<!DOCTYPE html><html lang="en-US-x-hixie"><head><meta charset="utf-8"><meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"><title>HTML Standard</title><meta content="#3c790a" name="theme-color"><meta content="light dark" name="color-scheme"><link rel="stylesheet" href="https://resources.whatwg.org/standard-shared-with-dev.css" crossorigin=""><link rel="stylesheet" href="https://resources.whatwg.org/standard.css" crossorigin=""><link rel="stylesheet" href="https://resources.whatwg.org/spec.css" crossorigin=""><link rel="icon" href="https://resources.whatwg.org/logo.svg" crossorigin=""><link rel="stylesheet" href="/styles.css" crossorigin=""><script>
   function toggleStatus(div) {
     div.parentNode.classList.toggle('wrapped');
   }
   function setLinkFragment(link) {
     link.hash = location.hash;
   }
  </script></head><body>
  
  <script defer="" src="/html-dfn.js" crossorigin=""></script>
  <script defer="" src="/var-click-highlighting.js" crossorigin=""></script>
  <script crossorigin="" defer="" src="https://resources.whatwg.org/commit-snapshot-shortcut-key.js"></script>
  <header id="head" class="head with-buttons">
   <a href="https://whatwg.org/" class="logo"><img width="100" alt="WHATWG" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/logo.svg" height="100"></a>
   <hgroup><h1 class="allcaps">HTML</h1><p id="living-standard">Living Standard — Last Updated <span class="pubdate">4 November 2025</span></p></hgroup>
   
   <nav>
    
    <div>
     
     <a href="/"><span><strong>One-Page Version</strong> <code>html.spec.whatwg.org</code></span></a>
     <a onclick="setLinkFragment(this);" href="/multipage/" id="multipage-link"><span><strong>Multipage Version</strong> <code>/multipage</code></span></a>
     <a onclick="setLinkFragment(this);" href="/dev/"><span><strong>Version for Web Devs</strong> <code>/dev</code></span></a>
     <a href="/print.pdf"><span><strong>PDF Version</strong> <code>/print.pdf</code></span></a>
     <a href="https://github.com/whatwg/html/wiki/Translations"><span><strong>Translations</strong> <code>日本語 • 简体中文</code></span></a>
    </div>
    <div>
     <a href="https://github.com/whatwg/html/blob/main/FAQ.md" class="misc"><span><strong>FAQ</strong> <code>on GitHub</code></span></a>
     <a href="https://whatwg.org/chat" class="comms"><span><strong>Chat</strong> <code>on Matrix</code></span></a>
    </div>
    <div>
     <a href="https://github.com/whatwg/html" class="changes"><span><strong>Contribute on GitHub</strong> <code>whatwg/html repository</code></span></a>
     <a href="https://github.com/whatwg/html/commits" class="changes"><span><strong>Commits</strong> <code>on GitHub</code></span></a>
     <a id="commit-snapshot-link" href="/commit-snapshots/0e5e7c9eee4f02e2c43dfbccedd798b692f35a0c/" class="changes"><span><strong>Snapshot</strong> <code>as of this commit</code></span></a>
     <a href="https://twitter.com/htmlstandard" class="changes"><span><strong>Twitter Updates</strong> <code>@htmlstandard</code></span></a>
    </div>
    <div>
     <a href="https://github.com/whatwg/html/issues" class="feedback"><span><strong>Open Issues</strong> <code>filed on GitHub</code></span></a>
     <a href="https://whatwg.org/newbug" class="feedback"><span><strong>Open an Issue</strong> <code>whatwg.org/newbug</code></span></a>
     <a href="https://github.com/web-platform-tests/wpt/tree/master/html" class="feedback"><span><strong>Tests</strong> <code>web-platform-tests html/</code></span></a>
     <a href="https://github.com/web-platform-tests/wpt/labels/html" class="feedback"><span><strong>Issues for Tests</strong> <code>ongoing work</code></span></a>
    </div>
   </nav>

   
  </header>

  

  

  <hr>

  <h2 id="table-of-contents" class="no-num no-toc">Table of contents</h2>
  <ol class="brief toc"><li><a href="#toc-introduction"><span class="secno">1</span> Introduction</a></li><li><a href="#toc-infrastructure"><span class="secno">2</span> Common infrastructure</a></li><li><a href="#toc-dom"><span class="secno">3</span> Semantics, structure, and APIs of HTML documents</a></li><li><a href="#toc-semantics"><span class="secno">4</span> The elements of HTML</a></li><li><a href="#toc-microdata"><span class="secno">5</span> Microdata</a></li><li><a href="#toc-editing"><span class="secno">6</span> User interaction</a></li><li><a href="#toc-browsers"><span class="secno">7</span> Loading web pages</a></li><li><a href="#toc-webappapis"><span class="secno">8</span> Web application APIs</a></li><li><a href="#toc-comms"><span class="secno">9</span> Communication</a></li><li><a href="#toc-workers"><span class="secno">10</span> Web workers</a></li><li><a href="#toc-worklets"><span class="secno">11</span> Worklets</a></li><li><a href="#toc-webstorage"><span class="secno">12</span> Web storage</a></li><li><a href="#toc-syntax"><span class="secno">13</span> The HTML syntax</a></li><li><a href="#toc-the-xhtml-syntax"><span class="secno">14</span> The XML syntax</a></li><li><a href="#toc-rendering"><span class="secno">15</span> Rendering</a></li><li><a href="#toc-obsolete"><span class="secno">16</span> Obsolete features</a></li><li><a href="#toc-iana"><span class="secno">17</span> IANA considerations</a></li><li><a href="#toc-index">Index</a></li><li><a href="#toc-references">References</a></li><li><a href="#toc-acknowledgments">Acknowledgments</a></li><li><a href="#toc-ipr">Intellectual property rights</a></li></ol>

  <h2 id="contents" class="no-num no-toc">Full table of contents</h2>
  <ol class="toc"><li id="toc-introduction"><a href="#introduction"><span class="secno">1</span> Introduction</a><ol><li><a href="#abstract"><span class="secno">1.1</span> Where does this specification fit?</a></li><li><a href="#is-this-html5?"><span class="secno">1.2</span> Is this HTML5?</a></li><li><a href="#background"><span class="secno">1.3</span> Background</a></li><li><a href="#audience"><span class="secno">1.4</span> Audience</a></li><li><a href="#scope"><span class="secno">1.5</span> Scope</a></li><li><a href="#history-2"><span class="secno">1.6</span> History</a></li><li><a href="#design-notes"><span class="secno">1.7</span> Design notes</a><ol><li><a href="#serialisability-of-script-execution"><span class="secno">1.7.1</span> Serializability of script execution</a></li><li><a href="#extensibility"><span class="secno">1.7.2</span> Extensibility</a></li></ol></li><li><a href="#html-vs-xhtml"><span class="secno">1.8</span> HTML vs XML syntax</a></li><li><a href="#structure-of-this-specification"><span class="secno">1.9</span> Structure of this specification</a><ol><li><a href="#how-to-read-this-specification"><span class="secno">1.9.1</span> How to read this specification</a></li><li><a href="#typographic-conventions"><span class="secno">1.9.2</span> Typographic conventions</a></li></ol></li><li><a href="#a-quick-introduction-to-html"><span class="secno">1.10</span> A quick introduction to HTML</a><ol><li><a href="#writing-secure-applications-with-html"><span class="secno">1.10.1</span> Writing secure applications with HTML</a></li><li><a href="#common-pitfalls-to-avoid-when-using-the-scripting-apis"><span class="secno">1.10.2</span> Common pitfalls to avoid when using the scripting APIs</a></li><li><a href="#how-to-catch-mistakes-when-writing-html:-validators-and-conformance-checkers"><span class="secno">1.10.3</span> How to catch mistakes when writing HTML: validators and conformance checkers</a></li></ol></li><li><a href="#conformance-requirements-for-authors"><span class="secno">1.11</span> Conformance requirements for authors</a><ol><li><a href="#presentational-markup"><span class="secno">1.11.1</span> Presentational markup</a></li><li><a href="#syntax-errors"><span class="secno">1.11.2</span> Syntax errors</a></li><li><a href="#restrictions-on-content-models-and-on-attribute-values"><span class="secno">1.11.3</span> Restrictions on content models and on attribute values</a></li></ol></li><li><a href="#suggested-reading"><span class="secno">1.12</span> Suggested reading</a></li></ol></li><li id="toc-infrastructure"><a href="#infrastructure"><span class="secno">2</span> Common infrastructure</a><ol><li><a href="#terminology"><span class="secno">2.1</span> Terminology</a><ol><li><a href="#parallelism"><span class="secno">2.1.1</span> Parallelism</a></li><li><a href="#resources"><span class="secno">2.1.2</span> Resources</a></li><li><a href="#xml"><span class="secno">2.1.3</span> XML compatibility</a></li><li><a href="#dom-trees"><span class="secno">2.1.4</span> DOM trees</a></li><li><a href="#scripting-2"><span class="secno">2.1.5</span> Scripting</a></li><li><a href="#plugins"><span class="secno">2.1.6</span> Plugins</a></li><li><a href="#encoding-terminology"><span class="secno">2.1.7</span> Character encodings</a></li><li><a href="#conformance-classes"><span class="secno">2.1.8</span> Conformance classes</a></li><li><a href="#dependencies"><span class="secno">2.1.9</span> Dependencies</a></li><li><a href="#extensibility-2"><span class="secno">2.1.10</span> Extensibility</a></li><li><a href="#interactions-with-xpath-and-xslt"><span class="secno">2.1.11</span> Interactions with XPath and XSLT</a></li></ol></li><li><a href="#policy-controlled-features"><span class="secno">2.2</span> Policy-controlled features</a></li><li><a href="#common-microsyntaxes"><span class="secno">2.3</span> Common microsyntaxes</a><ol><li><a href="#common-parser-idioms"><span class="secno">2.3.1</span> Common parser idioms</a></li><li><a href="#boolean-attributes"><span class="secno">2.3.2</span> Boolean attributes</a></li><li><a href="#keywords-and-enumerated-attributes"><span class="secno">2.3.3</span> Keywords and enumerated attributes</a></li><li><a href="#numbers"><span class="secno">2.3.4</span> Numbers</a><ol><li><a href="#signed-integers"><span class="secno">2.3.4.1</span> Signed integers</a></li><li><a href="#non-negative-integers"><span class="secno">2.3.4.2</span> Non-negative integers</a></li><li><a href="#floating-point-numbers"><span class="secno">2.3.4.3</span> Floating-point numbers</a></li><li><a href="#percentages-and-dimensions"><span class="secno">2.3.4.4</span> Percentages and lengths</a></li><li><a href="#nonzero-percentages-and-lengths"><span class="secno">2.3.4.5</span> Nonzero percentages and lengths</a></li><li><a href="#lists-of-floating-point-numbers"><span class="secno">2.3.4.6</span> Lists of floating-point numbers</a></li><li><a href="#lists-of-dimensions"><span class="secno">2.3.4.7</span> Lists of dimensions</a></li></ol></li><li><a href="#dates-and-times"><span class="secno">2.3.5</span> Dates and times</a><ol><li><a href="#months"><span class="secno">2.3.5.1</span> Months</a></li><li><a href="#dates"><span class="secno">2.3.5.2</span> Dates</a></li><li><a href="#yearless-dates"><span class="secno">2.3.5.3</span> Yearless dates</a></li><li><a href="#times"><span class="secno">2.3.5.4</span> Times</a></li><li><a href="#local-dates-and-times"><span class="secno">2.3.5.5</span> Local dates and times</a></li><li><a href="#time-zones"><span class="secno">2.3.5.6</span> Time zones</a></li><li><a href="#global-dates-and-times"><span class="secno">2.3.5.7</span> Global dates and times</a></li><li><a href="#weeks"><span class="secno">2.3.5.8</span> Weeks</a></li><li><a href="#durations"><span class="secno">2.3.5.9</span> Durations</a></li><li><a href="#vaguer-moments-in-time"><span class="secno">2.3.5.10</span> Vaguer moments in time</a></li></ol></li><li><a href="#colours"><span class="secno">2.3.6</span> Legacy colors</a></li><li><a href="#space-separated-tokens"><span class="secno">2.3.7</span> Space-separated tokens</a></li><li><a href="#comma-separated-tokens"><span class="secno">2.3.8</span> Comma-separated tokens</a></li><li><a href="#syntax-references"><span class="secno">2.3.9</span> References</a></li><li><a href="#mq"><span class="secno">2.3.10</span> Media queries</a></li><li><a href="#unique-values"><span class="secno">2.3.11</span> Unique internal values</a></li></ol></li><li><a href="#urls"><span class="secno">2.4</span> URLs</a><ol><li><a href="#terminology-2"><span class="secno">2.4.1</span> Terminology</a></li><li><a href="#resolving-urls"><span class="secno">2.4.2</span> Parsing URLs</a></li><li><a href="#document-base-urls"><span class="secno">2.4.3</span> Document base URLs</a></li></ol></li><li><a href="#fetching-resources"><span class="secno">2.5</span> Fetching resources</a><ol><li><a href="#terminology-3"><span class="secno">2.5.1</span> Terminology</a></li><li><a href="#content-type-sniffing"><span class="secno">2.5.2</span> Determining the type of a resource</a></li><li><a href="#extracting-character-encodings-from-meta-elements"><span class="secno">2.5.3</span> Extracting character encodings from <code>meta</code> elements</a></li><li><a href="#cors-settings-attributes"><span class="secno">2.5.4</span> CORS settings attributes</a></li><li><a href="#referrer-policy-attributes"><span class="secno">2.5.5</span> Referrer policy attributes</a></li><li><a href="#nonce-attributes"><span class="secno">2.5.6</span> Nonce attributes</a></li><li><a href="#lazy-loading-attributes"><span class="secno">2.5.7</span> Lazy loading attributes</a></li><li><a href="#blocking-attributes"><span class="secno">2.5.8</span> Blocking attributes</a></li><li><a href="#fetch-priority-attributes"><span class="secno">2.5.9</span> Fetch priority attributes</a></li></ol></li><li><a href="#common-dom-interfaces"><span class="secno">2.6</span> Common DOM interfaces</a><ol><li><a href="#reflecting-content-attributes-in-idl-attributes"><span class="secno">2.6.1</span> Reflecting content attributes in IDL attributes</a></li><li><a href="#using-reflect-via-idl-extended-attributes"><span class="secno">2.6.2</span> Using reflect via IDL extended attributes</a></li><li><a href="#using-reflect-in-specifications"><span class="secno">2.6.3</span> Using reflect in specifications</a></li><li><a href="#collections"><span class="secno">2.6.4</span> Collections</a><ol><li><a href="#the-htmlallcollection-interface"><span class="secno">2.6.4.1</span> The <code>HTMLAllCollection</code> interface</a><ol><li><a href="#HTMLAllCollection-call"><span class="secno">2.6.4.1.1</span> [[Call]] ( <var>thisArgument</var>, <var>argumentsList</var> )</a></li></ol></li><li><a href="#the-htmlformcontrolscollection-interface"><span class="secno">2.6.4.2</span> The <code>HTMLFormControlsCollection</code> interface</a></li><li><a href="#the-htmloptionscollection-interface"><span class="secno">2.6.4.3</span> The <code>HTMLOptionsCollection</code> interface</a></li></ol></li><li><a href="#the-domstringlist-interface"><span class="secno">2.6.5</span> The <code>DOMStringList</code> interface</a></li></ol></li><li><a href="#safe-passing-of-structured-data"><span class="secno">2.7</span> Safe passing of structured data</a><ol><li><a href="#serializable-objects"><span class="secno">2.7.1</span> Serializable objects</a></li><li><a href="#transferable-objects"><span class="secno">2.7.2</span> Transferable objects</a></li><li><a href="#structuredserializeinternal"><span class="secno">2.7.3</span> StructuredSerializeInternal ( <var>value</var>, <var>forStorage</var> [ ,
  <var>memory</var> ] )</a></li><li><a href="#structuredserialize"><span class="secno">2.7.4</span> StructuredSerialize ( <var>value</var> )</a></li><li><a href="#structuredserializeforstorage"><span class="secno">2.7.5</span> StructuredSerializeForStorage ( <var>value</var> )</a></li><li><a href="#structureddeserialize"><span class="secno">2.7.6</span> StructuredDeserialize ( <var>serialized</var>, <var>targetRealm</var> [ ,
  <var>memory</var> ] )</a></li><li><a href="#structuredserializewithtransfer"><span class="secno">2.7.7</span> StructuredSerializeWithTransfer ( <var>value</var>, <var>transferList</var>
  )</a></li><li><a href="#structureddeserializewithtransfer"><span class="secno">2.7.8</span> StructuredDeserializeWithTransfer ( <var>serializeWithTransferResult</var>,
  <var>targetRealm</var> )</a></li><li><a href="#performing-structured-clones-from-other-specifications"><span class="secno">2.7.9</span> Performing serialization and
  transferring from other specifications</a></li><li><a href="#structured-cloning"><span class="secno">2.7.10</span> Structured cloning API</a></li></ol></li></ol></li><li id="toc-dom"><a href="#dom"><span class="secno">3</span> Semantics, structure, and APIs of HTML documents</a><ol><li><a href="#documents"><span class="secno">3.1</span> Documents</a><ol><li><a href="#the-document-object"><span class="secno">3.1.1</span> The <code>Document</code> object</a></li><li><a href="#the-documentorshadowroot-interface"><span class="secno">3.1.2</span> The <code>DocumentOrShadowRoot</code> interface</a></li><li><a href="#resource-metadata-management"><span class="secno">3.1.3</span> Resource metadata management</a></li><li><a href="#reporting-document-loading-status"><span class="secno">3.1.4</span> Reporting document loading status</a></li><li><a href="#render-blocking-mechanism"><span class="secno">3.1.5</span> Render-blocking mechanism</a></li><li><a href="#dom-tree-accessors"><span class="secno">3.1.6</span> DOM tree accessors</a></li></ol></li><li><a href="#elements"><span class="secno">3.2</span> Elements</a><ol><li><a href="#semantics-2"><span class="secno">3.2.1</span> Semantics</a></li><li><a href="#elements-in-the-dom"><span class="secno">3.2.2</span> Elements in the DOM</a></li><li><a href="#html-element-constructors"><span class="secno">3.2.3</span> HTML element constructors</a></li><li><a href="#element-definitions"><span class="secno">3.2.4</span> Element definitions</a><ol><li><a href="#attributes"><span class="secno">3.2.4.1</span> Attributes</a></li></ol></li><li><a href="#content-models"><span class="secno">3.2.5</span> Content models</a><ol><li><a href="#the-nothing-content-model"><span class="secno">3.2.5.1</span> The "nothing" content model</a></li><li><a href="#kinds-of-content"><span class="secno">3.2.5.2</span> Kinds of content</a><ol><li><a href="#metadata-content"><span class="secno">3.2.5.2.1</span> Metadata content</a></li><li><a href="#flow-content"><span class="secno">3.2.5.2.2</span> Flow content</a></li><li><a href="#sectioning-content"><span class="secno">3.2.5.2.3</span> Sectioning content</a></li><li><a href="#heading-content"><span class="secno">3.2.5.2.4</span> Heading content</a></li><li><a href="#phrasing-content"><span class="secno">3.2.5.2.5</span> Phrasing content</a></li><li><a href="#embedded-content-2"><span class="secno">3.2.5.2.6</span> Embedded content</a></li><li><a href="#interactive-content"><span class="secno">3.2.5.2.7</span> Interactive content</a></li><li><a href="#palpable-content"><span class="secno">3.2.5.2.8</span> Palpable content</a></li><li><a href="#script-supporting-elements"><span class="secno">3.2.5.2.9</span> Script-supporting elements</a></li><li><a href="#select-element-inner-content-elements"><span class="secno">3.2.5.2.10</span> <code>select</code> element inner content elements</a></li><li><a href="#optgroup-element-inner-content-elements"><span class="secno">3.2.5.2.11</span> <code>optgroup</code> element inner content elements</a></li><li><a href="#option-element-inner-content-elements"><span class="secno">3.2.5.2.12</span> <code>option</code> element inner content elements</a></li></ol></li><li><a href="#transparent-content-models"><span class="secno">3.2.5.3</span> Transparent content models</a></li><li><a href="#paragraphs"><span class="secno">3.2.5.4</span> Paragraphs</a></li></ol></li><li><a href="#global-attributes"><span class="secno">3.2.6</span> Global attributes</a><ol><li><a href="#the-title-attribute"><span class="secno">3.2.6.1</span> The <code>title</code> attribute</a></li><li><a href="#the-lang-and-xml:lang-attributes"><span class="secno">3.2.6.2</span> The <code>lang</code> and <code>xml:lang</code>
  attributes</a></li><li><a href="#the-translate-attribute"><span class="secno">3.2.6.3</span> The <code>translate</code> attribute</a></li><li><a href="#the-dir-attribute"><span class="secno">3.2.6.4</span> The <code>dir</code> attribute</a></li><li><a href="#the-style-attribute"><span class="secno">3.2.6.5</span> The <code>style</code> attribute</a></li><li><a href="#embedding-custom-non-visible-data-with-the-data-*-attributes"><span class="secno">3.2.6.6</span> Embedding custom non-visible data with the <code>data-*</code> attributes</a></li></ol></li><li><a href="#the-innertext-idl-attribute"><span class="secno">3.2.7</span> The <code>innerText</code> and <code>outerText</code> properties</a></li><li><a href="#requirements-relating-to-the-bidirectional-algorithm"><span class="secno">3.2.8</span> Requirements relating to the bidirectional algorithm</a><ol><li><a href="#authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters"><span class="secno">3.2.8.1</span> Authoring conformance criteria for bidirectional-algorithm formatting characters</a></li><li><a href="#user-agent-conformance-criteria"><span class="secno">3.2.8.2</span> User agent conformance criteria</a></li></ol></li><li><a href="#wai-aria"><span class="secno">3.2.9</span> Requirements related to ARIA and to platform accessibility APIs</a></li></ol></li></ol></li><li id="toc-semantics"><a href="#semantics"><span class="secno">4</span> The elements of HTML</a><ol><li><a href="#the-root-element"><span class="secno">4.1</span> The document element</a><ol><li><a href="#the-html-element"><span class="secno">4.1.1</span> The <code>html</code> element</a></li></ol></li><li><a href="#document-metadata"><span class="secno">4.2</span> Document metadata</a><ol><li><a href="#the-head-element"><span class="secno">4.2.1</span> The <code>head</code> element</a></li><li><a href="#the-title-element"><span class="secno">4.2.2</span> The <code>title</code> element</a></li><li><a href="#the-base-element"><span class="secno">4.2.3</span> The <code>base</code> element</a></li><li><a href="#the-link-element"><span class="secno">4.2.4</span> The <code>link</code> element</a><ol><li><a href="#processing-the-media-attribute"><span class="secno">4.2.4.1</span> Processing the <code>media</code> attribute</a></li><li><a href="#processing-the-type-attribute"><span class="secno">4.2.4.2</span> Processing the <code>type</code> attribute</a></li><li><a href="#fetching-and-processing-a-resource-from-a-link-element"><span class="secno">4.2.4.3</span> Fetching and processing a resource
  from a <code>link</code> element</a></li><li><a href="#processing-link-headers"><span class="secno">4.2.4.4</span> Processing `<code>Link</code>` headers</a></li><li><a href="#early-hints"><span class="secno">4.2.4.5</span> Early hints</a></li><li><a href="#providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element"><span class="secno">4.2.4.6</span> Providing users with a means to follow hyperlinks created using the <code>link</code>
  element</a></li></ol></li><li><a href="#the-meta-element"><span class="secno">4.2.5</span> The <code>meta</code>
  element</a><ol><li><a href="#standard-metadata-names"><span class="secno">4.2.5.1</span> Standard metadata names</a></li><li><a href="#other-metadata-names"><span class="secno">4.2.5.2</span> Other metadata names</a></li><li><a href="#pragma-directives"><span class="secno">4.2.5.3</span> Pragma directives</a></li><li><a href="#charset"><span class="secno">4.2.5.4</span> Specifying the document's character encoding</a></li></ol></li><li><a href="#the-style-element"><span class="secno">4.2.6</span> The <code>style</code> element</a></li><li><a href="#interactions-of-styling-and-scripting"><span class="secno">4.2.7</span> Interactions of styling and scripting</a></li></ol></li><li><a href="#sections"><span class="secno">4.3</span> Sections</a><ol><li><a href="#the-body-element"><span class="secno">4.3.1</span> The <code>body</code> element</a></li><li><a href="#the-article-element"><span class="secno">4.3.2</span> The <code>article</code> element</a></li><li><a href="#the-section-element"><span class="secno">4.3.3</span> The <code>section</code> element</a></li><li><a href="#the-nav-element"><span class="secno">4.3.4</span> The <code>nav</code> element</a></li><li><a href="#the-aside-element"><span class="secno">4.3.5</span> The <code>aside</code> element</a></li><li><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><span class="secno">4.3.6</span> The <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, and <code>h6</code>
  elements</a></li><li><a href="#the-hgroup-element"><span class="secno">4.3.7</span> The <code>hgroup</code> element</a></li><li><a href="#the-header-element"><span class="secno">4.3.8</span> The <code>header</code> element</a></li><li><a href="#the-footer-element"><span class="secno">4.3.9</span> The <code>footer</code> element</a></li><li><a href="#the-address-element"><span class="secno">4.3.10</span> The <code>address</code> element</a></li><li><a href="#headings-and-outlines-2"><span class="secno">4.3.11</span> Headings and outlines</a><ol><li><a href="#heading-levels-&amp;-offsets"><span class="secno">4.3.11.1</span> Heading levels &amp; offsets</a></li><li><a href="#sample-outlines"><span class="secno">4.3.11.2</span> Sample outlines</a></li><li><a href="#exposing-outlines-to-users"><span class="secno">4.3.11.3</span> Exposing outlines to users</a></li></ol></li><li><a href="#usage-summary-2"><span class="secno">4.3.12</span> Usage summary</a><ol><li><a href="#article-or-section"><span class="secno">4.3.12.1</span> Article or section?</a></li></ol></li></ol></li><li><a href="#grouping-content"><span class="secno">4.4</span> Grouping content</a><ol><li><a href="#the-p-element"><span class="secno">4.4.1</span> The <code>p</code> element</a></li><li><a href="#the-hr-element"><span class="secno">4.4.2</span> The <code>hr</code> element</a></li><li><a href="#the-pre-element"><span class="secno">4.4.3</span> The <code>pre</code> element</a></li><li><a href="#the-blockquote-element"><span class="secno">4.4.4</span> The <code>blockquote</code> element</a></li><li><a href="#the-ol-element"><span class="secno">4.4.5</span> The <code>ol</code> element</a></li><li><a href="#the-ul-element"><span class="secno">4.4.6</span> The <code>ul</code> element</a></li><li><a href="#the-menu-element"><span class="secno">4.4.7</span> The <code>menu</code> element</a></li><li><a href="#the-li-element"><span class="secno">4.4.8</span> The <code>li</code> element</a></li><li><a href="#the-dl-element"><span class="secno">4.4.9</span> The <code>dl</code> element</a></li><li><a href="#the-dt-element"><span class="secno">4.4.10</span> The <code>dt</code> element</a></li><li><a href="#the-dd-element"><span class="secno">4.4.11</span> The <code>dd</code> element</a></li><li><a href="#the-figure-element"><span class="secno">4.4.12</span> The <code>figure</code> element</a></li><li><a href="#the-figcaption-element"><span class="secno">4.4.13</span> The <code>figcaption</code> element</a></li><li><a href="#the-main-element"><span class="secno">4.4.14</span> The <code>main</code> element</a></li><li><a href="#the-search-element"><span class="secno">4.4.15</span> The <code>search</code> element</a></li><li><a href="#the-div-element"><span class="secno">4.4.16</span> The <code>div</code> element</a></li></ol></li><li><a href="#text-level-semantics"><span class="secno">4.5</span> Text-level semantics</a><ol><li><a href="#the-a-element"><span class="secno">4.5.1</span> The <code>a</code> element</a></li><li><a href="#the-em-element"><span class="secno">4.5.2</span> The <code>em</code> element</a></li><li><a href="#the-strong-element"><span class="secno">4.5.3</span> The <code>strong</code> element</a></li><li><a href="#the-small-element"><span class="secno">4.5.4</span> The <code>small</code> element</a></li><li><a href="#the-s-element"><span class="secno">4.5.5</span> The <code>s</code> element</a></li><li><a href="#the-cite-element"><span class="secno">4.5.6</span> The <code>cite</code> element</a></li><li><a href="#the-q-element"><span class="secno">4.5.7</span> The <code>q</code> element</a></li><li><a href="#the-dfn-element"><span class="secno">4.5.8</span> The <code>dfn</code> element</a></li><li><a href="#the-abbr-element"><span class="secno">4.5.9</span> The <code>abbr</code> element</a></li><li><a href="#the-ruby-element"><span class="secno">4.5.10</span> The <code>ruby</code> element</a></li><li><a href="#the-rt-element"><span class="secno">4.5.11</span> The <code>rt</code> element</a></li><li><a href="#the-rp-element"><span class="secno">4.5.12</span> The <code>rp</code> element</a></li><li><a href="#the-data-element"><span class="secno">4.5.13</span> The <code>data</code> element</a></li><li><a href="#the-time-element"><span class="secno">4.5.14</span> The <code>time</code> element</a></li><li><a href="#the-code-element"><span class="secno">4.5.15</span> The <code>code</code> element</a></li><li><a href="#the-var-element"><span class="secno">4.5.16</span> The <code>var</code> element</a></li><li><a href="#the-samp-element"><span class="secno">4.5.17</span> The <code>samp</code> element</a></li><li><a href="#the-kbd-element"><span class="secno">4.5.18</span> The <code>kbd</code> element</a></li><li><a href="#the-sub-and-sup-elements"><span class="secno">4.5.19</span> The <code>sub</code> and <code>sup</code> elements</a></li><li><a href="#the-i-element"><span class="secno">4.5.20</span> The <code>i</code> element</a></li><li><a href="#the-b-element"><span class="secno">4.5.21</span> The <code>b</code> element</a></li><li><a href="#the-u-element"><span class="secno">4.5.22</span> The <code>u</code> element</a></li><li><a href="#the-mark-element"><span class="secno">4.5.23</span> The <code>mark</code> element</a></li><li><a href="#the-bdi-element"><span class="secno">4.5.24</span> The <code>bdi</code> element</a></li><li><a href="#the-bdo-element"><span class="secno">4.5.25</span> The <code>bdo</code> element</a></li><li><a href="#the-span-element"><span class="secno">4.5.26</span> The <code>span</code> element</a></li><li><a href="#the-br-element"><span class="secno">4.5.27</span> The <code>br</code> element</a></li><li><a href="#the-wbr-element"><span class="secno">4.5.28</span> The <code>wbr</code> element</a></li><li><a href="#usage-summary"><span class="secno">4.5.29</span> Usage summary</a></li></ol></li><li><a href="#links"><span class="secno">4.6</span> Links</a><ol><li><a href="#introduction-2"><span class="secno">4.6.1</span> Introduction</a></li><li><a href="#links-created-by-a-and-area-elements"><span class="secno">4.6.2</span> Links created by <code>a</code> and <code>area</code> elements</a></li><li><a href="#api-for-a-and-area-elements"><span class="secno">4.6.3</span> API for <code>a</code> and <code>area</code> elements</a></li><li><a href="#following-hyperlinks"><span class="secno">4.6.4</span> Following hyperlinks</a></li><li><a href="#downloading-resources"><span class="secno">4.6.5</span> Downloading resources</a></li><li><a href="#hyperlink-auditing"><span class="secno">4.6.6</span> Hyperlink auditing</a><ol><li><a href="#the-ping-headers"><span class="secno">4.6.6.1</span> The `<code>Ping-From</code>` and `<code>Ping-To</code>` headers</a></li></ol></li><li><a href="#linkTypes"><span class="secno">4.6.7</span> Link types</a><ol><li><a href="#rel-alternate"><span class="secno">4.6.7.1</span> Link type "<code>alternate</code>"</a></li><li><a href="#link-type-author"><span class="secno">4.6.7.2</span> Link type "<code>author</code>"</a></li><li><a href="#link-type-bookmark"><span class="secno">4.6.7.3</span> Link type "<code>bookmark</code>"</a></li><li><a href="#link-type-canonical"><span class="secno">4.6.7.4</span> Link type "<code>canonical</code>"</a></li><li><a href="#link-type-dns-prefetch"><span class="secno">4.6.7.5</span> Link type "<code>dns-prefetch</code>"</a></li><li><a href="#link-type-expect"><span class="secno">4.6.7.6</span> Link type "<code>expect</code>"</a></li><li><a href="#link-type-external"><span class="secno">4.6.7.7</span> Link type "<code>external</code>"</a></li><li><a href="#link-type-help"><span class="secno">4.6.7.8</span> Link type "<code>help</code>"</a></li><li><a href="#rel-icon"><span class="secno">4.6.7.9</span> Link type "<code>icon</code>"</a></li><li><a href="#link-type-license"><span class="secno">4.6.7.10</span> Link type "<code>license</code>"</a></li><li><a href="#link-type-manifest"><span class="secno">4.6.7.11</span> Link type "<code>manifest</code>"</a></li><li><a href="#link-type-modulepreload"><span class="secno">4.6.7.12</span> Link type "<code>modulepreload</code>"</a></li><li><a href="#link-type-nofollow"><span class="secno">4.6.7.13</span> Link type "<code>nofollow</code>"</a></li><li><a href="#link-type-noopener"><span class="secno">4.6.7.14</span> Link type "<code>noopener</code>"</a></li><li><a href="#link-type-noreferrer"><span class="secno">4.6.7.15</span> Link type "<code>noreferrer</code>"</a></li><li><a href="#link-type-opener"><span class="secno">4.6.7.16</span> Link type "<code>opener</code>"</a></li><li><a href="#link-type-pingback"><span class="secno">4.6.7.17</span> Link type "<code>pingback</code>"</a></li><li><a href="#link-type-preconnect"><span class="secno">4.6.7.18</span> Link type "<code>preconnect</code>"</a></li><li><a href="#link-type-prefetch"><span class="secno">4.6.7.19</span> Link type "<code>prefetch</code>"</a></li><li><a href="#link-type-preload"><span class="secno">4.6.7.20</span> Link type "<code>preload</code>"</a></li><li><a href="#link-type-privacy-policy"><span class="secno">4.6.7.21</span> Link type "<code>privacy-policy</code>"</a></li><li><a href="#link-type-search"><span class="secno">4.6.7.22</span> Link type "<code>search</code>"</a></li><li><a href="#link-type-stylesheet"><span class="secno">4.6.7.23</span> Link type "<code>stylesheet</code>"</a></li><li><a href="#link-type-tag"><span class="secno">4.6.7.24</span> Link type "<code>tag</code>"</a></li><li><a href="#link-type-terms-of-service"><span class="secno">4.6.7.25</span> Link Type "<code>terms-of-service</code>"</a></li><li><a href="#sequential-link-types"><span class="secno">4.6.7.26</span> Sequential link types</a><ol><li><a href="#link-type-next"><span class="secno">4.6.7.26.1</span> Link type "<code>next</code>"</a></li><li><a href="#link-type-prev"><span class="secno">4.6.7.26.2</span> Link type "<code>prev</code>"</a></li></ol></li><li><a href="#other-link-types"><span class="secno">4.6.7.27</span> Other link types</a></li></ol></li></ol></li><li><a href="#edits"><span class="secno">4.7</span> Edits</a><ol><li><a href="#the-ins-element"><span class="secno">4.7.1</span> The <code>ins</code> element</a></li><li><a href="#the-del-element"><span class="secno">4.7.2</span> The <code>del</code> element</a></li><li><a href="#attributes-common-to-ins-and-del-elements"><span class="secno">4.7.3</span> Attributes common to <code>ins</code> and <code>del</code> elements</a></li><li><a href="#edits-and-paragraphs"><span class="secno">4.7.4</span> Edits and paragraphs</a></li><li><a href="#edits-and-lists"><span class="secno">4.7.5</span> Edits and lists</a></li><li><a href="#edits-and-tables"><span class="secno">4.7.6</span> Edits and tables</a></li></ol></li><li><a href="#embedded-content"><span class="secno">4.8</span> Embedded content</a><ol><li><a href="#the-picture-element"><span class="secno">4.8.1</span> The <code>picture</code> element</a></li><li><a href="#the-source-element"><span class="secno">4.8.2</span> The <code>source</code> element</a></li><li><a href="#the-img-element"><span class="secno">4.8.3</span> The <code>img</code> element</a></li><li><a href="#images"><span class="secno">4.8.4</span> Images</a><ol><li><a href="#introduction-3"><span class="secno">4.8.4.1</span> Introduction</a><ol><li><a href="#adaptive-images"><span class="secno">4.8.4.1.1</span> Adaptive images</a></li></ol></li><li><a href="#attributes-common-to-source-and-img-elements"><span class="secno">4.8.4.2</span> Attributes common to <code>source</code>,
  <code>img</code>, and <code>link</code> elements</a><ol><li><a href="#srcset-attributes"><span class="secno">4.8.4.2.1</span> Srcset attributes</a></li><li><a href="#sizes-attributes"><span class="secno">4.8.4.2.2</span> Sizes attributes</a></li></ol></li><li><a href="#images-processing-model"><span class="secno">4.8.4.3</span> Processing model</a><ol><li><a href="#when-to-obtain-images"><span class="secno">4.8.4.3.1</span> When to obtain images</a></li><li><a href="#reacting-to-dom-mutations"><span class="secno">4.8.4.3.2</span> Reacting to DOM mutations</a></li><li><a href="#the-list-of-available-images"><span class="secno">4.8.4.3.3</span> The list of available images</a></li><li><a href="#decoding-images"><span class="secno">4.8.4.3.4</span> Decoding images</a></li><li><a href="#updating-the-image-data"><span class="secno">4.8.4.3.5</span> Updating the image data</a></li><li><a href="#preparing-an-image-for-presentation"><span class="secno">4.8.4.3.6</span> Preparing an image for presentation</a></li><li><a href="#selecting-an-image-source"><span class="secno">4.8.4.3.7</span> Selecting an image source</a></li><li><a href="#creating-a-source-set-from-attributes"><span class="secno">4.8.4.3.8</span> Creating a source set from attributes</a></li><li><a href="#updating-the-source-set"><span class="secno">4.8.4.3.9</span> Updating the source set</a></li><li><a href="#parsing-a-srcset-attribute"><span class="secno">4.8.4.3.10</span> Parsing a srcset attribute</a></li><li><a href="#parsing-a-sizes-attribute"><span class="secno">4.8.4.3.11</span> Parsing a sizes attribute</a></li><li><a href="#normalizing-the-source-densities"><span class="secno">4.8.4.3.12</span> Normalizing the source densities</a></li><li><a href="#reacting-to-environment-changes"><span class="secno">4.8.4.3.13</span> Reacting to environment changes</a></li></ol></li><li><a href="#alt"><span class="secno">4.8.4.4</span> Requirements for providing text to act as an alternative for images</a><ol><li><a href="#general-guidelines"><span class="secno">4.8.4.4.1</span> General guidelines</a></li><li><a href="#a-link-or-button-containing-nothing-but-the-image"><span class="secno">4.8.4.4.2</span> A link or button containing nothing but the image</a></li><li><a href="#a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations"><span class="secno">4.8.4.4.3</span> A phrase or paragraph with an alternative graphical representation: charts, diagrams, graphs, maps, illustrations</a></li><li><a href="#a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos"><span class="secno">4.8.4.4.4</span> A short phrase or label with an alternative graphical representation: icons, logos</a></li><li><a href="#text-that-has-been-rendered-to-a-graphic-for-typographical-effect"><span class="secno">4.8.4.4.5</span> Text that has been rendered to a graphic for typographical effect</a></li><li><a href="#a-graphical-representation-of-some-of-the-surrounding-text"><span class="secno">4.8.4.4.6</span> A graphical representation of some of the surrounding text</a></li><li><a href="#ancillary-images"><span class="secno">4.8.4.4.7</span> Ancillary images</a></li><li><a href="#a-purely-decorative-image-that-doesn't-add-any-information"><span class="secno">4.8.4.4.8</span> A purely decorative image that doesn't add any information</a></li><li><a href="#a-group-of-images-that-form-a-single-larger-picture-with-no-links"><span class="secno">4.8.4.4.9</span> A group of images that form a single larger picture with no links</a></li><li><a href="#a-group-of-images-that-form-a-single-larger-picture-with-links"><span class="secno">4.8.4.4.10</span> A group of images that form a single larger picture with links</a></li><li><a href="#a-key-part-of-the-content"><span class="secno">4.8.4.4.11</span> A key part of the content</a></li><li><a href="#an-image-not-intended-for-the-user"><span class="secno">4.8.4.4.12</span> An image not intended for the user</a></li><li><a href="#an-image-in-an-e-mail-or-private-document-intended-for-a-specific-person-who-is-known-to-be-able-to-view-images"><span class="secno">4.8.4.4.13</span> An image in an email or private document intended for a specific person who is known to be able to view images</a></li><li><a href="#guidance-for-markup-generators"><span class="secno">4.8.4.4.14</span> Guidance for markup generators</a></li><li><a href="#guidance-for-conformance-checkers"><span class="secno">4.8.4.4.15</span> Guidance for conformance checkers</a></li></ol></li></ol></li><li><a href="#the-iframe-element"><span class="secno">4.8.5</span> The
  <code>iframe</code> element</a></li><li><a href="#the-embed-element"><span class="secno">4.8.6</span> The <code>embed</code> element</a></li><li><a href="#the-object-element"><span class="secno">4.8.7</span> The <code>object</code> element</a></li><li><a href="#the-video-element"><span class="secno">4.8.8</span> The <code>video</code> element</a></li><li><a href="#the-audio-element"><span class="secno">4.8.9</span> The <code>audio</code> element</a></li><li><a href="#the-track-element"><span class="secno">4.8.10</span> The <code>track</code> element</a></li><li><a href="#media-elements"><span class="secno">4.8.11</span> Media elements</a><ol><li><a href="#error-codes"><span class="secno">4.8.11.1</span> Error codes</a></li><li><a href="#location-of-the-media-resource"><span class="secno">4.8.11.2</span> Location of the media resource</a></li><li><a href="#mime-types"><span class="secno">4.8.11.3</span> MIME types</a></li><li><a href="#network-states"><span class="secno">4.8.11.4</span> Network states</a></li><li><a href="#loading-the-media-resource"><span class="secno">4.8.11.5</span> Loading the media resource</a></li><li><a href="#offsets-into-the-media-resource"><span class="secno">4.8.11.6</span> Offsets into the media resource</a></li><li><a href="#ready-states"><span class="secno">4.8.11.7</span> Ready states</a></li><li><a href="#playing-the-media-resource"><span class="secno">4.8.11.8</span> Playing the media resource</a></li><li><a href="#seeking"><span class="secno">4.8.11.9</span> Seeking</a></li><li><a href="#media-resources-with-multiple-media-tracks"><span class="secno">4.8.11.10</span> Media resources with multiple media tracks</a><ol><li><a href="#audiotracklist-and-videotracklist-objects"><span class="secno">4.8.11.10.1</span> <code>AudioTrackList</code> and <code>VideoTrackList</code> objects</a></li><li><a href="#selecting-specific-audio-and-video-tracks-declaratively"><span class="secno">4.8.11.10.2</span> Selecting specific audio and video tracks declaratively</a></li></ol></li><li><a href="#timed-text-tracks"><span class="secno">4.8.11.11</span> Timed text tracks</a><ol><li><a href="#text-track-model"><span class="secno">4.8.11.11.1</span> Text track model</a></li><li><a href="#sourcing-in-band-text-tracks"><span class="secno">4.8.11.11.2</span> Sourcing in-band text tracks</a></li><li><a href="#sourcing-out-of-band-text-tracks"><span class="secno">4.8.11.11.3</span> Sourcing out-of-band text tracks</a></li><li><a href="#guidelines-for-exposing-cues-in-various-formats-as-text-track-cues"><span class="secno">4.8.11.11.4</span> Guidelines for exposing cues in various formats as text track cues</a></li><li><a href="#text-track-api"><span class="secno">4.8.11.11.5</span> Text track API</a></li><li><a href="#cue-events"><span class="secno">4.8.11.11.6</span> Event handlers for objects of the text track APIs</a></li><li><a href="#best-practices-for-metadata-text-tracks"><span class="secno">4.8.11.11.7</span> Best practices for metadata text tracks</a></li></ol></li><li><a href="#identifying-a-track-kind-through-a-url"><span class="secno">4.8.11.12</span> Identifying a track kind through a URL</a></li><li><a href="#user-interface"><span class="secno">4.8.11.13</span> User interface</a></li><li><a href="#time-ranges"><span class="secno">4.8.11.14</span> Time ranges</a></li><li><a href="#the-trackevent-interface"><span class="secno">4.8.11.15</span> The <code>TrackEvent</code> interface</a></li><li><a href="#mediaevents"><span class="secno">4.8.11.16</span> Events summary</a></li><li><a href="#security-and-privacy-considerations"><span class="secno">4.8.11.17</span> Security and privacy considerations</a></li><li><a href="#best-practices-for-authors-using-media-elements"><span class="secno">4.8.11.18</span> Best practices for authors using media elements</a></li><li><a href="#best-practices-for-implementers-of-media-elements"><span class="secno">4.8.11.19</span> Best practices for implementers of media elements</a></li></ol></li><li><a href="#the-map-element"><span class="secno">4.8.12</span> The <code>map</code> element</a></li><li><a href="#the-area-element"><span class="secno">4.8.13</span> The <code>area</code> element</a></li><li><a href="#image-maps"><span class="secno">4.8.14</span> Image maps</a><ol><li><a href="#authoring"><span class="secno">4.8.14.1</span> Authoring</a></li><li><a href="#image-map-processing-model"><span class="secno">4.8.14.2</span> Processing model</a></li></ol></li><li><a href="#mathml"><span class="secno">4.8.15</span> MathML</a></li><li><a href="#svg-0"><span class="secno">4.8.16</span> SVG</a></li><li><a href="#dimension-attributes"><span class="secno">4.8.17</span> Dimension attributes</a></li></ol></li><li><a href="#tables"><span class="secno">4.9</span> Tabular data</a><ol><li><a href="#the-table-element"><span class="secno">4.9.1</span> The <code>table</code> element</a><ol><li><a href="#table-descriptions-techniques"><span class="secno">4.9.1.1</span> Techniques for describing tables</a></li><li><a href="#table-layout-techniques"><span class="secno">4.9.1.2</span> Techniques for table design</a></li></ol></li><li><a href="#the-caption-element"><span class="secno">4.9.2</span> The <code>caption</code> element</a></li><li><a href="#the-colgroup-element"><span class="secno">4.9.3</span> The <code>colgroup</code> element</a></li><li><a href="#the-col-element"><span class="secno">4.9.4</span> The <code>col</code> element</a></li><li><a href="#the-tbody-element"><span class="secno">4.9.5</span> The <code>tbody</code> element</a></li><li><a href="#the-thead-element"><span class="secno">4.9.6</span> The <code>thead</code> element</a></li><li><a href="#the-tfoot-element"><span class="secno">4.9.7</span> The <code>tfoot</code> element</a></li><li><a href="#the-tr-element"><span class="secno">4.9.8</span> The <code>tr</code> element</a></li><li><a href="#the-td-element"><span class="secno">4.9.9</span> The <code>td</code> element</a></li><li><a href="#the-th-element"><span class="secno">4.9.10</span> The <code>th</code> element</a></li><li><a href="#attributes-common-to-td-and-th-elements"><span class="secno">4.9.11</span> Attributes common to <code>td</code> and <code>th</code> elements</a></li><li><a href="#table-processing-model"><span class="secno">4.9.12</span> Processing model</a><ol><li><a href="#forming-a-table"><span class="secno">4.9.12.1</span> Forming a table</a></li><li><a href="#header-and-data-cell-semantics"><span class="secno">4.9.12.2</span> Forming relationships between data cells and header cells</a></li></ol></li><li><a href="#table-examples"><span class="secno">4.9.13</span> Examples</a></li></ol></li><li><a href="#forms"><span class="secno">4.10</span> Forms</a><ol><li><a href="#introduction-4"><span class="secno">4.10.1</span> Introduction</a><ol><li><a href="#writing-a-form's-user-interface"><span class="secno">4.10.1.1</span> Writing a form's user interface</a></li><li><a href="#implementing-the-server-side-processing-for-a-form"><span class="secno">4.10.1.2</span> Implementing the server-side processing for a form</a></li><li><a href="#configuring-a-form-to-communicate-with-a-server"><span class="secno">4.10.1.3</span> Configuring a form to communicate with a server</a></li><li><a href="#client-side-form-validation"><span class="secno">4.10.1.4</span> Client-side form validation</a></li><li><a href="#enabling-client-side-automatic-filling-of-form-controls"><span class="secno">4.10.1.5</span> Enabling client-side automatic filling of form controls</a></li><li><a href="#improving-the-user-experience-on-mobile-devices"><span class="secno">4.10.1.6</span> Improving the user experience on mobile devices</a></li><li><a href="#the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality"><span class="secno">4.10.1.7</span> The difference between the field type, the autofill field name, and the input modality</a></li><li><a href="#input-author-notes"><span class="secno">4.10.1.8</span> Date, time, and number formats</a></li></ol></li><li><a href="#categories"><span class="secno">4.10.2</span> Categories</a></li><li><a href="#the-form-element"><span class="secno">4.10.3</span> The <code>form</code> element</a></li><li><a href="#the-label-element"><span class="secno">4.10.4</span> The <code>label</code> element</a></li><li><a href="#the-input-element"><span class="secno">4.10.5</span> The <code>input</code> element</a><ol><li><a href="#states-of-the-type-attribute"><span class="secno">4.10.5.1</span> States of the <code>type</code> attribute</a><ol><li><a href="#hidden-state-(type=hidden)"><span class="secno">4.10.5.1.1</span> Hidden state (<code>type=hidden</code>)</a></li><li><a href="#text-(type=text)-state-and-search-state-(type=search)"><span class="secno">4.10.5.1.2</span> Text (<code>type=text</code>) state and Search state (<code>type=search</code>)</a></li><li><a href="#telephone-state-(type=tel)"><span class="secno">4.10.5.1.3</span> Telephone state (<code>type=tel</code>)</a></li><li><a href="#url-state-(type=url)"><span class="secno">4.10.5.1.4</span> URL state (<code>type=url</code>)</a></li><li><a href="#email-state-(type=email)"><span class="secno">4.10.5.1.5</span> Email state (<code>type=email</code>)</a></li><li><a href="#password-state-(type=password)"><span class="secno">4.10.5.1.6</span> Password state (<code>type=password</code>)</a></li><li><a href="#date-state-(type=date)"><span class="secno">4.10.5.1.7</span> Date state (<code>type=date</code>)</a></li><li><a href="#month-state-(type=month)"><span class="secno">4.10.5.1.8</span> Month state (<code>type=month</code>)</a></li><li><a href="#week-state-(type=week)"><span class="secno">4.10.5.1.9</span> Week state (<code>type=week</code>)</a></li><li><a href="#time-state-(type=time)"><span class="secno">4.10.5.1.10</span> Time state (<code>type=time</code>)</a></li><li><a href="#local-date-and-time-state-(type=datetime-local)"><span class="secno">4.10.5.1.11</span> Local Date and Time state (<code>type=datetime-local</code>)</a></li><li><a href="#number-state-(type=number)"><span class="secno">4.10.5.1.12</span> Number state (<code>type=number</code>)</a></li><li><a href="#range-state-(type=range)"><span class="secno">4.10.5.1.13</span> Range state (<code>type=range</code>)</a></li><li><a href="#color-state-(type=color)"><span class="secno">4.10.5.1.14</span> Color state (<code>type=color</code>)</a></li><li><a href="#checkbox-state-(type=checkbox)"><span class="secno">4.10.5.1.15</span> Checkbox state (<code>type=checkbox</code>)</a></li><li><a href="#radio-button-state-(type=radio)"><span class="secno">4.10.5.1.16</span> Radio Button state (<code>type=radio</code>)</a></li><li><a href="#file-upload-state-(type=file)"><span class="secno">4.10.5.1.17</span> File Upload state (<code>type=file</code>)</a></li><li><a href="#submit-button-state-(type=submit)"><span class="secno">4.10.5.1.18</span> Submit Button state (<code>type=submit</code>)</a></li><li><a href="#image-button-state-(type=image)"><span class="secno">4.10.5.1.19</span> Image Button state (<code>type=image</code>)</a></li><li><a href="#reset-button-state-(type=reset)"><span class="secno">4.10.5.1.20</span> Reset Button state (<code>type=reset</code>)</a></li><li><a href="#button-state-(type=button)"><span class="secno">4.10.5.1.21</span> Button state (<code>type=button</code>)</a></li></ol></li><li><a href="#input-impl-notes"><span class="secno">4.10.5.2</span> Implementation notes regarding localization of form controls</a></li><li><a href="#common-input-element-attributes"><span class="secno">4.10.5.3</span> Common <code>input</code> element attributes</a><ol><li><a href="#the-maxlength-and-minlength-attributes"><span class="secno">4.10.5.3.1</span> The <code>maxlength</code> and <code>minlength</code> attributes</a></li><li><a href="#the-size-attribute"><span class="secno">4.10.5.3.2</span> The <code>size</code> attribute</a></li><li><a href="#the-readonly-attribute"><span class="secno">4.10.5.3.3</span> The <code>readonly</code> attribute</a></li><li><a href="#the-required-attribute"><span class="secno">4.10.5.3.4</span> The <code>required</code> attribute</a></li><li><a href="#the-multiple-attribute"><span class="secno">4.10.5.3.5</span> The <code>multiple</code> attribute</a></li><li><a href="#the-pattern-attribute"><span class="secno">4.10.5.3.6</span> The <code>pattern</code> attribute</a></li><li><a href="#the-min-and-max-attributes"><span class="secno">4.10.5.3.7</span> The <code>min</code> and <code>max</code> attributes</a></li><li><a href="#the-step-attribute"><span class="secno">4.10.5.3.8</span> The <code>step</code> attribute</a></li><li><a href="#the-list-attribute"><span class="secno">4.10.5.3.9</span> The <code>list</code> attribute</a></li><li><a href="#the-placeholder-attribute"><span class="secno">4.10.5.3.10</span> The <code>placeholder</code> attribute</a></li></ol></li><li><a href="#common-input-element-apis"><span class="secno">4.10.5.4</span> Common <code>input</code> element APIs</a></li><li><a href="#common-input-element-events"><span class="secno">4.10.5.5</span> Common event behaviors</a></li></ol></li><li><a href="#the-button-element"><span class="secno">4.10.6</span> The <code>button</code> element</a></li><li><a href="#the-select-element"><span class="secno">4.10.7</span> The <code>select</code> element</a></li><li><a href="#the-datalist-element"><span class="secno">4.10.8</span> The <code>datalist</code> element</a></li><li><a href="#the-optgroup-element"><span class="secno">4.10.9</span> The <code>optgroup</code> element</a></li><li><a href="#the-option-element"><span class="secno">4.10.10</span> The <code>option</code> element</a></li><li><a href="#the-textarea-element"><span class="secno">4.10.11</span> The <code>textarea</code> element</a></li><li><a href="#the-output-element"><span class="secno">4.10.12</span> The <code>output</code> element</a></li><li><a href="#the-progress-element"><span class="secno">4.10.13</span> The <code>progress</code> element</a></li><li><a href="#the-meter-element"><span class="secno">4.10.14</span> The <code>meter</code> element</a></li><li><a href="#the-fieldset-element"><span class="secno">4.10.15</span> The <code>fieldset</code> element</a></li><li><a href="#the-legend-element"><span class="secno">4.10.16</span> The <code>legend</code> element</a></li><li><a href="#the-selectedcontent-element"><span class="secno">4.10.17</span> The <code>selectedcontent</code> element</a></li><li><a href="#form-control-infrastructure"><span class="secno">4.10.18</span> Form control infrastructure</a><ol><li><a href="#a-form-control's-value"><span class="secno">4.10.18.1</span> A form control's value</a></li><li><a href="#mutability"><span class="secno">4.10.18.2</span> Mutability</a></li><li><a href="#association-of-controls-and-forms"><span class="secno">4.10.18.3</span> Association of controls and forms</a></li></ol></li><li><a href="#attributes-common-to-form-controls"><span class="secno">4.10.19</span> Attributes common to form controls</a><ol><li><a href="#naming-form-controls:-the-name-attribute"><span class="secno">4.10.19.1</span> Naming form controls: the <code>name</code> attribute</a></li><li><a href="#submitting-element-directionality:-the-dirname-attribute"><span class="secno">4.10.19.2</span> Submitting element directionality: the <code>dirname</code> attribute</a></li><li><a href="#limiting-user-input-length:-the-maxlength-attribute"><span class="secno">4.10.19.3</span> Limiting user input length: the <code>maxlength</code> attribute</a></li><li><a href="#setting-minimum-input-length-requirements:-the-minlength-attribute"><span class="secno">4.10.19.4</span> Setting minimum input length requirements: the <code>minlength</code> attribute</a></li><li><a href="#enabling-and-disabling-form-controls:-the-disabled-attribute"><span class="secno">4.10.19.5</span> Enabling and disabling form controls: the <code>disabled</code> attribute</a></li><li><a href="#form-submission-attributes"><span class="secno">4.10.19.6</span> Form submission attributes</a></li><li><a href="#autofill"><span class="secno">4.10.19.7</span> Autofill</a><ol><li><a href="#autofilling-form-controls:-the-autocomplete-attribute"><span class="secno">4.10.19.7.1</span> Autofilling form controls: the <code>autocomplete</code> attribute</a></li><li><a href="#autofill-processing-model"><span class="secno">4.10.19.7.2</span> Processing model</a></li></ol></li></ol></li><li><a href="#textFieldSelection"><span class="secno">4.10.20</span> APIs for the text control selections</a></li><li><a href="#constraints"><span class="secno">4.10.21</span> Constraints</a><ol><li><a href="#definitions"><span class="secno">4.10.21.1</span> Definitions</a></li><li><a href="#constraint-validation"><span class="secno">4.10.21.2</span> Constraint validation</a></li><li><a href="#the-constraint-validation-api"><span class="secno">4.10.21.3</span> The constraint validation API</a></li><li><a href="#security-forms"><span class="secno">4.10.21.4</span> Security</a></li></ol></li><li><a href="#form-submission-2"><span class="secno">4.10.22</span> Form submission</a><ol><li><a href="#introduction-5"><span class="secno">4.10.22.1</span> Introduction</a></li><li><a href="#implicit-submission"><span class="secno">4.10.22.2</span> Implicit submission</a></li><li><a href="#form-submission-algorithm"><span class="secno">4.10.22.3</span> Form submission algorithm</a></li><li><a href="#constructing-form-data-set"><span class="secno">4.10.22.4</span> Constructing the entry list</a></li><li><a href="#selecting-a-form-submission-encoding"><span class="secno">4.10.22.5</span> Selecting a form submission encoding</a></li><li><a href="#converting-an-entry-list-to-a-list-of-name-value-pairs"><span class="secno">4.10.22.6</span> Converting an entry list to a list of name-value pairs</a></li><li><a href="#url-encoded-form-data"><span class="secno">4.10.22.7</span> URL-encoded form data</a></li><li><a href="#multipart-form-data"><span class="secno">4.10.22.8</span> Multipart form data</a></li><li><a href="#plain-text-form-data"><span class="secno">4.10.22.9</span> Plain text form data</a></li><li><a href="#the-submitevent-interface"><span class="secno">4.10.22.10</span> The <code>SubmitEvent</code> interface</a></li><li><a href="#the-formdataevent-interface"><span class="secno">4.10.22.11</span> The <code>FormDataEvent</code> interface</a></li></ol></li><li><a href="#resetting-a-form"><span class="secno">4.10.23</span> Resetting a form</a></li></ol></li><li><a href="#interactive-elements"><span class="secno">4.11</span> Interactive elements</a><ol><li><a href="#the-details-element"><span class="secno">4.11.1</span> The <code>details</code> element</a></li><li><a href="#the-summary-element"><span class="secno">4.11.2</span> The <code>summary</code> element</a></li><li><a href="#commands"><span class="secno">4.11.3</span> Commands</a><ol><li><a href="#facets-2"><span class="secno">4.11.3.1</span> Facets</a></li><li><a href="#using-the-a-element-to-define-a-command"><span class="secno">4.11.3.2</span> Using the <code>a</code> element to define a command</a></li><li><a href="#using-the-button-element-to-define-a-command"><span class="secno">4.11.3.3</span> Using the <code>button</code> element to define a command</a></li><li><a href="#using-the-input-element-to-define-a-command"><span class="secno">4.11.3.4</span> Using the <code>input</code> element to define a command</a></li><li><a href="#using-the-option-element-to-define-a-command"><span class="secno">4.11.3.5</span> Using the <code>option</code> element to define a command</a></li><li><a href="#using-the-accesskey-attribute-on-a-legend-element-to-define-a-command"><span class="secno">4.11.3.6</span> Using the <code>accesskey</code> attribute
  on a <code>legend</code> element to define a command</a></li><li><a href="#using-the-accesskey-attribute-to-define-a-command-on-other-elements"><span class="secno">4.11.3.7</span> Using the <code>accesskey</code>
  attribute to define a command on other elements</a></li></ol></li><li><a href="#the-dialog-element"><span class="secno">4.11.4</span> The <code>dialog</code> element</a></li><li><a href="#dialog-light-dismiss"><span class="secno">4.11.5</span> Dialog light dismiss</a></li></ol></li><li><a href="#scripting-3"><span class="secno">4.12</span> Scripting</a><ol><li><a href="#the-script-element"><span class="secno">4.12.1</span> The <code>script</code> element</a><ol><li><a href="#script-processing-model"><span class="secno">4.12.1.1</span> Processing model</a></li><li><a href="#scriptingLanguages"><span class="secno">4.12.1.2</span> Scripting languages</a></li><li><a href="#restrictions-for-contents-of-script-elements"><span class="secno">4.12.1.3</span> Restrictions for contents of <code>script</code> elements</a></li><li><a href="#inline-documentation-for-external-scripts"><span class="secno">4.12.1.4</span> Inline documentation for external scripts</a></li><li><a href="#scriptTagXSLT"><span class="secno">4.12.1.5</span> Interaction of <code>script</code> elements and XSLT</a></li></ol></li><li><a href="#the-noscript-element"><span class="secno">4.12.2</span> The <code>noscript</code> element</a></li><li><a href="#the-template-element"><span class="secno">4.12.3</span> The <code>template</code> element</a><ol><li><a href="#template-XSLT-XPath"><span class="secno">4.12.3.1</span> Interaction of <code>template</code> elements with XSLT and XPath</a></li></ol></li><li><a href="#the-slot-element"><span class="secno">4.12.4</span> The <code>slot</code> element</a></li><li><a href="#the-canvas-element"><span class="secno">4.12.5</span> The <code>canvas</code> element</a><ol><li><a href="#2dcontext"><span class="secno">4.12.5.1</span> The 2D rendering context</a><ol><li><a href="#implementation-notes"><span class="secno">4.12.5.1.1</span> Implementation notes</a></li><li><a href="#the-canvas-settings"><span class="secno">4.12.5.1.2</span> The canvas settings</a></li><li><a href="#the-canvas-state"><span class="secno">4.12.5.1.3</span> The canvas state</a></li><li><a href="#line-styles"><span class="secno">4.12.5.1.4</span> Line styles</a></li><li><a href="#text-styles"><span class="secno">4.12.5.1.5</span> Text styles</a></li><li><a href="#building-paths"><span class="secno">4.12.5.1.6</span> Building paths</a></li><li><a href="#path2d-objects"><span class="secno">4.12.5.1.7</span> <code>Path2D</code> objects</a></li><li><a href="#transformations"><span class="secno">4.12.5.1.8</span> Transformations</a></li><li><a href="#image-sources-for-2d-rendering-contexts"><span class="secno">4.12.5.1.9</span> Image sources for 2D rendering contexts</a></li><li><a href="#fill-and-stroke-styles"><span class="secno">4.12.5.1.10</span> Fill and stroke styles</a></li><li><a href="#drawing-rectangles-to-the-bitmap"><span class="secno">4.12.5.1.11</span> Drawing rectangles to the bitmap</a></li><li><a href="#drawing-text-to-the-bitmap"><span class="secno">4.12.5.1.12</span> Drawing text to the bitmap</a></li><li><a href="#drawing-paths-to-the-canvas"><span class="secno">4.12.5.1.13</span> Drawing paths to the canvas</a></li><li><a href="#drawing-focus-rings-and-scrolling-paths-into-view"><span class="secno">4.12.5.1.14</span> Drawing focus rings</a></li><li><a href="#drawing-images"><span class="secno">4.12.5.1.15</span> Drawing images</a></li><li><a href="#pixel-manipulation"><span class="secno">4.12.5.1.16</span> Pixel manipulation</a></li><li><a href="#compositing"><span class="secno">4.12.5.1.17</span> Compositing</a></li><li><a href="#image-smoothing"><span class="secno">4.12.5.1.18</span> Image smoothing</a></li><li><a href="#shadows"><span class="secno">4.12.5.1.19</span> Shadows</a></li><li><a href="#filters"><span class="secno">4.12.5.1.20</span> Filters</a></li><li><a href="#working-with-externally-defined-svg-filters"><span class="secno">4.12.5.1.21</span> Working with externally-defined SVG filters</a></li><li><a href="#drawing-model"><span class="secno">4.12.5.1.22</span> Drawing model</a></li><li><a href="#best-practices"><span class="secno">4.12.5.1.23</span> Best practices</a></li><li><a href="#examples"><span class="secno">4.12.5.1.24</span> Examples</a></li></ol></li><li><a href="#the-imagebitmap-rendering-context"><span class="secno">4.12.5.2</span> The <code>ImageBitmap</code> rendering context</a><ol><li><a href="#introduction-6"><span class="secno">4.12.5.2.1</span> Introduction</a></li><li><a href="#the-imagebitmaprenderingcontext-interface"><span class="secno">4.12.5.2.2</span> The <code>ImageBitmapRenderingContext</code> interface</a></li></ol></li><li><a href="#the-offscreencanvas-interface"><span class="secno">4.12.5.3</span> The <code>OffscreenCanvas</code> interface</a><ol><li><a href="#the-offscreen-2d-rendering-context"><span class="secno">4.12.5.3.1</span> The offscreen 2D rendering context</a></li></ol></li><li><a href="#colour-spaces-and-colour-correction"><span class="secno">4.12.5.4</span> Color spaces and color space
  conversion</a></li><li><a href="#serialising-bitmaps-to-a-file"><span class="secno">4.12.5.5</span> Serializing bitmaps to a file</a></li><li><a href="#security-with-canvas-elements"><span class="secno">4.12.5.6</span> Security with <code>canvas</code> elements</a></li><li><a href="#premultiplied-alpha-and-the-2d-rendering-context"><span class="secno">4.12.5.7</span> Premultiplied alpha and the 2D rendering context</a></li></ol></li></ol></li><li><a href="#custom-elements"><span class="secno">4.13</span> Custom elements</a><ol><li><a href="#custom-elements-intro"><span class="secno">4.13.1</span> Introduction</a><ol><li><a href="#custom-elements-autonomous-example"><span class="secno">4.13.1.1</span> Creating an autonomous custom element</a></li><li><a href="#custom-elements-face-example"><span class="secno">4.13.1.2</span> Creating a form-associated custom element</a></li><li><a href="#custom-elements-accessibility-example"><span class="secno">4.13.1.3</span> Creating a custom element with default accessible roles, states, and properties</a></li><li><a href="#custom-elements-customized-builtin-example"><span class="secno">4.13.1.4</span> Creating a customized built-in element</a></li><li><a href="#custom-elements-autonomous-drawbacks"><span class="secno">4.13.1.5</span> Drawbacks of autonomous custom elements</a></li><li><a href="#custom-elements-upgrades-examples"><span class="secno">4.13.1.6</span> Upgrading elements after their creation</a></li><li><a href="#scoped-custom-element-registries"><span class="secno">4.13.1.7</span> Scoped custom element registries</a></li><li><a href="#exposing-custom-element-states"><span class="secno">4.13.1.8</span> Exposing custom element states</a></li></ol></li><li><a href="#custom-element-conformance"><span class="secno">4.13.2</span> Requirements for custom element constructors and
  reactions</a><ol><li><a href="#preserving-custom-element-state-when-moved"><span class="secno">4.13.2.1</span> Preserving custom element state when moved</a></li></ol></li><li><a href="#custom-elements-core-concepts"><span class="secno">4.13.3</span> Core concepts</a></li><li><a href="#custom-elements-api"><span class="secno">4.13.4</span> The <code>CustomElementRegistry</code> interface</a></li><li><a href="#upgrades"><span class="secno">4.13.5</span> Upgrades</a></li><li><a href="#custom-element-reactions"><span class="secno">4.13.6</span> Custom element reactions</a></li><li><a href="#element-internals"><span class="secno">4.13.7</span> Element internals</a><ol><li><a href="#the-elementinternals-interface"><span class="secno">4.13.7.1</span> The <code>ElementInternals</code> interface</a></li><li><a href="#shadow-root-access"><span class="secno">4.13.7.2</span> Shadow root access</a></li><li><a href="#form-associated-custom-elements"><span class="secno">4.13.7.3</span> Form-associated custom elements</a></li><li><a href="#accessibility-semantics"><span class="secno">4.13.7.4</span> Accessibility semantics</a></li><li><a href="#custom-state-pseudo-class"><span class="secno">4.13.7.5</span> Custom state pseudo-class</a></li></ol></li></ol></li><li><a href="#common-idioms"><span class="secno">4.14</span> Common idioms without dedicated elements</a><ol><li><a href="#rel-up"><span class="secno">4.14.1</span> Breadcrumb navigation</a></li><li><a href="#tag-clouds"><span class="secno">4.14.2</span> Tag clouds</a></li><li><a href="#conversations"><span class="secno">4.14.3</span> Conversations</a></li><li><a href="#footnotes"><span class="secno">4.14.4</span> Footnotes</a></li></ol></li><li><a href="#disabled-elements"><span class="secno">4.15</span> Disabled elements</a></li><li><a href="#selectors"><span class="secno">4.16</span> Matching HTML elements using selectors and CSS</a><ol><li><a href="#case-sensitivity-of-the-css-'attr()'-function"><span class="secno">4.16.1</span> Case-sensitivity of the CSS 'attr()' function</a></li><li><a href="#case-sensitivity-of-selectors"><span class="secno">4.16.2</span> Case-sensitivity of selectors</a></li><li><a href="#pseudo-classes"><span class="secno">4.16.3</span> Pseudo-classes</a></li></ol></li></ol></li><li id="toc-microdata"><a href="#microdata"><span class="secno">5</span> Microdata</a><ol><li><a href="#introduction-7"><span class="secno">5.1</span> Introduction</a><ol><li><a href="#overview"><span class="secno">5.1.1</span> Overview</a></li><li><a href="#the-basic-syntax"><span class="secno">5.1.2</span> The basic syntax</a></li><li><a href="#typed-items"><span class="secno">5.1.3</span> Typed items</a></li><li><a href="#global-identifiers-for-items"><span class="secno">5.1.4</span> Global identifiers for items</a></li><li><a href="#selecting-names-when-defining-vocabularies"><span class="secno">5.1.5</span> Selecting names when defining vocabularies</a></li></ol></li><li><a href="#encoding-microdata"><span class="secno">5.2</span> Encoding microdata</a><ol><li><a href="#the-microdata-model"><span class="secno">5.2.1</span> The microdata model</a></li><li><a href="#items"><span class="secno">5.2.2</span> Items</a></li><li><a href="#names:-the-itemprop-attribute"><span class="secno">5.2.3</span> Names: the <code>itemprop</code> attribute</a></li><li><a href="#values"><span class="secno">5.2.4</span> Values</a></li><li><a href="#associating-names-with-items"><span class="secno">5.2.5</span> Associating names with items</a></li><li><a href="#microdata-and-other-namespaces"><span class="secno">5.2.6</span> Microdata and other namespaces</a></li></ol></li><li><a href="#mdvocabs"><span class="secno">5.3</span> Sample microdata vocabularies</a><ol><li><a href="#vcard"><span class="secno">5.3.1</span> vCard</a><ol><li><a href="#conversion-to-vcard"><span class="secno">5.3.1.1</span> Conversion to vCard</a></li><li><a href="#examples-2"><span class="secno">5.3.1.2</span> Examples</a></li></ol></li><li><a href="#vevent"><span class="secno">5.3.2</span> vEvent</a><ol><li><a href="#conversion-to-icalendar"><span class="secno">5.3.2.1</span> Conversion to iCalendar</a></li><li><a href="#examples-3"><span class="secno">5.3.2.2</span> Examples</a></li></ol></li><li><a href="#licensing-works"><span class="secno">5.3.3</span> Licensing works</a><ol><li><a href="#examples-4"><span class="secno">5.3.3.1</span> Examples</a></li></ol></li></ol></li><li><a href="#converting-html-to-other-formats"><span class="secno">5.4</span> Converting HTML to other formats</a><ol><li><a href="#json"><span class="secno">5.4.1</span> JSON</a></li></ol></li></ol></li><li id="toc-editing"><a href="#editing"><span class="secno">6</span> User interaction</a><ol><li><a href="#the-hidden-attribute"><span class="secno">6.1</span> The <code>hidden</code> attribute</a></li><li><a href="#page-visibility"><span class="secno">6.2</span> Page visibility</a><ol><li><a href="#the-visibilitystateentry-interface"><span class="secno">6.2.1</span> The <code>VisibilityStateEntry</code> interface</a></li></ol></li><li><a href="#inert-subtrees"><span class="secno">6.3</span> Inert subtrees</a><ol><li><a href="#modal-dialogs-and-inert-subtrees"><span class="secno">6.3.1</span> Modal dialogs and inert subtrees</a></li><li><a href="#the-inert-attribute"><span class="secno">6.3.2</span> The <code>inert</code> attribute</a></li></ol></li><li><a href="#tracking-user-activation"><span class="secno">6.4</span> Tracking user activation</a><ol><li><a href="#user-activation-data-model"><span class="secno">6.4.1</span> Data model</a></li><li><a href="#user-activation-processing-model"><span class="secno">6.4.2</span> Processing model</a></li><li><a href="#user-activation-gated-apis"><span class="secno">6.4.3</span> APIs gated by user activation</a></li><li><a href="#the-useractivation-interface"><span class="secno">6.4.4</span> The <code>UserActivation</code> interface</a></li><li><a href="#user-activation-user-agent-automation"><span class="secno">6.4.5</span> User agent automation</a></li></ol></li><li><a href="#activation"><span class="secno">6.5</span> Activation behavior of elements</a><ol><li><a href="#the-toggleevent-interface"><span class="secno">6.5.1</span> The <code>ToggleEvent</code> interface</a></li><li><a href="#the-commandevent-interface"><span class="secno">6.5.2</span> The <code>CommandEvent</code> interface</a></li></ol></li><li><a href="#focus"><span class="secno">6.6</span> Focus</a><ol><li><a href="#introduction-8"><span class="secno">6.6.1</span> Introduction</a></li><li><a href="#data-model"><span class="secno">6.6.2</span> Data model</a></li><li><a href="#the-tabindex-attribute"><span class="secno">6.6.3</span> The <code>tabindex</code> attribute</a></li><li><a href="#focus-processing-model"><span class="secno">6.6.4</span> Processing model</a></li><li><a href="#sequential-focus-navigation"><span class="secno">6.6.5</span> Sequential focus navigation</a></li><li><a href="#focus-management-apis"><span class="secno">6.6.6</span> Focus management APIs</a></li><li><a href="#the-autofocus-attribute"><span class="secno">6.6.7</span> The <code>autofocus</code> attribute</a></li></ol></li><li><a href="#assigning-keyboard-shortcuts"><span class="secno">6.7</span> Assigning keyboard shortcuts</a><ol><li><a href="#introduction-9"><span class="secno">6.7.1</span> Introduction</a></li><li><a href="#the-accesskey-attribute"><span class="secno">6.7.2</span> The <code>accesskey</code>
  attribute</a></li><li><a href="#keyboard-shortcuts-processing-model"><span class="secno">6.7.3</span> Processing
  model</a></li></ol></li><li><a href="#editing-2"><span class="secno">6.8</span> Editing</a><ol><li><a href="#contenteditable"><span class="secno">6.8.1</span> Making document regions editable: The <code>contenteditable</code> content attribute</a></li><li><a href="#making-entire-documents-editable:-the-designmode-idl-attribute"><span class="secno">6.8.2</span> Making entire documents
  editable: the <code>designMode</code> getter and setter</a></li><li><a href="#best-practices-for-in-page-editors"><span class="secno">6.8.3</span> Best practices for in-page editors</a></li><li><a href="#editing-apis"><span class="secno">6.8.4</span> Editing APIs</a></li><li><a href="#spelling-and-grammar-checking"><span class="secno">6.8.5</span> Spelling and grammar checking</a></li><li><a href="#writing-suggestions"><span class="secno">6.8.6</span> Writing suggestions</a></li><li><a href="#autocapitalization"><span class="secno">6.8.7</span> Autocapitalization</a></li><li><a href="#autocorrection"><span class="secno">6.8.8</span> Autocorrection</a></li><li><a href="#input-modalities:-the-inputmode-attribute"><span class="secno">6.8.9</span> Input modalities: the <code>inputmode</code> attribute</a></li><li><a href="#input-modalities:-the-enterkeyhint-attribute"><span class="secno">6.8.10</span> Input modalities: the <code>enterkeyhint</code>
  attribute</a></li></ol></li><li><a href="#find-in-page"><span class="secno">6.9</span> Find-in-page</a><ol><li><a href="#introduction-10"><span class="secno">6.9.1</span> Introduction</a></li><li><a href="#interaction-with-details-and-hidden=until-found"><span class="secno">6.9.2</span> Interaction with <code>details</code> and <code>hidden=until-found</code></a></li><li><a href="#interaction-with-selection"><span class="secno">6.9.3</span> Interaction with selection</a></li></ol></li><li><a href="#close-requests-and-close-watchers"><span class="secno">6.10</span> Close requests and close watchers</a><ol><li><a href="#close-requests"><span class="secno">6.10.1</span> Close requests</a></li><li><a href="#close-watcher-infrastructure"><span class="secno">6.10.2</span> Close watcher infrastructure</a></li><li><a href="#the-closewatcher-interface"><span class="secno">6.10.3</span> The <code>CloseWatcher</code> interface</a></li></ol></li><li><a href="#dnd"><span class="secno">6.11</span> Drag and drop</a><ol><li><a href="#event-drag"><span class="secno">6.11.1</span> Introduction</a></li><li><a href="#the-drag-data-store"><span class="secno">6.11.2</span> The drag data store</a></li><li><a href="#the-datatransfer-interface"><span class="secno">6.11.3</span> The <code>DataTransfer</code> interface</a><ol><li><a href="#the-datatransferitemlist-interface"><span class="secno">6.11.3.1</span> The <code>DataTransferItemList</code> interface</a></li><li><a href="#the-datatransferitem-interface"><span class="secno">6.11.3.2</span> The <code>DataTransferItem</code> interface</a></li></ol></li><li><a href="#the-dragevent-interface"><span class="secno">6.11.4</span> The <code>DragEvent</code> interface</a></li><li><a href="#drag-and-drop-processing-model"><span class="secno">6.11.5</span> Processing model</a></li><li><a href="#dndevents"><span class="secno">6.11.6</span> Events summary</a></li><li><a href="#the-draggable-attribute"><span class="secno">6.11.7</span> The <code>draggable</code> attribute</a></li><li><a href="#security-risks-in-the-drag-and-drop-model"><span class="secno">6.11.8</span> Security risks in the drag-and-drop model</a></li></ol></li><li><a href="#the-popover-attribute"><span class="secno">6.12</span> The <code>popover</code> attribute</a><ol><li><a href="#the-popover-target-attributes"><span class="secno">6.12.1</span> The popover target attributes</a></li><li><a href="#popover-light-dismiss"><span class="secno">6.12.2</span> Popover light dismiss</a></li></ol></li></ol></li><li id="toc-browsers"><a href="#browsers"><span class="secno">7</span> Loading web pages</a><ol><li><a href="#loading-web-pages-supporting-concepts"><span class="secno">7.1</span> Supporting concepts</a><ol><li><a href="#origin"><span class="secno">7.1.1</span> Origins</a><ol><li><a href="#sites"><span class="secno">7.1.1.1</span> Sites</a></li><li><a href="#relaxing-the-same-origin-restriction"><span class="secno">7.1.1.2</span> Relaxing the same-origin restriction</a></li></ol></li><li><a href="#origin-keyed-agent-clusters"><span class="secno">7.1.2</span> Origin-keyed agent clusters</a></li><li><a href="#cross-origin-opener-policies"><span class="secno">7.1.3</span> Cross-origin opener policies</a><ol><li><a href="#the-coop-headers"><span class="secno">7.1.3.1</span> The headers</a></li><li><a href="#browsing-context-group-switches-due-to-cross-origin-opener-policy"><span class="secno">7.1.3.2</span> Browsing context group
  switches due to opener policy</a></li><li><a href="#coop-reporting"><span class="secno">7.1.3.3</span> Reporting</a></li></ol></li><li><a href="#coep"><span class="secno">7.1.4</span> Cross-origin embedder policies</a><ol><li><a href="#the-coep-headers"><span class="secno">7.1.4.1</span> The headers</a></li><li><a href="#embedder-policy-checks"><span class="secno">7.1.4.2</span> Embedder policy checks</a></li></ol></li><li><a href="#sandboxing"><span class="secno">7.1.5</span> Sandboxing</a></li><li><a href="#policy-containers"><span class="secno">7.1.6</span> Policy containers</a></li></ol></li><li><a href="#nav-traversal-apis"><span class="secno">7.2</span> APIs related to navigation and
  session history</a><ol><li><a href="#cross-origin-objects"><span class="secno">7.2.1</span> Security infrastructure for <code>Window</code>,
  <code>WindowProxy</code>, and <code>Location</code> objects</a><ol><li><a href="#integration-with-idl"><span class="secno">7.2.1.1</span> Integration with IDL</a></li><li><a href="#shared-internal-slot:-crossoriginpropertydescriptormap"><span class="secno">7.2.1.2</span> Shared internal slot: [[CrossOriginPropertyDescriptorMap]]</a></li><li><a href="#shared-abstract-operations"><span class="secno">7.2.1.3</span> Shared abstract operations</a><ol><li><a href="#crossoriginproperties-(-o-)"><span class="secno">7.2.1.3.1</span> CrossOriginProperties ( <var>O</var> )</a></li><li><a href="#crossoriginpropertyfallback-(-p-)"><span class="secno">7.2.1.3.2</span> CrossOriginPropertyFallback ( <var>P</var> )</a></li><li><a href="#isplatformobjectsameorigin-(-o-)"><span class="secno">7.2.1.3.3</span> IsPlatformObjectSameOrigin ( <var>O</var> )</a></li><li><a href="#crossorigingetownpropertyhelper-(-o,-p-)"><span class="secno">7.2.1.3.4</span> CrossOriginGetOwnPropertyHelper ( <var>O</var>, <var>P</var> )</a></li><li><a href="#crossoriginget-(-o,-p,-receiver-)"><span class="secno">7.2.1.3.5</span> CrossOriginGet ( <var>O</var>, <var>P</var>, <var>Receiver</var> )</a></li><li><a href="#crossoriginset-(-o,-p,-v,-receiver-)"><span class="secno">7.2.1.3.6</span> CrossOriginSet ( <var>O</var>, <var>P</var>, <var>V</var>,
  <var>Receiver</var> )</a></li><li><a href="#crossoriginownpropertykeys-(-o-)"><span class="secno">7.2.1.3.7</span> CrossOriginOwnPropertyKeys ( <var>O</var> )</a></li></ol></li></ol></li><li><a href="#the-window-object"><span class="secno">7.2.2</span> The <code>Window</code> object</a><ol><li><a href="#apis-for-creating-and-navigating-browsing-contexts-by-name"><span class="secno">7.2.2.1</span> Opening and closing windows</a></li><li><a href="#accessing-other-browsing-contexts"><span class="secno">7.2.2.2</span> Indexed access on the <code>Window</code> object</a></li><li><a href="#named-access-on-the-window-object"><span class="secno">7.2.2.3</span> Named access on the <code>Window</code> object</a></li><li><a href="#navigating-nested-browsing-contexts-in-the-dom"><span class="secno">7.2.2.4</span> Accessing related windows</a></li><li><a href="#browser-interface-elements"><span class="secno">7.2.2.5</span> Historical browser interface element APIs</a></li><li><a href="#script-settings-for-window-objects"><span class="secno">7.2.2.6</span> Script settings for <code>Window</code> objects</a></li></ol></li><li><a href="#the-windowproxy-exotic-object"><span class="secno">7.2.3</span> The <code>WindowProxy</code> exotic object</a><ol><li><a href="#windowproxy-getprototypeof"><span class="secno">7.2.3.1</span> [[GetPrototypeOf]] ( )</a></li><li><a href="#windowproxy-setprototypeof"><span class="secno">7.2.3.2</span> [[SetPrototypeOf]] ( <var>V</var> )</a></li><li><a href="#windowproxy-isextensible"><span class="secno">7.2.3.3</span> [[IsExtensible]] ( )</a></li><li><a href="#windowproxy-preventextensions"><span class="secno">7.2.3.4</span> [[PreventExtensions]] ( )</a></li><li><a href="#windowproxy-getownproperty"><span class="secno">7.2.3.5</span> [[GetOwnProperty]] ( <var>P</var> )</a></li><li><a href="#windowproxy-defineownproperty"><span class="secno">7.2.3.6</span> [[DefineOwnProperty]] ( <var>P</var>, <var>Desc</var>
  )</a></li><li><a href="#windowproxy-get"><span class="secno">7.2.3.7</span> [[Get]] ( <var>P</var>, <var>Receiver</var> )</a></li><li><a href="#windowproxy-set"><span class="secno">7.2.3.8</span> [[Set]] ( <var>P</var>, <var>V</var>, <var>Receiver</var> )</a></li><li><a href="#windowproxy-delete"><span class="secno">7.2.3.9</span> [[Delete]] ( <var>P</var> )</a></li><li><a href="#windowproxy-ownpropertykeys"><span class="secno">7.2.3.10</span> [[OwnPropertyKeys]] ( )</a></li></ol></li><li><a href="#the-location-interface"><span class="secno">7.2.4</span> The <code>Location</code> interface</a><ol><li><a href="#location-getprototypeof"><span class="secno">7.2.4.1</span> [[GetPrototypeOf]] ( )</a></li><li><a href="#location-setprototypeof"><span class="secno">7.2.4.2</span> [[SetPrototypeOf]] ( <var>V</var> )</a></li><li><a href="#location-isextensible"><span class="secno">7.2.4.3</span> [[IsExtensible]] ( )</a></li><li><a href="#location-preventextensions"><span class="secno">7.2.4.4</span> [[PreventExtensions]] ( )</a></li><li><a href="#location-getownproperty"><span class="secno">7.2.4.5</span> [[GetOwnProperty]] ( <var>P</var> )</a></li><li><a href="#location-defineownproperty"><span class="secno">7.2.4.6</span> [[DefineOwnProperty]] ( <var>P</var>, <var>Desc</var> )</a></li><li><a href="#location-get"><span class="secno">7.2.4.7</span> [[Get]] ( <var>P</var>, <var>Receiver</var> )</a></li><li><a href="#location-set"><span class="secno">7.2.4.8</span> [[Set]] ( <var>P</var>, <var>V</var>, <var>Receiver</var> )</a></li><li><a href="#location-delete"><span class="secno">7.2.4.9</span> [[Delete]] ( <var>P</var> )</a></li><li><a href="#location-ownpropertykeys"><span class="secno">7.2.4.10</span> [[OwnPropertyKeys]] ( )</a></li></ol></li><li><a href="#the-history-interface"><span class="secno">7.2.5</span> The <code>History</code> interface</a></li><li><a href="#navigation-api"><span class="secno">7.2.6</span> The navigation API</a><ol><li><a href="#navigation-api-intro"><span class="secno">7.2.6.1</span> Introduction</a></li><li><a href="#navigation-interface"><span class="secno">7.2.6.2</span> The <code>Navigation</code> interface</a></li><li><a href="#navigation-api-core"><span class="secno">7.2.6.3</span> Core infrastructure</a></li><li><a href="#navigation-api-entry-updates"><span class="secno">7.2.6.4</span> Initializing and updating the entry list</a></li><li><a href="#the-navigationhistoryentry-interface"><span class="secno">7.2.6.5</span> The <code>NavigationHistoryEntry</code> interface</a></li><li><a href="#the-history-entry-list"><span class="secno">7.2.6.6</span> The history entry list</a></li><li><a href="#navigation-api-initiating-navigations"><span class="secno">7.2.6.7</span> Initiating navigations</a></li><li><a href="#ongoing-navigation-tracking"><span class="secno">7.2.6.8</span> Ongoing navigation tracking</a></li><li><a href="#navigation-activation-interface"><span class="secno">7.2.6.9</span> The <code>NavigationActivation</code> interface</a></li><li><a href="#the-navigate-event"><span class="secno">7.2.6.10</span> The <code>navigate</code> event</a><ol><li><a href="#the-navigateevent-interface"><span class="secno">7.2.6.10.1</span> The <code>NavigateEvent</code> interface</a></li><li><a href="#the-navigationprecommitcontroller-interface"><span class="secno">7.2.6.10.2</span> The <code>NavigationPrecommitController</code> interface</a></li><li><a href="#the-navigationdestination-interface"><span class="secno">7.2.6.10.3</span> The <code>NavigationDestination</code> interface</a></li><li><a href="#navigate-event-firing"><span class="secno">7.2.6.10.4</span> Firing the event</a></li><li><a href="#navigate-event-scroll-focus"><span class="secno">7.2.6.10.5</span> Scroll and focus behavior</a></li></ol></li></ol></li><li><a href="#nav-traversal-event-interfaces"><span class="secno">7.2.7</span> Event interfaces</a><ol><li><a href="#the-navigationcurrententrychangeevent-interface"><span class="secno">7.2.7.1</span> The <code>NavigationCurrentEntryChangeEvent</code> interface</a></li><li><a href="#the-popstateevent-interface"><span class="secno">7.2.7.2</span> The <code>PopStateEvent</code> interface</a></li><li><a href="#the-hashchangeevent-interface"><span class="secno">7.2.7.3</span> The <code>HashChangeEvent</code> interface</a></li><li><a href="#the-pageswapevent-interface"><span class="secno">7.2.7.4</span> The <code>PageSwapEvent</code> interface</a></li><li><a href="#the-pagerevealevent-interface"><span class="secno">7.2.7.5</span> The <code>PageRevealEvent</code> interface</a></li><li><a href="#the-pagetransitionevent-interface"><span class="secno">7.2.7.6</span> The <code>PageTransitionEvent</code> interface</a></li><li><a href="#the-beforeunloadevent-interface"><span class="secno">7.2.7.7</span> The <code>BeforeUnloadEvent</code> interface</a></li></ol></li><li><a href="#the-notrestoredreasons-interface"><span class="secno">7.2.8</span> The <code>NotRestoredReasons</code> interface</a></li></ol></li><li><a href="#infrastructure-for-sequences-of-documents"><span class="secno">7.3</span> Infrastructure for sequences of documents</a><ol><li><a href="#navigables"><span class="secno">7.3.1</span> Navigables</a><ol><li><a href="#traversable-navigables"><span class="secno">7.3.1.1</span> Traversable navigables</a></li><li><a href="#top-level-traversables"><span class="secno">7.3.1.2</span> Top-level traversables</a></li><li><a href="#child-navigables"><span class="secno">7.3.1.3</span> Child navigables</a></li><li><a href="#jake-diagrams"><span class="secno">7.3.1.4</span> Jake diagrams</a></li><li><a href="#related-navigable-collections"><span class="secno">7.3.1.5</span> Related navigable collections</a></li><li><a href="#garbage-collection-and-browsing-contexts"><span class="secno">7.3.1.6</span> Navigable destruction</a></li><li><a href="#navigable-target-names"><span class="secno">7.3.1.7</span> Navigable target names</a></li></ol></li><li><a href="#windows"><span class="secno">7.3.2</span> Browsing contexts</a><ol><li><a href="#creating-browsing-contexts"><span class="secno">7.3.2.1</span> Creating browsing contexts</a></li><li><a href="#nested-browsing-contexts"><span class="secno">7.3.2.2</span> Related browsing contexts</a></li><li><a href="#groupings-of-browsing-contexts"><span class="secno">7.3.2.3</span> Groupings of browsing contexts</a></li></ol></li><li><a href="#fully-active-documents"><span class="secno">7.3.3</span> Fully active documents</a></li></ol></li><li><a href="#navigation-and-session-history"><span class="secno">7.4</span> Navigation and session
  history</a><ol><li><a href="#session-history-infrastructure"><span class="secno">7.4.1</span> Session history</a><ol><li><a href="#session-history-entries"><span class="secno">7.4.1.1</span> Session history entries</a></li><li><a href="#document-state"><span class="secno">7.4.1.2</span> Document state</a></li><li><a href="#centralized-modifications-of-session-history"><span class="secno">7.4.1.3</span> Centralized modifications of session history</a></li><li><a href="#low-level-operations-on-session-history"><span class="secno">7.4.1.4</span> Low-level operations on session history</a></li></ol></li><li><a href="#navigating-across-documents"><span class="secno">7.4.2</span> Navigation</a><ol><li><a href="#navigation-supporting-concepts"><span class="secno">7.4.2.1</span> Supporting concepts</a></li><li><a href="#beginning-navigation"><span class="secno">7.4.2.2</span> Beginning navigation</a></li><li><a href="#ending-navigation"><span class="secno">7.4.2.3</span> Ending navigation</a><ol><li><a href="#the-usual-cross-document-navigation-case"><span class="secno">7.4.2.3.1</span> The usual cross-document navigation case</a></li><li><a href="#the-javascript:-url-special-case"><span class="secno">7.4.2.3.2</span> The <code>javascript:</code> URL special case</a></li><li><a href="#scroll-to-fragid"><span class="secno">7.4.2.3.3</span> Fragment navigations</a></li><li><a href="#non-fetch-schemes-and-external-software"><span class="secno">7.4.2.3.4</span> Non-fetch schemes and external software</a></li></ol></li><li><a href="#preventing-navigation"><span class="secno">7.4.2.4</span> Preventing navigation</a></li><li><a href="#aborting-navigation"><span class="secno">7.4.2.5</span> Aborting navigation</a></li></ol></li><li><a href="#reloading-and-traversing"><span class="secno">7.4.3</span> Reloading and traversing</a></li><li><a href="#navigate-non-frag-sync"><span class="secno">7.4.4</span> Non-fragment synchronous "navigations"</a></li><li><a href="#populating-a-session-history-entry"><span class="secno">7.4.5</span> Populating a session history entry</a></li><li><a href="#applying-the-history-step"><span class="secno">7.4.6</span> Applying the history step</a><ol><li><a href="#updating-the-traversable"><span class="secno">7.4.6.1</span> Updating the traversable</a></li><li><a href="#updating-the-document"><span class="secno">7.4.6.2</span> Updating the document</a></li><li><a href="#revealing-the-document"><span class="secno">7.4.6.3</span> Revealing the document</a></li><li><a href="#scrolling-to-a-fragment"><span class="secno">7.4.6.4</span> Scrolling to a fragment</a></li><li><a href="#persisted-user-state-restoration"><span class="secno">7.4.6.5</span> Persisted history entry state</a></li></ol></li></ol></li><li><a href="#document-lifecycle"><span class="secno">7.5</span> Document lifecycle</a><ol><li><a href="#shared-document-creation-infrastructure"><span class="secno">7.5.1</span> Shared document creation infrastructure</a></li><li><a href="#read-html"><span class="secno">7.5.2</span> Loading HTML documents</a></li><li><a href="#read-xml"><span class="secno">7.5.3</span> Loading XML documents</a></li><li><a href="#read-text"><span class="secno">7.5.4</span> Loading text documents</a></li><li><a href="#read-multipart-x-mixed-replace"><span class="secno">7.5.5</span> Loading <code>multipart/x-mixed-replace</code>
  documents</a></li><li><a href="#read-media"><span class="secno">7.5.6</span> Loading media documents</a></li><li><a href="#read-ua-inline"><span class="secno">7.5.7</span> Loading
  a document for inline content that doesn't have a DOM</a></li><li><a href="#loading-documents"><span class="secno">7.5.8</span> Finishing the loading process</a></li><li><a href="#unloading-documents"><span class="secno">7.5.9</span> Unloading documents</a></li><li><a href="#destroying-documents"><span class="secno">7.5.10</span> Destroying documents</a></li><li><a href="#aborting-a-document-load"><span class="secno">7.5.11</span> Aborting a document load</a></li></ol></li><li><a href="#speculative-loading"><span class="secno">7.6</span> Speculative loading</a><ol><li><a href="#speculation-rules"><span class="secno">7.6.1</span> Speculation rules</a><ol><li><a href="#speculation-rules-data-model"><span class="secno">7.6.1.1</span> Data model</a></li><li><a href="#speculation-rules-parsing"><span class="secno">7.6.1.2</span> Parsing</a></li><li><a href="#speculation-rules-processing-model"><span class="secno">7.6.1.3</span> Processing model</a></li></ol></li><li><a href="#navigational-prefetching"><span class="secno">7.6.2</span> Navigational prefetching</a></li><li><a href="#the-speculation-rules-header"><span class="secno">7.6.3</span> The `<code>Speculation-Rules</code>` header</a></li><li><a href="#the-sec-speculation-tags-header"><span class="secno">7.6.4</span> The `<code>Sec-Speculation-Tags</code>` header</a></li><li><a href="#speculative-loading-security"><span class="secno">7.6.5</span> Security considerations</a><ol><li><a href="#speculative-loading-cross-site-requests"><span class="secno">7.6.5.1</span> Cross-site requests</a></li><li><a href="#speculative-loading-injected-content"><span class="secno">7.6.5.2</span> Injected content</a></li><li><a href="#speculative-loading-ip-anonymization"><span class="secno">7.6.5.3</span> IP anonymization</a></li></ol></li><li><a href="#speculative-loading-privacy"><span class="secno">7.6.6</span> Privacy considerations</a><ol><li><a href="#speculative-loading-heuristics"><span class="secno">7.6.6.1</span> Heuristics and optionality</a></li><li><a href="#speculative-loading-state-partitioning"><span class="secno">7.6.6.2</span> State partitioning</a></li><li><a href="#speculative-loading-identity-joining"><span class="secno">7.6.6.3</span> Identity joining</a></li></ol></li></ol></li><li><a href="#the-x-frame-options-header"><span class="secno">7.7</span> The `<code>X-Frame-Options</code>` header</a></li><li><a href="#the-refresh-header"><span class="secno">7.8</span> The `<code>Refresh</code>` header</a></li><li><a href="#nav-traversal-ui"><span class="secno">7.9</span> Browser user interface
  considerations</a></li></ol></li><li id="toc-webappapis"><a href="#webappapis"><span class="secno">8</span> Web application APIs</a><ol><li><a href="#scripting"><span class="secno">8.1</span> Scripting</a><ol><li><a href="#introduction-11"><span class="secno">8.1.1</span> Introduction</a></li><li><a href="#agents-and-agent-clusters"><span class="secno">8.1.2</span> Agents and agent clusters</a><ol><li><a href="#integration-with-the-javascript-agent-formalism"><span class="secno">8.1.2.1</span> Integration with the JavaScript agent formalism</a></li><li><a href="#integration-with-the-javascript-agent-cluster-formalism"><span class="secno">8.1.2.2</span> Integration with the JavaScript agent cluster formalism</a></li></ol></li><li><a href="#realms-and-their-counterparts"><span class="secno">8.1.3</span> Realms and their counterparts</a><ol><li><a href="#environments"><span class="secno">8.1.3.1</span> Environments</a></li><li><a href="#environment-settings-objects"><span class="secno">8.1.3.2</span> Environment settings objects</a></li><li><a href="#realms-settings-objects-global-objects"><span class="secno">8.1.3.3</span> Realms, settings objects, and global objects</a><ol><li><a href="#entry"><span class="secno">8.1.3.3.1</span> Entry</a></li><li><a href="#incumbent"><span class="secno">8.1.3.3.2</span> Incumbent</a></li><li><a href="#current"><span class="secno">8.1.3.3.3</span> Current</a></li><li><a href="#relevant"><span class="secno">8.1.3.3.4</span> Relevant</a></li></ol></li><li><a href="#enabling-and-disabling-scripting"><span class="secno">8.1.3.4</span> Enabling and disabling scripting</a></li><li><a href="#secure-contexts"><span class="secno">8.1.3.5</span> Secure contexts</a></li></ol></li><li><a href="#scripting-processing-model"><span class="secno">8.1.4</span> Script processing
  model</a><ol><li><a href="#script-structs"><span class="secno">8.1.4.1</span> Scripts</a></li><li><a href="#fetching-scripts"><span class="secno">8.1.4.2</span> Fetching scripts</a></li><li><a href="#creating-scripts"><span class="secno">8.1.4.3</span> Creating scripts</a></li><li><a href="#calling-scripts"><span class="secno">8.1.4.4</span> Calling scripts</a></li><li><a href="#killing-scripts"><span class="secno">8.1.4.5</span> Killing scripts</a></li><li><a href="#runtime-script-errors"><span class="secno">8.1.4.6</span> Runtime script errors</a></li><li><a href="#unhandled-promise-rejections"><span class="secno">8.1.4.7</span> Unhandled promise rejections</a></li><li><a href="#import-map-parse-results"><span class="secno">8.1.4.8</span> Import map parse results</a></li><li><a href="#speculation-rules-parse-results"><span class="secno">8.1.4.9</span> Speculation rules parse results</a></li></ol></li><li><a href="#module-specifier-resolution"><span class="secno">8.1.5</span> Module specifier resolution</a><ol><li><a href="#the-resolution-algorithm"><span class="secno">8.1.5.1</span> The resolution algorithm</a></li><li><a href="#import-maps"><span class="secno">8.1.5.2</span> Import maps</a></li><li><a href="#import-map-processing-model"><span class="secno">8.1.5.3</span> Import map processing model</a></li></ol></li><li><a href="#javascript-specification-host-hooks"><span class="secno">8.1.6</span> JavaScript specification host hooks</a><ol><li><a href="#the-hostensurecanaddprivateelement-implementation"><span class="secno">8.1.6.1</span> HostEnsureCanAddPrivateElement(<var>O</var>)</a></li><li><a href="#hostensurecancompilestrings(realm,-parameterstrings,-bodystring,-codestring,-compilationtype,-parameterargs,-bodyarg)"><span class="secno">8.1.6.2</span> HostEnsureCanCompileStrings(<var>realm</var>,
  <var>parameterStrings</var>, <var>bodyString</var>, <var>codeString</var>, <var>compilationType</var>,
  <var>parameterArgs</var>, <var>bodyArg</var>)</a></li><li><a href="#hostgetcodeforeval(argument)"><span class="secno">8.1.6.3</span> HostGetCodeForEval(<var>argument</var>)</a></li><li><a href="#the-hostpromiserejectiontracker-implementation"><span class="secno">8.1.6.4</span> HostPromiseRejectionTracker(<var>promise</var>, <var>operation</var>)</a></li><li><a href="#hostsystemutcepochnanoseconds"><span class="secno">8.1.6.5</span> HostSystemUTCEpochNanoseconds(<var>global</var>)</a></li><li><a href="#integration-with-javascript-jobs"><span class="secno">8.1.6.6</span> Job-related host hooks</a><ol><li><a href="#hostcalljobcallback"><span class="secno">8.1.6.6.1</span> HostCallJobCallback(<var>callback</var>, <var>V</var>,
  <var>argumentsList</var>)</a></li><li><a href="#hostenqueuefinalizationregistrycleanupjob"><span class="secno">8.1.6.6.2</span> HostEnqueueFinalizationRegistryCleanupJob(<var>finalizationRegistry</var>)</a></li><li><a href="#hostenqueuegenericjob"><span class="secno">8.1.6.6.3</span> HostEnqueueGenericJob(<var>job</var>,
  <var>realm</var>)</a></li><li><a href="#hostenqueuepromisejob"><span class="secno">8.1.6.6.4</span> HostEnqueuePromiseJob(<var>job</var>,
  <var>realm</var>)</a></li><li><a href="#hostenqueuetimeoutjob"><span class="secno">8.1.6.6.5</span> HostEnqueueTimeoutJob(<var>job</var>, <var>realm</var>,
  <var>milliseconds</var>)</a></li><li><a href="#hostmakejobcallback"><span class="secno">8.1.6.6.6</span> HostMakeJobCallback(<var>callable</var>)</a></li></ol></li><li><a href="#integration-with-the-javascript-module-system"><span class="secno">8.1.6.7</span> Module-related host hooks</a><ol><li><a href="#hostgetimportmetaproperties"><span class="secno">8.1.6.7.1</span> HostGetImportMetaProperties(<var>moduleRecord</var>)</a></li><li><a href="#hostgetsupportedimportattributes"><span class="secno">8.1.6.7.2</span> HostGetSupportedImportAttributes()</a></li><li><a href="#hostloadimportedmodule"><span class="secno">8.1.6.7.3</span> HostLoadImportedModule(<var>referrer</var>,
  <var>moduleRequest</var>, <var>loadState</var>, <var>payload</var>)</a></li></ol></li></ol></li><li><a href="#event-loops"><span class="secno">8.1.7</span> Event loops</a><ol><li><a href="#definitions-3"><span class="secno">8.1.7.1</span> Definitions</a></li><li><a href="#queuing-tasks"><span class="secno">8.1.7.2</span> Queuing tasks</a></li><li><a href="#event-loop-processing-model"><span class="secno">8.1.7.3</span> Processing model</a></li><li><a href="#generic-task-sources"><span class="secno">8.1.7.4</span> Generic task sources</a></li><li><a href="#event-loop-for-spec-authors"><span class="secno">8.1.7.5</span> Dealing with the event loop from other specifications</a></li></ol></li><li><a href="#events"><span class="secno">8.1.8</span> Events</a><ol><li><a href="#event-handler-attributes"><span class="secno">8.1.8.1</span> Event handlers</a></li><li><a href="#event-handlers-on-elements,-document-objects,-and-window-objects"><span class="secno">8.1.8.2</span> Event handlers on elements, <code>Document</code> objects, and <code>Window</code> objects</a><ol><li><a href="#idl-definitions"><span class="secno">8.1.8.2.1</span> IDL definitions</a></li></ol></li><li><a href="#event-firing"><span class="secno">8.1.8.3</span> Event firing</a></li></ol></li></ol></li><li><a href="#windoworworkerglobalscope-mixin"><span class="secno">8.2</span> The <code>WindowOrWorkerGlobalScope</code> mixin</a></li><li><a href="#atob"><span class="secno">8.3</span> Base64 utility methods</a></li><li><a href="#dynamic-markup-insertion"><span class="secno">8.4</span> Dynamic markup insertion</a><ol><li><a href="#opening-the-input-stream"><span class="secno">8.4.1</span> Opening the input stream</a></li><li><a href="#closing-the-input-stream"><span class="secno">8.4.2</span> Closing the input stream</a></li><li><a href="#document.write()"><span class="secno">8.4.3</span> <code>document.write()</code></a></li><li><a href="#document.writeln()"><span class="secno">8.4.4</span> <code>document.writeln()</code></a></li></ol></li><li><a href="#dom-parsing-and-serialization"><span class="secno">8.5</span> DOM parsing and serialization APIs</a><ol><li><a href="#the-domparser-interface"><span class="secno">8.5.1</span> The <code>DOMParser</code> interface</a></li><li><a href="#unsafe-html-parsing-methods"><span class="secno">8.5.2</span> Unsafe HTML parsing methods</a></li><li><a href="#html-serialization-methods"><span class="secno">8.5.3</span> HTML serialization methods</a></li><li><a href="#the-innerhtml-property"><span class="secno">8.5.4</span> The <code>innerHTML</code> property</a></li><li><a href="#the-outerhtml-property"><span class="secno">8.5.5</span> The <code>outerHTML</code> property</a></li><li><a href="#the-insertadjacenthtml()-method"><span class="secno">8.5.6</span> The <code>insertAdjacentHTML()</code> method</a></li><li><a href="#the-createcontextualfragment()-method"><span class="secno">8.5.7</span> The <code>createContextualFragment()</code>
  method</a></li><li><a href="#the-xmlserializer-interface"><span class="secno">8.5.8</span> The <code>XMLSerializer</code> interface</a></li></ol></li><li><a href="#timers"><span class="secno">8.6</span> Timers</a></li><li><a href="#microtask-queuing"><span class="secno">8.7</span> Microtask queuing</a></li><li><a href="#user-prompts"><span class="secno">8.8</span> User prompts</a><ol><li><a href="#simple-dialogs"><span class="secno">8.8.1</span> Simple dialogs</a></li><li><a href="#printing"><span class="secno">8.8.2</span> Printing</a></li></ol></li><li><a href="#system-state-and-capabilities"><span class="secno">8.9</span> System state and capabilities</a><ol><li><a href="#the-navigator-object"><span class="secno">8.9.1</span> The <code>Navigator</code> object</a><ol><li><a href="#client-identification"><span class="secno">8.9.1.1</span> Client identification</a></li><li><a href="#language-preferences"><span class="secno">8.9.1.2</span> Language preferences</a></li><li><a href="#navigator.online"><span class="secno">8.9.1.3</span> Browser state</a></li><li><a href="#custom-handlers"><span class="secno">8.9.1.4</span> Custom scheme handlers: the <code>registerProtocolHandler()</code> method</a><ol><li><a href="#security-and-privacy"><span class="secno">8.9.1.4.1</span> Security and privacy</a></li><li><a href="#user-agent-automation"><span class="secno">8.9.1.4.2</span> User agent automation</a></li></ol></li><li><a href="#cookies"><span class="secno">8.9.1.5</span> Cookies</a></li><li><a href="#pdf-viewing-support"><span class="secno">8.9.1.6</span> PDF viewing support</a></li></ol></li></ol></li><li><a href="#images-2"><span class="secno">8.10</span> Images</a><ol><li><a href="#the-imagedata-interface"><span class="secno">8.10.1</span> The <code>ImageData</code> interface</a></li><li><a href="#the-imagebitmap-interface"><span class="secno">8.10.2</span> The <code>ImageBitmap</code> interface</a></li></ol></li><li><a href="#animation-frames"><span class="secno">8.11</span> Animation frames</a></li></ol></li><li id="toc-comms"><a href="#comms"><span class="secno">9</span> Communication</a><ol><li><a href="#the-messageevent-interface"><span class="secno">9.1</span> The <code>MessageEvent</code> interface</a></li><li><a href="#server-sent-events"><span class="secno">9.2</span> Server-sent events</a><ol><li><a href="#server-sent-events-intro"><span class="secno">9.2.1</span> Introduction</a></li><li><a href="#the-eventsource-interface"><span class="secno">9.2.2</span> The <code>EventSource</code> interface</a></li><li><a href="#sse-processing-model"><span class="secno">9.2.3</span> Processing model</a></li><li><a href="#the-last-event-id-header"><span class="secno">9.2.4</span> The `<code>Last-Event-ID</code>` header</a></li><li><a href="#parsing-an-event-stream"><span class="secno">9.2.5</span> Parsing an event stream</a></li><li><a href="#event-stream-interpretation"><span class="secno">9.2.6</span> Interpreting an event stream</a></li><li><a href="#authoring-notes"><span class="secno">9.2.7</span> Authoring notes</a></li><li><a href="#eventsource-push"><span class="secno">9.2.8</span> Connectionless push and other features</a></li><li><a href="#garbage-collection"><span class="secno">9.2.9</span> Garbage collection</a></li><li><a href="#implementation-advice"><span class="secno">9.2.10</span> Implementation advice</a></li></ol></li><li><a href="#web-messaging"><span class="secno">9.3</span> Cross-document messaging</a><ol><li><a href="#introduction-12"><span class="secno">9.3.1</span> Introduction</a></li><li><a href="#security-postmsg"><span class="secno">9.3.2</span> Security</a><ol><li><a href="#authors"><span class="secno">9.3.2.1</span> Authors</a></li><li><a href="#user-agents"><span class="secno">9.3.2.2</span> User agents</a></li></ol></li><li><a href="#posting-messages"><span class="secno">9.3.3</span> Posting messages</a></li></ol></li><li><a href="#channel-messaging"><span class="secno">9.4</span> Channel messaging</a><ol><li><a href="#introduction-13"><span class="secno">9.4.1</span> Introduction</a><ol><li><a href="#examples-5"><span class="secno">9.4.1.1</span> Examples</a></li><li><a href="#ports-as-the-basis-of-an-object-capability-model-on-the-web"><span class="secno">9.4.1.2</span> Ports as the basis of an object-capability model on the web</a></li><li><a href="#ports-as-the-basis-of-abstracting-out-service-implementations"><span class="secno">9.4.1.3</span> Ports as the basis of abstracting out service implementations</a></li></ol></li><li><a href="#message-channels"><span class="secno">9.4.2</span> Message channels</a></li><li><a href="#the-messageeventtarget-mixin"><span class="secno">9.4.3</span> The
  <code>MessageEventTarget</code> mixin</a></li><li><a href="#message-ports"><span class="secno">9.4.4</span> Message ports</a></li><li><a href="#ports-and-garbage-collection"><span class="secno">9.4.5</span> Ports and garbage collection</a></li></ol></li><li><a href="#broadcasting-to-other-browsing-contexts"><span class="secno">9.5</span> Broadcasting to other browsing contexts</a></li></ol></li><li id="toc-workers"><a href="#workers"><span class="secno">10</span> Web workers</a><ol><li><a href="#introduction-14"><span class="secno">10.1</span> Introduction</a><ol><li><a href="#scope-2"><span class="secno">10.1.1</span> Scope</a></li><li><a href="#examples-6"><span class="secno">10.1.2</span> Examples</a><ol><li><a href="#a-background-number-crunching-worker"><span class="secno">10.1.2.1</span> A background number-crunching worker</a></li><li><a href="#module-worker-example"><span class="secno">10.1.2.2</span> Using a JavaScript module as a worker</a></li><li><a href="#shared-workers-introduction"><span class="secno">10.1.2.3</span> Shared workers introduction</a></li><li><a href="#shared-state-using-a-shared-worker"><span class="secno">10.1.2.4</span> Shared state using a shared worker</a></li><li><a href="#delegation"><span class="secno">10.1.2.5</span> Delegation</a></li><li><a href="#providing-libraries"><span class="secno">10.1.2.6</span> Providing libraries</a></li></ol></li><li><a href="#tutorials"><span class="secno">10.1.3</span> Tutorials</a><ol><li><a href="#creating-a-dedicated-worker"><span class="secno">10.1.3.1</span> Creating a dedicated worker</a></li><li><a href="#communicating-with-a-dedicated-worker"><span class="secno">10.1.3.2</span> Communicating with a dedicated worker</a></li><li><a href="#shared-workers"><span class="secno">10.1.3.3</span> Shared workers</a></li></ol></li></ol></li><li><a href="#infrastructure-2"><span class="secno">10.2</span> Infrastructure</a><ol><li><a href="#the-global-scope"><span class="secno">10.2.1</span> The global scope</a><ol><li><a href="#the-workerglobalscope-common-interface"><span class="secno">10.2.1.1</span> The <code>WorkerGlobalScope</code> common interface</a></li><li><a href="#dedicated-workers-and-the-dedicatedworkerglobalscope-interface"><span class="secno">10.2.1.2</span> Dedicated workers and the <code>DedicatedWorkerGlobalScope</code> interface</a></li><li><a href="#shared-workers-and-the-sharedworkerglobalscope-interface"><span class="secno">10.2.1.3</span> Shared workers and the <code>SharedWorkerGlobalScope</code> interface</a></li></ol></li><li><a href="#worker-event-loop"><span class="secno">10.2.2</span> The event loop</a></li><li><a href="#the-worker's-lifetime"><span class="secno">10.2.3</span> The worker's lifetime</a></li><li><a href="#worker-processing-model"><span class="secno">10.2.4</span> Processing model</a></li><li><a href="#runtime-script-errors-2"><span class="secno">10.2.5</span> Runtime script errors</a></li><li><a href="#creating-workers"><span class="secno">10.2.6</span> Creating workers</a><ol><li><a href="#the-abstractworker-mixin"><span class="secno">10.2.6.1</span> The
  <code>AbstractWorker</code> mixin</a></li><li><a href="#script-settings-for-workers"><span class="secno">10.2.6.2</span> Script settings for workers</a></li><li><a href="#dedicated-workers-and-the-worker-interface"><span class="secno">10.2.6.3</span> Dedicated workers and the <code>Worker</code> interface</a></li><li><a href="#shared-workers-and-the-sharedworker-interface"><span class="secno">10.2.6.4</span> Shared workers and the <code>SharedWorker</code> interface</a></li></ol></li><li><a href="#navigator.hardwareconcurrency"><span class="secno">10.2.7</span> Concurrent hardware capabilities</a></li></ol></li><li><a href="#apis-available-to-workers"><span class="secno">10.3</span> APIs available to workers</a><ol><li><a href="#importing-scripts-and-libraries"><span class="secno">10.3.1</span> Importing scripts and libraries</a></li><li><a href="#the-workernavigator-object"><span class="secno">10.3.2</span> The <code>WorkerNavigator</code> interface</a></li><li><a href="#worker-locations"><span class="secno">10.3.3</span> The <code>WorkerLocation</code> interface</a></li></ol></li></ol></li><li id="toc-worklets"><a href="#worklets"><span class="secno">11</span> Worklets</a><ol><li><a href="#worklets-intro"><span class="secno">11.1</span> Introduction</a><ol><li><a href="#worklets-motivations"><span class="secno">11.1.1</span> Motivations</a></li><li><a href="#worklets-idempotent"><span class="secno">11.1.2</span> Code idempotence</a></li><li><a href="#worklets-speculative"><span class="secno">11.1.3</span> Speculative evaluation</a></li></ol></li><li><a href="#worklets-examples"><span class="secno">11.2</span> Examples</a><ol><li><a href="#worklets-examples-loading"><span class="secno">11.2.1</span> Loading scripts</a></li><li><a href="#worklets-example-registering"><span class="secno">11.2.2</span> Registering a class and invoking its methods</a></li></ol></li><li><a href="#worklets-infrastructure"><span class="secno">11.3</span> Infrastructure</a><ol><li><a href="#worklets-global"><span class="secno">11.3.1</span> The global scope</a><ol><li><a href="#worklet-agents-and-event-loops"><span class="secno">11.3.1.1</span> Agents and event loops</a></li><li><a href="#worklets-creation-termination"><span class="secno">11.3.1.2</span> Creation and termination</a></li><li><a href="#script-settings-for-worklets"><span class="secno">11.3.1.3</span> Script settings for worklets</a></li></ol></li><li><a href="#worklets-worklet"><span class="secno">11.3.2</span> The <code>Worklet</code> class</a></li><li><a href="#worklets-lifetime"><span class="secno">11.3.3</span> The worklet's lifetime</a></li></ol></li></ol></li><li id="toc-webstorage"><a href="#webstorage"><span class="secno">12</span> Web storage</a><ol><li><a href="#introduction-15"><span class="secno">12.1</span> Introduction</a></li><li><a href="#storage"><span class="secno">12.2</span> The API</a><ol><li><a href="#the-storage-interface"><span class="secno">12.2.1</span> The <code>Storage</code> interface</a></li><li><a href="#the-sessionstorage-attribute"><span class="secno">12.2.2</span> The <code>sessionStorage</code> getter</a></li><li><a href="#the-localstorage-attribute"><span class="secno">12.2.3</span> The <code>localStorage</code> getter</a></li><li><a href="#the-storageevent-interface"><span class="secno">12.2.4</span> The <code>StorageEvent</code> interface</a></li></ol></li><li><a href="#privacy"><span class="secno">12.3</span> Privacy</a><ol><li><a href="#user-tracking"><span class="secno">12.3.1</span> User tracking</a></li><li><a href="#sensitivity-of-data"><span class="secno">12.3.2</span> Sensitivity of data</a></li></ol></li><li><a href="#security-storage"><span class="secno">12.4</span> Security</a><ol><li><a href="#dns-spoofing-attacks"><span class="secno">12.4.1</span> DNS spoofing attacks</a></li><li><a href="#cross-directory-attacks"><span class="secno">12.4.2</span> Cross-directory attacks</a></li><li><a href="#implementation-risks"><span class="secno">12.4.3</span> Implementation risks</a></li></ol></li></ol></li><li id="toc-syntax"><a href="#syntax"><span class="secno">13</span> The HTML syntax</a><ol><li><a href="#writing"><span class="secno">13.1</span> Writing HTML documents</a><ol><li><a href="#the-doctype"><span class="secno">13.1.1</span> The DOCTYPE</a></li><li><a href="#elements-2"><span class="secno">13.1.2</span> Elements</a><ol><li><a href="#start-tags"><span class="secno">13.1.2.1</span> Start tags</a></li><li><a href="#end-tags"><span class="secno">13.1.2.2</span> End tags</a></li><li><a href="#attributes-2"><span class="secno">13.1.2.3</span> Attributes</a></li><li><a href="#optional-tags"><span class="secno">13.1.2.4</span> Optional tags</a></li><li><a href="#element-restrictions"><span class="secno">13.1.2.5</span> Restrictions on content models</a></li><li><a href="#cdata-rcdata-restrictions"><span class="secno">13.1.2.6</span> Restrictions on the contents of raw text and escapable raw text elements</a></li></ol></li><li><a href="#text-2"><span class="secno">13.1.3</span> Text</a><ol><li><a href="#newlines"><span class="secno">13.1.3.1</span> Newlines</a></li></ol></li><li><a href="#character-references"><span class="secno">13.1.4</span> Character references</a></li><li><a href="#cdata-sections"><span class="secno">13.1.5</span> CDATA sections</a></li><li><a href="#comments"><span class="secno">13.1.6</span> Comments</a></li></ol></li><li><a href="#parsing"><span class="secno">13.2</span> Parsing HTML documents</a><ol><li><a href="#overview-of-the-parsing-model"><span class="secno">13.2.1</span> Overview of the parsing model</a></li><li><a href="#parse-errors"><span class="secno">13.2.2</span> Parse errors</a></li><li><a href="#the-input-byte-stream"><span class="secno">13.2.3</span> The input byte stream</a><ol><li><a href="#parsing-with-a-known-character-encoding"><span class="secno">13.2.3.1</span> Parsing with a known character encoding</a></li><li><a href="#determining-the-character-encoding"><span class="secno">13.2.3.2</span> Determining the character encoding</a></li><li><a href="#character-encodings"><span class="secno">13.2.3.3</span> Character encodings</a></li><li><a href="#changing-the-encoding-while-parsing"><span class="secno">13.2.3.4</span> Changing the encoding while parsing</a></li><li><a href="#preprocessing-the-input-stream"><span class="secno">13.2.3.5</span> Preprocessing the input stream</a></li></ol></li><li><a href="#parse-state"><span class="secno">13.2.4</span> Parse state</a><ol><li><a href="#the-insertion-mode"><span class="secno">13.2.4.1</span> The insertion mode</a></li><li><a href="#the-stack-of-open-elements"><span class="secno">13.2.4.2</span> The stack of open elements</a></li><li><a href="#the-list-of-active-formatting-elements"><span class="secno">13.2.4.3</span> The list of active formatting elements</a></li><li><a href="#the-element-pointers"><span class="secno">13.2.4.4</span> The element pointers</a></li><li><a href="#other-parsing-state-flags"><span class="secno">13.2.4.5</span> Other parsing state flags</a></li></ol></li><li><a href="#tokenization"><span class="secno">13.2.5</span> Tokenization</a><ol><li><a href="#data-state"><span class="secno">13.2.5.1</span> Data state</a></li><li><a href="#rcdata-state"><span class="secno">13.2.5.2</span> RCDATA state</a></li><li><a href="#rawtext-state"><span class="secno">13.2.5.3</span> RAWTEXT state</a></li><li><a href="#script-data-state"><span class="secno">13.2.5.4</span> Script data state</a></li><li><a href="#plaintext-state"><span class="secno">13.2.5.5</span> PLAINTEXT state</a></li><li><a href="#tag-open-state"><span class="secno">13.2.5.6</span> Tag open state</a></li><li><a href="#end-tag-open-state"><span class="secno">13.2.5.7</span> End tag open state</a></li><li><a href="#tag-name-state"><span class="secno">13.2.5.8</span> Tag name state</a></li><li><a href="#rcdata-less-than-sign-state"><span class="secno">13.2.5.9</span> RCDATA less-than sign state</a></li><li><a href="#rcdata-end-tag-open-state"><span class="secno">13.2.5.10</span> RCDATA end tag open state</a></li><li><a href="#rcdata-end-tag-name-state"><span class="secno">13.2.5.11</span> RCDATA end tag name state</a></li><li><a href="#rawtext-less-than-sign-state"><span class="secno">13.2.5.12</span> RAWTEXT less-than sign state</a></li><li><a href="#rawtext-end-tag-open-state"><span class="secno">13.2.5.13</span> RAWTEXT end tag open state</a></li><li><a href="#rawtext-end-tag-name-state"><span class="secno">13.2.5.14</span> RAWTEXT end tag name state</a></li><li><a href="#script-data-less-than-sign-state"><span class="secno">13.2.5.15</span> Script data less-than sign state</a></li><li><a href="#script-data-end-tag-open-state"><span class="secno">13.2.5.16</span> Script data end tag open state</a></li><li><a href="#script-data-end-tag-name-state"><span class="secno">13.2.5.17</span> Script data end tag name state</a></li><li><a href="#script-data-escape-start-state"><span class="secno">13.2.5.18</span> Script data escape start state</a></li><li><a href="#script-data-escape-start-dash-state"><span class="secno">13.2.5.19</span> Script data escape start dash state</a></li><li><a href="#script-data-escaped-state"><span class="secno">13.2.5.20</span> Script data escaped state</a></li><li><a href="#script-data-escaped-dash-state"><span class="secno">13.2.5.21</span> Script data escaped dash state</a></li><li><a href="#script-data-escaped-dash-dash-state"><span class="secno">13.2.5.22</span> Script data escaped dash dash state</a></li><li><a href="#script-data-escaped-less-than-sign-state"><span class="secno">13.2.5.23</span> Script data escaped less-than sign state</a></li><li><a href="#script-data-escaped-end-tag-open-state"><span class="secno">13.2.5.24</span> Script data escaped end tag open state</a></li><li><a href="#script-data-escaped-end-tag-name-state"><span class="secno">13.2.5.25</span> Script data escaped end tag name state</a></li><li><a href="#script-data-double-escape-start-state"><span class="secno">13.2.5.26</span> Script data double escape start state</a></li><li><a href="#script-data-double-escaped-state"><span class="secno">13.2.5.27</span> Script data double escaped state</a></li><li><a href="#script-data-double-escaped-dash-state"><span class="secno">13.2.5.28</span> Script data double escaped dash state</a></li><li><a href="#script-data-double-escaped-dash-dash-state"><span class="secno">13.2.5.29</span> Script data double escaped dash dash state</a></li><li><a href="#script-data-double-escaped-less-than-sign-state"><span class="secno">13.2.5.30</span> Script data double escaped less-than sign state</a></li><li><a href="#script-data-double-escape-end-state"><span class="secno">13.2.5.31</span> Script data double escape end state</a></li><li><a href="#before-attribute-name-state"><span class="secno">13.2.5.32</span> Before attribute name state</a></li><li><a href="#attribute-name-state"><span class="secno">13.2.5.33</span> Attribute name state</a></li><li><a href="#after-attribute-name-state"><span class="secno">13.2.5.34</span> After attribute name state</a></li><li><a href="#before-attribute-value-state"><span class="secno">13.2.5.35</span> Before attribute value state</a></li><li><a href="#attribute-value-(double-quoted)-state"><span class="secno">13.2.5.36</span> Attribute value (double-quoted) state</a></li><li><a href="#attribute-value-(single-quoted)-state"><span class="secno">13.2.5.37</span> Attribute value (single-quoted) state</a></li><li><a href="#attribute-value-(unquoted)-state"><span class="secno">13.2.5.38</span> Attribute value (unquoted) state</a></li><li><a href="#after-attribute-value-(quoted)-state"><span class="secno">13.2.5.39</span> After attribute value (quoted) state</a></li><li><a href="#self-closing-start-tag-state"><span class="secno">13.2.5.40</span> Self-closing start tag state</a></li><li><a href="#bogus-comment-state"><span class="secno">13.2.5.41</span> Bogus comment state</a></li><li><a href="#markup-declaration-open-state"><span class="secno">13.2.5.42</span> Markup declaration open state</a></li><li><a href="#comment-start-state"><span class="secno">13.2.5.43</span> Comment start state</a></li><li><a href="#comment-start-dash-state"><span class="secno">13.2.5.44</span> Comment start dash state</a></li><li><a href="#comment-state"><span class="secno">13.2.5.45</span> Comment state</a></li><li><a href="#comment-less-than-sign-state"><span class="secno">13.2.5.46</span> Comment less-than sign state</a></li><li><a href="#comment-less-than-sign-bang-state"><span class="secno">13.2.5.47</span> Comment less-than sign bang state</a></li><li><a href="#comment-less-than-sign-bang-dash-state"><span class="secno">13.2.5.48</span> Comment less-than sign bang dash state</a></li><li><a href="#comment-less-than-sign-bang-dash-dash-state"><span class="secno">13.2.5.49</span> Comment less-than sign bang dash dash state</a></li><li><a href="#comment-end-dash-state"><span class="secno">13.2.5.50</span> Comment end dash state</a></li><li><a href="#comment-end-state"><span class="secno">13.2.5.51</span> Comment end state</a></li><li><a href="#comment-end-bang-state"><span class="secno">13.2.5.52</span> Comment end bang state</a></li><li><a href="#doctype-state"><span class="secno">13.2.5.53</span> DOCTYPE state</a></li><li><a href="#before-doctype-name-state"><span class="secno">13.2.5.54</span> Before DOCTYPE name state</a></li><li><a href="#doctype-name-state"><span class="secno">13.2.5.55</span> DOCTYPE name state</a></li><li><a href="#after-doctype-name-state"><span class="secno">13.2.5.56</span> After DOCTYPE name state</a></li><li><a href="#after-doctype-public-keyword-state"><span class="secno">13.2.5.57</span> After DOCTYPE public keyword state</a></li><li><a href="#before-doctype-public-identifier-state"><span class="secno">13.2.5.58</span> Before DOCTYPE public identifier state</a></li><li><a href="#doctype-public-identifier-(double-quoted)-state"><span class="secno">13.2.5.59</span> DOCTYPE public identifier (double-quoted) state</a></li><li><a href="#doctype-public-identifier-(single-quoted)-state"><span class="secno">13.2.5.60</span> DOCTYPE public identifier (single-quoted) state</a></li><li><a href="#after-doctype-public-identifier-state"><span class="secno">13.2.5.61</span> After DOCTYPE public identifier state</a></li><li><a href="#between-doctype-public-and-system-identifiers-state"><span class="secno">13.2.5.62</span> Between DOCTYPE public and system identifiers state</a></li><li><a href="#after-doctype-system-keyword-state"><span class="secno">13.2.5.63</span> After DOCTYPE system keyword state</a></li><li><a href="#before-doctype-system-identifier-state"><span class="secno">13.2.5.64</span> Before DOCTYPE system identifier state</a></li><li><a href="#doctype-system-identifier-(double-quoted)-state"><span class="secno">13.2.5.65</span> DOCTYPE system identifier (double-quoted) state</a></li><li><a href="#doctype-system-identifier-(single-quoted)-state"><span class="secno">13.2.5.66</span> DOCTYPE system identifier (single-quoted) state</a></li><li><a href="#after-doctype-system-identifier-state"><span class="secno">13.2.5.67</span> After DOCTYPE system identifier state</a></li><li><a href="#bogus-doctype-state"><span class="secno">13.2.5.68</span> Bogus DOCTYPE state</a></li><li><a href="#cdata-section-state"><span class="secno">13.2.5.69</span> CDATA section state</a></li><li><a href="#cdata-section-bracket-state"><span class="secno">13.2.5.70</span> CDATA section bracket state</a></li><li><a href="#cdata-section-end-state"><span class="secno">13.2.5.71</span> CDATA section end state</a></li><li><a href="#character-reference-state"><span class="secno">13.2.5.72</span> Character reference state</a></li><li><a href="#named-character-reference-state"><span class="secno">13.2.5.73</span> Named character reference state</a></li><li><a href="#ambiguous-ampersand-state"><span class="secno">13.2.5.74</span> Ambiguous ampersand state</a></li><li><a href="#numeric-character-reference-state"><span class="secno">13.2.5.75</span> Numeric character reference state</a></li><li><a href="#hexadecimal-character-reference-start-state"><span class="secno">13.2.5.76</span> Hexadecimal character reference start state</a></li><li><a href="#decimal-character-reference-start-state"><span class="secno">13.2.5.77</span> Decimal character reference start state</a></li><li><a href="#hexadecimal-character-reference-state"><span class="secno">13.2.5.78</span> Hexadecimal character reference state</a></li><li><a href="#decimal-character-reference-state"><span class="secno">13.2.5.79</span> Decimal character reference state</a></li><li><a href="#numeric-character-reference-end-state"><span class="secno">13.2.5.80</span> Numeric character reference end state</a></li></ol></li><li><a href="#tree-construction"><span class="secno">13.2.6</span> Tree construction</a><ol><li><a href="#creating-and-inserting-nodes"><span class="secno">13.2.6.1</span> Creating and inserting nodes</a></li><li><a href="#parsing-elements-that-contain-only-text"><span class="secno">13.2.6.2</span> Parsing elements that contain only text</a></li><li><a href="#closing-elements-that-have-implied-end-tags"><span class="secno">13.2.6.3</span> Closing elements that have implied end tags</a></li><li><a href="#parsing-main-inhtml"><span class="secno">13.2.6.4</span> The rules for parsing tokens in HTML content</a><ol><li><a href="#the-initial-insertion-mode"><span class="secno">13.2.6.4.1</span> The "initial" insertion mode</a></li><li><a href="#the-before-html-insertion-mode"><span class="secno">13.2.6.4.2</span> The "before html" insertion mode</a></li><li><a href="#the-before-head-insertion-mode"><span class="secno">13.2.6.4.3</span> The "before head" insertion mode</a></li><li><a href="#parsing-main-inhead"><span class="secno">13.2.6.4.4</span> The "in head" insertion mode</a></li><li><a href="#parsing-main-inheadnoscript"><span class="secno">13.2.6.4.5</span> The "in head noscript" insertion mode</a></li><li><a href="#the-after-head-insertion-mode"><span class="secno">13.2.6.4.6</span> The "after head" insertion mode</a></li><li><a href="#parsing-main-inbody"><span class="secno">13.2.6.4.7</span> The "in body" insertion mode</a></li><li><a href="#parsing-main-incdata"><span class="secno">13.2.6.4.8</span> The "text" insertion mode</a></li><li><a href="#parsing-main-intable"><span class="secno">13.2.6.4.9</span> The "in table" insertion mode</a></li><li><a href="#parsing-main-intabletext"><span class="secno">13.2.6.4.10</span> The "in table text" insertion mode</a></li><li><a href="#parsing-main-incaption"><span class="secno">13.2.6.4.11</span> The "in caption" insertion mode</a></li><li><a href="#parsing-main-incolgroup"><span class="secno">13.2.6.4.12</span> The "in column group" insertion mode</a></li><li><a href="#parsing-main-intbody"><span class="secno">13.2.6.4.13</span> The "in table body" insertion mode</a></li><li><a href="#parsing-main-intr"><span class="secno">13.2.6.4.14</span> The "in row" insertion mode</a></li><li><a href="#parsing-main-intd"><span class="secno">13.2.6.4.15</span> The "in cell" insertion mode</a></li><li><a href="#parsing-main-intemplate"><span class="secno">13.2.6.4.16</span> The "in template" insertion mode</a></li><li><a href="#parsing-main-afterbody"><span class="secno">13.2.6.4.17</span> The "after body" insertion mode</a></li><li><a href="#parsing-main-inframeset"><span class="secno">13.2.6.4.18</span> The "in frameset" insertion mode</a></li><li><a href="#parsing-main-afterframeset"><span class="secno">13.2.6.4.19</span> The "after frameset" insertion mode</a></li><li><a href="#the-after-after-body-insertion-mode"><span class="secno">13.2.6.4.20</span> The "after after body" insertion mode</a></li><li><a href="#the-after-after-frameset-insertion-mode"><span class="secno">13.2.6.4.21</span> The "after after frameset" insertion mode</a></li></ol></li><li><a href="#parsing-main-inforeign"><span class="secno">13.2.6.5</span> The rules for parsing tokens in foreign content</a></li></ol></li><li><a href="#the-end"><span class="secno">13.2.7</span> The end</a></li><li><a href="#speculative-html-parsing"><span class="secno">13.2.8</span> Speculative HTML parsing</a></li><li><a href="#coercing-an-html-dom-into-an-infoset"><span class="secno">13.2.9</span> Coercing an HTML DOM into an infoset</a></li><li><a href="#an-introduction-to-error-handling-and-strange-cases-in-the-parser"><span class="secno">13.2.10</span> An introduction to error handling and strange cases in the parser</a><ol><li><a href="#misnested-tags:-b-i-/b-/i"><span class="secno">13.2.10.1</span> Misnested tags: &lt;b&gt;&lt;i&gt;&lt;/b&gt;&lt;/i&gt;</a></li><li><a href="#misnested-tags:-b-p-/b-/p"><span class="secno">13.2.10.2</span> Misnested tags: &lt;b&gt;&lt;p&gt;&lt;/b&gt;&lt;/p&gt;</a></li><li><a href="#unexpected-markup-in-tables"><span class="secno">13.2.10.3</span> Unexpected markup in tables</a></li><li><a href="#scripts-that-modify-the-page-as-it-is-being-parsed"><span class="secno">13.2.10.4</span> Scripts that modify the page as it is being parsed</a></li><li><a href="#the-execution-of-scripts-that-are-moving-across-multiple-documents"><span class="secno">13.2.10.5</span> The execution of scripts that are moving across multiple documents</a></li><li><a href="#unclosed-formatting-elements"><span class="secno">13.2.10.6</span> Unclosed formatting elements</a></li></ol></li></ol></li><li><a href="#serialising-html-fragments"><span class="secno">13.3</span> Serializing HTML fragments</a></li><li><a href="#parsing-html-fragments"><span class="secno">13.4</span> Parsing HTML fragments</a></li><li><a href="#named-character-references"><span class="secno">13.5</span> Named character references</a></li></ol></li><li id="toc-the-xhtml-syntax"><a href="#the-xhtml-syntax"><span class="secno">14</span> The XML syntax</a><ol><li><a href="#writing-xhtml-documents"><span class="secno">14.1</span> Writing documents in the XML syntax</a></li><li><a href="#parsing-xhtml-documents"><span class="secno">14.2</span> Parsing XML documents</a></li><li><a href="#serialising-xhtml-fragments"><span class="secno">14.3</span> Serializing XML fragments</a></li><li><a href="#parsing-xhtml-fragments"><span class="secno">14.4</span> Parsing XML fragments</a></li></ol></li><li id="toc-rendering"><a href="#rendering"><span class="secno">15</span> Rendering</a><ol><li><a href="#introduction-16"><span class="secno">15.1</span> Introduction</a></li><li><a href="#the-css-user-agent-style-sheet-and-presentational-hints"><span class="secno">15.2</span> The CSS user agent style sheet and presentational hints</a></li><li><a href="#non-replaced-elements"><span class="secno">15.3</span> Non-replaced elements</a><ol><li><a href="#hidden-elements"><span class="secno">15.3.1</span> Hidden elements</a></li><li><a href="#the-page"><span class="secno">15.3.2</span> The page</a></li><li><a href="#flow-content-3"><span class="secno">15.3.3</span> Flow content</a></li><li><a href="#phrasing-content-3"><span class="secno">15.3.4</span> Phrasing content</a></li><li><a href="#bidi-rendering"><span class="secno">15.3.5</span> Bidirectional text</a></li><li><a href="#sections-and-headings"><span class="secno">15.3.6</span> Sections and headings</a></li><li><a href="#lists"><span class="secno">15.3.7</span> Lists</a></li><li><a href="#tables-2"><span class="secno">15.3.8</span> Tables</a></li><li><a href="#margin-collapsing-quirks"><span class="secno">15.3.9</span> Margin collapsing quirks</a></li><li><a href="#form-controls"><span class="secno">15.3.10</span> Form controls</a></li><li><a href="#the-hr-element-2"><span class="secno">15.3.11</span> The <code>hr</code> element</a></li><li><a href="#the-fieldset-and-legend-elements"><span class="secno">15.3.12</span> The <code>fieldset</code> and <code>legend</code> elements</a></li></ol></li><li><a href="#replaced-elements"><span class="secno">15.4</span> Replaced elements</a><ol><li><a href="#embedded-content-rendering-rules"><span class="secno">15.4.1</span> Embedded content</a></li><li><a href="#images-3"><span class="secno">15.4.2</span> Images</a></li><li><a href="#attributes-for-embedded-content-and-images"><span class="secno">15.4.3</span> Attributes for embedded content and images</a></li><li><a href="#image-maps-2"><span class="secno">15.4.4</span> Image maps</a></li></ol></li><li><a href="#widgets"><span class="secno">15.5</span> Widgets</a><ol><li><a href="#native-appearance-2"><span class="secno">15.5.1</span> Native appearance</a></li><li><a href="#writing-mode"><span class="secno">15.5.2</span> Writing mode</a></li><li><a href="#button-layout"><span class="secno">15.5.3</span> Button layout</a></li><li><a href="#the-button-element-2"><span class="secno">15.5.4</span> The <code>button</code> element</a></li><li><a href="#the-details-and-summary-elements"><span class="secno">15.5.5</span> The <code>details</code> and <code>summary</code> elements</a></li><li><a href="#the-input-element-as-a-text-entry-widget"><span class="secno">15.5.6</span> The <code>input</code> element as a text entry widget</a></li><li><a href="#the-input-element-as-domain-specific-widgets"><span class="secno">15.5.7</span> The <code>input</code> element as domain-specific widgets</a></li><li><a href="#the-input-element-as-a-range-control"><span class="secno">15.5.8</span> The <code>input</code> element as a range control</a></li><li><a href="#the-input-element-as-a-colour-well"><span class="secno">15.5.9</span> The <code>input</code> element as a color
  well</a></li><li><a href="#the-input-element-as-a-checkbox-and-radio-button-widgets"><span class="secno">15.5.10</span> The <code>input</code> element as a checkbox and radio button widgets</a></li><li><a href="#the-input-element-as-a-file-upload-control"><span class="secno">15.5.11</span> The <code>input</code> element as a file upload control</a></li><li><a href="#the-input-element-as-a-button"><span class="secno">15.5.12</span> The <code>input</code> element as a button</a></li><li><a href="#the-marquee-element-2"><span class="secno">15.5.13</span> The <code>marquee</code> element</a></li><li><a href="#the-meter-element-2"><span class="secno">15.5.14</span> The <code>meter</code> element</a></li><li><a href="#the-progress-element-2"><span class="secno">15.5.15</span> The <code>progress</code> element</a></li><li><a href="#the-select-element-2"><span class="secno">15.5.16</span> The <code>select</code> element</a></li><li><a href="#the-textarea-element-2"><span class="secno">15.5.17</span> The <code>textarea</code> element</a></li></ol></li><li><a href="#frames-and-framesets"><span class="secno">15.6</span> Frames and framesets</a></li><li><a href="#interactive-media"><span class="secno">15.7</span> Interactive media</a><ol><li><a href="#links,-forms,-and-navigation"><span class="secno">15.7.1</span> Links, forms, and navigation</a></li><li><a href="#the-title-attribute-2"><span class="secno">15.7.2</span> The <code>title</code> attribute</a></li><li><a href="#editing-hosts"><span class="secno">15.7.3</span> Editing hosts</a></li><li><a href="#text-rendered-in-native-user-interfaces"><span class="secno">15.7.4</span> Text rendered in native user interfaces</a></li></ol></li><li><a href="#print-media"><span class="secno">15.8</span> Print media</a></li><li><a href="#unstyled-xml-documents"><span class="secno">15.9</span> Unstyled XML documents</a></li></ol></li><li id="toc-obsolete"><a href="#obsolete"><span class="secno">16</span> Obsolete features</a><ol><li><a href="#obsolete-but-conforming-features"><span class="secno">16.1</span> Obsolete but conforming features</a><ol><li><a href="#warnings-for-obsolete-but-conforming-features"><span class="secno">16.1.1</span> Warnings for obsolete but conforming features</a></li></ol></li><li><a href="#non-conforming-features"><span class="secno">16.2</span> Non-conforming features</a></li><li><a href="#requirements-for-implementations"><span class="secno">16.3</span> Requirements for implementations</a><ol><li><a href="#the-marquee-element"><span class="secno">16.3.1</span> The <code>marquee</code> element</a></li><li><a href="#frames"><span class="secno">16.3.2</span> Frames</a></li><li><a href="#other-elements,-attributes-and-apis"><span class="secno">16.3.3</span> Other elements, attributes and APIs</a></li></ol></li></ol></li><li id="toc-iana"><a href="#iana"><span class="secno">17</span> IANA considerations</a><ol><li><a href="#text/html"><span class="secno">17.1</span> <code>text/html</code></a></li><li><a href="#multipart/x-mixed-replace"><span class="secno">17.2</span> <code>multipart/x-mixed-replace</code></a></li><li><a href="#application/xhtml+xml"><span class="secno">17.3</span> <code>application/xhtml+xml</code></a></li><li><a href="#text/ping"><span class="secno">17.4</span> <code>text/ping</code></a></li><li><a href="#application/microdata+json"><span class="secno">17.5</span> <code>application/microdata+json</code></a></li><li><a href="#application/speculationrules+json"><span class="secno">17.6</span> <code>application/speculationrules+json</code></a></li><li><a href="#text/event-stream"><span class="secno">17.7</span> <code>text/event-stream</code></a></li><li><a href="#web+-scheme-prefix"><span class="secno">17.8</span> <code>web+</code> scheme prefix</a></li></ol></li><li id="toc-index"><a href="#index">Index</a><ol><li><a href="#elements-3">Elements</a></li><li><a href="#element-content-categories">Element content categories</a></li><li><a href="#attributes-3">Attributes</a></li><li><a href="#element-interfaces">Element interfaces</a></li><li><a href="#all-interfaces">All interfaces</a></li><li><a href="#events-2">Events</a></li><li><a href="#http-headers">HTTP headers</a></li><li><a href="#mime-types-2">MIME types</a></li></ol></li><li id="toc-references"><a href="#references">References</a></li><li id="toc-acknowledgments"><a href="#acknowledgments">Acknowledgments</a></li><li id="toc-ipr"><a href="#ipr">Intellectual property rights</a></li></ol>

  

  <h2 id="introduction"><span class="secno">1</span> Introduction<a href="#introduction" class="self-link"></a></h2>

  

  <h3 id="abstract"><span class="secno">1.1</span> Where does this specification fit?<a href="#abstract" class="self-link"></a></h3>

  <p>This specification defines a big part of the web platform, in lots of detail. Its place in the
  web platform specification stack relative to other specifications can be best summed up as
  follows:</p>

  <svg id="abstractimg" width="398" role="img" viewBox="0 0 398 359" height="359" aria-label="It consists of everything else, above such core technologies as HTTP, TLS, DOM, Unicode, Web IDL, MIME, URL, XML, JavaScript, and Encoding; below higher-level technologies like CSS, SVG, MathML, and Service Workers; and to the side of technologies like IndexedDB, Fetch, CSP, AV1, Opus, and PNG.">
   <rect width="398" height="80"></rect>
   <text class="horizontal" x="199" y="45">CSS SVG MathML Service Workers</text>
   <rect width="67" y="85" height="177"></rect>
   <text transform="translate(25 173.5) rotate(-90)" class="left">IDB Fetch CSP</text>
   <text transform="translate(50 173.5) rotate(-90)" class="left">AV1 Opus PNG</text>
   
   <image xlink:href="/images/abstract.jpeg" width="326" x="72" y="85" height="177"></image>
   <text class="right" x="130" y="250">THIS SPECIFICATION</text>
   <rect width="398" y="267" height="92"></rect>
   <text class="horizontal" x="199" y="300">HTTP TLS DOM Unicode Web IDL</text>
   <text class="horizontal" x="199" y="330">MIME URL XML JavaScript Encoding</text>
  </svg>

  


  <h3 id="is-this-html5?"><span class="secno">1.2</span> Is this HTML5?<a href="#is-this-html5?" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>In short: Yes.</p>

  <p>In more length: the term "HTML5" is widely used as a buzzword to refer to modern web
  technologies, many of which (though by no means all) are developed at the WHATWG. This document is
  one such; others are available from <a href="https://spec.whatwg.org/">the WHATWG Standards
  overview</a>.</p>


  <h3 id="background"><span class="secno">1.3</span> Background<a href="#background" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>HTML is the World Wide Web's core markup language. Originally, HTML was primarily designed as a
  language for semantically describing scientific documents. Its general design, however, has
  enabled it to be adapted, over the subsequent years, to describe a number of other types of
  documents and even applications.</p>


  <h3 id="audience"><span class="secno">1.4</span> Audience<a href="#audience" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>This specification is intended for authors of documents and scripts that use the features
  defined in this specification, implementers of tools that operate on pages that
  use the features defined in this specification, and individuals wishing to establish the
  correctness of documents or implementations with respect to the requirements of this
  specification.</p>

  <p>This document is probably not suited to readers who do not already have at least a passing
  familiarity with web technologies, as in places it sacrifices clarity for precision, and brevity
  for completeness. More approachable tutorials and authoring guides can provide a gentler
  introduction to the topic.</p>

  <p>In particular, familiarity with the basics of DOM is necessary for a complete understanding of
  some of the more technical parts of this specification. An understanding of Web IDL, HTTP, XML,
  Unicode, character encodings, JavaScript, and CSS will also be helpful in places but is not
  essential.</p>


  <h3 id="scope"><span class="secno">1.5</span> Scope<a href="#scope" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>This specification is limited to providing a semantic-level markup language and associated
  semantic-level scripting APIs for authoring accessible pages on the web ranging from static
  documents to dynamic applications.</p>

  <p>The scope of this specification does not include providing mechanisms for media-specific
  customization of presentation (although default rendering rules for web browsers are included at
  the end of this specification, and several mechanisms for hooking into CSS are provided as part of
  the language).</p>

  <p>The scope of this specification is not to describe an entire operating system. In particular,
  hardware configuration software, image manipulation tools, and applications that users would be
  expected to use with high-end workstations on a daily basis are out of scope. In terms of
  applications, this specification is targeted specifically at applications that would be expected
  to be used by users on an occasional basis, or regularly but from disparate locations, with low
  CPU requirements. Examples of such applications include online purchasing systems, searching
  systems, games (especially multiplayer online games), public telephone books or address books,
  communications software (email clients, instant messaging clients, discussion software), document
  editing software, etc.</p>


  <h3 id="history-2"><span class="secno">1.6</span> History<a href="#history-2" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>For its first five years (1990-1995), HTML went through a number of revisions and experienced a
  number of extensions, primarily hosted first at CERN, and then at the IETF.</p>

  <p>With the creation of the W3C, HTML's development changed venue again. A first abortive attempt
  at extending HTML in 1995 known as HTML 3.0 then made way to a more pragmatic approach known as
  HTML 3.2, which was completed in 1997. HTML4 quickly followed later that same year.</p>

  <p>The following year, the W3C membership decided to stop evolving HTML and instead begin work on
  an XML-based equivalent, called XHTML.  This
  effort started with a reformulation of HTML4 in XML, known as XHTML 1.0, which added no new
  features except the new serialization, and which was completed in 2000. After XHTML 1.0, the W3C's
  focus turned to making it easier for other working groups to extend XHTML, under the banner of
  XHTML Modularization. In parallel with this, the W3C also worked on a new language that was not
  compatible with the earlier HTML and XHTML languages, calling it XHTML2.</p>

  <p>Around the time that HTML's evolution was stopped in 1998, parts of the API for HTML developed
  by browser vendors were specified and published under the name DOM Level 1 (in 1998) and DOM Level
  2 Core and DOM Level 2 HTML (starting in 2000 and culminating in 2003). These efforts then petered
  out, with some DOM Level 3 specifications published in 2004 but the working group being closed
  before all the Level 3 drafts were completed.</p>

  <p>In 2003, the publication of XForms, a technology which was positioned as the next generation of
  web forms, sparked a renewed interest in evolving HTML itself, rather than finding replacements
  for it. This interest was borne from the realization that XML's deployment as a web technology was
  limited to entirely new technologies (like RSS and later Atom), rather than as a replacement for
  existing deployed technologies (like HTML).</p>

  <p>A proof of concept to show that it was possible to extend HTML4's forms to provide many of the
  features that XForms 1.0 introduced, without requiring browsers to implement rendering engines
  that were incompatible with existing HTML web pages, was the first result of this renewed
  interest. At this early stage, while the draft was already publicly available, and input was
  already being solicited from all sources, the specification was only under Opera Software's
  copyright.</p>

  <p>The idea that HTML's evolution should be reopened was tested at a W3C workshop in 2004, where
  some of the principles that underlie the HTML5 work (described below), as well as the
  aforementioned early draft proposal covering just forms-related features, were presented to the
  W3C jointly by Mozilla and Opera. The proposal was rejected on the grounds that the proposal
  conflicted with the previously chosen direction for the web's evolution; the W3C staff and
  membership voted to continue developing XML-based replacements instead.</p>

  <p>Shortly thereafter, Apple, Mozilla, and Opera jointly announced their intent to continue
  working on the effort under the umbrella of a new venue called the WHATWG. A public mailing list
  was created, and the draft was moved to the WHATWG site. The copyright was subsequently amended to
  be jointly owned by all three vendors, and to allow reuse of the specification.</p>

  <p>The WHATWG was based on several core principles, in particular that technologies need to be
  backwards compatible, that specifications and implementations need to match even if this means
  changing the specification rather than the implementations, and that specifications need to be
  detailed enough that implementations can achieve complete interoperability without
  reverse-engineering each other.</p>

  <p>The latter requirement in particular required that the scope of the HTML5 specification include
  what had previously been specified in three separate documents: HTML4, XHTML1, and DOM2 HTML. It
  also meant including significantly more detail than had previously been considered the norm.</p>

  <p>In 2006, the W3C indicated an interest to participate in the development of HTML5 after all,
  and in 2007 formed a working group chartered to work with the WHATWG on the development of the
  HTML5 specification. Apple, Mozilla, and Opera allowed the W3C to publish the specification under
  the W3C copyright, while keeping a version with the less restrictive license on the WHATWG
  site.</p>

  <p>For a number of years, both groups then worked together. In 2011, however, the groups came to
  the conclusion that they had different goals: the W3C wanted to publish a "finished" version of
  "HTML5", while the WHATWG wanted to continue working on a Living Standard for HTML, continuously
  maintaining the specification rather than freezing it in a state with known problems, and adding
  new features as needed to evolve the platform.</p>

  <p>In 2019, the WHATWG and W3C <a href="https://www.w3.org/blog/news/archives/7753">signed an
  agreement</a> to collaborate on a single version of HTML going forward: this document.</p>



  <h3 id="design-notes"><span class="secno">1.7</span> Design notes<a href="#design-notes" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>It must be admitted that many aspects of HTML appear at first glance to be nonsensical and
  inconsistent.</p>

  <p>HTML, its supporting DOM APIs, as well as many of its supporting technologies, have been
  developed over a period of several decades by a wide array of people with different priorities
  who, in many cases, did not know of each other's existence.</p>

  <p>Features have thus arisen from many sources, and have not always been designed in especially
  consistent ways. Furthermore, because of the unique characteristics of the web, implementation
  bugs have often become de-facto, and now de-jure, standards, as content is often unintentionally
  written in ways that rely on them before they can be fixed.</p>

  <p>Despite all this, efforts have been made to adhere to certain design goals. These are described
  in the next few subsections.</p>


  

  <h4 id="serialisability-of-script-execution"><span class="secno">1.7.1</span> Serializability of script execution<a href="#serialisability-of-script-execution" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>To avoid exposing web authors to the complexities of multithreading, the HTML and DOM APIs are
  designed such that no script can ever detect the simultaneous execution of other scripts. Even
  with <a href="#worker" id="serialisability-of-script-execution:worker">workers</a>, the intent is that the behavior of implementations can
  be thought of as completely serializing the execution of all scripts in all globals.</p>

  <p>The exception to this general design principle is the JavaScript <code id="serialisability-of-script-execution:sharedarraybuffer"><a data-x-internal="sharedarraybuffer" href="https://tc39.es/ecma262/#sec-sharedarraybuffer-objects">SharedArrayBuffer</a></code>
  class. Using <code id="serialisability-of-script-execution:sharedarraybuffer-2"><a data-x-internal="sharedarraybuffer" href="https://tc39.es/ecma262/#sec-sharedarraybuffer-objects">SharedArrayBuffer</a></code> objects, it can in fact be observed that scripts in
  other <a href="https://tc39.es/ecma262/#sec-agents" id="serialisability-of-script-execution:agent" data-x-internal="agent">agents</a> are executing simultaneously. Furthermore, due to the
  JavaScript memory model, there are situations which not only are un-representable via serialized
  <em>script</em> execution, but also un-representable via serialized <em>statement</em> execution
  among those scripts.</p>

  



  <h4 id="extensibility"><span class="secno">1.7.2</span> Extensibility<a href="#extensibility" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>HTML has a wide array of extensibility mechanisms that can be used for adding semantics in a
  safe manner:</p>

  <ul><li><p>Authors can use the <code id="extensibility:classes"><a href="#classes">class</a></code> attribute to extend elements,
   effectively creating their own elements, while using the most applicable existing "real" HTML
   element, so that browsers and other tools that don't know of the extension can still support it
   somewhat well. This is the tack used by microformats, for example.</p></li><li><p>Authors can include data for inline client-side scripts or server-side site-wide scripts
   to process using the <code id="extensibility:attr-data-*"><a href="#attr-data-*">data-*=""</a></code> attributes. These are guaranteed
   to never be touched by browsers, and allow scripts to include data on HTML elements that scripts
   can then look for and process.</p></li><li><p>Authors can use the <code id="extensibility:the-meta-element"><a href="#the-meta-element">&lt;meta name="" content=""&gt;</a></code> mechanism to
   include page-wide metadata.</p></li><li><p>Authors can use the <code id="extensibility:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel=""</a></code> mechanism to annotate
   links with specific meanings by registering <a href="#concept-rel-extensions" id="extensibility:concept-rel-extensions">extensions to
   the predefined set of link types</a>. This is also used by microformats.</p></li><li><p>Authors can embed raw data using the <code id="extensibility:the-script-element"><a href="#the-script-element">&lt;script type=""&gt;</a></code>
   mechanism with a custom type, for further handling by inline or server-side scripts.</p></li><li><p>Authors can extend APIs using the JavaScript prototyping mechanism. This is widely used by
   script libraries, for instance.</p></li><li><p>Authors can use the microdata feature (the <code id="extensibility:attr-itemscope"><a href="#attr-itemscope">itemscope=""</a></code> and <code id="extensibility:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop=""</a></code>
   attributes) to embed nested name-value pairs of data to be shared with other applications and
   sites.</p></li><li><p>Authors can define, share, and use <a href="#custom-element" id="extensibility:custom-element">custom elements</a>
   to extend the vocabulary of HTML. The requirements of <a href="#valid-custom-element-name" id="extensibility:valid-custom-element-name">valid custom element names</a> ensure forward compatibility (since no elements will be
   added to HTML, SVG, or MathML with hyphen-containing local names in the future).</p></li></ul>




  <h3 id="html-vs-xhtml"><span class="secno">1.8</span> HTML vs XML syntax<a href="#html-vs-xhtml" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>This specification defines an abstract language for describing documents and applications, and
  some APIs for interacting with in-memory representations of resources that use this language.</p>

  <p>The in-memory representation is known as "DOM HTML", or "the DOM" for short.</p>

  <p>There are various concrete syntaxes that can be used to transmit resources that use this
  abstract language, two of which are defined in this specification.</p>

  <p>The first such concrete syntax is the HTML syntax. This is the format suggested for most
  authors. It is compatible with most legacy web browsers. If a document is transmitted with the
  <code id="html-vs-xhtml:text/html"><a href="#text/html">text/html</a></code> <a id="html-vs-xhtml:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a>, then it will be processed as an HTML document by
  web browsers. This specification defines the latest HTML syntax, known simply as "HTML".</p>

  <p>The second concrete syntax is XML. When a document is transmitted with an <a id="html-vs-xhtml:xml-mime-type" href="https://mimesniff.spec.whatwg.org/#xml-mime-type" data-x-internal="xml-mime-type">XML MIME
  type</a>, such as <code id="html-vs-xhtml:application/xhtml+xml"><a href="#application/xhtml+xml">application/xhtml+xml</a></code>, then it is treated as an XML document by
  web browsers, to be parsed by an XML processor. Authors are reminded that the processing for XML
  and HTML differs; in particular, even minor syntax errors will prevent a document labeled as XML
  from being rendered fully, whereas they would be ignored in the HTML syntax.</p>

  <p class="note">The XML syntax for HTML was formerly referred to as "XHTML", but this
  specification does not use that term (among other reasons, because no such term is used for the
  HTML syntaxes of MathML and SVG).</p>

  <p>The DOM, the HTML syntax, and the XML syntax cannot all represent the same content. For
  example, namespaces cannot be represented using the HTML syntax, but they are supported in the DOM
  and in the XML syntax. Similarly, documents that use the <code id="html-vs-xhtml:the-noscript-element"><a href="#the-noscript-element">noscript</a></code> feature can be
  represented using the HTML syntax, but cannot be represented with the DOM or in the XML syntax.
  Comments that contain the string "<code>--&gt;</code>" can only be represented in the
  DOM, not in the HTML and XML syntaxes.</p>


  <h3 id="structure-of-this-specification"><span class="secno">1.9</span> Structure of this specification<a href="#structure-of-this-specification" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>This specification is divided into the following major sections:</p>

  <dl><dt><a href="#introduction">Introduction</a></dt><dd>Non-normative materials providing a context for the HTML standard.</dd><dt><a href="#infrastructure">Common infrastructure</a></dt><dd>The conformance classes, algorithms, definitions, and the common underpinnings of the rest of
   the specification.</dd><dt><a href="#dom">Semantics, structure, and APIs of HTML documents</a></dt><dd>Documents are built from elements. These elements form a tree using the DOM. This section
   defines the features of this DOM, as well as introducing the features common to all elements, and
   the concepts used in defining elements.</dd><dt><a href="#semantics">The elements of HTML</a></dt><dd>Each element has a predefined meaning, which is explained in this section. Rules for authors
   on how to use the element, along with user agent requirements for how to
   handle each element, are also given. This includes large signature features of HTML such
   as video playback and subtitles, form controls and form submission, and a 2D graphics API known
   as the HTML canvas.</dd><dt><a href="#microdata">Microdata</a></dt><dd>This specification introduces a mechanism for adding machine-readable annotations to
   documents, so that tools can extract trees of name-value pairs from the document. This section
   describes this mechanism and some algorithms that can be used to convert HTML
   documents into other formats. This section also defines some sample Microdata vocabularies
   for contact information, calendar events, and licensing works.</dd><dt><a href="#editing">User interaction</a></dt><dd>HTML documents can provide a number of mechanisms for users to interact with and modify
   content, which are described in this section, such as how focus works, and drag-and-drop.</dd><dt><a href="#browsers">Loading web pages</a></dt><dd>HTML documents do not exist in a vacuum — this section defines many of the features
   that affect environments that deal with multiple pages, such as web browsers.</dd><dt><a href="#webappapis">Web application APIs</a></dt><dd>This section introduces basic features for scripting of applications in HTML.</dd><dt><a href="#workers">Web workers</a></dt><dd>This section defines an API for background threads in JavaScript.</dd><dt><a href="#worklets">Worklets</a></dt><dd>This section defines infrastructure for APIs that need to run JavaScript separately from the
   main JavaScript execution environment.</dd><dt><a href="#comms">The communication APIs</a></dt><dd>This section describes some mechanisms that applications written in HTML can use to
   communicate with other applications from different domains running on the same client. It also
   introduces a server-push event stream mechanism known as Server Sent Events or
   <code id="structure-of-this-specification:eventsource"><a href="#eventsource">EventSource</a></code>, and a two-way full-duplex socket protocol for scripts known as Web
   Sockets.</dd><dt><a href="#webstorage">Web storage</a></dt><dd>This section defines a client-side storage mechanism based on name-value pairs.</dd><dt><a href="#syntax">The HTML syntax</a></dt><dt><a href="#xhtml">The XML syntax</a></dt><dd>All of these features would be for naught if they couldn't be represented in a serialized
   form and sent to other people, and so these sections define the syntaxes of HTML and XML, along with rules for how to parse content using those syntaxes.</dd><dt><a href="#rendering">Rendering</a></dt><dd>This section defines the default rendering rules for web browsers.</dd></dl>

  <p>There are also some appendices, listing <a href="#obsolete">obsolete features</a> and <a href="#iana">IANA considerations</a>, and several indices.</p>


  

  <h4 id="how-to-read-this-specification"><span class="secno">1.9.1</span> How to read this specification<a href="#how-to-read-this-specification" class="self-link"></a></h4>

  <p>This specification should be read like all other specifications. First, it should be read
  cover-to-cover, multiple times. Then, it should be read backwards at least once. Then it should be
  read by picking random sections from the contents list and following all the cross-references.</p>

  <p>As described in the conformance requirements section below, this specification describes
  conformance criteria for a variety of conformance classes. In particular, there are conformance
  requirements that apply to <em>producers</em>, for example authors and the documents they create,
  and there are conformance requirements that apply to <em>consumers</em>, for example web browsers.
  They can be distinguished by what they are requiring: a requirement on a producer states what is
  allowed, while a requirement on a consumer states how software is to act.</p>

  <div class="example">

   <p>For example, "the <code>foo</code> attribute's value must be a <a href="#valid-integer" id="how-to-read-this-specification:valid-integer">valid
   integer</a>" is a requirement on producers, as it lays out the allowed values; in contrast,
   the requirement "the <code>foo</code> attribute's value must be parsed using the
   <a href="#rules-for-parsing-integers" id="how-to-read-this-specification:rules-for-parsing-integers">rules for parsing integers</a>" is a requirement on consumers, as it describes how to
   process the content.</p>

  </div>

  <p><strong>Requirements on producers have no bearing whatsoever on consumers.</strong></p>

  <div class="example">

   <p>Continuing the above example, a requirement stating that a particular attribute's value is
   constrained to being a <a href="#valid-integer" id="how-to-read-this-specification:valid-integer-2">valid integer</a> emphatically does <em>not</em> imply anything
   about the requirements on consumers. It might be that the consumers are in fact required to treat
   the attribute as an opaque string, completely unaffected by whether the value conforms to the
   requirements or not. It might be (as in the previous example) that the consumers are required to
   parse the value using specific rules that define how invalid (non-numeric in this case) values
   are to be processed.</p>

  </div>

  



  <h4 id="typographic-conventions"><span class="secno">1.9.2</span> Typographic conventions<a href="#typographic-conventions" class="self-link"></a></h4>

  <p>This is a definition, requirement, or explanation.</p>

  <p class="note">This is a note.</p>

  <p class="example">This is an example.</p>

  <p class="XXX">This is an open issue.</p>

  <p class="warning">This is a warning.</p>

  <pre class="extract"><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn><c- g="">Example</c-></dfn> {
  // this is an IDL definition
};</code></pre>

  <dl class="domintro"><dt><code><var>variable</var> = <var>object</var>.<a href="#x-that" id="typographic-conventions:x-that">method</a>([<var>optionalArgument</var>])</code></dt><dd><p>This is a note to authors describing the usage of an interface.</p></dd></dl>

  <pre><code class="css"><c- c="">/* this is a CSS fragment */</c-></code></pre>

  <p>The defining instance of a term is marked up like <dfn id="x-this">this</dfn>. Uses of that
  term are marked up like <a href="#x-this" id="typographic-conventions:x-this">this</a> or like <i id="typographic-conventions:x-this-2"><a href="#x-this">this</a></i>.</p>

  <p>The defining instance of an element, attribute, or API is marked up like <dfn id="x-that"><code>this</code></dfn>. References to that element, attribute, or API are marked up
  like <code id="typographic-conventions:x-that-2"><a href="#x-that">this</a></code>.</p>

  <p>Other code fragments are marked up <code>like this</code>.</p>

  <p>Variables are marked up like <var>this</var>.</p>

  <p>In an algorithm, steps in <a href="#synchronous-section" id="typographic-conventions:synchronous-section">synchronous
  sections</a> are marked with ⌛.</p>

  <p>In some cases, requirements are given in the form of lists with conditions and corresponding
  requirements. In such cases, the requirements that apply to a condition are always the first set
  of requirements that follow the condition, even in the case of there being multiple sets of
  conditions for those requirements. Such cases are presented as follows:</p>

  <dl class="switch"><dt>This is a condition
   </dt><dt>This is another condition
   </dt><dd>This is the requirement that applies to the conditions above.

   </dd><dt>This is a third condition
   </dt><dd>This is the requirement that applies to the third condition.
  </dd></dl>




  <h3 id="a-quick-introduction-to-html"><span class="secno">1.10</span> A quick introduction to HTML<a href="#a-quick-introduction-to-html" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>A basic HTML document looks like this:</p>

  <pre id="intro-early-example"><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Sample page<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Sample page<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This is a <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"demo.html"</c-><c- p="">&gt;</c->simple<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> sample.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- c="">&lt;!-- this is a comment --&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

  <p>HTML documents consist of a tree of elements and text. Each element is denoted in the source by
  a <a href="#syntax-start-tag" id="a-quick-introduction-to-html:syntax-start-tag">start tag</a>, such as "<code>&lt;body&gt;</code>", and
  an <a href="#syntax-end-tag" id="a-quick-introduction-to-html:syntax-end-tag">end tag</a>, such as "<code>&lt;/body&gt;</code>".
  (Certain start tags and end tags can in certain cases be <a href="#syntax-tag-omission" id="a-quick-introduction-to-html:syntax-tag-omission">omitted</a> and are implied by other tags.)</p>

  <p>Tags have to be nested such that elements are all completely within each other, without
  overlapping:</p>

  <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This is <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->very <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->wrong<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c->!<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
  <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->is <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->correct<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  <p>This specification defines a set of elements that can be used in HTML, along with rules about
  the ways in which the elements can be nested.</p>

  <p>Elements can have attributes, which control how the elements work. In the example below, there
  is a <a href="#hyperlink" id="a-quick-introduction-to-html:hyperlink">hyperlink</a>, formed using the <code id="a-quick-introduction-to-html:the-a-element"><a href="#the-a-element">a</a></code> element and its <code id="a-quick-introduction-to-html:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"demo.html"</c-><c- p="">&gt;</c->simple<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>

  <p><a href="#syntax-attributes" id="a-quick-introduction-to-html:syntax-attributes">Attributes</a> are placed inside the start tag, and consist
  of a <a href="#syntax-attribute-name" id="a-quick-introduction-to-html:syntax-attribute-name">name</a> and a <a href="#syntax-attribute-value" id="a-quick-introduction-to-html:syntax-attribute-value">value</a>, separated by an "<code>=</code>" character.
  The attribute value can remain <a href="#unquoted">unquoted</a> if it doesn't contain <a id="a-quick-introduction-to-html:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
  whitespace</a> or any of <code>"</code> <code>'</code> <code>`</code> <code>=</code> <code>&lt;</code> or <code>&gt;</code>. Otherwise, it has to be quoted using either single or double quotes. The
  value, along with the "<code>=</code>" character, can be omitted altogether if the value
  is the empty string.</p>

  <pre><code class="html"><c- c="">&lt;!-- empty attributes --&gt;</c->
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">address</c-> <c- e="">disabled</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">address</c-> <c- e="">disabled</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->

<c- c="">&lt;!-- attributes with a value --&gt;</c->
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">address</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">200</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">address</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">'200'</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">address</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">"200"</c-><c- p="">&gt;</c-></code></pre>

  <p>HTML user agents (e.g., web browsers) then <i>parse</i> this markup, turning it into a DOM
  (Document Object Model) tree. A DOM tree is an in-memory representation of a document.</p>

  <p>DOM trees contain several kinds of nodes, in particular a <code id="a-quick-introduction-to-html:documenttype"><a data-x-internal="documenttype" href="https://dom.spec.whatwg.org/#interface-documenttype">DocumentType</a></code> node,
  <code id="a-quick-introduction-to-html:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> nodes, <code id="a-quick-introduction-to-html:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes, <code id="a-quick-introduction-to-html:comment-2"><a data-x-internal="comment-2" href="https://dom.spec.whatwg.org/#interface-comment">Comment</a></code> nodes, and in some cases
  <code id="a-quick-introduction-to-html:processinginstruction"><a data-x-internal="processinginstruction" href="https://dom.spec.whatwg.org/#interface-processinginstruction">ProcessingInstruction</a></code> nodes.</p>

  <p>The <a href="#intro-early-example">markup snippet at the top of this section</a> would be
  turned into the following DOM tree:</p>

  <ul class="domTree"><li class="t10">DOCTYPE: <code>html</code></li><li class="t1"><code id="a-quick-introduction-to-html:the-html-element"><a href="#the-html-element">html</a></code> <span class="t2"><code id="a-quick-introduction-to-html:attr-lang" class="attribute name"><a href="#attr-lang">lang</a></code>="<code class="attribute value">en</code>"</span><ul><li class="t1"><code id="a-quick-introduction-to-html:the-head-element"><a href="#the-head-element">head</a></code><ul><li class="t3"><code id="a-quick-introduction-to-html:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>⏎␣␣</span></li><li class="t1"><code id="a-quick-introduction-to-html:the-title-element"><a href="#the-title-element">title</a></code><ul><li class="t3"><code id="a-quick-introduction-to-html:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>Sample page</span></li></ul></li><li class="t3"><code id="a-quick-introduction-to-html:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>⏎␣</span></li></ul></li><li class="t3"><code id="a-quick-introduction-to-html:text-5"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>⏎␣</span></li><li class="t1"><code id="a-quick-introduction-to-html:the-body-element"><a href="#the-body-element">body</a></code><ul><li class="t3"><code id="a-quick-introduction-to-html:text-6"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>⏎␣␣</span></li><li class="t1"><code id="a-quick-introduction-to-html:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code><ul><li class="t3"><code id="a-quick-introduction-to-html:text-7"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>Sample page</span></li></ul></li><li class="t3"><code id="a-quick-introduction-to-html:text-8"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>⏎␣␣</span></li><li class="t1"><code id="a-quick-introduction-to-html:the-p-element"><a href="#the-p-element">p</a></code><ul><li class="t3"><code id="a-quick-introduction-to-html:text-9"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>This is a </span></li><li class="t1"><code id="a-quick-introduction-to-html:the-a-element-2"><a href="#the-a-element">a</a></code> <span class="t2"><code id="a-quick-introduction-to-html:attr-hyperlink-href-2" class="attribute name"><a href="#attr-hyperlink-href">href</a></code>="<code class="attribute value">demo.html</code>"</span><ul><li class="t3"><code id="a-quick-introduction-to-html:text-10"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>simple</span></li></ul></li><li class="t3"><code id="a-quick-introduction-to-html:text-11"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span> sample.</span></li></ul></li><li class="t3"><code id="a-quick-introduction-to-html:text-12"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>⏎␣␣</span></li><li class="t8"><code id="a-quick-introduction-to-html:comment-2-2"><a data-x-internal="comment-2" href="https://dom.spec.whatwg.org/#interface-comment">#comment</a></code>: <span> this is a comment </span></li><li class="t3"><code id="a-quick-introduction-to-html:text-13"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>⏎␣⏎</span></li></ul></li></ul></li></ul>

  <p>The <a id="a-quick-introduction-to-html:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> of this tree is the <code id="a-quick-introduction-to-html:the-html-element-2"><a href="#the-html-element">html</a></code> element, which is the
  element always found in that position in HTML documents. It contains two elements,
  <code id="a-quick-introduction-to-html:the-head-element-2"><a href="#the-head-element">head</a></code> and <code id="a-quick-introduction-to-html:the-body-element-2"><a href="#the-body-element">body</a></code>, as well as a <code id="a-quick-introduction-to-html:text-14"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node between them.</p>

  <p>There are many more <code id="a-quick-introduction-to-html:text-15"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes in the DOM tree than one would initially expect,
  because the source contains a number of spaces (represented here by "␣") and line breaks
  ("⏎") that all end up as <code id="a-quick-introduction-to-html:text-16"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes in the DOM. However, for historical
  reasons not all of the spaces and line breaks in the original markup appear in the DOM. In
  particular, all the whitespace before <code id="a-quick-introduction-to-html:the-head-element-3"><a href="#the-head-element">head</a></code> start tag ends up being dropped silently,
  and all the whitespace after the <code id="a-quick-introduction-to-html:the-body-element-3"><a href="#the-body-element">body</a></code> end tag ends up placed at the end of the
  <code id="a-quick-introduction-to-html:the-body-element-4"><a href="#the-body-element">body</a></code>.</p>

  <p>The <code id="a-quick-introduction-to-html:the-head-element-4"><a href="#the-head-element">head</a></code> element contains a <code id="a-quick-introduction-to-html:the-title-element-2"><a href="#the-title-element">title</a></code> element, which itself contains a
  <code id="a-quick-introduction-to-html:text-17"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node with the text "Sample page". Similarly, the <code id="a-quick-introduction-to-html:the-body-element-5"><a href="#the-body-element">body</a></code> element
  contains an <code id="a-quick-introduction-to-html:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code> element, a <code id="a-quick-introduction-to-html:the-p-element-2"><a href="#the-p-element">p</a></code> element, and a comment.</p>

  <hr>

  <p>This DOM tree can be manipulated from scripts in the page. Scripts (typically in JavaScript)
  are small programs that can be embedded using the <code id="a-quick-introduction-to-html:the-script-element"><a href="#the-script-element">script</a></code> element or using <a href="#event-handler-content-attributes" id="a-quick-introduction-to-html:event-handler-content-attributes">event
  handler content attributes</a>. For example, here is a form with a script that sets the value
  of the form's <code id="a-quick-introduction-to-html:the-output-element"><a href="#the-output-element">output</a></code> element to say "Hello World":</p>

  <pre><code class="html"><c- p="">&lt;</c-><a href="#the-form-element" id="a-quick-introduction-to-html:the-form-element"><c- f="">form</c-></a> <a href="#attr-form-name" id="a-quick-introduction-to-html:attr-form-name"><c- e="">name</c-></a><c- o="">=</c-><c- s="">"main"</c-><c- p="">&gt;</c->
 Result: <c- p="">&lt;</c-><a href="#the-output-element" id="a-quick-introduction-to-html:the-output-element-2"><c- f="">output</c-></a> <a href="#attr-fe-name" id="a-quick-introduction-to-html:attr-fe-name"><c- e="">name</c-></a><c- o="">=</c-><c- s="">"result"</c-><c- p="">&gt;&lt;/</c-><c- f="">output</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><a href="#the-script-element" id="a-quick-introduction-to-html:the-script-element-2"><c- f="">script</c-></a><c- p="">&gt;</c->
  <a href="#document" id="a-quick-introduction-to-html:document">document</a><c- p="">.</c-><a href="#dom-document-forms" id="a-quick-introduction-to-html:dom-document-forms">forms</a><c- p="">.</c->main<c- p="">.</c-><a href="#dom-form-elements" id="a-quick-introduction-to-html:dom-form-elements">elements</a><c- p="">.</c->result<c- p="">.</c-><a href="#dom-output-value" id="a-quick-introduction-to-html:dom-output-value">value</a> <c- o="">=</c-> <c- t="">'Hello World'</c-><c- p="">;</c->
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p>Each element in the DOM tree is represented by an object, and these objects have APIs so that
  they can be manipulated. For instance, a link (e.g. the <code id="a-quick-introduction-to-html:the-a-element-3"><a href="#the-a-element">a</a></code> element in the tree above)
  can have its "<code id="a-quick-introduction-to-html:attr-hyperlink-href-3"><a href="#attr-hyperlink-href">href</a></code>" attribute changed in several
  ways:</p>

  <pre><code class="js"><c- a="">var</c-> a <c- o="">=</c-> <a href="#document" id="a-quick-introduction-to-html:document-2">document</a><c- p="">.</c-><a href="#dom-document-links" id="a-quick-introduction-to-html:dom-document-links">links</a><c- p="">[</c-><c- mf="">0</c-><c- p="">];</c-> <c- c1="">// obtain the first link in the document</c->
a<c- p="">.</c-><a href="#dom-hyperlink-href" id="a-quick-introduction-to-html:dom-hyperlink-href">href</a> <c- o="">=</c-> <c- t="">'sample.html'</c-><c- p="">;</c-> <c- c1="">// change the destination URL of the link</c->
a<c- p="">.</c-><a href="#dom-hyperlink-protocol" id="a-quick-introduction-to-html:dom-hyperlink-protocol">protocol</a> <c- o="">=</c-> <c- t="">'https'</c-><c- p="">;</c-> <c- c1="">// change just the scheme part of the URL</c->
a<c- p="">.</c->setAttribute<c- p="">(</c-><c- t="">'href'</c-><c- p="">,</c-> <c- t="">'https://example.com/'</c-><c- p="">);</c-> <c- c1="">// change the content attribute directly</c-></code></pre>

  <p>Since DOM trees are used as the way to represent HTML documents when they are processed and
  presented by implementations (especially interactive implementations like web browsers), this
  specification is mostly phrased in terms of DOM trees, instead of the markup described above.</p>

  <hr>

  <p>HTML documents represent a media-independent description of interactive content. HTML documents
  might be rendered to a screen, or through a speech synthesizer, or on a braille display. To
  influence exactly how such rendering takes place, authors can use a styling language such as
  CSS.</p>

  <p>In the following example, the page has been made yellow-on-blue using CSS.</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Sample styled page<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
   <c- f="">body</c-> <c- p="">{</c-> <c- k="">background</c-><c- p="">:</c-> <c- kc="">navy</c-><c- p="">;</c-> <c- k="">color</c-><c- p="">:</c-> <c- kc="">yellow</c-><c- p="">;</c-> <c- p="">}</c->
  <c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Sample styled page<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This page is just a demo.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

  <p>For more details on how to use HTML, authors are encouraged to consult tutorials and guides.
  Some of the examples included in this specification might also be of use, but the novice author is
  cautioned that this specification, by necessity, defines the language with a level of detail that
  might be difficult to understand at first.</p>



  <h4 id="writing-secure-applications-with-html"><span class="secno">1.10.1</span> Writing secure applications with HTML<a href="#writing-secure-applications-with-html" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>When HTML is used to create interactive sites, care needs to be taken to avoid introducing
  vulnerabilities through which attackers can compromise the integrity of the site itself or of the
  site's users.</p>

  <p>A comprehensive study of this matter is beyond the scope of this document, and authors are
  strongly encouraged to study the matter in more detail. However, this section attempts to provide
  a quick introduction to some common pitfalls in HTML application development.</p>

  <p>The security model of the web is based on the concept of "origins", and correspondingly many of
  the potential attacks on the web involve cross-origin actions. <a href="#refsORIGIN">[ORIGIN]</a></p>

  <dl><dt>Not validating user input</dt><dt>Cross-site scripting (XSS)</dt><dt>SQL injection</dt><dd>
    <p>When accepting untrusted input, e.g. user-generated content such as text comments, values in
    URL parameters, messages from third-party sites, etc, it is imperative that the data be
    validated before use, and properly escaped when displayed. Failing to do this can allow a
    hostile user to perform a variety of attacks, ranging from the potentially benign, such as
    providing bogus user information like a negative age, to the serious, such as running scripts
    every time a user looks at a page that includes the information, potentially propagating the
    attack in the process, to the catastrophic, such as deleting all data in the server.</p>

    <p>When writing filters to validate user input, it is imperative that filters always be
    safelist-based, allowing known-safe constructs and disallowing all other input. Blocklist-based
    filters that disallow known-bad inputs and allow everything else are not secure, as not
    everything that is bad is yet known (for example, because it might be invented in the
    future).</p>

    <div class="example">

     <p>For example, suppose a page looked at its URL's query string to determine what to display,
     and the site then redirected the user to that page to display a message, as in:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"message.cgi?say=Hello"</c-><c- p="">&gt;</c->Say Hello<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"message.cgi?say=Welcome"</c-><c- p="">&gt;</c->Say Welcome<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"message.cgi?say=Kittens"</c-><c- p="">&gt;</c->Say Kittens<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

     <p>If the message was just displayed to the user without escaping, a hostile attacker could
     then craft a URL that contained a script element:</p>

     <pre>https://example.com/message.cgi?say=%3Cscript%3Ealert%28%27Oh%20no%21%27%29%3C/script%3E</pre>

     <p>If the attacker then convinced a victim user to visit this page, a script of the attacker's
     choosing would run on the page. Such a script could do any number of hostile actions, limited
     only by what the site offers: if the site is an e-commerce shop, for instance, such a script
     could cause the user to unknowingly make arbitrarily many unwanted purchases.</p>

     <p>This is called a cross-site scripting attack.</p>

    </div>

    <p>There are many constructs that can be used to try to trick a site into executing code. Here
    are some that authors are encouraged to consider when writing safelist filters:</p>

    <ul><li>When allowing harmless-seeming elements like <code id="writing-secure-applications-with-html:the-img-element"><a href="#the-img-element">img</a></code>, it is important to safelist
     any provided attributes as well. If one allowed all attributes then an attacker could, for
     instance, use the <code id="writing-secure-applications-with-html:handler-onload"><a href="#handler-onload">onload</a></code> attribute to run arbitrary
     script.</li><li>When allowing URLs to be provided (e.g. for links), the scheme of each URL also needs to be
     explicitly safelisted, as there are many schemes that can be abused. The most prominent
     example is "<code id="writing-secure-applications-with-html:the-javascript:-url-special-case"><a href="#the-javascript:-url-special-case">javascript:</a></code>", but user agents can
     implement (and indeed, have historically implemented) others.</li><li>Allowing a <code id="writing-secure-applications-with-html:the-base-element"><a href="#the-base-element">base</a></code> element to be inserted means any <code id="writing-secure-applications-with-html:the-script-element"><a href="#the-script-element">script</a></code> elements
     in the page with relative links can be hijacked, and similarly that any form submissions can
     get redirected to a hostile site.</li></ul>
   </dd><dt>Cross-site request forgery (CSRF)</dt><dd>
    <p>If a site allows a user to make form submissions with user-specific side-effects, for example
    posting messages on a forum under the user's name, making purchases, or applying for a passport,
    it is important to verify that the request was made by the user intentionally, rather than by
    another site tricking the user into making the request unknowingly.</p>

    <p>This problem exists because HTML forms can be submitted to other origins.</p>

    <p>Sites can prevent such attacks by populating forms with user-specific hidden tokens, or by
    checking `<code id="writing-secure-applications-with-html:http-origin"><a data-x-internal="http-origin" href="https://fetch.spec.whatwg.org/#http-origin">Origin</a></code>` headers on all requests.</p>
   </dd><dt>Clickjacking</dt><dd>
    <p>A page that provides users with an interface to perform actions that the user might not wish
    to perform needs to be designed so as to avoid the possibility that users can be tricked into
    activating the interface.</p>

    <p>One way that a user could be so tricked is if a hostile site places the victim site in a
    small <code id="writing-secure-applications-with-html:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> and then convinces the user to click, for instance by having the user
    play a reaction game. Once the user is playing the game, the hostile site can quickly position
    the iframe under the mouse cursor just as the user is about to click, thus tricking the user
    into clicking the victim site's interface.</p>

    <p>To avoid this, sites that do not expect to be used in frames are encouraged to only enable
    their interface if they detect that they are not in a frame (e.g. by comparing the <code id="writing-secure-applications-with-html:dom-window"><a href="#dom-window">window</a></code> object to the value of the <code id="writing-secure-applications-with-html:dom-top"><a href="#dom-top">top</a></code>
    attribute).</p>
   </dd></dl>


  <h4 id="common-pitfalls-to-avoid-when-using-the-scripting-apis"><span class="secno">1.10.2</span> Common pitfalls to avoid when using the scripting APIs<a href="#common-pitfalls-to-avoid-when-using-the-scripting-apis" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Scripts in HTML have "run-to-completion" semantics, meaning that the browser will generally run
  the script uninterrupted before doing anything else, such as firing further events or continuing
  to parse the document.</p>

  <p>On the other hand, parsing of HTML files happens incrementally, meaning that
  the parser can pause at any point to let scripts run. This is generally a good thing, but it does
  mean that authors need to be careful to avoid hooking event handlers after the events could have
  possibly fired.</p>

  <p>There are two techniques for doing this reliably: use <a href="#event-handler-content-attributes" id="common-pitfalls-to-avoid-when-using-the-scripting-apis:event-handler-content-attributes">event handler content
  attributes</a>, or create the element and add the event handlers in the same script. The latter
  is safe because, as mentioned earlier, scripts are run to completion before further events can
  fire.</p>

  <div class="example">

   <p>One way this could manifest itself is with <code id="common-pitfalls-to-avoid-when-using-the-scripting-apis:the-img-element"><a href="#the-img-element">img</a></code> elements and the <code id="common-pitfalls-to-avoid-when-using-the-scripting-apis:event-load"><a href="#event-load">load</a></code> event. The event could fire as soon as the element has been
   parsed, especially if the image has already been cached (which is common).</p>

   <p>Here, the author uses the <code id="common-pitfalls-to-avoid-when-using-the-scripting-apis:handler-onload"><a href="#handler-onload">onload</a></code> handler on an
   <code id="common-pitfalls-to-avoid-when-using-the-scripting-apis:the-img-element-2"><a href="#the-img-element">img</a></code> element to catch the <code id="common-pitfalls-to-avoid-when-using-the-scripting-apis:event-load-2"><a href="#event-load">load</a></code> event:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"games.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Games"</c-> <c- e="">onload</c-><c- o="">=</c-><c- s="">"gamesLogoHasLoaded(event)"</c-><c- p="">&gt;</c-></code></pre>

   <p>If the element is being added by script, then so long as the event handlers are added in the
   same script, the event will still not be missed:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> img <c- o="">=</c-> <c- k="">new</c-> Image<c- p="">();</c->
 img<c- p="">.</c->src <c- o="">=</c-> <c- t="">'games.png'</c-><c- p="">;</c->
 img<c- p="">.</c->alt <c- o="">=</c-> <c- t="">'Games'</c-><c- p="">;</c->
 img<c- p="">.</c->onload <c- o="">=</c-> gamesLogoHasLoaded<c- p="">;</c->
 <c- c1="">// img.addEventListener('load', gamesLogoHasLoaded, false); // would work also</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>However, if the author first created the <code id="common-pitfalls-to-avoid-when-using-the-scripting-apis:the-img-element-3"><a href="#the-img-element">img</a></code> element and then in a separate
   script added the event listeners, there's a chance that the <code id="common-pitfalls-to-avoid-when-using-the-scripting-apis:event-load-3"><a href="#event-load">load</a></code>
   event would be fired in between, leading it to be missed:</p>

   <pre class="bad"><code class="html"><c- c="">&lt;!-- Do not use this style, it has a race condition! --&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"games"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"games.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Games"</c-><c- p="">&gt;</c->
 <c- c="">&lt;!-- the 'load' event might fire here while the parser is taking a</c->
<c- c="">      break, in which case you will not see it! --&gt;</c->
 <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> img <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'games'</c-><c- p="">);</c->
  img<c- p="">.</c->onload <c- o="">=</c-> gamesLogoHasLoaded<c- p="">;</c-> <c- c1="">// might never fire!</c->
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="how-to-catch-mistakes-when-writing-html:-validators-and-conformance-checkers"><span class="secno">1.10.3</span> How to catch mistakes when writing HTML: validators and conformance checkers<a href="#how-to-catch-mistakes-when-writing-html:-validators-and-conformance-checkers" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Authors are encouraged to make use of conformance checkers (also known as <i>validators</i>) to
  catch common mistakes. The WHATWG maintains a list of such tools at: <a href="https://whatwg.org/validator/">https://whatwg.org/validator/</a></p>



  <h3 id="conformance-requirements-for-authors"><span class="secno">1.11</span> Conformance requirements for authors<a href="#conformance-requirements-for-authors" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>Unlike previous versions of the HTML specification, this specification defines in some detail
  the required processing for invalid documents as well as valid documents.</p> 

  <p>However, even though the processing of invalid content is in most cases well-defined,
  conformance requirements for documents are still important: in practice, interoperability (the
  situation in which all implementations process particular content in a reliable and identical or
  equivalent way) is not the only goal of document conformance requirements. This section details
  some of the more common reasons for still distinguishing between a conforming document and one
  with errors.</p>


  <h4 id="presentational-markup"><span class="secno">1.11.1</span> Presentational markup<a href="#presentational-markup" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>The majority of presentational features from previous versions of HTML are no longer allowed.
  Presentational markup in general has been found to have a number of problems:</p>

  <dl><dt>The use of presentational elements leads to poorer accessibility</dt><dd>
    <p>While it is possible to use presentational markup in a way that provides users of assistive
    technologies (ATs) with an acceptable experience (e.g. using ARIA), doing so is significantly
    more difficult than doing so when using semantically-appropriate markup. Furthermore, even using
    such techniques doesn't help make pages accessible for non-AT non-graphical users, such as users
    of text-mode browsers.</p>

    <p>Using media-independent markup, on the other hand, provides an easy way for documents to be
    authored in such a way that they work for more users (e.g. users of text browsers).</p>
   </dd><dt>Higher cost of maintenance</dt><dd>
    <p>It is significantly easier to maintain a site written in such a way that the markup is
    style-independent. For example, changing the color of a site that uses <code>&lt;font&nbsp;color=""&gt;</code> throughout requires changes across the entire site,
    whereas a similar change to a site based on CSS can be done by changing a single file.</p>
   </dd><dt>Larger document sizes</dt><dd>
    <p>Presentational markup tends to be much more redundant, and thus results in larger document
    sizes.</p>
   </dd></dl>

  <p>For those reasons, presentational markup has been removed from HTML in this version. This
  change should not come as a surprise; HTML4 deprecated presentational markup many years ago and
  provided a mode (HTML4 Transitional) to help authors move away from presentational markup; later,
  XHTML 1.1 went further and obsoleted those features altogether.</p>

  <p>The only remaining presentational markup features in HTML are the <code id="presentational-markup:attr-style"><a href="#attr-style">style</a></code> attribute and the <code id="presentational-markup:the-style-element"><a href="#the-style-element">style</a></code> element. Use of the <code id="presentational-markup:attr-style-2"><a href="#attr-style">style</a></code> attribute is somewhat discouraged in production environments, but
  it can be useful for rapid prototyping (where its rules can be directly moved into a separate
  style sheet later) and for providing specific styles in unusual cases where a separate style sheet
  would be inconvenient. Similarly, the <code id="presentational-markup:the-style-element-2"><a href="#the-style-element">style</a></code> element can be useful in syndication or
  for page-specific styles, but in general an external style sheet is likely to be more convenient
  when the styles apply to multiple pages.</p>

  <p>It is also worth noting that some elements that were previously presentational have been
  redefined in this specification to be media-independent: <code id="presentational-markup:the-b-element"><a href="#the-b-element">b</a></code>, <code id="presentational-markup:the-i-element"><a href="#the-i-element">i</a></code>,
  <code id="presentational-markup:the-hr-element"><a href="#the-hr-element">hr</a></code>, <code id="presentational-markup:the-s-element"><a href="#the-s-element">s</a></code>, <code id="presentational-markup:the-small-element"><a href="#the-small-element">small</a></code>, and <code id="presentational-markup:the-u-element"><a href="#the-u-element">u</a></code>.</p>


  <h4 id="syntax-errors"><span class="secno">1.11.2</span> Syntax errors<a href="#syntax-errors" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>The syntax of HTML is constrained to avoid a wide variety of problems.</p>

  <dl><dt>Unintuitive error-handling behavior</dt><dd>
    <p>Certain invalid syntax constructs, when parsed, result in DOM trees that are highly
    unintuitive.</p>

    <div class="example">

     <p>For example, the following markup fragment results in a DOM with an <code id="syntax-errors:the-hr-element"><a href="#the-hr-element">hr</a></code> element
     that is an <em>earlier</em> sibling of the corresponding <code id="syntax-errors:the-table-element"><a href="#the-table-element">table</a></code> element:</p>

     <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;&lt;</c-><c- f="">hr</c-><c- p="">&gt;</c->...</code></pre>

    </div>
   </dd><dt>Errors with optional error recovery</dt><dd>
    <p>To allow user agents to be used in controlled environments without having to implement the
    more bizarre and convoluted error handling rules, user agents are permitted to fail whenever
    encountering a <a href="#parse-errors" id="syntax-errors:parse-errors">parse error</a>.</p>
   </dd><dt>Errors where the error-handling behavior is not compatible with streaming user agents</dt><dd>
    <p>Some error-handling behavior, such as the behavior for the <code>&lt;table&gt;&lt;hr&gt;...</code> example mentioned above, are incompatible with streaming
    user agents (user agents that process HTML files in one pass, without storing state). To avoid
    interoperability problems with such user agents, any syntax resulting in such behavior is
    considered invalid.</p>
   </dd><dt>Errors that can result in infoset coercion</dt><dd>
    <p>When a user agent based on XML is connected to an HTML parser, it is possible that certain
    invariants that XML enforces, such as element or attribute names never contain multiple colons,
    will be violated by an HTML file. Handling this can require that the parser coerce the HTML DOM
    into an XML-compatible infoset. Most syntax constructs that require such handling are considered
    invalid. (Comments containing two consecutive hyphens, or ending with a hyphen, are exceptions
    that are allowed in the HTML syntax.)</p>
   </dd><dt>Errors that result in disproportionately poor performance</dt><dd>
    <p>Certain syntax constructs can result in disproportionately poor performance. To discourage the
    use of such constructs, they are typically made non-conforming.</p>

    <div class="example">

     <p>For example, the following markup results in poor performance, since all the unclosed
     <code id="syntax-errors:the-i-element"><a href="#the-i-element">i</a></code> elements have to be reconstructed in each paragraph, resulting in progressively
     more elements in each paragraph:</p>

     <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->She dreamt.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->She dreamt that she ate breakfast.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->Then lunch.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->And finally dinner.</code></pre>

     <p>The resulting DOM for this fragment would be:</p>

     <ul class="domTree"><li class="t1"><code id="syntax-errors:the-p-element"><a href="#the-p-element">p</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-2"><a href="#the-i-element">i</a></code><ul><li class="t3"><code id="syntax-errors:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>She dreamt.</span></li></ul></li></ul></li><li class="t1"><code id="syntax-errors:the-p-element-2"><a href="#the-p-element">p</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-3"><a href="#the-i-element">i</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-4"><a href="#the-i-element">i</a></code><ul><li class="t3"><code id="syntax-errors:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>She dreamt that she ate breakfast.</span></li></ul></li></ul></li></ul></li><li class="t1"><code id="syntax-errors:the-p-element-3"><a href="#the-p-element">p</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-5"><a href="#the-i-element">i</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-6"><a href="#the-i-element">i</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-7"><a href="#the-i-element">i</a></code><ul><li class="t3"><code id="syntax-errors:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>Then lunch.</span></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code id="syntax-errors:the-p-element-4"><a href="#the-p-element">p</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-8"><a href="#the-i-element">i</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-9"><a href="#the-i-element">i</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-10"><a href="#the-i-element">i</a></code><ul><li class="t1"><code id="syntax-errors:the-i-element-11"><a href="#the-i-element">i</a></code><ul><li class="t3"><code id="syntax-errors:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>And finally dinner.</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

    </div>
   </dd><dt>Errors involving fragile syntax constructs</dt><dd>
    <p>There are syntax constructs that, for historical reasons, are relatively fragile. To help
    reduce the number of users who accidentally run into such problems, they are made
    non-conforming.</p>

    <div class="example">

     <p>For example, the parsing of certain named character references in attributes happens even
     with the closing semicolon being omitted. It is safe to include an ampersand followed by
     letters that do not form a named character reference, but if the letters are changed to a
     string that <em>does</em> form a named character reference, they will be interpreted as that
     character instead.</p>

     <p>In this fragment, the attribute's value is "<code>?bill&amp;ted</code>":</p>

     <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?bill&amp;ted"</c-><c- p="">&gt;</c->Bill and Ted<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>

     <p>In the following fragment, however, the attribute's value is actually "<code>?art©</code>", <em>not</em> the intended "<code>?art&amp;copy</code>",
     because even without the final semicolon, "<code>&amp;copy</code>" is handled the same
     as "<code>&amp;copy;</code>" and thus gets interpreted as "<code>©</code>":</p>

     <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?art&amp;copy"</c-><c- p="">&gt;</c->Art and Copy<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>

     <p>To avoid this problem, all named character references are required to end with a semicolon,
     and uses of named character references without a semicolon are flagged as errors.</p>

     <p>Thus, the correct way to express the above cases is as
     follows:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?bill&amp;ted"</c-><c- p="">&gt;</c->Bill and Ted<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- &amp;ted is ok, since it's not a named character reference --&gt;</c-></code></pre>
     <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?art&amp;amp;copy"</c-><c- p="">&gt;</c->Art and Copy<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- the &amp; has to be escaped, since &amp;copy </c-><em><c- c="">is</c-></em><c- c=""> a named character reference --&gt;</c-></code></pre>

    </div>
   </dd><dt>Errors involving known interoperability problems in legacy user agents</dt><dd>
    <p>Certain syntax constructs are known to cause especially subtle or serious problems in legacy
    user agents, and are therefore marked as non-conforming to help authors avoid them.</p>

    <div class="example">

     <p>For example, this is why the U+0060 GRAVE ACCENT character (`) is not allowed in unquoted
     attributes. In certain legacy user agents,  it is sometimes treated as a
     quote character.</p>

    </div>

    <div class="example">

     <p>Another example of this is the DOCTYPE, which is required to trigger <a id="syntax-errors:no-quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-no-quirks" data-x-internal="no-quirks-mode">no-quirks
     mode</a>, because the behavior of legacy user agents in <a id="syntax-errors:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a> is often
     largely undocumented.</p>

    </div>
   </dd><dt>Errors that risk exposing authors to security attacks</dt><dd>
    <p>Certain restrictions exist purely to avoid known security problems.</p>

    <div class="example">

     <p>For example, the restriction on using UTF-7 exists purely to avoid authors falling prey to a
     known cross-site-scripting attack using UTF-7. <a href="#refsUTF7">[UTF7]</a></p>

    </div>
   </dd><dt>Cases where the author's intent is unclear</dt><dd>
    <p>Markup where the author's intent is very unclear is often made non-conforming. Correcting
    these errors early makes later maintenance easier.</p>

    <div class="example">

     <p>For example, it is unclear whether the author intended the following to be an
     <code id="syntax-errors:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code> heading or an <code id="syntax-errors:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code> heading:</p>

     <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Contact details<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c-></code></pre>

    </div>
   </dd><dt>Cases that are likely to be typos</dt><dd>
    <p>When a user makes a simple typo, it is helpful if the error can be caught early, as this can
    save the author a lot of debugging time. This specification therefore usually considers it an
    error to use element names, attribute names, and so forth, that do not match the names defined
    in this specification.</p>

    <div class="example">

     <p>For example, if the author typed <code>&lt;capton&gt;</code> instead of <code>&lt;caption&gt;</code>, this would be flagged as an error and the author could correct
     the typo immediately.</p>

    </div>
   </dd><dt>Errors that could interfere with new syntax in the future</dt><dd>
    <p>In order to allow the language syntax to be extended in the future, certain otherwise
    harmless features are disallowed.</p>

    <div class="example">

     <p>For example, "attributes" in end tags are ignored currently, but they are invalid, in case a
     future change to the language makes use of that syntax feature without conflicting with
     already-deployed (and valid!) content.</p>

    </div>
   </dd></dl>

  <p>Some authors find it helpful to be in the practice of always quoting all attributes and always
  including all optional tags, preferring the consistency derived from such custom over the minor
  benefits of terseness afforded by making use of the flexibility of the HTML syntax. To aid such
  authors, conformance checkers can provide modes of operation wherein such conventions are
  enforced.</p>



  <h4 id="restrictions-on-content-models-and-on-attribute-values"><span class="secno">1.11.3</span> Restrictions on content models and on attribute values<a href="#restrictions-on-content-models-and-on-attribute-values" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Beyond the syntax of the language, this specification also places restrictions on how elements
  and attributes can be specified. These restrictions are present for similar reasons:</p>

  <dl><dt>Errors involving content with dubious semantics</dt><dd>
    <p>To avoid misuse of elements with defined meanings, content models are defined that restrict
    how elements can be nested when such nestings would be of dubious value.</p>

    <p class="example">For example, this specification disallows nesting a <code id="restrictions-on-content-models-and-on-attribute-values:the-section-element"><a href="#the-section-element">section</a></code>
    element inside a <code id="restrictions-on-content-models-and-on-attribute-values:the-kbd-element"><a href="#the-kbd-element">kbd</a></code> element, since it is highly unlikely for an author to indicate
    that an entire section should be keyed in.</p>
   </dd><dt>Errors that involve a conflict in expressed semantics</dt><dd>
    <p>Similarly, to draw the author's attention to mistakes in the use of elements, clear
    contradictions in the semantics expressed are also considered conformance errors.</p>

    <div class="example">

     <p>In the fragments below, for example, the semantics are nonsensical: a separator cannot
     simultaneously be a cell, nor can a radio button be a progress bar.</p>

     <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">hr</c-> <c- e="">role</c-><c- o="">=</c-><c- s="">"cell"</c-><c- p="">&gt;</c-></code></pre>
     <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">role</c-><c- o="">=</c-><c- s="">progressbar</c-><c- p="">&gt;</c-></code></pre>

    </div>

    <p class="example">Another example is the restrictions on the content models of the
    <code id="restrictions-on-content-models-and-on-attribute-values:the-ul-element"><a href="#the-ul-element">ul</a></code> element, which only allows <code id="restrictions-on-content-models-and-on-attribute-values:the-li-element"><a href="#the-li-element">li</a></code> element children. Lists by definition
    consist just of zero or more list items, so if a <code id="restrictions-on-content-models-and-on-attribute-values:the-ul-element-2"><a href="#the-ul-element">ul</a></code> element contains something
    other than an <code id="restrictions-on-content-models-and-on-attribute-values:the-li-element-2"><a href="#the-li-element">li</a></code> element, it's not clear what was meant.</p>
   </dd><dt>Cases where the default styles are likely to lead to confusion</dt><dd>
    <p>Certain elements have default styles or behaviors that make certain combinations likely to
    lead to confusion. Where these have equivalent alternatives without this problem, the confusing
    combinations are disallowed.</p>

    <p class="example">For example, <code id="restrictions-on-content-models-and-on-attribute-values:the-div-element"><a href="#the-div-element">div</a></code> elements are rendered as <a href="https://drafts.csswg.org/css2/#block-boxes%E2%91%A0" id="restrictions-on-content-models-and-on-attribute-values:block-box" data-x-internal="block-box">block boxes</a>, and <code id="restrictions-on-content-models-and-on-attribute-values:the-span-element"><a href="#the-span-element">span</a></code> elements as <a href="https://drafts.csswg.org/css2/#inline-box" id="restrictions-on-content-models-and-on-attribute-values:inline-box" data-x-internal="inline-box">inline boxes</a>. Putting a <a id="restrictions-on-content-models-and-on-attribute-values:block-box-2" href="https://drafts.csswg.org/css2/#block-boxes%E2%91%A0" data-x-internal="block-box">block box</a> in an
    <a id="restrictions-on-content-models-and-on-attribute-values:inline-box-2" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a> is unnecessarily confusing; since either nesting just <code id="restrictions-on-content-models-and-on-attribute-values:the-div-element-2"><a href="#the-div-element">div</a></code>
    elements, or nesting just <code id="restrictions-on-content-models-and-on-attribute-values:the-span-element-2"><a href="#the-span-element">span</a></code> elements, or nesting <code id="restrictions-on-content-models-and-on-attribute-values:the-span-element-3"><a href="#the-span-element">span</a></code> elements
    inside <code id="restrictions-on-content-models-and-on-attribute-values:the-div-element-3"><a href="#the-div-element">div</a></code> elements all serve the same purpose as nesting a <code id="restrictions-on-content-models-and-on-attribute-values:the-div-element-4"><a href="#the-div-element">div</a></code>
    element in a <code id="restrictions-on-content-models-and-on-attribute-values:the-span-element-4"><a href="#the-span-element">span</a></code> element, but only the latter involves a <a id="restrictions-on-content-models-and-on-attribute-values:block-box-3" href="https://drafts.csswg.org/css2/#block-boxes%E2%91%A0" data-x-internal="block-box">block box</a> in
    an <a id="restrictions-on-content-models-and-on-attribute-values:inline-box-3" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, the latter combination is disallowed.</p>

    <p class="example">Another example would be the way <a href="#interactive-content-2" id="restrictions-on-content-models-and-on-attribute-values:interactive-content-2">interactive content</a> cannot be
    nested. For example, a <code id="restrictions-on-content-models-and-on-attribute-values:the-button-element"><a href="#the-button-element">button</a></code> element cannot contain a <code id="restrictions-on-content-models-and-on-attribute-values:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>
    element. This is because the default behavior of such nesting interactive elements would be
    highly confusing to users. Instead of nesting these elements, they can be placed side by
    side.</p>
   </dd><dt>Errors that indicate a likely misunderstanding of the specification</dt><dd>
    <p>Sometimes, something is disallowed because allowing it would likely cause author
    confusion.</p>

    <p class="example">For example, setting the <code id="restrictions-on-content-models-and-on-attribute-values:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code>
    attribute to the value "<code>false</code>" is disallowed, because despite the
    appearance of meaning that the element is enabled, it in fact means that the element is
    <em>disabled</em> (what matters for implementations is the presence of the attribute, not its
    value).</p>
   </dd><dt>Errors involving limits that have been imposed merely to simplify the language</dt><dd>
    <p>Some conformance errors simplify the language that authors need to learn.</p>

    <p class="example">For example, the <code id="restrictions-on-content-models-and-on-attribute-values:the-area-element"><a href="#the-area-element">area</a></code> element's <code id="restrictions-on-content-models-and-on-attribute-values:attr-area-shape"><a href="#attr-area-shape">shape</a></code> attribute, despite accepting both <code id="restrictions-on-content-models-and-on-attribute-values:attr-area-shape-keyword-circ"><a href="#attr-area-shape-keyword-circ">circ</a></code> and <code id="restrictions-on-content-models-and-on-attribute-values:attr-area-shape-keyword-circle"><a href="#attr-area-shape-keyword-circle">circle</a></code> values in practice as synonyms, disallows
    the use of the <code id="restrictions-on-content-models-and-on-attribute-values:attr-area-shape-keyword-circ-2"><a href="#attr-area-shape-keyword-circ">circ</a></code> value, so as to simplify
    tutorials and other learning aids. There would be no benefit to allowing both, but it would
    cause extra confusion when teaching the language.</p>
   </dd><dt>Errors that involve peculiarities of the parser</dt><dd>
    <p>Certain elements are parsed in somewhat eccentric ways (typically for historical reasons),
    and their content model restrictions are intended to avoid exposing the author to these
    issues.</p>

    <div class="example">

     <p>For example, a <code id="restrictions-on-content-models-and-on-attribute-values:the-form-element"><a href="#the-form-element">form</a></code> element isn't allowed inside <a href="#phrasing-content-2" id="restrictions-on-content-models-and-on-attribute-values:phrasing-content-2">phrasing content</a>,
     because when parsed as HTML, a <code id="restrictions-on-content-models-and-on-attribute-values:the-form-element-2"><a href="#the-form-element">form</a></code> element's start tag will imply a
     <code id="restrictions-on-content-models-and-on-attribute-values:the-p-element"><a href="#the-p-element">p</a></code> element's end tag. Thus, the following markup results in two <a href="#paragraph" id="restrictions-on-content-models-and-on-attribute-values:paragraph">paragraphs</a>, not one:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome. <c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name:<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

     <p>It is parsed exactly like the following:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome. <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">form</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name:<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

    </div>
   </dd><dt>Errors that would likely result in scripts failing in hard-to-debug ways</dt><dd>
    <p>Some errors are intended to help prevent script problems that would be hard to debug.</p>

    <p class="example">This is why, for instance, it is non-conforming to have two <code id="restrictions-on-content-models-and-on-attribute-values:the-id-attribute"><a href="#the-id-attribute">id</a></code> attributes with the same value. Duplicate IDs lead to the wrong
    element being selected, with sometimes disastrous effects whose cause is hard to determine.</p>
   </dd><dt>Errors that waste authoring time</dt><dd>
    <p>Some constructs are disallowed because historically they have been the cause of a lot of
    wasted authoring time, and by encouraging authors to avoid making them, authors can save time in
    future efforts.</p>

    <p class="example">For example, a <code id="restrictions-on-content-models-and-on-attribute-values:the-script-element"><a href="#the-script-element">script</a></code> element's <code id="restrictions-on-content-models-and-on-attribute-values:attr-script-src"><a href="#attr-script-src">src</a></code> attribute causes the element's contents to be ignored.
    However, this isn't obvious, especially if the element's contents appear to be executable script
    — which can lead to authors spending a lot of time trying to debug the inline script
    without realizing that it is not executing. To reduce this problem, this specification makes it
    non-conforming to have executable script in a <code id="restrictions-on-content-models-and-on-attribute-values:the-script-element-2"><a href="#the-script-element">script</a></code> element when the <code id="restrictions-on-content-models-and-on-attribute-values:attr-script-src-2"><a href="#attr-script-src">src</a></code> attribute is present. This means that authors who are
    validating their documents are less likely to waste time with this kind of mistake.</p>
   </dd><dt>Errors that involve areas that affect authors migrating between the HTML and XML
   syntaxes</dt><dd>
    <p>Some authors like to write files that can be interpreted as both XML and HTML with similar
    results. Though this practice is discouraged in general due to the myriad of subtle
    complications involved (especially when involving scripting, styling, or any kind of automated
    serialization), this specification has a few restrictions intended to at least somewhat mitigate
    the difficulties. This makes it easier for authors to use this as a transitionary step when
    migrating between the HTML and XML syntaxes.</p>

    <p class="example">For example, there are somewhat complicated rules surrounding the <code id="restrictions-on-content-models-and-on-attribute-values:attr-lang"><a href="#attr-lang">lang</a></code> and <code id="restrictions-on-content-models-and-on-attribute-values:attr-xml-lang"><a data-x-internal="attr-xml-lang" href="https://www.w3.org/TR/xml/#sec-lang-tag">xml:lang</a></code> attributes
    intended to keep the two synchronized.</p>

    <p class="example">Another example would be the restrictions on the values of <code>xmlns</code> attributes in the HTML serialization, which are intended to ensure that
    elements in conforming documents end up in the same namespaces whether processed as HTML or
    XML.</p>
   </dd><dt>Errors that involve areas reserved for future expansion</dt><dd>
    <p>As with the restrictions on the syntax intended to allow for new syntax in future revisions
    of the language, some restrictions on the content models of elements and values of attributes
    are intended to allow for future expansion of the HTML vocabulary.</p>

    <p class="example">For example, limiting the values of the <code id="restrictions-on-content-models-and-on-attribute-values:attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code> attribute that start with an U+005F LOW LINE
    character (_) to only specific predefined values allows new predefined values to be introduced
    at a future time without conflicting with author-defined values.</p>
   </dd><dt>Errors that indicate a mis-use of other specifications</dt><dd>
    <p>Certain restrictions are intended to support the restrictions made by other
    specifications.</p>

    <p class="example">For example, requiring that attributes that take media query lists use only
    <em>valid</em> media query lists reinforces the importance of following the conformance rules of
    that specification.</p>
   </dd></dl>



  <h3 id="suggested-reading"><span class="secno">1.12</span> Suggested reading<a href="#suggested-reading" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>The following documents might be of interest to readers of this specification.</p>

  <dl><dt><cite>Character Model for the World Wide Web 1.0: Fundamentals</cite> <a href="#refsCHARMOD">[CHARMOD]</a></dt><dd><blockquote><p>This Architectural Specification provides authors of specifications, software
   developers, and content developers with a common reference for interoperable text manipulation on
   the World Wide Web, building on the Universal Character Set, defined jointly by the Unicode
   Standard and ISO/IEC 10646. Topics addressed include use of the terms 'character', 'encoding' and
   'string', a reference processing model, choice and identification of character encodings,
   character escaping, and string indexing.</p></blockquote></dd><dt><cite>Unicode Security Considerations</cite> <a href="#refsUTR36">[UTR36]</a></dt><dd><blockquote><p>Because Unicode contains such a large number of characters and incorporates
   the varied writing systems of the world, incorrect usage can expose programs or systems to
   possible security attacks. This is especially important as more and more products are
   internationalized. This document describes some of the security considerations that programmers,
   system analysts, standards developers, and users should take into account, and provides specific
   recommendations to reduce the risk of problems.</p></blockquote></dd><dt><cite>Web Content Accessibility Guidelines (WCAG)</cite> <a href="#refsWCAG">[WCAG]</a></dt><dd><blockquote><p>Web Content Accessibility Guidelines (WCAG) covers a wide range of
   recommendations for making web content more accessible. Following these guidelines will make
   content accessible to a wider range of people with disabilities, including blindness and low
   vision, deafness and hearing loss, learning disabilities, cognitive limitations, limited
   movement, speech disabilities, photosensitivity and combinations of these. Following these
   guidelines will also often make your web content more usable to users in
   general.</p></blockquote></dd><dt><cite>Authoring Tool Accessibility Guidelines (ATAG) 2.0</cite> <a href="#refsATAG">[ATAG]</a></dt><dd><blockquote><p>This specification provides guidelines for designing web content
   authoring tools that are more accessible for people with disabilities. An authoring tool that
   conforms to these guidelines will promote accessibility by providing an accessible user interface
   to authors with disabilities as well as by enabling, supporting, and promoting the production of
   accessible web content by all authors.</p></blockquote></dd><dt><cite>User Agent Accessibility Guidelines (UAAG) 2.0</cite> <a href="#refsUAAG">[UAAG]</a></dt><dd><blockquote><p>This document provides guidelines for designing user agents that
   lower barriers to web accessibility for people with disabilities. User agents include browsers
   and other types of software that retrieve and render web content. A user agent that conforms to
   these guidelines will promote accessibility through its own user interface and through other
   internal facilities, including its ability to communicate with other technologies (especially
   assistive technologies). Furthermore, all users, not just users with disabilities, should find
   conforming user agents to be more usable.</p></blockquote></dd></dl>



  <h2 id="infrastructure"><span class="secno">2</span> Common infrastructure<a href="#infrastructure" class="self-link"></a></h2>

  <p>This specification depends on <cite>Infra</cite>. <a href="#refsINFRA">[INFRA]</a></p>

  <h3 id="terminology"><span class="secno">2.1</span> Terminology<a href="#terminology" class="self-link"></a></h3>

  <p>This specification refers to both HTML and XML attributes and IDL attributes, often in the same
  context. When it is not clear which is being referred to, they are referred to as <dfn data-lt="content attribute" data-export="">content attributes</dfn> for HTML and XML attributes,
  and <dfn>IDL attributes</dfn> for those defined on IDL interfaces. Similarly, the term
  "properties" is used for both JavaScript object properties and CSS properties. When these are
  ambiguous they are qualified as <dfn>object properties</dfn> and <dfn>CSS properties</dfn> respectively.</p>

  <p>Generally, when the specification states that a feature applies to <a href="#syntax" id="terminology:syntax">the HTML syntax</a>
  or <a href="#the-xhtml-syntax" id="terminology:the-xhtml-syntax">the XML syntax</a>, it also includes the other. When a feature specifically only
  applies to one of the two languages, it is called out by explicitly stating that it does not apply
  to the other format, as in "for HTML, ... (this does not apply to XML)".</p>

  <p>This specification uses the term <dfn>document</dfn> to refer to any use of HTML,
  ranging from short static documents to long essays or reports with rich multimedia, as well as to
  fully-fledged interactive applications. The term is used to refer both to <code id="terminology:document"><a href="#document">Document</a></code>
  objects and their descendant DOM trees, and to serialized byte streams using the <a href="#syntax" id="terminology:syntax-2">HTML syntax</a> or the <a href="#the-xhtml-syntax" id="terminology:the-xhtml-syntax-2">XML syntax</a>, depending
  on context.</p>

  <p>In the context of the DOM structures, the terms <a href="https://dom.spec.whatwg.org/#html-document" id="terminology:html-documents" data-x-internal="html-documents">HTML
  document</a> and <a href="https://dom.spec.whatwg.org/#xml-document" id="terminology:xml-documents" data-x-internal="xml-documents">XML document</a> are used as defined in
  <cite>DOM</cite>, and refer specifically to two different modes that <code id="terminology:document-2"><a href="#document">Document</a></code> objects
  can find themselves in. <a href="#refsDOM">[DOM]</a> (Such uses are always hyperlinked to their
  definition.)</p>

  <p>In the context of byte streams, the term HTML document refers to resources labeled as
  <code id="terminology:text/html"><a href="#text/html">text/html</a></code>, and the term XML document refers to resources labeled with an <a id="terminology:xml-mime-type" href="https://mimesniff.spec.whatwg.org/#xml-mime-type" data-x-internal="xml-mime-type">XML
  MIME type</a>.</p>

  <hr>

  <p>For simplicity, terms such as <dfn>shown</dfn>, <dfn>displayed</dfn>, and
  <dfn>visible</dfn> might sometimes be used when referring to the way a document is
  rendered to the user. These terms are not meant to imply a visual medium; they must be considered
  to apply to other media in equivalent ways.</p>


  

  <h4 id="parallelism"><span class="secno">2.1.1</span> Parallelism<a href="#parallelism" class="self-link"></a></h4>

  <p>To run steps <dfn id="in-parallel" data-export="">in parallel</dfn> means those steps are to be run, one after another,
  at the same time as other logic in the standard (e.g., at the same time as the <a href="#event-loop" id="parallelism:event-loop">event
  loop</a>). This standard does not define the precise mechanism by which this is achieved, be it
  time-sharing cooperative multitasking, fibers, threads, processes, using different hyperthreads,
  cores, CPUs, machines, etc. By contrast, an operation that is to run <dfn id="immediately">immediately</dfn> must
  interrupt the currently running task, run itself, and then resume the previously running task.</p>

  <p class="note">For guidance on writing specifications that leverage parallelism, see <a href="#event-loop-for-spec-authors">Dealing with the event loop from other specifications</a>.</p>

  <p>To avoid race conditions between different <a href="#in-parallel" id="parallelism:in-parallel">in parallel</a> algorithms that operate on
  the same data, a <a href="#parallel-queue" id="parallelism:parallel-queue">parallel queue</a> can be used.</p>

  <p>A <dfn id="parallel-queue" data-export="">parallel queue</dfn> represents a queue of algorithm steps that must be run in
  series.</p>

  <p>A <a href="#parallel-queue" id="parallelism:parallel-queue-2">parallel queue</a> has an <dfn id="algorithm-queue">algorithm queue</dfn> (a <a id="parallelism:queue" href="https://infra.spec.whatwg.org/#queue" data-x-internal="queue">queue</a>),
  initially empty.</p>

  <div data-algorithm="">
  <p>To <dfn data-dfn-for="parallel queue" id="enqueue-the-following-steps" data-lt="enqueue steps|enqueue the following
  steps" data-export="">enqueue steps</dfn> to a <a href="#parallel-queue" id="parallelism:parallel-queue-3">parallel queue</a>,
  <a id="parallelism:enqueue" href="https://infra.spec.whatwg.org/#queue-enqueue" data-x-internal="enqueue">enqueue</a> the algorithm steps to the <a href="#parallel-queue" id="parallelism:parallel-queue-4">parallel queue</a>'s <a href="#algorithm-queue" id="parallelism:algorithm-queue">algorithm
  queue</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="starting-a-new-parallel-queue" data-lt="start a new parallel queue|starting a
  new parallel queue" data-export="">start a new parallel queue</dfn>, run the following steps:</p>

  <ol><li><p>Let <var>parallelQueue</var> be a new <a href="#parallel-queue" id="parallelism:parallel-queue-5">parallel queue</a>.</p></li><li>
    <p>Run the following steps <a href="#in-parallel" id="parallelism:in-parallel-2">in parallel</a>:</p>

    <ol><li>
      <p>While true:</p>

      <ol><li><p>Let <var>steps</var> be the result of <a href="https://infra.spec.whatwg.org/#queue-dequeue" id="parallelism:dequeue" data-x-internal="dequeue">dequeuing</a> from
       <var>parallelQueue</var>'s <a href="#algorithm-queue" id="parallelism:algorithm-queue-2">algorithm queue</a>.</p></li><li><p>If <var>steps</var> is not nothing, then run <var>steps</var>.</p></li><li><p><a id="parallelism:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: running <var>steps</var> did not throw an exception, as steps
       running <a href="#in-parallel" id="parallelism:in-parallel-3">in parallel</a> are not allowed to throw.</p></li></ol>

      <p class="note">Implementations are not expected to implement this as a continuously running
      loop. Algorithms in standards are to be easy to understand and are not necessarily great for
      battery life or performance.</p>
     </li></ol>
   </li><li><p>Return <var>parallelQueue</var>.</p></li></ol>
  </div>

  <p class="note">Steps running <a href="#in-parallel" id="parallelism:in-parallel-4">in parallel</a> can themselves run other steps in <a href="#in-parallel" id="parallelism:in-parallel-5">in
  parallel</a>. E.g., inside a <a href="#parallel-queue" id="parallelism:parallel-queue-6">parallel queue</a> it can be useful to run a series of
  steps in parallel with the queue.</p>

  <div data-var-scope="" class="example">
   <p>Imagine a standard defined <var>nameList</var> (a <a id="parallelism:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>), along with a method to
   add a <var>name</var> to <var>nameList</var>, unless <var>nameList</var> already <a href="https://infra.spec.whatwg.org/#list-contain" id="parallelism:list-contains" data-x-internal="list-contains">contains</a> <var>name</var>, in which case it rejects.</p>

   <p>The following solution suffers from race conditions:</p>

   <div data-algorithm="">
   <ol><li><p>Let <var>p</var> be a new promise created in <a id="parallelism:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-realm" id="parallelism:concept-relevant-realm">relevant realm</a>.</p></li><li><p>Let <var>global</var> be <a id="parallelism:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="parallelism:concept-relevant-global">relevant global
    object</a>.</p></li><li>
     <p>Run the following steps <a href="#in-parallel" id="parallelism:in-parallel-6">in parallel</a>:</p>

     <ol><li><p>If <var>nameList</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="parallelism:list-contains-2" data-x-internal="list-contains">contains</a> <var>name</var>,
      then <a href="#queue-a-global-task" id="parallelism:queue-a-global-task">queue a global task</a> on the <a href="#dom-manipulation-task-source" id="parallelism:dom-manipulation-task-source">DOM manipulation task source</a> given
      <var>global</var> to reject <var>p</var> with a <code id="parallelism:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>, and abort these
      steps.</p></li><li><p>Do some potentially lengthy work.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="parallelism:list-append" data-x-internal="list-append">Append</a> <var>name</var> to
      <var>nameList</var>.</p></li><li><p><a href="#queue-a-global-task" id="parallelism:queue-a-global-task-2">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="parallelism:dom-manipulation-task-source-2">DOM manipulation task source</a> given
      <var>global</var> to resolve <var>p</var> with undefined.</p></li></ol>
    </li><li><p>Return <var>p</var>.</p></li></ol>
   </div>

   <p>Two invocations of the above could run simultaneously, meaning <var>name</var> isn't in
   <var>nameList</var> during step 3.1, but it <em>might be added</em> before step 3.3 runs,
   meaning <var>name</var> ends up in <var>nameList</var> twice.</p>

   <p>Parallel queues solve this. The standard would let <var>nameListQueue</var> be the result of
   <a href="#starting-a-new-parallel-queue" id="parallelism:starting-a-new-parallel-queue">starting a new parallel queue</a>, then:</p>

   <div data-algorithm="">
   <ol><li><p>Let <var>p</var> be a new promise created in <a id="parallelism:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-realm" id="parallelism:concept-relevant-realm-2">relevant realm</a>.</p></li><li><p>Let <var>global</var> be <a id="parallelism:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="parallelism:concept-relevant-global-2">relevant global
    object</a>.</p></li><li>
     <p><mark><a href="#enqueue-the-following-steps" id="parallelism:enqueue-the-following-steps">Enqueue the following steps</a> to <var>nameListQueue</var>:</mark></p>

     <ol><li><p>If <var>nameList</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="parallelism:list-contains-3" data-x-internal="list-contains">contains</a> <var>name</var>,
      then <a href="#queue-a-global-task" id="parallelism:queue-a-global-task-3">queue a global task</a> on the <a href="#dom-manipulation-task-source" id="parallelism:dom-manipulation-task-source-3">DOM manipulation task source</a> given
      <var>global</var> to reject <var>p</var> with a <code id="parallelism:typeerror-2"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>, and abort these
      steps.</p></li><li><p>Do some potentially lengthy work.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="parallelism:list-append-2" data-x-internal="list-append">Append</a> <var>name</var> to
      <var>nameList</var>.</p></li><li><p><a href="#queue-a-global-task" id="parallelism:queue-a-global-task-4">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="parallelism:dom-manipulation-task-source-4">DOM manipulation task source</a> given
      <var>global</var> to resolve <var>p</var> with undefined.</p></li></ol>
    </li><li><p>Return <var>p</var>.</p></li></ol>
   </div>

   <p>The steps would now queue and the race is avoided.</p>
  </div>

  


  <h4 id="resources"><span class="secno">2.1.2</span> Resources<a href="#resources" class="self-link"></a></h4>

  <p>The specification uses the term <dfn>supported</dfn> when referring to whether a user
  agent has an implementation capable of decoding the semantics of an external resource. A format or
  type is said to be <i>supported</i> if the implementation can process an external resource of that
  format or type without critical aspects of the resource being ignored. Whether a specific resource
  is <i>supported</i> can depend on what features of the resource's format are in use.</p>

  <p class="example">For example, a PNG image would be considered to be in a supported format if its
  pixel data could be decoded and rendered, even if, unbeknownst to the implementation, the image
  also contained animation data.</p>

  <p class="example">An MPEG-4 video file would not be considered to be in a supported format if the
  compression format used was not supported, even if the implementation could determine the
  dimensions of the movie from the file's metadata.</p>

  <p>What some specifications, in particular the HTTP specifications, refer to as a
  <i>representation</i> is referred to in this specification as a <dfn>resource</dfn>.
  <a href="#refsHTTP">[HTTP]</a></p>

  <p>A resource's <dfn id="critical-subresources">critical subresources</dfn> are those that the resource needs to have
  available to be correctly processed. Which resources are considered critical or not is defined by
  the specification that defines the resource's format.</p>

  <p>For <a href="https://drafts.csswg.org/cssom/#css-style-sheet" id="resources:css-style-sheet" data-x-internal="css-style-sheet">CSS style sheets</a>, we tentatively define here that
  their critical subresources are other style sheets imported via <code>@import</code>
  rules, including those indirectly imported by other imported style sheets.</p>

  <p class="XXX">This definition is not fully interoperable; furthermore, some user agents seem to
  count resources like background images or web fonts as critical subresources. Ideally, the CSS
  Working Group would define this; see <a href="https://github.com/w3c/csswg-drafts/issues/1088">w3c/csswg-drafts issue #1088</a> to track
  progress on that front.</p>


  <h4 id="xml"><span class="secno">2.1.3</span> XML compatibility<a href="#xml" class="self-link"></a></h4>

  <p id="html-namespace">To ease migration from HTML to XML, user agents conforming to this
  specification will place elements in HTML in the <code id="xml:html-namespace-2"><a data-x-internal="html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace">http://www.w3.org/1999/xhtml</a></code> namespace, at least for the purposes of the DOM and
  CSS. The term "<dfn id="html-elements" data-export="">HTML elements</dfn>" refers to any element in that namespace, even in
  XML documents.</p>

  <p>Except where otherwise stated, all elements defined or mentioned in this specification are in
  the <a id="xml:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a> ("<code>http://www.w3.org/1999/xhtml</code>"), and all
  attributes defined or mentioned in this specification have no namespace.</p>

  <p>The term <dfn id="element-type">element type</dfn> is used to refer to the set of elements that have a given
  local name and namespace. For example, <code id="xml:the-button-element"><a href="#the-button-element">button</a></code> elements are elements with the element
  type <code id="xml:the-button-element-2"><a href="#the-button-element">button</a></code>, meaning they have the local name "<code>button</code>" and
  (implicitly as defined above) the <a id="xml:html-namespace-2-3" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>.</p>


  <h4 id="dom-trees"><span class="secno">2.1.4</span> DOM trees<a href="#dom-trees" class="self-link"></a></h4>

  <p>When it is stated that some element or attribute is <dfn id="ignore">ignored</dfn>, or
  treated as some other value, or handled as if it was something else, this refers only to the
  processing of the node after it is in the DOM. A user agent must not mutate the
  DOM in such situations.</p>

  <p>A content attribute is said to <dfn>change</dfn> value only if its new value is
  different than its previous value; setting an attribute to a value it already has does not change
  it.</p>

  <p>The term <dfn>empty</dfn>, when used for an attribute value, <code id="dom-trees:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node,
  or string, means that the <a id="dom-trees:length" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the text is zero (i.e., not even containing <a href="https://infra.spec.whatwg.org/#control" id="dom-trees:control" data-x-internal="control">controls</a> or U+0020 SPACE).</p>

  <p>An HTML element can have specific <dfn id="html-element-insertion-steps">HTML element insertion steps</dfn>, <dfn id="html-element-post-connection-steps">HTML element
  post-connection steps</dfn>, <dfn id="html-element-removing-steps">HTML element removing steps</dfn>, and <dfn id="html-element-moving-steps">HTML element moving
  steps</dfn> all defined for the element's <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="dom-trees:concept-element-local-name" data-x-internal="concept-element-local-name">local
  name</a>.</p>

  <div data-algorithm="">
  <p>The <a href="https://dom.spec.whatwg.org/#concept-node-insert-ext" id="dom-trees:concept-node-insert-ext" data-x-internal="concept-node-insert-ext">insertion steps</a> for the HTML Standard, given
  <var>insertedNode</var>, are defined as the following:</p>

  <ol><li><p>If <var>insertedNode</var> is an element whose <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="dom-trees:concept-element-namespace" data-x-internal="concept-element-namespace">namespace</a> is the <a id="dom-trees:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, and this
   standard defines <a href="#html-element-insertion-steps" id="dom-trees:html-element-insertion-steps">HTML element insertion steps</a>
   for <var>insertedNode</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="dom-trees:concept-element-local-name-2" data-x-internal="concept-element-local-name">local name</a>, then
   run the corresponding <a href="#html-element-insertion-steps" id="dom-trees:html-element-insertion-steps-2">HTML element insertion steps</a> given
   <var>insertedNode</var>.</p></li><li>
    <p>If <var>insertedNode</var> is a <a href="#form-associated-element" id="dom-trees:form-associated-element">form-associated element</a> or the ancestor of a
    <a href="#form-associated-element" id="dom-trees:form-associated-element-2">form-associated element</a>, then:</p>

    <ol><li><p>If the <a href="#form-associated-element" id="dom-trees:form-associated-element-3">form-associated element</a>'s <a href="#parser-inserted-flag" id="dom-trees:parser-inserted-flag">parser inserted flag</a> is set,
     then return.</p></li><li><p><a href="#reset-the-form-owner" id="dom-trees:reset-the-form-owner">Reset the form owner</a> of the <a href="#form-associated-element" id="dom-trees:form-associated-element-4">form-associated element</a>.</p></li></ol>
   </li><li><p>If <var>insertedNode</var> is an <code id="dom-trees:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> that is not on the
   <a href="#stack-of-open-elements" id="dom-trees:stack-of-open-elements">stack of open elements</a> of an <a href="#html-parser" id="dom-trees:html-parser">HTML parser</a>, then
   <a href="#process-internal-resource-links" id="dom-trees:process-internal-resource-links">process internal resource links</a> given <var>insertedNode</var>'s
   <a id="dom-trees:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="https://dom.spec.whatwg.org/#concept-node-post-connection-ext" id="dom-trees:concept-node-post-connection-ext" data-x-internal="concept-node-post-connection-ext">post-connection steps</a> for the HTML
  Standard, given <var>insertedNode</var>, are defined as the following:</p>

  <ol><li><p>If <var>insertedNode</var> is an element whose <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="dom-trees:concept-element-namespace-2" data-x-internal="concept-element-namespace">namespace</a> is the <a id="dom-trees:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, and this
   standard defines <a href="#html-element-post-connection-steps" id="dom-trees:html-element-post-connection-steps">HTML element post-connection
   steps</a> for <var>insertedNode</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="dom-trees:concept-element-local-name-3" data-x-internal="concept-element-local-name">local
   name</a>, then run the corresponding <a href="#html-element-post-connection-steps" id="dom-trees:html-element-post-connection-steps-2">HTML element post-connection steps</a> given
   <var>insertedNode</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="https://dom.spec.whatwg.org/#concept-node-remove-ext" id="dom-trees:concept-node-remove-ext" data-x-internal="concept-node-remove-ext">removing steps</a> for the HTML Standard, given
  <var>removedNode</var> and <var>oldParent</var>, are defined as the following:</p>

  <ol><li><p>Let <var>document</var> be <var>removedNode</var>'s <a id="dom-trees:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li id="node-remove-focus-fixup">
    <p>If <var>document</var>'s <a href="#focused-area-of-the-document" id="dom-trees:focused-area-of-the-document">focused area</a> is
    <var>removedNode</var>, then set <var>document</var>'s <a href="#focused-area-of-the-document" id="dom-trees:focused-area-of-the-document-2">focused area</a> to <var>document</var>'s <a id="dom-trees:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>, and set
    <var>document</var>'s <a href="#concept-relevant-global" id="dom-trees:concept-relevant-global">relevant global object</a>'s <a href="#window-navigation-api" id="dom-trees:window-navigation-api">navigation API</a>'s <a href="#focus-changed-during-ongoing-navigation" id="dom-trees:focus-changed-during-ongoing-navigation">focus changed during ongoing
    navigation</a> to false.</p>

    <p class="note">This does <em>not</em> perform the <a href="#unfocusing-steps" id="dom-trees:unfocusing-steps">unfocusing steps</a>,
    <a href="#focusing-steps" id="dom-trees:focusing-steps">focusing steps</a>, or <a href="#focus-update-steps" id="dom-trees:focus-update-steps">focus update steps</a>, and thus no <code id="dom-trees:event-blur"><a href="#event-blur">blur</a></code> or <code id="dom-trees:event-change"><a href="#event-change">change</a></code> events are
    fired.</p>
   </li><li><p>If <var>removedNode</var> is an element whose <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="dom-trees:concept-element-namespace-3" data-x-internal="concept-element-namespace">namespace</a> is the <a id="dom-trees:html-namespace-2-3" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, and this
   standard defines <a href="#html-element-removing-steps" id="dom-trees:html-element-removing-steps">HTML element removing steps</a>
   for <var>removedNode</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="dom-trees:concept-element-local-name-4" data-x-internal="concept-element-local-name">local name</a>, then
   run the corresponding <a href="#html-element-removing-steps" id="dom-trees:html-element-removing-steps-2">HTML element removing steps</a> given <var>removedNode</var> and
   <var>oldParent</var>.</p></li><li><p>If <var>removedNode</var> is a <a href="#form-associated-element" id="dom-trees:form-associated-element-5">form-associated element</a> with a non-null
   <a href="#form-owner" id="dom-trees:form-owner">form owner</a> and <var>removedNode</var> and its <a href="#form-owner" id="dom-trees:form-owner-2">form owner</a> are no longer
   in the same <a id="dom-trees:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>, then <a href="#reset-the-form-owner" id="dom-trees:reset-the-form-owner-2">reset the form owner</a> of
   <var>removedNode</var>.</p></li><li><p>If <var>removedNode</var>'s <code id="dom-trees:attr-popover"><a href="#attr-popover">popover</a></code> attribute is not in
   the <a href="#attr-popover-none-state" id="dom-trees:attr-popover-none-state">No Popover</a> state, then run the <a href="#hide-popover-algorithm" id="dom-trees:hide-popover-algorithm">hide
   popover algorithm</a> given <var>removedNode</var>, false, false, false, and null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="https://dom.spec.whatwg.org/#concept-node-move-ext" id="dom-trees:concept-node-move-ext" data-x-internal="concept-node-move-ext">moving steps</a> for the HTML Standard, given
  <var>movedNode</var>, are defined as the following:</p>

  <ol><li><p>If <var>movedNode</var> is an element whose <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="dom-trees:concept-element-namespace-4" data-x-internal="concept-element-namespace">namespace</a> is the <a id="dom-trees:html-namespace-2-4" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, and this
   standard defines <a href="#html-element-moving-steps" id="dom-trees:html-element-moving-steps">HTML element moving steps</a> for <var>movedNode</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="dom-trees:concept-element-local-name-5" data-x-internal="concept-element-local-name">local name</a>, then run the corresponding <a href="#html-element-moving-steps" id="dom-trees:html-element-moving-steps-2">HTML
   element moving steps</a> given <var>movedNode</var>.</p></li><li><p>If <var>movedNode</var> is a <a href="#form-associated-element" id="dom-trees:form-associated-element-6">form-associated element</a> with a non-null
   <a href="#form-owner" id="dom-trees:form-owner-3">form owner</a> and <var>movedNode</var> and its <a href="#form-owner" id="dom-trees:form-owner-4">form owner</a> are no longer in
   the same <a id="dom-trees:tree-2" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>, then <a href="#reset-the-form-owner" id="dom-trees:reset-the-form-owner-3">reset the form owner</a> of
   <var>movedNode</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <dfn id="insert-an-element-into-a-document" data-lt="inserted into a document|node is inserted into a document" data-export="">node is inserted into a
  document</dfn> when the <a href="https://dom.spec.whatwg.org/#concept-node-insert-ext" id="dom-trees:concept-node-insert-ext-2" data-x-internal="concept-node-insert-ext">insertion steps</a> are invoked
  with it as the argument and it is now <a id="dom-trees:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>.  Analogously, a <dfn id="remove-an-element-from-a-document" data-lt="removed
  from a document|node is removed from a document" data-export="">node is removed from a document</dfn> when
  the <a href="https://dom.spec.whatwg.org/#concept-node-remove-ext" id="dom-trees:concept-node-remove-ext-2" data-x-internal="concept-node-remove-ext">removing steps</a> are invoked with it as the
  argument and it is now no longer <a id="dom-trees:in-a-document-tree-2" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A node <dfn id="becomes-connected" data-export="">becomes connected</dfn> when the <a href="https://dom.spec.whatwg.org/#concept-node-insert-ext" id="dom-trees:concept-node-insert-ext-3" data-x-internal="concept-node-insert-ext">insertion steps</a> are invoked with it as the argument and it
  is now <a id="dom-trees:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>. Analogously, a node <dfn id="becomes-disconnected" data-lt="become disconnected" data-export="">becomes disconnected</dfn> when the <a href="https://dom.spec.whatwg.org/#concept-node-remove-ext" id="dom-trees:concept-node-remove-ext-3" data-x-internal="concept-node-remove-ext">removing
  steps</a> are invoked with it as the argument and it is now no longer
  <a id="dom-trees:connected-2" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A node is <dfn id="browsing-context-connected" data-export="">browsing-context connected</dfn> when it is <a id="dom-trees:connected-3" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a> and
  its <a href="https://dom.spec.whatwg.org/#concept-shadow-including-root" id="dom-trees:shadow-including-root" data-x-internal="shadow-including-root">shadow-including root</a>'s <a href="#concept-document-bc" id="dom-trees:concept-document-bc">browsing context</a> is non-null. A node <dfn id="becomes-browsing-context-connected" data-lt="become
  browsing-context connected" data-export="">becomes browsing-context connected</dfn> when the <a href="https://dom.spec.whatwg.org/#concept-node-insert-ext" id="dom-trees:concept-node-insert-ext-4" data-x-internal="concept-node-insert-ext">insertion steps</a> are invoked with it as the argument and it
  is now <a href="#browsing-context-connected" id="dom-trees:browsing-context-connected">browsing-context connected</a>. A node <dfn id="becomes-browsing-context-disconnected" data-lt="become browsing-context
  disconnected" data-export="">becomes browsing-context disconnected</dfn> either when the <a href="https://dom.spec.whatwg.org/#concept-node-remove-ext" id="dom-trees:concept-node-remove-ext-4" data-x-internal="concept-node-remove-ext">removing steps</a> are invoked with it as the argument and it
  is now no longer <a href="#browsing-context-connected" id="dom-trees:browsing-context-connected-2">browsing-context connected</a>, or when its <a id="dom-trees:shadow-including-root-2" href="https://dom.spec.whatwg.org/#concept-shadow-including-root" data-x-internal="shadow-including-root">shadow-including
  root</a>'s <a href="#concept-document-bc" id="dom-trees:concept-document-bc-2">browsing context</a> becomes null.
  </p></div>


  <h4 id="scripting-2"><span class="secno">2.1.5</span> Scripting<a href="#scripting-2" class="self-link"></a></h4>

  <p>The construction "a <code>Foo</code> object", where <code>Foo</code> is
  actually an interface, is sometimes used instead of the more accurate "an object implementing the
  interface <code>Foo</code>".</p>

  <p>An IDL attribute is said to be <dfn>getting</dfn> when its value is being retrieved
  (e.g. by author script), and is said to be <dfn>setting</dfn> when a new value is
  assigned to it.</p>

  <p>If a DOM object is said to be <dfn id="live">live</dfn>, then the attributes and methods on that object
  must operate on the actual underlying data, not a snapshot of the
  data.</p>


  <h4 id="plugins"><span class="secno">2.1.6</span> Plugins<a href="#plugins" class="self-link"></a></h4>

  <p>The term <dfn id="plugin">plugin</dfn> refers to an <a id="plugins:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> set of content
  handlers used by the user agent that can take part in the user agent's rendering of a
  <code id="plugins:document"><a href="#document">Document</a></code> object, but that neither act as <a href="#child-navigable" id="plugins:child-navigable">child
  navigables</a> of the <code id="plugins:document-2"><a href="#document">Document</a></code> nor introduce any <code id="plugins:node"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code> objects to the
  <code id="plugins:document-3"><a href="#document">Document</a></code>'s DOM.</p>

  <p>Typically such content handlers are provided by third parties, though a user agent can also
  designate built-in content handlers as plugins.</p>

  

  <p>A user agent must not consider the types <code id="plugins:text/plain"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code> and
  <code id="plugins:application/octet-stream"><a data-x-internal="application/octet-stream" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1">application/octet-stream</a></code> as having a registered <a href="#plugin" id="plugins:plugin">plugin</a>.</p> 

  

  <p class="example">One example of a plugin would be a PDF viewer that is instantiated in a
  <a href="#navigable" id="plugins:navigable">navigable</a> when the user navigates to a PDF file. This would count as a plugin
  regardless of whether the party that implemented the PDF viewer component was the same as that
  which implemented the user agent itself. However, a PDF viewer application that launches separate
  from the user agent (as opposed to using the same interface) is not a plugin by this
  definition.</p>

  <p class="note">This specification does not define a mechanism for interacting with plugins, as it
  is expected to be user-agent- and platform-specific. Some UAs might opt to support a plugin
  mechanism such as the Netscape Plugin API; others might use remote content converters or have
  built-in support for certain types. Indeed, this specification doesn't require user agents to
  support plugins at all. <a href="#refsNPAPI">[NPAPI]</a></p>

  

  <p class="warning">Browsers should take extreme care when interacting with external content
  intended for <a href="#plugin" id="plugins:plugin-2">plugins</a>. When third-party software is run with the same
  privileges as the user agent itself, vulnerabilities in the third-party software become as
  dangerous as those in the user agent.</p>

  <p>
  <a id="plugins:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  Since different users having different sets of <a href="#plugin" id="plugins:plugin-3">plugins</a> provides a
  tracking vector that increases the chances of users being uniquely identified, user agents are
  encouraged to support the exact same set of <a href="#plugin" id="plugins:plugin-4">plugins</a> for each
  user.</p>

  



  <h4 id="encoding-terminology"><span class="secno">2.1.7</span> Character encodings<a href="#encoding-terminology" class="self-link"></a></h4>

  <p>A <dfn id="encoding"><a href="https://encoding.spec.whatwg.org/#encoding">character
  encoding</a></dfn>, or just <i>encoding</i> where that is not ambiguous, is a defined way to convert
  between byte streams and Unicode strings, as defined in <cite>Encoding</cite>. An
  <a id="encoding-terminology:encoding" href="https://encoding.spec.whatwg.org/#encoding" data-x-internal="encoding">encoding</a> has an <dfn id="encoding-name"><a href="https://encoding.spec.whatwg.org/#name">encoding
  name</a></dfn> and one or more <dfn id="encoding-label"><a href="https://encoding.spec.whatwg.org/#label">encoding labels</a></dfn>, referred to as the
  encoding's <i>name</i> and <i>labels</i> in the Encoding standard. <a href="#refsENCODING">[ENCODING]</a></p>



  

  <h4 id="conformance-classes"><span class="secno">2.1.8</span> Conformance classes<a href="#conformance-classes" class="self-link"></a></h4>

  <p>This specification describes the conformance criteria for user agents
  (relevant to implementers) and documents (relevant to authors and
  authoring tool implementers).</p>

  <p><dfn id="conforming-documents">Conforming documents</dfn> are those that comply with all the conformance criteria for
  documents. For readability, some of these conformance requirements are phrased as conformance
  requirements on authors; such requirements are implicitly requirements on documents: by
  definition, all documents are assumed to have had an author. (In some cases, that author may
  itself be a user agent — such user agents are subject to additional rules, as explained
  below.)</p>

  <p class="example">For example, if a requirement states that "authors must not
  use the <code>foobar</code> element", it would imply that documents are not allowed to
  contain elements named <code>foobar</code>.</p>

  <p class="note impl">There is no implied relationship between document conformance requirements
  and implementation conformance requirements. User agents are not free to handle non-conformant
  documents as they please; the processing model described in this specification applies to
  implementations regardless of the conformity of the input documents.</p>

  <p>User agents fall into several (overlapping) categories with different conformance
  requirements.</p>

  <dl><dt id="interactive">Web browsers and other interactive user agents</dt><dd>
    <p>Web browsers that support <a href="#the-xhtml-syntax" id="conformance-classes:the-xhtml-syntax">the XML syntax</a> must process elements and attributes
    from the <a id="conformance-classes:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a> found in XML documents as described in this specification,
    so that users can interact with them, unless the semantics of those elements have been
    overridden by other specifications.</p>

    <p class="example">A conforming web browser would, upon finding a <code id="conformance-classes:the-script-element"><a href="#the-script-element">script</a></code> element in
    an XML document, execute the script contained in that element. However, if the element is found
    within a transformation expressed in XSLT (assuming the user agent also supports XSLT), then the
    processor would instead treat the <code id="conformance-classes:the-script-element-2"><a href="#the-script-element">script</a></code> element as an opaque element that forms
    part of the transform.</p>

    <p>Web browsers that support <a href="#syntax" id="conformance-classes:syntax">the HTML syntax</a> must process documents labeled with an
    <a id="conformance-classes:html-mime-type" href="https://mimesniff.spec.whatwg.org/#html-mime-type" data-x-internal="html-mime-type">HTML MIME type</a> as described in this specification, so that users can interact with
    them.</p>

    <p>User agents that support scripting must also be conforming implementations of the IDL
    fragments in this specification, as described in <cite>Web IDL</cite>. <a href="#refsWEBIDL">[WEBIDL]</a></p>

    <p class="note">Unless explicitly stated, specifications that override the semantics of HTML
    elements do not override the requirements on DOM objects representing those elements. For
    example, the <code id="conformance-classes:the-script-element-3"><a href="#the-script-element">script</a></code> element in the example above would still implement the
    <code id="conformance-classes:htmlscriptelement"><a href="#htmlscriptelement">HTMLScriptElement</a></code> interface.</p>
   </dd><dt id="non-interactive">Non-interactive presentation user agents</dt><dd>
    <p>User agents that process HTML and XML documents purely to render non-interactive versions of
    them must comply to the same conformance criteria as web browsers, except that they are exempt
    from requirements regarding user interaction.</p>

    <p class="note">Typical examples of non-interactive presentation user agents are printers
    (static UAs) and overhead displays (dynamic UAs). It is expected that most static
    non-interactive presentation user agents will also opt to <a href="#non-scripted">lack scripting
    support</a>.</p>

    <p class="example">A non-interactive but dynamic presentation UA would still execute scripts,
    allowing forms to be dynamically submitted, and so forth. However, since the concept of "focus"
    is irrelevant when the user cannot interact with the document, the UA would not need to support
    any of the focus-related DOM APIs.</p>
   </dd><dt id="renderingUA">Visual user agents that support the suggested default rendering</dt><dd>
    <p>User agents, whether interactive or not, may be designated (possibly as a user option) as
    supporting the suggested default rendering defined by this specification.</p>

    <p>This is not required. In particular, even user agents that do implement the suggested default
    rendering are encouraged to offer settings that override this default to improve the experience
    for the user, e.g. changing the color contrast, using different focus styles, or otherwise
    making the experience more accessible and usable to the user.</p>

    <p>User agents that are designated as supporting the suggested default rendering must, while so
    designated, implement the rules <a href="#rendering">the Rendering section</a> defines as the
    behavior that user agents are <em>expected</em> to implement.</p>
   </dd><dt id="non-scripted">User agents with no scripting support</dt><dd>
    <p>Implementations that do not support scripting (or which have their scripting features
    disabled entirely) are exempt from supporting the events and DOM interfaces mentioned in this
    specification. For the parts of this specification that are defined in terms of an events model
    or in terms of the DOM, such user agents must still act as if events and the DOM were
    supported.</p>

    <p class="note">Scripting can form an integral part of an application. Web browsers that do not
    support scripting, or that have scripting disabled, might be unable to fully convey the author's
    intent.</p>
   </dd><dt>Conformance checkers</dt><dd id="conformance-checkers">

    <p>Conformance checkers must verify that a document conforms to the applicable conformance
    criteria described in this specification. Automated conformance checkers are exempt from
    detecting errors that require interpretation of the author's intent (for example, while a
    document is non-conforming if the content of a <code id="conformance-classes:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code> element is not a quote,
    conformance checkers running without the input of human judgement do not have to check that
    <code id="conformance-classes:the-blockquote-element-2"><a href="#the-blockquote-element">blockquote</a></code> elements only contain quoted material).</p>

    <p>Conformance checkers must check that the input document conforms when parsed without a
    <a href="#concept-document-bc" id="conformance-classes:concept-document-bc">browsing context</a> (meaning that no scripts are run, and
    that the parser's <a href="#scripting-flag" id="conformance-classes:scripting-flag">scripting flag</a> is disabled), and should also check that the input
    document conforms when parsed with a <a href="#concept-document-bc" id="conformance-classes:concept-document-bc-2">browsing context</a>
    in which scripts execute, and that the scripts never cause non-conforming states to occur other
    than transiently during script execution itself. (This is only a "SHOULD" and not a "MUST"
    requirement because it has been proven to be impossible. <a href="#refsCOMPUTABLE">[COMPUTABLE]</a>)</p>

    <p>The term "HTML validator" can be used to refer to a conformance checker that itself conforms
    to the applicable requirements of this specification.</p>

    <div class="note">

     <p>XML DTDs cannot express all the conformance requirements of this specification. Therefore, a
     validating XML processor and a DTD cannot constitute a conformance checker. Also, since neither
     of the two authoring formats defined in this specification are applications of SGML, a
     validating SGML system cannot constitute a conformance checker either.</p>

     <p>To put it another way, there are three types of conformance criteria:</p>

     <ol><li>Criteria that can be expressed in a DTD.</li><li>Criteria that cannot be expressed by a DTD, but can still be checked by a machine.</li><li>Criteria that can only be checked by a human.</li></ol>

     <p>A conformance checker must check for the first two. A simple DTD-based validator only checks
     for the first class of errors and is therefore not a conforming conformance checker according
     to this specification.</p>

    </div>
   </dd><dt>Data mining tools</dt><dd id="data-mining">

    <p>Applications and tools that process HTML and XML documents for reasons other than to either
    render the documents or check them for conformance should act in accordance with the semantics
    of the documents that they process.</p>

    <p class="example">A tool that generates <a href="#outline" id="conformance-classes:outline">document outlines</a> but
    increases the nesting level for each paragraph and does not increase the nesting level for
    <a href="#concept-heading" id="conformance-classes:concept-heading">headings</a> would not be conforming.</p>
   </dd><dt id="editors">Authoring tools and markup generators</dt><dd>
    <p>Authoring tools and markup generators must generate <a href="#conforming-documents" id="conformance-classes:conforming-documents">conforming documents</a>.
    Conformance criteria that apply to authors also apply to authoring tools, where appropriate.</p>

    <p>Authoring tools are exempt from the strict requirements of using elements only for their
    specified purpose, but only to the extent that authoring tools are not yet able to determine
    author intent. However, authoring tools must not automatically misuse elements or encourage
    their users to do so.</p>

    <p class="example">For example, it is not conforming to use an <code id="conformance-classes:the-address-element"><a href="#the-address-element">address</a></code> element for
    arbitrary contact information; that element can only be used for marking up contact information
    for its nearest <code id="conformance-classes:the-article-element"><a href="#the-article-element">article</a></code> or <code id="conformance-classes:the-body-element"><a href="#the-body-element">body</a></code> element ancestor. However, since an
    authoring tool is likely unable to determine the difference, an authoring tool is exempt from
    that requirement. This does not mean, though, that authoring tools can use <code id="conformance-classes:the-address-element-2"><a href="#the-address-element">address</a></code>
    elements for any block of italics text (for instance); it just means that the authoring tool
    doesn't have to verify that when the user uses a tool for inserting contact information for an
    <code id="conformance-classes:the-article-element-2"><a href="#the-article-element">article</a></code> element, that the user really is doing that and not inserting something
    else instead.</p>

    <p class="note">In terms of conformance checking, an editor has to output documents that conform
    to the same extent that a conformance checker will verify.</p>

    <p>When an authoring tool is used to edit a non-conforming document, it may preserve the
    conformance errors in sections of the document that were not edited during the editing session
    (i.e. an editing tool is allowed to round-trip erroneous content). However, an authoring tool
    must not claim that the output is conformant if errors have been so preserved.</p>

    <p>Authoring tools are expected to come in two broad varieties: tools that work from structure
    or semantic data, and tools that work on a What-You-See-Is-What-You-Get media-specific editing
    basis (WYSIWYG).</p>

    <p>The former is the preferred mechanism for tools that author HTML, since the structure in the
    source information can be used to make informed choices regarding which HTML elements and
    attributes are most appropriate.</p>

    <p>However, WYSIWYG tools are legitimate. WYSIWYG tools should use elements they know are
    appropriate, and should not use elements that they do not know to be appropriate. This might in
    certain extreme cases mean limiting the use of flow elements to just a few elements, like
    <code id="conformance-classes:the-div-element"><a href="#the-div-element">div</a></code>, <code id="conformance-classes:the-b-element"><a href="#the-b-element">b</a></code>, <code id="conformance-classes:the-i-element"><a href="#the-i-element">i</a></code>, and <code id="conformance-classes:the-span-element"><a href="#the-span-element">span</a></code> and making liberal use
    of the <code id="conformance-classes:attr-style"><a href="#attr-style">style</a></code> attribute.</p>

    <p>All authoring tools, whether WYSIWYG or not, should make a best effort attempt at enabling
    users to create well-structured, semantically rich, media-independent content.</p>
   </dd></dl>

  <p>For compatibility with existing content and prior specifications, this specification describes
  two authoring formats: one based on <a href="#the-xhtml-syntax" id="conformance-classes:the-xhtml-syntax-2">XML</a>, and one using a <a href="#writing">custom format</a> inspired by SGML (referred to as <a href="#syntax" id="conformance-classes:syntax-2">the HTML syntax</a>).
  Implementations must support at least one of these two formats, although supporting both is
  encouraged.</p>

  <p>Some conformance requirements are phrased as requirements on elements, attributes, methods or
  objects. Such requirements fall into two categories: those describing content model restrictions,
  and those describing implementation behavior. Those in the former category are requirements on
  documents and authoring tools. Those in the second category are requirements on user agents.
  Similarly, some conformance requirements are phrased as requirements on authors; such requirements
  are to be interpreted as conformance requirements on the documents that authors produce. (In other
  words, this specification does not distinguish between conformance criteria on authors and
  conformance criteria on documents.)</p>

  


  <h4 id="dependencies"><span class="secno">2.1.9</span> Dependencies<a href="#dependencies" class="self-link"></a></h4>

  
  <div data-noexport="">

  <p>This specification relies on several other underlying specifications.</p>

  <dl><dt>Infra</dt><dd>
    <p>The following terms are defined in <cite>Infra</cite>: <a href="#refsINFRA">[INFRA]</a></p>

    <ul class="brief"><li>The general iteration terms <dfn id="while"><a href="https://infra.spec.whatwg.org/#iteration-while">while</a></dfn>,
             <dfn id="continue"><a href="https://infra.spec.whatwg.org/#iteration-continue">continue</a></dfn>, and
             <dfn id="break"><a href="https://infra.spec.whatwg.org/#iteration-break">break</a></dfn>.</li><li><dfn id="assert"><a href="https://infra.spec.whatwg.org/#assert">Assert</a></dfn></li><li><dfn id="implementation-defined"><a href="https://infra.spec.whatwg.org/#implementation-defined">implementation-defined</a></dfn></li><li><dfn id="willful-violation"><a href="https://infra.spec.whatwg.org/#willful-violation">willful violation</a></dfn></li><li id="fingerprint"><span id="fingerprinting-vector"></span>
     <a id="dependencies:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
     <dfn id="tracking-vector"><a href="https://infra.spec.whatwg.org/#tracking-vector">tracking vector</a></dfn></li><li><dfn id="code-point"><a href="https://infra.spec.whatwg.org/#code-point">code point</a></dfn> and its synonym
         <dfn id="character"><a href="https://infra.spec.whatwg.org/#code-point">character</a></dfn></li><li><dfn id="surrogate"><a href="https://infra.spec.whatwg.org/#surrogate">surrogate</a></dfn></li><li><dfn id="scalar-value"><a href="https://infra.spec.whatwg.org/#scalar-value">scalar value</a></dfn></li><li><dfn id="tuple"><a href="https://infra.spec.whatwg.org/#tuple">tuple</a></dfn></li><li><dfn id="noncharacter"><a href="https://infra.spec.whatwg.org/#noncharacter">noncharacter</a></dfn></li><li><dfn id="string"><a href="https://infra.spec.whatwg.org/#string">string</a></dfn>,
         <dfn id="code-unit"><a href="https://infra.spec.whatwg.org/#code-unit">code unit</a></dfn>,
         <dfn id="code-unit-prefix"><a href="https://infra.spec.whatwg.org/#code-unit-prefix">code unit prefix</a></dfn>,
         <dfn id="code-unit-less-than"><a href="https://infra.spec.whatwg.org/#code-unit-less-than">code unit less than</a></dfn>,
         <dfn id="starts-with"><a href="https://infra.spec.whatwg.org/#string-starts-with">starts with</a></dfn>,
         <dfn id="ends-with"><a href="https://infra.spec.whatwg.org/#string-ends-with">ends with</a></dfn>,
         <dfn id="length"><a href="https://infra.spec.whatwg.org/#string-length">length</a></dfn>, and
         <dfn id="code-point-length"><a href="https://infra.spec.whatwg.org/#string-code-point-length">code point length</a></dfn></li><li id="case-sensitive">The string equality operations <dfn id="is"><a href="https://infra.spec.whatwg.org/#string-is">is</a></dfn> and
         <dfn id="identical-to"><a href="https://infra.spec.whatwg.org/#string-is">identical to</a></dfn></li><li><dfn id="scalar-value-string"><a href="https://infra.spec.whatwg.org/#scalar-value-string">scalar value string</a></dfn></li><li><dfn id="convert"><a href="https://infra.spec.whatwg.org/#javascript-string-convert">convert</a></dfn></li><li><dfn id="ascii-string"><a href="https://infra.spec.whatwg.org/#ascii-string">ASCII string</a></dfn></li><li><dfn id="ascii-tab-or-newline"><a href="https://infra.spec.whatwg.org/#ascii-tab-or-newline">ASCII tab or newline</a></dfn></li><li><dfn id="space-characters"><a href="https://infra.spec.whatwg.org/#ascii-whitespace">ASCII whitespace</a></dfn></li><li><dfn id="control"><a href="https://infra.spec.whatwg.org/#control">control</a></dfn></li><li><dfn id="ascii-digits"><a href="https://infra.spec.whatwg.org/#ascii-digit">ASCII digit</a></dfn></li><li><dfn id="uppercase-ascii-hex-digits"><a href="https://infra.spec.whatwg.org/#ascii-upper-hex-digit">ASCII upper hex digit</a></dfn></li><li><dfn id="lowercase-ascii-hex-digits"><a href="https://infra.spec.whatwg.org/#ascii-lower-hex-digit">ASCII lower hex digit</a></dfn></li><li><dfn id="ascii-hex-digits"><a href="https://infra.spec.whatwg.org/#ascii-hex-digit">ASCII hex digit</a></dfn></li><li><dfn id="uppercase-ascii-letters"><a href="https://infra.spec.whatwg.org/#ascii-upper-alpha">ASCII upper alpha</a></dfn></li><li><dfn id="lowercase-ascii-letters"><a href="https://infra.spec.whatwg.org/#ascii-lower-alpha">ASCII lower alpha</a></dfn></li><li><dfn id="ascii-letters"><a href="https://infra.spec.whatwg.org/#ascii-alpha">ASCII alpha</a></dfn></li><li><dfn id="alphanumeric-ascii-characters"><a href="https://infra.spec.whatwg.org/#ascii-alphanumeric">ASCII alphanumeric</a></dfn></li><li><dfn id="isomorphic-decode"><a href="https://infra.spec.whatwg.org/#isomorphic-decode">isomorphic decode</a></dfn></li><li><dfn id="isomorphic-encode"><a href="https://infra.spec.whatwg.org/#isomorphic-encode">isomorphic encode</a></dfn></li><li><dfn id="converted-to-ascii-lowercase"><a href="https://infra.spec.whatwg.org/#ascii-lowercase">ASCII lowercase</a></dfn></li><li><dfn id="converted-to-ascii-uppercase"><a href="https://infra.spec.whatwg.org/#ascii-uppercase">ASCII uppercase</a></dfn></li><li><dfn id="ascii-case-insensitive"><a href="https://infra.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a></dfn></li><li><dfn id="strip-newlines"><a href="https://infra.spec.whatwg.org/#strip-newlines">strip newlines</a></dfn></li><li><dfn id="normalize-newlines"><a href="https://infra.spec.whatwg.org/#normalize-newlines">normalize newlines</a></dfn></li><li><dfn id="strip-leading-and-trailing-ascii-whitespace"><a href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace">strip leading and trailing ASCII whitespace</a></dfn></li><li><dfn id="strip-and-collapse-ascii-whitespace"><a href="https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace">strip and collapse ASCII whitespace</a></dfn></li><li><dfn id="split-a-string-on-spaces"><a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace">split a string on ASCII whitespace</a></dfn></li><li><dfn id="split-a-string-on-commas"><a href="https://infra.spec.whatwg.org/#split-on-commas">split a string on commas</a></dfn></li><li><dfn id="collect-a-sequence-of-code-points"><a href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points">collect a sequence of code points</a></dfn> and its associated
         <dfn id="position-variable"><a href="https://infra.spec.whatwg.org/#string-position-variable">position variable</a></dfn></li><li><dfn id="skip-ascii-whitespace"><a href="https://infra.spec.whatwg.org/#skip-ascii-whitespace">skip ASCII whitespace</a></dfn></li><li>The <dfn id="ordered-map"><a href="https://infra.spec.whatwg.org/#ordered-map">ordered map</a></dfn> data structure and the associated definitions for
             <dfn id="map-key"><a href="https://infra.spec.whatwg.org/#map-key">key</a></dfn>,
             <dfn id="map-value"><a href="https://infra.spec.whatwg.org/#map-value">value</a></dfn>,
             <dfn id="map-empty"><a href="https://infra.spec.whatwg.org/#map-is-empty">empty</a></dfn>,
             <dfn id="map-entry"><a href="https://infra.spec.whatwg.org/#map-entry">entry</a></dfn>,
             <dfn id="map-exists"><a href="https://infra.spec.whatwg.org/#map-exists">exists</a></dfn>,
             <dfn id="map-get"><a href="https://infra.spec.whatwg.org/#map-get">getting the value of an entry</a></dfn>,
             <dfn id="map-set"><a href="https://infra.spec.whatwg.org/#map-set">setting the value of an entry</a></dfn>,
             <dfn id="map-remove"><a href="https://infra.spec.whatwg.org/#map-remove">removing an entry</a></dfn>,
             <dfn id="map-clear"><a href="https://infra.spec.whatwg.org/#map-clear">clear</a></dfn>,
             <dfn id="map-get-the-keys"><a href="https://infra.spec.whatwg.org/#map-getting-the-keys">getting the keys</a></dfn>,
             <dfn id="map-get-the-values"><a href="https://infra.spec.whatwg.org/#map-getting-the-values">getting the values</a></dfn>,
             <dfn id="map-sort-descending"><a href="https://infra.spec.whatwg.org/#map-sort-in-descending-order">sorting in descending order</a></dfn>,
             <dfn id="map-size"><a href="https://infra.spec.whatwg.org/#map-size">size</a></dfn>, and
             <dfn id="map-iterate"><a href="https://infra.spec.whatwg.org/#map-iterate">iterate</a></dfn></li><li>The <dfn id="list"><a href="https://infra.spec.whatwg.org/#list">list</a></dfn> data structure and the associated definitions for
             <dfn id="list-append"><a href="https://infra.spec.whatwg.org/#list-append">append</a></dfn>,
             <dfn id="list-extend"><a href="https://infra.spec.whatwg.org/#list-extend">extend</a></dfn>,
             <dfn id="list-prepend"><a href="https://infra.spec.whatwg.org/#list-prepend">prepend</a></dfn>,
             <dfn id="list-replace"><a href="https://infra.spec.whatwg.org/#list-replace">replace</a></dfn>,
             <dfn id="list-remove"><a href="https://infra.spec.whatwg.org/#list-remove">remove</a></dfn>,
             <dfn id="list-empty"><a href="https://infra.spec.whatwg.org/#list-empty">empty</a></dfn>,
             <dfn id="list-contains"><a href="https://infra.spec.whatwg.org/#list-contain">contains</a></dfn>,
             <dfn id="list-size"><a href="https://infra.spec.whatwg.org/#list-size">size</a></dfn>,
             <dfn id="indices"><a href="https://infra.spec.whatwg.org/#list-get-the-indices">indices</a></dfn>,
             <dfn id="list-is-empty"><a href="https://infra.spec.whatwg.org/#list-is-empty">is empty</a></dfn>,
             <dfn id="list-item"><a href="https://infra.spec.whatwg.org/#list-item">item</a></dfn>,
             <dfn id="list-iterate"><a href="https://infra.spec.whatwg.org/#list-iterate">iterate</a></dfn>, and
             <dfn id="list-clone"><a href="https://infra.spec.whatwg.org/#list-clone">clone</a></dfn>
             <dfn id="list-sort"><a href="https://infra.spec.whatwg.org/#list-sort-in-ascending-order">sort in ascending order</a></dfn>
             <dfn id="list-sort-descending"><a href="https://infra.spec.whatwg.org/#list-sort-in-descending-order">sort in descending order</a></dfn></li><li>The <dfn id="stack"><a href="https://infra.spec.whatwg.org/#stack">stack</a></dfn> data structure and the associated definitions for
             <dfn id="stack-push"><a href="https://infra.spec.whatwg.org/#stack-push">push</a></dfn> and
             <dfn id="stack-pop"><a href="https://infra.spec.whatwg.org/#stack-pop">pop</a></dfn></li><li>The <dfn id="queue"><a href="https://infra.spec.whatwg.org/#queue">queue</a></dfn> data structure and the associated definitions for
             <dfn id="enqueue"><a href="https://infra.spec.whatwg.org/#queue-enqueue">enqueue</a></dfn> and
             <dfn id="dequeue"><a href="https://infra.spec.whatwg.org/#queue-dequeue">dequeue</a></dfn></li><li>The <dfn id="set"><a href="https://infra.spec.whatwg.org/#ordered-set">ordered set</a></dfn> data structure and the associated definition for
             <dfn id="set-append"><a href="https://infra.spec.whatwg.org/#set-append">append</a></dfn> and
             <dfn id="set-union"><a href="https://infra.spec.whatwg.org/#set-union">union</a></dfn></li><li>The <dfn id="struct"><a href="https://infra.spec.whatwg.org/#struct">struct</a></dfn> specification type and the associated definition for
             <dfn id="struct-item"><a href="https://infra.spec.whatwg.org/#struct-item">item</a></dfn></li><li>The <dfn id="byte-sequence"><a href="https://infra.spec.whatwg.org/#byte-sequence">byte sequence</a></dfn> data structure</li><li>The <dfn id="forgiving-base64-encode"><a href="https://infra.spec.whatwg.org/#forgiving-base64-encode">forgiving-base64 encode</a></dfn> and
             <dfn id="forgiving-base64-decode"><a href="https://infra.spec.whatwg.org/#forgiving-base64-decode">forgiving-base64 decode</a></dfn> algorithms</li><li><dfn id="exclusive-range"><a href="https://infra.spec.whatwg.org/#the-exclusive-range">exclusive range</a></dfn></li><li><dfn id="parse-a-json-string-to-an-infra-value"><a href="https://infra.spec.whatwg.org/#parse-a-json-string-to-an-infra-value">parse a JSON string to an Infra value</a></dfn></li><li><dfn id="html-namespace-2"><a href="https://infra.spec.whatwg.org/#html-namespace">HTML namespace</a></dfn></li><li><dfn id="mathml-namespace"><a href="https://infra.spec.whatwg.org/#mathml-namespace">MathML namespace</a></dfn></li><li><dfn id="svg-namespace"><a href="https://infra.spec.whatwg.org/#svg-namespace">SVG namespace</a></dfn></li><li><dfn id="xlink-namespace"><a href="https://infra.spec.whatwg.org/#xlink-namespace">XLink namespace</a></dfn></li><li><dfn id="xml-namespace"><a href="https://infra.spec.whatwg.org/#xml-namespace">XML namespace</a></dfn></li><li><dfn id="xmlns-namespace"><a href="https://infra.spec.whatwg.org/#xmlns-namespace">XMLNS namespace</a></dfn></li></ul>
   </dd><dt>Unicode and Encoding</dt><dd>
    <p>The Unicode character set is used to represent textual data, and <cite>Encoding</cite>
    defines requirements around <a href="https://encoding.spec.whatwg.org/#encoding" id="dependencies:encoding" data-x-internal="encoding">character encodings</a>.
    <a href="#refsUNICODE">[UNICODE]</a></p>

    <p class="note">This specification <a href="#encoding-terminology">introduces terminology</a>
    based on the terms defined in those specifications, as described earlier.</p>

    <p>The following terms are used as defined in <cite>Encoding</cite>: <a href="#refsENCODING">[ENCODING]</a></p>

    <ul class="brief"><li><dfn id="getting-an-encoding"><a href="https://encoding.spec.whatwg.org/#concept-encoding-get">Getting an
     encoding</a></dfn></li><li><dfn id="get-an-output-encoding"><a href="https://encoding.spec.whatwg.org/#get-an-output-encoding">Get an output
     encoding</a></dfn></li><li>The generic <dfn id="decode"><a href="https://encoding.spec.whatwg.org/#decode">decode</a></dfn>
     algorithm which takes a byte stream and an encoding and returns a character stream</li><li>The <dfn id="utf-8-decode"><a href="https://encoding.spec.whatwg.org/#utf-8-decode">UTF-8 decode</a></dfn>
     algorithm which takes a byte stream and returns a character stream, additionally stripping one
     leading UTF-8 Byte Order Mark (BOM), if any</li><li>The <dfn id="utf-8-decode-without-bom"><a href="https://encoding.spec.whatwg.org/#utf-8-decode-without-bom">UTF-8
     decode without BOM</a></dfn> algorithm which is identical to <a id="dependencies:utf-8-decode" href="https://encoding.spec.whatwg.org/#utf-8-decode" data-x-internal="utf-8-decode">UTF-8 decode</a> except that
     it does not strip one leading UTF-8 Byte Order Mark (BOM)</li><li>The <dfn id="encode"><a href="https://encoding.spec.whatwg.org/#encode">encode</a></dfn> algorithm
     which takes a character stream and an encoding and returns a byte stream</li><li>The <dfn id="utf-8-encode"><a href="https://encoding.spec.whatwg.org/#utf-8-encode">UTF-8 encode</a></dfn>
     algorithm which takes a character stream and returns a byte stream</li><li>The <dfn id="bom-sniff"><a href="https://encoding.spec.whatwg.org/#bom-sniff">BOM sniff</a></dfn>
     algorithm which takes a byte stream and returns an encoding or null.</li></ul>
   </dd><dt>XML and related specifications</dt><dd>
    <p>Implementations that support <a href="#the-xhtml-syntax" id="dependencies:the-xhtml-syntax">the XML syntax</a> for HTML must support some version
    of XML, as well as its corresponding namespaces specification, because that syntax uses an XML
    serialization with namespaces. <a href="#refsXML">[XML]</a> <a href="#refsXMLNS">[XMLNS]</a></p>

    <p>Data mining tools and other user agents that perform operations on content without running
    scripts, evaluating CSS or XPath expressions, or otherwise exposing the resulting DOM to
    arbitrary content, may "support namespaces" by just asserting that their DOM node analogues are
    in certain namespaces, without actually exposing the namespace strings.</p>

    <p class="note">In <a href="#syntax" id="dependencies:syntax">the HTML syntax</a>, namespace prefixes and namespace declarations
    do not have the same effect as in XML. For instance, the colon has no special meaning in HTML
    element names.</p>

    <hr>

    <p>The attribute with the name <dfn id="attr-xml-space"><a href="https://www.w3.org/TR/xml/#sec-white-space"><code>space</code></a></dfn> in the <a id="dependencies:xml-namespace" href="https://infra.spec.whatwg.org/#xml-namespace" data-x-internal="xml-namespace">XML namespace</a> is defined by
    <cite>Extensible Markup Language</cite> (<cite>XML</cite>). <a href="#refsXML">[XML]</a></p>

    <p>The <dfn id="xml-name"><a href="https://www.w3.org/TR/xml/#NT-Name"><code>Name</code></a></dfn> production is defined in <cite>XML</cite>.
    <a href="#refsXML">[XML]</a></p>

    <p>This specification also references the <dfn id="xml-stylesheet"><a href="https://www.w3.org/TR/xml-stylesheet/#the-xml-stylesheet-processing-instruction"><code>&lt;?xml-stylesheet?&gt;</code></a></dfn>
    processing instruction, defined in <cite>Associating Style Sheets with XML documents</cite>.
    <a href="#refsXMLSSPI">[XMLSSPI]</a></p>

    <p>This specification also non-normatively mentions the <dfn id="xsltprocessor"><code>XSLTProcessor</code></dfn>
    interface and its <dfn id="dom-xsltprocessor-transformtofragment"><code>transformToFragment()</code></dfn> and <dfn id="dom-xsltprocessor-transformtodocument"><code>transformToDocument()</code></dfn> methods.
    <a href="#refsXSLTP">[XSLTP]</a></p>
   </dd><dt>URLs</dt><dd>
    <p>The following terms are defined in <cite>URL</cite>: <a href="#refsURL">[URL]</a></p>

    <ul class="brief"><li><dfn id="concept-host"><a href="https://url.spec.whatwg.org/#concept-host">host</a></dfn></li><li><dfn id="public-suffix"><a href="https://url.spec.whatwg.org/#host-public-suffix">public suffix</a></dfn></li><li><dfn id="concept-domain"><a href="https://url.spec.whatwg.org/#concept-domain">domain</a></dfn></li><li><dfn id="ip-address"><a href="https://url.spec.whatwg.org/#ip-address">IP address</a></dfn></li><li><dfn id="url"><a href="https://url.spec.whatwg.org/#concept-url">URL</a></dfn></li><li><dfn id="concept-url-origin"><a href="https://url.spec.whatwg.org/#concept-url-origin">Origin</a></dfn> of URLs</li><li><dfn id="absolute-url"><a href="https://url.spec.whatwg.org/#syntax-url-absolute">Absolute URL</a></dfn></li><li><dfn id="relative-url"><a href="https://url.spec.whatwg.org/#syntax-url-relative">Relative URL</a></dfn></li><li><dfn id="registrable-domain"><a href="https://url.spec.whatwg.org/#host-registrable-domain">registrable domain</a></dfn></li><li>The <dfn id="url-parser"><a href="https://url.spec.whatwg.org/#concept-url-parser">URL parser</a></dfn>
     </li><li data-var-scope="">The <dfn id="basic-url-parser"><a href="https://url.spec.whatwg.org/#concept-basic-url-parser">basic URL parser</a></dfn> and its
      <dfn id="basic-url-parser-url"><a href="https://url.spec.whatwg.org/#basic-url-parser-url"><var>url</var></a></dfn> and
      <dfn id="basic-url-parser-state-override"><a href="https://url.spec.whatwg.org/#basic-url-parser-state-override"><var>state override</var></a></dfn>
      arguments, as well as these parser states:
      <ul class="brief"><li><dfn id="scheme-start-state"><a href="https://url.spec.whatwg.org/#scheme-start-state">scheme start state</a></dfn></li><li><dfn id="host-state"><a href="https://url.spec.whatwg.org/#host-state">host state</a></dfn></li><li><dfn id="hostname-state"><a href="https://url.spec.whatwg.org/#hostname-state">hostname state</a></dfn></li><li><dfn id="port-state"><a href="https://url.spec.whatwg.org/#port-state">port state</a></dfn></li><li><dfn id="path-start-state"><a href="https://url.spec.whatwg.org/#path-start-state">path start state</a></dfn></li><li><dfn id="query-state"><a href="https://url.spec.whatwg.org/#query-state">query state</a></dfn></li><li><dfn id="fragment-state"><a href="https://url.spec.whatwg.org/#fragment-state">fragment state</a></dfn></li></ul>
     </li><li>
      <dfn id="url-record"><a href="https://url.spec.whatwg.org/#concept-url">URL record</a></dfn>, as well as its
      individual components:
      <ul class="brief"><li><dfn id="concept-url-scheme"><a href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></dfn></li><li><dfn id="concept-url-username"><a href="https://url.spec.whatwg.org/#concept-url-username">username</a></dfn></li><li><dfn id="concept-url-password"><a href="https://url.spec.whatwg.org/#concept-url-password">password</a></dfn></li><li><dfn id="concept-url-host"><a href="https://url.spec.whatwg.org/#concept-url-host">host</a></dfn></li><li><dfn id="concept-url-port"><a href="https://url.spec.whatwg.org/#concept-url-port">port</a></dfn></li><li><dfn id="concept-url-path"><a href="https://url.spec.whatwg.org/#concept-url-path">path</a></dfn></li><li><dfn id="concept-url-query"><a href="https://url.spec.whatwg.org/#concept-url-query">query</a></dfn></li><li><dfn id="concept-url-fragment"><a href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a></dfn></li><li><dfn id="concept-url-blob-entry"><a href="https://url.spec.whatwg.org/#concept-url-blob-entry">blob URL entry</a></dfn></li></ul>
     </li><li><dfn id="valid-url-string"><a href="https://url.spec.whatwg.org/#valid-url-string">valid URL string</a></dfn></li><li>The <dfn id="cannot-have-a-username/password/port"><a href="https://url.spec.whatwg.org/#cannot-have-a-username-password-port">cannot have a username/password/port</a></dfn> concept</li><li>The <dfn id="opaque-path"><a href="https://url.spec.whatwg.org/#url-opaque-path">opaque path</a></dfn> concept</li><li><dfn id="concept-url-serializer"><a href="https://url.spec.whatwg.org/#concept-url-serializer">URL serializer</a></dfn> and its
         <dfn id="url-serializer-exclude-fragment"><a href="https://url.spec.whatwg.org/#url-serializer-exclude-fragment">exclude fragment</a></dfn> argument</li><li><dfn id="url-path-serializer"><a href="https://url.spec.whatwg.org/#url-path-serializer">URL path serializer</a></dfn></li><li>The <dfn id="host-parser"><a href="https://url.spec.whatwg.org/#concept-host-parser">host parser</a></dfn></li><li>The <dfn id="host-serializer"><a href="https://url.spec.whatwg.org/#concept-host-serializer">host serializer</a></dfn></li><li><dfn id="host-equals"><a href="https://url.spec.whatwg.org/#concept-host-equals">Host equals</a></dfn></li><li><dfn id="concept-url-equals"><a href="https://url.spec.whatwg.org/#concept-url-equals">URL equals</a></dfn> and its
         <dfn id="url-equals-exclude-fragments"><a href="https://url.spec.whatwg.org/#url-equals-exclude-fragments">exclude fragments</a></dfn> argument</li><li><dfn id="serialize-an-integer"><a href="https://url.spec.whatwg.org/#serialize-an-integer">serialize an integer</a></dfn></li><li><dfn id="default-encode-set"><a href="https://url.spec.whatwg.org/#default-encode-set">Default encode set</a></dfn></li><li><dfn id="component-percent-encode-set"><a href="https://url.spec.whatwg.org/#component-percent-encode-set">component percent-encode set</a></dfn></li><li><dfn id="utf-8-percent-encode"><a href="https://url.spec.whatwg.org/#string-utf-8-percent-encode">UTF-8 percent-encode</a></dfn></li><li><dfn id="percent-decode"><a href="https://url.spec.whatwg.org/#string-percent-decode">percent-decode</a></dfn></li><li><dfn id="set-the-username"><a href="https://url.spec.whatwg.org/#set-the-username">set the username</a></dfn></li><li><dfn id="set-the-password"><a href="https://url.spec.whatwg.org/#set-the-password">set the password</a></dfn></li><li>The <dfn id="application/x-www-form-urlencoded"><a href="https://url.spec.whatwg.org/#concept-urlencoded"><code>application/x-www-form-urlencoded</code></a></dfn> format</li><li>The <dfn id="application/x-www-form-urlencoded-serializer"><a href="https://url.spec.whatwg.org/#concept-urlencoded-serializer"><code>application/x-www-form-urlencoded</code> serializer</a></dfn></li><li><dfn id="is-special"><a href="https://url.spec.whatwg.org/#is-special">is special</a></dfn></li></ul>

    <p>A number of schemes and protocols are referenced by this specification also:</p>

    <ul class="brief"><li>The <dfn id="about-protocol"><a href="https://www.rfc-editor.org/rfc/rfc6694#section-2"><code>about:</code></a></dfn> scheme
     <a href="#refsABOUT">[ABOUT]</a></li><li>The <dfn id="blob-protocol"><a href="https://w3c.github.io/FileAPI/#DefinitionOfScheme"><code>blob:</code></a></dfn> scheme
     <a href="#refsFILEAPI">[FILEAPI]</a></li><li>The <dfn id="data-protocol"><a href="https://www.rfc-editor.org/rfc/rfc2397#section-2"><code>data:</code></a></dfn> scheme
     <a href="#refsRFC2397">[RFC2397]</a></li><li>The <dfn id="http-protocol"><a href="https://httpwg.org/specs/rfc7230.html#http.uri"><code>http:</code></a></dfn> scheme
     <a href="#refsHTTP">[HTTP]</a></li><li>The <dfn id="https-protocol"><a href="https://httpwg.org/specs/rfc7230.html#https.uri"><code>https:</code></a></dfn> scheme
     <a href="#refsHTTP">[HTTP]</a></li><li>The <dfn id="mailto-protocol"><a href="https://www.rfc-editor.org/rfc/rfc6068#section-2"><code>mailto:</code></a></dfn>
     scheme <a href="#refsMAILTO">[MAILTO]</a></li><li>The <dfn id="sms-protocol"><a href="https://www.rfc-editor.org/rfc/rfc5724#section-2"><code>sms:</code></a></dfn> scheme
     <a href="#refsSMS">[SMS]</a></li><li>The <dfn id="urn-protocol"><a href="https://www.rfc-editor.org/rfc/rfc2141#section-2"><code>urn:</code></a></dfn> scheme
     <a href="#refsURN">[URN]</a></li></ul>

    <p><dfn id="media-fragment-syntax"><a href="https://www.w3.org/TR/media-frags/#media-fragment-syntax">Media fragment
    syntax</a></dfn> is defined in <cite>Media Fragments URI</cite>. <a href="#refsMEDIAFRAG">[MEDIAFRAG]</a></p>
   </dd><dt>URL Pattern</dt><dd>
    <p>The following terms are defined in <cite>URL Pattern</cite>: <a href="#refsURLPATTERN">[URLPATTERN]</a></p>

    <ul class="brief"><li><dfn id="url-pattern"><a href="https://urlpattern.spec.whatwg.org/#url-pattern">URL pattern</a></dfn></li><li><dfn id="url-pattern-match"><a href="https://urlpattern.spec.whatwg.org/#url-pattern-match">match</a></dfn></li><li><dfn id="build-a-url-pattern-from-an-infra-value"><a href="https://urlpattern.spec.whatwg.org/#build-a-url-pattern-from-an-infra-value">build a URL pattern from an Infra value</a></dfn></li><li><dfn id="parse-a-url-pattern-constructor-string"><a href="https://urlpattern.spec.whatwg.org/#parse-a-constructor-string">parse a URL pattern constructor string</a></dfn></li><li><dfn id="urlpatterninit"><a href="https://urlpattern.spec.whatwg.org/#dictdef-urlpatterninit"><code>URLPatternInit</code></a></dfn></li></ul>
   </dd><dt>HTTP and related specifications</dt><dd>
    <p>The following terms are defined in the HTTP specifications: <a href="#refsHTTP">[HTTP]</a></p>

    <ul class="brief"><li>`<dfn id="http-accept"><a href="https://httpwg.org/specs/rfc7231.html#header.accept"><code>Accept</code></a></dfn>` header</li><li>`<dfn id="http-accept-language"><a href="https://httpwg.org/specs/rfc7231.html#header.accept-language"><code>Accept-Language</code></a></dfn>` header</li><li>`<dfn id="http-cache-control"><a href="https://httpwg.org/specs/rfc7234.html#header.cache-control"><code>Cache-Control</code></a></dfn>` header</li><li>`<dfn id="http-content-disposition"><a href="https://httpwg.org/specs/rfc6266.html"><code>Content-Disposition</code></a></dfn>` header</li><li>`<dfn id="http-content-language"><a href="https://httpwg.org/specs/rfc7231.html#header.content-language"><code>Content-Language</code></a></dfn>` header</li><li>`<dfn id="http-content-range"><a href="https://httpwg.org/specs/rfc7233.html#header.content-range"><code>Content-Range</code></a></dfn>` header</li><li>`<dfn id="http-last-modified"><a href="https://httpwg.org/specs/rfc7232.html#header.last-modified"><code>Last-Modified</code></a></dfn>` header</li><li>`<dfn id="http-range"><a href="https://httpwg.org/specs/rfc7233.html#header.range"><code>Range</code></a></dfn>` header</li><li>`<dfn id="http-referer"><a href="https://httpwg.org/specs/rfc7231.html#header.referer"><code>Referer</code></a></dfn>` header</li></ul>

    <p>The following terms are defined in <cite>HTTP State Management Mechanism</cite>:
    <a href="#refsCOOKIES">[COOKIES]</a></p>

    <ul class="brief"><li><dfn id="cookie-string"><a href="https://httpwg.org/specs/rfc6265.html#sane-cookie-syntax">cookie-string</a></dfn></li><li><dfn id="receives-a-set-cookie-string"><a href="https://httpwg.org/specs/rfc6265.html#storage-model">receives a set-cookie-string</a></dfn></li><li>`<dfn id="http-cookie"><a href="https://httpwg.org/specs/rfc6265.html#cookie"><code>Cookie</code></a></dfn>` header</li></ul>

    <p>The following term is defined in <cite>Web Linking</cite>: <a href="#refsWEBLINK">[WEBLINK]</a></p>

    <ul class="brief"><li>`<dfn id="http-link"><a href="https://httpwg.org/specs/rfc8288.html#header"><code>Link</code></a></dfn>` header</li><li><dfn id="parsing-a-link-field-value"><a href="https://httpwg.org/specs/rfc8288.html#parse-fv">Parsing a `<code>Link</code>` field value</a></dfn></li></ul>

    <p>The following terms are defined in <cite>Structured Field Values for HTTP</cite>:
    <a href="#refsSTRUCTURED-FIELDS">[STRUCTURED-FIELDS]</a></p>

    <ul class="brief"><li><dfn id="http-structured-header"><a href="https://httpwg.org/specs/rfc8941.html">structured header</a></dfn></li><li><dfn id="http-structured-header-boolean"><a href="https://httpwg.org/specs/rfc8941.html#boolean">boolean</a></dfn></li><li><dfn id="http-structured-header-list"><a href="https://httpwg.org/specs/rfc8941.html#list">list</a></dfn></li><li><dfn id="http-structured-header-parameters"><a href="https://httpwg.org/specs/rfc8941.html#param">parameters</a></dfn></li><li><dfn id="http-structured-header-string"><a href="https://httpwg.org/specs/rfc8941.html#string">string</a></dfn></li><li><dfn id="http-structured-header-token"><a href="https://httpwg.org/specs/rfc8941.html#token">token</a></dfn></li></ul>

    <p>The following terms are defined in <cite>MIME Sniffing</cite>: <a href="#refsMIMESNIFF">[MIMESNIFF]</a></p>

    <ul class="brief"><li><dfn id="mime-type"><a href="https://mimesniff.spec.whatwg.org/#mime-type">MIME type</a></dfn></li><li><dfn id="mime-type-essence"><a href="https://mimesniff.spec.whatwg.org/#mime-type-essence">MIME type essence</a></dfn></li><li><dfn id="valid-mime-type-string"><a href="https://mimesniff.spec.whatwg.org/#valid-mime-type">valid MIME type string</a></dfn></li><li><dfn id="valid-mime-type-string-with-no-parameters"><a href="https://mimesniff.spec.whatwg.org/#valid-mime-type-with-no-parameters">valid MIME type string with no parameters</a></dfn></li><li><dfn id="html-mime-type"><a href="https://mimesniff.spec.whatwg.org/#html-mime-type">HTML MIME type</a></dfn></li><li><dfn id="javascript-mime-type"><a href="https://mimesniff.spec.whatwg.org/#javascript-mime-type">JavaScript MIME type</a></dfn> and
         <dfn id="javascript-mime-type-essence-match"><a href="https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match">JavaScript MIME type essence match</a></dfn></li><li><dfn id="json-mime-type"><a href="https://mimesniff.spec.whatwg.org/#json-mime-type">JSON MIME type</a></dfn></li><li><dfn id="xml-mime-type"><a href="https://mimesniff.spec.whatwg.org/#xml-mime-type">XML MIME type</a></dfn></li><li><dfn id="image-mime-type"><a href="https://mimesniff.spec.whatwg.org/#image-mime-type">image MIME type</a></dfn></li><li><dfn id="audio-or-video-mime-type"><a href="https://mimesniff.spec.whatwg.org/#audio-or-video-mime-type">audio or video MIME type</a></dfn></li><li><dfn id="font-mime-type"><a href="https://mimesniff.spec.whatwg.org/#font-mime-type">font MIME type</a></dfn></li><li><dfn id="parse-a-mime-type"><a href="https://mimesniff.spec.whatwg.org/#parse-a-mime-type">parse a MIME type</a></dfn></li><li><dfn id="is-mime-type-supported-by-the-user-agent"><a href="https://mimesniff.spec.whatwg.org/#supported-by-the-user-agent">is MIME type supported by the user agent?</a></dfn></li></ul>
   </dd><dt>Fetch</dt><dd>
    <p>The following terms are defined in <cite>Fetch</cite>: <a href="#refsFETCH">[FETCH]</a></p>

    <ul class="brief"><li><dfn id="header-abnf"><a href="https://fetch.spec.whatwg.org/#abnf">ABNF</a></dfn></li><li><dfn id="about:blank"><code>about:blank</code></dfn></li><li>`<dfn id="sec-purpose"><a href="https://fetch.spec.whatwg.org/#sec-purpose-header"><code>Sec-Purpose</code></a></dfn>`</li><li>An <dfn id="http(s)-scheme"><a href="https://fetch.spec.whatwg.org/#http-scheme">HTTP(S) scheme</a></dfn></li><li>A URL which <dfn id="is-local"><a href="https://fetch.spec.whatwg.org/#is-local">is local</a></dfn></li><li>A <dfn id="local-scheme"><a href="https://fetch.spec.whatwg.org/#local-scheme">local scheme</a></dfn></li><li>A <dfn id="fetch-scheme"><a href="https://fetch.spec.whatwg.org/#fetch-scheme">fetch scheme</a></dfn></li><li><dfn id="cors-protocol"><a href="https://fetch.spec.whatwg.org/#http-cors-protocol">CORS protocol</a></dfn></li><li><dfn id="environment-default-user-agent-value"><a href="https://fetch.spec.whatwg.org/#environment-default-user-agent-value">environment default `<code>User-Agent</code>` value</a></dfn></li><li><dfn id="extract-a-mime-type"><a href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type">extract a MIME type</a></dfn></li><li><dfn id="legacy-extract-an-encoding"><a href="https://fetch.spec.whatwg.org/#legacy-extract-an-encoding">legacy extract an encoding</a></dfn></li><li><dfn id="concept-fetch"><a href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a></dfn></li><li><dfn id="fetch-controller"><a href="https://fetch.spec.whatwg.org/#fetch-controller">fetch controller</a></dfn></li><li><dfn id="process-the-next-manual-redirect"><a href="https://fetch.spec.whatwg.org/#fetch-controller-process-the-next-manual-redirect">process the next manual redirect</a></dfn></li><li><dfn id="ok-status"><a href="https://fetch.spec.whatwg.org/#ok-status">ok status</a></dfn></li><li><dfn id="navigation-request"><a href="https://fetch.spec.whatwg.org/#navigation-request">navigation request</a></dfn></li><li><dfn id="network-error"><a href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a></dfn></li><li><dfn id="aborted-network-error"><a href="https://fetch.spec.whatwg.org/#concept-aborted-network-error">aborted network error</a></dfn></li><li>`<dfn id="http-origin"><a href="https://fetch.spec.whatwg.org/#http-origin"><code>Origin</code></a></dfn>` header</li><li>`<dfn id="cross-origin-resource-policy"><a href="https://fetch.spec.whatwg.org/#http-cross-origin-resource-policy"><code>Cross-Origin-Resource-Policy</code></a></dfn>` header</li><li><dfn id="getting-a-structured-field-value"><a href="https://fetch.spec.whatwg.org/#concept-header-list-get-structured-header">getting a structured field value</a></dfn></li><li><dfn id="concept-header-list"><a href="https://fetch.spec.whatwg.org/#concept-header-list">header list</a></dfn></li><li><dfn id="concept-header-list-set"><a href="https://fetch.spec.whatwg.org/#concept-header-list-set">set</a></dfn></li><li><dfn id="concept-header-list-get-decode-split"><a href="https://fetch.spec.whatwg.org/#concept-header-list-get-decode-split">get, decode, and split</a></dfn></li><li><dfn id="fetch-controller-abort"><a href="https://fetch.spec.whatwg.org/#fetch-controller-abort">abort</a></dfn></li><li><dfn id="cross-origin-resource-policy-check"><a href="https://fetch.spec.whatwg.org/#cross-origin-resource-policy-check">cross-origin resource policy check</a></dfn></li><li>the <dfn id="requestcredentials"><a href="https://fetch.spec.whatwg.org/#requestcredentials"><code>RequestCredentials</code></a></dfn> enumeration</li><li>the <dfn id="requestdestination"><a href="https://fetch.spec.whatwg.org/#requestdestination"><code>RequestDestination</code></a></dfn> enumeration</li><li>the <dfn id="fetch()"><a href="https://fetch.spec.whatwg.org/#dom-global-fetch"><code>fetch()</code></a></dfn> method</li><li><dfn id="report-timing"><a href="https://fetch.spec.whatwg.org/#finalize-and-report-timing">report timing</a></dfn></li><li><dfn id="serialize-a-response-url-for-reporting"><a href="https://fetch.spec.whatwg.org/#serialize-a-response-url-for-reporting">serialize a response URL for reporting</a></dfn></li><li><dfn id="body-safely-extract"><a href="https://fetch.spec.whatwg.org/#bodyinit-safely-extract">safely extracting a body</a></dfn></li><li><dfn id="body-incrementally-read"><a href="https://fetch.spec.whatwg.org/#body-incrementally-read">incrementally reading a body</a></dfn></li><li><dfn id="processresponseconsumebody"><a href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></dfn></li><li><dfn id="processresponseendofbody"><a href="https://fetch.spec.whatwg.org/#fetch-processresponseendofbody">processResponseEndOfBody</a></dfn></li><li><dfn id="processresponse"><a href="https://fetch.spec.whatwg.org/#process-response">processResponse</a></dfn></li><li><dfn id="useparallelqueue"><a href="https://fetch.spec.whatwg.org/#fetch-useparallelqueue">useParallelQueue</a></dfn></li><li><dfn id="processearlyhintsresponse"><a href="https://fetch.spec.whatwg.org/#fetch-processearlyhintsresponse">processEarlyHintsResponse</a></dfn></li><li><dfn id="connection-pool"><a href="https://fetch.spec.whatwg.org/#concept-connection-pool">connection pool</a></dfn></li><li><dfn id="obtain-a-connection"><a href="https://fetch.spec.whatwg.org/#concept-connection-obtain">obtain a connection</a></dfn></li><li><dfn id="determine-the-network-partition-key"><a href="https://fetch.spec.whatwg.org/#determine-the-network-partition-key">determine the network partition key</a></dfn></li><li><dfn id="extract-full-timing-info"><a href="https://fetch.spec.whatwg.org/#extract-full-timing-info">extract full timing info</a></dfn></li><li><dfn id="as-a-body"><a href="https://fetch.spec.whatwg.org/#byte-sequence-as-a-body">as a body</a></dfn></li><li><dfn id="response-body-info"><a href="https://fetch.spec.whatwg.org/#response-body-info">response body info</a></dfn></li><li><dfn id="resolve-an-origin"><a href="https://fetch.spec.whatwg.org/#resolve-an-origin">resolve an origin</a></dfn></li><li><dfn id="credentials"><a href="https://fetch.spec.whatwg.org/#credentials">credentials</a></dfn></li><li><dfn id="reserve-deferred-fetch-quota"><a href="https://fetch.spec.whatwg.org/#reserve-deferred-fetch-quota">reserve deferred fetch quota</a></dfn></li><li><dfn id="potentially-free-deferred-fetch-quota"><a href="https://fetch.spec.whatwg.org/#reserve-deferred-fetch-quota">potentially free deferred fetch quota</a></dfn></li><li><dfn id="is-offline"><a href="https://fetch.spec.whatwg.org/#is-offline">is offline</a></dfn></li><li>
      <dfn id="concept-response"><a href="https://fetch.spec.whatwg.org/#concept-response">response</a></dfn> and its
      associated:
      <ul class="brief"><li><dfn id="concept-response-type"><a href="https://fetch.spec.whatwg.org/#concept-response-type">type</a></dfn></li><li><dfn id="concept-response-url"><a href="https://fetch.spec.whatwg.org/#concept-response-url">URL</a></dfn></li><li><dfn id="concept-response-url-list"><a href="https://fetch.spec.whatwg.org/#concept-response-url-list">URL list</a></dfn></li><li><dfn id="concept-response-status"><a href="https://fetch.spec.whatwg.org/#concept-response-status">status</a></dfn></li><li><dfn id="concept-response-header-list"><a href="https://fetch.spec.whatwg.org/#concept-response-header-list">header list</a></dfn></li><li><dfn id="concept-response-body"><a href="https://fetch.spec.whatwg.org/#concept-response-body">body</a></dfn></li><li><dfn id="concept-response-body-info"><a href="https://fetch.spec.whatwg.org/#concept-response-body-info">body info</a></dfn></li><li><dfn id="concept-internal-response"><a href="https://fetch.spec.whatwg.org/#concept-internal-response">internal response</a></dfn></li><li><dfn id="concept-response-location-url"><a href="https://fetch.spec.whatwg.org/#concept-response-location-url">location URL</a></dfn></li><li><dfn id="concept-response-timing-info"><a href="https://fetch.spec.whatwg.org/#concept-response-timing-info">timing info</a></dfn></li><li><dfn id="concept-response-service-worker-timing-info"><a href="https://fetch.spec.whatwg.org/#response-service-worker-timing-info">service worker timing info</a></dfn></li><li><dfn id="concept-response-has-cross-origin-redirects"><a href="https://fetch.spec.whatwg.org/#response-has-cross-origin-redirects">has-cross-origin-redirects</a></dfn></li><li><dfn id="concept-response-timing-allow-passed"><a href="https://fetch.spec.whatwg.org/#concept-response-timing-allow-passed">timing allow passed</a></dfn></li><li>
        <dfn id="extract-content-range-values"><a href="https://wicg.github.io/background-fetch/#extract-content-range-values">extract content-range values</a></dfn>
        
       </li></ul>
     </li><li>
      <dfn id="concept-request"><a href="https://fetch.spec.whatwg.org/#concept-request">request</a></dfn> and its associated:
      <ul class="brief"><li><dfn id="concept-request-url"><a href="https://fetch.spec.whatwg.org/#concept-request-url">URL</a></dfn></li><li><dfn id="concept-request-method"><a href="https://fetch.spec.whatwg.org/#concept-request-method">method</a></dfn></li><li><dfn id="concept-request-header-list"><a href="https://fetch.spec.whatwg.org/#concept-request-header-list">header list</a></dfn></li><li><dfn id="concept-request-body"><a href="https://fetch.spec.whatwg.org/#concept-request-body">body</a></dfn></li><li><dfn id="concept-request-client"><a href="https://fetch.spec.whatwg.org/#concept-request-client">client</a></dfn></li><li><dfn id="concept-request-url-list"><a href="https://fetch.spec.whatwg.org/#concept-request-url-list">URL list</a></dfn></li><li><dfn id="concept-request-current-url"><a href="https://fetch.spec.whatwg.org/#concept-request-current-url">current URL</a></dfn></li><li><dfn id="concept-request-reserved-client"><a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client">reserved client</a></dfn></li><li><dfn id="concept-request-replaces-client-id"><a href="https://fetch.spec.whatwg.org/#concept-request-replaces-client-id">replaces client id</a></dfn></li><li><dfn id="concept-request-initiator"><a href="https://fetch.spec.whatwg.org/#concept-request-initiator">initiator</a></dfn></li><li><dfn id="concept-request-destination"><a href="https://fetch.spec.whatwg.org/#concept-request-destination">destination</a></dfn></li><li><dfn id="concept-potential-destination"><a href="https://fetch.spec.whatwg.org/#concept-potential-destination">potential destination</a></dfn></li><li><dfn id="concept-potential-destination-translate"><a href="https://fetch.spec.whatwg.org/#concept-potential-destination-translate">translating</a></dfn> a <a href="https://fetch.spec.whatwg.org/#concept-potential-destination" id="dependencies:concept-potential-destination" data-x-internal="concept-potential-destination">potential destination</a></li><li><dfn id="concept-script-like-destination"><a href="https://fetch.spec.whatwg.org/#request-destination-script-like">script-like</a></dfn> <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="dependencies:concept-request-destination" data-x-internal="concept-request-destination">destinations</a></li><li><dfn id="concept-request-priority"><a href="https://fetch.spec.whatwg.org/#request-priority">priority</a></dfn></li><li><dfn id="concept-request-origin"><a href="https://fetch.spec.whatwg.org/#concept-request-origin">origin</a></dfn></li><li><dfn id="concept-request-referrer"><a href="https://fetch.spec.whatwg.org/#concept-request-referrer">referrer</a></dfn></li><li><dfn id="synchronous-flag"><a href="https://fetch.spec.whatwg.org/#synchronous-flag">synchronous flag</a></dfn></li><li><dfn id="concept-request-mode"><a href="https://fetch.spec.whatwg.org/#concept-request-mode">mode</a></dfn></li><li><dfn id="concept-request-credentials-mode"><a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode">credentials mode</a></dfn></li><li><dfn id="use-url-credentials-flag"><a href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag">use-URL-credentials flag</a></dfn></li><li><dfn id="unsafe-request-flag"><a href="https://fetch.spec.whatwg.org/#unsafe-request-flag">unsafe-request flag</a></dfn></li><li><dfn id="concept-request-cache-mode"><a href="https://fetch.spec.whatwg.org/#concept-request-cache-mode">cache mode</a></dfn></li><li><dfn id="concept-request-redirect-count"><a href="https://fetch.spec.whatwg.org/#concept-request-redirect-count">redirect count</a></dfn></li><li><dfn id="concept-request-redirect-mode"><a href="https://fetch.spec.whatwg.org/#concept-request-redirect-mode">redirect mode</a></dfn></li><li><dfn id="concept-request-policy-container"><a href="https://fetch.spec.whatwg.org/#concept-request-policy-container">policy container</a></dfn></li><li><dfn id="concept-request-referrer-policy"><a href="https://fetch.spec.whatwg.org/#concept-request-referrer-policy">referrer policy</a></dfn></li><li><dfn id="concept-request-nonce-metadata"><a href="https://fetch.spec.whatwg.org/#concept-request-nonce-metadata">cryptographic nonce metadata</a></dfn></li><li><dfn id="concept-request-integrity-metadata"><a href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata">integrity metadata</a></dfn></li><li><dfn id="concept-request-parser-metadata"><a href="https://fetch.spec.whatwg.org/#concept-request-parser-metadata">parser metadata</a></dfn></li><li><dfn id="concept-request-reload-navigation-flag"><a href="https://fetch.spec.whatwg.org/#concept-request-reload-navigation-flag">reload-navigation flag</a></dfn></li><li><dfn id="concept-request-history-navigation-flag"><a href="https://fetch.spec.whatwg.org/#concept-request-history-navigation-flag">history-navigation flag</a></dfn></li><li><dfn id="concept-request-user-activation"><a href="https://fetch.spec.whatwg.org/#request-user-activation">user-activation</a></dfn></li><li><dfn id="concept-request-render-blocking"><a href="https://fetch.spec.whatwg.org/#request-render-blocking">render-blocking</a></dfn></li><li><dfn id="concept-request-initiator-type"><a href="https://fetch.spec.whatwg.org/#request-initiator-type">initiator type</a></dfn></li><li><dfn id="concept-request-service-workers-mode"><a href="https://fetch.spec.whatwg.org/#request-service-workers-mode">service-workers mode</a></dfn></li><li><dfn id="concept-request-traversable-for-user-prompts"><a href="https://fetch.spec.whatwg.org/#concept-request-window">traversable for user prompts</a></dfn></li><li><dfn id="top-level-navigation-initiator-origin"><a href="https://fetch.spec.whatwg.org/#request-top-level-navigation-initiator-origin">top-level navigation initiator origin</a></dfn></li><li><dfn id="add-a-range-header"><a href="https://fetch.spec.whatwg.org/#concept-request-add-range-header">add a range header</a></dfn></li><li><dfn id="destination-type"><a href="https://fetch.spec.whatwg.org/#destination-type">destination type</a></dfn></li></ul>
     </li><li>
      <dfn id="fetch-timing-info"><a href="https://fetch.spec.whatwg.org/#fetch-timing-info">fetch timing info</a></dfn> and its
      associated:
      <ul class="brief"><li><dfn id="fetch-timing-info-start-time"><a href="https://fetch.spec.whatwg.org/#fetch-timing-info-start-time">start time</a></dfn></li><li><dfn id="fetch-timing-info-end-time"><a href="https://fetch.spec.whatwg.org/#fetch-timing-info-end-time">end time</a></dfn></li></ul>
     </li></ul>

    <p>The following terms are defined in <cite>Referrer Policy</cite>:
    <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p>

    <ul class="brief"><li><dfn id="referrer-policy"><a href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy">referrer policy</a></dfn></li><li>The `<dfn id="http-referrer-policy"><a href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-header-dfn"><code>Referrer-Policy</code></a></dfn>` HTTP header</li><li>The <dfn id="parse-referrer-policy-header"><a href="https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header">parse a referrer policy from a `<code>Referrer-Policy</code>` header</a></dfn> algorithm</li><li>The "<dfn id="referrer-policy-no-referrer"><a href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer"><code>no-referrer</code></a></dfn>",
             "<dfn id="referrer-policy-no-referrer-when-downgrade"><a href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer-when-downgrade"><code>no-referrer-when-downgrade</code></a></dfn>",
             "<dfn id="referrer-policy-origin-when-cross-origin"><a href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-origin-when-cross-origin"><code>origin-when-cross-origin</code></a></dfn>", and
             "<dfn id="referrer-policy-unsafe-url"><a href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-unsafe-url"><code>unsafe-url</code></a></dfn>" referrer policies</li><li>The <dfn id="default-referrer-policy"><a href="https://w3c.github.io/webappsec-referrer-policy/#default-referrer-policy">default referrer policy</a></dfn></li></ul>

    <p>The following terms are defined in <cite>Mixed Content</cite>: <a href="#refsMIX">[MIX]</a></p>

    <ul class="brief"><li><dfn id="a-priori-authenticated-url"><a href="https://w3c.github.io/webappsec-mixed-content/#a-priori-authenticated-url"><i>a priori</i> authenticated URL</a></dfn></li></ul>

    <p>The following terms are defined in <cite>Subresource Integrity</cite>: <a href="#refsSRI">[SRI]</a></p>

    <ul class="brief"><li><dfn id="parse-integrity-metadata"><a href="https://w3c.github.io/webappsec-subresource-integrity/#parse-metadata">parse integrity metadata</a></dfn></li><li><dfn id="the-requirements-of-the-integrity-attribute"><a href="https://w3c.github.io/webappsec-subresource-integrity/#the-integrity-attribute">the requirements of the integrity attribute</a></dfn></li><li><dfn id="get-the-strongest-metadata-from-set"><a href="https://w3c.github.io/webappsec-subresource-integrity/#get-the-strongest-metadata">get the strongest metadata from set</a></dfn></li><li><dfn id="integrity-policy"><a href="https://w3c.github.io/webappsec-subresource-integrity/#integrity-policy">integrity policy</a></dfn></li><li><dfn id="parse-integrity-policy-headers"><a href="https://w3c.github.io/webappsec-subresource-integrity/#parse-integrity-policy-headers">parse Integrity-Policy headers</a></dfn></li></ul>
   </dd><dt>The No-Vary-Search HTTP Response Header Field</dt><dd>
    <p>The following terms are defined in <cite>The No-Vary-Search HTTP Response Header
    Field</cite>: <a href="#refsNOVARYSEARCH">[NOVARYSEARCH]</a></p>

    <ul class="brief"><li>`<dfn id="no-vary-search"><a href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-http-header-field-definitio"><code>No-Vary-Search</code></a></dfn>`</li><li><dfn id="parse-a-url-search-variance"><a href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#parse-a-url-search-variance">parse a URL search variance</a></dfn></li><li><dfn id="url-search-variance"><a href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-data-model">URL search variance</a></dfn></li><li><dfn id="default-url-search-variance"><a href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-data-model">default URL search variance</a></dfn></li><li><dfn id="equivalent-modulo-search-variance"><a href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-comparing">equivalent modulo search variance</a></dfn></li></ul>
   </dd><dt>Paint Timing</dt><dd>
    <p>The following terms are defined in <cite>Paint Timing</cite>: <a href="#refsPAINTTIMING">[PAINTTIMING]</a></p>

    <ul class="brief"><li><dfn id="mark-paint-timing"><a href="https://w3c.github.io/paint-timing/#mark-paint-timing">mark paint timing</a></dfn></li></ul>
   </dd><dt>Navigation Timing</dt><dd>
    <p>The following terms are defined in <cite>Navigation Timing</cite>:
    <a href="#refsNAVIGATIONTIMING">[NAVIGATIONTIMING]</a></p>

    <ul class="brief"><li><dfn id="create-the-navigation-timing-entry"><a href="https://w3c.github.io/navigation-timing/#dfn-create-the-navigation-timing-entry">create the navigation timing entry</a></dfn></li><li><dfn id="queue-the-navigation-timing-entry"><a href="https://w3c.github.io/navigation-timing/#dfn-queue-the-navigation-timing-entry">queue the navigation timing entry</a></dfn></li><li><dfn id="navigationtimingtype"><a href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype"><code>NavigationTimingType</code></a></dfn> and its
         "<dfn id="dom-navigationtimingtype-navigate"><a href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype-navigate"><code>navigate</code></a></dfn>",
         "<dfn id="dom-navigationtimingtype-reload"><a href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype-reload"><code>reload</code></a></dfn>", and
         "<dfn id="dom-navigationtimingtype-back_forward"><a href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype-back_forward"><code>back_forward</code></a></dfn>" values.</li></ul>
   </dd><dt>Resource Timing</dt><dd>
    <p>The following terms are defined in <cite>Resource Timing</cite>:
    <a href="#refsRESOURCETIMING">[RESOURCETIMING]</a></p>

    <ul class="brief"><li><dfn id="mark-resource-timing"><a href="https://w3c.github.io/resource-timing/#dfn-mark-resource-timing">Mark resource timing</a></dfn></li></ul>

   </dd><dt>Performance Timeline</dt><dd>
    <p>The following terms are defined in <cite>Performance Timeline</cite>:
    <a href="#refsPERFORMANCETIMELINE">[PERFORMANCETIMELINE]</a></p>

    <ul class="brief"><li><dfn id="performanceentry"><a href="https://w3c.github.io/performance-timeline/#dom-performanceentry"><code>PerformanceEntry</code></a></dfn> and its
         <dfn id="performanceentry-name"><a href="https://w3c.github.io/performance-timeline/#dom-performanceentry-name"><code>name</code></a></dfn>,
         <dfn id="performanceentry-entrytype"><a href="https://w3c.github.io/performance-timeline/#dom-performanceentry-entrytype"><code>entryType</code></a></dfn>,
         <dfn id="performanceentry-starttime"><a href="https://w3c.github.io/performance-timeline/#dom-performanceentry-starttime"><code>startTime</code></a></dfn>, and
         <dfn id="performanceentry-duration"><a href="https://w3c.github.io/performance-timeline/#dom-performanceentry-duration"><code>duration</code></a></dfn> attributes.</li><li><dfn id="queue-a-performance-entry"><a href="https://w3c.github.io/performance-timeline/#queue-a-performanceentry">Queue a performance entry</a></dfn></li></ul>
   </dd><dt>Long Animation Frames</dt><dd>
    <p>The following terms are defined in <cite>Long Animation Frames</cite>: <a href="#refsLONGANIMATIONFRAMES">[LONGANIMATIONFRAMES]</a></p>

    <ul class="brief"><li><dfn id="record-task-start-time"><a href="https://w3c.github.io/long-animation-frames/#record-task-start-time">record task start time</a></dfn></li><li><dfn id="record-task-end-time"><a href="https://w3c.github.io/long-animation-frames/#record-task-end-time">record task end time</a></dfn></li><li><dfn id="record-rendering-time"><a href="https://w3c.github.io/long-animation-frames/#record-rendering-time">record rendering time</a></dfn></li><li><dfn id="record-classic-script-creation-time"><a href="https://w3c.github.io/long-animation-frames/#record-classic-script-creation-time">record classic script creation time</a></dfn></li><li><dfn id="record-classic-script-execution-start-time"><a href="https://w3c.github.io/long-animation-frames/#record-classic-script-execution-start-time">record classic script execution start time</a></dfn></li><li><dfn id="record-module-script-execution-start-time"><a href="https://w3c.github.io/long-animation-frames/#record-module-script-execution-start-time">record module script execution start time</a></dfn></li><li><dfn id="record-pause-duration"><a href="https://w3c.github.io/long-animation-frames/#record-pause-duration">Record pause duration</a></dfn></li><li><dfn id="record-timing-info-for-timer-handler"><a href="https://w3c.github.io/long-animation-frames/#record-timing-info-for-timer-handler">record timing info for timer handler</a></dfn></li><li><dfn id="record-timing-info-for-microtask-checkpoint"><a href="https://w3c.github.io/long-animation-frames/#record-timing-info-for-microtask-checkpoint">record timing info for microtask checkpoint</a></dfn></li></ul>
   </dd><dt>Long Tasks</dt><dd>
    <p>The following terms are defined in <cite>Long Tasks</cite>: <a href="#refsLONGTASKS">[LONGTASKS]</a></p>

    <ul class="brief"><li><dfn id="report-long-tasks"><a href="https://w3c.github.io/longtasks/#report-long-tasks">report long tasks</a></dfn></li></ul>
   </dd><dt>Web IDL</dt><dd>
    <p>The IDL fragments in this specification must be interpreted as required for conforming IDL
    fragments, as described in <cite>Web IDL</cite>. <a href="#refsWEBIDL">[WEBIDL]</a></p>

    <p>The following terms are defined in <cite>Web IDL</cite>:</p>

    <ul class="brief"><li><dfn id="this"><a href="https://webidl.spec.whatwg.org/#this">this</a></dfn></li><li><dfn id="extended-attribute"><a href="https://webidl.spec.whatwg.org/#dfn-extended-attribute">extended attribute</a></dfn></li><li><dfn id="named-constructor"><a href="https://webidl.spec.whatwg.org/#dfn-named-constructor">named constructor</a></dfn></li><li><dfn id="constructor-operation"><a href="https://webidl.spec.whatwg.org/#idl-constructors">constructor operation</a></dfn></li><li><dfn id="overridden-constructor-steps"><a href="https://webidl.spec.whatwg.org/#overridden-constructor-steps">overridden constructor steps</a></dfn></li><li><dfn id="internally-create-a-new-object-implementing-the-interface"><a href="https://webidl.spec.whatwg.org/#internally-create-a-new-object-implementing-the-interface">internally create a new object implementing the interface</a></dfn></li><li><dfn id="array-index-property-name"><a href="https://webidl.spec.whatwg.org/#dfn-array-index-property-name">array index property name</a></dfn></li><li><dfn id="buffer-source-byte-length"><a href="https://webidl.spec.whatwg.org/#buffersource-byte-length">buffer source byte length</a></dfn></li><li><dfn id="supports-indexed-properties"><a href="https://webidl.spec.whatwg.org/#dfn-support-indexed-properties">supports indexed properties</a></dfn></li><li><dfn id="supported-property-indices"><a href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices">supported property indices</a></dfn></li><li><dfn id="determine-the-value-of-an-indexed-property"><a href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-an-indexed-property">determine the value of an indexed property</a></dfn></li><li><dfn id="set-the-value-of-an-existing-indexed-property"><a href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-an-existing-indexed-property">set the value of an existing indexed property</a></dfn></li><li><dfn id="set-the-value-of-a-new-indexed-property"><a href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-a-new-indexed-property">set the value of a new indexed property</a></dfn></li><li><dfn id="support-named-properties"><a href="https://webidl.spec.whatwg.org/#dfn-support-named-properties">support named properties</a></dfn></li><li><dfn id="supported-property-names"><a href="https://webidl.spec.whatwg.org/#dfn-supported-property-names">supported property names</a></dfn></li><li><dfn id="determine-the-value-of-a-named-property"><a href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-a-named-property">determine the value of a named property</a></dfn></li><li><dfn id="set-the-value-of-an-existing-named-property"><a href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-an-existing-named-property">set the value of an existing named property</a></dfn></li><li><dfn id="set-the-value-of-a-new-named-property"><a href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-a-new-named-property">set the value of a new named property</a></dfn></li><li><dfn id="delete-an-existing-named-property"><a href="https://webidl.spec.whatwg.org/#dfn-delete-an-existing-named-property">delete an existing named property</a></dfn></li><li><dfn id="perform-a-security-check"><a href="https://webidl.spec.whatwg.org/#dfn-perform-a-security-check">perform a security check</a></dfn></li><li><dfn id="platform-object"><a href="https://webidl.spec.whatwg.org/#dfn-platform-object">platform object</a></dfn></li><li><dfn id="legacy-platform-object"><a href="https://webidl.spec.whatwg.org/#dfn-legacy-platform-object">legacy platform object</a></dfn></li><li><dfn id="primary-interface"><a href="https://webidl.spec.whatwg.org/#dfn-primary-interface">primary interface</a></dfn></li><li><dfn id="interface-object"><a href="https://webidl.spec.whatwg.org/#dfn-interface-object">interface object</a></dfn></li><li><dfn id="named-properties-object"><a href="https://webidl.spec.whatwg.org/#dfn-named-properties-object">named properties object</a></dfn></li><li><dfn id="include"><a href="https://webidl.spec.whatwg.org/#include">include</a></dfn></li><li><dfn id="inherit"><a href="https://webidl.spec.whatwg.org/#dfn-inherit">inherit</a></dfn></li><li><dfn id="interface-prototype-object"><a href="https://webidl.spec.whatwg.org/#dfn-interface-prototype-object">interface prototype object</a></dfn></li><li><dfn id="implements"><a href="https://webidl.spec.whatwg.org/#implements">implements</a></dfn></li><li><dfn id="associated-realm"><a href="https://webidl.spec.whatwg.org/#dfn-associated-realm">associated realm</a></dfn></li><li><dfn id="realm-field-of-a-platform-object"><a href="https://webidl.spec.whatwg.org/#es-platform-objects">[[Realm]] field of a platform object</a></dfn></li><li><dfn id="named-properties-object-getownproperty"><a href="https://webidl.spec.whatwg.org/#named-properties-object-getownproperty">[[GetOwnProperty]] internal method of a named properties object</a></dfn></li><li><dfn id="callback-context"><a href="https://webidl.spec.whatwg.org/#dfn-callback-context">callback context</a></dfn></li><li><dfn id="frozen-array"><a href="https://webidl.spec.whatwg.org/#dfn-frozen-array-type">frozen array</a></dfn> and
         <dfn id="creating-a-frozen-array"><a href="https://webidl.spec.whatwg.org/#dfn-create-frozen-array">creating a frozen array</a></dfn></li><li><dfn id="new"><a href="https://webidl.spec.whatwg.org/#new">create a new object implementing the interface</a></dfn></li><li><dfn id="dfn-callback-this-value"><a href="https://webidl.spec.whatwg.org/#dfn-callback-this-value">callback this value</a></dfn></li><li><dfn id="concept-idl-convert"><a href="https://webidl.spec.whatwg.org/#es-type-mapping">converting</a></dfn> between Web IDL types and JS types</li><li><dfn id="es-invoking-callback-functions"><a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function">invoking</a></dfn> and
         <dfn id="es-constructing-callback-functions"><a href="https://webidl.spec.whatwg.org/#construct-a-callback-function">constructing</a></dfn> callback functions</li><li><dfn id="overload-resolution-algorithm"><a href="https://webidl.spec.whatwg.org/#dfn-overload-resolution-algorithm">overload resolution algorithm</a></dfn></li><li><dfn id="idl-exposed"><a href="https://webidl.spec.whatwg.org/#dfn-exposed">exposed</a></dfn></li><li><dfn id="a-promise-resolved-with"><a href="https://webidl.spec.whatwg.org/#a-promise-resolved-with">a promise resolved with</a></dfn></li><li><dfn id="a-promise-rejected-with"><a href="https://webidl.spec.whatwg.org/#a-promise-rejected-with">a promise rejected with</a></dfn></li><li><dfn id="wait-for-all"><a href="https://webidl.spec.whatwg.org/#wait-for-all">wait for all</a></dfn></li><li><dfn id="upon-rejection"><a href="https://webidl.spec.whatwg.org/#upon-rejection">upon rejection</a></dfn></li><li><dfn id="upon-fulfillment"><a href="https://webidl.spec.whatwg.org/#upon-fulfillment">upon fulfillment</a></dfn></li><li><dfn id="mark-as-handled"><a href="https://webidl.spec.whatwg.org/#mark-a-promise-as-handled">mark as handled</a></dfn></li><li><dfn id="global"><a href="https://webidl.spec.whatwg.org/#Global"><code>[Global]</code></a></dfn></li><li><dfn id="legacyfactoryfunction"><a href="https://webidl.spec.whatwg.org/#LegacyFactoryFunction"><code>[LegacyFactoryFunction]</code></a></dfn></li><li><dfn id="legacylenientthis"><a href="https://webidl.spec.whatwg.org/#LegacyLenientThis"><code>[LegacyLenientThis]</code></a></dfn></li><li><dfn id="legacynulltoemptystring"><a href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString"><code>[LegacyNullToEmptyString]</code></a></dfn></li><li><dfn id="legacyoverridebuiltins"><a href="https://webidl.spec.whatwg.org/#LegacyOverrideBuiltIns"><code>[LegacyOverrideBuiltIns]</code></a></dfn></li><li><dfn id="legacyplatformobjectgetownproperty"><a href="https://webidl.spec.whatwg.org/#LegacyPlatformObjectGetOwnProperty">LegacyPlatformObjectGetOwnProperty</a></dfn></li><li><dfn id="legacytreatnonobjectasnull"><a href="https://webidl.spec.whatwg.org/#LegacyTreatNonObjectAsNull"><code>[LegacyTreatNonObjectAsNull]</code></a></dfn></li><li><dfn id="legacyunenumerablenamedproperties"><a href="https://webidl.spec.whatwg.org/#LegacyUnenumerableNamedProperties"><code>[LegacyUnenumerableNamedProperties]</code></a></dfn></li><li><dfn id="legacyunforgeable"><a href="https://webidl.spec.whatwg.org/#LegacyUnforgeable"><code>[LegacyUnforgeable]</code></a></dfn></li><li><dfn id="set-entries"><a href="https://webidl.spec.whatwg.org/#dfn-set-entries">set entries</a></dfn></li></ul>

    <p><cite>Web IDL</cite> also defines the following types that are used in this specification:</p>

    <ul class="brief"><li><dfn id="idl-arraybuffer"><a href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer"><code>ArrayBuffer</code></a></dfn></li><li><dfn id="idl-arraybufferview"><a href="https://webidl.spec.whatwg.org/#common-ArrayBufferView"><code>ArrayBufferView</code></a></dfn></li><li><dfn id="idl-boolean"><a href="https://webidl.spec.whatwg.org/#idl-boolean"><code>boolean</code></a></dfn></li><li><dfn id="idl-domstring"><a href="https://webidl.spec.whatwg.org/#idl-DOMString"><code>DOMString</code></a></dfn></li><li><dfn id="idl-double"><a href="https://webidl.spec.whatwg.org/#idl-double"><code>double</code></a></dfn></li><li><dfn id="idl-enumeration"><a href="https://webidl.spec.whatwg.org/#idl-enums">enumeration</a></dfn></li><li><dfn id="idl-float16array"><a href="https://webidl.spec.whatwg.org/#idl-Float16Array"><code>Float16Array</code></a></dfn></li><li><dfn id="idl-function"><a href="https://webidl.spec.whatwg.org/#common-Function"><code>Function</code></a></dfn></li><li><dfn id="idl-long"><a href="https://webidl.spec.whatwg.org/#idl-long"><code>long</code></a></dfn></li><li><dfn id="idl-object"><a href="https://webidl.spec.whatwg.org/#idl-object"><code>object</code></a></dfn></li><li><dfn id="idl-promise"><a href="https://webidl.spec.whatwg.org/#idl-promise"><code>Promise</code></a></dfn></li><li><dfn id="idl-uint8clampedarray"><a href="https://webidl.spec.whatwg.org/#idl-Uint8ClampedArray"><code>Uint8ClampedArray</code></a></dfn></li><li><dfn id="idl-unrestricted-double"><a href="https://webidl.spec.whatwg.org/#idl-unrestricted-double"><code>unrestricted double</code></a></dfn></li><li><dfn id="idl-unsigned-long"><a href="https://webidl.spec.whatwg.org/#idl-unsigned-long"><code>unsigned long</code></a></dfn></li><li><dfn id="idl-usvstring"><a href="https://webidl.spec.whatwg.org/#idl-USVString"><code>USVString</code></a></dfn></li><li><dfn id="idl-voidfunction"><a href="https://webidl.spec.whatwg.org/#VoidFunction"><code>VoidFunction</code></a></dfn></li><li><dfn id="quotaexceedederror"><a href="https://webidl.spec.whatwg.org/#quotaexceedederror"><code>QuotaExceededError</code></a></dfn></li></ul>

    <p>The term <dfn id="throw"><a href="https://webidl.spec.whatwg.org/#dfn-throw">throw</a></dfn> in this
    specification is used as defined in <cite>Web IDL</cite>. The <dfn id="domexception"><a href="https://webidl.spec.whatwg.org/#dfn-DOMException"><code>DOMException</code></a></dfn>
    type and the following exception names are defined by Web IDL and used by this
    specification:</p>

    <ul class="brief"><li><dfn id="indexsizeerror"><a href="https://webidl.spec.whatwg.org/#indexsizeerror">"<code>IndexSizeError</code>"</a></dfn></li><li><dfn id="hierarchyrequesterror"><a href="https://webidl.spec.whatwg.org/#hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a></dfn></li><li><dfn id="invalidcharactererror"><a href="https://webidl.spec.whatwg.org/#invalidcharactererror">"<code>InvalidCharacterError</code>"</a></dfn></li><li><dfn id="nomodificationallowederror"><a href="https://webidl.spec.whatwg.org/#nomodificationallowederror">"<code>NoModificationAllowedError</code>"</a></dfn></li><li><dfn id="notfounderror"><a href="https://webidl.spec.whatwg.org/#notfounderror">"<code>NotFoundError</code>"</a></dfn></li><li><dfn id="notsupportederror"><a href="https://webidl.spec.whatwg.org/#notsupportederror">"<code>NotSupportedError</code>"</a></dfn></li><li><dfn id="invalidstateerror"><a href="https://webidl.spec.whatwg.org/#invalidstateerror">"<code>InvalidStateError</code>"</a></dfn></li><li><dfn id="syntaxerror"><a href="https://webidl.spec.whatwg.org/#syntaxerror">"<code>SyntaxError</code>"</a></dfn></li><li><dfn id="invalidaccesserror"><a href="https://webidl.spec.whatwg.org/#invalidaccesserror">"<code>InvalidAccessError</code>"</a></dfn></li><li><dfn id="securityerror"><a href="https://webidl.spec.whatwg.org/#securityerror">"<code>SecurityError</code>"</a></dfn></li><li><dfn id="networkerror"><a href="https://webidl.spec.whatwg.org/#networkerror">"<code>NetworkError</code>"</a></dfn></li><li><dfn id="aborterror"><a href="https://webidl.spec.whatwg.org/#aborterror">"<code>AbortError</code>"</a></dfn></li><li><dfn id="datacloneerror"><a href="https://webidl.spec.whatwg.org/#datacloneerror">"<code>DataCloneError</code>"</a></dfn></li><li><dfn id="encodingerror"><a href="https://webidl.spec.whatwg.org/#encodingerror">"<code>EncodingError</code>"</a></dfn></li><li><dfn id="notallowederror"><a href="https://webidl.spec.whatwg.org/#notallowederror">"<code>NotAllowedError</code>"</a></dfn></li></ul>

    <p>When this specification requires a user agent to <dfn id="create-a-date-object">create a <code>Date</code> object</dfn>
    representing a particular time (which could be the special value Not-a-Number), the milliseconds
    component of that time, if any, must be truncated to an integer, and the time value of the newly
    created <code id="dependencies:date"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object must represent the resulting truncated time.</p>

    <p class="example">For instance, given the time 23045 millionths of a second after 01:00 UTC on
    January 1st 2000, i.e. the time 2000-01-01T00:00:00.023045Z, then the <code id="dependencies:date-2"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object
    created representing that time would represent the same time as that created representing the
    time 2000-01-01T00:00:00.023Z, 45 millionths earlier. If the given time is NaN, then the result
    is a <code id="dependencies:date-3"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object that represents a time value NaN (indicating that the object does
    not represent a specific instant of time).</p>
   </dd><dt>JavaScript</dt><dd>
    <p>Some parts of the language described by this specification only support JavaScript as the
    underlying scripting language. <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

    <p class="note">The term "JavaScript" is used to refer to ECMA-262, rather than the official
    term ECMAScript, since the term JavaScript is more widely known.</p>

    <p>The following terms are defined in the JavaScript specification and used in this
    specification:</p>

    <ul class="brief"><li><dfn id="active-function-object"><a href="https://tc39.es/ecma262/#active-function-object">active function object</a></dfn></li><li><dfn id="agent"><a href="https://tc39.es/ecma262/#sec-agents">agent</a></dfn> and
         <dfn id="agent-cluster"><a href="https://tc39.es/ecma262/#sec-agent-clusters">agent cluster</a></dfn></li><li><dfn id="automatic-semicolon-insertion"><a href="https://tc39.es/ecma262/#sec-automatic-semicolon-insertion">automatic semicolon insertion</a></dfn></li><li><dfn id="candidate-execution"><a href="https://tc39.es/ecma262/#sec-candidate-executions">candidate execution</a></dfn></li><li>The <dfn id="current-realm"><a href="https://tc39.es/ecma262/#current-realm">current realm</a></dfn></li><li><dfn id="clamping"><a href="https://tc39.es/ecma262/#clamping">clamping</a></dfn> a mathematical value</li><li><dfn id="early-error"><a href="https://tc39.es/ecma262/#early-error-rule">early error</a></dfn></li><li><dfn id="forward-progress"><a href="https://tc39.es/ecma262/#sec-forward-progress">forward progress</a></dfn></li><li><dfn id="invariants-of-the-essential-internal-methods"><a href="https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods">invariants of the essential internal methods</a></dfn></li><li><dfn id="javascript-execution-context"><a href="https://tc39.es/ecma262/#sec-execution-contexts">JavaScript execution context</a></dfn></li><li><dfn id="javascript-execution-context-stack"><a href="https://tc39.es/ecma262/#execution-context-stack">JavaScript execution context stack</a></dfn></li><li><dfn id="realm"><a href="https://tc39.es/ecma262/#sec-code-realms">realm</a></dfn></li><li><dfn id="jobcallback-record"><a href="https://tc39.es/ecma262/#sec-jobcallback-records">JobCallback Record</a></dfn></li><li><dfn id="newtarget"><a href="https://tc39.es/ecma262/#sec-built-in-function-objects">NewTarget</a></dfn></li><li><dfn id="running-javascript-execution-context"><a href="https://tc39.es/ecma262/#running-execution-context">running JavaScript execution context</a></dfn></li><li><dfn id="surrounding-agent"><a href="https://tc39.es/ecma262/#surrounding-agent">surrounding agent</a></dfn></li><li><dfn id="abstract-closure"><a href="https://tc39.es/ecma262/#sec-abstract-closure">abstract closure</a></dfn></li><li><dfn id="immutable-prototype-exotic-object"><a href="https://tc39.es/ecma262/#immutable-prototype-exotic-object">immutable prototype exotic object</a></dfn></li><li><dfn id="well-known-symbols"><a href="https://tc39.es/ecma262/#sec-well-known-symbols">Well-Known Symbols</a></dfn>, including
         <dfn id="symbol.hasinstance">%Symbol.hasInstance%</dfn>,
         <dfn id="symbol.isconcatspreadable">%Symbol.isConcatSpreadable%</dfn>,
         <dfn id="symbol.toprimitive">%Symbol.toPrimitive%</dfn>, and
         <dfn id="symbol.tostringtag">%Symbol.toStringTag%</dfn></li><li><dfn id="well-known-intrinsic-objects"><a href="https://tc39.es/ecma262/#sec-well-known-intrinsic-objects">Well-Known Intrinsic Objects</a></dfn>, including
         <dfn id="array.prototype"><a href="https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object">%Array.prototype%</a></dfn>,
         <dfn id="error.prototype"><a href="https://tc39.es/ecma262/#sec-properties-of-the-error-prototype-object">%Error.prototype%</a></dfn>,
         <dfn id="evalerror.prototype">%EvalError.prototype%</dfn>,
         <dfn id="function.prototype"><a href="https://tc39.es/ecma262/#sec-properties-of-the-function-prototype-object">%Function.prototype%</a></dfn>,
         <dfn id="object.prototype"><a href="https://tc39.es/ecma262/#sec-properties-of-the-object-prototype-object">%Object.prototype%</a></dfn>,
         <dfn id="object.prototype.valueof"><a href="https://tc39.es/ecma262/#sec-object.prototype.valueof">%Object.prototype.valueOf%</a></dfn>,
         <dfn id="rangeerror.prototype">%RangeError.prototype%</dfn>,
         <dfn id="referenceerror.prototype">%ReferenceError.prototype%</dfn>,
         <dfn id="syntaxerror.prototype">%SyntaxError.prototype%</dfn>,
         <dfn id="typeerror.prototype">%TypeError.prototype%</dfn>, and
         <dfn id="urierror.prototype">%URIError.prototype%</dfn></li><li>The <dfn id="js-prod-functionbody"><a href="https://tc39.es/ecma262/#prod-FunctionBody"><i>FunctionBody</i></a></dfn> production</li><li>The <dfn id="js-prod-module"><a href="https://tc39.es/ecma262/#prod-Module"><i>Module</i></a></dfn> production</li><li>The <dfn id="js-prod-pattern"><a href="https://tc39.es/ecma262/#prod-Pattern"><i>Pattern</i></a></dfn> production</li><li>The <dfn id="js-prod-script"><a href="https://tc39.es/ecma262/#prod-Script"><i>Script</i></a></dfn> production</li><li>The
     <dfn id="js-bigint"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-bigint-type">BigInt</a></dfn>,
     <dfn id="js-boolean"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-boolean-type">Boolean</a></dfn>,
     <dfn id="js-number"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type">Number</a></dfn>,
     <dfn id="js-string"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">String</a></dfn>,
     <dfn id="js-symbol"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-symbol-type">Symbol</a></dfn>,
     and <dfn id="js-object"><a href="https://tc39.es/ecma262/#sec-object-type">Object</a></dfn> ECMAScript language types</li><li>The <dfn id="completion-record"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">Completion Record</a></dfn> specification type</li><li>The <dfn id="js-list"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></dfn> and
             <dfn id="record"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></dfn> specification types</li><li>The <dfn id="propertydescriptor"><a href="https://tc39.es/ecma262/#sec-property-descriptor-specification-type">Property Descriptor</a></dfn> specification type</li><li>The <dfn id="modulerequest-record"><a href="https://tc39.es/ecma262/#modulerequest-record">ModuleRequest Record</a></dfn> specification type</li><li>The <dfn id="script-record"><a href="https://tc39.es/ecma262/#sec-script-records">Script Record</a></dfn> specification type</li><li>The <dfn id="synthetic-module-record"><a href="https://tc39.es/ecma262/#sec-synthetic-module-records">Synthetic Module Record</a></dfn> specification type</li><li>The <dfn id="cyclic-module-record"><a href="https://tc39.es/ecma262/#sec-cyclic-module-records">Cyclic Module Record</a></dfn> specification type</li><li>The <dfn id="source-text-module-record"><a href="https://tc39.es/ecma262/#sec-source-text-module-records">Source Text Module Record</a></dfn> specification type and its
             <dfn id="js-evaluate"><a href="https://tc39.es/ecma262/#sec-moduleevaluation">Evaluate</a></dfn>,
             <dfn id="js-link"><a href="https://tc39.es/ecma262/#sec-moduledeclarationlinking">Link</a></dfn> and
             <dfn id="js-loadrequestedmodules"><a href="https://tc39.es/ecma262/#sec-LoadRequestedModules">LoadRequestedModules</a></dfn> methods</li><li>The <dfn id="arraycreate"><a href="https://tc39.es/ecma262/#sec-arraycreate">ArrayCreate</a></dfn> abstract operation</li><li>The <dfn id="call"><a href="https://tc39.es/ecma262/#sec-call">Call</a></dfn> abstract operation</li><li>The <dfn id="clearkeptobjects"><a href="https://tc39.es/ecma262/#sec-clear-kept-objects">ClearKeptObjects</a></dfn> abstract operation</li><li>The <dfn id="cleanupfinalizationregistry"><a href="https://tc39.es/ecma262/#sec-cleanup-finalization-registry">CleanupFinalizationRegistry</a></dfn> abstract operation</li><li>The <dfn id="construct"><a href="https://tc39.es/ecma262/#sec-construct">Construct</a></dfn> abstract operation</li><li>The <dfn id="copydatablockbytes"><a href="https://tc39.es/ecma262/#sec-copydatablockbytes">CopyDataBlockBytes</a></dfn> abstract operation</li><li>The <dfn id="createbuiltinfunction"><a href="https://tc39.es/ecma262/#sec-createbuiltinfunction">CreateBuiltinFunction</a></dfn> abstract operation</li><li>The <dfn id="createbytedatablock"><a href="https://tc39.es/ecma262/#sec-createbytedatablock">CreateByteDataBlock</a></dfn> abstract operation</li><li>The <dfn id="createdataproperty"><a href="https://tc39.es/ecma262/#sec-createdataproperty">CreateDataProperty</a></dfn> abstract operation</li><li>The <dfn id="createdefaultexportsyntheticmodule"><a href="https://tc39.es/ecma262/#sec-create-default-export-synthetic-module">CreateDefaultExportSyntheticModule</a></dfn> abstract operation</li><li>The <dfn id="definepropertyorthrow"><a href="https://tc39.es/ecma262/#sec-definepropertyorthrow">DefinePropertyOrThrow</a></dfn> abstract operation</li><li>The <dfn id="detacharraybuffer"><a href="https://tc39.es/ecma262/#sec-detacharraybuffer">DetachArrayBuffer</a></dfn> abstract operation</li><li>The <dfn id="enumerableownproperties"><a href="https://tc39.es/ecma262/#sec-enumerableownproperties">EnumerableOwnProperties</a></dfn> abstract operation</li><li>The <dfn id="finishloadingimportedmodule"><a href="https://tc39.es/ecma262/#sec-FinishLoadingImportedModule">FinishLoadingImportedModule</a></dfn> abstract operation</li><li>The <dfn id="js-ordinaryfunctioncreate"><a href="https://tc39.es/ecma262/#sec-ordinaryfunctioncreate">OrdinaryFunctionCreate</a></dfn> abstract operation</li><li>The <dfn id="js-get"><a href="https://tc39.es/ecma262/#sec-get-o-p">Get</a></dfn> abstract operation</li><li>The <dfn id="getactivescriptormodule"><a href="https://tc39.es/ecma262/#sec-getactivescriptormodule">GetActiveScriptOrModule</a></dfn> abstract operation</li><li>The <dfn id="getfunctionrealm"><a href="https://tc39.es/ecma262/#sec-getfunctionrealm">GetFunctionRealm</a></dfn> abstract operation</li><li>The <dfn id="hasownproperty"><a href="https://tc39.es/ecma262/#sec-hasownproperty">HasOwnProperty</a></dfn> abstract operation</li><li>The <dfn id="js-hostcalljobcallback"><a href="https://tc39.es/ecma262/#sec-hostcalljobcallback">HostCallJobCallback</a></dfn> abstract operation</li><li>The <dfn id="js-hostenqueuefinalizationregistrycleanupjob"><a href="https://tc39.es/ecma262/#sec-host-cleanup-finalization-registry">HostEnqueueFinalizationRegistryCleanupJob</a></dfn> abstract operation</li><li>The <dfn id="js-hostenqueuegenericjob"><a href="https://tc39.es/ecma262/#sec-hostenqueuegenericjob">HostEnqueueGenericJob</a></dfn> abstract operation</li><li>The <dfn id="js-hostenqueuepromisejob"><a href="https://tc39.es/ecma262/#sec-hostenqueuepromisejob">HostEnqueuePromiseJob</a></dfn> abstract operation</li><li>The <dfn id="js-hostenqueuetimeoutjob"><a href="https://tc39.es/ecma262/#sec-hostenqueuetimeoutjob">HostEnqueueTimeoutJob</a></dfn> abstract operation</li><li>The <dfn id="js-hostensurecanaddprivateelement"><a href="https://tc39.es/ecma262/#sec-hostensurecanaddprivateelement">HostEnsureCanAddPrivateElement</a></dfn> abstract operation</li><li>The <dfn id="js-hostgetsupportedimportattributes"><a href="https://tc39.es/ecma262/#sec-hostgetsupportedimportattributes">HostGetSupportedImportAttributes</a></dfn> abstract operation</li><li>The <dfn id="js-hostloadimportedmodule"><a href="https://tc39.es/ecma262/#sec-HostLoadImportedModule">HostLoadImportedModule</a></dfn> abstract operation</li><li>The <dfn id="js-hostmakejobcallback"><a href="https://tc39.es/ecma262/#sec-hostmakejobcallback">HostMakeJobCallback</a></dfn> abstract operation</li><li>The <dfn id="js-hostpromiserejectiontracker"><a href="https://tc39.es/ecma262/#sec-host-promise-rejection-tracker">HostPromiseRejectionTracker</a></dfn> abstract operation</li><li>The <dfn id="js-initializehostdefinedrealm"><a href="https://tc39.es/ecma262/#sec-initializehostdefinedrealm">InitializeHostDefinedRealm</a></dfn> abstract operation</li><li>The <dfn id="isarraybufferviewoutofbounds"><a href="https://tc39.es/ecma262/#sec-isarraybufferviewoutofbounds">IsArrayBufferViewOutOfBounds</a></dfn> abstract operation</li><li>The <dfn id="isaccessordescriptor"><a href="https://tc39.es/ecma262/#sec-isaccessordescriptor">IsAccessorDescriptor</a></dfn> abstract operation</li><li>The <dfn id="iscallable"><a href="https://tc39.es/ecma262/#sec-iscallable">IsCallable</a></dfn> abstract operation</li><li>The <dfn id="isconstructor"><a href="https://tc39.es/ecma262/#sec-isconstructor">IsConstructor</a></dfn> abstract operation</li><li>The <dfn id="isdatadescriptor"><a href="https://tc39.es/ecma262/#sec-isdatadescriptor">IsDataDescriptor</a></dfn> abstract operation</li><li>The <dfn id="isdetachedbuffer"><a href="https://tc39.es/ecma262/#sec-isdetachedbuffer">IsDetachedBuffer</a></dfn> abstract operation</li><li>The <dfn id="issharedarraybuffer"><a href="https://tc39.es/ecma262/#sec-issharedarraybuffer">IsSharedArrayBuffer</a></dfn> abstract operation</li><li>The <dfn id="js-newobjectenvironment"><a href="https://tc39.es/ecma262/#sec-newobjectenvironment">NewObjectEnvironment</a></dfn> abstract operation</li><li>The <dfn id="normalcompletion"><a href="https://tc39.es/ecma262/#sec-normalcompletion">NormalCompletion</a></dfn> abstract operation</li><li>The <dfn id="ordinarygetprototypeof"><a href="https://tc39.es/ecma262/#sec-ordinarygetprototypeof">OrdinaryGetPrototypeOf</a></dfn> abstract operation</li><li>The <dfn id="ordinarysetprototypeof"><a href="https://tc39.es/ecma262/#sec-ordinarysetprototypeof">OrdinarySetPrototypeOf</a></dfn> abstract operation</li><li>The <dfn id="ordinaryisextensible"><a href="https://tc39.es/ecma262/#sec-ordinaryisextensible">OrdinaryIsExtensible</a></dfn> abstract operation</li><li>The <dfn id="ordinarypreventextensions"><a href="https://tc39.es/ecma262/#sec-ordinarypreventextensions">OrdinaryPreventExtensions</a></dfn> abstract operation</li><li>The <dfn id="ordinarygetownproperty"><a href="https://tc39.es/ecma262/#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a></dfn> abstract operation</li><li>The <dfn id="ordinarydefineownproperty"><a href="https://tc39.es/ecma262/#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a></dfn> abstract operation</li><li>The <dfn id="ordinaryget"><a href="https://tc39.es/ecma262/#sec-ordinaryget">OrdinaryGet</a></dfn> abstract operation</li><li>The <dfn id="ordinaryset"><a href="https://tc39.es/ecma262/#sec-ordinaryset">OrdinarySet</a></dfn> abstract operation</li><li>The <dfn id="ordinarydelete"><a href="https://tc39.es/ecma262/#sec-ordinarydelete">OrdinaryDelete</a></dfn> abstract operation</li><li>The <dfn id="ordinaryownpropertykeys"><a href="https://tc39.es/ecma262/#sec-ordinaryownpropertykeys">OrdinaryOwnPropertyKeys</a></dfn> abstract operation</li><li>The <dfn id="ordinaryobjectcreate"><a href="https://tc39.es/ecma262/#sec-objectcreate">OrdinaryObjectCreate</a></dfn> abstract operation</li><li>The <dfn id="parsejsonmodule"><a href="https://tc39.es/ecma262/#sec-parse-json-module">ParseJSONModule</a></dfn> abstract operation</li><li>The <dfn id="js-parsemodule"><a href="https://tc39.es/ecma262/#sec-parsemodule">ParseModule</a></dfn> abstract operation</li><li>The <dfn id="js-parsescript"><a href="https://tc39.es/ecma262/#sec-parse-script">ParseScript</a></dfn> abstract operation</li><li>The <dfn id="newpromisereactionjob"><a href="https://tc39.es/ecma262/#sec-newpromisereactionjob">NewPromiseReactionJob</a></dfn> abstract operation</li><li>The <dfn id="newpromiseresolvethenablejob"><a href="https://tc39.es/ecma262/#sec-newpromiseresolvethenablejob">NewPromiseResolveThenableJob</a></dfn> abstract operation</li><li>The <dfn id="regexpbuiltinexec"><a href="https://tc39.es/ecma262/#sec-regexpbuiltinexec">RegExpBuiltinExec</a></dfn> abstract operation</li><li>The <dfn id="regexpcreate"><a href="https://tc39.es/ecma262/#sec-regexpcreate">RegExpCreate</a></dfn> abstract operation</li><li>The <dfn id="runjobs"><a href="https://tc39.es/ecma262/#sec-runjobs">RunJobs</a></dfn> abstract operation</li><li>The <dfn id="samevalue"><a href="https://tc39.es/ecma262/#sec-samevalue">SameValue</a></dfn> abstract operation</li><li>The <dfn id="js-scriptevaluation"><a href="https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation">ScriptEvaluation</a></dfn> abstract operation</li><li>The <dfn id="setsyntheticmoduleexport"><a href="https://tc39.es/ecma262/#sec-setsyntheticmoduleexport">SetSyntheticModuleExport</a></dfn> abstract operation</li><li>The <dfn id="setimmutableprototype"><a href="https://tc39.es/ecma262/#sec-set-immutable-prototype">SetImmutablePrototype</a></dfn> abstract operation</li><li>The <dfn id="throwcompletion"><a href="https://tc39.es/ecma262/#sec-throwcompletion">ThrowCompletion</a></dfn> abstract operation</li><li>The <dfn id="js-toboolean"><a href="https://tc39.es/ecma262/#sec-toboolean">ToBoolean</a></dfn> abstract operation</li><li>The <dfn id="tostring"><a href="https://tc39.es/ecma262/#sec-tostring">ToString</a></dfn> abstract operation</li><li>The <dfn id="touint32"><a href="https://tc39.es/ecma262/#sec-touint32">ToUint32</a></dfn> abstract operation</li><li>The <dfn id="typedarraycreate"><a href="https://tc39.es/ecma262/#typedarray-create">TypedArrayCreate</a></dfn> abstract operation</li><li>The <dfn id="js-abstract-equality"><a href="https://tc39.es/ecma262/#sec-islooselyequal">IsLooselyEqual</a></dfn> abstract operation</li><li>The <dfn id="js-strict-equality"><a href="https://tc39.es/ecma262/#sec-isstrictlyequal">IsStrictlyEqual</a></dfn> abstract operation</li><li>The <dfn id="atomics"><a href="https://tc39.es/ecma262/#sec-atomics-object"><code>Atomics</code></a></dfn> object</li><li>The <dfn id="atomics.waitasync"><a href="https://tc39.es/ecma262/#sec-atomics.waitasync"><code>Atomics.waitAsync</code></a></dfn> object</li><li>The <dfn id="date"><a href="https://tc39.es/ecma262/#sec-date-objects"><code>Date</code></a></dfn> class</li><li>The <dfn id="finalizationregistry"><a href="https://tc39.es/ecma262/#sec-finalization-registry-objects"><code>FinalizationRegistry</code></a></dfn> class</li><li>The <dfn id="regexp"><a href="https://tc39.es/ecma262/#sec-regexp-regular-expression-objects"><code>RegExp</code></a></dfn> class</li><li>The <dfn id="sharedarraybuffer"><a href="https://tc39.es/ecma262/#sec-sharedarraybuffer-objects"><code>SharedArrayBuffer</code></a></dfn> class</li><li>The <dfn id="syntaxerror-2"><a href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-syntaxerror"><code>SyntaxError</code></a></dfn> class</li><li>The <dfn id="typeerror"><a href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror"><code>TypeError</code></a></dfn> class</li><li>The <dfn id="js-rangeerror"><a href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror"><code>RangeError</code></a></dfn> class</li><li>The <dfn id="weakref"><a href="https://tc39.es/ecma262/#sec-weak-ref-objects"><code>WeakRef</code></a></dfn> class</li><li>The <dfn id="eval()"><a href="https://tc39.es/ecma262/#sec-eval-x"><code>eval()</code></a></dfn> function</li><li>The <dfn id="weakref.prototype.deref()"><a href="https://tc39.es/ecma262/#sec-weak-ref.prototype.deref"><code>WeakRef.prototype.deref()</code></a></dfn> function</li><li>The <dfn id="ishtmldda"><a href="https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot">[[IsHTMLDDA]]</a></dfn> internal slot</li><li><dfn id="import()"><a href="https://tc39.es/ecma262/#sec-import-calls"><code>import()</code></a></dfn></li><li><dfn id="import.meta"><a href="https://tc39.es/ecma262/#sec-meta-properties"><code>import.meta</code></a></dfn></li><li>The <dfn id="js-hostgetimportmetaproperties"><a href="https://tc39.es/ecma262/#sec-hostgetimportmetaproperties">HostGetImportMetaProperties</a></dfn> abstract operation</li><li>The <dfn id="js-typeof"><a href="https://tc39.es/ecma262/#sec-typeof-operator"><code>typeof</code></a></dfn> operator</li><li>The <dfn id="delete"><a href="https://tc39.es/ecma262/#sec-delete-operator"><code>delete</code></a></dfn> operator</li><li><dfn id="the-typedarray-constructors"><a href="https://tc39.es/ecma262/#table-49">The <var>TypedArray</var> Constructors</a></dfn> table</li></ul>

    <p>User agents that support JavaScript must also implement the <cite>Dynamic Code Brand
    Checks</cite> proposal. The following terms are defined there, and used in this specification:
    <a href="#refsJSDYNAMICCODEBRANDCHECKS">[JSDYNAMICCODEBRANDCHECKS]</a></p>

    <ul class="brief"><li>The <dfn id="js-hostensurecancompilestrings"><a href="https://tc39.es/proposal-dynamic-code-brand-checks/#sec-hostensurecancompilestrings">HostEnsureCanCompileStrings</a></dfn> abstract operation</li><li>The <dfn id="js-hostgetcodeforeval"><a href="https://tc39.es/proposal-dynamic-code-brand-checks/#sec-hostgetcodeforeval">HostGetCodeForEval</a></dfn> abstract operation</li></ul>

    <p>User agents that support JavaScript must also implement <cite>ECMAScript
    Internationalization API</cite>. <a href="#refsJSINTL">[JSINTL]</a></p>

    <p>User agents that support JavaScript must also implement the <cite>Temporal</cite> proposal.
    The following terms are defined there, and used in this specification: <a href="#refsJSTEMPORAL">[JSTEMPORAL]</a></p>

    <ul class="brief"><li>The <dfn id="js-hostsystemutcepochnanoseconds"><a href="https://tc39.es/proposal-temporal/#sec-hostsystemutcepochnanoseconds">HostSystemUTCEpochNanoseconds</a></dfn> abstract operation</li><li>The <dfn id="nsmaxinstant"><a href="https://tc39.es/proposal-temporal/#eqn-nsMaxInstant">nsMaxInstant</a></dfn> and
         <dfn id="nsmininstant"><a href="https://tc39.es/proposal-temporal/#eqn-nsMinInstant">nsMinInstant</a></dfn> values</li></ul>
   </dd><dt>WebAssembly</dt><dd>
    <p>The following term is defined in <cite>WebAssembly JavaScript Interface</cite>:
    <a href="#refsWASMJS">[WASMJS]</a></p>

    <ul class="brief"><li><dfn id="webassembly.module"><a href="https://webassembly.github.io/spec/js-api/#module"><code>WebAssembly.Module</code></a></dfn></li></ul>
   </dd><dt>DOM</dt><dd>
    <p>The Document Object Model (DOM) is a representation — a model — of a document and
    its content. The DOM is not just an API; the conformance criteria of HTML implementations are
    defined, in this specification, in terms of operations on the DOM. <a href="#refsDOM">[DOM]</a></p>

    <p>Implementations must support DOM and the events defined in UI Events, because this
    specification is defined in terms of the DOM, and some of the features are defined as extensions
    to the DOM interfaces. <a href="#refsDOM">[DOM]</a> <a href="#refsUIEVENTS">[UIEVENTS]</a></p>

    <p>In particular, the following features are defined in <cite>DOM</cite>: <a href="#refsDOM">[DOM]</a></p>

    <ul class="brief"><li><dfn id="attr"><a href="https://dom.spec.whatwg.org/#interface-attr"><code>Attr</code></a></dfn> interface</li><li><dfn id="characterdata"><a href="https://dom.spec.whatwg.org/#interface-characterdata"><code>CharacterData</code></a></dfn> interface</li><li><dfn id="comment-2"><a href="https://dom.spec.whatwg.org/#interface-comment"><code>Comment</code></a></dfn> interface</li><li><dfn id="domimplementation"><a href="https://dom.spec.whatwg.org/#interface-domimplementation"><code>DOMImplementation</code></a></dfn> interface</li><li><dfn id="dom-document"><a href="https://dom.spec.whatwg.org/#interface-document"><code>Document</code></a></dfn> interface and its
         <dfn id="dom-document-doctype"><a href="https://dom.spec.whatwg.org/#dom-document-doctype"><code>doctype</code></a></dfn> attribute
     </li><li><dfn id="dom-documentorshadowroot"><a href="https://dom.spec.whatwg.org/#documentorshadowroot"><code>DocumentOrShadowRoot</code></a></dfn> interface</li><li><dfn id="documentfragment"><a href="https://dom.spec.whatwg.org/#interface-documentfragment"><code>DocumentFragment</code></a></dfn> interface</li><li><dfn id="documenttype"><a href="https://dom.spec.whatwg.org/#interface-documenttype"><code>DocumentType</code></a></dfn> interface</li><li><dfn id="childnode"><a href="https://dom.spec.whatwg.org/#interface-childnode"><code>ChildNode</code></a></dfn> interface</li><li><dfn id="element"><a href="https://dom.spec.whatwg.org/#interface-element"><code>Element</code></a></dfn> interface</li><li><dfn id="dom-element-attachshadow"><a href="https://dom.spec.whatwg.org/#dom-element-attachshadow"><code>attachShadow()</code></a></dfn> method.</li><li>An element's <dfn id="concept-element-shadow-root"><a href="https://dom.spec.whatwg.org/#concept-element-shadow-root">shadow root</a></dfn></li><li>A <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="dependencies:concept-element-shadow-root" data-x-internal="concept-element-shadow-root">shadow root</a>'s <dfn id="concept-shadow-root-mode"><a href="https://dom.spec.whatwg.org/#shadowroot-mode">mode</a></dfn></li><li>A <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="dependencies:concept-element-shadow-root-2" data-x-internal="concept-element-shadow-root">shadow root</a>'s <dfn id="concept-shadow-root-declarative"><a href="https://dom.spec.whatwg.org/#shadowroot-declarative">declarative</a></dfn> member</li><li>The <dfn id="concept-attach-a-shadow-root"><a href="https://dom.spec.whatwg.org/#concept-attach-a-shadow-root">attach a shadow root</a></dfn> algorithm</li><li>The <dfn id="dom-retarget"><a href="https://dom.spec.whatwg.org/#retarget">retargeting algorithm</a></dfn></li><li><dfn id="node"><a href="https://dom.spec.whatwg.org/#interface-node"><code>Node</code></a></dfn> interface</li><li><dfn id="nodelist"><a href="https://dom.spec.whatwg.org/#interface-nodelist"><code>NodeList</code></a></dfn> interface</li><li><dfn id="processinginstruction"><a href="https://dom.spec.whatwg.org/#interface-processinginstruction"><code>ProcessingInstruction</code></a></dfn> interface</li><li><dfn id="shadowroot"><a href="https://dom.spec.whatwg.org/#interface-shadowroot"><code>ShadowRoot</code></a></dfn> interface</li><li><dfn id="text"><a href="https://dom.spec.whatwg.org/#interface-text"><code>Text</code></a></dfn> interface</li><li><dfn id="range"><a href="https://dom.spec.whatwg.org/#interface-range"><code>Range</code></a></dfn> interface</li><li><dfn id="node-document"><a href="https://dom.spec.whatwg.org/#concept-node-document">node document</a></dfn> concept</li><li><dfn id="concept-document-type"><a href="https://dom.spec.whatwg.org/#concept-document-type">document type</a></dfn> concept</li><li><dfn id="concept-documentfragment-host"><a href="https://dom.spec.whatwg.org/#concept-documentfragment-host">host</a></dfn> concept</li><li>The <dfn id="shadow-root"><a href="https://dom.spec.whatwg.org/#concept-shadow-root">shadow root</a></dfn> concept, and its <dfn id="delegates-focus"><a href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus">delegates focus</a></dfn>, <dfn id="available-to-element-internals"><a href="https://dom.spec.whatwg.org/#shadowroot-available-to-element-internals">available to element internals</a></dfn>, <dfn id="clonable"><a href="https://dom.spec.whatwg.org/#shadowroot-clonable">clonable</a></dfn>, <dfn id="shadow-serializable"><a href="https://dom.spec.whatwg.org/#shadowroot-serializable">serializable</a></dfn>, <dfn id="shadow-root-custom-element-registry"><a href="https://dom.spec.whatwg.org/#shadowroot-custom-element-registry">custom element registry</a></dfn>, and <dfn id="keep-custom-element-registry-null"><a href="https://dom.spec.whatwg.org/#shadowroot-keep-custom-element-registry-null">keep custom element registry null</a></dfn>.</li><li>The <dfn id="shadow-host"><a href="https://dom.spec.whatwg.org/#element-shadow-host">shadow host</a></dfn> concept</li><li><dfn id="htmlcollection"><a href="https://dom.spec.whatwg.org/#interface-htmlcollection"><code>HTMLCollection</code></a></dfn> interface, its
         <dfn id="dom-htmlcollection-length"><a href="https://dom.spec.whatwg.org/#dom-htmlcollection-length"><code>length</code></a></dfn> attribute, and its
         <dfn id="dom-htmlcollection-item"><a href="https://dom.spec.whatwg.org/#dom-htmlcollection-item"><code>item()</code></a></dfn> and
         <dfn id="dom-htmlcollection-nameditem"><a href="https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem"><code>namedItem()</code></a></dfn> methods</li><li>The terms <dfn id="concept-collection"><a href="https://dom.spec.whatwg.org/#concept-collection">collection</a></dfn> and <dfn id="represented-by-the-collection"><a href="https://dom.spec.whatwg.org/#represented-by-the-collection">represented by the collection</a></dfn></li><li><dfn id="domtokenlist"><a href="https://dom.spec.whatwg.org/#interface-domtokenlist"><code>DOMTokenList</code></a></dfn> interface, and its
         <dfn id="dom-domtokenlist-value"><a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value"><code>value</code></a></dfn> attribute and
         <dfn id="dom-domtokenlist-supports"><a href="https://dom.spec.whatwg.org/#dom-domtokenlist-supports"><code>supports</code></a></dfn> operation</li><li><dfn id="dom-domimplementation-createdocument"><a href="https://dom.spec.whatwg.org/#dom-domimplementation-createdocument"><code>createDocument()</code></a></dfn> method</li><li><dfn id="dom-domimplementation-createhtmldocument"><a href="https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument"><code>createHTMLDocument()</code></a></dfn> method</li><li><dfn id="dom-document-createelement"><a href="https://dom.spec.whatwg.org/#dom-document-createelement"><code>createElement()</code></a></dfn> method</li><li><dfn id="dom-document-createelementns"><a href="https://dom.spec.whatwg.org/#dom-document-createelementns"><code>createElementNS()</code></a></dfn> method</li><li><dfn id="dom-document-getelementbyid"><a href="https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid"><code>getElementById()</code></a></dfn> method</li><li><dfn id="dom-document-getelementsbyclassname"><a href="https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname"><code>getElementsByClassName()</code></a></dfn> method</li><li><dfn id="dom-node-append"><a href="https://dom.spec.whatwg.org/#dom-node-append"><code>append()</code></a></dfn> method</li><li><dfn id="dom-node-appendchild"><a href="https://dom.spec.whatwg.org/#dom-node-appendchild"><code>appendChild()</code></a></dfn> method</li><li><dfn id="dom-node-clonenode"><a href="https://dom.spec.whatwg.org/#dom-node-clonenode"><code>cloneNode()</code></a></dfn> method</li><li><dfn id="dom-parentnode-movebefore"><a href="https://dom.spec.whatwg.org/#dom-parentnode-movebefore"><code>moveBefore()</code></a></dfn> method</li><li><dfn id="dom-document-importnode"><a href="https://dom.spec.whatwg.org/#dom-document-importnode"><code>importNode()</code></a></dfn> method</li><li><dfn id="dom-event-preventdefault"><a href="https://dom.spec.whatwg.org/#dom-event-preventdefault"><code>preventDefault()</code></a></dfn> method</li><li><dfn id="dom-element-id"><a href="https://dom.spec.whatwg.org/#dom-element-id"><code>id</code></a></dfn> attribute</li><li><dfn id="dom-element-setattribute"><a href="https://dom.spec.whatwg.org/#dom-element-setattribute"><code>setAttribute()</code></a></dfn> method</li><li><dfn id="textcontent"><a href="https://dom.spec.whatwg.org/#dom-node-textcontent"><code>textContent</code></a></dfn> attribute</li><li>The <dfn id="tree"><a href="https://dom.spec.whatwg.org/#concept-tree">tree</a></dfn>, <dfn id="shadow-tree"><a href="https://dom.spec.whatwg.org/#concept-shadow-tree">shadow tree</a></dfn>, and <dfn id="node-tree"><a href="https://dom.spec.whatwg.org/#concept-node-tree">node tree</a></dfn> concepts</li><li>The <dfn id="tree-order"><a href="https://dom.spec.whatwg.org/#concept-tree-order">tree order</a></dfn> and <dfn id="shadow-including-tree-order"><a href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order">shadow-including tree order</a></dfn> concepts</li><li>The <dfn id="concept-element"><a href="https://dom.spec.whatwg.org/#concept-element">element</a></dfn> concept</li><li>The <dfn id="concept-tree-child"><a href="https://dom.spec.whatwg.org/#concept-tree-child">child</a></dfn> concept</li><li>The <dfn id="root"><a href="https://dom.spec.whatwg.org/#concept-tree-root">root</a></dfn> and <dfn id="shadow-including-root"><a href="https://dom.spec.whatwg.org/#concept-shadow-including-root">shadow-including root</a></dfn> concepts</li><li>The <dfn id="inclusive-ancestor"><a href="https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor">inclusive ancestor</a></dfn>,
             <dfn id="ancestor"><a href="https://dom.spec.whatwg.org/#concept-tree-ancestor">ancestor</a></dfn>,
             <dfn id="descendant"><a href="https://dom.spec.whatwg.org/#concept-tree-descendant">descendant</a></dfn>,
             <dfn id="concept-shadow-including-ancestor"><a href="https://dom.spec.whatwg.org/#concept-shadow-including-ancestor">shadow-including ancestor</a></dfn>,
             <dfn id="shadow-including-descendant"><a href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant">shadow-including descendant</a></dfn>,
             <dfn id="shadow-including-inclusive-descendant"><a href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant">shadow-including inclusive descendant</a></dfn>, and
             <dfn id="shadow-including-inclusive-ancestor"><a href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-ancestor">shadow-including inclusive ancestor</a></dfn> concepts</li><li>The <dfn id="first-child"><a href="https://dom.spec.whatwg.org/#concept-tree-first-child">first child</a></dfn>,
             <dfn id="last-child"><a href="https://dom.spec.whatwg.org/#concept-tree-last-child">last child</a></dfn>,
             <dfn id="next-sibling"><a href="https://dom.spec.whatwg.org/#concept-tree-next-sibling">next sibling</a></dfn>,
             <dfn id="previous-sibling"><a href="https://dom.spec.whatwg.org/#concept-tree-previous-sibling">previous sibling</a></dfn>, and
             <dfn id="parent"><a href="https://dom.spec.whatwg.org/#concept-tree-parent">parent</a></dfn> concepts</li><li>The <dfn id="parent-element"><a href="https://dom.spec.whatwg.org/#parent-element">parent element</a></dfn> concept</li><li>The <dfn id="document-element"><a href="https://dom.spec.whatwg.org/#document-element">document element</a></dfn> concept</li><li>The <dfn id="in-a-document-tree"><a href="https://dom.spec.whatwg.org/#in-a-document-tree">in a document tree</a></dfn>, <dfn id="in-a-document"><a href="https://dom.spec.whatwg.org/#in-a-document">in a document</a></dfn> (legacy), and <dfn id="connected"><a href="https://dom.spec.whatwg.org/#connected">connected</a></dfn> concepts</li><li>The <dfn id="concept-slot"><a href="https://dom.spec.whatwg.org/#concept-slot">slot</a></dfn> concept, and its <dfn id="slot-name"><a href="https://dom.spec.whatwg.org/#slot-name">name</a></dfn> and <dfn id="assigned-nodes"><a href="https://dom.spec.whatwg.org/#slot-assigned-nodes">assigned nodes</a></dfn></li><li>The <dfn id="assigned-slot"><a href="https://dom.spec.whatwg.org/#slotable-assigned-slot">assigned slot</a></dfn> concept</li><li>The <dfn id="slot-assignment"><a href="https://dom.spec.whatwg.org/#dom-shadowroot-slot-assignment">slot assignment</a></dfn> concept</li><li>The <dfn id="slottable"><a href="https://dom.spec.whatwg.org/#concept-slotable">slottable</a></dfn> concept</li><li>The <dfn id="assign-slottables-for-a-tree"><a href="https://dom.spec.whatwg.org/#assign-slotables-for-a-tree">assign slottables for a tree</a></dfn> algorithm</li><li>The <dfn id="event-slotchange"><a href="https://dom.spec.whatwg.org/#eventdef-htmlslotelement-slotchange"><code>slotchange</code></a></dfn> event</li><li>The <dfn id="inclusive-descendant"><a href="https://dom.spec.whatwg.org/#concept-tree-inclusive-descendant">inclusive descendant</a></dfn> concept</li><li>The <dfn id="finding-flattened-slottables"><a href="https://dom.spec.whatwg.org/#find-flattened-slotables">find flattened slottables</a></dfn> algorithm</li><li>The <dfn id="manual-slot-assignment"><a href="https://dom.spec.whatwg.org/#slottable-manual-slot-assignment">manual slot assignment</a></dfn> concept</li><li>The <dfn id="assign-a-slot"><a href="https://dom.spec.whatwg.org/#assign-a-slot">assign a slot</a></dfn> algorithm</li><li>The <dfn id="pre-insert"><a href="https://dom.spec.whatwg.org/#concept-node-pre-insert">pre-insert</a></dfn>, <dfn id="concept-node-insert"><a href="https://dom.spec.whatwg.org/#concept-node-insert">insert</a></dfn>, <dfn id="concept-node-append"><a href="https://dom.spec.whatwg.org/#concept-node-append">append</a></dfn>, <dfn id="concept-node-replace"><a href="https://dom.spec.whatwg.org/#concept-node-replace">replace</a></dfn>, <dfn id="concept-node-replace-all"><a href="https://dom.spec.whatwg.org/#concept-node-replace-all">replace all</a></dfn>, <dfn id="string-replace-all"><a href="https://dom.spec.whatwg.org/#string-replace-all">string replace all</a></dfn>, <dfn id="concept-node-remove"><a href="https://dom.spec.whatwg.org/#concept-node-remove">remove</a></dfn>, and <dfn id="concept-node-adopt"><a href="https://dom.spec.whatwg.org/#concept-node-adopt">adopt</a></dfn> algorithms for nodes</li><li>The <dfn id="concept-tree-descendant"><a href="https://dom.spec.whatwg.org/#concept-tree-descendant">descendant</a></dfn> concept</li><li>The <dfn id="concept-node-insert-ext"><a href="https://dom.spec.whatwg.org/#concept-node-insert-ext">insertion steps</a></dfn>,
     </li><li>The <dfn id="concept-node-post-connection-ext"><a href="https://dom.spec.whatwg.org/#concept-node-post-connection-ext">post-connection steps</a></dfn>,
             <dfn id="concept-node-remove-ext"><a href="https://dom.spec.whatwg.org/#concept-node-remove-ext">removing steps</a></dfn>,
             <dfn id="concept-node-move-ext"><a href="https://dom.spec.whatwg.org/#concept-node-move-ext">moving steps</a></dfn>,
             <dfn id="concept-node-adopt-ext"><a href="https://dom.spec.whatwg.org/#concept-node-adopt-ext">adopting steps</a></dfn>, and
             <dfn id="children-changed-steps"><a href="https://dom.spec.whatwg.org/#concept-node-children-changed-ext">children changed steps</a></dfn> hooks for elements</li><li>The <dfn id="concept-element-attributes-change"><a href="https://dom.spec.whatwg.org/#concept-element-attributes-change">change</a></dfn>, <dfn id="concept-element-attributes-append"><a href="https://dom.spec.whatwg.org/#concept-element-attributes-append">append</a></dfn>, <dfn id="concept-element-attributes-remove"><a href="https://dom.spec.whatwg.org/#concept-element-attributes-remove">remove</a></dfn>, <dfn id="concept-element-attributes-replace"><a href="https://dom.spec.whatwg.org/#concept-element-attributes-replace">replace</a></dfn>, <dfn id="concept-element-attributes-get-by-namespace"><a href="https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace">get an attribute by namespace and local name</a></dfn>, <dfn id="concept-element-attributes-set-value"><a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value">set value</a></dfn>, and <dfn id="concept-element-attributes-remove-by-namespace"><a href="https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace">remove an attribute by namespace and local name</a></dfn> algorithms for attributes</li><li>The <dfn id="concept-element-attributes-change-ext"><a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext">attribute change steps</a></dfn> hook for attributes</li><li>The <dfn id="concept-attribute-value"><a href="https://dom.spec.whatwg.org/#concept-attribute-value">value</a></dfn> concept for attributes</li><li>The <dfn id="concept-attribute-local-name"><a href="https://dom.spec.whatwg.org/#concept-attribute-local-name">local name</a></dfn> concept for attributes</li><li>The <dfn id="attribute-list"><a href="https://dom.spec.whatwg.org/#concept-element-attribute">attribute list</a></dfn> concept</li><li>The <dfn id="concept-cd-data"><a href="https://dom.spec.whatwg.org/#concept-cd-data">data</a></dfn> of a <code id="dependencies:characterdata"><a data-x-internal="characterdata" href="https://dom.spec.whatwg.org/#interface-characterdata">CharacterData</a></code> node and its
             <dfn id="replace-data"><a href="https://dom.spec.whatwg.org/#concept-cd-replace">replace data</a></dfn> algorithm</li><li>The <dfn id="child-text-content"><a href="https://dom.spec.whatwg.org/#concept-child-text-content">child text content</a></dfn> of a node</li><li>The <dfn id="descendant-text-content"><a href="https://dom.spec.whatwg.org/#concept-descendant-text-content">descendant text content</a></dfn> of a node</li><li>The <dfn id="concept-doctype-name"><a href="https://dom.spec.whatwg.org/#concept-doctype-name">name</a></dfn>,
             <dfn id="concept-doctype-publicid"><a href="https://dom.spec.whatwg.org/#concept-doctype-publicid">public ID</a></dfn>, and
             <dfn id="concept-doctype-systemid"><a href="https://dom.spec.whatwg.org/#concept-doctype-systemid">system ID</a></dfn> of a doctype</li><li><dfn id="event"><a href="https://dom.spec.whatwg.org/#interface-event"><code>Event</code></a></dfn> interface</li><li><dfn id="dom-event-constructor"><a href="https://dom.spec.whatwg.org/#concept-event-constructor"><code>Event</code> and derived interfaces constructor behavior</a></dfn></li><li><dfn id="eventtarget"><a href="https://dom.spec.whatwg.org/#interface-eventtarget"><code>EventTarget</code></a></dfn> interface</li><li>The <dfn id="activation-behaviour"><a href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior">activation behavior</a></dfn> hook</li><li>The <dfn id="legacy-pre-activation-behavior"><a href="https://dom.spec.whatwg.org/#eventtarget-legacy-pre-activation-behavior">legacy-pre-activation behavior</a></dfn> hook</li><li>The <dfn id="legacy-canceled-activation-behavior"><a href="https://dom.spec.whatwg.org/#eventtarget-legacy-canceled-activation-behavior">legacy-canceled-activation behavior</a></dfn> hook</li><li>The <dfn id="creating-an-event"><a href="https://dom.spec.whatwg.org/#concept-event-create">create an event</a></dfn> algorithm</li><li>The <dfn id="concept-event-fire"><a href="https://dom.spec.whatwg.org/#concept-event-fire">fire an event</a></dfn> algorithm</li><li>The <dfn id="canceled-flag"><a href="https://dom.spec.whatwg.org/#canceled-flag">canceled flag</a></dfn></li><li>The <dfn id="dispatch-flag"><a href="https://dom.spec.whatwg.org/#dispatch-flag">dispatch flag</a></dfn></li><li>The <dfn id="concept-event-dispatch"><a href="https://dom.spec.whatwg.org/#concept-event-dispatch">dispatch</a></dfn> algorithm</li><li><dfn id="eventinit"><a href="https://dom.spec.whatwg.org/#dictdef-eventinit"><code>EventInit</code></a></dfn> dictionary type</li><li><dfn id="dom-event-type"><a href="https://dom.spec.whatwg.org/#dom-event-type"><code>type</code></a></dfn> attribute</li><li>An event's <dfn id="concept-event-target"><a href="https://dom.spec.whatwg.org/#concept-event-target">target</a></dfn></li><li><dfn id="dom-event-currenttarget"><a href="https://dom.spec.whatwg.org/#dom-event-currenttarget"><code>currentTarget</code></a></dfn> attribute</li><li><dfn id="dom-event-bubbles"><a href="https://dom.spec.whatwg.org/#dom-event-bubbles"><code>bubbles</code></a></dfn> attribute</li><li><dfn id="dom-event-cancelable"><a href="https://dom.spec.whatwg.org/#dom-event-cancelable"><code>cancelable</code></a></dfn> attribute</li><li><dfn id="dom-event-composed"><a href="https://dom.spec.whatwg.org/#dom-event-composed"><code>composed</code></a></dfn> attribute</li><li><dfn id="composed-flag"><a href="https://dom.spec.whatwg.org/#composed-flag">composed flag</a></dfn></li><li><dfn id="dom-event-istrusted"><a href="https://dom.spec.whatwg.org/#dom-event-istrusted"><code>isTrusted</code></a></dfn> attribute</li><li><dfn id="dom-event-initevent"><a href="https://dom.spec.whatwg.org/#dom-event-initevent"><code>initEvent()</code></a></dfn> method</li><li><dfn id="add-an-event-listener"><a href="https://dom.spec.whatwg.org/#add-an-event-listener">add an event listener</a></dfn></li><li><dfn id="dom-eventtarget-addeventlistener"><a href="https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener"><code>addEventListener()</code></a></dfn> method</li><li>The <dfn id="remove-an-event-listener"><a href="https://dom.spec.whatwg.org/#remove-an-event-listener">remove an event listener</a></dfn> and
             <dfn id="remove-all-event-listeners"><a href="https://dom.spec.whatwg.org/#remove-all-event-listeners">remove all event listeners</a></dfn> algorithms</li><li><dfn id="dom-eventlistener"><a href="https://dom.spec.whatwg.org/#callbackdef-eventlistener"><code>EventListener</code></a></dfn> callback interface</li><li>The <dfn id="concept-event-type"><a href="https://dom.spec.whatwg.org/#dom-event-type">type</a></dfn> of an event</li><li>An <dfn id="event-listener"><a href="https://dom.spec.whatwg.org/#concept-event-listener">event listener</a></dfn> and its
            <dfn id="event-listener-type"><a href="https://dom.spec.whatwg.org/#event-listener-type">type</a></dfn> and
            <dfn id="event-listener-callback"><a href="https://dom.spec.whatwg.org/#event-listener-callback">callback</a></dfn></li><li>The <dfn id="document's-character-encoding"><a href="https://dom.spec.whatwg.org/#concept-document-encoding">encoding</a></dfn> (herein the <i>character encoding</i>),
             <dfn id="concept-document-mode"><a href="https://dom.spec.whatwg.org/#concept-document-mode">mode</a></dfn>,
             <dfn id="document-custom-element-registry"><a href="https://dom.spec.whatwg.org/#document-custom-element-registry">custom element registry</a></dfn>,
             <dfn id="concept-document-allow-declarative-shadow-roots"><a href="https://dom.spec.whatwg.org/#concept-document-allow-declarative-shadow-roots">allow declarative shadow roots</a></dfn>, and
             <dfn id="concept-document-content-type"><a href="https://dom.spec.whatwg.org/#concept-document-content-type">content type</a></dfn> of a <code id="dependencies:document"><a href="#document">Document</a></code></li><li>The distinction between <dfn id="xml-documents"><a href="https://dom.spec.whatwg.org/#xml-document">XML documents</a></dfn> and
                                 <dfn id="html-documents"><a href="https://dom.spec.whatwg.org/#html-document">HTML documents</a></dfn></li><li>The terms <dfn id="quirks-mode"><a href="https://dom.spec.whatwg.org/#concept-document-quirks">quirks mode</a></dfn>,
                   <dfn id="limited-quirks-mode"><a href="https://dom.spec.whatwg.org/#concept-document-limited-quirks">limited-quirks mode</a></dfn>, and
                   <dfn id="no-quirks-mode"><a href="https://dom.spec.whatwg.org/#concept-document-no-quirks">no-quirks mode</a></dfn></li><li data-var-scope="">The algorithm <dfn id="concept-node-clone"><a href="https://dom.spec.whatwg.org/#concept-node-clone">clone a node</a></dfn> with its arguments
                       <dfn id="concept-node-clone-document"><a href="https://dom.spec.whatwg.org/#clone-a-node-document"><var>document</var></a></dfn>,
                       <dfn id="concept-node-clone-subtree"><a href="https://dom.spec.whatwg.org/#clone-a-node-subtree"><var>subtree</var></a></dfn>,
                       <dfn id="concept-node-clone-parent"><a href="https://dom.spec.whatwg.org/#clone-a-node-parent"><var>parent</var></a></dfn>, and
                       <dfn id="concept-node-clone-fallbackregistry"><a href="https://dom.spec.whatwg.org/#clone-a-node-fallbackregistry"><var>fallbackRegistry</var></a></dfn>, and the concept of
                       <dfn id="concept-node-clone-ext"><a href="https://dom.spec.whatwg.org/#concept-node-clone-ext">cloning steps</a></dfn></li><li>The concept of an element's <dfn id="concept-id"><a href="https://dom.spec.whatwg.org/#concept-id">unique identifier (ID)</a></dfn></li><li>The concept of an element's <dfn id="concept-class"><a href="https://dom.spec.whatwg.org/#concept-class">classes</a></dfn></li><li>The term <dfn id="concept-supported-tokens"><a href="https://dom.spec.whatwg.org/#concept-supported-tokens">supported tokens</a></dfn></li><li>The concept of a DOM <dfn id="concept-range"><a href="https://dom.spec.whatwg.org/#concept-range">range</a></dfn>, and the terms
                              <dfn id="concept-range-start-node"><a href="https://dom.spec.whatwg.org/#concept-range-start-node">start node</a></dfn>,
                              <dfn id="concept-range-start"><a href="https://dom.spec.whatwg.org/#concept-range-start">start</a></dfn>,
                              <dfn id="concept-range-end"><a href="https://dom.spec.whatwg.org/#concept-range-end">end</a></dfn>, and
                              <dfn id="concept-range-bp"><a href="https://dom.spec.whatwg.org/#concept-range-bp">boundary point</a></dfn> as applied to ranges.</li><li>The <dfn id="create-an-element"><a href="https://dom.spec.whatwg.org/#concept-create-element">create an element</a></dfn> algorithm</li><li>The <dfn id="element-interface"><a href="https://dom.spec.whatwg.org/#concept-element-interface">element interface</a></dfn> concept</li><li>The concepts of <dfn id="custom-element-state"><a href="https://dom.spec.whatwg.org/#concept-element-custom-element-state">custom element state</a></dfn>, and of
                         <dfn id="concept-element-defined"><a href="https://dom.spec.whatwg.org/#concept-element-defined">defined</a></dfn> and
                         <dfn id="concept-element-custom"><a href="https://dom.spec.whatwg.org/#concept-element-custom">custom</a></dfn> elements</li><li>An element's <dfn id="concept-element-namespace"><a href="https://dom.spec.whatwg.org/#concept-element-namespace">namespace</a></dfn>,
                      <dfn id="concept-element-namespace-prefix"><a href="https://dom.spec.whatwg.org/#concept-element-namespace-prefix">namespace prefix</a></dfn>,
                      <dfn id="concept-element-local-name"><a href="https://dom.spec.whatwg.org/#concept-element-local-name">local name</a></dfn>,
                      <dfn id="element-custom-element-registry"><a href="https://dom.spec.whatwg.org/#element-custom-element-registry">custom element registry</a></dfn>,
                      <dfn id="concept-element-custom-element-definition"><a href="https://dom.spec.whatwg.org/#concept-element-custom-element-definition">custom element definition</a></dfn>, and
                      <dfn id="concept-element-is-value"><a href="https://dom.spec.whatwg.org/#concept-element-is-value"><code>is</code> value</a></dfn></li><li><dfn id="mutationobserver"><a href="https://dom.spec.whatwg.org/#mutationobserver"><code>MutationObserver</code></a></dfn> interface and <dfn id="mutation-observers"><a href="https://dom.spec.whatwg.org/#mutation-observers">mutation observers</a></dfn> in general</li><li><dfn id="abortcontroller"><a href="https://dom.spec.whatwg.org/#abortcontroller"><code>AbortController</code></a></dfn> and its
         <dfn id="concept-abortcontroller-signal"><a href="https://dom.spec.whatwg.org/#abortcontroller-signal">signal</a></dfn></li><li><dfn id="abortsignal"><a href="https://dom.spec.whatwg.org/#abortsignal"><code>AbortSignal</code></a></dfn></li><li><dfn id="abortsignal-aborted"><a href="https://dom.spec.whatwg.org/#abortsignal-aborted">aborted</a></dfn></li><li><dfn id="signal-abort"><a href="https://dom.spec.whatwg.org/#abortcontroller-signal-abort">signal abort</a></dfn></li><li><dfn id="abortsignal-add"><a href="https://dom.spec.whatwg.org/#abortsignal-add">add</a></dfn></li><li>The <dfn id="get-an-attribute-by-name"><a href="https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name">get an attribute by name</a></dfn> algorithm</li><li><dfn id="valid-attribute-local-name"><a href="https://dom.spec.whatwg.org/#valid-attribute-local-name">valid attribute local name</a></dfn></li><li><dfn id="valid-element-local-name"><a href="https://dom.spec.whatwg.org/#valid-element-local-name">valid element local name</a></dfn></li></ul>

    <p>The following features are defined in <cite>UI Events</cite>: <a href="#refsUIEVENTS">[UIEVENTS]</a></p>

    <ul class="brief"><li>The <dfn id="mouseevent"><a href="https://w3c.github.io/uievents/#mouseevent"><code>MouseEvent</code></a></dfn> interface</li><li>The <code id="dependencies:mouseevent"><a data-x-internal="mouseevent" href="https://w3c.github.io/uievents/#mouseevent">MouseEvent</a></code> interface's <dfn id="dom-mouseevent-relatedtarget"><a href="https://w3c.github.io/uievents/#dom-mouseevent-relatedtarget"><code>relatedTarget</code></a></dfn> attribute</li><li>The <code id="dependencies:mouseevent-2"><a data-x-internal="mouseevent" href="https://w3c.github.io/uievents/#mouseevent">MouseEvent</a></code> interface's <dfn id="dom-mouseevent-button"><a href="https://w3c.github.io/uievents/#dom-mouseevent-button"><code>button</code></a></dfn> attribute</li><li><dfn id="mouseeventinit"><a href="https://w3c.github.io/uievents/#dictdef-mouseeventinit"><code>MouseEventInit</code></a></dfn> dictionary type</li><li>The <dfn id="focusevent"><a href="https://w3c.github.io/uievents/#focusevent"><code>FocusEvent</code></a></dfn> interface</li><li>The <code id="dependencies:focusevent"><a data-x-internal="focusevent" href="https://w3c.github.io/uievents/#focusevent">FocusEvent</a></code> interface's <dfn id="dom-focusevent-relatedtarget"><a href="https://w3c.github.io/uievents/#dom-focusevent-relatedtarget"><code>relatedTarget</code></a></dfn> attribute</li><li>The <dfn id="uievent"><a href="https://w3c.github.io/uievents/#uievent"><code>UIEvent</code></a></dfn> interface</li><li>The <code id="dependencies:uievent"><a data-x-internal="uievent" href="https://w3c.github.io/uievents/#uievent">UIEvent</a></code> interface's <dfn id="dom-uievent-view"><a href="https://w3c.github.io/uievents/#dom-uievent-view"><code>view</code></a></dfn> attribute</li><li><dfn id="event-auxclick"><a href="https://w3c.github.io/uievents/#event-type-auxclick"><code>auxclick</code></a></dfn> event</li><li><dfn id="event-beforeinput"><a href="https://w3c.github.io/uievents/#event-type-beforeinput"><code>beforeinput</code></a></dfn> event</li><li><dfn id="event-click"><a href="https://w3c.github.io/uievents/#event-type-click"><code>click</code></a></dfn> event</li><li><dfn id="event-contextmenu"><a href="https://w3c.github.io/uievents/#event-type-contextmenu"><code>contextmenu</code></a></dfn> event</li><li><dfn id="event-dblclick"><a href="https://w3c.github.io/uievents/#event-type-dblclick"><code>dblclick</code></a></dfn> event</li><li><dfn id="event-input"><a href="https://w3c.github.io/uievents/#event-type-input"><code>input</code></a></dfn> event</li><li><dfn id="event-mousedown"><a href="https://w3c.github.io/uievents/#event-type-mousedown"><code>mousedown</code></a></dfn> event</li><li><dfn id="event-mouseenter"><a href="https://w3c.github.io/uievents/#event-type-mouseenter"><code>mouseenter</code></a></dfn> event</li><li><dfn id="event-mouseleave"><a href="https://w3c.github.io/uievents/#event-type-mouseleave"><code>mouseleave</code></a></dfn> event</li><li><dfn id="event-mousemove"><a href="https://w3c.github.io/uievents/#event-type-mousemove"><code>mousemove</code></a></dfn> event</li><li><dfn id="event-mouseout"><a href="https://w3c.github.io/uievents/#event-type-mouseout"><code>mouseout</code></a></dfn> event</li><li><dfn id="event-mouseover"><a href="https://w3c.github.io/uievents/#event-type-mouseover"><code>mouseover</code></a></dfn> event</li><li><dfn id="event-mouseup"><a href="https://w3c.github.io/uievents/#event-type-mouseup"><code>mouseup</code></a></dfn> event</li><li><dfn id="event-wheel"><a href="https://w3c.github.io/uievents/#event-type-wheel"><code>wheel</code></a></dfn> event</li><li><dfn id="event-keydown"><a href="https://w3c.github.io/uievents/#event-type-keydown"><code>keydown</code></a></dfn> event</li><li><dfn id="event-keypress"><a href="https://w3c.github.io/uievents/#event-type-keypress"><code>keypress</code></a></dfn> event</li><li><dfn id="event-keyup"><a href="https://w3c.github.io/uievents/#event-type-keyup"><code>keyup</code></a></dfn> event</li></ul>

    <p>The following features are defined in <cite>Touch Events</cite>: <a href="#refsTOUCH">[TOUCH]</a></p>

    <ul class="brief"><li><dfn id="touch"><a href="https://w3c.github.io/touch-events/#touch-interface"><code>Touch</code></a></dfn> interface</li><li><dfn id="touch-point"><a href="https://w3c.github.io/touch-events/#dfn-touch-point">Touch point</a></dfn> concept</li><li><dfn id="event-touchend"><a href="https://w3c.github.io/touch-events/#event-touchend"><code>touchend</code></a></dfn> event</li></ul>

    <p>The following features are defined in <cite>Pointer Events</cite>:
    <a href="#refsPOINTEREVENTS">[POINTEREVENTS]</a></p>

    <ul class="brief"><li>The <dfn id="pointerevent"><a href="https://w3c.github.io/pointerevents/#pointerevent-interface"><code>PointerEvent</code></a></dfn> interface</li><li>The <code id="dependencies:pointerevent"><a data-x-internal="pointerevent" href="https://w3c.github.io/pointerevents/#pointerevent-interface">PointerEvent</a></code> interface's <dfn id="pointertype"><a href="https://w3c.github.io/pointerevents/#dom-pointerevent-pointertype"><code>pointerType</code></a></dfn> attribute</li><li><dfn id="fire-a-pointer-event"><a href="https://w3c.github.io/pointerevents/#dfn-fire-a-pointer-event">fire a pointer event</a></dfn></li><li><dfn id="event-pointerdown"><a href="https://w3c.github.io/pointerevents/#the-pointerdown-event"><code>pointerdown</code></a></dfn> event</li><li><dfn id="event-pointerup"><a href="https://w3c.github.io/pointerevents/#the-pointerup-event"><code>pointerup</code></a></dfn> event</li><li><dfn id="event-pointercancel"><a href="https://w3c.github.io/pointerevents/#the-pointercancel-event"><code>pointercancel</code></a></dfn> event</li></ul>

    <p>The following events are defined in <cite>Clipboard API and events</cite>:
    <a href="#refsCLIPBOARD-APIS">[CLIPBOARD-APIS]</a></p>

    <ul class="brief"><li><dfn id="event-copy"><a href="https://w3c.github.io/clipboard-apis/#clipboard-event-copy"><code>copy</code></a></dfn> event</li><li><dfn id="event-cut"><a href="https://w3c.github.io/clipboard-apis/#clipboard-event-cut"><code>cut</code></a></dfn> event</li><li><dfn id="event-paste"><a href="https://w3c.github.io/clipboard-apis/#clipboard-event-paste"><code>paste</code></a></dfn> event</li></ul>

    <p>This specification sometimes uses the term <dfn>name</dfn> to refer to the event's
    <a href="https://dom.spec.whatwg.org/#dom-event-type" id="dependencies:concept-event-type" data-x-internal="concept-event-type">type</a>; as in, "an event named <code>click</code>" or "if the event name is <code>keypress</code>". The terms
    "name" and "type" for events are synonymous.</p>

    <p>The following features are defined in <cite>DOM Parsing and Serialization</cite>:
    <a href="#refsDOMPARSING">[DOMPARSING]</a></p>

    <ul class="brief"><li><dfn id="xml-serialization"><a href="https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization"><code>XML serialization</code></a></dfn></li></ul>

    <p>The following features are defined in <cite>Selection API</cite>: <a href="#refsSELECTION">[SELECTION]</a></p>

    <ul class="brief"><li><dfn id="document-selection"><a href="https://w3c.github.io/selection-api/#dfn-selection">selection</a></dfn></li><li><dfn id="selection"><a href="https://w3c.github.io/selection-api/#selection-interface"><code>Selection</code></a></dfn></li></ul>

    <p class="note">User agents are encouraged to implement the features described in
    <cite>execCommand</cite>. <a href="#refsEXECCOMMAND">[EXECCOMMAND]</a></p>

    <p>The following features are defined in <cite>Fullscreen API</cite>: <a href="#refsFULLSCREEN">[FULLSCREEN]</a></p>

    <ul class="brief"><li><dfn id="dom-element-requestfullscreen"><a href="https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen"><code>requestFullscreen()</code></a></dfn></li><li><dfn id="event-fullscreenchange"><a href="https://fullscreen.spec.whatwg.org/#eventdef-document-fullscreenchange"><code>fullscreenchange</code></a></dfn></li><li><dfn id="run-the-fullscreen-steps"><a href="https://fullscreen.spec.whatwg.org/#run-the-fullscreen-steps">run the fullscreen steps</a></dfn></li><li><dfn id="fully-exit-fullscreen"><a href="https://fullscreen.spec.whatwg.org/#fully-exit-fullscreen">fully exit fullscreen</a></dfn></li><li><dfn id="fullscreen-element"><a href="https://fullscreen.spec.whatwg.org/#fullscreen-element">fullscreen element</a></dfn></li><li><dfn id="fullscreen-flag"><a href="https://fullscreen.spec.whatwg.org/#fullscreen-flag">fullscreen flag</a></dfn></li></ul>

    <p><cite>High Resolution Time</cite> provides the following features: <a href="#refsHRT">[HRT]</a></p>

    <ul class="brief"><li><dfn id="current-high-resolution-time"><a href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time">current high resolution time</a></dfn></li><li><dfn id="relative-high-resolution-time"><a href="https://w3c.github.io/hr-time/#dfn-relative-high-resolution-time">relative high resolution time</a></dfn></li><li><dfn id="unsafe-shared-current-time"><a href="https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time">unsafe shared current time</a></dfn></li><li><dfn id="shared-monotonic-clock"><a href="https://w3c.github.io/hr-time/#dfn-shared-monotonic-clock">shared monotonic clock</a></dfn></li><li><dfn id="unsafe-moment"><a href="https://w3c.github.io/hr-time/#dfn-unsafe-moment">unsafe moment</a></dfn></li><li><dfn id="duration-from"><a href="https://w3c.github.io/hr-time/#dfn-duration-from">duration from</a></dfn></li><li><dfn id="coarsen-time"><a href="https://w3c.github.io/hr-time/#dfn-coarsen-time">coarsen time</a></dfn></li><li><dfn id="current-wall-time"><a href="https://w3c.github.io/hr-time/#dfn-current-wall-time">current wall time</a></dfn></li><li><dfn id="unix-epoch"><a href="https://w3c.github.io/hr-time/#dfn-unix-epoch">Unix epoch</a></dfn></li><li><dfn id="domhighrestimestamp"><a href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp"><code>DOMHighResTimeStamp</code></a></dfn></li></ul>
   </dd><dt>File API</dt><dd>
    <p>This specification uses the following features defined in <cite>File API</cite>:
    <a href="#refsFILEAPI">[FILEAPI]</a></p>

    <ul class="brief"><li>The <dfn id="blob"><a href="https://w3c.github.io/FileAPI/#dfn-Blob"><code>Blob</code></a></dfn> interface and its
             <dfn id="dom-blob-type"><a href="https://w3c.github.io/FileAPI/#dfn-type"><code>type</code></a></dfn> attribute</li><li>The <dfn id="file"><a href="https://w3c.github.io/FileAPI/#dfn-file"><code>File</code></a></dfn> interface and its
             <dfn id="dom-file-name"><a href="https://w3c.github.io/FileAPI/#dfn-name"><code>name</code></a></dfn> and
             <dfn id="dom-file-lastmodified"><a href="https://w3c.github.io/FileAPI/#dfn-lastModified"><code>lastModified</code></a></dfn> attributes</li><li>The <dfn id="filelist"><a href="https://w3c.github.io/FileAPI/#filelist-section"><code>FileList</code></a></dfn> interface</li><li>The concept of a <code id="dependencies:blob"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code>'s <dfn id="snapshot-state"><a href="https://w3c.github.io/FileAPI/#snapshot-state">snapshot state</a></dfn></li><li>The concept of <dfn id="file-error-read">read errors</dfn></li><li><dfn id="blob-url-store"><a href="https://w3c.github.io/FileAPI/#BlobURLStore">Blob URL Store</a></dfn></li><li><dfn id="blob-url-entry"><a href="https://w3c.github.io/FileAPI/#blob-url-entry">blob URL entry</a></dfn> and its
         <dfn id="blob-url-entry-environment"><a href="https://w3c.github.io/FileAPI/#blob-url-entry-environment">environment</a></dfn></li><li>The <dfn id="blob-url-obtain-object"><a href="https://w3c.github.io/FileAPI/#blob-url-obtain-object">obtain a blob object</a></dfn> algorithm</li></ul>
   </dd><dt>Indexed Database API</dt><dd>
    <p>The following terms are defined in <cite>Indexed Database API</cite>:
    <a href="#refsINDEXEDDB">[INDEXEDDB]</a></p>

    <ul class="brief"><li><dfn id="cleanup-indexed-database-transactions"><a href="https://w3c.github.io/IndexedDB/#cleanup-indexed-database-transactions">cleanup Indexed Database transactions</a></dfn></li><li><dfn id="idbversionchangeevent"><a href="https://w3c.github.io/IndexedDB/#idbversionchangeevent"><code>IDBVersionChangeEvent</code></a></dfn></li></ul>
   </dd><dt>Media Source Extensions</dt><dd>
    <p>The following terms are defined in <cite>Media Source Extensions</cite>:
    <a href="#refsMEDIASOURCE">[MEDIASOURCE]</a></p>

    <ul class="brief"><li><dfn id="mediasource"><a href="https://w3c.github.io/media-source/#idl-def-mediasource"><code>MediaSource</code></a></dfn> interface</li><li><dfn id="detaching-from-a-media-element"><a href="https://w3c.github.io/media-source/#mediasource-detach">detaching from a media element</a></dfn></li></ul>
   </dd><dt>Media Capture and Streams</dt><dd>
    <p>The following terms are defined in <cite>Media Capture and Streams</cite>:
    <a href="#refsMEDIASTREAM">[MEDIASTREAM]</a></p>

    <ul class="brief"><li><dfn id="mediastream"><a href="https://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-mediastream"><code>MediaStream</code></a></dfn> interface</li><li><dfn id="mediastreamtrack"><a href="https://w3c.github.io/mediacapture-main/getusermedia.html#mediastreamtrack"><code>MediaStreamTrack</code></a></dfn></li><li><dfn id="live-state"><a href="https://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-MediaStreamTrackState.live">live state</a></dfn></li><li><dfn id="getusermedia()"><a href="https://w3c.github.io/mediacapture-main/getusermedia.html#dom-mediadevices-getusermedia"><code>getUserMedia()</code></a></dfn></li></ul>
   </dd><dt>Reporting</dt><dd>
    <p>The following terms are defined in <cite>Reporting</cite>: <a href="#refsREPORTING">[REPORTING]</a></p>

    <ul class="brief"><li><dfn id="queue-a-report"><a href="https://w3c.github.io/reporting/#queue-report">Queue a report</a></dfn></li><li><dfn id="report-type"><a href="https://w3c.github.io/reporting/#report-type">report type</a></dfn></li><li><dfn id="visible-to-reportingobservers"><a href="https://w3c.github.io/reporting/#visible-to-reportingobservers">visible to <code>ReportingObserver</code>s</a></dfn></li></ul>
   </dd><dt>XMLHttpRequest</dt><dd>
    <p>The following features and terms are defined in <cite>XMLHttpRequest</cite>:
    <a href="#refsXHR">[XHR]</a></p>

    <ul class="brief"><li>The <dfn id="xmlhttprequest"><a href="https://xhr.spec.whatwg.org/#xmlhttprequest"><code>XMLHttpRequest</code></a></dfn> interface, and its
             <dfn id="dom-xmlhttprequest-responsexml"><a href="https://xhr.spec.whatwg.org/#dom-xmlhttprequest-responsexml"><code>responseXML</code></a></dfn> attribute</li><li>The <dfn id="progressevent"><a href="https://xhr.spec.whatwg.org/#interface-progressevent"><code>ProgressEvent</code></a></dfn> interface, and its
             <dfn id="dom-progressevent-lengthcomputable"><a href="https://xhr.spec.whatwg.org/#dom-progressevent-lengthcomputable"><code>lengthComputable</code></a></dfn>,
             <dfn id="dom-progressevent-loaded"><a href="https://xhr.spec.whatwg.org/#dom-progressevent-loaded"><code>loaded</code></a></dfn>, and
             <dfn id="dom-progressevent-total"><a href="https://xhr.spec.whatwg.org/#dom-progressevent-total"><code>total</code></a></dfn> attributes</li><li>The <dfn id="formdata"><a href="https://xhr.spec.whatwg.org/#formdata"><code>FormData</code></a></dfn> interface, and its associated
             <dfn id="formdata-entry-list"><a href="https://xhr.spec.whatwg.org/#concept-formdata-entry-list">entry list</a></dfn></li></ul>
   </dd><dt>Battery Status</dt><dd>
    <p>The following features are defined in <cite>Battery Status API</cite>: <a href="#refsBATTERY">[BATTERY]</a></p>

    <ul class="brief"><li><dfn id="dom-navigator-getbattery"><a href="https://w3c.github.io/battery/#widl-Navigator-getBattery-Promise-BatteryManager"><code>getBattery()</code></a></dfn> method</li></ul>
   </dd><dt>Media Queries</dt><dd>
    <p>Implementations must support <cite>Media Queries</cite>. The <dfn id="media-condition"><a href="https://drafts.csswg.org/mediaqueries/#typedef-media-condition">&lt;media-condition&gt;</a></dfn>
    feature is defined therein. <a href="#refsMQ">[MQ]</a></p>
   </dd><dt>CSS modules</dt><dd>
    <p>While support for CSS as a whole is not required of implementations of this specification
    (though it is encouraged, at least for web browsers), some features are defined in terms of
    specific CSS requirements.</p>

    <p>When this specification requires that something be <dfn id="parse-something-according-to-a-css-grammar"><a href="https://drafts.csswg.org/css-syntax/#parse-grammar">parsed according
    to a particular CSS grammar</a></dfn>, the relevant algorithm in <cite>CSS Syntax</cite> must be
    followed, including error handling rules. <a href="#refsCSSSYNTAX">[CSSSYNTAX]</a></p>

    <p class="example">For example, user agents are required to close all open constructs upon
    finding the end of a style sheet unexpectedly. Thus, when parsing the string "<code>rgb(0,0,0</code>" (with a missing close-parenthesis) for a color value, the close
    parenthesis is implied by this error handling rule, and a value is obtained (the color 'black').
    However, the similar construct "<code>rgb(0,0,</code>" (with both a missing
    parenthesis and a missing "blue" value) cannot be parsed, as closing the open construct does not
    result in a viable value.</p>

    <p>The following terms and features are defined in <cite>Cascading Style Sheets</cite>
    (<cite>CSS</cite>): <a href="#refsCSS">[CSS]</a></p>

    <ul class="brief"><li><dfn id="viewport"><a href="https://drafts.csswg.org/css2/#viewport">viewport</a></dfn></li><li><dfn id="line-box"><a href="https://drafts.csswg.org/css2/#line-box">line box</a></dfn></li><li><dfn id="out-of-flow"><a href="https://drafts.csswg.org/css2/#out-of-flow">out-of-flow</a></dfn></li><li><dfn id="in-flow"><a href="https://drafts.csswg.org/css2/#in-flow">in-flow</a></dfn></li><li><dfn id="collapsing-margins"><a href="https://drafts.csswg.org/css2/#collapsing-margins">collapsing margins</a></dfn></li><li><dfn id="containing-block"><a href="https://drafts.csswg.org/css2/#containing-block-details">containing block</a></dfn></li><li><dfn id="inline-box"><a href="https://drafts.csswg.org/css2/#inline-box">inline box</a></dfn></li><li><dfn id="block-box"><a href="https://drafts.csswg.org/css2/#block-boxes%E2%91%A0">block box</a></dfn></li><li>The <dfn id="'top'"><a href="https://drafts.csswg.org/css2/#propdef-top">'top'</a></dfn>,
              <dfn id="'bottom'"><a href="https://drafts.csswg.org/css2/#propdef-bottom">'bottom'</a></dfn>,
              <dfn id="'left'"><a href="https://drafts.csswg.org/css2/#propdef-left">'left'</a></dfn>, and
              <dfn id="'right'"><a href="https://drafts.csswg.org/css2/#propdef-right">'right'</a></dfn> properties</li><li>The <dfn id="'float'"><a href="https://drafts.csswg.org/css2/#float-position">'float'</a></dfn> property</li><li>The <dfn id="'clear'"><a href="https://drafts.csswg.org/css2/#flow-control">'clear'</a></dfn> property</li><li>The <dfn id="'width'"><a href="https://drafts.csswg.org/css2/#the-width-property">'width'</a></dfn> property</li><li>The <dfn id="'height'"><a href="https://drafts.csswg.org/css2/#the-height-property">'height'</a></dfn> property</li><li>The <dfn id="'min-width'"><a href="https://drafts.csswg.org/css2/#min-max-widths">'min-width'</a></dfn> property</li><li>The <dfn id="'min-height'"><a href="https://drafts.csswg.org/css2/#min-max-heights">'min-height'</a></dfn> property</li><li>The <dfn id="'max-width'"><a href="https://drafts.csswg.org/css2/#min-max-widths">'max-width'</a></dfn> property</li><li>The <dfn id="'max-height'"><a href="https://drafts.csswg.org/css2/#min-max-heights">'max-height'</a></dfn> property</li><li>The <dfn id="'line-height'"><a href="https://drafts.csswg.org/css2/#propdef-line-height">'line-height'</a></dfn> property</li><li>The <dfn id="'vertical-align'"><a href="https://drafts.csswg.org/css2/#propdef-vertical-align">'vertical-align'</a></dfn> property</li><li>The <dfn id="'content'"><a href="https://drafts.csswg.org/css2/#content%E2%91%A0">'content'</a></dfn> property</li><li>The <dfn id="'inline-block'"><a href="https://drafts.csswg.org/css2/#value-def-inline-block">'inline-block'</a></dfn> value of the <a id="dependencies:'display'" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property</li><li>The <dfn id="'visibility'"><a href="https://drafts.csswg.org/css2/#propdef-visibility">'visibility'</a></dfn> property</li></ul>

    <p>The basic version of the <dfn id="'display'"><a href="https://drafts.csswg.org/css2/#display-prop">'display'</a></dfn> property
    is defined in <cite>CSS</cite>, and the property is extended by other CSS modules.
    <a href="#refsCSS">[CSS]</a> <a href="#refsCSSRUBY">[CSSRUBY]</a> <a href="#refsCSSTABLE">[CSSTABLE]</a></p>

    <p>The following terms and features are defined in <cite>CSS Box Model</cite>:
    <a href="#refsCSSBOX">[CSSBOX]</a></p>

    <ul><li><dfn id="content-area"><a href="https://drafts.csswg.org/css-box/#content-area">content area</a></dfn></li><li><dfn id="content-box"><a href="https://drafts.csswg.org/css-box/#content-box">content box</a></dfn></li><li><dfn id="border-box"><a href="https://drafts.csswg.org/css-box/#border-box">border box</a></dfn></li><li><dfn id="margin-box"><a href="https://drafts.csswg.org/css-box/#margin-box">margin box</a></dfn></li><li><dfn id="border-edge"><a href="https://drafts.csswg.org/css-box/#border-edge">border edge</a></dfn></li><li><dfn id="margin-edge"><a href="https://drafts.csswg.org/css-box/#margin-edge">margin edge</a></dfn></li><li>The <dfn id="'margin-top'"><a href="https://drafts.csswg.org/css-box/#propdef-margin-top">'margin-top'</a></dfn>,
              <dfn id="'margin-bottom'"><a href="https://drafts.csswg.org/css-box/#propdef-margin-bottom">'margin-bottom'</a></dfn>,
              <dfn id="'margin-left'"><a href="https://drafts.csswg.org/css-box/#propdef-margin-left">'margin-left'</a></dfn>, and
              <dfn id="'margin-right'"><a href="https://drafts.csswg.org/css-box/#propdef-margin-right">'margin-right'</a></dfn> properties</li><li>The <dfn id="'padding-top'"><a href="https://drafts.csswg.org/css-box/#propdef-padding-top">'padding-top'</a></dfn>,
              <dfn id="'padding-bottom'"><a href="https://drafts.csswg.org/css-box/#propdef-padding-bottom">'padding-bottom'</a></dfn>,
              <dfn id="'padding-left'"><a href="https://drafts.csswg.org/css-box/#propdef-padding-left">'padding-left'</a></dfn>, and
              <dfn id="'padding-right'"><a href="https://drafts.csswg.org/css-box/#propdef-padding-right">'padding-right'</a></dfn> properties</li></ul>

    <p>The following features are defined in <cite>CSS Logical Properties</cite>:
    <a href="#refsCSSLOGICAL">[CSSLOGICAL]</a></p>

    <ul class="brief"><li>The <dfn id="'margin-block'"><a href="https://drafts.csswg.org/css-logical/#propdef-margin-block">'margin-block'</a></dfn>,
              <dfn id="'margin-block-start'"><a href="https://drafts.csswg.org/css-logical/#propdef-margin-block-start">'margin-block-start'</a></dfn>,
              <dfn id="'margin-block-end'"><a href="https://drafts.csswg.org/css-logical/#propdef-margin-block-end">'margin-block-end'</a></dfn>,
              <dfn id="'margin-inline'"><a href="https://drafts.csswg.org/css-logical/#propdef-margin-inline">'margin-inline'</a></dfn>,
              <dfn id="'margin-inline-start'"><a href="https://drafts.csswg.org/css-logical/#propdef-margin-inline-start">'margin-inline-start'</a></dfn>, and
              <dfn id="'margin-inline-end'"><a href="https://drafts.csswg.org/css-logical/#propdef-margin-inline-end">'margin-inline-end'</a></dfn> properties</li><li>The <dfn id="'padding-block'"><a href="https://drafts.csswg.org/css-logical/#propdef-padding-block">'padding-block'</a></dfn>,
              <dfn id="'padding-block-start'"><a href="https://drafts.csswg.org/css-logical/#propdef-padding-block-start">'padding-block-start'</a></dfn>,
              <dfn id="'padding-block-end'"><a href="https://drafts.csswg.org/css-logical/#propdef-padding-block-end">'padding-block-end'</a></dfn>,
              <dfn id="'padding-inline'"><a href="https://drafts.csswg.org/css-logical/#propdef-padding-inline">'padding-inline'</a></dfn>,
              <dfn id="'padding-inline-start'"><a href="https://drafts.csswg.org/css-logical/#propdef-padding-inline-start">'padding-inline-start'</a></dfn>, and
              <dfn id="'padding-inline-end'"><a href="https://drafts.csswg.org/css-logical/#propdef-padding-inline-end">'padding-inline-end'</a></dfn> properties</li><li>The <dfn id="'border-block-width'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-block-width">'border-block-width'</a></dfn>,
              <dfn id="'border-block-start-width'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-block-start-width">'border-block-start-width'</a></dfn>,
              <dfn id="'border-block-end-width'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-block-end-width">'border-block-end-width'</a></dfn>,
              <dfn id="'border-inline-width'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-inline-width">'border-inline-width'</a></dfn>,
              <dfn id="'border-inline-start-width'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-inline-start-width">'border-inline-start-width'</a></dfn>,
              <dfn id="'border-inline-end-width'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-inline-end-width">'border-inline-end-width'</a></dfn>,
              <dfn id="'border-block-style'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-block-style">'border-block-style'</a></dfn>,
              <dfn id="'border-block-start-style'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-block-start-style">'border-block-start-style'</a></dfn>,
              <dfn id="'border-block-end-style'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-block-end-style">'border-block-end-style'</a></dfn>,
              <dfn id="'border-inline-style'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-inline-style">'border-inline-style'</a></dfn>,
              <dfn id="'border-inline-start-style'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-inline-start-style">'border-inline-start-style'</a></dfn>,
              <dfn id="'border-inline-end-style'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-inline-end-style">'border-inline-end-style'</a></dfn>,
              <dfn id="'border-block-start-color'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-block-start-color">'border-block-start-color'</a></dfn>,
              <dfn id="'border-block-end-color'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-block-end-color">'border-block-end-color'</a></dfn>,
              <dfn id="'border-inline-start-color'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-inline-start-color">'border-inline-start-color'</a></dfn>,
              <dfn id="'border-inline-end-color'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-inline-end-color">'border-inline-end-color'</a></dfn>,
              <dfn id="'border-start-start-radius'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-start-start-radius">'border-start-start-radius'</a></dfn>,
              <dfn id="'border-start-end-radius'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-start-end-radius">'border-start-end-radius'</a></dfn>,
              <dfn id="'border-end-start-radius'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-end-start-radius">'border-end-start-radius'</a></dfn>, and
              <dfn id="'border-end-end-radius'"><a href="https://drafts.csswg.org/css-logical/#propdef-border-end-end-radius">'border-end-end-radius'</a></dfn>
              properties</li><li>The <dfn id="'block-size'"><a href="https://drafts.csswg.org/css-logical/#propdef-block-size">'block-size'</a></dfn> property</li><li>The <dfn id="'inline-size'"><a href="https://drafts.csswg.org/css-logical/#propdef-inline-size">'inline-size'</a></dfn> property</li><li>The <dfn id="'inset-block-start'"><a href="https://drafts.csswg.org/css-logical/#propdef-inset-block-start">'inset-block-start'</a></dfn> property</li><li>The <dfn id="'inset-block-end'"><a href="https://drafts.csswg.org/css-logical/#propdef-inset-block-end">'inset-block-end'</a></dfn> property</li></ul>

    <p>The following terms and features are defined in <cite>CSS Color</cite>:
    <a href="#refsCSSCOLOR">[CSSCOLOR]</a></p>

    <ul class="brief"><li><dfn id="named-color"><a href="https://drafts.csswg.org/css-color/#named-color">named color</a></dfn></li><li><dfn id="color"><a href="https://drafts.csswg.org/css-color/#typedef-color">&lt;color&gt;</a></dfn></li><li>The <dfn id="'color'"><a href="https://drafts.csswg.org/css-color/#the-color-property">'color'</a></dfn> property</li><li>The <dfn id="currentcolor"><a href="https://drafts.csswg.org/css-color/#valdef-color-currentcolor">'currentcolor'</a></dfn> value</li><li><dfn id="opaque-black"><a href="https://drafts.csswg.org/css-color/#opaque-black">opaque black</a></dfn></li><li><dfn id="transparent-black"><a href="https://drafts.csswg.org/css-color/#transparent-black">transparent black</a></dfn></li><li><dfn id="'srgb'"><a href="https://drafts.csswg.org/css-color/#valdef-color-srgb">'srgb'</a></dfn> color space</li><li><dfn id="'display-p3'"><a href="https://drafts.csswg.org/css-color/#valdef-color-display-p3">'display-p3'</a></dfn> color space</li><li><dfn id="'relative-colorimetric'"><a href="https://drafts.csswg.org/css-color-5/#valdef-color-profile-rendering-intent-relative-colorimetric">'relative-colorimetric'</a></dfn> rendering intent</li><li><dfn id="parsed-as-a-css-color-value"><a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value">parse a CSS &lt;color&gt; value</a></dfn></li><li><dfn id="serialisation-of-a-color"><a href="https://drafts.csswg.org/css-color/#serializing-color-values">serialize a CSS &lt;color&gt; value</a></dfn> including <dfn id="html-compatible-serialization-is-requested"><a href="https://drafts.csswg.org/css-color/#color-serialization-html-compatible-serialization-is-requested">HTML-compatible serialization is requested</a></dfn></li><li><dfn id="converting-colors"><a href="https://drafts.csswg.org/css-color/#color-conversion">Converting Colors</a></dfn></li><li><dfn id="color-function"><a href="https://drafts.csswg.org/css-color/#color-function">'color()'</a></dfn></li></ul>

    <p>The following terms are defined in <cite>CSS Images</cite>: <a href="#refsCSSIMAGES">[CSSIMAGES]</a></p>

    <ul class="brief"><li><dfn id="default-object-size"><a href="https://drafts.csswg.org/css-images/#default-object-size">default object size</a></dfn></li><li><dfn id="concrete-object-size"><a href="https://drafts.csswg.org/css-images/#concrete-object-size">concrete object size</a></dfn></li><li><dfn id="natural-dimensions"><a href="https://drafts.csswg.org/css-images/#natural-dimensions">natural dimensions</a></dfn></li><li><dfn id="natural-height"><a href="https://drafts.csswg.org/css-images/#natural-height">natural height</a></dfn></li><li><dfn id="natural-width"><a href="https://drafts.csswg.org/css-images/#natural-width">natural width</a></dfn></li><li>The <dfn id="'image-orientation'"><a href="https://drafts.csswg.org/css-images-3/#the-image-orientation">'image-orientation'</a></dfn> property</li><li><dfn id="'conic-gradient'"><a href="https://drafts.csswg.org/css-images-4/#funcdef-conic-gradient">'conic-gradient'</a></dfn></li><li>The <dfn id="'object-fit'"><a href="https://drafts.csswg.org/css-images/#the-object-fit">'object-fit'</a></dfn> property</li></ul>

    <p>The term <dfn id="paint-source"><a href="https://drafts.csswg.org/css-images-4/#paint-source">paint
    source</a></dfn> is used as defined in <cite>CSS Images Level 4</cite>
    to define the interaction of certain HTML elements with the CSS 'element()' function.
    <a href="#refsCSSIMAGES4">[CSSIMAGES4]</a></p>

    <p>The following features are defined in <cite>CSS Backgrounds and Borders</cite>:
    <a href="#refsCSSBG">[CSSBG]</a></p>

    <ul class="brief"><li>The <dfn id="'background-color'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-background-color">'background-color'</a></dfn>,
              <dfn id="'background-image'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-background-image">'background-image'</a></dfn>,
              <dfn id="'background-repeat'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-background-repeat">'background-repeat'</a></dfn>,
              <dfn id="'background-attachment'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-background-attachment">'background-attachment'</a></dfn>,
              <dfn id="'background-position'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-background-position">'background-position'</a></dfn>,
              <dfn id="'background-clip'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-background-clip">'background-clip'</a></dfn>,
              <dfn id="'background-origin'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-background-origin">'background-origin'</a></dfn>, and
              <dfn id="'background-size'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-background-size">'background-size'</a></dfn>
              properties</li><li>The <dfn id="'border-radius'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-radius">'border-radius'</a></dfn>,
              <dfn id="'border-top-left-radius'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-left-radius">'border-top-left-radius'</a></dfn>,
              <dfn id="'border-top-right-radius'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-right-radius">'border-top-right-radius'</a></dfn>,
              <dfn id="'border-bottom-right-radius'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-right-radius">'border-bottom-right-radius'</a></dfn>,
              <dfn id="'border-bottom-left-radius'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-left-radius">'border-bottom-left-radius'</a></dfn>
              properties</li><li>The <dfn id="'border-image-source'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-image-source">'border-image-source'</a></dfn>,
              <dfn id="'border-image-slice'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-image-slice">'border-image-slice'</a></dfn>,
              <dfn id="'border-image-width'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-image-width">'border-image-width'</a></dfn>,
              <dfn id="'border-image-outset'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-image-outset">'border-image-outset'</a></dfn>, and
              <dfn id="'border-image-repeat'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-image-repeat">'border-image-repeat'</a></dfn>
              properties</li></ul>

    <p><cite>CSS Backgrounds and Borders</cite> also defines the following border properties:
    <a href="#refsCSSBG">[CSSBG]</a></p>

    <table><caption>Border properties
     </caption><tbody><tr><td>
       </td><th>Top
       </th><th>Bottom
       </th><th>Left
       </th><th>Right
      </th></tr><tr><th>Width
       </th><td><dfn id="'border-top-width'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-width">'border-top-width'</a></dfn>
       </td><td><dfn id="'border-bottom-width'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-width">'border-bottom-width'</a></dfn>
       </td><td><dfn id="'border-left-width'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-left-width">'border-left-width'</a></dfn>
       </td><td><dfn id="'border-right-width'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-right-width">'border-right-width'</a></dfn>
      </td></tr><tr><th>Style
       </th><td><dfn id="'border-top-style'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-style">'border-top-style'</a></dfn>
       </td><td><dfn id="'border-bottom-style'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-style">'border-bottom-style'</a></dfn>
       </td><td><dfn id="'border-left-style'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-left-style">'border-left-style'</a></dfn>
       </td><td><dfn id="'border-right-style'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-right-style">'border-right-style'</a></dfn>
      </td></tr><tr><th>Color
       </th><td><dfn id="'border-top-color'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-color">'border-top-color'</a></dfn>
       </td><td><dfn id="'border-bottom-color'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-color">'border-bottom-color'</a></dfn>
       </td><td><dfn id="'border-left-color'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-left-color">'border-left-color'</a></dfn>
       </td><td><dfn id="'border-right-color'"><a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-right-color">'border-right-color'</a></dfn>
    </td></tr></tbody></table>

    <p>The following features are defined in <cite>CSS Box Alignment</cite>: <a href="#refsCSSALIGN">[CSSALIGN]</a></p>

    <ul class="brief"><li>The <dfn id="'align-content'"><a href="https://drafts.csswg.org/css-align/#propdef-align-content">'align-content'</a></dfn> property</li><li>The <dfn id="'align-items'"><a href="https://drafts.csswg.org/css-align/#propdef-align-items">'align-items'</a></dfn> property</li><li>The <dfn id="'align-self'"><a href="https://drafts.csswg.org/css-align/#propdef-align-self">'align-self'</a></dfn> property</li><li>The <dfn id="'justify-self'"><a href="https://drafts.csswg.org/css-align/#propdef-justify-self">'justify-self'</a></dfn> property</li><li>The <dfn id="'justify-content'"><a href="https://drafts.csswg.org/css-align/#propdef-propdef-justify-content">'justify-content'</a></dfn> property</li><li>The <dfn id="'justify-items'"><a href="https://drafts.csswg.org/css-align/#propdef-propdef-justify-items">'justify-items'</a></dfn> property</li></ul>

    <p>The following terms and features are defined in <cite>CSS Display</cite>:
    <a href="#refsCSSDISPLAY">[CSSDISPLAY]</a></p>

    <ul class="brief"><li><dfn id="outer-display-type"><a href="https://drafts.csswg.org/css-display/#outer-display-type">outer display type</a></dfn></li><li><dfn id="inner-display-type"><a href="https://drafts.csswg.org/css-display/#inner-display-type">inner display type</a></dfn></li><li><dfn id="block-level"><a href="https://drafts.csswg.org/css-display/#block-level">block-level</a></dfn></li><li><dfn id="block-container"><a href="https://drafts.csswg.org/css-display/#block-container">block container</a></dfn></li><li><dfn id="formatting-context"><a href="https://drafts.csswg.org/css-display/#formatting-context">formatting context</a></dfn></li><li><dfn id="block-formatting-context"><a href="https://drafts.csswg.org/css-display/#block-formatting-context">block formatting context</a></dfn></li><li><dfn id="inline-formatting-context"><a href="https://drafts.csswg.org/css-display/#inline-formatting-context">inline formatting context</a></dfn></li><li><dfn id="replaced-element"><a href="https://drafts.csswg.org/css-display/#replaced-element">replaced element</a></dfn></li><li><dfn id="css-box"><a href="https://drafts.csswg.org/css-display/#css-box">CSS box</a></dfn></li></ul>

    <p>The following features are defined in <cite>CSS Flexible Box Layout</cite>:
    <a href="#refsCSSFLEXBOX">[CSSFLEXBOX]</a></p>

    <ul class="brief"><li>The <dfn id="'flex-direction'"><a href="https://drafts.csswg.org/css-flexbox/#propdef-flex-direction">'flex-direction'</a></dfn> property</li><li>The <dfn id="'flex-wrap'"><a href="https://drafts.csswg.org/css-flexbox/#propdef-flex-wrap">'flex-wrap'</a></dfn> property</li></ul>

    <p>The following terms and features are defined in <cite>CSS Fonts</cite>:
    <a href="#refsCSSFONTS">[CSSFONTS]</a></p>

    <ul class="brief"><li><dfn id="first-available-font"><a href="https://drafts.csswg.org/css-fonts/#first-available-font">first available font</a></dfn></li><li>The <dfn id="'font-family'"><a href="https://drafts.csswg.org/css-fonts/#font-family-prop">'font-family'</a></dfn> property</li><li>The <dfn id="'font-weight'"><a href="https://drafts.csswg.org/css-fonts/#font-weight-prop">'font-weight'</a></dfn> property</li><li>The <dfn id="'font-size'"><a href="https://drafts.csswg.org/css-fonts/#font-size-prop">'font-size'</a></dfn> property</li><li>The <dfn id="'font'"><a href="https://drafts.csswg.org/css-fonts/#font-prop">'font'</a></dfn> property</li><li>The <dfn id="'font-kerning'"><a href="https://drafts.csswg.org/css-fonts/#propdef-font-kerning">'font-kerning'</a></dfn> property</li><li>The <dfn id="'font-stretch'"><a href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch">'font-stretch'</a></dfn> property</li><li>The <dfn id="'font-variant-caps'"><a href="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps">'font-variant-caps'</a></dfn> property</li><li>The <dfn id="'small-caps'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-small-caps">'small-caps'</a></dfn> value</li><li>The <dfn id="'all-small-caps'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-all-small-caps">'all-small-caps'</a></dfn> value</li><li>The <dfn id="'petite-caps'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-petite-caps">'petite-caps'</a></dfn> value</li><li>The <dfn id="'all-petite-caps'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-all-petite-caps">'all-petite-caps'</a></dfn> value</li><li>The <dfn id="'unicase'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-unicase">'unicase'</a></dfn> value</li><li>The <dfn id="'titling-caps'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-titling-caps">'titling-caps'</a></dfn> value</li><li>The <dfn id="'ultra-condensed'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-ultra-condensed">'ultra-condensed'</a></dfn> value</li><li>The <dfn id="'extra-condensed'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-extra-condensed">'extra-condensed'</a></dfn> value</li><li>The <dfn id="'condensed'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-condensed">'condensed'</a></dfn> value</li><li>The <dfn id="'semi-condensed'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-semi-condensed">'semi-condensed'</a></dfn> value</li><li>The <dfn id="'semi-expanded'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-semi-expanded">'semi-expanded'</a></dfn> value</li><li>The <dfn id="'expanded'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-expanded">'expanded'</a></dfn> value</li><li>The <dfn id="'extra-expanded'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-extra-expanded">'extra-expanded'</a></dfn> value</li><li>The <dfn id="'ultra-expanded'"><a href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-ultra-expanded">'ultra-expanded'</a></dfn> value</li></ul>

    <p>The following features are defined in <cite>CSS Forms</cite>:
    <a href="#refsCSSFORMS">[CSSFORMS]</a></p>

    <ul class="brief"><li><dfn id="'::picker'"><a href="https://drafts.csswg.org/css-forms/#the-picker-pseudo-element">'::picker'</a></dfn></li><li><dfn id="'::checkmark'"><a href="https://drafts.csswg.org/css-forms/#selectordef-checkmark">'::checkmark'</a></dfn></li><li><dfn id="'::picker-icon'"><a href="https://drafts.csswg.org/css-forms/#picker-opener-icon-the-picker-icon-pseudo-element">'::picker-icon'</a></dfn></li></ul>

    <p>The following features are defined in <cite>CSS Grid Layout</cite>: <a href="#refsCSSGRID">[CSSGRID]</a></p>

    <ul class="brief"><li>The <dfn id="'grid-auto-columns'"><a href="https://drafts.csswg.org/css-grid/#propdef-grid-auto-columns">'grid-auto-columns'</a></dfn> property</li><li>The <dfn id="'grid-auto-flow'"><a href="https://drafts.csswg.org/css-grid/#propdef-grid-auto-flow">'grid-auto-flow'</a></dfn> property</li><li>The <dfn id="'grid-auto-rows'"><a href="https://drafts.csswg.org/css-grid/#propdef-grid-auto-rows">'grid-auto-rows'</a></dfn> property</li><li>The <dfn id="'grid-column-gap'"><a href="https://drafts.csswg.org/css-grid/#propdef-grid-column-gap">'grid-column-gap'</a></dfn> property</li><li>The <dfn id="'grid-row-gap'"><a href="https://drafts.csswg.org/css-grid/#propdef-grid-row-gap">'grid-row-gap'</a></dfn> property</li><li>The <dfn id="'grid-template-areas'"><a href="https://drafts.csswg.org/css-grid/#propdef-grid-template-areas">'grid-template-areas'</a></dfn> property</li><li>The <dfn id="'grid-template-columns'"><a href="https://drafts.csswg.org/css-grid/#propdef-grid-template-columns">'grid-template-columns'</a></dfn> property</li><li>The <dfn id="'grid-template-rows'"><a href="https://drafts.csswg.org/css-grid/#propdef-grid-template-rows">'grid-template-rows'</a></dfn> property</li></ul>

    <p>The following terms are defined in <cite>CSS Inline Layout</cite>: <a href="#refsCSSINLINE">[CSSINLINE]</a></p>

    <ul class="brief"><li><dfn id="alphabetic-baseline"><a href="https://drafts.csswg.org/css-inline/#alphabetic-baseline">alphabetic baseline</a></dfn></li><li><dfn id="ascent-metric"><a href="https://drafts.csswg.org/css-inline/#ascent-metric">ascent metric</a></dfn></li><li><dfn id="descent-metric"><a href="https://drafts.csswg.org/css-inline/#descent-metric">descent metric</a></dfn></li><li><dfn id="em-over-baseline"><a href="https://drafts.csswg.org/css-inline/#em-over-baseline">em-over baseline</a></dfn></li><li><dfn id="em-under-baseline"><a href="https://drafts.csswg.org/css-inline/#em-under-baseline">em-under baseline</a></dfn></li><li><dfn id="hanging-baseline"><a href="https://drafts.csswg.org/css-inline/#hanging-baseline">hanging baseline</a></dfn></li><li><dfn id="ideographic-under-baseline"><a href="https://drafts.csswg.org/css-inline/#ideographic-under-baseline">ideographic-under baseline</a></dfn></li></ul>

    <p>The following terms and features are defined in <cite>CSS Box Sizing</cite>:
    <a href="#refsCSSSIZING">[CSSSIZING]</a></p>

    <ul class="brief"><li><dfn id="fit-content-inline-size"><a href="https://drafts.csswg.org/css-sizing/#fit-content-inline-size">fit-content inline size</a></dfn></li><li><dfn id="'aspect-ratio'"><a href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio">'aspect-ratio'</a></dfn> property</li><li><dfn id="intrinsic-size"><a href="https://drafts.csswg.org/css-sizing/#intrinsic-size">intrinsic size</a></dfn></li></ul>

    <p>The following features are defined in <cite>CSS Lists and Counters</cite>.
    <a href="#refsCSSLISTS">[CSSLISTS]</a></p>

    <ul class="brief"><li><dfn id="css-list-item"><a href="https://drafts.csswg.org/css-lists/#list-item">list item</a></dfn></li><li>The <dfn id="'counter-reset'"><a href="https://drafts.csswg.org/css-lists/#propdef-counter-reset">'counter-reset'</a></dfn> property</li><li>The <dfn id="'counter-set'"><a href="https://drafts.csswg.org/css-lists/#propdef-counter-set">'counter-set'</a></dfn> property</li><li>The <dfn id="'list-style-type'"><a href="https://drafts.csswg.org/css-lists/#propdef-list-style-type">'list-style-type'</a></dfn> property</li></ul>

    <p>The following features are defined in <cite>CSS Overflow</cite>. <a href="#refsCSSOVERFLOW">[CSSOVERFLOW]</a></p>

    <ul class="brief"><li>The <dfn id="'overflow'"><a href="https://drafts.csswg.org/css-overflow/#propdef-overflow">'overflow'</a></dfn> property and its <dfn id="'hidden'"><a href="https://drafts.csswg.org/css-overflow/#valdef-overflow-hidden">'hidden'</a></dfn> value</li><li>The <dfn id="'text-overflow'"><a href="https://drafts.csswg.org/css-overflow/#propdef-text-overflow">'text-overflow'</a></dfn> property</li><li>The term <dfn id="scroll-container"><a href="https://drafts.csswg.org/css-overflow/#scroll-container">scroll container</a></dfn>
    </li></ul>

    <p>The following terms and features are defined in <cite>CSS Positioned Layout</cite>:
    <a href="#refsCSSPOSITION">[CSSPOSITION]</a></p>

    <ul class="brief"><li><dfn id="absolutely-positioned"><a href="https://drafts.csswg.org/css-position/#absolute-position">absolutely-positioned</a></dfn></li><li>The <dfn id="'position'"><a href="https://drafts.csswg.org/css-position/#position-property">'position'</a></dfn> property and its
              <dfn id="'static'"><a href="https://drafts.csswg.org/css-position/#valdef-position-static">'static'</a></dfn> value</li><li>The <dfn id="top-layer"><a href="https://drafts.csswg.org/css-position-4/#document-top-layer">top layer</a></dfn>
              (an <a href="https://infra.spec.whatwg.org/#ordered-set" id="dependencies:set" data-x-internal="set">ordered set</a>)</li><li><dfn id="add-an-element-to-the-top-layer"><a href="https://drafts.csswg.org/css-position-4/#add-an-element-to-the-top-layer">add an element to the top layer</a></dfn></li><li><dfn id="request-an-element-to-be-removed-from-the-top-layer"><a href="https://drafts.csswg.org/css-position-4/#request-an-element-to-be-removed-from-the-top-layer">request an element to be removed from the top layer</a></dfn></li><li><dfn id="remove-an-element-from-the-top-layer-immediately"><a href="https://drafts.csswg.org/css-position-4/#remove-an-element-from-the-top-layer-immediately">remove an element from the top layer immediately</a></dfn></li><li><dfn id="process-top-layer-removals"><a href="https://drafts.csswg.org/css-position-4/#process-top-layer-removals">process top layer removals</a></dfn></li></ul>

    <p>The following features are defined in <cite>CSS Multi-column Layout</cite>.
    <a href="#refsCSSMULTICOL">[CSSMULTICOL]</a></p>

    <ul class="brief"><li>The <dfn id="'column-count'"><a href="https://drafts.csswg.org/css-multicol/#propdef-column-count">'column-count'</a></dfn> property</li><li>The <dfn id="'column-fill'"><a href="https://drafts.csswg.org/css-multicol/#propdef-column-fill">'column-fill'</a></dfn> property</li><li>The <dfn id="'column-gap'"><a href="https://drafts.csswg.org/css-multicol/#propdef-column-gap">'column-gap'</a></dfn> property</li><li>The <dfn id="'column-rule'"><a href="https://drafts.csswg.org/css-multicol/#propdef-column-rule">'column-rule'</a></dfn> property</li><li>The <dfn id="'column-width'"><a href="https://drafts.csswg.org/css-multicol/#propdef-column-width">'column-width'</a></dfn> property</li></ul>

    <p>The <dfn id="'ruby-base'"><a href="https://drafts.csswg.org/css-ruby/#valdef-display-ruby-base">'ruby-base'</a></dfn>
    value of the <a id="dependencies:'display'-2" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property is defined in <cite>CSS Ruby Layout</cite>.
    <a href="#refsCSSRUBY">[CSSRUBY]</a></p>

    <p>The following features are defined in <cite>CSS Table</cite>: <a href="#refsCSSTABLE">[CSSTABLE]</a></p>

    <ul class="brief"><li>The <dfn id="'border-spacing'"><a href="https://drafts.csswg.org/css-tables/#propdef-border-spacing">'border-spacing'</a></dfn> property</li><li>The <dfn id="'border-collapse'"><a href="https://drafts.csswg.org/css-tables/#border-collapse-property">'border-collapse'</a></dfn> property</li><li>The <dfn id="'table-cell'"><a href="https://drafts.csswg.org/css-tables/#table-cell">'table-cell'</a></dfn>,
              <dfn id="'table-row'"><a href="https://drafts.csswg.org/css-tables/#table-row">'table-row'</a></dfn>,
              <dfn id="'table-caption'"><a href="https://drafts.csswg.org/css-tables/#table-caption">'table-caption'</a></dfn>, and
              <dfn id="'table'"><a href="https://drafts.csswg.org/css-tables/#table">'table'</a></dfn> values of the <a id="dependencies:'display'-3" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property</li></ul>

    <p>The following features are defined in <cite>CSS Text</cite>: <a href="#refsCSSTEXT">[CSSTEXT]</a></p>

    <ul class="brief"><li>The <dfn id="content-language"><a href="https://drafts.csswg.org/css-text-4/#content-language">content language</a></dfn> concept</li><li>The <dfn id="'text-transform'"><a href="https://drafts.csswg.org/css-text/#text-transform-property">'text-transform'</a></dfn> property</li><li>The <dfn id="'white-space'"><a href="https://drafts.csswg.org/css-text/#white-space-property">'white-space'</a></dfn> property</li><li>The <dfn id="'text-align'"><a href="https://drafts.csswg.org/css-text/#text-align-property">'text-align'</a></dfn> property</li><li>The <dfn id="'letter-spacing'"><a href="https://drafts.csswg.org/css-text/#letter-spacing-property">'letter-spacing'</a></dfn> property</li><li>The <dfn id="'word-spacing'"><a href="https://drafts.csswg.org/css-text/#propdef-word-spacing">'word-spacing'</a></dfn> property</li></ul>

    <p>The following features are defined in <cite>CSS Writing Modes</cite>: <a href="#refsCSSWM">[CSSWM]</a></p>

    <ul class="brief"><li>The <dfn id="'direction'"><a href="https://drafts.csswg.org/css-writing-modes/#direction">'direction'</a></dfn> property</li><li>The <dfn id="'unicode-bidi'"><a href="https://drafts.csswg.org/css-writing-modes/#unicode-bidi">'unicode-bidi'</a></dfn> property</li><li>The <dfn id="'writing-mode'"><a href="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode">'writing-mode'</a></dfn> property</li><li>The <dfn id="block-flow-direction"><a href="https://drafts.csswg.org/css-writing-modes/#block-flow-direction">block flow direction</a></dfn>,
              <dfn id="block-axis"><a href="https://drafts.csswg.org/css-writing-modes/#block-axis">block axis</a></dfn>,
              <dfn id="inline-axis"><a href="https://drafts.csswg.org/css-writing-modes/#inline-axis">inline axis</a></dfn>,
              <dfn id="block-size"><a href="https://drafts.csswg.org/css-writing-modes/#block-size">block size</a></dfn>,
              <dfn id="inline-size"><a href="https://drafts.csswg.org/css-writing-modes/#inline-size">inline size</a></dfn>,
              <dfn id="block-start"><a href="https://drafts.csswg.org/css-writing-modes/#block-start">block-start</a></dfn>,
              <dfn id="block-end"><a href="https://drafts.csswg.org/css-writing-modes/#block-end">block-end</a></dfn>,
              <dfn id="inline-start"><a href="https://drafts.csswg.org/css-writing-modes/#inline-start">inline-start</a></dfn>,
              <dfn id="inline-end"><a href="https://drafts.csswg.org/css-writing-modes/#inline-end">inline-end</a></dfn>,
              <dfn id="line-left"><a href="https://drafts.csswg.org/css-writing-modes/#line-left">line-left</a></dfn>, and
              <dfn id="line-right"><a href="https://drafts.csswg.org/css-writing-modes/#line-right">line-right</a></dfn> concepts</li></ul>

    <p>The following features are defined in <cite>CSS Basic User Interface</cite>:
    <a href="#refsCSSUI">[CSSUI]</a></p>

    <ul class="brief"><li>The <dfn id="'outline'"><a href="https://drafts.csswg.org/css-ui/#outline">'outline'</a></dfn> property</li><li>The <dfn id="'cursor'"><a href="https://drafts.csswg.org/css-ui/#cursor">'cursor'</a></dfn> property</li><li>The <dfn id="'appearance'"><a href="https://drafts.csswg.org/css-ui/#appearance-switching">'appearance'</a></dfn> property, its
              <dfn id="compat-auto"><a href="https://drafts.csswg.org/css-ui/#typedef-appearance-compat-auto">&lt;compat-auto&gt;</a></dfn> non-terminal value type, its
              <dfn id="'textfield'"><a href="https://drafts.csswg.org/css-ui/#valdef-appearance-textfield">'textfield'</a></dfn> value, and its
              <dfn id="'menulist-button'"><a href="https://drafts.csswg.org/css-ui/#valdef-appearance-menulist-button">'menulist-button'</a></dfn> value.</li><li>The <dfn id="'field-sizing'"><a href="https://drafts.csswg.org/css-ui/#field-sizing">'field-sizing'</a></dfn> property, and its
              <dfn id="field-sizing-content"><a href="https://drafts.csswg.org/css-ui/#valdef-field-sizing-content">'content'</a></dfn> value.</li><li>The concept <dfn id="widget"><a href="https://drafts.csswg.org/css-ui/#widget">widget</a></dfn></li><li>The concept <dfn id="native-appearance"><a href="https://drafts.csswg.org/css-ui/#native-appearance">native appearance</a></dfn></li><li>The concept <dfn id="primitive-appearance"><a href="https://drafts.csswg.org/css-ui/#primitive-appearance">primitive appearance</a></dfn></li><li>The concept <dfn id="base-appearance"><a href="https://drafts.csswg.org/css-ui/#base-appearance">base appearance</a></dfn></li><li>The concept <dfn id="element-with-default-preferred-size"><a href="https://drafts.csswg.org/css-ui/#element-with-default-preferred-size">element with default preferred size</a></dfn></li><li>The <dfn id="non-devolvable-widget"><a href="https://drafts.csswg.org/css-ui/#non-devolvable">non-devolvable widget</a></dfn> and
              <dfn id="devolvable-widget"><a href="https://drafts.csswg.org/css-ui/#devolvable">devolvable widget</a></dfn> classification, and the related
              <dfn id="devolved-widget"><a href="https://drafts.csswg.org/css-ui/#devolved">devolved widget</a></dfn> state.</li><li>The <dfn id="'pointer-events'"><a href="https://drafts.csswg.org/css-ui-4/#pointer-events-control">'pointer-events'</a></dfn> property</li><li>The <dfn id="'user-select'"><a href="https://drafts.csswg.org/css-ui-4/#content-selection">'user-select'</a></dfn> property</li></ul>

    <p>The algorithm to <dfn id="update-animations-and-send-events"><a href="https://drafts.csswg.org/web-animations-1/#update-animations-and-send-events">update
    animations and send events</a></dfn> is defined in <cite>Web Animations</cite>.
    <a href="#refsWEBANIMATIONS">[WEBANIMATIONS]</a></p>

    <p>Implementations that support scripting must support the CSS Object Model. The following
    features and terms are defined in the CSSOM specifications: <a href="#refsCSSOM">[CSSOM]</a>
    <a href="#refsCSSOMVIEW">[CSSOMVIEW]</a>

    </p><ul class="brief"><li><dfn id="screen"><a href="https://drafts.csswg.org/cssom-view/#the-screen-interface"><code>Screen</code></a></dfn> interface</li><li><dfn id="linkstyle"><a href="https://drafts.csswg.org/cssom/#the-linkstyle-interface"><code>LinkStyle</code></a></dfn> interface</li><li><dfn id="cssstyledeclaration"><a href="https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface"><code>CSSStyleDeclaration</code></a></dfn> interface</li><li><dfn id="dom-style"><a href="https://drafts.csswg.org/cssom/#dom-elementcssinlinestyle-style"><code>style</code></a></dfn> IDL attribute</li><li><dfn id="dom-cssstyledeclaration-csstext"><a href="https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-csstext"><code>cssText</code></a></dfn> attribute of <code id="dependencies:cssstyledeclaration"><a data-x-internal="cssstyledeclaration" href="https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface">CSSStyleDeclaration</a></code></li><li><dfn id="stylesheet"><a href="https://drafts.csswg.org/cssom/#the-stylesheet-interface"><code>StyleSheet</code></a></dfn> interface</li><li><dfn id="cssstylesheet"><a href="https://drafts.csswg.org/cssom/#the-cssstylesheet-interface"><code>CSSStyleSheet</code></a></dfn> interface</li><li><dfn id="create-a-css-style-sheet"><a href="https://drafts.csswg.org/cssom/#create-a-css-style-sheet">create a CSS style sheet</a></dfn></li><li><dfn id="remove-a-css-style-sheet"><a href="https://drafts.csswg.org/cssom/#remove-a-css-style-sheet">remove a CSS style sheet</a></dfn></li><li><dfn id="associated-css-style-sheet"><a href="https://drafts.csswg.org/cssom/#associated-css-style-sheet">associated CSS style sheet</a></dfn></li><li><dfn id="create-a-constructed-cssstylesheet"><a href="https://drafts.csswg.org/cssom/#create-a-constructed-cssstylesheet">create a constructed <code>CSSStyleSheet</code></a></dfn></li><li><dfn id="synchronously-replace-the-rules-of-a-cssstylesheet"><a href="https://drafts.csswg.org/cssom/#synchronously-replace-the-rules-of-a-cssstylesheet">synchronously replace the rules of a <code>CSSStyleSheet</code></a></dfn></li><li><dfn id="disable-a-css-style-sheet"><a href="https://drafts.csswg.org/cssom/#disable-a-css-style-sheet">disable a CSS style sheet</a></dfn></li><li>
      <dfn id="css-style-sheet"><a href="https://drafts.csswg.org/cssom/#css-style-sheet">CSS style sheets</a></dfn> and their
      properties:
      <ul class="brief"><li><dfn id="concept-css-style-sheet-type"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-type">type</a></dfn></li><li><dfn id="concept-css-style-sheet-location"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-location">location</a></dfn></li><li><dfn id="concept-css-style-sheet-parent-css-style-sheet"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-parent-css-style-sheet">parent CSS style sheet</a></dfn></li><li><dfn id="concept-css-style-sheet-owner-node"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-owner-node">owner node</a></dfn></li><li><dfn id="concept-css-style-sheet-owner-css-rule"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-owner-css-rule">owner CSS rule</a></dfn></li><li><dfn id="concept-css-style-sheet-media"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-media">media</a></dfn></li><li><dfn id="concept-css-style-sheet-title"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-title">title</a></dfn></li><li><dfn id="concept-css-style-sheet-alternate-flag"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-alternate-flag">alternate flag</a></dfn></li><li><dfn id="concept-css-style-sheet-disabled-flag"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag">disabled flag</a></dfn></li><li><dfn id="concept-css-style-sheet-css-rules"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-css-rules">CSS rules</a></dfn></li><li><dfn id="concept-css-style-sheet-origin-clean-flag"><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-origin-clean-flag">origin-clean flag</a></dfn></li></ul>
     </li><li><dfn id="css-style-sheet-set"><a href="https://drafts.csswg.org/cssom/#css-style-sheet-set">CSS style sheet set</a></dfn></li><li><dfn id="css-style-sheet-set-name"><a href="https://drafts.csswg.org/cssom/#css-style-sheet-set-name">CSS style sheet set name</a></dfn></li><li><dfn id="preferred-css-style-sheet-set-name"><a href="https://drafts.csswg.org/cssom/#preferred-css-style-sheet-set-name">preferred CSS style sheet set name</a></dfn></li><li><dfn id="change-the-preferred-css-style-sheet-set-name"><a href="https://drafts.csswg.org/cssom/#change-the-preferred-css-style-sheet-set-name">change the preferred CSS style sheet set name</a></dfn></li><li><dfn id="serializing-a-css-value"><a href="https://drafts.csswg.org/cssom/#serialize-a-css-value">Serializing a CSS value</a></dfn></li><li><dfn id="run-the-resize-steps"><a href="https://drafts.csswg.org/cssom-view/#document-run-the-resize-steps">run the resize steps</a></dfn></li><li><dfn id="run-the-scroll-steps"><a href="https://drafts.csswg.org/cssom-view/#document-run-the-scroll-steps">run the scroll steps</a></dfn></li><li><dfn id="evaluate-media-queries-and-report-changes"><a href="https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes">evaluate media queries and report changes</a></dfn></li><li><dfn id="scroll-a-target-into-view"><a href="https://drafts.csswg.org/cssom-view/#scroll-a-target-into-view">Scroll a target into view</a></dfn></li><li><dfn id="scroll-to-the-beginning-of-the-document"><a href="https://drafts.csswg.org/cssom-view/#scroll-to-the-beginning-of-the-document">Scroll to the beginning of the document</a></dfn></li><li>The <dfn id="event-resize"><a href="https://drafts.csswg.org/cssom-view/#eventdef-window-resize"><code>resize</code></a></dfn> event</li><li>The <dfn id="event-scroll"><a href="https://drafts.csswg.org/cssom-view/#eventdef-document-scroll"><code>scroll</code></a></dfn> event</li><li>The <dfn id="event-scrollend"><a href="https://drafts.csswg.org/cssom-view/#eventdef-document-scrollend"><code>scrollend</code></a></dfn> event</li><li><dfn id="set-up-browsing-context-features"><a href="https://drafts.csswg.org/cssom-view/#set-up-browsing-context-features">set up browsing context features</a></dfn></li><li>The <dfn id="mouseevent-clientx"><a href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clientx">clientX</a></dfn> and <dfn id="mouseevent-clienty"><a href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clienty">clientY</a></dfn> extension attributes of the <a id="dependencies:mouseevent-3" href="https://w3c.github.io/uievents/#mouseevent" data-x-internal="mouseevent">MouseEvent</a> interface</li></ul>

    <p>The following features and terms are defined in <cite>CSS Syntax</cite>:
    <a href="#refsCSSSYNTAX">[CSSSYNTAX]</a></p>

    <ul class="brief"><li><dfn id="conformant-style-sheet"><a href="https://drafts.csswg.org/css-syntax/#conform-classes">conformant style sheet</a></dfn></li><li><dfn id="parse-a-list-of-component-values"><a href="https://drafts.csswg.org/css-syntax/#parse-a-list-of-component-values">parse a list of component values</a></dfn></li><li><dfn id="parse-a-comma-separated-list-of-component-values"><a href="https://drafts.csswg.org/css-syntax/#parse-a-comma-separated-list-of-component-values">parse a comma-separated list of component values</a></dfn></li><li><dfn id="component-value"><a href="https://drafts.csswg.org/css-syntax/#component-value">component value</a></dfn></li><li><dfn id="environment-encoding"><a href="https://drafts.csswg.org/css-syntax/#environment-encoding">environment encoding</a></dfn></li><li><dfn id="whitespace-token"><a href="https://drafts.csswg.org/css-syntax/#typedef-whitespace-token">&lt;whitespace-token&gt;</a></dfn></li></ul>

    <p>The following terms are defined in <cite>Selectors</cite>: <a href="#refsSELECTORS">[SELECTORS]</a></p>

    <ul class="brief"><li><dfn id="selector-list"><a href="https://drafts.csswg.org/selectors/#typedef-selector-list"><code>&lt;selector-list&gt;</code></a></dfn></li><li><dfn id="parse-a-selector"><a href="https://drafts.csswg.org/selectors/#parse-a-selector">parse a selector</a></dfn></li><li><dfn id="selector"><a href="https://drafts.csswg.org/selectors/#selector">selector</a></dfn></li><li><dfn id="type-selector"><a href="https://drafts.csswg.org/selectors/#type-selector">type selector</a></dfn></li><li><dfn id="attribute-selector"><a href="https://drafts.csswg.org/selectors/#attribute-selector">attribute selector</a></dfn></li><li><dfn id="pseudo-class"><a href="https://drafts.csswg.org/selectors/#pseudo-class">pseudo-class</a></dfn></li><li><dfn id=":focus-visible"><a href="https://drafts.csswg.org/selectors/#the-focus-visible-pseudo"><code>:focus-visible</code></a></dfn>
     pseudo-class</li><li><dfn id="indicate-focus"><a href="https://drafts.csswg.org/selectors/#indicate-focus">indicate focus</a></dfn></li><li><dfn id="pseudo-element"><a href="https://drafts.csswg.org/selectors/#pseudo-element">pseudo-element</a></dfn></li><li><dfn id="match-a-selector-against-an-element"><a href="https://drafts.csswg.org/selectors/#match-a-selector-against-an-element">match a selector against an element</a></dfn></li><li><dfn id="scoping-root"><a href="https://drafts.csswg.org/selectors/#scoping-root">scoping root</a></dfn></li></ul>

    <p>The following features are defined in <cite>CSS Values and Units</cite>:
    <a href="#refsCSSVALUES">[CSSVALUES]</a></p>

    <ul class="brief"><li><dfn id="length-2"><a href="https://drafts.csswg.org/css-values/#lengths">&lt;length&gt;</a></dfn></li><li>The <dfn id="'em'"><a href="https://drafts.csswg.org/css-values/#em">'em'</a></dfn> unit</li><li>The <dfn id="'ex'"><a href="https://drafts.csswg.org/css-values/#ex">'ex'</a></dfn> unit</li><li>The <dfn id="'vw'"><a href="https://drafts.csswg.org/css-values/#vw">'vw'</a></dfn> unit</li><li>The <dfn id="'in'"><a href="https://drafts.csswg.org/css-values/#in">'in'</a></dfn> unit</li><li>The <dfn id="'px'"><a href="https://drafts.csswg.org/css-values/#px">'px'</a></dfn> unit</li><li>The <dfn id="'pt'"><a href="https://drafts.csswg.org/css-values/#pt">'pt'</a></dfn> unit</li><li>The <dfn id="'attr()'"><a href="https://drafts.csswg.org/css-values/#funcdef-attr">'attr()'</a></dfn> function</li><li>The <dfn id="math-functions"><a href="https://drafts.csswg.org/css-values/#math-function">math functions</a></dfn></li></ul>

    <p>The following features are defined in <cite>CSS View Transitions</cite>:
    <a href="#refsCSSVIEWTRANSITIONS">[CSSVIEWTRANSITIONS]</a></p>

    <ul class="brief"><li><dfn id="perform-pending-transition-operations"><a href="https://drafts.csswg.org/css-view-transitions/#perform-pending-transition-operations">perform pending transition operations</a></dfn></li><li><dfn id="rendering-suppression-for-view-transitions"><a href="https://drafts.csswg.org/css-view-transitions/#document-rendering-suppression-for-view-transitions">rendering suppression for view transitions</a></dfn></li><li><dfn id="activate-view-transition"><a href="https://drafts.csswg.org/css-view-transitions/#activate-view-transition">activate view transition</a></dfn></li><li><dfn id="viewtransition"><a href="https://drafts.csswg.org/css-view-transitions/#viewtransition"><code>ViewTransition</code></a></dfn></li><li><dfn id="view-transition-page-visibility-change-steps"><a href="https://drafts.csswg.org/css-view-transitions/#view-transition-page-visibility-change-steps">view transition page visibility change steps</a></dfn></li><li><dfn id="resolving-inbound-cross-document-view-transition"><a href="https://drafts.csswg.org/css-view-transitions-2/#resolve-inbound-cross-document-view-transition">resolving inbound cross-document view-transition</a></dfn></li><li><dfn id="setting-up-a-cross-document-view-transition"><a href="https://drafts.csswg.org/css-view-transitions-2/#setup-cross-document-view-transition">setting up a cross-document view-transition</a></dfn></li><li><dfn id="can-navigation-trigger-a-cross-document-view-transition"><a href="https://drafts.csswg.org/css-view-transitions-2/#can-navigation-trigger-a-cross-document-view-transition">can navigation trigger a cross-document view-transition?</a></dfn>
    </li></ul>

    <p>The term <dfn id="css-styling-attribute"><a href="https://drafts.csswg.org/css-style-attr/#style-attribute">style attribute</a></dfn> is
    defined in <cite>CSS Style Attributes</cite>. <a href="#refsCSSATTR">[CSSATTR]</a></p>

    <p>The following terms are defined in the <cite>CSS Cascading and Inheritance</cite>:
    <a href="#refsCSSCASCADE">[CSSCASCADE]</a></p>

    <ul class="brief"><li><dfn id="cascaded-value"><a href="https://drafts.csswg.org/css-cascade/#cascaded-value">cascaded value</a></dfn></li><li><dfn id="specified-value"><a href="https://drafts.csswg.org/css-cascade/#specified-value">specified value</a></dfn></li><li><dfn id="computed-value"><a href="https://drafts.csswg.org/css-cascade/#computed-value">computed value</a></dfn></li><li><dfn id="used-value"><a href="https://drafts.csswg.org/css-cascade/#used-value">used value</a></dfn></li><li><dfn id="cascade-origin"><a href="https://drafts.csswg.org/css-cascade/#origin">cascade origin</a></dfn></li><li><dfn id="author-origin"><a href="https://drafts.csswg.org/css-cascade/#cascade-origin-author">Author Origin</a></dfn></li><li><dfn id="user-origin"><a href="https://drafts.csswg.org/css-cascade/#cascade-origin-user">User Origin</a></dfn></li><li><dfn id="user-agent-origin"><a href="https://drafts.csswg.org/css-cascade/#cascade-origin-ua">User Agent Origin</a></dfn></li><li><dfn id="animation-origin"><a href="https://drafts.csswg.org/css-cascade/#cascade-origin-animation">Animation Origin</a></dfn></li><li><dfn id="transition-origin"><a href="https://drafts.csswg.org/css-cascade/#cascade-origin-transition">Transition Origin</a></dfn></li><li><dfn id="initial-value"><a href="https://drafts.csswg.org/css-cascade/#initial-value">initial value</a></dfn></li></ul>

    <p>The <code id="dependencies:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> object's use of fonts depends on the features
    described in the CSS <cite>Fonts</cite> and <cite>Font Loading</cite> specifications, including
    in particular <dfn id="fontface"><code>FontFace</code></dfn> objects and the <dfn id="font-source"><a href="https://drafts.csswg.org/css-font-loading/#font-source">font source</a></dfn> concept.
    <a href="#refsCSSFONTS">[CSSFONTS]</a> <a href="#refsCSSFONTLOAD">[CSSFONTLOAD]</a></p>

    <p>The following interfaces and terms are defined in <cite>Geometry Interfaces</cite>:
    <a href="#refsGEOMETRY">[GEOMETRY]</a></p>

    <ul class="brief"><li><dfn id="dommatrix"><a href="https://drafts.fxtf.org/geometry/#dommatrix"><code>DOMMatrix</code></a></dfn> interface, and associated
         <dfn id="m11-element"><a href="https://drafts.fxtf.org/geometry/#matrix-m11-element">m11 element</a></dfn>,
         <dfn id="m12-element"><a href="https://drafts.fxtf.org/geometry/#matrix-m12-element">m12 element</a></dfn>,
         <dfn id="m21-element"><a href="https://drafts.fxtf.org/geometry/#matrix-m21-element">m21 element</a></dfn>,
         <dfn id="m22-element"><a href="https://drafts.fxtf.org/geometry/#matrix-m22-element">m22 element</a></dfn>,
         <dfn id="m41-element"><a href="https://drafts.fxtf.org/geometry/#matrix-m41-element">m41 element</a></dfn>, and
         <dfn id="m42-element"><a href="https://drafts.fxtf.org/geometry/#matrix-m42-element">m42 element</a></dfn></li><li><dfn id="dommatrix2dinit"><a href="https://drafts.fxtf.org/geometry/#dictdef-dommatrix2dinit"><code>DOMMatrix2DInit</code></a></dfn> and
         <dfn id="dommatrixinit"><a href="https://drafts.fxtf.org/geometry/#dictdef-dommatrixinit"><code>DOMMatrixInit</code></a></dfn> dictionaries</li><li>The <dfn id="create-a-dommatrix-from-a-dictionary"><a href="https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-dictionary">create a <code>DOMMatrix</code> from a dictionary</a></dfn>
         and <dfn id="create-a-dommatrix-from-a-2d-dictionary"><a href="https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-2d-dictionary">create a <code>DOMMatrix</code> from a 2D dictionary</a></dfn>
         algorithms for <code id="dependencies:dommatrix2dinit"><a data-x-internal="dommatrix2dinit" href="https://drafts.fxtf.org/geometry/#dictdef-dommatrix2dinit">DOMMatrix2DInit</a></code> or <code id="dependencies:dommatrixinit"><a data-x-internal="dommatrixinit" href="https://drafts.fxtf.org/geometry/#dictdef-dommatrixinit">DOMMatrixInit</a></code></li><li>The <dfn id="dompointinit"><a href="https://drafts.fxtf.org/geometry/#dictdef-dompointinit"><code>DOMPointInit</code></a></dfn> dictionary, and associated
         <dfn id="dompointinit-x"><a href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></dfn> and
         <dfn id="dompointinit-y"><a href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></dfn> members</li><li><dfn id="matrix-multiplication"><a href="https://drafts.fxtf.org/geometry/#matrix-multiply">Matrix multiplication</a></dfn></li></ul>

    <p>The following terms are defined in the <cite>CSS Scoping</cite>: <a href="#refsCSSSCOPING">[CSSSCOPING]</a></p>

    <ul class="brief"><li><dfn id="flat-tree"><a href="https://drafts.csswg.org/css-scoping/#flat-tree">flat tree</a></dfn></li></ul>

    <p>The following terms and features are defined in <cite>CSS Color Adjustment</cite>:
    <a href="#refsCSSCOLORADJUST">[CSSCOLORADJUST]</a></p>

    <ul class="brief"><li><dfn id="'color-scheme'"><a href="https://drafts.csswg.org/css-color-adjust/#color-scheme-prop">'color-scheme'</a></dfn></li><li><dfn id="page's-supported-color-schemes"><a href="https://drafts.csswg.org/css-color-adjust/#pages-supported-color-schemes">page's supported color-schemes</a></dfn></li></ul>

    <p>The following terms are defined in <cite>CSS Pseudo-Elements</cite>: <a href="#refsCSSPSEUDO">[CSSPSEUDO]</a></p>

    <ul class="brief"><li><dfn id="'::details-content'"><a href="https://drafts.csswg.org/css-pseudo/#details-content-pseudo">'::details-content'</a></dfn></li><li><dfn id="'::file-selector-button'"><a href="https://drafts.csswg.org/css-pseudo/#file-selector-button-pseudo">'::file-selector-button'</a></dfn></li></ul>

    <p>The following terms are defined in <cite>CSS Containment</cite>: <a href="#refsCSSCONTAIN">[CSSCONTAIN]</a></p>

    <ul class="brief"><li><dfn id="skips-its-contents"><a href="https://drafts.csswg.org/css-contain/#skips-its-contents">skips its contents</a></dfn></li><li><dfn id="relevant-to-the-user"><a href="https://drafts.csswg.org/css-contain/#relevant-to-the-user">relevant to the user</a></dfn></li><li><dfn id="proximity-to-the-viewport"><a href="https://drafts.csswg.org/css-contain/#proximity-to-the-viewport">proximity to the viewport</a></dfn></li><li><dfn id="layout-containment"><a href="https://drafts.csswg.org/css-contain/#containment-layout">layout containment</a></dfn></li><li><dfn id="'content-visibility'"><a href="https://drafts.csswg.org/css-contain/#content-visibility">'content-visibility'</a></dfn> property</li><li><dfn id="content-visibility-auto"><a href="https://drafts.csswg.org/css-contain/#propdef-content-visibility">'auto'</a></dfn> value for <a id="dependencies:'content-visibility'" href="https://drafts.csswg.org/css-contain/#content-visibility" data-x-internal="'content-visibility'">'content-visibility'</a></li></ul>

    <p>The following terms are defined in <cite>CSS Anchor Positioning</cite>: <a href="#refsCSSANCHOR">[CSSANCHOR]</a></p>

    <ul class="brief"><li><dfn id="implicit-anchor-element"><a href="https://drafts.csswg.org/css-anchor-position/#implicit-anchor-element">implicit anchor element</a></dfn></li></ul>
   </dd><dt>Intersection Observer</dt><dd>
    <p>The following term is defined in <cite>Intersection Observer</cite>:
    <a href="#refsINTERSECTIONOBSERVER">[INTERSECTIONOBSERVER]</a></p>

    <ul class="brief"><li><dfn id="run-the-update-intersection-observations-steps"><a href="https://w3c.github.io/IntersectionObserver/#run-the-update-intersection-observations-steps">run the update intersection observations steps</a></dfn></li><li><dfn id="intersectionobserver"><a href="https://w3c.github.io/IntersectionObserver/#intersectionobserver"><code>IntersectionObserver</code></a></dfn></li><li><dfn id="intersectionobserverinit"><a href="https://w3c.github.io/IntersectionObserver/#dictdef-intersectionobserverinit"><code>IntersectionObserverInit</code></a></dfn></li><li><dfn id="dom-intersectionobserver-observe"><a href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-observe"><code>observe</code></a></dfn></li><li><dfn id="dom-intersectionobserver-unobserve"><a href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-unobserve"><code>unobserve</code></a></dfn></li><li><dfn id="dom-intersectionobserverentry-isintersecting"><a href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserverentry-isintersecting"><code>isIntersecting</code></a></dfn></li><li><dfn id="dom-intersectionobserverentry-target"><a href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserverentry-target"><code>target</code></a></dfn></li></ul>
   </dd><dt>Resize Observer</dt><dd>
    <p>The following terms are defined in <cite>Resize Observer</cite>:
    <a href="#refsRESIZEOBSERVER">[RESIZEOBSERVER]</a></p>

    <ul class="brief"><li><dfn id="gather-active-resize-observations-at-depth"><a href="https://drafts.csswg.org/resize-observer-1/#gather-active-observations-h">gather active resize observations at depth</a></dfn></li><li><dfn id="has-active-resize-observations"><a href="https://drafts.csswg.org/resize-observer-1/#has-active-observations-h">has active resize observations</a></dfn></li><li><dfn id="has-skipped-resize-observations"><a href="https://drafts.csswg.org/resize-observer-1/#has-skipped-observations-h">has skipped resize observations</a></dfn></li><li><dfn id="broadcast-active-resize-observations"><a href="https://drafts.csswg.org/resize-observer-1/#broadcast-resize-notifications-h">broadcast active resize observations</a></dfn></li><li><dfn id="deliver-resize-loop-error"><a href="https://drafts.csswg.org/resize-observer-1/#deliver-resize-error">deliver resize loop error</a></dfn></li></ul>
   </dd><dt>WebGL</dt><dd>
    <p>The following interfaces are defined in the WebGL specifications: <a href="#refsWEBGL">[WEBGL]</a></p>

    <ul class="brief"><li><dfn id="webglrenderingcontext"><a href="https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContext"><code>WebGLRenderingContext</code></a></dfn> interface</li><li><dfn id="webgl2renderingcontext"><a href="https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext"><code>WebGL2RenderingContext</code></a></dfn> interface</li><li><dfn id="webglcontextattributes"><a href="https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLContextAttributes"><code>WebGLContextAttributes</code></a></dfn> dictionary</li></ul>
   </dd><dt>WebGPU</dt><dd>
    <p>The following interfaces are defined in <cite>WebGPU</cite>: <a href="#refsWEBGPU">[WEBGPU]</a></p>

    <ul class="brief"><li><dfn id="gpucanvascontext"><a href="https://gpuweb.github.io/gpuweb/#canvas-context"><code>GPUCanvasContext</code></a></dfn> interface</li></ul>
   </dd><dt>WebVTT</dt><dd>
    <p>Implementations may support WebVTT as a text track format for subtitles, captions, metadata,
    etc., for media resources. <a href="#refsWEBVTT">[WEBVTT]</a></p>

    <p>The following terms, used in this specification, are defined in <cite>WebVTT</cite>:</p>

    <ul class="brief"><li><dfn id="webvtt-file"><a href="https://w3c.github.io/webvtt/#webvtt-file">WebVTT file</a></dfn></li><li><dfn id="webvtt-file-using-cue-text"><a href="https://w3c.github.io/webvtt/#webvtt-file-using-cue-text">WebVTT file using cue text</a></dfn></li><li><dfn id="webvtt-file-using-only-nested-cues"><a href="https://w3c.github.io/webvtt/#webvtt-file-using-only-nested-cues">WebVTT file using only nested cues</a></dfn></li><li><dfn id="webvtt-parser"><a href="https://w3c.github.io/webvtt/#webvtt-parser">WebVTT parser</a></dfn></li><li>The <dfn id="rules-for-updating-the-display-of-webvtt-text-tracks"><a href="https://w3c.github.io/webvtt/#rules-for-updating-the-display-of-webvtt-text-tracks">rules for updating the display of WebVTT text tracks</a></dfn></li><li>The WebVTT <dfn id="text-track-cue-writing-direction"><a href="https://w3c.github.io/webvtt/#webvtt-cue-writing-direction">text track cue writing direction</a></dfn></li><li><dfn id="vttcue"><a href="https://w3c.github.io/webvtt/#vttcue"><code>VTTCue</code></a></dfn> interface</li></ul>
   </dd><dt>ARIA</dt><dd>
    <p>The <dfn id="attr-aria-role" data-dfn-type="element-attr"><code>role</code></dfn> attribute is defined in
    <cite>Accessible Rich Internet Applications</cite> (<cite>ARIA</cite>), as are the following
    roles: <a href="#refsARIA">[ARIA]</a></p>

    <ul class="brief"><li><dfn id="attr-aria-role-button"><a href="https://w3c.github.io/aria/#button"><code>button</code></a></dfn></li><li><dfn id="attr-aria-role-presentation"><a href="https://w3c.github.io/aria/#presentation"><code>presentation</code></a></dfn></li></ul>

    <p>In addition, the following <dfn id="attr-aria-*"><code>aria-*</code></dfn> content
    attributes are defined in <cite>ARIA</cite>: <a href="#refsARIA">[ARIA]</a></p>

    <ul class="brief"><li><dfn id="attr-aria-checked"><a href="https://w3c.github.io/aria/#aria-checked"><code>aria-checked</code></a></dfn></li><li><dfn id="attr-aria-describedby"><a href="https://w3c.github.io/aria/#aria-describedby"><code>aria-describedby</code></a></dfn></li><li><dfn id="attr-aria-disabled"><a href="https://w3c.github.io/aria/#aria-disabled"><code>aria-disabled</code></a></dfn></li><li><dfn id="attr-aria-label"><a href="https://w3c.github.io/aria/#aria-label"><code>aria-label</code></a></dfn></li><li><dfn id="attr-aria-level"><a href="https://w3c.github.io/aria/#aria-level"><code>aria-level</code></a></dfn></li></ul>

    <p>Finally, the following terms are defined in <cite>ARIA</cite>: <a href="#refsARIA">[ARIA]</a></p>

    <ul class="brief"><li><dfn id="role"><a href="https://w3c.github.io/aria/#dfn-role">role</a></dfn></li><li><dfn id="concept-accessible-name"><a href="https://w3c.github.io/aria/#dfn-accessible-name">accessible name</a></dfn></li><li>The <dfn id="ariamixin"><a href="https://w3c.github.io/aria/#ARIAMixin"><code>ARIAMixin</code></a></dfn> interface, with its associated
             <dfn id="ariamixin-getter-steps"><a href="https://w3c.github.io/aria/#dfn-ariamixin-getter-steps"><code>ARIAMixin</code> getter steps</a></dfn> and
             <dfn id="ariamixin-setter-steps"><a href="https://w3c.github.io/aria/#dfn-ariamixin-setter-steps"><code>ARIAMixin</code> setter steps</a></dfn> hooks, and its
             <dfn id="dom-ariamixin-role"><a href="https://w3c.github.io/aria/#idl-def-ariamixin-role"><code>role</code></a></dfn> and
             <dfn id="dom-ariamixin-aria*"><a href="https://w3c.github.io/aria/#idl-def-ariamixin-ariaactivedescendantelement"><code>aria*</code></a></dfn> attributes</li></ul>
   </dd><dt>Content Security Policy</dt><dd>
    <p>The following terms are defined in <cite>Content Security Policy</cite>: <a href="#refsCSP">[CSP]</a></p>

    <ul class="brief"><li><dfn id="content-security-policy"><a href="https://w3c.github.io/webappsec-csp/#content-security-policy-object">Content Security Policy</a></dfn></li><li><dfn id="csp-disposition"><a href="https://w3c.github.io/webappsec-csp/#policy-disposition">disposition</a></dfn></li><li><dfn id="csp-directive-set"><a href="https://w3c.github.io/webappsec-csp/#policy-directive-set">directive set</a></dfn></li><li><dfn id="content-security-policy-directive"><a href="https://w3c.github.io/webappsec-csp/#directives">Content Security Policy directive</a></dfn></li><li><dfn id="concept-csp-list"><a href="https://w3c.github.io/webappsec-csp/#csp-list">CSP list</a></dfn></li><li>The <dfn id="content-security-policy-syntax"><a href="https://w3c.github.io/webappsec-csp/#grammardef-serialized-policy">Content Security Policy syntax</a></dfn></li><li><dfn id="enforce-the-policy"><a href="https://w3c.github.io/webappsec-csp/#enforced">enforce the policy</a></dfn></li><li>The <dfn id="parse-a-serialized-content-security-policy"><a href="https://w3c.github.io/webappsec-csp/#parse-serialized-policy">parse a serialized Content Security Policy</a></dfn> algorithm</li><li>The <dfn id="run-csp-initialization-for-a-document"><a href="https://w3c.github.io/webappsec-csp/#run-document-csp-initialization">Run CSP initialization for a Document</a></dfn> algorithm</li><li>The <dfn id="run-csp-initialization-for-a-global-object"><a href="https://w3c.github.io/webappsec-csp/#run-global-object-csp-initialization">Run CSP initialization for a global object</a></dfn> algorithm</li><li>The <dfn id="should-element's-inline-behavior-be-blocked-by-content-security-policy"><a href="https://w3c.github.io/webappsec-csp/#should-block-inline">Should element's inline behavior be blocked by Content Security Policy?</a></dfn> algorithm</li><li>The <dfn id="should-navigation-request-of-type-be-blocked-by-content-security-policy"><a href="https://w3c.github.io/webappsec-csp/#should-block-navigation-request">Should navigation request of type be blocked by Content Security Policy?</a></dfn> algorithm</li><li>The <dfn id="should-navigation-response-to-navigation-request-of-type-in-target-be-blocked-by-content-security-policy"><a href="https://w3c.github.io/webappsec-csp/#should-block-navigation-response">Should navigation response to navigation request of type in target be blocked by Content Security Policy?</a></dfn> algorithm</li><li>The <dfn id="report-uri-directive"><a href="https://w3c.github.io/webappsec-csp/#report-uri"><code>report-uri</code> directive</a></dfn></li><li>The <dfn id="csp-ensurecspdoesnotblockstringcompilation"><a href="https://w3c.github.io/webappsec-csp/#can-compile-strings">EnsureCSPDoesNotBlockStringCompilation</a></dfn> abstract operation</li><li>The <dfn id="is-base-allowed-for-document"><a href="https://w3c.github.io/webappsec-csp/#allow-base-for-document">Is base allowed for Document?</a></dfn> algorithm</li><li>The <dfn id="frame-ancestors-directive"><a href="https://w3c.github.io/webappsec-csp/#frame-ancestors"><code>frame-ancestors</code> directive</a></dfn></li><li>The <dfn id="sandbox-directive"><a href="https://w3c.github.io/webappsec-csp/#sandbox"><code>sandbox</code> directive</a></dfn></li><li>The <dfn id="contains-a-header-delivered-content-security-policy"><a href="https://w3c.github.io/webappsec-csp/#contains-a-header-delivered-content-security-policy">contains a header-delivered Content Security Policy</a></dfn> property.</li><li>The <dfn id="parse-response-csp"><a href="https://w3c.github.io/webappsec-csp/#parse-response-csp">Parse a response's Content Security Policies</a></dfn> algorithm.</li><li><dfn id="securitypolicyviolationevent"><a href="https://w3c.github.io/webappsec-csp/#securitypolicyviolationevent"><code>SecurityPolicyViolationEvent</code></a></dfn> interface</li><li>The <dfn id="event-securitypolicyviolation"><a href="https://w3c.github.io/webappsec-csp/#eventdef-globaleventhandlers-securitypolicyviolation"><code>securitypolicyviolation</code></a></dfn> event</li></ul>
   </dd><dt>Service Workers</dt><dd>
    <p>The following terms are defined in <cite>Service Workers</cite>: <a href="#refsSW">[SW]</a></p>

    <ul class="brief"><li><dfn id="dfn-active-worker"><a href="https://w3c.github.io/ServiceWorker/#dfn-active-worker">active worker</a></dfn></li><li><dfn id="dfn-client-message-queue"><a href="https://w3c.github.io/ServiceWorker/#dfn-client-message-queue">client message queue</a></dfn></li><li><dfn id="dfn-control"><a href="https://w3c.github.io/ServiceWorker/#dfn-control">control</a></dfn></li><li><dfn id="on-fetch-request-algorithm"><a href="https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm">handle fetch</a></dfn></li><li><dfn id="scope-match-algorithm"><a href="https://w3c.github.io/ServiceWorker/#scope-match-algorithm">match service worker registration</a></dfn></li><li><dfn id="dfn-service-worker"><a href="https://w3c.github.io/ServiceWorker/#dfn-service-worker">service worker</a></dfn></li><li><dfn id="serviceworkercontainer-service-worker-client"><a href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client">service worker client</a></dfn></li><li><dfn id="service-worker-registration"><a href="https://w3c.github.io/service-workers/#dfn-service-worker-registration">service worker registration</a></dfn></li><li><dfn id="serviceworker"><a href="https://w3c.github.io/ServiceWorker/#serviceworker"><code>ServiceWorker</code></a></dfn> interface</li><li><dfn id="serviceworkercontainer"><a href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer"><code>ServiceWorkerContainer</code></a></dfn> interface</li><li><dfn id="serviceworkerglobalscope"><a href="https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope"><code>ServiceWorkerGlobalScope</code></a></dfn> interface</li><li><dfn id="service-worker-unregister"><a href="https://w3c.github.io/service-workers/#navigator-service-worker-unregister"><code>unregister</code></a></dfn></li></ul>
   </dd><dt>Secure Contexts</dt><dd>
    <p>The following algorithms are defined in <cite>Secure Contexts</cite>:
    <a href="#refsSECURE-CONTEXTS">[SECURE-CONTEXTS]</a></p>

    <ul class="brief"><li><dfn id="is-url-potentially-trustworthy"><a href="https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url">Is url potentially trustworthy?</a></dfn></li></ul>
   </dd><dt>Permissions Policy</dt><dd>
    <p>The following terms are defined in <cite>Permissions Policy</cite>:
    <a href="#refsPERMISSIONSPOLICY">[PERMISSIONSPOLICY]</a></p>

    <ul class="brief"><li><dfn id="concept-permissions-policy"><a href="https://w3c.github.io/webappsec-feature-policy/#permissions-policy">permissions policy</a></dfn></li><li><dfn id="concept-policy-controlled-feature"><a href="https://w3c.github.io/webappsec-feature-policy/#policy-controlled-feature">policy-controlled feature</a></dfn></li><li><dfn id="concept-container-policy"><a href="https://w3c.github.io/webappsec-feature-policy/#container-policy">container policy</a></dfn></li><li><dfn id="concept-serialized-permissions-policy"><a href="https://w3c.github.io/webappsec-feature-policy/#serialized-permissions-policy">serialized permissions policy</a></dfn></li><li><dfn id="concept-default-allowlist"><a href="https://w3c.github.io/webappsec-feature-policy/#default-allowlist">default allowlist</a></dfn></li><li>The <dfn id="creating-a-permissions-policy"><a href="https://w3c.github.io/webappsec-feature-policy/#create-for-navigable">creating a permissions policy</a></dfn> algorithm</li><li>The <dfn id="creating-a-permissions-policy-from-a-response"><a href="https://w3c.github.io/webappsec-feature-policy/#create-from-response">creating a permissions policy from a response</a></dfn> algorithm</li><li>The <dfn id="is-feature-enabled"><a href="https://w3c.github.io/webappsec-feature-policy/#is-feature-enabled">is feature enabled by policy for origin</a></dfn> algorithm</li><li>The <dfn id="process-permissions-policy-attributes"><a href="https://w3c.github.io/webappsec-feature-policy/#process-permissions-policy-attributes">process permissions policy attributes</a></dfn> algorithm</li></ul>
   </dd><dt>Payment Request API</dt><dd>
    <p>The following feature is defined in <cite>Payment Request API</cite>:
    <a href="#refsPAYMENTREQUEST">[PAYMENTREQUEST]</a></p>

    <ul class="brief"><li><dfn id="paymentrequest"><a href="https://w3c.github.io/payment-request/#dom-paymentrequest"><code>PaymentRequest</code></a></dfn> interface</li></ul>
   </dd><dt>MathML</dt><dd>
    <p>While support for MathML as a whole is not required by this specification (though it is
    encouraged, at least for web browsers), certain features depend upon small parts of MathML being
    implemented. <a href="#refsMATHML">[MATHML]</a></p>

    <p>The following features are defined in <cite>Mathematical Markup Language</cite>
    (<cite>MathML</cite>):</p>

    <ul class="brief"><li><dfn id="mathml-annotation-xml"><a href="https://w3c.github.io/mathml-core/#dfn-annotation-xml">MathML <code>annotation-xml</code></a></dfn> element</li><li><dfn id="mathml-math"><a href="https://w3c.github.io/mathml-core/#the-top-level-math-element">MathML <code>math</code></a></dfn> element</li><li><dfn id="mathml-merror"><a href="https://w3c.github.io/mathml-core/#error-message-merror">MathML <code>merror</code></a></dfn> element</li><li><dfn id="mathml-mi"><a href="https://w3c.github.io/mathml-core/#the-mi-element">MathML <code>mi</code></a></dfn> element</li><li><dfn id="mathml-mn"><a href="https://w3c.github.io/mathml-core/#number-mn">MathML <code>mn</code></a></dfn> element</li><li><dfn id="mathml-mo"><a href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo">MathML <code>mo</code></a></dfn> element</li><li><dfn id="mathml-ms"><a href="https://w3c.github.io/mathml-core/#string-literal-ms">MathML <code>ms</code></a></dfn> element</li><li><dfn id="mathml-mtext"><a href="https://w3c.github.io/mathml-core/#text-mtext">MathML <code>mtext</code></a></dfn> element</li></ul>
   </dd><dt>SVG</dt><dd>
    <p>While support for SVG as a whole is not required by this specification (though it is
    encouraged, at least for web browsers), certain features depend upon parts of SVG being
    implemented.</p>

    <p>User agents that implement SVG must implement the <cite>SVG 2</cite> specification, and not
    any earlier revisions.</p>

    <p>The following features are defined in the <cite>SVG 2</cite> specification:
    <a href="#refsSVG">[SVG]</a></p>

    <ul class="brief"><li><dfn id="svgelement"><a href="https://svgwg.org/svg2-draft/types.html#InterfaceSVGElement"><code>SVGElement</code></a></dfn> interface</li><li><dfn id="svgimageelement"><a href="https://svgwg.org/svg2-draft/embedded.html#InterfaceSVGImageElement"><code>SVGImageElement</code></a></dfn> interface</li><li><dfn id="svgscriptelement"><a href="https://svgwg.org/svg2-draft/interact.html#InterfaceSVGScriptElement"><code>SVGScriptElement</code></a></dfn> interface</li><li><dfn id="svgsvgelement"><a href="https://svgwg.org/svg2-draft/struct.html#InterfaceSVGSVGElement"><code>SVGSVGElement</code></a></dfn> interface</li><li><dfn id="svg-a"><a href="https://svgwg.org/svg2-draft/linking.html#AElement">SVG <code>a</code></a></dfn> element</li><li><dfn id="svg-desc"><a href="https://svgwg.org/svg2-draft/struct.html#DescElement">SVG <code>desc</code></a></dfn> element</li><li><dfn id="svg-foreignobject"><a href="https://svgwg.org/svg2-draft/embedded.html#ForeignObjectElement">SVG <code>foreignObject</code></a></dfn> element</li><li><dfn id="svg-image"><a href="https://svgwg.org/svg2-draft/embedded.html#ImageElement">SVG <code>image</code></a></dfn> element</li><li><dfn id="svg-script"><a href="https://svgwg.org/svg2-draft/interact.html#ScriptElement">SVG <code>script</code></a></dfn> element</li><li><dfn id="svg-svg"><a href="https://svgwg.org/svg2-draft/struct.html#SVGElement">SVG <code>svg</code></a></dfn> element</li><li><dfn id="svg-title"><a href="https://svgwg.org/svg2-draft/struct.html#TitleElement">SVG <code>title</code></a></dfn> element</li><li><dfn id="svg-use"><a href="https://svgwg.org/svg2-draft/struct.html#UseElement">SVG <code>use</code></a></dfn> element</li><li><dfn id="svg-text-rendering"><a href="https://svgwg.org/svg2-draft/painting.html#TextRendering">SVG <code>text-rendering</code></a></dfn> property</li></ul>
   </dd><dt>Filter Effects</dt><dd>
    <p>The following features are defined in <cite>Filter Effects</cite>: <a href="#refsFILTERS">[FILTERS]</a></p>

    <ul class="brief"><li><dfn id="filter-value-list"><a href="https://drafts.fxtf.org/filter-effects/#typedef-filter-value-list">&lt;filter-value-list&gt;</a></dfn></li></ul>
   </dd><dt>Compositing</dt><dd>
    <p>The following features are defined in <cite>Compositing and Blending</cite>:
    <a href="#refsCOMPOSITE">[COMPOSITE]</a></p>

    <ul class="brief"><li><dfn id="blend-mode"><a href="https://drafts.fxtf.org/compositing/#ltblendmodegt">&lt;blend-mode&gt;</a></dfn></li><li><dfn id="composite-mode"><a href="https://drafts.fxtf.org/compositing/#compositemode">&lt;composite-mode&gt;</a></dfn></li><li><dfn id="gcop-source-over"><a href="https://drafts.fxtf.org/compositing/#porterduffcompositingoperators_srcover">source-over</a></dfn></li><li><dfn id="gcop-copy"><a href="https://drafts.fxtf.org/compositing/#porterduffcompositingoperators_src">copy</a></dfn></li></ul>
   </dd><dt>Cooperative Scheduling of Background Tasks</dt><dd>
    <p>The following features are defined in <cite>Cooperative Scheduling of Background
    Tasks</cite>: <a href="#refsREQUESTIDLECALLBACK">[REQUESTIDLECALLBACK]</a></p>

    <ul class="brief"><li><dfn id="requestidlecallback()"><a href="https://w3c.github.io/requestidlecallback/#the-requestidlecallback-method"><code>requestIdleCallback()</code></a></dfn></li><li><dfn id="start-an-idle-period-algorithm"><a href="https://w3c.github.io/requestidlecallback/#start-an-idle-period-algorithm">start an idle period algorithm</a></dfn></li></ul>
   </dd><dt>Screen Orientation</dt><dd>
    <p>The following terms are defined in <cite>Screen Orientation</cite>:
    <a href="#refsSCREENORIENTATION">[SCREENORIENTATION]</a></p>

    <ul><li><dfn id="screen-orientation-change-steps"><a href="https://w3c.github.io/screen-orientation/#dfn-screen-orientation-change-steps">screen orientation change steps</a></dfn></li></ul>
   </dd><dt>Storage</dt><dd>
    <p>The following terms are defined in <cite>Storage</cite>: <a href="#refsSTORAGE">[STORAGE]</a></p>

    <ul class="brief"><li><dfn id="storage-key"><a href="https://storage.spec.whatwg.org/#storage-key">storage key</a></dfn></li><li><dfn id="obtain-a-local-storage-bottle-map"><a href="https://storage.spec.whatwg.org/#obtain-a-local-storage-bottle-map">obtain a local storage bottle map</a></dfn></li><li><dfn id="obtain-a-session-storage-bottle-map"><a href="https://storage.spec.whatwg.org/#obtain-a-session-storage-bottle-map">obtain a session storage bottle map</a></dfn></li><li><dfn id="obtain-a-storage-key-for-non-storage-purposes"><a href="https://storage.spec.whatwg.org/#obtain-a-storage-key-for-non-storage-purposes">obtain a storage key for non-storage purposes</a></dfn></li><li><dfn id="storage-key-equal"><a href="https://storage.spec.whatwg.org/#storage-key-equal">storage key equal</a></dfn></li><li><dfn id="storage-proxy-map"><a href="https://storage.spec.whatwg.org/#storage-proxy-map">storage proxy map</a></dfn></li><li><dfn id="legacy-clone-a-traversable-storage-shed"><a href="https://storage.spec.whatwg.org/#legacy-clone-a-traversable-storage-shed">legacy-clone a traversable storage shed</a></dfn></li></ul>
   </dd><dt>Web App Manifest</dt><dd>
    <p>The following features are defined in <cite>Web App Manifest</cite>: <a href="#refsMANIFEST">[MANIFEST]</a></p>

    <ul class="brief"><li><dfn id="application-manifest"><a href="https://w3c.github.io/manifest/#dfn-manifest">application manifest</a></dfn></li><li><dfn id="installed-web-application"><a href="https://w3c.github.io/manifest/#dfn-installed-web-application">installed web application</a></dfn></li><li><dfn id="process-the-manifest"><a href="https://w3c.github.io/manifest/#dfn-processing-a-manifest">process the manifest</a></dfn></li></ul>
   </dd><dt>WebAssembly JavaScript Interface: ESM Integration</dt><dd>
    <p>The following terms are defined in <cite>WebAssembly JavaScript Interface: ESM Integration</cite>: <a href="#refsWASMESM">[WASMESM]</a></p>

    <ul class="brief"><li><dfn id="webassembly-module-record"><a href="https://webassembly.github.io/esm-integration/js-api/index.html#webassembly-module-record">WebAssembly Module Record</a></dfn></li><li><dfn id="parse-a-webassembly-module"><a href="https://webassembly.github.io/esm-integration/js-api/index.html#parse-a-webassembly-module">parse a WebAssembly module</a></dfn></li></ul>
   </dd><dt>WebCodecs</dt><dd>
    <p>The following features are defined in <cite>WebCodecs</cite>: <a href="#refsWEBCODECS">[WEBCODECS]</a></p>

    <ul class="brief"><li><dfn id="videoframe"><a href="https://w3c.github.io/webcodecs/#videoframe-interface"><code>VideoFrame</code></a></dfn> interface.</li><li><dfn id="display-width"><a href="https://w3c.github.io/webcodecs/#dom-videoframe-display-width-slot">[[display width]]</a></dfn></li><li><dfn id="display-height"><a href="https://w3c.github.io/webcodecs/#dom-videoframe-display-height-slot">[[display height]]</a></dfn></li></ul>
   </dd><dt>WebDriver</dt><dd>
    <p>The following terms are defined in <cite>WebDriver</cite>: <a href="#refsWEBDRIVER">[WEBDRIVER]</a></p>

    <ul class="brief"><li><dfn id="extension-command"><a href="https://w3c.github.io/webdriver/#dfn-extension-commands">extension command</a></dfn></li><li><dfn id="remote-end-steps"><a href="https://w3c.github.io/webdriver/#dfn-remote-end-steps">remote end steps</a></dfn></li><li><dfn id="webdriver-error"><a href="https://w3c.github.io/webdriver/#dfn-errors">WebDriver error</a></dfn></li><li><dfn id="webdriver-error-code"><a href="https://w3c.github.io/webdriver/#dfn-error-code">WebDriver error code</a></dfn></li><li><dfn id="invalid-argument"><a href="https://w3c.github.io/webdriver/#dfn-invalid-argument">invalid argument</a></dfn></li><li><dfn id="getting-a-property"><a href="https://w3c.github.io/webdriver/#dfn-getting-properties">getting a property</a></dfn></li><li><dfn id="success-value"><a href="https://w3c.github.io/webdriver/#dfn-success">success</a></dfn></li><li><dfn id="webdriver's-security-considerations"><a href="https://w3c.github.io/webdriver/#security">WebDriver's security considerations</a></dfn></li><li><dfn id="webdriver-current-browsing-context"><a href="https://w3c.github.io/webdriver/#dfn-current-browsing-context">current browsing context</a></dfn></li></ul>
   </dd><dt>WebDriver BiDi</dt><dd>
    <p>The following terms are defined in <cite>WebDriver BiDi</cite>: <a href="#refsWEBDRIVERBIDI">[WEBDRIVERBIDI]</a></p>

    <ul class="brief"><li><dfn id="webdriver-bidi-navigation-status"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a></dfn></li><li><dfn id="navigation-status-id"><a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id">navigation status id</a></dfn></li><li><dfn id="navigation-status-status"><a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status">navigation status status</a></dfn></li><li><dfn id="navigation-status-canceled"><a href="https://w3c.github.io/webdriver-bidi/#navigation-status-canceled">navigation status canceled</a></dfn></li><li><dfn id="navigation-status-committed"><a href="https://w3c.github.io/webdriver-bidi/#navigation-status-committed">navigation status committed</a></dfn></li><li><dfn id="navigation-status-pending"><a href="https://w3c.github.io/webdriver-bidi/#navigation-status-pending">navigation status pending</a></dfn></li><li><dfn id="navigation-status-complete"><a href="https://w3c.github.io/webdriver-bidi/#navigation-status-complete">navigation status complete</a></dfn></li><li><dfn id="navigation-status-url"><a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url">navigation status url</a></dfn></li><li><dfn id="navigation-status-suggested-filename"><a href="https://w3c.github.io/webdriver-bidi/#navigation-status-suggested-filename">navigation status suggested filename</a></dfn></li><li><dfn id="download-behavior-struct-allowed"><a href="https://w3c.github.io/webdriver-bidi/#download-behavior-struct-allowed">download behavior allowed</a></dfn></li><li><dfn id="download-behavior-struct-destination-folder"><a href="https://w3c.github.io/webdriver-bidi/#download-behavior-struct-destination-folder">download behavior destination folder</a></dfn></li><li><dfn id="navigation-status-downloaded-filepath"><a href="https://w3c.github.io/webdriver-bidi/#navigation-status-downloaded-filepath">navigation status downloaded filepath</a></dfn></li><li><dfn id="webdriver-bidi-navigation-aborted"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-aborted">WebDriver BiDi navigation aborted</a></dfn></li><li><dfn id="webdriver-bidi-navigation-committed"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-committed">WebDriver BiDi navigation committed</a></dfn></li><li><dfn id="webdriver-bidi-navigation-failed"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-failed">WebDriver BiDi navigation failed</a></dfn></li><li><dfn id="webdriver-bidi-navigation-started"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-started">WebDriver BiDi navigation started</a></dfn></li><li><dfn id="webdriver-bidi-download-end"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-download-end">WebDriver BiDi download end</a></dfn></li><li><dfn id="webdriver-bidi-download-will-begin"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-download-will-begin">WebDriver BiDi download will begin</a></dfn></li><li><dfn id="webdriver-bidi-fragment-navigated"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-fragment-navigated">WebDriver BiDi fragment navigated</a></dfn></li><li><dfn id="webdriver-bidi-dom-content-loaded"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-dom-content-loaded">WebDriver BiDi DOM content loaded</a></dfn></li><li><dfn id="webdriver-bidi-load-complete"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-load-complete">WebDriver BiDi load complete</a></dfn></li><li><dfn id="webdriver-bidi-history-updated"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-history-updated">WebDriver BiDi history updated</a></dfn></li><li><dfn id="webdriver-bidi-navigable-created"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-created">WebDriver BiDi navigable created</a></dfn></li><li><dfn id="webdriver-bidi-navigable-destroyed"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-destroyed">WebDriver BiDi navigable destroyed</a></dfn></li><li><dfn id="webdriver-bidi-user-prompt-closed"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-closed">WebDriver BiDi user prompt closed</a></dfn></li><li><dfn id="webdriver-bidi-user-prompt-opened"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-opened">WebDriver BiDi user prompt opened</a></dfn></li><li><dfn id="webdriver-bidi-file-dialog-opened"><a href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-file-dialog-opened">WebDriver BiDi file dialog opened</a></dfn></li></ul>
   </dd><dt>Web Cryptography API</dt><dd>
    <p>The following terms are defined in <cite>Web Cryptography API</cite>:
    <a href="#refsWEBCRYPTO">[WEBCRYPTO]</a></p>

    <ul class="brief"><li><dfn id="generating-a-random-uuid"><a href="https://w3c.github.io/webcrypto/#dfn-generate-a-random-uuid">generating a random UUID</a></dfn></li></ul>
   </dd><dt>WebSockets</dt><dd>
    <p>The following terms are defined in <cite>WebSockets</cite>: <a href="#refsWEBSOCKETS">[WEBSOCKETS]</a></p>

    <ul class="brief"><li><dfn id="websocket-2"><a href="https://websockets.spec.whatwg.org/#websocket"><code>WebSocket</code></a></dfn></li><li><dfn data-dfn-for="WebSocket" id="make-disappear"><a href="https://websockets.spec.whatwg.org/#make-disappear">make disappear</a></dfn></li></ul>
   </dd><dt>WebTransport</dt><dd>
    <p>The following terms are defined in <cite>WebTransport</cite>: <a href="#refsWEBTRANSPORT">[WEBTRANSPORT]</a></p>

    <ul class="brief"><li><dfn id="webtransport"><a href="https://w3c.github.io/webtransport/#webtransport"><code>WebTransport</code></a></dfn></li><li><dfn id="context-cleanup-steps"><a href="https://w3c.github.io/webtransport/#context-cleanup-steps"><code>context cleanup steps</code></a></dfn></li></ul>
   </dd><dt>Web Authentication: An API for accessing Public Key Credentials</dt><dd>
    <p>The following terms are defined in <cite>Web Authentication: An API for accessing Public Key
    Credentials</cite>: <a href="#refsWEBAUTHN">[WEBAUTHN]</a></p>

    <ul class="brief"><li><dfn id="public-key-credential"><a href="https://w3c.github.io/webauthn/#public-key-credential">public key credential</a></dfn></li></ul>
   </dd><dt>Credential Management</dt><dd>
    <p>The following terms are defined in <cite>Credential Management</cite>: <a href="#refsCREDMAN">[CREDMAN]</a></p>

    <ul class="brief"><li><dfn id="conditional-mediation"><a href="https://w3c.github.io/webappsec-credential-management/#dom-credentialmediationrequirement-conditional">conditional mediation</a></dfn></li><li><dfn id="credman-credential"><a href="https://w3c.github.io/webappsec-credential-management/#credential">credential</a></dfn></li><li><dfn id="navigator.credentials.get()"><a href="https://w3c.github.io/webappsec-credential-management/#dom-credentialscontainer-get"><code>navigator.credentials.get()</code></a></dfn></li></ul>
   </dd><dt>Console</dt><dd>
    <p>The following terms are defined in <cite>Console</cite>: <a href="#refsCONSOLE">[CONSOLE]</a></p>

    <ul class="brief"><li><dfn id="report-a-warning-to-the-console"><a href="https://console.spec.whatwg.org/#report-a-warning-to-the-console">report a warning to the console</a></dfn></li></ul>
   </dd><dt>Web Locks API</dt><dd>
    <p>The following terms are defined in <cite>Web Locks API</cite>: <a href="#refsWEBLOCKS">[WEBLOCKS]</a></p>

    <ul class="brief"><li><dfn id="locks"><a href="https://w3c.github.io/web-locks/#lock-concept">locks</a></dfn></li><li><dfn id="lock-requests"><a href="https://w3c.github.io/web-locks/#lock-request">lock requests</a></dfn></li></ul>
   </dd><dt>Trusted Types</dt><dd>
    <p>This specification uses the following features defined in <cite>Trusted Types</cite>:
    <a href="#refsTRUSTED-TYPES">[TRUSTED-TYPES]</a></p>

    <ul class="brief"><li><dfn id="tt-trustedhtml"><a href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><code>TrustedHTML</code></a></dfn></li><li><dfn id="tt-trustedhtml-data"><a href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml-data">data</a></dfn></li><li><dfn id="tt-trustedscript"><a href="https://w3c.github.io/trusted-types/dist/spec/#trusted-script"><code>TrustedScript</code></a></dfn></li><li><dfn id="tt-trustedscript-data"><a href="https://w3c.github.io/trusted-types/dist/spec/#trustedscript-data"><code>data</code></a></dfn></li><li><dfn id="tt-trustedscripturl"><a href="https://w3c.github.io/trusted-types/dist/spec/#trustedscripturl"><code>TrustedScriptURL</code></a></dfn></li><li><dfn id="tt-getcompliantstring"><a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm">Get Trusted Type compliant string</a></dfn></li></ul>
   </dd><dt>WebRTC API</dt><dd>
    <p>The following terms are defined in <cite>WebRTC API</cite>: <a href="#refsWEBRTC">[WEBRTC]</a></p>

    <ul class="brief"><li><dfn id="rtcdatachannel"><a href="https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel"><code>RTCDataChannel</code></a></dfn></li><li><dfn id="rtcpeerconnection"><a href="https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection"><code>RTCPeerConnection</code></a></dfn></li></ul>
   </dd><dt>Picture-in-Picture API</dt><dd>
    <p>The following terms are defined in <cite>Picture-in-Picture API</cite>: <a href="#refsPICTUREINPICTURE">[PICTUREINPICTURE]</a></p>

    <ul class="brief"><li><dfn id="pictureinpicturewindow"><a href="https://w3c.github.io/picture-in-picture/#pictureinpicturewindow"><code>PictureInPictureWindow</code></a></dfn></li></ul>
   </dd><dt>Idle Detection API</dt><dd>
    <p>The following terms are defined in <cite>Idle Detection API</cite>:</p>

    <ul class="brief"><li><dfn id="idledetector"><a href="https://wicg.github.io/idle-detection/#idledetector"><code>IdleDetector</code></a></dfn></li></ul>
   </dd><dt>Web Speech API</dt><dd>
    <p>The following terms are defined in <cite>Web Speech API</cite>:</p>

    <ul class="brief"><li><dfn id="speechrecognition"><a href="https://wicg.github.io/speech-api/#speechrecognition"><code>SpeechRecognition</code></a></dfn></li></ul>
   </dd><dt>WebOTP API</dt><dd>
    <p>The following terms are defined in <cite>WebOTP API</cite>:</p>

    <ul class="brief"><li><dfn id="otpcredential"><a href="https://wicg.github.io/web-otp/#otpcredential"><code>OTPCredential</code></a></dfn></li></ul>
   </dd><dt>Web Share API</dt><dd>
   <p>The following terms are defined in <cite>Web Share API</cite>:</p>

   <ul class="brief"><li><dfn id="dom-navigator-share"><a href="https://w3c.github.io/web-share/#share-method">share()</a></dfn></li></ul>
  </dd><dt>Web Smart Card API</dt><dd>
   <p>The following terms are defined in <cite>Web Smart Card API</cite>:</p>

   <ul class="brief"><li><dfn id="smartcardconnection"><a href="https://wicg.github.io/web-smart-card/#dom-smartcardconnection"><code>SmartCardConnection</code></a></dfn></li></ul>
  </dd><dt>Web Background Synchronization</dt><dd>
   <p>The following terms are defined in <cite>Web Background Synchronization</cite>:</p>

   <ul class="brief"><li><dfn id="syncmanager"><a href="https://wicg.github.io/background-sync/spec/#syncmanager"><code>SyncManager</code></a></dfn></li><li><dfn id="dom-syncmanager-register"><a href="https://wicg.github.io/background-sync/spec/#dom-syncmanager-register"><code>register()</code></a></dfn></li></ul>
  </dd><dt>Web Periodic Background Synchronization</dt><dd>
   <p>The following terms are defined in <cite>Web Periodic Background Synchronization</cite>:</p>

   <ul class="brief"><li><dfn id="periodicsyncmanager"><a href="https://wicg.github.io/periodic-background-sync/#periodicsyncmanager"><code>PeriodicSyncManager</code></a></dfn></li><li><dfn id="dom-periodicsyncmanager-register"><a href="https://wicg.github.io/periodic-background-sync/#dom-periodicsyncmanager-register"><code>register()</code></a></dfn></li></ul>
  </dd><dt>Web Background Fetch</dt><dd>
   <p>The following terms are defined in <cite>Background Fetch</cite>:</p>

   <ul class="brief"><li><dfn id="backgroundfetchmanager"><a href="https://wicg.github.io/background-fetch/#backgroundfetchmanager"><code>BackgroundFetchManager</code></a></dfn></li><li><dfn id="dom-backgroundfetchmanager-fetch"><a href="https://wicg.github.io/background-fetch/#dom-backgroundfetchmanager-fetch"><code>fetch()</code></a></dfn></li></ul>
  </dd><dt>Keyboard Lock</dt><dd>
   <p>The following terms are defined in <cite>Keyboard Lock</cite>:</p>

   <ul class="brief"><li><dfn id="keyboard"><a href="https://wicg.github.io/keyboard-lock/#keyboard"><code>Keyboard</code></a></dfn></li><li><dfn id="dom-keyboard-lock"><a href="https://wicg.github.io/keyboard-lock/#dom-keyboard-lock"><code>lock()</code></a></dfn></li></ul>
  </dd><dt>Web MIDI API</dt><dd>
   <p>The following terms are defined in <cite>Web MIDI API</cite>:</p>

   <ul class="brief"><li><dfn id="dom-navigator-requestmidiaccess"><a href="https://webaudio.github.io/web-midi-api/#dom-navigator-requestmidiaccess"><code>requestMIDIAccess()</code></a></dfn></li></ul>
  </dd><dt>Generic Sensor API</dt><dd>
   <p>The following terms are defined in <cite>Generic Sensor API</cite>:</p>

   <ul class="brief"><li><dfn id="request-sensor-access"><a href="https://w3c.github.io/sensors/#request-sensor-access">request sensor access</a></dfn></li></ul>
  </dd><dt>WebHID API</dt><dd>
   <p>The following terms are defined in <cite>WebHID API</cite>:</p>

   <ul class="brief"><li><dfn id="request-device"><a href="https://wicg.github.io/webhid/#requestdevice-method"><code>requestDevice</code></a></dfn></li></ul>
  </dd><dt>WebXR Device API</dt><dd>
   <p>The following terms are defined in <cite>WebXR Device API</cite>:</p>

   <ul class="brief"><li><dfn id="xrsystem"><a href="https://immersive-web.github.io/webxr/#xrsystem"><code>XRSystem</code></a></dfn></li></ul>
  </dd></dl>

  <hr>

  <p>This specification does not <em>require</em> support of any particular network protocol, style
  sheet language, scripting language, or any of the DOM specifications beyond those required in the
  list above. However, the language described by this specification is biased towards CSS as the
  styling language, JavaScript as the scripting language, and HTTP as the network protocol, and
  several features assume that those languages and protocols are in use.</p>

  <p>A user agent that implements the HTTP protocol must implement <cite>HTTP State Management
  Mechanism</cite> (Cookies) as well. <a href="#refsHTTP">[HTTP]</a> <a href="#refsCOOKIES">[COOKIES]</a></p>

  <p class="note">This specification might have certain additional requirements on character
  encodings, image formats, audio formats, and video formats in the respective sections.</p>

  </div>




  <h4 id="extensibility-2"><span class="secno">2.1.10</span> Extensibility<a href="#extensibility-2" class="self-link"></a></h4>

  <p>Vendor-specific proprietary user agent extensions to this specification are strongly
  discouraged. Documents must not use such extensions, as doing so reduces interoperability and
  fragments the user base, allowing only users of specific user agents to access the content in
  question.</p>

  

  <p>All extensions must be defined so that the use of extensions neither contradicts nor causes the
  non-conformance of functionality defined in the specification.</p> 

  <div class="example">

   <p>For example, while strongly discouraged from doing so, an implementation could add a new IDL
   attribute "<code>typeTime</code>" to a control that returned the time it took the user
   to select the current value of a control (say). On the other hand, defining a new control that
   appears in a form's <code id="extensibility-2:dom-form-elements"><a href="#dom-form-elements">elements</a></code> array would be in violation
   of the above requirement, as it would violate the definition of <code id="extensibility-2:dom-form-elements-2"><a href="#dom-form-elements">elements</a></code> given in this specification.</p>

  </div>

  

  <hr>

  <p>When vendor-neutral extensions to this specification are needed, either this specification can
  be updated accordingly, or an extension specification can be written that overrides the
  requirements in this specification. When someone applying this specification to their activities
  decides that they will recognize the requirements of such an extension specification, it becomes
  an <dfn id="other-applicable-specifications">applicable specification</dfn> for the purposes
  of conformance requirements in this specification.</p>

  <p class="note">Someone could write a specification that defines any arbitrary byte stream as
  conforming, and then claim that their random junk is conforming. However, that does not mean that
  their random junk actually is conforming for everyone's purposes: if someone else decides that
  that specification does not apply to their work, then they can quite legitimately say that the
  aforementioned random junk is just that, junk, and not conforming at all. As far as conformance
  goes, what matters in a particular community is what that community <em>agrees</em> is
  applicable.</p>

  

  <hr>

  <p>User agents must treat elements and attributes that they do not understand as semantically
  neutral; leaving them in the DOM (for DOM processors), and styling them according to CSS (for CSS
  processors), but not inferring any meaning from them.</p>

  <p>When support for a feature is disabled (e.g. as an emergency measure to mitigate a security
  problem, or to aid in development, or for performance reasons), user agents must act as if they
  had no support for the feature whatsoever, and as if the feature was not mentioned in this
  specification. For example, if a particular feature is accessed via an attribute in a Web IDL
  interface, the attribute itself would be omitted from the objects that implement that interface
  — leaving the attribute on the object but making it return null or throw an exception is
  insufficient.</p>

  


  

  <h4 id="interactions-with-xpath-and-xslt"><span class="secno">2.1.11</span> Interactions with XPath and XSLT<a href="#interactions-with-xpath-and-xslt" class="self-link"></a></h4>

  <p id="xpath-1.0-processors">Implementations of XPath 1.0 that operate on <a id="interactions-with-xpath-and-xslt:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML
  documents</a> parsed or created in the manners described in this specification (e.g. as part of
  the <code>document.evaluate()</code> API) must act as if the following edit was applied
  to the XPath 1.0 specification.</p>

  <p>First, remove this paragraph:</p>

  <blockquote cite="https://www.w3.org/TR/1999/REC-xpath-19991116/#node-tests">

   <p>A <a href="https://www.w3.org/TR/REC-xml-names/#NT-QName">QName</a> in the node test is expanded
   into an <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#dt-expanded-name">expanded-name</a>
   using the namespace declarations from the expression context. This is the same way expansion is
   done for element type names in start and end-tags except that the default namespace declared with
   <code>xmlns</code> is not used: if the <a href="https://www.w3.org/TR/REC-xml-names/#NT-QName">QName</a> does not have a prefix, then the
   namespace URI is null (this is the same way attribute names are expanded). It is an error if the
   <a href="https://www.w3.org/TR/REC-xml-names/#NT-QName">QName</a> has a prefix for which there is
   no namespace declaration in the expression context.</p>

  </blockquote>

  <p>Then, insert in its place the following:</p>

  <blockquote cite="https://www.w3.org/Bugs/Public/show_bug.cgi?id=7059#c37">

   <p>A QName in the node test is expanded into an expanded-name using the namespace declarations
   from the expression context. If the QName has a prefix, then there must be a namespace declaration for this prefix in
   the expression context, and the corresponding namespace URI is the one that is
   associated with this prefix. It is an error if the QName has a prefix for which there is no
   namespace declaration in the expression context. </p>

   <p>If the QName has no prefix and the principal node type of the axis is element, then the
   default element namespace is used. Otherwise, if the QName has no prefix, the namespace URI is
   null. The default element namespace is a member of the context for the XPath expression. The
   value of the default element namespace when executing an XPath expression through the DOM3 XPath
   API is determined in the following way:</p>

   <ol><li>If the context node is from an HTML DOM, the default element namespace is
    "http://www.w3.org/1999/xhtml".</li><li>Otherwise, the default element namespace URI is null.</li></ol>

   <p class="note">This is equivalent to adding the default element namespace feature of XPath 2.0
   to XPath 1.0, and using the HTML namespace as the default element namespace for HTML documents.
   It is motivated by the desire to have implementations be compatible with legacy HTML content
   while still supporting the changes that this specification introduces to HTML regarding the
   namespace used for HTML elements, and by the desire to use XPath 1.0 rather than XPath 2.0.</p>

  </blockquote>

  <p class="note">This change is a <a id="interactions-with-xpath-and-xslt:willful-violation" href="https://infra.spec.whatwg.org/#willful-violation" data-x-internal="willful-violation">willful violation</a> of the XPath 1.0 specification,
  motivated by desire to have implementations be compatible with legacy content while still
  supporting the changes that this specification introduces to HTML regarding which namespace is
  used for HTML elements. <a href="#refsXPATH10">[XPATH10]</a></p> 

  <hr>

  <p id="dom-based-xslt-1.0-processors">XSLT 1.0 processors outputting to a DOM when the output
  method is "html" (either explicitly or via the defaulting rule in XSLT 1.0) are affected as
  follows:</p>

  <p>If the transformation program outputs an element in no namespace, the processor must, prior to
  constructing the corresponding DOM element node, change the namespace of the element to the
  <a id="interactions-with-xpath-and-xslt:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, <a href="https://infra.spec.whatwg.org/#ascii-lowercase" id="interactions-with-xpath-and-xslt:converted-to-ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">ASCII-lowercase</a> the
  element's local name, and <a href="https://infra.spec.whatwg.org/#ascii-lowercase" id="interactions-with-xpath-and-xslt:converted-to-ascii-lowercase-2" data-x-internal="converted-to-ascii-lowercase">ASCII-lowercase</a> the
  names of any non-namespaced attributes on the element.</p>

  <p class="note">This requirement is a <a id="interactions-with-xpath-and-xslt:willful-violation-2" href="https://infra.spec.whatwg.org/#willful-violation" data-x-internal="willful-violation">willful violation</a> of the XSLT 1.0
  specification, required because this specification changes the namespaces and case-sensitivity
  rules of HTML in a manner that would otherwise be incompatible with DOM-based XSLT
  transformations. (Processors that serialize the output are unaffected.) <a href="#refsXSLT10">[XSLT10]</a></p> 

  <hr>

  <p>This specification does not specify precisely how XSLT processing interacts with the <a href="#html-parser" id="interactions-with-xpath-and-xslt:html-parser">HTML
  parser</a> infrastructure (for example, whether an XSLT processor acts as if it puts any
  elements into a <a href="#stack-of-open-elements" id="interactions-with-xpath-and-xslt:stack-of-open-elements">stack of open elements</a>). However, XSLT processors must <a href="#stop-parsing" id="interactions-with-xpath-and-xslt:stop-parsing">stop
  parsing</a> if they successfully complete, and must <a href="#update-the-current-document-readiness" id="interactions-with-xpath-and-xslt:update-the-current-document-readiness">update the current document
  readiness</a> first to "<code>interactive</code>" and then to "<code>complete</code>" if they are aborted.</p>

  <hr>

  <p>This specification does not specify how XSLT interacts with the <a href="#navigate" id="interactions-with-xpath-and-xslt:navigate">navigation</a> algorithm, how it fits in with the <a href="#event-loop" id="interactions-with-xpath-and-xslt:event-loop">event loop</a>, nor
  how error pages are to be handled (e.g. whether XSLT errors are to replace an incremental XSLT
  output, or are rendered inline, etc.).</p>

  <p class="note">There are also additional non-normative comments regarding the interaction of XSLT
  and HTML <a href="#scriptTagXSLT">in the <code>script</code> element section</a>, and of
  XSLT, XPath, and HTML <a href="#template-XSLT-XPath">in the <code>template</code> element
  section</a>.</p>

  



  <h3 id="policy-controlled-features"><span class="secno">2.2</span> Policy-controlled features<a href="#policy-controlled-features" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy/document-domain" title="The HTTP Permissions-Policy header document-domain directive controls whether the current document is allowed to set document.domain.">Headers/Permissions-Policy/document-domain</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 74+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 88+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 88+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>This document defines the following <a href="https://w3c.github.io/webappsec-feature-policy/#policy-controlled-feature" id="policy-controlled-features:concept-policy-controlled-feature" data-x-internal="concept-policy-controlled-feature">policy-controlled features</a>:</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy/autoplay" title="The HTTP Permissions-Policy header autoplay directive controls whether the current document is allowed to autoplay media requested through the HTMLMediaElement interface.">Headers/Feature-Policy/autoplay</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 74+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy/autoplay" title="The HTTP Permissions-Policy header autoplay directive controls whether the current document is allowed to autoplay media requested through the HTMLMediaElement interface.">Headers/Permissions-Policy/autoplay</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 74+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>88+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>88+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><ul><li>"<dfn id="autoplay-feature"><code>autoplay</code></dfn>", which has a <a href="https://w3c.github.io/webappsec-feature-policy/#default-allowlist" id="policy-controlled-features:concept-default-allowlist" data-x-internal="concept-default-allowlist">default allowlist</a> of <code>'self'</code>.</li><li>"<dfn id="cross-origin-isolated-feature"><code>cross-origin-isolated</code></dfn>", which has a <a href="https://w3c.github.io/webappsec-feature-policy/#default-allowlist" id="policy-controlled-features:concept-default-allowlist-2" data-x-internal="concept-default-allowlist">default allowlist</a> of <code>'self'</code>.</li><li>"<dfn id="focus-without-user-activation-feature"><code>focus-without-user-activation</code></dfn>", which has a <a href="https://w3c.github.io/webappsec-feature-policy/#default-allowlist" id="policy-controlled-features:concept-default-allowlist-3" data-x-internal="concept-default-allowlist">default allowlist</a> of <code>'self'</code>.</li></ul>


  <h3 id="common-microsyntaxes"><span class="secno">2.3</span> Common microsyntaxes<a href="#common-microsyntaxes" class="self-link"></a></h3>

  <p>There are various places in HTML that accept particular data types, such as dates or numbers.
  This section describes what the conformance criteria for content in those formats is, and how to
  parse them.</p>

  

  <p class="note">Implementers are strongly urged to carefully examine any third-party libraries
  they might consider using to implement the parsing of syntaxes described below. For example, date
  libraries are likely to implement error handling behavior that differs from what is required in
  this specification, since error-handling behavior is often not defined in specifications that
  describe date syntaxes similar to those used in this specification, and thus implementations tend
  to vary greatly in how they handle errors.</p>

  


  

  <h4 id="common-parser-idioms"><span class="secno">2.3.1</span> Common parser idioms<a href="#common-parser-idioms" class="self-link"></a></h4>

  <p data-var-scope="">Some of the micro-parsers described below follow the pattern of having an <var>input</var>
  variable that holds the string being parsed, and having a <var>position</var> variable pointing at
  the next character to parse in <var>input</var>.</p>

  



  <h4 id="boolean-attributes"><span class="secno">2.3.2</span> Boolean attributes<a href="#boolean-attributes" class="self-link"></a></h4>

  <p>A number of attributes are <dfn id="boolean-attribute">boolean attributes</dfn>. The
  presence of a boolean attribute on an element represents the true value, and the absence of the
  attribute represents the false value.</p>

  <p>If the attribute is present, its value must either be the empty string or a value that is an
  <a id="boolean-attributes:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the attribute's canonical name, with no leading or
  trailing whitespace.</p>

  <p class="note">The values "true" and "false" are not allowed on boolean attributes. To represent
  a false value, the attribute has to be omitted altogether.</p>

  <div class="example">

   <p>Here is an example of a checkbox that is checked and disabled. The <code id="boolean-attributes:attr-input-checked"><a href="#attr-input-checked">checked</a></code> and <code id="boolean-attributes:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code>
   attributes are the boolean attributes.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">checked</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">cheese</c-> <c- e="">disabled</c-><c- p="">&gt;</c-> Cheese<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

   <p>This could be equivalently written as this:

   </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">checked</c-><c- o="">=</c-><c- s="">checked</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">cheese</c-> <c- e="">disabled</c-><c- o="">=</c-><c- s="">disabled</c-><c- p="">&gt;</c-> Cheese<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

   <p>You can also mix styles; the following is still equivalent:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'checkbox'</c-> <c- e="">checked</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">cheese</c-> <c- e="">disabled</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-> Cheese<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="keywords-and-enumerated-attributes"><span class="secno">2.3.3</span> Keywords and enumerated attributes<a href="#keywords-and-enumerated-attributes" class="self-link"></a></h4>

  <p>Some attributes, called <dfn id="enumerated-attribute" data-lt="enumerated attribute" data-export="">enumerated attributes</dfn>, take on a finite set of states. The state for such an
  attribute is derived by combining the attribute's value, a set of keyword/state mappings, and
  three possible special states that can also be given in the specification of the attribute. These
  special states are the <dfn id="invalid-value-default"><i>invalid value default</i></dfn>, the <dfn id="missing-value-default"><i>missing value
  default</i></dfn>, and the <dfn id="empty-value-default"><i>empty value default</i></dfn>.</p>

  <p class="note">Multiple keywords can map to the same state.</p>

  <div data-algorithm="">
  <p>To determine the state of an attribute, use the following steps:</p>

  <ol><li>
    <p>If the attribute is not specified:</p>

    <ol><li><p>If the attribute has a <i id="keywords-and-enumerated-attributes:missing-value-default"><a href="#missing-value-default">missing value default</a></i>
     state defined, then return that <i id="keywords-and-enumerated-attributes:missing-value-default-2"><a href="#missing-value-default">missing value default</a></i>
     state.</p></li><li><p>Otherwise, return no state.</p></li></ol>
   </li><li><p>If the attribute's value is an <a id="keywords-and-enumerated-attributes:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the
   keywords defined for the attribute, then return the state represented by that keyword.</p></li><li><p>If the attribute has an <i id="keywords-and-enumerated-attributes:empty-value-default"><a href="#empty-value-default">empty value default</a></i> state
   defined and the attribute's value is the empty string, then return that <i id="keywords-and-enumerated-attributes:empty-value-default-2"><a href="#empty-value-default">empty value default</a></i> state.</p></li><li><p>If the attribute has an <i id="keywords-and-enumerated-attributes:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> state
   defined, then return that <i id="keywords-and-enumerated-attributes:invalid-value-default-2"><a href="#invalid-value-default">invalid value default</a></i>
   state.</p></li><li><p>Return no state.</p></li></ol>
  </div>

  <p>For authoring conformance purposes, if an enumerated attribute is specified, the attribute's
  value must be one of:</p>

  <ul><li><p>An <a id="keywords-and-enumerated-attributes:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the conforming keywords for that
   attribute, with no leading or trailing whitespace.</p></li><li><p>The empty string and the attribute must have an <i id="keywords-and-enumerated-attributes:empty-value-default-3"><a href="#empty-value-default">empty
   value default</a></i> defined.</p></li></ul>

  <div data-algorithm="">
  <p>For <a href="#reflect" id="keywords-and-enumerated-attributes:reflect">reflection</a> purposes, states which have any keywords mapping
  to them are said to have a <dfn id="canonical-keyword">canonical keyword</dfn>. This is determined as follows:</p>

  <ol><li><p>If there is only one keyword mapping to the given state, then it is that keyword.</p></li><li><p>If there is only one <em>conforming</em> keyword mapping to the given state, then it is
   that conforming keyword.</p></li><li><p>If there are two conforming keywords mapping to the given state, and one is the empty
   string, then the canonical keyword will be the conforming keyword that is not the empty
   string.</p></li><li><p>Otherwise, the canonical keyword for the state will be explicitly given in the
   specification for the attribute.</p></li></ol>
  </div>



  <h4 id="numbers"><span class="secno">2.3.4</span> Numbers<a href="#numbers" class="self-link"></a></h4>

  <h5 id="signed-integers"><span class="secno">2.3.4.1</span> Signed integers<a href="#signed-integers" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-integer">valid integer</dfn> if it consists of one or more <a id="signed-integers:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>,
  optionally prefixed with a U+002D HYPHEN-MINUS character (-).</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#valid-integer" id="signed-integers:valid-integer">valid integer</a> without a U+002D HYPHEN-MINUS (-) prefix represents the number
  that is represented in base ten by that string of digits. A <a href="#valid-integer" id="signed-integers:valid-integer-2">valid integer</a>
  <em>with</em> a U+002D HYPHEN-MINUS (-) prefix represents the number represented in base ten by
  the string of digits that follows the U+002D HYPHEN-MINUS, subtracted from zero.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn id="rules-for-parsing-integers">rules for parsing integers</dfn> are as given in the following algorithm. When
  invoked, the steps must be followed in the order given, aborting at the first step that returns a
  value. This algorithm will return either an integer or an error.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the
   start of the string.</p></li><li><p>Let <var>sign</var> have the value "positive".</p></li><li><p><a id="signed-integers:skip-ascii-whitespace" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
   <var>position</var>.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, return an error.</p></li><li>
    <p>If the character indicated by <var>position</var> (the first character) is a U+002D
    HYPHEN-MINUS character (-):</p>

    <ol><li>Let <var>sign</var> be "negative".</li><li>Advance <var>position</var> to the next character.</li><li>If <var>position</var> is past the end of <var>input</var>, return an error.</li></ol>

    <p>Otherwise, if the character indicated by <var>position</var> (the first character) is a
    U+002B PLUS SIGN character (+):</p>

    <ol><li>Advance <var>position</var> to the next character. (The "<code>+</code>" is
     ignored, but it is not conforming.)</li><li>If <var>position</var> is past the end of <var>input</var>, return an error.</li></ol>
   </li><li><p>If the character indicated by <var>position</var> is not an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="signed-integers:ascii-digits-2" data-x-internal="ascii-digits">ASCII digit</a>, then return an error.</p></li><li><p><a id="signed-integers:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="signed-integers:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>, and interpret the resulting sequence as a base-ten
   integer. Let <var>value</var> be that integer.</p></li><li><p>If <var>sign</var> is "positive", return <var>value</var>, otherwise return the result of
   subtracting <var>value</var> from zero.</p></li></ol>
  </div>

  


  <h5 id="non-negative-integers"><span class="secno">2.3.4.2</span> Non-negative integers<a href="#non-negative-integers" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-non-negative-integer">valid non-negative integer</dfn> if it consists of one or more <a id="non-negative-integers:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
  digits</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#valid-non-negative-integer" id="non-negative-integers:valid-non-negative-integer">valid non-negative integer</a> represents the number that is represented in base ten
  by that string of digits.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn id="rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</dfn> are as given in the following algorithm.
  When invoked, the steps must be followed in the order given, aborting at the first step that
  returns a value. This algorithm will return either zero, a positive integer, or an error.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>value</var> be the result of parsing <var>input</var> using the
   <a href="#rules-for-parsing-integers" id="non-negative-integers:rules-for-parsing-integers">rules for parsing integers</a>.</p></li><li><p>If <var>value</var> is an error, return an error.</p></li><li><p>If <var>value</var> is less than zero, return an error.</p></li><li><p>Return <var>value</var>.</p></li></ol>
  </div>

  

  


  <h5 id="floating-point-numbers"><span class="secno">2.3.4.3</span> Floating-point numbers<a href="#floating-point-numbers" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-floating-point-number">valid floating-point number</dfn> if it consists of:</p>

  <ol><li><p>Optionally, a U+002D HYPHEN-MINUS character (-).</p></li><li>
    <p>One or both of the following, in the given order:</p>

    <ol><li><p>A series of one or more <a id="floating-point-numbers:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>.</p></li><li>
      <p>Both of the following, in the given order:</p>

      <ol><li><p>A single U+002E FULL STOP character (.).</p></li><li><p>A series of one or more <a id="floating-point-numbers:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>.</p></li></ol>
     </li></ol>
   </li><li>
    <p>Optionally:</p>

    <ol><li><p>Either a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E
     character (E).</p></li><li><p>Optionally, a U+002D HYPHEN-MINUS character (-) or U+002B PLUS SIGN character
     (+).</p></li><li><p>A series of one or more <a id="floating-point-numbers:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>A <a href="#valid-floating-point-number" id="floating-point-numbers:valid-floating-point-number">valid floating-point number</a> represents the number obtained by multiplying the
  significand by ten raised to the power of the exponent, where the significand is the first number,
  interpreted as base ten (including the decimal point and the number after the decimal point, if
  any, and interpreting the significand as a negative number if the whole string starts with a
  U+002D HYPHEN-MINUS character (-) and the number is not zero), and where the exponent is the
  number after the E, if any (interpreted as a negative number if there is a U+002D HYPHEN-MINUS
  character (-) between the E and the number and the number is not zero, or else ignoring a U+002B
  PLUS SIGN character (+) between the E and the number if there is one). If there is no E, then the
  exponent is treated as zero.</p>
  </div>

  <p class="note">The Infinity and Not-a-Number (NaN) values are not <a href="#valid-floating-point-number" id="floating-point-numbers:valid-floating-point-number-2">valid floating-point numbers</a>.</p>

  

  <p class="note">The <a href="#valid-floating-point-number" id="floating-point-numbers:valid-floating-point-number-3">valid floating-point number</a> concept is typically only used to
  restrict what is allowed for authors, while the user agent requirements use the <a href="#rules-for-parsing-floating-point-number-values" id="floating-point-numbers:rules-for-parsing-floating-point-number-values">rules for
  parsing floating-point number values</a> below (e.g., the <code id="floating-point-numbers:attr-progress-max"><a href="#attr-progress-max">max</a></code> attribute of the <code id="floating-point-numbers:the-progress-element"><a href="#the-progress-element">progress</a></code> element). However, in
  some cases the user agent requirements include checking if a string is a <a href="#valid-floating-point-number" id="floating-point-numbers:valid-floating-point-number-4">valid
  floating-point number</a> (e.g., the <a href="#value-sanitization-algorithm" id="floating-point-numbers:value-sanitization-algorithm">value sanitization algorithm</a> for the <a href="#number-state-(type=number)" id="floating-point-numbers:number-state-(type=number)">Number</a> state of the <code id="floating-point-numbers:the-input-element"><a href="#the-input-element">input</a></code> element, or the
  <a href="#parse-a-srcset-attribute" id="floating-point-numbers:parse-a-srcset-attribute">parse a srcset attribute</a> algorithm).</p>

  <div data-algorithm="">
  <p>The <dfn id="best-representation-of-the-number-as-a-floating-point-number">best
  representation of the number <var>n</var> as a floating-point number</dfn> is the string
  obtained from running <a id="floating-point-numbers:tostring" href="https://tc39.es/ecma262/#sec-tostring" data-x-internal="tostring">ToString</a>(<var>n</var>). The abstract operation
  <a id="floating-point-numbers:tostring-2" href="https://tc39.es/ecma262/#sec-tostring" data-x-internal="tostring">ToString</a> is not uniquely determined. When there are multiple possible strings that
  could be obtained from <a id="floating-point-numbers:tostring-3" href="https://tc39.es/ecma262/#sec-tostring" data-x-internal="tostring">ToString</a> for a particular value, the user agent must always
  return the same string for that value (though it may differ from the value used by other user
  agents).</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="rules-for-parsing-floating-point-number-values" data-export="">rules for parsing floating-point number values</dfn> are as given in the
  following algorithm. This algorithm must be aborted at the first step that returns something.
  This algorithm will return either a number or an error.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the
   start of the string.</p></li><li><p>Let <var>value</var> have the value 1.</p></li><li><p>Let <var>divisor</var> have the value 1.</p></li><li><p>Let <var>exponent</var> have the value 1.</p></li><li><p><a id="floating-point-numbers:skip-ascii-whitespace" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
   <var>position</var>.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, return an error.</p></li><li>
    <p>If the character indicated by <var>position</var> is a U+002D HYPHEN-MINUS character (-):</p>

    <ol><li>Change <var>value</var> and <var>divisor</var> to −1.</li><li>Advance <var>position</var> to the next character.</li><li>If <var>position</var> is past the end of <var>input</var>, return an error.</li></ol>

    <p>Otherwise, if the character indicated by <var>position</var> (the first character) is a
    U+002B PLUS SIGN character (+):</p>

    <ol><li>Advance <var>position</var> to the next character. (The "<code>+</code>"
     is ignored, but it is not conforming.)</li><li>If <var>position</var> is past the end of <var>input</var>, return an error.</li></ol>
   </li><li><p>If the character indicated by <var>position</var> is a U+002E FULL STOP (.), and that is
   not the last character in <var>input</var>, and the character after the character indicated by
   <var>position</var> is an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="floating-point-numbers:ascii-digits-4" data-x-internal="ascii-digits">ASCII digit</a>, then set
   <var>value</var> to zero and jump to the step labeled <i>fraction</i>.</p> 

   </li><li><p>If the character indicated by <var>position</var> is not an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="floating-point-numbers:ascii-digits-5" data-x-internal="ascii-digits">ASCII digit</a>, then return an error.</p></li><li><p><a id="floating-point-numbers:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="floating-point-numbers:ascii-digits-6" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>, and interpret the resulting sequence as a base-ten
   integer. Multiply <var>value</var> by that integer.</p></li><li>If <var>position</var> is past the end of <var>input</var>, jump to the step labeled
   <i>conversion</i>.</li><li><p><i>Fraction</i>: If the character indicated by <var>position</var> is a U+002E
   FULL STOP (.), run these substeps:</p>

    <ol><li><p>Advance <var>position</var> to the next character.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, or if the character
     indicated by <var>position</var> is not an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="floating-point-numbers:ascii-digits-7" data-x-internal="ascii-digits">ASCII digit</a>,
     U+0065 LATIN SMALL LETTER E (e), or U+0045 LATIN CAPITAL LETTER E (E), then jump to the step
     labeled <i>conversion</i>.</p></li><li><p>If the character indicated by <var>position</var> is a U+0065 LATIN SMALL
     LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E character (E), skip the remainder of
     these substeps.</p>

     </li><li><p><i>Fraction loop</i>: Multiply <var>divisor</var> by ten.</p></li><li>Add the value of the character indicated by <var>position</var>, interpreted as a
     base-ten digit (0..9) and divided by <var>divisor</var>, to <var>value</var>.</li><li><p>Advance <var>position</var> to the next character.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, then jump to the step
     labeled <i>conversion</i>.</p></li><li><p>If the character indicated by <var>position</var> is an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="floating-point-numbers:ascii-digits-8" data-x-internal="ascii-digits">ASCII digit</a>, jump back to the step labeled <i>fraction loop</i> in these
     substeps.</p></li></ol>
   </li><li><p>If the character indicated by <var>position</var> is U+0065 (e) or a U+0045 (E), then:</p>

    <ol><li><p>Advance <var>position</var> to the next character.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, then jump to the step
     labeled <i>conversion</i>.</p></li><li>
      <p>If the character indicated by <var>position</var> is a U+002D HYPHEN-MINUS character
      (-):</p>

      <ol><li>Change <var>exponent</var> to −1.</li><li>Advance <var>position</var> to the next character.</li><li><p>If <var>position</var> is past the end of <var>input</var>, then jump to the step
       labeled <i>conversion</i>.</p></li></ol>

      <p>Otherwise, if the character indicated by <var>position</var> is a U+002B PLUS SIGN
      character (+):</p>

      <ol><li>Advance <var>position</var> to the next character.</li><li><p>If <var>position</var> is past the end of <var>input</var>, then jump to the step
       labeled <i>conversion</i>.</p></li></ol>
     </li><li><p>If the character indicated by <var>position</var> is not an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="floating-point-numbers:ascii-digits-9" data-x-internal="ascii-digits">ASCII digit</a>, then jump to the step labeled <i>conversion</i>.</p></li><li><p><a id="floating-point-numbers:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="floating-point-numbers:ascii-digits-10" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
     <var>input</var> given <var>position</var>, and interpret the resulting sequence as a base-ten
     integer. Multiply <var>exponent</var> by that integer.</p></li><li><p>Multiply <var>value</var> by ten raised to the <var>exponent</var>th power.</p></li></ol>
   </li><li><p><i>Conversion</i>: Let <var>S</var> be the set of finite IEEE 754 double-precision
   floating-point values except −0, but with two special values added: 2<sup>1024</sup> and −2<sup>1024</sup>.</p></li><li><p>Let <var>rounded-value</var> be the number in <var>S</var> that is closest to
   <var>value</var>, selecting the number with an even significand if there are two equally close
   values. (The two special values 2<sup>1024</sup> and −2<sup>1024</sup>
   are considered to have even significands for this purpose.)</p></li><li><p>If <var>rounded-value</var> is 2<sup>1024</sup> or −2<sup>1024</sup>, return an error.</p></li><li><p>Return <var>rounded-value</var>.</p></li></ol>
  </div>

  



  <h5 id="percentages-and-dimensions"><span class="secno">2.3.4.4</span> Percentages and lengths<a href="#percentages-and-dimensions" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>The <dfn id="rules-for-parsing-dimension-values">rules for parsing dimension values</dfn> are as given in the following algorithm. When
  invoked, the steps must be followed in the order given, aborting at the first step that returns a
  value. This algorithm will return either a number greater than or equal to 0.0, or failure; if a
  number is returned, then it is further categorized as either a percentage or a length.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a <a id="percentages-and-dimensions:position-variable" href="https://infra.spec.whatwg.org/#string-position-variable" data-x-internal="position-variable">position variable</a> for <var>input</var>,
   initially pointing at the start of <var>input</var>.</p></li><li><p><a id="percentages-and-dimensions:skip-ascii-whitespace" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
   <var>position</var>.</p></li><li><p>If <var>position</var> is past the end of <var>input</var> or the code point at
   <var>position</var> within <var>input</var> is not an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="percentages-and-dimensions:ascii-digits" data-x-internal="ascii-digits">ASCII
   digit</a>, then return failure.</p></li><li><p><a id="percentages-and-dimensions:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="percentages-and-dimensions:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>, and interpret the resulting sequence as a base-ten
   integer. Let <var>value</var> be that number.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, then return <var>value</var>
   as a length.</p></li><li>
    <p>If the code point at <var>position</var> within <var>input</var> is U+002E (.), then:</p>

    <ol><li><p>Advance <var>position</var> by 1.</p></li><li><p>If <var>position</var> is past the end of <var>input</var> or the code point at
     <var>position</var> within <var>input</var> is not an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="percentages-and-dimensions:ascii-digits-3" data-x-internal="ascii-digits">ASCII
     digit</a>, then return the <a href="#current-dimension-value" id="percentages-and-dimensions:current-dimension-value">current dimension value</a> with <var>value</var>,
     <var>input</var>, and <var>position</var>.</p></li><li><p>Let <var>divisor</var> have the value 1.</p></li><li>
      <p>While true:</p>

      <ol><li><p>Multiply <var>divisor</var> by ten.</p></li><li><p>Add the value of the code point at <var>position</var> within <var>input</var>,
       interpreted as a base-ten digit (0..9) and divided by <var>divisor</var>, to
       <var>value</var>.</p></li><li><p>Advance <var>position</var> by 1.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, then return
       <var>value</var> as a length.</p></li><li><p>If the code point at <var>position</var> within <var>input</var> is not an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="percentages-and-dimensions:ascii-digits-4" data-x-internal="ascii-digits">ASCII digit</a>, then <a id="percentages-and-dimensions:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li></ol>
     </li></ol>
   </li><li><p>Return the <a href="#current-dimension-value" id="percentages-and-dimensions:current-dimension-value-2">current dimension value</a> with <var>value</var>, <var>input</var>,
   and <var>position</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="current-dimension-value">current dimension value</dfn>, given <var>value</var>, <var>input</var>, and
  <var>position</var>, is determined as follows:</p>

  <ol><li><p>If <var>position</var> is past the end of <var>input</var>, then return <var>value</var>
   as a length.</p></li><li><p>If the code point at <var>position</var> within <var>input</var> is U+0025 (%), then
   return <var>value</var> as a percentage.</p></li><li><p>Return <var>value</var> as a length.</p></li></ol>
  </div>

  <h5 id="nonzero-percentages-and-lengths"><span class="secno">2.3.4.5</span> Nonzero percentages and lengths<a href="#nonzero-percentages-and-lengths" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>The <dfn id="rules-for-parsing-non-zero-dimension-values">rules for parsing nonzero dimension
  values</dfn> are as given in the following algorithm. When invoked, the steps must be followed in
  the order given, aborting at the first step that returns a value. This algorithm will return
  either a number greater than 0.0, or an error; if a number is returned, then it is further
  categorized as either a percentage or a length.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>value</var> be the result of parsing <var>input</var> using the <a href="#rules-for-parsing-dimension-values" id="nonzero-percentages-and-lengths:rules-for-parsing-dimension-values">rules for
   parsing dimension values</a>.</p></li><li><p>If <var>value</var> is an error, return an error.</p></li><li><p>If <var>value</var> is zero, return an error.</p></li><li><p>If <var>value</var> is a percentage, return <var>value</var> as a percentage.</p></li><li><p>Return <var>value</var> as a length.</p></li></ol>
  </div>

  


  <h5 id="lists-of-floating-point-numbers"><span class="secno">2.3.4.6</span> Lists of floating-point numbers<a href="#lists-of-floating-point-numbers" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A <dfn id="valid-list-of-floating-point-numbers">valid list of floating-point numbers</dfn> is a number of <a href="#valid-floating-point-number" id="lists-of-floating-point-numbers:valid-floating-point-number">valid floating-point numbers</a> separated by U+002C COMMA characters,
  with no other characters (e.g. no <a id="lists-of-floating-point-numbers:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>). In addition, there might be
  restrictions on the number of floating-point numbers that can be given, or on the range of values
  allowed.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn id="rules-for-parsing-a-list-of-floating-point-numbers">rules for parsing a list of floating-point numbers</dfn> are as follows:</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the
   start of the string.</p></li><li><p>Let <var>numbers</var> be an initially empty list of floating-point numbers. This list
   will be the result of this algorithm.</p></li><li><p><a id="lists-of-floating-point-numbers:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="lists-of-floating-point-numbers:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>,
   U+002C COMMA, or U+003B SEMICOLON characters from <var>input</var> given <var>position</var>.
   This skips past any leading delimiters.</p></li><li><p>While <var>position</var> is not past the end of <var>input</var>:</p>

    <ol><li><p><a id="lists-of-floating-point-numbers:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are not <a id="lists-of-floating-point-numbers:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
     whitespace</a>, U+002C COMMA, U+003B SEMICOLON, <a id="lists-of-floating-point-numbers:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, U+002E FULL STOP,
     or U+002D HYPHEN-MINUS characters from <var>input</var> given <var>position</var>. This skips
     past leading garbage.</p></li><li><p><a id="lists-of-floating-point-numbers:collect-a-sequence-of-code-points-3" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are not <a id="lists-of-floating-point-numbers:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
     whitespace</a>, U+002C COMMA, or U+003B SEMICOLON characters from <var>input</var> given
     <var>position</var>, and let <var>unparsed number</var> be the result.</p></li><li><p>Let <var>number</var> be the result of parsing <var>unparsed number</var> using the
     <a href="#rules-for-parsing-floating-point-number-values" id="lists-of-floating-point-numbers:rules-for-parsing-floating-point-number-values">rules for parsing floating-point number values</a>.</p></li><li><p>If <var>number</var> is an error, set <var>number</var> to zero.</p></li><li><p>Append <var>number</var> to <var>numbers</var>.</p></li><li><p><a id="lists-of-floating-point-numbers:collect-a-sequence-of-code-points-4" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="lists-of-floating-point-numbers:space-characters-5" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>,
     U+002C COMMA, or U+003B SEMICOLON characters from <var>input</var> given <var>position</var>.
     This skips past the delimiter.</p></li></ol>
   </li><li><p>Return <var>numbers</var>.</p></li></ol>
  </div>

  

  

  <h5 id="lists-of-dimensions"><span class="secno">2.3.4.7</span> Lists of dimensions<a href="#lists-of-dimensions" class="self-link"></a></h5>

  

  <div data-algorithm="">
  <p>The <dfn id="rules-for-parsing-a-list-of-dimensions">rules for parsing a list of dimensions</dfn> are as follows. These rules return a list
  of zero or more pairs consisting of a number and a unit, the unit being one of <i>percentage</i>,
  <i>relative</i>, and <i>absolute</i>.</p>

  <ol><li><p>Let <var>raw input</var> be the string being parsed.</p></li><li><p>If the last character in <var>raw input</var> is a U+002C COMMA character (,),
   then remove that character from <var>raw input</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#split-on-commas" id="lists-of-dimensions:split-a-string-on-commas" data-x-internal="split-a-string-on-commas">Split the string <var>raw input</var> on
   commas</a>. Let <var>raw tokens</var> be the resulting list of tokens.</p></li><li><p>Let <var>result</var> be an empty list of number/unit pairs.</p></li><li>
    <p>For each token in <var>raw tokens</var>, run the following substeps:</p>

    <ol><li><p>Let <var>input</var> be the token.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>,
     initially pointing at the start of the string.</p></li><li><p>Let <var>value</var> be the number 0.</p></li><li><p>Let <var>unit</var> be <i>absolute</i>.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, set <var>unit</var> to <i>relative</i> and jump to the last substep.</p></li><li><p>If the character at <var>position</var> is an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="lists-of-dimensions:ascii-digits" data-x-internal="ascii-digits">ASCII digit</a>, <a id="lists-of-dimensions:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">collect a sequence of code points</a> that are <a id="lists-of-dimensions:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
     digits</a> from <var>input</var> given <var>position</var>, interpret the resulting sequence
     as an integer in base ten, and increment <var>value</var> by that integer.</p></li><li>
      <p>If the character at <var>position</var> is U+002E (.), then:</p>

      <ol><li><p><a id="lists-of-dimensions:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> consisting of <a id="lists-of-dimensions:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
       whitespace</a> and <a id="lists-of-dimensions:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from <var>input</var> given
       <var>position</var>. Let <var>s</var> be the resulting sequence.</p></li><li><p>Remove all <a id="lists-of-dimensions:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> in <var>s</var>.</p></li><li>
        <p>If <var>s</var> is not the empty string, then:</p>

        <ol><li><p>Let <var>length</var> be the number of characters in <var>s</var> (after the spaces were removed).</p></li><li><p>Let <var>fraction</var> be the result of interpreting <var>s</var> as a base-ten integer, and then dividing that number by <span>10<sup><var>length</var></sup></span>.</p></li><li><p>Increment <var>value</var> by <var>fraction</var>.</p></li></ol>
       </li></ol>
     </li><li><p><a id="lists-of-dimensions:skip-ascii-whitespace" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
     <var>position</var>.</p></li><li>
      <p>If the character at <var>position</var> is a U+0025 PERCENT SIGN character (%),
      then set <var>unit</var> to <i>percentage</i>.</p>

      <p>Otherwise, if the character at <var>position</var> is a U+002A ASTERISK character
      (*), then set <var>unit</var> to <i>relative</i>.</p>
     </li><li><p>Add an entry to <var>result</var> consisting of the number given by <var>value</var> and the unit given by <var>unit</var>.</p></li></ol>
   </li><li><p>Return the list <var>result</var>.</p></li></ol>
  </div>

  


  <h4 id="dates-and-times"><span class="secno">2.3.5</span> Dates and times<a href="#dates-and-times" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>In the algorithms below, the <dfn id="number-of-days-in-month-month-of-year-year">number of days in month <var>month</var> of year
  <var>year</var></dfn> is: <em>31</em> if <var>month</var> is 1, 3, 5, 7, 8,
  10, or 12; <em>30</em> if <var>month</var> is 4, 6, 9, or 11; <em>29</em> if <var>month</var> is 2
  and <var>year</var> is a number divisible by 400, or if <var>year</var> is a number divisible by 4
  but not by 100; and <em>28</em> otherwise. This takes into account leap years in the Gregorian
  calendar. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>
  </div>

  <p>When <a id="dates-and-times:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> are used in the date and time syntaxes defined in this section,
  they express numbers in base ten.</p>

  

  <p class="note">While the formats described here are intended to be subsets of the corresponding
  ISO8601 formats, this specification defines parsing rules in much more detail than ISO8601.
  Implementers are therefore encouraged to carefully examine any date parsing libraries before using
  them to implement the parsing rules described below; ISO8601 libraries might not parse dates and
  times in exactly the same manner. <a href="#refsISO8601">[ISO8601]</a></p>

  

  <p>Where this specification refers to the <dfn id="proleptic-gregorian-calendar">proleptic Gregorian calendar</dfn>, it means the
  modern Gregorian calendar, extrapolated backwards to year 1. A date in the <a href="#proleptic-gregorian-calendar" id="dates-and-times:proleptic-gregorian-calendar">proleptic
  Gregorian calendar</a>, sometimes explicitly referred to as a <dfn id="proleptic-gregorian-date">proleptic-Gregorian
  date</dfn>, is one that is described using that calendar even if that calendar was not in use at
  the time (or place) in question. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>

  <p class="note">The use of the Gregorian calendar as the wire format in this specification is an
  arbitrary choice resulting from the cultural biases of those involved in the decision. See also
  the section discussing <a href="#input-author-notes">date, time, and number formats</a> in forms
  (for authors), <a href="#input-impl-notes">implementation notes regarding
  localization of form controls</a>, and the <code id="dates-and-times:the-time-element"><a href="#the-time-element">time</a></code> element.</p>


  <h5 id="months"><span class="secno">2.3.5.1</span> Months<a href="#months" class="self-link"></a></h5>

  <p>A <dfn id="concept-month">month</dfn> consists of a specific <a href="#proleptic-gregorian-date" id="months:proleptic-gregorian-date">proleptic-Gregorian
  date</a> with no time-zone information and no date information beyond a year and a month.
  <a href="#refsGREGORIAN">[GREGORIAN]</a></p>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-month-string">valid month string</dfn> representing a year <var>year</var> and
  month <var>month</var> if it consists of the following components in the given order:</p>

  <ol><li>Four or more <a id="months:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing <var>year</var>, where <var>year</var>&nbsp;&gt;&nbsp;0</li><li>A U+002D HYPHEN-MINUS character (-)</li><li>Two <a id="months:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing the month <var>month</var>, in the range
   1&nbsp;≤&nbsp;<var>month</var>&nbsp;≤&nbsp;12</li></ol>
  </div>

  

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-month-string">parse a month string</dfn> are as follows. This will return either a year and
  month, or nothing. If at any point the algorithm says that it "fails", this means that it is
  aborted at that point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p><a href="#parse-a-month-component" id="months:parse-a-month-component">Parse a month component</a> to obtain <var>year</var> and <var>month</var>. If this returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is <em>not</em> beyond the
   end of <var>input</var>, then fail.</p></li><li><p>Return <var>year</var> and <var>month</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-month-component">parse a month component</dfn>, given an <var>input</var> string and
  a <var>position</var>, are as follows. This will return either a year and a month, or
  nothing. If at any point the algorithm says that it "fails", this means that it is aborted at that
  point and returns nothing.</p>

  <ol><li><p><a id="months:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="months:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>. If the collected sequence is not at least four
   characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten integer.
   Let <var>year</var> be that number.</p></li><li><p>If <var>year</var> is not a number greater than zero, then fail.</p></li><li><p>If <var>position</var> is beyond the end of <var>input</var> or if the
   character at <var>position</var> is not a U+002D HYPHEN-MINUS character, then fail.
   Otherwise, move <var>position</var> forwards one character.</p></li><li><p><a id="months:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="months:ascii-digits-4" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>. If the collected sequence is not exactly two
   characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten integer.
   Let <var>month</var> be that number.</p></li><li><p>If <var>month</var> is not a number in the range 1&nbsp;≤&nbsp;<var>month</var>&nbsp;≤&nbsp;12, then fail.</p></li><li><p>Return <var>year</var> and <var>month</var>.</p></li></ol>
  </div>

  


  <h5 id="dates"><span class="secno">2.3.5.2</span> Dates<a href="#dates" class="self-link"></a></h5>

  <p>A <dfn id="concept-date">date</dfn> consists of a specific <a href="#proleptic-gregorian-date" id="dates:proleptic-gregorian-date">proleptic-Gregorian
  date</a> with no time-zone information, consisting of a year, a month, and a day.
  <a href="#refsGREGORIAN">[GREGORIAN]</a></p>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-date-string">valid date string</dfn> representing a year <var>year</var>, month
  <var>month</var>, and day <var>day</var> if it consists of the following
  components in the given order:</p>

  <ol><li>A <a href="#valid-month-string" id="dates:valid-month-string">valid month string</a>, representing <var>year</var> and <var>month</var></li><li>A U+002D HYPHEN-MINUS character (-)</li><li>Two <a id="dates:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing <var>day</var>, in the range
   1&nbsp;≤&nbsp;<var>day</var>&nbsp;≤&nbsp;<var>maxday</var> where <var>maxday</var> is the <a href="#number-of-days-in-month-month-of-year-year" id="dates:number-of-days-in-month-month-of-year-year">number of
   days in the month <var>month</var> and year <var>year</var></a></li></ol>
  </div>

  

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-date-string">parse a date string</dfn> are as follows. This will return either a date, or
  nothing. If at any point the algorithm says that it "fails", this means that it is aborted at that
  point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p><a href="#parse-a-date-component" id="dates:parse-a-date-component">Parse a date component</a> to obtain <var>year</var>, <var>month</var>, and <var>day</var>. If this returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.</p></li><li><p>Let <var>date</var> be the date with year <var>year</var>, month <var>month</var>, and day <var>day</var>.</p></li><li><p>Return <var>date</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-date-component">parse a date component</dfn>, given an <var>input</var> string and a
  <var>position</var>, are as follows. This will return either a year, a month, and a day,
  or nothing. If at any point the algorithm says that it "fails", this means that it is aborted at
  that point and returns nothing.</p>

  <ol><li><p><a href="#parse-a-month-component" id="dates:parse-a-month-component">Parse a month component</a> to obtain <var>year</var> and <var>month</var>. If this returns nothing, then fail.</p></li><li><p>Let <var>maxday</var> be the <a href="#number-of-days-in-month-month-of-year-year" id="dates:number-of-days-in-month-month-of-year-year-2">number of days in month <var>month</var> of year <var>year</var></a>.</p></li><li><p>If <var>position</var> is beyond the end of <var>input</var> or if the
   character at <var>position</var> is not a U+002D HYPHEN-MINUS character, then fail.
   Otherwise, move <var>position</var> forwards one character.</p></li><li><p><a id="dates:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="dates:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>. If the collected sequence is not exactly two
   characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten integer.
   Let <var>day</var> be that number.</p></li><li><p>If <var>day</var> is not a number in the range 1&nbsp;≤&nbsp;<var>day</var>&nbsp;≤&nbsp;<var>maxday</var>, then fail.</p></li><li><p>Return <var>year</var>, <var>month</var>, and <var>day</var>.</p></li></ol>
  </div>

  


  <h5 id="yearless-dates"><span class="secno">2.3.5.3</span> Yearless dates<a href="#yearless-dates" class="self-link"></a></h5>

  <p>A <dfn id="concept-yearless-date">yearless date</dfn> consists of a Gregorian month and a
  day within that month, but with no associated year. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-yearless-date-string">valid yearless date string</dfn> representing a month <var>month</var> and a day <var>day</var> if it consists of the following components
  in the given order:</p>

  <ol><li>Optionally, two U+002D HYPHEN-MINUS characters (-)</li><li>Two <a id="yearless-dates:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing the month <var>month</var>, in the range
   1&nbsp;≤&nbsp;<var>month</var>&nbsp;≤&nbsp;12</li><li>A U+002D HYPHEN-MINUS character (-)</li><li>Two <a id="yearless-dates:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing <var>day</var>, in the range
   1&nbsp;≤&nbsp;<var>day</var>&nbsp;≤&nbsp;<var>maxday</var> where <var>maxday</var> is the <a href="#number-of-days-in-month-month-of-year-year" id="yearless-dates:number-of-days-in-month-month-of-year-year">number of
   days</a> in the month <var>month</var> and any arbitrary leap year (e.g. 4 or
   2000)</li></ol>

  <p class="note">In other words, if the <var>month</var> is "<code>02</code>",
  meaning February, then the day can be 29, as if the year was a leap year.</p>
  </div>

  

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-yearless-date-string">parse a yearless date string</dfn> are as follows. This will return either a
  month and a day, or nothing. If at any point the algorithm says that it "fails", this means that
  it is aborted at that point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p><a href="#parse-a-yearless-date-component" id="yearless-dates:parse-a-yearless-date-component">Parse a yearless date component</a> to obtain <var>month</var> and <var>day</var>. If this returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.</p></li><li><p>Return <var>month</var> and <var>day</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-yearless-date-component">parse a yearless date component</dfn>, given an <var>input</var>
  string and a <var>position</var>, are as follows. This will return either a month and a
  day, or nothing. If at any point the algorithm says that it "fails", this means that it is aborted
  at that point and returns nothing.</p>

  <ol><li><p><a id="yearless-dates:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are U+002D HYPHEN-MINUS characters (-)
   from <var>input</var> given <var>position</var>. If the collected sequence is not exactly zero or
   two characters long, then fail.</p></li><li><p><a id="yearless-dates:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="yearless-dates:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>. If the collected sequence is not exactly two
   characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten integer.
   Let <var>month</var> be that number.</p></li><li><p>If <var>month</var> is not a number in the range 1&nbsp;≤&nbsp;<var>month</var>&nbsp;≤&nbsp;12, then fail.</p></li><li><p>Let <var>maxday</var> be the <a href="#number-of-days-in-month-month-of-year-year" id="yearless-dates:number-of-days-in-month-month-of-year-year-2">number of days</a> in month <var>month</var> of any arbitrary leap year (e.g. 4
   or 2000).</p></li><li><p>If <var>position</var> is beyond the end of <var>input</var> or if the
   character at <var>position</var> is not a U+002D HYPHEN-MINUS character, then fail.
   Otherwise, move <var>position</var> forwards one character.</p></li><li><p><a id="yearless-dates:collect-a-sequence-of-code-points-3" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="yearless-dates:ascii-digits-4" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>. If the collected sequence is not exactly two
   characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten integer.
   Let <var>day</var> be that number.</p></li><li><p>If <var>day</var> is not a number in the range 1&nbsp;≤&nbsp;<var>day</var>&nbsp;≤&nbsp;<var>maxday</var>, then fail.</p></li><li><p>Return <var>month</var> and <var>day</var>.</p></li></ol>
  </div>

  


  <h5 id="times"><span class="secno">2.3.5.4</span> Times<a href="#times" class="self-link"></a></h5>

  <p>A <dfn id="concept-time">time</dfn> consists of a specific time with no time-zone
  information, consisting of an hour, a minute, a second, and a fraction of a second.</p>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-time-string">valid time string</dfn> representing an hour <var>hour</var>, a
  minute <var>minute</var>, and a second <var>second</var> if it consists of the
  following components in the given order:</p>

  <ol><li>Two <a id="times:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing <var>hour</var>, in the range
   0&nbsp;≤&nbsp;<var>hour</var>&nbsp;≤&nbsp;23</li><li>A U+003A COLON character (:)</li><li>Two <a id="times:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing <var>minute</var>, in the range
   0&nbsp;≤&nbsp;<var>minute</var>&nbsp;≤&nbsp;59</li><li>If <var>second</var> is nonzero, or optionally if <var>second</var> is
   zero:

    <ol><li>A U+003A COLON character (:)</li><li>Two <a id="times:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing the integer part of <var>second</var>,
     in the range 0&nbsp;≤&nbsp;<var>s</var>&nbsp;≤&nbsp;59</li><li>If <var>second</var> is not an integer, or optionally if <var>second</var> is an integer:

      <ol><li>A U+002E FULL STOP character (.)</li><li>One, two, or three <a id="times:ascii-digits-4" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing the fractional part of <var>second</var></li></ol>
     </li></ol>
   </li></ol>

  <p class="note">The <var>second</var> component cannot be 60 or 61; leap seconds cannot
  be represented.</p>
  </div>

  

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-time-string">parse a time string</dfn> are as follows. This will return either a time, or
  nothing. If at any point the algorithm says that it "fails", this means that it is aborted at that
  point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p><a href="#parse-a-time-component" id="times:parse-a-time-component">Parse a time component</a> to obtain <var>hour</var>, <var>minute</var>, and <var>second</var>. If this returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.</p></li><li><p>Let <var>time</var> be the time with hour <var>hour</var>, minute <var>minute</var>, and second <var>second</var>.</p></li><li><p>Return <var>time</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-time-component">parse a time component</dfn>, given an <var>input</var> string and a
  <var>position</var>, are as follows. This will return either an hour, a minute, and a
  second, or nothing. If at any point the algorithm says that it "fails", this means that it is
  aborted at that point and returns nothing.</p>

  <ol><li><p><a id="times:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="times:ascii-digits-5" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>. If the collected sequence is not exactly two
   characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten integer.
   Let <var>hour</var> be that number.</p></li><li>If <var>hour</var> is not a number in the range 0&nbsp;≤&nbsp;<var>hour</var>&nbsp;≤&nbsp;23, then fail.</li><li><p>If <var>position</var> is beyond the end of <var>input</var> or if the
   character at <var>position</var> is not a U+003A COLON character, then fail. Otherwise,
   move <var>position</var> forwards one character.</p></li><li><p><a id="times:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="times:ascii-digits-6" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>. If the collected sequence is not exactly two
   characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten integer.
   Let <var>minute</var> be that number.</p></li><li>If <var>minute</var> is not a number in the range 0&nbsp;≤&nbsp;<var>minute</var>&nbsp;≤&nbsp;59, then fail.</li><li><p>Let <var>second</var> be 0.</p></li><li>
    <p>If <var>position</var> is not beyond the end of <var>input</var> and the character at
    <var>position</var> is U+003A (:), then:</p>

    <ol><li><p>Advance <var>position</var> to the next character in <var>input</var>.</p></li><li><p>If <var>position</var> is beyond the end of <var>input</var>, or at
     the last character in <var>input</var>, or if the next <em>two</em> characters in <var>input</var> starting at <var>position</var> are not both <a id="times:ascii-digits-7" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
     digits</a>, then fail.</p></li><li><p><a id="times:collect-a-sequence-of-code-points-3" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are either <a id="times:ascii-digits-8" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>
     or U+002E FULL STOP characters from <var>input</var> given <var>position</var>. If the
     collected sequence is three characters long, or if it is longer than three characters long and
     the third character is not a U+002E FULL STOP character, or if it has more than one U+002E FULL
     STOP character, then fail. Otherwise, interpret the resulting sequence as a base-ten number
     (possibly with a fractional part). Set <var>second</var> to that number.</p></li><li><p>If <var>second</var> is not a number in the range
     0&nbsp;≤&nbsp;<var>second</var>&nbsp;&lt;&nbsp;60, then fail.</p></li></ol>
   </li><li><p>Return <var>hour</var>, <var>minute</var>, and <var>second</var>.</p></li></ol>
  </div>

  


  <h5 id="local-dates-and-times"><span class="secno">2.3.5.5</span> Local dates and times<a href="#local-dates-and-times" class="self-link"></a></h5>

  <p>A <dfn id="concept-datetime-local">local date and time</dfn> consists of a specific
  <a href="#proleptic-gregorian-date" id="local-dates-and-times:proleptic-gregorian-date">proleptic-Gregorian date</a>, consisting of a year, a month, and a day, and a time,
  consisting of an hour, a minute, a second, and a fraction of a second, but expressed without a
  time zone. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-local-date-and-time-string">valid local date and time string</dfn> representing a date and time if it
  consists of the following components in the given order:</p>

  <ol><li>A <a href="#valid-date-string" id="local-dates-and-times:valid-date-string">valid date string</a> representing the date</li><li>A U+0054 LATIN CAPITAL LETTER T character (T) or a U+0020 SPACE character</li><li>A <a href="#valid-time-string" id="local-dates-and-times:valid-time-string">valid time string</a> representing the time</li></ol>
  </div>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-normalised-local-date-and-time-string">valid
  normalized local date and time string</dfn> representing a date and time if it consists of the
  following components in the given order:</p>

  <ol><li>A <a href="#valid-date-string" id="local-dates-and-times:valid-date-string-2">valid date string</a> representing the date</li><li>A U+0054 LATIN CAPITAL LETTER T character (T)</li><li>A <a href="#valid-time-string" id="local-dates-and-times:valid-time-string-2">valid time string</a> representing the time, expressed as the shortest possible
   string for the given time (e.g. omitting the seconds component entirely if the given time is zero
   seconds past the minute)</li></ol>
  </div>

  

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-local-date-and-time-string">parse a local date and time string</dfn> are as follows. This will return
  either a date and time, or nothing. If at any point the algorithm says that it "fails", this means
  that it is aborted at that point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p><a href="#parse-a-date-component" id="local-dates-and-times:parse-a-date-component">Parse a date component</a> to obtain <var>year</var>, <var>month</var>, and <var>day</var>. If this returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is beyond the end of <var>input</var> or if the
   character at <var>position</var> is neither a U+0054 LATIN CAPITAL LETTER T character
   (T) nor a U+0020 SPACE character, then fail. Otherwise, move <var>position</var>
   forwards one character.</p></li><li><p><a href="#parse-a-time-component" id="local-dates-and-times:parse-a-time-component">Parse a time component</a> to obtain <var>hour</var>, <var>minute</var>, and <var>second</var>. If this returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.</p></li><li><p>Let <var>date</var> be the date with year <var>year</var>, month <var>month</var>, and day <var>day</var>.</p></li><li><p>Let <var>time</var> be the time with hour <var>hour</var>, minute <var>minute</var>, and second <var>second</var>.</p></li><li><p>Return <var>date</var> and <var>time</var>.</p></li></ol>
  </div>

  


  <h5 id="time-zones"><span class="secno">2.3.5.6</span> Time zones<a href="#time-zones" class="self-link"></a></h5>

  <p>A <dfn id="concept-timezone">time-zone offset</dfn> consists of a signed number of hours and
  minutes.</p>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-time-zone-offset-string">valid time-zone offset string</dfn> representing a time-zone offset if it
  consists of either:</p>


  <ul><li><p>A U+005A LATIN CAPITAL LETTER Z character (Z), allowed only if the time zone is
   UTC</p></li><li>
    <p>Or, the following components, in the given order:</p>

    <ol><li>Either a U+002B PLUS SIGN character (+) or, if the time-zone offset is not zero, a U+002D
     HYPHEN-MINUS character (-), representing the sign of the time-zone offset</li><li>Two <a id="time-zones:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing the hours component <var>hour</var> of
     the time-zone offset, in the range 0&nbsp;≤&nbsp;<var>hour</var>&nbsp;≤&nbsp;23</li><li>Optionally, a U+003A COLON character (:)</li><li>Two <a id="time-zones:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing the minutes component <var>minute</var> of the time-zone offset, in the range 0&nbsp;≤&nbsp;<var>minute</var>&nbsp;≤&nbsp;59</li></ol>
   </li></ul>
  </div>

  <p class="note">This format allows for time-zone offsets from -23:59 to +23:59. Right now, in
  practice, the range of offsets of actual time zones is -12:00 to +14:00, and the minutes component
  of offsets of actual time zones is always either 00, 30, or 45. There is no guarantee that this
  will remain so forever, however, since time zones are used as political footballs and are thus
  subject to very whimsical policy decisions.</p>

  <p class="note">See also the usage notes and examples in the <a href="#concept-datetime" id="time-zones:concept-datetime">global
  date and time</a> section below for details on using time-zone offsets with historical times
  that predate the formation of formal time zones.</p>

  

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-time-zone-offset-string">parse a time-zone offset string</dfn> are as follows. This will return either
  a time-zone offset, or nothing. If at any point the algorithm says that it "fails", this means
  that it is aborted at that point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p><a href="#parse-a-time-zone-offset-component" id="time-zones:parse-a-time-zone-offset-component">Parse a time-zone offset component</a> to obtain <var>timezone<sub>hours</sub></var> and <var>timezone<sub>minutes</sub></var>. If this
   returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.</p></li><li><p>Return the time-zone offset that is <var>timezone<sub>hours</sub></var>
   hours and <var>timezone<sub>minutes</sub></var> minutes from UTC.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-time-zone-offset-component">parse a time-zone offset component</dfn>, given an <var>input</var>
  string and a <var>position</var>, are as follows. This will return either time-zone hours
  and time-zone minutes, or nothing. If at any point the algorithm says that it "fails", this means
  that it is aborted at that point and returns nothing.</p>

  <ol><li>
    <p>If the character at <var>position</var> is a U+005A LATIN CAPITAL LETTER Z character
    (Z), then:</p>

    <ol><li><p>Let <var>timezone<sub>hours</sub></var> be 0.</p></li><li><p>Let <var>timezone<sub>minutes</sub></var> be 0.</p></li><li><p>Advance <var>position</var> to the next character in <var>input</var>.</p></li></ol>

    <p>Otherwise, if the character at <var>position</var> is either a U+002B PLUS SIGN (+)
    or a U+002D HYPHEN-MINUS (-), then:</p>

    <ol><li><p>If the character at <var>position</var> is a U+002B PLUS SIGN (+), let <var>sign</var> be "positive". Otherwise, it's a U+002D HYPHEN-MINUS (-); let <var>sign</var> be "negative".</p></li><li><p>Advance <var>position</var> to the next character in <var>input</var>.</p></li><li><p><a id="time-zones:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="time-zones:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
     <var>input</var> given <var>position</var>. Let <var>s</var> be the collected
     sequence.</p></li><li>
      <p>If <var>s</var> is exactly two characters long, then:</p>

      <ol><li><p>Interpret <var>s</var> as a base-ten integer. Let <var>timezone<sub>hours</sub></var> be that number.</p></li><li><p>If <var>position</var> is beyond the end of <var>input</var> or if
       the character at <var>position</var> is not a U+003A COLON character, then fail.
       Otherwise, move <var>position</var> forwards one character.</p></li><li><p><a id="time-zones:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="time-zones:ascii-digits-4" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
       <var>input</var> given <var>position</var>. If the collected sequence is not exactly two
       characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten
       integer. Let <var>timezone<sub>minutes</sub></var> be that number.</p></li></ol>

      <p>If <var>s</var> is exactly four characters long, then:</p>

      <ol><li><p>Interpret the first two characters of <var>s</var> as a base-ten integer. Let
       <var>timezone<sub>hours</sub></var> be that number.</p></li><li><p>Interpret the last two characters of <var>s</var> as a base-ten integer. Let
       <var>timezone<sub>minutes</sub></var> be that number.</p></li></ol>

      <p>Otherwise, fail.</p>
     </li><li>If <var>timezone<sub>hours</sub></var> is not a number in the range
     0&nbsp;≤&nbsp;<var>timezone<sub>hours</sub></var>&nbsp;≤&nbsp;23, then
     fail.</li><li>If <var>sign</var> is "negative", then negate <var>timezone<sub>hours</sub></var>.</li><li>If <var>timezone<sub>minutes</sub></var> is not a number in the range
     0&nbsp;≤&nbsp;<var>timezone<sub>minutes</sub></var>&nbsp;≤&nbsp;59,
     then fail.</li><li>If <var>sign</var> is "negative", then negate <var>timezone<sub>minutes</sub></var>.</li></ol>

    <p>Otherwise, fail.</p>
   </li><li><p>Return <var>timezone<sub>hours</sub></var> and <var>timezone<sub>minutes</sub></var>.</p></li></ol>
  </div>

  


  <h5 id="global-dates-and-times"><span class="secno">2.3.5.7</span> Global dates and times<a href="#global-dates-and-times" class="self-link"></a></h5>

  <p>A <dfn id="concept-datetime">global date and time</dfn> consists of a specific
  <a href="#proleptic-gregorian-date" id="global-dates-and-times:proleptic-gregorian-date">proleptic-Gregorian date</a>, consisting of a year, a month, and a day, and a time,
  consisting of an hour, a minute, a second, and a fraction of a second, expressed with a time-zone
  offset, consisting of a signed number of hours and minutes. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-global-date-and-time-string">valid global date and time string</dfn> representing a date, time, and a
  time-zone offset if it consists of the following components in the given order:</p>

  <ol><li>A <a href="#valid-date-string" id="global-dates-and-times:valid-date-string">valid date string</a> representing the date</li><li>A U+0054 LATIN CAPITAL LETTER T character (T) or a U+0020 SPACE character</li><li>A <a href="#valid-time-string" id="global-dates-and-times:valid-time-string">valid time string</a> representing the time</li><li>A <a href="#valid-time-zone-offset-string" id="global-dates-and-times:valid-time-zone-offset-string">valid time-zone offset string</a> representing the time-zone offset</li></ol>
  </div>

  <p>Times in dates before the formation of UTC in the mid-twentieth century must be expressed and
  interpreted in terms of UT1 (contemporary Earth solar time at the 0° longitude), not UTC (the
  approximation of UT1 that ticks in SI seconds). Time before the formation of time zones must be
  expressed and interpreted as UT1 times with explicit time zones that approximate the contemporary
  difference between the appropriate local time and the time observed at the location of Greenwich,
  London.</p>

  <div class="example">

   <p>The following are some examples of dates written as <a href="#valid-global-date-and-time-string" id="global-dates-and-times:valid-global-date-and-time-string">valid global date and time strings</a>.</p>

   <dl><dt>"<code>0037-12-13 00:00Z</code>"</dt><dd>Midnight in areas using London time on the birthday of Nero (the Roman Emperor). See below
    for further discussion on which date this actually corresponds to.</dd><dt>"<code>1979-10-14T12:00:00.001-04:00</code>"</dt><dd>One millisecond after noon on October 14th 1979, in the time zone in use on the east coast
    of the USA during daylight saving time.</dd><dt>"<code>8592-01-01T02:09+02:09</code>"</dt><dd>Midnight UTC on the 1st of January, 8592. The time zone associated with that time is two
    hours and nine minutes ahead of UTC, which is not currently a real time zone, but is nonetheless
    allowed.</dd></dl>

   <p>Several things are notable about these dates:</p>

   <ul><li>Years with fewer than four digits have to be zero-padded. The date "37-12-13" would not be a
    valid date.</li><li>If the "<code>T</code>" is replaced by a space, it must be a single space
    character. The string "<code>2001-12-21&nbsp;&nbsp;12:00Z</code>" (with two spaces
    between the components) would not be parsed successfully.</li><li>To unambiguously identify a moment in time prior to the introduction of the Gregorian
    calendar (insofar as moments in time before the formation of UTC can be unambiguously
    identified), the date has to be first converted to the Gregorian calendar from the calendar in
    use at the time (e.g. from the Julian calendar). The date of Nero's birth is the 15th of
    December 37, in the Julian Calendar, which is the 13th of December 37 in the <a href="#proleptic-gregorian-calendar" id="global-dates-and-times:proleptic-gregorian-calendar">proleptic
    Gregorian calendar</a>.</li><li>The time and time-zone offset components are not optional.</li><li>Dates before the year one can't be represented as a datetime in this version of HTML.</li><li>Times of specific events in ancient times are, at best, approximations, since time was not
    well coordinated or measured until relatively recent decades.</li><li>Time-zone offsets differ based on daylight saving time.</li></ul>

  </div>

  

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-global-date-and-time-string">parse a global date and time string</dfn> are as follows. This will return
  either a time in UTC, with associated time-zone offset information for round-tripping or display
  purposes, or nothing. If at any point the algorithm says that it "fails", this means that it is
  aborted at that point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p><a href="#parse-a-date-component" id="global-dates-and-times:parse-a-date-component">Parse a date component</a> to obtain <var>year</var>, <var>month</var>, and <var>day</var>. If this returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is beyond the end of <var>input</var> or if the
   character at <var>position</var> is neither a U+0054 LATIN CAPITAL LETTER T character
   (T) nor a U+0020 SPACE character, then fail. Otherwise, move <var>position</var>
   forwards one character.</p></li><li><p><a href="#parse-a-time-component" id="global-dates-and-times:parse-a-time-component">Parse a time component</a> to obtain <var>hour</var>, <var>minute</var>, and <var>second</var>. If this returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is beyond the end of <var>input</var>, then
   fail.</p></li><li><p><a href="#parse-a-time-zone-offset-component" id="global-dates-and-times:parse-a-time-zone-offset-component">Parse a time-zone offset component</a> to obtain <var>timezone<sub>hours</sub></var> and <var>timezone<sub>minutes</sub></var>. If this
   returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.</p></li><li><p>Let <var>time</var> be the moment in time at year <var>year</var>, month
   <var>month</var>, day <var>day</var>, hours <var>hour</var>, minute
   <var>minute</var>, second <var>second</var>, subtracting <var>timezone<sub>hours</sub></var> hours and <var>timezone<sub>minutes</sub></var> minutes. That moment in time is a moment in the UTC time
   zone.</p></li><li><p>Let <var>timezone</var> be <var>timezone<sub>hours</sub></var>
   hours and <var>timezone<sub>minutes</sub></var> minutes from UTC.</p></li><li><p>Return <var>time</var> and <var>timezone</var>.</p></li></ol>
  </div>

  


  <h5 id="weeks"><span class="secno">2.3.5.8</span> Weeks<a href="#weeks" class="self-link"></a></h5>

  <p>A <dfn id="concept-week">week</dfn> consists of a week-year number and a week number
  representing a seven-day period starting on a Monday. Each week-year in this calendaring system
  has either 52 or 53 such seven-day periods, as defined below. The seven-day period starting on the
  Gregorian date Monday December 29th 1969 (1969-12-29) is defined as week number 1 in week-year
  1970. Consecutive weeks are numbered sequentially. The week before the number 1 week in a
  week-year is the last week in the previous week-year, and vice versa. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>

  <div data-algorithm="">
  <p>A week-year with a number <var>year</var> has 53 weeks if it corresponds to either a
  year <var>year</var> in the <a href="#proleptic-gregorian-calendar" id="weeks:proleptic-gregorian-calendar">proleptic Gregorian calendar</a> that has a Thursday
  as its first day (January 1st), or a year <var>year</var> in the <a href="#proleptic-gregorian-calendar" id="weeks:proleptic-gregorian-calendar-2">proleptic
  Gregorian calendar</a> that has a Wednesday as its first day (January 1st) and where <var>year</var> is a number divisible by 400, or a number divisible by 4 but not by 100. All
  other week-years have 52 weeks.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="week-number-of-the-last-day">week number of the last day</dfn> of a week-year with 53 weeks is 53; the week number
  of the last day of a week-year with 52 weeks is 52.</p>
  </div>

  <p data-var-scope="" class="note">The week-year number of a particular day can be different than the number of the
  year that contains that day in the <a href="#proleptic-gregorian-calendar" id="weeks:proleptic-gregorian-calendar-3">proleptic Gregorian calendar</a>. The first week in a
  week-year <var>y</var> is the week that contains the first Thursday of the Gregorian year
  <var>y</var>.</p>

  <p class="note">For modern purposes, a <a href="#concept-week" id="weeks:concept-week">week</a> as defined here is
  equivalent to ISO weeks as defined in ISO 8601. <a href="#refsISO8601">[ISO8601]</a></p>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-week-string">valid week string</dfn> representing a week-year <var>year</var>
  and week <var>week</var> if it consists of the following components in the given
  order:</p>

  <ol><li>Four or more <a id="weeks:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing <var>year</var>, where <var>year</var>&nbsp;&gt;&nbsp;0</li><li>A U+002D HYPHEN-MINUS character (-)</li><li>A U+0057 LATIN CAPITAL LETTER W character (W)</li><li>Two <a id="weeks:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing the week <var>week</var>, in the range
   1&nbsp;≤&nbsp;<var>week</var>&nbsp;≤&nbsp;<var>maxweek</var>, where <var>maxweek</var> is the <a href="#week-number-of-the-last-day" id="weeks:week-number-of-the-last-day">week number of the last day</a> of week-year <var>year</var></li></ol>
  </div>

  

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-week-string">parse a week string</dfn> are as follows. This will return either a week-year
  number and week number, or nothing. If at any point the algorithm says that it "fails", this means
  that it is aborted at that point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p><a id="weeks:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="weeks:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>. If the collected sequence is not at least four
   characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten integer.
   Let <var>year</var> be that number.</p></li><li><p>If <var>year</var> is not a number greater than zero, then fail.</p></li><li><p>If <var>position</var> is beyond the end of <var>input</var> or if the
   character at <var>position</var> is not a U+002D HYPHEN-MINUS character, then fail.
   Otherwise, move <var>position</var> forwards one character.</p></li><li><p>If <var>position</var> is beyond the end of <var>input</var> or if the
   character at <var>position</var> is not a U+0057 LATIN CAPITAL LETTER W character (W),
   then fail. Otherwise, move <var>position</var> forwards one character.</p></li><li><p><a id="weeks:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="weeks:ascii-digits-4" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>. If the collected sequence is not exactly two
   characters long, then fail. Otherwise, interpret the resulting sequence as a base-ten integer.
   Let <var>week</var> be that number.</p></li><li><p>Let <var>maxweek</var> be the <a href="#week-number-of-the-last-day" id="weeks:week-number-of-the-last-day-2">week number of the last day</a> of year
   <var>year</var>.</p></li><li><p>If <var>week</var> is not a number in the range 1&nbsp;≤&nbsp;<var>week</var>&nbsp;≤&nbsp;<var>maxweek</var>, then fail.</p></li><li><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.</p></li><li><p>Return the week-year number <var>year</var> and the week number <var>week</var>.</p></li></ol>
  </div>

  


  <h5 id="durations"><span class="secno">2.3.5.9</span> Durations<a href="#durations" class="self-link"></a></h5>

  

  <p>A <dfn id="concept-duration">duration</dfn> consists of  a number of seconds.</p>

  <p class="note">Since months and seconds are not comparable (a month is not a precise number of
  seconds, but is instead a period whose exact length depends on the precise day from which it is
  measured) a <a href="#concept-duration" id="durations:concept-duration">duration</a> as defined in this specification cannot
   include months (or years, which are equivalent to
  twelve months). Only durations that describe a specific number of seconds can be described.</p>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-duration-string">valid duration string</dfn> representing a <a href="#concept-duration" id="durations:concept-duration-2">duration</a> <var>t</var> if it consists of either of the
  following:</p>

  <ul><li>
    

    

    <p>A literal U+0050 LATIN CAPITAL LETTER P character followed by one or more of the following
    subcomponents, in the order given, where the number of days, hours, minutes, and
    seconds corresponds to the same number of seconds as in <var>t</var>:</p>

    <ol><li><p>One or more <a id="durations:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> followed by a U+0044 LATIN CAPITAL LETTER D
     character, representing a number of days.</p></li><li>
      <p>A U+0054 LATIN CAPITAL LETTER T character followed by one or more of the following
      subcomponents, in the order given:</p>

      <ol><li><p>One or more <a id="durations:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> followed by a U+0048 LATIN CAPITAL LETTER H
       character, representing a number of hours.</p></li><li><p>One or more <a id="durations:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> followed by a U+004D LATIN CAPITAL LETTER M
       character, representing a number of minutes.</p></li><li>
        <p>The following components:</p>

        <ol><li><p>One or more <a id="durations:ascii-digits-4" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing a number of seconds.</p></li><li><p>Optionally, a U+002E FULL STOP character (.) followed by one, two, or three
         <a id="durations:ascii-digits-5" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing a fraction of a second.</p></li><li><p>A U+0053 LATIN CAPITAL LETTER S character.</p></li></ol>
       </li></ol>
     </li></ol>

    <p class="note">This, as with a number of other date- and time-related microsyntaxes defined in
    this specification, is based on one of the formats defined in ISO 8601. <a href="#refsISO8601">[ISO8601]</a></p>
   </li><li>
    <p>One or more <a href="#duration-time-component" id="durations:duration-time-component">duration time components</a>, each with
    a different <a href="#duration-time-component-scale" id="durations:duration-time-component-scale">duration time component scale</a>, in any order; the sum of the represented
    seconds being equal to the number of seconds in <var>t</var>.</p>

    <p>A <dfn id="duration-time-component">duration time component</dfn> is a string consisting of the following components:</p>

    <ol><li><p>Zero or more <a id="durations:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p></li><li><p>One or more <a id="durations:ascii-digits-6" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing a number of time units, scaled by
     the <a href="#duration-time-component-scale" id="durations:duration-time-component-scale-2">duration time component scale</a> specified (see below) to represent a number of
     seconds.</p></li><li><p>If the <a href="#duration-time-component-scale" id="durations:duration-time-component-scale-3">duration time component scale</a> specified is 1 (i.e. the units are
     seconds), then, optionally, a U+002E FULL STOP character (.) followed by one, two, or three
     <a id="durations:ascii-digits-7" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing a fraction of a second.</p></li><li><p>Zero or more <a id="durations:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p></li><li>
      <p>One of the following characters, representing the <dfn id="duration-time-component-scale">duration time component scale</dfn>
      of the time unit used in the numeric part of the <a href="#duration-time-component" id="durations:duration-time-component-2">duration time component</a>:</p>

      <dl><dt>U+0057 LATIN CAPITAL LETTER W character</dt><dt>U+0077 LATIN SMALL LETTER W character</dt><dd>Weeks. The scale is 604800.</dd><dt>U+0044 LATIN CAPITAL LETTER D character</dt><dt>U+0064 LATIN SMALL LETTER D character</dt><dd>Days. The scale is 86400.</dd><dt>U+0048 LATIN CAPITAL LETTER H character</dt><dt>U+0068 LATIN SMALL LETTER H character</dt><dd>Hours. The scale is 3600.</dd><dt>U+004D LATIN CAPITAL LETTER M character</dt><dt>U+006D LATIN SMALL LETTER M character</dt><dd>Minutes. The scale is 60.</dd><dt>U+0053 LATIN CAPITAL LETTER S character</dt><dt>U+0073 LATIN SMALL LETTER S character</dt><dd>Seconds. The scale is 1.</dd></dl>
     </li><li><p>Zero or more <a id="durations:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p></li></ol>

    <p class="note">This is not based on any of the formats in ISO 8601. It is intended to be a more
    human-readable alternative to the ISO 8601 duration format.</p>
   </li></ul>
  </div>

  

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-duration-string">parse a duration string</dfn> are as follows. This will return either a <a href="#concept-duration" id="durations:concept-duration-3">duration</a> or nothing. If at any point the algorithm says that it
  "fails", this means that it is aborted at that point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p>Let <var>months</var>, <var>seconds</var>, and <var>component
   count</var> all be zero.</p></li><li>
    <p>Let <var>M-disambiguator</var> be <i>minutes</i>.</p>

    
    <p class="note">This flag's other value is <i>months</i>. It is used to disambiguate the "M"
    unit in ISO8601 durations, which use the same unit for months and minutes. Months are not
    allowed, but are parsed for future compatibility and to avoid misinterpreting ISO8601 durations
    that would be valid in other contexts.</p>
   </li><li><p><a id="durations:skip-ascii-whitespace" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
   <var>position</var>.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, then
   fail.</p></li><li><p>If the character in <var>input</var> pointed to by <var>position</var> is a U+0050 LATIN
   CAPITAL LETTER P character, then advance <var>position</var> to the next character, set
   <var>M-disambiguator</var> to <i>months</i>, and <a id="durations:skip-ascii-whitespace-2" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">skip ASCII whitespace</a> within
   <var>input</var> given <var>position</var>.</p></li><li>
    <p>While true:</p>

    <ol><li><p>Let <var>units</var> be undefined. It will be assigned one of the following
     values: <i>years</i>, <i>months</i>, <i>weeks</i>, <i>days</i>, <i>hours</i>, <i>minutes</i>,
     and <i>seconds</i>.</p></li><li><p>Let <var>next character</var> be undefined. It is used to process characters
     from the <var>input</var>.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, then break.</p></li><li><p>If the character in <var>input</var> pointed to by <var>position</var> is a U+0054 LATIN
     CAPITAL LETTER T character, then advance <var>position</var> to the next character, set
     <var>M-disambiguator</var> to <i>minutes</i>, <a id="durations:skip-ascii-whitespace-3" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">skip ASCII whitespace</a> within
     <var>input</var> given <var>position</var>, and <a id="durations:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Set <var>next character</var> to the character in <var>input</var>
     pointed to by <var>position</var>.</p></li><li>
      <p>If <var>next character</var> is a U+002E FULL STOP character (.), then let <var>N</var> be 0. (Do not advance <var>position</var>. That is taken care
      of below.)</p>

      <p>Otherwise, if <var>next character</var> is an <a href="https://infra.spec.whatwg.org/#ascii-digit" id="durations:ascii-digits-8" data-x-internal="ascii-digits">ASCII
      digit</a>, then <a id="durations:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">collect a sequence of code points</a> that are <a id="durations:ascii-digits-9" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
      digits</a> from <var>input</var> given <var>position</var>, interpret the resulting
      sequence as a base-ten integer, and let <var>N</var> be that number.</p>

      <p>Otherwise, <var>next character</var> is not part of a number; fail.</p>
     </li><li><p>If <var>position</var> is past the end of <var>input</var>, then
     fail.</p></li><li><p>Set <var>next character</var> to the character in <var>input</var>
     pointed to by <var>position</var>, and this time advance <var>position</var>
     to the next character. (If <var>next character</var> was a U+002E FULL STOP character
     (.) before, it will still be that character this time.)</p></li><li>
      <p>If <var>next character</var> is U+002E (.), then:</p>

      <ol><li><p><a id="durations:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="durations:ascii-digits-10" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
       <var>input</var> given <var>position</var>. Let <var>s</var> be the resulting
       sequence.</p></li><li><p>If <var>s</var> is the empty string, then fail.</p></li><li><p>Let <var>length</var> be the number of characters in <var>s</var>.</p></li><li><p>Let <var>fraction</var> be the result of interpreting <var>s</var>
       as a base-ten integer, and then dividing that number by <span>10<sup><var>length</var></sup></span>.</p></li><li><p>Increment <var>N</var> by <var>fraction</var>.</p></li><li><p><a id="durations:skip-ascii-whitespace-4" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
       <var>position</var>.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, then
       fail.</p></li><li><p>Set <var>next character</var> to the character in <var>input</var>
       pointed to by <var>position</var>, and advance <var>position</var> to the
       next character.</p></li><li><p>If <var>next character</var> is neither a U+0053 LATIN CAPITAL LETTER S
       character nor a U+0073 LATIN SMALL LETTER S character, then fail.</p></li><li><p>Set <var>units</var> to <i>seconds</i>.</p></li></ol>

      <p>Otherwise:</p>

      <ol><li><p>If <var>next character</var> is <a id="durations:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, then <a id="durations:skip-ascii-whitespace-5" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">skip ASCII
       whitespace</a> within <var>input</var> given <var>position</var>, set <var>next
       character</var> to the character in <var>input</var> pointed to by <var>position</var>, and
       advance <var>position</var> to the next character.</p></li><li>
        

        <p>If <var>next character</var> is a U+0059 LATIN CAPITAL LETTER Y character, or a
        U+0079 LATIN SMALL LETTER Y character, set <var>units</var> to <i>years</i> and set
        <var>M-disambiguator</var> to <i>months</i>.</p>

        <p>If <var>next character</var> is a U+004D LATIN CAPITAL LETTER M character or a
        U+006D LATIN SMALL LETTER M character, and <var>M-disambiguator</var> is
        <i>months</i>, then set <var>units</var> to <i>months</i>.</p>

        <p>If <var>next character</var> is a U+0057 LATIN CAPITAL LETTER W character or a
        U+0077 LATIN SMALL LETTER W character, set <var>units</var> to <i>weeks</i> and set
        <var>M-disambiguator</var> to <i>minutes</i>.</p>

        <p>If <var>next character</var> is a U+0044 LATIN CAPITAL LETTER D character or a
        U+0064 LATIN SMALL LETTER D character, set <var>units</var> to <i>days</i> and set
        <var>M-disambiguator</var> to <i>minutes</i>.</p>

        <p>If <var>next character</var> is a U+0048 LATIN CAPITAL LETTER H character or a
        U+0068 LATIN SMALL LETTER H character, set <var>units</var> to <i>hours</i> and set
        <var>M-disambiguator</var> to <i>minutes</i>.</p>

        <p>If <var>next character</var> is a U+004D LATIN CAPITAL LETTER M character or a
        U+006D LATIN SMALL LETTER M character, and <var>M-disambiguator</var> is
        <i>minutes</i>, then set <var>units</var> to <i>minutes</i>.</p>

        <p>If <var>next character</var> is a U+0053 LATIN CAPITAL LETTER S character or a
        U+0073 LATIN SMALL LETTER S character, set <var>units</var> to <i>seconds</i> and
        set <var>M-disambiguator</var> to <i>minutes</i>.</p>

        <p>Otherwise, if <var>next character</var> is none of the above characters, then
        fail.</p>
       </li></ol>
     </li><li><p>Increment <var>component count</var>.</p></li><li><p>Let <var>multiplier</var> be 1.</p></li><li><p>If <var>units</var> is <i>years</i>, multiply <var>multiplier</var> by
     12 and set <var>units</var> to <i>months</i>.</p></li><li>
      <p>If <var>units</var> is <i>months</i>, add the product of <var>N</var> and
      <var>multiplier</var> to <var>months</var>.</p>

      <p>Otherwise:</p>

      <ol><li><p>If <var>units</var> is <i>weeks</i>, multiply <var>multiplier</var>
       by 7 and set <var>units</var> to <i>days</i>.</p></li><li><p>If <var>units</var> is <i>days</i>, multiply <var>multiplier</var>
       by 24 and set <var>units</var> to <i>hours</i>.</p></li><li><p>If <var>units</var> is <i>hours</i>, multiply <var>multiplier</var>
       by 60 and set <var>units</var> to <i>minutes</i>.</p></li><li><p>If <var>units</var> is <i>minutes</i>, multiply <var>multiplier</var> by 60 and set <var>units</var> to <i>seconds</i>.</p></li><li><p>Forcibly, <var>units</var> is now <i>seconds</i>. Add the product of <var>N</var> and <var>multiplier</var> to <var>seconds</var>.</p></li></ol>
     </li><li><p><a id="durations:skip-ascii-whitespace-6" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
     <var>position</var>.</p></li></ol>
   </li><li><p>If <var>component count</var> is zero,
   fail.</p></li><li><p>If <var>months</var> is not zero, fail.</p></li><li><p>Return the <a href="#concept-duration" id="durations:concept-duration-4">duration</a> consisting of <var>seconds</var> seconds.</p></li></ol>
  </div>

  


  <h5 id="vaguer-moments-in-time"><span class="secno">2.3.5.10</span> Vaguer moments in time<a href="#vaguer-moments-in-time" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-date-string-with-optional-time">valid date string with optional time</dfn> if
  it is also one of the following:</p>

  <ul><li>A <a href="#valid-date-string" id="vaguer-moments-in-time:valid-date-string">valid date string</a></li><li>A <a href="#valid-global-date-and-time-string" id="vaguer-moments-in-time:valid-global-date-and-time-string">valid global date and time string</a></li></ul>
  </div>

  

  <hr>

  <div data-algorithm="">
  <p>The rules to <dfn id="parse-a-date-or-time-string">parse a date or time string</dfn> are as follows. The algorithm will return
  either a <a href="#concept-date" id="vaguer-moments-in-time:concept-date">date</a>, a <a href="#concept-time" id="vaguer-moments-in-time:concept-time">time</a>, a <a href="#concept-datetime" id="vaguer-moments-in-time:concept-datetime">global date and time</a>, or nothing. If at any point the algorithm
  says that it "fails", this means that it is aborted at that point and returns nothing.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.</p></li><li><p>Set <var>start position</var> to the same position as <var>position</var>.</p></li><li><p>Set the <var>date present</var> and <var>time present</var> flags to
   true.</p></li><li><p><a href="#parse-a-date-component" id="vaguer-moments-in-time:parse-a-date-component">Parse a date component</a> to obtain <var>year</var>, <var>month</var>, and <var>day</var>. If this fails, then set the <var>date
   present</var> flag to false.</p>

   </li><li>
    <p>If <var>date present</var> is true, and <var>position</var> is not beyond
    the end of <var>input</var>, and the character at <var>position</var> is
    either a U+0054 LATIN CAPITAL LETTER T character (T) or a U+0020 SPACE character, then advance
    <var>position</var> to the next character in <var>input</var>.</p>

    <p>Otherwise, if <var>date present</var> is true, and either <var>position</var> is beyond the end of <var>input</var> or the character at <var>position</var> is neither a U+0054 LATIN CAPITAL LETTER T character (T) nor a U+0020
    SPACE character, then set <var>time present</var> to false.</p>

    <p>Otherwise, if <var>date present</var> is false, set <var>position</var>
    back to the same position as <var>start position</var>.</p>
   </li><li><p>If the <var>time present</var> flag is true, then <a href="#parse-a-time-component" id="vaguer-moments-in-time:parse-a-time-component">parse a time
   component</a> to obtain <var>hour</var>, <var>minute</var>, and <var>second</var>. If this returns nothing, then fail.</p></li><li><p>If the <var>date present</var> and <var>time present</var> flags are
   both true, but <var>position</var> is beyond the end of <var>input</var>, then
   fail.</p></li><li><p>If the <var>date present</var> and <var>time present</var> flags are
   both true, <a href="#parse-a-time-zone-offset-component" id="vaguer-moments-in-time:parse-a-time-zone-offset-component">parse a time-zone offset component</a> to obtain <var>timezone<sub>hours</sub></var> and <var>timezone<sub>minutes</sub></var>. If this
   returns nothing, then fail.</p>

   </li><li><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.</p></li><li>
    <p>If the <var>date present</var> flag is true and the <var>time present</var>
    flag is false, then let <var>date</var> be the date with year <var>year</var>,
    month <var>month</var>, and day <var>day</var>, and return <var>date</var>.</p>

    <p>Otherwise, if the <var>time present</var> flag is true and the <var>date
    present</var> flag is false, then let <var>time</var> be the time with hour <var>hour</var>, minute <var>minute</var>, and second <var>second</var>,
    and return <var>time</var>.</p>

    <p>Otherwise, let <var>time</var> be the moment in time at year <var>year</var>, month <var>month</var>, day <var>day</var>, hours <var>hour</var>, minute <var>minute</var>, second <var>second</var>,
    subtracting <var>timezone<sub>hours</sub></var> hours and <var>timezone<sub>minutes</sub></var> minutes, that moment in time being a moment
    in the UTC time zone; let <var>timezone</var> be <var>timezone<sub>hours</sub></var> hours and <var>timezone<sub>minutes</sub></var>
    minutes from UTC; and return <var>time</var> and <var>timezone</var>.</p>
   </li></ol>
  </div>

  


  

  <h4 id="colours"><span class="secno">2.3.6</span> Legacy colors<a href="#colours" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>Some obsolete legacy attributes parse colors using the
  <dfn id="rules-for-parsing-a-legacy-colour-value">rules for parsing a legacy color
  value</dfn>, given a string <var>input</var>. They will return either a CSS color or failure.</p>

  <ol><li><p>If <var>input</var> is the empty string, then return failure.</p></li><li><p><a id="colours:strip-leading-and-trailing-ascii-whitespace" href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">Strip leading and trailing ASCII whitespace</a> from <var>input</var>.</p></li><li><p>If <var>input</var> is an <a id="colours:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>transparent</code>", then return failure.</p></li><li>
    <p>If <var>input</var> is an <a id="colours:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the <a href="https://drafts.csswg.org/css-color/#named-color" id="colours:named-color" data-x-internal="named-color">named colors</a>, then return the CSS color corresponding to that
    keyword. <a href="#refsCSSCOLOR">[CSSCOLOR]</a></p>

    <p class="note"><a href="https://www.w3.org/TR/css3-color/#css2-system">CSS2 System
    Colors</a> are not recognized.</p>
   </li><li>
    <p>If <var>input</var>'s <a id="colours:code-point-length" href="https://infra.spec.whatwg.org/#string-code-point-length" data-x-internal="code-point-length">code point length</a> is four, and the first character in
    <var>input</var> is U+0023 (#), and the last three characters of <var>input</var> are all
    <a id="colours:ascii-hex-digits" href="https://infra.spec.whatwg.org/#ascii-hex-digit" data-x-internal="ascii-hex-digits">ASCII hex digits</a>, then:</p>

    <ol><li><p>Let <var>result</var> be a CSS color.</p>

     </li><li><p>Interpret the second character of <var>input</var> as a hexadecimal digit; let
     the red component of <var>result</var> be the resulting number multiplied by 17.</p>

     </li><li><p>Interpret the third character of <var>input</var> as a hexadecimal digit; let
     the green component of <var>result</var> be the resulting number multiplied by 17.</p>

     </li><li><p>Interpret the fourth character of <var>input</var> as a hexadecimal digit; let
     the blue component of <var>result</var> be the resulting number multiplied by 17.</p>

     </li><li><p>Return <var>result</var>.</p>
    </li></ol>
   </li><li><p>Replace any <a href="https://infra.spec.whatwg.org/#code-point" id="colours:code-point" data-x-internal="code-point">code points</a> greater than U+FFFF in
   <var>input</var> (i.e., any characters that are not in the basic multilingual plane) with "<code>00</code>".</p></li><li><p>If <var>input</var>'s <a id="colours:code-point-length-2" href="https://infra.spec.whatwg.org/#string-code-point-length" data-x-internal="code-point-length">code point length</a> is greater than 128, truncate
   <var>input</var>, leaving only the first 128 characters.</p></li><li><p>If the first character in <var>input</var> is U+0023 (#), then remove it.</p></li><li><p>Replace any character in <var>input</var> that is not an <a href="https://infra.spec.whatwg.org/#ascii-hex-digit" id="colours:ascii-hex-digits-2" data-x-internal="ascii-hex-digits">ASCII hex digit</a> with U+0030 (0).</p></li><li><p>While <var>input</var>'s <a id="colours:code-point-length-3" href="https://infra.spec.whatwg.org/#string-code-point-length" data-x-internal="code-point-length">code point length</a> is zero or not a multiple of
   three, append U+0030 (0) to <var>input</var>.</p></li><li><p>Split <var>input</var> into three strings of equal <a id="colours:code-point-length-4" href="https://infra.spec.whatwg.org/#string-code-point-length" data-x-internal="code-point-length">code point length</a>, to
   obtain three components. Let <var>length</var> be the <a id="colours:code-point-length-5" href="https://infra.spec.whatwg.org/#string-code-point-length" data-x-internal="code-point-length">code point length</a> that all of
   those components have (one third the <a id="colours:code-point-length-6" href="https://infra.spec.whatwg.org/#string-code-point-length" data-x-internal="code-point-length">code point length</a> of <var>input</var>).</p></li><li><p>If <var>length</var> is greater than 8, then remove the leading <span><var>length</var>-8</span> characters in each component, and let <var>length</var> be 8.</p></li><li><p>While <var>length</var> is greater than two and the first character in each
   component is U+0030 (0), remove that character and reduce <var>length</var> by one.</p></li><li><p>If <var>length</var> is <em>still</em> greater than two, truncate each component,
   leaving only the first two characters in each.</p></li><li><p>Let <var>result</var> be a CSS color.</p>

   </li><li><p>Interpret the first component as a hexadecimal number; let the red component of <var>result</var> be the resulting number.</p></li><li><p>Interpret the second component as a hexadecimal number; let the green component of <var>result</var> be the resulting number.</p></li><li><p>Interpret the third component as a hexadecimal number; let the blue component of <var>result</var> be the resulting number.</p></li><li><p>Return <var>result</var>.</p>
  </li></ol>
  </div>

  



  <h4 id="space-separated-tokens"><span class="secno">2.3.7</span> Space-separated tokens<a href="#space-separated-tokens" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A <dfn id="set-of-space-separated-tokens" data-export="">set of space-separated tokens</dfn> is a string containing zero or more words
  (known as tokens) separated by one or more <a id="space-separated-tokens:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, where words consist of
  any string of one or more characters, none of which are <a id="space-separated-tokens:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p>

  <p>A string containing a <a href="#set-of-space-separated-tokens" id="space-separated-tokens:set-of-space-separated-tokens">set of space-separated tokens</a> may have leading or trailing
  <a id="space-separated-tokens:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p>
  </div>

  <div data-algorithm="">
  <p>An <dfn id="unordered-set-of-unique-space-separated-tokens" data-export="">unordered set of unique space-separated tokens</dfn> is a <a href="#set-of-space-separated-tokens" id="space-separated-tokens:set-of-space-separated-tokens-2">set of
  space-separated tokens</a> where none of the tokens are duplicated.</p>
  </div>

  <div data-algorithm="">
  <p>An <dfn id="ordered-set-of-unique-space-separated-tokens">ordered set of unique space-separated tokens</dfn> is a <a href="#set-of-space-separated-tokens" id="space-separated-tokens:set-of-space-separated-tokens-3">set of space-separated
  tokens</a> where none of the tokens are duplicated but where the order of the tokens is
  meaningful.</p>
  </div>

  <p><a href="#set-of-space-separated-tokens" id="space-separated-tokens:set-of-space-separated-tokens-4">Sets of space-separated tokens</a> sometimes
  have a defined set of allowed values. When a set of allowed values is defined, the tokens must all
  be from that list of allowed values; other values are non-conforming. If no such set of allowed
  values is provided, then all values are conforming.</p>

  <p class="note">How tokens in a <a href="#set-of-space-separated-tokens" id="space-separated-tokens:set-of-space-separated-tokens-5">set of space-separated tokens</a> are to be compared
  (e.g. case-sensitively or not) is defined on a per-set basis.</p>



  <h4 id="comma-separated-tokens"><span class="secno">2.3.8</span> Comma-separated tokens<a href="#comma-separated-tokens" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A <dfn id="set-of-comma-separated-tokens">set of comma-separated tokens</dfn> is a string containing zero or more tokens each
  separated from the next by a single U+002C COMMA character (,), where tokens consist of any string
  of zero or more characters, neither beginning nor ending with <a id="comma-separated-tokens:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, nor
  containing any U+002C COMMA characters (,), and optionally surrounded by <a id="comma-separated-tokens:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
  whitespace</a>.</p>
  </div>

  <p class="example">For instance, the string "<code>&nbsp;a&nbsp;,b,,d&nbsp;d&nbsp;</code>" consists of four tokens: "a", "b", the empty
  string, and "d&nbsp;d". Leading and trailing whitespace around each token doesn't count as part of
  the token, and the empty string can be a token.</p>

  <p><a href="#set-of-comma-separated-tokens" id="comma-separated-tokens:set-of-comma-separated-tokens">Sets of comma-separated tokens</a> sometimes
  have further restrictions on what consists a valid token. When such restrictions are defined, the
  tokens must all fit within those restrictions; other values are non-conforming. If no such
  restrictions are specified, then all values are conforming.</p>



  <h4 id="syntax-references"><span class="secno">2.3.9</span> References<a href="#syntax-references" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A <dfn id="valid-hash-name-reference">valid hash-name reference</dfn> to an element of type <var>type</var> is a
  string consisting of a U+0023 NUMBER SIGN character (#) followed by a string which exactly matches
  the value of the <code>name</code> attribute of an element with type <var>type</var> in
  the same <a id="syntax-references:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn id="rules-for-parsing-a-hash-name-reference">rules for parsing a hash-name reference</dfn> to an element of type <var>type</var>,
  given a context node <var>scope</var>, are as follows:</p>

  <ol><li><p>If the string being parsed does not contain a U+0023 NUMBER SIGN character, or if the
   first such character in the string is the last character in the string, then return null.</p></li><li><p>Let <var>s</var> be the string from the character immediately after the first
   U+0023 NUMBER SIGN character in the string being parsed up to the end of that string.</p></li><li>
    <p>Return the first element of type <var>type</var> in <var>scope</var>'s <a id="syntax-references:tree-2" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>, in
    <a id="syntax-references:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, that has an <code id="syntax-references:the-id-attribute"><a href="#the-id-attribute">id</a></code> or <code>name</code> attribute whose value is <var>s</var>, or null if there is no such
    element.</p>

    <p class="note">Although <code id="syntax-references:the-id-attribute-2"><a href="#the-id-attribute">id</a></code> attributes are accounted for when
    parsing, they are not used in determining whether a value is a <a href="#valid-hash-name-reference" id="syntax-references:valid-hash-name-reference"><em>valid</em> hash-name
    reference</a>. That is, a hash-name reference that refers to an element based on <code id="syntax-references:the-id-attribute-3"><a href="#the-id-attribute">id</a></code> is a conformance error (unless that element also has a <code>name</code> attribute with the same value).</p>
   </li></ol>
  </div>

  


  <h4 id="mq"><span class="secno">2.3.10</span> Media queries<a href="#mq" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-media-query-list">valid media query list</dfn> if it matches the <code>&lt;media-query-list&gt;</code> production of <cite>Media Queries</cite>.
  <a href="#refsMQ">[MQ]</a></p>
  </div>

  <div data-algorithm="">
  <p>A string <dfn id="matches-the-environment">matches the environment</dfn> of the user if it is the empty string, a string
  consisting of only <a id="mq:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, or is a media query list that matches the user's
  environment according to the definitions given in <cite>Media Queries</cite>. <a href="#refsMQ">[MQ]</a></p>
  </div>


  <h4 id="unique-values"><span class="secno">2.3.11</span> Unique internal values<a href="#unique-values" class="self-link"></a></h4>

  <p>A <dfn id="unique-internal-value">unique internal value</dfn> is a value that is serializable, comparable by value, and
  never exposed to script.</p>

  <div data-algorithm="">
  <p>To create a <dfn id="new-unique-internal-value">new unique internal value</dfn>, return a <a href="#unique-internal-value" id="unique-values:unique-internal-value">unique internal value</a>
  that has never previously been returned by this algorithm.</p>
  </div>


  <h3 id="urls"><span class="secno">2.4</span> URLs<a href="#urls" class="self-link"></a></h3>

  <h4 id="terminology-2"><span class="secno">2.4.1</span> Terminology<a href="#terminology-2" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-non-empty-url">valid non-empty URL</dfn> if it is a <a id="terminology-2:valid-url-string" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL string</a> but it is
  not the empty string.</p>
  </div>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-url-potentially-surrounded-by-spaces">valid URL potentially surrounded by spaces</dfn> if, after <a href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" id="terminology-2:strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">stripping leading and trailing ASCII
  whitespace</a> from it, it is a <a id="terminology-2:valid-url-string-2" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL string</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by spaces</dfn> if, after <a href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" id="terminology-2:strip-leading-and-trailing-ascii-whitespace-2" data-x-internal="strip-leading-and-trailing-ascii-whitespace">stripping leading and trailing ASCII
  whitespace</a> from it, it is a <a href="#valid-non-empty-url" id="terminology-2:valid-non-empty-url">valid non-empty URL</a>.</p>
  </div>

  <hr>

  <p>This specification defines the URL <dfn id="about:legacy-compat"><code>about:legacy-compat</code></dfn> as a reserved,
  though unresolvable, <code id="terminology-2:about-protocol"><a data-x-internal="about-protocol" href="https://www.rfc-editor.org/rfc/rfc6694#section-2">about:</a></code> URL, for use in <a href="#syntax-doctype" id="terminology-2:syntax-doctype">DOCTYPE</a>s in <a id="terminology-2:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a> when needed for
  compatibility with XML tools. <a href="#refsABOUT">[ABOUT]</a></p>

  <p>This specification defines the URL <dfn id="about:html-kind"><code>about:html-kind</code></dfn> as a reserved,
  though unresolvable, <code id="terminology-2:about-protocol-2"><a data-x-internal="about-protocol" href="https://www.rfc-editor.org/rfc/rfc6694#section-2">about:</a></code> URL, that is used as an
  identifier for kinds of media tracks. <a href="#refsABOUT">[ABOUT]</a></p>

  <p>This specification defines the URL <dfn id="about:srcdoc"><code>about:srcdoc</code></dfn> as a reserved, though
  unresolvable, <code id="terminology-2:about-protocol-3"><a data-x-internal="about-protocol" href="https://www.rfc-editor.org/rfc/rfc6694#section-2">about:</a></code> URL, that is used as the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="terminology-2:the-document's-address" data-x-internal="the-document's-address">URL</a> of <a href="#an-iframe-srcdoc-document" id="terminology-2:an-iframe-srcdoc-document"><code>iframe</code> <code>srcdoc</code> documents</a>.
  <a href="#refsABOUT">[ABOUT]</a></p>

  <hr>

  <div data-algorithm="">
  <p>A <a id="terminology-2:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <dfn id="matches-about:blank">matches <code>about:blank</code></dfn> if its <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="terminology-2:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is "<code>about</code>", its <a href="https://url.spec.whatwg.org/#concept-url-path" id="terminology-2:concept-url-path" data-x-internal="concept-url-path">path</a> contains a single string "<code>blank</code>", its
  <a href="https://url.spec.whatwg.org/#concept-url-username" id="terminology-2:concept-url-username" data-x-internal="concept-url-username">username</a> and <a href="https://url.spec.whatwg.org/#concept-url-password" id="terminology-2:concept-url-password" data-x-internal="concept-url-password">password</a> are the empty string, and its <a href="https://url.spec.whatwg.org/#concept-url-host" id="terminology-2:concept-url-host" data-x-internal="concept-url-host">host</a> is null.</p>
  </div>

  <p class="note">Such a URL's <a href="https://url.spec.whatwg.org/#concept-url-query" id="terminology-2:concept-url-query" data-x-internal="concept-url-query">query</a> and <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="terminology-2:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> can be non-null. For example, the <a id="terminology-2:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL
  record</a> created by <a href="https://url.spec.whatwg.org/#concept-url-parser" id="terminology-2:url-parser" data-x-internal="url-parser">parsing</a> "<code>about:blank?foo#bar</code>" <a href="#matches-about:blank" id="terminology-2:matches-about:blank">matches <code>about:blank</code></a>.</p>

  <div data-algorithm="">
  <p>A <a id="terminology-2:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <dfn id="matches-about:srcdoc">matches <code>about:srcdoc</code></dfn> if its <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="terminology-2:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a> is "<code>about</code>", its <a href="https://url.spec.whatwg.org/#concept-url-path" id="terminology-2:concept-url-path-2" data-x-internal="concept-url-path">path</a> contains a single string "<code>srcdoc</code>",
  its <a href="https://url.spec.whatwg.org/#concept-url-query" id="terminology-2:concept-url-query-2" data-x-internal="concept-url-query">query</a> is null, its <a href="https://url.spec.whatwg.org/#concept-url-username" id="terminology-2:concept-url-username-2" data-x-internal="concept-url-username">username</a> and <a href="https://url.spec.whatwg.org/#concept-url-password" id="terminology-2:concept-url-password-2" data-x-internal="concept-url-password">password</a> are the empty string, and its <a href="https://url.spec.whatwg.org/#concept-url-host" id="terminology-2:concept-url-host-2" data-x-internal="concept-url-host">host</a> is null.</p>
  </div>

  <p class="note">The reason that <a href="#matches-about:srcdoc" id="terminology-2:matches-about:srcdoc">matches <code>about:srcdoc</code></a> ensures that the
  <a id="terminology-2:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="terminology-2:concept-url-query-3" data-x-internal="concept-url-query">query</a> is null is because it is not
  possible to create <a href="#an-iframe-srcdoc-document" id="terminology-2:an-iframe-srcdoc-document-2">an <code>iframe</code> <code>srcdoc</code> document</a> whose <a href="https://dom.spec.whatwg.org/#concept-document-url" id="terminology-2:the-document's-address-2" data-x-internal="the-document's-address">URL</a> has a non-null <a href="https://url.spec.whatwg.org/#concept-url-query" id="terminology-2:concept-url-query-4" data-x-internal="concept-url-query">query</a>, unlike <code id="terminology-2:document"><a href="#document">Document</a></code>s whose <a href="https://dom.spec.whatwg.org/#concept-document-url" id="terminology-2:the-document's-address-3" data-x-internal="the-document's-address">URL</a> <a href="#matches-about:blank" id="terminology-2:matches-about:blank-2">matches <code>about:blank</code></a>. In other
  words, the set of all <a id="terminology-2:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>s that <a href="#matches-about:srcdoc" id="terminology-2:matches-about:srcdoc-2">match
  <code>about:srcdoc</code></a> only vary in their <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="terminology-2:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a>.</p>


  

  <h4 id="resolving-urls"><span class="secno">2.4.2</span> Parsing URLs<a href="#resolving-urls" class="self-link"></a></h4>

  <p>Parsing a URL is the process of taking a string and obtaining the <a id="resolving-urls:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> that
  it represents. While this process is defined in <cite>URL</cite>, the HTML standard defines
  several wrappers to abstract base URLs and encodings. <a href="#refsURL">[URL]</a></p>

  <p class="note">Most new APIs are to use <a href="#parse-a-url" id="resolving-urls:parse-a-url">parse a URL</a>. Older APIs and HTML elements
  might have reason to use <a href="#encoding-parsing-a-url" id="resolving-urls:encoding-parsing-a-url">encoding-parse a URL</a>. When a
  custom base URL is needed or no base URL is desired, the <a id="resolving-urls:url-parser" href="https://url.spec.whatwg.org/#concept-url-parser" data-x-internal="url-parser">URL parser</a> can of course be
  used directly as well.</p>

  <div data-algorithm="">
  <p>To <dfn id="parse-a-url" data-export="">parse a URL</dfn>, given a string <var>url</var>, relative to a
  <code id="resolving-urls:document"><a href="#document">Document</a></code> object or <a href="#environment-settings-object" id="resolving-urls:environment-settings-object">environment settings object</a> <var>environment</var>,
  run these steps. They return failure or a <a id="resolving-urls:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p>

  <ol><li><p>Let <var>baseURL</var> be <var>environment</var>'s <a href="#document-base-url" id="resolving-urls:document-base-url">base
   URL</a>, if <var>environment</var> is a <code id="resolving-urls:document-2"><a href="#document">Document</a></code> object; otherwise
   <var>environment</var>'s <a href="#api-base-url" id="resolving-urls:api-base-url">API base URL</a>.</p></li><li><p>Return the result of applying the <a id="resolving-urls:url-parser-2" href="https://url.spec.whatwg.org/#concept-url-parser" data-x-internal="url-parser">URL parser</a> to <var>url</var>, with
   <var>baseURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="resolve-a-url">To <dfn id="encoding-parsing-a-url" data-export="">encoding-parse a URL</dfn>,
  given a string <var>url</var>, relative to a <code id="resolving-urls:document-3"><a href="#document">Document</a></code> object or <a href="#environment-settings-object" id="resolving-urls:environment-settings-object-2">environment
  settings object</a> <var>environment</var>, run these steps. They return failure or a
  <a id="resolving-urls:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p>

  <ol><li><p>Let <var>encoding</var> be <a id="resolving-urls:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>.</p></li><li><p>If <var>environment</var> is a <code id="resolving-urls:document-4"><a href="#document">Document</a></code> object, then set <var>encoding</var>
   to <var>environment</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="resolving-urls:document's-character-encoding" data-x-internal="document's-character-encoding">character
   encoding</a>.</p></li><li><p>Otherwise, if <var>environment</var>'s <a href="#concept-relevant-global" id="resolving-urls:concept-relevant-global">relevant global object</a> is a
   <code id="resolving-urls:window"><a href="#window">Window</a></code> object, set <var>encoding</var> to <var>environment</var>'s <a href="#concept-relevant-global" id="resolving-urls:concept-relevant-global-2">relevant
   global object</a>'s <a href="#concept-document-window" id="resolving-urls:concept-document-window">associated
   <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="resolving-urls:document's-character-encoding-2" data-x-internal="document's-character-encoding">character
   encoding</a>.</p></li><li><p>Let <var>baseURL</var> be <var>environment</var>'s <a href="#document-base-url" id="resolving-urls:document-base-url-2">base
   URL</a>, if <var>environment</var> is a <code id="resolving-urls:document-5"><a href="#document">Document</a></code> object; otherwise
   <var>environment</var>'s <a href="#api-base-url" id="resolving-urls:api-base-url-2">API base URL</a>.</p></li><li><p>Return the result of applying the <a id="resolving-urls:url-parser-3" href="https://url.spec.whatwg.org/#concept-url-parser" data-x-internal="url-parser">URL parser</a> to <var>url</var>, with
   <var>baseURL</var> and <var>encoding</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="encoding-parsing-and-serializing-a-url">encoding-parse-and-serialize a
  URL</dfn>, given a string <var>url</var>, relative to a <code id="resolving-urls:document-6"><a href="#document">Document</a></code> object or
  <a href="#environment-settings-object" id="resolving-urls:environment-settings-object-3">environment settings object</a> <var>environment</var>, run these steps. They return
  failure or a string.</p>

  <ol><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="resolving-urls:encoding-parsing-a-url-2">encoding-parsing a URL</a> given
   <var>url</var>, relative to <var>environment</var>.</p></li><li><p>If <var>url</var> is failure, then return failure.</p></li><li><p>Return the result of applying the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="resolving-urls:concept-url-serializer" data-x-internal="concept-url-serializer">URL
   serializer</a> to <var>url</var>.</p></li></ol>
  </div>

  



  

  <h4 id="document-base-urls"><span class="secno">2.4.3</span> Document base URLs<a href="#document-base-urls" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>The <dfn id="document-base-url" data-export="">document base URL</dfn> of a <code id="document-base-urls:document"><a href="#document">Document</a></code> <var>document</var> is the
  <a id="document-base-urls:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> obtained by running these steps:</p>

  <ol><li><p>If <var>document</var> has no <a id="document-base-urls:descendant" href="https://dom.spec.whatwg.org/#concept-tree-descendant" data-x-internal="descendant">descendant</a> <code id="document-base-urls:the-base-element"><a href="#the-base-element">base</a></code> element that has
   an <code id="document-base-urls:attr-base-href"><a href="#attr-base-href">href</a></code> attribute, then return <var>document</var>'s
   <a href="#fallback-base-url" id="document-base-urls:fallback-base-url">fallback base URL</a>.</p></li><li><p>Otherwise, return the <a href="#frozen-base-url" id="document-base-urls:frozen-base-url">frozen base URL</a> of the first <code id="document-base-urls:the-base-element-2"><a href="#the-base-element">base</a></code> element
   in <var>document</var> that has an <code id="document-base-urls:attr-base-href-2"><a href="#attr-base-href">href</a></code> attribute, in
   <a id="document-base-urls:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="fallback-base-url">fallback base URL</dfn> of a <code id="document-base-urls:document-2"><a href="#document">Document</a></code> object <var>document</var> is the
  <a id="document-base-urls:url-record-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> obtained by running these steps:</p>

  <ol><li>
    <p>If <var>document</var> is <a href="#an-iframe-srcdoc-document" id="document-base-urls:an-iframe-srcdoc-document">an <code>iframe</code>
    <code>srcdoc</code> document</a>:</p>

    <ol><li><p><a id="document-base-urls:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var>'s <a href="#concept-document-about-base-url" id="document-base-urls:concept-document-about-base-url">about base URL</a> is non-null.</p></li><li><p>Return <var>document</var>'s <a href="#concept-document-about-base-url" id="document-base-urls:concept-document-about-base-url-2">about base
     URL</a>.</p></li></ol>
   </li><li><p>If <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="document-base-urls:the-document's-address" data-x-internal="the-document's-address">URL</a> <a href="#matches-about:blank" id="document-base-urls:matches-about:blank">matches
   <code>about:blank</code></a> and <var>document</var>'s <a href="#concept-document-about-base-url" id="document-base-urls:concept-document-about-base-url-3">about base URL</a> is non-null, then return
   <var>document</var>'s <a href="#concept-document-about-base-url" id="document-base-urls:concept-document-about-base-url-4">about base
   URL</a>.</p></li><li><p>Return <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="document-base-urls:the-document's-address-2" data-x-internal="the-document's-address">URL</a>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="set-the-url">set the URL</dfn> for a <code id="document-base-urls:document-3"><a href="#document">Document</a></code> <var>document</var> to a <a id="document-base-urls:url-record-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL
  record</a> <var>url</var>:</p>

  <ol><li><p>Set <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="document-base-urls:the-document's-address-3" data-x-internal="the-document's-address">URL</a> to
   <var>url</var>.</p></li><li><p><a href="#respond-to-base-url-changes" id="document-base-urls:respond-to-base-url-changes">Respond to base URL changes</a> given <var>document</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="dynamic-changes-to-base-urls">To <dfn id="respond-to-base-url-changes">respond to base URL changes</dfn> for a
  <code id="document-base-urls:document-4"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p>The user agent should update any user interface elements which are displaying affected
   URLs, or data derived from such URLs, to the user. Examples of such user interface elements would
   be a status bar that displays a <a href="#hyperlink" id="document-base-urls:hyperlink">hyperlink</a>'s <a href="#concept-hyperlink-url" id="document-base-urls:concept-hyperlink-url">url</a>, or some user interface which displays the URL
   specified by a <code id="document-base-urls:the-q-element"><a href="#the-q-element">q</a></code>, <code id="document-base-urls:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code>, <code id="document-base-urls:the-ins-element"><a href="#the-ins-element">ins</a></code>, or <code id="document-base-urls:the-del-element"><a href="#the-del-element">del</a></code>
   element's <code>cite</code> attribute.</p></li><li><p>Ensure that the CSS <code id="document-base-urls:selector-link"><a href="#selector-link">:link</a></code>/<code id="document-base-urls:selector-visited"><a href="#selector-visited">:visited</a></code>/etc. <a href="https://drafts.csswg.org/selectors/#pseudo-class" id="document-base-urls:pseudo-class" data-x-internal="pseudo-class">pseudo-classes</a>
   are updated appropriately.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="document-base-urls:list-iterate" data-x-internal="list-iterate">For each</a> <var>descendant</var> of <var>document</var>'s
    <a href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant" id="document-base-urls:shadow-including-descendant" data-x-internal="shadow-including-descendant">shadow-including descendants</a>:</p>

    <ol><li>
      <p>If <var>descendant</var> is a <code id="document-base-urls:the-script-element"><a href="#the-script-element">script</a></code> element whose <a href="#concept-script-result" id="document-base-urls:concept-script-result">result</a> is a <a href="#speculation-rules-parse-result" id="document-base-urls:speculation-rules-parse-result">speculation rules parse result</a>,
      then:</p>

      <ol><li><p>Let <var>oldResult</var> be <var>element</var>'s <a href="#concept-script-result" id="document-base-urls:concept-script-result-2">result</a>.</p></li><li><p>Let <var>newResult</var> be the result of <a href="#create-a-speculation-rules-parse-result" id="document-base-urls:create-a-speculation-rules-parse-result">creating a speculation rules parse result</a> given <var>element</var>'s
       <a id="document-base-urls:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> and <var>element</var>'s <a id="document-base-urls:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p><a href="#update-speculation-rules" id="document-base-urls:update-speculation-rules">Update speculation rules</a> given <var>element</var>'s <a href="#concept-relevant-global" id="document-base-urls:concept-relevant-global">relevant global
       object</a>, <var>oldResult</var>, and <var>newResult</var>.</p></li></ol>
    </li></ol>
   </li><li><p><a href="#consider-speculative-loads" id="document-base-urls:consider-speculative-loads">Consider speculative loads</a> given <var>document</var>.</p></li></ol>
  </div>

  <p id="example-base-url-change-img-unaffected" class="example"><a href="#example-base-url-change-img-unaffected" class="self-link"></a>This means that changing the base
  URL doesn't affect, for example, the image displayed by <code id="document-base-urls:the-img-element"><a href="#the-img-element">img</a></code> elements. Thus,
  subsequent accesses of the <code id="document-base-urls:dom-img-src"><a href="#dom-img-src">src</a></code> IDL attribute from script will
  return a new <a id="document-base-urls:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a> that might no longer correspond to the image being
  shown.</p>

  


  

  <h3 id="fetching-resources"><span class="secno">2.5</span> Fetching resources<a href="#fetching-resources" class="self-link"></a></h3>

  <h4 id="terminology-3"><span class="secno">2.5.1</span> Terminology<a href="#terminology-3" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A <a href="https://fetch.spec.whatwg.org/#concept-response" id="terminology-3:concept-response" data-x-internal="concept-response">response</a> whose <a href="https://fetch.spec.whatwg.org/#concept-response-type" id="terminology-3:concept-response-type" data-x-internal="concept-response-type">type</a> is "<code>basic</code>", "<code>cors</code>", or "<code>default</code>" is <dfn id="cors-same-origin" data-export="">CORS-same-origin</dfn>.
  <a href="#refsFETCH">[FETCH]</a></p>
  </div>

  <div data-algorithm="">
  <p>A <a href="https://fetch.spec.whatwg.org/#concept-response" id="terminology-3:concept-response-2" data-x-internal="concept-response">response</a> whose <a href="https://fetch.spec.whatwg.org/#concept-response-type" id="terminology-3:concept-response-type-2" data-x-internal="concept-response-type">type</a> is "<code>opaque</code>" or "<code>opaqueredirect</code>" is <dfn id="cors-cross-origin">CORS-cross-origin</dfn>.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="https://fetch.spec.whatwg.org/#concept-response" id="terminology-3:concept-response-3" data-x-internal="concept-response">response</a>'s <dfn id="unsafe-response" data-export="">unsafe response</dfn> is its
  <a href="https://fetch.spec.whatwg.org/#concept-internal-response" id="terminology-3:concept-internal-response" data-x-internal="concept-internal-response">internal response</a> if it has one, and the <a href="https://fetch.spec.whatwg.org/#concept-response" id="terminology-3:concept-response-4" data-x-internal="concept-response">response</a> itself otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="create-a-potential-cors-request">create a potential-CORS request</dfn>, given a <var>url</var>, <var>destination</var>,
  <var>corsAttributeState</var>, and an optional <i>same-origin fallback flag</i>, run these
  steps:</p>

  <ol><li><p>Let <var>mode</var> be "<code>no-cors</code>" if <var>corsAttributeState</var>
   is <a href="#attr-crossorigin-none" id="terminology-3:attr-crossorigin-none">No CORS</a>, and "<code>cors</code>"
   otherwise.</p></li><li><p>If <i>same-origin fallback flag</i> is set and <var>mode</var> is "<code>no-cors</code>", set <var>mode</var> to "<code>same-origin</code>".</p></li><li><p>Let <var>credentialsMode</var> be "<code>include</code>".</p></li><li><p>If <var>corsAttributeState</var> is <a href="#attr-crossorigin-anonymous" id="terminology-3:attr-crossorigin-anonymous">Anonymous</a>, set <var>credentialsMode</var> to "<code>same-origin</code>".</p></li><li><p>Return a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="terminology-3:concept-request" data-x-internal="concept-request">request</a> whose
   <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="terminology-3:concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>url</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="terminology-3:concept-request-destination" data-x-internal="concept-request-destination">destination</a> is <var>destination</var>,
   <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="terminology-3:concept-request-mode" data-x-internal="concept-request-mode">mode</a> is <var>mode</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="terminology-3:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> is
   <var>credentialsMode</var>, and whose <a id="terminology-3:use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a> is set.</p></li></ol>
  </div>


  <h4 id="content-type-sniffing"><span class="secno">2.5.2</span> Determining the type of a resource<a href="#content-type-sniffing" class="self-link"></a></h4>

  <p>The <dfn id="content-type">Content-Type metadata</dfn> of a resource must be obtained and
  interpreted in a manner consistent with the requirements of <cite>MIME Sniffing</cite>.
  <a href="#refsMIMESNIFF">[MIMESNIFF]</a></p>

  <p>The <dfn id="content-type-sniffing-2"><a href="https://mimesniff.spec.whatwg.org/#computed-mime-type">computed MIME type</a></dfn> of a
  resource must be found in a manner consistent with the requirements given in <cite>MIME
  Sniffing</cite>. <a href="#refsMIMESNIFF">[MIMESNIFF]</a></p>

  <p>The <dfn id="content-type-sniffing:-image"><a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-images-specifically">rules for
  sniffing images specifically</a></dfn>, the <dfn id="content-type-sniffing:-text-or-binary"><a href="https://mimesniff.spec.whatwg.org/#rules-for-text-or-binary">rules for distinguishing
  if a resource is text or binary</a></dfn>, and the <dfn id="content-type-sniffing:-video"><a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-audio-and-video-specifically">rules
  for sniffing audio and video specifically</a></dfn> are also defined in <cite>MIME Sniffing</cite>.
  These rules return a <a id="content-type-sniffing:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> as their result. <a href="#refsMIMESNIFF">[MIMESNIFF]</a></p>

  <p class="warning">It is imperative that the rules in <cite>MIME Sniffing</cite> be
  followed exactly. When a user agent uses different heuristics for content type detection than the
  server expects, security problems can occur. For more details, see <cite>MIME Sniffing</cite>.
  <a href="#refsMIMESNIFF">[MIMESNIFF]</a></p>


  <h4 id="extracting-character-encodings-from-meta-elements"><span class="secno">2.5.3</span> Extracting character encodings from <code id="extracting-character-encodings-from-meta-elements:the-meta-element"><a href="#the-meta-element">meta</a></code> elements<a href="#extracting-character-encodings-from-meta-elements" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>The <dfn id="algorithm-for-extracting-a-character-encoding-from-a-meta-element">algorithm for extracting a character encoding from a <code>meta</code> element</dfn>,
  given a string <var>s</var>, is as follows. It returns either a character encoding or
  nothing.</p>

  <ol><li><p>Let <var>position</var> be a pointer into <var>s</var>, initially
   pointing at the start of the string.</p></li><li><p><i>Loop</i>: Find the first seven characters in <var>s</var> after <var>position</var> that are an <a id="extracting-character-encodings-from-meta-elements:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the word "<code>charset</code>". If no such match is found, return nothing.</p></li><li><p>Skip any <a id="extracting-character-encodings-from-meta-elements:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> that immediately follow the word "<code>charset</code>" (there might not be any).</p></li><li><p>If the next character is not a U+003D EQUALS SIGN (=), then move <var>position</var> to point just before that next character, and jump back to the step
   labeled <i>loop</i>.</p></li><li><p>Skip any <a id="extracting-character-encodings-from-meta-elements:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> that immediately follow the equals sign (there
   might not be any).</p></li><li>
    <p>Process the next character as follows:</p>

    <dl class="switch"><dt>If it is a U+0022 QUOTATION MARK character (") and there is a later U+0022 QUOTATION MARK character (") in <var>s</var></dt><dt>If it is a U+0027 APOSTROPHE character (') and there is a later U+0027 APOSTROPHE character (') in <var>s</var></dt><dd>Return the result of <a id="extracting-character-encodings-from-meta-elements:getting-an-encoding" href="https://encoding.spec.whatwg.org/#concept-encoding-get" data-x-internal="getting-an-encoding">getting an encoding</a> from the substring that is between
     this character and the next earliest occurrence of this character.</dd><dt>If it is an unmatched U+0022 QUOTATION MARK character (")</dt><dt>If it is an unmatched U+0027 APOSTROPHE character (')</dt><dt>If there is no next character</dt><dd>Return nothing.</dd><dt>Otherwise</dt><dd>Return the result of <a id="extracting-character-encodings-from-meta-elements:getting-an-encoding-2" href="https://encoding.spec.whatwg.org/#concept-encoding-get" data-x-internal="getting-an-encoding">getting an encoding</a> from the substring that consists of
     this character up to but not including the first <a id="extracting-character-encodings-from-meta-elements:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> or U+003B
     SEMICOLON character (;), or the end of <var>s</var>, whichever comes first.</dd></dl>
   </li></ol>
  </div>

  <p class="note">This algorithm is distinct from those in the HTTP specifications (for example,
  HTTP doesn't allow the use of single quotes and requires supporting a backslash-escape mechanism
  that is not supported by this algorithm). While the
  algorithm is used in contexts that, historically, were related to HTTP, the syntax as supported by
  implementations diverged some time ago. <a href="#refsHTTP">[HTTP]</a></p>

  


  <h4 id="cors-settings-attributes"><span class="secno">2.5.4</span> CORS settings attributes<a href="#cors-settings-attributes" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin" title="The crossorigin attribute, valid on the <audio>, <img>, <link>, <script>, and <video> elements, provides support for CORS, defining how the element handles cross-origin requests, thereby enabling the configuration of the CORS requests for the element's fetched data. Depending on the element, the attribute can be a CORS settings attribute.">Attributes/crossorigin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>8+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>13+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>A <dfn id="cors-settings-attribute">CORS settings attribute</dfn> is an <a href="#enumerated-attribute" id="cors-settings-attributes:enumerated-attribute">enumerated attribute</a> with the following
  keywords and states:</p>

  <table><thead><tr><th> Keyword
     </th><th> State
     </th><th> Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="audio/crossorigin,video/crossorigin,img/crossorigin,link/crossorigin,script/crossorigin" id="attr-crossorigin-anonymous-keyword" data-dfn-type="attr-value"><code>anonymous</code></dfn>
     </td><td><dfn id="attr-crossorigin-anonymous">Anonymous</dfn>
     </td><td><a href="https://fetch.spec.whatwg.org/#concept-request" id="cors-settings-attributes:concept-request" data-x-internal="concept-request">Requests</a> for the element will have their
     <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="cors-settings-attributes:concept-request-mode" data-x-internal="concept-request-mode">mode</a> set to "<code>cors</code>" and their
     <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="cors-settings-attributes:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> set to "<code>same-origin</code>".
    </td></tr><tr><td><dfn data-dfn-for="audio/crossorigin,video/crossorigin,img/crossorigin,link/crossorigin,script/crossorigin" id="attr-crossorigin-use-credentials-keyword" data-dfn-type="attr-value"><code>use-credentials</code></dfn>
     </td><td><dfn id="attr-crossorigin-use-credentials">Use Credentials</dfn>
     </td><td><a href="https://fetch.spec.whatwg.org/#concept-request" id="cors-settings-attributes:concept-request-2" data-x-internal="concept-request">Requests</a> for the element will have their <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="cors-settings-attributes:concept-request-mode-2" data-x-internal="concept-request-mode">mode</a> set to "<code>cors</code>" and their <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="cors-settings-attributes:concept-request-credentials-mode-2" data-x-internal="concept-request-credentials-mode">credentials mode</a> set to "<code>include</code>".
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="cors-settings-attributes:missing-value-default"><a href="#missing-value-default">missing value default</a></i> is the <dfn id="attr-crossorigin-none">No CORS</dfn> state, and its <i id="cors-settings-attributes:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> and <i id="cors-settings-attributes:empty-value-default"><a href="#empty-value-default">empty value default</a></i> are
  both the <a href="#attr-crossorigin-anonymous" id="cors-settings-attributes:attr-crossorigin-anonymous">Anonymous</a> state.</p>
  </div>

  <p>The majority of fetches governed by <a href="#cors-settings-attribute" id="cors-settings-attributes:cors-settings-attribute">CORS settings
  attributes</a> will be done via the <a href="#create-a-potential-cors-request" id="cors-settings-attributes:create-a-potential-cors-request">create a potential-CORS request</a> algorithm.</p>

  <div data-algorithm="">
  <p id="module-script-credentials-mode">For more modern features, where the request's <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="cors-settings-attributes:concept-request-mode-3" data-x-internal="concept-request-mode">mode</a> is always "<code>cors</code>", certain <a href="#cors-settings-attribute" id="cors-settings-attributes:cors-settings-attribute-2">CORS settings attributes</a> have been repurposed to have a
  slightly different meaning, wherein they only impact the <a href="https://fetch.spec.whatwg.org/#concept-request" id="cors-settings-attributes:concept-request-3" data-x-internal="concept-request">request</a>'s <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="cors-settings-attributes:concept-request-credentials-mode-3" data-x-internal="concept-request-credentials-mode">credentials mode</a>. To perform this translation, we
  define the <dfn id="cors-settings-attribute-credentials-mode" data-export="">CORS settings attribute credentials mode</dfn> for a given <a href="#cors-settings-attribute" id="cors-settings-attributes:cors-settings-attribute-3">CORS
  settings attribute</a> to be determined by switching on the attribute's state:</p>

  <dl class="switch"><dt><a href="#attr-crossorigin-none" id="cors-settings-attributes:attr-crossorigin-none">No CORS</a></dt><dt><a href="#attr-crossorigin-anonymous" id="cors-settings-attributes:attr-crossorigin-anonymous-2">Anonymous</a></dt><dd>"<code>same-origin</code>"</dd><dt><a href="#attr-crossorigin-none" id="cors-settings-attributes:attr-crossorigin-none-2">Use Credentials</a></dt><dd>"<code>include</code>"</dd></dl>
  </div>


  <h4 id="referrer-policy-attributes"><span class="secno">2.5.5</span> Referrer policy attributes<a href="#referrer-policy-attributes" class="self-link"></a></h4>

  <p>A <dfn id="referrer-policy-attribute" data-export="">referrer policy attribute</dfn> is an <a href="#enumerated-attribute" id="referrer-policy-attributes:enumerated-attribute">enumerated attribute</a>.  Each
  <a id="referrer-policy-attributes:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>, including the empty string, is a keyword for this attribute, mapping
  to a state of the same name.</p>

  <div data-algorithm="">
  <p>The attribute's <i id="referrer-policy-attributes:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="referrer-policy-attributes:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the empty string state.</p>
  </div>

  <p>The impact of these states on the processing model of various <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="referrer-policy-attributes:concept-fetch" data-x-internal="concept-fetch">fetches</a> is defined in more detail throughout this specification, in
  <cite>Fetch</cite>, and in <cite>Referrer Policy</cite>. <a href="#refsFETCH">[FETCH]</a>
  <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p>

  <div class="note">
   <p>Several signals can contribute to which processing model is used for a given <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="referrer-policy-attributes:concept-fetch-2" data-x-internal="concept-fetch">fetch</a>; a <a href="#referrer-policy-attribute" id="referrer-policy-attributes:referrer-policy-attribute">referrer policy attribute</a> is only one of
   them. In general, the order in which these signals are processed are:</p>

   <ol><li><p>First, the presence of a <code id="referrer-policy-attributes:link-type-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code> link
    type;</p></li><li><p>Then, the value of a <a href="#referrer-policy-attribute" id="referrer-policy-attributes:referrer-policy-attribute-2">referrer policy attribute</a>;</p></li><li><p>Then, the presence of any <code id="referrer-policy-attributes:the-meta-element"><a href="#the-meta-element">meta</a></code> element with <code id="referrer-policy-attributes:attr-meta-name"><a href="#attr-meta-name">name</a></code> attribute set to <code id="referrer-policy-attributes:meta-referrer"><a href="#meta-referrer">referrer</a></code>.</p></li><li><p>Finally, the `<code id="referrer-policy-attributes:http-referrer-policy"><a data-x-internal="http-referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-header-dfn">Referrer-Policy</a></code>` HTTP
    header.</p></li></ol>
  </div>

  <h4 id="nonce-attributes"><span class="secno">2.5.6</span> Nonce attributes<a href="#nonce-attributes" class="self-link"></a></h4>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce" title="The nonce global attribute is a content attribute defining a cryptographic nonce (&quot;number used once&quot;) which can be used by Content Security Policy to determine whether or not a given fetch will be allowed to proceed for a given element.">Global_attributes/nonce</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>Yes</span></span><span class="chrome yes"><span>Chrome</span><span>Yes</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>Yes</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>A <dfn data-dfn-for="htmlsvg-global" id="attr-nonce" data-dfn-type="element-attr"><code>nonce</code></dfn> content
  attribute represents a cryptographic nonce ("number used once") which can be used by <cite>Content
  Security Policy</cite> to determine whether or not a given fetch will be allowed to proceed. The
  value is text. <a href="#refsCSP">[CSP]</a></p>

  <p>Elements that have a <code id="nonce-attributes:attr-nonce"><a href="#attr-nonce">nonce</a></code> content attribute ensure that the
  cryptographic nonce is only exposed to script (and not to side-channels like CSS attribute
  selectors) by taking the value from the content attribute, moving it into an internal slot
  named <dfn data-dfn-for="HTMLOrSVGElement" id="cryptographicnonce" data-dfn-type="attribute">[[CryptographicNonce]]</dfn>, exposing it to script
  via the <code id="nonce-attributes:htmlorsvgelement"><a href="#htmlorsvgelement">HTMLOrSVGElement</a></code> interface mixin, and setting the content attribute to the
  empty string. Unless otherwise specified, the slot's value is the empty string.</p>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-noncedelement-nonce" id="dom-htmlorsvgelement-nonce-dev">nonce</a></code></dt><dd><p>Returns the value set for <var>element</var>'s cryptographic nonce. If the setter was not
   used, this will be the value originally found in the <code id="nonce-attributes:attr-nonce-2"><a href="#attr-nonce">nonce</a></code>
   content attribute.</p></dd><dt><code><var>element</var>.<a href="#dom-noncedelement-nonce" id="nonce-attributes:dom-noncedelement-nonce">nonce</a> = <var>value</var></code></dt><dd><p>Updates <var>element</var>'s cryptographic nonce value.</p></dd></dl>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/nonce" title="The nonce property of the HTMLElement interface returns the cryptographic number used once that is used by Content Security Policy to determine whether a given fetch will be allowed to proceed.">HTMLElement/nonce</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>75+</span></span><span class="safari yes"><span>Safari</span><span title="Partial implementation.">🔰 10+</span></span><span class="chrome yes"><span>Chrome</span><span>61+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOrSVGElement" id="dom-noncedelement-nonce" data-dfn-type="attribute"><code>nonce</code></dfn> IDL attribute must, on getting, return the
  value of this element's <a href="#cryptographicnonce" id="nonce-attributes:cryptographicnonce">[[CryptographicNonce]]</a>; and on setting, set this element's
  <a href="#cryptographicnonce" id="nonce-attributes:cryptographicnonce-2">[[CryptographicNonce]]</a> to the given value.</p>
  </div>

  <p id="nonce-does-not-update-dom" class="note"><a href="#nonce-does-not-update-dom" class="self-link"></a>Note how the setter for the <code id="nonce-attributes:dom-noncedelement-nonce-2"><a href="#dom-noncedelement-nonce">nonce</a></code> IDL attribute does not update the corresponding
  content attribute. This, as well as the below setting of the <code id="nonce-attributes:attr-nonce-3"><a href="#attr-nonce">nonce</a></code> content attribute to the empty string when an element
  <a href="#becomes-browsing-context-connected" id="nonce-attributes:becomes-browsing-context-connected">becomes browsing-context connected</a>, is meant to prevent exfiltration of the nonce
  value through mechanisms that can easily read content attributes, such as selectors. Learn more in
  <a href="https://github.com/whatwg/html/issues/2369">issue #2369</a>, where this behavior was
  introduced.</p>

  <div data-algorithm="">
  <p>The following <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="nonce-attributes:concept-element-attributes-change-ext" data-x-internal="concept-element-attributes-change-ext">attribute change
  steps</a> are used for the <code id="nonce-attributes:attr-nonce-4"><a href="#attr-nonce">nonce</a></code> content attribute:

  </p><ol><li><p>If <var>element</var> does not <a id="nonce-attributes:include" href="https://webidl.spec.whatwg.org/#include" data-x-internal="include">include</a> <code id="nonce-attributes:htmlorsvgelement-2"><a href="#htmlorsvgelement">HTMLOrSVGElement</a></code>, then
   return.</p></li><li><p>If <var>localName</var> is not <code id="nonce-attributes:attr-nonce-5"><a href="#attr-nonce">nonce</a></code> or
   <var>namespace</var> is not null, then return.</p></li><li><p>If <var>value</var> is null, then set <var>element</var>'s
   <a href="#cryptographicnonce" id="nonce-attributes:cryptographicnonce-3">[[CryptographicNonce]]</a> to the empty string.</p></li><li><p>Otherwise, set <var>element</var>'s <a href="#cryptographicnonce" id="nonce-attributes:cryptographicnonce-4">[[CryptographicNonce]]</a> to
   <var>value</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Whenever an element <a href="https://webidl.spec.whatwg.org/#include" id="nonce-attributes:include-2" data-x-internal="include">including</a> <code id="nonce-attributes:htmlorsvgelement-3"><a href="#htmlorsvgelement">HTMLOrSVGElement</a></code>
  <a href="#becomes-browsing-context-connected" id="nonce-attributes:becomes-browsing-context-connected-2">becomes browsing-context connected</a>, the user agent must execute the following steps
  on the <var>element</var>:</p>

  <ol><li><p>Let <var>CSP list</var> be <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-shadow-including-root" id="nonce-attributes:shadow-including-root" data-x-internal="shadow-including-root">shadow-including root</a>'s <a href="#concept-document-policy-container" id="nonce-attributes:concept-document-policy-container">policy
   container</a>'s <a href="#policy-container-csp-list" id="nonce-attributes:policy-container-csp-list">CSP list</a>.</p></li><li>
    <p>If <var>CSP list</var> <a id="nonce-attributes:contains-a-header-delivered-content-security-policy" href="https://w3c.github.io/webappsec-csp/#contains-a-header-delivered-content-security-policy" data-x-internal="contains-a-header-delivered-content-security-policy">contains a header-delivered Content Security Policy</a>, and
    <var>element</var> has a <code id="nonce-attributes:attr-nonce-6"><a href="#attr-nonce">nonce</a></code> content attribute
    whose value is not the empty string, then:</p>

    <ol><li><p>Let <var>nonce</var> be <var>element</var>'s
     <a href="#cryptographicnonce" id="nonce-attributes:cryptographicnonce-5">[[CryptographicNonce]]</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="nonce-attributes:concept-element-attributes-set-value" data-x-internal="concept-element-attributes-set-value">Set an attribute value</a> for
     <var>element</var> using "<code id="nonce-attributes:attr-nonce-7"><a href="#attr-nonce">nonce</a></code>" and the empty
     string.</p></li><li><p>Set <var>element</var>'s <a href="#cryptographicnonce" id="nonce-attributes:cryptographicnonce-6">[[CryptographicNonce]]</a> to
     <var>nonce</var>.</p></li></ol>

    <p class="note">If <var>element</var>'s <a href="#cryptographicnonce" id="nonce-attributes:cryptographicnonce-7">[[CryptographicNonce]]</a> were not restored it
    would be the empty string at this point.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="https://dom.spec.whatwg.org/#concept-node-clone-ext" id="nonce-attributes:concept-node-clone-ext" data-x-internal="concept-node-clone-ext">cloning steps</a> for elements that
  <a id="nonce-attributes:include-3" href="https://webidl.spec.whatwg.org/#include" data-x-internal="include">include</a> <code id="nonce-attributes:htmlorsvgelement-4"><a href="#htmlorsvgelement">HTMLOrSVGElement</a></code> given <var>node</var>, <var>copy</var>, and
  <var>subtree</var> are to set <var>copy</var>'s <a href="#cryptographicnonce" id="nonce-attributes:cryptographicnonce-8">[[CryptographicNonce]]</a> to
  <var>node</var>'s <a href="#cryptographicnonce" id="nonce-attributes:cryptographicnonce-9">[[CryptographicNonce]]</a>.</p>
  </div>

  <h4 id="lazy-loading-attributes"><span class="secno">2.5.7</span> Lazy loading attributes<a href="#lazy-loading-attributes" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading" title="Lazy loading is a strategy to identify resources as non-blocking (non-critical) and load these only when needed. It's a way to shorten the length of the critical rendering path, which translates into reduced page load times.">Lazy_loading</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>75+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>A <dfn id="lazy-loading-attribute">lazy loading attribute</dfn> is an <a href="#enumerated-attribute" id="lazy-loading-attributes:enumerated-attribute">enumerated attribute</a> with the following
  keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="img/loading,iframe/loading" id="attr-loading-lazy" data-dfn-type="attr-value"><code>lazy</code></dfn>
     </td><td><dfn id="attr-loading-lazy-state">Lazy</dfn>
     </td><td>Used to defer fetching a resource until some conditions are met.
    </td></tr><tr><td><dfn data-dfn-for="img/loading,iframe/loading" id="attr-loading-eager" data-dfn-type="attr-value"><code>eager</code></dfn>
     </td><td><dfn id="attr-loading-eager-state">Eager</dfn>
     </td><td>Used to fetch a resource immediately; the default state.
  </td></tr></tbody></table>

  <p>The attribute directs the user agent to fetch a resource immediately or to defer fetching until
  some conditions associated with the element are met, according to the attribute's current
  state.</p>

  <div data-algorithm="">
  <p>The attribute's <i id="lazy-loading-attributes:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="lazy-loading-attributes:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#attr-loading-eager-state" id="lazy-loading-attributes:attr-loading-eager-state">Eager</a> state.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="will-lazy-load-element-steps">will lazy load element steps</dfn>, given an element <var>element</var>,
  are as follows:</p>

  <ol><li>
    <p>If <a href="#concept-n-noscript" id="lazy-loading-attributes:concept-n-noscript">scripting is disabled</a> for <var>element</var>,
    then return false.</p>

    <p class="note">This is an anti-tracking measure, because if a user agent supported lazy loading
    when scripting is disabled, it would still be possible for a site to track a user's approximate
    scroll position throughout a session, by strategically placing images in a page's markup such
    that a server can track how many images are requested and when.</p>
   </li><li><p>If <var>element</var>'s <a href="#lazy-loading-attribute" id="lazy-loading-attributes:lazy-loading-attribute">lazy loading attribute</a> is in the <a href="#attr-loading-lazy-state" id="lazy-loading-attributes:attr-loading-lazy-state">Lazy</a> state, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <p>Each <code id="lazy-loading-attributes:the-img-element"><a href="#the-img-element">img</a></code> and <code id="lazy-loading-attributes:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element has associated <dfn id="lazy-load-resumption-steps">lazy load resumption
  steps</dfn>, initially null.</p>

  <p class="note">For <code id="lazy-loading-attributes:the-img-element-2"><a href="#the-img-element">img</a></code> and <code id="lazy-loading-attributes:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> elements that <a href="#will-lazy-load-element-steps" id="lazy-loading-attributes:will-lazy-load-element-steps">will lazy load</a>, these steps are run from the <a href="#lazy-load-intersection-observer" id="lazy-loading-attributes:lazy-load-intersection-observer">lazy load
  intersection observer</a>'s callback or when their <a href="#lazy-loading-attribute" id="lazy-loading-attributes:lazy-loading-attribute-2">lazy loading attribute</a> is set
  to the <a href="#attr-loading-eager-state" id="lazy-loading-attributes:attr-loading-eager-state-2">Eager</a> state. This causes the element to
  continue loading.</p>

  <p>Each <code id="lazy-loading-attributes:document"><a href="#document">Document</a></code> has a <dfn id="lazy-load-intersection-observer">lazy load intersection observer</dfn>, initially set to
  null but can be set to an <code id="lazy-loading-attributes:intersectionobserver"><a data-x-internal="intersectionobserver" href="https://w3c.github.io/IntersectionObserver/#intersectionobserver">IntersectionObserver</a></code> instance.</p>

  <div data-algorithm="">
  <p>To <dfn id="start-intersection-observing-a-lazy-loading-element">start intersection-observing a lazy loading element</dfn> <var>element</var>, run these
  steps:</p>

  <ol><li><p>Let <var>doc</var> be <var>element</var>'s <a id="lazy-loading-attributes:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li>
    <p>If <var>doc</var>'s <a href="#lazy-load-intersection-observer" id="lazy-loading-attributes:lazy-load-intersection-observer-2">lazy load intersection observer</a> is null, set it to a new
    <code id="lazy-loading-attributes:intersectionobserver-2"><a data-x-internal="intersectionobserver" href="https://w3c.github.io/IntersectionObserver/#intersectionobserver">IntersectionObserver</a></code> instance, initialized as follows:</p>

    <p class="XXX">The intention is to use the original value of the
    <code id="lazy-loading-attributes:intersectionobserver-3"><a data-x-internal="intersectionobserver" href="https://w3c.github.io/IntersectionObserver/#intersectionobserver">IntersectionObserver</a></code> constructor. However, we're forced to use the
    JavaScript-exposed constructor in this specification, until <cite>Intersection Observer</cite>
    exposes low-level hooks for use in specifications. See bug <a href="https://github.com/w3c/IntersectionObserver/issues/464">w3c/IntersectionObserver#464</a>
    which tracks this. <a href="#refsINTERSECTIONOBSERVER">[INTERSECTIONOBSERVER]</a></p>

    <ul><li>
      <p>The <var>callback</var> is these steps, with arguments <var>entries</var> and
      <var>observer</var>:</p>

      <ol><li>
        <p>For each <var>entry</var> in <var>entries</var> <span class="XXX">using a method of
        iteration which does not trigger developer-modifiable array accessors or
        iteration hooks</span>:</p>

        <ol><li><p>Let <var>resumptionSteps</var> be null.</p></li><li><p>If <var>entry</var>.<code id="lazy-loading-attributes:dom-intersectionobserverentry-isintersecting"><a data-x-internal="dom-intersectionobserverentry-isintersecting" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserverentry-isintersecting">isIntersecting</a></code> is true, then
         set <var>resumptionSteps</var> to <var>entry</var>.<code id="lazy-loading-attributes:dom-intersectionobserverentry-target"><a data-x-internal="dom-intersectionobserverentry-target" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserverentry-target">target</a></code>'s
         <a href="#lazy-load-resumption-steps" id="lazy-loading-attributes:lazy-load-resumption-steps">lazy load resumption steps</a>.</p></li><li><p>If <var>resumptionSteps</var> is null, then return.</p></li><li><p><a href="#stop-intersection-observing-a-lazy-loading-element" id="lazy-loading-attributes:stop-intersection-observing-a-lazy-loading-element">Stop intersection-observing a lazy loading element</a> for
         <var>entry</var>.<code id="lazy-loading-attributes:dom-intersectionobserverentry-target-2"><a data-x-internal="dom-intersectionobserverentry-target" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserverentry-target">target</a></code>.</p></li><li><p>Set <var>entry</var>.<code id="lazy-loading-attributes:dom-intersectionobserverentry-target-3"><a data-x-internal="dom-intersectionobserverentry-target" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserverentry-target">target</a></code>'s <a href="#lazy-load-resumption-steps" id="lazy-loading-attributes:lazy-load-resumption-steps-2">lazy load resumption
         steps</a> to null.</p></li><li><p>Invoke <var>resumptionSteps</var>.</p></li></ol>

        <p class="XXX">The intention is to use the original value of the
        <code id="lazy-loading-attributes:dom-intersectionobserverentry-isintersecting-2"><a data-x-internal="dom-intersectionobserverentry-isintersecting" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserverentry-isintersecting">isIntersecting</a></code> and
        <code id="lazy-loading-attributes:dom-intersectionobserverentry-target-4"><a data-x-internal="dom-intersectionobserverentry-target" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserverentry-target">target</a></code> getters. See <a href="https://github.com/w3c/IntersectionObserver/issues/464">w3c/IntersectionObserver#464</a>.
        <a href="#refsINTERSECTIONOBSERVER">[INTERSECTIONOBSERVER]</a></p>
       </li></ol>
     </li><li>
      <p>The <var>options</var> is an <code id="lazy-loading-attributes:intersectionobserverinit"><a data-x-internal="intersectionobserverinit" href="https://w3c.github.io/IntersectionObserver/#dictdef-intersectionobserverinit">IntersectionObserverInit</a></code> dictionary with the
      following dictionary members: «[ "<code>scrollMargin</code>" → <a href="#lazy-load-root-margin" id="lazy-loading-attributes:lazy-load-root-margin">lazy load scroll
      margin</a> ]»</p>

      <p class="note">This allows for fetching the image during scrolling, when it does not yet —
      but is about to — intersect the viewport.</p>

      <p class="XXX">The <a href="#lazy-load-root-margin" id="lazy-loading-attributes:lazy-load-root-margin-2">lazy load scroll margin</a> suggestions imply dynamic changes to the
      value, but the <code id="lazy-loading-attributes:intersectionobserver-4"><a data-x-internal="intersectionobserver" href="https://w3c.github.io/IntersectionObserver/#intersectionobserver">IntersectionObserver</a></code> API does not support changing the scroll
      margin. See issue <a href="https://github.com/w3c/IntersectionObserver/issues/428">w3c/IntersectionObserver#428</a>.</p>
     </li></ul>
   </li><li>
    <p>Call <var>doc</var>'s <a href="#lazy-load-intersection-observer" id="lazy-loading-attributes:lazy-load-intersection-observer-3">lazy load intersection observer</a>'s <code id="lazy-loading-attributes:dom-intersectionobserver-observe"><a data-x-internal="dom-intersectionobserver-observe" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-observe">observe</a></code> method with <var>element</var> as the
    argument.</p>

    <p class="XXX">The intention is to use the original value of the <code id="lazy-loading-attributes:dom-intersectionobserver-observe-2"><a data-x-internal="dom-intersectionobserver-observe" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-observe">observe</a></code> method. See <a href="https://github.com/w3c/IntersectionObserver/issues/464">w3c/IntersectionObserver#464</a>.
    <a href="#refsINTERSECTIONOBSERVER">[INTERSECTIONOBSERVER]</a></p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="stop-intersection-observing-a-lazy-loading-element">stop intersection-observing a lazy loading element</dfn> <var>element</var>, run these
  steps:</p>

  <ol><li><p>Let <var>doc</var> be <var>element</var>'s <a id="lazy-loading-attributes:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p><a id="lazy-loading-attributes:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>doc</var>'s <a href="#lazy-load-intersection-observer" id="lazy-loading-attributes:lazy-load-intersection-observer-4">lazy load intersection observer</a> is not
   null.</p></li><li>
    <p>Call <var>doc</var>'s <a href="#lazy-load-intersection-observer" id="lazy-loading-attributes:lazy-load-intersection-observer-5">lazy load intersection observer</a>'s <code id="lazy-loading-attributes:dom-intersectionobserver-unobserve"><a data-x-internal="dom-intersectionobserver-unobserve" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-unobserve">unobserve</a></code> method with <var>element</var> as
    the argument.</p>

    <p class="XXX">The intention is to use the original value of the <code id="lazy-loading-attributes:dom-intersectionobserver-unobserve-2"><a data-x-internal="dom-intersectionobserver-unobserve" href="https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-unobserve">unobserve</a></code> method. See <a href="https://github.com/w3c/IntersectionObserver/issues/464">w3c/IntersectionObserver#464</a>.
    <a href="#refsINTERSECTIONOBSERVER">[INTERSECTIONOBSERVER]</a></p>
   </li></ol>
  </div>

  <p>
  <a id="lazy-loading-attributes:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  The <dfn id="lazy-load-root-margin">lazy load scroll margin</dfn> is an
  <a id="lazy-loading-attributes:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> value, but with the following suggestions to consider:</p>

  <ul><li><p>Set a minimum value that most often results in the resources being loaded before they
   intersect the viewport under normal usage patterns for the given device.</p></li><li><p>The typical scrolling speed: increase the value for devices with faster typical scrolling
   speeds.</p></li><li><p>The current scrolling speed or momentum: the UA can attempt to predict where the scrolling
   will likely stop, and adjust the value accordingly.</p></li><li><p>The network quality: increase the value for slow or high-latency connections.</p></li><li><p>User preferences can influence the value.</p></li></ul>

  <p class="note">It is important <a href="https://infra.spec.whatwg.org/#tracking-vector" id="lazy-loading-attributes:tracking-vector-2" data-x-internal="tracking-vector">for privacy</a> that the
  <a href="#lazy-load-root-margin" id="lazy-loading-attributes:lazy-load-root-margin-3">lazy load scroll margin</a> not leak additional information. For example, the typical
  scrolling speed on the current device could be imprecise so as to not introduce a new
  fingerprinting vector.</p>

  <h4 id="blocking-attributes"><span class="secno">2.5.8</span> Blocking attributes<a href="#blocking-attributes" class="self-link"></a></h4>

  <p>A <dfn id="blocking-attribute">blocking attribute</dfn> explicitly indicates that certain operations should be blocked
  on the fetching of an external resource. The operations that can be blocked are represented by
  <dfn id="possible-blocking-token">possible blocking tokens</dfn>, which are strings listed by
  the following table:</p>

  <table><thead><tr><th>Possible blocking token
     </th><th>Description
   </th></tr></thead><tbody><tr><td>"<dfn id="blocking-token-render"><code>render</code></dfn>"
     </td><td>The element is <a href="#potentially-render-blocking" id="blocking-attributes:potentially-render-blocking">potentially render-blocking</a>.
  </td></tr></tbody></table>


  <p id="future-blocking-tokens" class="note"><a href="#future-blocking-tokens" class="self-link"></a>In the future, there might be more <a href="#possible-blocking-token" id="blocking-attributes:possible-blocking-token">possible blocking tokens</a>.</p>

  <p>A <a href="#blocking-attribute" id="blocking-attributes:blocking-attribute">blocking attribute</a> must have a value that is an <a href="#unordered-set-of-unique-space-separated-tokens" id="blocking-attributes:unordered-set-of-unique-space-separated-tokens">unordered set of unique
  space-separated tokens</a>, each of which are <a href="#possible-blocking-token" id="blocking-attributes:possible-blocking-token-2">possible
  blocking tokens</a>. The <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="blocking-attributes:concept-supported-tokens" data-x-internal="concept-supported-tokens">supported tokens</a> of a
  <a href="#blocking-attribute" id="blocking-attributes:blocking-attribute-2">blocking attribute</a> are the <a href="#possible-blocking-token" id="blocking-attributes:possible-blocking-token-3">possible blocking
  tokens</a>. Any element can have at most one <a href="#blocking-attribute" id="blocking-attributes:blocking-attribute-3">blocking attribute</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="blocking-tokens-set">blocking tokens set</dfn> for an element <var>el</var> are the result of the
  following steps:</p>

  <ol><li><p>Let <var>value</var> be the value of <var>el</var>'s <a href="#blocking-attribute" id="blocking-attributes:blocking-attribute-4">blocking attribute</a>, or
   the empty string if no such attribute exists.</p>

   </li><li><p>Set <var>value</var> to <var>value</var>, <a id="blocking-attributes:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>.</p>

   </li><li><p>Let <var>rawTokens</var> be the result of <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="blocking-attributes:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">splitting <var>value</var> on ASCII whitespace</a>.</p>

   </li><li><p>Return a set containing the elements of <var>rawTokens</var> that are <a href="#possible-blocking-token" id="blocking-attributes:possible-blocking-token-4">possible blocking tokens</a>.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>An element is <dfn id="potentially-render-blocking">potentially render-blocking</dfn> if its <a href="#blocking-tokens-set" id="blocking-attributes:blocking-tokens-set">blocking tokens set</a>
  contains "<code id="blocking-attributes:blocking-token-render"><a href="#blocking-token-render">render</a></code>", or if it is
  <dfn id="implicitly-potentially-render-blocking">implicitly potentially render-blocking</dfn>, which will be defined at the individual
  elements. By default, an element is not <a href="#implicitly-potentially-render-blocking" id="blocking-attributes:implicitly-potentially-render-blocking">implicitly potentially render-blocking</a>.</p>
  </div>

  <h4 id="fetch-priority-attributes"><span class="secno">2.5.9</span> Fetch priority attributes<a href="#fetch-priority-attributes" class="self-link"></a></h4>

  <p>A <dfn id="fetch-priority-attribute">fetch priority attribute</dfn> is an <a href="#enumerated-attribute" id="fetch-priority-attributes:enumerated-attribute">enumerated attribute</a> with the
  following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="img/fetchpriority,script/fetchpriority,link/fetchpriority" id="attr-fetchpriority-high" data-dfn-type="attr-value"><code>high</code></dfn>
     </td><td><dfn id="attr-fetchpriority-high-state">High</dfn>
     </td><td>Signals a high-priority <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetch-priority-attributes:concept-fetch" data-x-internal="concept-fetch">fetch</a> relative to other
     resources with the same <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetch-priority-attributes:concept-request-destination" data-x-internal="concept-request-destination">destination</a>.
    </td></tr><tr><td><dfn data-dfn-for="img/fetchpriority,script/fetchpriority,link/fetchpriority" id="attr-fetchpriority-low" data-dfn-type="attr-value"><code>low</code></dfn>
     </td><td><dfn id="attr-fetchpriority-low-state">Low</dfn>
     </td><td>Signals a low-priority <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetch-priority-attributes:concept-fetch-2" data-x-internal="concept-fetch">fetch</a> relative to other
     resources with the same <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetch-priority-attributes:concept-request-destination-2" data-x-internal="concept-request-destination">destination</a>.
    </td></tr><tr><td><dfn data-dfn-for="img/fetchpriority,script/fetchpriority,link/fetchpriority" id="attr-fetchpriority-auto" data-dfn-type="attr-value"><code>auto</code></dfn>
     </td><td><dfn id="attr-fetchpriority-auto-state">Auto</dfn>
     </td><td>Signals automatic determination of <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetch-priority-attributes:concept-fetch-3" data-x-internal="concept-fetch">fetch</a> priority
     relative to other resources with the same <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetch-priority-attributes:concept-request-destination-3" data-x-internal="concept-request-destination">destination</a>.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="fetch-priority-attributes:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and
  <i id="fetch-priority-attributes:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the
  <a href="#attr-fetchpriority-auto-state" id="fetch-priority-attributes:attr-fetchpriority-auto-state">Auto</a> state.</p>
  </div>

  <h3 id="common-dom-interfaces"><span class="secno">2.6</span> Common DOM interfaces<a href="#common-dom-interfaces" class="self-link"></a></h3>

  <h4 id="reflecting-content-attributes-in-idl-attributes"><span class="secno">2.6.1</span> Reflecting content attributes in IDL attributes<a href="#reflecting-content-attributes-in-idl-attributes" class="self-link"></a></h4>

  <p>The building blocks for reflecting are as follows:</p>

  <ul><li><p>A <dfn id="reflected-target">reflected target</dfn> is an element or <code id="reflecting-content-attributes-in-idl-attributes:elementinternals"><a href="#elementinternals">ElementInternals</a></code>
   object. It is typically clear from context and typically identical to the interface of the
   <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute">reflected IDL attribute</a>. It is always identical to that interface when it is an
   <code id="reflecting-content-attributes-in-idl-attributes:elementinternals-2"><a href="#elementinternals">ElementInternals</a></code> object.</p></li><li><p>A <dfn id="reflected-idl-attribute">reflected IDL attribute</dfn> is an attribute interface member.</p></li><li><p>A <dfn id="reflected-content-attribute-name">reflected content attribute name</dfn> is a string. When the <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target">reflected
   target</a> is an element, it represents the local name of a content attribute whose namespace
   is null. When the <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-2">reflected target</a> is an <code id="reflecting-content-attributes-in-idl-attributes:elementinternals-3"><a href="#elementinternals">ElementInternals</a></code> object, it
   represents a key of the <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-3">reflected target</a>'s <a href="#internals-target" id="reflecting-content-attributes-in-idl-attributes:internals-target">target
   element</a>'s <a href="#internal-content-attribute-map" id="reflecting-content-attributes-in-idl-attributes:internal-content-attribute-map">internal content attribute map</a>.</p></li></ul>

  <p>A <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-2">reflected IDL attribute</a> can be defined to <dfn id="reflect" data-export="">reflect</dfn> a
  <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name">reflected content attribute name</a> of a <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-4">reflected target</a>. In general this
  means that the IDL attribute getter returns the current value of the content attribute, and the
  setter changes the value of the content attribute to the given value.</p>

  

  <p><a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-5">Reflected targets</a> have these associated algorithms:

  </p><ul class="brief"><li><dfn id="get-the-element">get the element</dfn>: takes no arguments; returns an element.</li><li><dfn id="get-the-content-attribute">get the content attribute</dfn>: takes no arguments; returns null or a string.</li><li><dfn id="set-the-content-attribute">set the content attribute</dfn>: takes a string <var>value</var>; returns nothing.</li><li><dfn id="delete-the-content-attribute">delete the content attribute</dfn>: takes no arguments; returns nothing.</li></ul>

  <div data-var-scope="">
  <p>For a <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-6">reflected target</a> that is an element <var>element</var>, these are defined as
  follows:</p>

  <dl><div data-algorithm="">
   <dt><a href="#get-the-element" id="reflecting-content-attributes-in-idl-attributes:get-the-element">get the element</a></dt>
   <dd><ol><li><p>Return <var>element</var>.</p></li></ol></dd>
   </div><div data-algorithm="">
   <dt><a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute">get the content attribute</a></dt>
   <dd>
    <ol><li><p>Let <var>attribute</var> be the result of running <a href="https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace" id="reflecting-content-attributes-in-idl-attributes:concept-element-attributes-get-by-namespace" data-x-internal="concept-element-attributes-get-by-namespace">get an attribute by namespace and local
     name</a> given null, the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-2">reflected content attribute name</a>, and
     <var>element</var>.</p></li><li><p>If <var>attribute</var> is null, then return null.</p></li><li><p>Return <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="reflecting-content-attributes-in-idl-attributes:concept-attribute-value" data-x-internal="concept-attribute-value">value</a>.</p></li></ol>
   </dd>
   </div><div data-algorithm="">
   <dt><a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute">set the content attribute</a> with a string <var>value</var></dt>
   <dd><ol><li><p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="reflecting-content-attributes-in-idl-attributes:concept-element-attributes-set-value" data-x-internal="concept-element-attributes-set-value">Set an attribute value</a>
   given <var>element</var>, the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-3">reflected content attribute name</a>, and
   <var>value</var>.</p></li></ol></dd>
   </div><div data-algorithm="">
   <dt><a href="#delete-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:delete-the-content-attribute">delete the content attribute</a></dt>
   <dd><ol><li><p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace" id="reflecting-content-attributes-in-idl-attributes:concept-element-attributes-remove-by-namespace" data-x-internal="concept-element-attributes-remove-by-namespace">Remove an attribute
   by namespace and local name</a> given null, the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-4">reflected content attribute name</a>,
   and <var>element</var>.</p></li></ol></dd>
   </div></dl>
  </div>

  <div data-var-scope="">
  <p>For a <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-7">reflected target</a> that is an <code id="reflecting-content-attributes-in-idl-attributes:elementinternals-4"><a href="#elementinternals">ElementInternals</a></code> object
  <var>elementInternals</var>, they are defined as follows:</p>

  <dl><div data-algorithm="">
   <dt><a href="#get-the-element" id="reflecting-content-attributes-in-idl-attributes:get-the-element-2">get the element</a></dt>
   <dd><ol><li><p>Return <var>elementInternals</var>'s <a href="#internals-target" id="reflecting-content-attributes-in-idl-attributes:internals-target-2">target
   element</a>.</p></li></ol></dd>
   </div><div data-algorithm="">
   <dt><a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-2">get the content attribute</a></dt>
   <dd>
    <ol><li><p>If <var>elementInternals</var>'s <a href="#internals-target" id="reflecting-content-attributes-in-idl-attributes:internals-target-3">target element</a>'s
     <a href="#internal-content-attribute-map" id="reflecting-content-attributes-in-idl-attributes:internal-content-attribute-map-2">internal content attribute map</a>[the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-5">reflected content attribute name</a>]
     <a href="https://infra.spec.whatwg.org/#map-exists" id="reflecting-content-attributes-in-idl-attributes:map-exists" data-x-internal="map-exists">does not exist</a>, then return null.

     </p></li><li><p>Return <var>elementInternals</var>'s <a href="#internals-target" id="reflecting-content-attributes-in-idl-attributes:internals-target-4">target
     element</a>'s <a href="#internal-content-attribute-map" id="reflecting-content-attributes-in-idl-attributes:internal-content-attribute-map-3">internal content attribute map</a>[the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-6">reflected content
     attribute name</a>].</p></li></ol>
   </dd>
   </div><div data-algorithm="">
   <dt><a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-2">set the content attribute</a> with a string <var>value</var></dt>
   <dd><ol><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="reflecting-content-attributes-in-idl-attributes:map-set" data-x-internal="map-set">Set</a> <var>elementInternals</var>'s <a href="#internals-target" id="reflecting-content-attributes-in-idl-attributes:internals-target-5">target element</a>'s <a href="#internal-content-attribute-map" id="reflecting-content-attributes-in-idl-attributes:internal-content-attribute-map-4">internal content attribute map</a>[the
   <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-7">reflected content attribute name</a>] to <var>value</var>.</p></li></ol></dd>
   </div><div data-algorithm="">
   <dt><a href="#delete-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:delete-the-content-attribute-2">delete the content attribute</a></dt>
   <dd><ol><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="reflecting-content-attributes-in-idl-attributes:map-remove" data-x-internal="map-remove">Remove</a> <var>elementInternals</var>'s <a href="#internals-target" id="reflecting-content-attributes-in-idl-attributes:internals-target-6">target element</a>'s <a href="#internal-content-attribute-map" id="reflecting-content-attributes-in-idl-attributes:internal-content-attribute-map-5">internal content attribute map</a>[the
   <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-8">reflected content attribute name</a>].</p></li></ol></dd>
   </div></dl>
  </div>

  <p class="note">This results in somewhat redundant data structures for
  <code id="reflecting-content-attributes-in-idl-attributes:elementinternals-5"><a href="#elementinternals">ElementInternals</a></code> objects as their <a href="#internals-target" id="reflecting-content-attributes-in-idl-attributes:internals-target-7">target
  element</a>'s <a href="#internal-content-attribute-map" id="reflecting-content-attributes-in-idl-attributes:internal-content-attribute-map-6">internal content attribute map</a> cannot be directly manipulated and as
  such reflection is only happening in a single direction. This approach was nevertheless chosen to
  make it less error-prone to define IDL attributes that are shared between <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-8">reflected targets</a> and benefit from common API semantics.</p>

  <hr>

  <p>IDL attributes of type <code id="reflecting-content-attributes-in-idl-attributes:idl-domstring"><a data-x-internal="idl-domstring" href="https://webidl.spec.whatwg.org/#idl-DOMString">DOMString</a></code> or <code><a href="https://webidl.spec.whatwg.org/#idl-DOMString" id="reflecting-content-attributes-in-idl-attributes:idl-domstring-2" data-x-internal="idl-domstring">DOMString</a>?</code> that <a href="#reflect" id="reflecting-content-attributes-in-idl-attributes:reflect">reflect</a> <a href="#enumerated-attribute" id="reflecting-content-attributes-in-idl-attributes:enumerated-attribute">enumerated</a> content attributes can be <dfn id="limited-to-only-known-values">limited to only known values</dfn>.
  Per the processing models below, those will cause the getters for such IDL attributes to only
  return keywords for those enumerated attributes, or the empty string or null.</p>

  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-3">reflected IDL attribute</a> has the type <code id="reflecting-content-attributes-in-idl-attributes:idl-domstring-3"><a data-x-internal="idl-domstring" href="https://webidl.spec.whatwg.org/#idl-DOMString">DOMString</a></code>:</p>

  <ul><li>
    <div data-algorithm="">
    <p>The getter steps are:</p>

    <ol><li><p>Let <var>element</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#get-the-element" id="reflecting-content-attributes-in-idl-attributes:get-the-element-3">get the
     element</a>.</p></li><li><p>Let <var>contentAttributeValue</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
     <a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-3">get the content attribute</a>.</p></li><li><p>Let <var>attributeDefinition</var> be the attribute definition of <var>element</var>'s
     content attribute whose namespace is null and local name is the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-9">reflected content
     attribute name</a>.

     </p></li><li>
      <p>If <var>attributeDefinition</var> indicates it is an <a href="#enumerated-attribute" id="reflecting-content-attributes-in-idl-attributes:enumerated-attribute-2">enumerated attribute</a> and
      the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-4">reflected IDL attribute</a> is defined to be <a href="#limited-to-only-known-values" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-known-values">limited to only known
      values</a>:</p>

      <ol><li><p>If <var>contentAttributeValue</var> does not correspond to any state of
       <var>attributeDefinition</var> (e.g., it is null and there is no <i id="reflecting-content-attributes-in-idl-attributes:missing-value-default"><a href="#missing-value-default">missing value default</a></i>), or if it is in a state of
       <var>attributeDefinition</var> with no associated keyword value, then return the empty
       string.</p></li><li><p>Return the <a href="#canonical-keyword" id="reflecting-content-attributes-in-idl-attributes:canonical-keyword">canonical keyword</a> for the state of
       <var>attributeDefinition</var> that <var>contentAttributeValue</var> corresponds to.</p></li></ol>
     </li><li><p>If <var>contentAttributeValue</var> is null, then return the empty string.</p></li><li><p>Return <var>contentAttributeValue</var>.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The setter steps are to run <a id="reflecting-content-attributes-in-idl-attributes:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-3">set the content attribute</a>
    with the given value.</p>
    </div>
   </li></ul>

  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-5">reflected IDL attribute</a> has the type <code><a href="https://webidl.spec.whatwg.org/#idl-DOMString" id="reflecting-content-attributes-in-idl-attributes:idl-domstring-4" data-x-internal="idl-domstring">DOMString</a>?</code>:</p>

  <ul><li>
    <div data-algorithm="">
    <p>The getter steps are:</p>

    <ol><li><p>Let <var>element</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#get-the-element" id="reflecting-content-attributes-in-idl-attributes:get-the-element-4">get the
     element</a>.</p></li><li><p>Let <var>contentAttributeValue</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
     <a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-4">get the content attribute</a>.</p></li><li><p>Let <var>attributeDefinition</var> be the attribute definition of <var>element</var>'s
     content attribute whose namespace is null and local name is the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-10">reflected content
     attribute name</a>.

     </p></li><li>
      <p>If <var>attributeDefinition</var> indicates it is an <a href="#enumerated-attribute" id="reflecting-content-attributes-in-idl-attributes:enumerated-attribute-3">enumerated attribute</a>:</p>

      <ol><li><p><a id="reflecting-content-attributes-in-idl-attributes:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-6">reflected IDL attribute</a> is <a href="#limited-to-only-known-values" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-known-values-2">limited to only
       known values</a>.</p></li><li><p><a id="reflecting-content-attributes-in-idl-attributes:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>contentAttributeValue</var> corresponds to a state of
       <var>attributeDefinition</var>.</p></li><li><p>If <var>contentAttributeValue</var> corresponds to a state of
       <var>attributeDefinition</var> with no associated keyword value, then return null.</p></li><li><p>Return the <a href="#canonical-keyword" id="reflecting-content-attributes-in-idl-attributes:canonical-keyword-2">canonical keyword</a> for the state of
       <var>attributeDefinition</var> that <var>contentAttributeValue</var> corresponds to.</p></li></ol>
     </li><li><p>Return <var>contentAttributeValue</var>.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The setter steps are:</p>

    <ol><li><p>If the given value is null, then run <a id="reflecting-content-attributes-in-idl-attributes:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#delete-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:delete-the-content-attribute-3">delete the content
     attribute</a>.</p></li><li><p>Otherwise, run <a id="reflecting-content-attributes-in-idl-attributes:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-4">set the content attribute</a> with the given
     value.</p></li></ol>
    </div>
   </li></ul>

  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-7">reflected IDL attribute</a> has the type <code id="reflecting-content-attributes-in-idl-attributes:idl-usvstring"><a data-x-internal="idl-usvstring" href="https://webidl.spec.whatwg.org/#idl-USVString">USVString</a></code>, optionally <dfn id="treated-as-a-url">treated as a URL</dfn>:</p>

  <ul><li>
    <div data-algorithm="">
    <p>The getter steps are:</p>

    <ol><li><p>Let <var>element</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#get-the-element" id="reflecting-content-attributes-in-idl-attributes:get-the-element-5">get the
     element</a>.</p></li><li><p>Let <var>contentAttributeValue</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
     <a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-5">get the content attribute</a>.</p></li><li>
      <p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-8">reflected IDL attribute</a> is <a href="#treated-as-a-url" id="reflecting-content-attributes-in-idl-attributes:treated-as-a-url">treated as a URL</a>:</p>

      <ol><li><p>If <var>contentAttributeValue</var> is null, then return the empty string.</p></li><li><p>Let <var>urlString</var> be the result of <a href="#encoding-parsing-and-serializing-a-url" id="reflecting-content-attributes-in-idl-attributes:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing a
       URL</a> given <var>contentAttributeValue</var>, relative to <var>element</var>'s
       <a id="reflecting-content-attributes-in-idl-attributes:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>urlString</var> is not failure, then return <var>urlString</var>.</p></li></ol>
     </li><li><p>Return <var>contentAttributeValue</var>, <a href="https://infra.spec.whatwg.org/#javascript-string-convert" id="reflecting-content-attributes-in-idl-attributes:convert" data-x-internal="convert">converted to a scalar value string</a>.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The setter steps are to run <a id="reflecting-content-attributes-in-idl-attributes:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-5">set the content attribute</a>
    with the given value.</p>
    </div>
   </li></ul>

  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-9">reflected IDL attribute</a> has the type <code id="reflecting-content-attributes-in-idl-attributes:idl-boolean"><a data-x-internal="idl-boolean" href="https://webidl.spec.whatwg.org/#idl-boolean">boolean</a></code>:</p>

  <ul><li>
    <div data-algorithm="">
    <p>The getter steps are:</p>

    <ol><li><p>Let <var>contentAttributeValue</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
     <a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-6">get the content attribute</a>.</p></li><li><p>If <var>contentAttributeValue</var> is null, then return false.</p></li><li><p>Return true.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The setter steps are:</p>

    <ol><li><p>If the given value is false, then run <a id="reflecting-content-attributes-in-idl-attributes:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#delete-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:delete-the-content-attribute-4">delete the content
     attribute</a>.</p></li><li><p>If the given value is true, then run <a id="reflecting-content-attributes-in-idl-attributes:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-6">set the content
     attribute</a> with the empty string.
    </p></li></ol>
    </div>
   </li></ul>

  <p class="note">This corresponds to the rules for <a href="#boolean-attribute" id="reflecting-content-attributes-in-idl-attributes:boolean-attribute">boolean content
  attributes</a>.

  </p><div data-var-scope="">
  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-10">reflected IDL attribute</a> has the type <code id="reflecting-content-attributes-in-idl-attributes:idl-long"><a data-x-internal="idl-long" href="https://webidl.spec.whatwg.org/#idl-long">long</a></code>,
  optionally <dfn id="limited-to-only-non-negative-numbers">limited to only non-negative numbers</dfn> and optionally with a <dfn id="default-value">default
  value</dfn> <var>defaultValue</var>:

  </p><ul><li>
    <div data-algorithm="">
    <p>The getter steps are:</p>

    <ol><li><p>Let <var>contentAttributeValue</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
     <a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-7">get the content attribute</a>.</p></li><li>
      <p>If <var>contentAttributeValue</var> is not null:

      </p><ol><li><p>Let <var>parsedValue</var> be the result of <a href="#rules-for-parsing-integers" id="reflecting-content-attributes-in-idl-attributes:rules-for-parsing-integers">integer parsing</a> <var>contentAttributeValue</var> if the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-11">reflected IDL
       attribute</a> is not <a href="#limited-to-only-non-negative-numbers" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers">limited to only non-negative numbers</a>; otherwise the
       result of <a href="#rules-for-parsing-non-negative-integers" id="reflecting-content-attributes-in-idl-attributes:rules-for-parsing-non-negative-integers">non-negative integer
       parsing</a> <var>contentAttributeValue</var>.</p></li><li><p>If <var>parsedValue</var> is not an error and is within the <code id="reflecting-content-attributes-in-idl-attributes:idl-long-2"><a data-x-internal="idl-long" href="https://webidl.spec.whatwg.org/#idl-long">long</a></code> range, then return <var>parsedValue</var>.</p></li></ol>
     </li><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-12">reflected IDL attribute</a> has a <a href="#default-value" id="reflecting-content-attributes-in-idl-attributes:default-value">default value</a>, then
     return <var>defaultValue</var>.</p></li><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-13">reflected IDL attribute</a> is <a href="#limited-to-only-non-negative-numbers" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers-2">limited to only non-negative
     numbers</a>, then return −1.</p></li><li><p>Return 0.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The setter steps are:</p>

    <ol><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-14">reflected IDL attribute</a> is <a href="#limited-to-only-non-negative-numbers" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers-3">limited to only non-negative
     numbers</a> and the given value is negative, then throw an
     <a id="reflecting-content-attributes-in-idl-attributes:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="reflecting-content-attributes-in-idl-attributes:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Run <a id="reflecting-content-attributes-in-idl-attributes:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-7">set the content attribute</a> with the given value
     converted to the shortest possible string representing the number as a <a href="#valid-integer" id="reflecting-content-attributes-in-idl-attributes:valid-integer">valid
     integer</a>.</p></li></ol>
    </div>
   </li></ul>
  </div>

  <div data-var-scope="">
  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-15">reflected IDL attribute</a> has the type <code id="reflecting-content-attributes-in-idl-attributes:idl-unsigned-long"><a data-x-internal="idl-unsigned-long" href="https://webidl.spec.whatwg.org/#idl-unsigned-long">unsigned long</a></code>, optionally <dfn id="limited-to-only-non-negative-numbers-greater-than-zero">limited to only positive
  numbers</dfn>, <dfn id="limited-to-only-non-negative-numbers-greater-than-zero-with-fallback">limited to only positive
  numbers with fallback</dfn>, or <dfn id="clamped-to-the-range">clamped to the range</dfn> [<var>clampedMin</var>,
  <var>clampedMax</var>], and optionally with a <a href="#default-value" id="reflecting-content-attributes-in-idl-attributes:default-value-2">default value</a> <var>defaultValue</var>:

  </p><ul><li>
    <div data-algorithm="">
    <p>The getter steps are:</p>

    <ol><li><p>Let <var>contentAttributeValue</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-16" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
     <a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-8">get the content attribute</a>.</p></li><li><p>Let <var>minimum</var> be 0.</p></li><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-16">reflected IDL attribute</a> is <a href="#limited-to-only-non-negative-numbers-greater-than-zero" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers-greater-than-zero">limited to only positive
     numbers</a> or <a href="#limited-to-only-non-negative-numbers-greater-than-zero-with-fallback" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers-greater-than-zero-with-fallback">limited to only positive numbers with fallback</a>, then set
     <var>minimum</var> to 1.</p></li><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-17">reflected IDL attribute</a> is <a href="#clamped-to-the-range" id="reflecting-content-attributes-in-idl-attributes:clamped-to-the-range">clamped to the range</a>, then
     set <var>minimum</var> to <var>clampedMin</var>.</p></li><li><p>Let <var>maximum</var> be 2147483647 if the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-18">reflected IDL attribute</a> is not
     <a href="#clamped-to-the-range" id="reflecting-content-attributes-in-idl-attributes:clamped-to-the-range-2">clamped to the range</a>; otherwise <var>clampedMax</var>.</p></li><li>
      <p>If <var>contentAttributeValue</var> is not null:

      </p><ol><li><p>Let <var>parsedValue</var> be the result of <a href="#rules-for-parsing-non-negative-integers" id="reflecting-content-attributes-in-idl-attributes:rules-for-parsing-non-negative-integers-2">non-negative integer parsing</a>
       <var>contentAttributeValue</var>.</p></li><li><p>If <var>parsedValue</var> is not an error and is in the range <var>minimum</var> to
       <var>maximum</var>, inclusive, then return <var>parsedValue</var>.</p></li><li>
        <p>If <var>parsedValue</var> is not an error and the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-19">reflected IDL attribute</a> is
        <a href="#clamped-to-the-range" id="reflecting-content-attributes-in-idl-attributes:clamped-to-the-range-3">clamped to the range</a>:

        </p><ol><li><p>If <var>parsedValue</var> is less than <var>minimum</var>, then return
         <var>minimum</var>.</p></li><li><p>Return <var>maximum</var>.</p></li></ol>
       </li></ol>
     </li><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-20">reflected IDL attribute</a> has a <a href="#default-value" id="reflecting-content-attributes-in-idl-attributes:default-value-3">default value</a>, then
     return <var>defaultValue</var>.</p></li><li><p>Return <var>minimum</var>.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The setter steps are:</p>

    <ol><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-21">reflected IDL attribute</a> is <a href="#limited-to-only-non-negative-numbers-greater-than-zero" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers-greater-than-zero-2">limited to only positive
     numbers</a> and the given value is 0, then throw an
     <a id="reflecting-content-attributes-in-idl-attributes:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="reflecting-content-attributes-in-idl-attributes:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>minimum</var> be 0.</p></li><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-22">reflected IDL attribute</a> is <a href="#limited-to-only-non-negative-numbers-greater-than-zero" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers-greater-than-zero-3">limited to only positive
     numbers</a> or <a href="#limited-to-only-non-negative-numbers-greater-than-zero-with-fallback" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers-greater-than-zero-with-fallback-2">limited to only positive numbers with fallback</a>, then set
     <var>minimum</var> to 1.</p></li><li><p>Let <var>newValue</var> be <var>minimum</var>.</p></li><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-23">reflected IDL attribute</a> has a <a href="#default-value" id="reflecting-content-attributes-in-idl-attributes:default-value-4">default value</a>, then set
     <var>newValue</var> to <var>defaultValue</var>.</p></li><li><p>If the given value is in the range <var>minimum</var> to 2147483647, inclusive,
     then set <var>newValue</var> to it.</p></li><li><p>Run <a id="reflecting-content-attributes-in-idl-attributes:this-17" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-8">set the content attribute</a> with <var>newValue</var>
     converted to the shortest possible string representing the number as a <a href="#valid-non-negative-integer" id="reflecting-content-attributes-in-idl-attributes:valid-non-negative-integer">valid non-negative
     integer</a>.</p></li></ol>
    </div>

    <p class="note"><a href="#clamped-to-the-range" id="reflecting-content-attributes-in-idl-attributes:clamped-to-the-range-4">Clamped to the range</a> has no effect on the setter steps.</p>
   </li></ul>
  </div>
  

  <div data-var-scope="">
  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-24">reflected IDL attribute</a> has the type <code id="reflecting-content-attributes-in-idl-attributes:idl-double"><a data-x-internal="idl-double" href="https://webidl.spec.whatwg.org/#idl-double">double</a></code>,
  optionally <a href="#limited-to-only-non-negative-numbers-greater-than-zero" id="limited-to-numbers-greater-than-zero">limited to only positive numbers</a>
  and optionally with a <a href="#default-value" id="reflecting-content-attributes-in-idl-attributes:default-value-5">default value</a> <var>defaultValue</var>:

  </p><ul><li>
    <div data-algorithm="">
    <p>The getter steps are:</p>

    <ol><li><p>Let <var>contentAttributeValue</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-18" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
     <a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-9">get the content attribute</a>.</p></li><li>
      <p>If <var>contentAttributeValue</var> is not null:

      </p><ol><li><p>Let <var>parsedValue</var> be the result of <a href="#rules-for-parsing-floating-point-number-values" id="reflecting-content-attributes-in-idl-attributes:rules-for-parsing-floating-point-number-values">floating-point number parsing</a>
       <var>contentAttributeValue</var>.</p></li><li><p>If <var>parsedValue</var> is not an error and is greater than 0, then return
       <var>parsedValue</var>.</p></li><li><p>If <var>parsedValue</var> is not an error and the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-25">reflected IDL attribute</a>
       is not <a href="#limited-to-only-non-negative-numbers-greater-than-zero" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers-greater-than-zero-4">limited to only positive numbers</a>, then return
       <var>parsedValue</var>.</p></li></ol>
     </li><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-26">reflected IDL attribute</a> has a <a href="#default-value" id="reflecting-content-attributes-in-idl-attributes:default-value-6">default value</a>, then
     return <var>defaultValue</var>.</p></li><li><p>Return 0.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The setter steps are:</p>

    <ol><li><p>If the <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-27">reflected IDL attribute</a> is <a href="#limited-to-only-non-negative-numbers-greater-than-zero" id="reflecting-content-attributes-in-idl-attributes:limited-to-only-non-negative-numbers-greater-than-zero-5">limited to only positive
     numbers</a> and the given value is not greater than 0, then return.</p></li><li><p>Run <a id="reflecting-content-attributes-in-idl-attributes:this-19" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-9">set the content attribute</a> with the given value,
     converted to the <a href="#best-representation-of-the-number-as-a-floating-point-number" id="reflecting-content-attributes-in-idl-attributes:best-representation-of-the-number-as-a-floating-point-number">best representation of the number as a floating-point
     number</a>.</p></li></ol>
    </div>
   </li></ul>
  </div>

  <p class="note">The values Infinity and Not-a-Number (NaN) values throw an exception on setting,
  as defined in <cite>Web IDL</cite>. <a href="#refsWEBIDL">[WEBIDL]</a></p>

  <div data-algorithm="">
  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-28">reflected IDL attribute</a> has the type <code id="reflecting-content-attributes-in-idl-attributes:domtokenlist"><a data-x-internal="domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist">DOMTokenList</a></code>, then its
  getter steps are to return a <code id="reflecting-content-attributes-in-idl-attributes:domtokenlist-2"><a data-x-internal="domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist">DOMTokenList</a></code> object whose associated element is
  <a id="reflecting-content-attributes-in-idl-attributes:this-20" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and associated attribute's local name is the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-11">reflected content
  attribute name</a>. Specification authors cannot reflect IDL attributes of this type on
  <code id="reflecting-content-attributes-in-idl-attributes:elementinternals-6"><a href="#elementinternals">ElementInternals</a></code>.</p>
  </div>
  

  <div data-var-scope="">
  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-29">reflected IDL attribute</a> has the type <code><var>T</var>?</code>,
  where <var>T</var> is either <code id="reflecting-content-attributes-in-idl-attributes:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or an interface that inherits from
  <code id="reflecting-content-attributes-in-idl-attributes:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>, then with <var>attr</var> being the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-12">reflected content attribute
  name</a>:</p>

  <ul><li><p>Its <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-9">reflected target</a> has an <dfn id="explicitly-set-attr-element">explicitly set
   <var>attr</var>-element</dfn>, which is a weak reference to an element or null. It is initially
   null.</p></li><li>
    <div data-algorithm="">
    <p>Its <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-10">reflected target</a> <var>reflectedTarget</var> has a <dfn data-dfn-for="Element,ElementInternals" id="attr-associated-element" data-export="">get the
    <var>attr</var>-associated element</dfn> algorithm, that runs these steps:</p>

    <ol><li><p>Let <var>element</var> be the result of running <var>reflectedTarget</var>'s <a href="#get-the-element" id="reflecting-content-attributes-in-idl-attributes:get-the-element-6">get
     the element</a>.</p></li><li><p>Let <var>contentAttributeValue</var> be the result of running
     <var>reflectedTarget</var>'s <a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-10">get the content attribute</a>.</p></li><li>
      <p>If <var>reflectedTarget</var>'s <a href="#explicitly-set-attr-element" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-element">explicitly set <var>attr</var>-element</a> is not
      null:</p>

      <ol><li><p>If <var>reflectedTarget</var>'s <a href="#explicitly-set-attr-element" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-element-2">explicitly set <var>attr</var>-element</a> is
       a <a id="reflecting-content-attributes-in-idl-attributes:descendant" href="https://dom.spec.whatwg.org/#concept-tree-descendant" data-x-internal="descendant">descendant</a> of any of <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-shadow-including-ancestor" id="reflecting-content-attributes-in-idl-attributes:concept-shadow-including-ancestor" data-x-internal="concept-shadow-including-ancestor">shadow-including ancestors</a>, then return
       <var>reflectedTarget</var>'s <a href="#explicitly-set-attr-element" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-element-3">explicitly set <var>attr</var>-element</a>.</p></li><li><p>Return null.</p></li></ol>
     </li><li>
      <p>Otherwise, if <var>contentAttributeValue</var> is not null, return the first element
      <var>candidate</var>, in <a id="reflecting-content-attributes-in-idl-attributes:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, that meets the following criteria:</p>

      <ul><li><p><var>candidate</var>'s <a id="reflecting-content-attributes-in-idl-attributes:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> is the same as <var>element</var>'s
       <a id="reflecting-content-attributes-in-idl-attributes:root-2" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>;</p></li><li><p><var>candidate</var>'s <a href="https://dom.spec.whatwg.org/#concept-id" id="reflecting-content-attributes-in-idl-attributes:concept-id" data-x-internal="concept-id">ID</a> is
       <var>contentAttributeValue</var>; and</p></li><li><p><var>candidate</var> <a id="reflecting-content-attributes-in-idl-attributes:implements" href="https://webidl.spec.whatwg.org/#implements" data-x-internal="implements">implements</a> <var>T</var>.</p></li></ul>

      <p>If no such element exists, then return null.</p>
     </li><li><p>Return null.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The getter steps are to return the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-21" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#attr-associated-element" id="reflecting-content-attributes-in-idl-attributes:attr-associated-element">get the
    <var>attr</var>-associated element</a>.</p>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The setter steps are:</p>
    <ol><li>
      <p>If the given value is null, then:</p>

      <ol><li><p>Set <a id="reflecting-content-attributes-in-idl-attributes:this-22" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#explicitly-set-attr-element" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-element-4">explicitly set <var>attr</var>-element</a> to
       null.</p></li><li><p>Run <a id="reflecting-content-attributes-in-idl-attributes:this-23" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#delete-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:delete-the-content-attribute-5">delete the content attribute</a>.</p></li><li><p>Return.</p></li></ol>
     </li><li><p>Run <a id="reflecting-content-attributes-in-idl-attributes:this-24" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-10">set the content attribute</a> with the empty
     string.</p></li><li><p>Set <a id="reflecting-content-attributes-in-idl-attributes:this-25" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#explicitly-set-attr-element" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-element-5">explicitly set <var>attr</var>-element</a> to a weak
     reference to the given value.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>For element <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-11">reflected targets</a> only: the following
    <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="reflecting-content-attributes-in-idl-attributes:concept-element-attributes-change-ext" data-x-internal="concept-element-attributes-change-ext">attribute change steps</a>, given
    <var>element</var>, <var>localName</var>, <var>oldValue</var>, <var>value</var>, and
    <var>namespace</var>, are used to synchronize between the content attribute and the IDL
    attribute:</p>

    <ol><li><p>If <var>localName</var> is not <var>attr</var> or <var>namespace</var> is not null, then
     return.</p></li><li><p>Set <var>element</var>'s <a href="#explicitly-set-attr-element" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-element-6">explicitly set <var>attr</var>-element</a> to
     null.</p></li></ol>
    </div>
   </li></ul>
  </div>

  <p class="note"><a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-30">Reflected IDL attributes</a> of this
  type are strongly encouraged to have their identifier end in "<code>Element</code>" for
  consistency.</p>

  <div data-var-scope="">
  <p>If a <a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-31">reflected IDL attribute</a> has the type <code>FrozenArray&lt;<var>T</var>&gt;?</code>, where <var>T</var> is either
  <code id="reflecting-content-attributes-in-idl-attributes:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or an interface that inherits from <code id="reflecting-content-attributes-in-idl-attributes:element-4"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>, then with
  <var>attr</var> being the <a href="#reflected-content-attribute-name" id="reflecting-content-attributes-in-idl-attributes:reflected-content-attribute-name-13">reflected content attribute name</a>:</p>

  <ul><li><p>Its <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-12">reflected target</a> has an <dfn id="explicitly-set-attr-elements">explicitly set
   <var>attr</var>-elements</dfn>, which is either a <a id="reflecting-content-attributes-in-idl-attributes:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of weak references to
   elements or null. It is initially null.</p></li><li><p>Its <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-13">reflected target</a> has a <dfn id="cached-attr-associated-elements">cached <var>attr</var>-associated
   elements</dfn>, which is a <a id="reflecting-content-attributes-in-idl-attributes:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of elements. It is initially « ».</p></li><li><p>Its <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-14">reflected target</a> has a <dfn id="cached-attr-associated-elements-object">cached <var>attr</var>-associated
   elements object</dfn>, which is a <code>FrozenArray&lt;<var>T</var>&gt;?</code>. It is
   initially null.</p></li><li>
    <div data-algorithm="">
    <p>Its <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-15">reflected target</a> <var>reflectedTarget</var> has a <dfn data-dfn-for="Element,ElementInternals" id="attr-associated-elements" data-export="">get the
    <var>attr</var>-associated elements</dfn> algorithm, which runs these steps:</p>

    <ol><li><p>Let <var>elements</var> be an empty <a id="reflecting-content-attributes-in-idl-attributes:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>Let <var>element</var> be the result of running <var>reflectedTarget</var>'s <a href="#get-the-element" id="reflecting-content-attributes-in-idl-attributes:get-the-element-7">get
     the element</a>.</p></li><li>
      <p>If <var>reflectedTarget</var>'s <a href="#explicitly-set-attr-elements" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-elements">explicitly set <var>attr</var>-elements</a> is not
      null:</p>

      <ol><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="reflecting-content-attributes-in-idl-attributes:list-iterate" data-x-internal="list-iterate">For each</a> <var>attrElement</var> in
        <var>reflectedTarget</var>'s <a href="#explicitly-set-attr-elements" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-elements-2">explicitly set <var>attr</var>-elements</a>:</p>

        <ol><li><p>If <var>attrElement</var> is not a <a id="reflecting-content-attributes-in-idl-attributes:descendant-2" href="https://dom.spec.whatwg.org/#concept-tree-descendant" data-x-internal="descendant">descendant</a> of any of
         <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-shadow-including-ancestor" id="reflecting-content-attributes-in-idl-attributes:concept-shadow-including-ancestor-2" data-x-internal="concept-shadow-including-ancestor">shadow-including
         ancestors</a>, then <a id="reflecting-content-attributes-in-idl-attributes:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="reflecting-content-attributes-in-idl-attributes:list-append" data-x-internal="list-append">Append</a> <var>attrElement</var> to
         <var>elements</var>.</p></li></ol>
       </li></ol>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p>Let <var>contentAttributeValue</var> be the result of running
       <var>reflectedTarget</var>'s <a href="#get-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:get-the-content-attribute-11">get the content attribute</a>.

       </p></li><li><p>If <var>contentAttributeValue</var> is null, then return null.</p></li><li><p>Let <var>tokens</var> be <var>contentAttributeValue</var>, <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="reflecting-content-attributes-in-idl-attributes:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">split on ASCII whitespace</a>.

       </p></li><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="reflecting-content-attributes-in-idl-attributes:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>id</var> of <var>tokens</var>:</p>

        <ol><li>
          <p>Let <var>candidate</var> be the first element, in <a id="reflecting-content-attributes-in-idl-attributes:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, that meets
          the following criteria:</p>

          <ul><li><p><var>candidate</var>'s <a id="reflecting-content-attributes-in-idl-attributes:root-3" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> is the same as <var>element</var>'s
           <a id="reflecting-content-attributes-in-idl-attributes:root-4" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>;</p></li><li><p><var>candidate</var>'s <a href="https://dom.spec.whatwg.org/#concept-id" id="reflecting-content-attributes-in-idl-attributes:concept-id-2" data-x-internal="concept-id">ID</a> is <var>id</var>;
           and</p></li><li><p><var>candidate</var> <a id="reflecting-content-attributes-in-idl-attributes:implements-2" href="https://webidl.spec.whatwg.org/#implements" data-x-internal="implements">implements</a> <var>T</var>.</p></li></ul>

          <p>If no such element exists, then <a id="reflecting-content-attributes-in-idl-attributes:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p>
         </li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="reflecting-content-attributes-in-idl-attributes:list-append-2" data-x-internal="list-append">Append</a> <var>candidate</var> to
         <var>elements</var>.</p></li></ol>
       </li></ol>
     </li><li><p>Return <var>elements</var>.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>The getter steps are:</p>

    <ol><li><p>Let <var>elements</var> be the result of running <a id="reflecting-content-attributes-in-idl-attributes:this-26" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#attr-associated-elements" id="reflecting-content-attributes-in-idl-attributes:attr-associated-elements">get the
     <var>attr</var>-associated elements</a>.</p></li><li><p>If the contents of <var>elements</var> is equal to the contents of <a id="reflecting-content-attributes-in-idl-attributes:this-27" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
     <a href="#cached-attr-associated-elements" id="reflecting-content-attributes-in-idl-attributes:cached-attr-associated-elements">cached <var>attr</var>-associated elements</a>, then return <a id="reflecting-content-attributes-in-idl-attributes:this-28" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
     <a href="#cached-attr-associated-elements-object" id="reflecting-content-attributes-in-idl-attributes:cached-attr-associated-elements-object">cached <var>attr</var>-associated elements object</a>.</p></li><li><p>Let <var>elementsAsFrozenArray</var> be <var>elements</var>, <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="reflecting-content-attributes-in-idl-attributes:concept-idl-convert" data-x-internal="concept-idl-convert">converted</a> to a <code>FrozenArray&lt;<var>T</var>&gt;?</code>.</p></li><li><p>Set <a id="reflecting-content-attributes-in-idl-attributes:this-29" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#cached-attr-associated-elements" id="reflecting-content-attributes-in-idl-attributes:cached-attr-associated-elements-2">cached <var>attr</var>-associated elements</a> to
     <var>elements</var>.</p></li><li><p>Set <a id="reflecting-content-attributes-in-idl-attributes:this-30" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#cached-attr-associated-elements-object" id="reflecting-content-attributes-in-idl-attributes:cached-attr-associated-elements-object-2">cached <var>attr</var>-associated elements object</a>
     to <var>elementsAsFrozenArray</var>.</p></li><li><p>Return <var>elementsAsFrozenArray</var>.</p></li></ol>
    </div>

    <p class="note">This extra caching layer is necessary to preserve the invariant that <code>element.reflectedElements === element.reflectedElements</code>.</p>
   </li><li>
    <div data-algorithm="">
    <p>The setter steps are:</p>
    <ol><li>
      <p>If the given value is null:</p>

      <ol><li><p>Set <a id="reflecting-content-attributes-in-idl-attributes:this-31" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#explicitly-set-attr-elements" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-elements-3">explicitly set <var>attr</var>-elements</a> to
       null.</p></li><li><p>Run <a id="reflecting-content-attributes-in-idl-attributes:this-32" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#delete-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:delete-the-content-attribute-6">delete the content attribute</a>.</p></li><li><p>Return.</p></li></ol>
     </li><li><p>Run <a id="reflecting-content-attributes-in-idl-attributes:this-33" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#set-the-content-attribute" id="reflecting-content-attributes-in-idl-attributes:set-the-content-attribute-11">set the content attribute</a> with the empty
     string.</p></li><li><p>Let <var>elements</var> be an empty <a id="reflecting-content-attributes-in-idl-attributes:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="reflecting-content-attributes-in-idl-attributes:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>element</var> in the given value:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="reflecting-content-attributes-in-idl-attributes:list-append-3" data-x-internal="list-append">Append</a> a weak reference to <var>element</var> to
       <var>elements</var>.</p></li></ol>
     </li><li><p>Set <a id="reflecting-content-attributes-in-idl-attributes:this-34" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#explicitly-set-attr-elements" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-elements-4">explicitly set <var>attr</var>-elements</a> to
     <var>elements</var>.</p></li></ol>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>For element <a href="#reflected-target" id="reflecting-content-attributes-in-idl-attributes:reflected-target-16">reflected targets</a> only: the following
    <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="reflecting-content-attributes-in-idl-attributes:concept-element-attributes-change-ext-2" data-x-internal="concept-element-attributes-change-ext">attribute change steps</a>, given
    <var>element</var>, <var>localName</var>, <var>oldValue</var>, <var>value</var>, and
    <var>namespace</var>, are used to synchronize between the content attribute and the IDL
    attribute:</p>

    <ol><li><p>If <var>localName</var> is not <var>attr</var> or <var>namespace</var> is not null, then
     return.</p></li><li><p>Set <var>element</var>'s <a href="#explicitly-set-attr-elements" id="reflecting-content-attributes-in-idl-attributes:explicitly-set-attr-elements-5">explicitly set <var>attr</var>-elements</a> to
     null.</p></li></ol>
    </div>
   </li></ul>
  </div>

  <p class="note"><a href="#reflected-idl-attribute" id="reflecting-content-attributes-in-idl-attributes:reflected-idl-attribute-32">Reflected IDL attributes</a> of this
  type are strongly encouraged to have their identifier end in "<code>Elements</code>" for
  consistency.</p>

  <h4 id="using-reflect-via-idl-extended-attributes"><span class="secno">2.6.2</span> Using reflect via IDL extended attributes<a href="#using-reflect-via-idl-extended-attributes" class="self-link"></a></h4>

  <p><a href="#reflect" id="using-reflect-via-idl-extended-attributes:reflect">Reflection</a> can be used from IDL through <a href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" id="using-reflect-via-idl-extended-attributes:extended-attribute" data-x-internal="extended-attribute">extended attributes</a>. <dfn id="xattr-reflect" data-dfn-type="extended-attribute" data-lt="Reflect"><code>[Reflect]</code></dfn>, <dfn id="xattr-reflectsetter" data-dfn-type="extended-attribute" data-lt="ReflectSetter"><code>[ReflectSetter]</code></dfn>, <dfn id="xattr-reflecturl" data-dfn-type="extended-attribute" data-lt="ReflectURL"><code>[ReflectURL]</code></dfn>,
  <dfn id="xattr-reflectnonnegative" data-dfn-type="extended-attribute" data-lt="ReflectNonNegative"><code>[ReflectNonNegative]</code></dfn>, <dfn id="xattr-reflectpositive" data-dfn-type="extended-attribute" data-lt="ReflectPositive"><code>[ReflectPositive]</code></dfn>, and
  <dfn id="xattr-reflectpositivewithfallback" data-dfn-type="extended-attribute" data-lt="ReflectPositiveWithFallback"><code>[ReflectPositiveWithFallback]</code></dfn> all
  trigger <a href="#reflect" id="using-reflect-via-idl-extended-attributes:reflect-2">reflection</a>. These must either take no arguments, or take a
  string; they must not appear on anything other than an interface member attribute; and only one of
  these can be used at a time.</p>

  <p>For one of these primary reflection <a href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" id="using-reflect-via-idl-extended-attributes:extended-attribute-2" data-x-internal="extended-attribute">extended
  attributes</a>, its <a href="#reflected-content-attribute-name" id="using-reflect-via-idl-extended-attributes:reflected-content-attribute-name">reflected content attribute name</a> is the string value it takes,
  if one is provided; otherwise it is the IDL attribute name <a id="using-reflect-via-idl-extended-attributes:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
  lowercase</a>.</p>

  <p>IDL attributes with the <code id="using-reflect-via-idl-extended-attributes:xattr-reflect"><a href="#xattr-reflect">[Reflect]</a></code> <a id="using-reflect-via-idl-extended-attributes:extended-attribute-3" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended
  attribute</a> must <a href="#reflect" id="using-reflect-via-idl-extended-attributes:reflect-3">reflect</a> <code id="using-reflect-via-idl-extended-attributes:xattr-reflect-2"><a href="#xattr-reflect">[Reflect]</a></code>'s
  <a href="#reflected-content-attribute-name" id="using-reflect-via-idl-extended-attributes:reflected-content-attribute-name-2">reflected content attribute name</a>.</p>

  <p>IDL attributes with the <code id="using-reflect-via-idl-extended-attributes:xattr-reflectsetter"><a href="#xattr-reflectsetter">[ReflectSetter]</a></code>
  <a id="using-reflect-via-idl-extended-attributes:extended-attribute-4" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a> on setting must <a href="#reflect" id="using-reflect-via-idl-extended-attributes:reflect-4">reflect</a> <code id="using-reflect-via-idl-extended-attributes:xattr-reflectsetter-2"><a href="#xattr-reflectsetter">[ReflectSetter]</a></code>'s <a href="#reflected-content-attribute-name" id="using-reflect-via-idl-extended-attributes:reflected-content-attribute-name-3">reflected content attribute
  name</a>.</p>

  <p>The <code id="using-reflect-via-idl-extended-attributes:xattr-reflecturl"><a href="#xattr-reflecturl">[ReflectURL]</a></code> <a id="using-reflect-via-idl-extended-attributes:extended-attribute-5" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a> must
  only appear on attributes with a type of <code id="using-reflect-via-idl-extended-attributes:idl-usvstring"><a data-x-internal="idl-usvstring" href="https://webidl.spec.whatwg.org/#idl-USVString">USVString</a></code>.</p>

  <p>IDL attributes with the <code id="using-reflect-via-idl-extended-attributes:xattr-reflecturl-2"><a href="#xattr-reflecturl">[ReflectURL]</a></code> <a id="using-reflect-via-idl-extended-attributes:extended-attribute-6" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended
  attribute</a> must <a href="#reflect" id="using-reflect-via-idl-extended-attributes:reflect-5">reflect</a>, <a href="#treated-as-a-url" id="using-reflect-via-idl-extended-attributes:treated-as-a-url">as a URL</a>, <code id="using-reflect-via-idl-extended-attributes:xattr-reflecturl-3"><a href="#xattr-reflecturl">[ReflectURL]</a></code>'s <a href="#reflected-content-attribute-name" id="using-reflect-via-idl-extended-attributes:reflected-content-attribute-name-4">reflected content attribute name</a>.</p>

  <p>The <code id="using-reflect-via-idl-extended-attributes:xattr-reflectnonnegative"><a href="#xattr-reflectnonnegative">[ReflectNonNegative]</a></code> <a id="using-reflect-via-idl-extended-attributes:extended-attribute-7" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended
  attribute</a> must only appear on attributes with a type of <code id="using-reflect-via-idl-extended-attributes:idl-long"><a data-x-internal="idl-long" href="https://webidl.spec.whatwg.org/#idl-long">long</a></code>.</p>

  <p>IDL attributes with the <code id="using-reflect-via-idl-extended-attributes:xattr-reflectnonnegative-2"><a href="#xattr-reflectnonnegative">[ReflectNonNegative]</a></code>
  <a id="using-reflect-via-idl-extended-attributes:extended-attribute-8" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a> must <a href="#reflect" id="using-reflect-via-idl-extended-attributes:reflect-6">reflect</a>, <a href="#limited-to-only-non-negative-numbers" id="using-reflect-via-idl-extended-attributes:limited-to-only-non-negative-numbers">limited to only non-negative
  numbers</a>, <code id="using-reflect-via-idl-extended-attributes:xattr-reflectnonnegative-3"><a href="#xattr-reflectnonnegative">[ReflectNonNegative]</a></code>'s
  <a href="#reflected-content-attribute-name" id="using-reflect-via-idl-extended-attributes:reflected-content-attribute-name-5">reflected content attribute name</a>.</p>

  <p>The <code id="using-reflect-via-idl-extended-attributes:xattr-reflectpositive"><a href="#xattr-reflectpositive">[ReflectPositive]</a></code> and <code id="using-reflect-via-idl-extended-attributes:xattr-reflectpositivewithfallback"><a href="#xattr-reflectpositivewithfallback">[ReflectPositiveWithFallback]</a></code> <a href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" id="using-reflect-via-idl-extended-attributes:extended-attribute-9" data-x-internal="extended-attribute">extended attributes</a> must only appear on attributes with a type
  of <code id="using-reflect-via-idl-extended-attributes:idl-double"><a data-x-internal="idl-double" href="https://webidl.spec.whatwg.org/#idl-double">double</a></code> or <code id="using-reflect-via-idl-extended-attributes:idl-unsigned-long"><a data-x-internal="idl-unsigned-long" href="https://webidl.spec.whatwg.org/#idl-unsigned-long">unsigned
  long</a></code>.</p>

  <p>IDL attributes with the <code id="using-reflect-via-idl-extended-attributes:xattr-reflectpositive-2"><a href="#xattr-reflectpositive">[ReflectPositive]</a></code>
  <a id="using-reflect-via-idl-extended-attributes:extended-attribute-10" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a> must <a href="#reflect" id="using-reflect-via-idl-extended-attributes:reflect-7">reflect</a>, <a href="#limited-to-only-non-negative-numbers-greater-than-zero" id="using-reflect-via-idl-extended-attributes:limited-to-only-non-negative-numbers-greater-than-zero">limited to only positive
  numbers</a>, <code id="using-reflect-via-idl-extended-attributes:xattr-reflectpositive-3"><a href="#xattr-reflectpositive">[ReflectPositive]</a></code>'s <a href="#reflected-content-attribute-name" id="using-reflect-via-idl-extended-attributes:reflected-content-attribute-name-6">reflected
  content attribute name</a>.</p>

  <p>IDL attributes with the <code id="using-reflect-via-idl-extended-attributes:xattr-reflectpositivewithfallback-2"><a href="#xattr-reflectpositivewithfallback">[ReflectPositiveWithFallback]</a></code> <a id="using-reflect-via-idl-extended-attributes:extended-attribute-11" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended
  attribute</a> must <a href="#reflect" id="using-reflect-via-idl-extended-attributes:reflect-8">reflect</a>, <a href="#limited-to-only-non-negative-numbers-greater-than-zero-with-fallback" id="using-reflect-via-idl-extended-attributes:limited-to-only-non-negative-numbers-greater-than-zero-with-fallback">limited to only positive numbers with
  fallback</a>, <code id="using-reflect-via-idl-extended-attributes:xattr-reflectpositivewithfallback-3"><a href="#xattr-reflectpositivewithfallback">[ReflectPositiveWithFallback]</a></code>'s <a href="#reflected-content-attribute-name" id="using-reflect-via-idl-extended-attributes:reflected-content-attribute-name-7">reflected
  content attribute name</a>.</p>

  <hr>

  <p>To supplement the above <a href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" id="using-reflect-via-idl-extended-attributes:extended-attribute-12" data-x-internal="extended-attribute">extended attributes</a> we also
  introduce <dfn id="xattr-reflectrange" data-dfn-type="extended-attribute" data-lt="ReflectRange"><code>[ReflectRange]</code></dfn>, and <dfn id="xattr-reflectdefault" data-dfn-type="extended-attribute" data-lt="ReflectDefault"><code>[ReflectDefault]</code></dfn>. These
  augment how <a href="#reflect" id="using-reflect-via-idl-extended-attributes:reflect-9">reflection</a> works and also must only appear on interface
  member attributes.</p>

  <p>The <code id="using-reflect-via-idl-extended-attributes:xattr-reflectrange"><a href="#xattr-reflectrange">[ReflectRange]</a></code> <a id="using-reflect-via-idl-extended-attributes:extended-attribute-13" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a>
  must take an integer list limited to two values. It must only be used on attributes with a type of
  <code id="using-reflect-via-idl-extended-attributes:idl-unsigned-long-2"><a data-x-internal="idl-unsigned-long" href="https://webidl.spec.whatwg.org/#idl-unsigned-long">unsigned long</a></code>. Additionally, it must also only appear
  alongside <code id="using-reflect-via-idl-extended-attributes:xattr-reflect-3"><a href="#xattr-reflect">[Reflect]</a></code>.</p>

  <p data-var-scope="">IDL attributes with the <code id="using-reflect-via-idl-extended-attributes:xattr-reflectrange-2"><a href="#xattr-reflectrange">[ReflectRange]</a></code> <a id="using-reflect-via-idl-extended-attributes:extended-attribute-14" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended
  attribute</a> are <a href="#clamped-to-the-range" id="using-reflect-via-idl-extended-attributes:clamped-to-the-range">clamped to the range</a> [<var>clampedMin</var>,
  <var>clampedMax</var>] where <var>clampedMin</var> is the first, and <var>clampedMax</var> is the
  second argument to the list provided to <code id="using-reflect-via-idl-extended-attributes:xattr-reflectrange-3"><a href="#xattr-reflectrange">[ReflectRange]</a></code>.</p>

  <p>The <code id="using-reflect-via-idl-extended-attributes:xattr-reflectdefault"><a href="#xattr-reflectdefault">[ReflectDefault]</a></code> <a id="using-reflect-via-idl-extended-attributes:extended-attribute-15" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a>
  must only be used on attributes with a type of <code id="using-reflect-via-idl-extended-attributes:idl-double-2"><a data-x-internal="idl-double" href="https://webidl.spec.whatwg.org/#idl-double">double</a></code>, <code id="using-reflect-via-idl-extended-attributes:idl-long-2"><a data-x-internal="idl-long" href="https://webidl.spec.whatwg.org/#idl-long">long</a></code>, or <code id="using-reflect-via-idl-extended-attributes:idl-unsigned-long-3"><a data-x-internal="idl-unsigned-long" href="https://webidl.spec.whatwg.org/#idl-unsigned-long">unsigned long</a></code>. When used
  on an attribute of type <code id="using-reflect-via-idl-extended-attributes:idl-double-3"><a data-x-internal="idl-double" href="https://webidl.spec.whatwg.org/#idl-double">double</a></code>, it must take a decimal; otherwise
  it must take an integer. Additionally, it must also only appear alongside <code id="using-reflect-via-idl-extended-attributes:xattr-reflect-4"><a href="#xattr-reflect">[Reflect]</a></code>, <code id="using-reflect-via-idl-extended-attributes:xattr-reflectnonnegative-4"><a href="#xattr-reflectnonnegative">[ReflectNonNegative]</a></code>, <code id="using-reflect-via-idl-extended-attributes:xattr-reflectpositive-4"><a href="#xattr-reflectpositive">[ReflectPositive]</a></code>, or <code id="using-reflect-via-idl-extended-attributes:xattr-reflectpositivewithfallback-4"><a href="#xattr-reflectpositivewithfallback">[ReflectPositiveWithFallback]</a></code>.</p>

  <p>IDL attributes with the <code id="using-reflect-via-idl-extended-attributes:xattr-reflectdefault-2"><a href="#xattr-reflectdefault">[ReflectDefault]</a></code>
  <a id="using-reflect-via-idl-extended-attributes:extended-attribute-16" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a> have a <a href="#default-value" id="using-reflect-via-idl-extended-attributes:default-value">default value</a> provided by the argument
  provided to <code id="using-reflect-via-idl-extended-attributes:xattr-reflectdefault-3"><a href="#xattr-reflectdefault">[ReflectDefault]</a></code>.</p>

  <h4 id="using-reflect-in-specifications"><span class="secno">2.6.3</span> Using reflect in specifications<a href="#using-reflect-in-specifications" class="self-link"></a></h4>

  <p><a href="#reflect" id="using-reflect-in-specifications:reflect">Reflection</a> is primarily about improving web developer ergonomics
  by giving them typed access to content attributes through <a href="#reflected-idl-attribute" id="using-reflect-in-specifications:reflected-idl-attribute">reflected IDL attributes</a>. The ultimate source of truth, which the web platform
  builds upon, is the content attributes themselves. That is, specification authors must not use the
  <a href="#reflected-idl-attribute" id="using-reflect-in-specifications:reflected-idl-attribute-2">reflected IDL attribute</a> getter or setter steps, but instead must use the content
  attribute presence and value. (Or an abstraction on top, such as the state of an <a href="#enumerated-attribute" id="using-reflect-in-specifications:enumerated-attribute">enumerated
  attribute</a>.)</p>

  <p>Two important exceptions to this are <a href="#reflected-idl-attribute" id="using-reflect-in-specifications:reflected-idl-attribute-3">reflected IDL
  attributes</a> whose type is one of the following:</p>

  <ul><li><p data-var-scope=""><code><var>T</var>?</code>, where <var>T</var> is either <code id="using-reflect-in-specifications:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or
   an interface that inherits from <code id="using-reflect-in-specifications:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code></p></li><li><p data-var-scope=""><code>FrozenArray&lt;<var>T</var>&gt;?</code>, where <var>T</var> is either
   <code id="using-reflect-in-specifications:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or an interface that inherits from <code id="using-reflect-in-specifications:element-4"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code></p></li></ul>

  <p data-var-scope="">For those, specification authors must use the <a href="#reflected-target" id="using-reflect-in-specifications:reflected-target">reflected target</a>'s
  <a href="#attr-associated-element" id="using-reflect-in-specifications:attr-associated-element">get the <var>attr</var>-associated element</a> and <a href="#attr-associated-elements" id="using-reflect-in-specifications:attr-associated-elements">get the
  <var>attr</var>-associated elements</a>, respectively. The content attribute presence and value
  must not be used as they cannot be fully synchronized with the <a href="#reflected-idl-attribute" id="using-reflect-in-specifications:reflected-idl-attribute-4">reflected IDL
  attribute</a>.</p>

  <p data-var-scope="">A <a href="#reflected-target" id="using-reflect-in-specifications:reflected-target-2">reflected target</a>'s <a href="#explicitly-set-attr-element" id="using-reflect-in-specifications:explicitly-set-attr-element">explicitly set <var>attr</var>-element</a>,
  <a href="#explicitly-set-attr-elements" id="using-reflect-in-specifications:explicitly-set-attr-elements">explicitly set <var>attr</var>-elements</a>, <a href="#cached-attr-associated-elements" id="using-reflect-in-specifications:cached-attr-associated-elements">cached <var>attr</var>-associated
  elements</a>, and <a href="#cached-attr-associated-elements-object" id="using-reflect-in-specifications:cached-attr-associated-elements-object">cached <var>attr</var>-associated elements object</a> are to be
  treated as internal implementation details and not to be built upon.</p>

  

  <h4 id="collections"><span class="secno">2.6.4</span> Collections<a href="#collections" class="self-link"></a></h4>

  <p>The <code id="collections:htmlformcontrolscollection"><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code> and <code id="collections:htmloptionscollection"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> interfaces
  are <a href="https://dom.spec.whatwg.org/#concept-collection" id="collections:concept-collection" data-x-internal="concept-collection">collections</a> derived from the
  <code id="collections:htmlcollection"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> interface. The <code id="collections:htmlallcollection"><a href="#htmlallcollection">HTMLAllCollection</a></code> interface is a <a href="https://dom.spec.whatwg.org/#concept-collection" id="collections:concept-collection-2" data-x-internal="concept-collection">collection</a>, but is not so derived.</p>


  <h5 id="the-htmlallcollection-interface"><span class="secno">2.6.4.1</span> The <code id="the-htmlallcollection-interface:htmlallcollection"><a href="#htmlallcollection">HTMLAllCollection</a></code> interface<a href="#the-htmlallcollection-interface" class="self-link"></a></h5>

  <p>The <code id="the-htmlallcollection-interface:htmlallcollection-2"><a href="#htmlallcollection">HTMLAllCollection</a></code> interface is used for the legacy <code id="the-htmlallcollection-interface:dom-document-all"><a href="#dom-document-all">document.all</a></code> attribute. It operates similarly to
  <code id="the-htmlallcollection-interface:htmlcollection"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code>; the main differences are that it allows a staggering variety of
  different (ab)uses of its methods to all end up returning something, and that it can be called as
  a function as an alternative to property access.</p>

  <p class="note">All <code id="the-htmlallcollection-interface:htmlallcollection-3"><a href="#htmlallcollection">HTMLAllCollection</a></code> objects are rooted at a <code id="the-htmlallcollection-interface:document"><a href="#document">Document</a></code>
  and have a filter that matches all elements, so the elements <a id="the-htmlallcollection-interface:represented-by-the-collection" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the
  collection</a> of an <code id="the-htmlallcollection-interface:htmlallcollection-4"><a href="#htmlallcollection">HTMLAllCollection</a></code> object consist of all the descendant
  elements of the root <code id="the-htmlallcollection-interface:document-2"><a href="#document">Document</a></code>.</p>

  <p>Objects that implement the <code id="the-htmlallcollection-interface:htmlallcollection-5"><a href="#htmlallcollection">HTMLAllCollection</a></code> interface are <a href="https://webidl.spec.whatwg.org/#dfn-legacy-platform-object" id="the-htmlallcollection-interface:legacy-platform-object" data-x-internal="legacy-platform-object">legacy platform objects</a> with an additional [[Call]] internal
  method described in the <a href="#HTMLAllCollection-call">section below</a>. They also have an
  <a id="the-htmlallcollection-interface:ishtmldda" href="https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot" data-x-internal="ishtmldda">[[IsHTMLDDA]]</a> internal slot.</p>

  <div class="note">
   <p>Objects that implement the <code id="the-htmlallcollection-interface:htmlallcollection-6"><a href="#htmlallcollection">HTMLAllCollection</a></code> interface have several unusual
   behaviors, due of the fact that they have an <a id="the-htmlallcollection-interface:ishtmldda-2" href="https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot" data-x-internal="ishtmldda">[[IsHTMLDDA]]</a> internal slot:</p>

   <ul><li><p>The <a href="https://tc39.es/ecma262/#sec-toboolean" id="the-htmlallcollection-interface:js-toboolean" data-x-internal="js-toboolean">ToBoolean</a> abstract operation in JavaScript returns
    false when given objects implementing the <code id="the-htmlallcollection-interface:htmlallcollection-7"><a href="#htmlallcollection">HTMLAllCollection</a></code> interface.</p></li><li><p>The <a href="https://tc39.es/ecma262/#sec-islooselyequal" id="the-htmlallcollection-interface:js-abstract-equality" data-x-internal="js-abstract-equality">IsLooselyEqual</a> abstract operation,
    when given objects implementing the <code id="the-htmlallcollection-interface:htmlallcollection-8"><a href="#htmlallcollection">HTMLAllCollection</a></code> interface, returns true when
    compared to the <code>undefined</code> and <code>null</code> values.
    (Comparisons using the <a href="https://tc39.es/ecma262/#sec-isstrictlyequal" id="the-htmlallcollection-interface:js-strict-equality" data-x-internal="js-strict-equality">IsStrictlyEqual</a> abstract
    operation, and IsLooselyEqual comparisons to other values such as strings or objects, are
    unaffected.)</p></li><li><p>The <code id="the-htmlallcollection-interface:js-typeof"><a data-x-internal="js-typeof" href="https://tc39.es/ecma262/#sec-typeof-operator">typeof</a></code> operator in JavaScript returns the string
    <code>"undefined"</code> when applied to objects implementing the
    <code id="the-htmlallcollection-interface:htmlallcollection-9"><a href="#htmlallcollection">HTMLAllCollection</a></code> interface.</p></li></ul>

   <p>These special behaviors are motivated by a desire for compatibility with two classes of legacy
   content: one that uses the presence of <code id="the-htmlallcollection-interface:dom-document-all-2"><a href="#dom-document-all">document.all</a></code> as a
   way to detect legacy user agents, and one that only supports those legacy user agents and uses
   the <code id="the-htmlallcollection-interface:dom-document-all-3"><a href="#dom-document-all">document.all</a></code> object without testing for its presence
   first. <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>
  </div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="the-htmlallcollection-interface:legacyunenumerablenamedproperties" href="https://webidl.spec.whatwg.org/#LegacyUnenumerableNamedProperties" data-x-internal="legacyunenumerablenamedproperties"><c- g="">LegacyUnenumerableNamedProperties</c-></a>]
<c- b="">interface</c-> <dfn id="htmlallcollection" data-dfn-type="interface"><c- g="">HTMLAllCollection</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-htmlallcollection-length" id="the-htmlallcollection-interface:dom-htmlallcollection-length"><c- g="">length</c-></a>;
  <c- b="">getter</c-> <a id="the-htmlallcollection-interface:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a> (<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <c- b="">getter</c-> (<a id="the-htmlallcollection-interface:htmlcollection-2" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <c- b="">or</c-> <a id="the-htmlallcollection-interface:element-2" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a>)? <a href="#dom-htmlallcollection-nameditem" id="the-htmlallcollection-interface:dom-htmlallcollection-nameditem"><c- g="">namedItem</c-></a>(<c- b="">DOMString</c-> <c- g="">name</c->);
  (<a id="the-htmlallcollection-interface:htmlcollection-3" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <c- b="">or</c-> <a id="the-htmlallcollection-interface:element-3" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a>)? <a href="#dom-htmlallcollection-item" id="the-htmlallcollection-interface:dom-htmlallcollection-item"><c- g="">item</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">nameOrIndex</c->);

  // Note: HTMLAllCollection objects have a <a href="#HTMLAllCollection-call">custom [[Call]] internal method</a> and an <a id="the-htmlallcollection-interface:ishtmldda-3" href="https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot" data-x-internal="ishtmldda">[[IsHTMLDDA]]</a> internal slot.
};</code></pre>

  

  <div data-algorithm="">
  <p>The object's <a id="the-htmlallcollection-interface:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> are as defined for
  <code id="the-htmlallcollection-interface:htmlcollection-4"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> objects.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-htmlallcollection-interface:supported-property-names" href="https://webidl.spec.whatwg.org/#dfn-supported-property-names" data-x-internal="supported-property-names">supported property names</a> consist of the non-empty values of all the <code id="the-htmlallcollection-interface:the-id-attribute"><a href="#the-id-attribute">id</a></code> attributes of all the elements <a id="the-htmlallcollection-interface:represented-by-the-collection-2" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the
  collection</a>, and the non-empty values of all the <code>name</code> attributes of
  all the <a href="#all-named-elements" id="the-htmlallcollection-interface:all-named-elements">"all"-named elements</a> <a id="the-htmlallcollection-interface:represented-by-the-collection-3" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the collection</a>, in
  <a id="the-htmlallcollection-interface:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, ignoring later duplicates, with the <code id="the-htmlallcollection-interface:the-id-attribute-2"><a href="#the-id-attribute">id</a></code> of
  an element preceding its <code>name</code> if it contributes both, they differ from
  each other, and neither is the duplicate of an earlier entry.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLAllCollection" id="dom-htmlallcollection-length" data-dfn-type="attribute"><code>length</code></dfn> getter steps are to return the number
  of nodes <a id="the-htmlallcollection-interface:represented-by-the-collection-4" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the collection</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The indexed property getter must return the result of <a href="#concept-get-all-indexed" id="the-htmlallcollection-interface:concept-get-all-indexed">getting the "all"-indexed element</a> from <a id="the-htmlallcollection-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>
  given the passed index.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLAllCollection" id="dom-htmlallcollection-nameditem" data-dfn-type="method"><code>namedItem(<var>name</var>)</code></dfn> method steps are
  to return the result of <a href="#concept-get-all-named" id="the-htmlallcollection-interface:concept-get-all-named">getting the "all"-named
  element(s)</a> from <a id="the-htmlallcollection-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> given <var>name</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLAllCollection" id="dom-htmlallcollection-item" data-dfn-type="method"><code>item(<var>nameOrIndex</var>)</code></dfn> method steps
  are:</p>

  <ol><li><p>If <var>nameOrIndex</var> was not provided, return null.</p></li><li><p>Return the result of <a href="#concept-get-all-indexed-or-named" id="the-htmlallcollection-interface:concept-get-all-indexed-or-named">getting the
   "all"-indexed or named element(s)</a> from <a id="the-htmlallcollection-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, given
   <var>nameOrIndex</var>.</p></li></ol>
  </div>

  <hr>

  
  <div data-algorithm="">
  <p>The following elements are <dfn id="all-named-elements">"all"-named elements</dfn>:
   <code id="the-htmlallcollection-interface:the-a-element"><a href="#the-a-element">a</a></code>,
   <code id="the-htmlallcollection-interface:the-button-element"><a href="#the-button-element">button</a></code>,
   <code id="the-htmlallcollection-interface:the-embed-element"><a href="#the-embed-element">embed</a></code>,
   <code id="the-htmlallcollection-interface:the-form-element"><a href="#the-form-element">form</a></code>,
   <code id="the-htmlallcollection-interface:frame"><a href="#frame">frame</a></code>,
   <code id="the-htmlallcollection-interface:frameset"><a href="#frameset">frameset</a></code>,
   <code id="the-htmlallcollection-interface:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>,
   <code id="the-htmlallcollection-interface:the-img-element"><a href="#the-img-element">img</a></code>,
   <code id="the-htmlallcollection-interface:the-input-element"><a href="#the-input-element">input</a></code>,
   <code id="the-htmlallcollection-interface:the-map-element"><a href="#the-map-element">map</a></code>,
   <code id="the-htmlallcollection-interface:the-meta-element"><a href="#the-meta-element">meta</a></code>,
   <code id="the-htmlallcollection-interface:the-object-element"><a href="#the-object-element">object</a></code>,
   <code id="the-htmlallcollection-interface:the-select-element"><a href="#the-select-element">select</a></code>, and
   <code id="the-htmlallcollection-interface:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>
  </p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="concept-get-all-indexed">get the "all"-indexed element</dfn> from an
  <code id="the-htmlallcollection-interface:htmlallcollection-10"><a href="#htmlallcollection">HTMLAllCollection</a></code> <var>collection</var> given an index <var>index</var>, return the
  <var>index</var><sup>th</sup> element in <var>collection</var>, or null if there is no such
  <var>index</var><sup>th</sup> element.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="concept-get-all-named">get the "all"-named element(s)</dfn> from an
  <code id="the-htmlallcollection-interface:htmlallcollection-11"><a href="#htmlallcollection">HTMLAllCollection</a></code> <var>collection</var> given a name <var>name</var>, perform the
  following steps:</p>

  <ol><li><p>If <var>name</var> is the empty string, return null.</p></li><li>
    <p>Let <var>subCollection</var> be an <code id="the-htmlallcollection-interface:htmlcollection-5"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> object rooted at the same
    <code id="the-htmlallcollection-interface:document-3"><a href="#document">Document</a></code> as <var>collection</var>, whose filter matches only elements that are
    either:</p>

    <ul><li><p><a href="#all-named-elements" id="the-htmlallcollection-interface:all-named-elements-2">"all"-named elements</a> with a <code>name</code> attribute equal to
     <var>name</var>, or</p></li><li><p>elements with an <a href="https://dom.spec.whatwg.org/#concept-id" id="the-htmlallcollection-interface:concept-id" data-x-internal="concept-id">ID</a> equal to <var>name</var>.</p></li></ul>
   </li><li><p>If there is exactly one element in <var>subCollection</var>, then return that
   element.</p></li><li><p>Otherwise, if <var>subCollection</var> is empty, return null.</p></li><li><p>Otherwise, return <var>subCollection</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="concept-get-all-indexed-or-named">get the "all"-indexed or named
  element(s)</dfn> from an <code id="the-htmlallcollection-interface:htmlallcollection-12"><a href="#htmlallcollection">HTMLAllCollection</a></code> <var>collection</var> given
  <var>nameOrIndex</var>:

  </p><ol><li><p>If <var>nameOrIndex</var>, <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="the-htmlallcollection-interface:concept-idl-convert" data-x-internal="concept-idl-convert">converted</a> to a
   JavaScript String value, is an <a id="the-htmlallcollection-interface:array-index-property-name" href="https://webidl.spec.whatwg.org/#dfn-array-index-property-name" data-x-internal="array-index-property-name">array index property name</a>, return the result of <a href="#concept-get-all-indexed" id="the-htmlallcollection-interface:concept-get-all-indexed-2">getting the "all"-indexed element</a> from
   <var>collection</var> given the number represented by <var>nameOrIndex</var>.</p></li><li><p>Return the result of <a href="#concept-get-all-named" id="the-htmlallcollection-interface:concept-get-all-named-2">getting the "all"-named
   element(s)</a> from <var>collection</var> given <var>nameOrIndex</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="HTMLAllCollection-call"><span class="secno">2.6.4.1.1</span> [[Call]] ( <var>thisArgument</var>, <var>argumentsList</var> )<a href="#HTMLAllCollection-call" class="self-link"></a></h6>

  <ol><li><p>If <var>argumentsList</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="HTMLAllCollection-call:list-size" data-x-internal="list-size">size</a> is zero, or if
   <var>argumentsList</var>[0] is undefined, return null.</p></li><li><p>Let <var>nameOrIndex</var> be the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="HTMLAllCollection-call:concept-idl-convert" data-x-internal="concept-idl-convert">converting</a> <var>argumentsList</var>[0] to a <code id="HTMLAllCollection-call:idl-domstring"><a data-x-internal="idl-domstring" href="https://webidl.spec.whatwg.org/#idl-DOMString">DOMString</a></code>.</p></li><li><p>Let <var>result</var> be the result of <a href="#concept-get-all-indexed-or-named" id="HTMLAllCollection-call:concept-get-all-indexed-or-named">getting the "all"-indexed or named element(s)</a>
   from this <code id="HTMLAllCollection-call:htmlallcollection"><a href="#htmlallcollection">HTMLAllCollection</a></code> given <var>nameOrIndex</var>.</p></li><li><p>Return the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="HTMLAllCollection-call:concept-idl-convert-2" data-x-internal="concept-idl-convert">converting</a>
   <var>result</var> to an ECMAScript value.</p></li></ol>

  <p class="note">The <var>thisArgument</var> is ignored, and thus code such as <code>Function.prototype.call.call(document.all, null, "x")</code> will still search for
  elements. (<code>document.all.call</code> does not exist, since <code>document.all</code> does not inherit from <code>Function.prototype</code>.)</p>
  </div>

  


  <h5 id="the-htmlformcontrolscollection-interface"><span class="secno">2.6.4.2</span> The <code id="the-htmlformcontrolscollection-interface:htmlformcontrolscollection"><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code> interface<a href="#the-htmlformcontrolscollection-interface" class="self-link"></a></h5>

  <p>The <code id="the-htmlformcontrolscollection-interface:htmlformcontrolscollection-2"><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code> interface is used for
  <a href="https://dom.spec.whatwg.org/#concept-collection" id="the-htmlformcontrolscollection-interface:concept-collection" data-x-internal="concept-collection">collections</a> of <a href="#category-listed" id="the-htmlformcontrolscollection-interface:category-listed">listed
  elements</a> in <code id="the-htmlformcontrolscollection-interface:the-form-element"><a href="#the-form-element">form</a></code> elements.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection" title="The HTMLFormControlsCollection interface represents a collection of HTML form control elements, returned by the HTMLFormElement interface's elements property.">HTMLFormControlsCollection</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/RadioNodeList" title="The RadioNodeList interface represents a collection of radio elements in a <form> or a <fieldset> element.">RadioNodeList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>21+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlformcontrolscollection" data-dfn-type="interface"><c- g="">HTMLFormControlsCollection</c-></dfn> : <a id="the-htmlformcontrolscollection-interface:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> {
  // inherits <a href="https://dom.spec.whatwg.org/#dom-htmlcollection-length" id="the-htmlformcontrolscollection-interface:dom-htmlcollection-length" data-x-internal="dom-htmlcollection-length">length</a> and <a href="https://dom.spec.whatwg.org/#dom-htmlcollection-item" id="the-htmlformcontrolscollection-interface:dom-htmlcollection-item" data-x-internal="dom-htmlcollection-item">item</a>()
  <c- b="">getter</c-> (<a href="#radionodelist" id="the-htmlformcontrolscollection-interface:radionodelist"><c- n="">RadioNodeList</c-></a> <c- b="">or</c-> <a id="the-htmlformcontrolscollection-interface:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a>)? <a href="#dom-htmlformcontrolscollection-nameditem" id="the-htmlformcontrolscollection-interface:dom-htmlformcontrolscollection-nameditem"><c- g="">namedItem</c-></a>(<c- b="">DOMString</c-> <c- g="">name</c->); // shadows inherited <a href="https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem" id="the-htmlformcontrolscollection-interface:dom-htmlcollection-nameditem" data-x-internal="dom-htmlcollection-nameditem">namedItem()</a>
};

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="radionodelist" data-dfn-type="interface"><c- g="">RadioNodeList</c-></dfn> : <a id="the-htmlformcontrolscollection-interface:nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist" data-x-internal="nodelist"><c- n="">NodeList</c-></a> {
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-radionodelist-value" id="the-htmlformcontrolscollection-interface:dom-radionodelist-value"><c- g="">value</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>collection</var>.<a href="https://dom.spec.whatwg.org/#dom-htmlcollection-length" id="dom-htmlcollection-length-dev" data-x-internal="dom-htmlcollection-length">length</a></code></dt><dd><p>Returns the number of elements in <var>collection</var>.</p></dd><dt><code><var>element</var> = <var>collection</var>.<a href="https://dom.spec.whatwg.org/#dom-htmlcollection-item" id="dom-htmlcollection-item-dev" data-x-internal="dom-htmlcollection-item">item</a>(<var>index</var>)</code></dt><dt><code><var>element</var> = <var>collection</var>[<var>index</var>]</code></dt><dd><p>Returns the item at index <var>index</var> in <var>collection</var>. The items are sorted
   in <a id="the-htmlformcontrolscollection-interface:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></dd><dt><code><var>element</var> = <var>collection</var>.<a href="#dom-htmlformcontrolscollection-nameditem" id="dom-htmlformcontrolscollection-nameditem-dev">namedItem</a>(<var>name</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection/namedItem" title="The HTMLFormControlsCollection.namedItem() method returns the RadioNodeList or the Element in the collection whose name or id match the specified name, or null if no node matches.">HTMLFormControlsCollection/namedItem</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>33+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>radioNodeList</var> = <var>collection</var>.<a href="#dom-htmlformcontrolscollection-nameditem" id="the-htmlformcontrolscollection-interface:dom-htmlformcontrolscollection-nameditem-2">namedItem</a>(<var>name</var>)</code></dt><dt><code><var>element</var> = <var>collection</var>[<var>name</var>]</code></dt><dt><code><var>radioNodeList</var> = <var>collection</var>[<var>name</var>]</code></dt><dd>
    <p>Returns the item with <a href="https://dom.spec.whatwg.org/#concept-id" id="the-htmlformcontrolscollection-interface:concept-id" data-x-internal="concept-id">ID</a> or <code id="the-htmlformcontrolscollection-interface:attr-fe-name"><a href="#attr-fe-name">name</a></code> <var>name</var> from <var>collection</var>.</p>

    <p>If there are multiple matching items, then a <code id="the-htmlformcontrolscollection-interface:radionodelist-2"><a href="#radionodelist">RadioNodeList</a></code> object containing all
    those elements is returned.</p>
   </dd><dt><code><var>radioNodeList</var>.<a href="#dom-radionodelist-value" id="dom-radionodelist-value-dev">value</a></code></dt><dd><p>Returns the value of the first checked radio button represented by
   <var>radioNodeList</var>.</p></dd><dt><code><var>radioNodeList</var>.<a href="#dom-radionodelist-value" id="the-htmlformcontrolscollection-interface:dom-radionodelist-value-2">value</a> = <var>value</var></code></dt><dd><p>Checks the first radio button represented by <var>radioNodeList</var> that has value
   <var>value</var>.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The object's <a id="the-htmlformcontrolscollection-interface:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> are as defined for
  <code id="the-htmlformcontrolscollection-interface:htmlcollection-2"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> objects.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-htmlformcontrolscollection-interface:supported-property-names" href="https://webidl.spec.whatwg.org/#dfn-supported-property-names" data-x-internal="supported-property-names">supported property names</a> consist of the non-empty values of all the <code id="the-htmlformcontrolscollection-interface:the-id-attribute"><a href="#the-id-attribute">id</a></code> and <code id="the-htmlformcontrolscollection-interface:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attributes of all the
  elements <a id="the-htmlformcontrolscollection-interface:represented-by-the-collection" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the collection</a>, in <a id="the-htmlformcontrolscollection-interface:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, ignoring later
  duplicates, with the <code id="the-htmlformcontrolscollection-interface:the-id-attribute-2"><a href="#the-id-attribute">id</a></code> of an element preceding its <code id="the-htmlformcontrolscollection-interface:attr-fe-name-3"><a href="#attr-fe-name">name</a></code> if it contributes both, they differ from each other, and neither is the
  duplicate of an earlier entry.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFormControlsCollection" id="dom-htmlformcontrolscollection-nameditem" data-dfn-type="method"><code>namedItem(<var>name</var>)</code></dfn> method
  must act according to the following algorithm:</p>

  <ol><li>If <var>name</var> is the empty string, return null and stop the algorithm.</li><li>If, at the time the method is called, there is exactly one node in the collection that has
   either an <code id="the-htmlformcontrolscollection-interface:the-id-attribute-3"><a href="#the-id-attribute">id</a></code> attribute or a <code id="the-htmlformcontrolscollection-interface:attr-fe-name-4"><a href="#attr-fe-name">name</a></code>
   attribute equal to <var>name</var>, then return that node and stop the algorithm.</li><li>Otherwise, if there are no nodes in the collection that have either an <code id="the-htmlformcontrolscollection-interface:the-id-attribute-4"><a href="#the-id-attribute">id</a></code> attribute or a <code id="the-htmlformcontrolscollection-interface:attr-fe-name-5"><a href="#attr-fe-name">name</a></code> attribute equal
   to <var>name</var>, then return null and stop the algorithm.</li><li>Otherwise, create a new <code id="the-htmlformcontrolscollection-interface:radionodelist-3"><a href="#radionodelist">RadioNodeList</a></code> object representing a <a href="#live" id="the-htmlformcontrolscollection-interface:live">live</a>
   view of the <code id="the-htmlformcontrolscollection-interface:htmlformcontrolscollection-3"><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code> object, further filtered so that the only
   nodes in the <code id="the-htmlformcontrolscollection-interface:radionodelist-4"><a href="#radionodelist">RadioNodeList</a></code> object are those that have either an <code id="the-htmlformcontrolscollection-interface:the-id-attribute-5"><a href="#the-id-attribute">id</a></code> attribute or a <code id="the-htmlformcontrolscollection-interface:attr-fe-name-6"><a href="#attr-fe-name">name</a></code> attribute equal
   to <var>name</var>. The nodes in the <code id="the-htmlformcontrolscollection-interface:radionodelist-5"><a href="#radionodelist">RadioNodeList</a></code> object must be sorted in
   <a id="the-htmlformcontrolscollection-interface:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</li><li>Return that <code id="the-htmlformcontrolscollection-interface:radionodelist-6"><a href="#radionodelist">RadioNodeList</a></code> object.</li></ol>
  </div>

  <hr>

  <p>Members of the <code id="the-htmlformcontrolscollection-interface:radionodelist-7"><a href="#radionodelist">RadioNodeList</a></code> interface inherited from the <code id="the-htmlformcontrolscollection-interface:nodelist-2"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code>
  interface must behave as they would on a <code id="the-htmlformcontrolscollection-interface:nodelist-3"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> object.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/RadioNodeList/value" title="If the underlying element collection contains radio buttons, the RadioNodeList.value property represents the checked radio button. On retrieving the value property, the value of the currently checked radio button is returned as a string. If the collection does not contain any radio buttons or none of the radio buttons in the collection is in checked state, the empty string is returned. On setting the value property, the first radio button input element whose value property is equal to the new value will be set to checked.">RadioNodeList/value</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>21+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="RadioNodeList" id="dom-radionodelist-value" data-dfn-type="attribute"><code>value</code></dfn> IDL attribute on the
  <code id="the-htmlformcontrolscollection-interface:radionodelist-8"><a href="#radionodelist">RadioNodeList</a></code> object, on getting, must return the value returned by running the
  following steps:</p>

  <ol><li><p>Let <var>element</var> be the first element in <a id="the-htmlformcontrolscollection-interface:tree-order-4" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>
   represented by the <code id="the-htmlformcontrolscollection-interface:radionodelist-9"><a href="#radionodelist">RadioNodeList</a></code> object that is an <code id="the-htmlformcontrolscollection-interface:the-input-element"><a href="#the-input-element">input</a></code> element whose
   <code id="the-htmlformcontrolscollection-interface:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#radio-button-state-(type=radio)" id="the-htmlformcontrolscollection-interface:radio-button-state-(type=radio)">Radio Button</a> state and whose <a href="#concept-fe-checked" id="the-htmlformcontrolscollection-interface:concept-fe-checked">checkedness</a> is true. Otherwise, let it be null.</p></li><li><p>If <var>element</var> is null, return the empty string.</p></li><li><p>If <var>element</var> is an element with no <code id="the-htmlformcontrolscollection-interface:attr-input-value"><a href="#attr-input-value">value</a></code> attribute, return the string "<code>on</code>".</p></li><li><p>Otherwise, return the value of <var>element</var>'s <code id="the-htmlformcontrolscollection-interface:attr-input-value-2"><a href="#attr-input-value">value</a></code> attribute.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>On setting, the <code id="the-htmlformcontrolscollection-interface:dom-radionodelist-value-3"><a href="#dom-radionodelist-value">value</a></code> IDL attribute must run the
  following steps:</p>

  <ol><li><p>If the new value is the string "<code>on</code>": let <var>element</var> be the first element in <a id="the-htmlformcontrolscollection-interface:tree-order-5" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>
   represented by the <code id="the-htmlformcontrolscollection-interface:radionodelist-10"><a href="#radionodelist">RadioNodeList</a></code> object that is an <code id="the-htmlformcontrolscollection-interface:the-input-element-2"><a href="#the-input-element">input</a></code> element whose
   <code id="the-htmlformcontrolscollection-interface:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#radio-button-state-(type=radio)" id="the-htmlformcontrolscollection-interface:radio-button-state-(type=radio)-2">Radio Button</a> state and whose <code id="the-htmlformcontrolscollection-interface:attr-input-value-3"><a href="#attr-input-value">value</a></code> content attribute is either absent, or present and equal to the new value, if any. If no such element exists, then instead let <var>element</var> be null.</p>

   <p>Otherwise: let <var>element</var> be the first element in <a id="the-htmlformcontrolscollection-interface:tree-order-6" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>
   represented by the <code id="the-htmlformcontrolscollection-interface:radionodelist-11"><a href="#radionodelist">RadioNodeList</a></code> object that is an <code id="the-htmlformcontrolscollection-interface:the-input-element-3"><a href="#the-input-element">input</a></code> element whose
   <code id="the-htmlformcontrolscollection-interface:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#radio-button-state-(type=radio)" id="the-htmlformcontrolscollection-interface:radio-button-state-(type=radio)-3">Radio Button</a> state and whose <code id="the-htmlformcontrolscollection-interface:attr-input-value-4"><a href="#attr-input-value">value</a></code> content attribute is present and equal to the new value, if
   any. If no such element exists, then instead let <var>element</var> be null.</p></li><li><p>If <var>element</var> is not null, then set its <a href="#concept-fe-checked" id="the-htmlformcontrolscollection-interface:concept-fe-checked-2">checkedness</a> to true.</p>
  </li></ol>
  </div>



  


  <h5 id="the-htmloptionscollection-interface"><span class="secno">2.6.4.3</span> The <code id="the-htmloptionscollection-interface:htmloptionscollection"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> interface<a href="#the-htmloptionscollection-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionsCollection" title="The HTMLOptionsCollection interface represents a collection of <option> HTML elements (in document order) and offers methods and properties for selecting from the list as well as optionally altering its items. This object is returned only by the options property of select.">HTMLOptionsCollection</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <p>The <code id="the-htmloptionscollection-interface:htmloptionscollection-2"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> interface is used for <a href="https://dom.spec.whatwg.org/#concept-collection" id="the-htmloptionscollection-interface:concept-collection" data-x-internal="concept-collection">collections</a> of <code id="the-htmloptionscollection-interface:the-option-element"><a href="#the-option-element">option</a></code> elements. It is always
  rooted on a <code id="the-htmloptionscollection-interface:the-select-element"><a href="#the-select-element">select</a></code> element and has attributes and methods that manipulate that
  element's descendants.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmloptionscollection" data-dfn-type="interface"><c- g="">HTMLOptionsCollection</c-></dfn> : <a id="the-htmloptionscollection-interface:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> {
  // inherits <a href="https://dom.spec.whatwg.org/#dom-htmlcollection-item" id="the-htmloptionscollection-interface:dom-htmlcollection-item" data-x-internal="dom-htmlcollection-item">item</a>(), <a href="https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem" id="the-htmloptionscollection-interface:dom-htmlcollection-nameditem" data-x-internal="dom-htmlcollection-nameditem">namedItem</a>()
  [<a href="#cereactions" id="the-htmloptionscollection-interface:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-htmloptionscollection-length" id="the-htmloptionscollection-interface:dom-htmloptionscollection-length"><c- g="">length</c-></a>; // shadows inherited <a href="https://dom.spec.whatwg.org/#dom-htmlcollection-length" id="the-htmloptionscollection-interface:dom-htmlcollection-length" data-x-internal="dom-htmlcollection-length">length</a>
  [<a href="#cereactions" id="the-htmloptionscollection-interface:cereactions-2"><c- g="">CEReactions</c-></a>] <a href="#dom-htmloptionscollection-setter"><c- b="">setter</c-></a> <c- b="">undefined</c-> (<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->, <a href="#htmloptionelement" id="the-htmloptionscollection-interface:htmloptionelement"><c- n="">HTMLOptionElement</c-></a>? <c- g="">option</c->);
  [<a href="#cereactions" id="the-htmloptionscollection-interface:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-htmloptionscollection-add" id="the-htmloptionscollection-interface:dom-htmloptionscollection-add"><c- g="">add</c-></a>((<a href="#htmloptionelement" id="the-htmloptionscollection-interface:htmloptionelement-2"><c- n="">HTMLOptionElement</c-></a> <c- b="">or</c-> <a href="#htmloptgroupelement" id="the-htmloptionscollection-interface:htmloptgroupelement"><c- n="">HTMLOptGroupElement</c-></a>) <c- g="">element</c->, <c- b="">optional</c-> (<a href="#htmlelement" id="the-htmloptionscollection-interface:htmlelement"><c- n="">HTMLElement</c-></a> <c- b="">or</c-> <c- b="">long</c->)? <c- g="">before</c-> = <c- b="">null</c->);
  [<a href="#cereactions" id="the-htmloptionscollection-interface:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-htmloptionscollection-remove" id="the-htmloptionscollection-interface:dom-htmloptionscollection-remove"><c- g="">remove</c-></a>(<c- b="">long</c-> <c- g="">index</c->);
  <c- b="">attribute</c-> <c- b="">long</c-> <a href="#dom-htmloptionscollection-selectedindex" id="the-htmloptionscollection-interface:dom-htmloptionscollection-selectedindex"><c- g="">selectedIndex</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>collection</var>.<a href="#dom-htmloptionscollection-length" id="dom-htmloptionscollection-length-dev">length</a></code></dt><dd><p>Returns the number of elements in <var>collection</var>.</p></dd><dt><code><var>collection</var>.<a href="#dom-htmloptionscollection-length" id="the-htmloptionscollection-interface:dom-htmloptionscollection-length-2">length</a> = <var>value</var></code></dt><dd>
    <p>When set to a smaller number than the existing length, truncates the number of
    <code id="the-htmloptionscollection-interface:the-option-element-2"><a href="#the-option-element">option</a></code> elements in the container corresponding to <var>collection</var>.</p>

    <p>When set to a greater number than the existing length, if that number is less than or equal
    to 100000, adds new blank <code id="the-htmloptionscollection-interface:the-option-element-3"><a href="#the-option-element">option</a></code> elements to the container corresponding to
    <var>collection</var>.</p>
   </dd><dt><code><var>element</var> = <var>collection</var>.<a href="https://dom.spec.whatwg.org/#dom-htmlcollection-item" id="the-htmloptionscollection-interface:dom-htmlcollection-item-2" data-x-internal="dom-htmlcollection-item">item</a>(<var>index</var>)</code></dt><dt><code><var>element</var> = <var>collection</var>[<var>index</var>]</code></dt><dd><p>Returns the item at index <var>index</var> in <var>collection</var>. The items are sorted
   in <a id="the-htmloptionscollection-interface:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></dd><dt><code><var>collection</var>[<var>index</var>] = <var>element</var></code></dt><dd>
    <p>When <var>index</var> is a greater number than the number of items in <var>collection</var>,
    adds new blank <code id="the-htmloptionscollection-interface:the-option-element-4"><a href="#the-option-element">option</a></code> elements in the corresponding container.</p>

    <p>When set to null, removes the item at index <var>index</var> from <var>collection</var>.</p>

    <p>When set to an <code id="the-htmloptionscollection-interface:the-option-element-5"><a href="#the-option-element">option</a></code> element, adds or replaces it at index <var>index</var> in
    <var>collection</var>.</p>
   </dd><dt><code><var>element</var> = <var>collection</var>.<a href="https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem" id="dom-htmlcollection-nameditem-dev" data-x-internal="dom-htmlcollection-nameditem">namedItem</a>(<var>name</var>)</code></dt><dt><code><var>element</var> = <var>collection</var>[<var>name</var>]</code></dt><dd>
    <p>Returns the item with <a href="https://dom.spec.whatwg.org/#concept-id" id="the-htmloptionscollection-interface:concept-id" data-x-internal="concept-id">ID</a> or <code id="the-htmloptionscollection-interface:attr-option-name"><a href="#attr-option-name">name</a></code> <var>name</var> from <var>collection</var>.</p>

    <p>If there are multiple matching items, then the first is returned.</p>
   </dd><dt><code><var>collection</var>.<a href="#dom-htmloptionscollection-add" id="dom-htmloptionscollection-add-dev">add</a>(<var>element</var>[, <var>before</var>])</code></dt><dd>
    <p>Inserts <var>element</var> before the node given by <var>before</var>.</p>

    <p>The <var>before</var> argument can be a number, in which case <var>element</var> is inserted
    before the item with that number, or an element from <var>collection</var>, in which case
    <var>element</var> is inserted before that element.</p>

    <p>If <var>before</var> is omitted, null, or a number out of range, then <var>element</var> will
    be added at the end of the list.</p>

    <p>Throws a <a id="the-htmloptionscollection-interface:hierarchyrequesterror" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a> <code id="the-htmloptionscollection-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    <var>element</var> is an ancestor of the element into which it is to be inserted.</p>
   </dd><dt><code><var>collection</var>.<a href="#dom-htmloptionscollection-remove" id="dom-htmloptionscollection-remove-dev">remove</a>(<var>index</var>)</code></dt><dd><p>Removes the item with index <var>index</var> from <var>collection</var>.</p></dd><dt><code><var>collection</var>.<a href="#dom-htmloptionscollection-selectedindex" id="the-htmloptionscollection-interface:dom-htmloptionscollection-selectedindex-2">selectedIndex</a></code></dt><dd><p>Returns the index of the first selected item, if any, or −1 if there is no selected
   item.</p></dd><dt><code><var>collection</var>.<a href="#dom-htmloptionscollection-selectedindex" id="dom-htmloptionscollection-selectedindex-dev">selectedIndex</a> = <var>index</var></code></dt><dd><p>Changes the selection to the <code id="the-htmloptionscollection-interface:the-option-element-6"><a href="#the-option-element">option</a></code> element at index <var>index</var> in
   <var>collection</var>.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The object's <a id="the-htmloptionscollection-interface:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> are as defined for
  <code id="the-htmloptionscollection-interface:htmlcollection-2"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> objects.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionsCollection" id="dom-htmloptionscollection-length" data-dfn-type="attribute"><code>length</code></dfn> getter steps are to return the
  number of nodes <a id="the-htmloptionscollection-interface:represented-by-the-collection" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the collection</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-htmloptionscollection-interface:dom-htmloptionscollection-length-3"><a href="#dom-htmloptionscollection-length">length</a></code> setter steps are:</p>

  <ol><li><p>Let <var>current</var> be the number of nodes <a id="the-htmloptionscollection-interface:represented-by-the-collection-2" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the
   collection</a>.</p></li><li>
    <p>If the given value is greater than <var>current</var>, then:</p>

    <ol><li><p>If the given value is greater than 100,000, then return.</p></li><li><p>Let <var>n</var> be <var>value</var> − <var>current</var>.</p></li><li><p>Append <var>n</var> new <code id="the-htmloptionscollection-interface:the-option-element-7"><a href="#the-option-element">option</a></code> elements with no attributes and no child
     nodes to the <code id="the-htmloptionscollection-interface:the-select-element-2"><a href="#the-select-element">select</a></code> element on which <a id="the-htmloptionscollection-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is rooted.</p></li></ol>
   </li><li>
    <p>If the given value is less than <var>current</var>, then:</p>

    <ol><li><p>Let <var>n</var> be <var>current</var> − <var>value</var>.</p></li><li><p>Remove the last <var>n</var> nodes in the collection from their parent nodes.</p></li></ol>
   </li></ol>
  </div>

  <p class="note">Setting <code id="the-htmloptionscollection-interface:dom-htmloptionscollection-length-4"><a href="#dom-htmloptionscollection-length">length</a></code> never removes
  or adds any <code id="the-htmloptionscollection-interface:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> elements, and never adds new children to existing
  <code id="the-htmloptionscollection-interface:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> elements (though it can remove children from them).</p>

  <div data-algorithm="">
  <p>The <a id="the-htmloptionscollection-interface:supported-property-names" href="https://webidl.spec.whatwg.org/#dfn-supported-property-names" data-x-internal="supported-property-names">supported property names</a> consist of the non-empty values of all the <code id="the-htmloptionscollection-interface:the-id-attribute"><a href="#the-id-attribute">id</a></code> and <code id="the-htmloptionscollection-interface:attr-option-name-2"><a href="#attr-option-name">name</a></code> attributes of all the
  elements <a id="the-htmloptionscollection-interface:represented-by-the-collection-3" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the collection</a>, in <a id="the-htmloptionscollection-interface:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, ignoring later
  duplicates, with the <code id="the-htmloptionscollection-interface:the-id-attribute-2"><a href="#the-id-attribute">id</a></code> of an element preceding its <code id="the-htmloptionscollection-interface:attr-option-name-3"><a href="#attr-option-name">name</a></code> if it contributes both, they differ from each other, and neither is
  the duplicate of an earlier entry.</p>
  </div>

  <div data-algorithm="">
  <p id="dom-htmloptionscollection-setter">When the user agent is to <a id="the-htmloptionscollection-interface:set-the-value-of-a-new-indexed-property" href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-a-new-indexed-property" data-x-internal="set-the-value-of-a-new-indexed-property">set the value of a new
  indexed property</a> or <a id="the-htmloptionscollection-interface:set-the-value-of-an-existing-indexed-property" href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-an-existing-indexed-property" data-x-internal="set-the-value-of-an-existing-indexed-property">set the value of an existing indexed property</a> for a given
  property index <var>index</var> to a new value <var>value</var>, it must run the following
  algorithm:</p>

  <ol><li><p>If <var>value</var> is null, invoke the steps for the <code id="the-htmloptionscollection-interface:dom-htmloptionscollection-remove-2"><a href="#dom-htmloptionscollection-remove">remove</a></code> method with <var>index</var> as
   the argument, and return.</p></li><li><p>Let <var>length</var> be the number of nodes <a id="the-htmloptionscollection-interface:represented-by-the-collection-4" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the
   collection</a>.</p></li><li><p>Let <var>n</var> be <var>index</var> minus <var>length</var>.</p></li><li><p>If <var>n</var> is greater than zero, then <a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-htmloptionscollection-interface:concept-node-append" data-x-internal="concept-node-append">append</a> a <code id="the-htmloptionscollection-interface:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> consisting of <span><var>n</var>-1</span> new <code id="the-htmloptionscollection-interface:the-option-element-8"><a href="#the-option-element">option</a></code> elements with no attributes and
   no child nodes to the <code id="the-htmloptionscollection-interface:the-select-element-3"><a href="#the-select-element">select</a></code> element on which the <code id="the-htmloptionscollection-interface:htmloptionscollection-3"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code>
   is rooted.</p></li><li><p>If <var>n</var> is greater than or equal to zero, <a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-htmloptionscollection-interface:concept-node-append-2" data-x-internal="concept-node-append">append</a> <var>value</var> to the <code id="the-htmloptionscollection-interface:the-select-element-4"><a href="#the-select-element">select</a></code>
   element. Otherwise, <a href="https://dom.spec.whatwg.org/#concept-node-replace" id="the-htmloptionscollection-interface:concept-node-replace" data-x-internal="concept-node-replace">replace</a> the <var>index</var>th element in the collection by <var>value</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionsCollection" id="dom-htmloptionscollection-add" data-dfn-type="method"><code>add(<var>element</var>, <var>before</var>)</code></dfn>
  method must act according to the following algorithm:</p>

  <ol><li><p>If <var>element</var> is an ancestor of the <code id="the-htmloptionscollection-interface:the-select-element-5"><a href="#the-select-element">select</a></code> element on which
   the <code id="the-htmloptionscollection-interface:htmloptionscollection-4"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> is rooted, then throw a
   <a id="the-htmloptionscollection-interface:hierarchyrequesterror-2" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a> <code id="the-htmloptionscollection-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>before</var> is an element, but that element isn't a descendant of the
   <code id="the-htmloptionscollection-interface:the-select-element-6"><a href="#the-select-element">select</a></code> element on which the <code id="the-htmloptionscollection-interface:htmloptionscollection-5"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> is rooted, then throw
   a <a id="the-htmloptionscollection-interface:notfounderror" href="https://webidl.spec.whatwg.org/#notfounderror" data-x-internal="notfounderror">"<code>NotFoundError</code>"</a> <code id="the-htmloptionscollection-interface:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>element</var> and <var>before</var> are the same element, then
   return.</p></li><li><p>If <var>before</var> is a node, then let <var>reference</var> be that
   node. Otherwise, if <var>before</var> is an integer, and there is a <var>before</var>th node in the collection, let <var>reference</var> be that node.
   Otherwise, let <var>reference</var> be null.</p></li><li><p>If <var>reference</var> is not null, let <var>parent</var> be the parent
   node of <var>reference</var>. Otherwise, let <var>parent</var> be the
   <code id="the-htmloptionscollection-interface:the-select-element-7"><a href="#the-select-element">select</a></code> element on which the <code id="the-htmloptionscollection-interface:htmloptionscollection-6"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> is rooted.</p></li><li><p><a id="the-htmloptionscollection-interface:pre-insert" href="https://dom.spec.whatwg.org/#concept-node-pre-insert" data-x-internal="pre-insert">Pre-insert</a> <var>element</var> into <var>parent</var> node before
   <var>reference</var>.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionsCollection" id="dom-htmloptionscollection-remove" data-dfn-type="method"><code>remove(<var>index</var>)</code></dfn> method must act
  according to the following algorithm:</p>

  <ol><li><p>If the number of nodes <a id="the-htmloptionscollection-interface:represented-by-the-collection-5" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the collection</a> is zero, return.</p></li><li><p>If <var>index</var> is not a number greater than or equal to 0 and less than the
   number of nodes <a id="the-htmloptionscollection-interface:represented-by-the-collection-6" href="https://dom.spec.whatwg.org/#represented-by-the-collection" data-x-internal="represented-by-the-collection">represented by the collection</a>, return.</p></li><li><p>Let <var>element</var> be the <var>index</var>th element in the
   collection.</p></li><li><p>Remove <var>element</var> from its parent node.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionsCollection" id="dom-htmloptionscollection-selectedindex" data-dfn-type="attribute"><code>selectedIndex</code></dfn> IDL attribute must act
  like the identically named attribute on the <code id="the-htmloptionscollection-interface:the-select-element-8"><a href="#the-select-element">select</a></code> element on which the
  <code id="the-htmloptionscollection-interface:htmloptionscollection-7"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> is rooted</p>
  </div>

  

  


  <h4 id="the-domstringlist-interface"><span class="secno">2.6.5</span> The <code id="the-domstringlist-interface:domstringlist"><a href="#domstringlist">DOMStringList</a></code> interface<a href="#the-domstringlist-interface" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMStringList" title="The DOMString interface is a legacy type returned by some APIs and represents a non-modifiable list of strings (DOMString). Modern APIs use Array objects (in WebIDL: sequence<DOMString>) instead.">DOMStringList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <p>The <code id="the-domstringlist-interface:domstringlist-2"><a href="#domstringlist">DOMStringList</a></code> interface is a non-fashionable retro way of representing a list
  of strings.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="domstringlist" data-dfn-type="interface"><c- g="">DOMStringList</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-domstringlist-length" id="the-domstringlist-interface:dom-domstringlist-length"><c- g="">length</c-></a>;
  <c- b="">getter</c-> <c- b="">DOMString</c->? <a href="#dom-domstringlist-item" id="the-domstringlist-interface:dom-domstringlist-item"><c- g="">item</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <c- b="">boolean</c-> <a href="#dom-domstringlist-contains" id="the-domstringlist-interface:dom-domstringlist-contains"><c- g="">contains</c-></a>(<c- b="">DOMString</c-> <c- g="">string</c->);
};</code></pre>

  <p class="warning">New APIs must use <code>sequence&lt;DOMString&gt;</code> or
  equivalent rather than <code id="the-domstringlist-interface:domstringlist-3"><a href="#domstringlist">DOMStringList</a></code>.</p>

  <dl class="domintro"><dt><code><var>strings</var>.<a href="#dom-domstringlist-length" id="dom-domstringlist-length-dev">length</a></code></dt><dd><p>Returns the number of strings in <var>strings</var>.</p></dd><dt><code><var>strings</var>[<var>index</var>]</code></dt><dt><code><var>strings</var>.<a href="#dom-domstringlist-item" id="dom-domstringlist-item-dev">item</a>(<var>index</var>)</code></dt><dd><p>Returns the string with index <var>index</var> from <var>strings</var>.</p></dd><dt><code><var>strings</var>.<a href="#dom-domstringlist-contains" id="dom-domstringlist-contains-dev">contains</a>(<var>string</var>)</code></dt><dd><p>Returns true if <var>strings</var> contains <var>string</var>, and false
   otherwise.</p></dd></dl>

  

  <p>Each <code id="the-domstringlist-interface:domstringlist-4"><a href="#domstringlist">DOMStringList</a></code> object has an associated <a id="the-domstringlist-interface:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p>

  <div data-algorithm="">
  <p>The <code id="the-domstringlist-interface:domstringlist-5"><a href="#domstringlist">DOMStringList</a></code> interface <a id="the-domstringlist-interface:supports-indexed-properties" href="https://webidl.spec.whatwg.org/#dfn-support-indexed-properties" data-x-internal="supports-indexed-properties">supports indexed properties</a>. The
  <a id="the-domstringlist-interface:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> are the <a id="the-domstringlist-interface:indices" href="https://infra.spec.whatwg.org/#list-get-the-indices" data-x-internal="indices">indices</a> of <a id="the-domstringlist-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  associated list.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMStringList/length" title="The read-only length property indicates the number of strings in the DOMStringList.">DOMStringList/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="DOMStringList" id="dom-domstringlist-length" data-dfn-type="attribute"><code>length</code></dfn> getter steps are to return
  <a id="the-domstringlist-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s associated list's <a href="https://infra.spec.whatwg.org/#list-size" id="the-domstringlist-interface:list-size" data-x-internal="list-size">size</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMStringList/item" title="The item() method returns a string from a DOMStringList by index.">DOMStringList/item</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="DOMStringList" id="dom-domstringlist-item" data-dfn-type="method"><code>item(<var>index</var>)</code></dfn> method steps are to
  return the <var>index</var>th item in <a id="the-domstringlist-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s associated list, or null if
  <var>index</var> plus one is greater than <a id="the-domstringlist-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s associated list's <a href="https://infra.spec.whatwg.org/#list-size" id="the-domstringlist-interface:list-size-2" data-x-internal="list-size">size</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMStringList/contains" title="The contains() method returns a boolean indicating whether the given string is in the list.">DOMStringList/contains</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="DOMStringList" id="dom-domstringlist-contains" data-dfn-type="method"><code>contains(<var>string</var>)</code></dfn> method steps
  are to return true if <a id="the-domstringlist-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s associated list <a href="https://infra.spec.whatwg.org/#list-contain" id="the-domstringlist-interface:list-contains" data-x-internal="list-contains">contains</a> <var>string</var>, and false otherwise.</p>
  </div>

  


  <h3 id="safe-passing-of-structured-data"><span class="secno">2.7</span> Safe passing of structured data<a href="#safe-passing-of-structured-data" class="self-link"></a></h3>

  <p id="structuredclone"><span id="structured-clone"></span>To support passing JavaScript objects,
  including <a href="https://webidl.spec.whatwg.org/#dfn-platform-object" id="safe-passing-of-structured-data:platform-object" data-x-internal="platform-object">platform objects</a>, across <a id="safe-passing-of-structured-data:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>
  boundaries, this specification defines the following infrastructure for
  serializing and deserializing objects, including in some cases transferring the underlying data
  instead of copying it. Collectively this serialization/deserialization process is known as
  "structured cloning", although most APIs perform separate serialization and deserialization steps.
  (With the notable exception being the <code id="safe-passing-of-structured-data:dom-structuredclone"><a href="#dom-structuredclone">structuredClone()</a></code>
  method.)</p>

  

  <p>This section uses the terminology and typographic conventions from the JavaScript
  specification. <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  

  <h4 id="serializable-objects" data-lt="serializable object" data-export=""><span class="secno">2.7.1</span> <dfn>Serializable objects</dfn><a href="#serializable-objects" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/https://developer.mozilla.org/en-US/docs/Glossary/Serializable_object" title="Serializable objects are objects that can be serialized and later deserialized in any JavaScript environment (&quot;realm&quot;). This allows them to, for example, be stored on disk and later restored, or cloned with structuredClone(), or shared between workers using DedicatedWorkerGlobalScope.postMessage().">/developer.mozilla.org/en-US/docs/Glossary/Serializable_object</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>103+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/https://developer.mozilla.org/en-US/docs/Glossary/Serializable_object" title="Serializable objects are objects that can be serialized and later deserialized in any JavaScript environment (&quot;realm&quot;). This allows them to, for example, be stored on disk and later restored, or cloned with structuredClone(), or shared between workers using DedicatedWorkerGlobalScope.postMessage().">/developer.mozilla.org/en-US/docs/Glossary/Serializable_object</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>103+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/https://developer.mozilla.org/en-US/docs/Glossary/Serializable_object" title="Serializable objects are objects that can be serialized and later deserialized in any JavaScript environment (&quot;realm&quot;). This allows them to, for example, be stored on disk and later restored, or cloned with structuredClone(), or shared between workers using DedicatedWorkerGlobalScope.postMessage().">/developer.mozilla.org/en-US/docs/Glossary/Serializable_object</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>103+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/https://developer.mozilla.org/en-US/docs/Glossary/Serializable_object" title="Serializable objects are objects that can be serialized and later deserialized in any JavaScript environment (&quot;realm&quot;). This allows them to, for example, be stored on disk and later restored, or cloned with structuredClone(), or shared between workers using DedicatedWorkerGlobalScope.postMessage().">/developer.mozilla.org/en-US/docs/Glossary/Serializable_object</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>103+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/https://developer.mozilla.org/en-US/docs/Glossary/Serializable_object" title="Serializable objects are objects that can be serialized and later deserialized in any JavaScript environment (&quot;realm&quot;). This allows them to, for example, be stored on disk and later restored, or cloned with structuredClone(), or shared between workers using DedicatedWorkerGlobalScope.postMessage().">/developer.mozilla.org/en-US/docs/Glossary/Serializable_object</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>103+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/https://developer.mozilla.org/en-US/docs/Glossary/Serializable_object" title="Serializable objects are objects that can be serialized and later deserialized in any JavaScript environment (&quot;realm&quot;). This allows them to, for example, be stored on disk and later restored, or cloned with structuredClone(), or shared between workers using DedicatedWorkerGlobalScope.postMessage().">/developer.mozilla.org/en-US/docs/Glossary/Serializable_object</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>103+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/https://developer.mozilla.org/en-US/docs/Glossary/Serializable_object" title="Serializable objects are objects that can be serialized and later deserialized in any JavaScript environment (&quot;realm&quot;). This allows them to, for example, be stored on disk and later restored, or cloned with structuredClone(), or shared between workers using DedicatedWorkerGlobalScope.postMessage().">/developer.mozilla.org/en-US/docs/Glossary/Serializable_object</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>103+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p><a href="#serializable-objects" id="serializable-objects:serializable-objects">Serializable objects</a> support being serialized, and later deserialized, in a way
  that is independent of any given <a id="serializable-objects:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>. This allows them to be stored on disk and
  later restored, or cloned across <a id="serializable-objects:agent" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a> and even <a id="serializable-objects:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>
  boundaries.</p>

  <p>Not all objects are <a href="#serializable-objects" id="serializable-objects:serializable-objects-2">serializable objects</a>, and not all aspects of objects that are
  <a href="#serializable-objects" id="serializable-objects:serializable-objects-3">serializable objects</a> are necessarily preserved when they are serialized.</p>

  

  <p><a href="https://webidl.spec.whatwg.org/#dfn-platform-object" id="serializable-objects:platform-object" data-x-internal="platform-object">Platform objects</a> can be <a href="#serializable-objects" id="serializable-objects:serializable-objects-4">serializable objects</a>
  if their <a id="serializable-objects:primary-interface" href="https://webidl.spec.whatwg.org/#dfn-primary-interface" data-x-internal="primary-interface">primary interface</a> is decorated with the <dfn id="serializable" data-dfn-type="extended-attribute" data-lt="Serializable"><code>[Serializable]</code></dfn> IDL <a id="serializable-objects:extended-attribute" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended
  attribute</a>. Such interfaces must also define the following algorithms:</p>

  <dl><div data-var-scope="">
   <dt><dfn id="serialization-steps" data-export="">serialization steps</dfn>, taking a <a id="serializable-objects:platform-object-2" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a>
   <var>value</var>, a <a id="serializable-objects:record" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> <var>serialized</var>, and a boolean
   <var>forStorage</var></dt>
   <dd>
    <p>A set of steps that serializes the data in <var>value</var> into fields of
    <var>serialized</var>. The resulting data serialized into <var>serialized</var> must be
    independent of any <a id="serializable-objects:realm-2" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>.</p>

    <p>These steps may throw an exception if serialization is not possible.</p>

    <p>These steps may perform a <a href="#sub-serialization" id="serializable-objects:sub-serialization">sub-serialization</a> to serialize nested data
    structures. They should not call <a href="#structuredserialize" id="serializable-objects:structuredserialize">StructuredSerialize</a> directly, as doing so will
    omit the important <var>memory</var> argument.</p>

    <p>The introduction of these steps should omit mention of the <var>forStorage</var> argument if
    it is not relevant to the algorithm.</p>
   </dd>
   </div><div data-var-scope="">
   <dt><dfn id="deserialization-steps" data-export="">deserialization steps</dfn>, taking a <a id="serializable-objects:record-2" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> <var>serialized</var>,
   a <a id="serializable-objects:platform-object-3" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> <var>value</var>, and a <a id="serializable-objects:realm-3" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>
   <var>targetRealm</var></dt>
   <dd>
    <p>A set of steps that deserializes the data in <var>serialized</var>, using it to set up
    <var>value</var> as appropriate. <var>value</var> will be a newly-created instance of the
    <a id="serializable-objects:platform-object-4" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> type in question, with none of its internal data set up; setting
    that up is the job of these steps.</p>

    <p>These steps may throw an exception if deserialization is not possible.</p>

    <p>These steps may perform a <a href="#sub-deserialization" id="serializable-objects:sub-deserialization">sub-deserialization</a> to deserialize nested data
    structures. They should not call <a href="#structureddeserialize" id="serializable-objects:structureddeserialize">StructuredDeserialize</a> directly, as doing so will
    omit the important <var>targetRealm</var> and <var>memory</var> arguments.</p>
   </dd>
   </div></dl>

  <p>It is up to the definition of individual platform objects to determine what data is serialized
  and deserialized by these steps. Typically the steps are very symmetric.</p>

  <p>The <code id="serializable-objects:serializable"><a href="#serializable">[Serializable]</a></code> extended attribute must take no
  arguments, and must only appear on an interface. It must not appear more than once on an
  interface.</p>

  <p>For a given <a id="serializable-objects:platform-object-5" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a>, only the object's <a id="serializable-objects:primary-interface-2" href="https://webidl.spec.whatwg.org/#dfn-primary-interface" data-x-internal="primary-interface">primary interface</a> is
  considered during the (de)serialization process. Thus, if inheritance is involved in defining the
  interface, each <code id="serializable-objects:serializable-2"><a href="#serializable">[Serializable]</a></code>-annotated interface in the
  inheritance chain needs to define standalone <a href="#serialization-steps" id="serializable-objects:serialization-steps">serialization steps</a> and
  <a href="#deserialization-steps" id="serializable-objects:deserialization-steps">deserialization steps</a>, including taking into account any important data that might
  come from inherited interfaces.</p>

  <div class="example">
   <p>Let's say we were defining a platform object <code>Person</code>, which had
   associated with it two pieces of associated data:</p>

   <ul><li><p>a name value, which is a string; and</p></li><li><p>a best friend value, which is either another <code>Person</code> instance
    or null.</p></li></ul>

   <p>We could then define <code>Person</code> instances to be <a href="#serializable-objects" id="serializable-objects:serializable-objects-5">serializable
   objects</a> by annotating the <code>Person</code> interface with the <code id="serializable-objects:serializable-3"><a href="#serializable">[Serializable]</a></code> <a id="serializable-objects:extended-attribute-2" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a>, and defining the
   following accompanying algorithms:</p>

   <div data-algorithm="">
   <p>Their <a href="#serialization-steps" id="serializable-objects:serialization-steps-2">serialization steps</a>, given <var>value</var> and <var>serialized</var>:</p>

   <ol><li><p>Set <var>serialized</var>.[[Name]] to <var>value</var>'s associated name
    value.</p></li><li><p>Let <var>serializedBestFriend</var> be the <a href="#sub-serialization" id="serializable-objects:sub-serialization-2">sub-serialization</a> of
    <var>value</var>'s associated best friend value.</p></li><li><p>Set <var>serialized</var>.[[BestFriend]] to <var>serializedBestFriend</var>.</p></li></ol>
   </div>

   <div data-algorithm="">
   <p>Their <a href="#deserialization-steps" id="serializable-objects:deserialization-steps-2">deserialization steps</a>, given <var>serialized</var>, <var>value</var>, and
   <var>targetRealm</var>:</p>

   <ol><li><p>Set <var>value</var>'s associated name value to
    <var>serialized</var>.[[Name]].</p></li><li><p>Let <var>deserializedBestFriend</var> be the <a href="#sub-deserialization" id="serializable-objects:sub-deserialization-2">sub-deserialization</a> of
    <var>serialized</var>.[[BestFriend]].</p></li><li><p>Set <var>value</var>'s associated best friend value to
    <var>deserializedBestFriend</var>.</p></li></ol>
   </div>
  </div>

  <p>Objects defined in the JavaScript specification are handled by the
  <a href="#structuredserialize" id="serializable-objects:structuredserialize-2">StructuredSerialize</a> abstract operation directly.</p>

  <p id="cloneable-objects" class="note"><a href="#cloneable-objects" class="self-link"></a>Originally, this specification defined the concept of
  "cloneable objects", which could be cloned from one <a id="serializable-objects:realm-4" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> to another. However, to
  better specify the behavior of certain more complex situations, the model was updated to make the
  serialization and deserialization explicit.</p>

  

  <h4 id="transferable-objects" data-lt="transferable object" data-export=""><span class="secno">2.7.2</span> <dfn>Transferable objects</dfn><a href="#transferable-objects" class="self-link"></a></h4>

  <p><a href="#transferable-objects" id="transferable-objects:transferable-objects">Transferable objects</a> support being transferred across <a href="https://tc39.es/ecma262/#sec-agents" id="transferable-objects:agent" data-x-internal="agent">agents</a>. Transferring is effectively recreating the object while sharing a
  reference to the underlying data and then detaching the object being transferred. This is useful
  to transfer ownership of expensive resources. Not all objects are <a href="#transferable-objects" id="transferable-objects:transferable-objects-2">transferable
  objects</a> and not all aspects of objects that are <a href="#transferable-objects" id="transferable-objects:transferable-objects-3">transferable objects</a> are
  necessarily preserved when transferred.</p>

  <p class="note">Transferring is an irreversible and non-idempotent operation. Once an object has
  been transferred, it cannot be transferred, or indeed used, again.</p>

  

  <p><a href="https://webidl.spec.whatwg.org/#dfn-platform-object" id="transferable-objects:platform-object" data-x-internal="platform-object">Platform objects</a> can be <a href="#transferable-objects" id="transferable-objects:transferable-objects-4">transferable objects</a>
  if their <a id="transferable-objects:primary-interface" href="https://webidl.spec.whatwg.org/#dfn-primary-interface" data-x-internal="primary-interface">primary interface</a> is decorated with the <dfn id="transferable" data-dfn-type="extended-attribute" data-lt="Transferable"><code>[Transferable]</code></dfn> IDL <a id="transferable-objects:extended-attribute" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended
  attribute</a>. Such interfaces must also define the following algorithms:</p>

  <dl><div data-var-scope="">
   <dt><dfn id="transfer-steps" data-export="">transfer steps</dfn>, taking a <a id="transferable-objects:platform-object-2" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a>
   <var>value</var> and a <a id="transferable-objects:record" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> <var>dataHolder</var></dt>
   <dd>
    <p>A set of steps that transfers the data in <var>value</var> into fields of
    <var>dataHolder</var>. The resulting data held in <var>dataHolder</var> must be
    independent of any <a id="transferable-objects:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>.</p>

    <p>These steps may throw an exception if transferral is not possible.</p>
   </dd>
   </div><div data-var-scope="">
   <dt><dfn id="transfer-receiving-steps" data-export="">transfer-receiving steps</dfn>, taking a <a id="transferable-objects:record-2" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a>
   <var>dataHolder</var> and a <a id="transferable-objects:platform-object-3" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> <var>value</var></dt>
   <dd>
    <p>A set of steps that receives the data in <var>dataHolder</var>, using it to set up
    <var>value</var> as appropriate. <var>value</var> will be a newly-created instance of the
    <a id="transferable-objects:platform-object-4" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> type in question, with none of its internal data set up; setting
    that up is the job of these steps.</p>

    <p>These steps may throw an exception if it is not possible to receive the transfer.</p>
   </dd>
   </div></dl>

  <p>It is up to the definition of individual platform objects to determine what data is transferred
  by these steps. Typically the steps are very symmetric.</p>

  <p>The <code id="transferable-objects:transferable"><a href="#transferable">[Transferable]</a></code> extended attribute must take no
  arguments, and must only appear on an interface. It must not appear more than once on an
  interface.</p>

  <p>For a given <a id="transferable-objects:platform-object-5" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a>, only the object's <a id="transferable-objects:primary-interface-2" href="https://webidl.spec.whatwg.org/#dfn-primary-interface" data-x-internal="primary-interface">primary interface</a> is
  considered during the transferring process. Thus, if inheritance is involved in defining the
  interface, each <code id="transferable-objects:transferable-2"><a href="#transferable">[Transferable]</a></code>-annotated interface in the
  inheritance chain needs to define standalone <a href="#transfer-steps" id="transferable-objects:transfer-steps">transfer steps</a> and
  <a href="#transfer-receiving-steps" id="transferable-objects:transfer-receiving-steps">transfer-receiving steps</a>, including taking into account any important data that might
  come from inherited interfaces.</p>

  <p><a href="https://webidl.spec.whatwg.org/#dfn-platform-object" id="transferable-objects:platform-object-6" data-x-internal="platform-object">Platform objects</a> that are <a href="#transferable-objects" id="transferable-objects:transferable-objects-5">transferable
  objects</a> have a <dfn data-dfn-for="platform object" id="detached" data-dfn-type="attribute">[[Detached]]</dfn> internal slot. This
  is used to ensure that once a platform object has been transferred, it cannot be transferred
  again.</p>

  <p>Objects defined in the JavaScript specification are handled by the
  <a href="#structuredserializewithtransfer" id="transferable-objects:structuredserializewithtransfer">StructuredSerializeWithTransfer</a> abstract operation directly.</p>

  <div data-algorithm="">
  <h4 id="structuredserializeinternal" data-dfn-type="abstract-op" data-noexport="" data-lt="StructuredSerializeInternal"><span class="secno">2.7.3</span> <dfn>StructuredSerializeInternal</dfn> ( <var>value</var>, <var>forStorage</var> [ ,
  <var>memory</var> ] )<a href="#structuredserializeinternal" class="self-link"></a></h4>

  <p>The <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal">StructuredSerializeInternal</a> abstract operation takes as input a JavaScript
  value <var>value</var> and serializes it to a <a id="structuredserializeinternal:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>-independent form, represented
  here as a <a id="structuredserializeinternal:record" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a>. This serialized form has all the information necessary to later
  deserialize into a new JavaScript value in a different realm.</p>

  <p>This process can throw an exception, for example when trying to serialize un-serializable
  objects.</p>

  <ol><li>
    <p>If <var>memory</var> was not supplied, let <var>memory</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-map" id="structuredserializeinternal:ordered-map" data-x-internal="ordered-map">map</a>.</p>

    <p class="note">The purpose of the <var>memory</var> map is to avoid serializing objects twice.
    This ends up preserving cycles and the identity of duplicate objects in graphs.</p>
   </li><li><p>If <var>memory</var>[<var>value</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="structuredserializeinternal:map-exists" data-x-internal="map-exists">exists</a>, then
   return <var>memory</var>[<var>value</var>].</p></li><li><p>Let <var>deep</var> be false.</p></li><li><p>If <var>value</var> is undefined, null, <a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-boolean-type" id="structuredserializeinternal:js-boolean" data-x-internal="js-boolean">a Boolean</a>, <a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type" id="structuredserializeinternal:js-number" data-x-internal="js-number">a Number</a>, <a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-bigint-type" id="structuredserializeinternal:js-bigint" data-x-internal="js-bigint">a BigInt</a>, or <a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type" id="structuredserializeinternal:js-string" data-x-internal="js-string">a String</a>, then return { [[Type]]: "primitive", [[Value]]:
   <var>value</var> }.</p></li><li><p>If <var>value</var> <a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-symbol-type" id="structuredserializeinternal:js-symbol" data-x-internal="js-symbol">is a Symbol</a>, then throw a
   <a id="structuredserializeinternal:datacloneerror" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializeinternal:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>serialized</var> be an uninitialized value.</p></li><li><p>If <var>value</var> has a [[BooleanData]] internal slot, then set <var>serialized</var> to
   { [[Type]]: "Boolean", [[BooleanData]]: <var>value</var>.[[BooleanData]] }.</p></li><li><p>Otherwise, if <var>value</var> has a [[NumberData]] internal slot, then set
   <var>serialized</var> to { [[Type]]: "Number", [[NumberData]]: <var>value</var>.[[NumberData]]
   }.</p></li><li><p>Otherwise, if <var>value</var> has a [[BigIntData]]
   internal slot, then set <var>serialized</var> to { [[Type]]: "BigInt", [[BigIntData]]:
   <var>value</var>.[[BigIntData]] }.</p></li><li><p>Otherwise, if <var>value</var> has a [[StringData]] internal slot, then set
   <var>serialized</var> to { [[Type]]: "String", [[StringData]]: <var>value</var>.[[StringData]]
   }.</p></li><li><p>Otherwise, if <var>value</var> has a [[DateValue]] internal slot, then set
   <var>serialized</var> to { [[Type]]: "Date", [[DateValue]]: <var>value</var>.[[DateValue]]
   }.</p></li><li><p>Otherwise, if <var>value</var> has a [[RegExpMatcher]] internal slot, then set
   <var>serialized</var> to { [[Type]]: "RegExp", [[RegExpMatcher]]:
   <var>value</var>.[[RegExpMatcher]], [[OriginalSource]]: <var>value</var>.[[OriginalSource]],
   [[OriginalFlags]]: <var>value</var>.[[OriginalFlags]] }.</p></li><li>
    <p>Otherwise, if <var>value</var> has an [[ArrayBufferData]] internal slot, then:</p>

    <ol><li>
      <p>If <a id="structuredserializeinternal:issharedarraybuffer" href="https://tc39.es/ecma262/#sec-issharedarraybuffer" data-x-internal="issharedarraybuffer">IsSharedArrayBuffer</a>(<var>value</var>) is true, then:

      </p><ol><li>
        <p>If the <a href="#current-settings-object" id="structuredserializeinternal:current-settings-object">current settings object</a>'s <a href="#concept-settings-object-cross-origin-isolated-capability" id="structuredserializeinternal:concept-settings-object-cross-origin-isolated-capability">cross-origin isolated
        capability</a> is false, then throw a <a id="structuredserializeinternal:datacloneerror-2" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a>
        <code id="structuredserializeinternal:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

        <p class="note">This check is only needed when serializing (and not when deserializing) as
        the <a href="#concept-settings-object-cross-origin-isolated-capability" id="structuredserializeinternal:concept-settings-object-cross-origin-isolated-capability-2">cross-origin
        isolated capability</a> cannot change over time and a <code id="structuredserializeinternal:sharedarraybuffer"><a data-x-internal="sharedarraybuffer" href="https://tc39.es/ecma262/#sec-sharedarraybuffer-objects">SharedArrayBuffer</a></code>
        cannot leave an <a id="structuredserializeinternal:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>.</p>
       </li><li><p>If <var>forStorage</var> is true, then throw a
       <a id="structuredserializeinternal:datacloneerror-3" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializeinternal:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>value</var> has an [[ArrayBufferMaxByteLength]] internal slot, then set
       <var>serialized</var> to { [[Type]]: "GrowableSharedArrayBuffer", [[ArrayBufferData]]:
       <var>value</var>.[[ArrayBufferData]], [[ArrayBufferByteLengthData]]:
       <var>value</var>.[[ArrayBufferByteLengthData]], [[ArrayBufferMaxByteLength]]:
       <var>value</var>.[[ArrayBufferMaxByteLength]], [[AgentCluster]]: the <a id="structuredserializeinternal:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding
       agent</a>'s <a id="structuredserializeinternal:agent-cluster-2" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a> }.</p></li><li><p>Otherwise, set <var>serialized</var> to { [[Type]]: "SharedArrayBuffer",
       [[ArrayBufferData]]: <var>value</var>.[[ArrayBufferData]], [[ArrayBufferByteLength]]:
       <var>value</var>.[[ArrayBufferByteLength]], [[AgentCluster]]: the <a id="structuredserializeinternal:surrounding-agent-2" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding
       agent</a>'s <a id="structuredserializeinternal:agent-cluster-3" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a> }.</p></li></ol>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p>If <a id="structuredserializeinternal:isdetachedbuffer" href="https://tc39.es/ecma262/#sec-isdetachedbuffer" data-x-internal="isdetachedbuffer">IsDetachedBuffer</a>(<var>value</var>) is true, then throw a
       <a id="structuredserializeinternal:datacloneerror-4" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializeinternal:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>size</var> be <var>value</var>.[[ArrayBufferByteLength]].</p></li><li>
        <p>Let <var>dataCopy</var> be ? <a id="structuredserializeinternal:createbytedatablock" href="https://tc39.es/ecma262/#sec-createbytedatablock" data-x-internal="createbytedatablock">CreateByteDataBlock</a>(<var>size</var>).</p>

        <p class="note">This can throw a <code id="structuredserializeinternal:js-rangeerror"><a data-x-internal="js-rangeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror">RangeError</a></code> exception
        upon allocation failure.</p>
       </li><li><p>Perform <a id="structuredserializeinternal:copydatablockbytes" href="https://tc39.es/ecma262/#sec-copydatablockbytes" data-x-internal="copydatablockbytes">CopyDataBlockBytes</a>(<var>dataCopy</var>, 0,
       <var>value</var>.[[ArrayBufferData]], 0, <var>size</var>).</p></li><li><p>If <var>value</var> has an [[ArrayBufferMaxByteLength]] internal slot, then set
       <var>serialized</var> to { [[Type]]: "ResizableArrayBuffer", [[ArrayBufferData]]:
       <var>dataCopy</var>, [[ArrayBufferByteLength]]: <var>size</var>,
       [[ArrayBufferMaxByteLength]]: <var>value</var>.[[ArrayBufferMaxByteLength]] }.</p></li><li><p>Otherwise, set <var>serialized</var> to { [[Type]]: "ArrayBuffer",
       [[ArrayBufferData]]: <var>dataCopy</var>, [[ArrayBufferByteLength]]: <var>size</var>
       }.</p></li></ol>
     </li></ol>
   </li><li>
    <p>Otherwise, if <var>value</var> has a [[ViewedArrayBuffer]] internal slot, then:</p>

    <ol><li><p>If <a id="structuredserializeinternal:isarraybufferviewoutofbounds" href="https://tc39.es/ecma262/#sec-isarraybufferviewoutofbounds" data-x-internal="isarraybufferviewoutofbounds">IsArrayBufferViewOutOfBounds</a>(<var>value</var>) is true, then throw a
     <a id="structuredserializeinternal:datacloneerror-5" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializeinternal:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>buffer</var> be the value of <var>value</var>'s [[ViewedArrayBuffer]] internal
     slot.</p></li><li><p>Let <var>bufferSerialized</var> be ?
     <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal-2">StructuredSerializeInternal</a>(<var>buffer</var>, <var>forStorage</var>,
     <var>memory</var>).</p></li><li><p><a id="structuredserializeinternal:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>bufferSerialized</var>.[[Type]] is "ArrayBuffer",
     "ResizableArrayBuffer", "SharedArrayBuffer", or "GrowableSharedArrayBuffer".</p></li><li><p>If <var>value</var> has a [[DataView]] internal slot, then set <var>serialized</var> to
     { [[Type]]: "ArrayBufferView", [[Constructor]]: "DataView", [[ArrayBufferSerialized]]:
     <var>bufferSerialized</var>, [[ByteLength]]: <var>value</var>.[[ByteLength]], [[ByteOffset]]:
     <var>value</var>.[[ByteOffset]] }.</p></li><li>
      <p>Otherwise:</p>

      <ol><li><p><a id="structuredserializeinternal:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>value</var> has a [[TypedArrayName]] internal slot.</p></li><li><p>Set <var>serialized</var> to { [[Type]]: "ArrayBufferView", [[Constructor]]:
       <var>value</var>.[[TypedArrayName]], [[ArrayBufferSerialized]]: <var>bufferSerialized</var>,
       [[ByteLength]]: <var>value</var>.[[ByteLength]], [[ByteOffset]]:
       <var>value</var>.[[ByteOffset]], [[ArrayLength]]: <var>value</var>.[[ArrayLength]] }.</p></li></ol>
     </li></ol>
   </li><li>
    <p>Otherwise, if <var>value</var> has a [[MapData]] internal slot, then:</p>

    <ol><li><p>Set <var>serialized</var> to { [[Type]]: "Map", [[MapData]]: a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structuredserializeinternal:js-list" data-x-internal="js-list">List</a> }.</p></li><li><p>Set <var>deep</var> to true.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>value</var> has a [[SetData]] internal slot, then:</p>

    <ol><li><p>Set <var>serialized</var> to { [[Type]]: "Set", [[SetData]]: a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structuredserializeinternal:js-list-2" data-x-internal="js-list">List</a> }.</p></li><li><p>Set <var>deep</var> to true.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>value</var> has an [[ErrorData]] internal slot and <var>value</var> is not
    a <a id="structuredserializeinternal:platform-object" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a>, then:</p>
    

    <ol><li><p>Let <var>name</var> be ? <a href="https://tc39.es/ecma262/#sec-get-o-p" id="structuredserializeinternal:js-get" data-x-internal="js-get">Get</a>(<var>value</var>,
     "name").</p></li><li><p>If <var>name</var> is not one of "Error", "EvalError", "RangeError", "ReferenceError",
     "SyntaxError", "TypeError", or "URIError", then set <var>name</var> to "Error".</p></li><li><p>Let <var>valueMessageDesc</var> be ? <var>value</var>.[[GetOwnProperty]]("<code>message</code>").</p></li><li><p>Let <var>message</var> be undefined if
     <a id="structuredserializeinternal:isdatadescriptor" href="https://tc39.es/ecma262/#sec-isdatadescriptor" data-x-internal="isdatadescriptor">IsDataDescriptor</a>(<var>valueMessageDesc</var>) is false, and
     ? <a id="structuredserializeinternal:tostring" href="https://tc39.es/ecma262/#sec-tostring" data-x-internal="tostring">ToString</a>(<var>valueMessageDesc</var>.[[Value]]) otherwise.</p></li><li><p>Set <var>serialized</var> to { [[Type]]: "Error", [[Name]]: <var>name</var>,
     [[Message]]: <var>message</var> }.</p></li><li>
      <p>User agents should attach a serialized representation of any interesting accompanying
      data which are not yet specified, notably the <code>stack</code> property, to
      <var>serialized</var>.</p>

      <p class="note">See the <cite>Error Stacks</cite> proposal for in-progress work on specifying
      this data. <a href="#refsJSERRORSTACKS">[JSERRORSTACKS]</a></p>
     </li></ol>
   </li><li>
    <p>Otherwise, if <var>value</var> is an Array exotic object, then:</p>
    

    <ol><li><p>Let <var>valueLenDescriptor</var> be ?
     <a id="structuredserializeinternal:ordinarygetownproperty" href="https://tc39.es/ecma262/#sec-ordinarygetownproperty" data-x-internal="ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<var>value</var>, "<code>length</code>").</p></li><li><p>Let <var>valueLen</var> be <var>valueLenDescriptor</var>.[[Value]].</p></li><li><p>Set <var>serialized</var> to { [[Type]]: "Array", [[Length]]: <var>valueLen</var>,
     [[Properties]]: a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structuredserializeinternal:js-list-3" data-x-internal="js-list">List</a> }.</p></li><li><p>Set <var>deep</var> to true.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>value</var> is a <a id="structuredserializeinternal:platform-object-2" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> that is a <a href="#serializable-objects" id="structuredserializeinternal:serializable-objects">serializable object</a>:</p>

    <ol><li><p>If <var>value</var> has a <a href="#detached" id="structuredserializeinternal:detached">[[Detached]]</a> internal slot whose value is true,
     then throw a <a id="structuredserializeinternal:datacloneerror-6" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializeinternal:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>typeString</var> be the identifier of the <a id="structuredserializeinternal:primary-interface" href="https://webidl.spec.whatwg.org/#dfn-primary-interface" data-x-internal="primary-interface">primary interface</a> of
     <var>value</var>.</p></li><li><p>Set <var>serialized</var> to { [[Type]]: <var>typeString</var> }.</p></li><li><p>Set <var>deep</var> to true.</p></li></ol>
   </li><li><p>Otherwise, if <var>value</var> is a <a id="structuredserializeinternal:platform-object-3" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a>, then throw a
   <a id="structuredserializeinternal:datacloneerror-7" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializeinternal:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Otherwise, if <a id="structuredserializeinternal:iscallable" href="https://tc39.es/ecma262/#sec-iscallable" data-x-internal="iscallable">IsCallable</a>(<var>value</var>) is true, then throw a
   <a id="structuredserializeinternal:datacloneerror-8" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializeinternal:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p>Otherwise, if <var>value</var> has any internal slot other than [[Prototype]],
    [[Extensible]], or [[PrivateElements]], then throw a <a id="structuredserializeinternal:datacloneerror-9" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a>
    <code id="structuredserializeinternal:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p class="example">For instance, a [[PromiseState]] or [[WeakMapData]] internal slot.</p>
   </li><li>
    <p>Otherwise, if <var>value</var> is an exotic object and <var>value</var> is not the
    <a id="structuredserializeinternal:object.prototype" href="https://tc39.es/ecma262/#sec-properties-of-the-object-prototype-object" data-x-internal="object.prototype">%Object.prototype%</a> intrinsic object associated with any <a id="structuredserializeinternal:realm-2" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>, then
    throw a <a id="structuredserializeinternal:datacloneerror-10" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializeinternal:domexception-10"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p class="example">For instance, a proxy object.</p>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p>Set <var>serialized</var> to { [[Type]]: "Object", [[Properties]]: a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structuredserializeinternal:js-list-4" data-x-internal="js-list">List</a> }.</p></li><li><p>Set <var>deep</var> to true.</p></li></ol>

    <p class="note"><a id="structuredserializeinternal:object.prototype-2" href="https://tc39.es/ecma262/#sec-properties-of-the-object-prototype-object" data-x-internal="object.prototype">%Object.prototype%</a> will end up being handled via this step and
    subsequent steps. The end result is that its exoticness is ignored, and after deserialization
    the result will be an empty object (not an <a id="structuredserializeinternal:immutable-prototype-exotic-object" href="https://tc39.es/ecma262/#immutable-prototype-exotic-object" data-x-internal="immutable-prototype-exotic-object">immutable prototype exotic object</a>).
   </p></li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="structuredserializeinternal:map-set" data-x-internal="map-set">Set</a> <var>memory</var>[<var>value</var>] to
   <var>serialized</var>.</p></li><li>
    <p>If <var>deep</var> is true, then:</p>

    <ol><li>
      <p>If <var>value</var> has a [[MapData]] internal slot, then:

      </p><ol><li><p>Let <var>copiedList</var> be a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structuredserializeinternal:js-list-5" data-x-internal="js-list">List</a>.

       </p></li><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structuredserializeinternal:list-iterate" data-x-internal="list-iterate">For each</a> <a id="structuredserializeinternal:record-2" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> { [[Key]], [[Value]] }
        <var>entry</var> of <var>value</var>.[[MapData]]:</p>

        <ol><li><p>Let <var>copiedEntry</var> be a new <a id="structuredserializeinternal:record-3" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> { [[Key]]:
         <var>entry</var>.[[Key]], [[Value]]: <var>entry</var>.[[Value]] }.</p></li><li><p>If <var>copiedEntry</var>.[[Key]] is not the special value <i>empty</i>, <a href="https://infra.spec.whatwg.org/#list-append" id="structuredserializeinternal:list-append" data-x-internal="list-append">append</a> <var>copiedEntry</var> to <var>copiedList</var>.</p></li></ol>
       </li><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structuredserializeinternal:list-iterate-2" data-x-internal="list-iterate">For each</a> <a id="structuredserializeinternal:record-4" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> { [[Key]], [[Value]] }
        <var>entry</var> of <var>copiedList</var>:</p>

        <ol><li><p>Let <var>serializedKey</var> be ?
         <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal-3">StructuredSerializeInternal</a>(<var>entry</var>.[[Key]], <var>forStorage</var>,
         <var>memory</var>).</p></li><li><p>Let <var>serializedValue</var> be ?
         <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal-4">StructuredSerializeInternal</a>(<var>entry</var>.[[Value]], <var>forStorage</var>,
         <var>memory</var>).</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="structuredserializeinternal:list-append-2" data-x-internal="list-append">Append</a> { [[Key]]: <var>serializedKey</var>,
         [[Value]]: <var>serializedValue</var> } to <var>serialized</var>.[[MapData]].</p></li></ol>
       </li></ol>
     </li><li>
      <p>Otherwise, if <var>value</var> has a [[SetData]] internal slot, then:</p>

      <ol><li><p>Let <var>copiedList</var> be a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structuredserializeinternal:js-list-6" data-x-internal="js-list">List</a>.

       </p></li><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structuredserializeinternal:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>entry</var> of <var>value</var>.[[SetData]]:</p>

        <ol><li><p>If <var>entry</var> is not the special value <i>empty</i>, <a href="https://infra.spec.whatwg.org/#list-append" id="structuredserializeinternal:list-append-3" data-x-internal="list-append">append</a> <var>entry</var> to <var>copiedList</var>.</p></li></ol>
       </li><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structuredserializeinternal:list-iterate-4" data-x-internal="list-iterate">For each</a> <var>entry</var> of <var>copiedList</var>:</p>

        <ol><li><p>Let <var>serializedEntry</var> be ?
         <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal-5">StructuredSerializeInternal</a>(<var>entry</var>, <var>forStorage</var>,
         <var>memory</var>).</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="structuredserializeinternal:list-append-4" data-x-internal="list-append">Append</a> <var>serializedEntry</var> to
         <var>serialized</var>.[[SetData]].</p></li></ol>
       </li></ol>
     </li><li>
      <p>Otherwise, if <var>value</var> is a <a id="structuredserializeinternal:platform-object-4" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> that is a <a href="#serializable-objects" id="structuredserializeinternal:serializable-objects-2">serializable object</a>, then perform the <a href="#serialization-steps" id="structuredserializeinternal:serialization-steps">serialization
      steps</a> for <var>value</var>'s <a id="structuredserializeinternal:primary-interface-2" href="https://webidl.spec.whatwg.org/#dfn-primary-interface" data-x-internal="primary-interface">primary interface</a>, given <var>value</var>,
      <var>serialized</var>, and <var>forStorage</var>.</p>

      <p>The <a href="#serialization-steps" id="structuredserializeinternal:serialization-steps-2">serialization steps</a> may need to perform a <dfn id="sub-serialization" data-export="">sub-serialization</dfn>. This is an operation which takes as input a value
      <var>subValue</var>, and returns <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal-6">StructuredSerializeInternal</a>(<var>subValue</var>,
      <var>forStorage</var>, <var>memory</var>). (In other words, a <a href="#sub-serialization" id="structuredserializeinternal:sub-serialization">sub-serialization</a>
      is a specialization of <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal-7">StructuredSerializeInternal</a> to be consistent within this
      invocation.)</p>
     </li><li>
      <p>Otherwise, for each <var>key</var> in !
      <a id="structuredserializeinternal:enumerableownproperties" href="https://tc39.es/ecma262/#sec-enumerableownproperties" data-x-internal="enumerableownproperties">EnumerableOwnProperties</a>(<var>value</var>, key):</p>

      <ol><li>
        <p>If ! <a id="structuredserializeinternal:hasownproperty" href="https://tc39.es/ecma262/#sec-hasownproperty" data-x-internal="hasownproperty">HasOwnProperty</a>(<var>value</var>, <var>key</var>) is true, then:</p>

        <ol><li><p>Let <var>inputValue</var> be ? <var>value</var>.[[Get]](<var>key</var>,
         <var>value</var>).</p></li><li><p>Let <var>outputValue</var> be ?
         <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal-8">StructuredSerializeInternal</a>(<var>inputValue</var>, <var>forStorage</var>,
         <var>memory</var>).</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="structuredserializeinternal:list-append-5" data-x-internal="list-append">Append</a> { [[Key]]: <var>key</var>, [[Value]]:
         <var>outputValue</var> } to <var>serialized</var>.[[Properties]].</p></li></ol>
       </li></ol>
     </li></ol>
   </li><li><p>Return <var>serialized</var>.</p></li></ol>
  </div>

  <div class="example">
   <p>It's important to realize that the <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structuredserializeinternal:record-5" data-x-internal="record">Records</a>
   produced by <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal-9">StructuredSerializeInternal</a> might contain "pointers" to other records
   that create circular references. For example, when we pass the following JavaScript object into
   <a href="#structuredserializeinternal" id="structuredserializeinternal:structuredserializeinternal-10">StructuredSerializeInternal</a>:</p>

  <pre><code class="js"><c- a="">const</c-> o <c- o="">=</c-> <c- p="">{};</c->
o<c- p="">.</c->myself <c- o="">=</c-> o<c- p="">;</c-></code></pre>

  <p>it produces the following result:</p>

  <pre><samp>{
  [[Type]]: "Object",
  [[Properties]]: «
    {
      [[Key]]: "myself",
      [[Value]]: <i>&lt;a pointer to this whole structure&gt;</i>
    }
  »
}</samp></pre>
  </div>


  <div data-algorithm="">
  <h4 id="structuredserialize" data-dfn-type="abstract-op" data-lt="StructuredSerialize"><span class="secno">2.7.4</span> <dfn>StructuredSerialize</dfn> ( <var>value</var> )<a href="#structuredserialize" class="self-link"></a></h4>

  <ol><li><p>Return ? <a href="#structuredserializeinternal" id="structuredserialize:structuredserializeinternal">StructuredSerializeInternal</a>(<var>value</var>, false).</p></li></ol>
  </div>


  <div data-algorithm="">
  <h4 id="structuredserializeforstorage" data-dfn-type="abstract-op" data-lt="StructuredSerializeForStorage"><span class="secno">2.7.5</span> <dfn>StructuredSerializeForStorage</dfn> ( <var>value</var> )<a href="#structuredserializeforstorage" class="self-link"></a></h4>

  <ol><li><p>Return ? <a href="#structuredserializeinternal" id="structuredserializeforstorage:structuredserializeinternal">StructuredSerializeInternal</a>(<var>value</var>, true).</p></li></ol>
  </div>


  <div data-algorithm="">
  <h4 id="structureddeserialize" data-dfn-type="abstract-op" data-lt="StructuredDeserialize"><span class="secno">2.7.6</span> <dfn>StructuredDeserialize</dfn> ( <var>serialized</var>, <var>targetRealm</var> [ ,
  <var>memory</var> ] )<a href="#structureddeserialize" class="self-link"></a></h4>

  <p>The <a href="#structureddeserialize" id="structureddeserialize:structureddeserialize">StructuredDeserialize</a> abstract operation takes as input a <a id="structureddeserialize:record" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a>
  <var>serialized</var>, which was previously produced by <a href="#structuredserialize" id="structureddeserialize:structuredserialize">StructuredSerialize</a> or
  <a href="#structuredserializeforstorage" id="structureddeserialize:structuredserializeforstorage">StructuredSerializeForStorage</a>, and deserializes it into a new JavaScript value,
  created in <var>targetRealm</var>.</p>

  <p>This process can throw an exception, for example when trying to allocate memory for the new
  objects (especially <code>ArrayBuffer</code> objects).</p>

  <ol><li>
    <p>If <var>memory</var> was not supplied, let <var>memory</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-map" id="structureddeserialize:ordered-map" data-x-internal="ordered-map">map</a>.</p>

    <p class="note">The purpose of the <var>memory</var> map is to avoid deserializing objects
    twice. This ends up preserving cycles and the identity of duplicate objects in graphs.</p>
   </li><li><p>If <var>memory</var>[<var>serialized</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="structureddeserialize:map-exists" data-x-internal="map-exists">exists</a>, then
   return <var>memory</var>[<var>serialized</var>].</p></li><li><p>Let <var>deep</var> be false.</p></li><li><p>Let <var>value</var> be an uninitialized value.</p></li><li><p>If <var>serialized</var>.[[Type]] is "primitive", then set <var>value</var> to
   <var>serialized</var>.[[Value]].</p>

   </li><li><p>Otherwise, if <var>serialized</var>.[[Type]] is "Boolean", then set <var>value</var> to a
   new Boolean object in <var>targetRealm</var> whose [[BooleanData]] internal slot value is
   <var>serialized</var>.[[BooleanData]].</p></li><li><p>Otherwise, if <var>serialized</var>.[[Type]] is "Number", then set <var>value</var> to a
   new Number object in <var>targetRealm</var> whose [[NumberData]] internal slot value is
   <var>serialized</var>.[[NumberData]].</p></li><li><p>Otherwise, if <var>serialized</var>.[[Type]] is "BigInt", then set <var>value</var> to a
   new BigInt object in <var>targetRealm</var> whose [[BigIntData]] internal slot value is
   <var>serialized</var>.[[BigIntData]].</p></li><li><p>Otherwise, if <var>serialized</var>.[[Type]] is "String", then set <var>value</var> to a
   new String object in <var>targetRealm</var> whose [[StringData]] internal slot value is
   <var>serialized</var>.[[StringData]].</p></li><li><p>Otherwise, if <var>serialized</var>.[[Type]] is "Date", then set <var>value</var> to a new
   Date object in <var>targetRealm</var> whose [[DateValue]] internal slot value is
   <var>serialized</var>.[[DateValue]].</p></li><li><p>Otherwise, if <var>serialized</var>.[[Type]] is "RegExp", then set <var>value</var> to a
   new RegExp object in <var>targetRealm</var> whose [[RegExpMatcher]] internal slot value is
   <var>serialized</var>.[[RegExpMatcher]], whose [[OriginalSource]] internal slot value is
   <var>serialized</var>.[[OriginalSource]], and whose [[OriginalFlags]] internal slot value is
   <var>serialized</var>.[[OriginalFlags]].</p></li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "SharedArrayBuffer", then:</p>

    <ol><li><p>If <var>targetRealm</var>'s corresponding <a id="structureddeserialize:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a> is not
     <var>serialized</var>.[[AgentCluster]], then throw a
     <a id="structureddeserialize:datacloneerror" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structureddeserialize:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Otherwise, set <var>value</var> to a new SharedArrayBuffer object in
     <var>targetRealm</var> whose [[ArrayBufferData]] internal slot value is
     <var>serialized</var>.[[ArrayBufferData]] and whose [[ArrayBufferByteLength]] internal slot
     value is <var>serialized</var>.[[ArrayBufferByteLength]].</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "GrowableSharedArrayBuffer", then:</p>

    <ol><li><p>If <var>targetRealm</var>'s corresponding <a id="structureddeserialize:agent-cluster-2" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a> is not
     <var>serialized</var>.[[AgentCluster]], then throw a
     <a id="structureddeserialize:datacloneerror-2" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structureddeserialize:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Otherwise, set <var>value</var> to a new SharedArrayBuffer object in
     <var>targetRealm</var> whose [[ArrayBufferData]] internal slot value is
     <var>serialized</var>.[[ArrayBufferData]], whose [[ArrayBufferByteLengthData]] internal slot
     value is <var>serialized</var>.[[ArrayBufferByteLengthData]], and whose
     [[ArrayBufferMaxByteLength]] internal slot value is
     <var>serialized</var>.[[ArrayBufferMaxByteLength]].</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "ArrayBuffer", then set <var>value</var> to a
    new ArrayBuffer object in <var>targetRealm</var> whose [[ArrayBufferData]] internal slot value
    is <var>serialized</var>.[[ArrayBufferData]], and whose [[ArrayBufferByteLength]] internal slot
    value is <var>serialized</var>.[[ArrayBufferByteLength]].</p>

    <p>If this throws an exception, catch it, and then throw a
    <a id="structureddeserialize:datacloneerror-3" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structureddeserialize:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p class="note">This step might throw an exception if there is not enough memory available to
    create such an ArrayBuffer object.</p>
   </li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "ResizableArrayBuffer", then set
    <var>value</var> to a new ArrayBuffer object in <var>targetRealm</var> whose [[ArrayBufferData]]
    internal slot value is <var>serialized</var>.[[ArrayBufferData]], whose
    [[ArrayBufferByteLength]] internal slot value is
    <var>serialized</var>.[[ArrayBufferByteLength]], and whose [[ArrayBufferMaxByteLength]] internal
    slot value is <var>serialized</var>.[[ArrayBufferMaxByteLength]].</p>

    <p>If this throws an exception, catch it, and then throw a
    <a id="structureddeserialize:datacloneerror-4" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structureddeserialize:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p class="note">This step might throw an exception if there is not enough memory available to
    create such an ArrayBuffer object.</p>
   </li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "ArrayBufferView", then:</p>

    <ol><li><p>Let <var>deserializedArrayBuffer</var> be ?
     <a href="#structureddeserialize" id="structureddeserialize:structureddeserialize-2">StructuredDeserialize</a>(<var>serialized</var>.[[ArrayBufferSerialized]],
     <var>targetRealm</var>, <var>memory</var>).</p></li><li><p>If <var>serialized</var>.[[Constructor]] is "DataView", then set <var>value</var> to a
     new DataView object in <var>targetRealm</var> whose [[ViewedArrayBuffer]] internal slot value
     is <var>deserializedArrayBuffer</var>, whose [[ByteLength]] internal slot value is
     <var>serialized</var>.[[ByteLength]], and whose [[ByteOffset]] internal slot value is
     <var>serialized</var>.[[ByteOffset]].</p></li><li><p>Otherwise, set <var>value</var> to a new typed array object in <var>targetRealm</var>,
     using the constructor given by <var>serialized</var>.[[Constructor]], whose
     [[ViewedArrayBuffer]] internal slot value is <var>deserializedArrayBuffer</var>, whose
     [[TypedArrayName]] internal slot value is <var>serialized</var>.[[Constructor]], whose
     [[ByteLength]] internal slot value is <var>serialized</var>.[[ByteLength]], whose
     [[ByteOffset]] internal slot value is <var>serialized</var>.[[ByteOffset]], and whose
     [[ArrayLength]] internal slot value is <var>serialized</var>.[[ArrayLength]].</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "Map", then:</p>

    <ol><li><p>Set <var>value</var> to a new Map object in <var>targetRealm</var> whose [[MapData]]
     internal slot value is a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structureddeserialize:js-list" data-x-internal="js-list">List</a>.</p></li><li><p>Set <var>deep</var> to true.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "Set", then:</p>

    <ol><li><p>Set <var>value</var> to a new Set object in <var>targetRealm</var> whose [[SetData]]
     internal slot value is a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structureddeserialize:js-list-2" data-x-internal="js-list">List</a>.</p></li><li><p>Set <var>deep</var> to true.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "Array", then:</p>

    <ol><li><p>Let <var>outputProto</var> be
     <var>targetRealm</var>.[[Intrinsics]].[[<a id="structureddeserialize:array.prototype" href="https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object" data-x-internal="array.prototype">%Array.prototype%</a>]].</p></li><li><p>Set <var>value</var> to ! <a id="structureddeserialize:arraycreate" href="https://tc39.es/ecma262/#sec-arraycreate" data-x-internal="arraycreate">ArrayCreate</a>(<var>serialized</var>.[[Length]],
     <var>outputProto</var>).</p></li><li><p>Set <var>deep</var> to true.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "Object", then:</p>

    <ol><li><p>Set <var>value</var> to a new Object in <var>targetRealm</var>.</p></li><li><p>Set <var>deep</var> to true.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "Error", then:</p>

    <ol><li><p>Let <var>prototype</var> be <a id="structureddeserialize:error.prototype" href="https://tc39.es/ecma262/#sec-properties-of-the-error-prototype-object" data-x-internal="error.prototype">%Error.prototype%</a>.</p></li><li><p>If <var>serialized</var>.[[Name]] is "EvalError", then set <var>prototype</var> to
     <a href="#evalerror.prototype" id="structureddeserialize:evalerror.prototype">%EvalError.prototype%</a>.</p></li><li><p>If <var>serialized</var>.[[Name]] is "RangeError", then set <var>prototype</var>
     to <a href="#rangeerror.prototype" id="structureddeserialize:rangeerror.prototype">%RangeError.prototype%</a>.</p></li><li><p>If <var>serialized</var>.[[Name]] is "ReferenceError", then set
     <var>prototype</var> to <a href="#referenceerror.prototype" id="structureddeserialize:referenceerror.prototype">%ReferenceError.prototype%</a>.</p></li><li><p>If <var>serialized</var>.[[Name]] is "SyntaxError", then set <var>prototype</var>
     to <a href="#syntaxerror.prototype" id="structureddeserialize:syntaxerror.prototype">%SyntaxError.prototype%</a>.</p></li><li><p>If <var>serialized</var>.[[Name]] is "TypeError", then set <var>prototype</var> to
     <a href="#typeerror.prototype" id="structureddeserialize:typeerror.prototype">%TypeError.prototype%</a>.</p></li><li><p>If <var>serialized</var>.[[Name]] is "URIError", then set <var>prototype</var> to
     <a href="#urierror.prototype" id="structureddeserialize:urierror.prototype">%URIError.prototype%</a>.</p></li><li><p>Let <var>message</var> be <var>serialized</var>.[[Message]].</p></li><li><p>Set <var>value</var> to <a id="structureddeserialize:ordinaryobjectcreate" href="https://tc39.es/ecma262/#sec-objectcreate" data-x-internal="ordinaryobjectcreate">OrdinaryObjectCreate</a>(<var>prototype</var>, «
     [[ErrorData]] »).</p></li><li><p>Let <var>messageDesc</var> be <a id="structureddeserialize:propertydescriptor" href="https://tc39.es/ecma262/#sec-property-descriptor-specification-type" data-x-internal="propertydescriptor">PropertyDescriptor</a> { [[Value]]:
     <var>message</var>, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true
     }.</p></li><li><p>If <var>message</var> is not undefined, then perform !
     <a id="structureddeserialize:ordinarydefineownproperty" href="https://tc39.es/ecma262/#sec-ordinarydefineownproperty" data-x-internal="ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<var>value</var>, "<code>message</code>",
     <var>messageDesc</var>).</p></li><li><p>Any interesting accompanying data attached to <var>serialized</var> should be
     deserialized and attached to <var>value</var>.</p></li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>interfaceName</var> be <var>serialized</var>.[[Type]].</p></li><li><p>If the interface identified by <var>interfaceName</var> is not
     <a href="https://webidl.spec.whatwg.org/#dfn-exposed" id="structureddeserialize:idl-exposed" data-x-internal="idl-exposed">exposed</a> in <var>targetRealm</var>, then throw a
     <a id="structureddeserialize:datacloneerror-5" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structureddeserialize:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>value</var> to a new instance of the interface identified by
     <var>interfaceName</var>, created in <var>targetRealm</var>.</p>

     </li><li><p>Set <var>deep</var> to true.</p></li></ol>
   </li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="structureddeserialize:map-set" data-x-internal="map-set">Set</a> <var>memory</var>[<var>serialized</var>] to
   <var>value</var>.</p></li><li>
    <p>If <var>deep</var> is true, then:</p>

    <ol><li>
      <p>If <var>serialized</var>.[[Type]] is "Map", then:</p>

      <ol><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structureddeserialize:list-iterate" data-x-internal="list-iterate">For each</a> <a id="structureddeserialize:record-2" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> { [[Key]], [[Value]] }
        <var>entry</var> of <var>serialized</var>.[[MapData]]:</p>

        <ol><li><p>Let <var>deserializedKey</var> be ?
         <a href="#structureddeserialize" id="structureddeserialize:structureddeserialize-3">StructuredDeserialize</a>(<var>entry</var>.[[Key]], <var>targetRealm</var>,
         <var>memory</var>).</p></li><li><p>Let <var>deserializedValue</var> be ?
         <a href="#structureddeserialize" id="structureddeserialize:structureddeserialize-4">StructuredDeserialize</a>(<var>entry</var>.[[Value]], <var>targetRealm</var>,
         <var>memory</var>).</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="structureddeserialize:list-append" data-x-internal="list-append">Append</a> { [[Key]]: <var>deserializedKey</var>,
         [[Value]]: <var>deserializedValue</var> } to <var>value</var>.[[MapData]].</p></li></ol>
       </li></ol>
     </li><li>
      <p>Otherwise, if <var>serialized</var>.[[Type]] is "Set", then:</p>

      <ol><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structureddeserialize:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>entry</var> of
        <var>serialized</var>.[[SetData]]:</p>

        <ol><li><p>Let <var>deserializedEntry</var> be ?
         <a href="#structureddeserialize" id="structureddeserialize:structureddeserialize-5">StructuredDeserialize</a>(<var>entry</var>, <var>targetRealm</var>,
         <var>memory</var>).</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="structureddeserialize:list-append-2" data-x-internal="list-append">Append</a> <var>deserializedEntry</var> to
         <var>value</var>.[[SetData]].</p></li></ol>
       </li></ol>
     </li><li>
      <p>Otherwise, if <var>serialized</var>.[[Type]] is "Array" or "Object", then:</p>

      <ol><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structureddeserialize:list-iterate-3" data-x-internal="list-iterate">For each</a> <a id="structureddeserialize:record-3" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> { [[Key]], [[Value]] }
        <var>entry</var> of <var>serialized</var>.[[Properties]]:</p>

        <ol><li><p>Let <var>deserializedValue</var> be ?
         <a href="#structureddeserialize" id="structureddeserialize:structureddeserialize-6">StructuredDeserialize</a>(<var>entry</var>.[[Value]], <var>targetRealm</var>,
         <var>memory</var>).</p></li><li><p>Let <var>result</var> be ! <a id="structureddeserialize:createdataproperty" href="https://tc39.es/ecma262/#sec-createdataproperty" data-x-internal="createdataproperty">CreateDataProperty</a>(<var>value</var>,
         <var>entry</var>.[[Key]], <var>deserializedValue</var>).</p></li><li><p><a id="structureddeserialize:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>result</var> is true.</p></li></ol>
       </li></ol>
     </li><li>
      <p>Otherwise:</p>

      <ol><li>
        <p>Perform the appropriate <a href="#deserialization-steps" id="structureddeserialize:deserialization-steps">deserialization steps</a> for the interface identified
        by <var>serialized</var>.[[Type]], given <var>serialized</var>, <var>value</var>, and
        <var>targetRealm</var>.</p>

        <p>The <a href="#deserialization-steps" id="structureddeserialize:deserialization-steps-2">deserialization steps</a> may need to perform a <dfn id="sub-deserialization" data-export="">sub-deserialization</dfn>. This is an operation which takes as input a
        previously-serialized <a id="structureddeserialize:record-4" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> <var>subSerialized</var>, and returns
        <a href="#structureddeserialize" id="structureddeserialize:structureddeserialize-7">StructuredDeserialize</a>(<var>subSerialized</var>, <var>targetRealm</var>,
        <var>memory</var>). (In other words, a <a href="#sub-deserialization" id="structureddeserialize:sub-deserialization">sub-deserialization</a> is a specialization
        of <a href="#structureddeserialize" id="structureddeserialize:structureddeserialize-8">StructuredDeserialize</a> to be consistent within this invocation.)</p>
       </li></ol>
    </li></ol>
   </li><li><p>Return <var>value</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h4 id="structuredserializewithtransfer" data-dfn-type="abstract-op" data-lt="StructuredSerializeWithTransfer"><span class="secno">2.7.7</span> <dfn>StructuredSerializeWithTransfer</dfn> ( <var>value</var>, <var>transferList</var>
  )<a href="#structuredserializewithtransfer" class="self-link"></a></h4>

  <ol><li>
    <p>Let <var>memory</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-map" id="structuredserializewithtransfer:ordered-map" data-x-internal="ordered-map">map</a>.</p>

    <p class="note">In addition to how it is used normally by
    <a href="#structuredserializeinternal" id="structuredserializewithtransfer:structuredserializeinternal">StructuredSerializeInternal</a>, in this algorithm <var>memory</var> is also used to
    ensure that <a href="#structuredserializeinternal" id="structuredserializewithtransfer:structuredserializeinternal-2">StructuredSerializeInternal</a> ignores items in <var>transferList</var>,
    and let us do our own handling instead.</p>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structuredserializewithtransfer:list-iterate" data-x-internal="list-iterate">For each</a> <var>transferable</var> of
    <var>transferList</var>:</p>

    <ol><li><p>If <var>transferable</var> has neither an [[ArrayBufferData]] internal slot nor a
     <a href="#detached" id="structuredserializewithtransfer:detached">[[Detached]]</a> internal slot, then throw a
     <a id="structuredserializewithtransfer:datacloneerror" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializewithtransfer:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>transferable</var> has an [[ArrayBufferData]] internal slot and
     <a id="structuredserializewithtransfer:issharedarraybuffer" href="https://tc39.es/ecma262/#sec-issharedarraybuffer" data-x-internal="issharedarraybuffer">IsSharedArrayBuffer</a>(<var>transferable</var>) is true, then throw a
     <a id="structuredserializewithtransfer:datacloneerror-2" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializewithtransfer:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>memory</var>[<var>transferable</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="structuredserializewithtransfer:map-exists" data-x-internal="map-exists">exists</a>,
     then throw a <a id="structuredserializewithtransfer:datacloneerror-3" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializewithtransfer:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#map-set" id="structuredserializewithtransfer:map-set" data-x-internal="map-set">Set</a> <var>memory</var>[<var>transferable</var>] to {
      [[Type]]: an uninitialized value }.</p>

      <p class="note"><var>transferable</var> is not transferred yet as transferring has side
      effects and <a href="#structuredserializeinternal" id="structuredserializewithtransfer:structuredserializeinternal-3">StructuredSerializeInternal</a> needs to be able to throw first.</p>
     </li></ol>
   </li><li><p>Let <var>serialized</var> be ? <a href="#structuredserializeinternal" id="structuredserializewithtransfer:structuredserializeinternal-4">StructuredSerializeInternal</a>(<var>value</var>,
   false, <var>memory</var>).</p></li><li><p>Let <var>transferDataHolders</var> be a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structuredserializewithtransfer:js-list" data-x-internal="js-list">List</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structuredserializewithtransfer:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>transferable</var> of
    <var>transferList</var>:</p>

    <ol><li><p>If <var>transferable</var> has an [[ArrayBufferData]] internal slot and
     <a id="structuredserializewithtransfer:isdetachedbuffer" href="https://tc39.es/ecma262/#sec-isdetachedbuffer" data-x-internal="isdetachedbuffer">IsDetachedBuffer</a>(<var>transferable</var>) is true, then throw a
     <a id="structuredserializewithtransfer:datacloneerror-4" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializewithtransfer:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>transferable</var> has a <a href="#detached" id="structuredserializewithtransfer:detached-2">[[Detached]]</a> internal slot and
     <var>transferable</var>.<a href="#detached" id="structuredserializewithtransfer:detached-3">[[Detached]]</a> is true, then throw a
     <a id="structuredserializewithtransfer:datacloneerror-5" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structuredserializewithtransfer:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>dataHolder</var> be <var>memory</var>[<var>transferable</var>].</p></li><li>
      <p>If <var>transferable</var> has an [[ArrayBufferData]] internal slot, then:</p>

      <ol><li>
        <p>If <var>transferable</var> has an [[ArrayBufferMaxByteLength]] internal slot, then:</p>

        <ol><li><p>Set <var>dataHolder</var>.[[Type]] to "ResizableArrayBuffer".</p></li><li><p>Set <var>dataHolder</var>.[[ArrayBufferData]] to
         <var>transferable</var>.[[ArrayBufferData]].</p></li><li><p>Set <var>dataHolder</var>.[[ArrayBufferByteLength]] to
         <var>transferable</var>.[[ArrayBufferByteLength]].</p></li><li><p>Set <var>dataHolder</var>.[[ArrayBufferMaxByteLength]] to
         <var>transferable</var>.[[ArrayBufferMaxByteLength]].</p></li></ol>
       </li><li>
        <p>Otherwise:</p>

        <ol><li><p>Set <var>dataHolder</var>.[[Type]] to "ArrayBuffer".</p></li><li><p>Set <var>dataHolder</var>.[[ArrayBufferData]] to
         <var>transferable</var>.[[ArrayBufferData]].</p></li><li><p>Set <var>dataHolder</var>.[[ArrayBufferByteLength]] to
         <var>transferable</var>.[[ArrayBufferByteLength]].</p></li></ol>
       </li><li>
        <p>Perform ? <a id="structuredserializewithtransfer:detacharraybuffer" href="https://tc39.es/ecma262/#sec-detacharraybuffer" data-x-internal="detacharraybuffer">DetachArrayBuffer</a>(<var>transferable</var>).</p>

        <p class="note">Specifications can use the [[ArrayBufferDetachKey]] internal slot to prevent
        <code id="structuredserializewithtransfer:idl-arraybuffer"><a data-x-internal="idl-arraybuffer" href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer">ArrayBuffer</a></code>s from being detached. This is used in
        <cite>WebAssembly JavaScript Interface</cite>, for example. <a href="#refsWASMJS">[WASMJS]</a></p>
       </li></ol>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p><a id="structuredserializewithtransfer:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>transferable</var> is a <a id="structuredserializewithtransfer:platform-object" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> that is
       a <a href="#transferable-objects" id="structuredserializewithtransfer:transferable-objects">transferable object</a>.</p></li><li><p>Let <var>interfaceName</var> be the identifier of the <a id="structuredserializewithtransfer:primary-interface" href="https://webidl.spec.whatwg.org/#dfn-primary-interface" data-x-internal="primary-interface">primary interface</a>
       of <var>transferable</var>.</p></li><li><p>Set <var>dataHolder</var>.[[Type]] to <var>interfaceName</var>.</p></li><li><p>Perform the appropriate <a href="#transfer-steps" id="structuredserializewithtransfer:transfer-steps">transfer steps</a> for the interface identified by
       <var>interfaceName</var>, given <var>transferable</var> and <var>dataHolder</var>.</p></li><li><p>Set <var>transferable</var>.<a href="#detached" id="structuredserializewithtransfer:detached-4">[[Detached]]</a> to true.</p></li></ol>
     </li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="structuredserializewithtransfer:list-append" data-x-internal="list-append">Append</a> <var>dataHolder</var> to
     <var>transferDataHolders</var>.</p></li></ol>
   </li><li><p>Return { [[Serialized]]: <var>serialized</var>, [[TransferDataHolders]]:
   <var>transferDataHolders</var> }.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h4 id="structureddeserializewithtransfer" data-dfn-type="abstract-op" data-lt="StructuredDeserializeWithTransfer"><span class="secno">2.7.8</span> <dfn>StructuredDeserializeWithTransfer</dfn> ( <var>serializeWithTransferResult</var>,
  <var>targetRealm</var> )<a href="#structureddeserializewithtransfer" class="self-link"></a></h4>

  <ol><li>
    <p>Let <var>memory</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-map" id="structureddeserializewithtransfer:ordered-map" data-x-internal="ordered-map">map</a>.</p>

    <p class="note">Analogous to <a href="#structuredserializewithtransfer" id="structureddeserializewithtransfer:structuredserializewithtransfer">StructuredSerializeWithTransfer</a>, in addition to how it
    is used normally by <a href="#structureddeserialize" id="structureddeserializewithtransfer:structureddeserialize">StructuredDeserialize</a>, in this algorithm <var>memory</var> is
    also used to ensure that <a href="#structureddeserialize" id="structureddeserializewithtransfer:structureddeserialize-2">StructuredDeserialize</a> ignores items in
    <var>serializeWithTransferResult</var>.[[TransferDataHolders]], and let us do our own handling
    instead.</p>
   </li><li><p>Let <var>transferredValues</var> be a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="structureddeserializewithtransfer:js-list" data-x-internal="js-list">List</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="structureddeserializewithtransfer:list-iterate" data-x-internal="list-iterate">For each</a> <var>transferDataHolder</var> of
    <var>serializeWithTransferResult</var>.[[TransferDataHolders]]:</p>

    <ol><li><p>Let <var>value</var> be an uninitialized value.</p></li><li>
      <p>If <var>transferDataHolder</var>.[[Type]] is "ArrayBuffer", then set <var>value</var> to a
      new ArrayBuffer object in <var>targetRealm</var> whose [[ArrayBufferData]] internal slot value
      is <var>transferDataHolder</var>.[[ArrayBufferData]], and whose [[ArrayBufferByteLength]]
      internal slot value is <var>transferDataHolder</var>.[[ArrayBufferByteLength]].</p>

      <p class="note">In cases where the original memory occupied by [[ArrayBufferData]] is
      accessible during the deserialization, this step is unlikely to throw an exception, as no new
      memory needs to be allocated: the memory occupied by [[ArrayBufferData]] is instead just
      getting transferred into the new ArrayBuffer. This could be true, for example, when both the
      source and target realms are in the same process.</p>
     </li><li>
      <p>Otherwise, if <var>transferDataHolder</var>.[[Type]] is "ResizableArrayBuffer", then set
      <var>value</var> to a new ArrayBuffer object in <var>targetRealm</var> whose
      [[ArrayBufferData]] internal slot value is <var>transferDataHolder</var>.[[ArrayBufferData]],
      whose [[ArrayBufferByteLength]] internal slot value is
      <var>transferDataHolder</var>.[[ArrayBufferByteLength]], and whose
      [[ArrayBufferMaxByteLength]] internal slot value is
      <var>transferDataHolder</var>.[[ArrayBufferMaxByteLength]].</p>

      <p class="note">For the same reason as the previous step, this step is also unlikely to throw
      an exception.</p>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p>Let <var>interfaceName</var> be <var>transferDataHolder</var>.[[Type]].</p></li><li><p>If the interface identified by <var>interfaceName</var> is not exposed in
       <var>targetRealm</var>, then throw a <a id="structureddeserializewithtransfer:datacloneerror" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a>
       <code id="structureddeserializewithtransfer:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>value</var> to a new instance of the interface identified by
       <var>interfaceName</var>, created in <var>targetRealm</var>.</p></li><li><p>Perform the appropriate <a href="#transfer-receiving-steps" id="structureddeserializewithtransfer:transfer-receiving-steps">transfer-receiving steps</a> for the interface
       identified by <var>interfaceName</var> given <var>transferDataHolder</var> and
       <var>value</var>.</p></li></ol>
     </li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="structureddeserializewithtransfer:map-set" data-x-internal="map-set">Set</a> <var>memory</var>[<var>transferDataHolder</var>] to
     <var>value</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="structureddeserializewithtransfer:list-append" data-x-internal="list-append">Append</a> <var>value</var> to
     <var>transferredValues</var>.</p></li></ol>
   </li><li><p>Let <var>deserialized</var> be ?
   <a href="#structureddeserialize" id="structureddeserializewithtransfer:structureddeserialize-3">StructuredDeserialize</a>(<var>serializeWithTransferResult</var>.[[Serialized]],
   <var>targetRealm</var>, <var>memory</var>).</p></li><li><p>Return { [[Deserialized]]: <var>deserialized</var>, [[TransferredValues]]:
   <var>transferredValues</var> }.</p></li></ol>
  </div>


  <h4 id="performing-structured-clones-from-other-specifications"><span class="secno">2.7.9</span> Performing serialization and
  transferring from other specifications<a href="#performing-structured-clones-from-other-specifications" class="self-link"></a></h4>

  <p>Other specifications may use the abstract operations defined here. The following provides
  some guidance on when each abstract operation is typically useful, with examples.</p>

  <dl><dt><a href="#structuredserializewithtransfer" id="performing-structured-clones-from-other-specifications:structuredserializewithtransfer">StructuredSerializeWithTransfer</a></dt><dt><a href="#structureddeserializewithtransfer" id="performing-structured-clones-from-other-specifications:structureddeserializewithtransfer">StructuredDeserializeWithTransfer</a></dt><dd>
    <p>Cloning a value to another <a id="performing-structured-clones-from-other-specifications:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>, with a transfer list, but where the target
    realm is not known ahead of time. In this case the serialization step can be performed
    immediately, with the deserialization step delayed until the target realm becomes known.</p>

    <p class="example"><code id="performing-structured-clones-from-other-specifications:dom-messageport-postmessage"><a href="#dom-messageport-postmessage">messagePort.postMessage()</a></code>
    uses this pair of abstract operations, as the destination realm is not known until the
    <code id="performing-structured-clones-from-other-specifications:messageport"><a href="#messageport">MessagePort</a></code> <a href="#has-been-shipped" id="performing-structured-clones-from-other-specifications:has-been-shipped">has been shipped</a>.</p>
   </dd><dt><a href="#structuredserialize" id="performing-structured-clones-from-other-specifications:structuredserialize">StructuredSerialize</a></dt><dt><a href="#structuredserializeforstorage" id="performing-structured-clones-from-other-specifications:structuredserializeforstorage">StructuredSerializeForStorage</a></dt><dt><a href="#structureddeserialize" id="performing-structured-clones-from-other-specifications:structureddeserialize">StructuredDeserialize</a></dt><dd>
    <p>Creating a <a id="performing-structured-clones-from-other-specifications:realm-2" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>-independent snapshot of a given value which can be saved for an
    indefinite amount of time, and then reified back into a JavaScript value later, possibly
    multiple times.</p>

    <p><a href="#structuredserializeforstorage" id="performing-structured-clones-from-other-specifications:structuredserializeforstorage-2">StructuredSerializeForStorage</a> can be used for situations where the serialization
    is anticipated to be stored in a persistent manner, instead of passed between realms. It throws
    when attempting to serialize <code id="performing-structured-clones-from-other-specifications:sharedarraybuffer"><a data-x-internal="sharedarraybuffer" href="https://tc39.es/ecma262/#sec-sharedarraybuffer-objects">SharedArrayBuffer</a></code> objects, since storing shared memory
    does not make sense. Similarly, it can throw or possibly have different behavior when given a
    <a id="performing-structured-clones-from-other-specifications:platform-object" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> with custom <a href="#serialization-steps" id="performing-structured-clones-from-other-specifications:serialization-steps">serialization steps</a> when the
    <var>forStorage</var> argument is true.</p>

    <p class="example"><code id="performing-structured-clones-from-other-specifications:dom-history-pushstate"><a href="#dom-history-pushstate">history.pushState()</a></code> and <code id="performing-structured-clones-from-other-specifications:dom-history-replacestate"><a href="#dom-history-replacestate">history.replaceState()</a></code> use
    <a href="#structuredserializeforstorage" id="performing-structured-clones-from-other-specifications:structuredserializeforstorage-3">StructuredSerializeForStorage</a> on author-supplied state objects, storing them as
    <a href="#serialized-state" id="performing-structured-clones-from-other-specifications:serialized-state">serialized state</a> in the appropriate <a href="#session-history-entry" id="performing-structured-clones-from-other-specifications:session-history-entry">session history entry</a>. Then,
    <a href="#structureddeserialize" id="performing-structured-clones-from-other-specifications:structureddeserialize-2">StructuredDeserialize</a> is used so that the <code id="performing-structured-clones-from-other-specifications:dom-history-state"><a href="#dom-history-state">history.state</a></code> property can return a clone of the
    originally-supplied state object.</p>

    <p class="example"><code id="performing-structured-clones-from-other-specifications:dom-broadcastchannel-postmessage"><a href="#dom-broadcastchannel-postmessage">broadcastChannel.postMessage()</a></code> uses
    <a href="#structuredserialize" id="performing-structured-clones-from-other-specifications:structuredserialize-2">StructuredSerialize</a> on its input, then uses <a href="#structureddeserialize" id="performing-structured-clones-from-other-specifications:structureddeserialize-3">StructuredDeserialize</a>
    multiple times on the result to produce a fresh clone for each destination being broadcast
    to. Note that transferring does not make sense in multi-destination situations.</p>

    <p class="example">Any API for persisting JavaScript values to the filesystem would also use
    <a href="#structuredserializeforstorage" id="performing-structured-clones-from-other-specifications:structuredserializeforstorage-4">StructuredSerializeForStorage</a> on its input and <a href="#structureddeserialize" id="performing-structured-clones-from-other-specifications:structureddeserialize-4">StructuredDeserialize</a>
    on its output.</p>
   </dd></dl>

  <p>In general, call sites may pass in Web IDL values instead of JavaScript values; this is to be
  understood to perform an implicit <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="performing-structured-clones-from-other-specifications:concept-idl-convert" data-x-internal="concept-idl-convert">conversion</a> to the
  JavaScript value before invoking these algorithms.</p>

  <hr>

  <p>Call sites that are not invoked as a result of author code synchronously calling into a user
  agent method must take care to properly <a href="#prepare-to-run-script" id="performing-structured-clones-from-other-specifications:prepare-to-run-script">prepare to run script</a> and <a href="#prepare-to-run-a-callback" id="performing-structured-clones-from-other-specifications:prepare-to-run-a-callback">prepare to
  run a callback</a> before invoking <a href="#structuredserialize" id="performing-structured-clones-from-other-specifications:structuredserialize-3">StructuredSerialize</a>,
  <a href="#structuredserializeforstorage" id="performing-structured-clones-from-other-specifications:structuredserializeforstorage-5">StructuredSerializeForStorage</a>, or <a href="#structuredserializewithtransfer" id="performing-structured-clones-from-other-specifications:structuredserializewithtransfer-2">StructuredSerializeWithTransfer</a>
  abstract operations, if they are being performed on arbitrary objects. This is necessary because
  the serialization process can invoke author-defined accessors as part of its final
  deep-serialization steps, and these accessors could call into operations that rely on the <a href="#concept-entry-everything" id="performing-structured-clones-from-other-specifications:concept-entry-everything">entry</a> and <a href="#concept-incumbent-everything" id="performing-structured-clones-from-other-specifications:concept-incumbent-everything">incumbent</a> concepts being properly set up.</p>

  <p class="example"><code id="performing-structured-clones-from-other-specifications:dom-window-postmessage"><a href="#dom-window-postmessage">window.postMessage()</a></code> performs
  <a href="#structuredserializewithtransfer" id="performing-structured-clones-from-other-specifications:structuredserializewithtransfer-3">StructuredSerializeWithTransfer</a> on its arguments, but is careful to do so
  immediately, inside the synchronous portion of its algorithm. Thus it is able to use the
  algorithms without needing to <a href="#prepare-to-run-script" id="performing-structured-clones-from-other-specifications:prepare-to-run-script-2">prepare to run script</a> and <a href="#prepare-to-run-a-callback" id="performing-structured-clones-from-other-specifications:prepare-to-run-a-callback-2">prepare to run a
  callback</a>.</p>

  <p class="example">In contrast, a hypothetical API that used <a href="#structuredserialize" id="performing-structured-clones-from-other-specifications:structuredserialize-4">StructuredSerialize</a> to
  serialize some author-supplied object periodically, directly from a <a href="#concept-task" id="performing-structured-clones-from-other-specifications:concept-task">task</a> on the <a href="#event-loop" id="performing-structured-clones-from-other-specifications:event-loop">event loop</a>, would need to ensure it performs
  the appropriate preparations beforehand. As of this time, we know of no such APIs on the platform;
  usually it is simpler to perform the serialization ahead of time, as a synchronous consequence of
  author code.</p>

  

  <h4 id="structured-cloning"><span class="secno">2.7.10</span> Structured cloning API<a href="#structured-cloning" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>result</var> = self.<a href="#dom-structuredclone" id="dom-structuredclone-dev">structuredClone</a>(<var>value</var>[, { <a href="#dom-structuredserializeoptions-transfer" id="structured-cloning:dom-structuredserializeoptions-transfer">transfer</a> }])</code></dt><dd>
    <p>Takes the input value and returns a deep copy by performing the structured clone algorithm.
    <a href="#transferable-objects" id="structured-cloning:transferable-objects">Transferable objects</a> listed in the <code id="structured-cloning:dom-structuredserializeoptions-transfer-2"><a href="#dom-structuredserializeoptions-transfer">transfer</a></code> array are transferred, not
    just cloned, meaning that they are no longer usable in the input value.</p>

    <p>Throws a <a id="structured-cloning:datacloneerror" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="structured-cloning:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if any part of
    the input value is not <a href="#serializable-objects" id="structured-cloning:serializable-objects">serializable</a>.</p>
   </dd></dl>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/structuredClone" title="The global structuredClone() method creates a deep clone of a given value using the structured clone algorithm.">structuredClone</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>94+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>98+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>98+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-structuredclone" data-dfn-type="method"><code>structuredClone(<var>value</var>,
  <var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>serialized</var> be ?
   <a href="#structuredserializewithtransfer" id="structured-cloning:structuredserializewithtransfer">StructuredSerializeWithTransfer</a>(<var>value</var>, <var>options</var>["<code id="structured-cloning:dom-structuredserializeoptions-transfer-3"><a href="#dom-structuredserializeoptions-transfer">transfer</a></code>"]).</p></li><li><p>Let <var>deserializeRecord</var> be ?
   <a href="#structureddeserializewithtransfer" id="structured-cloning:structureddeserializewithtransfer">StructuredDeserializeWithTransfer</a>(<var>serialized</var>, <a id="structured-cloning:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a href="#concept-relevant-realm" id="structured-cloning:concept-relevant-realm">relevant realm</a>).</p></li><li><p>Return <var>deserializeRecord</var>.[[Deserialized]].</p></li></ol>
  </div>

  


  <h2 id="dom"><span class="secno">3</span> Semantics, structure, and APIs of HTML documents<a href="#dom" class="self-link"></a></h2>

  <h3 id="documents"><span class="secno">3.1</span> Documents<a href="#documents" class="self-link"></a></h3>

  <p>Every XML and HTML document in an HTML UA is represented by a <code id="documents:document"><a href="#document">Document</a></code> object.
  <a href="#refsDOM">[DOM]</a></p>

  <p>The <code id="documents:document-2"><a href="#document">Document</a></code> object's <dfn id="the-document's-address"><a href="https://dom.spec.whatwg.org/#concept-document-url">URL</a></dfn> is defined in
  <cite>DOM</cite>. It is initially set when the <code id="documents:document-3"><a href="#document">Document</a></code> object is created, but can
  change during the lifetime of the <code id="documents:document-4"><a href="#document">Document</a></code> object; for example, it changes when the
  user <a href="#navigate" id="documents:navigate">navigates</a> to a <a href="#navigate-fragid" id="documents:navigate-fragid">fragment</a>
  on the page and when the <code id="documents:dom-history-pushstate"><a href="#dom-history-pushstate">pushState()</a></code> method is called
  with a new <a id="documents:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>. <a href="#refsDOM">[DOM]</a></p>
  

  <p class="warning">Interactive user agents typically expose the <code id="documents:document-5"><a href="#document">Document</a></code> object's
  <a href="https://dom.spec.whatwg.org/#concept-document-url" id="documents:the-document's-address" data-x-internal="the-document's-address">URL</a> in their user interface. This is the primary
  mechanism by which a user can tell if a site is attempting to impersonate another.</p>

  <p>The <code id="documents:document-6"><a href="#document">Document</a></code> object's <dfn id="concept-document-origin"><a href="https://dom.spec.whatwg.org/#concept-document-origin">origin</a></dfn> is defined in
  <cite>DOM</cite>. It is initially set when the <code id="documents:document-7"><a href="#document">Document</a></code> object is created, and can
  change during the lifetime of the <code id="documents:document-8"><a href="#document">Document</a></code> only upon setting <code id="documents:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code>. A <code id="documents:document-9"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="documents:concept-document-origin" data-x-internal="concept-document-origin">origin</a> can differ from the <a href="https://url.spec.whatwg.org/#concept-url-origin" id="documents:concept-url-origin" data-x-internal="concept-url-origin">origin</a> of its <a href="https://dom.spec.whatwg.org/#concept-document-url" id="documents:the-document's-address-2" data-x-internal="the-document's-address">URL</a>;
  for example when a <a href="#child-navigable" id="documents:child-navigable">child navigable</a> is <a href="#create-a-new-child-navigable" id="documents:create-a-new-child-navigable">created</a>, its <a href="#nav-document" id="documents:nav-document">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="documents:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> is inherited from its <a href="#nav-parent" id="documents:nav-parent">parent</a>'s <a href="#nav-document" id="documents:nav-document-2">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="documents:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a>, even though its <a href="#nav-document" id="documents:nav-document-3">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="documents:the-document's-address-3" data-x-internal="the-document's-address">URL</a> is
  <code id="documents:about:blank"><a href="#about:blank">about:blank</a></code>. <a href="#refsDOM">[DOM]</a></p>

  <p>When a <code id="documents:document-10"><a href="#document">Document</a></code> is created by a <a href="#concept-script" id="documents:concept-script">script</a> using
  the <code id="documents:dom-domimplementation-createdocument"><a data-x-internal="dom-domimplementation-createdocument" href="https://dom.spec.whatwg.org/#dom-domimplementation-createdocument">createDocument()</a></code> or <code id="documents:dom-domimplementation-createhtmldocument"><a data-x-internal="dom-domimplementation-createhtmldocument" href="https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument">createHTMLDocument()</a></code> methods, the
  <code id="documents:document-11"><a href="#document">Document</a></code> is <a href="#ready-for-post-load-tasks" id="documents:ready-for-post-load-tasks">ready for post-load tasks</a> immediately.</p>

  <p><dfn id="the-document's-referrer" data-export="">The document's referrer</dfn> is a string (representing a <a id="documents:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>) that
  can be set when the <code id="documents:document-12"><a href="#document">Document</a></code> is created. If it is not explicitly set, then its value
  is the empty string.</p>


  <h4 id="the-document-object"><span class="secno">3.1.1</span> The <code id="the-document-object:document"><a href="#document">Document</a></code> object<a href="#the-document-object" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document" title="The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.">Document</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <p><cite>DOM</cite> defines a <code id="the-document-object:dom-document"><a data-x-internal="dom-document" href="https://dom.spec.whatwg.org/#interface-document">Document</a></code> interface, which
  this specification extends significantly.</p>

  <pre><code class="idl"><c- b="">enum</c-> <dfn id="documentreadystate" data-dfn-type="enum"><c- g="">DocumentReadyState</c-></dfn> { <c- s="">"loading"</c->, <c- s="">"interactive"</c->, <c- s="">"complete"</c-> };
<c- b="">enum</c-> <dfn id="documentvisibilitystate" data-dfn-type="enum"><c- g="">DocumentVisibilityState</c-></dfn> { <c- s="">"visible"</c->, <c- s="">"hidden"</c-> };
<c- b="">typedef</c-> (<a href="#htmlscriptelement" id="the-document-object:htmlscriptelement"><c- n="">HTMLScriptElement</c-></a> <c- b="">or</c-> <a id="the-document-object:svgscriptelement" href="https://svgwg.org/svg2-draft/interact.html#InterfaceSVGScriptElement" data-x-internal="svgscriptelement"><c- n="">SVGScriptElement</c-></a>) <dfn id="htmlorsvgscriptelement" data-dfn-type="typedef"><c- g="">HTMLOrSVGScriptElement</c-></dfn>;

[<a id="the-document-object:legacyoverridebuiltins" href="https://webidl.spec.whatwg.org/#LegacyOverrideBuiltIns" data-x-internal="legacyoverridebuiltins"><c- g="">LegacyOverrideBuiltIns</c-></a>]
<c- b="">partial</c-> <c- b="">interface</c-> <dfn data-lt="" id="document"><c- g="">Document</c-></dfn> {
  <c- b="">static</c-> <code id="the-document-object:document-2"><a href="#document"><c- n="">Document</c-></a></code> <a href="#dom-parsehtmlunsafe" id="the-document-object:dom-parsehtmlunsafe"><c- g="">parseHTMLUnsafe</c-></a>((<code id="the-document-object:tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> <c- b="">DOMString</c->) <c- g="">html</c->);

  // <a href="#resource-metadata-management" id="the-document-object:resource-metadata-management">resource metadata management</a>
  [<c- g="">PutForwards</c->=<a href="#dom-location-href" id="the-document-object:dom-location-href"><c- n="">href</c-></a>, <a id="the-document-object:legacyunforgeable" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#location" id="the-document-object:location"><c- n="">Location</c-></a>? <a href="#dom-document-location" id="the-document-object:dom-document-location"><c- g="">location</c-></a>;
  <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-document-domain" id="the-document-object:dom-document-domain"><c- g="">domain</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-document-referrer" id="the-document-object:dom-document-referrer"><c- g="">referrer</c-></a>;
  <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-document-cookie" id="the-document-object:dom-document-cookie"><c- g="">cookie</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-document-lastmodified" id="the-document-object:dom-document-lastmodified"><c- g="">lastModified</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#documentreadystate" id="the-document-object:documentreadystate"><c- n="">DocumentReadyState</c-></a> <a href="#dom-document-readystate" id="the-document-object:dom-document-readystate"><c- g="">readyState</c-></a>;

  // <a href="#dom-tree-accessors" id="the-document-object:dom-tree-accessors">DOM tree accessors</a>
  <a href="#dom-document-nameditem"><c- b="">getter</c-></a> <c- b="">object</c-> (<c- b="">DOMString</c-> <c- g="">name</c->);
  [<a href="#cereactions" id="the-document-object:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#document.title" id="the-document-object:document.title"><c- g="">title</c-></a>;
  [<a href="#cereactions" id="the-document-object:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-document-dir" id="the-document-object:dom-document-dir"><c- g="">dir</c-></a>;
  [<a href="#cereactions" id="the-document-object:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <a href="#htmlelement" id="the-document-object:htmlelement"><c- n="">HTMLElement</c-></a>? <a href="#dom-document-body" id="the-document-object:dom-document-body"><c- g="">body</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlheadelement" id="the-document-object:htmlheadelement"><c- n="">HTMLHeadElement</c-></a>? <a href="#dom-document-head" id="the-document-object:dom-document-head"><c- g="">head</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-document-object:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-document-images" id="the-document-object:dom-document-images"><c- g="">images</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-document-object:htmlcollection-2" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-document-embeds" id="the-document-object:dom-document-embeds"><c- g="">embeds</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-document-object:htmlcollection-3" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-document-plugins" id="the-document-object:dom-document-plugins"><c- g="">plugins</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-document-object:htmlcollection-4" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-document-links" id="the-document-object:dom-document-links"><c- g="">links</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-document-object:htmlcollection-5" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-document-forms" id="the-document-object:dom-document-forms"><c- g="">forms</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-document-object:htmlcollection-6" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-document-scripts" id="the-document-object:dom-document-scripts"><c- g="">scripts</c-></a>;
  <c- n="">NodeList</c-> <a href="#dom-document-getelementsbyname" id="the-document-object:dom-document-getelementsbyname"><c- g="">getElementsByName</c-></a>(<c- b="">DOMString</c-> <c- g="">elementName</c->);
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlorsvgscriptelement" id="the-document-object:htmlorsvgscriptelement"><c- n="">HTMLOrSVGScriptElement</c-></a>? <a href="#dom-document-currentscript" id="the-document-object:dom-document-currentscript"><c- g="">currentScript</c-></a>; // classic scripts in a document tree only

  // <a href="#dynamic-markup-insertion" id="the-document-object:dynamic-markup-insertion">dynamic markup insertion</a>
  [<a href="#cereactions" id="the-document-object:cereactions-4"><c- g="">CEReactions</c-></a>] <a href="#document" id="the-document-object:document-3"><c- n="">Document</c-></a> <a href="#dom-document-open" id="the-document-object:dom-document-open"><c- g="">open</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">unused1</c->, <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">unused2</c->); // both arguments are <a href="#dom-document-open-unused-arguments">ignored</a>
  <a href="#windowproxy" id="the-document-object:windowproxy"><c- n="">WindowProxy</c-></a>? <a href="#dom-document-open-window" id="the-document-object:dom-document-open-window"><c- g="">open</c-></a>(<c- b="">USVString</c-> <c- g="">url</c->, <c- b="">DOMString</c-> <c- g="">name</c->, <c- b="">DOMString</c-> <c- g="">features</c->);
  [<a href="#cereactions" id="the-document-object:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-document-close" id="the-document-object:dom-document-close"><c- g="">close</c-></a>();
  [<a href="#cereactions" id="the-document-object:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-document-write" id="the-document-object:dom-document-write"><c- g="">write</c-></a>((<code id="the-document-object:tt-trustedhtml-2"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> <c- b="">DOMString</c->)... <c- g="">text</c->);
  [<a href="#cereactions" id="the-document-object:cereactions-7"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-document-writeln" id="the-document-object:dom-document-writeln"><c- g="">writeln</c-></a>((<code id="the-document-object:tt-trustedhtml-3"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> <c- b="">DOMString</c->)... <c- g="">text</c->);

  // <a href="#editing" id="the-document-object:editing">user interaction</a>
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#windowproxy" id="the-document-object:windowproxy-2"><c- n="">WindowProxy</c-></a>? <a href="#dom-document-defaultview" id="the-document-object:dom-document-defaultview"><c- g="">defaultView</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-document-hasfocus" id="the-document-object:dom-document-hasfocus"><c- g="">hasFocus</c-></a>();
  [<a href="#cereactions" id="the-document-object:cereactions-8"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#designMode" id="the-document-object:designMode"><c- g="">designMode</c-></a>;
  [<a href="#cereactions" id="the-document-object:cereactions-9"><c- g="">CEReactions</c-></a>] <c- b="">boolean</c-> <a href="https://w3c.github.io/editing/docs/execCommand/#execcommand%28%29" id="the-document-object:execCommand" data-x-internal="execCommand"><c- g="">execCommand</c-></a>(<c- b="">DOMString</c-> <c- g="">commandId</c->, <c- b="">optional</c-> <c- b="">boolean</c-> <c- g="">showUI</c-> = <c- b="">false</c->, <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">value</c-> = "");
  <c- b="">boolean</c-> <a href="https://w3c.github.io/editing/docs/execCommand/#querycommandenabled%28%29" id="the-document-object:dom-document-querycommandenabled" data-x-internal="dom-document-querycommandenabled"><c- g="">queryCommandEnabled</c-></a>(<c- b="">DOMString</c-> <c- g="">commandId</c->);
  <c- b="">boolean</c-> <a href="https://w3c.github.io/editing/docs/execCommand/#querycommandindeterm%28%29" id="the-document-object:dom-document-querycommandindeterm" data-x-internal="dom-document-querycommandindeterm"><c- g="">queryCommandIndeterm</c-></a>(<c- b="">DOMString</c-> <c- g="">commandId</c->);
  <c- b="">boolean</c-> <a href="https://w3c.github.io/editing/docs/execCommand/#querycommandstate%28%29" id="the-document-object:dom-document-querycommandstate" data-x-internal="dom-document-querycommandstate"><c- g="">queryCommandState</c-></a>(<c- b="">DOMString</c-> <c- g="">commandId</c->);
  <c- b="">boolean</c-> <a href="https://w3c.github.io/editing/docs/execCommand/#querycommandsupported%28%29" id="the-document-object:dom-document-querycommandsupported" data-x-internal="dom-document-querycommandsupported"><c- g="">queryCommandSupported</c-></a>(<c- b="">DOMString</c-> <c- g="">commandId</c->);
  <c- b="">DOMString</c-> <a href="https://w3c.github.io/editing/docs/execCommand/#querycommandvalue%28%29" id="the-document-object:dom-document-querycommandvalue" data-x-internal="dom-document-querycommandvalue"><c- g="">queryCommandValue</c-></a>(<c- b="">DOMString</c-> <c- g="">commandId</c->);
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-document-hidden" id="the-document-object:dom-document-hidden"><c- g="">hidden</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#documentvisibilitystate" id="the-document-object:documentvisibilitystate"><c- n="">DocumentVisibilityState</c-></a> <a href="#dom-document-visibilitystate" id="the-document-object:dom-document-visibilitystate"><c- g="">visibilityState</c-></a>;

  // special <a href="#event-handler-idl-attributes" id="the-document-object:event-handler-idl-attributes">event handler IDL attributes</a> that only apply to Document objects
  [<a id="the-document-object:legacylenientthis" href="https://webidl.spec.whatwg.org/#LegacyLenientThis" data-x-internal="legacylenientthis"><c- g="">LegacyLenientThis</c-></a>] <c- b="">attribute</c-> <a href="#eventhandler" id="the-document-object:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-onreadystatechange" id="the-document-object:handler-onreadystatechange"><c- g="">onreadystatechange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-document-object:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-onvisibilitychange" id="the-document-object:handler-onvisibilitychange"><c- g="">onvisibilitychange</c-></a>;

  // <a href="#Document-partial">also has obsolete members</a>
};
<a href="#document" id="the-document-object:document-4"><c- n="">Document</c-></a> <c- b="">includes</c-> <a href="#globaleventhandlers" id="the-document-object:globaleventhandlers"><c- n="">GlobalEventHandlers</c-></a>;</code></pre>

  <p>Each <code id="the-document-object:document-5"><a href="#document">Document</a></code> has a <dfn data-dfn-for="Document" id="concept-document-policy-container" data-export="">policy container</dfn> (a <a href="#policy-container" id="the-document-object:policy-container">policy container</a>), initially a new policy
  container, which contains policies which apply to the <code id="the-document-object:document-6"><a href="#document">Document</a></code>.</p>

  <p id="concept-document-feature-policy">Each <code id="the-document-object:document-7"><a href="#document">Document</a></code> has a <dfn data-dfn-for="Document" id="concept-document-permissions-policy" data-export="">permissions policy</dfn>, which
  is a <a href="https://w3c.github.io/webappsec-feature-policy/#permissions-policy" id="the-document-object:concept-permissions-policy" data-x-internal="concept-permissions-policy">permissions policy</a>, which is initially
  empty.</p>

  <p>Each <code id="the-document-object:document-8"><a href="#document">Document</a></code> has a <dfn id="concept-document-module-map">module map</dfn>,
  which is a <a href="#module-map" id="the-document-object:module-map">module map</a>, initially empty.</p>

  <p>Each <code id="the-document-object:document-9"><a href="#document">Document</a></code> has an <dfn id="concept-document-coop">opener policy</dfn>,
  which is an <a href="#cross-origin-opener-policy" id="the-document-object:cross-origin-opener-policy">opener policy</a>, initially a new opener policy.</p>

  <p>Each <code id="the-document-object:document-10"><a href="#document">Document</a></code> has an <dfn id="is-initial-about:blank">is initial <code>about:blank</code></dfn>, which is a
  boolean, initially false.</p>

  <p>Each <code id="the-document-object:document-11"><a href="#document">Document</a></code> has a <dfn id="concept-document-navigation-id">during-loading
  navigation ID for WebDriver BiDi</dfn>, which is a <a href="#navigation-id" id="the-document-object:navigation-id">navigation ID</a> or null, initially
  null.</p>

  <p class="note">As the name indicates, this is used for interfacing with the <cite>WebDriver
  BiDi</cite> specification, which needs to be informed about certain occurrences during the early
  parts of the <code id="the-document-object:document-12"><a href="#document">Document</a></code>'s lifecycle, in a way that ties them to the original
  <a href="#navigation-id" id="the-document-object:navigation-id-2">navigation ID</a> used when the navigation that created this <code id="the-document-object:document-13"><a href="#document">Document</a></code> was
  the <a href="#ongoing-navigation" id="the-document-object:ongoing-navigation">ongoing navigation</a>. This eventually gets set back to null, after <cite>WebDriver
  BiDi</cite> considers the loading process to be finished. <a href="#refsBIDI">[BIDI]</a></p>

  <p>Each <code id="the-document-object:document-14"><a href="#document">Document</a></code> has an <dfn id="concept-document-about-base-url">about base
  URL</dfn>, which is a <a id="the-document-object:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> or null, initially null.</p>

  <p class="note">This is only populated for "<code>about:</code>"-schemed
  <code id="the-document-object:document-15"><a href="#document">Document</a></code>s.</p>

  <p>Each <code id="the-document-object:document-16"><a href="#document">Document</a></code> has a <dfn id="concept-document-bfcache-blocking-details">bfcache blocking details</dfn>, which is a
  <a id="the-document-object:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <a href="#nrr-details-struct" id="the-document-object:nrr-details-struct">not restored reason details</a>,
  initially empty.</p>

  <p>Each <code id="the-document-object:document-17"><a href="#document">Document</a></code> has an <dfn id="open-dialogs-list">open dialogs list</dfn>, which is a <a id="the-document-object:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of
  <code id="the-document-object:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> elements, initially empty.</p>

  <h4 id="the-documentorshadowroot-interface"><span class="secno">3.1.2</span> The <code id="the-documentorshadowroot-interface:documentorshadowroot"><a href="#documentorshadowroot">DocumentOrShadowRoot</a></code> interface<a href="#the-documentorshadowroot-interface" class="self-link"></a></h4>

  <p><cite>DOM</cite> defines the <code id="the-documentorshadowroot-interface:dom-documentorshadowroot"><a data-x-internal="dom-documentorshadowroot" href="https://dom.spec.whatwg.org/#documentorshadowroot">DocumentOrShadowRoot</a></code> mixin, which this specification
  extends.</p>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <c- b="">mixin</c-> <dfn data-lt="" id="documentorshadowroot"><c- g="">DocumentOrShadowRoot</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-documentorshadowroot-interface:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a>? <a href="#dom-documentorshadowroot-activeelement" id="the-documentorshadowroot-interface:dom-documentorshadowroot-activeelement"><c- g="">activeElement</c-></a>;
};</code></pre>

  <h4 id="resource-metadata-management"><span class="secno">3.1.3</span> <dfn>Resource metadata management</dfn><a href="#resource-metadata-management" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-referrer" id="dom-document-referrer-dev">referrer</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer" title="The Document.referrer property returns the URI of the page that linked to this page.">Document/referrer</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="resource-metadata-management:the-document's-address" data-x-internal="the-document's-address">URL</a> of the <code id="resource-metadata-management:document"><a href="#document">Document</a></code> from
    which the user navigated to this one, unless it was blocked or there was no such document, in
    which case it returns the empty string.</p>

    <p>The <code id="resource-metadata-management:link-type-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code> link type can be used to block the
    referrer.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-referrer" data-dfn-type="attribute"><code>referrer</code></dfn>
  attribute must return <a href="#the-document's-referrer" id="resource-metadata-management:the-document's-referrer">the document's referrer</a>.</p>
  </div>

  

  <hr>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-cookie" id="dom-document-cookie-dev">cookie</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the HTTP cookies that apply to the <code id="resource-metadata-management:document-2"><a href="#document">Document</a></code>. If there are no cookies or
    cookies can't be applied to this resource, the empty string will be returned.</p>

    <p>Can be set, to add a new cookie to the element's set of HTTP cookies.</p>

    <p>If the contents are <a href="#sandboxed-origin-browsing-context-flag" id="resource-metadata-management:sandboxed-origin-browsing-context-flag">sandboxed into an
    opaque origin</a> (e.g., in an <code id="resource-metadata-management:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> with the <code id="resource-metadata-management:attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute), a
    <a id="resource-metadata-management:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="resource-metadata-management:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> will be thrown on getting
    and setting.</p>
   </dd></dl>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie" title="The Document property cookie lets you read and write cookies associated with the document. It serves as a getter and setter for the actual values of the cookies.">Document/cookie</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><p>The <dfn data-dfn-for="Document" id="dom-document-cookie" data-dfn-type="attribute"><code>cookie</code></dfn>
  attribute represents the cookies of the resource identified by the document's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="resource-metadata-management:the-document's-address-2" data-x-internal="the-document's-address">URL</a>.</p>

  <p class="note">Using the synchronous <code id="resource-metadata-management:dom-document-cookie"><a href="#dom-document-cookie">document.cookie</a></code>
  API can be a source of performance issues. The <cite>Cookie Store API</cite> can be used instead,
  as it provides an asynchronous way to handle cookies to avoid performance issues. See the <a href="https://cookiestore.spec.whatwg.org/#intro">Cookie Store API introduction</a> for more
  information. <a href="#refsCOOKIESTORE">[COOKIESTORE]</a></p>

  <div data-algorithm="">
  <p>A <code id="resource-metadata-management:document-3"><a href="#document">Document</a></code> object that falls into one of the following conditions is a
  <dfn id="cookie-averse-document-object">cookie-averse <code>Document</code> object</dfn>:</p>

  <ul><li>A <code id="resource-metadata-management:document-4"><a href="#document">Document</a></code> object whose <a href="#concept-document-bc" id="resource-metadata-management:concept-document-bc">browsing
   context</a> is null.</li><li>A <code id="resource-metadata-management:document-5"><a href="#document">Document</a></code> whose <a href="https://dom.spec.whatwg.org/#concept-document-url" id="resource-metadata-management:the-document's-address-3" data-x-internal="the-document's-address">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="resource-metadata-management:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is not an <a id="resource-metadata-management:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>.</li></ul>
  </div>

  

  <div data-algorithm="">
  <p id="sandboxCookies">
  <a id="resource-metadata-management:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  On getting, if the document is a <a href="#cookie-averse-document-object" id="resource-metadata-management:cookie-averse-document-object">cookie-averse <code>Document</code> object</a>, then the
  user agent must return the empty string. Otherwise, if the <code id="resource-metadata-management:document-6"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="resource-metadata-management:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is an <a href="#concept-origin-opaque" id="resource-metadata-management:concept-origin-opaque">opaque
  origin</a>, the user agent must throw a <a id="resource-metadata-management:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
  <code id="resource-metadata-management:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>. Otherwise, the user agent must return the <a id="resource-metadata-management:cookie-string" href="https://httpwg.org/specs/rfc6265.html#sane-cookie-syntax" data-x-internal="cookie-string">cookie-string</a>
  for the document's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="resource-metadata-management:the-document's-address-4" data-x-internal="the-document's-address">URL</a> for a "non-HTTP" API, decoded
  using <a id="resource-metadata-management:utf-8-decode-without-bom" href="https://encoding.spec.whatwg.org/#utf-8-decode-without-bom" data-x-internal="utf-8-decode-without-bom">UTF-8 decode without BOM</a>. <a href="#refsCOOKIES">[COOKIES]</a></p>
  </div>

  <div data-algorithm="">
  <p>On setting, if the document is a <a href="#cookie-averse-document-object" id="resource-metadata-management:cookie-averse-document-object-2">cookie-averse <code>Document</code> object</a>, then
  the user agent must do nothing. Otherwise, if the <code id="resource-metadata-management:document-7"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="resource-metadata-management:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> is an <a href="#concept-origin-opaque" id="resource-metadata-management:concept-origin-opaque-2">opaque
  origin</a>, the user agent must throw a <a id="resource-metadata-management:securityerror-3" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
  <code id="resource-metadata-management:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>. Otherwise, the user agent must act as it would when <a href="https://httpwg.org/specs/rfc6265.html#storage-model" id="resource-metadata-management:receives-a-set-cookie-string" data-x-internal="receives-a-set-cookie-string">receiving a set-cookie-string</a> for the document's
  <a href="https://dom.spec.whatwg.org/#concept-document-url" id="resource-metadata-management:the-document's-address-5" data-x-internal="the-document's-address">URL</a> via a "non-HTTP" API, consisting of the new value
  <a href="https://encoding.spec.whatwg.org/#utf-8-encode" id="resource-metadata-management:utf-8-encode" data-x-internal="utf-8-encode">encoded as UTF-8</a>. <a href="#refsCOOKIES">[COOKIES]</a> <a href="#refsENCODING">[ENCODING]</a></p>
  </div>

  <p class="note">Since the <code id="resource-metadata-management:dom-document-cookie-2"><a href="#dom-document-cookie">cookie</a></code> attribute is accessible
  across frames, the path restrictions on cookies are only a tool to help manage which cookies are
  sent to which parts of the site, and are not in any way a security feature.</p>

  <p class="warning">The <code id="resource-metadata-management:dom-document-cookie-3"><a href="#dom-document-cookie">cookie</a></code> attribute's getter and
  setter synchronously access shared state. Since there is no locking mechanism, other browsing
  contexts in a multiprocess user agent can modify cookies while scripts are running. A site could,
  for instance, try to read a cookie, increment its value, then write it back out, using the new
  value of the cookie as a unique identifier for the session; if the site does this twice in two
  different browser windows at the same time, it might end up using the same "unique" identifier for
  both sessions, with potentially disastrous effects.</p>

  <hr>

  

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-lastmodified" id="dom-document-lastmodified-dev">lastModified</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/lastModified" title="The lastModified property of the Document interface returns a string containing the date and time on which the current document was last modified.">Document/lastModified</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the date of the last modification to the document, as reported by the server, in the
    form "<code>MM/DD/YYYY&nbsp;hh:mm:ss</code>", in the user's local time zone.</p>

    <p>If the last modification date is not known, the current time is returned instead.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-lastmodified" data-dfn-type="attribute"><code>lastModified</code></dfn> attribute, on getting, must return
  the date and time of the <code id="resource-metadata-management:document-8"><a href="#document">Document</a></code>'s source file's last modification, in the user's
  local time zone, in the following format:</p>

  <ol><li><p>The month component of the date.</p></li><li><p>A U+002F SOLIDUS character (/).</p></li><li><p>The day component of the date.</p></li><li><p>A U+002F SOLIDUS character (/).</p></li><li><p>The year component of the date.</p></li><li><p>A U+0020 SPACE character.</p></li><li><p>The hours component of the time.</p></li><li><p>A U+003A COLON character (:).</p></li><li><p>The minutes component of the time.</p></li><li><p>A U+003A COLON character (:).</p></li><li><p>The seconds component of the time.</p></li></ol>

  <p>All the numeric components above, other than the year, must be given as two <a id="resource-metadata-management:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
  digits</a> representing the number in base ten, zero-padded if necessary. The year must be
  given as the shortest possible string of four or more <a id="resource-metadata-management:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> representing the
  number in base ten, zero-padded if necessary.</p>
  </div>

  <p>The <code id="resource-metadata-management:document-9"><a href="#document">Document</a></code>'s source file's last modification date and time must be derived from
  relevant features of the networking protocols used, e.g. from the value of the HTTP `<code id="resource-metadata-management:http-last-modified"><a data-x-internal="http-last-modified" href="https://httpwg.org/specs/rfc7232.html#header.last-modified">Last-Modified</a></code>` header of the document, or from metadata in the
  file system for local files. If the last modification date and time are not known, the attribute
  must return the current date and time in the above format.</p>

  


  <h4 id="reporting-document-loading-status"><span class="secno">3.1.4</span> Reporting document loading status<a href="#reporting-document-loading-status" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-readystate" id="dom-document-readystate-dev">readyState</a></code></dt><dd>
    <p>Returns "<code>loading</code>" while the <code id="reporting-document-loading-status:document"><a href="#document">Document</a></code> is loading, "<code>interactive</code>" once it is finished parsing but still loading subresources, and
    "<code>complete</code>" once it has loaded.</p>

    <p>The <code id="reporting-document-loading-status:event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code> event fires on the
    <code id="reporting-document-loading-status:document-2"><a href="#document">Document</a></code> object when this value changes.</p>

    <p>The <code id="reporting-document-loading-status:event-domcontentloaded"><a href="#event-domcontentloaded">DOMContentLoaded</a></code> event fires after the transition to
    "<code>interactive</code>" but before the transition to "<code>complete</code>", at the point where all subresources apart from <code id="reporting-document-loading-status:attr-script-async"><a href="#attr-script-async">async</a></code> <code id="reporting-document-loading-status:the-script-element"><a href="#the-script-element">script</a></code> elements have loaded.</p>
   </dd></dl>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState" title="The Document.readyState property describes the loading state of the document. When the value of this property changes, a readystatechange event fires on the document object.">Document/readyState</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.6+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div><p>Each <code id="reporting-document-loading-status:document-3"><a href="#document">Document</a></code> has a <dfn id="current-document-readiness">current document readiness</dfn>, a string, initially
  "<code>complete</code>".</p>

  <p class="note">For <code id="reporting-document-loading-status:document-4"><a href="#document">Document</a></code> objects created via the <a href="#initialise-the-document-object" id="reporting-document-loading-status:initialise-the-document-object">create and initialize a <code>Document</code> object</a>
  algorithm, this will be immediately reset to "<code>loading</code>" before any script
  can observe the value of <code id="reporting-document-loading-status:dom-document-readystate"><a href="#dom-document-readystate">document.readyState</a></code>. This
  default applies to other cases such as <a href="#is-initial-about:blank" id="reporting-document-loading-status:is-initial-about:blank">initial
  <code>about:blank</code></a> <code id="reporting-document-loading-status:document-5"><a href="#document">Document</a></code>s or <code id="reporting-document-loading-status:document-6"><a href="#document">Document</a></code>s without a
  <a href="#concept-document-bc" id="reporting-document-loading-status:concept-document-bc">browsing context</a>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-readystate" data-dfn-type="attribute"><code>readyState</code></dfn> getter steps are to return
  <a id="reporting-document-loading-status:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#current-document-readiness" id="reporting-document-loading-status:current-document-readiness">current document readiness</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="update-the-current-document-readiness">update the current document readiness</dfn> for <code id="reporting-document-loading-status:document-7"><a href="#document">Document</a></code>
  <var>document</var> to <var>readinessValue</var>:</p>

  <ol><li><p>If <var>document</var>'s <a href="#current-document-readiness" id="reporting-document-loading-status:current-document-readiness-2">current document readiness</a> equals
   <var>readinessValue</var>, then return.</p></li><li><p>Set <var>document</var>'s <a href="#current-document-readiness" id="reporting-document-loading-status:current-document-readiness-3">current document readiness</a> to
   <var>readinessValue</var>.</p></li><li>
    <p>If <var>document</var> is associated with an <a href="#html-parser" id="reporting-document-loading-status:html-parser">HTML parser</a>, then:</p>

    <ol><li><p>Let <var>now</var> be the <a id="reporting-document-loading-status:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given
     <var>document</var>'s <a href="#concept-relevant-global" id="reporting-document-loading-status:concept-relevant-global">relevant global object</a>.</p></li><li><p>If <var>readinessValue</var> is "<code>complete</code>", and
     <var>document</var>'s <a href="#load-timing-info" id="reporting-document-loading-status:load-timing-info">load timing info</a>'s <a href="#dom-complete-time" id="reporting-document-loading-status:dom-complete-time">DOM complete time</a> is 0, then
     set <var>document</var>'s <a href="#load-timing-info" id="reporting-document-loading-status:load-timing-info-2">load timing info</a>'s <a href="#dom-complete-time" id="reporting-document-loading-status:dom-complete-time-2">DOM complete time</a> to
     <var>now</var>.</p></li><li><p>Otherwise, if <var>readinessValue</var> is "<code>interactive</code>", and
     <var>document</var>'s <a href="#load-timing-info" id="reporting-document-loading-status:load-timing-info-3">load timing info</a>'s <a href="#dom-interactive-time" id="reporting-document-loading-status:dom-interactive-time">DOM interactive time</a> is 0,
     then set <var>document</var>'s <a href="#load-timing-info" id="reporting-document-loading-status:load-timing-info-4">load timing info</a>'s <a href="#dom-interactive-time" id="reporting-document-loading-status:dom-interactive-time-2">DOM interactive
     time</a> to <var>now</var>.</p></li></ol>
   </li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="reporting-document-loading-status:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="reporting-document-loading-status:event-readystatechange-2"><a href="#event-readystatechange">readystatechange</a></code> at <var>document</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>A <code id="reporting-document-loading-status:document-8"><a href="#document">Document</a></code> is said to have an <dfn id="active-parser">active parser</dfn> if it is associated with an
  <a href="#html-parser" id="reporting-document-loading-status:html-parser-2">HTML parser</a> or an <a href="#xml-parser" id="reporting-document-loading-status:xml-parser">XML parser</a> that has not yet been <a href="#stop-parsing" id="reporting-document-loading-status:stop-parsing">stopped</a> or <a href="#abort-a-parser" id="reporting-document-loading-status:abort-a-parser">aborted</a>.</p>
  </div>

  <hr>

  <p>A <code id="reporting-document-loading-status:document-9"><a href="#document">Document</a></code> has a <a href="#document-load-timing-info" id="reporting-document-loading-status:document-load-timing-info">document load timing info</a> <dfn data-dfn-for="Document" id="load-timing-info" data-export="">load timing info</dfn>.</p>

  <p>A <code id="reporting-document-loading-status:document-10"><a href="#document">Document</a></code> has a <a href="#document-unload-timing-info" id="reporting-document-loading-status:document-unload-timing-info">document unload timing info</a> <dfn data-dfn-for="Document" id="previous-document-unload-timing" data-export="">previous document unload timing</dfn>.</p>

  <p>A <code id="reporting-document-loading-status:document-11"><a href="#document">Document</a></code> has a boolean <dfn id="was-created-via-cross-origin-redirects" data-export="">was created via cross-origin redirects</dfn>,
  initially false.</p>

  <p>The <dfn id="document-load-timing-info" data-export="">document load timing info</dfn> <a id="reporting-document-loading-status:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="reporting-document-loading-status:struct-item" data-x-internal="struct-item">items</a>:</p>

  <dl><dt><dfn data-dfn-for="document load timing info" id="navigation-start-time" data-export="">navigation start time</dfn> (default 0)</dt><dd>A number</dd><dt><dfn data-dfn-for="document load timing info" id="dom-interactive-time" data-export="">DOM interactive time</dfn> (default 0)</dt><dt><dfn data-dfn-for="document load timing info" id="dom-content-loaded-event-start-time" data-export="">DOM content loaded event start time</dfn>
   (default 0)</dt><dt><dfn data-dfn-for="document load timing info" id="dom-content-loaded-event-end-time" data-export="">DOM content loaded event end time</dfn> (default
   0)</dt><dt><dfn data-dfn-for="document load timing info" id="dom-complete-time" data-export="">DOM complete time</dfn> (default 0)</dt><dt><dfn data-dfn-for="document load timing info" id="load-event-start-time" data-export="">load event start time</dfn> (default 0)</dt><dt><dfn data-dfn-for="document load timing info" id="load-event-end-time" data-export="">load event end time</dfn> (default 0)</dt><dd><code id="reporting-document-loading-status:domhighrestimestamp"><a data-x-internal="domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp">DOMHighResTimeStamp</a></code> values</dd></dl>

  <p>The <dfn id="document-unload-timing-info" data-export="">document unload timing info</dfn> <a id="reporting-document-loading-status:struct-2" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="reporting-document-loading-status:struct-item-2" data-x-internal="struct-item">items</a>:</p>

  <dl><dt><dfn data-dfn-for="document unload timing info" id="unload-event-start-time" data-export="">unload event start time</dfn> (default 0)</dt><dt><dfn data-dfn-for="document unload timing info" id="unload-event-end-time" data-export="">unload event end time</dfn> (default 0)</dt><dd><code id="reporting-document-loading-status:domhighrestimestamp-2"><a data-x-internal="domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp">DOMHighResTimeStamp</a></code> values</dd></dl>

  

  <h4 id="render-blocking-mechanism"><span class="secno">3.1.5</span> <dfn>Render-blocking mechanism</dfn><a href="#render-blocking-mechanism" class="self-link"></a></h4>

  <p>Each <code id="render-blocking-mechanism:document"><a href="#document">Document</a></code> has a <dfn id="render-blocking-element-set">render-blocking element set</dfn>, a <a id="render-blocking-mechanism:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of
  elements, initially the empty set.</p>

  <div data-algorithm="">
  <p>A <code id="render-blocking-mechanism:document-2"><a href="#document">Document</a></code> <var>document</var> <dfn id="allows-adding-render-blocking-elements">allows adding render-blocking elements</dfn>
  if <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-content-type" id="render-blocking-mechanism:concept-document-content-type" data-x-internal="concept-document-content-type">content type</a> is
  "<code id="render-blocking-mechanism:text/html"><a href="#text/html">text/html</a></code>" and <a href="#the-body-element-2" id="render-blocking-mechanism:the-body-element-2">the body element</a> of <var>document</var> is null.</p>
  </div>

  <div data-algorithm="">
  <p>A <code id="render-blocking-mechanism:document-3"><a href="#document">Document</a></code> <var>document</var> is <dfn id="render-blocked">render-blocked</dfn> if both of the
  following are true:</p>

  <ul><li><p><var>document</var>'s <a href="#render-blocking-element-set" id="render-blocking-mechanism:render-blocking-element-set">render-blocking element set</a> is non-empty, or
   <var>document</var> <a href="#allows-adding-render-blocking-elements" id="render-blocking-mechanism:allows-adding-render-blocking-elements">allows adding render-blocking elements</a>.</p>

   </li><li><p>The <a id="render-blocking-mechanism:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given <var>document</var>'s <a href="#concept-relevant-global" id="render-blocking-mechanism:concept-relevant-global">relevant
   global object</a> has not exceeded an <a id="render-blocking-mechanism:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> timeout value.</p>
  </li></ul>
  </div>

  <div data-algorithm="">
  <p>An element <var>el</var> is <dfn id="render-blocking">render-blocking</dfn> if <var>el</var>'s
  <a id="render-blocking-mechanism:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> <var>document</var> is <a href="#render-blocked" id="render-blocking-mechanism:render-blocked">render-blocked</a>, and <var>el</var>
  is in <var>document</var>'s <a href="#render-blocking-element-set" id="render-blocking-mechanism:render-blocking-element-set-2">render-blocking element set</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="block-rendering">block rendering</dfn> on an element <var>el</var>:</p>

  <ol><li><p>Let <var>document</var> be <var>el</var>'s <a id="render-blocking-mechanism:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p>

   </li><li><p>If <var>document</var> <a href="#allows-adding-render-blocking-elements" id="render-blocking-mechanism:allows-adding-render-blocking-elements-2">allows adding render-blocking elements</a>, then
   <a href="https://infra.spec.whatwg.org/#set-append" id="render-blocking-mechanism:set-append" data-x-internal="set-append">append</a> <var>el</var> to <var>document</var>'s
   <a href="#render-blocking-element-set" id="render-blocking-mechanism:render-blocking-element-set-3">render-blocking element set</a>.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="unblock-rendering">unblock rendering</dfn> on an element <var>el</var>:</p>

  <ol><li><p>Let <var>document</var> be <var>el</var>'s <a id="render-blocking-mechanism:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p>

   </li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="render-blocking-mechanism:list-remove" data-x-internal="list-remove">Remove</a> <var>el</var> from <var>document</var>'s
   <a href="#render-blocking-element-set" id="render-blocking-mechanism:render-blocking-element-set-4">render-blocking element set</a>.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>Whenever a <a href="#render-blocking" id="render-blocking-mechanism:render-blocking">render-blocking</a> element <var>el</var>
  <a href="#becomes-browsing-context-disconnected" id="render-blocking-mechanism:becomes-browsing-context-disconnected">becomes browsing-context disconnected</a>, or <var>el</var>'s
  <a href="#blocking-attribute" id="render-blocking-mechanism:blocking-attribute">blocking attribute</a>'s value is changed so that <var>el</var> is no longer
  <a href="#potentially-render-blocking" id="render-blocking-mechanism:potentially-render-blocking">potentially render-blocking</a>, then <a href="#unblock-rendering" id="render-blocking-mechanism:unblock-rendering">unblock rendering</a> on
  <var>el</var>.</p>
  </div>

  <h4 id="dom-tree-accessors"><span class="secno">3.1.6</span> <dfn>DOM tree accessors</dfn><a href="#dom-tree-accessors" class="self-link"></a></h4>

  <div data-algorithm="">
  <p><dfn id="the-html-element-2">The <code>html</code> element</dfn> of a document is its <a id="dom-tree-accessors:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>,
  if it's an <code id="dom-tree-accessors:the-html-element"><a href="#the-html-element">html</a></code> element, and null otherwise.</p>
  </div>

  <hr>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-head" id="dom-document-head-dev">head</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/head" title="The head read-only property of the Document interface returns the <head> element of the current document.">Document/head</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Returns <a href="#the-head-element-2" id="dom-tree-accessors:the-head-element-2">the <code>head</code> element</a>.</p></dd></dl>

  <div data-algorithm="">
  <p><dfn id="the-head-element-2">The <code>head</code> element</dfn> of a document is the first <code id="dom-tree-accessors:the-head-element"><a href="#the-head-element">head</a></code> element
  that is a child of <a href="#the-html-element-2" id="dom-tree-accessors:the-html-element-2">the <code>html</code> element</a>, if there is one, or null
  otherwise.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-head" data-dfn-type="attribute"><code>head</code></dfn> attribute,
  on getting, must return <a href="#the-head-element-2" id="dom-tree-accessors:the-head-element-2-2">the <code>head</code> element</a> of the document (a
  <code id="dom-tree-accessors:the-head-element-3"><a href="#the-head-element">head</a></code> element or null).</p>
  </div>

  

  <hr>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#document.title" id="dom-document-title-dev">title</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the document's title, as given by <a href="#the-title-element-2" id="dom-tree-accessors:the-title-element-2">the <code>title</code> element</a> for
    HTML and as given by the <a id="dom-tree-accessors:svg-title" href="https://svgwg.org/svg2-draft/struct.html#TitleElement" data-x-internal="svg-title">SVG <code>title</code></a> element for SVG.</p>

    <p>Can be set, to update the document's title. If there is no appropriate element to update, the
    new value is ignored.</p>
   </dd></dl>

  <div data-algorithm="">
  <p><dfn id="the-title-element-2">The <code>title</code> element</dfn> of a document is the first <code id="dom-tree-accessors:the-title-element"><a href="#the-title-element">title</a></code> element
  in the document (in <a id="dom-tree-accessors:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>), if there is one, or null otherwise.</p>
  </div>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/title" title="The document.title property gets or sets the current title of the document. When present, it defaults to the value of the <title>.">Document/title</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="document.title" data-dfn-type="attribute"><code>title</code></dfn> attribute must, on getting, run the following
  algorithm:</p>

  <ol><li><p>If the <a id="dom-tree-accessors:document-element-2" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> is an <a id="dom-tree-accessors:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a> element, then
   let <var>value</var> be the <a id="dom-tree-accessors:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> of the first <a id="dom-tree-accessors:svg-title-2" href="https://svgwg.org/svg2-draft/struct.html#TitleElement" data-x-internal="svg-title">SVG
   <code>title</code></a> element that is a child of the <a id="dom-tree-accessors:document-element-3" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>.</p></li><li><p>Otherwise, let <var>value</var> be the <a id="dom-tree-accessors:child-text-content-2" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> of <a href="#the-title-element-2" id="dom-tree-accessors:the-title-element-2-2">the
   <code>title</code> element</a>, or the empty string if <a href="#the-title-element-2" id="dom-tree-accessors:the-title-element-2-3">the <code>title</code>
   element</a> is null.</p></li><li><p><a id="dom-tree-accessors:strip-and-collapse-ascii-whitespace" href="https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace" data-x-internal="strip-and-collapse-ascii-whitespace">Strip and collapse ASCII whitespace</a> in <var>value</var>.</p></li><li><p>Return <var>value</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>On setting, the steps corresponding to the first matching condition in the following list must
  be run:</p>

  <dl class="switch"><dt>If the <a id="dom-tree-accessors:document-element-4" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> is an <a id="dom-tree-accessors:svg-svg-2" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a> element</dt><dd>
    <ol><li><p>If there is an <a id="dom-tree-accessors:svg-title-3" href="https://svgwg.org/svg2-draft/struct.html#TitleElement" data-x-internal="svg-title">SVG <code>title</code></a> element that is a child of the
     <a id="dom-tree-accessors:document-element-5" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>, let <var>element</var> be the first such element.</p></li><li>
      <p>Otherwise:</p>

      <ol><li><p>Let <var>element</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="dom-tree-accessors:create-an-element" data-x-internal="create-an-element">creating an
       element</a> given the <a id="dom-tree-accessors:document-element-6" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>'s <a id="dom-tree-accessors:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, "<code>title</code>", and the <a id="dom-tree-accessors:svg-namespace" href="https://infra.spec.whatwg.org/#svg-namespace" data-x-internal="svg-namespace">SVG namespace</a>.</p>

       </li><li><p>Insert <var>element</var> as the <a id="dom-tree-accessors:first-child" href="https://dom.spec.whatwg.org/#concept-tree-first-child" data-x-internal="first-child">first child</a> of the <a id="dom-tree-accessors:document-element-7" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document
       element</a>.</p></li></ol>
     </li><li><p><a id="dom-tree-accessors:string-replace-all" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">String replace all</a> with the given value within <var>element</var>.</p></li></ol>
   </dd><dt>If the <a id="dom-tree-accessors:document-element-8" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> is in the <a id="dom-tree-accessors:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></dt><dd>
    <ol><li><p>If <a href="#the-title-element-2" id="dom-tree-accessors:the-title-element-2-4">the <code>title</code> element</a> is null and <a href="#the-head-element-2" id="dom-tree-accessors:the-head-element-2-3">the <code>head</code>
     element</a> is null, then return.</p></li><li><p>If <a href="#the-title-element-2" id="dom-tree-accessors:the-title-element-2-5">the <code>title</code> element</a> is non-null, let <var>element</var> be
     <a href="#the-title-element-2" id="dom-tree-accessors:the-title-element-2-6">the <code>title</code> element</a>.</p></li><li>
      <p>Otherwise:</p>

      <ol><li><p>Let <var>element</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="dom-tree-accessors:create-an-element-2" data-x-internal="create-an-element">creating an
       element</a> given the <a id="dom-tree-accessors:document-element-9" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>'s <a id="dom-tree-accessors:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, "<code>title</code>", and the <a id="dom-tree-accessors:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>.</p>

       </li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="dom-tree-accessors:concept-node-append" data-x-internal="concept-node-append">Append</a> <var>element</var> to <a href="#the-head-element-2" id="dom-tree-accessors:the-head-element-2-4">the
       <code>head</code> element</a>.</p></li></ol>
     </li><li><p><a id="dom-tree-accessors:string-replace-all-2" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">String replace all</a> with the given value within <var>element</var>.</p></li></ol>
   </dd><dt>Otherwise</dt><dd>
    <p>Do nothing.</p>
   </dd></dl>
  </div>

  

  <hr>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-body" id="dom-document-body-dev">body</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/body" title="The Document.body property represents the <body> or <frameset> node of the current document, or null if no such element exists.">Document/body</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>60+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns <a href="#the-body-element-2" id="dom-tree-accessors:the-body-element-2">the body element</a>.</p>

    <p>Can be set, to replace <a href="#the-body-element-2" id="dom-tree-accessors:the-body-element-2-2">the body element</a>.</p>

    <p>If the new value is not a <code id="dom-tree-accessors:the-body-element"><a href="#the-body-element">body</a></code> or <code id="dom-tree-accessors:frameset"><a href="#frameset">frameset</a></code> element, this will throw
    a <a id="dom-tree-accessors:hierarchyrequesterror" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a> <code id="dom-tree-accessors:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd></dl>

  <div data-algorithm="">
  <p><dfn id="the-body-element-2" data-export="">The body element</dfn> of a document is the first of <a href="#the-html-element-2" id="dom-tree-accessors:the-html-element-2-2">the <code>html</code>
  element</a>'s children that is either a <code id="dom-tree-accessors:the-body-element-3"><a href="#the-body-element">body</a></code> element or a <code id="dom-tree-accessors:frameset-2"><a href="#frameset">frameset</a></code>
  element, or null if there is no such element.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-body" data-dfn-type="attribute"><code>body</code></dfn> attribute,
  on getting, must return <a href="#the-body-element-2" id="dom-tree-accessors:the-body-element-2-3">the body element</a> of the document (either a <code id="dom-tree-accessors:the-body-element-4"><a href="#the-body-element">body</a></code>
  element, a <code id="dom-tree-accessors:frameset-3"><a href="#frameset">frameset</a></code> element, or null). On setting, the following algorithm must be
  run:</p>

  <ol><li>If the new value is not a <code id="dom-tree-accessors:the-body-element-5"><a href="#the-body-element">body</a></code> or <code id="dom-tree-accessors:frameset-4"><a href="#frameset">frameset</a></code> element, then throw a
   <a id="dom-tree-accessors:hierarchyrequesterror-2" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a> <code id="dom-tree-accessors:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</li><li>Otherwise, if the new value is the same as <a href="#the-body-element-2" id="dom-tree-accessors:the-body-element-2-4">the body element</a>, return.</li><li>Otherwise, if <a href="#the-body-element-2" id="dom-tree-accessors:the-body-element-2-5">the body element</a> is not null, then <a href="https://dom.spec.whatwg.org/#concept-node-replace" id="dom-tree-accessors:concept-node-replace" data-x-internal="concept-node-replace">replace</a> <a href="#the-body-element-2" id="dom-tree-accessors:the-body-element-2-6">the body element</a> with the new value
   within <a href="#the-body-element-2" id="dom-tree-accessors:the-body-element-2-7">the body element</a>'s parent and return.</li><li>Otherwise, if there is no <a id="dom-tree-accessors:document-element-10" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>, throw a
   <a id="dom-tree-accessors:hierarchyrequesterror-3" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a> <code id="dom-tree-accessors:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</li><li>Otherwise, <a href="#the-body-element-2" id="dom-tree-accessors:the-body-element-2-8">the body element</a> is null, but there's a
   <a id="dom-tree-accessors:document-element-11" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>. <a href="https://dom.spec.whatwg.org/#concept-node-append" id="dom-tree-accessors:concept-node-append-2" data-x-internal="concept-node-append">Append</a> the new value to
   the <a id="dom-tree-accessors:document-element-12" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>.</li></ol>
  </div>

  <p class="note">The value returned by the <code id="dom-tree-accessors:dom-document-body"><a href="#dom-document-body">body</a></code> getter is
  not always the one passed to the setter.</p>

  <div class="example">
   <p>In this example, the setter successfully inserts a <code id="dom-tree-accessors:the-body-element-6"><a href="#the-body-element">body</a></code> element (though this is
   non-conforming since SVG does not allow a <code id="dom-tree-accessors:the-body-element-7"><a href="#the-body-element">body</a></code> as child of <a id="dom-tree-accessors:svg-svg-3" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG
   <code>svg</code></a>). However the getter will return null because the document element is not
   <code id="dom-tree-accessors:the-html-element-3"><a href="#the-html-element">html</a></code>.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">svg</c-> <c- e="">xmlns</c-><c- o="">=</c-><c- s="">"http://www.w3.org/2000/svg"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  document<c- p="">.</c->body <c- o="">=</c-> document<c- p="">.</c->createElementNS<c- p="">(</c-><c- u="">"http://www.w3.org/1999/xhtml"</c-><c- p="">,</c-> <c- u="">"body"</c-><c- p="">);</c->
  console<c- p="">.</c->assert<c- p="">(</c->document<c- p="">.</c->body <c- o="">===</c-> <c- kc="">null</c-><c- p="">);</c->
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">svg</c-><c- p="">&gt;</c-></code></pre>
  </div>

  

  <hr>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-images" id="dom-document-images-dev">images</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/images" title="The images read-only property of the Document interface returns a collection of the images in the current HTML document.">Document/images</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="dom-tree-accessors:htmlcollection"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="dom-tree-accessors:the-img-element"><a href="#the-img-element">img</a></code> elements in the
    <code id="dom-tree-accessors:document"><a href="#document">Document</a></code>.</p>
   </dd><dt><code><var>document</var>.<a href="#dom-document-embeds" id="dom-document-embeds-dev">embeds</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/embeds" title="The embeds read-only property of the Document interface returns a list of the embedded <embed> elements within the current document.">Document/embeds</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera yes"><span>Opera</span><span>51+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></dt><dt><code><var>document</var>.<a href="#dom-document-plugins" id="dom-document-plugins-dev">plugins</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/plugins" title="The plugins read-only property of the Document interface returns an HTMLCollection object containing one or more HTMLEmbedElements representing the <embed> elements in the current document.">Document/plugins</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera yes"><span>Opera</span><span>51+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>10.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="dom-tree-accessors:htmlcollection-2"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="dom-tree-accessors:the-embed-element"><a href="#the-embed-element">embed</a></code> elements in the
    <code id="dom-tree-accessors:document-2"><a href="#document">Document</a></code>.</p>
   </dd><dt><code><var>document</var>.<a href="#dom-document-links" id="dom-document-links-dev">links</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/links" title="The links read-only property of the Document interface returns a collection of all <area> elements and <a> elements in a document with a value for the href attribute.">Document/links</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="dom-tree-accessors:htmlcollection-3"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="dom-tree-accessors:the-a-element"><a href="#the-a-element">a</a></code> and <code id="dom-tree-accessors:the-area-element"><a href="#the-area-element">area</a></code> elements
    in the <code id="dom-tree-accessors:document-3"><a href="#document">Document</a></code> that have <code id="dom-tree-accessors:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code>
    attributes.</p>
   </dd><dt><code><var>document</var>.<a href="#dom-document-forms" id="dom-document-forms-dev">forms</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/forms" title="The forms read-only property of the Document interface returns an HTMLCollection listing all the <form> elements contained in the document.">Document/forms</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="dom-tree-accessors:htmlcollection-4"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="dom-tree-accessors:the-form-element"><a href="#the-form-element">form</a></code> elements in the
    <code id="dom-tree-accessors:document-4"><a href="#document">Document</a></code>.</p>
   </dd><dt><code><var>document</var>.<a href="#dom-document-scripts" id="dom-document-scripts-dev">scripts</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/scripts" title="The scripts property of the Document interface returns a list of the <script> elements in the document. The returned object is an HTMLCollection.">Document/scripts</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="dom-tree-accessors:htmlcollection-5"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="dom-tree-accessors:the-script-element"><a href="#the-script-element">script</a></code> elements in the
    <code id="dom-tree-accessors:document-5"><a href="#document">Document</a></code>.</p>
   </dd></dl>

  

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-images" data-dfn-type="attribute"><code>images</code></dfn>
  attribute must return an <code id="dom-tree-accessors:htmlcollection-6"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="dom-tree-accessors:document-6"><a href="#document">Document</a></code> node,
  whose filter matches only <code id="dom-tree-accessors:the-img-element-2"><a href="#the-img-element">img</a></code> elements.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-embeds" data-dfn-type="attribute"><code>embeds</code></dfn>
  attribute must return an <code id="dom-tree-accessors:htmlcollection-7"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="dom-tree-accessors:document-7"><a href="#document">Document</a></code> node,
  whose filter matches only <code id="dom-tree-accessors:the-embed-element-2"><a href="#the-embed-element">embed</a></code> elements.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-plugins" data-dfn-type="attribute"><code>plugins</code></dfn>
  attribute must return the same object as that returned by the <code id="dom-tree-accessors:dom-document-embeds"><a href="#dom-document-embeds">embeds</a></code> attribute.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-links" data-dfn-type="attribute"><code>links</code></dfn>
  attribute must return an <code id="dom-tree-accessors:htmlcollection-8"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="dom-tree-accessors:document-8"><a href="#document">Document</a></code> node,
  whose filter matches only <code id="dom-tree-accessors:the-a-element-2"><a href="#the-a-element">a</a></code> elements with <code id="dom-tree-accessors:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> attributes and <code id="dom-tree-accessors:the-area-element-2"><a href="#the-area-element">area</a></code> elements with <code id="dom-tree-accessors:attr-hyperlink-href-3"><a href="#attr-hyperlink-href">href</a></code> attributes.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-forms" data-dfn-type="attribute"><code>forms</code></dfn>
  attribute must return an <code id="dom-tree-accessors:htmlcollection-9"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="dom-tree-accessors:document-9"><a href="#document">Document</a></code> node,
  whose filter matches only <code id="dom-tree-accessors:the-form-element-2"><a href="#the-form-element">form</a></code> elements.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-scripts" data-dfn-type="attribute"><code>scripts</code></dfn>
  attribute must return an <code id="dom-tree-accessors:htmlcollection-10"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="dom-tree-accessors:document-10"><a href="#document">Document</a></code> node,
  whose filter matches only <code id="dom-tree-accessors:the-script-element-2"><a href="#the-script-element">script</a></code> elements.</p>
  </div>

  <hr>

  

  <dl class="domintro"><dt><code><var>collection</var> = <var>document</var>.<a href="#dom-document-getelementsbyname" id="dom-document-getelementsbyname-dev">getElementsByName</a>(<var>name</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByName" title="The getElementsByName() method of the Document object returns a NodeList Collection of elements with a given name attribute in the document.">Document/getElementsByName</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Returns a <code id="dom-tree-accessors:nodelist"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> of elements in the <code id="dom-tree-accessors:document-11"><a href="#document">Document</a></code> that have a <code>name</code> attribute with the value <var>name</var>.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-getelementsbyname" data-dfn-type="method"><code>getElementsByName(<var>elementName</var>)</code></dfn> method
  steps are to return a <a href="#live" id="dom-tree-accessors:live">live</a> <code id="dom-tree-accessors:nodelist-2"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> containing all the <a href="#html-elements" id="dom-tree-accessors:html-elements">HTML
  elements</a> in that document that have a <code>name</code> attribute whose value is
  <a id="dom-tree-accessors:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> the <var>elementName</var> argument, in <a id="dom-tree-accessors:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>. When the
  method is invoked on a <code id="dom-tree-accessors:document-12"><a href="#document">Document</a></code> object again with the same argument, the user agent
  may return the same as the object returned by the earlier call. In other cases, a new
  <code id="dom-tree-accessors:nodelist-3"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> object must be returned.</p>
  </div>

  

  <hr>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-currentscript" id="dom-document-currentscript-dev">currentScript</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/currentScript" title="The Document.currentScript property returns the <script> element whose script is currently being processed and isn't a JavaScript module. (For modules use import.meta instead.)">Document/currentScript</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>29+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="dom-tree-accessors:the-script-element-3"><a href="#the-script-element">script</a></code> element, or the <a id="dom-tree-accessors:svg-script" href="https://svgwg.org/svg2-draft/interact.html#ScriptElement" data-x-internal="svg-script">SVG <code>script</code></a> element,
    that is currently executing, as long as the element represents a <a href="#classic-script" id="dom-tree-accessors:classic-script">classic script</a>. In
    the case of reentrant script execution, returns the one that most recently started executing
    amongst those that have not yet finished executing.</p>

    <p>Returns null if the <code id="dom-tree-accessors:document-13"><a href="#document">Document</a></code> is not currently executing a <code id="dom-tree-accessors:the-script-element-4"><a href="#the-script-element">script</a></code> or
    <a id="dom-tree-accessors:svg-script-2" href="https://svgwg.org/svg2-draft/interact.html#ScriptElement" data-x-internal="svg-script">SVG <code>script</code></a> element (e.g., because the running script is an event
    handler, or a timeout), or if the currently executing <code id="dom-tree-accessors:the-script-element-5"><a href="#the-script-element">script</a></code> or <a id="dom-tree-accessors:svg-script-3" href="https://svgwg.org/svg2-draft/interact.html#ScriptElement" data-x-internal="svg-script">SVG
    <code>script</code></a> element represents a <a href="#module-script" id="dom-tree-accessors:module-script">module script</a>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-currentscript" data-dfn-type="attribute"><code>currentScript</code></dfn> attribute, on getting, must return
  the value to which it was most recently set. When the <code id="dom-tree-accessors:document-14"><a href="#document">Document</a></code> is created, the <code id="dom-tree-accessors:dom-document-currentscript"><a href="#dom-document-currentscript">currentScript</a></code> must be initialized to null.</p>
  </div>

  

  <p class="note">This API has fallen out of favor in the implementer and standards community, as
  it globally exposes <code id="dom-tree-accessors:the-script-element-6"><a href="#the-script-element">script</a></code> or <a id="dom-tree-accessors:svg-script-4" href="https://svgwg.org/svg2-draft/interact.html#ScriptElement" data-x-internal="svg-script">SVG <code>script</code></a> elements. As such,
  it is not available in newer contexts, such as when running <a href="#module-script" id="dom-tree-accessors:module-script-2">module
  scripts</a> or when running scripts in a <a id="dom-tree-accessors:shadow-tree" href="https://dom.spec.whatwg.org/#concept-shadow-tree" data-x-internal="shadow-tree">shadow tree</a>. We are looking into creating
  a new solution for identifying the running script in such contexts, which does not make it
  globally available: see <a href="https://github.com/whatwg/html/issues/1013">issue #1013</a>.</p>

  

  <hr>

  <div data-algorithm="">
  <p id="dom-document-namedItem-which">The <code id="dom-tree-accessors:document-15"><a href="#document">Document</a></code> interface <a href="https://webidl.spec.whatwg.org/#dfn-support-named-properties" id="dom-tree-accessors:support-named-properties" data-x-internal="support-named-properties">supports named properties</a>. The <a id="dom-tree-accessors:supported-property-names" href="https://webidl.spec.whatwg.org/#dfn-supported-property-names" data-x-internal="supported-property-names">supported property names</a> of a
  <code id="dom-tree-accessors:document-16"><a href="#document">Document</a></code> object <var>document</var> at any moment consist of the following, in
  <a id="dom-tree-accessors:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> according to the element that contributed them, ignoring later duplicates,
  and with values from <code id="dom-tree-accessors:the-id-attribute"><a href="#the-id-attribute">id</a></code> attributes coming before values from <code>name</code> attributes when the same element contributes both:</p>

  
  <ul><li><p>the value of the <code>name</code> content attribute for all
   <a href="#exposed" id="dom-tree-accessors:exposed">exposed</a> <code id="dom-tree-accessors:the-embed-element-3"><a href="#the-embed-element">embed</a></code>, <code id="dom-tree-accessors:the-form-element-3"><a href="#the-form-element">form</a></code>, <code id="dom-tree-accessors:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>,
   <code id="dom-tree-accessors:the-img-element-3"><a href="#the-img-element">img</a></code>, and <a href="#exposed" id="dom-tree-accessors:exposed-2">exposed</a> <code id="dom-tree-accessors:the-object-element"><a href="#the-object-element">object</a></code> elements that have a non-empty
   <code>name</code> content attribute and are <a id="dom-tree-accessors:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a> with
   <var>document</var> as their <a id="dom-tree-accessors:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>;</p></li><li><p>the value of the <code id="dom-tree-accessors:the-id-attribute-2"><a href="#the-id-attribute">id</a></code> content attribute for all
   <a href="#exposed" id="dom-tree-accessors:exposed-3">exposed</a> <code id="dom-tree-accessors:the-object-element-2"><a href="#the-object-element">object</a></code> elements that have a non-empty
   <code id="dom-tree-accessors:the-id-attribute-3"><a href="#the-id-attribute">id</a></code> content attribute and are <a id="dom-tree-accessors:in-a-document-tree-2" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a> with
   <var>document</var> as their <a id="dom-tree-accessors:root-2" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>; and</p></li><li><p>the value of the <code id="dom-tree-accessors:the-id-attribute-4"><a href="#the-id-attribute">id</a></code> content attribute for all
   <code id="dom-tree-accessors:the-img-element-4"><a href="#the-img-element">img</a></code> elements that have both a non-empty <code id="dom-tree-accessors:the-id-attribute-5"><a href="#the-id-attribute">id</a></code> content
   attribute and a non-empty <code>name</code> content attribute, and are <a id="dom-tree-accessors:in-a-document-tree-3" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a
   document tree</a> with <var>document</var> as their <a id="dom-tree-accessors:root-3" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p id="dom-document-nameditem">To <a id="dom-tree-accessors:determine-the-value-of-a-named-property" href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-a-named-property" data-x-internal="determine-the-value-of-a-named-property">determine the value of a named property</a>
  <var>name</var> for a <code id="dom-tree-accessors:document-17"><a href="#document">Document</a></code>, the user agent must return the value obtained using
  the following steps:</p>

  <ol><li>
    <p>Let <var>elements</var> be the list of <a href="#dom-document-nameditem-filter" id="dom-tree-accessors:dom-document-nameditem-filter">named
    elements</a> with the name <var>name</var> that are <a id="dom-tree-accessors:in-a-document-tree-4" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a> with the
    <code id="dom-tree-accessors:document-18"><a href="#document">Document</a></code> as their <a id="dom-tree-accessors:root-4" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>.</p>

    <p class="note">There will be at least one such element, since the algorithm would otherwise not
    have been <a href="https://webidl.spec.whatwg.org/#LegacyPlatformObjectGetOwnProperty" id="dom-tree-accessors:legacyplatformobjectgetownproperty" data-x-internal="legacyplatformobjectgetownproperty">invoked by Web IDL</a>.</p>
   </li><li><p>If <var>elements</var> has only one element, and that element is an <code id="dom-tree-accessors:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>
   element, and that <code id="dom-tree-accessors:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code> element's <a href="#content-navigable" id="dom-tree-accessors:content-navigable">content navigable</a> is not null, then
   return the <a href="#nav-wp" id="dom-tree-accessors:nav-wp">active <code>WindowProxy</code></a> of the element's
   <a href="#content-navigable" id="dom-tree-accessors:content-navigable-2">content navigable</a>.</p></li><li>
    <p>Otherwise, if <var>elements</var> has only one element, return that element.</p>
   </li><li>
    <p>Otherwise, return an <code id="dom-tree-accessors:htmlcollection-11"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="dom-tree-accessors:document-19"><a href="#document">Document</a></code> node,
    whose filter matches only <a href="#dom-document-nameditem-filter" id="dom-tree-accessors:dom-document-nameditem-filter-2">named elements</a> with
    the name <var>name</var>.</p> 
   </li></ol>
  </div>

  <div data-algorithm="">
  <p><dfn id="dom-document-nameditem-filter">Named elements</dfn> with the name <var>name</var>, for the purposes of the above algorithm, are those that are either:</p>

  
  <ul><li><a href="#exposed" id="dom-tree-accessors:exposed-4">Exposed</a> <code id="dom-tree-accessors:the-embed-element-4"><a href="#the-embed-element">embed</a></code>, <code id="dom-tree-accessors:the-form-element-4"><a href="#the-form-element">form</a></code>, <code id="dom-tree-accessors:the-iframe-element-4"><a href="#the-iframe-element">iframe</a></code>,
   <code id="dom-tree-accessors:the-img-element-5"><a href="#the-img-element">img</a></code>, or <a href="#exposed" id="dom-tree-accessors:exposed-5">exposed</a> <code id="dom-tree-accessors:the-object-element-3"><a href="#the-object-element">object</a></code> elements that have a <code>name</code> content attribute whose value is <var>name</var>, or</li><li><a href="#exposed" id="dom-tree-accessors:exposed-6">Exposed</a> <code id="dom-tree-accessors:the-object-element-4"><a href="#the-object-element">object</a></code> elements that have an <code id="dom-tree-accessors:the-id-attribute-6"><a href="#the-id-attribute">id</a></code> content attribute whose value is <var>name</var>, or</li><li><code id="dom-tree-accessors:the-img-element-6"><a href="#the-img-element">img</a></code> elements that have an <code id="dom-tree-accessors:the-id-attribute-7"><a href="#the-id-attribute">id</a></code> content attribute
   whose value is <var>name</var>, and that have a non-empty <code>name</code>
   content attribute present also.</li></ul>
  </div>

  <div data-algorithm="">
  <p>An <code id="dom-tree-accessors:the-embed-element-5"><a href="#the-embed-element">embed</a></code> or <code id="dom-tree-accessors:the-object-element-5"><a href="#the-object-element">object</a></code> element is said to be <dfn id="exposed">exposed</dfn> if it has
  no <a href="#exposed" id="dom-tree-accessors:exposed-7">exposed</a> <code id="dom-tree-accessors:the-object-element-6"><a href="#the-object-element">object</a></code> ancestor, and, for <code id="dom-tree-accessors:the-object-element-7"><a href="#the-object-element">object</a></code> elements, is
  additionally either not showing its <a href="#fallback-content" id="dom-tree-accessors:fallback-content">fallback content</a> or has no <code id="dom-tree-accessors:the-object-element-8"><a href="#the-object-element">object</a></code> or
  <code id="dom-tree-accessors:the-embed-element-6"><a href="#the-embed-element">embed</a></code> descendants.</p>
  </div>

  

  <hr>

  <p class="note">The <code id="dom-tree-accessors:dom-document-dir"><a href="#dom-document-dir">dir</a></code> attribute on the
  <code id="dom-tree-accessors:document-20"><a href="#document">Document</a></code> interface is defined along with the <code id="dom-tree-accessors:attr-dir"><a href="#attr-dir">dir</a></code>
  content attribute.</p>



  <h3 id="elements"><span class="secno">3.2</span> Elements<a href="#elements" class="self-link"></a></h3>

  <h4 id="semantics-2"><span class="secno">3.2.1</span> Semantics<a href="#semantics-2" class="self-link"></a></h4>

  <p>Elements, attributes, and attribute values in HTML are defined (by this specification) to have
  certain meanings (semantics). For example, the <code id="semantics-2:the-ol-element"><a href="#the-ol-element">ol</a></code> element represents an ordered list,
  and the <code id="semantics-2:attr-lang"><a href="#attr-lang">lang</a></code> attribute represents the language of the content.</p>

  <p>These definitions allow HTML processors, such as web browsers or search engines, to present and
  use documents and applications in a wide variety of contexts that the author might not have
  considered.</p>

  <div class="example">

   <p>As a simple example, consider a web page written by an author who only considered desktop
   computer web browsers:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->My Page<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Welcome to my page<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I like cars and lorries and have a big Jeep!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Where I live<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I live in a small hut on a mountain!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>Because HTML conveys <em>meaning</em>, rather than presentation, the same
   page can also be used by a small browser on a mobile phone, without any change to the page.
   Instead of headings being in large letters as on the desktop, for example, the browser on the
   mobile phone might use the same size text for the whole page, but with the headings in bold.</p>

   <p>But it goes further than just differences in screen size: the same page could equally be used
   by a blind user using a browser based around speech synthesis, which instead of displaying the
   page on a screen, reads the page to the user, e.g. using headphones. Instead of large text for
   the headings, the speech browser might use a different volume or a slower voice.</p>

   <p>That's not all, either. Since the browsers know which parts of the page are the headings, they
   can create a document outline that the user can use to quickly navigate around the document,
   using keys for "jump to next heading" or "jump to previous heading". Such features are especially
   common with speech browsers, where users would otherwise find quickly navigating a page quite
   difficult.</p>

   <p>Even beyond browsers, software can make use of this information. Search engines can use the
   headings to more effectively index a page, or to provide quick links to subsections of the page
   from their results. Tools can use the headings to create a table of contents (that is in fact how
   this very specification's table of contents is generated).</p>

   <p>This example has focused on headings, but the same principle applies to all of the semantics
   in HTML.</p>

  </div>

  <p>Authors must not use elements, attributes, or attribute values for purposes other than their
  appropriate intended semantic purpose, as doing so prevents software from correctly processing the
  page.</p>

  <div class="example">

   <p>For example, the following snippet, intended to represent the heading of a
   corporate site, is non-conforming because the second line is not intended to
   be a heading of a subsection, but merely a subheading or subtitle (a
   subordinate heading for the same section).</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->ACME Corporation<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->The leaders in arbitrary fast delivery since 1920<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 ...</code></pre>

   <p>The <code id="semantics-2:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code> element can be used for these kinds of situations:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->ACME Corporation<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The leaders in arbitrary fast delivery since 1920<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
 ...</code></pre>

  </div>

  <div class="example">

   <p>The document in this next example is similarly non-conforming, despite
   being syntactically correct, because the data placed in the cells is clearly
   not tabular data, and the <code id="semantics-2:the-cite-element"><a href="#the-cite-element">cite</a></code> element mis-used:</p>

   <pre lang="en-GB" class="bad"><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-GB"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c-> Demonstration <c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> My favourite animal is the cat. <c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->
     —<c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://example.org/~ernest/"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Ernest<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->,
     in an essay from 1992
    <c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>This would make software that relies on these semantics fail: for example,
   a speech browser that allowed a blind user to navigate tables in the document
   would report the quote above as a table, confusing the user; similarly, a
   tool that extracted titles of works from pages would extract "Ernest" as the
   title of a work, even though it's actually a person's name, not a title.</p>

   <p>A corrected version of this document might be:</p>

   <pre lang="en-GB"><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-GB"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c-> Demonstration <c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> My favourite animal is the cat. <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
   —<c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://example.org/~ernest/"</c-><c- p="">&gt;</c->Ernest<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->,
   in an essay from 1992
  <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Authors must not use elements, attributes, or attribute values that are not permitted by this
  specification or <a href="#other-applicable-specifications" id="semantics-2:other-applicable-specifications">other applicable specifications</a>, as doing so makes it significantly
  harder for the language to be extended in the future.</p>

  <div class="example">

   <p>In the next example, there is a non-conforming attribute value ("carpet") and a non-conforming
   attribute ("texture"), which is not permitted by this specification:</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Carpet: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"carpet"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"c"</c-> <c- e="">texture</c-><c- o="">=</c-><c- s="">"deep pile"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

   <p>Here would be an alternative and correct way to mark this up:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Carpet: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"carpet"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"c"</c-> <c- e="">data-texture</c-><c- o="">=</c-><c- s="">"deep pile"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p id="no-browsing-context">DOM nodes whose <a id="semantics-2:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#concept-document-bc" id="semantics-2:concept-document-bc">browsing context</a> is null are exempt from all document
  conformance requirements other than the <a href="#writing">HTML syntax</a> requirements and <a href="#writing-xhtml-documents">XML syntax</a> requirements.</p>

  <div class="example">
   <p>In particular, the <code id="semantics-2:the-template-element"><a href="#the-template-element">template</a></code> element's <a href="#template-contents" id="semantics-2:template-contents">template contents</a>'s <a id="semantics-2:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>'s <a href="#concept-document-bc" id="semantics-2:concept-document-bc-2">browsing context</a> is null. For
   example, the <a href="#concept-element-content-model" id="semantics-2:concept-element-content-model">content model</a> requirements and
   attribute value microsyntax requirements do not apply to a <code id="semantics-2:the-template-element-2"><a href="#the-template-element">template</a></code> element's
   <a href="#template-contents" id="semantics-2:template-contents-2">template contents</a>. In this example an <code id="semantics-2:the-img-element"><a href="#the-img-element">img</a></code> element has attribute values
   that are placeholders that would be invalid outside a <code id="semantics-2:the-template-element-3"><a href="#the-template-element">template</a></code> element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">template</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <mark><c- e="">src</c-><c- o="">=</c-><c- s="">"{{src}}"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"{{alt}}"</c-></mark><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">template</c-><c- p="">&gt;</c-></code></pre>

   <p>However, if the above markup were to omit the <code>&lt;/h1&gt;</code> end tag, that
   would be a violation of the <a href="#writing">HTML syntax</a>, and would thus be flagged as an
   error by conformance checkers.</p>
  </div>

  <p>Through scripting and using other mechanisms, the values of attributes, text, and indeed the
  entire structure of the document may change dynamically while a user agent is processing it. The
  semantics of a document at an instant in time are those represented by the state of the document
  at that instant in time, and the semantics of a document can therefore change over time. User
  agents must update their presentation of the document as this
  occurs.</p>

  <p class="example">HTML has a <code id="semantics-2:the-progress-element"><a href="#the-progress-element">progress</a></code> element that describes a progress bar. If its
  "value" attribute is dynamically updated by a script, the UA would update the rendering to show
  the progress changing.</p>



  <h4 id="elements-in-the-dom"><span class="secno">3.2.2</span> Elements in the DOM<a href="#elements-in-the-dom" class="self-link"></a></h4>

  <p>The nodes representing <a href="#html-elements" id="elements-in-the-dom:html-elements">HTML elements</a> in the DOM must
  implement, and expose to scripts, the interfaces listed for them in the relevant sections of this
  specification. This includes <a href="#html-elements" id="elements-in-the-dom:html-elements-2">HTML elements</a> in <a id="elements-in-the-dom:xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a>, even when
  those documents are in another context (e.g. inside an XSLT transform).</p>

  <p>Elements in the DOM <dfn id="represents">represent</dfn> things; that is, they have
  intrinsic <em>meaning</em>, also known as semantics.</p>

  <p class="example">For example, an <code id="elements-in-the-dom:the-ol-element"><a href="#the-ol-element">ol</a></code> element represents an ordered list.</p>

  <p>Elements can be <dfn id="referenced">referenced</dfn> (referred to) in some way, either
  explicitly or implicitly. One way that an element in the DOM can be explicitly referenced is by
  giving an <code id="elements-in-the-dom:the-id-attribute"><a href="#the-id-attribute">id</a></code> attribute to the element, and then creating a
  <a href="#hyperlink" id="elements-in-the-dom:hyperlink">hyperlink</a> with that <code id="elements-in-the-dom:the-id-attribute-2"><a href="#the-id-attribute">id</a></code> attribute's value as the <a href="#navigate-fragid" id="elements-in-the-dom:navigate-fragid">fragment</a> for the <a href="#hyperlink" id="elements-in-the-dom:hyperlink-2">hyperlink</a>'s <code id="elements-in-the-dom:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute value. Hyperlinks are not necessary for a
  reference, however; any manner of referring to the element in question will suffice.</p>

  <div class="example">
   <p>Consider the following <code id="elements-in-the-dom:the-figure-element"><a href="#the-figure-element">figure</a></code> element, which is given an <code id="elements-in-the-dom:the-id-attribute-3"><a href="#the-id-attribute">id</a></code> attribute:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"module-script-graph"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"module-script-graph.svg"</c->
       <c- e="">alt</c-><c- o="">=</c-><c- s="">"Module A depends on module B, which depends</c->
<c- s="">            on modules C and D."</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Figure 27: a simple module graph<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

   <p>A <a href="#hyperlink" id="elements-in-the-dom:hyperlink-3">hyperlink</a>-based <a href="#referenced" id="elements-in-the-dom:referenced">reference</a> could be created
   using the <code id="elements-in-the-dom:the-a-element"><a href="#the-a-element">a</a></code> element, like so:</p>

   <pre><code class="html">As we can see in <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#module-script-graph"</c-><c- p="">&gt;</c->figure 27<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->, ...</code></pre>

   <p>However, there are many other ways of <a href="#referenced" id="elements-in-the-dom:referenced-2">referencing</a> the
   <code id="elements-in-the-dom:the-figure-element-2"><a href="#the-figure-element">figure</a></code> element, such as:</p>

   <ul><li><p>"As depicted in the figure of modules A, B, C, and D..."</p></li><li><p>"In Figure 27..." (without a hyperlink)</p></li><li><p>"From the contents of the 'simple module graph' figure..."</p></li><li><p>"In the figure below..." (but <a href="#figure-note-about-references">this is
    discouraged</a>)</p></li></ul>
  </div>

  <p>The basic interface, from which all the <a href="#html-elements" id="elements-in-the-dom:html-elements-3">HTML elements</a>' interfaces inherit, and which must be used by elements that have no additional requirements, is
  the <code id="elements-in-the-dom:htmlelement"><a href="#htmlelement">HTMLElement</a></code> interface.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" title="The HTMLElement interface represents any HTML element. Some elements directly implement this interface, while others implement it via an interface that inherits it.">HTMLElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>1+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/title" title="The HTMLElement.title property represents the title of the element: the text usually displayed in a 'tooltip' popup when the mouse is over the node.">HTMLElement/title</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/lang" title="The HTMLElement.lang property gets or sets the base language of an element's attribute values and text content.">HTMLElement/lang</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert" title="The HTMLElement property inert reflects the value of the element's inert attribute. It is a boolean value that, when present, makes the browser &quot;ignore&quot; user input events for the element, including focus events and events from assistive technologies. The browser may also ignore page search and text selection in the element. This can be useful when building UIs such as modals where you would want to &quot;trap&quot; the focus inside the modal when it's visible.">HTMLElement/inert</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>112+</span></span><span class="safari yes"><span>Safari</span><span>15.5+</span></span><span class="chrome yes"><span>Chrome</span><span>102+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>102+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/accessKey" title="The HTMLElement.accessKey property sets the keystroke which a user can press to jump to a given element.">HTMLElement/accessKey</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>5+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>17+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLUnknownElement" title="The HTMLUnknownElement interface represents an invalid HTML element and derives from the HTMLElement interface, but without implementing any additional properties or methods.">HTMLUnknownElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>15+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlelement" data-dfn-type="interface"><c- g="">HTMLElement</c-></dfn> : <a id="elements-in-the-dom:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a> {
  [<a href="#htmlconstructor" id="elements-in-the-dom:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // metadata attributes
  [<a href="#cereactions" id="elements-in-the-dom:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="elements-in-the-dom:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLElement" id="dom-title" data-dfn-type="attribute"><c- g="">title</c-></dfn>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="elements-in-the-dom:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLElement" id="dom-lang" data-dfn-type="attribute"><c- g="">lang</c-></dfn>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-translate" id="elements-in-the-dom:dom-translate"><c- g="">translate</c-></a>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-dir" id="elements-in-the-dom:dom-dir"><c- g="">dir</c-></a>;

  // <a href="#editing" id="elements-in-the-dom:editing">user interaction</a>
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> (<c- b="">boolean</c-> <c- b="">or</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <c- b="">or</c-> <c- b="">DOMString</c->)? <a href="#dom-hidden" id="elements-in-the-dom:dom-hidden"><c- g="">hidden</c-></a>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="elements-in-the-dom:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLElement" id="dom-inert" data-dfn-type="attribute"><c- g="">inert</c-></dfn>;
  <c- b="">undefined</c-> <a href="#dom-click" id="elements-in-the-dom:dom-click"><c- g="">click</c-></a>();
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="elements-in-the-dom:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLElement" id="dom-accesskey" data-dfn-type="attribute"><c- g="">accessKey</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-accesskeylabel" id="elements-in-the-dom:dom-accesskeylabel"><c- g="">accessKeyLabel</c-></a>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-8"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-draggable" id="elements-in-the-dom:dom-draggable"><c- g="">draggable</c-></a>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-9"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-spellcheck" id="elements-in-the-dom:dom-spellcheck"><c- g="">spellcheck</c-></a>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-10"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="elements-in-the-dom:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-writingsuggestions" id="elements-in-the-dom:dom-writingsuggestions"><c- g="">writingSuggestions</c-></a>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-11"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="elements-in-the-dom:xattr-reflectsetter-2"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-autocapitalize" id="elements-in-the-dom:dom-autocapitalize"><c- g="">autocapitalize</c-></a>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-12"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-autocorrect" id="elements-in-the-dom:dom-autocorrect"><c- g="">autocorrect</c-></a>;

  [<a href="#cereactions" id="elements-in-the-dom:cereactions-13"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> [<a id="elements-in-the-dom:legacynulltoemptystring" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <a href="#dom-innertext" id="elements-in-the-dom:dom-innertext"><c- g="">innerText</c-></a>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-14"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> [<a id="elements-in-the-dom:legacynulltoemptystring-2" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <a href="#dom-outertext" id="elements-in-the-dom:dom-outertext"><c- g="">outerText</c-></a>;

  <a href="#elementinternals" id="elements-in-the-dom:elementinternals"><c- n="">ElementInternals</c-></a> <a href="#dom-attachinternals" id="elements-in-the-dom:dom-attachinternals"><c- g="">attachInternals</c-></a>();

  // The popover API
  <c- b="">undefined</c-> <a href="#dom-showpopover" id="elements-in-the-dom:dom-showpopover"><c- g="">showPopover</c-></a>(<c- b="">optional</c-> <a href="#showpopoveroptions" id="elements-in-the-dom:showpopoveroptions"><c- n="">ShowPopoverOptions</c-></a> <c- g="">options</c-> = {});
  <c- b="">undefined</c-> <a href="#dom-hidepopover" id="elements-in-the-dom:dom-hidepopover"><c- g="">hidePopover</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-togglepopover" id="elements-in-the-dom:dom-togglepopover"><c- g="">togglePopover</c-></a>(<c- b="">optional</c-> (<a href="#togglepopoveroptions" id="elements-in-the-dom:togglepopoveroptions"><c- n="">TogglePopoverOptions</c-></a> <c- b="">or</c-> <c- b="">boolean</c->) <c- g="">options</c-> = {});
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-15"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-popover" id="elements-in-the-dom:dom-popover"><c- g="">popover</c-></a>;

  [<a href="#cereactions" id="elements-in-the-dom:cereactions-16"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="elements-in-the-dom:xattr-reflect-5"><c- g="">Reflect</c-></a>, <a href="#xattr-reflectrange" id="elements-in-the-dom:xattr-reflectrange">ReflectRange=(0, 8)</a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLElement" id="dom-headingoffset" data-dfn-type="attribute"><c- g="">headingOffset</c-></dfn>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-17"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="elements-in-the-dom:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLElement" id="dom-headingreset" data-dfn-type="attribute"><c- g="">headingReset</c-></dfn>;
};

<c- b="">dictionary</c-> <dfn id="showpopoveroptions" data-dfn-type="dictionary"><c- g="">ShowPopoverOptions</c-></dfn> {
  <a href="#htmlelement" id="elements-in-the-dom:htmlelement-2"><c- n="">HTMLElement</c-></a> <dfn data-dfn-for="ShowPopoverOptions" id="dom-showpopoveroptions-source" data-dfn-type="dict-member"><c- g="">source</c-></dfn>;
};

<c- b="">dictionary</c-> <dfn id="togglepopoveroptions" data-dfn-type="dictionary"><c- g="">TogglePopoverOptions</c-></dfn> : <a href="#showpopoveroptions" id="elements-in-the-dom:showpopoveroptions-2"><c- n="">ShowPopoverOptions</c-></a> {
  <c- b="">boolean</c-> <dfn data-dfn-for="TogglePopoverOptions" id="dom-togglepopoveroptions-force" data-dfn-type="dict-member"><c- g="">force</c-></dfn>;
};

<a href="#htmlelement" id="elements-in-the-dom:htmlelement-3"><c- n="">HTMLElement</c-></a> <c- b="">includes</c-> <a href="#globaleventhandlers" id="elements-in-the-dom:globaleventhandlers"><c- n="">GlobalEventHandlers</c-></a>;
<a href="#htmlelement" id="elements-in-the-dom:htmlelement-4"><c- n="">HTMLElement</c-></a> <c- b="">includes</c-> <a href="#elementcontenteditable" id="elements-in-the-dom:elementcontenteditable"><c- n="">ElementContentEditable</c-></a>;
<a href="#htmlelement" id="elements-in-the-dom:htmlelement-5"><c- n="">HTMLElement</c-></a> <c- b="">includes</c-> <a href="#htmlorsvgelement" id="elements-in-the-dom:htmlorsvgelement"><c- n="">HTMLOrSVGElement</c-></a>;

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlunknownelement" data-dfn-type="interface"><c- g="">HTMLUnknownElement</c-></dfn> : <a href="#htmlelement" id="elements-in-the-dom:htmlelement-6"><c- n="">HTMLElement</c-></a> {
  // Note: <a href="#customized-built-in-element-restrictions">intentionally</a> no [<a href="#htmlconstructor" id="elements-in-the-dom:htmlconstructor-2">HTMLConstructor</a>]
};</code></pre>

  <p>The <code id="elements-in-the-dom:htmlelement-7"><a href="#htmlelement">HTMLElement</a></code> interface holds methods and attributes related to a number of
  disparate features, and the members of this interface are therefore described in various different
  sections of this specification.</p>

  

  <hr>

  <div data-algorithm="">
  <p>The <a id="elements-in-the-dom:element-interface" href="https://dom.spec.whatwg.org/#concept-element-interface" data-x-internal="element-interface">element interface</a> for an element with name <var>name</var> in the
  <a id="elements-in-the-dom:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a> is determined as follows:</p>

  <ol><li><p>If <var>name</var> is <code id="elements-in-the-dom:applet"><a href="#applet">applet</a></code>, <code id="elements-in-the-dom:bgsound"><a href="#bgsound">bgsound</a></code>, <code id="elements-in-the-dom:blink"><a href="#blink">blink</a></code>,
   <code id="elements-in-the-dom:isindex"><a href="#isindex">isindex</a></code>, <code id="elements-in-the-dom:keygen"><a href="#keygen">keygen</a></code>, <code id="elements-in-the-dom:multicol"><a href="#multicol">multicol</a></code>, <code id="elements-in-the-dom:nextid"><a href="#nextid">nextid</a></code>, or
   <code id="elements-in-the-dom:spacer"><a href="#spacer">spacer</a></code>, then return <code id="elements-in-the-dom:htmlunknownelement"><a href="#htmlunknownelement">HTMLUnknownElement</a></code>.</p></li><li><p>If <var>name</var> is <code id="elements-in-the-dom:acronym"><a href="#acronym">acronym</a></code>, <code id="elements-in-the-dom:basefont"><a href="#basefont">basefont</a></code>, <code id="elements-in-the-dom:big"><a href="#big">big</a></code>,
   <code id="elements-in-the-dom:center"><a href="#center">center</a></code>, <code id="elements-in-the-dom:nobr"><a href="#nobr">nobr</a></code>, <code id="elements-in-the-dom:noembed"><a href="#noembed">noembed</a></code>, <code id="elements-in-the-dom:noframes"><a href="#noframes">noframes</a></code>,
   <code id="elements-in-the-dom:plaintext"><a href="#plaintext">plaintext</a></code>, <code id="elements-in-the-dom:rb"><a href="#rb">rb</a></code>, <code id="elements-in-the-dom:rtc"><a href="#rtc">rtc</a></code>, <code id="elements-in-the-dom:strike"><a href="#strike">strike</a></code>, or
   <code id="elements-in-the-dom:tt"><a href="#tt">tt</a></code>, then return <code id="elements-in-the-dom:htmlelement-8"><a href="#htmlelement">HTMLElement</a></code>.</p></li><li><p>If <var>name</var> is <code id="elements-in-the-dom:listing"><a href="#listing">listing</a></code> or <code id="elements-in-the-dom:xmp"><a href="#xmp">xmp</a></code>, then return
   <code id="elements-in-the-dom:htmlpreelement"><a href="#htmlpreelement">HTMLPreElement</a></code>.</p></li><li><p>Otherwise, if this specification defines an interface appropriate for the <a href="#element-type" id="elements-in-the-dom:element-type">element
   type</a> corresponding to the local name <var>name</var>, then return that interface.</p></li><li><p>If <a href="#other-applicable-specifications" id="elements-in-the-dom:other-applicable-specifications">other applicable specifications</a> define an appropriate interface for
   <var>name</var>, then return the interface they define.</p></li><li><p>If <var>name</var> is a <a href="#valid-custom-element-name" id="elements-in-the-dom:valid-custom-element-name">valid custom element name</a>, then return
   <code id="elements-in-the-dom:htmlelement-9"><a href="#htmlelement">HTMLElement</a></code>.</p>

   </li><li><p>Return <code id="elements-in-the-dom:htmlunknownelement-2"><a href="#htmlunknownelement">HTMLUnknownElement</a></code>.</p></li></ol>
  </div>

  <p class="note">The use of <code id="elements-in-the-dom:htmlelement-10"><a href="#htmlelement">HTMLElement</a></code> instead of <code id="elements-in-the-dom:htmlunknownelement-3"><a href="#htmlunknownelement">HTMLUnknownElement</a></code> in
  the case of <a href="#valid-custom-element-name" id="elements-in-the-dom:valid-custom-element-name-2">valid custom element names</a> is done to
  ensure that any potential future <a href="#upgrades" id="elements-in-the-dom:upgrades">upgrades</a> only cause
  a linear transition of the element's prototype chain, from <code id="elements-in-the-dom:htmlelement-11"><a href="#htmlelement">HTMLElement</a></code> to a subclass,
  instead of a lateral one, from <code id="elements-in-the-dom:htmlunknownelement-4"><a href="#htmlunknownelement">HTMLUnknownElement</a></code> to an unrelated subclass.</p>

  <p>Features shared between HTML and SVG elements use the <code id="elements-in-the-dom:htmlorsvgelement-2"><a href="#htmlorsvgelement">HTMLOrSVGElement</a></code> interface
  mixin: <a href="#refsSVG">[SVG]</a></p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus" title="The autofocus global attribute is a Boolean attribute indicating that an element should be focused on page load, or when the <dialog> that it is part of is displayed.">Global_attributes/autofocus</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Partial implementation.">🔰 1+</span></span><span class="safari yes"><span>Safari</span><span title="Partial implementation.">🔰 4+</span></span><span class="chrome yes"><span>Chrome</span><span>79+</span></span><hr><span class="opera yes"><span>Opera</span><span>66+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Partial implementation.">🔰 10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>79+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>57+</span></span></div></div></div><pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="htmlorsvgelement" data-dfn-type="interface"><c- g="">HTMLOrSVGElement</c-></dfn> {
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#domstringmap" id="elements-in-the-dom:domstringmap"><c- n="">DOMStringMap</c-></a> <a href="#dom-dataset" id="elements-in-the-dom:dom-dataset"><c- g="">dataset</c-></a>;
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-noncedelement-nonce" id="elements-in-the-dom:dom-noncedelement-nonce"><c- g="">nonce</c-></a>; // <a href="#nonce-does-not-update-dom">intentionally no [CEReactions]</a>

  [<a href="#cereactions" id="elements-in-the-dom:cereactions-18"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="elements-in-the-dom:xattr-reflect-7"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLOrSVGElement" id="dom-fe-autofocus" data-dfn-type="attribute"><c- g="">autofocus</c-></dfn>;
  [<a href="#cereactions" id="elements-in-the-dom:cereactions-19"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="elements-in-the-dom:xattr-reflectsetter-3"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">long</c-> <a href="#dom-tabindex" id="elements-in-the-dom:dom-tabindex"><c- g="">tabIndex</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-focus" id="elements-in-the-dom:dom-focus"><c- g="">focus</c-></a>(<c- b="">optional</c-> <a href="#focusoptions" id="elements-in-the-dom:focusoptions"><c- n="">FocusOptions</c-></a> <c- g="">options</c-> = {});
  <c- b="">undefined</c-> <a href="#dom-blur" id="elements-in-the-dom:dom-blur"><c- g="">blur</c-></a>();
};</code></pre>

  

  <div class="example">
   <p>An example of an element that is neither an HTML nor SVG element is one created as
   follows:</p>

   <pre><code class="html">const el = document.createElementNS("some namespace", "example");
console.assert(el.constructor === Element);</code></pre>
  </div>

  

  <h4 id="html-element-constructors"><span class="secno">3.2.3</span> HTML element constructors<a href="#html-element-constructors" class="self-link"></a></h4>

  <p>To support the <a href="#custom-elements">custom elements</a> feature, all HTML elements have
  special constructor behavior. This is indicated via the <dfn id="htmlconstructor" data-dfn-type="extended-attribute" data-lt="HTMLConstructor"><code>[HTMLConstructor]</code></dfn> IDL
  <a id="html-element-constructors:extended-attribute" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a>.  It indicates that the interface object for the given interface
  will have a specific behavior when called, as defined in detail below.</p>

  <p>The <code id="html-element-constructors:htmlconstructor"><a href="#htmlconstructor">[HTMLConstructor]</a></code> extended attribute must take no
  arguments, and must only appear on <a href="https://webidl.spec.whatwg.org/#idl-constructors" id="html-element-constructors:constructor-operation" data-x-internal="constructor-operation">constructor
  operations</a>. It must appear only once on a constructor operation, and the interface must
  contain only the single, annotated constructor operation, and no others. The annotated
  constructor operation must be declared to take no arguments.</p>

  <div data-algorithm="">
  <p>Interfaces declared with constructor operations that are annotated with the <code id="html-element-constructors:htmlconstructor-2"><a href="#htmlconstructor">[HTMLConstructor]</a></code> extended attribute have the following
  <a id="html-element-constructors:overridden-constructor-steps" href="https://webidl.spec.whatwg.org/#overridden-constructor-steps" data-x-internal="overridden-constructor-steps">overridden constructor steps</a>:</p>

  <ol><li>
    <p>If <a id="html-element-constructors:newtarget" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a> is equal to the <a id="html-element-constructors:active-function-object" href="https://tc39.es/ecma262/#active-function-object" data-x-internal="active-function-object">active function
    object</a>, then throw a <code id="html-element-constructors:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>.</p>

    <div class="example">
     <p>This can occur when a custom element is defined using an <a id="html-element-constructors:element-interface" href="https://dom.spec.whatwg.org/#concept-element-interface" data-x-internal="element-interface">element interface</a> as
     its constructor:</p>

     <pre><code class="js">customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"bad-1"</c-><c- p="">,</c-> HTMLButtonElement<c- p="">);</c->
<c- k="">new</c-> HTMLButtonElement<c- p="">();</c->          <c- c1="">// (1)</c->
document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"bad-1"</c-><c- p="">);</c->  <c- c1="">// (2)</c-></code></pre>

     <p>In this case, during the execution of <code id="html-element-constructors:htmlbuttonelement"><a href="#htmlbuttonelement">HTMLButtonElement</a></code> (either explicitly, as
     in (1), or implicitly, as in (2)), both the <a id="html-element-constructors:active-function-object-2" href="https://tc39.es/ecma262/#active-function-object" data-x-internal="active-function-object">active function object</a> and
     <a id="html-element-constructors:newtarget-2" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a> are <code id="html-element-constructors:htmlbuttonelement-2"><a href="#htmlbuttonelement">HTMLButtonElement</a></code>. If this check was not present, it
     would be possible to create an instance of <code id="html-element-constructors:htmlbuttonelement-3"><a href="#htmlbuttonelement">HTMLButtonElement</a></code> whose local name was
     <code>bad-1</code>.</p>
    </div>
   </li><li><p>Let <var>registry</var> be null.</p></li><li>
    <p>If the <a id="html-element-constructors:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s <a href="#active-custom-element-constructor-map" id="html-element-constructors:active-custom-element-constructor-map">active custom element constructor
    map</a>[<a id="html-element-constructors:newtarget-3" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a>] <a href="https://infra.spec.whatwg.org/#map-exists" id="html-element-constructors:map-exists" data-x-internal="map-exists">exists</a>:</p>

    <ol><li><p>Set <var>registry</var> to the <a id="html-element-constructors:surrounding-agent-2" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s <a href="#active-custom-element-constructor-map" id="html-element-constructors:active-custom-element-constructor-map-2">active custom
     element constructor map</a>[<a id="html-element-constructors:newtarget-4" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a>].</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="html-element-constructors:map-remove" data-x-internal="map-remove">Remove</a> the <a id="html-element-constructors:surrounding-agent-3" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s
     <a href="#active-custom-element-constructor-map" id="html-element-constructors:active-custom-element-constructor-map-3">active custom element constructor map</a>[<a id="html-element-constructors:newtarget-5" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a>].</p></li></ol>
   </li><li><p>Otherwise, set <var>registry</var> to the <a href="#current-global-object" id="html-element-constructors:current-global-object">current global object</a>'s <a href="#concept-document-window" id="html-element-constructors:concept-document-window">associated <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="html-element-constructors:document-custom-element-registry" data-x-internal="document-custom-element-registry">custom element registry</a>.</p></li><li>
    <p>Let <var>definition</var> be the item in <var>registry</var>'s <a href="#custom-element-definition-set" id="html-element-constructors:custom-element-definition-set">custom element
    definition set</a> with <a href="#concept-custom-element-definition-constructor" id="html-element-constructors:concept-custom-element-definition-constructor">constructor</a> equal to
    <a id="html-element-constructors:newtarget-6" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a>. If there is no such item, then throw a <code id="html-element-constructors:typeerror-2"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>.</p>

    <p class="note">Since there can be no item in <var>registry</var>'s <a href="#custom-element-definition-set" id="html-element-constructors:custom-element-definition-set-2">custom element
    definition set</a> with a <a href="#concept-custom-element-definition-constructor" id="html-element-constructors:concept-custom-element-definition-constructor-2">constructor</a> of undefined, this
    step also prevents HTML element constructors from being called as functions (since in that case
    <a id="html-element-constructors:newtarget-7" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a> will be undefined).</p>
   </li><li><p>Let <var>isValue</var> be null.</p></li><li>
    <p>If <var>definition</var>'s <a href="#concept-custom-element-definition-local-name" id="html-element-constructors:concept-custom-element-definition-local-name">local
    name</a> is equal to <var>definition</var>'s <a href="#concept-custom-element-definition-name" id="html-element-constructors:concept-custom-element-definition-name">name</a> (i.e., <var>definition</var> is for
    an <a href="#autonomous-custom-element" id="html-element-constructors:autonomous-custom-element">autonomous custom element</a>):</p>

    <ol><li>
      <p>If the <a id="html-element-constructors:active-function-object-3" href="https://tc39.es/ecma262/#active-function-object" data-x-internal="active-function-object">active function object</a> is not <code id="html-element-constructors:htmlelement"><a href="#htmlelement">HTMLElement</a></code>, then throw a
      <code id="html-element-constructors:typeerror-3"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>.</p>

      <div class="example">
       <p>This can occur when a custom element is defined to not extend any local names, but
       inherits from a non-<code id="html-element-constructors:htmlelement-2"><a href="#htmlelement">HTMLElement</a></code> class:</p>

       <pre><code class="js">customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"bad-2"</c-><c- p="">,</c-> <c- a="">class</c-> Bad2 <c- k="">extends</c-> HTMLParagraphElement <c- p="">{});</c-></code></pre>

       <p>In this case, during the (implicit) <code>super()</code> call that occurs when
       constructing an instance of <code>Bad2</code>, the <a id="html-element-constructors:active-function-object-4" href="https://tc39.es/ecma262/#active-function-object" data-x-internal="active-function-object">active function
       object</a> is <code id="html-element-constructors:htmlparagraphelement"><a href="#htmlparagraphelement">HTMLParagraphElement</a></code>, not <code id="html-element-constructors:htmlelement-3"><a href="#htmlelement">HTMLElement</a></code>.</p>
      </div>
     </li></ol>
   </li><li>
    <p>Otherwise (i.e., if <var>definition</var> is for a <a href="#customized-built-in-element" id="html-element-constructors:customized-built-in-element">customized built-in
    element</a>):</p>

    <ol><li><p>Let <var>valid local names</var> be the list of local names for elements defined in this
     specification or in <a href="#other-applicable-specifications" id="html-element-constructors:other-applicable-specifications">other applicable specifications</a> that use the <a id="html-element-constructors:active-function-object-5" href="https://tc39.es/ecma262/#active-function-object" data-x-internal="active-function-object">active
     function object</a> as their <a id="html-element-constructors:element-interface-2" href="https://dom.spec.whatwg.org/#concept-element-interface" data-x-internal="element-interface">element interface</a>.</p></li><li>
      <p>If <var>valid local names</var> does not contain <var>definition</var>'s <a href="#concept-custom-element-definition-local-name" id="html-element-constructors:concept-custom-element-definition-local-name-2">local name</a>, then throw a
      <code id="html-element-constructors:typeerror-4"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>.</p>

      <div class="example">
       <p>This can occur when a custom element is defined to extend a given local name but inherits
       from the wrong class:</p>

       <pre><code class="js">customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"bad-3"</c-><c- p="">,</c-> <c- a="">class</c-> Bad3 <c- k="">extends</c-> HTMLQuoteElement <c- p="">{},</c-> <c- p="">{</c-> <c- k="">extends</c-><c- o="">:</c-> <c- u="">"p"</c-> <c- p="">});</c-></code></pre>

       <p>In this case, during the (implicit) <code>super()</code> call that occurs when
       constructing an instance of <code>Bad3</code>, <var>valid local names</var> is the
       list containing <code id="html-element-constructors:the-q-element"><a href="#the-q-element">q</a></code> and <code id="html-element-constructors:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code>, but <var>definition</var>'s <a href="#concept-custom-element-definition-local-name" id="html-element-constructors:concept-custom-element-definition-local-name-3">local name</a> is <code id="html-element-constructors:the-p-element"><a href="#the-p-element">p</a></code>,
       which is not in that list.</p>
      </div>
     </li><li><p>Set <var>isValue</var> to <var>definition</var>'s <a href="#concept-custom-element-definition-name" id="html-element-constructors:concept-custom-element-definition-name-2">name</a>.</p></li></ol>
   </li><li>
    <p>If <var>definition</var>'s <a href="#concept-custom-element-definition-construction-stack" id="html-element-constructors:concept-custom-element-definition-construction-stack">construction stack</a> is
    empty:</p>

    <ol><li><p>Let <var>element</var> be the result of <a href="https://webidl.spec.whatwg.org/#internally-create-a-new-object-implementing-the-interface" id="html-element-constructors:internally-create-a-new-object-implementing-the-interface" data-x-internal="internally-create-a-new-object-implementing-the-interface">internally creating a new object implementing the interface</a>
     to which the <a id="html-element-constructors:active-function-object-6" href="https://tc39.es/ecma262/#active-function-object" data-x-internal="active-function-object">active function object</a> corresponds, given the <a id="html-element-constructors:current-realm" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current
     realm</a> and <a id="html-element-constructors:newtarget-8" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a>.</p></li><li><p>Set <var>element</var>'s <a id="html-element-constructors:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> to the <a href="#current-global-object" id="html-element-constructors:current-global-object-2">current global
     object</a>'s <a href="#concept-document-window" id="html-element-constructors:concept-document-window-2">associated
     <code>Document</code></a>.</p></li><li><p>Set <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="html-element-constructors:concept-element-namespace" data-x-internal="concept-element-namespace">namespace</a> to
     the <a id="html-element-constructors:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>.</p></li><li><p>Set <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-namespace-prefix" id="html-element-constructors:concept-element-namespace-prefix" data-x-internal="concept-element-namespace-prefix">namespace
     prefix</a> to null.</p></li><li><p>Set <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="html-element-constructors:concept-element-local-name" data-x-internal="concept-element-local-name">local name</a> to
     <var>definition</var>'s <a href="#concept-custom-element-definition-local-name" id="html-element-constructors:concept-custom-element-definition-local-name-4">local
     name</a>.</p></li><li><p>Set <var>element</var>'s <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="html-element-constructors:element-custom-element-registry" data-x-internal="element-custom-element-registry">custom element
     registry</a> to <var>registry</var>.</p></li><li><p>Set <var>element</var>'s <a id="html-element-constructors:custom-element-state" href="https://dom.spec.whatwg.org/#concept-element-custom-element-state" data-x-internal="custom-element-state">custom element state</a> to "<code>custom</code>".</p></li><li><p>Set <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-custom-element-definition" id="html-element-constructors:concept-element-custom-element-definition" data-x-internal="concept-element-custom-element-definition">custom
     element definition</a> to <var>definition</var>.</p></li><li><p>Set <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="html-element-constructors:concept-element-is-value" data-x-internal="concept-element-is-value"><code>is</code> value</a> to <var>isValue</var>.</p></li><li><p>Return <var>element</var>.</p></li></ol>

    <p class="note">This occurs when author script constructs a new custom element directly, e.g.,
    via <code>new MyCustomElement()</code>.</p>
   </li><li><p>Let <var>prototype</var> be ? <a href="https://tc39.es/ecma262/#sec-get-o-p" id="html-element-constructors:js-get" data-x-internal="js-get">Get</a>(<a id="html-element-constructors:newtarget-9" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a>,
   "prototype").</p></li><li>
    <p>If <var>prototype</var> <a href="https://tc39.es/ecma262/#sec-object-type" id="html-element-constructors:js-object" data-x-internal="js-object">is not an Object</a>, then:</p>

    <ol><li><p>Let <var>realm</var> be ? <a id="html-element-constructors:getfunctionrealm" href="https://tc39.es/ecma262/#sec-getfunctionrealm" data-x-internal="getfunctionrealm">GetFunctionRealm</a>(<a id="html-element-constructors:newtarget-10" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a>).</p></li><li><p>Set <var>prototype</var> to the <a id="html-element-constructors:interface-prototype-object" href="https://webidl.spec.whatwg.org/#dfn-interface-prototype-object" data-x-internal="interface-prototype-object">interface prototype object</a> of
     <var>realm</var> whose interface is the same as the interface of the <a id="html-element-constructors:active-function-object-7" href="https://tc39.es/ecma262/#active-function-object" data-x-internal="active-function-object">active function
     object</a>.</p></li></ol>

    <p class="note">The realm of the <a id="html-element-constructors:active-function-object-8" href="https://tc39.es/ecma262/#active-function-object" data-x-internal="active-function-object">active function object</a> might not be
    <var>realm</var>, so we are using the more general concept of "the same interface" across
    realms; we are not looking for equality of <a href="https://webidl.spec.whatwg.org/#dfn-interface-object" id="html-element-constructors:interface-object" data-x-internal="interface-object">interface
    objects</a>. This fallback behavior, including using the realm of <a id="html-element-constructors:newtarget-11" href="https://tc39.es/ecma262/#sec-built-in-function-objects" data-x-internal="newtarget">NewTarget</a> and
    looking up the appropriate prototype there, is designed to match analogous behavior for the
    JavaScript built-ins and Web IDL's <a id="html-element-constructors:internally-create-a-new-object-implementing-the-interface-2" href="https://webidl.spec.whatwg.org/#internally-create-a-new-object-implementing-the-interface" data-x-internal="internally-create-a-new-object-implementing-the-interface">internally create a new object implementing the
    interface</a> algorithm.</p>
   </li><li><p>Let <var>element</var> be the last entry in <var>definition</var>'s <a href="#concept-custom-element-definition-construction-stack" id="html-element-constructors:concept-custom-element-definition-construction-stack-2">construction stack</a>.</p></li><li>
    <p>If <var>element</var> is an <a href="#concept-already-constructed-marker" id="html-element-constructors:concept-already-constructed-marker"><i>already
    constructed</i> marker</a>, then throw a <code id="html-element-constructors:typeerror-5"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>.</p>

    <div class="example">
     <p>This can occur when the author code inside the <a href="#custom-element-constructor" id="html-element-constructors:custom-element-constructor">custom element
     constructor</a> <a href="#custom-element-conformance">non-conformantly</a> creates another
     instance of the class being constructed, before calling <code>super()</code>:</p>

     <pre><code class="js"><c- a="">let</c-> doSillyThing <c- o="">=</c-> <c- kc="">true</c-><c- p="">;</c->

<c- a="">class</c-> DontDoThis <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->doSillyThing<c- p="">)</c-> <c- p="">{</c->
      doSillyThing <c- o="">=</c-> <c- kc="">false</c-><c- p="">;</c->
      <c- k="">new</c-> DontDoThis<c- p="">();</c->
      <c- c1="">// Now the construction stack will contain an </c-><i><c- c1="">already constructed</c-></i><c- c1=""> marker.</c->
    <c- p="">}</c->

    <c- c1="">// This will then fail with a TypeError:</c->
    <c- k="">super</c-><c- p="">();</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>
    </div>

    <div class="example">
     <p>This can also occur when author code inside the <a href="#custom-element-constructor" id="html-element-constructors:custom-element-constructor-2">custom element constructor</a> <a href="#custom-element-conformance">non-conformantly</a> calls <code>super()</code>
     twice, since per the JavaScript specification, this actually executes the superclass
     constructor (i.e. this algorithm) twice, before throwing an error:

     </p><pre><code class="js"><c- a="">class</c-> DontDoThisEither <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->

    <c- c1="">// This will throw, but not until it has already called into the HTMLElement constructor</c->
    <c- k="">super</c-><c- p="">();</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>
    </div>
   </li><li><p>Perform ? <var>element</var>.[[SetPrototypeOf]](<var>prototype</var>).</p></li><li><p>Replace the last entry in <var>definition</var>'s <a href="#concept-custom-element-definition-construction-stack" id="html-element-constructors:concept-custom-element-definition-construction-stack-3">construction stack</a> with an
   <a href="#concept-already-constructed-marker" id="html-element-constructors:concept-already-constructed-marker-2"><i>already constructed</i>
   marker</a>.</p></li><li>
    <p>Return <var>element</var>.</p>

    <p class="note">This step is normally reached when <a href="#upgrades" id="html-element-constructors:upgrades">upgrading</a> a custom element; the existing element is
    returned, so that the <code>super()</code> call inside the <a href="#custom-element-constructor" id="html-element-constructors:custom-element-constructor-3">custom element
    constructor</a> assigns that existing element to <b>this</b>.</p>
   </li></ol>
  </div>

  <hr>

  <p>In addition to the constructor behavior implied by <code id="html-element-constructors:htmlconstructor-3"><a href="#htmlconstructor">[HTMLConstructor]</a></code>, some elements also have <a href="https://webidl.spec.whatwg.org/#dfn-named-constructor" id="html-element-constructors:named-constructor" data-x-internal="named-constructor">named constructors</a> (which are really factory functions with a modified <code>prototype</code> property).

  </p><div class="example">
   <p>Named constructors for HTML elements can also be used in an <code id="html-element-constructors:dom-elementdefinitionoptions-extends"><a href="#dom-elementdefinitionoptions-extends">extends</a></code> clause when defining a <a href="#custom-element-constructor" id="html-element-constructors:custom-element-constructor-4">custom
   element constructor</a>:</p>

   <pre><code class="js"><c- a="">class</c-> AutoEmbiggenedImage <c- k="">extends</c-> Image <c- p="">{</c->
  constructor<c- p="">(</c->width<c- p="">,</c-> height<c- p="">)</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">(</c->width <c- o="">*</c-> <c- mf="">10</c-><c- p="">,</c-> height <c- o="">*</c-> <c- mf="">10</c-><c- p="">);</c->
  <c- p="">}</c->
<c- p="">}</c->

customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"auto-embiggened"</c-><c- p="">,</c-> AutoEmbiggenedImage<c- p="">,</c-> <c- p="">{</c-> <c- k="">extends</c-><c- o="">:</c-> <c- u="">"img"</c-> <c- p="">});</c->

<c- a="">const</c-> image <c- o="">=</c-> <c- k="">new</c-> AutoEmbiggenedImage<c- p="">(</c-><c- mf="">15</c-><c- p="">,</c-> <c- mf="">20</c-><c- p="">);</c->
console<c- p="">.</c->assert<c- p="">(</c->image<c- p="">.</c->width <c- o="">===</c-> <c- mf="">150</c-><c- p="">);</c->
console<c- p="">.</c->assert<c- p="">(</c->image<c- p="">.</c->height <c- o="">===</c-> <c- mf="">200</c-><c- p="">);</c-></code></pre>
  </div>

  



  <h4 id="element-definitions"><span class="secno">3.2.4</span> Element definitions<a href="#element-definitions" class="self-link"></a></h4>

  <p>Each element in this specification has a definition that includes the following
  information:</p>

  <dl><dt><dfn id="concept-element-categories">Categories</dfn></dt><dd><p>A list of <a href="#content-categories" id="element-definitions:content-categories">categories</a> to which the element belongs.
   These are used when defining the <a href="#content-models" id="element-definitions:content-models">content models</a> for each element.</p></dd><dt><dfn id="concept-element-contexts">Contexts in which this element can be used</dfn></dt><dd>
    <p>A <em>non-normative</em> description of where the element can be used. This information is
    redundant with the content models of elements that allow this one as a child, and is provided
    only as a convenience.</p>

    <div class="note">
     <p>For simplicity, only the most specific expectations are listed.</p>

     <p>For example, all <a href="#phrasing-content-2" id="element-definitions:phrasing-content-2">phrasing content</a> is <a href="#flow-content-2" id="element-definitions:flow-content-2">flow content</a>. Thus, elements
     that are <a href="#phrasing-content-2" id="element-definitions:phrasing-content-2-2">phrasing content</a> will only be listed as "where <a href="#phrasing-content-2" id="element-definitions:phrasing-content-2-3">phrasing
     content</a> is expected", since this is the more-specific expectation. Anywhere that expects
     <a href="#flow-content-2" id="element-definitions:flow-content-2-2">flow content</a> also expects <a href="#phrasing-content-2" id="element-definitions:phrasing-content-2-4">phrasing content</a>, and thus also meets this
     expectation.</p>
    </div>
   </dd><dt><dfn id="concept-element-content-model">Content model</dfn></dt><dd><p>A normative description of what content must be included as children and descendants of
   the element.</p></dd><dt><dfn id="concept-element-tag-omission">Tag omission in text/html</dfn></dt><dd><p>A <em>non-normative</em> description of whether, in the <code id="element-definitions:text/html"><a href="#text/html">text/html</a></code> syntax, the
   <a href="#syntax-start-tag" id="element-definitions:syntax-start-tag">start</a> and <a href="#syntax-end-tag" id="element-definitions:syntax-end-tag">end</a> tags can
   be omitted. This information is redundant with the normative requirements given in the <a href="#syntax-tag-omission" id="element-definitions:syntax-tag-omission">optional tags</a> section, and is provided in the element
   definitions only as a convenience.</p></dd><dt><dfn id="concept-element-attributes">Content attributes</dfn></dt><dd><p>A normative list of attributes that may be specified on the element (except where
   otherwise disallowed), along with non-normative descriptions of those attributes. (The content to
   the left of the dash is normative, the content to the right of the dash is not.)</p></dd><dt><dfn id="concept-element-accessibility-considerations">Accessibility considerations</dfn></dt><dd>
    <p>For authors: Conformance requirements for use of <cite>ARIA</cite> <code id="element-definitions:attr-aria-role"><a href="#attr-aria-role">role</a></code> and <code id="element-definitions:attr-aria-*"><a href="#attr-aria-*">aria-*</a></code> attributes are
    defined in <cite>ARIA in HTML</cite>. <a href="#refsARIA">[ARIA]</a> <a href="#refsARIAHTML">[ARIAHTML]</a></p>

    <p>For implementers: User agent requirements for implementing accessibility API semantics are
    defined in <cite>HTML Accessibility API Mappings</cite>. <a href="#refsHTMLAAM">[HTMLAAM]</a></p>
   </dd><dt><dfn id="concept-element-dom">DOM interface</dfn></dt><dd><p>A normative definition of a DOM interface that such elements must implement.</p></dd></dl>

  <p>This is then followed by a description of what the element <a href="#represents" id="element-definitions:represents">represents</a>, along with
  any additional normative conformance criteria that may apply to authors and implementations. Examples are sometimes also included.</p>


  <h5 id="attributes"><span class="secno">3.2.4.1</span> Attributes<a href="#attributes" class="self-link"></a></h5>

  <p id="attribute-text">An attribute value is a string. Except where otherwise specified,
  attribute values on <a href="#html-elements" id="attributes:html-elements">HTML elements</a> may be any string value, including the empty
  string, and there is no restriction on what text can be specified in such attribute values.</p>



  <h4 id="content-models"><span class="secno">3.2.5</span> <dfn>Content models</dfn><a href="#content-models" class="self-link"></a></h4>

  <p>Each element defined in this specification has a content model: a description of the element's
  expected <a href="#concept-html-contents" id="content-models:concept-html-contents">contents</a>. An <a href="#html-elements" id="content-models:html-elements">HTML
  element</a> must have contents that match the requirements described in the element's content
  model. The <dfn id="concept-html-contents">contents</dfn> of an element are its children in the
  DOM.</p>

  <p><a id="content-models:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> is always allowed between elements. User agents represent these
  characters between elements in the source markup as <code id="content-models:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes in the DOM. Empty <code id="content-models:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes and
  <code id="content-models:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes consisting of just sequences of those characters are considered
  <dfn id="inter-element-whitespace">inter-element whitespace</dfn>.</p>

  <p><a href="#inter-element-whitespace" id="content-models:inter-element-whitespace">Inter-element whitespace</a>, comment nodes, and processing instruction nodes must be
  ignored when establishing whether an element's contents match the element's content model or not,
  and must be ignored when following algorithms that define document and element semantics.</p>

  <p data-var-scope="" class="note">Thus, an element <var>A</var> is said to be <i>preceded or followed</i>
  by a second element <var>B</var> if <var>A</var> and <var>B</var> have
  the same parent node and there are no other element nodes or <code id="content-models:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes (other than
  <a href="#inter-element-whitespace" id="content-models:inter-element-whitespace-2">inter-element whitespace</a>) between them. Similarly, a node is the <i>only child</i> of
  an element if that element contains no other nodes other than <a href="#inter-element-whitespace" id="content-models:inter-element-whitespace-3">inter-element
  whitespace</a>, comment nodes, and processing instruction nodes.</p>

  <p>Authors must not use <a href="#html-elements" id="content-models:html-elements-2">HTML elements</a> anywhere except where they are explicitly
  allowed, as defined for each element, or as explicitly required by other specifications. For XML
  compound documents, these contexts could be inside elements from other namespaces, if those
  elements are defined as providing the relevant contexts.</p>

  <p class="example"><cite>The Atom Syndication Format</cite> defines a <code>content</code> element. When its <code>type</code> attribute has the value
  <code>xhtml</code>, <cite>The Atom Syndication Format</cite> requires that it contain a
  single HTML <code id="content-models:the-div-element"><a href="#the-div-element">div</a></code> element. Thus, a <code id="content-models:the-div-element-2"><a href="#the-div-element">div</a></code> element is allowed in that context,
  even though this is not explicitly normatively stated by this specification. <a href="#refsATOM">[ATOM]</a></p>

  <p>In addition, <a href="#html-elements" id="content-models:html-elements-3">HTML elements</a> may be orphan nodes (i.e. without a parent node).</p>

  <div class="example">

   <p>For example, creating a <code id="content-models:the-td-element"><a href="#the-td-element">td</a></code> element and storing it in a global variable in a
   script is conforming, even though <code id="content-models:the-td-element-2"><a href="#the-td-element">td</a></code> elements are otherwise only supposed to be used
   inside <code id="content-models:the-tr-element"><a href="#the-tr-element">tr</a></code> elements.</p>

   <pre><code class="js"><c- a="">var</c-> data <c- o="">=</c-> <c- p="">{</c->
  name<c- o="">:</c-> <c- u="">"Banana"</c-><c- p="">,</c->
  cell<c- o="">:</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'td'</c-><c- p="">),</c->
<c- p="">};</c-></code></pre>

  </div>


  <h5 id="the-nothing-content-model"><span class="secno">3.2.5.1</span> The "nothing" content model<a href="#the-nothing-content-model" class="self-link"></a></h5>

  <p>When an element's content model is <dfn id="concept-content-nothing">nothing</dfn>, the
  element must contain no <code id="the-nothing-content-model:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes (other than <a href="#inter-element-whitespace" id="the-nothing-content-model:inter-element-whitespace">inter-element whitespace</a>)
  and no element nodes.</p>

  <p class="note">Most HTML elements whose content model is "nothing" are also, for convenience,
  <a href="#void-elements" id="the-nothing-content-model:void-elements">void elements</a> (elements that have no <a href="#syntax-end-tag" id="the-nothing-content-model:syntax-end-tag">end tag</a> in
  the <a href="#syntax">HTML syntax</a>). However, these are entirely separate concepts.</p>


  <h5 id="kinds-of-content"><span class="secno">3.2.5.2</span> Kinds of content<a href="#kinds-of-content" class="self-link"></a></h5>

  <p>Each element in HTML falls into zero or more <dfn id="content-categories">categories</dfn>
  that group elements with similar characteristics together. The following broad categories are used
  in this specification:</p>

  <ul class="brief"><li><a href="#metadata-content-2" id="kinds-of-content:metadata-content-2">Metadata content</a></li><li><a href="#flow-content-2" id="kinds-of-content:flow-content-2">Flow content</a></li><li><a href="#sectioning-content-2" id="kinds-of-content:sectioning-content-2">Sectioning content</a></li><li><a href="#heading-content-2" id="kinds-of-content:heading-content-2">Heading content</a></li><li><a href="#phrasing-content-2" id="kinds-of-content:phrasing-content-2">Phrasing content</a></li><li><a href="#embedded-content-category" id="kinds-of-content:embedded-content-category">Embedded content</a></li><li><a href="#interactive-content-2" id="kinds-of-content:interactive-content-2">Interactive content</a></li></ul>

  <p class="note">Some elements also fall into other categories, which are defined in other parts of
  this specification.</p>

  <p>These categories are related as follows:</p>

  <p><iframe src="/images/content-venn.svg" width="1000" height="288"></iframe></p>

  <p>Sectioning content, heading content, phrasing content, embedded content, and interactive
  content are all types of flow content. Metadata is sometimes flow content. Metadata and
  interactive content are sometimes phrasing content. Embedded content is also a type of phrasing
  content, and sometimes is interactive content.</p>

  <p>Other categories are also used for specific purposes, e.g. form controls are specified using a
  number of categories to define common requirements. Some elements have unique requirements and do
  not fit into any particular category.</p>


  <h6 id="metadata-content"><span class="secno">3.2.5.2.1</span> Metadata content<a href="#metadata-content" class="self-link"></a></h6>

  <p><dfn id="metadata-content-2" data-export="">Metadata content</dfn> is content that sets up the presentation or behavior of the
  rest of the content, or that sets up the relationship of the document with other documents, or
  that conveys other "out of band" information.</p>

  
  <ul class="brief category-list"><li><code id="metadata-content:the-base-element"><a href="#the-base-element">base</a></code></li><li><code id="metadata-content:the-link-element"><a href="#the-link-element">link</a></code></li><li><code id="metadata-content:the-meta-element"><a href="#the-meta-element">meta</a></code></li><li><code id="metadata-content:the-noscript-element"><a href="#the-noscript-element">noscript</a></code></li><li><code id="metadata-content:the-script-element"><a href="#the-script-element">script</a></code></li><li><code id="metadata-content:the-style-element"><a href="#the-style-element">style</a></code></li><li><code id="metadata-content:the-template-element"><a href="#the-template-element">template</a></code></li><li><code id="metadata-content:the-title-element"><a href="#the-title-element">title</a></code></li></ul>

  <p>Elements from other namespaces whose semantics are primarily metadata-related (e.g. RDF) are
  also <a href="#metadata-content-2" id="metadata-content:metadata-content-2">metadata content</a>.</p>

  <div class="example">

   <p>Thus, in the XML serialization, one can use RDF, like this:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">html</c-> <c- e="">xmlns</c-><c- o="">=</c-><c- s="">"http://www.w3.org/1999/xhtml"</c->
      <c- e="">xmlns:r</c-><c- o="">=</c-><c- s="">"http://www.w3.org/1999/02/22-rdf-syntax-ns#"</c-> <c- e="">xml:lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hedral's Home Page<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">r:RDF</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">Person</c-> <c- e="">xmlns</c-><c- o="">=</c-><c- s="">"http://www.w3.org/2000/10/swap/pim/contact#"</c->
           <c- e="">r:about</c-><c- o="">=</c-><c- s="">"https://hedral.example.com/#"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">fullName</c-><c- p="">&gt;</c->Cat Hedral<c- p="">&lt;/</c-><c- f="">fullName</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">mailbox</c-> <c- e="">r:resource</c-><c- o="">=</c-><c- s="">"mailto:hedral@damowmow.com"</c-><c- p="">/&gt;</c->
    <c- p="">&lt;</c-><c- f="">personalTitle</c-><c- p="">&gt;</c->Sir<c- p="">&lt;/</c-><c- f="">personalTitle</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">Person</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">r:RDF</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->My home page<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I like playing with string, I guess. Sister says squirrels are fun
  too so sometimes I follow her to play with them.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>This isn't possible in the HTML serialization, however.</p>

  </div>


  <h6 id="flow-content"><span class="secno">3.2.5.2.2</span> Flow content<a href="#flow-content" class="self-link"></a></h6>

  <p>Most elements that are used in the body of documents and applications are categorized as
  <dfn id="flow-content-2" data-export="">flow content</dfn>.</p>

  
  <ul class="brief category-list"><li><code id="flow-content:the-a-element"><a href="#the-a-element">a</a></code></li><li><code id="flow-content:the-abbr-element"><a href="#the-abbr-element">abbr</a></code></li><li><code id="flow-content:the-address-element"><a href="#the-address-element">address</a></code></li><li><code id="flow-content:the-area-element"><a href="#the-area-element">area</a></code> (if it is a descendant of a <code id="flow-content:the-map-element"><a href="#the-map-element">map</a></code> element)</li><li><code id="flow-content:the-article-element"><a href="#the-article-element">article</a></code></li><li><code id="flow-content:the-aside-element"><a href="#the-aside-element">aside</a></code></li><li><code id="flow-content:the-audio-element"><a href="#the-audio-element">audio</a></code></li><li><code id="flow-content:the-b-element"><a href="#the-b-element">b</a></code></li><li><code id="flow-content:the-bdi-element"><a href="#the-bdi-element">bdi</a></code></li><li><code id="flow-content:the-bdo-element"><a href="#the-bdo-element">bdo</a></code></li><li><code id="flow-content:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code></li><li><code id="flow-content:the-br-element"><a href="#the-br-element">br</a></code></li><li><code id="flow-content:the-button-element"><a href="#the-button-element">button</a></code></li><li><code id="flow-content:the-canvas-element"><a href="#the-canvas-element">canvas</a></code></li><li><code id="flow-content:the-cite-element"><a href="#the-cite-element">cite</a></code></li><li><code id="flow-content:the-code-element"><a href="#the-code-element">code</a></code></li><li><code id="flow-content:the-data-element"><a href="#the-data-element">data</a></code></li><li><code id="flow-content:the-datalist-element"><a href="#the-datalist-element">datalist</a></code></li><li><code id="flow-content:the-del-element"><a href="#the-del-element">del</a></code></li><li><code id="flow-content:the-details-element"><a href="#the-details-element">details</a></code></li><li><code id="flow-content:the-dfn-element"><a href="#the-dfn-element">dfn</a></code></li><li><code id="flow-content:the-dialog-element"><a href="#the-dialog-element">dialog</a></code></li><li><code id="flow-content:the-div-element"><a href="#the-div-element">div</a></code></li><li><code id="flow-content:the-dl-element"><a href="#the-dl-element">dl</a></code></li><li><code id="flow-content:the-em-element"><a href="#the-em-element">em</a></code></li><li><code id="flow-content:the-embed-element"><a href="#the-embed-element">embed</a></code></li><li><code id="flow-content:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code></li><li><code id="flow-content:the-figure-element"><a href="#the-figure-element">figure</a></code></li><li><code id="flow-content:the-footer-element"><a href="#the-footer-element">footer</a></code></li><li><code id="flow-content:the-form-element"><a href="#the-form-element">form</a></code></li><li><code id="flow-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code></li><li><code id="flow-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code></li><li><code id="flow-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code></li><li><code id="flow-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code></li><li><code id="flow-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code></li><li><code id="flow-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code></li><li><code id="flow-content:the-header-element"><a href="#the-header-element">header</a></code></li><li><code id="flow-content:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code></li><li><code id="flow-content:the-hr-element"><a href="#the-hr-element">hr</a></code></li><li><code id="flow-content:the-i-element"><a href="#the-i-element">i</a></code></li><li><code id="flow-content:the-iframe-element"><a href="#the-iframe-element">iframe</a></code></li><li><code id="flow-content:the-img-element"><a href="#the-img-element">img</a></code></li><li><code id="flow-content:the-input-element"><a href="#the-input-element">input</a></code></li><li><code id="flow-content:the-ins-element"><a href="#the-ins-element">ins</a></code></li><li><code id="flow-content:the-kbd-element"><a href="#the-kbd-element">kbd</a></code></li><li><code id="flow-content:the-label-element"><a href="#the-label-element">label</a></code></li><li><code id="flow-content:the-link-element"><a href="#the-link-element">link</a></code> (if it is <a href="#allowed-in-the-body" id="flow-content:allowed-in-the-body">allowed in the body</a>)</li><li><code id="flow-content:the-main-element"><a href="#the-main-element">main</a></code> (if it is a <a href="#hierarchically-correct-main-element" id="flow-content:hierarchically-correct-main-element">hierarchically correct <code>main</code> element</a>)</li><li><code id="flow-content:the-map-element-2"><a href="#the-map-element">map</a></code></li><li><code id="flow-content:the-mark-element"><a href="#the-mark-element">mark</a></code></li><li><a id="flow-content:mathml-math" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a></li><li><code id="flow-content:the-menu-element"><a href="#the-menu-element">menu</a></code></li><li><code id="flow-content:the-meta-element"><a href="#the-meta-element">meta</a></code> (if the <code id="flow-content:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is present)</li><li><code id="flow-content:the-meter-element"><a href="#the-meter-element">meter</a></code></li><li><code id="flow-content:the-nav-element"><a href="#the-nav-element">nav</a></code></li><li><code id="flow-content:the-noscript-element"><a href="#the-noscript-element">noscript</a></code></li><li><code id="flow-content:the-object-element"><a href="#the-object-element">object</a></code></li><li><code id="flow-content:the-ol-element"><a href="#the-ol-element">ol</a></code></li><li><code id="flow-content:the-output-element"><a href="#the-output-element">output</a></code></li><li><code id="flow-content:the-p-element"><a href="#the-p-element">p</a></code></li><li><code id="flow-content:the-picture-element"><a href="#the-picture-element">picture</a></code></li><li><code id="flow-content:the-pre-element"><a href="#the-pre-element">pre</a></code></li><li><code id="flow-content:the-progress-element"><a href="#the-progress-element">progress</a></code></li><li><code id="flow-content:the-q-element"><a href="#the-q-element">q</a></code></li><li><code id="flow-content:the-ruby-element"><a href="#the-ruby-element">ruby</a></code></li><li><code id="flow-content:the-s-element"><a href="#the-s-element">s</a></code></li><li><code id="flow-content:the-samp-element"><a href="#the-samp-element">samp</a></code></li><li><code id="flow-content:the-script-element"><a href="#the-script-element">script</a></code></li><li><code id="flow-content:the-search-element"><a href="#the-search-element">search</a></code></li><li><code id="flow-content:the-section-element"><a href="#the-section-element">section</a></code></li><li><code id="flow-content:the-select-element"><a href="#the-select-element">select</a></code></li><li><code id="flow-content:the-slot-element"><a href="#the-slot-element">slot</a></code></li><li><code id="flow-content:the-small-element"><a href="#the-small-element">small</a></code></li><li><code id="flow-content:the-span-element"><a href="#the-span-element">span</a></code></li><li><code id="flow-content:the-strong-element"><a href="#the-strong-element">strong</a></code></li><li><code id="flow-content:the-sub-and-sup-elements"><a href="#the-sub-and-sup-elements">sub</a></code></li><li><code id="flow-content:the-sub-and-sup-elements-2"><a href="#the-sub-and-sup-elements">sup</a></code></li><li><a id="flow-content:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a></li><li><code id="flow-content:the-table-element"><a href="#the-table-element">table</a></code></li><li><code id="flow-content:the-template-element"><a href="#the-template-element">template</a></code></li><li><code id="flow-content:the-textarea-element"><a href="#the-textarea-element">textarea</a></code></li><li><code id="flow-content:the-time-element"><a href="#the-time-element">time</a></code></li><li><code id="flow-content:the-u-element"><a href="#the-u-element">u</a></code></li><li><code id="flow-content:the-ul-element"><a href="#the-ul-element">ul</a></code></li><li><code id="flow-content:the-var-element"><a href="#the-var-element">var</a></code></li><li><code id="flow-content:the-video-element"><a href="#the-video-element">video</a></code></li><li><code id="flow-content:the-wbr-element"><a href="#the-wbr-element">wbr</a></code></li><li><a href="#autonomous-custom-element" id="flow-content:autonomous-custom-element">autonomous custom elements</a></li><li><a href="#text-content" id="flow-content:text-content">text</a></li></ul>


  <h6 id="sectioning-content"><span class="secno">3.2.5.2.3</span> Sectioning content<a href="#sectioning-content" class="self-link"></a></h6>

  <p><dfn id="sectioning-content-2" data-export="">Sectioning content</dfn> is content that defines the scope of <code id="sectioning-content:the-header-element"><a href="#the-header-element">header</a></code>
  and <code id="sectioning-content:the-footer-element"><a href="#the-footer-element">footer</a></code> elements.</p>

  
  <ul class="brief category-list"><li><code id="sectioning-content:the-article-element"><a href="#the-article-element">article</a></code></li><li><code id="sectioning-content:the-aside-element"><a href="#the-aside-element">aside</a></code></li><li><code id="sectioning-content:the-nav-element"><a href="#the-nav-element">nav</a></code></li><li><code id="sectioning-content:the-section-element"><a href="#the-section-element">section</a></code></li></ul>


  <h6 id="heading-content"><span class="secno">3.2.5.2.4</span> Heading content<a href="#heading-content" class="self-link"></a></h6>

  <p><dfn id="heading-content-2" data-export="">Heading content</dfn> defines the heading of a section (whether explicitly marked
  up using <a href="#sectioning-content-2" id="heading-content:sectioning-content-2">sectioning content</a> elements, or implied by the heading content itself).</p>

  
  <ul class="brief category-list"><li><code id="heading-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code></li><li><code id="heading-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code></li><li><code id="heading-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code></li><li><code id="heading-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code></li><li><code id="heading-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code></li><li><code id="heading-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code></li><li><code id="heading-content:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code> (if it has a descendant <code id="heading-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-7"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code> to <code id="heading-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-8"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> element)</li></ul>


  <h6 id="phrasing-content"><span class="secno">3.2.5.2.5</span> Phrasing content<a href="#phrasing-content" class="self-link"></a></h6>

  <p><dfn id="phrasing-content-2" data-export="">Phrasing content</dfn> is the text of the document, as well as elements that mark
  up that text at the intra-paragraph level. Runs of <a href="#phrasing-content-2" id="phrasing-content:phrasing-content-2">phrasing content</a> form <a href="#paragraph" id="phrasing-content:paragraph">paragraphs</a>.</p>

  
  <ul class="brief category-list"><li><code id="phrasing-content:the-a-element"><a href="#the-a-element">a</a></code></li><li><code id="phrasing-content:the-abbr-element"><a href="#the-abbr-element">abbr</a></code></li><li><code id="phrasing-content:the-area-element"><a href="#the-area-element">area</a></code> (if it is a descendant of a <code id="phrasing-content:the-map-element"><a href="#the-map-element">map</a></code> element)</li><li><code id="phrasing-content:the-audio-element"><a href="#the-audio-element">audio</a></code></li><li><code id="phrasing-content:the-b-element"><a href="#the-b-element">b</a></code></li><li><code id="phrasing-content:the-bdi-element"><a href="#the-bdi-element">bdi</a></code></li><li><code id="phrasing-content:the-bdo-element"><a href="#the-bdo-element">bdo</a></code></li><li><code id="phrasing-content:the-br-element"><a href="#the-br-element">br</a></code></li><li><code id="phrasing-content:the-button-element"><a href="#the-button-element">button</a></code></li><li><code id="phrasing-content:the-canvas-element"><a href="#the-canvas-element">canvas</a></code></li><li><code id="phrasing-content:the-cite-element"><a href="#the-cite-element">cite</a></code></li><li><code id="phrasing-content:the-code-element"><a href="#the-code-element">code</a></code></li><li><code id="phrasing-content:the-data-element"><a href="#the-data-element">data</a></code></li><li><code id="phrasing-content:the-datalist-element"><a href="#the-datalist-element">datalist</a></code></li><li><code id="phrasing-content:the-del-element"><a href="#the-del-element">del</a></code></li><li><code id="phrasing-content:the-dfn-element"><a href="#the-dfn-element">dfn</a></code></li><li><code id="phrasing-content:the-em-element"><a href="#the-em-element">em</a></code></li><li><code id="phrasing-content:the-embed-element"><a href="#the-embed-element">embed</a></code></li><li><code id="phrasing-content:the-i-element"><a href="#the-i-element">i</a></code></li><li><code id="phrasing-content:the-iframe-element"><a href="#the-iframe-element">iframe</a></code></li><li><code id="phrasing-content:the-img-element"><a href="#the-img-element">img</a></code></li><li><code id="phrasing-content:the-input-element"><a href="#the-input-element">input</a></code></li><li><code id="phrasing-content:the-ins-element"><a href="#the-ins-element">ins</a></code></li><li><code id="phrasing-content:the-kbd-element"><a href="#the-kbd-element">kbd</a></code></li><li><code id="phrasing-content:the-label-element"><a href="#the-label-element">label</a></code></li><li><code id="phrasing-content:the-link-element"><a href="#the-link-element">link</a></code> (if it is <a href="#allowed-in-the-body" id="phrasing-content:allowed-in-the-body">allowed in the body</a>)</li><li><code id="phrasing-content:the-map-element-2"><a href="#the-map-element">map</a></code></li><li><code id="phrasing-content:the-mark-element"><a href="#the-mark-element">mark</a></code></li><li><a id="phrasing-content:mathml-math" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a></li><li><code id="phrasing-content:the-meta-element"><a href="#the-meta-element">meta</a></code> (if the <code id="phrasing-content:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is present)</li><li><code id="phrasing-content:the-meter-element"><a href="#the-meter-element">meter</a></code></li><li><code id="phrasing-content:the-noscript-element"><a href="#the-noscript-element">noscript</a></code></li><li><code id="phrasing-content:the-object-element"><a href="#the-object-element">object</a></code></li><li><code id="phrasing-content:the-output-element"><a href="#the-output-element">output</a></code></li><li><code id="phrasing-content:the-picture-element"><a href="#the-picture-element">picture</a></code></li><li><code id="phrasing-content:the-progress-element"><a href="#the-progress-element">progress</a></code></li><li><code id="phrasing-content:the-q-element"><a href="#the-q-element">q</a></code></li><li><code id="phrasing-content:the-ruby-element"><a href="#the-ruby-element">ruby</a></code></li><li><code id="phrasing-content:the-s-element"><a href="#the-s-element">s</a></code></li><li><code id="phrasing-content:the-samp-element"><a href="#the-samp-element">samp</a></code></li><li><code id="phrasing-content:the-script-element"><a href="#the-script-element">script</a></code></li><li><code id="phrasing-content:the-select-element"><a href="#the-select-element">select</a></code></li><li><code id="phrasing-content:the-selectedcontent-element"><a href="#the-selectedcontent-element">selectedcontent</a></code> (if it is a descendant of a <code id="phrasing-content:the-button-element-2"><a href="#the-button-element">button</a></code> in a
   <code id="phrasing-content:the-select-element-2"><a href="#the-select-element">select</a></code>)</li><li><code id="phrasing-content:the-slot-element"><a href="#the-slot-element">slot</a></code></li><li><code id="phrasing-content:the-small-element"><a href="#the-small-element">small</a></code></li><li><code id="phrasing-content:the-span-element"><a href="#the-span-element">span</a></code></li><li><code id="phrasing-content:the-strong-element"><a href="#the-strong-element">strong</a></code></li><li><code id="phrasing-content:the-sub-and-sup-elements"><a href="#the-sub-and-sup-elements">sub</a></code></li><li><code id="phrasing-content:the-sub-and-sup-elements-2"><a href="#the-sub-and-sup-elements">sup</a></code></li><li><a id="phrasing-content:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a></li><li><code id="phrasing-content:the-template-element"><a href="#the-template-element">template</a></code></li><li><code id="phrasing-content:the-textarea-element"><a href="#the-textarea-element">textarea</a></code></li><li><code id="phrasing-content:the-time-element"><a href="#the-time-element">time</a></code></li><li><code id="phrasing-content:the-u-element"><a href="#the-u-element">u</a></code></li><li><code id="phrasing-content:the-var-element"><a href="#the-var-element">var</a></code></li><li><code id="phrasing-content:the-video-element"><a href="#the-video-element">video</a></code></li><li><code id="phrasing-content:the-wbr-element"><a href="#the-wbr-element">wbr</a></code></li><li><a href="#autonomous-custom-element" id="phrasing-content:autonomous-custom-element">autonomous custom elements</a></li><li><a href="#text-content" id="phrasing-content:text-content">text</a></li></ul>

  <p class="note">Most elements that are categorized as phrasing content can only contain elements
  that are themselves categorized as phrasing content, not any flow content.</p>

  <p><dfn id="text-content">Text</dfn>, in the context of content models, means either nothing,
  or <code id="phrasing-content:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes. <a href="#text-content" id="phrasing-content:text-content-2">Text</a> is sometimes used as a content
  model on its own, but is also <a href="#phrasing-content-2" id="phrasing-content:phrasing-content-2-2">phrasing content</a>, and can be <a href="#inter-element-whitespace" id="phrasing-content:inter-element-whitespace">inter-element
  whitespace</a> (if the <code id="phrasing-content:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes are empty or contain just <a id="phrasing-content:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
  whitespace</a>).</p>

  <p><code id="phrasing-content:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes and attribute values must consist of <a href="https://infra.spec.whatwg.org/#scalar-value" id="phrasing-content:scalar-value" data-x-internal="scalar-value">scalar
  values</a>, excluding <a href="https://infra.spec.whatwg.org/#noncharacter" id="phrasing-content:noncharacter" data-x-internal="noncharacter">noncharacters</a>, and <a href="https://infra.spec.whatwg.org/#control" id="phrasing-content:control" data-x-internal="control">controls</a> other than <a id="phrasing-content:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.

   
  

  This specification includes extra constraints on the exact value of <code id="phrasing-content:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes and
  attribute values depending on their precise context.

  

  </p>



  <h6 id="embedded-content-2"><span class="secno">3.2.5.2.6</span> Embedded content<a href="#embedded-content-2" class="self-link"></a></h6>

  <p><dfn id="embedded-content-category" data-export="">Embedded content</dfn> is content that imports
  another resource into the document, or content from another vocabulary that
  is inserted into the document.</p>

  
  <ul class="brief category-list"><li><code id="embedded-content-2:the-audio-element"><a href="#the-audio-element">audio</a></code></li><li><code id="embedded-content-2:the-canvas-element"><a href="#the-canvas-element">canvas</a></code></li><li><code id="embedded-content-2:the-embed-element"><a href="#the-embed-element">embed</a></code></li><li><code id="embedded-content-2:the-iframe-element"><a href="#the-iframe-element">iframe</a></code></li><li><code id="embedded-content-2:the-img-element"><a href="#the-img-element">img</a></code></li><li><a id="embedded-content-2:mathml-math" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a></li><li><code id="embedded-content-2:the-object-element"><a href="#the-object-element">object</a></code></li><li><code id="embedded-content-2:the-picture-element"><a href="#the-picture-element">picture</a></code></li><li><a id="embedded-content-2:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a></li><li><code id="embedded-content-2:the-video-element"><a href="#the-video-element">video</a></code></li></ul>

  <p>Elements that are from namespaces other than the <a id="embedded-content-2:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a> and that convey
  content but not metadata, are <a href="#embedded-content-category" id="embedded-content-2:embedded-content-category">embedded content</a> for the purposes of the content models
  defined in this specification. (For example, MathML or SVG.)</p>

  <p>Some embedded content elements can have <dfn id="fallback-content">fallback content</dfn>: content that is to be used
  when the external resource cannot be used (e.g. because it is of an unsupported format). The
  element definitions state what the fallback is, if any.</p>
  


  <h6 id="interactive-content"><span class="secno">3.2.5.2.7</span> Interactive content<a href="#interactive-content" class="self-link"></a></h6>



  <p><dfn id="interactive-content-2" data-export="">Interactive content</dfn> is content that is specifically intended for user
  interaction.</p>

  
  <ul class="brief category-list"><li><code id="interactive-content:the-a-element"><a href="#the-a-element">a</a></code> (if the <code id="interactive-content:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute is present)</li><li><code id="interactive-content:the-audio-element"><a href="#the-audio-element">audio</a></code> (if the <code id="interactive-content:attr-media-controls"><a href="#attr-media-controls">controls</a></code> attribute is present)</li><li><code id="interactive-content:the-button-element"><a href="#the-button-element">button</a></code></li><li><code id="interactive-content:the-details-element"><a href="#the-details-element">details</a></code></li><li><code id="interactive-content:the-embed-element"><a href="#the-embed-element">embed</a></code></li><li><code id="interactive-content:the-iframe-element"><a href="#the-iframe-element">iframe</a></code></li><li><code id="interactive-content:the-img-element"><a href="#the-img-element">img</a></code> (if the <code id="interactive-content:attr-hyperlink-usemap"><a href="#attr-hyperlink-usemap">usemap</a></code> attribute is present)</li><li><code id="interactive-content:the-input-element"><a href="#the-input-element">input</a></code> (if the <code id="interactive-content:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is <em>not</em> in the <a href="#hidden-state-(type=hidden)" id="interactive-content:hidden-state-(type=hidden)">Hidden</a> state)</li><li><code id="interactive-content:the-label-element"><a href="#the-label-element">label</a></code></li><li><code id="interactive-content:the-select-element"><a href="#the-select-element">select</a></code></li><li><code id="interactive-content:the-textarea-element"><a href="#the-textarea-element">textarea</a></code></li><li><code id="interactive-content:the-video-element"><a href="#the-video-element">video</a></code> (if the <code id="interactive-content:attr-media-controls-2"><a href="#attr-media-controls">controls</a></code> attribute is present)</li></ul>



  <h6 id="palpable-content"><span class="secno">3.2.5.2.8</span> Palpable content<a href="#palpable-content" class="self-link"></a></h6>

  <p>As a general rule, elements whose content model allows any <a href="#flow-content-2" id="palpable-content:flow-content-2">flow content</a> or
  <a href="#phrasing-content-2" id="palpable-content:phrasing-content-2">phrasing content</a> should have at least one node in its <a href="#concept-html-contents" id="palpable-content:concept-html-contents">contents</a> that is <dfn id="palpable-content-2" data-export="">palpable content</dfn> and
  that does not have the <code id="palpable-content:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute specified.</p>

  <p class="note"><a href="#palpable-content-2" id="palpable-content:palpable-content-2">Palpable content</a> makes an element non-empty by providing either
  some descendant non-empty <a href="#text-content" id="palpable-content:text-content">text</a>, or else something users can
  hear (<code id="palpable-content:the-audio-element"><a href="#the-audio-element">audio</a></code> elements) or view (<code id="palpable-content:the-video-element"><a href="#the-video-element">video</a></code>, <code id="palpable-content:the-img-element"><a href="#the-img-element">img</a></code>, or
  <code id="palpable-content:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> elements) or otherwise interact with (for example, interactive form
  controls).</p>

  <p>This requirement is not a hard requirement, however, as there are many cases where an element
  can be empty legitimately, for example when it is used as a placeholder which will later be filled
  in by a script, or when the element is part of a template and would on most pages be filled in but
  on some pages is not relevant.</p>

  <p>Conformance checkers are encouraged to provide a mechanism for authors to find elements that
  fail to fulfill this requirement, as an authoring aid.</p>

  <p>The following elements are palpable content:</p>

  
  <ul class="brief category-list"><li><code id="palpable-content:the-a-element"><a href="#the-a-element">a</a></code></li><li><code id="palpable-content:the-abbr-element"><a href="#the-abbr-element">abbr</a></code></li><li><code id="palpable-content:the-address-element"><a href="#the-address-element">address</a></code></li><li><code id="palpable-content:the-article-element"><a href="#the-article-element">article</a></code></li><li><code id="palpable-content:the-aside-element"><a href="#the-aside-element">aside</a></code></li><li><code id="palpable-content:the-audio-element-2"><a href="#the-audio-element">audio</a></code> (if the <code id="palpable-content:attr-media-controls"><a href="#attr-media-controls">controls</a></code> attribute is present)</li><li><code id="palpable-content:the-b-element"><a href="#the-b-element">b</a></code></li><li><code id="palpable-content:the-bdi-element"><a href="#the-bdi-element">bdi</a></code></li><li><code id="palpable-content:the-bdo-element"><a href="#the-bdo-element">bdo</a></code></li><li><code id="palpable-content:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code></li><li><code id="palpable-content:the-button-element"><a href="#the-button-element">button</a></code></li><li><code id="palpable-content:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code></li><li><code id="palpable-content:the-cite-element"><a href="#the-cite-element">cite</a></code></li><li><code id="palpable-content:the-code-element"><a href="#the-code-element">code</a></code></li><li><code id="palpable-content:the-data-element"><a href="#the-data-element">data</a></code></li><li><code id="palpable-content:the-del-element"><a href="#the-del-element">del</a></code></li><li><code id="palpable-content:the-details-element"><a href="#the-details-element">details</a></code></li><li><code id="palpable-content:the-dfn-element"><a href="#the-dfn-element">dfn</a></code></li><li><code id="palpable-content:the-div-element"><a href="#the-div-element">div</a></code></li><li><code id="palpable-content:the-dl-element"><a href="#the-dl-element">dl</a></code> (if the element's children include at least one name-value group)</li><li><code id="palpable-content:the-em-element"><a href="#the-em-element">em</a></code></li><li><code id="palpable-content:the-embed-element"><a href="#the-embed-element">embed</a></code></li><li><code id="palpable-content:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code></li><li><code id="palpable-content:the-figure-element"><a href="#the-figure-element">figure</a></code></li><li><code id="palpable-content:the-footer-element"><a href="#the-footer-element">footer</a></code></li><li><code id="palpable-content:the-form-element"><a href="#the-form-element">form</a></code></li><li><code id="palpable-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code></li><li><code id="palpable-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code></li><li><code id="palpable-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code></li><li><code id="palpable-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code></li><li><code id="palpable-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code></li><li><code id="palpable-content:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code></li><li><code id="palpable-content:the-header-element"><a href="#the-header-element">header</a></code></li><li><code id="palpable-content:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code></li><li><code id="palpable-content:the-i-element"><a href="#the-i-element">i</a></code></li><li><code id="palpable-content:the-iframe-element"><a href="#the-iframe-element">iframe</a></code></li><li><code id="palpable-content:the-img-element-2"><a href="#the-img-element">img</a></code></li><li><code id="palpable-content:the-input-element"><a href="#the-input-element">input</a></code> (if the <code id="palpable-content:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is <em>not</em> in the <a href="#hidden-state-(type=hidden)" id="palpable-content:hidden-state-(type=hidden)">Hidden</a> state)</li><li><code id="palpable-content:the-ins-element"><a href="#the-ins-element">ins</a></code></li><li><code id="palpable-content:the-kbd-element"><a href="#the-kbd-element">kbd</a></code></li><li><code id="palpable-content:the-label-element"><a href="#the-label-element">label</a></code></li><li><code id="palpable-content:the-main-element"><a href="#the-main-element">main</a></code></li><li><code id="palpable-content:the-map-element"><a href="#the-map-element">map</a></code></li><li><code id="palpable-content:the-mark-element"><a href="#the-mark-element">mark</a></code></li><li><a id="palpable-content:mathml-math" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a></li><li><code id="palpable-content:the-menu-element"><a href="#the-menu-element">menu</a></code> (if the element's children include at least one <code id="palpable-content:the-li-element"><a href="#the-li-element">li</a></code> element)</li><li><code id="palpable-content:the-meter-element"><a href="#the-meter-element">meter</a></code></li><li><code id="palpable-content:the-nav-element"><a href="#the-nav-element">nav</a></code></li><li><code id="palpable-content:the-object-element"><a href="#the-object-element">object</a></code></li><li><code id="palpable-content:the-ol-element"><a href="#the-ol-element">ol</a></code> (if the element's children include at least one <code id="palpable-content:the-li-element-2"><a href="#the-li-element">li</a></code> element)</li><li><code id="palpable-content:the-output-element"><a href="#the-output-element">output</a></code></li><li><code id="palpable-content:the-p-element"><a href="#the-p-element">p</a></code></li><li><code id="palpable-content:the-picture-element"><a href="#the-picture-element">picture</a></code></li><li><code id="palpable-content:the-pre-element"><a href="#the-pre-element">pre</a></code></li><li><code id="palpable-content:the-progress-element"><a href="#the-progress-element">progress</a></code></li><li><code id="palpable-content:the-q-element"><a href="#the-q-element">q</a></code></li><li><code id="palpable-content:the-ruby-element"><a href="#the-ruby-element">ruby</a></code></li><li><code id="palpable-content:the-s-element"><a href="#the-s-element">s</a></code></li><li><code id="palpable-content:the-samp-element"><a href="#the-samp-element">samp</a></code></li><li><code id="palpable-content:the-search-element"><a href="#the-search-element">search</a></code></li><li><code id="palpable-content:the-section-element"><a href="#the-section-element">section</a></code></li><li><code id="palpable-content:the-select-element"><a href="#the-select-element">select</a></code></li><li><code id="palpable-content:the-small-element"><a href="#the-small-element">small</a></code></li><li><code id="palpable-content:the-span-element"><a href="#the-span-element">span</a></code></li><li><code id="palpable-content:the-strong-element"><a href="#the-strong-element">strong</a></code></li><li><code id="palpable-content:the-sub-and-sup-elements"><a href="#the-sub-and-sup-elements">sub</a></code></li><li><code id="palpable-content:the-sub-and-sup-elements-2"><a href="#the-sub-and-sup-elements">sup</a></code></li><li><a id="palpable-content:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a></li><li><code id="palpable-content:the-table-element"><a href="#the-table-element">table</a></code></li><li><code id="palpable-content:the-textarea-element"><a href="#the-textarea-element">textarea</a></code></li><li><code id="palpable-content:the-time-element"><a href="#the-time-element">time</a></code></li><li><code id="palpable-content:the-u-element"><a href="#the-u-element">u</a></code></li><li><code id="palpable-content:the-ul-element"><a href="#the-ul-element">ul</a></code> (if the element's children include at least one <code id="palpable-content:the-li-element-3"><a href="#the-li-element">li</a></code> element)</li><li><code id="palpable-content:the-var-element"><a href="#the-var-element">var</a></code></li><li><code id="palpable-content:the-video-element-2"><a href="#the-video-element">video</a></code></li><li><a href="#autonomous-custom-element" id="palpable-content:autonomous-custom-element">autonomous custom elements</a></li><li><a href="#text-content" id="palpable-content:text-content-2">text</a> that is not <a href="#inter-element-whitespace" id="palpable-content:inter-element-whitespace">inter-element whitespace</a></li></ul>


  <h6 id="script-supporting-elements"><span class="secno">3.2.5.2.9</span> Script-supporting elements<a href="#script-supporting-elements" class="self-link"></a></h6>

  <p><dfn id="script-supporting-elements-2">Script-supporting elements</dfn> are those that do not <a href="#represents" id="script-supporting-elements:represents">represent</a> anything themselves (i.e. they are not rendered), but are
  used to support scripts, e.g. to provide functionality for the user.</p>

  <p>The following elements are script-supporting elements:</p>

  
  <ul class="brief category-list"><li><code id="script-supporting-elements:the-script-element"><a href="#the-script-element">script</a></code></li><li><code id="script-supporting-elements:the-template-element"><a href="#the-template-element">template</a></code></li></ul>


  <h6 id="select-element-inner-content-elements"><span class="secno">3.2.5.2.10</span> <code id="select-element-inner-content-elements:the-select-element"><a href="#the-select-element">select</a></code> element inner content elements<a href="#select-element-inner-content-elements" class="self-link"></a></h6>

  <p><dfn id="select-element-inner-content-elements-2"><code>select</code> element inner content elements</dfn> are the elements which are
  allowed as descendants of <code id="select-element-inner-content-elements:the-select-element-2"><a href="#the-select-element">select</a></code> elements.</p>

  <p>The following are <a href="#select-element-inner-content-elements-2" id="select-element-inner-content-elements:select-element-inner-content-elements-2"><code>select</code> element inner content elements</a>:</p>

  <ul class="brief category-list"><li><code id="select-element-inner-content-elements:the-option-element"><a href="#the-option-element">option</a></code></li><li><code id="select-element-inner-content-elements:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code></li><li><code id="select-element-inner-content-elements:the-hr-element"><a href="#the-hr-element">hr</a></code></li><li><a href="#script-supporting-elements-2" id="select-element-inner-content-elements:script-supporting-elements-2">script-supporting elements</a></li><li><code id="select-element-inner-content-elements:the-noscript-element"><a href="#the-noscript-element">noscript</a></code></li><li><code id="select-element-inner-content-elements:the-div-element"><a href="#the-div-element">div</a></code></li></ul>

  <h6 id="optgroup-element-inner-content-elements"><span class="secno">3.2.5.2.11</span> <code id="optgroup-element-inner-content-elements:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element inner content elements<a href="#optgroup-element-inner-content-elements" class="self-link"></a></h6>

  <p><dfn id="optgroup-element-inner-content-elements-2"><code>optgroup</code> element inner content elements</dfn> are the elements which are
  allowed as descendants of <code id="optgroup-element-inner-content-elements:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> elements.</p>

  <p>The following are <a href="#optgroup-element-inner-content-elements-2" id="optgroup-element-inner-content-elements:optgroup-element-inner-content-elements-2"><code>optgroup</code> element inner content elements</a>:</p>

  <ul class="brief category-list"><li><code id="optgroup-element-inner-content-elements:the-option-element"><a href="#the-option-element">option</a></code></li><li><a href="#script-supporting-elements-2" id="optgroup-element-inner-content-elements:script-supporting-elements-2">script-supporting elements</a></li><li><code id="optgroup-element-inner-content-elements:the-noscript-element"><a href="#the-noscript-element">noscript</a></code></li><li><code id="optgroup-element-inner-content-elements:the-div-element"><a href="#the-div-element">div</a></code></li></ul>

  <h6 id="option-element-inner-content-elements"><span class="secno">3.2.5.2.12</span> <code id="option-element-inner-content-elements:the-option-element"><a href="#the-option-element">option</a></code> element inner content elements<a href="#option-element-inner-content-elements" class="self-link"></a></h6>

  <p><dfn id="option-element-inner-content-elements-2"><code>option</code> element inner content elements</dfn> are the elements which are
  allowed as descendants of <code id="option-element-inner-content-elements:the-option-element-2"><a href="#the-option-element">option</a></code> elements.</p>

  <p>The following are <a href="#option-element-inner-content-elements-2" id="option-element-inner-content-elements:option-element-inner-content-elements-2"><code>option</code> element inner content elements</a>:</p>

  <ul class="brief category-list"><li><code id="option-element-inner-content-elements:the-div-element"><a href="#the-div-element">div</a></code></li><li><a href="#phrasing-content-2" id="option-element-inner-content-elements:phrasing-content-2">phrasing content</a> that is not in the following exclusion list</li></ul>

  <p>The following are excluded from <a href="#option-element-inner-content-elements-2" id="option-element-inner-content-elements:option-element-inner-content-elements-2-2"><code>option</code> element inner content
  elements</a>:</p>

  

  <ul class="brief category-list"><li><code id="option-element-inner-content-elements:the-datalist-element"><a href="#the-datalist-element">datalist</a></code></li><li><code id="option-element-inner-content-elements:the-object-element"><a href="#the-object-element">object</a></code></li><li><a href="#interactive-content-2" id="option-element-inner-content-elements:interactive-content-2">interactive content</a></li><li>elements with the <code id="option-element-inner-content-elements:attr-tabindex"><a href="#attr-tabindex">tabindex</a></code> attribute specified</li></ul>



  <h5 id="transparent-content-models"><span class="secno">3.2.5.3</span> Transparent content models<a href="#transparent-content-models" class="self-link"></a></h5>

  <p>Some elements are described as <dfn id="transparent">transparent</dfn>; they have "transparent" in the
  description of their content model. The content model of a <a href="#transparent" id="transparent-content-models:transparent">transparent</a> element is
  derived from the content model of its parent element: the elements required in the part of the
  content model that is "transparent" are the same elements as required in the part of the content
  model of the parent of the transparent element in which the transparent element finds itself.</p>

  <div class="example">

   <p>For instance, an <code id="transparent-content-models:the-ins-element"><a href="#the-ins-element">ins</a></code> element inside a <code id="transparent-content-models:the-ruby-element"><a href="#the-ruby-element">ruby</a></code> element cannot contain an
   <code id="transparent-content-models:the-rt-element"><a href="#the-rt-element">rt</a></code> element, because the part of the <code id="transparent-content-models:the-ruby-element-2"><a href="#the-ruby-element">ruby</a></code> element's content model that
   allows <code id="transparent-content-models:the-ins-element-2"><a href="#the-ins-element">ins</a></code> elements is the part that allows <a href="#phrasing-content-2" id="transparent-content-models:phrasing-content-2">phrasing content</a>, and the
   <code id="transparent-content-models:the-rt-element-2"><a href="#the-rt-element">rt</a></code> element is not <a href="#phrasing-content-2" id="transparent-content-models:phrasing-content-2-2">phrasing content</a>.</p>

  </div>



  <p class="note">In some cases, where transparent elements are nested in each other, the process
  has to be applied iteratively.</p>

  <div class="example">
   <p>Consider the following markup fragment:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">object</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-><c- p="">&gt;&lt;</c-><c- f="">map</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/"</c-><c- p="">&gt;</c->Apples<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">map</c-><c- p="">&gt;&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">object</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>To check whether "Apples" is allowed inside the <code id="transparent-content-models:the-a-element"><a href="#the-a-element">a</a></code> element, the content models are
   examined. The <code id="transparent-content-models:the-a-element-2"><a href="#the-a-element">a</a></code> element's content model is transparent, as is the <code id="transparent-content-models:the-map-element"><a href="#the-map-element">map</a></code>
   element's, as is the <code id="transparent-content-models:the-ins-element-3"><a href="#the-ins-element">ins</a></code> element's, as is the <code id="transparent-content-models:the-object-element"><a href="#the-object-element">object</a></code> element's. The
   <code id="transparent-content-models:the-object-element-2"><a href="#the-object-element">object</a></code> element is found in the <code id="transparent-content-models:the-p-element"><a href="#the-p-element">p</a></code> element, whose content model is
   <a href="#phrasing-content-2" id="transparent-content-models:phrasing-content-2-3">phrasing content</a>. Thus, "Apples" is allowed, as text is phrasing content.</p>
  </div>

  <p>When a transparent element has no parent, then the part of its content model that is
  "transparent" must instead be treated as accepting any <a href="#flow-content-2" id="transparent-content-models:flow-content-2">flow content</a>.</p>


  <h5 id="paragraphs"><span class="secno">3.2.5.4</span> Paragraphs<a href="#paragraphs" class="self-link"></a></h5>

  <p class="note">The term <a href="#paragraph" id="paragraphs:paragraph">paragraph</a> as defined in this section is used for more than
  just the definition of the <code id="paragraphs:the-p-element"><a href="#the-p-element">p</a></code> element. The <a href="#paragraph" id="paragraphs:paragraph-2">paragraph</a> concept defined here
  is used to describe how to interpret documents. The <code id="paragraphs:the-p-element-2"><a href="#the-p-element">p</a></code> element is merely one of
  several ways of marking up a <a href="#paragraph" id="paragraphs:paragraph-3">paragraph</a>.</p>

  
  <p>A <dfn id="paragraph">paragraph</dfn> is typically a run of <a href="#phrasing-content-2" id="paragraphs:phrasing-content-2">phrasing content</a> that forms a block
  of text with one or more sentences that discuss a particular topic, as in typography, but can also
  be used for more general thematic grouping. For instance, an address is also a paragraph, as is a
  part of a form, a byline, or a stanza in a poem.</p>

  <div class="example">

   <p>In the following example, there are two paragraphs in a section. There is also a heading,
   which contains phrasing content that is not a paragraph. Note how the comments and
   <a href="#inter-element-whitespace" id="paragraphs:inter-element-whitespace">inter-element whitespace</a> do not form paragraphs.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Example of paragraphs<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  This is the <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->first<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> paragraph in this example.
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This is the second.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- c="">&lt;!-- This is not a paragraph. --&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Paragraphs in <a href="#flow-content-2" id="paragraphs:flow-content-2">flow content</a> are defined relative to what the document looks like
  without the <code id="paragraphs:the-a-element"><a href="#the-a-element">a</a></code>, <code id="paragraphs:the-ins-element"><a href="#the-ins-element">ins</a></code>, <code id="paragraphs:the-del-element"><a href="#the-del-element">del</a></code>, and <code id="paragraphs:the-map-element"><a href="#the-map-element">map</a></code> elements
  complicating matters, since those elements, with their hybrid content models, can straddle
  paragraph boundaries, as shown in the first two examples below.</p>

  <p class="note">Generally, having elements straddle paragraph boundaries is best avoided.
  Maintaining such markup can be difficult.</p>

  <div class="example">

   <p>The following example takes the markup from the earlier example and puts <code id="paragraphs:the-ins-element-2"><a href="#the-ins-element">ins</a></code> and
   <code id="paragraphs:the-del-element-2"><a href="#the-del-element">del</a></code> elements around some of the markup to show that the text was changed (though in
   this case, the changes admittedly don't make much sense). Notice how this example has exactly the
   same paragraphs as the previous one, despite the <code id="paragraphs:the-ins-element-3"><a href="#the-ins-element">ins</a></code> and <code id="paragraphs:the-del-element-3"><a href="#the-del-element">del</a></code> elements
   — the <code id="paragraphs:the-ins-element-4"><a href="#the-ins-element">ins</a></code> element straddles the heading and the first paragraph, and the
   <code id="paragraphs:the-del-element-4"><a href="#the-del-element">del</a></code> element straddles the boundary between the two paragraphs.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">ins</c-><c- p="">&gt;&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Example of paragraphs<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  This is the <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->first<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> paragraph in<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c-> this example<c- p="">&lt;</c-><c- f="">del</c-><c- p="">&gt;</c->.
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This is the second.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">del</c-><c- p="">&gt;</c->
  <c- c="">&lt;!-- This is not a paragraph. --&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <div data-algorithm="">
  <p>Let <var>view</var> be a view of the DOM that replaces all <code id="paragraphs:the-a-element-2"><a href="#the-a-element">a</a></code>,
  <code id="paragraphs:the-ins-element-5"><a href="#the-ins-element">ins</a></code>, <code id="paragraphs:the-del-element-5"><a href="#the-del-element">del</a></code>, and <code id="paragraphs:the-map-element-2"><a href="#the-map-element">map</a></code> elements in the document with their <a href="#concept-html-contents" id="paragraphs:concept-html-contents">contents</a>. Then, in <var>view</var>, for each run
  of sibling <a href="#phrasing-content-2" id="paragraphs:phrasing-content-2-2">phrasing content</a> nodes uninterrupted by other types of content, in an
  element that accepts content other than <a href="#phrasing-content-2" id="paragraphs:phrasing-content-2-3">phrasing content</a> as well as <a href="#phrasing-content-2" id="paragraphs:phrasing-content-2-4">phrasing
  content</a>, let <var>first</var> be the first node of the run, and let <var>last</var> be the last node of the run. For each such run that consists of at least one
  node that is neither <a href="#embedded-content-category" id="paragraphs:embedded-content-category">embedded content</a> nor <a href="#inter-element-whitespace" id="paragraphs:inter-element-whitespace-2">inter-element whitespace</a>, a
  paragraph exists in the original DOM from immediately before <var>first</var> to
  immediately after <var>last</var>. (Paragraphs can thus span across <code id="paragraphs:the-a-element-3"><a href="#the-a-element">a</a></code>,
  <code id="paragraphs:the-ins-element-6"><a href="#the-ins-element">ins</a></code>, <code id="paragraphs:the-del-element-6"><a href="#the-del-element">del</a></code>, and <code id="paragraphs:the-map-element-3"><a href="#the-map-element">map</a></code> elements.)</p>
  </div>

  <p>Conformance checkers may warn authors of cases where they have paragraphs that overlap each
  other (this can happen with <code id="paragraphs:the-object-element"><a href="#the-object-element">object</a></code>, <code id="paragraphs:the-video-element"><a href="#the-video-element">video</a></code>, <code id="paragraphs:the-audio-element"><a href="#the-audio-element">audio</a></code>, and
  <code id="paragraphs:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> elements, and indirectly through elements in other namespaces that allow HTML
  to be further embedded therein, like <a id="paragraphs:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a> or <a id="paragraphs:mathml-math" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML
  <code>math</code></a>).</p>
  

  

  <p>A <a href="#paragraph" id="paragraphs:paragraph-4">paragraph</a> is also formed explicitly by <code id="paragraphs:the-p-element-3"><a href="#the-p-element">p</a></code> elements.</p>

  <p class="note">The <code id="paragraphs:the-p-element-4"><a href="#the-p-element">p</a></code> element can be used to wrap individual paragraphs when there
  would otherwise not be any content other than phrasing content to separate the paragraphs from
  each other.</p>

  <div class="example">

   <p>In the following example, the link spans half of the first paragraph, all of the heading
   separating the two paragraphs, and half of the second paragraph. It straddles the paragraphs and
   the heading.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
 Welcome!
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"about.html"</c-><c- p="">&gt;</c->
  This is home of...
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The Falcons!<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  The Lockheed Martin multirole jet fighter aircraft!
 <c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 This page discusses the F-16 Fighting Falcon's innermost secrets.
<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c-></code></pre>

   <p>Here is another way of marking this up, this time showing the paragraphs explicitly, and
   splitting the one link element into three:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome! <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"about.html"</c-><c- p="">&gt;</c->This is home of...<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"about.html"</c-><c- p="">&gt;</c->The Falcons!<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"about.html"</c-><c- p="">&gt;</c->The Lockheed Martin multirole jet
 fighter aircraft!<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> This page discusses the F-16 Fighting
 Falcon's innermost secrets.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   

   <p>It is possible for paragraphs to overlap when using certain elements that define fallback
   content. For example, in the following section:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->My Cats<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 You can play with my cat simulator.
 <c- p="">&lt;</c-><c- f="">object</c-> <c- e="">data</c-><c- o="">=</c-><c- s="">"cats.sim"</c-><c- p="">&gt;</c->
  To see the cat simulator, use one of the following links:
  <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"cats.sim"</c-><c- p="">&gt;</c->Download simulator file<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://sims.example.com/watch?v=LYds5xY4INU"</c-><c- p="">&gt;</c->Use online simulator<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
  Alternatively, upgrade to the Mellblom Browser.
 <c- p="">&lt;/</c-><c- f="">object</c-><c- p="">&gt;</c->
 I'm quite proud of it.
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>There are five paragraphs:</p>

   <ol class="brief"><li>The paragraph that says "You can play with my cat simulator. <i>object</i> I'm
    quite proud of it.", where <i>object</i> is the <code id="paragraphs:the-object-element-2"><a href="#the-object-element">object</a></code> element.</li><li>The paragraph that says "To see the cat simulator, use one of the following links:".</li><li>The paragraph that says "Download simulator file".</li><li>The paragraph that says "Use online simulator".</li><li>The paragraph that says "Alternatively, upgrade to the Mellblom Browser.".</li></ol>

   <p>The first paragraph is overlapped by the other four. A user agent that supports the "cats.sim"
   resource will only show the first one, but a user agent that shows the fallback will confusingly
   show the first sentence of the first paragraph as if it was in the same paragraph as the second
   one, and will show the last paragraph as if it was at the start of the second sentence of the
   first paragraph.</p>

   <p>To avoid this confusion, explicit <code id="paragraphs:the-p-element-5"><a href="#the-p-element">p</a></code> elements can be used. For example:</p>

   
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->My Cats<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You can play with my cat simulator.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">object</c-> <c- e="">data</c-><c- o="">=</c-><c- s="">"cats.sim"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->To see the cat simulator, use one of the following links:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"cats.sim"</c-><c- p="">&gt;</c->Download simulator file<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://sims.example.com/watch?v=LYds5xY4INU"</c-><c- p="">&gt;</c->Use online simulator<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Alternatively, upgrade to the Mellblom Browser.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">object</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I'm quite proud of it.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="global-attributes"><span class="secno">3.2.6</span> <dfn>Global attributes</dfn><a href="#global-attributes" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes" title="Global attributes are attributes common to all HTML elements; they can be used on all elements, though they may have no effect on some elements.">Global_attributes</a></p></div></div>

  <p>The following attributes are common to and may be specified on all <a href="#html-elements" id="global-attributes:html-elements">HTML
  elements</a> (even those not defined in this specification):</p>

  <ul class="brief"><li><code id="global-attributes:the-accesskey-attribute"><a href="#the-accesskey-attribute">accesskey</a></code></li><li><code id="global-attributes:attr-autocapitalize"><a href="#attr-autocapitalize">autocapitalize</a></code></li><li><code id="global-attributes:attr-autocorrect"><a href="#attr-autocorrect">autocorrect</a></code></li><li><code id="global-attributes:attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code></li><li><code id="global-attributes:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code></li><li><code id="global-attributes:attr-dir"><a href="#attr-dir">dir</a></code></li><li><code id="global-attributes:attr-draggable"><a href="#attr-draggable">draggable</a></code></li><li><code id="global-attributes:attr-enterkeyhint"><a href="#attr-enterkeyhint">enterkeyhint</a></code></li><li><code id="global-attributes:attr-headingoffset"><a href="#attr-headingoffset">headingoffset</a></code></li><li><code id="global-attributes:attr-headingreset"><a href="#attr-headingreset">headingreset</a></code></li><li><code id="global-attributes:attr-hidden"><a href="#attr-hidden">hidden</a></code></li><li><code id="global-attributes:the-inert-attribute"><a href="#the-inert-attribute">inert</a></code></li><li><code id="global-attributes:attr-inputmode"><a href="#attr-inputmode">inputmode</a></code></li><li><code id="global-attributes:attr-is"><a href="#attr-is">is</a></code></li><li><code id="global-attributes:attr-itemid"><a href="#attr-itemid">itemid</a></code></li><li><code id="global-attributes:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code></li><li><code id="global-attributes:attr-itemref"><a href="#attr-itemref">itemref</a></code></li><li><code id="global-attributes:attr-itemscope"><a href="#attr-itemscope">itemscope</a></code></li><li><code id="global-attributes:attr-itemtype"><a href="#attr-itemtype">itemtype</a></code></li><li><code id="global-attributes:attr-lang"><a href="#attr-lang">lang</a></code></li><li><code id="global-attributes:attr-nonce"><a href="#attr-nonce">nonce</a></code></li><li><code id="global-attributes:attr-popover"><a href="#attr-popover">popover</a></code></li><li><code id="global-attributes:attr-spellcheck"><a href="#attr-spellcheck">spellcheck</a></code></li><li><code id="global-attributes:attr-style"><a href="#attr-style">style</a></code></li><li><code id="global-attributes:attr-tabindex"><a href="#attr-tabindex">tabindex</a></code></li><li><code id="global-attributes:attr-title"><a href="#attr-title">title</a></code></li><li><code id="global-attributes:attr-translate"><a href="#attr-translate">translate</a></code></li><li><code id="global-attributes:attr-writingsuggestions"><a href="#attr-writingsuggestions">writingsuggestions</a></code></li></ul>

  

  <p>These attributes are only defined by this specification as attributes for <a href="#html-elements" id="global-attributes:html-elements-2">HTML
  elements</a>. When this specification refers to elements having these attributes, elements from
  namespaces that are not defined as having these attributes must not be considered as being
  elements with these attributes.</p>

  <div class="example">

   <p>For example, in the following XML fragment, the "<code>bogus</code>" element does not
   have a <code id="global-attributes:attr-dir-2"><a href="#attr-dir">dir</a></code> attribute as defined in this specification, despite
   having an attribute with the literal name "<code>dir</code>". Thus, <a href="#the-directionality" id="global-attributes:the-directionality">the
   directionality</a> of the inner-most <code id="global-attributes:the-span-element"><a href="#the-span-element">span</a></code> element is '<a href="#concept-rtl" id="global-attributes:concept-rtl">rtl</a>', inherited from the <code id="global-attributes:the-div-element"><a href="#the-div-element">div</a></code> element indirectly through
   the "<code>bogus</code>" element.</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">xmlns</c-><c- o="">=</c-><c- s="">"http://www.w3.org/1999/xhtml"</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">"rtl"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">bogus</c-> <c- e="">xmlns</c-><c- o="">=</c-><c- s="">"https://example.net/ns"</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">"ltr"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">xmlns</c-><c- o="">=</c-><c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">bogus</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/slot" title="The slot global attribute assigns a slot in a shadow DOM shadow tree to an element: An element with a slot attribute is assigned to the slot created by the <slot> element whose name attribute's value matches that slot attribute's value.">Global_attributes/slot</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>53+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie unknown"><span>Internet Explorer</span><span>?</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p><cite>DOM</cite> defines the user agent requirements for the <dfn data-dfn-for="global" id="classes" data-dfn-type="element-attr"><code>class</code></dfn>, <dfn data-dfn-for="global" id="the-id-attribute" data-dfn-type="element-attr"><code>id</code></dfn>, and <dfn data-dfn-for="global" id="attr-slot" data-dfn-type="element-attr"><code>slot</code></dfn> attributes for any element in any namespace.
  <a href="#refsDOM">[DOM]</a></p>

  <p>The <code id="global-attributes:classes"><a href="#classes">class</a></code>, <code id="global-attributes:the-id-attribute"><a href="#the-id-attribute">id</a></code>, and <code id="global-attributes:attr-slot"><a href="#attr-slot">slot</a></code> attributes may be specified on all <a href="#html-elements" id="global-attributes:html-elements-3">HTML elements</a>.</p>

  <p>When specified on <a href="#html-elements" id="global-attributes:html-elements-4">HTML elements</a>, the <code id="global-attributes:classes-2"><a href="#classes">class</a></code>
  attribute must have a value that is a <a href="#set-of-space-separated-tokens" id="global-attributes:set-of-space-separated-tokens">set of space-separated tokens</a> representing the
  various classes that the element belongs to.</p>

  <div class="note">

  <p>Assigning classes to an element affects class matching in selectors in CSS, the <code id="global-attributes:dom-document-getelementsbyclassname"><a data-x-internal="dom-document-getelementsbyclassname" href="https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname">getElementsByClassName()</a></code> method in the DOM,
  and other such features.</p>

  <p>There are no additional restrictions on the tokens authors can use in the <code id="global-attributes:classes-3"><a href="#classes">class</a></code> attribute, but authors are encouraged to use values that describe
  the nature of the content, rather than values that describe the desired presentation of the
  content.</p>

  </div>

  <p>When specified on <a href="#html-elements" id="global-attributes:html-elements-5">HTML elements</a>, the <code id="global-attributes:the-id-attribute-2"><a href="#the-id-attribute">id</a></code> attribute
  value must be unique amongst all the <a href="https://dom.spec.whatwg.org/#concept-id" id="global-attributes:concept-id" data-x-internal="concept-id">IDs</a> in the element's
  <a id="global-attributes:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> and must contain at least one character. The value must not contain any
  <a id="global-attributes:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p>

  

  <div class="note">

  <p>The <code id="global-attributes:the-id-attribute-3"><a href="#the-id-attribute">id</a></code> attribute specifies its element's <a href="https://dom.spec.whatwg.org/#concept-id" id="global-attributes:concept-id-2" data-x-internal="concept-id">unique identifier (ID)</a>.</p>

  <p>There are no other restrictions on what form an ID can take; in particular, IDs can consist of
  just digits, start with a digit, start with an underscore, consist of just punctuation, etc.</p>

  <p>An element's <a href="https://dom.spec.whatwg.org/#concept-id" id="global-attributes:concept-id-3" data-x-internal="concept-id">unique identifier</a> can be used for a variety of
  purposes, most notably as a way to link to specific parts of a document using <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="global-attributes:concept-url-fragment" data-x-internal="concept-url-fragment">fragments</a>, as a way to target an element when scripting, and
  as a way to style a specific element from CSS.</p>

  </div>

  

  <p>Identifiers are opaque strings. Particular meanings should not be derived from the value of the
  <code id="global-attributes:the-id-attribute-4"><a href="#the-id-attribute">id</a></code> attribute.</p>

  

  <p>There are no conformance requirements for the <code id="global-attributes:attr-slot-2"><a href="#attr-slot">slot</a></code> attribute
  specific to <a href="#html-elements" id="global-attributes:html-elements-6">HTML elements</a>.</p>

  <p class="note">The <code id="global-attributes:attr-slot-3"><a href="#attr-slot">slot</a></code> attribute is used to <a id="global-attributes:assign-a-slot" href="https://dom.spec.whatwg.org/#assign-a-slot" data-x-internal="assign-a-slot">assign a
  slot</a> to an element: an element with a <code id="global-attributes:attr-slot-4"><a href="#attr-slot">slot</a></code> attribute is
  <a href="https://dom.spec.whatwg.org/#assign-a-slot" id="global-attributes:assign-a-slot-2" data-x-internal="assign-a-slot">assigned</a> to the <a href="https://dom.spec.whatwg.org/#concept-slot" id="global-attributes:concept-slot" data-x-internal="concept-slot">slot</a>
  created by the <code id="global-attributes:the-slot-element"><a href="#the-slot-element">slot</a></code> element whose <a href="#attr-slot-name" id="global-attributes:attr-slot-name">name</a>
  attribute's value matches that <code id="global-attributes:attr-slot-5"><a href="#attr-slot">slot</a></code> attribute's value — but only
  if that <code id="global-attributes:the-slot-element-2"><a href="#the-slot-element">slot</a></code> element finds itself in the <a id="global-attributes:shadow-tree" href="https://dom.spec.whatwg.org/#concept-shadow-tree" data-x-internal="shadow-tree">shadow tree</a> whose
  <a id="global-attributes:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>'s <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="global-attributes:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">host</a> has the corresponding
  <code id="global-attributes:attr-slot-6"><a href="#attr-slot">slot</a></code> attribute value.</p>

  <hr>

  <p>To enable assistive technology products to expose a more fine-grained interface than is
  otherwise possible with HTML elements and attributes, a set of <a href="#wai-aria">annotations
  for assistive technology products</a> can be specified (the ARIA <code id="global-attributes:attr-aria-role"><a href="#attr-aria-role">role</a></code> and <code id="global-attributes:attr-aria-*"><a href="#attr-aria-*">aria-*</a></code> attributes).
  <a href="#refsARIA">[ARIA]</a></p>

  <hr>

  <p>The following <a href="#event-handler-content-attributes" id="global-attributes:event-handler-content-attributes">event handler content attributes</a> may be specified on any <a href="#html-elements" id="global-attributes:html-elements-7">HTML element</a>:</p>

  <ul class="brief"><li><code id="global-attributes:handler-onauxclick"><a href="#handler-onauxclick">onauxclick</a></code></li><li><code id="global-attributes:handler-onbeforeinput"><a href="#handler-onbeforeinput">onbeforeinput</a></code></li><li><code id="global-attributes:handler-onbeforematch"><a href="#handler-onbeforematch">onbeforematch</a></code></li><li><code id="global-attributes:handler-onbeforetoggle"><a href="#handler-onbeforetoggle">onbeforetoggle</a></code></li><li><code id="global-attributes:handler-onblur"><a href="#handler-onblur">onblur</a></code>*</li><li><code id="global-attributes:handler-oncancel"><a href="#handler-oncancel">oncancel</a></code></li><li><code id="global-attributes:handler-oncanplay"><a href="#handler-oncanplay">oncanplay</a></code></li><li><code id="global-attributes:handler-oncanplaythrough"><a href="#handler-oncanplaythrough">oncanplaythrough</a></code></li><li><code id="global-attributes:handler-onchange"><a href="#handler-onchange">onchange</a></code></li><li><code id="global-attributes:handler-onclick"><a href="#handler-onclick">onclick</a></code></li><li><code id="global-attributes:handler-onclose"><a href="#handler-onclose">onclose</a></code></li><li><code id="global-attributes:handler-oncommand"><a href="#handler-oncommand">oncommand</a></code></li><li><code id="global-attributes:handler-oncontextlost"><a href="#handler-oncontextlost">oncontextlost</a></code></li><li><code id="global-attributes:handler-oncontextmenu"><a href="#handler-oncontextmenu">oncontextmenu</a></code></li><li><code id="global-attributes:handler-oncontextrestored"><a href="#handler-oncontextrestored">oncontextrestored</a></code></li><li><code id="global-attributes:handler-oncopy"><a href="#handler-oncopy">oncopy</a></code></li><li><code id="global-attributes:handler-oncuechange"><a href="#handler-oncuechange">oncuechange</a></code></li><li><code id="global-attributes:handler-oncut"><a href="#handler-oncut">oncut</a></code></li><li><code id="global-attributes:handler-ondblclick"><a href="#handler-ondblclick">ondblclick</a></code></li><li><code id="global-attributes:handler-ondrag"><a href="#handler-ondrag">ondrag</a></code></li><li><code id="global-attributes:handler-ondragend"><a href="#handler-ondragend">ondragend</a></code></li><li><code id="global-attributes:handler-ondragenter"><a href="#handler-ondragenter">ondragenter</a></code></li><li><code id="global-attributes:handler-ondragleave"><a href="#handler-ondragleave">ondragleave</a></code></li><li><code id="global-attributes:handler-ondragover"><a href="#handler-ondragover">ondragover</a></code></li><li><code id="global-attributes:handler-ondragstart"><a href="#handler-ondragstart">ondragstart</a></code></li><li><code id="global-attributes:handler-ondrop"><a href="#handler-ondrop">ondrop</a></code></li><li><code id="global-attributes:handler-ondurationchange"><a href="#handler-ondurationchange">ondurationchange</a></code></li><li><code id="global-attributes:handler-onemptied"><a href="#handler-onemptied">onemptied</a></code></li><li><code id="global-attributes:handler-onended"><a href="#handler-onended">onended</a></code></li><li><code id="global-attributes:handler-onerror"><a href="#handler-onerror">onerror</a></code>*</li><li><code id="global-attributes:handler-onfocus"><a href="#handler-onfocus">onfocus</a></code>*</li><li><code id="global-attributes:handler-onformdata"><a href="#handler-onformdata">onformdata</a></code></li><li><code id="global-attributes:handler-oninput"><a href="#handler-oninput">oninput</a></code></li><li><code id="global-attributes:handler-oninvalid"><a href="#handler-oninvalid">oninvalid</a></code></li><li><code id="global-attributes:handler-onkeydown"><a href="#handler-onkeydown">onkeydown</a></code></li><li><code id="global-attributes:handler-onkeypress"><a href="#handler-onkeypress">onkeypress</a></code></li><li><code id="global-attributes:handler-onkeyup"><a href="#handler-onkeyup">onkeyup</a></code></li><li><code id="global-attributes:handler-onload"><a href="#handler-onload">onload</a></code>*</li><li><code id="global-attributes:handler-onloadeddata"><a href="#handler-onloadeddata">onloadeddata</a></code></li><li><code id="global-attributes:handler-onloadedmetadata"><a href="#handler-onloadedmetadata">onloadedmetadata</a></code></li><li><code id="global-attributes:handler-onloadstart"><a href="#handler-onloadstart">onloadstart</a></code></li><li><code id="global-attributes:handler-onmousedown"><a href="#handler-onmousedown">onmousedown</a></code></li><li><code id="global-attributes:handler-onmouseenter"><a href="#handler-onmouseenter">onmouseenter</a></code></li><li><code id="global-attributes:handler-onmouseleave"><a href="#handler-onmouseleave">onmouseleave</a></code></li><li><code id="global-attributes:handler-onmousemove"><a href="#handler-onmousemove">onmousemove</a></code></li><li><code id="global-attributes:handler-onmouseout"><a href="#handler-onmouseout">onmouseout</a></code></li><li><code id="global-attributes:handler-onmouseover"><a href="#handler-onmouseover">onmouseover</a></code></li><li><code id="global-attributes:handler-onmouseup"><a href="#handler-onmouseup">onmouseup</a></code></li><li><code id="global-attributes:handler-onpaste"><a href="#handler-onpaste">onpaste</a></code></li><li><code id="global-attributes:handler-onpause"><a href="#handler-onpause">onpause</a></code></li><li><code id="global-attributes:handler-onplay"><a href="#handler-onplay">onplay</a></code></li><li><code id="global-attributes:handler-onplaying"><a href="#handler-onplaying">onplaying</a></code></li><li><code id="global-attributes:handler-onprogress"><a href="#handler-onprogress">onprogress</a></code></li><li><code id="global-attributes:handler-onratechange"><a href="#handler-onratechange">onratechange</a></code></li><li><code id="global-attributes:handler-onreset"><a href="#handler-onreset">onreset</a></code></li><li><code id="global-attributes:handler-onresize"><a href="#handler-onresize">onresize</a></code>*</li><li><code id="global-attributes:handler-onscroll"><a href="#handler-onscroll">onscroll</a></code>*</li><li><code id="global-attributes:handler-onscrollend"><a href="#handler-onscrollend">onscrollend</a></code>*</li><li><code id="global-attributes:handler-onsecuritypolicyviolation"><a href="#handler-onsecuritypolicyviolation">onsecuritypolicyviolation</a></code></li><li><code id="global-attributes:handler-onseeked"><a href="#handler-onseeked">onseeked</a></code></li><li><code id="global-attributes:handler-onseeking"><a href="#handler-onseeking">onseeking</a></code></li><li><code id="global-attributes:handler-onselect"><a href="#handler-onselect">onselect</a></code></li><li><code id="global-attributes:handler-onslotchange"><a href="#handler-onslotchange">onslotchange</a></code></li><li><code id="global-attributes:handler-onstalled"><a href="#handler-onstalled">onstalled</a></code></li><li><code id="global-attributes:handler-onsubmit"><a href="#handler-onsubmit">onsubmit</a></code></li><li><code id="global-attributes:handler-onsuspend"><a href="#handler-onsuspend">onsuspend</a></code></li><li><code id="global-attributes:handler-ontimeupdate"><a href="#handler-ontimeupdate">ontimeupdate</a></code></li><li><code id="global-attributes:handler-ontoggle"><a href="#handler-ontoggle">ontoggle</a></code></li><li><code id="global-attributes:handler-onvolumechange"><a href="#handler-onvolumechange">onvolumechange</a></code></li><li><code id="global-attributes:handler-onwaiting"><a href="#handler-onwaiting">onwaiting</a></code></li><li><code id="global-attributes:handler-onwheel"><a href="#handler-onwheel">onwheel</a></code></li></ul>

  <p class="note">The attributes marked with an asterisk have a different meaning when specified on
  <code id="global-attributes:the-body-element"><a href="#the-body-element">body</a></code> elements as those elements expose <a href="#event-handlers" id="global-attributes:event-handlers">event handlers</a> of the
  <code id="global-attributes:window"><a href="#window">Window</a></code> object with the same names.</p>

  <p class="note">While these attributes apply to all elements, they are not useful on all elements.
  For example, only <a href="#media-element" id="global-attributes:media-element">media elements</a> will ever receive a <code id="global-attributes:event-media-volumechange"><a href="#event-media-volumechange">volumechange</a></code> event fired by the user agent.</p>

  <hr>

  <p><a href="#custom-data-attribute" id="global-attributes:custom-data-attribute">Custom data attributes</a> (e.g. <code>data-foldername</code> or <code>data-msgid</code>) can be specified on any
  <a href="#html-elements" id="global-attributes:html-elements-8">HTML element</a>, to store custom data, state, annotations, and
  similar, specific to the page.</p>

  <hr>

  <p>In <a id="global-attributes:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>, elements in the <a id="global-attributes:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a> may have an <code>xmlns</code> attribute specified, if, and only if, it has the exact value "<code>http://www.w3.org/1999/xhtml</code>". This does not apply to <a id="global-attributes:xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML
  documents</a>.</p>

  <p class="note">In HTML, the <code>xmlns</code> attribute has absolutely no effect. It
  is basically a talisman. It is allowed merely to make migration to and from XML mildly easier.
  When parsed by an <a href="#html-parser" id="global-attributes:html-parser">HTML parser</a>, the attribute ends up in no namespace. In XML, the
  attribute is part of the namespace declaration mechanism and always ends up in the "<code>http://www.w3.org/2000/xmlns/</code>" namespace.</p>

  <hr>

  <p><cite>XML</cite> also allows the use of the <code id="global-attributes:attr-xml-space"><a data-x-internal="attr-xml-space" href="https://www.w3.org/TR/xml/#sec-white-space">xml:space</a></code>
  attribute in the <a id="global-attributes:xml-namespace" href="https://infra.spec.whatwg.org/#xml-namespace" data-x-internal="xml-namespace">XML namespace</a> on any element in an <a href="https://dom.spec.whatwg.org/#xml-document" id="global-attributes:xml-documents-2" data-x-internal="xml-documents">XML
  document</a>. This attribute has no effect on <a href="#html-elements" id="global-attributes:html-elements-9">HTML elements</a>, as the default
  behavior in HTML is to preserve whitespace. <a href="#refsXML">[XML]</a></p>

  <p class="note">There is no way to serialize the <code id="global-attributes:attr-xml-space-2"><a data-x-internal="attr-xml-space" href="https://www.w3.org/TR/xml/#sec-white-space">xml:space</a></code>
  attribute on <a href="#html-elements" id="global-attributes:html-elements-10">HTML elements</a> in the <code id="global-attributes:text/html"><a href="#text/html">text/html</a></code> syntax.</p>



  <h5 id="the-title-attribute"><span class="secno">3.2.6.1</span> The <code id="the-title-attribute:attr-title"><a href="#attr-title">title</a></code> attribute<a href="#the-title-attribute" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title" title="The title global attribute contains text representing advisory information related to the element it belongs to.">Global_attributes/title</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <dfn data-dfn-for="html-global" id="attr-title" data-dfn-type="element-attr"><code>title</code></dfn> attribute
  <a href="#represents" id="the-title-attribute:represents">represents</a> advisory information for the element, such as would be appropriate for a
  tooltip. On a link, this could be the title or a description of the target resource; on an image,
  it could be the image credit or a description of the image; on a paragraph, it could be a footnote
  or commentary on the text; on a citation, it could be further information about the source; on
  <a href="#interactive-content-2" id="the-title-attribute:interactive-content-2">interactive content</a>, it could be a label for, or instructions for, use of the
  element; and so forth.  The value is text.</p>

  
  <p class="note">Relying on the <code id="the-title-attribute:attr-title-2"><a href="#attr-title">title</a></code> attribute is currently
  discouraged as many user agents do not expose the attribute in an accessible manner as required by
  this specification (e.g., requiring a pointing device such as a mouse to cause a tooltip to
  appear, which excludes keyboard-only users and touch-only users, such as anyone with a modern
  phone or tablet).</p>

  <p>If this attribute is omitted from an element, then it implies that the <code id="the-title-attribute:attr-title-3"><a href="#attr-title">title</a></code> attribute of the nearest ancestor <a href="#html-elements" id="the-title-attribute:html-elements">HTML element</a> with a <code id="the-title-attribute:attr-title-4"><a href="#attr-title">title</a></code> attribute set is also
  relevant to this element. Setting the attribute overrides this, explicitly stating that the
  advisory information of any ancestors is not relevant to this element. Setting the attribute to
  the empty string indicates that the element has no advisory information.</p>

  <p>If the <code id="the-title-attribute:attr-title-5"><a href="#attr-title">title</a></code> attribute's value contains U+000A LINE FEED (LF)
  characters, the content is split into multiple lines. Each U+000A LINE FEED (LF) character
  represents a line break.</p>

  <div class="example">
   <p>Caution is advised with respect to the use of newlines in <code id="the-title-attribute:attr-title-6"><a href="#attr-title">title</a></code> attributes.</p>

   <p>For instance, the following snippet actually defines an abbreviation's expansion <em>with a
   line break in it</em>:</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My logs show that there was some interest in <c- p="">&lt;</c-><c- f="">abbr</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Hypertext</c->
<c- s="">Transport Protocol"</c-><c- p="">&gt;</c->HTTP<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-> today.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre> 
  </div>

  <p>Some elements, such as <code id="the-title-attribute:the-link-element"><a href="#the-link-element">link</a></code>, <code id="the-title-attribute:the-abbr-element"><a href="#the-abbr-element">abbr</a></code>, and <code id="the-title-attribute:the-input-element"><a href="#the-input-element">input</a></code>, define
  additional semantics for the <code id="the-title-attribute:attr-title-7"><a href="#attr-title">title</a></code> attribute beyond the semantics
  described above.</p> 

  

  <div data-algorithm="">
  <p>The <dfn id="advisory-information">advisory information</dfn> of an element is the value that the following algorithm
  returns, with the algorithm being aborted once a value is returned. When the algorithm returns the
  empty string, then there is no advisory information.</p>

  <ol><li><p>If the element has a <code id="the-title-attribute:attr-title-8"><a href="#attr-title">title</a></code> attribute, then return the
   result of running <a id="the-title-attribute:normalize-newlines" href="https://infra.spec.whatwg.org/#normalize-newlines" data-x-internal="normalize-newlines">normalize newlines</a> on its value.</p></li><li><p>If the element has a parent element, then return the parent element's <a href="#advisory-information" id="the-title-attribute:advisory-information">advisory
   information</a>.</p></li><li><p>Return the empty string.</p></li></ol>
  </div>

  <p>User agents should inform the user when elements have <a href="#advisory-information" id="the-title-attribute:advisory-information-2">advisory information</a>,
  otherwise the information would not be discoverable.</p>

  <hr>

  



  <h5 id="the-lang-and-xml:lang-attributes"><span class="secno">3.2.6.2</span> The <code id="the-lang-and-xml:lang-attributes:attr-lang"><a href="#attr-lang">lang</a></code> and <code id="the-lang-and-xml:lang-attributes:attr-xml-lang"><a data-x-internal="attr-xml-lang" href="https://www.w3.org/TR/xml/#sec-lang-tag">xml:lang</a></code>
  attributes<a href="#the-lang-and-xml:lang-attributes" class="self-link"></a></h5>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang" title="The lang global attribute helps define the language of an element: the language that non-editable elements are written in, or the language that the editable elements should be written in by the user. The attribute contains a single &quot;language tag&quot; in the format defined in RFC 5646: Tags for Identifying Languages (also known as BCP 47).">Global_attributes/lang</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="html-global" id="attr-lang" data-dfn-type="element-attr"><code>lang</code></dfn> attribute
  (in no namespace) specifies the primary language for the element's contents and for any of the
  element's attributes that contain text. Its value must be a valid BCP 47 language tag, or the
  empty string. Setting the attribute to the empty string indicates that the primary language is
  unknown. <a href="#refsBCP47">[BCP47]</a></p>

  <p>The <dfn id="attr-xml-lang"><a href="https://www.w3.org/TR/xml/#sec-lang-tag"><code>lang</code></a></dfn> attribute in the <a id="the-lang-and-xml:lang-attributes:xml-namespace" href="https://infra.spec.whatwg.org/#xml-namespace" data-x-internal="xml-namespace">XML namespace</a> is defined in XML.
  <a href="#refsXML">[XML]</a></p>

  <p>If these attributes are omitted from an element, then the language of this element is the same
  as the language of its parent element, if any (except for <code id="the-lang-and-xml:lang-attributes:the-slot-element"><a href="#the-slot-element">slot</a></code> elements in a
  <a id="the-lang-and-xml:lang-attributes:shadow-tree" href="https://dom.spec.whatwg.org/#concept-shadow-tree" data-x-internal="shadow-tree">shadow tree</a>).</p>

  <p>The <code id="the-lang-and-xml:lang-attributes:attr-lang-2"><a href="#attr-lang">lang</a></code> attribute in no namespace may be used on any <a href="#html-elements" id="the-lang-and-xml:lang-attributes:html-elements">HTML element</a>.</p>

  <p>The <a href="https://www.w3.org/TR/xml/#sec-lang-tag" id="the-lang-and-xml:lang-attributes:attr-xml-lang-2" data-x-internal="attr-xml-lang"><code>lang</code> attribute in the <span>XML
  namespace</span></a> may be used on <a href="#html-elements" id="the-lang-and-xml:lang-attributes:html-elements-2">HTML elements</a> in <a id="the-lang-and-xml:lang-attributes:xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a>,
  as well as elements in other namespaces if the relevant specifications allow it (in particular,
  MathML and SVG allow <a href="https://www.w3.org/TR/xml/#sec-lang-tag" id="the-lang-and-xml:lang-attributes:attr-xml-lang-3" data-x-internal="attr-xml-lang"><code>lang</code> attributes in the
  <span>XML namespace</span></a> to be specified on their elements). If both the <code id="the-lang-and-xml:lang-attributes:attr-lang-3"><a href="#attr-lang">lang</a></code> attribute in no namespace and the <a href="https://www.w3.org/TR/xml/#sec-lang-tag" id="the-lang-and-xml:lang-attributes:attr-xml-lang-4" data-x-internal="attr-xml-lang"><code>lang</code> attribute in the <span>XML namespace</span></a> are specified on the same
  element, they must have exactly the same value when compared in an <a id="the-lang-and-xml:lang-attributes:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> manner.</p>

  <p>Authors must not use the <a href="https://www.w3.org/TR/xml/#sec-lang-tag" id="the-lang-and-xml:lang-attributes:attr-xml-lang-5" data-x-internal="attr-xml-lang"><code>lang</code> attribute in
  the <span>XML namespace</span></a> on <a href="#html-elements" id="the-lang-and-xml:lang-attributes:html-elements-3">HTML elements</a> in <a id="the-lang-and-xml:lang-attributes:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML
  documents</a>. To ease migration to and from XML, authors may specify an attribute in no
  namespace with no prefix and with the literal localname "<code>xml:lang</code>" on
  <a href="#html-elements" id="the-lang-and-xml:lang-attributes:html-elements-4">HTML elements</a> in <a id="the-lang-and-xml:lang-attributes:html-documents-2" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>, but such attributes must only be
  specified if a <code id="the-lang-and-xml:lang-attributes:attr-lang-4"><a href="#attr-lang">lang</a></code> attribute in no namespace is also specified,
  and both attributes must have the same value when compared in an <a id="the-lang-and-xml:lang-attributes:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> manner.</p>

  <p class="note">The attribute in no namespace with no prefix and with the literal localname "<code>xml:lang</code>" has no effect on language processing.</p>

  

  <hr>

  <div data-algorithm="">
  <p>To determine the <dfn data-dfn-for="Node" id="language" data-export="">language</dfn> of a node, user agents must use the
  first appropriate step in the following list:</p>

  <dl class="switch"><dt>If the node is an element that has a <a href="https://www.w3.org/TR/xml/#sec-lang-tag" id="the-lang-and-xml:lang-attributes:attr-xml-lang-6" data-x-internal="attr-xml-lang"><code>lang</code>
   attribute in the <span>XML namespace</span></a> set</dt><dd><p>Use the value of that attribute.</p></dd><dt>If the node is an <a href="#html-elements" id="the-lang-and-xml:lang-attributes:html-elements-5">HTML element</a> or an element in the
   <a id="the-lang-and-xml:lang-attributes:svg-namespace" href="https://infra.spec.whatwg.org/#svg-namespace" data-x-internal="svg-namespace">SVG namespace</a>, and it has a <code id="the-lang-and-xml:lang-attributes:attr-lang-5"><a href="#attr-lang">lang</a></code> in no namespace
   attribute set</dt><dd><p>Use the value of that attribute.</p></dd><dt>If the node's parent is a <a id="the-lang-and-xml:lang-attributes:shadow-root" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a></dt><dd><p>Use the <a href="#language" id="the-lang-and-xml:lang-attributes:language">language</a> of that <a id="the-lang-and-xml:lang-attributes:shadow-root-2" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a>'s <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="the-lang-and-xml:lang-attributes:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">host</a>.</p></dd><dt>If the node's <a id="the-lang-and-xml:lang-attributes:parent-element" href="https://dom.spec.whatwg.org/#parent-element" data-x-internal="parent-element">parent element</a> is not null</dt><dd><p>Use the <a href="#language" id="the-lang-and-xml:lang-attributes:language-2">language</a> of that <a id="the-lang-and-xml:lang-attributes:parent-element-2" href="https://dom.spec.whatwg.org/#parent-element" data-x-internal="parent-element">parent element</a>.</p></dd><dt>Otherwise</dt><dd><p>If there is a <a href="#pragma-set-default-language" id="the-lang-and-xml:lang-attributes:pragma-set-default-language">pragma-set default language</a> set, then that is the language of
   the node. If there is no <a href="#pragma-set-default-language" id="the-lang-and-xml:lang-attributes:pragma-set-default-language-2">pragma-set default language</a> set, then language information
   from a higher-level protocol (such as HTTP), if any, must be used as the final fallback language
   instead. In the absence of any such language information, and in cases where the higher-level
   protocol reports multiple languages, the language of the node is unknown, and the corresponding
   language tag is the empty string.</p></dd></dl>
  </div>

  <p>If the resulting value is not a recognized language tag, then it must be treated as an unknown
  language having the given language tag, distinct from all other languages. For the purposes of
  round-tripping or communicating with other services that expect language tags, user agents should
  pass unknown language tags through unmodified, and tagged as being BCP 47 language tags, so that
  subsequent services do not interpret the data as another type of language description.
  <a href="#refsBCP47">[BCP47]</a></p>

  <p class="example">Thus, for instance, an element with <code>lang="xyzzy"</code> would be
  matched by the selector <code>:lang(xyzzy)</code> (e.g. in CSS), but it would not be
  matched by <code>:lang(abcde)</code>, even though both are equally invalid. Similarly, if
  a web browser and screen reader working in unison communicated about the language of the element,
  the browser would tell the screen reader that the language was "xyzzy", even if it knew it was
  invalid, just in case the screen reader actually supported a language with that tag after all.
  Even if the screen reader supported both BCP 47 and another syntax for encoding language names,
  and in that other syntax the string "xyzzy" was a way to denote the Belarusian language, it would
  be <em>incorrect</em> for the screen reader to then start treating text as Belarusian, because
  "xyzzy" is not how Belarusian is described in BCP 47 codes (BCP 47 uses the code "be" for
  Belarusian).</p>

  <p>If the resulting value is the empty string, then it must be interpreted as meaning that the
  language of the node is <dfn id="concept-explicitly-unknown">explicitly unknown</dfn>.</p>

  <hr>

  <p>User agents may use the element's language to determine proper processing or rendering (e.g. in
  the selection of appropriate fonts or pronunciations, for dictionary selection, or for the user
  interfaces of form controls such as date pickers). </p>

  

  



  <h5 id="the-translate-attribute"><span class="secno">3.2.6.3</span> The <code id="the-translate-attribute:attr-translate"><a href="#attr-translate">translate</a></code> attribute<a href="#the-translate-attribute" class="self-link"></a></h5>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/translate" title="The translate global attribute is an enumerated attribute that is used to specify whether an element's translatable attribute values and its Text node children should be translated when the page is localized, or whether to leave them unchanged.">Global_attributes/translate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>111+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>19+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="html-global" id="attr-translate" data-dfn-type="element-attr"><code>translate</code></dfn>
  attribute is used to specify whether an element's attribute values and the values of its
  <code id="the-translate-attribute:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node children are to be translated when the page is localized, or whether to
  leave them unchanged. It is an <a href="#enumerated-attribute" id="the-translate-attribute:enumerated-attribute">enumerated attribute</a> with the
  following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/translate" id="attr-translate-yes-keyword" data-dfn-type="attr-value"><code>yes</code></dfn>
     </td><td><dfn id="attr-translate-yes-state">Yes</dfn>
     </td><td>Sets <a href="#translation-mode" id="the-translate-attribute:translation-mode">translation mode</a> to <a href="#translate-enabled" id="the-translate-attribute:translate-enabled">translate-enabled</a>.
    </td></tr><tr><td><dfn data-dfn-for="html-global/translate" id="attr-translate-no-keyword" data-dfn-type="attr-value"><code>no</code></dfn>
     </td><td><dfn id="attr-translate-no-state">No</dfn>
     </td><td>Sets <a href="#translation-mode" id="the-translate-attribute:translation-mode-2">translation mode</a> to <a href="#no-translate" id="the-translate-attribute:no-translate">no-translate</a>.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-translate-attribute:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-translate-attribute:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <dfn id="attr-translate-inherit-state">Inherit</dfn> state, and its <i id="the-translate-attribute:empty-value-default"><a href="#empty-value-default">empty value default</a></i> is the <a href="#attr-translate-yes-state" id="the-translate-attribute:attr-translate-yes-state">Yes</a>
  state.</p>
  </div>

  <div data-algorithm="">
  <p>Each element (even non-HTML elements) has a <dfn id="translation-mode">translation mode</dfn>, which is in either the
  <a href="#translate-enabled" id="the-translate-attribute:translate-enabled-2">translate-enabled</a> state or the <a href="#no-translate" id="the-translate-attribute:no-translate-2">no-translate</a> state. If an <a href="#html-elements" id="the-translate-attribute:html-elements">HTML element</a>'s <code id="the-translate-attribute:attr-translate-2"><a href="#attr-translate">translate</a></code>
  attribute is in the <a href="#attr-translate-yes-state" id="the-translate-attribute:attr-translate-yes-state-2">Yes</a> state, then the element's
  <a href="#translation-mode" id="the-translate-attribute:translation-mode-3">translation mode</a> is in the <a href="#translate-enabled" id="the-translate-attribute:translate-enabled-3">translate-enabled</a> state; otherwise, if the
  element's <code id="the-translate-attribute:attr-translate-3"><a href="#attr-translate">translate</a></code> attribute is in the <a href="#attr-translate-no-state" id="the-translate-attribute:attr-translate-no-state">No</a> state, then the element's <a href="#translation-mode" id="the-translate-attribute:translation-mode-4">translation mode</a>
  is in the <a href="#no-translate" id="the-translate-attribute:no-translate-3">no-translate</a> state. Otherwise, either the element's <code id="the-translate-attribute:attr-translate-4"><a href="#attr-translate">translate</a></code> attribute is in the <a href="#attr-translate-inherit-state" id="the-translate-attribute:attr-translate-inherit-state">Inherit</a> state, or the element is not an <a href="#html-elements" id="the-translate-attribute:html-elements-2">HTML element</a> and thus does not have a <code id="the-translate-attribute:attr-translate-5"><a href="#attr-translate">translate</a></code> attribute; in either case, the element's
  <a href="#translation-mode" id="the-translate-attribute:translation-mode-5">translation mode</a> is in the same state as its <a id="the-translate-attribute:parent-element" href="https://dom.spec.whatwg.org/#parent-element" data-x-internal="parent-element">parent element</a>'s, if any,
  or in the <a href="#translate-enabled" id="the-translate-attribute:translate-enabled-4">translate-enabled</a> state, if the element's <a id="the-translate-attribute:parent-element-2" href="https://dom.spec.whatwg.org/#parent-element" data-x-internal="parent-element">parent element</a> is
  null.</p>
  </div>

  <p>When an element is in the <dfn id="translate-enabled">translate-enabled</dfn> state, the element's <a href="#translatable-attributes" id="the-translate-attribute:translatable-attributes">translatable
  attributes</a> and the values of its <code id="the-translate-attribute:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node children are to be translated when
  the page is localized.</p>

  <p>When an element is in the <dfn id="no-translate">no-translate</dfn> state, the element's attribute values and the
  values of its <code id="the-translate-attribute:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node children are to be left as-is when the page is localized,
  e.g. because the element contains a person's name or a name of a computer program.</p>

  <div data-algorithm="">
  <p>The following attributes are <dfn id="translatable-attributes">translatable attributes</dfn>:</p>

  <ul class="brief"><li><code id="the-translate-attribute:attr-th-abbr"><a href="#attr-th-abbr">abbr</a></code> on <code id="the-translate-attribute:the-th-element"><a href="#the-th-element">th</a></code> elements</li><li><code>alt</code> on <code id="the-translate-attribute:attr-area-alt"><a href="#attr-area-alt">area</a></code>,
                                     <code id="the-translate-attribute:attr-img-alt"><a href="#attr-img-alt">img</a></code>, and
                                     <code id="the-translate-attribute:attr-input-alt"><a href="#attr-input-alt">input</a></code> elements</li><li><code id="the-translate-attribute:attr-meta-content"><a href="#attr-meta-content">content</a></code> on <code id="the-translate-attribute:the-meta-element"><a href="#the-meta-element">meta</a></code> elements, if the <code id="the-translate-attribute:attr-meta-name"><a href="#attr-meta-name">name</a></code> attribute specifies a metadata name whose value is known to be translatable</li><li><code id="the-translate-attribute:attr-hyperlink-download"><a href="#attr-hyperlink-download">download</a></code> on <code id="the-translate-attribute:the-a-element"><a href="#the-a-element">a</a></code> and
                                                                 <code id="the-translate-attribute:the-area-element"><a href="#the-area-element">area</a></code> elements</li><li><code>label</code> on <code id="the-translate-attribute:attr-optgroup-label"><a href="#attr-optgroup-label">optgroup</a></code>,
                                       <code id="the-translate-attribute:attr-option-label"><a href="#attr-option-label">option</a></code>, and
                                       <code id="the-translate-attribute:attr-track-label"><a href="#attr-track-label">track</a></code> elements</li><li><code id="the-translate-attribute:attr-lang"><a href="#attr-lang">lang</a></code> on <a href="#html-elements" id="the-translate-attribute:html-elements-3">HTML elements</a>; must be "translated" to match the language used in the translation</li><li><code>placeholder</code> on <code id="the-translate-attribute:attr-input-placeholder"><a href="#attr-input-placeholder">input</a></code> and
                                             <code id="the-translate-attribute:attr-textarea-placeholder"><a href="#attr-textarea-placeholder">textarea</a></code> elements</li><li><code id="the-translate-attribute:attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> on <code id="the-translate-attribute:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> elements; must be parsed and recursively processed</li><li><code id="the-translate-attribute:attr-style"><a href="#attr-style">style</a></code> on <a href="#html-elements" id="the-translate-attribute:html-elements-4">HTML elements</a>; must be parsed and
   recursively processed (e.g. for the values of <a id="the-translate-attribute:'content'" href="https://drafts.csswg.org/css2/#content%E2%91%A0" data-x-internal="'content'">'content'</a> properties)</li><li><code id="the-translate-attribute:attr-title"><a href="#attr-title">title</a></code> on all <a href="#html-elements" id="the-translate-attribute:html-elements-5">HTML elements</a></li><li><code id="the-translate-attribute:attr-input-value"><a href="#attr-input-value">value</a></code> on <code id="the-translate-attribute:the-input-element"><a href="#the-input-element">input</a></code> elements with a
       <code id="the-translate-attribute:attr-input-type"><a href="#attr-input-type">type</a></code> attribute in the <a href="#button-state-(type=button)" id="the-translate-attribute:button-state-(type=button)">Button</a> state
       or the <a href="#reset-button-state-(type=reset)" id="the-translate-attribute:reset-button-state-(type=reset)">Reset Button</a> state</li></ul>
  </div>

  <p>Other specifications may define other attributes that are also <a href="#translatable-attributes" id="the-translate-attribute:translatable-attributes-2">translatable
  attributes</a>. For example, <cite>ARIA</cite> would define the <code id="the-translate-attribute:attr-aria-label"><a data-x-internal="attr-aria-label" href="https://w3c.github.io/aria/#aria-label">aria-label</a></code> attribute as translatable.</p>

  

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-translate" data-dfn-type="attribute"><code>translate</code></dfn> IDL
  attribute must, on getting, return true if the element's <a href="#translation-mode" id="the-translate-attribute:translation-mode-6">translation mode</a> is
  <a href="#translate-enabled" id="the-translate-attribute:translate-enabled-5">translate-enabled</a>, and false otherwise. On setting, it must set the content
  attribute's value to "<code>yes</code>" if the new value is true, and set the content
  attribute's value to "<code>no</code>" otherwise.</p>
  </div>

  

  <div class="example">

   <p>In this example, everything in the document is to be translated when the page is localized,
   except the sample keyboard input and sample program output:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- default on the document element is translate=yes --&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->The Bee Game<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- implied translate=yes inherited from ancestors --&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The Bee Game is a text adventure game in English.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->When the game launches, the first thing you should do is type
  <c- p="">&lt;</c-><c- f="">kbd</c-> <strong><c- e="">translate</c-><c- o="">=</c-><c- s="">no</c-></strong><c- p="">&gt;</c->eat honey<c- p="">&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;</c->. The game will respond with:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;&lt;</c-><c- f="">samp</c-> <strong><c- e="">translate</c-><c- o="">=</c-><c- s="">no</c-></strong><c- p="">&gt;</c->Yum yum! That was some good honey!<c- p="">&lt;/</c-><c- f="">samp</c-><c- p="">&gt;&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h5 id="the-dir-attribute"><span class="secno">3.2.6.4</span> The <code id="the-dir-attribute:attr-dir"><a href="#attr-dir">dir</a></code> attribute<a href="#the-dir-attribute" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir" title="The dir global attribute is an enumerated attribute that indicates the directionality of the element's text.">Global_attributes/dir</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <dfn data-dfn-for="html-global" id="attr-dir" data-dfn-type="element-attr"><code>dir</code></dfn> attribute
  is an <a href="#enumerated-attribute" id="the-dir-attribute:enumerated-attribute">enumerated attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/dir" id="attr-dir-ltr" data-dfn-type="attr-value"><code>ltr</code></dfn>
     </td><td><dfn id="attr-dir-ltr-state">LTR</dfn>
     </td><td>The contents of the element are explicitly directionally isolated left-to-right text.
    </td></tr><tr><td><dfn data-dfn-for="html-global/dir" id="attr-dir-rtl" data-dfn-type="attr-value"><code>rtl</code></dfn>
     </td><td><dfn id="attr-dir-rtl-state">RTL</dfn>
     </td><td>The contents of the element are explicitly directionally isolated right-to-left text.
    </td></tr><tr><td><dfn data-dfn-for="html-global/dir" id="attr-dir-auto" data-dfn-type="attr-value"><code>auto</code></dfn>
     </td><td><dfn id="attr-dir-auto-state">Auto</dfn>
     </td><td>The contents of the element are explicitly directionally isolated text, but the direction
     is to be determined programmatically using the contents of the element (as described
     below).
  </td></tr></tbody></table>

  <div class="note">
   <p>The heuristic used by the <a href="#attr-dir-auto-state" id="the-dir-attribute:attr-dir-auto-state">Auto</a> state is very crude
   (it just looks at the first character with a strong directionality, in a manner analogous to the
   Paragraph Level determination in the bidirectional algorithm). Authors are urged to only use this
   value as a last resort when the direction of the text is truly unknown and no better server-side
   heuristic can be applied. <a href="#refsBIDI">[BIDI]</a></p>

   <p>For <code id="the-dir-attribute:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> and <code id="the-dir-attribute:the-pre-element"><a href="#the-pre-element">pre</a></code> elements, the heuristic is applied on a
   per-paragraph level.</p>
  </div>

  <div data-algorithm="">
  <p>The attribute's <i id="the-dir-attribute:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-dir-attribute:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <dfn id="attr-dir-undefined-state">Undefined</dfn> state.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="the-directionality">directionality</dfn> of an element (any element, not just
  an <a href="#html-elements" id="the-dir-attribute:html-elements">HTML element</a>) is either '<dfn id="concept-ltr">ltr</dfn>' or '<dfn id="concept-rtl">rtl</dfn>'. To compute the <a href="#the-directionality" id="the-dir-attribute:the-directionality">directionality</a> given an element <var>element</var>, switch on
  <var>element</var>'s <code id="the-dir-attribute:attr-dir-2"><a href="#attr-dir">dir</a></code> attribute state:</p>

  <dl class="switch"><dt><a href="#attr-dir-ltr-state" id="the-dir-attribute:attr-dir-ltr-state">LTR</a></dt><dd><p>Return '<a href="#concept-ltr" id="the-dir-attribute:concept-ltr">ltr</a>'.</p></dd><dt><a href="#attr-dir-rtl-state" id="the-dir-attribute:attr-dir-rtl-state">RTL</a></dt><dd><p>Return '<a href="#concept-rtl" id="the-dir-attribute:concept-rtl">rtl</a>'.</p></dd><dt><a href="#attr-dir-auto-state" id="the-dir-attribute:attr-dir-auto-state-2">Auto</a></dt><dd>
    <ol><li><p>Let <var>result</var> be the <a href="#auto-directionality" id="the-dir-attribute:auto-directionality">auto directionality</a> of
     <var>element</var>.</p></li><li><p>If <var>result</var> is null, then return '<a href="#concept-ltr" id="the-dir-attribute:concept-ltr-2">ltr</a>'.</p></li><li><p>Return <var>result</var>.</p></li></ol>
   </dd><dt><a href="#attr-dir-undefined-state" id="the-dir-attribute:attr-dir-undefined-state">Undefined</a></dt><dd>
    <dl class="switch"><dt>If <var>element</var> is a <code id="the-dir-attribute:the-bdi-element"><a href="#the-bdi-element">bdi</a></code> element</dt><dd>
      <ol><li><p>Let <var>result</var> be the <a href="#auto-directionality" id="the-dir-attribute:auto-directionality-2">auto directionality</a> of
       <var>element</var>.</p></li><li><p>If <var>result</var> is null, then return '<a href="#concept-ltr" id="the-dir-attribute:concept-ltr-3">ltr</a>'.</p></li><li><p>Return <var>result</var>.</p></li></ol>
     </dd><dt>If <var>element</var> is an <code id="the-dir-attribute:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="the-dir-attribute:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#telephone-state-(type=tel)" id="the-dir-attribute:telephone-state-(type=tel)">Telephone</a> state</dt><dd><p>Return '<a href="#concept-ltr" id="the-dir-attribute:concept-ltr-4">ltr</a>'.</p></dd><dt>Otherwise</dt><dd><p>Return the <a href="#parent-directionality" id="the-dir-attribute:parent-directionality">parent directionality</a> of <var>element</var>.</p></dd></dl>
   </dd></dl>
  </div>

  <p class="note">Since the <code id="the-dir-attribute:attr-dir-3"><a href="#attr-dir">dir</a></code> attribute is only defined for
  <a href="#html-elements" id="the-dir-attribute:html-elements-2">HTML elements</a>, it cannot be present on elements from other namespaces. Thus, elements
  from other namespaces always end up using the <a href="#parent-directionality" id="the-dir-attribute:parent-directionality-2">parent directionality</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="auto-directionality-form-associated-elements">auto-directionality form-associated elements</dfn> are:

  </p><ul><li><p><code id="the-dir-attribute:the-input-element-2"><a href="#the-input-element">input</a></code> elements whose <code id="the-dir-attribute:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is
   in the <a href="#hidden-state-(type=hidden)" id="the-dir-attribute:hidden-state-(type=hidden)">Hidden</a>, <a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-dir-attribute:text-(type=text)-state-and-search-state-(type=search)">Text</a>, <a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-dir-attribute:text-(type=text)-state-and-search-state-(type=search)-2">Search</a>,
   <a href="#telephone-state-(type=tel)" id="the-dir-attribute:telephone-state-(type=tel)-2">Telephone</a>, <a href="#url-state-(type=url)" id="the-dir-attribute:url-state-(type=url)">URL</a>, <a href="#email-state-(type=email)" id="the-dir-attribute:email-state-(type=email)">Email</a>, <a href="#password-state-(type=password)" id="the-dir-attribute:password-state-(type=password)">Password</a>, <a href="#submit-button-state-(type=submit)" id="the-dir-attribute:submit-button-state-(type=submit)">Submit
   Button</a>, <a href="#reset-button-state-(type=reset)" id="the-dir-attribute:reset-button-state-(type=reset)">Reset Button</a>, or <a href="#button-state-(type=button)" id="the-dir-attribute:button-state-(type=button)">Button</a> state, and</p></li><li><p><code id="the-dir-attribute:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> elements.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>To compute the <dfn id="auto-directionality">auto directionality</dfn> given an element <var>element</var>:</p>

  <ol><li>
    <p>If <var>element</var> is an <a href="#auto-directionality-form-associated-elements" id="the-dir-attribute:auto-directionality-form-associated-elements">auto-directionality form-associated element</a>:

    </p><ol><li><p>If <var>element</var>'s <a href="#concept-fe-value" id="the-dir-attribute:concept-fe-value">value</a> contains a
     character of bidirectional character type AL or R, and there is no character of bidirectional
     character type L anywhere before it in the element's <a href="#concept-fe-value" id="the-dir-attribute:concept-fe-value-2">value</a>, then return '<a href="#concept-rtl" id="the-dir-attribute:concept-rtl-2">rtl</a>'.
     <a href="#refsBIDI">[BIDI]</a></p></li><li><p>If <var>element</var>'s <a href="#concept-fe-value" id="the-dir-attribute:concept-fe-value-3">value</a> is not the empty
     string, then return '<a href="#concept-ltr" id="the-dir-attribute:concept-ltr-5">ltr</a>'.</p></li><li><p>Return null.</p></li></ol>
   </li><li>
    <p>If <var>element</var> is a <code id="the-dir-attribute:the-slot-element"><a href="#the-slot-element">slot</a></code> element whose <a id="the-dir-attribute:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> is a
    <a id="the-dir-attribute:shadow-root" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a> and <var>element</var>'s <a id="the-dir-attribute:assigned-nodes" href="https://dom.spec.whatwg.org/#slot-assigned-nodes" data-x-internal="assigned-nodes">assigned nodes</a> are not empty:</p>

    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-dir-attribute:list-iterate" data-x-internal="list-iterate">For each</a> node <var>child</var> of <var>element</var>'s
      <a id="the-dir-attribute:assigned-nodes-2" href="https://dom.spec.whatwg.org/#slot-assigned-nodes" data-x-internal="assigned-nodes">assigned nodes</a>:</p>

      <ol><li><p>Let <var>childDirection</var> be null.</p></li><li><p>If <var>child</var> is a <code id="the-dir-attribute:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, then set <var>childDirection</var> to
       the <a href="#text-node-directionality" id="the-dir-attribute:text-node-directionality">text node directionality</a> of <var>child</var>.</p></li><li>
        <p>Otherwise:</p>

        <ol><li><p><a id="the-dir-attribute:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>child</var> is an <code id="the-dir-attribute:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> node.</p></li><li><p>Set <var>childDirection</var> to the <a href="#contained-text-auto-directionality" id="the-dir-attribute:contained-text-auto-directionality">contained text auto directionality</a>
         of <var>child</var> with <i><a href="#auto-directionality-can-exclude-root" id="the-dir-attribute:auto-directionality-can-exclude-root">canExcludeRoot</a></i> set to
         true.</p></li></ol>
       </li><li><p>If <var>childDirection</var> is not null, then return
       <var>childDirection</var>.</p></li></ol>
     </li><li><p>Return null.</p></li></ol>
   </li><li><p>Return the <a href="#contained-text-auto-directionality" id="the-dir-attribute:contained-text-auto-directionality-2">contained text auto directionality</a> of <var>element</var> with
   <i><a href="#auto-directionality-can-exclude-root" id="the-dir-attribute:auto-directionality-can-exclude-root-2">canExcludeRoot</a></i> set to
   false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To compute the <dfn id="contained-text-auto-directionality">contained text auto directionality</dfn> of an element
  <var>element</var> with a boolean <dfn id="auto-directionality-can-exclude-root"><var>canExcludeRoot</var></dfn>:</p>

  <ol><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-dir-attribute:list-iterate-2" data-x-internal="list-iterate">For each</a> node <var>descendant</var> of
    <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="the-dir-attribute:descendant" data-x-internal="descendant">descendants</a>, in <a id="the-dir-attribute:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
    order</a>:</p>

    <ol><li>
      <p>If any of</p>

      <ul class="brief"><li><var>descendant</var></li><li>any ancestor element of <var>descendant</var> that is a descendant of <var>element</var></li><li>if <var>canExcludeRoot</var> is true, <var>element</var></li></ul>

      <p>is one of</p>

      <ul class="brief"><li>a <code id="the-dir-attribute:the-bdi-element-2"><a href="#the-bdi-element">bdi</a></code> element</li><li>a <code id="the-dir-attribute:the-script-element"><a href="#the-script-element">script</a></code> element</li><li>a <code id="the-dir-attribute:the-style-element"><a href="#the-style-element">style</a></code> element</li><li>a <code id="the-dir-attribute:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code> element</li><li>an element whose <code id="the-dir-attribute:attr-dir-4"><a href="#attr-dir">dir</a></code> attribute is not in the <a href="#attr-dir-undefined-state" id="the-dir-attribute:attr-dir-undefined-state-2">Undefined</a> state</li></ul>

      <p>then <a id="the-dir-attribute:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p>
     </li><li><p>If <var>descendant</var> is a <code id="the-dir-attribute:the-slot-element-2"><a href="#the-slot-element">slot</a></code> element whose <a id="the-dir-attribute:root-2" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> is a
     <a id="the-dir-attribute:shadow-root-2" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a>, then return the <a href="#the-directionality" id="the-dir-attribute:the-directionality-2">directionality</a> of that <a id="the-dir-attribute:shadow-root-3" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a>'s <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="the-dir-attribute:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">host</a>.</p></li><li><p>If <var>descendant</var> is not a <code id="the-dir-attribute:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, then
     <a id="the-dir-attribute:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>result</var> be the <a href="#text-node-directionality" id="the-dir-attribute:text-node-directionality-2">text node directionality</a> of
     <var>descendant</var>.</p></li><li><p>If <var>result</var> is not null, then return <var>result</var>.</p></li></ol>
   </li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To compute the <dfn id="text-node-directionality">text node directionality</dfn> given a <code id="the-dir-attribute:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node
  <var>text</var>:</p>

  <ol><li><p>If <var>text</var>'s <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="the-dir-attribute:concept-cd-data" data-x-internal="concept-cd-data">data</a> does not contain a code
   point whose bidirectional character type is L, AL, or R, then return null.
   <a href="#refsBIDI">[BIDI]</a></p></li><li><p>Let <var>codePoint</var> be the first code point in <var>text</var>'s <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="the-dir-attribute:concept-cd-data-2" data-x-internal="concept-cd-data">data</a> whose bidirectional character type is L, AL, or R.</p></li><li><p>If <var>codePoint</var> is of bidirectional character type AL or R, then return '<a href="#concept-rtl" id="the-dir-attribute:concept-rtl-3">rtl</a>'.</p></li><li><p>If <var>codePoint</var> is of bidirectional character type L, then return '<a href="#concept-ltr" id="the-dir-attribute:concept-ltr-6">ltr</a>'.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To compute the <dfn id="parent-directionality">parent directionality</dfn> given an element <var>element</var>:</p>

  <ol><li><p>Let <var>parentNode</var> be <var>element</var>'s parent node.</p></li><li><p>If <var>parentNode</var> is a <a id="the-dir-attribute:shadow-root-4" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a>, then return the <a href="#the-directionality" id="the-dir-attribute:the-directionality-3">directionality</a> of <var>parentNode</var>'s <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="the-dir-attribute:concept-documentfragment-host-2" data-x-internal="concept-documentfragment-host">host</a>.</p></li><li><p>If <var>parentNode</var> is an element, then return the <a href="#the-directionality" id="the-dir-attribute:the-directionality-4">directionality</a> of <var>parentNode</var>.</p></li><li><p>Return '<a href="#concept-ltr" id="the-dir-attribute:concept-ltr-7">ltr</a>'.</p></li></ol>
  </div>

  

  <p class="note">This attribute <a href="#bidireq">has rendering requirements involving the
  bidirectional algorithm</a>.</p>

  

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="directionality-of-the-attribute">directionality of an attribute</dfn> of an
  <a href="#html-elements" id="the-dir-attribute:html-elements-3">HTML element</a>, which is used when the text of that attribute is
  to be included in the rendering in some manner, is determined as per the first appropriate set of
  steps from the following list:</p>

  <dl class="switch"><dt>If the attribute is a <a href="#directionality-capable-attribute" id="the-dir-attribute:directionality-capable-attribute">directionality-capable attribute</a> and the element's <code id="the-dir-attribute:attr-dir-5"><a href="#attr-dir">dir</a></code> attribute is in the <a href="#attr-dir-auto-state" id="the-dir-attribute:attr-dir-auto-state-3">Auto</a>
   state</dt><dd>
    <p>Find the first character (in logical order) of the attribute's value that is of bidirectional
    character type L, AL, or R. <a href="#refsBIDI">[BIDI]</a></p>

    <p>If such a character is found and it is of bidirectional character type AL or R, the
    <a href="#directionality-of-the-attribute" id="the-dir-attribute:directionality-of-the-attribute">directionality of the attribute</a> is '<a href="#concept-rtl" id="the-dir-attribute:concept-rtl-4">rtl</a>'.</p>

    <p>Otherwise, the <a href="#directionality-of-the-attribute" id="the-dir-attribute:directionality-of-the-attribute-2">directionality of the attribute</a> is '<a href="#concept-ltr" id="the-dir-attribute:concept-ltr-8">ltr</a>'.</p>
   </dd><dt>Otherwise</dt><dd>The <a href="#directionality-of-the-attribute" id="the-dir-attribute:directionality-of-the-attribute-3">directionality of the attribute</a> is the same as <a href="#the-directionality" id="the-dir-attribute:the-directionality-5">the element's directionality</a>.</dd></dl>
  </div>

  <div data-algorithm="">
  <p>The following attributes are <dfn id="directionality-capable-attribute">directionality-capable attributes</dfn>:</p>

  <ul class="brief"><li><code id="the-dir-attribute:attr-th-abbr"><a href="#attr-th-abbr">abbr</a></code> on <code id="the-dir-attribute:the-th-element"><a href="#the-th-element">th</a></code> elements</li><li><code>alt</code> on <code id="the-dir-attribute:attr-area-alt"><a href="#attr-area-alt">area</a></code>,
                                    <code id="the-dir-attribute:attr-img-alt"><a href="#attr-img-alt">img</a></code>, and
                                    <code id="the-dir-attribute:attr-input-alt"><a href="#attr-input-alt">input</a></code> elements</li><li><code id="the-dir-attribute:attr-meta-content"><a href="#attr-meta-content">content</a></code> on <code id="the-dir-attribute:the-meta-element"><a href="#the-meta-element">meta</a></code> elements, if the <code id="the-dir-attribute:attr-meta-name"><a href="#attr-meta-name">name</a></code> attribute specifies a metadata name whose value is primarily intended to be human-readable rather than machine-readable</li><li><code>label</code> on <code id="the-dir-attribute:attr-optgroup-label"><a href="#attr-optgroup-label">optgroup</a></code>,
                                       <code id="the-dir-attribute:attr-option-label"><a href="#attr-option-label">option</a></code>, and
                                       <code id="the-dir-attribute:attr-track-label"><a href="#attr-track-label">track</a></code> elements</li><li><code>placeholder</code> on <code id="the-dir-attribute:attr-input-placeholder"><a href="#attr-input-placeholder">input</a></code> and
                                            <code id="the-dir-attribute:attr-textarea-placeholder"><a href="#attr-textarea-placeholder">textarea</a></code> elements</li><li><code id="the-dir-attribute:attr-title"><a href="#attr-title">title</a></code> on all <a href="#html-elements" id="the-dir-attribute:html-elements-4">HTML elements</a></li></ul>
  </div>

  <hr>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-dir" id="dom-dir-dev">dir</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns <a href="#the-html-element-2" id="the-dir-attribute:the-html-element-2">the <code>html</code> element</a>'s <code id="the-dir-attribute:attr-dir-6"><a href="#attr-dir">dir</a></code>
    attribute's value, if any.</p>

    <p>Can be set, to either "<code>ltr</code>", "<code>rtl</code>", or "<code>auto</code>" to replace <a href="#the-html-element-2" id="the-dir-attribute:the-html-element-2-2">the <code>html</code> element</a>'s <code id="the-dir-attribute:attr-dir-7"><a href="#attr-dir">dir</a></code> attribute's value.</p>

    <p>If there is no <a href="#the-html-element-2" id="the-dir-attribute:the-html-element-2-3"><code>html</code> element</a>, returns the
    empty string and ignores new values.</p>
   </dd></dl>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dir" title="The HTMLElement.dir property gets or sets the text writing directionality of the content of the current element.">HTMLElement/dir</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-dir" data-dfn-type="attribute"><code>dir</code></dfn> IDL attribute on
  an element must <a href="#reflect" id="the-dir-attribute:reflect">reflect</a> the <code id="the-dir-attribute:attr-dir-8"><a href="#attr-dir">dir</a></code> content attribute of
  that element, <a href="#limited-to-only-known-values" id="the-dir-attribute:limited-to-only-known-values">limited to only known values</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/dir" title="The Document.dir property is a string representing the directionality of the text of the document, whether left to right (default) or right to left. Possible values are 'rtl', right to left, and 'ltr', left to right.">Document/dir</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera yes"><span>Opera</span><span>51+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-dir" data-dfn-type="attribute"><code>dir</code></dfn> IDL
  attribute on <code id="the-dir-attribute:document"><a href="#document">Document</a></code> objects must <a href="#reflect" id="the-dir-attribute:reflect-2">reflect</a> the <code id="the-dir-attribute:attr-dir-9"><a href="#attr-dir">dir</a></code> content attribute of <a href="#the-html-element-2" id="the-dir-attribute:the-html-element-2-4">the <code>html</code> element</a>, if
  any, <a href="#limited-to-only-known-values" id="the-dir-attribute:limited-to-only-known-values-2">limited to only known values</a>. If there is no such element, then the attribute
  must return the empty string and do nothing on setting.</p>
  </div>

  

  <p class="note">Authors are strongly encouraged to use the <code id="the-dir-attribute:attr-dir-10"><a href="#attr-dir">dir</a></code>
  attribute to indicate text direction rather than using CSS, since that way their documents will
  continue to render correctly even in the absence of CSS (e.g. as interpreted by search
  engines).</p>

  <div class="example">

   <p>This markup fragment is of an IM conversation.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">auto</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"u1"</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">bdi</c-><c- p="">&gt;</c->Student<c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c->:<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> How do you write "What's your name?" in Arabic?<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">auto</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"u2"</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">bdi</c-><c- p="">&gt;</c->Teacher<c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c->:<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> ما اسمك؟<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">auto</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"u1"</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">bdi</c-><c- p="">&gt;</c->Student<c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c->:<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> Thanks.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">auto</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"u2"</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">bdi</c-><c- p="">&gt;</c->Teacher<c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c->:<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> That's written "شكرًا".<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">auto</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"u2"</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">bdi</c-><c- p="">&gt;</c->Teacher<c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c->:<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> Do you know how to write "Please"?<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">auto</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"u1"</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">bdi</c-><c- p="">&gt;</c->Student<c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c->:<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> "من فضلك", right?<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>



   <p>Given a suitable style sheet and the default alignment styles for the <code id="the-dir-attribute:the-p-element"><a href="#the-p-element">p</a></code> element,
   namely to align the text to the <i>start edge</i> of the paragraph, the resulting rendering could
   be as follows:</p>

   <p><img width="366" src="/images/im.png" height="157" alt="Each paragraph rendered as a separate block, with the paragraphs left-aligned except the second paragraph and the last one, which would be right aligned, with the usernames ('Student' and 'Teacher' in this example) flush right, with a colon to their left, and the text first to the left of that."></p>

   <p>As noted earlier, the <code id="the-dir-attribute:attr-dir-auto"><a href="#attr-dir-auto">auto</a></code> value is not a panacea. The
   final paragraph in this example is misinterpreted as being right-to-left text, since it begins
   with an Arabic character, which causes the "right?" to be to the left of the Arabic text.</p>

  </div>



  <h5 id="the-style-attribute"><span class="secno">3.2.6.5</span> The <code id="the-style-attribute:attr-style"><a href="#attr-style">style</a></code> attribute<a href="#the-style-attribute" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/style" title="The style global attribute contains CSS styling declarations to be applied to the element. Note that it is recommended for styles to be defined in a separate file or files. This attribute and the <style> element have mainly the purpose of allowing for quick styling, for example for testing purposes.">Global_attributes/style</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>All <a href="#html-elements" id="the-style-attribute:html-elements">HTML elements</a> may have the <dfn data-dfn-for="html-global" id="attr-style" data-dfn-type="element-attr"><code>style</code></dfn> content attribute set. This is a <a href="https://drafts.csswg.org/css-style-attr/#style-attribute" id="the-style-attribute:css-styling-attribute" data-x-internal="css-styling-attribute">style attribute</a> as defined by <cite>CSS Style
  Attributes</cite>. <a href="#refsCSSATTR">[CSSATTR]</a></p>

  

  <p>In user agents that support CSS, the attribute's value must be parsed when the attribute is
  added or has its value changed,
  according to the rules given for <a href="https://drafts.csswg.org/css-style-attr/#style-attribute" id="the-style-attribute:css-styling-attribute-2" data-x-internal="css-styling-attribute">style attributes</a>.
  <a href="#refsCSSATTR">[CSSATTR]</a></p>

  <p>However, if the <a id="the-style-attribute:should-element's-inline-behavior-be-blocked-by-content-security-policy" href="https://w3c.github.io/webappsec-csp/#should-block-inline" data-x-internal="should-element's-inline-behavior-be-blocked-by-content-security-policy">Should element's inline behavior be blocked by Content Security
  Policy?</a> algorithm returns "<code>Blocked</code>" when executed upon the
  attribute's <a id="the-style-attribute:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element">element</a>, "<code>style attribute</code>", and the attribute's
  value, then the style rules defined in the attribute's value must not be applied to the
  <a id="the-style-attribute:element-2" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element">element</a>. <a href="#refsCSP">[CSP]</a></p>

  

  <p>Documents that use <code id="the-style-attribute:attr-style-2"><a href="#attr-style">style</a></code> attributes on any of their elements
  must still be comprehensible and usable if those attributes were removed.</p>

  <p class="note">In particular, using the <code id="the-style-attribute:attr-style-3"><a href="#attr-style">style</a></code> attribute to hide
  and show content, or to convey meaning that is otherwise not included in the document, is
  non-conforming. (To hide and show content, use the <code id="the-style-attribute:attr-hidden"><a href="#attr-hidden">hidden</a></code>
  attribute.)</p>

  <hr>

  <dl class="domintro"><dt><code><var>element</var>.<a href="https://drafts.csswg.org/cssom/#dom-elementcssinlinestyle-style" id="dom-style-dev" data-x-internal="dom-style">style</a></code></dt><dd><p>Returns a <code id="the-style-attribute:cssstyledeclaration"><a data-x-internal="cssstyledeclaration" href="https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface">CSSStyleDeclaration</a></code> object for the element's <code id="the-style-attribute:attr-style-4"><a href="#attr-style">style</a></code> attribute.</p></dd></dl>

  

  <p>The <code id="the-style-attribute:dom-style"><a data-x-internal="dom-style" href="https://drafts.csswg.org/cssom/#dom-elementcssinlinestyle-style">style</a></code> IDL attribute is defined in <cite>CSS Object
  Model</cite>. <a href="#refsCSSOM">[CSSOM]</a></p>

  

  <div class="example">

   <p>In the following example, the words that refer to colors are marked up using the
   <code id="the-style-attribute:the-span-element"><a href="#the-span-element">span</a></code> element and the <code id="the-style-attribute:attr-style-5"><a href="#attr-style">style</a></code> attribute to make those
   words show up in the relevant colors in visual media.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My sweat suit is <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">style</c-><c- o="">=</c-><c- s="">"color: green; background:</c->
<c- s="">transparent"</c-><c- p="">&gt;</c->green<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> and my eyes are <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">style</c-><c- o="">=</c-><c- s="">"color: blue;</c->
<c- s="">background: transparent"</c-><c- p="">&gt;</c->blue<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h5 id="embedding-custom-non-visible-data-with-the-data-*-attributes"><span class="secno">3.2.6.6</span> <dfn>Embedding custom non-visible data</dfn> with the <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:attr-data-*"><a href="#attr-data-*">data-*</a></code> attributes<a href="#embedding-custom-non-visible-data-with-the-data-*-attributes" class="self-link"></a></h5>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*" title="The data-* global attributes form a class of attributes called custom data attributes, that allow proprietary information to be exchanged between the HTML and its DOM representation by scripts.">Global_attributes/data-*</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>7+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>A <dfn id="custom-data-attribute">custom data attribute</dfn> is an attribute in no namespace whose name starts with the
  string "<dfn id="attr-data-*"><code>data-</code></dfn>", has at least one character after the
  hyphen, is a <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:valid-attribute-local-name" href="https://dom.spec.whatwg.org/#valid-attribute-local-name" data-x-internal="valid-attribute-local-name">valid attribute local name</a>, and contains no <a href="https://infra.spec.whatwg.org/#ascii-upper-alpha" id="embedding-custom-non-visible-data-with-the-data-*-attributes:uppercase-ascii-letters" data-x-internal="uppercase-ascii-letters">ASCII upper alphas</a>.</p>
  </div>

  <p class="note">All attribute names on <a href="#html-elements" id="embedding-custom-non-visible-data-with-the-data-*-attributes:html-elements">HTML elements</a> in <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>
  get ASCII-lowercased automatically, so the restriction on ASCII uppercase letters doesn't affect
  such documents.</p>

  <p><a href="#custom-data-attribute" id="embedding-custom-non-visible-data-with-the-data-*-attributes:custom-data-attribute">Custom data attributes</a> are intended to store custom
  data, state, annotations, and similar, private to the page or application, for which there are no
  more appropriate attributes or elements.</p>

  <p>These attributes are not intended for use by software that is not known to the administrators
  of the site that uses the attributes. For generic extensions that are to be used by multiple
  independent tools, either this specification should be extended to provide the feature explicitly,
  or a technology like <a href="#microdata" id="embedding-custom-non-visible-data-with-the-data-*-attributes:microdata">microdata</a> should be used (with a standardized vocabulary).</p>

  <div class="example">

   <p>For instance, a site about music could annotate list items representing tracks in an album
   with custom data attributes containing the length of each track. This information could then be
   used by the site itself to allow the user to sort the list by track length, or to filter the list
   for tracks of certain lengths.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">ol</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">data-length</c-><c- o="">=</c-><c- s="">"2m11s"</c-><c- p="">&gt;</c->Beyond The Sea<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 ...
<c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c-></code></pre>

   <p>It would be inappropriate, however, for the user to use generic software not associated with
   that music site to search for tracks of a certain length by looking at this data.</p>

   <p>This is because these attributes are intended for use by the site's own scripts, and are not a
   generic extension mechanism for publicly-usable metadata.</p>

  </div>

  <div class="example">

   <p>Similarly, a page author could write markup that provides information for a translation tool
   that they are intending to use:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The third <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">data-mytrans-de</c-><c- o="">=</c-><c- s="">"Anspruch"</c-><c- p="">&gt;</c->claim<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> covers the case of <c- p="">&lt;</c-><c- f="">span</c->
<c- e="">translate</c-><c- o="">=</c-><c- s="">"no"</c-><c- p="">&gt;</c->HTML<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> markup.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>In this example, the "<code>data-mytrans-de</code>" attribute gives specific text
   for the MyTrans product to use when translating the phrase "claim" to German. However, the
   standard <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:attr-translate"><a href="#attr-translate">translate</a></code> attribute is used to tell it that in all
   languages, "HTML" is to remain unchanged. When a standard attribute is available, there is no
   need for a <a href="#custom-data-attribute" id="embedding-custom-non-visible-data-with-the-data-*-attributes:custom-data-attribute-2">custom data attribute</a> to be used.</p>

  </div>

  <div class="example">

   <p>In this example, custom data attributes are used to store the result of a feature detection
   for <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:paymentrequest"><a data-x-internal="paymentrequest" href="https://w3c.github.io/payment-request/#dom-paymentrequest">PaymentRequest</a></code>, which could be used in CSS to style a checkout page
   differently.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- k="">if</c-> <c- p="">(</c-><c- t="">'PaymentRequest'</c-> <c- k="">in</c-> window<c- p="">)</c-> <c- p="">{</c->
   document<c- p="">.</c->documentElement<c- p="">.</c->dataset<c- p="">.</c->hasPaymentRequest <c- o="">=</c-> <c- t="">''</c-><c- p="">;</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>Here, the <code>data-has-payment-request</code> attribute is effectively being used
   as a <a href="#boolean-attribute" id="embedding-custom-non-visible-data-with-the-data-*-attributes:boolean-attribute">boolean attribute</a>; it is enough to check the presence of the attribute.
   However, if the author so wishes, it could later be populated with some value, maybe to indicate
   limited functionality of the feature.</p>

  </div>

  <p>Every <a href="#html-elements" id="embedding-custom-non-visible-data-with-the-data-*-attributes:html-elements-2">HTML element</a> may have any number of <a href="#custom-data-attribute" id="embedding-custom-non-visible-data-with-the-data-*-attributes:custom-data-attribute-3">custom data attributes</a> specified, with any value.</p>

  <p>Authors should carefully design such extensions so that when the attributes are ignored and any
  associated CSS dropped, the page is still usable.</p>

  

  <p>User agents must not derive any implementation behavior from these attributes or values.
  Specifications intended for user agents must not define these attributes to have any meaningful
  values.</p>

  

  <p>JavaScript libraries may use the <a href="#custom-data-attribute" id="embedding-custom-non-visible-data-with-the-data-*-attributes:custom-data-attribute-4">custom data
  attributes</a>, as they are considered to be part of the page on which they are used. Authors
  of libraries that are reused by many authors are encouraged to include their name in the attribute
  names, to reduce the risk of clashes. Where it makes sense, library authors are also encouraged to
  make the exact name used in the attribute names customizable, so that libraries whose authors
  unknowingly picked the same name can be used on the same page, and so that multiple versions of a
  particular library can be used on the same page even when those versions are not mutually
  compatible.</p>

  <div class="example">

   <p>For example, a library called "DoQuery" could use attribute names like <code>data-doquery-range</code>, and a library called "jJo" could use attributes names like
   <code>data-jjo-range</code>. The jJo library could also provide an API to set which
   prefix to use (e.g. <code>J.setDataPrefix('j2')</code>, making the attributes have names
   like <code>data-j2-range</code>).</p>

  </div>

  <hr>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-dataset" id="dom-dataset-dev">dataset</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset" title="The dataset read-only property of the HTMLElement interface provides read/write access to custom data attributes (data-*) on elements. It exposes a map of strings (DOMStringMap) with an entry for each data-* attribute.">HTMLElement/dataset</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>7+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SVGElement/dataset" title="The dataset read-only property of the HTMLElement interface provides read/write access to custom data attributes (data-*) on elements. It exposes a map of strings (DOMStringMap) with an entry for each data-* attribute.">SVGElement/dataset</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>51+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>55+</span></span><hr><span class="opera yes"><span>Opera</span><span>41+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>41+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap"><a href="#domstringmap">DOMStringMap</a></code> object for the element's <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:attr-data-*-2"><a href="#attr-data-*">data-*</a></code> attributes.</p>

    <p>Hyphenated names become camel-cased. For example, <code>data-foo-bar=""</code>
    becomes <code>element.dataset.fooBar</code>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOrSVGElement" id="dom-dataset" data-dfn-type="attribute"><code>dataset</code></dfn> IDL
  attribute provides convenient accessors for all the <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:attr-data-*-3"><a href="#attr-data-*">data-*</a></code>
  attributes on an element. On getting, the <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:dom-dataset"><a href="#dom-dataset">dataset</a></code> IDL attribute
  must return a <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-2"><a href="#domstringmap">DOMStringMap</a></code> whose associated element is this element.</p>
  </div>

  

  <p>The <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-3"><a href="#domstringmap">DOMStringMap</a></code> interface is used for the <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:dom-dataset-2"><a href="#dom-dataset">dataset</a></code> attribute. Each <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-4"><a href="#domstringmap">DOMStringMap</a></code> has an <dfn id="concept-domstringmap-element">associated element</dfn>.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:legacyoverridebuiltins" href="https://webidl.spec.whatwg.org/#LegacyOverrideBuiltIns" data-x-internal="legacyoverridebuiltins"><c- g="">LegacyOverrideBuiltIns</c-></a>]
<c- b="">interface</c-> <dfn id="domstringmap" data-dfn-type="interface"><c- g="">DOMStringMap</c-></dfn> {
  <a href="#dom-domstringmap-nameditem"><c- b="">getter</c-></a> <c- b="">DOMString</c-> (<c- b="">DOMString</c-> <c- g="">name</c->);
  [<a href="#cereactions" id="embedding-custom-non-visible-data-with-the-data-*-attributes:cereactions"><c- g="">CEReactions</c-></a>] <a href="#dom-domstringmap-setitem"><c- b="">setter</c-></a> <c- b="">undefined</c-> (<c- b="">DOMString</c-> <c- g="">name</c->, <c- b="">DOMString</c-> <c- g="">value</c->);
  [<a href="#cereactions" id="embedding-custom-non-visible-data-with-the-data-*-attributes:cereactions-2"><c- g="">CEReactions</c-></a>] <a href="#dom-domstringmap-removeitem"><c- b="">deleter</c-></a> <c- b="">undefined</c-> (<c- b="">DOMString</c-> <c- g="">name</c->);
};</code></pre>

  

  <div data-algorithm="">
  <p>To <dfn id="concept-domstringmap-pairs">get a <code>DOMStringMap</code>'s name-value
  pairs</dfn>, run the following algorithm:</p>

  <ol><li><p>Let <var>list</var> be an empty list of name-value pairs.</p></li><li><p>For each content attribute on the <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-5"><a href="#domstringmap">DOMStringMap</a></code>'s <a href="#concept-domstringmap-element" id="embedding-custom-non-visible-data-with-the-data-*-attributes:concept-domstringmap-element">associated element</a> whose first five characters are
   the string "<code>data-</code>" and whose remaining characters (if any) do not include
   any <a href="https://infra.spec.whatwg.org/#ascii-upper-alpha" id="embedding-custom-non-visible-data-with-the-data-*-attributes:uppercase-ascii-letters-2" data-x-internal="uppercase-ascii-letters">ASCII upper alphas</a>, in the order that those
   attributes are listed in the element's <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:attribute-list" href="https://dom.spec.whatwg.org/#concept-element-attribute" data-x-internal="attribute-list">attribute list</a>, add a name-value pair to
   <var>list</var> whose name is the attribute's name with the first five characters removed and
   whose value is the attribute's value.</p></li><li><p>For each name in <var>list</var>, for each U+002D HYPHEN-MINUS character (-) in the name
   that is followed by an <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:lowercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-lower-alpha" data-x-internal="lowercase-ascii-letters">ASCII lower alpha</a>, remove the U+002D HYPHEN-MINUS character
   (-) and replace the character that followed it by the same character <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:converted-to-ascii-uppercase" href="https://infra.spec.whatwg.org/#ascii-uppercase" data-x-internal="converted-to-ascii-uppercase">converted to ASCII
   uppercase</a>.</p></li><li><p>Return <var>list</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:supported-property-names" href="https://webidl.spec.whatwg.org/#dfn-supported-property-names" data-x-internal="supported-property-names">supported property names</a> on a <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-6"><a href="#domstringmap">DOMStringMap</a></code> object at any instant
  are the names of each pair returned from <a href="#concept-domstringmap-pairs" id="embedding-custom-non-visible-data-with-the-data-*-attributes:concept-domstringmap-pairs">getting the
  <code>DOMStringMap</code>'s name-value pairs</a> at that instant, in the order returned.</p>
  </div>

  <div data-algorithm="">
  <p id="dom-domstringmap-nameditem">To <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:determine-the-value-of-a-named-property" href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-a-named-property" data-x-internal="determine-the-value-of-a-named-property">determine the value of a named property</a>
  <var>name</var> for a <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-7"><a href="#domstringmap">DOMStringMap</a></code>, return the value component of the name-value pair
  whose name component is <var>name</var> in the list returned from <a href="#concept-domstringmap-pairs" id="embedding-custom-non-visible-data-with-the-data-*-attributes:concept-domstringmap-pairs-2">getting the <code>DOMStringMap</code>'s name-value
  pairs</a>.</p>
  </div>

  <div data-algorithm="">
  <p id="dom-domstringmap-setitem">To <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:set-the-value-of-a-new-named-property" href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-a-new-named-property" data-x-internal="set-the-value-of-a-new-named-property">set the value of a new named property</a> or
  <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:set-the-value-of-an-existing-named-property" href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-an-existing-named-property" data-x-internal="set-the-value-of-an-existing-named-property">set the value of an existing named property</a> for a <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-8"><a href="#domstringmap">DOMStringMap</a></code>, given a
  property name <var>name</var> and a new value <var>value</var>, run the following steps:</p>

  <ol><li><p>If <var>name</var> contains a U+002D HYPHEN-MINUS character (-) followed by an <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:lowercase-ascii-letters-2" href="https://infra.spec.whatwg.org/#ascii-lower-alpha" data-x-internal="lowercase-ascii-letters">ASCII
   lower alpha</a>, then throw a <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>For each <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:uppercase-ascii-letters-3" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a> in <var>name</var>, insert a U+002D HYPHEN-MINUS
   character (-) before the character and replace the character with the same character
   <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>.</p></li><li><p>Insert the string <code>data-</code> at the front of <var>name</var>.</p></li><li><p>If <var>name</var> is not a <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:valid-attribute-local-name-2" href="https://dom.spec.whatwg.org/#valid-attribute-local-name" data-x-internal="valid-attribute-local-name">valid attribute local name</a>, then throw an
   <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:invalidcharactererror" href="https://webidl.spec.whatwg.org/#invalidcharactererror" data-x-internal="invalidcharactererror">"<code>InvalidCharacterError</code>"</a> <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="embedding-custom-non-visible-data-with-the-data-*-attributes:concept-element-attributes-set-value" data-x-internal="concept-element-attributes-set-value">Set an attribute value</a> for the
   <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-9"><a href="#domstringmap">DOMStringMap</a></code>'s <a href="#concept-domstringmap-element" id="embedding-custom-non-visible-data-with-the-data-*-attributes:concept-domstringmap-element-2">associated element</a>
   using <var>name</var> and <var>value</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="dom-domstringmap-removeitem">To <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:delete-an-existing-named-property" href="https://webidl.spec.whatwg.org/#dfn-delete-an-existing-named-property" data-x-internal="delete-an-existing-named-property">delete an existing named property</a>
  <var>name</var> for a <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-10"><a href="#domstringmap">DOMStringMap</a></code>, run the following steps:</p>

  <ol><li><p>For each <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:uppercase-ascii-letters-4" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a> in <var>name</var>, insert a U+002D HYPHEN-MINUS
   character (-) before the character and replace the character with the same character
   <a id="embedding-custom-non-visible-data-with-the-data-*-attributes:converted-to-ascii-lowercase-2" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>.</p></li><li><p>Insert the string <code>data-</code> at the front of <var>name</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-remove" id="embedding-custom-non-visible-data-with-the-data-*-attributes:concept-element-attributes-remove" data-x-internal="concept-element-attributes-remove">Remove an attribute by name</a> given
   <var>name</var> and the <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:domstringmap-11"><a href="#domstringmap">DOMStringMap</a></code>'s <a href="#concept-domstringmap-element" id="embedding-custom-non-visible-data-with-the-data-*-attributes:concept-domstringmap-element-3">associated element</a>.</p></li></ol>
  </div>

  <p class="note">This algorithm will only get invoked by <cite>Web IDL</cite> for names that
  are given by the earlier algorithm for <a href="#concept-domstringmap-pairs" id="embedding-custom-non-visible-data-with-the-data-*-attributes:concept-domstringmap-pairs-3">getting the
  <code>DOMStringMap</code>'s name-value pairs</a>. <a href="#refsWEBIDL">[WEBIDL]</a></p>

  

  <div class="example">

   <p>If a web page wanted an element to represent a space ship, e.g. as part of a game, it would
   have to use the <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:classes"><a href="#classes">class</a></code> attribute along with <code id="embedding-custom-non-visible-data-with-the-data-*-attributes:attr-data-*-4"><a href="#attr-data-*">data-*</a></code> attributes:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"spaceship"</c-> <c- e="">data-ship-id</c-><c- o="">=</c-><c- s="">"92432"</c->
     <c- e="">data-weapons</c-><c- o="">=</c-><c- s="">"laser 2"</c-> <c- e="">data-shields</c-><c- o="">=</c-><c- s="">"50%"</c->
     <c- e="">data-</c-><c- e="">x</c-><c- o="">=</c-><c- s="">"30"</c-> <c- e="">data-y</c-><c- o="">=</c-><c- s="">"10"</c-> <c- e="">data-z</c-><c- o="">=</c-><c- s="">"90"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"fire"</c->
         <c- e="">onclick</c-><c- o="">=</c-><c- s="">"spaceships[this.parentNode.dataset.shipId].fire()"</c-><c- p="">&gt;</c->
  Fire
 <c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

   <p>Notice how the hyphenated attribute name becomes camel-cased in the API.</p>

  </div>

  <div class="example">

   <p>Given the following fragment and elements with similar constructions:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"tower"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"tower5"</c-> <c- e="">data-</c-><c- e="">x</c-><c- o="">=</c-><c- s="">"12"</c-> <c- e="">data-y</c-><c- o="">=</c-><c- s="">"5"</c->
     <c- e="">data-ai</c-><c- o="">=</c-><c- s="">"robotarget"</c-> <c- e="">data-hp</c-><c- o="">=</c-><c- s="">"46"</c-> <c- e="">data-ability</c-><c- o="">=</c-><c- s="">"flames"</c->
     <c- e="">src</c-><c- o="">=</c-><c- s="">"towers/rocket.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Rocket Tower"</c-><c- p="">&gt;</c-></code></pre>

   <p>...one could imagine a function <code>splashDamage()</code> that takes some arguments, the first
   of which is the element to process:</p>

   <pre><code class="js"><c- a="">function</c-> splashDamage<c- p="">(</c->node<c- p="">,</c-> x<c- p="">,</c-> y<c- p="">,</c-> damage<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->node<c- p="">.</c->classList<c- p="">.</c->contains<c- p="">(</c-><c- t="">'tower'</c-><c- p="">)</c-> <c- o="">&amp;&amp;</c-> <c- c1="">// checking the 'class' attribute</c->
      node<c- p="">.</c->dataset<c- p="">.</c->x <c- o="">==</c-> x <c- o="">&amp;&amp;</c-> <c- c1="">// reading the 'data-x' attribute</c->
      node<c- p="">.</c->dataset<c- p="">.</c->y <c- o="">==</c-> y<c- p="">)</c-> <c- p="">{</c-> <c- c1="">// reading the 'data-y' attribute</c->
    <c- a="">var</c-> hp <c- o="">=</c-> parseInt<c- p="">(</c->node<c- p="">.</c->dataset<c- p="">.</c->hp<c- p="">);</c-> <c- c1="">// reading the 'data-hp' attribute</c->
    hp <c- o="">=</c-> hp <c- o="">-</c-> damage<c- p="">;</c->
    <c- k="">if</c-> <c- p="">(</c->hp <c- o="">&lt;</c-> <c- mf="">0</c-><c- p="">)</c-> <c- p="">{</c->
      hp <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
      node<c- p="">.</c->dataset<c- p="">.</c->ai <c- o="">=</c-> <c- t="">'dead'</c-><c- p="">;</c-> <c- c1="">// setting the 'data-ai' attribute</c->
      <c- k="">delete</c-> node<c- p="">.</c->dataset<c- p="">.</c->ability<c- p="">;</c-> <c- c1="">// removing the 'data-ability' attribute</c->
    <c- p="">}</c->
    node<c- p="">.</c->dataset<c- p="">.</c->hp <c- o="">=</c-> hp<c- p="">;</c-> <c- c1="">// setting the 'data-hp' attribute</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

  </div>


  <h4 id="the-innertext-idl-attribute"><span class="secno">3.2.7</span> The <code id="the-innertext-idl-attribute:dom-innertext"><a href="#dom-innertext">innerText</a></code> and <code id="the-innertext-idl-attribute:dom-outertext"><a href="#dom-outertext">outerText</a></code> properties<a href="#the-innertext-idl-attribute" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText" title="The innerText property of the HTMLElement interface represents the rendered text content of a node and its descendants.">HTMLElement/innerText</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>45+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>1+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-innertext" id="dom-innertext-dev">innerText</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the element's text content "as rendered".</p>

    <p>Can be set, to replace the element's children with the given value, but with line breaks
    converted to <code id="the-innertext-idl-attribute:the-br-element"><a href="#the-br-element">br</a></code> elements.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-outertext" id="dom-outertext-dev">outerText</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the element's text content "as rendered".</p>

    <p>Can be set, to replace the element with the given value, but with line breaks converted to
    <code id="the-innertext-idl-attribute:the-br-element-2"><a href="#the-br-element">br</a></code> elements.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn id="get-the-text-steps" data-export="">get the text steps</dfn>, given an <a href="#htmlelement" id="the-innertext-idl-attribute:htmlelement">HTMLElement</a>
  <var>element</var>, are:</p>

  <ol><li>
    <p>If <var>element</var> is not <a href="#being-rendered" id="the-innertext-idl-attribute:being-rendered">being rendered</a> or if the user agent is a non-CSS
    user agent, then return <var>element</var>'s <a id="the-innertext-idl-attribute:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a>.</p>

    <p class="note">This step can produce surprising results, as when the <code id="the-innertext-idl-attribute:dom-innertext-2"><a href="#dom-innertext">innerText</a></code> getter is invoked on an element not <a href="#being-rendered" id="the-innertext-idl-attribute:being-rendered-2">being
    rendered</a>, its text contents are returned, but when accessed on an element that is
    <a href="#being-rendered" id="the-innertext-idl-attribute:being-rendered-3">being rendered</a>, all of its children that are not <a href="#being-rendered" id="the-innertext-idl-attribute:being-rendered-4">being rendered</a> have
    their text contents ignored.</p>
   </li><li><p>Let <var>results</var> be a new empty <a id="the-innertext-idl-attribute:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p>For each child node <var>node</var> of <var>element</var>:</p>

    <ol><li><p>Let <var>current</var> be the <a id="the-innertext-idl-attribute:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> resulting in running the <a href="#rendered-text-collection-steps" id="the-innertext-idl-attribute:rendered-text-collection-steps">rendered
     text collection steps</a> with <var>node</var>. Each item in <var>results</var> will either
     be a <a id="the-innertext-idl-attribute:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> or a positive integer (a <i>required line break count</i>).</p>

     <p class="note">Intuitively, a <i>required line break count</i> item means that a certain
     number of line breaks appear at that point, but they can be collapsed with the line breaks
     induced by adjacent <i>required line break count</i> items, reminiscent to CSS
     margin-collapsing.</p>

     </li><li><p>For each item <var>item</var> in <var>current</var>, append <var>item</var> to
     <var>results</var>.</p></li></ol>
   </li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="the-innertext-idl-attribute:list-remove" data-x-internal="list-remove">Remove</a> any items from <var>results</var> that are the
   empty string.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="the-innertext-idl-attribute:list-remove-2" data-x-internal="list-remove">Remove</a> any runs of consecutive <i>required line break
   count</i> items at the start or end of <var>results</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-replace" id="the-innertext-idl-attribute:list-replace" data-x-internal="list-replace">Replace</a> each remaining run of consecutive <i>required
   line break count</i> items with a string consisting of as many U+000A LF code points as the
   maximum of the values in the <i>required line break count</i> items.</p></li><li><p>Return the concatenation of the string items in <var>results</var>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/outerText" title="The outerText property of the HTMLElement interface returns the same value as HTMLElement.innerText. When used as a setter it replaces the whole current node with the given text (this differs from innerText, which replaces the content inside the current node).">HTMLElement/outerText</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>1.3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>1+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-innertext" data-dfn-type="attribute"><code>innerText</code></dfn> and
  <dfn data-dfn-for="HTMLElement" id="dom-outertext" data-dfn-type="attribute"><code>outerText</code></dfn> getter steps
  are to return the result of running <a href="#get-the-text-steps" id="the-innertext-idl-attribute:get-the-text-steps">get the text steps</a> with <a id="the-innertext-idl-attribute:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="rendered-text-collection-steps">rendered text collection steps</dfn>, given a <a id="the-innertext-idl-attribute:node" href="https://dom.spec.whatwg.org/#interface-node" data-x-internal="node">node</a> <var>node</var>,
  are as follows:</p>

  <ol><li><p>Let <var>items</var> be the result of running the <a href="#rendered-text-collection-steps" id="the-innertext-idl-attribute:rendered-text-collection-steps-2">rendered text collection
   steps</a> with each child node of <var>node</var> in <a id="the-innertext-idl-attribute:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, and then
   concatenating the results to a single <a id="the-innertext-idl-attribute:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>If <var>node</var>'s <a id="the-innertext-idl-attribute:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of <a id="the-innertext-idl-attribute:'visibility'" href="https://drafts.csswg.org/css2/#propdef-visibility" data-x-internal="'visibility'">'visibility'</a> is not
   'visible', then return <var>items</var>.</p></li><li>
    <p>If <var>node</var> is not <a href="#being-rendered" id="the-innertext-idl-attribute:being-rendered-5">being rendered</a>, then return <var>items</var>. For the
    purpose of this step, the following elements must act as described if the
    <a id="the-innertext-idl-attribute:computed-value-2" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of the <a id="the-innertext-idl-attribute:'display'" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property is not 'none':</p>

    <ul><li><p><code id="the-innertext-idl-attribute:the-select-element"><a href="#the-select-element">select</a></code> elements have an associated non-replaced inline <a id="the-innertext-idl-attribute:css-box" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS box</a>
     whose child boxes include only those of <code id="the-innertext-idl-attribute:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> and <code id="the-innertext-idl-attribute:the-option-element"><a href="#the-option-element">option</a></code> element
     descendant nodes;</p></li><li><p><code id="the-innertext-idl-attribute:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> elements have an associated non-replaced block-level <a id="the-innertext-idl-attribute:css-box-2" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS
     box</a> whose child boxes include only those of <code id="the-innertext-idl-attribute:the-option-element-2"><a href="#the-option-element">option</a></code> element descendant
     nodes; and</p></li><li><p><code id="the-innertext-idl-attribute:the-option-element-3"><a href="#the-option-element">option</a></code> elements have an associated non-replaced block-level <a id="the-innertext-idl-attribute:css-box-3" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS
     box</a> whose child boxes are as normal for non-replaced block-level <a href="https://drafts.csswg.org/css-display/#css-box" id="the-innertext-idl-attribute:css-box-4" data-x-internal="css-box">CSS boxes</a>.</p></li></ul>

    <p class="note"><var>items</var> can be non-empty due to 'display:contents'.</p>
   </li><li><p>If <var>node</var> is a <code id="the-innertext-idl-attribute:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, then for each CSS text box produced by
   <var>node</var>, in content order, compute the text of the box after application of the CSS
   <a id="the-innertext-idl-attribute:'white-space'" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> processing rules and <a id="the-innertext-idl-attribute:'text-transform'" href="https://drafts.csswg.org/css-text/#text-transform-property" data-x-internal="'text-transform'">'text-transform'</a> rules, set
   <var>items</var> to the <a id="the-innertext-idl-attribute:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of the resulting strings, and return <var>items</var>.
   The CSS <a id="the-innertext-idl-attribute:'white-space'-2" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> processing rules are slightly modified: collapsible spaces at
   the end of lines are always collapsed, but they are only removed if the line is the last line of
   the block, or it ends with a <code id="the-innertext-idl-attribute:the-br-element-3"><a href="#the-br-element">br</a></code> element. Soft hyphens should be preserved.
   <a href="#refsCSSTEXT">[CSSTEXT]</a></p></li><li><p>If <var>node</var> is a <code id="the-innertext-idl-attribute:the-br-element-4"><a href="#the-br-element">br</a></code> element, then <a href="https://infra.spec.whatwg.org/#list-append" id="the-innertext-idl-attribute:list-append" data-x-internal="list-append">append</a> a string containing a single U+000A LF code point to
   <var>items</var>.</p></li><li><p>If <var>node</var>'s <a id="the-innertext-idl-attribute:computed-value-3" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of <a id="the-innertext-idl-attribute:'display'-2" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> is
   <a id="the-innertext-idl-attribute:'table-cell'" href="https://drafts.csswg.org/css-tables/#table-cell" data-x-internal="'table-cell'">'table-cell'</a>, and <var>node</var>'s <a id="the-innertext-idl-attribute:css-box-5" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS box</a> is not the last
   <a id="the-innertext-idl-attribute:'table-cell'-2" href="https://drafts.csswg.org/css-tables/#table-cell" data-x-internal="'table-cell'">'table-cell'</a> box of its enclosing <a id="the-innertext-idl-attribute:'table-row'" href="https://drafts.csswg.org/css-tables/#table-row" data-x-internal="'table-row'">'table-row'</a> box, then <a href="https://infra.spec.whatwg.org/#list-append" id="the-innertext-idl-attribute:list-append-2" data-x-internal="list-append">append</a> a string containing a single U+0009 TAB code point to
   <var>items</var>.</p></li><li><p>If <var>node</var>'s <a id="the-innertext-idl-attribute:computed-value-4" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of <a id="the-innertext-idl-attribute:'display'-3" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> is
   <a id="the-innertext-idl-attribute:'table-row'-2" href="https://drafts.csswg.org/css-tables/#table-row" data-x-internal="'table-row'">'table-row'</a>, and <var>node</var>'s <a id="the-innertext-idl-attribute:css-box-6" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS box</a> is not the last
   <a id="the-innertext-idl-attribute:'table-row'-3" href="https://drafts.csswg.org/css-tables/#table-row" data-x-internal="'table-row'">'table-row'</a> box of the nearest ancestor <a id="the-innertext-idl-attribute:'table'" href="https://drafts.csswg.org/css-tables/#table" data-x-internal="'table'">'table'</a> box, then <a href="https://infra.spec.whatwg.org/#list-append" id="the-innertext-idl-attribute:list-append-3" data-x-internal="list-append">append</a> a string containing a single U+000A LF code point to
   <var>items</var>.</p></li><li><p>If <var>node</var> is a <code id="the-innertext-idl-attribute:the-p-element"><a href="#the-p-element">p</a></code> element, then <a href="https://infra.spec.whatwg.org/#list-append" id="the-innertext-idl-attribute:list-append-4" data-x-internal="list-append">append</a> 2 (a <i>required line break count</i>) at the beginning and end of
   <var>items</var>.</p></li><li>
    <p>If <var>node</var>'s <a id="the-innertext-idl-attribute:used-value" href="https://drafts.csswg.org/css-cascade/#used-value" data-x-internal="used-value">used value</a> of <a id="the-innertext-idl-attribute:'display'-4" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> is
    <a id="the-innertext-idl-attribute:block-level" href="https://drafts.csswg.org/css-display/#block-level" data-x-internal="block-level">block-level</a> or <a id="the-innertext-idl-attribute:'table-caption'" href="https://drafts.csswg.org/css-tables/#table-caption" data-x-internal="'table-caption'">'table-caption'</a>, then <a href="https://infra.spec.whatwg.org/#list-append" id="the-innertext-idl-attribute:list-append-5" data-x-internal="list-append">append</a> 1 (a <i>required line break count</i>) at the beginning and end of
    <var>items</var>. <a href="#refsCSSDISPLAY">[CSSDISPLAY]</a></p>

    <p class="note">Floats and absolutely-positioned elements fall into this category.</p>
   </li><li><p>Return <var>items</var>.</p></li></ol>
  </div>

  <p class="note">Note that descendant nodes of most replaced elements (e.g., <code id="the-innertext-idl-attribute:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>,
  <code id="the-innertext-idl-attribute:the-input-element"><a href="#the-input-element">input</a></code>, and <code id="the-innertext-idl-attribute:the-video-element"><a href="#the-video-element">video</a></code> — but not <code id="the-innertext-idl-attribute:the-button-element"><a href="#the-button-element">button</a></code>) are not rendered
  by CSS, strictly speaking, and therefore have no <a href="https://drafts.csswg.org/css-display/#css-box" id="the-innertext-idl-attribute:css-box-7" data-x-internal="css-box">CSS boxes</a> for the
  purposes of this algorithm.</p>

  <p class="XXX">This algorithm is amenable to being generalized to work on <a href="https://dom.spec.whatwg.org/#concept-range" id="the-innertext-idl-attribute:concept-range" data-x-internal="concept-range">ranges</a>. Then we can use it as the basis for <code id="the-innertext-idl-attribute:selection"><a data-x-internal="selection" href="https://w3c.github.io/selection-api/#selection-interface">Selection</a></code>'s
  stringifier and maybe expose it directly on <a href="https://dom.spec.whatwg.org/#concept-range" id="the-innertext-idl-attribute:concept-range-2" data-x-internal="concept-range">ranges</a>. See <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=10583">Bugzilla bug 10583</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="set-the-inner-text-steps" data-export="">set the inner text steps</dfn>, given an <a href="#htmlelement" id="the-innertext-idl-attribute:htmlelement-2">HTMLElement</a>
  <var>element</var>, and a string <var>value</var> are:</p>

  <ol><li><p>Let <var>fragment</var> be the <a href="#rendered-text-fragment" id="the-innertext-idl-attribute:rendered-text-fragment">rendered text fragment</a> for <var>value</var>
   given <var>element</var>'s <a id="the-innertext-idl-attribute:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-replace-all" id="the-innertext-idl-attribute:concept-node-replace-all" data-x-internal="concept-node-replace-all">Replace all</a> with <var>fragment</var>
   within <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-innertext-idl-attribute:dom-innertext-3"><a href="#dom-innertext">innerText</a></code> setter steps are to run <a href="#set-the-inner-text-steps" id="the-innertext-idl-attribute:set-the-inner-text-steps">set the inner
  text steps</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-innertext-idl-attribute:dom-outertext-2"><a href="#dom-outertext">outerText</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-innertext-idl-attribute:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s parent is null, then throw a
   <a id="the-innertext-idl-attribute:nomodificationallowederror" href="https://webidl.spec.whatwg.org/#nomodificationallowederror" data-x-internal="nomodificationallowederror">"<code>NoModificationAllowedError</code>"</a> <code id="the-innertext-idl-attribute:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>next</var> be <a id="the-innertext-idl-attribute:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-innertext-idl-attribute:next-sibling" href="https://dom.spec.whatwg.org/#concept-tree-next-sibling" data-x-internal="next-sibling">next sibling</a>.</p></li><li><p>Let <var>previous</var> be <a id="the-innertext-idl-attribute:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-innertext-idl-attribute:previous-sibling" href="https://dom.spec.whatwg.org/#concept-tree-previous-sibling" data-x-internal="previous-sibling">previous sibling</a>.</p></li><li><p>Let <var>fragment</var> be the <a href="#rendered-text-fragment" id="the-innertext-idl-attribute:rendered-text-fragment-2">rendered text fragment</a> for the given value
   given <a id="the-innertext-idl-attribute:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-innertext-idl-attribute:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>fragment</var> has no <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="the-innertext-idl-attribute:concept-tree-child" data-x-internal="concept-tree-child">children</a>, then
   <a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-innertext-idl-attribute:concept-node-append" data-x-internal="concept-node-append">append</a> a new <code id="the-innertext-idl-attribute:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node whose <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="the-innertext-idl-attribute:concept-cd-data" data-x-internal="concept-cd-data">data</a> is the empty string and <a id="the-innertext-idl-attribute:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is
   <a id="the-innertext-idl-attribute:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-innertext-idl-attribute:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> to <var>fragment</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-replace" id="the-innertext-idl-attribute:concept-node-replace" data-x-internal="concept-node-replace">Replace</a> <a id="the-innertext-idl-attribute:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> with
   <var>fragment</var> within <a id="the-innertext-idl-attribute:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s parent.</p></li><li><p>If <var>next</var> is non-null and <var>next</var>'s <a id="the-innertext-idl-attribute:previous-sibling-2" href="https://dom.spec.whatwg.org/#concept-tree-previous-sibling" data-x-internal="previous-sibling">previous sibling</a> is a
   <code id="the-innertext-idl-attribute:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, then <a href="#merge-with-the-next-text-node" id="the-innertext-idl-attribute:merge-with-the-next-text-node">merge with the next text node</a> given <var>next</var>'s
   <a id="the-innertext-idl-attribute:previous-sibling-3" href="https://dom.spec.whatwg.org/#concept-tree-previous-sibling" data-x-internal="previous-sibling">previous sibling</a>.</p></li><li><p>If <var>previous</var> is a <code id="the-innertext-idl-attribute:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, then <a href="#merge-with-the-next-text-node" id="the-innertext-idl-attribute:merge-with-the-next-text-node-2">merge with the next text
   node</a> given <var>previous</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="rendered-text-fragment">rendered text fragment</dfn> for a string <var>input</var> given a
  <code id="the-innertext-idl-attribute:document"><a href="#document">Document</a></code> <var>document</var> is the result of running the following steps:</p>

  <ol><li><p>Let <var>fragment</var> be a new <code id="the-innertext-idl-attribute:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> whose <a id="the-innertext-idl-attribute:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a> is <var>document</var>.</p></li><li><p>Let <var>position</var> be a <a id="the-innertext-idl-attribute:position-variable" href="https://infra.spec.whatwg.org/#string-position-variable" data-x-internal="position-variable">position variable</a> for <var>input</var>,
   initially pointing at the start of <var>input</var>.</p></li><li><p>Let <var>text</var> be the empty string.</p></li><li>
    <p>While <var>position</var> is not past the end of <var>input</var>:</p>

    <ol><li><p><a id="the-innertext-idl-attribute:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are not U+000A LF or U+000D CR from
     <var>input</var> given <var>position</var>, and set <var>text</var> to the result.</p></li><li><p>If <var>text</var> is not the empty string, then <a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-innertext-idl-attribute:concept-node-append-2" data-x-internal="concept-node-append">append</a> a new <code id="the-innertext-idl-attribute:text-5"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node whose <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="the-innertext-idl-attribute:concept-cd-data-2" data-x-internal="concept-cd-data">data</a> is <var>text</var> and <a id="the-innertext-idl-attribute:node-document-6" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is
     <var>document</var> to <var>fragment</var>.</p></li><li>
      <p>While <var>position</var> is not past the end of <var>input</var>, and the code point at
      <var>position</var> is either U+000A LF or U+000D CR:</p>

      <ol><li><p>If the code point at <var>position</var> is U+000D CR and the next code point is
       U+000A LF, then advance <var>position</var> to the next code point in
       <var>input</var>.</p></li><li><p>Advance <var>position</var> to the next code point in <var>input</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-innertext-idl-attribute:concept-node-append-3" data-x-internal="concept-node-append">Append</a> the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-innertext-idl-attribute:create-an-element" data-x-internal="create-an-element">creating an element</a> given <var>document</var>, "<code>br</code>",
       and the <a id="the-innertext-idl-attribute:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a> to <var>fragment</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Return <var>fragment</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="merge-with-the-next-text-node">merge with the next text node</dfn> given a <code id="the-innertext-idl-attribute:text-6"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node <var>node</var>:</p>

  <ol><li><p>Let <var>next</var> be <var>node</var>'s <a id="the-innertext-idl-attribute:next-sibling-2" href="https://dom.spec.whatwg.org/#concept-tree-next-sibling" data-x-internal="next-sibling">next sibling</a>.</p></li><li><p>If <var>next</var> is not a <code id="the-innertext-idl-attribute:text-7"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, then return.</p></li><li><p><a id="the-innertext-idl-attribute:replace-data" href="https://dom.spec.whatwg.org/#concept-cd-replace" data-x-internal="replace-data">Replace data</a> with <var>node</var>, <var>node</var>'s <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="the-innertext-idl-attribute:concept-cd-data-3" data-x-internal="concept-cd-data">data</a>'s <a id="the-innertext-idl-attribute:length" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a>, 0, and <var>next</var>'s <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="the-innertext-idl-attribute:concept-cd-data-4" data-x-internal="concept-cd-data">data</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-remove" id="the-innertext-idl-attribute:concept-node-remove" data-x-internal="concept-node-remove">Remove</a> <var>next</var>.</p></li></ol>
  </div>

  

  <h4 id="requirements-relating-to-the-bidirectional-algorithm"><span class="secno">3.2.8</span> Requirements relating to the bidirectional algorithm<a href="#requirements-relating-to-the-bidirectional-algorithm" class="self-link"></a></h4>

  
  <h5 id="authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters"><span class="secno">3.2.8.1</span> Authoring conformance criteria for bidirectional-algorithm formatting characters<a href="#authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters" class="self-link"></a></h5>
  

  <p><a href="#text-content" id="authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters:text-content">Text content</a> in <a href="#html-elements" id="authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters:html-elements">HTML elements</a> with <code id="authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes in their
  <a href="#concept-html-contents" id="authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters:concept-html-contents">contents</a>, and text in attributes of <a href="#html-elements" id="authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters:html-elements-2">HTML
  elements</a> that allow free-form text, may contain characters in the ranges U+202A to U+202E
  and U+2066 to U+2069 (the bidirectional-algorithm formatting characters). <a href="#refsBIDI">[BIDI]</a></p>

  <p class="note">Authors are encouraged to use the <code id="authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters:attr-dir"><a href="#attr-dir">dir</a></code> attribute, the
  <code id="authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters:the-bdo-element"><a href="#the-bdo-element">bdo</a></code> element, and the <code id="authoring-conformance-criteria-for-bidirectional-algorithm-formatting-characters:the-bdi-element"><a href="#the-bdi-element">bdi</a></code> element, rather than maintaining the
  bidirectional-algorithm formatting characters manually. The bidirectional-algorithm formatting
  characters interact poorly with CSS.</p>


  

  <h5 id="user-agent-conformance-criteria"><span class="secno">3.2.8.2</span> User agent conformance criteria<a href="#user-agent-conformance-criteria" class="self-link"></a></h5>

  <p>User agents must implement the Unicode bidirectional algorithm to determine the proper ordering
  of characters when rendering documents and parts of documents. <a href="#refsBIDI">[BIDI]</a></p>

  <p>The mapping of HTML to the Unicode bidirectional algorithm must be done in one of three ways.
  Either the user agent must implement CSS, including in particular the CSS
  <a id="user-agent-conformance-criteria:'unicode-bidi'" href="https://drafts.csswg.org/css-writing-modes/#unicode-bidi" data-x-internal="'unicode-bidi'">'unicode-bidi'</a>, <a id="user-agent-conformance-criteria:'direction'" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a>, and <a id="user-agent-conformance-criteria:'content'" href="https://drafts.csswg.org/css2/#content%E2%91%A0" data-x-internal="'content'">'content'</a> properties, and
  must have, in its user agent style sheet, the rules using those properties given in this
  specification's <a href="#rendering">rendering</a> section, or, alternatively, the user agent must
  act as if it implemented just the aforementioned properties and had a user agent style sheet that
  included all the aforementioned rules, but without letting style sheets specified in documents
  override them, or, alternatively, the user agent must implement another styling language with
  equivalent semantics. <a href="#refsCSSGC">[CSSGC]</a></p>

  <p id="bidireq">The following elements and attributes have requirements defined by the <a href="#rendering">rendering</a> section that, due to the requirements in this section, are
  requirements on all user agents (not just those that <a href="#renderingUA">support the suggested
  default rendering</a>):</p>

  <ul class="brief"><li><code id="user-agent-conformance-criteria:attr-dir"><a href="#attr-dir">dir</a></code> attribute</li><li><code id="user-agent-conformance-criteria:the-bdi-element"><a href="#the-bdi-element">bdi</a></code> element</li><li><code id="user-agent-conformance-criteria:the-bdo-element"><a href="#the-bdo-element">bdo</a></code> element</li><li><code id="user-agent-conformance-criteria:the-br-element"><a href="#the-br-element">br</a></code> element</li><li><code id="user-agent-conformance-criteria:the-pre-element"><a href="#the-pre-element">pre</a></code> element</li><li><code id="user-agent-conformance-criteria:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element</li><li><code id="user-agent-conformance-criteria:the-wbr-element"><a href="#the-wbr-element">wbr</a></code> element</li></ul>

  

  

  <h4 id="wai-aria"><span class="secno">3.2.9</span> Requirements related to ARIA and to platform accessibility APIs<a href="#wai-aria" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>User agent requirements for implementing Accessibility API semantics on <a href="#html-elements" id="wai-aria:html-elements">HTML
  elements</a> are defined in <cite>HTML Accessibility API Mappings</cite>. In addition to the
  rules there, for a <a href="#custom-element" id="wai-aria:custom-element">custom element</a> <var>element</var>, the default ARIA role semantics
  are determined as follows: <a href="#refsHTMLAAM">[HTMLAAM]</a></p>

  <ol><li><p>Let <var>map</var> be <var>element</var>'s <a href="#internal-content-attribute-map" id="wai-aria:internal-content-attribute-map">internal content attribute
   map</a>.</p></li><li><p>If <var>map</var>["<code>role</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="wai-aria:map-exists" data-x-internal="map-exists">exists</a>,
   then return it.</p></li><li><p>Return no role.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Similarly, for a <a href="#custom-element" id="wai-aria:custom-element-2">custom element</a> <var>element</var>, the default ARIA state and
  property semantics, for a state or property named <var>stateOrProperty</var>, are determined as
  follows:</p>

  <ol><li>
    <p>If <var>element</var>'s <a href="#attached-internals" id="wai-aria:attached-internals">attached internals</a> is non-null:</p>

    <ol><li><p>If <var>element</var>'s <a href="#attached-internals" id="wai-aria:attached-internals-2">attached internals</a>'s <a href="#attr-associated-element" id="wai-aria:attr-associated-element">get the <var>stateOrProperty</var>-associated element</a> exists,
     then return the result of running it.</p></li><li><p>If <var>element</var>'s <a href="#attached-internals" id="wai-aria:attached-internals-3">attached internals</a>'s <a href="#attr-associated-elements" id="wai-aria:attr-associated-elements">get the <var>stateOrProperty</var>-associated elements</a> exists,
     then return the result of running it.</p></li></ol>
    

   </li><li><p>If <var>element</var>'s <a href="#internal-content-attribute-map" id="wai-aria:internal-content-attribute-map-2">internal content attribute
   map</a>[<var>stateOrProperty</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="wai-aria:map-exists-2" data-x-internal="map-exists">exists</a>, then return
   it.</p></li><li><p>Return the default value for <var>stateOrProperty</var>.</p></li></ol>
  </div>

  <p class="note">The "default semantics" referred to here are sometimes also called "native",
  "implicit", or "host language" semantics in <cite>ARIA</cite>. <a href="#refsARIA">[ARIA]</a></p>

  <p class="note">One implication of these definitions is that the default semantics can change over
  time. This allows custom elements the same expressivity as built-in elements; e.g., compare to how
  the default ARIA role semantics of an <code id="wai-aria:the-a-element"><a href="#the-a-element">a</a></code> element change as the <code id="wai-aria:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute is added or removed.</p>

  <p>For an example of this in action, see <a href="#custom-elements-accessibility-example">the
  custom elements section</a>.</p>

  <hr>

  <p>Conformance checker requirements for checking use of ARIA <code id="wai-aria:attr-aria-role"><a href="#attr-aria-role">role</a></code> and <code id="wai-aria:attr-aria-*"><a href="#attr-aria-*">aria-*</a></code> attributes on
  <a href="#html-elements" id="wai-aria:html-elements-2">HTML elements</a> are defined in <cite>ARIA in HTML</cite>. <a href="#refsARIAHTML">[ARIAHTML]</a></p>

  



  <h2 id="semantics"><span class="secno">4</span> The elements of HTML<a href="#semantics" class="self-link"></a></h2>

  <h3 id="the-root-element"><span class="secno">4.1</span> The document element<a href="#the-root-element" class="self-link"></a></h3>

  <h4 id="the-html-element"><span class="secno">4.1.1</span> The <dfn data-dfn-type="element"><code>html</code></dfn> element<a href="#the-html-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html" title="The <html> HTML element represents the root (top-level element) of an HTML document, so it is also referred to as the root element. All other elements must be descendants of this element.">Element/html</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLHtmlElement" title="The HTMLHtmlElement interface serves as the root node for a given HTML document. This object inherits the properties and methods described in the HTMLElement interface.">HTMLHtmlElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-html-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-html-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As document's <a id="the-html-element:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>.</dd><dd>Wherever a subdocument fragment is allowed in a compound document.</dd><dt><a href="#concept-element-content-model" id="the-html-element:concept-element-content-model">Content model</a>:</dt><dd>A <code id="the-html-element:the-head-element"><a href="#the-head-element">head</a></code> element followed by a <code id="the-html-element:the-body-element"><a href="#the-body-element">body</a></code> element.</dd><dt><a href="#concept-element-tag-omission" id="the-html-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>An <code id="the-html-element:the-html-element"><a href="#the-html-element">html</a></code> element's <a href="#syntax-start-tag" id="the-html-element:syntax-start-tag">start tag</a> can be omitted
  if the first thing inside the <code id="the-html-element:the-html-element-2"><a href="#the-html-element">html</a></code> element is not a <a href="#syntax-comments" id="the-html-element:syntax-comments">comment</a>.</dd><dd>An <code id="the-html-element:the-html-element-3"><a href="#the-html-element">html</a></code> element's <a href="#syntax-end-tag" id="the-html-element:syntax-end-tag">end tag</a> can be omitted if
  the <code id="the-html-element:the-html-element-4"><a href="#the-html-element">html</a></code> element is not immediately followed by a <a href="#syntax-comments" id="the-html-element:syntax-comments-2">comment</a>.</dd><dt><a href="#concept-element-attributes" id="the-html-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-html-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-html-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-html">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-html">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-html-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlhtmlelement" data-dfn-type="interface"><c- g="">HTMLHtmlElement</c-></dfn> : <a href="#htmlelement" id="the-html-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-html-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLHtmlElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-html-element:the-html-element-5"><a href="#the-html-element">html</a></code> element <a href="#represents" id="the-html-element:represents">represents</a> the root of an HTML document.</p>

  <p>Authors are encouraged to specify a <code id="the-html-element:attr-lang"><a href="#attr-lang">lang</a></code> attribute on the root
  <code id="the-html-element:the-html-element-6"><a href="#the-html-element">html</a></code> element, giving the document's language. This aids speech synthesis tools to
  determine what pronunciations to use, translation tools to determine what rules to use, and so
  forth.</p>

  <div class="example">

   <p>The <code id="the-html-element:the-html-element-7"><a href="#the-html-element">html</a></code> element in the following example declares that the document's language
   is English.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Swapping Songs<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Swapping Songs<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Tonight I swapped some of the songs I wrote with some friends, who
gave me some of the songs they wrote. I love sharing my music.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></strong></code></pre>

  </div>




  <h3 id="document-metadata"><span class="secno">4.2</span> Document metadata<a href="#document-metadata" class="self-link"></a></h3>

  <h4 id="the-head-element"><span class="secno">4.2.1</span> The <dfn data-dfn-type="element"><code>head</code></dfn> element<a href="#the-head-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head" title="The <head> HTML element contains machine-readable information (metadata) about the document, like its title, scripts, and style sheets.">Element/head</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLHeadElement" title="The HTMLHeadElement interface contains the descriptive information, or metadata, for a document. This object inherits all of the properties and methods described in the HTMLElement interface.">HTMLHeadElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-head-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-head-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As the first element in an <code id="the-head-element:the-html-element"><a href="#the-html-element">html</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-head-element:concept-element-content-model">Content model</a>:</dt><dd>If the document is <a href="#an-iframe-srcdoc-document" id="the-head-element:an-iframe-srcdoc-document">an <code>iframe</code> <code>srcdoc</code> document</a> or if title information is available from a higher-level protocol: Zero or more elements of <a href="#metadata-content-2" id="the-head-element:metadata-content-2">metadata content</a>, of which no more than one is a <code id="the-head-element:the-title-element"><a href="#the-title-element">title</a></code> element and no more than one is a <code id="the-head-element:the-base-element"><a href="#the-base-element">base</a></code> element.</dd><dd>Otherwise: One or more elements of <a href="#metadata-content-2" id="the-head-element:metadata-content-2-2">metadata content</a>, of which exactly one is a <code id="the-head-element:the-title-element-2"><a href="#the-title-element">title</a></code> element and no more than one is a <code id="the-head-element:the-base-element-2"><a href="#the-base-element">base</a></code> element.</dd><dt><a href="#concept-element-tag-omission" id="the-head-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-head-element:the-head-element"><a href="#the-head-element">head</a></code> element's <a href="#syntax-start-tag" id="the-head-element:syntax-start-tag">start tag</a> can be omitted if
  the element is empty, or if the first thing inside the <code id="the-head-element:the-head-element-2"><a href="#the-head-element">head</a></code> element is an
  element.</dd><dd>A <code id="the-head-element:the-head-element-3"><a href="#the-head-element">head</a></code> element's <a href="#syntax-end-tag" id="the-head-element:syntax-end-tag">end tag</a> can be omitted if
  the <code id="the-head-element:the-head-element-4"><a href="#the-head-element">head</a></code> element is not immediately followed by <a id="the-head-element:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> or a
  <a href="#syntax-comments" id="the-head-element:syntax-comments">comment</a>.</dd><dt><a href="#concept-element-attributes" id="the-head-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-head-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-head-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-head">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-head">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-head-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlheadelement" data-dfn-type="interface"><c- g="">HTMLHeadElement</c-></dfn> : <a href="#htmlelement" id="the-head-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-head-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();
};</code></pre>
   </dd></dl>

  <p>The <code id="the-head-element:the-head-element-5"><a href="#the-head-element">head</a></code> element <a href="#represents" id="the-head-element:represents">represents</a> a collection of metadata for the
  <code id="the-head-element:document"><a href="#document">Document</a></code>.</p>

  <div class="example">

   <p>The collection of metadata in a <code id="the-head-element:the-head-element-6"><a href="#the-head-element">head</a></code> element can be large or small. Here is an
   example of a very short one:</p>

   <pre><code class="html"><c- cp="">&lt;!doctype html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->A document with a short head<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 ...</code></pre>

   <p>Here is an example of a longer one:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">HTML</c-> <c- e="">LANG</c-><c- o="">=</c-><c- s="">"EN"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">HEAD</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">META</c-> <c- e="">CHARSET</c-><c- o="">=</c-><c- s="">"UTF-8"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">BASE</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"https://www.example.com/"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">TITLE</c-><c- p="">&gt;</c->An application with a long head<c- p="">&lt;/</c-><c- f="">TITLE</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">LINK</c-> <c- e="">REL</c-><c- o="">=</c-><c- s="">"STYLESHEET"</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"default.css"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">LINK</c-> <c- e="">REL</c-><c- o="">=</c-><c- s="">"STYLESHEET ALTERNATE"</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"big.css"</c-> <c- e="">TITLE</c-><c- o="">=</c-><c- s="">"Big Text"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">SCRIPT</c-> <c- e="">SRC</c-><c- o="">=</c-><c- s="">"support.js"</c-><c- p="">&gt;&lt;/</c-><c- f="">SCRIPT</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">META</c-> <c- e="">NAME</c-><c- o="">=</c-><c- s="">"APPLICATION-NAME"</c-> <c- e="">CONTENT</c-><c- o="">=</c-><c- s="">"Long headed application"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">HEAD</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">BODY</c-><c- p="">&gt;</c->
 ...</code></pre>

  </div>

  <p class="note">The <code id="the-head-element:the-title-element-3"><a href="#the-title-element">title</a></code> element is a required child in most situations, but when a
  higher-level protocol provides title information, e.g., in the subject line of an email when HTML
  is used as an email authoring format, the <code id="the-head-element:the-title-element-4"><a href="#the-title-element">title</a></code> element can be omitted.</p>



  <h4 id="the-title-element"><span class="secno">4.2.2</span> The <dfn data-dfn-type="element"><code>title</code></dfn> element<a href="#the-title-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title" title="The <title> HTML element defines the document's title that is shown in a browser's title bar or a page's tab. It only contains text; tags within the element are ignored.">Element/title</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>1+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTitleElement" title="The HTMLTitleElement interface is implemented by a document's <title>. This element inherits all of the properties and methods of the HTMLElement interface.">HTMLTitleElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-title-element:concept-element-categories">Categories</a>:</dt><dd><a href="#metadata-content-2" id="the-title-element:metadata-content-2">Metadata content</a>.</dd><dt><a href="#concept-element-contexts" id="the-title-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>In a <code id="the-title-element:the-head-element"><a href="#the-head-element">head</a></code> element containing no other <code id="the-title-element:the-title-element"><a href="#the-title-element">title</a></code> elements.</dd><dt><a href="#concept-element-content-model" id="the-title-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#text-content" id="the-title-element:text-content">Text</a> that is not <a href="#inter-element-whitespace" id="the-title-element:inter-element-whitespace">inter-element whitespace</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-title-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-title-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-title-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-title-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-title">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-title">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-title-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltitleelement" data-dfn-type="interface"><c- g="">HTMLTitleElement</c-></dfn> : <a href="#htmlelement" id="the-title-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-title-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-title-element:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-title-text" id="the-title-element:dom-title-text"><c- g="">text</c-></a>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-title-element:the-title-element-2"><a href="#the-title-element">title</a></code> element <a href="#represents" id="the-title-element:represents">represents</a> the document's title or name. Authors
  should use titles that identify their documents even when they are used out of context, for
  example in a user's history or bookmarks, or in search results. The document's title is often
  different from its first heading, since the first heading does not have to stand alone when taken
  out of context.</p>

  <p>There must be no more than one <code id="the-title-element:the-title-element-3"><a href="#the-title-element">title</a></code> element per document.</p>

  <p class="note">If it's reasonable for the <code id="the-title-element:document"><a href="#document">Document</a></code> to have no title, then the
  <code id="the-title-element:the-title-element-4"><a href="#the-title-element">title</a></code> element is probably not required. See the <code id="the-title-element:the-head-element-2"><a href="#the-head-element">head</a></code> element's content
  model for a description of when the element is required.</p>

  <dl class="domintro"><dt><code><var>title</var>.<a href="#dom-title-text" id="dom-title-text-dev">text</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the <a id="the-title-element:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> of the element.</p>

    <p>Can be set, to replace the element's children with the given value.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTitleElement" id="dom-title-text" data-dfn-type="attribute"><code>text</code></dfn>
  attribute's getter must return this <code id="the-title-element:the-title-element-5"><a href="#the-title-element">title</a></code> element's <a id="the-title-element:child-text-content-2" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text
  content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-title-element:dom-title-text-2"><a href="#dom-title-text">text</a></code> attribute's setter must <a id="the-title-element:string-replace-all" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">string replace
  all</a> with the given value within this <code id="the-title-element:the-title-element-6"><a href="#the-title-element">title</a></code> element.</p>
  </div>

  

  <div class="example">

   <p>Here are some examples of appropriate titles, contrasted with the top-level headings that
   might be used on those same pages.</p>

   <pre><code class="html">  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Introduction to The Mating Rituals of Bees<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
    ...
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Introduction<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This companion guide to the highly successful
  <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Introduction to Medieval Bee-Keeping<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-> book is...</code></pre>

   <p>The next page might be a part of the same site. Note how the title describes the subject
   matter unambiguously, while the first heading assumes the reader knows what the context is and
   therefore won't wonder if the dances are Salsa or Waltz:</p>

   <pre><code class="html">  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Dances used during bee mating rituals<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
    ...
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The Dances<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>The string to use as the document's title is given by the <code id="the-title-element:document.title"><a href="#document.title">document.title</a></code> IDL attribute.</p>

  

  <p>User agents should use the document's title when referring to the document in their user
  interface. When the contents of a <code id="the-title-element:the-title-element-7"><a href="#the-title-element">title</a></code> element are used in this way, <a href="#the-directionality" id="the-title-element:the-directionality">the
  directionality</a> of that <code id="the-title-element:the-title-element-8"><a href="#the-title-element">title</a></code> element should be used to set the directionality
  of the document's title in the user interface.</p>

  


  <h4 id="the-base-element"><span class="secno">4.2.3</span> The <dfn data-dfn-type="element"><code>base</code></dfn> element<a href="#the-base-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base" title="The <base> HTML element specifies the base URL to use for all relative URLs in a document. There can be only one <base> element in a document.">Element/base</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLBaseElement" title="The HTMLBaseElement interface contains the base URI for a document. This object inherits all of the properties and methods as described in the HTMLElement interface.">HTMLBaseElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-base-element:concept-element-categories">Categories</a>:</dt><dd><a href="#metadata-content-2" id="the-base-element:metadata-content-2">Metadata content</a>.</dd><dt><a href="#concept-element-contexts" id="the-base-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>In a <code id="the-base-element:the-head-element"><a href="#the-head-element">head</a></code> element containing no other <code id="the-base-element:the-base-element"><a href="#the-base-element">base</a></code> elements.</dd><dt><a href="#concept-element-content-model" id="the-base-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-base-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-base-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-base-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-base-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-base-element:global-attributes">Global attributes</a></dd><dd><code id="the-base-element:attr-base-href"><a href="#attr-base-href">href</a></code> —  <a href="#document-base-url" id="the-base-element:document-base-url">Document base URL</a>
     </dd><dd><code id="the-base-element:attr-base-target"><a href="#attr-base-target">target</a></code> —  Default <a href="#navigable" id="the-base-element:navigable">navigable</a> for <a href="#hyperlink" id="the-base-element:hyperlink">hyperlink</a> <a href="#navigate" id="the-base-element:navigate">navigation</a> and <a href="#form-submission-2" id="the-base-element:form-submission-2">form submission</a>
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-base-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-base">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-base">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-base-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlbaseelement" data-dfn-type="interface"><c- g="">HTMLBaseElement</c-></dfn> : <a href="#htmlelement" id="the-base-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-base-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-base-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-base-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-base-href" id="the-base-element:dom-base-href"><c- g="">href</c-></a>;
  [<a href="#cereactions" id="the-base-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-base-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLBaseElement" id="dom-base-target" data-dfn-type="attribute"><c- g="">target</c-></dfn>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-base-element:the-base-element-2"><a href="#the-base-element">base</a></code> element allows authors to specify the <a href="#document-base-url" id="the-base-element:document-base-url-2">document base URL</a> for
  the purposes of parsing <a href="https://url.spec.whatwg.org/#concept-url" id="the-base-element:url" data-x-internal="url">URLs</a>, and the name of the default
  <a href="#navigable" id="the-base-element:navigable-2">navigable</a> for the purposes of <a href="#following-hyperlinks-2" id="the-base-element:following-hyperlinks-2">following hyperlinks</a>. The element does not
  <a href="#represents" id="the-base-element:represents">represent</a> any content beyond this information.</p>

  <p>There must be no more than one <code id="the-base-element:the-base-element-3"><a href="#the-base-element">base</a></code> element per document.</p>

  <p>A <code id="the-base-element:the-base-element-4"><a href="#the-base-element">base</a></code> element must have either an <code id="the-base-element:attr-base-href-2"><a href="#attr-base-href">href</a></code>
  attribute, a <code id="the-base-element:attr-base-target-2"><a href="#attr-base-target">target</a></code> attribute, or both.</p>

  <p>The <dfn data-dfn-for="base" id="attr-base-href" data-dfn-type="element-attr"><code>href</code></dfn> content
  attribute, if specified, must contain a <a href="#valid-url-potentially-surrounded-by-spaces" id="the-base-element:valid-url-potentially-surrounded-by-spaces">valid URL potentially surrounded by
  spaces</a>.</p>

  <p>A <code id="the-base-element:the-base-element-5"><a href="#the-base-element">base</a></code> element, if it has an <code id="the-base-element:attr-base-href-3"><a href="#attr-base-href">href</a></code> attribute,
  must come before any other elements in the tree that have attributes defined as taking <a href="https://url.spec.whatwg.org/#concept-url" id="the-base-element:url-2" data-x-internal="url">URLs</a>.</p>

  

  <p class="note">If there are multiple <code id="the-base-element:the-base-element-6"><a href="#the-base-element">base</a></code> elements with <code id="the-base-element:attr-base-href-4"><a href="#attr-base-href">href</a></code> attributes, all but the first are ignored.</p>

  

  <p>The <dfn data-dfn-for="base" id="attr-base-target" data-dfn-type="element-attr"><code>target</code></dfn> attribute,
  if specified, must contain a <a href="#valid-navigable-target-name-or-keyword" id="the-base-element:valid-navigable-target-name-or-keyword">valid navigable target name or keyword</a>, which specifies
  which <a href="#navigable" id="the-base-element:navigable-3">navigable</a> is to be used as the default when <a href="#hyperlink" id="the-base-element:hyperlink-2">hyperlinks</a> and <a href="#the-form-element" id="the-base-element:the-form-element">forms</a> in the
  <code id="the-base-element:document"><a href="#document">Document</a></code> cause <a href="#navigate" id="the-base-element:navigate-2">navigation</a>.</p>

  <p>A <code id="the-base-element:the-base-element-7"><a href="#the-base-element">base</a></code> element, if it has a <code id="the-base-element:attr-base-target-3"><a href="#attr-base-target">target</a></code>
  attribute, must come before any elements in the tree that represent <a href="#hyperlink" id="the-base-element:hyperlink-3">hyperlinks</a>.</p>

  

  <p class="note">If there are multiple <code id="the-base-element:the-base-element-8"><a href="#the-base-element">base</a></code> elements with <code id="the-base-element:attr-base-target-4"><a href="#attr-base-target">target</a></code> attributes, all but the first are ignored.</p>

  <div data-algorithm="">
  <p>To <dfn id="get-an-element's-target">get an element's target</dfn>, given an <code id="the-base-element:the-a-element"><a href="#the-a-element">a</a></code>, <code id="the-base-element:the-area-element"><a href="#the-area-element">area</a></code>, or
  <code id="the-base-element:the-form-element-2"><a href="#the-form-element">form</a></code> element <var>element</var>, and an optional string-or-null <var>target</var>
  (default null), run these steps:

  </p><ol><li>
    <p>If <var>target</var> is null, then:</p>

    <ol><li><p>If <var>element</var> has a <code>target</code> attribute, then set
     <var>target</var> to that attribute's value.</p></li><li><p>Otherwise, if <var>element</var>'s <a id="the-base-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> contains a
     <code id="the-base-element:the-base-element-9"><a href="#the-base-element">base</a></code> element with a <code id="the-base-element:attr-base-target-5"><a href="#attr-base-target">target</a></code> attribute, set
     <var>target</var> to the value of the <code id="the-base-element:attr-base-target-6"><a href="#attr-base-target">target</a></code> attribute
     of the first such <code id="the-base-element:the-base-element-10"><a href="#the-base-element">base</a></code> element.</p></li></ol>
   </li><li><p>If <var>target</var> is not null, and contains an <a id="the-base-element:ascii-tab-or-newline" href="https://infra.spec.whatwg.org/#ascii-tab-or-newline" data-x-internal="ascii-tab-or-newline">ASCII tab or newline</a> and a
   U+003C (&lt;), then set <var>target</var> to "<code>_blank</code>".</p></li><li><p>Return <var>target</var>.</p></li></ol>
  </div>

  <hr>

  <p>A <code id="the-base-element:the-base-element-11"><a href="#the-base-element">base</a></code> element that is the first <code id="the-base-element:the-base-element-12"><a href="#the-base-element">base</a></code> element with an <code id="the-base-element:attr-base-href-5"><a href="#attr-base-href">href</a></code> content attribute <a id="the-base-element:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a> has a
  <dfn id="frozen-base-url">frozen base URL</dfn>. The <a href="#frozen-base-url" id="the-base-element:frozen-base-url">frozen base URL</a> must be <a href="#immediately" id="the-base-element:immediately">immediately</a>
  <a href="#set-the-frozen-base-url" id="the-base-element:set-the-frozen-base-url">set</a> for an element whenever any of the following
  situations occur:</p>

  <ul><li><p>The <code id="the-base-element:the-base-element-13"><a href="#the-base-element">base</a></code> element becomes the first <code id="the-base-element:the-base-element-14"><a href="#the-base-element">base</a></code> element in <a id="the-base-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
   order</a> with an <code id="the-base-element:attr-base-href-6"><a href="#attr-base-href">href</a></code> content attribute in its
   <code id="the-base-element:document-2"><a href="#document">Document</a></code>.</p></li><li><p>The <code id="the-base-element:the-base-element-15"><a href="#the-base-element">base</a></code> element is the first <code id="the-base-element:the-base-element-16"><a href="#the-base-element">base</a></code> element in <a id="the-base-element:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
   order</a> with an <code id="the-base-element:attr-base-href-7"><a href="#attr-base-href">href</a></code> content attribute in its
   <code id="the-base-element:document-3"><a href="#document">Document</a></code>, and its <code id="the-base-element:attr-base-href-8"><a href="#attr-base-href">href</a></code> content attribute is
   changed.</p></li></ul>

  <div data-algorithm="">
  <p>To <dfn id="set-the-frozen-base-url" data-export="">set the frozen base URL</dfn> for an element <var>element</var>:</p>

  <ol><li><p>Let <var>document</var> be <var>element</var>'s <a id="the-base-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.

   </p></li><li><p>Let <var>urlRecord</var> be the result of <a href="https://url.spec.whatwg.org/#concept-url-parser" id="the-base-element:url-parser" data-x-internal="url-parser">parsing</a> the
   value of <var>element</var>'s <code id="the-base-element:attr-base-href-9"><a href="#attr-base-href">href</a></code> content attribute with
   <var>document</var>'s <a href="#fallback-base-url" id="the-base-element:fallback-base-url">fallback base URL</a>, and <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="the-base-element:document's-character-encoding" data-x-internal="document's-character-encoding">character encoding</a>. (Thus, the <code id="the-base-element:the-base-element-17"><a href="#the-base-element">base</a></code>
   element isn't affected by itself.)</p></li><li>
    <p>If any of the following are true:</p>

    <ul><li><p><var>urlRecord</var> is failure;</p></li><li><p><var>urlRecord</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="the-base-element:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is "<code>data</code>" or "<code>javascript</code>"; or</p></li><li><p>running <a id="the-base-element:is-base-allowed-for-document" href="https://w3c.github.io/webappsec-csp/#allow-base-for-document" data-x-internal="is-base-allowed-for-document">Is base allowed for Document?</a> on <var>urlRecord</var> and
     <var>document</var> returns "<code>Blocked</code>",</p></li></ul>

    <p>then set <var>element</var>'s <a href="#frozen-base-url" id="the-base-element:frozen-base-url-2">frozen base URL</a> to <var>document</var>'s
    <a href="#fallback-base-url" id="the-base-element:fallback-base-url-2">fallback base URL</a> and return.</p>
   </li><li><p>Set <var>element</var>'s <a href="#frozen-base-url" id="the-base-element:frozen-base-url-3">frozen base URL</a> to <var>urlRecord</var>.</p></li><li><p><a href="#respond-to-base-url-changes" id="the-base-element:respond-to-base-url-changes">Respond to base URL changes</a> given <var>document</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLBaseElement" id="dom-base-href" data-dfn-type="attribute"><code>href</code></dfn> IDL
  attribute, on getting, must return the result of running the following algorithm:
  

  </p><ol><li><p>Let <var>document</var> be <var>element</var>'s <a id="the-base-element:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.

   </p></li><li><p>Let <var>url</var> be the value of the <code id="the-base-element:attr-base-href-10"><a href="#attr-base-href">href</a></code>
   attribute of this element, if it has one, and the empty string otherwise.</p></li><li><p>Let <var>urlRecord</var> be the result of <a href="https://url.spec.whatwg.org/#concept-url-parser" id="the-base-element:url-parser-2" data-x-internal="url-parser">parsing</a>
   <var>url</var> with <var>document</var>'s <a href="#fallback-base-url" id="the-base-element:fallback-base-url-3">fallback base URL</a>, and
   <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="the-base-element:document's-character-encoding-2" data-x-internal="document's-character-encoding">character encoding</a>.
   (Thus, the <code id="the-base-element:the-base-element-18"><a href="#the-base-element">base</a></code> element isn't affected by other <code id="the-base-element:the-base-element-19"><a href="#the-base-element">base</a></code> elements or
   itself.)</p></li><li><p>If <var>urlRecord</var> is failure, return <var>url</var>.</p></li><li><p>Return the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-base-element:concept-url-serializer" data-x-internal="concept-url-serializer">serialization</a> of
   <var>urlRecord</var>.</p></li></ol>
  </div>

  

  <div class="example">

   <p>In this example, a <code id="the-base-element:the-base-element-20"><a href="#the-base-element">base</a></code> element is used to set the <a href="#document-base-url" id="the-base-element:document-base-url-3">document base
   URL</a>:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->This is an example for the <c- ni="">&amp;lt;</c->base<c- ni="">&amp;gt;</c-> element<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">base</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://www.example.com/news/index.html"</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Visit the <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"archives.html"</c-><c- p="">&gt;</c->archives<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>The link in the above example would be a link to "<code>https://www.example.com/news/archives.html</code>".</p>

  </div>




  <h4 id="the-link-element"><span class="secno">4.2.4</span> The <dfn data-dfn-type="element"><code>link</code></dfn> element<a href="#the-link-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link" title="The <link> HTML element specifies relationships between the current document and an external resource. This element is most commonly used to link to stylesheets, but is also used to establish site icons (both &quot;favicon&quot; style icons and icons for the home screen and apps on mobile devices) among other things.">Element/link</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement" title="The HTMLLinkElement interface represents reference information for external resources and the relationship of those resources to a document and vice versa (corresponds to <link> element; not to be confused with <a>, which is represented by HTMLAnchorElement). This object inherits all of the properties and methods of the HTMLElement interface.">HTMLLinkElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/rel" title="The HTMLLinkElement.rel property reflects the rel attribute. It is a string containing a space-separated list of link types indicating the relationship between the resource represented by the <link> element and the current document.">HTMLLinkElement/rel</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/relList" title="The HTMLLinkElement.relList read-only property reflects the rel attribute. It is a live DOMTokenList containing the set of link types indicating the relationship between the resource represented by the <link> element and the current document.">HTMLLinkElement/relList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>30+</span></span><span class="safari yes"><span>Safari</span><span>9+</span></span><span class="chrome yes"><span>Chrome</span><span>50+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-link-element:concept-element-categories">Categories</a>:</dt><dd><a href="#metadata-content-2" id="the-link-element:metadata-content-2">Metadata content</a>.</dd><dd>If the element is <a href="#allowed-in-the-body" id="the-link-element:allowed-in-the-body">allowed in the body</a>: <a href="#flow-content-2" id="the-link-element:flow-content-2">flow content</a>.</dd><dd>If the element is <a href="#allowed-in-the-body" id="the-link-element:allowed-in-the-body-2">allowed in the body</a>: <a href="#phrasing-content-2" id="the-link-element:phrasing-content-2">phrasing content</a>.</dd><dt><a href="#concept-element-contexts" id="the-link-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#metadata-content-2" id="the-link-element:metadata-content-2-2">metadata content</a> is expected.</dd><dd>In a <code id="the-link-element:the-noscript-element"><a href="#the-noscript-element">noscript</a></code> element that is a child of a <code id="the-link-element:the-head-element"><a href="#the-head-element">head</a></code> element.</dd><dd>If the element is <a href="#allowed-in-the-body" id="the-link-element:allowed-in-the-body-3">allowed in the body</a>: where <a href="#phrasing-content-2" id="the-link-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-link-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-link-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-link-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-link-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-link-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-link-element:global-attributes">Global attributes</a></dd><dd><code id="the-link-element:attr-link-href"><a href="#attr-link-href">href</a></code> —  Address of the <a href="#hyperlink" id="the-link-element:hyperlink">hyperlink</a>
     </dd><dd><code id="the-link-element:attr-link-crossorigin"><a href="#attr-link-crossorigin">crossorigin</a></code> —  How the element handles crossorigin requests
     </dd><dd><code id="the-link-element:attr-link-rel"><a href="#attr-link-rel">rel</a></code> —  Relationship between the document containing the <a href="#hyperlink" id="the-link-element:hyperlink-2">hyperlink</a> and the destination resource
     </dd><dd><code id="the-link-element:attr-link-media"><a href="#attr-link-media">media</a></code> —  Applicable media
     </dd><dd><code id="the-link-element:attr-link-integrity"><a href="#attr-link-integrity">integrity</a></code> —  Integrity metadata used in <cite>Subresource Integrity</cite> checks <a href="#refsSRI">[SRI]</a>
     </dd><dd><code id="the-link-element:attr-link-hreflang"><a href="#attr-link-hreflang">hreflang</a></code> —  Language of the linked resource
     </dd><dd><code id="the-link-element:attr-link-type"><a href="#attr-link-type">type</a></code> —  Hint for the type of the referenced resource
     </dd><dd><code id="the-link-element:attr-link-referrerpolicy"><a href="#attr-link-referrerpolicy">referrerpolicy</a></code> —  <a id="the-link-element:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">Referrer policy</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-link-element:concept-fetch" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </dd><dd><code id="the-link-element:attr-link-sizes"><a href="#attr-link-sizes">sizes</a></code> —  Sizes of the icons (for <code id="the-link-element:attr-link-rel-2"><a href="#attr-link-rel">rel</a></code>="<code id="the-link-element:rel-icon"><a href="#rel-icon">icon</a></code>")
     </dd><dd><code id="the-link-element:attr-link-imagesrcset"><a href="#attr-link-imagesrcset">imagesrcset</a></code> —  Images to use in different situations, e.g., high-resolution displays, small monitors, etc. (for <code id="the-link-element:attr-link-rel-3"><a href="#attr-link-rel">rel</a></code>="<code id="the-link-element:link-type-preload"><a href="#link-type-preload">preload</a></code>")
     </dd><dd><code id="the-link-element:attr-link-imagesizes"><a href="#attr-link-imagesizes">imagesizes</a></code> —  Image sizes for different page layouts (for <code id="the-link-element:attr-link-rel-4"><a href="#attr-link-rel">rel</a></code>="<code id="the-link-element:link-type-preload-2"><a href="#link-type-preload">preload</a></code>")
     </dd><dd><code id="the-link-element:attr-link-as"><a href="#attr-link-as">as</a></code> —  <a href="https://fetch.spec.whatwg.org/#concept-potential-destination" id="the-link-element:concept-potential-destination" data-x-internal="concept-potential-destination">Potential destination</a> for a preload request (for <code id="the-link-element:attr-link-rel-5"><a href="#attr-link-rel">rel</a></code>="<code id="the-link-element:link-type-preload-3"><a href="#link-type-preload">preload</a></code>" and <code id="the-link-element:attr-link-rel-6"><a href="#attr-link-rel">rel</a></code>="<code id="the-link-element:link-type-modulepreload"><a href="#link-type-modulepreload">modulepreload</a></code>")
     </dd><dd><code id="the-link-element:attr-link-blocking"><a href="#attr-link-blocking">blocking</a></code> —  Whether the element is <a href="#potentially-render-blocking" id="the-link-element:potentially-render-blocking">potentially render-blocking</a>
     </dd><dd><code id="the-link-element:attr-link-color"><a href="#attr-link-color">color</a></code> —  Color to use when customizing a site's icon (for <code id="the-link-element:attr-link-rel-7"><a href="#attr-link-rel">rel</a></code>="<code>mask-icon</code>")
     </dd><dd><code id="the-link-element:attr-link-disabled"><a href="#attr-link-disabled">disabled</a></code> —  Whether the link is disabled
     </dd><dd><code id="the-link-element:attr-link-fetchpriority"><a href="#attr-link-fetchpriority">fetchpriority</a></code> —  Sets the <a href="https://fetch.spec.whatwg.org/#request-priority" id="the-link-element:concept-request-priority" data-x-internal="concept-request-priority">priority</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-link-element:concept-fetch-2" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </dd><dd>Also, the <code id="the-link-element:attr-link-title"><a href="#attr-link-title">title</a></code> attribute <a href="#attr-link-title" id="the-link-element:attr-link-title-2">has special semantics</a> on this element:  Title of the link;  <a id="the-link-element:css-style-sheet-set-name" href="https://drafts.csswg.org/cssom/#css-style-sheet-set-name" data-x-internal="css-style-sheet-set-name">CSS style sheet set name</a>
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-link-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-link">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-link">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-link-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmllinkelement" data-dfn-type="interface"><c- g="">HTMLLinkElement</c-></dfn> : <a href="#htmlelement" id="the-link-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-link-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-link-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-link-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-href" data-dfn-type="attribute"><c- g="">href</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-link-crossorigin" id="the-link-element:dom-link-crossorigin"><c- g="">crossOrigin</c-></a>;
  [<a href="#cereactions" id="the-link-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-rel" data-dfn-type="attribute"><c- g="">rel</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-link-as" id="the-link-element:dom-link-as"><c- g="">as</c-></a>;
  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-link-element:dom-domtokenlist-value" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-2">Reflect</a>="<a href="#attr-link-rel" id="the-link-element:attr-link-rel-8">rel</a>"] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-link-element:domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-rellist" data-dfn-type="attribute"><c- g="">relList</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-media" data-dfn-type="attribute"><c- g="">media</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-integrity" data-dfn-type="attribute"><c- g="">integrity</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-hreflang" data-dfn-type="attribute"><c- g="">hreflang</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;
  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-link-element:dom-domtokenlist-value-2" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-7"><c- g="">Reflect</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-link-element:domtokenlist-2" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-sizes" data-dfn-type="attribute"><c- g="">sizes</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-9"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-8"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-imagesrcset" data-dfn-type="attribute"><c- g="">imageSrcset</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-10"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-9"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-imagesizes" data-dfn-type="attribute"><c- g="">imageSizes</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-11"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-link-referrerpolicy" id="the-link-element:dom-link-referrerpolicy"><c- g="">referrerPolicy</c-></a>;
  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-link-element:dom-domtokenlist-value-3" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-10"><c- g="">Reflect</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-link-element:domtokenlist-3" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-blocking" data-dfn-type="attribute"><c- g="">blocking</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-12"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-link-element:xattr-reflect-11"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-disabled" data-dfn-type="attribute"><c- g="">disabled</c-></dfn>;
  [<a href="#cereactions" id="the-link-element:cereactions-13"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-link-fetchpriority" id="the-link-element:dom-link-fetchpriority"><c- g="">fetchPriority</c-></a>;

  // <a href="#HTMLLinkElement-partial">also has obsolete members</a>
};
<a href="#htmllinkelement" id="the-link-element:htmllinkelement"><c- n="">HTMLLinkElement</c-></a> <c- b="">includes</c-> <a id="the-link-element:linkstyle" href="https://drafts.csswg.org/cssom/#the-linkstyle-interface" data-x-internal="linkstyle"><c- n="">LinkStyle</c-></a>;</code></pre>
   </dd></dl>

  <p>The <code id="the-link-element:the-link-element"><a href="#the-link-element">link</a></code> element allows authors to link their document to other resources.</p>

  <p>The address of the link(s) is given by the <dfn data-dfn-for="link" id="attr-link-href" data-dfn-type="element-attr"><code>href</code></dfn> attribute. If the <code id="the-link-element:attr-link-href-2"><a href="#attr-link-href">href</a></code> attribute is present, then its value must be a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="the-link-element:valid-non-empty-url-potentially-surrounded-by-spaces">valid
  non-empty URL potentially surrounded by spaces</a>. One or both of the <code id="the-link-element:attr-link-href-3"><a href="#attr-link-href">href</a></code> or <code id="the-link-element:attr-link-imagesrcset-2"><a href="#attr-link-imagesrcset">imagesrcset</a></code>
  attributes must be present.</p>

  <p>If both the <code id="the-link-element:attr-link-href-4"><a href="#attr-link-href">href</a></code> and <code id="the-link-element:attr-link-imagesrcset-3"><a href="#attr-link-imagesrcset">imagesrcset</a></code> attributes are absent, then the element does not
  define a link.</p>

  <p>The types of link indicated (the relationships) are given by the value of the <dfn data-dfn-for="link" id="attr-link-rel" data-dfn-type="element-attr"><code>rel</code></dfn> attribute, which, if present, must have a
  value that is a <a href="#unordered-set-of-unique-space-separated-tokens" id="the-link-element:unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</a>. The <a href="#linkTypes">allowed keywords and their meanings</a> are defined in a later section. If the <code id="the-link-element:attr-link-rel-9"><a href="#attr-link-rel">rel</a></code> attribute is absent, has no keywords, or if
  none of the keywords used are allowed according to the definitions in this specification, then the
  element does not create any links.</p>

  

  <p><code id="the-link-element:attr-link-rel-10"><a href="#attr-link-rel">rel</a></code>'s
  <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="the-link-element:concept-supported-tokens" data-x-internal="concept-supported-tokens">supported tokens</a> are the keywords defined in
  <a href="#linkTypes">HTML link types</a> which are allowed on <code id="the-link-element:the-link-element-2"><a href="#the-link-element">link</a></code> elements, impact
  the processing model, and are supported by the user agent. The possible <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="the-link-element:concept-supported-tokens-2" data-x-internal="concept-supported-tokens">supported tokens</a> are
  <code id="the-link-element:rel-alternate"><a href="#rel-alternate">alternate</a></code>,
  <code id="the-link-element:link-type-dns-prefetch"><a href="#link-type-dns-prefetch">dns-prefetch</a></code>,
  <code id="the-link-element:link-type-expect"><a href="#link-type-expect">expect</a></code>,
  <code id="the-link-element:rel-icon-2"><a href="#rel-icon">icon</a></code>,
  <code id="the-link-element:link-type-manifest"><a href="#link-type-manifest">manifest</a></code>,
  <code id="the-link-element:link-type-modulepreload-2"><a href="#link-type-modulepreload">modulepreload</a></code>,
  <code id="the-link-element:link-type-next"><a href="#link-type-next">next</a></code>,
  <code id="the-link-element:link-type-pingback"><a href="#link-type-pingback">pingback</a></code>,
  <code id="the-link-element:link-type-preconnect"><a href="#link-type-preconnect">preconnect</a></code>,
  <code id="the-link-element:link-type-prefetch"><a href="#link-type-prefetch">prefetch</a></code>,
  <code id="the-link-element:link-type-preload-4"><a href="#link-type-preload">preload</a></code>,
  <code id="the-link-element:link-type-search"><a href="#link-type-search">search</a></code>, and
  <code id="the-link-element:link-type-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code>.
  <code id="the-link-element:attr-link-rel-11"><a href="#attr-link-rel">rel</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="the-link-element:concept-supported-tokens-3" data-x-internal="concept-supported-tokens">supported
  tokens</a> must only include the tokens from this list that the user agent implements the
  processing model for.</p>

  <p class="note">Theoretically a user agent could support the processing model for the <code id="the-link-element:link-type-canonical"><a href="#link-type-canonical">canonical</a></code> keyword — if it were a search engine that executed
  JavaScript. But in practice that's quite unlikely. So in most cases, <code id="the-link-element:link-type-canonical-2"><a href="#link-type-canonical">canonical</a></code> ought not be included in <code id="the-link-element:attr-link-rel-12"><a href="#attr-link-rel">rel</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="the-link-element:concept-supported-tokens-4" data-x-internal="concept-supported-tokens">supported
  tokens</a>.</p>

  

  <p>A <code id="the-link-element:the-link-element-3"><a href="#the-link-element">link</a></code> element must have either a <code id="the-link-element:attr-link-rel-13"><a href="#attr-link-rel">rel</a></code>
  attribute or an <code id="the-link-element:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute, but not both.</p>

  <div data-algorithm="">
  <p>If a <code id="the-link-element:the-link-element-4"><a href="#the-link-element">link</a></code> element has an <code id="the-link-element:names:-the-itemprop-attribute-2"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute,
  or has a <code id="the-link-element:attr-link-rel-14"><a href="#attr-link-rel">rel</a></code> attribute that contains only keywords that are
  <a href="#body-ok" id="the-link-element:body-ok">body-ok</a>, then the element is said to be <dfn id="allowed-in-the-body">allowed in the body</dfn>. This means
  that the element can be used where <a href="#phrasing-content-2" id="the-link-element:phrasing-content-2-3">phrasing content</a> is expected.</p>
  </div>

  <p class="note">If the <code id="the-link-element:attr-link-rel-15"><a href="#attr-link-rel">rel</a></code> attribute is used, the element can
  only sometimes be used in the <code id="the-link-element:the-body-element"><a href="#the-body-element">body</a></code> of the page. When used with the <code id="the-link-element:names:-the-itemprop-attribute-3"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute, the element can be used both in the
  <code id="the-link-element:the-head-element-2"><a href="#the-head-element">head</a></code> element and in the <code id="the-link-element:the-body-element-2"><a href="#the-body-element">body</a></code> of the page, subject to the constraints of
  the microdata model.</p>

  <hr>

  <p>Two categories of links can be created using the <code id="the-link-element:the-link-element-5"><a href="#the-link-element">link</a></code> element: <a href="#external-resource-link" id="the-link-element:external-resource-link">links to external resources</a> and <a href="#hyperlink" id="the-link-element:hyperlink-3">hyperlinks</a>. The <a href="#linkTypes">link types section</a> defines
  whether a particular link type is an external resource or a hyperlink. One <code id="the-link-element:the-link-element-6"><a href="#the-link-element">link</a></code>
  element can create multiple links (of which some might be <a href="#external-resource-link" id="the-link-element:external-resource-link-2">external resource links</a> and some might be <a href="#hyperlink" id="the-link-element:hyperlink-4">hyperlinks</a>); exactly which and how many links are created depends on the
  keywords given in the <code id="the-link-element:attr-link-rel-16"><a href="#attr-link-rel">rel</a></code> attribute. User agents must process
  the links on a per-link basis, not a per-element basis.</p>

  <p class="note">Each link created for a <code id="the-link-element:the-link-element-7"><a href="#the-link-element">link</a></code> element is handled separately. For
  instance, if there are two <code id="the-link-element:the-link-element-8"><a href="#the-link-element">link</a></code> elements with <code>rel="stylesheet"</code>,
  they each count as a separate external resource, and each is affected by its own attributes
  independently. Similarly, if a single <code id="the-link-element:the-link-element-9"><a href="#the-link-element">link</a></code> element has a <code id="the-link-element:attr-link-rel-17"><a href="#attr-link-rel">rel</a></code> attribute with the value <code>next stylesheet</code>,
  it creates both a <a href="#hyperlink" id="the-link-element:hyperlink-5">hyperlink</a> (for the <code id="the-link-element:link-type-next-2"><a href="#link-type-next">next</a></code> keyword) and
  an <a href="#external-resource-link" id="the-link-element:external-resource-link-3">external resource link</a> (for the <code id="the-link-element:link-type-stylesheet-2"><a href="#link-type-stylesheet">stylesheet</a></code>
  keyword), and they are affected by other attributes (such as <code id="the-link-element:attr-link-media-2"><a href="#attr-link-media">media</a></code> or <code id="the-link-element:attr-link-title-3"><a href="#attr-link-title">title</a></code>)
  differently.</p>

  <div class="example">
   <p>For example, the following <code id="the-link-element:the-link-element-10"><a href="#the-link-element">link</a></code> element creates two <a href="#hyperlink" id="the-link-element:hyperlink-6">hyperlinks</a> (to the same page):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"author license"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/about"</c-><c- p="">&gt;</c-></code></pre>

   <p>The two links created by this element are one whose semantic is that the target page has
   information about the current page's author, and one whose semantic is that the target page has
   information regarding the license under which the current page is provided.</p>
  </div>

  <p><a href="#hyperlink" id="the-link-element:hyperlink-7">Hyperlinks</a> created with the <code id="the-link-element:the-link-element-11"><a href="#the-link-element">link</a></code> element and its
  <code id="the-link-element:attr-link-rel-18"><a href="#attr-link-rel">rel</a></code> attribute apply to the whole document. This contrasts with
  the <code id="the-link-element:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code> attribute of <code id="the-link-element:the-a-element"><a href="#the-a-element">a</a></code> and <code id="the-link-element:the-area-element"><a href="#the-area-element">area</a></code>
  elements, which indicates the type of a link whose context is given by the link's location within
  the document.</p>

  <p>Unlike those created by <code id="the-link-element:the-a-element-2"><a href="#the-a-element">a</a></code> and <code id="the-link-element:the-area-element-2"><a href="#the-area-element">area</a></code> elements, <a href="#hyperlink" id="the-link-element:hyperlink-8">hyperlinks</a> created by <code id="the-link-element:the-link-element-12"><a href="#the-link-element">link</a></code> elements are not displayed as
  part of the document by default, in user agents that <a href="#renderingUA">support the suggested
  default rendering</a>. And even if they are force-displayed using CSS, they have no
  <a id="the-link-element:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a>. Instead, they primarily provide semantic information which might
  be used by the page or by other software that consumes the page's contents. Additionally, the user
  agent can <a href="#providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element">provide
  its own UI for following such hyperlinks</a>.</p>

  <p>The exact behavior for <a href="#external-resource-link" id="the-link-element:external-resource-link-4">links to external resources</a>
  depends on the exact relationship, as defined for the relevant <a href="#linkTypes">link
  type</a>.</p>

  <hr>

  <p>The <dfn data-dfn-for="link" id="attr-link-crossorigin" data-dfn-type="element-attr"><code>crossorigin</code></dfn>
  attribute is a <a href="#cors-settings-attribute" id="the-link-element:cors-settings-attribute">CORS settings attribute</a>. It is intended for use with <a href="#external-resource-link" id="the-link-element:external-resource-link-5">external resource links</a>.</p>

  <p>The <dfn data-dfn-for="link" id="attr-link-media" data-dfn-type="element-attr"><code>media</code></dfn> attribute
  says which media the resource applies to. The value must be a <a href="#valid-media-query-list" id="the-link-element:valid-media-query-list">valid media query
  list</a>.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity" title="Subresource Integrity (SRI) is a security feature that enables browsers to verify that resources they fetch (for example, from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched resource must match.">Subresource_Integrity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>43+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>45+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="link" id="attr-link-integrity" data-dfn-type="element-attr"><code>integrity</code></dfn>
  attribute represents the <a href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata" id="the-link-element:concept-request-integrity-metadata" data-x-internal="concept-request-integrity-metadata">integrity
  metadata</a> for requests which this element is responsible for. The value is text. The
  attribute must only be specified on <code id="the-link-element:the-link-element-13"><a href="#the-link-element">link</a></code> elements that have a <code id="the-link-element:attr-link-rel-19"><a href="#attr-link-rel">rel</a></code> attribute that contains the <code id="the-link-element:link-type-stylesheet-3"><a href="#link-type-stylesheet">stylesheet</a></code>, <code id="the-link-element:link-type-preload-5"><a href="#link-type-preload">preload</a></code>, or <code id="the-link-element:link-type-modulepreload-3"><a href="#link-type-modulepreload">modulepreload</a></code> keyword. <a href="#refsSRI">[SRI]</a></p>

  <p>The <dfn data-dfn-for="link" id="attr-link-hreflang" data-dfn-type="element-attr"><code>hreflang</code></dfn>
  attribute on the <code id="the-link-element:the-link-element-14"><a href="#the-link-element">link</a></code> element has the same semantics as the <a href="#attr-hyperlink-hreflang" id="the-link-element:attr-hyperlink-hreflang"><code>hreflang</code> attribute on the <code>a</code>
  element</a>.</p>

  <p>The <dfn data-dfn-for="link" id="attr-link-type" data-dfn-type="element-attr"><code>type</code></dfn> attribute
  gives the <a id="the-link-element:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> of the linked resource. It is purely advisory. The value must be
  a <a id="the-link-element:valid-mime-type-string" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">valid MIME type string</a>.</p>

  <p>For <a href="#external-resource-link" id="the-link-element:external-resource-link-6">external resource links</a>, the <code id="the-link-element:attr-link-type-2"><a href="#attr-link-type">type</a></code> attribute is used as a hint to user agents so that they can
  avoid fetching resources they do not support.</p>

  <p>The <dfn data-dfn-for="link" id="attr-link-referrerpolicy" data-dfn-type="element-attr"><code>referrerpolicy</code></dfn> attribute is a <a href="#referrer-policy-attribute" id="the-link-element:referrer-policy-attribute">referrer policy
  attribute</a>. It is intended for use with <a href="#external-resource-link" id="the-link-element:external-resource-link-7">external
  resource links</a>, where it helps set the <a id="the-link-element:referrer-policy-2" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a> used when <a href="#fetch-and-process-the-linked-resource" id="the-link-element:fetch-and-process-the-linked-resource">fetching and processing the linked resource</a>.
  <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p>

  <p>The <dfn data-dfn-for="link" id="attr-link-title" data-dfn-type="element-attr"><code>title</code></dfn> attribute
  gives the title of the link. With one exception, it is purely advisory. The value is text. The
  exception is for style sheet links that are <a id="the-link-element:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>, for which the <code id="the-link-element:attr-link-title-4"><a href="#attr-link-title">title</a></code> attribute defines <a href="https://drafts.csswg.org/cssom/#css-style-sheet-set" id="the-link-element:css-style-sheet-set" data-x-internal="css-style-sheet-set">CSS
  style sheet sets</a>.</p>

  <p class="note">The <code id="the-link-element:attr-link-title-5"><a href="#attr-link-title">title</a></code> attribute on <code id="the-link-element:the-link-element-15"><a href="#the-link-element">link</a></code>
  elements differs from the global <code id="the-link-element:attr-title"><a href="#attr-title">title</a></code> attribute of most other
  elements in that a link without a title does not inherit the title of the parent element: it
  merely has no title.</p>

  <hr>

  <p>The <dfn data-dfn-for="link" id="attr-link-imagesrcset" data-dfn-type="element-attr"><code>imagesrcset</code></dfn>
  attribute may be present, and is a <a href="#srcset-attribute" id="the-link-element:srcset-attribute">srcset attribute</a>.</p>

  <p>The <code id="the-link-element:attr-link-imagesrcset-4"><a href="#attr-link-imagesrcset">imagesrcset</a></code> and <code id="the-link-element:attr-link-href-5"><a href="#attr-link-href">href</a></code> attributes (if <a href="#width-descriptor" id="the-link-element:width-descriptor">width
  descriptors</a> are not used) together contribute the <a href="#image-source" id="the-link-element:image-source">image
  sources</a> to the <a href="#source-set" id="the-link-element:source-set">source set</a>.</p>

  <p>If the <code id="the-link-element:attr-link-imagesrcset-5"><a href="#attr-link-imagesrcset">imagesrcset</a></code> attribute is present and has any
  <a href="#image-candidate-string" id="the-link-element:image-candidate-string">image candidate strings</a> using a <a href="#width-descriptor" id="the-link-element:width-descriptor-2">width
  descriptor</a>, the <dfn data-dfn-for="link" id="attr-link-imagesizes" data-dfn-type="element-attr"><code>imagesizes</code></dfn> attribute must also be present, and is a
  <a href="#sizes-attribute" id="the-link-element:sizes-attribute">sizes attribute</a>. The <code id="the-link-element:attr-link-imagesizes-2"><a href="#attr-link-imagesizes">imagesizes</a></code> attribute
  contributes the <a href="#source-size-2" id="the-link-element:source-size-2">source size</a> to the <a href="#source-set" id="the-link-element:source-set-2">source set</a>.</p>

  <p>The <code id="the-link-element:attr-link-imagesrcset-6"><a href="#attr-link-imagesrcset">imagesrcset</a></code> and <code id="the-link-element:attr-link-imagesizes-3"><a href="#attr-link-imagesizes">imagesizes</a></code> attributes must only be specified on
  <code id="the-link-element:the-link-element-16"><a href="#the-link-element">link</a></code> elements that have both a <code id="the-link-element:attr-link-rel-20"><a href="#attr-link-rel">rel</a></code> attribute that
  specifies the <code id="the-link-element:link-type-preload-6"><a href="#link-type-preload">preload</a></code> keyword, as well as an <code id="the-link-element:attr-link-as-2"><a href="#attr-link-as">as</a></code> attribute in the "<code>image</code>" state.</p>

  <div class="example">
   <p>These attributes allow preloading the appropriate resource that is later used by an
   <code id="the-link-element:the-img-element"><a href="#the-img-element">img</a></code> element that has the corresponding values for its <code id="the-link-element:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code> and <code id="the-link-element:attr-img-sizes"><a href="#attr-img-sizes">sizes</a></code>
   attributes:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"preload"</c-> <c- e="">as</c-><c- o="">=</c-><c- s="">"image"</c->
      <c- e="">imagesrcset</c-><c- o="">=</c-><c- s="">"wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w"</c->
      <c- e="">imagesizes</c-><c- o="">=</c-><c- s="">"50vw"</c-><c- p="">&gt;</c->

<c- c="">&lt;!-- ... later, or perhaps inserted dynamically ... --&gt;</c->
<c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"wolf.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"A rad wolf"</c->
     <c- e="">srcset</c-><c- o="">=</c-><c- s="">"wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w"</c->
     <c- e="">sizes</c-><c- o="">=</c-><c- s="">"50vw"</c-><c- p="">&gt;</c-></code></pre>

     <p>Note how we omit the <code id="the-link-element:attr-link-href-6"><a href="#attr-link-href">href</a></code> attribute, as it would only
     be relevant for browsers that do not support <code id="the-link-element:attr-link-imagesrcset-7"><a href="#attr-link-imagesrcset">imagesrcset</a></code>, and in those cases it would likely cause the
     incorrect image to be preloaded.</p>
  </div>

  <div class="example">
   <p>The <code id="the-link-element:attr-link-imagesrcset-8"><a href="#attr-link-imagesrcset">imagesrcset</a></code> attribute can be combined with the
   <code id="the-link-element:attr-link-media-3"><a href="#attr-link-media">media</a></code> attribute to preload the appropriate resource
   selected from a <code id="the-link-element:the-picture-element"><a href="#the-picture-element">picture</a></code> element's sources, for <a href="#art-direction" id="the-link-element:art-direction">art direction</a>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"preload"</c-> <c- e="">as</c-><c- o="">=</c-><c- s="">"image"</c->
      <c- e="">imagesrcset</c-><c- o="">=</c-><c- s="">"dog-cropped-1x.jpg, dog-cropped-2x.jpg 2x"</c->
      <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 800px)"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"preload"</c-> <c- e="">as</c-><c- o="">=</c-><c- s="">"image"</c->
      <c- e="">imagesrcset</c-><c- o="">=</c-><c- s="">"dog-wide-1x.jpg, dog-wide-2x.jpg 2x"</c->
      <c- e="">media</c-><c- o="">=</c-><c- s="">"(min-width: 801px)"</c-><c- p="">&gt;</c->

<c- c="">&lt;!-- ... later, or perhaps inserted dynamically ... --&gt;</c->
<c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"dog-cropped-1x.jpg, dog-cropped-2x.jpg 2x"</c->
          <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 800px)"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"dog-wide-1x.jpg"</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"dog-wide-2x.jpg 2x"</c->
       <c- e="">alt</c-><c- o="">=</c-><c- s="">"An awesome dog"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <hr>

  <p>The <dfn data-dfn-for="link" id="attr-link-sizes" data-dfn-type="element-attr"><code>sizes</code></dfn> attribute
  gives the sizes of icons for visual media. Its value, if present, is merely advisory. User agents may use the value to decide which icon(s) to use if multiple icons are
  available. If specified, the attribute must have a value that is an <a href="#unordered-set-of-unique-space-separated-tokens" id="the-link-element:unordered-set-of-unique-space-separated-tokens-2">unordered set of
  unique space-separated tokens</a> which are <a id="the-link-element:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>. Each value
  must be either an <a id="the-link-element:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code id="the-link-element:attr-link-sizes-any"><a href="#attr-link-sizes-any">any</a></code>", or a value that consists of two <a href="#valid-non-negative-integer" id="the-link-element:valid-non-negative-integer">valid non-negative integers</a> that do not have a leading U+0030 DIGIT
  ZERO (0) character and that are separated by a single U+0078 LATIN SMALL LETTER X or U+0058 LATIN
  CAPITAL LETTER X character. The attribute must only be specified on <code id="the-link-element:the-link-element-17"><a href="#the-link-element">link</a></code> elements
  that have a <code id="the-link-element:attr-link-rel-21"><a href="#attr-link-rel">rel</a></code> attribute that specifies the <code id="the-link-element:rel-icon-3"><a href="#rel-icon">icon</a></code> keyword or the <code>apple-touch-icon</code> keyword.</p>

  <p class="note">The <code>apple-touch-icon</code> keyword is a registered <a href="#concept-rel-extensions" id="the-link-element:concept-rel-extensions">extension to the predefined set of link types</a>, but user
  agents are not required to support it in any way.</p>

  <hr>

  <p>The <dfn data-dfn-for="link" id="attr-link-as" data-dfn-type="element-attr"><code>as</code></dfn> attribute
  specifies the <a href="https://fetch.spec.whatwg.org/#concept-potential-destination" id="the-link-element:concept-potential-destination-2" data-x-internal="concept-potential-destination">potential destination</a> for a
  preload request for the resource given by the <code id="the-link-element:attr-link-href-7"><a href="#attr-link-href">href</a></code> attribute.
  It is an <a href="#enumerated-attribute" id="the-link-element:enumerated-attribute">enumerated attribute</a>. Each <a href="https://fetch.spec.whatwg.org/#concept-potential-destination" id="the-link-element:concept-potential-destination-3" data-x-internal="concept-potential-destination">potential destination</a> is a keyword for this
  attribute, mapping to a state of the same name. The attribute must be specified on
  <code id="the-link-element:the-link-element-18"><a href="#the-link-element">link</a></code> elements that have a <code id="the-link-element:attr-link-rel-22"><a href="#attr-link-rel">rel</a></code> attribute that
  contains the <code id="the-link-element:link-type-preload-7"><a href="#link-type-preload">preload</a></code> keyword. It may be specified on
  <code id="the-link-element:the-link-element-19"><a href="#the-link-element">link</a></code> elements that have a <code id="the-link-element:attr-link-rel-23"><a href="#attr-link-rel">rel</a></code> attribute that
  contains the <code id="the-link-element:link-type-modulepreload-4"><a href="#link-type-modulepreload">modulepreload</a></code> keyword; in such cases it must
  have a value which is a <a href="https://fetch.spec.whatwg.org/#request-destination-script-like" id="the-link-element:concept-script-like-destination" data-x-internal="concept-script-like-destination">script-like
  destination</a>. For other <code id="the-link-element:the-link-element-20"><a href="#the-link-element">link</a></code> elements, it must not be specified.</p>

  <p>The processing model for how the <code id="the-link-element:attr-link-as-3"><a href="#attr-link-as">as</a></code> attribute is
  used is given in an individual link type's <a href="#fetch-and-process-the-linked-resource" id="the-link-element:fetch-and-process-the-linked-resource-2">fetch and process the linked resource</a>
  algorithm.</p>

  <p class="note">The attribute does not have a <i id="the-link-element:missing-value-default"><a href="#missing-value-default">missing value
  default</a></i> or <i id="the-link-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i>, meaning that invalid
  or missing values for the attribute map to no state. This is accounted for in the processing
  model. For <code id="the-link-element:link-type-preload-8"><a href="#link-type-preload">preload</a></code> links, both conditions are an error; for
  <code id="the-link-element:link-type-modulepreload-5"><a href="#link-type-modulepreload">modulepreload</a></code> links, a missing value will be treated as
  "<code>script</code>".</p>

  <hr>

  <p>The <dfn data-dfn-for="link" id="attr-link-blocking" data-dfn-type="element-attr"><code>blocking</code></dfn>
  attribute is a <a href="#blocking-attribute" id="the-link-element:blocking-attribute">blocking attribute</a>. It is used by link types <code id="the-link-element:link-type-stylesheet-4"><a href="#link-type-stylesheet">stylesheet</a></code> and <code id="the-link-element:link-type-expect-2"><a href="#link-type-expect">expect</a></code>, and it must only be specified on link elements
  that have a <code id="the-link-element:attr-link-rel-24"><a href="#attr-link-rel">rel</a></code> attribute containing those keywords.</p>

  <hr>

  <p>The <dfn data-dfn-for="link" id="attr-link-color" data-dfn-type="element-attr"><code>color</code></dfn> attribute is
  used with the <code>mask-icon</code> link type. The attribute must only be specified on
  <code id="the-link-element:the-link-element-21"><a href="#the-link-element">link</a></code> elements that have a <code id="the-link-element:attr-link-rel-25"><a href="#attr-link-rel">rel</a></code> attribute that
  contains the <code>mask-icon</code> keyword. The value must be a string that matches the
  CSS <a id="the-link-element:color" href="https://drafts.csswg.org/css-color/#typedef-color" data-x-internal="color">&lt;color&gt;</a> production, defining a suggested color that user agents can use to
  customize the display of the icon that the user sees when they pin your site.</p>

  <p class="note">This specification does not have any user agent requirements for the <code id="the-link-element:attr-link-color-2"><a href="#attr-link-color">color</a></code> attribute.</p>

  <p class="note">The <code>mask-icon</code> keyword is a registered <a href="#concept-rel-extensions" id="the-link-element:concept-rel-extensions-2">extension to the predefined set of link types</a>, but user
  agents are not required to support it in any way.</p>

  <hr>

  <p><code id="the-link-element:the-link-element-22"><a href="#the-link-element">link</a></code> elements have an associated <dfn id="explicitly-enabled">explicitly enabled</dfn> boolean. It is
  initially false.

  </p><p>The <dfn data-dfn-for="link" id="attr-link-disabled" data-dfn-type="element-attr"><code>disabled</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-link-element:boolean-attribute">boolean attribute</a> that is used with the <code id="the-link-element:link-type-stylesheet-5"><a href="#link-type-stylesheet">stylesheet</a></code> link type.  The attribute must only be specified on
  <code id="the-link-element:the-link-element-23"><a href="#the-link-element">link</a></code> elements that have a <code id="the-link-element:attr-link-rel-26"><a href="#attr-link-rel">rel</a></code> attribute that
  contains the <code id="the-link-element:link-type-stylesheet-6"><a href="#link-type-stylesheet">stylesheet</a></code> keyword.</p>

  <div data-algorithm="">
  <p>Whenever the <code id="the-link-element:attr-link-disabled-2"><a href="#attr-link-disabled">disabled</a></code> attribute is removed, set the
  <code id="the-link-element:the-link-element-24"><a href="#the-link-element">link</a></code> element's <a href="#explicitly-enabled" id="the-link-element:explicitly-enabled">explicitly enabled</a> attribute to true.</p>
  </div>

  <div class="example">
   <p>Removing the <code id="the-link-element:attr-link-disabled-3"><a href="#attr-link-disabled">disabled</a></code> attribute dynamically, e.g.,
   using <code>document.querySelector("link").removeAttribute("disabled")</code>, will
   fetch and apply the style sheet:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">link</c-> <c- e="">disabled</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"css/pooh"</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/fetchPriority" title="The fetchPriority property of the HTMLLinkElement interface represents a hint given to the browser on how it should prioritize the preload of the given resource relative to other resources of the same type.">HTMLLinkElement/fetchPriority</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span title="Requires setting a user preference or runtime flag.">🔰 preview+</span></span><span class="chrome yes"><span>Chrome</span><span>102+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>102+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="link" id="attr-link-fetchpriority" data-dfn-type="element-attr"><code>fetchpriority</code></dfn> attribute is a <a href="#fetch-priority-attribute" id="the-link-element:fetch-priority-attribute">fetch
  priority attribute</a> that is intended for use with <a href="#external-resource-link" id="the-link-element:external-resource-link-8">external resource links</a>, where it is used to set the <a href="https://fetch.spec.whatwg.org/#request-priority" id="the-link-element:concept-request-priority-2" data-x-internal="concept-request-priority">priority</a> used when <a href="#fetch-and-process-the-linked-resource" id="the-link-element:fetch-and-process-the-linked-resource-3">fetching and processing the linked
  resource</a>.</p>

  
  <hr>

  <p class="note">There is no reflecting IDL attribute for the <code id="the-link-element:attr-link-color-3"><a href="#attr-link-color">color</a></code> attribute, but this might be added later.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/as" title="The as property of the HTMLLinkElement interface returns a string representing the type of content to be preloaded by a link element.">HTMLLinkElement/as</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>50+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLLinkElement" id="dom-link-as" data-dfn-type="attribute"><code>as</code></dfn> IDL
  attribute must <a href="#reflect" id="the-link-element:reflect">reflect</a> the <code id="the-link-element:attr-link-as-4"><a href="#attr-link-as">as</a></code> content attribute,
  <a href="#limited-to-only-known-values" id="the-link-element:limited-to-only-known-values">limited to only known values</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLLinkElement" id="dom-link-crossorigin" data-dfn-type="attribute"><code>crossOrigin</code></dfn> IDL attribute must <a href="#reflect" id="the-link-element:reflect-2">reflect</a> the
  <code id="the-link-element:attr-link-crossorigin-2"><a href="#attr-link-crossorigin">crossorigin</a></code> content attribute, <a href="#limited-to-only-known-values" id="the-link-element:limited-to-only-known-values-2">limited to only
  known values</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/referrerPolicy" title="The HTMLLinkElement.referrerPolicy property reflects the HTML referrerpolicy attribute of the <link> element defining which referrer is sent when fetching the resource.">HTMLLinkElement/referrerPolicy</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>58+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLLinkElement" id="dom-link-referrerpolicy" data-dfn-type="attribute"><code>referrerPolicy</code></dfn> IDL attribute must
  <a href="#reflect" id="the-link-element:reflect-3">reflect</a> the <code id="the-link-element:attr-link-referrerpolicy-2"><a href="#attr-link-referrerpolicy">referrerpolicy</a></code> content
  attribute, <a href="#limited-to-only-known-values" id="the-link-element:limited-to-only-known-values-3">limited to only known values</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLLinkElement" id="dom-link-fetchpriority" data-dfn-type="attribute"><code>fetchPriority</code></dfn> IDL attribute must
  <a href="#reflect" id="the-link-element:reflect-4">reflect</a> the <code id="the-link-element:attr-link-fetchpriority-2"><a href="#attr-link-fetchpriority">fetchpriority</a></code> content
  attribute, <a href="#limited-to-only-known-values" id="the-link-element:limited-to-only-known-values-4">limited to only known values</a>.</p>
  </div>

  <p class="note">The <code id="the-link-element:dom-link-rellist"><a href="#dom-link-rellist">relList</a></code> attribute can be used for
  feature detection, by calling its <code id="the-link-element:dom-domtokenlist-supports"><a data-x-internal="dom-domtokenlist-supports" href="https://dom.spec.whatwg.org/#dom-domtokenlist-supports">supports()</a></code>
  method to check which <a href="#linkTypes">types of links</a> are supported.</p>

  <h5 id="processing-the-media-attribute"><span class="secno">4.2.4.1</span> Processing the <code id="processing-the-media-attribute:attr-link-media"><a href="#attr-link-media">media</a></code> attribute<a href="#processing-the-media-attribute" class="self-link"></a></h5>

  <p>If the link is a <a href="#hyperlink" id="processing-the-media-attribute:hyperlink">hyperlink</a> then the <code id="processing-the-media-attribute:attr-link-media-2"><a href="#attr-link-media">media</a></code>
  attribute is purely advisory, and describes for which media the document in question was
  designed.</p>

  <p>However, if the link is an <a href="#external-resource-link" id="processing-the-media-attribute:external-resource-link">external resource link</a>, then the <code id="processing-the-media-attribute:attr-link-media-3"><a href="#attr-link-media">media</a></code> attribute is prescriptive. The user agent must apply the
  external resource when the <code id="processing-the-media-attribute:attr-link-media-4"><a href="#attr-link-media">media</a></code> attribute's value
  <a href="#matches-the-environment" id="processing-the-media-attribute:matches-the-environment">matches the environment</a> and the other relevant conditions apply, and must not apply
  it otherwise.</p>

  <p id="default-media">The default, if the <code id="processing-the-media-attribute:attr-link-media-5"><a href="#attr-link-media">media</a></code> attribute is
  omitted, is "<code>all</code>", meaning that by default links apply to all media.</p>

  <p class="note">The external resource might have further restrictions defined within that limit
  its applicability. For example, a CSS style sheet might have some <code>@media</code>
  blocks. This specification does not override such further restrictions or requirements.</p>

  <h5 id="processing-the-type-attribute"><span class="secno">4.2.4.2</span> Processing the <code id="processing-the-type-attribute:attr-link-type"><a href="#attr-link-type">type</a></code> attribute<a href="#processing-the-type-attribute" class="self-link"></a></h5>

  <p>If the <code id="processing-the-type-attribute:attr-link-type-2"><a href="#attr-link-type">type</a></code> attribute is present, then the user agent must
  assume that the resource is of the given type (even if that is not a <a id="processing-the-type-attribute:valid-mime-type-string" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">valid MIME type
  string</a>, e.g. the empty string). If the attribute is omitted, but the <a href="#external-resource-link" id="processing-the-type-attribute:external-resource-link">external
  resource link</a> type has a default type defined, then the user agent must assume that the
  resource is of that type. If the UA does not support the given <a id="processing-the-type-attribute:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> for the
  given link relationship, then the UA should not <a href="#fetch-and-process-the-linked-resource" id="processing-the-type-attribute:fetch-and-process-the-linked-resource">fetch and process the linked
  resource</a>; if the UA does support the given <a id="processing-the-type-attribute:mime-type-2" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> for the given link
  relationship, then the UA should <a href="#fetch-and-process-the-linked-resource" id="processing-the-type-attribute:fetch-and-process-the-linked-resource-2">fetch and process the linked resource</a> at the
  appropriate time as specified for the <a href="#external-resource-link" id="processing-the-type-attribute:external-resource-link-2">external resource link</a>'s particular type.
  If the attribute is omitted, and the <a href="#external-resource-link" id="processing-the-type-attribute:external-resource-link-3">external resource link</a> type does not have a
  default type defined, but the user agent would <a href="#fetch-and-process-the-linked-resource" id="processing-the-type-attribute:fetch-and-process-the-linked-resource-3">fetch and process the linked resource</a>
  if the type was known and supported, then the user agent should <a href="#fetch-and-process-the-linked-resource" id="processing-the-type-attribute:fetch-and-process-the-linked-resource-4">fetch and process the linked
  resource</a> under the assumption that it will be supported.</p>

  <p>User agents must not consider the <code id="processing-the-type-attribute:attr-link-type-3"><a href="#attr-link-type">type</a></code> attribute
  authoritative — upon fetching the resource, user agents must not use the <code id="processing-the-type-attribute:attr-link-type-4"><a href="#attr-link-type">type</a></code> attribute to determine its actual type. Only the actual type
  (as defined in the next paragraph) is used to determine whether to <em>apply</em> the resource,
  not the aforementioned assumed type.</p>

  <p id="concept-link-type-sniffing">If the <a href="#external-resource-link" id="processing-the-type-attribute:external-resource-link-4">external resource link</a> type defines rules
  for processing the resource's <a href="#content-type" id="processing-the-type-attribute:content-type">Content-Type metadata</a>, then those
  rules apply.  Otherwise, if the resource is expected to be an image, user agents may apply the
  <a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-images-specifically" id="processing-the-type-attribute:content-type-sniffing:-image" data-x-internal="content-type-sniffing:-image">image sniffing rules</a>, with the <var>official
  type</var> being the type determined from the resource's <a href="#content-type" id="processing-the-type-attribute:content-type-2">Content-Type
  metadata</a>, and use the resulting <a href="https://mimesniff.spec.whatwg.org/#computed-mime-type" id="processing-the-type-attribute:content-type-sniffing-2" data-x-internal="content-type-sniffing-2">computed type of the
  resource</a> as if it was the actual type.  Otherwise, if neither of these conditions apply or
  if the user agent opts not to apply the image sniffing rules, then the user agent must use the
  resource's <a href="#content-type" id="processing-the-type-attribute:content-type-3">Content-Type metadata</a> to determine the type of the
  resource. If there is no type metadata, but the <a href="#external-resource-link" id="processing-the-type-attribute:external-resource-link-5">external resource link</a> type has a
  default type defined, then the user agent must assume that the resource is of that type.</p>

  <p class="note">The <code id="processing-the-type-attribute:link-type-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code> link type defines rules for
  processing the resource's <a href="#content-type" id="processing-the-type-attribute:content-type-4">Content-Type metadata</a>.</p>

  <p>Once the user agent has established the type of the resource, the user agent must apply the
  resource if it is of a supported type and the other relevant conditions apply, and must ignore the
  resource otherwise.</p>

  <div class="example">

   <p>If a document contains style sheet links labeled as follows:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"A"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text/plain"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"B"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text/css"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"C"</c-><c- p="">&gt;</c-></code></pre>

   <p>...then a compliant UA that supported only CSS style sheets would fetch the B and C files, and
   skip the A file (since <code id="processing-the-type-attribute:text/plain"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code> is not the <a id="processing-the-type-attribute:mime-type-3" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> for CSS style
   sheets).</p>

   <p>For files B and C, it would then check the actual types returned by the server. For those that
   are sent as <code id="processing-the-type-attribute:text/css"><a href="#text/css">text/css</a></code>, it would apply the styles, but for those labeled as
   <code id="processing-the-type-attribute:text/plain-2"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>, or any other type, it would not.</p>

   <p>If one of the two files was returned without a <a href="#content-type" id="processing-the-type-attribute:content-type-5">Content-Type</a> metadata, or with a
   syntactically incorrect type like <code>Content-Type:&nbsp;"null"</code>, then the
   default type for <code id="processing-the-type-attribute:link-type-stylesheet-2"><a href="#link-type-stylesheet">stylesheet</a></code> links would kick in. Since that
   default type is <code id="processing-the-type-attribute:text/css-2"><a href="#text/css">text/css</a></code>, the style sheet <em>would</em> nonetheless be applied.</p>

  </div>

  <h5 id="fetching-and-processing-a-resource-from-a-link-element"><span class="secno">4.2.4.3</span> <span id="obtaining-a-resource-from-a-link-element"></span>Fetching and processing a resource
  from a <code id="fetching-and-processing-a-resource-from-a-link-element:the-link-element"><a href="#the-link-element">link</a></code> element<a href="#fetching-and-processing-a-resource-from-a-link-element" class="self-link"></a></h5>

  <div data-var-scope="">
  <p id="concept-link-obtain">All <a href="#external-resource-link" id="fetching-and-processing-a-resource-from-a-link-element:external-resource-link">external resource
  links</a> have a <dfn id="fetch-and-process-the-linked-resource">fetch and process the linked resource</dfn> algorithm, which takes a
  <code id="fetching-and-processing-a-resource-from-a-link-element:the-link-element-2"><a href="#the-link-element">link</a></code> element <var>el</var>. They also have <dfn id="linked-resource-fetch-setup-steps">linked resource fetch setup
  steps</dfn> which take a <code id="fetching-and-processing-a-resource-from-a-link-element:the-link-element-3"><a href="#the-link-element">link</a></code> element <var>el</var> and <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-and-processing-a-resource-from-a-link-element:concept-request" data-x-internal="concept-request">request</a> <var>request</var>. Individual link types may provide
  their own <a href="#fetch-and-process-the-linked-resource" id="fetching-and-processing-a-resource-from-a-link-element:fetch-and-process-the-linked-resource">fetch and process the linked resource</a> algorithm, but unless explicitly
  stated, they use the <a href="#default-fetch-and-process-the-linked-resource" id="fetching-and-processing-a-resource-from-a-link-element:default-fetch-and-process-the-linked-resource">default fetch and process the linked resource</a> algorithm.
  Similarly, individual link types may provide their own <a href="#linked-resource-fetch-setup-steps" id="fetching-and-processing-a-resource-from-a-link-element:linked-resource-fetch-setup-steps">linked resource fetch setup
  steps</a>, but unless explicitly stated, these steps just return true.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="default-fetch-and-process-the-linked-resource">default fetch and process the linked resource</dfn>, given a <code id="fetching-and-processing-a-resource-from-a-link-element:the-link-element-4"><a href="#the-link-element">link</a></code> element
  <var>el</var>, is as follows:</p>

  <ol><li><p>Let <var>options</var> be the result of <a href="#create-link-options-from-element" id="fetching-and-processing-a-resource-from-a-link-element:create-link-options-from-element">creating link options</a> from <var>el</var>.</p></li><li><p>Let <var>request</var> be the result of <a href="#create-a-link-request" id="fetching-and-processing-a-resource-from-a-link-element:create-a-link-request">creating a
   link request</a> given <var>options</var>.</p></li><li><p>If <var>request</var> is null, then return.</p></li><li><p>Set <var>request</var>'s <a id="fetching-and-processing-a-resource-from-a-link-element:synchronous-flag" href="https://fetch.spec.whatwg.org/#synchronous-flag" data-x-internal="synchronous-flag">synchronous flag</a>.</p></li><li><p>Run the <a href="#linked-resource-fetch-setup-steps" id="fetching-and-processing-a-resource-from-a-link-element:linked-resource-fetch-setup-steps-2">linked resource fetch setup steps</a>, given <var>el</var> and
   <var>request</var>. If the result is false, then return.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="fetching-and-processing-a-resource-from-a-link-element:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator
   type</a> to "<code>css</code>" if <var>el</var>'s <code id="fetching-and-processing-a-resource-from-a-link-element:attr-link-rel"><a href="#attr-link-rel">rel</a></code> attribute contains the keyword <code id="fetching-and-processing-a-resource-from-a-link-element:link-type-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code>; "<code>link</code>" otherwise.</p></li><li>
    <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetching-and-processing-a-resource-from-a-link-element:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var> with <i id="fetching-and-processing-a-resource-from-a-link-element:processresponseconsumebody"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> set to the following steps
    given <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-and-processing-a-resource-from-a-link-element:concept-response" data-x-internal="concept-response">response</a> <var>response</var> and null, failure, or
    a <a id="fetching-and-processing-a-resource-from-a-link-element:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bodyBytes</var>:</p>

    <ol><li><p>Let <var>success</var> be true.</p></li><li>
      <p>If any of the following are true:</p>

      <ul><li><p><var>bodyBytes</var> is null or failure; or</p></li><li><p><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="fetching-and-processing-a-resource-from-a-link-element:concept-response-status" data-x-internal="concept-response-status">status</a> is not an
       <a id="fetching-and-processing-a-resource-from-a-link-element:ok-status" href="https://fetch.spec.whatwg.org/#ok-status" data-x-internal="ok-status">ok status</a>,</p></li></ul>

      <p>then set <var>success</var> to false.</p>

      <p class="note">Note that content-specific errors, e.g., CSS parse errors or PNG decoding
      errors, do not affect <var>success</var>.</p>
     </li><li>
      <p>Otherwise, wait for the <a href="#external-resource-link" id="fetching-and-processing-a-resource-from-a-link-element:external-resource-link-2">link
      resource</a>'s <a href="#critical-subresources" id="fetching-and-processing-a-resource-from-a-link-element:critical-subresources">critical subresources</a> to finish loading.</p>

      <p class="XXX">The specification that defines a link type's <a href="#critical-subresources" id="fetching-and-processing-a-resource-from-a-link-element:critical-subresources-2">critical subresources</a>
      (e.g., CSS) is expected to describe how these subresources are fetched and processed. However,
      since this is not currently explicit, this specification describes waiting for a <a href="#external-resource-link" id="fetching-and-processing-a-resource-from-a-link-element:external-resource-link-3">link resource</a>'s <a href="#critical-subresources" id="fetching-and-processing-a-resource-from-a-link-element:critical-subresources-3">critical subresources</a> to
      be fetched and processed, with the expectation that this will be done correctly.</p>
     </li><li><p><a href="#process-the-linked-resource" id="fetching-and-processing-a-resource-from-a-link-element:process-the-linked-resource">Process the linked resource</a> given <var>el</var>, <var>success</var>,
     <var>response</var>, and <var>bodyBytes</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="create-a-link-request">create a link request</dfn> given a <a href="#link-processing-options" id="fetching-and-processing-a-resource-from-a-link-element:link-processing-options">link processing options</a>
  <var>options</var>:</p>

  <ol><li><p><a id="fetching-and-processing-a-resource-from-a-link-element:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>options</var>'s <a href="#link-options-href" id="fetching-and-processing-a-resource-from-a-link-element:link-options-href">href</a> is
   not the empty string.</p></li><li>
    <p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="fetching-and-processing-a-resource-from-a-link-element:encoding-parsing-a-url">encoding-parsing a URL</a> given
    <var>options</var>'s <a href="#link-options-href" id="fetching-and-processing-a-resource-from-a-link-element:link-options-href-2">href</a>, relative to
    <var>options</var>'s <a href="#link-options-base-url" id="fetching-and-processing-a-resource-from-a-link-element:link-options-base-url">base URL</a>.</p>

    <p class="XXX">Passing the base URL instead of a document or environment is tracked by <a href="https://github.com/whatwg/html/issues/9715">issue #9715</a>.</p>
   </li><li><p>If <var>url</var> is failure, then return null.</p></li><li><p>Let <var>request</var> be the result of <a href="#create-a-potential-cors-request" id="fetching-and-processing-a-resource-from-a-link-element:create-a-potential-cors-request">creating a potential-CORS request</a> given <var>url</var>, <var>options</var>'s
   <a href="#link-options-destination" id="fetching-and-processing-a-resource-from-a-link-element:link-options-destination">destination</a>, and <var>options</var>'s <a href="#link-options-crossorigin" id="fetching-and-processing-a-resource-from-a-link-element:link-options-crossorigin">crossorigin</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-policy-container" id="fetching-and-processing-a-resource-from-a-link-element:concept-request-policy-container" data-x-internal="concept-request-policy-container">policy
   container</a> to <var>options</var>'s <a href="#link-options-policy-container" id="fetching-and-processing-a-resource-from-a-link-element:link-options-policy-container">policy
   container</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata" id="fetching-and-processing-a-resource-from-a-link-element:concept-request-integrity-metadata" data-x-internal="concept-request-integrity-metadata">integrity
   metadata</a> to <var>options</var>'s <a href="#link-options-integrity" id="fetching-and-processing-a-resource-from-a-link-element:link-options-integrity">integrity</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-nonce-metadata" id="fetching-and-processing-a-resource-from-a-link-element:concept-request-nonce-metadata" data-x-internal="concept-request-nonce-metadata">cryptographic
   nonce metadata</a> to <var>options</var>'s <a href="#link-options-nonce" id="fetching-and-processing-a-resource-from-a-link-element:link-options-nonce">cryptographic
   nonce metadata</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-referrer-policy" id="fetching-and-processing-a-resource-from-a-link-element:concept-request-referrer-policy" data-x-internal="concept-request-referrer-policy">referrer
   policy</a> to <var>options</var>'s <a href="#link-options-referrer-policy" id="fetching-and-processing-a-resource-from-a-link-element:link-options-referrer-policy">referrer
   policy</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="fetching-and-processing-a-resource-from-a-link-element:concept-request-client" data-x-internal="concept-request-client">client</a> to
   <var>options</var>'s <a href="#link-options-environment" id="fetching-and-processing-a-resource-from-a-link-element:link-options-environment">environment</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-priority" id="fetching-and-processing-a-resource-from-a-link-element:concept-request-priority" data-x-internal="concept-request-priority">priority</a> to
   <var>options</var>'s <a href="#link-options-fetch-priority" id="fetching-and-processing-a-resource-from-a-link-element:link-options-fetch-priority">fetch priority</a>.</p></li><li><p>Return <var>request</var>.</p></li></ol>
  </div>

  <p>User agents may opt to only try to <a href="#fetch-and-process-the-linked-resource" id="fetching-and-processing-a-resource-from-a-link-element:fetch-and-process-the-linked-resource-2">fetch
  and process</a> such resources when they are needed, instead of pro-actively fetching all the
  <a href="#external-resource-link" id="fetching-and-processing-a-resource-from-a-link-element:external-resource-link-4">external resources</a> that are not applied.</p>

  
  
  <div data-var-scope="">
  <p>Similar to the <a href="#fetch-and-process-the-linked-resource" id="fetching-and-processing-a-resource-from-a-link-element:fetch-and-process-the-linked-resource-3">fetch and process the linked resource</a> algorithm, all <a href="#external-resource-link" id="fetching-and-processing-a-resource-from-a-link-element:external-resource-link-5">external resource links</a> have a <dfn id="process-the-linked-resource">process the linked
  resource</dfn> algorithm which takes a <code id="fetching-and-processing-a-resource-from-a-link-element:the-link-element-5"><a href="#the-link-element">link</a></code> element <var>el</var>, boolean
  <var>success</var>, a <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-and-processing-a-resource-from-a-link-element:concept-response-2" data-x-internal="concept-response">response</a> <var>response</var>, and a
  <a id="fetching-and-processing-a-resource-from-a-link-element:byte-sequence-2" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bodyBytes</var>. Individual link types may provide their own
  <a href="#process-the-linked-resource" id="fetching-and-processing-a-resource-from-a-link-element:process-the-linked-resource-2">process the linked resource</a> algorithm, but unless explicitly stated, that algorithm
  does nothing.</p>
  </div>

  <p>Unless otherwise specified for a given <code id="fetching-and-processing-a-resource-from-a-link-element:attr-link-rel-2"><a href="#attr-link-rel">rel</a></code> keyword, the
  element must <a href="#delay-the-load-event" id="fetching-and-processing-a-resource-from-a-link-element:delay-the-load-event">delay the load event</a> of the element's <a id="fetching-and-processing-a-resource-from-a-link-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> until
  all the attempts to <a href="#fetch-and-process-the-linked-resource" id="fetching-and-processing-a-resource-from-a-link-element:fetch-and-process-the-linked-resource-4">fetch and process the linked resource</a> and its <a href="#critical-subresources" id="fetching-and-processing-a-resource-from-a-link-element:critical-subresources-4">critical
  subresources</a> are complete. (Resources that the user agent has not yet attempted to fetch
  and process, e.g., because it is waiting for the resource to be needed, do not <a href="#delay-the-load-event" id="fetching-and-processing-a-resource-from-a-link-element:delay-the-load-event-2">delay the
  load event</a>.)</p>

  <h5 id="processing-link-headers"><span class="secno">4.2.4.4</span> Processing `<code id="processing-link-headers:http-link"><a data-x-internal="http-link" href="https://httpwg.org/specs/rfc8288.html#header">Link</a></code>` headers<a href="#processing-link-headers" class="self-link"></a></h5>

  <p>All link types that can be <a href="#external-resource-link" id="processing-link-headers:external-resource-link">external resource
  links</a> define a <dfn id="process-a-link-header">process a link header</dfn> algorithm, which takes a <a href="#link-processing-options" id="processing-link-headers:link-processing-options">link
  processing options</a>. This algorithm defines whether and how they react to appearing in an
  HTTP `<code id="processing-link-headers:http-link-2"><a data-x-internal="http-link" href="https://httpwg.org/specs/rfc8288.html#header">Link</a></code>` response header.</p>

  <p class="note">For most link types, this algorithm does nothing. The <a href="#table-link-relations">summary table</a> is a good reference to quickly know whether a link
  type has defined <a href="#process-a-link-header" id="processing-link-headers:process-a-link-header">process a link header</a> steps.</p>

  <p>A <dfn id="link-processing-options">link processing options</dfn> is a <a id="processing-link-headers:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a>. It has the following
  <a href="https://infra.spec.whatwg.org/#struct-item" id="processing-link-headers:struct-item" data-x-internal="struct-item">items</a>:</p>

  <dl><dt><dfn id="link-options-href">href</dfn> (default the empty string)</dt><dt><dfn id="link-options-initiator">initiator</dfn> (default "<code>link</code>")</dt><dt><dfn id="link-options-integrity">integrity</dfn> (default the empty string)</dt><dt><dfn id="link-options-type">type</dfn> (default the empty string)</dt><dt><dfn id="link-options-nonce">cryptographic nonce metadata</dfn> (default the empty
   string)</dt><dd>A string</dd><dt><dfn id="link-options-destination">destination</dfn> (default the empty string)</dt><dd>A <a id="processing-link-headers:destination-type" href="https://fetch.spec.whatwg.org/#destination-type" data-x-internal="destination-type">destination type</a>.</dd><dt><dfn id="link-options-crossorigin">crossorigin</dfn> (default <a href="#attr-crossorigin-none" id="processing-link-headers:attr-crossorigin-none">No CORS</a>)</dt><dd>A <a href="#cors-settings-attribute" id="processing-link-headers:cors-settings-attribute">CORS settings attribute</a> state</dd><dt><dfn id="link-options-referrer-policy">referrer policy</dfn> (default the empty
   string)</dt><dd>A <a id="processing-link-headers:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a></dd><dt><dfn id="link-options-source-set">source set</dfn> (default null)</dt><dd>Null or a  <a href="#source-set" id="processing-link-headers:source-set">source set</a></dd><dt><dfn id="link-options-base-url">base URL</dfn></dt><dd>A <a id="processing-link-headers:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a></dd><dt><dfn id="link-options-origin">origin</dfn></dt><dd>An <a href="#concept-origin" id="processing-link-headers:concept-origin">origin</a></dd><dt><dfn id="link-options-environment">environment</dfn></dt><dd>An <a href="#environment" id="processing-link-headers:environment">environment</a></dd><dt><dfn id="link-options-policy-container">policy container</dfn></dt><dd>A <a href="#policy-container" id="processing-link-headers:policy-container">policy container</a></dd><dt><dfn id="link-options-document">document</dfn> (default null)</dt><dd>Null or a <code id="processing-link-headers:document"><a href="#document">Document</a></code></dd><dt><dfn id="link-options-on-document-ready">on document ready</dfn> (default null)</dt><dd>Null or an algorithm accepting a <code id="processing-link-headers:document-2"><a href="#document">Document</a></code></dd><dt><dfn id="link-options-fetch-priority">fetch priority</dfn> (default <code id="processing-link-headers:attr-fetchpriority-auto-state"><a href="#attr-fetchpriority-auto-state">Auto</a></code>)</dt><dd>A <a href="#fetch-priority-attribute" id="processing-link-headers:fetch-priority-attribute">fetch priority attribute</a> state</dd></dl>

  <p class="note">A <a href="#link-processing-options" id="processing-link-headers:link-processing-options-2">link processing options</a> has a <a href="#link-options-base-url" id="processing-link-headers:link-options-base-url">base URL</a> and an <a href="#link-options-href" id="processing-link-headers:link-options-href">href</a>
  rather than a parsed URL because the URL could be a result of the options's <a href="#link-options-source-set" id="processing-link-headers:link-options-source-set">source set</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="create-link-options-from-element">create link options from element</dfn> given a <code id="processing-link-headers:the-link-element"><a href="#the-link-element">link</a></code> element
  <var>el</var>:</p>

  <ol><li><p>Let <var>document</var> be <var>el</var>'s <a id="processing-link-headers:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li>
    <p>Let <var>options</var> be a new <a href="#link-processing-options" id="processing-link-headers:link-processing-options-3">link processing options</a> with</p>

    <dl class="props"><dt><a href="#link-options-crossorigin" id="processing-link-headers:link-options-crossorigin">crossorigin</a></dt><dd>the state of <var>el</var>'s <code id="processing-link-headers:attr-link-crossorigin"><a href="#attr-link-crossorigin">crossorigin</a></code>
     content attribute</dd><dt><a href="#link-options-referrer-policy" id="processing-link-headers:link-options-referrer-policy">referrer policy</a></dt><dd>the state of <var>el</var>'s <code id="processing-link-headers:attr-link-referrerpolicy"><a href="#attr-link-referrerpolicy">referrerpolicy</a></code>
     content attribute</dd><dt><a href="#link-options-source-set" id="processing-link-headers:link-options-source-set-2">source set</a></dt><dd><var>el</var>'s <a href="#source-set" id="processing-link-headers:source-set-2">source set</a></dd><dt><a href="#link-options-base-url" id="processing-link-headers:link-options-base-url-2">base URL</a></dt><dd><var>document</var>'s <a href="#document-base-url" id="processing-link-headers:document-base-url">document base URL</a></dd><dt><a href="#link-options-origin" id="processing-link-headers:link-options-origin">origin</a></dt><dd><var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="processing-link-headers:concept-document-origin" data-x-internal="concept-document-origin">origin</a></dd><dt><a href="#link-options-environment" id="processing-link-headers:link-options-environment">environment</a></dt><dd><var>document</var>'s <a href="#relevant-settings-object" id="processing-link-headers:relevant-settings-object">relevant settings object</a></dd><dt><a href="#link-options-policy-container" id="processing-link-headers:link-options-policy-container">policy container</a></dt><dd><var>document</var>'s <a href="#concept-document-policy-container" id="processing-link-headers:concept-document-policy-container">policy container</a></dd><dt><a href="#link-options-document" id="processing-link-headers:link-options-document">document</a></dt><dd><var>document</var></dd><dt><a href="#link-options-nonce" id="processing-link-headers:link-options-nonce">cryptographic nonce metadata</a></dt><dd>the current value of <var>el</var>'s <a href="#cryptographicnonce" id="processing-link-headers:cryptographicnonce">[[CryptographicNonce]]</a> internal slot</dd><dt><a href="#link-options-fetch-priority" id="processing-link-headers:link-options-fetch-priority">fetch priority</a></dt><dd>the state of <var>el</var>'s <code id="processing-link-headers:attr-link-fetchpriority"><a href="#attr-link-fetchpriority">fetchpriority</a></code>
     content attribute</dd></dl>
   </li><li><p>If <var>el</var> has an <code id="processing-link-headers:attr-link-href"><a href="#attr-link-href">href</a></code> attribute, then set
   <var>options</var>'s <a href="#link-options-href" id="processing-link-headers:link-options-href-2">href</a> to the value of
   <var>el</var>'s <code id="processing-link-headers:attr-link-href-2"><a href="#attr-link-href">href</a></code> attribute.</p></li><li><p>If <var>el</var> has an <code id="processing-link-headers:attr-link-integrity"><a href="#attr-link-integrity">integrity</a></code> attribute,
   then set <var>options</var>'s <a href="#link-options-integrity" id="processing-link-headers:link-options-integrity">integrity</a> to the
   value of <var>el</var>'s <code id="processing-link-headers:attr-link-integrity-2"><a href="#attr-link-integrity">integrity</a></code> content
   attribute.</p></li><li><p>If <var>el</var> has a <code id="processing-link-headers:attr-link-type"><a href="#attr-link-type">type</a></code> attribute, then set
   <var>options</var>'s <a href="#link-options-type" id="processing-link-headers:link-options-type">type</a> to the value of
   <var>el</var>'s <code id="processing-link-headers:attr-link-type-2"><a href="#attr-link-type">type</a></code> attribute.</p></li><li>
    <p><a id="processing-link-headers:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>options</var>'s <a href="#link-options-href" id="processing-link-headers:link-options-href-3">href</a> is not
    the empty string, or <var>options</var>'s <a href="#link-options-source-set" id="processing-link-headers:link-options-source-set-3">source
    set</a> is not null.</p>

    <p>A <code id="processing-link-headers:the-link-element-2"><a href="#the-link-element">link</a></code> element with neither an <code id="processing-link-headers:attr-link-href-3"><a href="#attr-link-href">href</a></code> or an
    <code id="processing-link-headers:attr-link-imagesrcset"><a href="#attr-link-imagesrcset">imagesrcset</a></code> does not represent a link.</p>
   </li><li><p>Return <var>options</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="extract-links-from-headers">extract links from headers</dfn> given a <a href="https://fetch.spec.whatwg.org/#concept-header-list" id="processing-link-headers:concept-header-list" data-x-internal="concept-header-list">header
  list</a> <var>headers</var>:</p>

  <ol><li><p>Let <var>links</var> be a new <a id="processing-link-headers:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>Let <var>rawLinkHeaders</var> be the result of <a href="https://fetch.spec.whatwg.org/#concept-header-list-get-decode-split" id="processing-link-headers:concept-header-list-get-decode-split" data-x-internal="concept-header-list-get-decode-split">getting, decoding, and splitting</a>
   `<code id="processing-link-headers:the-link-element-3"><a href="#the-link-element">Link</a></code>` from <var>headers</var>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="processing-link-headers:list-iterate" data-x-internal="list-iterate">For each</a> <var>linkHeader</var> of
    <var>rawLinkHeaders</var>:</p>

    <ol><li><p>Let <var>linkObject</var> be the result of <a href="https://httpwg.org/specs/rfc8288.html#parse-fv" id="processing-link-headers:parsing-a-link-field-value" data-x-internal="parsing-a-link-field-value">parsing</a> <var>linkHeader</var>. <a href="#refsWEBLINK">[WEBLINK]</a></p></li><li><p>If <var>linkObject</var>["<code>target_uri</code>"] does not
     <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists" data-x-internal="map-exists">exist</a>, then <a id="processing-link-headers:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="processing-link-headers:list-append" data-x-internal="list-append">Append</a> <var>linkObject</var> to
     <var>links</var>.</p></li></ol>
   </li><li><p>Return <var>links</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="process-link-headers">process link headers</dfn> given a <code id="processing-link-headers:document-3"><a href="#document">Document</a></code> <var>doc</var>,
  a <a href="https://fetch.spec.whatwg.org/#concept-response" id="processing-link-headers:concept-response" data-x-internal="concept-response">response</a> <var>response</var>, and a
  "<code>pre-media</code>" or "<code>media</code>" <var>phase</var>:</p>

  <ol><li><p>Let <var>links</var> be the result of <a href="#extract-links-from-headers" id="processing-link-headers:extract-links-from-headers">extracting links</a> from <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="processing-link-headers:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="processing-link-headers:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>linkObject</var> in <var>links</var>:</p>

    <ol><li><p>Let <var>rel</var> be <var>linkObject</var>["<code>relation_type</code>"].</p></li><li><p>Let <var>attribs</var> be <var>linkObject</var>["<code>target_attributes</code>"].</p></li><li><p>Let <var>expectedPhase</var> be "<code>media</code>" if either "<code id="processing-link-headers:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code>", "<code id="processing-link-headers:attr-link-imagesrcset-2"><a href="#attr-link-imagesrcset">imagesrcset</a></code>", or "<code id="processing-link-headers:attr-link-media"><a href="#attr-link-media">media</a></code>" <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-2" data-x-internal="map-exists">exist</a> in
     <var>attribs</var>; otherwise "<code>pre-media</code>".</p></li><li><p>If <var>expectedPhase</var> is not <var>phase</var>, then
     <a id="processing-link-headers:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>attribs</var>["<code id="processing-link-headers:attr-link-media-2"><a href="#attr-link-media">media</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-3" data-x-internal="map-exists">exists</a> and <var>attribs</var>["<code id="processing-link-headers:attr-link-media-3"><a href="#attr-link-media">media</a></code>"]
     does not <a href="#matches-the-environment" id="processing-link-headers:matches-the-environment">match the environment</a>, then
     <a id="processing-link-headers:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li>
      <p>Let <var>options</var> be a new <a href="#link-processing-options" id="processing-link-headers:link-processing-options-4">link processing options</a> with</p>

      <dl class="props"><dt><a href="#link-options-href" id="processing-link-headers:link-options-href-4">href</a></dt><dd><var>linkObject</var>["<code>target_uri</code>"]</dd><dt><a href="#link-options-base-url" id="processing-link-headers:link-options-base-url-3">base URL</a></dt><dd><var>doc</var>'s <a href="#document-base-url" id="processing-link-headers:document-base-url-2">document base URL</a></dd><dt><a href="#link-options-origin" id="processing-link-headers:link-options-origin-2">origin</a></dt><dd><var>doc</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="processing-link-headers:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a></dd><dt><a href="#link-options-environment" id="processing-link-headers:link-options-environment-2">environment</a></dt><dd><var>doc</var>'s <a href="#relevant-settings-object" id="processing-link-headers:relevant-settings-object-2">relevant settings object</a></dd><dt><a href="#link-options-policy-container" id="processing-link-headers:link-options-policy-container-2">policy container</a></dt><dd><var>doc</var>'s <a href="#concept-document-policy-container" id="processing-link-headers:concept-document-policy-container-2">policy
       container</a></dd><dt><a href="#link-options-document" id="processing-link-headers:link-options-document-2">document</a></dt><dd><var>doc</var></dd></dl>
     </li><li><p><a href="#apply-link-options-from-parsed-header-attributes" id="processing-link-headers:apply-link-options-from-parsed-header-attributes">Apply link options from parsed header attributes</a> to <var>options</var>
     given <var>attribs</var> and <var>rel</var>. If that returned false, then return.</p></li><li><p>If <var>attribs</var>["<code id="processing-link-headers:attr-link-imagesrcset-3"><a href="#attr-link-imagesrcset">imagesrcset</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-4" data-x-internal="map-exists">exists</a> and <var>attribs</var>["<code id="processing-link-headers:attr-link-imagesizes"><a href="#attr-link-imagesizes">imagesizes</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-5" data-x-internal="map-exists">exists</a>,
     then set <var>options</var>'s <a href="#link-options-source-set" id="processing-link-headers:link-options-source-set-4">source set</a> to the
     result of <a href="#create-a-source-set" id="processing-link-headers:create-a-source-set">creating a source set</a> given
     <var>linkObject</var>["<code>target_uri</code>"], <var>attribs</var>["<code id="processing-link-headers:attr-link-imagesrcset-4"><a href="#attr-link-imagesrcset">imagesrcset</a></code>"], <var>attribs</var>["<code id="processing-link-headers:attr-link-imagesizes-2"><a href="#attr-link-imagesizes">imagesizes</a></code>"], and null.</p></li><li><p>Run the <a href="#process-a-link-header" id="processing-link-headers:process-a-link-header-2">process a link header</a> steps for <var>rel</var> given
     <var>options</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="apply-link-options-from-parsed-header-attributes">apply link options from parsed header attributes</dfn> to a <a href="#link-processing-options" id="processing-link-headers:link-processing-options-5">link processing
  options</a> <var>options</var> given <var>attribs</var> and a string <var>rel</var>:</p>

  <ol><li>
    <p>If <var>rel</var> is "<code id="processing-link-headers:link-type-preload"><a href="#link-type-preload">preload</a></code>":</p>

    <ol><li><p>If <var>attribs</var>["<code id="processing-link-headers:attr-link-as"><a href="#attr-link-as">as</a></code>"] does not <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-6" data-x-internal="map-exists">exist</a>, then return false.</p></li><li><p>Let <var>destination</var> be the result of <a href="#translate-a-preload-destination" id="processing-link-headers:translate-a-preload-destination">translating</a> <var>attribs</var>["<code id="processing-link-headers:attr-link-as-2"><a href="#attr-link-as">as</a></code>"].</p></li><li><p>If <var>destination</var> is null, then return false.</p></li><li><p>Set <var>options</var>'s <a href="#link-options-destination" id="processing-link-headers:link-options-destination">destination</a> to
     <var>destination</var>.</p></li></ol>
   </li><li><p>If <var>attribs</var>["<code id="processing-link-headers:attr-link-crossorigin-2"><a href="#attr-link-crossorigin">crossorigin</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-7" data-x-internal="map-exists">exists</a> and is an <a id="processing-link-headers:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of
   the <a href="#cors-settings-attribute" id="processing-link-headers:cors-settings-attribute-2">CORS settings attribute</a> <a href="#enumerated-attribute" id="processing-link-headers:enumerated-attribute">keywords</a>,
   then set <var>options</var>'s <a href="#link-options-crossorigin" id="processing-link-headers:link-options-crossorigin-2">crossorigin</a> to the
   <a href="#cors-settings-attribute" id="processing-link-headers:cors-settings-attribute-3">CORS settings attribute</a> state corresponding to that keyword.</p></li><li><p>If <var>attribs</var>["<code id="processing-link-headers:attr-link-integrity-3"><a href="#attr-link-integrity">integrity</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-8" data-x-internal="map-exists">exists</a>, then set <var>options</var>'s <a href="#link-options-integrity" id="processing-link-headers:link-options-integrity-2">integrity</a> to <var>attribs</var>["<code id="processing-link-headers:attr-link-integrity-4"><a href="#attr-link-integrity">integrity</a></code>"].</p></li><li><p>If <var>attribs</var>["<code id="processing-link-headers:attr-link-referrerpolicy-2"><a href="#attr-link-referrerpolicy">referrerpolicy</a></code>"]
   <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-9" data-x-internal="map-exists">exists</a> and is an <a id="processing-link-headers:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
   some <a id="processing-link-headers:referrer-policy-2" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>, then set <var>options</var>'s <a href="#link-options-referrer-policy" id="processing-link-headers:link-options-referrer-policy-2">referrer policy</a> to that <a id="processing-link-headers:referrer-policy-3" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>.</p></li><li><p>If <var>attribs</var>["<code id="processing-link-headers:attr-nonce"><a href="#attr-nonce">nonce</a></code>"]
   <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-10" data-x-internal="map-exists">exists</a>, then set <var>options</var>'s <a href="#link-options-nonce" id="processing-link-headers:link-options-nonce-2">nonce</a> to <var>attribs</var>["<code id="processing-link-headers:attr-nonce-2"><a href="#attr-nonce">nonce</a></code>"].</p></li><li><p>If <var>attribs</var>["<code id="processing-link-headers:attr-link-type-3"><a href="#attr-link-type">type</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-11" data-x-internal="map-exists">exists</a>, then set <var>options</var>'s <a href="#link-options-type" id="processing-link-headers:link-options-type-2">type</a> to <var>attribs</var>["<code id="processing-link-headers:attr-link-type-4"><a href="#attr-link-type">type</a></code>"].</p></li><li><p>If <var>attribs</var>["<code id="processing-link-headers:attr-link-fetchpriority-2"><a href="#attr-link-fetchpriority">fetchpriority</a></code>"]
   <a href="https://infra.spec.whatwg.org/#map-exists" id="processing-link-headers:map-exists-12" data-x-internal="map-exists">exists</a> and is an <a id="processing-link-headers:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
   a <a href="#fetch-priority-attribute" id="processing-link-headers:fetch-priority-attribute-2">fetch priority attribute</a> keyword, then set <var>options</var>'s <a href="#link-options-fetch-priority" id="processing-link-headers:link-options-fetch-priority-2">fetch priority</a> to that <a href="#fetch-priority-attribute" id="processing-link-headers:fetch-priority-attribute-3">fetch priority
   attribute</a> keyword.</p></li><li><p>Return true.</p></li></ol>
  </div>



  <h5 id="early-hints"><span class="secno">4.2.4.5</span> Early hints<a href="#early-hints" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103" title="The HTTP 103 Early Hints information response may be sent by a server while it is still preparing a response, with hints about the resources that the server is expecting the final response will link. This allows a browser to start preloading resources even before the server has prepared and sent that final response.">Status/103</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>preview+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>103+</span></span><hr><span class="opera no"><span>Opera</span><span>No</span></span><span class="edge_blink yes"><span>Edge</span><span>103+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p><dfn id="early-hints-2">Early hints</dfn> allow user-agents to perform some operations, such as to speculatively
  load resources that are likely to be used by the document, before the navigation request is fully
  handled by the server and a response code is served. Servers can indicate early hints by serving a
  <a href="https://fetch.spec.whatwg.org/#concept-response" id="early-hints:concept-response" data-x-internal="concept-response">response</a> with a 103 status code before serving the final
  <a href="https://fetch.spec.whatwg.org/#concept-response" id="early-hints:concept-response-2" data-x-internal="concept-response">response</a>.<a href="#refsRFC8297">[RFC8297]</a></p>

  <p class="note">For compatibility reasons <a href="https://httpwg.org/specs/rfc8297.html#security-considerations">early hints are typically
  delivered over HTTP/2 or above</a>, but for readability we use HTTP/1.1-style notation below.</p>

  <div class="example">
   <p>For example, given the following sequence of responses:</p>
   <pre>103 Early Hint
Link: &lt;/image.png&gt;; <a href="#attr-link-rel" id="early-hints:attr-link-rel">rel</a>=<a href="#link-type-preload" id="early-hints:link-type-preload">preload</a>; <a href="#attr-link-as" id="early-hints:attr-link-as">as</a>=image</pre>

   <pre>200 OK
Content-Type: text/html

&lt;!DOCTYPE html&gt;
...
&lt;img src="/image.png"&gt;</pre>

   <p>the image will start loading before the HTML content arrives.</p>
  </div>

  <p class="note">Only the first early hint response served during the navigation is handled, and it
  is discarded if it is succeeded by a cross-origin redirect.</p>

  <p>In addition to the `<code id="early-hints:http-link"><a data-x-internal="http-link" href="https://httpwg.org/specs/rfc8288.html#header">Link</a></code>` headers, it is possible that the 103
  response contains a <a id="early-hints:content-security-policy" href="https://w3c.github.io/webappsec-csp/#content-security-policy-object" data-x-internal="content-security-policy">Content Security Policy</a> header, which is enforced when processing
  the early hint.</p>

  <div class="example">
   <p>For example, given the following sequence of responses:</p>
   <pre>103 Early Hint
Content-Security-Policy: style-src: self;
Link: &lt;/style.css&gt;; <a href="#attr-link-rel" id="early-hints:attr-link-rel-2">rel</a>=<a href="#link-type-preload" id="early-hints:link-type-preload-2">preload</a>; <a href="#attr-link-as" id="early-hints:attr-link-as-2">as</a>=style</pre>

   <pre>103 Early Hint
Link: &lt;/image.png&gt;; <a href="#attr-link-rel" id="early-hints:attr-link-rel-3">rel</a>=<a href="#link-type-preload" id="early-hints:link-type-preload-3">preload</a>; <a href="#attr-link-as" id="early-hints:attr-link-as-3">as</a>=image</pre>

   <pre>302 Redirect
Location: /alternate.html</pre>

   <pre>200 OK
Content-Security-Policy: style-src: none;
Link: &lt;/font.ttf&gt;; <a href="#attr-link-rel" id="early-hints:attr-link-rel-4">rel</a>=<a href="#link-type-preload" id="early-hints:link-type-preload-4">preload</a>; <a href="#attr-link-as" id="early-hints:attr-link-as-4">as</a>=font</pre>

   <p>The font and style would be loaded, and the image will be discarded, as only the first early
   hint response in the final redirect chain is respected. The late <a id="early-hints:content-security-policy-2" href="https://w3c.github.io/webappsec-csp/#content-security-policy-object" data-x-internal="content-security-policy">Content Security
   Policy</a> header comes after the request to fetch the style has already been performed, but
   the style will not be accessible to the document.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="process-early-hint-headers">process early hint headers</dfn> given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="early-hints:concept-response-3" data-x-internal="concept-response">response</a> <var>response</var> and an <a href="#environment" id="early-hints:environment">environment</a>
  <var>reservedEnvironment</var>:</p>

  <p class="note">Early-hint `<code id="early-hints:http-link-2"><a data-x-internal="http-link" href="https://httpwg.org/specs/rfc8288.html#header">Link</a></code>` headers are always processed
  before `<code id="early-hints:http-link-3"><a data-x-internal="http-link" href="https://httpwg.org/specs/rfc8288.html#header">Link</a></code>` headers from the final <a href="https://fetch.spec.whatwg.org/#concept-response" id="early-hints:concept-response-4" data-x-internal="concept-response">response</a>, followed by <code id="early-hints:the-link-element"><a href="#the-link-element">link</a></code> elements. This is
  equivalent to prepending the contents of the early and final `<code id="early-hints:http-link-4"><a data-x-internal="http-link" href="https://httpwg.org/specs/rfc8288.html#header">Link</a></code>` headers to the <code id="early-hints:document"><a href="#document">Document</a></code>'s <code id="early-hints:the-head-element"><a href="#the-head-element">head</a></code> element,
  in respective order.</p>

  <ol><li>
    <p>Let <var>earlyPolicyContainer</var> be the result of <a href="#creating-a-policy-container-from-a-fetch-response" id="early-hints:creating-a-policy-container-from-a-fetch-response">creating a policy container from
    a fetch response</a> given <var>response</var> and <var>reservedEnvironment</var>.</p>

    <p class="note">This allows the early hint <a href="https://fetch.spec.whatwg.org/#concept-response" id="early-hints:concept-response-5" data-x-internal="concept-response">response</a> to
    include a <a id="early-hints:content-security-policy-3" href="https://w3c.github.io/webappsec-csp/#content-security-policy-object" data-x-internal="content-security-policy">Content Security Policy</a> which would be <a href="https://w3c.github.io/webappsec-csp/#enforced" id="early-hints:enforce-the-policy" data-x-internal="enforce-the-policy">enforced</a> when fetching the early hint <a href="https://fetch.spec.whatwg.org/#concept-request" id="early-hints:concept-request" data-x-internal="concept-request">request</a>.</p>
   </li><li><p>Let <var>links</var> be the result of <a href="#extract-links-from-headers" id="early-hints:extract-links-from-headers">extracting links</a> from <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="early-hints:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a>.</p></li><li><p>Let <var>earlyHints</var> be an empty <a id="early-hints:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="early-hints:list-iterate" data-x-internal="list-iterate">For each</a> <var>linkObject</var> in <var>links</var>:</p>

    <p class="note">The moment we receive the early hint link header, we begin <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="early-hints:concept-fetch" data-x-internal="concept-fetch">fetching</a> <var>earlyRequest</var>. If it comes back before the
    <code id="early-hints:document-2"><a href="#document">Document</a></code> is created, we set <var>earlyResponse</var> to the <a href="https://fetch.spec.whatwg.org/#concept-response" id="early-hints:concept-response-6" data-x-internal="concept-response">response</a> of that <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="early-hints:concept-fetch-2" data-x-internal="concept-fetch">fetch</a> and
    once the <code id="early-hints:document-3"><a href="#document">Document</a></code> is created we commit it (by making it available in the <a href="#map-of-preloaded-resources" id="early-hints:map-of-preloaded-resources">map
    of preloaded resources</a> as if it was a <code id="early-hints:the-link-element-2"><a href="#the-link-element">link</a></code> element). If the
    <code id="early-hints:document-4"><a href="#document">Document</a></code> is created first, the <a href="https://fetch.spec.whatwg.org/#concept-response" id="early-hints:concept-response-7" data-x-internal="concept-response">response</a> is
    committed as soon as it becomes available.</p>

    <ol><li><p>Let <var>rel</var> be <var>linkObject</var>["<code>relation_type</code>"].</p></li><li>
      <p>Let <var>options</var> be a new <a href="#link-processing-options" id="early-hints:link-processing-options">link processing options</a> with</p>

      <dl class="props"><dt><a href="#link-options-href" id="early-hints:link-options-href">href</a></dt><dd><var>linkObject</var>["<code>target_uri</code>"]</dd><dt><a href="#link-options-initiator" id="early-hints:link-options-initiator">initiator</a></dt><dd>"<code>early-hint</code>"</dd><dt><a href="#link-options-base-url" id="early-hints:link-options-base-url">base URL</a></dt><dd><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="early-hints:concept-response-url" data-x-internal="concept-response-url">URL</a></dd><dt><a href="#link-options-origin" id="early-hints:link-options-origin">origin</a></dt><dd><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="early-hints:concept-response-url-2" data-x-internal="concept-response-url">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="early-hints:concept-url-origin" data-x-internal="concept-url-origin">origin</a></dd><dt><a href="#link-options-environment" id="early-hints:link-options-environment">environment</a></dt><dd><var>reservedEnvironment</var></dd><dt><a href="#link-options-policy-container" id="early-hints:link-options-policy-container">policy container</a></dt><dd><var>earlyPolicyContainer</var></dd></dl>
     </li><li>
      <p>Let <var>attribs</var> be <var>linkObject</var>["<code>target_attributes</code>"].</p>

      <p class="note">Only the <code id="early-hints:attr-link-as-5"><a href="#attr-link-as">as</a></code>, <code id="early-hints:attr-link-crossorigin"><a href="#attr-link-crossorigin">crossorigin</a></code>, <code id="early-hints:attr-link-integrity"><a href="#attr-link-integrity">integrity</a></code>, and <code id="early-hints:attr-link-type"><a href="#attr-link-type">type</a></code>
      attributes are handled as part of early hint processing. The other ones, in particular <code id="early-hints:attr-link-blocking"><a href="#attr-link-blocking">blocking</a></code>, <code id="early-hints:attr-link-imagesrcset"><a href="#attr-link-imagesrcset">imagesrcset</a></code>, <code id="early-hints:attr-link-imagesizes"><a href="#attr-link-imagesizes">imagesizes</a></code>, and <code id="early-hints:attr-link-media"><a href="#attr-link-media">media</a></code> are only applicable once a <code id="early-hints:document-5"><a href="#document">Document</a></code> is
      created.</p>
     </li><li><p><a href="#apply-link-options-from-parsed-header-attributes" id="early-hints:apply-link-options-from-parsed-header-attributes">Apply link options from parsed header attributes</a> to <var>options</var>
     given <var>attribs</var> and <var>rel</var>. If that returned false, then return.</p></li><li><p>Run the <a href="#process-a-link-header" id="early-hints:process-a-link-header">process a link header</a> steps for <var>rel</var> given
     <var>options</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="early-hints:list-append" data-x-internal="list-append">Append</a> <var>options</var> to
     <var>earlyHints</var>.</p></li></ol>
   </li><li>
    <p>Return the following substeps given <code id="early-hints:document-6"><a href="#document">Document</a></code> <var>doc</var>: <a href="https://infra.spec.whatwg.org/#list-iterate" id="early-hints:list-iterate-2" data-x-internal="list-iterate">for each</a> <var>options</var> in <var>earlyHints</var>:</p>

    <ol><li><p>If <var>options</var>'s <a href="#link-options-on-document-ready" id="early-hints:link-options-on-document-ready">on document ready</a> is null, then set
     <var>options</var>'s <a href="#link-options-document" id="early-hints:link-options-document">document</a> to
     <var>doc</var>.</p></li><li><p>Otherwise, call <var>options</var>'s <a href="#link-options-on-document-ready" id="early-hints:link-options-on-document-ready-2">on document ready</a> with <var>doc</var>.</p></li></ol>
   </li></ol>
  </div>

  

  <h5 id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element"><span class="secno">4.2.4.6</span> Providing users with a means to follow hyperlinks created using the <code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:the-link-element"><a href="#the-link-element">link</a></code>
  element<a href="#providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element" class="self-link"></a></h5>

  <p id="linkui">Interactive user agents may provide users with a means to <a href="#following-hyperlinks-2" id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:following-hyperlinks-2">follow the hyperlinks</a> created using the <code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:the-link-element-2"><a href="#the-link-element">link</a></code> element, somewhere
  within their user interface. Such invocations of the <a href="#following-hyperlinks-2" id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:following-hyperlinks-2-2">follow
  the hyperlink</a> algorithm must set the <i id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:following-userinvolvement"><a href="#following-userinvolvement">userInvolvement</a></i> argument to "<code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:uni-browser-ui"><a href="#uni-browser-ui">browser UI</a></code>". The exact interface is not defined by this
  specification, but it could include the following information (obtained from the element's
  attributes, again as defined below), in some form or another (possibly simplified), for each
  <a href="#hyperlink" id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:hyperlink">hyperlink</a> created with each <code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:the-link-element-3"><a href="#the-link-element">link</a></code> element in the document:</p>

  <ul><li>The relationship between this document and the resource (given by the <code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:attr-link-rel"><a href="#attr-link-rel">rel</a></code> attribute)</li><li>The title of the resource (given by the <code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:attr-link-title"><a href="#attr-link-title">title</a></code>
   attribute).</li><li>The address of the resource (given by the <code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:attr-link-href"><a href="#attr-link-href">href</a></code>
   attribute).</li><li>The language of the resource (given by the <code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:attr-link-hreflang"><a href="#attr-link-hreflang">hreflang</a></code>
   attribute).</li><li>The optimum media for the resource (given by the <code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:attr-link-media"><a href="#attr-link-media">media</a></code>
   attribute).</li></ul>

  <p>User agents could also include other information, such as the type of the resource (as given by
  the <code id="providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:attr-link-type"><a href="#attr-link-type">type</a></code> attribute).</p>




  <h4 id="the-meta-element"><span class="secno">4.2.5</span> The <dfn id="meta" data-dfn-type="element"><code>meta</code></dfn>
  element<a href="#the-meta-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta" title="The <meta> HTML element represents metadata that cannot be represented by other HTML meta-related elements, like <base>, <link>, <script>, <style> or <title>.">Element/meta</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMetaElement" title="The HTMLMetaElement interface contains descriptive metadata about a document provided in HTML as <meta> elements. This interface inherits all of the properties and methods described in the HTMLElement interface.">HTMLMetaElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-meta-element:concept-element-categories">Categories</a>:</dt><dd><a href="#metadata-content-2" id="the-meta-element:metadata-content-2">Metadata content</a>.</dd><dd>If the <code id="the-meta-element:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is present: <a href="#flow-content-2" id="the-meta-element:flow-content-2">flow content</a>.</dd><dd>If the <code id="the-meta-element:names:-the-itemprop-attribute-2"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is present: <a href="#phrasing-content-2" id="the-meta-element:phrasing-content-2">phrasing content</a>.</dd><dt><a href="#concept-element-contexts" id="the-meta-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>If the <code id="the-meta-element:attr-meta-charset"><a href="#attr-meta-charset">charset</a></code> attribute is present, or if the element's <code id="the-meta-element:attr-meta-http-equiv"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute is in the <a href="#attr-meta-http-equiv-content-type" id="the-meta-element:attr-meta-http-equiv-content-type">Encoding declaration state</a>: in a <code id="the-meta-element:the-head-element"><a href="#the-head-element">head</a></code> element.</dd><dd>If the <code id="the-meta-element:attr-meta-http-equiv-2"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute is present but not in the <a href="#attr-meta-http-equiv-content-type" id="the-meta-element:attr-meta-http-equiv-content-type-2">Encoding declaration state</a>: in a <code id="the-meta-element:the-head-element-2"><a href="#the-head-element">head</a></code> element.</dd><dd>If the <code id="the-meta-element:attr-meta-http-equiv-3"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute is present but not in the <a href="#attr-meta-http-equiv-content-type" id="the-meta-element:attr-meta-http-equiv-content-type-3">Encoding declaration state</a>: in a <code id="the-meta-element:the-noscript-element"><a href="#the-noscript-element">noscript</a></code> element that is a child of a <code id="the-meta-element:the-head-element-3"><a href="#the-head-element">head</a></code> element.</dd><dd>If the <code id="the-meta-element:attr-meta-name"><a href="#attr-meta-name">name</a></code> attribute is present: where <a href="#metadata-content-2" id="the-meta-element:metadata-content-2-2">metadata content</a> is expected.</dd><dd>If the <code id="the-meta-element:names:-the-itemprop-attribute-3"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is present: where <a href="#metadata-content-2" id="the-meta-element:metadata-content-2-3">metadata content</a> is expected.</dd><dd>If the <code id="the-meta-element:names:-the-itemprop-attribute-4"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is present: where <a href="#phrasing-content-2" id="the-meta-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-meta-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-meta-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-meta-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-meta-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-meta-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-meta-element:global-attributes">Global attributes</a></dd><dd><code id="the-meta-element:attr-meta-name-2"><a href="#attr-meta-name">name</a></code> —  Metadata name
     </dd><dd><code id="the-meta-element:attr-meta-http-equiv-4"><a href="#attr-meta-http-equiv">http-equiv</a></code> —  Pragma directive
     </dd><dd><code id="the-meta-element:attr-meta-content"><a href="#attr-meta-content">content</a></code> —  Value of the element
     </dd><dd><code id="the-meta-element:attr-meta-charset-2"><a href="#attr-meta-charset">charset</a></code> —  <a href="#character-encoding-declaration" id="the-meta-element:character-encoding-declaration">Character encoding declaration</a>
     </dd><dd><code id="the-meta-element:attr-meta-media"><a href="#attr-meta-media">media</a></code> —  Applicable media
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-meta-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-meta">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-meta">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-meta-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlmetaelement" data-dfn-type="interface"><c- g="">HTMLMetaElement</c-></dfn> : <a href="#htmlelement" id="the-meta-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-meta-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-meta-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-meta-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMetaElement" id="dom-meta-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="the-meta-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-meta-element:xattr-reflect-2">Reflect</a>="<a href="#attr-meta-http-equiv" id="the-meta-element:attr-meta-http-equiv-5">http-equiv</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMetaElement" id="dom-meta-httpequiv" data-dfn-type="attribute"><c- g="">httpEquiv</c-></dfn>;
  [<a href="#cereactions" id="the-meta-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-meta-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMetaElement" id="dom-meta-content" data-dfn-type="attribute"><c- g="">content</c-></dfn>;
  [<a href="#cereactions" id="the-meta-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-meta-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMetaElement" id="dom-meta-media" data-dfn-type="attribute"><c- g="">media</c-></dfn>;

  // <a href="#HTMLMetaElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-meta-element:the-meta-element"><a href="#the-meta-element">meta</a></code> element <a href="#represents" id="the-meta-element:represents">represents</a> various kinds of metadata that cannot be
  expressed using the <code id="the-meta-element:the-title-element"><a href="#the-title-element">title</a></code>, <code id="the-meta-element:the-base-element"><a href="#the-base-element">base</a></code>, <code id="the-meta-element:the-link-element"><a href="#the-link-element">link</a></code>, <code id="the-meta-element:the-style-element"><a href="#the-style-element">style</a></code>,
  and <code id="the-meta-element:the-script-element"><a href="#the-script-element">script</a></code> elements.</p>

  <p>The <code id="the-meta-element:the-meta-element-2"><a href="#the-meta-element">meta</a></code> element can represent document-level metadata with the <code id="the-meta-element:attr-meta-name-3"><a href="#attr-meta-name">name</a></code> attribute, pragma directives with the <code id="the-meta-element:attr-meta-http-equiv-6"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute, and the file's <a href="#character-encoding-declaration" id="the-meta-element:character-encoding-declaration-2">character encoding
  declaration</a> when an HTML document is serialized to string form (e.g. for transmission over
  the network or for disk storage) with the <code id="the-meta-element:attr-meta-charset-3"><a href="#attr-meta-charset">charset</a></code>
  attribute.</p>

  <p>Exactly one of the <code id="the-meta-element:attr-meta-name-4"><a href="#attr-meta-name">name</a></code>, <code id="the-meta-element:attr-meta-http-equiv-7"><a href="#attr-meta-http-equiv">http-equiv</a></code>, <code id="the-meta-element:attr-meta-charset-4"><a href="#attr-meta-charset">charset</a></code>,
  and <code id="the-meta-element:names:-the-itemprop-attribute-5"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attributes must be specified.</p>

  <p>If either <code id="the-meta-element:attr-meta-name-5"><a href="#attr-meta-name">name</a></code>, <code id="the-meta-element:attr-meta-http-equiv-8"><a href="#attr-meta-http-equiv">http-equiv</a></code>, or <code id="the-meta-element:names:-the-itemprop-attribute-6"><a href="#names:-the-itemprop-attribute">itemprop</a></code> is
  specified, then the <code id="the-meta-element:attr-meta-content-2"><a href="#attr-meta-content">content</a></code> attribute must also be
  specified. Otherwise, it must be omitted.</p>

  <p>The <dfn data-dfn-for="meta" id="attr-meta-charset" data-dfn-type="element-attr"><code>charset</code></dfn>
  attribute specifies the <a href="https://encoding.spec.whatwg.org/#encoding" id="the-meta-element:encoding" data-x-internal="encoding">character encoding</a> used by the document.
  This is a <a href="#character-encoding-declaration" id="the-meta-element:character-encoding-declaration-3">character encoding declaration</a>. If the attribute is present, its value must
  be an <a id="the-meta-element:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>utf-8</code>".</p>

  <p class="note">The <code id="the-meta-element:attr-meta-charset-5"><a href="#attr-meta-charset">charset</a></code> attribute on the
  <code id="the-meta-element:the-meta-element-3"><a href="#the-meta-element">meta</a></code> element has no effect in XML documents, but is allowed in XML documents in order
  to facilitate migration to and from XML.</p>

  <p>There must not be more than one <code id="the-meta-element:the-meta-element-4"><a href="#the-meta-element">meta</a></code> element with a <code id="the-meta-element:attr-meta-charset-6"><a href="#attr-meta-charset">charset</a></code> attribute per document.</p>

  <p>The <dfn data-dfn-for="meta" id="attr-meta-content" data-dfn-type="element-attr"><code>content</code></dfn>
  attribute gives the value of the document metadata or pragma directive when the element is used
  for those purposes. The allowed values depend on the exact context, as described in subsequent
  sections of this specification.</p>

  <p>If a <code id="the-meta-element:the-meta-element-5"><a href="#the-meta-element">meta</a></code> element has a <dfn data-dfn-for="meta" id="attr-meta-name" data-dfn-type="element-attr"><code>name</code></dfn> attribute, it sets document metadata. Document metadata
  is expressed in terms of name-value pairs, the <code id="the-meta-element:attr-meta-name-6"><a href="#attr-meta-name">name</a></code> attribute
  on the <code id="the-meta-element:the-meta-element-6"><a href="#the-meta-element">meta</a></code> element giving the name, and the <code id="the-meta-element:attr-meta-content-3"><a href="#attr-meta-content">content</a></code> attribute on the same element giving the value. The name
  specifies what aspect of metadata is being set; valid names and the meaning of their values are
  described in the following sections. If a <code id="the-meta-element:the-meta-element-7"><a href="#the-meta-element">meta</a></code> element has no <code id="the-meta-element:attr-meta-content-4"><a href="#attr-meta-content">content</a></code> attribute, then the value part of the metadata
  name-value pair is the empty string.</p>

  <p>The <dfn data-dfn-for="meta" id="attr-meta-media" data-dfn-type="element-attr"><code>media</code></dfn> attribute
  says which media the metadata applies to. The value must be a <a href="#valid-media-query-list" id="the-meta-element:valid-media-query-list">valid media query list</a>.
  Unless the <code id="the-meta-element:attr-meta-name-7"><a href="#attr-meta-name">name</a></code> is <code id="the-meta-element:meta-theme-color"><a href="#meta-theme-color">theme-color</a></code>, the <code id="the-meta-element:attr-meta-media-2"><a href="#attr-meta-media">media</a></code>
  attribute has no effect on the processing model and must not be used by authors.</p>


  <h5 id="standard-metadata-names"><span class="secno">4.2.5.1</span> Standard metadata names<a href="#standard-metadata-names" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name" title="The <meta> element can be used to provide document metadata in terms of name-value pairs, with the name attribute giving the metadata name, and the content attribute giving the value.">Element/meta/name</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <p>This specification defines a few names for the <code id="standard-metadata-names:attr-meta-name"><a href="#attr-meta-name">name</a></code>
  attribute of the <code id="standard-metadata-names:the-meta-element"><a href="#the-meta-element">meta</a></code> element.</p>

  <p>Names are case-insensitive<span class="impl">, and must be compared in an <a id="standard-metadata-names:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> manner</span>.</p>

  <dl><dt><dfn data-dfn-for="meta/name" id="meta-application-name" data-dfn-type="attr-value"><code>application-name</code></dfn></dt><dd>
    <p>The value must be a short free-form string giving the name of the web application that the
    page represents. If the page is not a web application, the <code id="standard-metadata-names:meta-application-name"><a href="#meta-application-name">application-name</a></code> metadata name must not be used.
    Translations of the web application's name may be given, using the <code id="standard-metadata-names:attr-lang"><a href="#attr-lang">lang</a></code> attribute to specify the language of each name.</p>

    <p>There must not be more than one <code id="standard-metadata-names:the-meta-element-2"><a href="#the-meta-element">meta</a></code> element with a given <a href="#language" id="standard-metadata-names:language">language</a>
    and where the <code id="standard-metadata-names:attr-meta-name-2"><a href="#attr-meta-name">name</a></code> attribute value is an
    <a id="standard-metadata-names:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
    <code id="standard-metadata-names:meta-application-name-2"><a href="#meta-application-name">application-name</a></code> per document.</p>

    

    <p>User agents may use the application name in UI in preference to the page's
    <code id="standard-metadata-names:the-title-element"><a href="#the-title-element">title</a></code>, since the title might include status messages and the like relevant to the
    status of the page at a particular moment in time instead of just being the name of the
    application.</p>

    <div data-algorithm="">
    <p>To find the application name to use given an ordered list of languages (e.g. British English,
    American English, and English), user agents must run the following steps:</p>

    <ol><li><p>Let <var>languages</var> be the list of languages.</p></li><li><p>Let <var>default language</var> be the <a href="#language" id="standard-metadata-names:language-2">language</a> of the
     <code id="standard-metadata-names:document"><a href="#document">Document</a></code>'s <a id="standard-metadata-names:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>, if any, and if that language is not
     unknown.</p>

     </li><li><p>If there is a <var>default language</var>, and if it is not the same language
     as any of the languages in <var>languages</var>, append it to <var>languages</var>.</p></li><li>
      <p>Let <var>winning language</var> be the first language in <var>languages</var> for which
      there is a <code id="standard-metadata-names:the-meta-element-3"><a href="#the-meta-element">meta</a></code> element in the <code id="standard-metadata-names:document-2"><a href="#document">Document</a></code> where the
      <code id="standard-metadata-names:attr-meta-name-3"><a href="#attr-meta-name">name</a></code> attribute value is an
      <a id="standard-metadata-names:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
      <code id="standard-metadata-names:meta-application-name-3"><a href="#meta-application-name">application-name</a></code> and whose
      <a href="#language" id="standard-metadata-names:language-3">language</a> is the language in question.</p>

      <p>If none of the languages have such a <code id="standard-metadata-names:the-meta-element-4"><a href="#the-meta-element">meta</a></code> element, then return;
      there's no given application name.</p>
     </li><li>
      <p>Return the value of the <code id="standard-metadata-names:attr-meta-content"><a href="#attr-meta-content">content</a></code> attribute of the
      first <code id="standard-metadata-names:the-meta-element-5"><a href="#the-meta-element">meta</a></code> element in the <code id="standard-metadata-names:document-3"><a href="#document">Document</a></code> in <a id="standard-metadata-names:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> where the
      <code id="standard-metadata-names:attr-meta-name-4"><a href="#attr-meta-name">name</a></code> attribute value is an
      <a id="standard-metadata-names:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for <code id="standard-metadata-names:meta-application-name-4"><a href="#meta-application-name">application-name</a></code>
      and whose <a href="#language" id="standard-metadata-names:language-4">language</a> is <var>winning language</var>.</p>
     </li></ol>
    </div>

    <p class="note">This algorithm would be used by a browser when it needs a name for the page, for
    instance, to label a bookmark. The languages it would provide to the algorithm would be the
    user's preferred languages.</p>

    
   </dd><dt><dfn data-dfn-for="meta/name" id="meta-author" data-dfn-type="attr-value"><code>author</code></dfn></dt><dd><p>The value must be a free-form string giving the name of one of the page's
   authors.</p></dd><dt><dfn data-dfn-for="meta/name" id="meta-description" data-dfn-type="attr-value"><code>description</code></dfn></dt><dd><p>The value must be a free-form string that describes the page. The value must be
   appropriate for use in a directory of pages, e.g. in a search engine. There must not be more than
   one <code id="standard-metadata-names:the-meta-element-6"><a href="#the-meta-element">meta</a></code> element where the <code id="standard-metadata-names:attr-meta-name-5"><a href="#attr-meta-name">name</a></code> attribute value
   is an <a id="standard-metadata-names:ascii-case-insensitive-5" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
   <code id="standard-metadata-names:meta-description"><a href="#meta-description">description</a></code> per document.</p></dd><dt><dfn data-dfn-for="meta/name" id="meta-generator" data-dfn-type="attr-value"><code>generator</code></dfn></dt><dd>
    <p>The value must be a free-form string that identifies one of the software packages used to
    generate the document. This value must not be used on pages whose markup is not generated by
    software, e.g. pages whose markup was written by a user in a text editor.</p>

    <div class="example">

     <p>Here is what a tool called "Frontweaver" could include in its output, in the page's
     <code id="standard-metadata-names:the-head-element"><a href="#the-head-element">head</a></code> element, to identify itself as the tool used to generate the page:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">generator</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"Frontweaver 8.2"</c-><c- p="">&gt;</c-></code></pre>

    </div>
   </dd><dt><dfn data-dfn-for="meta/name" id="meta-keywords" data-dfn-type="attr-value"><code>keywords</code></dfn></dt><dd>
    <p>The value must be a <a href="#set-of-comma-separated-tokens" id="standard-metadata-names:set-of-comma-separated-tokens">set of comma-separated tokens</a>, each of which is a keyword
    relevant to the page.</p>

    <div class="example">

     <p>This page about typefaces on British motorways uses a <code id="standard-metadata-names:the-meta-element-7"><a href="#the-meta-element">meta</a></code> element to specify
     some keywords that users might use to look for the page:</p>

     <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-GB"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Typefaces on UK motorways<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"keywords"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"british,type face,font,fonts,highway,highways"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  ...</code></pre>

    </div>

    <p class="note">Many search engines do not consider such keywords, because this feature has
    historically been used unreliably and even misleadingly as a way to spam search engine results
    in a way that is not helpful for users.</p>

    

    <div data-algorithm="">
    <p>To obtain the list of keywords that the author has specified as applicable to the page, the
    user agent must run the following steps:</p>

    <ol><li><p>Let <var>keywords</var> be an empty list.</p></li><li>
      <p>For each <code id="standard-metadata-names:the-meta-element-8"><a href="#the-meta-element">meta</a></code> element with a <code id="standard-metadata-names:attr-meta-name-6"><a href="#attr-meta-name">name</a></code>
      attribute and a <code id="standard-metadata-names:attr-meta-content-2"><a href="#attr-meta-content">content</a></code> attribute and where the <code id="standard-metadata-names:attr-meta-name-7"><a href="#attr-meta-name">name</a></code> attribute value is an <a id="standard-metadata-names:ascii-case-insensitive-6" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>
      match for <code id="standard-metadata-names:meta-keywords"><a href="#meta-keywords">keywords</a></code>:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#split-on-commas" id="standard-metadata-names:split-a-string-on-commas" data-x-internal="split-a-string-on-commas">Split the value of the element's <code>content</code> attribute on commas</a>.</p></li><li><p>Add the resulting tokens, if any, to <var>keywords</var>.</p></li></ol>
     </li><li><p>Remove any duplicates from <var>keywords</var>.</p></li><li><p>Return <var>keywords</var>. This is the list of keywords that the author has
     specified as applicable to the page.</p></li></ol>
    </div>

    <p>User agents should not use this information when there is insufficient confidence in the
    reliability of the value.</p>

    <p class="example">For instance, it would be reasonable for a content management system to use
    the keyword information of pages within the system to populate the index of a site-specific
    search engine, but a large-scale content aggregator that used this information would likely find
    that certain users would try to game its ranking mechanism through the use of inappropriate
    keywords.</p>

    
   </dd><dt><dfn data-dfn-for="meta/name" id="meta-referrer" data-dfn-type="attr-value"><code>referrer</code></dfn></dt><dd>
    <p>The value must be a <a id="standard-metadata-names:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>, which defines the default <a id="standard-metadata-names:referrer-policy-2" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer
    policy</a> for the <code id="standard-metadata-names:document-4"><a href="#document">Document</a></code>. <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p>

    

    <div data-algorithm="">
    <p>If any <code id="standard-metadata-names:the-meta-element-9"><a href="#the-meta-element">meta</a></code> element <var>element</var> is <a href="#insert-an-element-into-a-document" id="standard-metadata-names:insert-an-element-into-a-document">inserted into the document</a>, or has its <code id="standard-metadata-names:attr-meta-name-8"><a href="#attr-meta-name">name</a></code> or <code id="standard-metadata-names:attr-meta-content-3"><a href="#attr-meta-content">content</a></code>
    attributes changed, user agents must run the following algorithm:</p>

    <ol><li><p>If <var>element</var> is not <a id="standard-metadata-names:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>, then return.</p></li><li><p>If <var>element</var> does not have a <code id="standard-metadata-names:attr-meta-name-9"><a href="#attr-meta-name">name</a></code>
     attribute whose value is an <a id="standard-metadata-names:ascii-case-insensitive-7" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code id="standard-metadata-names:meta-referrer"><a href="#meta-referrer">referrer</a></code>", then return.</p></li><li><p>If <var>element</var> does not have a <code id="standard-metadata-names:attr-meta-content-4"><a href="#attr-meta-content">content</a></code>
     attribute, or that attribute's value is the empty string, then return.</p></li><li><p>Let <var>value</var> be the value of <var>element</var>'s <code id="standard-metadata-names:attr-meta-content-5"><a href="#attr-meta-content">content</a></code> attribute, <a id="standard-metadata-names:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
     lowercase</a>.</p></li><li>
      <p>If <var>value</var> is one of the values given in the first column of the following table,
      then set <var>value</var> to the value given in the second column:</p>

      <table><thead><tr><th>Legacy value
         </th><th>Referrer policy
       </th></tr></thead><tbody><tr><td><code>never</code>
         </td><td><code id="standard-metadata-names:referrer-policy-no-referrer"><a data-x-internal="referrer-policy-no-referrer" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer">no-referrer</a></code>
        </td></tr><tr><td><code>default</code>
         </td><td>the <a id="standard-metadata-names:default-referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#default-referrer-policy" data-x-internal="default-referrer-policy">default referrer policy</a>
        </td></tr><tr><td><code>always</code>
         </td><td><code id="standard-metadata-names:referrer-policy-unsafe-url"><a data-x-internal="referrer-policy-unsafe-url" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-unsafe-url">unsafe-url</a></code>
        </td></tr><tr><td><code>origin-when-crossorigin</code>
         </td><td><code id="standard-metadata-names:referrer-policy-origin-when-cross-origin"><a data-x-internal="referrer-policy-origin-when-cross-origin" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-origin-when-cross-origin">origin-when-cross-origin</a></code>
      </td></tr></tbody></table>
     </li><li><p>If <var>value</var> is a <a id="standard-metadata-names:referrer-policy-3" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>, then set <var>element</var>'s
     <a id="standard-metadata-names:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#concept-document-policy-container" id="standard-metadata-names:concept-document-policy-container">policy
     container</a>'s <a href="#policy-container-referrer-policy" id="standard-metadata-names:policy-container-referrer-policy">referrer policy</a> to
     <var>policy</var>.</p></li></ol>
    </div>

    <p class="note">For historical reasons, unlike other standard metadata names, the processing
    model for <code id="standard-metadata-names:meta-referrer-2"><a href="#meta-referrer">referrer</a></code> is not responsive to element removals,
    and does not use <a id="standard-metadata-names:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>. Only the most-recently-inserted or
    most-recently-modified <code id="standard-metadata-names:the-meta-element-10"><a href="#the-meta-element">meta</a></code> element in this state has an effect.</p>

    
   </dd><dt><dfn data-dfn-for="meta/name" id="meta-theme-color" data-dfn-type="attr-value"><code>theme-color</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color" title="The theme-color value for the name attribute of the <meta> element indicates a suggested color that user agents should use to customize the display of the page or of the surrounding user interface. If specified, the content attribute must contain a valid CSS <color>.">Element/meta/name/theme-color</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span title="Partial implementation.">🔰 73+</span></span><hr><span class="opera no"><span>Opera</span><span>No</span></span><span class="edge_blink yes"><span>Edge</span><span title="Partial implementation.">🔰 79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>80+</span></span><span class="webview_android no"><span>WebView Android</span><span>No</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>6.2+</span></span><span class="opera_android no"><span>Opera Android</span><span>No</span></span></div></div></div></dt><dd>
    <p>The value must be a string that matches the CSS <a id="standard-metadata-names:color" href="https://drafts.csswg.org/css-color/#typedef-color" data-x-internal="color">&lt;color&gt;</a> production, defining
    a suggested color that user agents should use to customize the display of the page or of the
    surrounding user interface. For example, a browser might color the page's title bar with the
    specified value, or use it as a color highlight in a tab bar or task switcher.</p>

    <p>Within an HTML document, the <code id="standard-metadata-names:attr-meta-media"><a href="#attr-meta-media">media</a></code> attribute value must
    be unique amongst all the <code id="standard-metadata-names:the-meta-element-11"><a href="#the-meta-element">meta</a></code> elements with their <code id="standard-metadata-names:attr-meta-name-10"><a href="#attr-meta-name">name</a></code> attribute value set to an <a id="standard-metadata-names:ascii-case-insensitive-8" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
    case-insensitive</a> match for <code id="standard-metadata-names:meta-theme-color"><a href="#meta-theme-color">theme-color</a></code>.</p>

    <div class="example">

     <p>This standard itself uses "WHATWG green" as its theme color:</p>

     <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->HTML Standard<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"theme-color"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"#3c790a"</c-><c- p="">&gt;</c->
...</code></pre>

    </div>

    <p>The <code id="standard-metadata-names:attr-meta-media-2"><a href="#attr-meta-media">media</a></code> attribute may be used to describe the context
    in which the provided color should be used.</p>

    <div class="example">
     <p>If we only wanted to use "WHATWG green" as this standard's theme color in dark mode,
     we could use the <code>prefers-color-scheme</code> media feature:</p>

     <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->HTML Standard<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"theme-color"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"#3c790a"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(prefers-color-scheme: dark)"</c-><c- p="">&gt;</c->
...</code></pre>
    </div>

    

     <div data-algorithm="">
     <p>To obtain a page's theme color, user agents must run the following steps:</p>

     <ol><li>
       <p>Let <var>candidate elements</var> be the list of all <code id="standard-metadata-names:the-meta-element-12"><a href="#the-meta-element">meta</a></code> elements that
       meet the following criteria, in <a id="standard-metadata-names:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

       <ul><li><p>the element is <a id="standard-metadata-names:in-a-document-tree-2" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>;</p></li><li><p>the element has a <code id="standard-metadata-names:attr-meta-name-11"><a href="#attr-meta-name">name</a></code> attribute, whose value
        is an <a id="standard-metadata-names:ascii-case-insensitive-9" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for <code id="standard-metadata-names:meta-theme-color-2"><a href="#meta-theme-color">theme-color</a></code>; and</p></li><li><p>the element has a <code id="standard-metadata-names:attr-meta-content-6"><a href="#attr-meta-content">content</a></code> attribute.</p></li></ul>
      </li><li>
       <p>For each <var>element</var> in <var>candidate elements</var>:</p>

       <ol><li><p>If <var>element</var> has a <code id="standard-metadata-names:attr-link-media"><a href="#attr-link-media">media</a></code> attribute
        and the value of <var>element</var>'s <code id="standard-metadata-names:attr-meta-media-3"><a href="#attr-meta-media">media</a></code>
        attribute does not <a href="#matches-the-environment" id="standard-metadata-names:matches-the-environment">match the environment</a>, then
        <a id="standard-metadata-names:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>value</var> be the result of <a href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" id="standard-metadata-names:strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">stripping leading and trailing ASCII whitespace</a> from the value of
        <var>element</var>'s <code id="standard-metadata-names:attr-meta-content-7"><a href="#attr-meta-content">content</a></code> attribute.</p></li><li><p>Let <var>color</var> be the result of <a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value" id="standard-metadata-names:parsed-as-a-css-color-value" data-x-internal="parsed-as-a-css-color-value">parsing</a> <var>value</var>.</p></li><li><p>If <var>color</var> is not failure, then return <var>color</var>.</p></li></ol>
      </li><li><p>Return nothing (the page has no theme color).</p></li></ol>
     </div>

     <p>If any <code id="standard-metadata-names:the-meta-element-13"><a href="#the-meta-element">meta</a></code> elements are <a href="#insert-an-element-into-a-document" id="standard-metadata-names:insert-an-element-into-a-document-2">inserted into the document</a> or <a href="#remove-an-element-from-a-document" id="standard-metadata-names:remove-an-element-from-a-document">removed from the document</a>, or existing <code id="standard-metadata-names:the-meta-element-14"><a href="#the-meta-element">meta</a></code> elements have their
     <code id="standard-metadata-names:attr-meta-name-12"><a href="#attr-meta-name">name</a></code>, <code id="standard-metadata-names:attr-meta-content-8"><a href="#attr-meta-content">content</a></code>, or
     <code id="standard-metadata-names:attr-link-media-2"><a href="#attr-link-media">media</a></code> attributes changed, or if the environment changes
     such that any <code id="standard-metadata-names:the-meta-element-15"><a href="#the-meta-element">meta</a></code> element's <code id="standard-metadata-names:attr-link-media-3"><a href="#attr-link-media">media</a></code>
     attribute's value may now or may no longer <a href="#matches-the-environment" id="standard-metadata-names:matches-the-environment-2">match the
     environment</a>, user agents must re-run the above algorithm and apply the result to any
     affected UI.</p>

    

    <p>When using the theme color in UI, user agents may adjust it in implementation-specific ways
    to make it more suitable for the UI in question. For example, if a user agent intends to use
    the theme color as a background and display white text over it, it might use a darker variant of
    the theme color in that part of the UI, to ensure adequate contrast.</p>
   </dd><dt><dfn data-dfn-for="meta/name" id="meta-color-scheme" data-dfn-type="attr-value"><code>color-scheme</code></dfn></dt><dd>
    <p>To aid user agents in rendering the page background with the desired color scheme immediately
    (rather than waiting for all CSS in the page to load), a <a id="standard-metadata-names:'color-scheme'" href="https://drafts.csswg.org/css-color-adjust/#color-scheme-prop" data-x-internal="'color-scheme'">'color-scheme'</a> value can
    be provided in a <code id="standard-metadata-names:the-meta-element-16"><a href="#the-meta-element">meta</a></code> element.</p>

    <p>The value must be a string that matches the syntax for the CSS <a id="standard-metadata-names:'color-scheme'-2" href="https://drafts.csswg.org/css-color-adjust/#color-scheme-prop" data-x-internal="'color-scheme'">'color-scheme'</a>
    property value. It determines the <a id="standard-metadata-names:page's-supported-color-schemes" href="https://drafts.csswg.org/css-color-adjust/#pages-supported-color-schemes" data-x-internal="page's-supported-color-schemes">page's supported color-schemes</a>.</p>

    <p>There must not be more than one <code id="standard-metadata-names:the-meta-element-17"><a href="#the-meta-element">meta</a></code> element with its <code id="standard-metadata-names:attr-meta-name-13"><a href="#attr-meta-name">name</a></code> attribute value set to an
    <a id="standard-metadata-names:ascii-case-insensitive-10" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for <code id="standard-metadata-names:meta-color-scheme"><a href="#meta-color-scheme">color-scheme</a></code> per document.</p>

    <div class="example">
     <p>The following declaration indicates that the page is aware of and can handle a color scheme
     with dark background colors and light foreground colors:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"color-scheme"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"dark"</c-><c- p="">&gt;</c-></code></pre>
    </div>

    

     <div data-algorithm="">
     <p>To obtain a <a id="standard-metadata-names:page's-supported-color-schemes-2" href="https://drafts.csswg.org/css-color-adjust/#pages-supported-color-schemes" data-x-internal="page's-supported-color-schemes">page's supported color-schemes</a>, user agents must run the following steps:</p>

     <ol><li>
       <p>Let <var>candidate elements</var> be the list of all <code id="standard-metadata-names:the-meta-element-18"><a href="#the-meta-element">meta</a></code> elements that
       meet the following criteria, in <a id="standard-metadata-names:tree-order-4" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

       <ul><li><p>the element is <a id="standard-metadata-names:in-a-document-tree-3" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>;</p></li><li><p>the element has a <code id="standard-metadata-names:attr-meta-name-14"><a href="#attr-meta-name">name</a></code> attribute, whose value
        is an <a id="standard-metadata-names:ascii-case-insensitive-11" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for <code id="standard-metadata-names:meta-color-scheme-2"><a href="#meta-color-scheme">color-scheme</a></code>; and</p></li><li><p>the element has a <code id="standard-metadata-names:attr-meta-content-9"><a href="#attr-meta-content">content</a></code> attribute.</p></li></ul>
      </li><li>
       <p>For each <var>element</var> in <var>candidate elements</var>:</p>

       <ol><li>Let <var>parsed</var> be the result of <a href="https://drafts.csswg.org/css-syntax/#parse-a-list-of-component-values" id="standard-metadata-names:parse-a-list-of-component-values" data-x-internal="parse-a-list-of-component-values">parsing a list of component values</a> given the value of <var>element</var>'s
        <code id="standard-metadata-names:attr-meta-content-10"><a href="#attr-meta-content">content</a></code> attribute.</li><li>If <var>parsed</var> is a valid CSS <a id="standard-metadata-names:'color-scheme'-3" href="https://drafts.csswg.org/css-color-adjust/#color-scheme-prop" data-x-internal="'color-scheme'">'color-scheme'</a> property value, then
        return <var>parsed</var>.</li></ol>
      </li><li><p>Return null.</p></li></ol>
     </div>

     <p>If any <code id="standard-metadata-names:the-meta-element-19"><a href="#the-meta-element">meta</a></code> elements are <a href="#insert-an-element-into-a-document" id="standard-metadata-names:insert-an-element-into-a-document-3">inserted into the document</a> or <a href="#remove-an-element-from-a-document" id="standard-metadata-names:remove-an-element-from-a-document-2">removed from the document</a>, or existing <code id="standard-metadata-names:the-meta-element-20"><a href="#the-meta-element">meta</a></code> elements have their
     <code id="standard-metadata-names:attr-meta-name-15"><a href="#attr-meta-name">name</a></code> or <code id="standard-metadata-names:attr-meta-content-11"><a href="#attr-meta-content">content</a></code>
     attributes changed, user agents must re-run the above algorithm.</p>

    

    <p class="note">Because these rules check successive elements until they find a match, an
    author can provide multiple such values to handle fallback for legacy user agents. Opposite to
    how CSS fallback works for properties, the multiple meta elements needs to be arranged with the
    legacy values after the newer values.</p>
   </dd></dl>



  <h5 id="other-metadata-names"><span class="secno">4.2.5.2</span> Other metadata names<a href="#other-metadata-names" class="self-link"></a></h5>

  <p>Anyone can create and use their own <dfn id="concept-meta-extensions">extensions to the
  predefined set of metadata names</dfn>. There is no requirement to register such extensions.</p>

  <p>However, a new metadata name should not be created in any of the following cases:</p>

  <ul><li><p>If either the name is a <a id="other-metadata-names:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, or the value of its accompanying <code id="other-metadata-names:attr-meta-content"><a href="#attr-meta-content">content</a></code> attribute is a <a id="other-metadata-names:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>; in those cases,
   registering it as an <a href="#concept-rel-extensions" id="other-metadata-names:concept-rel-extensions">extension to the predefined set of
   link types</a> is encouraged (rather than creating a new metadata name).</p></li><li><p>If the name is for something expected to have processing requirements in user agents; in
   that case it ought to be standardized.</p></li></ul>

  <p>Also, before creating and using a new metadata name, consulting the <a href="https://wiki.whatwg.org/wiki/MetaExtensions">WHATWG Wiki MetaExtensions page</a> is
  encouraged — to avoid choosing a metadata name that's already in use, and to avoid duplicating the
  purpose of any metadata names that are already in use, and to avoid new standardized names
  clashing with your chosen name. <a href="#refsWHATWGWIKI">[WHATWGWIKI]</a></p>

  <p>Anyone is free to edit the WHATWG Wiki MetaExtensions page at any time to add a metadata name.
  New metadata names can be specified with the following information:</p>

  <dl><dt>Keyword</dt><dd><p>The actual name being defined. The name should not be confusingly similar to any other
   defined name (e.g. differing only in case).</p></dd><dt>Brief description</dt><dd><p>A short non-normative description of what the metadata name's meaning is, including the
   format the value is required to be in.</p></dd><dt>Specification</dt><dd>A link to a more detailed description of the metadata name's semantics and requirements. It
   could be another page on the wiki, or a link to an external page.</dd><dt>Synonyms</dt><dd><p>A list of other names that have exactly the same processing requirements. Authors should
   not use the names defined to be synonyms (they are only intended to allow user agents to support
   legacy content). Anyone may remove synonyms that are not used in practice; only names that need to
   be processed as synonyms for compatibility with legacy content are to be registered in this
   way.</p></dd><dt>Status</dt><dd>
    <p>One of the following:</p>

    <dl><dt>Proposed</dt><dd>The name has not received wide peer review and approval. Someone has proposed it and is, or
     soon will be, using it.</dd><dt>Ratified</dt><dd>The name has received wide peer review and approval. It has a specification that
     unambiguously defines how to handle pages that use the name, including when they use it in
     incorrect ways.</dd><dt>Discontinued</dt><dd>The metadata name has received wide peer review and it has been found wanting. Existing
     pages are using this metadata name, but new pages should avoid it. The "brief description" and
     "specification" entries will give details of what authors should use instead, if anything.</dd></dl>

    <p>If a metadata name is found to be redundant with existing values, it should be removed and
    listed as a synonym for the existing value.</p>

    <p>If a metadata name is added in the "proposed" state for a period of a month or more without
    being used or specified, then it may be removed from the WHATWG Wiki MetaExtensions page.</p>

    <p>If a metadata name is added with the "proposed" status and found to be redundant with
    existing values, it should be removed and listed as a synonym for the existing value. If a
    metadata name is added with the "proposed" status and found to be harmful, then it should be
    changed to "discontinued" status.</p>

    <p>Anyone can change the status at any time, but should only do so in accordance with the
    definitions above.</p>
   </dd></dl>



  <h5 id="pragma-directives"><span class="secno">4.2.5.3</span> Pragma directives<a href="#pragma-directives" class="self-link"></a></h5>

  <p>When the <dfn data-dfn-for="meta" id="attr-meta-http-equiv" data-dfn-type="element-attr"><code>http-equiv</code></dfn> attribute is specified on a
  <code id="pragma-directives:the-meta-element"><a href="#the-meta-element">meta</a></code> element, the element is a pragma directive.</p>

  <div id="warning-http-equiv-unrelated-to-http-headers" class="warning">
   <p>Despite the name <code id="pragma-directives:attr-meta-http-equiv"><a href="#attr-meta-http-equiv">http-equiv</a></code>, pragma directives are
   almost entirely unrelated to HTTP headers. Implementers and web developers are best off thinking
   of them as entirely separate, and the name as being a historical accident.</p>

   <p>In more detail, although the <code id="pragma-directives:attr-meta-http-equiv-refresh"><a href="#attr-meta-http-equiv-refresh">refresh</a></code>
   keyword has the same processing model as the corresponding `<code id="pragma-directives:refresh"><a href="#refresh">Refresh</a></code>` header, every
   other standardized pragma directive has at least slightly different behavior than the
   similarly-named header. (And usually dramatically-different behavior.)</p>

   <p>Implementers or specification writers contemplating adding new document-level pragmas or HTTP
   header-controlled switches should be cautious about this mismatch, and avoid perpetuating the
   existing confusion by adding the same or similar behavior to both an HTTP header and an <code id="pragma-directives:attr-meta-http-equiv-2"><a href="#attr-meta-http-equiv">http-equiv</a></code> pragma. Instead, consider providing only an HTTP
   header, or if an in-document pragma is needed, consider adding a new attribute to
   <code id="pragma-directives:the-meta-element-2"><a href="#the-meta-element">meta</a></code> similar to the model used by the <code id="pragma-directives:attr-meta-charset"><a href="#attr-meta-charset">charset</a></code> attribute. (Note that avoiding in-document pragmas is
   often the better choice, since the DOM is mutable. Thus, even in the simple case where the
   developer does not add, remove, or mutate <code id="pragma-directives:the-meta-element-3"><a href="#the-meta-element">meta</a></code> elements, the policy will go from
   un-applied to applied during parsing, which can have complex implications.)</p>
  </div>

  <p>The <code id="pragma-directives:attr-meta-http-equiv-3"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute is an <a href="#enumerated-attribute" id="pragma-directives:enumerated-attribute">enumerated
  attribute</a> with the following keywords and states:</p>

  <table id="table-http-equiv" class="yesno"><thead><tr><th>Keyword
     </th><th>Conforming
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="meta/http-equiv" id="attr-meta-http-equiv-keyword-content-language" data-dfn-type="attr-value"><code>content-language</code></dfn>
     </td><td class="no">No
     </td><td><a href="#attr-meta-http-equiv-content-language" id="pragma-directives:attr-meta-http-equiv-content-language">Content language</a>
     </td><td>Sets the <a href="#pragma-set-default-language" id="pragma-directives:pragma-set-default-language">pragma-set default language</a>.
    </td></tr><tr><td><dfn data-dfn-for="meta/http-equiv" id="attr-meta-http-equiv-keyword-content-type" data-dfn-type="attr-value"><code>content-type</code></dfn>
     </td><td>
     </td><td><a href="#attr-meta-http-equiv-content-type" id="pragma-directives:attr-meta-http-equiv-content-type">Encoding declaration</a>
     </td><td>An alternative form of setting the <code id="pragma-directives:attr-meta-charset-2"><a href="#attr-meta-charset">charset</a></code>.
    </td></tr><tr><td><dfn data-dfn-for="meta/http-equiv" id="attr-meta-http-equiv-keyword-default-style" data-dfn-type="attr-value"><code>default-style</code></dfn>
     </td><td>
     </td><td><a href="#attr-meta-http-equiv-default-style" id="pragma-directives:attr-meta-http-equiv-default-style">Default style</a>
     </td><td>Sets the <a href="https://drafts.csswg.org/cssom/#css-style-sheet-set-name" id="pragma-directives:css-style-sheet-set-name" data-x-internal="css-style-sheet-set-name">name</a> of the default
     <a id="pragma-directives:css-style-sheet-set" href="https://drafts.csswg.org/cssom/#css-style-sheet-set" data-x-internal="css-style-sheet-set">CSS style sheet set</a>.
    </td></tr><tr><td><dfn data-dfn-for="meta/http-equiv" id="attr-meta-http-equiv-keyword-refresh" data-dfn-type="attr-value"><code>refresh</code></dfn>
     </td><td>
     </td><td><a href="#attr-meta-http-equiv-refresh" id="pragma-directives:attr-meta-http-equiv-refresh-2">Refresh</a>
     </td><td>Acts as a timed redirect.
    </td></tr><tr><td><dfn data-dfn-for="meta/http-equiv" id="attr-meta-http-equiv-keyword-set-cookie" data-dfn-type="attr-value"><code>set-cookie</code></dfn>
     </td><td class="no">No
     </td><td><a href="#attr-meta-http-equiv-set-cookie" id="pragma-directives:attr-meta-http-equiv-set-cookie">Set-Cookie</a>
     </td><td>Has no effect.
    </td></tr><tr><td><dfn data-dfn-for="meta/http-equiv" id="attr-meta-http-equiv-keyword-x-ua-compatible" data-dfn-type="attr-value"><code>x-ua-compatible</code></dfn>
     </td><td>
     </td><td><a href="#attr-meta-http-equiv-x-ua-compatible" id="pragma-directives:attr-meta-http-equiv-x-ua-compatible">X-UA-Compatible</a>
     </td><td>In practice, encourages Internet Explorer to more closely follow the specifications.
    </td></tr><tr><td><dfn data-dfn-for="meta/http-equiv" id="attr-meta-http-equiv-keyword-content-security-policy" data-dfn-type="attr-value"><code>content-security-policy</code></dfn>
     </td><td>
     </td><td><a href="#attr-meta-http-equiv-content-security-policy" id="pragma-directives:attr-meta-http-equiv-content-security-policy">Content security policy</a>
     </td><td><a href="https://w3c.github.io/webappsec-csp/#enforced" id="pragma-directives:enforce-the-policy" data-x-internal="enforce-the-policy">Enforces</a> a <a id="pragma-directives:content-security-policy" href="https://w3c.github.io/webappsec-csp/#content-security-policy-object" data-x-internal="content-security-policy">Content Security
     Policy</a> on a <code id="pragma-directives:document"><a href="#document">Document</a></code>.
  </td></tr></tbody></table>



  <div data-algorithm="">

  

  <p>When a <code id="pragma-directives:the-meta-element-4"><a href="#the-meta-element">meta</a></code> element is <a href="#insert-an-element-into-a-document" id="pragma-directives:insert-an-element-into-a-document">inserted
  into the document</a>, if its <code id="pragma-directives:attr-meta-http-equiv-4"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute is
  present and represents one of the above states, then the user agent must run the algorithm
  appropriate for that state, as described in the following list:</p>

  

  <dl><dt><dfn id="attr-meta-http-equiv-content-language">Content language state</dfn>
   (<code>http-equiv="<code id="pragma-directives:attr-meta-http-equiv-keyword-content-language"><a href="#attr-meta-http-equiv-keyword-content-language">content-language</a></code>"</code>)

   </dt><dd>

    <p class="note">This feature is non-conforming. Authors are encouraged to use the <code id="pragma-directives:attr-lang"><a href="#attr-lang">lang</a></code> attribute instead.</p>

    <p>This pragma sets the <dfn id="pragma-set-default-language">pragma-set default language</dfn>. Until such a pragma is
    successfully processed, there is no <a href="#pragma-set-default-language" id="pragma-directives:pragma-set-default-language-2">pragma-set default language</a>.</p>

    

    <ol><li><p>If the <code id="pragma-directives:the-meta-element-5"><a href="#the-meta-element">meta</a></code> element has no <code id="pragma-directives:attr-meta-content"><a href="#attr-meta-content">content</a></code>
     attribute, then return.</p></li><li><p>If the element's <code id="pragma-directives:attr-meta-content-2"><a href="#attr-meta-content">content</a></code> attribute contains a
     U+002C COMMA character (,), then return.</p></li><li><p>Let <var>input</var> be the value of the element's <code id="pragma-directives:attr-meta-content-3"><a href="#attr-meta-content">content</a></code> attribute.</p></li><li><p>Let <var>position</var> point at the first character of <var>input</var>.</p></li><li><p><a id="pragma-directives:skip-ascii-whitespace" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
     <var>position</var>.</p></li><li><p><a id="pragma-directives:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are not <a id="pragma-directives:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
     whitespace</a> from <var>input</var> given <var>position</var>.</p></li><li><p>Let <var>candidate</var> be the string that resulted from the previous
     step.</p></li><li><p>If <var>candidate</var> is the empty string, return.</p></li><li>
      <p>Set the <a href="#pragma-set-default-language" id="pragma-directives:pragma-set-default-language-3">pragma-set default language</a> to <var>candidate</var>.</p>

      <p class="note">If the value consists of multiple space-separated tokens, tokens after the
      first are ignored.</p>
     </li></ol>

    <p class="note">This pragma is almost, but not quite, entirely unlike the HTTP `<code id="pragma-directives:http-content-language"><a data-x-internal="http-content-language" href="https://httpwg.org/specs/rfc7231.html#header.content-language">Content-Language</a></code>` header of the same name.
    <a href="#refsHTTP">[HTTP]</a></p>
   </dd><dt><dfn id="attr-meta-http-equiv-content-type">Encoding declaration state</dfn> (<code>http-equiv="<code id="pragma-directives:attr-meta-http-equiv-keyword-content-type"><a href="#attr-meta-http-equiv-keyword-content-type">content-type</a></code>"</code>)

   </dt><dd>
    <p>The <a href="#attr-meta-http-equiv-content-type" id="pragma-directives:attr-meta-http-equiv-content-type-2">Encoding declaration state</a> is
    just an alternative form of setting the <code id="pragma-directives:attr-meta-charset-3"><a href="#attr-meta-charset">charset</a></code>
    attribute: it is a <a href="#character-encoding-declaration" id="pragma-directives:character-encoding-declaration">character encoding declaration</a>. This state's user
    agent requirements are all handled by the parsing section of the specification.</p>

    <p>For <code id="pragma-directives:the-meta-element-6"><a href="#the-meta-element">meta</a></code> elements with an <code id="pragma-directives:attr-meta-http-equiv-5"><a href="#attr-meta-http-equiv">http-equiv</a></code>
    attribute in the <a href="#attr-meta-http-equiv-content-type" id="pragma-directives:attr-meta-http-equiv-content-type-3">Encoding declaration
    state</a>, the <code id="pragma-directives:attr-meta-content-4"><a href="#attr-meta-content">content</a></code> attribute must have a value
    that is an <a id="pragma-directives:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for a string that consists of:
    "<code>text/html;</code>", optionally followed by any number of <a id="pragma-directives:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
    whitespace</a>, followed by "<code>charset=utf-8</code>".</p>

    <p>A document must not contain both a <code id="pragma-directives:the-meta-element-7"><a href="#the-meta-element">meta</a></code> element with an <code id="pragma-directives:attr-meta-http-equiv-6"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute in the <a href="#attr-meta-http-equiv-content-type" id="pragma-directives:attr-meta-http-equiv-content-type-4">Encoding declaration state</a> and a
    <code id="pragma-directives:the-meta-element-8"><a href="#the-meta-element">meta</a></code> element with the <code id="pragma-directives:attr-meta-charset-4"><a href="#attr-meta-charset">charset</a></code> attribute
    present.</p>

    <p>The <a href="#attr-meta-http-equiv-content-type" id="pragma-directives:attr-meta-http-equiv-content-type-5">Encoding declaration state</a> may be
    used in <a id="pragma-directives:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>, but elements with an <code id="pragma-directives:attr-meta-http-equiv-7"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute in that state must not be used in
    <a id="pragma-directives:xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a>.</p>
   </dd><dt><dfn id="attr-meta-http-equiv-default-style">Default style state</dfn> (<code>http-equiv="<code id="pragma-directives:attr-meta-http-equiv-keyword-default-style"><a href="#attr-meta-http-equiv-keyword-default-style">default-style</a></code>"</code>)

   <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Alternative_style_sheets" title="Specifying alternative style sheets in a web page provides a way for users to see multiple versions of a page, based on their needs or preferences.">Alternative_style_sheets</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari unknown"><span>Safari</span><span>?</span></span><span class="chrome no"><span>Chrome</span><span>1–48</span></span><hr><span class="opera yes"><span>Opera</span><span>Yes</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>This pragma sets the <a href="https://drafts.csswg.org/cssom/#css-style-sheet-set-name" id="pragma-directives:css-style-sheet-set-name-2" data-x-internal="css-style-sheet-set-name">name</a> of the default
    <a id="pragma-directives:css-style-sheet-set-2" href="https://drafts.csswg.org/cssom/#css-style-sheet-set" data-x-internal="css-style-sheet-set">CSS style sheet set</a>.</p>

    

    <ol><li><p>If the <code id="pragma-directives:the-meta-element-9"><a href="#the-meta-element">meta</a></code> element has no <code id="pragma-directives:attr-meta-content-5"><a href="#attr-meta-content">content</a></code>
     attribute, or if that attribute's value is the empty string, then return.</p></li><li><p><a id="pragma-directives:change-the-preferred-css-style-sheet-set-name" href="https://drafts.csswg.org/cssom/#change-the-preferred-css-style-sheet-set-name" data-x-internal="change-the-preferred-css-style-sheet-set-name">Change the preferred CSS style sheet set name</a> with the name being the value
     of the element's <code id="pragma-directives:attr-meta-content-6"><a href="#attr-meta-content">content</a></code> attribute.
     <a href="#refsCSSOM">[CSSOM]</a></p></li></ol>

    
   </dd><dt><dfn id="attr-meta-http-equiv-refresh">Refresh state</dfn> (<code>http-equiv="<code id="pragma-directives:attr-meta-http-equiv-keyword-refresh"><a href="#attr-meta-http-equiv-keyword-refresh">refresh</a></code>"</code>)

   </dt><dd>
    <p>This pragma acts as a timed redirect.</p>

    <p>A <code id="pragma-directives:document-2"><a href="#document">Document</a></code> object has an associated <dfn data-dfn-for="Document" id="will-declaratively-refresh">will declaratively
    refresh</dfn> (a boolean). It is initially false.</p>

    

    <ol><li><p>If the <code id="pragma-directives:the-meta-element-10"><a href="#the-meta-element">meta</a></code> element has no <code id="pragma-directives:attr-meta-content-7"><a href="#attr-meta-content">content</a></code>
     attribute, or if that attribute's value is the empty string, then return.</p></li><li><p>Let <var>input</var> be the value of the element's <code id="pragma-directives:attr-meta-content-8"><a href="#attr-meta-content">content</a></code> attribute.</p></li><li><p>Run the <a href="#shared-declarative-refresh-steps" id="pragma-directives:shared-declarative-refresh-steps">shared declarative refresh steps</a> with the <code id="pragma-directives:the-meta-element-11"><a href="#the-meta-element">meta</a></code>
     element's <a id="pragma-directives:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, <var>input</var>, and the <code id="pragma-directives:the-meta-element-12"><a href="#the-meta-element">meta</a></code>
     element.</p></li></ol>

    <p>The <dfn id="shared-declarative-refresh-steps">shared declarative refresh steps</dfn>, given a <code id="pragma-directives:document-3"><a href="#document">Document</a></code> object
    <var>document</var>, string <var>input</var>, and optionally a <code id="pragma-directives:the-meta-element-13"><a href="#the-meta-element">meta</a></code> element
    <var>meta</var>, are as follows:</p>

    <ol><li><p>If <var>document</var>'s <a href="#will-declaratively-refresh" id="pragma-directives:will-declaratively-refresh">will declaratively refresh</a> is true, then
     return.</p></li><li><p>Let <var>position</var> point at the first <a id="pragma-directives:code-point" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> of
     <var>input</var>.</p></li><li><p><a id="pragma-directives:skip-ascii-whitespace-2" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
     <var>position</var>.</p></li><li><p>Let <var>time</var> be 0.</p></li><li><p><a id="pragma-directives:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="pragma-directives:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
     <var>input</var> given <var>position</var>, and let <var>timeString</var> be the
     result.</p></li><li>
      <p>If <var>timeString</var> is the empty string, then:</p>

      <ol><li><p>If the <a id="pragma-directives:code-point-2" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in <var>input</var> pointed to by <var>position</var>
       is not U+002E (.), then return.</p></li></ol>
     </li><li><p>Otherwise, set <var>time</var> to the result of parsing <var>timeString</var> using the
     <a href="#rules-for-parsing-non-negative-integers" id="pragma-directives:rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a>.</p></li><li><p><a id="pragma-directives:collect-a-sequence-of-code-points-3" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="pragma-directives:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> and
     U+002E FULL STOP characters (.) from <var>input</var> given <var>position</var>. Ignore any
     collected characters.</p></li><li><p>Let <var>urlRecord</var> be <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="pragma-directives:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li>
      <p>If <var>position</var> is not past the end of <var>input</var>, then:</p>

      <ol><li><p>If the <a id="pragma-directives:code-point-3" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in <var>input</var> pointed to by <var>position</var>
       is not U+003B (;), U+002C (,), or <a id="pragma-directives:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, then return.</p></li><li><p><a id="pragma-directives:skip-ascii-whitespace-3" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
       <var>position</var>.</p></li><li><p>If the <a id="pragma-directives:code-point-4" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in <var>input</var> pointed to by <var>position</var>
       is U+003B (;) or U+002C (,), then advance <var>position</var> to the next <a id="pragma-directives:code-point-5" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
       point</a>.</p></li><li><p><a id="pragma-directives:skip-ascii-whitespace-4" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
       <var>position</var>.</p></li></ol>
     </li><li>
      <p>If <var>position</var> is not past the end of <var>input</var>, then:</p>

      <ol><li><p>Let <var>urlString</var> be the substring of <var>input</var> from the
       <a id="pragma-directives:code-point-6" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> at <var>position</var> to the end of the string.</p></li><li><p>If the <a id="pragma-directives:code-point-7" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in <var>input</var> pointed to by <var>position</var>
       is U+0055 (U) or U+0075 (u), then advance <var>position</var> to the next <a id="pragma-directives:code-point-8" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
       point</a>. Otherwise, jump to the step labeled <i>skip quotes</i>.</p></li><li><p>If the <a id="pragma-directives:code-point-9" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in <var>input</var> pointed to by <var>position</var>
       is U+0052 (R) or U+0072 (r), then advance <var>position</var> to the next <a id="pragma-directives:code-point-10" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
       point</a>. Otherwise, jump to the step labeled <i>parse</i>.</p></li><li><p>If the <a id="pragma-directives:code-point-11" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in <var>input</var> pointed to by <var>position</var>
       is U+004C (L) or U+006C (l), then advance <var>position</var> to the next <a id="pragma-directives:code-point-12" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
       point</a>. Otherwise, jump to the step labeled <i>parse</i>.</p></li><li><p><a id="pragma-directives:skip-ascii-whitespace-5" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
       <var>position</var>.</p></li><li><p>If the <a id="pragma-directives:code-point-13" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in <var>input</var> pointed to by <var>position</var>
       is U+003D (=), then advance <var>position</var> to the next <a id="pragma-directives:code-point-14" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a>.
       Otherwise, jump to the step labeled <i>parse</i>.</p></li><li><p><a id="pragma-directives:skip-ascii-whitespace-6" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
       <var>position</var>.</p></li><li><p><i>Skip quotes</i>: If the <a id="pragma-directives:code-point-15" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in <var>input</var> pointed to by
       <var>position</var> is U+0027 (') or U+0022 ("), then let <var>quote</var> be that <a id="pragma-directives:code-point-16" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
       point</a>, and advance <var>position</var> to the next <a id="pragma-directives:code-point-17" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a>. Otherwise,
       let <var>quote</var> be the empty string.</p></li><li><p>Set <var>urlString</var> to the substring of <var>input</var> from the <a id="pragma-directives:code-point-18" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
       point</a> at <var>position</var> to the end of the string.</p></li><li><p>If <var>quote</var> is not the empty string, and there is a <a id="pragma-directives:code-point-19" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in
       <var>urlString</var> equal to <var>quote</var>, then truncate <var>urlString</var> at that
       <a id="pragma-directives:code-point-20" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a>, so that it and all subsequent <a href="https://infra.spec.whatwg.org/#code-point" id="pragma-directives:code-point-21" data-x-internal="code-point">code
       points</a> are removed.</p>

       </li><li><p><i>Parse</i>: Set <var>urlRecord</var> to the result of <a href="#encoding-parsing-a-url" id="pragma-directives:encoding-parsing-a-url">encoding-parsing a
       URL</a> given <var>urlString</var>, relative to <var>document</var>.</p></li><li><p>If <var>urlRecord</var> is failure, then return.</p></li></ol>
     </li><li><p>Set <var>document</var>'s <a href="#will-declaratively-refresh" id="pragma-directives:will-declaratively-refresh-2">will declaratively refresh</a> to true.</p></li><li>
      <p>Perform one or more of the following steps:</p>

      <ul><li>
        <p>After the refresh has come due (as defined below), if the user has not canceled the
        redirect and, if <var>meta</var> is given, <var>document</var>'s <a href="#active-sandboxing-flag-set" id="pragma-directives:active-sandboxing-flag-set">active sandboxing
        flag set</a> does not have the <a href="#sandboxed-automatic-features-browsing-context-flag" id="pragma-directives:sandboxed-automatic-features-browsing-context-flag">sandboxed automatic features browsing context
        flag</a> set, then <a href="#navigate" id="pragma-directives:navigate">navigate</a>
        <var>document</var>'s <a href="#node-navigable" id="pragma-directives:node-navigable">node navigable</a> to <var>urlRecord</var> using
        <var>document</var>, with <i id="pragma-directives:navigation-hh"><a href="#navigation-hh">historyHandling</a></i> set to "<code id="pragma-directives:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p>

        <p>For the purposes of the previous paragraph, a refresh is said to have come due as soon as
        the <em>later</em> of the following two conditions occurs:</p>

        <ul><li>At least <var>time</var> seconds have elapsed since <var>document</var>'s
         <a href="#completely-loaded-time" id="pragma-directives:completely-loaded-time">completely loaded time</a>, adjusted to take into account user or user agent
         preferences.</li><li>If <var>meta</var> is given, at least <var>time</var> seconds have elapsed since
         <var>meta</var> was <a href="#insert-an-element-into-a-document" id="pragma-directives:insert-an-element-into-a-document-2">inserted into the
         document</a> <var>document</var>, adjusted to take into account user or user agent
         preferences.</li></ul>

        <p class="note">It is important to use <var>document</var> here, and not <var>meta</var>'s
        <a id="pragma-directives:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, as that might have changed between the initial set of steps and
        the refresh coming due and <var>meta</var> is not always given (in case of the HTTP
        `<code id="pragma-directives:refresh-2"><a href="#refresh">Refresh</a></code>` header).</p>
       </li><li><p>Provide the user with an interface that, when selected, <a href="#navigate" id="pragma-directives:navigate-2">navigates</a> <var>document</var>'s <a href="#node-navigable" id="pragma-directives:node-navigable-2">node
       navigable</a> to <var>urlRecord</var> using <var>document</var>.</p></li><li><p>Do nothing.</p></li></ul>

      <p>In addition, the user agent may, as with anything, inform the user of any and all aspects
      of its operation, including the state of any timers, the destinations of any timed redirects,
      and so forth.</p>
     </li></ol>

    

    <p id="conformance-attr-meta-http-equiv-refresh">For <code id="pragma-directives:the-meta-element-14"><a href="#the-meta-element">meta</a></code> elements with an <code id="pragma-directives:attr-meta-http-equiv-8"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute in the <a href="#attr-meta-http-equiv-refresh" id="pragma-directives:attr-meta-http-equiv-refresh-3">Refresh state</a>, the <code id="pragma-directives:attr-meta-content-9"><a href="#attr-meta-content">content</a></code> attribute must have a value consisting either of:</p>

    <ul><li>just a <a href="#valid-non-negative-integer" id="pragma-directives:valid-non-negative-integer">valid non-negative integer</a>, or</li><li>a <a href="#valid-non-negative-integer" id="pragma-directives:valid-non-negative-integer-2">valid non-negative integer</a>, followed by a U+003B SEMICOLON character
     (;), followed by one or more <a id="pragma-directives:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, followed by a substring that is
     an <a id="pragma-directives:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>URL</code>",
     followed by a U+003D EQUALS SIGN character (=), followed by a <a id="pragma-directives:valid-url-string" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL string</a>
     that does not start with a literal U+0027 APOSTROPHE (') or U+0022 QUOTATION MARK (")
     character.</li></ul>

    <p>In the former case, the integer represents a number of seconds before the page is to be
    reloaded; in the latter case the integer represents a number of seconds before the page is to be
    replaced by the page at the given <a id="pragma-directives:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p>

    <div class="example">
     <p>A news organization's front page could include the following markup in the page's
     <code id="pragma-directives:the-head-element"><a href="#the-head-element">head</a></code> element, to ensure that the page automatically reloads from the server every
     five minutes:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">http-equiv</c-><c- o="">=</c-><c- s="">"Refresh"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"300"</c-><c- p="">&gt;</c-></code></pre>
    </div>

    <div class="example">
     <p>A sequence of pages could be used as an automated slide show by making each page refresh to
     the next page in the sequence, using markup such as the following:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">http-equiv</c-><c- o="">=</c-><c- s="">"Refresh"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"20; URL=page4.html"</c-><c- p="">&gt;</c-></code></pre>
    </div>
   </dd><dt><dfn id="attr-meta-http-equiv-set-cookie">Set-Cookie state</dfn> (<code>http-equiv="<code id="pragma-directives:attr-meta-http-equiv-keyword-set-cookie"><a href="#attr-meta-http-equiv-keyword-set-cookie">set-cookie</a></code>"</code>)

   </dt><dd>
    <p>This pragma is non-conforming and has no effect.</p>

    <p>User agents are required to ignore this pragma.</p>
   </dd><dt><dfn id="attr-meta-http-equiv-x-ua-compatible">X-UA-Compatible state</dfn> (<code>http-equiv="<code id="pragma-directives:attr-meta-http-equiv-keyword-x-ua-compatible"><a href="#attr-meta-http-equiv-keyword-x-ua-compatible">x-ua-compatible</a></code>"</code>)

   </dt><dd>
    <p>In practice, this pragma encourages Internet Explorer to more closely follow the
    specifications.</p>

    <p>For <code id="pragma-directives:the-meta-element-15"><a href="#the-meta-element">meta</a></code> elements with an <code id="pragma-directives:attr-meta-http-equiv-9"><a href="#attr-meta-http-equiv">http-equiv</a></code>
    attribute in the <a href="#attr-meta-http-equiv-x-ua-compatible" id="pragma-directives:attr-meta-http-equiv-x-ua-compatible-2">X-UA-Compatible state</a>, the
    <code id="pragma-directives:attr-meta-content-10"><a href="#attr-meta-content">content</a></code> attribute must have a value that is an
    <a id="pragma-directives:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>IE=edge</code>".</p>

    <p>User agents are required to ignore this pragma.</p>
   </dd><dt><dfn id="attr-meta-http-equiv-content-security-policy" data-export="">Content security policy state</dfn> (<code>http-equiv="<code id="pragma-directives:attr-meta-http-equiv-keyword-content-security-policy"><a href="#attr-meta-http-equiv-keyword-content-security-policy">content-security-policy</a></code>"</code>)

   </dt><dd>
    <p>This pragma <a href="https://w3c.github.io/webappsec-csp/#enforced" id="pragma-directives:enforce-the-policy-2" data-x-internal="enforce-the-policy">enforces</a> a <a id="pragma-directives:content-security-policy-2" href="https://w3c.github.io/webappsec-csp/#content-security-policy-object" data-x-internal="content-security-policy">Content Security
    Policy</a> on a <code id="pragma-directives:document-4"><a href="#document">Document</a></code>. <a href="#refsCSP">[CSP]</a></p>

    

    <ol><li><p>If the <code id="pragma-directives:the-meta-element-16"><a href="#the-meta-element">meta</a></code> element is not a child of a <code id="pragma-directives:the-head-element-2"><a href="#the-head-element">head</a></code> element,
     return.</p></li><li><p>If the <code id="pragma-directives:the-meta-element-17"><a href="#the-meta-element">meta</a></code> element has no <code id="pragma-directives:attr-meta-content-11"><a href="#attr-meta-content">content</a></code>
     attribute, or if that attribute's value is the empty string, then return.</p></li><li><p>Let <var>policy</var> be the result of executing Content Security Policy's <a id="pragma-directives:parse-a-serialized-content-security-policy" href="https://w3c.github.io/webappsec-csp/#parse-serialized-policy" data-x-internal="parse-a-serialized-content-security-policy">parse
     a serialized Content Security Policy</a> algorithm on the <code id="pragma-directives:the-meta-element-18"><a href="#the-meta-element">meta</a></code> element's
     <code id="pragma-directives:attr-meta-content-12"><a href="#attr-meta-content">content</a></code> attribute's value, with a source of "meta",
     and a disposition of "enforce".</p></li><li><p>Remove all occurrences of the <code id="pragma-directives:report-uri-directive"><a data-x-internal="report-uri-directive" href="https://w3c.github.io/webappsec-csp/#report-uri">report-uri</a></code>, <code id="pragma-directives:frame-ancestors-directive"><a data-x-internal="frame-ancestors-directive" href="https://w3c.github.io/webappsec-csp/#frame-ancestors">frame-ancestors</a></code>, and <code id="pragma-directives:sandbox-directive"><a data-x-internal="sandbox-directive" href="https://w3c.github.io/webappsec-csp/#sandbox">sandbox</a></code> <a href="https://w3c.github.io/webappsec-csp/#directives" id="pragma-directives:content-security-policy-directive" data-x-internal="content-security-policy-directive">directives</a> from <var>policy</var>.</p></li><li><p><a id="pragma-directives:enforce-the-policy-3" href="https://w3c.github.io/webappsec-csp/#enforced" data-x-internal="enforce-the-policy">Enforce the policy</a> <var>policy</var>.</p></li></ol>

    

    <p>For <code id="pragma-directives:the-meta-element-19"><a href="#the-meta-element">meta</a></code> elements with an <code id="pragma-directives:attr-meta-http-equiv-10"><a href="#attr-meta-http-equiv">http-equiv</a></code>
    attribute in the <a href="#attr-meta-http-equiv-content-security-policy" id="pragma-directives:attr-meta-http-equiv-content-security-policy-2">Content security
    policy state</a>, the <code id="pragma-directives:attr-meta-content-13"><a href="#attr-meta-content">content</a></code> attribute must have a
    value consisting of a <a href="https://w3c.github.io/webappsec-csp/#grammardef-serialized-policy" id="pragma-directives:content-security-policy-syntax" data-x-internal="content-security-policy-syntax">valid Content Security
    Policy</a>, but must not contain any <code id="pragma-directives:report-uri-directive-2"><a data-x-internal="report-uri-directive" href="https://w3c.github.io/webappsec-csp/#report-uri">report-uri</a></code>,
    <code id="pragma-directives:frame-ancestors-directive-2"><a data-x-internal="frame-ancestors-directive" href="https://w3c.github.io/webappsec-csp/#frame-ancestors">frame-ancestors</a></code>, or <code id="pragma-directives:sandbox-directive-2"><a data-x-internal="sandbox-directive" href="https://w3c.github.io/webappsec-csp/#sandbox">sandbox</a></code> <a href="https://w3c.github.io/webappsec-csp/#directives" id="pragma-directives:content-security-policy-directive-2" data-x-internal="content-security-policy-directive">directives</a>.
    The <a id="pragma-directives:content-security-policy-3" href="https://w3c.github.io/webappsec-csp/#content-security-policy-object" data-x-internal="content-security-policy">Content Security Policy</a> given in the <code id="pragma-directives:attr-meta-content-14"><a href="#attr-meta-content">content</a></code> attribute will be <a href="https://w3c.github.io/webappsec-csp/#enforced" id="pragma-directives:enforce-the-policy-4" data-x-internal="enforce-the-policy">enforced</a> upon the current document. <a href="#refsCSP">[CSP]</a></p>

    <p class="note">At the time of inserting the <code id="pragma-directives:the-meta-element-20"><a href="#the-meta-element">meta</a></code> element to the document, it is
    possible that some resources have already been fetched. For example, images might be stored in
    the <a href="#list-of-available-images" id="pragma-directives:list-of-available-images">list of available images</a> prior to dynamically inserting a <code id="pragma-directives:the-meta-element-21"><a href="#the-meta-element">meta</a></code>
    element with an <code id="pragma-directives:attr-meta-http-equiv-11"><a href="#attr-meta-http-equiv">http-equiv</a></code> attribute in the <a href="#attr-meta-http-equiv-content-security-policy" id="pragma-directives:attr-meta-http-equiv-content-security-policy-3">Content security policy state</a>.
    Resources that have already been fetched are not guaranteed to be blocked by a <a id="pragma-directives:content-security-policy-4" href="https://w3c.github.io/webappsec-csp/#content-security-policy-object" data-x-internal="content-security-policy">Content
    Security Policy</a> that's <a href="https://w3c.github.io/webappsec-csp/#enforced" id="pragma-directives:enforce-the-policy-5" data-x-internal="enforce-the-policy">enforced</a> late.</p>

    <div class="example">

     <p>A page might choose to mitigate the risk of cross-site scripting attacks by preventing the
     execution of inline JavaScript, as well as blocking all plugin content, using a policy such
     as the following:

     </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">http-equiv</c-><c- o="">=</c-><c- s="">"Content-Security-Policy"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"script-src 'self'; object-src 'none'"</c-><c- p="">&gt;</c-></code></pre>

    </div>
   </dd></dl>

  </div>

  <p>There must not be more than one <code id="pragma-directives:the-meta-element-22"><a href="#the-meta-element">meta</a></code> element with any particular state in the
  document at a time.</p>


  <h5 id="charset"><span class="secno">4.2.5.4</span> Specifying the document's character encoding<a href="#charset" class="self-link"></a></h5>

  

  <p>A <dfn id="character-encoding-declaration">character encoding declaration</dfn> is a mechanism by which the <a href="https://encoding.spec.whatwg.org/#encoding" id="charset:encoding" data-x-internal="encoding">character encoding</a> used to store or transmit a document is specified.</p>

  <p>The Encoding standard requires use of the <a id="charset:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a> <a href="https://encoding.spec.whatwg.org/#encoding" id="charset:encoding-2" data-x-internal="encoding">character
  encoding</a> and requires use of the "<code>utf-8</code>" <a id="charset:encoding-label" href="https://encoding.spec.whatwg.org/#label" data-x-internal="encoding-label">encoding label</a>
  to identify it. Those requirements necessitate that the document's <a href="#character-encoding-declaration" id="charset:character-encoding-declaration">character encoding
  declaration</a>, if it exists, specifies an <a id="charset:encoding-label-2" href="https://encoding.spec.whatwg.org/#label" data-x-internal="encoding-label">encoding label</a> using an <a id="charset:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for "<code>utf-8</code>". Regardless of whether a
  <a href="#character-encoding-declaration" id="charset:character-encoding-declaration-2">character encoding declaration</a> is present or not, the actual <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="charset:document's-character-encoding" data-x-internal="document's-character-encoding">character encoding</a> used to encode the document must be
  <a id="charset:utf-8-2" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>. <a href="#refsENCODING">[ENCODING]</a></p>

  <p>To enforce the above rules, authoring tools must default to using <a id="charset:utf-8-3" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>
  for newly-created documents.</p>

  <p>The following restrictions also apply:</p>

  <ul><li>The character encoding declaration must be serialized without the use of <a href="#syntax-charref" id="charset:syntax-charref">character references</a> or character escapes of any kind.</li><li id="charset1024"><span id="charset512">The element containing the character encoding
   declaration must be serialized completely within the first 1024 bytes of the
   document.</span></li></ul>

  <p>In addition, due to a number of restrictions on <code id="charset:the-meta-element"><a href="#the-meta-element">meta</a></code> elements, there can only be
  one <code id="charset:the-meta-element-2"><a href="#the-meta-element">meta</a></code>-based character encoding declaration per document.</p> 

  <div data-algorithm="">
  <p>If an <a href="https://dom.spec.whatwg.org/#html-document" id="charset:html-documents" data-x-internal="html-documents">HTML document</a> does not start with a BOM, and its
  <a id="charset:encoding-3" href="https://encoding.spec.whatwg.org/#encoding" data-x-internal="encoding">encoding</a> is not explicitly given by <a href="#content-type" id="charset:content-type">Content-Type
  metadata</a>, and the document is not <a href="#an-iframe-srcdoc-document" id="charset:an-iframe-srcdoc-document">an <code>iframe</code> <code>srcdoc</code> document</a>, then the encoding must be specified
  using a <code id="charset:the-meta-element-3"><a href="#the-meta-element">meta</a></code> element with a <code id="charset:attr-meta-charset"><a href="#attr-meta-charset">charset</a></code> attribute
  or a <code id="charset:the-meta-element-4"><a href="#the-meta-element">meta</a></code> element with an <code id="charset:attr-meta-http-equiv"><a href="#attr-meta-http-equiv">http-equiv</a></code>
  attribute in the <a href="#attr-meta-http-equiv-content-type" id="charset:attr-meta-http-equiv-content-type">Encoding declaration
  state</a>.</p>
  </div>

  <div class="note">
   <p>A character encoding declaration is required (either in the <a href="#content-type" id="charset:content-type-2">Content-Type metadata</a> or explicitly in the file) even when all
   characters are in the ASCII range, because a character encoding is needed to process non-ASCII
   characters entered by the user in forms, in URLs generated by scripts, and so forth.</p>

   <p>Using non-UTF-8 encodings can have unexpected results on form submission and URL encodings,
   which use the <a id="charset:document's-character-encoding-2" href="https://dom.spec.whatwg.org/#concept-document-encoding" data-x-internal="document's-character-encoding">document's character encoding</a> by default.</p>
  </div>

  <p>If the document is <a href="#an-iframe-srcdoc-document" id="charset:an-iframe-srcdoc-document-2">an <code>iframe</code> <code>srcdoc</code>
  document</a>, the document must not have a <a href="#character-encoding-declaration" id="charset:character-encoding-declaration-3">character encoding declaration</a>. (In
  this case, the source is already decoded, since it is part of the document that contained the
  <code id="charset:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>.)</p>

  <p>In XML, the XML declaration should be used for inline character encoding information, if
  necessary.</p>

  <div class="example">

   <p>In HTML, to declare that the character encoding is <a id="charset:utf-8-4" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>, the author could
   include the following markup near the top of the document (in the <code id="charset:the-head-element"><a href="#the-head-element">head</a></code> element):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c-></code></pre>

   <p>In XML, the XML declaration would be used instead, at the very top of the markup:</p>

   <pre><code class="html"><c- cp="">&lt;?xml version="1.0" encoding="utf-8"?&gt;</c-></code></pre>

  </div>



  <h4 id="the-style-element"><span class="secno">4.2.6</span> The <dfn data-dfn-type="element"><code>style</code></dfn> element<a href="#the-style-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style" title="The <style> HTML element contains style information for a document, or part of a document. It contains CSS, which is applied to the contents of the document containing the <style> element.">Element/style</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLStyleElement" title="The HTMLStyleElement interface represents a <style> element. It inherits properties and methods from its parent, HTMLElement.">HTMLStyleElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLStyleElement/media" title="The HTMLStyleElement.media property specifies the intended destination medium for style information.">HTMLStyleElement/media</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-style-element:concept-element-categories">Categories</a>:</dt><dd><a href="#metadata-content-2" id="the-style-element:metadata-content-2">Metadata content</a>.</dd><dt><a href="#concept-element-contexts" id="the-style-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#metadata-content-2" id="the-style-element:metadata-content-2-2">metadata content</a> is expected.</dd><dd>In a <code id="the-style-element:the-noscript-element"><a href="#the-noscript-element">noscript</a></code> element that is a child of a <code id="the-style-element:the-head-element"><a href="#the-head-element">head</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-style-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#text-content" id="the-style-element:text-content">Text</a> that gives a <a id="the-style-element:conformant-style-sheet" href="https://drafts.csswg.org/css-syntax/#conform-classes" data-x-internal="conformant-style-sheet">conformant style sheet</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-style-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-style-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-style-element:global-attributes">Global attributes</a></dd><dd><code id="the-style-element:attr-style-media"><a href="#attr-style-media">media</a></code> —  Applicable media
     </dd><dd><code id="the-style-element:attr-style-blocking"><a href="#attr-style-blocking">blocking</a></code> —  Whether the element is <a href="#potentially-render-blocking" id="the-style-element:potentially-render-blocking">potentially render-blocking</a>
     </dd><dd>Also, the <code id="the-style-element:attr-style-title"><a href="#attr-style-title">title</a></code> attribute <a href="#attr-style-title" id="the-style-element:attr-style-title-2">has special semantics</a> on this element:  <a id="the-style-element:css-style-sheet-set-name" href="https://drafts.csswg.org/cssom/#css-style-sheet-set-name" data-x-internal="css-style-sheet-set-name">CSS style sheet set name</a>
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-style-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-style">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-style">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-style-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlstyleelement" data-dfn-type="interface"><c- g="">HTMLStyleElement</c-></dfn> : <a href="#htmlelement" id="the-style-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-style-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-style-disabled" id="the-style-element:dom-style-disabled"><c- g="">disabled</c-></a>;
  [<a href="#cereactions" id="the-style-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-style-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLStyleElement" id="dom-style-media" data-dfn-type="attribute"><c- g="">media</c-></dfn>;
  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-style-element:dom-domtokenlist-value" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-style-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-style-element:domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLStyleElement" id="dom-style-blocking" data-dfn-type="attribute"><c- g="">blocking</c-></dfn>;

  // <a href="#HTMLStyleElement-partial">also has obsolete members</a>
};
<a href="#htmlstyleelement" id="the-style-element:htmlstyleelement"><c- n="">HTMLStyleElement</c-></a> <c- b="">includes</c-> <a id="the-style-element:linkstyle" href="https://drafts.csswg.org/cssom/#the-linkstyle-interface" data-x-internal="linkstyle"><c- n="">LinkStyle</c-></a>;</code></pre>
   </dd></dl>

  <p>The <code id="the-style-element:the-style-element"><a href="#the-style-element">style</a></code> element allows authors to embed CSS style sheets in their documents.
  The <code id="the-style-element:the-style-element-2"><a href="#the-style-element">style</a></code> element is one of several inputs to the styling processing
  model. The element does not <a href="#represents" id="the-style-element:represents">represent</a> content for the
  user.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLStyleElement/disabled" title="The HTMLStyleElement.disabled property can be used to get and set whether the stylesheet is disabled (true) or not (false).">HTMLStyleElement/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLStyleElement" id="dom-style-disabled" data-dfn-type="attribute"><code>disabled</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-style-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> does not have an <a id="the-style-element:associated-css-style-sheet" href="https://drafts.csswg.org/cssom/#associated-css-style-sheet" data-x-internal="associated-css-style-sheet">associated CSS style sheet</a>, return
   false.</p></li><li><p>If <a id="the-style-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-style-element:associated-css-style-sheet-2" href="https://drafts.csswg.org/cssom/#associated-css-style-sheet" data-x-internal="associated-css-style-sheet">associated CSS style sheet</a>'s <a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag" id="the-style-element:concept-css-style-sheet-disabled-flag" data-x-internal="concept-css-style-sheet-disabled-flag">disabled flag</a> is set, return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-style-element:dom-style-disabled-2"><a href="#dom-style-disabled">disabled</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-style-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> does not have an <a id="the-style-element:associated-css-style-sheet-3" href="https://drafts.csswg.org/cssom/#associated-css-style-sheet" data-x-internal="associated-css-style-sheet">associated CSS style sheet</a>,
   return.</p></li><li><p>If the given value is true, set <a id="the-style-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-style-element:associated-css-style-sheet-4" href="https://drafts.csswg.org/cssom/#associated-css-style-sheet" data-x-internal="associated-css-style-sheet">associated CSS style
   sheet</a>'s <a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag" id="the-style-element:concept-css-style-sheet-disabled-flag-2" data-x-internal="concept-css-style-sheet-disabled-flag">disabled flag</a>.
   Otherwise, unset <a id="the-style-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-style-element:associated-css-style-sheet-5" href="https://drafts.csswg.org/cssom/#associated-css-style-sheet" data-x-internal="associated-css-style-sheet">associated CSS style sheet</a>'s <a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag" id="the-style-element:concept-css-style-sheet-disabled-flag-3" data-x-internal="concept-css-style-sheet-disabled-flag">disabled flag</a>.</p></li></ol>
  </div>

  <div class="example">
   <p>Importantly, <code id="the-style-element:dom-style-disabled-3"><a href="#dom-style-disabled">disabled</a></code> attribute assignments only take
   effect when the <code id="the-style-element:the-style-element-3"><a href="#the-style-element">style</a></code> element has an <a id="the-style-element:associated-css-style-sheet-6" href="https://drafts.csswg.org/cssom/#associated-css-style-sheet" data-x-internal="associated-css-style-sheet">associated CSS style sheet</a>:</p>

   <pre><code class="js"><c- a="">const</c-> style <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'style'</c-><c- p="">);</c->
style<c- p="">.</c->disabled <c- o="">=</c-> <c- kc="">true</c-><c- p="">;</c->
style<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'body { background-color: red; }'</c-><c- p="">;</c->
document<c- p="">.</c->body<c- p="">.</c->append<c- p="">(</c->style<c- p="">);</c->
console<c- p="">.</c->log<c- p="">(</c->style<c- p="">.</c->disabled<c- p="">);</c-> <c- c1="">// false</c-></code></pre>
  </div>

  <p>The <dfn data-dfn-for="style" id="attr-style-media" data-dfn-type="element-attr"><code>media</code></dfn> attribute
  says which media the styles apply to. The value must be a <a href="#valid-media-query-list" id="the-style-element:valid-media-query-list">valid media query list</a>.
  The user agent must apply the styles when the <code id="the-style-element:attr-style-media-2"><a href="#attr-style-media">media</a></code> attribute's value <a href="#matches-the-environment" id="the-style-element:matches-the-environment">matches the environment</a> and
  the other relevant conditions apply, and must not apply them otherwise.</p>

  

  <p class="note">The styles might be further limited in scope, e.g. in CSS with the use of <code>@media</code> blocks. This specification does not override such further restrictions or
  requirements.</p>

  

  <p id="style-default-media">The default, if the <code id="the-style-element:attr-style-media-3"><a href="#attr-style-media">media</a></code>
  attribute is omitted, is "<code>all</code>", meaning that by default styles apply to all
  media.</p>

  <p>The <dfn data-dfn-for="style" id="attr-style-blocking" data-dfn-type="element-attr"><code>blocking</code></dfn>
  attribute is a <a href="#blocking-attribute" id="the-style-element:blocking-attribute">blocking attribute</a>.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Alternative_style_sheets" title="Specifying alternative style sheets in a web page provides a way for users to see multiple versions of a page, based on their needs or preferences.">Alternative_style_sheets</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari unknown"><span>Safari</span><span>?</span></span><span class="chrome no"><span>Chrome</span><span>1–48</span></span><hr><span class="opera yes"><span>Opera</span><span>Yes</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p id="title-on-style">The <dfn data-dfn-for="style" id="attr-style-title" data-dfn-type="element-attr"><code>title</code></dfn> attribute on <code id="the-style-element:the-style-element-4"><a href="#the-style-element">style</a></code> elements defines
  <a href="https://drafts.csswg.org/cssom/#css-style-sheet-set" id="the-style-element:css-style-sheet-set" data-x-internal="css-style-sheet-set">CSS style sheet sets</a>. If the <code id="the-style-element:the-style-element-5"><a href="#the-style-element">style</a></code> element
  has no <code id="the-style-element:attr-style-title-3"><a href="#attr-style-title">title</a></code> attribute, then it has no title; the <code id="the-style-element:attr-title"><a href="#attr-title">title</a></code> attribute of ancestors does not apply to the <code id="the-style-element:the-style-element-6"><a href="#the-style-element">style</a></code>
  element. If the <code id="the-style-element:the-style-element-7"><a href="#the-style-element">style</a></code> element is not <a id="the-style-element:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>, then the <code id="the-style-element:attr-style-title-4"><a href="#attr-style-title">title</a></code> attribute is ignored. <a href="#refsCSSOM">[CSSOM]</a></p>

  <p class="note">The <code id="the-style-element:attr-style-title-5"><a href="#attr-style-title">title</a></code> attribute on <code id="the-style-element:the-style-element-8"><a href="#the-style-element">style</a></code>
  elements, like the <code id="the-style-element:attr-link-title"><a href="#attr-link-title">title</a></code> attribute on <code id="the-style-element:the-link-element"><a href="#the-link-element">link</a></code>
  elements, differs from the global <code id="the-style-element:attr-title-2"><a href="#attr-title">title</a></code> attribute in that a
  <code id="the-style-element:the-style-element-9"><a href="#the-style-element">style</a></code> block without a title does not inherit the title of the parent element: it
  merely has no title.</p>

  <p>The <a id="the-style-element:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> of a <code id="the-style-element:the-style-element-10"><a href="#the-style-element">style</a></code> element must be that of a
  <a id="the-style-element:conformant-style-sheet-2" href="https://drafts.csswg.org/css-syntax/#conform-classes" data-x-internal="conformant-style-sheet">conformant style sheet</a>.</p>

  <div data-algorithm="">
  <p>A <code id="the-style-element:the-style-element-11"><a href="#the-style-element">style</a></code> element is <a href="#implicitly-potentially-render-blocking" id="the-style-element:implicitly-potentially-render-blocking">implicitly potentially render-blocking</a> if the
  element was created by its <a id="the-style-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s parser.</p>
  </div>

  <hr>

  

  <p>The user agent must run the <a href="#update-a-style-block" id="the-style-element:update-a-style-block">update a <code>style</code> block</a> algorithm whenever
  any of the following conditions occur:</p>
  

  <ul><li><p>The element is popped off the <a href="#stack-of-open-elements" id="the-style-element:stack-of-open-elements">stack of open elements</a> of an <a href="#html-parser" id="the-style-element:html-parser">HTML
   parser</a> or <a href="#xml-parser" id="the-style-element:xml-parser">XML parser</a>.</p></li><li><p>The element is not on the <a href="#stack-of-open-elements" id="the-style-element:stack-of-open-elements-2">stack of open elements</a> of an <a href="#html-parser" id="the-style-element:html-parser-2">HTML
   parser</a> or <a href="#xml-parser" id="the-style-element:xml-parser-2">XML parser</a>, and it <a href="#becomes-connected" id="the-style-element:becomes-connected">becomes connected</a> or <a href="#becomes-disconnected" id="the-style-element:becomes-disconnected">disconnected</a>.</p></li><li><p>The element's <a id="the-style-element:children-changed-steps" href="https://dom.spec.whatwg.org/#concept-node-children-changed-ext" data-x-internal="children-changed-steps">children changed steps</a> run.</p></li></ul>

  <div data-algorithm="">
  <p>The <dfn id="update-a-style-block" data-export="">update a <code>style</code> block</dfn> algorithm is as follows:</p>

  <ol><li><p>Let <var>element</var> be the <code id="the-style-element:the-style-element-12"><a href="#the-style-element">style</a></code> element.</p></li><li><p>If <var>element</var> has an <a id="the-style-element:associated-css-style-sheet-7" href="https://drafts.csswg.org/cssom/#associated-css-style-sheet" data-x-internal="associated-css-style-sheet">associated CSS style sheet</a>, <a href="https://drafts.csswg.org/cssom/#remove-a-css-style-sheet" id="the-style-element:remove-a-css-style-sheet" data-x-internal="remove-a-css-style-sheet">remove the CSS style sheet</a> in question.</p></li><li><p>If <var>element</var> is not <a id="the-style-element:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li>
    <p>If <var>element</var>'s <code id="the-style-element:attr-style-type"><a href="#attr-style-type">type</a></code> attribute is present and
    its value is neither the empty string nor an <a id="the-style-element:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
    "<code id="the-style-element:text/css"><a href="#text/css">text/css</a></code>", then return.</p>

    <p class="note">In particular, a <code id="the-style-element:attr-style-type-2"><a href="#attr-style-type">type</a></code> value with
    parameters, such as "<code>text/css; charset=utf-8</code>", will cause this algorithm
    to return early.</p>
   </li><li><p>If the <a id="the-style-element:should-element's-inline-behavior-be-blocked-by-content-security-policy" href="https://w3c.github.io/webappsec-csp/#should-block-inline" data-x-internal="should-element's-inline-behavior-be-blocked-by-content-security-policy">Should element's inline behavior be blocked by Content Security
   Policy?</a> algorithm returns "<code>Blocked</code>" when executed upon the
   <code id="the-style-element:the-style-element-13"><a href="#the-style-element">style</a></code> element, "<code>style</code>", and the <code id="the-style-element:the-style-element-14"><a href="#the-style-element">style</a></code> element's
   <a id="the-style-element:child-text-content-2" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a>, then return. <a href="#refsCSP">[CSP]</a></p></li><li>
    <p><a id="the-style-element:create-a-css-style-sheet" href="https://drafts.csswg.org/cssom/#create-a-css-style-sheet" data-x-internal="create-a-css-style-sheet">Create a CSS style sheet</a> with the following properties:</p>

    <dl><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-type" id="the-style-element:concept-css-style-sheet-type" data-x-internal="concept-css-style-sheet-type">type</a></dt><dd><p><code id="the-style-element:text/css-2"><a href="#text/css">text/css</a></code></p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-owner-node" id="the-style-element:concept-css-style-sheet-owner-node" data-x-internal="concept-css-style-sheet-owner-node">owner node</a></dt><dd><p><var>element</var></p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-media" id="the-style-element:concept-css-style-sheet-media" data-x-internal="concept-css-style-sheet-media">media</a></dt><dd>
      <p>The <code id="the-style-element:attr-style-media-4"><a href="#attr-style-media">media</a></code> attribute of <var>element</var>.</p>

      <p class="note">This is a reference to the (possibly absent at this time) attribute, rather
      than a copy of the attribute's current value. <cite>CSSOM</cite> defines what happens
      when the attribute is dynamically set, changed, or removed.</p>
     </dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-title" id="the-style-element:concept-css-style-sheet-title" data-x-internal="concept-css-style-sheet-title">title</a></dt><dd>
      <p>The <code id="the-style-element:attr-style-title-6"><a href="#attr-style-title">title</a></code> attribute of <var>element</var>, if
      <var>element</var> is <a id="the-style-element:in-a-document-tree-2" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>, or the empty string otherwise.</p>

      <p class="note">Again, this is a <em>reference</em> to the attribute.</p>
     </dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-alternate-flag" id="the-style-element:concept-css-style-sheet-alternate-flag" data-x-internal="concept-css-style-sheet-alternate-flag">alternate flag</a></dt><dd><p>Unset.</p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-origin-clean-flag" id="the-style-element:concept-css-style-sheet-origin-clean-flag" data-x-internal="concept-css-style-sheet-origin-clean-flag">origin-clean flag</a></dt><dd><p>Set.</p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-location" id="the-style-element:concept-css-style-sheet-location" data-x-internal="concept-css-style-sheet-location">location</a></dt><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-parent-css-style-sheet" id="the-style-element:concept-css-style-sheet-parent-css-style-sheet" data-x-internal="concept-css-style-sheet-parent-css-style-sheet">parent CSS style sheet</a></dt><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-owner-css-rule" id="the-style-element:concept-css-style-sheet-owner-css-rule" data-x-internal="concept-css-style-sheet-owner-css-rule">owner CSS rule</a></dt><dd><p>null</p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag" id="the-style-element:concept-css-style-sheet-disabled-flag-4" data-x-internal="concept-css-style-sheet-disabled-flag">disabled flag</a></dt><dd><p>Left at its default value.</p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-css-rules" id="the-style-element:concept-css-style-sheet-css-rules" data-x-internal="concept-css-style-sheet-css-rules">CSS rules</a></dt><dd>
      <p>Left uninitialized.</p>

      <p class="XXX">This doesn't seem right. Presumably we should be using the element's
      <a id="the-style-element:child-text-content-3" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a>? Tracked as <a href="https://github.com/whatwg/html/issues/2997">issue #2997</a>.</p>
     </dd></dl>
   </li><li><p>If <var>element</var> <a href="#contributes-a-script-blocking-style-sheet" id="the-style-element:contributes-a-script-blocking-style-sheet">contributes a script-blocking style sheet</a>, <a href="https://infra.spec.whatwg.org/#set-append" id="the-style-element:set-append" data-x-internal="set-append">append</a> <var>element</var> to its <a id="the-style-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
   <a href="#script-blocking-style-sheet-set" id="the-style-element:script-blocking-style-sheet-set">script-blocking style sheet set</a>.</p></li><li><p>If <var>element</var>'s <code id="the-style-element:attr-style-media-5"><a href="#attr-style-media">media</a></code> attribute's value
   <a href="#matches-the-environment" id="the-style-element:matches-the-environment-2">matches the environment</a> and <var>element</var> is
   <a href="#potentially-render-blocking" id="the-style-element:potentially-render-blocking-2">potentially render-blocking</a>, then <a href="#block-rendering" id="the-style-element:block-rendering">block rendering</a> on
   <var>element</var>.</p></li></ol>
  </div>

  
  <div data-algorithm="">
  <p>Once the attempts to obtain the style sheet's <a href="#critical-subresources" id="the-style-element:critical-subresources">critical subresources</a>, if any, are
  complete, or, if the style sheet has no <a href="#critical-subresources" id="the-style-element:critical-subresources-2">critical subresources</a>, once the style sheet
  has been parsed and processed, the user agent must run these steps:</p>

  <p class="XXX">Fetching the <a href="#critical-subresources" id="the-style-element:critical-subresources-3">critical subresources</a> is not well-defined; probably <a href="https://github.com/whatwg/html/issues/968">issue #968</a> is the best resolution for that.
  In the meantime, any <a href="#critical-subresources" id="the-style-element:critical-subresources-4">critical subresource</a> <a href="https://fetch.spec.whatwg.org/#concept-request" id="the-style-element:concept-request" data-x-internal="concept-request">request</a> should have its <a href="https://fetch.spec.whatwg.org/#request-render-blocking" id="the-style-element:concept-request-render-blocking" data-x-internal="concept-request-render-blocking">render-blocking</a> set to whether or not the
  <code id="the-style-element:the-style-element-15"><a href="#the-style-element">style</a></code> element is currently <a href="#render-blocking" id="the-style-element:render-blocking">render-blocking</a>.</p>

  <ol><li><p>Let <var>element</var> be the <code id="the-style-element:the-style-element-16"><a href="#the-style-element">style</a></code> element associated with the style sheet
   in question.</p></li><li><p>Let <var>success</var> be true.</p></li><li>
    <p>If the attempts to obtain any of the style sheet's <a href="#critical-subresources" id="the-style-element:critical-subresources-5">critical subresources</a> failed
    for any reason (e.g., DNS error, HTTP 404 response, a connection being prematurely closed,
    unsupported Content-Type), set <var>success</var> to false.</p>

    <p class="note">Note that content-specific errors, e.g., CSS parse errors or PNG decoding
    errors, do not affect <var>success</var>.</p>
   </li><li>
    <p><a href="#queue-an-element-task" id="the-style-element:queue-an-element-task">Queue an element task</a> on the <a href="#networking-task-source" id="the-style-element:networking-task-source">networking task source</a> given
    <var>element</var> and the following steps:</p>

    <ol><li><p>If <var>success</var> is true, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-style-element:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a>
     named <code id="the-style-element:event-load"><a href="#event-load">load</a></code> at <var>element</var>.</p></li><li><p>Otherwise, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-style-element:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-style-element:event-error"><a href="#event-error">error</a></code> at <var>element</var>.</p></li><li>
      <p>If <var>element</var> <a href="#contributes-a-script-blocking-style-sheet" id="the-style-element:contributes-a-script-blocking-style-sheet-2">contributes a script-blocking style sheet</a>:</p>

      <ol><li><p><a id="the-style-element:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>element</var>'s <a id="the-style-element:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
       <a href="#script-blocking-style-sheet-set" id="the-style-element:script-blocking-style-sheet-set-2">script-blocking style sheet set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="the-style-element:list-contains" data-x-internal="list-contains">contains</a>
       <var>element</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="the-style-element:list-remove" data-x-internal="list-remove">Remove</a> <var>element</var> from its <a id="the-style-element:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
       document</a>'s <a href="#script-blocking-style-sheet-set" id="the-style-element:script-blocking-style-sheet-set-3">script-blocking style sheet set</a>.</p></li></ol>
     </li><li><p><a href="#unblock-rendering" id="the-style-element:unblock-rendering">Unblock rendering</a> on <var>element</var>.</p></li></ol>
   </li></ol>
  </div>

  <p>The element must <a href="#delay-the-load-event" id="the-style-element:delay-the-load-event">delay the load event</a> of the element's <a id="the-style-element:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> until all the
  attempts to obtain the style sheet's <a href="#critical-subresources" id="the-style-element:critical-subresources-6">critical subresources</a>, if any, are complete.</p>

  

  <p class="note">This specification does not specify a style system, but CSS is expected to be
  supported by most web browsers. <a href="#refsCSS">[CSS]</a></p>

  <p>The <code id="the-style-element:linkstyle-2"><a data-x-internal="linkstyle" href="https://drafts.csswg.org/cssom/#the-linkstyle-interface">LinkStyle</a></code> interface is also implemented by this element. <a href="#refsCSSOM">[CSSOM]</a></p>

  <div class="example">

   <p>The following document has its stress emphasis styled as bright red text rather than italics
   text, while leaving titles of works and Latin words in their default italics. It shows how using
   appropriate elements enables easier restyling of documents.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-US"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->My favorite book<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
   <c- f="">body</c-> <c- p="">{</c-> <c- k="">color</c-><c- p="">:</c-> <c- kc="">black</c-><c- p="">;</c-> <c- k="">background</c-><c- p="">:</c-> <c- kc="">white</c-><c- p="">;</c-> <c- p="">}</c->
   <c- f="">em</c-> <c- p="">{</c-> <c- k="">font-style</c-><c- p="">:</c-> <c- kc="">normal</c-><c- p="">;</c-> <c- k="">color</c-><c- p="">:</c-> <c- kc="">red</c-><c- p="">;</c-> <c- p="">}</c->
  <c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->favorite<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> book of all time has <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->got<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> to be
  <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->A Cat's Life<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->. It is a book by P. Rahmel that talks
  about the <c- p="">&lt;</c-><c- f="">i</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"la"</c-><c- p="">&gt;</c->Felis catus<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c-> in modern human society.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

  </div>



  

  <h4 id="interactions-of-styling-and-scripting"><span class="secno">4.2.7</span> Interactions of styling and scripting<a href="#interactions-of-styling-and-scripting" class="self-link"></a></h4>

  <p>If the style sheet referenced no other resources (e.g., it was an internal style sheet given by
  a <code id="interactions-of-styling-and-scripting:the-style-element"><a href="#the-style-element">style</a></code> element with no <code>@import</code> rules), then the style rules
  must be <a href="#immediately" id="interactions-of-styling-and-scripting:immediately">immediately</a> made available to script; otherwise, the style rules must only be
  made available to script once the <a href="#event-loop" id="interactions-of-styling-and-scripting:event-loop">event loop</a> reaches its <a href="#update-the-rendering" id="interactions-of-styling-and-scripting:update-the-rendering">update the
  rendering</a> step.</p>

  <div data-algorithm="">
  <p id="a-style-sheet-that-is-blocking-scripts">An element <var>el</var> in the context of a
  <code id="interactions-of-styling-and-scripting:document"><a href="#document">Document</a></code> of an <a href="#html-parser" id="interactions-of-styling-and-scripting:html-parser">HTML parser</a> or <a href="#xml-parser" id="interactions-of-styling-and-scripting:xml-parser">XML parser</a> <dfn id="contributes-a-script-blocking-style-sheet">contributes a
  script-blocking style sheet</dfn> if all of the following are true:</p>

  <ul><li><p><var>el</var> was created by that <code id="interactions-of-styling-and-scripting:document-2"><a href="#document">Document</a></code>'s parser.</p></li><li><p><var>el</var> is either a <code id="interactions-of-styling-and-scripting:the-style-element-2"><a href="#the-style-element">style</a></code> element or a <code id="interactions-of-styling-and-scripting:the-link-element"><a href="#the-link-element">link</a></code> element that
   was an <a href="#link-type-stylesheet" id="interactions-of-styling-and-scripting:link-type-stylesheet">external resource link that contributes to the styling
   processing model</a> when the <var>el</var> was created by the parser.</p></li><li><p><var>el</var>'s <code>media</code> attribute's value
   <a href="#matches-the-environment" id="interactions-of-styling-and-scripting:matches-the-environment">matches the environment</a>.</p></li><li><p><var>el</var>'s style sheet was enabled when the element was created by the
   parser.</p></li><li><p>The last time the <a href="#event-loop" id="interactions-of-styling-and-scripting:event-loop-2">event loop</a> reached <a href="#step1">step 1</a>,
   <var>el</var>'s <a id="interactions-of-styling-and-scripting:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> was that <code id="interactions-of-styling-and-scripting:document-3"><a href="#document">Document</a></code>.</p></li><li>
    <p>The user agent hasn't given up on loading that particular style sheet yet. A user agent
    may give up on loading a style sheet at any time.</p>

    <p class="note">Giving up on a style sheet before the style sheet loads, if the style sheet
    eventually does still load, means that the script might end up operating with incorrect
    information. For example, if a style sheet sets the color of an element to green, but a script
    that inspects the resulting style is executed before the sheet is loaded, the script will find
    that the element is black (or whatever the default color is), and might thus make poor choices
    (e.g., deciding to use black as the color elsewhere on the page, instead of green). Implementers
    have to balance the likelihood of a script using incorrect information with the performance impact
    of doing nothing while waiting for a slow network request to finish.</p>
   </li></ul>
  </div>

  <p class="XXX">It is expected that counterparts to the above rules also apply to
  <code id="interactions-of-styling-and-scripting:xml-stylesheet"><a data-x-internal="xml-stylesheet" href="https://www.w3.org/TR/xml-stylesheet/#the-xml-stylesheet-processing-instruction">&lt;?xml-stylesheet?&gt;</a></code> PIs. However, this has not yet been thoroughly
  investigated.</p>

  <p>A <code id="interactions-of-styling-and-scripting:document-4"><a href="#document">Document</a></code> has a <dfn id="script-blocking-style-sheet-set">script-blocking style sheet set</dfn>, which is an <a href="https://infra.spec.whatwg.org/#ordered-set" id="interactions-of-styling-and-scripting:set" data-x-internal="set">ordered set</a>, initially empty.</p>

  <div data-algorithm="">
  <p>A <code id="interactions-of-styling-and-scripting:document-5"><a href="#document">Document</a></code> <var>document</var> <dfn id="has-a-style-sheet-that-is-blocking-scripts">has a style sheet that is blocking
  scripts</dfn> if the following steps return true:</p>

  <ol><li><p>If <var>document</var>'s <a href="#script-blocking-style-sheet-set" id="interactions-of-styling-and-scripting:script-blocking-style-sheet-set">script-blocking style sheet set</a> is not <a href="https://infra.spec.whatwg.org/#list-is-empty" id="interactions-of-styling-and-scripting:list-is-empty" data-x-internal="list-is-empty">empty</a>, then return true.</p></li><li><p>If <var>document</var>'s <a href="#node-navigable" id="interactions-of-styling-and-scripting:node-navigable">node navigable</a> is null, then return false.</p></li><li><p>Let <var>containerDocument</var> be <var>document</var>'s <a href="#node-navigable" id="interactions-of-styling-and-scripting:node-navigable-2">node navigable</a>'s
   <a href="#nav-container" id="interactions-of-styling-and-scripting:nav-container">container document</a>.</p></li><li><p>If <var>containerDocument</var> is non-null and <var>containerDocument</var>'s
   <a href="#script-blocking-style-sheet-set" id="interactions-of-styling-and-scripting:script-blocking-style-sheet-set-2">script-blocking style sheet set</a> is not <a href="https://infra.spec.whatwg.org/#list-is-empty" id="interactions-of-styling-and-scripting:list-is-empty-2" data-x-internal="list-is-empty">empty</a>,
   then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <code id="interactions-of-styling-and-scripting:document-6"><a href="#document">Document</a></code> <dfn id="has-no-style-sheet-that-is-blocking-scripts">has no style sheet that is blocking scripts</dfn> if it does not
  <a href="#has-a-style-sheet-that-is-blocking-scripts" id="interactions-of-styling-and-scripting:has-a-style-sheet-that-is-blocking-scripts">have a style sheet that is blocking
  scripts</a>.</p>
  </div>

  




  <h3 id="sections"><span class="secno">4.3</span> Sections<a href="#sections" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Introduction_to_HTML/Document_and_website_structure#HTML_for_structuring_content" title="At this point, you should have a better idea about how to structure a web page/site. In the last article of this module, we'll learn how to debug HTML.">Introduction_to_HTML/Document_and_website_structure#HTML_for_structuring_content</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.1+</span></span></div></div></div>

  <h4 id="the-body-element"><span class="secno">4.3.1</span> The <dfn data-dfn-type="element"><code>body</code></dfn> element<a href="#the-body-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body" title="The <body> HTML element represents the content of an HTML document. There can be only one <body> element in a document.">Element/body</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement" title="The HTMLBodyElement interface provides special properties (beyond those inherited from the regular HTMLElement interface) for manipulating <body> elements.">HTMLBodyElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-body-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-body-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As the second element in an <code id="the-body-element:the-html-element"><a href="#the-html-element">html</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-body-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-body-element:flow-content-2">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-body-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-body-element:the-body-element"><a href="#the-body-element">body</a></code> element's <a href="#syntax-start-tag" id="the-body-element:syntax-start-tag">start tag</a> can be omitted
  if the element is empty, or if the first thing inside the <code id="the-body-element:the-body-element-2"><a href="#the-body-element">body</a></code> element is not
  <a id="the-body-element:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> or a <a href="#syntax-comments" id="the-body-element:syntax-comments">comment</a>, except if the
  first thing inside the <code id="the-body-element:the-body-element-3"><a href="#the-body-element">body</a></code> element is a <code id="the-body-element:the-meta-element"><a href="#the-meta-element">meta</a></code>, <code id="the-body-element:the-noscript-element"><a href="#the-noscript-element">noscript</a></code>,
  <code id="the-body-element:the-link-element"><a href="#the-link-element">link</a></code>, <code id="the-body-element:the-script-element"><a href="#the-script-element">script</a></code>, <code id="the-body-element:the-style-element"><a href="#the-style-element">style</a></code>, or <code id="the-body-element:the-template-element"><a href="#the-template-element">template</a></code> element.
  </dd><dd>A <code id="the-body-element:the-body-element-4"><a href="#the-body-element">body</a></code> element's <a href="#syntax-end-tag" id="the-body-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-body-element:the-body-element-5"><a href="#the-body-element">body</a></code> element is not immediately followed by a <a href="#syntax-comments" id="the-body-element:syntax-comments-2">comment</a>.</dd><dt><a href="#concept-element-attributes" id="the-body-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-body-element:global-attributes">Global attributes</a></dd><dd><code id="the-body-element:handler-window-onafterprint"><a href="#handler-window-onafterprint">onafterprint</a></code></dd><dd><code id="the-body-element:handler-window-onbeforeprint"><a href="#handler-window-onbeforeprint">onbeforeprint</a></code></dd><dd><code id="the-body-element:handler-window-onbeforeunload"><a href="#handler-window-onbeforeunload">onbeforeunload</a></code></dd><dd><code id="the-body-element:handler-window-onhashchange"><a href="#handler-window-onhashchange">onhashchange</a></code></dd><dd><code id="the-body-element:handler-window-onlanguagechange"><a href="#handler-window-onlanguagechange">onlanguagechange</a></code></dd><dd><code id="the-body-element:handler-window-onmessage"><a href="#handler-window-onmessage">onmessage</a></code></dd><dd><code id="the-body-element:handler-window-onmessageerror"><a href="#handler-window-onmessageerror">onmessageerror</a></code></dd><dd><code id="the-body-element:handler-window-onoffline"><a href="#handler-window-onoffline">onoffline</a></code></dd><dd><code id="the-body-element:handler-window-ononline"><a href="#handler-window-ononline">ononline</a></code></dd><dd><code id="the-body-element:handler-window-onpageswap"><a href="#handler-window-onpageswap">onpageswap</a></code></dd><dd><code id="the-body-element:handler-window-onpagehide"><a href="#handler-window-onpagehide">onpagehide</a></code></dd><dd><code id="the-body-element:handler-window-onpagereveal"><a href="#handler-window-onpagereveal">onpagereveal</a></code></dd><dd><code id="the-body-element:handler-window-onpageshow"><a href="#handler-window-onpageshow">onpageshow</a></code></dd><dd><code id="the-body-element:handler-window-onpopstate"><a href="#handler-window-onpopstate">onpopstate</a></code></dd><dd><code id="the-body-element:handler-window-onrejectionhandled"><a href="#handler-window-onrejectionhandled">onrejectionhandled</a></code></dd><dd><code id="the-body-element:handler-window-onstorage"><a href="#handler-window-onstorage">onstorage</a></code></dd><dd><code id="the-body-element:handler-window-onunhandledrejection"><a href="#handler-window-onunhandledrejection">onunhandledrejection</a></code></dd><dd><code id="the-body-element:handler-window-onunload"><a href="#handler-window-onunload">onunload</a></code></dd><dt><a href="#concept-element-accessibility-considerations" id="the-body-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-body">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-body">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-body-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlbodyelement" data-dfn-type="interface"><c- g="">HTMLBodyElement</c-></dfn> : <a href="#htmlelement" id="the-body-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-body-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLBodyElement-partial">also has obsolete members</a>
};

<a href="#htmlbodyelement" id="the-body-element:htmlbodyelement"><c- n="">HTMLBodyElement</c-></a> <c- b="">includes</c-> <a href="#windoweventhandlers" id="the-body-element:windoweventhandlers"><c- n="">WindowEventHandlers</c-></a>;</code></pre>
</dd></dl>

  <p>The <code id="the-body-element:the-body-element-6"><a href="#the-body-element">body</a></code> element <a href="#represents" id="the-body-element:represents">represents</a> the contents of the document.</p>

  <p>In conforming documents, there is only one <code id="the-body-element:the-body-element-7"><a href="#the-body-element">body</a></code> element. The <code id="the-body-element:dom-document-body"><a href="#dom-document-body">document.body</a></code> IDL attribute provides scripts with easy access to
  a document's <code id="the-body-element:the-body-element-8"><a href="#the-body-element">body</a></code> element.</p>

  

  <p class="note">Some DOM operations (for example, parts of the <a href="#dnd" id="the-body-element:dnd">drag and drop</a> model)
  are defined in terms of "<a href="#the-body-element-2" id="the-body-element:the-body-element-2-2">the body element</a>". This refers to a particular element in
  the DOM, as per the definition of the term, and not any arbitrary <code id="the-body-element:the-body-element-9"><a href="#the-body-element">body</a></code> element.</p>

  

  <p>The <code id="the-body-element:the-body-element-10"><a href="#the-body-element">body</a></code> element exposes as <a href="#event-handler-content-attributes" id="the-body-element:event-handler-content-attributes">event handler content attributes</a> a number
  of the <a href="#event-handlers" id="the-body-element:event-handlers">event handlers</a> of the <code id="the-body-element:window"><a href="#window">Window</a></code> object. It also mirrors their
  <a href="#event-handler-idl-attributes" id="the-body-element:event-handler-idl-attributes">event handler IDL attributes</a>.</p>

  <p>The <a href="#event-handlers" id="the-body-element:event-handlers-2">event handlers</a> of the <code id="the-body-element:window-2"><a href="#window">Window</a></code> object named by the
  <a href="#window-reflecting-body-element-event-handler-set" id="the-body-element:window-reflecting-body-element-event-handler-set"><code>Window</code>-reflecting body element event handler set</a>, exposed on the
  <code id="the-body-element:the-body-element-11"><a href="#the-body-element">body</a></code> element, replace the generic <a href="#event-handlers" id="the-body-element:event-handlers-3">event handlers</a> with the same names
  normally supported by <a href="#html-elements" id="the-body-element:html-elements">HTML elements</a>.</p>

  <p class="example">Thus, for example, a bubbling <code id="the-body-element:event-error"><a href="#event-error">error</a></code> event
  dispatched on a child of <a href="#the-body-element-2" id="the-body-element:the-body-element-2-3">the body element</a> of a <code id="the-body-element:document"><a href="#document">Document</a></code> would first
  trigger the <code id="the-body-element:handler-onerror"><a href="#handler-onerror">onerror</a></code> <a href="#event-handler-content-attributes" id="the-body-element:event-handler-content-attributes-2">event handler content
  attributes</a> of that element, then that of the root <code id="the-body-element:the-html-element-2"><a href="#the-html-element">html</a></code> element, and only
  <em>then</em> would it trigger the <code id="the-body-element:handler-onerror-2"><a href="#handler-onerror">onerror</a></code> <a href="#event-handler-content-attributes" id="the-body-element:event-handler-content-attributes-3">event handler content attribute</a> on the
  <code id="the-body-element:the-body-element-12"><a href="#the-body-element">body</a></code> element. This is because the event would bubble from the target, to the
  <code id="the-body-element:the-body-element-13"><a href="#the-body-element">body</a></code>, to the <code id="the-body-element:the-html-element-3"><a href="#the-html-element">html</a></code>, to the <code id="the-body-element:document-2"><a href="#document">Document</a></code>, to the
  <code id="the-body-element:window-3"><a href="#window">Window</a></code>, and the <a href="#event-handlers" id="the-body-element:event-handlers-4">event handler</a> on the
  <code id="the-body-element:the-body-element-14"><a href="#the-body-element">body</a></code> is watching the <code id="the-body-element:window-4"><a href="#window">Window</a></code> not the <code id="the-body-element:the-body-element-15"><a href="#the-body-element">body</a></code>. A regular event
  listener attached to the <code id="the-body-element:the-body-element-16"><a href="#the-body-element">body</a></code> using <code>addEventListener()</code>,
  however, would be run when the event bubbled through the <code id="the-body-element:the-body-element-17"><a href="#the-body-element">body</a></code> and not when it reaches
  the <code id="the-body-element:window-5"><a href="#window">Window</a></code> object.</p>

  <div class="example">

   <p>This page updates an indicator to show whether or not the user is online:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Online or offline?<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">function</c-> update<c- p="">(</c->online<c- p="">)</c-> <c- p="">{</c->
     document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'status'</c-><c- p="">).</c->textContent <c- o="">=</c->
       online <c- o="">?</c-> <c- t="">'Online'</c-> <c- o="">:</c-> <c- t="">'Offline'</c-><c- p="">;</c->
   <c- p="">}</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-> <c- e="">ononline</c-><c- o="">=</c-><c- s="">"update(true)"</c->
       <c- e="">onoffline</c-><c- o="">=</c-><c- s="">"update(false)"</c->
       <c- e="">onload</c-><c- o="">=</c-><c- s="">"update(navigator.onLine)"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You are: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"status"</c-><c- p="">&gt;</c->(Unknown)<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-article-element"><span class="secno">4.3.2</span> The <dfn data-dfn-type="element"><code>article</code></dfn> element<a href="#the-article-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article" title="The <article> HTML element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication). Examples include: a forum post, a magazine or newspaper article, or a blog entry, a product card, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.">Element/article</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-article-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-article-element:flow-content-2">Flow content</a>.</dd><dd><a href="#sectioning-content-2" id="the-article-element:sectioning-content-2">Sectioning content</a>.</dd><dd><a href="#palpable-content-2" id="the-article-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-article-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#sectioning-content-2" id="the-article-element:sectioning-content-2-2">sectioning content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-article-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-article-element:flow-content-2-2">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-article-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-article-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-article-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-article-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-article">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-article">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-article-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-article-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-article-element:the-article-element"><a href="#the-article-element">article</a></code> element <a href="#represents" id="the-article-element:represents">represents</a> a complete, or self-contained,
  composition in a document, page, application, or site and that is, in principle, independently
  distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or
  newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any
  other independent item of content.</p>

  

  <p>When <code id="the-article-element:the-article-element-2"><a href="#the-article-element">article</a></code> elements are nested, the inner <code id="the-article-element:the-article-element-3"><a href="#the-article-element">article</a></code> elements
  represent articles that are in principle related to the contents of the outer article. For
  instance, a blog entry on a site that accepts user-submitted comments could represent the comments
  as <code id="the-article-element:the-article-element-4"><a href="#the-article-element">article</a></code> elements nested within the <code id="the-article-element:the-article-element-5"><a href="#the-article-element">article</a></code> element for the blog
  entry.</p>

  <p>Author information associated with an <code id="the-article-element:the-article-element-6"><a href="#the-article-element">article</a></code> element (q.v. the
  <code id="the-article-element:the-address-element"><a href="#the-address-element">address</a></code> element) does not apply to nested <code id="the-article-element:the-article-element-7"><a href="#the-article-element">article</a></code> elements.</p>

  <p class="note">When used specifically with content to be redistributed in syndication, the
  <code id="the-article-element:the-article-element-8"><a href="#the-article-element">article</a></code> element is similar in purpose to the <code>entry</code> element in
  Atom. <a href="#refsATOM">[ATOM]</a>

  </p><p class="note">The schema.org microdata vocabulary can be used to provide the publication date
  for an <code id="the-article-element:the-article-element-9"><a href="#the-article-element">article</a></code> element, using one of the CreativeWork subtypes.</p>

  <p>When the main content of the page (i.e. excluding footers, headers, navigation blocks, and
  sidebars) is all one single self-contained composition, that content may be marked with an
  <code id="the-article-element:the-article-element-10"><a href="#the-article-element">article</a></code>, but it is technically redundant in that case (since it's self-evident that
  the page is a single composition, as it is a single document).</p>

  <div id="article-example" class="example"><a href="#article-example" class="self-link"></a>

   <p>This example shows a blog post using the <code id="the-article-element:the-article-element-11"><a href="#the-article-element">article</a></code> element, with some schema.org
   annotations:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/BlogPosting"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"headline"</c-><c- p="">&gt;</c->The Very First Rule of Life<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"datePublished"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-10-09"</c-><c- p="">&gt;</c->3 days ago<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?comments=0"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If there's a microphone anywhere near you, assume it's hot and
 sending whatever you're saying to the world. Seriously.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><em>...</em><c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"discussionUrl"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?comments=1"</c-><c- p="">&gt;</c->Show comments...<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <p>Here is that same blog post, but showing some of the comments:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/BlogPosting"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"headline"</c-><c- p="">&gt;</c->The Very First Rule of Life<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"datePublished"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-10-09"</c-><c- p="">&gt;</c->3 days ago<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?comments=0"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If there's a microphone anywhere near you, assume it's hot and
 sending whatever you're saying to the world. Seriously.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><em>...</em><c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Comments<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"comment"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Comment"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"c1"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#c1"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Posted by: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"creator"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Person"</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->George Washington<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"dateCreated"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-10-10"</c-><c- p="">&gt;</c->15 minutes ago<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Yeah! Especially when talking about your lobbyist friends!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"comment"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Comment"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"c2"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#c2"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Posted by: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"creator"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Person"</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->George Hammond<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"dateCreated"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-10-10"</c-><c- p="">&gt;</c->5 minutes ago<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Hey, you have the same first name as me.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <p>Notice the use of <code id="the-article-element:the-footer-element"><a href="#the-footer-element">footer</a></code> to give the information for each comment (such as who
   wrote it and when): the <code id="the-article-element:the-footer-element-2"><a href="#the-footer-element">footer</a></code> element <em>can</em> appear at the start of its
   section when appropriate, such as in this case. (Using <code id="the-article-element:the-header-element"><a href="#the-header-element">header</a></code> in this case wouldn't
   be wrong either; it's mostly a matter of authoring preference.)</p>

  </div>

  <div class="example">

   <p>In this example, <code id="the-article-element:the-article-element-12"><a href="#the-article-element">article</a></code> elements are used to host widgets on a portal page. The
   widgets are implemented as <a href="#customized-built-in-element" id="the-article-element:customized-built-in-element">customized built-in
   elements</a> in order to get specific styling and scripted behavior.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->eHome Portal<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/scripts/widgets.js"</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">stylesheet</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/styles/main.css"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">article</c-> <c- e="">is</c-><c- o="">=</c-><c- s="">"stock-widget"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Stocks<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Stock <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Value <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Delta
  <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">template</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">template</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Refresh"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"this.parentElement.refresh()"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">article</c-> <c- e="">is</c-><c- o="">=</c-><c- s="">"news-widget"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->News<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">template</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">template</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Refresh"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"this.parentElement.refresh()"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-section-element"><span class="secno">4.3.3</span> The <dfn data-dfn-type="element"><code>section</code></dfn> element<a href="#the-section-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section" title="The <section> HTML element represents a generic standalone section of a document, which doesn't have a more specific semantic element to represent it. Sections should always have a heading, with very few exceptions.">Element/section</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-section-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-section-element:flow-content-2">Flow content</a>.</dd><dd><a href="#sectioning-content-2" id="the-section-element:sectioning-content-2">Sectioning content</a>.</dd><dd><a href="#palpable-content-2" id="the-section-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-section-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#sectioning-content-2" id="the-section-element:sectioning-content-2-2">sectioning content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-section-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-section-element:flow-content-2-2">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-section-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-section-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-section-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-section-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-section">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-section">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-section-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-section-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-section-element:the-section-element"><a href="#the-section-element">section</a></code> element <a href="#represents" id="the-section-element:represents">represents</a> a generic section of a document or
  application. A section, in this context, is a thematic grouping of content, typically with a
  heading.</p>

  <p class="example">Examples of sections would be chapters, the various tabbed pages in a tabbed
  dialog box, or the numbered sections of a thesis. A web site's home page could be split into
  sections for an introduction, news items, and contact information.</p>

  <p class="note">Authors are encouraged to use the <code id="the-section-element:the-article-element"><a href="#the-article-element">article</a></code> element instead of the
  <code id="the-section-element:the-section-element-2"><a href="#the-section-element">section</a></code> element when it would make sense to syndicate the contents of the
  element.</p>

  <p id="use-div-for-wrappers" class="note"><a href="#use-div-for-wrappers" class="self-link"></a>The <code id="the-section-element:the-section-element-3"><a href="#the-section-element">section</a></code> element is not a generic
  container element. When an element is needed only for styling purposes or as a convenience for
  scripting, authors are encouraged to use the <code id="the-section-element:the-div-element"><a href="#the-div-element">div</a></code> element instead. A general rule is
  that the <code id="the-section-element:the-section-element-4"><a href="#the-section-element">section</a></code> element is appropriate only if the element's contents would be
  listed explicitly in the document's <a href="#outline" id="the-section-element:outline">outline</a>.</p>

  <div class="example">

   <p>In the following example, we see an article (part of a larger web page) about apples,
   containing two short sections.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Apples<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Tasty, delicious fruit!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The apple is the pomaceous fruit of the apple tree.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Red Delicious<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->These bright red apples are the most common found in many
  supermarkets.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Granny Smith<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->These juicy, green apples make a great filling for
  apple pies.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Here is a graduation programme with two sections, one for the list of people graduating, and
   one for the description of the ceremony. (The markup in this example features an uncommon style
   sometimes used to minimize the amount of <a href="#inter-element-whitespace" id="the-section-element:inter-element-whitespace">inter-element whitespace</a>.)</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE Html&gt;</c->
<c- p="">&lt;</c-><c- f="">Html</c-> <c- e="">Lang</c-><c- o="">=</c-><c- s="">En</c->
 <c- p="">&gt;&lt;</c-><c- f="">Head</c->
   <c- p="">&gt;&lt;</c-><c- f="">Title</c->
     <c- p="">&gt;</c->Graduation Ceremony Summer 2022<c- p="">&lt;/</c-><c- f="">Title</c->
   <c- p="">&gt;&lt;/</c-><c- f="">Head</c->
 <c- p="">&gt;&lt;</c-><c- f="">Body</c->
   <c- p="">&gt;&lt;</c-><c- f="">H1</c->
     <c- p="">&gt;</c->Graduation<c- p="">&lt;/</c-><c- f="">H1</c->
   <c- p="">&gt;&lt;</c-><c- f="">Section</c->
     <c- p="">&gt;&lt;</c-><c- f="">H2</c->
       <c- p="">&gt;</c->Ceremony<c- p="">&lt;/</c-><c- f="">H2</c->
     <c- p="">&gt;&lt;</c-><c- f="">P</c->
       <c- p="">&gt;</c->Opening Procession<c- p="">&lt;/</c-><c- f="">P</c->
     <c- p="">&gt;&lt;</c-><c- f="">P</c->
       <c- p="">&gt;</c->Speech by Valedictorian<c- p="">&lt;/</c-><c- f="">P</c->
     <c- p="">&gt;&lt;</c-><c- f="">P</c->
       <c- p="">&gt;</c->Speech by Class President<c- p="">&lt;/</c-><c- f="">P</c->
     <c- p="">&gt;&lt;</c-><c- f="">P</c->
       <c- p="">&gt;</c->Presentation of Diplomas<c- p="">&lt;/</c-><c- f="">P</c->
     <c- p="">&gt;&lt;</c-><c- f="">P</c->
       <c- p="">&gt;</c->Closing Speech by Headmaster<c- p="">&lt;/</c-><c- f="">P</c->
   <c- p="">&gt;&lt;/</c-><c- f="">Section</c->
   <c- p="">&gt;&lt;</c-><c- f="">Section</c->
     <c- p="">&gt;&lt;</c-><c- f="">H2</c->
       <c- p="">&gt;</c->Graduates<c- p="">&lt;/</c-><c- f="">H2</c->
     <c- p="">&gt;&lt;</c-><c- f="">Ul</c->
       <c- p="">&gt;&lt;</c-><c- f="">Li</c->
         <c- p="">&gt;</c->Molly Carpenter<c- p="">&lt;/</c-><c- f="">Li</c->
       <c- p="">&gt;&lt;</c-><c- f="">Li</c->
         <c- p="">&gt;</c->Anastasia Luccio<c- p="">&lt;/</c-><c- f="">Li</c->
       <c- p="">&gt;&lt;</c-><c- f="">Li</c->
         <c- p="">&gt;</c->Ebenezar McCoy<c- p="">&lt;/</c-><c- f="">Li</c->
       <c- p="">&gt;&lt;</c-><c- f="">Li</c->
         <c- p="">&gt;</c->Karrin Murphy<c- p="">&lt;/</c-><c- f="">Li</c->
       <c- p="">&gt;&lt;</c-><c- f="">Li</c->
         <c- p="">&gt;</c->Thomas Raith<c- p="">&lt;/</c-><c- f="">Li</c->
       <c- p="">&gt;&lt;</c-><c- f="">Li</c->
         <c- p="">&gt;</c->Susan Rodriguez<c- p="">&lt;/</c-><c- f="">Li</c->
     <c- p="">&gt;&lt;/</c-><c- f="">Ul</c->
   <c- p="">&gt;&lt;/</c-><c- f="">Section</c->
 <c- p="">&gt;&lt;/</c-><c- f="">Body</c->
<c- p="">&gt;&lt;/</c-><c- f="">Html</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In this example, a book author has marked up some sections as chapters and some as appendices,
   and uses CSS to style the headers in these two classes of section differently.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
 <c- f="">section</c-> <c- p="">{</c-> <c- k="">border</c-><c- p="">:</c-> <c- kc="">double</c-> <c- kc="">medium</c-><c- p="">;</c-> <c- k="">margin</c-><c- p="">:</c-> <c- mi="">2</c-><c- b="">em</c-><c- p="">;</c-> <c- p="">}</c->
 <c- f="">section</c-><c- p="">.</c-><c- nc="">chapter</c-> <c- f="">h2</c-> <c- p="">{</c-> <c- k="">font</c-><c- p="">:</c-> <c- mi="">2</c-><c- b="">em</c-> <c- n="">Roboto</c-><c- p="">,</c-> <c- n="">Helvetica</c-> <c- n="">Neue</c-><c- p="">,</c-> <c- kc="">sans-serif</c-><c- p="">;</c-> <c- p="">}</c->
 <c- f="">section</c-><c- p="">.</c-><c- nc="">appendix</c-> <c- f="">h2</c-> <c- p="">{</c-> <c- k="">font</c-><c- p="">:</c-> <c- kc="">small-caps</c-> <c- mi="">2</c-><c- b="">em</c-> <c- n="">Roboto</c-><c- p="">,</c-> <c- n="">Helvetica</c-> <c- n="">Neue</c-><c- p="">,</c-> <c- kc="">sans-serif</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->My Book<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->A sample with not much content<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Published by Dummy Publicorp Ltd.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"chapter"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->My First Chapter<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This is the first of my chapters. It doesn't say much.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->But it has two paragraphs!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"chapter"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->It Continues: The Second Chapter<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Bla dee bla, dee bla dee bla. Boom.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"chapter"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Chapter Three: A Further Example<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->It's not like a battle between brightness and earthtones would go
 unnoticed.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->But it might ruin my story.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"appendix"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Appendix A: Overview of Examples<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->These are demonstrations.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"appendix"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Appendix B: Some Closing Remarks<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Hopefully this long example shows that you <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->can<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> style
 sections, so long as they are used to indicate actual sections.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-nav-element"><span class="secno">4.3.4</span> The <dfn data-dfn-type="element"><code>nav</code></dfn> element<a href="#the-nav-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nav" title="The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.">Element/nav</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-nav-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-nav-element:flow-content-2">Flow content</a>.</dd><dd><a href="#sectioning-content-2" id="the-nav-element:sectioning-content-2">Sectioning content</a>.</dd><dd><a href="#palpable-content-2" id="the-nav-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-nav-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#sectioning-content-2" id="the-nav-element:sectioning-content-2-2">sectioning content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-nav-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-nav-element:flow-content-2-2">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-nav-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-nav-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-nav-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-nav-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-nav">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-nav">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-nav-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-nav-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-nav-element:the-nav-element"><a href="#the-nav-element">nav</a></code> element <a href="#represents" id="the-nav-element:represents">represents</a> a section of a page that links to other
  pages or to parts within the page: a section with navigation links.</p>

  <p class="note">Not all groups of links on a page need to be in a <code id="the-nav-element:the-nav-element-2"><a href="#the-nav-element">nav</a></code> element —
  the element is primarily intended for sections that consist of major navigation blocks. In
  particular, it is common for footers to have a short list of links to various pages of a site,
  such as the terms of service, the home page, and a copyright page. The <code id="the-nav-element:the-footer-element"><a href="#the-footer-element">footer</a></code> element
  alone is sufficient for such cases; while a <code id="the-nav-element:the-nav-element-3"><a href="#the-nav-element">nav</a></code> element can be used in such cases, it
  is usually unnecessary.</p>

  <p class="note">User agents (such as screen readers) that are targeted at users who can benefit
  from navigation information being omitted in the initial rendering, or who can benefit from
  navigation information being immediately available, can use this element as a way to determine
  what content on the page to initially skip or provide on request (or both).</p>

  <div class="example">

   <p>In the following example, there are two <code id="the-nav-element:the-nav-element-4"><a href="#the-nav-element">nav</a></code> elements, one for primary navigation
   around the site, and one for secondary navigation around the page itself.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The Wiki Center Of Exampland<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/"</c-><c- p="">&gt;</c->Home<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/events"</c-><c- p="">&gt;</c->Current Events<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
   <em>...more...</em>
  <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Demos in Exampland<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Written by A. N. Other.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#public"</c-><c- p="">&gt;</c->Public demonstrations<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#destroy"</c-><c- p="">&gt;</c->Demolitions<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
    <em>...more...</em>
   <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">section</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"public"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Public demonstrations<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><em>...more...</em><c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">section</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"destroy"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Demolitions<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><em>...more...</em><c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
   <em>...more...</em>
  <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?edit"</c-><c- p="">&gt;</c->Edit<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> | <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?delete"</c-><c- p="">&gt;</c->Delete<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> | <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?Rename"</c-><c- p="">&gt;</c->Rename<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->© copyright 1998 Exampland Emperor<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following example, the page has several places where links are present, but only one of
   those places is considered a navigation section.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Blog"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Wake up sheeple!<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"news.html"</c-><c- p="">&gt;</c->News<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> -
     <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"blog.html"</c-><c- p="">&gt;</c->Blog<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> -
     <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"forums.html"</c-><c- p="">&gt;</c->Forums<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Last Modified: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"dateModified"</c-><c- p="">&gt;</c->2009-04-01<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Navigation<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"articles.html"</c-><c- p="">&gt;</c->Index of all articles<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"today.html"</c-><c- p="">&gt;</c->Things sheeple need to wake up for today<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"successes.html"</c-><c- p="">&gt;</c->Sheeple we have managed to wake<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">main</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"blogPosts"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/BlogPosting"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">h2</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"headline"</c-><c- p="">&gt;</c->My Day at the Beach<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"articleBody"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Today I went to the beach and had a lot of fun.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <em>...more content...</em>
   <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Posted <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"datePublished"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-10-10"</c-><c- p="">&gt;</c->Thursday<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
  <em>...more blog posts...</em>
 <c- p="">&lt;/</c-><c- f="">main</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Copyright ©
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"copyrightYear"</c-><c- p="">&gt;</c->2010<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"copyrightHolder"</c-><c- p="">&gt;</c->The Example Company<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"about.html"</c-><c- p="">&gt;</c->About<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> -
     <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"policy.html"</c-><c- p="">&gt;</c->Privacy Policy<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> -
     <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"contact.html"</c-><c- p="">&gt;</c->Contact Us<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

   <p>You can also see microdata annotations in the above example that use the schema.org vocabulary
   to provide the publication date and other metadata about the blog post.</p>

  </div>

  <div class="example">

   <p>A <code id="the-nav-element:the-nav-element-5"><a href="#the-nav-element">nav</a></code> element doesn't have to contain a list, it can contain other kinds of
   content as well. In this navigation block, links are provided in prose:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Navigation<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You are on my home page. To the north lies <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/blog"</c-><c- p="">&gt;</c->my
 blog<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->, from whence the sounds of battle can be heard. To the east
 you can see a large mountain, upon which many <c- p="">&lt;</c-><c- f="">a</c->
 <c- e="">href</c-><c- o="">=</c-><c- s="">"/school"</c-><c- p="">&gt;</c->school papers<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> are littered. Far up thus mountain
 you can spy a little figure who appears to be me, desperately
 scribbling a <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/school/thesis"</c-><c- p="">&gt;</c->thesis<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->To the west are several exits. One fun-looking exit is labeled <c- p="">&lt;</c-><c- f="">a</c->
 <c- e="">href</c-><c- o="">=</c-><c- s="">"https://games.example.com/"</c-><c- p="">&gt;</c->"games"<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->. Another more
 boring-looking exit is labeled <c- p="">&lt;</c-><c- f="">a</c->
 <c- e="">href</c-><c- o="">=</c-><c- s="">"https://isp.example.net/"</c-><c- p="">&gt;</c->ISP™<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->To the south lies a dark and dank <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/about"</c-><c- p="">&gt;</c->contacts
 page<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->. Cobwebs cover its disused entrance, and at one point you
 see a rat run quickly out of the page.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In this example, <code id="the-nav-element:the-nav-element-6"><a href="#the-nav-element">nav</a></code> is used in an email application, to let the user switch
   folders:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Compose"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"compose()"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Folders<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/inbox"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"return openFolder(this.href)"</c-><c- p="">&gt;</c->Inbox<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">count</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/sent"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"return openFolder(this.href)"</c-><c- p="">&gt;</c->Sent<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/drafts"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"return openFolder(this.href)"</c-><c- p="">&gt;</c->Drafts<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/trash"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"return openFolder(this.href)"</c-><c- p="">&gt;</c->Trash<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/customers"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"return openFolder(this.href)"</c-><c- p="">&gt;</c->Customers<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-aside-element"><span class="secno">4.3.5</span> The <dfn data-dfn-type="element"><code>aside</code></dfn> element<a href="#the-aside-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside" title="The <aside> HTML element represents a portion of a document whose content is only indirectly related to the document's main content. Asides are frequently presented as sidebars or call-out boxes.">Element/aside</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-aside-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-aside-element:flow-content-2">Flow content</a>.</dd><dd><a href="#sectioning-content-2" id="the-aside-element:sectioning-content-2">Sectioning content</a>.</dd><dd><a href="#palpable-content-2" id="the-aside-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-aside-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#sectioning-content-2" id="the-aside-element:sectioning-content-2-2">sectioning content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-aside-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-aside-element:flow-content-2-2">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-aside-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-aside-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-aside-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-aside-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-aside">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-aside">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-aside-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-aside-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-aside-element:the-aside-element"><a href="#the-aside-element">aside</a></code> element <a href="#represents" id="the-aside-element:represents">represents</a> a section of a page that consists of
  content that is tangentially related to the content around the <code id="the-aside-element:the-aside-element-2"><a href="#the-aside-element">aside</a></code> element, and
  which could be considered separate from that content. Such sections are often represented as
  sidebars in printed typography.</p>

  <p>The element can be used for typographical effects like pull quotes or sidebars, for
  advertising, for groups of <code id="the-aside-element:the-nav-element"><a href="#the-nav-element">nav</a></code> elements, and for other content that is considered
  separate from the main content of the page.</p>

  <p class="note">It's not appropriate to use the <code id="the-aside-element:the-aside-element-3"><a href="#the-aside-element">aside</a></code> element just for
  parentheticals, since those are part of the main flow of the document.</p>

  <div class="example">

   <p>The following example shows how an aside is used to mark up background material on Switzerland
   in a much longer news story on Europe.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Switzerland<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Switzerland, a land-locked country in the middle of geographic
 Europe, has not joined the geopolitical European Union, though it is
 a signatory to a number of European treaties.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The following example shows how an aside is used to mark up a pull quote in a longer
   article.</p>

   <pre><code class="html">...

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->He later joined a large company, continuing on the same work.
<c- p="">&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->I love my job. People ask me what I do for fun when I'm not at
work. But I'm paid to do my hobby, so I never know what to
answer. Some people wonder what they would do if they didn't have to
work... but I know what I would do, because I was unemployed for a
year, and I filled that time doing exactly what I do now.<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->People ask me what I do for fun when I'm not at work. But I'm
 paid to do my hobby, so I never know what to answer.<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Of course his work — or should that be hobby? —
isn't his only passion. He also enjoys other pleasures.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

...</code></pre>

  </div>

  <div class="example">

   <p>The following extract shows how <code id="the-aside-element:the-aside-element-4"><a href="#the-aside-element">aside</a></code> can be used for blogrolls and other side
   content on a blog:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->My wonderful blog<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My tagline<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
  <c- c="">&lt;!-- </c-><em><c- c="">this aside contains two sections that are tangentially related</c->
<c- c="">  to the page, namely, links to other blogs, and links to blog posts</c->
<c- c="">  from this blog</c-></em><c- c=""> --&gt;</c->
  <c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->My blogroll<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://blog.example.com/"</c-><c- p="">&gt;</c->Example Blog<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Archives<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">ol</c-> <c- e="">reversed</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/last-post"</c-><c- p="">&gt;</c->My last post<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/first-post"</c-><c- p="">&gt;</c->My first post<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
  <c- c="">&lt;!-- </c-><em><c- c="">this aside is tangentially related to the page also, it</c->
<c- c="">  contains twitter messages from the blog author</c-></em><c- c=""> --&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Twitter Feed<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">blockquote</c-> <c- e="">cite</c-><c- o="">=</c-><c- s="">"https://twitter.example.net/t31351234"</c-><c- p="">&gt;</c->
   I'm on vacation, writing my blog.
  <c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">blockquote</c-> <c- e="">cite</c-><c- o="">=</c-><c- s="">"https://twitter.example.net/t31219752"</c-><c- p="">&gt;</c->
   I'm going to go on vacation soon.
  <c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- c="">&lt;!-- </c-><em><c- c="">this is a blog post</c-></em><c- c=""> --&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->My last post<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This is my last post.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/last-post"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">bookmark</c-><c- p="">&gt;</c->Permalink<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- c="">&lt;!-- </c-><em><c- c="">this is also a blog post</c-></em><c- c=""> --&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->My first post<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This is my first post.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
   <c- c="">&lt;!-- </c-><em><c- c="">this aside is about the blog post, since it's inside the</c->
<c- c="">   &lt;article&gt; element; it would be wrong, for instance, to put the</c->
<c- c="">   blogroll here, since the blogroll isn't really related to this post</c->
<c- c="">   specifically, only to the page as a whole</c-></em><c- c=""> --&gt;</c->
   <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Posting<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->While I'm thinking about it, I wanted to say something about
   posting. Posting is fun!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/first-post"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">bookmark</c-><c- p="">&gt;</c->Permalink<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/archives"</c-><c- p="">&gt;</c->Archives<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> -
   <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/about"</c-><c- p="">&gt;</c->About me<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> -
   <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/copyright"</c-><c- p="">&gt;</c->Copyright<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><span class="secno">4.3.6</span> The <dfn id="the-h1-element" data-dfn-type="element"><code>h1</code></dfn>, <dfn id="the-h2-element" data-dfn-type="element"><code>h2</code></dfn>, <dfn id="the-h3-element" data-dfn-type="element"><code>h3</code></dfn>, <dfn id="the-h4-element" data-dfn-type="element"><code>h4</code></dfn>, <dfn id="the-h5-element" data-dfn-type="element"><code>h5</code></dfn>, and <dfn id="the-h6-element" data-dfn-type="element"><code>h6</code></dfn>
  elements<a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements" title="The <h1> to <h6> HTML elements represent six levels of section headings. <h1> is the highest section level and <h6> is the lowest.">Element/Heading_Elements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements" title="The <h1> to <h6> HTML elements represent six levels of section headings. <h1> is the highest section level and <h6> is the lowest.">Element/Heading_Elements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements" title="The <h1> to <h6> HTML elements represent six levels of section headings. <h1> is the highest section level and <h6> is the lowest.">Element/Heading_Elements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements" title="The <h1> to <h6> HTML elements represent six levels of section headings. <h1> is the highest section level and <h6> is the lowest.">Element/Heading_Elements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements" title="The <h1> to <h6> HTML elements represent six levels of section headings. <h1> is the highest section level and <h6> is the lowest.">Element/Heading_Elements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements" title="The <h1> to <h6> HTML elements represent six levels of section headings. <h1> is the highest section level and <h6> is the lowest.">Element/Heading_Elements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLHeadingElement" title="The HTMLHeadingElement interface represents the different heading elements, <h1> through <h6>. It inherits methods and properties from the HTMLElement interface.">HTMLHeadingElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:flow-content-2">Flow content</a>.</dd><dd><a href="#heading-content-2" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:heading-content-2">Heading content</a>.</dd><dd><a href="#palpable-content-2" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of an <code id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code> element.</dd><dd>Where <a href="#heading-content-2" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:heading-content-2-2">heading content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-h1-h6">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-h1-h6">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlheadingelement" data-dfn-type="interface"><c- g="">HTMLHeadingElement</c-></dfn> : <a href="#htmlelement" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLHeadingElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>These elements <a href="#represents" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:represents">represent</a> headings for their sections.</p>

  <p>The semantics and meaning of these elements are defined in the section on <a href="#headings-and-outlines">headings and outlines</a>.</p>

  <p>These elements have a <a href="#heading-level" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:heading-level">heading level</a> given by the number in their name. The
  <a href="#heading-level" id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:heading-level-2">heading level</a> corresponds to the levels of nested sections. The <code id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>
  element is for a top-level section, <code id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code> for a subsection, <code id="the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code> for a
  sub-subsection, and so on.</p>

  <div class="example">

   <p>As far as their respective document outlines (their heading and section structures) are
   concerned, these two snippets are semantically equivalent:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Let's call it a draw(ing surface)<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Diving in<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Simple shapes<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Canvas coordinates<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Canvas coordinates diagram<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Paths<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Let's call it a draw(ing surface)<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Diving in<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Simple shapes<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Canvas coordinates<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Canvas coordinates diagram<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Paths<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

   <p>Authors might prefer the former style for its terseness, or the latter style for its
   additional styling hooks. Which is best is purely an issue of preferred authoring style.</p>
  </div>


  <h4 id="the-hgroup-element"><span class="secno">4.3.7</span> The <dfn data-dfn-type="element"><code>hgroup</code></dfn> element<a href="#the-hgroup-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hgroup" title="The <hgroup> HTML element represents a heading and related content. It groups a single <h1>–<h6> element with one or more <p>.">Element/hgroup</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>2.2+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-hgroup-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-hgroup-element:flow-content-2">Flow content</a>.</dd><dd><a href="#heading-content-2" id="the-hgroup-element:heading-content-2">Heading content</a>.</dd><dd><a href="#palpable-content-2" id="the-hgroup-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-hgroup-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#heading-content-2" id="the-hgroup-element:heading-content-2-2">heading content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-hgroup-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or more <code id="the-hgroup-element:the-p-element"><a href="#the-p-element">p</a></code> elements, followed by one <code id="the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, <code id="the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>,
   <code id="the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, <code id="the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>, <code id="the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>, or <code id="the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> element, followed by zero
   or more <code id="the-hgroup-element:the-p-element-2"><a href="#the-p-element">p</a></code> elements, optionally intermixed with <a href="#script-supporting-elements-2" id="the-hgroup-element:script-supporting-elements-2">script-supporting
   elements</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-hgroup-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-hgroup-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-hgroup-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-hgroup-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-hgroup">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-hgroup">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-hgroup-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-hgroup-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-hgroup-element:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code> element <a href="#represents" id="the-hgroup-element:represents">represents</a> a heading and related content. The
  element may be used to group an <code id="the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-7"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>–<code id="the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-8"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> element with one or more
  <code id="the-hgroup-element:the-p-element-3"><a href="#the-p-element">p</a></code> elements containing content representing a subheading, alternative title, or
  tagline.</p>

  <div class="example">
   <p>Here are some examples of valid headings contained within an <code id="the-hgroup-element:the-hgroup-element-2"><a href="#the-hgroup-element">hgroup</a></code> element.</p>

    <pre><code class="html"><c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The reality dysfunction<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Space is not the only void<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c-></code></pre>

    <pre><code class="html"><c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Dr. Strangelove<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Or: How I Learned to Stop Worrying and Love the Bomb<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <h4 id="the-header-element"><span class="secno">4.3.8</span> The <dfn data-dfn-type="element"><code>header</code></dfn> element<a href="#the-header-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header" title="The <header> HTML element represents introductory content, typically a group of introductory or navigational aids. It may contain some heading elements but also a logo, a search form, an author name, and other elements.">Element/header</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-header-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-header-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-header-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-header-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-header-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-header-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-header-element:flow-content-2-3">Flow content</a>, but with no <code id="the-header-element:the-header-element"><a href="#the-header-element">header</a></code> or <code id="the-header-element:the-footer-element"><a href="#the-footer-element">footer</a></code> element
   descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-header-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-header-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-header-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-header-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd>If there is an ancestor <a href="#sectioning-content-2" id="the-header-element:sectioning-content-2">sectioning content</a> element: <a href="https://w3c.github.io/html-aria/#el-header">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-header">for implementers</a>.</dd><dd>Otherwise: <a href="https://w3c.github.io/html-aria/#el-header">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-header-ancestorbody">for implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-header-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-header-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-header-element:the-header-element-2"><a href="#the-header-element">header</a></code> element <a href="#represents" id="the-header-element:represents">represents</a> a group of introductory or navigational
  aids.</p>

  <p class="note">A <code id="the-header-element:the-header-element-3"><a href="#the-header-element">header</a></code> element is intended to usually contain a heading
  (an <code id="the-header-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>–<code id="the-header-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> element or an <code id="the-header-element:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code> element), but this is
  not required. The <code id="the-header-element:the-header-element-4"><a href="#the-header-element">header</a></code> element can also be used to wrap a section's table of
  contents, a search form, or any relevant logos.</p>

  <div class="example">

  <p>Here are some sample headers. This first one is for a game:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to...<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Voidwars!<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c-></code></pre>

   <p>The following snippet shows how the element can be used to mark
   up a specification's header:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Fullscreen API<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Living Standard — Last Updated 19 October 2015<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Participate:<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://github.com/whatwg/fullscreen"</c-><c- p="">&gt;</c->GitHub whatwg/fullscreen<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Commits:<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://github.com/whatwg/fullscreen/commits"</c-><c- p="">&gt;</c->GitHub whatwg/fullscreen/commits<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p class="note">The <code id="the-header-element:the-header-element-5"><a href="#the-header-element">header</a></code> element is not <a href="#sectioning-content-2" id="the-header-element:sectioning-content-2-2">sectioning content</a>; it doesn't
  introduce a new section.</p>

  <div class="example">

  <p>In this example, the page has a page heading given by the <code id="the-header-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code> element, and two
  subsections whose headings are given by <code id="the-header-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code> elements. The content after the
  <code id="the-header-element:the-header-element-6"><a href="#the-header-element">header</a></code> element is still part of the last subsection started in the
  <code id="the-header-element:the-header-element-7"><a href="#the-header-element">header</a></code> element, because the <code id="the-header-element:the-header-element-8"><a href="#the-header-element">header</a></code> element doesn't take part in the
  <a href="#outline" id="the-header-element:outline">outline</a> algorithm.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Little Green Guys With Guns<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/games"</c-><c- p="">&gt;</c->Games<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/forum"</c-><c- p="">&gt;</c->Forum<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/download"</c-><c- p="">&gt;</c->Download<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Important News<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- this starts a second subsection --&gt;</c->
  <c- c="">&lt;!-- this is part of the subsection entitled "Important News" --&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->To play today's games you will need to update your client.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Games<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- this starts a third subsection --&gt;</c->
 <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You have three active games:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- c="">&lt;!-- this is still part of the subsection entitled "Games" --&gt;</c->
 ...</code></pre>

  </div>




  <h4 id="the-footer-element"><span class="secno">4.3.9</span> The <dfn data-dfn-type="element"><code>footer</code></dfn> element<a href="#the-footer-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/footer" title="The <footer> HTML element represents a footer for its nearest ancestor sectioning content or sectioning root element. A <footer> typically contains information about the author of the section, copyright data or links to related documents.">Element/footer</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-footer-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-footer-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-footer-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-footer-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-footer-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-footer-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-footer-element:flow-content-2-3">Flow content</a>, but with no <code id="the-footer-element:the-header-element"><a href="#the-header-element">header</a></code> or <code id="the-footer-element:the-footer-element"><a href="#the-footer-element">footer</a></code> element
   descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-footer-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-footer-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-footer-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-footer-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd>If there is an ancestor <a href="#sectioning-content-2" id="the-footer-element:sectioning-content-2">sectioning content</a> element: <a href="https://w3c.github.io/html-aria/#el-footer">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-footer">for implementers</a>.</dd><dd>Otherwise: <a href="https://w3c.github.io/html-aria/#el-footer">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-footer-ancestorbody">for implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-footer-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-footer-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-footer-element:the-footer-element-2"><a href="#the-footer-element">footer</a></code> element <a href="#represents" id="the-footer-element:represents">represents</a> a footer for its nearest ancestor
  <a href="#sectioning-content-2" id="the-footer-element:sectioning-content-2-2">sectioning content</a> element, or for <a href="#the-body-element-2" id="the-footer-element:the-body-element-2">the body element</a> if there is no such
  ancestor. A footer typically contains information about its section such as who wrote it, links
  to related documents, copyright data, and the like.</p>

  <p>When the <code id="the-footer-element:the-footer-element-3"><a href="#the-footer-element">footer</a></code> element contains entire sections, they <a href="#represents" id="the-footer-element:represents-2">represent</a> appendices, indices, long colophons, verbose license
  agreements, and other such content.</p>

  <p class="note">Contact information for the author or editor of a section belongs in an
  <code id="the-footer-element:the-address-element"><a href="#the-address-element">address</a></code> element, possibly itself inside a <code id="the-footer-element:the-footer-element-4"><a href="#the-footer-element">footer</a></code>. Bylines and other
  information that could be suitable for both a <code id="the-footer-element:the-header-element-2"><a href="#the-header-element">header</a></code> or a <code id="the-footer-element:the-footer-element-5"><a href="#the-footer-element">footer</a></code> can be
  placed in either (or neither). The primary purpose of these elements is merely to help the author
  write self-explanatory markup that is easy to maintain and style; they are not intended to impose
  specific structures on authors.</p>

  <p>Footers don't necessarily have to appear at the <em>end</em> of a section, though they usually
  do.</p>

  <p>When there is no ancestor <a href="#sectioning-content-2" id="the-footer-element:sectioning-content-2-3">sectioning content</a> element, then it applies to the whole
  page.</p>

  <p class="note">The <code id="the-footer-element:the-footer-element-6"><a href="#the-footer-element">footer</a></code> element is not itself <a href="#sectioning-content-2" id="the-footer-element:sectioning-content-2-4">sectioning content</a>; it
  doesn't introduce a new section.</p>

  <div class="example">

   <p>Here is a page with two footers, one at the top and one at the bottom, with the same
   content:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"../"</c-><c- p="">&gt;</c->Back to index...<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Lorem ipsum<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The ipsum of all lorems<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->A dolor sit amet, consectetur adipisicing elit, sed do eiusmod
 tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
 veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
 ea commodo consequat. Duis aute irure dolor in reprehenderit in
 voluptate velit esse cillum dolore eu fugiat nulla
 pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
 culpa qui officia deserunt mollit anim id est laborum.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"../"</c-><c- p="">&gt;</c->Back to index...<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Here is an example which shows the <code id="the-footer-element:the-footer-element-7"><a href="#the-footer-element">footer</a></code> element being used both for a site-wide
   footer and for a section footer.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">HTML</c-> <c- e="">LANG</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;&lt;</c-><c- f="">HEAD</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">TITLE</c-><c- p="">&gt;</c->The Ramblings of a Scientist<c- p="">&lt;/</c-><c- f="">TITLE</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">BODY</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">H1</c-><c- p="">&gt;</c->The Ramblings of a Scientist<c- p="">&lt;/</c-><c- f="">H1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ARTICLE</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">H1</c-><c- p="">&gt;</c->Episode 15<c- p="">&lt;/</c-><c- f="">H1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">VIDEO</c-> <c- e="">SRC</c-><c- o="">=</c-><c- s="">"/fm/015.ogv"</c-> <c- e="">CONTROLS</c-> <c- e="">PRELOAD</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">P</c-><c- p="">&gt;&lt;</c-><c- f="">A</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/fm/015.ogv"</c-><c- p="">&gt;</c->Download video<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">P</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">VIDEO</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">FOOTER</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- footer for article --&gt;</c->
  <c- p="">&lt;</c-><c- f="">P</c-><c- p="">&gt;</c->Published <c- p="">&lt;</c-><c- f="">TIME</c-> <c- e="">DATETIME</c-><c- o="">=</c-><c- s="">"2009-10-21T18:26-07:00"</c-><c- p="">&gt;</c->on 2009/10/21 at 6:26pm<c- p="">&lt;/</c-><c- f="">TIME</c-><c- p="">&gt;&lt;/</c-><c- f="">P</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">FOOTER</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ARTICLE</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ARTICLE</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">H1</c-><c- p="">&gt;</c->My Favorite Trains<c- p="">&lt;/</c-><c- f="">H1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">P</c-><c- p="">&gt;</c->I love my trains. My favorite train of all time is a Köf.<c- p="">&lt;/</c-><c- f="">P</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">P</c-><c- p="">&gt;</c->It is fun to see them pull some coal cars because they look so
 dwarfed in comparison.<c- p="">&lt;/</c-><c- f="">P</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">FOOTER</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- footer for article --&gt;</c->
  <c- p="">&lt;</c-><c- f="">P</c-><c- p="">&gt;</c->Published <c- p="">&lt;</c-><c- f="">TIME</c-> <c- e="">DATETIME</c-><c- o="">=</c-><c- s="">"2009-09-15T14:54-07:00"</c-><c- p="">&gt;</c->on 2009/09/15 at 2:54pm<c- p="">&lt;/</c-><c- f="">TIME</c-><c- p="">&gt;&lt;/</c-><c- f="">P</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">FOOTER</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ARTICLE</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">FOOTER</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- site wide footer --&gt;</c->
 <c- p="">&lt;</c-><c- f="">NAV</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">P</c-><c- p="">&gt;&lt;</c-><c- f="">A</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/credits.html"</c-><c- p="">&gt;</c->Credits<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c-> —
     <c- p="">&lt;</c-><c- f="">A</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/tos.html"</c-><c- p="">&gt;</c->Terms of Service<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c-> —
     <c- p="">&lt;</c-><c- f="">A</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/index.html"</c-><c- p="">&gt;</c->Blog Index<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;&lt;/</c-><c- f="">P</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">NAV</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">P</c-><c- p="">&gt;</c->Copyright © 2009 Gordon Freeman<c- p="">&lt;/</c-><c- f="">P</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">FOOTER</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">BODY</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">HTML</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Some site designs have what is sometimes referred to as "fat footers" — footers that
   contain a lot of material, including images, links to other articles, links to pages for sending
   feedback, special offers... in some ways, a whole "front page" in the footer.</p>

   <p>This fragment shows the bottom of a page on a site with a "fat footer":</p>

   <pre><code class="html">...
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Articles<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/somersaults.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-> Go to the gym with
    our somersaults class! Our teacher Jim takes you through the paces
    in this two-part article. <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"articles/somersaults/1"</c-><c- p="">&gt;</c->Part
    1<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> · <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"articles/somersaults/2"</c-><c- p="">&gt;</c->Part 2<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/kindplus.jpeg"</c-><c- p="">&gt;</c-> Tired of walking on the edge of
    a clif<c- c="">&lt;!-- sic --&gt;</c->? Our guest writer Lara shows you how to bumble
    your way through the bars. <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"articles/kindplus/1"</c-><c- p="">&gt;</c->Read
    more...<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/crisps.jpeg"</c-><c- p="">&gt;</c-> The chips are down, now all
    that's left is a potato. What can you do with it? <c- p="">&lt;</c-><c- f="">a</c->
    <c- e="">href</c-><c- o="">=</c-><c- s="">"articles/crisps/1"</c-><c- p="">&gt;</c->Read more...<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/about"</c-><c- p="">&gt;</c->About us...<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/feedback"</c-><c- p="">&gt;</c->Send feedback!<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/sitemap"</c-><c- p="">&gt;</c->Sitemap<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Copyright © 2015 The Snacker —
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/tos"</c-><c- p="">&gt;</c->Terms of Service<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-address-element"><span class="secno">4.3.10</span> The <dfn data-dfn-type="element"><code>address</code></dfn> element<a href="#the-address-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/address" title="The <address> HTML element indicates that the enclosed HTML provides contact information for a person or people, or for an organization.">Element/address</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-address-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-address-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-address-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-address-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-address-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-address-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-address-element:flow-content-2-3">Flow content</a>, but with no <a href="#heading-content-2" id="the-address-element:heading-content-2">heading
   content</a> descendants, no <a href="#sectioning-content-2" id="the-address-element:sectioning-content-2">sectioning content</a>
   descendants, and no <code id="the-address-element:the-header-element"><a href="#the-header-element">header</a></code>, <code id="the-address-element:the-footer-element"><a href="#the-footer-element">footer</a></code>, or
   <code id="the-address-element:the-address-element"><a href="#the-address-element">address</a></code> element descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-address-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-address-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-address-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-address-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-address">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-address">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-address-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-address-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-address-element:the-address-element-2"><a href="#the-address-element">address</a></code> element <a href="#represents" id="the-address-element:represents">represents</a> the contact information for its
  nearest <code id="the-address-element:the-article-element"><a href="#the-article-element">article</a></code> or <code id="the-address-element:the-body-element"><a href="#the-body-element">body</a></code> element ancestor. If that is <a href="#the-body-element-2" id="the-address-element:the-body-element-2">the body
  element</a>, then the contact information applies to the document as a whole.</p>

  <div class="example">
   <p>For example, a page at the W3C web site related to HTML might
   include the following contact information:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">ADDRESS</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">A</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"../People/Raggett/"</c-><c- p="">&gt;</c->Dave Raggett<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c->,
 <c- p="">&lt;</c-><c- f="">A</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"../People/Arnaud/"</c-><c- p="">&gt;</c->Arnaud Le Hors<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c->,
 contact persons for the <c- p="">&lt;</c-><c- f="">A</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"Activity"</c-><c- p="">&gt;</c->W3C HTML Activity<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ADDRESS</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>The <code id="the-address-element:the-address-element-3"><a href="#the-address-element">address</a></code> element must not be used to represent arbitrary addresses (e.g. postal
  addresses), unless those addresses are in fact the relevant contact information. (The
  <code id="the-address-element:the-p-element"><a href="#the-p-element">p</a></code> element is the appropriate element for marking up postal addresses in general.)</p>

  <p>The <code id="the-address-element:the-address-element-4"><a href="#the-address-element">address</a></code> element must not contain information other than contact
  information.</p>

  <div class="example">
   <p>For example, the following is non-conforming use of the
   <code id="the-address-element:the-address-element-5"><a href="#the-address-element">address</a></code> element:</p>
   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">ADDRESS</c-><c- p="">&gt;</c->Last Modified: 1999/12/24 23:37:50<c- p="">&lt;/</c-><c- f="">ADDRESS</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>Typically, the <code id="the-address-element:the-address-element-6"><a href="#the-address-element">address</a></code> element would be included along with other information in a
  <code id="the-address-element:the-footer-element-2"><a href="#the-footer-element">footer</a></code> element.</p>

  

  <div data-algorithm="">
  <p>The contact information for a node <var>node</var> is a collection of
  <code id="the-address-element:the-address-element-7"><a href="#the-address-element">address</a></code> elements defined by the first applicable entry from the following list:</p>

  <dl class="switch"><dt>If <var>node</var> is an <code id="the-address-element:the-article-element-2"><a href="#the-article-element">article</a></code> element</dt><dt>If <var>node</var> is a <code id="the-address-element:the-body-element-3"><a href="#the-body-element">body</a></code> element</dt><dd>
    <p>The contact information consists of all the <code id="the-address-element:the-address-element-8"><a href="#the-address-element">address</a></code> elements that have <var>node</var> as an ancestor and do not have another <code id="the-address-element:the-body-element-4"><a href="#the-body-element">body</a></code> or
    <code id="the-address-element:the-article-element-3"><a href="#the-article-element">article</a></code> element ancestor that is a descendant of <var>node</var>.</p>
   </dd><dt>If <var>node</var> has an ancestor element that is an <code id="the-address-element:the-article-element-4"><a href="#the-article-element">article</a></code> element</dt><dt>If <var>node</var> has an ancestor element that is a <code id="the-address-element:the-body-element-5"><a href="#the-body-element">body</a></code> element</dt><dd>
    <p>The contact information of <var>node</var> is the same as the contact information of
    the nearest <code id="the-address-element:the-article-element-5"><a href="#the-article-element">article</a></code> or <code id="the-address-element:the-body-element-6"><a href="#the-body-element">body</a></code> element ancestor, whichever is
    nearest.</p>
   </dd><dt>If <var>node</var>'s <a id="the-address-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> has <a href="#the-body-element-2" id="the-address-element:the-body-element-2-2">a body
   element</a></dt><dd>
    <p>The contact information of <var>node</var> is the same as the contact information of
    <a href="#the-body-element-2" id="the-address-element:the-body-element-2-3">the body element</a> of the <code id="the-address-element:document"><a href="#document">Document</a></code>.</p>
   </dd><dt>Otherwise</dt><dd>
    <p>There is no contact information for <var>node</var>.</p>
   </dd></dl>
  </div>

  <p>User agents may expose the contact information of a node to the user, or use it for other
  purposes, such as indexing sections based on the sections' contact information.</p>

  

  <div class="example">

   <p>In this example the footer contains contact information and a copyright notice.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">address</c-><c- p="">&gt;</c->
  For more details, contact
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"mailto:js@example.com"</c-><c- p="">&gt;</c->John Smith<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.
 <c- p="">&lt;/</c-><c- f="">address</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->© copyright 2038 Example Corp.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="headings-and-outlines-2"><span class="secno">4.3.11</span> <span id="headings-and-outlines"></span><span id="outlines"></span>Headings and outlines<a href="#headings-and-outlines-2" class="self-link"></a></h4>

  <p><code id="headings-and-outlines-2:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>–<code id="headings-and-outlines-2:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> elements have a <dfn id="heading-level">heading level</dfn>, which is
  given by <a href="#get-an-element's-computed-heading-level" id="headings-and-outlines-2:get-an-element's-computed-heading-level">getting the element's computed
  heading level</a>.</p>

  <p>These elements <a href="#represents" id="headings-and-outlines-2:represents">represent</a> <dfn id="concept-heading">headings</dfn>. The lower a <a href="#concept-heading" id="headings-and-outlines-2:concept-heading">heading</a>'s <a href="#heading-level" id="headings-and-outlines-2:heading-level">heading level</a> is, the fewer ancestor
  sections the <a href="#concept-heading" id="headings-and-outlines-2:concept-heading-2">heading</a> has.</p>

  <div data-algorithm="">
  <p>The <dfn id="outline">outline</dfn> is all <a href="#concept-heading" id="headings-and-outlines-2:concept-heading-3">headings</a> in a
  document, in <a id="headings-and-outlines-2:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p>
  </div>

  <p>The <a href="#outline" id="headings-and-outlines-2:outline">outline</a> should be used for generating document outlines, for example when
  generating tables of contents. When creating an interactive table of contents, entries should
  jump the user to the relevant <a href="#concept-heading" id="headings-and-outlines-2:concept-heading-4">heading</a>.</p>

  <p>If a document has one or more <a href="#concept-heading" id="headings-and-outlines-2:concept-heading-5">headings</a>, at least a
  single <a href="#concept-heading" id="headings-and-outlines-2:concept-heading-6">heading</a> within the <a href="#outline" id="headings-and-outlines-2:outline-2">outline</a> should have
  a <a href="#heading-level" id="headings-and-outlines-2:heading-level-2">heading level</a> of 1.</p>

  <div data-algorithm="">
  <p>Each <a href="#concept-heading" id="headings-and-outlines-2:concept-heading-7">heading</a> following another <a href="#concept-heading" id="headings-and-outlines-2:concept-heading-8">heading</a> <var>lead</var> in the <a href="#outline" id="headings-and-outlines-2:outline-3">outline</a> must
  have a <a href="#heading-level" id="headings-and-outlines-2:heading-level-3">heading level</a> that is less than, equal to, or 1 greater than <var>lead</var>'s
  <a href="#heading-level" id="headings-and-outlines-2:heading-level-4">heading level</a>.</p>
  </div>

  <div class="example">
   <p>The following example is non-conforming:</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Apples<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Apples are fruit.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Taste<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->They taste lovely.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

   <p>It could be written as follows and then it would be conforming:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Apples<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Apples are fruit.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Taste<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->They taste lovely.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <h5 id="heading-levels-&amp;-offsets"><span class="secno">4.3.11.1</span> Heading levels &amp; offsets<a href="#heading-levels-&amp;-offsets" class="self-link"></a></h5>

  <p>The <dfn data-dfn-for="global" id="attr-headingoffset" data-dfn-type="element-attr"><code>headingoffset</code></dfn>
  content attribute allows authors to offset heading levels for descendants.</p>

  <p>The <dfn data-dfn-for="global" id="attr-headingreset" data-dfn-type="element-attr"><code>headingreset</code></dfn>
  content attribute allows authors to prevent a heading offset computation from traversing beyond
  the element with the attribute.</p>

  <div data-algorithm="">
  <p>To <dfn id="get-an-element's-computed-heading-level">get an element's computed heading level</dfn>, given an element
  <var>element</var>:</p>

  <ol><li><p>Let <var>level</var> be 0.</p></li><li><p>If <var>element</var>'s local name is <code id="heading-levels-&amp;-offsets:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, then set
   <var>level</var> to 1.</p></li><li><p>If <var>element</var>'s local name is <code id="heading-levels-&amp;-offsets:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>, then set
   <var>level</var> to 2.</p></li><li><p>If <var>element</var>'s local name is <code id="heading-levels-&amp;-offsets:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, then set
   <var>level</var> to 3.</p></li><li><p>If <var>element</var>'s local name is <code id="heading-levels-&amp;-offsets:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>, then set
   <var>level</var> to 4.</p></li><li><p>If <var>element</var>'s local name is <code id="heading-levels-&amp;-offsets:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>, then set
   <var>level</var> to 5.</p></li><li><p>If <var>element</var>'s local name is <code id="heading-levels-&amp;-offsets:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>, then set
   <var>level</var> to 6.</p></li><li><p><a id="heading-levels-&amp;-offsets:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>level</var> is not 0.</p></li><li><p>Increment <var>level</var> by the result of <a href="#get-an-element's-computed-heading-offset" id="heading-levels-&amp;-offsets:get-an-element's-computed-heading-offset">getting an element's computed heading
   offset</a> given <var>element</var>.</p></li><li><p>If <var>level</var> is greater than 9, then return 9.</p></li><li><p>Return <var>level</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="get-an-element's-computed-heading-offset">get an element's computed heading offset</dfn>, given an element <var>element</var>,
  perform the following steps. They return a non-negative integer.</p>

  <ol><li><p>Let <var>offset</var> be 0.</p></li><li><p>Let <var>inclusiveAncestor</var> be <var>element</var>.</p></li><li>
    <p>While <var>inclusiveAncestor</var> is not null:</p>

    <ol><li><p>Let <var>nextOffset</var> be 0.</p></li><li>
      <p>If <var>inclusiveAncestor</var> is an <a href="#html-elements" id="heading-levels-&amp;-offsets:html-elements">HTML element</a> and
      has a <code id="heading-levels-&amp;-offsets:attr-headingoffset"><a href="#attr-headingoffset">headingoffset</a></code> attribute, then parse its value
      using the <a href="#rules-for-parsing-non-negative-integers" id="heading-levels-&amp;-offsets:rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a>.</p>

      <p>If the result of parsing the value is not an error, then set <var>nextOffset</var> to that
      value.</p>
     </li><li><p>Increment <var>offset</var> by <var>nextOffset</var>.</p></li><li><p>If <var>inclusiveAncestor</var> is an <a href="#html-elements" id="heading-levels-&amp;-offsets:html-elements-2">HTML element</a>
     and has a <code id="heading-levels-&amp;-offsets:attr-headingreset"><a href="#attr-headingreset">headingreset</a></code> attribute, then return
     <var>offset</var>.</p></li><li><p>Set <var>inclusiveAncestor</var> to the parent node of <var>inclusiveAncestor</var>
     within the <a id="heading-levels-&amp;-offsets:flat-tree" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a>.</p></li></ol>
   </li><li><p>Return <var>offset</var>.</p></li></ol>
  </div>

  <div class="example">
   <p>This example shows a combination of <code id="heading-levels-&amp;-offsets:attr-headingoffset-2"><a href="#attr-headingoffset">headingoffset</a></code>,
   <code id="heading-levels-&amp;-offsets:attr-headingreset-2"><a href="#attr-headingreset">headingreset</a></code>, and <code id="heading-levels-&amp;-offsets:attr-aria-level"><a data-x-internal="attr-aria-level" href="https://w3c.github.io/aria/#aria-level">aria-level</a></code> attributes with comments demonstrating the respective
   heading levels. This example illustrates the various combinations and is not a best practice
   example.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">main</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->This is a heading level 1<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">article</c-> <c- e="">headingoffset</c-><c- o="">=</c-><c- s="">"1"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->This is a heading level 2<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">section</c-> <c- e="">headingoffset</c-><c- o="">=</c-><c- s="">"1"</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->This is a heading level 3<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">dialog</c-> <c- e="">headingreset</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->This is a heading level 1<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
     <c- p="">&lt;/</c-><c- f="">dialog</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h1</c-> <c- e="">aria-level</c-><c- o="">=</c-><c- s="">"2"</c-><c- p="">&gt;</c->This is a heading level 2<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">main</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <h5 id="sample-outlines"><span class="secno">4.3.11.2</span> Sample outlines<a href="#sample-outlines" class="self-link"></a></h5>

  <div class="example">
   <p>The following markup fragment:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">hgroup</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"document-title"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->HTML: Living Standard<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Last Updated 12 August 2016<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Some intro to the document.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Table of contents<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">ol</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">toc</c-><c- p="">&gt;</c->...<c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->First section<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Some intro to the first section.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

   <p>...results in 3 document headings:</p>

   <ol class="brief"><li><p><code>&lt;h1&gt;HTML: Living Standard&lt;/h1&gt;</code></p></li><li><p><code>&lt;h2&gt;Table of contents&lt;/h2&gt;</code>.</p></li><li><p><code>&lt;h2&gt;First section&lt;/h2&gt;</code>.</p></li></ol>

   <p>A rendered view of the <a href="#outline" id="sample-outlines:outline">outline</a> might look like:</p>

   <p><img class="darkmode-aware" src="/images/outline.svg" width="465" alt="Top-level section with the heading &quot;HTML: Living Standard&quot; and two subsections; &quot;Table of contents&quot; and &quot;First section&quot;." height="120"></p>
  </div>

  <div class="example">
   <p>First, here is a document, which is a book with very short chapters and subsections:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->The Tax Book (all in one page)<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The Tax Book<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Earning money<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Earning money is good.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Getting a job<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->To earn money you typically need a job.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Spending money<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Spending is what money is mainly used for.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Cheap things<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Buying cheap things often not cost-effective.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Expensive things<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The most expensive thing is often not the most cost-effective either.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Investing money<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You can lend your money to other people.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Losing money<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If you spend money or invest money, sooner or later you will lose money.
<c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Poor judgement<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Usually if you lose money it's because you made a mistake.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Its <a href="#outline" id="sample-outlines:outline-2">outline</a> could be presented as follows:</p>

   <ol class="brief"><li>
     The Tax Book
     <ol class="brief"><li>
       Earning money
       <ol class="brief"><li>Getting a job</li></ol>
      </li><li>
       Spending money
       <ol class="brief"><li>Cheap things</li><li>Expensive things</li></ol>
      </li><li>Investing money</li><li>
       Losing money
       <ol class="brief"><li>Poor judgement</li></ol>
      </li></ol>
   </li></ol>

   <p>Notice that the <code id="sample-outlines:the-title-element"><a href="#the-title-element">title</a></code> element is not a <a href="#concept-heading" id="sample-outlines:concept-heading">heading</a>.</p>
  </div>

  <div class="example">
   <p>A document can contain multiple top-level headings:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Alphabetic Fruit<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Apples<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Pomaceous.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Bananas<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Edible.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Carambola<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Star.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>The document's <a href="#outline" id="sample-outlines:outline-3">outline</a> could be presented as follows:</p>

   <ol class="brief"><li>Apples</li><li>Bananas</li><li>Carambola</li></ol>
  </div>

  <div class="example">
   <p><code id="sample-outlines:the-header-element"><a href="#the-header-element">header</a></code> elements do not influence the <a href="#outline" id="sample-outlines:outline-4">outline</a> of a
   document:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->We're adopting a child! — Ray's blog<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Ray's blog<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?t=-1d"</c-><c- p="">&gt;</c->Yesterday<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->;
   <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?t=-7d"</c-><c- p="">&gt;</c->Last week<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->;
   <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?t=-1m"</c-><c- p="">&gt;</c->Last month<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->We're adopting a child!<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->As of today, Janine and I have signed the papers to become
 the proud parents of baby Diane! We've been looking forward to
 this day for weeks.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>The document's <a href="#outline" id="sample-outlines:outline-5">outline</a> could be presented as follows:</p>

   <ol class="brief"><li> Ray's blog
     <ol class="brief"><li> We're adopting a child!
     </li></ol>
   </li></ol>
  </div>

  <hr>

  <div class="example">
   <p>The following example is conforming, but not encouraged as it has no <a href="#concept-heading" id="sample-outlines:concept-heading-2">heading</a> whose <a href="#heading-level" id="sample-outlines:heading-level">heading level</a> is 1:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Alphabetic Fruit<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Apples<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Pomaceous.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Bananas<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Edible.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Carambola<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Star.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>The document's <a href="#outline" id="sample-outlines:outline-6">outline</a> could be presented as follows:</p>

   <ol class="brief"><li>
     <ol class="brief"><li>Apples</li><li>Bananas</li><li>Carambola</li></ol>
    </li></ol>
  </div>

  <div class="example">
   <p>The following example is conforming, but not encouraged as the first <a href="#concept-heading" id="sample-outlines:concept-heading-3">heading</a>'s <a href="#heading-level" id="sample-outlines:heading-level-2">heading level</a> is not 1:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Feathers on The Site of Encyclopedic Knowledge<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->A plea from our caretakers<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Please, we beg of you, send help! We're stuck in the server room!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Feathers<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Epidermal growths.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  <p>The document's <a href="#outline" id="sample-outlines:outline-7">outline</a> could be presented as follows:</p>

  <ol class="brief"><li>
     <ol class="brief"><li>A plea from our caretakers</li></ol>
    </li><li>Feathers</li></ol>
  </div>


  <h5 id="exposing-outlines-to-users"><span class="secno">4.3.11.3</span> Exposing outlines to users<a href="#exposing-outlines-to-users" class="self-link"></a></h5>

  <p>User agents are encouraged to expose page <a href="#outline" id="exposing-outlines-to-users:outline">outlines</a> to users to
  aid in navigation. This is especially true for non-visual media, e.g. screen readers.</p>

  <div class="example">
   <p>For instance, a user agent could map the arrow keys as follows:</p>

   <dl><dt><kbd><kbd>Shift</kbd> + <kbd>← Left</kbd></kbd></dt><dd>Go to previous heading</dd><dt><kbd><kbd>Shift</kbd> + <kbd>→ Right</kbd></kbd></dt><dd>Go to next heading</dd><dt><kbd><kbd>Shift</kbd> + <kbd>↑ Up</kbd></kbd></dt><dd>Go to next heading whose <a href="#heading-level" id="exposing-outlines-to-users:heading-level">level</a> is one less than the
    current heading's level</dd><dt><kbd><kbd>Shift</kbd> + <kbd>↓ Down</kbd></kbd></dt><dd>Go to next heading whose <a href="#heading-level" id="exposing-outlines-to-users:heading-level-2">level</a> is the same as the
    current heading's level</dd></dl>
  </div>


  <h4 id="usage-summary-2"><span class="secno">4.3.12</span> Usage summary<a href="#usage-summary-2" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <table class="vertical-summary-table"><thead><tr><th rowspan="2">Element
     </th><th>Purpose
    </th></tr><tr><th>Example
   </th></tr></thead><tbody><tr><td rowspan="2"><code id="usage-summary-2:the-body-element"><a href="#the-body-element">body</a></code>
     </td><td>The contents of the document.
    </td></tr><tr><td><pre class="example"><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Steve Hill's Home Page<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c-></strong> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Hard Trance is My Life.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-> <strong><c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

    </td></tr><tr><td rowspan="2"><code id="usage-summary-2:the-article-element"><a href="#the-article-element">article</a></code>
     </td><td>A complete, or self-contained,
  composition in a document, page, application, or site and that is, in principle, independently
  distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or
  newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any
  other independent item of content.
    </td></tr><tr><td><pre class="example"><code class="html"><strong><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/tumblr_masqy2s5yn1rzfqbpo1_500.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Yellow smiley face with the caption 'masif'"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My fave Masif tee so far!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->Posted 2 days ago<c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></strong>
<strong><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/tumblr_m9tf6wSr6W1rzfqbpo1_500.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Happy 2nd birthday Masif Saturdays!!!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->Posted 3 weeks ago<c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></strong></code></pre>

    </td></tr><tr><td rowspan="2"><code id="usage-summary-2:the-section-element"><a href="#the-section-element">section</a></code>
     </td><td>A generic section of a document or
  application. A section, in this context, is a thematic grouping of content, typically with a
  heading.
    </td></tr><tr><td><pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Biography<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The facts<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->1500+ shows, 14+ countries<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></strong>
<strong><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->2010/2011 figures per year<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->100+ shows, 8+ countries<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></strong></code></pre>

    </td></tr><tr><td rowspan="2"><code id="usage-summary-2:the-nav-element"><a href="#the-nav-element">nav</a></code>
     </td><td>A section of a page that links to other
  pages or to parts within the page: a section with navigation links.
    </td></tr><tr><td><pre class="example"><code class="html"><strong><c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/"</c-><c- p="">&gt;</c->Home<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/biog.html"</c-><c- p="">&gt;</c->Bio<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/discog.html"</c-><c- p="">&gt;</c->Discog<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c-></strong></code></pre>

    </td></tr><tr><td rowspan="2"><code id="usage-summary-2:the-aside-element"><a href="#the-aside-element">aside</a></code>
     </td><td>A section of a page that consists of
  content that is tangentially related to the content around the <code id="usage-summary-2:the-aside-element-2"><a href="#the-aside-element">aside</a></code> element, and
  which could be considered separate from that content. Such sections are often represented as
  sidebars in printed typography.
    </td></tr><tr><td><pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Music<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->As any burner can tell you, the event has a lot of trance.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c-></strong>You can buy the music we played at our <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"buy.html"</c-><c- p="">&gt;</c->playlist page<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<strong><c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This year we played a kind of trance that originated in Belgium, Germany, and the Netherlands in the mid-90s.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

    </td></tr><tr><td rowspan="2"><code id="usage-summary-2:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>–<code id="usage-summary-2:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>
     </td><td>A heading
    </td></tr><tr><td><pre class="example"><code class="html"><strong><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c-></strong>The Guide To Music On The Playa<strong><c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></strong>
<strong><c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c-></strong>The Main Stage<strong><c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If you want to play on a stage, you should bring one.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c-></strong>Amplified Music<strong><c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Amplifiers up to 300W or 90dB are welcome.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

    </td></tr><tr><td rowspan="2"><code id="usage-summary-2:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code>
     </td><td>A heading and related content. The
  element may be used to group an <code id="usage-summary-2:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>–<code id="usage-summary-2:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> element with one or more
  <code id="usage-summary-2:the-p-element"><a href="#the-p-element">p</a></code> elements containing content representing a subheading, alternative title, or
  tagline.
    </td></tr><tr><td><pre class="example"><code class="html"><strong><c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Burning Music<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The Guide To Music On The Playa<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Main Stage<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The Fiction Of A Music Festival<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If you want to play on a stage, you should bring one.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">hgroup</c-><c- p="">&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Loudness!<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Questions About Amplified Music<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;/</c-><c- f="">hgroup</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Amplifiers up to 300W or 90dB are welcome.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

    </td></tr><tr><td rowspan="2"><code id="usage-summary-2:the-header-element"><a href="#the-header-element">header</a></code>
     </td><td>A group of introductory or navigational
  aids.
    </td></tr><tr><td><pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Hard Trance is My Life<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->By DJ Steve Hill and Technikal<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The album with the amusing punctuation has red artwork.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

    </td></tr><tr><td rowspan="2"><code id="usage-summary-2:the-footer-element"><a href="#the-footer-element">footer</a></code>
     </td><td>A footer for its nearest ancestor
  <a href="#sectioning-content-2" id="usage-summary-2:sectioning-content-2">sectioning content</a> element, or for <a href="#the-body-element-2" id="usage-summary-2:the-body-element-2">the body element</a> if there is no such
  ancestor. A footer typically contains information about its section such as who wrote it, links
  to related documents, copyright data, and the like.
    </td></tr><tr><td><pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Hard Trance is My Life<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The album with the amusing punctuation has red artwork.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Artists: DJ Steve Hill and Technikal<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </td></tr></tbody></table>


  <h5 id="article-or-section"><span class="secno">4.3.12.1</span> Article or section?<a href="#article-or-section" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>A <code id="article-or-section:the-section-element"><a href="#the-section-element">section</a></code> forms part of something else. An <code id="article-or-section:the-article-element"><a href="#the-article-element">article</a></code> is its own thing.
  But how does one know which is which? Mostly the real answer is "it depends on author intent".</p>

  <p>For example, one could imagine a book with a "Granny Smith" chapter that just said "These
  juicy, green apples make a great filling for apple pies."; that would be a <code id="article-or-section:the-section-element-2"><a href="#the-section-element">section</a></code>
  because there'd be lots of other chapters on (maybe) other kinds of apples.</p>

  <p>On the other hand, one could imagine a tweet or reddit comment or tumblr post or newspaper
  classified ad that just said "Granny Smith. These juicy, green apples make a great filling for
  apple pies."; it would then be <code id="article-or-section:the-article-element-2"><a href="#the-article-element">article</a></code>s because that was the whole thing.</p>

  <p>A comment on an article is not part of the <code id="article-or-section:the-article-element-3"><a href="#the-article-element">article</a></code> on which it is commenting,
  therefore it is its own <code id="article-or-section:the-article-element-4"><a href="#the-article-element">article</a></code>.</p>



  <h3 id="grouping-content"><span class="secno">4.4</span> Grouping content<a href="#grouping-content" class="self-link"></a></h3>

  <h4 id="the-p-element"><span class="secno">4.4.1</span> The <dfn data-dfn-type="element"><code>p</code></dfn> element<a href="#the-p-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p" title="The <p> HTML element represents a paragraph. Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content, such as images or form fields.">Element/p</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLParagraphElement" title="The HTMLParagraphElement interface provides special properties (beyond those of the regular HTMLElement object interface it inherits) for manipulating <p> elements.">HTMLParagraphElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-p-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-p-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-p-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-p-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-p-element:flow-content-2-2">flow content</a> is expected.</dd><dd>As a child of an <code id="the-p-element:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-p-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-p-element:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-p-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-p-element:the-p-element"><a href="#the-p-element">p</a></code> element's <a href="#syntax-end-tag" id="the-p-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-p-element:the-p-element-2"><a href="#the-p-element">p</a></code> element is immediately followed by an <code id="the-p-element:the-address-element"><a href="#the-address-element">address</a></code>, <code id="the-p-element:the-article-element"><a href="#the-article-element">article</a></code>,
  <code id="the-p-element:the-aside-element"><a href="#the-aside-element">aside</a></code>, <code id="the-p-element:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code>, <code id="the-p-element:the-details-element"><a href="#the-details-element">details</a></code>, <code id="the-p-element:the-dialog-element"><a href="#the-dialog-element">dialog</a></code>,
  <code id="the-p-element:the-div-element"><a href="#the-div-element">div</a></code>, <code id="the-p-element:the-dl-element"><a href="#the-dl-element">dl</a></code>, <code id="the-p-element:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code>, <code id="the-p-element:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code>,
  <code id="the-p-element:the-figure-element"><a href="#the-figure-element">figure</a></code>, <code id="the-p-element:the-footer-element"><a href="#the-footer-element">footer</a></code>, <code id="the-p-element:the-form-element"><a href="#the-form-element">form</a></code>, <code id="the-p-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, <code id="the-p-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>,
  <code id="the-p-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, <code id="the-p-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>, <code id="the-p-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>, <code id="the-p-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>, <code id="the-p-element:the-header-element"><a href="#the-header-element">header</a></code>,
  <code id="the-p-element:the-hgroup-element-2"><a href="#the-hgroup-element">hgroup</a></code>, <code id="the-p-element:the-hr-element"><a href="#the-hr-element">hr</a></code>, <code id="the-p-element:the-main-element"><a href="#the-main-element">main</a></code>, <code id="the-p-element:the-menu-element"><a href="#the-menu-element">menu</a></code>, <code id="the-p-element:the-nav-element"><a href="#the-nav-element">nav</a></code>,
  <code id="the-p-element:the-ol-element"><a href="#the-ol-element">ol</a></code>, <code id="the-p-element:the-p-element-3"><a href="#the-p-element">p</a></code>, <code id="the-p-element:the-pre-element"><a href="#the-pre-element">pre</a></code>, <code id="the-p-element:the-search-element"><a href="#the-search-element">search</a></code>, <code id="the-p-element:the-section-element"><a href="#the-section-element">section</a></code>,
  <code id="the-p-element:the-table-element"><a href="#the-table-element">table</a></code>, or <code id="the-p-element:the-ul-element"><a href="#the-ul-element">ul</a></code> element, or if there is no more content in the parent
  element and the parent element is an <a href="#html-elements" id="the-p-element:html-elements">HTML element</a> that is not
  an <code id="the-p-element:the-a-element"><a href="#the-a-element">a</a></code>, <code id="the-p-element:the-audio-element"><a href="#the-audio-element">audio</a></code>, <code id="the-p-element:the-del-element"><a href="#the-del-element">del</a></code>, <code id="the-p-element:the-ins-element"><a href="#the-ins-element">ins</a></code>, <code id="the-p-element:the-map-element"><a href="#the-map-element">map</a></code>,
  <code id="the-p-element:the-noscript-element"><a href="#the-noscript-element">noscript</a></code>, or <code id="the-p-element:the-video-element"><a href="#the-video-element">video</a></code> element, or an <a href="#autonomous-custom-element" id="the-p-element:autonomous-custom-element">autonomous custom
  element</a>.</dd><dt><a href="#concept-element-attributes" id="the-p-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-p-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-p-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-p">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-p">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-p-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlparagraphelement" data-dfn-type="interface"><c- g="">HTMLParagraphElement</c-></dfn> : <a href="#htmlelement" id="the-p-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-p-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLParagraphElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-p-element:the-p-element-4"><a href="#the-p-element">p</a></code> element <a href="#represents" id="the-p-element:represents">represents</a> a <a href="#paragraph" id="the-p-element:paragraph">paragraph</a>.</p>

  <p class="note">While paragraphs are usually represented in visual media by blocks of text that
  are physically separated from adjacent blocks through blank lines, a style sheet or user agent
  would be equally justified in presenting paragraph breaks in a different manner, for instance
  using inline pilcrows (¶).</p>

  <div class="example">
   <p>The following examples are conforming HTML fragments:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The little kitten gently seated herself on a piece of
carpet. Later in her life, this would be referred to as the time the
cat sat on the mat.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Personal information<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"n"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"anon"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"checkbox"</c-><c- p="">&gt;</c-> Hide from other users<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Address: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></code></pre>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->There was once an example from Femley,<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
Whose markup was of dubious quality.<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
The validator complained,<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
So the author was pained,<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
To move the error from the markup to the rhyming.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>The <code id="the-p-element:the-p-element-5"><a href="#the-p-element">p</a></code> element should not be used when a more specific element is more
  appropriate.</p>

  <div class="example">

   <p>The following example is technically correct:</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- c="">&lt;!-- ... --&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Last modified: 2001-04-23<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Author: fred@example.com<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>However, it would be better marked-up as:</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- c="">&lt;!-- ... --&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->Last modified: 2001-04-23<c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">address</c-><c- p="">&gt;</c->Author: fred@example.com<c- p="">&lt;/</c-><c- f="">address</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>Or:</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- c="">&lt;!-- ... --&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Last modified: 2001-04-23<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">address</c-><c- p="">&gt;</c->Author: fred@example.com<c- p="">&lt;/</c-><c- f="">address</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="note">

   <p>List elements (in particular, <code id="the-p-element:the-ol-element-2"><a href="#the-ol-element">ol</a></code> and <code id="the-p-element:the-ul-element-2"><a href="#the-ul-element">ul</a></code> elements) cannot be children
   of <code id="the-p-element:the-p-element-6"><a href="#the-p-element">p</a></code> elements. When a sentence contains a bulleted list, therefore, one might wonder
   how it should be marked up.</p>

   <div class="example">
    <p>For instance, this fantastic sentence has bullets relating to</p>
    <ul><li>wizards,
     </li><li>faster-than-light travel, and
     </li><li>telepathy,
    </li></ul>
    <p>and is further discussed below.</p>
   </div>

   <p>The solution is to realize that a <i id="the-p-element:paragraph-2"><a href="#paragraph">paragraph</a></i>, in HTML terms, is not a
   logical concept, but a structural one. In the fantastic example above, there are actually
   <em>five</em> <a href="#paragraph" id="the-p-element:paragraph-3">paragraphs</a> as defined by this specification: one
   before the list, one for each bullet, and one after the list.</p>

   <div class="example">

    <p>The markup for the above example could therefore be:</p>

    <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->For instance, this fantastic sentence has bullets relating to<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->wizards,
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->faster-than-light travel, and
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->telepathy,
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->and is further discussed below.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   </div>

   <p>Authors wishing to conveniently style such "logical" paragraphs consisting of multiple
   "structural" paragraphs can use the <code id="the-p-element:the-div-element-2"><a href="#the-div-element">div</a></code> element instead of the <code id="the-p-element:the-p-element-7"><a href="#the-p-element">p</a></code>
   element.</p>

   <div class="example">

    <p>Thus for instance the above example could become the following:</p>

    <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-><c- p="">&gt;</c->For instance, this fantastic sentence has bullets relating to
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->wizards,
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->faster-than-light travel, and
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->telepathy,
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
and is further discussed below.<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

    <p>This example still has five structural paragraphs, but now the author can style just the
    <code id="the-p-element:the-div-element-3"><a href="#the-div-element">div</a></code> instead of having to consider each part of the example separately.</p>

   </div>

  </div>



  <h4 id="the-hr-element"><span class="secno">4.4.2</span> The <dfn data-dfn-type="element"><code>hr</code></dfn> element<a href="#the-hr-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr" title="The <hr> HTML element represents a thematic break between paragraph-level elements: for example, a change of scene in a story, or a shift of topic within a section.">Element/hr</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLHRElement" title="The HTMLHRElement interface provides special properties (beyond those of the HTMLElement interface it also has available to it by inheritance) for manipulating <hr> elements.">HTMLHRElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-hr-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-hr-element:flow-content-2">Flow content</a>.</dd><dd><a href="#select-element-inner-content-elements-2" id="the-hr-element:select-element-inner-content-elements-2"><code>select</code> element inner content elements</a>.</dd><dt><a href="#concept-element-contexts" id="the-hr-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-hr-element:flow-content-2-2">flow content</a> is expected.</dd><dd>As a child of a <code id="the-hr-element:the-select-element"><a href="#the-select-element">select</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-hr-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-hr-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-hr-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-hr-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-hr-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-hr-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-hr-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-hr">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-hr">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-hr-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlhrelement" data-dfn-type="interface"><c- g="">HTMLHRElement</c-></dfn> : <a href="#htmlelement" id="the-hr-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-hr-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLHRElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-hr-element:the-hr-element"><a href="#the-hr-element">hr</a></code> element <a href="#represents" id="the-hr-element:represents">represents</a> a <a href="#paragraph" id="the-hr-element:paragraph">paragraph</a>-level thematic
  break, e.g., a scene change in a story, or a transition to another topic within a section of a
  reference book; alternatively, it represents a separator between a set of options of a
  <code id="the-hr-element:the-select-element-2"><a href="#the-select-element">select</a></code> element.</p>

  <div class="example">

   <p>The following fictional extract from a project manual shows two sections that use the
   <code id="the-hr-element:the-hr-element-2"><a href="#the-hr-element">hr</a></code> element to separate topics within the section.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Communication<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->There are various methods of communication. This section
 covers a few of the important ones used by the project.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">hr</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Communication stones seem to come in pairs and have mysterious
 properties:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->They can transfer thoughts in two directions once activated
  if used alone.<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->If used with another device, they can transfer one's
  consciousness to another body.<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->If both stones are used with another device, the
  consciousnesses switch bodies.<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">hr</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Radios use the electromagnetic spectrum in the meter range and
 longer.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">hr</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Signal flares use the electromagnetic spectrum in the
 nanometer range.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Food<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->All food at the project is rationed:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Potatoes<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->Two per day<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Soup<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->One bowl per day<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">hr</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Cooking is done by the chefs on a set rotation.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>There is no need for an <code id="the-hr-element:the-hr-element-3"><a href="#the-hr-element">hr</a></code> element between the sections themselves, since the
   <code id="the-hr-element:the-section-element"><a href="#the-section-element">section</a></code> elements and the <code id="the-hr-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code> elements imply thematic changes
   themselves.</p>

  </div>

  <div class="example">

   <p>The following extract from <cite>Pandora's Star</cite> by Peter F. Hamilton shows two
   paragraphs that precede a scene change and the paragraph that follows it. The scene change,
   represented in the printed book by a gap containing a solitary centered star between the second
   and third paragraphs, is here represented using the <code id="the-hr-element:the-hr-element-4"><a href="#the-hr-element">hr</a></code> element.</p>

   

   <pre lang="en-GB"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Dudley was ninety-two, in his second life, and fast approaching
time for another rejuvenation. Despite his body having the physical
age of a standard fifty-year-old, the prospect of a long degrading
campaign within academia was one he regarded with dread. For a
supposedly advanced civilization, the Intersolar Commonwealth could be
appallingly backward at times, not to mention cruel.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->Maybe it won't be that bad<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c->, he told himself. The lie was
comforting enough to get him through the rest of the night's
shift.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">hr</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The Carlton AllLander drove Dudley home just after dawn. Like the
astronomer, the vehicle was old and worn, but perfectly capable of
doing its job. It had a cheap diesel engine, common enough on a
semi-frontier world like Gralmond, although its drive array was a
thoroughly modern photoneural processor. With its high suspension and
deep-tread tyres it could plough along the dirt track to the
observatory in all weather and seasons, including the metre-deep snow
of Gralmond's winters.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p class="note">The <code id="the-hr-element:the-hr-element-5"><a href="#the-hr-element">hr</a></code> element does not affect the document's
  <a href="#outline" id="the-hr-element:outline">outline</a>.</p>

  <h4 id="the-pre-element"><span class="secno">4.4.3</span> The <dfn data-dfn-type="element"><code>pre</code></dfn> element<a href="#the-pre-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre" title="The <pre> HTML element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered using a non-proportional, or monospaced, font. Whitespace inside this element is displayed as written.">Element/pre</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLPreElement" title="The HTMLPreElement interface exposes specific properties and methods (beyond those of the HTMLElement interface it also has available to it by inheritance) for manipulating a block of preformatted text (<pre>).">HTMLPreElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-pre-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-pre-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-pre-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-pre-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-pre-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-pre-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-pre-element:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-pre-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-pre-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-pre-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-pre-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-pre">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-pre">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-pre-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlpreelement" data-dfn-type="interface"><c- g="">HTMLPreElement</c-></dfn> : <a href="#htmlelement" id="the-pre-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-pre-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLPreElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-pre-element:the-pre-element"><a href="#the-pre-element">pre</a></code> element <a href="#represents" id="the-pre-element:represents">represents</a> a block of preformatted text, in which
  structure is represented by typographic conventions rather than by elements.</p>

  <p class="note">In <a href="#syntax" id="the-pre-element:syntax">the HTML syntax</a>, a leading newline character immediately following
  the <code id="the-pre-element:the-pre-element-2"><a href="#the-pre-element">pre</a></code> element start tag is stripped.</p>

  <p>Some examples of cases where the <code id="the-pre-element:the-pre-element-3"><a href="#the-pre-element">pre</a></code> element could be used:</p>

  <ul><li>Including an email, with paragraphs indicated by blank lines, lists indicated by lines
   prefixed with a bullet, and so on.</li><li>Including fragments of computer code, with structure indicated according to the conventions
   of that language.</li><li>Displaying ASCII art.</li></ul>

  <p class="note">Authors are encouraged to consider how preformatted text will be experienced when
  the formatting is lost, as will be the case for users of speech synthesizers, braille displays,
  and the like. For cases like ASCII art, it is likely that an alternative presentation, such as a
  textual description, would be more universally accessible to the readers of the document.</p>

  <p>To represent a block of computer code, the <code id="the-pre-element:the-pre-element-4"><a href="#the-pre-element">pre</a></code> element can be used with a
  <code id="the-pre-element:the-code-element"><a href="#the-code-element">code</a></code> element; to represent a block of computer output the <code id="the-pre-element:the-pre-element-5"><a href="#the-pre-element">pre</a></code> element
  can be used with a <code id="the-pre-element:the-samp-element"><a href="#the-samp-element">samp</a></code> element. Similarly, the <code id="the-pre-element:the-kbd-element"><a href="#the-kbd-element">kbd</a></code> element can be used
  within a <code id="the-pre-element:the-pre-element-6"><a href="#the-pre-element">pre</a></code> element to indicate text that the user is to enter.</p>

  

  <p class="note">This element <a href="#bidireq">has rendering requirements involving the
  bidirectional algorithm</a>.</p>
  

  <div class="example">

   <p>In the following snippet, a sample of computer code is presented.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This is the <c- p="">&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->Panel<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c-> constructor:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->function Panel(element, canClose, closeHandler) {
  this.element = element;
  this.canClose = canClose;
  this.closeHandler = function () { if (closeHandler) closeHandler() };
}<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following snippet, <code id="the-pre-element:the-samp-element-2"><a href="#the-samp-element">samp</a></code> and <code id="the-pre-element:the-kbd-element-2"><a href="#the-kbd-element">kbd</a></code> elements are mixed in the
   contents of a <code id="the-pre-element:the-pre-element-7"><a href="#the-pre-element">pre</a></code> element to show a session of Zork I.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;&lt;</c-><c- f="">samp</c-><c- p="">&gt;</c->You are in an open field west of a big white house with a boarded
front door.
There is a small mailbox here.

&gt;<c- p="">&lt;/</c-><c- f="">samp</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">kbd</c-><c- p="">&gt;</c->open mailbox<c- p="">&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">samp</c-><c- p="">&gt;</c->Opening the mailbox reveals:
A leaflet.

&gt;<c- p="">&lt;/</c-><c- f="">samp</c-><c- p="">&gt;&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The following shows a contemporary poem that uses the <code id="the-pre-element:the-pre-element-8"><a href="#the-pre-element">pre</a></code> element to preserve its
   unusual formatting, which forms an intrinsic part of the poem itself.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;</c->                maxling

it is with a          heart
               heavy

that i admit loss of a feline
        so           loved

a friend lost to the
        unknown
                                (night)

~cdr 11dec07<c- p="">&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-blockquote-element"><span class="secno">4.4.4</span> The <dfn data-dfn-type="element"><code>blockquote</code></dfn> element<a href="#the-blockquote-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote" title="The <blockquote> HTML element indicates that the enclosed text is an extended quotation. Usually, this is rendered visually by indentation (see Notes for how to change it). A URL for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the <cite> element.">Element/blockquote</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLQuoteElement" title="The HTMLQuoteElement interface provides special properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating quoting elements, like <blockquote> and <q>, but not the <cite> element.">HTMLQuoteElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-blockquote-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-blockquote-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-blockquote-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-blockquote-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-blockquote-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-blockquote-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-blockquote-element:flow-content-2-3">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-blockquote-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-blockquote-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-blockquote-element:global-attributes">Global attributes</a></dd><dd><code id="the-blockquote-element:attr-blockquote-cite"><a href="#attr-blockquote-cite">cite</a></code> —  Link to the source of the quotation or more information about the edit
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-blockquote-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-blockquote">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-blockquote">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-blockquote-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlquoteelement" data-dfn-type="interface"><c- g="">HTMLQuoteElement</c-></dfn> : <a href="#htmlelement" id="the-blockquote-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-blockquote-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-blockquote-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-blockquote-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLQuoteElement" id="dom-quote-cite" data-dfn-type="attribute"><c- g="">cite</c-></dfn>;
};</code></pre>
    <p class="note">The <code id="the-blockquote-element:htmlquoteelement"><a href="#htmlquoteelement">HTMLQuoteElement</a></code> interface is also used by the <code id="the-blockquote-element:the-q-element"><a href="#the-q-element">q</a></code>
    element.</p>
   </dd></dl>

  <p>The <code id="the-blockquote-element:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code> element <a href="#represents" id="the-blockquote-element:represents">represents</a> a section that is quoted from
  another source.</p>

  <p>Content inside a <code id="the-blockquote-element:the-blockquote-element-2"><a href="#the-blockquote-element">blockquote</a></code> must be quoted from another source, whose address, if
  it has one, may be cited in the <dfn data-dfn-for="blockquote" id="attr-blockquote-cite" data-dfn-type="element-attr"><code>cite</code></dfn> attribute.</p>

  <p>If the <code id="the-blockquote-element:attr-blockquote-cite-2"><a href="#attr-blockquote-cite">cite</a></code> attribute is present, it must be a
  <a href="#valid-url-potentially-surrounded-by-spaces" id="the-blockquote-element:valid-url-potentially-surrounded-by-spaces">valid URL potentially surrounded by spaces</a>. To obtain the
  corresponding citation link, the value of the attribute must be <a href="#encoding-parsing-a-url" id="the-blockquote-element:encoding-parsing-a-url">parsed</a> relative to the element's <a id="the-blockquote-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>. User agents may
  allow users to follow such citation links, but they are primarily intended for private use (e.g.,
  by server-side scripts collecting statistics about a site's use of quotations), not for
  readers.</p>

  <p>The content of a <code id="the-blockquote-element:the-blockquote-element-3"><a href="#the-blockquote-element">blockquote</a></code> may be abbreviated or may have context added in the
  conventional manner for the text's language.</p>

  <div class="example">

   <p>For example, in English this is traditionally done using square brackets. Consider a page with
   the sentence "Jane ate the cracker. She then said she liked apples and fish."; it could be quoted
   as follows:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->[Jane] then said she liked [...] fish.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Attribution for the quotation, if any, must be placed outside the <code id="the-blockquote-element:the-blockquote-element-4"><a href="#the-blockquote-element">blockquote</a></code>
  element.</p> 

  <div class="example">

   <p>For example, here the attribution is given in a paragraph after the quote:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I contend that we are both atheists. I just believe in one fewer
 god than you do. When you understand why you dismiss all the other
 possible gods, you will understand why I dismiss yours.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->— Stephen Roberts<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>The other examples below show other ways of showing attribution.</p>

  </div>

  <div class="example">

   <p>Here a <code id="the-blockquote-element:the-blockquote-element-5"><a href="#the-blockquote-element">blockquote</a></code> element is used in conjunction with a <code id="the-blockquote-element:the-figure-element"><a href="#the-figure-element">figure</a></code>
   element and its <code id="the-blockquote-element:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code> to clearly relate a quote to its attribution (which is
   not part of the quote and therefore doesn't belong inside the <code id="the-blockquote-element:the-blockquote-element-6"><a href="#the-blockquote-element">blockquote</a></code>
   itself):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The truth may be puzzling. It may take some work to grapple with.
  It may be counterintuitive. It may contradict deeply held
  prejudices. It may not be consonant with what we desperately want to
  be true. But our preferences do not determine what's true. We have a
  method, and that method helps us to reach not absolute truth, only
  asymptotic approaches to the truth — never there, just closer
  and closer, always finding vast new oceans of undiscovered
  possibilities. Cleverly designed experiments are the key.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Carl Sagan, in "<c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Wonder and Skepticism<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->", from
 the <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Skeptical Inquirer<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-> Volume 19, Issue 1 (January-February
 1995)<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>This next example shows the use of <code id="the-blockquote-element:the-cite-element"><a href="#the-cite-element">cite</a></code> alongside <code id="the-blockquote-element:the-blockquote-element-7"><a href="#the-blockquote-element">blockquote</a></code>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->His next piece was the aptly named <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Sonnet 130<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">blockquote</c-> <c- e="">cite</c-><c- o="">=</c-><c- s="">"https://quotes.example.org/s/sonnet130.html"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My mistress' eyes are nothing like the sun,<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
  Coral is far more red, than her lips red,<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
  ...</code></pre>

  </div>

  <div class="example">

   <p>This example shows how a forum post could use <code id="the-blockquote-element:the-blockquote-element-8"><a href="#the-blockquote-element">blockquote</a></code> to show what post a user
   is replying to. The <code id="the-blockquote-element:the-article-element"><a href="#the-article-element">article</a></code> element is used for each post, to mark up the
   threading.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://bacon.example.com/?blog=109431"</c-><c- p="">&gt;</c->Bacon on a crowbar<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->t3yw<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> 12 points 1 hour ago<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I bet a narwhal would love that.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?pid=29578"</c-><c- p="">&gt;</c->permalink<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->greg<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> 8 points 1 hour ago<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I bet a narwhal would love that.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Dude narwhals don't eat bacon.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?pid=29579"</c-><c- p="">&gt;</c->permalink<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->t3yw<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> 15 points 1 hour ago<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I bet a narwhal would love that.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Dude narwhals don't eat bacon.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Next thing you'll be saying they don't get capes and wizard
    hats either!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?pid=29580"</c-><c- p="">&gt;</c->permalink<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->boing<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> -5 points 1 hour ago<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->narwhals are worse than ceiling cat<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?pid=29581"</c-><c- p="">&gt;</c->permalink<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
     <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->fred<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> 1 points 23 minutes ago<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I bet a narwhal would love that.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I bet they'd love to peel a banana too.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?pid=29582"</c-><c- p="">&gt;</c->permalink<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>This example shows the use of a <code id="the-blockquote-element:the-blockquote-element-9"><a href="#the-blockquote-element">blockquote</a></code> for short snippets, demonstrating that
   one does not have to use <code id="the-blockquote-element:the-p-element"><a href="#the-p-element">p</a></code> elements inside <code id="the-blockquote-element:the-blockquote-element-10"><a href="#the-blockquote-element">blockquote</a></code> elements:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->He began his list of "lessons" with the following:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;</c->One should never assume that his side of
the issue will be recognized, let alone that it will
be conceded to have merits.<c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->He continued with a number of similar points, ending with:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;</c->Finally, one should be prepared for the threat
of breakdown in negotiations at any given moment and not
be cowed by the possibility.<c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->We shall now discuss these points...</code></pre>

  </div>

  <p class="note"><a href="#conversations">Examples of how to represent a conversation</a> are shown
  in a later section; it is not appropriate to use the <code id="the-blockquote-element:the-cite-element-2"><a href="#the-cite-element">cite</a></code> and <code id="the-blockquote-element:the-blockquote-element-11"><a href="#the-blockquote-element">blockquote</a></code>
  elements for this purpose.</p>



  <h4 id="the-ol-element"><span class="secno">4.4.5</span> The <dfn data-dfn-type="element"><code>ol</code></dfn> element<a href="#the-ol-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol" title="The <ol> HTML element represents an ordered list of items — typically rendered as a numbered list.">Element/ol</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLOListElement" title="The HTMLOListElement interface provides special properties (beyond those defined on the regular HTMLElement interface it also has available to it by inheritance) for manipulating ordered list elements.">HTMLOListElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-ol-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-ol-element:flow-content-2">Flow content</a>.</dd><dd>If the element's children include at least one <code id="the-ol-element:the-li-element"><a href="#the-li-element">li</a></code> element: <a href="#palpable-content-2" id="the-ol-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-ol-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-ol-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-ol-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or more <code id="the-ol-element:the-li-element-2"><a href="#the-li-element">li</a></code> and <a href="#script-supporting-elements-2" id="the-ol-element:script-supporting-elements-2">script-supporting</a> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-ol-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-ol-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-ol-element:global-attributes">Global attributes</a></dd><dd><code id="the-ol-element:attr-ol-reversed"><a href="#attr-ol-reversed">reversed</a></code> —  Number the list backwards
     </dd><dd><code id="the-ol-element:attr-ol-start"><a href="#attr-ol-start">start</a></code> —  <a href="#concept-ol-start" id="the-ol-element:concept-ol-start">Starting value</a> of the list
     </dd><dd><code id="the-ol-element:attr-ol-type"><a href="#attr-ol-type">type</a></code> —  Kind of list marker
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-ol-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-ol">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-ol">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-ol-element:concept-element-dom">DOM interface</a>:</dt><dd>
<pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlolistelement" data-dfn-type="interface"><c- g="">HTMLOListElement</c-></dfn> : <a href="#htmlelement" id="the-ol-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-ol-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-ol-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-ol-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLOListElement" id="dom-ol-reversed" data-dfn-type="attribute"><c- g="">reversed</c-></dfn>;
  [<a href="#cereactions" id="the-ol-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-ol-element:xattr-reflect-2"><c- g="">Reflect</c-></a>, <a href="#xattr-reflectdefault" id="the-ol-element:xattr-reflectdefault">ReflectDefault=1</a>] <c- b="">attribute</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLOListElement" id="dom-ol-start" data-dfn-type="attribute"><c- g="">start</c-></dfn>;
  [<a href="#cereactions" id="the-ol-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-ol-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLOListElement" id="dom-ol-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;

  // <a href="#HTMLOListElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-ol-element:the-ol-element"><a href="#the-ol-element">ol</a></code> element <a href="#represents" id="the-ol-element:represents">represents</a> a list of items, where the items have been
  intentionally ordered, such that changing the order would change the meaning of the document.</p>

  <p>The items of the list are the <code id="the-ol-element:the-li-element-3"><a href="#the-li-element">li</a></code> element child nodes of the <code id="the-ol-element:the-ol-element-2"><a href="#the-ol-element">ol</a></code>
  element, in <a id="the-ol-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol#attr-reversed" title="The <ol> HTML element represents an ordered list of items — typically rendered as a numbered list.">Element/ol#attr-reversed</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>18+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>18+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>≤79+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="ol" id="attr-ol-reversed" data-dfn-type="element-attr"><code>reversed</code></dfn> attribute
  is a <a href="#boolean-attribute" id="the-ol-element:boolean-attribute">boolean attribute</a>. If present, it indicates that the list is a descending list
  (..., 3, 2, 1). If the attribute is omitted, the list is an ascending list (1, 2, 3, ...).</p>

  <p>The <dfn data-dfn-for="ol" id="attr-ol-start" data-dfn-type="element-attr"><code>start</code></dfn> attribute, if
  present, must be a <a href="#valid-integer" id="the-ol-element:valid-integer">valid integer</a>. It is used to determine the <a href="#concept-ol-start" id="the-ol-element:concept-ol-start-2">starting value</a> of the list.</p>

  

  

  <div data-algorithm="">
  <p>An <code id="the-ol-element:the-ol-element-3"><a href="#the-ol-element">ol</a></code> element has a <dfn id="concept-ol-start">starting value</dfn>, which is
  an integer determined as follows:</p>

  <ol><li>
    <p>If the <code id="the-ol-element:the-ol-element-4"><a href="#the-ol-element">ol</a></code> element has a <code id="the-ol-element:attr-ol-start-2"><a href="#attr-ol-start">start</a></code> attribute,
    then:</p>

    <ol><li><p>Let <var>parsed</var> be the result of <a href="#rules-for-parsing-integers" id="the-ol-element:rules-for-parsing-integers">parsing
     the value of the attribute as an integer</a>.</p></li><li><p>If <var>parsed</var> is not an error, then return <var>parsed</var>.</p></li></ol>
   </li><li><p>If the <code id="the-ol-element:the-ol-element-5"><a href="#the-ol-element">ol</a></code> element has a <code id="the-ol-element:attr-ol-reversed-2"><a href="#attr-ol-reversed">reversed</a></code>
   attribute, then return the number of <a href="#list-owner" id="the-ol-element:list-owner">owned <code>li</code>
   elements</a>.</p></li><li><p>Return 1.</p></li></ol>
  </div>

  

  <p>The <dfn data-dfn-for="ol" id="attr-ol-type" data-dfn-type="element-attr"><code>type</code></dfn> attribute can be
  used to specify the kind of marker to use in the list, in the cases where that matters (e.g.
  because items are to be <a href="#referenced" id="the-ol-element:referenced">referenced</a> by their number/letter). The attribute, if
  specified, must have a value that is <a id="the-ol-element:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> one of the characters given in the
  first cell of one of the rows of the following table. The <code id="the-ol-element:attr-ol-type-2"><a href="#attr-ol-type">type</a></code> attribute represents the state given in the cell in the second
  column of the row whose first cell matches the attribute's value; if none of the cells match, or
  if the attribute is omitted, then the attribute represents the <a href="#attr-ol-type-state-decimal" id="the-ol-element:attr-ol-type-state-decimal">decimal</a> state.</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Description
     </th><th colspan="8">Examples for values 1-3 and 3999-4001
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="ol/type" id="attr-ol-type-keyword-decimal" data-dfn-type="attr-value"><code>1</code></dfn>
     (U+0031)
     </td><td><dfn id="attr-ol-type-state-decimal">decimal</dfn>
     </td><td>Decimal numbers
     </td><td class="eg"><samp>1.</samp> </td><td class="eg"><samp>2.</samp> </td><td class="eg"><samp>3.</samp> </td><td class="eg">... </td><td class="eg"><samp>3999.</samp> </td><td class="eg"><samp>4000.</samp> </td><td class="eg"><samp>4001.</samp> </td><td class="eg">...
    </td></tr><tr><td><dfn data-dfn-for="ol/type" id="attr-ol-type-keyword-lower-alpha" data-dfn-type="attr-value"><code>a</code></dfn> (U+0061)
     </td><td><dfn id="attr-ol-type-state-lower-alpha">lower-alpha</dfn>
     </td><td>Lowercase latin alphabet
     </td><td class="eg"><samp>a.</samp> </td><td class="eg"><samp>b.</samp> </td><td class="eg"><samp>c.</samp> </td><td class="eg">... </td><td class="eg"><samp>ewu.</samp> </td><td class="eg"><samp>ewv.</samp> </td><td class="eg"><samp>eww.</samp> </td><td class="eg">...
    </td></tr><tr><td><dfn data-dfn-for="ol/type" id="attr-ol-type-keyword-upper-alpha" data-dfn-type="attr-value"><code>A</code></dfn> (U+0041)
     </td><td><dfn id="attr-ol-type-state-upper-alpha">upper-alpha</dfn>
     </td><td>Uppercase latin alphabet
     </td><td class="eg"><samp>A.</samp> </td><td class="eg"><samp>B.</samp> </td><td class="eg"><samp>C.</samp> </td><td class="eg">... </td><td class="eg"><samp>EWU.</samp> </td><td class="eg"><samp>EWV.</samp> </td><td class="eg"><samp>EWW.</samp> </td><td class="eg">...
    </td></tr><tr><td><dfn data-dfn-for="ol/type" id="attr-ol-type-keyword-lower-roman" data-dfn-type="attr-value"><code>i</code></dfn> (U+0069)

     </td><td><dfn id="attr-ol-type-state-lower-roman">lower-roman</dfn>
     </td><td>Lowercase roman numerals
     </td><td class="eg"><samp>i.</samp> </td><td class="eg"><samp>ii.</samp> </td><td class="eg"><samp>iii.</samp> </td><td class="eg">... </td><td class="eg"><samp>mmmcmxcix.</samp> </td><td class="eg"><samp>i̅v̅.</samp> </td><td class="eg"><samp>i̅v̅i.</samp> </td><td class="eg">...
    </td></tr><tr><td><dfn data-dfn-for="ol/type" id="attr-ol-type-keyword-upper-roman" data-dfn-type="attr-value"><code>I</code></dfn> (U+0049)
     </td><td><dfn id="attr-ol-type-state-upper-roman">upper-roman</dfn>
     </td><td>Uppercase roman numerals
     </td><td class="eg"><samp>I.</samp> </td><td class="eg"><samp>II.</samp> </td><td class="eg"><samp>III.</samp> </td><td class="eg">... </td><td class="eg"><samp>MMMCMXCIX.</samp> </td><td class="eg"><samp>I̅V̅.</samp> </td><td class="eg"><samp>I̅V̅I.</samp> </td><td class="eg">...
  </td></tr></tbody></table>

  

  <p>User agents should render the items of the list in a manner consistent with the state of the
  <code id="the-ol-element:attr-ol-type-3"><a href="#attr-ol-type">type</a></code> attribute of the <code id="the-ol-element:the-ol-element-6"><a href="#the-ol-element">ol</a></code> element. Numbers less than
  or equal to zero should always use the decimal system regardless of the <code id="the-ol-element:attr-ol-type-4"><a href="#attr-ol-type">type</a></code> attribute.</p>

  <p class="note">For CSS user agents, a mapping for this attribute to the
  <a id="the-ol-element:'list-style-type'" href="https://drafts.csswg.org/css-lists/#propdef-list-style-type" data-x-internal="'list-style-type'">'list-style-type'</a> CSS property is given <a href="#decohints">in the Rendering
  section</a> (the mapping is straightforward: the states above have the same names as their
  corresponding CSS values).</p>

  

  <p class="note">It is possible to redefine the default CSS list styles used to implement this
  attribute in CSS user agents; doing so will affect how list items are rendered.</p>

  

  

  <p class="note">Due to <a href="#xattr-reflectdefault" id="the-ol-element:xattr-reflectdefault-2">[ReflectDefault]</a> the <code id="the-ol-element:dom-ol-start"><a href="#dom-ol-start">start</a></code> IDL attribute does not necessarily match the list's <a href="#concept-ol-start" id="the-ol-element:concept-ol-start-3">starting value</a>, in cases where the <code id="the-ol-element:attr-ol-start-3"><a href="#attr-ol-start">start</a></code> content attribute is omitted and the <code id="the-ol-element:attr-ol-reversed-3"><a href="#attr-ol-reversed">reversed</a></code> content attribute is specified.</p>

  

  <div class="example">

   <p>The following markup shows a list where the order matters, and where the <code id="the-ol-element:the-ol-element-7"><a href="#the-ol-element">ol</a></code>
   element is therefore appropriate. Compare this list to the equivalent list in the <code id="the-ol-element:the-ul-element"><a href="#the-ul-element">ul</a></code>
   section to see an example of the same items using the <code id="the-ol-element:the-ul-element-2"><a href="#the-ul-element">ul</a></code> element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I have lived in the following countries (given in the order of when
I first lived there):<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ol</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Switzerland
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->United Kingdom
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->United States
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Norway
<c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c-></code></pre>

   <p>Note how changing the order of the list changes the meaning of the document. In the following
   example, changing the relative order of the first two items has changed the birthplace of the
   author:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I have lived in the following countries (given in the order of when
I first lived there):<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ol</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->United Kingdom
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Switzerland
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->United States
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Norway
<c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-ul-element"><span class="secno">4.4.6</span> The <dfn data-dfn-type="element"><code>ul</code></dfn> element<a href="#the-ul-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul" title="The <ul> HTML element represents an unordered list of items, typically rendered as a bulleted list.">Element/ul</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLUListElement" title="The HTMLUListElement interface provides special properties (beyond those defined on the regular HTMLElement interface it also has available to it by inheritance) for manipulating unordered list (<ul>) elements.">HTMLUListElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-ul-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-ul-element:flow-content-2">Flow content</a>.</dd><dd>If the element's children include at least one <code id="the-ul-element:the-li-element"><a href="#the-li-element">li</a></code> element: <a href="#palpable-content-2" id="the-ul-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-ul-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-ul-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-ul-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or more <code id="the-ul-element:the-li-element-2"><a href="#the-li-element">li</a></code> and <a href="#script-supporting-elements-2" id="the-ul-element:script-supporting-elements-2">script-supporting</a> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-ul-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-ul-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-ul-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-ul-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-ul">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-ul">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-ul-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlulistelement" data-dfn-type="interface"><c- g="">HTMLUListElement</c-></dfn> : <a href="#htmlelement" id="the-ul-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-ul-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLUListElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-ul-element:the-ul-element"><a href="#the-ul-element">ul</a></code> element <a href="#represents" id="the-ul-element:represents">represents</a> a list of items, where the order of the
  items is not important — that is, where changing the order would not materially change the
  meaning of the document.</p>

  <p>The items of the list are the <code id="the-ul-element:the-li-element-3"><a href="#the-li-element">li</a></code> element child nodes of the <code id="the-ul-element:the-ul-element-2"><a href="#the-ul-element">ul</a></code>
  element.</p>

  <div class="example">

   <p>The following markup shows a list where the order does not matter, and where the
   <code id="the-ul-element:the-ul-element-3"><a href="#the-ul-element">ul</a></code> element is therefore appropriate. Compare this list to the equivalent list in the
   <code id="the-ul-element:the-ol-element"><a href="#the-ol-element">ol</a></code> section to see an example of the same items using the <code id="the-ul-element:the-ol-element-2"><a href="#the-ol-element">ol</a></code>
   element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I have lived in the following countries:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Norway
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Switzerland
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->United Kingdom
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->United States
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

   <p>Note that changing the order of the list does not change the meaning of the document. The
   items in the snippet above are given in alphabetical order, but in the snippet below they are
   given in order of the size of their current account balance in 2007, without changing the meaning
   of the document whatsoever:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I have lived in the following countries:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Switzerland
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Norway
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->United Kingdom
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->United States
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-menu-element"><span class="secno">4.4.7</span> The <dfn id="menus" data-dfn-type="element"><code>menu</code></dfn> element<a href="#the-menu-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/menu" title="The <menu> HTML element is described in the HTML specification as a semantic alternative to <ul>, but treated by browsers (and exposed through the accessibility tree) as no different than <ul>. It represents an unordered list of items (which are represented by <li> elements).">Element/menu</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuElement" title="The HTMLMenuElement interface provides special properties (beyond those defined on the regular HTMLElement interface it also has available to it by inheritance) for manipulating <menu> elements.">HTMLMenuElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-menu-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-menu-element:flow-content-2">Flow content</a>.</dd><dd>If the element's children include at least one <code id="the-menu-element:the-li-element"><a href="#the-li-element">li</a></code> element: <a href="#palpable-content-2" id="the-menu-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-menu-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-menu-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-menu-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or more <code id="the-menu-element:the-li-element-2"><a href="#the-li-element">li</a></code> and <a href="#script-supporting-elements-2" id="the-menu-element:script-supporting-elements-2">script-supporting</a> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-menu-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-menu-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-menu-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-menu-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-menu">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-menu">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-menu-element:concept-element-dom">DOM interface</a>:</dt><dd>
<pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlmenuelement" data-dfn-type="interface"><c- g="">HTMLMenuElement</c-></dfn> : <a href="#htmlelement" id="the-menu-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-menu-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLMenuElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-menu-element:the-menu-element"><a href="#the-menu-element">menu</a></code> element <a href="#represents" id="the-menu-element:represents">represents</a> a toolbar consisting of its contents, in
  the form of an unordered list of items (represented by <code id="the-menu-element:the-li-element-3"><a href="#the-li-element">li</a></code> elements), each of
  which represents a command that the user can perform or activate.</p>

  <p class="note">The <code id="the-menu-element:the-menu-element-2"><a href="#the-menu-element">menu</a></code> element is simply a semantic alternative to <code id="the-menu-element:the-ul-element"><a href="#the-ul-element">ul</a></code>
  to express an unordered list of commands (a "toolbar").</p>

  <div class="example">
   <p>In this example, a text-editing application uses a <code id="the-menu-element:the-menu-element-3"><a href="#the-menu-element">menu</a></code> element to provide a
   series of editing commands:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">menu</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"copy()"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"copy.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Copy"</c-><c- p="">&gt;&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"cut()"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"cut.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Cut"</c-><c- p="">&gt;&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"paste()"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"paste.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Paste"</c-><c- p="">&gt;&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">menu</c-><c- p="">&gt;</c-></code></pre>

   <p>Note that the styling to make this look like a conventional toolbar menu is up to the
   application.</p>
  </div>


  <h4 id="the-li-element"><span class="secno">4.4.8</span> The <dfn data-dfn-type="element"><code>li</code></dfn> element<a href="#the-li-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li" title="The <li> HTML element is used to represent an item in a list. It must be contained in a parent element: an ordered list (<ol>), an unordered list (<ul>), or a menu (<menu>). In menus and unordered lists, list items are usually displayed using bullet points. In ordered lists, they are usually displayed with an ascending counter on the left, such as a number or letter.">Element/li</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLIElement" title="The HTMLLIElement interface exposes specific properties and methods (beyond those defined by regular HTMLElement interface it also has available to it by inheritance) for manipulating list elements.">HTMLLIElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-li-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-li-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Inside <code id="the-li-element:the-ol-element"><a href="#the-ol-element">ol</a></code> elements.</dd><dd>Inside <code id="the-li-element:the-ul-element"><a href="#the-ul-element">ul</a></code> elements.</dd><dd>Inside <code id="the-li-element:the-menu-element"><a href="#the-menu-element">menu</a></code> elements.</dd><dt><a href="#concept-element-content-model" id="the-li-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-li-element:flow-content-2">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-li-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>An <code id="the-li-element:the-li-element"><a href="#the-li-element">li</a></code> element's <a href="#syntax-end-tag" id="the-li-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-li-element:the-li-element-2"><a href="#the-li-element">li</a></code> element is immediately followed by another <code id="the-li-element:the-li-element-3"><a href="#the-li-element">li</a></code> element or if there is
  no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-li-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-li-element:global-attributes">Global attributes</a></dd><dd>If the element is not a child of an <code id="the-li-element:the-ul-element-2"><a href="#the-ul-element">ul</a></code> or <code id="the-li-element:the-menu-element-2"><a href="#the-menu-element">menu</a></code> element: <code id="the-li-element:attr-li-value"><a href="#attr-li-value">value</a></code> —  <a href="#ordinal-value" id="the-li-element:ordinal-value">Ordinal value</a> of the list item
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-li-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-li">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-li">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-li-element:concept-element-dom">DOM interface</a>:</dt><dd>
<pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmllielement" data-dfn-type="interface"><c- g="">HTMLLIElement</c-></dfn> : <a href="#htmlelement" id="the-li-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-li-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-li-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-li-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLLIElement" id="dom-li-value" data-dfn-type="attribute"><c- g="">value</c-></dfn>;

  // <a href="#HTMLLIElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-li-element:the-li-element-4"><a href="#the-li-element">li</a></code> element <a href="#represents" id="the-li-element:represents">represents</a> a list item. If its parent element is an
  <code id="the-li-element:the-ol-element-2"><a href="#the-ol-element">ol</a></code>, <code id="the-li-element:the-ul-element-3"><a href="#the-ul-element">ul</a></code>, or <code id="the-li-element:the-menu-element-3"><a href="#the-menu-element">menu</a></code> element, then the element is an item of the
  parent element's list, as defined for those elements. Otherwise, the list item has no defined
  list-related relationship to any other <code id="the-li-element:the-li-element-5"><a href="#the-li-element">li</a></code> element.</p>

  <p>The <dfn data-dfn-for="li" id="attr-li-value" data-dfn-type="element-attr"><code>value</code></dfn> attribute, if
  present, must be a <a href="#valid-integer" id="the-li-element:valid-integer">valid integer</a>. It is used to determine the <a href="#ordinal-value" id="the-li-element:ordinal-value-2">ordinal
  value</a> of the list item, when the <code id="the-li-element:the-li-element-6"><a href="#the-li-element">li</a></code>'s <a href="#list-owner" id="the-li-element:list-owner">list owner</a> is an
  <code id="the-li-element:the-ol-element-3"><a href="#the-ol-element">ol</a></code> element.</p>

  

  <hr>

  <div data-algorithm="">
  <p>Any element whose <a id="the-li-element:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of <a id="the-li-element:'display'" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> is 'list-item' has a
  <dfn id="list-owner">list owner</dfn>, which is determined as follows:</p>

  <ol><li><p>If the element is not <a href="#being-rendered" id="the-li-element:being-rendered">being rendered</a>, return null; the element has no
   <a href="#list-owner" id="the-li-element:list-owner-2">list owner</a>.</p>

   </li><li><p>Let <var>ancestor</var> be the element's parent.</p></li><li><p>If the element has an <code id="the-li-element:the-ol-element-4"><a href="#the-ol-element">ol</a></code>, <code id="the-li-element:the-ul-element-4"><a href="#the-ul-element">ul</a></code>, or <code id="the-li-element:the-menu-element-4"><a href="#the-menu-element">menu</a></code> ancestor, set
   <var>ancestor</var> to the closest such ancestor element.</p></li><li>
    <p>Return the closest inclusive ancestor of <var>ancestor</var> that produces a <a id="the-li-element:css-box" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS
    box</a>.</p>

    <p class="note">Such an element will always exist, as at the very least the <a id="the-li-element:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document
    element</a> will always produce a <a id="the-li-element:css-box-2" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS box</a>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To determine the <dfn id="ordinal-value">ordinal value</dfn> of each element owned by a given <a href="#list-owner" id="the-li-element:list-owner-3">list
  owner</a> <var>owner</var>, perform the following steps:</p>

  <ol><li><p>Let <var>i</var> be 1.</p></li><li><p>If <var>owner</var> is an <code id="the-li-element:the-ol-element-5"><a href="#the-ol-element">ol</a></code> element, let <var>numbering</var> be
   <var>owner</var>'s <a href="#concept-ol-start" id="the-li-element:concept-ol-start">starting value</a>. Otherwise, let
   <var>numbering</var> be 1.</p></li><li><p><i>Loop</i>: If <var>i</var> is greater than the number of <a href="#list-owner" id="the-li-element:list-owner-4">list items that <var>owner</var> owns</a>, then return; all
   of <var>owner</var>'s <a href="#list-owner" id="the-li-element:list-owner-5">owned list items</a> have been assigned <a href="#ordinal-value" id="the-li-element:ordinal-value-3">ordinal values</a>.</p></li><li><p>Let <var>item</var> be the <var>i</var>th of <var>owner</var>'s <a href="#list-owner" id="the-li-element:list-owner-6">owned list items</a>, in <a id="the-li-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p>

   </li><li>
    <p>If <var>item</var> is an <code id="the-li-element:the-li-element-7"><a href="#the-li-element">li</a></code> element that has a <code id="the-li-element:attr-li-value-2"><a href="#attr-li-value">value</a></code> attribute, then:</p>

    <ol><li><p>Let <var>parsed</var> be the result of <a href="#rules-for-parsing-integers" id="the-li-element:rules-for-parsing-integers">parsing
     the value of the attribute as an integer</a>.</p></li><li><p>If <var>parsed</var> is not an error, then set <var>numbering</var> to
     <var>parsed</var>.</p></li></ol>
   </li><li><p>The <a href="#ordinal-value" id="the-li-element:ordinal-value-4">ordinal value</a> of <var>item</var> is <var>numbering</var>.</p></li><li><p>If <var>owner</var> is an <code id="the-li-element:the-ol-element-6"><a href="#the-ol-element">ol</a></code> element, and <var>owner</var> has a <code id="the-li-element:attr-ol-reversed"><a href="#attr-ol-reversed">reversed</a></code> attribute, decrement <var>numbering</var> by 1;
   otherwise, increment <var>numbering</var> by 1.</p></li><li><p>Increment <var>i</var> by 1.</p></li><li><p>Go to the step labeled <i>loop</i>.</p>
  </li></ol>
  </div>

  <hr>

  <div class="example">
   <p>The element's <code id="the-li-element:dom-li-value"><a href="#dom-li-value">value</a></code> IDL attribute does not directly
   correspond to its <a href="#ordinal-value" id="the-li-element:ordinal-value-5">ordinal value</a>; it simply <a href="#reflect" id="the-li-element:reflect">reflects</a>
   the content attribute. For example, given this list:

   </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ol</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Item 1
 <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"3"</c-><c- p="">&gt;</c->Item 3
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Item 4
<c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c-></code></pre>

   <p>The <a href="#ordinal-value" id="the-li-element:ordinal-value-6">ordinal values</a> are 1, 3, and 4, whereas the <code id="the-li-element:dom-li-value-2"><a href="#dom-li-value">value</a></code> IDL attributes return 0, 3, 0 on getting.</p>
  </div>

  

  <div class="example">

   <p>The following example, the top ten movies are listed (in reverse order). Note the way the list
   is given a title by using a <code id="the-li-element:the-figure-element"><a href="#the-figure-element">figure</a></code> element and its <code id="the-li-element:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code>
   element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->The top 10 movies of all time<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ol</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"10"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Josie and the Pussycats<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2001<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"9"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"sh"</c-><c- p="">&gt;</c->Црна мачка, бели мачор<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 1998<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->A Bug's Life<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 1998<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"7"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Toy Story<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 1995<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"6"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Monsters, Inc<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2001<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"5"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Cars<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2006<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"4"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Toy Story 2<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 1999<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"3"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Finding Nemo<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2003<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"2"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->The Incredibles<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2004<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1"</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Ratatouille<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2007<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

   <p>The markup could also be written as follows, using the <code id="the-li-element:attr-ol-reversed-2"><a href="#attr-ol-reversed">reversed</a></code> attribute on the <code id="the-li-element:the-ol-element-7"><a href="#the-ol-element">ol</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->The top 10 movies of all time<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ol</c-> <c- e="">reversed</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Josie and the Pussycats<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2001<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"sh"</c-><c- p="">&gt;</c->Црна мачка, бели мачор<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 1998<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->A Bug's Life<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 1998<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Toy Story<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 1995<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Monsters, Inc<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2001<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Cars<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2006<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Toy Story 2<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 1999<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Finding Nemo<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2003<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->The Incredibles<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2004<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Ratatouille<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, 2007<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p class="note">While it is conforming to include heading elements (e.g. <code id="the-li-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>) inside
  <code id="the-li-element:the-li-element-8"><a href="#the-li-element">li</a></code> elements, it likely does not convey the semantics that the author intended. A
  heading starts a new section, so a heading in a list implicitly splits the list into spanning
  multiple sections.</p>



  <h4 id="the-dl-element"><span class="secno">4.4.9</span> The <dfn data-dfn-type="element"><code>dl</code></dfn> element<a href="#the-dl-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl" title="The <dl> HTML element represents a description list. The element encloses a list of groups of terms (specified using the <dt> element) and descriptions (provided by <dd> elements). Common uses for this element are to implement a glossary or to display metadata (a list of key-value pairs).">Element/dl</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDListElement" title="The HTMLDListElement interface provides special properties (beyond those of the regular HTMLElement interface it also has available to it by inheritance) for manipulating definition list (<dl>) elements.">HTMLDListElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-dl-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-dl-element:flow-content-2">Flow content</a>.</dd><dd>If the element's children include at least one name-value group: <a href="#palpable-content-2" id="the-dl-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-dl-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-dl-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-dl-element:concept-element-content-model">Content model</a>:</dt><dd>Either: Zero or more groups each consisting of one or more <code id="the-dl-element:the-dt-element"><a href="#the-dt-element">dt</a></code> elements followed by one or more <code id="the-dl-element:the-dd-element"><a href="#the-dd-element">dd</a></code> elements, optionally intermixed with <a href="#script-supporting-elements-2" id="the-dl-element:script-supporting-elements-2">script-supporting elements</a>.</dd><dd>Or: One or more <code id="the-dl-element:the-div-element"><a href="#the-div-element">div</a></code> elements, optionally intermixed with <a href="#script-supporting-elements-2" id="the-dl-element:script-supporting-elements-2-2">script-supporting elements</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-dl-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-dl-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-dl-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-dl-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-dl">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-dl">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-dl-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmldlistelement" data-dfn-type="interface"><c- g="">HTMLDListElement</c-></dfn> : <a href="#htmlelement" id="the-dl-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-dl-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLDListElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-dl-element:the-dl-element"><a href="#the-dl-element">dl</a></code> element <a href="#represents" id="the-dl-element:represents">represents</a> an association list consisting of zero or
  more name-value groups (a description list). A name-value group consists of one or more names
  (<code id="the-dl-element:the-dt-element-2"><a href="#the-dt-element">dt</a></code> elements, possibly as children of a <code id="the-dl-element:the-div-element-2"><a href="#the-div-element">div</a></code> element child) followed by
  one or more values (<code id="the-dl-element:the-dd-element-2"><a href="#the-dd-element">dd</a></code> elements, possibly as children of a <code id="the-dl-element:the-div-element-3"><a href="#the-div-element">div</a></code> element
  child), ignoring any nodes other than <code id="the-dl-element:the-dt-element-3"><a href="#the-dt-element">dt</a></code> and <code id="the-dl-element:the-dd-element-3"><a href="#the-dd-element">dd</a></code> element children, and
  <code id="the-dl-element:the-dt-element-4"><a href="#the-dt-element">dt</a></code> and <code id="the-dl-element:the-dd-element-4"><a href="#the-dd-element">dd</a></code> elements that are children of <code id="the-dl-element:the-div-element-4"><a href="#the-div-element">div</a></code> element
  children. Within a single <code id="the-dl-element:the-dl-element-2"><a href="#the-dl-element">dl</a></code> element, there should not be more than one
  <code id="the-dl-element:the-dt-element-5"><a href="#the-dt-element">dt</a></code> element for each name.</p>

  <p>Name-value groups may be terms and definitions, metadata topics and values, questions and
  answers, or any other groups of name-value data.</p>

  <p>The values within a group are alternatives; multiple paragraphs forming part of the same value
  must all be given within the same <code id="the-dl-element:the-dd-element-5"><a href="#the-dd-element">dd</a></code> element.</p>

  <p>The order of the list of groups, and of the names and values within each group, may be
  significant.</p>

  <p>In order to annotate groups with <a href="#microdata" id="the-dl-element:microdata">microdata</a> attributes, or other <a href="#global-attributes" id="the-dl-element:global-attributes-2">global
  attributes</a> that apply to whole groups, or just for styling purposes, each group in a
  <code id="the-dl-element:the-dl-element-3"><a href="#the-dl-element">dl</a></code> element can be wrapped in a <code id="the-dl-element:the-div-element-5"><a href="#the-div-element">div</a></code> element. This does not change the
  semantics of the <code id="the-dl-element:the-dl-element-4"><a href="#the-dl-element">dl</a></code> element.</p>

  

  <div data-var-scope="">
  <div data-algorithm="">
  <p>The name-value groups of a <code id="the-dl-element:the-dl-element-5"><a href="#the-dl-element">dl</a></code> element <var>dl</var> are determined using the
  following algorithm. A name-value group has a name (a list of <code id="the-dl-element:the-dt-element-6"><a href="#the-dt-element">dt</a></code> elements, initially
  empty) and a value (a list of <code id="the-dl-element:the-dd-element-6"><a href="#the-dd-element">dd</a></code> elements, initially empty).</p>

  <ol><li><p>Let <var>groups</var> be an empty list of name-value groups.</p></li><li><p>Let <var>current</var> be a new name-value group.</p></li><li><p>Let <var>seenDd</var> be false.</p></li><li><p>Let <var>child</var> be <var>dl</var>'s <a id="the-dl-element:first-child" href="https://dom.spec.whatwg.org/#concept-tree-first-child" data-x-internal="first-child">first child</a>.</p></li><li><p>Let <var>grandchild</var> be null.</p></li><li>
    <p>While <var>child</var> is not null:</p>

    <ol><li>
      <p>If <var>child</var> is a <code id="the-dl-element:the-div-element-6"><a href="#the-div-element">div</a></code> element, then:</p>

      <ol><li><p>Let <var>grandchild</var> be <var>child</var>'s <a id="the-dl-element:first-child-2" href="https://dom.spec.whatwg.org/#concept-tree-first-child" data-x-internal="first-child">first child</a>.</p></li><li>
        <p>While <var>grandchild</var> is not null:</p>

        <ol><li><p><a href="#process-dt-or-dd" id="the-dl-element:process-dt-or-dd">Process <code>dt</code> or <code>dd</code></a> for
         <var>grandchild</var>.</p></li><li><p>Set <var>grandchild</var> to <var>grandchild</var>'s <a id="the-dl-element:next-sibling" href="https://dom.spec.whatwg.org/#concept-tree-next-sibling" data-x-internal="next-sibling">next
         sibling</a>.</p></li></ol>
       </li></ol>
     </li><li><p>Otherwise, <a href="#process-dt-or-dd" id="the-dl-element:process-dt-or-dd-2">process <code>dt</code> or <code>dd</code></a> for
     <var>child</var>.</p></li><li><p>Set <var>child</var> to <var>child</var>'s <a id="the-dl-element:next-sibling-2" href="https://dom.spec.whatwg.org/#concept-tree-next-sibling" data-x-internal="next-sibling">next sibling</a>.</p></li></ol>
   </li><li><p>If <var>current</var> is not empty, then append <var>current</var> to
   <var>groups</var>.</p></li><li><p>Return <var>groups</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="process-dt-or-dd">process <code>dt</code> or <code>dd</code></dfn> for a node <var>node</var> means to
  follow these steps:</p>

  <ol><li><p>Let <var>groups</var>, <var>current</var>, and <var>seenDd</var> be the same variables as
   those of the same name in the algorithm that invoked these steps.</p></li><li>
    <p>If <var>node</var> is a <code id="the-dl-element:the-dt-element-7"><a href="#the-dt-element">dt</a></code> element, then:</p>

    <ol><li><p>If <var>seenDd</var> is true, then append <var>current</var> to <var>groups</var>, set
     <var>current</var> to a new name-value group, and set <var>seenDd</var> to false.</p></li><li><p>Append <var>node</var> to <var>current</var>'s name.</p></li></ol>
   </li><li><p>Otherwise, if <var>node</var> is a <code id="the-dl-element:the-dd-element-7"><a href="#the-dd-element">dd</a></code> element, then append <var>node</var> to
   <var>current</var>'s value and set <var>seenDd</var> to true.</p></li></ol>
  </div>
  </div>

  <p class="note">When a name-value group has an empty list as name or value, it is often due to
  accidentally using <code id="the-dl-element:the-dd-element-8"><a href="#the-dd-element">dd</a></code> elements in the place of <code id="the-dl-element:the-dt-element-8"><a href="#the-dt-element">dt</a></code> elements and vice
  versa. Conformance checkers can spot such mistakes and might be able to advise authors how to
  correctly use the markup.</p>

  

  <div class="example">

   <p>In the following example, one entry ("Authors") is linked to two values ("John" and
   "Luke").</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> Authors
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> John
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> Luke
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> Editor
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> Frank
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">

   <p>In the following example, one definition is linked to two terms.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-US"</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">dfn</c-><c- p="">&gt;</c->color<c- p="">&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <span lang="en-GB"><c- p="">&lt;</c-><c- f="">dt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-GB"</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">dfn</c-><c- p="">&gt;</c->colour<c- p="">&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c-></span>
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> A sensation which (in humans) derives from the ability of
 the fine structure of the eye to distinguish three differently
 filtered analyses of a view. <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">

   <p>The following example illustrates the use of the <code id="the-dl-element:the-dl-element-6"><a href="#the-dl-element">dl</a></code> element to mark up metadata
   of sorts. At the end of the example, one group has two metadata labels ("Authors" and "Editors")
   and two values ("Robert Rothman" and "Daniel Jackson"). This example also uses the
   <code id="the-dl-element:the-div-element-7"><a href="#the-div-element">div</a></code> element around the groups of <code id="the-dl-element:the-dt-element-9"><a href="#the-dt-element">dt</a></code> and <code id="the-dl-element:the-dd-element-9"><a href="#the-dd-element">dd</a></code> element, to aid
   with styling.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> Last modified time <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> 2004-12-23T23:33Z <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> Recommended update interval <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> 60s <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> Authors <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> Editors <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> Robert Rothman <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> Daniel Jackson <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">

   <p>The following example shows the <code id="the-dl-element:the-dl-element-7"><a href="#the-dl-element">dl</a></code> element used to give a set of instructions.
   The order of the instructions here is important (in the other examples, the order of the blocks
   was not important).</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Determine the victory points as follows (use the
first matching case):<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> If you have exactly five gold coins <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> You get five victory points <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> If you have one or more gold coins, and you have one or more silver coins <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> You get two victory points <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> If you have one or more silver coins <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> You get one victory point <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> Otherwise <c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> You get no victory points <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">

   <p>The following snippet shows a <code id="the-dl-element:the-dl-element-8"><a href="#the-dl-element">dl</a></code> element being used as a glossary. Note the use
   of <code id="the-dl-element:the-dfn-element"><a href="#the-dfn-element">dfn</a></code> to indicate the word being defined.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;&lt;</c-><c- f="">dfn</c-><c- p="">&gt;</c->Apartment<c- p="">&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c->, n.<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->An execution context grouping one or more threads with one or
 more COM objects.<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;&lt;</c-><c- f="">dfn</c-><c- p="">&gt;</c->Flat<c- p="">&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c->, n.<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->A deflated tire.<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;&lt;</c-><c- f="">dfn</c-><c- p="">&gt;</c->Home<c- p="">&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c->, n.<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->The user's login directory.<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">

   <p>This example uses <a href="#microdata" id="the-dl-element:microdata-2">microdata</a> attributes in a <code id="the-dl-element:the-dl-element-9"><a href="#the-dl-element">dl</a></code> element, together
   with the <code id="the-dl-element:the-div-element-8"><a href="#the-div-element">div</a></code> element, to annotate the ice cream desserts at a French restaurant.</p>
   

   <pre lang="fr"><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Product"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Café ou Chocolat Liégeois
  <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"offers"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Offer"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"price"</c-><c- p="">&gt;</c->3.50<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"priceCurrency"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"EUR"</c-><c- p="">&gt;</c->€<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"description"</c-><c- p="">&gt;</c->
   2 boules Café ou Chocolat, 1 boule Vanille, sauce café ou chocolat, chantilly
 <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->

 <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Product"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Américaine
  <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"offers"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Offer"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"price"</c-><c- p="">&gt;</c->3.50<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"priceCurrency"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"EUR"</c-><c- p="">&gt;</c->€<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"description"</c-><c- p="">&gt;</c->
   1 boule Crème brûlée, 1 boule Vanille, 1 boule Caramel, chantilly
 <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

   <p>Without the <code id="the-dl-element:the-div-element-9"><a href="#the-div-element">div</a></code> element the markup would need to use the <code id="the-dl-element:attr-itemref"><a href="#attr-itemref">itemref</a></code> attribute to link the data in the <code id="the-dl-element:the-dd-element-10"><a href="#the-dd-element">dd</a></code> elements
   with the item, as follows.</p>

   <pre lang="fr"><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Product"</c-> <c- e="">itemref</c-><c- o="">=</c-><c- s="">"1-offer 1-description"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Café ou Chocolat Liégeois<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"1-offer"</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"offers"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Offer"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"price"</c-><c- p="">&gt;</c->3.50<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"priceCurrency"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"EUR"</c-><c- p="">&gt;</c->€<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"1-description"</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"description"</c-><c- p="">&gt;</c->
  2 boules Café ou Chocolat, 1 boule Vanille, sauce café ou chocolat, chantilly

 <c- p="">&lt;</c-><c- f="">dt</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Product"</c-> <c- e="">itemref</c-><c- o="">=</c-><c- s="">"2-offer 2-description"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Américaine<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"2-offer"</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"offers"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Offer"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"price"</c-><c- p="">&gt;</c->3.50<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"priceCurrency"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"EUR"</c-><c- p="">&gt;</c->€<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"2-description"</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"description"</c-><c- p="">&gt;</c->
  1 boule Crème brûlée, 1 boule Vanille, 1 boule Caramel, chantilly
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p class="note">The <code id="the-dl-element:the-dl-element-10"><a href="#the-dl-element">dl</a></code> element is inappropriate for marking up dialogue. See some <a href="#conversations">examples of how to mark up dialogue</a>.</p>



  <h4 id="the-dt-element"><span class="secno">4.4.10</span> The <dfn data-dfn-type="element"><code>dt</code></dfn> element<a href="#the-dt-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dt" title="The <dt> HTML element specifies a term in a description or definition list, and as such must be used inside a <dl> element. It is usually followed by a <dd> element; however, multiple <dt> elements in a row indicate several terms that are all defined by the immediate next <dd> element.">Element/dt</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-dt-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-dt-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Before <code id="the-dt-element:the-dd-element"><a href="#the-dd-element">dd</a></code> or <code id="the-dt-element:the-dt-element"><a href="#the-dt-element">dt</a></code> elements inside <code id="the-dt-element:the-dl-element"><a href="#the-dl-element">dl</a></code> elements.</dd><dd>Before <code id="the-dt-element:the-dd-element-2"><a href="#the-dd-element">dd</a></code> or <code id="the-dt-element:the-dt-element-2"><a href="#the-dt-element">dt</a></code> elements inside <code id="the-dt-element:the-div-element"><a href="#the-div-element">div</a></code> elements that are children of a <code id="the-dt-element:the-dl-element-2"><a href="#the-dl-element">dl</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-dt-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-dt-element:flow-content-2">Flow content</a>, but with no <code id="the-dt-element:the-header-element"><a href="#the-header-element">header</a></code>, <code id="the-dt-element:the-footer-element"><a href="#the-footer-element">footer</a></code>, <a href="#sectioning-content-2" id="the-dt-element:sectioning-content-2">sectioning content</a>, or <a href="#heading-content-2" id="the-dt-element:heading-content-2">heading content</a> descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-dt-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-dt-element:the-dt-element-3"><a href="#the-dt-element">dt</a></code> element's <a href="#syntax-end-tag" id="the-dt-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-dt-element:the-dt-element-4"><a href="#the-dt-element">dt</a></code> element is immediately followed by another <code id="the-dt-element:the-dt-element-5"><a href="#the-dt-element">dt</a></code> element or a
  <code id="the-dt-element:the-dd-element-3"><a href="#the-dd-element">dd</a></code> element.</dd><dt><a href="#concept-element-attributes" id="the-dt-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-dt-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-dt-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-dt">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-dt">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-dt-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-dt-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-dt-element:the-dt-element-6"><a href="#the-dt-element">dt</a></code> element <a href="#represents" id="the-dt-element:represents">represents</a> the term, or name, part of a
  term-description group in a description list (<code id="the-dt-element:the-dl-element-3"><a href="#the-dl-element">dl</a></code> element).</p>

  <p class="note">The <code id="the-dt-element:the-dt-element-7"><a href="#the-dt-element">dt</a></code> element itself, when used in a <code id="the-dt-element:the-dl-element-4"><a href="#the-dl-element">dl</a></code> element, does
  not indicate that its contents are a term being defined, but this can be indicated using the
  <code id="the-dt-element:the-dfn-element"><a href="#the-dfn-element">dfn</a></code> element.</p>

  <div class="example">

   <p>This example shows a list of frequently asked questions (a FAQ) marked up using the
   <code id="the-dt-element:the-dt-element-8"><a href="#the-dt-element">dt</a></code> element for questions and the <code id="the-dt-element:the-dd-element-4"><a href="#the-dd-element">dd</a></code> element for answers.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->FAQ<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->What do we want?<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->Our data.<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->When do we want it?<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->Now.<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Where is it?<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->We are not sure.<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-dd-element"><span class="secno">4.4.11</span> The <dfn data-dfn-type="element"><code>dd</code></dfn> element<a href="#the-dd-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dd" title="The <dd> HTML element provides the description, definition, or value for the preceding term (<dt>) in a description list (<dl>).">Element/dd</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-dd-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-dd-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>After <code id="the-dd-element:the-dt-element"><a href="#the-dt-element">dt</a></code> or <code id="the-dd-element:the-dd-element"><a href="#the-dd-element">dd</a></code> elements inside <code id="the-dd-element:the-dl-element"><a href="#the-dl-element">dl</a></code> elements.</dd><dd>After <code id="the-dd-element:the-dt-element-2"><a href="#the-dt-element">dt</a></code> or <code id="the-dd-element:the-dd-element-2"><a href="#the-dd-element">dd</a></code> elements inside <code id="the-dd-element:the-div-element"><a href="#the-div-element">div</a></code> elements that are children of a <code id="the-dd-element:the-dl-element-2"><a href="#the-dl-element">dl</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-dd-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-dd-element:flow-content-2">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-dd-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-dd-element:the-dd-element-3"><a href="#the-dd-element">dd</a></code> element's <a href="#syntax-end-tag" id="the-dd-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-dd-element:the-dd-element-4"><a href="#the-dd-element">dd</a></code> element is immediately followed by another <code id="the-dd-element:the-dd-element-5"><a href="#the-dd-element">dd</a></code> element or a
  <code id="the-dd-element:the-dt-element-3"><a href="#the-dt-element">dt</a></code> element, or if there is no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-dd-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-dd-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-dd-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-dd">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-dd">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-dd-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-dd-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-dd-element:the-dd-element-6"><a href="#the-dd-element">dd</a></code> element <a href="#represents" id="the-dd-element:represents">represents</a> the description, definition, or value, part
  of a term-description group in a description list (<code id="the-dd-element:the-dl-element-3"><a href="#the-dl-element">dl</a></code> element).</p>

  <div class="example">

   <p>A <code id="the-dd-element:the-dl-element-4"><a href="#the-dl-element">dl</a></code> can be used to define a vocabulary list, like in a dictionary. In the
   following example, each entry, given by a <code id="the-dd-element:the-dt-element-4"><a href="#the-dt-element">dt</a></code> with a <code id="the-dd-element:the-dfn-element"><a href="#the-dfn-element">dfn</a></code>, has several
   <code id="the-dd-element:the-dd-element-7"><a href="#the-dd-element">dd</a></code>s, showing the various parts of the definition.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;&lt;</c-><c- f="">dfn</c-><c- p="">&gt;</c->happiness<c- p="">&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"pronunciation"</c-><c- p="">&gt;</c->/ˈhæpinəs/<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"part-of-speech"</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-><c- p="">&gt;&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->n.<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;&lt;/</c-><c- f="">i</c-><c- p="">&gt;&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->The state of being happy.<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->Good fortune; success. <c- p="">&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->Oh <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->happiness<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->! It worked!<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;&lt;</c-><c- f="">dfn</c-><c- p="">&gt;</c->rejoice<c- p="">&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"pronunciation"</c-><c- p="">&gt;</c->/rɪˈdʒɔɪs/<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"part-of-speech"</c-><c- p="">&gt;&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->v.intr.<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c-> To be delighted oneself.<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"part-of-speech"</c-><c- p="">&gt;&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->v.tr.<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c-> To cause one to be delighted.<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h4 id="the-figure-element"><span class="secno">4.4.12</span> The <dfn data-dfn-type="element"><code>figure</code></dfn> element<a href="#the-figure-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure" title="The <figure> HTML element represents self-contained content, potentially with an optional caption, which is specified using the <figcaption> element. The figure, its caption, and its contents are referenced as a single unit.">Element/figure</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-figure-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-figure-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-figure-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-figure-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-figure-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-figure-element:concept-element-content-model">Content model</a>:</dt><dd>Either: one <code id="the-figure-element:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code> element followed by <a href="#flow-content-2" id="the-figure-element:flow-content-2-3">flow content</a>.</dd><dd>Or: <a href="#flow-content-2" id="the-figure-element:flow-content-2-4">flow content</a> followed by one <code id="the-figure-element:the-figcaption-element-2"><a href="#the-figcaption-element">figcaption</a></code> element.</dd><dd>Or: <a href="#flow-content-2" id="the-figure-element:flow-content-2-5">flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-figure-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-figure-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-figure-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-figure-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-figure">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-figure">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-figure-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-figure-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-figure-element:the-figure-element"><a href="#the-figure-element">figure</a></code> element <a href="#represents" id="the-figure-element:represents">represents</a> some <a href="#flow-content-2" id="the-figure-element:flow-content-2-6">flow content</a>,
  optionally with a caption, that is self-contained (like a complete sentence) and is typically
  <a href="#referenced" id="the-figure-element:referenced">referenced</a> as a single unit from the main flow of the document.</p>

  <p class="note">"Self-contained" in this context does not necessarily mean independent. For
  example, each sentence in a paragraph is self-contained; an image that is part of a sentence would
  be inappropriate for <code id="the-figure-element:the-figure-element-2"><a href="#the-figure-element">figure</a></code>, but an entire sentence made of images would be
  fitting.</p>

  <p>The element can thus be used to annotate illustrations, diagrams, photos, code listings,
  etc.</p>

  <div id="figure-note-about-references" class="note"><a href="#figure-note-about-references" class="self-link"></a>
   <p>When a <code id="the-figure-element:the-figure-element-3"><a href="#the-figure-element">figure</a></code> is referred to from the main content of the document by identifying
   it by its caption (e.g., by figure number), it enables such content to be easily moved away from
   that primary content, e.g., to the side of the page, to dedicated pages, or to an appendix,
   without affecting the flow of the document.</p>

   <p>If a <code id="the-figure-element:the-figure-element-4"><a href="#the-figure-element">figure</a></code> element is <a href="#referenced" id="the-figure-element:referenced-2">referenced</a> by its relative position, e.g.,
   "in the photograph above" or "as the next figure shows", then moving the figure would disrupt the
   page's meaning. Authors are encouraged to consider using labels to refer to figures, rather than
   using such relative references, so that the page can easily be restyled without affecting the
   page's meaning.</p>
  </div>

  <p>The first <code id="the-figure-element:the-figcaption-element-3"><a href="#the-figcaption-element">figcaption</a></code> element child of the element, if any,
  represents the caption of the <code id="the-figure-element:the-figure-element-5"><a href="#the-figure-element">figure</a></code> element's contents. If there is no child
  <code id="the-figure-element:the-figcaption-element-4"><a href="#the-figcaption-element">figcaption</a></code> element, then there is no caption.</p>

  <p>A <code id="the-figure-element:the-figure-element-6"><a href="#the-figure-element">figure</a></code> element's contents are part of the surrounding flow. If the purpose of
  the page is to display the figure, for example a photograph on an image sharing site, the
  <code id="the-figure-element:the-figure-element-7"><a href="#the-figure-element">figure</a></code> and <code id="the-figure-element:the-figcaption-element-5"><a href="#the-figcaption-element">figcaption</a></code> elements can be used to explicitly provide a
  caption for that figure. For content that is only tangentially related, or that serves a separate
  purpose than the surrounding flow, the <code id="the-figure-element:the-aside-element"><a href="#the-aside-element">aside</a></code> element should be used (and can itself
  wrap a <code id="the-figure-element:the-figure-element-8"><a href="#the-figure-element">figure</a></code>). For example, a pull quote that repeats content from an
  <code id="the-figure-element:the-article-element"><a href="#the-article-element">article</a></code> would be more appropriate in an <code id="the-figure-element:the-aside-element-2"><a href="#the-aside-element">aside</a></code> than in a
  <code id="the-figure-element:the-figure-element-9"><a href="#the-figure-element">figure</a></code>, because it isn't part of the content, it's a repetition of the content for
  the purposes of enticing readers or highlighting key topics.</p>

  <div class="example">
   <p>This example shows the <code id="the-figure-element:the-figure-element-10"><a href="#the-figure-element">figure</a></code> element to mark up a code listing.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->In <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#l4"</c-><c- p="">&gt;</c->listing 4<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> we see the primary core interface
API declaration.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">figure</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"l4"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Listing 4. The primary core interface API declaration.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->interface PrimaryCore {
 boolean verifyDataLine();
 undefined sendData(sequence<c- ni="">&amp;lt;</c->byte&gt; data);
 undefined initSelfDestruct();
}<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The API is designed to use UTF-8.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>Here we see a <code id="the-figure-element:the-figure-element-11"><a href="#the-figure-element">figure</a></code> element to mark up a photo that is the main content of the
   page (as in a gallery).</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Bubbles at work — My Gallery™<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"bubbles-work.jpeg"</c->
      <c- e="">alt</c-><c- o="">=</c-><c- s="">"Bubbles, sitting in his office chair, works on his</c->
<c- s="">           latest project intently."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Bubbles at work<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"19414.html"</c-><c- p="">&gt;</c->Prev<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> — <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"19416.html"</c-><c- p="">&gt;</c->Next<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>In this example, we see an image that is <em>not</em> a figure, as well as an image and a
   video that are. The first image is literally part of the example's second sentence, so it's not a
   self-contained unit, and thus <code id="the-figure-element:the-figure-element-12"><a href="#the-figure-element">figure</a></code> would be inappropriate.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Malinko's comics<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This case centered on some sort of "intellectual property"
infringement related to a comic (see Exhibit A). The suit started
after a trailer ending with these words:

<c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"promblem-packed-action.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"ROUGH COPY! Promblem-Packed Action!"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->...was aired. A lawyer, armed with a Bigger Notebook, launched a
preemptive strike using snowballs. A complete copy of the trailer is
included with Exhibit B.

<c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"ex-a.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Two squiggles on a dirty piece of paper."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Exhibit A. The alleged <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->rough copy<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-> comic.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">video</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"ex-b.mov"</c-><c- p="">&gt;&lt;/</c-><c- f="">video</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Exhibit B. The <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Rough Copy<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-> trailer.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The case was resolved out of court.</code></pre>
  </div>

  <div class="example">
   <p>Here, a part of a poem is marked up using <code id="the-figure-element:the-figure-element-13"><a href="#the-figure-element">figure</a></code>.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->'Twas brillig, and the slithy toves<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
 Did gyre and gimble in the wabe;<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
 All mimsy were the borogoves,<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
 And the mome raths outgrabe.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Jabberwocky<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-> (first verse). Lewis Carroll, 1832-98<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>In this example, which could be part of a much larger work discussing a castle, nested
   <code id="the-figure-element:the-figure-element-14"><a href="#the-figure-element">figure</a></code> elements are used to provide both a group caption and individual captions for
   each figure in the group:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->The castle through the ages: 1423, 1858, and 1999 respectively.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Etching. Anonymous, ca. 1423.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"castle1423.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The castle has one tower, and a tall wall around it."</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Oil-based paint on canvas. Maria Towle, 1858.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"castle1858.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The castle now has two towers and two walls."</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Film photograph. Peter Jankle, 1999.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"castle1999.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The castle lies in ruins, the original tower all that remains in one piece."</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>The previous example could also be more succinctly written as follows (using <code id="the-figure-element:attr-title"><a href="#attr-title">title</a></code> attributes in place of the nested
   <code id="the-figure-element:the-figure-element-15"><a href="#the-figure-element">figure</a></code>/<code id="the-figure-element:the-figcaption-element-6"><a href="#the-figcaption-element">figcaption</a></code> pairs):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"castle1423.jpeg"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Etching. Anonymous, ca. 1423."</c->
      <c- e="">alt</c-><c- o="">=</c-><c- s="">"The castle has one tower, and a tall wall around it."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"castle1858.jpeg"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Oil-based paint on canvas. Maria Towle, 1858."</c->
      <c- e="">alt</c-><c- o="">=</c-><c- s="">"The castle now has two towers and two walls."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"castle1999.jpeg"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Film photograph. Peter Jankle, 1999."</c->
      <c- e="">alt</c-><c- o="">=</c-><c- s="">"The castle lies in ruins, the original tower all that remains in one piece."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->The castle through the ages: 1423, 1858, and 1999 respectively.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>The figure is sometimes <a href="#referenced" id="the-figure-element:referenced-3">referenced</a> only implicitly from the content:</p>

   

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Fiscal negotiations stumble in Congress as deadline nears<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"obama-reid.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Obama and Reid sit together smiling in the Oval Office."</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Barack Obama and Harry Reid. White House press photograph.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Negotiations in Congress to end the fiscal impasse sputtered on Tuesday, leaving both chambers
 grasping for a way to reopen the government and raise the country's borrowing authority with a
 Thursday deadline drawing near.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 ...
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h4 id="the-figcaption-element"><span class="secno">4.4.13</span> The <dfn data-dfn-type="element"><code>figcaption</code></dfn> element<a href="#the-figcaption-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption" title="The <figcaption> HTML element represents a caption or legend describing the rest of the contents of its parent <figure> element.">Element/figcaption</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-figcaption-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-figcaption-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As the first or last child of a <code id="the-figcaption-element:the-figure-element"><a href="#the-figure-element">figure</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-figcaption-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-figcaption-element:flow-content-2">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-figcaption-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-figcaption-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-figcaption-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-figcaption-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-figcaption">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-figcaption">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-figcaption-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-figcaption-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-figcaption-element:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code> element <a href="#represents" id="the-figcaption-element:represents">represents</a> a caption or legend for the rest of
  the contents of the <code id="the-figcaption-element:the-figcaption-element-2"><a href="#the-figcaption-element">figcaption</a></code> element's parent <code id="the-figcaption-element:the-figure-element-2"><a href="#the-figure-element">figure</a></code> element, if any.</p>

  <div class="example">
   <p>The element can contain additional information about the source:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->A duck.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Photograph courtesy of 🌟 News.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Average rent for 3-room apartments, excluding non-profit apartments<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Zürich’s Statistics Office — <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">2017-11-14</c-><c- p="">&gt;</c->14 November 2017<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h4 id="the-main-element"><span class="secno">4.4.14</span> The <dfn data-dfn-type="element"><code>main</code></dfn> element<a href="#the-main-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main" title="The <main> HTML element represents the dominant content of the <body> of a document. The main content area consists of content that is directly related to or expands upon the central topic of a document, or the central functionality of an application.">Element/main</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>21+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>26+</span></span><hr><span class="opera yes"><span>Opera</span><span>16+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-main-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-main-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-main-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-main-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-main-element:flow-content-2-2">flow content</a> is expected, but only if it is a <a href="#hierarchically-correct-main-element" id="the-main-element:hierarchically-correct-main-element">hierarchically correct
   <code>main</code> element</a>.</dd><dt><a href="#concept-element-content-model" id="the-main-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-main-element:flow-content-2-3">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-main-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-main-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-main-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-main-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-main">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-main">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-main-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-main-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-main-element:the-main-element"><a href="#the-main-element">main</a></code> element <a href="#represents" id="the-main-element:represents">represents</a> the dominant contents of the
  document.</p>

  <p>A document must not have more than one <code id="the-main-element:the-main-element-2"><a href="#the-main-element">main</a></code> element that does not have the <code id="the-main-element:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute specified.</p>

  <div data-algorithm="">
  <p>A <dfn id="hierarchically-correct-main-element">hierarchically correct <code>main</code> element</dfn> is one whose ancestor elements
  are limited to <code id="the-main-element:the-html-element"><a href="#the-html-element">html</a></code>, <code id="the-main-element:the-body-element"><a href="#the-body-element">body</a></code>, <code id="the-main-element:the-div-element"><a href="#the-div-element">div</a></code>, <code id="the-main-element:the-form-element"><a href="#the-form-element">form</a></code> without
  an <a href="https://w3c.github.io/aria/#dfn-accessible-name" id="the-main-element:concept-accessible-name" data-x-internal="concept-accessible-name">accessible name</a>, and <a href="#autonomous-custom-element" id="the-main-element:autonomous-custom-element">autonomous custom elements</a>. Each <code id="the-main-element:the-main-element-3"><a href="#the-main-element">main</a></code> element must be a
  <a href="#hierarchically-correct-main-element" id="the-main-element:hierarchically-correct-main-element-2">hierarchically correct <code>main</code> element</a>.</p>
  </div>

  <div class="example">

   <p>In this example, the author has used a presentation where each component of the page is
   rendered in a box. To wrap the main content of the page (as opposed to the header, the footer,
   the navigation bar, and a sidebar), the <code id="the-main-element:the-main-element-4"><a href="#the-main-element">main</a></code> element is used.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->RPG System 17<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
 <c- f="">header</c-><c- o="">,</c-> <c- f="">nav</c-><c- o="">,</c-> <c- f="">aside</c-><c- o="">,</c-> <c- f="">main</c-><c- o="">,</c-> <c- f="">footer</c-> <c- p="">{</c->
   <c- k="">margin</c-><c- p="">:</c-> <c- mf="">0.5</c-><c- b="">em</c-><c- p="">;</c-> <c- k="">border</c-><c- p="">:</c-> <c- kc="">thin</c-> <c- kc="">solid</c-><c- p="">;</c-> <c- k="">padding</c-><c- p="">:</c-> <c- mf="">0.5</c-><c- b="">em</c-><c- p="">;</c->
   <c- k="">background</c-><c- p="">:</c-> <c- mh="">#EFF</c-><c- p="">;</c-> <c- k="">color</c-><c- p="">:</c-> <c- kc="">black</c-><c- p="">;</c-> <c- k="">box-shadow</c-><c- p="">:</c-> <c- mi="">0</c-> <c- mi="">0</c-> <c- mf="">0.25</c-><c- b="">em</c-> <c- mh="">#033</c-><c- p="">;</c->
 <c- p="">}</c->
 <c- f="">h1</c-><c- o="">,</c-> <c- f="">h2</c-><c- o="">,</c-> <c- f="">p</c-> <c- p="">{</c-> <c- k="">margin</c-><c- p="">:</c-> <c- mi="">0</c-><c- p="">;</c-> <c- p="">}</c->
 <c- f="">nav</c-><c- o="">,</c-> <c- f="">main</c-> <c- p="">{</c-> <c- k="">float</c-><c- p="">:</c-> <c- kc="">left</c-><c- p="">;</c-> <c- p="">}</c->
 <c- f="">aside</c-> <c- p="">{</c-> <c- k="">float</c-><c- p="">:</c-> <c- kc="">right</c-><c- p="">;</c-> <c- p="">}</c->
 <c- f="">footer</c-> <c- p="">{</c-> <c- k="">clear</c-><c- p="">:</c-> <c- kc="">both</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->System Eighteen<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"../16/"</c-><c- p="">&gt;</c->← System 17<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"../18/"</c-><c- p="">&gt;</c->RPXIX →<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This system has no HP mechanic, so there's no healing.
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">main</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Character creation<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Attributes (magic, strength, agility) are purchased at the cost of one point per level.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Rolls<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Each encounter, roll the dice for all your skills. If you roll more than the opponent, you win.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">main</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Copyright © 2013
<c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>In the following example, multiple <code id="the-main-element:the-main-element-5"><a href="#the-main-element">main</a></code> elements are used and script is used to
   make navigation work without a server roundtrip and to set the <code id="the-main-element:attr-hidden-2"><a href="#attr-hidden">hidden</a></code> attribute on those that are not current:

   </p><pre><code class="html"><c- cp="">&lt;!doctype html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en-CA</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">utf-8</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c-> … <c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">stylesheet</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">spa.css</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">spa.js</c-> <c- e="">async</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">/</c-><c- p="">&gt;</c->Home<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">/about</c-><c- p="">&gt;</c->About<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">/contact</c-><c- p="">&gt;</c->Contact<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">main</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Home<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 …
<c- p="">&lt;/</c-><c- f="">main</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">main</c-> <c- e="">hidden</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->About<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 …
<c- p="">&lt;/</c-><c- f="">main</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">main</c-> <c- e="">hidden</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Contact<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 …
<c- p="">&lt;/</c-><c- f="">main</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->Made with ❤️ by <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">https://example.com/</c-><c- p="">&gt;</c->Example 👻<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-search-element"><span class="secno">4.4.15</span> The <dfn data-dfn-type="element"><code>search</code></dfn> element<a href="#the-search-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="No support in current engines." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/search" title="The <search> HTML element is a container representing the parts of the document or application with form controls or other content related to performing a search or filtering operation. The <search> element semantically identifies the purpose of the element's contents as having search or filtering capabilities. The search or filtering functionality can be for the website or application, the current web page or document, or the entire Internet or subsection thereof.">Element/search</a></p><p class="less-than-two-engines-text">No support in current engines.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera no"><span>Opera</span><span>No</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-search-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-search-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-search-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-search-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-search-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-search-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-search-element:flow-content-2-3">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-search-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-search-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-search-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-search-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-search">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-search">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-search-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-search-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-search-element:the-search-element"><a href="#the-search-element">search</a></code> element <a href="#represents" id="the-search-element:represents">represents</a> a part of a document or application
  that contains a set of form controls or other content related to performing a search or filtering
  operation. This could be a search of the web site or application; a way of searching or filtering
  search results on the current web page; or a global or Internet-wide search function.</p>

  <p class="note">It's not appropriate to use the <code id="the-search-element:the-search-element-2"><a href="#the-search-element">search</a></code> element just for presenting
  search results, though suggestions and links as part of "quick search" results can be
  included as part of a search feature. Rather, a returned web page of search results would instead
  be expected to be presented as part of the main content of that web page.</p>

  <div class="example">
   <p>In the following example, the author is including a search form within the
   <code id="the-search-element:the-header-element"><a href="#the-header-element">header</a></code> of the web page:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/"</c-><c- p="">&gt;</c->My fancy blog<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  ...
  <c- p="">&lt;</c-><c- f="">search</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"search.php"</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">"query"</c-><c- p="">&gt;</c->Find an article<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"query"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"q"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"search"</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"submit"</c-><c- p="">&gt;</c->Go!<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">search</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>In this example, the author has implemented their web application's search functionality
   entirely with JavaScript. There is no use of the <code id="the-search-element:the-form-element"><a href="#the-form-element">form</a></code> element to perform
   server-side submission, but the containing <code id="the-search-element:the-search-element-3"><a href="#the-search-element">search</a></code> element semantically identifies
   the purpose of the descendant content as representing search capabilities.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">search</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
    Find and filter your query
    <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"search"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"query"</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"checkbox"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"exact-only"</c-><c- p="">&gt;</c->
    Exact matches only
  <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->

  <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Results found:<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">ul</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"results"</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"services/consulting"</c-><c- p="">&gt;</c->Consulting services<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
          Find out how can we help you improve your business with our integrated consultants, Bob and Bob.
        <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
      <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
      ...
    <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
    <c- c="">&lt;!--</c->
<c- c="">      when a query returns or filters out all results</c->
<c- c="">      render the no results message here</c->
<c- c="">    --&gt;</c->
    <c- p="">&lt;</c-><c- f="">output</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"no-results"</c-><c- p="">&gt;&lt;/</c-><c- f="">output</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">search</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
    <p>In the following example, the page has two search features. The first is located in the web page's
    <code id="the-search-element:the-header-element-2"><a href="#the-header-element">header</a></code> and serves as a global mechanism to search the web site's content. Its purpose is
    indicated by its specified <code id="the-search-element:the-title-element"><a href="#the-title-element">title</a></code> attribute. The second is included as part of the main content
    of the page, as it represents a mechanism to search and filter the content of the current page. It contains
    a heading to indicate its purpose.</p>

    <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
    ...
    <c- p="">&lt;</c-><c- f="">search</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Website"</c-><c- p="">&gt;</c->
      ...
    <c- p="">&lt;/</c-><c- f="">search</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">main</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Hotels near your location<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">search</c-><c- p="">&gt;</c->
       <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Filter results<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
       ...
     <c- p="">&lt;/</c-><c- f="">search</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
      <c- c="">&lt;!-- search result content --&gt;</c->
    <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">main</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h4 id="the-div-element"><span class="secno">4.4.16</span> The <dfn data-dfn-type="element"><code>div</code></dfn> element<a href="#the-div-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div" title="The <div> HTML element is the generic container for flow content. It has no effect on the content or layout until styled in some way using CSS (e.g. styling is directly applied to it, or some kind of layout model like Flexbox is applied to its parent element).">Element/div</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement" title="The HTMLDivElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <div> elements.">HTMLDivElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-div-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-div-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-div-element:palpable-content-2">Palpable content</a>.</dd><dd><a href="#select-element-inner-content-elements-2" id="the-div-element:select-element-inner-content-elements-2"><code>select</code> element inner content elements</a>.</dd><dd><a href="#optgroup-element-inner-content-elements-2" id="the-div-element:optgroup-element-inner-content-elements-2"><code>optgroup</code> element inner content elements</a>.</dd><dd><a href="#option-element-inner-content-elements-2" id="the-div-element:option-element-inner-content-elements-2"><code>option</code> element inner content elements</a>.</dd><dt><a href="#concept-element-contexts" id="the-div-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-div-element:flow-content-2-2">flow content</a> is expected.</dd><dd>As a child of a <code id="the-div-element:the-dl-element"><a href="#the-dl-element">dl</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-div-element:concept-element-content-model">Content model</a>:</dt><dd>If the element is a child of a <code id="the-div-element:the-dl-element-2"><a href="#the-dl-element">dl</a></code> element: One or more <code id="the-div-element:the-dt-element"><a href="#the-dt-element">dt</a></code> elements followed by one or more <code id="the-div-element:the-dd-element"><a href="#the-dd-element">dd</a></code> elements, optionally intermixed with <a href="#script-supporting-elements-2" id="the-div-element:script-supporting-elements-2">script-supporting elements</a>.</dd><dd>Otherwise, if the element is a descendant of an <code id="the-div-element:the-option-element"><a href="#the-option-element">option</a></code> element: Zero or more
   <a href="#option-element-inner-content-elements-2" id="the-div-element:option-element-inner-content-elements-2-2"><code>option</code> element inner content elements</a>.</dd><dd>Otherwise, if the element is a descendant of an <code id="the-div-element:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element: Zero or more
   <a href="#optgroup-element-inner-content-elements-2" id="the-div-element:optgroup-element-inner-content-elements-2-2"><code>optgroup</code> element inner content elements</a>.</dd><dd>Otherwise, if the element is a descendant of a <code id="the-div-element:the-select-element"><a href="#the-select-element">select</a></code> element: Zero or more
   <a href="#select-element-inner-content-elements-2" id="the-div-element:select-element-inner-content-elements-2-2"><code>select</code> element inner content elements</a>.</dd><dd>Otherwise: <a href="#flow-content-2" id="the-div-element:flow-content-2-3">flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-div-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-div-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-div-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-div-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-div">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-div">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-div-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmldivelement" data-dfn-type="interface"><c- g="">HTMLDivElement</c-></dfn> : <a href="#htmlelement" id="the-div-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-div-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLDivElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-div-element:the-div-element"><a href="#the-div-element">div</a></code> element has no special meaning at all. It <a href="#represents" id="the-div-element:represents">represents</a> its
  children. It can be used with the <code id="the-div-element:classes"><a href="#classes">class</a></code>, <code id="the-div-element:attr-lang"><a href="#attr-lang">lang</a></code>, and <code id="the-div-element:attr-title"><a href="#attr-title">title</a></code> attributes to mark up
  semantics common to a group of consecutive elements. It can also be used in a <code id="the-div-element:the-dl-element-3"><a href="#the-dl-element">dl</a></code>
  element, wrapping groups of <code id="the-div-element:the-dt-element-2"><a href="#the-dt-element">dt</a></code> and <code id="the-div-element:the-dd-element-2"><a href="#the-dd-element">dd</a></code> elements.</p>

  <p class="note">Authors are strongly encouraged to view the <code id="the-div-element:the-div-element-2"><a href="#the-div-element">div</a></code> element as an element
  of last resort, for when no other element is suitable. Use of more appropriate elements instead of
  the <code id="the-div-element:the-div-element-3"><a href="#the-div-element">div</a></code> element leads to better accessibility for readers and easier maintainability
  for authors.</p>

  <div class="example">

   <p>For example, a blog post would be marked up using <code id="the-div-element:the-article-element"><a href="#the-article-element">article</a></code>, a chapter using
   <code id="the-div-element:the-section-element"><a href="#the-section-element">section</a></code>, a page's navigation aids using <code id="the-div-element:the-nav-element"><a href="#the-nav-element">nav</a></code>, and a group of form
   controls using <code id="the-div-element:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code>.</p>

   <p>On the other hand, <code id="the-div-element:the-div-element-4"><a href="#the-div-element">div</a></code> elements can be useful for stylistic purposes or to wrap
   multiple paragraphs within a section that are all to be annotated in a similar way. In the
   following example, we see <code id="the-div-element:the-div-element-5"><a href="#the-div-element">div</a></code> elements used as a way to set the language of two
   paragraphs at once, instead of setting the language on the two paragraph elements separately:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-US"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->My use of language and my cats<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My cat's behavior hasn't changed much since her absence, except
 that she plays her new physique to the neighbors regularly, in an
 attempt to get pets.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-GB"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My other cat, coloured black and white, is a sweetie. He followed
  us to the pool today, walking down the pavement with us. Yesterday
  he apparently visited our neighbours. I wonder if he recognises that
  their flat is a mirror image of ours.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Hm, I just noticed that in the last paragraph I used British
  English. But I'm supposed to write in American English. So I
  shouldn't say "pavement" or "flat" or "colour"...<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I should say "sidewalk" and "apartment" and "color"!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h3 id="text-level-semantics"><span class="secno">4.5</span> Text-level semantics<a href="#text-level-semantics" class="self-link"></a></h3>

  <h4 id="the-a-element"><span class="secno">4.5.1</span> The <dfn data-dfn-type="element"><code>a</code></dfn> element<a href="#the-a-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a" title="The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.">Element/a</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement" title="The HTMLAnchorElement interface represents hyperlink elements and provides special properties and methods (beyond those of the regular HTMLElement object interface that they inherit from) for manipulating the layout and presentation of such elements. This interface corresponds to <a> element; not to be confused with <link>, which is represented by HTMLLinkElement)">HTMLAnchorElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/download" title="The HTMLAnchorElement.download property is a string indicating that the linked resource is intended to be downloaded rather than displayed in the browser. The value, if any, specifies the default file name for use in labeling the resource in a local file system. If the name is not a valid file name in the underlying OS, the browser will adjust it.">HTMLAnchorElement/download</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>20+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>15+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/rel" title="The HTMLAnchorElement.rel property reflects the rel attribute. It is a string containing a space-separated list of link types indicating the relationship between the resource represented by the <a> element and the current document.">HTMLAnchorElement/rel</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/relList" title="The HTMLAnchorElement.relList read-only property reflects the rel attribute. It is a live DOMTokenList containing the set of link types indicating the relationship between the resource represented by the <a> element and the current document.">HTMLAnchorElement/relList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>30+</span></span><span class="safari yes"><span>Safari</span><span>9+</span></span><span class="chrome yes"><span>Chrome</span><span>65+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-a-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-a-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-a-element:phrasing-content-2">Phrasing content</a>.</dd><dd>If the element has an <code id="the-a-element:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute: <a href="#interactive-content-2" id="the-a-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#palpable-content-2" id="the-a-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-a-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-a-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-a-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#transparent" id="the-a-element:transparent">Transparent</a>, but there must be no <a href="#interactive-content-2" id="the-a-element:interactive-content-2-2">interactive content</a> descendant,
   <code id="the-a-element:the-a-element"><a href="#the-a-element">a</a></code> element descendant, or descendant with the <code id="the-a-element:attr-tabindex"><a href="#attr-tabindex">tabindex</a></code> attribute specified.</dd><dt><a href="#concept-element-tag-omission" id="the-a-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-a-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-a-element:global-attributes">Global attributes</a></dd><dd><code id="the-a-element:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> —  Address of the <a href="#hyperlink" id="the-a-element:hyperlink">hyperlink</a>
     </dd><dd><code id="the-a-element:attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code> —  <a href="#navigable" id="the-a-element:navigable">Navigable</a> for <a href="#hyperlink" id="the-a-element:hyperlink-2">hyperlink</a> <a href="#navigate" id="the-a-element:navigate">navigation</a>
     </dd><dd><code id="the-a-element:attr-hyperlink-download"><a href="#attr-hyperlink-download">download</a></code> —  Whether to download the resource instead of navigating to it, and its filename if so
     </dd><dd><code id="the-a-element:ping"><a href="#ping">ping</a></code> —  <a href="https://url.spec.whatwg.org/#concept-url" id="the-a-element:url" data-x-internal="url">URLs</a> to ping
     </dd><dd><code id="the-a-element:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code> —  Relationship between the location in the document containing the <a href="#hyperlink" id="the-a-element:hyperlink-3">hyperlink</a> and the destination resource
     </dd><dd><code id="the-a-element:attr-hyperlink-hreflang"><a href="#attr-hyperlink-hreflang">hreflang</a></code> —  Language of the linked resource
     </dd><dd><code id="the-a-element:attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code> —  Hint for the type of the referenced resource
     </dd><dd><code id="the-a-element:attr-hyperlink-referrerpolicy"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code> —  <a id="the-a-element:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">Referrer policy</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-a-element:concept-fetch" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-a-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd>If the element has an <code id="the-a-element:attr-hyperlink-href-3"><a href="#attr-hyperlink-href">href</a></code> attribute: <a href="https://w3c.github.io/html-aria/#el-a">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-a">for implementers</a>.</dd><dd>Otherwise: <a href="https://w3c.github.io/html-aria/#el-a-no-href">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-a-no-href">for implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-a-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlanchorelement" data-dfn-type="interface"><c- g="">HTMLAnchorElement</c-></dfn> : <a href="#htmlelement" id="the-a-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-a-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-a-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-a-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-target" data-dfn-type="attribute"><c- g="">target</c-></dfn>;
  [<a href="#cereactions" id="the-a-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-a-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-download" data-dfn-type="attribute"><c- g="">download</c-></dfn>;
  [<a href="#cereactions" id="the-a-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-a-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-ping" data-dfn-type="attribute"><c- g="">ping</c-></dfn>;
  [<a href="#cereactions" id="the-a-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-a-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-rel" data-dfn-type="attribute"><c- g="">rel</c-></dfn>;
  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-a-element:dom-domtokenlist-value" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-a-element:xattr-reflect-5">Reflect</a>="<a href="#attr-hyperlink-rel" id="the-a-element:attr-hyperlink-rel-2">rel</a>"] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-a-element:domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-rellist" data-dfn-type="attribute"><c- g="">relList</c-></dfn>;
  [<a href="#cereactions" id="the-a-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-a-element:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-hreflang" data-dfn-type="attribute"><c- g="">hreflang</c-></dfn>;
  [<a href="#cereactions" id="the-a-element:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-a-element:xattr-reflect-7"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;

  [<a href="#cereactions" id="the-a-element:cereactions-7"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-a-text" id="the-a-element:dom-a-text"><c- g="">text</c-></a>;

  [<a href="#cereactions" id="the-a-element:cereactions-8"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-a-referrerpolicy" id="the-a-element:dom-a-referrerpolicy"><c- g="">referrerPolicy</c-></a>;

  // <a href="#HTMLAnchorElement-partial">also has obsolete members</a>
};
<a href="#htmlanchorelement" id="the-a-element:htmlanchorelement"><c- n="">HTMLAnchorElement</c-></a> <c- b="">includes</c-> <a href="#htmlhyperlinkelementutils" id="the-a-element:htmlhyperlinkelementutils"><c- n="">HTMLHyperlinkElementUtils</c-></a>;</code></pre>
   </dd></dl>

  <p>If the <code id="the-a-element:the-a-element-2"><a href="#the-a-element">a</a></code> element has an <code id="the-a-element:attr-hyperlink-href-4"><a href="#attr-hyperlink-href">href</a></code> attribute,
  then it <a href="#represents" id="the-a-element:represents">represents</a> a <a href="#hyperlink" id="the-a-element:hyperlink-4">hyperlink</a> (a hypertext anchor) labeled by its
  contents.</p>

  

  <p>If the <code id="the-a-element:the-a-element-3"><a href="#the-a-element">a</a></code> element has no <code id="the-a-element:attr-hyperlink-href-5"><a href="#attr-hyperlink-href">href</a></code> attribute,
  then the element <a href="#represents" id="the-a-element:represents-2">represents</a> a placeholder for where a link might otherwise have been
  placed, if it had been relevant, consisting of just the element's contents.</p>

  <p>The <code id="the-a-element:attr-hyperlink-target-2"><a href="#attr-hyperlink-target">target</a></code>, <code id="the-a-element:attr-hyperlink-download-2"><a href="#attr-hyperlink-download">download</a></code>, <code id="the-a-element:ping-2"><a href="#ping">ping</a></code>,
  <code id="the-a-element:attr-hyperlink-rel-3"><a href="#attr-hyperlink-rel">rel</a></code>, <code id="the-a-element:attr-hyperlink-hreflang-2"><a href="#attr-hyperlink-hreflang">hreflang</a></code>, <code id="the-a-element:attr-hyperlink-type-2"><a href="#attr-hyperlink-type">type</a></code>,
  and <code id="the-a-element:attr-hyperlink-referrerpolicy-2"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code> attributes must be omitted
  if the <code id="the-a-element:attr-hyperlink-href-6"><a href="#attr-hyperlink-href">href</a></code> attribute is not present.</p>

  <p>If the <code id="the-a-element:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is specified on an <code id="the-a-element:the-a-element-4"><a href="#the-a-element">a</a></code> element,
  then the <code id="the-a-element:attr-hyperlink-href-7"><a href="#attr-hyperlink-href">href</a></code> attribute must also be specified.</p>

  <div class="example">

   <p>If a site uses a consistent navigation toolbar on every page, then the link that would
   normally link to the page itself could be marked up using an <code id="the-a-element:the-a-element-5"><a href="#the-a-element">a</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/"</c-><c- p="">&gt;</c->Home<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/news"</c-><c- p="">&gt;</c->News<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-><c- p="">&gt;</c->Examples<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/legal"</c-><c- p="">&gt;</c->Legal<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <p>The <code id="the-a-element:attr-hyperlink-href-8"><a href="#attr-hyperlink-href">href</a></code>, <code id="the-a-element:attr-hyperlink-target-3"><a href="#attr-hyperlink-target">target</a></code>, <code id="the-a-element:attr-hyperlink-download-3"><a href="#attr-hyperlink-download">download</a></code>, <code id="the-a-element:ping-3"><a href="#ping">ping</a></code>,
  and <code id="the-a-element:attr-hyperlink-referrerpolicy-3"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code> attributes affect what
  happens when users <a href="#following-hyperlinks-2" id="the-a-element:following-hyperlinks-2">follow hyperlinks</a> or <a href="#downloading-hyperlinks" id="the-a-element:downloading-hyperlinks">download hyperlinks</a> created using the <code id="the-a-element:the-a-element-6"><a href="#the-a-element">a</a></code>
  element. The <code id="the-a-element:attr-hyperlink-rel-4"><a href="#attr-hyperlink-rel">rel</a></code>, <code id="the-a-element:attr-hyperlink-hreflang-3"><a href="#attr-hyperlink-hreflang">hreflang</a></code>, and <code id="the-a-element:attr-hyperlink-type-3"><a href="#attr-hyperlink-type">type</a></code>
  attributes may be used to indicate to the user the likely nature of the target resource before the
  user follows the link.</p>

  

  <dl class="domintro"><dt><code><var>a</var>.<a href="#dom-a-text" id="dom-a-text-dev">text</a></code></dt><dd><p>Same as <code id="the-a-element:textcontent"><a data-x-internal="textcontent" href="https://dom.spec.whatwg.org/#dom-node-textcontent">textContent</a></code>.</p></dd></dl>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/referrerPolicy" title="The HTMLAnchorElement.referrerPolicy property reflect the HTML referrerpolicy attribute of the <a> element defining which referrer is sent when fetching the resource.">HTMLAnchorElement/referrerPolicy</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>14+</span></span><span class="chrome yes"><span>Chrome</span><span>52+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The IDL attribute <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-referrerpolicy" data-dfn-type="attribute"><code>referrerPolicy</code></dfn> must <a href="#reflect" id="the-a-element:reflect">reflect</a> the <code id="the-a-element:attr-hyperlink-referrerpolicy-4"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code> content attribute, <a href="#limited-to-only-known-values" id="the-a-element:limited-to-only-known-values">limited to
  only known values</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-text" data-dfn-type="attribute"><code>text</code></dfn>
  attribute's getter must return this element's <a id="the-a-element:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-a-element:dom-a-text-2"><a href="#dom-a-text">text</a></code> attribute's setter must <a id="the-a-element:string-replace-all" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">string replace
  all</a> with the given value within this element.</p>
  </div>

  

  <div class="example">
   <p>The <code id="the-a-element:the-a-element-7"><a href="#the-a-element">a</a></code> element can be wrapped around entire paragraphs, lists, tables, and so
   forth, even entire sections, so long as there is no interactive content within (e.g., buttons or
   other links). This example shows how this can be used to make an entire advertising block into a
   link:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">aside</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"advertising"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Advertising<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://ad.example.com/?adid=1929&amp;amp;pubid=1422"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Mellblomatic 9000!<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Turn all your widgets into mellbloms!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Only $9.99 plus shipping and handling.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://ad.example.com/?adid=375&amp;amp;pubid=1422"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The Mellblom Browser<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Web browsing at the speed of light.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->No other browser goes faster!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>The following example shows how a bit of script can be used to effectively make an entire row
   in a job listing table a hyperlink:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Position
  <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Team
  <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Location
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/jobs/manager"</c-><c- p="">&gt;</c->Manager<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Remotees
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Remote
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/jobs/director"</c-><c- p="">&gt;</c->Director<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Remotees
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Remote
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/jobs/astronaut"</c-><c- p="">&gt;</c->Astronaut<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Architecture
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Remote
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"table"</c-><c- p="">).</c->onclick <c- o="">=</c-> <c- p="">({</c-> target <c- p="">})</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->target<c- p="">.</c->parentElement<c- p="">.</c->localName <c- o="">===</c-> <c- u="">"tr"</c-><c- p="">)</c-> <c- p="">{</c->
    <c- a="">const</c-> link <c- o="">=</c-> target<c- p="">.</c->parentElement<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"a"</c-><c- p="">);</c->
    <c- k="">if</c-> <c- p="">(</c->link<c- p="">)</c-> <c- p="">{</c->
      link<c- p="">.</c->click<c- p="">();</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h4 id="the-em-element"><span class="secno">4.5.2</span> The <dfn data-dfn-type="element"><code>em</code></dfn> element<a href="#the-em-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/em" title="The <em> HTML element marks text that has stress emphasis. The <em> element can be nested, with each level of nesting indicating a greater degree of emphasis.">Element/em</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-em-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-em-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-em-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-em-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-em-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-em-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-em-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-em-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-em-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-em-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-em-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-em-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-em">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-em">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-em-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-em-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-em-element:the-em-element"><a href="#the-em-element">em</a></code> element <a href="#represents" id="the-em-element:represents">represents</a> stress emphasis of its contents.</p>

  <p>The level of stress that a particular piece of content has is given by its number of ancestor
  <code id="the-em-element:the-em-element-2"><a href="#the-em-element">em</a></code> elements.</p>

  <p>The placement of stress emphasis changes the meaning of the sentence. The element thus forms an
  integral part of the content. The precise way in which stress is used in this way depends on the
  language.</p>

  <div class="example">

   <p>These examples show how changing the stress emphasis changes the meaning. First, a general
   statement of fact, with no stress:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Cats are cute animals.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>By emphasizing the first word, the statement implies that the kind of animal under discussion
   is in question (maybe someone is asserting that dogs are cute):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->Cats<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> are cute animals.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Moving the stress to the verb, one highlights that the truth of the entire sentence is in
   question (maybe someone is saying cats are not cute):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Cats <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->are<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> cute animals.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>By moving it to the adjective, the exact nature of the cats is reasserted (maybe someone
   suggested cats were <em>mean</em> animals):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Cats are <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->cute<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> animals.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Similarly, if someone asserted that cats were vegetables, someone correcting this might
   emphasize the last word:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Cats are cute <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->animals<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>By emphasizing the entire sentence, it becomes clear that the speaker is fighting hard to get
   the point across. This kind of stress emphasis also typically affects the punctuation, hence the
   exclamation mark here.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->Cats are cute animals!<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Anger mixed with emphasizing the cuteness could lead to markup such as:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->Cats are <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->cute<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> animals!<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="note">

   <p>The <code id="the-em-element:the-em-element-3"><a href="#the-em-element">em</a></code> element isn't a generic "italics" element. Sometimes, text is intended to
   stand out from the rest of the paragraph, as if it was in a different mood or voice. For this,
   the <code id="the-em-element:the-i-element"><a href="#the-i-element">i</a></code> element is more appropriate.</p>

   <p>The <code id="the-em-element:the-em-element-4"><a href="#the-em-element">em</a></code> element also isn't intended to convey importance; for that purpose, the
   <code id="the-em-element:the-strong-element"><a href="#the-strong-element">strong</a></code> element is more appropriate.</p>

   

  </div>



  <h4 id="the-strong-element"><span class="secno">4.5.3</span> The <dfn data-dfn-type="element"><code>strong</code></dfn> element<a href="#the-strong-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strong" title="The <strong> HTML element indicates that its contents have strong importance, seriousness, or urgency. Browsers typically render the contents in bold type.">Element/strong</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-strong-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-strong-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-strong-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-strong-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-strong-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-strong-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-strong-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-strong-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-strong-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-strong-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-strong-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-strong-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-strong">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-strong">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-strong-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-strong-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-strong-element:the-strong-element"><a href="#the-strong-element">strong</a></code> element <a href="#represents" id="the-strong-element:represents">represents</a> strong importance, seriousness, or
  urgency for its contents.</p>

  <p><strong>Importance</strong>: the <code id="the-strong-element:the-strong-element-2"><a href="#the-strong-element">strong</a></code> element can be used in a heading, caption,
  or paragraph to distinguish the part that really matters from other parts that might be more
  detailed, more jovial, or merely boilerplate. (This is distinct from marking up subheadings, for
  which the <code id="the-strong-element:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code> element is appropriate.)</p>

  <p class="example">For example, the first word of the previous paragraph is marked up with
  <code id="the-strong-element:the-strong-element-3"><a href="#the-strong-element">strong</a></code> to distinguish it from the more detailed text in the rest of the
  paragraph.</p>

  <p><strong>Seriousness</strong>: the <code id="the-strong-element:the-strong-element-4"><a href="#the-strong-element">strong</a></code> element can be used to mark up a warning
  or caution notice.</p>

  <p><strong>Urgency</strong>: the <code id="the-strong-element:the-strong-element-5"><a href="#the-strong-element">strong</a></code> element can be used to denote contents that
  the user needs to see sooner than other parts of the document.</p>

  <p>The relative level of importance of a piece of content is given by its number of ancestor
  <code id="the-strong-element:the-strong-element-6"><a href="#the-strong-element">strong</a></code> elements; each <code id="the-strong-element:the-strong-element-7"><a href="#the-strong-element">strong</a></code> element increases the importance of its
  contents.</p>

  <p>Changing the importance of a piece of text with the <code id="the-strong-element:the-strong-element-8"><a href="#the-strong-element">strong</a></code> element does not change
  the meaning of the sentence.</p>

  <div class="example">

   <p>Here, the word "chapter" and the actual chapter number are mere boilerplate, and the actual
   name of the chapter is marked up with <code id="the-strong-element:the-strong-element-9"><a href="#the-strong-element">strong</a></code>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Chapter 1: <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->The Praxis<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></code></pre>

   <p>In the following example, the name of the diagram in the caption is marked up with
   <code id="the-strong-element:the-strong-element-10"><a href="#the-strong-element">strong</a></code>, to distinguish it from boilerplate text (before) and the description
   (after):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Figure 1. <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Ant colony dynamics<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->. The ants in this colony are
affected by the heat source (upper left) and the food source (lower right).<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c-></code></pre>

   <p>In this example, the heading is really "Flowers, Bees, and Honey", but the author has added a
   light-hearted addition to the heading. The <code id="the-strong-element:the-strong-element-11"><a href="#the-strong-element">strong</a></code> element is thus used to mark up
   the first part to distinguish it from the latter part.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Flowers, Bees, and Honey<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> and other things I don't understand<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">
   <p>Here is an example of a warning notice in a game, with the
   various parts marked up according to how important they are:</p>
   
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Warning.<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> This dungeon is dangerous.
<c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Avoid the ducks.<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> Take any gold you find.
<c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Do not take any of the diamonds<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->,
they are explosive and <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->will destroy anything within
ten meters.<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> You have been warned.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">

   <p>In this example, the <code id="the-strong-element:the-strong-element-12"><a href="#the-strong-element">strong</a></code> element is used to denote the part of the text that
   the user is intended to read first.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to Remy, the reminder system.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Your tasks for today:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Turn off the oven.<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Put out the trash.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Do the laundry.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-small-element"><span class="secno">4.5.4</span> The <dfn data-dfn-type="element"><code>small</code></dfn> element<a href="#the-small-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small" title="The <small> HTML element represents side-comments and small print, like copyright and legal text, independent of its styled presentation. By default, it renders text within it one font-size smaller, such as from small to x-small.">Element/small</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-small-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-small-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-small-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-small-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-small-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-small-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-small-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-small-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-small-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-small-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-small-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-small-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-small">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-small">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-small-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-small-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-small-element:the-small-element"><a href="#the-small-element">small</a></code> element <a href="#represents" id="the-small-element:represents">represents</a> side comments such as small print.</p>

  <p class="note">Small print typically features disclaimers, caveats, legal restrictions, or
  copyrights. Small print is also sometimes used for attribution, or for satisfying licensing
  requirements.</p>

  <p class="note">The <code id="the-small-element:the-small-element-2"><a href="#the-small-element">small</a></code> element does not "de-emphasize" or lower the importance of
  text emphasized by the <code id="the-small-element:the-em-element"><a href="#the-em-element">em</a></code> element or marked as important with the <code id="the-small-element:the-strong-element"><a href="#the-strong-element">strong</a></code>
  element. To mark text as not emphasized or important, simply do not mark it up with the
  <code id="the-small-element:the-em-element-2"><a href="#the-em-element">em</a></code> or <code id="the-small-element:the-strong-element-2"><a href="#the-strong-element">strong</a></code> elements respectively.</p>

  <p>The <code id="the-small-element:the-small-element-3"><a href="#the-small-element">small</a></code> element should not be used for extended spans of text, such as multiple
  paragraphs, lists, or sections of text. It is only intended for short runs of text. The text of a
  page listing terms of use, for instance, would not be a suitable candidate for the
  <code id="the-small-element:the-small-element-4"><a href="#the-small-element">small</a></code> element: in such a case, the text is not a side comment, it is the main content
  of the page.</p>

  <p>The <code id="the-small-element:the-small-element-5"><a href="#the-small-element">small</a></code> element must not be used for subheadings; for that purpose, use the
  <code id="the-small-element:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code> element.</p>

  <div class="example">

   <p>In this example, the <code id="the-small-element:the-small-element-6"><a href="#the-small-element">small</a></code> element is used to indicate that value-added tax is
   not included in a price of a hotel room:</p>

   <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Single room
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->199 € <c- p="">&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->breakfast included, VAT not included<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Double room
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->239 € <c- p="">&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->breakfast included, VAT not included<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In this second example, the <code id="the-small-element:the-small-element-7"><a href="#the-small-element">small</a></code> element is used for a side comment in an
   article.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Example Corp today announced record profits for the
second quarter <c- p="">&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->(Full Disclosure: Foo News is a subsidiary of
Example Corp)<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;</c->, leading to speculation about a third quarter
merger with Demo Group.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>This is distinct from a sidebar, which might be multiple paragraphs long and is removed from
   the main flow of text. In the following example, we see a sidebar from the same article. This
   sidebar also has small print, indicating the source of the information in the sidebar.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Example Corp<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This company mostly creates small software and Web
 sites.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The Example Corp company mission is "To provide entertainment
 and news on a sample basis".<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Information obtained from <c- p="">&lt;</c-><c- f="">a</c->
 <c- e="">href</c-><c- o="">=</c-><c- s="">"https://example.com/about.html"</c-><c- p="">&gt;</c->example.com<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> home
 page.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In this last example, the <code id="the-small-element:the-small-element-8"><a href="#the-small-element">small</a></code> element is marked as being <em>important</em>
   small print.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Continued use of this service will result in a kiss.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-s-element"><span class="secno">4.5.5</span> The <dfn data-dfn-type="element"><code>s</code></dfn> element<a href="#the-s-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/s" title="The <s> HTML element renders text with a strikethrough, or a line through it. Use the <s> element to represent things that are no longer relevant or no longer accurate. However, <s> is not appropriate when indicating document edits; for that, use the <del> and <ins> elements, as appropriate.">Element/s</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-s-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-s-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-s-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-s-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-s-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-s-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-s-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-s-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-s-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-s-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-s-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-s-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-s">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-s">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-s-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-s-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-s-element:the-s-element"><a href="#the-s-element">s</a></code> element <a href="#represents" id="the-s-element:represents">represents</a> contents that are no longer accurate or no
  longer relevant.</p>

  <p class="note">The <code id="the-s-element:the-s-element-2"><a href="#the-s-element">s</a></code> element is not appropriate when indicating document edits; to
  mark a span of text as having been removed from a document, use the <code id="the-s-element:the-del-element"><a href="#the-del-element">del</a></code> element.</p>

  <div class="example">

   <p>In this example a recommended retail price has been marked as no longer relevant as the
   product in question has a new sale price.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Buy our Iced Tea and Lemonade!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">s</c-><c- p="">&gt;</c->Recommended retail price: $3.99 per bottle<c- p="">&lt;/</c-><c- f="">s</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Now selling for just $2.99 a bottle!<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-cite-element"><span class="secno">4.5.6</span> The <dfn data-dfn-type="element"><code>cite</code></dfn> element<a href="#the-cite-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/cite" title="The <cite> HTML element is used to mark up the title of a cited creative work. The reference may be in an abbreviated form according to context-appropriate conventions related to citation metadata.">Element/cite</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-cite-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-cite-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-cite-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-cite-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-cite-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-cite-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-cite-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-cite-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-cite-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-cite-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-cite-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-cite-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-cite">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-cite">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-cite-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-cite-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-cite-element:the-cite-element"><a href="#the-cite-element">cite</a></code> element <a href="#represents" id="the-cite-element:represents">represents</a> the title of a work (e.g.
    a book,
    a paper,
    an essay,
    a poem,
    a score,
    a song,
    a script,
    a film,
    a TV show,
    a game,
    a sculpture,
    a painting,
    a theatre production,
    a play,
    an opera,
    a musical,
    an exhibition,
    a legal case report,
    a computer program, 
  etc.). This can be a work that is being quoted or <a href="#referenced" id="the-cite-element:referenced">referenced</a> in detail (i.e., a
  citation), or it can just be a work that is mentioned in passing.</p>

  <p>A person's name is not the title of a work — even if people call that person a piece of
  work — and the element must therefore not be used to mark up people's names. (In some cases,
  the <code id="the-cite-element:the-b-element"><a href="#the-b-element">b</a></code> element might be appropriate for names; e.g. in a gossip article where the
  names of famous people are keywords rendered with a different style to draw attention to them. In
  other cases, if an element is <em>really</em> needed, the <code id="the-cite-element:the-span-element"><a href="#the-span-element">span</a></code> element can be
  used.)</p>



  <div class="example">

   <p>This next example shows a typical use of the <code id="the-cite-element:the-cite-element-2"><a href="#the-cite-element">cite</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My favorite book is <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->The Reality Dysfunction<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-> by
Peter F. Hamilton. My favorite comic is <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Pearls Before
Swine<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-> by Stephan Pastis. My favorite track is <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Jive
Samba<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-> by the Cannonball Adderley Sextet.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>This is correct usage:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->According to the Wikipedia article <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->HTML<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, as it
stood in mid-February 2008, leaving attribute values unquoted is
unsafe. This is obviously an over-simplification.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>The following, however, is incorrect usage, as the <code id="the-cite-element:the-cite-element-3"><a href="#the-cite-element">cite</a></code> element here is
   containing far more than the title of the work:</p>

   <pre class="bad"><code class="html"><c- c="">&lt;!-- do not copy this example, it is an example of bad usage! --&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->According to <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->the Wikipedia article on HTML<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, as it
stood in mid-February 2008, leaving attribute values unquoted is
unsafe. This is obviously an over-simplification.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The <code id="the-cite-element:the-cite-element-4"><a href="#the-cite-element">cite</a></code> element is a key part of any citation in a bibliography, but it is only
   used to mark the title:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Universal Declaration of Human Rights<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, United Nations,
December 1948. Adopted by General Assembly resolution 217 A (III).<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p class="note">A <em>citation</em> is not a <em>quote</em> (for which the <code id="the-cite-element:the-q-element"><a href="#the-q-element">q</a></code> element
  is appropriate).</p>

  <div class="example">

   <p>This is incorrect usage, because <code id="the-cite-element:the-cite-element-5"><a href="#the-cite-element">cite</a></code> is not for quotes:</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->This is wrong!<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, said Ian.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>This is also incorrect usage, because a person is not a work:</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->This is still wrong!<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;</c->, said <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Ian<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>The correct usage does not use a <code id="the-cite-element:the-cite-element-6"><a href="#the-cite-element">cite</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->This is correct<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;</c->, said Ian.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>As mentioned above, the <code id="the-cite-element:the-b-element-2"><a href="#the-b-element">b</a></code> element might be relevant for marking names as being
   keywords in certain kinds of documents:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->And then <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->Ian<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> said <c- p="">&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->this might be right, in a
gossip column, maybe!<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-q-element"><span class="secno">4.5.7</span> The <dfn data-dfn-type="element"><code>q</code></dfn> element<a href="#the-q-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q" title="The <q> HTML element indicates that the enclosed text is a short inline quotation. Most modern browsers implement this by surrounding the text in quotation marks. This element is intended for short quotations that don't require paragraph breaks; for long quotations use the <blockquote> element.">Element/q</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-q-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-q-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-q-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-q-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-q-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-q-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-q-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-q-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-q-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-q-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-q-element:global-attributes">Global attributes</a></dd><dd><code id="the-q-element:attr-q-cite"><a href="#attr-q-cite">cite</a></code> —  Link to the source of the quotation or more information about the edit
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-q-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-q">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-q">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-q-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-q-element:htmlquoteelement"><a href="#htmlquoteelement">HTMLQuoteElement</a></code>.</dd></dl>

  <p>The <code id="the-q-element:the-q-element"><a href="#the-q-element">q</a></code> element <a href="#represents" id="the-q-element:represents">represents</a> some <a href="#phrasing-content-2" id="the-q-element:phrasing-content-2-4">phrasing
  content</a> quoted from another source.</p>

  <p>Quotation punctuation (such as quotation marks) that is quoting the contents of the element
  must not appear immediately before, after, or inside <code id="the-q-element:the-q-element-2"><a href="#the-q-element">q</a></code> elements; they will be
  inserted into the rendering by the user agent.</p>

  <p>Content inside a <code id="the-q-element:the-q-element-3"><a href="#the-q-element">q</a></code> element must be quoted from another source, whose address, if
  it has one, may be cited in the <dfn data-dfn-for="q" id="attr-q-cite" data-dfn-type="element-attr"><code>cite</code></dfn> attribute. The source may be fictional, as when quoting
  characters in a novel or screenplay.</p>

  <p>If the <code id="the-q-element:attr-q-cite-2"><a href="#attr-q-cite">cite</a></code> attribute is present, it must be a <a href="#valid-url-potentially-surrounded-by-spaces" id="the-q-element:valid-url-potentially-surrounded-by-spaces">valid
  URL potentially surrounded by spaces</a>. To obtain the corresponding citation
  link, the value of the attribute must be <a href="#encoding-parsing-a-url" id="the-q-element:encoding-parsing-a-url">parsed</a>
  relative to the element's <a id="the-q-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>. User agents may allow users to follow
  such citation links, but they are primarily intended for private use (e.g., by server-side scripts
  collecting statistics about a site's use of quotations), not for readers.</p>

  <p>The <code id="the-q-element:the-q-element-4"><a href="#the-q-element">q</a></code> element must not be used in place of quotation marks that do not represent
  quotes; for example, it is inappropriate to use the <code id="the-q-element:the-q-element-5"><a href="#the-q-element">q</a></code> element for marking up
  sarcastic statements.</p>

  <p>The use of <code id="the-q-element:the-q-element-6"><a href="#the-q-element">q</a></code> elements to mark up quotations is entirely optional; using explicit
  quotation punctuation without <code id="the-q-element:the-q-element-7"><a href="#the-q-element">q</a></code> elements is just as correct.</p>

  <div class="example">

   <p>Here is a simple example of the use of the <code id="the-q-element:the-q-element-8"><a href="#the-q-element">q</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The man said <c- p="">&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->Things that are impossible just take
longer<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;</c->. I disagreed with him.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Here is an example with both an explicit citation link in the <code id="the-q-element:the-q-element-9"><a href="#the-q-element">q</a></code> element, and an
   explicit citation outside:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The W3C page <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->About W3C<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-> says the W3C's
mission is <c- p="">&lt;</c-><c- f="">q</c-> <c- e="">cite</c-><c- o="">=</c-><c- s="">"https://www.w3.org/Consortium/"</c-><c- p="">&gt;</c->To lead the
World Wide Web to its full potential by developing protocols and
guidelines that ensure long-term growth for the Web<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;</c->. I
disagree with this mission.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following example, the quotation itself contains a quotation:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->In <c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Example One<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c->, he writes <c- p="">&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->The man
said <c- p="">&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->Things that are impossible just take longer<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;</c->. I
disagreed with him<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;</c->. Well, I disagree even more!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following example, quotation marks are used instead of the <code id="the-q-element:the-q-element-10"><a href="#the-q-element">q</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->His best argument was ❝I disagree❞, which
I thought was laughable.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following example, there is no quote — the quotation marks are used to name a
   word. Use of the <code id="the-q-element:the-q-element-11"><a href="#the-q-element">q</a></code> element in this case would be inappropriate.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The word "ineffable" could have been used to describe the disaster
resulting from the campaign's mismanagement.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-dfn-element"><span class="secno">4.5.8</span> The <dfn data-dfn-type="element"><code>dfn</code></dfn> element<a href="#the-dfn-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dfn" title="The <dfn> HTML element is used to indicate the term being defined within the context of a definition phrase or sentence. The ancestor <p> element, the <dt>/<dd> pairing, or the nearest <section> ancestor of the <dfn> element, is considered to be the definition of the term.">Element/dfn</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>15+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-dfn-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-dfn-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-dfn-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-dfn-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-dfn-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-dfn-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-dfn-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-dfn-element:phrasing-content-2-3">Phrasing content</a>, but there must be no <code id="the-dfn-element:the-dfn-element"><a href="#the-dfn-element">dfn</a></code> element descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-dfn-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-dfn-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-dfn-element:global-attributes">Global attributes</a></dd><dd>Also, the <code id="the-dfn-element:attr-dfn-title"><a href="#attr-dfn-title">title</a></code> attribute <a href="#attr-dfn-title" id="the-dfn-element:attr-dfn-title-2">has special semantics</a> on this element:  Full term or expansion of abbreviation
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-dfn-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-dfn">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-dfn">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-dfn-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-dfn-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-dfn-element:the-dfn-element-2"><a href="#the-dfn-element">dfn</a></code> element <a href="#represents" id="the-dfn-element:represents">represents</a> the defining instance of a term. The <a href="#paragraph" id="the-dfn-element:paragraph">paragraph</a>, <a href="#the-dl-element" id="the-dfn-element:the-dl-element">description list group</a>, or <a href="#sectioning-content-2" id="the-dfn-element:sectioning-content-2">section</a> that is the nearest ancestor of the <code id="the-dfn-element:the-dfn-element-3"><a href="#the-dfn-element">dfn</a></code>
  element must also contain the definition(s) for the <a href="#defining-term" id="the-dfn-element:defining-term">term</a> given
  by the <code id="the-dfn-element:the-dfn-element-4"><a href="#the-dfn-element">dfn</a></code> element.</p>

  <div data-algorithm="">
  <p><dfn id="defining-term">Defining term</dfn>: if the <code id="the-dfn-element:the-dfn-element-5"><a href="#the-dfn-element">dfn</a></code> element has a <dfn data-dfn-for="dfn" id="attr-dfn-title" data-dfn-type="element-attr"><code>title</code></dfn> attribute, then the exact value of that
  attribute is the term being defined. Otherwise, if it contains exactly one element child node and
  no child <code id="the-dfn-element:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes, and that child element is an <code id="the-dfn-element:the-abbr-element"><a href="#the-abbr-element">abbr</a></code> element with a
  <code id="the-dfn-element:attr-abbr-title"><a href="#attr-abbr-title">title</a></code> attribute, then the exact value of <em>that</em>
  attribute is the term being defined. Otherwise, it is the <a id="the-dfn-element:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a> of
  the <code id="the-dfn-element:the-dfn-element-6"><a href="#the-dfn-element">dfn</a></code> element that gives the term being defined.</p>
  </div>

  

  <p>If the <code id="the-dfn-element:attr-dfn-title-3"><a href="#attr-dfn-title">title</a></code> attribute of the <code id="the-dfn-element:the-dfn-element-7"><a href="#the-dfn-element">dfn</a></code> element is
  present, then it must contain only the term being defined.</p>

  <p class="note">The <code id="the-dfn-element:attr-title"><a href="#attr-title">title</a></code> attribute of ancestor elements does not
  affect <code id="the-dfn-element:the-dfn-element-8"><a href="#the-dfn-element">dfn</a></code> elements.</p>

  <p>An <code id="the-dfn-element:the-a-element"><a href="#the-a-element">a</a></code> element that links to a <code id="the-dfn-element:the-dfn-element-9"><a href="#the-dfn-element">dfn</a></code> element represents an instance of
  the term defined by the <code id="the-dfn-element:the-dfn-element-10"><a href="#the-dfn-element">dfn</a></code> element.</p>

  <div class="example">

   <p>In the following fragment, the term "Garage Door Opener" is first defined in the first
   paragraph, then used in the second. In both cases, its abbreviation is what is actually
   displayed.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The <strong><c- p="">&lt;</c-><c- f="">dfn</c-><c- p="">&gt;&lt;</c-><c- f="">abbr</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Garage Door Opener"</c-><c- p="">&gt;</c->GDO<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c-></strong>
is a device that allows off-world teams to open the iris.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- c="">&lt;!-- ... later in the document: --&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Teal'c activated his <strong><c- p="">&lt;</c-><c- f="">abbr</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Garage Door Opener"</c-><c- p="">&gt;</c->GDO<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-></strong>
and so Hammond ordered the iris to be opened.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>With the addition of an <code id="the-dfn-element:the-a-element-2"><a href="#the-a-element">a</a></code> element, the <a href="#referenced" id="the-dfn-element:referenced">reference</a>
   can be made explicit:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The <c- p="">&lt;</c-><c- f="">dfn</c-> <strong><c- e="">id</c-><c- o="">=</c-><c- s="">gdo</c-></strong><c- p="">&gt;&lt;</c-><c- f="">abbr</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Garage Door Opener"</c-><c- p="">&gt;</c->GDO<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c->
is a device that allows off-world teams to open the iris.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- c="">&lt;!-- ... later in the document: --&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Teal'c activated his <strong><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">#gdo</c-><c- p="">&gt;</c-></strong><c- p="">&lt;</c-><c- f="">abbr</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Garage Door Opener"</c-><c- p="">&gt;</c->GDO<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-><strong><c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></strong>
and so Hammond ordered the iris to be opened.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-abbr-element"><span class="secno">4.5.9</span> The <dfn data-dfn-type="element"><code>abbr</code></dfn> element<a href="#the-abbr-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/abbr" title="The <abbr> HTML element represents an abbreviation or acronym.">Element/abbr</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>7+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-abbr-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-abbr-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-abbr-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-abbr-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-abbr-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-abbr-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-abbr-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-abbr-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-abbr-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-abbr-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-abbr-element:global-attributes">Global attributes</a></dd><dd>Also, the <code id="the-abbr-element:attr-abbr-title"><a href="#attr-abbr-title">title</a></code> attribute <a href="#attr-abbr-title" id="the-abbr-element:attr-abbr-title-2">has special semantics</a> on this element:  Full term or expansion of abbreviation
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-abbr-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-abbr">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-abbr">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-abbr-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-abbr-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-abbr-element:the-abbr-element"><a href="#the-abbr-element">abbr</a></code> element <a href="#represents" id="the-abbr-element:represents">represents</a> an abbreviation or acronym, optionally
  with its expansion. The <dfn data-dfn-for="abbr" id="attr-abbr-title" data-dfn-type="element-attr"><code>title</code></dfn> attribute may be used to provide an expansion of the
  abbreviation. The attribute, if specified, must contain an expansion of the abbreviation, and
  nothing else.</p>

  <div class="example">

   <p>The paragraph below contains an abbreviation marked up with the <code id="the-abbr-element:the-abbr-element-2"><a href="#the-abbr-element">abbr</a></code> element.
   This paragraph <a href="#defining-term" id="the-abbr-element:defining-term">defines the term</a> "Web Hypertext Application
   Technology Working Group".</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The <c- p="">&lt;</c-><c- f="">dfn</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">whatwg</c-><c- p="">&gt;&lt;</c-><c- f="">abbr</c->
<c- e="">title</c-><c- o="">=</c-><c- s="">"Web Hypertext Application Technology Working Group"</c-><c- p="">&gt;</c->WHATWG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c->
is a loose unofficial collaboration of web browser manufacturers and
interested parties who wish to develop new technologies designed to
allow authors to write and deploy Applications over the World Wide
Web.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>An alternative way to write this would be:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The <c- p="">&lt;</c-><c- f="">dfn</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">whatwg</c-><c- p="">&gt;</c->Web Hypertext Application Technology
Working Group<c- p="">&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c-> (<c- p="">&lt;</c-><c- f="">abbr</c->
<c- e="">title</c-><c- o="">=</c-><c- s="">"Web Hypertext Application Technology Working Group"</c-><c- p="">&gt;</c->WHATWG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c->)
is a loose unofficial collaboration of web browser manufacturers and
interested parties who wish to develop new technologies designed to
allow authors to write and deploy Applications over the World Wide
Web.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>This paragraph has two abbreviations. Notice how only one is defined; the other, with no
   expansion associated with it, does not use the <code id="the-abbr-element:the-abbr-element-3"><a href="#the-abbr-element">abbr</a></code> element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The
<c- p="">&lt;</c-><c- f="">abbr</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Web Hypertext Application Technology Working Group"</c-><c- p="">&gt;</c->WHATWG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c->
started working on HTML5 in 2004.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>This paragraph links an abbreviation to its definition.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#whatwg"</c-><c- p="">&gt;&lt;</c-><c- f="">abbr</c->
<c- e="">title</c-><c- o="">=</c-><c- s="">"Web Hypertext Application Technology Working Group"</c-><c- p="">&gt;</c->WHATWG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
community does not have much representation from Asia.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>This paragraph marks up an abbreviation without giving an expansion, possibly as a hook to
   apply styles for abbreviations (e.g. smallcaps).</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Philip` and Dashiva both denied that they were going to
get the issue counts from past revisions of the specification to
backfill the <c- p="">&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->WHATWG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-> issue graph.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>If an abbreviation is pluralized, the expansion's grammatical number (plural vs singular) must
  match the grammatical number of the contents of the element.</p>

  <div class="example">

   <p>Here the plural is outside the element, so the expansion is in the singular:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Two <c- p="">&lt;</c-><c- f="">abbr</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Working Group"</c-><c- p="">&gt;</c->WG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c->s worked on
this specification: the <c- p="">&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->WHATWG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-> and the
<c- p="">&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->HTMLWG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Here the plural is inside the element, so the expansion is in the plural:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Two <c- p="">&lt;</c-><c- f="">abbr</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Working Groups"</c-><c- p="">&gt;</c->WGs<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-> worked on
this specification: the <c- p="">&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->WHATWG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-> and the
<c- p="">&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->HTMLWG<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Abbreviations do not have to be marked up using this element. It is expected to be useful in
  the following cases:</p>

  <ul><li>Abbreviations for which the author wants to give expansions, where using the
   <code id="the-abbr-element:the-abbr-element-4"><a href="#the-abbr-element">abbr</a></code> element with a <code id="the-abbr-element:attr-title"><a href="#attr-title">title</a></code> attribute is an
   alternative to including the expansion inline (e.g. in parentheses).</li><li>Abbreviations that are likely to be unfamiliar to the document's readers, for which authors
   are encouraged to either mark up the abbreviation using an <code id="the-abbr-element:the-abbr-element-5"><a href="#the-abbr-element">abbr</a></code> element with a <code id="the-abbr-element:attr-title-2"><a href="#attr-title">title</a></code> attribute or include the expansion inline in the text the first
   time the abbreviation is used.</li><li>Abbreviations whose presence needs to be semantically annotated, e.g. so that they can be
   identified from a style sheet and given specific styles, for which the <code id="the-abbr-element:the-abbr-element-6"><a href="#the-abbr-element">abbr</a></code> element
   can be used without a <code id="the-abbr-element:attr-title-3"><a href="#attr-title">title</a></code> attribute.</li></ul>

  <p class="note">Providing an expansion in a <code id="the-abbr-element:attr-title-4"><a href="#attr-title">title</a></code> attribute once
  will not necessarily cause other <code id="the-abbr-element:the-abbr-element-7"><a href="#the-abbr-element">abbr</a></code> elements in the same document with the same
  contents but without a <code id="the-abbr-element:attr-title-5"><a href="#attr-title">title</a></code> attribute to behave as if they had
  the same expansion. Every <code id="the-abbr-element:the-abbr-element-8"><a href="#the-abbr-element">abbr</a></code> element is independent.</p>


  <h4 id="the-ruby-element"><span class="secno">4.5.10</span> The <dfn data-dfn-type="element"><code>ruby</code></dfn> element<a href="#the-ruby-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ruby" title="The <ruby> HTML element represents small annotations that are rendered above, below, or next to base text, usually used for showing the pronunciation of East Asian characters. It can also be used for annotating other kinds of text, but this usage is less common.">Element/ruby</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-ruby-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-ruby-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-ruby-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-ruby-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-ruby-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-ruby-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-ruby-element:concept-element-content-model">Content model</a>:</dt><dd>See prose.</dd><dt><a href="#concept-element-tag-omission" id="the-ruby-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-ruby-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-ruby-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-ruby-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-ruby">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-ruby">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-ruby-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-ruby-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-ruby-element:the-ruby-element"><a href="#the-ruby-element">ruby</a></code> element allows one or more spans of phrasing content to be marked with
  ruby annotations. Ruby annotations are short runs of text presented alongside base text, primarily
  used in East Asian typography as a guide for pronunciation or to include other annotations. In
  Japanese, this form of typography is also known as <i>furigana</i>.</p>

  <p>The content model of <code id="the-ruby-element:the-ruby-element-2"><a href="#the-ruby-element">ruby</a></code> elements consists of one or more of the following
  sequences:</p>

  <ol><li>
    <p>One or the other of the following:</p>

    <ul><li><p><a href="#phrasing-content-2" id="the-ruby-element:phrasing-content-2-3">Phrasing content</a>, but with no <code id="the-ruby-element:the-ruby-element-3"><a href="#the-ruby-element">ruby</a></code> elements and with no
     <code id="the-ruby-element:the-ruby-element-4"><a href="#the-ruby-element">ruby</a></code> element descendants</p></li><li><p>A single <code id="the-ruby-element:the-ruby-element-5"><a href="#the-ruby-element">ruby</a></code> element that itself has no <code id="the-ruby-element:the-ruby-element-6"><a href="#the-ruby-element">ruby</a></code> element
     descendants</p></li></ul>
   </li><li>
    <p>One or the other of the following:</p>

    <ul><li><p>One or more <code id="the-ruby-element:the-rt-element"><a href="#the-rt-element">rt</a></code> elements</p>

     </li><li><p>An <code id="the-ruby-element:the-rp-element"><a href="#the-rp-element">rp</a></code> element followed by one or more <code id="the-ruby-element:the-rt-element-2"><a href="#the-rt-element">rt</a></code> elements, each of
     which is itself followed by an <code id="the-ruby-element:the-rp-element-2"><a href="#the-rp-element">rp</a></code> element</p></li></ul>
  </li></ol>

  

  <p>The <code id="the-ruby-element:the-ruby-element-7"><a href="#the-ruby-element">ruby</a></code> and <code id="the-ruby-element:the-rt-element-3"><a href="#the-rt-element">rt</a></code> elements can be used for a variety of kinds of
  annotations, including in particular (though by no means limited to) those described below. For
  more details on Japanese Ruby in particular, and how to render Ruby for Japanese, see
  <cite>Requirements for Japanese Text Layout</cite>. <a href="#refsJLREQ">[JLREQ]</a></p>

  <p class="note">At the time of writing, CSS does not yet provide a way to fully control the
  rendering of the HTML <code id="the-ruby-element:the-ruby-element-8"><a href="#the-ruby-element">ruby</a></code> element. It is hoped that CSS will be extended to support
  the styles described below in due course.</p>

  

  <dl><dt>Mono-ruby for individual base characters in Japanese

   </dt><dd>
    <p>One or more hiragana or katakana characters (the ruby annotation) are placed with each
    ideographic character (the base text). This is used to provide readings of kanji characters.

    </p><div class="example"> 
     <pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->B<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->annotation<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>
    </div>

    <div class="example">
     <p>In this example, notice how each annotation corresponds to a single base character.
     </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->君<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->くん<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->子<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->し<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->は<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->和<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->わ<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->して<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->同<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->どう<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->ぜず。</code></pre>
     <p lang="ja"><ruby>君<rt>くん</rt></ruby><ruby>子<rt>し</rt></ruby>は<ruby>和<rt>わ</rt></ruby>して<ruby>同<rt>どう</rt></ruby>ぜず。
     </p><p>This example can also be written as follows, using one <code id="the-ruby-element:the-ruby-element-9"><a href="#the-ruby-element">ruby</a></code> element with two
     segments of base text and two annotations (one for each) rather than two back-to-back
     <code id="the-ruby-element:the-ruby-element-10"><a href="#the-ruby-element">ruby</a></code> elements each with one base text segment and annotation (as in the markup
     above):
     </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->君<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->くん<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->子<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->し<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->は<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->和<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->わ<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->して<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->同<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->どう<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->ぜず。</code></pre>
    </div>
   </dd><dt>Mono-ruby for compound words (jukugo)

   </dt><dd>
    <p>This is similar to the previous case: each ideographic character in the compound word (the
    base text) has its reading given in hiragana or katakana characters (the ruby annotation). The
    difference is that the base text segments form a compound word rather than being separate from
    each other.

    </p><div class="example"> 
     <pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->B<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->annotation<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->B<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->annotation<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>
    </div>

    <div class="example">
     <p>In this example, notice again how each annotation corresponds to a single base character. In this example, each compound word (jukugo) corresponds to a single <code id="the-ruby-element:the-ruby-element-11"><a href="#the-ruby-element">ruby</a></code> element.</p>
     <p>The rendering here is expected to be that each annotation be placed over (or next to, in vertical text) the corresponding base character, with the annotations not overhanging any of the adjacent characters.</p>
     <pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->鬼<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->き<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->門<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->もん<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->の<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->方<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->ほう<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->角<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->がく<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->を<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->凝<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->ぎょう<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->視<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->し<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->する</code></pre>
     <p lang="ja"><ruby>鬼<rt>き</rt>門<rt>もん</rt></ruby>の<ruby>方<rt>ほう</rt>角<rt>がく</rt></ruby>を<ruby>凝<rt>ぎょう</rt>視<rt>し</rt></ruby>する

    </p></div>
   </dd><dt>Jukugo-ruby

   </dt><dd>
    <p>This is semantically identical to the previous case (each individual ideographic character in
    the base compound word has its reading given in an annotation in hiragana or katakana
    characters), but the rendering is the more complicated Jukugo Ruby rendering.

    </p><div class="example">
     <p>This is the same example as above for mono-ruby for compound words. The different rendering is expected to be achieved using different styling (e.g. in CSS), and is not shown here.</p>
     <pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->鬼<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->き<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->門<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->もん<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->の<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->方<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->ほう<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->角<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->がく<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->を<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->凝<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->ぎょう<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->視<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->し<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->する</code></pre>
     
     
    </div>

    <p class="note">For more details on <a href="https://www.w3.org/TR/jlreq/#positioning_of_jukugoruby">Jukugo Ruby rendering</a>, see
    Appendix F in the <cite>Requirements for Japanese Text Layout</cite>. <a href="#refsJLREQ">[JLREQ]</a></p>
   </dd><dt>Group ruby for describing meanings

   </dt><dd>
    <p>The annotation describes the meaning of the base text, rather than (or in addition to) the
    pronunciation. As such, both the base text and the annotation can be multiple characters long.

    </p><div class="example"> <pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->BASE<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->annotation<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre> </div>

    <div class="example">
     <p>Here a compound ideographic word has its corresponding katakana given as an annotation.
     </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->境界面<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->インターフェース<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>
     <p lang="ja"><ruby>境界面<rt>インターフェース</rt></ruby>
    </p></div>

    <div class="example">
     <p>Here a compound ideographic word has its translation in English provided as an annotation.
     </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"ja"</c-><c- p="">&gt;</c->編集者<c- p="">&lt;</c-><c- f="">rt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->editor<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>
     <p><ruby lang="ja">編集者<rt lang="en">editor</rt></ruby>
    </p></div>
   </dd><dt>Group ruby for Jukuji readings

   </dt><dd>
    <p>A phonetic reading that corresponds to multiple base characters, because a one-to-one mapping
    would be difficult. (In English, the words "Colonel" and "Lieutenant" are examples of words
    where a direct mapping of pronunciation to individual letters is, in some dialects, rather
    unclear.)

    </p><div class="example">
     <p>In this example, the name of a species of flowers has a phonetic reading provided using group ruby:
     </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->紫陽花<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->あじさい<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>
     <p lang="ja"><ruby>紫陽花<rt>あじさい</rt></ruby>
    </p></div>
   </dd><dt>Text with both phonetic and semantic annotations (double-sided ruby)

   </dt><dd>
    <p>Sometimes, ruby styles described above are combined.

    </p><p>If this results in two annotations covering the same single base segment, then the
    annotations can just be placed back to back.

    </p><div class="example">
     <pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->BASE<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->annotation 1<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->annotation 2<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>
    </div>

    <div class="example">
     <pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->B<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->a<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->a<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->A<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->a<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->a<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->S<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->a<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->a<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->E<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->a<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->a<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>
    </div>

    <div class="example">

     <p>In this contrived example, some symbols are given names in English and French.

     </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->
 ♥ <c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c-> Heart <c- p="">&lt;</c-><c- f="">rt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">fr</c-><c- p="">&gt;</c-> Cœur <c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->
 ☘ <c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c-> Shamrock <c- p="">&lt;</c-><c- f="">rt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">fr</c-><c- p="">&gt;</c-> Trèfle <c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->
 ✶ <c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c-> Star <c- p="">&lt;</c-><c- f="">rt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">fr</c-><c- p="">&gt;</c-> Étoile <c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>

    </div>

    <p>In more complicated situations such as the following examples, a nested <code id="the-ruby-element:the-ruby-element-12"><a href="#the-ruby-element">ruby</a></code>
    element is used to give the inner annotations, and then that whole <code id="the-ruby-element:the-ruby-element-13"><a href="#the-ruby-element">ruby</a></code> is then
    given an annotation at the "outer" level.

    </p><div class="example">
     <pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->B<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->a<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->A<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->n<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->S<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->t<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->E<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->n<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->annotation<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>
    </div>

    <div class="example">
     <p>Here both a phonetic reading and the meaning are given in ruby annotations. The annotation on the nested <code id="the-ruby-element:the-ruby-element-14"><a href="#the-ruby-element">ruby</a></code> element gives a mono-ruby phonetic annotation for each base character, while the annotation in the <code id="the-ruby-element:the-rt-element-4"><a href="#the-rt-element">rt</a></code> element that is a child of the outer <code id="the-ruby-element:the-ruby-element-15"><a href="#the-ruby-element">ruby</a></code> element gives the meaning using hiragana.
     </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->東<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->とう<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->南<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->なん<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->たつみ<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->の方角</code></pre>
     <p lang="ja"><ruby><ruby>東<rt>とう</rt>南<rt>なん</rt></ruby><rt>たつみ</rt></ruby>の方角
    </p></div>

    <div class="example">
     <p>This is the same example, but the meaning is given in English instead of Japanese:
     </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->東<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->とう<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->南<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->なん<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en</c-><c- p="">&gt;</c->Southeast<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->の方角</code></pre>
     <p lang="ja"><ruby><ruby>東<rt>とう</rt>南<rt>なん</rt></ruby><rt lang="en">Southeast</rt></ruby>の方角
    </p></div>
   </dd></dl>

  <hr>

  <p>Within a <code id="the-ruby-element:the-ruby-element-16"><a href="#the-ruby-element">ruby</a></code> element that does not have a <code id="the-ruby-element:the-ruby-element-17"><a href="#the-ruby-element">ruby</a></code> element ancestor,
  content is segmented and segments are placed into three categories: base text segments, annotation
  segments, and ignored segments. Ignored segments do not form part of the document's semantics
  (they consist of some <a href="#inter-element-whitespace" id="the-ruby-element:inter-element-whitespace">inter-element whitespace</a> and <code id="the-ruby-element:the-rp-element-3"><a href="#the-rp-element">rp</a></code> elements, the
  latter of which are used for legacy user agents that do not support ruby at all). Base text
  segments can overlap (with a limit of two segments overlapping any one position in the DOM, and
  with any segment having an earlier start point than an overlapping segment also having an equal or
  later end point, and any segment have a later end point than an overlapping segment also having an
  equal or earlier start point). Annotation segments correspond to <code id="the-ruby-element:the-rt-element-5"><a href="#the-rt-element">rt</a></code> elements. Each annotation
  segment can be associated with a base text segment, and each base text segment can have annotation
  segments associated with it. (In a conforming document, each base text segment is associated with
  at least one annotation segment, and each annotation segment is associated with one base text
  segment.) A <code id="the-ruby-element:the-ruby-element-18"><a href="#the-ruby-element">ruby</a></code> element <a href="#represents" id="the-ruby-element:represents">represents</a> the union of the segments of base
  text it contains, along with the mapping from those base text segments to annotation segments.
  Segments are described in terms of DOM ranges; annotation segment ranges always
  consist of exactly one element. <a href="#refsDOM">[DOM]</a></p>

  

  <div data-var-scope="">
  <div data-algorithm="">
  <p>At any particular time, the segmentation and categorization of content of a <code id="the-ruby-element:the-ruby-element-19"><a href="#the-ruby-element">ruby</a></code>
  element is the result that would be obtained from running the following algorithm:</p>

  <ol><li><p>Let <var>base text segments</var> be an empty list of base text segments, each
   potentially with a list of base text subsegments.</p></li><li><p>Let <var>annotation segments</var> be an empty list of annotation segments, each
   potentially being associated with a base text segment or subsegment.</p></li><li><p>Let <var>root</var> be the <code id="the-ruby-element:the-ruby-element-20"><a href="#the-ruby-element">ruby</a></code> element for which the algorithm is
   being run.</p></li><li><p>If <var>root</var> has a <code id="the-ruby-element:the-ruby-element-21"><a href="#the-ruby-element">ruby</a></code> element ancestor, then jump to the
   step labeled <i>end</i>.</p></li><li><p>Let <var>current parent</var> be <var>root</var>.</p></li><li><p>Let <var>index</var> be 0.</p></li><li><p>Let <var>start index</var> be null.</p></li><li><p>Let <var>saved start index</var> be null.</p></li><li><p>Let <var>current base text</var> be null.</p></li><li><p><i>Start mode</i>: If <var>index</var> is greater than or equal to the number of child
   nodes in <var>current parent</var>, then jump to the step labeled <i>end mode</i>.</p>

   </li><li><p>If the <var>index</var>th node in <var>current parent</var> is an
   <code id="the-ruby-element:the-rt-element-6"><a href="#the-rt-element">rt</a></code> or <code id="the-ruby-element:the-rp-element-4"><a href="#the-rp-element">rp</a></code> element, jump to the step labeled <i>annotation
   mode</i>.</p></li><li><p>Set <var>start index</var> to the value of <var>index</var>.</p></li><li><p><i>Base mode</i>: If the <var>index</var>th node in <var>current
   parent</var> is a <code id="the-ruby-element:the-ruby-element-22"><a href="#the-ruby-element">ruby</a></code> element, and if <var>current parent</var> is the
   same element as <var>root</var>, then <a href="#push-a-ruby-level" id="the-ruby-element:push-a-ruby-level">push a ruby level</a> and then jump to
   the step labeled <i>start mode</i>.</p></li><li><p>If the <var>index</var>th node in <var>current parent</var> is an
   <code id="the-ruby-element:the-rt-element-7"><a href="#the-rt-element">rt</a></code> or <code id="the-ruby-element:the-rp-element-5"><a href="#the-rp-element">rp</a></code> element, then <a href="#set-the-current-base-text" id="the-ruby-element:set-the-current-base-text">set the current base text</a> and then
   jump to the step labeled <i>annotation mode</i>.</p></li><li><p>Increment <var>index</var> by one.</p></li><li><p><i>Base mode post-increment</i>: If <var>index</var> is greater than or equal to the
   number of child nodes in <var>current parent</var>, then jump to the step labeled <i>end
   mode</i>.</p></li><li><p>Jump back to the step labeled <i>base mode</i>.</p></li><li><p><i>Annotation mode</i>: If the <var>index</var>th node in <var>current
   parent</var> is an <code id="the-ruby-element:the-rt-element-8"><a href="#the-rt-element">rt</a></code> element, then <a href="#push-a-ruby-annotation" id="the-ruby-element:push-a-ruby-annotation">push a ruby annotation</a> and jump to
   the step labeled <i>annotation mode increment</i>.</p></li><li><p>If the <var>index</var>th node in <var>current parent</var> is an
   <code id="the-ruby-element:the-rp-element-6"><a href="#the-rp-element">rp</a></code> element, jump to the step labeled <i>annotation mode increment</i>.</p></li><li><p>If the <var>index</var>th node in <var>current parent</var> is not a
   <code id="the-ruby-element:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, or is a <code id="the-ruby-element:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node that is not <a href="#inter-element-whitespace" id="the-ruby-element:inter-element-whitespace-2">inter-element
   whitespace</a>, then jump to the step labeled <i>base mode</i>.</p></li><li><p><i>Annotation mode increment</i>: Let <var>lookahead index</var> be <var>index</var> plus one.</p></li><li><p><i>Annotation mode white-space skipper</i>: If <var>lookahead index</var> is
   equal to the number of child nodes in <var>current parent</var> then jump to the step
   labeled <i>end mode</i>.</p></li><li><p>If the <var>lookahead index</var>th node in <var>current parent</var> is
   an <code id="the-ruby-element:the-rt-element-9"><a href="#the-rt-element">rt</a></code> element or an <code id="the-ruby-element:the-rp-element-7"><a href="#the-rp-element">rp</a></code> element, then set <var>index</var> to
   <var>lookahead index</var> and jump to the step labeled <i>annotation mode</i>.</p></li><li><p>If the <var>lookahead index</var>th node in <var>current parent</var> is
   not a <code id="the-ruby-element:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, or is a <code id="the-ruby-element:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node that is not <a href="#inter-element-whitespace" id="the-ruby-element:inter-element-whitespace-3">inter-element
   whitespace</a>, then jump to the step labeled <i>base mode</i> (without further incrementing
   <var>index</var>, so the <a href="#inter-element-whitespace" id="the-ruby-element:inter-element-whitespace-4">inter-element whitespace</a> seen so far becomes part
   of the next base text segment).</p></li><li><p>Increment <var>lookahead index</var> by one.</p></li><li><p>Jump to the step labeled <i>annotation mode white-space skipper</i>.</p></li><li><p><i>End mode</i>: If <var>current parent</var> is not the same element as <var>root</var>, then <a href="#pop-a-ruby-level" id="the-ruby-element:pop-a-ruby-level">pop a ruby level</a> and jump to the step labeled <i>base mode
   post-increment</i>.</p></li><li><p><i>End</i>: Return <var>base text segments</var> and <var>annotation
   segments</var>. Any content of the <code id="the-ruby-element:the-ruby-element-23"><a href="#the-ruby-element">ruby</a></code> element not described by segments in either
   of those lists is implicitly in an <i>ignored segment</i>.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>When the steps above say to <dfn id="set-the-current-base-text">set the current base text</dfn>, it means to run the following
  steps at that point in the algorithm:</p>

  <ol><li><p>Let <var>text range</var> be a DOM range whose <a href="https://dom.spec.whatwg.org/#concept-range-start" id="the-ruby-element:concept-range-start" data-x-internal="concept-range-start">start</a> is the <a href="https://dom.spec.whatwg.org/#concept-range-bp" id="the-ruby-element:concept-range-bp" data-x-internal="concept-range-bp">boundary
   point</a> (<var>current parent</var>, <var>start index</var>) and whose
   <a href="https://dom.spec.whatwg.org/#concept-range-end" id="the-ruby-element:concept-range-end" data-x-internal="concept-range-end">end</a> is the <a href="https://dom.spec.whatwg.org/#concept-range-bp" id="the-ruby-element:concept-range-bp-2" data-x-internal="concept-range-bp">boundary
   point</a> (<var>current parent</var>, <var>index</var>).</p></li><li><p>Let <var>new text segment</var> be a base text segment described by the range
   <var>text range</var>.</p>

   </li><li><p>Add <var>new text segment</var> to <var>base text
   segments</var>.</p></li><li><p>Let <var>current base text</var> be <var>new text
   segment</var>.</p></li><li><p>Let <var>start index</var> be null.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>When the steps above say to <dfn id="push-a-ruby-level">push a ruby level</dfn>, it means to run the following steps
  at that point in the algorithm:</p>

  <ol><li><p>Let <var>current parent</var> be the <var>index</var>th node in <var>current parent</var>.</p></li><li><p>Let <var>index</var> be 0.</p></li><li><p>Set <var>saved start index</var> to the value of <var>start
   index</var>.</p></li><li><p>Let <var>start index</var> be null.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>When the steps above say to <dfn id="pop-a-ruby-level">pop a ruby level</dfn>, it means to run the following steps at
  that point in the algorithm:</p>

  <ol><li><p>Let <var>index</var> be the position of <var>current parent</var> in
   <var>root</var>.</p></li><li><p>Let <var>current parent</var> be <var>root</var>.</p></li><li><p>Increment <var>index</var> by one.</p></li><li><p>Set <var>start index</var> to the value of <var>saved start
   index</var>.</p></li><li><p>Let <var>saved start index</var> be null.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>When the steps above say to <dfn id="push-a-ruby-annotation">push a ruby annotation</dfn>, it means to run the following
  steps at that point in the algorithm:</p>

  <ol><li><p>Let <var>rt</var> be the <code id="the-ruby-element:the-rt-element-10"><a href="#the-rt-element">rt</a></code> element that is the <var>index</var>th node of <var>current parent</var>.</p></li><li><p>Let <var>annotation range</var> be a DOM range whose <a href="https://dom.spec.whatwg.org/#concept-range-start" id="the-ruby-element:concept-range-start-2" data-x-internal="concept-range-start">start</a> is the <a href="https://dom.spec.whatwg.org/#concept-range-bp" id="the-ruby-element:concept-range-bp-3" data-x-internal="concept-range-bp">boundary
   point</a> (<var>current parent</var>, <var>index</var>) and whose <a href="https://dom.spec.whatwg.org/#concept-range-end" id="the-ruby-element:concept-range-end-2" data-x-internal="concept-range-end">end</a> is the <a href="https://dom.spec.whatwg.org/#concept-range-bp" id="the-ruby-element:concept-range-bp-4" data-x-internal="concept-range-bp">boundary point</a>
   (<var>current parent</var>, <var>index</var> plus one) (i.e. that contains only
   <var>rt</var>).</p></li><li><p>Let <var>new annotation segment</var> be an annotation segment described by the
   range <var>annotation range</var>.</p></li><li><p>If <var>current base text</var> is not null, associate <var>new
   annotation segment</var> with <var>current base text</var>.</p></li><li><p>Add <var>new annotation segment</var> to <var>annotation
   segments</var>.</p></li></ol>
  </div>
  </div>

  

  <div class="example">

   
   

   <p>In this example, each ideograph in the Japanese text <span lang="ja">漢字</span> is annotated with its reading in hiragana.</p>

   <pre lang="ja"><code class="html">...
<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->漢<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->かん<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->字<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->じ<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->
...</code></pre>

   <p>This might be rendered as:</p>

   <p><img src="/images/sample-ruby-ja.png" width="171" alt="The two main ideographs, each with its annotation in hiragana rendered in a smaller font above it." height="78"></p>

  </div>

  <div class="example">

   

   <p>In this example, each ideograph in the traditional Chinese text <span lang="zh-TW">漢字</span> is annotated with its bopomofo reading.</p>

   <pre lang="zh-TW"><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->漢<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->ㄏㄢˋ<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->字<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->ㄗˋ<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>

   <p>This might be rendered as:</p>

   <p><img src="/images/sample-ruby-bopomofo.png" width="78" alt="The two main ideographs, each with its bopomofo annotation rendered in a smaller font next to it." height="100"></p>

  </div>

  <div class="example">

   

   <p>In this example, each ideograph in the simplified Chinese text <span lang="zh-CN">汉字</span> is annotated with its pinyin reading.</p>

   <pre lang="zh-CN"><code class="html">...<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->汉<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->hàn<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->字<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->zì<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->...</code></pre>

   <p>This might be rendered as:</p>

   <p><img src="/images/sample-ruby-pinyin.png" width="173" alt="The two main ideographs, each with its pinyin annotation rendered in a smaller font above it." height="79"></p>

  </div>

  

  <div class="example">

   <p>In this more contrived example, the acronym "HTML" has four annotations: one for the whole
   acronym, briefly describing what it is, one for the letters "HT" expanding them to "Hypertext",
   one for the letter "M" expanding it to "Markup", and one for the letter "L" expanding it to
   "Language".</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->HT<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->Hypertext<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->M<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->Markup<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;</c->L<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->Language<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->An abstract language for describing documents and applications
<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-rt-element"><span class="secno">4.5.11</span> The <dfn data-dfn-type="element"><code>rt</code></dfn> element<a href="#the-rt-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/rt" title="The <rt> HTML element specifies the ruby text component of a ruby annotation, which is used to provide pronunciation, translation, or transliteration information for East Asian typography. The <rt> element must always be contained within a <ruby> element.">Element/rt</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie yes"><span>Internet Explorer</span><span>5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-rt-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-rt-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-rt-element:the-ruby-element"><a href="#the-ruby-element">ruby</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-rt-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-rt-element:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-rt-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>An <code id="the-rt-element:the-rt-element"><a href="#the-rt-element">rt</a></code> element's <a href="#syntax-end-tag" id="the-rt-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-rt-element:the-rt-element-2"><a href="#the-rt-element">rt</a></code> element is immediately followed by an <code id="the-rt-element:the-rt-element-3"><a href="#the-rt-element">rt</a></code> or <code id="the-rt-element:the-rp-element"><a href="#the-rp-element">rp</a></code> element,
  or if there is no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-rt-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-rt-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-rt-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-rt">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-rt">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-rt-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-rt-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-rt-element:the-rt-element-4"><a href="#the-rt-element">rt</a></code> element marks the ruby text component of a ruby annotation. When it is the
  child of a <code id="the-rt-element:the-ruby-element-2"><a href="#the-ruby-element">ruby</a></code> element, it doesn't <a href="#represents" id="the-rt-element:represents">represent</a>
  anything itself, but the <code id="the-rt-element:the-ruby-element-3"><a href="#the-ruby-element">ruby</a></code> element uses it as part of determining what <em>it</em>
  <a href="#represents" id="the-rt-element:represents-2">represents</a>.</p>

  

  <p>An <code id="the-rt-element:the-rt-element-5"><a href="#the-rt-element">rt</a></code> element that is not a child of a <code id="the-rt-element:the-ruby-element-4"><a href="#the-ruby-element">ruby</a></code> element
  <a href="#represents" id="the-rt-element:represents-3">represents</a> the same thing as its children.</p>

  


  <h4 id="the-rp-element"><span class="secno">4.5.12</span> The <dfn data-dfn-type="element"><code>rp</code></dfn> element<a href="#the-rp-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/rp" title="The <rp> HTML element is used to provide fall-back parentheses for browsers that do not support display of ruby annotations using the <ruby> element. One <rp> element should enclose each of the opening and closing parentheses that wrap the <rt> element that contains the annotation's text.">Element/rp</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie yes"><span>Internet Explorer</span><span>5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-rp-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-rp-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-rp-element:the-ruby-element"><a href="#the-ruby-element">ruby</a></code> element, either immediately before or immediately after an <code id="the-rp-element:the-rt-element"><a href="#the-rt-element">rt</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-rp-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#text-content" id="the-rp-element:text-content">Text</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-rp-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>An <code id="the-rp-element:the-rp-element"><a href="#the-rp-element">rp</a></code> element's <a href="#syntax-end-tag" id="the-rp-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-rp-element:the-rp-element-2"><a href="#the-rp-element">rp</a></code> element is immediately followed by an <code id="the-rp-element:the-rt-element-2"><a href="#the-rt-element">rt</a></code> or <code id="the-rp-element:the-rp-element-3"><a href="#the-rp-element">rp</a></code> element,
  or if there is no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-rp-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-rp-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-rp-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-rp">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-rp">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-rp-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-rp-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-rp-element:the-rp-element-4"><a href="#the-rp-element">rp</a></code> element can be used to provide parentheses or other content around a ruby
  text component of a ruby annotation, to be shown by user agents that don't support ruby
  annotations.</p>

  <p>An <code id="the-rp-element:the-rp-element-5"><a href="#the-rp-element">rp</a></code> element that is a child of a <code id="the-rp-element:the-ruby-element-2"><a href="#the-ruby-element">ruby</a></code>
  element <a href="#represents" id="the-rp-element:represents">represents</a> nothing. An <code id="the-rp-element:the-rp-element-6"><a href="#the-rp-element">rp</a></code> element
  whose parent element is not a <code id="the-rp-element:the-ruby-element-3"><a href="#the-ruby-element">ruby</a></code> element <a href="#represents" id="the-rp-element:represents-2">represents</a> its
  children.</p>

  <div class="example">

   <p>The example above, in which each ideograph in the text <span lang="ja">漢字</span> is annotated with its phonetic reading, could be expanded to
   use <code id="the-rp-element:the-rp-element-7"><a href="#the-rp-element">rp</a></code> so that in legacy user agents the readings are in parentheses:</p>

   <pre lang="ja"><code class="html">...
<c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->漢<c- p="">&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->（<c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->かん<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->）<c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;</c->字<c- p="">&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->（<c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->じ<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->）<c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c->
...</code></pre>

   <p>In conforming user agents the rendering would be as above, but in user agents that do not
   support ruby, the rendering would be:</p>

   <pre lang="ja">... 漢（かん）字（じ）...</pre>

  </div>

  <div class="example">

   <p>When there are multiple annotations for a segment, <code id="the-rp-element:the-rp-element-8"><a href="#the-rp-element">rp</a></code> elements can also be placed
   between the annotations. Here is another copy of an earlier contrived example showing some
   symbols with names given in English and French, but this time with <code id="the-rp-element:the-rp-element-9"><a href="#the-rp-element">rp</a></code> elements as
   well:

   </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c->
♥<c- p="">&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->: <c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->Heart<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->, <c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">fr</c-><c- p="">&gt;</c->Cœur<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;</c->
☘<c- p="">&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->: <c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->Shamrock<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->, <c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">fr</c-><c- p="">&gt;</c->Trèfle<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;</c->
✶<c- p="">&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->: <c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->Star<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->, <c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;&lt;</c-><c- f="">rt</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">fr</c-><c- p="">&gt;</c->Étoile<c- p="">&lt;/</c-><c- f="">rt</c-><c- p="">&gt;&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">rp</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></code></pre>

   <p>This would make the example render as follows in non-ruby-capable user agents:

   </p><pre>♥: Heart, <span lang="fr">Cœur</span>. ☘: Shamrock, <span lang="fr">Trèfle</span>. ✶: Star, <span lang="fr">Étoile</span>.</pre>

  </div>


  <h4 id="the-data-element"><span class="secno">4.5.13</span> The <dfn data-dfn-type="element"><code>data</code></dfn> element<a href="#the-data-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data" title="The <data> HTML element links a given piece of content with a machine-readable translation. If the content is time- or date-related, the <time> element must be used.">Element/data</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>62+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDataElement" title="The HTMLDataElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <data> elements.">HTMLDataElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>62+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDataElement/value" title="The value property of the HTMLDataElement interface returns a string reflecting the value HTML attribute.">HTMLDataElement/value</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>62+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-data-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-data-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-data-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-data-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-data-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-data-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-data-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-data-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-data-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-data-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-data-element:global-attributes">Global attributes</a></dd><dd><code id="the-data-element:attr-data-value"><a href="#attr-data-value">value</a></code> —  Machine-readable value
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-data-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-data">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-data">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-data-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmldataelement" data-dfn-type="interface"><c- g="">HTMLDataElement</c-></dfn> : <a href="#htmlelement" id="the-data-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-data-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-data-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-data-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLDataElement" id="dom-data-value" data-dfn-type="attribute"><c- g="">value</c-></dfn>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-data-element:the-data-element"><a href="#the-data-element">data</a></code> element <a href="#represents" id="the-data-element:represents">represents</a> its contents, along with a
  machine-readable form of those contents in the <code id="the-data-element:attr-data-value-2"><a href="#attr-data-value">value</a></code>
  attribute.</p>

  <p>The <dfn data-dfn-for="data" id="attr-data-value" data-dfn-type="element-attr"><code>value</code></dfn> attribute
  must be present. Its value must be a representation of the element's contents in a
  machine-readable format.</p>

  <p class="note">When the value is date- or time-related, the more specific <code id="the-data-element:the-time-element"><a href="#the-time-element">time</a></code>
  element can be used instead.</p>

  <p>The element can be used for several purposes.</p>

  <p>When combined with microformats or the <a href="#microdata">microdata attributes</a> defined in
  this specification, the element serves to provide both a machine-readable value for the purposes
  of data processors, and a human-readable value for the purposes of rendering in a web browser. In
  this case, the format to be used in the <code id="the-data-element:attr-data-value-3"><a href="#attr-data-value">value</a></code> attribute is
  determined by the microformats or microdata vocabulary in use.</p>

  <p>The element can also, however, be used in conjunction with scripts in the page, for when a
  script has a literal value to store alongside a human-readable value. In such cases, the format to
  be used depends only on the needs of the script. (The <code id="the-data-element:attr-data-*"><a href="#attr-data-*">data-*</a></code>
  attributes can also be useful in such situations.)</p>

  <div class="example">

   <p>Here, a short table has its numeric values encoded using the <code id="the-data-element:the-data-element-2"><a href="#the-data-element">data</a></code> element so
   that the table sorting JavaScript library can provide a sorting mechanism on each column
   despite the numbers being presented in textual form in one column and in a decomposed form in
   another.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"sortable.js"</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">table</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"sortable"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Game <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Corporations <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Map Size
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 1830 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8"</c-><c- p="">&gt;</c->Eight<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"93"</c-><c- p="">&gt;</c->19+74 hexes (93 total)<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 1856 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"11"</c-><c- p="">&gt;</c->Eleven<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"99"</c-><c- p="">&gt;</c->12+87 hexes (99 total)<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 1870 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"10"</c-><c- p="">&gt;</c->Ten<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"149"</c-><c- p="">&gt;</c->4+145 hexes (149 total)<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

  </div>




  <h4 id="the-time-element"><span class="secno">4.5.14</span> The <dfn data-dfn-type="element"><code>time</code></dfn> element<a href="#the-time-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time" title="The <time> HTML element represents a specific period in time. It may include the datetime attribute to translate dates into machine-readable format, allowing for better search engine results or custom features such as reminders.">Element/time</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>62+</span></span><hr><span class="opera yes"><span>Opera</span><span>49+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>46+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTimeElement" title="The HTMLTimeElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <time> elements.">HTMLTimeElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>62+</span></span><hr><span class="opera yes"><span>Opera</span><span>49+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>46+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTimeElement/dateTime" title="The HTMLTimeElement.dateTime property is a string that reflects the datetime HTML attribute, containing a machine-readable form of the element's date and time value.">HTMLTimeElement/dateTime</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>62+</span></span><hr><span class="opera yes"><span>Opera</span><span>49+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>46+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-time-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-time-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-time-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-time-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-time-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-time-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-time-element:concept-element-content-model">Content model</a>:</dt><dd>If the element has a <code id="the-time-element:attr-time-datetime"><a href="#attr-time-datetime">datetime</a></code> attribute: <a href="#phrasing-content-2" id="the-time-element:phrasing-content-2-3">Phrasing content</a>.</dd><dd>Otherwise: <a href="#text-content" id="the-time-element:text-content">Text</a>, but must match requirements described in prose below.</dd><dt><a href="#concept-element-tag-omission" id="the-time-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-time-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-time-element:global-attributes">Global attributes</a></dd><dd><code id="the-time-element:attr-time-datetime-2"><a href="#attr-time-datetime">datetime</a></code> —  Machine-readable value
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-time-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-time">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-time">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-time-element:concept-element-dom">DOM interface</a>:</dt><dd>
<pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltimeelement" data-dfn-type="interface"><c- g="">HTMLTimeElement</c-></dfn> : <a href="#htmlelement" id="the-time-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-time-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-time-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-time-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTimeElement" id="dom-time-datetime" data-dfn-type="attribute"><c- g="">dateTime</c-></dfn>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-time-element:the-time-element"><a href="#the-time-element">time</a></code> element <a href="#represents" id="the-time-element:represents">represents</a> its contents, along with a
  machine-readable form of those contents in the <code id="the-time-element:attr-time-datetime-3"><a href="#attr-time-datetime">datetime</a></code>
  attribute. The kind of content is limited to various kinds of dates, times, time-zone offsets, and
  durations, as described below.</p>

  <p>The <dfn data-dfn-for="time" id="attr-time-datetime" data-dfn-type="element-attr"><code>datetime</code></dfn>
  attribute may be present. If present, its value must be a representation of the element's contents
  in a machine-readable format.</p>

  <p>A <code id="the-time-element:the-time-element-2"><a href="#the-time-element">time</a></code> element that does not have a <code id="the-time-element:attr-time-datetime-4"><a href="#attr-time-datetime">datetime</a></code> content attribute must not have any element
  descendants.</p>

  <div data-algorithm="">
  <p>The <dfn id="datetime-value">datetime value</dfn> of a <code id="the-time-element:the-time-element-3"><a href="#the-time-element">time</a></code> element is the value of the element's
  <code id="the-time-element:attr-time-datetime-5"><a href="#attr-time-datetime">datetime</a></code> content attribute, if it has one, otherwise the
  <a id="the-time-element:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> of the <code id="the-time-element:the-time-element-4"><a href="#the-time-element">time</a></code> element.</p>
  </div>

  <p>The <a href="#datetime-value" id="the-time-element:datetime-value">datetime value</a> of a <code id="the-time-element:the-time-element-5"><a href="#the-time-element">time</a></code> element must match one of the following
  syntaxes.</p>

  <dl><dt>A <a href="#valid-month-string" id="the-time-element:valid-month-string">valid month string</a></dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
   </dd><dt>A <a href="#valid-date-string" id="the-time-element:valid-date-string">valid date string</a></dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
   </dd><dt>A <a href="#valid-yearless-date-string" id="the-time-element:valid-yearless-date-string">valid yearless date string</a></dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->11-18<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
   </dd><dt>A <a href="#valid-time-string" id="the-time-element:valid-time-string">valid time string</a></dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->14:54<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->14:54:39<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->14:54:39.929<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
   </dd><dt>A <a href="#valid-local-date-and-time-string" id="the-time-element:valid-local-date-and-time-string">valid local date and time string</a></dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54:39<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54:39.929<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54:39<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54:39.929<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <p class="note">Times with dates but without a time zone offset are useful for specifying events
    that are observed at the same specific time in each time zone, throughout a day. For example,
    the 2020 new year is celebrated at 2020-01-01 00:00 in each time zone, not at the same precise
    moment across all time zones. For events that occur at the same time across all time zones, for
    example a videoconference meeting, a <a href="#valid-global-date-and-time-string" id="the-time-element:valid-global-date-and-time-string">valid global date and time string</a> is likely
    more useful.</p>
   </dd><dt>A <a href="#valid-time-zone-offset-string" id="the-time-element:valid-time-zone-offset-string">valid time-zone offset string</a></dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->Z<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->+0000<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->+00:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->-0800<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->-08:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <p class="note">For times without dates (or times referring to events that recur on multiple
    dates), specifying the geographic location that controls the time is usually more useful than
    specifying a time zone offset, because geographic locations change time zone offsets with
    daylight saving time. In some cases, geographic locations even change time zone, e.g. when the
    boundaries of those time zones are redrawn, as happened with Samoa at the end of 2011. There
    exists a time zone database that describes the boundaries of time zones and what rules apply
    within each such zone, known as the <i>time zone database</i>. <a href="#refsTZDATABASE">[TZDATABASE]</a></p>
   </dd><dt>A <a href="#valid-global-date-and-time-string" id="the-time-element:valid-global-date-and-time-string-2">valid global date and time string</a></dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54Z<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54:39Z<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54:39.929Z<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54+0000<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54:39+0000<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54:39.929+0000<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54+00:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54:39+00:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T14:54:39.929+00:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T06:54-0800<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T06:54:39-0800<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T06:54:39.929-0800<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T06:54-08:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T06:54:39-08:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18T06:54:39.929-08:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54Z<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54:39Z<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54:39.929Z<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54+0000<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54:39+0000<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54:39.929+0000<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54+00:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54:39+00:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 14:54:39.929+00:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 06:54-0800<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 06:54:39-0800<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 06:54:39.929-0800<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 06:54-08:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 06:54:39-08:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-11-18 06:54:39.929-08:00<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <p class="note">Times with dates and a time zone offset are useful for specifying specific
    events, or recurring virtual events where the time is not anchored to a specific geographic
    location. For example, the precise time of an asteroid impact, or a particular meeting in a
    series of meetings held at 1400 UTC every day, regardless of whether any particular part of the
    world is observing daylight saving time or not. For events where the precise time varies by the
    local time zone offset of a specific geographic location, a <a href="#valid-local-date-and-time-string" id="the-time-element:valid-local-date-and-time-string-2">valid local date and time
    string</a> combined with that geographic location is likely more useful.</p>
   </dd><dt>A <a href="#valid-week-string" id="the-time-element:valid-week-string">valid week string</a></dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011-W47<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
   </dd><dt>Four or more <a id="the-time-element:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, at least one of which is not U+0030 DIGIT ZERO (0)</dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->2011<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->0001<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
   </dd><dt>A <a href="#valid-duration-string" id="the-time-element:valid-duration-string">valid duration string</a></dt><dd>
    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->PT4H18M3S<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>

    <pre class="example"><code class="html"><c- p="">&lt;</c-><c- f="">time</c-><c- p="">&gt;</c->4h 18m 3s<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></code></pre>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn id="machine-readable-equivalent-of-the-element's-contents">machine-readable equivalent of the element's contents</dfn> must be obtained from the
  element's <a href="#datetime-value" id="the-time-element:datetime-value-2">datetime value</a> by using the following algorithm:</p>

  <ol><li><p>If <a href="#parse-a-month-string" id="the-time-element:parse-a-month-string">parsing a month string</a> from the element's
   <a href="#datetime-value" id="the-time-element:datetime-value-3">datetime value</a> returns a <a href="#concept-month" id="the-time-element:concept-month">month</a>, that is the
   machine-readable equivalent; return.</p></li><li><p>If <a href="#parse-a-date-string" id="the-time-element:parse-a-date-string">parsing a date string</a> from the element's
   <a href="#datetime-value" id="the-time-element:datetime-value-4">datetime value</a> returns a <a href="#concept-date" id="the-time-element:concept-date">date</a>, that is the
   machine-readable equivalent; return.</p></li><li><p>If <a href="#parse-a-yearless-date-string" id="the-time-element:parse-a-yearless-date-string">parsing a yearless date string</a> from
   the element's <a href="#datetime-value" id="the-time-element:datetime-value-5">datetime value</a> returns a <a href="#concept-yearless-date" id="the-time-element:concept-yearless-date">yearless
   date</a>, that is the machine-readable equivalent; return.</p></li><li><p>If <a href="#parse-a-time-string" id="the-time-element:parse-a-time-string">parsing a time string</a> from the element's
   <a href="#datetime-value" id="the-time-element:datetime-value-6">datetime value</a> returns a <a href="#concept-time" id="the-time-element:concept-time">time</a>, that is the
   machine-readable equivalent; return.</p></li><li><p>If <a href="#parse-a-local-date-and-time-string" id="the-time-element:parse-a-local-date-and-time-string">parsing a local date and time
   string</a> from the element's <a href="#datetime-value" id="the-time-element:datetime-value-7">datetime value</a> returns a <a href="#concept-datetime-local" id="the-time-element:concept-datetime-local">local date and time</a>, that is the machine-readable
   equivalent; return.</p></li><li><p>If <a href="#parse-a-time-zone-offset-string" id="the-time-element:parse-a-time-zone-offset-string">parsing a time-zone offset string</a>
   from the element's <a href="#datetime-value" id="the-time-element:datetime-value-8">datetime value</a> returns a <a href="#concept-timezone" id="the-time-element:concept-timezone">time-zone
   offset</a>, that is the machine-readable equivalent; return.</p></li><li><p>If <a href="#parse-a-global-date-and-time-string" id="the-time-element:parse-a-global-date-and-time-string">parsing a global date and time
   string</a> from the element's <a href="#datetime-value" id="the-time-element:datetime-value-9">datetime value</a> returns a <a href="#concept-datetime" id="the-time-element:concept-datetime">global date and time</a>, that is the machine-readable equivalent;
   return.</p></li><li><p>If <a href="#parse-a-week-string" id="the-time-element:parse-a-week-string">parsing a week string</a> from the element's
   <a href="#datetime-value" id="the-time-element:datetime-value-10">datetime value</a> returns a <a href="#concept-week" id="the-time-element:concept-week">week</a>, that is the
   machine-readable equivalent; return.</p></li><li><p>If the element's <a href="#datetime-value" id="the-time-element:datetime-value-11">datetime value</a> consists of only <a id="the-time-element:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>,
   at least one of which is not U+0030 DIGIT ZERO (0), then the machine-readable equivalent is the
   base-ten interpretation of those digits, representing a year; return.</p></li><li><p>If <a href="#parse-a-duration-string" id="the-time-element:parse-a-duration-string">parsing a duration string</a> from the
   element's <a href="#datetime-value" id="the-time-element:datetime-value-12">datetime value</a> returns a <a href="#concept-duration" id="the-time-element:concept-duration">duration</a>,
   that is the machine-readable equivalent; return.</p></li><li><p>There is no machine-readable equivalent.</p></li></ol>
  </div>

  <p data-var-scope="" class="note">The algorithms referenced above are intended to be designed such that for any
  arbitrary string <var>s</var>, only one of the algorithms returns a value. A more
  efficient approach might be to create a single algorithm that parses all these data types in one
  pass; developing such an algorithm is left as an exercise to the reader.</p>

  

  <div class="example">

   <p>The <code id="the-time-element:the-time-element-6"><a href="#the-time-element">time</a></code> element can be used to encode dates, for example in microformats. The
   following shows a hypothetical way of encoding an event using a variant on hCalendar that uses
   the <code id="the-time-element:the-time-element-7"><a href="#the-time-element">time</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"vevent"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"http://www.web2con.com/"</c-><c- p="">&gt;</c->http://www.web2con.com/<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"summary"</c-><c- p="">&gt;</c->Web 2.0 Conference<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->:
 <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"dtstart"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2005-10-05"</c-><c- p="">&gt;</c->October 5<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-> -
 <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"dtend"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2005-10-07"</c-><c- p="">&gt;</c->7<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->,
 at the <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"location"</c-><c- p="">&gt;</c->Argent Hotel, San Francisco, CA<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Here, a fictional microdata vocabulary based on the Atom vocabulary is used with the
   <code id="the-time-element:the-time-element-8"><a href="#the-time-element">time</a></code> element to mark up a blog post's publication date.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"https://n.example.org/rfc4287"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"title"</c-><c- p="">&gt;</c->Big tasks<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->Published <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"published"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-08-29"</c-><c- p="">&gt;</c->two days ago<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"content"</c-><c- p="">&gt;</c->Today, I went out and bought a bike for my kid.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In this example, another article's publication date is marked up using <code id="the-time-element:the-time-element-9"><a href="#the-time-element">time</a></code>, this
   time using the schema.org microdata vocabulary:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/BlogPosting"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"headline"</c-><c- p="">&gt;</c->Small tasks<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->Published <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"datePublished"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-08-30"</c-><c- p="">&gt;</c->yesterday<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"articleBody"</c-><c- p="">&gt;</c->I put a bike bell on her bike.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following snippet, the <code id="the-time-element:the-time-element-10"><a href="#the-time-element">time</a></code> element is used to encode a date in the
   ISO8601 format, for later processing by a script:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Our first date was <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2006-09-23"</c-><c- p="">&gt;</c->a Saturday<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>In this second snippet, the value includes a time:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->We stopped talking at <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2006-09-24T05:00-07:00"</c-><c- p="">&gt;</c->5am the next morning<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>A script loaded by the page (and thus privy to the page's internal convention of marking up
   dates and times using the <code id="the-time-element:the-time-element-11"><a href="#the-time-element">time</a></code> element) could scan through the page and look at all
   the <code id="the-time-element:the-time-element-12"><a href="#the-time-element">time</a></code> elements therein to create an index of dates and times.</p>

  </div>

  <div class="example">

   <p>For example, this element conveys the string "Friday" with the additional semantic that the
   18th of November 2011 is the meaning that corresponds to "Friday":</p>

   <pre><code class="html">Today is <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2011-11-18"</c-><c- p="">&gt;</c->Friday<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->.</code></pre>

  </div>

  <div class="example">

   <p>In this example, a specific time in the Pacific Standard Time timezone is specified:</p>

   <pre><code class="html">Your next meeting is at <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2011-11-18T15:00-08:00"</c-><c- p="">&gt;</c->3pm<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->.</code></pre>

  </div>




  <h4 id="the-code-element"><span class="secno">4.5.15</span> The <dfn data-dfn-type="element"><code>code</code></dfn> element<a href="#the-code-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code" title="The <code> HTML element displays its contents styled in a fashion intended to indicate that the text is a short fragment of computer code. By default, the content text is displayed using the user agent's default monospace font.">Element/code</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-code-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-code-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-code-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-code-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-code-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-code-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-code-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-code-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-code-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-code-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-code-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-code-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-code">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-code">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-code-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-code-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-code-element:the-code-element"><a href="#the-code-element">code</a></code> element <a href="#represents" id="the-code-element:represents">represents</a> a fragment of computer code. This could
  be an XML element name, a filename, a computer program, or any other string that a computer would
  recognize.</p>

  <p>There is no formal way to indicate the language of computer code being marked up. Authors who
  wish to mark <code id="the-code-element:the-code-element-2"><a href="#the-code-element">code</a></code> elements with the language used, e.g. so that syntax highlighting
  scripts can use the right rules, can use the <code id="the-code-element:classes"><a href="#classes">class</a></code> attribute, e.g.
  by adding a class prefixed with "<code>language-</code>" to the element.</p>

  <div class="example">

   <p>The following example shows how the element can be used in a paragraph to mark up element
   names and computer code, including punctuation.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The <c- p="">&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->code<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c-> element represents a fragment of computer
code.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->When you call the <c- p="">&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->activate()<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c-> method on the
<c- p="">&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->robotSnowman<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c-> object, the eyes glow.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The example below uses the <c- p="">&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->begin<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c-> keyword to indicate
the start of a statement block. It is paired with an <c- p="">&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->end<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c->
keyword, which is followed by the <c- p="">&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c-> punctuation character
(full stop) to indicate the end of the program.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The following example shows how a block of code could be marked up using the <code id="the-code-element:the-pre-element"><a href="#the-pre-element">pre</a></code>
   and <code id="the-code-element:the-code-element-3"><a href="#the-code-element">code</a></code> elements.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;&lt;</c-><c- f="">code</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"language-pascal"</c-><c- p="">&gt;</c->var i: Integer;
begin
   i := 1;
end.<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

   <p>A class is used in that example to indicate the language used.</p>

  </div>

  <p class="note">See the <code id="the-code-element:the-pre-element-2"><a href="#the-pre-element">pre</a></code> element for more details.</p>


  <h4 id="the-var-element"><span class="secno">4.5.16</span> The <dfn data-dfn-type="element"><code>var</code></dfn> element<a href="#the-var-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/var" title="The <var> HTML element represents the name of a variable in a mathematical expression or a programming context. It's typically presented using an italicized version of the current typeface, although that behavior is browser-dependent.">Element/var</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-var-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-var-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-var-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-var-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-var-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-var-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-var-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-var-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-var-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-var-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-var-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-var-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-var">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-var">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-var-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-var-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-var-element:the-var-element"><a href="#the-var-element">var</a></code> element <a href="#represents" id="the-var-element:represents">represents</a> a variable. This could be an actual
  variable in a mathematical expression or programming context, an identifier representing a
  constant, a symbol identifying a physical quantity, a function parameter, or just be a term used
  as a placeholder in prose.</p>

  <div class="example">
   <p>In the paragraph below, the letter "n" is being used as a
   variable in prose:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If there are <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->n<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c-> pipes leading to the ice
cream factory then I expect at <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->least<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->n<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->
flavors of ice cream to be available for purchase!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>For mathematics, in particular for anything beyond the simplest of expressions, MathML is more
  appropriate. However, the <code id="the-var-element:the-var-element-2"><a href="#the-var-element">var</a></code> element can still be used to refer to specific
  variables that are then mentioned in MathML expressions.</p>

  <div class="example">

   <p>In this example, an equation is shown, with a legend that references the variables in the
   equation. The expression itself is marked up with MathML, but the variables are mentioned in the
   figure's legend using <code id="the-var-element:the-var-element-3"><a href="#the-var-element">var</a></code>.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">math</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->a<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">mo</c-><c- p="">&gt;</c->=<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">msqrt</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">msup</c-><c- p="">&gt;&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->b<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;&lt;</c-><c- f="">mn</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">mn</c-><c- p="">&gt;&lt;/</c-><c- f="">msup</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->+<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">msup</c-><c- p="">&gt;&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->c<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;&lt;</c-><c- f="">mn</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">mn</c-><c- p="">&gt;&lt;/</c-><c- f="">msup</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">msqrt</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">math</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
  Using Pythagoras' theorem to solve for the hypotenuse <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->a<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c-> of
  a triangle with sides <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->b<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c-> and <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->c<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Here, the equation describing mass-energy equivalence is used in a sentence, and the
   <code id="the-var-element:the-var-element-4"><a href="#the-var-element">var</a></code> element is used to mark the variables and constants in that equation:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Then she turned to the blackboard and picked up the chalk. After a few moment's
thought, she wrote <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->E<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c-> = <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->m<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->c<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;&lt;</c-><c- f="">sup</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">sup</c-><c- p="">&gt;</c->. The teacher
looked pleased.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-samp-element"><span class="secno">4.5.17</span> The <dfn data-dfn-type="element"><code>samp</code></dfn> element<a href="#the-samp-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/samp" title="The <samp> HTML element is used to enclose inline text which represents sample (or quoted) output from a computer program. Its contents are typically rendered using the browser's default monospaced font (such as Courier or Lucida Console).">Element/samp</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-samp-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-samp-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-samp-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-samp-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-samp-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-samp-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-samp-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-samp-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-samp-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-samp-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-samp-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-samp-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-samp">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-samp">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-samp-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-samp-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-samp-element:the-samp-element"><a href="#the-samp-element">samp</a></code> element <a href="#represents" id="the-samp-element:represents">represents</a> sample or quoted output from another
  program or computing system.</p>

  <p class="note">See the <code id="the-samp-element:the-pre-element"><a href="#the-pre-element">pre</a></code> and <code id="the-samp-element:the-kbd-element"><a href="#the-kbd-element">kbd</a></code> elements for more details.</p>

  <p class="note">This element can be contrasted with the <code id="the-samp-element:the-output-element"><a href="#the-output-element">output</a></code> element, which can be
  used to provide immediate output in a web application.</p>

  <div class="example">
   <p>This example shows the <code id="the-samp-element:the-samp-element-2"><a href="#the-samp-element">samp</a></code> element being used
   inline:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The computer said <c- p="">&lt;</c-><c- f="">samp</c-><c- p="">&gt;</c->Too much cheese in tray
two<c- p="">&lt;/</c-><c- f="">samp</c-><c- p="">&gt;</c-> but I didn't know what that meant.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">

   <p>This second example shows a block of sample output from a console program. Nested
   <code id="the-samp-element:the-samp-element-3"><a href="#the-samp-element">samp</a></code> and <code id="the-samp-element:the-kbd-element-2"><a href="#the-kbd-element">kbd</a></code> elements allow for the styling of specific elements
   of the sample output using a style sheet. There's also a few parts of the <code id="the-samp-element:the-samp-element-4"><a href="#the-samp-element">samp</a></code> that
   are annotated with even more detailed markup, to enable very precise styling. To achieve this,
   <code id="the-samp-element:the-span-element"><a href="#the-span-element">span</a></code> elements are used.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;&lt;</c-><c- f="">samp</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"prompt"</c-><c- p="">&gt;</c->jdoe@mowmow:~$<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">kbd</c-><c- p="">&gt;</c->ssh demo.example.com<c- p="">&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;</c->
Last login: Tue Apr 12 09:10:17 2005 from mowmow.example.com on pts/1
Linux demo 2.6.10-grsec+gg3+e+fhs6b+nfs+gr0501+++p3+c4a+gr2b-reslog-v6.189 #1 SMP Tue Feb 1 11:22:36 PST 2005 i686 unknown

<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"prompt"</c-><c- p="">&gt;</c->jdoe@demo:~$<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"cursor"</c-><c- p="">&gt;</c->_<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">samp</c-><c- p="">&gt;&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>This third example shows a block of input and its respective output. The example uses
   both <code id="the-samp-element:the-code-element"><a href="#the-code-element">code</a></code> and <code id="the-samp-element:the-samp-element-5"><a href="#the-samp-element">samp</a></code> elements.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">code</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"language-javascript"</c-><c- p="">&gt;</c->console.log(2.3 + 2.4)<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">samp</c-><c- p="">&gt;</c->4.699999999999999<c- p="">&lt;/</c-><c- f="">samp</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-kbd-element"><span class="secno">4.5.18</span> The <dfn data-dfn-type="element"><code>kbd</code></dfn> element<a href="#the-kbd-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd" title="The <kbd> HTML element represents a span of inline text denoting textual user input from a keyboard, voice input, or any other text entry device. By convention, the user agent defaults to rendering the contents of a <kbd> element using its default monospace font, although this is not mandated by the HTML standard.">Element/kbd</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-kbd-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-kbd-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-kbd-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-kbd-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-kbd-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-kbd-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-kbd-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-kbd-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-kbd-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-kbd-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-kbd-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-kbd-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-kbd">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-kbd">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-kbd-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-kbd-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-kbd-element:the-kbd-element"><a href="#the-kbd-element">kbd</a></code> element <a href="#represents" id="the-kbd-element:represents">represents</a> user input (typically keyboard input,
  although it may also be used to represent other input, such as voice commands).</p>

  <p>When the <code id="the-kbd-element:the-kbd-element-2"><a href="#the-kbd-element">kbd</a></code> element is nested inside a <code id="the-kbd-element:the-samp-element"><a href="#the-samp-element">samp</a></code> element, it represents
  the input as it was echoed by the system.</p>

  <p>When the <code id="the-kbd-element:the-kbd-element-3"><a href="#the-kbd-element">kbd</a></code> element <em>contains</em> a <code id="the-kbd-element:the-samp-element-2"><a href="#the-samp-element">samp</a></code> element, it represents
  input based on system output, for example invoking a menu item.</p>

  <p>When the <code id="the-kbd-element:the-kbd-element-4"><a href="#the-kbd-element">kbd</a></code> element is nested inside another <code id="the-kbd-element:the-kbd-element-5"><a href="#the-kbd-element">kbd</a></code> element, it
  represents an actual key or other single unit of input as appropriate for the input mechanism.</p>

  <div class="example">

   <p>Here the <code id="the-kbd-element:the-kbd-element-6"><a href="#the-kbd-element">kbd</a></code> element is used to indicate keys to press:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->To make George eat an apple, press <c- p="">&lt;</c-><c- f="">kbd</c-><c- p="">&gt;&lt;</c-><c- f="">kbd</c-><c- p="">&gt;</c->Shift<c- p="">&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;</c-> + <c- p="">&lt;</c-><c- f="">kbd</c-><c- p="">&gt;</c->F3<c- p="">&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>In this second example, the user is told to pick a particular menu item. The outer
   <code id="the-kbd-element:the-kbd-element-7"><a href="#the-kbd-element">kbd</a></code> element marks up a block of input, with the inner <code id="the-kbd-element:the-kbd-element-8"><a href="#the-kbd-element">kbd</a></code> elements
   representing each individual step of the input, and the <code id="the-kbd-element:the-samp-element-3"><a href="#the-samp-element">samp</a></code> elements inside them
   indicating that the steps are input based on something being displayed by the system, in this
   case menu labels:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->To make George eat an apple, select
    <c- p="">&lt;</c-><c- f="">kbd</c-><c- p="">&gt;&lt;</c-><c- f="">kbd</c-><c- p="">&gt;&lt;</c-><c- f="">samp</c-><c- p="">&gt;</c->File<c- p="">&lt;/</c-><c- f="">samp</c-><c- p="">&gt;&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;</c->|<c- p="">&lt;</c-><c- f="">kbd</c-><c- p="">&gt;&lt;</c-><c- f="">samp</c-><c- p="">&gt;</c->Eat Apple...<c- p="">&lt;/</c-><c- f="">samp</c-><c- p="">&gt;&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Such precision isn't necessary; the following is equally fine:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->To make George eat an apple, select <c- p="">&lt;</c-><c- f="">kbd</c-><c- p="">&gt;</c->File | Eat Apple...<c- p="">&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-sub-and-sup-elements"><span class="secno">4.5.19</span> The <dfn id="the-sub-element" data-dfn-type="element"><code>sub</code></dfn> and <dfn id="the-sup-element" data-dfn-type="element"><code>sup</code></dfn> elements<a href="#the-sub-and-sup-elements" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub" title="The <sub> HTML element specifies inline text which should be displayed as subscript for solely typographical reasons. Subscripts are typically rendered with a lowered baseline using smaller text.">Element/sub</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup" title="The <sup> HTML element specifies inline text which is to be displayed as superscript for solely typographical reasons. Superscripts are usually rendered with a raised baseline using smaller text.">Element/sup</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-sub-and-sup-elements:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-sub-and-sup-elements:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-sub-and-sup-elements:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-sub-and-sup-elements:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-sub-and-sup-elements:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-sub-and-sup-elements:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-sub-and-sup-elements:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-sub-and-sup-elements:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-sub-and-sup-elements:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-sub-and-sup-elements:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-sub-and-sup-elements:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-sub-and-sup-elements:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd>The <code id="the-sub-and-sup-elements:the-sub-and-sup-elements"><a href="#the-sub-and-sup-elements">sub</a></code> element: <a href="https://w3c.github.io/html-aria/#el-sub">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-sub">for implementers</a>.</dd><dd>The <code id="the-sub-and-sup-elements:the-sub-and-sup-elements-2"><a href="#the-sub-and-sup-elements">sup</a></code> element: <a href="https://w3c.github.io/html-aria/#el-sup">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-sup">for implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-sub-and-sup-elements:concept-element-dom">DOM interface</a>:</dt><dd>Use <code id="the-sub-and-sup-elements:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-sub-and-sup-elements:the-sub-and-sup-elements-3"><a href="#the-sub-and-sup-elements">sup</a></code> element <a href="#represents" id="the-sub-and-sup-elements:represents">represents</a> a superscript and the <code id="the-sub-and-sup-elements:the-sub-and-sup-elements-4"><a href="#the-sub-and-sup-elements">sub</a></code>
  element <a href="#represents" id="the-sub-and-sup-elements:represents-2">represents</a> a subscript.</p>

  <p>These elements must be used only to mark up typographical conventions with specific meanings,
  not for typographical presentation for presentation's sake. For example, it would be inappropriate
  for the <code id="the-sub-and-sup-elements:the-sub-and-sup-elements-5"><a href="#the-sub-and-sup-elements">sub</a></code> and <code id="the-sub-and-sup-elements:the-sub-and-sup-elements-6"><a href="#the-sub-and-sup-elements">sup</a></code> elements to be used in the name of the LaTeX
  document preparation system. In general, authors should use these elements only if the
  <em>absence</em> of those elements would change the meaning of the content.</p>

  <p>In certain languages, superscripts are part of the typographical conventions for some
  abbreviations.</p>

  <div class="example">
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Their names are
<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"fr"</c-><c- p="">&gt;&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->M<c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;</c->lle<c- p="">&lt;/</c-><c- f="">sup</c-><c- p="">&gt;&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-> Gwendoline<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> and
<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"fr"</c-><c- p="">&gt;&lt;</c-><c- f="">abbr</c-><c- p="">&gt;</c->M<c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;</c->me<c- p="">&lt;/</c-><c- f="">sup</c-><c- p="">&gt;&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-> Denise<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>The <code id="the-sub-and-sup-elements:the-sub-and-sup-elements-7"><a href="#the-sub-and-sup-elements">sub</a></code> element can be used inside a <code id="the-sub-and-sup-elements:the-var-element"><a href="#the-var-element">var</a></code> element, for variables that
  have subscripts.</p>

  <div class="example">

   <p>Here, the <code id="the-sub-and-sup-elements:the-sub-and-sup-elements-8"><a href="#the-sub-and-sup-elements">sub</a></code> element is used to represent the subscript that identifies the
   variable in a family of variables:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The coordinate of the <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->i<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->th point is
(<c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->x<c- p="">&lt;</c-><c- f="">sub</c-><c- p="">&gt;&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->i<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;&lt;/</c-><c- f="">sub</c-><c- p="">&gt;&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->, <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->y<c- p="">&lt;</c-><c- f="">sub</c-><c- p="">&gt;&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->i<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;&lt;/</c-><c- f="">sub</c-><c- p="">&gt;&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->).
For example, the 10th point has coordinate
(<c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->x<c- p="">&lt;</c-><c- f="">sub</c-><c- p="">&gt;</c->10<c- p="">&lt;/</c-><c- f="">sub</c-><c- p="">&gt;&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->, <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->y<c- p="">&lt;</c-><c- f="">sub</c-><c- p="">&gt;</c->10<c- p="">&lt;/</c-><c- f="">sub</c-><c- p="">&gt;&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->).<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>Mathematical expressions often use subscripts and superscripts. Authors are encouraged to use
  MathML for marking up mathematics, but authors may opt to use <code id="the-sub-and-sup-elements:the-sub-and-sup-elements-9"><a href="#the-sub-and-sup-elements">sub</a></code> and
  <code id="the-sub-and-sup-elements:the-sub-and-sup-elements-10"><a href="#the-sub-and-sup-elements">sup</a></code> if detailed mathematical markup is not desired. <a href="#refsMATHML">[MATHML]</a></p>

  <div class="example">
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->E<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->=<c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->m<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->c<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;&lt;</c-><c- f="">sup</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">sup</c-><c- p="">&gt;</c-></code></pre>
   <pre><code class="html">f(<c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->x<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->, <c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->n<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c->) = log<c- p="">&lt;</c-><c- f="">sub</c-><c- p="">&gt;</c->4<c- p="">&lt;/</c-><c- f="">sub</c-><c- p="">&gt;&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->x<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;&lt;</c-><c- f="">sup</c-><c- p="">&gt;&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->n<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;&lt;/</c-><c- f="">sup</c-><c- p="">&gt;</c-></code></pre>
  </div>



  <h4 id="the-i-element"><span class="secno">4.5.20</span> The <dfn data-dfn-type="element"><code>i</code></dfn> element<a href="#the-i-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i" title="The <i> HTML element represents a range of text that is set off from the normal text for some reason, such as idiomatic text, technical terms, taxonomical designations, among others. Historically, these have been presented using italicized type, which is the original source of the <i> naming of this element.">Element/i</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-i-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-i-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-i-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-i-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-i-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-i-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-i-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-i-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-i-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-i-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-i-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-i-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-i">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-i">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-i-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-i-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-i-element:the-i-element"><a href="#the-i-element">i</a></code> element <a href="#represents" id="the-i-element:represents">represents</a> a span of text in an alternate voice or
  mood, or otherwise offset from the normal prose in a manner indicating a different quality of
  text, such as a taxonomic designation, a technical term, an idiomatic phrase from another
  language, transliteration, a thought, or a ship name in Western texts.</p>

  <p>Terms in languages different from the main text should be annotated with <code id="the-i-element:attr-lang"><a href="#attr-lang">lang</a></code> attributes (or, in XML, <a href="https://www.w3.org/TR/xml/#sec-lang-tag" id="the-i-element:attr-xml-lang" data-x-internal="attr-xml-lang"><code>lang</code> attributes in the <span>XML namespace</span></a>).</p>

  <div class="example">
   <p>The examples below show uses of the <code id="the-i-element:the-i-element-2"><a href="#the-i-element">i</a></code> element:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The <c- p="">&lt;</c-><c- f="">i</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"taxonomy"</c-><c- p="">&gt;</c->Felis silvestris catus<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c-> is cute.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The term <c- p="">&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->prose content<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c-> is defined above.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->There is a certain <c- p="">&lt;</c-><c- f="">i</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"fr"</c-><c- p="">&gt;</c->je ne sais quoi<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c-> in the air.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
   <p>In the following example, a dream sequence is marked up using
   <code id="the-i-element:the-i-element-3"><a href="#the-i-element">i</a></code> elements.</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Raymond tried to sleep.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->The ship sailed away on Thursday<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c->, he
dreamt. <c- p="">&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->The ship had many people aboard, including a beautiful
princess called Carey. He watched her, day-in, day-out, hoping she
would notice him, but she never did.<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->Finally one night he picked up the courage to speak with
her—<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Raymond woke with a start as the fire alarm rang out.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>Authors can use the <code id="the-i-element:classes"><a href="#classes">class</a></code> attribute on the <code id="the-i-element:the-i-element-4"><a href="#the-i-element">i</a></code>
  element to identify why the element is being used, so that if the style of a particular use (e.g.
  dream sequences as opposed to taxonomic terms) is to be changed at a later date, the author
  doesn't have to go through the entire document (or series of related documents) annotating each
  use.</p>

  <p>Authors are encouraged to consider whether other elements might be more applicable than the
  <code id="the-i-element:the-i-element-5"><a href="#the-i-element">i</a></code> element, for instance the <code id="the-i-element:the-em-element"><a href="#the-em-element">em</a></code> element for marking up stress emphasis,
  or the <code id="the-i-element:the-dfn-element"><a href="#the-dfn-element">dfn</a></code> element to mark up the defining instance of a term.</p>

  <p class="note">Style sheets can be used to format <code id="the-i-element:the-i-element-6"><a href="#the-i-element">i</a></code> elements, just like any other
  element can be restyled. Thus, it is not the case that content in <code id="the-i-element:the-i-element-7"><a href="#the-i-element">i</a></code> elements will
  necessarily be italicized.</p>


  <h4 id="the-b-element"><span class="secno">4.5.21</span> The <dfn data-dfn-type="element"><code>b</code></dfn> element<a href="#the-b-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b" title="The <b> HTML element is used to draw the reader's attention to the element's contents, which are not otherwise granted special importance. This was formerly known as the Boldface element, and most browsers still draw the text in boldface. However, you should not use <b> for styling text or granting importance. If you wish to create boldface text, you should use the CSS font-weight property. If you wish to indicate an element is of special importance, you should use the <strong> element.">Element/b</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-b-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-b-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-b-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-b-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-b-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-b-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-b-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-b-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-b-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-b-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-b-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-b-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-b">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-b">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-b-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-b-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-b-element:the-b-element"><a href="#the-b-element">b</a></code> element <a href="#represents" id="the-b-element:represents">represents</a> a span of text to which attention is being
  drawn for utilitarian purposes without conveying any extra importance and with no implication of
  an alternate voice or mood, such as key words in a document abstract, product names in a review,
  actionable words in interactive text-driven software, or an article lede.</p>

  <div class="example">

   <p>The following example shows a use of the <code id="the-b-element:the-b-element-2"><a href="#the-b-element">b</a></code> element to highlight key words without
   marking them up as important:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->frobonitor<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> and <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->barbinator<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> components are fried.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following example, objects in a text adventure are highlighted as being special by use
   of the <code id="the-b-element:the-b-element-3"><a href="#the-b-element">b</a></code> element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You enter a small room. Your <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->sword<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> glows
brighter. A <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->rat<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> scurries past the corner wall.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Another case where the <code id="the-b-element:the-b-element-4"><a href="#the-b-element">b</a></code> element is appropriate is in marking up the lede (or
   lead) sentence or paragraph. The following example shows how a <a href="http://news.bbc.co.uk/2/hi/uk_news/scotland/north_east/7101506.stm">BBC article about
   kittens adopting a rabbit as their own</a> could be marked up:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Kittens 'adopted' by pet rabbit<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"lede"</c-><c- p="">&gt;</c->Six abandoned kittens have found an
 unexpected new mother figure — a pet rabbit.<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Veterinary nurse Melanie Humble took the three-week-old
 kittens to her Aberdeen home.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<i>[...]</i></code></pre>

  </div>

  <p>As with the <code id="the-b-element:the-i-element"><a href="#the-i-element">i</a></code> element, authors can use the <code id="the-b-element:classes"><a href="#classes">class</a></code>
  attribute on the <code id="the-b-element:the-b-element-5"><a href="#the-b-element">b</a></code> element to identify why the element is being used, so that if the
  style of a particular use is to be changed at a later date, the author doesn't have to go through
  annotating each use.</p>

  <p>The <code id="the-b-element:the-b-element-6"><a href="#the-b-element">b</a></code> element should be used as a last resort when no other element is more
  appropriate. In particular, headings should use the <code id="the-b-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code> to <code id="the-b-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> elements,
  stress emphasis should use the <code id="the-b-element:the-em-element"><a href="#the-em-element">em</a></code> element, importance should be denoted with the
  <code id="the-b-element:the-strong-element"><a href="#the-strong-element">strong</a></code> element, and text marked or highlighted should use the <code id="the-b-element:the-mark-element"><a href="#the-mark-element">mark</a></code>
  element.</p>

  <div class="example">

   <p>The following would be <em>incorrect</em> usage:</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->WARNING!<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> Do not frob the barbinator!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>In the previous example, the correct element to use would have been <code id="the-b-element:the-strong-element-2"><a href="#the-strong-element">strong</a></code>, not
   <code id="the-b-element:the-b-element-7"><a href="#the-b-element">b</a></code>.</p>

  </div>

  <p class="note">Style sheets can be used to format <code id="the-b-element:the-b-element-8"><a href="#the-b-element">b</a></code> elements, just like any other
  element can be restyled. Thus, it is not the case that content in <code id="the-b-element:the-b-element-9"><a href="#the-b-element">b</a></code> elements will
  necessarily be boldened.</p>



  <h4 id="the-u-element"><span class="secno">4.5.22</span> The <dfn data-dfn-type="element"><code>u</code></dfn> element<a href="#the-u-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/u" title="The <u> HTML element represents a span of inline text which should be rendered in a way that indicates that it has a non-textual annotation. This is rendered by default as a simple solid underline, but may be altered using CSS.">Element/u</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-u-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-u-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-u-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-u-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-u-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-u-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-u-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-u-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-u-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-u-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-u-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-u-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-u">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-u">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-u-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-u-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-u-element:the-u-element"><a href="#the-u-element">u</a></code> element <a href="#represents" id="the-u-element:represents">represents</a> a span of text with an unarticulated, though
  explicitly rendered, non-textual annotation, such as labeling the text as being a proper name in
  Chinese text (a Chinese proper name mark), or labeling the text as being misspelt.</p>

  <p>In most cases, another element is likely to be more appropriate: for marking stress emphasis,
  the <code id="the-u-element:the-em-element"><a href="#the-em-element">em</a></code> element should be used; for marking key words or phrases either the
  <code id="the-u-element:the-b-element"><a href="#the-b-element">b</a></code> element or the <code id="the-u-element:the-mark-element"><a href="#the-mark-element">mark</a></code> element should be used, depending on the context;
  for marking book titles, the <code id="the-u-element:the-cite-element"><a href="#the-cite-element">cite</a></code> element should be used; for labeling text with explicit textual annotations, the
  <code id="the-u-element:the-ruby-element"><a href="#the-ruby-element">ruby</a></code> element should be used; for technical terms, taxonomic designation,
  transliteration, a thought, or for labeling ship names in Western texts, the <code id="the-u-element:the-i-element"><a href="#the-i-element">i</a></code>
  element should be used.</p>

  <p class="note">The default rendering of the <code id="the-u-element:the-u-element-2"><a href="#the-u-element">u</a></code> element in visual presentations
  clashes with the conventional rendering of hyperlinks (underlining). Authors are encouraged to
  avoid using the <code id="the-u-element:the-u-element-3"><a href="#the-u-element">u</a></code> element where it could be confused for a hyperlink.</p>

  <div class="example">

   <p>In this example, a <code id="the-u-element:the-u-element-4"><a href="#the-u-element">u</a></code> element is used to mark a word as misspelt:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The <c- p="">&lt;</c-><c- f="">u</c-><c- p="">&gt;</c->see<c- p="">&lt;/</c-><c- f="">u</c-><c- p="">&gt;</c-> is full of fish.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-mark-element"><span class="secno">4.5.23</span> The <dfn data-dfn-type="element"><code>mark</code></dfn> element<a href="#the-mark-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark" title="The <mark> HTML element represents text which is marked or highlighted for reference or notation purposes due to the marked passage's relevance in the enclosing context.">Element/mark</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>7+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-mark-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-mark-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-mark-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-mark-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-mark-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-mark-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-mark-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-mark-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-mark-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-mark-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-mark-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-mark-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-mark">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-mark">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-mark-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-mark-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  

  <p>The <code id="the-mark-element:the-mark-element"><a href="#the-mark-element">mark</a></code> element <a href="#represents" id="the-mark-element:represents">represents</a> a run of text in one document marked or
  highlighted for <a href="#referenced" id="the-mark-element:referenced">reference</a> purposes, due to its relevance in
  another context. When used in a quotation or other block of text referred to from the prose, it
  indicates a highlight that was not originally present but which has been added to bring the
  reader's attention to a part of the text that might not have been considered important by the
  original author when the block was originally written, but which is now under previously
  unexpected scrutiny. When used in the main prose of a document, it indicates a part of the
  document that has been highlighted due to its likely relevance to the user's current activity.</p>

  <div class="example">

   <p>This example shows how the <code id="the-mark-element:the-mark-element-2"><a href="#the-mark-element">mark</a></code> element can be used to bring attention to a
   particular part of a quotation:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-US"</c-><c- p="">&gt;</c->Consider the following quote:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<span lang="en-GB"><c- p="">&lt;</c-><c- f="">blockquote</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-GB"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Look around and you will find, no-one's really
 <c- p="">&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->colour<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;</c-> blind.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c-></span>
<c- p="">&lt;</c-><c- f="">p</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en-US"</c-><c- p="">&gt;</c->As we can tell from the <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->spelling<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> of the word,
the person writing this quote is clearly not American.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>(If the goal was to mark the element as misspelt, however, the <code id="the-mark-element:the-u-element"><a href="#the-u-element">u</a></code> element,
   possibly with a class, would be more appropriate.)</p>

  </div>

  <div class="example">

   <p>Another example of the <code id="the-mark-element:the-mark-element-3"><a href="#the-mark-element">mark</a></code> element is highlighting parts of a document that are
   matching some search string. If someone looked at a document, and the server knew that the user
   was searching for the word "kitten", then the server might return the document with one paragraph
   modified as follows:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I also have some <c- p="">&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->kitten<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;</c->s who are visiting me
these days. They're really cute. I think they like my garden! Maybe I
should adopt a <c- p="">&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->kitten<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following snippet, a paragraph of text refers to a specific part of a code
   fragment.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The highlighted part below is where the error lies:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->var i: Integer;
begin
   i := <c- p="">&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->1.1<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;</c->;
end.<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

   <p>This is separate from <em>syntax highlighting</em>, for which <code id="the-mark-element:the-span-element"><a href="#the-span-element">span</a></code> is more
   appropriate. Combining both, one would get:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The highlighted part below is where the error lies:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;&lt;</c-><c- f="">code</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">keyword</c-><c- p="">&gt;</c->var<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">ident</c-><c- p="">&gt;</c->i<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">type</c-><c- p="">&gt;</c->Integer<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->;
<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">keyword</c-><c- p="">&gt;</c->begin<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">ident</c-><c- p="">&gt;</c->i<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> := <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">literal</c-><c- p="">&gt;&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->1.1<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->;
<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">keyword</c-><c- p="">&gt;</c->end<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>This is another example showing the use of <code id="the-mark-element:the-mark-element-4"><a href="#the-mark-element">mark</a></code> to highlight a part of quoted
   text that was originally not emphasized. In this example, common typographic conventions have led
   the author to explicitly style <code id="the-mark-element:the-mark-element-5"><a href="#the-mark-element">mark</a></code> elements in quotes to render in italics.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
 <c- f="">blockquote</c-> <c- f="">mark</c-><c- o="">,</c-> <c- f="">q</c-> <c- f="">mark</c-> <c- p="">{</c->
   <c- k="">font</c-><c- p="">:</c-> <c- kc="">inherit</c-><c- p="">;</c-> <c- k="">font-style</c-><c- p="">:</c-> <c- kc="">italic</c-><c- p="">;</c->
   <c- k="">text-decoration</c-><c- p="">:</c-> <c- kc="">none</c-><c- p="">;</c->
   <c- k="">background</c-><c- p="">:</c-> <c- kc="">transparent</c-><c- p="">;</c-> <c- k="">color</c-><c- p="">:</c-> <c- kc="">inherit</c-><c- p="">;</c->
 <c- p="">}</c->
 <c- p="">.</c-><c- nc="">bubble</c-> <c- f="">em</c-> <c- p="">{</c->
   <c- k="">font</c-><c- p="">:</c-> <c- kc="">inherit</c-><c- p="">;</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- kc="">larger</c-><c- p="">;</c->
   <c- k="">text-decoration</c-><c- p="">:</c-> <c- kc="">underline</c-><c- p="">;</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->She knew<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Did you notice the subtle joke in the joke on panel 4?<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"bubble"</c-><c- p="">&gt;</c->I didn't <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->want<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> to believe. <c- p="">&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->Of course
  on some level I realized it was a known-plaintext attack.<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;</c-> But I
  couldn't admit it until I saw for myself.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">blockquote</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->(Emphasis mine.) I thought that was great. It's so pedantic, yet it
 explains everything neatly.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <p>Note, incidentally, the distinction between the <code id="the-mark-element:the-em-element"><a href="#the-em-element">em</a></code> element in this example, which
   is part of the original text being quoted, and the <code id="the-mark-element:the-mark-element-6"><a href="#the-mark-element">mark</a></code> element, which is
   highlighting a part for comment.</p>

  </div>

  <div class="example">

   <p>The following example shows the difference between denoting the <em>importance</em> of a span
   of text (<code id="the-mark-element:the-strong-element"><a href="#the-strong-element">strong</a></code>) as opposed to denoting the <em>relevance</em> of a span of text
   (<code id="the-mark-element:the-mark-element-7"><a href="#the-mark-element">mark</a></code>). It is an extract from a textbook, where the extract has had the parts
   relevant to the exam highlighted. The safety warnings, important though they may be, are
   apparently not relevant to the exam.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Wormhole Physics Introduction<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->A wormhole in normal conditions can be held open for a
maximum of just under 39 minutes.<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;</c-> Conditions that can increase
the time include a powerful energy source coupled to one or both of
the gates connecting the wormhole, and a large gravity well (such as a
black hole).<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->Momentum is preserved across the wormhole. Electromagnetic
radiation can travel in both directions through a wormhole,
but matter cannot.<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->When a wormhole is created, a vortex normally forms.
<c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Warning: The vortex caused by the wormhole opening will
annihilate anything in its path.<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> Vortexes can be avoided when
using sufficiently advanced dialing technology.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->An obstruction in a gate will prevent it from accepting a
wormhole connection.<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-bdi-element"><span class="secno">4.5.24</span> The <dfn data-dfn-type="element"><code>bdi</code></dfn> element<a href="#the-bdi-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdi" title="The <bdi> HTML element tells the browser's bidirectional algorithm to treat the text it contains in isolation from its surrounding text. It's particularly useful when a website dynamically inserts some text and doesn't know the directionality of the text being inserted.">Element/bdi</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>10+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>16+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-bdi-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-bdi-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-bdi-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-bdi-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-bdi-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-bdi-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-bdi-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-bdi-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-bdi-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-bdi-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-bdi-element:global-attributes">Global attributes</a></dd><dd>Also, the <code id="the-bdi-element:attr-dir"><a href="#attr-dir">dir</a></code> global attribute has special semantics on this element.</dd><dt><a href="#concept-element-accessibility-considerations" id="the-bdi-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-bdi">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-bdi">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-bdi-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-bdi-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-bdi-element:the-bdi-element"><a href="#the-bdi-element">bdi</a></code> element <a href="#represents" id="the-bdi-element:represents">represents</a> a span of text that is to be isolated from
  its surroundings for the purposes of bidirectional text formatting. <a href="#refsBIDI">[BIDI]</a></p>

  <p class="note">The <code id="the-bdi-element:attr-dir-2"><a href="#attr-dir">dir</a></code> global attribute defaults to <code id="the-bdi-element:attr-dir-auto"><a href="#attr-dir-auto">auto</a></code> on this element (it never inherits from the parent element like
  with other elements).</p>

  

  <p class="note">This element <a href="#bidireq">has rendering requirements involving the
  bidirectional algorithm</a>.</p>

  

  <div class="example">

   <p>This element is especially useful when embedding user-generated content with an unknown
   directionality.</p>

   <p>In this example, usernames are shown along with the number of posts that the user has
   submitted. If the <code id="the-bdi-element:the-bdi-element-2"><a href="#the-bdi-element">bdi</a></code> element were not used, the username of the Arabic user would
   end up confusing the text (the bidirectional algorithm would put the colon and the number "3"
   next to the word "User" rather than next to the word "posts").</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->User <c- p="">&lt;</c-><c- f="">bdi</c-><c- p="">&gt;</c->jcranmer<c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c->: 12 posts.
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->User <c- p="">&lt;</c-><c- f="">bdi</c-><c- p="">&gt;</c->hober<c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c->: 5 posts.
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->User <c- p="">&lt;</c-><c- f="">bdi</c-><c- p="">&gt;</c-><bdo dir="rtl">إيان</bdo><c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c->: 3 posts.
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

   <figure>
    <img src="/images/sample-bdi.png" alt="">
    <figcaption>When using the <code id="the-bdi-element:the-bdi-element-3"><a href="#the-bdi-element">bdi</a></code> element, the username acts as expected.</figcaption>
   </figure>

   <figure>
    <img src="/images/sample-not-bdi.png" alt="">
    <figcaption>If the <code id="the-bdi-element:the-bdi-element-4"><a href="#the-bdi-element">bdi</a></code> element were to be replaced by a <code id="the-bdi-element:the-b-element"><a href="#the-b-element">b</a></code> element, the username would confuse the bidirectional algorithm and the third bullet would end up saying "User 3 :", followed by the Arabic name (right-to-left), followed by "posts" and a period.</figcaption>
   </figure>

  </div>


  <h4 id="the-bdo-element"><span class="secno">4.5.25</span> The <dfn data-dfn-type="element"><code>bdo</code></dfn> element<a href="#the-bdo-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdo" title="The <bdo> HTML element overrides the current directionality of text, so that the text within is rendered in a different direction.">Element/bdo</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>10+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>15+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-bdo-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-bdo-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-bdo-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-bdo-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-bdo-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-bdo-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-bdo-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-bdo-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-bdo-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-bdo-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-bdo-element:global-attributes">Global attributes</a></dd><dd>Also, the <code id="the-bdo-element:attr-dir"><a href="#attr-dir">dir</a></code> global attribute has special semantics on this element.</dd><dt><a href="#concept-element-accessibility-considerations" id="the-bdo-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-bdo">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-bdo">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-bdo-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-bdo-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-bdo-element:the-bdo-element"><a href="#the-bdo-element">bdo</a></code> element <a href="#represents" id="the-bdo-element:represents">represents</a> explicit text directionality formatting
  control for its children. It allows authors to override the Unicode bidirectional algorithm by
  explicitly specifying a direction override. <a href="#refsBIDI">[BIDI]</a></p>

  <p>Authors must specify the <code id="the-bdo-element:attr-dir-2"><a href="#attr-dir">dir</a></code> attribute on this element, with the
  value <code id="the-bdo-element:attr-dir-ltr"><a href="#attr-dir-ltr">ltr</a></code> to specify a left-to-right override and with the value <code id="the-bdo-element:attr-dir-rtl"><a href="#attr-dir-rtl">rtl</a></code> to
  specify a right-to-left override. The <code id="the-bdo-element:attr-dir-auto"><a href="#attr-dir-auto">auto</a></code> value must not be specified.</p>

  

  <p class="note">This element <a href="#bidireq">has rendering requirements involving the
  bidirectional algorithm</a>.</p>

  



  <h4 id="the-span-element"><span class="secno">4.5.26</span> The <dfn data-dfn-type="element"><code>span</code></dfn> element<a href="#the-span-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span" title="The <span> HTML element is a generic inline container for phrasing content, which does not inherently represent anything. It can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang. It should be used only when no other semantic element is appropriate. <span> is very much like a <div> element, but <div> is a block-level element whereas a <span> is an inline-level element.">Element/span</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSpanElement" title="The HTMLSpanElement interface represents a <span> element and derives from the HTMLElement interface, but without implementing any additional properties or methods.">HTMLSpanElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>15+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-span-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-span-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-span-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-span-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-span-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-span-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-span-element:concept-element-content-model">Content model</a>:</dt><dd>If the element is a descendant of an <code id="the-span-element:the-option-element"><a href="#the-option-element">option</a></code> element: Zero or more
   <a href="#option-element-inner-content-elements-2" id="the-span-element:option-element-inner-content-elements-2"><code>option</code> element inner content elements</a>, except <code id="the-span-element:the-div-element"><a href="#the-div-element">div</a></code>
   elements.</dd><dd>Otherwise: <a href="#phrasing-content-2" id="the-span-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-span-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-span-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-span-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-span-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-span">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-span">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-span-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlspanelement" data-dfn-type="interface"><c- g="">HTMLSpanElement</c-></dfn> : <a href="#htmlelement" id="the-span-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-span-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();
};</code></pre>
   </dd></dl>

  <p>The <code id="the-span-element:the-span-element"><a href="#the-span-element">span</a></code> element doesn't mean anything on its own, but can be useful when used
  together with the <a href="#global-attributes" id="the-span-element:global-attributes-2">global attributes</a>, e.g. <code id="the-span-element:classes"><a href="#classes">class</a></code>,
  <code id="the-span-element:attr-lang"><a href="#attr-lang">lang</a></code>, or <code id="the-span-element:attr-dir"><a href="#attr-dir">dir</a></code>. It
  <a href="#represents" id="the-span-element:represents">represents</a> its children.</p>

  <div class="example">

   <p>In this example, a code fragment is marked up using <code id="the-span-element:the-span-element-2"><a href="#the-span-element">span</a></code> elements and <code id="the-span-element:classes-2"><a href="#classes">class</a></code> attributes so that its keywords and identifiers can be
   color-coded from CSS:</p>

   

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;&lt;</c-><c- f="">code</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"lang-c"</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"keyword"</c-><c- p="">&gt;</c->for<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> (<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->j<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> = 0; <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->j<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- ni="">&amp;lt;</c-> 256; <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->j<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->++) {
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->i_t3<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> = (<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->i_t3<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> &amp; 0x1ffff) | (<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->j<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- ni="">&amp;lt;&amp;lt;</c-> 17);
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->i_t6<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> = (((((((<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->i_t3<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> &gt;&gt; 3) ^ <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->i_t3<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->) &gt;&gt; 1) ^ <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->i_t3<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->) &gt;&gt; 8) ^ <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->i_t3<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->) &gt;&gt; 5) &amp; 0xff;
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"keyword"</c-><c- p="">&gt;</c->if<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> (<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->i_t6<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> == <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"ident"</c-><c- p="">&gt;</c->i_t1<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->)
    <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"keyword"</c-><c- p="">&gt;</c->break<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->;
}<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-br-element"><span class="secno">4.5.27</span> The <dfn data-dfn-type="element"><code>br</code></dfn> element<a href="#the-br-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/br" title="The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.">Element/br</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLBRElement" title="The HTMLBRElement interface represents an HTML line break element (<br>). It inherits from HTMLElement.">HTMLBRElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-br-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-br-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-br-element:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-contexts" id="the-br-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-br-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-br-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-br-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-br-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-br-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-br-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-br-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-br-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-br">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-br">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-br-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlbrelement" data-dfn-type="interface"><c- g="">HTMLBRElement</c-></dfn> : <a href="#htmlelement" id="the-br-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-br-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLBRElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-br-element:the-br-element"><a href="#the-br-element">br</a></code> element <a href="#represents" id="the-br-element:represents">represents</a> a line break.</p>

  <p class="note">While line breaks are usually represented in visual media by physically moving
  subsequent text to a new line, a style sheet or user agent would be equally justified in causing
  line breaks to be rendered in a different manner, for instance as green dots, or as extra
  spacing.</p>

  <p><code id="the-br-element:the-br-element-2"><a href="#the-br-element">br</a></code> elements must be used only for line breaks that are actually part of the
  content, as in poems or addresses.</p>

  <div class="example">

  <p>The following example is correct usage of the <code id="the-br-element:the-br-element-3"><a href="#the-br-element">br</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->P. Sherman<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
42 Wallaby Way<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
Sydney<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p><code id="the-br-element:the-br-element-4"><a href="#the-br-element">br</a></code> elements must not be used for separating thematic groups in a paragraph.</p>

  <div class="example">

   <p>The following examples are non-conforming, as they abuse the <code id="the-br-element:the-br-element-5"><a href="#the-br-element">br</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> ...<c- p="">&gt;</c->34 comments.<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">a</c-> ...<c- p="">&gt;</c->Add a comment.<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"address"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Here are alternatives to the above, which are correct:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> ...<c- p="">&gt;</c->34 comments.<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> ...<c- p="">&gt;</c->Add a comment.<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"address"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>If a <a href="#paragraph" id="the-br-element:paragraph">paragraph</a> consists of nothing but a single <code id="the-br-element:the-br-element-6"><a href="#the-br-element">br</a></code> element, it
  represents a placeholder blank line (e.g. as in a template). Such blank lines must not be used for
  presentation purposes.</p>

  

  <p>Any content inside <code id="the-br-element:the-br-element-7"><a href="#the-br-element">br</a></code> elements must not be considered part of the surrounding
  text.</p>

  <p class="note">This element <a href="#bidireq">has rendering requirements involving the
  bidirectional algorithm</a>.</p>

  


  <h4 id="the-wbr-element"><span class="secno">4.5.28</span> The <dfn data-dfn-type="element"><code>wbr</code></dfn> element<a href="#the-wbr-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr" title="The <wbr> HTML element represents a word break opportunity—a position within text where the browser may optionally break a line, though its line-breaking rules would not otherwise create a break at that location.">Element/wbr</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>5.5–7</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-wbr-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-wbr-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-wbr-element:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-contexts" id="the-wbr-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-wbr-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-wbr-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-wbr-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-wbr-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-wbr-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-wbr-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-wbr-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-wbr-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-wbr">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-wbr">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-wbr-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-wbr-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-wbr-element:the-wbr-element"><a href="#the-wbr-element">wbr</a></code> element <a href="#represents" id="the-wbr-element:represents">represents</a> a line break opportunity.</p>

  <div class="example">

   <p>In the following example, someone is quoted as saying something which, for effect, is written
   as one long word. However, to ensure that the text can be wrapped in a readable fashion, the
   individual words in the quote are separated using a <code id="the-wbr-element:the-wbr-element-2"><a href="#the-wbr-element">wbr</a></code> element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->So then she pointed at the tiger and screamed
"there<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->is<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->no<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->way<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->you<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->are<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->ever<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->going<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->to<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->catch<c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c->me"!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

   <p>Any content inside <code id="the-wbr-element:the-wbr-element-3"><a href="#the-wbr-element">wbr</a></code> elements must not be considered part of the surrounding
   text.</p>

   <pre class="example"><code class="js"><c- a="">var</c-> wbr <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"wbr"</c-><c- p="">);</c->
wbr<c- p="">.</c->textContent <c- o="">=</c-> <c- u="">"This is wrong"</c-><c- p="">;</c->
document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->wbr<c- p="">);</c-></code></pre>

   <p class="note">This element <a href="#bidireq">has rendering requirements involving the
   bidirectional algorithm</a>.</p>

  



  <h4 id="usage-summary"><span class="secno">4.5.29</span> Usage summary<a href="#usage-summary" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <table><thead><tr><th>Element
     </th><th>Purpose
     </th><th>Example
   </th></tr></thead><tbody><tr><td><code id="usage-summary:the-a-element"><a href="#the-a-element">a</a></code>
     </td><td>Hyperlinks
     </td><td><pre class="example"><code class="html">Visit my <strong><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"drinks.html"</c-><c- p="">&gt;</c->drinks<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></strong> page.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-em-element"><a href="#the-em-element">em</a></code>
     </td><td>Stress emphasis
     </td><td><pre class="example"><code class="html">I must say I <strong><c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->adore<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-></strong> lemonade.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-strong-element"><a href="#the-strong-element">strong</a></code>
     </td><td>Importance
     </td><td><pre class="example"><code class="html">This tea is <strong><c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->very hot<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-></strong>.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-small-element"><a href="#the-small-element">small</a></code>
     </td><td>Side comments
     </td><td><pre class="example"><code class="html">These grapes are made into wine. <strong><c- p="">&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Alcohol is addictive.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;</c-></strong></code></pre>

    </td></tr><tr><td><code id="usage-summary:the-s-element"><a href="#the-s-element">s</a></code>
     </td><td>Inaccurate text
     </td><td><pre class="example"><code class="html">Price: <strong><c- p="">&lt;</c-><c- f="">s</c-><c- p="">&gt;</c->£4.50<c- p="">&lt;/</c-><c- f="">s</c-><c- p="">&gt;</c-></strong> £2.00!</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-cite-element"><a href="#the-cite-element">cite</a></code>
     </td><td>Titles of works
     </td><td><pre class="example"><code class="html">The case <strong><c- p="">&lt;</c-><c- f="">cite</c-><c- p="">&gt;</c->Hugo v. Danielle<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;</c-></strong> is relevant here.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-q-element"><a href="#the-q-element">q</a></code>
     </td><td>Quotations
     </td><td><pre class="example"><code class="html">The judge said <strong><c- p="">&lt;</c-><c- f="">q</c-><c- p="">&gt;</c->You can drink water from the fish tank<c- p="">&lt;/</c-><c- f="">q</c-><c- p="">&gt;</c-></strong> but advised against it.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-dfn-element"><a href="#the-dfn-element">dfn</a></code>
     </td><td>Defining instance
     </td><td><pre class="example"><code class="html">The term <strong><c- p="">&lt;</c-><c- f="">dfn</c-><c- p="">&gt;</c->organic food<c- p="">&lt;/</c-><c- f="">dfn</c-><c- p="">&gt;</c-></strong> refers to food produced without synthetic chemicals.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-abbr-element"><a href="#the-abbr-element">abbr</a></code>
     </td><td>Abbreviations
     </td><td><pre class="example"><code class="html">Organic food in Ireland is certified by the <strong><c- p="">&lt;</c-><c- f="">abbr</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Irish Organic Farmers and Growers Association"</c-><c- p="">&gt;</c->IOFGA<c- p="">&lt;/</c-><c- f="">abbr</c-><c- p="">&gt;</c-></strong>.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-ruby-element"><a href="#the-ruby-element">ruby</a></code>, <code id="usage-summary:the-rt-element"><a href="#the-rt-element">rt</a></code>, <code id="usage-summary:the-rp-element"><a href="#the-rp-element">rp</a></code>
     </td><td>Ruby annotations
     </td><td><pre class="example"><code class="html"><strong><c- p="">&lt;</c-><c- f="">ruby</c-><c- p="">&gt;</c-> OJ <c- p="">&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->(<c- p="">&lt;</c-><c- f="">rt</c-><c- p="">&gt;</c->Orange Juice<c- p="">&lt;</c-><c- f="">rp</c-><c- p="">&gt;</c->)<c- p="">&lt;/</c-><c- f="">ruby</c-><c- p="">&gt;</c-></strong></code></pre>

    </td></tr><tr><td><code id="usage-summary:the-data-element"><a href="#the-data-element">data</a></code>
     </td><td>Machine-readable equivalent
     </td><td><pre class="example"><code class="html">Available starting today! <strong><c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"UPC:022014640201"</c-><c- p="">&gt;</c->North Coast Organic Apple Cider<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c-></strong></code></pre>

    </td></tr><tr><td><code id="usage-summary:the-time-element"><a href="#the-time-element">time</a></code>
     </td><td>Machine-readable equivalent of date- or time-related data
     </td><td><pre class="example"><code class="html">Available starting on <strong><c- p="">&lt;</c-><c- f="">time</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2011-11-18"</c-><c- p="">&gt;</c->November 18th<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c-></strong>!</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-code-element"><a href="#the-code-element">code</a></code>
     </td><td>Computer code
     </td><td><pre class="example"><code class="html">The <strong><c- p="">&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->fruitdb<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c-></strong> program can be used for tracking fruit production.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-var-element"><a href="#the-var-element">var</a></code>
     </td><td>Variables
     </td><td><pre class="example"><code class="html">If there are <strong><c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->n<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c-></strong> fruit in the bowl, at least <strong><c- p="">&lt;</c-><c- f="">var</c-><c- p="">&gt;</c->n<c- p="">&lt;/</c-><c- f="">var</c-><c- p="">&gt;</c-></strong>÷2 will be ripe.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-samp-element"><a href="#the-samp-element">samp</a></code>
     </td><td>Computer output
     </td><td><pre class="example"><code class="html">The computer said <strong><c- p="">&lt;</c-><c- f="">samp</c-><c- p="">&gt;</c->Unknown error -3<c- p="">&lt;/</c-><c- f="">samp</c-><c- p="">&gt;</c-></strong>.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-kbd-element"><a href="#the-kbd-element">kbd</a></code>
     </td><td>User input
     </td><td><pre class="example"><code class="html">Hit <strong><c- p="">&lt;</c-><c- f="">kbd</c-><c- p="">&gt;</c->F1<c- p="">&lt;/</c-><c- f="">kbd</c-><c- p="">&gt;</c-></strong> to continue.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-sub-and-sup-elements"><a href="#the-sub-and-sup-elements">sub</a></code>
     </td><td>Subscripts
     </td><td><pre class="example"><code class="html">Water is H<strong><c- p="">&lt;</c-><c- f="">sub</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">sub</c-><c- p="">&gt;</c-></strong>O.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-sub-and-sup-elements-2"><a href="#the-sub-and-sup-elements">sup</a></code>
     </td><td>Superscripts
     </td><td><pre class="example"><code class="html">The Hydrogen in heavy water is usually <strong><c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">sup</c-><c- p="">&gt;</c-></strong>H.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-i-element"><a href="#the-i-element">i</a></code>
     </td><td>Alternative voice
     </td><td><pre class="example"><code class="html">Lemonade consists primarily of <strong><c- p="">&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->Citrus limon<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c-></strong>.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-b-element"><a href="#the-b-element">b</a></code>
     </td><td>Keywords
     </td><td><pre class="example"><code class="html">Take a <strong><c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->lemon<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-></strong> and squeeze it with a <strong><c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->juicer<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-></strong>.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-u-element"><a href="#the-u-element">u</a></code>
     </td><td>Annotations
     </td><td><pre class="example"><code class="html">The mixture of apple juice and <strong><c- p="">&lt;</c-><c- f="">u</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"spelling"</c-><c- p="">&gt;</c->eldeflower<c- p="">&lt;/</c-><c- f="">u</c-><c- p="">&gt;</c-></strong> juice is very pleasant.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-mark-element"><a href="#the-mark-element">mark</a></code>
     </td><td>Highlight
     </td><td><pre class="example"><code class="html">Elderflower cordial, with one <strong><c- p="">&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->part<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;</c-></strong> cordial to ten <strong><c- p="">&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->part<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;</c-></strong>s water, stands a<strong><c- p="">&lt;</c-><c- f="">mark</c-><c- p="">&gt;</c->part<c- p="">&lt;/</c-><c- f="">mark</c-><c- p="">&gt;</c-></strong> from the rest.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-bdi-element"><a href="#the-bdi-element">bdi</a></code>
     </td><td>Text directionality isolation
     </td><td><pre class="example"><code class="html">The recommended restaurant is <strong><c- p="">&lt;</c-><c- f="">bdi</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->My Juice Café (At The Beach)<c- p="">&lt;/</c-><c- f="">bdi</c-><c- p="">&gt;</c-></strong>.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-bdo-element"><a href="#the-bdo-element">bdo</a></code>
     </td><td>Text directionality formatting
     </td><td><pre class="example"><code class="html">The proposal is to write English, but in reverse order. "Juice" would become "<strong><c- p="">&lt;</c-><c- f="">bdo</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">rtl</c-><c- p="">&gt;</c->Juice<c- p="">&lt;/</c-><c- f="">bdo</c-><c- p="">&gt;</c-></strong>"&gt;</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-span-element"><a href="#the-span-element">span</a></code>
     </td><td>Other
     </td><td><pre class="example"><code class="html">In French we call it <strong><c- p="">&lt;</c-><c- f="">span</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"fr"</c-><c- p="">&gt;</c->sirop de sureau<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-></strong>.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-br-element"><a href="#the-br-element">br</a></code>
     </td><td>Line break
     </td><td><pre class="example"><code class="html">Simply Orange Juice Company<strong><c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c-></strong>Apopka, FL 32703<strong><c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c-></strong>U.S.A.</code></pre>

    </td></tr><tr><td><code id="usage-summary:the-wbr-element"><a href="#the-wbr-element">wbr</a></code>
     </td><td>Line breaking opportunity
     </td><td><pre class="example"><code class="html">www.simply<strong><c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c-></strong>orange<strong><c- p="">&lt;</c-><c- f="">wbr</c-><c- p="">&gt;</c-></strong>juice.com</code></pre>

  </td></tr></tbody></table>



  <h3 id="links"><span class="secno">4.6</span> Links<a href="#links" class="self-link"></a></h3>

  <h4 id="introduction-2"><span class="secno">4.6.1</span> Introduction<a href="#introduction-2" class="self-link"></a></h4>

  <p>Links are a conceptual construct, created by <code id="introduction-2:the-a-element"><a href="#the-a-element">a</a></code>, <code id="introduction-2:the-area-element"><a href="#the-area-element">area</a></code>,
  <code id="introduction-2:the-form-element"><a href="#the-form-element">form</a></code>, and <code id="introduction-2:the-link-element"><a href="#the-link-element">link</a></code> elements, that <a href="#represents" id="introduction-2:represents">represent</a>
  a connection between two resources, one of which is the current <code id="introduction-2:document"><a href="#document">Document</a></code>. There are
  three kinds of links in HTML:</p>

  <dl><dt><dfn id="external-resource-link" data-lt="external resource link" data-export="">Links to
   external resources</dfn></dt><dd><p>These are links to resources that are to be used to augment the current document,
   generally automatically processed by the user agent. All <a href="#external-resource-link" id="introduction-2:external-resource-link">external resource links</a> have a <a href="#fetch-and-process-the-linked-resource" id="introduction-2:fetch-and-process-the-linked-resource">fetch and process the linked resource</a>
   algorithm which describes how the resource is obtained.</p></dd><dt><dfn id="hyperlink" data-lt="hyperlink" data-export="">Hyperlinks</dfn></dt><dd><p>These are links to other resources that are generally exposed to the user by the user
   agent so that the user can cause the user agent to <a href="#navigate" id="introduction-2:navigate">navigate</a> to those resources, e.g.
   to visit them in a browser or download them.</p></dd><dt><dfn id="internal-resource-link" data-export="">Internal resource links</dfn></dt><dd><p>These are links to resources within the current document, used to give those resources
   special meaning or behavior.</p></dd></dl>

  <p>For <code id="introduction-2:the-link-element-2"><a href="#the-link-element">link</a></code> elements with an <code id="introduction-2:attr-link-href"><a href="#attr-link-href">href</a></code> attribute and a
  <code id="introduction-2:attr-link-rel"><a href="#attr-link-rel">rel</a></code> attribute, links must be created for the keywords of the
  <code id="introduction-2:attr-link-rel-2"><a href="#attr-link-rel">rel</a></code> attribute, as defined for those keywords in the <a href="#linkTypes">link types</a> section.</p>

  <p>Similarly, for <code id="introduction-2:the-a-element-2"><a href="#the-a-element">a</a></code> and <code id="introduction-2:the-area-element-2"><a href="#the-area-element">area</a></code> elements with an <code id="introduction-2:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute and a <code id="introduction-2:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code> attribute, links must be created for the keywords of the
  <code id="introduction-2:attr-hyperlink-rel-2"><a href="#attr-hyperlink-rel">rel</a></code> attribute as defined for those keywords in the <a href="#linkTypes">link types</a> section. Unlike <code id="introduction-2:the-link-element-3"><a href="#the-link-element">link</a></code> elements, however,
  <code id="introduction-2:the-a-element-3"><a href="#the-a-element">a</a></code> and <code id="introduction-2:the-area-element-3"><a href="#the-area-element">area</a></code> elements with an <code id="introduction-2:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code>
  attribute that either do not have a <code id="introduction-2:attr-hyperlink-rel-3"><a href="#attr-hyperlink-rel">rel</a></code> attribute, or
  whose <code id="introduction-2:attr-hyperlink-rel-4"><a href="#attr-hyperlink-rel">rel</a></code> attribute has no keywords that are defined as
  specifying <a href="#hyperlink" id="introduction-2:hyperlink">hyperlinks</a>, must also create a <a href="#hyperlink" id="introduction-2:hyperlink-2">hyperlink</a>.
  This implied hyperlink has no special meaning (it has no <a href="#linkTypes">link type</a>)
  beyond linking the element's <a id="introduction-2:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> to the resource given by the element's <code id="introduction-2:attr-hyperlink-href-3"><a href="#attr-hyperlink-href">href</a></code> attribute.</p>

  <p>Similarly, for <code id="introduction-2:the-form-element-2"><a href="#the-form-element">form</a></code> elements with a <code id="introduction-2:attr-form-rel"><a href="#attr-form-rel">rel</a></code>
  attribute, links must be created for the keywords of the <code id="introduction-2:attr-form-rel-2"><a href="#attr-form-rel">rel</a></code>
  attribute as defined for those keywords in the <a href="#linkTypes">link types</a> section.
  <code id="introduction-2:the-form-element-3"><a href="#the-form-element">form</a></code> elements that do not have a <code id="introduction-2:attr-form-rel-3"><a href="#attr-form-rel">rel</a></code> attribute,
  or whose <code id="introduction-2:attr-form-rel-4"><a href="#attr-form-rel">rel</a></code> attribute has no keywords that are defined as
  specifying <a href="#hyperlink" id="introduction-2:hyperlink-3">hyperlinks</a>, must also create a <a href="#hyperlink" id="introduction-2:hyperlink-4">hyperlink</a>.

  </p><p>A <a href="#hyperlink" id="introduction-2:hyperlink-5">hyperlink</a> can have one or more <dfn id="hyperlink-annotation">hyperlink
  annotations</dfn> that modify the processing semantics of that hyperlink.</p>


  <h4 id="links-created-by-a-and-area-elements"><span class="secno">4.6.2</span> Links created by <code id="links-created-by-a-and-area-elements:the-a-element"><a href="#the-a-element">a</a></code> and <code id="links-created-by-a-and-area-elements:the-area-element"><a href="#the-area-element">area</a></code> elements<a href="#links-created-by-a-and-area-elements" class="self-link"></a></h4>

  <p>The <dfn data-dfn-for="a,area" id="attr-hyperlink-href" data-dfn-type="element-attr"><code>href</code></dfn>
  attribute on <code id="links-created-by-a-and-area-elements:the-a-element-2"><a href="#the-a-element">a</a></code> and <code id="links-created-by-a-and-area-elements:the-area-element-2"><a href="#the-area-element">area</a></code> elements must have a value that is a <a href="#valid-url-potentially-surrounded-by-spaces" id="links-created-by-a-and-area-elements:valid-url-potentially-surrounded-by-spaces">valid
  URL potentially surrounded by spaces</a>.</p>

  <p class="note">The <code id="links-created-by-a-and-area-elements:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute on <code id="links-created-by-a-and-area-elements:the-a-element-3"><a href="#the-a-element">a</a></code> and
  <code id="links-created-by-a-and-area-elements:the-area-element-3"><a href="#the-area-element">area</a></code> elements is not required; when those elements do not have <code id="links-created-by-a-and-area-elements:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> attributes they do not create hyperlinks.</p>

  <p>The <dfn data-dfn-for="a,area" id="attr-hyperlink-target" data-dfn-type="element-attr"><code>target</code></dfn>
  attribute, if present, must be a <a href="#valid-navigable-target-name-or-keyword" id="links-created-by-a-and-area-elements:valid-navigable-target-name-or-keyword">valid navigable target name or keyword</a>. It gives the
  name of the <a href="#navigable" id="links-created-by-a-and-area-elements:navigable">navigable</a> that will be used. User agents use this
  name when <a href="#following-hyperlinks-2" id="links-created-by-a-and-area-elements:following-hyperlinks-2">following hyperlinks</a>.</p>

  <p>The <dfn data-dfn-for="a,area" id="attr-hyperlink-download" data-dfn-type="element-attr"><code>download</code></dfn>
  attribute, if present, indicates that the author intends the hyperlink to be used for <a href="#downloading-hyperlinks" id="links-created-by-a-and-area-elements:downloading-hyperlinks">downloading a resource</a>. The attribute may have a value; the
  value, if any, specifies the default filename that the author recommends for use in labeling the
  resource in a local file system. There are no restrictions on allowed values, but authors are
  cautioned that most file systems have limitations with regard to what punctuation is supported in
  filenames, and user agents are likely to adjust filenames accordingly.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-ping" title="The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.">Element/a#attr-ping</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 1+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>12+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>≤37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="a,area" id="ping" data-dfn-type="element-attr"><code>ping</code></dfn> attribute, if present, gives the URLs of the
  resources that are interested in being notified if the user follows the hyperlink. The value must
  be a <a href="#set-of-space-separated-tokens" id="links-created-by-a-and-area-elements:set-of-space-separated-tokens">set of space-separated tokens</a>, each of which must be a <a href="#valid-non-empty-url" id="links-created-by-a-and-area-elements:valid-non-empty-url">valid non-empty
  URL</a> whose <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="links-created-by-a-and-area-elements:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is an <a id="links-created-by-a-and-area-elements:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S)
  scheme</a>. The value is used by the user agent for <a href="#hyperlink-auditing" id="links-created-by-a-and-area-elements:hyperlink-auditing">hyperlink
  auditing</a>.</p>

  <p>The <dfn data-dfn-for="a,area" id="attr-hyperlink-rel" data-dfn-type="element-attr"><code>rel</code></dfn> attribute on <code id="links-created-by-a-and-area-elements:the-a-element-4"><a href="#the-a-element">a</a></code> and <code id="links-created-by-a-and-area-elements:the-area-element-4"><a href="#the-area-element">area</a></code>
  elements controls what kinds of links the elements create. The attribute's value must be an
  <a href="#unordered-set-of-unique-space-separated-tokens" id="links-created-by-a-and-area-elements:unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</a>. The <a href="#linkTypes">allowed
  keywords and their meanings</a> are defined below.</p>

  <p><code id="links-created-by-a-and-area-elements:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="links-created-by-a-and-area-elements:concept-supported-tokens" data-x-internal="concept-supported-tokens">supported tokens</a> are the keywords defined in <a href="#linkTypes">HTML link types</a> which are allowed on <code id="links-created-by-a-and-area-elements:the-a-element-5"><a href="#the-a-element">a</a></code> and <code id="links-created-by-a-and-area-elements:the-area-element-5"><a href="#the-area-element">area</a></code>
  elements, impact the processing model, and are supported by the user agent. The possible <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="links-created-by-a-and-area-elements:concept-supported-tokens-2" data-x-internal="concept-supported-tokens">supported tokens</a> are <code id="links-created-by-a-and-area-elements:link-type-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code>, <code id="links-created-by-a-and-area-elements:link-type-noopener"><a href="#link-type-noopener">noopener</a></code>, and <code id="links-created-by-a-and-area-elements:link-type-opener"><a href="#link-type-opener">opener</a></code>. <code id="links-created-by-a-and-area-elements:attr-hyperlink-rel-2"><a href="#attr-hyperlink-rel">rel</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="links-created-by-a-and-area-elements:concept-supported-tokens-3" data-x-internal="concept-supported-tokens">supported tokens</a> must only include the tokens from this
  list that the user agent implements the processing model for.</p>

  <p>The <code id="links-created-by-a-and-area-elements:attr-hyperlink-rel-3"><a href="#attr-hyperlink-rel">rel</a></code> attribute has no default value. If the
  attribute is omitted or if none of the values in the attribute are recognized by the user agent,
  then the document has no particular relationship with the destination resource other than there
  being a hyperlink between the two.</p>

  <p>The <dfn data-dfn-for="a,area" id="attr-hyperlink-hreflang" data-dfn-type="element-attr"><code>hreflang</code></dfn>
  attribute on <code id="links-created-by-a-and-area-elements:the-a-element-6"><a href="#the-a-element">a</a></code> elements that create <a href="#hyperlink" id="links-created-by-a-and-area-elements:hyperlink">hyperlinks</a>, if
  present, gives the language of the linked resource. It is purely advisory. The value must be a
  valid BCP 47 language tag. <a href="#refsBCP47">[BCP47]</a> User agents must not consider this
  attribute authoritative — upon fetching the resource, user agents must use only language
  information associated with the resource to determine its language, not metadata included in the
  link to the resource.</p>

  <p>The <dfn data-dfn-for="a,area" id="attr-hyperlink-type" data-dfn-type="element-attr"><code>type</code></dfn>
  attribute, if present, gives the <a id="links-created-by-a-and-area-elements:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> of the linked resource. It is purely
  advisory. The value must be a <a id="links-created-by-a-and-area-elements:valid-mime-type-string" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">valid MIME type string</a>. User agents must
  not consider the <code id="links-created-by-a-and-area-elements:attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code> attribute authoritative —
  upon fetching the resource, user agents must not use metadata included in the link to the resource
  to determine its type.</p>

  <p>The <dfn data-dfn-for="a,area" id="attr-hyperlink-referrerpolicy" data-dfn-type="element-attr"><code>referrerpolicy</code></dfn> attribute is a <a href="#referrer-policy-attribute" id="links-created-by-a-and-area-elements:referrer-policy-attribute">referrer
  policy attribute</a>. Its purpose is to set the <a id="links-created-by-a-and-area-elements:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a> used when
  <a href="#following-hyperlinks-2" id="links-created-by-a-and-area-elements:following-hyperlinks-2-2">following hyperlinks</a>. <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p>

  <hr>

  <p>When an <code id="links-created-by-a-and-area-elements:the-a-element-7"><a href="#the-a-element">a</a></code> or <code id="links-created-by-a-and-area-elements:the-area-element-6"><a href="#the-area-element">area</a></code> element's <a id="links-created-by-a-and-area-elements:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> is
  invoked, the user agent may allow the user to indicate a preference regarding whether the
  hyperlink is to be used for <a href="#navigate" id="links-created-by-a-and-area-elements:navigate">navigation</a> or whether the resource it
  specifies is to be downloaded.</p>

  <p>In the absence of a user preference, the default should be navigation if the element has no
  <code id="links-created-by-a-and-area-elements:attr-hyperlink-download"><a href="#attr-hyperlink-download">download</a></code> attribute, and should be to download the
  specified resource if it does.</p>

  <div data-algorithm="">
  <p>The <a id="links-created-by-a-and-area-elements:activation-behaviour-2" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> of an <code id="links-created-by-a-and-area-elements:the-a-element-8"><a href="#the-a-element">a</a></code> or <code id="links-created-by-a-and-area-elements:the-area-element-7"><a href="#the-area-element">area</a></code> element
  <var>element</var> given an event <var>event</var> is:</p>

  <ol><li><p>If <var>element</var> has no <code id="links-created-by-a-and-area-elements:attr-hyperlink-href-3"><a href="#attr-hyperlink-href">href</a></code> attribute,
   then return.</p></li><li><p>Let <var>hyperlinkSuffix</var> be null.</p></li><li><p>If <var>element</var> is an <code id="links-created-by-a-and-area-elements:the-a-element-9"><a href="#the-a-element">a</a></code> element, and <var>event</var>'s <a href="https://dom.spec.whatwg.org/#concept-event-target" id="links-created-by-a-and-area-elements:concept-event-target" data-x-internal="concept-event-target">target</a> is an <code id="links-created-by-a-and-area-elements:the-img-element"><a href="#the-img-element">img</a></code> with an <code id="links-created-by-a-and-area-elements:attr-img-ismap"><a href="#attr-img-ismap">ismap</a></code> attribute specified, then:</p>

    <ol><li><p>Let <var>x</var> and <var>y</var> be 0.</p></li><li><p>If <var>event</var>'s <code id="links-created-by-a-and-area-elements:dom-event-istrusted"><a data-x-internal="dom-event-istrusted" href="https://dom.spec.whatwg.org/#dom-event-istrusted">isTrusted</a></code> attribute is
     initialized to true, then set <var>x</var> to the distance in <a href="https://drafts.csswg.org/css-values/#px" id="links-created-by-a-and-area-elements:'px'" data-x-internal="'px'">CSS
     pixels</a> from the left edge of the image to the location of the click, and set
     <var>y</var> to the distance in <a href="https://drafts.csswg.org/css-values/#px" id="links-created-by-a-and-area-elements:'px'-2" data-x-internal="'px'">CSS pixels</a> from the top edge of the
     image to the location of the click.</p></li><li><p>If <var>x</var> is negative, set <var>x</var> to 0.</p></li><li><p>If <var>y</var> is negative, set <var>y</var> to 0.</p></li><li><p>Set <var>hyperlinkSuffix</var> to the concatenation of U+003F (?), the value of
     <var>x</var> expressed as a base-ten integer using <a id="links-created-by-a-and-area-elements:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, U+002C (,), and
     the value of <var>y</var> expressed as a base-ten integer using <a id="links-created-by-a-and-area-elements:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
     digits</a>.</p></li></ol>
   </li><li><p>Let <var>userInvolvement</var> be <var>event</var>'s <a href="#event-uni" id="links-created-by-a-and-area-elements:event-uni">user
   navigation involvement</a>.</p></li><li>
    <p>If the user has expressed a preference to download the hyperlink, then set
    <var>userInvolvement</var> to "<code id="links-created-by-a-and-area-elements:uni-browser-ui"><a href="#uni-browser-ui">browser UI</a></code>".</p>

    <p class="note">That is, if the user has expressed a specific preference for downloading, this
    no longer counts as merely "<code id="links-created-by-a-and-area-elements:uni-activation"><a href="#uni-activation">activation</a></code>".</p>
   </li><li><p>If <var>element</var> has a <code id="links-created-by-a-and-area-elements:attr-hyperlink-download-2"><a href="#attr-hyperlink-download">download</a></code>
   attribute, or if the user has expressed a preference to download the hyperlink, then <a href="#downloading-hyperlinks" id="links-created-by-a-and-area-elements:downloading-hyperlinks-2">download the hyperlink</a> created by <var>element</var> with
   <i id="links-created-by-a-and-area-elements:downloading-hyperlinksuffix"><a href="#downloading-hyperlinksuffix">hyperlinkSuffix</a></i> set to <var>hyperlinkSuffix</var> and
   <i id="links-created-by-a-and-area-elements:downloading-userinvolvement"><a href="#downloading-userinvolvement">userInvolvement</a></i> set to
   <var>userInvolvement</var>.</p></li><li><p>Otherwise, <a href="#following-hyperlinks-2" id="links-created-by-a-and-area-elements:following-hyperlinks-2-3">follow the hyperlink</a> created by
   <var>element</var> with <i id="links-created-by-a-and-area-elements:following-hyperlinksuffix"><a href="#following-hyperlinksuffix">hyperlinkSuffix</a></i> set to
   <var>hyperlinkSuffix</var> and <i id="links-created-by-a-and-area-elements:following-userinvolvement"><a href="#following-userinvolvement">userInvolvement</a></i> set to
   <var>userInvolvement</var>.</p></li></ol>
  </div>


  <h4 id="api-for-a-and-area-elements"><span class="secno">4.6.3</span> API for <code id="api-for-a-and-area-elements:the-a-element"><a href="#the-a-element">a</a></code> and <code id="api-for-a-and-area-elements:the-area-element"><a href="#the-area-element">area</a></code> elements<a href="#api-for-a-and-area-elements" class="self-link"></a></h4>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="htmlhyperlinkelementutils" data-dfn-type="interface"><c- g="">HTMLHyperlinkElementUtils</c-></dfn> {
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="api-for-a-and-area-elements:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">stringifier</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-href" id="api-for-a-and-area-elements:dom-hyperlink-href"><c- g="">href</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-origin" id="api-for-a-and-area-elements:dom-hyperlink-origin"><c- g="">origin</c-></a>;
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-protocol" id="api-for-a-and-area-elements:dom-hyperlink-protocol"><c- g="">protocol</c-></a>;
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-username" id="api-for-a-and-area-elements:dom-hyperlink-username"><c- g="">username</c-></a>;
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-password" id="api-for-a-and-area-elements:dom-hyperlink-password"><c- g="">password</c-></a>;
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-host" id="api-for-a-and-area-elements:dom-hyperlink-host"><c- g="">host</c-></a>;
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-hostname" id="api-for-a-and-area-elements:dom-hyperlink-hostname"><c- g="">hostname</c-></a>;
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions-7"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-port" id="api-for-a-and-area-elements:dom-hyperlink-port"><c- g="">port</c-></a>;
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions-8"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-pathname" id="api-for-a-and-area-elements:dom-hyperlink-pathname"><c- g="">pathname</c-></a>;
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions-9"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-search" id="api-for-a-and-area-elements:dom-hyperlink-search"><c- g="">search</c-></a>;
  [<a href="#cereactions" id="api-for-a-and-area-elements:cereactions-10"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hyperlink-hash" id="api-for-a-and-area-elements:dom-hyperlink-hash"><c- g="">hash</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>hyperlink</var>.<span>toString()</span></code></dt><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-href" id="dom-hyperlink-href-dev">href</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/href" title="The HTMLAnchorElement.href property is a stringifier that returns a string containing the whole URL, and allows the href to be updated.">HTMLAnchorElement/href</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/toString" title="The HTMLAnchorElement.toString() stringifier method returns a string containing the whole URL. It is a read-only version of HTMLAnchorElement.href.">HTMLAnchorElement/toString</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>52+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/href" title="The HTMLAreaElement.href property is a stringifier that returns a string containing the whole URL, and allows the href to be updated.">HTMLAreaElement/href</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/toString" title="The HTMLAreaElement.toString() stringifier method returns a string containing the whole URL. It is a read-only version of HTMLAreaElement.href.">HTMLAreaElement/toString</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>32+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL.</p>

    <p>Can be set, to change the URL.</p>
   </dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-origin" id="dom-hyperlink-origin-dev">origin</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/origin" title="The HTMLAnchorElement.origin read-only property is a string containing the Unicode serialization of the origin of the represented URL.">HTMLAnchorElement/origin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>26+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/origin" title="The HTMLAreaElement.origin read-only property is a string containing the Unicode serialization of the origin of the represented URL.">HTMLAreaElement/origin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>26+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>32+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the hyperlink's URL's origin.</p></dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-protocol" id="dom-hyperlink-protocol-dev">protocol</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/protocol" title="The HTMLAnchorElement.protocol property is a string representing the protocol scheme of the URL, including the final ':'.">HTMLAnchorElement/protocol</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/protocol" title="The HTMLAreaElement.protocol property is a string representing the protocol scheme of the URL, including the final ':'.">HTMLAreaElement/protocol</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL's scheme.</p>

    <p>Can be set, to change the URL's scheme.</p>
   </dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-username" id="dom-hyperlink-username-dev">username</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/username" title="The HTMLAnchorElement.username property is a string containing the username specified before the domain name.">HTMLAnchorElement/username</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>26+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>32+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/username" title="The HTMLAreaElement.username property is a string containing the username specified before the domain name.">HTMLAreaElement/username</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>26+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>32+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL's username.</p>

    <p>Can be set, to change the URL's username.</p>
   </dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-password" id="dom-hyperlink-password-dev">password</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/password" title="The HTMLAnchorElement.password property is a string containing the password specified before the domain name.">HTMLAnchorElement/password</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>26+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>32+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/password" title="The HTMLAreaElement.password property is a string containing the password specified before the domain name.">HTMLAreaElement/password</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>26+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>32+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL's password.</p>

    <p>Can be set, to change the URL's password.</p>
   </dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-host" id="dom-hyperlink-host-dev">host</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/host" title="The HTMLAnchorElement.host property is a string containing the host, that is the hostname, and then, if the port of the URL is nonempty, a ':', and the port of the URL.">HTMLAnchorElement/host</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/host" title="The HTMLAreaElement.host property is a string containing the host, that is the hostname, and then, if the port of the URL is nonempty, a ':', and the port of the URL.">HTMLAreaElement/host</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL's host and port (if different from the default port for the
    scheme).</p>

    <p>Can be set, to change the URL's host and port.</p>
   </dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-hostname" id="dom-hyperlink-hostname-dev">hostname</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/hostname" title="The HTMLAnchorElement.hostname property is a string containing the domain of the URL.">HTMLAnchorElement/hostname</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/hostname" title="The HTMLAreaElement.hostname property is a string containing the domain of the URL.">HTMLAreaElement/hostname</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL's host.</p>

    <p>Can be set, to change the URL's host.</p>
   </dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-port" id="dom-hyperlink-port-dev">port</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/port" title="The HTMLAnchorElement.port property is a string containing the port number of the URL. If the URL does not contain an explicit port number, it will be set to ''.">HTMLAnchorElement/port</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/port" title="The HTMLAreaElement.port property is a string containing the port number of the URL. If the URL does not contain an explicit port number, it will be set to ''.">HTMLAreaElement/port</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL's port.</p>

    <p>Can be set, to change the URL's port.</p>
   </dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-pathname" id="dom-hyperlink-pathname-dev">pathname</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/pathname" title="The HTMLAnchorElement.pathname property is a string containing an initial '/' followed by the path of the URL not including the query string or fragment (or the empty string if there is no path).">HTMLAnchorElement/pathname</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/pathname" title="The HTMLAreaElement.pathname property is a string containing an initial '/' followed by the path of the URL not including the query string or fragment (or the empty string if there is no path).">HTMLAreaElement/pathname</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL's path.</p>

    <p>Can be set, to change the URL's path.</p>
   </dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-search" id="dom-hyperlink-search-dev">search</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/search" title="The HTMLAnchorElement.search property is a search string, also called a query string, that is a string containing a '?' followed by the parameters of the URL.">HTMLAnchorElement/search</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/search" title="The HTMLAreaElement.search property is a search string, also called a query string, that is a string containing a '?' followed by the parameters of the URL.">HTMLAreaElement/search</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL's query (includes leading "<code>?</code>" if
    non-empty).</p>

    <p>Can be set, to change the URL's query (ignores leading "<code>?</code>").</p>
   </dd><dt><code><var>hyperlink</var>.<a href="#dom-hyperlink-hash" id="dom-hyperlink-hash-dev">hash</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/hash" title="The HTMLAnchorElement.hash property returns a string containing a '#' followed by the fragment identifier of the URL.">HTMLAnchorElement/hash</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/hash" title="The HTMLAreaElement.hash property returns a string containing a '#' followed by the fragment identifier of the URL.">HTMLAreaElement/hash</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the hyperlink's URL's fragment (includes leading "<code>#</code>" if
    non-empty).</p>

    <p>Can be set, to change the URL's fragment (ignores leading "<code>#</code>").</p>
   </dd></dl>

  

  <p>An element implementing the <code id="api-for-a-and-area-elements:htmlhyperlinkelementutils"><a href="#htmlhyperlinkelementutils">HTMLHyperlinkElementUtils</a></code> mixin has an associated <dfn id="concept-hyperlink-url">url</dfn> (null or a <a id="api-for-a-and-area-elements:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>). It is initially null.

  </p><div data-algorithm="">
  <p>An element implementing the <code id="api-for-a-and-area-elements:htmlhyperlinkelementutils-2"><a href="#htmlhyperlinkelementutils">HTMLHyperlinkElementUtils</a></code> mixin has an associated <dfn id="concept-hyperlink-url-set">set the url</dfn> algorithm, which runs these steps:</p>

  <ol><li><p>Set this element's <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url">url</a> to null.</p></li><li><p>If this element's <code id="api-for-a-and-area-elements:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> content attribute is
   absent, then return.</p></li><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="api-for-a-and-area-elements:encoding-parsing-a-url">encoding-parsing a URL</a> given this
   element's <code id="api-for-a-and-area-elements:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> content attribute's value, relative to
   this element's <a id="api-for-a-and-area-elements:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>url</var> is not failure, then set this element's <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-2">url</a> to <var>url</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When elements implementing the <code id="api-for-a-and-area-elements:htmlhyperlinkelementutils-3"><a href="#htmlhyperlinkelementutils">HTMLHyperlinkElementUtils</a></code> mixin are created, the
  user agent must <a href="#concept-hyperlink-url-set" id="api-for-a-and-area-elements:concept-hyperlink-url-set">set the url</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#html-element-insertion-steps" id="api-for-a-and-area-elements:html-element-insertion-steps">HTML element insertion steps</a> for <code id="api-for-a-and-area-elements:the-a-element-2"><a href="#the-a-element">a</a></code> and <code id="api-for-a-and-area-elements:the-area-element-2"><a href="#the-area-element">area</a></code>
  elements, given <var>insertedNode</var>, are:</p>

  <ol><li><p>If <var>insertedNode</var> is not <a id="api-for-a-and-area-elements:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li><p><a href="#consider-speculative-loads" id="api-for-a-and-area-elements:consider-speculative-loads">Consider speculative loads</a> given <var>insertedNode</var>'s <a id="api-for-a-and-area-elements:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#html-element-removing-steps" id="api-for-a-and-area-elements:html-element-removing-steps">HTML element removing steps</a> for <code id="api-for-a-and-area-elements:the-a-element-3"><a href="#the-a-element">a</a></code> and <code id="api-for-a-and-area-elements:the-area-element-3"><a href="#the-area-element">area</a></code> elements,
  given <var>removedNode</var> and <var>oldParent</var>, are:</p>

  <ol><li><p>If <var>oldParent</var> is not <a id="api-for-a-and-area-elements:connected-2" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li><p><a href="#consider-speculative-loads" id="api-for-a-and-area-elements:consider-speculative-loads-2">Consider speculative loads</a> given <var>oldParent</var>'s <a id="api-for-a-and-area-elements:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#html-element-moving-steps" id="api-for-a-and-area-elements:html-element-moving-steps">HTML element moving steps</a> for <code id="api-for-a-and-area-elements:the-a-element-4"><a href="#the-a-element">a</a></code> and <code id="api-for-a-and-area-elements:the-area-element-4"><a href="#the-area-element">area</a></code> elements,
  given <var>movedNode</var>, are:</p>

  <ol><li><p><a href="#consider-speculative-loads" id="api-for-a-and-area-elements:consider-speculative-loads-3">Consider speculative loads</a> given <var>movedNode</var>'s <a id="api-for-a-and-area-elements:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The following <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="api-for-a-and-area-elements:concept-element-attributes-change-ext" data-x-internal="concept-element-attributes-change-ext">attribute change
  steps</a>, given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
  <var>value</var>, and <var>namespace</var>, are used for all <code id="api-for-a-and-area-elements:the-a-element-5"><a href="#the-a-element">a</a></code> and <code id="api-for-a-and-area-elements:the-area-element-5"><a href="#the-area-element">area</a></code>
  elements:</p>

  <ol><li><p>If <var>namespace</var> is not null, then return.</p></li><li><p>If <var>oldValue</var> equals <var>value</var>, then return.</p></li><li>
    <p>If <var>localName</var> is <code id="api-for-a-and-area-elements:attr-hyperlink-href-3"><a href="#attr-hyperlink-href">href</a></code>, then <a href="#concept-hyperlink-url-set" id="api-for-a-and-area-elements:concept-hyperlink-url-set-2">set the url</a> given <var>element</var>.</p>

    <p class="note">This is only observable for <code id="api-for-a-and-area-elements:blob-protocol"><a data-x-internal="blob-protocol" href="https://w3c.github.io/FileAPI/#DefinitionOfScheme">blob:</a></code> URLs as
    <a href="https://url.spec.whatwg.org/#concept-url-parser" id="api-for-a-and-area-elements:url-parser" data-x-internal="url-parser">parsing</a> them involves a <a id="api-for-a-and-area-elements:blob-url-store" href="https://w3c.github.io/FileAPI/#BlobURLStore" data-x-internal="blob-url-store">Blob URL Store</a> lookup.</p>
   </li><li><p>If <var>localName</var> is <code id="api-for-a-and-area-elements:attr-hyperlink-href-4"><a href="#attr-hyperlink-href">href</a></code>, <code id="api-for-a-and-area-elements:attr-hyperlink-referrerpolicy"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code>, or <code id="api-for-a-and-area-elements:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code>, then <a href="#consider-speculative-loads" id="api-for-a-and-area-elements:consider-speculative-loads-4">consider speculative loads</a> given
   <var>element</var>'s <a id="api-for-a-and-area-elements:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>An element implementing the <code id="api-for-a-and-area-elements:htmlhyperlinkelementutils-4"><a href="#htmlhyperlinkelementutils">HTMLHyperlinkElementUtils</a></code> mixin has an associated
  <dfn id="reinitialise-url">reinitialize url</dfn> algorithm, which runs these
  steps:</p>

  <ol><li><p>If the element's <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-3">url</a> is non-null, its <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="api-for-a-and-area-elements:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is "<code>blob</code>", and it has an
   <a id="api-for-a-and-area-elements:opaque-path" href="https://url.spec.whatwg.org/#url-opaque-path" data-x-internal="opaque-path">opaque path</a>, then terminate these steps.</p></li><li><p><a href="#concept-hyperlink-url-set" id="api-for-a-and-area-elements:concept-hyperlink-url-set-3">Set the url</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="update-href">update <code>href</code></dfn>, set the element's <code id="api-for-a-and-area-elements:attr-hyperlink-href-5"><a href="#attr-hyperlink-href">href</a></code> content attribute's value to the element's <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-4">url</a>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="api-for-a-and-area-elements:concept-url-serializer" data-x-internal="concept-url-serializer">serialized</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-href" data-dfn-type="attribute"><code>href</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-5">url</a>.</p></li><li><p>If <var>url</var> is null and <a id="api-for-a-and-area-elements:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> has no <code id="api-for-a-and-area-elements:attr-hyperlink-href-6"><a href="#attr-hyperlink-href">href</a></code> content attribute, return the empty string.

   </p></li><li><p>Otherwise, if <var>url</var> is null, return <a id="api-for-a-and-area-elements:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="api-for-a-and-area-elements:attr-hyperlink-href-7"><a href="#attr-hyperlink-href">href</a></code> content attribute's value.</p></li><li><p>Return <var>url</var>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="api-for-a-and-area-elements:concept-url-serializer-2" data-x-internal="concept-url-serializer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-origin" data-dfn-type="attribute"><code>origin</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-2">Reinitialize url</a>.</p></li><li><p>If <a id="api-for-a-and-area-elements:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-6">url</a> is null, return the
   empty string.</p></li><li><p>Return the <a href="#ascii-serialisation-of-an-origin" id="api-for-a-and-area-elements:ascii-serialisation-of-an-origin">serialization</a> of
   <a id="api-for-a-and-area-elements:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-7">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="api-for-a-and-area-elements:concept-url-origin" data-x-internal="concept-url-origin">origin</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-protocol" data-dfn-type="attribute"><code>protocol</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-3">Reinitialize url</a>.</p></li><li><p>If <a id="api-for-a-and-area-elements:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-8">url</a> is null, return
   "<code>:</code>".</p></li><li><p>Return <a id="api-for-a-and-area-elements:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-9">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="api-for-a-and-area-elements:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a>, followed by "<code>:</code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="api-for-a-and-area-elements:dom-hyperlink-protocol-2"><a href="#dom-hyperlink-protocol">protocol</a></code> setter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-4">Reinitialize url</a>.</p></li><li><p>If <a id="api-for-a-and-area-elements:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-10">url</a> is null, then
   return.</p></li><li>
    <p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="api-for-a-and-area-elements:basic-url-parser" data-x-internal="basic-url-parser">Basic URL parse</a> the given value, followed by "<code>:</code>", with <a id="api-for-a-and-area-elements:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-11">url</a> as
    <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="api-for-a-and-area-elements:basic-url-parser-url" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="api-for-a-and-area-elements:scheme-start-state" href="https://url.spec.whatwg.org/#scheme-start-state" data-x-internal="scheme-start-state">scheme start state</a> as
    <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="api-for-a-and-area-elements:basic-url-parser-state-override" data-x-internal="basic-url-parser-state-override"><i>state override</i></a>.</p>

    <p class="note">Because the URL parser ignores multiple consecutive colons, providing a value
    of "<code>https:</code>" (or even "<code>https::::</code>") is the same as
    providing a value of "<code>https</code>".</p>
   </li><li><p><a href="#update-href" id="api-for-a-and-area-elements:update-href">Update <code>href</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-username" data-dfn-type="attribute"><code>username</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-5">Reinitialize url</a>.</p></li><li><p>If <a id="api-for-a-and-area-elements:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-12">url</a> is null, return the
   empty string.</p></li><li><p>Return <a id="api-for-a-and-area-elements:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-13">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-username" id="api-for-a-and-area-elements:concept-url-username" data-x-internal="concept-url-username">username</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="api-for-a-and-area-elements:dom-hyperlink-username-2"><a href="#dom-hyperlink-username">username</a></code> setter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-6">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-14">url</a>.</p></li><li><p>If <var>url</var> is null or <var>url</var>
   <a id="api-for-a-and-area-elements:cannot-have-a-username/password/port" href="https://url.spec.whatwg.org/#cannot-have-a-username-password-port" data-x-internal="cannot-have-a-username/password/port">cannot have a username/password/port</a>, then return.</p></li><li><p><a id="api-for-a-and-area-elements:set-the-username" href="https://url.spec.whatwg.org/#set-the-username" data-x-internal="set-the-username">Set the username</a>, given <var>url</var> and the given value.</p></li><li><p><a href="#update-href" id="api-for-a-and-area-elements:update-href-2">Update <code>href</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-password" data-dfn-type="attribute"><code>password</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-7">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-15">url</a>.</p></li><li><p>If <var>url</var> is null, then return the empty string.</p></li><li><p>Return <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-password" id="api-for-a-and-area-elements:concept-url-password" data-x-internal="concept-url-password">password</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="api-for-a-and-area-elements:dom-hyperlink-password-2"><a href="#dom-hyperlink-password">password</a></code> setter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-8">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-16">url</a>.</p></li><li><p>If <var>url</var> is null or <var>url</var>
   <a id="api-for-a-and-area-elements:cannot-have-a-username/password/port-2" href="https://url.spec.whatwg.org/#cannot-have-a-username-password-port" data-x-internal="cannot-have-a-username/password/port">cannot have a username/password/port</a>, then return.</p></li><li><p><a id="api-for-a-and-area-elements:set-the-password" href="https://url.spec.whatwg.org/#set-the-password" data-x-internal="set-the-password">Set the password</a>, given <var>url</var> and the given value.</p></li><li><p><a href="#update-href" id="api-for-a-and-area-elements:update-href-3">Update <code>href</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-host" data-dfn-type="attribute"><code>host</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-9">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-17">url</a>.</p></li><li><p>If <var>url</var> or <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="api-for-a-and-area-elements:concept-url-host" data-x-internal="concept-url-host">host</a> is null,
   return the empty string.</p></li><li><p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="api-for-a-and-area-elements:concept-url-port" data-x-internal="concept-url-port">port</a> is null, return
   <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="api-for-a-and-area-elements:concept-url-host-2" data-x-internal="concept-url-host">host</a>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="api-for-a-and-area-elements:host-serializer" data-x-internal="host-serializer">serialized</a>.</p></li><li><p>Return <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="api-for-a-and-area-elements:concept-url-host-3" data-x-internal="concept-url-host">host</a>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="api-for-a-and-area-elements:host-serializer-2" data-x-internal="host-serializer">serialized</a>, followed by "<code>:</code>" and <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="api-for-a-and-area-elements:concept-url-port-2" data-x-internal="concept-url-port">port</a>, <a href="https://url.spec.whatwg.org/#serialize-an-integer" id="api-for-a-and-area-elements:serialize-an-integer" data-x-internal="serialize-an-integer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="api-for-a-and-area-elements:dom-hyperlink-host-2"><a href="#dom-hyperlink-host">host</a></code> setter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-10">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-16" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-18">url</a>.</p></li><li><p>If <var>url</var> is null or <var>url</var> has an <a id="api-for-a-and-area-elements:opaque-path-2" href="https://url.spec.whatwg.org/#url-opaque-path" data-x-internal="opaque-path">opaque path</a>, then
   return.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="api-for-a-and-area-elements:basic-url-parser-2" data-x-internal="basic-url-parser">Basic URL parse</a> the given value, with
   <var>url</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="api-for-a-and-area-elements:basic-url-parser-url-2" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="api-for-a-and-area-elements:host-state" href="https://url.spec.whatwg.org/#host-state" data-x-internal="host-state">host
   state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="api-for-a-and-area-elements:basic-url-parser-state-override-2" data-x-internal="basic-url-parser-state-override"><i>state
   override</i></a>.</p></li><li><p><a href="#update-href" id="api-for-a-and-area-elements:update-href-4">Update <code>href</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-hostname" data-dfn-type="attribute"><code>hostname</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-11">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-17" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-19">url</a>.</p></li><li><p>If <var>url</var> or <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="api-for-a-and-area-elements:concept-url-host-4" data-x-internal="concept-url-host">host</a> is null,
   return the empty string.</p></li><li><p>Return <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="api-for-a-and-area-elements:concept-url-host-5" data-x-internal="concept-url-host">host</a>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="api-for-a-and-area-elements:host-serializer-3" data-x-internal="host-serializer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="api-for-a-and-area-elements:dom-hyperlink-hostname-2"><a href="#dom-hyperlink-hostname">hostname</a></code> setter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-12">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-18" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-20">url</a>.</p></li><li><p>If <var>url</var> is null or <var>url</var> has an <a id="api-for-a-and-area-elements:opaque-path-3" href="https://url.spec.whatwg.org/#url-opaque-path" data-x-internal="opaque-path">opaque path</a>, then
   return.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="api-for-a-and-area-elements:basic-url-parser-3" data-x-internal="basic-url-parser">Basic URL parse</a> the given value, with
   <var>url</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="api-for-a-and-area-elements:basic-url-parser-url-3" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="api-for-a-and-area-elements:hostname-state" href="https://url.spec.whatwg.org/#hostname-state" data-x-internal="hostname-state">hostname
   state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="api-for-a-and-area-elements:basic-url-parser-state-override-3" data-x-internal="basic-url-parser-state-override"><i>state
   override</i></a>.</p></li><li><p><a href="#update-href" id="api-for-a-and-area-elements:update-href-5">Update <code>href</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-port" data-dfn-type="attribute"><code>port</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-13">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-19" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-21">url</a>.</p></li><li><p>If <var>url</var> or <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="api-for-a-and-area-elements:concept-url-port-3" data-x-internal="concept-url-port">port</a> is null,
   return the empty string.</p></li><li><p>Return <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="api-for-a-and-area-elements:concept-url-port-4" data-x-internal="concept-url-port">port</a>, <a href="https://url.spec.whatwg.org/#serialize-an-integer" id="api-for-a-and-area-elements:serialize-an-integer-2" data-x-internal="serialize-an-integer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="api-for-a-and-area-elements:dom-hyperlink-port-2"><a href="#dom-hyperlink-port">port</a></code> setter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-14">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-20" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-22">url</a>.</p></li><li><p>If <var>url</var> is null or <var>url</var>
   <a id="api-for-a-and-area-elements:cannot-have-a-username/password/port-3" href="https://url.spec.whatwg.org/#cannot-have-a-username-password-port" data-x-internal="cannot-have-a-username/password/port">cannot have a username/password/port</a>, then return.</p></li><li><p>If the given value is the empty string, then set <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="api-for-a-and-area-elements:concept-url-port-5" data-x-internal="concept-url-port">port</a> to null.</p></li><li><p>Otherwise, <a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="api-for-a-and-area-elements:basic-url-parser-4" data-x-internal="basic-url-parser">basic URL parse</a> the given value, with
   <var>url</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="api-for-a-and-area-elements:basic-url-parser-url-4" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="api-for-a-and-area-elements:port-state" href="https://url.spec.whatwg.org/#port-state" data-x-internal="port-state">port
   state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="api-for-a-and-area-elements:basic-url-parser-state-override-4" data-x-internal="basic-url-parser-state-override"><i>state
   override</i></a>.</p></li><li><p><a href="#update-href" id="api-for-a-and-area-elements:update-href-6">Update <code>href</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-pathname" data-dfn-type="attribute"><code>pathname</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-15">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-21" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-23">url</a>.</p></li><li><p>If <var>url</var> is null, then return the empty string.</p></li><li><p>Return the result of <a href="https://url.spec.whatwg.org/#url-path-serializer" id="api-for-a-and-area-elements:url-path-serializer" data-x-internal="url-path-serializer">URL path serializing</a>
   <var>url</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="api-for-a-and-area-elements:dom-hyperlink-pathname-2"><a href="#dom-hyperlink-pathname">pathname</a></code> setter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-16">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-22" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-24">url</a>.</p></li><li><p>If <var>url</var> is null or <var>url</var> has an <a id="api-for-a-and-area-elements:opaque-path-4" href="https://url.spec.whatwg.org/#url-opaque-path" data-x-internal="opaque-path">opaque path</a>, then
   return.</p></li><li><p>Set <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-path" id="api-for-a-and-area-elements:concept-url-path" data-x-internal="concept-url-path">path</a> to the empty
   list.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="api-for-a-and-area-elements:basic-url-parser-5" data-x-internal="basic-url-parser">Basic URL parse</a> the given value, with
   <var>url</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="api-for-a-and-area-elements:basic-url-parser-url-5" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="api-for-a-and-area-elements:path-start-state" href="https://url.spec.whatwg.org/#path-start-state" data-x-internal="path-start-state">path start
   state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="api-for-a-and-area-elements:basic-url-parser-state-override-5" data-x-internal="basic-url-parser-state-override"><i>state
   override</i></a>.</p></li><li><p><a href="#update-href" id="api-for-a-and-area-elements:update-href-7">Update <code>href</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-search" data-dfn-type="attribute"><code>search</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-17">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-23" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-25">url</a>.</p></li><li><p>If <var>url</var> is null, or <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="api-for-a-and-area-elements:concept-url-query" data-x-internal="concept-url-query">query</a> is either null or the empty string, return the empty
   string.</p></li><li><p>Return "<code>?</code>", followed by <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="api-for-a-and-area-elements:concept-url-query-2" data-x-internal="concept-url-query">query</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="api-for-a-and-area-elements:dom-hyperlink-search-2"><a href="#dom-hyperlink-search">search</a></code> setter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-18">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-24" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-26">url</a>.</p></li><li><p>If <var>url</var> is null, terminate these steps.</p></li><li><p>If the given value is the empty string, set <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="api-for-a-and-area-elements:concept-url-query-3" data-x-internal="concept-url-query">query</a> to null.

   </p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>input</var> be the given value with a single leading "<code>?</code>"
     removed, if any.</p></li><li><p>Set <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="api-for-a-and-area-elements:concept-url-query-4" data-x-internal="concept-url-query">query</a> to the empty
     string.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="api-for-a-and-area-elements:basic-url-parser-6" data-x-internal="basic-url-parser">Basic URL parse</a> <var>input</var>, with
     <var>url</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="api-for-a-and-area-elements:basic-url-parser-url-6" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="api-for-a-and-area-elements:query-state" href="https://url.spec.whatwg.org/#query-state" data-x-internal="query-state">query
     state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="api-for-a-and-area-elements:basic-url-parser-state-override-6" data-x-internal="basic-url-parser-state-override"><i>state
     override</i></a>.</p></li></ol>
   </li><li><p><a href="#update-href" id="api-for-a-and-area-elements:update-href-8">Update <code>href</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLHyperlinkElementUtils" id="dom-hyperlink-hash" data-dfn-type="attribute"><code>hash</code></dfn> getter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-19">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-25" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-27">url</a>.</p></li><li><p>If <var>url</var> is null, or <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="api-for-a-and-area-elements:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> is either null or the empty string, return the
   empty string.</p></li><li><p>Return "<code>#</code>", followed by <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="api-for-a-and-area-elements:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="api-for-a-and-area-elements:dom-hyperlink-hash-2"><a href="#dom-hyperlink-hash">hash</a></code> setter steps are:</p>

  <ol><li><p><a href="#reinitialise-url" id="api-for-a-and-area-elements:reinitialise-url-20">Reinitialize url</a>.</p></li><li><p>Let <var>url</var> be <a id="api-for-a-and-area-elements:this-26" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-hyperlink-url" id="api-for-a-and-area-elements:concept-hyperlink-url-28">url</a>.</p></li><li><p>If <var>url</var> is null, then return.</p></li><li><p>If the given value is the empty string, set <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="api-for-a-and-area-elements:concept-url-fragment-3" data-x-internal="concept-url-fragment">fragment</a> to null.

   </p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>input</var> be the given value with a single leading "<code>#</code>"
     removed, if any.</p></li><li><p>Set <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="api-for-a-and-area-elements:concept-url-fragment-4" data-x-internal="concept-url-fragment">fragment</a> to the empty
     string.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="api-for-a-and-area-elements:basic-url-parser-7" data-x-internal="basic-url-parser">Basic URL parse</a> <var>input</var>, with
     <var>url</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="api-for-a-and-area-elements:basic-url-parser-url-7" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="api-for-a-and-area-elements:fragment-state" href="https://url.spec.whatwg.org/#fragment-state" data-x-internal="fragment-state">fragment
     state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="api-for-a-and-area-elements:basic-url-parser-state-override-7" data-x-internal="basic-url-parser-state-override"><i>state
     override</i></a>.</p></li></ol>
   </li><li><p><a href="#update-href" id="api-for-a-and-area-elements:update-href-9">Update <code>href</code></a>.</p></li></ol>
  </div>


  <h4 id="following-hyperlinks"><span class="secno">4.6.4</span> Following hyperlinks<a href="#following-hyperlinks" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>An element <var>element</var> <dfn id="cannot-navigate">cannot navigate</dfn> if any of the following are true:</p>

  <ul><li><p><var>element</var>'s <a id="following-hyperlinks:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="following-hyperlinks:fully-active">fully active</a>;
   or</p></li><li><p><var>element</var> is not an <code id="following-hyperlinks:the-a-element"><a href="#the-a-element">a</a></code> element and is not
   <a id="following-hyperlinks:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>.</p></li></ul>
  </div>

  <p class="note">This is also used by <a href="#concept-form-submit" id="following-hyperlinks:concept-form-submit">form submission</a> for
  the <code id="following-hyperlinks:the-form-element"><a href="#the-form-element">form</a></code> element. The exception for <code id="following-hyperlinks:the-a-element-2"><a href="#the-a-element">a</a></code> elements is for compatibility with
  web content.</p>

  <div data-algorithm="">
  <p>To <dfn id="get-an-element's-noopener">get an element's noopener</dfn>, given an <code id="following-hyperlinks:the-a-element-3"><a href="#the-a-element">a</a></code>, <code id="following-hyperlinks:the-area-element"><a href="#the-area-element">area</a></code>, or
  <code id="following-hyperlinks:the-form-element-2"><a href="#the-form-element">form</a></code> element <var>element</var>, a <a id="following-hyperlinks:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> <var>url</var>, and a
  string <var>target</var>, perform the following steps. They return a boolean.</p>

  <ol><li><p>If <var>element</var>'s <a href="#linkTypes">link types</a> include the <code id="following-hyperlinks:link-type-noopener"><a href="#link-type-noopener">noopener</a></code> or <code id="following-hyperlinks:link-type-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code>
   keyword, then return true.</p></li><li id="opener-processing-model"><p>If <var>element</var>'s <a href="#linkTypes">link types</a>
   do not include the <code id="following-hyperlinks:link-type-opener"><a href="#link-type-opener">opener</a></code> keyword and <var>target</var> is an
   <a id="following-hyperlinks:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>_blank</code>", then return
   true.</p></li><li>
    <p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-blob-entry" id="following-hyperlinks:concept-url-blob-entry" data-x-internal="concept-url-blob-entry">blob URL entry</a> is not
    null:</p>

    <ol><li><p>Let <var>blobOrigin</var> be <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-blob-entry" id="following-hyperlinks:concept-url-blob-entry-2" data-x-internal="concept-url-blob-entry">blob URL entry</a>'s <a href="https://w3c.github.io/FileAPI/#blob-url-entry-environment" id="following-hyperlinks:blob-url-entry-environment" data-x-internal="blob-url-entry-environment">environment</a>'s <a href="#concept-settings-object-origin" id="following-hyperlinks:concept-settings-object-origin">origin</a>.</p></li><li><p>Let <var>topLevelOrigin</var> be <var>element</var>'s <a href="#relevant-settings-object" id="following-hyperlinks:relevant-settings-object">relevant settings
     object</a>'s <a href="#concept-environment-top-level-origin" id="following-hyperlinks:concept-environment-top-level-origin">top-level origin</a>.</p></li><li><p>If <var>blobOrigin</var> is not <a href="#same-site" id="following-hyperlinks:same-site">same site</a> with <var>topLevelOrigin</var>,
     then return true.</p></li></ol>
   </li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="following-hyperlinks-2">follow the hyperlink</dfn> created by an element
  <var>subject</var>, given an optional <dfn id="following-hyperlinksuffix"><var>hyperlinkSuffix</var></dfn> (default null) and an
  optional <dfn id="following-userinvolvement"><var>userInvolvement</var></dfn> (default "<code id="following-hyperlinks:uni-none"><a href="#uni-none">none</a></code>"):</p>

  <ol><li><p>If <var>subject</var> <a href="#cannot-navigate" id="following-hyperlinks:cannot-navigate">cannot navigate</a>, then return.</p></li><li><p>Let <var>targetAttributeValue</var> be the empty string.</p></li><li><p>If <var>subject</var> is an <code id="following-hyperlinks:the-a-element-4"><a href="#the-a-element">a</a></code> or <code id="following-hyperlinks:the-area-element-2"><a href="#the-area-element">area</a></code> element, then set
   <var>targetAttributeValue</var> to the result of <a href="#get-an-element's-target" id="following-hyperlinks:get-an-element's-target">getting
   an element's target</a> given <var>subject</var>.</p></li><li><p>Let <var>urlRecord</var> be the result of <a href="#encoding-parsing-a-url" id="following-hyperlinks:encoding-parsing-a-url">encoding-parsing a URL</a> given
   <var>subject</var>'s <code id="following-hyperlinks:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute value, relative to
   <var>subject</var>'s <a id="following-hyperlinks:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>urlRecord</var> is failure, then return.</p></li><li><p>Let <var>noopener</var> be the result of <a href="#get-an-element's-noopener" id="following-hyperlinks:get-an-element's-noopener">getting
   an element's noopener</a> with <var>subject</var>, <var>urlRecord</var>, and
   <var>targetAttributeValue</var>.</p></li><li><p>Let <var>targetNavigable</var> be the first return value of applying <a href="#the-rules-for-choosing-a-navigable" id="following-hyperlinks:the-rules-for-choosing-a-navigable">the rules for
   choosing a navigable</a> given <var>targetAttributeValue</var>, <var>subject</var>'s
   <a href="#node-navigable" id="following-hyperlinks:node-navigable">node navigable</a>, and <var>noopener</var>.</p></li><li><p>If <var>targetNavigable</var> is null, then return.</p></li><li><p>Let <var>urlString</var> be the result of applying the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="following-hyperlinks:concept-url-serializer" data-x-internal="concept-url-serializer">URL serializer</a> to <var>urlRecord</var>.</p></li><li><p>If <var>hyperlinkSuffix</var> is non-null, then append it to
   <var>urlString</var>.</p></li><li>
    <p><a href="#navigate" id="following-hyperlinks:navigate">Navigate</a> <var>targetNavigable</var> to
    <var>urlString</var> using <var>subject</var>'s <a id="following-hyperlinks:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, with <i id="following-hyperlinks:navigation-referrer-policy"><a href="#navigation-referrer-policy">referrerPolicy</a></i> set to <var>subject</var>'s
    <a href="#hyperlink-referrer-policy" id="following-hyperlinks:hyperlink-referrer-policy">hyperlink referrer policy</a>, <i id="following-hyperlinks:navigation-user-involvement"><a href="#navigation-user-involvement">userInvolvement</a></i> set to <var>userInvolvement</var>, and
    <i id="following-hyperlinks:navigation-source-element"><a href="#navigation-source-element">sourceElement</a></i> set to <var>subject</var>.</p>

    <p class="note">Unlike many other types of navigations, following hyperlinks does not have
    special "<code id="following-hyperlinks:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>" behavior for when
    documents are not <a href="#completely-loaded" id="following-hyperlinks:completely-loaded">completely loaded</a>. This is true for both user-initiated instances
    of following hyperlinks, as well as script-triggered ones via, e.g., <code>aElement.click()</code>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="hyperlink-referrer-policy">hyperlink referrer policy</dfn> for an element <var>subject</var> is the value
  returned by the following steps:</p>

  <ol><li id="noreferrer-a-area-processing-model"><p>If <var>subject</var>'s <a href="#linkTypes">link
   types</a> includes the <code id="following-hyperlinks:link-type-noreferrer-2"><a href="#link-type-noreferrer">noreferrer</a></code> keyword, then return
   "<code>no-referrer</code>".</p></li><li><p>Return the current state of <var>subject</var>'s <code id="following-hyperlinks:attr-hyperlink-referrerpolicy"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code> content attribute.</p></li></ol>
  </div>

  




  <h4 id="downloading-resources"><span class="secno">4.6.5</span> Downloading resources<a href="#downloading-resources" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/download" title="The HTMLAnchorElement.download property is a string indicating that the linked resource is intended to be downloaded rather than displayed in the browser. The value, if any, specifies the default file name for use in labeling the resource in a local file system. If the name is not a valid file name in the underlying OS, the browser will adjust it.">HTMLAnchorElement/download</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>20+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>15+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>In some cases, resources are intended for later use rather than immediate viewing. To indicate
  that a resource is intended to be downloaded for use later, rather than immediately used, the
  <code id="downloading-resources:attr-hyperlink-download"><a href="#attr-hyperlink-download">download</a></code> attribute can be specified on the
  <code id="downloading-resources:the-a-element"><a href="#the-a-element">a</a></code> or <code id="downloading-resources:the-area-element"><a href="#the-area-element">area</a></code> element that creates the <a href="#hyperlink" id="downloading-resources:hyperlink">hyperlink</a> to that
  resource.</p>

  <p>The attribute can furthermore be given a value, to specify the filename that user agents are
  to use when storing the resource in a file system. This value can be overridden by the `<code id="downloading-resources:http-content-disposition"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition</a></code>` HTTP header's filename parameters.
  <a href="#refsRFC6266">[RFC6266]</a></p>

  <p>In cross-origin situations, the <code id="downloading-resources:attr-hyperlink-download-2"><a href="#attr-hyperlink-download">download</a></code>
  attribute has to be combined with the `<code id="downloading-resources:http-content-disposition-2"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition</a></code>` HTTP header, specifically with the
  <code>attachment</code> disposition type, to avoid the user being warned of possibly
  nefarious activity. (This is to protect users from being made to download sensitive personal or
  confidential information without their full understanding.)</p>

  

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="downloading-hyperlinks" data-export="">download the hyperlink</dfn> created by an
  element <var>subject</var>, given an optional <dfn id="downloading-hyperlinksuffix"><var>hyperlinkSuffix</var></dfn> (default null) and an
  optional <dfn id="downloading-userinvolvement"><var>userInvolvement</var></dfn> (default
  "<code id="downloading-resources:uni-none"><a href="#uni-none">none</a></code>"):</p>

  <ol><li><p>If <var>subject</var> <a href="#cannot-navigate" id="downloading-resources:cannot-navigate">cannot navigate</a>, then return.</p></li><li id="allowed-to-download"><p>If <var>subject</var>'s <a id="downloading-resources:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#active-sandboxing-flag-set" id="downloading-resources:active-sandboxing-flag-set">active
   sandboxing flag set</a> has the <a href="#sandboxed-downloads-browsing-context-flag" id="downloading-resources:sandboxed-downloads-browsing-context-flag">sandboxed downloads browsing context flag</a> set,
   then return.</p></li><li><p>Let <var>urlString</var> be the result of <a href="#encoding-parsing-and-serializing-a-url" id="downloading-resources:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing a
   URL</a> given <var>subject</var>'s <code id="downloading-resources:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute
   value, relative to <var>subject</var>'s <a id="downloading-resources:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>urlString</var> is failure, then return.</p></li><li><p>If <var>hyperlinkSuffix</var> is non-null, then append it to
   <var>urlString</var>.</p></li><li>
    <p>If <var>userInvolvement</var> is not "<code id="downloading-resources:uni-browser-ui"><a href="#uni-browser-ui">browser UI</a></code>",
    then:</p>

    <ol><li><p><a id="downloading-resources:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>subject</var> has a <code id="downloading-resources:attr-hyperlink-download-3"><a href="#attr-hyperlink-download">download</a></code> attribute.</p></li><li><p>Let <var>navigation</var> be <var>subject</var>'s <a href="#concept-relevant-global" id="downloading-resources:concept-relevant-global">relevant global object</a>'s
     <a href="#window-navigation-api" id="downloading-resources:window-navigation-api">navigation API</a>.</p></li><li><p>Let <var>filename</var> be the value of <var>subject</var>'s <code id="downloading-resources:attr-hyperlink-download-4"><a href="#attr-hyperlink-download">download</a></code> attribute.</p></li><li><p>Let <var>continue</var> be the result of <a href="#fire-a-download-request-navigate-event" id="downloading-resources:fire-a-download-request-navigate-event">firing a download request <code>navigate</code> event</a> at
     <var>navigation</var> with <i id="downloading-resources:fire-navigate-download-destinationurl"><a href="#fire-navigate-download-destinationurl">destinationURL</a></i>
     set to <var>urlString</var>, <i id="downloading-resources:fire-navigate-download-userinvolvement"><a href="#fire-navigate-download-userinvolvement">userInvolvement</a></i> set to
     <var>userInvolvement</var>, <i id="downloading-resources:fire-navigate-download-sourceelement"><a href="#fire-navigate-download-sourceelement">sourceElement</a></i>
     set to <var>subject</var>, and <i id="downloading-resources:fire-navigate-download-filename"><a href="#fire-navigate-download-filename">filename</a></i> set to
     <var>filename</var>.</p></li><li><p>If <var>continue</var> is false, then return.</p></li></ol>
   </li><li>
    <p>Run these steps <a href="#in-parallel" id="downloading-resources:in-parallel">in parallel</a>:</p>

    <ol><li><p>Optionally, the user agent may abort these steps, if it believes doing so would
     safeguard the user from a potentially hostile download.</p></li><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="downloading-resources:concept-request" data-x-internal="concept-request">request</a> whose
     <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="downloading-resources:concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>urlString</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="downloading-resources:concept-request-client" data-x-internal="concept-request-client">client</a> is <a href="#entry-settings-object" id="downloading-resources:entry-settings-object">entry settings object</a>, <a href="https://fetch.spec.whatwg.org/#concept-request-initiator" id="downloading-resources:concept-request-initiator" data-x-internal="concept-request-initiator">initiator</a> is "<code>download</code>", <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="downloading-resources:concept-request-destination" data-x-internal="concept-request-destination">destination</a> is the empty string, and whose
     <a id="downloading-resources:synchronous-flag" href="https://fetch.spec.whatwg.org/#synchronous-flag" data-x-internal="synchronous-flag">synchronous flag</a> and <a id="downloading-resources:use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a> are set.</p></li><li><p>Let <var>response</var> be the result of <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="downloading-resources:concept-fetch" data-x-internal="concept-fetch">fetching</a>
     <var>request</var>.</p></li><li><p><a href="#handle-as-a-download" id="downloading-resources:handle-as-a-download">Handle as a download</a> <var>response</var> with
     <var>subject</var>'s <a href="#node-navigable" id="downloading-resources:node-navigable">node navigable</a> and null.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="handle-as-a-download">handle as a download</dfn> a <a href="https://fetch.spec.whatwg.org/#concept-response" id="downloading-resources:concept-response" data-x-internal="concept-response">response</a>
  <var>response</var> with a <a href="#navigable" id="downloading-resources:navigable">navigable</a>
  <var>navigable</var> and a <a href="#navigation-id" id="downloading-resources:navigation-id">navigation ID</a> or null <var>navigationId</var>:</p>

  <ol><li><p>Let <var>suggestedFilename</var> be the result of <a href="#getting-the-suggested-filename" id="downloading-resources:getting-the-suggested-filename">getting the suggested
   filename</a> for <var>response</var>.</p></li><li><p>Let <var>download behavior</var> be the result of <a id="downloading-resources:webdriver-bidi-download-will-begin" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-download-will-begin" data-x-internal="webdriver-bidi-download-will-begin">WebDriver BiDi download will
   begin</a> with <var>navigable</var> and a new <a id="downloading-resources:webdriver-bidi-navigation-status" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a>
   whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="downloading-resources:navigation-status-id" data-x-internal="navigation-status-id">id</a> is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="downloading-resources:navigation-status-status" data-x-internal="navigation-status-status">status</a> is "<code id="downloading-resources:navigation-status-pending"><a data-x-internal="navigation-status-pending" href="https://w3c.github.io/webdriver-bidi/#navigation-status-pending">pending</a></code>", <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="downloading-resources:navigation-status-url" data-x-internal="navigation-status-url">url</a> is <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="downloading-resources:concept-response-url" data-x-internal="concept-response-url">URL</a>, and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-suggested-filename" id="downloading-resources:navigation-status-suggested-filename" data-x-internal="navigation-status-suggested-filename">suggestedFilename</a> is
   <var>suggestedFilename</var>.</p></li><li>
    <p>If <var>download behavior</var> is not null and <var>download behavior</var>'s
    <a href="https://w3c.github.io/webdriver-bidi/#download-behavior-struct-allowed" id="downloading-resources:download-behavior-struct-allowed" data-x-internal="download-behavior-struct-allowed">allowed</a> is false:</p>

    <ol><li><p>Invoke <a id="downloading-resources:webdriver-bidi-download-end" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-download-end" data-x-internal="webdriver-bidi-download-end">WebDriver BiDi download end</a> with <var>navigable</var> and a new
     <a id="downloading-resources:webdriver-bidi-navigation-status-2" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="downloading-resources:navigation-status-id-2" data-x-internal="navigation-status-id">id</a> is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="downloading-resources:navigation-status-status-2" data-x-internal="navigation-status-status">status</a> is "<code id="downloading-resources:navigation-status-canceled"><a data-x-internal="navigation-status-canceled" href="https://w3c.github.io/webdriver-bidi/#navigation-status-canceled">canceled</a></code>", <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="downloading-resources:navigation-status-url-2" data-x-internal="navigation-status-url">url</a> is <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="downloading-resources:concept-response-url-2" data-x-internal="concept-response-url">URL</a>.</p></li><li><p>Return.</p></li></ol>
   </li><li><p>If <var>download behavior</var> is not null, let <var>destinationFolder</var> be
   <var>download behavior</var>'s <a href="https://w3c.github.io/webdriver-bidi/#download-behavior-struct-destination-folder" id="downloading-resources:download-behavior-struct-destination-folder" data-x-internal="download-behavior-struct-destination-folder">destinationFolder</a>.</p></li><li>
    <p>Run these steps <a href="#in-parallel" id="downloading-resources:in-parallel-2">in parallel</a>:</p>

    <ol><li><p>Run <a id="downloading-resources:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> steps to save <var>response</var> for later use.
     If <var>destinationFolder</var> is not null, the user agent should save the file to that path.
     If the user agent needs a filename, the user agent should use the
     <var>suggestedFilename</var>.</p></li><li>
        <p>If any of the following are true:</p>

        <ul class="brief"><li><p>the download is canceled by the user;</p></li><li><p>the download is canceled by the user agent;</p></li><li><p>an error occurs (for example, a network error, not enough storage, an unavailable
         destination folder);</p></li></ul>

        <p>then:</p>

        <ol><li><p>Invoke <a id="downloading-resources:webdriver-bidi-download-end-2" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-download-end" data-x-internal="webdriver-bidi-download-end">WebDriver BiDi download end</a> with <var>navigable</var> and a new
          <a id="downloading-resources:webdriver-bidi-navigation-status-3" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="downloading-resources:navigation-status-id-3" data-x-internal="navigation-status-id">id</a> is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="downloading-resources:navigation-status-status-3" data-x-internal="navigation-status-status">status</a> is "<code id="downloading-resources:navigation-status-canceled-2"><a data-x-internal="navigation-status-canceled" href="https://w3c.github.io/webdriver-bidi/#navigation-status-canceled">canceled</a></code>", <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="downloading-resources:navigation-status-url-3" data-x-internal="navigation-status-url">url</a> is <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="downloading-resources:concept-response-url-3" data-x-internal="concept-response-url">URL</a>.</p></li><li><p>Return.</p></li></ol>
     </li><li><p>When the download completes successfully, invoke <a id="downloading-resources:webdriver-bidi-download-end-3" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-download-end" data-x-internal="webdriver-bidi-download-end">WebDriver BiDi download
     end</a> with <var>navigable</var> and a new <a id="downloading-resources:webdriver-bidi-navigation-status-4" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a>
     whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="downloading-resources:navigation-status-id-4" data-x-internal="navigation-status-id">id</a> is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="downloading-resources:navigation-status-status-4" data-x-internal="navigation-status-status">status</a> is "<code id="downloading-resources:navigation-status-complete"><a data-x-internal="navigation-status-complete" href="https://w3c.github.io/webdriver-bidi/#navigation-status-complete">complete</a></code>", <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-downloaded-filepath" id="downloading-resources:navigation-status-downloaded-filepath" data-x-internal="navigation-status-downloaded-filepath">downloadedFilepath</a> is an absolute path
     of the downloaded file if available, otherwise null, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="downloading-resources:navigation-status-url-4" data-x-internal="navigation-status-url">url</a> is <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="downloading-resources:concept-response-url-4" data-x-internal="concept-response-url">URL</a>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="getting-the-suggested-filename">get the suggested filename</dfn> for a <a href="https://fetch.spec.whatwg.org/#concept-response" id="downloading-resources:concept-response-2" data-x-internal="concept-response">response</a> <var>response</var>:</p>

  <p class="warning">This algorithm is intended to mitigate security dangers involved in downloading
  files from untrusted sites, and user agents are strongly urged to follow it.</p> 

  <ol><li><p>Let <var>filename</var> be the undefined value.</p></li><li><p>If <var>response</var> has a `<code id="downloading-resources:http-content-disposition-3"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition</a></code>` header, that header specifies the
   <code>attachment</code> disposition type, and the header includes filename information,
   then let <var>filename</var> have the value specified by the header, and jump to the step labeled
   <i>sanitize</i> below. <a href="#refsRFC6266">[RFC6266]</a></p></li><li><p>Let <var>interface origin</var> be the <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="downloading-resources:concept-document-origin" data-x-internal="concept-document-origin">origin</a> of the <code id="downloading-resources:document"><a href="#document">Document</a></code> in which the <a href="#downloading-hyperlinks" id="downloading-resources:downloading-hyperlinks">download</a> or <a href="#navigate" id="downloading-resources:navigate">navigate</a> action resulting in the
   download was initiated, if any.</p></li><li><p>Let <var>response origin</var> be the <a href="#concept-origin" id="downloading-resources:concept-origin">origin</a> of the URL of
   <var>response</var>, unless that URL's <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="downloading-resources:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> component
   is <code>data</code>, in which case let <var>response origin</var> be the same as the
   <var>interface origin</var>, if any.</p></li><li><p>If there is no <var>interface origin</var>, then let <var>trusted operation</var> be true.
   Otherwise, let <var>trusted operation</var> be true if <var>response origin</var> is the
   <a href="#same-origin" id="downloading-resources:same-origin">same origin</a> as <var>interface origin</var>, and false otherwise.</p></li><li><p>If <var>trusted operation</var> is true and <var>response</var> has a `<code id="downloading-resources:http-content-disposition-4"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition</a></code>` header and that header includes
   filename information, then let <var>filename</var> have the value specified by the header, and
   jump to the step labeled <i>sanitize</i> below. <a href="#refsRFC6266">[RFC6266]</a></p></li><li><p>If the download was not initiated from a <a href="#hyperlink" id="downloading-resources:hyperlink-2">hyperlink</a> created by an
   <code id="downloading-resources:the-a-element-2"><a href="#the-a-element">a</a></code> or <code id="downloading-resources:the-area-element-2"><a href="#the-area-element">area</a></code> element, or if the element of the <a href="#hyperlink" id="downloading-resources:hyperlink-3">hyperlink</a> from
   which it was initiated did not have a <code id="downloading-resources:attr-hyperlink-download-5"><a href="#attr-hyperlink-download">download</a></code>
   attribute when the download was initiated, or if there was such an attribute but its value when
   the download was initiated was the empty string, then jump to the step labeled <i>no proposed
   filename</i>.</p></li><li><p>Let <var>proposed filename</var> have the value of the <code id="downloading-resources:attr-hyperlink-download-6"><a href="#attr-hyperlink-download">download</a></code> attribute of the element of the
   <a href="#hyperlink" id="downloading-resources:hyperlink-4">hyperlink</a> that initiated the download at the time the download was
   initiated.</p></li><li><p>If <var>trusted operation</var> is true, let <var>filename</var> have
   the value of <var>proposed filename</var>, and jump to the step labeled <i>sanitize</i>
   below.</p></li><li><p>If <var>response</var> has a `<code id="downloading-resources:http-content-disposition-5"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition</a></code>` header and that header specifies
   the <code>attachment</code> disposition type, let <var>filename</var> have the value of
   <var>proposed filename</var>, and jump to the step labeled <i>sanitize</i> below.
   <a href="#refsRFC6266">[RFC6266]</a></p></li><li><p><i>No proposed filename</i>: If <var>trusted operation</var> is true, or if the user
   indicated a preference for having the response in question downloaded, let <var>filename</var>
   have a value derived from the <a id="downloading-resources:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of <var>response</var> in an
   <a id="downloading-resources:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner, and jump to the step labeled <i>sanitize</i>
   below.</p></li><li>
    <p>Let <var>filename</var> be set to the user's preferred filename or to a filename selected by
    the user agent, and jump to the step labeled <i>sanitize</i> below.</p>

    <div class="warning">

     <p>If the algorithm reaches this step, then a download was begun from a different origin than
     <var>response</var>, and the origin did not mark the file as suitable for downloading, and the
     download was not initiated by the user. This could be because a <code id="downloading-resources:attr-hyperlink-download-7"><a href="#attr-hyperlink-download">download</a></code> attribute was used to trigger the download, or
     because <var>response</var> is not of a type that the user agent supports.</p>

     <p>This could be dangerous, because, for instance, a hostile server could be trying to get a
     user to unknowingly download private information and then re-upload it to the hostile server,
     by tricking the user into thinking the data is from the hostile server.</p>

     <p>Thus, it is in the user's interests that the user be somehow notified that
     <var>response</var> comes from quite a different source, and to prevent confusion, any
     suggested filename from the potentially hostile <var>interface origin</var> should be
     ignored.</p>

    </div>
   </li><li><p><i>Sanitize</i>: Optionally, allow the user to influence <var>filename</var>. For
   example, a user agent could prompt the user for a filename, potentially providing the value of
   <var>filename</var> as determined above as a default value.</p></li><li>
    <p>Adjust <var>filename</var> to be suitable for the local file system.</p>

    <p class="example">For example, this could involve removing characters that are not legal in
    filenames, or trimming leading and trailing whitespace.</p>
   </li><li><p>If the platform conventions do not in any way use <a href="#concept-extension" id="downloading-resources:concept-extension">extensions</a> to determine the types of file on the file system,
   then return <var>filename</var> as the filename.</p></li><li><p>Let <var>claimed type</var> be the type given by <var>response</var>'s <a href="#content-type" id="downloading-resources:content-type">Content-Type metadata</a>, if any is known. Let <var>named type</var> be
   the type given by <var>filename</var>'s <a href="#concept-extension" id="downloading-resources:concept-extension-2">extension</a>, if any
   is known. For the purposes of this step, a <i>type</i> is a mapping of a <a id="downloading-resources:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a>
   to an <a href="#concept-extension" id="downloading-resources:concept-extension-3">extension</a>.</p></li><li><p>If <var>named type</var> is consistent with the user's preferences (e.g., because the
   value of <var>filename</var> was determined by prompting the user), then return
   <var>filename</var> as the filename.</p></li><li><p>If <var>claimed type</var> and <var>named type</var> are the same type (i.e., the type
   given by <var>response</var>'s <a href="#content-type" id="downloading-resources:content-type-2">Content-Type metadata</a> is
   consistent with the type given by <var>filename</var>'s <a href="#concept-extension" id="downloading-resources:concept-extension-4">extension</a>), then return <var>filename</var> as the
   filename.</p></li><li>
    <p>If the <var>claimed type</var> is known, then alter <var>filename</var> to
    add an <a href="#concept-extension" id="downloading-resources:concept-extension-5">extension</a> corresponding to <var>claimed
    type</var>.</p>

    <p>Otherwise, if <var>named type</var> is known to be potentially dangerous (e.g. it
    will be treated by the platform conventions as a native executable, shell script, HTML
    application, or executable-macro-capable document), then optionally alter <var>filename</var> to add a known-safe <a href="#concept-extension" id="downloading-resources:concept-extension-6">extension</a>
    (e.g. "<code>.txt</code>").</p>

    <p class="note">This last step would make it impossible to download executables, which might not
    be desirable. As always, implementers are forced to balance security and usability in this
    matter.</p>
   </li><li><p>Return <var>filename</var> as the filename.</p></li></ol>
  </div>

  <p>For the purposes of this algorithm, a file <dfn id="concept-extension">extension</dfn>
  consists of any part of the filename that platform conventions dictate will be used for
  identifying the type of the file. For example, many operating systems use the part of the filename
  following the last dot ("<code>.</code>") in the filename to determine the type of the
  file, and from that the manner in which the file is to be opened or executed.</p>

  <p>User agents should ignore any directory or path information provided by the response itself,
  its <a id="downloading-resources:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, and any <code id="downloading-resources:attr-hyperlink-download-8"><a href="#attr-hyperlink-download">download</a></code> attribute, in
  deciding where to store the resulting file in the user's file system.</p>

  


  <h4 id="hyperlink-auditing"><span class="secno">4.6.6</span> <dfn>Hyperlink auditing</dfn><a href="#hyperlink-auditing" class="self-link"></a></h4>

  

  <div data-algorithm="">
  <p>If a <a href="#hyperlink" id="hyperlink-auditing:hyperlink">hyperlink</a> created by an <code id="hyperlink-auditing:the-a-element"><a href="#the-a-element">a</a></code> or <code id="hyperlink-auditing:the-area-element"><a href="#the-area-element">area</a></code> element has a
  <code id="hyperlink-auditing:ping"><a href="#ping">ping</a></code> attribute, and the user follows the hyperlink, and
  the value of the element's <code id="hyperlink-auditing:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute can be <a href="#encoding-parsing-a-url" id="hyperlink-auditing:encoding-parsing-a-url">parsed</a>, relative to the element's <a id="hyperlink-auditing:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
  document</a>, without failure, then the user agent must take the <code id="hyperlink-auditing:ping-2"><a href="#ping">ping</a></code> attribute's value, <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="hyperlink-auditing:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">split that string on ASCII whitespace</a>, <a href="#encoding-parsing-a-url" id="hyperlink-auditing:encoding-parsing-a-url-2">parse</a> each resulting token, relative to the element's <a id="hyperlink-auditing:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, and
  then run these steps for each resulting <a id="hyperlink-auditing:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>ping URL</var>, ignoring when
  parsing returns failure:</p>

  <ol><li><p>If <var>ping URL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="hyperlink-auditing:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is not an
   <a id="hyperlink-auditing:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>, then return.</p></li><li><p>Optionally, return. (For example, the user agent might wish to ignore any or
   all ping URLs in accordance with the user's expressed preferences.)</p></li><li><p>Let <var>settingsObject</var> be the element's <a id="hyperlink-auditing:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
   <a href="#relevant-settings-object" id="hyperlink-auditing:relevant-settings-object">relevant settings object</a>.</p></li><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="hyperlink-auditing:concept-request" data-x-internal="concept-request">request</a> whose <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="hyperlink-auditing:concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>ping URL</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-method" id="hyperlink-auditing:concept-request-method" data-x-internal="concept-request-method">method</a> is `<code>POST</code>`, <a href="https://fetch.spec.whatwg.org/#concept-request-header-list" id="hyperlink-auditing:concept-request-header-list" data-x-internal="concept-request-header-list">header list</a> is « (`<code id="hyperlink-auditing:content-type"><a href="#content-type">Content-Type</a></code>`,
   `<code id="hyperlink-auditing:text/ping"><a href="#text/ping">text/ping</a></code>`) », <a href="https://fetch.spec.whatwg.org/#concept-request-body" id="hyperlink-auditing:concept-request-body" data-x-internal="concept-request-body">body</a> is `<code>PING</code>`, <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="hyperlink-auditing:concept-request-client" data-x-internal="concept-request-client">client</a> is
   <var>settingsObject</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="hyperlink-auditing:concept-request-destination" data-x-internal="concept-request-destination">destination</a> is the
   empty string, <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="hyperlink-auditing:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> is "<code>include</code>", <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="hyperlink-auditing:concept-request-referrer" data-x-internal="concept-request-referrer">referrer</a> is "<code>no-referrer</code>", and whose <a id="hyperlink-auditing:use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a> is set, and whose
   <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="hyperlink-auditing:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator type</a> is "<code>ping</code>".</p></li><li>
    <p>Let <var>target URL</var> be the result of <a href="#encoding-parsing-and-serializing-a-url" id="hyperlink-auditing:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing a
    URL</a> given the element's <code id="hyperlink-auditing:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> attribute's value,
    relative to the element's <a id="hyperlink-auditing:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, and then:</p>

    <dl class="switch"><dt>If the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="hyperlink-auditing:the-document's-address" data-x-internal="the-document's-address">URL</a> of the <code id="hyperlink-auditing:document"><a href="#document">Document</a></code> object
     containing the hyperlink being audited and <var>ping URL</var> have the <a href="#same-origin" id="hyperlink-auditing:same-origin">same
     origin</a></dt><dt>If the origins are different, but the <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="hyperlink-auditing:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a> of
     the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="hyperlink-auditing:the-document's-address-2" data-x-internal="the-document's-address">URL</a> of the <code id="hyperlink-auditing:document-2"><a href="#document">Document</a></code> containing the
     hyperlink being audited is not "<code>https</code>"</dt><dd><var>request</var> must include a `<code id="hyperlink-auditing:ping-from"><a href="#ping-from">Ping-From</a></code>` header with, as its value, the
     <a href="https://dom.spec.whatwg.org/#concept-document-url" id="hyperlink-auditing:the-document's-address-3" data-x-internal="the-document's-address">URL</a> of the document containing the hyperlink, and a
     `<code id="hyperlink-auditing:ping-to"><a href="#ping-to">Ping-To</a></code>` HTTP header with, as its value, the <var>target URL</var>.</dd><dt>Otherwise</dt><dd><var>request</var> must include a `<code id="hyperlink-auditing:ping-to-2"><a href="#ping-to">Ping-To</a></code>` HTTP header with, as its value,
     <var>target URL</var>. <span class="note"><var>request</var> does not include a
     `<code id="hyperlink-auditing:ping-from-2"><a href="#ping-from">Ping-From</a></code>` header.</span></dd></dl>
   </li><li><p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="hyperlink-auditing:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var>.</p></li></ol>
  </div>

  <p>This may be done <a href="#in-parallel" id="hyperlink-auditing:in-parallel">in parallel</a> with the primary fetch, and is independent of the
  result of that fetch.</p>

  <p>User agents should allow the user to adjust this behavior, for example in conjunction with a
  setting that disables the sending of HTTP `<code id="hyperlink-auditing:http-referer"><a data-x-internal="http-referer" href="https://httpwg.org/specs/rfc7231.html#header.referer">Referer</a></code>` (sic)
  headers. Based on the user's preferences, UAs may either <a href="#ignore" id="hyperlink-auditing:ignore">ignore</a> the <code id="hyperlink-auditing:ping-3"><a href="#ping">ping</a></code> attribute altogether, or selectively ignore URLs in the
  list (e.g. ignoring any third-party URLs); this is explicitly accounted for in the steps
  above.</p>

  <p>User agents must ignore any entity bodies returned in the responses. User agents may close the
  connection prematurely once they start receiving a response body.</p>

  <p id="fingerprint-ping">
  <a id="hyperlink-auditing:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  An <code id="hyperlink-auditing:the-a-element-2"><a href="#the-a-element">a</a></code> or <code id="hyperlink-auditing:the-area-element-2"><a href="#the-area-element">area</a></code> element that creates a <a href="#hyperlink" id="hyperlink-auditing:hyperlink-2">hyperlink</a> and has
  the <code id="hyperlink-auditing:ping-4"><a href="#ping">ping</a></code> attribute is present, user agents may indicate
  to the user that following the hyperlink will also cause secondary requests to be sent in the
  background, possibly including listing the actual target URLs.</p>

  <p class="example">For example, a visual user agent could include the hostnames of the target ping
  URLs along with the hyperlink's actual URL in a status bar or tooltip.</p>

  

  <div class="note">
   <p>The <code id="hyperlink-auditing:ping-5"><a href="#ping">ping</a></code> attribute is redundant with pre-existing
   technologies like HTTP redirects and JavaScript in allowing web pages to track which off-site
   links are most popular or allowing advertisers to track click-through rates.</p>

   <p>However, the <code id="hyperlink-auditing:ping-6"><a href="#ping">ping</a></code> attribute provides these advantages
   to the user over those alternatives:</p>

   <ul><li>It allows the user to see the final target URL unobscured.</li><li>It allows the UA to inform the user about the out-of-band notifications.</li><li>It allows the UA to optimize the use of available network bandwidth so that the target page
    loads faster.</li></ul>
  </div>

  

  <h5 id="the-ping-headers"><span class="secno">4.6.6.1</span> The `<code id="the-ping-headers:ping-from"><a href="#ping-from">Ping-From</a></code>` and `<code id="the-ping-headers:ping-to"><a href="#ping-to">Ping-To</a></code>` headers<a href="#the-ping-headers" class="self-link"></a></h5>

  <p>The `<dfn id="ping-from" data-dfn-type="http-header"><code>Ping-From</code></dfn>` and `<dfn id="ping-to" data-dfn-type="http-header"><code>Ping-To</code></dfn>` HTTP request headers are included in <a href="#hyperlink-auditing" id="the-ping-headers:hyperlink-auditing">hyperlink
  auditing</a> requests. Their value is a <a id="the-ping-headers:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-ping-headers:concept-url-serializer" data-x-internal="concept-url-serializer">serialized</a>.</p>


  <h4 id="linkTypes"><span class="secno">4.6.7</span> Link types<a href="#linkTypes" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types" title="The rel attribute defines the relationship between a linked resource and the current document. Valid on <link>, <a>, <area>, and <form>, the supported values depend on the element on which the attribute is found.">Link_types</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types" title="The rel attribute defines the relationship between a linked resource and the current document. Valid on <link>, <a>, <area>, and <form>, the supported values depend on the element on which the attribute is found.">Link_types</a></p></div></div>

  <p>The following table summarizes the link types that are defined by this specification, by their
  corresponding keywords. This table is non-normative; the actual definitions for the link types are
  given in the next few sections.</p>

  <p>In this section, the term <i>referenced document</i> refers to the resource identified by the
  element representing the link, and the term <i>current document</i> refers to the resource within
  which the element representing the link finds itself.</p>

  

  <p>To determine which link types apply to a <code id="linkTypes:the-link-element"><a href="#the-link-element">link</a></code>, <code id="linkTypes:the-a-element"><a href="#the-a-element">a</a></code>, <code id="linkTypes:the-area-element"><a href="#the-area-element">area</a></code>,
  or <code id="linkTypes:the-form-element"><a href="#the-form-element">form</a></code> element, the element's <code>rel</code> attribute must be <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="linkTypes:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">split on ASCII whitespace</a>. The resulting tokens
  are the keywords for the link types that apply to that element.</p>

  

  <p>Except where otherwise specified, a keyword must not be specified more than once per <code id="linkTypes:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code> attribute.</p>

  <p>Some of the sections that follow the table below list synonyms for certain keywords. The
  indicated synonyms are to be handled as specified by user agents, but must
  not be used in documents (for example, the keyword "<code>copyright</code>").</p>

  <p>Keywords are always <a id="linkTypes:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>, and must be
  compared as such.</p>

  <p class="example">Thus, <code>rel="next"</code> is the same as <code>rel="NEXT"</code>.</p>

  <p>Keywords that are <dfn id="body-ok">body-ok</dfn> affect whether <code id="linkTypes:the-link-element-2"><a href="#the-link-element">link</a></code> elements are
  <a href="#allowed-in-the-body" id="linkTypes:allowed-in-the-body">allowed in the body</a>. The <a href="#body-ok" id="linkTypes:body-ok">body-ok</a> keywords are
  <code id="linkTypes:link-type-dns-prefetch"><a href="#link-type-dns-prefetch">dns-prefetch</a></code>,
  <code id="linkTypes:link-type-modulepreload"><a href="#link-type-modulepreload">modulepreload</a></code>,
  <code id="linkTypes:link-type-pingback"><a href="#link-type-pingback">pingback</a></code>,
  <code id="linkTypes:link-type-preconnect"><a href="#link-type-preconnect">preconnect</a></code>,
  <code id="linkTypes:link-type-prefetch"><a href="#link-type-prefetch">prefetch</a></code>,
  <code id="linkTypes:link-type-preload"><a href="#link-type-preload">preload</a></code>, and
  <code id="linkTypes:link-type-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code>.</p>

  <p>New link types that are to be implemented by web browsers are to be added to this standard. The
  remainder can be <a href="#concept-rel-extensions" id="linkTypes:concept-rel-extensions">registered as extensions</a>.</p>

  <table id="table-link-relations" class="yesno"><thead><tr><th rowspan="2">Link type</th><th colspan="3">Effect on...</th><th rowspan="2"><a href="#body-ok" id="linkTypes:body-ok-2">body-ok</a></th><th rowspan="2">Has `<code id="linkTypes:http-link"><a data-x-internal="http-link" href="https://httpwg.org/specs/rfc8288.html#header">Link</a></code>` processing</th><th rowspan="2">Brief description</th></tr><tr><th><code id="linkTypes:the-link-element-3"><a href="#the-link-element">link</a></code></th><th><code id="linkTypes:the-a-element-2"><a href="#the-a-element">a</a></code> and <code id="linkTypes:the-area-element-2"><a href="#the-area-element">area</a></code></th><th><code id="linkTypes:the-form-element-2"><a href="#the-form-element">form</a></code></th></tr></thead><tbody><tr><td><code id="linkTypes:rel-alternate"><a href="#rel-alternate">alternate</a></code></td><td colspan="2"><a href="#hyperlink" id="linkTypes:hyperlink">Hyperlink</a></td><td><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Gives alternate representations of the current document.</td></tr><tr><td><code id="linkTypes:link-type-canonical"><a href="#link-type-canonical">canonical</a></code></td><td><a href="#hyperlink" id="linkTypes:hyperlink-2">Hyperlink</a></td><td colspan="2"><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Gives the preferred URL for the current document.</td></tr><tr><td><code id="linkTypes:link-type-author"><a href="#link-type-author">author</a></code></td><td colspan="2"><a href="#hyperlink" id="linkTypes:hyperlink-3">Hyperlink</a></td><td><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Gives a link to the author of the current document or article.</td></tr><tr><td><code id="linkTypes:link-type-bookmark"><a href="#link-type-bookmark">bookmark</a></code></td><td><em>not allowed</em></td><td><a href="#hyperlink" id="linkTypes:hyperlink-4">Hyperlink</a></td><td><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Gives the permalink for the nearest ancestor section.</td></tr><tr><td><code id="linkTypes:link-type-dns-prefetch-2"><a href="#link-type-dns-prefetch">dns-prefetch</a></code></td><td><a href="#external-resource-link" id="linkTypes:external-resource-link">External Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="yes"> Yes </td><td class="no"> · </td><td>Specifies that the user agent should preemptively perform DNS resolution for the target resource's <a href="#concept-origin" id="linkTypes:concept-origin">origin</a>.</td></tr><tr><td><code id="linkTypes:link-type-expect"><a href="#link-type-expect">expect</a></code></td><td><a href="#internal-resource-link" id="linkTypes:internal-resource-link">Internal Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Expect an element with the target ID to appear in the current document.</td></tr><tr><td><code id="linkTypes:link-type-external"><a href="#link-type-external">external</a></code></td><td><em>not allowed</em></td><td colspan="2"><a href="#hyperlink-annotation" id="linkTypes:hyperlink-annotation">Annotation</a></td><td class="no"> · </td><td class="no"> · </td><td>Indicates that the referenced document is not part of the same site as the current document.</td></tr><tr><td><code id="linkTypes:link-type-help"><a href="#link-type-help">help</a></code></td><td colspan="3"><a href="#hyperlink" id="linkTypes:hyperlink-5">Hyperlink</a></td><td class="no"> · </td><td class="no"> · </td><td>Provides a link to context-sensitive help.</td></tr><tr><td><code id="linkTypes:rel-icon"><a href="#rel-icon">icon</a></code></td><td><a href="#external-resource-link" id="linkTypes:external-resource-link-2">External Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Imports an icon to represent the current document.</td></tr><tr><td><code id="linkTypes:link-type-manifest"><a href="#link-type-manifest">manifest</a></code></td><td><a href="#external-resource-link" id="linkTypes:external-resource-link-3">External Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Imports or links to an <a id="linkTypes:application-manifest" href="https://w3c.github.io/manifest/#dfn-manifest" data-x-internal="application-manifest">application manifest</a>. <a href="#refsMANIFEST">[MANIFEST]</a></td></tr><tr><td><code id="linkTypes:link-type-modulepreload-2"><a href="#link-type-modulepreload">modulepreload</a></code></td><td><a href="#external-resource-link" id="linkTypes:external-resource-link-4">External Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="yes"> Yes </td><td class="no"> · </td><td>Specifies that the user agent must preemptively <a href="#fetch-a-single-module-script" id="linkTypes:fetch-a-single-module-script">fetch the module
     script</a> and store it in the document's <a href="#concept-document-module-map" id="linkTypes:concept-document-module-map">module map</a> for later
     evaluation. Optionally, the module's dependencies can be fetched as well.</td></tr><tr><td><code id="linkTypes:link-type-license"><a href="#link-type-license">license</a></code></td><td colspan="3"><a href="#hyperlink" id="linkTypes:hyperlink-6">Hyperlink</a></td><td class="no"> · </td><td class="no"> · </td><td>Indicates that the main content of the current document is covered by the copyright license described by the referenced document.</td></tr><tr><td><code id="linkTypes:link-type-next"><a href="#link-type-next">next</a></code></td><td colspan="3"><a href="#hyperlink" id="linkTypes:hyperlink-7">Hyperlink</a></td><td class="no"> · </td><td class="no"> · </td><td>Indicates that the current document is a part of a series, and that the next document in the series is the referenced document.</td></tr><tr><td><code id="linkTypes:link-type-nofollow"><a href="#link-type-nofollow">nofollow</a></code></td><td><em>not allowed</em></td><td colspan="2"><a href="#hyperlink-annotation" id="linkTypes:hyperlink-annotation-2">Annotation</a></td><td class="no"> · </td><td class="no"> · </td><td>Indicates that the current document's original author or publisher does not endorse the referenced document.</td></tr><tr><td><code id="linkTypes:link-type-noopener"><a href="#link-type-noopener">noopener</a></code></td><td><em>not allowed</em></td><td colspan="2"><a href="#hyperlink-annotation" id="linkTypes:hyperlink-annotation-3">Annotation</a></td><td class="no"> · </td><td class="no"> · </td><td>Creates a <a href="#top-level-traversable" id="linkTypes:top-level-traversable">top-level traversable</a> with a non-<a href="#auxiliary-browsing-context" id="linkTypes:auxiliary-browsing-context">auxiliary browsing
     context</a> if the hyperlink would otherwise create one that was auxiliary (i.e., has an
     appropriate <code id="linkTypes:attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code> attribute value).</td></tr><tr><td><code id="linkTypes:link-type-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code></td><td><em>not allowed</em></td><td colspan="2"><a href="#hyperlink-annotation" id="linkTypes:hyperlink-annotation-4">Annotation</a></td><td class="no"> · </td><td class="no"> · </td><td>No `<code id="linkTypes:http-referer"><a data-x-internal="http-referer" href="https://httpwg.org/specs/rfc7231.html#header.referer">Referer</a></code>` (sic) header will be included.
     Additionally, has the same effect as <code id="linkTypes:link-type-noopener-2"><a href="#link-type-noopener">noopener</a></code>.</td></tr><tr><td><code id="linkTypes:link-type-opener"><a href="#link-type-opener">opener</a></code></td><td><em>not allowed</em></td><td colspan="2"><a href="#hyperlink-annotation" id="linkTypes:hyperlink-annotation-5">Annotation</a></td><td class="no"> · </td><td class="no"> · </td><td>Creates an <a href="#auxiliary-browsing-context" id="linkTypes:auxiliary-browsing-context-2">auxiliary browsing context</a> if the hyperlink would otherwise create
     a <a href="#top-level-traversable" id="linkTypes:top-level-traversable-2">top-level traversable</a> with a non-<a href="#auxiliary-browsing-context" id="linkTypes:auxiliary-browsing-context-3">auxiliary browsing context</a> (i.e.,
     has "<code>_blank</code>" as <code id="linkTypes:attr-hyperlink-target-2"><a href="#attr-hyperlink-target">target</a></code>
     attribute value).</td></tr><tr><td><code id="linkTypes:link-type-pingback-2"><a href="#link-type-pingback">pingback</a></code></td><td><a href="#external-resource-link" id="linkTypes:external-resource-link-5">External Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="yes"> Yes </td><td class="no"> · </td><td>Gives the address of the pingback server that handles pingbacks to the current document.</td></tr><tr><td><code id="linkTypes:link-type-preconnect-2"><a href="#link-type-preconnect">preconnect</a></code></td><td><a href="#external-resource-link" id="linkTypes:external-resource-link-6">External Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="yes"> Yes </td><td class="yes"> Yes </td><td>Specifies that the user agent should preemptively connect to the target resource's <a href="#concept-origin" id="linkTypes:concept-origin-2">origin</a>.</td></tr><tr><td><code id="linkTypes:link-type-prefetch-2"><a href="#link-type-prefetch">prefetch</a></code></td><td><a href="#external-resource-link" id="linkTypes:external-resource-link-7">External Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="yes"> Yes </td><td class="no"> · </td><td>Specifies that the user agent should preemptively <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="linkTypes:concept-fetch" data-x-internal="concept-fetch">fetch</a> and cache the target resource as it is likely to be required for a followup <a href="#navigate" id="linkTypes:navigate">navigation</a>.</td></tr><tr><td><code id="linkTypes:link-type-preload-2"><a href="#link-type-preload">preload</a></code></td><td><a href="#external-resource-link" id="linkTypes:external-resource-link-8">External Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="yes"> Yes </td><td class="yes"> Yes </td><td>Specifies that the user agent must preemptively <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="linkTypes:concept-fetch-2" data-x-internal="concept-fetch">fetch</a> and cache the target resource for current <a href="#navigate" id="linkTypes:navigate-2">navigation</a> according to the <a href="https://fetch.spec.whatwg.org/#concept-potential-destination" id="linkTypes:concept-potential-destination" data-x-internal="concept-potential-destination">potential destination</a> given by the <code id="linkTypes:attr-link-as"><a href="#attr-link-as">as</a></code> attribute (and the <a href="https://fetch.spec.whatwg.org/#request-priority" id="linkTypes:concept-request-priority" data-x-internal="concept-request-priority">priority</a> associated with the <a href="https://fetch.spec.whatwg.org/#concept-potential-destination-translate" id="linkTypes:concept-potential-destination-translate" data-x-internal="concept-potential-destination-translate">corresponding</a> <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="linkTypes:concept-request-destination" data-x-internal="concept-request-destination">destination</a>).</td></tr><tr><td><code id="linkTypes:link-type-prev"><a href="#link-type-prev">prev</a></code></td><td colspan="3"><a href="#hyperlink" id="linkTypes:hyperlink-8">Hyperlink</a></td><td class="no"> · </td><td class="no"> · </td><td>Indicates that the current document is a part of a series, and that the previous document in the series is the referenced document.</td></tr><tr><td><code id="linkTypes:link-type-privacy-policy"><a href="#link-type-privacy-policy">privacy-policy</a></code></td><td colspan="2"><a href="#hyperlink" id="linkTypes:hyperlink-9">Hyperlink</a></td><td><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Gives a link to information about the data collection and usage practices that apply to the current document.</td></tr><tr><td><code id="linkTypes:link-type-search"><a href="#link-type-search">search</a></code></td><td colspan="3"><a href="#hyperlink" id="linkTypes:hyperlink-10">Hyperlink</a></td><td class="no"> · </td><td class="no"> · </td><td>Gives a link to a resource that can be used to search through the current document and its related pages.</td></tr><tr><td><code id="linkTypes:link-type-stylesheet-2"><a href="#link-type-stylesheet">stylesheet</a></code></td><td><a href="#external-resource-link" id="linkTypes:external-resource-link-9">External Resource</a></td><td colspan="2"><em>not allowed</em></td><td class="yes"> Yes </td><td class="no"> · </td><td>Imports a style sheet.</td></tr><tr><td><code id="linkTypes:link-type-tag"><a href="#link-type-tag">tag</a></code></td><td><em>not allowed</em></td><td><a href="#hyperlink" id="linkTypes:hyperlink-11">Hyperlink</a></td><td><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Gives a tag (identified by the given address) that applies to the current document.</td></tr><tr><td><code id="linkTypes:link-type-terms-of-service"><a href="#link-type-terms-of-service">terms-of-service</a></code></td><td colspan="2"><a href="#hyperlink" id="linkTypes:hyperlink-12">Hyperlink</a></td><td><em>not allowed</em></td><td class="no"> · </td><td class="no"> · </td><td>Gives a link to information about the agreements between the current document's provider and users who wish to use the current document.</td></tr></tbody></table>


  <h5 id="rel-alternate"><span class="secno">4.6.7.1</span> <span id="link-type-alternate"></span>Link type "<dfn data-dfn-for="link/rel,a/rel,area/rel" data-dfn-type="attr-value"><code>alternate</code></dfn>"<a href="#rel-alternate" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Alternative_style_sheets" title="Specifying alternative style sheets in a web page provides a way for users to see multiple versions of a page, based on their needs or preferences.">Alternative_style_sheets</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari unknown"><span>Safari</span><span>?</span></span><span class="chrome no"><span>Chrome</span><span>1–48</span></span><hr><span class="opera yes"><span>Opera</span><span>Yes</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="rel-alternate:rel-alternate"><a href="#rel-alternate">alternate</a></code> keyword may be used with <code id="rel-alternate:the-link-element"><a href="#the-link-element">link</a></code>,
  <code id="rel-alternate:the-a-element"><a href="#the-a-element">a</a></code>, and <code id="rel-alternate:the-area-element"><a href="#the-area-element">area</a></code> elements.</p>

  <p>The meaning of this keyword depends on the values of the other attributes.</p>

  <dl class="switch"><dt>If the element is a <code id="rel-alternate:the-link-element-2"><a href="#the-link-element">link</a></code> element and the <code id="rel-alternate:attr-link-rel"><a href="#attr-link-rel">rel</a></code>
   attribute also contains the keyword <code id="rel-alternate:link-type-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code></dt><dd>
    <p>The <code id="rel-alternate:rel-alternate-2"><a href="#rel-alternate">alternate</a></code> keyword modifies the meaning of the <code id="rel-alternate:link-type-stylesheet-2"><a href="#link-type-stylesheet">stylesheet</a></code> keyword in the way described for that keyword. The
    <code id="rel-alternate:rel-alternate-3"><a href="#rel-alternate">alternate</a></code> keyword does not create a link of its own.</p>

    <div class="example">

     <p>Here, a set of <code id="rel-alternate:the-link-element-3"><a href="#the-link-element">link</a></code> elements provide some style sheets:</p>

     <pre><code class="html"><c- c="">&lt;!-- a persistent style sheet --&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"default.css"</c-><c- p="">&gt;</c->

<c- c="">&lt;!-- the preferred alternate style sheet --&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"green.css"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Green styles"</c-><c- p="">&gt;</c->

<c- c="">&lt;!-- some alternate style sheets --&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"contrast.css"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"High contrast"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"big.css"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Big fonts"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"wide.css"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Wide screen"</c-><c- p="">&gt;</c-></code></pre>

    </div>
   </dd><dt>If the <code id="rel-alternate:rel-alternate-4"><a href="#rel-alternate">alternate</a></code> keyword is used with the <code id="rel-alternate:attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code> attribute set to the value <code>application/rss+xml</code> or the value <code>application/atom+xml</code></dt><dd>
    <p>The keyword creates a <a href="#hyperlink" id="rel-alternate:hyperlink">hyperlink</a> referencing a syndication feed (though not
    necessarily syndicating exactly the same content as the current page).</p>

    

    <p>For the purposes of feed autodiscovery, user agents should consider all <code id="rel-alternate:the-link-element-4"><a href="#the-link-element">link</a></code>
    elements in the document with the <code id="rel-alternate:rel-alternate-5"><a href="#rel-alternate">alternate</a></code> keyword used and
    with their <code id="rel-alternate:attr-hyperlink-type-2"><a href="#attr-hyperlink-type">type</a></code> attribute set to the value <code>application/rss+xml</code> or the value <code>application/atom+xml</code>. If the user agent has the concept of a default
    syndication feed, the first such element (in <a id="rel-alternate:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>) should be used as the
    default.</p>

    

    <div class="example">
     <p>The following <code id="rel-alternate:the-link-element-5"><a href="#the-link-element">link</a></code> elements give syndication feeds for a blog:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"application/atom+xml"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"posts.xml"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Cool Stuff Blog"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"application/atom+xml"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"posts.xml?category=robots"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Cool Stuff Blog: robots category"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"application/atom+xml"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"comments.xml"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Cool Stuff Blog: Comments"</c-><c- p="">&gt;</c-></code></pre>

     <p>Such <code id="rel-alternate:the-link-element-6"><a href="#the-link-element">link</a></code> elements would be used by user agents engaged in feed autodiscovery,
     with the first being the default (where applicable).</p>

     <p>The following example offers various different syndication feeds to the user, using
     <code id="rel-alternate:the-a-element-2"><a href="#the-a-element">a</a></code> elements:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You can access the planets database using Atom feeds:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"recently-visited-planets.xml"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"application/atom+xml"</c-><c- p="">&gt;</c->Recently Visited Planets<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"known-bad-planets.xml"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"application/atom+xml"</c-><c- p="">&gt;</c->Known Bad Planets<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"unexplored-planets.xml"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"alternate"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"application/atom+xml"</c-><c- p="">&gt;</c->Unexplored Planets<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

     <p>These links would not be used in feed autodiscovery.</p>
    </div>
   </dd><dt>Otherwise</dt><dd>
    <p>The keyword creates a <a href="#hyperlink" id="rel-alternate:hyperlink-2">hyperlink</a> referencing an alternate representation of the
    current document.</p>

    <p>The nature of the referenced document is given by the <code id="rel-alternate:attr-hyperlink-hreflang"><a href="#attr-hyperlink-hreflang">hreflang</a></code>, and <code id="rel-alternate:attr-hyperlink-type-3"><a href="#attr-hyperlink-type">type</a></code> attributes.</p>

    <p>If the <code id="rel-alternate:rel-alternate-6"><a href="#rel-alternate">alternate</a></code> keyword is used with the <code id="rel-alternate:attr-hyperlink-hreflang-2"><a href="#attr-hyperlink-hreflang">hreflang</a></code> attribute, and that attribute's value differs
    from the <a id="rel-alternate:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>'s <a href="#language" id="rel-alternate:language">language</a>, it indicates that the referenced
    document is a translation.</p>

    <p>If the <code id="rel-alternate:rel-alternate-7"><a href="#rel-alternate">alternate</a></code> keyword is used with the <code id="rel-alternate:attr-hyperlink-type-4"><a href="#attr-hyperlink-type">type</a></code> attribute, it indicates that the referenced document is
    a reformulation of the current document in the specified format.</p>

    <p>The <code id="rel-alternate:attr-hyperlink-hreflang-3"><a href="#attr-hyperlink-hreflang">hreflang</a></code> and <code id="rel-alternate:attr-hyperlink-type-5"><a href="#attr-hyperlink-type">type</a></code> attributes can be combined when specified with the <code id="rel-alternate:rel-alternate-8"><a href="#rel-alternate">alternate</a></code> keyword.</p>

    <div class="example">

     <p>The following example shows how you can specify versions of the page that use alternative
     formats, are aimed at other languages, and that are intended for other media:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">alternate</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/en/html"</c-> <c- e="">hreflang</c-><c- o="">=</c-><c- s="">en</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text/html</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"English HTML"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">alternate</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/fr/html"</c-> <c- e="">hreflang</c-><c- o="">=</c-><c- s="">fr</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text/html</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"French HTML"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">alternate</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/en/html/print"</c-> <c- e="">hreflang</c-><c- o="">=</c-><c- s="">en</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text/html</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">print</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"English HTML (for printing)"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">alternate</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/fr/html/print"</c-> <c- e="">hreflang</c-><c- o="">=</c-><c- s="">fr</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text/html</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">print</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"French HTML (for printing)"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">alternate</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/en/pdf"</c-> <c- e="">hreflang</c-><c- o="">=</c-><c- s="">en</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">application/pdf</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"English PDF"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">alternate</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/fr/pdf"</c-> <c- e="">hreflang</c-><c- o="">=</c-><c- s="">fr</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">application/pdf</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"French PDF"</c-><c- p="">&gt;</c-></code></pre>

    </div>

    <p>This relationship is transitive — that is, if a document links to two other documents
    with the link type "<code id="rel-alternate:rel-alternate-9"><a href="#rel-alternate">alternate</a></code>", then, in addition to implying
    that those documents are alternative representations of the first document, it is also implying
    that those two documents are alternative representations of each other.</p>
   </dd></dl>


  <h5 id="link-type-author"><span class="secno">4.6.7.2</span> Link type "<dfn data-dfn-for="link/rel,a/rel,area/rel" data-dfn-type="attr-value"><code>author</code></dfn>"<a href="#link-type-author" class="self-link"></a></h5>

  <p>The <code id="link-type-author:link-type-author"><a href="#link-type-author">author</a></code> keyword may be used with <code id="link-type-author:the-link-element"><a href="#the-link-element">link</a></code>,
  <code id="link-type-author:the-a-element"><a href="#the-a-element">a</a></code>, and <code id="link-type-author:the-area-element"><a href="#the-area-element">area</a></code> elements. This keyword creates a <a href="#hyperlink" id="link-type-author:hyperlink">hyperlink</a>.</p>

  <p>For <code id="link-type-author:the-a-element-2"><a href="#the-a-element">a</a></code> and <code id="link-type-author:the-area-element-2"><a href="#the-area-element">area</a></code> elements, the <code id="link-type-author:link-type-author-2"><a href="#link-type-author">author</a></code>
  keyword indicates that the referenced document provides further information about the author of
  the nearest <code id="link-type-author:the-article-element"><a href="#the-article-element">article</a></code> element ancestor of the element defining the hyperlink, if there
  is one, or of the page as a whole, otherwise.</p>

  <p>For <code id="link-type-author:the-link-element-2"><a href="#the-link-element">link</a></code> elements, the <code id="link-type-author:link-type-author-3"><a href="#link-type-author">author</a></code> keyword indicates
  that the referenced document provides further information about the author for the page as a
  whole.</p>

  <p class="note">The "referenced document" can be, and often is, a <code id="link-type-author:mailto-protocol"><a data-x-internal="mailto-protocol" href="https://www.rfc-editor.org/rfc/rfc6068#section-2">mailto:</a></code> URL giving the email address of the author. <a href="#refsMAILTO">[MAILTO]</a></p>

  

  <p><strong>Synonyms</strong>: For historical reasons, user agents must also treat
  <code id="link-type-author:the-link-element-3"><a href="#the-link-element">link</a></code>, <code id="link-type-author:the-a-element-3"><a href="#the-a-element">a</a></code>, and <code id="link-type-author:the-area-element-3"><a href="#the-area-element">area</a></code> elements that have a <code>rev</code> attribute with the value "<code>made</code>" as having the <code id="link-type-author:link-type-author-4"><a href="#link-type-author">author</a></code> keyword specified as a link relationship.</p>

  


  <h5 id="link-type-bookmark"><span class="secno">4.6.7.3</span> Link type "<dfn data-dfn-for="a/rel,area/rel" data-dfn-type="attr-value"><code>bookmark</code></dfn>"<a href="#link-type-bookmark" class="self-link"></a></h5>

  <p>The <code id="link-type-bookmark:link-type-bookmark"><a href="#link-type-bookmark">bookmark</a></code> keyword may be used with <code id="link-type-bookmark:the-a-element"><a href="#the-a-element">a</a></code> and
  <code id="link-type-bookmark:the-area-element"><a href="#the-area-element">area</a></code> elements. This keyword creates a <a href="#hyperlink" id="link-type-bookmark:hyperlink">hyperlink</a>.</p>

  <p>The <code id="link-type-bookmark:link-type-bookmark-2"><a href="#link-type-bookmark">bookmark</a></code> keyword gives a permalink for the nearest
  ancestor <code id="link-type-bookmark:the-article-element"><a href="#the-article-element">article</a></code> element of the linking element in question, or of
  the section the linking element is most closely associated with, if
  there are no ancestor <code id="link-type-bookmark:the-article-element-2"><a href="#the-article-element">article</a></code> elements.</p>

  <div class="example">

   <p>The following snippet has three permalinks. A user agent could determine which permalink
   applies to which part of the spec by looking at where the permalinks are given.</p>

   <pre><code class="html"> ...
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Example of permalinks<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->First example<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"a.html"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"bookmark"</c-><c- p="">&gt;</c->This permalink applies to
   only the content from the first H2 to the second H2<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->. The DIV isn't
   exactly that section, but it roughly corresponds to it.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Second example<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"b"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"b.html"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"bookmark"</c-><c- p="">&gt;</c->This permalink applies to
   the outer ARTICLE element<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> (which could be, e.g., a blog post).<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">article</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"c"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"c.html"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"bookmark"</c-><c- p="">&gt;</c->This permalink applies to
    the inner ARTICLE element<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> (which could be, e.g., a blog comment).<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
 ...</code></pre>

  </div>


  <h5 id="link-type-canonical"><span class="secno">4.6.7.4</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>canonical</code></dfn>"<a href="#link-type-canonical" class="self-link"></a></h5>

  <p>The <code id="link-type-canonical:link-type-canonical"><a href="#link-type-canonical">canonical</a></code> keyword may be used with <code id="link-type-canonical:the-link-element"><a href="#the-link-element">link</a></code>
  element. This keyword creates a <a href="#hyperlink" id="link-type-canonical:hyperlink">hyperlink</a>.</p>

  <p>The <code id="link-type-canonical:link-type-canonical-2"><a href="#link-type-canonical">canonical</a></code> keyword indicates that URL given by the <code id="link-type-canonical:attr-link-href"><a href="#attr-link-href">href</a></code> attribute is the preferred URL for the current document. That
  helps search engines reduce duplicate content, as described in more detail in <cite>The Canonical
  Link Relation</cite>. <a href="#refsRFC6596">[RFC6596]</a></p>


  <h5 id="link-type-dns-prefetch"><span class="secno">4.6.7.5</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>dns-prefetch</code></dfn>"<a href="#link-type-dns-prefetch" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/dns-prefetch" title="The dns-prefetch keyword for the rel attribute of the <link> element is a hint to browsers that the user is likely to need resources from the target resource's origin, and therefore the browser can likely improve the user experience by preemptively performing DNS resolution for that origin.">Link_types/dns-prefetch</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari unknown"><span>Safari</span><span>?</span></span><span class="chrome yes"><span>Chrome</span><span>46+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie unknown"><span>Internet Explorer</span><span>?</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>Yes</span></span><span class="webview_android yes"><span>WebView Android</span><span>46+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="link-type-dns-prefetch:link-type-dns-prefetch"><a href="#link-type-dns-prefetch">dns-prefetch</a></code> keyword may be used with
  <code id="link-type-dns-prefetch:the-link-element"><a href="#the-link-element">link</a></code> elements. This keyword creates an <a href="#external-resource-link" id="link-type-dns-prefetch:external-resource-link">external
  resource link</a>. This keyword is <a href="#body-ok" id="link-type-dns-prefetch:body-ok">body-ok</a>.</p>

  <p>The <code id="link-type-dns-prefetch:link-type-dns-prefetch-2"><a href="#link-type-dns-prefetch">dns-prefetch</a></code> keyword indicates that preemptively
  performing DNS resolution for the <a href="#concept-origin" id="link-type-dns-prefetch:concept-origin">origin</a> of the specified resource is likely to be
  beneficial, as it is highly likely that the user will require resources located at that
  <a href="#concept-origin" id="link-type-dns-prefetch:concept-origin-2">origin</a>, and the user experience would be improved by preempting the latency costs
  associated with DNS resolution.</p>

  <p>There is no default type for resources given by the <code id="link-type-dns-prefetch:link-type-dns-prefetch-3"><a href="#link-type-dns-prefetch">dns-prefetch</a></code> keyword.</p>

  <div data-algorithm="">
  <p>The appropriate times to <a href="#fetch-and-process-the-linked-resource" id="link-type-dns-prefetch:fetch-and-process-the-linked-resource">fetch and
  process</a> this type of link are:</p>

  <ul><li><p>When the <a href="#external-resource-link" id="link-type-dns-prefetch:external-resource-link-2">external resource link</a> is created on a <code id="link-type-dns-prefetch:the-link-element-2"><a href="#the-link-element">link</a></code> element
   that is already <a href="#browsing-context-connected" id="link-type-dns-prefetch:browsing-context-connected">browsing-context connected</a>.</p></li><li><p>When the <a href="#external-resource-link" id="link-type-dns-prefetch:external-resource-link-3">external resource link</a>'s <code id="link-type-dns-prefetch:the-link-element-3"><a href="#the-link-element">link</a></code> element <a href="#becomes-browsing-context-connected" id="link-type-dns-prefetch:becomes-browsing-context-connected">becomes
   browsing-context connected</a>.</p></li><li><p>When the <code id="link-type-dns-prefetch:attr-link-href"><a href="#attr-link-href">href</a></code> attribute of the <code id="link-type-dns-prefetch:the-link-element-4"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-dns-prefetch:external-resource-link-4">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-dns-prefetch:browsing-context-connected-2">browsing-context
   connected</a> is changed.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>The <a href="#fetch-and-process-the-linked-resource" id="link-type-dns-prefetch:fetch-and-process-the-linked-resource-2">fetch and process the linked resource</a> steps for this type of linked resource,
  given a <code id="link-type-dns-prefetch:the-link-element-5"><a href="#the-link-element">link</a></code> element <var>el</var>, are:

  </p><ol><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="link-type-dns-prefetch:encoding-parsing-a-url">encoding-parsing a URL</a> given
   <var>el</var>'s <code id="link-type-dns-prefetch:attr-link-href-2"><a href="#attr-link-href">href</a></code> attribute's value, relative to
   <var>el</var>'s <a id="link-type-dns-prefetch:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>url</var> is failure, then return.</p></li><li><p>Let <var>partitionKey</var> be the result of <a href="https://fetch.spec.whatwg.org/#determine-the-network-partition-key" id="link-type-dns-prefetch:determine-the-network-partition-key" data-x-internal="determine-the-network-partition-key">determining the network partition key</a> given <var>el</var>'s
   <a id="link-type-dns-prefetch:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#relevant-settings-object" id="link-type-dns-prefetch:relevant-settings-object">relevant settings object</a>.</p></li><li>
    <p>The user agent should <a id="link-type-dns-prefetch:resolve-an-origin" href="https://fetch.spec.whatwg.org/#resolve-an-origin" data-x-internal="resolve-an-origin">resolve an origin</a> given <var>partitionKey</var> and
    <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="link-type-dns-prefetch:concept-url-origin" data-x-internal="concept-url-origin">origin</a>.</p>

    <p class="note">As the results of this algorithm can be cached, future fetches could be
    faster.</p>
   </li></ol>
  </div>


  <h5 id="link-type-expect"><span class="secno">4.6.7.6</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>expect</code></dfn>"<a href="#link-type-expect" class="self-link"></a></h5>

  <p>The <code id="link-type-expect:link-type-expect"><a href="#link-type-expect">expect</a></code> keyword may be used with <code id="link-type-expect:the-link-element"><a href="#the-link-element">link</a></code>
  elements. This keyword creates an <a href="#internal-resource-link" id="link-type-expect:internal-resource-link">internal resource
  link</a>.</p>

  <p>An <a href="#internal-resource-link" id="link-type-expect:internal-resource-link-2">internal resource link</a> created by the <code id="link-type-expect:link-type-expect-2"><a href="#link-type-expect">expect</a></code>
  keyword can be used to <a href="#render-blocked" id="link-type-expect:render-blocked">block rendering</a> until the element that
  it <a href="#the-indicated-part-of-the-document" id="link-type-expect:the-indicated-part-of-the-document">indicates</a> is connected to the document and fully
  parsed.</p>

  <p>There is no default type for resources given by the <code id="link-type-expect:link-type-expect-3"><a href="#link-type-expect">expect</a></code>
  keyword.</p>

  <div data-algorithm="">
  <p>Whenever any of the following conditions occur for a <code id="link-type-expect:the-link-element-2"><a href="#the-link-element">link</a></code> element
  <var>el</var>:</p>

  <ul><li><p>the <code id="link-type-expect:link-type-expect-4"><a href="#link-type-expect">expect</a></code> <a href="#internal-resource-link" id="link-type-expect:internal-resource-link-3">internal resource link</a> is created
   on <var>el</var> that is already <a href="#browsing-context-connected" id="link-type-expect:browsing-context-connected">browsing-context connected</a>;</p></li><li><p>an <code id="link-type-expect:link-type-expect-5"><a href="#link-type-expect">expect</a></code> <a href="#internal-resource-link" id="link-type-expect:internal-resource-link-4">internal resource link</a> has been
   created on <var>el</var> and <var>el</var> becomes
   <a href="#browsing-context-connected" id="link-type-expect:browsing-context-connected-2">browsing-context connected</a>;</p></li><li><p>an <code id="link-type-expect:link-type-expect-6"><a href="#link-type-expect">expect</a></code> <a href="#internal-resource-link" id="link-type-expect:internal-resource-link-5">internal resource link</a> has been
   created on <var>el</var>, <var>el</var> is already <a href="#browsing-context-connected" id="link-type-expect:browsing-context-connected-3">browsing-context connected</a>, and
   <var>el</var>'s <code id="link-type-expect:attr-link-href"><a href="#attr-link-href">href</a></code> attribute is set, changed, or removed;
   or</p></li><li><p>an <code id="link-type-expect:link-type-expect-7"><a href="#link-type-expect">expect</a></code> <a href="#internal-resource-link" id="link-type-expect:internal-resource-link-6">internal resource link</a> has been
   created on <var>el</var>, <var>el</var> is already <a href="#browsing-context-connected" id="link-type-expect:browsing-context-connected-4">browsing-context connected</a>, and
   <var>el</var>'s <code id="link-type-expect:attr-link-media"><a href="#attr-link-media">media</a></code> attribute is set, changed, or
   removed,</p></li></ul>

  <p>then <a href="#process-internal-resource-link" id="link-type-expect:process-internal-resource-link">process</a> <var>el</var>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="process-internal-resource-link">process internal resource link</dfn> given a <code id="link-type-expect:the-link-element-3"><a href="#the-link-element">link</a></code> element <var>el</var>,
  run these steps:</p>

  <ol><li><p>Let <var>doc</var> be <var>el</var>'s <a id="link-type-expect:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="link-type-expect:encoding-parsing-a-url">encoding-parsing a URL</a> given
   <var>el</var>'s <code id="link-type-expect:attr-link-href-2"><a href="#attr-link-href">href</a></code> attribute's value, relative to
   <var>doc</var>.</p></li><li><p>If this fails, or if <var>url</var> does not <a href="https://url.spec.whatwg.org/#concept-url-equals" id="link-type-expect:concept-url-equals" data-x-internal="concept-url-equals">equal</a> <var>doc</var>'s
   <a href="https://dom.spec.whatwg.org/#concept-document-url" id="link-type-expect:the-document's-address" data-x-internal="the-document's-address">URL</a> with <i id="link-type-expect:url-equals-exclude-fragments"><a data-x-internal="url-equals-exclude-fragments" href="https://url.spec.whatwg.org/#url-equals-exclude-fragments">exclude fragments</a></i> set to false, then <a href="#unblock-rendering" id="link-type-expect:unblock-rendering">unblock rendering</a> on
   <var>el</var> and return.</p></li><li><p>Let <var>indicatedElement</var> be the result of <a href="#select-the-indicated-part" id="link-type-expect:select-the-indicated-part">selecting the indicated part</a> given <var>doc</var>
   and <var>url</var>.</p></li><li>
    <p>If all of the following are true:</p>

    <ul><li><p><var>doc</var>'s <a href="#current-document-readiness" id="link-type-expect:current-document-readiness">current document readiness</a> is "<code>loading</code>";</p></li><li><p><var>el</var> creates an <a href="#internal-resource-link" id="link-type-expect:internal-resource-link-7">internal resource link</a>;</p></li><li><p><var>el</var> is <a href="#browsing-context-connected" id="link-type-expect:browsing-context-connected-5">browsing-context connected</a>;</p></li><li><p><var>el</var>'s <code id="link-type-expect:attr-link-rel"><a href="#attr-link-rel">rel</a></code> attribute
     contains <code id="link-type-expect:link-type-expect-8"><a href="#link-type-expect">expect</a></code>;</p></li><li><p><var>el</var> is <a href="#potentially-render-blocking" id="link-type-expect:potentially-render-blocking">potentially render-blocking</a>;</p></li><li><p><var>el</var>'s <code id="link-type-expect:attr-link-media-2"><a href="#attr-link-media">media</a></code> attribute
     <a href="#matches-the-environment" id="link-type-expect:matches-the-environment">matches the environment</a>; and</p></li><li><p><var>indicatedElement</var> is not an element, or is on a
     <a href="#stack-of-open-elements" id="link-type-expect:stack-of-open-elements">stack of open elements</a> of an <a href="#html-parser" id="link-type-expect:html-parser">HTML parser</a> whose associated
     <code id="link-type-expect:document"><a href="#document">Document</a></code> is <var>doc</var>,</p></li></ul>

     <p>then <a href="#block-rendering" id="link-type-expect:block-rendering">block rendering</a> on <var>el</var>.</p>
   </li><li><p>Otherwise, <a href="#unblock-rendering" id="link-type-expect:unblock-rendering-2">unblock rendering</a> on <var>el</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="process-internal-resource-links">process internal resource links</dfn> given a <code id="link-type-expect:document-2"><a href="#document">Document</a></code> <var>doc</var>:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="link-type-expect:list-iterate" data-x-internal="list-iterate">For each</a> <code id="link-type-expect:link-type-expect-9"><a href="#link-type-expect">expect</a></code> <code id="link-type-expect:the-link-element-4"><a href="#the-link-element">link</a></code> element <var>link</var> in
   <var>doc</var>'s <a href="#render-blocking-element-set" id="link-type-expect:render-blocking-element-set">render-blocking element set</a>, <a href="#process-internal-resource-link" id="link-type-expect:process-internal-resource-link-2">process</a> <var>link</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The following <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="link-type-expect:concept-element-attributes-change-ext" data-x-internal="concept-element-attributes-change-ext">attribute change
  steps</a>, given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
  <var>value</var>, and <var>namespace</var>, are used to ensure <code id="link-type-expect:link-type-expect-10"><a href="#link-type-expect">expect</a></code> <code id="link-type-expect:the-link-element-5"><a href="#the-link-element">link</a></code> elements respond to dynamic <code id="link-type-expect:the-id-attribute"><a href="#the-id-attribute">id</a></code> and <code id="link-type-expect:attr-a-name"><a href="#attr-a-name">name</a></code> changes:</p>

  <ol><li><p>If <var>namespace</var> is not null, then return.</p></li><li><p>If <var>element</var> is in a <a href="#stack-of-open-elements" id="link-type-expect:stack-of-open-elements-2">stack of open elements</a> of an
   <a href="#html-parser" id="link-type-expect:html-parser-2">HTML parser</a>, then return.</p></li><li>
    <p>If any of the following is true:</p>

    <ul><li><p><var>localName</var> is <code id="link-type-expect:the-id-attribute-2"><a href="#the-id-attribute">id</a></code>; or</p></li><li><p><var>localName</var> is <code id="link-type-expect:attr-a-name-2"><a href="#attr-a-name">name</a></code> and <var>element</var> is an <code id="link-type-expect:the-a-element"><a href="#the-a-element">a</a></code> element,</p></li></ul>

    <p>then <a href="#process-internal-resource-links" id="link-type-expect:process-internal-resource-links">process internal resource links</a> given <var>element</var>'s
    <a id="link-type-expect:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p>
   </li></ol>
  </div>

  <h5 id="link-type-external"><span class="secno">4.6.7.7</span> Link type "<dfn data-dfn-for="a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>external</code></dfn>"<a href="#link-type-external" class="self-link"></a></h5>
  

  <p>The <code id="link-type-external:link-type-external"><a href="#link-type-external">external</a></code> keyword may be used with <code id="link-type-external:the-a-element"><a href="#the-a-element">a</a></code>,
  <code id="link-type-external:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-external:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword does not create a
  <a href="#hyperlink" id="link-type-external:hyperlink">hyperlink</a>, but <a href="#hyperlink-annotation" id="link-type-external:hyperlink-annotation">annotates</a> any other
  hyperlinks created by the element (the implied hyperlink, if no other keywords create one).</p>

  <p>The <code id="link-type-external:link-type-external-2"><a href="#link-type-external">external</a></code> keyword indicates that the link is leading to a
  document that is not part of the site that the current document forms a part of.</p>


  <h5 id="link-type-help"><span class="secno">4.6.7.8</span> Link type "<dfn data-dfn-for="link/rel,a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>help</code></dfn>"<a href="#link-type-help" class="self-link"></a></h5>

  <p>The <code id="link-type-help:link-type-help"><a href="#link-type-help">help</a></code> keyword may be used with <code id="link-type-help:the-link-element"><a href="#the-link-element">link</a></code>,
  <code id="link-type-help:the-a-element"><a href="#the-a-element">a</a></code>, <code id="link-type-help:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-help:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword creates a
  <a href="#hyperlink" id="link-type-help:hyperlink">hyperlink</a>.</p>

  <p>For <code id="link-type-help:the-a-element-2"><a href="#the-a-element">a</a></code>, <code id="link-type-help:the-area-element-2"><a href="#the-area-element">area</a></code>, and <code id="link-type-help:the-form-element-2"><a href="#the-form-element">form</a></code> elements, the <code id="link-type-help:link-type-help-2"><a href="#link-type-help">help</a></code> keyword indicates that the referenced document provides further help
  information for the parent of the element defining the hyperlink, and its children.</p>

  <div class="example">

   <p>In the following example, the form control has associated context-sensitive help. The user
   agent could use this information, for example, displaying the referenced document if the user
   presses the "Help" or "F1" key.</p>

   <pre><code class="html"> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> Topic: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">topic</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"help/topic.html"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"help"</c-><c- p="">&gt;</c->(Help)<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>For <code id="link-type-help:the-link-element-2"><a href="#the-link-element">link</a></code> elements, the <code id="link-type-help:link-type-help-3"><a href="#link-type-help">help</a></code> keyword indicates that
  the referenced document provides help for the page as a whole.</p>

  <p>For <code id="link-type-help:the-a-element-3"><a href="#the-a-element">a</a></code> and <code id="link-type-help:the-area-element-3"><a href="#the-area-element">area</a></code> elements, on some browsers, the <code id="link-type-help:link-type-help-4"><a href="#link-type-help">help</a></code> keyword causes the link to use a different cursor.</p>


  <h5 id="rel-icon"><span class="secno">4.6.7.9</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>icon</code></dfn>"<a href="#rel-icon" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types#icon" title="The rel attribute defines the relationship between a linked resource and the current document. Valid on <link>, <a>, <area>, and <form>, the supported values depend on the element on which the attribute is found.">Link_types#icon</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios no"><span>Safari iOS</span><span>No</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android yes"><span>WebView Android</span><span>38+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>4.0+</span></span><span class="opera_android no"><span>Opera Android</span><span>No</span></span><hr><span class="caniuse"><span><a href="https://caniuse.com/#feat=link-icon-png" title="Favicons">caniuse.com table</a></span></span></div></div></div>

  <p>The <code id="rel-icon:rel-icon"><a href="#rel-icon">icon</a></code> keyword may be used with <code id="rel-icon:the-link-element"><a href="#the-link-element">link</a></code> elements.
  This keyword creates an <a href="#external-resource-link" id="rel-icon:external-resource-link">external resource link</a>.</p>

  

  <p>The specified resource is an icon representing the page or site, and should be used by the user
  agent when representing the page in the user interface.</p>

  

  <p>Icons could be auditory icons, visual icons, or other kinds of icons. If
  multiple icons are provided, the user agent must select the most appropriate icon according to the
  <code id="rel-icon:attr-link-type"><a href="#attr-link-type">type</a></code>, <code id="rel-icon:attr-link-media"><a href="#attr-link-media">media</a></code>, and <code id="rel-icon:attr-link-sizes"><a href="#attr-link-sizes">sizes</a></code> attributes. If there are multiple equally appropriate icons,
  user agents must use the last one declared in <a id="rel-icon:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> at the time that the user
  agent collected the list of icons. If the user agent tries to use an icon but that icon is
  determined, upon closer examination, to in fact be inappropriate (e.g. because it uses an
  unsupported format), then the user agent must try the next-most-appropriate icon as determined by
  the attributes.</p>

  

  <p class="note">User agents are not required to update icons when the list of icons changes, but
  are encouraged to do so.</p>

  <p>There is no default type for resources given by the <code id="rel-icon:rel-icon-2"><a href="#rel-icon">icon</a></code> keyword.
  However, for the purposes of <a href="#concept-link-type-sniffing">determining the type of the
  resource</a>, user agents must expect the resource to be an image.</p>

  

  <p>The <code id="rel-icon:attr-link-sizes-2"><a href="#attr-link-sizes">sizes</a></code> keywords represent icon sizes in raw pixels (as
  opposed to <a href="https://drafts.csswg.org/css-values/#px" id="rel-icon:'px'" data-x-internal="'px'">CSS pixels</a>).</p>

  <p class="note">An icon that is 50 <a href="https://drafts.csswg.org/css-values/#px" id="rel-icon:'px'-2" data-x-internal="'px'">CSS pixels</a> wide intended for
  displays with a device pixel density of two device pixels per <a href="https://drafts.csswg.org/css-values/#px" id="rel-icon:'px'-3" data-x-internal="'px'">CSS pixel</a>
  (2x, 192dpi) would have a width of 100 raw pixels. This feature does not support indicating that a
  different resource is to be used for small high-resolution icons vs large low-resolution icons
  (e.g. 50×50 2x vs 100×100 1x).</p>

  

  <p>To parse and process the attribute's value, the user agent must first <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="rel-icon:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">split the attribute's value on ASCII whitespace</a>, and must then
  parse each resulting keyword to determine what it represents.</p>

  

  <p>The <dfn id="attr-link-sizes-any"><code>any</code></dfn> keyword represents that the
  resource contains a scalable icon, e.g. as provided by an SVG image.</p>

  

  <div data-algorithm="">
  <p>Other keywords must be further parsed as follows to determine what they represent:</p>

  <ol><li><p>If the keyword doesn't contain exactly one U+0078 LATIN SMALL LETTER X or U+0058 LATIN
   CAPITAL LETTER X character, then this keyword doesn't represent anything. Return for
   that keyword.</p></li><li><p>Let <var>width string</var> be the string before the "<code>x</code>" or
   "<code>X</code>".</p></li><li><p>Let <var>height string</var> be the string after the "<code>x</code>" or
   "<code>X</code>".</p></li><li><p>If either <var>width string</var> or <var>height string</var> start with
   a U+0030 DIGIT ZERO (0) character or contain any characters other than <a id="rel-icon:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>,
   then this keyword doesn't represent anything. Return for that keyword.</p></li><li><p>Apply the <a href="#rules-for-parsing-non-negative-integers" id="rel-icon:rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a> to <var>width
   string</var> to obtain <var>width</var>.</p></li><li><p>Apply the <a href="#rules-for-parsing-non-negative-integers" id="rel-icon:rules-for-parsing-non-negative-integers-2">rules for parsing non-negative integers</a> to <var>height
   string</var> to obtain <var>height</var>.</p></li><li><p>The keyword represents that the resource contains a bitmap icon with a width of <var>width</var> device pixels and a height of <var>height</var> device
   pixels.</p></li></ol>
  </div>

  

  <p>The keywords specified on the <code id="rel-icon:attr-link-sizes-3"><a href="#attr-link-sizes">sizes</a></code> attribute must not
  represent icon sizes that are not actually available in the linked resource.</p>

  

  <div data-algorithm="">
  <p>The <a href="#linked-resource-fetch-setup-steps" id="rel-icon:linked-resource-fetch-setup-steps">linked resource fetch setup steps</a> for this type of linked resource, given a
  <code id="rel-icon:the-link-element-2"><a href="#the-link-element">link</a></code> element <var>el</var> and <a href="https://fetch.spec.whatwg.org/#concept-request" id="rel-icon:concept-request" data-x-internal="concept-request">request</a>
  <var>request</var>, are:</p>

  <ol><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="rel-icon:concept-request-destination" data-x-internal="concept-request-destination">destination</a> to
   "<code>image</code>".</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#process-a-link-header" id="rel-icon:process-a-link-header">process a link header</a> steps for this type of linked resource are to do
  nothing.</p>
  </div>

  <div data-algorithm="">
  <p>In the absence of a <code id="rel-icon:the-link-element-3"><a href="#the-link-element">link</a></code> with the <code id="rel-icon:rel-icon-3"><a href="#rel-icon">icon</a></code> keyword, for
  <code id="rel-icon:document"><a href="#document">Document</a></code> objects whose <a href="https://dom.spec.whatwg.org/#concept-document-url" id="rel-icon:the-document's-address" data-x-internal="the-document's-address">URL</a>'s
  <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="rel-icon:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is an <a id="rel-icon:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>, user agents may
  instead run these steps <a href="#in-parallel" id="rel-icon:in-parallel">in parallel</a>:</p>

  <ol><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="rel-icon:concept-request-2" data-x-internal="concept-request">request</a> whose
   <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="rel-icon:concept-request-url" data-x-internal="concept-request-url">URL</a> is the <a id="rel-icon:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> obtained by
   resolving the <a id="rel-icon:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> "<code>/favicon.ico</code>" against the
   <code id="rel-icon:document-2"><a href="#document">Document</a></code> object's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="rel-icon:the-document's-address-2" data-x-internal="the-document's-address">URL</a>, <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="rel-icon:concept-request-client" data-x-internal="concept-request-client">client</a> is the <code id="rel-icon:document-3"><a href="#document">Document</a></code> object's
   <a href="#relevant-settings-object" id="rel-icon:relevant-settings-object">relevant settings object</a>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="rel-icon:concept-request-destination-2" data-x-internal="concept-request-destination">destination</a> is "<code>image</code>",
   <a id="rel-icon:synchronous-flag" href="https://fetch.spec.whatwg.org/#synchronous-flag" data-x-internal="synchronous-flag">synchronous flag</a> is set, <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="rel-icon:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials
   mode</a> is "<code>include</code>", and whose <a id="rel-icon:use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a>
   is set.</p></li><li><p>Let <var>response</var> be the result of <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="rel-icon:concept-fetch" data-x-internal="concept-fetch">fetching</a> <var>request</var>.</p></li><li><p>Use <var>response</var>'s <a href="#unsafe-response" id="rel-icon:unsafe-response">unsafe response</a> as an icon as if it had been
   declared using the <code id="rel-icon:rel-icon-4"><a href="#rel-icon">icon</a></code> keyword.</p></li></ol>
  </div>

  

  <div class="example">

   <p>The following snippet shows the top part of an application with several icons.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->lsForums — Inbox<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">icon</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">favicon.png</c-> <c- e="">sizes</c-><c- o="">=</c-><c- s="">"16x16"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"image/png"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">icon</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">windows.ico</c-> <c- e="">sizes</c-><c- o="">=</c-><c- s="">"32x32 48x48"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"image/vnd.microsoft.icon"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">icon</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">mac.icns</c-> <c- e="">sizes</c-><c- o="">=</c-><c- s="">"128x128 512x512 8192x8192 32768x32768"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">icon</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">iphone.png</c-> <c- e="">sizes</c-><c- o="">=</c-><c- s="">"57x57"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"image/png"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">icon</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">gnome.svg</c-> <c- e="">sizes</c-><c- o="">=</c-><c- s="">"any"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"image/svg+xml"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">stylesheet</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">lsforums.css</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">lsforums.js</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">application-name</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"lsForums"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  ...</code></pre>

  </div>

  <p>For historical reasons, the <code id="rel-icon:rel-icon-5"><a href="#rel-icon">icon</a></code> keyword may be preceded by the
  keyword "<code>shortcut</code>". If the "<code>shortcut</code>" keyword is
  present, the <code id="rel-icon:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code> attribute's entire value must be an
  <a id="rel-icon:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>shortcut&nbsp;icon</code>" (with a single U+0020 SPACE character between the tokens and
  no other <a id="rel-icon:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>).</p>


  <h5 id="link-type-license"><span class="secno">4.6.7.10</span> Link type "<dfn data-dfn-for="link/rel,a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>license</code></dfn>"<a href="#link-type-license" class="self-link"></a></h5>

  <p>The <code id="link-type-license:link-type-license"><a href="#link-type-license">license</a></code> keyword may be used with <code id="link-type-license:the-link-element"><a href="#the-link-element">link</a></code>,
  <code id="link-type-license:the-a-element"><a href="#the-a-element">a</a></code>, <code id="link-type-license:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-license:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword creates a
  <a href="#hyperlink" id="link-type-license:hyperlink">hyperlink</a>.</p>

  <p>The <code id="link-type-license:link-type-license-2"><a href="#link-type-license">license</a></code> keyword indicates that the referenced document
  provides the copyright license terms under which the main content of the current document is
  provided.</p>

  <p>This specification does not specify how to distinguish between the main content of a document
  and content that is not deemed to be part of that main content. The distinction should be made
  clear to the user.</p>

  <div class="example">

   <p>Consider a photo sharing site. A page on that site might describe and show a photograph, and
   the page might be marked up as follows:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Exampl Pictures: Kissat<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"stylesheet"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/style/default"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Kissat<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"../"</c-><c- p="">&gt;</c->Return to photo index<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/pix/39627052_fd8dcd98b5.jpg"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Kissat<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->One of them has six toes!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"license"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"http://www.opensource.org/licenses/mit-license.php"</c-><c- p="">&gt;</c->MIT Licensed<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/"</c-><c- p="">&gt;</c->Home<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> | <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"../"</c-><c- p="">&gt;</c->Photo index<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->© copyright 2009 Exampl Pictures. All Rights Reserved.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>In this case the <code id="link-type-license:link-type-license-3"><a href="#link-type-license">license</a></code> applies to just the photo (the main
   content of the document), not the whole document. In particular not the design of the page
   itself, which is covered by the copyright given at the bottom of the document. This could be made
   clearer in the styling (e.g. making the license link prominently positioned near the photograph,
   while having the page copyright in light small text at the foot of the page).</p>

  </div>

  

  <p><strong>Synonyms</strong>: For historical reasons, user agents must also treat the keyword
  "<code>copyright</code>" like the <code id="link-type-license:link-type-license-4"><a href="#link-type-license">license</a></code> keyword.</p>

  


  <h5 id="link-type-manifest"><span class="secno">4.6.7.11</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>manifest</code></dfn>"<a href="#link-type-manifest" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/manifest" title="The manifest keyword for the rel attribute of the <link> element indicates that the target resource is a Web app manifest.">Link_types/manifest</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox unknown"><span>Firefox</span><span>?</span></span><span class="safari unknown"><span>Safari</span><span>?</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie unknown"><span>Internet Explorer</span><span>?</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>39+</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="link-type-manifest:link-type-manifest"><a href="#link-type-manifest">manifest</a></code> keyword may be used with <code id="link-type-manifest:the-link-element"><a href="#the-link-element">link</a></code> elements.
  This keyword creates an <a href="#external-resource-link" id="link-type-manifest:external-resource-link">external resource link</a>.</p>

  <p>The <code id="link-type-manifest:link-type-manifest-2"><a href="#link-type-manifest">manifest</a></code> keyword indicates the manifest file that provides
  metadata associated with the current document.</p>

  

  <p>There is no default type for resources given by the <code id="link-type-manifest:link-type-manifest-3"><a href="#link-type-manifest">manifest</a></code>
  keyword.</p>

  <p>When a web application is not <a href="https://w3c.github.io/manifest/#dfn-installed-web-application" id="link-type-manifest:installed-web-application" data-x-internal="installed-web-application">installed</a>, the
  appropriate time to <a href="#fetch-and-process-the-linked-resource" id="link-type-manifest:fetch-and-process-the-linked-resource">fetch and process the linked resource</a> for this link type is when
  the user agent deems it necessary. For example, when the user chooses to <a href="https://w3c.github.io/manifest/#dfn-installed-web-application" id="link-type-manifest:installed-web-application-2" data-x-internal="installed-web-application">install the web application</a>.</p>

  <div data-algorithm="">
  <p>For an <a href="https://w3c.github.io/manifest/#dfn-installed-web-application" id="link-type-manifest:installed-web-application-3" data-x-internal="installed-web-application">installed web application</a>, the
  appropriate times to <a href="#fetch-and-process-the-linked-resource" id="link-type-manifest:fetch-and-process-the-linked-resource-2">fetch and process the linked resource</a> for this link type
  are:</p>

  <ul><li><p>When the <a href="#external-resource-link" id="link-type-manifest:external-resource-link-2">external resource link</a> is created on a <code id="link-type-manifest:the-link-element-2"><a href="#the-link-element">link</a></code> element
   that is already <a href="#browsing-context-connected" id="link-type-manifest:browsing-context-connected">browsing-context connected</a>.</p></li><li><p>When the <a href="#external-resource-link" id="link-type-manifest:external-resource-link-3">external resource link</a>'s <code id="link-type-manifest:the-link-element-3"><a href="#the-link-element">link</a></code> element <a href="#becomes-browsing-context-connected" id="link-type-manifest:becomes-browsing-context-connected">becomes
   browsing-context connected</a>.</p></li><li><p>When the <code id="link-type-manifest:attr-link-href"><a href="#attr-link-href">href</a></code> attribute of the <code id="link-type-manifest:the-link-element-4"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-manifest:external-resource-link-4">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-manifest:browsing-context-connected-2">browsing-context
   connected</a> is changed.</p></li></ul>
  </div>

  <p>In any case, only the first <code id="link-type-manifest:the-link-element-5"><a href="#the-link-element">link</a></code> element in <a id="link-type-manifest:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> whose <code id="link-type-manifest:attr-link-rel"><a href="#attr-link-rel">rel</a></code> attribute contains the token <code id="link-type-manifest:link-type-manifest-4"><a href="#link-type-manifest">manifest</a></code> may be used.</p>

  <p>A user agent must not <a href="#delay-the-load-event" id="link-type-manifest:delay-the-load-event">delay the load event</a> for this link type.</p>

  <div data-algorithm="">
  <p>The <a href="#linked-resource-fetch-setup-steps" id="link-type-manifest:linked-resource-fetch-setup-steps">linked resource fetch setup steps</a> for this type of linked resource, given a
  <code id="link-type-manifest:the-link-element-6"><a href="#the-link-element">link</a></code> element <var>el</var> and <a href="https://fetch.spec.whatwg.org/#concept-request" id="link-type-manifest:concept-request" data-x-internal="concept-request">request</a>
  <var>request</var>, are:</p>

  <ol><li><p>Let <var>navigable</var> be <var>el</var>'s <a id="link-type-manifest:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#node-navigable" id="link-type-manifest:node-navigable">node
   navigable</a>.</p></li><li><p>If <var>navigable</var> is null, then return false.</p></li><li><p>If <var>navigable</var> is not a <a href="#top-level-traversable" id="link-type-manifest:top-level-traversable">top-level traversable</a>, then return
   false.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-initiator" id="link-type-manifest:concept-request-initiator" data-x-internal="concept-request-initiator">initiator</a> to
   "<code>manifest</code>".</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="link-type-manifest:concept-request-destination" data-x-internal="concept-request-destination">destination</a> to
   "<code>manifest</code>".</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="link-type-manifest:concept-request-mode" data-x-internal="concept-request-mode">mode</a> to "<code>cors</code>".</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="link-type-manifest:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials
   mode</a> to the <a href="#cors-settings-attribute-credentials-mode" id="link-type-manifest:cors-settings-attribute-credentials-mode">CORS settings attribute credentials mode</a> for <var>el</var>'s
   <code id="link-type-manifest:attr-link-crossorigin"><a href="#attr-link-crossorigin">crossorigin</a></code> content attribute.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <a href="#process-the-linked-resource" id="link-type-manifest:process-the-linked-resource">process this type of linked resource</a> given
  a <code id="link-type-manifest:the-link-element-7"><a href="#the-link-element">link</a></code> element <var>el</var>, boolean <var>success</var>, <a href="https://fetch.spec.whatwg.org/#concept-response" id="link-type-manifest:concept-response" data-x-internal="concept-response">response</a> <var>response</var>, and <a id="link-type-manifest:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a>
  <var>bodyBytes</var>:</p>

  <ol><li><p>If <var>response</var>'s <a href="#content-type" id="link-type-manifest:content-type">Content-Type metadata</a> is not a
   <a id="link-type-manifest:json-mime-type" href="https://mimesniff.spec.whatwg.org/#json-mime-type" data-x-internal="json-mime-type">JSON MIME type</a>, then set <var>success</var> to false.</p></li><li>
    <p>If <var>success</var> is true:</p>

    <ol><li><p>Let <var>document URL</var> be <var>el</var>'s <a id="link-type-manifest:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="link-type-manifest:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li><p>Let <var>manifest URL</var> be <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="link-type-manifest:concept-response-url" data-x-internal="concept-response-url">URL</a>.</p></li><li><p><a id="link-type-manifest:process-the-manifest" href="https://w3c.github.io/manifest/#dfn-processing-a-manifest" data-x-internal="process-the-manifest">Process the manifest</a> given <var>document URL</var>, <var>manifest
     URL</var>, and <var>bodyBytes</var>. <a href="#refsMANIFEST">[MANIFEST]</a></p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#process-a-link-header" id="link-type-manifest:process-a-link-header">process a link header</a> steps for this type of linked resource are to do
  nothing.</p>
  </div>

  


  <h5 id="link-type-modulepreload"><span class="secno">4.6.7.12</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>modulepreload</code></dfn>"<a href="#link-type-modulepreload" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/modulepreload" title="The modulepreload keyword, for the rel attribute of the <link> element, provides a declarative way to preemptively fetch a module script, parse and compile it, and store it in the document's module map for later execution.">Link_types/modulepreload</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>115+</span></span><span class="safari unknown"><span>Safari</span><span>?</span></span><span class="chrome yes"><span>Chrome</span><span>66+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie unknown"><span>Internet Explorer</span><span>?</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="link-type-modulepreload:link-type-modulepreload"><a href="#link-type-modulepreload">modulepreload</a></code> keyword may be used with
  <code id="link-type-modulepreload:the-link-element"><a href="#the-link-element">link</a></code> elements. This keyword creates an <a href="#external-resource-link" id="link-type-modulepreload:external-resource-link">external resource link</a>. This
  keyword is <a href="#body-ok" id="link-type-modulepreload:body-ok">body-ok</a>.</p>

  <p>The <code id="link-type-modulepreload:link-type-modulepreload-2"><a href="#link-type-modulepreload">modulepreload</a></code> keyword is a specialized alternative
  to the <code id="link-type-modulepreload:link-type-preload"><a href="#link-type-preload">preload</a></code> keyword, with a processing model geared toward
  preloading <a href="#module-script" id="link-type-modulepreload:module-script">module scripts</a>. In particular, it uses the specific
  fetch behavior for module scripts (including, e.g., a different interpretation of the <code id="link-type-modulepreload:attr-link-crossorigin"><a href="#attr-link-crossorigin">crossorigin</a></code> attribute), and places the result into the
  appropriate <a href="#concept-document-module-map" id="link-type-modulepreload:concept-document-module-map">module map</a> for later evaluation. In
  contrast, a similar <a href="#external-resource-link" id="link-type-modulepreload:external-resource-link-2">external resource link</a> using the <code id="link-type-modulepreload:link-type-preload-2"><a href="#link-type-preload">preload</a></code> keyword would place the result in the preload cache, without
  affecting the document's <a href="#concept-document-module-map" id="link-type-modulepreload:concept-document-module-map-2">module map</a>.</p>

  <p>Additionally, implementations can take advantage of the fact that <a href="#module-script" id="link-type-modulepreload:module-script-2">module scripts</a> declare their dependencies in order to fetch the specified module's
  dependency as well. This is intended as an optimization opportunity, since the user agent knows
  that, in all likelihood, those dependencies will also be needed later. It will not generally be
  observable without using technology such as service workers, or monitoring on the server side.
  Notably, the appropriate <code id="link-type-modulepreload:event-load"><a href="#event-load">load</a></code> or <code id="link-type-modulepreload:event-error"><a href="#event-error">error</a></code> events will occur after the specified module is fetched, and
  will not wait for any dependencies.</p>

  

  <p>A user agent must not <a href="#delay-the-load-event" id="link-type-modulepreload:delay-the-load-event">delay the load event</a> for this link type.</p>

  <div data-algorithm="">
  <p>The appropriate times to <a href="#fetch-and-process-the-linked-resource" id="link-type-modulepreload:fetch-and-process-the-linked-resource">fetch and process the linked resource</a> for such a link
  are:</p>

  <ul><li><p>When the <a href="#external-resource-link" id="link-type-modulepreload:external-resource-link-3">external resource link</a> is created on a <code id="link-type-modulepreload:the-link-element-2"><a href="#the-link-element">link</a></code> element
   that is already <a href="#browsing-context-connected" id="link-type-modulepreload:browsing-context-connected">browsing-context connected</a>.</p></li><li><p>When the <a href="#external-resource-link" id="link-type-modulepreload:external-resource-link-4">external resource link</a>'s <code id="link-type-modulepreload:the-link-element-3"><a href="#the-link-element">link</a></code> element <a href="#becomes-browsing-context-connected" id="link-type-modulepreload:becomes-browsing-context-connected">becomes
   browsing-context connected</a>.</p></li><li><p>When the <code id="link-type-modulepreload:attr-link-href"><a href="#attr-link-href">href</a></code> attribute of the <code id="link-type-modulepreload:the-link-element-4"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-modulepreload:external-resource-link-5">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-modulepreload:browsing-context-connected-2">browsing-context
   connected</a> is changed.</p></li></ul>
  </div>

  

  <p class="note">Unlike some other link relations, changing the relevant attributes (such as <code id="link-type-modulepreload:attr-link-as"><a href="#attr-link-as">as</a></code>, <code id="link-type-modulepreload:attr-link-crossorigin-2"><a href="#attr-link-crossorigin">crossorigin</a></code>, and
  <code id="link-type-modulepreload:attr-link-referrerpolicy"><a href="#attr-link-referrerpolicy">referrerpolicy</a></code>) of such a <code id="link-type-modulepreload:the-link-element-5"><a href="#the-link-element">link</a></code>
  does not trigger a new fetch. This is because the document's <a href="#concept-document-module-map" id="link-type-modulepreload:concept-document-module-map-3">module map</a> has already been populated by a previous
  fetch, and so re-fetching would be pointless.</p>

  

  <div data-algorithm="">
  <p>The <a href="#fetch-and-process-the-linked-resource" id="link-type-modulepreload:fetch-and-process-the-linked-resource-2">fetch and process the linked resource</a> algorithm for <code id="link-type-modulepreload:link-type-modulepreload-3"><a href="#link-type-modulepreload">modulepreload</a></code> links, given a <code id="link-type-modulepreload:the-link-element-6"><a href="#the-link-element">link</a></code> element
  <var>el</var>, is as follows:</p>

  <ol><li><p>If <var>el</var>'s <code id="link-type-modulepreload:attr-link-href-2"><a href="#attr-link-href">href</a></code> attribute's value is the
   empty string, then return.</p></li><li><p>Let <var>destination</var> be the current state of <var>el</var>'s <code id="link-type-modulepreload:attr-link-as-2"><a href="#attr-link-as">as</a></code> attribute (a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="link-type-modulepreload:concept-request-destination" data-x-internal="concept-request-destination">destination</a>), or "<code>script</code>" if
   it is in no state.</p></li><li><p>If <var>destination</var> is not <a href="https://fetch.spec.whatwg.org/#request-destination-script-like" id="link-type-modulepreload:concept-script-like-destination" data-x-internal="concept-script-like-destination">script-like</a>, then <a href="#queue-an-element-task" id="link-type-modulepreload:queue-an-element-task">queue an element
   task</a> on the <a href="#networking-task-source" id="link-type-modulepreload:networking-task-source">networking task source</a> given <var>el</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="link-type-modulepreload:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="link-type-modulepreload:event-error-2"><a href="#event-error">error</a></code>
   at <var>el</var>, and return.</p></li><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="link-type-modulepreload:encoding-parsing-a-url">encoding-parsing a URL</a> given
   <var>el</var>'s <code id="link-type-modulepreload:attr-link-href-3"><a href="#attr-link-href">href</a></code> attribute's value, relative to
   <var>el</var>'s <a id="link-type-modulepreload:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>url</var> is failure, then return.</p></li><li><p>Let <var>settings object</var> be <var>el</var>'s <a id="link-type-modulepreload:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
   <a href="#relevant-settings-object" id="link-type-modulepreload:relevant-settings-object">relevant settings object</a>.</p></li><li><p>Let <var>credentials mode</var> be the <a href="#cors-settings-attribute-credentials-mode" id="link-type-modulepreload:cors-settings-attribute-credentials-mode">CORS settings attribute credentials
   mode</a> for <var>el</var>'s <code id="link-type-modulepreload:attr-link-crossorigin-3"><a href="#attr-link-crossorigin">crossorigin</a></code>
   attribute.</p></li><li><p>Let <var>cryptographic nonce</var> be
   <var>el</var>.<a href="#cryptographicnonce" id="link-type-modulepreload:cryptographicnonce">[[CryptographicNonce]]</a>.</p></li><li><p>Let <var>integrity metadata</var> be the value of <var>el</var>'s <code id="link-type-modulepreload:attr-link-integrity"><a href="#attr-link-integrity">integrity</a></code> attribute, if it is specified, or the empty string
   otherwise.</p></li><li><p>If <var>el</var> does not have an <code id="link-type-modulepreload:attr-link-integrity-2"><a href="#attr-link-integrity">integrity</a></code>
   attribute, then set <var>integrity metadata</var> to the result of <a href="#resolving-a-module-integrity-metadata" id="link-type-modulepreload:resolving-a-module-integrity-metadata">resolving a module
   integrity metadata</a> with <var>url</var> and <var>settings object</var>.</p></li><li><p>Let <var>referrer policy</var> be the current state of <var>el</var>'s <code id="link-type-modulepreload:attr-link-referrerpolicy-2"><a href="#attr-link-referrerpolicy">referrerpolicy</a></code> attribute.</p></li><li><p>Let <var>fetch priority</var> be the current state of <var>el</var>'s <code id="link-type-modulepreload:attr-link-fetchpriority"><a href="#attr-link-fetchpriority">fetchpriority</a></code> attribute.</p></li><li><p>Let <var>options</var> be a <a href="#script-fetch-options" id="link-type-modulepreload:script-fetch-options">script fetch options</a> whose <a href="#concept-script-fetch-options-nonce" id="link-type-modulepreload:concept-script-fetch-options-nonce">cryptographic nonce</a> is <var>cryptographic
   nonce</var>, <a href="#concept-script-fetch-options-integrity" id="link-type-modulepreload:concept-script-fetch-options-integrity">integrity metadata</a> is
   <var>integrity metadata</var>, <a href="#concept-script-fetch-options-parser" id="link-type-modulepreload:concept-script-fetch-options-parser">parser
   metadata</a> is "<code>not-parser-inserted</code>", <a href="#concept-script-fetch-options-credentials" id="link-type-modulepreload:concept-script-fetch-options-credentials">credentials mode</a> is <var>credentials
   mode</var>, <a href="#concept-script-fetch-options-referrer-policy" id="link-type-modulepreload:concept-script-fetch-options-referrer-policy">referrer
   policy</a> is <var>referrer policy</var>, and <a href="#concept-script-fetch-options-fetch-priority" id="link-type-modulepreload:concept-script-fetch-options-fetch-priority">fetch priority</a> is
   <var>fetch priority</var>.</p></li><li>
    <p><a href="#fetch-a-modulepreload-module-script-graph" id="link-type-modulepreload:fetch-a-modulepreload-module-script-graph">Fetch a modulepreload module script graph</a> given <var>url</var>,
    <var>destination</var>, <var>settings object</var>, <var>options</var>, and with the following
    steps given <var>result</var>:</p>

    <ol><li><p>If <var>result</var> is null, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="link-type-modulepreload:concept-event-fire-2" data-x-internal="concept-event-fire">fire an
     event</a> named <code id="link-type-modulepreload:event-error-3"><a href="#event-error">error</a></code> at <var>el</var>,
     and return.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="link-type-modulepreload:concept-event-fire-3" data-x-internal="concept-event-fire">Fire an event</a> named <code id="link-type-modulepreload:event-load-2"><a href="#event-load">load</a></code> at <var>el</var>.</p></li></ol>
   </li></ol>
  </div>

   <div data-algorithm="">
   <p>The <a href="#process-a-link-header" id="link-type-modulepreload:process-a-link-header">process a link header</a> steps for this type of linked resource are to do
   nothing.</p>
   </div>

  

  <div id="example-modulepreload-manifest" class="example"><a href="#example-modulepreload-manifest" class="self-link"></a>
   <p>The following snippet shows the top part of an application with several modules preloaded:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->IRCFog<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"modulepreload"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"app.mjs"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"modulepreload"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"helpers.mjs"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"modulepreload"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"irc.mjs"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"modulepreload"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"fog-machine.mjs"</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"module"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"app.mjs"</c-><c- p="">&gt;</c->
<c- p="">...</c-></code></pre>

   <p>Assume that the module graph for the application is as follows:</p>

   <img class="darkmode-aware" src="/images/ircfog-modules.svg" width="301" alt="The module graph is rooted at app.mjs, which depends on irc.mjs and fog-machine.mjs. In turn, irc.mjs depends on helpers.mjs." height="151">

   <p>Here we see the application developer has used <code id="link-type-modulepreload:link-type-modulepreload-4"><a href="#link-type-modulepreload">modulepreload</a></code> to declare all of the modules in their module graph,
   ensuring that the user agent initiates fetches for them all. Without such preloading, the user
   agent might need to go through multiple network roundtrips before discovering <code>helpers.mjs</code>, if technologies such as HTTP/2 Server Push are not in play. In
   this way, <code id="link-type-modulepreload:link-type-modulepreload-5"><a href="#link-type-modulepreload">modulepreload</a></code> <code id="link-type-modulepreload:the-link-element-7"><a href="#the-link-element">link</a></code> elements can be
   used as a sort of "manifest" of the application's modules.</p>
  </div>

  <div id="example-modulepreload-dynamic-import" class="example"><a href="#example-modulepreload-dynamic-import" class="self-link"></a>
   <p>The following code shows how <code id="link-type-modulepreload:link-type-modulepreload-6"><a href="#link-type-modulepreload">modulepreload</a></code> links can
   be used in conjunction with <code id="link-type-modulepreload:import()"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> to ensure network fetching is done ahead of
   time, so that when <code id="link-type-modulepreload:import()-2"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> is called, the module is already ready (but not
   evaluated) in the <a href="#module-map" id="link-type-modulepreload:module-map">module map</a>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">link</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"modulepreload"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"awesome-viewer.mjs"</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"import('./awesome-viewer.mjs').then(m =&gt; m.view())"</c-><c- p="">&gt;</c->
  View awesome thing
<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <h5 id="link-type-nofollow"><span class="secno">4.6.7.13</span> Link type "<dfn data-dfn-for="a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>nofollow</code></dfn>"<a href="#link-type-nofollow" class="self-link"></a></h5>

  <p>The <code id="link-type-nofollow:link-type-nofollow"><a href="#link-type-nofollow">nofollow</a></code> keyword may be used with <code id="link-type-nofollow:the-a-element"><a href="#the-a-element">a</a></code>,
  <code id="link-type-nofollow:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-nofollow:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword does not create a
  <a href="#hyperlink" id="link-type-nofollow:hyperlink">hyperlink</a>, but <a href="#hyperlink-annotation" id="link-type-nofollow:hyperlink-annotation">annotates</a> any other
  hyperlinks created by the element (the implied hyperlink, if no other keywords create one).</p>

  <p>The <code id="link-type-nofollow:link-type-nofollow-2"><a href="#link-type-nofollow">nofollow</a></code> keyword indicates that the link is not endorsed
  by the original author or publisher of the page, or that the link to the referenced document was
  included primarily because of a commercial relationship between people affiliated with the two
  pages.</p>


  <h5 id="link-type-noopener"><span class="secno">4.6.7.14</span> Link type "<dfn data-dfn-for="a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>noopener</code></dfn>"<a href="#link-type-noopener" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/noopener" title="The noopener keyword for the rel attribute of the <a>, <area>, and <form> elements instructs the browser to navigate to the target resource without granting the new browsing context access to the document that opened it — by not setting the Window.opener property on the opened window (it returns null).">Link_types/noopener</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>52+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/noopener" title="The noopener keyword for the rel attribute of the <a>, <area>, and <form> elements instructs the browser to navigate to the target resource without granting the new browsing context access to the document that opened it — by not setting the Window.opener property on the opened window (it returns null).">Link_types/noopener</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>52+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="link-type-noopener:link-type-noopener"><a href="#link-type-noopener">noopener</a></code> keyword may be used with <code id="link-type-noopener:the-a-element"><a href="#the-a-element">a</a></code>,
  <code id="link-type-noopener:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-noopener:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword does not create a
  <a href="#hyperlink" id="link-type-noopener:hyperlink">hyperlink</a>, but <a href="#hyperlink-annotation" id="link-type-noopener:hyperlink-annotation">annotates</a> any other
  hyperlinks created by the element (the implied hyperlink, if no other keywords create one).</p>

  <p>The keyword indicates that any newly created <a href="#top-level-traversable" id="link-type-noopener:top-level-traversable">top-level traversable</a> which results
  from following the <a href="#hyperlink" id="link-type-noopener:hyperlink-2">hyperlink</a> will not contain an <a href="#auxiliary-browsing-context" id="link-type-noopener:auxiliary-browsing-context">auxiliary browsing
  context</a>. E.g., the resulting <code id="link-type-noopener:window"><a href="#window">Window</a></code>'s <code id="link-type-noopener:dom-opener"><a href="#dom-opener">opener</a></code>
  getter will return null.</p>

  <p class="note">See also the <a href="#noopener">processing model</a>.</p>

  <div class="example">
   <p>This typically creates a <a href="#top-level-traversable" id="link-type-noopener:top-level-traversable-2">top-level traversable</a> with an <a href="#auxiliary-browsing-context" id="link-type-noopener:auxiliary-browsing-context-2">auxiliary browsing
   context</a> (assuming there is no existing <a href="#navigable" id="link-type-noopener:navigable">navigable</a> whose <a href="#nav-target" id="link-type-noopener:nav-target">target name</a> is "<code>example</code>"):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">help.html</c-> <c- e="">target</c-><c- o="">=</c-><c- s="">example</c-><c- p="">&gt;</c->Help!<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>

   <p>This creates a <a href="#top-level-traversable" id="link-type-noopener:top-level-traversable-3">top-level traversable</a> with a non-<a href="#auxiliary-browsing-context" id="link-type-noopener:auxiliary-browsing-context-3">auxiliary browsing
   context</a> (assuming the same thing):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">help.html</c-> <c- e="">target</c-><c- o="">=</c-><c- s="">example</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">noopener</c-><c- p="">&gt;</c->Help!<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>

   <p>These are equivalent and only navigate the <a href="#nav-parent" id="link-type-noopener:nav-parent">parent
   navigable</a>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">index.html</c-> <c- e="">target</c-><c- o="">=</c-><c- s="">_parent</c-><c- p="">&gt;</c->Home<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">index.html</c-> <c- e="">target</c-><c- o="">=</c-><c- s="">_parent</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">noopener</c-><c- p="">&gt;</c->Home<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h5 id="link-type-noreferrer"><span class="secno">4.6.7.15</span> Link type "<dfn data-dfn-for="a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>noreferrer</code></dfn>"<a href="#link-type-noreferrer" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/noreferrer" title="The noreferrer keyword for the rel attribute of the <a>, <area>, and <form> elements instructs the browser, when navigating to the target resource, to omit the Referer header and otherwise leak no referrer information — and additionally to behave as if the noopener keyword were also specified.">Link_types/noreferrer</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>33+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>16+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Partial implementation.">🔰 11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.5+</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/noreferrer" title="The noreferrer keyword for the rel attribute of the <a>, <area>, and <form> elements instructs the browser, when navigating to the target resource, to omit the Referer header and otherwise leak no referrer information — and additionally to behave as if the noopener keyword were also specified.">Link_types/noreferrer</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>33+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>16+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Partial implementation.">🔰 11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.5+</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="link-type-noreferrer:link-type-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code> keyword may be used with <code id="link-type-noreferrer:the-a-element"><a href="#the-a-element">a</a></code>,
  <code id="link-type-noreferrer:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-noreferrer:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword does not create a
  <a href="#hyperlink" id="link-type-noreferrer:hyperlink">hyperlink</a>, but <a href="#hyperlink-annotation" id="link-type-noreferrer:hyperlink-annotation">annotates</a> any other
  hyperlinks created by the element (the implied hyperlink, if no other keywords create one).</p>

  <p>It indicates that no referrer information is to be leaked when following the link and also
  implies the <code id="link-type-noreferrer:link-type-noopener"><a href="#link-type-noopener">noopener</a></code> keyword behavior under the same
  conditions.</p>

  <p class="note">See also the <a href="#noreferrer-a-area-processing-model">processing
  model</a> where referrer is directly manipulated.</p>

  <p class="example"><code>&lt;a href="..." rel="noreferrer" target="_blank"&gt;</code>
  has the same behavior as <code>&lt;a href="..." rel="noreferrer noopener" target="_blank"&gt;</code>.</p>


  <h5 id="link-type-opener"><span class="secno">4.6.7.16</span> Link type "<dfn data-dfn-for="a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>opener</code></dfn>"<a href="#link-type-opener" class="self-link"></a></h5>

  <p>The <code id="link-type-opener:link-type-opener"><a href="#link-type-opener">opener</a></code> keyword may be used with <code id="link-type-opener:the-a-element"><a href="#the-a-element">a</a></code>,
  <code id="link-type-opener:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-opener:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword does not create a
  <a href="#hyperlink" id="link-type-opener:hyperlink">hyperlink</a>, but <a href="#hyperlink-annotation" id="link-type-opener:hyperlink-annotation">annotates</a> any other
  hyperlinks created by the element (the implied hyperlink, if no other keywords create one).</p>

  <p>The keyword indicates that any newly created <a href="#top-level-traversable" id="link-type-opener:top-level-traversable">top-level traversable</a> which results
  from following the <a href="#hyperlink" id="link-type-opener:hyperlink-2">hyperlink</a> will contain an <a href="#auxiliary-browsing-context" id="link-type-opener:auxiliary-browsing-context">auxiliary browsing
  context</a>.</p>

  <p class="note">See also the <a href="#opener-processing-model">processing model</a>.</p>

  <div class="example">
   <p>In the following example the <code id="link-type-opener:link-type-opener-2"><a href="#link-type-opener">opener</a></code> is used to allow the help
   page popup to navigate its opener, e.g., in case what the user is looking for can be found
   elsewhere. An alternative might be to use a named target, rather than <code>_blank</code>, but this has the potential to clash with existing names.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"..."</c-> <mark><c- e="">rel</c-><c- o="">=</c-><c- s="">opener</c-></mark> <c- e="">target</c-><c- o="">=</c-><c- s="">_blank</c-><c- p="">&gt;</c->Help!<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h5 id="link-type-pingback"><span class="secno">4.6.7.17</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>pingback</code></dfn>"<a href="#link-type-pingback" class="self-link"></a></h5>

  <p>The <code id="link-type-pingback:link-type-pingback"><a href="#link-type-pingback">pingback</a></code> keyword may be used with <code id="link-type-pingback:the-link-element"><a href="#the-link-element">link</a></code>
  elements. This keyword creates an <a href="#external-resource-link" id="link-type-pingback:external-resource-link">external resource
  link</a>. This keyword is <a href="#body-ok" id="link-type-pingback:body-ok">body-ok</a>.</p>

  <p>For the semantics of the <code id="link-type-pingback:link-type-pingback-2"><a href="#link-type-pingback">pingback</a></code> keyword, see
  <cite>Pingback 1.0</cite>. <a href="#refsPINGBACK">[PINGBACK]</a></p>


  <h5 id="link-type-preconnect"><span class="secno">4.6.7.18</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>preconnect</code></dfn>"<a href="#link-type-preconnect" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preconnect" title="The preconnect keyword for the rel attribute of the <link> element is a hint to browsers that the user is likely to need resources from the target resource's origin, and therefore the browser can likely improve the user experience by preemptively initiating a connection to that origin. Preconnecting speeds up future loads from a given origin by preemptively performing part or all of the handshake (DNS+TCP for HTTP, and DNS+TCP+TLS for HTTPS origins).">Link_types/preconnect</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>39+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>46+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>4.0+</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="link-type-preconnect:link-type-preconnect"><a href="#link-type-preconnect">preconnect</a></code> keyword may be used with <code id="link-type-preconnect:the-link-element"><a href="#the-link-element">link</a></code>
  elements. This keyword creates an <a href="#external-resource-link" id="link-type-preconnect:external-resource-link">external resource
  link</a>. This keyword is <a href="#body-ok" id="link-type-preconnect:body-ok">body-ok</a>.</p>

  <p>The <code id="link-type-preconnect:link-type-preconnect-2"><a href="#link-type-preconnect">preconnect</a></code> keyword indicates that preemptively
  initiating a connection to the <a href="#concept-origin" id="link-type-preconnect:concept-origin">origin</a> of the specified resource is likely to be
  beneficial, as it is highly likely that the user will require resources located at that
  <a href="#concept-origin" id="link-type-preconnect:concept-origin-2">origin</a>, and the user experience would be improved by preempting the latency costs
  associated with establishing the connection.</p>

  <p>There is no default type for resources given by the <code id="link-type-preconnect:link-type-preconnect-3"><a href="#link-type-preconnect">preconnect</a></code> keyword.</p>

  <p>A user agent must not <a href="#delay-the-load-event" id="link-type-preconnect:delay-the-load-event">delay the load event</a> for this link type.</p>

  <div data-algorithm="">
  <p>The appropriate times to <a href="#fetch-and-process-the-linked-resource" id="link-type-preconnect:fetch-and-process-the-linked-resource">fetch and
  process</a> this type of link are:</p>

  <ul><li><p>When the <a href="#external-resource-link" id="link-type-preconnect:external-resource-link-2">external resource link</a> is created on a <code id="link-type-preconnect:the-link-element-2"><a href="#the-link-element">link</a></code> element
   that is already <a href="#browsing-context-connected" id="link-type-preconnect:browsing-context-connected">browsing-context connected</a>.</p></li><li><p>When the <a href="#external-resource-link" id="link-type-preconnect:external-resource-link-3">external resource link</a>'s <code id="link-type-preconnect:the-link-element-3"><a href="#the-link-element">link</a></code> element <a href="#becomes-browsing-context-connected" id="link-type-preconnect:becomes-browsing-context-connected">becomes
   browsing-context connected</a>.</p></li><li><p>When the <code id="link-type-preconnect:attr-link-href"><a href="#attr-link-href">href</a></code> attribute of the <code id="link-type-preconnect:the-link-element-4"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-preconnect:external-resource-link-4">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-preconnect:browsing-context-connected-2">browsing-context
   connected</a> is changed.</p></li><li><p>When the <code id="link-type-preconnect:attr-link-crossorigin"><a href="#attr-link-crossorigin">crossorigin</a></code> attribute of the
   <code id="link-type-preconnect:the-link-element-5"><a href="#the-link-element">link</a></code> element of an <a href="#external-resource-link" id="link-type-preconnect:external-resource-link-5">external resource
   link</a> that is already <a href="#browsing-context-connected" id="link-type-preconnect:browsing-context-connected-3">browsing-context connected</a> is set, changed, or
   removed.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>The <a href="#fetch-and-process-the-linked-resource" id="link-type-preconnect:fetch-and-process-the-linked-resource-2">fetch and process the linked resource</a> steps for this type of linked resource,
  given a <code id="link-type-preconnect:the-link-element-6"><a href="#the-link-element">link</a></code> element <var>el</var>, are to <a href="#create-link-options-from-element" id="link-type-preconnect:create-link-options-from-element">create link options</a> from <var>el</var> and
  to <a href="#preconnect" id="link-type-preconnect:preconnect">preconnect</a> given the result.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#process-a-link-header" id="link-type-preconnect:process-a-link-header">process a link header</a> step for this type of linked resource given a <a href="#link-processing-options" id="link-type-preconnect:link-processing-options">link processing options</a> <var>options</var> are to
  <a href="#preconnect" id="link-type-preconnect:preconnect-2">preconnect</a> given <var>options</var>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="preconnect">preconnect</dfn> given a <a href="#link-processing-options" id="link-type-preconnect:link-processing-options-2">link processing options</a> <var>options</var>:</p>

  <ol><li><p>If <var>options</var>'s
   <a href="#link-options-href" id="link-type-preconnect:link-options-href">href</a> is an empty string, return.</p></li><li>
    <p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="link-type-preconnect:encoding-parsing-a-url">encoding-parsing a URL</a> given
    <var>options</var>'s <a href="#link-options-href" id="link-type-preconnect:link-options-href-2">href</a>, relative to
    <var>options</var>'s <a href="#link-options-base-url" id="link-type-preconnect:link-options-base-url">base URL</a>.</p>

    <p class="XXX">Passing the base URL instead of a document or environment is tracked by <a href="https://github.com/whatwg/html/issues/9715">issue #9715</a>.</p>
   </li><li><p>If <var>url</var> is failure, then return.</p></li><li><p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="link-type-preconnect:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is not an
   <a id="link-type-preconnect:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>, then return.</p></li><li><p>Let <var>partitionKey</var> be the result of <a href="https://fetch.spec.whatwg.org/#determine-the-network-partition-key" id="link-type-preconnect:determine-the-network-partition-key" data-x-internal="determine-the-network-partition-key">determining the network partition key</a> given <var>options</var>'s
   <a href="#link-options-environment" id="link-type-preconnect:link-options-environment">environment</a>.</p></li><li><p>Let <var>useCredentials</var> be true.</p></li><li><p>If <var>options</var>'s <a href="#link-options-crossorigin" id="link-type-preconnect:link-options-crossorigin">crossorigin</a> is
   <a href="#attr-crossorigin-anonymous" id="link-type-preconnect:attr-crossorigin-anonymous">Anonymous</a> and <var>options</var>'s <a href="#link-options-origin" id="link-type-preconnect:link-options-origin">origin</a> does not
   have the <a href="#same-origin" id="link-type-preconnect:same-origin">same origin</a> as <var>url</var>'s
   <a href="https://url.spec.whatwg.org/#concept-url-origin" id="link-type-preconnect:concept-url-origin" data-x-internal="concept-url-origin">origin</a>, then set <var>useCredentials</var> to
   false.</p></li><li>
    <p>The user agent should <a id="link-type-preconnect:obtain-a-connection" href="https://fetch.spec.whatwg.org/#concept-connection-obtain" data-x-internal="obtain-a-connection">obtain a connection</a> given <var>partitionKey</var>,
    <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="link-type-preconnect:concept-url-origin-2" data-x-internal="concept-url-origin">origin</a>, and
    <var>useCredentials</var>.</p>

    <p class="note">This connection is obtained but not used directly. It will remain in the
    <a id="link-type-preconnect:connection-pool" href="https://fetch.spec.whatwg.org/#concept-connection-pool" data-x-internal="connection-pool">connection pool</a> for subsequent use.</p>

    <p>The user agent should attempt to initiate a preconnect and perform the full connection
    handshake (DNS+TCP for HTTP, and DNS+TCP+TLS for HTTPS origins) whenever possible, but is
    allowed to elect to perform a partial handshake (DNS only for HTTP, and DNS or DNS+TCP for
    HTTPS origins), or skip it entirely, due to resource constraints or other reasons.</p>

    <p>The optimal number of connections per origin is dependent on the negotiated protocol, users
    current connectivity profile, available device resources, global connection limits, and other
    context specific variables. As a result, the decision for how many connections should be opened
    is deferred to the user agent.</p>
   </li></ol>
  </div>

  <h5 id="link-type-prefetch"><span class="secno">4.6.7.19</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>prefetch</code></dfn>"<a href="#link-type-prefetch" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/prefetch" title="The prefetch keyword for the rel attribute of the <link> element is a hint to browsers that the user is likely to need the target resource for future navigations, and therefore the browser can likely improve the user experience by preemptively fetching and caching the resource.">Link_types/prefetch</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.5+</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="link-type-prefetch:link-type-prefetch"><a href="#link-type-prefetch">prefetch</a></code> keyword may be used with <code id="link-type-prefetch:the-link-element"><a href="#the-link-element">link</a></code>
  elements. This keyword creates an <a href="#external-resource-link" id="link-type-prefetch:external-resource-link">external resource
  link</a>. This keyword is <a href="#body-ok" id="link-type-prefetch:body-ok">body-ok</a>.</p>

  <p>The <code id="link-type-prefetch:link-type-prefetch-2"><a href="#link-type-prefetch">prefetch</a></code> keyword indicates that preemptively <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="link-type-prefetch:concept-fetch" data-x-internal="concept-fetch">fetching</a> and caching the specified resource or same-site document is
  likely to be beneficial, as it is highly likely that the user will require this resource for
  future navigations.</p>

  <p>There is no default type for resources given by the <code id="link-type-prefetch:link-type-prefetch-3"><a href="#link-type-prefetch">prefetch</a></code>
  keyword.</p>

  <div data-algorithm="">
  <p>The appropriate times to <a href="#fetch-and-process-the-linked-resource" id="link-type-prefetch:fetch-and-process-the-linked-resource">fetch and
  process</a> this type of link are:</p>

  <ul><li><p>When the <a href="#external-resource-link" id="link-type-prefetch:external-resource-link-2">external resource link</a> is created on a <code id="link-type-prefetch:the-link-element-2"><a href="#the-link-element">link</a></code> element
   that is already <a href="#browsing-context-connected" id="link-type-prefetch:browsing-context-connected">browsing-context connected</a>.</p></li><li><p>When the <a href="#external-resource-link" id="link-type-prefetch:external-resource-link-3">external resource link</a>'s <code id="link-type-prefetch:the-link-element-3"><a href="#the-link-element">link</a></code> element <a href="#becomes-browsing-context-connected" id="link-type-prefetch:becomes-browsing-context-connected">becomes
   browsing-context connected</a>.</p></li><li><p>When the <code id="link-type-prefetch:attr-link-href"><a href="#attr-link-href">href</a></code> attribute of the <code id="link-type-prefetch:the-link-element-4"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-prefetch:external-resource-link-4">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-prefetch:browsing-context-connected-2">browsing-context
   connected</a> is changed.</p></li><li><p>When the <code id="link-type-prefetch:attr-link-crossorigin"><a href="#attr-link-crossorigin">crossorigin</a></code> attribute of the
   <code id="link-type-prefetch:the-link-element-5"><a href="#the-link-element">link</a></code> element of an <a href="#external-resource-link" id="link-type-prefetch:external-resource-link-5">external resource
   link</a> that is already <a href="#browsing-context-connected" id="link-type-prefetch:browsing-context-connected-3">browsing-context connected</a> is set, changed, or
   removed.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>The <a href="#fetch-and-process-the-linked-resource" id="link-type-prefetch:fetch-and-process-the-linked-resource-2">fetch and process the linked resource</a> algorithm for <code id="link-type-prefetch:link-type-prefetch-4"><a href="#link-type-prefetch">prefetch</a></code> links, given a <code id="link-type-prefetch:the-link-element-6"><a href="#the-link-element">link</a></code> element
  <var>el</var>, is as follows:</p>

  <ol><li><p>If <var>el</var>'s <code id="link-type-prefetch:attr-link-href-2"><a href="#attr-link-href">href</a></code> attribute's value is the
   empty string, then return.</p></li><li><p>Let <var>options</var> be the result of <a href="#create-link-options-from-element" id="link-type-prefetch:create-link-options-from-element">creating link options</a> from <var>el</var>.</p></li><li><p>Let <var>request</var> be the result of <a href="#create-a-link-request" id="link-type-prefetch:create-a-link-request">creating a
   link request</a> given <var>options</var>.</p></li><li><p>If <var>request</var> is null, then return.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-initiator" id="link-type-prefetch:concept-request-initiator" data-x-internal="concept-request-initiator">initiator</a> to
   "<code>prefetch</code>".</p></li><li>
    <p>Let <var>processPrefetchResponse</var> be the following steps given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="link-type-prefetch:concept-response" data-x-internal="concept-response">response</a> <var>response</var> and null, failure, or a
    <a id="link-type-prefetch:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bytesOrNull</var>:</p>

    <ol><li><p>If <var>response</var> is a <a id="link-type-prefetch:network-error" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="link-type-prefetch:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="link-type-prefetch:event-error"><a href="#event-error">error</a></code> at <var>el</var>.</p></li><li><p>Otherwise, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="link-type-prefetch:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="link-type-prefetch:event-load"><a href="#event-load">load</a></code> at <var>el</var>.</p></li></ol>
   </li><li><p>The user agent should <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="link-type-prefetch:concept-fetch-2" data-x-internal="concept-fetch">fetch</a> <var>request</var>, with
   <i id="link-type-prefetch:processresponseconsumebody"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> set to
   <var>processPrefetchResponse</var>. User agents may delay the fetching of <var>request</var> to
   prioritize other requests that are necessary for the current document.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#process-a-link-header" id="link-type-prefetch:process-a-link-header">process a link header</a> steps for this type of linked resource are to do
  nothing.</p>
  </div>

  <h5 id="link-type-preload"><span class="secno">4.6.7.20</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>preload</code></dfn>"<a href="#link-type-preload" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload" title="The preload value of the <link> element's rel attribute lets you declare fetch requests in the HTML's <head>, specifying resources that your page will need very soon, which you want to start loading early in the page lifecycle, before browsers' main rendering machinery kicks in. This ensures they are available earlier and are less likely to block the page's render, improving performance. Even though the name contains the term load, it doesn't load and execute the script but only schedules it to be downloaded and cached with a higher priority.">Link_types/preload</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>85+</span></span><span class="safari unknown"><span>Safari</span><span>?</span></span><span class="chrome yes"><span>Chrome</span><span title="Partial implementation.">🔰 50+</span></span><hr><span class="opera yes"><span>Opera</span><span>37+</span></span><span class="edge_blink yes"><span>Edge</span><span title="Partial implementation.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie unknown"><span>Internet Explorer</span><span>?</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>50+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>5.0+</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="link-type-preload:link-type-preload"><a href="#link-type-preload">preload</a></code> keyword may be used with <code id="link-type-preload:the-link-element"><a href="#the-link-element">link</a></code>
  elements. This keyword creates an <a href="#external-resource-link" id="link-type-preload:external-resource-link">external resource
  link</a>. This keyword is <a href="#body-ok" id="link-type-preload:body-ok">body-ok</a>.</p>

  <p>The <code id="link-type-preload:link-type-preload-2"><a href="#link-type-preload">preload</a></code> keyword indicates that the user agent will
  preemptively <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="link-type-preload:concept-fetch" data-x-internal="concept-fetch">fetch</a> and cache the specified resource according
  to the <a href="https://fetch.spec.whatwg.org/#concept-potential-destination" id="link-type-preload:concept-potential-destination" data-x-internal="concept-potential-destination">potential destination</a> given by the
  <code id="link-type-preload:attr-link-as"><a href="#attr-link-as">as</a></code> attribute, and the <a href="https://fetch.spec.whatwg.org/#request-priority" id="link-type-preload:concept-request-priority" data-x-internal="concept-request-priority">priority</a> given by the <code id="link-type-preload:attr-link-fetchpriority"><a href="#attr-link-fetchpriority">fetchpriority</a></code> attribute, as it is highly likely that the
  user will require this resource for the current navigation.

  </p><p class="note">User-agents might perform additional operations when a resource is loaded, such as
  preemptively <a href="#dom-img-decode" id="link-type-preload:dom-img-decode">decoding images</a> or <a href="https://drafts.csswg.org/cssom/#create-a-css-style-sheet" id="link-type-preload:create-a-css-style-sheet" data-x-internal="create-a-css-style-sheet">creating style sheets</a>. However, these additional
  operations cannot have observable effects.</p>

  <p>There is no default type for resources given by the <code id="link-type-preload:link-type-preload-3"><a href="#link-type-preload">preload</a></code>
  keyword.</p>

  <p>A user agent must not <a href="#delay-the-load-event" id="link-type-preload:delay-the-load-event">delay the load event</a> for this link type.</p>

  <div data-algorithm="">
  <p>The appropriate times to <a href="#fetch-and-process-the-linked-resource" id="link-type-preload:fetch-and-process-the-linked-resource">fetch and process the linked resource</a> for such a link
   are:</p>

  <ul><li><p>When the <a href="#external-resource-link" id="link-type-preload:external-resource-link-2">external resource link</a> is created on a <code id="link-type-preload:the-link-element-2"><a href="#the-link-element">link</a></code> element
   that is already <a href="#browsing-context-connected" id="link-type-preload:browsing-context-connected">browsing-context connected</a>.</p></li><li><p>When the <a href="#external-resource-link" id="link-type-preload:external-resource-link-3">external resource link</a>'s <code id="link-type-preload:the-link-element-3"><a href="#the-link-element">link</a></code> element <a href="#becomes-browsing-context-connected" id="link-type-preload:becomes-browsing-context-connected">becomes
   browsing-context connected</a>.</p></li><li><p>When the <code id="link-type-preload:attr-link-href"><a href="#attr-link-href">href</a></code> attribute of the <code id="link-type-preload:the-link-element-4"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-preload:external-resource-link-4">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-preload:browsing-context-connected-2">browsing-context
   connected</a> is changed.</p></li><li><p>When the <code id="link-type-preload:attr-link-as-2"><a href="#attr-link-as">as</a></code> attribute of the <code id="link-type-preload:the-link-element-5"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-preload:external-resource-link-5">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-preload:browsing-context-connected-3">browsing-context
   connected</a> is changed.</p></li><li><p>When the <code id="link-type-preload:attr-link-type"><a href="#attr-link-type">type</a></code> attribute of the <code id="link-type-preload:the-link-element-6"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-preload:external-resource-link-6">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-preload:browsing-context-connected-4">browsing-context
   connected</a>, but was previously not obtained due to the <code id="link-type-preload:attr-link-type-2"><a href="#attr-link-type">type</a></code> attribute specifying an unsupported type for the request
   <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="link-type-preload:concept-request-destination" data-x-internal="concept-request-destination">destination</a>, is set, removed, or
   changed.</p></li><li><p>When the <code id="link-type-preload:attr-link-media"><a href="#attr-link-media">media</a></code> attribute of the <code id="link-type-preload:the-link-element-7"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-preload:external-resource-link-7">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-preload:browsing-context-connected-5">browsing-context
   connected</a>, but was previously not obtained due to the <code id="link-type-preload:attr-link-media-2"><a href="#attr-link-media">media</a></code> attribute not
   <a href="#matches-the-environment" id="link-type-preload:matches-the-environment">matching the environment</a>, is changed or
   removed.</p></li></ul>
  </div>

  <p>A <code id="link-type-preload:document"><a href="#document">Document</a></code> has a <dfn id="map-of-preloaded-resources">map of preloaded resources</dfn>, which is an
  <a id="link-type-preload:ordered-map" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>, initially empty.</p>

  <p>A <dfn id="preload-key">preload key</dfn> is a <a id="link-type-preload:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a>. It has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="link-type-preload:struct-item" data-x-internal="struct-item">items</a>:</p>

  <dl><dt><dfn id="preload-url">URL</dfn>
   </dt><dd>A <a id="link-type-preload:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>

   </dd><dt><dfn id="preload-destination">destination</dfn>
   </dt><dd>A string

   </dd><dt><dfn id="preload-mode">mode</dfn>
   </dt><dd>A <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="link-type-preload:concept-request-mode" data-x-internal="concept-request-mode">request mode</a>, either
   "<code>same-origin</code>", "<code>cors</code>", or
   "<code>no-cors</code>"

   </dd><dt><dfn id="preload-credentials-mode">credentials mode</dfn>
   </dt><dd>A <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="link-type-preload:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a>
  </dd></dl>

  <p>A <dfn id="preload-entry">preload entry</dfn> is a <a id="link-type-preload:struct-2" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a>. It has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="link-type-preload:struct-item-2" data-x-internal="struct-item">items</a>:</p>

  <dl><dt><dfn id="preload-integrity-metadata">integrity metadata</dfn>
   </dt><dd>A string

   </dd><dt><dfn id="preload-response">response</dfn>
   </dt><dd>Null or a <a href="https://fetch.spec.whatwg.org/#concept-response" id="link-type-preload:concept-response" data-x-internal="concept-response">response</a>

   </dd><dt><dfn id="preload-on-response-available">on response available</dfn>
   </dt><dd>Null, or an algorithm accepting a <a href="https://fetch.spec.whatwg.org/#concept-response" id="link-type-preload:concept-response-2" data-x-internal="concept-response">response</a> or null
  </dd></dl>

  <div data-algorithm="">
  <p>To <dfn id="consume-a-preloaded-resource" data-export="">consume a preloaded resource</dfn> for <code id="link-type-preload:window"><a href="#window">Window</a></code> <var>window</var>,
  given a <a id="link-type-preload:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, a string <var>destination</var>, a string
  <var>mode</var>, a string <var>credentialsMode</var>, a string <var>integrityMetadata</var>, and
  <var>onResponseAvailable</var>, which is an algorithm accepting a <a href="https://fetch.spec.whatwg.org/#concept-response" id="link-type-preload:concept-response-3" data-x-internal="concept-response">response</a>:</p>

  <ol><li><p>Let <var>key</var> be a <a href="#preload-key" id="link-type-preload:preload-key">preload key</a> whose <a href="#preload-url" id="link-type-preload:preload-url">URL</a> is <var>url</var>, <a href="#preload-destination" id="link-type-preload:preload-destination">destination</a> is
   <var>destination</var>, <a href="#preload-mode" id="link-type-preload:preload-mode">mode</a> is <var>mode</var>, and
   <a href="#preload-credentials-mode" id="link-type-preload:preload-credentials-mode">credentials mode</a> is
   <var>credentialsMode</var>.</p></li><li><p>Let <var>preloads</var> be <var>window</var>'s <a href="#concept-document-window" id="link-type-preload:concept-document-window">associated <code>Document</code></a>'s <a href="#map-of-preloaded-resources" id="link-type-preload:map-of-preloaded-resources">map of
   preloaded resources</a>.</p></li><li><p>If <var>key</var> does not <a href="https://infra.spec.whatwg.org/#map-exists" id="link-type-preload:map-exists" data-x-internal="map-exists">exist</a> in <var>preloads</var>,
   then return false.</p></li><li><p>Let <var>entry</var> be <var>preloads</var>[<var>key</var>].</p></li><li><p>Let <var>consumerIntegrityMetadata</var> be the result of
   <a href="https://w3c.github.io/webappsec-subresource-integrity/#parse-metadata" id="link-type-preload:parse-integrity-metadata" data-x-internal="parse-integrity-metadata">parsing</a> <var>integrityMetadata</var>.</p></li><li><p>Let <var>preloadIntegrityMetadata</var> be the result of
   <a href="https://w3c.github.io/webappsec-subresource-integrity/#parse-metadata" id="link-type-preload:parse-integrity-metadata-2" data-x-internal="parse-integrity-metadata">parsing</a> <var>entry</var>'s
   <a href="#preload-integrity-metadata" id="link-type-preload:preload-integrity-metadata">integrity metadata</a>.</p></li><li>
    <p>If none of the following conditions apply:</p>

    <ul><li><p><var>consumerIntegrityMetadata</var> is <code>no metadata</code>;</p></li><li>
      <p><var>consumerIntegrityMetadata</var> is equal to <var>preloadIntegrityMetadata</var>;
      or</p>

      <p class="XXX">This comparison would ignore unknown integrity options. See <a href="https://github.com/w3c/webappsec-subresource-integrity/issues/116">issue #116.</a></p>
     </li></ul>

    <p>then return false.</p>

    <p class="note">A mismatch in integrity metadata between the preload and the consumer, even if
    both match the data, would lead to an additional fetch from the network.</p>

    <p class="note">It is important that <a href="https://fetch.spec.whatwg.org/#concept-network-error" id="link-type-preload:network-error" data-x-internal="network-error">network errors</a> are
    added to the preload cache so that if a preload request results in an error, the erroneous
    response isn't re-requested from the network later. This also has security implications;
    consider the case where a developer specifies subresource integrity metadata on a preload
    request, but not the following resource request. If the preload request fails subresource
    integrity verification and is discarded, the resource request will fetch and consume a
    potentially-malicious response from the network without verifying its integrity.
    <a href="#refsSRI">[SRI]</a></p>
   </li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="link-type-preload:map-remove" data-x-internal="map-remove">Remove</a> <var>preloads</var>[<var>key</var>].</p></li><li><p>If <var>entry</var>'s <a href="#preload-response" id="link-type-preload:preload-response">response</a> is null, then set
   <var>entry</var>'s <a href="#preload-on-response-available" id="link-type-preload:preload-on-response-available">on response available</a> to
   <var>onResponseAvailable</var>.</p></li><li><p>Otherwise, call <var>onResponseAvailable</var> with <var>entry</var>'s <a href="#preload-response" id="link-type-preload:preload-response-2">response</a>.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>For the purposes of this section, a string <var>type</var>
  <dfn id="match-preload-type">matches</dfn> a string <var>destination</var> if the following
  algorithm returns true:</p>
  <ol><li><p>If <var>type</var> is an empty string, then return true.</p></li><li><p>If <var>destination</var> is "<code>fetch</code>", then return true.</p></li><li><p>Let <var>mimeTypeRecord</var> be the result of
   <a href="https://mimesniff.spec.whatwg.org/#parse-a-mime-type" id="link-type-preload:parse-a-mime-type" data-x-internal="parse-a-mime-type">parsing</a> <var>type</var>.</p></li><li><p>If <var>mimeTypeRecord</var> is failure, then return false.</p></li><li><p>If <var>mimeTypeRecord</var> is not <a href="https://mimesniff.spec.whatwg.org/#supported-by-the-user-agent" id="link-type-preload:is-mime-type-supported-by-the-user-agent" data-x-internal="is-mime-type-supported-by-the-user-agent">supported by the user agent</a>, then
   return false.</p>

   </li><li>
    <p>If any of the following are true:</p>

    <ul><li><p><var>destination</var> is "<code>audio</code>" or "<code>video</code>", and <var>mimeTypeRecord</var> is an
     <a id="link-type-preload:audio-or-video-mime-type" href="https://mimesniff.spec.whatwg.org/#audio-or-video-mime-type" data-x-internal="audio-or-video-mime-type">audio or video MIME type</a>;</p></li><li><p><var>destination</var> is a
     <a href="https://fetch.spec.whatwg.org/#request-destination-script-like" id="link-type-preload:concept-script-like-destination" data-x-internal="concept-script-like-destination">script-like destination</a> and
     <var>mimeTypeRecord</var> is a <a id="link-type-preload:javascript-mime-type" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type" data-x-internal="javascript-mime-type">JavaScript MIME type</a>;</p></li><li><p><var>destination</var> is "<code>image</code>" and
     <var>mimeTypeRecord</var> is an <a id="link-type-preload:image-mime-type" href="https://mimesniff.spec.whatwg.org/#image-mime-type" data-x-internal="image-mime-type">image MIME type</a>;</p></li><li><p><var>destination</var> is "<code>font</code>" and
     <var>mimeTypeRecord</var> is a <a id="link-type-preload:font-mime-type" href="https://mimesniff.spec.whatwg.org/#font-mime-type" data-x-internal="font-mime-type">font MIME type</a>;</p></li><li><p><var>destination</var> is "<code>json</code>" and
     <var>mimeTypeRecord</var> is a <a id="link-type-preload:json-mime-type" href="https://mimesniff.spec.whatwg.org/#json-mime-type" data-x-internal="json-mime-type">JSON MIME type</a>;</p></li><li><p><var>destination</var> is "<code>style</code>" and
     <var>mimeTypeRecord</var>'s <a href="https://mimesniff.spec.whatwg.org/#mime-type-essence" id="link-type-preload:mime-type-essence" data-x-internal="mime-type-essence">essence</a> is
     <code id="link-type-preload:text/css"><a href="#text/css">text/css</a></code>; or</p></li><li><p><var>destination</var> is "<code>track</code>" and
     <var>mimeTypeRecord</var>'s <a href="https://mimesniff.spec.whatwg.org/#mime-type-essence" id="link-type-preload:mime-type-essence-2" data-x-internal="mime-type-essence">essence</a> is
     <code id="link-type-preload:text/vtt"><a href="#text/vtt">text/vtt</a></code>,</p></li></ul>

    <p>then return true.</p>
   </li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="create-a-preload-key">create a preload key</dfn> for a <a href="https://fetch.spec.whatwg.org/#concept-request" id="link-type-preload:concept-request" data-x-internal="concept-request">request</a>
  <var>request</var>, return a new <a href="#preload-key" id="link-type-preload:preload-key-2">preload key</a> whose <a href="#preload-url" id="link-type-preload:preload-url-2">URL</a> is <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="link-type-preload:concept-request-url" data-x-internal="concept-request-url">URL</a>, <a href="#preload-destination" id="link-type-preload:preload-destination-2">destination</a> is <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="link-type-preload:concept-request-destination-2" data-x-internal="concept-request-destination">destination</a>, <a href="#preload-mode" id="link-type-preload:preload-mode-2">mode</a> is <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="link-type-preload:concept-request-mode-2" data-x-internal="concept-request-mode">mode</a>, and
  <a href="#preload-credentials-mode" id="link-type-preload:preload-credentials-mode-2">credentials mode</a> is <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="link-type-preload:concept-request-credentials-mode-2" data-x-internal="concept-request-credentials-mode">credentials mode</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="translate-a-preload-destination">translate a preload destination</dfn> given a string <var>destination</var>:</p>

  <ol><li><p>If <var>destination</var> is not "<code>fetch</code>", "<code>font</code>",
   "<code>image</code>", "<code>script</code>", "<code>style</code>",
   or "<code>track</code>", then return null.</p></li><li><p>Return the result of <a href="https://fetch.spec.whatwg.org/#concept-potential-destination-translate" id="link-type-preload:concept-potential-destination-translate" data-x-internal="concept-potential-destination-translate">translating</a>
   <var>destination</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="preload">preload</dfn> given a <a href="#link-processing-options" id="link-type-preload:link-processing-options">link processing options</a> <var>options</var> and
  an optional <var>processResponse</var>, which is an algorithm accepting a <a href="https://fetch.spec.whatwg.org/#concept-response" id="link-type-preload:concept-response-4" data-x-internal="concept-response">response</a>:</p>

  <ol><li><p>If <var>options</var>'s <a href="#link-options-type" id="link-type-preload:link-options-type">type</a> doesn't <a href="#match-preload-type" id="link-type-preload:match-preload-type">match</a> <var>options</var>'s <a href="#link-options-destination" id="link-type-preload:link-options-destination">destination</a>, then return.</p></li><li><p>If <var>options</var>'s <a href="#link-options-destination" id="link-type-preload:link-options-destination-2">destination</a> is
   "<code>image</code>" and <var>options</var>'s <a href="#link-options-source-set" id="link-type-preload:link-options-source-set">source set</a> is not null, then set <var>options</var>'s <a href="#link-options-href" id="link-type-preload:link-options-href">href</a> to the result of <a href="#select-an-image-source-from-a-source-set" id="link-type-preload:select-an-image-source-from-a-source-set">selecting an image source</a> from <var>options</var>'s <a href="#link-options-source-set" id="link-type-preload:link-options-source-set-2">source set</a>.</p></li><li><p>Let <var>request</var> be the result of <a href="#create-a-link-request" id="link-type-preload:create-a-link-request">creating a
   link request</a> given <var>options</var>.</p></li><li><p>If <var>request</var> is null, then return.</p></li><li><p>Let <var>unsafeEndTime</var> be 0.</p></li><li><p>Let <var>entry</var> be a new <a href="#preload-entry" id="link-type-preload:preload-entry">preload entry</a> whose
   <a href="#preload-integrity-metadata" id="link-type-preload:preload-integrity-metadata-2">integrity metadata</a> is <var>options</var>'s
   <a href="#link-options-integrity" id="link-type-preload:link-options-integrity">integrity</a>.</p></li><li><p>Let <var>key</var> be the result of <a href="#create-a-preload-key" id="link-type-preload:create-a-preload-key">creating a
   preload key</a> given <var>request</var>.</p></li><li><p>If <var>options</var>'s <a href="#link-options-document" id="link-type-preload:link-options-document">document</a> is null, then
   set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="link-type-preload:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator type</a> to
   "<code>early hint</code>".</p></li><li><p>Let <var>controller</var> be null.</p></li><li><p>Let <var>reportTiming</var> given a <code id="link-type-preload:document-2"><a href="#document">Document</a></code> <var>document</var> be to
   <a id="link-type-preload:report-timing" href="https://fetch.spec.whatwg.org/#finalize-and-report-timing" data-x-internal="report-timing">report timing</a> for <var>controller</var> given <var>document</var>'s <a href="#concept-relevant-global" id="link-type-preload:concept-relevant-global">relevant
   global object</a>.</p></li><li>
    <p>Set <var>controller</var> to the result of <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="link-type-preload:concept-fetch-2" data-x-internal="concept-fetch">fetching</a> <var>request</var>, with <i id="link-type-preload:processresponseconsumebody"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> set to the following steps
    given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="link-type-preload:concept-response-5" data-x-internal="concept-response">response</a> <var>response</var> and null, failure,
    or a <a id="link-type-preload:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bodyBytes</var>:</p>

    <ol><li>
      <p>If <var>bodyBytes</var> is a <a id="link-type-preload:byte-sequence-2" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a>, then set <var>response</var>'s
      <a href="https://fetch.spec.whatwg.org/#concept-response-body" id="link-type-preload:concept-response-body" data-x-internal="concept-response-body">body</a> to <var>bodyBytes</var> <a id="link-type-preload:as-a-body" href="https://fetch.spec.whatwg.org/#byte-sequence-as-a-body" data-x-internal="as-a-body">as a
      body</a>.</p>

      <p class="note">By using <i id="link-type-preload:processresponseconsumebody-2"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i>,
      we have <a href="https://fetch.spec.whatwg.org/#bodyinit-safely-extract" id="link-type-preload:body-safely-extract" data-x-internal="body-safely-extract">extracted</a> the entire <a href="https://fetch.spec.whatwg.org/#concept-response-body" id="link-type-preload:concept-response-body-2" data-x-internal="concept-response-body">body</a>. This is necessary to ensure the preloader loads the
      entire body from the network, regardless of whether the preload will be consumed (which is
      uncertain at this point). This step then resets the request's body to a new body containing the
      same bytes, so that other specifications can read from it at the time of actual consumption,
      despite us having already done so once.</p>
     </li><li><p>Otherwise, set <var>response</var> to a <a id="link-type-preload:network-error-2" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>.</p></li><li><p>Set <var>unsafeEndTime</var> to the <a id="link-type-preload:unsafe-shared-current-time" href="https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time" data-x-internal="unsafe-shared-current-time">unsafe shared current time</a>.</p></li><li><p>If <var>options</var>'s <a href="#link-options-document" id="link-type-preload:link-options-document-2">document</a> is not
     null, then call <var>reportTiming</var> given <var>options</var>'s <a href="#link-options-document" id="link-type-preload:link-options-document-3">document</a>.</p></li><li><p>If <var>entry</var>'s <a href="#preload-on-response-available" id="link-type-preload:preload-on-response-available-2">on response
     available</a> is null, then set <var>entry</var>'s <a href="#preload-response" id="link-type-preload:preload-response-3">response</a> to <var>response</var>; otherwise call <var>entry</var>'s <a href="#preload-on-response-available" id="link-type-preload:preload-on-response-available-3">on response available</a> given
     <var>response</var>.</p></li><li><p>If <var>processResponse</var> is given, then call <var>processResponse</var> with
     <var>response</var>.</p></li></ol>
   </li><li>
    <p>Let <var>commit</var> be the following steps given a <code id="link-type-preload:document-3"><a href="#document">Document</a></code>
    <var>document</var>:</p>

    <ol><li><p>If <var>entry</var>'s <a href="#preload-response" id="link-type-preload:preload-response-4">response</a> is not null, then
     call <var>reportTiming</var> given <var>document</var>.</p></li><li><p>Set <var>document</var>'s <a href="#map-of-preloaded-resources" id="link-type-preload:map-of-preloaded-resources-2">map of preloaded resources</a>[<var>key</var>] to
     <var>entry</var>.</p></li></ol>
   </li><li><p>If <var>options</var>'s <a href="#link-options-document" id="link-type-preload:link-options-document-4">document</a> is null, then set <var>options</var>'s <a href="#link-options-on-document-ready" id="link-type-preload:link-options-on-document-ready">on document ready</a> to <var>commit</var>.
   Otherwise, call <var>commit</var> with <var>options</var>'s <a href="#link-options-document" id="link-type-preload:link-options-document-5">document</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#fetch-and-process-the-linked-resource" id="link-type-preload:fetch-and-process-the-linked-resource-2">fetch and process the linked resource</a> steps for this type of linked resource,
  given a <code id="link-type-preload:the-link-element-8"><a href="#the-link-element">link</a></code> element <var>el</var>, are:</p>

  <ol><li><p><a href="#update-the-source-set" id="link-type-preload:update-the-source-set">Update the source set</a> for <var>el</var>.</p></li><li><p>Let <var>options</var> be the result of <a href="#create-link-options-from-element" id="link-type-preload:create-link-options-from-element">creating link options</a> from
   <var>el</var>.</p></li><li><p>Let <var>destination</var> be the result of <a href="#translate-a-preload-destination" id="link-type-preload:translate-a-preload-destination">translating</a> the keyword representing the state of <var>el</var>'s <code id="link-type-preload:attr-link-as-3"><a href="#attr-link-as">as</a></code> attribute.</p></li><li><p>If <var>destination</var> is null, then return.</p></li><li><p>Set <var>options</var>'s <a href="#link-options-destination" id="link-type-preload:link-options-destination-3">destination</a> to
   <var>destination</var>.</p></li><li>
    <p><a href="#preload" id="link-type-preload:preload">Preload</a> <var>options</var>, with the following steps given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="link-type-preload:concept-response-6" data-x-internal="concept-response">response</a> <var>response</var>:

    </p><ol><li>
      <p>If <var>response</var> is a <a id="link-type-preload:network-error-3" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="link-type-preload:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="link-type-preload:event-error"><a href="#event-error">error</a></code> at <var>el</var>. Otherwise, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="link-type-preload:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named
      <code id="link-type-preload:event-load"><a href="#event-load">load</a></code> at <var>el</var>.</p>

      <p class="XXX">The actual browsers' behavior is different from the spec here, and the
      feasibility of changing the behavior has not yet been investigated. See <a href="https://github.com/whatwg/html/issues/1142">issue #1142</a>.</p>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#process-a-link-header" id="link-type-preload:process-a-link-header">process a link header</a> step for this type of link
  given a <a href="#link-processing-options" id="link-type-preload:link-processing-options-2">link processing options</a> <var>options</var>
  is to <a href="#preload" id="link-type-preload:preload-2">preload</a> <var>options</var>.</p>
  </div>


  <h5 id="link-type-privacy-policy"><span class="secno">4.6.7.21</span> Link type "<dfn data-dfn-for="link/rel,a/rel,area/rel" data-dfn-type="attr-value"><code>privacy-policy</code></dfn>"<a href="#link-type-privacy-policy" class="self-link"></a></h5>

  <p>The <code id="link-type-privacy-policy:link-type-privacy-policy"><a href="#link-type-privacy-policy">privacy-policy</a></code> keyword may be used with
  <code id="link-type-privacy-policy:the-link-element"><a href="#the-link-element">link</a></code>, <code id="link-type-privacy-policy:the-a-element"><a href="#the-a-element">a</a></code>, and <code id="link-type-privacy-policy:the-area-element"><a href="#the-area-element">area</a></code> elements. This keyword creates a
  <a href="#hyperlink" id="link-type-privacy-policy:hyperlink">hyperlink</a>.</p>

  <p>The <code id="link-type-privacy-policy:link-type-privacy-policy-2"><a href="#link-type-privacy-policy">privacy-policy</a></code> keyword indicates that the
  referenced document contains information about the data collection and usage practices that apply
  to the current document, as described in more detail in <cite>Additional Link Relation
  Types</cite>. The referenced document may be a standalone privacy policy, or a specific section of
  some more general document. <a href="#refsRFC6903">[RFC6903]</a></p>


  <h5 id="link-type-search"><span class="secno">4.6.7.22</span> Link type "<dfn data-dfn-for="link/rel,a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>search</code></dfn>"<a href="#link-type-search" class="self-link"></a></h5>

  <p>The <code id="link-type-search:link-type-search"><a href="#link-type-search">search</a></code> keyword may be used with <code id="link-type-search:the-link-element"><a href="#the-link-element">link</a></code>,
  <code id="link-type-search:the-a-element"><a href="#the-a-element">a</a></code>, <code id="link-type-search:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-search:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword creates a
  <a href="#hyperlink" id="link-type-search:hyperlink">hyperlink</a>.</p>

  <p>The <code id="link-type-search:link-type-search-2"><a href="#link-type-search">search</a></code> keyword indicates that the referenced document
  provides an interface specifically for searching the document and its related resources.</p>

  <p class="note">OpenSearch description documents can be used with <code id="link-type-search:the-link-element-2"><a href="#the-link-element">link</a></code> elements and
  the <code id="link-type-search:link-type-search-3"><a href="#link-type-search">search</a></code> link type to enable user agents to autodiscover search
  interfaces. <a href="#refsOPENSEARCH">[OPENSEARCH]</a></p>


  <h5 id="link-type-stylesheet"><span class="secno">4.6.7.23</span> Link type "<dfn data-dfn-for="link/rel" data-dfn-type="attr-value"><code>stylesheet</code></dfn>"<a href="#link-type-stylesheet" class="self-link"></a></h5>

  <p>The <code id="link-type-stylesheet:link-type-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code> keyword may be used with <code id="link-type-stylesheet:the-link-element"><a href="#the-link-element">link</a></code>
  elements. This keyword creates an <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link">external resource
  link</a> that contributes to the styling processing model. This keyword is
  <a href="#body-ok" id="link-type-stylesheet:body-ok">body-ok</a>.</p>

  <p>The specified resource is a <a id="link-type-stylesheet:css-style-sheet" href="https://drafts.csswg.org/cssom/#css-style-sheet" data-x-internal="css-style-sheet">CSS style sheet</a> that describes how to present the
  document.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Alternative_style_sheets" title="Specifying alternative style sheets in a web page provides a way for users to see multiple versions of a page, based on their needs or preferences.">Alternative_style_sheets</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari unknown"><span>Safari</span><span>?</span></span><span class="chrome no"><span>Chrome</span><span>1–48</span></span><hr><span class="opera yes"><span>Opera</span><span>Yes</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>If the <code id="link-type-stylesheet:rel-alternate"><a href="#rel-alternate">alternate</a></code> keyword is also specified on the
  <code id="link-type-stylesheet:the-link-element-2"><a href="#the-link-element">link</a></code> element, then <dfn id="the-link-is-an-alternative-stylesheet">the link is an
  alternative style sheet</dfn>; in this case, the <code id="link-type-stylesheet:attr-title"><a href="#attr-title">title</a></code> attribute
  must be specified on the <code id="link-type-stylesheet:the-link-element-3"><a href="#the-link-element">link</a></code> element, with a non-empty value.</p>

  <p>The default type for resources given by the <code id="link-type-stylesheet:link-type-stylesheet-2"><a href="#link-type-stylesheet">stylesheet</a></code>
  keyword is <code id="link-type-stylesheet:text/css"><a href="#text/css">text/css</a></code>.</p>

  <div data-algorithm="">
  <p>A <code id="link-type-stylesheet:the-link-element-4"><a href="#the-link-element">link</a></code> element of this type is <a href="#implicitly-potentially-render-blocking" id="link-type-stylesheet:implicitly-potentially-render-blocking">implicitly potentially render-blocking</a>
  if the element was created by its <a id="link-type-stylesheet:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s parser.</p>
  </div>

  

  <div data-algorithm="">
  <p>When the <code id="link-type-stylesheet:attr-link-disabled"><a href="#attr-link-disabled">disabled</a></code> attribute of a <code id="link-type-stylesheet:the-link-element-5"><a href="#the-link-element">link</a></code>
  element with a <code id="link-type-stylesheet:link-type-stylesheet-3"><a href="#link-type-stylesheet">stylesheet</a></code> keyword is set, <a href="https://drafts.csswg.org/cssom/#disable-a-css-style-sheet" id="link-type-stylesheet:disable-a-css-style-sheet" data-x-internal="disable-a-css-style-sheet">disable</a> the <a id="link-type-stylesheet:associated-css-style-sheet" href="https://drafts.csswg.org/cssom/#associated-css-style-sheet" data-x-internal="associated-css-style-sheet">associated CSS style sheet</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The appropriate times to <a href="#fetch-and-process-the-linked-resource" id="link-type-stylesheet:fetch-and-process-the-linked-resource">fetch and
  process</a> this type of link are:

  
  </p><ul><li><p>When the <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link-2">external resource link</a> is created on a <code id="link-type-stylesheet:the-link-element-6"><a href="#the-link-element">link</a></code> element
   that is already <a href="#browsing-context-connected" id="link-type-stylesheet:browsing-context-connected">browsing-context connected</a>.</p></li><li><p>When the <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link-3">external resource link</a>'s <code id="link-type-stylesheet:the-link-element-7"><a href="#the-link-element">link</a></code> element <a href="#becomes-browsing-context-connected" id="link-type-stylesheet:becomes-browsing-context-connected">becomes
   browsing-context connected</a>.</p></li><li><p>When the <code id="link-type-stylesheet:attr-link-href"><a href="#attr-link-href">href</a></code> attribute of the <code id="link-type-stylesheet:the-link-element-8"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link-4">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-stylesheet:browsing-context-connected-2">browsing-context
   connected</a> is changed.</p></li><li><p>When the <code id="link-type-stylesheet:attr-link-disabled-2"><a href="#attr-link-disabled">disabled</a></code> attribute of the
   <code id="link-type-stylesheet:the-link-element-9"><a href="#the-link-element">link</a></code> element of an <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link-5">external resource link</a> that is already
   <a href="#browsing-context-connected" id="link-type-stylesheet:browsing-context-connected-3">browsing-context connected</a> is set, changed, or removed.</p></li><li><p>When the <code id="link-type-stylesheet:attr-link-crossorigin"><a href="#attr-link-crossorigin">crossorigin</a></code> attribute of the
   <code id="link-type-stylesheet:the-link-element-10"><a href="#the-link-element">link</a></code> element of an <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link-6">external resource
   link</a> that is already <a href="#browsing-context-connected" id="link-type-stylesheet:browsing-context-connected-4">browsing-context connected</a> is set, changed, or
   removed.</p></li><li><p>When the <code id="link-type-stylesheet:attr-link-type"><a href="#attr-link-type">type</a></code> attribute of the <code id="link-type-stylesheet:the-link-element-11"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link-7">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-stylesheet:browsing-context-connected-5">browsing-context
   connected</a> is set or changed to a value that does not or no longer matches the <a href="#content-type" id="link-type-stylesheet:content-type">Content-Type metadata</a> of the previous obtained external resource, if
   any.</p></li><li><p>When the <code id="link-type-stylesheet:attr-link-type-2"><a href="#attr-link-type">type</a></code> attribute of the <code id="link-type-stylesheet:the-link-element-12"><a href="#the-link-element">link</a></code>
   element of an <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link-8">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-stylesheet:browsing-context-connected-6">browsing-context
   connected</a>, but was previously not obtained due to the <code id="link-type-stylesheet:attr-link-type-3"><a href="#attr-link-type">type</a></code> attribute specifying an unsupported type, is removed or
   changed.</p></li><li><p>When the <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link-9">external resource link</a> that is already <a href="#browsing-context-connected" id="link-type-stylesheet:browsing-context-connected-7">browsing-context
   connected</a> changes from being <a href="#the-link-is-an-alternative-stylesheet" id="link-type-stylesheet:the-link-is-an-alternative-stylesheet">an
   alternative style sheet</a> to not being one, or vice versa.</p></li></ul>
  </div>

  <p><strong>Quirk</strong>: If the document has been set to <a id="link-type-stylesheet:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, has the
  <a href="#same-origin" id="link-type-stylesheet:same-origin">same origin</a> as the <a id="link-type-stylesheet:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the external resource,
  and the <a href="#content-type" id="link-type-stylesheet:content-type-2">Content-Type metadata</a> of the external resource is not a
  supported style sheet type, the user agent must instead assume it to be <code id="link-type-stylesheet:text/css-2"><a href="#text/css">text/css</a></code>.</p>

  <div data-algorithm="">
  <p>The <a href="#linked-resource-fetch-setup-steps" id="link-type-stylesheet:linked-resource-fetch-setup-steps">linked resource fetch setup steps</a> for this type of linked resource, given a
  <code id="link-type-stylesheet:the-link-element-13"><a href="#the-link-element">link</a></code> element <var>el</var> and <a href="https://fetch.spec.whatwg.org/#concept-request" id="link-type-stylesheet:concept-request" data-x-internal="concept-request">request</a>
  <var>request</var>, are:</p>

  <ol><li><p>If <var>el</var>'s <code id="link-type-stylesheet:attr-link-disabled-3"><a href="#attr-link-disabled">disabled</a></code> attribute is set,
   then return false.</p></li><li><p>If <var>el</var> <a href="#contributes-a-script-blocking-style-sheet" id="link-type-stylesheet:contributes-a-script-blocking-style-sheet">contributes a script-blocking style sheet</a>, <a href="https://infra.spec.whatwg.org/#set-append" id="link-type-stylesheet:set-append" data-x-internal="set-append">append</a> <var>el</var> to its <a id="link-type-stylesheet:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#script-blocking-style-sheet-set" id="link-type-stylesheet:script-blocking-style-sheet-set">script-blocking
   style sheet set</a>.</p></li><li><p>If <var>el</var>'s <code id="link-type-stylesheet:attr-link-media"><a href="#attr-link-media">media</a></code> attribute's value
   <a href="#matches-the-environment" id="link-type-stylesheet:matches-the-environment">matches the environment</a> and <var>el</var> is
   <a href="#potentially-render-blocking" id="link-type-stylesheet:potentially-render-blocking">potentially render-blocking</a>, then <a href="#block-rendering" id="link-type-stylesheet:block-rendering">block rendering</a> on
   <var>el</var>.</p></li><li><p>If <var>el</var> is currently <a href="#render-blocking" id="link-type-stylesheet:render-blocking">render-blocking</a>, then set <var>request</var>'s
   <a href="https://fetch.spec.whatwg.org/#request-render-blocking" id="link-type-stylesheet:concept-request-render-blocking" data-x-internal="concept-request-render-blocking">render-blocking</a> to true.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <p class="XXX">See <a href="https://github.com/whatwg/html/issues/968">issue #968</a> for plans
  to use the CSSOM <a href="https://drafts.csswg.org/cssom/#fetching-css-style-sheets">fetch a CSS
  style sheet</a> algorithm instead of the <a href="#default-fetch-and-process-the-linked-resource" id="link-type-stylesheet:default-fetch-and-process-the-linked-resource">default fetch and process the linked
  resource</a> algorithm. In the meantime, any <a href="#critical-subresources" id="link-type-stylesheet:critical-subresources">critical
  subresource</a> <a href="https://fetch.spec.whatwg.org/#concept-request" id="link-type-stylesheet:concept-request-2" data-x-internal="concept-request">request</a> should have its <a href="https://fetch.spec.whatwg.org/#request-render-blocking" id="link-type-stylesheet:concept-request-render-blocking-2" data-x-internal="concept-request-render-blocking">render-blocking</a> set to whether or not the
  <code id="link-type-stylesheet:the-link-element-14"><a href="#the-link-element">link</a></code> element is currently <a href="#render-blocking" id="link-type-stylesheet:render-blocking-2">render-blocking</a>.</p>

  <div data-algorithm="">
  <p>To <a href="#process-the-linked-resource" id="link-type-stylesheet:process-the-linked-resource">process this type of linked resource</a>
  given a <code id="link-type-stylesheet:the-link-element-15"><a href="#the-link-element">link</a></code> element <var>el</var>, boolean <var>success</var>, <a href="https://fetch.spec.whatwg.org/#concept-response" id="link-type-stylesheet:concept-response" data-x-internal="concept-response">response</a> <var>response</var>, and <a id="link-type-stylesheet:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a>
  <var>bodyBytes</var>:</p>

  
  

  <ol><li><p>If the resource's <a href="#content-type" id="link-type-stylesheet:content-type-3">Content-Type metadata</a> is not
   <code id="link-type-stylesheet:text/css-3"><a href="#text/css">text/css</a></code>, then set <var>success</var> to false.</p></li><li>
    <p>If <var>el</var> no longer creates an <a href="#external-resource-link" id="link-type-stylesheet:external-resource-link-10">external resource link</a> that contributes to
    the styling processing model, or if, since the resource in question was <a href="#fetch-and-process-the-linked-resource" id="link-type-stylesheet:fetch-and-process-the-linked-resource-2">fetched</a>, it has become appropriate to <a href="#fetch-and-process-the-linked-resource" id="link-type-stylesheet:fetch-and-process-the-linked-resource-3">fetch</a> it again, then:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="link-type-stylesheet:list-remove" data-x-internal="list-remove">Remove</a> <var>el</var> from <var>el</var>'s <a id="link-type-stylesheet:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
     document</a>'s <a href="#script-blocking-style-sheet-set" id="link-type-stylesheet:script-blocking-style-sheet-set-2">script-blocking style sheet set</a>.</p></li><li><p>Return.</p></li></ol>
   </li><li><p>If <var>el</var> has an <a id="link-type-stylesheet:associated-css-style-sheet-2" href="https://drafts.csswg.org/cssom/#associated-css-style-sheet" data-x-internal="associated-css-style-sheet">associated CSS style sheet</a>, <a href="https://drafts.csswg.org/cssom/#remove-a-css-style-sheet" id="link-type-stylesheet:remove-a-css-style-sheet" data-x-internal="remove-a-css-style-sheet">remove the CSS style sheet</a>.</p></li><li>
    <p>If <var>success</var> is true, then:</p>

    <ol><li>
      <p><a id="link-type-stylesheet:create-a-css-style-sheet" href="https://drafts.csswg.org/cssom/#create-a-css-style-sheet" data-x-internal="create-a-css-style-sheet">Create a CSS style sheet</a> with the following properties:</p>

      <dl><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-type" id="link-type-stylesheet:concept-css-style-sheet-type" data-x-internal="concept-css-style-sheet-type">type</a></dt><dd><p><code id="link-type-stylesheet:text/css-4"><a href="#text/css">text/css</a></code></p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-location" id="link-type-stylesheet:concept-css-style-sheet-location" data-x-internal="concept-css-style-sheet-location">location</a></dt><dd>
        <p><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url-list" id="link-type-stylesheet:concept-response-url-list" data-x-internal="concept-response-url-list">URL list</a>[0]</p>

        <p class="XXX">We provide a URL here on the assumption that <a href="https://github.com/w3c/csswg-drafts/issues/9316">w3c/csswg-drafts issue #9316</a> will
        be fixed.</p>
       </dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-owner-node" id="link-type-stylesheet:concept-css-style-sheet-owner-node" data-x-internal="concept-css-style-sheet-owner-node">owner node</a></dt><dd><p><var>el</var></p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-media" id="link-type-stylesheet:concept-css-style-sheet-media" data-x-internal="concept-css-style-sheet-media">media</a></dt><dd>
        <p>The <code id="link-type-stylesheet:attr-link-media-2"><a href="#attr-link-media">media</a></code> attribute of <var>el</var>.</p>

        <p class="note">This is a reference to the (possibly absent at this time) attribute, rather
        than a copy of the attribute's current value. <cite>CSSOM</cite> defines what happens
        when the attribute is dynamically set, changed, or removed.</p>
       </dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-title" id="link-type-stylesheet:concept-css-style-sheet-title" data-x-internal="concept-css-style-sheet-title">title</a></dt><dd>
        <p>The <code id="link-type-stylesheet:attr-link-title"><a href="#attr-link-title">title</a></code> attribute of <var>el</var>, if
        <var>el</var> is <a id="link-type-stylesheet:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>, or the empty string otherwise.</p>

        <p class="note">This is similarly a reference to the attribute, rather than a copy of the
        attribute's current value.</p>
       </dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-alternate-flag" id="link-type-stylesheet:concept-css-style-sheet-alternate-flag" data-x-internal="concept-css-style-sheet-alternate-flag">alternate flag</a></dt><dd><p>Set if <a href="#the-link-is-an-alternative-stylesheet" id="link-type-stylesheet:the-link-is-an-alternative-stylesheet-2">the link is an alternative style sheet</a> and <var>el</var>'s
       <a href="#explicitly-enabled" id="link-type-stylesheet:explicitly-enabled">explicitly enabled</a> is false; unset otherwise.</p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-origin-clean-flag" id="link-type-stylesheet:concept-css-style-sheet-origin-clean-flag" data-x-internal="concept-css-style-sheet-origin-clean-flag">origin-clean flag</a></dt><dd><p>Set if the resource is <a href="#cors-same-origin" id="link-type-stylesheet:cors-same-origin">CORS-same-origin</a>; unset otherwise.</p></dd><dt>
        <a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-parent-css-style-sheet" id="link-type-stylesheet:concept-css-style-sheet-parent-css-style-sheet" data-x-internal="concept-css-style-sheet-parent-css-style-sheet">parent CSS style
        sheet</a>
       </dt><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-owner-css-rule" id="link-type-stylesheet:concept-css-style-sheet-owner-css-rule" data-x-internal="concept-css-style-sheet-owner-css-rule">owner CSS rule</a></dt><dd><p>null</p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag" id="link-type-stylesheet:concept-css-style-sheet-disabled-flag" data-x-internal="concept-css-style-sheet-disabled-flag">disabled flag</a></dt><dd><p>Left at its default value.</p></dd><dt><a href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-css-rules" id="link-type-stylesheet:concept-css-style-sheet-css-rules" data-x-internal="concept-css-style-sheet-css-rules">CSS rules</a></dt><dd>
         <p>Left uninitialized.</p>

         <p class="XXX">This doesn't seem right. Presumably we should be using <var>bodyBytes</var>?
         Tracked as <a href="https://github.com/whatwg/html/issues/2997">issue #2997</a>.</p>
        </dd></dl>

      <p>The CSS <a id="link-type-stylesheet:environment-encoding" href="https://drafts.csswg.org/css-syntax/#environment-encoding" data-x-internal="environment-encoding">environment encoding</a> is the result of running the following steps:
      <a href="#refsCSSSYNTAX">[CSSSYNTAX]</a></p>

      <ol><li><p>If <var>el</var> has a <code id="link-type-stylesheet:attr-link-charset"><a href="#attr-link-charset">charset</a></code> attribute,
       <a href="https://encoding.spec.whatwg.org/#concept-encoding-get" id="link-type-stylesheet:getting-an-encoding" data-x-internal="getting-an-encoding">get an encoding</a> from that attribute's value. If
       that succeeds, return the resulting encoding. <a href="#refsENCODING">[ENCODING]</a></p></li><li><p>Otherwise, return the <a id="link-type-stylesheet:document's-character-encoding" href="https://dom.spec.whatwg.org/#concept-document-encoding" data-x-internal="document's-character-encoding">document's character encoding</a>.
       <a href="#refsDOM">[DOM]</a></p></li></ol>
     </li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="link-type-stylesheet:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="link-type-stylesheet:event-load"><a href="#event-load">load</a></code> at <var>el</var>.</p></li></ol>
   </li><li><p>Otherwise, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="link-type-stylesheet:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="link-type-stylesheet:event-error"><a href="#event-error">error</a></code> at <var>el</var>.</p></li><li>
    <p>If <var>el</var> <a href="#contributes-a-script-blocking-style-sheet" id="link-type-stylesheet:contributes-a-script-blocking-style-sheet-2">contributes a script-blocking style sheet</a>, then:</p>

    <ol><li><p><a id="link-type-stylesheet:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>el</var>'s <a id="link-type-stylesheet:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#script-blocking-style-sheet-set" id="link-type-stylesheet:script-blocking-style-sheet-set-3">script-blocking
     style sheet set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="link-type-stylesheet:list-contains" data-x-internal="list-contains">contains</a> <var>el</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="link-type-stylesheet:list-remove-2" data-x-internal="list-remove">Remove</a> <var>el</var> from its <a id="link-type-stylesheet:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
     document</a>'s <a href="#script-blocking-style-sheet-set" id="link-type-stylesheet:script-blocking-style-sheet-set-4">script-blocking style sheet set</a>.</p></li></ol>
   </li><li><p><a href="#unblock-rendering" id="link-type-stylesheet:unblock-rendering">Unblock rendering</a> on <var>el</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#process-a-link-header" id="link-type-stylesheet:process-a-link-header">process a link header</a> steps for this type of linked resource are to do
  nothing.</p>
  </div>

  


  <h5 id="link-type-tag"><span class="secno">4.6.7.24</span> Link type "<dfn data-dfn-for="a/rel,area/rel" data-dfn-type="attr-value"><code>tag</code></dfn>"<a href="#link-type-tag" class="self-link"></a></h5>

  <p>The <code id="link-type-tag:link-type-tag"><a href="#link-type-tag">tag</a></code> keyword may be used with <code id="link-type-tag:the-a-element"><a href="#the-a-element">a</a></code> and
  <code id="link-type-tag:the-area-element"><a href="#the-area-element">area</a></code> elements. This keyword creates a <a href="#hyperlink" id="link-type-tag:hyperlink">hyperlink</a>.</p>

  <p>The <code id="link-type-tag:link-type-tag-2"><a href="#link-type-tag">tag</a></code> keyword indicates that the <em>tag</em> that the
  referenced document represents applies to the current document.</p>

  <p class="note">Since it indicates that the tag <em>applies to the current document</em>, it would
  be inappropriate to use this keyword in the markup of a <a href="#tag-cloud">tag cloud</a>, which
  lists the popular tags across a set of pages.</p>

  <div class="example">

   <p>This document is about some gems, and so it is <i>tagged</i> with "<code>https://en.wikipedia.org/wiki/Gemstone</code>" to unambiguously categorize it as applying
   to the "jewel" kind of gems, and not to, say, the towns in the US, the Ruby package format, or
   the Swiss locomotive class:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->My Precious<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->My precious<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Summer 2012<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Recently I managed to dispose of a red gem that had been
  bothering me. I now have a much nicer blue sapphire.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The red gem had been found in a bauxite stone while I was digging
  out the office level, but nobody was willing to haul it away. The
  same red gem stayed there for literally years.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
   Tags: <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">tag</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://en.wikipedia.org/wiki/Gemstone"</c-><c- p="">&gt;</c->Gemstone<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In <em>this</em> document, there are two articles. The "<code id="link-type-tag:link-type-tag-3"><a href="#link-type-tag">tag</a></code>"
   link, however, applies to the whole page (and would do so wherever it was placed, including if it
   was within the <code id="link-type-tag:the-article-element"><a href="#the-article-element">article</a></code> elements).</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Gem 4/4<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->801: Steinbock<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The number 801 Gem 4/4 electro-diesel has an ibex and was rebuilt in 2002.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->802: Murmeltier<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"https://upload.wikimedia.org/wikipedia/commons/b/b0/Trains_de_la_Bernina_en_hiver_2.jpg"</c->
         <c- e="">alt</c-><c- o="">=</c-><c- s="">"The 802 was red with pantographs and tall vents on the side."</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->The 802 in the 1980s, above Lago Bianco.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The number 802 Gem 4/4 electro-diesel has a marmot and was rebuilt in 2003.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"topic"</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">tag</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://en.wikipedia.org/wiki/Rhaetian_Railway_Gem_4/4"</c-><c- p="">&gt;</c->Gem 4/4<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h5 id="link-type-terms-of-service"><span class="secno">4.6.7.25</span> Link Type "<dfn data-dfn-for="link/rel,a/rel,area/rel" data-dfn-type="attr-value"><code>terms-of-service</code></dfn>"<a href="#link-type-terms-of-service" class="self-link"></a></h5>

  <p>The <code id="link-type-terms-of-service:link-type-terms-of-service"><a href="#link-type-terms-of-service">terms-of-service</a></code> keyword may be used with
  <code id="link-type-terms-of-service:the-link-element"><a href="#the-link-element">link</a></code>, <code id="link-type-terms-of-service:the-a-element"><a href="#the-a-element">a</a></code>, and <code id="link-type-terms-of-service:the-area-element"><a href="#the-area-element">area</a></code> elements. This keyword creates a
  <a href="#hyperlink" id="link-type-terms-of-service:hyperlink">hyperlink</a>.</p>

  <p>The <code id="link-type-terms-of-service:link-type-terms-of-service-2"><a href="#link-type-terms-of-service">terms-of-service</a></code> keyword indicates that the
  referenced document contains information about the agreements between the current document's
  provider and users who wish to use the current document, as described in more detail in
  <cite>Additional Link Relation Types</cite>. <a href="#refsRFC6903">[RFC6903]</a></p>


  <h5 id="sequential-link-types"><span class="secno">4.6.7.26</span> Sequential link types<a href="#sequential-link-types" class="self-link"></a></h5>

  <p>Some documents form part of a sequence of documents.</p>

  <p>A sequence of documents is one where each document can have a <em>previous sibling</em> and a
  <em>next sibling</em>. A document with no previous sibling is the start of its sequence, a
  document with no next sibling is the end of its sequence.</p>

  <p>A document may be part of multiple sequences.</p>


  <h6 id="link-type-next"><span class="secno">4.6.7.26.1</span> Link type "<dfn data-dfn-for="link/rel,a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>next</code></dfn>"<a href="#link-type-next" class="self-link"></a></h6>

  <p>The <code id="link-type-next:link-type-next"><a href="#link-type-next">next</a></code> keyword may be used with <code id="link-type-next:the-link-element"><a href="#the-link-element">link</a></code>,
  <code id="link-type-next:the-a-element"><a href="#the-a-element">a</a></code>, <code id="link-type-next:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-next:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword creates a
  <a href="#hyperlink" id="link-type-next:hyperlink">hyperlink</a>.</p>

  <p>The <code id="link-type-next:link-type-next-2"><a href="#link-type-next">next</a></code> keyword indicates that the document is part of a
  sequence, and that the link is leading to the document that is the next logical document in the
  sequence.</p>

  <p>When the <code id="link-type-next:link-type-next-3"><a href="#link-type-next">next</a></code> keyword is used with a <code id="link-type-next:the-link-element-2"><a href="#the-link-element">link</a></code>
  element, user agents should process such links as if they were using one of the <code id="link-type-next:link-type-dns-prefetch"><a href="#link-type-dns-prefetch">dns-prefetch</a></code>, <code id="link-type-next:link-type-preconnect"><a href="#link-type-preconnect">preconnect</a></code>, or
  <code id="link-type-next:link-type-prefetch"><a href="#link-type-prefetch">prefetch</a></code> keywords. Which keyword the user agent wishes to use
  is implementation-dependent; for example, a user agent may wish to use the less-costly <code id="link-type-next:link-type-preconnect-2"><a href="#link-type-preconnect">preconnect</a></code> processing model when trying to conserve data, battery
  power, or processing power, or may wish to pick a keyword depending on heuristic analysis of past
  user behavior in similar scenarios.</p>

  <h6 id="link-type-prev"><span class="secno">4.6.7.26.2</span> Link type "<dfn data-dfn-for="link/rel,a/rel,area/rel,form/rel" data-dfn-type="attr-value"><code>prev</code></dfn>"<a href="#link-type-prev" class="self-link"></a></h6>

  <p>The <code id="link-type-prev:link-type-prev"><a href="#link-type-prev">prev</a></code> keyword may be used with <code id="link-type-prev:the-link-element"><a href="#the-link-element">link</a></code>,
  <code id="link-type-prev:the-a-element"><a href="#the-a-element">a</a></code>, <code id="link-type-prev:the-area-element"><a href="#the-area-element">area</a></code>, and <code id="link-type-prev:the-form-element"><a href="#the-form-element">form</a></code> elements. This keyword creates a
  <a href="#hyperlink" id="link-type-prev:hyperlink">hyperlink</a>.</p>

  <p>The <code id="link-type-prev:link-type-prev-2"><a href="#link-type-prev">prev</a></code> keyword indicates that the document is part of a
  sequence, and that the link is leading to the document that is the previous logical document in
  the sequence.</p>

  

  <p><strong>Synonyms</strong>: For historical reasons, user agents must also treat the keyword
  "<code>previous</code>" like the <code id="link-type-prev:link-type-prev-3"><a href="#link-type-prev">prev</a></code> keyword.</p>

  


  <h5 id="other-link-types"><span class="secno">4.6.7.27</span> Other link types<a href="#other-link-types" class="self-link"></a></h5>

  <p><dfn id="concept-rel-extensions">Extensions to the predefined set of link types</dfn> may
  be registered on the <a href="https://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions">microformats
  page for existing rel values</a>. <a href="#refsMFREL">[MFREL]</a></p>

  <p>Anyone is free to edit the <span>microformats page for existing rel values</span> at
  any time to add a type. Extension types must be specified with the following information:</p>

  <dl><dt>Keyword</dt><dd>
    <p>The actual value being defined. The value should not be confusingly similar to any other
    defined value (e.g. differing only in case).</p>

    <p>If the value contains a U+003A COLON character (:), it must also be an <a id="other-link-types:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>
   </dd><dt>Effect on... <code id="other-link-types:the-link-element"><a href="#the-link-element">link</a></code></dt><dd>
    <p>One of the following:</p>

    <dl><dt>Not allowed</dt><dd>The keyword must not be specified on <code id="other-link-types:the-link-element-2"><a href="#the-link-element">link</a></code> elements.</dd><dt>Hyperlink</dt><dd>The keyword may be specified on a <code id="other-link-types:the-link-element-3"><a href="#the-link-element">link</a></code> element; it creates a
     <a href="#hyperlink" id="other-link-types:hyperlink">hyperlink</a>.</dd><dt>External Resource</dt><dd>The keyword may be specified on a <code id="other-link-types:the-link-element-4"><a href="#the-link-element">link</a></code> element; it creates an <a href="#external-resource-link" id="other-link-types:external-resource-link">external
     resource link</a>.</dd></dl>
   </dd><dt>Effect on... <code id="other-link-types:the-a-element"><a href="#the-a-element">a</a></code> and <code id="other-link-types:the-area-element"><a href="#the-area-element">area</a></code></dt><dd>
    <p>One of the following:</p>

    <dl><dt>Not allowed</dt><dd>The keyword must not be specified on <code id="other-link-types:the-a-element-2"><a href="#the-a-element">a</a></code> and <code id="other-link-types:the-area-element-2"><a href="#the-area-element">area</a></code> elements.</dd><dt>Hyperlink</dt><dd>The keyword may be specified on <code id="other-link-types:the-a-element-3"><a href="#the-a-element">a</a></code> and <code id="other-link-types:the-area-element-3"><a href="#the-area-element">area</a></code> elements; it creates a
     <a href="#hyperlink" id="other-link-types:hyperlink-2">hyperlink</a>.</dd><dt>External Resource</dt><dd>The keyword may be specified on <code id="other-link-types:the-a-element-4"><a href="#the-a-element">a</a></code> and <code id="other-link-types:the-area-element-4"><a href="#the-area-element">area</a></code> elements; it creates
     an <a href="#external-resource-link" id="other-link-types:external-resource-link-2">external resource link</a>.</dd><dt>Hyperlink Annotation</dt><dd>The keyword may be specified on <code id="other-link-types:the-a-element-5"><a href="#the-a-element">a</a></code> and <code id="other-link-types:the-area-element-5"><a href="#the-area-element">area</a></code> elements; it <a href="#hyperlink-annotation" id="other-link-types:hyperlink-annotation">annotates</a> other <a href="#hyperlink" id="other-link-types:hyperlink-3">hyperlinks</a>
     created by the element.</dd></dl>
   </dd><dt>Effect on... <code id="other-link-types:the-form-element"><a href="#the-form-element">form</a></code></dt><dd>
    <p>One of the following:</p>

    <dl><dt>Not allowed</dt><dd>The keyword must not be specified on <code id="other-link-types:the-form-element-2"><a href="#the-form-element">form</a></code> elements.</dd><dt>Hyperlink</dt><dd>The keyword may be specified on <code id="other-link-types:the-form-element-3"><a href="#the-form-element">form</a></code> elements; it creates a
     <a href="#hyperlink" id="other-link-types:hyperlink-4">hyperlink</a>.</dd><dt>External Resource</dt><dd>The keyword may be specified on <code id="other-link-types:the-form-element-4"><a href="#the-form-element">form</a></code> elements; it creates an <a href="#external-resource-link" id="other-link-types:external-resource-link-3">external
     resource link</a>.</dd><dt>Hyperlink Annotation</dt><dd>The keyword may be specified on <code id="other-link-types:the-form-element-5"><a href="#the-form-element">form</a></code> elements; it <a href="#hyperlink-annotation" id="other-link-types:hyperlink-annotation-2">annotates</a> other <a href="#hyperlink" id="other-link-types:hyperlink-5">hyperlinks</a> created by the
     element.</dd></dl>
   </dd><dt>Brief description</dt><dd><p>A short non-normative description of what the keyword's meaning is.</p></dd><dt>Specification</dt><dd><p>A link to a more detailed description of the keyword's semantics and requirements. It
   could be another page on the wiki, or a link to an external page.</p></dd><dt>Synonyms</dt><dd><p>A list of other keyword values that have exactly the same processing requirements. Authors
   should not use the values defined to be synonyms, they are only intended to allow user agents to
   support legacy content. Anyone may remove synonyms that are not used in practice; only names that
   need to be processed as synonyms for compatibility with legacy content are to be registered in
   this way.</p></dd><dt>Status</dt><dd>
    <p>One of the following:</p>

    <dl><dt>Proposed</dt><dd>The keyword has not received wide peer review and approval. Someone has proposed it and is,
     or soon will be, using it.</dd><dt>Ratified</dt><dd>The keyword has received wide peer review and approval. It has a specification that
     unambiguously defines how to handle pages that use the keyword, including when they use it in
     incorrect ways.</dd><dt>Discontinued</dt><dd>The keyword has received wide peer review and it has been found wanting. Existing pages are
     using this keyword, but new pages should avoid it. The "brief description" and "specification"
     entries will give details of what authors should use instead, if anything.</dd></dl>

    <p>If a keyword is found to be redundant with existing values, it should be removed and listed
    as a synonym for the existing value.</p>

    <p>If a keyword is registered in the "proposed" state for a period of a month or more without
    being used or specified, then it may be removed from the registry.</p>

    <p>If a keyword is added with the "proposed" status and found to be redundant with existing
    values, it should be removed and listed as a synonym for the existing value. If a keyword is
    added with the "proposed" status and found to be harmful, then it should be changed to
    "discontinued" status.</p>

    <p>Anyone can change the status at any time, but should only do so in accordance with the
    definitions above.</p>
   </dd></dl>

  

  <p>Conformance checkers must use the information given on the <span>microformats page
  for existing rel values</span> to establish if a value is allowed or not: values defined in this
  specification or marked as "proposed" or "ratified" must be accepted when used on the elements for
  which they apply as described in the "Effect on..." field, whereas values marked as "discontinued"
  or not listed in either this specification or on the aforementioned page must be rejected as
  invalid. Conformance checkers may cache this information (e.g. for performance reasons or to avoid
  the use of unreliable network connectivity).</p>

  <p>When an author uses a new type not defined by either this specification or the wiki page,
  conformance checkers should offer to add the value to the wiki, with the details described above,
  with the "proposed" status.</p>

  

  <p>Types defined as extensions in the <a href="https://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions">microformats
  page for existing rel values</a> with the status "proposed" or "ratified" may be used with the
  <code>rel</code> attribute on <code id="other-link-types:the-link-element-5"><a href="#the-link-element">link</a></code>, <code id="other-link-types:the-a-element-6"><a href="#the-a-element">a</a></code>, and <code id="other-link-types:the-area-element-6"><a href="#the-area-element">area</a></code>
  elements in accordance to the "Effect on..." field. <a href="#refsMFREL">[MFREL]</a></p>



  <h3 id="edits"><span class="secno">4.7</span> Edits<a href="#edits" class="self-link"></a></h3>

  <p>The <code id="edits:the-ins-element"><a href="#the-ins-element">ins</a></code> and <code id="edits:the-del-element"><a href="#the-del-element">del</a></code> elements represent edits to the document.</p>


  <h4 id="the-ins-element"><span class="secno">4.7.1</span> The <dfn data-dfn-type="element"><code>ins</code></dfn> element<a href="#the-ins-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ins" title="The <ins> HTML element represents a range of text that has been added to a document. You can use the <del> element to similarly represent a range of text that has been deleted from the document.">Element/ins</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-ins-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-ins-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-ins-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-ins-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-ins-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-ins-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-ins-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#transparent" id="the-ins-element:transparent">Transparent</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-ins-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-ins-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-ins-element:global-attributes">Global attributes</a></dd><dd><code id="the-ins-element:attr-mod-cite"><a href="#attr-mod-cite">cite</a></code> —  Link to the source of the quotation or more information about the edit
     </dd><dd><code id="the-ins-element:attr-mod-datetime"><a href="#attr-mod-datetime">datetime</a></code> —  Date and (optionally) time of the change
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-ins-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-ins">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-ins">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-ins-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-ins-element:htmlmodelement"><a href="#htmlmodelement">HTMLModElement</a></code>.</dd></dl>

  <p>The <code id="the-ins-element:the-ins-element"><a href="#the-ins-element">ins</a></code> element <a href="#represents" id="the-ins-element:represents">represents</a> an addition to the document.</p>

  <div class="example">

   <p>The following represents the addition of a single paragraph:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> I like fruit. <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></code></pre>

   <p>As does the following, because everything in the <code id="the-ins-element:the-aside-element"><a href="#the-aside-element">aside</a></code> element here counts as
   <a href="#phrasing-content-2" id="the-ins-element:phrasing-content-2-3">phrasing content</a> and therefore there is just one <a href="#paragraph" id="the-ins-element:paragraph">paragraph</a>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->
  Apples are <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->tasty<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c->.
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->
  So are pears.
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p><code id="the-ins-element:the-ins-element-2"><a href="#the-ins-element">ins</a></code> elements should not cross <a href="#paragraph" id="the-ins-element:paragraph-2">implied paragraph</a>
  boundaries.</p>

  <div class="example">

   <p>The following example represents the addition of two paragraphs, the second of which was
   inserted in two parts. The first <code id="the-ins-element:the-ins-element-3"><a href="#the-ins-element">ins</a></code> element in this example thus crosses a
   paragraph boundary, which is considered poor form.</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- c="">&lt;!-- don't do this --&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2005-03-16 00:00Z"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> I like fruit. <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  Apples are <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->tasty<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c->.
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2007-12-19 00:00Z"</c-><c- p="">&gt;</c->
  So are pears.
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></code></pre>

   <p>Here is a better way of marking this up. It uses more elements, but none of the elements cross
   implied paragraph boundaries.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2005-03-16 00:00Z"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> I like fruit. <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2005-03-16 00:00Z"</c-><c- p="">&gt;</c->
  Apples are <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->tasty<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c->.
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2007-12-19 00:00Z"</c-><c- p="">&gt;</c->
  So are pears.
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></code></pre>

   

  </div>


  <h4 id="the-del-element"><span class="secno">4.7.2</span> The <dfn data-dfn-type="element"><code>del</code></dfn> element<a href="#the-del-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/del" title="The <del> HTML element represents a range of text that has been deleted from a document. This can be used when rendering &quot;track changes&quot; or source code diff information, for example. The <ins> element can be used for the opposite purpose: to indicate text that has been added to the document.">Element/del</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-del-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-del-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-del-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-del-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-del-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-del-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-del-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#transparent" id="the-del-element:transparent">Transparent</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-del-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-del-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-del-element:global-attributes">Global attributes</a></dd><dd><code id="the-del-element:attr-mod-cite"><a href="#attr-mod-cite">cite</a></code> —  Link to the source of the quotation or more information about the edit
     </dd><dd><code id="the-del-element:attr-mod-datetime"><a href="#attr-mod-datetime">datetime</a></code> —  Date and (optionally) time of the change
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-del-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-del">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-del">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-del-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-del-element:htmlmodelement"><a href="#htmlmodelement">HTMLModElement</a></code>.</dd></dl>

  <p>The <code id="the-del-element:the-del-element"><a href="#the-del-element">del</a></code> element <a href="#represents" id="the-del-element:represents">represents</a> a removal from the document.</p>

  <p><code id="the-del-element:the-del-element-2"><a href="#the-del-element">del</a></code> elements should not cross <a href="#paragraph" id="the-del-element:paragraph">implied paragraph</a>
  boundaries.</p>

  <div class="example">

   <p>The following shows a "to do" list where items that have been done are crossed-off with the
   date and time of their completion.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->To Do<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Empty the dishwasher<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">del</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-10-11T01:25-07:00"</c-><c- p="">&gt;</c->Watch Walter Lewin's lectures<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">del</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-10-10T23:38-07:00"</c-><c- p="">&gt;</c->Download more tracks<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Buy a printer<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="attributes-common-to-ins-and-del-elements"><span class="secno">4.7.3</span> Attributes common to <code id="attributes-common-to-ins-and-del-elements:the-ins-element"><a href="#the-ins-element">ins</a></code> and <code id="attributes-common-to-ins-and-del-elements:the-del-element"><a href="#the-del-element">del</a></code> elements<a href="#attributes-common-to-ins-and-del-elements" class="self-link"></a></h4>

  <p>The <dfn data-dfn-for="ins,del" id="attr-mod-cite" data-dfn-type="element-attr"><code>cite</code></dfn> attribute
  may be used to specify the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="attributes-common-to-ins-and-del-elements:the-document's-address" data-x-internal="the-document's-address">URL</a> of a document that
  explains the change. When that document is long, for instance the minutes of a meeting, authors
  are encouraged to include a <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="attributes-common-to-ins-and-del-elements:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> pointing to the
  specific part of that document that discusses the change.</p>

  <p>If the <code id="attributes-common-to-ins-and-del-elements:attr-mod-cite"><a href="#attr-mod-cite">cite</a></code> attribute is present, it must be a <a href="#valid-url-potentially-surrounded-by-spaces" id="attributes-common-to-ins-and-del-elements:valid-url-potentially-surrounded-by-spaces">valid
  URL potentially surrounded by spaces</a> that explains the change. To obtain
  the corresponding citation link, the value of the attribute must be <a href="#encoding-parsing-a-url" id="attributes-common-to-ins-and-del-elements:encoding-parsing-a-url">parsed</a> relative to the element's <a id="attributes-common-to-ins-and-del-elements:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>. User agents may
  allow users to follow such citation links, but they are primarily intended for private use (e.g.,
  by server-side scripts collecting statistics about a site's edits), not for readers.</p>


  <p>The <dfn data-dfn-for="ins,del" id="attr-mod-datetime" data-dfn-type="element-attr"><code>datetime</code></dfn>
  attribute may be used to specify the time and date of the change.</p>

  <p>If present, the <code id="attributes-common-to-ins-and-del-elements:attr-mod-datetime"><a href="#attr-mod-datetime">datetime</a></code> attribute's value must be a
  <a href="#valid-date-string-with-optional-time" id="attributes-common-to-ins-and-del-elements:valid-date-string-with-optional-time">valid date string with optional time</a>.</p>

  

  <div data-algorithm="">
  <p>User agents must parse the <code id="attributes-common-to-ins-and-del-elements:attr-mod-datetime-2"><a href="#attr-mod-datetime">datetime</a></code> attribute according
  to the <a href="#parse-a-date-or-time-string" id="attributes-common-to-ins-and-del-elements:parse-a-date-or-time-string">parse a date or time string</a> algorithm. If that doesn't return a <a href="#concept-date" id="attributes-common-to-ins-and-del-elements:concept-date">date</a> or a <a href="#concept-datetime" id="attributes-common-to-ins-and-del-elements:concept-datetime">global date and time</a>,
  then the modification has no associated timestamp (the value is non-conforming; it is not a
  <a href="#valid-date-string-with-optional-time" id="attributes-common-to-ins-and-del-elements:valid-date-string-with-optional-time-2">valid date string with optional time</a>). Otherwise, the modification is marked as
  having been made at the given <a href="#concept-date" id="attributes-common-to-ins-and-del-elements:concept-date-2">date</a> or <a href="#concept-datetime" id="attributes-common-to-ins-and-del-elements:concept-datetime-2">global date and time</a>. If the given value is a <a href="#concept-datetime" id="attributes-common-to-ins-and-del-elements:concept-datetime-3">global date and time</a>, then user agents should use the associated
  time-zone offset information to determine which time zone to present the given datetime in.</p>
  </div>

  

  <p>This value may be shown to the user, but it is primarily intended for
  private use.</p>

  

  <p>The <code id="attributes-common-to-ins-and-del-elements:the-ins-element-2"><a href="#the-ins-element">ins</a></code> and <code id="attributes-common-to-ins-and-del-elements:the-del-element-2"><a href="#the-del-element">del</a></code> elements must implement the
  <code id="attributes-common-to-ins-and-del-elements:htmlmodelement"><a href="#htmlmodelement">HTMLModElement</a></code> interface:</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLModElement" title="The HTMLModElement interface provides special properties (beyond the regular methods and properties available through the HTMLElement interface they also have available to them by inheritance) for manipulating modification elements, that is <del> and <ins>.">HTMLModElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlmodelement" data-dfn-type="interface"><c- g="">HTMLModElement</c-></dfn> : <a href="#htmlelement" id="attributes-common-to-ins-and-del-elements:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="attributes-common-to-ins-and-del-elements:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="attributes-common-to-ins-and-del-elements:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="attributes-common-to-ins-and-del-elements:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLModElement" id="dom-mod-cite" data-dfn-type="attribute"><c- g="">cite</c-></dfn>;
  [<a href="#cereactions" id="attributes-common-to-ins-and-del-elements:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="attributes-common-to-ins-and-del-elements:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLModElement" id="dom-mod-datetime" data-dfn-type="attribute"><c- g="">dateTime</c-></dfn>;
};</code></pre>

  



  <h4 id="edits-and-paragraphs"><span class="secno">4.7.4</span> Edits and paragraphs<a href="#edits-and-paragraphs" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Since the <code id="edits-and-paragraphs:the-ins-element"><a href="#the-ins-element">ins</a></code> and <code id="edits-and-paragraphs:the-del-element"><a href="#the-del-element">del</a></code> elements do not affect <a href="#paragraph" id="edits-and-paragraphs:paragraph">paragraphing</a>, it is possible, in some cases where paragraphs are <a href="#paragraph" id="edits-and-paragraphs:paragraph-2">implied</a> (without explicit <code id="edits-and-paragraphs:the-p-element"><a href="#the-p-element">p</a></code> elements), for an
  <code id="edits-and-paragraphs:the-ins-element-2"><a href="#the-ins-element">ins</a></code> or <code id="edits-and-paragraphs:the-del-element-2"><a href="#the-del-element">del</a></code> element to span both an entire paragraph or other
  non-<a href="#phrasing-content-2" id="edits-and-paragraphs:phrasing-content-2">phrasing content</a> elements and part of another paragraph. For example:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
   This is a paragraph that was inserted.
  <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  This is another paragraph whose first sentence was inserted
  at the same time as the paragraph above.
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
 This is a second sentence, which was there all along.
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  <p>By only wrapping some paragraphs in <code id="edits-and-paragraphs:the-p-element-2"><a href="#the-p-element">p</a></code> elements, one can even get the end of one
  paragraph, a whole second paragraph, and the start of a third paragraph to be covered by the same
  <code id="edits-and-paragraphs:the-ins-element-3"><a href="#the-ins-element">ins</a></code> or <code id="edits-and-paragraphs:the-del-element-3"><a href="#the-del-element">del</a></code> element (though this is very confusing, and not considered
  good practice):</p>

  <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 This is the first paragraph. <c- p="">&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->This sentence was
 inserted.
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This second paragraph was inserted.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 This sentence was inserted too.<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c-> This is the
 third paragraph in this example.
 <c- c="">&lt;!-- (don't do this) --&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  <p>However, due to the way <a href="#paragraph" id="edits-and-paragraphs:paragraph-3">implied paragraphs</a> are defined, it is
  not possible to mark up the end of one paragraph and the start of the very next one using the same
  <code id="edits-and-paragraphs:the-ins-element-4"><a href="#the-ins-element">ins</a></code> or <code id="edits-and-paragraphs:the-del-element-4"><a href="#the-del-element">del</a></code> element. You instead have to use one (or two) <code id="edits-and-paragraphs:the-p-element-3"><a href="#the-p-element">p</a></code>
  element(s) and two <code id="edits-and-paragraphs:the-ins-element-5"><a href="#the-ins-element">ins</a></code> or <code id="edits-and-paragraphs:the-del-element-5"><a href="#the-del-element">del</a></code> elements, as for example:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This is the first paragraph. <c- p="">&lt;</c-><c- f="">del</c-><c- p="">&gt;</c->This sentence was
 deleted.<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">del</c-><c- p="">&gt;</c->This sentence was deleted too.<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;</c-> That
 sentence needed a separate <c- ni="">&amp;lt;</c->del<c- ni="">&amp;gt;</c-> element.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  <p>Partly because of the confusion described above, authors are strongly encouraged to always mark
  up all paragraphs with the <code id="edits-and-paragraphs:the-p-element-4"><a href="#the-p-element">p</a></code> element, instead of having <code id="edits-and-paragraphs:the-ins-element-6"><a href="#the-ins-element">ins</a></code> or
  <code id="edits-and-paragraphs:the-del-element-6"><a href="#the-del-element">del</a></code> elements that cross <a href="#paragraph" id="edits-and-paragraphs:paragraph-4">implied paragraphs</a>
  boundaries.</p>


  <h4 id="edits-and-lists"><span class="secno">4.7.5</span> Edits and lists<a href="#edits-and-lists" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>The content models of the <code id="edits-and-lists:the-ol-element"><a href="#the-ol-element">ol</a></code> and <code id="edits-and-lists:the-ul-element"><a href="#the-ul-element">ul</a></code> elements do not allow
  <code id="edits-and-lists:the-ins-element"><a href="#the-ins-element">ins</a></code> and <code id="edits-and-lists:the-del-element"><a href="#the-del-element">del</a></code> elements as children. Lists always represent all their
  items, including items that would otherwise have been marked as deleted.</p>

  <p>To indicate that an item is inserted or deleted, an <code id="edits-and-lists:the-ins-element-2"><a href="#the-ins-element">ins</a></code> or <code id="edits-and-lists:the-del-element-2"><a href="#the-del-element">del</a></code>
  element can be wrapped around the contents of the <code id="edits-and-lists:the-li-element"><a href="#the-li-element">li</a></code> element. To indicate that an
  item has been replaced by another, a single <code id="edits-and-lists:the-li-element-2"><a href="#the-li-element">li</a></code> element can have one or more
  <code id="edits-and-lists:the-del-element-3"><a href="#the-del-element">del</a></code> elements followed by one or more <code id="edits-and-lists:the-ins-element-3"><a href="#the-ins-element">ins</a></code> elements.</p>

  <div class="example">

   <p>In the following example, a list that started empty had items added and removed from it over
   time. The bits in the example that have been emphasized show the parts that are the "current"
   state of the list. The list item numbers don't take into account the edits, though.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Stop-ship bugs<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ol</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2008-02-12T15:20Z"</c-><c- p="">&gt;</c-><em>Bug 225:
 Rain detector doesn't work in snow</em><c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">del</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2008-03-01T20:22Z"</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2008-02-14T12:02Z"</c-><c- p="">&gt;</c->Bug 228:
 Water buffer overflows in April<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2008-02-16T13:50Z"</c-><c- p="">&gt;</c-><em>Bug 230:
 Water heater doesn't use renewable fuels</em><c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">del</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2008-02-20T21:15Z"</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2008-02-16T14:25Z"</c-><c- p="">&gt;</c->Bug 232:
 Carbon dioxide emissions detected after startup<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following example, a list that started with just fruit was replaced by a list with just
   colors.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->List of <c- p="">&lt;</c-><c- f="">del</c-><c- p="">&gt;</c->fruits<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->colors<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">del</c-><c- p="">&gt;</c->Lime<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->Green<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">del</c-><c- p="">&gt;</c->Apple<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Orange<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">del</c-><c- p="">&gt;</c->Pear<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->Teal<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">del</c-><c- p="">&gt;</c->Lemon<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->Yellow<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Olive<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->Purple<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="edits-and-tables"><span class="secno">4.7.6</span> Edits and tables<a href="#edits-and-tables" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>The elements that form part of the table model have complicated content model requirements that
  do not allow for the <code id="edits-and-tables:the-ins-element"><a href="#the-ins-element">ins</a></code> and <code id="edits-and-tables:the-del-element"><a href="#the-del-element">del</a></code> elements, so indicating edits to a
  table can be difficult.</p>

  <p>To indicate that an entire row or an entire column has been added or removed, the entire
  contents of each cell in that row or column can be wrapped in <code id="edits-and-tables:the-ins-element-2"><a href="#the-ins-element">ins</a></code> or <code id="edits-and-tables:the-del-element-2"><a href="#the-del-element">del</a></code>
  elements (respectively).</p>

  <div class="example">

   <p>Here, a table's row has been added:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Game name           <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Game publisher   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Verdict
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Diablo 2            <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Blizzard         <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 8/10
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Portal              <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Valve            <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 10/10
<strong>  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->Portal 2<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->Valve<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">ins</c-><c- p="">&gt;</c->10/10<c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

   <p>Here, a column has been removed (the time at which it was removed is given also, as is a link
   to the page explaining why):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Game name           <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Game publisher   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> <strong><c- p="">&lt;</c-><c- f="">del</c-> <c- e="">cite</c-><c- o="">=</c-><c- s="">"/edits/r192"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2011-05-02 14:23Z"</c-><c- p="">&gt;</c->Verdict<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Diablo 2            <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Blizzard         <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <strong><c- p="">&lt;</c-><c- f="">del</c-> <c- e="">cite</c-><c- o="">=</c-><c- s="">"/edits/r192"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2011-05-02 14:23Z"</c-><c- p="">&gt;</c->8/10<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Portal              <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Valve            <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <strong><c- p="">&lt;</c-><c- f="">del</c-> <c- e="">cite</c-><c- o="">=</c-><c- s="">"/edits/r192"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2011-05-02 14:23Z"</c-><c- p="">&gt;</c->10/10<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Portal 2            <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Valve            <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <strong><c- p="">&lt;</c-><c- f="">del</c-> <c- e="">cite</c-><c- o="">=</c-><c- s="">"/edits/r192"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2011-05-02 14:23Z"</c-><c- p="">&gt;</c->10/10<c- p="">&lt;/</c-><c- f="">del</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Generally speaking, there is no good way to indicate more complicated edits (e.g. that a cell
  was removed, moving all subsequent cells up or to the left).</p>




  <h3 id="embedded-content"><span class="secno">4.8</span> Embedded content<a href="#embedded-content" class="self-link"></a></h3>

  <h4 id="the-picture-element"><span class="secno">4.8.1</span> The <dfn data-dfn-type="element"><code>picture</code></dfn> element<a href="#the-picture-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture" title="The <picture> HTML element contains zero or more <source> elements and one <img> element to offer alternative versions of an image for different display/device scenarios.">Element/picture</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>9.1+</span></span><span class="chrome yes"><span>Chrome</span><span>38+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLPictureElement" title="The HTMLPictureElement interface represents a <picture> HTML element. It doesn't implement specific properties or methods.">HTMLPictureElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>9.1+</span></span><span class="chrome yes"><span>Chrome</span><span>38+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-picture-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-picture-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-picture-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#embedded-content-category" id="the-picture-element:embedded-content-category">Embedded content</a>.</dd><dd><a href="#palpable-content-2" id="the-picture-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-picture-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#embedded-content-category" id="the-picture-element:embedded-content-category-2">embedded content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-picture-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or more <code id="the-picture-element:the-source-element"><a href="#the-source-element">source</a></code> elements, followed by one <code id="the-picture-element:the-img-element"><a href="#the-img-element">img</a></code> element,
   optionally intermixed with <a href="#script-supporting-elements-2" id="the-picture-element:script-supporting-elements-2">script-supporting elements</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-picture-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-picture-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-picture-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-picture-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-picture">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-picture">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-picture-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlpictureelement" data-dfn-type="interface"><c- g="">HTMLPictureElement</c-></dfn> : <a href="#htmlelement" id="the-picture-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-picture-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();
};</code></pre>
   </dd></dl>

  <p>The <code id="the-picture-element:the-picture-element"><a href="#the-picture-element">picture</a></code> element is a container
  which provides multiple sources to its contained <code id="the-picture-element:the-img-element-2"><a href="#the-img-element">img</a></code> element
  to allow authors to declaratively control or give hints to the user agent about which image resource to use,
  based on the screen pixel density, <a id="the-picture-element:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> size, image format, and other factors.
  It <a href="#represents" id="the-picture-element:represents">represents</a> its children.</p>

  <p class="note">The <code id="the-picture-element:the-picture-element-2"><a href="#the-picture-element">picture</a></code> element is somewhat different from the similar-looking
  <code id="the-picture-element:the-video-element"><a href="#the-video-element">video</a></code> and <code id="the-picture-element:the-audio-element"><a href="#the-audio-element">audio</a></code> elements. While all of them contain <code id="the-picture-element:the-source-element-2"><a href="#the-source-element">source</a></code>
  elements, the <code id="the-picture-element:the-source-element-3"><a href="#the-source-element">source</a></code> element's <code id="the-picture-element:attr-source-src"><a href="#attr-source-src">src</a></code> attribute
  has no meaning when the element is nested within a <code id="the-picture-element:the-picture-element-3"><a href="#the-picture-element">picture</a></code> element, and the resource
  selection algorithm is different. Also, the <code id="the-picture-element:the-picture-element-4"><a href="#the-picture-element">picture</a></code> element itself does not display
  anything; it merely provides a context for its contained <code id="the-picture-element:the-img-element-3"><a href="#the-img-element">img</a></code> element that enables it
  to choose from multiple <a href="https://url.spec.whatwg.org/#concept-url" id="the-picture-element:url" data-x-internal="url">URLs</a>.</p>


  <h4 id="the-source-element"><span class="secno">4.8.2</span> The <dfn data-dfn-type="element"><code>source</code></dfn> element<a href="#the-source-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source" title="The <source> HTML element specifies multiple media resources for the <picture>, the <audio> element, or the <video> element. It is a void element, meaning that it has no content and does not have a closing tag. It is commonly used to offer the same media content in multiple file formats in order to provide compatibility with a broad range of browsers given their differing support for image file formats and media file formats.">Element/source</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement" title="The HTMLSourceElement interface provides special properties (beyond the regular HTMLElement object interface it also has available to it by inheritance) for manipulating <source> elements.">HTMLSourceElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-source-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-source-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-source-element:the-picture-element"><a href="#the-picture-element">picture</a></code> element, before the <code id="the-source-element:the-img-element"><a href="#the-img-element">img</a></code> element.</dd><dd>As a child of a <a href="#media-element" id="the-source-element:media-element">media element</a>, before any <a href="#flow-content-2" id="the-source-element:flow-content-2">flow content</a> or
   <code id="the-source-element:the-track-element"><a href="#the-track-element">track</a></code> elements.</dd><dt><a href="#concept-element-content-model" id="the-source-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-source-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-source-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-source-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-source-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-source-element:global-attributes">Global attributes</a></dd><dd><code id="the-source-element:attr-source-type"><a href="#attr-source-type">type</a></code> —  Type of embedded resource
     </dd><dd><code id="the-source-element:attr-source-media"><a href="#attr-source-media">media</a></code> —  Applicable media
     </dd><dd><code id="the-source-element:attr-source-src"><a href="#attr-source-src">src</a></code> (in <code id="the-source-element:the-audio-element"><a href="#the-audio-element">audio</a></code> or <code id="the-source-element:the-video-element"><a href="#the-video-element">video</a></code>) —  Address of the resource
     </dd><dd><code id="the-source-element:attr-source-srcset"><a href="#attr-source-srcset">srcset</a></code> (in <code id="the-source-element:the-picture-element-2"><a href="#the-picture-element">picture</a></code>) —  Images to use in different situations, e.g., high-resolution displays, small monitors, etc.
     </dd><dd><code id="the-source-element:attr-source-sizes"><a href="#attr-source-sizes">sizes</a></code> (in <code id="the-source-element:the-picture-element-3"><a href="#the-picture-element">picture</a></code>) —  Image sizes for different page layouts
     </dd><dd><code id="the-source-element:attr-dim-width"><a href="#attr-dim-width">width</a></code> (in <code id="the-source-element:the-picture-element-4"><a href="#the-picture-element">picture</a></code>) —  Horizontal dimension
     </dd><dd><code id="the-source-element:attr-dim-height"><a href="#attr-dim-height">height</a></code> (in <code id="the-source-element:the-picture-element-5"><a href="#the-picture-element">picture</a></code>) —  Vertical dimension
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-source-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-source">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-source">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-source-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlsourceelement" data-dfn-type="interface"><c- g="">HTMLSourceElement</c-></dfn> : <a href="#htmlelement" id="the-source-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-source-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-source-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-source-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLSourceElement" id="dom-source-src" data-dfn-type="attribute"><c- g="">src</c-></dfn>;
  [<a href="#cereactions" id="the-source-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-source-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLSourceElement" id="dom-source-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;
  [<a href="#cereactions" id="the-source-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-source-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLSourceElement" id="dom-source-srcset" data-dfn-type="attribute"><c- g="">srcset</c-></dfn>;
  [<a href="#cereactions" id="the-source-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-source-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLSourceElement" id="dom-source-sizes" data-dfn-type="attribute"><c- g="">sizes</c-></dfn>;
  [<a href="#cereactions" id="the-source-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-source-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLSourceElement" id="dom-source-media" data-dfn-type="attribute"><c- g="">media</c-></dfn>;
  [<a href="#cereactions" id="the-source-element:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-source-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLSourceElement" id="dom-source-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;
  [<a href="#cereactions" id="the-source-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-source-element:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLSourceElement" id="dom-source-height" data-dfn-type="attribute"><c- g="">height</c-></dfn>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-source-element:the-source-element"><a href="#the-source-element">source</a></code> element allows authors to specify multiple alternative
  <a href="#source-set" id="the-source-element:source-set">source sets</a> for <code id="the-source-element:the-img-element-2"><a href="#the-img-element">img</a></code> elements or multiple alternative
  <a href="#media-resource" id="the-source-element:media-resource">media resources</a> for <a href="#media-element" id="the-source-element:media-element-2">media
  elements</a>. It does not <a href="#represents" id="the-source-element:represents">represent</a> anything on its own.</p>

  <p>The <dfn data-dfn-for="source" id="attr-source-type" data-dfn-type="element-attr"><code>type</code></dfn> attribute
  may be present. If present, the value must be a <a id="the-source-element:valid-mime-type-string" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">valid MIME type string</a>.</p>

  <p>The <dfn data-dfn-for="source" id="attr-source-media" data-dfn-type="element-attr"><code>media</code></dfn>
  attribute may also be present. If present, the value must contain a <a href="#valid-media-query-list" id="the-source-element:valid-media-query-list">valid media query
  list</a>. The user agent will skip to the next <code id="the-source-element:the-source-element-2"><a href="#the-source-element">source</a></code> element if the value does
  not <a href="#matches-the-environment" id="the-source-element:matches-the-environment">match the environment</a>.</p>

  <p class="note">The <code id="the-source-element:attr-source-media-2"><a href="#attr-source-media">media</a></code> attribute is only evaluated
  once during the <a href="#concept-media-load-algorithm" id="the-source-element:concept-media-load-algorithm">resource selection algorithm</a>
  for <a href="#media-element" id="the-source-element:media-element-3">media elements</a>. In contrast, when using the
  <code id="the-source-element:the-picture-element-6"><a href="#the-picture-element">picture</a></code> element, the user agent will <a href="#img-environment-changes">react to
  changes in the environment</a>.</p>

  <p>The remainder of the requirements depend on whether the parent is a <code id="the-source-element:the-picture-element-7"><a href="#the-picture-element">picture</a></code>
  element or a <a href="#media-element" id="the-source-element:media-element-4">media element</a>:</p>

  <dl class="switch"><dt>The <code id="the-source-element:the-source-element-3"><a href="#the-source-element">source</a></code> element's parent is a <code id="the-source-element:the-picture-element-8"><a href="#the-picture-element">picture</a></code> element</dt><dd>
    <p>The <dfn data-dfn-for="source" id="attr-source-srcset" data-dfn-type="element-attr"><code>srcset</code></dfn>
    attribute must be present, and is a <a href="#srcset-attribute" id="the-source-element:srcset-attribute">srcset attribute</a>.</p>

    <p>The <code id="the-source-element:attr-source-srcset-2"><a href="#attr-source-srcset">srcset</a></code> attribute contributes the <a href="#image-source" id="the-source-element:image-source">image sources</a> to the <a href="#source-set" id="the-source-element:source-set-2">source set</a>, if the
    <code id="the-source-element:the-source-element-4"><a href="#the-source-element">source</a></code> element is selected.</p>

    <p>If the <code id="the-source-element:attr-source-srcset-3"><a href="#attr-source-srcset">srcset</a></code> attribute has any <a href="#image-candidate-string" id="the-source-element:image-candidate-string">image candidate strings</a> using a <a href="#width-descriptor" id="the-source-element:width-descriptor">width descriptor</a>, the
    <code id="the-source-element:attr-source-sizes-2"><a href="#attr-source-sizes">sizes</a></code> attribute may also be present. If, additionally,
    the following sibling <code id="the-source-element:the-img-element-3"><a href="#the-img-element">img</a></code> element does not <a href="#allows-auto-sizes" id="the-source-element:allows-auto-sizes">allow
    auto-sizes</a>, the <code id="the-source-element:attr-source-sizes-3"><a href="#attr-source-sizes">sizes</a></code> attribute must be present.
    The <dfn data-dfn-for="source" id="attr-source-sizes" data-dfn-type="element-attr"><code>sizes</code></dfn>
    attribute is a <a href="#sizes-attribute" id="the-source-element:sizes-attribute">sizes attribute</a>, which contributes the <a href="#source-size-2" id="the-source-element:source-size-2">source size</a> to
    the <a href="#source-set" id="the-source-element:source-set-3">source set</a>, if the <code id="the-source-element:the-source-element-5"><a href="#the-source-element">source</a></code> element is selected.</p>

    <p class="note">If the <code id="the-source-element:the-img-element-4"><a href="#the-img-element">img</a></code> element <a href="#allows-auto-sizes" id="the-source-element:allows-auto-sizes-2">allows auto-sizes</a>, then the <code id="the-source-element:attr-source-sizes-4"><a href="#attr-source-sizes">sizes</a></code> attribute can be omitted on previous sibling
    <code id="the-source-element:the-source-element-6"><a href="#the-source-element">source</a></code> elements. In such cases, it is equivalent to specifying <code id="the-source-element:valdef-sizes-auto"><a href="#valdef-sizes-auto">auto</a></code>.</p>

    <p>The <code id="the-source-element:the-source-element-7"><a href="#the-source-element">source</a></code> element supports <a href="#dimension-attributes" id="the-source-element:dimension-attributes">dimension attributes</a>. The
    <code id="the-source-element:the-img-element-5"><a href="#the-img-element">img</a></code> element can use the <code id="the-source-element:attr-dim-width-2"><a href="#attr-dim-width">width</a></code> and <code id="the-source-element:attr-dim-height-2"><a href="#attr-dim-height">height</a></code> attributes of a <code id="the-source-element:the-source-element-8"><a href="#the-source-element">source</a></code> element, instead of
    those on the <code id="the-source-element:the-img-element-6"><a href="#the-img-element">img</a></code> element itself, to determine its rendered dimensions and
    aspect-ratio, <a href="#dimRendering">as defined in the Rendering section</a>.</p>

    <p>The <code id="the-source-element:attr-source-type-2"><a href="#attr-source-type">type</a></code> attribute gives the type of the images in the
    <a href="#source-set" id="the-source-element:source-set-4">source set</a>, to allow the user agent to skip to the next <code id="the-source-element:the-source-element-9"><a href="#the-source-element">source</a></code> element
    if it does not support the given type.</p>

    <p class="note">If the <code id="the-source-element:attr-source-type-3"><a href="#attr-source-type">type</a></code> attribute is <em>not</em>
    specified, the user agent will not select a different <code id="the-source-element:the-source-element-10"><a href="#the-source-element">source</a></code> element if it finds
    that it does not support the image format after fetching it.</p>

    <p>When a <code id="the-source-element:the-source-element-11"><a href="#the-source-element">source</a></code> element has a following sibling <code id="the-source-element:the-source-element-12"><a href="#the-source-element">source</a></code> element or
    <code id="the-source-element:the-img-element-7"><a href="#the-img-element">img</a></code> element with a <code id="the-source-element:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code> attribute
    specified, it must have at least one of the following:</p>

    <ul><li><p>A <code id="the-source-element:attr-source-media-3"><a href="#attr-source-media">media</a></code> attribute specified with a value that,
     after <a href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" id="the-source-element:strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">stripping leading and trailing
     ASCII whitespace</a>, is not the empty string and is not an <a id="the-source-element:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
     case-insensitive</a> match for the string "<code>all</code>".</p></li><li><p>A <code id="the-source-element:attr-source-type-4"><a href="#attr-source-type">type</a></code> attribute specified.</p></li></ul>

    <p>The <code id="the-source-element:attr-source-src-2"><a href="#attr-source-src">src</a></code> attribute must not be present.</p>
   </dd><dt>The <code id="the-source-element:the-source-element-13"><a href="#the-source-element">source</a></code> element's parent is a <a href="#media-element" id="the-source-element:media-element-5">media element</a></dt><dd>
    <p>The <dfn data-dfn-for="source" id="attr-source-src" data-dfn-type="element-attr"><code>src</code></dfn> attribute
    gives the <a id="the-source-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the <a href="#media-resource" id="the-source-element:media-resource-2">media resource</a>. The value must be a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="the-source-element:valid-non-empty-url-potentially-surrounded-by-spaces">valid
    non-empty URL potentially surrounded by spaces</a>. This attribute must be present.</p>

    <p>The <code id="the-source-element:attr-source-type-5"><a href="#attr-source-type">type</a></code> attribute gives the type of the <a href="#media-resource" id="the-source-element:media-resource-3">media
    resource</a>, to help the user agent determine if it can play this <a href="#media-resource" id="the-source-element:media-resource-4">media
    resource</a> before fetching it. The <code>codecs</code> parameter, which certain
    MIME types define, might be necessary to specify exactly how the resource is encoded.
    <a href="#refsRFC6381">[RFC6381]</a></p>

    <p class="note">Dynamically modifying a <code id="the-source-element:the-source-element-14"><a href="#the-source-element">source</a></code> element's <code id="the-source-element:attr-source-src-3"><a href="#attr-source-src">src</a></code> or <code id="the-source-element:attr-source-type-6"><a href="#attr-source-type">type</a></code> attribute
    when the element is already inserted in a <code id="the-source-element:the-video-element-2"><a href="#the-video-element">video</a></code> or <code id="the-source-element:the-audio-element-2"><a href="#the-audio-element">audio</a></code> element will
    have no effect. To change what is playing, just use the <code id="the-source-element:attr-media-src"><a href="#attr-media-src">src</a></code>
    attribute on the <a href="#media-element" id="the-source-element:media-element-6">media element</a> directly, possibly making use of the <code id="the-source-element:dom-navigator-canplaytype"><a href="#dom-navigator-canplaytype">canPlayType()</a></code> method to pick from amongst available
    resources. Generally, manipulating <code id="the-source-element:the-source-element-15"><a href="#the-source-element">source</a></code> elements manually after the document has
    been parsed is an unnecessarily complicated approach.</p>

    <div class="example">

     <p>The following list shows some examples of how to use the <code>codecs=</code> MIME
     parameter in the <code id="the-source-element:attr-source-type-7"><a href="#attr-source-type">type</a></code> attribute.</p>

     <dl><dt>H.264 Constrained baseline profile video (main and extended video compatible) level 3 and Low-Complexity AAC audio in MP4 container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.mp4'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/mp4; codecs="avc1.42E01E, mp4a.40.2"'</c-><c- p="">&gt;</c-></code></pre></dd><dt>H.264 Extended profile video (baseline-compatible) level 3 and Low-Complexity AAC audio in MP4 container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.mp4'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/mp4; codecs="avc1.58A01E, mp4a.40.2"'</c-><c- p="">&gt;</c-></code></pre></dd><dt>H.264 Main profile video level 3 and Low-Complexity AAC audio in MP4 container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.mp4'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/mp4; codecs="avc1.4D401E, mp4a.40.2"'</c-><c- p="">&gt;</c-></code></pre></dd><dt>H.264 'High' profile video (incompatible with main, baseline, or extended profiles) level 3 and Low-Complexity AAC audio in MP4 container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.mp4'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/mp4; codecs="avc1.64001E, mp4a.40.2"'</c-><c- p="">&gt;</c-></code></pre></dd><dt>MPEG-4 Visual Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.mp4'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/mp4; codecs="mp4v.20.8, mp4a.40.2"'</c-><c- p="">&gt;</c-></code></pre></dd><dt>MPEG-4 Advanced Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.mp4'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/mp4; codecs="mp4v.20.240, mp4a.40.2"'</c-><c- p="">&gt;</c-></code></pre></dd><dt>MPEG-4 Visual Simple Profile Level 0 video and AMR audio in 3GPP container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.3gp'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/3gpp; codecs="mp4v.20.8, samr"'</c-><c- p="">&gt;</c-></code></pre></dd><dt>Theora video and Vorbis audio in Ogg container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.ogv'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/ogg; codecs="theora, vorbis"'</c-><c- p="">&gt;</c-></code></pre></dd><dt>Theora video and Speex audio in Ogg container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.ogv'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/ogg; codecs="theora, speex"'</c-><c- p="">&gt;</c-></code></pre></dd><dt>Vorbis audio alone in Ogg container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'audio.ogg'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'audio/ogg; codecs=vorbis'</c-><c- p="">&gt;</c-></code></pre></dd><dt>Speex audio alone in Ogg container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'audio.spx'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'audio/ogg; codecs=speex'</c-><c- p="">&gt;</c-></code></pre></dd><dt>FLAC audio alone in Ogg container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'audio.oga'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'audio/ogg; codecs=flac'</c-><c- p="">&gt;</c-></code></pre></dd><dt>Dirac video and Vorbis audio in Ogg container</dt><dd><pre><code class="html"><c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.ogv'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/ogg; codecs="dirac, vorbis"'</c-><c- p="">&gt;</c-></code></pre></dd></dl>
    </div>

    <p>The <code id="the-source-element:attr-source-srcset-4"><a href="#attr-source-srcset">srcset</a></code> and <code id="the-source-element:attr-source-sizes-5"><a href="#attr-source-sizes">sizes</a></code> attributes must not be present.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <code id="the-source-element:the-source-element-16"><a href="#the-source-element">source</a></code> <a href="#html-element-insertion-steps" id="the-source-element:html-element-insertion-steps">HTML element insertion steps</a>, given
  <var>insertedNode</var>, are:</p>

  <ol><li><p>Let <var>parent</var> be <var>insertedNode</var>'s <a id="the-source-element:parent" href="https://dom.spec.whatwg.org/#concept-tree-parent" data-x-internal="parent">parent</a>.</p></li><li><p>If <var>parent</var> is a <a href="#media-element" id="the-source-element:media-element-7">media element</a> that has no <code id="the-source-element:attr-media-src-2"><a href="#attr-media-src">src</a></code> attribute and whose <code id="the-source-element:dom-media-networkstate"><a href="#dom-media-networkstate">networkState</a></code> has the value <code id="the-source-element:dom-media-network_empty"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code>, then invoke that <a href="#media-element" id="the-source-element:media-element-8">media
   element</a>'s <a href="#concept-media-load-algorithm" id="the-source-element:concept-media-load-algorithm-2">resource selection
   algorithm</a>.</p></li><li><p>If <var>parent</var> is a <code id="the-source-element:the-picture-element-9"><a href="#the-picture-element">picture</a></code> element, then <a href="https://infra.spec.whatwg.org/#list-iterate" id="the-source-element:list-iterate" data-x-internal="list-iterate">for each</a> <var>child</var> of <var>parent</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="the-source-element:concept-tree-child" data-x-internal="concept-tree-child">children</a>, if <var>child</var> is an <code id="the-source-element:the-img-element-8"><a href="#the-img-element">img</a></code> element,
   then count this as a <a href="#relevant-mutations" id="the-source-element:relevant-mutations">relevant mutation</a> for
   <var>child</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-source-element:the-source-element-17"><a href="#the-source-element">source</a></code> <a href="#html-element-moving-steps" id="the-source-element:html-element-moving-steps">HTML element moving steps</a>, given <var>movedNode</var> and
  <var>oldParent</var>, are:</p>

  <ol><li><p>If <var>oldParent</var> is a <code id="the-source-element:the-picture-element-10"><a href="#the-picture-element">picture</a></code> element, then <a href="https://infra.spec.whatwg.org/#list-iterate" id="the-source-element:list-iterate-2" data-x-internal="list-iterate">for each</a> <var>child</var> of <var>oldParent</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="the-source-element:concept-tree-child-2" data-x-internal="concept-tree-child">children</a>, if <var>child</var> is an <code id="the-source-element:the-img-element-9"><a href="#the-img-element">img</a></code> element,
   then count this as a <a href="#relevant-mutations" id="the-source-element:relevant-mutations-2">relevant mutation</a> for
   <var>child</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-source-element:the-source-element-18"><a href="#the-source-element">source</a></code> <a href="#html-element-removing-steps" id="the-source-element:html-element-removing-steps">HTML element removing steps</a>, given <var>removedNode</var>
  and <var>oldParent</var>, are:</p>

  <ol><li><p>If <var>oldParent</var> is a <code id="the-source-element:the-picture-element-11"><a href="#the-picture-element">picture</a></code> element, then <a href="https://infra.spec.whatwg.org/#list-iterate" id="the-source-element:list-iterate-3" data-x-internal="list-iterate">for each</a> <var>child</var> of <var>oldParent</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="the-source-element:concept-tree-child-3" data-x-internal="concept-tree-child">children</a>, if <var>child</var> is an <code id="the-source-element:the-img-element-10"><a href="#the-img-element">img</a></code> element,
   then count this as a <a href="#relevant-mutations" id="the-source-element:relevant-mutations-3">relevant mutation</a> for
   <var>child</var>.</p></li></ol>
  </div>

  

  <div class="example">
   <p>If the author isn't sure if user agents will all be able to render the media resources
   provided, the author can listen to the <code id="the-source-element:event-error"><a href="#event-error">error</a></code> event on the last
   <code id="the-source-element:the-source-element-19"><a href="#the-source-element">source</a></code> element and trigger fallback behavior:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">function</c-> fallback<c- p="">(</c->video<c- p="">)</c-> <c- p="">{</c->
   <c- c1="">// replace &lt;video&gt; with its contents</c->
   <c- k="">while</c-> <c- p="">(</c->video<c- p="">.</c->hasChildNodes<c- p="">())</c-> <c- p="">{</c->
     <c- k="">if</c-> <c- p="">(</c->video<c- p="">.</c->firstChild <c- k="">instanceof</c-> HTMLSourceElement<c- p="">)</c->
       video<c- p="">.</c->removeChild<c- p="">(</c->video<c- p="">.</c->firstChild<c- p="">);</c->
     <c- k="">else</c->
       video<c- p="">.</c->parentNode<c- p="">.</c->insertBefore<c- p="">(</c->video<c- p="">.</c->firstChild<c- p="">,</c-> video<c- p="">);</c->
   <c- p="">}</c->
   video<c- p="">.</c->parentNode<c- p="">.</c->removeChild<c- p="">(</c->video<c- p="">);</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">video</c-> <c- e="">controls</c-> <c- e="">autoplay</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.mp4'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/mp4; codecs="avc1.42E01E, mp4a.40.2"'</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">'video.ogv'</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">'video/ogg; codecs="theora, vorbis"'</c->
         <c- e="">onerror</c-><c- o="">=</c-><c- s="">"fallback(parentNode)"</c-><c- p="">&gt;</c->
 ...
<c- p="">&lt;/</c-><c- f="">video</c-><c- p="">&gt;</c-></code></pre>
  </div>



  <h4 id="the-img-element"><span class="secno">4.8.3</span> The <dfn data-dfn-type="element"><code>img</code></dfn> element<a href="#the-img-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img" title="The <img> HTML element embeds an image into the document.">Element/img</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement" title="The HTMLImageElement interface represents an HTML <img> element, providing the properties and methods used to manipulate image elements.">HTMLImageElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt" title="The HTMLImageElement property alt provides fallback (alternate) text to display when the image specified by the <img> element is not loaded.">HTMLImageElement/alt</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset" title="The HTMLImageElement property srcset is a string which identifies one or more image candidate strings, separated using commas (,) each specifying image resources to use under given circumstances.">HTMLImageElement/srcset</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>34+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/sizes" title="The HTMLImageElement property sizes allows you to specify the layout width of the image for each of a list of media conditions. This provides the ability to automatically select among different images—even images of different orientations or aspect ratios—as the document state changes to match different media conditions.">HTMLImageElement/sizes</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>9.1+</span></span><span class="chrome yes"><span>Chrome</span><span>38+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/useMap" title="The useMap property on the HTMLImageElement interface reflects the value of the HTML usemap attribute, which is a string providing the name of the client-side image map to apply to the image.">HTMLImageElement/useMap</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/isMap" title="The HTMLImageElement property isMap is a Boolean value which indicates that the image is to be used by a server-side image map. This may only be used on images located within an <a> element.">HTMLImageElement/isMap</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-img-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-img-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-img-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#embedded-content-category" id="the-img-element:embedded-content-category">Embedded content</a>.</dd><dd><a href="#form-associated-element" id="the-img-element:form-associated-element">Form-associated element</a>.</dd><dd>If the element has a <code id="the-img-element:attr-hyperlink-usemap"><a href="#attr-hyperlink-usemap">usemap</a></code> attribute: <a href="#interactive-content-2" id="the-img-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#palpable-content-2" id="the-img-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-img-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#embedded-content-category" id="the-img-element:embedded-content-category-2">embedded content</a> is expected.</dd><dd>As a child of a <code id="the-img-element:the-picture-element"><a href="#the-picture-element">picture</a></code> element, after all <code id="the-img-element:the-source-element"><a href="#the-source-element">source</a></code> elements.</dd><dt><a href="#concept-element-content-model" id="the-img-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-img-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-img-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-img-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-img-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-img-element:global-attributes">Global attributes</a></dd><dd><code id="the-img-element:attr-img-alt"><a href="#attr-img-alt">alt</a></code> —  Replacement text for use when images are not available
     </dd><dd><code id="the-img-element:attr-img-src"><a href="#attr-img-src">src</a></code> —  Address of the resource
     </dd><dd><code id="the-img-element:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code> —  Images to use in different situations, e.g., high-resolution displays, small monitors, etc.
     </dd><dd><code id="the-img-element:attr-img-sizes"><a href="#attr-img-sizes">sizes</a></code> —  Image sizes for different page layouts
     </dd><dd><code id="the-img-element:attr-img-crossorigin"><a href="#attr-img-crossorigin">crossorigin</a></code> —  How the element handles crossorigin requests
     </dd><dd><code id="the-img-element:attr-hyperlink-usemap-2"><a href="#attr-hyperlink-usemap">usemap</a></code> —  Name of <a href="#image-map" id="the-img-element:image-map">image map</a> to use
     </dd><dd><code id="the-img-element:attr-img-ismap"><a href="#attr-img-ismap">ismap</a></code> —  Whether the image is a server-side image map
     </dd><dd><code id="the-img-element:attr-dim-width"><a href="#attr-dim-width">width</a></code> —  Horizontal dimension
     </dd><dd><code id="the-img-element:attr-dim-height"><a href="#attr-dim-height">height</a></code> —  Vertical dimension
     </dd><dd><code id="the-img-element:attr-img-referrerpolicy"><a href="#attr-img-referrerpolicy">referrerpolicy</a></code> —  <a id="the-img-element:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">Referrer policy</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-img-element:concept-fetch" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </dd><dd><code id="the-img-element:attr-img-decoding"><a href="#attr-img-decoding">decoding</a></code> —  Decoding hint to use when processing this image for presentation
     </dd><dd><code id="the-img-element:attr-img-loading"><a href="#attr-img-loading">loading</a></code> —  Used when determining loading deferral
     </dd><dd><code id="the-img-element:attr-img-fetchpriority"><a href="#attr-img-fetchpriority">fetchpriority</a></code> —  Sets the <a href="https://fetch.spec.whatwg.org/#request-priority" id="the-img-element:concept-request-priority" data-x-internal="concept-request-priority">priority</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-img-element:concept-fetch-2" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-img-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd>If the element has a non-empty <code id="the-img-element:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code> attribute: <a href="https://w3c.github.io/html-aria/#el-img">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-img">for implementers</a>.</dd><dd>Otherwise: <a href="https://w3c.github.io/html-aria/#el-img-empty-alt">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-img-empty-alt">for implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-img-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="the-img-element:legacyfactoryfunction" href="https://webidl.spec.whatwg.org/#LegacyFactoryFunction" data-x-internal="legacyfactoryfunction"><c- g="">LegacyFactoryFunction</c-></a>=<a href="#dom-image" id="the-img-element:dom-image"><c- n="">Image</c-></a>(<c- b="">optional</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">width</c->, <c- b="">optional</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">height</c->)]
<c- b="">interface</c-> <dfn id="htmlimageelement" data-dfn-type="interface"><c- g="">HTMLImageElement</c-></dfn> : <a href="#htmlelement" id="the-img-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-img-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-img-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-img-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-alt" data-dfn-type="attribute"><c- g="">alt</c-></dfn>;
  [<a href="#cereactions" id="the-img-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-img-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-src" data-dfn-type="attribute"><c- g="">src</c-></dfn>;
  [<a href="#cereactions" id="the-img-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-img-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-srcset" data-dfn-type="attribute"><c- g="">srcset</c-></dfn>;
  [<a href="#cereactions" id="the-img-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-img-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-sizes" data-dfn-type="attribute"><c- g="">sizes</c-></dfn>;
  [<a href="#cereactions" id="the-img-element:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-img-crossorigin" id="the-img-element:dom-img-crossorigin"><c- g="">crossOrigin</c-></a>;
  [<a href="#cereactions" id="the-img-element:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-img-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-usemap" data-dfn-type="attribute"><c- g="">useMap</c-></dfn>;
  [<a href="#cereactions" id="the-img-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-img-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-ismap" data-dfn-type="attribute"><c- g="">isMap</c-></dfn>;
  [<a href="#cereactions" id="the-img-element:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-img-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-img-width" id="the-img-element:dom-img-width"><c- g="">width</c-></a>;
  [<a href="#cereactions" id="the-img-element:cereactions-9"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-img-element:xattr-reflectsetter-2"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-img-height" id="the-img-element:dom-img-height"><c- g="">height</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-img-naturalwidth" id="the-img-element:dom-img-naturalwidth"><c- g="">naturalWidth</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-img-naturalheight" id="the-img-element:dom-img-naturalheight"><c- g="">naturalHeight</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-img-complete" id="the-img-element:dom-img-complete"><c- g="">complete</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-img-currentsrc" id="the-img-element:dom-img-currentsrc"><c- g="">currentSrc</c-></a>;
  [<a href="#cereactions" id="the-img-element:cereactions-10"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-img-referrerpolicy" id="the-img-element:dom-img-referrerpolicy"><c- g="">referrerPolicy</c-></a>;
  [<a href="#cereactions" id="the-img-element:cereactions-11"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-img-decoding" id="the-img-element:dom-img-decoding"><c- g="">decoding</c-></a>;
  [<a href="#cereactions" id="the-img-element:cereactions-12"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-img-loading" id="the-img-element:dom-img-loading"><c- g="">loading</c-></a>;
  [<a href="#cereactions" id="the-img-element:cereactions-13"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-img-fetchpriority" id="the-img-element:dom-img-fetchpriority"><c- g="">fetchPriority</c-></a>;

  <a href="https://webidl.spec.whatwg.org/#idl-promise" id="the-img-element:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<c- b="">undefined</c->&gt; <a href="#dom-img-decode" id="the-img-element:dom-img-decode"><c- g="">decode</c-></a>();

  // <a href="#HTMLImageElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>An <code id="the-img-element:the-img-element"><a href="#the-img-element">img</a></code> element represents an image.</p>

  <p>An <code id="the-img-element:the-img-element-2"><a href="#the-img-element">img</a></code> element has a <dfn id="concept-img-dimension-attribute-source">dimension
  attribute source</dfn>, initially set to the element itself.</p>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/src" title="The HTMLImageElement property src, which reflects the HTML src attribute, specifies the image to display in the <img> element.">HTMLImageElement/src</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-srcset" title="The <img> HTML element embeds an image into the document.">Element/img#attr-srcset</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>34+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>≤18+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The image given by the <dfn data-dfn-for="img" id="attr-img-src" data-dfn-type="element-attr"><code>src</code></dfn>
  and <dfn data-dfn-for="img" id="attr-img-srcset" data-dfn-type="element-attr"><code>srcset</code></dfn> attributes, and
  any previous sibling <code id="the-img-element:the-source-element-2"><a href="#the-source-element">source</a></code> elements' <code id="the-img-element:attr-source-srcset"><a href="#attr-source-srcset">srcset</a></code>
  attributes if the parent is a <code id="the-img-element:the-picture-element-2"><a href="#the-picture-element">picture</a></code> element, is the embedded content; the value of
  the <dfn data-dfn-for="img" id="attr-img-alt" data-dfn-type="element-attr"><code>alt</code></dfn> attribute provides
  equivalent content for those who cannot process images or who have image loading disabled (i.e.,
  it is the <code id="the-img-element:the-img-element-3"><a href="#the-img-element">img</a></code> element's <a href="#fallback-content" id="the-img-element:fallback-content">fallback content</a>).</p>

  <p>The requirements on the <code id="the-img-element:attr-img-alt-3"><a href="#attr-img-alt">alt</a></code> attribute's value are described
  <a href="#alt">in a separate section</a>.</p>

  <p>At least one of the <code id="the-img-element:attr-img-src-2"><a href="#attr-img-src">src</a></code> and <code id="the-img-element:attr-img-srcset-2"><a href="#attr-img-srcset">srcset</a></code> attributes must be present.</p>

  <p>If the <code id="the-img-element:attr-img-src-3"><a href="#attr-img-src">src</a></code> attribute is present, it must contain a
  <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="the-img-element:valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by spaces</a> referencing a non-interactive,
  optionally animated, image resource that is neither paged nor scripted.</p>

  <p class="note">The requirements above imply that images can be static bitmaps (e.g. PNGs, GIFs,
  JPEGs), single-page vector documents (single-page PDFs, XML files with an SVG document element),
  animated bitmaps (APNGs, animated GIFs), animated vector graphics (XML files with an SVG
  <a id="the-img-element:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> that use declarative SMIL animation), and so forth. However, these
  definitions preclude SVG files with script, multipage PDF files, interactive MNG files, HTML
  documents, plain text documents, and the like. <a href="#refsPNG">[PNG]</a> <a href="#refsGIF">[GIF]</a> <a href="#refsJPEG">[JPEG]</a>
  <a href="#refsPDF">[PDF]</a> <a href="#refsXML">[XML]</a> <a href="#refsAPNG">[APNG]</a> <a href="#refsSVG">[SVG]</a> <a href="#refsMNG">[MNG]</a></p>

  <p>The <code id="the-img-element:attr-img-srcset-3"><a href="#attr-img-srcset">srcset</a></code> attribute is a <a href="#srcset-attribute" id="the-img-element:srcset-attribute">srcset
  attribute</a>.</p>

  <p>The <code id="the-img-element:attr-img-srcset-4"><a href="#attr-img-srcset">srcset</a></code> attribute and the <code id="the-img-element:attr-img-src-4"><a href="#attr-img-src">src</a></code> attribute (if <a href="#width-descriptor" id="the-img-element:width-descriptor">width
  descriptors</a> are not used) contribute the <a href="#image-source" id="the-img-element:image-source">image sources</a>
  to the <a href="#source-set" id="the-img-element:source-set">source set</a> (if no <code id="the-img-element:the-source-element-3"><a href="#the-source-element">source</a></code> element was selected).</p>

  <p>If the <code id="the-img-element:attr-img-srcset-5"><a href="#attr-img-srcset">srcset</a></code> attribute is present and has any <a href="#image-candidate-string" id="the-img-element:image-candidate-string">image candidate strings</a> using a <a href="#width-descriptor" id="the-img-element:width-descriptor-2">width
  descriptor</a>, the <code id="the-img-element:attr-img-sizes-2"><a href="#attr-img-sizes">sizes</a></code> attribute must also be present.
  If the <code id="the-img-element:attr-img-srcset-6"><a href="#attr-img-srcset">srcset</a></code> attribute is <em>not</em> specified, and the
  <code id="the-img-element:attr-img-loading-2"><a href="#attr-img-loading">loading</a></code> attribute is in the <a href="#attr-loading-lazy-state" id="the-img-element:attr-loading-lazy-state">Lazy</a> state, the <code id="the-img-element:attr-img-sizes-3"><a href="#attr-img-sizes">sizes</a></code> attribute may be specified with the value "<code>auto</code>" (<a id="the-img-element:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>). The <dfn data-dfn-for="img" id="attr-img-sizes" data-dfn-type="element-attr"><code>sizes</code></dfn> attribute is a <a href="#sizes-attribute" id="the-img-element:sizes-attribute">sizes attribute</a>,
  which contributes the <a href="#source-size-2" id="the-img-element:source-size-2">source size</a> to the <a href="#source-set" id="the-img-element:source-set-2">source set</a> (if no
  <code id="the-img-element:the-source-element-4"><a href="#the-source-element">source</a></code> element was selected).</p>

  <div data-algorithm="">
  <p>An <code id="the-img-element:the-img-element-4"><a href="#the-img-element">img</a></code> element <dfn id="allows-auto-sizes">allows auto-sizes</dfn> if:</p>

  <ul><li>its <code id="the-img-element:attr-img-loading-3"><a href="#attr-img-loading">loading</a></code> attribute is in the <a href="#attr-loading-lazy-state" id="the-img-element:attr-loading-lazy-state-2">Lazy</a> state, and</li><li>its <code id="the-img-element:attr-img-sizes-4"><a href="#attr-img-sizes">sizes</a></code> attribute's value is "<code>auto</code>" (<a id="the-img-element:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>), or starts with "<code>auto,</code>" (<a id="the-img-element:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>).</li></ul>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin" title="The crossorigin attribute, valid on the <audio>, <img>, <link>, <script>, and <video> elements, provides support for CORS, defining how the element handles cross-origin requests, thereby enabling the configuration of the CORS requests for the element's fetched data. Depending on the element, the attribute can be a CORS settings attribute.">Attributes/crossorigin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>8+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>13+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="img" id="attr-img-crossorigin" data-dfn-type="element-attr"><code>crossorigin</code></dfn>
  attribute is a <a href="#cors-settings-attribute" id="the-img-element:cors-settings-attribute">CORS settings attribute</a>. Its purpose is to allow images from
  third-party sites that allow cross-origin access to be used with <code id="the-img-element:the-canvas-element"><a href="#the-canvas-element">canvas</a></code>.</p>

  <p>The <dfn data-dfn-for="img" id="attr-img-referrerpolicy" data-dfn-type="element-attr"><code>referrerpolicy</code></dfn> attribute is a <a href="#referrer-policy-attribute" id="the-img-element:referrer-policy-attribute">referrer
  policy attribute</a>. Its purpose is to set the <a id="the-img-element:referrer-policy-2" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a> used when <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-img-element:concept-fetch-3" data-x-internal="concept-fetch">fetching</a> the image. <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p>

  <p>The <dfn data-dfn-for="img" id="attr-img-decoding" data-dfn-type="element-attr"><code>decoding</code></dfn>
  attribute indicates the preferred method to <a href="#img-decoding-process" id="the-img-element:img-decoding-process">decode</a> this
  image. The attribute, if present, must be an <a href="#image-decoding-hint" id="the-img-element:image-decoding-hint">image decoding hint</a>. This attribute's <i id="the-img-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-img-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#attr-img-decoding-auto-state" id="the-img-element:attr-img-decoding-auto-state">Auto</a> state.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/fetchPriority" title="The fetchPriority property of the HTMLImageElement interface represents a hint given to the browser on how it should prioritize the fetch of the image relative to other images.">HTMLImageElement/fetchPriority</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span title="Requires setting a user preference or runtime flag.">🔰 preview+</span></span><span class="chrome yes"><span>Chrome</span><span>102+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>102+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="img" id="attr-img-fetchpriority" data-dfn-type="element-attr"><code>fetchpriority</code></dfn> attribute is a <a href="#fetch-priority-attribute" id="the-img-element:fetch-priority-attribute">fetch
  priority attribute</a>. Its purpose is to set the <a href="https://fetch.spec.whatwg.org/#request-priority" id="the-img-element:concept-request-priority-2" data-x-internal="concept-request-priority">priority</a> used when <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-img-element:concept-fetch-4" data-x-internal="concept-fetch">fetching</a> the image.</p>

  <p>The <dfn data-dfn-for="img" id="attr-img-loading" data-dfn-type="element-attr"><code>loading</code></dfn> attribute is a <a href="#lazy-loading-attribute" id="the-img-element:lazy-loading-attribute">lazy
  loading attribute</a>. Its purpose is to indicate the policy for loading images that are
  outside the viewport.</p>

  <div data-algorithm="">
  <p>When the <code id="the-img-element:attr-img-loading-4"><a href="#attr-img-loading">loading</a></code> attribute's state is changed to the
  <a href="#attr-loading-eager-state" id="the-img-element:attr-loading-eager-state">Eager</a> state, the user agent must run these
  steps:</p>

  <ol><li><p>Let <var>resumptionSteps</var> be the <code id="the-img-element:the-img-element-5"><a href="#the-img-element">img</a></code> element's <a href="#lazy-load-resumption-steps" id="the-img-element:lazy-load-resumption-steps">lazy load
   resumption steps</a>.</p></li><li><p>If <var>resumptionSteps</var> is null, then return.</p></li><li><p>Set the <code id="the-img-element:the-img-element-6"><a href="#the-img-element">img</a></code>'s <a href="#lazy-load-resumption-steps" id="the-img-element:lazy-load-resumption-steps-2">lazy load resumption steps</a> to null.</p></li><li><p>Invoke <var>resumptionSteps</var>.</p></li></ol>
  </div>

  <div class="example">
<pre><code class="html"><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"1.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"1"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"2.jpeg"</c-> <c- e="">loading</c-><c- o="">=</c-><c- s="">eager</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"2"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"3.jpeg"</c-> <c- e="">loading</c-><c- o="">=</c-><c- s="">lazy</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"3"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">very-large</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- Everything after this div is below the viewport --&gt;</c->
<c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"4.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"4"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"5.jpeg"</c-> <c- e="">loading</c-><c- o="">=</c-><c- s="">lazy</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"5"</c-><c- p="">&gt;</c-></code></pre>

   <p>In the example above, the images load as follows:</p>

   <dl class="switch"><dt><code>1.jpeg</code>, <code>2.jpeg</code>,
    <code>4.jpeg</code></dt><dd><p>The images load eagerly and delay the window's load event.</p></dd><dt><code>3.jpeg</code></dt><dd><p>The image loads when layout is known, due to being in the viewport, however it does not
    delay the window's load event.</p></dd><dt><code>5.jpeg</code></dt><dd><p>The image loads only once scrolled into the viewport, and does not delay the window's
    load event.</p></dd></dl>

   <p class="note">Developers are encouraged to specify a preferred aspect ratio via <code id="the-img-element:attr-dim-width-2"><a href="#attr-dim-width">width</a></code> and <code id="the-img-element:attr-dim-height-2"><a href="#attr-dim-height">height</a></code> attributes
   on lazy loaded images, even if CSS sets the image's width and height properties, to prevent the
   page layout from shifting around after the image loads.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-img-element:the-img-element-7"><a href="#the-img-element">img</a></code> <a href="#html-element-insertion-steps" id="the-img-element:html-element-insertion-steps">HTML element insertion steps</a>, given <var>insertedNode</var>,
  are:</p>

  <ol><li><p>If <var>insertedNode</var>'s parent is a <code id="the-img-element:the-picture-element-3"><a href="#the-picture-element">picture</a></code> element, then, count this as
   a <a href="#relevant-mutations" id="the-img-element:relevant-mutations">relevant mutation</a> for
   <var>insertedNode</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-img-element:the-img-element-8"><a href="#the-img-element">img</a></code> <a href="#html-element-moving-steps" id="the-img-element:html-element-moving-steps">HTML element moving steps</a>, given <var>movedNode</var> and
  <var>oldParent</var>, are:</p>

  <ol><li><p>If <var>oldParent</var> is a <code id="the-img-element:the-picture-element-4"><a href="#the-picture-element">picture</a></code> element, then, count this as a <a href="#relevant-mutations" id="the-img-element:relevant-mutations-2">relevant mutation</a> for <var>movedNode</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-img-element:the-img-element-9"><a href="#the-img-element">img</a></code> <a href="#html-element-removing-steps" id="the-img-element:html-element-removing-steps">HTML element removing steps</a>, given <var>removedNode</var> and
  <var>oldParent</var>, are:</p>

  <ol><li><p>If <var>oldParent</var> is a <code id="the-img-element:the-picture-element-5"><a href="#the-picture-element">picture</a></code> element, then, count this as a
   <a href="#relevant-mutations" id="the-img-element:relevant-mutations-3">relevant mutation</a> for <var>removedNode</var>.</p></li></ol>
  </div>

  <hr>

  <p>The <code id="the-img-element:the-img-element-10"><a href="#the-img-element">img</a></code> element must not be used as a layout tool. In particular, <code id="the-img-element:the-img-element-11"><a href="#the-img-element">img</a></code>
  elements should not be used to display transparent images, as such images rarely convey meaning and
  rarely add anything useful to the document.</p>

  

  <hr>

  <div data-algorithm="">
  <p>What an <code id="the-img-element:the-img-element-12"><a href="#the-img-element">img</a></code> element represents depends on the <code id="the-img-element:attr-img-src-5"><a href="#attr-img-src">src</a></code> attribute and the <code id="the-img-element:attr-img-alt-4"><a href="#attr-img-alt">alt</a></code>
  attribute.</p>

  <dl class="switch"><dt>If the <code id="the-img-element:attr-img-src-6"><a href="#attr-img-src">src</a></code> attribute is set and the <code id="the-img-element:attr-img-alt-5"><a href="#attr-img-alt">alt</a></code> attribute is set to the empty string</dt><dd>
    <p>The image is either decorative or supplemental to the rest of the content, redundant with
    some other information in the document.</p>

    <p>If the image is <a href="#img-available" id="the-img-element:img-available">available</a> and the user agent is configured
    to display that image, then the element <a href="#represents" id="the-img-element:represents">represents</a> the element's image data.</p>

    <p>Otherwise, the element <a href="#represents" id="the-img-element:represents-2">represents</a> nothing, and may be omitted completely from
    the rendering. User agents may provide the user with a notification that an image is present but
    has been omitted from the rendering.</p>
   </dd><dt>If the <code id="the-img-element:attr-img-src-7"><a href="#attr-img-src">src</a></code> attribute is set and the <code id="the-img-element:attr-img-alt-6"><a href="#attr-img-alt">alt</a></code> attribute is set to a value that isn't empty</dt><dd>
    <p>The image is a key part of the content; the <code id="the-img-element:attr-img-alt-7"><a href="#attr-img-alt">alt</a></code> attribute
    gives a textual equivalent or replacement for the image.</p>

    <p>If the image is <a href="#img-available" id="the-img-element:img-available-2">available</a> and the user agent is configured
    to display that image, then the element <a href="#represents" id="the-img-element:represents-3">represents</a> the element's image data.</p>

    <p>Otherwise, the element <a href="#represents" id="the-img-element:represents-4">represents</a> the text given by the <code id="the-img-element:attr-img-alt-8"><a href="#attr-img-alt">alt</a></code> attribute. User agents may provide the user with a notification
    that an image is present but has been omitted from the rendering.</p>
   </dd><dt>If the <code id="the-img-element:attr-img-src-8"><a href="#attr-img-src">src</a></code> attribute is set and the <code id="the-img-element:attr-img-alt-9"><a href="#attr-img-alt">alt</a></code> attribute is not</dt><dd>
    <p>The image might be a key part of the content, and there is no textual equivalent of the image
    available.</p>

    <p class="note">In a conforming document, the absence of the <code id="the-img-element:attr-img-alt-10"><a href="#attr-img-alt">alt</a></code> attribute indicates that the image is a key part of the content
    but that a textual replacement for the image was not available when the image was generated.</p>

    <p>If the image is <a href="#img-available" id="the-img-element:img-available-3">available</a> and the user agent is configured
    to display that image, then the element <a href="#represents" id="the-img-element:represents-5">represents</a> the element's image data.</p>

    <p>If the image has a <code id="the-img-element:attr-img-src-9"><a href="#attr-img-src">src</a></code> attribute whose value is
    the empty string, then the element <a href="#represents" id="the-img-element:represents-6">represents</a> nothing.</p>

    <p>Otherwise, the user agent should display some sort of indicator that there is an image that
    is not being rendered, and may, if requested by the user, or if so configured, or when required
    to provide contextual information in response to navigation, provide caption information for the
    image, derived as follows:</p>

    <ol><li><p>If the image has a <code id="the-img-element:attr-title"><a href="#attr-title">title</a></code> attribute whose value is not
     the empty string, then return the value of that attribute.</p></li><li><p>If the image is a descendant of a <code id="the-img-element:the-figure-element"><a href="#the-figure-element">figure</a></code> element that has a child
     <code id="the-img-element:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code> element, and, ignoring the <code id="the-img-element:the-figcaption-element-2"><a href="#the-figcaption-element">figcaption</a></code> element and its
     descendants, the <code id="the-img-element:the-figure-element-2"><a href="#the-figure-element">figure</a></code> element has no <a href="#flow-content-2" id="the-img-element:flow-content-2-2">flow content</a> descendants other
     than <a href="#inter-element-whitespace" id="the-img-element:inter-element-whitespace">inter-element whitespace</a> and the <code id="the-img-element:the-img-element-13"><a href="#the-img-element">img</a></code> element, then return the
     contents of the first such <code id="the-img-element:the-figcaption-element-3"><a href="#the-figcaption-element">figcaption</a></code> element.</p></li><li><p>Return nothing. (There is no caption information.)</p></li></ol>
   </dd><dt>If the <code id="the-img-element:attr-img-src-10"><a href="#attr-img-src">src</a></code> attribute is not set and either the <code id="the-img-element:attr-img-alt-11"><a href="#attr-img-alt">alt</a></code> attribute is set to the empty string or the <code id="the-img-element:attr-img-alt-12"><a href="#attr-img-alt">alt</a></code> attribute is not set at all</dt><dd>
    <p>The element <a href="#represents" id="the-img-element:represents-7">represents</a> nothing.</p>
   </dd><dt>Otherwise</dt><dd>
    <p>The element <a href="#represents" id="the-img-element:represents-8">represents</a> the text given by the <code id="the-img-element:attr-img-alt-13"><a href="#attr-img-alt">alt</a></code> attribute.</p>
   </dd></dl>
  </div>

  <p>The <code id="the-img-element:attr-img-alt-14"><a href="#attr-img-alt">alt</a></code> attribute does not represent advisory information.
  User agents must not present the contents of the <code id="the-img-element:attr-img-alt-15"><a href="#attr-img-alt">alt</a></code> attribute
  in the same way as content of the <code id="the-img-element:attr-title-2"><a href="#attr-title">title</a></code> attribute.</p>

  <p>User agents may always provide the user with the option to display any image, or to prevent any
  image from being displayed. User agents may also apply heuristics to help the user make use of the
  image when the user is unable to see it, e.g. due to a visual disability or because they are using
  a text terminal with no graphics capabilities. Such heuristics could include, for instance,
  optical character recognition (OCR) of text found within the image.</p>

  <p class="warning">While user agents are encouraged to repair cases of missing <code id="the-img-element:attr-img-alt-16"><a href="#attr-img-alt">alt</a></code> attributes, authors must not rely on such behavior. <a href="#alt">Requirements for providing text to act as an alternative for images</a> are described
  in detail below.</p>

  <p>The <em>contents</em> of <code id="the-img-element:the-img-element-14"><a href="#the-img-element">img</a></code> elements, if any, are ignored for the purposes of
  rendering.</p>

  

  <hr>

  <p>The <code id="the-img-element:attr-hyperlink-usemap-3"><a href="#attr-hyperlink-usemap">usemap</a></code> attribute,
  if present, can indicate that the image has an associated
  <a href="#image-map" id="the-img-element:image-map-2">image map</a>.</p>

  <p>The <dfn data-dfn-for="img" id="attr-img-ismap" data-dfn-type="element-attr"><code>ismap</code></dfn> attribute,
  when used on an element that is a descendant of an <code id="the-img-element:the-a-element"><a href="#the-a-element">a</a></code> element with an <code id="the-img-element:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute, indicates by its presence that the element
  provides access to a server-side image map. This affects how events are handled on the
  corresponding <code id="the-img-element:the-a-element-2"><a href="#the-a-element">a</a></code> element.</p>

  <p>The <code id="the-img-element:attr-img-ismap-2"><a href="#attr-img-ismap">ismap</a></code> attribute is a
  <a href="#boolean-attribute" id="the-img-element:boolean-attribute">boolean attribute</a>. The attribute must not be specified
  on an element that does not have an ancestor <code id="the-img-element:the-a-element-3"><a href="#the-a-element">a</a></code> element
  with an <code id="the-img-element:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> attribute.</p>

  <p class="note">The <code id="the-img-element:attr-hyperlink-usemap-4"><a href="#attr-hyperlink-usemap">usemap</a></code> and <code id="the-img-element:attr-img-ismap-3"><a href="#attr-img-ismap">ismap</a></code> attributes can result in confusing behavior when used
  together with <code id="the-img-element:the-source-element-5"><a href="#the-source-element">source</a></code> elements with the <code id="the-img-element:attr-source-media"><a href="#attr-source-media">media</a></code>
  attribute specified in a <code id="the-img-element:the-picture-element-6"><a href="#the-picture-element">picture</a></code> element.</p>

  <p>The <code id="the-img-element:the-img-element-15"><a href="#the-img-element">img</a></code> element supports <a href="#dimension-attributes" id="the-img-element:dimension-attributes">dimension
  attributes</a>.</p>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/crossOrigin" title="The HTMLImageElement interface's crossOrigin attribute is a string which specifies the Cross-Origin Resource Sharing (CORS) setting to use when retrieving the image.">HTMLImageElement/crossOrigin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>8+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>13+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLImageElement" id="dom-img-crossorigin" data-dfn-type="attribute"><code>crossOrigin</code></dfn> IDL attribute must
  <a href="#reflect" id="the-img-element:reflect">reflect</a> the <code id="the-img-element:attr-img-crossorigin-2"><a href="#attr-img-crossorigin">crossorigin</a></code> content attribute,
  <a href="#limited-to-only-known-values" id="the-img-element:limited-to-only-known-values">limited to only known values</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/referrerPolicy" title="The HTMLImageElement.referrerPolicy property reflects the HTML referrerpolicy attribute of the <img> element defining which referrer is sent when fetching the resource.">HTMLImageElement/referrerPolicy</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>14+</span></span><span class="chrome yes"><span>Chrome</span><span>52+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLImageElement" id="dom-img-referrerpolicy" data-dfn-type="attribute"><code>referrerPolicy</code></dfn> IDL attribute must
  <a href="#reflect" id="the-img-element:reflect-2">reflect</a> the <code id="the-img-element:attr-img-referrerpolicy-2"><a href="#attr-img-referrerpolicy">referrerpolicy</a></code> content
  attribute, <a href="#limited-to-only-known-values" id="the-img-element:limited-to-only-known-values-2">limited to only known values</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decoding" title="The decoding property of the HTMLImageElement interface represents a hint given to the browser on how it should decode the image.">HTMLImageElement/decoding</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>65+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SVGImageElement/decoding" title="The decoding property of the SVGImageElement interface represents a hint given to the browser on how it should decode the image.">SVGImageElement/decoding</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>65+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLImageElement" id="dom-img-decoding" data-dfn-type="attribute"><code>decoding</code></dfn>
  IDL attribute must <a href="#reflect" id="the-img-element:reflect-3">reflect</a> the <code id="the-img-element:attr-img-decoding-2"><a href="#attr-img-decoding">decoding</a></code>
  content attribute, <a href="#limited-to-only-known-values" id="the-img-element:limited-to-only-known-values-3">limited to only known values</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/loading" title="The HTMLImageElement property loading is a string whose value provides a hint to the user agent on how to handle the loading of the image which is currently outside the window's visual viewport.">HTMLImageElement/loading</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>75+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLImageElement" id="dom-img-loading" data-dfn-type="attribute"><code>loading</code></dfn>
  IDL attribute must <a href="#reflect" id="the-img-element:reflect-4">reflect</a> the <code id="the-img-element:attr-img-loading-5"><a href="#attr-img-loading">loading</a></code> content
  attribute, <a href="#limited-to-only-known-values" id="the-img-element:limited-to-only-known-values-4">limited to only known values</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLImageElement" id="dom-img-fetchpriority" data-dfn-type="attribute"><code>fetchPriority</code></dfn> IDL attribute
  must <a href="#reflect" id="the-img-element:reflect-5">reflect</a> the <code id="the-img-element:attr-img-fetchpriority-2"><a href="#attr-img-fetchpriority">fetchpriority</a></code> content
  attribute, <a href="#limited-to-only-known-values" id="the-img-element:limited-to-only-known-values-5">limited to only known values</a>.</p>
  </div>

  

  <dl class="domintro"><dt><code><var>image</var>.<a href="#dom-img-width" id="dom-img-width-dev">width</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width" title="The width property of the HTMLImageElement interface indicates the width at which an image is drawn in CSS pixels if it's being drawn or rendered to any visual medium such as a screen or printer. Otherwise, it's the natural, pixel density-corrected width of the image.">HTMLImageElement/width</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>image</var>.<a href="#dom-img-height" id="dom-img-height-dev">height</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height" title="The height property of the HTMLImageElement interface indicates the height at which the image is drawn, in CSS pixels if the image is being drawn or rendered to any visual medium such as the screen or a printer; otherwise, it's the natural, pixel density corrected height of the image.">HTMLImageElement/height</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>These attributes return the actual rendered dimensions of the image, or 0 if the dimensions
    are not known.</p>

    <p>They can be set, to change the corresponding content attributes.</p>
   </dd><dt><code><var>image</var>.<a href="#dom-img-naturalwidth" id="dom-img-naturalwidth-dev">naturalWidth</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/naturalWidth" title="The HTMLImageElement interface's read-only naturalWidth property returns the intrinsic (natural), density-corrected width of the image in CSS pixels.">HTMLImageElement/naturalWidth</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>image</var>.<a href="#dom-img-naturalheight" id="dom-img-naturalheight-dev">naturalHeight</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/naturalHeight" title="The HTMLImageElement interface's naturalHeight property is a read-only value which returns the intrinsic (natural), density-corrected height of the image in CSS pixels.">HTMLImageElement/naturalHeight</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>These attributes return the natural dimensions of the image, or 0 if the dimensions are not
    known.</p>
   </dd><dt><code><var>image</var>.<a href="#dom-img-complete" id="dom-img-complete-dev">complete</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/complete" title="The read-only HTMLImageElement interface's complete attribute is a Boolean value which indicates whether or not the image has completely loaded.">HTMLImageElement/complete</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns true if the image has been completely downloaded or if no image is specified;
    otherwise, returns false.</p>
   </dd><dt><code><var>image</var>.<a href="#dom-img-currentsrc" id="dom-img-currentsrc-dev">currentSrc</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/currentSrc" title="The read-only HTMLImageElement property currentSrc indicates the URL of the image which is currently presented in the <img> element it represents.">HTMLImageElement/currentSrc</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>9.1+</span></span><span class="chrome yes"><span>Chrome</span><span>38+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the image's <a id="the-img-element:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a>.</p></dd><dt><code><var>image</var>.<a href="#dom-img-decode" id="dom-img-decode-dev">decode</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode" title="The decode() method of the HTMLImageElement interface returns a Promise that resolves when the image is decoded and it is safe to append the image to the DOM.">HTMLImageElement/decode</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SVGImageElement/decode" title="The decode() method of the SVGImageElement interface initiates asynchronous decoding of an image, returning a Promise that resolves once the image data is ready for use.">SVGImageElement/decode</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>This method causes the user agent to <a href="#img-decoding-process" id="the-img-element:img-decoding-process-2">decode</a> the
    image <a href="#in-parallel" id="the-img-element:in-parallel">in parallel</a>, returning a promise that fulfills when decoding is complete.</p>

    <p>The promise will be rejected with an <a id="the-img-element:encodingerror" href="https://webidl.spec.whatwg.org/#encodingerror" data-x-internal="encodingerror">"<code>EncodingError</code>"</a>
    <code id="the-img-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the image cannot be decoded.</p>
   </dd><dt><code><var>image</var> = new <a href="#dom-image" id="dom-image-dev">Image</a>([ <var>width</var> [, <var>height</var> ] ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image" title="The Image() constructor creates a new HTMLImageElement instance. It is functionally equivalent to document.createElement('img').">HTMLImageElement/Image</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns a new <code id="the-img-element:the-img-element-16"><a href="#the-img-element">img</a></code> element, with the <code id="the-img-element:attr-dim-width-3"><a href="#attr-dim-width">width</a></code>
    and <code id="the-img-element:attr-dim-height-3"><a href="#attr-dim-height">height</a></code> attributes set to the values passed in the
    relevant arguments, if applicable.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The IDL attributes <dfn data-dfn-for="HTMLImageElement" id="dom-img-width" data-dfn-type="attribute"><code>width</code></dfn> and <dfn data-dfn-for="HTMLImageElement" id="dom-img-height" data-dfn-type="attribute"><code>height</code></dfn> must return the rendered width and height of the
  image, in <a href="https://drafts.csswg.org/css-values/#px" id="the-img-element:'px'" data-x-internal="'px'">CSS pixels</a>, if the image is <a href="#being-rendered" id="the-img-element:being-rendered">being rendered</a>; or
  else the <a href="#density-corrected-intrinsic-width-and-height" id="the-img-element:density-corrected-intrinsic-width-and-height">density-corrected natural width and height</a> of the image, in <a href="https://drafts.csswg.org/css-values/#px" id="the-img-element:'px'-2" data-x-internal="'px'">CSS pixels</a>, if the image has <a href="#density-corrected-intrinsic-width-and-height" id="the-img-element:density-corrected-intrinsic-width-and-height-2">density-corrected natural width and
  height</a> and is <i id="the-img-element:img-available-4"><a href="#img-available">available</a></i> but is not <a href="#being-rendered" id="the-img-element:being-rendered-2">being
  rendered</a>; or else 0, if the image is not <i id="the-img-element:img-available-5"><a href="#img-available">available</a></i> or does
  not have <a href="#density-corrected-intrinsic-width-and-height" id="the-img-element:density-corrected-intrinsic-width-and-height-3">density-corrected natural width and height</a>. <a href="#refsCSS">[CSS]</a></p>
  </div>

  <div data-algorithm="">
  <p>The IDL attributes <dfn data-dfn-for="HTMLImageElement" id="dom-img-naturalwidth" data-dfn-type="attribute"><code>naturalWidth</code></dfn> and <dfn data-dfn-for="HTMLImageElement" id="dom-img-naturalheight" data-dfn-type="attribute"><code>naturalHeight</code></dfn> must return
  the <a href="#density-corrected-intrinsic-width-and-height" id="the-img-element:density-corrected-intrinsic-width-and-height-4">density-corrected natural width and height</a> of the image, in <a href="https://drafts.csswg.org/css-values/#px" id="the-img-element:'px'-3" data-x-internal="'px'">CSS pixels</a>, if the image has <a href="#density-corrected-intrinsic-width-and-height" id="the-img-element:density-corrected-intrinsic-width-and-height-5">density-corrected natural width and
  height</a> and is <i id="the-img-element:img-available-6"><a href="#img-available">available</a></i>, or else 0. <a href="#refsCSS">[CSS]</a></p>
  </div>

  <p class="note">Since the <a href="#density-corrected-intrinsic-width-and-height" id="the-img-element:density-corrected-intrinsic-width-and-height-6">density-corrected natural width and height</a> of an image
  take into account any orientation specified in its metadata, <code id="the-img-element:dom-img-naturalwidth-2"><a href="#dom-img-naturalwidth">naturalWidth</a></code> and <code id="the-img-element:dom-img-naturalheight-2"><a href="#dom-img-naturalheight">naturalHeight</a></code> reflect the dimensions after applying any
  rotation needed to correctly orient the image, regardless of the value of the
  <a id="the-img-element:'image-orientation'" href="https://drafts.csswg.org/css-images-3/#the-image-orientation" data-x-internal="'image-orientation'">'image-orientation'</a> property.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLImageElement" id="dom-img-complete" data-dfn-type="attribute"><code>complete</code></dfn> getter steps are:</p>

  <ol><li>
    <p>If any of the following are true:</p>

    <ul><li><p>both the <code id="the-img-element:attr-img-src-11"><a href="#attr-img-src">src</a></code> attribute and the <code id="the-img-element:attr-img-srcset-7"><a href="#attr-img-srcset">srcset</a></code> attribute are omitted;</p></li><li><p>the <code id="the-img-element:attr-img-srcset-8"><a href="#attr-img-srcset">srcset</a></code> attribute is omitted and the <code id="the-img-element:attr-img-src-12"><a href="#attr-img-src">src</a></code> attribute's value is the empty string;</p></li><li><p>the <code id="the-img-element:the-img-element-17"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="the-img-element:current-request">current request</a>'s <a href="#img-req-state" id="the-img-element:img-req-state">state</a> is <a href="#img-all" id="the-img-element:img-all">completely available</a> and
     its <a href="#pending-request" id="the-img-element:pending-request">pending request</a> is null; or</p></li><li><p>the <code id="the-img-element:the-img-element-18"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="the-img-element:current-request-2">current request</a>'s <a href="#img-req-state" id="the-img-element:img-req-state-2">state</a> is <a href="#img-error" id="the-img-element:img-error">broken</a> and its
     <a href="#pending-request" id="the-img-element:pending-request-2">pending request</a> is null,</p></li></ul>

    <p>then return true.</p>
   </li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLImageElement" id="dom-img-currentsrc" data-dfn-type="attribute"><code>currentSrc</code></dfn> IDL attribute must return the
  <code id="the-img-element:the-img-element-19"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="the-img-element:current-request-3">current request</a>'s <a href="#img-req-url" id="the-img-element:img-req-url">current
  URL</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLImageElement" id="dom-img-decode" data-dfn-type="method"><code>decode()</code></dfn>
  method, when invoked, must perform the following steps:</p>

  <ol><li><p>Let <var>promise</var> be a new promise.</p></li><li>
    <p><a href="#queue-a-microtask" id="the-img-element:queue-a-microtask">Queue a microtask</a> to perform the following steps:</p>

    <div class="note">
     <p>This is done because <a href="#update-the-image-data" id="the-img-element:update-the-image-data">updating the image data</a>
     takes place in a microtask as well. Thus, to make code such as</p>

     <pre><code class="js">img<c- p="">.</c->src <c- o="">=</c-> <c- u="">"stars.jpg"</c-><c- p="">;</c->
img<c- p="">.</c->decode<c- p="">();</c-></code></pre>

     <p>properly decode <code>stars.jpg</code>, we need to delay any processing by one
     microtask.</p>
    </div>

    <ol><li><p>Let <var>global</var> be <a id="the-img-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-img-element:concept-relevant-global">relevant global
     object</a>.</p></li><li>
      <p>If any of the following are true:</p>

      <ul><li><p><a id="the-img-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-img-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="the-img-element:fully-active">fully active</a>;
       or</p></li><li><p><a id="the-img-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#current-request" id="the-img-element:current-request-4">current request</a>'s <a href="#img-req-state" id="the-img-element:img-req-state-3">state</a> is <a href="#img-error" id="the-img-element:img-error-2">broken</a>,</p></li></ul>

      <p>then reject <var>promise</var> with an <a id="the-img-element:encodingerror-2" href="https://webidl.spec.whatwg.org/#encodingerror" data-x-internal="encodingerror">"<code>EncodingError</code>"</a>
      <code id="the-img-element:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
     </li><li>
      <p>Otherwise, <a href="#in-parallel" id="the-img-element:in-parallel-2">in parallel</a>, wait for one of the following cases to occur, and
      perform the corresponding actions:</p>

      <dl class="switch"><dt>This <code id="the-img-element:the-img-element-20"><a href="#the-img-element">img</a></code> element's <a id="the-img-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> stops being <a href="#fully-active" id="the-img-element:fully-active-2">fully
       active</a></dt><dt>This <code id="the-img-element:the-img-element-21"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="the-img-element:current-request-5">current request</a> changes or is mutated</dt><dt>This <code id="the-img-element:the-img-element-22"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="the-img-element:current-request-6">current request</a>'s <a href="#img-req-state" id="the-img-element:img-req-state-4">state</a> becomes <a href="#img-error" id="the-img-element:img-error-3">broken</a></dt><dd><p><a href="#queue-a-global-task" id="the-img-element:queue-a-global-task">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="the-img-element:dom-manipulation-task-source">DOM manipulation task source</a> with
       <var>global</var> to reject <var>promise</var> with an
       <a id="the-img-element:encodingerror-3" href="https://webidl.spec.whatwg.org/#encodingerror" data-x-internal="encodingerror">"<code>EncodingError</code>"</a> <code id="the-img-element:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></dd><dt>This <code id="the-img-element:the-img-element-23"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="the-img-element:current-request-7">current request</a>'s <a href="#img-req-state" id="the-img-element:img-req-state-5">state</a> becomes <a href="#img-all" id="the-img-element:img-all-2">completely
       available</a></dt><dd>
        <p><a href="#img-decoding-process" id="the-img-element:img-decoding-process-3">Decode</a> the image.</p>

        <p>If decoding does not need to be performed for this image (for example because it is a
        vector graphic) or the decoding process completes successfully, then <a href="#queue-a-global-task" id="the-img-element:queue-a-global-task-2">queue a global
        task</a> on the <a href="#dom-manipulation-task-source" id="the-img-element:dom-manipulation-task-source-2">DOM manipulation task source</a> with <var>global</var> to
        resolve <var>promise</var> with undefined.</p>

        <p>If decoding fails (for example due to invalid image data), then <a href="#queue-a-global-task" id="the-img-element:queue-a-global-task-3">queue a global
        task</a> on the <a href="#dom-manipulation-task-source" id="the-img-element:dom-manipulation-task-source-3">DOM manipulation task source</a> with <var>global</var> to
        reject <var>promise</var> with an <a id="the-img-element:encodingerror-4" href="https://webidl.spec.whatwg.org/#encodingerror" data-x-internal="encodingerror">"<code>EncodingError</code>"</a>
        <code id="the-img-element:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

        <p>User agents should ensure that the decoded media data stays readily available until at
        least the end of the next successful <a href="#update-the-rendering" id="the-img-element:update-the-rendering">update the rendering</a> step in the
        <a href="#event-loop" id="the-img-element:event-loop">event loop</a>. This is an important part of the API contract, and should not be
        broken if at all possible. (Typically, this would only be violated in low-memory situations
        that require evicting decoded image data, or when the image is too large to keep in decoded
        form for this period of time.)</p>
       </dd></dl>

      <p class="note">Animated images will become <a href="#img-all" id="the-img-element:img-all-3">completely available</a>
      only after all their frames are loaded. Thus, even though an implementation could decode the
      first frame before that point, the above steps will not do so, instead waiting until all
      frames are available.</p>
     </li></ol>
   </li><li><p>Return <var>promise</var>.</p></li></ol>
  </div>

  

  <div class="example">
   <p>Without the <code id="the-img-element:dom-img-decode-2"><a href="#dom-img-decode">decode()</a></code> method, the process of loading an
   <code id="the-img-element:the-img-element-24"><a href="#the-img-element">img</a></code> element and then displaying it might look like the following:</p>

   <pre><code class="js"><c- a="">const</c-> img <c- o="">=</c-> <c- k="">new</c-> Image<c- p="">();</c->
img<c- p="">.</c->src <c- o="">=</c-> <c- u="">"nebula.jpg"</c-><c- p="">;</c->
img<c- p="">.</c->onload <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
    document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->img<c- p="">);</c->
<c- p="">};</c->
img<c- p="">.</c->onerror <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
    document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c-><c- k="">new</c-> Text<c- p="">(</c-><c- u="">"Could not load the nebula :("</c-><c- p="">));</c->
<c- p="">};</c-></code></pre>

   <p>However, this can cause notable dropped frames, as the paint that occurs after inserting the
   image into the DOM causes a synchronous decode on the main thread.</p>

   <p>This can instead be rewritten using the <code id="the-img-element:dom-img-decode-3"><a href="#dom-img-decode">decode()</a></code>
   method:</p>

   <pre><code class="js"><c- a="">const</c-> img <c- o="">=</c-> <c- k="">new</c-> Image<c- p="">();</c->
img<c- p="">.</c->src <c- o="">=</c-> <c- u="">"nebula.jpg"</c-><c- p="">;</c->
img<c- p="">.</c->decode<c- p="">().</c->then<c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
    document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->img<c- p="">);</c->
<c- p="">}).</c-><c- k="">catch</c-><c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
    document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c-><c- k="">new</c-> Text<c- p="">(</c-><c- u="">"Could not load the nebula :("</c-><c- p="">));</c->
<c- p="">});</c-></code></pre>

   <p>This latter form avoids the dropped frames of the original, by allowing the user agent to
   decode the image <a href="#in-parallel" id="the-img-element:in-parallel-3">in parallel</a>, and only inserting it into the DOM (and thus causing
   it to be painted) once the decoding process is complete.</p>
  </div>

  <div class="example">
   <p>Because the <code id="the-img-element:dom-img-decode-4"><a href="#dom-img-decode">decode()</a></code> method attempts to ensure that the
   decoded image data is available for at least one frame, it can be combined with the <code id="the-img-element:dom-animationframeprovider-requestanimationframe"><a href="#dom-animationframeprovider-requestanimationframe">requestAnimationFrame()</a></code> API.
   This means it can be used with coding styles or frameworks that ensure that all DOM modifications
   are batched together as <a href="#list-of-animation-frame-callbacks" id="the-img-element:list-of-animation-frame-callbacks">animation frame
   callbacks</a>:</p>

   <pre><code class="js"><c- a="">const</c-> container <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"#container"</c-><c- p="">);</c->

<c- a="">const</c-> <c- p="">{</c-> containerWidth<c- p="">,</c-> containerHeight <c- p="">}</c-> <c- o="">=</c-> computeDesiredSize<c- p="">();</c->
requestAnimationFrame<c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
 container<c- p="">.</c->style<c- p="">.</c->width <c- o="">=</c-> containerWidth<c- p="">;</c->
 container<c- p="">.</c->style<c- p="">.</c->height <c- o="">=</c-> containerHeight<c- p="">;</c->
<c- p="">});</c->

<c- c1="">// ...</c->

<c- a="">const</c-> img <c- o="">=</c-> <c- k="">new</c-> Image<c- p="">();</c->
img<c- p="">.</c->src <c- o="">=</c-> <c- u="">"supernova.jpg"</c-><c- p="">;</c->
img<c- p="">.</c->decode<c- p="">().</c->then<c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
    requestAnimationFrame<c- p="">(()</c-> <c- p="">=&gt;</c-> container<c- p="">.</c->appendChild<c- p="">(</c->img<c- p="">));</c->
<c- p="">});</c-></code></pre>
  </div>

  

  <div data-algorithm="">
  <p>A legacy factory function is provided for creating <code id="the-img-element:htmlimageelement"><a href="#htmlimageelement">HTMLImageElement</a></code> objects (in
  addition to the factory methods from DOM such as <code id="the-img-element:dom-document-createelement"><a data-x-internal="dom-document-createelement" href="https://dom.spec.whatwg.org/#dom-document-createelement">createElement()</a></code>): <dfn id="dom-image"><code>Image(<var>width</var>, <var>height</var>)</code></dfn>. When invoked,
  the legacy factory function must perform the following steps:</p>

  <ol><li><p>Let <var>document</var> be the <a href="#current-global-object" id="the-img-element:current-global-object">current global object</a>'s <a href="#concept-document-window" id="the-img-element:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>Let <var>img</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-img-element:create-an-element" data-x-internal="create-an-element">creating an
   element</a> given <var>document</var>, "<code>img</code>", and the <a id="the-img-element:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
   namespace</a>.</p></li><li><p>If <var>width</var> is given, then <a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="the-img-element:concept-element-attributes-set-value" data-x-internal="concept-element-attributes-set-value">set
   an attribute value</a> for <var>img</var> using "<code id="the-img-element:attr-dim-width-4"><a href="#attr-dim-width">width</a></code>"
   and <var>width</var>.</p></li><li><p>If <var>height</var> is given, then <a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="the-img-element:concept-element-attributes-set-value-2" data-x-internal="concept-element-attributes-set-value">set an attribute value</a> for <var>img</var>
   using "<code id="the-img-element:attr-dim-height-4"><a href="#attr-dim-height">height</a></code>" and <var>height</var>.</p></li><li><p>Return <var>img</var>.</p></li></ol>
  </div>

  

  <div class="example">

   <p>A single image can have different appropriate alternative text depending on the context.</p>

   <p>In each of the following cases, the same image is used, yet the <code id="the-img-element:attr-img-alt-17"><a href="#attr-img-alt">alt</a></code> text is different each time. The image is the coat of arms of the
   Carouge municipality in the canton Geneva in Switzerland.</p>

   <p>Here it is used as a supplementary icon:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I lived in <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"carouge.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-> Carouge.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Here it is used as an icon representing the town:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Home town: <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"carouge.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Carouge"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Here it is used as part of a text on the town:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Carouge has a coat of arms.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"carouge.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The coat of arms depicts a lion, sitting in front of a tree."</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->It is used as decoration all over the town.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Here it is used as a way to support a similar text where the description is given as well as,
   instead of as an alternative to, the image:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Carouge has a coat of arms.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"carouge.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The coat of arms depicts a lion, sitting in front of a tree.
It is used as decoration all over the town.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Here it is used as part of a story:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->She picked up the folder and a piece of paper fell out.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"carouge.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Shaped like a shield, the paper had a</c->
<c- s="">red background, a green tree, and a yellow lion with its tongue</c->
<c- s="">hanging out and whose tail was shaped like an S."</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->She stared at the folder. S! The answer she had been looking for all
this time was simply the letter S! How had she not seen that before? It all
came together now. The phone call where Hector had referred to a lion's tail,
the time Maria had stuck her tongue out...<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Here it is not known at the time of publication what the image will be, only that it will be a
   coat of arms of some kind, and thus no replacement text can be provided, and instead only a brief
   caption for the image is provided, in the <code id="the-img-element:attr-title-3"><a href="#attr-title">title</a></code> attribute:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The last user to have uploaded a coat of arms uploaded this one:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"last-uploaded-coat-of-arms.cgi"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"User-uploaded coat of arms."</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Ideally, the author would find a way to provide real replacement text even in this case, e.g.
   by asking the previous user. Not providing replacement text makes the document more difficult to
   use for people who are unable to view images, e.g. blind users, or users or very low-bandwidth
   connections or who pay by the byte, or users who are forced to use a text-only web browser.</p>

  </div>

  <div class="example">

   <p>Here are some more examples showing the same picture used in different contexts, with
   different appropriate alternate texts each time.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->My cats<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Fluffy<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Fluffy is my favorite.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"fluffy.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"She likes playing with a ball of yarn."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->She's just too cute.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Miles<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My other cat, Miles just eats and sleeps.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Photography<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Shooting moving targets indoors<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The trick here is to know how to anticipate; to know at what speed and
 what distance the subject will pass by.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"fluffy.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"A cat flying by, chasing a ball of yarn, can be</c->
<c- s=""> photographed quite nicely using this technique."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Nature by night<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->To achieve this, you'll need either an extremely sensitive film, or
 immense flash lights.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->About me<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->My pets<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I've got a cat named Fluffy and a dog named Miles.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"fluffy.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Fluffy, my cat, tends to keep itself busy."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My dog Miles and I like go on long walks together.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->music<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->After our walks, having emptied my mind, I like listening to Bach.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Fluffy and the Yarn<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Fluffy was a cat who liked to play with yarn. She also liked to jump.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"fluffy.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Fluffy"</c-><c- p="">&gt;&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->She would play in the morning, she would play in the evening.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="images"><span class="secno">4.8.4</span> Images<a href="#images" class="self-link"></a></h4>

  <h5 id="introduction-3"><span class="secno">4.8.4.1</span> Introduction<a href="#introduction-3" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>To embed an image in HTML, when there is only a single image resource, use the <code id="introduction-3:the-img-element"><a href="#the-img-element">img</a></code>
  element and its <code id="introduction-3:attr-img-src"><a href="#attr-img-src">src</a></code> attribute.</p>

  <div class="example">

<pre><code class="html"><c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->From today's featured article<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/uploads/100-marie-lloyd.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">"100"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"150"</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/wiki/Marie_Lloyd"</c-><c- p="">&gt;</c->Marie Lloyd<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> (1870–1922)
was an English <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/wiki/Music_hall"</c-><c- p="">&gt;</c->music hall<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> singer, ...</code></pre>

  </div>

  <p>However, there are a number of situations for which the author might wish to use multiple image
  resources that the user agent can choose from:</p>

  <ul><li>
    <p>Different users might have different environmental characteristics:</p>

    <ul><li>
      <p>The users' physical screen size might be different from one another.</p>

      <div class="example">
       <p>A mobile phone's screen might be 4 inches diagonally, while a laptop's screen might be 14
       inches diagonally.</p>

       <svg font-size="2.5" role="img" viewBox="0 0 80 32" font-family="sans-serif" height="200" aria-label="The phone's screen is much smaller compared to the laptop's screen.">
        
        <rect width="6" fill="white" stroke="black" x="6" height="12" y="18" rx="1"></rect>
        <text transform="translate(9 24)
        rotate(-60)" text-anchor="middle" dominant-baseline="middle">4″</text>
        
        <rect width="40" stroke-width="2" fill="white" stroke="black" x="30" height="26" y="2" rx="2"></rect>
        <line y2="30" stroke-linecap="round" stroke-width="2" stroke="black" x1="26" y1="30" x2="74"></line>
        <text transform="translate(50 15)
        rotate(-30)" text-anchor="middle" dominant-baseline="middle">14″</text>
       </svg>
      </div>

      <p class="note">This is only relevant when an image's rendered size depends on the
      <a id="introduction-3:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> size.</p>
     </li><li>
      <p>The users' screen pixel density might be different from one another.</p>

      <div class="example">
       <p>A mobile phone's screen might have three times as many physical pixels per inch
      compared to another mobile phone's screen, regardless of their physical screen size.</p>

       <svg font-size="2.5" role="img" viewBox="0 0 56 27" font-family="sans-serif" height="170" aria-label="One phone has big pixels, the other has small pixels.">
        <defs>
         <pattern id="img-intro-pixel" width="3" patternUnits="userSpaceOnUse" stroke-linecap="round" x="0" y="0" height="3">
          <rect fill="black" width="3" x="0" height="3" y="0"></rect>
          <line y2="2.5" stroke="red" x1="0.5" x2="0.5" y1="0.5"></line>
          <line y2="2.5" stroke="lime" x1="1.5" x2="1.5" y1="0.5"></line>
          <line y2="2.5" stroke="blue" x1="2.5" x2="2.5" y1="0.5"></line>
         </pattern>
        </defs>
        
        <rect width="6" fill="white" stroke="black" x="6" height="12" y="8" rx="1"></rect>
        <rect width="6" fill="white" stroke="black" x="36" height="12" y="8" rx="1"></rect>
        
        <line y2="24" stroke-width="3" stroke="brown" x1="15" y1="16" x2="22"></line>
        <circle cx="10" cy="10" fill="url(#img-intro-pixel)" stroke="black" r="8"></circle>
        <line y2="24" stroke-width="3" stroke="brown" x1="45" y1="16" x2="52"></line>
        <circle cx="120" transform="scale(0.333333)" cy="30" r="24" stroke-width="3" fill="url(#img-intro-pixel)" stroke="black"></circle>
        
        <text x="20" y="10" dominant-baseline="middle">1x</text>
        <text x="50" y="10" dominant-baseline="middle">3x</text>
       </svg>
      </div>
     </li><li>
      <p>The users' zoom level might be different from one another, or might change for a single
      user over time.</p>

      <p class="example">A user might zoom in to a particular image to be able to get a more
      detailed look.</p>

      <p>The zoom level and the screen pixel density (the previous point) can both affect the number
      of physical screen pixels per <a href="https://drafts.csswg.org/css-values/#px" id="introduction-3:'px'" data-x-internal="'px'">CSS pixel</a>. This ratio is usually
      referred to as <dfn id="device-pixel-ratio">device-pixel-ratio</dfn>.</p>
     </li><li>
      <p>The users' screen orientation might be different from one another, or might change for a
      single user over time.</p>

      <div class="example">
       <p>A tablet can be held upright or rotated 90 degrees, so that the screen is either
       "portrait" or "landscape".</p>

       <svg font-size="2.5" role="img" viewBox="0 0 60 32" font-family="sans-serif" height="200" aria-label="The tablet has two orientations.">
        
        <rect width="14" fill="white" stroke="black" x="6" height="20" y="5" rx="1"></rect>
        <line y2="24" stroke-width="1.1" stroke="black" x1="6" y1="24" x2="20"></line>
        <text text-anchor="middle" x="13" y="14.5" dominant-baseline="middle">Portrait</text>
        <rect width="20" fill="white" stroke="black" x="30" height="14" y="11" rx="1"></rect>
        <line y2="11" stroke-width="1.1" stroke="black" x1="31" y1="25" x2="31"></line>
        <text text-anchor="middle" x="40.5" y="18" dominant-baseline="middle">Landscape</text>
       </svg>
      </div>
     </li><li>
      <p>The users' network speed, network latency and bandwidth cost might be different from one
      another, or might change for a single user over time.</p>

      <p class="example">A user might be on a fast, low-latency and constant-cost connection while
      at work, on a slow, low-latency and constant-cost connection while at home, and on a
      variable-speed, high-latency and variable-cost connection anywhere else.</p>
     </li></ul>
   </li><li>
    <p>Authors might want to show the same image content but with different rendered size depending
    on, usually, the width of the <a id="introduction-3:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>. This is usually referred to as
    <dfn id="viewport-based-selection">viewport-based selection</dfn>.</p>

    <div class="example">
     <p>A web page might have a banner at the top that always spans the entire <a id="introduction-3:viewport-3" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>
     width. In this case, the rendered size of the image depends on the physical size of the screen
     (assuming a maximised browser window).</p>

     <svg viewBox="0 0 52 25.6" height="160" aria-label="The upright-held phone shows a
     small wolf at the top, and the tablet shows the same image but it is bigger." role="img">
      

      
      <rect width="6" fill="white" stroke="black" x="6" height="12" y="8" rx="1"></rect>
      <rect fill="#716966" x="7" width="4" height="2" y="9"></rect>
      <image xlink:href="/images/wolf.jpg" width="4" x="7" y="9" height="2"></image>

      
      <rect width="20" fill="white" stroke="black" x="25" height="14" y="6" rx="1"></rect>
      <line y2="6" stroke-width="1.1" stroke="black" x1="26" y1="20" x2="26"></line>
      <rect fill="#716966" x="27" width="17" height="8.5" y="7"></rect>
      <image xlink:href="/images/wolf.jpg" width="17" x="27" y="7" height="8.5"></image>

     </svg>
    </div>

    <div class="example">
     <p>Another web page might have images in columns, with a single column for screens with a small
     physical size, two columns for screens with medium physical size, and three columns for screens
     with big physical size, with the images varying in rendered size in each case to fill up the
     <a id="introduction-3:viewport-4" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>. In this case, the rendered size of an image might be <em>bigger</em> in
     the one-column layout compared to the two-column layout, despite the screen being smaller.</p>

     <svg font-size="2.5" role="img" viewBox="0 0 115 32" font-family="sans-serif" height="200" aria-label="The rotated phone shows a top part of an image of a kettlebell swing; the
     upright-held tablet shows a bit smaller images in two columns; the laptop shows images in three
     columns.">
      

      
      <rect width="12" fill="white" stroke="black" x="6" height="6" y="24" rx="1"></rect>
      <rect fill="#987b5a" width="10" x="7" height="4.5" y="25"></rect>
      <image xlink:href="/images/kettlebell.jpg" preserveAspectRatio="xMinYMin slice" width="10" x="7" y="25" height="4.5"></image>
      <text text-anchor="middle" x="12" y="21">Narrow, 1 column</text>

      
      <rect width="14" fill="white" stroke="black" x="32" height="20" y="10" rx="1"></rect>
      <line y2="29" stroke-width="1.1" stroke="black" x1="32" y1="29" x2="46"></line>
      <rect fill="#987b5a" width="5.5" x="33" height="5.5" y="11"></rect>
      <image xlink:href="/images/kettlebell.jpg" width="5.5" x="33" y="11" height="5.5"></image>
      <rect fill="burlywood" width="5.5" x="39.5" height="5.5" y="11"></rect>
      <rect fill="silver" width="5.5" x="33" height="5.5" y="17.5"></rect>
      <text text-anchor="middle" x="39" y="7">Medium, 2 columns</text>

      
      <rect width="40" stroke-width="2" fill="white" stroke="black" x="65" height="26" y="2" rx="2"></rect>
      <line y2="30" stroke-linecap="round" stroke-width="2" stroke="black" x1="61" y1="30" x2="109"></line>
      <rect fill="#987b5a" width="10" x="67" height="10" y="4"></rect>
      <image xlink:href="/images/kettlebell.jpg" width="10" x="67" y="4" height="10"></image>
      <rect fill="burlywood" width="10" x="80" height="10" y="4"></rect>
      <rect fill="silver" width="10" x="93" height="10" y="4"></rect>
      <text text-anchor="middle" x="85" y="25">Wide, 3 columns</text>
     </svg>
    </div>
   </li><li>
    <p>Authors might want to show different image content depending on the rendered size of the
    image. This is usually referred to as <dfn id="art-direction">art direction</dfn>.</p>

    <div class="example">
     <p>When a web page is viewed on a screen with a large physical size (assuming a maximised
     browser window), the author might wish to include some less relevant parts surrounding the
     critical part of the image. When the same web page is viewed on a screen with a small physical
     size, the author might wish to show only the critical part of the image.</p>

     <svg viewBox="0 0 52 25.6" height="160" aria-label="The upright-held phone shows a
     cropped image of a wolf; the rotated tablet shows the uncropped image." role="img">
      

      
      <rect width="6" fill="white" stroke="black" x="6" height="12" y="8" rx="1"></rect>
      <rect fill="#716966" x="7" width="4" height="6" y="9"></rect>
      <image xlink:href="/images/wolf.jpg" preserveAspectRatio="xMidYMid slice" width="4" x="7" y="9" height="6"></image>

      
      <rect width="20" fill="white" stroke="black" x="25" height="14" y="6" rx="1"></rect>
      <line y2="6" stroke-width="1.1" stroke="black" x1="26" y1="20" x2="26"></line>
      <rect fill="#716966" x="27" width="17" height="8.5" y="7"></rect>
      <image xlink:href="/images/wolf.jpg" width="17" x="27" y="7" height="8.5"></image>

     </svg>
    </div>
   </li><li>
    <p>Authors might want to show the same image content but using different image formats,
    depending on which image formats the user agent supports. This is usually referred to as
    <dfn id="image-format-based-selection">image format-based selection</dfn>.</p>

    <p class="example">A web page might have some images in the JPEG, WebP and JPEG XR image
    formats, with the latter two having better compression abilities compared to JPEG. Since
    different user agents can support different image formats, with some formats offering better
    compression ratios, the author would like to serve the better formats to user agents that
    support them, while providing JPEG fallback for user agents that don't.</p>
   </li></ul>

  <p>The above situations are not mutually exclusive. For example, it is reasonable to combine
  different resources for different <a href="#device-pixel-ratio" id="introduction-3:device-pixel-ratio">device-pixel-ratio</a> with different resources for
  <a href="#art-direction" id="introduction-3:art-direction">art direction</a>.</p>

  <p>While it is possible to solve these problems using scripting, doing so introduces some other
  problems:</p>

  <ul><li><p>Some user agents aggressively download images specified in the HTML markup, before scripts
   have had a chance to run, so that web pages complete loading sooner. If a script changes which
   image to download, the user agent will potentially start two separate downloads, which can
   instead cause worse page loading performance.</p></li><li><p>If the author avoids specifying any image in the HTML markup and instead instantiates a
   single download from script, that avoids the double download problem above but then no image will
   be downloaded at all for users with scripting disabled and the aggressive image downloading
   optimization will also be disabled.</p></li></ul>

  <p>With this in mind, this specification introduces a number of features to address the above
  problems in a declarative manner.</p>

  <dl><dt><a href="#device-pixel-ratio" id="introduction-3:device-pixel-ratio-2">Device-pixel-ratio</a>-based selection when the rendered size of the image is
   fixed</dt><dd>
    <p>The <code id="introduction-3:attr-img-src-2"><a href="#attr-img-src">src</a></code> and <code id="introduction-3:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code>
    attributes on the <code id="introduction-3:the-img-element-2"><a href="#the-img-element">img</a></code> element can be used, using the <code>x</code>
    descriptor, to provide multiple images that only vary in their size (the smaller image is a
    scaled-down version of the bigger image).</p>

    <p class="note">The <code>x</code> descriptor is not appropriate when the rendered
    size of the image depends on the <a id="introduction-3:viewport-5" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> width
    (<a href="#viewport-based-selection" id="introduction-3:viewport-based-selection">viewport-based selection</a>), but can be used together with
    <a href="#art-direction" id="introduction-3:art-direction-2">art direction</a>.</p>

    <div class="example">

<pre><code class="html"><c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->From today's featured article<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">img</c-> <strong><c- e="">src</c-><c- o="">=</c-><c- s="">"/uploads/100-marie-lloyd.jpg"</c-></strong>
     <strong><c- e="">srcset</c-><c- o="">=</c-><c- s="">"/uploads/150-marie-lloyd.jpg 1.5x, /uploads/200-marie-lloyd.jpg 2x"</c-></strong>
     <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">"100"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"150"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/wiki/Marie_Lloyd"</c-><c- p="">&gt;</c->Marie Lloyd<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> (1870–1922)
was an English <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/wiki/Music_hall"</c-><c- p="">&gt;</c->music hall<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> singer, ...</code></pre>

     <p>The user agent can choose any of the given resources depending on the user's screen's pixel
     density, zoom level, and possibly other factors such as the user's network conditions.</p>

     <p>For backwards compatibility with older user agents that don't yet understand the <code id="introduction-3:attr-img-srcset-2"><a href="#attr-img-srcset">srcset</a></code> attribute, one of the URLs is specified in the
     <code id="introduction-3:the-img-element-3"><a href="#the-img-element">img</a></code> element's <code id="introduction-3:attr-img-src-3"><a href="#attr-img-src">src</a></code> attribute. This will result
     in something useful (though perhaps lower-resolution than the user would like) being displayed
     even in older user agents. For new user agents, the <code id="introduction-3:attr-img-src-4"><a href="#attr-img-src">src</a></code>
     attribute participates in the resource selection, as if it was specified in <code id="introduction-3:attr-img-srcset-3"><a href="#attr-img-srcset">srcset</a></code> with a <code>1x</code> descriptor.</p>

     <p>The image's rendered size is given in the <code id="introduction-3:attr-dim-width"><a href="#attr-dim-width">width</a></code> and
     <code id="introduction-3:attr-dim-height"><a href="#attr-dim-height">height</a></code> attributes, which allows the user agent to
     allocate space for the image before it is downloaded.</p>

    </div>
   </dd><dt><a href="#viewport-based-selection" id="introduction-3:viewport-based-selection-2">Viewport-based selection</a></dt><dd>
    <p>The <code id="introduction-3:attr-img-srcset-4"><a href="#attr-img-srcset">srcset</a></code> and <code id="introduction-3:attr-img-sizes"><a href="#attr-img-sizes">sizes</a></code> attributes can be used, using the <code>w</code>
    descriptor, to provide multiple images that only vary in their size (the smaller image is a
    scaled-down version of the bigger image).</p>

    <div class="example">

     <p>In this example, a banner image takes up the entire <a id="introduction-3:viewport-6" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> width (using
     appropriate CSS).</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <strong><c- e="">sizes</c-><c- o="">=</c-><c- s="">"100vw"</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"wolf-400.jpg 400w, wolf-800.jpg 800w, wolf-1600.jpg 1600w"</c-></strong>
     <c- e="">src</c-><c- o="">=</c-><c- s="">"wolf-400.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The rad wolf"</c-><c- p="">&gt;&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></code></pre>

     <p>The user agent will calculate the effective pixel density of each image from the specified
     <code>w</code> descriptors and the specified rendered size in the <code id="introduction-3:attr-img-sizes-2"><a href="#attr-img-sizes">sizes</a></code> attribute. It can then choose any of the given resources
     depending on the user's screen's pixel density, zoom level, and possibly other factors such as
     the user's network conditions.</p>

     <p>If the user's screen is 320 <a href="https://drafts.csswg.org/css-values/#px" id="introduction-3:'px'-2" data-x-internal="'px'">CSS pixels</a> wide, this is equivalent
     to specifying <code>wolf-400.jpg 1.25x, wolf-800.jpg 2.5x, wolf-1600.jpg 5x</code>.
     On the other hand, if the user's screen is 1200 <a href="https://drafts.csswg.org/css-values/#px" id="introduction-3:'px'-3" data-x-internal="'px'">CSS pixels</a> wide,
     this is equivalent to specifying <code>wolf-400.jpg 0.33x, wolf-800.jpg 0.67x, wolf-1600.jpg 1.33x</code>. By using the
     <code>w</code> descriptors and the <code id="introduction-3:attr-img-sizes-3"><a href="#attr-img-sizes">sizes</a></code>
     attribute, the user agent can choose the correct image source to download regardless of how
     large the user's device is.</p>

     <p>For backwards compatibility, one of the URLs is specified in the <code id="introduction-3:the-img-element-4"><a href="#the-img-element">img</a></code> element's
     <code id="introduction-3:attr-img-src-5"><a href="#attr-img-src">src</a></code> attribute. In new user agents, the <code id="introduction-3:attr-img-src-6"><a href="#attr-img-src">src</a></code> attribute is ignored when the <code id="introduction-3:attr-img-srcset-5"><a href="#attr-img-srcset">srcset</a></code> attribute uses <code>w</code> descriptors.</p>

    </div>

    <div class="example">

     <p>In this example, the web page has three layouts depending on the width of the
     <a id="introduction-3:viewport-7" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>. The narrow layout has one column of images (the width of each image is
     about 100%), the middle layout has two columns of images (the width of each image is about
     50%), and the widest layout has three columns of images, and some page margin (the width of
     each image is about 33%). It breaks between these layouts when the <a id="introduction-3:viewport-8" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> is
     <code>30em</code> wide and <code>50em</code> wide, respectively.</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">img</c-> <strong><c- e="">sizes</c-><c- o="">=</c-><c- s="">"(max-width: 30em) 100vw, (max-width: 50em) 50vw, calc(33vw - 100px)"</c-></strong>
     <strong><c- e="">srcset</c-><c- o="">=</c-><c- s="">"swing-200.jpg 200w, swing-400.jpg 400w, swing-800.jpg 800w, swing-1600.jpg 1600w"</c-></strong>
     <c- e="">src</c-><c- o="">=</c-><c- s="">"swing-400.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Kettlebell Swing"</c-><c- p="">&gt;</c-></code></pre>

     <p>The <code id="introduction-3:attr-img-sizes-4"><a href="#attr-img-sizes">sizes</a></code> attribute sets up the layout breakpoints at
     <code>30em</code> and <code>50em</code>, and declares the image sizes
     between these breakpoints to be <code>100vw</code>, <code>50vw</code>, or
     <code>calc(33vw - 100px)</code>. These sizes do not necessarily have to match up
     exactly with the actual image width as specified in the CSS.</p>

     <p>The user agent will pick a width from the <code id="introduction-3:attr-img-sizes-5"><a href="#attr-img-sizes">sizes</a></code>
     attribute, using the first item with a <a id="introduction-3:media-condition" href="https://drafts.csswg.org/mediaqueries/#typedef-media-condition" data-x-internal="media-condition">&lt;media-condition&gt;</a> (the part in
     parentheses) that evaluates to true, or using the last item (<code>calc(33vw -
     100px)</code>) if they all evaluate to false.</p>

     <p>For example, if the <a id="introduction-3:viewport-9" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> width is <code>29em</code>, then <code>(max-width: 30em)</code> evaluates to true and <code>100vw</code> is used,
     so the image size, for the purpose of resource selection, is <code>29em</code>. If
     the <a id="introduction-3:viewport-10" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> width is instead <code>32em</code>, then
     <code>(max-width: 30em)</code> evaluates to false, but
     <code>(max-width: 50em)</code> evaluates to true
     and <code>50vw</code> is used, so the image size, for the purpose of resource
     selection, is <code>16em</code> (half the <a id="introduction-3:viewport-11" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> width). Notice that
     the slightly wider <a id="introduction-3:viewport-12" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> results in a smaller image because of the different
     layout.</p>

     <p>The user agent can then calculate the effective pixel density and choose an appropriate
     resource similarly to the previous example.</p>

    </div>

    <div class="example">

     <p>This example is the same as the previous example, but the image is <a href="#attr-loading-lazy-state" id="introduction-3:attr-loading-lazy-state">lazy-loaded</a>. In this case, the <code id="introduction-3:attr-img-sizes-6"><a href="#attr-img-sizes">sizes</a></code> attribute can use the <code id="introduction-3:valdef-sizes-auto"><a href="#valdef-sizes-auto">auto</a></code> keyword, and the user agent will use the <code id="introduction-3:attr-dim-width-2"><a href="#attr-dim-width">width</a></code> attribute (or the width specified in CSS) for the
     <a href="#source-size-2" id="introduction-3:source-size-2">source size</a>.</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">img</c-> <strong><c- e="">loading</c-><c- o="">=</c-><c- s="">"lazy"</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">"200"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"200"</c-> <c- e="">sizes</c-><c- o="">=</c-><c- s="">"auto"</c-></strong>
     <c- e="">srcset</c-><c- o="">=</c-><c- s="">"swing-200.jpg 200w, swing-400.jpg 400w, swing-800.jpg 800w, swing-1600.jpg 1600w"</c->
     <c- e="">src</c-><c- o="">=</c-><c- s="">"swing-400.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Kettlebell Swing"</c-><c- p="">&gt;</c-></code></pre>

     <p>For better backwards-compatibility with legacy user agents that don't support the <code id="introduction-3:valdef-sizes-auto-2"><a href="#valdef-sizes-auto">auto</a></code> keyword, fallback sizes can be specified if desired.</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">loading</c-><c- o="">=</c-><c- s="">"lazy"</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">"200"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"200"</c->
     <strong><c- e="">sizes</c-><c- o="">=</c-><c- s="">"auto, (max-width: 30em) 100vw, (max-width: 50em) 50vw, calc(33vw - 100px)"</c-></strong>
     <c- e="">srcset</c-><c- o="">=</c-><c- s="">"swing-200.jpg 200w, swing-400.jpg 400w, swing-800.jpg 800w, swing-1600.jpg 1600w"</c->
     <c- e="">src</c-><c- o="">=</c-><c- s="">"swing-400.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Kettlebell Swing"</c-><c- p="">&gt;</c-></code></pre>

    </div>
   </dd><dt><a href="#art-direction" id="introduction-3:art-direction-3">Art direction</a>-based selection</dt><dd>
    <p>The <code id="introduction-3:the-picture-element"><a href="#the-picture-element">picture</a></code> element and the <code id="introduction-3:the-source-element"><a href="#the-source-element">source</a></code> element, together with the <code id="introduction-3:attr-source-media"><a href="#attr-source-media">media</a></code> attribute, can be used to provide multiple images that
    vary the image content (for instance the smaller image might be a cropped version of the bigger
    image).</p>

    <div class="example">

<pre><code class="html"><c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">source</c-> <strong><c- e="">media</c-><c- o="">=</c-><c- s="">"(min-width: 45em)"</c-></strong> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"large.jpg"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">source</c-> <strong><c- e="">media</c-><c- o="">=</c-><c- s="">"(min-width: 32em)"</c-></strong> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"med.jpg"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"small.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The wolf runs through the snow."</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c-></code></pre>

     <p>The user agent will choose the first <code id="introduction-3:the-source-element-2"><a href="#the-source-element">source</a></code> element for which the media query
     in the <code id="introduction-3:attr-source-media-2"><a href="#attr-source-media">media</a></code> attribute matches, and then choose an
     appropriate URL from its <code id="introduction-3:attr-source-srcset"><a href="#attr-source-srcset">srcset</a></code> attribute.</p>

     <p>The rendered size of the image varies depending on which resource is chosen. To specify
     dimensions that the user agent can use before having downloaded the image, CSS can be used.</p>

<pre><code class="css"><c- f="">img </c-><c- p="">{</c-> <c- k="">width</c-><c- p="">:</c-> <c- m="">300</c-><c- l="">px</c-><c- p="">;</c-> <c- k="">height</c-><c- p="">:</c-> <c- m="">300</c-><c- l="">px</c-> <c- p="">}</c->
<c- n="">@media</c-> <c- p="">(</c->min-width<c- f="">: 32em) </c-><c- p="">{</c-> img { width: 500px; height:300px } }
@media (min-width: 45em) { img { width: 700px; height:400px } }</code></pre>

    </div>

    <div class="example">

     <p>This example combines <a href="#art-direction" id="introduction-3:art-direction-4">art direction</a>- and <a href="#device-pixel-ratio" id="introduction-3:device-pixel-ratio-3">device-pixel-ratio</a>-based
     selection. A banner that takes half the <a id="introduction-3:viewport-13" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> is provided in two versions,
     one for wide screens and one for narrow screens.</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 500px)"</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"banner-phone.jpeg, banner-phone-HD.jpeg 2x"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"banner.jpeg"</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"banner-HD.jpeg 2x"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The Breakfast Combo"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></code></pre>

    </div>
   </dd><dt><a href="#image-format-based-selection" id="introduction-3:image-format-based-selection">Image format-based selection</a></dt><dd>
    <p>The <code id="introduction-3:attr-source-type"><a href="#attr-source-type">type</a></code> attribute on the <code id="introduction-3:the-source-element-3"><a href="#the-source-element">source</a></code> element
    can be used to provide multiple images in different formats.</p>

    <div class="example">

<pre><code class="html"><c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->From today's featured article<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"/uploads/100-marie-lloyd.webp"</c-> <strong><c- e="">type</c-><c- o="">=</c-><c- s="">"image/webp"</c-></strong><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"/uploads/100-marie-lloyd.jxr"</c-> <strong><c- e="">type</c-><c- o="">=</c-><c- s="">"image/vnd.ms-photo"</c-></strong><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/uploads/100-marie-lloyd.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">"100"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"150"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/wiki/Marie_Lloyd"</c-><c- p="">&gt;</c->Marie Lloyd<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> (1870–1922)
was an English <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/wiki/Music_hall"</c-><c- p="">&gt;</c->music hall<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> singer, ...</code></pre>

     <p>In this example, the user agent will choose the first source that has a <code id="introduction-3:attr-source-type-2"><a href="#attr-source-type">type</a></code> attribute with a supported MIME type. If the user agent
     supports WebP images, the first <code id="introduction-3:the-source-element-4"><a href="#the-source-element">source</a></code> element will be chosen. If not, but the
     user agent does support JPEG XR images, the second <code id="introduction-3:the-source-element-5"><a href="#the-source-element">source</a></code> element will be chosen.
     If neither of those formats are supported, the <code id="introduction-3:the-img-element-5"><a href="#the-img-element">img</a></code> element will be chosen.</p>

    </div>
   </dd></dl>


  <h6 id="adaptive-images"><span class="secno">4.8.4.1.1</span> Adaptive images<a href="#adaptive-images" class="self-link"></a></h6>

  <p><i>This section is non-normative.</i></p>

  <p>CSS and media queries can be used to construct graphical page layouts that adapt dynamically to
  the user's environment, in particular to different <a id="adaptive-images:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> dimensions and pixel
  densities. For content, however, CSS does not help; instead, we have the <code id="adaptive-images:the-img-element"><a href="#the-img-element">img</a></code> element's
  <code id="adaptive-images:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code> attribute and the <code id="adaptive-images:the-picture-element"><a href="#the-picture-element">picture</a></code> element.
  This section walks through a sample case showing how to use these features.</p>

  <p>Consider a situation where on wide screens (wider than 600 <a href="https://drafts.csswg.org/css-values/#px" id="adaptive-images:'px'" data-x-internal="'px'">CSS
  pixels</a>) a 300×150 image named <code>a-rectangle.png</code> is to be used,
  but on smaller screens (600 <a href="https://drafts.csswg.org/css-values/#px" id="adaptive-images:'px'-2" data-x-internal="'px'">CSS pixels</a> and less), a smaller
  100×100 image called <code>a-square.png</code> is to be used. The markup for this
  would look like this:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"a-square.png"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 600px)"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"a-rectangle.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Barney Frank wears a suit and glasses."</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Barney Frank, 2011<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

  <p class="note">For details on what to put in the <code id="adaptive-images:attr-img-alt"><a href="#attr-img-alt">alt</a></code>
  attribute, see the <a href="#alt">Requirements for providing text to act as an alternative for
  images</a> section.</p>

  <p>The problem with this is that the user agent does not necessarily know what dimensions to use
  for the image when the image is loading. To avoid the layout having to be reflowed multiple times
  as the page is loading, CSS and CSS media queries can be used to provide the dimensions:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
 <c- p="">#</c-><c- nn="">a</c-> <c- p="">{</c-> <c- k="">width</c-><c- p="">:</c-> <c- mi="">300</c-><c- b="">px</c-><c- p="">;</c-> <c- k="">height</c-><c- p="">:</c-> <c- mi="">150</c-><c- b="">px</c-><c- p="">;</c-> <c- p="">}</c->
 <c- p="">@</c-><c- k="">media</c-> <c- o="">(</c-><c- f="">max-width</c-><c- o="">:</c-> <c- f="">600px</c-><c- o="">)</c-> <c- p="">{</c-> <c- p="">#</c-><c- nn="">a</c-> <c- p="">{</c-> <c- k="">width</c-><c- p="">:</c-> <c- mi="">100</c-><c- b="">px</c-><c- p="">;</c-> <c- k="">height</c-><c- p="">:</c-> <c- mi="">100</c-><c- b="">px</c-><c- p="">;</c-> <c- p="">}</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"a-square.png"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 600px)"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"a-rectangle.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Barney Frank wears a suit and glasses."</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Barney Frank, 2011<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

  <p>Alternatively, the <code id="adaptive-images:attr-dim-width"><a href="#attr-dim-width">width</a></code> and <code id="adaptive-images:attr-dim-height"><a href="#attr-dim-height">height</a></code> attributes can be used on the <code id="adaptive-images:the-source-element"><a href="#the-source-element">source</a></code> and
  <code id="adaptive-images:the-img-element-2"><a href="#the-img-element">img</a></code> elements to provide the width and height:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"a-square.png"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 600px)"</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">"100"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"100"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"a-rectangle.png"</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">"300"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"150"</c->
  <c- e="">alt</c-><c- o="">=</c-><c- s="">"Barney Frank wears a suit and glasses."</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Barney Frank, 2011<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
</code></pre>

  <hr>

  <p>The <code id="adaptive-images:the-img-element-3"><a href="#the-img-element">img</a></code> element is used with the <code id="adaptive-images:attr-img-src"><a href="#attr-img-src">src</a></code> attribute,
  which gives the URL of the image to use for legacy user agents that do not support the
  <code id="adaptive-images:the-picture-element-2"><a href="#the-picture-element">picture</a></code> element. This leads to a question of which image to provide in the <code id="adaptive-images:attr-img-src-2"><a href="#attr-img-src">src</a></code> attribute.</p>

  <p>If the author wants the biggest image in legacy user agents, the markup could be as
  follows:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-mobile.jpeg"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 720px)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-tablet.jpeg"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 1280px)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"pear-desktop.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The pear is juicy."</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c-></code></pre>

  <p>However, if legacy mobile user agents are more important, one can list all three images in the
  <code id="adaptive-images:the-source-element-2"><a href="#the-source-element">source</a></code> elements, overriding the <code id="adaptive-images:attr-img-src-3"><a href="#attr-img-src">src</a></code> attribute
  entirely.</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-mobile.jpeg"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 720px)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-tablet.jpeg"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 1280px)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-desktop.jpeg"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"pear-mobile.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The pear is juicy."</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c-></code></pre>

  <p>Since at this point the <code id="adaptive-images:attr-img-src-4"><a href="#attr-img-src">src</a></code> attribute is actually being
  ignored entirely by <code id="adaptive-images:the-picture-element-3"><a href="#the-picture-element">picture</a></code>-supporting user agents, the <code id="adaptive-images:attr-img-src-5"><a href="#attr-img-src">src</a></code> attribute can default to any image, including one that is neither
  the smallest nor biggest:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-mobile.jpeg"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 720px)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-tablet.jpeg"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(max-width: 1280px)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-desktop.jpeg"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"pear-tablet.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The pear is juicy."</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c-></code></pre>

  <hr>

  <p>Above the <code>max-width</code> media feature is used, giving the maximum
  (<a id="adaptive-images:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>) dimensions that an image is intended for. It is also possible to use <code>min-width</code> instead.</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">picture</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-desktop.jpeg"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(min-width: 1281px)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">source</c-> <c- e="">srcset</c-><c- o="">=</c-><c- s="">"pear-tablet.jpeg"</c-> <c- e="">media</c-><c- o="">=</c-><c- s="">"(min-width: 721px)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"pear-mobile.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The pear is juicy."</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">picture</c-><c- p="">&gt;</c-></code></pre>


  <h5 id="attributes-common-to-source-and-img-elements"><span class="secno">4.8.4.2</span> Attributes common to <code id="attributes-common-to-source-and-img-elements:the-source-element"><a href="#the-source-element">source</a></code>,
  <code id="attributes-common-to-source-and-img-elements:the-img-element"><a href="#the-img-element">img</a></code>, and <code id="attributes-common-to-source-and-img-elements:the-link-element"><a href="#the-link-element">link</a></code> elements<a href="#attributes-common-to-source-and-img-elements" class="self-link"></a></h5>

  <h6 id="srcset-attributes"><span class="secno">4.8.4.2.1</span> Srcset attributes<a href="#srcset-attributes" class="self-link"></a></h6>

  <p>A <dfn id="srcset-attribute">srcset attribute</dfn> is an attribute with requirements defined in this section.</p>

  <p>If present, its value must consist of one or more <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string">image
  candidate strings</a>, each separated from the next by a U+002C COMMA character (,). If an
  <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-2">image candidate string</a> contains no descriptors and no <a id="srcset-attributes:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>
  after the URL, the following <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-3">image candidate string</a>, if there is one, must begin with
  one or more <a id="srcset-attributes:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p>

  <div data-algorithm="">
  <p>An <dfn id="image-candidate-string">image candidate string</dfn> consists of the following components, in order, with the
  further restrictions described below this list:</p>

  <ol><li><p>Zero or more <a id="srcset-attributes:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p></li><li><p>A <a href="#valid-non-empty-url" id="srcset-attributes:valid-non-empty-url">valid non-empty URL</a> that does not start or end with a U+002C COMMA
   character (,), referencing a non-interactive, optionally animated, image resource that is neither
   paged nor scripted.</p></li><li><p>Zero or more <a id="srcset-attributes:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p></li><li>
    <p>Zero or one of the following:</p>

    <ul><li><p>A <dfn id="width-descriptor">width descriptor</dfn>, consisting of: <a id="srcset-attributes:space-characters-5" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, a
     <a href="#valid-non-negative-integer" id="srcset-attributes:valid-non-negative-integer">valid non-negative integer</a> giving a number greater than zero representing the
     <dfn id="width-descriptor-value">width descriptor value</dfn>, and a U+0077 LATIN SMALL LETTER W character.</p></li><li><p>A <dfn id="pixel-density-descriptor">pixel density descriptor</dfn>, consisting of: <a id="srcset-attributes:space-characters-6" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, a
     <a href="#valid-floating-point-number" id="srcset-attributes:valid-floating-point-number">valid floating-point number</a> giving a number greater than zero representing the
     <dfn id="pixel-density-descriptor-value">pixel density descriptor value</dfn>, and a U+0078 LATIN SMALL LETTER X
     character.</p></li></ul>
   </li><li><p>Zero or more <a id="srcset-attributes:space-characters-7" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p></li></ol>
  </div>

  <p>There must not be an <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-4">image candidate string</a> for an element that has the same
  <a href="#width-descriptor-value" id="srcset-attributes:width-descriptor-value">width descriptor value</a> as another <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-5">image candidate string</a>'s <a href="#width-descriptor-value" id="srcset-attributes:width-descriptor-value-2">width
  descriptor value</a> for the same element.</p>

  <p>There must not be an <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-6">image candidate string</a> for an element that has the same
  <a href="#pixel-density-descriptor-value" id="srcset-attributes:pixel-density-descriptor-value">pixel density descriptor value</a> as another <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-7">image candidate string</a>'s
  <a href="#pixel-density-descriptor-value" id="srcset-attributes:pixel-density-descriptor-value-2">pixel density descriptor value</a> for the same element. For the purpose of this
  requirement, an <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-8">image candidate string</a> with no descriptors is equivalent to an
  <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-9">image candidate string</a> with a <code>1x</code> descriptor.</p>

  <p>If an <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-10">image candidate string</a> for an element has the <a href="#width-descriptor" id="srcset-attributes:width-descriptor">width descriptor</a>
  specified, all other <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-11">image candidate strings</a> for that
  element must also have the <a href="#width-descriptor" id="srcset-attributes:width-descriptor-2">width descriptor</a> specified.</p>

  <p>The specified width in an <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-12">image candidate string</a>'s <a href="#width-descriptor" id="srcset-attributes:width-descriptor-3">width descriptor</a>
  must match the <a id="srcset-attributes:natural-width" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> in the resource given by the
  <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-13">image candidate string</a>'s URL, if it has a <a id="srcset-attributes:natural-width-2" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a>.</p>

  <p>If an element has a <a href="#sizes-attribute" id="srcset-attributes:sizes-attribute">sizes attribute</a> present, all <a href="#image-candidate-string" id="srcset-attributes:image-candidate-string-14">image candidate strings</a> for that element must have the <a href="#width-descriptor" id="srcset-attributes:width-descriptor-4">width
  descriptor</a> specified.</p>


  <h6 id="sizes-attributes"><span class="secno">4.8.4.2.2</span> Sizes attributes<a href="#sizes-attributes" class="self-link"></a></h6>

  <p>A <dfn id="sizes-attribute">sizes attribute</dfn> is an attribute with requirements defined in this section.</p>

  <p>If present, the value must be a <a href="#valid-source-size-list" id="sizes-attributes:valid-source-size-list">valid source size list</a>.</p>

  <div data-algorithm="">
  <p>A <dfn id="valid-source-size-list">valid source size list</dfn> is a string that matches the following grammar:
  <a href="#refsCSSVALUES">[CSSVALUES]</a> <a href="#refsMQ">[MQ]</a></p>

<pre><code class="html"><dfn id="source-size-list" data-dfn-type="type"><c- p="">&lt;</c-><c- f="">source-size-list</c-><c- p="">&gt;</c-></dfn> = <a href="#source-size" id="sizes-attributes:source-size"><c- p="">&lt;</c-><c- f="">source-size</c-><c- p="">&gt;</c-></a>#? , <a href="#source-size-value" id="sizes-attributes:source-size-value"><c- p="">&lt;</c-><c- f="">source-size-value</c-><c- p="">&gt;</c-></a>
<dfn id="source-size" data-dfn-type="type"><c- p="">&lt;</c-><c- f="">source-size</c-><c- p="">&gt;</c-></dfn> = <a id="sizes-attributes:media-condition" href="https://drafts.csswg.org/mediaqueries/#typedef-media-condition" data-x-internal="media-condition"><c- p="">&lt;</c-><c- f="">media-condition</c-><c- p="">&gt;</c-></a> <a href="#source-size-value" id="sizes-attributes:source-size-value-2"><c- p="">&lt;</c-><c- f="">source-size-value</c-><c- p="">&gt;</c-></a> | <a href="#valdef-sizes-auto" id="sizes-attributes:valdef-sizes-auto">auto</a>
<dfn id="source-size-value" data-dfn-type="type"><c- p="">&lt;</c-><c- f="">source-size-value</c-><c- p="">&gt;</c-></dfn> = <a id="sizes-attributes:length-2" href="https://drafts.csswg.org/css-values/#lengths" data-x-internal="length-2"><c- p="">&lt;</c-><c- f="">length</c-><c- p="">&gt;</c-></a> | <a href="#valdef-sizes-auto" id="sizes-attributes:valdef-sizes-auto-2">auto</a></code></pre>

  <p>A <a href="#source-size-value" id="sizes-attributes:source-size-value-3">&lt;source-size-value&gt;</a> that is a <a id="sizes-attributes:length-2-2" href="https://drafts.csswg.org/css-values/#lengths" data-x-internal="length-2">&lt;length&gt;</a> must not be negative,
  and must not use CSS functions other than the <a id="sizes-attributes:math-functions" href="https://drafts.csswg.org/css-values/#math-function" data-x-internal="math-functions">math functions</a>.</p>
  </div>

  <p>The keyword <dfn id="valdef-sizes-auto"><code>auto</code></dfn> is a width that is
  computed in <a href="#parse-a-sizes-attribute" id="sizes-attributes:parse-a-sizes-attribute">parse a sizes attribute</a>. If present, it must be the first entry and the
  entire <a href="#source-size-list" id="sizes-attributes:source-size-list">&lt;source-size-list&gt;</a> value must either be the string "<code>auto</code>" (<a id="sizes-attributes:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>) or start with the string "<code>auto,</code>" (<a id="sizes-attributes:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>).</p>

  <p class="note">If the <code id="sizes-attributes:the-img-element"><a href="#the-img-element">img</a></code> element that initiated the image loading (with the
  <a href="#update-the-image-data" id="sizes-attributes:update-the-image-data">update the image data</a> or <a href="#img-environment-changes" id="sizes-attributes:img-environment-changes">react to environment
  changes</a> algorithms) <a href="#allows-auto-sizes" id="sizes-attributes:allows-auto-sizes">allows auto-sizes</a> and is <a href="#being-rendered" id="sizes-attributes:being-rendered">being rendered</a>,
  then <code id="sizes-attributes:valdef-sizes-auto-3"><a href="#valdef-sizes-auto">auto</a></code> is the <a id="sizes-attributes:concrete-object-size" href="https://drafts.csswg.org/css-images/#concrete-object-size" data-x-internal="concrete-object-size">concrete object size</a> width.
  Otherwise, the <code id="sizes-attributes:valdef-sizes-auto-4"><a href="#valdef-sizes-auto">auto</a></code> value is ignored and the next
  <a href="#source-size-2" id="sizes-attributes:source-size-2">source size</a> is used instead, if any.</p>

  <p>The <code id="sizes-attributes:valdef-sizes-auto-5"><a href="#valdef-sizes-auto">auto</a></code> keyword may be specified in the <code id="sizes-attributes:attr-source-sizes"><a href="#attr-source-sizes">sizes</a></code> attribute of <code id="sizes-attributes:the-source-element"><a href="#the-source-element">source</a></code> elements and <code id="sizes-attributes:attr-img-sizes"><a href="#attr-img-sizes">sizes</a></code> attribute of <code id="sizes-attributes:the-img-element-2"><a href="#the-img-element">img</a></code> elements, if the following
  conditions are met. Otherwise, <code id="sizes-attributes:valdef-sizes-auto-6"><a href="#valdef-sizes-auto">auto</a></code> must not be
  specified.</p>

  <ul><li><p>The element is a <code id="sizes-attributes:the-source-element-2"><a href="#the-source-element">source</a></code> element with a following sibling
   <code id="sizes-attributes:the-img-element-3"><a href="#the-img-element">img</a></code> element.</p></li><li><p>The element is an <code id="sizes-attributes:the-img-element-4"><a href="#the-img-element">img</a></code> element.</p></li><li><p>The <code id="sizes-attributes:the-img-element-5"><a href="#the-img-element">img</a></code> element referenced in either condition above <a href="#allows-auto-sizes" id="sizes-attributes:allows-auto-sizes-2">allows
   auto-sizes</a>.</p></li></ul>

  <p class="note">In addition, it is strongly encouraged to specify dimensions using the <code id="sizes-attributes:attr-dim-width"><a href="#attr-dim-width">width</a></code> and <code id="sizes-attributes:attr-dim-height"><a href="#attr-dim-height">height</a></code> attributes
  or with CSS. Without specified dimensions, the image will likely render with 300x150 dimensions
  because <code>sizes="auto"</code> implies <code>contain-intrinsic-size: 300px
  150px</code> in <a href="#img-contain-size">the Rendering section</a>.</p>

  <p>The <a href="#source-size-value" id="sizes-attributes:source-size-value-4">&lt;source-size-value&gt;</a> gives the intended layout width of the image. The
  author can specify different widths for different environments with
  <a id="sizes-attributes:media-condition-2" href="https://drafts.csswg.org/mediaqueries/#typedef-media-condition" data-x-internal="media-condition">&lt;media-condition&gt;</a>s.</p>

  <p class="note">Percentages are not allowed in a <a href="#source-size-value" id="sizes-attributes:source-size-value-5">&lt;source-size-value&gt;</a>,
  to avoid confusion about what it would be relative to.
  The <a id="sizes-attributes:'vw'" href="https://drafts.csswg.org/css-values/#vw" data-x-internal="'vw'">'vw'</a> unit can be used for sizes relative to the <a id="sizes-attributes:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>
  width.</p>

  

  <h5 id="images-processing-model"><span class="secno">4.8.4.3</span> Processing model<a href="#images-processing-model" class="self-link"></a></h5>

  <hr>

  <p>An <code id="images-processing-model:the-img-element"><a href="#the-img-element">img</a></code> element has a <dfn id="current-request">current request</dfn> and a <dfn id="pending-request">pending request</dfn>.
  The <a href="#current-request" id="images-processing-model:current-request">current request</a> is initially set to a new <a href="#image-request" id="images-processing-model:image-request">image request</a>.
  The <a href="#pending-request" id="images-processing-model:pending-request">pending request</a> is initially set to null.</p>

  <p>An <dfn id="image-request" data-export="">image request</dfn> has a <dfn data-dfn-for="image request" id="img-req-state" data-export="">state</dfn>, <dfn data-dfn-for="image request" id="img-req-url" data-export="">current URL</dfn>, and <dfn data-dfn-for="image request" id="img-req-data" data-export="">image data</dfn>.</p>

  <p>An <a href="#image-request" id="images-processing-model:image-request-2">image request</a>'s <a href="#img-req-state" id="images-processing-model:img-req-state">state</a> is one of the
  following:</p>

  <dl><dt><dfn id="img-none">Unavailable</dfn></dt><dd>The user agent hasn't obtained any image data,
   or has obtained some or all of the image data but
   hasn't yet decoded enough of the image to get the image dimensions.</dd><dt><dfn id="img-inc">Partially available</dfn></dt><dd>The user agent has obtained some of the image data and at least the image dimensions are
   available.</dd><dt><dfn id="img-all">Completely available</dfn></dt><dd>The user agent has obtained all of the image data and at least the image dimensions are
   available.</dd><dt><dfn id="img-error">Broken</dfn></dt><dd>The user agent has obtained all of the image data that it can, but it cannot even decode the
   image enough to get the image dimensions (e.g. the image is corrupted, or the format is not
   supported, or no data could be obtained).</dd></dl>

  <p>An <a href="#image-request" id="images-processing-model:image-request-3">image request</a>'s <a href="#img-req-url" id="images-processing-model:img-req-url">current URL</a> is initially the
  empty string.</p>

  <p>An <a href="#image-request" id="images-processing-model:image-request-4">image request</a>'s <a href="#img-req-data" id="images-processing-model:img-req-data">image data</a> is the decoded
  image data.</p>

  <div data-algorithm="">
  <p>When an <a href="#image-request" id="images-processing-model:image-request-5">image request</a>'s <a href="#img-req-state" id="images-processing-model:img-req-state-2">state</a> is either <a href="#img-inc" id="images-processing-model:img-inc">partially available</a> or <a href="#img-all" id="images-processing-model:img-all">completely available</a>,
  the <a href="#image-request" id="images-processing-model:image-request-6">image request</a> is said to be <dfn id="img-available">available</dfn>.</p>
  </div>

  <div data-algorithm="">
  <p>When an <code id="images-processing-model:the-img-element-2"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="images-processing-model:current-request-2">current request</a>'s <a href="#img-req-state" id="images-processing-model:img-req-state-3">state</a> is <a href="#img-all" id="images-processing-model:img-all-2">completely available</a> and the
  user agent can decode the media data without errors, then the <code id="images-processing-model:the-img-element-3"><a href="#the-img-element">img</a></code> element is said to
  be <dfn id="img-good">fully decodable</dfn>.</p>
  </div>

  <p>An <a href="#image-request" id="images-processing-model:image-request-7">image request</a>'s <a href="#img-req-state" id="images-processing-model:img-req-state-4">state</a> is initially <a href="#img-none" id="images-processing-model:img-none">unavailable</a>.</p>

  <p>When an <code id="images-processing-model:the-img-element-4"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="images-processing-model:current-request-3">current request</a> is <a href="#img-available" id="images-processing-model:img-available">available</a>, the <code id="images-processing-model:the-img-element-5"><a href="#the-img-element">img</a></code> element provides a <a id="images-processing-model:paint-source" href="https://drafts.csswg.org/css-images-4/#paint-source" data-x-internal="paint-source">paint
  source</a> whose width is the image's <a href="#density-corrected-intrinsic-width-and-height" id="images-processing-model:density-corrected-intrinsic-width-and-height">density-corrected natural width</a> (if any), whose height is the image's <a href="#density-corrected-intrinsic-width-and-height" id="images-processing-model:density-corrected-intrinsic-width-and-height-2">density-corrected natural height</a>
  (if any), and whose appearance is the natural appearance of the image.</p>

  <hr>

  <div data-algorithm="">
  <p>An <code id="images-processing-model:the-img-element-6"><a href="#the-img-element">img</a></code> element is said to <dfn id="use-srcset-or-picture">use <code>srcset</code> or
  <code>picture</code></dfn> if it has a <code id="images-processing-model:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code> attribute
  specified or if it has a parent that is a <code id="images-processing-model:the-picture-element"><a href="#the-picture-element">picture</a></code> element.</p>
  </div>

  <hr>

  <p>Each <code id="images-processing-model:the-img-element-7"><a href="#the-img-element">img</a></code> element has a <dfn id="last-selected-source">last selected source</dfn>, which must initially be
  null.</p>

  <p>Each <a href="#image-request" id="images-processing-model:image-request-8">image request</a> has a <dfn id="current-pixel-density">current pixel density</dfn>, which must initially be
  1.</p>

  <p>Each <a href="#image-request" id="images-processing-model:image-request-9">image request</a> has <dfn id="preferred-density-corrected-dimensions">preferred density-corrected dimensions</dfn>, which is
  either a struct consisting of a width and a height or is null. It must initially be null.</p>

  <div data-algorithm="">
  <p>To determine the <dfn id="density-corrected-intrinsic-width-and-height">density-corrected
  natural width and height</dfn> of an <code id="images-processing-model:the-img-element-8"><a href="#the-img-element">img</a></code> element <var>img</var>:</p>

  <ol><li>
    <p>Let <var>dim</var> be <var>img</var>'s <a href="#current-request" id="images-processing-model:current-request-4">current request</a>'s <a href="#preferred-density-corrected-dimensions" id="images-processing-model:preferred-density-corrected-dimensions">preferred
    density-corrected dimensions</a>.</p>

    <p class="note">The <a href="#preferred-density-corrected-dimensions" id="images-processing-model:preferred-density-corrected-dimensions-2">preferred density-corrected dimensions</a> are set in the
    <a href="#prepare-an-image-for-presentation" id="images-processing-model:prepare-an-image-for-presentation">prepare an image for presentation</a> algorithm based on meta information in the
    image.</p>
   </li><li><p>If <var>dim</var> is null, set <var>dim</var> to <var>img</var>'s <a id="images-processing-model:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural
   dimensions</a>.</p></li><li><p>Set <var>dim</var>'s width to <var>dim</var>'s width divided by <var>img</var>'s
   <a href="#current-request" id="images-processing-model:current-request-5">current request</a>'s <a href="#current-pixel-density" id="images-processing-model:current-pixel-density">current pixel density</a>.</p></li><li><p>Set <var>dim</var>'s height to <var>dim</var>'s height divided by <var>img</var>'s
   <a href="#current-request" id="images-processing-model:current-request-6">current request</a>'s <a href="#current-pixel-density" id="images-processing-model:current-pixel-density-2">current pixel density</a>.</p></li><li><p>Return <var>dim</var>.</p></li></ol>
  </div>

  <p class="example">For example, if the <a href="#current-pixel-density" id="images-processing-model:current-pixel-density-3">current pixel density</a> is 3.125, that means
  that there are 300 device pixels per <a href="https://drafts.csswg.org/css-values/#in" id="images-processing-model:'in'" data-x-internal="'in'">CSS inch</a>, and thus if the image
  data is 300x600, it has <a href="#density-corrected-intrinsic-width-and-height" id="images-processing-model:density-corrected-intrinsic-width-and-height-3">density-corrected natural width and height</a> of 96 <a href="https://drafts.csswg.org/css-values/#px" id="images-processing-model:'px'" data-x-internal="'px'">CSS pixels</a> by 192 <a href="https://drafts.csswg.org/css-values/#px" id="images-processing-model:'px'-2" data-x-internal="'px'">CSS pixels</a>.</p>

  <p>All <code id="images-processing-model:the-img-element-9"><a href="#the-img-element">img</a></code> and <code id="images-processing-model:the-link-element"><a href="#the-link-element">link</a></code> elements are associated with a <a href="#source-set" id="images-processing-model:source-set">source set</a>.</p>

  <p>A <dfn id="source-set">source set</dfn> is an ordered set of zero or more <a href="#image-source" id="images-processing-model:image-source">image sources</a>
  and a <a href="#source-size-2" id="images-processing-model:source-size-2">source size</a>.</p>

  <p>An <dfn id="image-source">image source</dfn> is a <a id="images-processing-model:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, and optionally either a <a href="#pixel-density-descriptor" id="images-processing-model:pixel-density-descriptor">pixel density
  descriptor</a>, or a <a href="#width-descriptor" id="images-processing-model:width-descriptor">width descriptor</a>.</p>

  <p>A <dfn id="source-size-2">source size</dfn> is a <a href="#source-size-value" id="images-processing-model:source-size-value">&lt;source-size-value&gt;</a>.
  When a <a href="#source-size-2" id="images-processing-model:source-size-2-2">source size</a> has a unit relative to the <a id="images-processing-model:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>,
  it must be interpreted relative to the <code id="images-processing-model:the-img-element-10"><a href="#the-img-element">img</a></code> element's <a id="images-processing-model:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
  <a id="images-processing-model:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>. Other units must be interpreted the same as in Media Queries.
  <a href="#refsMQ">[MQ]</a></p>

  <hr>

  <p>A <dfn id="concept-microsyntax-parse-error">parse error</dfn> for algorithms in this
  section indicates a non-fatal mismatch between input and requirements. User agents are encouraged
  to expose <a href="#concept-microsyntax-parse-error" id="images-processing-model:concept-microsyntax-parse-error">parse error</a>s somehow.</p>

  <hr>

  <p>Whether the image is fetched successfully or not (e.g. whether the response status was an
  <a id="images-processing-model:ok-status" href="https://fetch.spec.whatwg.org/#ok-status" data-x-internal="ok-status">ok status</a>) must be ignored when determining the image's type and whether it is a
  valid image.</p>

  <p class="note">This allows servers to return images with error responses, and have them
  displayed.</p>

  <p id="img-determine-type">The user agent should apply the <a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-images-specifically" id="images-processing-model:content-type-sniffing:-image" data-x-internal="content-type-sniffing:-image">image sniffing rules</a> to determine the type of the image, with the image's <a href="#content-type" id="images-processing-model:content-type">associated Content-Type headers</a> giving the <var>official
  type</var>. If these rules are not applied, then the type of the image must be the type given by
  the image's <a href="#content-type" id="images-processing-model:content-type-2">associated Content-Type headers</a>.</p>

  <p>User agents must not support non-image resources with the <code id="images-processing-model:the-img-element-11"><a href="#the-img-element">img</a></code> element (e.g. XML
  files whose <a id="images-processing-model:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> is an HTML element). User agents must not run executable
  code (e.g. scripts) embedded in the image resource. User agents must only display the first page
  of a multipage resource (e.g. a PDF file). User agents must not allow the resource to act in an
  interactive fashion, but should honour any animation in the resource.</p>

  <p>This specification does not specify which image types are to be supported.</p>


  <h6 id="when-to-obtain-images"><span class="secno">4.8.4.3.1</span> When to obtain images<a href="#when-to-obtain-images" class="self-link"></a></h6>

  <p>By default, images are obtained immediately. User agents may provide users with the option to
  instead obtain them on-demand. (The on-demand option might be used by bandwidth-constrained users,
  for example.)</p>

  <div data-algorithm="">
  <p>When obtaining images immediately, the user agent must synchronously <a href="#update-the-image-data" id="when-to-obtain-images:update-the-image-data">update the image
  data</a> of the <code id="when-to-obtain-images:the-img-element"><a href="#the-img-element">img</a></code> element, with the <i>restart animation</i> flag set if so
  stated, whenever that element is created or has experienced <a href="#relevant-mutations" id="when-to-obtain-images:relevant-mutations">relevant mutations</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When obtaining images on demand, the user agent must <a href="#update-the-image-data" id="when-to-obtain-images:update-the-image-data-2">update the image data</a> of an
  <code id="when-to-obtain-images:the-img-element-2"><a href="#the-img-element">img</a></code> element whenever it needs the image data (i.e., on demand), but only if the
  <code id="when-to-obtain-images:the-img-element-3"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="when-to-obtain-images:current-request">current request</a>'s <a href="#img-req-state" id="when-to-obtain-images:img-req-state">state</a> is <a href="#img-none" id="when-to-obtain-images:img-none">unavailable</a>. When an
  <code id="when-to-obtain-images:the-img-element-4"><a href="#the-img-element">img</a></code> element has experienced <a href="#relevant-mutations" id="when-to-obtain-images:relevant-mutations-2">relevant mutations</a>, if the user agent only
  obtains images on demand, the <code id="when-to-obtain-images:the-img-element-5"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="when-to-obtain-images:current-request-2">current request</a>'s <a href="#img-req-state" id="when-to-obtain-images:img-req-state-2">state</a> must return to <a href="#img-none" id="when-to-obtain-images:img-none-2">unavailable</a>.</p>
  </div>


  <h6 id="reacting-to-dom-mutations"><span class="secno">4.8.4.3.2</span> Reacting to DOM mutations<a href="#reacting-to-dom-mutations" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>The <dfn id="relevant-mutations">relevant mutations</dfn> for an <code id="reacting-to-dom-mutations:the-img-element"><a href="#the-img-element">img</a></code> element are as follows:</p>

  <ul><li><p>The element's <code id="reacting-to-dom-mutations:attr-img-src"><a href="#attr-img-src">src</a></code>, <code id="reacting-to-dom-mutations:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code>, <code id="reacting-to-dom-mutations:attr-dim-width"><a href="#attr-dim-width">width</a></code>, or <code id="reacting-to-dom-mutations:attr-img-sizes"><a href="#attr-img-sizes">sizes</a></code> attributes are set, changed, or removed.</p></li><li><p>The element's <code id="reacting-to-dom-mutations:attr-img-src-2"><a href="#attr-img-src">src</a></code> attribute is set to the same value as the previous value.
   This must set the <i>restart animation</i> flag for the <a href="#update-the-image-data" id="reacting-to-dom-mutations:update-the-image-data">update the image data</a> algorithm.</p></li><li><p>The element's <code id="reacting-to-dom-mutations:attr-img-crossorigin"><a href="#attr-img-crossorigin">crossorigin</a></code> attribute's state is changed.</p></li><li><p>The element's <code id="reacting-to-dom-mutations:attr-img-referrerpolicy"><a href="#attr-img-referrerpolicy">referrerpolicy</a></code> attribute's
   state is changed.</p></li><li><p>The <code id="reacting-to-dom-mutations:the-img-element-2"><a href="#the-img-element">img</a></code> or <code id="reacting-to-dom-mutations:the-source-element"><a href="#the-source-element">source</a></code> <a href="#html-element-insertion-steps" id="reacting-to-dom-mutations:html-element-insertion-steps">HTML element insertion steps</a>,
   <a href="#html-element-removing-steps" id="reacting-to-dom-mutations:html-element-removing-steps">HTML element removing steps</a>, and <a href="#html-element-moving-steps" id="reacting-to-dom-mutations:html-element-moving-steps">HTML element moving steps</a> count the
   mutation as a <a href="#relevant-mutations" id="reacting-to-dom-mutations:relevant-mutations">relevant mutation</a>.</p></li><li><p>The element's parent is a <code id="reacting-to-dom-mutations:the-picture-element"><a href="#the-picture-element">picture</a></code> element and a <code id="reacting-to-dom-mutations:the-source-element-2"><a href="#the-source-element">source</a></code> element
   that is a previous sibling has its <code id="reacting-to-dom-mutations:attr-source-srcset"><a href="#attr-source-srcset">srcset</a></code>, <code id="reacting-to-dom-mutations:attr-source-sizes"><a href="#attr-source-sizes">sizes</a></code>, <code id="reacting-to-dom-mutations:attr-source-media"><a href="#attr-source-media">media</a></code>, <code id="reacting-to-dom-mutations:attr-source-type"><a href="#attr-source-type">type</a></code>, <code id="reacting-to-dom-mutations:attr-dim-width-2"><a href="#attr-dim-width">width</a></code> or <code id="reacting-to-dom-mutations:attr-dim-height"><a href="#attr-dim-height">height</a></code> attributes set, changed, or removed.</p></li><li><p>The element's <a href="https://dom.spec.whatwg.org/#concept-node-adopt-ext" id="reacting-to-dom-mutations:concept-node-adopt-ext" data-x-internal="concept-node-adopt-ext">adopting steps</a> are run.</p></li><li><p>If the element <a href="#allows-auto-sizes" id="reacting-to-dom-mutations:allows-auto-sizes">allows auto-sizes</a>: the element starts or stops <a href="#being-rendered" id="reacting-to-dom-mutations:being-rendered">being
   rendered</a>, or its <a id="reacting-to-dom-mutations:concrete-object-size" href="https://drafts.csswg.org/css-images/#concrete-object-size" data-x-internal="concrete-object-size">concrete object size</a> width changes. This must set the
   <i>maybe omit events</i> flag for the <a href="#update-the-image-data" id="reacting-to-dom-mutations:update-the-image-data-2">update the image data</a> algorithm.</p></li></ul>
  </div>


  <h6 id="the-list-of-available-images"><span class="secno">4.8.4.3.3</span> The list of available images<a href="#the-list-of-available-images" class="self-link"></a></h6>

  <p>Each <code id="the-list-of-available-images:document"><a href="#document">Document</a></code> object must have a <dfn id="list-of-available-images">list of available images</dfn>. Each image
  in this list is identified by a tuple consisting of an <a id="the-list-of-available-images:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a>, a <a href="#cors-settings-attribute" id="the-list-of-available-images:cors-settings-attribute">CORS
  settings attribute</a> mode, and, if the mode is not <a href="#attr-crossorigin-none" id="the-list-of-available-images:attr-crossorigin-none">No
  CORS</a>, an <a href="#concept-origin" id="the-list-of-available-images:concept-origin">origin</a>.
  Each image furthermore has an <dfn id="ignore-higher-layer-caching">ignore higher-layer caching</dfn> flag.
  User agents may copy entries from one <code id="the-list-of-available-images:document-2"><a href="#document">Document</a></code>
  object's <a href="#list-of-available-images" id="the-list-of-available-images:list-of-available-images">list of available images</a> to another at any time (e.g. when the
  <code id="the-list-of-available-images:document-3"><a href="#document">Document</a></code> is created, user agents can add to it all the images that are loaded in
  other <code id="the-list-of-available-images:document-4"><a href="#document">Document</a></code>s), but must not change the keys of entries copied in this way when
  doing so, and must unset the <a href="#ignore-higher-layer-caching" id="the-list-of-available-images:ignore-higher-layer-caching">ignore higher-layer caching</a> flag for the copied entry.
  User agents may also remove images from such lists at any time (e.g. to save
  memory).
  User agents must remove entries in the <a href="#list-of-available-images" id="the-list-of-available-images:list-of-available-images-2">list of available images</a> as appropriate
  given higher-layer caching semantics for the resource (e.g. the HTTP `<code id="the-list-of-available-images:http-cache-control"><a data-x-internal="http-cache-control" href="https://httpwg.org/specs/rfc7234.html#header.cache-control">Cache-Control</a></code>` response header) when the <a href="#ignore-higher-layer-caching" id="the-list-of-available-images:ignore-higher-layer-caching-2">ignore
  higher-layer caching</a> flag is unset.</p>

  <p class="note">The <a href="#list-of-available-images" id="the-list-of-available-images:list-of-available-images-3">list of available images</a> is intended to enable synchronous
  switching when changing the <code id="the-list-of-available-images:attr-img-src"><a href="#attr-img-src">src</a></code> attribute to a URL that has
  previously been loaded, and to avoid re-downloading images in the same document even when they
  don't allow caching per HTTP. It is not used to avoid re-downloading the same image while the
  previous image is still loading.</p>

  <p class="note">The user agent can also store the image data separately from the <a href="#list-of-available-images" id="the-list-of-available-images:list-of-available-images-4">list of available images</a>.</p>

  <p class="example">For example, if a resource has the HTTP response header
  `<code>Cache-Control: must-revalidate</code>`, and its <a href="#ignore-higher-layer-caching" id="the-list-of-available-images:ignore-higher-layer-caching-3">ignore higher-layer
  caching</a> flag is unset, the user agent would remove it from the <a href="#list-of-available-images" id="the-list-of-available-images:list-of-available-images-5">list of available
  images</a> but could keep the image data separately, and use that if the server responds with a
  <code>304 Not Modified</code> status.</p>

  <h6 id="decoding-images"><span class="secno">4.8.4.3.4</span> Decoding images<a href="#decoding-images" class="self-link"></a></h6>

  <p>Image data is usually encoded in order to reduce file size. This means that in order for the
  user agent to present the image to the screen, the data needs to be decoded.
  <dfn id="img-decoding-process">Decoding</dfn> is the process which converts an image's media
  data into a bitmap form, suitable for presentation to the screen. Note that this process can be
  slow relative to other processes involved in presenting content. Thus, the user agent can choose
  when to perform decoding, in order to create the best user experience.</p>

  <p>Image decoding is said to be synchronous if it prevents presentation of other content until it
  is finished. Typically, this has an effect of atomically presenting the image and any other
  content at the same time. However, this presentation is delayed by the amount of time it takes to
  perform the decode.</p>

  <p>Image decoding is said to be asynchronous if it does not prevent presentation of other content.
  This has an effect of presenting non-image content faster. However, the image content is missing
  on screen until the decode finishes. Once the decode is finished, the screen is updated with the
  image.</p>

  <p>In both synchronous and asynchronous decoding modes, the final content is presented to screen
  after the same amount of time has elapsed. The main difference is whether the user agent presents
  non-image content ahead of presenting the final content.</p>

  <p>In order to aid the user agent in deciding whether to perform synchronous or asynchronous
  decode, the <code id="decoding-images:attr-img-decoding"><a href="#attr-img-decoding">decoding</a></code> attribute can be set on
  <code id="decoding-images:the-img-element"><a href="#the-img-element">img</a></code> elements. The possible values of the <code id="decoding-images:attr-img-decoding-2"><a href="#attr-img-decoding">decoding</a></code> attribute are the following <dfn id="image-decoding-hint">image decoding
  hint</dfn> keywords:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="img/decoding" id="attr-img-decoding-sync" data-dfn-type="attr-value"><code>sync</code></dfn>
     </td><td><dfn id="attr-img-decoding-sync-state">Sync</dfn>
     </td><td>Indicates a preference to <a href="#img-decoding-process" id="decoding-images:img-decoding-process">decode</a> this image
     synchronously for atomic presentation with other content.
    </td></tr><tr><td><dfn data-dfn-for="img/decoding" id="attr-img-decoding-async" data-dfn-type="attr-value"><code>async</code></dfn>
     </td><td><dfn id="attr-img-decoding-async-state">Async</dfn>
     </td><td>Indicates a preference to <a href="#img-decoding-process" id="decoding-images:img-decoding-process-2">decode</a> this image
     asynchronously to avoid delaying presentation of other content.
    </td></tr><tr><td><dfn data-dfn-for="img/decoding" id="attr-img-decoding-auto" data-dfn-type="attr-value"><code>auto</code></dfn>
     </td><td><dfn id="attr-img-decoding-auto-state">Auto</dfn>
     </td><td>Indicates no preference in decoding mode (the default).
  </td></tr></tbody></table>

  <p>When <a href="#img-decoding-process" id="decoding-images:img-decoding-process-3">decoding</a> an image, the user agent should
  respect the preference indicated by the <code id="decoding-images:attr-img-decoding-3"><a href="#attr-img-decoding">decoding</a></code>
  attribute's state. If the state indicated is <a href="#attr-img-decoding-auto-state" id="decoding-images:attr-img-decoding-auto-state">Auto</a>, then the user agent is free to choose any
  decoding behavior.</p>

  <p class="note">It is also possible to control the decoding behavior using the <code id="decoding-images:dom-img-decode"><a href="#dom-img-decode">decode()</a></code> method. Since the <code id="decoding-images:dom-img-decode-2"><a href="#dom-img-decode">decode()</a></code> method performs <a href="#img-decoding-process" id="decoding-images:img-decoding-process-4">decoding</a> independently from the process responsible for
  presenting content to screen, it is unaffected by the <code id="decoding-images:attr-img-decoding-4"><a href="#attr-img-decoding">decoding</a></code> attribute.</p>

  <h6 id="updating-the-image-data"><span class="secno">4.8.4.3.5</span> Updating the image data<a href="#updating-the-image-data" class="self-link"></a></h6>

  <p class="note">This algorithm cannot be called from steps running <a href="#in-parallel" id="updating-the-image-data:in-parallel">in parallel</a>. If
  a user agent needs to call this algorithm from steps running <a href="#in-parallel" id="updating-the-image-data:in-parallel-2">in parallel</a>, it needs to
  <a href="#queue-a-task" id="updating-the-image-data:queue-a-task">queue</a> a task to do so.</p>

  <div data-algorithm="">
  <p>When the user agent is to <dfn id="update-the-image-data">update the image data</dfn> of an <code id="updating-the-image-data:the-img-element"><a href="#the-img-element">img</a></code> element,
  optionally with the <i>restart animations</i> flag set, optionally with the <i>maybe omit
  events</i> flag set, it must run the following steps:</p>

  <ol><li>
    <p>If the element's <a id="updating-the-image-data:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="updating-the-image-data:fully-active">fully active</a>, then:</p>

    <ol><li><p>Continue running this algorithm <a href="#in-parallel" id="updating-the-image-data:in-parallel-3">in parallel</a>.</p></li><li><p>Wait until the element's <a id="updating-the-image-data:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is <a href="#fully-active" id="updating-the-image-data:fully-active-2">fully
     active</a>.</p></li><li><p>If another instance of this algorithm for this <code id="updating-the-image-data:the-img-element-2"><a href="#the-img-element">img</a></code> element was started after this instance
     (even if it aborted and is no longer running), then return.</p></li><li><p><a href="#queue-a-microtask" id="updating-the-image-data:queue-a-microtask">Queue a microtask</a> to continue this algorithm.</p></li></ol>
   </li><li><p>If the user agent cannot support images, or its support for images has been disabled, then
   <a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request">abort the image request</a> for the <a href="#current-request" id="updating-the-image-data:current-request">current request</a> and the <a href="#pending-request" id="updating-the-image-data:pending-request">pending
   request</a>, set the <a href="#current-request" id="updating-the-image-data:current-request-2">current request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state">state</a> to
   <a href="#img-none" id="updating-the-image-data:img-none">unavailable</a>, set the <a href="#pending-request" id="updating-the-image-data:pending-request-2">pending request</a> to null, and
   return.</p></li><li><p>Let <var>previousURL</var> be the <a href="#current-request" id="updating-the-image-data:current-request-3">current request</a>'s <a href="#img-req-url" id="updating-the-image-data:img-req-url">current URL</a>.</p></li><li><p>Let <var>selected source</var> be null and <var>selected pixel density</var> be undefined.

   </p></li><li><p>If the element does not <a href="#use-srcset-or-picture" id="updating-the-image-data:use-srcset-or-picture">use <code>srcset</code> or <code>picture</code></a> and
   it has a <code id="updating-the-image-data:attr-img-src"><a href="#attr-img-src">src</a></code> attribute specified whose value is not the empty
   string, then set <var>selected source</var> to the value of the element's <code id="updating-the-image-data:attr-img-src-2"><a href="#attr-img-src">src</a></code> attribute and set <var>selected pixel density</var> to
   1.0.</p></li><li><p>Set the element's <a href="#last-selected-source" id="updating-the-image-data:last-selected-source">last selected source</a> to <var>selected
   source</var>.</p></li><li>
    <p>If <var>selected source</var> is not null, then:</p>

    <ol><li><p>Let <var>urlString</var> be the result of <a href="#encoding-parsing-and-serializing-a-url" id="updating-the-image-data:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing a
     URL</a> given <var>selected source</var>, relative to the element's <a id="updating-the-image-data:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
     document</a>.</p></li><li><p>If <var>urlString</var> is failure, then abort this inner set of steps.</p></li><li><p>Let <var>key</var> be a tuple consisting of <var>urlString</var>, the <code id="updating-the-image-data:the-img-element-3"><a href="#the-img-element">img</a></code>
     element's <code id="updating-the-image-data:attr-img-crossorigin"><a href="#attr-img-crossorigin">crossorigin</a></code> attribute's mode, and, if that
     mode is not <a href="#attr-crossorigin-none" id="updating-the-image-data:attr-crossorigin-none">No CORS</a>, the <a id="updating-the-image-data:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
     document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="updating-the-image-data:concept-document-origin" data-x-internal="concept-document-origin">origin</a>.</p></li><li>
      <p>If the <a href="#list-of-available-images" id="updating-the-image-data:list-of-available-images">list of available images</a> contains an entry for <var>key</var>,
      then:</p>

      <ol><li><p>Set the <a href="#ignore-higher-layer-caching" id="updating-the-image-data:ignore-higher-layer-caching">ignore higher-layer caching</a> flag for that entry.</p></li><li><p><a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-2">Abort the image request</a> for the <a href="#current-request" id="updating-the-image-data:current-request-4">current request</a> and the
       <a href="#pending-request" id="updating-the-image-data:pending-request-3">pending request</a>.</p></li><li><p>Set the <a href="#pending-request" id="updating-the-image-data:pending-request-4">pending request</a> to null.</p></li><li><p>Set the <a href="#current-request" id="updating-the-image-data:current-request-5">current request</a> to a new <a href="#image-request" id="updating-the-image-data:image-request">image request</a> whose <a href="#img-req-data" id="updating-the-image-data:img-req-data">image data</a> is that of the entry and whose <a href="#img-req-state" id="updating-the-image-data:img-req-state-2">state</a> is <a href="#img-all" id="updating-the-image-data:img-all">completely
       available</a>.</p></li><li><p><a href="#prepare-an-image-for-presentation" id="updating-the-image-data:prepare-an-image-for-presentation">Prepare the <span>current request</span>
       for presentation</a> given the <code id="updating-the-image-data:the-img-element-4"><a href="#the-img-element">img</a></code> element.</p></li><li><p>Set the <a href="#current-request" id="updating-the-image-data:current-request-6">current request</a>'s <a href="#current-pixel-density" id="updating-the-image-data:current-pixel-density">current pixel density</a> to <var>selected
       pixel density</var>.</p></li><li>
        <p><a href="#queue-an-element-task" id="updating-the-image-data:queue-an-element-task">Queue an element task</a> on the <a href="#dom-manipulation-task-source" id="updating-the-image-data:dom-manipulation-task-source">DOM manipulation task source</a>
        given the <code id="updating-the-image-data:the-img-element-5"><a href="#the-img-element">img</a></code> element and the following steps:</p>

        <ol><li><p>If <i>restart animation</i> is set, then <a href="#restart-the-animation" id="updating-the-image-data:restart-the-animation">restart the
         animation</a>.</p></li><li><p>Set the <a href="#current-request" id="updating-the-image-data:current-request-7">current request</a>'s <a href="#img-req-url" id="updating-the-image-data:img-req-url-2">current URL</a> to
         <var>urlString</var>.</p></li><li><p>If <i>maybe omit events</i> is not set or <var>previousURL</var> is not equal to
         <var>urlString</var>, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-image-data:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named
         <code id="updating-the-image-data:event-load"><a href="#event-load">load</a></code> at the <code id="updating-the-image-data:the-img-element-6"><a href="#the-img-element">img</a></code> element.</p></li></ol>
       </li><li><p>Abort the <a href="#update-the-image-data" id="updating-the-image-data:update-the-image-data">update the image data</a> algorithm.</p></li></ol>
     </li></ol>
   </li><li><p><a href="#queue-a-microtask" id="updating-the-image-data:queue-a-microtask-2">Queue a microtask</a> to perform the rest of this algorithm, allowing the <a href="#concept-task" id="updating-the-image-data:concept-task">task</a> that invoked this algorithm to continue.</p></li><li>
    <p>If another instance of this algorithm for this <code id="updating-the-image-data:the-img-element-7"><a href="#the-img-element">img</a></code> element was started after
    this instance (even if it aborted and is no longer running), then return.</p>

    <p class="note">Only the last instance takes effect, to avoid multiple requests when, for
    example, the <code id="updating-the-image-data:attr-img-src-3"><a href="#attr-img-src">src</a></code>, <code id="updating-the-image-data:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code>,
    and <code id="updating-the-image-data:attr-img-crossorigin-2"><a href="#attr-img-crossorigin">crossorigin</a></code> attributes are all set in
    succession.</p>
   </li><li><p>Let <var>selected source</var> and <var>selected pixel density</var> be the URL and pixel
   density that results from <a href="#select-an-image-source" id="updating-the-image-data:select-an-image-source">selecting an image source</a>,
   respectively.</p></li><li>
    <p>If <var>selected source</var> is null, then:</p>

    <ol><li><p>Set the <a href="#current-request" id="updating-the-image-data:current-request-8">current request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-3">state</a> to
     <a href="#img-error" id="updating-the-image-data:img-error">broken</a>, <a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-3">abort the image request</a> for the
     <a href="#current-request" id="updating-the-image-data:current-request-9">current request</a> and the <a href="#pending-request" id="updating-the-image-data:pending-request-5">pending request</a>, and set the <a href="#pending-request" id="updating-the-image-data:pending-request-6">pending
     request</a> to null.</p></li><li>
      <p><a href="#queue-an-element-task" id="updating-the-image-data:queue-an-element-task-2">Queue an element task</a> on the <a href="#dom-manipulation-task-source" id="updating-the-image-data:dom-manipulation-task-source-2">DOM manipulation task source</a> given
      the <code id="updating-the-image-data:the-img-element-8"><a href="#the-img-element">img</a></code> element and the following steps:</p>

      <ol><li><p>Change the <a href="#current-request" id="updating-the-image-data:current-request-10">current request</a>'s <a href="#img-req-url" id="updating-the-image-data:img-req-url-3">current
       URL</a> to the empty string.</p></li><li>
        <p>If all of the following are true:</p>

        <ul><li><p>the element has a <code id="updating-the-image-data:attr-img-src-4"><a href="#attr-img-src">src</a></code> attribute or it <a href="#use-srcset-or-picture" id="updating-the-image-data:use-srcset-or-picture-2">uses <code>srcset</code> or
         <code>picture</code></a>; and</p></li><li><p><i>maybe omit events</i> is not set or <var>previousURL</var> is not the empty
         string,</p></li></ul>

        <p>then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-image-data:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="updating-the-image-data:event-error"><a href="#event-error">error</a></code> at the <code id="updating-the-image-data:the-img-element-9"><a href="#the-img-element">img</a></code> element.</p>
       </li></ol>
     </li><li><p>Return.</p></li></ol>
   </li><li><p>Let <var>urlString</var> be the result of <a href="#encoding-parsing-and-serializing-a-url" id="updating-the-image-data:encoding-parsing-and-serializing-a-url-2">encoding-parsing-and-serializing a
   URL</a> given <var>selected source</var>, relative to the element's <a id="updating-the-image-data:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>.</p></li><li>
    <p>If <var>urlString</var> is failure, then:</p>

    <ol><li><p><a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-4">Abort the image request</a> for the <a href="#current-request" id="updating-the-image-data:current-request-11">current request</a> and the
     <a href="#pending-request" id="updating-the-image-data:pending-request-7">pending request</a>.</p></li><li><p>Set the <a href="#current-request" id="updating-the-image-data:current-request-12">current request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-4">state</a> to
     <a href="#img-error" id="updating-the-image-data:img-error-2">broken</a>.</p></li><li><p>Set the <a href="#pending-request" id="updating-the-image-data:pending-request-8">pending request</a> to null.</p></li><li>
      <p><a href="#queue-an-element-task" id="updating-the-image-data:queue-an-element-task-3">Queue an element task</a> on the <a href="#dom-manipulation-task-source" id="updating-the-image-data:dom-manipulation-task-source-3">DOM manipulation task
      source</a> given the <code id="updating-the-image-data:the-img-element-10"><a href="#the-img-element">img</a></code> element and the following steps:</p>

      <ol><li><p>Change the <a href="#current-request" id="updating-the-image-data:current-request-13">current request</a>'s <a href="#img-req-url" id="updating-the-image-data:img-req-url-4">current
       URL</a> to <var>selected source</var>.</p></li><li><p>If <i>maybe omit events</i> is not set or <var>previousURL</var> is not equal to
       <var>selected source</var>, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-image-data:concept-event-fire-3" data-x-internal="concept-event-fire">fire an event</a>
       named <code id="updating-the-image-data:event-error-2"><a href="#event-error">error</a></code> at the <code id="updating-the-image-data:the-img-element-11"><a href="#the-img-element">img</a></code> element.</p></li></ol>
     </li><li><p>Return.</p></li></ol>
   </li><li><p>If the <a href="#pending-request" id="updating-the-image-data:pending-request-9">pending request</a> is not null and <var>urlString</var> is the same as
   the <a href="#pending-request" id="updating-the-image-data:pending-request-10">pending request</a>'s <a href="#img-req-url" id="updating-the-image-data:img-req-url-5">current URL</a>, then
   return.</p></li><li><p>If <var>urlString</var> is the same as the <a href="#current-request" id="updating-the-image-data:current-request-14">current request</a>'s <a href="#img-req-url" id="updating-the-image-data:img-req-url-6">current URL</a> and the <a href="#current-request" id="updating-the-image-data:current-request-15">current request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-5">state</a> is <a href="#img-inc" id="updating-the-image-data:img-inc">partially available</a>, then
   <a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-5">abort the image request</a> for the <a href="#pending-request" id="updating-the-image-data:pending-request-11">pending request</a>, <a href="#queue-an-element-task" id="updating-the-image-data:queue-an-element-task-4">queue an element
   task</a> on the <a href="#dom-manipulation-task-source" id="updating-the-image-data:dom-manipulation-task-source-4">DOM manipulation task source</a> given the <code id="updating-the-image-data:the-img-element-12"><a href="#the-img-element">img</a></code> element
   to <a href="#restart-the-animation" id="updating-the-image-data:restart-the-animation-2">restart the animation</a> if <i>restart animation</i> is set, and return.</p></li><li><p><a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-6">Abort the image request</a> for the <a href="#pending-request" id="updating-the-image-data:pending-request-12">pending request</a>.</p></li><li><p>Set <var>image request</var> to a new <a href="#image-request" id="updating-the-image-data:image-request-2">image request</a> whose <a href="#img-req-url" id="updating-the-image-data:img-req-url-7">current URL</a> is <var>urlString</var>.</p></li><li><p>If the <a href="#current-request" id="updating-the-image-data:current-request-16">current request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-6">state</a> is <a href="#img-none" id="updating-the-image-data:img-none-2">unavailable</a> or <a href="#img-error" id="updating-the-image-data:img-error-3">broken</a>, then set the
   <a href="#current-request" id="updating-the-image-data:current-request-17">current request</a> to <var>image request</var>. Otherwise, set the <a href="#pending-request" id="updating-the-image-data:pending-request-13">pending
   request</a> to <var>image request</var>.</p></li><li><p>Let <var>request</var> be the result of <a href="#create-a-potential-cors-request" id="updating-the-image-data:create-a-potential-cors-request">creating a potential-CORS request</a> given <var>urlString</var>, "<code>image</code>", and the current state of the element's <code id="updating-the-image-data:attr-img-crossorigin-3"><a href="#attr-img-crossorigin">crossorigin</a></code> content attribute.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="updating-the-image-data:concept-request-client" data-x-internal="concept-request-client">client</a> to the
   element's <a id="updating-the-image-data:node-document-6" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#relevant-settings-object" id="updating-the-image-data:relevant-settings-object">relevant settings object</a>.</p></li><li><p>If the element <a href="#use-srcset-or-picture" id="updating-the-image-data:use-srcset-or-picture-3">uses <code>srcset</code> or
   <code>picture</code></a>, set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-initiator" id="updating-the-image-data:concept-request-initiator" data-x-internal="concept-request-initiator">initiator</a> to "<code>imageset</code>".</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-referrer-policy" id="updating-the-image-data:concept-request-referrer-policy" data-x-internal="concept-request-referrer-policy">referrer
   policy</a> to the current state of the element's <code id="updating-the-image-data:attr-img-referrerpolicy"><a href="#attr-img-referrerpolicy">referrerpolicy</a></code> attribute.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-priority" id="updating-the-image-data:concept-request-priority" data-x-internal="concept-request-priority">priority</a> to the current state of the
   element's <code id="updating-the-image-data:attr-img-fetchpriority"><a href="#attr-img-fetchpriority">fetchpriority</a></code> attribute.</p></li><li><p>Let <var>delay load event</var> be true if the <code id="updating-the-image-data:the-img-element-13"><a href="#the-img-element">img</a></code>'s <a href="#lazy-loading-attribute" id="updating-the-image-data:lazy-loading-attribute">lazy loading
   attribute</a> is in the <a href="#attr-loading-eager-state" id="updating-the-image-data:attr-loading-eager-state">Eager</a> state, or if
   <a href="#concept-n-noscript" id="updating-the-image-data:concept-n-noscript">scripting is disabled</a> for the <code id="updating-the-image-data:the-img-element-14"><a href="#the-img-element">img</a></code>, and
   false otherwise.</p></li><li>
    <p>If the <a href="#will-lazy-load-element-steps" id="updating-the-image-data:will-lazy-load-element-steps">will lazy load element steps</a> given the <code id="updating-the-image-data:the-img-element-15"><a href="#the-img-element">img</a></code> return true,
    then:</p>

    <ol><li><p>Set the <code id="updating-the-image-data:the-img-element-16"><a href="#the-img-element">img</a></code>'s <a href="#lazy-load-resumption-steps" id="updating-the-image-data:lazy-load-resumption-steps">lazy load resumption steps</a> to the rest of this
     algorithm starting with the step labeled <i>fetch the image</i>.</p></li><li><p><a href="#start-intersection-observing-a-lazy-loading-element" id="updating-the-image-data:start-intersection-observing-a-lazy-loading-element">Start intersection-observing a lazy loading element</a> for the
     <code id="updating-the-image-data:the-img-element-17"><a href="#the-img-element">img</a></code> element.</p></li><li><p>Return.</p></li></ol>
   </li><li>
    
    <p><i>Fetch the image</i>: <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="updating-the-image-data:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var>. Return
    from this algorithm, and run the remaining steps as part of the fetch's <i id="updating-the-image-data:processresponse"><a data-x-internal="processresponse" href="https://fetch.spec.whatwg.org/#process-response">processResponse</a></i> for the <a href="https://fetch.spec.whatwg.org/#concept-response" id="updating-the-image-data:concept-response" data-x-internal="concept-response">response</a> <var>response</var>.</p>

    

    <p>The resource obtained in this fashion, if any, is <var>image request</var>'s <a href="#img-req-data" id="updating-the-image-data:img-req-data-2">image data</a>. It can be either <a href="#cors-same-origin" id="updating-the-image-data:cors-same-origin">CORS-same-origin</a> or
    <a href="#cors-cross-origin" id="updating-the-image-data:cors-cross-origin">CORS-cross-origin</a>; this affects the image's interaction with other APIs (e.g.,
    when used on a <code id="updating-the-image-data:the-canvas-element"><a href="#the-canvas-element">canvas</a></code>).</p>

    
    <p>When <var>delay load event</var> is true, fetching the image must <a href="#delay-the-load-event" id="updating-the-image-data:delay-the-load-event">delay the load
    event</a> of the element's <a id="updating-the-image-data:node-document-7" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> until the <a href="#concept-task" id="updating-the-image-data:concept-task-2">task</a> that is <a href="#queue-a-task" id="updating-the-image-data:queue-a-task-2">queued</a> by the
    <a href="#networking-task-source" id="updating-the-image-data:networking-task-source">networking task source</a> once the resource has been fetched (<a href="#img-load">defined below</a>) has been run.
    </p>

    <p class="warning">This, unfortunately, can be used to perform a rudimentary port scan of the
    user's local network (especially in conjunction with scripting, though scripting isn't actually
    necessary to carry out such an attack). User agents may implement <a href="#concept-origin" id="updating-the-image-data:concept-origin">cross-origin</a> access control policies that are stricter than those
    described above to mitigate this attack, but unfortunately such policies are typically not
    compatible with existing web content.</p>
   </li><li>
    <p>As soon as possible, jump to the first applicable entry from the following list:</p>

    <dl class="switch"><dt>If the resource type is <code id="updating-the-image-data:multipart/x-mixed-replace"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code></dt><dd>
      <p>The next <a href="#concept-task" id="updating-the-image-data:concept-task-3">task</a> that is <a href="#queue-a-task" id="updating-the-image-data:queue-a-task-3">queued</a> by the <a href="#networking-task-source" id="updating-the-image-data:networking-task-source-2">networking task source</a> while the image is being
      fetched must run the following steps:</p>

      <ol><li>
        <p>If <var>image request</var> is the <a href="#pending-request" id="updating-the-image-data:pending-request-14">pending request</a>
        and at least one body part has been completely decoded,
        <a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-7">abort the image request</a> for the <a href="#current-request" id="updating-the-image-data:current-request-18">current request</a>,
        and <a href="#upgrade-the-pending-request-to-the-current-request" id="updating-the-image-data:upgrade-the-pending-request-to-the-current-request">upgrade the pending request to the current request</a>.</p>
       </li><li><p>Otherwise, if <var>image request</var> is the <a href="#pending-request" id="updating-the-image-data:pending-request-15">pending request</a> and the
       user agent is able to determine that <var>image request</var>'s image is corrupted in some
       fatal way such that the image dimensions cannot be obtained, <a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-8">abort the image
       request</a> for the <a href="#current-request" id="updating-the-image-data:current-request-19">current request</a>, <a href="#upgrade-the-pending-request-to-the-current-request" id="updating-the-image-data:upgrade-the-pending-request-to-the-current-request-2">upgrade the pending request to the
       current request</a>, and set the <a href="#current-request" id="updating-the-image-data:current-request-20">current request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-7">state</a> to <a href="#img-error" id="updating-the-image-data:img-error-4">broken</a>.</p></li><li><p>Otherwise, if <var>image request</var> is the <a href="#current-request" id="updating-the-image-data:current-request-21">current request</a>, its <a href="#img-req-state" id="updating-the-image-data:img-req-state-8">state</a> is <a href="#img-none" id="updating-the-image-data:img-none-3">unavailable</a>, and the
       user agent is able to determine <var>image request</var>'s image's width and height, set the
       <a href="#current-request" id="updating-the-image-data:current-request-22">current request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-9">state</a> to <a href="#img-inc" id="updating-the-image-data:img-inc-2">partially available</a>.</p></li><li><p>Otherwise, if <var>image request</var> is the <a href="#current-request" id="updating-the-image-data:current-request-23">current request</a>, its <a href="#img-req-state" id="updating-the-image-data:img-req-state-10">state</a> is <a href="#img-none" id="updating-the-image-data:img-none-4">unavailable</a>, and the
       user agent is able to determine that <var>image request</var>'s image is corrupted in some
       fatal way such that the image dimensions cannot be obtained, set the <a href="#current-request" id="updating-the-image-data:current-request-24">current
       request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-11">state</a> to <a href="#img-error" id="updating-the-image-data:img-error-5">broken</a>.
       </p>
       </li></ol>

      <p>Each <a href="#concept-task" id="updating-the-image-data:concept-task-4">task</a> that is <a href="#queue-a-task" id="updating-the-image-data:queue-a-task-4">queued</a> by the <a href="#networking-task-source" id="updating-the-image-data:networking-task-source-3">networking task source</a> while the image is being
      fetched must update the presentation of the image, but as each new body part comes in, if the
      user agent is able to determine the image's width and height, it must <a href="#prepare-an-image-for-presentation" id="updating-the-image-data:prepare-an-image-for-presentation-2">prepare the <code>img</code> element's <span>current request</span>
      for presentation</a> given the <code id="updating-the-image-data:the-img-element-18"><a href="#the-img-element">img</a></code> element and replace the previous image.
      Once one body part has been completely decoded, perform the following steps:</p>

      <ol><li><p>Set the <code id="updating-the-image-data:the-img-element-19"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="updating-the-image-data:current-request-25">current request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-12">state</a> to <a href="#img-all" id="updating-the-image-data:img-all-2">completely
       available</a>.</p></li><li><p>If <i>maybe omit events</i> is not set or <var>previousURL</var> is not equal to
       <var>urlString</var>, then <a href="#queue-an-element-task" id="updating-the-image-data:queue-an-element-task-5">queue an element task</a> on the <a href="#dom-manipulation-task-source" id="updating-the-image-data:dom-manipulation-task-source-5">DOM manipulation task source</a>
       given the <code id="updating-the-image-data:the-img-element-20"><a href="#the-img-element">img</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-image-data:concept-event-fire-4" data-x-internal="concept-event-fire">fire an event</a>
       named <code id="updating-the-image-data:event-load-2"><a href="#event-load">load</a></code> at the <code id="updating-the-image-data:the-img-element-21"><a href="#the-img-element">img</a></code> element.</p></li></ol>
      
     </dd><dt>If the resource type and data corresponds to a supported image format, <a href="#img-determine-type">as described below</a></dt><dd>
      <p>The next <a href="#concept-task" id="updating-the-image-data:concept-task-5">task</a> that is <a href="#queue-a-task" id="updating-the-image-data:queue-a-task-5">queued</a> by the <a href="#networking-task-source" id="updating-the-image-data:networking-task-source-4">networking task source</a> while the image is being
      fetched must run the following steps:</p>

      <ol><li><p>If the user agent is able to determine <var>image request</var>'s image's width and
       height, and <var>image request</var> is the <a href="#pending-request" id="updating-the-image-data:pending-request-16">pending request</a>, set <var>image
       request</var>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-13">state</a> to <a href="#img-inc" id="updating-the-image-data:img-inc-3">partially
       available</a>.</p></li><li><p>Otherwise, if the user agent is able to determine <var>image request</var>'s image's
       width and height, and <var>image request</var> is the <a href="#current-request" id="updating-the-image-data:current-request-26">current request</a>, <a href="#prepare-an-image-for-presentation" id="updating-the-image-data:prepare-an-image-for-presentation-3">prepare <var>image request</var> for
       presentation</a> given the <code id="updating-the-image-data:the-img-element-22"><a href="#the-img-element">img</a></code> element and set <var>image request</var>'s
       <a href="#img-req-state" id="updating-the-image-data:img-req-state-14">state</a> to <a href="#img-inc" id="updating-the-image-data:img-inc-4">partially
       available</a>.</p></li><li>
        <p>Otherwise, if the user agent is able to determine that <var>image request</var>'s image
        is corrupted in some fatal way such that the image dimensions cannot be obtained, and
        <var>image request</var> is the <a href="#pending-request" id="updating-the-image-data:pending-request-17">pending request</a>:</p>

        <ol><li><p><a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-9">Abort the image request</a> for the <a href="#current-request" id="updating-the-image-data:current-request-27">current request</a> and the
         <a href="#pending-request" id="updating-the-image-data:pending-request-18">pending request</a>.</p></li><li><p><a href="#upgrade-the-pending-request-to-the-current-request" id="updating-the-image-data:upgrade-the-pending-request-to-the-current-request-3">Upgrade the pending request to the current request</a>.</p></li><li><p>Set the <a href="#current-request" id="updating-the-image-data:current-request-28">current request</a>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-15">state</a> to
         <a href="#img-error" id="updating-the-image-data:img-error-6">broken</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-image-data:concept-event-fire-5" data-x-internal="concept-event-fire">Fire an event</a> named <code id="updating-the-image-data:event-error-3"><a href="#event-error">error</a></code> at the <code id="updating-the-image-data:the-img-element-23"><a href="#the-img-element">img</a></code> element.</p></li></ol>
       </li><li>
        <p>Otherwise, if the user agent is able to determine that <var>image request</var>'s image
        is corrupted in some fatal way such that the image dimensions cannot be obtained, and
        <var>image request</var> is the <a href="#current-request" id="updating-the-image-data:current-request-29">current request</a>:</p>

        <ol><li><p><a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-10">Abort the image request</a> for <var>image request</var>.</p></li><li><p>If <i>maybe omit events</i> is not set or <var>previousURL</var> is not equal to
         <var>urlString</var>, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-image-data:concept-event-fire-6" data-x-internal="concept-event-fire">fire an event</a> named
         <code id="updating-the-image-data:event-error-4"><a href="#event-error">error</a></code> at the <code id="updating-the-image-data:the-img-element-24"><a href="#the-img-element">img</a></code> element.</p></li></ol>
       </li></ol>

      <p id="img-load">That <a href="#concept-task" id="updating-the-image-data:concept-task-6">task</a>, and each subsequent <a href="#concept-task" id="updating-the-image-data:concept-task-7">task</a>, that is <a href="#queue-a-task" id="updating-the-image-data:queue-a-task-6">queued</a> by the
      <a href="#networking-task-source" id="updating-the-image-data:networking-task-source-5">networking task source</a> while the image is being fetched, if <var>image
      request</var> is the <a href="#current-request" id="updating-the-image-data:current-request-30">current request</a>, must update the presentation of the image
      appropriately (e.g., if the image is a progressive JPEG, each packet can improve the
      resolution of the image).</p>

      <p>Furthermore, the last <a href="#concept-task" id="updating-the-image-data:concept-task-8">task</a> that is <a href="#queue-a-task" id="updating-the-image-data:queue-a-task-7">queued</a> by the <a href="#networking-task-source" id="updating-the-image-data:networking-task-source-6">networking task source</a> once the resource has been
      fetched must additionally run these steps:</p>

      <ol><li><p>If <var>image request</var> is the <a href="#pending-request" id="updating-the-image-data:pending-request-19">pending request</a>,
       <a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-11">abort the image request</a> for the <a href="#current-request" id="updating-the-image-data:current-request-31">current request</a>,
       <a href="#upgrade-the-pending-request-to-the-current-request" id="updating-the-image-data:upgrade-the-pending-request-to-the-current-request-4">upgrade the pending request to the current request</a>, and
       <a href="#prepare-an-image-for-presentation" id="updating-the-image-data:prepare-an-image-for-presentation-4">prepare <var>image request</var> for
       presentation</a> given the <code id="updating-the-image-data:the-img-element-25"><a href="#the-img-element">img</a></code> element.</p></li><li><p>Set <var>image request</var> to the <a href="#img-all" id="updating-the-image-data:img-all-3">completely
       available</a> state.</p></li><li><p>Add the image to the <a href="#list-of-available-images" id="updating-the-image-data:list-of-available-images-2">list of available images</a> using the key
       <var>key</var>, with the <a href="#ignore-higher-layer-caching" id="updating-the-image-data:ignore-higher-layer-caching-2">ignore higher-layer caching</a> flag set.</p></li><li><p>If <i>maybe omit events</i> is not set or <var>previousURL</var> is not equal to
       <var>urlString</var>, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-image-data:concept-event-fire-7" data-x-internal="concept-event-fire">fire an event</a> named
       <code id="updating-the-image-data:event-load-3"><a href="#event-load">load</a></code> at the <code id="updating-the-image-data:the-img-element-26"><a href="#the-img-element">img</a></code> element.</p></li></ol>
     </dd><dt>Otherwise</dt><dd><p>The image data is not in a supported file format; the user agent must set <var>image
     request</var>'s <a href="#img-req-state" id="updating-the-image-data:img-req-state-16">state</a> to <a href="#img-error" id="updating-the-image-data:img-error-7">broken</a>, <a href="#abort-the-image-request" id="updating-the-image-data:abort-the-image-request-12">abort the image request</a> for the <a href="#current-request" id="updating-the-image-data:current-request-32">current
     request</a> and the <a href="#pending-request" id="updating-the-image-data:pending-request-20">pending request</a>, <a href="#upgrade-the-pending-request-to-the-current-request" id="updating-the-image-data:upgrade-the-pending-request-to-the-current-request-5">upgrade the pending request to the
     current request</a> if <var>image request</var> is the <a href="#pending-request" id="updating-the-image-data:pending-request-21">pending request</a>, and
     then, if <i>maybe omit events</i> is not set or <var>previousURL</var> is not equal to
     <var>urlString</var>, <a href="#queue-an-element-task" id="updating-the-image-data:queue-an-element-task-6">queue an element task</a> on the <a href="#dom-manipulation-task-source" id="updating-the-image-data:dom-manipulation-task-source-6">DOM manipulation task
     source</a> given the <code id="updating-the-image-data:the-img-element-27"><a href="#the-img-element">img</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-image-data:concept-event-fire-8" data-x-internal="concept-event-fire">fire an
     event</a> named <code id="updating-the-image-data:event-error-5"><a href="#event-error">error</a></code> at the <code id="updating-the-image-data:the-img-element-28"><a href="#the-img-element">img</a></code>
     element.</p></dd></dl>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>While a user agent is running the above algorithm for an element <var>x</var>, there must be a
  strong reference from the element's <a id="updating-the-image-data:node-document-8" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> to the element <var>x</var>, even
  if that element is not <a id="updating-the-image-data:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="abort-the-image-request">abort the image request</dfn> for an <a href="#image-request" id="updating-the-image-data:image-request-3">image request</a> or null <var>image
  request</var> means to run the following steps:</p>

  <ol><li><p>If <var>image request</var> is null, then return.</p></li><li><p>Forget <var>image request</var>'s <a href="#img-req-data" id="updating-the-image-data:img-req-data-3">image data</a>, if any.</p></li><li><p>Abort any instance of the <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="updating-the-image-data:concept-fetch-2" data-x-internal="concept-fetch">fetching</a> algorithm for
   <var>image request</var>, discarding any pending tasks generated by that algorithm.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="upgrade-the-pending-request-to-the-current-request">upgrade the pending request to the current request</dfn> for an <code id="updating-the-image-data:the-img-element-29"><a href="#the-img-element">img</a></code> element means to run the following steps:</p>

  <ol><li><p>Set the <code id="updating-the-image-data:the-img-element-30"><a href="#the-img-element">img</a></code> element's <a href="#current-request" id="updating-the-image-data:current-request-33">current request</a> to the <a href="#pending-request" id="updating-the-image-data:pending-request-22">pending request</a>.</p></li><li><p>Set the <code id="updating-the-image-data:the-img-element-31"><a href="#the-img-element">img</a></code> element's <a href="#pending-request" id="updating-the-image-data:pending-request-23">pending request</a> to null.</p></li></ol>
  </div>


  <h6 id="preparing-an-image-for-presentation"><span class="secno">4.8.4.3.6</span> Preparing an image for presentation<a href="#preparing-an-image-for-presentation" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>To <dfn id="prepare-an-image-for-presentation">prepare an image for presentation</dfn> for an <a href="#image-request" id="preparing-an-image-for-presentation:image-request">image request</a>
  <var>req</var> given image element <var>img</var>:</p>

  <ol><li><p>Let <var>exifTagMap</var> be the EXIF tags obtained from <var>req</var>'s <a href="#img-req-data" id="preparing-an-image-for-presentation:img-req-data">image data</a>, as defined by the relevant codec.
   <a href="#refsEXIF">[EXIF]</a></p></li><li><p>Let <var>physicalWidth</var> and <var>physicalHeight</var> be the width and height
   obtained from <var>req</var>'s <a href="#img-req-data" id="preparing-an-image-for-presentation:img-req-data-2">image data</a>, as defined by the
   relevant codec.</p></li><li><p>Let <var>dimX</var> be the value of <var>exifTagMap</var>'s tag <code>0xA002</code> (<code>PixelXDimension</code>).</p></li><li><p>Let <var>dimY</var> be the value of <var>exifTagMap</var>'s tag <code>0xA003</code> (<code>PixelYDimension</code>).</p></li><li><p>Let <var>resX</var> be the value of <var>exifTagMap</var>'s tag <code>0x011A</code> (<code>XResolution</code>).</p></li><li><p>Let <var>resY</var> be the value of <var>exifTagMap</var>'s tag <code>0x011B</code> (<code>YResolution</code>).</p></li><li><p>Let <var>resUnit</var> be the value of <var>exifTagMap</var>'s tag <code>0x0128</code> (<code>ResolutionUnit</code>).</p></li><li>
    <p>If all the following are true:</p>

    <ul><li><p><var>dimX</var> is a positive integer;</p></li><li><p><var>dimY</var> is a positive integer;</p></li><li><p><var>resX</var> is a positive floating-point number;</p></li><li><p><var>resY</var> is a positive floating-point number;</p></li><li><p><var>physicalWidth</var>&nbsp;×&nbsp;72&nbsp;/&nbsp;<var>resX</var> is
     <var>dimX</var>;</p></li><li><p><var>physicalHeight</var>&nbsp;×&nbsp;72&nbsp;/&nbsp;<var>resY</var> is
     <var>dimY</var>;</p></li><li><p><var>resUnit</var> is <code>2</code> (<code>Inch</code>),</p></li></ul>

    <p>then:</p>

    <ol><li><p>If <var>req</var>'s <a href="#img-req-data" id="preparing-an-image-for-presentation:img-req-data-3">image data</a> is
     <a href="#cors-cross-origin" id="preparing-an-image-for-presentation:cors-cross-origin">CORS-cross-origin</a>, then set <var>img</var>'s <a id="preparing-an-image-for-presentation:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> to
     <var>dimX</var> and <var>dimY</var>, and scale <var>img</var>'s pixel data
     accordingly.</p></li><li><p>Otherwise, set <var>req</var>'s <a href="#preferred-density-corrected-dimensions" id="preparing-an-image-for-presentation:preferred-density-corrected-dimensions">preferred density-corrected dimensions</a> to a
     struct with its width set to <var>dimX</var> and its height set to <var>dimY</var>.</p></li></ol>
   </li><li><p>Update <var>req</var>'s <code id="preparing-an-image-for-presentation:the-img-element"><a href="#the-img-element">img</a></code> element's presentation appropriately.</p></li></ol>
  </div>

  <p class="note">Resolution in EXIF is equivalent to <a href="https://drafts.csswg.org/css-values/#pt" id="preparing-an-image-for-presentation:'pt'" data-x-internal="'pt'">CSS points per
  inch</a>, therefore 72 is the base for computing size from resolution.</p>

  <p class="XXX">It is not yet specified what would be the case if EXIF arrives after the image is
  already presented. See <a href="https://github.com/w3c/csswg-drafts/issues/4929">issue
  #4929</a>.</p>



  <h6 id="selecting-an-image-source"><span class="secno">4.8.4.3.7</span> Selecting an image source<a href="#selecting-an-image-source" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>To <dfn id="select-an-image-source">select an image source</dfn> given an <code id="selecting-an-image-source:the-img-element"><a href="#the-img-element">img</a></code> element <var>el</var>:</p>

  <ol><li><p><a href="#update-the-source-set" id="selecting-an-image-source:update-the-source-set">Update the source set</a> for <var>el</var>.</p></li><li><p>If <var>el</var>'s <a href="#source-set" id="selecting-an-image-source:source-set">source set</a> is empty, return null as the URL and undefined
   as the pixel density.</p></li><li><p>Return the result of <a href="#select-an-image-source-from-a-source-set" id="selecting-an-image-source:select-an-image-source-from-a-source-set">selecting an
   image</a> from <var>el</var>'s <a href="#source-set" id="selecting-an-image-source:source-set-2">source set</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="select-an-image-source-from-a-source-set">select an image source from a source set</dfn> given a <a href="#source-set" id="selecting-an-image-source:source-set-3">source set</a>
  <var>sourceSet</var>:</p>

  <ol><li><p>If an entry <var>b</var> in <var>sourceSet</var> has the same associated <a href="#pixel-density-descriptor" id="selecting-an-image-source:pixel-density-descriptor">pixel
   density descriptor</a> as an earlier entry <var>a</var> in <var>sourceSet</var>, then remove
   entry <var>b</var>. Repeat this step until none of the entries in <var>sourceSet</var> have the
   same associated <a href="#pixel-density-descriptor" id="selecting-an-image-source:pixel-density-descriptor-2">pixel density descriptor</a> as an earlier entry.</p></li><li><p>In an <a id="selecting-an-image-source:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner, choose one <a href="#image-source" id="selecting-an-image-source:image-source">image source</a>
   from <var>sourceSet</var>. Let <var>selectedSource</var> be this choice.</p></li><li><p>Return <var>selectedSource</var> and its associated pixel density.</p></li></ol>
  </div>

  <h6 id="creating-a-source-set-from-attributes"><span class="secno">4.8.4.3.8</span> Creating a source set from attributes<a href="#creating-a-source-set-from-attributes" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When asked to <dfn id="create-a-source-set">create a source set</dfn> given a string <var>default source</var>, a string
  <var>srcset</var>, a string <var>sizes</var>, and an element or null <var>img</var>:</p>

  <ol><li><p>Let <var>source set</var> be an empty <a href="#source-set" id="creating-a-source-set-from-attributes:source-set">source set</a>.</p></li><li><p>If <var>srcset</var> is not an empty string, then set
   <var>source set</var> to the result of <a href="#parse-a-srcset-attribute" id="creating-a-source-set-from-attributes:parse-a-srcset-attribute">parsing</a>
   <var>srcset</var>.</p></li><li><p>Set <var>source set</var>'s <a href="#source-size-2" id="creating-a-source-set-from-attributes:source-size-2">source size</a> to the result of <a href="#parse-a-sizes-attribute" id="creating-a-source-set-from-attributes:parse-a-sizes-attribute">parsing</a> <var>sizes</var> with <var>img</var>.</p></li><li><p>If <var>default source</var> is not the empty string and
   <var>source set</var> does not contain an <a href="#image-source" id="creating-a-source-set-from-attributes:image-source">image source</a> with a <a href="#pixel-density-descriptor" id="creating-a-source-set-from-attributes:pixel-density-descriptor">pixel
   density descriptor</a> value of 1, and no <a href="#image-source" id="creating-a-source-set-from-attributes:image-source-2">image source</a> with a <a href="#width-descriptor" id="creating-a-source-set-from-attributes:width-descriptor">width
   descriptor</a>, append <var>default source</var> to <var>source set</var>.</p></li><li><p><a href="#normalise-the-source-densities" id="creating-a-source-set-from-attributes:normalise-the-source-densities">Normalize the source densities</a> of <var>source set</var>.</p></li><li><p>Return <var>source set</var>.</p></li></ol>
 </div>


  <h6 id="updating-the-source-set"><span class="secno">4.8.4.3.9</span> Updating the source set<a href="#updating-the-source-set" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When asked to <dfn id="update-the-source-set">update the source set</dfn> for a given <code id="updating-the-source-set:the-img-element"><a href="#the-img-element">img</a></code> or
  <code id="updating-the-source-set:the-link-element"><a href="#the-link-element">link</a></code> element <var>el</var>, user agents must do the following:</p>

  <ol><li><p>Set <var>el</var>'s <a href="#source-set" id="updating-the-source-set:source-set">source set</a> to an empty <a href="#source-set" id="updating-the-source-set:source-set-2">source set</a>.</p></li><li><p>Let <var>elements</var> be « <var>el</var> ».</p></li><li><p>If <var>el</var> is an <code id="updating-the-source-set:the-img-element-2"><a href="#the-img-element">img</a></code> element whose parent node is a
   <code id="updating-the-source-set:the-picture-element"><a href="#the-picture-element">picture</a></code> element, then <a href="https://infra.spec.whatwg.org/#list-replace" id="updating-the-source-set:list-replace" data-x-internal="list-replace">replace</a> the contents of
   <var>elements</var> with <var>el</var>'s parent node's child elements, retaining relative
   order.</p></li><li><p>Let <var>img</var> be <var>el</var> if <var>el</var> is an <code id="updating-the-source-set:the-img-element-3"><a href="#the-img-element">img</a></code> element,
   otherwise null.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-source-set:list-iterate" data-x-internal="list-iterate">For each</a> <var>child</var> in <var>elements</var>:</p>

    <ol><li>
      <p>If <var>child</var> is <var>el</var>:</p>

      <ol><li><p>Let <var>default source</var> be the empty string.</p></li><li><p>Let <var>srcset</var> be the empty string.</p></li><li><p>Let <var>sizes</var> be the empty string.</p></li><li><p>If <var>el</var> is an <code id="updating-the-source-set:the-img-element-4"><a href="#the-img-element">img</a></code> element that has a <code id="updating-the-source-set:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code> attribute, then set <var>srcset</var> to that
       attribute's value.</p></li><li><p>Otherwise, if <var>el</var> is a <code id="updating-the-source-set:the-link-element-2"><a href="#the-link-element">link</a></code> element that has an <code id="updating-the-source-set:attr-link-imagesrcset"><a href="#attr-link-imagesrcset">imagesrcset</a></code> attribute, then set <var>srcset</var> to
       that attribute's value.</p></li><li><p>If <var>el</var> is an <code id="updating-the-source-set:the-img-element-5"><a href="#the-img-element">img</a></code> element that has a <code id="updating-the-source-set:attr-img-sizes"><a href="#attr-img-sizes">sizes</a></code> attribute, then set <var>sizes</var> to that attribute's
       value.</p></li><li><p>Otherwise, if <var>el</var> is a <code id="updating-the-source-set:the-link-element-3"><a href="#the-link-element">link</a></code> element that has an <code id="updating-the-source-set:attr-link-imagesizes"><a href="#attr-link-imagesizes">imagesizes</a></code> attribute, then set <var>sizes</var> to that
       attribute's value.</p></li><li><p>If <var>el</var> is an <code id="updating-the-source-set:the-img-element-6"><a href="#the-img-element">img</a></code> element that has a <code id="updating-the-source-set:attr-img-src"><a href="#attr-img-src">src</a></code> attribute, then set <var>default source</var> to that
       attribute's value.</p></li><li><p>Otherwise, if <var>el</var> is a <code id="updating-the-source-set:the-link-element-4"><a href="#the-link-element">link</a></code> element that has an <code id="updating-the-source-set:attr-link-href"><a href="#attr-link-href">href</a></code> attribute, then set <var>default source</var> to that
       attribute's value.</p></li><li><p>Set <var>el</var>'s <a href="#source-set" id="updating-the-source-set:source-set-3">source set</a> to the result of <a href="#create-a-source-set" id="updating-the-source-set:create-a-source-set">creating a source set</a> given <var>default source</var>, <var>srcset</var>,
       <var>sizes</var>, and <var>img</var>.</p></li><li>
        <p>Return.</p>

        <p class="note">If <var>el</var> is a <code id="updating-the-source-set:the-link-element-5"><a href="#the-link-element">link</a></code> element, then <var>elements</var>
        contains only <var>el</var>, so this step will be reached immediately and the rest of the
        algorithm will not run.</p>
       </li></ol>
     </li><li><p>If <var>child</var> is not a <code id="updating-the-source-set:the-source-element"><a href="#the-source-element">source</a></code> element, then
     <a id="updating-the-source-set:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>child</var> does not have a <code id="updating-the-source-set:attr-source-srcset"><a href="#attr-source-srcset">srcset</a></code>
     attribute, <a id="updating-the-source-set:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a> to the next child.</p></li><li><p><a href="#parse-a-srcset-attribute" id="updating-the-source-set:parse-a-srcset-attribute">Parse <var>child</var>'s srcset attribute</a> and
     let <var>source set</var> be the returned <a href="#source-set" id="updating-the-source-set:source-set-4">source set</a>.</p></li><li><p>If <var>source set</var> has zero <a href="#image-source" id="updating-the-source-set:image-source">image sources</a>,
     <a id="updating-the-source-set:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a> to the next child.</p></li><li><p>If <var>child</var> has a <code id="updating-the-source-set:attr-source-media"><a href="#attr-source-media">media</a></code> attribute, and
     its value does not <a href="#matches-the-environment" id="updating-the-source-set:matches-the-environment">match the environment</a>,
     <a id="updating-the-source-set:continue-4" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a> to the next child.</p></li><li><p><a href="#parse-a-sizes-attribute" id="updating-the-source-set:parse-a-sizes-attribute">Parse <var>child</var>'s sizes attribute</a>
     with <var>img</var>, and let <var>source set</var>'s <a href="#source-size-2" id="updating-the-source-set:source-size-2">source size</a> be the returned
     value.</p></li><li><p>If <var>child</var> has a <code id="updating-the-source-set:attr-source-type"><a href="#attr-source-type">type</a></code> attribute, and its
     value is an unknown or unsupported <a id="updating-the-source-set:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a>, <a id="updating-the-source-set:continue-5" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a> to the next child.</p></li><li><p>If <var>child</var> has <code id="updating-the-source-set:attr-dim-width"><a href="#attr-dim-width">width</a></code> or <code id="updating-the-source-set:attr-dim-height"><a href="#attr-dim-height">height</a></code> attributes, set <var>el</var>'s <a href="#concept-img-dimension-attribute-source" id="updating-the-source-set:concept-img-dimension-attribute-source">dimension attribute source</a> to
     <var>child</var>. Otherwise, set <var>el</var>'s <a href="#concept-img-dimension-attribute-source" id="updating-the-source-set:concept-img-dimension-attribute-source-2">dimension attribute source</a> to
     <var>el</var>.</p></li><li><p><a href="#normalise-the-source-densities" id="updating-the-source-set:normalise-the-source-densities">Normalize the source densities</a> of <var>source set</var>.</p></li><li><p>Set <var>el</var>'s <a href="#source-set" id="updating-the-source-set:source-set-5">source set</a> to <var>source set</var>.</p></li><li><p>Return.</p></li></ol>
   </li></ol>
  </div>

  <p class="note">Each <code id="updating-the-source-set:the-img-element-7"><a href="#the-img-element">img</a></code> element independently considers its previous sibling
  <code id="updating-the-source-set:the-source-element-2"><a href="#the-source-element">source</a></code> elements plus the <code id="updating-the-source-set:the-img-element-8"><a href="#the-img-element">img</a></code> element itself for selecting an <a href="#image-source" id="updating-the-source-set:image-source-2">image
  source</a>, ignoring any other (invalid) elements, including other <code id="updating-the-source-set:the-img-element-9"><a href="#the-img-element">img</a></code> elements in
  the same <code id="updating-the-source-set:the-picture-element-2"><a href="#the-picture-element">picture</a></code> element, or <code id="updating-the-source-set:the-source-element-3"><a href="#the-source-element">source</a></code> elements that are following siblings
  of the relevant <code id="updating-the-source-set:the-img-element-10"><a href="#the-img-element">img</a></code> element.</p>


  <h6 id="parsing-a-srcset-attribute"><span class="secno">4.8.4.3.10</span> Parsing a srcset attribute<a href="#parsing-a-srcset-attribute" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When asked to <dfn id="parse-a-srcset-attribute">parse a srcset attribute</dfn> from an element, parse the value of the
  element's <a href="#srcset-attribute" id="parsing-a-srcset-attribute:srcset-attribute">srcset attribute</a> as follows:</p>

  <ol><li><p>Let <var>input</var> be the value passed to this algorithm.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>,
   initially pointing at the start of the string.</p></li><li><p>Let <var>candidates</var> be an initially empty <a href="#source-set" id="parsing-a-srcset-attribute:source-set">source set</a>.</p></li><li><p><i>Splitting loop</i>: <a id="parsing-a-srcset-attribute:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="parsing-a-srcset-attribute:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
   whitespace</a> or U+002C COMMA characters from <var>input</var> given <var>position</var>. If
   any U+002C COMMA characters were collected, that is a <a href="#concept-microsyntax-parse-error" id="parsing-a-srcset-attribute:concept-microsyntax-parse-error">parse error</a>.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>,
   return <var>candidates</var>.</p></li><li><p><a id="parsing-a-srcset-attribute:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are not <a id="parsing-a-srcset-attribute:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>
   from <var>input</var> given <var>position</var>, and let <var>url</var> be the result.</p></li><li><p>Let <var>descriptors</var> be a new empty list.</p></li><li>
    <p>If <var>url</var> ends with U+002C (,), then:</p>

    <ol><li><p>Remove all trailing U+002C COMMA characters from <var>url</var>.
     If this removed more than one character,
     that is a <a href="#concept-microsyntax-parse-error" id="parsing-a-srcset-attribute:concept-microsyntax-parse-error-2">parse error</a>.</p></li></ol>

    <p>Otherwise:</p>

    <ol><li><p><i>Descriptor tokenizer</i>: <a id="parsing-a-srcset-attribute:skip-ascii-whitespace" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var>
     given <var>position</var>.</p></li><li><p>Let <var>current descriptor</var> be the empty string.</p></li><li><p>Let <var>state</var> be <i>in descriptor</i>.</p></li><li>
      <p>Let <var>c</var> be the character at <var>position</var>.
      Do the following depending on the value of <var>state</var>.
      For the purpose of this step, "EOF" is a special character representing
      that <var>position</var> is past the end of <var>input</var>.</p>

      <dl class="switch"><dt><i>In descriptor</i></dt><dd>
        <p>Do the following, depending on the value of <var>c</var>:</p>

        <dl class="switch"><dt><a id="parsing-a-srcset-attribute:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a></dt><dd><p>If <var>current descriptor</var> is not empty,
         append <var>current descriptor</var> to <var>descriptors</var>
         and let <var>current descriptor</var> be the empty string.
         Set <var>state</var> to <i>after descriptor</i>.</p></dd><dt>U+002C COMMA (,)</dt><dd><p>Advance <var>position</var> to the next character in <var>input</var>.
         If <var>current descriptor</var> is not empty,
         append <var>current descriptor</var> to <var>descriptors</var>.
         Jump to the step labeled <i>descriptor parser</i>.</p></dd><dt>U+0028 LEFT PARENTHESIS (()</dt><dd><p>Append <var>c</var> to <var>current descriptor</var>.
         Set <var>state</var> to <i>in parens</i>.</p></dd><dt>EOF</dt><dd><p>If <var>current descriptor</var> is not empty,
         append <var>current descriptor</var> to <var>descriptors</var>.
         Jump to the step labeled <i>descriptor parser</i>.</p></dd><dt>Anything else</dt><dd><p>Append <var>c</var> to <var>current descriptor</var>.</p></dd></dl>
       </dd><dt><i>In parens</i></dt><dd>
        <p>Do the following, depending on the value of <var>c</var>:</p>

        <dl class="switch"><dt>U+0029 RIGHT PARENTHESIS ())</dt><dd><p>Append <var>c</var> to <var>current descriptor</var>.
         Set <var>state</var> to <i>in descriptor</i>.</p></dd><dt>EOF</dt><dd><p>Append <var>current descriptor</var> to <var>descriptors</var>.
         Jump to the step labeled <i>descriptor parser</i>.</p></dd><dt>Anything else</dt><dd><p>Append <var>c</var> to <var>current descriptor</var>.</p></dd></dl>
       </dd><dt><i>After descriptor</i></dt><dd>
        <p>Do the following, depending on the value of <var>c</var>:</p>

        <dl class="switch"><dt><a id="parsing-a-srcset-attribute:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a></dt><dd><p>Stay in this state.</p></dd><dt>EOF</dt><dd><p>Jump to the step labeled <i>descriptor parser</i>.</p></dd><dt>Anything else</dt><dd><p>Set <var>state</var> to <i>in descriptor</i>.
         Set <var>position</var> to the <em>previous</em> character in <var>input</var>.</p></dd></dl>
       </dd></dl>

      <p>Advance <var>position</var> to the next character in <var>input</var>. Repeat this
      step.</p>

      <p class="note">In order to be compatible with future additions,
      this algorithm supports multiple descriptors and descriptors with parens.</p>
     </li></ol>
   </li><li><p><i>Descriptor parser</i>: Let <var>error</var> be <i>no</i>.</p></li><li><p>Let <var>width</var> be <i>absent</i>.</p></li><li><p>Let <var>density</var> be <i>absent</i>.</p></li><li><p>Let <var>future-compat-h</var> be <i>absent</i>.</p></li><li>
    <p>For each descriptor in <var>descriptors</var>,
    run the appropriate set of steps from the following list:</p>

    <dl class="switch"><dt>If the descriptor consists of a <a href="#valid-non-negative-integer" id="parsing-a-srcset-attribute:valid-non-negative-integer">valid non-negative integer</a>
     followed by a U+0077 LATIN SMALL LETTER W character</dt><dd>
      <ol><li>
        <p>If the user agent does not support the <code id="parsing-a-srcset-attribute:attr-img-sizes"><a href="#attr-img-sizes">sizes</a></code> attribute,
        let <var>error</var> be <i>yes</i>.</p>

        <p class="note">A conforming user agent will support the <code id="parsing-a-srcset-attribute:attr-img-sizes-2"><a href="#attr-img-sizes">sizes</a></code> attribute.
        However, user agents typically implement and ship features in an incremental manner in practice.</p>
       </li><li><p>If <var>width</var> and <var>density</var>
       are not both <i>absent</i>,
       then let <var>error</var> be <i>yes</i>.</p></li><li><p>Apply the <a href="#rules-for-parsing-non-negative-integers" id="parsing-a-srcset-attribute:rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a> to the descriptor. If
       the result is 0, let <var>error</var> be <i>yes</i>. Otherwise, let <var>width</var> be the
       result.</p></li></ol>
     </dd><dt>If the descriptor consists of a <a href="#valid-floating-point-number" id="parsing-a-srcset-attribute:valid-floating-point-number">valid floating-point number</a>
     followed by a U+0078 LATIN SMALL LETTER X character</dt><dd>
      <ol><li><p>If <var>width</var>, <var>density</var> and <var>future-compat-h</var>
       are not all <i>absent</i>,
       then let <var>error</var> be <i>yes</i>.</p></li><li>
        <p>Apply the <a href="#rules-for-parsing-floating-point-number-values" id="parsing-a-srcset-attribute:rules-for-parsing-floating-point-number-values">rules for parsing floating-point number values</a> to the descriptor.
        If the result is less than 0, let <var>error</var> be <i>yes</i>. Otherwise, let
        <var>density</var> be the result.</p>

        <p class="note">If <var>density</var> is 0, the <a id="parsing-a-srcset-attribute:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> will be
        infinite. User agents are <a href="https://infra.spec.whatwg.org/#algorithm-limits">expected
        to have limits</a> in how big images can be rendered.</p>
       </li></ol>
     </dd><dt>If the descriptor consists of a <a href="#valid-non-negative-integer" id="parsing-a-srcset-attribute:valid-non-negative-integer-2">valid non-negative integer</a>
     followed by a U+0068 LATIN SMALL LETTER H character</dt><dd>
      <p>This is a <a href="#concept-microsyntax-parse-error" id="parsing-a-srcset-attribute:concept-microsyntax-parse-error-3">parse error</a>.</p>

      <ol><li><p>If <var>future-compat-h</var> and <var>density</var>
       are not both <i>absent</i>,
       then let <var>error</var> be <i>yes</i>.</p></li><li><p>Apply the <a href="#rules-for-parsing-non-negative-integers" id="parsing-a-srcset-attribute:rules-for-parsing-non-negative-integers-2">rules for parsing non-negative integers</a> to the descriptor. If
       the result is 0, let <var>error</var> be <i>yes</i>. Otherwise, let
       <var>future-compat-h</var> be the result.</p></li></ol>
     </dd><dt>Anything else</dt><dd><p>Let <var>error</var> be <i>yes</i>.</p></dd></dl>
   </li><li><p>If <var>future-compat-h</var> is not <i>absent</i> and <var>width</var> is <i>absent</i>,
   let <var>error</var> be <i>yes</i>.</p></li><li><p>If <var>error</var> is still <i>no</i>,
   then append a new <a href="#image-source" id="parsing-a-srcset-attribute:image-source">image source</a> to <var>candidates</var>
   whose URL is <var>url</var>,
   associated with a width <var>width</var> if not <i>absent</i>
   and a pixel density <var>density</var> if not <i>absent</i>.
   Otherwise, there is a <a href="#concept-microsyntax-parse-error" id="parsing-a-srcset-attribute:concept-microsyntax-parse-error-4">parse error</a>.</p></li><li><p>Return to the step labeled <i>splitting loop</i>.</p></li></ol>
  </div>


  <h6 id="parsing-a-sizes-attribute"><span class="secno">4.8.4.3.11</span> Parsing a sizes attribute<a href="#parsing-a-sizes-attribute" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When asked to <dfn id="parse-a-sizes-attribute">parse a sizes attribute</dfn> from an element <var>element</var>, with an
  <code id="parsing-a-sizes-attribute:the-img-element"><a href="#the-img-element">img</a></code> element or null <var>img</var>:</p>

  <ol><li><p>Let <var>unparsed sizes list</var> be the result of <a href="https://drafts.csswg.org/css-syntax/#parse-a-comma-separated-list-of-component-values" id="parsing-a-sizes-attribute:parse-a-comma-separated-list-of-component-values" data-x-internal="parse-a-comma-separated-list-of-component-values">parsing a comma-separated list of component values</a> from the
   value of <var>element</var>'s <a href="#sizes-attribute" id="parsing-a-sizes-attribute:sizes-attribute">sizes attribute</a> (or the empty string, if the attribute
   is absent). <a href="#refsCSSSYNTAX">[CSSSYNTAX]</a></p></li><li><p>Let <var>size</var> be null.</p></li><li>
    <p>For each <var>unparsed size</var> in <var>unparsed sizes list</var>:</p>

    <ol><li><p>Remove all consecutive <a id="parsing-a-sizes-attribute:whitespace-token" href="https://drafts.csswg.org/css-syntax/#typedef-whitespace-token" data-x-internal="whitespace-token">&lt;whitespace-token&gt;</a>s
     from the end of <var>unparsed size</var>.
     If <var>unparsed size</var> is now empty,
     then that is a <a href="#concept-microsyntax-parse-error" id="parsing-a-sizes-attribute:concept-microsyntax-parse-error">parse error</a>;
     <a id="parsing-a-sizes-attribute:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If the last <a id="parsing-a-sizes-attribute:component-value" href="https://drafts.csswg.org/css-syntax/#component-value" data-x-internal="component-value">component value</a> in <var>unparsed size</var>
     is a valid non-negative <a href="#source-size-value" id="parsing-a-sizes-attribute:source-size-value">&lt;source-size-value&gt;</a>,
     then set <var>size</var> to its value
     and remove the <a id="parsing-a-sizes-attribute:component-value-2" href="https://drafts.csswg.org/css-syntax/#component-value" data-x-internal="component-value">component value</a> from <var>unparsed size</var>.
     Any CSS function other than the <a id="parsing-a-sizes-attribute:math-functions" href="https://drafts.csswg.org/css-values/#math-function" data-x-internal="math-functions">math functions</a> is invalid.
     Otherwise, there is a <a href="#concept-microsyntax-parse-error" id="parsing-a-sizes-attribute:concept-microsyntax-parse-error-2">parse error</a>;
     <a id="parsing-a-sizes-attribute:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li>
      <p>If <var>size</var> is <code id="parsing-a-sizes-attribute:valdef-sizes-auto"><a href="#valdef-sizes-auto">auto</a></code>, and <var>img</var>
      is not null, and <var>img</var> is <a href="#being-rendered" id="parsing-a-sizes-attribute:being-rendered">being rendered</a>, and <var>img</var>
      <a href="#allows-auto-sizes" id="parsing-a-sizes-attribute:allows-auto-sizes">allows auto-sizes</a>, then set <var>size</var> to the <a id="parsing-a-sizes-attribute:concrete-object-size" href="https://drafts.csswg.org/css-images/#concrete-object-size" data-x-internal="concrete-object-size">concrete object
      size</a> width of <var>img</var>, in <a href="https://drafts.csswg.org/css-values/#px" id="parsing-a-sizes-attribute:'px'" data-x-internal="'px'">CSS pixels</a>.</p>

      <p class="note">If <var>size</var> is still <code id="parsing-a-sizes-attribute:valdef-sizes-auto-2"><a href="#valdef-sizes-auto">auto</a></code>,
      then it will be ignored.</p>
     </li><li>
      <p>Remove all consecutive <a id="parsing-a-sizes-attribute:whitespace-token-2" href="https://drafts.csswg.org/css-syntax/#typedef-whitespace-token" data-x-internal="whitespace-token">&lt;whitespace-token&gt;</a>s from the end of <var>unparsed
      size</var>. If <var>unparsed size</var> is now empty:</p>

      <ol><li><p>If this was not the last item in <var>unparsed sizes list</var>, that is a <a href="#concept-microsyntax-parse-error" id="parsing-a-sizes-attribute:concept-microsyntax-parse-error-3">parse error</a>.</p></li><li><p>If <var>size</var> is not <code id="parsing-a-sizes-attribute:valdef-sizes-auto-3"><a href="#valdef-sizes-auto">auto</a></code>, then return
       <var>size</var>. Otherwise, continue.</p></li></ol>
     </li><li><p>Parse the remaining <a href="https://drafts.csswg.org/css-syntax/#component-value" id="parsing-a-sizes-attribute:component-value-3" data-x-internal="component-value">component values</a> in <var>unparsed size</var>
     as a <a id="parsing-a-sizes-attribute:media-condition" href="https://drafts.csswg.org/mediaqueries/#typedef-media-condition" data-x-internal="media-condition">&lt;media-condition&gt;</a>.
     If it does not parse correctly,
     or it does parse correctly but the <a id="parsing-a-sizes-attribute:media-condition-2" href="https://drafts.csswg.org/mediaqueries/#typedef-media-condition" data-x-internal="media-condition">&lt;media-condition&gt;</a> evaluates to false,
     <a id="parsing-a-sizes-attribute:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>. <a href="#refsMQ">[MQ]</a></p></li><li><p>If <var>size</var> is not <code id="parsing-a-sizes-attribute:valdef-sizes-auto-4"><a href="#valdef-sizes-auto">auto</a></code>, then return
     <var>size</var>. Otherwise, continue.</p></li></ol>
   </li><li><p>Return <code>100vw</code>.</p></li></ol>
  </div>

  <p class="note">It is invalid to use a bare <a href="#source-size-value" id="parsing-a-sizes-attribute:source-size-value-2">&lt;source-size-value&gt;</a> that is a <a id="parsing-a-sizes-attribute:length-2" href="https://drafts.csswg.org/css-values/#lengths" data-x-internal="length-2">&lt;length&gt;</a>
  (without an accompanying <a id="parsing-a-sizes-attribute:media-condition-3" href="https://drafts.csswg.org/mediaqueries/#typedef-media-condition" data-x-internal="media-condition">&lt;media-condition&gt;</a>)
  as an entry in the <a href="#source-size-list" id="parsing-a-sizes-attribute:source-size-list">&lt;source-size-list&gt;</a> that is not the last entry.
  However, the parsing algorithm allows it at any point in the <a href="#source-size-list" id="parsing-a-sizes-attribute:source-size-list-2">&lt;source-size-list&gt;</a>,
  and will accept it immediately as the size
  if the preceding entries in the list weren't used.
  This is to enable future extensions,
  and protect against simple author errors such as a final trailing comma.
  A bare <code id="parsing-a-sizes-attribute:valdef-sizes-auto-5"><a href="#valdef-sizes-auto">auto</a></code> keyword is allowed to have other entries
  following it to provide a fallback for legacy user agents.</p>


  <h6 id="normalizing-the-source-densities"><span class="secno">4.8.4.3.12</span> Normalizing the source densities<a href="#normalizing-the-source-densities" class="self-link"></a></h6>

  <p>An <a href="#image-source" id="normalizing-the-source-densities:image-source">image source</a> can have a <a href="#pixel-density-descriptor" id="normalizing-the-source-densities:pixel-density-descriptor">pixel density descriptor</a>, a <a href="#width-descriptor" id="normalizing-the-source-densities:width-descriptor">width
  descriptor</a>, or no descriptor at all accompanying its URL. Normalizing a <a href="#source-set" id="normalizing-the-source-densities:source-set">source
  set</a> gives every <a href="#image-source" id="normalizing-the-source-densities:image-source-2">image source</a> a <a href="#pixel-density-descriptor" id="normalizing-the-source-densities:pixel-density-descriptor-2">pixel density descriptor</a>.</p>

  <div data-algorithm="">
  <p>When asked to <dfn id="normalise-the-source-densities">normalize the source
  densities</dfn> of a <a href="#source-set" id="normalizing-the-source-densities:source-set-2">source set</a> <var>source set</var>, the user agent must do the
  following:</p>

  <ol><li><p>Let <var>source size</var> be <var>source set</var>'s <a href="#source-size-2" id="normalizing-the-source-densities:source-size-2">source size</a>.</p></li><li>
    <p>For each <a href="#image-source" id="normalizing-the-source-densities:image-source-3">image source</a> in <var>source set</var>:</p>

    <ol><li><p>If the <a href="#image-source" id="normalizing-the-source-densities:image-source-4">image source</a> has a <a href="#pixel-density-descriptor" id="normalizing-the-source-densities:pixel-density-descriptor-3">pixel density descriptor</a>, <a id="normalizing-the-source-densities:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a> to the next
     <a href="#image-source" id="normalizing-the-source-densities:image-source-5">image source</a>.</p></li><li>
      <p>Otherwise, if the <a href="#image-source" id="normalizing-the-source-densities:image-source-6">image source</a> has a <a href="#width-descriptor" id="normalizing-the-source-densities:width-descriptor-2">width descriptor</a>, replace the <a href="#width-descriptor" id="normalizing-the-source-densities:width-descriptor-3">width
      descriptor</a> with a <a href="#pixel-density-descriptor" id="normalizing-the-source-densities:pixel-density-descriptor-4">pixel density descriptor</a> with a <a href="#pixel-density-descriptor-value" id="normalizing-the-source-densities:pixel-density-descriptor-value">value</a> of the <a href="#width-descriptor-value" id="normalizing-the-source-densities:width-descriptor-value">width descriptor value</a> divided by <var>source size</var> and a unit
      of <code>x</code>.</p>

      <p class="note">If the <a href="#source-size-2" id="normalizing-the-source-densities:source-size-2-2">source size</a> is 0, then the density would be infinity,
      which results in the <a id="normalizing-the-source-densities:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> being 0 by 0.</p>
     </li><li><p>Otherwise, give the <a href="#image-source" id="normalizing-the-source-densities:image-source-7">image source</a> a <a href="#pixel-density-descriptor" id="normalizing-the-source-densities:pixel-density-descriptor-5">pixel density descriptor</a> of <code>1x</code>.</p></li></ol>
   </li></ol>
  </div>


  <h6 id="reacting-to-environment-changes"><span class="secno">4.8.4.3.13</span> Reacting to environment changes<a href="#reacting-to-environment-changes" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>The user agent may at any time run the following algorithm to update an <code id="reacting-to-environment-changes:the-img-element"><a href="#the-img-element">img</a></code>
  element's image in order to <dfn id="img-environment-changes">react to changes in the
  environment</dfn>. (User agents are <em>not required</em> to ever run this algorithm; for example,
  if the user is not looking at the page any more, the user agent might want to wait until the user
  has returned to the page before determining which image to use, in case the environment changes
  again in the meantime.)</p>

  <p class="note">User agents are encouraged to run this algorithm in particular when the user changes
  the <a id="reacting-to-environment-changes:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>'s size (e.g. by resizing the window or changing the page zoom), and when
  an <code id="reacting-to-environment-changes:the-img-element-2"><a href="#the-img-element">img</a></code> element is <a href="#insert-an-element-into-a-document" id="reacting-to-environment-changes:insert-an-element-into-a-document">inserted into a
  document</a>, so that the <a href="#density-corrected-intrinsic-width-and-height" id="reacting-to-environment-changes:density-corrected-intrinsic-width-and-height">density-corrected natural width and height</a> match the
  new <a id="reacting-to-environment-changes:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>, and so that the correct image is chosen when <a href="#art-direction" id="reacting-to-environment-changes:art-direction">art direction</a>
  is involved.</p>

  <ol><li><p><a href="#await-a-stable-state" id="reacting-to-environment-changes:await-a-stable-state">Await a stable state</a>. The <a href="#synchronous-section" id="reacting-to-environment-changes:synchronous-section">synchronous section</a>
   consists of all the remaining steps of this algorithm until the algorithm says the
   <a href="#synchronous-section" id="reacting-to-environment-changes:synchronous-section-2">synchronous section</a> has ended. (Steps in <a href="#synchronous-section" id="reacting-to-environment-changes:synchronous-section-3">synchronous sections</a> are marked with ⌛.)</p></li><li><p>⌛ If the <code id="reacting-to-environment-changes:the-img-element-3"><a href="#the-img-element">img</a></code> element does not <a href="#use-srcset-or-picture" id="reacting-to-environment-changes:use-srcset-or-picture">use <code>srcset</code> or
   <code>picture</code></a>, its <a id="reacting-to-environment-changes:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="reacting-to-environment-changes:fully-active">fully active</a>, it has
   image data whose resource type is <code id="reacting-to-environment-changes:multipart/x-mixed-replace"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code>, or its <a href="#pending-request" id="reacting-to-environment-changes:pending-request">pending
   request</a> is not null, then return.</p></li><li><p>⌛ Let <var>selected source</var> and <var>selected pixel
   density</var> be the URL and pixel density that results from <a href="#select-an-image-source" id="reacting-to-environment-changes:select-an-image-source">selecting an image source</a>, respectively.</p></li><li><p>⌛ If <var>selected source</var> is null, then return.</p></li><li><p>⌛ If <var>selected source</var> and <var>selected pixel
   density</var> are the same as the element's <a href="#last-selected-source" id="reacting-to-environment-changes:last-selected-source">last selected source</a> and <a href="#current-pixel-density" id="reacting-to-environment-changes:current-pixel-density">current
   pixel density</a>, then return.</p></li><li><p>⌛ Let <var>urlString</var> be the result of <a href="#encoding-parsing-and-serializing-a-url" id="reacting-to-environment-changes:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing
   a URL</a> given <var>selected source</var>, relative to the element's <a id="reacting-to-environment-changes:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>.</p></li><li><p>⌛ If <var>urlString</var> is failure, then return.</p></li><li><p>⌛ Let <var>corsAttributeState</var> be the state of the element's <code id="reacting-to-environment-changes:attr-img-crossorigin"><a href="#attr-img-crossorigin">crossorigin</a></code> content attribute.</p></li><li><p>⌛ Let <var>origin</var> be the <code id="reacting-to-environment-changes:the-img-element-4"><a href="#the-img-element">img</a></code> element's <a id="reacting-to-environment-changes:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="reacting-to-environment-changes:concept-document-origin" data-x-internal="concept-document-origin">origin</a>.</p></li><li><p>⌛ Let <var>client</var> be the <code id="reacting-to-environment-changes:the-img-element-5"><a href="#the-img-element">img</a></code> element's <a id="reacting-to-environment-changes:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>'s <a href="#relevant-settings-object" id="reacting-to-environment-changes:relevant-settings-object">relevant settings object</a>.</p></li><li><p>⌛ Let <var>key</var> be a tuple consisting of <var>urlString</var>,
   <var>corsAttributeState</var>, and, if <var>corsAttributeState</var> is not <a href="#attr-crossorigin-none" id="reacting-to-environment-changes:attr-crossorigin-none">No CORS</a>, <var>origin</var>.</p></li><li><p>⌛ Let <var>image request</var> be a new <a href="#image-request" id="reacting-to-environment-changes:image-request">image request</a>
   whose <a href="#img-req-url" id="reacting-to-environment-changes:img-req-url">current URL</a> is <var>urlString</var>.</p></li><li><p>⌛ Set the element's <a href="#pending-request" id="reacting-to-environment-changes:pending-request-2">pending request</a> to <var>image request</var>.</p></li><li><p>End the <a href="#synchronous-section" id="reacting-to-environment-changes:synchronous-section-4">synchronous section</a>, continuing the remaining steps
   <a href="#in-parallel" id="reacting-to-environment-changes:in-parallel">in parallel</a>.</p></li><li>
    <p>If the <a href="#list-of-available-images" id="reacting-to-environment-changes:list-of-available-images">list of available images</a> contains an entry for <var>key</var>,
    then set <var>image request</var>'s <a href="#img-req-data" id="reacting-to-environment-changes:img-req-data">image data</a> to that of the entry.
    Continue to the next step.</p>

    <p>Otherwise:</p>

    <ol><li><p>Let <var>request</var> be the result of <a href="#create-a-potential-cors-request" id="reacting-to-environment-changes:create-a-potential-cors-request">creating a potential-CORS request</a> given
     <var>urlString</var>, "<code>image</code>", and
     <var>corsAttributeState</var>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="reacting-to-environment-changes:concept-request-client" data-x-internal="concept-request-client">client</a> to
     <var>client</var>, set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-initiator" id="reacting-to-environment-changes:concept-request-initiator" data-x-internal="concept-request-initiator">initiator</a> to "<code>imageset</code>", and set <var>request</var>'s <a id="reacting-to-environment-changes:synchronous-flag" href="https://fetch.spec.whatwg.org/#synchronous-flag" data-x-internal="synchronous-flag">synchronous
     flag</a>.</p></li><li><p>Set <var>request</var>'s
     <a href="https://fetch.spec.whatwg.org/#concept-request-referrer-policy" id="reacting-to-environment-changes:concept-request-referrer-policy" data-x-internal="concept-request-referrer-policy">referrer policy</a> to the current state of
     the element's <code id="reacting-to-environment-changes:attr-img-referrerpolicy"><a href="#attr-img-referrerpolicy">referrerpolicy</a></code> attribute.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-priority" id="reacting-to-environment-changes:concept-request-priority" data-x-internal="concept-request-priority">priority</a> to the current state of the element's <code id="reacting-to-environment-changes:attr-img-fetchpriority"><a href="#attr-img-fetchpriority">fetchpriority</a></code> attribute.</p></li><li><p>Let <var>response</var> be the result of <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="reacting-to-environment-changes:concept-fetch" data-x-internal="concept-fetch">fetching</a> <var>request</var>.</p></li><li><p>If <var>response</var>'s <a href="#unsafe-response" id="reacting-to-environment-changes:unsafe-response">unsafe response</a> is a <a id="reacting-to-environment-changes:network-error" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a> or
     if the image format is unsupported (as determined by applying the <a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-images-specifically" id="reacting-to-environment-changes:content-type-sniffing:-image" data-x-internal="content-type-sniffing:-image">image sniffing rules</a>, again as mentioned earlier),
     or if the user agent is able to determine that <var>image request</var>'s image is corrupted in
     some fatal way such that the image dimensions cannot be obtained, or if the resource type is
     <code id="reacting-to-environment-changes:multipart/x-mixed-replace-2"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code>, then set the <a href="#pending-request" id="reacting-to-environment-changes:pending-request-3">pending request</a> to null and abort
     these steps.</p></li><li><p>Otherwise, <var>response</var>'s <a href="#unsafe-response" id="reacting-to-environment-changes:unsafe-response-2">unsafe response</a> is <var>image
     request</var>'s <a href="#img-req-data" id="reacting-to-environment-changes:img-req-data-2">image data</a>. It can be either
     <a href="#cors-same-origin" id="reacting-to-environment-changes:cors-same-origin">CORS-same-origin</a> or <a href="#cors-cross-origin" id="reacting-to-environment-changes:cors-cross-origin">CORS-cross-origin</a>; this affects the image's
     interaction with other APIs (e.g., when used on a <code id="reacting-to-environment-changes:the-canvas-element"><a href="#the-canvas-element">canvas</a></code>).</p></li></ol>
   </li><li>
    <p><a href="#queue-an-element-task" id="reacting-to-environment-changes:queue-an-element-task">Queue an element task</a> on the <a href="#dom-manipulation-task-source" id="reacting-to-environment-changes:dom-manipulation-task-source">DOM manipulation task source</a> given
    the <code id="reacting-to-environment-changes:the-img-element-6"><a href="#the-img-element">img</a></code> element and the following steps:</p>

    <ol><li><p>If the <code id="reacting-to-environment-changes:the-img-element-7"><a href="#the-img-element">img</a></code> element has experienced <a href="#relevant-mutations" id="reacting-to-environment-changes:relevant-mutations">relevant mutations</a>
     since this algorithm started, then set the <a href="#pending-request" id="reacting-to-environment-changes:pending-request-4">pending request</a> to null and abort these
     steps.</p>

     </li><li><p>Set the <code id="reacting-to-environment-changes:the-img-element-8"><a href="#the-img-element">img</a></code> element's <a href="#last-selected-source" id="reacting-to-environment-changes:last-selected-source-2">last selected source</a> to <var>selected
     source</var> and the <code id="reacting-to-environment-changes:the-img-element-9"><a href="#the-img-element">img</a></code> element's <a href="#current-pixel-density" id="reacting-to-environment-changes:current-pixel-density-2">current pixel density</a> to
     <var>selected pixel density</var>.</p></li><li><p>Set the <var>image request</var>'s <a href="#img-req-state" id="reacting-to-environment-changes:img-req-state">state</a> to <a href="#img-all" id="reacting-to-environment-changes:img-all">completely available</a>.</p></li><li><p>Add the image to the <a href="#list-of-available-images" id="reacting-to-environment-changes:list-of-available-images-2">list of available images</a> using the key <var>key</var>,
     with the <a href="#ignore-higher-layer-caching" id="reacting-to-environment-changes:ignore-higher-layer-caching">ignore higher-layer caching</a> flag set.</p></li><li><p><a href="#upgrade-the-pending-request-to-the-current-request" id="reacting-to-environment-changes:upgrade-the-pending-request-to-the-current-request">Upgrade the pending request to the current request</a>.</p></li><li><p><a href="#prepare-an-image-for-presentation" id="reacting-to-environment-changes:prepare-an-image-for-presentation">Prepare <var>image request</var> for
     presentation</a> given the <code id="reacting-to-environment-changes:the-img-element-10"><a href="#the-img-element">img</a></code> element.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="reacting-to-environment-changes:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="reacting-to-environment-changes:event-load"><a href="#event-load">load</a></code> at the <code id="reacting-to-environment-changes:the-img-element-11"><a href="#the-img-element">img</a></code> element.</p></li></ol>
   </li></ol>
  </div>

  


  <h5 id="alt"><span class="secno">4.8.4.4</span> Requirements for providing text to act as an alternative for images<a href="#alt" class="self-link"></a></h5>


  <h6 id="general-guidelines"><span class="secno">4.8.4.4.1</span> General guidelines<a href="#general-guidelines" class="self-link"></a></h6>

  <p>Except where otherwise specified, the <code id="general-guidelines:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute must be
  specified and its value must not be empty; the value must be an appropriate replacement for the
  image. The specific requirements for the <code id="general-guidelines:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code> attribute depend on
  what the image is intended to represent, as described in the following sections.</p>

  <p>The most general rule to consider when writing alternative text is the following: <strong>the
  intent is that replacing every image with the text of its <code id="general-guidelines:attr-img-alt-3"><a href="#attr-img-alt">alt</a></code>
  attribute does not change the meaning of the page</strong>.</p>

  <p>So, in general, alternative text can be written by considering what one would have written had
  one not been able to include the image.</p>

  <p>A corollary to this is that the <code id="general-guidelines:attr-img-alt-4"><a href="#attr-img-alt">alt</a></code> attribute's value should
  never contain text that could be considered the image's <em>caption</em>, <em>title</em>, or
  <em>legend</em>. It is supposed to contain replacement text that could be used by users
  <em>instead</em> of the image; it is not meant to supplement the image. The <code id="general-guidelines:attr-title"><a href="#attr-title">title</a></code> attribute can be used for supplemental information.</p>

  <p>Another corollary is that the <code id="general-guidelines:attr-img-alt-5"><a href="#attr-img-alt">alt</a></code> attribute's value should
  not repeat information that is already provided in the prose next to the image.</p>

  <p class="note">One way to think of alternative text is to think about how you would read the page
  containing the image to someone over the phone, without mentioning that there is an image present.
  Whatever you say instead of the image is typically a good start for writing the alternative
  text.</p>


  <h6 id="a-link-or-button-containing-nothing-but-the-image"><span class="secno">4.8.4.4.2</span> A link or button containing nothing but the image<a href="#a-link-or-button-containing-nothing-but-the-image" class="self-link"></a></h6>

  <p>When an <code id="a-link-or-button-containing-nothing-but-the-image:the-a-element"><a href="#the-a-element">a</a></code> element that creates a <a href="#hyperlink" id="a-link-or-button-containing-nothing-but-the-image:hyperlink">hyperlink</a>, or a <code id="a-link-or-button-containing-nothing-but-the-image:the-button-element"><a href="#the-button-element">button</a></code>
  element, has no textual content but contains one or more images, the <code id="a-link-or-button-containing-nothing-but-the-image:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attributes must contain text that together convey the purpose of
  the link or button.</p>

  <div class="example">

   <p>In this example, a user is asked to pick their preferred color from a list of three. Each color
   is given by an image, but for users who have configured their user agent not to display images,
   the color names are used instead:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Pick your color<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"green.html"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"green.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Green"</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"blue.html"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"blue.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Blue"</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"red.html"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"red.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Red"</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In this example, each button has a set of images to indicate the kind of color output desired
   by the user. The first image is used in each case to give the alternative text.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"rgb"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"red"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"RGB"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"green"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"blue"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"cmyk"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"cyan"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"CMYK"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"magenta"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"yellow"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"black"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-></code></pre>

   <p>Since each image represents one part of the text, it could also be written like this:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"rgb"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"red"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"R"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"green"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"G"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"blue"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"B"</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"cmyk"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"cyan"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"C"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"magenta"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"M"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"yellow"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Y"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"black"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"K"</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-></code></pre>

   <p>However, with other alternative text, this might not work, and putting all the alternative
   text into one image in each case might make more sense:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"rgb"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"red"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"sRGB profile"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"green"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"blue"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"cmyk"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"cyan"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"CMYK profile"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"magenta"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"yellow"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"black"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h6 id="a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations"><span class="secno">4.8.4.4.3</span> A phrase or paragraph with an alternative graphical representation: charts, diagrams, graphs, maps, illustrations<a href="#a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations" class="self-link"></a></h6>

  <p>Sometimes something can be more clearly stated in graphical form, for example as a flowchart, a
  diagram, a graph, or a simple map showing directions. In such cases, an image can be given using
  the <code id="a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations:the-img-element"><a href="#the-img-element">img</a></code> element, but the lesser textual version must still be given, so that users
  who are unable to view the image (e.g. because they have a very slow connection, or because they
  are using a text-only browser, or because they are listening to the page being read out by a
  hands-free automobile voice web browser, or simply because they are blind) are still able to
  understand the message being conveyed.</p>

  <p>The text must be given in the <code id="a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute, and must convey
  the same message as the image specified in the <code id="a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations:attr-img-src"><a href="#attr-img-src">src</a></code>
  attribute.</p>

  <p>It is important to realize that the alternative text is a <em>replacement</em> for the image,
  not a description of the image.</p>

  <div class="example">

   <p>In the following example we have <a href="/images/parsing-model-overview.svg">a flowchart</a>
   in image form, with text in the <code id="a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code> attribute rephrasing the
   flowchart in prose form:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->In the common case, the data handled by the tokenization stage
comes from the network, but it can also come from script.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/parsing-model-overview.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The Network</c->
<c- s="">passes data to the Input Stream Preprocessor, which passes it to the</c->
<c- s="">Tokenizer, which passes it to the Tree Construction stage. From there,</c->
<c- s="">data goes to both the DOM and to Script Execution. Script Execution is</c->
<c- s="">linked to the DOM, and, using document.write(), passes data to the</c->
<c- s="">Tokenizer."</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Here's another example, showing a good solution and a bad solution to the problem of including
   an image in a description.</p>

   <p>First, here's the good solution. This sample shows how the alternative text should just be
   what you would have put in the prose if the image had never existed.</p>

   <pre><code class="html"><c- c="">&lt;!-- This is the correct way to do things. --&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 You are standing in an open field west of a house.
 <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"house.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The house is white, with a boarded front door."</c-><c- p="">&gt;</c-></strong>
 There is a small mailbox here.
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Second, here's the bad solution. In this incorrect way of doing things, the alternative text
   is simply a description of the image, instead of a textual replacement for the image. It's bad
   because when the image isn't shown, the text doesn't flow as well as in the first example.</p>

   <pre class="bad"><code class="html"><c- c="">&lt;!-- </c-><em><c- c="">This is the wrong way to do things.</c-></em><c- c=""> --&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 You are standing in an open field west of a house.
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"house.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"A white house, with a boarded front door."</c-><c- p="">&gt;</c->
 There is a small mailbox here.
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Text such as "Photo of white house with boarded door" would be equally bad alternative text
   (though it could be suitable for the <code id="a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations:attr-title"><a href="#attr-title">title</a></code> attribute or in the
   <code id="a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code> element of a <code id="a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations:the-figure-element"><a href="#the-figure-element">figure</a></code> with this image).</p>

  </div>


  <h6 id="a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos"><span class="secno">4.8.4.4.4</span> A short phrase or label with an alternative graphical representation: icons, logos<a href="#a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos" class="self-link"></a></h6>

  <p>A document can contain information in iconic form. The icon is intended to help users of visual
  browsers to recognize features at a glance.</p>

  <p>In some cases, the icon is supplemental to a text label conveying the same meaning. In those
  cases, the <code id="a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute must be present but must be empty.</p>

  <div class="example">

   <p>Here the icons are next to text that conveys the same meaning, so they have an empty <code id="a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code> attribute:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/help/"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/icons/help.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-></strong> Help<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/configure/"</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/icons/configuration.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-></strong>
 Configuration Tools<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>In other cases, the icon has no text next to it describing what it means; the icon is supposed
  to be self-explanatory. In those cases, an equivalent textual label must be given in the <code id="a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos:attr-img-alt-3"><a href="#attr-img-alt">alt</a></code> attribute.</p>

  <div class="example">

   <p>Here, posts on a news site are labeled with an icon indicating their topic.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Ratatouille wins <c- p="">&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->Best Movie of the Year<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c-> award<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"movies.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Movies"</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Pixar has won yet another <c- p="">&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->Best Movie of the Year<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c-> award,
  making this its 8th win in the last 12 years.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Latest TWiT episode is online<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"podcasts.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Podcasts"</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The latest TWiT episode has been posted, in which we hear
  several tech news stories as well as learning much more about the
  iPhone. This week, the panelists compare how reflective their
  iPhones' Apple logos are.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Many pages include logos, insignia, flags, or emblems, which stand for a particular entity such
  as a company, organization, project, band, software package, country, or some such.</p>

  <p>If the logo is being used to represent the entity, e.g. as a page heading, the <code id="a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos:attr-img-alt-4"><a href="#attr-img-alt">alt</a></code> attribute must contain the name of the entity being represented by
  the logo. The <code id="a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos:attr-img-alt-5"><a href="#attr-img-alt">alt</a></code> attribute must <em>not</em> contain text like
  the word "logo", as it is not the fact that it is a logo that is being conveyed, it's the entity
  itself.</p>

  <p>If the logo is being used next to the name of the entity that it represents, then the logo is
  supplemental, and its <code id="a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos:attr-img-alt-6"><a href="#attr-img-alt">alt</a></code> attribute must instead be empty.</p>

  <p>If the logo is merely used as decorative material (as branding, or, for example, as a side
  image in an article that mentions the entity to which the logo belongs), then the entry below on
  purely decorative images applies. If the logo is actually being discussed, then it is being used
  as a phrase or paragraph (the description of the logo) with an alternative graphical
  representation (the logo itself), and the first entry above applies.</p>

  <div class="example">

   <p>In the following snippets, all four of the above cases are present. First, we see a logo used
   to represent a company:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"XYZ.gif"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The XYZ company"</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></code></pre>

   <p>Next, we see a paragraph which uses a logo right next to the company name, and so doesn't have
   any alternative text:

   </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->News<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->We have recently been looking at buying the <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"alpha.gif"</c->
 <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-> ΑΒΓ company</strong>, a small Greek company
 specializing in our type of product.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>In this third snippet, we have a logo being used in an aside, as part of the larger article
   discussing the acquisition:</p>

<pre><code class="html"><strong><c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"alpha-large.gif"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The ΑΒΓ company has had a good quarter, and our
 pie chart studies of their accounts suggest a much bigger blue slice
 than its green and orange slices, which is always a good sign.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <p>Finally, we have an opinion piece talking about a logo, and the logo is therefore described in
   detail in the alternative text.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Consider for a moment their logo:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<strong><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/images/logo"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"It consists of a green circle with a</c->
<c- s="">green question mark centered inside it."</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->How unoriginal can you get? I mean, oooooh, a question mark, how
<c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->revolutionary<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c->, how utterly <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->ground-breaking<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c->, I'm
sure everyone will rush to adopt those specifications now! They could
at least have tried for some sort of, I don't know, sequence of
rounded squares with varying shades of green and bold white outlines,
at least that would look good on the cover of a blue book.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>This example shows how the alternative text should be written such that if the image isn't <i id="a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos:img-available"><a href="#img-available">available</a></i>, and the text is used instead, the text flows seamlessly into
   the surrounding text, as if the image had never been there in the first place.</p>

  </div>


  <h6 id="text-that-has-been-rendered-to-a-graphic-for-typographical-effect"><span class="secno">4.8.4.4.5</span> Text that has been rendered to a graphic for typographical effect<a href="#text-that-has-been-rendered-to-a-graphic-for-typographical-effect" class="self-link"></a></h6>

  <p>Sometimes, an image just consists of text, and the purpose of the image is not to highlight the
  actual typographic effects used to render the text, but just to convey the text itself.</p>

  <p>In such cases, the <code id="text-that-has-been-rendered-to-a-graphic-for-typographical-effect:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute must be present but must
  consist of the same text as written in the image itself.</p>

  <div class="example">

   <p>Consider a graphic containing the text "Earth Day", but with the letters all decorated with
   flowers and plants. If the text is merely being used as a heading, to spice up the page for
   graphical users, then the correct alternative text is just the same text "Earth Day", and no
   mention need be made of the decorations:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"earthdayheading.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Earth Day"</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>An illuminated manuscript might use graphics for some of its images. The alternative text in
   such a situation is just the character that the image represents.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"initials/o.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"O"</c-><c- p="">&gt;</c->nce upon a time and a long long time ago, late at
night, when it was dark, over the hills, through the woods, across a great ocean, in a land far
away, in a small house, on a hill, under a full moon...</code></pre> 

  </div>

  <p>When an image is used to represent a character that cannot otherwise be represented in Unicode,
  for example gaiji, itaiji, or new characters such as novel currency symbols, the alternative text
  should be a more conventional way of writing the same thing, e.g. using the phonetic hiragana or
  katakana to give the character's pronunciation.</p>

  <div class="example">

   <p>In this example from 1997, a new-fangled currency symbol that looks like a curly E with two
   bars in the middle instead of one is represented using an image. The alternative text gives the
   character's pronunciation.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Only <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"euro.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"euro "</c-><c- p="">&gt;</c->5.99!</code></pre>

  </div>

  <p>An image should not be used if characters would serve an identical purpose. Only when the text
  cannot be directly represented using text, e.g., because of decorations or because there is no
  appropriate character (as in the case of gaiji), would an image be appropriate.</p>

  <p class="note">If an author is tempted to use an image because their default system font does not
  support a given character, then web fonts are a better solution than images.</p>



  <h6 id="a-graphical-representation-of-some-of-the-surrounding-text"><span class="secno">4.8.4.4.6</span> A graphical representation of some of the surrounding text<a href="#a-graphical-representation-of-some-of-the-surrounding-text" class="self-link"></a></h6>

  <p>In many cases, the image is actually just supplementary, and its presence merely reinforces the
  surrounding text. In these cases, the <code id="a-graphical-representation-of-some-of-the-surrounding-text:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute must be
  present but its value must be the empty string.</p>

  <p>In general, an image falls into this category if removing the image doesn't make the page any
  less useful, but including the image makes it a lot easier for users of visual browsers to
  understand the concept.</p>

  <div class="example">

   <p>A flowchart that repeats the previous paragraph in graphical form:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The Network passes data to the Input Stream Preprocessor, which
passes it to the Tokenizer, which passes it to the Tree Construction
stage. From there, data goes to both the DOM and to Script Execution.
Script Execution is linked to the DOM, and, using document.write(),
passes data to the Tokenizer.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/parsing-model-overview.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong></code></pre>

   <p>In these cases, it would be wrong to include alternative text that consists of just a caption.
   If a caption is to be included, then either the <code id="a-graphical-representation-of-some-of-the-surrounding-text:attr-title"><a href="#attr-title">title</a></code> attribute
   can be used, or the <code id="a-graphical-representation-of-some-of-the-surrounding-text:the-figure-element"><a href="#the-figure-element">figure</a></code> and <code id="a-graphical-representation-of-some-of-the-surrounding-text:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code> elements can be used. In the
   latter case, the image would in fact be a phrase or paragraph with an alternative graphical
   representation, and would thus require alternative text.</p>

   <pre><code class="html"><c- c="">&lt;!-- Using the title="" attribute --&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The Network passes data to the Input Stream Preprocessor, which
passes it to the Tokenizer, which passes it to the Tree Construction
stage. From there, data goes to both the DOM and to Script Execution.
Script Execution is linked to the DOM, and, using document.write(),
passes data to the Tokenizer.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/parsing-model-overview.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c->
        <c- e="">title</c-><c- o="">=</c-><c- s="">"Flowchart representation of the parsing model."</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- c="">&lt;!-- Using &lt;figure&gt; and &lt;figcaption&gt; --&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The Network passes data to the Input Stream Preprocessor, which
passes it to the Tokenizer, which passes it to the Tree Construction
stage. From there, data goes to both the DOM and to Script Execution.
Script Execution is linked to the DOM, and, using document.write(),
passes data to the Tokenizer.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/parsing-model-overview.svg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The Network leads to</c->
<c- s=""> the Input Stream Preprocessor, which leads to the Tokenizer, which</c->
<c- s=""> leads to the Tree Construction stage. The Tree Construction stage</c->
<c- s=""> leads to two items. The first is Script Execution, which leads via</c->
<c- s=""> document.write() back to the Tokenizer. The second item from which</c->
<c- s=""> Tree Construction leads is the DOM. The DOM is related to the Script</c->
<c- s=""> Execution."</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Flowchart representation of the parsing model.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

   <pre class="bad"><code class="html"><c- c="">&lt;!-- This is WRONG. Do not do this. Instead, do what the above examples do. --&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The Network passes data to the Input Stream Preprocessor, which
passes it to the Tokenizer, which passes it to the Tree Construction
stage. From there, data goes to both the DOM and to Script Execution.
Script Execution is linked to the DOM, and, using document.write(),
passes data to the Tokenizer.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/parsing-model-overview.svg"</c->
        <c- e="">alt</c-><c- o="">=</c-><c- s="">"Flowchart representation of the parsing model."</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- c="">&lt;!-- Never put the image's caption in the alt="" attribute! --&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>A graph that repeats the previous paragraph in graphical form:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->According to a study covering several billion pages,
about 62% of documents on the web in 2007 triggered the Quirks
rendering mode of web browsers, about 30% triggered the Almost
Standards mode, and about 9% triggered the Standards mode.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"rendering-mode-pie-chart.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong></code></pre>

  </div>



  <h6 id="ancillary-images"><span class="secno">4.8.4.4.7</span> Ancillary images<a href="#ancillary-images" class="self-link"></a></h6>

  <p>Sometimes, an image is not critical to the content, but is nonetheless neither purely
  decorative nor entirely redundant with the text. In these cases, the <code id="ancillary-images:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute must be present, and its value should either be the
  empty string, or a textual representation of the information that the image conveys. If the image
  has a caption giving the image's title, then the <code id="ancillary-images:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code>
  attribute's value must not be empty (as that would be quite confusing for non-visual readers).</p>

  <div class="example">

   <p>Consider a news article about a political figure, in which the individual's face was shown in
   an image. The image is not purely decorative, as it is relevant to the story. The image is not
   entirely redundant with the story either, as it shows what the politician looks like. Whether
   any alternative text need be provided is an authoring decision, decided by whether the image
   influences the interpretation of the prose.</p>

   <p>In this first variant, the image is shown without context, and no alternative text is
   provided:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"president.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-></strong> Ahead of today's referendum,
the President wrote an open letter to all registered voters. In it, she admitted that the country was
divided.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>If the picture is just a face, there might be no value in describing it. It's of no interest
   to the reader whether the individual has red hair or blond hair, whether the individual has white
   skin or black skin, whether the individual has one eye or two eyes.</p>

   <p>However, if the picture is more dynamic, for instance showing the politician as angry, or
   particularly happy, or devastated, some alternative text would be useful in setting the tone of
   the article, a tone that might otherwise be missed:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"president.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The President is sad."</c-><c- p="">&gt;</c-></strong>
Ahead of today's referendum, the President wrote an open letter to all
registered voters. In it, she admitted that the country was divided.
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"president.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The President is happy!"</c-><c- p="">&gt;</c-></strong>
Ahead of today's referendum, the President wrote an open letter to all
registered voters. In it, she admitted that the country was divided.
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>Whether the individual was "sad" or "happy" makes a difference to how the rest of the
   paragraph is to be interpreted: is she likely saying that she is unhappy with the country
   being divided, or is she saying that the prospect of a divided country is good for her
   political career? The interpretation varies based on the image.</p>

  </div>

  <div class="example">

   <p>If the image has a caption, then including alternative text avoids leaving the non-visual user
   confused as to what the caption refers to.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Ahead of today's referendum, the President wrote an open letter to
all registered voters. In it, she admitted that the country was divided.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"president.jpeg"</c->
      <c- e="">alt</c-><c- o="">=</c-><c- s="">"A high forehead, cheerful disposition, and dark hair round out the President's face."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c-> The President of Ruritania. Photo © 2014 PolitiPhoto. <c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></strong></code></pre>

  </div>



  <h6 id="a-purely-decorative-image-that-doesn't-add-any-information"><span class="secno">4.8.4.4.8</span> A purely decorative image that doesn't add any information<a href="#a-purely-decorative-image-that-doesn't-add-any-information" class="self-link"></a></h6>

  <p>If an image is decorative but isn't especially page-specific — for example an image that
  forms part of a site-wide design scheme — the image should be specified in the site's CSS,
  not in the markup of the document.</p>

  <p>However, a decorative image that isn't discussed by the surrounding text but still has some
  relevance can be included in a page using the <code id="a-purely-decorative-image-that-doesn't-add-any-information:the-img-element"><a href="#the-img-element">img</a></code> element. Such images are
  decorative, but still form part of the content. In these cases, the <code id="a-purely-decorative-image-that-doesn't-add-any-information:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute must be present but its value must be the empty
  string.</p>

  <div class="example">

   <p>Examples where the image is purely decorative despite being relevant would include things like
   a photo of the Black Rock City landscape in a blog post about an event at Burning Man, or an
   image of a painting inspired by a poem, on a page reciting that poem. The following snippet shows
   an example of the latter case (only the first verse is included in this snippet):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The Lady of Shalott<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"shalott.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->On either side the river lie<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
Long fields of barley and of rye,<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
That clothe the wold and meet the sky;<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
And through the field the road run by<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
To many-tower'd Camelot;<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
And up and down the people go,<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
Gazing where the lilies blow<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
Round an island there below,<c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
The island of Shalott.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h6 id="a-group-of-images-that-form-a-single-larger-picture-with-no-links"><span class="secno">4.8.4.4.9</span> A group of images that form a single larger picture with no links<a href="#a-group-of-images-that-form-a-single-larger-picture-with-no-links" class="self-link"></a></h6>

  <p>When a picture has been sliced into smaller image files that are then displayed together to
  form the complete picture again, one of the images must have its <code id="a-group-of-images-that-form-a-single-larger-picture-with-no-links:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute set as per the relevant rules that would be appropriate
  for the picture as a whole, and then all the remaining images must have their <code id="a-group-of-images-that-form-a-single-larger-picture-with-no-links:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code> attribute set to the empty string.</p>

  <div class="example">

   <p>In the following example, a picture representing a company logo for <span>XYZ
   Corp</span> has been split into two pieces, the first containing the letters "XYZ" and the second
   with the word "Corp". The alternative text ("XYZ Corp") is all in the first image.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"logo1.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"XYZ Corp"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"logo2.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following example, a rating is shown as three filled stars and two empty stars. While
   the alternative text could have been "★★★☆☆", the author has
   instead decided to more helpfully give the rating in the form "3 out of 5". That is the
   alternative text of the first image, and the rest have blank alternative text.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Rating: <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">5</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">3</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"1"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"3 out of 5"</c->
  <c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"1"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"1"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"0"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c->
  <c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"0"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-></strong><c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h6 id="a-group-of-images-that-form-a-single-larger-picture-with-links"><span class="secno">4.8.4.4.10</span> A group of images that form a single larger picture with links<a href="#a-group-of-images-that-form-a-single-larger-picture-with-links" class="self-link"></a></h6>

  <p>Generally, <a href="#image-map" id="a-group-of-images-that-form-a-single-larger-picture-with-links:image-map">image maps</a> should be used instead of slicing an image
  for links.</p>

  <p>However, if an image is indeed sliced and any of the components of the sliced picture are the
  sole contents of links, then one image per link must have alternative text in its <code id="a-group-of-images-that-form-a-single-larger-picture-with-links:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute representing the purpose of the link.</p>

  <div class="example">

   <p>In the following example, a picture representing the flying spaghetti monster emblem, with
   each of the left noodly appendages and the right noodly appendages in different images, so that
   the user can pick the left side or the right side in an adventure.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The Church<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You come across a flying spaghetti monster. Which side of His
Noodliness do you wish to reach out for?<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?go=left"</c-> <c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"fsm-left.png"</c->  <c- e="">alt</c-><c- o="">=</c-><c- s="">"Left side. "</c-><c- p="">&gt;&lt;/</c-><c- f="">a</c->
  <c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"fsm-middle.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c->
  <c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?go=right"</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"fsm-right.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Right side."</c-><c- p="">&gt;&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong></code></pre>

  </div>



  <h6 id="a-key-part-of-the-content"><span class="secno">4.8.4.4.11</span> A key part of the content<a href="#a-key-part-of-the-content" class="self-link"></a></h6>

  <p>In some cases, the image is a critical part of the content. This could be the case, for
  instance, on a page that is part of a photo gallery. The image is the whole <em>point</em> of the
  page containing it.</p>

  <p>How to provide alternative text for an image that is a key part of the content depends on the
  image's provenance.</p>

  <dl><dt>The general case</dt><dd>
    <p>When it is possible for detailed alternative text to be provided, for example if the image is
    part of a series of screenshots in a magazine review, or part of a comic strip, or is a
    photograph in a blog entry about that photograph, text that can serve as a substitute for the
    image must be given as the contents of the <code id="a-key-part-of-the-content:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute.</p>

    <div class="example">

     <p>A screenshot in a gallery of screenshots for a new OS, with some alternative text:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"KDE%20Light%20desktop.png"</c->
      <c- e="">alt</c-><c- o="">=</c-><c- s="">"The desktop is blue, with icons along the left hand side in</c->
<c- s="">           two columns, reading System, Home, K-Mail, etc. A window is</c->
<c- s="">           open showing that menus wrap to a second line if they</c->
<c- s="">           cannot fit in the window. The window has a list of icons</c->
<c- s="">           along the top, with an address bar below it, a list of</c->
<c- s="">           icons for tabs along the left edge, a status bar on the</c->
<c- s="">           bottom, and two panes in the middle. The desktop has a bar</c->
<c- s="">           at the bottom of the screen with a few buttons, a pager, a</c->
<c- s="">           list of open applications, and a clock."</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Screenshot of a KDE desktop.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

    </div>

    <div class="example">

     <p>A graph in a financial report:</p>

     <pre><code class="html"><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"sales.gif"</c->
     <c- e="">title</c-><c- o="">=</c-><c- s="">"Sales graph"</c->
     <c- e="">alt</c-><c- o="">=</c-><c- s="">"From 1998 to 2005, sales increased by the following percentages</c->
<c- s="">     with each year: 624%, 75%, 138%, 40%, 35%, 9%, 21%"</c-><c- p="">&gt;</c-></strong></code></pre>

     <p>Note that "sales graph" would be inadequate alternative text for a sales graph. Text that
     would be a good <em>caption</em> is not generally suitable as replacement text.</p>

    </div>
   </dd><dt>Images that defy a complete description</dt><dd>
    <p>In certain cases, the nature of the image might be such that providing thorough alternative
    text is impractical. For example, the image could be indistinct, or could be a complex fractal,
    or could be a detailed topographical map.</p>

    <p>In these cases, the <code id="a-key-part-of-the-content:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code> attribute must contain some
    suitable alternative text, but it may be somewhat brief.</p>

    <div class="example">

     <p>Sometimes there simply is no text that can do justice to an image. For example, there is
     little that can be said to usefully describe a Rorschach inkblot test. However, a description,
     even if brief, is still better than nothing:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/commons/a/a7/Rorschach1.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"A shape with left-right</c->
<c- s=""> symmetry with indistinct edges, with a small gap in the center, two</c->
<c- s=""> larger gaps offset slightly from the center, with two similar gaps</c->
<c- s=""> under them. The outline is wider in the top half than the bottom</c->
<c- s=""> half, with the sides extending upwards higher than the center, and</c->
<c- s=""> the center extending below the sides."</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->A black outline of the first of the ten cards
 in the Rorschach inkblot test.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

     <p>Note that the following would be a very bad use of alternative text:</p>

     <pre class="bad"><code class="html"><c- c="">&lt;!-- This example is wrong. Do not copy it. --&gt;</c->
<c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/commons/a/a7/Rorschach1.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"A black outline</c->
<c- s=""> of the first of the ten cards in the Rorschach inkblot test."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->A black outline of the first of the ten cards
 in the Rorschach inkblot test.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

     <p>Including the caption in the alternative text like this isn't useful because it effectively
     duplicates the caption for users who don't have images, taunting them twice yet not helping
     them any more than if they had only read or heard the caption once.</p>

    </div>

    <div class="example">

     <p>Another example of an image that defies full description is a fractal, which, by definition,
     is infinite in detail.</p>

     <p>The following example shows one possible way of providing alternative text for the full view
     of an image of the Mandelbrot set.</p>

     <pre><code class="html"><strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"ms1.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The Mandelbrot set appears as a cardioid with</c->
<c- s="">its cusp on the real axis in the positive direction, with a smaller</c->
<c- s="">bulb aligned along the same center line, touching it in the negative</c->
<c- s="">direction, and with these two shapes being surrounded by smaller bulbs</c->
<c- s="">of various sizes."</c-><c- p="">&gt;</c-></strong></code></pre>

    </div>

    <div class="example">

     <p>Similarly, a photograph of a person's face, for example in a biography, can be considered
     quite relevant and key to the content, but it can be hard to fully substitute text for:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"bio"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->A Biography of Isaac Asimov<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Born <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->Isaak Yudovich Ozimov<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> in 1920, Isaac was a prolific author.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"headpics/asimov.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Isaac Asimov had dark hair, a tall forehead, and wore glasses.</c->
<c- s=""> Later in life, he wore long white sideburns."</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Asimov was born in Russia, and moved to the US when he was three years old.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->...<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

     <p>In such cases it is unnecessary (and indeed discouraged) to include a reference to the
     presence of the image itself in the alternative text, since such text would be redundant with
     the browser itself reporting the presence of the image. For example, if the alternative text
     was "A photo of Isaac Asimov", then a conforming user agent might read that out as "(Image) A
     photo of Isaac Asimov" rather than the more useful "(Image) Isaac Asimov had dark hair, a tall
     forehead, and wore glasses...".</p>

    </div>
   </dd><dt id="unknown-images">Images whose contents are not known</dt><dd>
    <p>In some unfortunate cases, there might be no alternative text available at all, either
    because the image is obtained in some automated fashion without any associated alternative text
    (e.g., a webcam), or because the page is being generated by a script using user-provided images
    where the user did not provide suitable or usable alternative text (e.g. photograph sharing
    sites), or because the author does not themself know what the images represent (e.g. a blind
    photographer sharing an image on their blog).</p>

    <p>In such cases, the <code id="a-key-part-of-the-content:attr-img-alt-3"><a href="#attr-img-alt">alt</a></code> attribute may be omitted, but one of
    the following conditions must be met as well:</p>

    <ul><li id="figcaption-as-alt-condition"><p>The <code id="a-key-part-of-the-content:the-img-element"><a href="#the-img-element">img</a></code> element is in a
     <code id="a-key-part-of-the-content:the-figure-element"><a href="#the-figure-element">figure</a></code> element that contains a <code id="a-key-part-of-the-content:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code> element that contains
     content other than <a href="#inter-element-whitespace" id="a-key-part-of-the-content:inter-element-whitespace">inter-element whitespace</a>, and, ignoring the
     <code id="a-key-part-of-the-content:the-figcaption-element-2"><a href="#the-figcaption-element">figcaption</a></code> element and its descendants, the <code id="a-key-part-of-the-content:the-figure-element-2"><a href="#the-figure-element">figure</a></code> element has no
     <a href="#flow-content-2" id="a-key-part-of-the-content:flow-content-2">flow content</a> descendants other than <a href="#inter-element-whitespace" id="a-key-part-of-the-content:inter-element-whitespace-2">inter-element whitespace</a> and the
     <code id="a-key-part-of-the-content:the-img-element-2"><a href="#the-img-element">img</a></code> element.</p></li><li>
      <p>The <code id="a-key-part-of-the-content:attr-title"><a href="#attr-title">title</a></code> attribute is present and has a non-empty
      value.</p>

      
      <p class="note">Relying on the <code id="a-key-part-of-the-content:attr-title-2"><a href="#attr-title">title</a></code> attribute is currently
      discouraged as many user agents do not expose the attribute in an accessible manner as
      required by this specification (e.g. requiring a pointing device such as a mouse to cause a
      tooltip to appear, which excludes keyboard-only users and touch-only users, such as anyone
      with a modern phone or tablet).</p>
     </li></ul>

    <p class="note">Such cases are to be kept to an absolute minimum. If there is even the slightest
    possibility of the author having the ability to provide real alternative text, then it would not
    be acceptable to omit the <code id="a-key-part-of-the-content:attr-img-alt-4"><a href="#attr-img-alt">alt</a></code> attribute.</p>

    <div class="example">

     <p>A photo on a photo-sharing site, if the site received the image with no metadata other than
     the caption, could be marked up as follows:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"1100670787_6a7c664aef.jpg"</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Bubbles traveled everywhere with us.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

     <p>It would be better, however, if a detailed description of the important parts of the image
     obtained from the user and included on the page.</p>

    </div>

    <div class="example">

     <p>A blind user's blog in which a photo taken by the user is shown. Initially, the user might
     not have any idea what the photo they took shows:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->I took a photo<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I went out today and took a photo!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
  <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"photo2.jpeg"</c-><c- p="">&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->A photograph taken blindly from my front porch.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

     <p>Eventually though, the user might obtain a description of the image from their friends and
     could then include alternative text:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->I took a photo<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I went out today and took a photo!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
  <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"photo2.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"The photograph shows my squirrel</c->
<c- s="">  feeder hanging from the edge of my roof. It is half full, but there</c->
<c- s="">  are no squirrels around. In the background, out-of-focus trees fill the</c->
<c- s="">  shot. The feeder is made of wood with a metal grate, and it contains</c->
<c- s="">  peanuts. The edge of the roof is wooden too, and is painted white</c->
<c- s="">  with light blue streaks."</c-><c- p="">&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->A photograph taken blindly from my front porch.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

    </div>

    <div class="example">

     <p>Sometimes the entire point of the image is that a textual description is not available, and
     the user is to provide the description. For instance, the point of a CAPTCHA image is to see if
     the user can literally read the graphic. Here is one way to mark up a CAPTCHA (note the <code id="a-key-part-of-the-content:attr-title-3"><a href="#attr-title">title</a></code> attribute):</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->What does this image say?
<strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"captcha.cgi?id=8934"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"CAPTCHA"</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">captcha</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
(If you cannot see the image, you can use an <c- p="">&lt;</c-><c- f="">a</c->
<c- e="">href</c-><c- o="">=</c-><c- s="">"?audio"</c-><c- p="">&gt;</c->audio<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> test instead.)<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

     <p>Another example would be software that displays images and asks for alternative text
     precisely for the purpose of then writing a page with correct alternative text. Such a page
     could have a table of images, like this:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Image <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Description
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"2421.png"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Image 640 by 100, filename 'banner.gif'"</c-><c- p="">&gt;</c-></strong>
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"alt2421"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <strong><c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"2422.png"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Image 200 by 480, filename 'ad3.gif'"</c-><c- p="">&gt;</c-></strong>
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"alt2422"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

     <p>Notice that even in this example, as much useful information as possible is still included
     in the <code id="a-key-part-of-the-content:attr-title-4"><a href="#attr-title">title</a></code> attribute.</p>

    </div>

    <p class="note">Since some users cannot use images at all (e.g. because they have a very slow
    connection, or because they are using a text-only browser, or because they are listening to the
    page being read out by a hands-free automobile voice web browser, or simply because they are
    blind), the <code id="a-key-part-of-the-content:attr-img-alt-5"><a href="#attr-img-alt">alt</a></code> attribute is only allowed to be omitted rather
    than being provided with replacement text when no alternative text is available and none can be
    made available, as in the above examples. Lack of effort from the part of the author is not an
    acceptable reason for omitting the <code id="a-key-part-of-the-content:attr-img-alt-6"><a href="#attr-img-alt">alt</a></code> attribute.</p>
   </dd></dl>



  <h6 id="an-image-not-intended-for-the-user"><span class="secno">4.8.4.4.12</span> An image not intended for the user<a href="#an-image-not-intended-for-the-user" class="self-link"></a></h6>

  <p>Generally authors should avoid using <code id="an-image-not-intended-for-the-user:the-img-element"><a href="#the-img-element">img</a></code> elements for purposes other than showing
  images.</p>

  <p>If an <code id="an-image-not-intended-for-the-user:the-img-element-2"><a href="#the-img-element">img</a></code> element is being used for purposes other than showing an image, e.g. as
  part of a service to count page views, then the <code id="an-image-not-intended-for-the-user:attr-img-alt"><a href="#attr-img-alt">alt</a></code> attribute
  must be the empty string.</p>

  <p>In such cases, the <code id="an-image-not-intended-for-the-user:attr-dim-width"><a href="#attr-dim-width">width</a></code> and <code id="an-image-not-intended-for-the-user:attr-dim-height"><a href="#attr-dim-height">height</a></code> attributes should both be set to zero.</p>


  <h6 id="an-image-in-an-e-mail-or-private-document-intended-for-a-specific-person-who-is-known-to-be-able-to-view-images"><span class="secno">4.8.4.4.13</span> An image in an email or private document intended for a specific person who is known to be able to view images<a href="#an-image-in-an-e-mail-or-private-document-intended-for-a-specific-person-who-is-known-to-be-able-to-view-images" class="self-link"></a></h6>

  <p><i>This section does not apply to documents that are publicly accessible, or whose target
  audience is not necessarily personally known to the author, such as documents on a web site,
  emails sent to public mailing lists, or software documentation.</i></p>

  <p>When an image is included in a private communication (such as an HTML email) aimed at a
  specific person who is known to be able to view images, the <code id="an-image-in-an-e-mail-or-private-document-intended-for-a-specific-person-who-is-known-to-be-able-to-view-images:attr-img-alt"><a href="#attr-img-alt">alt</a></code>
  attribute may be omitted. However, even in such cases authors are strongly urged to include
  alternative text (as appropriate according to the kind of image involved, as described in the
  above entries), so that the email is still usable should the user use a mail client that does not
  support images, or should the document be forwarded on to other users whose abilities might not
  include easily seeing images.</p>




  

  <h6 id="guidance-for-markup-generators"><span class="secno">4.8.4.4.14</span> Guidance for markup generators<a href="#guidance-for-markup-generators" class="self-link"></a></h6>

  <p>Markup generators (such as WYSIWYG authoring tools) should, wherever possible, obtain
  alternative text from their users. However, it is recognized that in many cases, this will not be
  possible.</p>

  <p>For images that are the sole contents of links, markup generators should examine the link
  target to determine the title of the target, or the URL of the target, and use information
  obtained in this manner as the alternative text.</p>

  <p>For images that have captions, markup generators should use the <code id="guidance-for-markup-generators:the-figure-element"><a href="#the-figure-element">figure</a></code> and
  <code id="guidance-for-markup-generators:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code> elements, or the <code id="guidance-for-markup-generators:attr-title"><a href="#attr-title">title</a></code> attribute, to
  provide the image's caption.</p>

  <p>As a last resort, implementers should either set the <code id="guidance-for-markup-generators:attr-img-alt"><a href="#attr-img-alt">alt</a></code>
  attribute to the empty string, under the assumption that the image is a purely decorative image
  that doesn't add any information but is still specific to the surrounding content, or omit the
  <code id="guidance-for-markup-generators:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code> attribute altogether, under the assumption that the image is
  a key part of the content.</p>

  <p>Markup generators may specify a <dfn id="attr-img-generator-unable-to-provide-required-alt"><code>generator-unable-to-provide-required-alt</code></dfn>
  attribute on <code id="guidance-for-markup-generators:the-img-element"><a href="#the-img-element">img</a></code> elements for which they have been unable to obtain alternative text
  and for which they have therefore omitted the <code id="guidance-for-markup-generators:attr-img-alt-3"><a href="#attr-img-alt">alt</a></code> attribute. The
  value of this attribute must be the empty string. Documents containing such attributes are not
  conforming, but conformance checkers will <a href="#guidance-for-conformance-checkers">silently
  ignore</a> this error.</p>

  <p class="note">This is intended to avoid markup generators from being pressured into replacing
  the error of omitting the <code id="guidance-for-markup-generators:attr-img-alt-4"><a href="#attr-img-alt">alt</a></code> attribute with the even more
  egregious error of providing phony alternative text, because state-of-the-art automated
  conformance checkers cannot distinguish phony alternative text from correct alternative text.</p>

  <p>Markup generators should generally avoid using the image's own filename as the alternative
  text. Similarly, markup generators should avoid generating alternative text from any content that
  will be equally available to presentation user agents (e.g., web browsers).</p>

  <p class="note">This is because once a page is generated, it will typically not be updated,
  whereas the browsers that later read the page can be updated by the user, therefore the browser is
  likely to have more up-to-date and finely-tuned heuristics than the markup generator did when
  generating the page.</p>

  

  

  <h6 id="guidance-for-conformance-checkers"><span class="secno">4.8.4.4.15</span> Guidance for conformance checkers<a href="#guidance-for-conformance-checkers" class="self-link"></a></h6>

  <p>A conformance checker must report the lack of an <code id="guidance-for-conformance-checkers:attr-img-alt"><a href="#attr-img-alt">alt</a></code>
  attribute as an error unless one of the conditions listed below applies:</p>

  <ul><li><p>The <code id="guidance-for-conformance-checkers:the-img-element"><a href="#the-img-element">img</a></code> element is in a <code id="guidance-for-conformance-checkers:the-figure-element"><a href="#the-figure-element">figure</a></code> element that satisfies <a href="#figcaption-as-alt-condition">the conditions described above</a>.</p></li><li><p>The <code id="guidance-for-conformance-checkers:the-img-element-2"><a href="#the-img-element">img</a></code> element has a <code id="guidance-for-conformance-checkers:attr-title"><a href="#attr-title">title</a></code> attribute with a
   value that is not the empty string (also as <a href="#unknown-images">described
   above</a>).</p></li><li><p>The conformance checker has been configured to assume that the document is an email or
   document intended for a specific person who is known to be able to view images.</p></li><li><p>The <code id="guidance-for-conformance-checkers:the-img-element-3"><a href="#the-img-element">img</a></code> element has a (non-conforming) <code id="guidance-for-conformance-checkers:attr-img-generator-unable-to-provide-required-alt"><a href="#attr-img-generator-unable-to-provide-required-alt">generator-unable-to-provide-required-alt</a></code>
   attribute whose value is the empty string. A conformance checker that is not reporting the lack
   of an <code id="guidance-for-conformance-checkers:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code> attribute as an error must also not report the
   presence of the empty <code id="guidance-for-conformance-checkers:attr-img-generator-unable-to-provide-required-alt-2"><a href="#attr-img-generator-unable-to-provide-required-alt">generator-unable-to-provide-required-alt</a></code>
   attribute as an error. (This case does not represent a case where the document is conforming,
   only that the generator could not determine appropriate alternative text — validators are
   not required to show an error in this case, because such an error might encourage markup
   generators to include bogus alternative text purely in an attempt to silence validators.
   Naturally, conformance checkers <em>may</em> report the lack of an <code id="guidance-for-conformance-checkers:attr-img-alt-3"><a href="#attr-img-alt">alt</a></code> attribute as an error even in the presence of the <code id="guidance-for-conformance-checkers:attr-img-generator-unable-to-provide-required-alt-3"><a href="#attr-img-generator-unable-to-provide-required-alt">generator-unable-to-provide-required-alt</a></code>
   attribute; for example, there could be a user option to report <em>all</em> conformance errors
   even those that might be the more or less inevitable result of using a markup
   generator.)</p></li></ul>

  


  <h4 id="the-iframe-element"><span class="secno">4.8.5</span> The
  <dfn data-dfn-type="element"><code>iframe</code></dfn> element<a href="#the-iframe-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe" title="The <iframe> HTML element represents a nested browsing context, embedding another HTML page into the current one.">Element/iframe</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>15+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement" title="The HTMLIFrameElement interface provides special properties and methods (beyond those of the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of inline frame elements.">HTMLIFrameElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/src" title="The HTMLIFrameElement.src property reflects the HTML referrerpolicy attribute of the <iframe> element defining which referrer is sent when fetching the resource.">HTMLIFrameElement/src</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/width" title="The width property of the HTMLObjectElement interface returns a string that reflects the width HTML attribute, specifying the displayed width of the resource in CSS pixels.">HTMLObjectElement/width</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/height" title="The height property of the HTMLObjectElement interface Returns a string that reflects the height HTML attribute, specifying the displayed height of the resource in CSS pixels.">HTMLObjectElement/height</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-iframe-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-iframe-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-iframe-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#embedded-content-category" id="the-iframe-element:embedded-content-category">Embedded content</a>.</dd><dd><a href="#interactive-content-2" id="the-iframe-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#palpable-content-2" id="the-iframe-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-iframe-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#embedded-content-category" id="the-iframe-element:embedded-content-category-2">embedded content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-iframe-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-iframe-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-iframe-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-iframe-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-iframe-element:global-attributes">Global attributes</a></dd><dd><code id="the-iframe-element:attr-iframe-src"><a href="#attr-iframe-src">src</a></code> —  Address of the resource
     </dd><dd><code id="the-iframe-element:attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> —  A document to render in the <code id="the-iframe-element:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>
     </dd><dd><code id="the-iframe-element:attr-iframe-name"><a href="#attr-iframe-name">name</a></code> —  Name of <a href="#content-navigable" id="the-iframe-element:content-navigable">content navigable</a>
     </dd><dd><code id="the-iframe-element:attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> —  Security rules for nested content
     </dd><dd><code id="the-iframe-element:attr-iframe-allow"><a href="#attr-iframe-allow">allow</a></code> —  <a href="https://w3c.github.io/webappsec-feature-policy/#permissions-policy" id="the-iframe-element:concept-permissions-policy" data-x-internal="concept-permissions-policy">Permissions policy</a> to be applied to the <code id="the-iframe-element:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>'s contents
     </dd><dd><code id="the-iframe-element:attr-iframe-allowfullscreen"><a href="#attr-iframe-allowfullscreen">allowfullscreen</a></code> —  Whether to allow the <code id="the-iframe-element:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code>'s contents to use <code id="the-iframe-element:dom-element-requestfullscreen"><a data-x-internal="dom-element-requestfullscreen" href="https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen">requestFullscreen()</a></code>
     </dd><dd><code id="the-iframe-element:attr-dim-width"><a href="#attr-dim-width">width</a></code> —  Horizontal dimension
     </dd><dd><code id="the-iframe-element:attr-dim-height"><a href="#attr-dim-height">height</a></code> —  Vertical dimension
     </dd><dd><code id="the-iframe-element:attr-iframe-referrerpolicy"><a href="#attr-iframe-referrerpolicy">referrerpolicy</a></code> —  <a id="the-iframe-element:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">Referrer policy</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-iframe-element:concept-fetch" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </dd><dd><code id="the-iframe-element:attr-iframe-loading"><a href="#attr-iframe-loading">loading</a></code> —  Used when determining loading deferral
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-iframe-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-iframe">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-iframe">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-iframe-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmliframeelement" data-dfn-type="interface"><c- g="">HTMLIFrameElement</c-></dfn> : <a href="#htmlelement" id="the-iframe-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-iframe-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-iframe-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-iframe-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-src" data-dfn-type="attribute"><c- g="">src</c-></dfn>;
  [<a href="#cereactions" id="the-iframe-element:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> (<code id="the-iframe-element:tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> <c- b="">DOMString</c->) <a href="#dom-iframe-srcdoc" id="the-iframe-element:dom-iframe-srcdoc"><c- g="">srcdoc</c-></a>;
  [<a href="#cereactions" id="the-iframe-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-iframe-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-iframe-element:dom-domtokenlist-value" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-iframe-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-iframe-element:domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-sandbox" data-dfn-type="attribute"><c- g="">sandbox</c-></dfn>;
  [<a href="#cereactions" id="the-iframe-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-iframe-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-allow" data-dfn-type="attribute"><c- g="">allow</c-></dfn>;
  [<a href="#cereactions" id="the-iframe-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-iframe-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-allowfullscreen" data-dfn-type="attribute"><c- g="">allowFullscreen</c-></dfn>;
  [<a href="#cereactions" id="the-iframe-element:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-iframe-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-dim-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;
  [<a href="#cereactions" id="the-iframe-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-iframe-element:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-dim-height" data-dfn-type="attribute"><c- g="">height</c-></dfn>;
  [<a href="#cereactions" id="the-iframe-element:cereactions-8"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-iframe-referrerpolicy" id="the-iframe-element:dom-iframe-referrerpolicy"><c- g="">referrerPolicy</c-></a>;
  [<a href="#cereactions" id="the-iframe-element:cereactions-9"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-iframe-loading" id="the-iframe-element:dom-iframe-loading"><c- g="">loading</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#document" id="the-iframe-element:document"><c- n="">Document</c-></a>? <a href="#dom-iframe-contentdocument" id="the-iframe-element:dom-iframe-contentdocument"><c- g="">contentDocument</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#windowproxy" id="the-iframe-element:windowproxy"><c- n="">WindowProxy</c-></a>? <a href="#dom-iframe-contentwindow" id="the-iframe-element:dom-iframe-contentwindow"><c- g="">contentWindow</c-></a>;
  <a href="#document" id="the-iframe-element:document-2"><c- n="">Document</c-></a>? <a href="#dom-media-getsvgdocument" id="the-iframe-element:dom-media-getsvgdocument"><c- g="">getSVGDocument</c-></a>();

  // <a href="#HTMLIFrameElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  

  <p>The <code id="the-iframe-element:the-iframe-element-4"><a href="#the-iframe-element">iframe</a></code> element <a href="#represents" id="the-iframe-element:represents">represents</a> its <a href="#content-navigable" id="the-iframe-element:content-navigable-2">content navigable</a>.</p>


  

  <p>The <dfn data-dfn-for="iframe" id="attr-iframe-src" data-dfn-type="element-attr"><code>src</code></dfn> attribute
  gives the <a id="the-iframe-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of a page that the element's <a href="#content-navigable" id="the-iframe-element:content-navigable-3">content navigable</a> is to
  contain. The attribute, if present, must be a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="the-iframe-element:valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by
  spaces</a>. If the <code id="the-iframe-element:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is specified on an
  <code id="the-iframe-element:the-iframe-element-5"><a href="#the-iframe-element">iframe</a></code> element, then the <code id="the-iframe-element:attr-iframe-src-2"><a href="#attr-iframe-src">src</a></code> attribute must
  also be specified.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-srcdoc" title="The <iframe> HTML element represents a nested browsing context, embedding another HTML page into the current one.">Element/iframe#attr-srcdoc</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>25+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="iframe" id="attr-iframe-srcdoc" data-dfn-type="element-attr"><code>srcdoc</code></dfn>
  attribute gives the content of the page that the element's <a href="#content-navigable" id="the-iframe-element:content-navigable-4">content navigable</a> is to
  contain. The value of the attribute is used to <a href="#create-navigation-params-from-a-srcdoc-resource" id="the-iframe-element:create-navigation-params-from-a-srcdoc-resource">construct</a> <dfn id="an-iframe-srcdoc-document" data-export="">an <code>iframe</code> <code>srcdoc</code> document</dfn>, which is a <code id="the-iframe-element:document-3"><a href="#document">Document</a></code> whose
  <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-iframe-element:the-document's-address" data-x-internal="the-document's-address">URL</a> <a href="#matches-about:srcdoc" id="the-iframe-element:matches-about:srcdoc">matches <code>about:srcdoc</code></a>.</p>

  <div data-algorithm="">
  <p>The <code id="the-iframe-element:attr-iframe-srcdoc-2"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute, if present, must have a value
  using <a href="#syntax" id="the-iframe-element:syntax">the HTML syntax</a> that consists of the following syntactic components, in the
  given order:</p>

  <ol><li>Any number of <a href="#syntax-comments" id="the-iframe-element:syntax-comments">comments</a> and <a id="the-iframe-element:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
   whitespace</a>.</li><li>Optionally, a <a href="#syntax-doctype" id="the-iframe-element:syntax-doctype">DOCTYPE</a>.

   </li><li>Any number of <a href="#syntax-comments" id="the-iframe-element:syntax-comments-2">comments</a> and <a id="the-iframe-element:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
   whitespace</a>.</li><li>The <a id="the-iframe-element:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>, in the form of an <code id="the-iframe-element:the-html-element"><a href="#the-html-element">html</a></code> <a href="#syntax-elements" id="the-iframe-element:syntax-elements">element</a>.</li><li>Any number of <a href="#syntax-comments" id="the-iframe-element:syntax-comments-3">comments</a> and <a id="the-iframe-element:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
   whitespace</a>.</li></ol>
  </div>

  <p class="note">The above requirements apply in <a id="the-iframe-element:xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a> as well.

  </p><div class="example">

   <p>Here a blog uses the <code id="the-iframe-element:attr-iframe-srcdoc-3"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute in conjunction
   with the <code id="the-iframe-element:attr-iframe-sandbox-2"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute described below to provide
   users of user agents that support this feature with an extra layer of protection from script
   injection in the blog post comments:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->I got my own magazine!<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->After much effort, I've finally found a publisher, and so now I
 have my own magazine! Isn't that awesome?! The first issue will come
 out in September, and we have articles about getting food, and about
 getting in boxes, it's going to be great!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Written by <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/users/cap"</c-><c- p="">&gt;</c->cap<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->, 1 hour ago.
 <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c-> Thirteen minutes ago, <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/users/ch"</c-><c- p="">&gt;</c->ch<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> wrote: <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">sandbox</c-> <c- e="">srcdoc</c-><c- o="">=</c-><c- s="">"&lt;p&gt;did you get a cover picture yet?"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c-> Nine minutes ago, <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/users/cap"</c-><c- p="">&gt;</c->cap<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> wrote: <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">sandbox</c-> <c- e="">srcdoc</c-><c- o="">=</c-><c- s="">"&lt;p&gt;Yeah, you can see it &lt;a href=&amp;quot;/gallery?mode=cover&amp;amp;amp;page=1&amp;quot;&gt;in my gallery&lt;/a&gt;."</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c-> Five minutes ago, <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/users/ch"</c-><c- p="">&gt;</c->ch<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> wrote: <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">sandbox</c-> <c- e="">srcdoc</c-><c- o="">=</c-><c- s="">"&lt;p&gt;hey that's earl's table.</c->
<c- s="">&lt;p&gt;you should get earl&amp;amp;amp;me on the next cover."</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <p>Notice the way that quotes have to be escaped (otherwise the <code id="the-iframe-element:attr-iframe-srcdoc-4"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute would end prematurely), and the way raw
   ampersands (e.g. in URLs or in prose) mentioned in the sandboxed content have to be
   <em>doubly</em> escaped — once so that the ampersand is preserved when originally parsing
   the <code id="the-iframe-element:attr-iframe-srcdoc-5"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute, and once more to prevent the
   ampersand from being misinterpreted when parsing the sandboxed content.</p>

   <p>Furthermore, notice that since the <a href="#syntax-doctype" id="the-iframe-element:syntax-doctype-2">DOCTYPE</a> is optional in
   <a href="#an-iframe-srcdoc-document" id="the-iframe-element:an-iframe-srcdoc-document"><code>iframe</code> <code>srcdoc</code> documents</a>, and the <code id="the-iframe-element:the-html-element-2"><a href="#the-html-element">html</a></code>,
   <code id="the-iframe-element:the-head-element"><a href="#the-head-element">head</a></code>, and <code id="the-iframe-element:the-body-element"><a href="#the-body-element">body</a></code> elements have <a href="#syntax-tag-omission">optional
   start and end tags</a>, and the <code id="the-iframe-element:the-title-element"><a href="#the-title-element">title</a></code> element is also optional in <a href="#an-iframe-srcdoc-document" id="the-iframe-element:an-iframe-srcdoc-document-2"><code>iframe</code> <code>srcdoc</code>
   documents</a>, the markup in a <code id="the-iframe-element:attr-iframe-srcdoc-6"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute can be
   relatively succinct despite representing an entire document, since only the contents of the
   <code id="the-iframe-element:the-body-element-2"><a href="#the-body-element">body</a></code> element need appear literally in the syntax. The other elements are still
   present, but only by implication.</p>

  </div>

  <p class="note">In <a href="#syntax" id="the-iframe-element:syntax-2">the HTML syntax</a>, authors need only remember to use U+0022
  QUOTATION MARK characters (") to wrap the attribute contents and then to escape all U+0026
  AMPERSAND (&amp;) and U+0022 QUOTATION MARK (") characters, and to specify the <code id="the-iframe-element:attr-iframe-sandbox-3"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute, to ensure safe embedding of content. (And
  remember to escape ampersands before quotation marks, to ensure quotation marks become &amp;quot;
  and not &amp;amp;quot;.)</p>

  <p class="note">In XML the U+003C LESS-THAN SIGN character (&lt;) needs to be escaped as well. In
  order to prevent <a href="https://www.w3.org/TR/xml/#AVNormalize">attribute-value
  normalization</a>, some of XML's whitespace characters — specifically U+0009 CHARACTER
  TABULATION (tab), U+000A LINE FEED (LF), and U+000D CARRIAGE RETURN (CR) — also need to be
  escaped. <a href="#refsXML">[XML]</a></p>

  <p class="note">If the <code id="the-iframe-element:attr-iframe-src-3"><a href="#attr-iframe-src">src</a></code> attribute and the <code id="the-iframe-element:attr-iframe-srcdoc-7"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute are both specified together, the <code id="the-iframe-element:attr-iframe-srcdoc-8"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute takes priority. This allows authors to provide
  a fallback <a id="the-iframe-element:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> for legacy user agents that do not support the <code id="the-iframe-element:attr-iframe-srcdoc-9"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute.</p>


  

  <hr> 

  <div data-algorithm="">
  <p>The <code id="the-iframe-element:the-iframe-element-6"><a href="#the-iframe-element">iframe</a></code> <a href="#html-element-post-connection-steps" id="the-iframe-element:html-element-post-connection-steps">HTML element post-connection steps</a>, given
  <var>insertedNode</var>, are:</p>

  <ol><li><p><a href="#create-a-new-child-navigable" id="the-iframe-element:create-a-new-child-navigable">Create a new child navigable</a> for <var>insertedNode</var>.</p></li><li><p>If <var>insertedNode</var> has a <code id="the-iframe-element:attr-iframe-sandbox-4"><a href="#attr-iframe-sandbox">sandbox</a></code>
   attribute, then <a href="#parse-a-sandboxing-directive" id="the-iframe-element:parse-a-sandboxing-directive">parse the sandboxing
   directive</a> given the attribute's value and <var>insertedNode</var>'s
   <a href="#iframe-sandboxing-flag-set" id="the-iframe-element:iframe-sandboxing-flag-set"><code>iframe</code> sandboxing flag set</a>.</p></li><li><p><a href="#process-the-iframe-attributes" id="the-iframe-element:process-the-iframe-attributes">Process the <code>iframe</code> attributes</a> for <var>insertedNode</var>, with
   <i id="the-iframe-element:process-iframe-initial-insertion"><a href="#process-iframe-initial-insertion">initialInsertion</a></i> set to true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-iframe-element:the-iframe-element-7"><a href="#the-iframe-element">iframe</a></code> <a href="#html-element-removing-steps" id="the-iframe-element:html-element-removing-steps">HTML element removing steps</a>, given
  <var>removedNode</var>, are to <a href="#destroy-a-child-navigable" id="the-iframe-element:destroy-a-child-navigable">destroy a child navigable</a> given
  <var>removedNode</var>.</p>
  </div>

  <p class="note">This happens without any <code id="the-iframe-element:event-unload"><a href="#event-unload">unload</a></code> events firing
  (the element's <a href="#concept-bcc-content-document" id="the-iframe-element:concept-bcc-content-document">content document</a> is <em><a href="#destroy-a-child-navigable" id="the-iframe-element:destroy-a-child-navigable-2">destroyed</a></em>, not <em><a href="#unload-a-document" id="the-iframe-element:unload-a-document">unloaded</a></em>).</p>

  <p class="XXX">Although <code id="the-iframe-element:the-iframe-element-8"><a href="#the-iframe-element">iframe</a></code>s are processed while in a <a id="the-iframe-element:shadow-tree" href="https://dom.spec.whatwg.org/#concept-shadow-tree" data-x-internal="shadow-tree">shadow tree</a>,
  per the above, several other aspects of their behavior are not well-defined with regards to
  shadow trees. See <a href="https://github.com/whatwg/html/issues/763">issue #763</a> for more
  detail.</p>

  

  <div data-algorithm="">
  <p>Whenever an <code id="the-iframe-element:the-iframe-element-9"><a href="#the-iframe-element">iframe</a></code> element with a non-null <a href="#content-navigable" id="the-iframe-element:content-navigable-5">content navigable</a> has its
  <code id="the-iframe-element:attr-iframe-srcdoc-10"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute set, changed, or removed, the user
  agent must <a href="#process-the-iframe-attributes" id="the-iframe-element:process-the-iframe-attributes-2">process the <code>iframe</code> attributes</a>.</p>
  </div>

  <div data-algorithm="">
  <p>Similarly, whenever an <code id="the-iframe-element:the-iframe-element-10"><a href="#the-iframe-element">iframe</a></code> element with a non-null <a href="#content-navigable" id="the-iframe-element:content-navigable-6">content
  navigable</a> but with no <code id="the-iframe-element:attr-iframe-srcdoc-11"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute specified
  has its <code id="the-iframe-element:attr-iframe-src-4"><a href="#attr-iframe-src">src</a></code> attribute set, changed, or removed, the user
  agent must <a href="#process-the-iframe-attributes" id="the-iframe-element:process-the-iframe-attributes-3">process the <code>iframe</code> attributes</a>.</p> 
  </div>

  <div data-algorithm="">
  <p>To <dfn id="process-the-iframe-attributes">process the <code>iframe</code> attributes</dfn> for an element <var>element</var>,
  with an optional boolean <dfn id="process-iframe-initial-insertion"><var>initialInsertion</var></dfn> (default false):</p>

  <ol><li>
    <p>If <var>element</var>'s <code id="the-iframe-element:attr-iframe-srcdoc-12"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute is
    specified, then:</p>

    <ol><li><p>Set <var>element</var>'s <a href="#current-navigation-was-lazy-loaded" id="the-iframe-element:current-navigation-was-lazy-loaded">current navigation was lazy loaded</a> boolean to
     false.</p></li><li>
      <p>If the <a href="#will-lazy-load-element-steps" id="the-iframe-element:will-lazy-load-element-steps">will lazy load element steps</a> given <var>element</var> return true,
      then:</p>

      <ol><li><p>Set <var>element</var>'s <a href="#lazy-load-resumption-steps" id="the-iframe-element:lazy-load-resumption-steps">lazy load resumption steps</a> to the rest of this
       algorithm starting with the step labeled <i>navigate to the srcdoc resource</i>.</p></li><li><p>Set <var>element</var>'s <a href="#current-navigation-was-lazy-loaded" id="the-iframe-element:current-navigation-was-lazy-loaded-2">current navigation was lazy loaded</a> boolean to
       true.</p></li><li><p><a href="#start-intersection-observing-a-lazy-loading-element" id="the-iframe-element:start-intersection-observing-a-lazy-loading-element">Start intersection-observing a lazy loading element</a> for
       <var>element</var>.</p></li><li><p>Return.</p></li></ol>
     </li><li>
      <p><i>Navigate to the srcdoc resource</i>: <a href="#navigate-an-iframe-or-frame" id="the-iframe-element:navigate-an-iframe-or-frame">Navigate an <code>iframe</code> or
      <code>frame</code></a> given <var>element</var>, <code id="the-iframe-element:about:srcdoc"><a href="#about:srcdoc">about:srcdoc</a></code>, the empty
      string, and the value of <var>element</var>'s <code id="the-iframe-element:attr-iframe-srcdoc-13"><a href="#attr-iframe-srcdoc">srcdoc</a></code>
      attribute.</p>

      <p>The resulting <code id="the-iframe-element:document-4"><a href="#document">Document</a></code> must be considered <a href="#an-iframe-srcdoc-document" id="the-iframe-element:an-iframe-srcdoc-document-3">an <code>iframe</code> <code>srcdoc</code> document</a>.</p>
     </li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>url</var> be the result of running the <a href="#shared-attribute-processing-steps-for-iframe-and-frame-elements" id="the-iframe-element:shared-attribute-processing-steps-for-iframe-and-frame-elements">shared attribute processing steps
     for <code>iframe</code> and <code>frame</code> elements</a> given <var>element</var> and
     <var>initialInsertion</var>.</p></li><li><p>If <var>url</var> is null, then return.</p></li><li>
      <p>If <var>url</var> <a href="#matches-about:blank" id="the-iframe-element:matches-about:blank">matches <code>about:blank</code></a> and
      <var>initialInsertion</var> is true, then:</p>

      <ol><li><p>Run the <a href="#iframe-load-event-steps" id="the-iframe-element:iframe-load-event-steps">iframe load event steps</a> given <var>element</var>.</p></li><li><p>Return.</p></li></ol>
     </li><li><p>Let <var>referrerPolicy</var> be the current state of <var>element</var>'s <code id="the-iframe-element:attr-iframe-referrerpolicy-2"><a href="#attr-iframe-referrerpolicy">referrerpolicy</a></code> content attribute.</p></li><li><p>Set <var>element</var>'s <a href="#current-navigation-was-lazy-loaded" id="the-iframe-element:current-navigation-was-lazy-loaded-3">current navigation was lazy loaded</a> boolean to
     false.</p></li><li>
      <p>If the <a href="#will-lazy-load-element-steps" id="the-iframe-element:will-lazy-load-element-steps-2">will lazy load element steps</a> given <var>element</var> return true,
      then:</p>

      <ol><li><p>Set <var>element</var>'s <a href="#lazy-load-resumption-steps" id="the-iframe-element:lazy-load-resumption-steps-2">lazy load resumption steps</a> to the rest of this
       algorithm starting with the step labeled <i>navigate</i>.</p></li><li><p>Set <var>element</var>'s <a href="#current-navigation-was-lazy-loaded" id="the-iframe-element:current-navigation-was-lazy-loaded-4">current navigation was lazy loaded</a> boolean to
       true.</p></li><li><p><a href="#start-intersection-observing-a-lazy-loading-element" id="the-iframe-element:start-intersection-observing-a-lazy-loading-element-2">Start intersection-observing a lazy loading element</a> for
       <var>element</var>.</p></li><li><p>Return.</p></li></ol>
     </li><li><p><i>Navigate</i>: <a href="#navigate-an-iframe-or-frame" id="the-iframe-element:navigate-an-iframe-or-frame-2">Navigate an <code>iframe</code> or <code>frame</code></a>
     given <var>element</var>, <var>url</var>, and <var>referrerPolicy</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p id="otherwise-steps-for-iframe-or-frame-elements">The <dfn id="shared-attribute-processing-steps-for-iframe-and-frame-elements">shared attribute processing steps
  for <code>iframe</code> and <code>frame</code> elements</dfn>, given an element
  <var>element</var> and a boolean <var>initialInsertion</var>, are:</p>

  <ol><li><p>Let <var>url</var> be the <a id="the-iframe-element:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> <code id="the-iframe-element:about:blank"><a href="#about:blank">about:blank</a></code>.</p></li><li>
    <p>If <var>element</var> has a <code id="the-iframe-element:attr-iframe-src-5"><a href="#attr-iframe-src">src</a></code> attribute specified,
    and its value is not the empty string, then:</p>

    <ol><li><p>Let <var>maybeURL</var> be the result of <a href="#encoding-parsing-a-url" id="the-iframe-element:encoding-parsing-a-url">encoding-parsing a URL</a> given that
     attribute's value, relative to <var>element</var>'s <a id="the-iframe-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>maybeURL</var> is not failure, then set <var>url</var> to
     <var>maybeURL</var>.</p></li></ol>
   </li><li><p>If the <a href="#inclusive-ancestor-navigables" id="the-iframe-element:inclusive-ancestor-navigables">inclusive ancestor navigables</a> of <var>element</var>'s <a href="#node-navigable" id="the-iframe-element:node-navigable">node
   navigable</a> contains a <a href="#navigable" id="the-iframe-element:navigable">navigable</a> whose <a href="#nav-document" id="the-iframe-element:nav-document">active
   document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-iframe-element:the-document's-address-2" data-x-internal="the-document's-address">URL</a> <a href="https://url.spec.whatwg.org/#concept-url-equals" id="the-iframe-element:concept-url-equals" data-x-internal="concept-url-equals">equals</a> <var>url</var> with <i id="the-iframe-element:url-equals-exclude-fragments"><a data-x-internal="url-equals-exclude-fragments" href="https://url.spec.whatwg.org/#url-equals-exclude-fragments">exclude fragments</a></i> set to true, then return null.</p></li><li>
    <p>If <var>url</var> <a href="#matches-about:blank" id="the-iframe-element:matches-about:blank-2">matches <code>about:blank</code></a> and
    <var>initialInsertion</var> is true, then perform the <a href="#url-and-history-update-steps" id="the-iframe-element:url-and-history-update-steps">URL and history update steps</a>
    given <var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-7">content navigable</a>'s <a href="#nav-document" id="the-iframe-element:nav-document-2">active
    document</a> and <var>url</var>.</p>

    <p class="note">This is necessary in case <var>url</var> is something like <code>about:blank?foo</code>. If <var>url</var> is just plain <code>about:blank</code>, this will do nothing.</p>
   </li><li><p>Return <var>url</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="navigate-an-iframe-or-frame">navigate an <code>iframe</code> or <code>frame</code></dfn> given an element
  <var>element</var>, a <a id="the-iframe-element:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, a <a id="the-iframe-element:referrer-policy-2" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>
  <var>referrerPolicy</var>, an optional string-or-null <var>srcdocString</var> (default
  null), and an optional boolean <var>initialInsertion</var> (default false):</p>

  <ol><li><p>Let <var>historyHandling</var> be "<code id="the-iframe-element:navigationhistorybehavior-auto"><a href="#navigationhistorybehavior-auto">auto</a></code>".</p>

   </li><li><p>If <var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-8">content navigable</a>'s <a href="#nav-document" id="the-iframe-element:nav-document-3">active document</a> is not <a href="#completely-loaded" id="the-iframe-element:completely-loaded">completely loaded</a>, then set
   <var>historyHandling</var> to "<code id="the-iframe-element:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p></li><li><p>If <var>element</var> is an <code id="the-iframe-element:the-iframe-element-11"><a href="#the-iframe-element">iframe</a></code>, then set <var>element</var>'s <a href="#iframe-pending-resource-timing-start-time" id="the-iframe-element:iframe-pending-resource-timing-start-time">pending resource-timing start time</a> to
   the <a id="the-iframe-element:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given <var>element</var>'s
   <a id="the-iframe-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#concept-relevant-global" id="the-iframe-element:concept-relevant-global">relevant global object</a>.</p></li><li><p><a href="#navigate" id="the-iframe-element:navigate">Navigate</a> <var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-9">content
   navigable</a> to <var>url</var> using <var>element</var>'s <a id="the-iframe-element:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, with
   <i id="the-iframe-element:navigation-hh"><a href="#navigation-hh">historyHandling</a></i> set to <var>historyHandling</var>, <i id="the-iframe-element:navigation-referrer-policy"><a href="#navigation-referrer-policy">referrerPolicy</a></i> set to <var>referrerPolicy</var>, <i id="the-iframe-element:navigation-resource"><a href="#navigation-resource">documentResource</a></i> set to <var>srcdocString</var>, and <i id="the-iframe-element:navigation-initial-insertion"><a href="#navigation-initial-insertion">initialInsertion</a></i> set to <var>initialInsertion</var>.</p></li></ol>
  </div>

  <p>Each <code id="the-iframe-element:document-5"><a href="#document">Document</a></code> has an <dfn id="iframe-load-in-progress">iframe load in progress</dfn> flag and a <dfn id="mute-iframe-load">mute
  iframe load</dfn> flag. When a <code id="the-iframe-element:document-6"><a href="#document">Document</a></code> is created, these flags must be unset for
  that <code id="the-iframe-element:document-7"><a href="#document">Document</a></code>.</p>

  <div data-algorithm="">
  <p>To run the <dfn id="iframe-load-event-steps">iframe load event steps</dfn>, given an <code id="the-iframe-element:the-iframe-element-12"><a href="#the-iframe-element">iframe</a></code> element
  <var>element</var>:</p>

  <ol><li><p><a id="the-iframe-element:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-10">content navigable</a> is not
   null.</p></li><li><p>Let <var>childDocument</var> be <var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-11">content navigable</a>'s
   <a href="#nav-document" id="the-iframe-element:nav-document-4">active document</a>.</p></li><li><p>If <var>childDocument</var> has its <a href="#mute-iframe-load" id="the-iframe-element:mute-iframe-load">mute iframe load</a> flag set, then
   return.</p></li><li>
    <p>If <var>element</var>'s <a href="#iframe-pending-resource-timing-start-time" id="the-iframe-element:iframe-pending-resource-timing-start-time-2">pending resource-timing start time</a> is
    not null, then:</p>

    <ol><li><p>Let <var>global</var> be <var>element</var>'s <a id="the-iframe-element:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
      <a href="#concept-relevant-global" id="the-iframe-element:concept-relevant-global-2">relevant global object</a>.</p></li><li><p>Let <var>fallbackTimingInfo</var> be a new <a href="https://fetch.spec.whatwg.org/#fetch-timing-info" id="the-iframe-element:fetch-timing-info" data-x-internal="fetch-timing-info">fetch timing info</a> whose <a href="https://fetch.spec.whatwg.org/#fetch-timing-info-start-time" id="the-iframe-element:fetch-timing-info-start-time" data-x-internal="fetch-timing-info-start-time">start time</a> is <var>element</var>'s <a href="#iframe-pending-resource-timing-start-time" id="the-iframe-element:iframe-pending-resource-timing-start-time-3">pending resource-timing start time</a>
      and whose <a href="https://fetch.spec.whatwg.org/#fetch-timing-info-end-time" id="the-iframe-element:fetch-timing-info-end-time" data-x-internal="fetch-timing-info-end-time">response end time</a> is the
      <a id="the-iframe-element:current-high-resolution-time-2" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given <var>global</var>.</p></li><li><p><a id="the-iframe-element:mark-resource-timing" href="https://w3c.github.io/resource-timing/#dfn-mark-resource-timing" data-x-internal="mark-resource-timing">Mark resource timing</a> given <var>fallbackTimingInfo</var>, <var>url</var>,
      "<code id="the-iframe-element:the-iframe-element-13"><a href="#the-iframe-element">iframe</a></code>", <var>global</var>, the empty string, a new
      <a href="https://fetch.spec.whatwg.org/#response-body-info" id="the-iframe-element:response-body-info" data-x-internal="response-body-info">response body info</a>, and 0.</p></li><li><p>Set <var>element</var>'s <a href="#iframe-pending-resource-timing-start-time" id="the-iframe-element:iframe-pending-resource-timing-start-time-4">pending resource-timing start time</a>
      to null.</p></li></ol>
   </li><li><p>Set <var>childDocument</var>'s <a href="#iframe-load-in-progress" id="the-iframe-element:iframe-load-in-progress">iframe load in progress</a> flag.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-iframe-element:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-iframe-element:event-load"><a href="#event-load">load</a></code> at <var>element</var>.</p></li><li><p>Unset <var>childDocument</var>'s <a href="#iframe-load-in-progress" id="the-iframe-element:iframe-load-in-progress-2">iframe load in progress</a> flag.</p></li></ol>
  </div>

  <p class="warning">This, in conjunction with scripting, can be used to probe the URL space of the
  local network's HTTP servers. User agents may implement <a href="#concept-origin" id="the-iframe-element:concept-origin">cross-origin</a>
  access control policies that are stricter than those described above to mitigate this attack, but
  unfortunately such policies are typically not compatible with existing web content.</p>

  <div data-algorithm="">
  <p>If an element type <dfn id="potentially-delays-the-load-event">potentially delays the load event</dfn>, then for each element
  <var>element</var> of that type, the user agent must <a href="#delay-the-load-event" id="the-iframe-element:delay-the-load-event">delay the load event</a> of
  <var>element</var>'s <a id="the-iframe-element:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> if <var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-12">content
  navigable</a> is non-null and any of the following are true:</p>

  <ul><li><p><var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-13">content navigable</a>'s <a href="#nav-document" id="the-iframe-element:nav-document-5">active
   document</a> is not <a href="#ready-for-post-load-tasks" id="the-iframe-element:ready-for-post-load-tasks">ready for post-load tasks</a>;</p></li><li><p><var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-14">content navigable</a>'s <a href="#delaying-load-events-mode" id="the-iframe-element:delaying-load-events-mode">is delaying <code>load</code> events</a> is true; or</p></li><li><p>anything is <a href="#delay-the-load-event" id="the-iframe-element:delay-the-load-event-2">delaying the load event</a> of
   <var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-15">content navigable</a>'s <a href="#nav-document" id="the-iframe-element:nav-document-6">active
   document</a>.</p></li></ul>

  <p class="note">If, during the handling of the <code id="the-iframe-element:event-load-2"><a href="#event-load">load</a></code> event,
  <var>element</var>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-16">content navigable</a> is again <a href="#navigate" id="the-iframe-element:navigate-2">navigated</a>, that will further <a href="#delay-the-load-event" id="the-iframe-element:delay-the-load-event-3">delay the load event</a>.</p>
  </div>

  <p>Each <code id="the-iframe-element:the-iframe-element-14"><a href="#the-iframe-element">iframe</a></code> element has an associated <dfn id="current-navigation-was-lazy-loaded">current navigation was lazy
  loaded</dfn> boolean, initially false. It is set and unset in the <a href="#process-the-iframe-attributes" id="the-iframe-element:process-the-iframe-attributes-4">process the
  <code>iframe</code> attributes</a> algorithm.</p>

  <p>An <code id="the-iframe-element:the-iframe-element-15"><a href="#the-iframe-element">iframe</a></code> element whose <a href="#current-navigation-was-lazy-loaded" id="the-iframe-element:current-navigation-was-lazy-loaded-5">current navigation was lazy loaded</a> boolean is
  false <a href="#potentially-delays-the-load-event" id="the-iframe-element:potentially-delays-the-load-event">potentially delays the load event</a>.</p>

  <p>Each <code id="the-iframe-element:the-iframe-element-16"><a href="#the-iframe-element">iframe</a></code> element has an associated null or
  <a id="the-iframe-element:domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp" data-x-internal="domhighrestimestamp"><code>DOMHighResTimeStamp</code></a> <dfn id="iframe-pending-resource-timing-start-time">pending resource-timing start time</dfn>,
  initially set to null.</p>
  

  

  <p class="note">If, when the element is created, the <code id="the-iframe-element:attr-iframe-srcdoc-14"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute is not set, and the <code id="the-iframe-element:attr-iframe-src-6"><a href="#attr-iframe-src">src</a></code> attribute is either also not set or set but its value cannot
  be <a href="#encoding-parsing-a-url" id="the-iframe-element:encoding-parsing-a-url-2">parsed</a>, the element's <a href="#content-navigable" id="the-iframe-element:content-navigable-17">content
  navigable</a> will remain at the <a href="#is-initial-about:blank" id="the-iframe-element:is-initial-about:blank">initial
  <code>about:blank</code></a> <code id="the-iframe-element:document-8"><a href="#document">Document</a></code>.</p>

  <p class="note">If the user <a href="#navigate" id="the-iframe-element:navigate-3">navigates</a> away from this page, the
  <code id="the-iframe-element:the-iframe-element-17"><a href="#the-iframe-element">iframe</a></code>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-18">content navigable</a>'s <a href="#nav-wp" id="the-iframe-element:nav-wp">active
  <code>WindowProxy</code></a> object will proxy new <code id="the-iframe-element:window"><a href="#window">Window</a></code> objects for new
  <code id="the-iframe-element:document-9"><a href="#document">Document</a></code> objects, but the <code id="the-iframe-element:attr-iframe-src-7"><a href="#attr-iframe-src">src</a></code> attribute will
  not change.</p>


  <hr> 

  <p>The <dfn data-dfn-for="iframe" id="attr-iframe-name" data-dfn-type="element-attr"><code>name</code></dfn>
  attribute, if present, must be a <a href="#valid-navigable-target-name" id="the-iframe-element:valid-navigable-target-name">valid navigable target name</a>. The given value is
  used to name the element's <a href="#content-navigable" id="the-iframe-element:content-navigable-19">content navigable</a> if present when that is <a href="#create-a-new-child-navigable" id="the-iframe-element:create-a-new-child-navigable-2">created</a>.</p>


  <hr> 

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox" title="The <iframe> HTML element represents a nested browsing context, embedding another HTML page into the current one.">Element/iframe#attr-sandbox</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>17+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="iframe" id="attr-iframe-sandbox" data-dfn-type="element-attr"><code>sandbox</code></dfn>
  attribute, when specified, enables a set of extra restrictions on any content hosted by the
  <code id="the-iframe-element:the-iframe-element-18"><a href="#the-iframe-element">iframe</a></code>. Its value must be an <a href="#unordered-set-of-unique-space-separated-tokens" id="the-iframe-element:unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated
  tokens</a> that are <a id="the-iframe-element:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>. The allowed values are:</p>

  <ul class="brief"><li><code id="the-iframe-element:attr-iframe-sandbox-allow-downloads"><a href="#attr-iframe-sandbox-allow-downloads">allow-downloads</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-forms"><a href="#attr-iframe-sandbox-allow-forms">allow-forms</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-modals"><a href="#attr-iframe-sandbox-allow-modals">allow-modals</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-orientation-lock"><a href="#attr-iframe-sandbox-allow-orientation-lock">allow-orientation-lock</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-pointer-lock"><a href="#attr-iframe-sandbox-allow-pointer-lock">allow-pointer-lock</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-popups"><a href="#attr-iframe-sandbox-allow-popups">allow-popups</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-popups-to-escape-sandbox"><a href="#attr-iframe-sandbox-allow-popups-to-escape-sandbox">allow-popups-to-escape-sandbox</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-presentation"><a href="#attr-iframe-sandbox-allow-presentation">allow-presentation</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-scripts"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-by-user-activation"><a href="#attr-iframe-sandbox-allow-top-navigation-by-user-activation">allow-top-navigation-by-user-activation</a></code></li><li><code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-to-custom-protocols"><a href="#attr-iframe-sandbox-allow-top-navigation-to-custom-protocols">allow-top-navigation-to-custom-protocols</a></code></li></ul>

  <p>When the attribute is set, the content is treated as being from a unique <a href="#concept-origin-opaque" id="the-iframe-element:concept-origin-opaque">opaque origin</a>, forms, scripts, and various potentially
  annoying APIs are disabled, and links are prevented from targeting other <a href="#navigable" id="the-iframe-element:navigable-2">navigables</a>. The <code id="the-iframe-element:attr-iframe-sandbox-allow-same-origin-2"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code> keyword causes the
  content to be treated as being from its real origin instead of forcing it into an <a href="#concept-origin-opaque" id="the-iframe-element:concept-origin-opaque-2">opaque origin</a>; the <code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-2"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code> keyword allows the
  content to <a href="#navigate" id="the-iframe-element:navigate-4">navigate</a> its <a href="#nav-traversable" id="the-iframe-element:nav-traversable">traversable navigable</a>;
  the <code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-by-user-activation-2"><a href="#attr-iframe-sandbox-allow-top-navigation-by-user-activation">allow-top-navigation-by-user-activation</a></code>
  keyword behaves similarly but allows such <a href="#navigate" id="the-iframe-element:navigate-5">navigation</a> only when the
  browsing context's <a href="#nav-window" id="the-iframe-element:nav-window">active window</a> has <a href="#transient-activation" id="the-iframe-element:transient-activation">transient
  activation</a>; the <code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-to-custom-protocols-2"><a href="#attr-iframe-sandbox-allow-top-navigation-to-custom-protocols">allow-top-navigation-to-custom-protocols</a></code>
  reenables navigations toward non <a id="the-iframe-element:fetch-scheme" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a> to be <a href="#hand-off-to-external-software" id="the-iframe-element:hand-off-to-external-software">handed off to external software</a>; and the <code id="the-iframe-element:attr-iframe-sandbox-allow-forms-2"><a href="#attr-iframe-sandbox-allow-forms">allow-forms</a></code>, <code id="the-iframe-element:attr-iframe-sandbox-allow-modals-2"><a href="#attr-iframe-sandbox-allow-modals">allow-modals</a></code>, <code id="the-iframe-element:attr-iframe-sandbox-allow-orientation-lock-2"><a href="#attr-iframe-sandbox-allow-orientation-lock">allow-orientation-lock</a></code>, <code id="the-iframe-element:attr-iframe-sandbox-allow-pointer-lock-2"><a href="#attr-iframe-sandbox-allow-pointer-lock">allow-pointer-lock</a></code>, <code id="the-iframe-element:attr-iframe-sandbox-allow-popups-2"><a href="#attr-iframe-sandbox-allow-popups">allow-popups</a></code>, <code id="the-iframe-element:attr-iframe-sandbox-allow-presentation-2"><a href="#attr-iframe-sandbox-allow-presentation">allow-presentation</a></code>, <code id="the-iframe-element:attr-iframe-sandbox-allow-scripts-2"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code>, and <code id="the-iframe-element:attr-iframe-sandbox-allow-popups-to-escape-sandbox-2"><a href="#attr-iframe-sandbox-allow-popups-to-escape-sandbox">allow-popups-to-escape-sandbox</a></code>
  keywords re-enable forms, modal dialogs, screen orientation lock, the pointer lock API, popups,
  the presentation API, scripts, and the creation of unsandboxed <a href="#auxiliary-browsing-context" id="the-iframe-element:auxiliary-browsing-context">auxiliary browsing contexts</a> respectively. The <code id="the-iframe-element:attr-iframe-sandbox-allow-downloads-2"><a href="#attr-iframe-sandbox-allow-downloads">allow-downloads</a></code> keyword allows content to
  perform downloads. <a href="#refsPOINTERLOCK">[POINTERLOCK]</a> <a href="#refsSCREENORIENTATION">[SCREENORIENTATION]</a> <a href="#refsPRESENTATION">[PRESENTATION]</a></p>

  <p>The <code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-3"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code> and <code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-by-user-activation-3"><a href="#attr-iframe-sandbox-allow-top-navigation-by-user-activation">allow-top-navigation-by-user-activation</a></code>
  keywords must not both be specified, as doing so is redundant; only <code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-4"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code> will have an effect
  in such non-conformant markup.</p>

  <p>Similarly, the <code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-to-custom-protocols-3"><a href="#attr-iframe-sandbox-allow-top-navigation-to-custom-protocols">allow-top-navigation-to-custom-protocols</a></code>
  keyword must not be specified if either <code id="the-iframe-element:attr-iframe-sandbox-allow-top-navigation-5"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code> or <code id="the-iframe-element:attr-iframe-sandbox-allow-popups-3"><a href="#attr-iframe-sandbox-allow-popups">allow-popups</a></code> are specified, as doing so is
  redundant.</p>

  <p class="note">To allow <code id="the-iframe-element:dom-alert"><a href="#dom-alert">alert()</a></code>, <code id="the-iframe-element:dom-confirm"><a href="#dom-confirm">confirm()</a></code>, and <code id="the-iframe-element:dom-prompt"><a href="#dom-prompt">prompt()</a></code> inside
  sandboxed content, both the <code id="the-iframe-element:attr-iframe-sandbox-allow-modals-3"><a href="#attr-iframe-sandbox-allow-modals">allow-modals</a></code>
  and <code id="the-iframe-element:attr-iframe-sandbox-allow-same-origin-3"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code> keywords need to
  be specified, and the loaded URL needs to be <a href="#same-origin" id="the-iframe-element:same-origin">same origin</a> with the <a href="#concept-environment-top-level-origin" id="the-iframe-element:concept-environment-top-level-origin">top-level
  origin</a>. Without the <code id="the-iframe-element:attr-iframe-sandbox-allow-same-origin-4"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code> keyword, the content is
  always treated as cross-origin, and cross-origin content <a href="#cannot-show-simple-dialogs" id="the-iframe-element:cannot-show-simple-dialogs">cannot show simple
  dialogs</a>.</p>

  <p class="warning">Setting both the <code id="the-iframe-element:attr-iframe-sandbox-allow-scripts-3"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code> and <code id="the-iframe-element:attr-iframe-sandbox-allow-same-origin-5"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code> keywords together when the
  embedded page has the <a href="#same-origin" id="the-iframe-element:same-origin-2">same origin</a> as the page containing the <code id="the-iframe-element:the-iframe-element-19"><a href="#the-iframe-element">iframe</a></code>
  allows the embedded page to simply remove the <code id="the-iframe-element:attr-iframe-sandbox-5"><a href="#attr-iframe-sandbox">sandbox</a></code>
  attribute and then reload itself, effectively breaking out of the sandbox altogether.</p>

  <p class="warning">These flags only take effect when the <a href="#content-navigable" id="the-iframe-element:content-navigable-20">content navigable</a> of the
  <code id="the-iframe-element:the-iframe-element-20"><a href="#the-iframe-element">iframe</a></code> element is <a href="#navigate" id="the-iframe-element:navigate-6">navigated</a>. Removing them, or
  removing the entire <code id="the-iframe-element:attr-iframe-sandbox-6"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute, has no effect on
  an already-loaded page.</p>

  <p class="warning">Potentially hostile files should not be served from the same server as the file
  containing the <code id="the-iframe-element:the-iframe-element-21"><a href="#the-iframe-element">iframe</a></code> element. Sandboxing hostile content is of minimal help if an
  attacker can convince the user to just visit the hostile content directly, rather than in the
  <code id="the-iframe-element:the-iframe-element-22"><a href="#the-iframe-element">iframe</a></code>. To limit the damage that can be caused by hostile HTML content, it should be
  served from a separate dedicated domain. Using a different domain ensures that scripts in the
  files are unable to attack the site, even if the user is tricked into visiting those pages
  directly, without the protection of the <code id="the-iframe-element:attr-iframe-sandbox-7"><a href="#attr-iframe-sandbox">sandbox</a></code>
  attribute.</p>

  

  

  <div data-algorithm="">
  <p>When an <code id="the-iframe-element:the-iframe-element-23"><a href="#the-iframe-element">iframe</a></code> element's <code id="the-iframe-element:attr-iframe-sandbox-8"><a href="#attr-iframe-sandbox">sandbox</a></code>
  attribute is set or changed while it has a non-null <a href="#content-navigable" id="the-iframe-element:content-navigable-21">content navigable</a>, the user
  agent must <a href="#parse-a-sandboxing-directive" id="the-iframe-element:parse-a-sandboxing-directive-2">parse the sandboxing directive</a>
  given the attribute's value and the <code id="the-iframe-element:the-iframe-element-24"><a href="#the-iframe-element">iframe</a></code> element's <a href="#iframe-sandboxing-flag-set" id="the-iframe-element:iframe-sandboxing-flag-set-2"><code>iframe</code>
  sandboxing flag set</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When an <code id="the-iframe-element:the-iframe-element-25"><a href="#the-iframe-element">iframe</a></code> element's <code id="the-iframe-element:attr-iframe-sandbox-9"><a href="#attr-iframe-sandbox">sandbox</a></code>
  attribute is removed while it has a non-null <a href="#content-navigable" id="the-iframe-element:content-navigable-22">content navigable</a>, the user agent must
  empty the <code id="the-iframe-element:the-iframe-element-26"><a href="#the-iframe-element">iframe</a></code> element's <a href="#iframe-sandboxing-flag-set" id="the-iframe-element:iframe-sandboxing-flag-set-3"><code>iframe</code> sandboxing flag set</a>.</p>
  </div>

  

  <div class="example">

   <p>In this example, some completely-unknown, potentially hostile, user-provided HTML content is
   embedded in a page. Because it is served from a separate domain, it is affected by all the normal
   cross-site restrictions. In addition, the embedded page has scripting disabled, plugins disabled,
   forms disabled, and it cannot navigate any frames or windows other than itself (or any frames or
   windows it itself embeds).</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->We're not scared of you! Here is your content, unedited:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">sandbox</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"https://usercontent.example.net/getusercontent.cgi?id=12193"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></code></pre>

   <p class="warning">It is important to use a separate domain so that if the attacker convinces the
   user to visit that page directly, the page doesn't run in the context of the site's origin, which
   would make the user vulnerable to any attack found in the page.</p>

  </div>

  <div class="example">

   <p>In this example, a gadget from another site is embedded. The gadget has scripting and forms
   enabled, and the origin sandbox restrictions are lifted, allowing the gadget to communicate with
   its originating server. The sandbox is still useful, however, as it disables plugins and popups,
   thus reducing the risk of the user being exposed to malware and other annoyances.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">sandbox</c-><c- o="">=</c-><c- s="">"allow-same-origin allow-forms allow-scripts"</c->
        <c- e="">src</c-><c- o="">=</c-><c- s="">"https://maps.example.com/embedded.html"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Suppose a file A contained the following fragment:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">sandbox</c-><c- o="">=</c-><c- s="">"allow-same-origin allow-forms"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">B</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></code></pre>

   <p>Suppose that file B contained an iframe also:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">sandbox</c-><c- o="">=</c-><c- s="">"allow-scripts"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">C</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></code></pre>

   <p>Further, suppose that file C contained a link:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">D</c-><c- p="">&gt;</c->Link<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>

   <p>For this example, suppose all the files were served as <code id="the-iframe-element:text/html"><a href="#text/html">text/html</a></code>.</p>

   <p>Page C in this scenario has all the sandboxing flags set. Scripts are disabled, because the
   <code id="the-iframe-element:the-iframe-element-27"><a href="#the-iframe-element">iframe</a></code> in A has scripts disabled, and this overrides the <code id="the-iframe-element:attr-iframe-sandbox-allow-scripts-4"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code> keyword set on the
   <code id="the-iframe-element:the-iframe-element-28"><a href="#the-iframe-element">iframe</a></code> in B. Forms are also disabled, because the inner <code id="the-iframe-element:the-iframe-element-29"><a href="#the-iframe-element">iframe</a></code> (in B)
   does not have the <code id="the-iframe-element:attr-iframe-sandbox-allow-forms-3"><a href="#attr-iframe-sandbox-allow-forms">allow-forms</a></code> keyword
   set.</p>

   <p>Suppose now that a script in A removes all the <code id="the-iframe-element:attr-iframe-sandbox-10"><a href="#attr-iframe-sandbox">sandbox</a></code> attributes in A  and B.
   This would change nothing immediately. If the user clicked the link in C, loading page D into
   the <code id="the-iframe-element:the-iframe-element-30"><a href="#the-iframe-element">iframe</a></code> in B, page D would now act as if the <code id="the-iframe-element:the-iframe-element-31"><a href="#the-iframe-element">iframe</a></code> in B had the
   <code id="the-iframe-element:attr-iframe-sandbox-allow-same-origin-6"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code> and <code id="the-iframe-element:attr-iframe-sandbox-allow-forms-4"><a href="#attr-iframe-sandbox-allow-forms">allow-forms</a></code> keywords set, because that was the
   state of the <a href="#content-navigable" id="the-iframe-element:content-navigable-23">content navigable</a> in the <code id="the-iframe-element:the-iframe-element-32"><a href="#the-iframe-element">iframe</a></code> in A when page B was
   loaded.</p>

   <p>Generally speaking, dynamically removing or changing the <code id="the-iframe-element:attr-iframe-sandbox-11"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute is ill-advised, because it can make it quite
   hard to reason about what will be allowed and what will not.</p>

  </div>


  <hr> 

  <p>The <dfn data-dfn-for="iframe" id="attr-iframe-allow" data-dfn-type="element-attr"><code>allow</code></dfn>
  attribute, when specified, determines the <a href="https://w3c.github.io/webappsec-feature-policy/#container-policy" id="the-iframe-element:concept-container-policy" data-x-internal="concept-container-policy">container
  policy</a> that will be used when the <a href="#concept-document-permissions-policy" id="the-iframe-element:concept-document-permissions-policy">permissions policy</a> for a
  <code id="the-iframe-element:document-10"><a href="#document">Document</a></code> in the <code id="the-iframe-element:the-iframe-element-33"><a href="#the-iframe-element">iframe</a></code>'s <a href="#content-navigable" id="the-iframe-element:content-navigable-24">content navigable</a> is initialized.
  Its value must be a <a href="https://w3c.github.io/webappsec-feature-policy/#serialized-permissions-policy" id="the-iframe-element:concept-serialized-permissions-policy" data-x-internal="concept-serialized-permissions-policy">serialized permissions
  policy</a>. <a href="#refsPERMISSIONSPOLICY">[PERMISSIONSPOLICY]</a></p>

  <div class="example">
   <p>In this example, an <code id="the-iframe-element:the-iframe-element-34"><a href="#the-iframe-element">iframe</a></code> is used to embed a map from an online navigation
   service. The <code id="the-iframe-element:attr-iframe-allow-2"><a href="#attr-iframe-allow">allow</a></code> attribute is used to enable the
   Geolocation API within the nested context.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"https://maps.example.com/"</c-> <c- e="">allow</c-><c- o="">=</c-><c- s="">"geolocation"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>The <dfn data-dfn-for="iframe" id="attr-iframe-allowfullscreen" data-dfn-type="element-attr"><code>allowfullscreen</code></dfn> attribute is a <a href="#boolean-attribute" id="the-iframe-element:boolean-attribute">boolean
  attribute</a>. When specified, it indicates that <code id="the-iframe-element:document-11"><a href="#document">Document</a></code> objects in the
  <code id="the-iframe-element:the-iframe-element-35"><a href="#the-iframe-element">iframe</a></code> element's <a href="#content-navigable" id="the-iframe-element:content-navigable-25">content navigable</a> will be initialized with a <a href="#concept-document-permissions-policy" id="the-iframe-element:concept-document-permissions-policy-2">permissions policy</a> which allows the "<code>fullscreen</code>" feature to be used from any <a href="#concept-origin" id="the-iframe-element:concept-origin-2">origin</a>. This is enforced by
  the <a href="https://w3c.github.io/webappsec-feature-policy/#process-permissions-policy-attributes" id="the-iframe-element:process-permissions-policy-attributes" data-x-internal="process-permissions-policy-attributes">process permissions policy
  attributes</a> algorithm. <a href="#refsPERMISSIONSPOLICY">[PERMISSIONSPOLICY]</a></p>

  <div class="example">

   <p>Here, an <code id="the-iframe-element:the-iframe-element-36"><a href="#the-iframe-element">iframe</a></code> is used to embed a player from a video site. The <code id="the-iframe-element:attr-iframe-allowfullscreen-2"><a href="#attr-iframe-allowfullscreen">allowfullscreen</a></code> attribute is needed to enable the
   player to show its video fullscreen.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"/usericons/1627591962735"</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->Fred Flintstone<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/posts/3095182851"</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">bookmark</c-><c- p="">&gt;</c->12:44<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> — <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#acl-3095182851"</c-><c- p="">&gt;</c->Private Post<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Check out my new ride!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"https://video.example.com/embed?id=92469812"</c-> <c- e="">allowfullscreen</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p class="note">Neither <code id="the-iframe-element:attr-iframe-allow-3"><a href="#attr-iframe-allow">allow</a></code> nor <code id="the-iframe-element:attr-iframe-allowfullscreen-3"><a href="#attr-iframe-allowfullscreen">allowfullscreen</a></code> can grant access to a feature in an
  <code id="the-iframe-element:the-iframe-element-37"><a href="#the-iframe-element">iframe</a></code> element's <a href="#content-navigable" id="the-iframe-element:content-navigable-26">content navigable</a> if the element's <a id="the-iframe-element:node-document-6" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
  document</a> is not already allowed to use that feature.</p>

  
   <div data-algorithm="">
   <p id="fullscreen-logic">To determine whether a <code id="the-iframe-element:document-12"><a href="#document">Document</a></code> object <var>document</var>
   is <dfn id="allowed-to-use" data-export="">allowed to use</dfn> the policy-controlled-feature <var>feature</var>, run these
   steps:</p>

   <ol><li><p>If <var>document</var>'s <a href="#concept-document-bc" id="the-iframe-element:concept-document-bc">browsing context</a> is
    null, then return false.</p></li><li><p>If <var>document</var> is not <a href="#fully-active" id="the-iframe-element:fully-active">fully active</a>, then return false.</p></li><li><p>If the result of running <a href="https://w3c.github.io/webappsec-feature-policy/#is-feature-enabled" id="the-iframe-element:is-feature-enabled" data-x-internal="is-feature-enabled">is feature enabled in document
    for origin</a> on <var>feature</var>, <var>document</var>, and <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-iframe-element:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is "<code>Enabled</code>", then return
    true.</p></li><li><p>Return false.</p></li></ol>
   </div>
  

  <p class="warning">Because they only influence the <a href="#concept-document-permissions-policy" id="the-iframe-element:concept-document-permissions-policy-3">permissions policy</a> of the <a href="#content-navigable" id="the-iframe-element:content-navigable-27">content
  navigable</a>'s <a href="#nav-document" id="the-iframe-element:nav-document-7">active document</a>, the <code id="the-iframe-element:attr-iframe-allow-4"><a href="#attr-iframe-allow">allow</a></code> and <code id="the-iframe-element:attr-iframe-allowfullscreen-4"><a href="#attr-iframe-allowfullscreen">allowfullscreen</a></code> attributes only take effect when the
  <a href="#content-navigable" id="the-iframe-element:content-navigable-28">content navigable</a> of the <code id="the-iframe-element:the-iframe-element-38"><a href="#the-iframe-element">iframe</a></code> is <a href="#navigate" id="the-iframe-element:navigate-7">navigated</a>. Adding or removing them has no effect on an already-loaded
  document.</p>


  <hr> 

  <p>The <code id="the-iframe-element:the-iframe-element-39"><a href="#the-iframe-element">iframe</a></code> element supports <a href="#dimension-attributes" id="the-iframe-element:dimension-attributes">dimension attributes</a> for cases where the
  embedded content has specific dimensions (e.g. ad units have well-defined dimensions).</p>

  <p>An <code id="the-iframe-element:the-iframe-element-40"><a href="#the-iframe-element">iframe</a></code> element never has <a href="#fallback-content" id="the-iframe-element:fallback-content">fallback content</a>, as it will always
  <a href="#create-a-new-child-navigable" id="the-iframe-element:create-a-new-child-navigable-3">create a new child navigable</a>, regardless of whether the specified initial
  contents are successfully used.</p>

  <hr> 

  <p>The <dfn data-dfn-for="iframe" id="attr-iframe-referrerpolicy" data-dfn-type="element-attr"><code>referrerpolicy</code></dfn> attribute is a
  <a href="#referrer-policy-attribute" id="the-iframe-element:referrer-policy-attribute">referrer policy attribute</a>. Its purpose is to set the <a id="the-iframe-element:referrer-policy-3" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>
  used when <a href="#process-the-iframe-attributes" id="the-iframe-element:process-the-iframe-attributes-5">processing the <code>iframe</code>
  attributes</a>. <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p>

  <p>The <dfn data-dfn-for="iframe" id="attr-iframe-loading" data-dfn-type="element-attr"><code>loading</code></dfn> attribute is a <a href="#lazy-loading-attribute" id="the-iframe-element:lazy-loading-attribute">lazy
  loading attribute</a>. Its purpose is to indicate the policy for loading <code id="the-iframe-element:the-iframe-element-41"><a href="#the-iframe-element">iframe</a></code>
  elements that are outside the viewport.</p>

  <div data-algorithm="">
  <p>When the <code id="the-iframe-element:attr-iframe-loading-2"><a href="#attr-iframe-loading">loading</a></code> attribute's state is changed to the
  <a href="#attr-loading-eager-state" id="the-iframe-element:attr-loading-eager-state">Eager</a> state, the user agent must run these
  steps:</p>

  <ol><li><p>Let <var>resumptionSteps</var> be the <code id="the-iframe-element:the-iframe-element-42"><a href="#the-iframe-element">iframe</a></code> element's <a href="#lazy-load-resumption-steps" id="the-iframe-element:lazy-load-resumption-steps-3">lazy load
   resumption steps</a>.</p></li><li><p>If <var>resumptionSteps</var> is null, then return.</p></li><li><p>Set the <code id="the-iframe-element:the-iframe-element-43"><a href="#the-iframe-element">iframe</a></code>'s <a href="#lazy-load-resumption-steps" id="the-iframe-element:lazy-load-resumption-steps-4">lazy load resumption steps</a> to null.</p></li><li><p>Invoke <var>resumptionSteps</var>.</p></li></ol>
  </div>

  <hr> 

  <p>Descendants of <code id="the-iframe-element:the-iframe-element-44"><a href="#the-iframe-element">iframe</a></code> elements represent nothing. (In legacy user agents that do
  not support <code id="the-iframe-element:the-iframe-element-45"><a href="#the-iframe-element">iframe</a></code> elements, the contents would be parsed as markup that could act as
  fallback content.)</p>

  <p class="note">The <a href="#html-parser" id="the-iframe-element:html-parser">HTML parser</a> treats markup inside <code id="the-iframe-element:the-iframe-element-46"><a href="#the-iframe-element">iframe</a></code> elements as
  text.</p>


  

  <hr> 

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/srcdoc" title="The srcdoc property of the HTMLIFrameElement specifies the content of the page.">HTMLIFrameElement/srcdoc</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>25+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-srcdoc" data-dfn-type="attribute"><code>srcdoc</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>attribute</var> be the result of running <a href="https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace" id="the-iframe-element:concept-element-attributes-get-by-namespace" data-x-internal="concept-element-attributes-get-by-namespace">get an attribute by namespace and local
   name</a> given null, <code id="the-iframe-element:attr-iframe-srcdoc-15"><a href="#attr-iframe-srcdoc">srcdoc</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-local-name" id="the-iframe-element:concept-attribute-local-name" data-x-internal="concept-attribute-local-name">local name</a>, and <a id="the-iframe-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>If <var>attribute</var> is null, then return the empty string.</p></li><li><p>Return <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="the-iframe-element:concept-attribute-value" data-x-internal="concept-attribute-value">value</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-iframe-element:dom-iframe-srcdoc-2"><a href="#dom-iframe-srcdoc">srcdoc</a></code> setter steps
  are:</p>

  <ol><li><p>Let <var>compliantString</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="the-iframe-element:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="the-iframe-element:tt-trustedhtml-2"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="the-iframe-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-iframe-element:concept-relevant-global-3">relevant global
   object</a>, the given value, "<code>HTMLIFrameElement srcdoc</code>", and "<code>script</code>".</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="the-iframe-element:concept-element-attributes-set-value" data-x-internal="concept-element-attributes-set-value">Set an attribute value</a> given
   <a id="the-iframe-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <code id="the-iframe-element:attr-iframe-srcdoc-16"><a href="#attr-iframe-srcdoc">srcdoc</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-local-name" id="the-iframe-element:concept-attribute-local-name-2" data-x-internal="concept-attribute-local-name">local name</a>, and
   <var>compliantString</var>.</p></li></ol>
  </div>

  <p>The <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="the-iframe-element:concept-supported-tokens" data-x-internal="concept-supported-tokens">supported tokens</a> for <code id="the-iframe-element:dom-iframe-sandbox"><a href="#dom-iframe-sandbox">sandbox</a></code>'s <code id="the-iframe-element:domtokenlist-2"><a data-x-internal="domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist">DOMTokenList</a></code> are the allowed
  values defined in the <code id="the-iframe-element:attr-iframe-sandbox-12"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute and supported by
  the user agent.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy" title="The HTMLIFrameElement.referrerPolicy property reflects the HTML referrerpolicy attribute of the <iframe> element defining which referrer is sent when fetching the resource.">HTMLIFrameElement/referrerPolicy</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>14+</span></span><span class="chrome yes"><span>Chrome</span><span>52+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-referrerpolicy" data-dfn-type="attribute"><code>referrerPolicy</code></dfn> IDL attribute must
  <a href="#reflect" id="the-iframe-element:reflect">reflect</a> the <code id="the-iframe-element:attr-iframe-referrerpolicy-3"><a href="#attr-iframe-referrerpolicy">referrerpolicy</a></code> content
  attribute, <a href="#limited-to-only-known-values" id="the-iframe-element:limited-to-only-known-values">limited to only known values</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-loading" data-dfn-type="attribute"><code>loading</code></dfn> IDL attribute must <a href="#reflect" id="the-iframe-element:reflect-2">reflect</a> the <code id="the-iframe-element:attr-iframe-loading-3"><a href="#attr-iframe-loading">loading</a></code> content attribute, <a href="#limited-to-only-known-values" id="the-iframe-element:limited-to-only-known-values-2">limited to only known
  values</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/contentDocument" title="If the iframe and the iframe's parent document are Same Origin, returns a Document (that is, the active document in the inline frame's nested browsing context), else returns null.">HTMLIFrameElement/contentDocument</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-contentdocument" data-dfn-type="attribute"><code>contentDocument</code></dfn> getter steps are to return
  <a id="the-iframe-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-bcc-content-document" id="the-iframe-element:concept-bcc-content-document-2">content document</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/contentWindow" title="The contentWindow property returns the Window object of an HTMLIFrameElement. You can use this Window object to access the iframe's document and its internal DOM. This attribute is read-only, but its properties can be manipulated like the global Window object.">HTMLIFrameElement/contentWindow</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-contentwindow" data-dfn-type="attribute"><code>contentWindow</code></dfn> getter steps are to return
  <a id="the-iframe-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#content-window" id="the-iframe-element:content-window">content window</a>.</p>
  </div>

  

  <div class="example">

   <p>Here is an example of a page using an <code id="the-iframe-element:the-iframe-element-47"><a href="#the-iframe-element">iframe</a></code> to include advertising from an
   advertising broker:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"https://ads.example.com/?customerid=923513721&amp;amp;format=banner"</c->
        <c- e="">width</c-><c- o="">=</c-><c- s="">"468"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"60"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></code></pre>

  </div>




  <h4 id="the-embed-element"><span class="secno">4.8.6</span> The <dfn data-dfn-type="element"><code>embed</code></dfn> element<a href="#the-embed-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed" title="The <embed> HTML element embeds external content at the specified point in the document. This content is provided by an external application or other source of interactive content such as a browser plug-in.">Element/embed</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>



  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLEmbedElement" title="The HTMLEmbedElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <embed> elements.">HTMLEmbedElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-embed-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-embed-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-embed-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#embedded-content-category" id="the-embed-element:embedded-content-category">Embedded content</a>.</dd><dd><a href="#interactive-content-2" id="the-embed-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#palpable-content-2" id="the-embed-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-embed-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#embedded-content-category" id="the-embed-element:embedded-content-category-2">embedded content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-embed-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-embed-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-embed-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-embed-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-embed-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-embed-element:global-attributes">Global attributes</a></dd><dd><code id="the-embed-element:attr-embed-src"><a href="#attr-embed-src">src</a></code> —  Address of the resource
     </dd><dd><code id="the-embed-element:attr-embed-type"><a href="#attr-embed-type">type</a></code> —  Type of embedded resource
     </dd><dd><code id="the-embed-element:attr-dim-width"><a href="#attr-dim-width">width</a></code> —  Horizontal dimension
     </dd><dd><code id="the-embed-element:attr-dim-height"><a href="#attr-dim-height">height</a></code> —  Vertical dimension
     </dd><dd>Any other attribute that has no namespace (see prose).</dd><dt><a href="#concept-element-accessibility-considerations" id="the-embed-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-embed">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-embed">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-embed-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlembedelement" data-dfn-type="interface"><c- g="">HTMLEmbedElement</c-></dfn> : <a href="#htmlelement" id="the-embed-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-embed-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-embed-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-embed-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLEmbedElement" id="dom-embed-src" data-dfn-type="attribute"><c- g="">src</c-></dfn>;
  [<a href="#cereactions" id="the-embed-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-embed-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLEmbedElement" id="dom-embed-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;
  [<a href="#cereactions" id="the-embed-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-embed-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLEmbedElement" id="dom-embed-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;
  [<a href="#cereactions" id="the-embed-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-embed-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLEmbedElement" id="dom-embed-height" data-dfn-type="attribute"><c- g="">height</c-></dfn>;
  <a href="#document" id="the-embed-element:document"><c- n="">Document</c-></a>? <a href="#dom-media-getsvgdocument" id="the-embed-element:dom-media-getsvgdocument"><c- g="">getSVGDocument</c-></a>();

  // <a href="#HTMLEmbedElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-embed-element:the-embed-element"><a href="#the-embed-element">embed</a></code> element provides an integration point for an external application or
  interactive content.</p>

  <p>The <dfn data-dfn-for="embed" id="attr-embed-src" data-dfn-type="element-attr"><code>src</code></dfn> attribute
  gives the <a id="the-embed-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the resource being embedded. The attribute, if present, must contain
  a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="the-embed-element:valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by spaces</a>.</p>

  <p>If the <code id="the-embed-element:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is specified on an
  <code id="the-embed-element:the-embed-element-2"><a href="#the-embed-element">embed</a></code> element, then the <code id="the-embed-element:attr-embed-src-2"><a href="#attr-embed-src">src</a></code> attribute must also
  be specified.</p>

  <p>The <dfn data-dfn-for="embed" id="attr-embed-type" data-dfn-type="element-attr"><code>type</code></dfn> attribute,
  if present, gives the <a id="the-embed-element:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> by which the plugin to instantiate is selected. The
  value must be a <a id="the-embed-element:valid-mime-type-string" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">valid MIME type string</a>. If both the <code id="the-embed-element:attr-embed-type-2"><a href="#attr-embed-type">type</a></code> attribute and the <code id="the-embed-element:attr-embed-src-3"><a href="#attr-embed-src">src</a></code>
  attribute are present, then the <code id="the-embed-element:attr-embed-type-3"><a href="#attr-embed-type">type</a></code> attribute must specify
  the same type as the <a href="#content-type" id="the-embed-element:content-type">explicit Content-Type metadata</a> of the
  resource given by the <code id="the-embed-element:attr-embed-src-4"><a href="#attr-embed-src">src</a></code> attribute.</p>

  

  <div data-algorithm="">
  <p>While any of the following conditions are occurring, any <a href="#plugin" id="the-embed-element:plugin">plugin</a> instantiated for
  the element must be removed, and the <code id="the-embed-element:the-embed-element-3"><a href="#the-embed-element">embed</a></code> element <a href="#represents" id="the-embed-element:represents">represents</a>
  nothing:</p>

  <ul><li><p>The element has neither a <code id="the-embed-element:attr-embed-src-5"><a href="#attr-embed-src">src</a></code> attribute nor a <code id="the-embed-element:attr-embed-type-4"><a href="#attr-embed-type">type</a></code> attribute.</p></li><li><p>The element has a <a href="#media-element" id="the-embed-element:media-element">media element</a> ancestor.</p></li><li><p>The element has an ancestor <code id="the-embed-element:the-object-element"><a href="#the-object-element">object</a></code> element that is <em>not</em> showing its
   <a href="#fallback-content" id="the-embed-element:fallback-content">fallback content</a>.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-embed-element:the-embed-element-4"><a href="#the-embed-element">embed</a></code> element is said to be <dfn id="concept-embed-active">potentially
  active</dfn> when the following conditions are all met simultaneously:</p>

  <ul><li><p>The element is <a id="the-embed-element:in-a-document" href="https://dom.spec.whatwg.org/#in-a-document" data-x-internal="in-a-document">in a document</a> or was <a id="the-embed-element:in-a-document-2" href="https://dom.spec.whatwg.org/#in-a-document" data-x-internal="in-a-document">in a document</a> the last time
   the <a href="#event-loop" id="the-embed-element:event-loop">event loop</a> reached <a href="#step1">step 1</a>.</p></li><li><p>The element's <a id="the-embed-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is <a href="#fully-active" id="the-embed-element:fully-active">fully active</a>.</p></li><li><p>The element has either a <code id="the-embed-element:attr-embed-src-6"><a href="#attr-embed-src">src</a></code> attribute set or a
   <code id="the-embed-element:attr-embed-type-5"><a href="#attr-embed-type">type</a></code> attribute set (or both).</p></li><li><p>The element's <code id="the-embed-element:attr-embed-src-7"><a href="#attr-embed-src">src</a></code> attribute is either absent or its
   value is not the empty string.</p></li><li><p>The element is not a descendant of a <a href="#media-element" id="the-embed-element:media-element-2">media element</a>.</p></li><li><p>The element is not a descendant of an <code id="the-embed-element:the-object-element-2"><a href="#the-object-element">object</a></code> element that is not showing its
   <a href="#fallback-content" id="the-embed-element:fallback-content-2">fallback content</a>.</p></li><li><p>The element is <a href="#being-rendered" id="the-embed-element:being-rendered">being rendered</a>, or was <a href="#being-rendered" id="the-embed-element:being-rendered-2">being rendered</a> the last
   time the <a href="#event-loop" id="the-embed-element:event-loop-2">event loop</a> reached <a href="#step1">step 1</a>.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>Whenever an <code id="the-embed-element:the-embed-element-5"><a href="#the-embed-element">embed</a></code> element that was not <a href="#concept-embed-active" id="the-embed-element:concept-embed-active">potentially active</a> becomes <a href="#concept-embed-active" id="the-embed-element:concept-embed-active-2">potentially active</a>, and whenever a <a href="#concept-embed-active" id="the-embed-element:concept-embed-active-3">potentially active</a> <code id="the-embed-element:the-embed-element-6"><a href="#the-embed-element">embed</a></code> element that is
  remaining <a href="#concept-embed-active" id="the-embed-element:concept-embed-active-4">potentially active</a> has its <code id="the-embed-element:attr-embed-type-6"><a href="#attr-embed-type">src</a></code> attribute set, changed, or removed or its <code id="the-embed-element:attr-embed-type-7"><a href="#attr-embed-type">type</a></code> attribute set, changed, or removed, the user agent must
  <a href="#queue-an-element-task" id="the-embed-element:queue-an-element-task">queue an element task</a> on the <dfn id="embed-task-source">embed task source</dfn> given the element
  to run <a href="#the-embed-element-setup-steps" id="the-embed-element:the-embed-element-setup-steps">the <code>embed</code> element setup steps</a> for that element.</p>
  </div>

  <div data-algorithm="">
  <p><dfn id="the-embed-element-setup-steps">The <code>embed</code> element setup steps</dfn> for a given <code id="the-embed-element:the-embed-element-7"><a href="#the-embed-element">embed</a></code> element
  <var>element</var> are as follows:</p>

  <ol><li><p>If another <a href="#concept-task" id="the-embed-element:concept-task">task</a> has since been queued to run <a href="#the-embed-element-setup-steps" id="the-embed-element:the-embed-element-setup-steps-2">the
   <code>embed</code> element setup steps</a> for <var>element</var>, then return.</p></li><li>
    <p>If <var>element</var> has a <code id="the-embed-element:attr-embed-src-8"><a href="#attr-embed-src">src</a></code> attribute set, then:</p>

    <ol><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="the-embed-element:encoding-parsing-a-url">encoding-parsing a URL</a> given
     <var>element</var>'s <code id="the-embed-element:attr-embed-src-9"><a href="#attr-embed-src">src</a></code> attribute's value, relative to
     <var>element</var>'s <a id="the-embed-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>url</var> is failure, then return.</p></li><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="the-embed-element:concept-request" data-x-internal="concept-request">request</a> whose
     <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="the-embed-element:concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>url</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="the-embed-element:concept-request-client" data-x-internal="concept-request-client">client</a> is <var>element</var>'s <a id="the-embed-element:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
     document</a>'s <a href="#relevant-settings-object" id="the-embed-element:relevant-settings-object">relevant settings object</a>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="the-embed-element:concept-request-destination" data-x-internal="concept-request-destination">destination</a> is "<code>embed</code>",
     <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="the-embed-element:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> is "<code>include</code>", <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="the-embed-element:concept-request-mode" data-x-internal="concept-request-mode">mode</a> is "<code>navigate</code>", <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="the-embed-element:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator
     type</a> is "<code>embed</code>", and whose <a id="the-embed-element:use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a>
     is set.</p></li><li>
      <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-embed-element:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var>, with <i id="the-embed-element:processresponse"><a data-x-internal="processresponse" href="https://fetch.spec.whatwg.org/#process-response">processResponse</a></i> set to the following steps given <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-embed-element:concept-response" data-x-internal="concept-response">response</a> <var>response</var>:</p>

      <ol><li><p>If another <a href="#concept-task" id="the-embed-element:concept-task-2">task</a> has since been queued to run
       <a href="#the-embed-element-setup-steps" id="the-embed-element:the-embed-element-setup-steps-3">the <code>embed</code> element setup steps</a> for <var>element</var>, then
       return.</p></li><li><p>If <var>response</var> is a <a id="the-embed-element:network-error" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-embed-element:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-embed-element:event-load"><a href="#event-load">load</a></code> at <var>element</var>, and return.</p></li><li><p>Let <var>type</var> be the result of determining the <a href="#concept-embed-type" id="the-embed-element:concept-embed-type">type of content</a> given <var>element</var> and
       <var>response</var>.</p></li><li>
        <p>Switch on <var>type</var>:</p>

        <dl class="switch"><dt>null</dt><dd>
          <ol><li><p><a href="#display-no-plugin" id="the-embed-element:display-no-plugin">Display no plugin</a> for <var>element</var>.</p></li></ol>
         </dd><dt>Otherwise</dt><dd>
          <ol><li><p>If <var>element</var>'s <a href="#content-navigable" id="the-embed-element:content-navigable">content navigable</a> is null, then
           <a href="#create-a-new-child-navigable" id="the-embed-element:create-a-new-child-navigable">create a new child navigable</a> for <var>element</var>.</p></li><li>
            <p><a href="#navigate" id="the-embed-element:navigate">Navigate</a> <var>element</var>'s <a href="#content-navigable" id="the-embed-element:content-navigable-2">content
            navigable</a> to <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="the-embed-element:concept-response-url" data-x-internal="concept-response-url">URL</a> using <var>element</var>'s <a id="the-embed-element:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
            document</a>, with <i id="the-embed-element:navigation-response"><a href="#navigation-response">response</a></i> set to
            <var>response</var>, and <i id="the-embed-element:navigation-hh"><a href="#navigation-hh">historyHandling</a></i> set to "<code id="the-embed-element:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p>

            <p class="note"><var>element</var>'s <code id="the-embed-element:attr-embed-src-10"><a href="#attr-embed-src">src</a></code> attribute
            does not get updated if the <a href="#content-navigable" id="the-embed-element:content-navigable-3">content navigable</a> gets further navigated to
            other locations.</p>
           </li><li><p><var>element</var> now <a href="#represents" id="the-embed-element:represents-2">represents</a> its <a href="#content-navigable" id="the-embed-element:content-navigable-4">content
           navigable</a>.</p></li></ol>
         </dd></dl>
       </li></ol>

      <p>Fetching the resource must <a href="#delay-the-load-event" id="the-embed-element:delay-the-load-event">delay the load event</a> of <var>element</var>'s
      <a id="the-embed-element:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p>
     </li></ol>
   </li><li><p>Otherwise, <a href="#display-no-plugin" id="the-embed-element:display-no-plugin-2">display no plugin</a> for <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To determine the <dfn id="concept-embed-type">type of the content</dfn> given an
  <code id="the-embed-element:the-embed-element-8"><a href="#the-embed-element">embed</a></code> element <var>element</var> and a <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-embed-element:concept-response-2" data-x-internal="concept-response">response</a> <var>response</var>, run the following steps:</p>

  <ol><li><p>If <var>element</var> has a <code id="the-embed-element:attr-embed-type-8"><a href="#attr-embed-type">type</a></code> attribute, and that
   attribute's value is a type that a <a href="#plugin" id="the-embed-element:plugin-2">plugin</a> supports, then return the value of the
   <code id="the-embed-element:attr-embed-type-9"><a href="#attr-embed-type">type</a></code> attribute.</p></li><li>
    <p>If the <a href="https://url.spec.whatwg.org/#concept-url-path" id="the-embed-element:concept-url-path" data-x-internal="concept-url-path">path</a> component of <var>response</var>'s
    <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="the-embed-element:concept-response-url-2" data-x-internal="concept-response-url">url</a> matches a pattern that a <a href="#plugin" id="the-embed-element:plugin-3">plugin</a>
    supports, then return the type that that plugin can handle.</p>

    <p class="example">For example, a plugin might say that it can handle URLs with <a href="https://url.spec.whatwg.org/#concept-url-path" id="the-embed-element:concept-url-path-2" data-x-internal="concept-url-path">path</a> components that end with the four character string
    "<code>.swf</code>".</p>

    
    
   </li><li><p>If <var>response</var> has <a href="#content-type" id="the-embed-element:content-type-2">explicit Content-Type
   metadata</a>, and that value is a type that a <a href="#plugin" id="the-embed-element:plugin-4">plugin</a> supports, then return that
   value.</p></li><li><p>Return null.</p></li></ol>
  

  <p class="note">It is intentional that the above algorithm allows <var>response</var> to have a
  non-<a id="the-embed-element:ok-status" href="https://fetch.spec.whatwg.org/#ok-status" data-x-internal="ok-status">ok status</a>. This allows servers to return data for plugins even with error
  responses (e.g., HTTP 500 Internal Server Error codes can still contain plugin data).</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="display-no-plugin">display no plugin</dfn> for an <code id="the-embed-element:the-embed-element-9"><a href="#the-embed-element">embed</a></code> element <var>element</var>:</p>

  <ol><li><p><a href="#destroy-a-child-navigable" id="the-embed-element:destroy-a-child-navigable">Destroy a child navigable</a> given <var>element</var>.</p></li><li><p>Display an indication that no <a href="#plugin" id="the-embed-element:plugin-5">plugin</a> could be found for <var>element</var>,
   as the contents of <var>element</var>.</p></li><li><p><var>element</var> now <a href="#represents" id="the-embed-element:represents-3">represents</a> nothing.</p></li></ol>
  </div>

  <p class="note">The <code id="the-embed-element:the-embed-element-10"><a href="#the-embed-element">embed</a></code> element has no <a href="#fallback-content" id="the-embed-element:fallback-content-3">fallback content</a>; its
  descendants are ignored.</p>

  <div data-algorithm="">
  <p>Whenever an <code id="the-embed-element:the-embed-element-11"><a href="#the-embed-element">embed</a></code> element that was <a href="#concept-embed-active" id="the-embed-element:concept-embed-active-5">potentially
  active</a> stops being <a href="#concept-embed-active" id="the-embed-element:concept-embed-active-6">potentially active</a>, any
  <a href="#plugin" id="the-embed-element:plugin-6">plugin</a> that had been instantiated for that element must be unloaded.</p>
  </div>

  <p>The <code id="the-embed-element:the-embed-element-12"><a href="#the-embed-element">embed</a></code> element <a href="#potentially-delays-the-load-event" id="the-embed-element:potentially-delays-the-load-event">potentially delays the load event</a>.</p>

  

  <p>The <code id="the-embed-element:the-embed-element-13"><a href="#the-embed-element">embed</a></code> element supports <a href="#dimension-attributes" id="the-embed-element:dimension-attributes">dimension attributes</a>.</p>




  <h4 id="the-object-element"><span class="secno">4.8.7</span> The <dfn data-dfn-type="element"><code>object</code></dfn> element<a href="#the-object-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object" title="The <object> HTML element represents an external resource, which can be treated as an image, a nested browsing context, or a resource to be handled by a plugin.">Element/object</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement" title="The HTMLObjectElement interface provides special properties and methods (beyond those on the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of <object> element, representing external resources.">HTMLObjectElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/data" title="The data property of the HTMLObjectElement interface returns a string that reflects the data HTML attribute, specifying the address of a resource's data.">HTMLObjectElement/data</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/type" title="The type property of the HTMLObjectElement interface returns a string that reflects the type HTML attribute, specifying the MIME type of the resource.">HTMLObjectElement/type</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/name" title="The name property of the HTMLObjectElement interface returns a string that reflects the name HTML attribute, specifying the name of the browsing context.">HTMLObjectElement/name</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-object-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-object-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-object-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#embedded-content-category" id="the-object-element:embedded-content-category">Embedded content</a>.</dd><dd><a href="#category-listed" id="the-object-element:category-listed">Listed</a> <a href="#form-associated-element" id="the-object-element:form-associated-element">form-associated element</a>.</dd><dd><a href="#palpable-content-2" id="the-object-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-object-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#embedded-content-category" id="the-object-element:embedded-content-category-2">embedded content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-object-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#transparent" id="the-object-element:transparent">Transparent</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-object-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-object-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-object-element:global-attributes">Global attributes</a></dd><dd><code id="the-object-element:attr-object-data"><a href="#attr-object-data">data</a></code> —  Address of the resource
     </dd><dd><code id="the-object-element:attr-object-type"><a href="#attr-object-type">type</a></code> —  Type of embedded resource
     </dd><dd><code id="the-object-element:attr-object-name"><a href="#attr-object-name">name</a></code> —  Name of <a href="#content-navigable" id="the-object-element:content-navigable">content navigable</a>
     </dd><dd><code id="the-object-element:attr-fae-form"><a href="#attr-fae-form">form</a></code> —  Associates the element with a <code id="the-object-element:the-form-element"><a href="#the-form-element">form</a></code> element
     </dd><dd><code id="the-object-element:attr-dim-width"><a href="#attr-dim-width">width</a></code> —  Horizontal dimension
     </dd><dd><code id="the-object-element:attr-dim-height"><a href="#attr-dim-height">height</a></code> —  Vertical dimension
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-object-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-object">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-object">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-object-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlobjectelement" data-dfn-type="interface"><c- g="">HTMLObjectElement</c-></dfn> : <a href="#htmlelement" id="the-object-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-object-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-object-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-object-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-data" data-dfn-type="attribute"><c- g="">data</c-></dfn>;
  [<a href="#cereactions" id="the-object-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-object-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;
  [<a href="#cereactions" id="the-object-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-object-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-object-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-fae-form" id="the-object-element:dom-fae-form"><c- g="">form</c-></a>;
  [<a href="#cereactions" id="the-object-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-object-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;
  [<a href="#cereactions" id="the-object-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-object-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-height" data-dfn-type="attribute"><c- g="">height</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#document" id="the-object-element:document"><c- n="">Document</c-></a>? <a href="#dom-object-contentdocument" id="the-object-element:dom-object-contentdocument"><c- g="">contentDocument</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#windowproxy" id="the-object-element:windowproxy"><c- n="">WindowProxy</c-></a>? <a href="#dom-object-contentwindow" id="the-object-element:dom-object-contentwindow"><c- g="">contentWindow</c-></a>;
  <a href="#document" id="the-object-element:document-2"><c- n="">Document</c-></a>? <a href="#dom-media-getsvgdocument" id="the-object-element:dom-media-getsvgdocument"><c- g="">getSVGDocument</c-></a>();

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-cva-willvalidate" id="the-object-element:dom-cva-willvalidate"><c- g="">willValidate</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#validitystate" id="the-object-element:validitystate"><c- n="">ValidityState</c-></a> <a href="#dom-cva-validity" id="the-object-element:dom-cva-validity"><c- g="">validity</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-cva-validationmessage" id="the-object-element:dom-cva-validationmessage"><c- g="">validationMessage</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-cva-checkvalidity" id="the-object-element:dom-cva-checkvalidity"><c- g="">checkValidity</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-cva-reportvalidity" id="the-object-element:dom-cva-reportvalidity"><c- g="">reportValidity</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-cva-setcustomvalidity" id="the-object-element:dom-cva-setcustomvalidity"><c- g="">setCustomValidity</c-></a>(<c- b="">DOMString</c-> <c- g="">error</c->);

  // <a href="#HTMLObjectElement-partial">also has obsolete members</a>
};</code></pre>
    <p>Depending on the type of content instantiated by the
    <code id="the-object-element:the-object-element"><a href="#the-object-element">object</a></code> element, the node also supports other
    interfaces.</p>
   </dd></dl>

  <p>The <code id="the-object-element:the-object-element-2"><a href="#the-object-element">object</a></code> element can represent an external resource, which, depending on the
  type of the resource, will either be treated as an image or as a <a href="#child-navigable" id="the-object-element:child-navigable">child
  navigable</a>.</p>

  <p>The <dfn data-dfn-for="object" id="attr-object-data" data-dfn-type="element-attr"><code>data</code></dfn> attribute
  specifies the <a id="the-object-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the resource. It must be present, and must contain a
  <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="the-object-element:valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by spaces</a>.</p>

  <p>The <dfn data-dfn-for="object" id="attr-object-type" data-dfn-type="element-attr"><code>type</code></dfn> attribute,
  if present, specifies the type of the resource. If present, the attribute must be a <a id="the-object-element:valid-mime-type-string" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">valid
  MIME type string</a>.</p>

  <p>The <dfn data-dfn-for="object" id="attr-object-name" data-dfn-type="element-attr"><code>name</code></dfn>
  attribute, if present, must be a <a href="#valid-navigable-target-name" id="the-object-element:valid-navigable-target-name">valid navigable target name</a>. The given value is
  used to name the element's <a href="#content-navigable" id="the-object-element:content-navigable-2">content navigable</a>, if applicable, and if present when the
  element's <a href="#content-navigable" id="the-object-element:content-navigable-3">content navigable</a> is <a href="#create-a-new-child-navigable" id="the-object-element:create-a-new-child-navigable">created</a>.</p>

  

  <div data-algorithm="">
  <p>Whenever one of the following conditions occur:</p>

  <ul><li>the element is created,

   </li><li>the element is popped off the <a href="#stack-of-open-elements" id="the-object-element:stack-of-open-elements">stack of open elements</a> of an <a href="#html-parser" id="the-object-element:html-parser">HTML
   parser</a> or <a href="#xml-parser" id="the-object-element:xml-parser">XML parser</a>,

   </li><li>the element is not on the <a href="#stack-of-open-elements" id="the-object-element:stack-of-open-elements-2">stack of open elements</a> of an <a href="#html-parser" id="the-object-element:html-parser-2">HTML parser</a>
   or <a href="#xml-parser" id="the-object-element:xml-parser-2">XML parser</a>, and it is either <a href="#insert-an-element-into-a-document" id="the-object-element:insert-an-element-into-a-document">inserted into a document</a> or <a href="#remove-an-element-from-a-document" id="the-object-element:remove-an-element-from-a-document">removed from a document</a>,

   </li><li>the element's <a id="the-object-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> changes whether it is <a href="#fully-active" id="the-object-element:fully-active">fully active</a>,

   </li><li>one of the element's ancestor <code id="the-object-element:the-object-element-3"><a href="#the-object-element">object</a></code> elements changes to or from showing its
   <a href="#fallback-content" id="the-object-element:fallback-content">fallback content</a>,

   </li><li>the element's <code id="the-object-element:attr-object-classid"><a href="#attr-object-classid">classid</a></code> attribute is set, changed, or
   removed,

   </li><li>the element's <code id="the-object-element:attr-object-classid-2"><a href="#attr-object-classid">classid</a></code> attribute is not present, and
   its <code id="the-object-element:attr-object-data-2"><a href="#attr-object-data">data</a></code> attribute is set, changed, or removed,

   </li><li>neither the element's <code id="the-object-element:attr-object-classid-3"><a href="#attr-object-classid">classid</a></code> attribute nor its
   <code id="the-object-element:attr-object-data-3"><a href="#attr-object-data">data</a></code> attribute are present, and its <code id="the-object-element:attr-object-type-2"><a href="#attr-object-type">type</a></code> attribute is set, changed, or removed,

   </li><li>the element changes from <a href="#being-rendered" id="the-object-element:being-rendered">being rendered</a> to not being rendered, or vice versa,
  </li></ul> 

  <p>...the user agent must <a href="#queue-an-element-task" id="the-object-element:queue-an-element-task">queue an element task</a> on the <a href="#dom-manipulation-task-source" id="the-object-element:dom-manipulation-task-source">DOM manipulation task
  source</a> given the <code id="the-object-element:the-object-element-4"><a href="#the-object-element">object</a></code> element to run the following steps to (re)determine
  what the <code id="the-object-element:the-object-element-5"><a href="#the-object-element">object</a></code> element represents. This <a href="#concept-task" id="the-object-element:concept-task">task</a>
  being <a href="#queue-a-task" id="the-object-element:queue-a-task">queued</a> or actively running must <a href="#delay-the-load-event" id="the-object-element:delay-the-load-event">delay the load
  event</a> of the element's <a id="the-object-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>. </p>

  <ol><li>
    <p>If the user has indicated a preference that this <code id="the-object-element:the-object-element-6"><a href="#the-object-element">object</a></code> element's <a href="#fallback-content" id="the-object-element:fallback-content-2">fallback
    content</a> be shown instead of the element's usual behavior, then jump to the step below
    labeled <i>fallback</i>.</p>

    <p class="note">For example, a user could ask for the element's <a href="#fallback-content" id="the-object-element:fallback-content-3">fallback content</a> to
    be shown because that content uses a format that the user finds more accessible.</p>
   </li><li><p>If the element has an ancestor <a href="#media-element" id="the-object-element:media-element">media element</a>, or has an ancestor
   <code id="the-object-element:the-object-element-7"><a href="#the-object-element">object</a></code> element that is <em>not</em> showing its <a href="#fallback-content" id="the-object-element:fallback-content-4">fallback content</a>, or if
   the element is not <a id="the-object-element:in-a-document" href="https://dom.spec.whatwg.org/#in-a-document" data-x-internal="in-a-document">in a document</a> whose <a href="#concept-document-bc" id="the-object-element:concept-document-bc">browsing
   context</a> is non-null, or if the element's <a id="the-object-element:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="the-object-element:fully-active-2">fully
   active</a>, or if the element is still in the <a href="#stack-of-open-elements" id="the-object-element:stack-of-open-elements-3">stack of open elements</a> of an
   <a href="#html-parser" id="the-object-element:html-parser-3">HTML parser</a> or <a href="#xml-parser" id="the-object-element:xml-parser-3">XML parser</a>, or if the element is not <a href="#being-rendered" id="the-object-element:being-rendered-2">being
   rendered</a>, then jump to the step below labeled <i>fallback</i>.</p></li><li><p>If the <code id="the-object-element:attr-object-data-4"><a href="#attr-object-data">data</a></code> attribute is present and its value is
   not the empty string, then:</p>

    <ol><li><p>If the <code id="the-object-element:attr-object-type-3"><a href="#attr-object-type">type</a></code> attribute is present and its value is
     not a type that the user agent supports, then the user agent may jump to the step below labeled
     <i>fallback</i> without fetching the content to examine its real type.</p></li><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="the-object-element:encoding-parsing-a-url">encoding-parsing a URL</a> given the <code id="the-object-element:attr-object-data-5"><a href="#attr-object-data">data</a></code> attribute's value, relative to the element's <a id="the-object-element:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
     document</a>.</p></li><li><p>If <var>url</var> is failure, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-object-element:concept-event-fire" data-x-internal="concept-event-fire">fire an
     event</a> named <code id="the-object-element:event-error"><a href="#event-error">error</a></code> at the element and jump to the step
     below labeled <i>fallback</i>.</p></li><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="the-object-element:concept-request" data-x-internal="concept-request">request</a> whose
     <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="the-object-element:concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>url</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="the-object-element:concept-request-client" data-x-internal="concept-request-client">client</a> is the element's <a id="the-object-element:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
     <a href="#relevant-settings-object" id="the-object-element:relevant-settings-object">relevant settings object</a>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="the-object-element:concept-request-destination" data-x-internal="concept-request-destination">destination</a> is "<code>object</code>",
     <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="the-object-element:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> is "<code>include</code>", <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="the-object-element:concept-request-mode" data-x-internal="concept-request-mode">mode</a> is "<code>navigate</code>", <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="the-object-element:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator
     type</a> is "<code>object</code>", and whose <a id="the-object-element:use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials
     flag</a> is set.</p></li><li>
      <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-object-element:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var>.</p>

      
      <p>Fetching the resource must <a href="#delay-the-load-event" id="the-object-element:delay-the-load-event-2">delay the load event</a> of the element's <a id="the-object-element:node-document-6" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
      document</a> until the <a href="#concept-task" id="the-object-element:concept-task-2">task</a> that is <a href="#queue-a-task" id="the-object-element:queue-a-task-2">queued</a> by the <a href="#networking-task-source" id="the-object-element:networking-task-source">networking task source</a> once the resource has been
      fetched (defined next) has been run.</p>
     </li><li><p>If the resource is not yet available (e.g. because the resource was not available in the
     cache, so that loading the resource required making a request over the network), then jump to
     the step below labeled <i>fallback</i>. The <a href="#concept-task" id="the-object-element:concept-task-3">task</a> that is
     <a href="#queue-a-task" id="the-object-element:queue-a-task-3">queued</a> by the <a href="#networking-task-source" id="the-object-element:networking-task-source-2">networking task source</a> once the
     resource is available must restart this algorithm from this step. Resources can load
     incrementally; user agents may opt to consider a resource "available" whenever enough data has
     been obtained to begin processing the resource.</p></li><li><p>If the load failed (e.g. there was an HTTP 404 error, there was a DNS error), <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-object-element:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-object-element:event-error-2"><a href="#event-error">error</a></code>
     at the element, then jump to the step below labeled <i>fallback</i>.</p></li><li id="object-type-detection">

      <p>Determine the <var>resource type</var>, as follows:</p>



      <ol><li>
        <p>Let the <var>resource type</var> be unknown.</p>
       </li><li>
        

        <p>If the user agent is configured to strictly obey Content-Type headers for this resource,
        and the resource has <a href="#content-type" id="the-object-element:content-type">associated Content-Type metadata</a>,
        then let the <var>resource type</var> be the type specified in <a href="#content-type" id="the-object-element:content-type-2">the resource's Content-Type metadata</a>, and jump to the step below
        labeled <i>handler</i>.</p>

        <p class="warning">This can introduce a vulnerability, wherein a site is trying to embed a
        resource that uses a particular type, but the remote site overrides that and instead
        furnishes the user agent with a resource that triggers a different type of content with different
        security characteristics. </p>
       </li><li>
        <p>Run the appropriate set of steps from the following
        list:</p>

        <dl class="switch"><dt>If the resource has <a href="#content-type" id="the-object-element:content-type-3">associated Content-Type
         metadata</a></dt><dd>
          <ol><li>
            <p>Let <var>binary</var> be false.</p>
           </li><li>
            <p>If the type specified in <a href="#content-type" id="the-object-element:content-type-4">the resource's Content-Type
            metadata</a> is "<code id="the-object-element:text/plain"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>", and the result of applying the <a href="https://mimesniff.spec.whatwg.org/#rules-for-text-or-binary" id="the-object-element:content-type-sniffing:-text-or-binary" data-x-internal="content-type-sniffing:-text-or-binary">rules for distinguishing if a resource is
            text or binary</a> to the resource is that the resource is not
            <code id="the-object-element:text/plain-2"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>, then set <var>binary</var> to true.</p>
           </li><li>
            <p>If the type specified in <a href="#content-type" id="the-object-element:content-type-5">the resource's Content-Type
            metadata</a> is "<code id="the-object-element:application/octet-stream"><a data-x-internal="application/octet-stream" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1">application/octet-stream</a></code>", then set <var>binary</var> to true.</p>
           </li><li>
            <p>If <var>binary</var> is false, then let the <var>resource
            type</var> be the type specified in <a href="#content-type" id="the-object-element:content-type-6">the resource's
            Content-Type metadata</a>, and jump to the step below labeled <i>handler</i>.</p>
           </li><li>
            <p>If there is a <code id="the-object-element:attr-object-type-4"><a href="#attr-object-type">type</a></code> attribute present on the
            <code id="the-object-element:the-object-element-8"><a href="#the-object-element">object</a></code> element, and its value is not <code id="the-object-element:application/octet-stream-2"><a data-x-internal="application/octet-stream" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1">application/octet-stream</a></code>,
            then run the following steps:</p>

            <ol><li>
              <p>If the attribute's value is a type that starts with "<code>image/</code>" that is
              not also an <a id="the-object-element:xml-mime-type" href="https://mimesniff.spec.whatwg.org/#xml-mime-type" data-x-internal="xml-mime-type">XML MIME type</a>, then let the <var>resource type</var> be the
              type specified in that <code id="the-object-element:attr-object-type-5"><a href="#attr-object-type">type</a></code> attribute.</p>
             </li><li>
              <p>Jump to the step below labeled <i>handler</i>.</p>
             </li></ol>
           </li></ol>
         </dd><dt>Otherwise, if the resource does not have <a href="#content-type" id="the-object-element:content-type-7">associated
         Content-Type metadata</a></dt><dd>
          <ol><li>
            <p>If there is a <code id="the-object-element:attr-object-type-6"><a href="#attr-object-type">type</a></code> attribute present on the
            <code id="the-object-element:the-object-element-9"><a href="#the-object-element">object</a></code> element, then let the <var>tentative type</var> be the type
            specified in that <code id="the-object-element:attr-object-type-7"><a href="#attr-object-type">type</a></code> attribute.</p>

            <p>Otherwise, let <var>tentative type</var> be the <a href="https://mimesniff.spec.whatwg.org/#computed-mime-type" id="the-object-element:content-type-sniffing-2" data-x-internal="content-type-sniffing-2">computed type of the resource</a>.</p>
           </li><li>
            <p>If <var>tentative type</var> is <em>not</em>
            <code id="the-object-element:application/octet-stream-3"><a data-x-internal="application/octet-stream" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1">application/octet-stream</a></code>, then let <var>resource type</var> be
            <var>tentative type</var> and jump to the step below labeled
            <i>handler</i>.</p>
           </li></ol>
         </dd></dl>
       </li><li>
        

        <p>If applying the <a id="the-object-element:url-parser" href="https://url.spec.whatwg.org/#concept-url-parser" data-x-internal="url-parser">URL parser</a> algorithm to the <a id="the-object-element:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the
        specified resource (after any redirects) results in a <a id="the-object-element:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> whose <a href="https://url.spec.whatwg.org/#concept-url-path" id="the-object-element:concept-url-path" data-x-internal="concept-url-path">path</a> component matches a pattern that a <a href="#plugin" id="the-object-element:plugin">plugin</a>
        supports, then let <var>resource type</var> be the type that that plugin can
        handle.</p>

        <p class="example">For example, a plugin might say that it can handle resources with <a href="https://url.spec.whatwg.org/#concept-url-path" id="the-object-element:concept-url-path-2" data-x-internal="concept-url-path">path</a> components that end with the four character string
        "<code>.swf</code>".</p>

        
        
       </li></ol>

      <p class="note">It is possible for this step to finish, or for one of the substeps above to
      jump straight to the next step, with <var>resource type</var> still being unknown. In
      both cases, the next step will trigger fallback.</p>
     </li><li><p><i>Handler</i>: Handle the content as given by the first of the following cases that
     matches:</p>

      <dl class="switch"><dt>If the <var>resource type</var> is an <a id="the-object-element:xml-mime-type-2" href="https://mimesniff.spec.whatwg.org/#xml-mime-type" data-x-internal="xml-mime-type">XML MIME type</a>, or  if the <var>resource type</var>
       does not start with "<code>image/</code>"</dt><dd>
        <p>If the <code id="the-object-element:the-object-element-10"><a href="#the-object-element">object</a></code> element's <a href="#content-navigable" id="the-object-element:content-navigable-4">content navigable</a> is null, then
        <a href="#create-a-new-child-navigable" id="the-object-element:create-a-new-child-navigable-2">create a new child navigable</a> for the element.</p>

        <p>Let <var>response</var> be the <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-object-element:concept-response" data-x-internal="concept-response">response</a> from
        <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-object-element:concept-fetch-2" data-x-internal="concept-fetch">fetch</a>.</p>

        <p>If <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="the-object-element:concept-response-url" data-x-internal="concept-response-url">URL</a> does not <a href="#matches-about:blank" id="the-object-element:matches-about:blank">match <code>about:blank</code></a>, then
        <a href="#navigate" id="the-object-element:navigate">navigate</a> the element's <a href="#content-navigable" id="the-object-element:content-navigable-5">content navigable</a> to
        <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="the-object-element:concept-response-url-2" data-x-internal="concept-response-url">URL</a> using the element's
        <a id="the-object-element:node-document-7" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, with <i id="the-object-element:navigation-hh"><a href="#navigation-hh">historyHandling</a></i> set to
        "<code id="the-object-element:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p>

        <p class="note">The <code id="the-object-element:attr-object-data-6"><a href="#attr-object-data">data</a></code> attribute of the
        <code id="the-object-element:the-object-element-11"><a href="#the-object-element">object</a></code> element doesn't get updated if the <a href="#content-navigable" id="the-object-element:content-navigable-6">content navigable</a> gets
        further <a href="#navigate" id="the-object-element:navigate-2">navigated</a> to other locations.</p>

        <p>The <code id="the-object-element:the-object-element-12"><a href="#the-object-element">object</a></code> element <a href="#represents" id="the-object-element:represents">represents</a> its <a href="#content-navigable" id="the-object-element:content-navigable-7">content
        navigable</a>.</p>

        
       </dd><dt>If the <var>resource type</var> starts with "<code>image/</code>", and support
       for images has not been disabled</dt><dd>
        <p><a href="#destroy-a-child-navigable" id="the-object-element:destroy-a-child-navigable">Destroy a child navigable</a> given the <code id="the-object-element:the-object-element-13"><a href="#the-object-element">object</a></code> element.</p>

        <p>Apply the <a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-images-specifically" id="the-object-element:content-type-sniffing:-image" data-x-internal="content-type-sniffing:-image">image sniffing</a> rules to
        determine the type of the image.</p>

        <p>The <code id="the-object-element:the-object-element-14"><a href="#the-object-element">object</a></code> element <a href="#represents" id="the-object-element:represents-2">represents</a> the specified image.</p>

        <p>If the image cannot be rendered, e.g. because it is malformed or in an unsupported
        format, jump to the step below labeled <i>fallback</i>.</p>
       </dd><dt>Otherwise</dt><dd>
        <p>The given <var>resource type</var> is not supported. Jump to the step below
        labeled <i>fallback</i>.</p>

        <p class="note">If the previous step ended with the <var>resource type</var> being
        unknown, this is the case that is triggered.</p>
       </dd></dl>
     </li><li><p>The element's contents are not part of what the <code id="the-object-element:the-object-element-15"><a href="#the-object-element">object</a></code> element
     represents.</p>

     </li><li>
      <p>If the <code id="the-object-element:the-object-element-16"><a href="#the-object-element">object</a></code> element does not represent its <a href="#content-navigable" id="the-object-element:content-navigable-8">content navigable</a>,
      then once the resource is completely loaded, <a href="#queue-an-element-task" id="the-object-element:queue-an-element-task-2">queue an element task</a> on the
      <a href="#dom-manipulation-task-source" id="the-object-element:dom-manipulation-task-source-2">DOM manipulation task source</a> given the <code id="the-object-element:the-object-element-17"><a href="#the-object-element">object</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-object-element:concept-event-fire-3" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-object-element:event-load"><a href="#event-load">load</a></code>
      at the element.</p>

      <p class="note">If the element <em>does</em> represent its <a href="#content-navigable" id="the-object-element:content-navigable-9">content navigable</a>,
      then an analogous task will be queued when the created <code id="the-object-element:document-3"><a href="#document">Document</a></code> is <a href="#completely-finish-loading" id="the-object-element:completely-finish-loading">completely finished loading</a>.</p>
     </li><li><p>Return.</p></li></ol>
   </li><li><p><i>Fallback</i>: The <code id="the-object-element:the-object-element-18"><a href="#the-object-element">object</a></code> element <a href="#represents" id="the-object-element:represents-3">represents</a> the element's
   children. This is the element's <a href="#fallback-content" id="the-object-element:fallback-content-5">fallback content</a>. <a href="#destroy-a-child-navigable" id="the-object-element:destroy-a-child-navigable-2">Destroy a child
   navigable</a> given the element.</p></li></ol>
  </div>

  <p>Due to the algorithm above, the contents of <code id="the-object-element:the-object-element-19"><a href="#the-object-element">object</a></code> elements act as <a href="#fallback-content" id="the-object-element:fallback-content-6">fallback
  content</a>, used only when referenced resources can't be shown (e.g. because it returned a 404
  error). This allows multiple <code id="the-object-element:the-object-element-20"><a href="#the-object-element">object</a></code> elements to be nested inside each other,
  targeting multiple user agents with different capabilities, with the user agent picking the first
  one it supports.</p>

  <p>The <code id="the-object-element:the-object-element-21"><a href="#the-object-element">object</a></code> element <a href="#potentially-delays-the-load-event" id="the-object-element:potentially-delays-the-load-event">potentially delays the load event</a>.</p>

  

  <p>The <code id="the-object-element:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> attribute is used to explicitly associate the
  <code id="the-object-element:the-object-element-22"><a href="#the-object-element">object</a></code> element with its <a href="#form-owner" id="the-object-element:form-owner">form owner</a>.</p>

  <p>The <code id="the-object-element:the-object-element-23"><a href="#the-object-element">object</a></code> element supports <a href="#dimension-attributes" id="the-object-element:dimension-attributes">dimension attributes</a>.</p>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/contentDocument" title="The contentDocument read-only property of the HTMLObjectElement interface Returns a Document representing the active document of the object element's nested browsing context, if any; otherwise null.">HTMLObjectElement/contentDocument</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLObjectElement" id="dom-object-contentdocument" data-dfn-type="attribute"><code>contentDocument</code></dfn> getter steps are to return
  <a id="the-object-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-bcc-content-document" id="the-object-element:concept-bcc-content-document">content document</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/contentWindow" title="The contentWindow read-only property of the HTMLObjectElement interface returns a WindowProxy representing the window proxy of the object element's nested browsing context, if any; otherwise null.">HTMLObjectElement/contentWindow</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>13+</span></span><span class="chrome yes"><span>Chrome</span><span>53+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLObjectElement" id="dom-object-contentwindow" data-dfn-type="attribute"><code>contentWindow</code></dfn> getter steps are to return
  <a id="the-object-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#content-window" id="the-object-element:content-window">content window</a>.</p>
  </div>

  <p>The <code id="the-object-element:dom-cva-willvalidate-2"><a href="#dom-cva-willvalidate">willValidate</a></code>, <code id="the-object-element:dom-cva-validity-2"><a href="#dom-cva-validity">validity</a></code>, and <code id="the-object-element:dom-cva-validationmessage-2"><a href="#dom-cva-validationmessage">validationMessage</a></code> attributes, and the <code id="the-object-element:dom-cva-checkvalidity-2"><a href="#dom-cva-checkvalidity">checkValidity()</a></code>, <code id="the-object-element:dom-cva-reportvalidity-2"><a href="#dom-cva-reportvalidity">reportValidity()</a></code>, and <code id="the-object-element:dom-cva-setcustomvalidity-2"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> methods, are part of the
  <a href="#the-constraint-validation-api" id="the-object-element:the-constraint-validation-api">constraint validation API</a>. The <code id="the-object-element:dom-fae-form-2"><a href="#dom-fae-form">form</a></code> IDL attribute
  is part of the element's forms API.</p>

  

  <div class="example">

   <p>In this example, an HTML page is embedded in another using the <code id="the-object-element:the-object-element-24"><a href="#the-object-element">object</a></code>
   element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">object</c-> <c- e="">data</c-><c- o="">=</c-><c- s="">"clock.html"</c-><c- p="">&gt;&lt;/</c-><c- f="">object</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->My HTML Clock<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-video-element"><span class="secno">4.8.8</span> The <dfn id="video" data-dfn-type="element"><code>video</code></dfn> element<a href="#the-video-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video" title="The <video> HTML element embeds a media player which supports video playback into the document. You can use <video> for audio content as well, but the <audio> element may provide a more appropriate user experience.">Element/video</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement" title="Implemented by the <video> element, the HTMLVideoElement interface provides special properties and methods for manipulating video objects. It also inherits properties and methods of HTMLMediaElement and HTMLElement.">HTMLVideoElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-video-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-video-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-video-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#embedded-content-category" id="the-video-element:embedded-content-category">Embedded content</a>.</dd><dd>If the element has a <code id="the-video-element:attr-media-controls"><a href="#attr-media-controls">controls</a></code> attribute: <a href="#interactive-content-2" id="the-video-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#palpable-content-2" id="the-video-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-video-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#embedded-content-category" id="the-video-element:embedded-content-category-2">embedded content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-video-element:concept-element-content-model">Content model</a>:</dt><dd>If the element has a <code id="the-video-element:attr-media-src"><a href="#attr-media-src">src</a></code> attribute:
 zero or more <code id="the-video-element:the-track-element"><a href="#the-track-element">track</a></code> elements, then
 <a href="#transparent" id="the-video-element:transparent">transparent</a>, but with no <a href="#media-element" id="the-video-element:media-element">media element</a> descendants.</dd><dd>If the element does not have a <code id="the-video-element:attr-media-src-2"><a href="#attr-media-src">src</a></code> attribute: zero or more <code id="the-video-element:the-source-element"><a href="#the-source-element">source</a></code> elements, then
 zero or more <code id="the-video-element:the-track-element-2"><a href="#the-track-element">track</a></code> elements, then
 <a href="#transparent" id="the-video-element:transparent-2">transparent</a>, but with no <a href="#media-element" id="the-video-element:media-element-2">media element</a> descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-video-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-video-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-video-element:global-attributes">Global attributes</a></dd><dd><code id="the-video-element:attr-media-src-3"><a href="#attr-media-src">src</a></code> —  Address of the resource
     </dd><dd><code id="the-video-element:attr-media-crossorigin"><a href="#attr-media-crossorigin">crossorigin</a></code> —  How the element handles crossorigin requests
     </dd><dd><code id="the-video-element:attr-video-poster"><a href="#attr-video-poster">poster</a></code> —  Poster frame to show prior to video playback
     </dd><dd><code id="the-video-element:attr-media-preload"><a href="#attr-media-preload">preload</a></code> —  Hints how much buffering the <a href="#media-resource" id="the-video-element:media-resource">media resource</a> will likely need
     </dd><dd><code id="the-video-element:attr-media-autoplay"><a href="#attr-media-autoplay">autoplay</a></code> —  Hint that the <a href="#media-resource" id="the-video-element:media-resource-2">media resource</a> can be started automatically when the page is loaded
     </dd><dd><code id="the-video-element:attr-video-playsinline"><a href="#attr-video-playsinline">playsinline</a></code> —  Encourage the user agent to display video content within the element's playback area
     </dd><dd><code id="the-video-element:attr-media-loop"><a href="#attr-media-loop">loop</a></code> —  Whether to loop the <a href="#media-resource" id="the-video-element:media-resource-3">media resource</a>
     </dd><dd><code id="the-video-element:attr-media-muted"><a href="#attr-media-muted">muted</a></code> —  Whether to mute the <a href="#media-resource" id="the-video-element:media-resource-4">media resource</a> by default
     </dd><dd><code id="the-video-element:attr-media-controls-2"><a href="#attr-media-controls">controls</a></code> —  Show user agent controls
     </dd><dd><code id="the-video-element:attr-dim-width"><a href="#attr-dim-width">width</a></code> —  Horizontal dimension
     </dd><dd><code id="the-video-element:attr-dim-height"><a href="#attr-dim-height">height</a></code> —  Vertical dimension
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-video-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-video">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-video">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-video-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlvideoelement" data-dfn-type="interface"><c- g="">HTMLVideoElement</c-></dfn> : <a href="#htmlmediaelement" id="the-video-element:htmlmediaelement"><c- n="">HTMLMediaElement</c-></a> {
  [<a href="#htmlconstructor" id="the-video-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-video-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-video-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLVideoElement" id="dom-video-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;
  [<a href="#cereactions" id="the-video-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-video-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLVideoElement" id="dom-video-height" data-dfn-type="attribute"><c- g="">height</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-video-videowidth" id="the-video-element:dom-video-videowidth"><c- g="">videoWidth</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-video-videoheight" id="the-video-element:dom-video-videoheight"><c- g="">videoHeight</c-></a>;
  [<a href="#cereactions" id="the-video-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-video-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLVideoElement" id="dom-video-poster" data-dfn-type="attribute"><c- g="">poster</c-></dfn>;
  [<a href="#cereactions" id="the-video-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-video-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLVideoElement" id="dom-video-playsinline" data-dfn-type="attribute"><c- g="">playsInline</c-></dfn>;
};</code></pre>
   </dd></dl>

  <p>A <code id="the-video-element:the-video-element"><a href="#the-video-element">video</a></code> element is used for playing videos or movies, and audio files with
  captions.</p>

  <p>Content may be provided inside the <code id="the-video-element:the-video-element-2"><a href="#the-video-element">video</a></code> element. User agents
  should not show this content to the user; it is intended for older web browsers which do
  not support <code id="the-video-element:the-video-element-3"><a href="#the-video-element">video</a></code>, so that text can be shown to the users of these older browsers
  informing them of how to access the video contents.</p>

  <p class="note">In particular, this content is not intended to address accessibility concerns. To
  make video content accessible to the partially sighted, the blind, the hard-of-hearing, the deaf,
  and those with other physical or cognitive disabilities, a variety of features are available.
  Captions can be provided, either embedded in the video stream or as external files using the
  <code id="the-video-element:the-track-element-3"><a href="#the-track-element">track</a></code> element. Sign-language tracks can be embedded in the video stream. Audio
  descriptions can be embedded in the video stream or in text form using a <a id="the-video-element:webvtt-file" href="https://w3c.github.io/webvtt/#webvtt-file" data-x-internal="webvtt-file">WebVTT file</a>
  referenced using the <code id="the-video-element:the-track-element-4"><a href="#the-track-element">track</a></code> element and synthesized into speech by the user agent.
  WebVTT can also be used to provide chapter titles. For users who would rather not use a media
  element at all, transcripts or other textual alternatives can be provided by simply linking to
  them in the prose near the <code id="the-video-element:the-video-element-4"><a href="#the-video-element">video</a></code> element. <a href="#refsWEBVTT">[WEBVTT]</a></p>

  <p>The <code id="the-video-element:the-video-element-5"><a href="#the-video-element">video</a></code> element is a <a href="#media-element" id="the-video-element:media-element-3">media element</a> whose <a href="#media-data" id="the-video-element:media-data">media data</a> is
  ostensibly video data, possibly with associated audio data.</p>

  <p>The <code id="the-video-element:attr-media-src-4"><a href="#attr-media-src">src</a></code>, <code id="the-video-element:attr-media-crossorigin-2"><a href="#attr-media-crossorigin">crossorigin</a></code>,
  <code id="the-video-element:attr-media-preload-2"><a href="#attr-media-preload">preload</a></code>, <code id="the-video-element:attr-media-autoplay-2"><a href="#attr-media-autoplay">autoplay</a></code>,
  <code id="the-video-element:attr-media-loop-2"><a href="#attr-media-loop">loop</a></code>, <code id="the-video-element:attr-media-muted-2"><a href="#attr-media-muted">muted</a></code>, and <code id="the-video-element:attr-media-controls-3"><a href="#attr-media-controls">controls</a></code> attributes are <a href="#media-element-attributes" id="the-video-element:media-element-attributes">the attributes common to all media elements</a>.</p>

  <p>The <dfn data-dfn-for="video" id="attr-video-poster" data-dfn-type="element-attr"><code>poster</code></dfn>
  attribute gives the <a id="the-video-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of an image file that the user agent can show while no video
  data is available.  The attribute, if present, must contain a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="the-video-element:valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL
  potentially surrounded by spaces</a>.</p>

  

  <div data-algorithm="">
  <p>If the specified resource is to be used, then, when the element is created or when the <code id="the-video-element:attr-video-poster-2"><a href="#attr-video-poster">poster</a></code> attribute is set, changed, or removed, the user agent must
  run the following steps to determine the element's <dfn id="poster-frame">poster frame</dfn> (regardless of the
  value of the element's <a href="#show-poster-flag" id="the-video-element:show-poster-flag">show poster flag</a>):</p> 

  <ol><li><p>If there is an existing instance of this algorithm running for this <code id="the-video-element:the-video-element-6"><a href="#the-video-element">video</a></code>
   element, abort that instance of this algorithm without changing the <a href="#poster-frame" id="the-video-element:poster-frame">poster
   frame</a>.</p></li><li><p>If the <code id="the-video-element:attr-video-poster-3"><a href="#attr-video-poster">poster</a></code> attribute's value is the empty string
   or if the attribute is absent, then there is no <a href="#poster-frame" id="the-video-element:poster-frame-2">poster frame</a>; return.</p></li><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="the-video-element:encoding-parsing-a-url">encoding-parsing a URL</a> given the <code id="the-video-element:attr-video-poster-4"><a href="#attr-video-poster">poster</a></code> attribute's value, relative to the element's <a id="the-video-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>.</p></li><li><p>If <var>url</var> is failure, then return. <span class="note">There is no <a href="#poster-frame" id="the-video-element:poster-frame-3">poster
   frame</a>.</span></p></li><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="the-video-element:concept-request" data-x-internal="concept-request">request</a> whose <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="the-video-element:concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>url</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="the-video-element:concept-request-client" data-x-internal="concept-request-client">client</a> is the element's <a id="the-video-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
   <a href="#relevant-settings-object" id="the-video-element:relevant-settings-object">relevant settings object</a>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="the-video-element:concept-request-destination" data-x-internal="concept-request-destination">destination</a> is "<code>image</code>", <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="the-video-element:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator type</a> is "<code>video</code>",
   <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="the-video-element:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> is "<code>include</code>", and whose <a id="the-video-element:use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a> is set.

   </p></li><li><p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-video-element:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var>. This must
   <a href="#delay-the-load-event" id="the-video-element:delay-the-load-event">delay the load event</a> of the element's <a id="the-video-element:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If an image is thus obtained, the <a href="#poster-frame" id="the-video-element:poster-frame-4">poster frame</a> is that image. Otherwise,
   there is no <a href="#poster-frame" id="the-video-element:poster-frame-5">poster frame</a>.</p></li></ol>
  </div>

  

  <p class="note">The image given by the <code id="the-video-element:attr-video-poster-5"><a href="#attr-video-poster">poster</a></code> attribute,
  the <i id="the-video-element:poster-frame-6"><a href="#poster-frame">poster frame</a></i>, is intended to be a representative frame of the
  video (typically one of the first non-blank frames) that gives the user an idea of what the video
  is like.</p>


  <p>The <dfn data-dfn-for="video" id="attr-video-playsinline" data-dfn-type="element-attr"><code>playsinline</code></dfn> attribute is a <a href="#boolean-attribute" id="the-video-element:boolean-attribute">boolean
  attribute</a>. If present, it serves as a hint to the user agent that the video ought to be
  displayed "inline" in the document by default, constrained to the element's playback area, instead
  of being displayed fullscreen or in an independent resizable window.</p>

  <p class="note">The absence of the <code id="the-video-element:attr-video-playsinline-2"><a href="#attr-video-playsinline">playsinline</a></code>
  attribute does not imply that the video will display fullscreen by default. Indeed, most user
  agents have chosen to play all videos inline by default, and in such user agents the <code id="the-video-element:attr-video-playsinline-3"><a href="#attr-video-playsinline">playsinline</a></code> attribute has no effect.</p>

  

  <hr>

  <div data-algorithm="">
  <p>A <code id="the-video-element:the-video-element-7"><a href="#the-video-element">video</a></code> element represents what is given for the first matching condition in the
  list below:</p>

  <dl class="switch"><dt>When no video data is available (the element's <code id="the-video-element:dom-media-readystate"><a href="#dom-media-readystate">readyState</a></code> attribute is either <code id="the-video-element:dom-media-have_nothing"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>, or <code id="the-video-element:dom-media-have_metadata"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> but no video data has yet been obtained at
   all, or the element's <code id="the-video-element:dom-media-readystate-2"><a href="#dom-media-readystate">readyState</a></code> attribute is any
   subsequent value but the <a href="#media-resource" id="the-video-element:media-resource-5">media resource</a> does not have a video channel)</dt><dd>The <code id="the-video-element:the-video-element-8"><a href="#the-video-element">video</a></code> element <a href="#represents" id="the-video-element:represents">represents</a> its <a href="#poster-frame" id="the-video-element:poster-frame-7">poster frame</a>, if any,
   or else <a id="the-video-element:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> with no <a id="the-video-element:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a>.</dd><dt>When the <code id="the-video-element:the-video-element-9"><a href="#the-video-element">video</a></code> element is <a href="#dom-media-paused" id="the-video-element:dom-media-paused">paused</a>, the <a href="#current-playback-position" id="the-video-element:current-playback-position">current playback position</a> is the first frame of video,
   and the element's <a href="#show-poster-flag" id="the-video-element:show-poster-flag-2">show poster flag</a> is set</dt><dd>The <code id="the-video-element:the-video-element-10"><a href="#the-video-element">video</a></code> element <a href="#represents" id="the-video-element:represents-2">represents</a> its <a href="#poster-frame" id="the-video-element:poster-frame-8">poster frame</a>, if any,
   or else the first frame of the video.</dd><dt>When the <code id="the-video-element:the-video-element-11"><a href="#the-video-element">video</a></code> element is <a href="#dom-media-paused" id="the-video-element:dom-media-paused-2">paused</a>, and the
   frame of video corresponding to the <a href="#current-playback-position" id="the-video-element:current-playback-position-2">current playback
   position</a> is not available (e.g. because the video is seeking or buffering)</dt><dt>When the <code id="the-video-element:the-video-element-12"><a href="#the-video-element">video</a></code> element is neither <a href="#potentially-playing" id="the-video-element:potentially-playing">potentially playing</a> nor <a href="#dom-media-paused" id="the-video-element:dom-media-paused-3">paused</a> (e.g. when seeking or stalled)</dt><dd>The <code id="the-video-element:the-video-element-13"><a href="#the-video-element">video</a></code> element <a href="#represents" id="the-video-element:represents-3">represents</a> the last frame of the video to have
   been rendered.</dd><dt>When the <code id="the-video-element:the-video-element-14"><a href="#the-video-element">video</a></code> element is <a href="#dom-media-paused" id="the-video-element:dom-media-paused-4">paused</a></dt><dd>The <code id="the-video-element:the-video-element-15"><a href="#the-video-element">video</a></code> element <a href="#represents" id="the-video-element:represents-4">represents</a> the frame of video corresponding to
   the <a href="#current-playback-position" id="the-video-element:current-playback-position-3">current playback position</a>.</dd><dt>Otherwise (the <code id="the-video-element:the-video-element-16"><a href="#the-video-element">video</a></code> element has a video channel and is <a href="#potentially-playing" id="the-video-element:potentially-playing-2">potentially
   playing</a>)</dt><dd>The <code id="the-video-element:the-video-element-17"><a href="#the-video-element">video</a></code> element <a href="#represents" id="the-video-element:represents-5">represents</a> the frame of video at the continuously
   increasing <a href="#current-playback-position" id="the-video-element:current-playback-position-4">"current" position</a>. When the
   <a href="#current-playback-position" id="the-video-element:current-playback-position-5">current playback position</a> changes such that the last frame rendered is no longer the
   frame corresponding to the <a href="#current-playback-position" id="the-video-element:current-playback-position-6">current playback position</a> in the video, the new frame
   must be rendered.</dd></dl>
  </div>

  <p>Frames of video must be obtained from the video track that was <a href="#dom-videotrack-selected" id="the-video-element:dom-videotrack-selected">selected</a> when the <a href="#event-loop" id="the-video-element:event-loop">event loop</a> last reached
  <a href="#step1">step 1</a>.</p>

  <p class="note">Which frame in a video stream corresponds to a particular playback position is
  defined by the video stream's format.</p>

  <p>The <code id="the-video-element:the-video-element-18"><a href="#the-video-element">video</a></code> element also <a href="#represents" id="the-video-element:represents-6">represents</a> any <a href="#text-track-cue" id="the-video-element:text-track-cue">text track cues</a> whose <a href="#text-track-cue-active-flag" id="the-video-element:text-track-cue-active-flag">text track cue active flag</a> is set and whose
  <a href="#text-track" id="the-video-element:text-track">text track</a> is in the <a href="#text-track-showing" id="the-video-element:text-track-showing">showing</a> mode, and any
  audio from the <a href="#media-resource" id="the-video-element:media-resource-6">media resource</a>, at the <a href="#current-playback-position" id="the-video-element:current-playback-position-7">current playback position</a>.</p>

  <p>Any audio associated with the <a href="#media-resource" id="the-video-element:media-resource-7">media resource</a> must, if played, be played
  synchronized with the <a href="#current-playback-position" id="the-video-element:current-playback-position-8">current playback position</a>, at the element's <a href="#effective-media-volume" id="the-video-element:effective-media-volume">effective
  media volume</a>. The user agent must play the audio from audio tracks that were <a href="#dom-audiotrack-enabled" id="the-video-element:dom-audiotrack-enabled">enabled</a> when the <a href="#event-loop" id="the-video-element:event-loop-2">event loop</a> last reached step
  1.</p>

  <p>In addition to the above, the user agent may provide messages to the user (such as "buffering",
  "no video loaded", "error", or more detailed information) by overlaying text or icons on the video
  or other areas of the element's playback area, or in another appropriate manner.</p>

  <p>User agents that cannot render the video may instead make the element <a href="#represents" id="the-video-element:represents-7">represent</a> a link to an external video playback utility or to the video
  data itself.</p>

  <p>When a <code id="the-video-element:the-video-element-19"><a href="#the-video-element">video</a></code> element's <a href="#media-resource" id="the-video-element:media-resource-8">media resource</a> has a video channel, the
  element provides a <a id="the-video-element:paint-source" href="https://drafts.csswg.org/css-images-4/#paint-source" data-x-internal="paint-source">paint source</a> whose width is the <a href="#media-resource" id="the-video-element:media-resource-9">media resource</a>'s
  <a href="#concept-video-intrinsic-width" id="the-video-element:concept-video-intrinsic-width">natural width</a>, whose height is the
  <a href="#media-resource" id="the-video-element:media-resource-10">media resource</a>'s <a href="#concept-video-intrinsic-height" id="the-video-element:concept-video-intrinsic-height">natural
  height</a>, and whose appearance is the frame of video corresponding to the <a href="#current-playback-position" id="the-video-element:current-playback-position-9">current playback position</a>, if that is available, or else
  (e.g. when the video is seeking or buffering) its previous appearance, if any, or else (e.g.
  because the video is still loading the first frame) blackness.</p>

  <hr>

  

  <dl class="domintro"><dt><code><var>video</var>.<a href="#dom-video-videowidth" id="dom-video-videowidth-dev">videoWidth</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement/videoWidth" title="The HTMLVideoElement interface's read-only videoWidth property indicates the intrinsic width of the video, expressed in CSS pixels. In simple terms, this is the width of the media in its natural size.">HTMLVideoElement/videoWidth</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dt><code><var>video</var>.<a href="#dom-video-videoheight" id="dom-video-videoheight-dev">videoHeight</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement/videoHeight" title="The HTMLVideoElement interface's read-only videoHeight property indicates the intrinsic height of the video, expressed in CSS pixels. In simple terms, this is the height of the media in its natural size.">HTMLVideoElement/videoHeight</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>These attributes return the natural dimensions of the video, or 0 if the dimensions are not
    known.</p>
   </dd></dl>

  

  <p>The <dfn id="concept-video-intrinsic-width">natural
  width</dfn> and <dfn id="concept-video-intrinsic-height">natural height</dfn> of the <a href="#media-resource" id="the-video-element:media-resource-11">media resource</a> are
  the dimensions of the resource in <a href="https://drafts.csswg.org/css-values/#px" id="the-video-element:'px'" data-x-internal="'px'">CSS pixels</a> after taking into account
  the resource's dimensions, aspect ratio, clean aperture, resolution, and so forth, as defined for
  the format used by the resource. If an anamorphic format does not define how to apply the aspect
  ratio to the video data's dimensions to obtain the "correct" dimensions, then the user agent must
  apply the ratio by increasing one dimension and leaving the other unchanged.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLVideoElement" id="dom-video-videowidth" data-dfn-type="attribute"><code>videoWidth</code></dfn> IDL attribute must return the <a href="#concept-video-intrinsic-width" id="the-video-element:concept-video-intrinsic-width-2">natural width</a> of the video in <a href="https://drafts.csswg.org/css-values/#px" id="the-video-element:'px'-2" data-x-internal="'px'">CSS pixels</a>. The <dfn data-dfn-for="HTMLVideoElement" id="dom-video-videoheight" data-dfn-type="attribute"><code>videoHeight</code></dfn> IDL attribute must return the <a href="#concept-video-intrinsic-height" id="the-video-element:concept-video-intrinsic-height-2">natural height</a> of the video in <a href="https://drafts.csswg.org/css-values/#px" id="the-video-element:'px'-3" data-x-internal="'px'">CSS pixels</a>. If the element's <code id="the-video-element:dom-media-readystate-3"><a href="#dom-media-readystate">readyState</a></code> attribute is <code id="the-video-element:dom-media-have_nothing-2"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>, then the attributes must return 0.</p>
  </div>

  <div data-algorithm="">
  <p id="dimUpdate">Whenever the <a href="#concept-video-intrinsic-width" id="the-video-element:concept-video-intrinsic-width-3">natural width</a>
  or <a href="#concept-video-intrinsic-height" id="the-video-element:concept-video-intrinsic-height-3">natural height</a> of the video changes
  (including, for example, because the <a href="#dom-videotrack-selected" id="the-video-element:dom-videotrack-selected-2">selected video
  track</a> was changed), if the element's <code id="the-video-element:dom-media-readystate-4"><a href="#dom-media-readystate">readyState</a></code>
  attribute is not <code id="the-video-element:dom-media-have_nothing-3"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>, the user agent must
  <a href="#queue-a-media-element-task" id="the-video-element:queue-a-media-element-task">queue a media element task</a> given the <a href="#media-element" id="the-video-element:media-element-4">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-video-element:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-video-element:event-media-resize"><a href="#event-media-resize">resize</a></code> at the <a href="#media-element" id="the-video-element:media-element-5">media element</a>.</p>
  </div>

  

  <p>The <code id="the-video-element:the-video-element-20"><a href="#the-video-element">video</a></code> element supports <a href="#dimension-attributes" id="the-video-element:dimension-attributes">dimension attributes</a>.</p>

  

  <p>In the absence of style rules to the contrary, video content should be rendered inside the
  element's playback area such that the video content is shown centered in the playback area at the
  largest possible size that fits completely within it, with the video content's aspect ratio being
  preserved. Thus, if the aspect ratio of the playback area does not match the aspect ratio of the
  video, the video will be shown letterboxed or pillarboxed. Areas of the element's playback area
  that do not contain the video represent nothing.</p>

  <p class="note">In user agents that implement CSS, the above requirement can be implemented by
  using the <a href="#video-object-fit">style rule suggested in the Rendering section</a>.</p>

  <div data-algorithm="">
  <p>The <a id="the-video-element:natural-width" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> of a <code id="the-video-element:the-video-element-21"><a href="#the-video-element">video</a></code> element's playback area is the
  <a id="the-video-element:natural-width-2" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> of the <a href="#poster-frame" id="the-video-element:poster-frame-9">poster frame</a>, if that is available and the
  element currently <a href="#represents" id="the-video-element:represents-8">represents</a> its poster frame; otherwise, it is the <a href="#concept-video-intrinsic-width" id="the-video-element:concept-video-intrinsic-width-4">natural width</a> of the video resource, if that is
  available; otherwise the <a id="the-video-element:natural-width-3" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> is missing.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-video-element:natural-height" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a> of a <code id="the-video-element:the-video-element-22"><a href="#the-video-element">video</a></code> element's playback area is the
  <a id="the-video-element:natural-height-2" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a> of the <a href="#poster-frame" id="the-video-element:poster-frame-10">poster frame</a>, if that is available and the
  element currently <a href="#represents" id="the-video-element:represents-9">represents</a> its poster frame; otherwise it is the <a href="#concept-video-intrinsic-height" id="the-video-element:concept-video-intrinsic-height-4">natural height</a> of the video resource, if that is
  available; otherwise the <a id="the-video-element:natural-height-3" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a> is missing.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-video-element:default-object-size" href="https://drafts.csswg.org/css-images/#default-object-size" data-x-internal="default-object-size">default object size</a> is a width of 300 <a href="https://drafts.csswg.org/css-values/#px" id="the-video-element:'px'-4" data-x-internal="'px'">CSS pixels</a>
  and a height of 150 <a href="https://drafts.csswg.org/css-values/#px" id="the-video-element:'px'-5" data-x-internal="'px'">CSS pixels</a>. <a href="#refsCSSIMAGES">[CSSIMAGES]</a></p>
  </div>

  <hr>

  <p>User agents should provide controls to enable or disable the display of closed captions, audio
  description tracks, and other additional data associated with the video stream, though such
  features should, again, not interfere with the page's normal rendering.</p>

  <p>User agents may allow users to view the video content in manners more suitable to the user,
  such as fullscreen or in an independent resizable window. User agents may even trigger such a
  viewing mode by default upon playing a video, although they should not do so when the <code id="the-video-element:attr-video-playsinline-4"><a href="#attr-video-playsinline">playsinline</a></code> attribute is specified. As with the other user
  interface features, controls to enable this should not interfere with the page's normal rendering
  unless the user agent is <a href="#expose-a-user-interface-to-the-user" id="the-video-element:expose-a-user-interface-to-the-user">exposing a user
  interface</a>. In such an independent viewing mode, however, user agents may make full user
  interfaces visible, even if the <code id="the-video-element:attr-media-controls-4"><a href="#attr-media-controls">controls</a></code> attribute is
  absent.</p>

  <p>User agents may allow video playback to affect system features that could interfere with the
  user's experience; for example, user agents could disable screensavers while video playback is in
  progress.</p>

  <hr>

  

  <div class="example">

   <p>This example shows how to detect when a video has failed to play correctly:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">function</c-> failed<c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
   <c- c1="">// video playback failed - show a message saying why</c->
   <c- k="">switch</c-> <c- p="">(</c->e<c- p="">.</c->target<c- p="">.</c->error<c- p="">.</c->code<c- p="">)</c-> <c- p="">{</c->
     <c- k="">case</c-> e<c- p="">.</c->target<c- p="">.</c->error<c- p="">.</c->MEDIA_ERR_ABORTED<c- o="">:</c->
       alert<c- p="">(</c-><c- t="">'You aborted the video playback.'</c-><c- p="">);</c->
       <c- k="">break</c-><c- p="">;</c->
     <c- k="">case</c-> e<c- p="">.</c->target<c- p="">.</c->error<c- p="">.</c->MEDIA_ERR_NETWORK<c- o="">:</c->
       alert<c- p="">(</c-><c- t="">'A network error caused the video download to fail part-way.'</c-><c- p="">);</c->
       <c- k="">break</c-><c- p="">;</c->
     <c- k="">case</c-> e<c- p="">.</c->target<c- p="">.</c->error<c- p="">.</c->MEDIA_ERR_DECODE<c- o="">:</c->
       alert<c- p="">(</c-><c- t="">'The video playback was aborted due to a corruption problem or because the video used features your browser did not support.'</c-><c- p="">);</c->
       <c- k="">break</c-><c- p="">;</c->
     <c- k="">case</c-> e<c- p="">.</c->target<c- p="">.</c->error<c- p="">.</c->MEDIA_ERR_SRC_NOT_SUPPORTED<c- o="">:</c->
       alert<c- p="">(</c-><c- t="">'The video could not be loaded, either because the server or network failed or because the format is not supported.'</c-><c- p="">);</c->
       <c- k="">break</c-><c- p="">;</c->
     <c- k="">default</c-><c- o="">:</c->
       alert<c- p="">(</c-><c- t="">'An unknown error occurred.'</c-><c- p="">);</c->
       <c- k="">break</c-><c- p="">;</c->
   <c- p="">}</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">video</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"tgif.vid"</c-> <c- e="">autoplay</c-> <c- e="">controls</c-> <c- e="">onerror</c-><c- o="">=</c-><c- s="">"failed(event)"</c-><c- p="">&gt;&lt;/</c-><c- f="">video</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"tgif.vid"</c-><c- p="">&gt;</c->Download the video file<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>




  





  <h4 id="the-audio-element"><span class="secno">4.8.9</span> The <dfn id="audio" data-dfn-type="element"><code>audio</code></dfn> element<a href="#the-audio-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio" title="The <audio> HTML element is used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the <source> element: the browser will choose the most suitable one. It can also be the destination for streamed media, using a MediaStream.">Element/audio</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement" title="The HTMLAudioElement interface provides access to the properties of <audio> elements, as well as methods to manipulate them.">HTMLAudioElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-audio-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-audio-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-audio-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#embedded-content-category" id="the-audio-element:embedded-content-category">Embedded content</a>.</dd><dd>If the element has a <code id="the-audio-element:attr-media-controls"><a href="#attr-media-controls">controls</a></code> attribute: <a href="#interactive-content-2" id="the-audio-element:interactive-content-2">Interactive content</a>.</dd><dd>If the element has a <code id="the-audio-element:attr-media-controls-2"><a href="#attr-media-controls">controls</a></code> attribute: <a href="#palpable-content-2" id="the-audio-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-audio-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#embedded-content-category" id="the-audio-element:embedded-content-category-2">embedded content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-audio-element:concept-element-content-model">Content model</a>:</dt><dd>If the element has a <code id="the-audio-element:attr-media-src"><a href="#attr-media-src">src</a></code> attribute:
zero or more <code id="the-audio-element:the-track-element"><a href="#the-track-element">track</a></code> elements, then
<a href="#transparent" id="the-audio-element:transparent">transparent</a>, but with no <a href="#media-element" id="the-audio-element:media-element">media element</a> descendants.</dd><dd>If the element does not have a <code id="the-audio-element:attr-media-src-2"><a href="#attr-media-src">src</a></code> attribute: zero or more <code id="the-audio-element:the-source-element"><a href="#the-source-element">source</a></code> elements, then
 zero or more <code id="the-audio-element:the-track-element-2"><a href="#the-track-element">track</a></code> elements, then
 <a href="#transparent" id="the-audio-element:transparent-2">transparent</a>, but with no <a href="#media-element" id="the-audio-element:media-element-2">media element</a> descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-audio-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-audio-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-audio-element:global-attributes">Global attributes</a></dd><dd><code id="the-audio-element:attr-media-src-3"><a href="#attr-media-src">src</a></code> —  Address of the resource
     </dd><dd><code id="the-audio-element:attr-media-crossorigin"><a href="#attr-media-crossorigin">crossorigin</a></code> —  How the element handles crossorigin requests
     </dd><dd><code id="the-audio-element:attr-media-preload"><a href="#attr-media-preload">preload</a></code> —  Hints how much buffering the <a href="#media-resource" id="the-audio-element:media-resource">media resource</a> will likely need
     </dd><dd><code id="the-audio-element:attr-media-autoplay"><a href="#attr-media-autoplay">autoplay</a></code> —  Hint that the <a href="#media-resource" id="the-audio-element:media-resource-2">media resource</a> can be started automatically when the page is loaded
     </dd><dd><code id="the-audio-element:attr-media-loop"><a href="#attr-media-loop">loop</a></code> —  Whether to loop the <a href="#media-resource" id="the-audio-element:media-resource-3">media resource</a>
     </dd><dd><code id="the-audio-element:attr-media-muted"><a href="#attr-media-muted">muted</a></code> —  Whether to mute the <a href="#media-resource" id="the-audio-element:media-resource-4">media resource</a> by default
     </dd><dd><code id="the-audio-element:attr-media-controls-3"><a href="#attr-media-controls">controls</a></code> —  Show user agent controls
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-audio-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-audio">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-audio">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-audio-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="the-audio-element:legacyfactoryfunction" href="https://webidl.spec.whatwg.org/#LegacyFactoryFunction" data-x-internal="legacyfactoryfunction"><c- g="">LegacyFactoryFunction</c-></a>=<a href="#dom-audio" id="the-audio-element:dom-audio"><c- n="">Audio</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">src</c->)]
<c- b="">interface</c-> <dfn id="htmlaudioelement" data-dfn-type="interface"><c- g="">HTMLAudioElement</c-></dfn> : <a href="#htmlmediaelement" id="the-audio-element:htmlmediaelement"><c- n="">HTMLMediaElement</c-></a> {
  [<a href="#htmlconstructor" id="the-audio-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();
};</code></pre>
   </dd></dl>

  <p>An <code id="the-audio-element:the-audio-element"><a href="#the-audio-element">audio</a></code> element <a href="#represents" id="the-audio-element:represents">represents</a> a sound or audio stream.</p>

  

  <p>Content may be provided inside the <code id="the-audio-element:the-audio-element-2"><a href="#the-audio-element">audio</a></code> element. User agents
  should not show this content to the user; it is intended for older web browsers which do
  not support <code id="the-audio-element:the-audio-element-3"><a href="#the-audio-element">audio</a></code>, so that text can be shown to the users of these older browsers
  informing them of how to access the audio contents.</p>

  <p class="note">In particular, this content is not intended to address accessibility concerns. To
  make audio content accessible to the deaf or to those with other physical or cognitive
  disabilities, a variety of features are available. If captions or a sign language video are
  available, the <code id="the-audio-element:the-video-element"><a href="#the-video-element">video</a></code> element can be used instead of the <code id="the-audio-element:the-audio-element-4"><a href="#the-audio-element">audio</a></code> element to
  play the audio, allowing users to enable the visual alternatives. Chapter titles can be provided
  to aid navigation, using the <code id="the-audio-element:the-track-element-3"><a href="#the-track-element">track</a></code> element and a <a id="the-audio-element:webvtt-file" href="https://w3c.github.io/webvtt/#webvtt-file" data-x-internal="webvtt-file">WebVTT file</a>. And,
  naturally, transcripts or other textual alternatives can be provided by simply linking to them in
  the prose near the <code id="the-audio-element:the-audio-element-5"><a href="#the-audio-element">audio</a></code> element. <a href="#refsWEBVTT">[WEBVTT]</a></p>

  <p>The <code id="the-audio-element:the-audio-element-6"><a href="#the-audio-element">audio</a></code> element is a <a href="#media-element" id="the-audio-element:media-element-3">media element</a> whose <a href="#media-data" id="the-audio-element:media-data">media data</a> is
  ostensibly audio data.</p>

  <p>The <code id="the-audio-element:attr-media-src-4"><a href="#attr-media-src">src</a></code>, <code id="the-audio-element:attr-media-crossorigin-2"><a href="#attr-media-crossorigin">crossorigin</a></code>,
  <code id="the-audio-element:attr-media-preload-2"><a href="#attr-media-preload">preload</a></code>, <code id="the-audio-element:attr-media-autoplay-2"><a href="#attr-media-autoplay">autoplay</a></code>,
  <code id="the-audio-element:attr-media-loop-2"><a href="#attr-media-loop">loop</a></code>, <code id="the-audio-element:attr-media-muted-2"><a href="#attr-media-muted">muted</a></code>, and <code id="the-audio-element:attr-media-controls-4"><a href="#attr-media-controls">controls</a></code> attributes are <a href="#media-element-attributes" id="the-audio-element:media-element-attributes">the attributes common to all media elements</a>.</p>

  <dl class="domintro"><dt><code><var>audio</var> = new <a href="#dom-audio" id="dom-audio-dev">Audio</a>([ <var>url</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement/Audio" title="The Audio() constructor creates and returns a new HTMLAudioElement which can be either attached to a document for the user to interact with and/or listen to, or can be used offscreen to manage and play audio.">HTMLAudioElement/Audio</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a new <code id="the-audio-element:the-audio-element-7"><a href="#the-audio-element">audio</a></code> element, with the <code id="the-audio-element:attr-media-src-5"><a href="#attr-media-src">src</a></code>
    attribute set to the value passed in the argument, if applicable.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>A legacy factory function is provided for creating <code id="the-audio-element:htmlaudioelement"><a href="#htmlaudioelement">HTMLAudioElement</a></code> objects (in
  addition to the factory methods from DOM such as <code id="the-audio-element:dom-document-createelement"><a data-x-internal="dom-document-createelement" href="https://dom.spec.whatwg.org/#dom-document-createelement">createElement()</a></code>): <dfn id="dom-audio"><code>Audio(<var>src</var>)</code></dfn>. When invoked, the legacy factory function
  must perform the following steps:</p>

  <ol><li><p>Let <var>document</var> be the <a href="#current-global-object" id="the-audio-element:current-global-object">current global object</a>'s <a href="#concept-document-window" id="the-audio-element:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>Let <var>audio</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-audio-element:create-an-element" data-x-internal="create-an-element">creating an
   element</a> given <var>document</var>, "<code>audio</code>", and the <a id="the-audio-element:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
   namespace</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="the-audio-element:concept-element-attributes-set-value" data-x-internal="concept-element-attributes-set-value">Set an attribute value</a> for
   <var>audio</var> using "<code id="the-audio-element:attr-media-preload-3"><a href="#attr-media-preload">preload</a></code>" and "<code id="the-audio-element:attr-media-preload-auto"><a href="#attr-media-preload-auto">auto</a></code>".</p></li><li><p>If <var>src</var> is given, then <a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="the-audio-element:concept-element-attributes-set-value-2" data-x-internal="concept-element-attributes-set-value">set
   an attribute value</a> for <var>audio</var> using "<code id="the-audio-element:attr-media-src-6"><a href="#attr-media-src">src</a></code>"
   and <var>src</var>. (This will <a href="#concept-media-load-algorithm-at-creation">cause the user
   agent to invoke</a> the object's <a href="#concept-media-load-algorithm" id="the-audio-element:concept-media-load-algorithm">resource selection
   algorithm</a> before returning.)</p></li><li><p>Return <var>audio</var>.</p></li></ol>
  </div>

  



  



  <h4 id="the-track-element"><span class="secno">4.8.10</span> The <dfn data-dfn-type="element"><code>track</code></dfn> element<a href="#the-track-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track" title="The <track> HTML element is used as a child of the media elements, <audio> and <video>. It lets you specify timed text tracks (or time-based data), for example to automatically handle subtitles. The tracks are formatted in WebVTT format (.vtt files) — Web Video Text Tracks.">Element/track</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>25+</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement" title="The HTMLTrackElement interface represents an HTML <track> element within the DOM. This element can be used as a child of either <audio> or <video> to specify a text track containing information such as closed captions or subtitles.">HTMLTrackElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement/src" title="The HTMLTrackElement.src property reflects the value of the <track> element's src attribute, which indicates the URL of the text track's data.">HTMLTrackElement/src</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-track-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-track-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <a href="#media-element" id="the-track-element:media-element">media element</a>, before any <a href="#flow-content-2" id="the-track-element:flow-content-2">flow content</a>.</dd><dt><a href="#concept-element-content-model" id="the-track-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-track-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-track-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-track-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-track-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-track-element:global-attributes">Global attributes</a></dd><dd><code id="the-track-element:attr-track-kind"><a href="#attr-track-kind">kind</a></code> —  The type of text track
     </dd><dd><code id="the-track-element:attr-track-src"><a href="#attr-track-src">src</a></code> —  Address of the resource
     </dd><dd><code id="the-track-element:attr-track-srclang"><a href="#attr-track-srclang">srclang</a></code> —  Language of the text track
     </dd><dd><code id="the-track-element:attr-track-label"><a href="#attr-track-label">label</a></code> —  User-visible label
     </dd><dd><code id="the-track-element:attr-track-default"><a href="#attr-track-default">default</a></code> —  Enable the track if no other <a href="#text-track" id="the-track-element:text-track">text track</a> is more suitable
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-track-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-track">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-track">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-track-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltrackelement" data-dfn-type="interface"><c- g="">HTMLTrackElement</c-></dfn> : <a href="#htmlelement" id="the-track-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-track-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-track-element:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-track-kind" id="the-track-element:dom-track-kind"><c- g="">kind</c-></a>;
  [<a href="#cereactions" id="the-track-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-track-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLTrackElement" id="dom-track-src" data-dfn-type="attribute"><c- g="">src</c-></dfn>;
  [<a href="#cereactions" id="the-track-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-track-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTrackElement" id="dom-track-srclang" data-dfn-type="attribute"><c- g="">srclang</c-></dfn>;
  [<a href="#cereactions" id="the-track-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-track-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTrackElement" id="dom-track-label" data-dfn-type="attribute"><c- g="">label</c-></dfn>;
  [<a href="#cereactions" id="the-track-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-track-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLTrackElement" id="dom-track-default" data-dfn-type="attribute"><c- g="">default</c-></dfn>;

  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-track-none" id="the-track-element:dom-track-none"><c- g="">NONE</c-></a> = 0;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-track-loading" id="the-track-element:dom-track-loading"><c- g="">LOADING</c-></a> = 1;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-track-loaded" id="the-track-element:dom-track-loaded"><c- g="">LOADED</c-></a> = 2;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-track-error" id="the-track-element:dom-track-error"><c- g="">ERROR</c-></a> = 3;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-track-readystate" id="the-track-element:dom-track-readystate"><c- g="">readyState</c-></a>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#texttrack" id="the-track-element:texttrack"><c- n="">TextTrack</c-></a> <a href="#dom-track-track" id="the-track-element:dom-track-track"><c- g="">track</c-></a>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-track-element:the-track-element"><a href="#the-track-element">track</a></code> element allows authors to specify explicit external timed <a href="#text-track" id="the-track-element:text-track-2">text tracks</a> for <a href="#media-element" id="the-track-element:media-element-2">media elements</a>. It
  does not <a href="#represents" id="the-track-element:represents">represent</a> anything on its own.</p>

  <p>The <dfn data-dfn-for="track" id="attr-track-kind" data-dfn-type="element-attr"><code>kind</code></dfn> attribute is
  an <a href="#enumerated-attribute" id="the-track-element:enumerated-attribute">enumerated attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="track/kind" id="attr-track-kind-keyword-subtitles" data-dfn-type="attr-value"><code>subtitles</code></dfn>
     </td><td><dfn id="attr-track-kind-subtitles">Subtitles</dfn>
     </td><td>
      Transcription or translation of the dialogue, suitable for when the sound is available but not understood (e.g. because the user does not understand the language of the <a href="#media-resource" id="the-track-element:media-resource">media resource</a>'s audio track).
      Overlaid on the video.
    </td></tr><tr><td><dfn data-dfn-for="track/kind" id="attr-track-kind-keyword-captions" data-dfn-type="attr-value"><code>captions</code></dfn>
     </td><td><dfn id="attr-track-kind-captions">Captions</dfn>
     </td><td>
      Transcription or translation of the dialogue, sound effects, relevant musical cues, and other relevant audio information, suitable for when sound is unavailable or not clearly audible (e.g. because it is muted, drowned-out by ambient noise, or because the user is deaf).
      Overlaid on the video; labeled as appropriate for the hard-of-hearing.
    </td></tr><tr><td><dfn data-dfn-for="track/kind" id="attr-track-kind-keyword-descriptions" data-dfn-type="attr-value"><code>descriptions</code></dfn>
     </td><td><dfn id="attr-track-kind-descriptions">Descriptions</dfn>
     </td><td>
      Textual descriptions of the video component of the <a href="#media-resource" id="the-track-element:media-resource-2">media resource</a>, intended for audio synthesis when the visual component is obscured, unavailable, or not usable (e.g. because the user is interacting with the application without a screen while driving, or because the user is blind).
      Synthesized as audio.
    </td></tr><tr><td><dfn data-dfn-for="track/kind" id="attr-track-kind-keyword-chapters" data-dfn-type="attr-value"><code>chapters</code></dfn>
     </td><td><dfn id="attr-track-kind-chapters">Chapters metadata</dfn>
     </td><td rowspan="2">
      Tracks intended for use from script.
      Not displayed by the user agent.
    </td></tr><tr><td><dfn data-dfn-for="track/kind" id="attr-track-kind-keyword-metadata" data-dfn-type="attr-value"><code>metadata</code></dfn>
     </td><td><dfn id="attr-track-kind-metadata">Metadata</dfn>
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-track-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> is the <a href="#attr-track-kind-subtitles" id="the-track-element:attr-track-kind-subtitles">subtitles</a> state, and its <i id="the-track-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> is the <a href="#attr-track-kind-metadata" id="the-track-element:attr-track-kind-metadata">metadata</a>
  state.</p>
  </div>

  <p>The <dfn data-dfn-for="track" id="attr-track-src" data-dfn-type="element-attr"><code>src</code></dfn> attribute
  gives the <a id="the-track-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the text track data. The value must be a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="the-track-element:valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL
  potentially surrounded by spaces</a>. This attribute must be present.</p>

  

  <p>The element has an associated <dfn id="track-url">track URL</dfn> (a string), initially the empty string.</p>

  <div data-algorithm="">
  <p>When the element's <code id="the-track-element:attr-track-src-2"><a href="#attr-track-src">src</a></code> attribute is set, run these steps:

  </p><ol><li><p>Let <var>trackURL</var> be failure.</p></li><li><p>Let <var>value</var> be the element's <code id="the-track-element:attr-track-src-3"><a href="#attr-track-src">src</a></code> attribute
   value.</p></li><li><p>If <var>value</var> is not the empty string, then set <var>trackURL</var> to the result of
   <a href="#encoding-parsing-and-serializing-a-url" id="the-track-element:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing a URL</a> given <var>value</var>, relative to the
   element's <a id="the-track-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>Set the element's <a href="#track-url" id="the-track-element:track-url">track URL</a> to <var>trackURL</var> if it is not failure;
   otherwise to the empty string.</p></li></ol>
  </div>

  

  <p>If the element's <a href="#track-url" id="the-track-element:track-url-2">track URL</a> identifies a WebVTT resource, and the element's <code id="the-track-element:attr-track-kind-2"><a href="#attr-track-kind">kind</a></code> attribute is not in the <a href="#attr-track-kind-chapters" id="the-track-element:attr-track-kind-chapters">chapters metadata</a> or <a href="#attr-track-kind-metadata" id="the-track-element:attr-track-kind-metadata-2">metadata</a> state, then the WebVTT file must be a
  <a id="the-track-element:webvtt-file-using-cue-text" href="https://w3c.github.io/webvtt/#webvtt-file-using-cue-text" data-x-internal="webvtt-file-using-cue-text">WebVTT file using cue text</a>. <a href="#refsWEBVTT">[WEBVTT]</a></p>

  <p>The <dfn data-dfn-for="track" id="attr-track-srclang" data-dfn-type="element-attr"><code>srclang</code></dfn>
  attribute gives the language of the text track data. The value must be a valid BCP 47 language
  tag. This attribute must be present if the element's <code id="the-track-element:attr-track-kind-3"><a href="#attr-track-kind">kind</a></code>
  attribute is in the <a href="#attr-track-kind-subtitles" id="the-track-element:attr-track-kind-subtitles-2">subtitles</a> state.
  <a href="#refsBCP47">[BCP47]</a></p>

  

  <div data-algorithm="">
  <p>If the element has a <code id="the-track-element:attr-track-srclang-2"><a href="#attr-track-srclang">srclang</a></code> attribute whose value is
  not the empty string, then the element's <dfn id="track-language">track language</dfn> is the value of the attribute.
  Otherwise, the element has no <a href="#track-language" id="the-track-element:track-language">track language</a>.</p>
  </div>

  

  <p>The <dfn data-dfn-for="track" id="attr-track-label" data-dfn-type="element-attr"><code>label</code></dfn> attribute
  gives a user-readable title for the track. This title is used by user agents when listing <a href="#attr-track-kind-subtitles" id="the-track-element:attr-track-kind-subtitles-3">subtitle</a>, <a href="#attr-track-kind-captions" id="the-track-element:attr-track-kind-captions">caption</a>, and <a href="#attr-track-kind-descriptions" id="the-track-element:attr-track-kind-descriptions">audio description</a> tracks in their user interface.</p>

  <p>The value of the <code id="the-track-element:attr-track-label-2"><a href="#attr-track-label">label</a></code> attribute, if the attribute is
  present, must not be the empty string. Furthermore, there must not be two <code id="the-track-element:the-track-element-2"><a href="#the-track-element">track</a></code>
  element children of the same <a href="#media-element" id="the-track-element:media-element-3">media element</a> whose <code id="the-track-element:attr-track-kind-4"><a href="#attr-track-kind">kind</a></code> attributes are in the same state, whose <code id="the-track-element:attr-track-srclang-3"><a href="#attr-track-srclang">srclang</a></code> attributes are both missing or have values that
  represent the same language, and whose <code id="the-track-element:attr-track-label-3"><a href="#attr-track-label">label</a></code> attributes are
  again both missing or both have the same value.</p>

  

  <div data-algorithm="">
  <p>If the element has a <code id="the-track-element:attr-track-label-4"><a href="#attr-track-label">label</a></code> attribute whose value is not
  the empty string, then the element's <dfn id="track-label">track label</dfn> is the value of the attribute.
  Otherwise, the element's <a href="#track-label" id="the-track-element:track-label">track label</a> is an empty string.</p>
  </div>

  

  <p>The <dfn data-dfn-for="track" id="attr-track-default" data-dfn-type="element-attr"><code>default</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-track-element:boolean-attribute">boolean attribute</a>, which, if specified, indicates that the track is to
  be enabled if the user's preferences do not indicate that another track would be more
  appropriate.</p>

  <p>Each <a href="#media-element" id="the-track-element:media-element-4">media element</a> must have no more than one <code id="the-track-element:the-track-element-3"><a href="#the-track-element">track</a></code> element child
  whose <code id="the-track-element:attr-track-kind-5"><a href="#attr-track-kind">kind</a></code> attribute is in the <a href="#attr-track-kind-subtitles" id="the-track-element:attr-track-kind-subtitles-4">subtitles</a> or <a href="#attr-track-kind-captions" id="the-track-element:attr-track-kind-captions-2">captions</a> state and whose <code id="the-track-element:attr-track-default-2"><a href="#attr-track-default">default</a></code> attribute is specified.</p>

  <p>Each <a href="#media-element" id="the-track-element:media-element-5">media element</a> must have no more than one <code id="the-track-element:the-track-element-4"><a href="#the-track-element">track</a></code> element child
  whose <code id="the-track-element:attr-track-kind-6"><a href="#attr-track-kind">kind</a></code> attribute is in the <a href="#attr-track-kind-descriptions" id="the-track-element:attr-track-kind-descriptions-2">description</a> state and whose <code id="the-track-element:attr-track-default-3"><a href="#attr-track-default">default</a></code> attribute is specified.</p>

  <p>Each <a href="#media-element" id="the-track-element:media-element-6">media element</a> must have no more than one <code id="the-track-element:the-track-element-5"><a href="#the-track-element">track</a></code> element child
  whose <code id="the-track-element:attr-track-kind-7"><a href="#attr-track-kind">kind</a></code> attribute is in the <a href="#attr-track-kind-chapters" id="the-track-element:attr-track-kind-chapters-2">chapters metadata</a> state and whose <code id="the-track-element:attr-track-default-4"><a href="#attr-track-default">default</a></code> attribute is specified.</p>

  <p class="note">There is no limit on the number of <code id="the-track-element:the-track-element-6"><a href="#the-track-element">track</a></code> elements whose <code id="the-track-element:attr-track-kind-8"><a href="#attr-track-kind">kind</a></code> attribute is in the <a href="#attr-track-kind-metadata" id="the-track-element:attr-track-kind-metadata-3">metadata</a> state and whose <code id="the-track-element:attr-track-default-5"><a href="#attr-track-default">default</a></code> attribute is specified.</p>

  <dl class="domintro"><dt><code><var>track</var>.<a href="#dom-track-readystate" id="dom-track-readystate-dev">readyState</a></code></dt><dd>
    <p>Returns the <a href="#text-track-readiness-state" id="the-track-element:text-track-readiness-state">text track readiness state</a>, represented by a number from the
    following list:</p>
    <dl><dt><code><var>track</var>.<a href="#dom-track-none" id="dom-track-none-dev">NONE</a> (0)</code></dt><dd><p>The <a href="#text-track-not-loaded" id="the-track-element:text-track-not-loaded">text track not loaded</a> state.</p></dd><dt><code><var>track</var>.<a href="#dom-track-loading" id="dom-track-loading-dev">LOADING</a> (1)</code></dt><dd><p>The <a href="#text-track-loading" id="the-track-element:text-track-loading">text track loading</a> state.</p></dd><dt><code><var>track</var>.<a href="#dom-track-loaded" id="dom-track-loaded-dev">LOADED</a> (2)</code></dt><dd><p>The <a href="#text-track-loaded" id="the-track-element:text-track-loaded">text track loaded</a> state.</p></dd><dt><code><var>track</var>.<a href="#dom-track-error" id="dom-track-error-dev">ERROR</a> (3)</code></dt><dd><p>The <a href="#text-track-failed-to-load" id="the-track-element:text-track-failed-to-load">text track failed to load</a> state.</p></dd></dl>
   </dd><dt><code><var>track</var>.<a href="#dom-track-track" id="dom-track-track-dev">track</a></code></dt><dd>
    <p>Returns the <code id="the-track-element:texttrack-2"><a href="#texttrack">TextTrack</a></code> object corresponding to the <a href="#text-track" id="the-track-element:text-track-3">text track</a> of the
    <code id="the-track-element:the-track-element-7"><a href="#the-track-element">track</a></code> element.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTrackElement" id="dom-track-readystate" data-dfn-type="attribute"><code>readyState</code></dfn> attribute must return the numeric value
  corresponding to the <a href="#text-track-readiness-state" id="the-track-element:text-track-readiness-state-2">text track readiness state</a> of the <code id="the-track-element:the-track-element-8"><a href="#the-track-element">track</a></code> element's
  <a href="#text-track" id="the-track-element:text-track-4">text track</a>, as defined by the following list:</p>

  <dl><dt><dfn data-dfn-for="HTMLTrackElement" id="dom-track-none" data-dfn-type="const"><code>NONE</code></dfn> (numeric value 0)</dt><dd>The <a href="#text-track-not-loaded" id="the-track-element:text-track-not-loaded-2">text track not loaded</a> state.</dd><dt><dfn data-dfn-for="HTMLTrackElement" id="dom-track-loading" data-dfn-type="const"><code>LOADING</code></dfn> (numeric value 1)</dt><dd>The <a href="#text-track-loading" id="the-track-element:text-track-loading-2">text track loading</a> state.</dd><dt><dfn data-dfn-for="HTMLTrackElement" id="dom-track-loaded" data-dfn-type="const"><code>LOADED</code></dfn> (numeric value 2)</dt><dd>The <a href="#text-track-loaded" id="the-track-element:text-track-loaded-2">text track loaded</a> state.</dd><dt><dfn data-dfn-for="HTMLTrackElement" id="dom-track-error" data-dfn-type="const"><code>ERROR</code></dfn> (numeric value 3)</dt><dd>The <a href="#text-track-failed-to-load" id="the-track-element:text-track-failed-to-load-2">text track failed to load</a> state.</dd></dl>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTrackElement" id="dom-track-track" data-dfn-type="attribute"><code>track</code></dfn> IDL
  attribute must, on getting, return the <code id="the-track-element:the-track-element-9"><a href="#the-track-element">track</a></code> element's <a href="#text-track" id="the-track-element:text-track-5">text track</a>'s
  corresponding <code id="the-track-element:texttrack-3"><a href="#texttrack">TextTrack</a></code> object.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTrackElement" id="dom-track-kind" data-dfn-type="attribute"><code>kind</code></dfn> IDL
  attribute must <a href="#reflect" id="the-track-element:reflect">reflect</a> the content attribute of the same name, <a href="#limited-to-only-known-values" id="the-track-element:limited-to-only-known-values">limited to only
  known values</a>.</p>
  </div>

  

  <div class="example">

   <p>This video has subtitles in several languages:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">video</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"brave.webm"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">track</c-> <c- e="">kind</c-><c- o="">=</c-><c- s="">subtitles</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">brave.en.vtt</c-> <c- e="">srclang</c-><c- o="">=</c-><c- s="">en</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"English"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">track</c-> <c- e="">kind</c-><c- o="">=</c-><c- s="">captions</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">brave.en.hoh.vtt</c-> <c- e="">srclang</c-><c- o="">=</c-><c- s="">en</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"English for the Hard of Hearing"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">track</c-> <c- e="">kind</c-><c- o="">=</c-><c- s="">subtitles</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">brave.fr.vtt</c-> <c- e="">srclang</c-><c- o="">=</c-><c- s="">fr</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">fr</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Français"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">track</c-> <c- e="">kind</c-><c- o="">=</c-><c- s="">subtitles</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">brave.de.vtt</c-> <c- e="">srclang</c-><c- o="">=</c-><c- s="">de</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">de</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Deutsch"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">video</c-><c- p="">&gt;</c-></code></pre>

   <p>(The <code id="the-track-element:attr-lang"><a href="#attr-lang">lang</a></code> attributes on the last two describe the language of
   the <code id="the-track-element:attr-track-label-5"><a href="#attr-track-label">label</a></code> attribute, not the language of the subtitles
   themselves. The language of the subtitles is given by the <code id="the-track-element:attr-track-srclang-4"><a href="#attr-track-srclang">srclang</a></code> attribute.)</p>

  </div>

  <h4 id="media-elements"><span class="secno">4.8.11</span> Media elements<a href="#media-elements" class="self-link"></a></h4>

  <p><a href="#htmlmediaelement" id="media-elements:htmlmediaelement">HTMLMediaElement</a> objects (<code id="media-elements:the-audio-element"><a href="#the-audio-element">audio</a></code> and <code id="media-elements:the-video-element"><a href="#the-video-element">video</a></code>, in this
  specification) are simply known as <dfn id="media-element" data-lt="media element" data-export="">media elements</dfn>.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement" title="The HTMLMediaElement interface adds to HTMLElement the properties and methods needed to support basic media-related capabilities that are common to audio and video.">HTMLMediaElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/src" title="The HTMLMediaElement.src property reflects the value of the HTML media element's src attribute, which indicates the URL of a media resource to use in the element.">HTMLMediaElement/src</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/autoplay" title="The HTMLMediaElement.autoplay property reflects the autoplay HTML attribute, indicating whether playback should automatically begin as soon as enough media is available to do so without interruption.">HTMLMediaElement/autoplay</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loop" title="The HTMLMediaElement.loop property reflects the loop HTML attribute, which controls whether the media element should start over when it reaches the end.">HTMLMediaElement/loop</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>11+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/controls" title="The HTMLMediaElement.controls property reflects the controls HTML attribute, which controls whether user interface controls for playing the media item will be displayed.">HTMLMediaElement/controls</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/defaultMuted" title="The HTMLMediaElement.defaultMuted property reflects the muted HTML attribute, which indicates whether the media element's audio output should be muted by default. This property has no dynamic effect. To mute and unmute the audio output, use the muted property.">HTMLMediaElement/defaultMuted</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>11+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>15+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><pre><code class="idl"><c- b="">enum</c-> <dfn id="canplaytyperesult" data-dfn-type="enum"><c- g="">CanPlayTypeResult</c-></dfn> { <c- s="">""</c-> /* <a href="#dom-canplaytyperesult-nil" id="media-elements:dom-canplaytyperesult-nil">empty string</a> */, <c- s="">"</c-><a href="#dom-canplaytyperesult-maybe" id="media-elements:dom-canplaytyperesult-maybe"><c- s="">maybe</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-canplaytyperesult-probably" id="media-elements:dom-canplaytyperesult-probably"><c- s="">probably</c-></a><c- s="">"</c-> };
<c- b="">typedef</c-> (<a id="media-elements:mediastream" href="https://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-mediastream" data-x-internal="mediastream"><c- n="">MediaStream</c-></a> <c- b="">or</c-> <a id="media-elements:mediasource" href="https://w3c.github.io/media-source/#idl-def-mediasource" data-x-internal="mediasource"><c- n="">MediaSource</c-></a> <c- b="">or</c-> <a id="media-elements:blob" href="https://w3c.github.io/FileAPI/#dfn-Blob" data-x-internal="blob"><c- n="">Blob</c-></a>) <dfn id="mediaprovider" data-dfn-type="typedef"><c- g="">MediaProvider</c-></dfn>;

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlmediaelement" data-dfn-type="interface"><c- g="">HTMLMediaElement</c-></dfn> : <a href="#htmlelement" id="media-elements:htmlelement"><c- n="">HTMLElement</c-></a> {

  // error state
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#mediaerror" id="media-elements:mediaerror"><c- n="">MediaError</c-></a>? <a href="#dom-media-error" id="media-elements:dom-media-error"><c- g="">error</c-></a>;

  // network state
  [<a href="#cereactions" id="media-elements:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="media-elements:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLMediaElement" id="dom-media-src" data-dfn-type="attribute"><c- g="">src</c-></dfn>;
  <c- b="">attribute</c-> <a href="#mediaprovider" id="media-elements:mediaprovider"><c- n="">MediaProvider</c-></a>? <a href="#dom-media-srcobject" id="media-elements:dom-media-srcobject"><c- g="">srcObject</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-media-currentsrc" id="media-elements:dom-media-currentsrc"><c- g="">currentSrc</c-></a>;
  [<a href="#cereactions" id="media-elements:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-media-crossorigin" id="media-elements:dom-media-crossorigin"><c- g="">crossOrigin</c-></a>;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-network_empty" id="media-elements:dom-media-network_empty"><c- g="">NETWORK_EMPTY</c-></a> = 0;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-network_idle" id="media-elements:dom-media-network_idle"><c- g="">NETWORK_IDLE</c-></a> = 1;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-network_loading" id="media-elements:dom-media-network_loading"><c- g="">NETWORK_LOADING</c-></a> = 2;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-network_no_source" id="media-elements:dom-media-network_no_source"><c- g="">NETWORK_NO_SOURCE</c-></a> = 3;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-networkstate" id="media-elements:dom-media-networkstate"><c- g="">networkState</c-></a>;
  [<a href="#cereactions" id="media-elements:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-media-preload" id="media-elements:dom-media-preload"><c- g="">preload</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#timeranges" id="media-elements:timeranges"><c- n="">TimeRanges</c-></a> <a href="#dom-media-buffered" id="media-elements:dom-media-buffered"><c- g="">buffered</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-media-load" id="media-elements:dom-media-load"><c- g="">load</c-></a>();
  <a href="#canplaytyperesult" id="media-elements:canplaytyperesult"><c- n="">CanPlayTypeResult</c-></a> <a href="#dom-navigator-canplaytype" id="media-elements:dom-navigator-canplaytype"><c- g="">canPlayType</c-></a>(<c- b="">DOMString</c-> <c- g="">type</c->);

  // ready state
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-have_nothing" id="media-elements:dom-media-have_nothing"><c- g="">HAVE_NOTHING</c-></a> = 0;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-have_metadata" id="media-elements:dom-media-have_metadata"><c- g="">HAVE_METADATA</c-></a> = 1;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-have_current_data" id="media-elements:dom-media-have_current_data"><c- g="">HAVE_CURRENT_DATA</c-></a> = 2;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-have_future_data" id="media-elements:dom-media-have_future_data"><c- g="">HAVE_FUTURE_DATA</c-></a> = 3;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-have_enough_data" id="media-elements:dom-media-have_enough_data"><c- g="">HAVE_ENOUGH_DATA</c-></a> = 4;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-media-readystate" id="media-elements:dom-media-readystate"><c- g="">readyState</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-media-seeking" id="media-elements:dom-media-seeking"><c- g="">seeking</c-></a>;

  // playback state
  <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-media-currenttime" id="media-elements:dom-media-currenttime"><c- g="">currentTime</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-media-fastseek" id="media-elements:dom-media-fastseek"><c- g="">fastSeek</c-></a>(<c- b="">double</c-> <c- g="">time</c->);
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-media-duration" id="media-elements:dom-media-duration"><c- g="">duration</c-></a>;
  <a href="https://webidl.spec.whatwg.org/#idl-object" id="media-elements:idl-object" data-x-internal="idl-object"><c- b="">object</c-></a> <a href="#dom-media-getstartdate" id="media-elements:dom-media-getstartdate"><c- g="">getStartDate</c-></a>();
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-media-paused" id="media-elements:dom-media-paused"><c- g="">paused</c-></a>;
  <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-media-defaultplaybackrate" id="media-elements:dom-media-defaultplaybackrate"><c- g="">defaultPlaybackRate</c-></a>;
  <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-media-playbackrate" id="media-elements:dom-media-playbackrate"><c- g="">playbackRate</c-></a>;
  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-media-preservespitch" id="media-elements:dom-media-preservespitch"><c- g="">preservesPitch</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#timeranges" id="media-elements:timeranges-2"><c- n="">TimeRanges</c-></a> <a href="#dom-media-played" id="media-elements:dom-media-played"><c- g="">played</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#timeranges" id="media-elements:timeranges-3"><c- n="">TimeRanges</c-></a> <a href="#dom-media-seekable" id="media-elements:dom-media-seekable"><c- g="">seekable</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-media-ended" id="media-elements:dom-media-ended"><c- g="">ended</c-></a>;
  [<a href="#cereactions" id="media-elements:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="media-elements:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLMediaElement" id="dom-media-autoplay" data-dfn-type="attribute"><c- g="">autoplay</c-></dfn>;
  [<a href="#cereactions" id="media-elements:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="media-elements:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLMediaElement" id="dom-media-loop" data-dfn-type="attribute"><c- g="">loop</c-></dfn>;
  <a href="https://webidl.spec.whatwg.org/#idl-promise" id="media-elements:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<c- b="">undefined</c->&gt; <a href="#dom-media-play" id="media-elements:dom-media-play"><c- g="">play</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-media-pause" id="media-elements:dom-media-pause"><c- g="">pause</c-></a>();

  // controls
  [<a href="#cereactions" id="media-elements:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="media-elements:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLMediaElement" id="dom-media-controls" data-dfn-type="attribute"><c- g="">controls</c-></dfn>;
  <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-media-volume" id="media-elements:dom-media-volume"><c- g="">volume</c-></a>;
  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-media-muted" id="media-elements:dom-media-muted"><c- g="">muted</c-></a>;
  [<a href="#cereactions" id="media-elements:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="media-elements:xattr-reflect-4">Reflect</a>="<a href="#attr-media-muted" id="media-elements:attr-media-muted">muted</a>"] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLMediaElement" id="dom-media-defaultmuted" data-dfn-type="attribute"><c- g="">defaultMuted</c-></dfn>;

  // tracks
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#audiotracklist" id="media-elements:audiotracklist"><c- n="">AudioTrackList</c-></a> <a href="#dom-media-audiotracks" id="media-elements:dom-media-audiotracks"><c- g="">audioTracks</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#videotracklist" id="media-elements:videotracklist"><c- n="">VideoTrackList</c-></a> <a href="#dom-media-videotracks" id="media-elements:dom-media-videotracks"><c- g="">videoTracks</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#texttracklist" id="media-elements:texttracklist"><c- n="">TextTrackList</c-></a> <a href="#dom-media-texttracks" id="media-elements:dom-media-texttracks"><c- g="">textTracks</c-></a>;
  <a href="#texttrack" id="media-elements:texttrack"><c- n="">TextTrack</c-></a> <a href="#dom-media-addtexttrack" id="media-elements:dom-media-addtexttrack"><c- g="">addTextTrack</c-></a>(<a href="#texttrackkind" id="media-elements:texttrackkind"><c- n="">TextTrackKind</c-></a> <c- g="">kind</c->, <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">label</c-> = "", <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">language</c-> = "");
};</code></pre>

  <p>The <dfn id="media-element-attributes">media element attributes</dfn>, <code id="media-elements:attr-media-src"><a href="#attr-media-src">src</a></code>, <code id="media-elements:attr-media-crossorigin"><a href="#attr-media-crossorigin">crossorigin</a></code>, <code id="media-elements:attr-media-preload"><a href="#attr-media-preload">preload</a></code>, <code id="media-elements:attr-media-autoplay"><a href="#attr-media-autoplay">autoplay</a></code>,
  <code id="media-elements:attr-media-loop"><a href="#attr-media-loop">loop</a></code>, <code id="media-elements:attr-media-muted-2"><a href="#attr-media-muted">muted</a></code>, and
  <code id="media-elements:attr-media-controls"><a href="#attr-media-controls">controls</a></code>, apply to all <a href="#media-element" id="media-elements:media-element">media elements</a>. They are defined in this section.</p>

  

  <p><a href="#media-element" id="media-elements:media-element-2">Media elements</a> are used to present audio data, or video and
  audio data, to the user. This is referred to as <dfn data-dfn-for="HTMLMediaElement" id="media-data" data-export="">media data</dfn>
  in this section, since this section applies equally to <a href="#media-element" id="media-elements:media-element-3">media
  elements</a> for audio or for video.

  The term <dfn id="media-resource">media resource</dfn> is used to refer to the complete set of media data, e.g. the
  complete video file, or complete audio file.

  </p>

  <p>A <a href="#media-resource" id="media-elements:media-resource">media resource</a> has an associated
  <dfn id="media-resource-origin">origin</dfn>, which is either "<code>none</code>",
  "<code>multiple</code>", "<code>rewritten</code>", or an
  <a href="#concept-origin" id="media-elements:concept-origin">origin</a>. It is initially set to "<code>none</code>".</p>

  <p>A <a href="#media-resource" id="media-elements:media-resource-2">media resource</a> can have multiple audio and video tracks. For the purposes of a
  <a href="#media-element" id="media-elements:media-element-4">media element</a>, the video data of the <a href="#media-resource" id="media-elements:media-resource-3">media resource</a> is only that of the
  currently selected track (if any) as given by the element's <code id="media-elements:dom-media-videotracks-2"><a href="#dom-media-videotracks">videoTracks</a></code> attribute when the <a href="#event-loop" id="media-elements:event-loop">event loop</a> last
  reached <a href="#step1">step 1</a>, and the audio data of the <a href="#media-resource" id="media-elements:media-resource-4">media resource</a> is the result of mixing all
  the currently enabled tracks (if any) given by the element's <code id="media-elements:dom-media-audiotracks-2"><a href="#dom-media-audiotracks">audioTracks</a></code> attribute when the <a href="#event-loop" id="media-elements:event-loop-2">event loop</a> last
  reached <a href="#step1">step 1</a>.</p>

  <p class="note">Both <code id="media-elements:the-audio-element-2"><a href="#the-audio-element">audio</a></code> and <code id="media-elements:the-video-element-2"><a href="#the-video-element">video</a></code> elements can be used for both audio
  and video. The main difference between the two is simply that the <code id="media-elements:the-audio-element-3"><a href="#the-audio-element">audio</a></code> element has
  no playback area for visual content (such as video or captions), whereas the <code id="media-elements:the-video-element-3"><a href="#the-video-element">video</a></code>
  element does.</p>

  

  <p>Each <a href="#media-element" id="media-elements:media-element-5">media element</a> has a unique <dfn id="media-element-event-task-source">media element event task source</dfn>.</p>

  <div data-algorithm="">
  <p>To <dfn id="queue-a-media-element-task" data-export="">queue a media element task</dfn> with a <a href="#media-element" id="media-elements:media-element-6">media element</a>
  <var>element</var> and a series of steps <var>steps</var>, <a href="#queue-an-element-task" id="media-elements:queue-an-element-task">queue an element task</a> on
  the <a href="#media-element" id="media-elements:media-element-7">media element</a>'s <a href="#media-element-event-task-source" id="media-elements:media-element-event-task-source">media element event task source</a> given
  <var>element</var> and <var>steps</var>.</p>
  </div>

  



  <h5 id="error-codes"><span class="secno">4.8.11.1</span> Error codes<a href="#error-codes" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaError" title="The MediaError interface represents an error which occurred while handling media in an HTML media element based on HTMLMediaElement, such as <audio> or <video>.">MediaError</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-error" id="dom-media-error-dev">error</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/error" title="The HTMLMediaElement.error property is the MediaError object for the most recent error, or null if there has not been an error. When an error event is received by the element, you can determine details about what happened by examining this object.">HTMLMediaElement/error</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="error-codes:mediaerror"><a href="#mediaerror">MediaError</a></code> object representing the current error state of the
    element.</p>

    <p>Returns null if there is no error.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>All <a href="#media-element" id="error-codes:media-element">media elements</a> have an associated error status, which
  records the last error the element encountered since its <a href="#concept-media-load-algorithm" id="error-codes:concept-media-load-algorithm">resource selection algorithm</a> was last invoked. The
  <dfn data-dfn-for="HTMLMediaElement" id="dom-media-error" data-dfn-type="attribute"><code>error</code></dfn> attribute,
  on getting, must return the <code id="error-codes:mediaerror-2"><a href="#mediaerror">MediaError</a></code> object created for this last error, or null if
  there has not been an error.</p>
  </div>

  

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="mediaerror" data-dfn-type="interface"><c- g="">MediaError</c-></dfn> {
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-mediaerror-media_err_aborted" id="error-codes:dom-mediaerror-media_err_aborted"><c- g="">MEDIA_ERR_ABORTED</c-></a> = 1;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-mediaerror-media_err_network" id="error-codes:dom-mediaerror-media_err_network"><c- g="">MEDIA_ERR_NETWORK</c-></a> = 2;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-mediaerror-media_err_decode" id="error-codes:dom-mediaerror-media_err_decode"><c- g="">MEDIA_ERR_DECODE</c-></a> = 3;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-mediaerror-media_err_src_not_supported" id="error-codes:dom-mediaerror-media_err_src_not_supported"><c- g="">MEDIA_ERR_SRC_NOT_SUPPORTED</c-></a> = 4;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-mediaerror-code" id="error-codes:dom-mediaerror-code"><c- g="">code</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-mediaerror-message" id="error-codes:dom-mediaerror-message"><c- g="">message</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-error" id="error-codes:dom-media-error">error</a>.<a href="#dom-mediaerror-code" id="dom-mediaerror-code-dev">code</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaError/code" title="The read-only property MediaError.code returns a numeric value which represents the kind of error that occurred on a media element. To get a text string with specific diagnostic information, see MediaError.message.">MediaError/code</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the current error's error code, from the list below.</p></dd><dt><code><var>media</var>.<a href="#dom-media-error" id="error-codes:dom-media-error-2">error</a>.<a href="#dom-mediaerror-message" id="dom-mediaerror-message-dev">message</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaError/message" title="The read-only property MediaError.message returns a human-readable string offering specific diagnostic details related to the error described by the MediaError object, or an empty string (&quot;&quot;) if no diagnostic information can be determined or provided.">MediaError/message</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>52+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>59+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns a specific informative diagnostic message about the error condition encountered. The
    message and message format are not generally uniform across different user agents. If no such
    message is available, then the empty string is returned.</p>
   </dd></dl>

  

  <p>Every <code id="error-codes:mediaerror-3"><a href="#mediaerror">MediaError</a></code> object has a <dfn id="concept-mediaerror-message">message</dfn>, which is a string, and a <dfn id="concept-mediaerror-code">code</dfn>, which is one of the following:</p>

  

  <dl><dt><dfn data-dfn-for="MediaError" id="dom-mediaerror-media_err_aborted" data-dfn-type="const"><code>MEDIA_ERR_ABORTED</code></dfn> (numeric value 1)</dt><dd>The fetching process for the <a href="#media-resource" id="error-codes:media-resource">media resource</a> was aborted by the user agent at the
   user's request.</dd><dt><dfn data-dfn-for="MediaError" id="dom-mediaerror-media_err_network" data-dfn-type="const"><code>MEDIA_ERR_NETWORK</code></dfn> (numeric value 2)</dt><dd>A network error of some description caused the user agent to stop fetching the <a href="#media-resource" id="error-codes:media-resource-2">media
   resource</a>, after the resource was established to be usable.</dd><dt><dfn data-dfn-for="MediaError" id="dom-mediaerror-media_err_decode" data-dfn-type="const"><code>MEDIA_ERR_DECODE</code></dfn> (numeric value 3)</dt><dd>An error of some description occurred while decoding the <a href="#media-resource" id="error-codes:media-resource-3">media resource</a>, after
   the resource was established to be usable.</dd><dt><dfn data-dfn-for="MediaError" id="dom-mediaerror-media_err_src_not_supported" data-dfn-type="const"><code>MEDIA_ERR_SRC_NOT_SUPPORTED</code></dfn> (numeric value 4)</dt><dd>The <a href="#media-resource" id="error-codes:media-resource-4">media resource</a> indicated by the <code id="error-codes:attr-media-src"><a href="#attr-media-src">src</a></code>
   attribute or <a href="#assigned-media-provider-object" id="error-codes:assigned-media-provider-object">assigned media provider object</a> was not suitable.</dd></dl>

  

  <div data-algorithm="">
  <p>To <dfn id="creating-a-mediaerror" data-export="">create a <code>MediaError</code></dfn>, given an
  error code which is one of the above values, return a new <code id="error-codes:mediaerror-4"><a href="#mediaerror">MediaError</a></code> object whose
  <a href="#concept-mediaerror-code" id="error-codes:concept-mediaerror-code">code</a> is the given error code and whose <a href="#concept-mediaerror-message" id="error-codes:concept-mediaerror-message">message</a> is a string containing any details the user
  agent is able to supply about the cause of the error condition, or the empty string if the user
  agent is unable to supply such details. This message string must not contain only the information
  already available via the supplied error code; for example, it must not simply be a translation of
  the code into a string format. If no additional information is available beyond that provided by
  the error code, the <a href="#concept-mediaerror-message" id="error-codes:concept-mediaerror-message-2">message</a> must be set to the
  empty string.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MediaError" id="dom-mediaerror-code" data-dfn-type="attribute"><code>code</code></dfn>
  getter steps are to return <a id="error-codes:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-mediaerror-code" id="error-codes:concept-mediaerror-code-2">code</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MediaError" id="dom-mediaerror-message" data-dfn-type="attribute"><code>message</code></dfn>
  getter steps are to return <a id="error-codes:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-mediaerror-message" id="error-codes:concept-mediaerror-message-3">message</a>.</p>
  </div>

  




  <h5 id="location-of-the-media-resource"><span class="secno">4.8.11.2</span> Location of the media resource<a href="#location-of-the-media-resource" class="self-link"></a></h5>

  <p>The <dfn data-dfn-for="audio,video" id="attr-media-src" data-dfn-type="element-attr"><code>src</code></dfn> content
  attribute on <a href="#media-element" id="location-of-the-media-resource:media-element">media elements</a> gives the <a id="location-of-the-media-resource:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the
  media resource (video, audio) to show. The attribute, if present, must contain a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="location-of-the-media-resource:valid-non-empty-url-potentially-surrounded-by-spaces">valid
  non-empty URL potentially surrounded by spaces</a>.</p>

  <p>If the <code id="location-of-the-media-resource:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is specified on the <a href="#media-element" id="location-of-the-media-resource:media-element-2">media
  element</a>, then the <code id="location-of-the-media-resource:attr-media-src"><a href="#attr-media-src">src</a></code> attribute must also be
  specified.</p>

  <p>The <dfn data-dfn-for="audio,video" id="attr-media-crossorigin" data-dfn-type="element-attr"><code>crossorigin</code></dfn> content attribute on <a href="#media-element" id="location-of-the-media-resource:media-element-3">media elements</a> is a <a href="#cors-settings-attribute" id="location-of-the-media-resource:cors-settings-attribute">CORS settings attribute</a>.</p>

  

  <div data-algorithm="">
  <p id="concept-media-load-algorithm-at-creation">If a <a href="#media-element" id="location-of-the-media-resource:media-element-4">media element</a> is created with a
  <code id="location-of-the-media-resource:attr-media-src-2"><a href="#attr-media-src">src</a></code> attribute, the user agent must <a href="#immediately" id="location-of-the-media-resource:immediately">immediately</a> invoke the
  <a href="#media-element" id="location-of-the-media-resource:media-element-5">media element</a>'s <a href="#concept-media-load-algorithm" id="location-of-the-media-resource:concept-media-load-algorithm">resource selection
  algorithm</a>.</p>
  </div>

  <div data-algorithm="">
  <p>If a <code id="location-of-the-media-resource:attr-media-src-3"><a href="#attr-media-src">src</a></code> attribute of a <a href="#media-element" id="location-of-the-media-resource:media-element-6">media element</a> is set
  or changed, the user agent must invoke the <a href="#media-element" id="location-of-the-media-resource:media-element-7">media element</a>'s <a href="#media-element-load-algorithm" id="location-of-the-media-resource:media-element-load-algorithm">media element load
  algorithm</a>. (<em>Removing</em> the <code id="location-of-the-media-resource:attr-media-src-4"><a href="#attr-media-src">src</a></code> attribute does
  not do this, even if there are <code id="location-of-the-media-resource:the-source-element"><a href="#the-source-element">source</a></code> elements present.)</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/crossOrigin" title="The HTMLMediaElement.crossOrigin property is the CORS setting for this media element. See CORS settings attributes for details.">HTMLMediaElement/crossOrigin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>33+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-crossorigin" data-dfn-type="attribute"><code>crossOrigin</code></dfn> IDL attribute must <a href="#reflect" id="location-of-the-media-resource:reflect">reflect</a>
  the <code id="location-of-the-media-resource:attr-media-crossorigin"><a href="#attr-media-crossorigin">crossorigin</a></code> content attribute, <a href="#limited-to-only-known-values" id="location-of-the-media-resource:limited-to-only-known-values">limited to
  only known values</a>.</p>
  </div>

  

  <p>A <dfn id="media-provider-object">media provider object</dfn> is an object that can represent a <a href="#media-resource" id="location-of-the-media-resource:media-resource">media
  resource</a>, separate from a <a id="location-of-the-media-resource:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>. <code id="location-of-the-media-resource:mediastream"><a data-x-internal="mediastream" href="https://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-mediastream">MediaStream</a></code> objects,
  <code id="location-of-the-media-resource:mediasource"><a data-x-internal="mediasource" href="https://w3c.github.io/media-source/#idl-def-mediasource">MediaSource</a></code> objects, and <code id="location-of-the-media-resource:blob"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> objects are all <a href="#media-provider-object" id="location-of-the-media-resource:media-provider-object">media provider objects</a>.</p>

  

  <p>Each <a href="#media-element" id="location-of-the-media-resource:media-element-8">media element</a> can have an <dfn id="assigned-media-provider-object">assigned media provider object</dfn>, which is a
  <a href="#media-provider-object" id="location-of-the-media-resource:media-provider-object-2">media provider object</a>. When a <a href="#media-element" id="location-of-the-media-resource:media-element-9">media element</a> is created, it has no
  <a href="#assigned-media-provider-object" id="location-of-the-media-resource:assigned-media-provider-object">assigned media provider object</a>.</p>

  

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-srcobject" id="dom-media-srcobject-dev">srcObject</a> [ = <var>source</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject" title="The srcObject property of the HTMLMediaElement interface sets or returns the object which serves as the source of the media associated with the HTMLMediaElement.">HTMLMediaElement/srcObject</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Partial implementation.">🔰 42+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span title="Partial implementation.">🔰 108+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Partial implementation.">🔰 108+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Allows the <a href="#media-element" id="location-of-the-media-resource:media-element-10">media element</a> to be assigned a <a href="#media-provider-object" id="location-of-the-media-resource:media-provider-object-3">media provider
    object</a>.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-currentsrc" id="dom-media-currentsrc-dev">currentSrc</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentSrc" title="The HTMLMediaElement.currentSrc property contains the absolute URL of the chosen media resource. This could happen, for example, if the web server selects a media file based on the resolution of the user's display. The value is an empty string if the networkState property is EMPTY.">HTMLMediaElement/currentSrc</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a id="location-of-the-media-resource:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the current <a href="#media-resource" id="location-of-the-media-resource:media-resource-2">media resource</a>, if any.</p>

    <p>Returns the empty string when there is no <a href="#media-resource" id="location-of-the-media-resource:media-resource-3">media resource</a>, or it doesn't have a
    <a id="location-of-the-media-resource:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p>
   </dd></dl>

  

  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-currentsrc" data-dfn-type="attribute"><code>currentSrc</code></dfn> IDL attribute must initially be set to the
  empty string. Its value is changed by the <a href="#concept-media-load-algorithm" id="location-of-the-media-resource:concept-media-load-algorithm-2">resource
  selection algorithm</a> defined below.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-srcobject" data-dfn-type="attribute"><code>srcObject</code></dfn> IDL attribute, on getting, must return the
  element's <a href="#assigned-media-provider-object" id="location-of-the-media-resource:assigned-media-provider-object-2">assigned media provider object</a>, if any, or null otherwise. On setting, it
  must set the element's <a href="#assigned-media-provider-object" id="location-of-the-media-resource:assigned-media-provider-object-3">assigned media provider object</a> to the new value, and then
  invoke the element's <a href="#media-element-load-algorithm" id="location-of-the-media-resource:media-element-load-algorithm-2">media element load algorithm</a>.</p>
  </div>

  

  <p class="note">There are three ways to specify a <a href="#media-resource" id="location-of-the-media-resource:media-resource-4">media resource</a>: the <code id="location-of-the-media-resource:dom-media-srcobject"><a href="#dom-media-srcobject">srcObject</a></code> IDL attribute, the <code id="location-of-the-media-resource:attr-media-src-5"><a href="#attr-media-src">src</a></code> content attribute, and <code id="location-of-the-media-resource:the-source-element-2"><a href="#the-source-element">source</a></code> elements. The IDL
  attribute takes priority, followed by the content attribute, followed by the elements.</p>



  <h5 id="mime-types"><span class="secno">4.8.11.3</span> MIME types<a href="#mime-types" class="self-link"></a></h5>

  <p>A <a href="#media-resource" id="mime-types:media-resource">media resource</a> can be described in terms of its <em>type</em>, specifically a
  <a id="mime-types:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a>, in some cases with a <code>codecs</code> parameter. (Whether the
  <code>codecs</code> parameter is allowed or not depends on the MIME type.)
  <a href="#refsRFC6381">[RFC6381]</a></p>

  <p>Types are usually somewhat incomplete descriptions; for example "<code>video/mpeg</code>" doesn't say anything except what the container type is, and even a
  type like "<code>video/mp4; codecs="avc1.42E01E, mp4a.40.2"</code>" doesn't
  include information like the actual bitrate (only the maximum bitrate). Thus, given a type, a user
  agent can often only know whether it <em>might</em> be able to play media of that type (with
  varying levels of confidence), or whether it definitely <em>cannot</em> play media of that
  type.</p>

  <p><dfn id="a-type-that-the-user-agent-knows-it-cannot-render">A type that the user agent knows it cannot render</dfn> is one that describes a resource
  that the user agent definitely does not support, for example because it doesn't recognize the
  container type, or it doesn't support the listed codecs.</p>

  <p>The <a id="mime-types:mime-type-2" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> "<code id="mime-types:application/octet-stream"><a data-x-internal="application/octet-stream" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1">application/octet-stream</a></code>" with no parameters is never
  <a href="#a-type-that-the-user-agent-knows-it-cannot-render" id="mime-types:a-type-that-the-user-agent-knows-it-cannot-render">a type that the user agent knows it cannot render</a>. User agents must treat that type
  as equivalent to the lack of any explicit <a href="#content-type" id="mime-types:content-type">Content-Type metadata</a>
  when it is used to label a potential <a href="#media-resource" id="mime-types:media-resource-2">media resource</a>.</p>

  <p class="note">Only the <a id="mime-types:mime-type-3" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> "<code id="mime-types:application/octet-stream-2"><a data-x-internal="application/octet-stream" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1">application/octet-stream</a></code>" with no
  parameters is special-cased here; if any parameter appears with it, it will be treated just like
  any other <a id="mime-types:mime-type-4" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a>. This is a deviation from the rule  that unknown <a id="mime-types:mime-type-5" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> parameters should be
  ignored.</p> 

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-navigator-canplaytype" id="dom-navigator-canplaytype-dev">canPlayType</a>(<var>type</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType" title="The HTMLMediaElement method canPlayType() reports how likely it is that the current browser will be able to play media of a given MIME type.">HTMLMediaElement/canPlayType</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the empty string (a negative response), "maybe", or "probably" based on how confident
    the user agent is that it can play media resources of the given type.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-navigator-canplaytype" data-dfn-type="method"><code>canPlayType(<var>type</var>)</code></dfn> method must return
  <dfn id="dom-canplaytyperesult-nil">the empty string</dfn> if <var>type</var> is <a href="#a-type-that-the-user-agent-knows-it-cannot-render" id="mime-types:a-type-that-the-user-agent-knows-it-cannot-render-2">a type
  that the user agent knows it cannot render</a> or is the type
  "<code id="mime-types:application/octet-stream-3"><a data-x-internal="application/octet-stream" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1">application/octet-stream</a></code>"; it must return "<dfn data-dfn-for="CanPlayTypeResult" id="dom-canplaytyperesult-probably" data-dfn-type="enum-value"><code>probably</code></dfn>" if
  the user agent is confident that the type represents a <a href="#media-resource" id="mime-types:media-resource-3">media resource</a> that it can
  render if used in with this <code id="mime-types:the-audio-element"><a href="#the-audio-element">audio</a></code> or <code id="mime-types:the-video-element"><a href="#the-video-element">video</a></code> element; and it must return
  "<dfn data-dfn-for="CanPlayTypeResult" id="dom-canplaytyperesult-maybe" data-dfn-type="enum-value"><code>maybe</code></dfn>" otherwise. Implementers are encouraged to
  return "<code id="mime-types:dom-canplaytyperesult-maybe"><a href="#dom-canplaytyperesult-maybe">maybe</a></code>" unless the type can be
  confidently established as being supported or not. Generally, a user agent should never return
  "<code id="mime-types:dom-canplaytyperesult-probably"><a href="#dom-canplaytyperesult-probably">probably</a></code>" for a type that allows the <code>codecs</code> parameter if that parameter is not present.</p>
  </div>

  

  <div class="example">

   <p>This script tests to see if the user agent supports a (fictional) new format to dynamically
   decide whether to use a <code id="mime-types:the-video-element-2"><a href="#the-video-element">video</a></code> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"video"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"playing-cats.nfv"</c-><c- p="">&gt;</c->Download video<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">const</c-> videoSection <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'video'</c-><c- p="">);</c->
 <c- a="">const</c-> videoElement <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'video'</c-><c- p="">);</c->
 <c- a="">const</c-> support <c- o="">=</c-> videoElement<c- p="">.</c->canPlayType<c- p="">(</c-><c- t="">'video/x-new-fictional-format;codecs="kittens,bunnies"'</c-><c- p="">);</c->
 <c- k="">if</c-> <c- p="">(</c->support <c- o="">===</c-> <c- u="">"probably"</c-><c- p="">)</c-> <c- p="">{</c->
   videoElement<c- p="">.</c->setAttribute<c- p="">(</c-><c- u="">"src"</c-><c- p="">,</c-> <c- u="">"playing-cats.nfv"</c-><c- p="">);</c->
   videoSection<c- p="">.</c->replaceChildren<c- p="">(</c->videoElement<c- p="">);</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p class="note">The <code id="mime-types:attr-source-type"><a href="#attr-source-type">type</a></code> attribute of the
  <code id="mime-types:the-source-element"><a href="#the-source-element">source</a></code> element allows the user agent to avoid downloading resources that use formats
  it cannot render.</p>


  <h5 id="network-states"><span class="secno">4.8.11.4</span> Network states<a href="#network-states" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-networkstate" id="dom-media-networkstate-dev">networkState</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/networkState" title="The HTMLMediaElement.networkState property indicates the current state of the fetching of media over the network.">HTMLMediaElement/networkState</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the current state of network activity for the element, from the codes in the list
    below.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>As <a href="#media-element" id="network-states:media-element">media elements</a> interact with the network, their current
  network activity is represented by the <dfn data-dfn-for="HTMLMediaElement" id="dom-media-networkstate" data-dfn-type="attribute"><code>networkState</code></dfn> attribute. On getting, it must return
  the current network state of the element, which must be one of the following values:</p>
  </div>

  

  <dl><dt><dfn data-dfn-for="HTMLMediaElement" id="dom-media-network_empty" data-dfn-type="const"><code>NETWORK_EMPTY</code></dfn> (numeric value 0)</dt><dd>The element has not yet been initialized. All attributes are in their initial states.</dd><dt><dfn data-dfn-for="HTMLMediaElement" id="dom-media-network_idle" data-dfn-type="const"><code>NETWORK_IDLE</code></dfn> (numeric value 1)</dt><dd>The element's <a href="#concept-media-load-algorithm" id="network-states:concept-media-load-algorithm">resource
   selection algorithm</a> is active and has selected a <a href="#media-resource" id="network-states:media-resource">resource</a>, but it is not actually using the network at this time.</dd><dt><dfn data-dfn-for="HTMLMediaElement" id="dom-media-network_loading" data-dfn-type="const"><code>NETWORK_LOADING</code></dfn> (numeric value 2)</dt><dd>The user agent is actively trying to download data.</dd><dt><dfn data-dfn-for="HTMLMediaElement" id="dom-media-network_no_source" data-dfn-type="const"><code>NETWORK_NO_SOURCE</code></dfn> (numeric value 3)</dt><dd>The element's <a href="#concept-media-load-algorithm" id="network-states:concept-media-load-algorithm-2">resource
   selection algorithm</a> is active, but it has not yet found a <a href="#media-resource" id="network-states:media-resource-2">resource</a> to use.</dd></dl>

  

  <p>The <a href="#concept-media-load-algorithm" id="network-states:concept-media-load-algorithm-3">resource selection algorithm</a> defined
  below describes exactly when the <code id="network-states:dom-media-networkstate"><a href="#dom-media-networkstate">networkState</a></code>
  attribute changes value and what events fire to indicate changes in this state.</p>

  




  <h5 id="loading-the-media-resource"><span class="secno">4.8.11.5</span> Loading the media resource<a href="#loading-the-media-resource" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-load" id="dom-media-load-dev">load</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/load" title="The HTMLMediaElement method load() resets the media element to its initial state and begins the process of selecting a media source and loading the media in preparation for playback to begin at the beginning.">HTMLMediaElement/load</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Causes the element to reset and start selecting and loading a new <a href="#media-resource" id="loading-the-media-resource:media-resource">media resource</a>
    from scratch.</p>
   </dd></dl>

  

  <p>All <a href="#media-element" id="loading-the-media-resource:media-element">media elements</a> have a <dfn id="can-autoplay-flag">can autoplay flag</dfn>,
  which must begin in the true state, and a <dfn id="delaying-the-load-event-flag">delaying-the-load-event flag</dfn>, which must
  begin in the false state. While the <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag">delaying-the-load-event flag</a> is true, the element
  must <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event">delay the load event</a> of its document.</p>

  <div data-algorithm="">
  <p>When the <dfn data-dfn-for="HTMLMediaElement" id="dom-media-load" data-dfn-type="method"><code>load()</code></dfn>
  method on a <a href="#media-element" id="loading-the-media-resource:media-element-2">media element</a> is invoked, the user agent must run the <a href="#media-element-load-algorithm" id="loading-the-media-resource:media-element-load-algorithm">media element
  load algorithm</a>.</p>
  </div>

  <p>A <a href="#media-element" id="loading-the-media-resource:media-element-3">media element</a> has an associated boolean <dfn id="is-currently-stalled">is currently stalled</dfn>, which
  is initially false.</p>

  <div data-algorithm="">
  <p>The <dfn id="media-element-load-algorithm">media element load algorithm</dfn> consists of the following steps.</p>

  <ol><li><p>Set this element's <a href="#is-currently-stalled" id="loading-the-media-resource:is-currently-stalled">is currently stalled</a> to false.</p></li><li><p>Abort any already-running instance of the <a href="#concept-media-load-algorithm" id="loading-the-media-resource:concept-media-load-algorithm">resource selection algorithm</a> for this
   element.</p></li><li><p>Let <var>pending tasks</var> be a list of all <a href="#concept-task" id="loading-the-media-resource:concept-task">tasks</a>
   from the <a href="#media-element" id="loading-the-media-resource:media-element-4">media element</a>'s <a href="#media-element-event-task-source" id="loading-the-media-resource:media-element-event-task-source">media element event task source</a> in one of the
   <a href="#task-queue" id="loading-the-media-resource:task-queue">task queues</a>.</p></li><li><p>For each task in <var>pending tasks</var> that would <a href="#resolve-pending-play-promises" id="loading-the-media-resource:resolve-pending-play-promises">resolve pending play
   promises</a> or <a href="#reject-pending-play-promises" id="loading-the-media-resource:reject-pending-play-promises">reject pending play promises</a>, immediately resolve or reject those
   promises in the order the corresponding tasks were queued.</p></li><li>
    <p>Remove each <a href="#concept-task" id="loading-the-media-resource:concept-task-2">task</a> in <var>pending tasks</var> from its
    <a href="#task-queue" id="loading-the-media-resource:task-queue-2">task queue</a>.</p>

    <p class="note">Basically, pending events and callbacks are discarded and promises in-flight to
    be resolved/rejected are resolved/rejected immediately when the media element starts loading a
    new resource.</p>
   </li><li><p>If the <a href="#media-element" id="loading-the-media-resource:media-element-5">media element</a>'s <code id="loading-the-media-resource:dom-media-networkstate"><a href="#dom-media-networkstate">networkState</a></code> is set to <code id="loading-the-media-resource:dom-media-network_loading"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code> or <code id="loading-the-media-resource:dom-media-network_idle"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code>, <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task">queue a media element task</a>
   given the <a href="#media-element" id="loading-the-media-resource:media-element-6">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a>
   named <code id="loading-the-media-resource:event-media-abort"><a href="#event-media-abort">abort</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-7">media element</a>.</p></li><li>
    <p>If the <a href="#media-element" id="loading-the-media-resource:media-element-8">media element</a>'s <code id="loading-the-media-resource:dom-media-networkstate-2"><a href="#dom-media-networkstate">networkState</a></code>
    is not set to <code id="loading-the-media-resource:dom-media-network_empty"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code>, then:</p>

    <ol><li><p><a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-2">Queue a media element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-9">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="loading-the-media-resource:event-media-emptied"><a href="#event-media-emptied">emptied</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-10">media element</a>.</p></li><li><p>If a fetching process is in progress for the <a href="#media-element" id="loading-the-media-resource:media-element-11">media
     element</a>, the user agent should stop it.</p></li><li><p>If the <a href="#media-element" id="loading-the-media-resource:media-element-12">media element</a>'s <a href="#assigned-media-provider-object" id="loading-the-media-resource:assigned-media-provider-object">assigned media provider object</a> is a
     <code id="loading-the-media-resource:mediasource"><a data-x-internal="mediasource" href="https://w3c.github.io/media-source/#idl-def-mediasource">MediaSource</a></code> object, then <a href="https://w3c.github.io/media-source/#mediasource-detach" id="loading-the-media-resource:detaching-from-a-media-element" data-x-internal="detaching-from-a-media-element">detach</a> it.</p></li><li><p><a href="#forget-the-media-element's-media-resource-specific-tracks" id="loading-the-media-resource:forget-the-media-element's-media-resource-specific-tracks">Forget the media element's media-resource-specific tracks</a>.</p></li><li><p>If <code id="loading-the-media-resource:dom-media-readystate"><a href="#dom-media-readystate">readyState</a></code> is not set to <code id="loading-the-media-resource:dom-media-have_nothing"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>, then set it to that state.</p></li><li>
     <p>If the <code id="loading-the-media-resource:dom-media-paused"><a href="#dom-media-paused">paused</a></code> attribute is false, then:</p>

      <ol><li><p>Set the <code id="loading-the-media-resource:dom-media-paused-2"><a href="#dom-media-paused">paused</a></code> attribute to true.</p></li><li><p><a href="#take-pending-play-promises" id="loading-the-media-resource:take-pending-play-promises">Take pending play promises</a> and <a href="#reject-pending-play-promises" id="loading-the-media-resource:reject-pending-play-promises-2">reject pending play promises</a>
       with the result and an <a id="loading-the-media-resource:aborterror" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a>
       <code id="loading-the-media-resource:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
     </li><li><p>If <code id="loading-the-media-resource:dom-media-seeking"><a href="#dom-media-seeking">seeking</a></code> is true, set it to false.</p></li><li>
      <p>Set the <a href="#current-playback-position" id="loading-the-media-resource:current-playback-position">current playback position</a> to 0.</p>

      <p>Set the <a href="#official-playback-position" id="loading-the-media-resource:official-playback-position">official playback position</a> to 0.</p>

      <p>If this changed the <a href="#official-playback-position" id="loading-the-media-resource:official-playback-position-2">official playback position</a>, then <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-3">queue a media
      element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-13">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-3" data-x-internal="concept-event-fire">fire an event</a> named <code id="loading-the-media-resource:event-media-timeupdate"><a href="#event-media-timeupdate">timeupdate</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-14">media element</a>.</p>
     </li><li><p>Set the <a href="#timeline-offset" id="loading-the-media-resource:timeline-offset">timeline offset</a> to Not-a-Number (NaN).</p></li><li>
      <p>Update the <code id="loading-the-media-resource:dom-media-duration"><a href="#dom-media-duration">duration</a></code> attribute to Not-a-Number
      (NaN).</p>

      <p class="note">The user agent <a href="#durationChange">will not</a> fire a <code id="loading-the-media-resource:event-media-durationchange"><a href="#event-media-durationchange">durationchange</a></code> event for this particular change of
      the duration.</p>
     </li></ol>
   </li><li><p>Set the <code id="loading-the-media-resource:dom-media-playbackrate"><a href="#dom-media-playbackrate">playbackRate</a></code> attribute to the value of
   the <code id="loading-the-media-resource:dom-media-defaultplaybackrate"><a href="#dom-media-defaultplaybackrate">defaultPlaybackRate</a></code> attribute.</p></li><li><p>Set the <code id="loading-the-media-resource:dom-media-error"><a href="#dom-media-error">error</a></code> attribute to null and the
   <a href="#can-autoplay-flag" id="loading-the-media-resource:can-autoplay-flag">can autoplay flag</a> to true.</p></li><li><p>Invoke the <a href="#media-element" id="loading-the-media-resource:media-element-15">media element</a>'s <a href="#concept-media-load-algorithm" id="loading-the-media-resource:concept-media-load-algorithm-2">resource selection algorithm</a>.</p></li><li>
    <p class="note">Playback of any previously playing <a href="#media-resource" id="loading-the-media-resource:media-resource-2">media resource</a> for this element
    stops.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="concept-media-load-algorithm">resource selection algorithm</dfn> for a
  <a href="#media-element" id="loading-the-media-resource:media-element-16">media element</a> is as follows. This algorithm is always invoked as part of a <a href="#concept-task" id="loading-the-media-resource:concept-task-3">task</a>, but one
  of the first steps in the algorithm is to return and continue running the remaining steps
  <a href="#in-parallel" id="loading-the-media-resource:in-parallel">in parallel</a>. In addition, this algorithm interacts
  closely with the <a href="#event-loop" id="loading-the-media-resource:event-loop">event loop</a> mechanism; in particular, it has <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section">synchronous sections</a> (which are triggered as part of the <a href="#event-loop" id="loading-the-media-resource:event-loop-2">event loop</a>
  algorithm). Steps in such sections are marked with ⌛.</p>

  <ol><li><p>Set the element's <code id="loading-the-media-resource:dom-media-networkstate-3"><a href="#dom-media-networkstate">networkState</a></code> attribute to
   the <code id="loading-the-media-resource:dom-media-network_no_source"><a href="#dom-media-network_no_source">NETWORK_NO_SOURCE</a></code> value.</p></li><li><p>Set the element's <a href="#show-poster-flag" id="loading-the-media-resource:show-poster-flag">show poster flag</a> to true.</p></li><li><p>Set the <a href="#media-element" id="loading-the-media-resource:media-element-17">media element</a>'s <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-2">delaying-the-load-event flag</a> to true
   (this <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-2">delays the load event</a>).</p></li><li><p><a href="#await-a-stable-state" id="loading-the-media-resource:await-a-stable-state">Await a stable state</a>, allowing the <a href="#concept-task" id="loading-the-media-resource:concept-task-4">task</a> that invoked this algorithm to continue. The <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-2">synchronous
   section</a> consists of all the remaining steps of this algorithm until the algorithm says the
   <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-3">synchronous section</a> has ended. (Steps in <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-4">synchronous sections</a> are marked with ⌛.)</p></li><li>
    <p>⌛ If the <a href="#media-element" id="loading-the-media-resource:media-element-18">media element</a>'s <a href="#blocked-on-parser" id="loading-the-media-resource:blocked-on-parser">blocked-on-parser</a> flag is false,
    then <a href="#populate-the-list-of-pending-text-tracks" id="loading-the-media-resource:populate-the-list-of-pending-text-tracks">populate the list of pending text tracks</a>.</p>
   </li><li>
    <p>⌛ If the <a href="#media-element" id="loading-the-media-resource:media-element-19">media element</a> has an <a href="#assigned-media-provider-object" id="loading-the-media-resource:assigned-media-provider-object-2">assigned media provider
    object</a>, then let <var>mode</var> be <i>object</i>.</p>

    <p>⌛ Otherwise, if the <a href="#media-element" id="loading-the-media-resource:media-element-20">media element</a> has no <a href="#assigned-media-provider-object" id="loading-the-media-resource:assigned-media-provider-object-3">assigned media provider
    object</a> but has a <code id="loading-the-media-resource:attr-media-src"><a href="#attr-media-src">src</a></code>
    attribute, then let <var>mode</var> be <i>attribute</i>.</p>

    <p>⌛ Otherwise, if the <a href="#media-element" id="loading-the-media-resource:media-element-21">media element</a> does not have an <a href="#assigned-media-provider-object" id="loading-the-media-resource:assigned-media-provider-object-4">assigned media provider
    object</a> and does not have a <code id="loading-the-media-resource:attr-media-src-2"><a href="#attr-media-src">src</a></code> attribute, but does have a <code id="loading-the-media-resource:the-source-element"><a href="#the-source-element">source</a></code> element child, then
    let <var>mode</var> be <i>children</i> and let <var>candidate</var>
    be the first such <code id="loading-the-media-resource:the-source-element-2"><a href="#the-source-element">source</a></code> element child in <a id="loading-the-media-resource:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p>

    <p>⌛ Otherwise, the <a href="#media-element" id="loading-the-media-resource:media-element-22">media element</a> has no <a href="#assigned-media-provider-object" id="loading-the-media-resource:assigned-media-provider-object-5">assigned media provider
    object</a> and has neither a <code id="loading-the-media-resource:attr-media-src-3"><a href="#attr-media-src">src</a></code> attribute nor a <code id="loading-the-media-resource:the-source-element-3"><a href="#the-source-element">source</a></code> element child:</p>

    <ol><li><p>⌛ Set the <code id="loading-the-media-resource:dom-media-networkstate-4"><a href="#dom-media-networkstate">networkState</a></code> to <code id="loading-the-media-resource:dom-media-network_empty-2"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code>.</p></li><li><p>⌛ Set the element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-3">delaying-the-load-event flag</a> to false. This stops <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-3">delaying the load event</a>.</p></li><li><p>End the <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-5">synchronous section</a> and return.</p></li></ol>
   </li><li><p>⌛ Set the <a href="#media-element" id="loading-the-media-resource:media-element-23">media element</a>'s <code id="loading-the-media-resource:dom-media-networkstate-5"><a href="#dom-media-networkstate">networkState</a></code> to <code id="loading-the-media-resource:dom-media-network_loading-2"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code>.</p></li><li><p>⌛ <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-4">Queue a media element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-24">media element</a> to
   <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-4" data-x-internal="concept-event-fire">fire an event</a> named <code id="loading-the-media-resource:event-media-loadstart"><a href="#event-media-loadstart">loadstart</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-25">media element</a>.</p></li><li>
    <p>Run the appropriate steps from the following list:</p>

    <dl class="switch"><dt>If <var>mode</var> is <i>object</i></dt><dd>
      <ol><li><p>⌛ Set the <code id="loading-the-media-resource:dom-media-currentsrc"><a href="#dom-media-currentsrc">currentSrc</a></code> attribute to
       the empty string.</p></li><li><p>End the <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-6">synchronous section</a>, continuing the remaining steps
       <a href="#in-parallel" id="loading-the-media-resource:in-parallel-2">in parallel</a>.</p></li><li><p>Run the <a href="#concept-media-load-resource" id="loading-the-media-resource:concept-media-load-resource">resource fetch algorithm</a>
       with the <a href="#assigned-media-provider-object" id="loading-the-media-resource:assigned-media-provider-object-6">assigned media provider object</a>. If that algorithm returns without
       aborting <em>this</em> one, then the load failed.</p></li><li><p><i>Failed with media provider</i>: Reaching this step indicates that the media
       resource failed to load. <a href="#take-pending-play-promises" id="loading-the-media-resource:take-pending-play-promises-2">Take pending play promises</a> and <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-5">queue a media
       element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-26">media element</a> to run the <a href="#dedicated-media-source-failure-steps" id="loading-the-media-resource:dedicated-media-source-failure-steps">dedicated media
       source failure steps</a> with the result.</p></li><li><p>Wait for the <a href="#concept-task" id="loading-the-media-resource:concept-task-5">task</a> queued by the previous step to have
       executed.</p></li><li><p>Return. The element won't attempt to load another resource until this
       algorithm is triggered again.</p></li></ol>
     </dd><dt>If <var>mode</var> is <i>attribute</i></dt><dd>
      <ol><li><p>⌛ If the <code id="loading-the-media-resource:attr-media-src-4"><a href="#attr-media-src">src</a></code>
       attribute's value is the empty string, then end the <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-7">synchronous section</a>, and jump
       down to the <i>failed with attribute</i> step below.</p></li><li><p>⌛ Let <var>urlRecord</var> be the result of <a href="#encoding-parsing-a-url" id="loading-the-media-resource:encoding-parsing-a-url">encoding-parsing a URL</a>
       given the <code id="loading-the-media-resource:attr-media-src-5"><a href="#attr-media-src">src</a></code> attribute's value, relative to the
       <a href="#media-element" id="loading-the-media-resource:media-element-27">media element</a>'s <a id="loading-the-media-resource:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> when the <code id="loading-the-media-resource:attr-media-src-6"><a href="#attr-media-src">src</a></code> attribute was last changed.</p>
       

       </li><li><p>⌛ If <var>urlRecord</var> is not failure, then set the <code id="loading-the-media-resource:dom-media-currentsrc-2"><a href="#dom-media-currentsrc">currentSrc</a></code> attribute to the result of applying the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="loading-the-media-resource:concept-url-serializer" data-x-internal="concept-url-serializer">URL serializer</a> to <var>urlRecord</var>.</p></li><li><p>End the <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-8">synchronous section</a>, continuing the remaining steps
       <a href="#in-parallel" id="loading-the-media-resource:in-parallel-3">in parallel</a>.</p></li><li><p>If <var>urlRecord</var> is not failure, then run the <a href="#concept-media-load-resource" id="loading-the-media-resource:concept-media-load-resource-2">resource fetch algorithm</a> with
       <var>urlRecord</var>. If that algorithm returns without aborting <em>this</em> one, then the
       load failed.</p></li><li><p><i>Failed with attribute</i>: Reaching this step indicates that the media resource
       failed to load or that <var>urlRecord</var> is failure. <a href="#take-pending-play-promises" id="loading-the-media-resource:take-pending-play-promises-3">Take pending play
       promises</a> and <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-6">queue a media element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-28">media
       element</a> to run the <a href="#dedicated-media-source-failure-steps" id="loading-the-media-resource:dedicated-media-source-failure-steps-2">dedicated media source failure steps</a> with the
       result.</p></li><li><p>Wait for the <a href="#concept-task" id="loading-the-media-resource:concept-task-6">task</a> queued by the previous step to have
       executed.</p></li><li><p>Return. The element won't attempt to load another resource until this
       algorithm is triggered again.</p></li></ol>
     </dd><dt>Otherwise (<var>mode</var> is <i>children</i>)</dt><dd>
      <ol><li>
        <p>⌛ Let <var>pointer</var> be a position defined by two adjacent nodes in the
        <a href="#media-element" id="loading-the-media-resource:media-element-29">media element</a>'s child list, treating the start of the list (before the first
        child in the list, if any) and end of the list (after the last child in the list, if any) as
        nodes in their own right. One node is the node before <var>pointer</var>, and the
        other node is the node after <var>pointer</var>. Initially, let <var>pointer</var> be the position between the <var>candidate</var> node and the
        next node, if there are any, or the end of the list, if it is the last node.</p>

        <p>As nodes are <a href="https://dom.spec.whatwg.org/#concept-node-insert-ext" id="loading-the-media-resource:concept-node-insert-ext" data-x-internal="concept-node-insert-ext">inserted</a>, <a href="https://dom.spec.whatwg.org/#concept-node-remove-ext" id="loading-the-media-resource:concept-node-remove-ext" data-x-internal="concept-node-remove-ext">removed</a>, and <a href="https://dom.spec.whatwg.org/#concept-node-move-ext" id="loading-the-media-resource:concept-node-move-ext" data-x-internal="concept-node-move-ext">moved</a> into the <a href="#media-element" id="loading-the-media-resource:media-element-30">media element</a>,
        <var>pointer</var> must be updated as follows:</p>

        <dl><dt>If a new node is <a href="https://dom.spec.whatwg.org/#concept-node-insert-ext" id="loading-the-media-resource:concept-node-insert-ext-2" data-x-internal="concept-node-insert-ext">inserted</a> or <a href="https://dom.spec.whatwg.org/#concept-node-move-ext" id="loading-the-media-resource:concept-node-move-ext-2" data-x-internal="concept-node-move-ext">moved</a> between the two nodes that define
         <var>pointer</var></dt><dd>Let <var>pointer</var> be the point between the node before <var>pointer</var> and the
         new node. In other words, insertions at <var>pointer</var> go after
         <var>pointer</var>.</dd><dt>If the node before <var>pointer</var> is removed</dt><dd>Let <var>pointer</var> be the point between the node after <var>pointer</var> and the
         node before the node after <var>pointer</var>. In other words, <var>pointer</var> doesn't
         move relative to the remaining nodes.</dd><dt>If the node after <var>pointer</var> is removed</dt><dd>Let <var>pointer</var> be the point between the node before <var>pointer</var> and the
         node after the node before <var>pointer</var>. Just as with the previous case,
         <var>pointer</var> doesn't move relative to the remaining nodes.</dd></dl>

        <p>Other changes don't affect <var>pointer</var>.</p>
       </li><li><p>⌛ <i>Process candidate</i>: If <var>candidate</var> does not have a
       <code id="loading-the-media-resource:attr-source-src"><a href="#attr-source-src">src</a></code> attribute, or if its <code id="loading-the-media-resource:attr-source-src-2"><a href="#attr-source-src">src</a></code> attribute's value is the empty string, then end the
       <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-9">synchronous section</a>, and jump down to the <i>failed with elements</i> step
       below.</p></li><li><p>⌛ If <var>candidate</var> has a <code id="loading-the-media-resource:attr-source-media"><a href="#attr-source-media">media</a></code>
       attribute whose value does not <a href="#matches-the-environment" id="loading-the-media-resource:matches-the-environment">match the
       environment</a>, then end the <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-10">synchronous section</a>, and jump down to the
       <i>failed with elements</i> step below.</p></li><li><p>⌛ Let <var>urlRecord</var> be the result of <a href="#encoding-parsing-a-url" id="loading-the-media-resource:encoding-parsing-a-url-2">encoding-parsing a URL</a>
       given <var>candidate</var>'s <code id="loading-the-media-resource:attr-media-src-7"><a href="#attr-media-src">src</a></code> attribute's value,
       relative to <var>candidate</var>'s <a id="loading-the-media-resource:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> when the <code id="loading-the-media-resource:attr-media-src-8"><a href="#attr-media-src">src</a></code> attribute was last changed.</p>
       

       </li><li><p>⌛ If <var>urlRecord</var> is failure, then end the <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-11">synchronous
       section</a>, and jump down to the <i>failed with elements</i> step below.</p></li><li><p>⌛ If <var>candidate</var> has a <code id="loading-the-media-resource:attr-source-type"><a href="#attr-source-type">type</a></code> attribute whose value, when parsed as a <a id="loading-the-media-resource:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME
       type</a> (including any codecs described by the <code>codecs</code> parameter, for
       types that define that parameter), represents <a href="#a-type-that-the-user-agent-knows-it-cannot-render" id="loading-the-media-resource:a-type-that-the-user-agent-knows-it-cannot-render">a type that the user agent knows it cannot
       render</a>, then end the <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-12">synchronous section</a>, and jump down to the <i>failed with elements</i> step below.</p></li><li><p>⌛ Set the <code id="loading-the-media-resource:dom-media-currentsrc-3"><a href="#dom-media-currentsrc">currentSrc</a></code> attribute to
       the result of applying the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="loading-the-media-resource:concept-url-serializer-2" data-x-internal="concept-url-serializer">URL serializer</a> to
       <var>urlRecord</var>.</p></li><li><p>End the <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-13">synchronous section</a>, continuing the remaining steps
       <a href="#in-parallel" id="loading-the-media-resource:in-parallel-4">in parallel</a>.</p></li><li><p>Run the <a href="#concept-media-load-resource" id="loading-the-media-resource:concept-media-load-resource-3">resource fetch algorithm</a>
       with <var>urlRecord</var>. If that algorithm returns without aborting <em>this</em> one,
       then the load failed.</p></li><li><p><i>Failed with elements</i>: <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-7">Queue a media element task</a> given the
       <a href="#media-element" id="loading-the-media-resource:media-element-31">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-5" data-x-internal="concept-event-fire">fire an event</a> named
       <code id="loading-the-media-resource:event-source-error"><a href="#event-source-error">error</a></code> at <var>candidate</var>.</p></li><li><p><a href="#await-a-stable-state" id="loading-the-media-resource:await-a-stable-state-2">Await a stable state</a>. The <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-14">synchronous section</a>
       consists of all the remaining steps of this algorithm until the algorithm says the
       <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-15">synchronous section</a> has ended. (Steps in <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-16">synchronous sections</a> are marked with ⌛.)</p></li><li><p>⌛ <a href="#forget-the-media-element's-media-resource-specific-tracks" id="loading-the-media-resource:forget-the-media-element's-media-resource-specific-tracks-2">Forget the media element's media-resource-specific
       tracks</a>.</p></li><li><p>⌛ <i>Find next candidate</i>: Let <var>candidate</var> be
       null.</p></li><li><p>⌛ <i>Search loop</i>: If the node after <var>pointer</var> is
       the end of the list, then jump to the <i>waiting</i> step below.</p></li><li><p>⌛ If the node after <var>pointer</var> is a <code id="loading-the-media-resource:the-source-element-4"><a href="#the-source-element">source</a></code> element,
       let <var>candidate</var> be that element.</p></li><li><p>⌛ Advance <var>pointer</var> so that the node before <var>pointer</var> is now the node that was after <var>pointer</var>, and the node
       after <var>pointer</var> is the node after the node that used to be after <var>pointer</var>, if any.</p></li><li><p>⌛ If <var>candidate</var> is null, jump back to the <i>search
       loop</i> step. Otherwise, jump back to the <i>process candidate</i> step.</p></li><li><p>⌛ <i>Waiting</i>: Set the element's <code id="loading-the-media-resource:dom-media-networkstate-6"><a href="#dom-media-networkstate">networkState</a></code> attribute to the <code id="loading-the-media-resource:dom-media-network_no_source-2"><a href="#dom-media-network_no_source">NETWORK_NO_SOURCE</a></code> value.</p></li><li><p>⌛ Set the element's <a href="#show-poster-flag" id="loading-the-media-resource:show-poster-flag-2">show poster flag</a> to true.</p></li><li><p>⌛ <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-8">Queue a media element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-32">media element</a>
       to set the element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-4">delaying-the-load-event flag</a> to false. This stops <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-4">delaying the load event</a>.</p></li><li><p>End the <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-17">synchronous section</a>, continuing the remaining steps
       <a href="#in-parallel" id="loading-the-media-resource:in-parallel-5">in parallel</a>.</p></li><li><p>Wait until the node after <var>pointer</var> is a node other than the end of
       the list. (This step might wait forever.)</p></li><li><p><a href="#await-a-stable-state" id="loading-the-media-resource:await-a-stable-state-3">Await a stable state</a>. The <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-18">synchronous section</a>
       consists of all the remaining steps of this algorithm until the algorithm says the
       <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-19">synchronous section</a> has ended. (Steps in <a href="#synchronous-section" id="loading-the-media-resource:synchronous-section-20">synchronous sections</a> are marked with ⌛.)</p></li><li><p>⌛ Set the element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-5">delaying-the-load-event flag</a> back to true (this
       <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-5">delays the load event</a> again, in case it hasn't been
       fired yet).</p>

       </li><li><p>⌛ Set the <code id="loading-the-media-resource:dom-media-networkstate-7"><a href="#dom-media-networkstate">networkState</a></code> back to <code id="loading-the-media-resource:dom-media-network_loading-3"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code>.</p></li><li><p>⌛ Jump back to the <i>find next candidate</i> step above.</p></li></ol>
     </dd></dl>

    <p>The <dfn id="dedicated-media-source-failure-steps">dedicated media source failure steps</dfn> with a list of promises
    <var>promises</var> are the following steps:</p>

    <ol><li><p>Set the <code id="loading-the-media-resource:dom-media-error-2"><a href="#dom-media-error">error</a></code> attribute to the result of
     <a href="#creating-a-mediaerror" id="loading-the-media-resource:creating-a-mediaerror">creating a <code>MediaError</code></a> with <code id="loading-the-media-resource:dom-mediaerror-media_err_src_not_supported"><a href="#dom-mediaerror-media_err_src_not_supported">MEDIA_ERR_SRC_NOT_SUPPORTED</a></code>.</p></li><li><p><a href="#forget-the-media-element's-media-resource-specific-tracks" id="loading-the-media-resource:forget-the-media-element's-media-resource-specific-tracks-3">Forget the media element's media-resource-specific tracks</a>.</p></li><li><p>Set the element's <code id="loading-the-media-resource:dom-media-networkstate-8"><a href="#dom-media-networkstate">networkState</a></code> attribute to
     the <code id="loading-the-media-resource:dom-media-network_no_source-3"><a href="#dom-media-network_no_source">NETWORK_NO_SOURCE</a></code> value.</p></li><li><p>Set the element's <a href="#show-poster-flag" id="loading-the-media-resource:show-poster-flag-3">show poster flag</a> to true.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-6" data-x-internal="concept-event-fire">Fire an event</a> named <code id="loading-the-media-resource:event-media-error"><a href="#event-media-error">error</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-33">media element</a>.</p></li><li><p><a href="#reject-pending-play-promises" id="loading-the-media-resource:reject-pending-play-promises-3">Reject pending play promises</a> with <var>promises</var> and a
     <a id="loading-the-media-resource:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="loading-the-media-resource:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set the element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-6">delaying-the-load-event flag</a> to false. This stops <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-6">delaying the load event</a>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="verify-a-media-response">verify a media response</dfn> given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="loading-the-media-resource:concept-response" data-x-internal="concept-response">response</a>
  <var>response</var>, a <a href="#media-resource" id="loading-the-media-resource:media-resource-3">media resource</a> <var>resource</var>, and
  "<code>entire resource</code>" or a
  (number, number or "<code>until end</code>") tuple <var>byteRange</var>:</p>

  <ol><li><p>If <var>response</var> is a <a id="loading-the-media-resource:network-error" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>, then return false.</p></li><li><p>If <var>byteRange</var> is "<code>entire resource</code>", then return
   true.</p></li><li><p>Let <var>internalResponse</var> be <var>response</var>'s
   <a href="#unsafe-response" id="loading-the-media-resource:unsafe-response">unsafe response</a>.</p></li><li><p>If <var>internalResponse</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="loading-the-media-resource:concept-response-status" data-x-internal="concept-response-status">status</a> is
   200, then return true.</p></li><li><p>If <var>internalResponse</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="loading-the-media-resource:concept-response-status-2" data-x-internal="concept-response-status">status</a> is
   not 206, then return false.</p></li><li>
    <p>If the result of <a href="https://wicg.github.io/background-fetch/#extract-content-range-values" id="loading-the-media-resource:extract-content-range-values" data-x-internal="extract-content-range-values">extracting content-range values</a> from
    <var>internalResponse</var> is failure, then return false.</p>

    <p class="note">Note that the extracted values are not used, and in particular are not compared
    to <var>byteRange</var>. So this step serves as syntactic validation of the `<code id="loading-the-media-resource:http-content-range"><a data-x-internal="http-content-range" href="https://httpwg.org/specs/rfc7233.html#header.content-range">Content-Range</a></code>` header, but if the `<code id="loading-the-media-resource:http-content-range-2"><a data-x-internal="http-content-range" href="https://httpwg.org/specs/rfc7233.html#header.content-range">Content-Range</a></code>` values on the response mismatch the `<code id="loading-the-media-resource:http-range"><a data-x-internal="http-range" href="https://httpwg.org/specs/rfc7233.html#header.range">Range</a></code>` values on the request, that is not considered a failure.</p>
   </li><li><p>Let <var>origin</var> be "<code>rewritten</code>" if
   <var>internalResponse</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="loading-the-media-resource:concept-response-url" data-x-internal="concept-response-url">URL</a> is null; otherwise
   <var>internalResponse</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="loading-the-media-resource:concept-response-url-2" data-x-internal="concept-response-url">URL</a>'s
   <a href="https://url.spec.whatwg.org/#concept-url-origin" id="loading-the-media-resource:concept-url-origin" data-x-internal="concept-url-origin">origin</a>.</p></li><li><p>Let <var>previousOrigin</var> be <var>resource</var>'s
   <a href="#media-resource-origin" id="loading-the-media-resource:media-resource-origin">origin</a>.</p></li><li>
    <p>If any of the following are true:</p>

    <ul><li><p><var>previousOrigin</var> is "<code>none</code>";</p></li><li><p><var>origin</var> and <var>previousOrigin</var> are "<code>rewritten</code>";
     or</p></li><li><p><var>origin</var> and <var>previousOrigin</var> are <a href="#concept-origin" id="loading-the-media-resource:concept-origin">origins</a>, and <var>origin</var> is <a href="#same-origin" id="loading-the-media-resource:same-origin">same origin</a> with
     <var>previousOrigin</var>,</p></li></ul>

    <p>then set <var>resource</var>'s <a href="#media-resource-origin" id="loading-the-media-resource:media-resource-origin-2">origin</a> to
    <var>origin</var>.</p>

    <p>Otherwise, if <var>response</var> is <a href="#cors-cross-origin" id="loading-the-media-resource:cors-cross-origin">CORS-cross-origin</a>, then return false.</p>

    <p>Otherwise, set <var>resource</var>'s <a href="#media-resource-origin" id="loading-the-media-resource:media-resource-origin-3">origin</a> to
    "<code>multiple</code>".</p>

    <p class="note">This ensures that opaque responses with range headers do not leak information
    by being patched together with other responses from different origins.</p>
   </li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="concept-media-load-resource" data-export="">resource fetch algorithm</dfn> for a
  <a href="#media-element" id="loading-the-media-resource:media-element-34">media element</a> and a given <a id="loading-the-media-resource:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> or <a href="#media-provider-object" id="loading-the-media-resource:media-provider-object">media provider
  object</a> is as follows:</p>

  <ol><li><p>Let <var>mode</var> be <i>remote</i>.</p></li><li>
    <p>If the algorithm was invoked with <a href="#media-provider-object" id="loading-the-media-resource:media-provider-object-2">media provider object</a>, then set
    <var>mode</var> to <i>local</i>.</p>

    <p>Otherwise:</p>

    <ol><li><p>Let <var>object</var> be the result of <a href="https://w3c.github.io/FileAPI/#blob-url-obtain-object" id="loading-the-media-resource:blob-url-obtain-object" data-x-internal="blob-url-obtain-object">obtaining
     a blob object</a> using the <a id="loading-the-media-resource:url-record-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a>'s <a href="https://url.spec.whatwg.org/#concept-url-blob-entry" id="loading-the-media-resource:concept-url-blob-entry" data-x-internal="concept-url-blob-entry">blob URL entry</a> and the <a href="#media-element" id="loading-the-media-resource:media-element-35">media element</a>'s
     <a id="loading-the-media-resource:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#relevant-settings-object" id="loading-the-media-resource:relevant-settings-object">relevant settings object</a>.</p></li><li><p>If <var>object</var> is a <a href="#media-provider-object" id="loading-the-media-resource:media-provider-object-3">media provider object</a>, then set <var>mode</var>
     to <i>local</i>.</p></li></ol>
   </li><li><p>If <var>mode</var> is <i>remote</i>, then let the <var>current media resource</var> be the
   resource given by the <a id="loading-the-media-resource:url-record-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> passed to this algorithm; otherwise, let the
   <var>current media resource</var> be the resource given by the <a href="#media-provider-object" id="loading-the-media-resource:media-provider-object-4">media provider
   object</a>. Either way, the <var>current media resource</var> is now the element's <a href="#media-resource" id="loading-the-media-resource:media-resource-4">media
   resource</a>.</p></li><li><p>Remove all <a href="#media-resource-specific-text-track" id="loading-the-media-resource:media-resource-specific-text-track">media-resource-specific text
   tracks</a> from the <a href="#media-element" id="loading-the-media-resource:media-element-36">media element</a>'s <a href="#list-of-pending-text-tracks" id="loading-the-media-resource:list-of-pending-text-tracks">list of pending text tracks</a>, if
   any.</p>


   </li><li>
    <p>Run the appropriate steps from the following list:</p>

    <dl class="switch"><dt>If <var>mode</var> is remote</dt><dd>
      <ol><li>
        <p>Optionally, run the following substeps. This is the expected behavior if the user agent
        intends to not attempt to fetch the resource until the user requests it explicitly (e.g. as
        a way to implement the <code id="loading-the-media-resource:attr-media-preload"><a href="#attr-media-preload">preload</a></code> attribute's <code id="loading-the-media-resource:attr-media-preload-none"><a href="#attr-media-preload-none">none</a></code> keyword).</p>

        <ol><li><p>Set the <code id="loading-the-media-resource:dom-media-networkstate-9"><a href="#dom-media-networkstate">networkState</a></code> to <code id="loading-the-media-resource:dom-media-network_idle-2"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code>.</p></li><li><p><a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-9">Queue a media element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-37">media element</a> to
         <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-7" data-x-internal="concept-event-fire">fire an event</a> named <code id="loading-the-media-resource:event-media-suspend"><a href="#event-media-suspend">suspend</a></code> at the element.</p></li><li><p><a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-10">Queue a media element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-38">media element</a> to set
         the element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-7">delaying-the-load-event flag</a> to false. This stops <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-7">delaying the load event</a>.</p></li><li><p>Wait for the task to be run.</p></li><li><p>Wait for an <a id="loading-the-media-resource:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> event (e.g., the user requesting
         that the media element begin playback).</p></li><li><p>Set the element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-8">delaying-the-load-event flag</a> back to true (this <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-8">delays the load event</a> again, in case it hasn't been fired
         yet).</p>

         </li><li><p>Set the <code id="loading-the-media-resource:dom-media-networkstate-10"><a href="#dom-media-networkstate">networkState</a></code> to <code id="loading-the-media-resource:dom-media-network_loading-4"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code>.</p></li></ol>
       </li><li><p>Let <var>destination</var> be "<code>audio</code>" if the <a href="#media-element" id="loading-the-media-resource:media-element-39">media
       element</a> is an <code id="loading-the-media-resource:the-audio-element"><a href="#the-audio-element">audio</a></code> element, or "<code>video</code>"
       otherwise.</p>

       </li><li><p>Let <var>request</var> be the result of <a href="#create-a-potential-cors-request" id="loading-the-media-resource:create-a-potential-cors-request">creating a potential-CORS request</a> given
       <var>current media resource</var>'s <a id="loading-the-media-resource:url-record-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a>, <var>destination</var>, and the
       current state of the <a href="#media-element" id="loading-the-media-resource:media-element-40">media element</a>'s
       <code id="loading-the-media-resource:attr-script-crossorigin"><a href="#attr-script-crossorigin">crossorigin</a></code> content attribute.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="loading-the-media-resource:concept-request-client" data-x-internal="concept-request-client">client</a> to the
       <a href="#media-element" id="loading-the-media-resource:media-element-41">media element</a>'s <a id="loading-the-media-resource:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#relevant-settings-object" id="loading-the-media-resource:relevant-settings-object-2">relevant settings
       object</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="loading-the-media-resource:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator
       type</a> to <var>destination</var>.</p></li><li><p>Let <var>byteRange</var>, which is "<code>entire resource</code>" or a
       (number, number or "<code>until end</code>") tuple, be the byte range required to satisfy
       missing data in <a href="#media-data" id="loading-the-media-resource:media-data">media data</a>. This value is <a id="loading-the-media-resource:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>
       and may rely on codec, network conditions or other heuristics. The user-agent may determine
       to fetch the resource in full, in which case <var>byteRange</var> would be
       "<code>entire resource</code>", to fetch from a byte offset until the end,
       in which case <var>byteRange</var> would be
       (number, "<code>until end</code>"), or to fetch a range between two byte offsets,
       in which case <var>byteRange</var> would be a (number, number) tuple representing the two
       offsets.</p></li><li>
        <p>If <var>byteRange</var> is not "<code>entire resource</code>", then:</p>
        <ol><li><p>If <var>byteRange</var>[1] is "<code>until end</code>", then
         <a id="loading-the-media-resource:add-a-range-header" href="https://fetch.spec.whatwg.org/#concept-request-add-range-header" data-x-internal="add-a-range-header">add a range header</a> to <var>request</var> given
         <var>byteRange</var>[0].</p></li><li><p>Otherwise, <a id="loading-the-media-resource:add-a-range-header-2" href="https://fetch.spec.whatwg.org/#concept-request-add-range-header" data-x-internal="add-a-range-header">add a range header</a> to <var>request</var> given
         <var>byteRange</var>[0] and <var>byteRange</var>[1].</p></li></ol>
       </li><li>
        <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="loading-the-media-resource:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var>, with
        <i id="loading-the-media-resource:processresponse"><a data-x-internal="processresponse" href="https://fetch.spec.whatwg.org/#process-response">processResponse</a></i> set to the following steps given
        <a href="https://fetch.spec.whatwg.org/#concept-response" id="loading-the-media-resource:concept-response-2" data-x-internal="concept-response">response</a> <var>response</var>:</p>

        <ol><li><p>Let <var>global</var> be the <a href="#media-element" id="loading-the-media-resource:media-element-42">media element</a>'s
         <a id="loading-the-media-resource:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#concept-relevant-global" id="loading-the-media-resource:concept-relevant-global">relevant global object</a>.</p></li><li><p>Let <var>updateMedia</var> be to <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-11">queue a media element task</a> given
         the <a href="#media-element" id="loading-the-media-resource:media-element-43">media element</a> to run the first appropriate steps from the
         <a href="#media-data-processing-steps-list" id="loading-the-media-resource:media-data-processing-steps-list">media data processing steps list</a> below. (A new task is used for
         this so that the work described below occurs relative to the appropriate
         <a href="#media-element-event-task-source" id="loading-the-media-resource:media-element-event-task-source-2">media element event task source</a> rather than using the
         <a href="#networking-task-source" id="loading-the-media-resource:networking-task-source">networking task source</a>.)</p>

         </li><li><p>Let <var>processEndOfMedia</var> be the following step: If the fetching process has
         completed without errors, including decoding the media data, and if all of the data is
         available to the user agent without network access, then, the user agent must move on to
         the <i>final step</i> below. This might never happen, e.g. when streaming an infinite
         resource such as web radio, or if the resource is longer than the user agent's ability to
         cache data.</p></li><li><p>If the result of <a href="#verify-a-media-response" id="loading-the-media-resource:verify-a-media-response">verifying</a>
         <var>response</var> given the <var>current media resource</var> and <var>byteRange</var>
         is false, then abort these steps.</p></li><li><p>Otherwise, <a href="https://fetch.spec.whatwg.org/#body-incrementally-read" id="loading-the-media-resource:body-incrementally-read" data-x-internal="body-incrementally-read">incrementally read</a>
         <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-body" id="loading-the-media-resource:concept-response-body" data-x-internal="concept-response-body">body</a> given
         <var>updateMedia</var>, <var>processEndOfMedia</var>, an empty algorithm, and
         <var>global</var>.</p></li><li><p>Update the <a href="#media-data" id="loading-the-media-resource:media-data-2">media data</a> with the contents of <var>response</var>'s
         <a href="#unsafe-response" id="loading-the-media-resource:unsafe-response-2">unsafe response</a> obtained in this fashion. <var>response</var> can be
         <a href="#cors-same-origin" id="loading-the-media-resource:cors-same-origin">CORS-same-origin</a> or <a href="#cors-cross-origin" id="loading-the-media-resource:cors-cross-origin-2">CORS-cross-origin</a>; this affects whether
         subtitles referenced in the <a href="#media-data" id="loading-the-media-resource:media-data-3">media data</a> are exposed in the API and, for
         <code id="loading-the-media-resource:the-video-element"><a href="#the-video-element">video</a></code> elements, whether a <code id="loading-the-media-resource:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> gets tainted when the video is
         drawn on it.</p></li></ol>

        <p>The <dfn id="stall-timeout" data-export="">media element stall timeout</dfn> is an
        <a id="loading-the-media-resource:implementation-defined-3" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> length of time, which should be about three seconds.
        When a <a href="#media-element" id="loading-the-media-resource:media-element-44">media element</a> that is actively attempting to obtain <a href="#media-data" id="loading-the-media-resource:media-data-4">media
        data</a> has failed to receive any data for a duration equal to the <a href="#stall-timeout" id="loading-the-media-resource:stall-timeout">media element
        stall timeout</a>, the user agent must <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-12">queue a media element task</a> given the
        <a href="#media-element" id="loading-the-media-resource:media-element-45">media element</a> to:</p>

        <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-8" data-x-internal="concept-event-fire">Fire an event</a> named <code id="loading-the-media-resource:event-media-stalled"><a href="#event-media-stalled">stalled</a></code> at the element.</p></li><li><p>Set the element's <a href="#is-currently-stalled" id="loading-the-media-resource:is-currently-stalled-2">is currently stalled</a> to true.</p></li></ol>

        <p>User agents may allow users to selectively block or slow <a href="#media-data" id="loading-the-media-resource:media-data-5">media data</a> downloads.
        When a <a href="#media-element" id="loading-the-media-resource:media-element-46">media element</a>'s download has been blocked altogether, the user agent must
        act as if it was stalled (as opposed to acting as if the connection was closed). The rate of the
        download may also be throttled automatically by the user agent, e.g. to balance the download
        with other connections sharing the same bandwidth.</p>

        <p id="resourceSuspend">User agents may decide to not download more content at any time,
        e.g. after buffering five minutes of a one hour media resource, while waiting for the user
        to decide whether to play the resource or not, while waiting for user input in an
        interactive resource, or when the user navigates away from the page. When a <a href="#media-element" id="loading-the-media-resource:media-element-47">media
        element</a>'s download has been suspended, the user agent must <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-13">queue a media
        element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-48">media element</a> to set the <code id="loading-the-media-resource:dom-media-networkstate-11"><a href="#dom-media-networkstate">networkState</a></code> to <code id="loading-the-media-resource:dom-media-network_idle-3"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code> and <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-9" data-x-internal="concept-event-fire">fire an event</a> named <code id="loading-the-media-resource:event-media-suspend-2"><a href="#event-media-suspend">suspend</a></code> at the element. If and when downloading of the
        resource resumes, the user agent must <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-14">queue a media element task</a> given the
        <a href="#media-element" id="loading-the-media-resource:media-element-49">media element</a> to set the <code id="loading-the-media-resource:dom-media-networkstate-12"><a href="#dom-media-networkstate">networkState</a></code> to <code id="loading-the-media-resource:dom-media-network_loading-5"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code>. Between the queuing of these
        tasks, the load is suspended (so <code id="loading-the-media-resource:event-media-progress"><a href="#event-media-progress">progress</a></code> events
        don't fire, as described above).</p>

        <p class="note">The <code id="loading-the-media-resource:attr-media-preload-2"><a href="#attr-media-preload">preload</a></code> attribute provides a hint
        regarding how much buffering the author thinks is advisable, even in the absence of the <code id="loading-the-media-resource:attr-media-autoplay"><a href="#attr-media-autoplay">autoplay</a></code> attribute.</p>

        <p>When a user agent decides to completely suspend a download, e.g., if it is waiting until
        the user starts playback before downloading any further content, the user agent must
        <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-15">queue a media element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-50">media element</a> to set the
        element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-9">delaying-the-load-event flag</a> to false. This stops <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-9">delaying the load event</a>.</p>

        <p>Although the above steps give an algorithm for issuing requests, the user agent may use
        other means besides those exact ones, especially in the face of error conditions. For
        example, the user agent may reconnect to the server or switch to a streaming protocol. The
        user agent must only consider the resource erroneous, and proceed into the error branches
        of the above steps, if the user agent has given up trying to fetch the resource.</p>

        <p>To determine the format of the <a href="#media-resource" id="loading-the-media-resource:media-resource-5">media resource</a>, the user agent must use the
        <a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-audio-and-video-specifically" id="loading-the-media-resource:content-type-sniffing:-video" data-x-internal="content-type-sniffing:-video">rules for sniffing audio and video specifically</a>.</p>

        <p>While the load is not suspended (see below), every 350ms (±200ms) or for every byte
        received, whichever is <em>least</em> frequent, <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-16">queue a media element task</a>
        given the <a href="#media-element" id="loading-the-media-resource:media-element-51">media element</a> to:

        </p><ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-10" data-x-internal="concept-event-fire">Fire an event</a> named <code id="loading-the-media-resource:event-media-progress-2"><a href="#event-media-progress">progress</a></code> at the element.</p></li><li><p>Set the element's <a href="#is-currently-stalled" id="loading-the-media-resource:is-currently-stalled-3">is currently stalled</a> to false.</p></li></ol>

        <p>While the user agent might still need network access to obtain parts of the <a href="#media-resource" id="loading-the-media-resource:media-resource-6">media
        resource</a>, the user agent must remain on this step.</p>

        <p class="example">For example, if the user agent has discarded the first half of a video, the
        user agent will remain at this step even once the <a href="#ended-playback" id="loading-the-media-resource:ended-playback">playback has
        ended</a>, because there is always the chance the user will seek back to the start. In fact,
        in this situation, once <a href="#ended-playback" id="loading-the-media-resource:ended-playback-2">playback has ended</a>, the user agent
        will end up firing a <code id="loading-the-media-resource:event-media-suspend-3"><a href="#event-media-suspend">suspend</a></code> event, as described
        earlier.</p>
       </li></ol>
     </dd><dt>Otherwise (<var>mode</var> is <i>local</i>)</dt><dd>
      <p>The resource described by the <var>current media resource</var>, if any, contains the
      <a href="#media-data" id="loading-the-media-resource:media-data-6">media data</a>. It is <a href="#cors-same-origin" id="loading-the-media-resource:cors-same-origin-2">CORS-same-origin</a>.</p>

      <p>If the <var>current media resource</var> is a raw data stream (e.g. from a
      <code id="loading-the-media-resource:file"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object), then to determine the format of the <a href="#media-resource" id="loading-the-media-resource:media-resource-7">media resource</a>,
      the user agent must use the <a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-audio-and-video-specifically" id="loading-the-media-resource:content-type-sniffing:-video-2" data-x-internal="content-type-sniffing:-video">rules for sniffing
      audio and video specifically</a>. Otherwise, if the data stream is pre-decoded, then the
      format is the format given by the relevant specification.</p>

      <p>Whenever new data for the <var>current media resource</var> becomes available, <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-17">queue
      a media element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-52">media element</a> to run the first appropriate
      steps from the <a href="#media-data-processing-steps-list" id="loading-the-media-resource:media-data-processing-steps-list-2">media data processing steps list</a> below.</p>

      <p>When the <var>current media resource</var> is permanently exhausted (e.g. all the bytes of
      a <code id="loading-the-media-resource:blob"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> have been processed), if there were no decoding errors, then the user
      agent must move on to the <i>final step</i> below. This might never happen, e.g. if the
      <var>current media resource</var> is a <code id="loading-the-media-resource:mediastream"><a data-x-internal="mediastream" href="https://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-mediastream">MediaStream</a></code>.</p>
     </dd></dl>

    <p>The <dfn id="media-data-processing-steps-list">media data processing steps list</dfn> is as follows:</p>

    <dl class="switch"><dt>If the <a href="#media-data" id="loading-the-media-resource:media-data-7">media data</a> cannot be fetched at all, due to network errors, causing the
     user agent to give up trying to fetch the resource</dt><dt>If the <a href="#media-data" id="loading-the-media-resource:media-data-8">media data</a> can be fetched but is found by inspection to be in an
     unsupported format, or can otherwise not be rendered at all</dt><dd>
      <p>DNS errors, HTTP 4xx and 5xx errors (and equivalents in other protocols), and other fatal
      network errors that occur before the user agent has established whether the <var>current media resource</var> is usable, as well as the file using an unsupported
      container format, or using unsupported codecs for all the data, must cause the user agent to
      execute the following steps:</p>

      <ol><li><p>The user agent should cancel the fetching process.</p></li><li><p>Abort this subalgorithm, returning to the <a href="#concept-media-load-algorithm" id="loading-the-media-resource:concept-media-load-algorithm-3">resource selection algorithm</a>.</p>
      </li></ol>
     </dd><dt id="found-another-audio-track">If the <a href="#media-resource" id="loading-the-media-resource:media-resource-8">media resource</a> is found to have an audio
     track</dt><dd>
      <ol><li><p>Create an <code id="loading-the-media-resource:audiotrack"><a href="#audiotrack">AudioTrack</a></code> object to represent the audio track.</p></li><li><p>Update the <a href="#media-element" id="loading-the-media-resource:media-element-53">media element</a>'s <code id="loading-the-media-resource:dom-media-audiotracks"><a href="#dom-media-audiotracks">audioTracks</a></code> attribute's <code id="loading-the-media-resource:audiotracklist"><a href="#audiotracklist">AudioTrackList</a></code>
       object with the new <code id="loading-the-media-resource:audiotrack-2"><a href="#audiotrack">AudioTrack</a></code> object.</p></li><li><p>Let <var>enable</var> be <i>unknown</i>.</p></li><li>
        <p>If either the <a href="#media-resource" id="loading-the-media-resource:media-resource-9">media resource</a> or the <a id="loading-the-media-resource:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the <var>current
        media resource</var> indicate a particular set of audio tracks to enable, or if the user
        agent has information that would facilitate the selection of specific audio tracks to
        improve the user's experience, then: if this audio track is one of the ones to enable, then
        set <var>enable</var> to <i>true</i>, otherwise, set <var>enable</var>
        to <i>false</i>.</p>

        <p class="example">This could be triggered by <a id="loading-the-media-resource:media-fragment-syntax" href="https://www.w3.org/TR/media-frags/#media-fragment-syntax" data-x-internal="media-fragment-syntax">media fragment syntax</a>, but it
        could also be triggered e.g. by the user agent selecting a 5.1 surround sound audio track
        over a stereo audio track.</p>
       </li><li><p>If <var>enable</var> is still <i>unknown</i>, then, if the <a href="#media-element" id="loading-the-media-resource:media-element-54">media
       element</a> does not yet have an <a href="#dom-audiotrack-enabled" id="loading-the-media-resource:dom-audiotrack-enabled">enabled</a>
       audio track, then set <var>enable</var> to <i>true</i>, otherwise, set <var>enable</var> to <i>false</i>.</p></li><li><p>If <var>enable</var> is <i>true</i>, then enable this audio track,
       otherwise, do not enable this audio track.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-11" data-x-internal="concept-event-fire">Fire an event</a> named <code id="loading-the-media-resource:event-media-addtrack"><a href="#event-media-addtrack">addtrack</a></code> at this <code id="loading-the-media-resource:audiotracklist-2"><a href="#audiotracklist">AudioTrackList</a></code> object,
       using <code id="loading-the-media-resource:trackevent"><a href="#trackevent">TrackEvent</a></code>, with the <code id="loading-the-media-resource:dom-trackevent-track"><a href="#dom-trackevent-track">track</a></code>
       attribute initialized to the new <code id="loading-the-media-resource:audiotrack-3"><a href="#audiotrack">AudioTrack</a></code> object.</p></li></ol>
     </dd><dt id="found-another-video-track">If the <a href="#media-resource" id="loading-the-media-resource:media-resource-10">media resource</a> is found to have a video
     track</dt><dd>
      <ol><li><p>Create a <code id="loading-the-media-resource:videotrack"><a href="#videotrack">VideoTrack</a></code> object to represent the video track.</p></li><li><p>Update the <a href="#media-element" id="loading-the-media-resource:media-element-55">media element</a>'s <code id="loading-the-media-resource:dom-media-videotracks"><a href="#dom-media-videotracks">videoTracks</a></code> attribute's <code id="loading-the-media-resource:videotracklist"><a href="#videotracklist">VideoTrackList</a></code>
       object with the new <code id="loading-the-media-resource:videotrack-2"><a href="#videotrack">VideoTrack</a></code> object.</p></li><li><p>Let <var>enable</var> be <i>unknown</i>.</p></li><li>
        <p>If either the <a href="#media-resource" id="loading-the-media-resource:media-resource-11">media resource</a> or the <a id="loading-the-media-resource:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the <var>current
        media resource</var> indicate a particular set of video tracks to enable, or if the user
        agent has information that would facilitate the selection of specific video tracks to
        improve the user's experience, then: if this video track is the first such video track, then
        set <var>enable</var> to <i>true</i>, otherwise, set <var>enable</var>
        to <i>false</i>.</p>

        <p class="example">This could again be triggered by <a id="loading-the-media-resource:media-fragment-syntax-2" href="https://www.w3.org/TR/media-frags/#media-fragment-syntax" data-x-internal="media-fragment-syntax">media fragment syntax</a>.</p>
       </li><li><p>If <var>enable</var> is still <i>unknown</i>, then, if the <a href="#media-element" id="loading-the-media-resource:media-element-56">media
       element</a> does not yet have a <a href="#dom-videotrack-selected" id="loading-the-media-resource:dom-videotrack-selected">selected</a>
       video track, then set <var>enable</var> to <i>true</i>, otherwise, set <var>enable</var> to <i>false</i>.</p></li><li><p>If <var>enable</var> is <i>true</i>, then select this track and unselect any
       previously selected video tracks, otherwise, do not select this video track. If other tracks
       are unselected, then <a href="#toggle-video-track">a <code>change</code> event will be fired</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-12" data-x-internal="concept-event-fire">Fire an event</a> named <code id="loading-the-media-resource:event-media-addtrack-2"><a href="#event-media-addtrack">addtrack</a></code> at this <code id="loading-the-media-resource:videotracklist-2"><a href="#videotracklist">VideoTrackList</a></code> object,
       using <code id="loading-the-media-resource:trackevent-2"><a href="#trackevent">TrackEvent</a></code>, with the <code id="loading-the-media-resource:dom-trackevent-track-2"><a href="#dom-trackevent-track">track</a></code>
       attribute initialized to the new <code id="loading-the-media-resource:videotrack-3"><a href="#videotrack">VideoTrack</a></code> object.</p></li></ol>
     </dd><dt id="getting-media-metadata">Once enough of the <a href="#media-data" id="loading-the-media-resource:media-data-9">media data</a> has been fetched to
     determine the duration of the <a href="#media-resource" id="loading-the-media-resource:media-resource-12">media resource</a>, its dimensions, and other
     metadata</dt><dd>
      <p>This indicates that the resource is usable. The user agent must follow these substeps:</p>

      <ol><li>
        <p><a href="#defineTimeline" id="loading-the-media-resource:defineTimeline">Establish the media timeline</a> for the purposes of the <a href="#current-playback-position" id="loading-the-media-resource:current-playback-position-2">current playback
        position</a> and the <a href="#earliest-possible-position" id="loading-the-media-resource:earliest-possible-position">earliest possible position</a>, based on the <a href="#media-data" id="loading-the-media-resource:media-data-10">media data</a>.</p>
       </li><li>
        <p>Update the <a href="#timeline-offset" id="loading-the-media-resource:timeline-offset-2">timeline offset</a> to the date and time that corresponds to the zero
        time in the <a href="#media-timeline" id="loading-the-media-resource:media-timeline">media timeline</a> established in the previous step, if any. If no
        explicit time and date is given by the <a href="#media-resource" id="loading-the-media-resource:media-resource-13">media resource</a>, the <a href="#timeline-offset" id="loading-the-media-resource:timeline-offset-3">timeline
        offset</a> must be set to Not-a-Number (NaN).</p>
       </li><li><p>Set the <a href="#current-playback-position" id="loading-the-media-resource:current-playback-position-3">current playback position</a> and the <a href="#official-playback-position" id="loading-the-media-resource:official-playback-position-3">official playback
       position</a> to the <a href="#earliest-possible-position" id="loading-the-media-resource:earliest-possible-position-2">earliest possible position</a>.</p></li><li>
        <p>Update the <code id="loading-the-media-resource:dom-media-duration-2"><a href="#dom-media-duration">duration</a></code> attribute with the time of
        the last frame of the resource, if known, on the <a href="#media-timeline" id="loading-the-media-resource:media-timeline-2">media timeline</a> established
        above. If it is not known (e.g. a stream that is in principle infinite), update the <code id="loading-the-media-resource:dom-media-duration-3"><a href="#dom-media-duration">duration</a></code> attribute to the value positive Infinity.</p>

        <p class="note">The user agent <a href="#durationChange">will</a> <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-18">queue a media
        element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-57">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-13" data-x-internal="concept-event-fire">fire an event</a> named <code id="loading-the-media-resource:event-media-durationchange-2"><a href="#event-media-durationchange">durationchange</a></code> at the element at this point.</p>
       </li><li>
        <p>For <code id="loading-the-media-resource:the-video-element-2"><a href="#the-video-element">video</a></code> elements, set the <code id="loading-the-media-resource:dom-video-videowidth"><a href="#dom-video-videowidth">videoWidth</a></code> and <code id="loading-the-media-resource:dom-video-videoheight"><a href="#dom-video-videoheight">videoHeight</a></code> attributes, and <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-19">queue a media
        element task</a> given the <a href="#media-element" id="loading-the-media-resource:media-element-58">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-14" data-x-internal="concept-event-fire">fire an event</a> named <code id="loading-the-media-resource:event-media-resize"><a href="#event-media-resize">resize</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-59">media element</a>.</p>

        <p class="note">Further <code id="loading-the-media-resource:event-media-resize-2"><a href="#event-media-resize">resize</a></code> events will be fired
        if the dimensions subsequently change.</p>
       </li><li>
        <p>Set the <code id="loading-the-media-resource:dom-media-readystate-2"><a href="#dom-media-readystate">readyState</a></code> attribute to <code id="loading-the-media-resource:dom-media-have_metadata"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code>.</p>

        <p class="note">A <code id="loading-the-media-resource:event-media-loadedmetadata"><a href="#event-media-loadedmetadata">loadedmetadata</a></code> DOM event
        <a href="#fire-loadedmetadata">will be fired</a> as part of setting the <code id="loading-the-media-resource:dom-media-readystate-3"><a href="#dom-media-readystate">readyState</a></code> attribute to a new value.</p>
       </li><li><p>Let <var>jumped</var> be false.</p></li><li><p>If the <a href="#media-element" id="loading-the-media-resource:media-element-60">media element</a>'s <a href="#default-playback-start-position" id="loading-the-media-resource:default-playback-start-position">default playback start position</a> is
       greater than zero, then <a href="#dom-media-seek" id="loading-the-media-resource:dom-media-seek">seek</a> to that time, and let <var>jumped</var> be true.</p></li><li><p>Set the <a href="#media-element" id="loading-the-media-resource:media-element-61">media element</a>'s <a href="#default-playback-start-position" id="loading-the-media-resource:default-playback-start-position-2">default playback
       start position</a> to zero.</p></li><li><p>Let the <var>initial playback position</var> be 0.</p></li><li>
        <p>If either the <a href="#media-resource" id="loading-the-media-resource:media-resource-14">media resource</a> or the <a id="loading-the-media-resource:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the <var>current
        media resource</var> indicate a particular start time, then set the <var>initial playback
        position</var> to that time and, if <var>jumped</var> is still false, <a href="#dom-media-seek" id="loading-the-media-resource:dom-media-seek-2">seek</a> to that time.</p>

        <p class="example">For example, with media formats that support <a id="loading-the-media-resource:media-fragment-syntax-3" href="https://www.w3.org/TR/media-frags/#media-fragment-syntax" data-x-internal="media-fragment-syntax">media fragment
        syntax</a>, the <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="loading-the-media-resource:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> can be used to
        indicate a start position.</p>
       </li><li><p>If there is no <a href="#dom-audiotrack-enabled" id="loading-the-media-resource:dom-audiotrack-enabled-2">enabled</a> audio track, then
       enable an audio track. This <a href="#toggle-audio-track">will cause a <code>change</code> event to be fired</a>.</p></li><li><p>If there is no <a href="#dom-videotrack-selected" id="loading-the-media-resource:dom-videotrack-selected-2">selected</a> video track,
       then select a video track. This <a href="#toggle-video-track">will cause a <code>change</code> event to be fired</a>.</p></li></ol>

      <p>Once the <code id="loading-the-media-resource:dom-media-readystate-4"><a href="#dom-media-readystate">readyState</a></code> attribute reaches <code id="loading-the-media-resource:dom-media-have_current_data"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code>, <a href="#fire-loadeddata">after
      the <code>loadeddata</code> event has been fired</a>, set the
      element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-10">delaying-the-load-event flag</a> to false. This stops <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-10">delaying the load event</a>.</p>

      <p class="note">A user agent that is attempting to reduce network usage while still fetching
      the metadata for each <a href="#media-resource" id="loading-the-media-resource:media-resource-15">media resource</a> would also stop buffering at this point,
      following <a href="#resourceSuspend">the rules described previously</a>, which involve the
      <code id="loading-the-media-resource:dom-media-networkstate-13"><a href="#dom-media-networkstate">networkState</a></code> attribute switching to the <code id="loading-the-media-resource:dom-media-network_idle-4"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code> value and a <code id="loading-the-media-resource:event-media-suspend-4"><a href="#event-media-suspend">suspend</a></code> event firing.</p>

      <p class="note">The user agent is <em>required</em> to determine the duration of the
      <a href="#media-resource" id="loading-the-media-resource:media-resource-16">media resource</a> and go through this step before playing.</p> 
     </dd><dt>Once the entire <a href="#media-resource" id="loading-the-media-resource:media-resource-17">media resource</a> has been fetched (but potentially before any of
     it has been decoded)</dt><dd>
      <p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-15" data-x-internal="concept-event-fire">Fire an event</a> named <code id="loading-the-media-resource:event-media-progress-3"><a href="#event-media-progress">progress</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-62">media element</a>.</p>

      <p>Set the <code id="loading-the-media-resource:dom-media-networkstate-14"><a href="#dom-media-networkstate">networkState</a></code> to <code id="loading-the-media-resource:dom-media-network_idle-5"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code> and <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-16" data-x-internal="concept-event-fire">fire an event</a> named
      <code id="loading-the-media-resource:event-media-suspend-5"><a href="#event-media-suspend">suspend</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-63">media element</a>.</p>

      <p>If the user agent ever discards any <a href="#media-data" id="loading-the-media-resource:media-data-11">media data</a> and then needs to resume the
      network activity to obtain it again, then it must <a href="#queue-a-media-element-task" id="loading-the-media-resource:queue-a-media-element-task-20">queue a media element task</a>
      given the <a href="#media-element" id="loading-the-media-resource:media-element-64">media element</a> to set the <code id="loading-the-media-resource:dom-media-networkstate-15"><a href="#dom-media-networkstate">networkState</a></code> to <code id="loading-the-media-resource:dom-media-network_loading-6"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code>.</p>

      <p class="note">If the user agent can keep the <a href="#media-resource" id="loading-the-media-resource:media-resource-18">media resource</a> loaded, then the
      algorithm will continue to its <i>final step</i> below, which aborts the algorithm.</p>
     </dd><dt>If the connection is interrupted after some <a href="#media-data" id="loading-the-media-resource:media-data-12">media data</a> has been received,
     causing the user agent to give up trying to fetch the resource</dt><dd>
      <p>Fatal network errors that occur after the user agent has established whether the <var>current media resource</var> is usable (i.e. once the <a href="#media-element" id="loading-the-media-resource:media-element-65">media element</a>'s
      <code id="loading-the-media-resource:dom-media-readystate-5"><a href="#dom-media-readystate">readyState</a></code> attribute is no longer <code id="loading-the-media-resource:dom-media-have_nothing-2"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>) must cause the user agent to execute the
      following steps:</p>

      <ol><li><p>The user agent should cancel the fetching process.</p></li><li><p>Set the <code id="loading-the-media-resource:dom-media-error-3"><a href="#dom-media-error">error</a></code> attribute to the result of
       <a href="#creating-a-mediaerror" id="loading-the-media-resource:creating-a-mediaerror-2">creating a <code>MediaError</code></a> with <code id="loading-the-media-resource:dom-mediaerror-media_err_network"><a href="#dom-mediaerror-media_err_network">MEDIA_ERR_NETWORK</a></code>.</p></li><li><p>Set the element's <code id="loading-the-media-resource:dom-media-networkstate-16"><a href="#dom-media-networkstate">networkState</a></code> attribute
       to the <code id="loading-the-media-resource:dom-media-network_idle-6"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code> value.</p></li><li><p>Set the element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-11">delaying-the-load-event flag</a> to false. This stops <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-11">delaying the load event</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-17" data-x-internal="concept-event-fire">Fire an event</a> named <code id="loading-the-media-resource:event-media-error-2"><a href="#event-media-error">error</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-66">media element</a>.</p></li><li><p>Abort the overall <a href="#concept-media-load-algorithm" id="loading-the-media-resource:concept-media-load-algorithm-4">resource selection
       algorithm</a>.</p></li></ol>
     </dd><dt id="fatal-decode-error">If the <a href="#media-data" id="loading-the-media-resource:media-data-13">media data</a> is corrupted</dt><dd>
      <p>Fatal errors in decoding the <a href="#media-data" id="loading-the-media-resource:media-data-14">media data</a> that occur after the user agent has
      established whether the <var>current media resource</var> is usable (i.e. once the <a href="#media-element" id="loading-the-media-resource:media-element-67">media element</a>'s
      <code id="loading-the-media-resource:dom-media-readystate-6"><a href="#dom-media-readystate">readyState</a></code> attribute is no longer <code id="loading-the-media-resource:dom-media-have_nothing-3"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>) must cause the
      user agent to execute the following steps:</p>

      <ol><li><p>The user agent should cancel the fetching process.</p></li><li><p>Set the <code id="loading-the-media-resource:dom-media-error-4"><a href="#dom-media-error">error</a></code> attribute to the result of
       <a href="#creating-a-mediaerror" id="loading-the-media-resource:creating-a-mediaerror-3">creating a <code>MediaError</code></a> with <code id="loading-the-media-resource:dom-mediaerror-media_err_decode"><a href="#dom-mediaerror-media_err_decode">MEDIA_ERR_DECODE</a></code>.</p></li><li><p>Set the element's <code id="loading-the-media-resource:dom-media-networkstate-17"><a href="#dom-media-networkstate">networkState</a></code> attribute
       to the <code id="loading-the-media-resource:dom-media-network_idle-7"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code> value.</p></li><li><p>Set the element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-12">delaying-the-load-event flag</a> to false. This stops <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-12">delaying the load event</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-18" data-x-internal="concept-event-fire">Fire an event</a> named <code id="loading-the-media-resource:event-media-error-3"><a href="#event-media-error">error</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-68">media element</a>.</p></li><li><p>Abort the overall <a href="#concept-media-load-algorithm" id="loading-the-media-resource:concept-media-load-algorithm-5">resource selection
       algorithm</a>.</p></li></ol>
     </dd><dt>If the <a href="#media-data" id="loading-the-media-resource:media-data-15">media data</a> fetching process is aborted by the user</dt><dd>
      <p>The fetching process is aborted by the user, e.g. because the user
      pressed a "stop" button, the user agent must execute the following steps. These steps are not
      followed if the <code id="loading-the-media-resource:dom-media-load"><a href="#dom-media-load">load()</a></code> method itself is invoked while
      these steps are running, as the steps above handle that particular kind of abort.</p>

      <ol><li><p>The user agent should cancel the fetching process.</p></li><li><p>Set the <code id="loading-the-media-resource:dom-media-error-5"><a href="#dom-media-error">error</a></code> attribute to the result of
       <a href="#creating-a-mediaerror" id="loading-the-media-resource:creating-a-mediaerror-4">creating a <code>MediaError</code></a> with <code id="loading-the-media-resource:dom-mediaerror-media_err_aborted"><a href="#dom-mediaerror-media_err_aborted">MEDIA_ERR_ABORTED</a></code>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-19" data-x-internal="concept-event-fire">Fire an event</a> named <code id="loading-the-media-resource:event-media-abort-2"><a href="#event-media-abort">abort</a></code> at the <a href="#media-element" id="loading-the-media-resource:media-element-69">media element</a>.</p></li><li>
        <p>If the <a href="#media-element" id="loading-the-media-resource:media-element-70">media element</a>'s <code id="loading-the-media-resource:dom-media-readystate-7"><a href="#dom-media-readystate">readyState</a></code>
        attribute has a value equal to <code id="loading-the-media-resource:dom-media-have_nothing-4"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>, set
        the element's <code id="loading-the-media-resource:dom-media-networkstate-18"><a href="#dom-media-networkstate">networkState</a></code> attribute to the
        <code id="loading-the-media-resource:dom-media-network_empty-3"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code> value, set the element's
        <a href="#show-poster-flag" id="loading-the-media-resource:show-poster-flag-4">show poster flag</a> to true, and <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-the-media-resource:concept-event-fire-20" data-x-internal="concept-event-fire">fire an
        event</a> named <code id="loading-the-media-resource:event-media-emptied-2"><a href="#event-media-emptied">emptied</a></code> at the element.</p>

        <p>Otherwise, set the element's <code id="loading-the-media-resource:dom-media-networkstate-19"><a href="#dom-media-networkstate">networkState</a></code>
        attribute to the <code id="loading-the-media-resource:dom-media-network_idle-8"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code> value.</p>
       </li><li><p>Set the element's <a href="#delaying-the-load-event-flag" id="loading-the-media-resource:delaying-the-load-event-flag-13">delaying-the-load-event flag</a> to false. This stops <a href="#delay-the-load-event" id="loading-the-media-resource:delay-the-load-event-13">delaying the load event</a>.</p></li><li><p>Abort the overall <a href="#concept-media-load-algorithm" id="loading-the-media-resource:concept-media-load-algorithm-6">resource selection
       algorithm</a>.</p></li></ol>
     </dd><dt id="non-fatal-media-error">If the <a href="#media-data" id="loading-the-media-resource:media-data-16">media data</a> can be fetched but has non-fatal
     errors or uses, in part, codecs that are unsupported, preventing the user agent from rendering
     the content completely correctly but not preventing playback altogether</dt><dd>
      <p>The server returning data that is partially usable but cannot be optimally rendered must
      cause the user agent to render just the bits it can handle, and ignore the rest.</p>

      
     </dd><dt id="found-a-media-resource-specific-timed-track">If the <a href="#media-resource" id="loading-the-media-resource:media-resource-19">media resource</a> is
     found to declare a <a href="#media-resource-specific-text-track" id="loading-the-media-resource:media-resource-specific-text-track-2">media-resource-specific text track</a> that the user agent
     supports</dt><dd>
      <p>If the <a href="#media-data" id="loading-the-media-resource:media-data-17">media data</a> is <a href="#cors-same-origin" id="loading-the-media-resource:cors-same-origin-3">CORS-same-origin</a>, run the <a href="#steps-to-expose-a-media-resource-specific-text-track" id="loading-the-media-resource:steps-to-expose-a-media-resource-specific-text-track">steps to
      expose a media-resource-specific text track</a> with the relevant data.</p>

      <p class="note">Cross-origin videos do not expose their subtitles, since that would allow
      attacks such as hostile sites reading subtitles from confidential videos on a user's
      intranet.</p>
     </dd></dl>
   </li><li><p><i>Final step</i>: If the user agent ever reaches this step (which can only happen if the entire resource
   gets loaded and kept available): abort the overall <a href="#concept-media-load-algorithm" id="loading-the-media-resource:concept-media-load-algorithm-7">resource selection algorithm</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#media-element" id="loading-the-media-resource:media-element-71">media element</a> is to <dfn id="forget-the-media-element's-media-resource-specific-tracks">forget the media element's media-resource-specific
  tracks</dfn>, the user agent must remove from the <a href="#media-element" id="loading-the-media-resource:media-element-72">media element</a>'s <a href="#list-of-text-tracks" id="loading-the-media-resource:list-of-text-tracks">list of text
  tracks</a> all the <a href="#media-resource-specific-text-track" id="loading-the-media-resource:media-resource-specific-text-track-3">media-resource-specific
  text tracks</a>, then empty the <a href="#media-element" id="loading-the-media-resource:media-element-73">media element</a>'s <code id="loading-the-media-resource:dom-media-audiotracks-2"><a href="#dom-media-audiotracks">audioTracks</a></code> attribute's <code id="loading-the-media-resource:audiotracklist-3"><a href="#audiotracklist">AudioTrackList</a></code> object,
  then empty the <a href="#media-element" id="loading-the-media-resource:media-element-74">media element</a>'s <code id="loading-the-media-resource:dom-media-videotracks-2"><a href="#dom-media-videotracks">videoTracks</a></code>
  attribute's <code id="loading-the-media-resource:videotracklist-3"><a href="#videotracklist">VideoTrackList</a></code> object. No events (in particular, no <code id="loading-the-media-resource:event-media-removetrack"><a href="#event-media-removetrack">removetrack</a></code> events) are fired as part of this; the <code id="loading-the-media-resource:event-media-error-4"><a href="#event-media-error">error</a></code> and <code id="loading-the-media-resource:event-media-emptied-3"><a href="#event-media-emptied">emptied</a></code>
  events, fired by the algorithms that invoke this one, can be used instead.</p>
  </div>

  

  <hr>

  <p>The <dfn data-dfn-for="audio,video" id="attr-media-preload" data-dfn-type="element-attr"><code>preload</code></dfn>
  attribute is an <a href="#enumerated-attribute" id="loading-the-media-resource:enumerated-attribute">enumerated attribute</a> with the following keywords and
  states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="audio/preload,video/preload" id="attr-media-preload-auto" data-dfn-type="attr-value"><code>auto</code></dfn>
     </td><td><dfn id="attr-media-preload-auto-state">Automatic</dfn>
     </td><td>Hints to the user agent that the user agent can put the user's needs first without risk to the server, up to and including optimistically downloading the entire resource.
    </td></tr><tr><td><dfn data-dfn-for="audio/preload,video/preload" id="attr-media-preload-none" data-dfn-type="attr-value"><code>none</code></dfn>
     </td><td><dfn id="attr-media-preload-none-state">None</dfn>
     </td><td>Hints to the user agent that either the author does not expect the user to need the media resource, or that the server wants to minimize unnecessary traffic.
         This state does not provide a hint regarding how aggressively to actually download the media resource if buffering starts anyway (e.g. once the user hits "play").
    </td></tr><tr><td><dfn data-dfn-for="audio/preload,video/preload" id="attr-media-preload-metadata" data-dfn-type="attr-value"><code>metadata</code></dfn>
     </td><td><dfn id="attr-media-preload-metadata-state">Metadata</dfn>
     </td><td>Hints to the user agent that the author does not expect the user to need the media resource, but that fetching the resource metadata (dimensions, track list, duration, etc.), and maybe even the first few frames, is reasonable. If the user agent precisely fetches no more than the metadata, then the <a href="#media-element" id="loading-the-media-resource:media-element-75">media element</a> will end up with its <code id="loading-the-media-resource:dom-media-readystate-8"><a href="#dom-media-readystate">readyState</a></code> attribute set to <code id="loading-the-media-resource:dom-media-have_metadata-2"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code>; typically though, some frames will be obtained as well and it will probably be <code id="loading-the-media-resource:dom-media-have_current_data-2"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> or <code id="loading-the-media-resource:dom-media-have_future_data"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code>.
         When the media resource is playing, hints to the user agent that bandwidth is to be considered scarce, e.g. suggesting throttling the download so that the media data is obtained at the slowest possible rate that still maintains consistent playback.
  </td></tr></tbody></table>

  <p>The attribute's <i id="loading-the-media-resource:empty-value-default"><a href="#empty-value-default">empty value default</a></i> is the <a href="#attr-media-preload-auto-state" id="loading-the-media-resource:attr-media-preload-auto-state">Automatic</a> state.</p>

  <div data-algorithm="">
  <p>The attribute's <i id="loading-the-media-resource:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="loading-the-media-resource:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both
  <a id="loading-the-media-resource:implementation-defined-4" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>, though the <a href="#attr-media-preload-metadata-state" id="loading-the-media-resource:attr-media-preload-metadata-state">Metadata</a> state is suggested as a compromise
  between reducing server load and providing an optimal user experience.</p>
  </div>

  <p>The attribute can be changed even once the <a href="#media-resource" id="loading-the-media-resource:media-resource-20">media resource</a> is being buffered or
  played; the descriptions in the table above are to be interpreted with that in mind.</p>

  <p class="note">Authors might switch the attribute from "<code id="loading-the-media-resource:attr-media-preload-none-2"><a href="#attr-media-preload-none">none</a></code>" or "<code id="loading-the-media-resource:attr-media-preload-metadata"><a href="#attr-media-preload-metadata">metadata</a></code>" to "<code id="loading-the-media-resource:attr-media-preload-auto"><a href="#attr-media-preload-auto">auto</a></code>" dynamically once the user begins playback. For
  example, on a page with many videos this might be used to indicate that the many videos are not to
  be downloaded unless requested, but that once one <em>is</em> requested it is to be downloaded
  aggressively.</p>

  

  <p>The <code id="loading-the-media-resource:attr-media-preload-3"><a href="#attr-media-preload">preload</a></code> attribute is intended to provide a hint to
  the user agent about what the author thinks will lead to the best user experience. The attribute
  may be ignored altogether, for example based on explicit user preferences or based on the
  available connectivity.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-preload" data-dfn-type="attribute"><code>preload</code></dfn>
  IDL attribute must <a href="#reflect" id="loading-the-media-resource:reflect">reflect</a> the content attribute of the same name, <a href="#limited-to-only-known-values" id="loading-the-media-resource:limited-to-only-known-values">limited to
  only known values</a>.</p>
  </div>

  

  <p class="note">The <code id="loading-the-media-resource:attr-media-autoplay-2"><a href="#attr-media-autoplay">autoplay</a></code> attribute can override the
  <code id="loading-the-media-resource:attr-media-preload-4"><a href="#attr-media-preload">preload</a></code> attribute (since if the media plays, it naturally
  has to buffer first, regardless of the hint given by the <code id="loading-the-media-resource:attr-media-preload-5"><a href="#attr-media-preload">preload</a></code> attribute). Including both is not an error, however.</p>

  <hr>



  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-buffered" id="dom-media-buffered-dev">buffered</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/buffered" title="The buffered read-only property of HTMLMediaElement objects returns a new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent has buffered at the moment the buffered property is accessed.">HTMLMediaElement/buffered</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="loading-the-media-resource:timeranges"><a href="#timeranges">TimeRanges</a></code> object that represents the ranges of the <a href="#media-resource" id="loading-the-media-resource:media-resource-21">media
    resource</a> that the user agent has buffered.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-buffered" data-dfn-type="attribute"><code>buffered</code></dfn> attribute must return a new static
  <a href="#normalised-timeranges-object" id="loading-the-media-resource:normalised-timeranges-object">normalized <code>TimeRanges</code> object</a> that represents the ranges of the
  <a href="#media-resource" id="loading-the-media-resource:media-resource-22">media resource</a>, if any, that the user agent has buffered, at the time the attribute
  is evaluated. User agents must accurately determine the ranges available, even for media streams
  where this can only be determined by tedious inspection.</p>
  </div>

  <p class="note">Typically this will be a single range anchored at the zero point, but if, e.g. the
  user agent uses HTTP range requests in response to seeking, then there could be multiple
  ranges.</p>

  <p>User agents may discard previously buffered data.</p>

  <p class="note">Thus, a time position included within a range of the objects return by the <code id="loading-the-media-resource:dom-media-buffered"><a href="#dom-media-buffered">buffered</a></code> attribute at one time can end up being not included in
  the range(s) of objects returned by the same attribute at later times.</p>

  <p class="warning">Returning a new object each time is a bad pattern for attribute getters and is
  only enshrined here as it would be costly to change it. It is not to be copied to new APIs.</p>

  



  <h5 id="offsets-into-the-media-resource"><span class="secno">4.8.11.6</span> Offsets into the media resource<a href="#offsets-into-the-media-resource" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-duration" id="dom-media-duration-dev">duration</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/duration" title="The read-only HTMLMediaElement property duration indicates the length of the element's media in seconds.">HTMLMediaElement/duration</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the length of the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource">media resource</a>, in seconds, assuming that the start of
    the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-2">media resource</a> is at time zero.</p>

    <p>Returns NaN if the duration isn't available.</p>

    <p>Returns Infinity for unbounded streams.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-currenttime" id="dom-media-currenttime-dev">currentTime</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentTime" title="The HTMLMediaElement interface's currentTime property specifies the current playback time in seconds.">HTMLMediaElement/currentTime</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="#official-playback-position" id="offsets-into-the-media-resource:official-playback-position">official playback position</a>, in seconds.</p>

    <p>Can be set, to seek to the given time.</p>
   </dd></dl>

  

  <p>A <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-3">media resource</a> has a <dfn id="media-timeline">media timeline</dfn> that maps times (in seconds) to
  positions in the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-4">media resource</a>. The origin of a timeline is its earliest defined
  position. The duration of a timeline is its last defined position.</p>

  <p><dfn id="defineTimeline">Establishing the media
  timeline</dfn>: if the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-5">media resource</a> somehow specifies an explicit timeline whose
  origin is not negative (i.e. gives each frame a specific time offset and gives the first frame a
  zero or positive offset), then the <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline">media timeline</a> should be that timeline. (Whether
  the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-6">media resource</a> can specify a timeline or not depends on the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-7">media resource's</a> format.) If the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-8">media resource</a> specifies an
  explicit start time <em>and date</em>, then that time and date should be considered the zero point
  in the <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-2">media timeline</a>; the <a href="#timeline-offset" id="offsets-into-the-media-resource:timeline-offset">timeline offset</a> will be the time and date,
  exposed using the <code id="offsets-into-the-media-resource:dom-media-getstartdate"><a href="#dom-media-getstartdate">getStartDate()</a></code> method.</p>

  <p>If the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-9">media resource</a> has a discontinuous timeline, the user agent must extend the
  timeline used at the start of the resource across the entire resource, so that the <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-3">media
  timeline</a> of the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-10">media resource</a> increases linearly starting from the
  <a href="#earliest-possible-position" id="offsets-into-the-media-resource:earliest-possible-position">earliest possible position</a> (as defined below), even if the underlying <a href="#media-data" id="offsets-into-the-media-resource:media-data">media
  data</a> has out-of-order or even overlapping time codes.</p>

  <p class="example">For example, if two clips have been concatenated into one video file, but the
  video format exposes the original times for the two clips, the video data might expose a timeline
  that goes, say, 00:15..00:29 and then 00:05..00:38. However, the user agent would not expose those
  times; it would instead expose the times as 00:15..00:29 and 00:29..01:02, as a single video.</p>

  <p>
  <a id="offsets-into-the-media-resource:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  In the rare case of a <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-11">media resource</a> that does not have an explicit timeline, the
  zero time on the <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-4">media timeline</a> should correspond to the first frame of the
  <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-12">media resource</a>. In the even rarer case of a <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-13">media resource</a> with no
  explicit timings of any kind, not even frame durations, the user agent must itself determine the
  time for each frame in an <a id="offsets-into-the-media-resource:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner.</p>

  <p class="note">An example of a file format with no explicit timeline but with explicit frame
  durations is the Animated GIF format. An example of a file format with no explicit timings at all
  is the JPEG-push format (<code id="offsets-into-the-media-resource:multipart/x-mixed-replace"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code> with JPEG frames, often
  used as the format for MJPEG streams).</p>

  <p>If, in the case of a resource with no timing information, the user agent will nonetheless be
  able to seek to an earlier point than the first frame originally provided by the server, then the
  zero time should correspond to the earliest seekable time of the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-14">media resource</a>;
  otherwise, it should correspond to the first frame received from the server (the point in the
  <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-15">media resource</a> at which the user agent began receiving the stream).</p>

  <p class="note">At the time of writing, there is no known format that lacks explicit frame time
  offsets yet still supports seeking to a frame before the first frame sent by the server.</p>

  <div class="example">

   <p>Consider a stream from a TV broadcaster, which begins streaming on a sunny Friday afternoon in
   October, and always sends connecting user agents the media data on the same media timeline, with
   its zero time set to the start of this stream. Months later, user agents connecting to this
   stream will find that the first frame they receive has a time with millions of seconds. The <code id="offsets-into-the-media-resource:dom-media-getstartdate-2"><a href="#dom-media-getstartdate">getStartDate()</a></code> method would always return the date that the
   broadcast started; this would allow controllers to display real times in their scrubber (e.g.
   "2:30pm") rather than a time relative to when the broadcast began ("8 months, 4 hours, 12
   minutes, and 23 seconds").</p>

   <p>Consider a stream that carries a video with several concatenated fragments, broadcast by a
   server that does not allow user agents to request specific times but instead just streams the
   video data in a predetermined order, with the first frame delivered always being identified as
   the frame with time zero. If a user agent connects to this stream and receives fragments defined
   as covering timestamps 2010-03-20 23:15:00 UTC to 2010-03-21 00:05:00 UTC and 2010-02-12 14:25:00
   UTC to 2010-02-12 14:35:00 UTC, it would expose this with a <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-5">media timeline</a> starting
   at 0s and extending to 3,600s (one hour). Assuming the streaming server disconnected at the end
   of the second clip, the <code id="offsets-into-the-media-resource:dom-media-duration"><a href="#dom-media-duration">duration</a></code> attribute would then
   return 3,600. The <code id="offsets-into-the-media-resource:dom-media-getstartdate-3"><a href="#dom-media-getstartdate">getStartDate()</a></code> method would return a
   <code id="offsets-into-the-media-resource:date"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object with a time corresponding to 2010-03-20 23:15:00 UTC. However, if a
   different user agent connected five minutes later, <em>it</em> would (presumably) receive
   fragments covering timestamps 2010-03-20 23:20:00 UTC to 2010-03-21 00:05:00 UTC and 2010-02-12
   14:25:00 UTC to 2010-02-12 14:35:00 UTC, and would expose this with a <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-6">media timeline</a>
   starting at 0s and extending to 3,300s (fifty five minutes). In this case, the <code id="offsets-into-the-media-resource:dom-media-getstartdate-4"><a href="#dom-media-getstartdate">getStartDate()</a></code> method would return a <code id="offsets-into-the-media-resource:date-2"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object
   with a time corresponding to 2010-03-20 23:20:00 UTC.</p>

   <p>In both of these examples, the <code id="offsets-into-the-media-resource:dom-media-seekable"><a href="#dom-media-seekable">seekable</a></code> attribute
   would give the ranges that the controller would want to actually display in its UI; typically, if
   the servers don't support seeking to arbitrary times, this would be the range of time from the
   moment the user agent connected to the stream up to the latest frame that the user agent has
   obtained; however, if the user agent starts discarding earlier information, the actual range
   might be shorter.</p>

  </div>

  <p>In any case, the user agent must ensure that the <a href="#earliest-possible-position" id="offsets-into-the-media-resource:earliest-possible-position-2">earliest possible position</a> (as
  defined below) using the established <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-7">media timeline</a>, is greater than or equal to
  zero.</p>

  <p>The <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-8">media timeline</a> also has an associated clock. Which clock is used is user-agent
  defined, and may be <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-16">media resource</a>-dependent, but it should approximate the user's
  wall clock.</p>

  <p><a href="#media-element" id="offsets-into-the-media-resource:media-element">Media elements</a> have a <dfn id="current-playback-position">current playback position</dfn>,
  which must initially (i.e. in the absence of <a href="#media-data" id="offsets-into-the-media-resource:media-data-2">media data</a>) be zero seconds. The
  <a href="#current-playback-position" id="offsets-into-the-media-resource:current-playback-position">current playback position</a> is a time on the <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-9">media timeline</a>.</p>

  <p><a href="#media-element" id="offsets-into-the-media-resource:media-element-2">Media elements</a> also have an <dfn id="official-playback-position">official playback
  position</dfn>, which must initially be set to zero seconds. The <a href="#official-playback-position" id="offsets-into-the-media-resource:official-playback-position-2">official playback
  position</a> is an approximation of the <a href="#current-playback-position" id="offsets-into-the-media-resource:current-playback-position-2">current playback position</a> that is kept
  stable while scripts are running.</p>

  <p><a href="#media-element" id="offsets-into-the-media-resource:media-element-3">Media elements</a> also have a <dfn id="default-playback-start-position">default playback start
  position</dfn>, which must initially be set to zero seconds. This time is used to allow the
  element to be seeked even before the media is loaded.</p>

  <p>Each <a href="#media-element" id="offsets-into-the-media-resource:media-element-4">media element</a> has a <dfn id="show-poster-flag">show poster flag</dfn>. When a <a href="#media-element" id="offsets-into-the-media-resource:media-element-5">media
  element</a> is created, this flag must be set to true. This flag is used to control when the
  user agent is to show a poster frame for a <code id="offsets-into-the-media-resource:the-video-element"><a href="#the-video-element">video</a></code> element instead of showing the video
  contents.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-currenttime" data-dfn-type="attribute"><code>currentTime</code></dfn> attribute must, on getting, return the
  <a href="#media-element" id="offsets-into-the-media-resource:media-element-6">media element</a>'s <a href="#default-playback-start-position" id="offsets-into-the-media-resource:default-playback-start-position">default playback start position</a>, unless that is zero, in
  which case it must return the element's <a href="#official-playback-position" id="offsets-into-the-media-resource:official-playback-position-3">official playback position</a>. The returned
  value must be expressed in seconds. On setting, if the <a href="#media-element" id="offsets-into-the-media-resource:media-element-7">media element</a>'s <code id="offsets-into-the-media-resource:dom-media-readystate"><a href="#dom-media-readystate">readyState</a></code> is <code id="offsets-into-the-media-resource:dom-media-have_nothing"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>, then it must set the <a href="#media-element" id="offsets-into-the-media-resource:media-element-8">media
  element</a>'s <a href="#default-playback-start-position" id="offsets-into-the-media-resource:default-playback-start-position-2">default playback start position</a> to the new value; otherwise, it must
  set the <a href="#official-playback-position" id="offsets-into-the-media-resource:official-playback-position-4">official playback position</a> to the new value and then <a href="#dom-media-seek" id="offsets-into-the-media-resource:dom-media-seek">seek</a> to the new value. The new value must be interpreted as being
  in seconds.</p>
  </div>

  <p>If the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-17">media resource</a> is a streaming resource, then the user agent might be unable
  to obtain certain parts of the resource after it has expired from its buffer. Similarly, some
  <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-18">media resources</a> might have a <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-10">media timeline</a> that
  doesn't start at zero. The <dfn id="earliest-possible-position">earliest possible position</dfn> is the earliest position in the
  stream or resource that the user agent can ever obtain again. It is also a time on the <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-11">media
  timeline</a>.</p>

  <p class="note">The <a href="#earliest-possible-position" id="offsets-into-the-media-resource:earliest-possible-position-3">earliest possible position</a> is not explicitly exposed in the API;
  it corresponds to the start time of the first range in the <code id="offsets-into-the-media-resource:dom-media-seekable-2"><a href="#dom-media-seekable">seekable</a></code> attribute's <code id="offsets-into-the-media-resource:timeranges"><a href="#timeranges">TimeRanges</a></code> object, if any, or
  the <a href="#current-playback-position" id="offsets-into-the-media-resource:current-playback-position-3">current playback position</a> otherwise.</p>

  <div data-algorithm="">
  <p>When the <a href="#earliest-possible-position" id="offsets-into-the-media-resource:earliest-possible-position-4">earliest possible position</a> changes, then: if the <a href="#current-playback-position" id="offsets-into-the-media-resource:current-playback-position-4">current playback
  position</a> is before the <a href="#earliest-possible-position" id="offsets-into-the-media-resource:earliest-possible-position-5">earliest possible position</a>, the user agent must <a href="#dom-media-seek" id="offsets-into-the-media-resource:dom-media-seek-2">seek</a> to the <a href="#earliest-possible-position" id="offsets-into-the-media-resource:earliest-possible-position-6">earliest possible position</a>; otherwise, if
  the user agent has not fired a <code id="offsets-into-the-media-resource:event-media-timeupdate"><a href="#event-media-timeupdate">timeupdate</a></code> event at
  the element in the past 15 to 250ms and is not still running event handlers for such an event,
  then the user agent must <a href="#queue-a-media-element-task" id="offsets-into-the-media-resource:queue-a-media-element-task">queue a media element task</a> given the <a href="#media-element" id="offsets-into-the-media-resource:media-element-9">media
  element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="offsets-into-the-media-resource:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="offsets-into-the-media-resource:event-media-timeupdate-2"><a href="#event-media-timeupdate">timeupdate</a></code> at the element.</p>
  </div>

  <p class="note">Because of the above requirement and the requirement in the <a href="#concept-media-load-resource" id="offsets-into-the-media-resource:concept-media-load-resource">resource fetch algorithm</a> that kicks in <a href="#getting-media-metadata">when the metadata of the clip becomes known</a>, the <a href="#current-playback-position" id="offsets-into-the-media-resource:current-playback-position-5">current
  playback position</a> can never be less than the <a href="#earliest-possible-position" id="offsets-into-the-media-resource:earliest-possible-position-7">earliest possible position</a>.</p>

  
  

  <div data-algorithm="">
  <p>If at any time the user agent learns that an audio or video track has ended and all <a href="#media-data" id="offsets-into-the-media-resource:media-data-3">media
  data</a> relating to that track corresponds to parts of the <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-12">media timeline</a> that
  are <em>before</em> the <a href="#earliest-possible-position" id="offsets-into-the-media-resource:earliest-possible-position-8">earliest possible position</a>, the user agent may <a href="#queue-a-media-element-task" id="offsets-into-the-media-resource:queue-a-media-element-task-2">queue a
  media element task</a> given the <a href="#media-element" id="offsets-into-the-media-resource:media-element-10">media element</a> to run these steps:</p>

  <ol><li><p>Remove the track from the <code id="offsets-into-the-media-resource:dom-media-audiotracks"><a href="#dom-media-audiotracks">audioTracks</a></code>
   attribute's <code id="offsets-into-the-media-resource:audiotracklist"><a href="#audiotracklist">AudioTrackList</a></code> object or the <code id="offsets-into-the-media-resource:dom-media-videotracks"><a href="#dom-media-videotracks">videoTracks</a></code> attribute's <code id="offsets-into-the-media-resource:videotracklist"><a href="#videotracklist">VideoTrackList</a></code> object
   as appropriate.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="offsets-into-the-media-resource:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="offsets-into-the-media-resource:event-media-removetrack"><a href="#event-media-removetrack">removetrack</a></code> at the <a href="#media-element" id="offsets-into-the-media-resource:media-element-11">media element</a>'s
   aforementioned <code id="offsets-into-the-media-resource:audiotracklist-2"><a href="#audiotracklist">AudioTrackList</a></code> or <code id="offsets-into-the-media-resource:videotracklist-2"><a href="#videotracklist">VideoTrackList</a></code> object, using
   <code id="offsets-into-the-media-resource:trackevent"><a href="#trackevent">TrackEvent</a></code>, with the <code id="offsets-into-the-media-resource:dom-trackevent-track"><a href="#dom-trackevent-track">track</a></code> attribute
   initialized to the <code id="offsets-into-the-media-resource:audiotrack"><a href="#audiotrack">AudioTrack</a></code> or <code id="offsets-into-the-media-resource:videotrack"><a href="#videotrack">VideoTrack</a></code> object representing the
   track.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-duration" data-dfn-type="attribute"><code>duration</code></dfn> attribute must return the time of the end of the
  <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-19">media resource</a>, in seconds, on the <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-13">media timeline</a>. If no <a href="#media-data" id="offsets-into-the-media-resource:media-data-4">media
  data</a> is available, then the attributes must return the Not-a-Number (NaN) value. If the
  <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-20">media resource</a> is not known to be bounded (e.g. streaming radio, or a live event with
  no announced end time), then the attribute must return the positive Infinity value.</p>
  </div>

  <p>The user agent must determine the duration of the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-21">media resource</a> before playing
  any part of the <a href="#media-data" id="offsets-into-the-media-resource:media-data-5">media data</a> and before setting <code id="offsets-into-the-media-resource:dom-media-readystate-2"><a href="#dom-media-readystate">readyState</a></code> to a value greater than or equal to <code id="offsets-into-the-media-resource:dom-media-have_metadata"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code>, even if doing so requires fetching multiple
  parts of the resource.</p>

  <div data-algorithm="">
  <p id="durationChange">When the length of the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-22">media resource</a> changes to a known value
  (e.g. from being unknown to known, or from a previously established length to a new length), the
  user agent must <a href="#queue-a-media-element-task" id="offsets-into-the-media-resource:queue-a-media-element-task-3">queue a media element task</a> given the <a href="#media-element" id="offsets-into-the-media-resource:media-element-12">media element</a> to
  <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="offsets-into-the-media-resource:concept-event-fire-3" data-x-internal="concept-event-fire">fire an event</a> named <code id="offsets-into-the-media-resource:event-media-durationchange"><a href="#event-media-durationchange">durationchange</a></code> at the <a href="#media-element" id="offsets-into-the-media-resource:media-element-13">media element</a>. (The
  event is not fired when the duration is reset as part of loading a new media resource.) If the
  duration is changed such that the <a href="#current-playback-position" id="offsets-into-the-media-resource:current-playback-position-6">current playback position</a> ends up being greater
  than the time of the end of the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-23">media resource</a>, then the user agent must also <a href="#dom-media-seek" id="offsets-into-the-media-resource:dom-media-seek-3">seek</a> to the time of the end of the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-24">media resource</a>.</p>
  </div>

  <p class="example">If an "infinite" stream ends for some reason, then the duration would change
  from positive Infinity to the time of the last frame or sample in the stream, and the <code id="offsets-into-the-media-resource:event-media-durationchange-2"><a href="#event-media-durationchange">durationchange</a></code> event would be fired. Similarly, if the
  user agent initially estimated the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-25">media resource</a>'s duration instead of determining
  it precisely, and later revises the estimate based on new information, then the duration would
  change and the <code id="offsets-into-the-media-resource:event-media-durationchange-3"><a href="#event-media-durationchange">durationchange</a></code> event would be
  fired.</p>

  <p>Some video files also have an explicit date and time corresponding to the zero time in the
  <a href="#media-timeline" id="offsets-into-the-media-resource:media-timeline-14">media timeline</a>, known as the <dfn id="timeline-offset">timeline offset</dfn>. Initially, the
  <a href="#timeline-offset" id="offsets-into-the-media-resource:timeline-offset-2">timeline offset</a> must be set to Not-a-Number (NaN).</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-getstartdate" data-dfn-type="method"><code>getStartDate()</code></dfn> method must return <a href="#create-a-date-object" id="offsets-into-the-media-resource:create-a-date-object">a new <code>Date</code> object</a> representing the current
  <a href="#timeline-offset" id="offsets-into-the-media-resource:timeline-offset-3">timeline offset</a>.</p>
  </div>

  

  <hr>

  <p>The <dfn data-dfn-for="audio,video" id="attr-media-loop" data-dfn-type="element-attr"><code>loop</code></dfn>
  attribute is a <a href="#boolean-attribute" id="offsets-into-the-media-resource:boolean-attribute">boolean attribute</a> that, if specified, indicates that the <a href="#media-element" id="offsets-into-the-media-resource:media-element-14">media
  element</a> is to seek back to the start of the <a href="#media-resource" id="offsets-into-the-media-resource:media-resource-26">media resource</a> upon reaching the
  end.</p>



  <h5 id="ready-states"><span class="secno">4.8.11.7</span> Ready states<a href="#ready-states" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-readystate" id="dom-media-readystate-dev">readyState</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState" title="The HTMLMediaElement.readyState property indicates the readiness state of the media.">HTMLMediaElement/readyState</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a value that expresses the current state of the element with respect to rendering the
    <a href="#current-playback-position" id="ready-states:current-playback-position">current playback position</a>, from the codes in the list below.</p>
   </dd></dl>

  

  <p><a href="#media-element" id="ready-states:media-element">Media elements</a> have a <i>ready state</i>, which describes to
  what degree they are ready to be rendered at the <a href="#current-playback-position" id="ready-states:current-playback-position-2">current playback position</a>. The
  possible values are as follows; the ready state of a media element at any particular time is the
  greatest value describing the state of the element:</p>

  

  <dl><dt><dfn data-dfn-for="HTMLMediaElement" id="dom-media-have_nothing" data-dfn-type="const"><code>HAVE_NOTHING</code></dfn> (numeric value 0)</dt><dd><p>No information regarding the <a href="#media-resource" id="ready-states:media-resource">media resource</a> is available. No data for the
   <a href="#current-playback-position" id="ready-states:current-playback-position-3">current playback position</a> is available. <a href="#media-element" id="ready-states:media-element-2">Media
   elements</a> whose <code id="ready-states:dom-media-networkstate"><a href="#dom-media-networkstate">networkState</a></code> attribute are set
   to <code id="ready-states:dom-media-network_empty"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code> are always in the <code id="ready-states:dom-media-have_nothing"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code> state.</p></dd><dt><dfn data-dfn-for="HTMLMediaElement" id="dom-media-have_metadata" data-dfn-type="const"><code>HAVE_METADATA</code></dfn> (numeric value 1)</dt><dd><p>Enough of the resource has been obtained that the duration of the resource is available.
   In the case of a <code id="ready-states:the-video-element"><a href="#the-video-element">video</a></code> element, the dimensions of the video are also available. No
   <a href="#media-data" id="ready-states:media-data">media data</a> is available for the immediate <a href="#current-playback-position" id="ready-states:current-playback-position-4">current playback
   position</a>.</p></dd><dt><dfn data-dfn-for="HTMLMediaElement" id="dom-media-have_current_data" data-dfn-type="const"><code>HAVE_CURRENT_DATA</code></dfn> (numeric value 2)</dt><dd><p>Data for the immediate <a href="#current-playback-position" id="ready-states:current-playback-position-5">current playback position</a> is available, but either not
   enough data is available that the user agent could successfully advance the <a href="#current-playback-position" id="ready-states:current-playback-position-6">current
   playback position</a> in the <a href="#direction-of-playback" id="ready-states:direction-of-playback">direction of playback</a> at all without immediately
   reverting to the <code id="ready-states:dom-media-have_metadata"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> state, or there is no
   more data to obtain in the <a href="#direction-of-playback" id="ready-states:direction-of-playback-2">direction of playback</a>. For example, in video this
   corresponds to the user agent having data from the current frame, but not the next frame, when
   the <a href="#current-playback-position" id="ready-states:current-playback-position-7">current playback position</a> is at the end of the current frame; and to when <a href="#ended-playback" id="ready-states:ended-playback">playback has ended</a>.</p></dd><dt><dfn data-dfn-for="HTMLMediaElement" id="dom-media-have_future_data" data-dfn-type="const"><code>HAVE_FUTURE_DATA</code></dfn> (numeric value 3)</dt><dd><p>Data for the immediate <a href="#current-playback-position" id="ready-states:current-playback-position-8">current playback position</a> is available, as well as
   enough data for the user agent to advance the <a href="#current-playback-position" id="ready-states:current-playback-position-9">current playback position</a> in the
   <a href="#direction-of-playback" id="ready-states:direction-of-playback-3">direction of playback</a> at least a little without immediately reverting to the <code id="ready-states:dom-media-have_metadata-2"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> state, and <a href="#the-text-tracks-are-ready" id="ready-states:the-text-tracks-are-ready">the text tracks are
   ready</a>. For example, in video this corresponds to the user agent having data for at least
   the current frame and the next frame when the <a href="#current-playback-position" id="ready-states:current-playback-position-10">current playback position</a> is at the
   instant in time between the two frames, or to the user agent having the video data for the
   current frame and audio data to keep playing at least a little when the <a href="#current-playback-position" id="ready-states:current-playback-position-11">current playback
   position</a> is in the middle of a frame. The user agent cannot be in this state if <a href="#ended-playback" id="ready-states:ended-playback-2">playback has ended</a>, as the <a href="#current-playback-position" id="ready-states:current-playback-position-12">current playback position</a>
   can never advance in this case.</p></dd><dt><dfn data-dfn-for="HTMLMediaElement" id="dom-media-have_enough_data" data-dfn-type="const"><code>HAVE_ENOUGH_DATA</code></dfn> (numeric value 4)</dt><dd>
   <p>All the conditions described for the <code id="ready-states:dom-media-have_future_data"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> state are met, and, in addition,
    either of the following conditions is also true:</p>

    <ul><li>The user agent estimates that data is being fetched at a rate where the <a href="#current-playback-position" id="ready-states:current-playback-position-13">current
     playback position</a>, if it were to advance at the element's <code id="ready-states:dom-media-playbackrate"><a href="#dom-media-playbackrate">playbackRate</a></code>, would not overtake the available data
     before playback reaches the end of the <a href="#media-resource" id="ready-states:media-resource-2">media resource</a>.</li><li>The user agent has entered a state where waiting longer will not result in further data
     being obtained, and therefore nothing would be gained by delaying playback any further. (For
     example, the buffer might be full.)</li></ul>
   </dd></dl>

  <p class="note">In practice, the difference between <code id="ready-states:dom-media-have_metadata-3"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> and <code id="ready-states:dom-media-have_current_data"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> is negligible. Really the only time
  the difference is relevant is when painting a <code id="ready-states:the-video-element-2"><a href="#the-video-element">video</a></code> element onto a
  <code id="ready-states:the-canvas-element"><a href="#the-canvas-element">canvas</a></code>, where it distinguishes the case where something will be drawn (<code id="ready-states:dom-media-have_current_data-2"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> or greater) from the case where
  nothing is drawn (<code id="ready-states:dom-media-have_metadata-4"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> or less). Similarly,
  the difference between <code id="ready-states:dom-media-have_current_data-3"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> (only
  the current frame) and <code id="ready-states:dom-media-have_future_data-2"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> (at least
  this frame and the next) can be negligible (in the extreme, only one frame). The only time that
  distinction really matters is when a page provides an interface for "frame-by-frame"
  navigation.</p>

  

  <div data-algorithm="">
  <p>When the ready state of a <a href="#media-element" id="ready-states:media-element-3">media element</a> whose <code id="ready-states:dom-media-networkstate-2"><a href="#dom-media-networkstate">networkState</a></code> is not <code id="ready-states:dom-media-network_empty-2"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code> changes, the user agent must follow the steps
  given below:</p>

  <ol><li>
    <p>Apply the first applicable set of substeps from the following list:</p>


    <dl class="switch"><dt>If the previous ready state was <code id="ready-states:dom-media-have_nothing-2"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>,
     and the new ready state is <code id="ready-states:dom-media-have_metadata-5"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code></dt><dd id="fire-loadedmetadata">

      <p><a href="#queue-a-media-element-task" id="ready-states:queue-a-media-element-task">Queue a media element task</a> given the <a href="#media-element" id="ready-states:media-element-4">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ready-states:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="ready-states:event-media-loadedmetadata"><a href="#event-media-loadedmetadata">loadedmetadata</a></code> at the element.</p>

      <p class="note">Before this task is run, as part of the <a href="#event-loop" id="ready-states:event-loop">event loop</a> mechanism, the
      rendering will have been updated to resize the <code id="ready-states:the-video-element-3"><a href="#the-video-element">video</a></code> element if appropriate.</p>
     </dd><dt id="handling-first-frame-available">If the previous ready state was <code id="ready-states:dom-media-have_metadata-6"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> and the new ready state is <code id="ready-states:dom-media-have_current_data-4"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> or greater</dt><dd>
      <p id="fire-loadeddata">If this is the first time this occurs for this <a href="#media-element" id="ready-states:media-element-5">media
      element</a> since the <code id="ready-states:dom-media-load"><a href="#dom-media-load">load()</a></code> algorithm was last
      invoked, the user agent must <a href="#queue-a-media-element-task" id="ready-states:queue-a-media-element-task-2">queue a media element task</a> given the <a href="#media-element" id="ready-states:media-element-6">media
      element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ready-states:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="ready-states:event-media-loadeddata"><a href="#event-media-loadeddata">loadeddata</a></code> at the element.</p>

      <p>If the new ready state is <code id="ready-states:dom-media-have_future_data-3"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code>
      or <code id="ready-states:dom-media-have_enough_data"><a href="#dom-media-have_enough_data">HAVE_ENOUGH_DATA</a></code>, then the relevant steps
      below must then be run also.</p>
     </dd><dt>If the previous ready state was <code id="ready-states:dom-media-have_future_data-4"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> or more, and the new ready state is
     <code id="ready-states:dom-media-have_current_data-5"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> or less</dt><dd>
      <p id="fire-waiting-when-waiting">If the <a href="#media-element" id="ready-states:media-element-7">media element</a> was <a href="#potentially-playing" id="ready-states:potentially-playing">potentially
      playing</a> before its <code id="ready-states:dom-media-readystate"><a href="#dom-media-readystate">readyState</a></code> attribute
      changed to a value lower than <code id="ready-states:dom-media-have_future_data-5"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code>, and the element has not
      <a href="#ended-playback" id="ready-states:ended-playback-3">ended playback</a>, and playback has not <a href="#stopped-due-to-errors" id="ready-states:stopped-due-to-errors">stopped due to errors</a>,
      <a href="#paused-for-user-interaction" id="ready-states:paused-for-user-interaction">paused for user interaction</a>, or <a href="#paused-for-in-band-content" id="ready-states:paused-for-in-band-content">paused for in-band content</a>, the user
      agent must <a href="#queue-a-media-element-task" id="ready-states:queue-a-media-element-task-3">queue a media element task</a> given the <a href="#media-element" id="ready-states:media-element-8">media element</a> to
      <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ready-states:concept-event-fire-3" data-x-internal="concept-event-fire">fire an event</a> named <code id="ready-states:event-media-timeupdate"><a href="#event-media-timeupdate">timeupdate</a></code> at the element, and <a href="#queue-a-media-element-task" id="ready-states:queue-a-media-element-task-4">queue a media
      element task</a> given the <a href="#media-element" id="ready-states:media-element-9">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ready-states:concept-event-fire-4" data-x-internal="concept-event-fire">fire an event</a> named <code id="ready-states:event-media-waiting"><a href="#event-media-waiting">waiting</a></code> at the element.</p>
     </dd><dt>If the previous ready state was <code id="ready-states:dom-media-have_current_data-6"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> or less, and the new ready state
     is <code id="ready-states:dom-media-have_future_data-6"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code></dt><dd>
      <p>The user agent must <a href="#queue-a-media-element-task" id="ready-states:queue-a-media-element-task-5">queue a media element task</a> given the <a href="#media-element" id="ready-states:media-element-10">media
      element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ready-states:concept-event-fire-5" data-x-internal="concept-event-fire">fire an event</a> named <code id="ready-states:event-media-canplay"><a href="#event-media-canplay">canplay</a></code> at the element.</p>

      <p>If the element's <code id="ready-states:dom-media-paused"><a href="#dom-media-paused">paused</a></code> attribute is false, the user
      agent must <a href="#notify-about-playing" id="ready-states:notify-about-playing">notify about playing</a> for the element.</p>
     </dd><dt>If the new ready state is <code id="ready-states:dom-media-have_enough_data-2"><a href="#dom-media-have_enough_data">HAVE_ENOUGH_DATA</a></code></dt><dd>
      <p>If the previous ready state was <code id="ready-states:dom-media-have_current_data-7"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> or less, the user agent must
      <a href="#queue-a-media-element-task" id="ready-states:queue-a-media-element-task-6">queue a media element task</a> given the <a href="#media-element" id="ready-states:media-element-11">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ready-states:concept-event-fire-6" data-x-internal="concept-event-fire">fire an event</a> named <code id="ready-states:event-media-canplay-2"><a href="#event-media-canplay">canplay</a></code> at the element, and, if the element's <code id="ready-states:dom-media-paused-2"><a href="#dom-media-paused">paused</a></code> attribute is false, <a href="#notify-about-playing" id="ready-states:notify-about-playing-2">notify about playing</a>
      for the element.</p>

      <p>The user agent must <a href="#queue-a-media-element-task" id="ready-states:queue-a-media-element-task-7">queue a media element task</a> given the <a href="#media-element" id="ready-states:media-element-12">media
      element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ready-states:concept-event-fire-7" data-x-internal="concept-event-fire">fire an event</a> named <code id="ready-states:event-media-canplaythrough"><a href="#event-media-canplaythrough">canplaythrough</a></code> at the element.</p>

      <p>If the element is not <a href="#eligible-for-autoplay" id="ready-states:eligible-for-autoplay">eligible for autoplay</a>, then the user agent must abort
      these substeps.</p>

      <p>The user agent may run the following substeps:</p>

      <ol><li>Set the <code id="ready-states:dom-media-paused-3"><a href="#dom-media-paused">paused</a></code> attribute to false.</li><li>If the element's <a href="#show-poster-flag" id="ready-states:show-poster-flag">show poster flag</a> is true, set it to false and run the
       <i id="ready-states:time-marches-on"><a href="#time-marches-on">time marches on</a></i> steps.</li><li><a href="#queue-a-media-element-task" id="ready-states:queue-a-media-element-task-8">Queue a media element task</a> given the element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ready-states:concept-event-fire-8" data-x-internal="concept-event-fire">fire an event</a> named <code id="ready-states:event-media-play"><a href="#event-media-play">play</a></code> at the element.</li><li><a href="#notify-about-playing" id="ready-states:notify-about-playing-3">Notify about playing</a> for the element.</li></ol>

      <p>Alternatively, if the element is a <code id="ready-states:the-video-element-4"><a href="#the-video-element">video</a></code> element, the user agent may start
      observing whether the element <a href="#intersect-the-viewport" id="ready-states:intersect-the-viewport">intersects the
      viewport</a>. When the element starts <a href="#intersect-the-viewport" id="ready-states:intersect-the-viewport-2">intersecting
      the viewport</a>, if the element is still <a href="#eligible-for-autoplay" id="ready-states:eligible-for-autoplay-2">eligible for autoplay</a>, run the
      substeps above. Optionally, when the element stops <a href="#intersect-the-viewport" id="ready-states:intersect-the-viewport-3">intersecting the viewport</a>, if the <a href="#can-autoplay-flag" id="ready-states:can-autoplay-flag">can autoplay flag</a> is still
      true and the <code id="ready-states:attr-media-autoplay"><a href="#attr-media-autoplay">autoplay</a></code> attribute is still specified,
      run the following substeps:</p>

      <ol><li>Run the <a href="#internal-pause-steps" id="ready-states:internal-pause-steps">internal pause steps</a> and set the <a href="#can-autoplay-flag" id="ready-states:can-autoplay-flag-2">can autoplay flag</a> to
       true.</li><li><a href="#queue-a-media-element-task" id="ready-states:queue-a-media-element-task-9">Queue a media element task</a> given the element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ready-states:concept-event-fire-9" data-x-internal="concept-event-fire">fire an event</a> named <code id="ready-states:event-media-pause"><a href="#event-media-pause">pause</a></code> at the element.</li></ol>

      <p class="note">The substeps for playing and pausing can run multiple times as the element
      starts or stops <a href="#intersect-the-viewport" id="ready-states:intersect-the-viewport-4">intersecting the viewport</a>, as
      long as the <a href="#can-autoplay-flag" id="ready-states:can-autoplay-flag-3">can autoplay flag</a> is true.</p>

      <p class="note">User agents do not need to support autoplay, and it is suggested that user
      agents honor user preferences on the matter. Authors are urged to use the <code id="ready-states:attr-media-autoplay-2"><a href="#attr-media-autoplay">autoplay</a></code> attribute rather than using script to force the
      video to play, so as to allow the user to override the behavior if so desired.</p>
     </dd></dl>
   </li></ol>
  </div>

  

  <p class="note">It is possible for the ready state of a media element to jump between these states
  discontinuously. For example, the state of a media element can jump straight from <code id="ready-states:dom-media-have_metadata-7"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> to <code id="ready-states:dom-media-have_enough_data-3"><a href="#dom-media-have_enough_data">HAVE_ENOUGH_DATA</a></code> without passing through the <code id="ready-states:dom-media-have_current_data-8"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> and <code id="ready-states:dom-media-have_future_data-7"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> states.</p>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-readystate" data-dfn-type="attribute"><code>readyState</code></dfn> IDL attribute must, on getting, return the
  value described above that describes the current ready state of the <a href="#media-element" id="ready-states:media-element-13">media
  element</a>.</p>
  </div>

  

  <p>The <dfn data-dfn-for="audio,video" id="attr-media-autoplay" data-dfn-type="element-attr"><code>autoplay</code></dfn> attribute is a <a href="#boolean-attribute" id="ready-states:boolean-attribute">boolean attribute</a>.
  When present, the user agent (as described in the algorithm described herein)
  will automatically begin playback of the <a href="#media-resource" id="ready-states:media-resource-3">media resource</a> as soon as it can do so
  without stopping.</p>

  <p class="note">Authors are urged to use the <code id="ready-states:attr-media-autoplay-3"><a href="#attr-media-autoplay">autoplay</a></code>
  attribute rather than using script to trigger automatic playback, as this allows the user to
  override the automatic playback when it is not desired, e.g. when using a screen reader. Authors
  are also encouraged to consider not using the automatic playback behavior at all, and instead to
  let the user agent wait for the user to start playback explicitly.</p>



  <h5 id="playing-the-media-resource"><span class="secno">4.8.11.8</span> Playing the media resource<a href="#playing-the-media-resource" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-paused" id="dom-media-paused-dev">paused</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/paused" title="The read-only HTMLMediaElement.paused property tells whether the media element is paused.">HTMLMediaElement/paused</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns true if playback is paused; false otherwise.</p></dd><dt><code><var>media</var>.<a href="#dom-media-ended" id="dom-media-ended-dev">ended</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ended" title="The HTMLMediaElement.ended property indicates whether the media element has ended playback.">HTMLMediaElement/ended</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns true if playback has reached the end of the <a href="#media-resource" id="playing-the-media-resource:media-resource">media resource</a>.</p></dd><dt><code><var>media</var>.<a href="#dom-media-defaultplaybackrate" id="dom-media-defaultplaybackrate-dev">defaultPlaybackRate</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/defaultPlaybackRate" title="The HTMLMediaElement.defaultPlaybackRate property indicates the default playback rate for the media.">HTMLMediaElement/defaultPlaybackRate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>20+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the default rate of playback, for when the user is not fast-forwarding or reversing
    through the <a href="#media-resource" id="playing-the-media-resource:media-resource-2">media resource</a>.</p>

    <p>Can be set, to change the default rate of playback.</p>

    <p>The default rate has no direct effect on playback, but if the user switches to a fast-forward
    mode, when they return to the normal playback mode, it is expected that the rate of playback
    will be returned to the default rate of playback.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-playbackrate" id="dom-media-playbackrate-dev">playbackRate</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate" title="The HTMLMediaElement.playbackRate property sets the rate at which the media is being played back. This is used to implement user controls for fast forward, slow motion, and so forth. The normal playback rate is multiplied by this value to obtain the current rate, so a value of 1.0 indicates normal speed.">HTMLMediaElement/playbackRate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>20+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the current rate playback, where 1.0 is normal speed.</p>

    <p>Can be set, to change the rate of playback.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-preservespitch" id="dom-media-preservespitch-dev">preservesPitch</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/preservesPitch" title="The HTMLMediaElement.preservesPitch property determines whether or not the browser should adjust the pitch of the audio to compensate for changes to the playback rate made by setting HTMLMediaElement.playbackRate.">HTMLMediaElement/preservesPitch</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>101+</span></span><span class="safari yes"><span>Safari</span><span title="Requires a prefix or alternative name.">🔰 4+</span></span><span class="chrome yes"><span>Chrome</span><span>86+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>86+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span title="Requires a prefix or alternative name.">🔰 4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns true if pitch-preserving algorithms are used when the <code id="playing-the-media-resource:dom-media-playbackrate"><a href="#dom-media-playbackrate">playbackRate</a></code> is not 1.0. The default value is true.</p>

    <p>Can be set to false to have the <a href="#media-resource" id="playing-the-media-resource:media-resource-3">media resource</a>'s audio pitch change up or down
    depending on the <code id="playing-the-media-resource:dom-media-playbackrate-2"><a href="#dom-media-playbackrate">playbackRate</a></code>. This is useful for
    aesthetic and performance reasons.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-played" id="dom-media-played-dev">played</a></code></dt><dd>
    <p>Returns a <code id="playing-the-media-resource:timeranges"><a href="#timeranges">TimeRanges</a></code> object that represents the ranges of the <a href="#media-resource" id="playing-the-media-resource:media-resource-4">media
    resource</a> that the user agent has played.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-play" id="dom-media-play-dev">play</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play" title="The HTMLMediaElement play() method attempts to begin playback of the media. It returns a Promise which is resolved when playback has been successfully started.">HTMLMediaElement/play</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>Sets the <code id="playing-the-media-resource:dom-media-paused"><a href="#dom-media-paused">paused</a></code> attribute to false, loading the
    <a href="#media-resource" id="playing-the-media-resource:media-resource-5">media resource</a> and beginning playback if necessary. If the playback had ended, will
    restart it from the start.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-pause" id="dom-media-pause-dev">pause</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/pause" title="The HTMLMediaElement.pause() method will pause playback of the media, if the media is already in a paused state this method will have no effect.">HTMLMediaElement/pause</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Sets the <code id="playing-the-media-resource:dom-media-paused-2"><a href="#dom-media-paused">paused</a></code> attribute to true, loading the
    <a href="#media-resource" id="playing-the-media-resource:media-resource-6">media resource</a> if necessary.</p>
   </dd></dl>

  

  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-paused" data-dfn-type="attribute"><code>paused</code></dfn>
  attribute represents whether the <a href="#media-element" id="playing-the-media-resource:media-element">media element</a> is paused or not. The attribute must
  initially be true.</p>

  <div data-algorithm="">
  <p>A <a href="#media-element" id="playing-the-media-resource:media-element-2">media element</a> is a <dfn id="blocked-media-element">blocked media element</dfn> if its <code id="playing-the-media-resource:dom-media-readystate"><a href="#dom-media-readystate">readyState</a></code> attribute is in the <code id="playing-the-media-resource:dom-media-have_nothing"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code> state, the <code id="playing-the-media-resource:dom-media-have_metadata"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> state, or the <code id="playing-the-media-resource:dom-media-have_current_data"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> state, or if the element has
  <a href="#paused-for-user-interaction" id="playing-the-media-resource:paused-for-user-interaction">paused for user interaction</a> or <a href="#paused-for-in-band-content" id="playing-the-media-resource:paused-for-in-band-content">paused for in-band content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#media-element" id="playing-the-media-resource:media-element-3">media element</a> is said to be <dfn data-dfn-for="media element" id="potentially-playing" data-export="">potentially
  playing</dfn> when its <code id="playing-the-media-resource:dom-media-paused-3"><a href="#dom-media-paused">paused</a></code> attribute is false, the
  element has not <a href="#ended-playback" id="playing-the-media-resource:ended-playback">ended playback</a>, playback has not <a href="#stopped-due-to-errors" id="playing-the-media-resource:stopped-due-to-errors">stopped due to errors</a>,
  and the element is not a <a href="#blocked-media-element" id="playing-the-media-resource:blocked-media-element">blocked media element</a>.</p>
  </div>

  <p class="note">A <code id="playing-the-media-resource:event-media-waiting"><a href="#event-media-waiting">waiting</a></code> DOM event <a href="#fire-waiting-when-waiting">can be fired</a> as a result of an element that is
  <a href="#potentially-playing" id="playing-the-media-resource:potentially-playing">potentially playing</a> stopping playback due to its <code id="playing-the-media-resource:dom-media-readystate-2"><a href="#dom-media-readystate">readyState</a></code> attribute changing to a value lower than <code id="playing-the-media-resource:dom-media-have_future_data"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code>.</p>

  <div data-algorithm="">
  <p>A <a href="#media-element" id="playing-the-media-resource:media-element-4">media element</a> is said to be <dfn id="eligible-for-autoplay">eligible for autoplay</dfn> when all of the
  following are true:</p>

  <ul><li><p>its <a href="#can-autoplay-flag" id="playing-the-media-resource:can-autoplay-flag">can autoplay flag</a> is true;</p></li><li><p>its <code id="playing-the-media-resource:dom-media-paused-4"><a href="#dom-media-paused">paused</a></code> attribute is true;</p></li><li><p>it has an <code id="playing-the-media-resource:attr-media-autoplay"><a href="#attr-media-autoplay">autoplay</a></code> attribute
   specified;</p></li><li><p>its <a id="playing-the-media-resource:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#active-sandboxing-flag-set" id="playing-the-media-resource:active-sandboxing-flag-set">active sandboxing flag set</a> does not have
   the <a href="#sandboxed-automatic-features-browsing-context-flag" id="playing-the-media-resource:sandboxed-automatic-features-browsing-context-flag">sandboxed automatic features browsing context flag</a> set; and</p></li><li><p>its <a id="playing-the-media-resource:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is <a href="#allowed-to-use" id="playing-the-media-resource:allowed-to-use">allowed to use</a> the "<code id="playing-the-media-resource:autoplay-feature"><a href="#autoplay-feature">autoplay</a></code>" feature.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>A <a href="#media-element" id="playing-the-media-resource:media-element-5">media element</a> is said to be <dfn id="allowed-to-play">allowed to play</dfn> if the user agent and the
  system allow media playback in the current context.</p>
  </div>

  <p class="example">For example, a user agent could allow playback only when the <a href="#media-element" id="playing-the-media-resource:media-element-6">media
  element</a>'s <code id="playing-the-media-resource:window"><a href="#window">Window</a></code> object has <a href="#transient-activation" id="playing-the-media-resource:transient-activation">transient activation</a>, but an
  exception could be made to allow playback while <a href="#concept-media-muted" id="playing-the-media-resource:concept-media-muted">muted</a>.</p>

  <div data-algorithm="">
  <p>A <a href="#media-element" id="playing-the-media-resource:media-element-7">media element</a> is said to have <dfn id="ended-playback">ended playback</dfn> when:</p>

  <ul><li><p>The element's <code id="playing-the-media-resource:dom-media-readystate-3"><a href="#dom-media-readystate">readyState</a></code> attribute is <code id="playing-the-media-resource:dom-media-have_metadata-2"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> or greater, and</p>

   </li><li>
    <p>Either:</p>

    <ul><li><p>The <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position">current playback position</a> is the end of the <a href="#media-resource" id="playing-the-media-resource:media-resource-7">media
     resource</a>, and</p></li><li><p>The <a href="#direction-of-playback" id="playing-the-media-resource:direction-of-playback">direction of playback</a> is forwards, and</p></li><li><p>The <a href="#media-element" id="playing-the-media-resource:media-element-8">media element</a> does not have a <code id="playing-the-media-resource:attr-media-loop"><a href="#attr-media-loop">loop</a></code> attribute specified.</p></li></ul>

    <p>Or:</p>

    <ul><li><p>The <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-2">current playback position</a> is the <a href="#earliest-possible-position" id="playing-the-media-resource:earliest-possible-position">earliest possible
     position</a>, and</p></li><li><p>The <a href="#direction-of-playback" id="playing-the-media-resource:direction-of-playback-2">direction of playback</a> is backwards.</p></li></ul>
   </li></ul>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-ended" data-dfn-type="attribute"><code>ended</code></dfn>
  attribute must return true if, the last time the <a href="#event-loop" id="playing-the-media-resource:event-loop">event loop</a> reached <a href="#step1">step 1</a>, the <a href="#media-element" id="playing-the-media-resource:media-element-9">media element</a> had <a href="#ended-playback" id="playing-the-media-resource:ended-playback-2">ended playback</a> and the
  <a href="#direction-of-playback" id="playing-the-media-resource:direction-of-playback-3">direction of playback</a> was forwards, and false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#media-element" id="playing-the-media-resource:media-element-10">media element</a> is said to have <dfn id="stopped-due-to-errors">stopped due to errors</dfn> when the
  element's <code id="playing-the-media-resource:dom-media-readystate-4"><a href="#dom-media-readystate">readyState</a></code> attribute is <code id="playing-the-media-resource:dom-media-have_metadata-3"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> or greater, and the user agent <a href="#non-fatal-media-error">encounters a non-fatal error</a> during the processing of the
  <a href="#media-data" id="playing-the-media-resource:media-data">media data</a>, and due to that error, is not able to play the content at the
  <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-3">current playback position</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#media-element" id="playing-the-media-resource:media-element-11">media element</a> is said to have <dfn id="paused-for-user-interaction">paused for user interaction</dfn> when its
  <code id="playing-the-media-resource:dom-media-paused-5"><a href="#dom-media-paused">paused</a></code> attribute is false, the <code id="playing-the-media-resource:dom-media-readystate-5"><a href="#dom-media-readystate">readyState</a></code> attribute is either <code id="playing-the-media-resource:dom-media-have_future_data-2"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> or <code id="playing-the-media-resource:dom-media-have_enough_data"><a href="#dom-media-have_enough_data">HAVE_ENOUGH_DATA</a></code>, and the user agent has reached a point
  in the <a href="#media-resource" id="playing-the-media-resource:media-resource-8">media resource</a> where the user has to make a selection for the resource to
  continue.</p>
  </div>

  <p>It is possible for a <a href="#media-element" id="playing-the-media-resource:media-element-12">media element</a> to have both <a href="#ended-playback" id="playing-the-media-resource:ended-playback-3">ended playback</a> and
  <a href="#paused-for-user-interaction" id="playing-the-media-resource:paused-for-user-interaction-2">paused for user interaction</a> at the same time.</p>

  <div data-algorithm="">
  <p>When a <a href="#media-element" id="playing-the-media-resource:media-element-13">media element</a> that is <a href="#potentially-playing" id="playing-the-media-resource:potentially-playing-2">potentially playing</a> stops playing
  because it has <a href="#paused-for-user-interaction" id="playing-the-media-resource:paused-for-user-interaction-3">paused for user interaction</a>, the user agent must <a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task">queue a media
  element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-14">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire" data-x-internal="concept-event-fire">fire
  an event</a> named <code id="playing-the-media-resource:event-media-timeupdate"><a href="#event-media-timeupdate">timeupdate</a></code> at the element.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#media-element" id="playing-the-media-resource:media-element-15">media element</a> is said to have <dfn id="paused-for-in-band-content">paused for in-band content</dfn> when its
  <code id="playing-the-media-resource:dom-media-paused-6"><a href="#dom-media-paused">paused</a></code> attribute is false, the <code id="playing-the-media-resource:dom-media-readystate-6"><a href="#dom-media-readystate">readyState</a></code> attribute is either <code id="playing-the-media-resource:dom-media-have_future_data-3"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> or <code id="playing-the-media-resource:dom-media-have_enough_data-2"><a href="#dom-media-have_enough_data">HAVE_ENOUGH_DATA</a></code>, and the user agent has suspended
  playback of the <a href="#media-resource" id="playing-the-media-resource:media-resource-9">media resource</a> in order to play content that is temporally anchored
  to the <a href="#media-resource" id="playing-the-media-resource:media-resource-10">media resource</a> and has a nonzero length, or to play content that is
  temporally anchored to a segment of the <a href="#media-resource" id="playing-the-media-resource:media-resource-11">media resource</a> but has a length longer than
  that segment.</p>
  </div>

  <p class="example">One example of when a <a href="#media-element" id="playing-the-media-resource:media-element-16">media element</a> would be <a href="#paused-for-in-band-content" id="playing-the-media-resource:paused-for-in-band-content-2">paused for
  in-band content</a> is when the user agent is playing <a href="#attr-track-kind-descriptions" id="playing-the-media-resource:attr-track-kind-descriptions">audio descriptions</a> from an external WebVTT file, and
  the synthesized speech generated for a cue is longer than the time between the <a href="#text-track-cue-start-time" id="playing-the-media-resource:text-track-cue-start-time">text track
  cue start time</a> and the <a href="#text-track-cue-end-time" id="playing-the-media-resource:text-track-cue-end-time">text track cue end time</a>.</p>

  <hr>

  <div data-algorithm="">
  <p id="reaches-the-end">When the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-4">current playback position</a> reaches the end of the
  <a href="#media-resource" id="playing-the-media-resource:media-resource-12">media resource</a> when the <a href="#direction-of-playback" id="playing-the-media-resource:direction-of-playback-4">direction of playback</a> is forwards, then the user
  agent must follow these steps:</p>

  <ol><li><p>If the <a href="#media-element" id="playing-the-media-resource:media-element-17">media element</a> has a <code id="playing-the-media-resource:attr-media-loop-2"><a href="#attr-media-loop">loop</a></code>
   attribute specified, then <a href="#dom-media-seek" id="playing-the-media-resource:dom-media-seek">seek</a> to the <a href="#earliest-possible-position" id="playing-the-media-resource:earliest-possible-position-2">earliest
   possible position</a> of the <a href="#media-resource" id="playing-the-media-resource:media-resource-13">media resource</a> and return.</p></li><li><p>As defined above, the <code id="playing-the-media-resource:dom-media-ended"><a href="#dom-media-ended">ended</a></code> IDL attribute starts
   returning true once the <a href="#event-loop" id="playing-the-media-resource:event-loop-2">event loop</a> returns to <a href="#step1">step 1</a>.</p></li><li>
    <p><a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-2">Queue a media element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-18">media element</a> and the
    following steps:</p>

    <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="playing-the-media-resource:event-media-timeupdate-2"><a href="#event-media-timeupdate">timeupdate</a></code> at the <a href="#media-element" id="playing-the-media-resource:media-element-19">media element</a>.</p></li><li>
      <p>If the <a href="#media-element" id="playing-the-media-resource:media-element-20">media element</a> has <a href="#ended-playback" id="playing-the-media-resource:ended-playback-4">ended playback</a>, the <a href="#direction-of-playback" id="playing-the-media-resource:direction-of-playback-5">direction of
      playback</a> is forwards, and <a href="#dom-media-paused" id="playing-the-media-resource:dom-media-paused-7">paused</a> is false,
      then:</p>

      <ol><li><p>Set the <code id="playing-the-media-resource:dom-media-paused-8"><a href="#dom-media-paused">paused</a></code> attribute to true.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-3" data-x-internal="concept-event-fire">Fire an event</a> named <code id="playing-the-media-resource:event-media-pause"><a href="#event-media-pause">pause</a></code> at the <a href="#media-element" id="playing-the-media-resource:media-element-21">media element</a>.</p></li><li><p><a href="#take-pending-play-promises" id="playing-the-media-resource:take-pending-play-promises">Take pending play promises</a> and <a href="#reject-pending-play-promises" id="playing-the-media-resource:reject-pending-play-promises">reject pending play promises</a>
       with the result and an <a id="playing-the-media-resource:aborterror" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a>
       <code id="playing-the-media-resource:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
     </li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-4" data-x-internal="concept-event-fire">Fire an event</a> named <code id="playing-the-media-resource:event-media-ended"><a href="#event-media-ended">ended</a></code> at the <a href="#media-element" id="playing-the-media-resource:media-element-22">media element</a>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>When the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-5">current playback position</a> reaches the <a href="#earliest-possible-position" id="playing-the-media-resource:earliest-possible-position-3">earliest possible
  position</a> of the <a href="#media-resource" id="playing-the-media-resource:media-resource-14">media resource</a> when the <a href="#direction-of-playback" id="playing-the-media-resource:direction-of-playback-6">direction of playback</a> is
  backwards, then the user agent must only <a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-3">queue a media element task</a> given the
  <a href="#media-element" id="playing-the-media-resource:media-element-23">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-5" data-x-internal="concept-event-fire">fire an event</a> named <code id="playing-the-media-resource:event-media-timeupdate-3"><a href="#event-media-timeupdate">timeupdate</a></code> at the element.</p>
  </div>

  <p class="note">The word "reaches" here does not imply that the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-6">current playback
  position</a> needs to have changed during normal playback; it could be via <a href="#dom-media-seek" id="playing-the-media-resource:dom-media-seek-2">seeking</a>, for instance.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-defaultplaybackrate" data-dfn-type="attribute"><code>defaultPlaybackRate</code></dfn> attribute gives the
  desired speed at which the <a href="#media-resource" id="playing-the-media-resource:media-resource-15">media resource</a> is to play, as a multiple of its intrinsic
  speed. The attribute is mutable: on getting it must return the last value it was set to, or 1.0 if
  it hasn't yet been set; on setting the attribute must be set to the new value.</p>
  </div>

  <p class="note">The <code id="playing-the-media-resource:dom-media-defaultplaybackrate"><a href="#dom-media-defaultplaybackrate">defaultPlaybackRate</a></code> is used
  by the user agent when it <a href="#expose-a-user-interface-to-the-user" id="playing-the-media-resource:expose-a-user-interface-to-the-user">exposes a user
  interface to the user</a>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-playbackrate" data-dfn-type="attribute"><code>playbackRate</code></dfn> attribute gives the effective playback
  rate, which is the speed at which the <a href="#media-resource" id="playing-the-media-resource:media-resource-16">media resource</a> plays, as a multiple of its
  intrinsic speed. If it is not equal to the <code id="playing-the-media-resource:dom-media-defaultplaybackrate-2"><a href="#dom-media-defaultplaybackrate">defaultPlaybackRate</a></code>, then the implication is that
  the user is using a feature such as fast forward or slow motion playback. The attribute is
  mutable: on getting it must return the last value it was set to, or 1.0 if it hasn't yet been set;
  on setting, the user agent must follow these steps:</p>

  <ol><li><p>If the given value is not supported by the user agent, then throw a
   <a id="playing-the-media-resource:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="playing-the-media-resource:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <code id="playing-the-media-resource:dom-media-playbackrate-3"><a href="#dom-media-playbackrate">playbackRate</a></code> to the new value, and if the
   element is <a href="#potentially-playing" id="playing-the-media-resource:potentially-playing-3">potentially playing</a>, change the playback speed.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="rateUpdate">When the <code id="playing-the-media-resource:dom-media-defaultplaybackrate-3"><a href="#dom-media-defaultplaybackrate">defaultPlaybackRate</a></code> or <code id="playing-the-media-resource:dom-media-playbackrate-4"><a href="#dom-media-playbackrate">playbackRate</a></code> attributes change value (either by being set
  by script or by being changed directly by the user agent, e.g. in response to user control), the
  user agent must <a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-4">queue a media element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-24">media element</a> to
  <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-6" data-x-internal="concept-event-fire">fire an event</a> named <code id="playing-the-media-resource:event-media-ratechange"><a href="#event-media-ratechange">ratechange</a></code> at the <a href="#media-element" id="playing-the-media-resource:media-element-25">media element</a>. The user
  agent must process attribute changes smoothly and must not introduce any perceivable gaps or
  muting of playback in response.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-preservespitch" data-dfn-type="attribute"><code>preservesPitch</code></dfn> getter steps are to return true if a
  pitch-preserving algorithm is in effect during playback. The setter steps are to correspondingly
  switch the pitch-preserving algorithm on or off, without any perceivable gaps or muting of
  playback. By default, such a pitch-preserving algorithm must be in effect (i.e., the getter will
  initially return true).</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-played" data-dfn-type="attribute"><code>played</code></dfn>
  attribute must return a new static <a href="#normalised-timeranges-object" id="playing-the-media-resource:normalised-timeranges-object">normalized <code>TimeRanges</code> object</a> that
  represents the ranges of points on the <a href="#media-timeline" id="playing-the-media-resource:media-timeline">media timeline</a> of the <a href="#media-resource" id="playing-the-media-resource:media-resource-17">media
  resource</a> reached through the usual monotonic increase of the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-7">current playback
  position</a> during normal playback, if any, at the time the attribute is evaluated.</p>
  </div>

  <p class="warning">Returning a new object each time is a bad pattern for attribute getters and is
  only enshrined here as it would be costly to change it. It is not to be copied to new APIs.</p>

  <hr>

  <p>Each <a href="#media-element" id="playing-the-media-resource:media-element-26">media element</a> has a <dfn id="list-of-pending-play-promises">list of pending play promises</dfn>, which must
  initially be empty.</p>

  <div data-algorithm="">
  <p>To <dfn id="take-pending-play-promises">take pending play promises</dfn> for a <a href="#media-element" id="playing-the-media-resource:media-element-27">media element</a>, the user agent must
  run the following steps:</p>

  <ol><li><p>Let <var>promises</var> be an empty list of promises.</p></li><li><p>Copy the <a href="#media-element" id="playing-the-media-resource:media-element-28">media element</a>'s <a href="#list-of-pending-play-promises" id="playing-the-media-resource:list-of-pending-play-promises">list of pending play promises</a> to
   <var>promises</var>.</p></li><li><p>Clear the <a href="#media-element" id="playing-the-media-resource:media-element-29">media element</a>'s <a href="#list-of-pending-play-promises" id="playing-the-media-resource:list-of-pending-play-promises-2">list of pending play
   promises</a>.</p></li><li>Return <var>promises</var>.</li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="resolve-pending-play-promises">resolve pending play promises</dfn> for a <a href="#media-element" id="playing-the-media-resource:media-element-30">media element</a> with a list of
  promises <var>promises</var>, the user agent must resolve each promise in <var>promises</var> with
  undefined.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="reject-pending-play-promises">reject pending play promises</dfn> for a <a href="#media-element" id="playing-the-media-resource:media-element-31">media element</a> with a list of
  promises <var>promises</var> and an exception name <var>error</var>, the user agent must reject
  each promise in <var>promises</var> with <var>error</var>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="notify-about-playing">notify about playing</dfn> for a <a href="#media-element" id="playing-the-media-resource:media-element-32">media element</a>, the user agent must run
  the following steps:</p>

  <ol><li><p><a href="#take-pending-play-promises" id="playing-the-media-resource:take-pending-play-promises-2">Take pending play promises</a> and let <var>promises</var> be the
   result.</p></li><li>
    <p><a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-5">Queue a media element task</a> given the element and the following steps:</p>

    <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-7" data-x-internal="concept-event-fire">Fire an event</a> named <code id="playing-the-media-resource:event-media-playing"><a href="#event-media-playing">playing</a></code> at the element.</p></li><li><p><a href="#resolve-pending-play-promises" id="playing-the-media-resource:resolve-pending-play-promises">Resolve pending play promises</a> with <var>promises</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>When the <dfn data-dfn-for="HTMLMediaElement" id="dom-media-play" data-dfn-type="method"><code>play()</code></dfn>
  method on a <a href="#media-element" id="playing-the-media-resource:media-element-33">media element</a> is invoked, the user agent must run the following
  steps.</p>

  <ol><li><p>If the <a href="#media-element" id="playing-the-media-resource:media-element-34">media element</a> is not <a href="#allowed-to-play" id="playing-the-media-resource:allowed-to-play">allowed to play</a>, then return
   <a id="playing-the-media-resource:a-promise-rejected-with" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> a <a id="playing-the-media-resource:notallowederror" href="https://webidl.spec.whatwg.org/#notallowederror" data-x-internal="notallowederror">"<code>NotAllowedError</code>"</a>
   <code id="playing-the-media-resource:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p>If the <a href="#media-element" id="playing-the-media-resource:media-element-35">media element</a>'s <code id="playing-the-media-resource:dom-media-error"><a href="#dom-media-error">error</a></code> attribute is
    not null and its <a href="#concept-mediaerror-code" id="playing-the-media-resource:concept-mediaerror-code">code</a> is <code id="playing-the-media-resource:dom-mediaerror-media_err_src_not_supported"><a href="#dom-mediaerror-media_err_src_not_supported">MEDIA_ERR_SRC_NOT_SUPPORTED</a></code>, then
    return <a id="playing-the-media-resource:a-promise-rejected-with-2" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> a <a id="playing-the-media-resource:notsupportederror-2" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a>
    <code id="playing-the-media-resource:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p class="note">This means that the <a href="#dedicated-media-source-failure-steps" id="playing-the-media-resource:dedicated-media-source-failure-steps">dedicated media source failure steps</a> have run.
    Playback is not possible until the <a href="#media-element-load-algorithm" id="playing-the-media-resource:media-element-load-algorithm">media element load algorithm</a> clears the <code id="playing-the-media-resource:dom-media-error-2"><a href="#dom-media-error">error</a></code> attribute.</p>
   </li><li><p>Let <var>promise</var> be a new promise and append <var>promise</var> to the <a href="#list-of-pending-play-promises" id="playing-the-media-resource:list-of-pending-play-promises-3">list of
   pending play promises</a>.</p></li><li><p>Run the <a href="#internal-play-steps" id="playing-the-media-resource:internal-play-steps">internal play steps</a> for the <a href="#media-element" id="playing-the-media-resource:media-element-36">media element</a>.</p></li><li><p>Return <var>promise</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="internal-play-steps">internal play steps</dfn> for a <a href="#media-element" id="playing-the-media-resource:media-element-37">media element</a> are as follows:</p>

  <ol><li><p>If the <a href="#media-element" id="playing-the-media-resource:media-element-38">media element</a>'s <code id="playing-the-media-resource:dom-media-networkstate"><a href="#dom-media-networkstate">networkState</a></code> attribute has the value <code id="playing-the-media-resource:dom-media-network_empty"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code>, invoke the <a href="#media-element" id="playing-the-media-resource:media-element-39">media element</a>'s
   <a href="#concept-media-load-algorithm" id="playing-the-media-resource:concept-media-load-algorithm">resource selection algorithm</a>.</p></li><li>
    <p>If the <a href="#ended-playback" id="playing-the-media-resource:ended-playback-5">playback has ended</a> and the <a href="#direction-of-playback" id="playing-the-media-resource:direction-of-playback-7">direction of
    playback</a> is forwards, <a href="#dom-media-seek" id="playing-the-media-resource:dom-media-seek-3">seek</a> to the <a href="#earliest-possible-position" id="playing-the-media-resource:earliest-possible-position-4">earliest
    possible position</a> of the <a href="#media-resource" id="playing-the-media-resource:media-resource-18">media resource</a>.</p>

    <p class="note">This <a href="#seekUpdate">will cause</a> the user agent to <a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-6">queue a media
    element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-40">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-8" data-x-internal="concept-event-fire">fire an event</a> named <code id="playing-the-media-resource:event-media-timeupdate-4"><a href="#event-media-timeupdate">timeupdate</a></code> at the <a href="#media-element" id="playing-the-media-resource:media-element-41">media element</a>.</p>
    
   </li><li>
    <p>If the <a href="#media-element" id="playing-the-media-resource:media-element-42">media element</a>'s <code id="playing-the-media-resource:dom-media-paused-9"><a href="#dom-media-paused">paused</a></code> attribute
    is true, then:</p>

    <ol><li><p>Change the value of <code id="playing-the-media-resource:dom-media-paused-10"><a href="#dom-media-paused">paused</a></code> to false.</p></li><li><p>If the <a href="#show-poster-flag" id="playing-the-media-resource:show-poster-flag">show poster flag</a> is true, set the element's <a href="#show-poster-flag" id="playing-the-media-resource:show-poster-flag-2">show poster
     flag</a> to false and run the <i id="playing-the-media-resource:time-marches-on"><a href="#time-marches-on">time marches on</a></i> steps.</p></li><li><p><a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-7">Queue a media element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-43">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-9" data-x-internal="concept-event-fire">fire an event</a> named <code id="playing-the-media-resource:event-media-play"><a href="#event-media-play">play</a></code> at the element.</p></li><li>
      <p>If the <a href="#media-element" id="playing-the-media-resource:media-element-44">media element</a>'s <code id="playing-the-media-resource:dom-media-readystate-7"><a href="#dom-media-readystate">readyState</a></code>
      attribute has the value <code id="playing-the-media-resource:dom-media-have_nothing-2"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>, <code id="playing-the-media-resource:dom-media-have_metadata-4"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code>, or <code id="playing-the-media-resource:dom-media-have_current_data-2"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code>, <a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-8">queue a media element
      task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-45">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-10" data-x-internal="concept-event-fire">fire an
      event</a> named <code id="playing-the-media-resource:event-media-waiting-2"><a href="#event-media-waiting">waiting</a></code> at the element.</p>

      <p>Otherwise, the <a href="#media-element" id="playing-the-media-resource:media-element-46">media element</a>'s <code id="playing-the-media-resource:dom-media-readystate-8"><a href="#dom-media-readystate">readyState</a></code> attribute has the value <code id="playing-the-media-resource:dom-media-have_future_data-4"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> or <code id="playing-the-media-resource:dom-media-have_enough_data-3"><a href="#dom-media-have_enough_data">HAVE_ENOUGH_DATA</a></code>: <a href="#notify-about-playing" id="playing-the-media-resource:notify-about-playing">notify about playing</a>
      for the element.</p>
     </li></ol>
   </li><li>
    <p>Otherwise, if the <a href="#media-element" id="playing-the-media-resource:media-element-47">media element</a>'s <code id="playing-the-media-resource:dom-media-readystate-9"><a href="#dom-media-readystate">readyState</a></code> attribute has the value <code id="playing-the-media-resource:dom-media-have_future_data-5"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> or <code id="playing-the-media-resource:dom-media-have_enough_data-4"><a href="#dom-media-have_enough_data">HAVE_ENOUGH_DATA</a></code>, <a href="#take-pending-play-promises" id="playing-the-media-resource:take-pending-play-promises-3">take pending play
    promises</a> and <a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-9">queue a media element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-48">media element</a>
    to <a href="#resolve-pending-play-promises" id="playing-the-media-resource:resolve-pending-play-promises-2">resolve pending play promises</a> with the result.</p>

    <p class="note">The media element is already playing. However, it's possible that
    <var>promise</var> will be <a href="#reject-pending-play-promises" id="playing-the-media-resource:reject-pending-play-promises-2">rejected</a> before
    the queued task is run.</p>
   </li><li><p>Set the <a href="#media-element" id="playing-the-media-resource:media-element-49">media element</a>'s <a href="#can-autoplay-flag" id="playing-the-media-resource:can-autoplay-flag-2">can autoplay flag</a> to false.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>When the <dfn data-dfn-for="HTMLMediaElement" id="dom-media-pause" data-dfn-type="method"><code>pause()</code></dfn>
  method is invoked, and when the user agent is required to pause the <a href="#media-element" id="playing-the-media-resource:media-element-50">media element</a>,
  the user agent must run the following steps:</p>

  <ol><li><p>If the <a href="#media-element" id="playing-the-media-resource:media-element-51">media element</a>'s <code id="playing-the-media-resource:dom-media-networkstate-2"><a href="#dom-media-networkstate">networkState</a></code> attribute has the value <code id="playing-the-media-resource:dom-media-network_empty-2"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code>, invoke the <a href="#media-element" id="playing-the-media-resource:media-element-52">media element</a>'s
   <a href="#concept-media-load-algorithm" id="playing-the-media-resource:concept-media-load-algorithm-2">resource selection algorithm</a>.</p></li><li><p>Run the <a href="#internal-pause-steps" id="playing-the-media-resource:internal-pause-steps">internal pause steps</a> for the <a href="#media-element" id="playing-the-media-resource:media-element-53">media element</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="internal-pause-steps">internal pause steps</dfn> for a <a href="#media-element" id="playing-the-media-resource:media-element-54">media element</a> are as follows:</p>

  <ol><li><p>Set the <a href="#media-element" id="playing-the-media-resource:media-element-55">media element</a>'s <a href="#can-autoplay-flag" id="playing-the-media-resource:can-autoplay-flag-3">can autoplay flag</a> to false.</p></li><li><p>If the <a href="#media-element" id="playing-the-media-resource:media-element-56">media element</a>'s <code id="playing-the-media-resource:dom-media-paused-11"><a href="#dom-media-paused">paused</a></code> attribute
   is false, run the following steps:</p>

    <ol><li><p>Change the value of <code id="playing-the-media-resource:dom-media-paused-12"><a href="#dom-media-paused">paused</a></code> to true.</p></li><li><p><a href="#take-pending-play-promises" id="playing-the-media-resource:take-pending-play-promises-4">Take pending play promises</a> and let <var>promises</var> be the
     result.</p></li><li>
      <p><a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-10">Queue a media element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-57">media element</a> and the
      following steps:</p>

      <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-11" data-x-internal="concept-event-fire">Fire an event</a> named <code id="playing-the-media-resource:event-media-timeupdate-5"><a href="#event-media-timeupdate">timeupdate</a></code> at the element.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-12" data-x-internal="concept-event-fire">Fire an event</a> named <code id="playing-the-media-resource:event-media-pause-2"><a href="#event-media-pause">pause</a></code> at the element.</p></li><li><p><a href="#reject-pending-play-promises" id="playing-the-media-resource:reject-pending-play-promises-3">Reject pending play promises</a> with <var>promises</var> and an
       <a id="playing-the-media-resource:aborterror-2" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a> <code id="playing-the-media-resource:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
     </li><li><p>Set the <a href="#official-playback-position" id="playing-the-media-resource:official-playback-position">official playback position</a> to the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-8">current playback
     position</a>.</p></li></ol>
   </li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>If the element's <code id="playing-the-media-resource:dom-media-playbackrate-5"><a href="#dom-media-playbackrate">playbackRate</a></code> is positive or zero,
  then the <dfn id="direction-of-playback">direction of playback</dfn> is forwards. Otherwise, it is backwards.</p>
  </div>

  <div data-algorithm="">
  <p id="media-playback">When a <a href="#media-element" id="playing-the-media-resource:media-element-58">media element</a> is <a href="#potentially-playing" id="playing-the-media-resource:potentially-playing-4">potentially playing</a> and
  its <code id="playing-the-media-resource:document"><a href="#document">Document</a></code> is a <a href="#fully-active" id="playing-the-media-resource:fully-active">fully active</a> <code id="playing-the-media-resource:document-2"><a href="#document">Document</a></code>, its <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-9">current
  playback position</a> must increase monotonically at the element's <code id="playing-the-media-resource:dom-media-playbackrate-6"><a href="#dom-media-playbackrate">playbackRate</a></code> units of media time per unit time of the
  <a href="#media-timeline" id="playing-the-media-resource:media-timeline-2">media timeline</a>'s clock. (This specification always refers to this as an
  <i>increase</i>, but that increase could actually be a <em>de</em>crease if the element's <code id="playing-the-media-resource:dom-media-playbackrate-7"><a href="#dom-media-playbackrate">playbackRate</a></code> is negative.)</p>
  </div>

  <p class="note">The element's <code id="playing-the-media-resource:dom-media-playbackrate-8"><a href="#dom-media-playbackrate">playbackRate</a></code> can be
  0.0, in which case the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-10">current playback position</a> doesn't move, despite playback not
  being paused (<code id="playing-the-media-resource:dom-media-paused-13"><a href="#dom-media-paused">paused</a></code> doesn't become true, and the <code id="playing-the-media-resource:event-media-pause-3"><a href="#event-media-pause">pause</a></code> event doesn't fire).</p>

  <p class="note">This specification doesn't define how the user agent achieves the appropriate
  playback rate — depending on the protocol and media available, it is plausible that the user
  agent could negotiate with the server to have the server provide the media data at the appropriate
  rate, so that (except for the period between when the rate is changed and when the server updates
  the stream's playback rate) the client doesn't actually have to drop or interpolate any
  frames.</p>

  <div data-algorithm="">
  <p>Any time the user agent <a href="#await-a-stable-state" id="playing-the-media-resource:await-a-stable-state">provides a stable state</a>,
  the <a href="#official-playback-position" id="playing-the-media-resource:official-playback-position-2">official playback position</a> must be set to the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-11">current playback
  position</a>.</p> 
  </div>

  <div data-algorithm="">
  <p>While the <a href="#direction-of-playback" id="playing-the-media-resource:direction-of-playback-8">direction of playback</a> is backwards, any corresponding audio must be
  <a href="#concept-media-muted" id="playing-the-media-resource:concept-media-muted-2">muted</a>. While the element's <code id="playing-the-media-resource:dom-media-playbackrate-9"><a href="#dom-media-playbackrate">playbackRate</a></code> is so low or so high that the user agent
  cannot play audio usefully, the corresponding audio must also be <a href="#concept-media-muted" id="playing-the-media-resource:concept-media-muted-3">muted</a>. If the element's <code id="playing-the-media-resource:dom-media-playbackrate-10"><a href="#dom-media-playbackrate">playbackRate</a></code> is not 1.0 and <code id="playing-the-media-resource:dom-media-preservespitch"><a href="#dom-media-preservespitch">preservesPitch</a></code> is true, the user agent must apply pitch
  adjustment to preserve the original pitch of the audio. Otherwise, the user agent must speed up
  or slow down the audio without any pitch adjustment.</p>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#media-element" id="playing-the-media-resource:media-element-59">media element</a> is <a href="#potentially-playing" id="playing-the-media-resource:potentially-playing-5">potentially playing</a>, its audio data played
  must be synchronized with the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-12">current playback position</a>, at the element's
  <a href="#effective-media-volume" id="playing-the-media-resource:effective-media-volume">effective media volume</a>. The user agent must play the audio from audio tracks that
  were enabled when the <a href="#event-loop" id="playing-the-media-resource:event-loop-3">event loop</a> last reached <a href="#step1">step 1</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#media-element" id="playing-the-media-resource:media-element-60">media element</a> is not <a href="#potentially-playing" id="playing-the-media-resource:potentially-playing-6">potentially playing</a>, audio must not play
  for the element.</p>
  </div>

  <div data-algorithm="">
  <p><a href="#media-element" id="playing-the-media-resource:media-element-61">Media elements</a> that are <a href="#potentially-playing" id="playing-the-media-resource:potentially-playing-7">potentially playing</a>
  while not <a id="playing-the-media-resource:in-a-document" href="https://dom.spec.whatwg.org/#in-a-document" data-x-internal="in-a-document">in a document</a> must not play any video, but should play any audio component.
  Media elements must not stop playing just because all references to them have been removed; only
  once a media element is in a state where no further audio could ever be played by that element may
  the element be garbage collected.</p>
  </div>

  <p class="note">It is possible for an element to which no explicit references exist to play audio,
  even if such an element is not still actively playing: for instance, it could be unpaused but
  stalled waiting for content to buffer, or it could be still buffering, but with a
  <code id="playing-the-media-resource:event-media-suspend"><a href="#event-media-suspend">suspend</a></code> event listener that begins playback. Even a
  media element whose <a href="#media-resource" id="playing-the-media-resource:media-resource-19">media resource</a> has no audio tracks could eventually play audio
  again if it had an event listener that changes the <a href="#media-resource" id="playing-the-media-resource:media-resource-20">media resource</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>Each <a href="#media-element" id="playing-the-media-resource:media-element-62">media element</a> has a <dfn id="list-of-newly-introduced-cues">list of newly introduced cues</dfn>, which must be
  initially empty. Whenever a <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue">text track cue</a> is added to the <a href="#text-track-list-of-cues" id="playing-the-media-resource:text-track-list-of-cues">list of cues</a> of a <a href="#text-track" id="playing-the-media-resource:text-track">text track</a> that is in the <a href="#list-of-text-tracks" id="playing-the-media-resource:list-of-text-tracks">list of text
  tracks</a> for a <a href="#media-element" id="playing-the-media-resource:media-element-63">media element</a>, that <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-2">cue</a> must
  be added to the <a href="#media-element" id="playing-the-media-resource:media-element-64">media element</a>'s <a href="#list-of-newly-introduced-cues" id="playing-the-media-resource:list-of-newly-introduced-cues">list of newly introduced cues</a>. Whenever
  a <a href="#text-track" id="playing-the-media-resource:text-track-2">text track</a> is added to the <a href="#list-of-text-tracks" id="playing-the-media-resource:list-of-text-tracks-2">list of text tracks</a> for a <a href="#media-element" id="playing-the-media-resource:media-element-65">media
  element</a>, all of the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-3">cues</a> in that <a href="#text-track" id="playing-the-media-resource:text-track-3">text
  track</a>'s <a href="#text-track-list-of-cues" id="playing-the-media-resource:text-track-list-of-cues-2">list of cues</a> must be added to the
  <a href="#media-element" id="playing-the-media-resource:media-element-66">media element</a>'s <a href="#list-of-newly-introduced-cues" id="playing-the-media-resource:list-of-newly-introduced-cues-2">list of newly introduced cues</a>. When a <a href="#media-element" id="playing-the-media-resource:media-element-67">media
  element</a>'s <a href="#list-of-newly-introduced-cues" id="playing-the-media-resource:list-of-newly-introduced-cues-3">list of newly introduced cues</a> has new cues added while the
  <a href="#media-element" id="playing-the-media-resource:media-element-68">media element</a>'s <a href="#show-poster-flag" id="playing-the-media-resource:show-poster-flag-3">show poster flag</a> is not set, then the user agent must
  run the <i id="playing-the-media-resource:time-marches-on-2"><a href="#time-marches-on">time marches on</a></i> steps.</p>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-4">text track cue</a> is removed from the <a href="#text-track-list-of-cues" id="playing-the-media-resource:text-track-list-of-cues-3">list of cues</a> of a <a href="#text-track" id="playing-the-media-resource:text-track-4">text track</a> that is in the <a href="#list-of-text-tracks" id="playing-the-media-resource:list-of-text-tracks-3">list of text
  tracks</a> for a <a href="#media-element" id="playing-the-media-resource:media-element-69">media element</a>, and whenever a <a href="#text-track" id="playing-the-media-resource:text-track-5">text track</a> is removed
  from the <a href="#list-of-text-tracks" id="playing-the-media-resource:list-of-text-tracks-4">list of text tracks</a> of a <a href="#media-element" id="playing-the-media-resource:media-element-70">media element</a>, if the <a href="#media-element" id="playing-the-media-resource:media-element-71">media
  element</a>'s <a href="#show-poster-flag" id="playing-the-media-resource:show-poster-flag-4">show poster flag</a> is not set, then the user agent must run the
  <i id="playing-the-media-resource:time-marches-on-3"><a href="#time-marches-on">time marches on</a></i> steps.</p>
  </div>

  <div data-algorithm="">
  <p>When the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-13">current playback position</a> of a <a href="#media-element" id="playing-the-media-resource:media-element-72">media element</a> changes (e.g.
  due to playback or seeking), the user agent must run the <i id="playing-the-media-resource:time-marches-on-4"><a href="#time-marches-on">time marches
  on</a></i> steps. To support use cases that depend on the timing accuracy of cue event firing, such as
  synchronizing captions with shot changes in a video, user agents should fire cue events as close
  as possible to their position on the media timeline, and ideally within 20 milliseconds. If the
  <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-14">current playback position</a> changes while the steps are running, then the user agent
  must wait for the steps to complete, and then must immediately rerun the steps. These steps are
  thus run as often as possible or needed.</p>
  </div>

  <p class="note">If one iteration takes a long time, this can cause short duration
  <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-5">cues</a> to be skipped over as the user agent rushes ahead to
  "catch up", so these cues will not appear in the <code id="playing-the-media-resource:dom-texttrack-activecues"><a href="#dom-texttrack-activecues">activeCues</a></code> list.</p>

  <div data-algorithm="">
  <p>The <dfn id="time-marches-on"><i>time marches on</i></dfn> steps are as follows:</p>

  <ol><li><p>Let <var>current cues</var> be a list of <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-6">cues</a>, initialized to contain all the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-7">cues</a> of all
   the <a href="#text-track-hidden" id="playing-the-media-resource:text-track-hidden">hidden</a> or <a href="#text-track-showing" id="playing-the-media-resource:text-track-showing">showing</a> <a href="#text-track" id="playing-the-media-resource:text-track-6">text tracks</a> of the <a href="#media-element" id="playing-the-media-resource:media-element-73">media
   element</a> (not the <a href="#text-track-disabled" id="playing-the-media-resource:text-track-disabled">disabled</a> ones) whose <a href="#text-track-cue-start-time" id="playing-the-media-resource:text-track-cue-start-time-2">start times</a> are less than or equal to the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-15">current
   playback position</a> and whose <a href="#text-track-cue-end-time" id="playing-the-media-resource:text-track-cue-end-time-2">end times</a> are
   greater than the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-16">current playback position</a>.</p></li><li><p>Let <var>other cues</var> be a list of <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-8">cues</a>,
   initialized to contain all the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-9">cues</a> of <a href="#text-track-hidden" id="playing-the-media-resource:text-track-hidden-2">hidden</a> and <a href="#text-track-showing" id="playing-the-media-resource:text-track-showing-2">showing</a> <a href="#text-track" id="playing-the-media-resource:text-track-7">text tracks</a> of the <a href="#media-element" id="playing-the-media-resource:media-element-74">media element</a> that are not present in <var>current cues</var>.</p></li><li><p>Let <var>last time</var> be the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-17">current playback position</a> at the
   time this algorithm was last run for this <a href="#media-element" id="playing-the-media-resource:media-element-75">media element</a>, if this is not the first
   time it has run.</p></li><li><p>If the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-18">current playback position</a> has, since the last time this algorithm was
   run, only changed through its usual monotonic increase during normal playback, then let
   <var>missed cues</var> be the list of <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-10">cues</a> in <var>other
   cues</var> whose <a href="#text-track-cue-start-time" id="playing-the-media-resource:text-track-cue-start-time-3">start times</a> are greater than or
   equal to <var>last time</var> and whose <a href="#text-track-cue-end-time" id="playing-the-media-resource:text-track-cue-end-time-3">end times</a>
   are less than or equal to the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-19">current playback position</a>. Otherwise, let <var>missed
   cues</var> be an empty list.</p></li><li><p>Remove all the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-11">cues</a> in <var>missed cues</var>
   that are also in the <a href="#media-element" id="playing-the-media-resource:media-element-76">media element</a>'s <a href="#list-of-newly-introduced-cues" id="playing-the-media-resource:list-of-newly-introduced-cues-4">list of newly introduced cues</a>, and
   then empty the element's <a href="#list-of-newly-introduced-cues" id="playing-the-media-resource:list-of-newly-introduced-cues-5">list of newly introduced cues</a>.</p></li><li><p>If the time was reached through the usual monotonic increase of the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-20">current playback
   position</a> during normal playback, and if the user agent has not fired a <code id="playing-the-media-resource:event-media-timeupdate-6"><a href="#event-media-timeupdate">timeupdate</a></code> event at the element in the past 15 to 250ms
   and is not still running event handlers for such an event, then the user agent must <a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-11">queue a
   media element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-77">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-13" data-x-internal="concept-event-fire">fire an event</a> named <code id="playing-the-media-resource:event-media-timeupdate-7"><a href="#event-media-timeupdate">timeupdate</a></code> at the element. (In the other cases, such as
   explicit seeks, relevant events get fired as part of the overall process of changing the
   <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-21">current playback position</a>.)</p>

   <p class="note">The event thus is not to be fired faster than about 66Hz or slower than 4Hz
   (assuming the event handlers don't take longer than 250ms to run). User agents are encouraged to
   vary the frequency of the event based on the system load and the average cost of processing the
   event each time, so that the UI updates are not any more frequent than the user agent can
   comfortably handle while decoding the video.</p></li><li><p>If all of the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-12">cues</a> in <var>current cues</var>
   have their <a href="#text-track-cue-active-flag" id="playing-the-media-resource:text-track-cue-active-flag">text track cue active flag</a> set, none of the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-13">cues</a> in <var>other cues</var> have their <a href="#text-track-cue-active-flag" id="playing-the-media-resource:text-track-cue-active-flag-2">text track cue active
   flag</a> set, and <var>missed cues</var> is empty, then return.</p></li><li>
    <p>If the time was reached through the usual monotonic increase of the <a href="#current-playback-position" id="playing-the-media-resource:current-playback-position-22">current playback
    position</a> during normal playback, and there are <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-14">cues</a>
    in <var>other cues</var> that have their <a href="#text-track-cue-pause-on-exit-flag" id="playing-the-media-resource:text-track-cue-pause-on-exit-flag">text track cue pause-on-exit flag</a>
    set and that either have their <a href="#text-track-cue-active-flag" id="playing-the-media-resource:text-track-cue-active-flag-3">text track cue active flag</a> set or are also in <var>missed cues</var>, then <a href="#immediately" id="playing-the-media-resource:immediately">immediately</a> <a href="#dom-media-pause" id="playing-the-media-resource:dom-media-pause">pause</a> the
    <a href="#media-element" id="playing-the-media-resource:media-element-78">media element</a>. </p>

    <p class="note">In the other cases, such as explicit seeks, playback is not paused by going past
    the end time of a <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-15">cue</a>, even if that <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-16">cue</a> has its <a href="#text-track-cue-pause-on-exit-flag" id="playing-the-media-resource:text-track-cue-pause-on-exit-flag-2">text track cue pause-on-exit flag</a> set.</p>
   </li><li>
    <p>Let <var>events</var> be a list of <a href="#concept-task" id="playing-the-media-resource:concept-task">tasks</a>,
    initially empty. Each <a href="#concept-task" id="playing-the-media-resource:concept-task-2">task</a> in this list will be associated
    with a <a href="#text-track" id="playing-the-media-resource:text-track-8">text track</a>, a <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-17">text track cue</a>, and a time, which are used to
    sort the list before the <a href="#concept-task" id="playing-the-media-resource:concept-task-3">tasks</a> are queued.</p>

    <p>Let <var>affected tracks</var> be a list of <a href="#text-track" id="playing-the-media-resource:text-track-9">text
    tracks</a>, initially empty.</p>

    <p>When the steps below say to <dfn id="prepare-an-event">prepare an event</dfn> named <var>event</var> for a
    <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-18">text track cue</a> <var>target</var> with a time <var>time</var>, the
    user agent must run these steps:</p>

    <ol><li><p>Let <var>track</var> be the <a href="#text-track" id="playing-the-media-resource:text-track-10">text track</a> with which the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-19">text
     track cue</a> <var>target</var> is associated.</p></li><li><p>Create a <a href="#concept-task" id="playing-the-media-resource:concept-task-4">task</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-14" data-x-internal="concept-event-fire">fire an event</a> named <var>event</var> at
     <var>target</var>.</p></li><li><p>Add the newly created <a href="#concept-task" id="playing-the-media-resource:concept-task-5">task</a> to <var>events</var>, associated with the time <var>time</var>, the <a href="#text-track" id="playing-the-media-resource:text-track-11">text
     track</a> <var>track</var>, and the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-20">text track cue</a> <var>target</var>.</p></li><li><p>Add <var>track</var> to <var>affected tracks</var>.</p></li></ol>
   </li><li><p>For each <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-21">text track cue</a> in <var>missed
   cues</var>, <a href="#prepare-an-event" id="playing-the-media-resource:prepare-an-event">prepare an event</a> named <code id="playing-the-media-resource:event-media-enter"><a href="#event-media-enter">enter</a></code> for the
   <code id="playing-the-media-resource:texttrackcue"><a href="#texttrackcue">TextTrackCue</a></code> object with the <a href="#text-track-cue-start-time" id="playing-the-media-resource:text-track-cue-start-time-4">text track cue start time</a>.</p></li><li><p>For each <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-22">text track cue</a> in <var>other
   cues</var> that either has its <a href="#text-track-cue-active-flag" id="playing-the-media-resource:text-track-cue-active-flag-4">text track cue active flag</a> set or is in <var>missed cues</var>, <a href="#prepare-an-event" id="playing-the-media-resource:prepare-an-event-2">prepare an event</a> named <code id="playing-the-media-resource:event-media-exit"><a href="#event-media-exit">exit</a></code> for the <code id="playing-the-media-resource:texttrackcue-2"><a href="#texttrackcue">TextTrackCue</a></code> object with the later of the
   <a href="#text-track-cue-end-time" id="playing-the-media-resource:text-track-cue-end-time-4">text track cue end time</a> and the <a href="#text-track-cue-start-time" id="playing-the-media-resource:text-track-cue-start-time-5">text track cue start time</a>.</p></li><li><p>For each <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-23">text track cue</a> in <var>current
   cues</var> that does not have its <a href="#text-track-cue-active-flag" id="playing-the-media-resource:text-track-cue-active-flag-5">text track cue active flag</a> set, <a href="#prepare-an-event" id="playing-the-media-resource:prepare-an-event-3">prepare an
   event</a> named <code id="playing-the-media-resource:event-media-enter-2"><a href="#event-media-enter">enter</a></code> for the <code id="playing-the-media-resource:texttrackcue-3"><a href="#texttrackcue">TextTrackCue</a></code>
   object with the <a href="#text-track-cue-start-time" id="playing-the-media-resource:text-track-cue-start-time-6">text track cue start time</a>.</p></li><li>
    <p>Sort the <a href="#concept-task" id="playing-the-media-resource:concept-task-6">tasks</a> in <var>events</var> in ascending
    time order (<a href="#concept-task" id="playing-the-media-resource:concept-task-7">tasks</a> with earlier times first).</p>

    <p>Further sort <a href="#concept-task" id="playing-the-media-resource:concept-task-8">tasks</a> in <var>events</var> that have
    the same time by the relative <a href="#text-track-cue-order" id="playing-the-media-resource:text-track-cue-order">text track cue order</a> of the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-24">text track cues</a> associated with these <a href="#concept-task" id="playing-the-media-resource:concept-task-9">tasks</a>.</p>

    <p>Finally, sort <a href="#concept-task" id="playing-the-media-resource:concept-task-10">tasks</a> in <var>events</var> that have the
    same time and same <a href="#text-track-cue-order" id="playing-the-media-resource:text-track-cue-order-2">text track cue order</a> by placing <a href="#concept-task" id="playing-the-media-resource:concept-task-11">tasks</a> that fire <code id="playing-the-media-resource:event-media-enter-3"><a href="#event-media-enter">enter</a></code>
    events before those that fire <code id="playing-the-media-resource:event-media-exit-2"><a href="#event-media-exit">exit</a></code> events.</p>
   </li><li><p><a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-12">Queue a media element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-79">media element</a> for each
   <a href="#concept-task" id="playing-the-media-resource:concept-task-12">task</a> in <var>events</var>, in list order.</p></li><li><p>Sort <var>affected tracks</var> in the same order as the <a href="#text-track" id="playing-the-media-resource:text-track-12">text tracks</a> appear in the <a href="#media-element" id="playing-the-media-resource:media-element-80">media element</a>'s <a href="#list-of-text-tracks" id="playing-the-media-resource:list-of-text-tracks-5">list of text
   tracks</a>, and remove duplicates.</p>

   </li><li><p>For each <a href="#text-track" id="playing-the-media-resource:text-track-13">text track</a> in <var>affected tracks</var>, in the list order,
   <a href="#queue-a-media-element-task" id="playing-the-media-resource:queue-a-media-element-task-13">queue a media element task</a> given the <a href="#media-element" id="playing-the-media-resource:media-element-81">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-15" data-x-internal="concept-event-fire">fire an event</a> named <code id="playing-the-media-resource:event-media-cuechange"><a href="#event-media-cuechange">cuechange</a></code> at the <code id="playing-the-media-resource:texttrack"><a href="#texttrack">TextTrack</a></code> object, and, if the
   <a href="#text-track" id="playing-the-media-resource:text-track-14">text track</a> has a corresponding <code id="playing-the-media-resource:the-track-element"><a href="#the-track-element">track</a></code> element, to then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="playing-the-media-resource:concept-event-fire-16" data-x-internal="concept-event-fire">fire an event</a> named <code id="playing-the-media-resource:event-media-cuechange-2"><a href="#event-media-cuechange">cuechange</a></code> at the <code id="playing-the-media-resource:the-track-element-2"><a href="#the-track-element">track</a></code> element as well.</p></li><li><p>Set the <a href="#text-track-cue-active-flag" id="playing-the-media-resource:text-track-cue-active-flag-6">text track cue active flag</a> of all the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-25">cues</a> in the <var>current cues</var>, and unset the <a href="#text-track-cue-active-flag" id="playing-the-media-resource:text-track-cue-active-flag-7">text track cue
   active flag</a> of all the <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-26">cues</a> in the <var>other
   cues</var>.</p></li><li><p>Run the <a href="#rules-for-updating-the-text-track-rendering" id="playing-the-media-resource:rules-for-updating-the-text-track-rendering">rules for updating the text track rendering</a> of each of the <a href="#text-track" id="playing-the-media-resource:text-track-15">text tracks</a> in <var>affected tracks</var> that are <a href="#text-track-showing" id="playing-the-media-resource:text-track-showing-3">showing</a>, providing the <a href="#text-track" id="playing-the-media-resource:text-track-16">text track</a>'s <a href="#text-track-language" id="playing-the-media-resource:text-track-language">text track
   language</a> as the fallback language if it is not the empty string. For example, for <a href="#text-track" id="playing-the-media-resource:text-track-17">text tracks</a> based on WebVTT, the <a id="playing-the-media-resource:rules-for-updating-the-display-of-webvtt-text-tracks" href="https://w3c.github.io/webvtt/#rules-for-updating-the-display-of-webvtt-text-tracks" data-x-internal="rules-for-updating-the-display-of-webvtt-text-tracks">rules for updating the display
   of WebVTT text tracks</a>. <a href="#refsWEBVTT">[WEBVTT]</a></p></li></ol>
  </div>

  <div data-algorithm="">
  <p>For the purposes of the algorithm above, a <a href="#text-track-cue" id="playing-the-media-resource:text-track-cue-27">text track cue</a> is considered to be part
  of a <a href="#text-track" id="playing-the-media-resource:text-track-18">text track</a> only if it is listed in the <a href="#text-track-list-of-cues" id="playing-the-media-resource:text-track-list-of-cues-4">text track list of cues</a>, not
  merely if it is associated with the <a href="#text-track" id="playing-the-media-resource:text-track-19">text track</a>.</p>
  </div>

  <p class="note">If the <a href="#media-element" id="playing-the-media-resource:media-element-82">media element</a>'s <a id="playing-the-media-resource:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> stops being a
  <a href="#fully-active" id="playing-the-media-resource:fully-active-2">fully active</a> document, then the playback will <a href="#media-playback">stop</a>
  until the document is active again.</p>

  <div data-algorithm="">
  <p>When a <a href="#media-element" id="playing-the-media-resource:media-element-83">media element</a> is <a href="#remove-an-element-from-a-document" id="playing-the-media-resource:remove-an-element-from-a-document">removed
  from a <code>Document</code></a>, the user agent must run the following steps:</p>

  <ol><li><p><a href="#await-a-stable-state" id="playing-the-media-resource:await-a-stable-state-2">Await a stable state</a>, allowing the <a href="#concept-task" id="playing-the-media-resource:concept-task-13">task</a> that removed the <a href="#media-element" id="playing-the-media-resource:media-element-84">media element</a> from the
   <code id="playing-the-media-resource:document-3"><a href="#document">Document</a></code> to continue. The <a href="#synchronous-section" id="playing-the-media-resource:synchronous-section">synchronous section</a> consists of all the
   remaining steps of this algorithm. (Steps in the <a href="#synchronous-section" id="playing-the-media-resource:synchronous-section-2">synchronous section</a> are marked with
   ⌛.)</p></li><li><p>⌛ If the <a href="#media-element" id="playing-the-media-resource:media-element-85">media element</a> is <a id="playing-the-media-resource:in-a-document-2" href="https://dom.spec.whatwg.org/#in-a-document" data-x-internal="in-a-document">in a document</a>, return.</p></li><li><p>⌛ Run the <a href="#internal-pause-steps" id="playing-the-media-resource:internal-pause-steps-2">internal pause steps</a> for the <a href="#media-element" id="playing-the-media-resource:media-element-86">media element</a>.</p>
  </li></ol>
  </div>

  



  <h5 id="seeking"><span class="secno">4.8.11.9</span> Seeking<a href="#seeking" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-seeking" id="dom-media-seeking-dev">seeking</a></code></dt><dd><p>Returns true if the user agent is currently seeking.</p></dd><dt><code><var>media</var>.<a href="#dom-media-seekable" id="dom-media-seekable-dev">seekable</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seekable" title="The seekable read-only property of HTMLMediaElement objects returns a new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent is able to seek to at the time seekable property is accessed.">HTMLMediaElement/seekable</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>8+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="seeking:timeranges"><a href="#timeranges">TimeRanges</a></code> object that represents the ranges of the <a href="#media-resource" id="seeking:media-resource">media
    resource</a> to which it is possible for the user agent to seek.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-fastseek" id="dom-media-fastseek-dev">fastSeek</a>(<var>time</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/fastSeek" title="The HTMLMediaElement.fastSeek() method quickly seeks the media to the new time with precision tradeoff.">HTMLMediaElement/fastSeek</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Seeks to near the given <var>time</var> as fast as possible, trading precision for speed. (To
    seek to a precise time, use the <code id="seeking:dom-media-currenttime"><a href="#dom-media-currenttime">currentTime</a></code>
    attribute.)</p>

    <p>This does nothing if the media resource has not been loaded.</p>
   </dd></dl>

  

  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-seeking" data-dfn-type="attribute"><code>seeking</code></dfn>
  attribute must initially have the value false.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-fastseek" data-dfn-type="method"><code>fastSeek(<var>time</var>)</code></dfn> method must <a href="#dom-media-seek" id="seeking:dom-media-seek">seek</a> to the time given by <var>time</var>, with the
  <i>approximate-for-speed</i> flag set.</p>
  </div>

  <div data-algorithm="">
  <p>When the user agent is required to <dfn id="dom-media-seek">seek</dfn> to a particular <var>new playback position</var> in the <a href="#media-resource" id="seeking:media-resource-2">media resource</a>, optionally with the
  <i>approximate-for-speed</i> flag set, it means that the user agent must run the following steps.
  This algorithm interacts closely with the <a href="#event-loop" id="seeking:event-loop">event loop</a> mechanism; in particular, it has
  a <a href="#synchronous-section" id="seeking:synchronous-section">synchronous section</a> (which is triggered as part of the <a href="#event-loop" id="seeking:event-loop-2">event loop</a>
  algorithm). Steps in that section are marked with ⌛.</p>

  <ol><li><p>Set the <a href="#media-element" id="seeking:media-element">media element</a>'s <a href="#show-poster-flag" id="seeking:show-poster-flag">show poster flag</a> to false.</p></li><li><p>If the <a href="#media-element" id="seeking:media-element-2">media element</a>'s <code id="seeking:dom-media-readystate"><a href="#dom-media-readystate">readyState</a></code>
   is <code id="seeking:dom-media-have_nothing"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>, return.</p></li><li><p>If the element's <code id="seeking:dom-media-seeking"><a href="#dom-media-seeking">seeking</a></code> IDL attribute is true,
   then another instance of this algorithm is already running. Abort that other instance of the
   algorithm without waiting for the step that it is running to complete.</p></li><li><p>Set the <code id="seeking:dom-media-seeking-2"><a href="#dom-media-seeking">seeking</a></code> IDL attribute to true.</p></li><li><p>If the seek was in response to a DOM method call or setting of an IDL attribute, then
   continue the script. The remainder of these steps must be run <a href="#in-parallel" id="seeking:in-parallel">in parallel</a>. With the exception
   of the steps marked with ⌛, they could be aborted at any time by another instance of this
   algorithm being invoked.</p></li><li><p>If the <var>new playback position</var> is later than the end of the <a href="#media-resource" id="seeking:media-resource-3">media
   resource</a>, then let it be the end of the <a href="#media-resource" id="seeking:media-resource-4">media resource</a> instead.</p></li><li><p>If the <var>new playback position</var> is less than the <a href="#earliest-possible-position" id="seeking:earliest-possible-position">earliest possible
   position</a>, let it be that position instead.</p></li><li><p>If the (possibly now changed) <var>new playback position</var> is not in one of
   the ranges given in the <code id="seeking:dom-media-seekable"><a href="#dom-media-seekable">seekable</a></code> attribute, then let it
   be the position in one of the ranges given in the <code id="seeking:dom-media-seekable-2"><a href="#dom-media-seekable">seekable</a></code> attribute that is the nearest to the <var>new
   playback position</var>. If two positions both satisfy that constraint (i.e. the <var>new playback position</var> is exactly in the middle between two ranges in the <code id="seeking:dom-media-seekable-3"><a href="#dom-media-seekable">seekable</a></code> attribute), then use the position that is closest to
   the <a href="#current-playback-position" id="seeking:current-playback-position">current playback position</a>. If there are no ranges given in the <code id="seeking:dom-media-seekable-4"><a href="#dom-media-seekable">seekable</a></code> attribute, then set the <code id="seeking:dom-media-seeking-3"><a href="#dom-media-seeking">seeking</a></code> IDL attribute to false and return.</p></li><li>
    <p>If the <i>approximate-for-speed</i> flag is set, adjust the <var>new playback
    position</var> to a value that will allow for playback to resume promptly. If <var>new
    playback position</var> before this step is before <a href="#current-playback-position" id="seeking:current-playback-position-2">current playback position</a>, then
    the adjusted <var>new playback position</var> must also be before the <a href="#current-playback-position" id="seeking:current-playback-position-3">current
    playback position</a>. Similarly, if the <var>new playback position</var> before
    this step is after <a href="#current-playback-position" id="seeking:current-playback-position-4">current playback position</a>, then the adjusted <var>new
    playback position</var> must also be after the <a href="#current-playback-position" id="seeking:current-playback-position-5">current playback position</a>.</p>

    <p class="example">For example, the user agent could snap to a nearby key frame, so that it
    doesn't have to spend time decoding then discarding intermediate frames before resuming
    playback.</p>
   </li><li><p><a href="#queue-a-media-element-task" id="seeking:queue-a-media-element-task">Queue a media element task</a> given the <a href="#media-element" id="seeking:media-element-3">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="seeking:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="seeking:event-media-seeking"><a href="#event-media-seeking">seeking</a></code> at the element.</p></li><li>
    <p>Set the <a href="#current-playback-position" id="seeking:current-playback-position-6">current playback position</a> to the <var>new playback
    position</var>.</p>

    <p class="note">If the <a href="#media-element" id="seeking:media-element-4">media element</a> was <a href="#potentially-playing" id="seeking:potentially-playing">potentially playing</a>
    immediately before it started seeking, but seeking caused its <code id="seeking:dom-media-readystate-2"><a href="#dom-media-readystate">readyState</a></code> attribute to change to a value lower than <code id="seeking:dom-media-have_future_data"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code>, then a <code id="seeking:event-media-waiting"><a href="#event-media-waiting">waiting</a></code> event <a href="#fire-waiting-when-waiting">will be
    fired</a> at the element.</p> 

    <p class="note">This step sets the <a href="#current-playback-position" id="seeking:current-playback-position-7">current playback position</a>, and thus can
    immediately trigger other conditions, such as the rules regarding when playback "<a href="#reaches-the-end">reaches the end of the media resource</a>" (part of the logic that
    handles looping), even before the user agent is actually able to render the media data for that
    position (as determined in the next step).</p>

    <p class="note">The <code id="seeking:dom-media-currenttime-2"><a href="#dom-media-currenttime">currentTime</a></code> attribute returns
    the <a href="#official-playback-position" id="seeking:official-playback-position">official playback position</a>, not the <a href="#current-playback-position" id="seeking:current-playback-position-8">current playback position</a>, and
    therefore gets updated before script execution, separate from this algorithm.</p>
   </li><li><p>Wait until the user agent has established whether or not the <a href="#media-data" id="seeking:media-data">media data</a> for
   the <var>new playback position</var> is available, and, if it is, until it has decoded
   enough data to play back that position.</p></li><li><p><a href="#await-a-stable-state" id="seeking:await-a-stable-state">Await a stable state</a>. The <a href="#synchronous-section" id="seeking:synchronous-section-2">synchronous section</a> consists of all
   the remaining steps of this algorithm. (Steps in the <a href="#synchronous-section" id="seeking:synchronous-section-3">synchronous section</a> are marked
   with ⌛.)</p></li><li><p>⌛ Set the <code id="seeking:dom-media-seeking-4"><a href="#dom-media-seeking">seeking</a></code> IDL attribute to
   false.</p></li><li><p>⌛ Run the <a href="#time-marches-on" id="seeking:time-marches-on">time marches on</a> steps.</p></li><li id="seekUpdate"><p>⌛ <a href="#queue-a-media-element-task" id="seeking:queue-a-media-element-task-2">Queue a media element task</a> given the <a href="#media-element" id="seeking:media-element-5">media
   element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="seeking:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="seeking:event-media-timeupdate"><a href="#event-media-timeupdate">timeupdate</a></code> at the element.</p></li><li><p>⌛ <a href="#queue-a-media-element-task" id="seeking:queue-a-media-element-task-3">Queue a media element task</a> given the <a href="#media-element" id="seeking:media-element-6">media element</a> to
   <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="seeking:concept-event-fire-3" data-x-internal="concept-event-fire">fire an event</a> named <code id="seeking:event-media-seeked"><a href="#event-media-seeked">seeked</a></code> at the element.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-seekable" data-dfn-type="attribute"><code>seekable</code></dfn> attribute must return a new static
  <a href="#normalised-timeranges-object" id="seeking:normalised-timeranges-object">normalized <code>TimeRanges</code> object</a> that represents the ranges of the
  <a href="#media-resource" id="seeking:media-resource-5">media resource</a>, if any, that the user agent is able to seek to, at the time the
  attribute is evaluated.</p>
  </div>

  <p class="note">If the user agent can seek to anywhere in the <a href="#media-resource" id="seeking:media-resource-6">media resource</a>, e.g.
  because it is a simple movie file and the user agent and the server support HTTP Range requests,
  then the attribute would return an object with one range, whose start is the time of the first
  frame (the <a href="#earliest-possible-position" id="seeking:earliest-possible-position-2">earliest possible position</a>, typically zero), and whose end is the same as
  the time of the first frame plus the <code id="seeking:dom-media-duration"><a href="#dom-media-duration">duration</a></code> attribute's
  value (which would equal the time of the last frame, and might be positive Infinity).</p>

  <p class="note">The range might be continuously changing, e.g. if the user agent is buffering a
  sliding window on an infinite stream. This is the behavior seen with DVRs viewing live TV, for
  instance.</p>

  <p class="warning">Returning a new object each time is a bad pattern for attribute getters and is
  only enshrined here as it would be costly to change it. It is not to be copied to new APIs.</p>

  <p>User agents should adopt a very liberal and optimistic view of what is seekable. User
  agents should also buffer recent content where possible to enable seeking to be fast.</p>

  <p class="example">For instance, consider a large video file served on an HTTP server without
  support for HTTP Range requests. A browser <em>could</em> implement this by only buffering the
  current frame and data obtained for subsequent frames, never allow seeking, except for seeking to
  the very start by restarting the playback. However, this would be a poor implementation. A high
  quality implementation would buffer the last few minutes of content (or more, if sufficient
  storage space is available), allowing the user to jump back and rewatch something surprising
  without any latency, and would in addition allow arbitrary seeking by reloading the file from the
  start if necessary, which would be slower but still more convenient than having to literally
  restart the video and watch it all the way through just to get to an earlier unbuffered spot.</p>

  <p><a href="#media-resource" id="seeking:media-resource-7">Media resources</a> might be internally scripted or
  interactive. Thus, a <a href="#media-element" id="seeking:media-element-7">media element</a> could play in a non-linear fashion. If this
  happens, the user agent must act as if the algorithm for <a href="#dom-media-seek" id="seeking:dom-media-seek-2">seeking</a> was used whenever the <a href="#current-playback-position" id="seeking:current-playback-position-9">current playback position</a>
  changes in a discontinuous fashion (so that the relevant events fire).</p>

  


  <h5 id="media-resources-with-multiple-media-tracks"><span class="secno">4.8.11.10</span> Media resources with multiple media tracks<a href="#media-resources-with-multiple-media-tracks" class="self-link"></a></h5>

  <p>A <a href="#media-resource" id="media-resources-with-multiple-media-tracks:media-resource">media resource</a> can have multiple embedded audio and video tracks. For example,
  in addition to the primary video and audio tracks, a <a href="#media-resource" id="media-resources-with-multiple-media-tracks:media-resource-2">media resource</a> could have
  foreign-language dubbed dialogues, director's commentaries, audio descriptions, alternative
  angles, or sign-language overlays.</p>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-audiotracks" id="dom-media-audiotracks-dev">audioTracks</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/audioTracks" title="The read-only audioTracks property on HTMLMediaElement objects returns an AudioTrackList object listing all of the AudioTrack objects representing the media element's audio tracks.">HTMLMediaElement/audioTracks</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="media-resources-with-multiple-media-tracks:audiotracklist"><a href="#audiotracklist">AudioTrackList</a></code> object representing the audio tracks available in the
    <a href="#media-resource" id="media-resources-with-multiple-media-tracks:media-resource-3">media resource</a>.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-videotracks" id="dom-media-videotracks-dev">videoTracks</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/videoTracks" title="The read-only videoTracks property on HTMLMediaElement objects returns a VideoTrackList object listing all of the VideoTrack objects representing the media element's video tracks.">HTMLMediaElement/videoTracks</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="media-resources-with-multiple-media-tracks:videotracklist"><a href="#videotracklist">VideoTrackList</a></code> object representing the video tracks available in the
    <a href="#media-resource" id="media-resources-with-multiple-media-tracks:media-resource-4">media resource</a>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-audiotracks" data-dfn-type="attribute"><code>audioTracks</code></dfn> attribute of a <a href="#media-element" id="media-resources-with-multiple-media-tracks:media-element">media element</a>
  must return a <a href="#live" id="media-resources-with-multiple-media-tracks:live">live</a> <code id="media-resources-with-multiple-media-tracks:audiotracklist-2"><a href="#audiotracklist">AudioTrackList</a></code> object representing the audio tracks
  available in the <a href="#media-element" id="media-resources-with-multiple-media-tracks:media-element-2">media element</a>'s <a href="#media-resource" id="media-resources-with-multiple-media-tracks:media-resource-5">media resource</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-videotracks" data-dfn-type="attribute"><code>videoTracks</code></dfn> attribute of a <a href="#media-element" id="media-resources-with-multiple-media-tracks:media-element-3">media element</a>
  must return a <a href="#live" id="media-resources-with-multiple-media-tracks:live-2">live</a> <code id="media-resources-with-multiple-media-tracks:videotracklist-2"><a href="#videotracklist">VideoTrackList</a></code> object representing the video tracks
  available in the <a href="#media-element" id="media-resources-with-multiple-media-tracks:media-element-4">media element</a>'s <a href="#media-resource" id="media-resources-with-multiple-media-tracks:media-resource-6">media resource</a>.</p>
  </div>

  <p class="note">There are only ever one <code id="media-resources-with-multiple-media-tracks:audiotracklist-3"><a href="#audiotracklist">AudioTrackList</a></code> object and one
  <code id="media-resources-with-multiple-media-tracks:videotracklist-3"><a href="#videotracklist">VideoTrackList</a></code> object per <a href="#media-element" id="media-resources-with-multiple-media-tracks:media-element-5">media element</a>, even if another <a href="#media-resource" id="media-resources-with-multiple-media-tracks:media-resource-7">media
  resource</a> is loaded into the element: the objects are reused. (The <code id="media-resources-with-multiple-media-tracks:audiotrack"><a href="#audiotrack">AudioTrack</a></code>
  and <code id="media-resources-with-multiple-media-tracks:videotrack"><a href="#videotrack">VideoTrack</a></code> objects are not, though.)</p>

  


  <h6 id="audiotracklist-and-videotracklist-objects"><span class="secno">4.8.11.10.1</span> <code id="audiotracklist-and-videotracklist-objects:audiotracklist"><a href="#audiotracklist">AudioTrackList</a></code> and <code id="audiotracklist-and-videotracklist-objects:videotracklist"><a href="#videotracklist">VideoTrackList</a></code> objects<a href="#audiotracklist-and-videotracklist-objects" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList" title="The AudioTrackList interface is used to represent a list of the audio tracks contained within a given HTML media element, with each track represented by a separate AudioTrack object in the list.">AudioTrackList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList" title="The VideoTrackList interface is used to represent a list of the video tracks contained within a <video> element, with each track represented by a separate VideoTrack object in the list.">VideoTrackList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList" title="The AudioTrackList interface is used to represent a list of the audio tracks contained within a given HTML media element, with each track represented by a separate AudioTrack object in the list.">AudioTrackList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span><hr><span class="caniuse"><span><a href="https://caniuse.com/#feat=audiotracks" title="Audio Tracks">caniuse.com table</a></span></span></div></div></div>

  <p>The <code id="audiotracklist-and-videotracklist-objects:audiotracklist-2"><a href="#audiotracklist">AudioTrackList</a></code> and <code id="audiotracklist-and-videotracklist-objects:videotracklist-2"><a href="#videotracklist">VideoTrackList</a></code> interfaces are used by
  attributes defined in the previous section.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack" title="The AudioTrack interface represents a single audio track from one of the HTML media elements, <audio> or <video>.">AudioTrack</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack" title="The VideoTrack interface represents a single video track from a <video> element.">VideoTrack</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="audiotracklist" data-dfn-type="interface"><c- g="">AudioTrackList</c-></dfn> : <a id="audiotracklist-and-videotracklist-objects:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-audiotracklist-length" id="audiotracklist-and-videotracklist-objects:dom-audiotracklist-length"><c- g="">length</c-></a>;
  <a href="#dom-tracklist-item"><c- b="">getter</c-></a> <a href="#audiotrack" id="audiotracklist-and-videotracklist-objects:audiotrack"><c- n="">AudioTrack</c-></a> (<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <a href="#audiotrack" id="audiotracklist-and-videotracklist-objects:audiotrack-2"><c- n="">AudioTrack</c-></a>? <a href="#dom-audiotracklist-gettrackbyid" id="audiotracklist-and-videotracklist-objects:dom-audiotracklist-gettrackbyid"><c- g="">getTrackById</c-></a>(<c- b="">DOMString</c-> <c- g="">id</c->);

  <c- b="">attribute</c-> <a href="#eventhandler" id="audiotracklist-and-videotracklist-objects:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-tracklist-onchange" id="audiotracklist-and-videotracklist-objects:handler-tracklist-onchange"><c- g="">onchange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="audiotracklist-and-videotracklist-objects:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-tracklist-onaddtrack" id="audiotracklist-and-videotracklist-objects:handler-tracklist-onaddtrack"><c- g="">onaddtrack</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="audiotracklist-and-videotracklist-objects:eventhandler-3"><c- n="">EventHandler</c-></a> <a href="#handler-tracklist-onremovetrack" id="audiotracklist-and-videotracklist-objects:handler-tracklist-onremovetrack"><c- g="">onremovetrack</c-></a>;
};

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="audiotrack" data-dfn-type="interface"><c- g="">AudioTrack</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-audiotrack-id" id="audiotracklist-and-videotracklist-objects:dom-audiotrack-id"><c- g="">id</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-audiotrack-kind" id="audiotracklist-and-videotracklist-objects:dom-audiotrack-kind"><c- g="">kind</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-audiotrack-label" id="audiotracklist-and-videotracklist-objects:dom-audiotrack-label"><c- g="">label</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-audiotrack-language" id="audiotracklist-and-videotracklist-objects:dom-audiotrack-language"><c- g="">language</c-></a>;
  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-audiotrack-enabled" id="audiotracklist-and-videotracklist-objects:dom-audiotrack-enabled"><c- g="">enabled</c-></a>;
};

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="videotracklist" data-dfn-type="interface"><c- g="">VideoTrackList</c-></dfn> : <a id="audiotracklist-and-videotracklist-objects:eventtarget-2" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-videotracklist-length" id="audiotracklist-and-videotracklist-objects:dom-videotracklist-length"><c- g="">length</c-></a>;
  <a href="#dom-tracklist-item"><c- b="">getter</c-></a> <a href="#videotrack" id="audiotracklist-and-videotracklist-objects:videotrack"><c- n="">VideoTrack</c-></a> (<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <a href="#videotrack" id="audiotracklist-and-videotracklist-objects:videotrack-2"><c- n="">VideoTrack</c-></a>? <a href="#dom-videotracklist-gettrackbyid" id="audiotracklist-and-videotracklist-objects:dom-videotracklist-gettrackbyid"><c- g="">getTrackById</c-></a>(<c- b="">DOMString</c-> <c- g="">id</c->);
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">long</c-> <a href="#dom-videotracklist-selectedindex" id="audiotracklist-and-videotracklist-objects:dom-videotracklist-selectedindex"><c- g="">selectedIndex</c-></a>;

  <c- b="">attribute</c-> <a href="#eventhandler" id="audiotracklist-and-videotracklist-objects:eventhandler-4"><c- n="">EventHandler</c-></a> <a href="#handler-tracklist-onchange" id="audiotracklist-and-videotracklist-objects:handler-tracklist-onchange-2"><c- g="">onchange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="audiotracklist-and-videotracklist-objects:eventhandler-5"><c- n="">EventHandler</c-></a> <a href="#handler-tracklist-onaddtrack" id="audiotracklist-and-videotracklist-objects:handler-tracklist-onaddtrack-2"><c- g="">onaddtrack</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="audiotracklist-and-videotracklist-objects:eventhandler-6"><c- n="">EventHandler</c-></a> <a href="#handler-tracklist-onremovetrack" id="audiotracklist-and-videotracklist-objects:handler-tracklist-onremovetrack-2"><c- g="">onremovetrack</c-></a>;
};

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="videotrack" data-dfn-type="interface"><c- g="">VideoTrack</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-videotrack-id" id="audiotracklist-and-videotracklist-objects:dom-videotrack-id"><c- g="">id</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-videotrack-kind" id="audiotracklist-and-videotracklist-objects:dom-videotrack-kind"><c- g="">kind</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-videotrack-label" id="audiotracklist-and-videotracklist-objects:dom-videotrack-label"><c- g="">label</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-videotrack-language" id="audiotracklist-and-videotracklist-objects:dom-videotrack-language"><c- g="">language</c-></a>;
  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-videotrack-selected" id="audiotracklist-and-videotracklist-objects:dom-videotrack-selected"><c- g="">selected</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-audiotracks" id="audiotracklist-and-videotracklist-objects:dom-media-audiotracks">audioTracks</a>.<a href="#dom-audiotracklist-length" id="dom-audiotracklist-length-dev">length</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList/length" title="The read-only AudioTrackList property length returns the number of entries in the AudioTrackList, each of which is an AudioTrack representing one audio track in the media element. A value of 0 indicates that there are no audio tracks in the media.">AudioTrackList/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>media</var>.<a href="#dom-media-videotracks" id="audiotracklist-and-videotracklist-objects:dom-media-videotracks">videoTracks</a>.<a href="#dom-videotracklist-length" id="dom-videotracklist-length-dev">length</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList/length" title="The read-only VideoTrackList property length returns the number of entries in the VideoTrackList, each of which is a VideoTrack representing one video track in the media element.">VideoTrackList/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the number of tracks in the list.</p></dd><dt><code><var>audioTrack</var> = <var>media</var>.<a href="#dom-media-audiotracks" id="audiotracklist-and-videotracklist-objects:dom-media-audiotracks-2">audioTracks</a>[<var>index</var>]</code></dt><dt><code><var>videoTrack</var> = <var>media</var>.<a href="#dom-media-videotracks" id="audiotracklist-and-videotracklist-objects:dom-media-videotracks-2">videoTracks</a>[<var>index</var>]</code></dt><dd><p>Returns the specified <code id="audiotracklist-and-videotracklist-objects:audiotrack-3"><a href="#audiotrack">AudioTrack</a></code> or <code id="audiotracklist-and-videotracklist-objects:videotrack-3"><a href="#videotrack">VideoTrack</a></code> object.</p></dd><dt><code><var>audioTrack</var> = <var>media</var>.<a href="#dom-media-audiotracks" id="audiotracklist-and-videotracklist-objects:dom-media-audiotracks-3">audioTracks</a>.<a href="#dom-audiotracklist-gettrackbyid" id="dom-audiotracklist-gettrackbyid-dev">getTrackById</a>(<var>id</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList/getTrackById" title="The AudioTrackList method getTrackById() returns the first AudioTrack object from the track list whose id matches the specified string. This lets you find a specified track if you know its ID string.">AudioTrackList/getTrackById</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>videoTrack</var> = <var>media</var>.<a href="#dom-media-videotracks" id="audiotracklist-and-videotracklist-objects:dom-media-videotracks-3">videoTracks</a>.<a href="#dom-videotracklist-gettrackbyid" id="dom-videotracklist-gettrackbyid-dev">getTrackById</a>(<var>id</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList/getTrackById" title="The VideoTrackList method getTrackById() returns the first VideoTrack object from the track list whose id matches the specified string.">VideoTrackList/getTrackById</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="audiotracklist-and-videotracklist-objects:audiotrack-4"><a href="#audiotrack">AudioTrack</a></code> or <code id="audiotracklist-and-videotracklist-objects:videotrack-4"><a href="#videotrack">VideoTrack</a></code> object with the given
    identifier, or null if no track has that identifier.</p>
   </dd><dt><code><var>audioTrack</var>.<a href="#dom-audiotrack-id" id="dom-audiotrack-id-dev">id</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/id" title="The id property contains a string which uniquely identifies the track represented by the AudioTrack.">AudioTrack/id</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>videoTrack</var>.<a href="#dom-videotrack-id" id="dom-videotrack-id-dev">id</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/id" title="The id property contains a string which uniquely identifies the track represented by the VideoTrack.">VideoTrack/id</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the ID of the given track. This is the ID that can be used with a <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="audiotracklist-and-videotracklist-objects:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> if the format supports <a id="audiotracklist-and-videotracklist-objects:media-fragment-syntax" href="https://www.w3.org/TR/media-frags/#media-fragment-syntax" data-x-internal="media-fragment-syntax">media fragment
    syntax</a>, and that can be used with the <code>getTrackById()</code> method.</p>
   </dd><dt><code><var>audioTrack</var>.<a href="#dom-audiotrack-kind" id="dom-audiotrack-kind-dev">kind</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/kind" title="The kind property contains a string indicating the category of audio contained in the AudioTrack.">AudioTrack/kind</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>videoTrack</var>.<a href="#dom-videotrack-kind" id="dom-videotrack-kind-dev">kind</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/kind" title="The kind property contains a string indicating the category of video contained in the VideoTrack.">VideoTrack/kind</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the category the given track falls into. The <a href="#dom-TrackList-getKind-categories">possible track categories</a> are given below.</p></dd><dt><code><var>audioTrack</var>.<a href="#dom-audiotrack-label" id="dom-audiotrack-label-dev">label</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/label" title="The read-only AudioTrack property label returns a string specifying the audio track's human-readable label, if one is available; otherwise, it returns an empty string.">AudioTrack/label</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>videoTrack</var>.<a href="#dom-videotrack-label" id="dom-videotrack-label-dev">label</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/label" title="The read-only VideoTrack property label returns a string specifying the video track's human-readable label, if one is available; otherwise, it returns an empty string.">VideoTrack/label</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the label of the given track, if known, or the empty string otherwise.</p></dd><dt><code><var>audioTrack</var>.<a href="#dom-audiotrack-language" id="dom-audiotrack-language-dev">language</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/language" title="The read-only AudioTrack property language returns a string identifying the language used in the audio track.">AudioTrack/language</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>videoTrack</var>.<a href="#dom-videotrack-language" id="dom-videotrack-language-dev">language</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/language" title="The read-only VideoTrack property language returns a string identifying the language used in the video track.">VideoTrack/language</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the language of the given track, if known, or the empty string otherwise.</p></dd><dt><code><var>audioTrack</var>.<a href="#dom-audiotrack-enabled" id="dom-audiotrack-enabled-dev">enabled</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/enabled" title="The AudioTrack property enabled specifies whether or not the described audio track is currently enabled for use. If the track is disabled by setting enabled to false, the track is muted and does not produce audio.">AudioTrack/enabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns true if the given track is active, and false otherwise.</p>

    <p>Can be set, to change whether the track is enabled or not. If multiple audio tracks are
    enabled simultaneously, they are mixed.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-videotracks" id="audiotracklist-and-videotracklist-objects:dom-media-videotracks-4">videoTracks</a>.<a href="#dom-videotracklist-selectedindex" id="dom-videotracklist-selectedindex-dev">selectedIndex</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList/selectedIndex" title="The read-only VideoTrackList property selectedIndex returns the index of the currently selected track, if any, or -1 otherwise.">VideoTrackList/selectedIndex</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the index of the currently selected track, if any, or −1
   otherwise.</p></dd><dt><code><var>videoTrack</var>.<a href="#dom-videotrack-selected" id="dom-videotrack-selected-dev">selected</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/selected" title="The VideoTrack property selected controls whether or not a particular video track is active.">VideoTrack/selected</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns true if the given track is active, and false otherwise.</p>

    <p>Can be set, to change whether the track is selected or not. Either zero or one video track is
    selected; selecting a new track while a previous one is selected will unselect the previous
    one.</p>
   </dd></dl>

  

  <p>An <code id="audiotracklist-and-videotracklist-objects:audiotracklist-3"><a href="#audiotracklist">AudioTrackList</a></code> object represents a dynamic list of zero or more audio tracks,
  of which zero or more can be enabled at a time. Each audio track is represented by an
  <code id="audiotracklist-and-videotracklist-objects:audiotrack-5"><a href="#audiotrack">AudioTrack</a></code> object.</p>

  <p>A <code id="audiotracklist-and-videotracklist-objects:videotracklist-3"><a href="#videotracklist">VideoTrackList</a></code> object represents a dynamic list of zero or more video tracks, of
  which zero or one can be selected at a time. Each video track is represented by a
  <code id="audiotracklist-and-videotracklist-objects:videotrack-5"><a href="#videotrack">VideoTrack</a></code> object.</p>

  <p>Tracks in <code id="audiotracklist-and-videotracklist-objects:audiotracklist-4"><a href="#audiotracklist">AudioTrackList</a></code> and <code id="audiotracklist-and-videotracklist-objects:videotracklist-4"><a href="#videotracklist">VideoTrackList</a></code> objects must be
  consistently ordered. If the <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource">media resource</a> is in a format that defines an order,
  then that order must be used; otherwise, the order must be the relative order in which the tracks
  are declared in the <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource-2">media resource</a>. The order used is called the <i>natural order</i>
  of the list.</p>

  <p class="note">Each track in one of these objects thus has an index; the first has the index
  0, and each subsequent track is numbered one higher than the previous one. If a <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource-3">media
  resource</a> dynamically adds or removes audio or video tracks, then the indices of the tracks
  will change dynamically. If the <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource-4">media resource</a> changes entirely, then all the
  previous tracks will be removed and replaced with new tracks.</p>

  <div data-algorithm="">
  <p>The <code id="audiotracklist-and-videotracklist-objects:audiotracklist-5"><a href="#audiotracklist">AudioTrackList</a></code> <dfn data-dfn-for="AudioTrackList" id="dom-audiotracklist-length" data-dfn-type="attribute"><code>length</code></dfn> and <code id="audiotracklist-and-videotracklist-objects:videotracklist-5"><a href="#videotracklist">VideoTrackList</a></code>
  <dfn data-dfn-for="VideoTrackList" id="dom-videotracklist-length" data-dfn-type="attribute"><code>length</code></dfn>
  attribute getters must return the number of tracks represented by their objects at the time of
  getting.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="audiotracklist-and-videotracklist-objects:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> of <code id="audiotracklist-and-videotracklist-objects:audiotracklist-6"><a href="#audiotracklist">AudioTrackList</a></code> and
  <code id="audiotracklist-and-videotracklist-objects:videotracklist-6"><a href="#videotracklist">VideoTrackList</a></code> objects at any instant are the numbers from zero to the number of
  tracks represented by the respective object minus one, if any tracks are represented. If an
  <code id="audiotracklist-and-videotracklist-objects:audiotracklist-7"><a href="#audiotracklist">AudioTrackList</a></code> or <code id="audiotracklist-and-videotracklist-objects:videotracklist-7"><a href="#videotracklist">VideoTrackList</a></code> object represents no tracks, it has no
  <a id="audiotracklist-and-videotracklist-objects:supported-property-indices-2" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a>.</p>
  </div>

  <div data-algorithm="">
  <p id="dom-tracklist-item">To <a id="audiotracklist-and-videotracklist-objects:determine-the-value-of-an-indexed-property" href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-an-indexed-property" data-x-internal="determine-the-value-of-an-indexed-property">determine the value of an indexed property</a> for a
  given index <var>index</var> in an <code id="audiotracklist-and-videotracklist-objects:audiotracklist-8"><a href="#audiotracklist">AudioTrackList</a></code> or <code id="audiotracklist-and-videotracklist-objects:videotracklist-8"><a href="#videotracklist">VideoTrackList</a></code>
  object <var>list</var>, the user agent must return the <code id="audiotracklist-and-videotracklist-objects:audiotrack-6"><a href="#audiotrack">AudioTrack</a></code> or
  <code id="audiotracklist-and-videotracklist-objects:videotrack-6"><a href="#videotrack">VideoTrack</a></code> object that represents the <var>index</var>th track in <var>list</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="audiotracklist-and-videotracklist-objects:audiotracklist-9"><a href="#audiotracklist">AudioTrackList</a></code> <dfn data-dfn-for="AudioTrackList" id="dom-audiotracklist-gettrackbyid" data-dfn-type="method"><code>getTrackById(<var>id</var>)</code></dfn> and
  <code id="audiotracklist-and-videotracklist-objects:videotracklist-9"><a href="#videotracklist">VideoTrackList</a></code> <dfn data-dfn-for="VideoTrackList" id="dom-videotracklist-gettrackbyid" data-dfn-type="method"><code>getTrackById(<var>id</var>)</code></dfn> methods must
  return the first <code id="audiotracklist-and-videotracklist-objects:audiotrack-7"><a href="#audiotrack">AudioTrack</a></code> or <code id="audiotracklist-and-videotracklist-objects:videotrack-7"><a href="#videotrack">VideoTrack</a></code> object (respectively) in the
  <code id="audiotracklist-and-videotracklist-objects:audiotracklist-10"><a href="#audiotracklist">AudioTrackList</a></code> or <code id="audiotracklist-and-videotracklist-objects:videotracklist-10"><a href="#videotracklist">VideoTrackList</a></code> object (respectively) whose identifier
  is equal to the value of the <var>id</var> argument (in the natural order of the list, as defined
  above). When no tracks match the given argument, the methods must return null.</p>
  </div>

  <p>The <code id="audiotracklist-and-videotracklist-objects:audiotrack-8"><a href="#audiotrack">AudioTrack</a></code> and <code id="audiotracklist-and-videotracklist-objects:videotrack-8"><a href="#videotrack">VideoTrack</a></code> objects represent specific tracks of a
  <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource-5">media resource</a>. Each track can have an identifier, category, label, and language.
  These aspects of a track are permanent for the lifetime of the track; even if a track is removed
  from a <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource-6">media resource</a>'s <code id="audiotracklist-and-videotracklist-objects:audiotracklist-11"><a href="#audiotracklist">AudioTrackList</a></code> or <code id="audiotracklist-and-videotracklist-objects:videotracklist-11"><a href="#videotracklist">VideoTrackList</a></code>
  objects, those aspects do not change.</p>

  <p>In addition, <code id="audiotracklist-and-videotracklist-objects:audiotrack-9"><a href="#audiotrack">AudioTrack</a></code> objects can each be enabled or disabled; this is the audio
  track's <i>enabled state</i>. When an <code id="audiotracklist-and-videotracklist-objects:audiotrack-10"><a href="#audiotrack">AudioTrack</a></code> is created, its <i>enabled state</i>
  must be set to false (disabled). The <a href="#concept-media-load-resource" id="audiotracklist-and-videotracklist-objects:concept-media-load-resource">resource fetch
  algorithm</a> can override this.</p>

  <p>Similarly, a single <code id="audiotracklist-and-videotracklist-objects:videotrack-9"><a href="#videotrack">VideoTrack</a></code> object per <code id="audiotracklist-and-videotracklist-objects:videotracklist-12"><a href="#videotracklist">VideoTrackList</a></code> object can
  be selected, this is the video track's <i>selection state</i>. When a <code id="audiotracklist-and-videotracklist-objects:videotrack-10"><a href="#videotrack">VideoTrack</a></code> is
  created, its <i>selection state</i> must be set to false (not selected). The <a href="#concept-media-load-resource" id="audiotracklist-and-videotracklist-objects:concept-media-load-resource-2">resource fetch algorithm</a> can override this.</p>

  <div data-algorithm="">
  <p>The <code id="audiotracklist-and-videotracklist-objects:audiotrack-11"><a href="#audiotrack">AudioTrack</a></code> <dfn data-dfn-for="AudioTrack" id="dom-audiotrack-id" data-dfn-type="attribute"><code>id</code></dfn> and <code id="audiotracklist-and-videotracklist-objects:videotrack-11"><a href="#videotrack">VideoTrack</a></code> <dfn data-dfn-for="VideoTrack" id="dom-videotrack-id" data-dfn-type="attribute"><code>id</code></dfn> attributes must return the
  identifier of the track, if it has one, or the empty string otherwise. If the <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource-7">media
  resource</a> is in a format that supports <a id="audiotracklist-and-videotracklist-objects:media-fragment-syntax-2" href="https://www.w3.org/TR/media-frags/#media-fragment-syntax" data-x-internal="media-fragment-syntax">media fragment syntax</a>, the identifier
  returned for a particular track must be the same identifier that would enable the track if used as
  the name of a track in the track dimension of such a <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="audiotracklist-and-videotracklist-objects:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a>. <a href="#refsINBAND">[INBAND]</a></p>
  </div>

  <p class="example">For example, in Ogg files, this would be the Name header field of the track.
  <a href="#refsOGGSKELETONHEADERS">[OGGSKELETONHEADERS]</a></p>

  <div data-algorithm="">
  <p>The <code id="audiotracklist-and-videotracklist-objects:audiotrack-12"><a href="#audiotrack">AudioTrack</a></code> <dfn data-dfn-for="AudioTrack" id="dom-audiotrack-kind" data-dfn-type="attribute"><code>kind</code></dfn> and <code id="audiotracklist-and-videotracklist-objects:videotrack-12"><a href="#videotrack">VideoTrack</a></code> <dfn data-dfn-for="VideoTrack" id="dom-videotrack-kind" data-dfn-type="attribute"><code>kind</code></dfn> attributes must return the
  category of the track, if it has one, or the empty string otherwise.</p>
  </div>

  <p>The category of a track is the string given in the first column of the table below that is the
  most appropriate for the track based on the definitions in the table's second and third columns,
  as determined by the metadata included in the track in the <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource-8">media resource</a>. The cell
  in the third column of a row says what the category given in the cell in the first column of that
  row applies to; a category is only appropriate for an audio track if it applies to audio tracks,
  and a category is only appropriate for video tracks if it applies to video tracks. Categories must
  only be returned for <code id="audiotracklist-and-videotracklist-objects:audiotrack-13"><a href="#audiotrack">AudioTrack</a></code> objects if they are appropriate for audio, and must
  only be returned for <code id="audiotracklist-and-videotracklist-objects:videotrack-13"><a href="#videotrack">VideoTrack</a></code> objects if they are appropriate for video.</p>

  <p>For Ogg files, the Role header field of the track gives the relevant metadata. For DASH media
  resources, the <code>Role</code> element conveys the information. For WebM, only the
  <code>FlagDefault</code> element currently maps to a value. <cite>Sourcing In-band
  Media Resource Tracks from Media Containers into HTML</cite> has further details.
  <a href="#refsOGGSKELETONHEADERS">[OGGSKELETONHEADERS]</a> <a href="#refsDASH">[DASH]</a> <a href="#refsWEBMCG">[WEBMCG]</a> <a href="#refsINBAND">[INBAND]</a></p>

  

  <table id="dom-TrackList-getKind-categories"><caption>Return values for <code id="audiotracklist-and-videotracklist-objects:audiotrack-14"><a href="#audiotrack">AudioTrack</a></code>'s <code id="audiotracklist-and-videotracklist-objects:dom-audiotrack-kind-2"><a href="#dom-audiotrack-kind">kind</a></code> and <code id="audiotracklist-and-videotracklist-objects:videotrack-14"><a href="#videotrack">VideoTrack</a></code>'s <code id="audiotracklist-and-videotracklist-objects:dom-videotrack-kind-2"><a href="#dom-videotrack-kind">kind</a></code></caption><thead><tr><th>Category
     </th><th>Definition
     </th><th>Applies to...</th><th>Examples
   </th></tr></thead><tbody><tr><td>"<dfn id="value-track-kind-alternate"><code>alternative</code></dfn>"
     </td><td>A possible alternative to the main track, e.g. a different take of a song (audio), or a different angle (video).
     </td><td>Audio and video.
     </td><td>Ogg: "audio/alternate" or "video/alternate"; DASH: "alternate" without "main" and "commentary" roles, and, for audio, without the "dub" role (other roles ignored).

    </td></tr><tr><td>"<dfn id="value-track-kind-caption"><code>captions</code></dfn>"
     </td><td>A version of the main video track with captions burnt in. (For legacy content; new content would use text tracks.)
     </td><td>Video only.
     </td><td>DASH: "caption" and "main" roles together (other roles ignored).

    </td></tr><tr><td>"<dfn id="value-track-kind-descriptions"><code>descriptions</code></dfn>"
     </td><td>An audio description of a video track.
     </td><td>Audio only.
     </td><td>Ogg: "audio/audiodesc".

    </td></tr><tr><td>"<dfn id="value-track-kind-main"><code>main</code></dfn>"
     </td><td>The primary audio or video track.
     </td><td>Audio and video.
     </td><td>Ogg: "audio/main" or "video/main"; WebM: the "FlagDefault" element is set; DASH: "main" role without "caption", "subtitle", and "dub" roles (other roles ignored).

    </td></tr><tr><td>"<dfn id="value-track-kind-main-desc"><code>main-desc</code></dfn>"
     </td><td>The primary audio track, mixed with audio descriptions.
     </td><td>Audio only.
     </td><td>AC3 audio in MPEG-2 TS: bsmod=2 and full_svc=1. 

    </td></tr><tr><td>"<dfn id="value-track-kind-sign"><code>sign</code></dfn>"
     </td><td>A sign-language interpretation of an audio track.
     </td><td>Video only.
     </td><td>Ogg: "video/sign".

    </td></tr><tr><td>"<dfn id="value-track-kind-subtitle"><code>subtitles</code></dfn>"
     </td><td>A version of the main video track with subtitles burnt in. (For legacy content; new content would use text tracks.)
     </td><td>Video only.
     </td><td>DASH: "subtitle" and "main" roles together (other roles ignored).

    </td></tr><tr><td>"<dfn id="value-track-kind-translation"><code>translation</code></dfn>"
     </td><td>A translated version of the main audio track.
     </td><td>Audio only.
     </td><td>Ogg: "audio/dub". DASH: "dub" and "main" roles together (other roles ignored).

    </td></tr><tr><td>"<dfn id="value-track-kind-commentary"><code>commentary</code></dfn>"
     </td><td>Commentary on the primary audio or video track, e.g. a director's commentary.
     </td><td>Audio and video.
     </td><td>DASH: "commentary" role without "main" role (other roles ignored).

    </td></tr><tr><td>"<dfn id="value-track-kind-none"><code></code></dfn>" (empty string)
     </td><td>No explicit kind, or the kind given by the track's metadata is not recognized by the user agent.
     </td><td>Audio and video.
     </td><td>

  </td></tr></tbody></table>

  

  <div data-algorithm="">
  <p>The <code id="audiotracklist-and-videotracklist-objects:audiotrack-15"><a href="#audiotrack">AudioTrack</a></code> <dfn data-dfn-for="AudioTrack" id="dom-audiotrack-label" data-dfn-type="attribute"><code>label</code></dfn> and <code id="audiotracklist-and-videotracklist-objects:videotrack-15"><a href="#videotrack">VideoTrack</a></code> <dfn data-dfn-for="VideoTrack" id="dom-videotrack-label" data-dfn-type="attribute"><code>label</code></dfn> attributes must return the
  label of the track, if it has one, or the empty string otherwise. <a href="#refsINBAND">[INBAND]</a></p>
  </div>

  <div data-algorithm="">
  <p>The <code id="audiotracklist-and-videotracklist-objects:audiotrack-16"><a href="#audiotrack">AudioTrack</a></code> <dfn data-dfn-for="AudioTrack" id="dom-audiotrack-language" data-dfn-type="attribute"><code>language</code></dfn> and <code id="audiotracklist-and-videotracklist-objects:videotrack-16"><a href="#videotrack">VideoTrack</a></code> <dfn data-dfn-for="VideoTrack" id="dom-videotrack-language" data-dfn-type="attribute"><code>language</code></dfn> attributes must
  return the BCP 47 language tag of the language of the track, if it has one, or the empty string
  otherwise. If the user agent is not able to express that language as a BCP 47 language tag (for
  example because the language information in the <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource-9">media resource</a>'s format is a
  free-form string without a defined interpretation), then the method must return the empty string,
  as if the track had no language. <a href="#refsINBAND">[INBAND]</a></p>
  </div>

  <div data-algorithm="">
  <p>The <code id="audiotracklist-and-videotracklist-objects:audiotrack-17"><a href="#audiotrack">AudioTrack</a></code> <dfn data-dfn-for="AudioTrack" id="dom-audiotrack-enabled" data-dfn-type="attribute"><code>enabled</code></dfn> attribute, on getting, must return true if
  the track is currently enabled, and false otherwise. On setting, it must enable the track if the
  new value is true, and disable it otherwise. (If the track is no longer in an
  <code id="audiotracklist-and-videotracklist-objects:audiotracklist-12"><a href="#audiotracklist">AudioTrackList</a></code> object, then the track being enabled or disabled has no effect beyond
  changing the value of the attribute on the <code id="audiotracklist-and-videotracklist-objects:audiotrack-18"><a href="#audiotrack">AudioTrack</a></code> object.)</p>
  </div>

  <div data-algorithm="">
  <p id="toggle-audio-track">Whenever an audio track in an <code id="audiotracklist-and-videotracklist-objects:audiotracklist-13"><a href="#audiotracklist">AudioTrackList</a></code> that was
  disabled is enabled, and whenever one that was enabled is disabled, the user agent must
  <a href="#queue-a-media-element-task" id="audiotracklist-and-videotracklist-objects:queue-a-media-element-task">queue a media element task</a> given the <a href="#media-element" id="audiotracklist-and-videotracklist-objects:media-element">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="audiotracklist-and-videotracklist-objects:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="audiotracklist-and-videotracklist-objects:event-media-change"><a href="#event-media-change">change</a></code> at the <code id="audiotracklist-and-videotracklist-objects:audiotracklist-14"><a href="#audiotracklist">AudioTrackList</a></code> object.</p>
  </div>

  <p>An audio track that has no data for a particular position on the <a href="#media-timeline" id="audiotracklist-and-videotracklist-objects:media-timeline">media timeline</a>,
  or that does not exist at that position, must be interpreted as being silent at that point on the
  timeline.</p>

  <div data-algorithm="">
  <p>The <code id="audiotracklist-and-videotracklist-objects:videotracklist-13"><a href="#videotracklist">VideoTrackList</a></code> <dfn data-dfn-for="VideoTrackList" id="dom-videotracklist-selectedindex" data-dfn-type="attribute"><code>selectedIndex</code></dfn> attribute must return the
  index of the currently selected track, if any. If the <code id="audiotracklist-and-videotracklist-objects:videotracklist-14"><a href="#videotracklist">VideoTrackList</a></code> object does not
  currently represent any tracks, or if none of the tracks are selected, it must instead return
  −1.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="audiotracklist-and-videotracklist-objects:videotrack-17"><a href="#videotrack">VideoTrack</a></code> <dfn data-dfn-for="VideoTrack" id="dom-videotrack-selected" data-dfn-type="attribute"><code>selected</code></dfn> attribute, on getting, must return true if
  the track is currently selected, and false otherwise. On setting, it must select the track if the
  new value is true, and unselect it otherwise. If the track is in a <code id="audiotracklist-and-videotracklist-objects:videotracklist-15"><a href="#videotracklist">VideoTrackList</a></code>,
  then all the other <code id="audiotracklist-and-videotracklist-objects:videotrack-18"><a href="#videotrack">VideoTrack</a></code> objects in that list must be unselected. (If the track
  is no longer in a <code id="audiotracklist-and-videotracklist-objects:videotracklist-16"><a href="#videotracklist">VideoTrackList</a></code> object, then the track being selected or unselected
  has no effect beyond changing the value of the attribute on the <code id="audiotracklist-and-videotracklist-objects:videotrack-19"><a href="#videotrack">VideoTrack</a></code>
  object.)</p>
  </div>

  <div data-algorithm="">
  <p id="toggle-video-track">Whenever a track in a <code id="audiotracklist-and-videotracklist-objects:videotracklist-17"><a href="#videotracklist">VideoTrackList</a></code> that was previously
  not selected is selected, and whenever the selected track in a <code id="audiotracklist-and-videotracklist-objects:videotracklist-18"><a href="#videotracklist">VideoTrackList</a></code> is
  unselected without a new track being selected in its stead, the user agent must <a href="#queue-a-media-element-task" id="audiotracklist-and-videotracklist-objects:queue-a-media-element-task-2">queue a
  media element task</a> given the <a href="#media-element" id="audiotracklist-and-videotracklist-objects:media-element-2">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="audiotracklist-and-videotracklist-objects:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="audiotracklist-and-videotracklist-objects:event-media-change-2"><a href="#event-media-change">change</a></code> at the <code id="audiotracklist-and-videotracklist-objects:videotracklist-19"><a href="#videotracklist">VideoTrackList</a></code> object. This <a href="#concept-task" id="audiotracklist-and-videotracklist-objects:concept-task">task</a> must be <a href="#queue-an-element-task" id="audiotracklist-and-videotracklist-objects:queue-an-element-task">queued</a>
  before the <a href="#concept-task" id="audiotracklist-and-videotracklist-objects:concept-task-2">task</a> that fires the <code id="audiotracklist-and-videotracklist-objects:event-media-resize"><a href="#event-media-resize">resize</a></code> event, if any.</p>
  </div>

  <p>A video track that has no data for a particular position on the <a href="#media-timeline" id="audiotracklist-and-videotracklist-objects:media-timeline-2">media timeline</a>
  must be interpreted as being <a id="audiotracklist-and-videotracklist-objects:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> at that point on the timeline, with
  the same dimensions as the last frame before that position, or, if the position is before all the
  data for that track, the same dimensions as the first frame for that track. A track that does not
  exist at all at the current position must be treated as if it existed but had no data.</p>

  <p class="example">For instance, if a video has a track that is only introduced after one hour of
  playback, and the user selects that track then goes back to the start, then the user agent will
  act as if that track started at the start of the <a href="#media-resource" id="audiotracklist-and-videotracklist-objects:media-resource-10">media resource</a> but was simply
  transparent until one hour in.</p>

  <hr>

  <p>The following are the <a href="#event-handlers" id="audiotracklist-and-videotracklist-objects:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="audiotracklist-and-videotracklist-objects:event-handler-event-type">event handler event types</a>) that must be supported, as <a href="#event-handler-idl-attributes" id="audiotracklist-and-videotracklist-objects:event-handler-idl-attributes">event handler IDL attributes</a>,
  by all objects implementing the <code id="audiotracklist-and-videotracklist-objects:audiotracklist-15"><a href="#audiotracklist">AudioTrackList</a></code> and <code id="audiotracklist-and-videotracklist-objects:videotracklist-20"><a href="#videotracklist">VideoTrackList</a></code>
  interfaces:</p>

  <table><thead><tr><th><a href="#event-handlers" id="audiotracklist-and-videotracklist-objects:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="audiotracklist-and-videotracklist-objects:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="AudioTrackList,VideoTrackList" id="handler-tracklist-onchange" data-dfn-type="attribute"><code>onchange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList/change_event" title="The change event is fired when an audio track is enabled or disabled, for example by changing the track's enabled property.">AudioTrackList/change_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList/change_event" title="The change event is fired when a text track is made active or inactive, or a TextTrackList is otherwise changed.">TextTrackList/change_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>33+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList/change_event" title="The change event is fired when a video track is made active or inactive, for example by changing the track's selected property.">VideoTrackList/change_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="audiotracklist-and-videotracklist-objects:event-media-change-3"><a href="#event-media-change">change</a></code>
    </td></tr><tr><td><dfn data-dfn-for="AudioTrackList,VideoTrackList" id="handler-tracklist-onaddtrack" data-dfn-type="attribute"><code>onaddtrack</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList/addtrack_event" title="The addtrack event is fired when a track is added to an AudioTrackList.">AudioTrackList/addtrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList/addtrack_event" title="The addtrack event is fired when a track is added to a TextTrackList.">TextTrackList/addtrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList/addtrack_event" title="The addtrack event is fired when a video track is added to a VideoTrackList.">VideoTrackList/addtrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="audiotracklist-and-videotracklist-objects:event-media-addtrack"><a href="#event-media-addtrack">addtrack</a></code>
    </td></tr><tr><td><dfn data-dfn-for="AudioTrackList,VideoTrackList" id="handler-tracklist-onremovetrack" data-dfn-type="attribute"><code>onremovetrack</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList/removetrack_event" title="The removetrack event is fired when a track is removed from an AudioTrackList.">AudioTrackList/removetrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList/removetrack_event" title="The removetrack event is fired when a track is removed from a TextTrackList.">TextTrackList/removetrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>33+</span></span><hr><span class="opera yes"><span>Opera</span><span>20+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>20+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList/removetrack_event" title="The removetrack event is fired when a video track is removed from a VideoTrackList.">VideoTrackList/removetrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="audiotracklist-and-videotracklist-objects:event-media-removetrack"><a href="#event-media-removetrack">removetrack</a></code>
  </td></tr></tbody></table>

  

  


  <h6 id="selecting-specific-audio-and-video-tracks-declaratively"><span class="secno">4.8.11.10.2</span> Selecting specific audio and video tracks declaratively<a href="#selecting-specific-audio-and-video-tracks-declaratively" class="self-link"></a></h6>

  <p>The <code id="selecting-specific-audio-and-video-tracks-declaratively:dom-media-audiotracks"><a href="#dom-media-audiotracks">audioTracks</a></code> and <code id="selecting-specific-audio-and-video-tracks-declaratively:dom-media-videotracks"><a href="#dom-media-videotracks">videoTracks</a></code> attributes allow scripts to select which track
  should play, but it is also possible to select specific tracks declaratively, by specifying
  particular tracks in the <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="selecting-specific-audio-and-video-tracks-declaratively:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> of the
  <a id="selecting-specific-audio-and-video-tracks-declaratively:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the <a href="#media-resource" id="selecting-specific-audio-and-video-tracks-declaratively:media-resource">media resource</a>. The format of the <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="selecting-specific-audio-and-video-tracks-declaratively:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a> depends on the <a id="selecting-specific-audio-and-video-tracks-declaratively:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> of the
  <a href="#media-resource" id="selecting-specific-audio-and-video-tracks-declaratively:media-resource-2">media resource</a>. <a href="#refsRFC2046">[RFC2046]</a> <a href="#refsURL">[URL]</a></p>

  <div class="example">

   <p>In this example, a video that uses a format that supports <a id="selecting-specific-audio-and-video-tracks-declaratively:media-fragment-syntax" href="https://www.w3.org/TR/media-frags/#media-fragment-syntax" data-x-internal="media-fragment-syntax">media fragment syntax</a>
   is embedded in such a way that the alternative angles labeled "Alternative" are enabled instead
   of the default video track.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">video</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"myvideo#track=Alternative"</c-><c- p="">&gt;&lt;/</c-><c- f="">video</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h5 id="timed-text-tracks"><span class="secno">4.8.11.11</span> Timed text tracks<a href="#timed-text-tracks" class="self-link"></a></h5>

  <h6 id="text-track-model"><span class="secno">4.8.11.11.1</span> Text track model<a href="#text-track-model" class="self-link"></a></h6>

  <p>A <a href="#media-element" id="text-track-model:media-element">media element</a> can have a group of associated <dfn id="text-track">text
  tracks</dfn>, known as the <a href="#media-element" id="text-track-model:media-element-2">media element</a>'s <dfn id="list-of-text-tracks">list of text tracks</dfn>. The <a href="#text-track" id="text-track-model:text-track">text tracks</a> are sorted as follows:</p>

  <ol><li><p>The <a href="#text-track" id="text-track-model:text-track-2">text tracks</a> corresponding to <code id="text-track-model:the-track-element"><a href="#the-track-element">track</a></code>
   element children of the <a href="#media-element" id="text-track-model:media-element-3">media element</a>, in <a id="text-track-model:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li><li><p>Any <a href="#text-track" id="text-track-model:text-track-3">text tracks</a> added using the <code id="text-track-model:dom-media-addtexttrack"><a href="#dom-media-addtexttrack">addTextTrack()</a></code> method, in the order they were added,
   oldest first.</p></li><li><p>Any <a href="#media-resource-specific-text-track" id="text-track-model:media-resource-specific-text-track">media-resource-specific text
   tracks</a> (<a href="#text-track" id="text-track-model:text-track-4">text tracks</a> corresponding to data in the
   <a href="#media-resource" id="text-track-model:media-resource">media resource</a>), in the order defined by the <a href="#media-resource" id="text-track-model:media-resource-2">media resource</a>'s format
   specification.</p></li></ol>

  <p>A <a href="#text-track" id="text-track-model:text-track-5">text track</a> consists of:</p>

  <dl><dt><dfn id="text-track-kind">The kind of text track</dfn>

   </dt><dd>
    <p>This decides how the track is handled by the user agent. The kind is represented by a string.
    The possible strings are:</p>

    <ul class="brief"><li><dfn id="dom-texttrack-kind-subtitles"><code>subtitles</code></dfn>
     </li><li><dfn id="dom-texttrack-kind-captions"><code>captions</code></dfn>
     </li><li><dfn id="dom-texttrack-kind-descriptions"><code>descriptions</code></dfn>
     </li><li><dfn id="dom-texttrack-kind-chapters"><code>chapters</code></dfn>
     </li><li><dfn id="dom-texttrack-kind-metadata"><code>metadata</code></dfn>
    </li></ul>

    <p>The <a href="#text-track-kind" id="text-track-model:text-track-kind">kind of track</a> can change dynamically, in the case of
    a <a href="#text-track" id="text-track-model:text-track-6">text track</a> corresponding to a <code id="text-track-model:the-track-element-2"><a href="#the-track-element">track</a></code> element.</p>
   </dd><dt><dfn id="text-track-label">A label</dfn>

   </dt><dd>
    <p>This is a human-readable string intended to identify the track for the user.</p>

    <p>The <a href="#text-track-label" id="text-track-model:text-track-label">label of a track</a> can change dynamically, in the
    case of a <a href="#text-track" id="text-track-model:text-track-7">text track</a> corresponding to a <code id="text-track-model:the-track-element-3"><a href="#the-track-element">track</a></code> element.</p>

    <p>When a <a href="#text-track-label" id="text-track-model:text-track-label-2">text track label</a> is the empty string, the user agent should automatically
    generate an appropriate label from the text track's other properties (e.g. the kind of text
    track and the text track's language) for use in its user interface. This automatically-generated
    label is not exposed in the API.</p>
   </dd><dt><dfn id="text-track-in-band-metadata-track-dispatch-type">An in-band metadata track dispatch type</dfn>

   </dt><dd>
    <p>This is a string extracted from the <a href="#media-resource" id="text-track-model:media-resource-3">media resource</a> specifically for in-band
    metadata tracks to enable such tracks to be dispatched to different scripts in the document.</p>

    <p class="example">For example, a traditional TV station broadcast streamed on the web and
    augmented with web-specific interactive features could include text tracks with metadata for ad
    targeting, trivia game data during game shows, player states during sports games, recipe
    information during food programs, and so forth. As each program starts and ends, new tracks
    might be added or removed from the stream, and as each one is added, the user agent could bind
    them to dedicated script modules using the value of this attribute.</p>

    <p>Other than for in-band metadata text tracks, the <a href="#text-track-in-band-metadata-track-dispatch-type" id="text-track-model:text-track-in-band-metadata-track-dispatch-type">in-band metadata track dispatch type</a> is the empty string. How this
    value is populated for different media formats is described in <a href="#steps-to-expose-a-media-resource-specific-text-track" id="text-track-model:steps-to-expose-a-media-resource-specific-text-track">steps to expose a
    media-resource-specific text track</a>.</p>
   </dd><dt><dfn id="text-track-language">A language</dfn>

   </dt><dd>
    <p>This is a string (a BCP 47 language tag) representing the language of the text track's cues.
    <a href="#refsBCP47">[BCP47]</a></p>

    <p>The <a href="#text-track-language" id="text-track-model:text-track-language">language of a text track</a> can change dynamically,
    in the case of a <a href="#text-track" id="text-track-model:text-track-8">text track</a> corresponding to a <code id="text-track-model:the-track-element-4"><a href="#the-track-element">track</a></code> element.</p>
   </dd><dt><dfn id="text-track-readiness-state">A readiness state</dfn>

   </dt><dd>
    <p>One of the following:</p>

    <dl><dt><dfn id="text-track-not-loaded">Not loaded</dfn>

     </dt><dd>
      <p>Indicates that the text track's cues have not been obtained.</p>
     </dd><dt><dfn id="text-track-loading">Loading</dfn>

     </dt><dd>
      <p>Indicates that the text track is loading and there have been no fatal errors encountered so
      far. Further cues might still be added to the track by the parser.</p>
     </dd><dt><dfn id="text-track-loaded">Loaded</dfn>

     </dt><dd>
      <p>Indicates that the text track has been loaded with no fatal errors.</p>
     </dd><dt><dfn id="text-track-failed-to-load">Failed to load</dfn>

     </dt><dd>
      <p>Indicates that the text track was enabled, but when the user agent attempted to obtain it,
      this failed in some way (e.g., <a id="text-track-model:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> could not be <a href="#encoding-parsing-a-url" id="text-track-model:encoding-parsing-a-url">parsed</a>, network error, unknown text track format). Some or all of the cues are
      likely missing and will not be obtained.</p>
     </dd></dl>

    <p>The <a href="#text-track-readiness-state" id="text-track-model:text-track-readiness-state">readiness state</a> of a <a href="#text-track" id="text-track-model:text-track-9">text
    track</a> changes dynamically as the track is obtained.</p>
   </dd><dt><dfn id="text-track-mode">A mode</dfn>

   </dt><dd>
    <p>One of the following:</p>

    <dl><dt><dfn id="text-track-disabled">Disabled</dfn>

     </dt><dd>
      <p>Indicates that the text track is not active. Other than for the purposes of exposing the
      track in the DOM, the user agent is ignoring the text track. No cues are active, no events are
      fired, and the user agent will not attempt to obtain the track's cues.</p>
     </dd><dt><dfn id="text-track-hidden">Hidden</dfn>

     </dt><dd>
      <p>Indicates that the text track is active, but that the user agent is not actively displaying
      the cues. If no attempt has yet been made to obtain the track's cues, the user agent will
      perform such an attempt momentarily. The user agent is maintaining a list of which cues are
      active, and events are being fired accordingly.</p>
     </dd><dt><dfn id="text-track-showing">Showing</dfn>

     </dt><dd>
      <p>Indicates that the text track is active. If no attempt has yet been made to obtain the
      track's cues, the user agent will perform such an attempt momentarily. The user agent is
      maintaining a list of which cues are active, and events are being fired accordingly. In
      addition, for text tracks whose <a href="#text-track-kind" id="text-track-model:text-track-kind-2">kind</a> is <code id="text-track-model:dom-texttrack-kind-subtitles"><a href="#dom-texttrack-kind-subtitles">subtitles</a></code> or <code id="text-track-model:dom-texttrack-kind-captions"><a href="#dom-texttrack-kind-captions">captions</a></code>, the cues are being overlaid on the video
      as appropriate; for text tracks whose <a href="#text-track-kind" id="text-track-model:text-track-kind-3">kind</a> is <code id="text-track-model:dom-texttrack-kind-descriptions"><a href="#dom-texttrack-kind-descriptions">descriptions</a></code>, the user agent is making the
      cues available to the user in a non-visual fashion; and for text tracks whose <a href="#text-track-kind" id="text-track-model:text-track-kind-4">kind</a> is <code id="text-track-model:dom-texttrack-kind-chapters"><a href="#dom-texttrack-kind-chapters">chapters</a></code>, the user agent is making available to
      the user a mechanism by which the user can navigate to any point in the <a href="#media-resource" id="text-track-model:media-resource-4">media
      resource</a> by selecting a cue.</p>
     </dd></dl>
   </dd><dt><dfn id="text-track-list-of-cues">A list of zero or more cues</dfn>

   </dt><dd>
    <p>A list of <a href="#text-track-cue" id="text-track-model:text-track-cue">text track cues</a>, along with <dfn id="rules-for-updating-the-text-track-rendering">rules for
    updating the text track rendering</dfn>. For example, for WebVTT, the <a id="text-track-model:rules-for-updating-the-display-of-webvtt-text-tracks" href="https://w3c.github.io/webvtt/#rules-for-updating-the-display-of-webvtt-text-tracks" data-x-internal="rules-for-updating-the-display-of-webvtt-text-tracks">rules for updating
    the display of WebVTT text tracks</a>. <a href="#refsWEBVTT">[WEBVTT]</a> </p>

    <p>The <a href="#text-track-list-of-cues" id="text-track-model:text-track-list-of-cues">list of cues of a text track</a> can change
    dynamically, either because the <a href="#text-track" id="text-track-model:text-track-10">text track</a> has <a href="#text-track-not-loaded" id="text-track-model:text-track-not-loaded">not yet been loaded</a> or is still <a href="#text-track-loading" id="text-track-model:text-track-loading">loading</a>,
    or due to DOM manipulation.</p>
   </dd></dl>

  <p>Each <a href="#text-track" id="text-track-model:text-track-11">text track</a> has a corresponding <code id="text-track-model:texttrack"><a href="#texttrack">TextTrack</a></code> object.</p>

  <hr>

  <p>Each <a href="#media-element" id="text-track-model:media-element-4">media element</a> has a <dfn id="list-of-pending-text-tracks">list of pending text tracks</dfn>, which must
  initially be empty, a <dfn id="blocked-on-parser">blocked-on-parser</dfn> flag, which must initially be false, and a
  <dfn id="did-perform-automatic-track-selection">did-perform-automatic-track-selection</dfn> flag, which must also initially be false.</p>

  <div data-algorithm="">
  <p>When the user agent is required to <dfn id="populate-the-list-of-pending-text-tracks">populate the list of pending text tracks</dfn> of a
  <a href="#media-element" id="text-track-model:media-element-5">media element</a>, the user agent must add to the element's <a href="#list-of-pending-text-tracks" id="text-track-model:list-of-pending-text-tracks">list of pending text
  tracks</a> each <a href="#text-track" id="text-track-model:text-track-12">text track</a> in the element's <a href="#list-of-text-tracks" id="text-track-model:list-of-text-tracks">list of text tracks</a> whose
  <a href="#text-track-mode" id="text-track-model:text-track-mode">text track mode</a> is not <a href="#text-track-disabled" id="text-track-model:text-track-disabled">disabled</a> and whose
  <a href="#text-track-readiness-state" id="text-track-model:text-track-readiness-state-2">text track readiness state</a> is  <a href="#text-track-loading" id="text-track-model:text-track-loading-2">loading</a>.</p>
  </div>

  <div data-algorithm="">
  <p>Whenever a <code id="text-track-model:the-track-element-5"><a href="#the-track-element">track</a></code> element's parent node changes, the user agent must remove the
  corresponding <a href="#text-track" id="text-track-model:text-track-13">text track</a> from any <a href="#list-of-pending-text-tracks" id="text-track-model:list-of-pending-text-tracks-2">list of pending text tracks</a> that it is
  in.</p>
  </div>

  <div data-algorithm="">
  <p>Whenever a <a href="#text-track" id="text-track-model:text-track-14">text track</a>'s <a href="#text-track-readiness-state" id="text-track-model:text-track-readiness-state-3">text track readiness state</a> changes to either
  <a href="#text-track-loaded" id="text-track-model:text-track-loaded">loaded</a> or <a href="#text-track-failed-to-load" id="text-track-model:text-track-failed-to-load">failed to
  load</a>, the user agent must remove it from any <a href="#list-of-pending-text-tracks" id="text-track-model:list-of-pending-text-tracks-3">list of pending text tracks</a> that
  it is in.</p>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#media-element" id="text-track-model:media-element-6">media element</a> is created by an <a href="#html-parser" id="text-track-model:html-parser">HTML parser</a> or <a href="#xml-parser" id="text-track-model:xml-parser">XML
  parser</a>, the user agent must set the element's <a href="#blocked-on-parser" id="text-track-model:blocked-on-parser">blocked-on-parser</a> flag to true.
  When a <a href="#media-element" id="text-track-model:media-element-7">media element</a> is popped off the <a href="#stack-of-open-elements" id="text-track-model:stack-of-open-elements">stack of open elements</a> of an
  <a href="#html-parser" id="text-track-model:html-parser-2">HTML parser</a> or <a href="#xml-parser" id="text-track-model:xml-parser-2">XML parser</a>, the user agent must <a href="#honor-user-preferences-for-automatic-text-track-selection" id="text-track-model:honor-user-preferences-for-automatic-text-track-selection">honor user
  preferences for automatic text track selection</a>, <a href="#populate-the-list-of-pending-text-tracks" id="text-track-model:populate-the-list-of-pending-text-tracks">populate the list of pending text
  tracks</a>, and set the element's <a href="#blocked-on-parser" id="text-track-model:blocked-on-parser-2">blocked-on-parser</a> flag to false.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#text-track" id="text-track-model:text-track-15">text tracks</a> of a <a href="#media-element" id="text-track-model:media-element-8">media element</a> are <dfn id="the-text-tracks-are-ready">ready</dfn> when both the element's <a href="#list-of-pending-text-tracks" id="text-track-model:list-of-pending-text-tracks-4">list of pending text
  tracks</a> is empty and the element's <a href="#blocked-on-parser" id="text-track-model:blocked-on-parser-3">blocked-on-parser</a> flag is false.</p>
  </div>

  <p>Each <a href="#media-element" id="text-track-model:media-element-9">media element</a> has a <dfn id="pending-text-track-change-notification-flag">pending text track change notification flag</dfn>,
  which must initially be unset.</p>

  <div data-algorithm="">
  <p>Whenever a <a href="#text-track" id="text-track-model:text-track-16">text track</a> that is in a <a href="#media-element" id="text-track-model:media-element-10">media element</a>'s <a href="#list-of-text-tracks" id="text-track-model:list-of-text-tracks-2">list of text
  tracks</a> has its <a href="#text-track-mode" id="text-track-model:text-track-mode-2">text track mode</a> change value, the user agent must run the
  following steps for the <a href="#media-element" id="text-track-model:media-element-11">media element</a>:</p>

  <ol><li><p>If the <a href="#media-element" id="text-track-model:media-element-12">media element</a>'s <a href="#pending-text-track-change-notification-flag" id="text-track-model:pending-text-track-change-notification-flag">pending text track change notification
   flag</a> is set, return.</p></li><li><p>Set the <a href="#media-element" id="text-track-model:media-element-13">media element</a>'s <a href="#pending-text-track-change-notification-flag" id="text-track-model:pending-text-track-change-notification-flag-2">pending text track change notification
   flag</a>.</p></li><li>
    <p><a href="#queue-a-media-element-task" id="text-track-model:queue-a-media-element-task">Queue a media element task</a> given the <a href="#media-element" id="text-track-model:media-element-14">media element</a> to run these
    steps:</p>

    <ol><li><p>Unset the <a href="#media-element" id="text-track-model:media-element-15">media element</a>'s <a href="#pending-text-track-change-notification-flag" id="text-track-model:pending-text-track-change-notification-flag-3">pending text track change notification
     flag</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="text-track-model:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="text-track-model:event-media-change"><a href="#event-media-change">change</a></code> at the <a href="#media-element" id="text-track-model:media-element-16">media element</a>'s <code id="text-track-model:dom-media-texttracks"><a href="#dom-media-texttracks">textTracks</a></code> attribute's <code id="text-track-model:texttracklist"><a href="#texttracklist">TextTrackList</a></code>
     object.</p></li></ol>
   </li><li><p>If the <a href="#media-element" id="text-track-model:media-element-17">media element</a>'s <a href="#show-poster-flag" id="text-track-model:show-poster-flag">show poster flag</a> is not set, run the
   <i id="text-track-model:time-marches-on"><a href="#time-marches-on">time marches on</a></i> steps.</p></li></ol>
  </div>

  <p>The <a href="#task-source" id="text-track-model:task-source">task source</a> for the <a href="#concept-task" id="text-track-model:concept-task">tasks</a> listed in this
  section is the <a href="#dom-manipulation-task-source" id="text-track-model:dom-manipulation-task-source">DOM manipulation task source</a>.</p>

  <hr>

  <p>A <dfn id="text-track-cue">text track cue</dfn> is the unit of time-sensitive data in a <a href="#text-track" id="text-track-model:text-track-17">text track</a>,
  corresponding for instance for subtitles and captions to the text that appears at a particular
  time and disappears at another time.</p>

  <p>Each <a href="#text-track-cue" id="text-track-model:text-track-cue-2">text track cue</a> consists of:</p>

  <dl><dt><dfn id="text-track-cue-identifier">An identifier</dfn>
   </dt><dd>
    <p>An arbitrary string.</p>
   </dd><dt><dfn id="text-track-cue-start-time">A start time</dfn>
   </dt><dd>
    <p>The time, in seconds and fractions of a second, that describes the beginning of the range of
    the <a href="#media-data" id="text-track-model:media-data">media data</a> to which the cue applies.</p>
   </dd><dt><dfn id="text-track-cue-end-time">An end time</dfn>
   </dt><dd>
    <p>The time, in seconds and fractions of a second, that describes the end of the range of the
    <a href="#media-data" id="text-track-model:media-data-2">media data</a> to which the cue applies, or positive Infinity for an <a href="#unbounded-text-track-cue" id="text-track-model:unbounded-text-track-cue">unbounded
    text track cue</a>.</p>
   </dd><dt><dfn id="text-track-cue-pause-on-exit-flag">A pause-on-exit flag</dfn>
   </dt><dd>
    <p>A boolean indicating whether playback of the <a href="#media-resource" id="text-track-model:media-resource-5">media resource</a> is to pause when the
    end of the range to which the cue applies is reached.</p>
   </dd><dt>Some additional format-specific data</dt><dd>
    <p>Additional fields, as needed for the format, including the actual data of the cue. For
    example, WebVTT has a <a id="text-track-model:text-track-cue-writing-direction" href="https://w3c.github.io/webvtt/#webvtt-cue-writing-direction" data-x-internal="text-track-cue-writing-direction">text track cue writing direction</a> and so forth.
    <a href="#refsWEBVTT">[WEBVTT]</a></p>
   </dd></dl>

  <div data-algorithm="">
  <p>An <dfn id="unbounded-text-track-cue">unbounded text track cue</dfn> is a text track cue
  with a <a href="#text-track-cue-end-time" id="text-track-model:text-track-cue-end-time">text track cue end time</a> set to positive Infinity. An active <a href="#unbounded-text-track-cue" id="text-track-model:unbounded-text-track-cue-2">unbounded
  text track cue</a> cannot become inactive through the usual monotonic increase of the
  <a href="#current-playback-position" id="text-track-model:current-playback-position">current playback position</a> during normal playback (e.g. a metadata cue for a chapter in a live
  event with no announced end time.)</p>
  </div>

  <p class="note">The <a href="#text-track-cue-start-time" id="text-track-model:text-track-cue-start-time">text track cue start time</a> and <a href="#text-track-cue-end-time" id="text-track-model:text-track-cue-end-time-2">text track cue end
  time</a> can be negative. (The <a href="#current-playback-position" id="text-track-model:current-playback-position-2">current playback position</a> can never be negative,
  though, so cues entirely before time zero cannot be active.)</p>

  <p>Each <a href="#text-track-cue" id="text-track-model:text-track-cue-3">text track cue</a> has a corresponding <code id="text-track-model:texttrackcue"><a href="#texttrackcue">TextTrackCue</a></code> object (or more
  specifically, an object that inherits from <code id="text-track-model:texttrackcue-2"><a href="#texttrackcue">TextTrackCue</a></code> — for example, WebVTT
  cues use the <code id="text-track-model:vttcue"><a data-x-internal="vttcue" href="https://w3c.github.io/webvtt/#vttcue">VTTCue</a></code> interface). A <a href="#text-track-cue" id="text-track-model:text-track-cue-4">text track cue</a>'s in-memory
  representation can be dynamically changed through this <code id="text-track-model:texttrackcue-3"><a href="#texttrackcue">TextTrackCue</a></code> API.
  <a href="#refsWEBVTT">[WEBVTT]</a></p>

  <p>A <a href="#text-track-cue" id="text-track-model:text-track-cue-5">text track cue</a> is associated with <a href="#rules-for-updating-the-text-track-rendering" id="text-track-model:rules-for-updating-the-text-track-rendering">rules for updating the text track
  rendering</a>, as defined by the specification for the specific kind of <a href="#text-track-cue" id="text-track-model:text-track-cue-6">text track
  cue</a>. These rules are used specifically when the object representing the cue is added to a
  <code id="text-track-model:texttrack-2"><a href="#texttrack">TextTrack</a></code> object using the <code id="text-track-model:dom-texttrack-addcue"><a href="#dom-texttrack-addcue">addCue()</a></code>
  method.</p>

  <p>In addition, each <a href="#text-track-cue" id="text-track-model:text-track-cue-7">text track cue</a> has two pieces of dynamic information:</p>

  <dl><dt>The <dfn id="text-track-cue-active-flag">active flag</dfn>
   </dt><dd>
    <p>This flag must be initially unset. The flag is used to ensure events are fired appropriately
    when the cue becomes active or inactive, and to make sure the right cues are rendered.</p>

    <div data-algorithm="">
    <p>The user agent must synchronously unset this flag whenever the <a href="#text-track-cue" id="text-track-model:text-track-cue-8">text track cue</a> is
    removed from its <a href="#text-track" id="text-track-model:text-track-18">text track</a>'s <a href="#text-track-list-of-cues" id="text-track-model:text-track-list-of-cues-2">text track list of cues</a>; whenever the
    <a href="#text-track" id="text-track-model:text-track-19">text track</a> itself is removed from its <a href="#media-element" id="text-track-model:media-element-18">media element</a>'s <a href="#list-of-text-tracks" id="text-track-model:list-of-text-tracks-3">list of
    text tracks</a> or has its <a href="#text-track-mode" id="text-track-model:text-track-mode-3">text track mode</a> changed to <a href="#text-track-disabled" id="text-track-model:text-track-disabled-2">disabled</a>; and whenever the <a href="#media-element" id="text-track-model:media-element-19">media element</a>'s <code id="text-track-model:dom-media-readystate"><a href="#dom-media-readystate">readyState</a></code> is changed back to <code id="text-track-model:dom-media-have_nothing"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>. When the flag is unset in this way for one
    or more cues in <a href="#text-track" id="text-track-model:text-track-20">text tracks</a> that were <a href="#text-track-showing" id="text-track-model:text-track-showing">showing</a> prior to the relevant incident, the user agent must, after having unset
    the flag for all the affected cues, apply the <a href="#rules-for-updating-the-text-track-rendering" id="text-track-model:rules-for-updating-the-text-track-rendering-2">rules for updating the text track
    rendering</a> of those <a href="#text-track" id="text-track-model:text-track-21">text tracks</a>. For example, for <a href="#text-track" id="text-track-model:text-track-22">text tracks</a> based on WebVTT, the <a id="text-track-model:rules-for-updating-the-display-of-webvtt-text-tracks-2" href="https://w3c.github.io/webvtt/#rules-for-updating-the-display-of-webvtt-text-tracks" data-x-internal="rules-for-updating-the-display-of-webvtt-text-tracks">rules for updating the display
    of WebVTT text tracks</a>. <a href="#refsWEBVTT">[WEBVTT]</a></p>
    </div>
   </dd><dt>The <dfn id="text-track-cue-display-state">display state</dfn>
   </dt><dd>
    <p>This is used as part of the rendering model, to keep cues in a consistent position. It must
    initially be empty. Whenever the <a href="#text-track-cue-active-flag" id="text-track-model:text-track-cue-active-flag">text track cue active flag</a> is unset, the user
    agent must empty the <a href="#text-track-cue-display-state" id="text-track-model:text-track-cue-display-state">text track cue display state</a>.</p>
   </dd></dl>

  <p>The <a href="#text-track-cue" id="text-track-model:text-track-cue-9">text track cues</a> of a <a href="#media-element" id="text-track-model:media-element-20">media element</a>'s
  <a href="#text-track" id="text-track-model:text-track-23">text tracks</a> are ordered relative to each other in the <dfn id="text-track-cue-order">text
  track cue order</dfn>, which is determined as follows: first group the <a href="#text-track-cue" id="text-track-model:text-track-cue-10">cues</a> by their <a href="#text-track" id="text-track-model:text-track-24">text track</a>, with the groups being sorted in the same order
  as their <a href="#text-track" id="text-track-model:text-track-25">text tracks</a> appear in the <a href="#media-element" id="text-track-model:media-element-21">media element</a>'s
  <a href="#list-of-text-tracks" id="text-track-model:list-of-text-tracks-4">list of text tracks</a>; then, within each group, <a href="#text-track-cue" id="text-track-model:text-track-cue-11">cues</a> must be sorted by their <a href="#text-track-cue-start-time" id="text-track-model:text-track-cue-start-time-2">start
  time</a>, earliest first; then, any <a href="#text-track-cue" id="text-track-model:text-track-cue-12">cues</a> with the same
  <a href="#text-track-cue-start-time" id="text-track-model:text-track-cue-start-time-3">start time</a> must be sorted by their <a href="#text-track-cue-end-time" id="text-track-model:text-track-cue-end-time-3">end time</a>, latest first; and finally, any <a href="#text-track-cue" id="text-track-model:text-track-cue-13">cues</a> with identical <a href="#text-track-cue-end-time" id="text-track-model:text-track-cue-end-time-4">end
  times</a> must be sorted in the order they were last added to their respective <a href="#text-track-list-of-cues" id="text-track-model:text-track-list-of-cues-3">text track
  list of cues</a>, oldest first (so e.g. for cues from a WebVTT file, that would initially be
  the order in which the cues were listed in the file). <a href="#refsWEBVTT">[WEBVTT]</a></p>


  <h6 id="sourcing-in-band-text-tracks"><span class="secno">4.8.11.11.2</span> Sourcing in-band text tracks<a href="#sourcing-in-band-text-tracks" class="self-link"></a></h6>

  <p>A <dfn id="media-resource-specific-text-track">media-resource-specific text track</dfn> is a <a href="#text-track" id="sourcing-in-band-text-tracks:text-track">text track</a> that corresponds
  to data found in the <a href="#media-resource" id="sourcing-in-band-text-tracks:media-resource">media resource</a>.</p>


  

  <p>Rules for processing and rendering such data are defined by the relevant specifications, e.g.
  the specification of the video format if the <a href="#media-resource" id="sourcing-in-band-text-tracks:media-resource-2">media resource</a> is a video. Details for
  some legacy formats can be found in <cite>Sourcing In-band Media Resource Tracks from Media
  Containers into HTML</cite>. <a href="#refsINBAND">[INBAND]</a></p>

  <div data-algorithm="">
  <p>When a <a href="#media-resource" id="sourcing-in-band-text-tracks:media-resource-3">media resource</a> contains data that the user agent recognizes and supports as
  being equivalent to a <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-2">text track</a>, the user agent <a href="#found-a-media-resource-specific-timed-track">runs</a> the <dfn id="steps-to-expose-a-media-resource-specific-text-track">steps to expose a
  media-resource-specific text track</dfn> with the relevant data, as follows.</p>

  

  <ol><li><p>Associate the relevant data with a new <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-3">text track</a> and its corresponding new
   <code id="sourcing-in-band-text-tracks:texttrack"><a href="#texttrack">TextTrack</a></code> object. The <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-4">text track</a> is a <a href="#media-resource-specific-text-track" id="sourcing-in-band-text-tracks:media-resource-specific-text-track">media-resource-specific
   text track</a>.</p></li><li><p>Set the new <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-5">text track</a>'s <a href="#text-track-kind" id="sourcing-in-band-text-tracks:text-track-kind">kind</a>, <a href="#text-track-label" id="sourcing-in-band-text-tracks:text-track-label">label</a>, and <a href="#text-track-language" id="sourcing-in-band-text-tracks:text-track-language">language</a>
   based on the semantics of the relevant data, as defined by the relevant specification. If there
   is no label in that data, then the <a href="#text-track-label" id="sourcing-in-band-text-tracks:text-track-label-2">label</a> must be set to the
   empty string.</p></li><li><p>Associate the <a href="#text-track-list-of-cues" id="sourcing-in-band-text-tracks:text-track-list-of-cues">text track list of cues</a> with the <a href="#rules-for-updating-the-text-track-rendering" id="sourcing-in-band-text-tracks:rules-for-updating-the-text-track-rendering">rules for updating the
   text track rendering</a> appropriate for the format in question.</p>

   </li><li>
    <p>If the new <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-6">text track</a>'s <a href="#text-track-kind" id="sourcing-in-band-text-tracks:text-track-kind-2">kind</a> is <code id="sourcing-in-band-text-tracks:dom-texttrack-kind-chapters"><a href="#dom-texttrack-kind-chapters">chapters</a></code> or <code id="sourcing-in-band-text-tracks:dom-texttrack-kind-metadata"><a href="#dom-texttrack-kind-metadata">metadata</a></code>, then set the <a href="#text-track-in-band-metadata-track-dispatch-type" id="sourcing-in-band-text-tracks:text-track-in-band-metadata-track-dispatch-type">text track in-band
    metadata track dispatch type</a> as follows, based on the type of the <a href="#media-resource" id="sourcing-in-band-text-tracks:media-resource-4">media
    resource</a>:</p>

    <dl class="switch"><dt>If the <a href="#media-resource" id="sourcing-in-band-text-tracks:media-resource-5">media resource</a> is an Ogg file</dt><dd>The <a href="#text-track-in-band-metadata-track-dispatch-type" id="sourcing-in-band-text-tracks:text-track-in-band-metadata-track-dispatch-type-2">text track in-band metadata track dispatch type</a> must be set to the value
     of the Name header field. <a href="#refsOGGSKELETONHEADERS">[OGGSKELETONHEADERS]</a></dd><dt>If the <a href="#media-resource" id="sourcing-in-band-text-tracks:media-resource-6">media resource</a> is a WebM file</dt><dd>The <a href="#text-track-in-band-metadata-track-dispatch-type" id="sourcing-in-band-text-tracks:text-track-in-band-metadata-track-dispatch-type-3">text track in-band metadata track dispatch type</a> must be set to the value
     of the <code>CodecID</code> element. <a href="#refsWEBMCG">[WEBMCG]</a></dd><dt>If the <a href="#media-resource" id="sourcing-in-band-text-tracks:media-resource-7">media resource</a> is an MPEG-2 file</dt><dd>Let <var>stream type</var> be the value of the "stream_type" field describing the text
     track's type in the file's program map section, interpreted as an 8-bit unsigned integer. Let
     <var>length</var> be the value of the "ES_info_length" field for the track in the same part of
     the program map section, interpreted as an integer as defined by <cite>Generic coding of moving
     pictures and associated audio information</cite>. Let <var>descriptor bytes</var> be the
     <var>length</var> bytes following the "ES_info_length" field. The <a href="#text-track-in-band-metadata-track-dispatch-type" id="sourcing-in-band-text-tracks:text-track-in-band-metadata-track-dispatch-type-4">text track in-band
     metadata track dispatch type</a> must be set to the concatenation of the <var>stream
     type</var> byte and the zero or more <var>descriptor bytes</var> bytes, expressed in
     hexadecimal using <a href="https://infra.spec.whatwg.org/#ascii-upper-hex-digit" id="sourcing-in-band-text-tracks:uppercase-ascii-hex-digits" data-x-internal="uppercase-ascii-hex-digits">ASCII upper hex digits</a>.
     <a href="#refsMPEG2">[MPEG2]</a>
     </dd><dt>If the <a href="#media-resource" id="sourcing-in-band-text-tracks:media-resource-8">media resource</a> is an MPEG-4 file</dt><dd>Let <var>stsd box</var> be the
     first <code>stsd</code> box of the
     first <code>stbl</code> box of the
     first <code>minf</code> box of the
     first <code>mdia</code> box of the
     <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-7">text track</a>'s <code>trak</code> box in the
     first <code>moov</code> box
     of the file, or null if no such <code>stsd</code> box exists.

     If <var>stsd box</var> is null, or if <var>stsd box</var> has neither a <code>mett</code> box nor a <code>metx</code> box, then the <a href="#text-track-in-band-metadata-track-dispatch-type" id="sourcing-in-band-text-tracks:text-track-in-band-metadata-track-dispatch-type-5">text track
     in-band metadata track dispatch type</a> must be set to the empty string.

     Otherwise, if <var>stsd box</var> has a <code>mett</code> box, then the <a href="#text-track-in-band-metadata-track-dispatch-type" id="sourcing-in-band-text-tracks:text-track-in-band-metadata-track-dispatch-type-6">text
     track in-band metadata track dispatch type</a> must be set to either the concatenation of the
     string "<code>mett</code>", a U+0020 SPACE character, and the value of the first <code>mime_format</code> field of the first <code>mett</code> box of <var>stsd
     box</var>, or the empty string if that field is absent in that box.

     Otherwise, if <var>stsd box</var> has no <code>mett</code> box but has a <code>metx</code> box, then the <a href="#text-track-in-band-metadata-track-dispatch-type" id="sourcing-in-band-text-tracks:text-track-in-band-metadata-track-dispatch-type-7">text track in-band metadata track dispatch type</a>
     must be set to either the concatenation of the string "<code>metx</code>", a U+0020 SPACE
     character, and the value of the first <code>namespace</code> field of the first <code>metx</code> box of <var>stsd box</var>, or the empty string if that field is absent in
     that box.

     <a href="#refsMPEG4">[MPEG4]</a>
     </dd></dl>
   </li><li><p>Populate the new <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-8">text track</a>'s <a href="#text-track-list-of-cues" id="sourcing-in-band-text-tracks:text-track-list-of-cues-2">list of
   cues</a> with the cues parsed so far, following the <a href="#guidelines-for-exposing-cues-in-various-formats-as-text-track-cues" id="sourcing-in-band-text-tracks:guidelines-for-exposing-cues-in-various-formats-as-text-track-cues">guidelines for exposing
   cues</a>, and begin updating it dynamically as necessary.</p></li><li><p>Set the new <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-9">text track</a>'s <a href="#text-track-readiness-state" id="sourcing-in-band-text-tracks:text-track-readiness-state">readiness
   state</a> to <a href="#text-track-loaded" id="sourcing-in-band-text-tracks:text-track-loaded">loaded</a>.</p></li><li><p>Set the new <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-10">text track</a>'s <a href="#text-track-mode" id="sourcing-in-band-text-tracks:text-track-mode">mode</a> to the
   mode consistent with the user's preferences and the requirements of the relevant specification
   for the data.</p>

    <p class="note">For instance, if there are no other active subtitles, and this is a forced
    subtitle track (a subtitle track giving subtitles in the audio track's primary language, but
    only for audio that is actually in another language), then those subtitles might be activated
    here.</p>
   </li><li><p>Add the new <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-11">text track</a> to the <a href="#media-element" id="sourcing-in-band-text-tracks:media-element">media element</a>'s <a href="#list-of-text-tracks" id="sourcing-in-band-text-tracks:list-of-text-tracks">list of text
   tracks</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sourcing-in-band-text-tracks:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="sourcing-in-band-text-tracks:event-media-addtrack"><a href="#event-media-addtrack">addtrack</a></code> at the <a href="#media-element" id="sourcing-in-band-text-tracks:media-element-2">media element</a>'s <code id="sourcing-in-band-text-tracks:dom-media-texttracks"><a href="#dom-media-texttracks">textTracks</a></code> attribute's <code id="sourcing-in-band-text-tracks:texttracklist"><a href="#texttracklist">TextTrackList</a></code> object,
   using <code id="sourcing-in-band-text-tracks:trackevent"><a href="#trackevent">TrackEvent</a></code>, with the <code id="sourcing-in-band-text-tracks:dom-trackevent-track"><a href="#dom-trackevent-track">track</a></code>
   attribute initialized to the <a href="#text-track" id="sourcing-in-band-text-tracks:text-track-12">text track</a>'s <code id="sourcing-in-band-text-tracks:texttrack-2"><a href="#texttrack">TextTrack</a></code> object.</p></li></ol>
  </div>

  

  

  



  

  <h6 id="sourcing-out-of-band-text-tracks"><span class="secno">4.8.11.11.3</span> Sourcing out-of-band text tracks<a href="#sourcing-out-of-band-text-tracks" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When a <code id="sourcing-out-of-band-text-tracks:the-track-element"><a href="#the-track-element">track</a></code> element is created, it must be associated with a new <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track">text
  track</a> (with its value set as defined below) and its corresponding new
  <code id="sourcing-out-of-band-text-tracks:texttrack"><a href="#texttrack">TextTrack</a></code> object.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#text-track-kind" id="sourcing-out-of-band-text-tracks:text-track-kind">text track kind</a> is determined from the state of the element's <code id="sourcing-out-of-band-text-tracks:attr-track-kind"><a href="#attr-track-kind">kind</a></code> attribute according to the following table; for a state given
  in a cell of the first column, the <a href="#text-track-kind" id="sourcing-out-of-band-text-tracks:text-track-kind-2">kind</a> is the string given
  in the second column:</p>

  <table><thead><tr><th>State
     </th><th>String
   </th></tr></thead><tbody><tr><td><a href="#attr-track-kind-subtitles" id="sourcing-out-of-band-text-tracks:attr-track-kind-subtitles">Subtitles</a>
     </td><td><code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-subtitles"><a href="#dom-texttrack-kind-subtitles">subtitles</a></code>
    </td></tr><tr><td><a href="#attr-track-kind-captions" id="sourcing-out-of-band-text-tracks:attr-track-kind-captions">Captions</a>
     </td><td><code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-captions"><a href="#dom-texttrack-kind-captions">captions</a></code>
    </td></tr><tr><td><a href="#attr-track-kind-descriptions" id="sourcing-out-of-band-text-tracks:attr-track-kind-descriptions">Descriptions</a>
     </td><td><code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-descriptions"><a href="#dom-texttrack-kind-descriptions">descriptions</a></code>
    </td></tr><tr><td><a href="#attr-track-kind-chapters" id="sourcing-out-of-band-text-tracks:attr-track-kind-chapters">Chapters metadata</a>
     </td><td><code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-chapters"><a href="#dom-texttrack-kind-chapters">chapters</a></code>
    </td></tr><tr><td><a href="#attr-track-kind-metadata" id="sourcing-out-of-band-text-tracks:attr-track-kind-metadata">Metadata</a>
     </td><td><code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-metadata"><a href="#dom-texttrack-kind-metadata">metadata</a></code>
  </td></tr></tbody></table>
  </div>

  <div data-algorithm="">
  <p>The <a href="#text-track-label" id="sourcing-out-of-band-text-tracks:text-track-label">text track label</a> is the element's <a href="#track-label" id="sourcing-out-of-band-text-tracks:track-label">track label</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#text-track-language" id="sourcing-out-of-band-text-tracks:text-track-language">text track language</a> is the element's <a href="#track-language" id="sourcing-out-of-band-text-tracks:track-language">track language</a>, if any, or
  the empty string otherwise.</p>
  </div>

  <p>As the <code id="sourcing-out-of-band-text-tracks:attr-track-kind-2"><a href="#attr-track-kind">kind</a></code>, <code id="sourcing-out-of-band-text-tracks:attr-track-label"><a href="#attr-track-label">label</a></code>,
  and <code id="sourcing-out-of-band-text-tracks:attr-track-srclang"><a href="#attr-track-srclang">srclang</a></code> attributes are set, changed, or removed, the
  <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-2">text track</a> must update accordingly, as per the definitions above.</p>

  <p class="note">Changes to the <a href="#track-url" id="sourcing-out-of-band-text-tracks:track-url">track URL</a> are handled in the algorithm below.</p>

  <p>The <a href="#text-track-readiness-state" id="sourcing-out-of-band-text-tracks:text-track-readiness-state">text track readiness state</a> is initially <a href="#text-track-not-loaded" id="sourcing-out-of-band-text-tracks:text-track-not-loaded">not loaded</a>, and the <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode">text track mode</a> is initially <a href="#text-track-disabled" id="sourcing-out-of-band-text-tracks:text-track-disabled">disabled</a>.</p>

  <p>The <a href="#text-track-list-of-cues" id="sourcing-out-of-band-text-tracks:text-track-list-of-cues">text track list of cues</a> is initially empty. It is dynamically modified when
  the referenced file is parsed. Associated with the list are the <a href="#rules-for-updating-the-text-track-rendering" id="sourcing-out-of-band-text-tracks:rules-for-updating-the-text-track-rendering">rules for updating the text
  track rendering</a> appropriate for the format in question; for WebVTT, this is the <a id="sourcing-out-of-band-text-tracks:rules-for-updating-the-display-of-webvtt-text-tracks" href="https://w3c.github.io/webvtt/#rules-for-updating-the-display-of-webvtt-text-tracks" data-x-internal="rules-for-updating-the-display-of-webvtt-text-tracks">rules
  for updating the display of WebVTT text tracks</a>. <a href="#refsWEBVTT">[WEBVTT]</a></p>

  <div data-algorithm="">
  <p>When a <code id="sourcing-out-of-band-text-tracks:the-track-element-2"><a href="#the-track-element">track</a></code> element's parent element changes and the new parent is a <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element">media
  element</a>, then the user agent must add the <code id="sourcing-out-of-band-text-tracks:the-track-element-3"><a href="#the-track-element">track</a></code> element's corresponding
  <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-3">text track</a> to the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-2">media element</a>'s <a href="#list-of-text-tracks" id="sourcing-out-of-band-text-tracks:list-of-text-tracks">list of text tracks</a>, and
  then <a href="#queue-a-media-element-task" id="sourcing-out-of-band-text-tracks:queue-a-media-element-task">queue a media element task</a> given the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-3">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sourcing-out-of-band-text-tracks:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="sourcing-out-of-band-text-tracks:event-media-addtrack"><a href="#event-media-addtrack">addtrack</a></code> at the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-4">media element</a>'s <code id="sourcing-out-of-band-text-tracks:dom-media-texttracks"><a href="#dom-media-texttracks">textTracks</a></code> attribute's <code id="sourcing-out-of-band-text-tracks:texttracklist"><a href="#texttracklist">TextTrackList</a></code> object,
  using <code id="sourcing-out-of-band-text-tracks:trackevent"><a href="#trackevent">TrackEvent</a></code>, with the <code id="sourcing-out-of-band-text-tracks:dom-trackevent-track"><a href="#dom-trackevent-track">track</a></code> attribute
  initialized to the <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-4">text track</a>'s <code id="sourcing-out-of-band-text-tracks:texttrack-2"><a href="#texttrack">TextTrack</a></code> object.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="sourcing-out-of-band-text-tracks:the-track-element-4"><a href="#the-track-element">track</a></code> element's parent element changes and the old parent was a <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-5">media
  element</a>, then the user agent must remove the <code id="sourcing-out-of-band-text-tracks:the-track-element-5"><a href="#the-track-element">track</a></code> element's corresponding
  <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-5">text track</a> from the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-6">media element</a>'s <a href="#list-of-text-tracks" id="sourcing-out-of-band-text-tracks:list-of-text-tracks-2">list of text tracks</a>,
  and then <a href="#queue-a-media-element-task" id="sourcing-out-of-band-text-tracks:queue-a-media-element-task-2">queue a media element task</a> given the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-7">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sourcing-out-of-band-text-tracks:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="sourcing-out-of-band-text-tracks:event-media-removetrack"><a href="#event-media-removetrack">removetrack</a></code> at the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-8">media element</a>'s <code id="sourcing-out-of-band-text-tracks:dom-media-texttracks-2"><a href="#dom-media-texttracks">textTracks</a></code> attribute's <code id="sourcing-out-of-band-text-tracks:texttracklist-2"><a href="#texttracklist">TextTrackList</a></code> object,
  using <code id="sourcing-out-of-band-text-tracks:trackevent-2"><a href="#trackevent">TrackEvent</a></code>, with the <code id="sourcing-out-of-band-text-tracks:dom-trackevent-track-2"><a href="#dom-trackevent-track">track</a></code> attribute
  initialized to the <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-6">text track</a>'s <code id="sourcing-out-of-band-text-tracks:texttrack-3"><a href="#texttrack">TextTrack</a></code> object.</p>
  </div>
  

  <hr>

  <div data-algorithm="">
  <p>When a <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-7">text track</a> corresponding to a <code id="sourcing-out-of-band-text-tracks:the-track-element-6"><a href="#the-track-element">track</a></code> element is added to a
  <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-9">media element</a>'s <a href="#list-of-text-tracks" id="sourcing-out-of-band-text-tracks:list-of-text-tracks-3">list of text tracks</a>, the user agent must <a href="#queue-a-media-element-task" id="sourcing-out-of-band-text-tracks:queue-a-media-element-task-3">queue a
  media element task</a> given the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-10">media element</a> to run the following steps for the
  <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-11">media element</a>:</p>

  <ol><li><p>If the element's <a href="#blocked-on-parser" id="sourcing-out-of-band-text-tracks:blocked-on-parser">blocked-on-parser</a> flag is true, then return.</p></li><li><p>If the element's <a href="#did-perform-automatic-track-selection" id="sourcing-out-of-band-text-tracks:did-perform-automatic-track-selection">did-perform-automatic-track-selection</a> flag is true, then
   return.</p></li><li><p><a href="#honor-user-preferences-for-automatic-text-track-selection" id="sourcing-out-of-band-text-tracks:honor-user-preferences-for-automatic-text-track-selection">Honor user preferences for automatic text track selection</a> for this
   element.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the user agent is required to <dfn id="honor-user-preferences-for-automatic-text-track-selection">honor user preferences for automatic text track
  selection</dfn> for a <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-12">media element</a>, the user agent must run the following steps:</p>

  <ol><li><p><a href="#perform-automatic-text-track-selection" id="sourcing-out-of-band-text-tracks:perform-automatic-text-track-selection">Perform automatic text track selection</a> for <code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-subtitles-2"><a href="#dom-texttrack-kind-subtitles">subtitles</a></code> and <code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-captions-2"><a href="#dom-texttrack-kind-captions">captions</a></code>.</p></li><li><p><a href="#perform-automatic-text-track-selection" id="sourcing-out-of-band-text-tracks:perform-automatic-text-track-selection-2">Perform automatic text track selection</a> for <code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-descriptions-2"><a href="#dom-texttrack-kind-descriptions">descriptions</a></code>.</p></li><li><p>If there are any <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-8">text tracks</a> in the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-13">media
   element</a>'s <a href="#list-of-text-tracks" id="sourcing-out-of-band-text-tracks:list-of-text-tracks-4">list of text tracks</a> whose <a href="#text-track-kind" id="sourcing-out-of-band-text-tracks:text-track-kind-3">text track kind</a> is <code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-metadata-2"><a href="#dom-texttrack-kind-metadata">chapters</a></code> or <code id="sourcing-out-of-band-text-tracks:dom-texttrack-kind-metadata-3"><a href="#dom-texttrack-kind-metadata">metadata</a></code> that correspond to <code id="sourcing-out-of-band-text-tracks:the-track-element-7"><a href="#the-track-element">track</a></code>
   elements with a <code id="sourcing-out-of-band-text-tracks:attr-track-default"><a href="#attr-track-default">default</a></code> attribute set whose <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-2">text
   track mode</a> is set to <a href="#text-track-disabled" id="sourcing-out-of-band-text-tracks:text-track-disabled-2">disabled</a>, then set the
   <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-3">text track mode</a> of all such tracks to <a href="#text-track-hidden" id="sourcing-out-of-band-text-tracks:text-track-hidden">hidden</a>.</p></li><li><p>Set the element's <a href="#did-perform-automatic-track-selection" id="sourcing-out-of-band-text-tracks:did-perform-automatic-track-selection-2">did-perform-automatic-track-selection</a> flag to
   true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the steps above say to <dfn id="perform-automatic-text-track-selection">perform automatic text track selection</dfn> for one or more
  <a href="#text-track-kind" id="sourcing-out-of-band-text-tracks:text-track-kind-4">text track kinds</a>, it means to run the following steps:</p>

  <ol><li><p>Let <var>candidates</var> be a list consisting of the <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-9">text tracks</a> in the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-14">media element</a>'s <a href="#list-of-text-tracks" id="sourcing-out-of-band-text-tracks:list-of-text-tracks-5">list of text tracks</a>
   whose <a href="#text-track-kind" id="sourcing-out-of-band-text-tracks:text-track-kind-5">text track kind</a> is one of the kinds that were passed to the algorithm, if any,
   in the order given in the <a href="#list-of-text-tracks" id="sourcing-out-of-band-text-tracks:list-of-text-tracks-6">list of text tracks</a>.</p></li><li><p>If <var>candidates</var> is empty, then return.</p></li><li><p>If any of the <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-10">text tracks</a> in <var>candidates</var> have a <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-4">text track mode</a> set to <a href="#text-track-showing" id="sourcing-out-of-band-text-tracks:text-track-showing">showing</a>, return.</p></li><li>
    <p>If the user has expressed an interest in having a track from <var>candidates</var>
    enabled based on its <a href="#text-track-kind" id="sourcing-out-of-band-text-tracks:text-track-kind-6">text track kind</a>, <a href="#text-track-language" id="sourcing-out-of-band-text-tracks:text-track-language-2">text track language</a>, and
    <a href="#text-track-label" id="sourcing-out-of-band-text-tracks:text-track-label-2">text track label</a>, then set its <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-5">text track mode</a> to <a href="#text-track-showing" id="sourcing-out-of-band-text-tracks:text-track-showing-2">showing</a>.</p> 

    <p class="note">For example, the user could have set a browser preference to the effect of "I
    want French captions whenever possible", or "If there is a subtitle track with 'Commentary' in
    the title, enable it", or "If there are audio description tracks available, enable one, ideally
    in Swiss German, but failing that in Standard Swiss German or Standard German".</p>

    <p>Otherwise, if there are any <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-11">text tracks</a> in <var>candidates</var> that correspond to <code id="sourcing-out-of-band-text-tracks:the-track-element-8"><a href="#the-track-element">track</a></code> elements with a <code id="sourcing-out-of-band-text-tracks:attr-track-default-2"><a href="#attr-track-default">default</a></code> attribute set whose <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-6">text track mode</a> is
    set to <a href="#text-track-disabled" id="sourcing-out-of-band-text-tracks:text-track-disabled-3">disabled</a>, then set the <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-7">text track
    mode</a> of the first such track to <a href="#text-track-showing" id="sourcing-out-of-band-text-tracks:text-track-showing-3">showing</a>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-12">text track</a> corresponding to a <code id="sourcing-out-of-band-text-tracks:the-track-element-9"><a href="#the-track-element">track</a></code> element experiences any of
  the following circumstances, the user agent must <a href="#start-the-track-processing-model" id="sourcing-out-of-band-text-tracks:start-the-track-processing-model">start the <code>track</code> processing
  model</a> for that <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-13">text track</a> and its <code id="sourcing-out-of-band-text-tracks:the-track-element-10"><a href="#the-track-element">track</a></code> element:

  </p><ul><li>The <code id="sourcing-out-of-band-text-tracks:the-track-element-11"><a href="#the-track-element">track</a></code> element is created.</li><li>The <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-14">text track</a> has its <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-8">text track mode</a> changed.</li><li>The <code id="sourcing-out-of-band-text-tracks:the-track-element-12"><a href="#the-track-element">track</a></code> element's parent element changes and the new parent is a <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-15">media
   element</a>.</li></ul>
  </div>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="start-the-track-processing-model">start the <code>track</code> processing model</dfn> for a
  <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-15">text track</a> and its <code id="sourcing-out-of-band-text-tracks:the-track-element-13"><a href="#the-track-element">track</a></code> element, it must run the following algorithm.
  This algorithm interacts closely with the <a href="#event-loop" id="sourcing-out-of-band-text-tracks:event-loop">event loop</a> mechanism; in particular, it has
  a <a href="#synchronous-section" id="sourcing-out-of-band-text-tracks:synchronous-section">synchronous section</a> (which is triggered as part of the <a href="#event-loop" id="sourcing-out-of-band-text-tracks:event-loop-2">event loop</a>
  algorithm). The steps in that section are marked with ⌛.</p>

  <ol><li><p>If another occurrence of this algorithm is already running for this <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-16">text
   track</a> and its <code id="sourcing-out-of-band-text-tracks:the-track-element-14"><a href="#the-track-element">track</a></code> element, return, letting that other algorithm
   take care of this element.</p></li><li><p>If the <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-17">text track</a>'s <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-9">text track mode</a> is not set to one of <a href="#text-track-hidden" id="sourcing-out-of-band-text-tracks:text-track-hidden-2">hidden</a> or <a href="#text-track-showing" id="sourcing-out-of-band-text-tracks:text-track-showing-4">showing</a>,
   then return.</p></li><li><p>If the <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-18">text track</a>'s <code id="sourcing-out-of-band-text-tracks:the-track-element-15"><a href="#the-track-element">track</a></code> element does not have a <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-16">media
   element</a> as a parent, return.</p></li><li><p>Run the remainder of these steps <a href="#in-parallel" id="sourcing-out-of-band-text-tracks:in-parallel">in parallel</a>, allowing whatever caused these steps to
   run to continue.</p></li><li><p><i>Top</i>: <a href="#await-a-stable-state" id="sourcing-out-of-band-text-tracks:await-a-stable-state">Await a stable state</a>. The <a href="#synchronous-section" id="sourcing-out-of-band-text-tracks:synchronous-section-2">synchronous section</a>
   consists of the following steps. (The steps in the <a href="#synchronous-section" id="sourcing-out-of-band-text-tracks:synchronous-section-3">synchronous section</a> are marked
   with ⌛.)</p></li><li><p>⌛ Set the <a href="#text-track-readiness-state" id="sourcing-out-of-band-text-tracks:text-track-readiness-state-2">text track readiness state</a> to <a href="#text-track-loading" id="sourcing-out-of-band-text-tracks:text-track-loading">loading</a>.</p></li><li><p>⌛ Let <var>URL</var> be the <a href="#track-url" id="sourcing-out-of-band-text-tracks:track-url-2">track URL</a> of the
   <code id="sourcing-out-of-band-text-tracks:the-track-element-16"><a href="#the-track-element">track</a></code> element.</p></li><li><p>⌛ If the <code id="sourcing-out-of-band-text-tracks:the-track-element-17"><a href="#the-track-element">track</a></code> element's parent is a <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-17">media element</a>, then
   let <var>corsAttributeState</var> be the state of the parent <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-18">media element</a>'s <code id="sourcing-out-of-band-text-tracks:attr-media-crossorigin"><a href="#attr-media-crossorigin">crossorigin</a></code> content attribute. Otherwise, let
   <var>corsAttributeState</var> be <a href="#attr-crossorigin-none" id="sourcing-out-of-band-text-tracks:attr-crossorigin-none">No CORS</a>.</p></li><li><p>End the <a href="#synchronous-section" id="sourcing-out-of-band-text-tracks:synchronous-section-4">synchronous section</a>, continuing the remaining steps
   <a href="#in-parallel" id="sourcing-out-of-band-text-tracks:in-parallel-2">in parallel</a>.</p></li><li>
    <p>If <var>URL</var> is not the empty string, then:

    </p><ol><li><p>Let <var>request</var> be the result of <a href="#create-a-potential-cors-request" id="sourcing-out-of-band-text-tracks:create-a-potential-cors-request">creating a potential-CORS request</a> given
     <var>URL</var>, "<code>track</code>", and <var>corsAttributeState</var>, and with the
     <i>same-origin fallback flag</i> set.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="sourcing-out-of-band-text-tracks:concept-request-client" data-x-internal="concept-request-client">client</a> to the
     <code id="sourcing-out-of-band-text-tracks:the-track-element-18"><a href="#the-track-element">track</a></code> element's <a id="sourcing-out-of-band-text-tracks:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#relevant-settings-object" id="sourcing-out-of-band-text-tracks:relevant-settings-object">relevant settings
     object</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="sourcing-out-of-band-text-tracks:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator
     type</a> to "<code>track</code>".</p></li><li><p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="sourcing-out-of-band-text-tracks:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var>.</p></li></ol>

    <p>The <a href="#concept-task" id="sourcing-out-of-band-text-tracks:concept-task">tasks</a> <a href="#queue-a-task" id="sourcing-out-of-band-text-tracks:queue-a-task">queued</a> by the
    fetching algorithm on the <a href="#networking-task-source" id="sourcing-out-of-band-text-tracks:networking-task-source">networking task source</a> to process the data as it is being
    fetched must determine the  type of
    the resource. If the  type of the resource is not a supported text
    track format, the load will fail, as described below. Otherwise, the resource's data must be
    passed to the appropriate parser (e.g., the <a id="sourcing-out-of-band-text-tracks:webvtt-parser" href="https://w3c.github.io/webvtt/#webvtt-parser" data-x-internal="webvtt-parser">WebVTT parser</a>) as it is received, with the <a href="#text-track-list-of-cues" id="sourcing-out-of-band-text-tracks:text-track-list-of-cues-2">text
    track list of cues</a> being used for that parser's output. <a href="#refsWEBVTT">[WEBVTT]</a></p>

    <p class="note">The appropriate parser will incrementally update the <a href="#text-track-list-of-cues" id="sourcing-out-of-band-text-tracks:text-track-list-of-cues-3">text track list of
    cues</a> during these <a href="#networking-task-source" id="sourcing-out-of-band-text-tracks:networking-task-source-2">networking task
    source</a> <a href="#concept-task" id="sourcing-out-of-band-text-tracks:concept-task-2">tasks</a>, as each such task is
    run with whatever data has been received from the network).</p>

    <p class="critical">This specification does not currently say whether or how to check the MIME
    types of text tracks, or whether or how to perform file type sniffing using the actual file
    data. Implementers differ in their intentions on this matter and it is therefore unclear what
    the right solution is. In the absence of any requirement here, the HTTP specifications' strict
    requirement to follow the Content-Type header prevails ("Content-Type specifies the media type
    of the underlying data." ... "If and only if the media type is not given by a Content-Type
    field, the recipient MAY attempt to guess the media type via inspection of its content
    and/or the name extension(s) of the URI used to identify the resource.").</p>

    <p>If fetching fails for any reason (network error, the server returns an error code, CORS
    fails, etc.), or if <var>URL</var> is the empty string, then <a href="#queue-an-element-task" id="sourcing-out-of-band-text-tracks:queue-an-element-task">queue an element task</a>
    on the <a href="#dom-manipulation-task-source" id="sourcing-out-of-band-text-tracks:dom-manipulation-task-source">DOM manipulation task source</a> given the <a href="#media-element" id="sourcing-out-of-band-text-tracks:media-element-19">media element</a> to first
    change the <a href="#text-track-readiness-state" id="sourcing-out-of-band-text-tracks:text-track-readiness-state-3">text track readiness state</a> to <a href="#text-track-failed-to-load" id="sourcing-out-of-band-text-tracks:text-track-failed-to-load">failed to load</a> and then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sourcing-out-of-band-text-tracks:concept-event-fire-3" data-x-internal="concept-event-fire">fire an event</a>
    named <code id="sourcing-out-of-band-text-tracks:event-track-error"><a href="#event-track-error">error</a></code> at the <code id="sourcing-out-of-band-text-tracks:the-track-element-19"><a href="#the-track-element">track</a></code> element.</p>
    

    <p>If fetching does not fail, but the  type of the resource is not a supported
    text track format, or the file was not successfully processed (e.g., the format in question is
    an XML format and the file contained a well-formedness error that <cite>XML</cite> requires be
    detected and reported to the application), then the <a href="#concept-task" id="sourcing-out-of-band-text-tracks:concept-task-3">task</a> that
    is <a href="#queue-an-element-task" id="sourcing-out-of-band-text-tracks:queue-an-element-task-2">queued</a> on the <a href="#networking-task-source" id="sourcing-out-of-band-text-tracks:networking-task-source-3">networking task source</a>
    in which the aforementioned problem is found must change the <a href="#text-track-readiness-state" id="sourcing-out-of-band-text-tracks:text-track-readiness-state-4">text track readiness
    state</a> to <a href="#text-track-failed-to-load" id="sourcing-out-of-band-text-tracks:text-track-failed-to-load-2">failed to load</a> and <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sourcing-out-of-band-text-tracks:concept-event-fire-4" data-x-internal="concept-event-fire">fire an event</a> named <code id="sourcing-out-of-band-text-tracks:event-track-error-2"><a href="#event-track-error">error</a></code> at the <code id="sourcing-out-of-band-text-tracks:the-track-element-20"><a href="#the-track-element">track</a></code> element.</p>

    <p>If fetching does not fail, and the file was successfully processed, then the final <a href="#concept-task" id="sourcing-out-of-band-text-tracks:concept-task-4">task</a> that is <a href="#queue-an-element-task" id="sourcing-out-of-band-text-tracks:queue-an-element-task-3">queued</a> by
    the <a href="#networking-task-source" id="sourcing-out-of-band-text-tracks:networking-task-source-4">networking task source</a>, after it has finished parsing the data, must change the
    <a href="#text-track-readiness-state" id="sourcing-out-of-band-text-tracks:text-track-readiness-state-5">text track readiness state</a> to <a href="#text-track-loaded" id="sourcing-out-of-band-text-tracks:text-track-loaded">loaded</a>, and
    <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sourcing-out-of-band-text-tracks:concept-event-fire-5" data-x-internal="concept-event-fire">fire an event</a> named <code id="sourcing-out-of-band-text-tracks:event-track-load"><a href="#event-track-load">load</a></code> at the <code id="sourcing-out-of-band-text-tracks:the-track-element-21"><a href="#the-track-element">track</a></code> element.</p>

    <p>If, while fetching is ongoing, either:</p>

    <ul><li>the <a href="#track-url" id="sourcing-out-of-band-text-tracks:track-url-3">track URL</a> changes so that it is no longer equal to <var>URL</var>, while the <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-10">text track mode</a> is set to <a href="#text-track-hidden" id="sourcing-out-of-band-text-tracks:text-track-hidden-3">hidden</a> or <a href="#text-track-showing" id="sourcing-out-of-band-text-tracks:text-track-showing-5">showing</a>; or</li><li>the <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-11">text track mode</a> changes to <a href="#text-track-hidden" id="sourcing-out-of-band-text-tracks:text-track-hidden-4">hidden</a>
     or <a href="#text-track-showing" id="sourcing-out-of-band-text-tracks:text-track-showing-6">showing</a>, while the <a href="#track-url" id="sourcing-out-of-band-text-tracks:track-url-4">track URL</a> is not
     equal to <var>URL</var>,</li></ul>

    <p>...then the user agent must abort <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="sourcing-out-of-band-text-tracks:concept-fetch-2" data-x-internal="concept-fetch">fetching</a>, discarding
    any pending <a href="#concept-task" id="sourcing-out-of-band-text-tracks:concept-task-5">tasks</a> generated by that algorithm (and in
    particular, not adding any cues to the <a href="#text-track-list-of-cues" id="sourcing-out-of-band-text-tracks:text-track-list-of-cues-4">text track list of cues</a> after the moment the
    URL changed), and then <a href="#queue-an-element-task" id="sourcing-out-of-band-text-tracks:queue-an-element-task-4">queue an element task</a> on the <a href="#dom-manipulation-task-source" id="sourcing-out-of-band-text-tracks:dom-manipulation-task-source-2">DOM manipulation task
    source</a> given the <code id="sourcing-out-of-band-text-tracks:the-track-element-22"><a href="#the-track-element">track</a></code> element that first changes the <a href="#text-track-readiness-state" id="sourcing-out-of-band-text-tracks:text-track-readiness-state-6">text track
    readiness state</a> to <a href="#text-track-failed-to-load" id="sourcing-out-of-band-text-tracks:text-track-failed-to-load-3">failed to load</a> and
    then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sourcing-out-of-band-text-tracks:concept-event-fire-6" data-x-internal="concept-event-fire">fires an event</a> named <code id="sourcing-out-of-band-text-tracks:event-track-error-3"><a href="#event-track-error">error</a></code> at the <code id="sourcing-out-of-band-text-tracks:the-track-element-23"><a href="#the-track-element">track</a></code> element. </p>
   </li><li><p>Wait until the <a href="#text-track-readiness-state" id="sourcing-out-of-band-text-tracks:text-track-readiness-state-7">text track readiness state</a> is no longer set to <a href="#text-track-loading" id="sourcing-out-of-band-text-tracks:text-track-loading-2">loading</a>.</p></li><li><p>Wait until the <a href="#track-url" id="sourcing-out-of-band-text-tracks:track-url-5">track URL</a> is no longer equal to <var>URL</var>, at
   the same time as the <a href="#text-track-mode" id="sourcing-out-of-band-text-tracks:text-track-mode-12">text track mode</a> is set to <a href="#text-track-hidden" id="sourcing-out-of-band-text-tracks:text-track-hidden-5">hidden</a> or <a href="#text-track-showing" id="sourcing-out-of-band-text-tracks:text-track-showing-7">showing</a>.</p></li><li><p>Jump to the step labeled <i>top</i>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Whenever a <code id="sourcing-out-of-band-text-tracks:the-track-element-24"><a href="#the-track-element">track</a></code> element has its <code id="sourcing-out-of-band-text-tracks:attr-track-src"><a href="#attr-track-src">src</a></code> attribute
  set, changed, or removed, the user agent must <a href="#immediately" id="sourcing-out-of-band-text-tracks:immediately">immediately</a> empty the element's <a href="#text-track" id="sourcing-out-of-band-text-tracks:text-track-19">text
  track</a>'s <a href="#text-track-list-of-cues" id="sourcing-out-of-band-text-tracks:text-track-list-of-cues-5">text track list of cues</a>. (This also causes the algorithm above to stop
  adding cues from the resource being obtained using the previously given URL, if any.)</p>
  </div>

  


  

  <h6 id="guidelines-for-exposing-cues-in-various-formats-as-text-track-cues"><span class="secno">4.8.11.11.4</span> <dfn>Guidelines for exposing cues</dfn> in various formats as <a href="#text-track-cue" id="guidelines-for-exposing-cues-in-various-formats-as-text-track-cues:text-track-cue">text track cues</a><a href="#guidelines-for-exposing-cues-in-various-formats-as-text-track-cues" class="self-link"></a></h6>

  <p>How a specific format's text track cues are to be interpreted for the purposes of processing by
  an HTML user agent is defined by that format. In the absence of such a specification, this section
  provides some constraints within which implementations can attempt to consistently expose such
  formats.</p>

  <p>To support the <a href="#text-track" id="guidelines-for-exposing-cues-in-various-formats-as-text-track-cues:text-track">text track</a> model of HTML, each unit of timed data is converted to a
  <a href="#text-track-cue" id="guidelines-for-exposing-cues-in-various-formats-as-text-track-cues:text-track-cue-2">text track cue</a>. Where the mapping of the format's features to the aspects of a
  <a href="#text-track-cue" id="guidelines-for-exposing-cues-in-various-formats-as-text-track-cues:text-track-cue-3">text track cue</a> as defined in this specification are not defined, implementations must
  ensure that the mapping is consistent with the definitions of the aspects of a <a href="#text-track-cue" id="guidelines-for-exposing-cues-in-various-formats-as-text-track-cues:text-track-cue-4">text track
  cue</a> as defined above, as well as with the following constraints:</p>

  <dl><dt>The <a href="#text-track-cue-identifier" id="guidelines-for-exposing-cues-in-various-formats-as-text-track-cues:text-track-cue-identifier">text track cue identifier</a>
   </dt><dd>
    <p>Should be set to the empty string if the format has no obvious analogue to a per-cue
    identifier.</p>
   </dd><dt>The <a href="#text-track-cue-pause-on-exit-flag" id="guidelines-for-exposing-cues-in-various-formats-as-text-track-cues:text-track-cue-pause-on-exit-flag">text track cue pause-on-exit flag</a>
   </dt><dd>
    <p>Should be set to false.</p>
   </dd></dl>

  


  <h6 id="text-track-api"><span class="secno">4.8.11.11.5</span> Text track API<a href="#text-track-api" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList" title="The TextTrackList interface is used to represent a list of the text tracks defined by the <track> element, with each track represented by a separate textTrack object in the list.">TextTrackList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="texttracklist" data-dfn-type="interface"><c- g="">TextTrackList</c-></dfn> : <a id="text-track-api:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-texttracklist-length" id="text-track-api:dom-texttracklist-length"><c- g="">length</c-></a>;
  <a href="#dom-texttracklist-item"><c- b="">getter</c-></a> <a href="#texttrack" id="text-track-api:texttrack"><c- n="">TextTrack</c-></a> (<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <a href="#texttrack" id="text-track-api:texttrack-2"><c- n="">TextTrack</c-></a>? <a href="#dom-texttracklist-gettrackbyid" id="text-track-api:dom-texttracklist-gettrackbyid"><c- g="">getTrackById</c-></a>(<c- b="">DOMString</c-> <c- g="">id</c->);

  <c- b="">attribute</c-> <a href="#eventhandler" id="text-track-api:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-texttracklist-onchange" id="text-track-api:handler-texttracklist-onchange"><c- g="">onchange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="text-track-api:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-texttracklist-onaddtrack" id="text-track-api:handler-texttracklist-onaddtrack"><c- g="">onaddtrack</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="text-track-api:eventhandler-3"><c- n="">EventHandler</c-></a> <a href="#handler-texttracklist-onremovetrack" id="text-track-api:handler-texttracklist-onremovetrack"><c- g="">onremovetrack</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-texttracks" id="dom-media-texttracks-dev">textTracks</a>.<span>length</span></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/textTracks" title="The read-only textTracks property on HTMLMediaElement objects returns a TextTrackList object listing all of the TextTrack objects representing the media element's text tracks, in the same order as in the list of text tracks.">HTMLMediaElement/textTracks</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the number of <a href="#text-track" id="text-track-api:text-track">text tracks</a> associated with the
    <a href="#media-element" id="text-track-api:media-element">media element</a> (e.g. from <code id="text-track-api:the-track-element"><a href="#the-track-element">track</a></code> elements). This is the number of <a href="#text-track" id="text-track-api:text-track-2">text tracks</a> in the <a href="#media-element" id="text-track-api:media-element-2">media element</a>'s <a href="#list-of-text-tracks" id="text-track-api:list-of-text-tracks">list of text
    tracks</a>.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-texttracks" id="text-track-api:dom-media-texttracks">textTracks[</a> <var>n</var> <span>]</span></code></dt><dd>
    <p>Returns the <code id="text-track-api:texttrack-3"><a href="#texttrack">TextTrack</a></code> object representing the <var>n</var>th <a href="#text-track" id="text-track-api:text-track-3">text
    track</a> in the <a href="#media-element" id="text-track-api:media-element-3">media element</a>'s <a href="#list-of-text-tracks" id="text-track-api:list-of-text-tracks-2">list of text tracks</a>.</p>
   </dd><dt><code><var>textTrack</var> = <var>media</var>.<a href="#dom-media-texttracks" id="text-track-api:dom-media-texttracks-2">textTracks</a>.<a href="#dom-texttracklist-gettrackbyid" id="dom-texttracklist-gettrackbyid-dev">getTrackById</a>(<var>id</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList/getTrackById" title="The TextTrackList method getTrackById() returns the first TextTrack object from the track list whose id matches the specified string. This lets you find a specified track if you know its ID string.">TextTrackList/getTrackById</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>33+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="text-track-api:texttrack-4"><a href="#texttrack">TextTrack</a></code> object with the given identifier, or null if no track has
    that identifier.</p>
   </dd></dl>

  

  <p>A <code id="text-track-api:texttracklist"><a href="#texttracklist">TextTrackList</a></code> object represents a dynamically updating list of <a href="#text-track" id="text-track-api:text-track-4">text tracks</a> in a given order.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-texttracks" data-dfn-type="attribute"><code>textTracks</code></dfn> attribute of <a href="#media-element" id="text-track-api:media-element-4">media elements</a> must return a <code id="text-track-api:texttracklist-2"><a href="#texttracklist">TextTrackList</a></code> object representing the
  <code id="text-track-api:texttrack-5"><a href="#texttrack">TextTrack</a></code> objects of the <a href="#text-track" id="text-track-api:text-track-5">text tracks</a> in the
  <a href="#media-element" id="text-track-api:media-element-5">media element</a>'s <a href="#list-of-text-tracks" id="text-track-api:list-of-text-tracks-3">list of text tracks</a>, in the same order as in the
  <a href="#list-of-text-tracks" id="text-track-api:list-of-text-tracks-4">list of text tracks</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList/length" title="The read-only TextTrackList property length returns the number of entries in the TextTrackList, each of which is a TextTrack representing one track in the media element.">TextTrackList/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrackList" id="dom-texttracklist-length" data-dfn-type="attribute"><code>length</code></dfn> attribute of a <code id="text-track-api:texttracklist-3"><a href="#texttracklist">TextTrackList</a></code>
  object must return the number of <a href="#text-track" id="text-track-api:text-track-6">text tracks</a> in the list
  represented by the <code id="text-track-api:texttracklist-4"><a href="#texttracklist">TextTrackList</a></code> object.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="text-track-api:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> of a <code id="text-track-api:texttracklist-5"><a href="#texttracklist">TextTrackList</a></code> object at any
  instant are the numbers from zero to the number of <a href="#text-track" id="text-track-api:text-track-7">text tracks</a> in
  the list represented by the <code id="text-track-api:texttracklist-6"><a href="#texttracklist">TextTrackList</a></code> object minus one, if any. If there are no
  <a href="#text-track" id="text-track-api:text-track-8">text tracks</a> in the list, there are no <a id="text-track-api:supported-property-indices-2" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property
  indices</a>.</p>
  </div>

  <div data-algorithm="">
  <p id="dom-texttracklist-item">To <a id="text-track-api:determine-the-value-of-an-indexed-property" href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-an-indexed-property" data-x-internal="determine-the-value-of-an-indexed-property">determine the value of an indexed property</a> of a
  <code id="text-track-api:texttracklist-7"><a href="#texttracklist">TextTrackList</a></code> object for a given index <var>index</var>, the user agent must return
  the <var>index</var>th <a href="#text-track" id="text-track-api:text-track-9">text track</a> in the list represented by the
  <code id="text-track-api:texttracklist-8"><a href="#texttracklist">TextTrackList</a></code> object.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrackList" id="dom-texttracklist-gettrackbyid" data-dfn-type="method"><code>getTrackById(<var>id</var>)</code></dfn> method must
  return the first <code id="text-track-api:texttrack-6"><a href="#texttrack">TextTrack</a></code> in the <code id="text-track-api:texttracklist-9"><a href="#texttracklist">TextTrackList</a></code> object whose <code id="text-track-api:dom-texttrack-id"><a href="#dom-texttrack-id">id</a></code> IDL attribute would return a value equal to the value of the
  <var>id</var> argument. When no tracks match the given argument, the method must return null.</p>
  </div>

  

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack" title="The TextTrack interface—part of the API for handling WebVTT (text tracks on media presentations)—describes and controls the text track associated with a particular <track> element.">TextTrack</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>31+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><pre><code class="idl"><c- b="">enum</c-> <dfn id="texttrackmode" data-dfn-type="enum"><c- g="">TextTrackMode</c-></dfn> { <c- s="">"</c-><a href="#dom-texttrack-disabled" id="text-track-api:dom-texttrack-disabled"><c- s="">disabled</c-></a><c- s="">"</c->,  <c- s="">"</c-><a href="#dom-texttrack-hidden" id="text-track-api:dom-texttrack-hidden"><c- s="">hidden</c-></a><c- s="">"</c->,  <c- s="">"</c-><a href="#dom-texttrack-showing" id="text-track-api:dom-texttrack-showing"><c- s="">showing</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="texttrackkind" data-dfn-type="enum"><c- g="">TextTrackKind</c-></dfn> { <c- s="">"</c-><a href="#dom-texttrack-kind-subtitles" id="text-track-api:dom-texttrack-kind-subtitles"><c- s="">subtitles</c-></a><c- s="">"</c->,  <c- s="">"</c-><a href="#dom-texttrack-kind-captions" id="text-track-api:dom-texttrack-kind-captions"><c- s="">captions</c-></a><c- s="">"</c->,  <c- s="">"</c-><a href="#dom-texttrack-kind-descriptions" id="text-track-api:dom-texttrack-kind-descriptions"><c- s="">descriptions</c-></a><c- s="">"</c->,  <c- s="">"</c-><a href="#dom-texttrack-kind-chapters" id="text-track-api:dom-texttrack-kind-chapters"><c- s="">chapters</c-></a><c- s="">"</c->,  <c- s="">"</c-><a href="#dom-texttrack-kind-metadata" id="text-track-api:dom-texttrack-kind-metadata"><c- s="">metadata</c-></a><c- s="">"</c-> };

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="texttrack" data-dfn-type="interface"><c- g="">TextTrack</c-></dfn> : <a id="text-track-api:eventtarget-2" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#texttrackkind" id="text-track-api:texttrackkind"><c- n="">TextTrackKind</c-></a> <a href="#dom-texttrack-kind" id="text-track-api:dom-texttrack-kind"><c- g="">kind</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-texttrack-label" id="text-track-api:dom-texttrack-label"><c- g="">label</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-texttrack-language" id="text-track-api:dom-texttrack-language"><c- g="">language</c-></a>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-texttrack-id" id="text-track-api:dom-texttrack-id-2"><c- g="">id</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-texttrack-inbandmetadatatrackdispatchtype" id="text-track-api:dom-texttrack-inbandmetadatatrackdispatchtype"><c- g="">inBandMetadataTrackDispatchType</c-></a>;

  <c- b="">attribute</c-> <a href="#texttrackmode" id="text-track-api:texttrackmode"><c- n="">TextTrackMode</c-></a> <a href="#dom-texttrack-mode" id="text-track-api:dom-texttrack-mode"><c- g="">mode</c-></a>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#texttrackcuelist" id="text-track-api:texttrackcuelist"><c- n="">TextTrackCueList</c-></a>? <a href="#dom-texttrack-cues" id="text-track-api:dom-texttrack-cues"><c- g="">cues</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#texttrackcuelist" id="text-track-api:texttrackcuelist-2"><c- n="">TextTrackCueList</c-></a>? <a href="#dom-texttrack-activecues" id="text-track-api:dom-texttrack-activecues"><c- g="">activeCues</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-texttrack-addcue" id="text-track-api:dom-texttrack-addcue"><c- g="">addCue</c-></a>(<a href="#texttrackcue" id="text-track-api:texttrackcue"><c- n="">TextTrackCue</c-></a> <c- g="">cue</c->);
  <c- b="">undefined</c-> <a href="#dom-texttrack-removecue" id="text-track-api:dom-texttrack-removecue"><c- g="">removeCue</c-></a>(<a href="#texttrackcue" id="text-track-api:texttrackcue-2"><c- n="">TextTrackCue</c-></a> <c- g="">cue</c->);

  <c- b="">attribute</c-> <a href="#eventhandler" id="text-track-api:eventhandler-4"><c- n="">EventHandler</c-></a> <a href="#handler-texttrack-oncuechange" id="text-track-api:handler-texttrack-oncuechange"><c- g="">oncuechange</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>textTrack</var> = <var>media</var>.<a href="#dom-media-addtexttrack" id="dom-media-addtexttrack-dev">addTextTrack</a>(<var>kind</var> [, <var>label</var> [, <var>language</var> ] ])</code></dt><dd>
    <p>Creates and returns a new <code id="text-track-api:texttrack-7"><a href="#texttrack">TextTrack</a></code> object, which is also added to the
    <a href="#media-element" id="text-track-api:media-element-6">media element</a>'s <a href="#list-of-text-tracks" id="text-track-api:list-of-text-tracks-5">list of text tracks</a>.</p>
   </dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-kind" id="dom-texttrack-kind-dev">kind</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/kind" title="The kind read-only property of the TextTrack interface returns the kind of text track this object represents. This decides how the track will be handled by a user agent.">TextTrack/kind</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the <a href="#text-track-kind" id="text-track-api:text-track-kind">text track kind</a> string.</p></dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-label" id="dom-texttrack-label-dev">label</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/label" title="The label read-only property of the TextTrack interface returns a human-readable label for the text track, if it is available.">TextTrack/label</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="#text-track-label" id="text-track-api:text-track-label">text track label</a>, if there is one, or the empty string otherwise
    (indicating that a custom label probably needs to be generated from the other attributes of the
    object if the object is exposed to the user).</p>
   </dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-language" id="dom-texttrack-language-dev">language</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/language" title="The language read-only property of the TextTrack interface returns the language of the text track.">TextTrack/language</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the <a href="#text-track-language" id="text-track-api:text-track-language">text track language</a> string.</p></dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-id" id="dom-texttrack-id-dev">id</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/id" title="The id read-only property of the TextTrack interface returns the ID of the track if it has one.">TextTrack/id</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>33+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the ID of the given track.</p>

    <p>For in-band tracks, this is the ID that can be used with a <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="text-track-api:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> if the format supports <a id="text-track-api:media-fragment-syntax" href="https://www.w3.org/TR/media-frags/#media-fragment-syntax" data-x-internal="media-fragment-syntax">media fragment
    syntax</a>, and that can be used with the <code id="text-track-api:dom-texttracklist-gettrackbyid-2"><a href="#dom-texttracklist-gettrackbyid">getTrackById()</a></code> method.</p>

    <p>For <code id="text-track-api:texttrack-8"><a href="#texttrack">TextTrack</a></code> objects corresponding to <code id="text-track-api:the-track-element-2"><a href="#the-track-element">track</a></code> elements, this is the
    ID of the <code id="text-track-api:the-track-element-3"><a href="#the-track-element">track</a></code> element.</p>
   </dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-inbandmetadatatrackdispatchtype" id="dom-texttrack-inbandmetadatatrackdispatchtype-dev">inBandMetadataTrackDispatchType</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/inBandMetadataTrackDispatchType" title="The inBandMetadataTrackDispatchType read-only property of the TextTrack interface returns the text track's in-band metadata dispatch type of the text track represented by the TextTrack object.">TextTrack/inBandMetadataTrackDispatchType</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the <a href="#text-track-in-band-metadata-track-dispatch-type" id="text-track-api:text-track-in-band-metadata-track-dispatch-type">text track in-band metadata track dispatch type</a> string.</p></dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-mode" id="dom-texttrack-mode-dev">mode</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/mode" title="The TextTrack interface's mode property is a string specifying and controlling the text track's mode: disabled, hidden, or showing. You can read this value to determine the current mode, and you can change this value to switch modes.">TextTrack/mode</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>31+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="#text-track-mode" id="text-track-api:text-track-mode">text track mode</a>, represented by a string from the following
    list:</p>

    <dl><dt>"<code id="text-track-api:dom-texttrack-disabled-2"><a href="#dom-texttrack-disabled">disabled</a></code>"</dt><dd><p>The <a href="#text-track-disabled" id="text-track-api:text-track-disabled">text track disabled</a> mode.</p></dd><dt>"<code id="text-track-api:dom-texttrack-hidden-2"><a href="#dom-texttrack-hidden">hidden</a></code>"</dt><dd><p>The <a href="#text-track-hidden" id="text-track-api:text-track-hidden">text track hidden</a> mode.</p></dd><dt>"<code id="text-track-api:dom-texttrack-showing-2"><a href="#dom-texttrack-showing">showing</a></code>"</dt><dd><p>The <a href="#text-track-showing" id="text-track-api:text-track-showing">text track showing</a> mode.</p></dd></dl>

    <p>Can be set, to change the mode.</p>
   </dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-cues" id="dom-texttrack-cues-dev">cues</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/cues" title="The cues read-only property of the TextTrack interface returns a TextTrackCueList object containing all of the track's cues.">TextTrack/cues</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>31+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues">text track list of cues</a>, as a <code id="text-track-api:texttrackcuelist-3"><a href="#texttrackcuelist">TextTrackCueList</a></code>
    object.</p>
   </dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-activecues" id="dom-texttrack-activecues-dev">activeCues</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/activeCues" title="The activeCues read-only property of the TextTrack interface returns a TextTrackCueList object listing the currently active cues.">TextTrack/activeCues</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>31+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="#text-track-cue" id="text-track-api:text-track-cue">text track cues</a> from the <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-2">text track
    list of cues</a> that are currently active (i.e. that start before the <a href="#current-playback-position" id="text-track-api:current-playback-position">current playback
    position</a> and end after it), as a <code id="text-track-api:texttrackcuelist-4"><a href="#texttrackcuelist">TextTrackCueList</a></code> object.</p>
   </dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-addcue" id="dom-texttrack-addcue-dev">addCue</a>(<var>cue</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/addCue" title="The addCue() method of the TextTrack interface adds a new cue to the list of cues.">TextTrack/addCue</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Adds the given cue to <var>textTrack</var>'s <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-3">text track list of
   cues</a>.</p></dd><dt><code><var>textTrack</var>.<a href="#dom-texttrack-removecue" id="dom-texttrack-removecue-dev">removeCue</a>(<var>cue</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/removeCue" title="The removeCue() method of the TextTrack interface removes a cue from the list of cues.">TextTrack/removeCue</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Removes the given cue from <var>textTrack</var>'s <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-4">text track list of
   cues</a>.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-addtexttrack" data-dfn-type="method"><code>addTextTrack(<var>kind</var>, <var>label</var>,
  <var>language</var>)</code></dfn> method of <a href="#media-element" id="text-track-api:media-element-7">media elements</a>,
  when invoked, must run the following steps:</p>

  <ol><li>
    <p>Create a new <code id="text-track-api:texttrack-9"><a href="#texttrack">TextTrack</a></code> object.</p>
   </li><li>
    <p>Create a new <a href="#text-track" id="text-track-api:text-track-10">text track</a> corresponding to the new object, and set its <a href="#text-track-kind" id="text-track-api:text-track-kind-2">text
    track kind</a> to <var>kind</var>, its <a href="#text-track-label" id="text-track-api:text-track-label-2">text track label</a> to <var>label</var>, its <a href="#text-track-language" id="text-track-api:text-track-language-2">text track language</a> to <var>language</var>, its
    <a href="#text-track-readiness-state" id="text-track-api:text-track-readiness-state">text track readiness state</a> to the <a href="#text-track-loaded" id="text-track-api:text-track-loaded">text track loaded</a> state, its
    <a href="#text-track-mode" id="text-track-api:text-track-mode-2">text track mode</a> to the <a href="#text-track-hidden" id="text-track-api:text-track-hidden-2">text track hidden</a> mode, and its <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-5">text
    track list of cues</a> to an empty list.</p>

    <p>Initially, the <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-6">text track list of cues</a> is not associated with any <a href="#rules-for-updating-the-text-track-rendering" id="text-track-api:rules-for-updating-the-text-track-rendering">rules
    for updating the text track rendering</a>. When a <a href="#text-track-cue" id="text-track-api:text-track-cue-2">text track cue</a> is added to it,
    the <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-7">text track list of cues</a> has its rules permanently set accordingly.</p>
   </li><li>
    <p>Add the new <a href="#text-track" id="text-track-api:text-track-11">text track</a> to the <a href="#media-element" id="text-track-api:media-element-8">media element</a>'s <a href="#list-of-text-tracks" id="text-track-api:list-of-text-tracks-6">list of text
    tracks</a>.</p>
   </li><li>
    <p><a href="#queue-a-media-element-task" id="text-track-api:queue-a-media-element-task">Queue a media element task</a> given the <a href="#media-element" id="text-track-api:media-element-9">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="text-track-api:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="text-track-api:event-media-addtrack"><a href="#event-media-addtrack">addtrack</a></code> at the <a href="#media-element" id="text-track-api:media-element-10">media element</a>'s <code id="text-track-api:dom-media-texttracks-3"><a href="#dom-media-texttracks">textTracks</a></code> attribute's <code id="text-track-api:texttracklist-10"><a href="#texttracklist">TextTrackList</a></code> object,
    using <code id="text-track-api:trackevent"><a href="#trackevent">TrackEvent</a></code>, with the <code id="text-track-api:dom-trackevent-track"><a href="#dom-trackevent-track">track</a></code>
    attribute initialized to the new <a href="#text-track" id="text-track-api:text-track-12">text track</a>'s <code id="text-track-api:texttrack-10"><a href="#texttrack">TextTrack</a></code> object.</p>
   </li><li>
    <p>Return the new <code id="text-track-api:texttrack-11"><a href="#texttrack">TextTrack</a></code> object.</p>
   </li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrack" id="dom-texttrack-kind" data-dfn-type="attribute"><code>kind</code></dfn>
  attribute must return the <a href="#text-track-kind" id="text-track-api:text-track-kind-3">text track kind</a> of the <a href="#text-track" id="text-track-api:text-track-13">text track</a> that the
  <code id="text-track-api:texttrack-12"><a href="#texttrack">TextTrack</a></code> object represents.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrack" id="dom-texttrack-label" data-dfn-type="attribute"><code>label</code></dfn>
  attribute must return the <a href="#text-track-label" id="text-track-api:text-track-label-3">text track label</a> of the <a href="#text-track" id="text-track-api:text-track-14">text track</a> that the
  <code id="text-track-api:texttrack-13"><a href="#texttrack">TextTrack</a></code> object represents.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrack" id="dom-texttrack-language" data-dfn-type="attribute"><code>language</code></dfn>
  attribute must return the <a href="#text-track-language" id="text-track-api:text-track-language-3">text track language</a> of the <a href="#text-track" id="text-track-api:text-track-15">text track</a> that the
  <code id="text-track-api:texttrack-14"><a href="#texttrack">TextTrack</a></code> object represents.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrack" id="dom-texttrack-id" data-dfn-type="attribute"><code>id</code></dfn> attribute
  returns the track's identifier, if it has one, or the empty string otherwise. For tracks that
  correspond to <code id="text-track-api:the-track-element-4"><a href="#the-track-element">track</a></code> elements, the track's identifier is the value of the element's
  <code id="text-track-api:the-id-attribute"><a href="#the-id-attribute">id</a></code> attribute, if any. For in-band tracks, the track's identifier is
  specified by the <a href="#media-resource" id="text-track-api:media-resource">media resource</a>. If the <a href="#media-resource" id="text-track-api:media-resource-2">media resource</a> is in a format
  that supports <a id="text-track-api:media-fragment-syntax-2" href="https://www.w3.org/TR/media-frags/#media-fragment-syntax" data-x-internal="media-fragment-syntax">media fragment syntax</a>, the identifier returned for a particular track
  must be the same identifier that would enable the track if used as the name of a track in the
  track dimension of such a <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="text-track-api:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrack" id="dom-texttrack-inbandmetadatatrackdispatchtype" data-dfn-type="attribute"><code>inBandMetadataTrackDispatchType</code></dfn>
  attribute must return the <a href="#text-track-in-band-metadata-track-dispatch-type" id="text-track-api:text-track-in-band-metadata-track-dispatch-type-2">text track in-band metadata track dispatch type</a> of the
  <a href="#text-track" id="text-track-api:text-track-16">text track</a> that the <code id="text-track-api:texttrack-15"><a href="#texttrack">TextTrack</a></code> object represents.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrack" id="dom-texttrack-mode" data-dfn-type="attribute"><code>mode</code></dfn>
  attribute, on getting, must return the string corresponding to the <a href="#text-track-mode" id="text-track-api:text-track-mode-3">text track mode</a> of
  the <a href="#text-track" id="text-track-api:text-track-17">text track</a> that the <code id="text-track-api:texttrack-16"><a href="#texttrack">TextTrack</a></code> object represents, as defined by the
  following list:</p>

  <dl><dt>"<dfn data-dfn-for="TextTrackMode" id="dom-texttrack-disabled" data-dfn-type="enum-value"><code>disabled</code></dfn>"</dt><dd>The <a href="#text-track-disabled" id="text-track-api:text-track-disabled-2">text track disabled</a> mode.</dd><dt>"<dfn data-dfn-for="TextTrackMode" id="dom-texttrack-hidden" data-dfn-type="enum-value"><code>hidden</code></dfn>"</dt><dd>The <a href="#text-track-hidden" id="text-track-api:text-track-hidden-3">text track hidden</a> mode.</dd><dt>"<dfn data-dfn-for="TextTrackMode" id="dom-texttrack-showing" data-dfn-type="enum-value"><code>showing</code></dfn>"</dt><dd>The <a href="#text-track-showing" id="text-track-api:text-track-showing-2">text track showing</a> mode.</dd></dl>
  </div>

  <div data-algorithm="">
  <p>On setting, if the new value isn't equal to what the attribute would currently return, the new
  value must be processed as follows:</p>

  <dl class="switch"><dt>If the new value is "<code id="text-track-api:dom-texttrack-disabled-3"><a href="#dom-texttrack-disabled">disabled</a></code>"</dt><dd>
    <p>Set the <a href="#text-track-mode" id="text-track-api:text-track-mode-4">text track mode</a> of the <a href="#text-track" id="text-track-api:text-track-18">text track</a> that the
    <code id="text-track-api:texttrack-17"><a href="#texttrack">TextTrack</a></code> object represents to the <a href="#text-track-disabled" id="text-track-api:text-track-disabled-3">text track disabled</a> mode.</p>
   </dd><dt>If the new value is "<code id="text-track-api:dom-texttrack-hidden-3"><a href="#dom-texttrack-hidden">hidden</a></code>"</dt><dd>
    <p>Set the <a href="#text-track-mode" id="text-track-api:text-track-mode-5">text track mode</a> of the <a href="#text-track" id="text-track-api:text-track-19">text track</a> that the
    <code id="text-track-api:texttrack-18"><a href="#texttrack">TextTrack</a></code> object represents to the <a href="#text-track-hidden" id="text-track-api:text-track-hidden-4">text track hidden</a> mode.</p>
   </dd><dt>If the new value is "<code id="text-track-api:dom-texttrack-showing-3"><a href="#dom-texttrack-showing">showing</a></code>"</dt><dd>
    <p>Set the <a href="#text-track-mode" id="text-track-api:text-track-mode-6">text track mode</a> of the <a href="#text-track" id="text-track-api:text-track-20">text track</a> that the
    <code id="text-track-api:texttrack-19"><a href="#texttrack">TextTrack</a></code> object represents to the <a href="#text-track-showing" id="text-track-api:text-track-showing-3">text track showing</a> mode.</p>
   </dd></dl>
  </div>

  <div data-algorithm="">
  <p>If the <a href="#text-track-mode" id="text-track-api:text-track-mode-7">text track mode</a> of the <a href="#text-track" id="text-track-api:text-track-21">text track</a> that the
  <code id="text-track-api:texttrack-20"><a href="#texttrack">TextTrack</a></code> object represents is not the <a href="#text-track-disabled" id="text-track-api:text-track-disabled-4">text track disabled</a> mode, then
  the <dfn data-dfn-for="TextTrack" id="dom-texttrack-cues" data-dfn-type="attribute"><code>cues</code></dfn> attribute
  must return a <a href="#live" id="text-track-api:live">live</a> <code id="text-track-api:texttrackcuelist-5"><a href="#texttrackcuelist">TextTrackCueList</a></code> object that represents the subset of
  the <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-8">text track list of cues</a> of the <a href="#text-track" id="text-track-api:text-track-22">text track</a> that the
  <code id="text-track-api:texttrack-21"><a href="#texttrack">TextTrack</a></code> object represents whose <a href="#text-track-cue-end-time" id="text-track-api:text-track-cue-end-time">end
  times</a> occur at or after the <a href="#earliest-possible-position-when-the-script-started" id="text-track-api:earliest-possible-position-when-the-script-started">earliest possible position when the script
  started</a>, in <a href="#text-track-cue-order" id="text-track-api:text-track-cue-order">text track cue order</a>. Otherwise, it must return null. For each
  <code id="text-track-api:texttrack-22"><a href="#texttrack">TextTrack</a></code> object, when an object is returned, the same <code id="text-track-api:texttrackcuelist-6"><a href="#texttrackcuelist">TextTrackCueList</a></code>
  object must be returned each time.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="earliest-possible-position-when-the-script-started">earliest possible position when the script started</dfn> is whatever the
  <a href="#earliest-possible-position" id="text-track-api:earliest-possible-position">earliest possible position</a> was the last time the <a href="#event-loop" id="text-track-api:event-loop">event loop</a> reached step
  1.</p>
  </div>

  <div data-algorithm="">
  <p>If the <a href="#text-track-mode" id="text-track-api:text-track-mode-8">text track mode</a> of the <a href="#text-track" id="text-track-api:text-track-23">text track</a> that the
  <code id="text-track-api:texttrack-23"><a href="#texttrack">TextTrack</a></code> object represents is not the <a href="#text-track-disabled" id="text-track-api:text-track-disabled-5">text track disabled</a> mode, then
  the <dfn data-dfn-for="TextTrack" id="dom-texttrack-activecues" data-dfn-type="attribute"><code>activeCues</code></dfn>
  attribute must return a <a href="#live" id="text-track-api:live-2">live</a> <code id="text-track-api:texttrackcuelist-7"><a href="#texttrackcuelist">TextTrackCueList</a></code> object that represents the
  subset of the <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-9">text track list of cues</a> of the <a href="#text-track" id="text-track-api:text-track-24">text track</a> that the
  <code id="text-track-api:texttrack-24"><a href="#texttrack">TextTrack</a></code> object represents whose <a href="#active-flag-was-set-when-the-script-started" id="text-track-api:active-flag-was-set-when-the-script-started">active flag was set when the script
  started</a>, in <a href="#text-track-cue-order" id="text-track-api:text-track-cue-order-2">text track cue order</a>. Otherwise, it must return null. For each
  <code id="text-track-api:texttrack-25"><a href="#texttrack">TextTrack</a></code> object, when an object is returned, the same <code id="text-track-api:texttrackcuelist-8"><a href="#texttrackcuelist">TextTrackCueList</a></code>
  object must be returned each time.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#text-track-cue" id="text-track-api:text-track-cue-3">text track cue</a>'s <dfn id="active-flag-was-set-when-the-script-started">active flag was set when the script started</dfn> if its
  <a href="#text-track-cue-active-flag" id="text-track-api:text-track-cue-active-flag">text track cue active flag</a> was set the last time the <a href="#event-loop" id="text-track-api:event-loop-2">event loop</a> reached
  <a href="#step1">step 1</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrack" id="dom-texttrack-addcue" data-dfn-type="method"><code>addCue(<var>cue</var>)</code></dfn> method of <code id="text-track-api:texttrack-26"><a href="#texttrack">TextTrack</a></code>
  objects, when invoked, must run the following steps:</p>

  <ol><li><p>If the <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-10">text track list of cues</a> does not yet have any associated <a href="#rules-for-updating-the-text-track-rendering" id="text-track-api:rules-for-updating-the-text-track-rendering-2">rules
   for updating the text track rendering</a>, then associate the <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-11">text track list of
   cues</a> with the <a href="#rules-for-updating-the-text-track-rendering" id="text-track-api:rules-for-updating-the-text-track-rendering-3">rules for updating the text track rendering</a> appropriate to <var>cue</var>.</p>

   </li><li><p>If <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-12">text track list of cues</a>' associated <a href="#rules-for-updating-the-text-track-rendering" id="text-track-api:rules-for-updating-the-text-track-rendering-4">rules for updating the text
   track rendering</a> are not the same <a href="#rules-for-updating-the-text-track-rendering" id="text-track-api:rules-for-updating-the-text-track-rendering-5">rules for updating the text track rendering</a>
   as appropriate for <var>cue</var>, then throw an <a id="text-track-api:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="text-track-api:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

   </li><li><p>If the given <var>cue</var> is in a <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-13">text track list of cues</a>, then
   remove <var>cue</var> from that <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-14">text track list of cues</a>.</p></li><li><p>Add <var>cue</var> to the <code id="text-track-api:texttrack-27"><a href="#texttrack">TextTrack</a></code> object's <a href="#text-track" id="text-track-api:text-track-25">text track</a>'s
   <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-15">text track list of cues</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrack" id="dom-texttrack-removecue" data-dfn-type="method"><code>removeCue(<var>cue</var>)</code></dfn> method of
  <code id="text-track-api:texttrack-28"><a href="#texttrack">TextTrack</a></code> objects, when invoked, must run the following steps:</p>

  <ol><li><p>If the given <var>cue</var> is not in the <code id="text-track-api:texttrack-29"><a href="#texttrack">TextTrack</a></code> object's <a href="#text-track" id="text-track-api:text-track-26">text
   track</a>'s <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-16">text track list of cues</a>, then throw a
   <a id="text-track-api:notfounderror" href="https://webidl.spec.whatwg.org/#notfounderror" data-x-internal="notfounderror">"<code>NotFoundError</code>"</a> <code id="text-track-api:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Remove <var>cue</var> from the <code id="text-track-api:texttrack-30"><a href="#texttrack">TextTrack</a></code> object's <a href="#text-track" id="text-track-api:text-track-27">text track</a>'s
   <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-17">text track list of cues</a>.</p></li></ol>
  </div>

  

  <div class="example">

   <p>In this example, an <code id="text-track-api:the-audio-element"><a href="#the-audio-element">audio</a></code> element is used to play a specific sound-effect from a
   sound file containing many sound effects. A cue is used to pause the audio, so that it ends
   exactly at the end of the clip, even if the browser is busy running some script. If the page had
   relied on script to pause the audio, then the start of the next clip might be heard if the
   browser was not able to run the script at the exact time specified.</p>

   <pre><code class="js"><c- a="">var</c-> sfx <c- o="">=</c-> <c- k="">new</c-> Audio<c- p="">(</c-><c- t="">'sfx.wav'</c-><c- p="">);</c->
<c- a="">var</c-> sounds <c- o="">=</c-> sfx<c- p="">.</c->addTextTrack<c- p="">(</c-><c- t="">'metadata'</c-><c- p="">);</c->

<c- c1="">// add sounds we care about</c->
<c- a="">function</c-> addFX<c- p="">(</c->start<c- p="">,</c-> end<c- p="">,</c-> name<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> cue <c- o="">=</c-> <c- k="">new</c-> VTTCue<c- p="">(</c->start<c- p="">,</c-> end<c- p="">,</c-> <c- t="">''</c-><c- p="">);</c->
  cue<c- p="">.</c->id <c- o="">=</c-> name<c- p="">;</c->
  cue<c- p="">.</c->pauseOnExit <c- o="">=</c-> <c- kc="">true</c-><c- p="">;</c->
  sounds<c- p="">.</c->addCue<c- p="">(</c->cue<c- p="">);</c->
<c- p="">}</c->
addFX<c- p="">(</c-><c- mf="">12.783</c-><c- p="">,</c-> <c- mf="">13.612</c-><c- p="">,</c-> <c- t="">'dog bark'</c-><c- p="">);</c->
addFX<c- p="">(</c-><c- mf="">13.612</c-><c- p="">,</c-> <c- mf="">15.091</c-><c- p="">,</c-> <c- t="">'kitten mew'</c-><c- p="">);</c->

<c- a="">function</c-> playSound<c- p="">(</c->id<c- p="">)</c-> <c- p="">{</c->
  sfx<c- p="">.</c->currentTime <c- o="">=</c-> sounds<c- p="">.</c->getCueById<c- p="">(</c->id<c- p="">).</c->startTime<c- p="">;</c->
  sfx<c- p="">.</c->play<c- p="">();</c->
<c- p="">}</c->

<c- c1="">// play a bark as soon as we can</c->
sfx<c- p="">.</c->oncanplaythrough <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
  playSound<c- p="">(</c-><c- t="">'dog bark'</c-><c- p="">);</c->
<c- p="">}</c->
<c- c1="">// meow when the user tries to leave,</c->
<c- c1="">// and have the browser ask them to stay</c->
window<c- p="">.</c->onbeforeunload <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  playSound<c- p="">(</c-><c- t="">'kitten mew'</c-><c- p="">);</c->
  e<c- p="">.</c->preventDefault<c- p="">();</c->
<c- p="">}</c-></code></pre>

  </div>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCueList" title="The TextTrackCueList array-like object represents a dynamically updating list of TextTrackCue objects.">TextTrackCueList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="texttrackcuelist" data-dfn-type="interface"><c- g="">TextTrackCueList</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-texttrackcuelist-length" id="text-track-api:dom-texttrackcuelist-length"><c- g="">length</c-></a>;
  <a href="#dom-texttrackcuelist-item"><c- b="">getter</c-></a> <a href="#texttrackcue" id="text-track-api:texttrackcue-3"><c- n="">TextTrackCue</c-></a> (<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <a href="#texttrackcue" id="text-track-api:texttrackcue-4"><c- n="">TextTrackCue</c-></a>? <a href="#dom-texttrackcuelist-getcuebyid" id="text-track-api:dom-texttrackcuelist-getcuebyid"><c- g="">getCueById</c-></a>(<c- b="">DOMString</c-> <c- g="">id</c->);
};</code></pre>

  <dl class="domintro"><dt><code><var>cuelist</var>.<a href="#dom-texttrackcuelist-length" id="dom-texttrackcuelist-length-dev">length</a></code></dt><dd><p>Returns the number of <a href="#text-track-cue" id="text-track-api:text-track-cue-4">cues</a> in the list.</p></dd><dt><code><var>cuelist</var>[<var>index</var>]</code></dt><dd>
    <p>Returns the <a href="#text-track-cue" id="text-track-api:text-track-cue-5">text track cue</a> with index <var>index</var> in the list. The cues are
    sorted in <a href="#text-track-cue-order" id="text-track-api:text-track-cue-order-3">text track cue order</a>.</p>
   </dd><dt><code><var>cuelist</var>.<a href="#dom-texttrackcuelist-getcuebyid" id="dom-texttrackcuelist-getcuebyid-dev">getCueById</a>(<var>id</var>)</code></dt><dd>
    <p>Returns the first <a href="#text-track-cue" id="text-track-api:text-track-cue-6">text track cue</a> (in <a href="#text-track-cue-order" id="text-track-api:text-track-cue-order-4">text track cue order</a>) with
    <a href="#text-track-cue-identifier" id="text-track-api:text-track-cue-identifier">text track cue identifier</a> <var>id</var>.</p>

    <p>Returns null if none of the cues have the given identifier or if the argument is the empty
    string.</p>
   </dd></dl>

  

  <p>A <code id="text-track-api:texttrackcuelist-9"><a href="#texttrackcuelist">TextTrackCueList</a></code> object represents a dynamically updating list of <a href="#text-track-cue" id="text-track-api:text-track-cue-7">text track cues</a> in a given order.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCueList/length" title="The length read-only property of the TextTrackCueList interface returns the number of cues in the list.">TextTrackCueList/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrackCueList" id="dom-texttrackcuelist-length" data-dfn-type="attribute"><code>length</code></dfn> attribute must return the number of <a href="#text-track-cue" id="text-track-api:text-track-cue-8">cues</a> in the list represented by the <code id="text-track-api:texttrackcuelist-10"><a href="#texttrackcuelist">TextTrackCueList</a></code>
  object.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="text-track-api:supported-property-indices-3" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> of a <code id="text-track-api:texttrackcuelist-11"><a href="#texttrackcuelist">TextTrackCueList</a></code> object at any
  instant are the numbers from zero to the number of <a href="#text-track-cue" id="text-track-api:text-track-cue-9">cues</a> in the
  list represented by the <code id="text-track-api:texttrackcuelist-12"><a href="#texttrackcuelist">TextTrackCueList</a></code> object minus one, if any. If there are no
  <a href="#text-track-cue" id="text-track-api:text-track-cue-10">cues</a> in the list, there are no <a id="text-track-api:supported-property-indices-4" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property
  indices</a>.</p>
  </div>

  <div data-algorithm="">
  <p id="dom-texttrackcuelist-item">To <a id="text-track-api:determine-the-value-of-an-indexed-property-2" href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-an-indexed-property" data-x-internal="determine-the-value-of-an-indexed-property">determine the value of an indexed property</a> for a
  given index <var>index</var>, the user agent must return the <var>index</var>th <a href="#text-track-cue" id="text-track-api:text-track-cue-11">text track
  cue</a> in the list represented by the <code id="text-track-api:texttrackcuelist-13"><a href="#texttrackcuelist">TextTrackCueList</a></code> object.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCueList/getCueById" title="The getCueById() method of the TextTrackCueList interface returns the first VTTCue in the list represented by the TextTrackCueList object whose identifier matches the value of id.">TextTrackCueList/getCueById</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrackCueList" id="dom-texttrackcuelist-getcuebyid" data-dfn-type="method"><code>getCueById(<var>id</var>)</code></dfn> method, when
  called with an argument other than the empty string, must return the first <a href="#text-track-cue" id="text-track-api:text-track-cue-12">text track
  cue</a> in the list represented by the <code id="text-track-api:texttrackcuelist-14"><a href="#texttrackcuelist">TextTrackCueList</a></code> object whose <a href="#text-track-cue-identifier" id="text-track-api:text-track-cue-identifier-2">text
  track cue identifier</a> is <var>id</var>, if any, or null otherwise. If the argument is the
  empty string, then the method must return null.</p>
  </div>

  

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue" title="TextTrackCue is an abstract class which is used as the basis for the various derived cue types, such as VTTCue; you will instead work with those derived types. These cues represent strings of text presented for some duration of time during the performance of a TextTrack. The cue includes the start time (the time at which the text will be displayed) and the end time (the time at which it will be removed from the display), as well as other information.">TextTrackCue</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="texttrackcue" data-dfn-type="interface"><c- g="">TextTrackCue</c-></dfn> : <a id="text-track-api:eventtarget-3" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#texttrack" id="text-track-api:texttrack-31"><c- n="">TextTrack</c-></a>? <a href="#dom-texttrackcue-track" id="text-track-api:dom-texttrackcue-track"><c- g="">track</c-></a>;

  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-texttrackcue-id" id="text-track-api:dom-texttrackcue-id"><c- g="">id</c-></a>;
  <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-texttrackcue-starttime" id="text-track-api:dom-texttrackcue-starttime"><c- g="">startTime</c-></a>;
  <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-texttrackcue-endtime" id="text-track-api:dom-texttrackcue-endtime"><c- g="">endTime</c-></a>;
  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-texttrackcue-pauseonexit" id="text-track-api:dom-texttrackcue-pauseonexit"><c- g="">pauseOnExit</c-></a>;

  <c- b="">attribute</c-> <a href="#eventhandler" id="text-track-api:eventhandler-5"><c- n="">EventHandler</c-></a> <a href="#handler-texttrackcue-onenter" id="text-track-api:handler-texttrackcue-onenter"><c- g="">onenter</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="text-track-api:eventhandler-6"><c- n="">EventHandler</c-></a> <a href="#handler-texttrackcue-onexit" id="text-track-api:handler-texttrackcue-onexit"><c- g="">onexit</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>cue</var>.<a href="#dom-texttrackcue-track" id="dom-texttrackcue-track-dev">track</a></code></dt><dd>
    <p>Returns the <code id="text-track-api:texttrack-32"><a href="#texttrack">TextTrack</a></code> object to which this <a href="#text-track-cue" id="text-track-api:text-track-cue-13">text track cue</a> belongs,
    if any, or null otherwise.</p>
   </dd><dt><code><var>cue</var>.<a href="#dom-texttrackcue-id" id="dom-texttrackcue-id-dev">id</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the <a href="#text-track-cue-identifier" id="text-track-api:text-track-cue-identifier-3">text track cue identifier</a>.</p>

    <p>Can be set.</p>
   </dd><dt><code><var>cue</var>.<a href="#dom-texttrackcue-starttime" id="dom-texttrackcue-starttime-dev">startTime</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the <a href="#text-track-cue-start-time" id="text-track-api:text-track-cue-start-time">text track cue start time</a>, in seconds.</p>

    <p>Can be set.</p>
   </dd><dt><code><var>cue</var>.<a href="#dom-texttrackcue-endtime" id="dom-texttrackcue-endtime-dev">endTime</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the <a href="#text-track-cue-end-time" id="text-track-api:text-track-cue-end-time-2">text track cue end time</a>, in seconds.</p>

    <p>Returns positive Infinity for an <a href="#unbounded-text-track-cue" id="text-track-api:unbounded-text-track-cue">unbounded text track cue</a>.</p>

    <p>Can be set.</p>
   </dd><dt><code><var>cue</var>.<a href="#dom-texttrackcue-pauseonexit" id="dom-texttrackcue-pauseonexit-dev">pauseOnExit</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns true if the <a href="#text-track-cue-pause-on-exit-flag" id="text-track-api:text-track-cue-pause-on-exit-flag">text track cue pause-on-exit flag</a> is set, false
    otherwise.</p>

    <p>Can be set.</p>
   </dd></dl>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/track" title="The track read-only property of the TextTrackCue interface returns the TextTrack object that this cue belongs to.">TextTrackCue/track</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrackCue" id="dom-texttrackcue-track" data-dfn-type="attribute"><code>track</code></dfn>
  attribute, on getting, must return the <code id="text-track-api:texttrack-33"><a href="#texttrack">TextTrack</a></code> object of the <a href="#text-track" id="text-track-api:text-track-28">text
  track</a> in whose <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-18">list of cues</a> the <a href="#text-track-cue" id="text-track-api:text-track-cue-14">text
  track cue</a> that the <code id="text-track-api:texttrackcue-5"><a href="#texttrackcue">TextTrackCue</a></code> object represents finds itself, if any; or
  null otherwise.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/id" title="The id property of the TextTrackCue interface returns and sets the identifier for this cue.">TextTrackCue/id</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrackCue" id="dom-texttrackcue-id" data-dfn-type="attribute"><code>id</code></dfn>
  attribute, on getting, must return the <a href="#text-track-cue-identifier" id="text-track-api:text-track-cue-identifier-4">text track cue identifier</a> of the <a href="#text-track-cue" id="text-track-api:text-track-cue-15">text
  track cue</a> that the <code id="text-track-api:texttrackcue-6"><a href="#texttrackcue">TextTrackCue</a></code> object represents. On setting, the <a href="#text-track-cue-identifier" id="text-track-api:text-track-cue-identifier-5">text
  track cue identifier</a> must be set to the new value.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/startTime" title="The startTime property of the TextTrackCue interface returns and sets the start time of the cue.">TextTrackCue/startTime</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrackCue" id="dom-texttrackcue-starttime" data-dfn-type="attribute"><code>startTime</code></dfn> attribute, on getting, must return the
  <a href="#text-track-cue-start-time" id="text-track-api:text-track-cue-start-time-2">text track cue start time</a> of the <a href="#text-track-cue" id="text-track-api:text-track-cue-16">text track cue</a> that the
  <code id="text-track-api:texttrackcue-7"><a href="#texttrackcue">TextTrackCue</a></code> object represents, in seconds. On setting, the <a href="#text-track-cue-start-time" id="text-track-api:text-track-cue-start-time-3">text track cue
  start time</a> must be set to the new value, interpreted in seconds; then, if the
  <code id="text-track-api:texttrackcue-8"><a href="#texttrackcue">TextTrackCue</a></code> object's <a href="#text-track-cue" id="text-track-api:text-track-cue-17">text track cue</a> is in a <a href="#text-track" id="text-track-api:text-track-29">text track</a>'s
  <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-19">list of cues</a>, and that <a href="#text-track" id="text-track-api:text-track-30">text track</a> is in
  a <a href="#media-element" id="text-track-api:media-element-11">media element</a>'s <a href="#list-of-text-tracks" id="text-track-api:list-of-text-tracks-7">list of text tracks</a>, and the <a href="#media-element" id="text-track-api:media-element-12">media
  element</a>'s <a href="#show-poster-flag" id="text-track-api:show-poster-flag">show poster flag</a> is not set, then run the <i id="text-track-api:time-marches-on"><a href="#time-marches-on">time marches on</a></i> steps for that <a href="#media-element" id="text-track-api:media-element-13">media element</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/endTime" title="The endTime property of the TextTrackCue interface returns and sets the end time of the cue.">TextTrackCue/endTime</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrackCue" id="dom-texttrackcue-endtime" data-dfn-type="attribute"><code>endTime</code></dfn> attribute, on getting, must return the
  <a href="#text-track-cue-end-time" id="text-track-api:text-track-cue-end-time-3">text track cue end time</a> of the <a href="#text-track-cue" id="text-track-api:text-track-cue-18">text track cue</a> that the
  <code id="text-track-api:texttrackcue-9"><a href="#texttrackcue">TextTrackCue</a></code> object represents, in seconds or positive Infinity. On setting, if the
  new value is negative Infinity or a Not-a-Number (NaN) value, then throw a <a href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError
  </a> exception. Otherwise, the <a href="#text-track-cue-end-time" id="text-track-api:text-track-cue-end-time-4">text track cue end time</a> must be set to the new value.
  Then, if the <code id="text-track-api:texttrackcue-10"><a href="#texttrackcue">TextTrackCue</a></code> object's <a href="#text-track-cue" id="text-track-api:text-track-cue-19">text track cue</a> is in a <a href="#text-track" id="text-track-api:text-track-31">text
  track</a>'s <a href="#text-track-list-of-cues" id="text-track-api:text-track-list-of-cues-20">list of cues</a>, and that <a href="#text-track" id="text-track-api:text-track-32">text
  track</a> is in a <a href="#media-element" id="text-track-api:media-element-14">media element</a>'s <a href="#list-of-text-tracks" id="text-track-api:list-of-text-tracks-8">list of text tracks</a>, and the
  <a href="#media-element" id="text-track-api:media-element-15">media element</a>'s <a href="#show-poster-flag" id="text-track-api:show-poster-flag-2">show poster flag</a> is not set, then run the <i id="text-track-api:time-marches-on-2"><a href="#time-marches-on">time marches on</a></i> steps for that <a href="#media-element" id="text-track-api:media-element-16">media element</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/pauseOnExit" title="The pauseOnExit property of the TextTrackCue interface returns or sets the flag indicating whether playback of the media should pause when the end of the range to which this cue applies is reached.">TextTrackCue/pauseOnExit</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="TextTrackCue" id="dom-texttrackcue-pauseonexit" data-dfn-type="attribute"><code>pauseOnExit</code></dfn> attribute, on getting, must return
  true if the <a href="#text-track-cue-pause-on-exit-flag" id="text-track-api:text-track-cue-pause-on-exit-flag-2">text track cue pause-on-exit flag</a> of the <a href="#text-track-cue" id="text-track-api:text-track-cue-20">text track cue</a> that
  the <code id="text-track-api:texttrackcue-11"><a href="#texttrackcue">TextTrackCue</a></code> object represents is set; or false otherwise. On setting, the
  <a href="#text-track-cue-pause-on-exit-flag" id="text-track-api:text-track-cue-pause-on-exit-flag-3">text track cue pause-on-exit flag</a> must be set if the new value is true, and must be
  unset otherwise.</p>
  </div>


  <h6 id="cue-events"><span class="secno">4.8.11.11.6</span> Event handlers for objects of the text track APIs<a href="#cue-events" class="self-link"></a></h6>

  <p>The following are the <a href="#event-handlers" id="cue-events:event-handlers">event handlers</a> that (and their corresponding <a href="#event-handler-event-type" id="cue-events:event-handler-event-type">event handler event types</a>) that must
  be supported, as <a href="#event-handler-idl-attributes" id="cue-events:event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the
  <code id="cue-events:texttracklist"><a href="#texttracklist">TextTrackList</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="cue-events:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="cue-events:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="TextTrackList" id="handler-texttracklist-onchange" data-dfn-type="attribute"><code>onchange</code></dfn> </td><td> <code id="cue-events:event-media-change"><a href="#event-media-change">change</a></code>
    </td></tr><tr><td><dfn data-dfn-for="TextTrackList" id="handler-texttracklist-onaddtrack" data-dfn-type="attribute"><code>onaddtrack</code></dfn> </td><td> <code id="cue-events:event-media-addtrack"><a href="#event-media-addtrack">addtrack</a></code>
    </td></tr><tr><td><dfn data-dfn-for="TextTrackList" id="handler-texttracklist-onremovetrack" data-dfn-type="attribute"><code>onremovetrack</code></dfn> </td><td> <code id="cue-events:event-media-removetrack"><a href="#event-media-removetrack">removetrack</a></code>
  </td></tr></tbody></table>

  <p>The following are the <a href="#event-handlers" id="cue-events:event-handlers-3">event handlers</a> that (and their corresponding <a href="#event-handler-event-type" id="cue-events:event-handler-event-type-3">event handler event types</a>) that must
  be supported, as <a href="#event-handler-idl-attributes" id="cue-events:event-handler-idl-attributes-2">event handler IDL attributes</a>, by all objects implementing the
  <code id="cue-events:texttrack"><a href="#texttrack">TextTrack</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="cue-events:event-handlers-4">Event handler</a> </th><th><a href="#event-handler-event-type" id="cue-events:event-handler-event-type-4">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="TextTrack" id="handler-texttrack-oncuechange" data-dfn-type="attribute"><code>oncuechange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/cuechange_event" title="The cuechange event fires when a TextTrack has changed the currently displaying cues. The event is fired on both the TextTrack and the HTMLTrackElement in which it's being presented, if any.">TextTrack/cuechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="cue-events:event-media-cuechange"><a href="#event-media-cuechange">cuechange</a></code>
  </td></tr></tbody></table>

  <p>The following are the <a href="#event-handlers" id="cue-events:event-handlers-5">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="cue-events:event-handler-event-type-5">event handler event types</a>) that must
  be supported, as <a href="#event-handler-idl-attributes" id="cue-events:event-handler-idl-attributes-3">event handler IDL attributes</a>, by all objects implementing the
  <code id="cue-events:texttrackcue"><a href="#texttrackcue">TextTrackCue</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="cue-events:event-handlers-6">Event handler</a> </th><th><a href="#event-handler-event-type" id="cue-events:event-handler-event-type-6">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="TextTrackCue" id="handler-texttrackcue-onenter" data-dfn-type="attribute"><code>onenter</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/enter_event" title="The enter event fires when a cue becomes active. In the case of subtitles or a caption this is when it displays over the media.">TextTrackCue/enter_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="cue-events:event-media-enter"><a href="#event-media-enter">enter</a></code>
    </td></tr><tr><td><dfn data-dfn-for="TextTrackCue" id="handler-texttrackcue-onexit" data-dfn-type="attribute"><code>onexit</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/exit_event" title="The exit event fires when a cue stops being active.">TextTrackCue/exit_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="cue-events:event-media-exit"><a href="#event-media-exit">exit</a></code>
  </td></tr></tbody></table>

  



  <h6 id="best-practices-for-metadata-text-tracks"><span class="secno">4.8.11.11.7</span> Best practices for metadata text tracks<a href="#best-practices-for-metadata-text-tracks" class="self-link"></a></h6>

  <p><i>This section is non-normative.</i></p>

  <p>Text tracks can be used for storing data relating to the media data, for interactive or
  augmented views.</p>

  <p>For example, a page showing a sports broadcast could include information about the current
  score. Suppose a robotics competition was being streamed live. The image could be overlaid with
  the scores, as follows:</p>

  <p><iframe src="data:text/html;charset=utf-8,%3C!DOCTYPE%20html%3E%0A%3Cstyle%3E%0A%20body%2C%20html%20%7B%20margin%3A%200%3B%20padding%3A%200%3B%20overflow%3A%20hidden%3B%20%7D%0A%20div%20%7B%20width%3A%20600px%3B%20height%3A%20400px%3B%20position%3A%20relative%3B%20%7D%0A%20p%20%7B%20position%3A%20absolute%3B%20top%3A%200%3B%20margin%3A%200.25em%3B%20font%3A%20small-caps%20900%202em%20sans-serif%3B%20text-shadow%3A%20white%200%200%204px%3B%20%7D%0A%20span%20%7B%20display%3A%20block%3B%20%7D%0A%20.left%20%7B%20color%3A%20red%3B%20left%3A%200%3B%20text-align%3A%20left%3B%20%7D%0A%20.right%20%7B%20color%3A%20blue%3B%20right%3A%200%3B%20text-align%3A%20right%3B%20%7D%0A%20.middle%20%7B%20color%3A%20white%3B%20top%3A%20auto%3B%20bottom%3A%200%3B%20left%3A%200%3B%20right%3A%200%3B%20text-align%3A%20center%3B%20text-shadow%3A%20black%200%200%204px%3B%20%7D%0A%20.middle%20span%20%7B%20display%3A%20inline-block%3B%20margin%3A%200%201em%3B%20font-size%3A%200.75em%3B%20text-transform%3A%20uppercase%3B%20%7D%0A%3C%2Fstyle%3E%0A%3Cdiv%3E%0A%20%3Cimg%20src%3D%22https%3A%2F%2Fhtml.spec.whatwg.org%2Fimages%2Frobots.jpeg%22%3E%0A%20%3Cp%20class%3D%22score%20left%22%3E%3Cspan%3ERed%20Alliance%3C%2Fspan%3E%20%3Cspan%3E78%3C%2Fspan%3E%3C%2Fp%3E%0A%20%3Cp%20class%3D%22score%20right%22%3E%3Cspan%3EBlue%20Alliance%3C%2Fspan%3E%20%3Cspan%3E66%3C%2Fspan%3E%3C%2Fp%3E%0A%20%3Cp%20class%3D%22score%20middle%22%3E%3Cspan%3EQual%20Match%2037%3C%2Fspan%3E%20%3Cspan%3EFriday%2014%3A21%3C%2Fspan%3E%0A%3C%2Fdiv%3E" width="600" height="400"></iframe>

  </p><p>In order to make the score display render correctly whenever the user seeks to an arbitrary
  point in the video, the metadata text track cues need to be as long as is appropriate for the
  score. For example, in the frame above, there would be maybe one cue that lasts the length of the
  match that gives the match number, one cue that lasts until the blue alliance's score changes, and
  one cue that lasts until the red alliance's score changes. If the video is just a stream of the
  live event, the time in the bottom right would presumably be automatically derived from the
  current video time, rather than based on a cue. However, if the video was just the highlights,
  then that might be given in cues also.</p>

  <p>The following shows what fragments of this could look like in a WebVTT file:</p>

  <pre>WEBVTT

...

05:10:00.000 --&gt; 05:12:15.000
matchtype:qual
matchnumber:37

...

05:11:02.251 --&gt; 05:11:17.198
red:78

05:11:03.672 --&gt; 05:11:54.198
blue:66

05:11:17.198 --&gt; 05:11:25.912
red:80

05:11:25.912 --&gt; 05:11:26.522
red:83

05:11:26.522 --&gt; 05:11:26.982
red:86

05:11:26.982 --&gt; 05:11:27.499
red:89

...</pre>

  <p>The key here is to notice that the information is given in cues that span the length of time to
  which the relevant event applies. If, instead, the scores were given as zero-length (or very
  brief, nearly zero-length) cues when the score changes, for example saying "red+2" at
  05:11:17.198, "red+3" at 05:11:25.912, etc, problems arise: primarily, seeking is much harder to
  implement, as the script has to walk the entire list of cues to make sure that no notifications
  have been missed; but also, if the cues are short it's possible the script will never see that
  they are active unless it listens to them specifically.</p>

  <p>When using cues in this manner, authors are encouraged to use the <code id="best-practices-for-metadata-text-tracks:event-media-cuechange"><a href="#event-media-cuechange">cuechange</a></code> event to update the current annotations. (In
  particular, using the <code id="best-practices-for-metadata-text-tracks:event-media-timeupdate"><a href="#event-media-timeupdate">timeupdate</a></code> event would be less
  appropriate as it would require doing work even when the cues haven't changed, and, more
  importantly, would introduce a higher latency between when the metadata cues become active and
  when the display is updated, since <code id="best-practices-for-metadata-text-tracks:event-media-timeupdate-2"><a href="#event-media-timeupdate">timeupdate</a></code> events
  are rate-limited.)</p>



  <h5 id="identifying-a-track-kind-through-a-url"><span class="secno">4.8.11.12</span> Identifying a track kind through a URL<a href="#identifying-a-track-kind-through-a-url" class="self-link"></a></h5>

  <p>Other specifications or formats that need a <a id="identifying-a-track-kind-through-a-url:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> to identify the return values of
  the <code id="identifying-a-track-kind-through-a-url:audiotrack"><a href="#audiotrack">AudioTrack</a></code> <code id="identifying-a-track-kind-through-a-url:dom-audiotrack-kind"><a href="#dom-audiotrack-kind">kind</a></code> or
  <code id="identifying-a-track-kind-through-a-url:videotrack"><a href="#videotrack">VideoTrack</a></code> <code id="identifying-a-track-kind-through-a-url:dom-videotrack-kind"><a href="#dom-videotrack-kind">kind</a></code> IDL attributes, or identify
  the <a href="#text-track-kind" id="identifying-a-track-kind-through-a-url:text-track-kind">kind of text track</a>, must use the
  <code id="identifying-a-track-kind-through-a-url:about:html-kind"><a href="#about:html-kind">about:html-kind</a></code> <a id="identifying-a-track-kind-through-a-url:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p>



  <h5 id="user-interface"><span class="secno">4.8.11.13</span> User interface<a href="#user-interface" class="self-link"></a></h5>

  <p>The <dfn data-dfn-for="audio,video" id="attr-media-controls" data-dfn-type="element-attr"><code>controls</code></dfn> attribute is a <a href="#boolean-attribute" id="user-interface:boolean-attribute">boolean attribute</a>.
  If present, it indicates that the author has not provided a scripted controller and would like the
  user agent to provide its own set of controls.</p>

  

  <p>If the attribute is present, or if <a href="#concept-n-noscript" id="user-interface:concept-n-noscript">scripting is
  disabled</a> for the <a href="#media-element" id="user-interface:media-element">media element</a>, then the user agent should <dfn id="expose-a-user-interface-to-the-user">expose a user
  interface to the user</dfn>. This user interface should include features to begin playback, pause
  playback, seek to an arbitrary position in the content (if the content supports arbitrary
  seeking), change the volume, change the display of closed captions or embedded sign-language
  tracks, select different audio tracks or turn on audio descriptions, and show the media content in
  manners more suitable to the user (e.g. fullscreen video or in an independent resizable window).
  Other controls may also be made available.</p>

  <p>Even when the attribute is absent, however, user agents may provide controls to affect playback
  of the media resource (e.g. play, pause, seeking, track selection, and volume controls), but such
  features should not interfere with the page's normal rendering. For example, such features could
  be exposed in the <a href="#media-element" id="user-interface:media-element-2">media element</a>'s context menu, platform media keys, or a remote
  control. The user agent may implement this simply by <a href="#expose-a-user-interface-to-the-user" id="user-interface:expose-a-user-interface-to-the-user">exposing a user interface to the user</a> as described above (as if the <code id="user-interface:attr-media-controls"><a href="#attr-media-controls">controls</a></code> attribute was present).</p>

  <p>If the user agent <a href="#expose-a-user-interface-to-the-user" id="user-interface:expose-a-user-interface-to-the-user-2">exposes a user interface to
  the user</a> by displaying controls over the <a href="#media-element" id="user-interface:media-element-3">media element</a>, then the user agent
  should suppress any user interaction events while the user agent is interacting with this
  interface. (For example, if the user clicks on a video's playback control, <code id="user-interface:event-mousedown"><a data-x-internal="event-mousedown" href="https://w3c.github.io/uievents/#event-type-mousedown">mousedown</a></code> events and so forth would not simultaneously be fired at
  elements on the page.)</p>

  <p>Where possible (specifically, for starting, stopping, pausing, and unpausing playback, for
  seeking, for changing the rate of playback, for fast-forwarding or rewinding, for listing,
  enabling, and disabling text tracks, and for muting or changing the volume of the audio), user
  interface features exposed by the user agent must be implemented in terms of the DOM API described
  above, so that, e.g., all the same events fire.</p>

  <p>Features such as fast-forward or rewind must be implemented by only changing the <code>playbackRate</code> attribute (and not the <code>defaultPlaybackRate</code>
  attribute).</p>

  <p>Seeking must be implemented in terms of <a href="#dom-media-seek" id="user-interface:dom-media-seek">seeking</a> to the
  requested position in the <a href="#media-element" id="user-interface:media-element-4">media element</a>'s <a href="#media-timeline" id="user-interface:media-timeline">media timeline</a>. For media
  resources where seeking to an arbitrary position would be slow, user agents are encouraged to use
  the <i>approximate-for-speed</i> flag when seeking in response to the user manipulating an
  approximate position interface such as a seek bar.</p>

  <hr>

  

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-media-volume" id="dom-media-volume-dev">volume</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/volume" title="The HTMLMediaElement.volume property sets the volume at which the media will be played.">HTMLMediaElement/volume</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span title="Partial implementation.">🔰 3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the current playback volume, as a number in the range 0.0 to 1.0, where 0.0 is the
    quietest and 1.0 the loudest.</p>

    <p>Can be set, to change the volume.</p>

    <p>Throws an <a id="user-interface:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="user-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the new
    value is not in the range 0.0 .. 1.0.</p>
   </dd><dt><code><var>media</var>.<a href="#dom-media-muted" id="dom-media-muted-dev">muted</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/muted" title="The HTMLMediaElement.muted property indicates whether the media element is muted.">HTMLMediaElement/muted</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns true if audio is muted, overriding the <code id="user-interface:dom-media-volume"><a href="#dom-media-volume">volume</a></code>
    attribute, and false if the <code id="user-interface:dom-media-volume-2"><a href="#dom-media-volume">volume</a></code> attribute is being
    honored.</p>

    <p>Can be set, to change whether the audio is muted or not.</p>
   </dd></dl>

  

  <p>A <a href="#media-element" id="user-interface:media-element-5">media element</a> has a <dfn id="concept-media-volume">playback volume</dfn>, which is a fraction in the range 0.0 (silent) to 1.0 (loudest).
  Initially, the volume should be 1.0, but user agents may remember the last set value across
  sessions, on a per-site basis or otherwise, so the volume may start at other values.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-volume" data-dfn-type="attribute"><code>volume</code></dfn>
  IDL attribute must return the <a href="#concept-media-volume" id="user-interface:concept-media-volume">playback volume</a> of any
  audio portions of the <a href="#media-element" id="user-interface:media-element-6">media element</a>. On setting, if the new value is in the range 0.0
  to 1.0 inclusive, the <a href="#media-element" id="user-interface:media-element-7">media element</a>'s <a href="#concept-media-volume" id="user-interface:concept-media-volume-2">playback
  volume</a> must be set to the new value. If the new value is outside the range 0.0 to 1.0
  inclusive, then, on setting, an <a id="user-interface:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a>
  <code id="user-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> must be thrown instead.</p>
  </div>

  <p>A <a href="#media-element" id="user-interface:media-element-8">media element</a> can also be <dfn data-dfn-for="media element" id="concept-media-muted" data-export="">muted</dfn>. If anything is muting the element, then it is muted. (For example, when the
  <a href="#direction-of-playback" id="user-interface:direction-of-playback">direction of playback</a> is backwards, the element is muted.)</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMediaElement" id="dom-media-muted" data-dfn-type="attribute"><code>muted</code></dfn> IDL
  attribute must return the value to which it was last set. When a <a href="#media-element" id="user-interface:media-element-9">media element</a> is
  created, if the element has a <code id="user-interface:attr-media-muted"><a href="#attr-media-muted">muted</a></code> content attribute
  specified, then the <code id="user-interface:dom-media-muted"><a href="#dom-media-muted">muted</a></code> IDL attribute should be set to
  true; otherwise, the user agents may set the value to the user's preferred value (e.g. remembering
  the last set value across sessions, on a per-site basis or otherwise). While the <code id="user-interface:dom-media-muted-2"><a href="#dom-media-muted">muted</a></code> IDL attribute is set to true, the <a href="#media-element" id="user-interface:media-element-10">media element</a>
  must be <a href="#concept-media-muted" id="user-interface:concept-media-muted">muted</a>.</p>
  </div>

  <div data-algorithm="">
  <p>Whenever either of the values that would be returned by the <code id="user-interface:dom-media-volume-3"><a href="#dom-media-volume">volume</a></code> and <code id="user-interface:dom-media-muted-3"><a href="#dom-media-muted">muted</a></code> IDL
  attributes change, the user agent must <a href="#queue-a-media-element-task" id="user-interface:queue-a-media-element-task">queue a media element task</a> given the
  <a href="#media-element" id="user-interface:media-element-11">media element</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="user-interface:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="user-interface:event-media-volumechange"><a href="#event-media-volumechange">volumechange</a></code> at the <a href="#media-element" id="user-interface:media-element-12">media element</a>. Then, if
  the <a href="#media-element" id="user-interface:media-element-13">media element</a> is not <a href="#allowed-to-play" id="user-interface:allowed-to-play">allowed to play</a>, the user agent must run the
  <a href="#internal-pause-steps" id="user-interface:internal-pause-steps">internal pause steps</a> for the <a href="#media-element" id="user-interface:media-element-14">media element</a>.</p>
  </div>

  <p>A user agent has an associated <dfn id="volume-locked">volume locked</dfn> (a boolean). Its value is
  <a id="user-interface:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> and determines whether the <a href="#concept-media-volume" id="user-interface:concept-media-volume-3">playback volume</a> takes effect.</p>

  <div data-algorithm="">
  <p>An element's <dfn data-dfn-for="HTMLMediaElement" id="effective-media-volume" data-export="">effective media volume</dfn> is determined as
  follows:</p>

  <ol><li><p>If the user has indicated that the user agent is to override the volume of the element,
   then return the volume desired by the user.</p></li><li><p>If the user agent's <a href="#volume-locked" id="user-interface:volume-locked">volume locked</a> is true, then return the system
   volume.</p></li><li><p>If the element's audio output is <a href="#concept-media-muted" id="user-interface:concept-media-muted-2">muted</a>, then
   return zero.</p></li><li><p>Let <var>volume</var> be the <a href="#concept-media-volume" id="user-interface:concept-media-volume-4">playback
   volume</a> of the audio portions of the <a href="#media-element" id="user-interface:media-element-15">media element</a>, in range 0.0 (silent) to
   1.0 (loudest).</p></li><li><p>Return <var>volume</var>, interpreted relative to the range 0.0 to 1.0, with 0.0 being
   silent, and 1.0 being the loudest setting, values in between increasing in loudness. The range
   need not be linear. The loudest setting may be lower than the system's loudest possible setting;
   for example the user could have set a maximum volume.</p></li></ol>
  </div>

  

  <p>The <dfn data-dfn-for="audio,video" id="attr-media-muted" data-dfn-type="element-attr"><code>muted</code></dfn>
  content attribute on <a href="#media-element" id="user-interface:media-element-16">media elements</a> is a <a href="#boolean-attribute" id="user-interface:boolean-attribute-2">boolean
  attribute</a> that controls the default state of the audio output of the <a href="#media-resource" id="user-interface:media-resource">media
  resource</a>, potentially overriding user preferences.</p>

  <p class="note">This attribute has no dynamic effect (it only controls the default state of the
  element).</p>

  <div class="example">

   <p>This video (an advertisement) autoplays, but to avoid annoying users, it does so without
   sound, and allows the user to turn the sound on. The user agent can pause the video if it's
   unmuted without a user interaction.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">video</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"adverts.cgi?kind=video"</c-> <c- e="">controls</c-> <c- e="">autoplay</c-> <c- e="">loop</c-> <c- e="">muted</c-><c- p="">&gt;&lt;/</c-><c- f="">video</c-><c- p="">&gt;</c-></code></pre>

  </div>




  <h5 id="time-ranges"><span class="secno">4.8.11.14</span> Time ranges<a href="#time-ranges" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TimeRanges" title="When loading a media resource for use by an <audio> or <video> element, the TimeRanges interface is used for representing the time ranges of the media resource that have been buffered, the time ranges that have been played, and the time ranges that are seekable.">TimeRanges</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <p>Objects implementing the <code id="time-ranges:timeranges"><a href="#timeranges">TimeRanges</a></code> interface
  represent a list of ranges (periods) of time.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="timeranges" data-dfn-type="interface"><c- g="">TimeRanges</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-timeranges-length" id="time-ranges:dom-timeranges-length"><c- g="">length</c-></a>;
  <c- b="">double</c-> <a href="#dom-timeranges-start" id="time-ranges:dom-timeranges-start"><c- g="">start</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <c- b="">double</c-> <a href="#dom-timeranges-end" id="time-ranges:dom-timeranges-end"><c- g="">end</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
};</code></pre>

  <dl class="domintro"><dt><code><var>media</var>.<a href="#dom-timeranges-length" id="dom-timeranges-length-dev">length</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TimeRanges/length" title="The TimeRanges.length read-only property returns the number of ranges in the object.">TimeRanges/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the number of ranges in the object.</p></dd><dt><code><var>time</var> = <var>media</var>.<a href="#dom-timeranges-start" id="dom-timeranges-start-dev">start</a>(<var>index</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TimeRanges/start" title="The start() method of the TimeRanges interface returns the time offset at which a specified time range begins.">TimeRanges/start</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the time for the start of the range with the given index.</p>

    <p>Throws an <a id="time-ranges:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="time-ranges:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the index
    is out of range.</p>
   </dd><dt><code><var>time</var> = <var>media</var>.<a href="#dom-timeranges-end" id="dom-timeranges-end-dev">end</a>(<var>index</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TimeRanges/end" title="The end() method of the TimeRanges interface returns the time offset at which a specified time range ends.">TimeRanges/end</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the time for the end of the range with the given index.</p>

    <p>Throws an <a id="time-ranges:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="time-ranges:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the index
    is out of range.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TimeRanges" id="dom-timeranges-length" data-dfn-type="attribute"><code>length</code></dfn>
  IDL attribute must return the number of ranges represented by the object.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TimeRanges" id="dom-timeranges-start" data-dfn-type="method"><code>start(<var>index</var>)</code></dfn> method must return the position
  of the start of the <var>index</var>th range represented by the object, in seconds measured from
  the start of the timeline that the object covers.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TimeRanges" id="dom-timeranges-end" data-dfn-type="method"><code>end(<var>index</var>)</code></dfn> method must return the position of
  the end of the <var>index</var>th range represented by the object, in seconds measured from the
  start of the timeline that the object covers.</p>
  </div>

  <p>These methods must throw <a id="time-ranges:indexsizeerror-3" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="time-ranges:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>s
  if called with an <var>index</var> argument greater than or equal to the number of ranges
  represented by the object.</p>

  <div data-algorithm="">
  <p>When a <code id="time-ranges:timeranges-2"><a href="#timeranges">TimeRanges</a></code> object is said to be a <dfn id="normalised-timeranges-object" data-export="">normalized <code>TimeRanges</code> object</dfn>,
  the ranges it represents must obey the following criteria:</p>

  <ul><li>The start of a range must be greater than the end of all earlier ranges.</li><li>The start of a range must be less than or equal to the end of that same range.</li></ul>
  </div>

  <p>In other words, the ranges in such an object are ordered, don't overlap, and don't touch
  (adjacent ranges are folded into one bigger range). A range can be empty (referencing just a
  single moment in time), e.g. to indicate that only one frame is currently buffered in the case
  that the user agent has discarded the entire <a href="#media-resource" id="time-ranges:media-resource">media resource</a> except for the current
  frame, when a <a href="#media-element" id="time-ranges:media-element">media element</a> is paused.</p>

  <p>Ranges in a <code id="time-ranges:timeranges-3"><a href="#timeranges">TimeRanges</a></code> object must be inclusive.</p>

  <p class="example">Thus, the end of a range would be equal to the start of a following adjacent
  (touching but not overlapping) range. Similarly, a range covering a whole timeline anchored at
  zero would have a start equal to zero and an end equal to the duration of the timeline.</p>

  <p>The timelines used by the objects returned by the <code id="time-ranges:dom-media-buffered"><a href="#dom-media-buffered">buffered</a></code>, <code id="time-ranges:dom-media-seekable"><a href="#dom-media-seekable">seekable</a></code>, and
  <code id="time-ranges:dom-media-played"><a href="#dom-media-played">played</a></code> IDL attributes of <a href="#media-element" id="time-ranges:media-element-2">media
  elements</a> must be that element's <a href="#media-timeline" id="time-ranges:media-timeline">media timeline</a>.</p>

  


  <h5 id="the-trackevent-interface"><span class="secno">4.8.11.15</span> The <code id="the-trackevent-interface:trackevent"><a href="#trackevent">TrackEvent</a></code> interface<a href="#the-trackevent-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TrackEvent" title="The TrackEvent interface, which is part of the HTML DOM specification, is used for events which represent changes to a set of available tracks on an HTML media element; these events are addtrack and removetrack.">TrackEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>27+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="trackevent" data-dfn-type="interface"><c- g="">TrackEvent</c-></dfn> : <a id="the-trackevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#trackeventinit" id="the-trackevent-interface:trackeventinit"><c- n="">TrackEventInit</c-></a> <c- g="">eventInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> (<a href="#videotrack" id="the-trackevent-interface:videotrack"><c- n="">VideoTrack</c-></a> <c- b="">or</c-> <a href="#audiotrack" id="the-trackevent-interface:audiotrack"><c- n="">AudioTrack</c-></a> <c- b="">or</c-> <a href="#texttrack" id="the-trackevent-interface:texttrack"><c- n="">TextTrack</c-></a>)? <a href="#dom-trackevent-track" id="the-trackevent-interface:dom-trackevent-track"><c- g="">track</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="trackeventinit" data-dfn-type="dictionary"><c- g="">TrackEventInit</c-></dfn> : <a id="the-trackevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  (<a href="#videotrack" id="the-trackevent-interface:videotrack-2"><c- n="">VideoTrack</c-></a> <c- b="">or</c-> <a href="#audiotrack" id="the-trackevent-interface:audiotrack-2"><c- n="">AudioTrack</c-></a> <c- b="">or</c-> <a href="#texttrack" id="the-trackevent-interface:texttrack-2"><c- n="">TextTrack</c-></a>)? <c- g="">track</c-> = <c- b="">null</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-trackevent-track" id="dom-trackevent-track-dev">track</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TrackEvent/track" title="The read-only track property of the TrackEvent interface specifies the media track object to which the event applies.">TrackEvent/track</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>27+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the track object (<code id="the-trackevent-interface:texttrack-3"><a href="#texttrack">TextTrack</a></code>, <code id="the-trackevent-interface:audiotrack-3"><a href="#audiotrack">AudioTrack</a></code>, or
    <code id="the-trackevent-interface:videotrack-3"><a href="#videotrack">VideoTrack</a></code>) to which the event relates.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="TrackEvent" id="dom-trackevent-track" data-dfn-type="attribute"><code>track</code></dfn>
  attribute must return the value it was initialized to. It represents the context information for
  the event.</p>
  </div>

  



  <h5 id="mediaevents"><span class="secno">4.8.11.16</span> Events summary<a href="#mediaevents" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>The following events fire on <a href="#media-element" id="mediaevents:media-element">media elements</a> as part of the
  processing model described above:</p>

  <table><thead><tr><th>Event name
     </th><th>Interface
     </th><th>Fired when...
     </th><th>Preconditions

   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-loadstart" data-dfn-type="event"><code>loadstart</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadstart_event" title="The loadstart event is fired when the browser has started to load a resource.">HTMLMediaElement/loadstart_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td><code id="mediaevents:event"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The user agent begins looking for <a href="#media-data" id="mediaevents:media-data">media data</a>, as part of the <a href="#concept-media-load-algorithm" id="mediaevents:concept-media-load-algorithm">resource selection algorithm</a>.

     </td><td><code id="mediaevents:dom-media-networkstate"><a href="#dom-media-networkstate">networkState</a></code> equals <code id="mediaevents:dom-media-network_loading"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code>

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-progress" data-dfn-type="event"><code>progress</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/progress_event" title="The progress event is fired periodically as the browser loads a resource.">HTMLMediaElement/progress_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td><code id="mediaevents:event-2"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The user agent is fetching <a href="#media-data" id="mediaevents:media-data-2">media data</a>.

     </td><td><code id="mediaevents:dom-media-networkstate-2"><a href="#dom-media-networkstate">networkState</a></code> equals <code id="mediaevents:dom-media-network_loading-2"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code>

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-suspend" data-dfn-type="event"><code>suspend</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/suspend_event" title="The suspend event is fired when media data loading has been suspended.">HTMLMediaElement/suspend_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-3"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The user agent is intentionally not currently fetching <a href="#media-data" id="mediaevents:media-data-3">media data</a>.

     </td><td><code id="mediaevents:dom-media-networkstate-3"><a href="#dom-media-networkstate">networkState</a></code> equals <code id="mediaevents:dom-media-network_idle"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code>

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-abort" data-dfn-type="event"><code>abort</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/abort_event" title="The abort event is fired when the resource was not fully loaded, but not as the result of an error.">HTMLMediaElement/abort_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td><code id="mediaevents:event-4"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The user agent stops fetching the <a href="#media-data" id="mediaevents:media-data-4">media data</a> before it is completely
     downloaded, but not due to an error.

     </td><td><code id="mediaevents:dom-media-error"><a href="#dom-media-error">error</a></code> is an object with the code <code id="mediaevents:dom-mediaerror-media_err_aborted"><a href="#dom-mediaerror-media_err_aborted">MEDIA_ERR_ABORTED</a></code>. <code id="mediaevents:dom-media-networkstate-4"><a href="#dom-media-networkstate">networkState</a></code> equals either <code id="mediaevents:dom-media-network_empty"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code> or <code id="mediaevents:dom-media-network_idle-2"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code>, depending on when the download was aborted.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-error" data-dfn-type="event"><code>error</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/error_event" title="The error event is fired when the resource could not be loaded due to an error (for example, a network connectivity problem).">HTMLMediaElement/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td><code id="mediaevents:event-5"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>An error occurs while fetching the <a href="#media-data" id="mediaevents:media-data-5">media data</a> or the type of the resource
     is not a supported media format.

     </td><td><code id="mediaevents:dom-media-error-2"><a href="#dom-media-error">error</a></code> is an object with the code <code id="mediaevents:dom-mediaerror-media_err_network"><a href="#dom-mediaerror-media_err_network">MEDIA_ERR_NETWORK</a></code> or higher. <code id="mediaevents:dom-media-networkstate-5"><a href="#dom-media-networkstate">networkState</a></code> equals either <code id="mediaevents:dom-media-network_empty-2"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code> or <code id="mediaevents:dom-media-network_idle-3"><a href="#dom-media-network_idle">NETWORK_IDLE</a></code>, depending on when the download was aborted.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-emptied" data-dfn-type="event"><code>emptied</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/emptied_event" title="The emptied event is fired when the media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the load() method is called to reload it.">HTMLMediaElement/emptied_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-6"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>A <a href="#media-element" id="mediaevents:media-element-2">media element</a> whose <code id="mediaevents:dom-media-networkstate-6"><a href="#dom-media-networkstate">networkState</a></code>
     was previously not in the <code id="mediaevents:dom-media-network_empty-3"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code> state has
     just switched to that state (either because of a fatal error during load that's about to be
     reported, or because the <code id="mediaevents:dom-media-load"><a href="#dom-media-load">load()</a></code> method was invoked while
     the <a href="#concept-media-load-algorithm" id="mediaevents:concept-media-load-algorithm-2">resource selection algorithm</a> was already
     running).

     </td><td><code id="mediaevents:dom-media-networkstate-7"><a href="#dom-media-networkstate">networkState</a></code> is <code id="mediaevents:dom-media-network_empty-4"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code>; all the IDL attributes are in their
     initial states.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-stalled" data-dfn-type="event"><code>stalled</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/stalled_event" title="The stalled event is fired when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.">HTMLMediaElement/stalled_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-7"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The user agent is trying to fetch <a href="#media-data" id="mediaevents:media-data-6">media data</a>, but data is unexpectedly not
     forthcoming.

     </td><td><code id="mediaevents:dom-media-networkstate-8"><a href="#dom-media-networkstate">networkState</a></code> is <code id="mediaevents:dom-media-network_loading-3"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code>.

   </td></tr></tbody><tbody><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-loadedmetadata" data-dfn-type="event"><code>loadedmetadata</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadedmetadata_event" title="The loadedmetadata event is fired when the metadata has been loaded.">HTMLMediaElement/loadedmetadata_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-8"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The user agent has just determined the duration and dimensions of the <a href="#media-resource" id="mediaevents:media-resource">media
     resource</a> and <a href="#the-text-tracks-are-ready" id="mediaevents:the-text-tracks-are-ready">the text tracks are ready</a>.

     </td><td><code id="mediaevents:dom-media-readystate"><a href="#dom-media-readystate">readyState</a></code> is newly equal to <code id="mediaevents:dom-media-have_metadata"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code> or greater for the first time.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-loadeddata" data-dfn-type="event"><code>loadeddata</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadeddata_event" title="The loadeddata event is fired when the frame at the current playback position of the media has finished loading; often the first frame.">HTMLMediaElement/loadeddata_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-9"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The user agent can render the <a href="#media-data" id="mediaevents:media-data-7">media data</a> at the <a href="#current-playback-position" id="mediaevents:current-playback-position">current playback
     position</a> for the first time.

     </td><td><code id="mediaevents:dom-media-readystate-2"><a href="#dom-media-readystate">readyState</a></code> newly increased to <code id="mediaevents:dom-media-have_current_data"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> or greater for the first time.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-canplay" data-dfn-type="event"><code>canplay</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canplay_event" title="The canplay event is fired when the user agent can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content.">HTMLMediaElement/canplay_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-10"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The user agent can resume playback of the <a href="#media-data" id="mediaevents:media-data-8">media data</a>, but estimates that if
     playback were to be started now, the <a href="#media-resource" id="mediaevents:media-resource-2">media resource</a> could not be rendered at the
     current playback rate up to its end without having to stop for further buffering of content.

     </td><td><code id="mediaevents:dom-media-readystate-3"><a href="#dom-media-readystate">readyState</a></code> newly increased to <code id="mediaevents:dom-media-have_future_data"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> or greater.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-canplaythrough" data-dfn-type="event"><code>canplaythrough</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canplaythrough_event" title="The canplaythrough event is fired when the user agent can play the media, and estimates that enough data has been loaded to play the media up to its end without having to stop for further buffering of content.">HTMLMediaElement/canplaythrough_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-11"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The user agent estimates that if playback were to be started now, the <a href="#media-resource" id="mediaevents:media-resource-3">media
     resource</a> could be rendered at the current playback rate all the way to its end without
     having to stop for further buffering.

     </td><td><code id="mediaevents:dom-media-readystate-4"><a href="#dom-media-readystate">readyState</a></code> is newly equal to <code id="mediaevents:dom-media-have_enough_data"><a href="#dom-media-have_enough_data">HAVE_ENOUGH_DATA</a></code>.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-playing" data-dfn-type="event"><code>playing</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event" title="The playing event is fired after playback is first started, and whenever it is restarted. For example it is fired when playback resumes after having been paused or delayed due to lack of data.">HTMLMediaElement/playing_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-12"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>Playback is ready to start after having been paused or delayed due to lack of <a href="#media-data" id="mediaevents:media-data-9">media
     data</a>.

     </td><td><code id="mediaevents:dom-media-readystate-5"><a href="#dom-media-readystate">readyState</a></code> is newly greater than or equal to
     <code id="mediaevents:dom-media-have_future_data-2"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code> and <code id="mediaevents:dom-media-paused"><a href="#dom-media-paused">paused</a></code> is false, or <code id="mediaevents:dom-media-paused-2"><a href="#dom-media-paused">paused</a></code> is newly false and <code id="mediaevents:dom-media-readystate-6"><a href="#dom-media-readystate">readyState</a></code> is greater than or equal to <code id="mediaevents:dom-media-have_future_data-3"><a href="#dom-media-have_future_data">HAVE_FUTURE_DATA</a></code>. Even if this event fires, the
     element might still not be <a href="#potentially-playing" id="mediaevents:potentially-playing">potentially playing</a>, e.g. if the element is
     <a href="#paused-for-user-interaction" id="mediaevents:paused-for-user-interaction">paused for user interaction</a> or <a href="#paused-for-in-band-content" id="mediaevents:paused-for-in-band-content">paused for in-band content</a>.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-waiting" data-dfn-type="event"><code>waiting</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/waiting_event" title="The waiting event is fired when playback has stopped because of a temporary lack of data.">HTMLMediaElement/waiting_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td><code id="mediaevents:event-13"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>Playback has stopped because the next frame is not available, but the user agent expects
     that frame to become available in due course.

     </td><td><code id="mediaevents:dom-media-readystate-7"><a href="#dom-media-readystate">readyState</a></code> is less than or equal to <code id="mediaevents:dom-media-have_current_data-2"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code>, and <code id="mediaevents:dom-media-paused-3"><a href="#dom-media-paused">paused</a></code> is false. Either <code id="mediaevents:dom-media-seeking"><a href="#dom-media-seeking">seeking</a></code> is true, or the <a href="#current-playback-position" id="mediaevents:current-playback-position-2">current playback position</a>
     is not contained in any of the ranges in <code id="mediaevents:dom-media-buffered"><a href="#dom-media-buffered">buffered</a></code>. It
     is possible for playback to stop for other reasons without <code id="mediaevents:dom-media-paused-4"><a href="#dom-media-paused">paused</a></code> being false, but those reasons do not fire this event
     (and when those situations resolve, a separate <code id="mediaevents:event-media-playing"><a href="#event-media-playing">playing</a></code>
     event is not fired either): e.g., <a href="#ended-playback" id="mediaevents:ended-playback">playback has ended</a>, or
     playback <a href="#stopped-due-to-errors" id="mediaevents:stopped-due-to-errors">stopped due to errors</a>, or the element has <a href="#paused-for-user-interaction" id="mediaevents:paused-for-user-interaction-2">paused for user
     interaction</a> or <a href="#paused-for-in-band-content" id="mediaevents:paused-for-in-band-content-2">paused for in-band content</a>.

   </td></tr></tbody><tbody><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-seeking" data-dfn-type="event"><code>seeking</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seeking_event" title="The seeking event is fired when a seek operation starts, meaning the Boolean seeking attribute has changed to true and the media is seeking a new position.">HTMLMediaElement/seeking_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-14"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The <code id="mediaevents:dom-media-seeking-2"><a href="#dom-media-seeking">seeking</a></code> IDL attribute changed to true, and the user agent has started seeking to a new position.

     </td><td>

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-seeked" data-dfn-type="event"><code>seeked</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seeked_event" title="The seeked event is fired when a seek operation completed, the current playback position has changed, and the Boolean seeking attribute is changed to false.">HTMLMediaElement/seeked_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-15"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The <code id="mediaevents:dom-media-seeking-3"><a href="#dom-media-seeking">seeking</a></code> IDL attribute changed to false after the <a href="#current-playback-position" id="mediaevents:current-playback-position-3">current playback position</a> was changed.

     </td><td>

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-ended" data-dfn-type="event"><code>ended</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ended_event" title="The ended event is fired when playback or streaming has stopped because the end of the media was reached or because no further data is available.">HTMLMediaElement/ended_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-16"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>Playback has stopped because the end of the <a href="#media-resource" id="mediaevents:media-resource-4">media resource</a> was reached.

     </td><td><code id="mediaevents:dom-media-currenttime"><a href="#dom-media-currenttime">currentTime</a></code> equals the end of the <a href="#media-resource" id="mediaevents:media-resource-5">media
     resource</a>; <code id="mediaevents:dom-media-ended"><a href="#dom-media-ended">ended</a></code> is true.

   </td></tr></tbody><tbody><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-durationchange" data-dfn-type="event"><code>durationchange</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/durationchange_event" title="The durationchange event is fired when the duration attribute has been updated.">HTMLMediaElement/durationchange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-17"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The <code id="mediaevents:dom-media-duration"><a href="#dom-media-duration">duration</a></code> attribute has just been updated.

     </td><td>

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-timeupdate" data-dfn-type="event"><code>timeupdate</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/timeupdate_event" title="The timeupdate event is fired when the time indicated by the currentTime attribute has been updated.">HTMLMediaElement/timeupdate_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-18"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The <a href="#current-playback-position" id="mediaevents:current-playback-position-4">current playback position</a> changed as part of normal playback or in an especially interesting way, for example discontinuously.

     </td><td>

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-play" data-dfn-type="event"><code>play</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play_event" title="The play event is fired when the paused property is changed from true to false, as a result of the play method, or the autoplay attribute.">HTMLMediaElement/play_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-19"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The element is no longer paused. Fired after the <code id="mediaevents:dom-media-play"><a href="#dom-media-play">play()</a></code>
     method has returned, or when the <code id="mediaevents:attr-media-autoplay"><a href="#attr-media-autoplay">autoplay</a></code> attribute
     has caused playback to begin.

     </td><td><code id="mediaevents:dom-media-paused-5"><a href="#dom-media-paused">paused</a></code> is newly false.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-pause" data-dfn-type="event"><code>pause</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/pause_event" title="The pause event is sent when a request to pause an activity is handled and the activity has entered its paused state, most commonly after the media has been paused through a call to the element's pause() method.">HTMLMediaElement/pause_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-20"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The element has been paused. Fired after the <code id="mediaevents:dom-media-pause"><a href="#dom-media-pause">pause()</a></code>
     method has returned.

     </td><td><code id="mediaevents:dom-media-paused-6"><a href="#dom-media-paused">paused</a></code> is newly true.

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-ratechange" data-dfn-type="event"><code>ratechange</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ratechange_event" title="The ratechange event is fired when the playback rate has changed.">HTMLMediaElement/ratechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td><code id="mediaevents:event-21"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>Either the <code id="mediaevents:dom-media-defaultplaybackrate"><a href="#dom-media-defaultplaybackrate">defaultPlaybackRate</a></code> or the
     <code id="mediaevents:dom-media-playbackrate"><a href="#dom-media-playbackrate">playbackRate</a></code> attribute has just been updated.

     </td><td>

   </td></tr></tbody><tbody><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-resize" data-dfn-type="event"><code>resize</code></dfn>

     </td><td><code id="mediaevents:event-22"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>One or both of the <code id="mediaevents:dom-video-videowidth"><a href="#dom-video-videowidth">videoWidth</a></code> and <code id="mediaevents:dom-video-videoheight"><a href="#dom-video-videoheight">videoHeight</a></code> attributes have just been updated.

     </td><td><a href="#media-element" id="mediaevents:media-element-3">Media element</a> is a <code id="mediaevents:the-video-element"><a href="#the-video-element">video</a></code> element; <code id="mediaevents:dom-media-readystate-8"><a href="#dom-media-readystate">readyState</a></code> is not <code id="mediaevents:dom-media-have_nothing"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code>

    </td></tr><tr><td><dfn data-dfn-for="HTMLMediaElement" id="event-media-volumechange" data-dfn-type="event"><code>volumechange</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/volumechange_event" title="The volumechange event is fired when either the volume attribute or the muted attribute has changed.">HTMLMediaElement/volumechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td><code id="mediaevents:event-23"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>Either the <code id="mediaevents:dom-media-volume"><a href="#dom-media-volume">volume</a></code> attribute or the <code id="mediaevents:dom-media-muted"><a href="#dom-media-muted">muted</a></code> attribute has changed. Fired after the relevant
     attribute's setter has returned.

     </td><td>

  </td></tr></tbody></table>


  <p>The following event fires on <code id="mediaevents:the-source-element"><a href="#the-source-element">source</a></code> elements:</p>

  <table><thead><tr><th>Event name

     </th><th>Interface

     </th><th>Fired when...

   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="HTMLSourceElement" id="event-source-error" data-dfn-type="event"><code>error</code></dfn>

     </td><td><code id="mediaevents:event-24"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>An error occurs while fetching the <a href="#media-data" id="mediaevents:media-data-10">media data</a> or the type of the resource
     is not a supported media format.

  </td></tr></tbody></table>


  <p>The following events fire on <code id="mediaevents:audiotracklist"><a href="#audiotracklist">AudioTrackList</a></code>, <code id="mediaevents:videotracklist"><a href="#videotracklist">VideoTrackList</a></code>, and
  <code id="mediaevents:texttracklist"><a href="#texttracklist">TextTrackList</a></code> objects:</p>

  <table><thead><tr><th>Event name

     </th><th>Interface

     </th><th>Fired when...

   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="AudioTrackList,VideoTrackList,TextTrackList" id="event-media-change" data-dfn-type="event"><code>change</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList/change_event" title="The change event is fired when an audio track is enabled or disabled, for example by changing the track's enabled property.">AudioTrackList/change_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList/change_event" title="The change event is fired when a text track is made active or inactive, or a TextTrackList is otherwise changed.">TextTrackList/change_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>33+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList/change_event" title="The change event is fired when a video track is made active or inactive, for example by changing the track's selected property.">VideoTrackList/change_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td><code id="mediaevents:event-25"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>One or more tracks in the track list have been enabled or disabled.

    </td></tr><tr><td><dfn data-dfn-for="AudioTrackList,VideoTrackList,TextTrackList" id="event-media-addtrack" data-dfn-type="event"><code>addtrack</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList/addtrack_event" title="The addtrack event is fired when a track is added to an AudioTrackList.">AudioTrackList/addtrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList/addtrack_event" title="The addtrack event is fired when a track is added to a TextTrackList.">TextTrackList/addtrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList/addtrack_event" title="The addtrack event is fired when a video track is added to a VideoTrackList.">VideoTrackList/addtrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td><code id="mediaevents:trackevent"><a href="#trackevent">TrackEvent</a></code>

     </td><td>A track has been added to the track list.

    </td></tr><tr><td><dfn data-dfn-for="AudioTrackList,VideoTrackList,TextTrackList" id="event-media-removetrack" data-dfn-type="event"><code>removetrack</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList/removetrack_event" title="The removetrack event is fired when a track is removed from an AudioTrackList.">AudioTrackList/removetrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList/removetrack_event" title="The removetrack event is fired when a track is removed from a TextTrackList.">TextTrackList/removetrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>33+</span></span><hr><span class="opera yes"><span>Opera</span><span>20+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>20+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VideoTrackList/removetrack_event" title="The removetrack event is fired when a video track is removed from a VideoTrackList.">VideoTrackList/removetrack_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 33+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td><code id="mediaevents:trackevent-2"><a href="#trackevent">TrackEvent</a></code>

     </td><td>A track has been removed from the track list.

  </td></tr></tbody></table>



  <p>The following event fires on <code id="mediaevents:texttrack"><a href="#texttrack">TextTrack</a></code> objects and <code id="mediaevents:the-track-element"><a href="#the-track-element">track</a></code> elements:</p>

  <table><thead><tr><th>Event name

     </th><th>Interface

     </th><th>Fired when...

   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="TextTrack,HTMLTrackElement" id="event-media-cuechange" data-dfn-type="event"><code>cuechange</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement/cuechange_event" title="The cuechange event fires when a TextTrack has changed the currently displaying cues. The event is fired on both the TextTrack and the HTMLTrackElement in which it's being presented, if any.">HTMLTrackElement/cuechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>32+</span></span><hr><span class="opera yes"><span>Opera</span><span>19+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4.3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>19+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/cuechange_event" title="The cuechange event fires when a TextTrack has changed the currently displaying cues. The event is fired on both the TextTrack and the HTMLTrackElement in which it's being presented, if any.">TextTrack/cuechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td><code id="mediaevents:event-26"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>One or more cues in the track have become active or stopped being active.

  </td></tr></tbody></table>


  <p>The following events fire on <code id="mediaevents:the-track-element-2"><a href="#the-track-element">track</a></code> elements:</p>

  <table><thead><tr><th>Event name

     </th><th>Interface

     </th><th>Fired when...

   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="HTMLTrackElement" id="event-track-error" data-dfn-type="event"><code>error</code></dfn>

     </td><td><code id="mediaevents:event-27"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>An error occurs while fetching the track data or the type of the resource is not supported text track format.

    </td></tr><tr><td><dfn data-dfn-for="HTMLTrackElement" id="event-track-load" data-dfn-type="event"><code>load</code></dfn>

     </td><td><code id="mediaevents:event-28"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>A track data has been fetched and successfully processed.
  </td></tr></tbody></table>


  <p>The following events fire on <code id="mediaevents:texttrackcue"><a href="#texttrackcue">TextTrackCue</a></code> objects:</p>

  <table><thead><tr><th>Event name

     </th><th>Interface

     </th><th>Fired when...

   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="TextTrackCue" id="event-media-enter" data-dfn-type="event"><code>enter</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/enter_event" title="The enter event fires when a cue becomes active. In the case of subtitles or a caption this is when it displays over the media.">TextTrackCue/enter_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td><code id="mediaevents:event-29"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The cue has become active.

    </td></tr><tr><td><dfn data-dfn-for="TextTrackCue" id="event-media-exit" data-dfn-type="event"><code>exit</code></dfn>

     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/exit_event" title="The exit event fires when a cue stops being active.">TextTrackCue/exit_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td><code id="mediaevents:event-30"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>

     </td><td>The cue has stopped being active.

  </td></tr></tbody></table>


  

  <h5 id="security-and-privacy-considerations"><span class="secno">4.8.11.17</span> Security and privacy considerations<a href="#security-and-privacy-considerations" class="self-link"></a></h5>

  <p>The main security and privacy implications of the <code id="security-and-privacy-considerations:the-video-element"><a href="#the-video-element">video</a></code> and <code id="security-and-privacy-considerations:the-audio-element"><a href="#the-audio-element">audio</a></code>
  elements come from the ability to embed media cross-origin. There are two directions that threats
  can flow: from hostile content to a victim page, and from a hostile page to victim content.</p>

  <hr>

  <p>If a victim page embeds hostile content, the threat is that the content might contain scripted
  code that attempts to interact with the <code id="security-and-privacy-considerations:document"><a href="#document">Document</a></code> that embeds the content. To avoid
  this, user agents must ensure that there is no access from the content to the embedding page. In
  the case of media content that uses DOM concepts, the embedded content must be treated as if it
  was in its own unrelated <a href="#top-level-traversable" id="security-and-privacy-considerations:top-level-traversable">top-level traversable</a>.</p>

  <p class="example">For instance, if an SVG animation was embedded in a <code id="security-and-privacy-considerations:the-video-element-2"><a href="#the-video-element">video</a></code> element,
  the user agent would not give it access to the DOM of the outer page. From the perspective of
  scripts in the SVG resource, the SVG file would appear to be in a lone top-level traversable
  with no parent.</p>

  <hr>

  <p>If a hostile page embeds victim content, the threat is that the embedding page could obtain
  information from the content that it would not otherwise have access to. The API does expose some
  information: the existence of the media, its type, its duration, its size, and the performance
  characteristics of its host. Such information is already potentially problematic, but in practice
  the same information can more or less be obtained using the <code id="security-and-privacy-considerations:the-img-element"><a href="#the-img-element">img</a></code> element, and so it
  has been deemed acceptable.</p>

  <p>However, significantly more sensitive information could be obtained if the user agent further
  exposes metadata within the content, such as subtitles. That information is therefore only exposed
  if the video resource uses CORS. The <code id="security-and-privacy-considerations:attr-media-crossorigin"><a href="#attr-media-crossorigin">crossorigin</a></code>
  attribute allows authors to enable CORS. <a href="#refsFETCH">[FETCH]</a></p>

  <p class="example">Without this restriction, an attacker could trick a user running within a
  corporate network into visiting a site that attempts to load a video from a previously leaked
  location on the corporation's intranet. If such a video included confidential plans for a new
  product, then being able to read the subtitles would present a serious confidentiality breach.</p>

  


  <h5 id="best-practices-for-authors-using-media-elements"><span class="secno">4.8.11.18</span> Best practices for authors using media elements<a href="#best-practices-for-authors-using-media-elements" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Playing audio and video resources on small devices such as set-top boxes or mobile phones is
  often constrained by limited hardware resources in the device. For example, a device might only
  support three simultaneous videos. For this reason, it is a good practice to release resources
  held by <a href="#media-element" id="best-practices-for-authors-using-media-elements:media-element">media elements</a> when they are done playing, either by
  being very careful about removing all references to the element and allowing it to be garbage
  collected, or, even better, by setting the element's <code id="best-practices-for-authors-using-media-elements:attr-media-src"><a href="#attr-media-src">src</a></code>
  attribute to an empty string. In cases where <code id="best-practices-for-authors-using-media-elements:dom-media-srcobject"><a href="#dom-media-srcobject">srcObject</a></code>
  was set, instead set the <code id="best-practices-for-authors-using-media-elements:dom-media-srcobject-2"><a href="#dom-media-srcobject">srcObject</a></code> to null.</p>

  <p>Similarly, when the playback rate is not exactly 1.0, hardware, software, or format limitations
  can cause video frames to be dropped and audio to be choppy or muted.</p>


  

  <h5 id="best-practices-for-implementers-of-media-elements"><span class="secno">4.8.11.19</span> Best practices for implementers of media elements<a href="#best-practices-for-implementers-of-media-elements" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>How accurately various aspects of the <a href="#media-element" id="best-practices-for-implementers-of-media-elements:media-element">media element</a> API are implemented is
  considered a quality-of-implementation issue.</p>

  <p>For example, when implementing the <code id="best-practices-for-implementers-of-media-elements:dom-media-buffered"><a href="#dom-media-buffered">buffered</a></code> attribute,
  how precise an implementation reports the ranges that have been buffered depends on how carefully
  the user agent inspects the data. Since the API reports ranges as times, but the data is obtained
  in byte streams, a user agent receiving a variable-bitrate stream might only be able to determine
  precise times by actually decoding all of the data. User agents aren't required to do this,
  however; they can instead return estimates (e.g. based on the average bitrate seen so far) which
  get revised as more information becomes available.</p>

  <p>As a general rule, user agents are urged to be conservative rather than optimistic. For
  example, it would be bad to report that everything had been buffered when it had not.</p>

  <p>Another quality-of-implementation issue would be playing a video backwards when the codec is
  designed only for forward playback (e.g. there aren't many key frames, and they are far apart, and
  the intervening frames only have deltas from the previous frame). User agents could do a poor job,
  e.g. only showing key frames; however, better implementations would do more work and thus do a
  better job, e.g. actually decoding parts of the video forwards, storing the complete frames, and
  then playing the frames backwards.</p>

  <p>Similarly, while implementations are allowed to drop buffered data at any time (there is no
  requirement that a user agent keep all the media data obtained for the lifetime of the media
  element), it is again a quality of implementation issue: user agents with sufficient resources to
  keep all the data around are encouraged to do so, as this allows for a better user experience. For
  example, if the user is watching a live stream, a user agent could allow the user only to view the
  live video; however, a better user agent would buffer everything and allow the user to seek
  through the earlier material, pause it, play it forwards and backwards, etc.</p>

  <hr>

  <p>When a <a href="#media-element" id="best-practices-for-implementers-of-media-elements:media-element-2">media element</a> that is paused is <a href="#remove-an-element-from-a-document" id="best-practices-for-implementers-of-media-elements:remove-an-element-from-a-document">removed from a document</a> and not reinserted before the next time the <a href="#event-loop" id="best-practices-for-implementers-of-media-elements:event-loop">event
  loop</a> reaches <a href="#step1">step 1</a>, implementations that are resource constrained are encouraged to take
  that opportunity to release all hardware resources (like video planes, networking resources, and
  data buffers) used by the <a href="#media-element" id="best-practices-for-implementers-of-media-elements:media-element-3">media element</a>. (User agents still have to keep track of the
  playback position and so forth, though, in case playback is later restarted.)</p>

  



  <h4 id="the-map-element"><span class="secno">4.8.12</span> The <dfn data-dfn-type="element"><code>map</code></dfn> element<a href="#the-map-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/map" title="The <map> HTML element is used with <area> elements to define an image map (a clickable link area).">Element/map</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMapElement" title="The HTMLMapElement interface provides special properties and methods (beyond those of the regular object HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of map elements.">HTMLMapElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-map-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-map-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-map-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="the-map-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-map-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-map-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-map-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#transparent" id="the-map-element:transparent">Transparent</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-map-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-map-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-map-element:global-attributes">Global attributes</a></dd><dd><code id="the-map-element:attr-map-name"><a href="#attr-map-name">name</a></code> —  Name of <a href="#image-map" id="the-map-element:image-map">image map</a> to <a href="#referenced" id="the-map-element:referenced">reference</a> from the <code id="the-map-element:attr-hyperlink-usemap"><a href="#attr-hyperlink-usemap">usemap</a></code> attribute
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-map-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-map">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-map">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-map-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlmapelement" data-dfn-type="interface"><c- g="">HTMLMapElement</c-></dfn> : <a href="#htmlelement" id="the-map-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-map-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-map-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-map-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMapElement" id="dom-map-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-map-element:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-map-areas" id="the-map-element:dom-map-areas"><c- g="">areas</c-></a>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-map-element:the-map-element"><a href="#the-map-element">map</a></code> element, in conjunction with an <code id="the-map-element:the-img-element"><a href="#the-img-element">img</a></code> element and any
  <code id="the-map-element:the-area-element"><a href="#the-area-element">area</a></code> element descendants, defines an <a href="#image-map" id="the-map-element:image-map-2">image map</a>. The element
  <a href="#represents" id="the-map-element:represents">represents</a> its children.</p>

  <p>The <dfn data-dfn-for="map" id="attr-map-name" data-dfn-type="element-attr"><code>name</code></dfn> attribute gives
  the map a name so that it can be <a href="#referenced" id="the-map-element:referenced-2">referenced</a>. The attribute must be present and must
  have a non-empty value with no <a id="the-map-element:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>. The value of the <code id="the-map-element:attr-map-name-2"><a href="#attr-map-name">name</a></code> attribute must not be equal to the value of the <code id="the-map-element:attr-map-name-3"><a href="#attr-map-name">name</a></code> attribute of another <code id="the-map-element:the-map-element-2"><a href="#the-map-element">map</a></code> element in the same
  <a id="the-map-element:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>. If the <code id="the-map-element:the-id-attribute"><a href="#the-id-attribute">id</a></code> attribute is also specified, both
  attributes must have the same value.</p>

  <dl class="domintro"><dt><code><var>map</var>.<a href="#dom-map-areas" id="dom-map-areas-dev">areas</a></code></dt><dd>
    <p>Returns an <code id="the-map-element:htmlcollection-2"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="the-map-element:the-area-element-2"><a href="#the-area-element">area</a></code> elements in the
    <code id="the-map-element:the-map-element-3"><a href="#the-map-element">map</a></code>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMapElement" id="dom-map-areas" data-dfn-type="attribute"><code>areas</code></dfn>
  attribute must return an <code id="the-map-element:htmlcollection-3"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="the-map-element:the-map-element-4"><a href="#the-map-element">map</a></code> element, whose
  filter matches only <code id="the-map-element:the-area-element-3"><a href="#the-area-element">area</a></code> elements.</p>
  </div>

  

  <div class="example">

   <p>Image maps can be defined in conjunction with other content on the page, to ease maintenance.
   This example is of a page with an image map at the top of the page and a corresponding set of
   text links at the bottom.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">HTML</c-> <c- e="">LANG</c-><c- o="">=</c-><c- s="">"EN"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">TITLE</c-><c- p="">&gt;</c->Babies™: Toys<c- p="">&lt;/</c-><c- f="">TITLE</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">HEADER</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">H1</c-><c- p="">&gt;</c->Toys<c- p="">&lt;/</c-><c- f="">H1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">IMG</c-> <c- e="">SRC</c-><c- o="">=</c-><c- s="">"/images/menu.gif"</c->
      <c- e="">ALT</c-><c- o="">=</c-><c- s="">"Babies™ navigation menu. Select a department to go to its page."</c->
      <c- e="">USEMAP</c-><c- o="">=</c-><c- s="">"#NAV"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">HEADER</c-><c- p="">&gt;</c->
 ...
<c- p="">&lt;</c-><c- f="">FOOTER</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">MAP</c-> <c- e="">NAME</c-><c- o="">=</c-><c- s="">"NAV"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">P</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">A</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/clothes/"</c-><c- p="">&gt;</c->Clothes<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">AREA</c-> <c- e="">ALT</c-><c- o="">=</c-><c- s="">"Clothes"</c-> <c- e="">COORDS</c-><c- o="">=</c-><c- s="">"0,0,100,50"</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/clothes/"</c-><c- p="">&gt;</c-> |
   <c- p="">&lt;</c-><c- f="">A</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/toys/"</c-><c- p="">&gt;</c->Toys<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">AREA</c-> <c- e="">ALT</c-><c- o="">=</c-><c- s="">"Toys"</c-> <c- e="">COORDS</c-><c- o="">=</c-><c- s="">"100,0,200,50"</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/toys/"</c-><c- p="">&gt;</c-> |
   <c- p="">&lt;</c-><c- f="">A</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/food/"</c-><c- p="">&gt;</c->Food<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">AREA</c-> <c- e="">ALT</c-><c- o="">=</c-><c- s="">"Food"</c-> <c- e="">COORDS</c-><c- o="">=</c-><c- s="">"200,0,300,50"</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/food/"</c-><c- p="">&gt;</c-> |
   <c- p="">&lt;</c-><c- f="">A</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/books/"</c-><c- p="">&gt;</c->Books<c- p="">&lt;/</c-><c- f="">A</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">AREA</c-> <c- e="">ALT</c-><c- o="">=</c-><c- s="">"Books"</c-> <c- e="">COORDS</c-><c- o="">=</c-><c- s="">"300,0,400,50"</c-> <c- e="">HREF</c-><c- o="">=</c-><c- s="">"/books/"</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">P</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">MAP</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">FOOTER</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-area-element"><span class="secno">4.8.13</span> The <dfn data-dfn-type="element"><code>area</code></dfn> element<a href="#the-area-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/area" title="The <area> HTML element defines an area inside an image map that has predefined clickable areas. An image map allows geometric areas on an image to be associated with hypertext links.">Element/area</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement" title="The HTMLAreaElement interface provides special properties and methods (beyond those of the regular object HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of <area> elements.">HTMLAreaElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/rel" title="The HTMLAreaElement.rel property reflects the rel attribute. It is a string containing a space-separated list of link types indicating the relationship between the resource represented by the <area> element and the current document.">HTMLAreaElement/rel</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>30+</span></span><span class="safari yes"><span>Safari</span><span>9+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/relList" title="The HTMLAreaElement.relList read-only property reflects the rel attribute. It is a live DOMTokenList containing the set of link types indicating the relationship between the resource represented by the <area> element and the current document.">HTMLAreaElement/relList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>30+</span></span><span class="safari yes"><span>Safari</span><span>9+</span></span><span class="chrome yes"><span>Chrome</span><span>65+</span></span><hr><span class="opera yes"><span>Opera</span><span>41+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>41+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-area-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-area-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-area-element:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-contexts" id="the-area-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-area-element:phrasing-content-2-2">phrasing content</a> is expected, but only if there is a <code id="the-area-element:the-map-element"><a href="#the-map-element">map</a></code> element ancestor.</dd><dt><a href="#concept-element-content-model" id="the-area-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-area-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-area-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-area-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-area-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-area-element:global-attributes">Global attributes</a></dd><dd><code id="the-area-element:attr-area-alt"><a href="#attr-area-alt">alt</a></code> —  Replacement text for use when images are not available
     </dd><dd><code id="the-area-element:attr-area-coords"><a href="#attr-area-coords">coords</a></code> —  Coordinates for the shape to be created in an <a href="#image-map" id="the-area-element:image-map">image map</a>
     </dd><dd><code id="the-area-element:attr-area-shape"><a href="#attr-area-shape">shape</a></code> —  The kind of shape to be created in an <a href="#image-map" id="the-area-element:image-map-2">image map</a>
     </dd><dd><code id="the-area-element:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> —  Address of the <a href="#hyperlink" id="the-area-element:hyperlink">hyperlink</a>
     </dd><dd><code id="the-area-element:attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code> —  <a href="#navigable" id="the-area-element:navigable">Navigable</a> for <a href="#hyperlink" id="the-area-element:hyperlink-2">hyperlink</a> <a href="#navigate" id="the-area-element:navigate">navigation</a>
     </dd><dd><code id="the-area-element:attr-hyperlink-download"><a href="#attr-hyperlink-download">download</a></code> —  Whether to download the resource instead of navigating to it, and its filename if so
     </dd><dd><code id="the-area-element:ping"><a href="#ping">ping</a></code> —  <a href="https://url.spec.whatwg.org/#concept-url" id="the-area-element:url" data-x-internal="url">URLs</a> to ping
     </dd><dd><code id="the-area-element:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code> —  Relationship between the location in the document containing the <a href="#hyperlink" id="the-area-element:hyperlink-3">hyperlink</a> and the destination resource
     </dd><dd><code id="the-area-element:attr-hyperlink-referrerpolicy"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code> —  <a id="the-area-element:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">Referrer policy</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-area-element:concept-fetch" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-area-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd>If the element has an <code id="the-area-element:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> attribute: <a href="https://w3c.github.io/html-aria/#el-area">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-area">for implementers</a>.</dd><dd>Otherwise: <a href="https://w3c.github.io/html-aria/#el-area-no-href">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-area-no-href">for implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-area-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlareaelement" data-dfn-type="interface"><c- g="">HTMLAreaElement</c-></dfn> : <a href="#htmlelement" id="the-area-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-area-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-area-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-area-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAreaElement" id="dom-area-alt" data-dfn-type="attribute"><c- g="">alt</c-></dfn>;
  [<a href="#cereactions" id="the-area-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-area-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAreaElement" id="dom-area-coords" data-dfn-type="attribute"><c- g="">coords</c-></dfn>;
  [<a href="#cereactions" id="the-area-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-area-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAreaElement" id="dom-area-shape" data-dfn-type="attribute"><c- g="">shape</c-></dfn>;
  [<a href="#cereactions" id="the-area-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-area-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAreaElement" id="dom-area-target" data-dfn-type="attribute"><c- g="">target</c-></dfn>;
  [<a href="#cereactions" id="the-area-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-area-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAreaElement" id="dom-area-download" data-dfn-type="attribute"><c- g="">download</c-></dfn>;
  [<a href="#cereactions" id="the-area-element:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-area-element:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLAreaElement" id="dom-area-ping" data-dfn-type="attribute"><c- g="">ping</c-></dfn>;
  [<a href="#cereactions" id="the-area-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-area-element:xattr-reflect-7"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAreaElement" id="dom-area-rel" data-dfn-type="attribute"><c- g="">rel</c-></dfn>;
  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-area-element:dom-domtokenlist-value" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-area-element:xattr-reflect-8">Reflect</a>="<a href="#attr-hyperlink-rel" id="the-area-element:attr-hyperlink-rel-2">rel</a>"] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-area-element:domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLAreaElement" id="dom-area-rellist" data-dfn-type="attribute"><c- g="">relList</c-></dfn>;
  [<a href="#cereactions" id="the-area-element:cereactions-8"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-area-referrerpolicy" id="the-area-element:dom-area-referrerpolicy"><c- g="">referrerPolicy</c-></a>;

  // <a href="#HTMLAreaElement-partial">also has obsolete members</a>
};
<a href="#htmlareaelement" id="the-area-element:htmlareaelement"><c- n="">HTMLAreaElement</c-></a> <c- b="">includes</c-> <a href="#htmlhyperlinkelementutils" id="the-area-element:htmlhyperlinkelementutils"><c- n="">HTMLHyperlinkElementUtils</c-></a>;</code></pre>
   </dd></dl>

  <p>The <code id="the-area-element:the-area-element"><a href="#the-area-element">area</a></code> element <a href="#represents" id="the-area-element:represents">represents</a> either a hyperlink with some text and a
  corresponding area on an <a href="#image-map" id="the-area-element:image-map-3">image map</a>, or a dead area on an image map.</p>

  <p>An <code id="the-area-element:the-area-element-2"><a href="#the-area-element">area</a></code> element with a parent node must have a <code id="the-area-element:the-map-element-2"><a href="#the-map-element">map</a></code> element
  ancestor.</p>

  <p>If the <code id="the-area-element:the-area-element-3"><a href="#the-area-element">area</a></code> element has an <code id="the-area-element:attr-hyperlink-href-3"><a href="#attr-hyperlink-href">href</a></code>
  attribute, then the <code id="the-area-element:the-area-element-4"><a href="#the-area-element">area</a></code> element represents a <a href="#hyperlink" id="the-area-element:hyperlink-4">hyperlink</a>. In this case,
  the <dfn data-dfn-for="area" id="attr-area-alt" data-dfn-type="element-attr"><code>alt</code></dfn> attribute must be
  present. It specifies the text of the hyperlink. Its value must be text that, when presented with
  the texts specified for the other hyperlinks of the <a href="#image-map" id="the-area-element:image-map-4">image map</a>, and with the
  alternative text of the image, but without the image itself, provides the user with the same kind
  of choice as the hyperlink would when used without its text but with its shape applied to the
  image. The <code id="the-area-element:attr-area-alt-2"><a href="#attr-area-alt">alt</a></code> attribute may be left blank if there is another
  <code id="the-area-element:the-area-element-5"><a href="#the-area-element">area</a></code> element in the same <a href="#image-map" id="the-area-element:image-map-5">image map</a> that points to the same resource and
  has a non-blank <code id="the-area-element:attr-area-alt-3"><a href="#attr-area-alt">alt</a></code> attribute.</p>

  <p>If the <code id="the-area-element:the-area-element-6"><a href="#the-area-element">area</a></code> element has no <code id="the-area-element:attr-hyperlink-href-4"><a href="#attr-hyperlink-href">href</a></code>
  attribute, then the area represented by the element cannot be selected, and the <code id="the-area-element:attr-area-alt-4"><a href="#attr-area-alt">alt</a></code> attribute must be omitted.</p>

  <p>In both cases, the <code id="the-area-element:attr-area-shape-2"><a href="#attr-area-shape">shape</a></code> and <code id="the-area-element:attr-area-coords-2"><a href="#attr-area-coords">coords</a></code> attributes specify the area.</p>

  <p>The <dfn data-dfn-for="area" id="attr-area-shape" data-dfn-type="element-attr"><code>shape</code></dfn> attribute is
  an <a href="#enumerated-attribute" id="the-area-element:enumerated-attribute">enumerated attribute</a> with the following keywords and states:</p>

  <table class="yesno"><thead><tr><th>Keyword
     </th><th>Conforming
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn id="attr-area-shape-keyword-circle"><code>circle</code></dfn>
     </td><td>
     </td><td rowspan="2"><a href="#attr-area-shape-circle" id="the-area-element:attr-area-shape-circle">Circle state</a>
     </td><td rowspan="2">Designates a circle, using exactly three integers in the <code id="the-area-element:attr-area-coords-3"><a href="#attr-area-coords">coords</a></code> attribute.
    </td></tr><tr><td><dfn id="attr-area-shape-keyword-circ"><code>circ</code></dfn>
     </td><td class="no">No
    </td></tr><tr><td><dfn id="attr-area-shape-keyword-default"><code>default</code></dfn>
     </td><td>
     </td><td><a href="#attr-area-shape-default" id="the-area-element:attr-area-shape-default">Default state</a>
     </td><td>This area is the whole image. (The <code id="the-area-element:attr-area-coords-4"><a href="#attr-area-coords">coords</a></code>
     attribute is not used.)
    </td></tr><tr><td><dfn id="attr-area-shape-keyword-poly"><code>poly</code></dfn>
     </td><td>
     </td><td rowspan="2"><a href="#attr-area-shape-poly" id="the-area-element:attr-area-shape-poly">Polygon state</a>
     </td><td rowspan="2">Designates a polygon, using at-least six integers in the <code id="the-area-element:attr-area-coords-5"><a href="#attr-area-coords">coords</a></code> attribute.
    </td></tr><tr><td><dfn id="attr-area-shape-keyword-polygon"><code>polygon</code></dfn>
     </td><td class="no">No
    </td></tr><tr><td><dfn id="attr-area-shape-keyword-rect"><code>rect</code></dfn>
     </td><td>
     </td><td rowspan="2"><a href="#attr-area-shape-rect" id="the-area-element:attr-area-shape-rect">Rectangle state</a>
     </td><td rowspan="2">Designates a rectangle, using exactly four integers in the <code id="the-area-element:attr-area-coords-6"><a href="#attr-area-coords">coords</a></code> attribute.
    </td></tr><tr><td><dfn id="attr-area-shape-keyword-rectangle"><code>rectangle</code></dfn>
     </td><td class="no">No
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-area-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-area-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#attr-area-shape-rect" id="the-area-element:attr-area-shape-rect-2">rectangle</a> state.</p>
  </div>

  <p>The <dfn data-dfn-for="area" id="attr-area-coords" data-dfn-type="element-attr"><code>coords</code></dfn> attribute
  must, if specified, contain a <a href="#valid-list-of-floating-point-numbers" id="the-area-element:valid-list-of-floating-point-numbers">valid list of floating-point numbers</a>. This attribute
  gives the coordinates for the shape described by the <code id="the-area-element:attr-area-shape-3"><a href="#attr-area-shape">shape</a></code>
  attribute. The processing for this attribute is described as part of the <a href="#image-map" id="the-area-element:image-map-6">image
  map</a> processing model.</p>

  

  <p>In the <dfn data-dfn-for="area/shape" id="attr-area-shape-circle" data-dfn-type="attr-value">circle state</dfn>,
  <code id="the-area-element:the-area-element-7"><a href="#the-area-element">area</a></code> elements must have a <code id="the-area-element:attr-area-coords-7"><a href="#attr-area-coords">coords</a></code> attribute
  present, with three integers, the last of which must be non-negative. The first integer must be
  the distance in <a href="https://drafts.csswg.org/css-values/#px" id="the-area-element:'px'" data-x-internal="'px'">CSS pixels</a> from the left edge of the image to the
  center of the circle, the second integer must be the distance in <a href="https://drafts.csswg.org/css-values/#px" id="the-area-element:'px'-2" data-x-internal="'px'">CSS
  pixels</a> from the top edge of the image to the center of the circle, and the third integer
  must be the radius of the circle, again in <a href="https://drafts.csswg.org/css-values/#px" id="the-area-element:'px'-3" data-x-internal="'px'">CSS pixels</a>.</p>

  <p>In the <dfn data-dfn-for="area/shape" id="attr-area-shape-default" data-dfn-type="attr-value">default state</dfn>,
  <code id="the-area-element:the-area-element-8"><a href="#the-area-element">area</a></code> elements must not have a <code id="the-area-element:attr-area-coords-8"><a href="#attr-area-coords">coords</a></code>
  attribute. (The area is the whole image.)</p>

  <p>In the <dfn data-dfn-for="area/shape" id="attr-area-shape-poly" data-dfn-type="attr-value">polygon state</dfn>,
  <code id="the-area-element:the-area-element-9"><a href="#the-area-element">area</a></code> elements must have a <code id="the-area-element:attr-area-coords-9"><a href="#attr-area-coords">coords</a></code> attribute
  with at least six integers, and the number of integers must be even. Each pair of integers must
  represent a coordinate given as the distances from the left and the top of the image in <a href="https://drafts.csswg.org/css-values/#px" id="the-area-element:'px'-4" data-x-internal="'px'">CSS pixels</a> respectively, and all the coordinates together must represent the
  points of the polygon, in order.</p>

  <p>In the <dfn data-dfn-for="area/shape" id="attr-area-shape-rect" data-dfn-type="attr-value">rectangle state</dfn>,
  <code id="the-area-element:the-area-element-10"><a href="#the-area-element">area</a></code> elements must have a <code id="the-area-element:attr-area-coords-10"><a href="#attr-area-coords">coords</a></code> attribute
  with exactly four integers, the first of which must be less than the third, and the second of
  which must be less than the fourth. The four points must represent, respectively, the distance
  from the left edge of the image to the left side of the rectangle, the distance from the top edge
  to the top side, the distance from the left edge to the right side, and the distance from the top
  edge to the bottom side, all in <a href="https://drafts.csswg.org/css-values/#px" id="the-area-element:'px'-5" data-x-internal="'px'">CSS pixels</a>.</p>

  

  <p>When user agents allow users to <a href="#following-hyperlinks-2" id="the-area-element:following-hyperlinks-2">follow hyperlinks</a> or
  <a href="#downloading-hyperlinks" id="the-area-element:downloading-hyperlinks">download hyperlinks</a> created using the
  <code id="the-area-element:the-area-element-11"><a href="#the-area-element">area</a></code> element, the <code id="the-area-element:attr-hyperlink-href-5"><a href="#attr-hyperlink-href">href</a></code>, <code id="the-area-element:attr-hyperlink-target-2"><a href="#attr-hyperlink-target">target</a></code>, <code id="the-area-element:attr-hyperlink-download-2"><a href="#attr-hyperlink-download">download</a></code>, and <code id="the-area-element:ping-2"><a href="#ping">ping</a></code> attributes decide how the link is followed. The <code id="the-area-element:attr-hyperlink-rel-3"><a href="#attr-hyperlink-rel">rel</a></code> attribute may be used to indicate to the user the likely
  nature of the target resource before the user follows the link.</p>

  

  <p>The <code id="the-area-element:attr-hyperlink-target-3"><a href="#attr-hyperlink-target">target</a></code>, <code id="the-area-element:attr-hyperlink-download-3"><a href="#attr-hyperlink-download">download</a></code>, <code id="the-area-element:ping-3"><a href="#ping">ping</a></code>,
  <code id="the-area-element:attr-hyperlink-rel-4"><a href="#attr-hyperlink-rel">rel</a></code>, and <code id="the-area-element:attr-hyperlink-referrerpolicy-2"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code> attributes must be omitted if the
  <code id="the-area-element:attr-hyperlink-href-6"><a href="#attr-hyperlink-href">href</a></code> attribute is not present.</p>

  <p>If the <code id="the-area-element:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is specified on an
  <code id="the-area-element:the-area-element-12"><a href="#the-area-element">area</a></code> element, then the <code id="the-area-element:attr-hyperlink-href-7"><a href="#attr-hyperlink-href">href</a></code> attribute must
  also be specified.</p>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLAreaElement/referrerPolicy" title="The HTMLAreaElement.referrerPolicy property reflect the HTML referrerpolicy attribute of the <area> element defining which referrer is sent when fetching the resource.">HTMLAreaElement/referrerPolicy</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>52+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The IDL attribute <dfn data-dfn-for="HTMLAreaElement" id="dom-area-referrerpolicy" data-dfn-type="attribute"><code>referrerPolicy</code></dfn> must <a href="#reflect" id="the-area-element:reflect">reflect</a> the <code id="the-area-element:attr-hyperlink-referrerpolicy-3"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code> content attribute, <a href="#limited-to-only-known-values" id="the-area-element:limited-to-only-known-values">limited to
  only known values</a>.</p>
  </div>

  



  <h4 id="image-maps"><span class="secno">4.8.14</span> Image maps<a href="#image-maps" class="self-link"></a></h4>

  

  

  <h5 id="authoring"><span class="secno">4.8.14.1</span> Authoring<a href="#authoring" class="self-link"></a></h5>

  

  <p>An <dfn id="image-map">image map</dfn> allows geometric areas on an image to be associated with <a href="#hyperlink" id="authoring:hyperlink">hyperlinks</a>.</p>

  <p>An image, in the form of an <code id="authoring:the-img-element"><a href="#the-img-element">img</a></code> element, may be associated with an image map (in
  the form of a <code id="authoring:the-map-element"><a href="#the-map-element">map</a></code> element) by specifying a <dfn data-dfn-for="img" id="attr-hyperlink-usemap" data-dfn-type="element-attr"><code>usemap</code></dfn> attribute on the <code id="authoring:the-img-element-2"><a href="#the-img-element">img</a></code> element. The
  <code id="authoring:attr-hyperlink-usemap"><a href="#attr-hyperlink-usemap">usemap</a></code> attribute, if specified, must be a <a href="#valid-hash-name-reference" id="authoring:valid-hash-name-reference">valid
  hash-name reference</a> to a <code id="authoring:the-map-element-2"><a href="#the-map-element">map</a></code> element.</p>

  <div class="example">

   <p>Consider an image that looks as follows:</p>

   <p><img src="/images/sample-usemap.png" width="600" alt="A line with four shapes in it, equally spaced: a red hollow box, a green circle, a blue triangle, and a yellow four-pointed star." height="150"></p>

   <p>If we wanted just the colored areas to be clickable, we could do it as follows:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 Please select a shape:
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"shapes.png"</c-> <c- e="">usemap</c-><c- o="">=</c-><c- s="">"#shapes"</c->
      <c- e="">alt</c-><c- o="">=</c-><c- s="">"Four shapes are available: a red hollow box, a green circle, a blue triangle, and a yellow four-pointed star."</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">map</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"shapes"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">area</c-> <c- e="">shape</c-><c- o="">=</c-><c- s="">rect</c-> <c- e="">coords</c-><c- o="">=</c-><c- s="">"50,50,100,100"</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- the hole in the red box --&gt;</c->
  <c- p="">&lt;</c-><c- f="">area</c-> <c- e="">shape</c-><c- o="">=</c-><c- s="">rect</c-> <c- e="">coords</c-><c- o="">=</c-><c- s="">"25,25,125,125"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"red.html"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Red box."</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">area</c-> <c- e="">shape</c-><c- o="">=</c-><c- s="">circle</c-> <c- e="">coords</c-><c- o="">=</c-><c- s="">"200,75,50"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"green.html"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Green circle."</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">area</c-> <c- e="">shape</c-><c- o="">=</c-><c- s="">poly</c-> <c- e="">coords</c-><c- o="">=</c-><c- s="">"325,25,262,125,388,125"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"blue.html"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Blue triangle."</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">area</c-> <c- e="">shape</c-><c- o="">=</c-><c- s="">poly</c-> <c- e="">coords</c-><c- o="">=</c-><c- s="">"450,25,435,60,400,75,435,90,450,125,465,90,500,75,465,60"</c->
        <c- e="">href</c-><c- o="">=</c-><c- s="">"yellow.html"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Yellow star."</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">map</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <h5 id="image-map-processing-model"><span class="secno">4.8.14.2</span> <span id="processing-model"></span>Processing model<a href="#image-map-processing-model" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>If an <code id="image-map-processing-model:the-img-element"><a href="#the-img-element">img</a></code> element has a <code id="image-map-processing-model:attr-hyperlink-usemap"><a href="#attr-hyperlink-usemap">usemap</a></code>
  attribute specified, user agents must process it as follows:</p>

  <ol><li><p>Parse the attribute's value using the <a href="#rules-for-parsing-a-hash-name-reference" id="image-map-processing-model:rules-for-parsing-a-hash-name-reference">rules for parsing a hash-name reference</a>
   to a <code id="image-map-processing-model:the-map-element"><a href="#the-map-element">map</a></code> element, with the element as the context node. This will return either an
   element (the <var>map</var>) or null.</p></li><li><p>If that returned null, then return. The image is not associated with an image
   map after all.</p></li><li><p>Otherwise, the user agent must collect all the <code id="image-map-processing-model:the-area-element"><a href="#the-area-element">area</a></code> elements that are
   descendants of the <var>map</var>. Let <var>areas</var> be that list.</p></li></ol>

  <p>Having obtained the list of <code id="image-map-processing-model:the-area-element-2"><a href="#the-area-element">area</a></code> elements that form the image map (the <var>areas</var>), interactive user agents must process the list in one of two ways.</p>

  <p>If the user agent intends to show the text that the <code id="image-map-processing-model:the-img-element-2"><a href="#the-img-element">img</a></code> element represents, then
  it must use the following steps:</p>

  <ol><li><p>Remove all the <code id="image-map-processing-model:the-area-element-3"><a href="#the-area-element">area</a></code> elements in <var>areas</var> that have no <code id="image-map-processing-model:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute.</p></li><li><p>Remove all the <code id="image-map-processing-model:the-area-element-4"><a href="#the-area-element">area</a></code> elements in <var>areas</var> that have no <code id="image-map-processing-model:attr-area-alt"><a href="#attr-area-alt">alt</a></code> attribute, or whose <code id="image-map-processing-model:attr-area-alt-2"><a href="#attr-area-alt">alt</a></code>
   attribute's value is the empty string, <em>if</em> there is another <code id="image-map-processing-model:the-area-element-5"><a href="#the-area-element">area</a></code> element in
   <var>areas</var> with the same value in the <code id="image-map-processing-model:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> attribute and with a non-empty <code id="image-map-processing-model:attr-area-alt-3"><a href="#attr-area-alt">alt</a></code> attribute.</p></li><li><p>Each remaining <code id="image-map-processing-model:the-area-element-6"><a href="#the-area-element">area</a></code> element in <var>areas</var> represents a
   <a href="#hyperlink" id="image-map-processing-model:hyperlink">hyperlink</a>. Those hyperlinks should all be made available to the user in a manner
   associated with the text of the <code id="image-map-processing-model:the-img-element-3"><a href="#the-img-element">img</a></code>.</p>

   <p>In this context, user agents may represent <code id="image-map-processing-model:the-area-element-7"><a href="#the-area-element">area</a></code> and <code id="image-map-processing-model:the-img-element-4"><a href="#the-img-element">img</a></code> elements
   with no specified <code>alt</code> attributes, or whose <code>alt</code>
   attributes are the empty string or some other non-visible text, in an
   <a id="image-map-processing-model:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> fashion intended to indicate the lack of suitable
   author-provided text.</p></li></ol>

  <p>If the user agent intends to show the image and allow interaction with the image to select
  hyperlinks, then the image must be associated with a set of layered shapes, taken from the
  <code id="image-map-processing-model:the-area-element-8"><a href="#the-area-element">area</a></code> elements in <var>areas</var>, in reverse <a id="image-map-processing-model:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> (so the last
  specified <code id="image-map-processing-model:the-area-element-9"><a href="#the-area-element">area</a></code> element in the <var>map</var> is the bottom-most shape, and
  the first element in the <var>map</var>, in <a id="image-map-processing-model:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, is the top-most shape).</p>
  </div>

  <div data-algorithm="">
  <p>Each <code id="image-map-processing-model:the-area-element-10"><a href="#the-area-element">area</a></code> element in <var>areas</var> must be processed as follows to
  obtain a shape to layer onto the image:</p>

  <ol><li><p>Find the state that the element's <code id="image-map-processing-model:attr-area-shape"><a href="#attr-area-shape">shape</a></code> attribute
   represents.</p></li><li><p>Use the <a href="#rules-for-parsing-a-list-of-floating-point-numbers" id="image-map-processing-model:rules-for-parsing-a-list-of-floating-point-numbers">rules for parsing a list of floating-point numbers</a> to parse the
   element's <code id="image-map-processing-model:attr-area-coords"><a href="#attr-area-coords">coords</a></code> attribute, if it is present, and let the
   <var>coords</var> list be the result. If the attribute is absent, let the <var>coords</var> list
   be the empty list.</p></li><li>
    <p>If the number of items in the <var>coords</var> list is less than the minimum number
    given for the <code id="image-map-processing-model:the-area-element-11"><a href="#the-area-element">area</a></code> element's current state, as per the following table, then the
    shape is empty; return.</p>

    <table><thead><tr><th>State
       </th><th>Minimum number of items
     </th></tr></thead><tbody><tr><td><a href="#attr-area-shape-circle" id="image-map-processing-model:attr-area-shape-circle">Circle state</a>
       </td><td>3
      </td></tr><tr><td><a href="#attr-area-shape-default" id="image-map-processing-model:attr-area-shape-default">Default state</a>
       </td><td>0
      </td></tr><tr><td><a href="#attr-area-shape-poly" id="image-map-processing-model:attr-area-shape-poly">Polygon state</a>
       </td><td>6
      </td></tr><tr><td><a href="#attr-area-shape-rect" id="image-map-processing-model:attr-area-shape-rect">Rectangle state</a>
       </td><td>4
    </td></tr></tbody></table>
   </li><li>
    <p>Check for excess items in the <var>coords</var> list as per the entry in the
    following list corresponding to the <code id="image-map-processing-model:attr-area-shape-2"><a href="#attr-area-shape">shape</a></code> attribute's
    state:</p>

    <dl class="switch"><dt><a href="#attr-area-shape-circle" id="image-map-processing-model:attr-area-shape-circle-2">Circle state</a></dt><dd>Drop any items in the list beyond the third.</dd><dt><a href="#attr-area-shape-default" id="image-map-processing-model:attr-area-shape-default-2">Default state</a></dt><dd>Drop all items in the list.</dd><dt><a href="#attr-area-shape-poly" id="image-map-processing-model:attr-area-shape-poly-2">Polygon state</a></dt><dd>Drop the last item if there's an odd number of items.</dd><dt><a href="#attr-area-shape-rect" id="image-map-processing-model:attr-area-shape-rect-2">Rectangle state</a></dt><dd>Drop any items in the list beyond the fourth.</dd></dl>
   </li><li><p>If the <code id="image-map-processing-model:attr-area-shape-3"><a href="#attr-area-shape">shape</a></code> attribute represents the <a href="#attr-area-shape-rect" id="image-map-processing-model:attr-area-shape-rect-3">rectangle state</a>, and the first number in the list is
   numerically greater than the third number in the list, then swap those two numbers around.</p></li><li><p>If the <code id="image-map-processing-model:attr-area-shape-4"><a href="#attr-area-shape">shape</a></code> attribute represents the <a href="#attr-area-shape-rect" id="image-map-processing-model:attr-area-shape-rect-4">rectangle state</a>, and the second number in the list is
   numerically greater than the fourth number in the list, then swap those two numbers around.</p></li><li><p>If the <code id="image-map-processing-model:attr-area-shape-5"><a href="#attr-area-shape">shape</a></code> attribute represents the <a href="#attr-area-shape-circle" id="image-map-processing-model:attr-area-shape-circle-3">circle state</a>, and the third number in the list is less than
   or equal to zero, then the shape is empty; return.</p></li><li><p>Now, the shape represented by the element is the one described for the entry in the list
   below corresponding to the state of the <code id="image-map-processing-model:attr-area-shape-6"><a href="#attr-area-shape">shape</a></code> attribute:</p>

    <dl class="switch"><dt><a href="#attr-area-shape-circle" id="image-map-processing-model:attr-area-shape-circle-4">Circle state</a></dt><dd>
      <p>Let <var>x</var> be the first number in <var>coords</var>, <var>y</var> be the second number, and <var>r</var> be the third number.</p>

      <p>The shape is a circle whose center is <var>x</var> <a href="https://drafts.csswg.org/css-values/#px" id="image-map-processing-model:'px'" data-x-internal="'px'">CSS pixels</a>
      from the left edge of the image and <var>y</var> <a href="https://drafts.csswg.org/css-values/#px" id="image-map-processing-model:'px'-2" data-x-internal="'px'">CSS pixels</a> from
      the top edge of the image, and whose radius is <var>r</var> <a href="https://drafts.csswg.org/css-values/#px" id="image-map-processing-model:'px'-3" data-x-internal="'px'">CSS
      pixels</a>.</p>
     </dd><dt><a href="#attr-area-shape-default" id="image-map-processing-model:attr-area-shape-default-3">Default state</a></dt><dd>
      <p>The shape is a rectangle that exactly covers the entire image.</p>
     </dd><dt><a href="#attr-area-shape-poly" id="image-map-processing-model:attr-area-shape-poly-3">Polygon state</a></dt><dd>
      <p>Let <var>x<sub><var>i</var></sub></var> be the <span>(2<var>i</var>)</span>th entry in <var>coords</var>, and <var>y<sub><var>i</var></sub></var> be the <span>(2<var>i</var>+1)</span>th entry in <var>coords</var> (the first entry in <var>coords</var> being the one with index 0).</p>

      <p>Let <var>the coordinates</var> be (<var>x<sub><var>i</var></sub></var>, <var>y<sub><var>i</var></sub></var>),
      interpreted in <a href="https://drafts.csswg.org/css-values/#px" id="image-map-processing-model:'px'-4" data-x-internal="'px'">CSS pixels</a> measured from the top left of the image,
      for all integer values of <var>i</var> from 0 to <span>(<var>N</var>/2)-1</span>,
      where <var>N</var> is the number of items in <var>coords</var>.</p>

      <p>The shape is a polygon whose vertices are given by <var>the coordinates</var>, and whose
      interior is established using the even-odd rule. <a href="#refsGRAPHICS">[GRAPHICS]</a></p>

      
     </dd><dt><a href="#attr-area-shape-rect" id="image-map-processing-model:attr-area-shape-rect-5">Rectangle state</a></dt><dd>
      <p>Let <var>x<sub>1</sub></var> be the first number in <var>coords</var>, <var>y<sub>1</sub></var> be the second number, <var>x<sub>2</sub></var> be the third number, and <var>y<sub>2</sub></var> be the fourth number.</p>

      <p>The shape is a rectangle whose top-left corner is given by the coordinate (<var>x<sub>1</sub></var>, <var>y<sub>1</sub></var>) and whose
      bottom right corner is given by the coordinate (<var>x<sub>2</sub></var>,
      <var>y<sub>2</sub></var>), those coordinates being interpreted as <a href="https://drafts.csswg.org/css-values/#px" id="image-map-processing-model:'px'-5" data-x-internal="'px'">CSS
      pixels</a> from the top left corner of the image.</p>
     </dd></dl>

    <p>For historical reasons, the coordinates must be interpreted relative to the
    <em>displayed</em> image after any stretching caused by the CSS <a id="image-map-processing-model:'width'" href="https://drafts.csswg.org/css2/#the-width-property" data-x-internal="'width'">'width'</a> and
    <a id="image-map-processing-model:'height'" href="https://drafts.csswg.org/css2/#the-height-property" data-x-internal="'height'">'height'</a> properties (or, for non-CSS browsers, the image element's <code>width</code> and <code>height</code> attributes — CSS browsers map
    those attributes to the aforementioned CSS properties).</p>

    <p class="note">Browser zoom features and transforms applied using CSS or SVG do not affect the
    coordinates.</p>
   </li></ol>
  </div>

  <p>Pointing device interaction with an image associated with a set of layered shapes per the above
  algorithm must result in the relevant user interaction events being first fired to the top-most
  shape covering the point that the pointing device indicated, if any, or to the image element
  itself, if there is no shape covering that point. User agents may also allow individual
  <code id="image-map-processing-model:the-area-element-12"><a href="#the-area-element">area</a></code> elements representing <a href="#hyperlink" id="image-map-processing-model:hyperlink-2">hyperlinks</a> to be selected
  and activated (e.g. using a keyboard).</p>

  <p class="note">Because a <code id="image-map-processing-model:the-map-element-2"><a href="#the-map-element">map</a></code> element (and its <code id="image-map-processing-model:the-area-element-13"><a href="#the-area-element">area</a></code> elements) can be
  associated with multiple <code id="image-map-processing-model:the-img-element-5"><a href="#the-img-element">img</a></code> elements, it is possible for an <code id="image-map-processing-model:the-area-element-14"><a href="#the-area-element">area</a></code>
  element to correspond to multiple <i id="image-map-processing-model:focusable-area"><a href="#focusable-area">focusable areas</a></i> of the
  document.</p>

  <p>Image maps are <a href="#live" id="image-map-processing-model:live">live</a>; if the DOM is mutated, then the user agent must act as if it
  had rerun the algorithms for image maps.</p>

  



  <h4 id="mathml"><span class="secno">4.8.15</span> MathML<a href="#mathml" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/HTML5_Parser#Inline_SVG_and_MathML_support" title="To build websites, you should know about HTML — the fundamental technology used to define the structure of a webpage. HTML is used to specify whether your web content should be recognized as a paragraph, list, heading, link, image, multimedia player, form, or one of many other available elements or even a new element that you define.">HTML/HTML5/HTML5_Parser#Inline_SVG_and_MathML_support</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>7+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>5+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div>

  <p>The <a id="mathml:mathml-math" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a> element falls into the <a href="#embedded-content-category" id="mathml:embedded-content-category">embedded content</a>,
  <a href="#phrasing-content-2" id="mathml:phrasing-content-2">phrasing content</a>, <a href="#flow-content-2" id="mathml:flow-content-2">flow content</a>, and <a href="#palpable-content-2" id="mathml:palpable-content-2">palpable content</a>
  categories for the purposes of the content models in this specification.</p>

  <p>When the <a id="mathml:mathml-annotation-xml" href="https://w3c.github.io/mathml-core/#dfn-annotation-xml" data-x-internal="mathml-annotation-xml">MathML <code>annotation-xml</code></a> element contains elements from the
  <a id="mathml:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, such elements must all be <a href="#flow-content-2" id="mathml:flow-content-2-2">flow content</a>.</p>

  <p>When the MathML token elements (<code id="mathml:mathml-mi"><a data-x-internal="mathml-mi" href="https://w3c.github.io/mathml-core/#the-mi-element">mi</a></code>, <code id="mathml:mathml-mo"><a data-x-internal="mathml-mo" href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo">mo</a></code>, <code id="mathml:mathml-mn"><a data-x-internal="mathml-mn" href="https://w3c.github.io/mathml-core/#number-mn">mn</a></code>, <code id="mathml:mathml-ms"><a data-x-internal="mathml-ms" href="https://w3c.github.io/mathml-core/#string-literal-ms">ms</a></code>, and <code id="mathml:mathml-mtext"><a data-x-internal="mathml-mtext" href="https://w3c.github.io/mathml-core/#text-mtext">mtext</a></code>) are descendants of HTML elements, they may contain
  <a href="#phrasing-content-2" id="mathml:phrasing-content-2-2">phrasing content</a> elements from the <a id="mathml:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>.</p>
  

  

  

  <p>User agents must handle text other than <a href="#inter-element-whitespace" id="mathml:inter-element-whitespace">inter-element whitespace</a> found in MathML
  elements whose content models do not allow straight text by pretending for the purposes of MathML
  content models, layout, and rendering that the text is actually wrapped in a <a id="mathml:mathml-mtext-2" href="https://w3c.github.io/mathml-core/#text-mtext" data-x-internal="mathml-mtext">MathML
  <code>mtext</code></a> element. (Such text is not, however, conforming.)</p>

  <p>User agents must act as if any MathML element whose contents does not match the element's
  content model was replaced, for the purposes of MathML layout and rendering, by a <a id="mathml:mathml-merror" href="https://w3c.github.io/mathml-core/#error-message-merror" data-x-internal="mathml-merror">MathML
  <code>merror</code></a> element containing some appropriate error message.</p>

  

  <p>The semantics of MathML elements are defined by <cite>MathML</cite> and <a href="#other-applicable-specifications" id="mathml:other-applicable-specifications">other applicable
  specifications</a>. <a href="#refsMATHML">[MATHML]</a></p>

  <div class="example">

   <p>Here is an example of the use of MathML in an HTML document:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->The quadratic formula<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The quadratic formula<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">math</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->x<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">mo</c-><c- p="">&gt;</c->=<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">mfrac</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">mrow</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">mo</c-> <c- e="">form</c-><c- o="">=</c-><c- s="">"prefix"</c-><c- p="">&gt;</c->−<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->b<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">mo</c-><c- p="">&gt;</c->±<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">msqrt</c-><c- p="">&gt;</c->
       <c- p="">&lt;</c-><c- f="">msup</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->b<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">mn</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">mn</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">msup</c-><c- p="">&gt;</c->
       <c- p="">&lt;</c-><c- f="">mo</c-><c- p="">&gt;</c->−<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c->
       <c- p="">&lt;</c-><c- f="">mn</c-><c- p="">&gt;</c->4<c- p="">&lt;/</c-><c- f="">mn</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">mo</c-><c- p="">&gt;</c->⁢<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->a<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">mo</c-><c- p="">&gt;</c->⁢<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->c<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;</c->
      <c- p="">&lt;/</c-><c- f="">msqrt</c-><c- p="">&gt;</c->
     <c- p="">&lt;/</c-><c- f="">mrow</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">mrow</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">mn</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">mn</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">mo</c-><c- p="">&gt;</c->⁢<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">mi</c-><c- p="">&gt;</c->a<c- p="">&lt;/</c-><c- f="">mi</c-><c- p="">&gt;</c->
     <c- p="">&lt;/</c-><c- f="">mrow</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">mfrac</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">math</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="svg-0"><span class="secno">4.8.16</span> SVG<a href="#svg-0" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/HTML5_Parser#Inline_SVG_and_MathML_support" title="To build websites, you should know about HTML — the fundamental technology used to define the structure of a webpage. HTML is used to specify whether your web content should be recognized as a paragraph, list, heading, link, image, multimedia player, form, or one of many other available elements or even a new element that you define.">HTML/HTML5/HTML5_Parser#Inline_SVG_and_MathML_support</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>37+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>7+</span></span><hr><span class="opera yes"><span>Opera</span><span>15+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>37+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>11.3+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>4+</span></span><span class="opera_android yes"><span>Opera Android</span><span>15+</span></span></div></div></div>

  <p>The <a id="svg-0:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a> element falls into the <a href="#embedded-content-category" id="svg-0:embedded-content-category">embedded content</a>,
  <a href="#phrasing-content-2" id="svg-0:phrasing-content-2">phrasing content</a>, <a href="#flow-content-2" id="svg-0:flow-content-2">flow content</a>, and <a href="#palpable-content-2" id="svg-0:palpable-content-2">palpable content</a>
  categories for the purposes of the content models in this specification.</p>

  <p>When the <a id="svg-0:svg-foreignobject" href="https://svgwg.org/svg2-draft/embedded.html#ForeignObjectElement" data-x-internal="svg-foreignobject">SVG <code>foreignObject</code></a> element contains elements from the
  <a id="svg-0:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, such elements must all be <a href="#flow-content-2" id="svg-0:flow-content-2-2">flow content</a>.</p>

  <p>The content model for the <a id="svg-0:svg-title" href="https://svgwg.org/svg2-draft/struct.html#TitleElement" data-x-internal="svg-title">SVG <code>title</code></a> element inside <a id="svg-0:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML
  documents</a> is <a href="#phrasing-content-2" id="svg-0:phrasing-content-2-2">phrasing content</a>. (This further constrains the requirements given
  in <cite>SVG 2</cite>.)</p>

  <p>The semantics of SVG elements are defined by <cite>SVG 2</cite> and <a href="#other-applicable-specifications" id="svg-0:other-applicable-specifications">other applicable
  specifications</a>. <a href="#refsSVG">[SVG]</a></p>

  <hr>

  <dl class="domintro"><dt><code><var>doc</var> = <var>iframe</var>.<a href="#dom-media-getsvgdocument" id="dom-media-getsvgdocument-dev">getSVGDocument</a>()</code></dt><dt><code><var>doc</var> = <var>embed</var>.<a href="#dom-media-getsvgdocument" id="svg-0:dom-media-getsvgdocument">getSVGDocument</a>()</code></dt><dt><code><var>doc</var> = <var>object</var>.<a href="#dom-media-getsvgdocument" id="svg-0:dom-media-getsvgdocument-2">getSVGDocument</a>()</code></dt><dd><p>Returns the <code id="svg-0:document"><a href="#document">Document</a></code> object, in the case of <code id="svg-0:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>,
   <code id="svg-0:the-embed-element"><a href="#the-embed-element">embed</a></code>, or <code id="svg-0:the-object-element"><a href="#the-object-element">object</a></code> elements being used to embed SVG.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLIFrameElement,HTMLEmbedElement,HTMLObjectElement" id="dom-media-getsvgdocument" data-dfn-type="method"><code>getSVGDocument()</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>document</var> be <a id="svg-0:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-bcc-content-document" id="svg-0:concept-bcc-content-document">content document</a>.</p></li><li><p>If <var>document</var> is non-null and was created by the <a href="#read-xml" id="svg-0:read-xml">page
   load processing model for XML files</a> section because the <a href="https://mimesniff.spec.whatwg.org/#computed-mime-type" id="svg-0:content-type-sniffing-2" data-x-internal="content-type-sniffing-2">computed type of the resource</a> in the <a href="#navigate" id="svg-0:navigate">navigate</a> algorithm was
   <code id="svg-0:image/svg+xml"><a href="#image/svg+xml">image/svg+xml</a></code>, then return <var>document</var>.</p></li><li><p>Return null.</p></li></ol>
  </div>

  



  <h4 id="dimension-attributes"><span class="secno">4.8.17</span> <dfn>Dimension attributes</dfn><a href="#dimension-attributes" class="self-link"></a></h4>

  <p><strong>Author requirements</strong>: The <dfn data-dfn-for="img,iframe,embed,object,source,video" id="attr-dim-width" data-dfn-type="element-attr"><code>width</code></dfn> and
  <dfn data-dfn-for="img,iframe,embed,object,source,video" id="attr-dim-height" data-dfn-type="element-attr"><code>height</code></dfn> attributes on <code id="dimension-attributes:the-img-element"><a href="#the-img-element">img</a></code>, <code id="dimension-attributes:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>,
  <code id="dimension-attributes:the-embed-element"><a href="#the-embed-element">embed</a></code>, <code id="dimension-attributes:the-object-element"><a href="#the-object-element">object</a></code>, <code id="dimension-attributes:the-video-element"><a href="#the-video-element">video</a></code>, <code id="dimension-attributes:the-source-element"><a href="#the-source-element">source</a></code> when the parent
  is a <code id="dimension-attributes:the-picture-element"><a href="#the-picture-element">picture</a></code> element and, when their <code id="dimension-attributes:attr-input-type"><a href="#attr-input-type">type</a></code>
  attribute is in the <a href="#image-button-state-(type=image)" id="dimension-attributes:image-button-state-(type=image)">Image Button</a> state,
  <code id="dimension-attributes:the-input-element"><a href="#the-input-element">input</a></code> elements may be specified to give the dimensions of the visual content of the
  element (the width and height respectively, relative to the nominal direction of the output
  medium), in <a href="https://drafts.csswg.org/css-values/#px" id="dimension-attributes:'px'" data-x-internal="'px'">CSS pixels</a>. The attributes, if specified, must have values
  that are <a href="#valid-non-negative-integer" id="dimension-attributes:valid-non-negative-integer">valid non-negative integers</a>.</p>

  <div data-algorithm="">
  <p>The specified dimensions given may differ from the dimensions specified in the resource itself,
  since the resource may have a resolution that differs from the CSS pixel resolution. (On screens,
  <a href="https://drafts.csswg.org/css-values/#px" id="dimension-attributes:'px'-2" data-x-internal="'px'">CSS pixels</a> have a resolution of 96ppi, but in general the CSS pixel
  resolution depends on the reading distance.) If both attributes are specified, then one of the
  following statements must be true:</p>

  <ul><li><var>specified width</var> - 0.5 ≤
             <var>specified height</var> * <var>target ratio</var> ≤
             <var>specified width</var> + 0.5</li><li><var>specified height</var> - 0.5 ≤
             <var>specified width</var> / <var>target ratio</var> ≤
             <var>specified height</var> + 0.5</li><li><var>specified height</var> = <var>specified width</var> = 0</li></ul>

  <p>The <var>target ratio</var> is the ratio of the <a id="dimension-attributes:natural-width" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> to the
  <a id="dimension-attributes:natural-height" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a> in the resource. The <var>specified width</var> and <var>specified
  height</var> are the values of the <code id="dimension-attributes:attr-dim-width"><a href="#attr-dim-width">width</a></code> and <code id="dimension-attributes:attr-dim-height"><a href="#attr-dim-height">height</a></code> attributes respectively.</p>
  </div>

  <p>The two attributes must be omitted if the resource in question does not have both a
  <a id="dimension-attributes:natural-width-2" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> and a <a id="dimension-attributes:natural-height-2" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a>.</p>

  <p>If the two attributes are both 0, it indicates that the element is not intended for the user
  (e.g. it might be a part of a service to count page views).</p>

  <p class="note">The dimension attributes are not intended to be used to stretch the image.</p>

  

  <p><strong>User agent requirements</strong>: User agents are expected to use these attributes <a href="#dimRendering">as hints for the rendering</a>.</p>

  <p class="note">For <code id="dimension-attributes:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>, <code id="dimension-attributes:the-embed-element-2"><a href="#the-embed-element">embed</a></code> and <code id="dimension-attributes:the-object-element-2"><a href="#the-object-element">object</a></code> the IDL
  attributes are <code id="dimension-attributes:idl-domstring"><a data-x-internal="idl-domstring" href="https://webidl.spec.whatwg.org/#idl-DOMString">DOMString</a></code>; for <code id="dimension-attributes:the-video-element-2"><a href="#the-video-element">video</a></code> and
  <code id="dimension-attributes:the-source-element-2"><a href="#the-source-element">source</a></code> the IDL attributes are <code id="dimension-attributes:idl-unsigned-long"><a data-x-internal="idl-unsigned-long" href="https://webidl.spec.whatwg.org/#idl-unsigned-long">unsigned
  long</a></code>.</p>

  <p class="note">The corresponding IDL attributes for <code id="dimension-attributes:dom-img-height"><a href="#dom-img-height">img</a></code> and
  <code id="dimension-attributes:dom-input-height"><a href="#dom-input-height">input</a></code> elements are defined in those respective elements'
  sections, as they are slightly more specific to those elements' other behaviors.</p>

  



  <h3 id="tables"><span class="secno">4.9</span> Tabular data<a href="#tables" class="self-link"></a></h3>


  <h4 id="the-table-element"><span class="secno">4.9.1</span> The <dfn data-dfn-type="element"><code>table</code></dfn> element<a href="#the-table-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table" title="The <table> HTML element represents tabular data — that is, information presented in a two-dimensional table comprised of rows and columns of cells containing data.">Element/table</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement" title="The HTMLTableElement interface provides special properties and methods (beyond the regular HTMLElement object interface it also has available to it by inheritance) for manipulating the layout and presentation of tables in an HTML document.">HTMLTableElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-table-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-table-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-table-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-table-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-table-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-table-element:concept-element-content-model">Content model</a>:</dt><dd>In this order: optionally a <code id="the-table-element:the-caption-element"><a href="#the-caption-element">caption</a></code> element, followed by zero or more
   <code id="the-table-element:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> elements, followed optionally by a <code id="the-table-element:the-thead-element"><a href="#the-thead-element">thead</a></code> element, followed by
   either zero or more <code id="the-table-element:the-tbody-element"><a href="#the-tbody-element">tbody</a></code> elements or one or more <code id="the-table-element:the-tr-element"><a href="#the-tr-element">tr</a></code> elements, followed
   optionally by a <code id="the-table-element:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> element, optionally intermixed with one or more
   <a href="#script-supporting-elements-2" id="the-table-element:script-supporting-elements-2">script-supporting elements</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-table-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-table-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-table-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-table-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-table">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-table">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-table-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltableelement" data-dfn-type="interface"><c- g="">HTMLTableElement</c-></dfn> : <a href="#htmlelement" id="the-table-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-table-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-table-element:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <a href="#htmltablecaptionelement" id="the-table-element:htmltablecaptionelement"><c- n="">HTMLTableCaptionElement</c-></a>? <a href="#dom-table-caption" id="the-table-element:dom-table-caption"><c- g="">caption</c-></a>;
  <a href="#htmltablecaptionelement" id="the-table-element:htmltablecaptionelement-2"><c- n="">HTMLTableCaptionElement</c-></a> <a href="#dom-table-createcaption" id="the-table-element:dom-table-createcaption"><c- g="">createCaption</c-></a>();
  [<a href="#cereactions" id="the-table-element:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-table-deletecaption" id="the-table-element:dom-table-deletecaption"><c- g="">deleteCaption</c-></a>();

  [<a href="#cereactions" id="the-table-element:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <a href="#htmltablesectionelement" id="the-table-element:htmltablesectionelement"><c- n="">HTMLTableSectionElement</c-></a>? <a href="#dom-table-thead" id="the-table-element:dom-table-thead"><c- g="">tHead</c-></a>;
  <a href="#htmltablesectionelement" id="the-table-element:htmltablesectionelement-2"><c- n="">HTMLTableSectionElement</c-></a> <a href="#dom-table-createthead" id="the-table-element:dom-table-createthead"><c- g="">createTHead</c-></a>();
  [<a href="#cereactions" id="the-table-element:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-table-deletethead" id="the-table-element:dom-table-deletethead"><c- g="">deleteTHead</c-></a>();

  [<a href="#cereactions" id="the-table-element:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <a href="#htmltablesectionelement" id="the-table-element:htmltablesectionelement-3"><c- n="">HTMLTableSectionElement</c-></a>? <a href="#dom-table-tfoot" id="the-table-element:dom-table-tfoot"><c- g="">tFoot</c-></a>;
  <a href="#htmltablesectionelement" id="the-table-element:htmltablesectionelement-4"><c- n="">HTMLTableSectionElement</c-></a> <a href="#dom-table-createtfoot" id="the-table-element:dom-table-createtfoot"><c- g="">createTFoot</c-></a>();
  [<a href="#cereactions" id="the-table-element:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-table-deletetfoot" id="the-table-element:dom-table-deletetfoot"><c- g="">deleteTFoot</c-></a>();

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-table-element:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-table-tbodies" id="the-table-element:dom-table-tbodies"><c- g="">tBodies</c-></a>;
  <a href="#htmltablesectionelement" id="the-table-element:htmltablesectionelement-5"><c- n="">HTMLTableSectionElement</c-></a> <a href="#dom-table-createtbody" id="the-table-element:dom-table-createtbody"><c- g="">createTBody</c-></a>();

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-table-element:htmlcollection-2" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-table-rows" id="the-table-element:dom-table-rows"><c- g="">rows</c-></a>;
  <a href="#htmltablerowelement" id="the-table-element:htmltablerowelement"><c- n="">HTMLTableRowElement</c-></a> <a href="#dom-table-insertrow" id="the-table-element:dom-table-insertrow"><c- g="">insertRow</c-></a>(<c- b="">optional</c-> <c- b="">long</c-> <c- g="">index</c-> = -1);
  [<a href="#cereactions" id="the-table-element:cereactions-7"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-table-deleterow" id="the-table-element:dom-table-deleterow"><c- g="">deleteRow</c-></a>(<c- b="">long</c-> <c- g="">index</c->);

  // <a href="#HTMLTableElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-table-element:the-table-element"><a href="#the-table-element">table</a></code> element <a href="#represents" id="the-table-element:represents">represents</a> data with more than one dimension, in
  the form of a <a href="#concept-table" id="the-table-element:concept-table">table</a>.</p>

  <p>The <code id="the-table-element:the-table-element-2"><a href="#the-table-element">table</a></code> element takes part in the <a href="#table-model" id="the-table-element:table-model">table
  model</a>. Tables have rows, columns, and cells given by their descendants. The rows and
  columns form a grid; a table's cells must completely cover that grid without overlap.</p>

  

  <p class="note">Precise rules for determining whether this conformance requirement is met are
  described in the description of the <a href="#table-model" id="the-table-element:table-model-2">table model</a>.</p>

  

  <p>Authors are encouraged to provide information describing how to interpret complex tables.
  Guidance on how to <a href="#table-descriptions-techniques">provide such information</a> is given
  below.</p>

  <p>Tables must not be used as layout aids. Historically, some web authors have misused tables in
  HTML as a way to control their page layout. This usage is non-conforming, because tools attempting
  to extract tabular data from such documents would obtain very confusing results. In particular,
  users of accessibility tools like screen readers are likely to find it very difficult to navigate
  pages with tables used for layout.</p>

  <p class="note">There are a variety of alternatives to using HTML tables for layout, such as CSS
  grid layout, CSS flexible box layout ("flexbox"), CSS multi-column layout, CSS positioning, and
  the CSS table model. <a href="#refsCSS">[CSS]</a></p>

  

  <hr>

  <p>Tables can be complicated to understand and navigate. To help users with this, user agents
  should clearly delineate cells in a table from each other, unless the user agent has classified
  the table as a (non-conforming) layout table.</p>

  

  <p class="note">Authors and implementers are encouraged to consider
  using some of the <a href="#table-layout-techniques">table design techniques</a> described below
  to make tables easier to navigate for users.</p>

  

  <p>User agents, especially those that do table analysis on arbitrary content, are encouraged to
  find heuristics to determine which tables actually contain data and which are merely being used
  for layout. This specification does not define a precise heuristic, but the following are
  suggested as possible indicators:</p>

  <table><thead><tr><th>Feature
     </th><th>Indication
   </th></tr></thead><tbody><tr><td>The use of the <code id="the-table-element:attr-aria-role"><a href="#attr-aria-role">role</a></code> attribute with the value <code id="the-table-element:attr-aria-role-presentation"><a data-x-internal="attr-aria-role-presentation" href="https://w3c.github.io/aria/#presentation">presentation</a></code>
     </td><td>Probably a layout table
    </td></tr><tr><td>The use of the non-conforming <code id="the-table-element:attr-table-border"><a href="#attr-table-border">border</a></code> attribute with the non-conforming value 0
     </td><td>Probably a layout table
    </td></tr><tr><td>The use of the non-conforming <code id="the-table-element:attr-table-cellspacing"><a href="#attr-table-cellspacing">cellspacing</a></code> and
     <code id="the-table-element:attr-table-cellpadding"><a href="#attr-table-cellpadding">cellpadding</a></code> attributes with the value 0
     </td><td>Probably a layout table
   </td></tr></tbody><tbody><tr><td>The use of <code id="the-table-element:the-caption-element-2"><a href="#the-caption-element">caption</a></code>, <code id="the-table-element:the-thead-element-2"><a href="#the-thead-element">thead</a></code>, or <code id="the-table-element:the-th-element"><a href="#the-th-element">th</a></code> elements
     </td><td>Probably a non-layout table
    </td></tr><tr><td>The use of the <code id="the-table-element:attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> and <code id="the-table-element:attr-th-scope"><a href="#attr-th-scope">scope</a></code> attributes
     </td><td>Probably a non-layout table
    </td></tr><tr><td>The use of the non-conforming <code id="the-table-element:attr-table-border-2"><a href="#attr-table-border">border</a></code> attribute with a value other than 0
     </td><td>Probably a non-layout table
    </td></tr><tr><td>Explicit visible borders set using CSS
     </td><td>Probably a non-layout table
   </td></tr></tbody><tbody><tr><td>The use of the <code id="the-table-element:attr-table-summary"><a href="#attr-table-summary">summary</a></code> attribute
     </td><td>Not a good indicator (both layout and non-layout tables have historically been given this attribute)
  </td></tr></tbody></table>

  <p class="note">It is quite possible that the above suggestions are wrong. Implementers are urged
  to provide feedback elaborating on their experiences with trying to create a layout table
  detection heuristic.</p>

  <p>If a <code id="the-table-element:the-table-element-3"><a href="#the-table-element">table</a></code> element has a (non-conforming) <code id="the-table-element:attr-table-summary-2"><a href="#attr-table-summary">summary</a></code> attribute, and the user agent has not classified the
  table as a layout table, the user agent may report the contents of that attribute to the user.</p>

  

  <hr>

  <dl class="domintro"><dt><code><var>table</var>.<a href="#dom-table-caption" id="dom-table-caption-dev">caption</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/caption" title="The HTMLTableElement.caption property represents the table caption. If no caption element is associated with the table, this property is null.">HTMLTableElement/caption</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the table's <code id="the-table-element:the-caption-element-3"><a href="#the-caption-element">caption</a></code> element.</p>

    <p>Can be set, to replace the <code id="the-table-element:the-caption-element-4"><a href="#the-caption-element">caption</a></code> element.</p>
   </dd><dt><code><var>caption</var> = <var>table</var>.<a href="#dom-table-createcaption" id="dom-table-createcaption-dev">createCaption</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/createCaption" title="The HTMLTableElement.createCaption() method returns the <caption> element associated with a given <table>. If no <caption> element exists on the table, this method creates it, and then returns it.">HTMLTableElement/createCaption</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Ensures the table has a <code id="the-table-element:the-caption-element-5"><a href="#the-caption-element">caption</a></code> element, and returns it.</p></dd><dt><code><var>table</var>.<a href="#dom-table-deletecaption" id="dom-table-deletecaption-dev">deleteCaption</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/deleteCaption" title="The HTMLTableElement.deleteCaption() method removes the <caption> element from a given <table>. If there is no <caption> element associated with the table, this method does nothing.">HTMLTableElement/deleteCaption</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Ensures the table does not have a <code id="the-table-element:the-caption-element-6"><a href="#the-caption-element">caption</a></code> element.</p></dd><dt><code><var>table</var>.<a href="#dom-table-thead" id="dom-table-thead-dev">tHead</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/tHead" title="The HTMLTableElement.tHead represents the <thead> element of a <table>. Its value will be null if there is no such element.">HTMLTableElement/tHead</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the table's <code id="the-table-element:the-thead-element-3"><a href="#the-thead-element">thead</a></code> element.</p>

    <p>Can be set, to replace the <code id="the-table-element:the-thead-element-4"><a href="#the-thead-element">thead</a></code> element. If the new value is not a
    <code id="the-table-element:the-thead-element-5"><a href="#the-thead-element">thead</a></code> element, throws a <a id="the-table-element:hierarchyrequesterror" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a>
    <code id="the-table-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd><dt><code><var>thead</var> = <var>table</var>.<a href="#dom-table-createthead" id="dom-table-createthead-dev">createTHead</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/createTHead" title="The createTHead() method of HTMLTableElement objects returns the <thead> element associated with a given <table>. If no header exists in the table, this method creates it, and then returns it.">HTMLTableElement/createTHead</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Ensures the table has a <code id="the-table-element:the-thead-element-6"><a href="#the-thead-element">thead</a></code> element, and returns it.</p></dd><dt><code><var>table</var>.<a href="#dom-table-deletethead" id="dom-table-deletethead-dev">deleteTHead</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/deleteTHead" title="The HTMLTableElement.deleteTHead() removes the <thead> element from a given <table>.">HTMLTableElement/deleteTHead</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Ensures the table does not have a <code id="the-table-element:the-thead-element-7"><a href="#the-thead-element">thead</a></code> element.</p></dd><dt><code><var>table</var>.<a href="#dom-table-tfoot" id="dom-table-tfoot-dev">tFoot</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/tFoot" title="The HTMLTableElement.tFoot property represents the <tfoot> element of a <table>. Its value will be null if there is no such element.">HTMLTableElement/tFoot</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the table's <code id="the-table-element:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code> element.</p>

    <p>Can be set, to replace the <code id="the-table-element:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code> element. If the new value is not a
    <code id="the-table-element:the-tfoot-element-4"><a href="#the-tfoot-element">tfoot</a></code> element, throws a <a id="the-table-element:hierarchyrequesterror-2" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a>
    <code id="the-table-element:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd><dt><code><var>tfoot</var> = <var>table</var>.<a href="#dom-table-createtfoot" id="dom-table-createtfoot-dev">createTFoot</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/createTFoot" title="The createTFoot() method of HTMLTableElement objects returns the <tfoot> element associated with a given <table>. If no footer exists in the table, this method creates it, and then returns it.">HTMLTableElement/createTFoot</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Ensures the table has a <code id="the-table-element:the-tfoot-element-5"><a href="#the-tfoot-element">tfoot</a></code> element, and returns it.</p></dd><dt><code><var>table</var>.<a href="#dom-table-deletetfoot" id="dom-table-deletetfoot-dev">deleteTFoot</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/deleteTFoot" title="The HTMLTableElement.deleteTFoot() method removes the <tfoot> element from a given <table>.">HTMLTableElement/deleteTFoot</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Ensures the table does not have a <code id="the-table-element:the-tfoot-element-6"><a href="#the-tfoot-element">tfoot</a></code> element.</p></dd><dt><code><var>table</var>.<a href="#dom-table-tbodies" id="dom-table-tbodies-dev">tBodies</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/tBodies" title="The HTMLTableElement.tBodies read-only property returns a live HTMLCollection of the bodies in a <table>.">HTMLTableElement/tBodies</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns an <code id="the-table-element:htmlcollection-3"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="the-table-element:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code> elements of the
   table.</p></dd><dt><code><var>tbody</var> = <var>table</var>.<a href="#dom-table-createtbody" id="dom-table-createtbody-dev">createTBody</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/createTBody" title="The createTBody() method of HTMLTableElement objects creates and returns a new <tbody> element associated with a given <table>.">HTMLTableElement/createTBody</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>25+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Creates a <code id="the-table-element:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code> element, inserts it into the table, and returns it.</p></dd><dt><code><var>table</var>.<a href="#dom-table-rows" id="dom-table-rows-dev">rows</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/rows" title="The read-only HTMLTableElement property rows returns a live HTMLCollection of all the rows in the table, including the rows contained within any <thead>, <tfoot>, and <tbody> elements.">HTMLTableElement/rows</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns an <code id="the-table-element:htmlcollection-4"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="the-table-element:the-tr-element-2"><a href="#the-tr-element">tr</a></code> elements of the
   table.</p></dd><dt><code><var>tr</var> = <var>table</var>.<a href="#dom-table-insertrow" id="dom-table-insertrow-dev">insertRow</a>([ <var>index</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/insertRow" title="The HTMLTableElement.insertRow() method inserts a new row (<tr>) in a given <table>, and returns a reference to the new row.">HTMLTableElement/insertRow</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>10+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Creates a <code id="the-table-element:the-tr-element-3"><a href="#the-tr-element">tr</a></code> element, along with a <code id="the-table-element:the-tbody-element-4"><a href="#the-tbody-element">tbody</a></code> if required, inserts them
    into the table at the position given by the argument, and returns the <code id="the-table-element:the-tr-element-4"><a href="#the-tr-element">tr</a></code>.</p>

    <p>The position is relative to the rows in the table. The index −1, which is the default
    if the argument is omitted, is equivalent to inserting at the end of the table.</p>

    <p>If the given position is less than −1 or greater than the number of rows, throws an
    <a id="the-table-element:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-table-element:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd><dt><code><var>table</var>.<a href="#dom-table-deleterow" id="dom-table-deleterow-dev">deleteRow</a>(<var>index</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/deleteRow" title="The HTMLTableElement.deleteRow() method removes a specific row (<tr>) from a given <table>.">HTMLTableElement/deleteRow</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Removes the <code id="the-table-element:the-tr-element-5"><a href="#the-tr-element">tr</a></code> element with the given position in the table.</p>

    <p>The position is relative to the rows in the table. The index −1 is equivalent to
    deleting the last row of the table.</p>

    <p>If the given position is less than −1 or greater than the index of the last row, or if
    there are no rows, throws an <a id="the-table-element:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a>
    <code id="the-table-element:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>In all of the following attribute and method definitions, when an element is to be
  <dfn id="table-created">table-created</dfn>, that means to <a id="the-table-element:create-an-element" href="https://dom.spec.whatwg.org/#concept-create-element" data-x-internal="create-an-element">create an element</a> given the
  <code id="the-table-element:the-table-element-4"><a href="#the-table-element">table</a></code> element's <a id="the-table-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, the given local name, and the <a id="the-table-element:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
  namespace</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-caption" data-dfn-type="attribute"><code>caption</code></dfn>
  IDL attribute must return, on getting, the first <code id="the-table-element:the-caption-element-7"><a href="#the-caption-element">caption</a></code> element child of the
  <code id="the-table-element:the-table-element-5"><a href="#the-table-element">table</a></code> element, if any, or null otherwise. On setting, the first <code id="the-table-element:the-caption-element-8"><a href="#the-caption-element">caption</a></code>
  element child of the <code id="the-table-element:the-table-element-6"><a href="#the-table-element">table</a></code> element, if any, must be removed, and the new value, if
  not null, must be inserted as the first node of the <code id="the-table-element:the-table-element-7"><a href="#the-table-element">table</a></code> element.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-createcaption" data-dfn-type="method"><code>createCaption()</code></dfn> method must return the first
  <code id="the-table-element:the-caption-element-9"><a href="#the-caption-element">caption</a></code> element child of the <code id="the-table-element:the-table-element-8"><a href="#the-table-element">table</a></code> element, if any; otherwise a new
  <code id="the-table-element:the-caption-element-10"><a href="#the-caption-element">caption</a></code> element must be <a href="#table-created" id="the-table-element:table-created">table-created</a>, inserted as the first node of the
  <code id="the-table-element:the-table-element-9"><a href="#the-table-element">table</a></code> element, and then returned.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-deletecaption" data-dfn-type="method"><code>deleteCaption()</code></dfn> method must remove the first
  <code id="the-table-element:the-caption-element-11"><a href="#the-caption-element">caption</a></code> element child of the <code id="the-table-element:the-table-element-10"><a href="#the-table-element">table</a></code> element, if any.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-thead" data-dfn-type="attribute"><code>tHead</code></dfn> IDL
  attribute must return, on getting, the first <code id="the-table-element:the-thead-element-8"><a href="#the-thead-element">thead</a></code> element child of the
  <code id="the-table-element:the-table-element-11"><a href="#the-table-element">table</a></code> element, if any, or null otherwise. On setting, if the new value is null or a
  <code id="the-table-element:the-thead-element-9"><a href="#the-thead-element">thead</a></code> element, the first <code id="the-table-element:the-thead-element-10"><a href="#the-thead-element">thead</a></code> element child of the <code id="the-table-element:the-table-element-12"><a href="#the-table-element">table</a></code>
  element, if any, must be removed, and the new value, if not null, must be inserted immediately
  before the first element in the <code id="the-table-element:the-table-element-13"><a href="#the-table-element">table</a></code> element that is neither a <code id="the-table-element:the-caption-element-12"><a href="#the-caption-element">caption</a></code>
  element nor a <code id="the-table-element:the-colgroup-element-2"><a href="#the-colgroup-element">colgroup</a></code> element, if any, or at the end of the table if there are no
  such elements. If the new value is neither null nor a <code id="the-table-element:the-thead-element-11"><a href="#the-thead-element">thead</a></code> element, then a
  <a id="the-table-element:hierarchyrequesterror-3" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a> <code id="the-table-element:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> must be thrown
  instead.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-createthead" data-dfn-type="method"><code>createTHead()</code></dfn> method must return the first
  <code id="the-table-element:the-thead-element-12"><a href="#the-thead-element">thead</a></code> element child of the <code id="the-table-element:the-table-element-14"><a href="#the-table-element">table</a></code> element, if any; otherwise a new
  <code id="the-table-element:the-thead-element-13"><a href="#the-thead-element">thead</a></code> element must be <a href="#table-created" id="the-table-element:table-created-2">table-created</a> and inserted immediately before the
  first element in the <code id="the-table-element:the-table-element-15"><a href="#the-table-element">table</a></code> element that is neither a <code id="the-table-element:the-caption-element-13"><a href="#the-caption-element">caption</a></code> element nor
  a <code id="the-table-element:the-colgroup-element-3"><a href="#the-colgroup-element">colgroup</a></code> element, if any, or at the end of the table if there are no such elements,
  and then that new element must be returned.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-deletethead" data-dfn-type="method"><code>deleteTHead()</code></dfn> method must remove the first
  <code id="the-table-element:the-thead-element-14"><a href="#the-thead-element">thead</a></code> element child of the <code id="the-table-element:the-table-element-16"><a href="#the-table-element">table</a></code> element, if any.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-tfoot" data-dfn-type="attribute"><code>tFoot</code></dfn> IDL
  attribute must return, on getting, the first <code id="the-table-element:the-tfoot-element-7"><a href="#the-tfoot-element">tfoot</a></code> element child of the
  <code id="the-table-element:the-table-element-17"><a href="#the-table-element">table</a></code> element, if any, or null otherwise. On setting, if the new value is null or a
  <code id="the-table-element:the-tfoot-element-8"><a href="#the-tfoot-element">tfoot</a></code> element, the first <code id="the-table-element:the-tfoot-element-9"><a href="#the-tfoot-element">tfoot</a></code> element child of the <code id="the-table-element:the-table-element-18"><a href="#the-table-element">table</a></code>
  element, if any, must be removed, and the new value, if not null, must be inserted at the end of
  the table. If the new value is neither null nor a <code id="the-table-element:the-tfoot-element-10"><a href="#the-tfoot-element">tfoot</a></code> element, then a
  <a id="the-table-element:hierarchyrequesterror-4" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a> <code id="the-table-element:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> must be thrown
  instead.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-createtfoot" data-dfn-type="method"><code>createTFoot()</code></dfn> method must return the first
  <code id="the-table-element:the-tfoot-element-11"><a href="#the-tfoot-element">tfoot</a></code> element child of the <code id="the-table-element:the-table-element-19"><a href="#the-table-element">table</a></code> element, if any; otherwise a new
  <code id="the-table-element:the-tfoot-element-12"><a href="#the-tfoot-element">tfoot</a></code> element must be <a href="#table-created" id="the-table-element:table-created-3">table-created</a> and inserted at the end of the
  table, and then that new element must be returned.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-deletetfoot" data-dfn-type="method"><code>deleteTFoot()</code></dfn> method must remove the first
  <code id="the-table-element:the-tfoot-element-13"><a href="#the-tfoot-element">tfoot</a></code> element child of the <code id="the-table-element:the-table-element-20"><a href="#the-table-element">table</a></code> element, if any.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-tbodies" data-dfn-type="attribute"><code>tBodies</code></dfn>
  attribute must return an <code id="the-table-element:htmlcollection-5"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="the-table-element:the-table-element-21"><a href="#the-table-element">table</a></code> node, whose
  filter matches only <code id="the-table-element:the-tbody-element-5"><a href="#the-tbody-element">tbody</a></code> elements that are children of the <code id="the-table-element:the-table-element-22"><a href="#the-table-element">table</a></code>
  element.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-createtbody" data-dfn-type="method"><code>createTBody()</code></dfn> method must <a href="#table-created" id="the-table-element:table-created-4">table-create</a> a new <code id="the-table-element:the-tbody-element-6"><a href="#the-tbody-element">tbody</a></code> element, insert it immediately
  after the last <code id="the-table-element:the-tbody-element-7"><a href="#the-tbody-element">tbody</a></code> element child in the <code id="the-table-element:the-table-element-23"><a href="#the-table-element">table</a></code> element, if any, or at
  the end of the <code id="the-table-element:the-table-element-24"><a href="#the-table-element">table</a></code> element if the <code id="the-table-element:the-table-element-25"><a href="#the-table-element">table</a></code> element has no
  <code id="the-table-element:the-tbody-element-8"><a href="#the-tbody-element">tbody</a></code> element children, and then must return the new <code id="the-table-element:the-tbody-element-9"><a href="#the-tbody-element">tbody</a></code> element.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableElement" id="dom-table-rows" data-dfn-type="attribute"><code>rows</code></dfn>
  attribute must return an <code id="the-table-element:htmlcollection-6"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="the-table-element:the-table-element-26"><a href="#the-table-element">table</a></code> node, whose
  filter matches only <code id="the-table-element:the-tr-element-6"><a href="#the-tr-element">tr</a></code> elements that are either children of the <code id="the-table-element:the-table-element-27"><a href="#the-table-element">table</a></code>
  element, or children of <code id="the-table-element:the-thead-element-15"><a href="#the-thead-element">thead</a></code>, <code id="the-table-element:the-tbody-element-10"><a href="#the-tbody-element">tbody</a></code>, or <code id="the-table-element:the-tfoot-element-14"><a href="#the-tfoot-element">tfoot</a></code> elements
  that are themselves children of the <code id="the-table-element:the-table-element-28"><a href="#the-table-element">table</a></code> element. The elements in the collection
  must be ordered such that those elements whose parent is a <code id="the-table-element:the-thead-element-16"><a href="#the-thead-element">thead</a></code> are included first,
  in <a id="the-table-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, followed by those elements whose parent is either a <code id="the-table-element:the-table-element-29"><a href="#the-table-element">table</a></code>
  or <code id="the-table-element:the-tbody-element-11"><a href="#the-tbody-element">tbody</a></code> element, again in <a id="the-table-element:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, followed finally by those
  elements whose parent is a <code id="the-table-element:the-tfoot-element-15"><a href="#the-tfoot-element">tfoot</a></code> element, still in <a id="the-table-element:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The behavior of the <dfn data-dfn-for="HTMLTableElement" id="dom-table-insertrow" data-dfn-type="method"><code>insertRow(<var>index</var>)</code></dfn> method depends on the state
  of the table. When it is called, the method must act as required by the first item in the
  following list of conditions that describes the state of the table and the <var>index</var>
  argument:</p>

  <dl class="switch"><dt>If <var>index</var> is less than −1 or greater than the number of elements
   in <code id="the-table-element:dom-table-rows-2"><a href="#dom-table-rows">rows</a></code> collection:</dt><dd>The method must throw an <a id="the-table-element:indexsizeerror-3" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a>
   <code id="the-table-element:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</dd><dt>If the <code id="the-table-element:dom-table-rows-3"><a href="#dom-table-rows">rows</a></code> collection has zero elements in it, and the
   <code id="the-table-element:the-table-element-30"><a href="#the-table-element">table</a></code> has no <code id="the-table-element:the-tbody-element-12"><a href="#the-tbody-element">tbody</a></code> elements in it:</dt><dd>The method must <a href="#table-created" id="the-table-element:table-created-5">table-create</a> a <code id="the-table-element:the-tbody-element-13"><a href="#the-tbody-element">tbody</a></code>
   element, then <a href="#table-created" id="the-table-element:table-created-6">table-create</a> a <code id="the-table-element:the-tr-element-7"><a href="#the-tr-element">tr</a></code> element, then
   append the <code id="the-table-element:the-tr-element-8"><a href="#the-tr-element">tr</a></code> element to the <code id="the-table-element:the-tbody-element-14"><a href="#the-tbody-element">tbody</a></code> element, then append the
   <code id="the-table-element:the-tbody-element-15"><a href="#the-tbody-element">tbody</a></code> element to the <code id="the-table-element:the-table-element-31"><a href="#the-table-element">table</a></code> element, and finally return the
   <code id="the-table-element:the-tr-element-9"><a href="#the-tr-element">tr</a></code> element.</dd><dt>If the <code id="the-table-element:dom-table-rows-4"><a href="#dom-table-rows">rows</a></code> collection has zero elements in it:</dt><dd>The method must <a href="#table-created" id="the-table-element:table-created-7">table-create</a> a <code id="the-table-element:the-tr-element-10"><a href="#the-tr-element">tr</a></code> element,
   append it to the last <code id="the-table-element:the-tbody-element-16"><a href="#the-tbody-element">tbody</a></code> element in the table, and return the <code id="the-table-element:the-tr-element-11"><a href="#the-tr-element">tr</a></code>
   element.</dd><dt>If <var>index</var> is −1 or equal to the number of items in <code id="the-table-element:dom-table-rows-5"><a href="#dom-table-rows">rows</a></code> collection:</dt><dd>The method must <a href="#table-created" id="the-table-element:table-created-8">table-create</a> a <code id="the-table-element:the-tr-element-12"><a href="#the-tr-element">tr</a></code> element,
   and append it to the parent of the last <code id="the-table-element:the-tr-element-13"><a href="#the-tr-element">tr</a></code> element in the <code id="the-table-element:dom-table-rows-6"><a href="#dom-table-rows">rows</a></code> collection. Then, the newly created <code id="the-table-element:the-tr-element-14"><a href="#the-tr-element">tr</a></code> element
   must be returned.</dd><dt>Otherwise:</dt><dd>The method must <a href="#table-created" id="the-table-element:table-created-9">table-create</a> a <code id="the-table-element:the-tr-element-15"><a href="#the-tr-element">tr</a></code> element,
   insert it immediately before the <var>index</var>th <code id="the-table-element:the-tr-element-16"><a href="#the-tr-element">tr</a></code> element in the <code id="the-table-element:dom-table-rows-7"><a href="#dom-table-rows">rows</a></code> collection, in the same parent, and finally must return the
   newly created <code id="the-table-element:the-tr-element-17"><a href="#the-tr-element">tr</a></code> element.</dd></dl>
  </div>

  <div data-algorithm="">
  <p>When the <dfn data-dfn-for="HTMLTableElement" id="dom-table-deleterow" data-dfn-type="method"><code>deleteRow(<var>index</var>)</code></dfn> method is called, the user
  agent must run the following steps:</p>

  <ol><li><p>If <var>index</var> is less than −1 or greater than or equal to the number of
   elements in the <code id="the-table-element:dom-table-rows-8"><a href="#dom-table-rows">rows</a></code> collection, then throw an
   <a id="the-table-element:indexsizeerror-4" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-table-element:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>index</var> is −1, then <a href="https://dom.spec.whatwg.org/#concept-node-remove" id="the-table-element:concept-node-remove" data-x-internal="concept-node-remove">remove</a>
   the last element in the <code id="the-table-element:dom-table-rows-9"><a href="#dom-table-rows">rows</a></code> collection from its parent, or
   do nothing if the <code id="the-table-element:dom-table-rows-10"><a href="#dom-table-rows">rows</a></code> collection is empty.</p></li><li><p>Otherwise, <a href="https://dom.spec.whatwg.org/#concept-node-remove" id="the-table-element:concept-node-remove-2" data-x-internal="concept-node-remove">remove</a> the <var>index</var>th element
   in the <code id="the-table-element:dom-table-rows-11"><a href="#dom-table-rows">rows</a></code> collection from its parent.</p></li></ol>
  </div>

  

  <div class="example">

   <p>Here is an example of a table being used to mark up a Sudoku puzzle. Observe the lack of
   headers, which are not necessary in such a table.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
 <c- p="">#</c-><c- nn="">sudoku</c-> <c- p="">{</c-> <c- k="">border-collapse</c-><c- p="">:</c-> <c- kc="">collapse</c-><c- p="">;</c-> <c- k="">border</c-><c- p="">:</c-> <c- kc="">solid</c-> <c- kc="">thick</c-><c- p="">;</c-> <c- p="">}</c->
 <c- p="">#</c-><c- nn="">sudoku</c-> <c- f="">colgroup</c-><c- o="">,</c-> <c- f="">table</c-><c- p="">#</c-><c- nn="">sudoku</c-> <c- f="">tbody</c-> <c- p="">{</c-> <c- k="">border</c-><c- p="">:</c-> <c- kc="">solid</c-> <c- kc="">medium</c-><c- p="">;</c-> <c- p="">}</c->
 <c- p="">#</c-><c- nn="">sudoku</c-> <c- f="">td</c-> <c- p="">{</c-> <c- k="">border</c-><c- p="">:</c-> <c- kc="">solid</c-> <c- kc="">thin</c-><c- p="">;</c-> <c- k="">height</c-><c- p="">:</c-> <c- mf="">1.4</c-><c- b="">em</c-><c- p="">;</c-> <c- k="">width</c-><c- p="">:</c-> <c- mf="">1.4</c-><c- b="">em</c-><c- p="">;</c-> <c- k="">text-align</c-><c- p="">:</c-> <c- kc="">center</c-><c- p="">;</c-> <c- k="">padding</c-><c- p="">:</c-> <c- mi="">0</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Today's Sudoku<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">table</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"sudoku"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">colgroup</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">colgroup</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">colgroup</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 1 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 3 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 6 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 4 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 7 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 9
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 2 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 9 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 1 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 7 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 6
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 2 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 4 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 3 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 9 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 8
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 5 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 9 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 7 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 1
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 6 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 5 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 2
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 7 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 9 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 8 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 2 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 5
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

  </div>




  <h5 id="table-descriptions-techniques"><span class="secno">4.9.1.1</span> Techniques for describing tables<a href="#table-descriptions-techniques" class="self-link"></a></h5>

  <p id="table-descriptions">For tables that consist of more than just a grid of cells with headers
  in the first row and headers in the first column, and for any table in general where the reader
  might have difficulty understanding the content, authors should include explanatory information
  introducing the table. This information is useful for all users, but is especially useful for
  users who cannot see the table, e.g. users of screen readers.</p>

  <p>Such explanatory information should introduce the purpose of the table, outline its basic cell
  structure, highlight any trends or patterns, and generally teach the user how to use the
  table.</p>

  

  <p>For instance, the following table:</p>

  <table><caption>Characteristics with positive and negative sides</caption><thead><tr><th id="n"> Negative
     </th><th> Characteristic
     </th><th> Positive
   </th></tr></thead><tbody><tr><td headers="n r1"> Sad
     </td><th id="r1"> Mood
     </th><td> Happy
    </td></tr><tr><td headers="n r2"> Failing
     </td><th id="r2"> Grade
     </th><td> Passing
  </td></tr></tbody></table>

  <p>...might benefit from a description explaining the way the table is laid out, something like
  "Characteristics are given in the second column, with the negative side in the left column and the
  positive side in the right column".</p>

  <p>There are a variety of ways to include this information, such as:</p>

  <dl><dt>In prose, surrounding the table</dt><dd>
    <div class="example"><pre><code class="html"><strong><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->In the following table, characteristics are given in the second
column, with the negative side in the left column and the positive
side in the right column.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->Characteristics with positive and negative sides<c- p="">&lt;/</c-><c- f="">caption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"n"</c-><c- p="">&gt;</c-> Negative
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Characteristic
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Positive
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r1"</c-><c- p="">&gt;</c-> Sad
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r1"</c-><c- p="">&gt;</c-> Mood
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Happy
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r2"</c-><c- p="">&gt;</c-> Failing
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r2"</c-><c- p="">&gt;</c-> Grade
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Passing
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre></div>
   </dd><dt>In the table's <code id="table-descriptions-techniques:the-caption-element"><a href="#the-caption-element">caption</a></code></dt><dd>
    <div class="example"><pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
<strong> <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Characteristics with positive and negative sides.<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Characteristics are given in the second column, with the
  negative side in the left column and the positive side in the right
  column.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;/</c-><c- f="">caption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"n"</c-><c- p="">&gt;</c-> Negative
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Characteristic
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Positive
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r1"</c-><c- p="">&gt;</c-> Sad
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r1"</c-><c- p="">&gt;</c-> Mood
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Happy
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r2"</c-><c- p="">&gt;</c-> Failing
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r2"</c-><c- p="">&gt;</c-> Grade
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Passing
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre></div>
   </dd><dt>In the table's <code id="table-descriptions-techniques:the-caption-element-2"><a href="#the-caption-element">caption</a></code>, in a <code id="table-descriptions-techniques:the-details-element"><a href="#the-details-element">details</a></code> element</dt><dd>
    <div class="example"><pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Characteristics with positive and negative sides.<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->
<strong>  <c- p="">&lt;</c-><c- f="">details</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">summary</c-><c- p="">&gt;</c->Help<c- p="">&lt;/</c-><c- f="">summary</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Characteristics are given in the second column, with the
   negative side in the left column and the positive side in the right
   column.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;/</c-><c- f="">caption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"n"</c-><c- p="">&gt;</c-> Negative
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Characteristic
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Positive
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r1"</c-><c- p="">&gt;</c-> Sad
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r1"</c-><c- p="">&gt;</c-> Mood
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Happy
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r2"</c-><c- p="">&gt;</c-> Failing
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r2"</c-><c- p="">&gt;</c-> Grade
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Passing
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre></div>
   </dd><dt>Next to the table, in the same <code id="table-descriptions-techniques:the-figure-element"><a href="#the-figure-element">figure</a></code></dt><dd>
    <div class="example"><pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Characteristics with positive and negative sides<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<strong> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Characteristics are given in the second column, with the
 negative side in the left column and the positive side in the right
 column.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"n"</c-><c- p="">&gt;</c-> Negative
    <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Characteristic
    <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Positive
  <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r1"</c-><c- p="">&gt;</c-> Sad
    <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r1"</c-><c- p="">&gt;</c-> Mood
    <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Happy
   <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r2"</c-><c- p="">&gt;</c-> Failing
    <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r2"</c-><c- p="">&gt;</c-> Grade
    <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Passing
 <c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre></div>
   </dd><dt>Next to the table, in a <code id="table-descriptions-techniques:the-figure-element-2"><a href="#the-figure-element">figure</a></code>'s <code id="table-descriptions-techniques:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code></dt><dd>
    <div class="example"><pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Characteristics with positive and negative sides<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->
<strong>  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Characteristics are given in the second column, with the
  negative side in the left column and the positive side in the right
  column.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"n"</c-><c- p="">&gt;</c-> Negative
    <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Characteristic
    <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Positive
  <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r1"</c-><c- p="">&gt;</c-> Sad
    <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r1"</c-><c- p="">&gt;</c-> Mood
    <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Happy
   <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">td</c-> <c- e="">headers</c-><c- o="">=</c-><c- s="">"n r2"</c-><c- p="">&gt;</c-> Failing
    <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r2"</c-><c- p="">&gt;</c-> Grade
    <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Passing
 <c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre></div>
   </dd></dl>

  <p>Authors may also use other techniques, or combinations of the above techniques, as
  appropriate.</p>

  <p>The best option, of course, rather than writing a description explaining the way the table is
  laid out, is to adjust the table such that no explanation is needed.</p>

  <div class="example">

   <p>In the case of the table used in the examples above, a simple rearrangement of the table so
   that the headers are on the top and left sides removes the need for an explanation as well as
   removing the need for the use of <code id="table-descriptions-techniques:attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attributes:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->Characteristics with positive and negative sides<c- p="">&lt;/</c-><c- f="">caption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Characteristic
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Negative
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Positive
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Mood
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Sad
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Happy
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Grade
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Failing
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Passing
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h5 id="table-layout-techniques"><span class="secno">4.9.1.2</span> Techniques for table design<a href="#table-layout-techniques" class="self-link"></a></h5>

  <p>Good table design is key to making tables more readable and usable.</p>

  <p>In visual media, providing column and row borders and alternating row backgrounds can be very
  effective to make complicated tables more readable.</p>

  <p>For tables with large volumes of numeric content, using monospaced fonts can help users see
  patterns, especially in situations where a user agent does not render the borders. (Unfortunately,
  for historical reasons, not rendering borders on tables is a common default.)</p>

  <p>In speech media, table cells can be distinguished by reporting the corresponding headers before
  reading the cell's contents, and by allowing users to navigate the table in a grid fashion, rather
  than serializing the entire contents of the table in source order.</p>

  <p>Authors are encouraged to use CSS to achieve these effects.</p>

  

  <p>User agents are encouraged to render tables using these techniques whenever the page does not
  use CSS and the table is not classified as a layout table.</p>

  




  <h4 id="the-caption-element"><span class="secno">4.9.2</span> The <dfn data-dfn-type="element"><code>caption</code></dfn> element<a href="#the-caption-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption" title="The <caption> HTML element specifies the caption (or title) of a table.">Element/caption</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCaptionElement" title="The HTMLTableCaptionElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating table <caption> elements.">HTMLTableCaptionElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-caption-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-caption-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As the first element child of a <code id="the-caption-element:the-table-element"><a href="#the-table-element">table</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-caption-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-caption-element:flow-content-2">Flow content</a>, but with no descendant <code id="the-caption-element:the-table-element-2"><a href="#the-table-element">table</a></code> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-caption-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-caption-element:the-caption-element"><a href="#the-caption-element">caption</a></code> element's <a href="#syntax-end-tag" id="the-caption-element:syntax-end-tag">end tag</a> can be omitted if
  the <code id="the-caption-element:the-caption-element-2"><a href="#the-caption-element">caption</a></code> element is not immediately followed by <a id="the-caption-element:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> or a
  <a href="#syntax-comments" id="the-caption-element:syntax-comments">comment</a>.</dd><dt><a href="#concept-element-attributes" id="the-caption-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-caption-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-caption-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-caption">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-caption">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-caption-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltablecaptionelement" data-dfn-type="interface"><c- g="">HTMLTableCaptionElement</c-></dfn> : <a href="#htmlelement" id="the-caption-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-caption-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  // <a href="#HTMLTableCaptionElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-caption-element:the-caption-element-3"><a href="#the-caption-element">caption</a></code> element <a href="#represents" id="the-caption-element:represents">represents</a> the title of the <code id="the-caption-element:the-table-element-3"><a href="#the-table-element">table</a></code>
  that is its parent, if it has a parent and that is a <code id="the-caption-element:the-table-element-4"><a href="#the-table-element">table</a></code> element.</p>

  

  <p>The <code id="the-caption-element:the-caption-element-4"><a href="#the-caption-element">caption</a></code> element takes part in the <a href="#table-model" id="the-caption-element:table-model">table model</a>.</p>

  

  <p>When a <code id="the-caption-element:the-table-element-5"><a href="#the-table-element">table</a></code> element is the only content in a <code id="the-caption-element:the-figure-element"><a href="#the-figure-element">figure</a></code> element other
  than the <code id="the-caption-element:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code>, the <code id="the-caption-element:the-caption-element-5"><a href="#the-caption-element">caption</a></code> element should be omitted in favor of
  the <code id="the-caption-element:the-figcaption-element-2"><a href="#the-figcaption-element">figcaption</a></code>.</p>

  <p>A caption can introduce context for a table, making it significantly easier to understand.</p>

  <div class="example">

   <p>Consider, for instance, the following table:</p>

   <table class="dice-example"><tbody><tr><th>   </th><th> 1 </th><th> 2 </th><th> 3 </th><th> 4 </th><th> 5 </th><th> 6
    </th></tr><tr><th> 1 </th><td> 2 </td><td> 3 </td><td> 4 </td><td> 5 </td><td> 6 </td><td> 7
    </td></tr><tr><th> 2 </th><td> 3 </td><td> 4 </td><td> 5 </td><td> 6 </td><td> 7 </td><td> 8
    </td></tr><tr><th> 3 </th><td> 4 </td><td> 5 </td><td> 6 </td><td> 7 </td><td> 8 </td><td> 9
    </td></tr><tr><th> 4 </th><td> 5 </td><td> 6 </td><td> 7 </td><td> 8 </td><td> 9 </td><td> 10
    </td></tr><tr><th> 5 </th><td> 6 </td><td> 7 </td><td> 8 </td><td> 9 </td><td> 10 </td><td> 11
    </td></tr><tr><th> 6 </th><td> 7 </td><td> 8 </td><td> 9 </td><td> 10 </td><td> 11 </td><td> 12
   </td></tr></tbody></table>

   <p>In the abstract, this table is not clear. However, with a caption giving the table's number
   (for <a href="#referenced" id="the-caption-element:referenced">reference</a> in the main prose) and explaining its use, it
   makes more sense:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Table 1.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->This table shows the total score obtained from rolling two
six-sided dice. The first row represents the value of the first die,
the first column the value of the second die. The total is given in
the cell that corresponds to the values of the two dice.
<c- p="">&lt;/</c-><c- f="">caption</c-><c- p="">&gt;</c-></code></pre>

   <p>This provides the user with more context:</p>

   <table class="dice-example"><caption>
     <p>Table 1.
     </p><p>This table shows the total score obtained from rolling two
     six-sided dice. The first row represents the value of the first
     die, the first column the value of the second die. The total is
     given in the cell that corresponds to the values of the two dice.
    </p></caption><tbody><tr><th>   </th><th> 1 </th><th> 2 </th><th> 3 </th><th> 4 </th><th> 5 </th><th> 6
    </th></tr><tr><th> 1 </th><td> 2 </td><td> 3 </td><td> 4 </td><td> 5 </td><td> 6 </td><td> 7
    </td></tr><tr><th> 2 </th><td> 3 </td><td> 4 </td><td> 5 </td><td> 6 </td><td> 7 </td><td> 8
    </td></tr><tr><th> 3 </th><td> 4 </td><td> 5 </td><td> 6 </td><td> 7 </td><td> 8 </td><td> 9
    </td></tr><tr><th> 4 </th><td> 5 </td><td> 6 </td><td> 7 </td><td> 8 </td><td> 9 </td><td> 10
    </td></tr><tr><th> 5 </th><td> 6 </td><td> 7 </td><td> 8 </td><td> 9 </td><td> 10 </td><td> 11
    </td></tr><tr><th> 6 </th><td> 7 </td><td> 8 </td><td> 9 </td><td> 10 </td><td> 11 </td><td> 12
   </td></tr></tbody></table>

  </div>




  <h4 id="the-colgroup-element"><span class="secno">4.9.3</span> The <dfn data-dfn-type="element"><code>colgroup</code></dfn> element<a href="#the-colgroup-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/colgroup" title="The <colgroup> HTML element defines a group of columns within a table.">Element/colgroup</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableColElement" title="The HTMLTableColElement interface provides properties for manipulating single or grouped table column elements.">HTMLTableColElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-colgroup-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-colgroup-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-colgroup-element:the-table-element"><a href="#the-table-element">table</a></code> element, after any
   <code id="the-colgroup-element:the-caption-element"><a href="#the-caption-element">caption</a></code> elements and before any <code id="the-colgroup-element:the-thead-element"><a href="#the-thead-element">thead</a></code>,
   <code id="the-colgroup-element:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>, <code id="the-colgroup-element:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code>, and <code id="the-colgroup-element:the-tr-element"><a href="#the-tr-element">tr</a></code>
   elements.</dd><dt><a href="#concept-element-content-model" id="the-colgroup-element:concept-element-content-model">Content model</a>:</dt><dd>If the <code id="the-colgroup-element:attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code> attribute is present: <a href="#concept-content-nothing" id="the-colgroup-element:concept-content-nothing">Nothing</a>.</dd><dd>If the <code id="the-colgroup-element:attr-colgroup-span-2"><a href="#attr-colgroup-span">span</a></code> attribute is absent: Zero or more <code id="the-colgroup-element:the-col-element"><a href="#the-col-element">col</a></code> and <code id="the-colgroup-element:the-template-element"><a href="#the-template-element">template</a></code> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-colgroup-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-colgroup-element:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> element's <a href="#syntax-start-tag" id="the-colgroup-element:syntax-start-tag">start tag</a> can be
  omitted if the first thing inside the <code id="the-colgroup-element:the-colgroup-element-2"><a href="#the-colgroup-element">colgroup</a></code> element is a <code id="the-colgroup-element:the-col-element-2"><a href="#the-col-element">col</a></code> element,
  and if the element is not immediately preceded by another <code id="the-colgroup-element:the-colgroup-element-3"><a href="#the-colgroup-element">colgroup</a></code> element whose
  <a href="#syntax-end-tag" id="the-colgroup-element:syntax-end-tag">end tag</a> has been omitted. (It can't be omitted if the element
  is empty.)</dd><dd>A <code id="the-colgroup-element:the-colgroup-element-4"><a href="#the-colgroup-element">colgroup</a></code> element's <a href="#syntax-end-tag" id="the-colgroup-element:syntax-end-tag-2">end tag</a> can be omitted
  if the <code id="the-colgroup-element:the-colgroup-element-5"><a href="#the-colgroup-element">colgroup</a></code> element is not immediately followed by <a id="the-colgroup-element:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>
  or a <a href="#syntax-comments" id="the-colgroup-element:syntax-comments">comment</a>.</dd><dt><a href="#concept-element-attributes" id="the-colgroup-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-colgroup-element:global-attributes">Global attributes</a></dd><dd><code id="the-colgroup-element:attr-colgroup-span-3"><a href="#attr-colgroup-span">span</a></code> —  Number of columns spanned by the element
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-colgroup-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-colgroup">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-colgroup">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-colgroup-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltablecolelement" data-dfn-type="interface"><c- g="">HTMLTableColElement</c-></dfn> : <a href="#htmlelement" id="the-colgroup-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-colgroup-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-colgroup-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-colgroup-element:xattr-reflect"><c- g="">Reflect</c-></a>, <a href="#xattr-reflectdefault" id="the-colgroup-element:xattr-reflectdefault">ReflectDefault=1</a>, <a href="#xattr-reflectrange" id="the-colgroup-element:xattr-reflectrange">ReflectRange=(1, 1000)</a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLTableColElement" id="dom-colgroup-span" data-dfn-type="attribute"><c- g="">span</c-></dfn>;

  // <a href="#HTMLTableColElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-colgroup-element:the-colgroup-element-6"><a href="#the-colgroup-element">colgroup</a></code> element <a href="#represents" id="the-colgroup-element:represents">represents</a> a <a href="#concept-column-group" id="the-colgroup-element:concept-column-group">group</a> of one or more <a href="#concept-column" id="the-colgroup-element:concept-column">columns</a> in the <code id="the-colgroup-element:the-table-element-2"><a href="#the-table-element">table</a></code> that is its parent, if it has a
  parent and that is a <code id="the-colgroup-element:the-table-element-3"><a href="#the-table-element">table</a></code> element.</p>

  <p>If the <code id="the-colgroup-element:the-colgroup-element-7"><a href="#the-colgroup-element">colgroup</a></code> element contains no <code id="the-colgroup-element:the-col-element-3"><a href="#the-col-element">col</a></code> elements, then the element
  may have a <dfn data-dfn-for="colgroup" id="attr-colgroup-span" data-dfn-type="element-attr"><code>span</code></dfn>
  content attribute specified, whose value must be a <a href="#valid-non-negative-integer" id="the-colgroup-element:valid-non-negative-integer">valid non-negative integer</a> greater
  than zero and less than or equal to 1000.</p>

  

  <p>The <code id="the-colgroup-element:the-colgroup-element-8"><a href="#the-colgroup-element">colgroup</a></code> element and its <code id="the-colgroup-element:attr-colgroup-span-4"><a href="#attr-colgroup-span">span</a></code>
  attribute take part in the <a href="#table-model" id="the-colgroup-element:table-model">table model</a>.</p>

  


  <h4 id="the-col-element"><span class="secno">4.9.4</span> The <dfn data-dfn-type="element"><code>col</code></dfn> element<a href="#the-col-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/col" title="The <col> HTML element defines a column within a table and is used for defining common semantics on all common cells. It is generally found within a <colgroup> element.">Element/col</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-col-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-col-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-col-element:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> element that doesn't have
   a <code id="the-col-element:attr-col-span"><a href="#attr-col-span">span</a></code> attribute.</dd><dt><a href="#concept-element-content-model" id="the-col-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-col-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-col-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-col-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-col-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-col-element:global-attributes">Global attributes</a></dd><dd><code id="the-col-element:attr-col-span-2"><a href="#attr-col-span">span</a></code> —  Number of columns spanned by the element
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-col-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-col">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-col">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-col-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-col-element:htmltablecolelement"><a href="#htmltablecolelement">HTMLTableColElement</a></code>, as defined for <code id="the-col-element:the-colgroup-element-2"><a href="#the-colgroup-element">colgroup</a></code> elements.</dd></dl>

  <p>If a <code id="the-col-element:the-col-element"><a href="#the-col-element">col</a></code> element has a parent and that is a <code id="the-col-element:the-colgroup-element-3"><a href="#the-colgroup-element">colgroup</a></code> element that
  itself has a parent that is a <code id="the-col-element:the-table-element"><a href="#the-table-element">table</a></code> element, then the <code id="the-col-element:the-col-element-2"><a href="#the-col-element">col</a></code> element
  <a href="#represents" id="the-col-element:represents">represents</a> one or more <a href="#concept-column" id="the-col-element:concept-column">columns</a> in the <a href="#concept-column-group" id="the-col-element:concept-column-group">column group</a> represented by that <code id="the-col-element:the-colgroup-element-4"><a href="#the-colgroup-element">colgroup</a></code>.</p>

  <p>The element may have a <dfn data-dfn-for="col" id="attr-col-span" data-dfn-type="element-attr"><code>span</code></dfn> content attribute specified, whose value must be a
  <a href="#valid-non-negative-integer" id="the-col-element:valid-non-negative-integer">valid non-negative integer</a> greater than zero and less than or equal to 1000.</p>

  

  <p>The <code id="the-col-element:the-col-element-3"><a href="#the-col-element">col</a></code> element and its <code id="the-col-element:attr-col-span-3"><a href="#attr-col-span">span</a></code> attribute take
  part in the <a href="#table-model" id="the-col-element:table-model">table model</a>.</p>

  


  <h4 id="the-tbody-element"><span class="secno">4.9.5</span> The <dfn data-dfn-type="element"><code>tbody</code></dfn> element<a href="#the-tbody-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody" title="The <tbody> HTML element encapsulates a set of table rows (<tr> elements), indicating that they comprise the body of the table (<table>).">Element/tbody</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableSectionElement" title="The HTMLTableSectionElement interface provides special properties and methods (beyond the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of sections, that is headers, footers and bodies (<thead>, <tfoot>, and <tbody>, respectively) in an HTML table.">HTMLTableSectionElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-tbody-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-tbody-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-tbody-element:the-table-element"><a href="#the-table-element">table</a></code> element, after any
   <code id="the-tbody-element:the-caption-element"><a href="#the-caption-element">caption</a></code>, <code id="the-tbody-element:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code>, and
   <code id="the-tbody-element:the-thead-element"><a href="#the-thead-element">thead</a></code> elements, but only if there are no
   <code id="the-tbody-element:the-tr-element"><a href="#the-tr-element">tr</a></code> elements that are children of the
   <code id="the-tbody-element:the-table-element-2"><a href="#the-table-element">table</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-tbody-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or more <code id="the-tbody-element:the-tr-element-2"><a href="#the-tr-element">tr</a></code> and <a href="#script-supporting-elements-2" id="the-tbody-element:script-supporting-elements-2">script-supporting</a> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-tbody-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-tbody-element:the-tbody-element"><a href="#the-tbody-element">tbody</a></code> element's <a href="#syntax-start-tag" id="the-tbody-element:syntax-start-tag">start tag</a> can be omitted
  if the first thing inside the <code id="the-tbody-element:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code> element is a <code id="the-tbody-element:the-tr-element-3"><a href="#the-tr-element">tr</a></code> element, and if the
  element is not immediately preceded by a <code id="the-tbody-element:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code>, <code id="the-tbody-element:the-thead-element-2"><a href="#the-thead-element">thead</a></code>, or
  <code id="the-tbody-element:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" id="the-tbody-element:syntax-end-tag">end tag</a> has been omitted. (It
  can't be omitted if the element is empty.)</dd><dd>A <code id="the-tbody-element:the-tbody-element-4"><a href="#the-tbody-element">tbody</a></code> element's <a href="#syntax-end-tag" id="the-tbody-element:syntax-end-tag-2">end tag</a> can be omitted if
  the <code id="the-tbody-element:the-tbody-element-5"><a href="#the-tbody-element">tbody</a></code> element is immediately followed by a <code id="the-tbody-element:the-tbody-element-6"><a href="#the-tbody-element">tbody</a></code> or
  <code id="the-tbody-element:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code> element, or if there is no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-tbody-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-tbody-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-tbody-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-tbody">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-tbody">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-tbody-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltablesectionelement" data-dfn-type="interface"><c- g="">HTMLTableSectionElement</c-></dfn> : <a href="#htmlelement" id="the-tbody-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-tbody-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-tbody-element:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-tbody-rows" id="the-tbody-element:dom-tbody-rows"><c- g="">rows</c-></a>;
  <a href="#htmltablerowelement" id="the-tbody-element:htmltablerowelement"><c- n="">HTMLTableRowElement</c-></a> <a href="#dom-tbody-insertrow" id="the-tbody-element:dom-tbody-insertrow"><c- g="">insertRow</c-></a>(<c- b="">optional</c-> <c- b="">long</c-> <c- g="">index</c-> = -1);
  [<a href="#cereactions" id="the-tbody-element:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-tbody-deleterow" id="the-tbody-element:dom-tbody-deleterow"><c- g="">deleteRow</c-></a>(<c- b="">long</c-> <c- g="">index</c->);

  // <a href="#HTMLTableSectionElement-partial">also has obsolete members</a>
};</code></pre>
    <p>The
    <code id="the-tbody-element:htmltablesectionelement"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code> interface is also used for <code id="the-tbody-element:the-thead-element-3"><a href="#the-thead-element">thead</a></code> and
    <code id="the-tbody-element:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code> elements.</p>
   </dd></dl>

  <p>The <code id="the-tbody-element:the-tbody-element-7"><a href="#the-tbody-element">tbody</a></code> element <a href="#represents" id="the-tbody-element:represents">represents</a> a <a href="#concept-row-group" id="the-tbody-element:concept-row-group">block</a> of <a href="#concept-row" id="the-tbody-element:concept-row">rows</a> that consist of a
  body of data for the parent <code id="the-tbody-element:the-table-element-3"><a href="#the-table-element">table</a></code> element, if the <code id="the-tbody-element:the-tbody-element-8"><a href="#the-tbody-element">tbody</a></code> element has a
  parent and it is a <code id="the-tbody-element:the-table-element-4"><a href="#the-table-element">table</a></code>.</p>

  

  <p>The <code id="the-tbody-element:the-tbody-element-9"><a href="#the-tbody-element">tbody</a></code> element takes part in the <a href="#table-model" id="the-tbody-element:table-model">table model</a>.</p>

  

  <dl class="domintro"><dt><code><var>tbody</var>.<a href="#dom-tbody-rows" id="dom-tbody-rows-dev">rows</a></code></dt><dd>
    <p>Returns an <code id="the-tbody-element:htmlcollection-2"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="the-tbody-element:the-tr-element-4"><a href="#the-tr-element">tr</a></code> elements of the table
    section.</p>
   </dd><dt><code><var>tr</var> = <var>tbody</var>.<a href="#dom-tbody-insertrow" id="dom-tbody-insertrow-dev">insertRow</a>([ <var>index</var> ])</code></dt><dd>
    <p>Creates a <code id="the-tbody-element:the-tr-element-5"><a href="#the-tr-element">tr</a></code> element, inserts it into the table section at the position given by
    the argument, and returns the <code id="the-tbody-element:the-tr-element-6"><a href="#the-tr-element">tr</a></code>.</p>

    <p>The position is relative to the rows in the table section. The index −1, which is the
    default if the argument is omitted, is equivalent to inserting at the end of the table
    section.</p>

    <p>If the given position is less than −1 or greater than the number of rows, throws an
    <a id="the-tbody-element:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-tbody-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd><dt><code><var>tbody</var>.<a href="#dom-tbody-deleterow" id="dom-tbody-deleterow-dev">deleteRow</a>(<var>index</var>)</code></dt><dd>
    <p>Removes the <code id="the-tbody-element:the-tr-element-7"><a href="#the-tr-element">tr</a></code> element with the given position in the table section.</p>

    <p>The position is relative to the rows in the table section. The index −1 is equivalent
    to deleting the last row of the table section.</p>

    <p>If the given position is less than −1 or greater than the index of the last row, or if
    there are no rows, throws an <a id="the-tbody-element:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a>
    <code id="the-tbody-element:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableSectionElement" id="dom-tbody-rows" data-dfn-type="attribute"><code>rows</code></dfn> attribute must return an <code id="the-tbody-element:htmlcollection-3"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code>
  rooted at this element, whose filter matches only <code id="the-tbody-element:the-tr-element-8"><a href="#the-tr-element">tr</a></code> elements that are children of
  this element.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableSectionElement" id="dom-tbody-insertrow" data-dfn-type="method"><code>insertRow(<var>index</var>)</code></dfn> method must act as
  follows:</p>

  <ol><li><p>If <var>index</var> is less than −1 or greater than the number of elements in the
   <code id="the-tbody-element:dom-tbody-rows-2"><a href="#dom-tbody-rows">rows</a></code> collection, throw an
   <a id="the-tbody-element:indexsizeerror-3" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-tbody-element:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>table row</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-tbody-element:create-an-element" data-x-internal="create-an-element">creating an
   element</a> given this element's <a id="the-tbody-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, "<code>tr</code>", and
   the <a id="the-tbody-element:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>.</p></li><li><p>If <var>index</var> is −1 or equal to the number of items in the <code id="the-tbody-element:dom-tbody-rows-3"><a href="#dom-tbody-rows">rows</a></code> collection, then <a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-tbody-element:concept-node-append" data-x-internal="concept-node-append">append</a> <var>table row</var> to this element.</p></li><li><p>Otherwise, <a href="https://dom.spec.whatwg.org/#concept-node-insert" id="the-tbody-element:concept-node-insert" data-x-internal="concept-node-insert">insert</a> <var>table row</var> as a
   child of this element, immediately before the <var>index</var>th <code id="the-tbody-element:the-tr-element-9"><a href="#the-tr-element">tr</a></code> element in the
   <code id="the-tbody-element:dom-tbody-rows-4"><a href="#dom-tbody-rows">rows</a></code> collection.</p></li><li><p>Return <var>table row</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableSectionElement" id="dom-tbody-deleterow" data-dfn-type="method"><code>deleteRow(<var>index</var>)</code></dfn> method must, when invoked,
  act as follows:

  </p><ol><li><p>If <var>index</var> is less than −1 or greater than or equal to the number of
   elements in the <code id="the-tbody-element:dom-tbody-rows-5"><a href="#dom-tbody-rows">rows</a></code> collection, then throw an
   <a id="the-tbody-element:indexsizeerror-4" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-tbody-element:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>index</var> is −1, then <a href="https://dom.spec.whatwg.org/#concept-node-remove" id="the-tbody-element:concept-node-remove" data-x-internal="concept-node-remove">remove</a>
   the last element in the <code id="the-tbody-element:dom-tbody-rows-6"><a href="#dom-tbody-rows">rows</a></code> collection from this
   element, or do nothing if the <code id="the-tbody-element:dom-tbody-rows-7"><a href="#dom-tbody-rows">rows</a></code> collection is
   empty.</p></li><li><p>Otherwise, <a href="https://dom.spec.whatwg.org/#concept-node-remove" id="the-tbody-element:concept-node-remove-2" data-x-internal="concept-node-remove">remove</a> the <var>index</var>th element
   in the <code id="the-tbody-element:dom-tbody-rows-8"><a href="#dom-tbody-rows">rows</a></code> collection from this element.</p></li></ol>
  </div>

  


  <h4 id="the-thead-element"><span class="secno">4.9.6</span> The <dfn data-dfn-type="element"><code>thead</code></dfn> element<a href="#the-thead-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead" title="The <thead> HTML element defines a set of rows defining the head of the columns of the table.">Element/thead</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-thead-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-thead-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-thead-element:the-table-element"><a href="#the-table-element">table</a></code> element, after any
   <code id="the-thead-element:the-caption-element"><a href="#the-caption-element">caption</a></code>, and <code id="the-thead-element:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code>
   elements and before any <code id="the-thead-element:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>, <code id="the-thead-element:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code>, and
   <code id="the-thead-element:the-tr-element"><a href="#the-tr-element">tr</a></code> elements, but only if there are no other
   <code id="the-thead-element:the-thead-element"><a href="#the-thead-element">thead</a></code> elements that are children of the
   <code id="the-thead-element:the-table-element-2"><a href="#the-table-element">table</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-thead-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or more <code id="the-thead-element:the-tr-element-2"><a href="#the-tr-element">tr</a></code> and <a href="#script-supporting-elements-2" id="the-thead-element:script-supporting-elements-2">script-supporting</a> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-thead-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-thead-element:the-thead-element-2"><a href="#the-thead-element">thead</a></code> element's <a href="#syntax-end-tag" id="the-thead-element:syntax-end-tag">end tag</a> can be omitted if
  the <code id="the-thead-element:the-thead-element-3"><a href="#the-thead-element">thead</a></code> element is immediately followed by a <code id="the-thead-element:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code> or
  <code id="the-thead-element:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code> element.</dd><dt><a href="#concept-element-attributes" id="the-thead-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-thead-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-thead-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-thead">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-thead">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-thead-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-thead-element:htmltablesectionelement"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code>, as defined for <code id="the-thead-element:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code> elements.</dd></dl>

  <p>The <code id="the-thead-element:the-thead-element-4"><a href="#the-thead-element">thead</a></code> element <a href="#represents" id="the-thead-element:represents">represents</a> the <a href="#concept-row-group" id="the-thead-element:concept-row-group">block</a> of <a href="#concept-row" id="the-thead-element:concept-row">rows</a> that consist of
  the column labels (headers) and any ancillary non-header cells for the parent <code id="the-thead-element:the-table-element-3"><a href="#the-table-element">table</a></code>
  element, if the <code id="the-thead-element:the-thead-element-5"><a href="#the-thead-element">thead</a></code> element has a parent and it is a <code id="the-thead-element:the-table-element-4"><a href="#the-table-element">table</a></code>.</p>

  

  <p>The <code id="the-thead-element:the-thead-element-6"><a href="#the-thead-element">thead</a></code> element takes part in the <a href="#table-model" id="the-thead-element:table-model">table model</a>.</p>

  

  <div class="example">

   <p>This example shows a <code id="the-thead-element:the-thead-element-7"><a href="#the-thead-element">thead</a></code> element being used. Notice the use of both
   <code id="the-thead-element:the-th-element"><a href="#the-th-element">th</a></code> and <code id="the-thead-element:the-td-element"><a href="#the-td-element">td</a></code> elements in the <code id="the-thead-element:the-thead-element-8"><a href="#the-thead-element">thead</a></code> element: the first row is
   the headers, and the second row is an explanation of how to fill in the table.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c-> School auction sign-up sheet <c- p="">&lt;/</c-><c- f="">caption</c-><c- p="">&gt;</c->
<strong> <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">e1</c-><c- p="">&gt;</c->Name<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">e2</c-><c- p="">&gt;</c->Product<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">e3</c-><c- p="">&gt;</c->Picture<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">e4</c-><c- p="">&gt;</c->Price<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Your name here
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->What are you selling?
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Link to a picture
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Your reserve price
</strong> <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Ms Danus
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Doughnuts
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"https://example.com/mydoughnuts.png"</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Doughnuts from Ms Danus"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->$45
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">e1</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">who</c-> <c- e="">required</c-> <c- e="">form</c-><c- o="">=</c-><c- s="">f</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">e2</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">what</c-> <c- e="">required</c-> <c- e="">form</c-><c- o="">=</c-><c- s="">f</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">e3</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">url</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">pic</c-> <c- e="">form</c-><c- o="">=</c-><c- s="">f</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">e4</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">0.01</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">required</c-> <c- e="">form</c-><c- o="">=</c-><c- s="">f</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">form</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">f</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"/auction.cgi"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">add</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Submit"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-tfoot-element"><span class="secno">4.9.7</span> The <dfn data-dfn-type="element"><code>tfoot</code></dfn> element<a href="#the-tfoot-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tfoot" title="The <tfoot> HTML element defines a set of rows summarizing the columns of the table.">Element/tfoot</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-tfoot-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-tfoot-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-tfoot-element:the-table-element"><a href="#the-table-element">table</a></code> element, after any
   <code id="the-tfoot-element:the-caption-element"><a href="#the-caption-element">caption</a></code>, <code id="the-tfoot-element:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code>, <code id="the-tfoot-element:the-thead-element"><a href="#the-thead-element">thead</a></code>,
   <code id="the-tfoot-element:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>, and <code id="the-tfoot-element:the-tr-element"><a href="#the-tr-element">tr</a></code> elements, but only if there
   are no other <code id="the-tfoot-element:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> elements that are children of the
   <code id="the-tfoot-element:the-table-element-2"><a href="#the-table-element">table</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-tfoot-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or more <code id="the-tfoot-element:the-tr-element-2"><a href="#the-tr-element">tr</a></code> and <a href="#script-supporting-elements-2" id="the-tfoot-element:script-supporting-elements-2">script-supporting</a> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-tfoot-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-tfoot-element:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code> element's <a href="#syntax-end-tag" id="the-tfoot-element:syntax-end-tag">end tag</a> can be omitted if
  there is no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-tfoot-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-tfoot-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-tfoot-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-tfoot">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-tfoot">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-tfoot-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-tfoot-element:htmltablesectionelement"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code>, as defined for <code id="the-tfoot-element:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code> elements.</dd></dl>

  <p>The <code id="the-tfoot-element:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code> element <a href="#represents" id="the-tfoot-element:represents">represents</a> the <a href="#concept-row-group" id="the-tfoot-element:concept-row-group">block</a> of <a href="#concept-row" id="the-tfoot-element:concept-row">rows</a> that consist of
  the column summaries (footers) for the parent <code id="the-tfoot-element:the-table-element-3"><a href="#the-table-element">table</a></code> element, if the
  <code id="the-tfoot-element:the-tfoot-element-4"><a href="#the-tfoot-element">tfoot</a></code> element has a parent and it is a <code id="the-tfoot-element:the-table-element-4"><a href="#the-table-element">table</a></code>.</p>

  

  <p>The <code id="the-tfoot-element:the-tfoot-element-5"><a href="#the-tfoot-element">tfoot</a></code> element takes part in the <a href="#table-model" id="the-tfoot-element:table-model">table
  model</a>.</p>

  


  <h4 id="the-tr-element"><span class="secno">4.9.8</span> The <dfn data-dfn-type="element"><code>tr</code></dfn> element<a href="#the-tr-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr" title="The <tr> HTML element defines a row of cells in a table. The row's cells can then be established using a mix of <td> (data cell) and <th> (header cell) elements.">Element/tr</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement" title="The HTMLTableRowElement interface provides special properties and methods (beyond the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of rows in an HTML table.">HTMLTableRowElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-tr-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-tr-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-tr-element:the-thead-element"><a href="#the-thead-element">thead</a></code> element.</dd><dd>As a child of a <code id="the-tr-element:the-tbody-element"><a href="#the-tbody-element">tbody</a></code> element.</dd><dd>As a child of a <code id="the-tr-element:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> element.</dd><dd>As a child of a <code id="the-tr-element:the-table-element"><a href="#the-table-element">table</a></code> element, after any
   <code id="the-tr-element:the-caption-element"><a href="#the-caption-element">caption</a></code>, <code id="the-tr-element:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code>, and <code id="the-tr-element:the-thead-element-2"><a href="#the-thead-element">thead</a></code>
   elements, but only if there are no <code id="the-tr-element:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code> elements that
   are children of the <code id="the-tr-element:the-table-element-2"><a href="#the-table-element">table</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-tr-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or more <code id="the-tr-element:the-td-element"><a href="#the-td-element">td</a></code>, <code id="the-tr-element:the-th-element"><a href="#the-th-element">th</a></code>, and <a href="#script-supporting-elements-2" id="the-tr-element:script-supporting-elements-2">script-supporting</a> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-tr-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-tr-element:the-tr-element"><a href="#the-tr-element">tr</a></code> element's <a href="#syntax-end-tag" id="the-tr-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-tr-element:the-tr-element-2"><a href="#the-tr-element">tr</a></code> element is immediately followed by another <code id="the-tr-element:the-tr-element-3"><a href="#the-tr-element">tr</a></code> element, or if there is
  no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-tr-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-tr-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-tr-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-tr">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-tr">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-tr-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltablerowelement" data-dfn-type="interface"><c- g="">HTMLTableRowElement</c-></dfn> : <a href="#htmlelement" id="the-tr-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-tr-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">long</c-> <a href="#dom-tr-rowindex" id="the-tr-element:dom-tr-rowindex"><c- g="">rowIndex</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">long</c-> <a href="#dom-tr-sectionrowindex" id="the-tr-element:dom-tr-sectionrowindex"><c- g="">sectionRowIndex</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-tr-element:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-tr-cells" id="the-tr-element:dom-tr-cells"><c- g="">cells</c-></a>;
  <a href="#htmltablecellelement" id="the-tr-element:htmltablecellelement"><c- n="">HTMLTableCellElement</c-></a> <a href="#dom-tr-insertcell" id="the-tr-element:dom-tr-insertcell"><c- g="">insertCell</c-></a>(<c- b="">optional</c-> <c- b="">long</c-> <c- g="">index</c-> = -1);
  [<a href="#cereactions" id="the-tr-element:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-tr-deletecell" id="the-tr-element:dom-tr-deletecell"><c- g="">deleteCell</c-></a>(<c- b="">long</c-> <c- g="">index</c->);

  // <a href="#HTMLTableRowElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-tr-element:the-tr-element-4"><a href="#the-tr-element">tr</a></code> element <a href="#represents" id="the-tr-element:represents">represents</a> a <a href="#concept-row" id="the-tr-element:concept-row">row</a> of
  <a href="#concept-cell" id="the-tr-element:concept-cell">cells</a> in a <a href="#concept-table" id="the-tr-element:concept-table">table</a>.</p>

  

  <p>The <code id="the-tr-element:the-tr-element-5"><a href="#the-tr-element">tr</a></code> element takes part in the <a href="#table-model" id="the-tr-element:table-model">table model</a>.</p>

  

  <dl class="domintro"><dt><code><var>tr</var>.<a href="#dom-tr-rowindex" id="dom-tr-rowindex-dev">rowIndex</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/rowIndex" title="The HTMLTableRowElement.rowIndex read-only property represents the position of a row in relation to the whole <table>.">HTMLTableRowElement/rowIndex</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the position of the row in the table's <code id="the-tr-element:dom-table-rows"><a href="#dom-table-rows">rows</a></code>
    list.</p>

    <p>Returns −1 if the element isn't in a table.</p>
   </dd><dt><code><var>tr</var>.<a href="#dom-tr-sectionrowindex" id="dom-tr-sectionrowindex-dev">sectionRowIndex</a></code></dt><dd>
    <p>Returns the position of the row in the table section's <code id="the-tr-element:dom-tbody-rows"><a href="#dom-tbody-rows">rows</a></code> list.</p>

    <p>Returns −1 if the element isn't in a table section.</p>
   </dd><dt><code><var>tr</var>.<a href="#dom-tr-cells" id="dom-tr-cells-dev">cells</a></code></dt><dd>
    <p>Returns an <code id="the-tr-element:htmlcollection-2"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="the-tr-element:the-td-element-2"><a href="#the-td-element">td</a></code> and <code id="the-tr-element:the-th-element-2"><a href="#the-th-element">th</a></code> elements of
    the row.</p>
   </dd><dt><code><var>cell</var> = <var>tr</var>.<a href="#dom-tr-insertcell" id="dom-tr-insertcell-dev">insertCell</a>([ <var>index</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/insertCell" title="The HTMLTableRowElement.insertCell() method inserts a new cell (<td>) into a table row (<tr>) and returns a reference to the cell.">HTMLTableRowElement/insertCell</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Creates a <code id="the-tr-element:the-td-element-3"><a href="#the-td-element">td</a></code> element, inserts it into the table row at the position given by the
    argument, and returns the <code id="the-tr-element:the-td-element-4"><a href="#the-td-element">td</a></code>.</p>

    <p>The position is relative to the cells in the row. The index −1, which is the default
    if the argument is omitted, is equivalent to inserting at the end of the row.</p>

    <p>If the given position is less than −1 or greater than the number of cells, throws an
    <a id="the-tr-element:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-tr-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd><dt><code><var>tr</var>.<a href="#dom-tr-deletecell" id="dom-tr-deletecell-dev">deleteCell</a>(<var>index</var>)</code></dt><dd>
    <p>Removes the <code id="the-tr-element:the-td-element-5"><a href="#the-td-element">td</a></code> or <code id="the-tr-element:the-th-element-3"><a href="#the-th-element">th</a></code> element with the given position in the
    row.</p>

    <p>The position is relative to the cells in the row. The index −1 is equivalent to
    deleting the last cell of the row.</p>

    <p>If the given position is less than −1 or greater than the index of the last cell, or
    if there are no cells, throws an <a id="the-tr-element:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a>
    <code id="the-tr-element:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-rowindex" data-dfn-type="attribute"><code>rowIndex</code></dfn> attribute must, if this element has a parent
  <code id="the-tr-element:the-table-element-3"><a href="#the-table-element">table</a></code> element, or a parent <code id="the-tr-element:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code>, <code id="the-tr-element:the-thead-element-3"><a href="#the-thead-element">thead</a></code>, or
  <code id="the-tr-element:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code> element and a <em>grandparent</em> <code id="the-tr-element:the-table-element-4"><a href="#the-table-element">table</a></code> element, return the index
  of this <code id="the-tr-element:the-tr-element-6"><a href="#the-tr-element">tr</a></code> element in that <code id="the-tr-element:the-table-element-5"><a href="#the-table-element">table</a></code> element's <code id="the-tr-element:dom-table-rows-2"><a href="#dom-table-rows">rows</a></code> collection. If there is no such <code id="the-tr-element:the-table-element-6"><a href="#the-table-element">table</a></code> element,
  then the attribute must return −1.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-sectionrowindex" data-dfn-type="attribute"><code>sectionRowIndex</code></dfn> attribute must, if this element has a
  parent <code id="the-tr-element:the-table-element-7"><a href="#the-table-element">table</a></code>, <code id="the-tr-element:the-tbody-element-4"><a href="#the-tbody-element">tbody</a></code>, <code id="the-tr-element:the-thead-element-4"><a href="#the-thead-element">thead</a></code>, or <code id="the-tr-element:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code> element,
  return the index of the <code id="the-tr-element:the-tr-element-7"><a href="#the-tr-element">tr</a></code> element in the parent element's <code>rows</code> collection (for tables, that's <code id="the-tr-element:htmltableelement"><a href="#htmltableelement">HTMLTableElement</a></code>'s <code id="the-tr-element:dom-table-rows-3"><a href="#dom-table-rows">rows</a></code> collection; for table sections, that's
  <code id="the-tr-element:htmltablesectionelement"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code>'s <code id="the-tr-element:dom-tbody-rows-2"><a href="#dom-tbody-rows">rows</a></code>
  collection). If there is no such parent element, then the attribute must return −1.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-cells" data-dfn-type="attribute"><code>cells</code></dfn>
  attribute must return an <code id="the-tr-element:htmlcollection-3"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at this <code id="the-tr-element:the-tr-element-8"><a href="#the-tr-element">tr</a></code> element, whose
  filter matches only <code id="the-tr-element:the-td-element-6"><a href="#the-td-element">td</a></code> and <code id="the-tr-element:the-th-element-4"><a href="#the-th-element">th</a></code> elements that are children of the
  <code id="the-tr-element:the-tr-element-9"><a href="#the-tr-element">tr</a></code> element.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-insertcell" data-dfn-type="method"><code>insertCell(<var>index</var>)</code></dfn> method must act as
  follows:</p>

  <ol><li><p>If <var>index</var> is less than −1 or greater than the number of elements in
   the <code id="the-tr-element:dom-tr-cells-2"><a href="#dom-tr-cells">cells</a></code> collection, then throw an
   <a id="the-tr-element:indexsizeerror-3" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-tr-element:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>table cell</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-tr-element:create-an-element" data-x-internal="create-an-element">creating an
   element</a> given this <code id="the-tr-element:the-tr-element-10"><a href="#the-tr-element">tr</a></code> element's <a id="the-tr-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, "<code>td</code>", and the <a id="the-tr-element:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>.</p></li><li><p>If <var>index</var> is equal to −1 or equal to the number of items in <code id="the-tr-element:dom-tr-cells-3"><a href="#dom-tr-cells">cells</a></code> collection, then <a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-tr-element:concept-node-append" data-x-internal="concept-node-append">append</a> <var>table cell</var> to this <code id="the-tr-element:the-tr-element-11"><a href="#the-tr-element">tr</a></code>
   element.</p></li><li><p>Otherwise, <a href="https://dom.spec.whatwg.org/#concept-node-insert" id="the-tr-element:concept-node-insert" data-x-internal="concept-node-insert">insert</a> <var>table cell</var> as a
   child of this <code id="the-tr-element:the-tr-element-12"><a href="#the-tr-element">tr</a></code> element, immediately before the <var>index</var>th <code id="the-tr-element:the-td-element-7"><a href="#the-td-element">td</a></code>
   or <code id="the-tr-element:the-th-element-5"><a href="#the-th-element">th</a></code> element in the <code id="the-tr-element:dom-tr-cells-4"><a href="#dom-tr-cells">cells</a></code> collection.</p></li><li><p>Return <var>table cell</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-deletecell" data-dfn-type="method"><code>deleteCell(<var>index</var>)</code></dfn> method must act as
  follows:</p>

  <ol><li><p>If <var>index</var> is less than −1 or greater than or equal to the number of
   elements in the <code id="the-tr-element:dom-tr-cells-5"><a href="#dom-tr-cells">cells</a></code> collection, then throw an
   <a id="the-tr-element:indexsizeerror-4" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-tr-element:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>index</var> is −1, then <a href="https://dom.spec.whatwg.org/#concept-node-remove" id="the-tr-element:concept-node-remove" data-x-internal="concept-node-remove">remove</a>
   the last element in the <code id="the-tr-element:dom-tr-cells-6"><a href="#dom-tr-cells">cells</a></code> collection from its
   parent, or do nothing if the <code id="the-tr-element:dom-tr-cells-7"><a href="#dom-tr-cells">cells</a></code> collection is
   empty.</p></li><li><p>Otherwise, <a href="https://dom.spec.whatwg.org/#concept-node-remove" id="the-tr-element:concept-node-remove-2" data-x-internal="concept-node-remove">remove</a> the <var>index</var>th element
   in the <code id="the-tr-element:dom-tr-cells-8"><a href="#dom-tr-cells">cells</a></code> collection from its parent.</p></li></ol>
  </div>

  


  <h4 id="the-td-element"><span class="secno">4.9.9</span> The <dfn data-dfn-type="element"><code>td</code></dfn> element<a href="#the-td-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td" title="The <td> HTML element defines a cell of a table that contains data. It participates in the table model.">Element/td</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement" title="The HTMLTableCellElement interface provides special properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of table cells, either header cells (<th>)) or data cells (<td>), in an HTML document.">HTMLTableCellElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-td-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-td-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-td-element:the-tr-element"><a href="#the-tr-element">tr</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-td-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-td-element:flow-content-2">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-td-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-td-element:the-td-element"><a href="#the-td-element">td</a></code> element's <a href="#syntax-end-tag" id="the-td-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-td-element:the-td-element-2"><a href="#the-td-element">td</a></code> element is immediately followed by a <code id="the-td-element:the-td-element-3"><a href="#the-td-element">td</a></code> or <code id="the-td-element:the-th-element"><a href="#the-th-element">th</a></code> element,
  or if there is no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-td-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-td-element:global-attributes">Global attributes</a></dd><dd><code id="the-td-element:attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code> —  Number of columns that the cell is to span
     </dd><dd><code id="the-td-element:attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code> —  Number of rows that the cell is to span
     </dd><dd><code id="the-td-element:attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> —  The header cells for this cell
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-td-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-td">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-td">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-td-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltablecellelement" data-dfn-type="interface"><c- g="">HTMLTableCellElement</c-></dfn> : <a href="#htmlelement" id="the-td-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-td-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-td-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-td-element:xattr-reflect"><c- g="">Reflect</c-></a>, <a href="#xattr-reflectdefault" id="the-td-element:xattr-reflectdefault">ReflectDefault=1</a>, <a href="#xattr-reflectrange" id="the-td-element:xattr-reflectrange">ReflectRange=(1, 1000)</a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-colspan" data-dfn-type="attribute"><c- g="">colSpan</c-></dfn>;
  [<a href="#cereactions" id="the-td-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-td-element:xattr-reflect-2"><c- g="">Reflect</c-></a>, <a href="#xattr-reflectdefault" id="the-td-element:xattr-reflectdefault-2">ReflectDefault=1</a>, <a href="#xattr-reflectrange" id="the-td-element:xattr-reflectrange-2">ReflectRange=(0, 65534)</a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-rowspan" data-dfn-type="attribute"><c- g="">rowSpan</c-></dfn>;
  [<a href="#cereactions" id="the-td-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-td-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn id="dom-tdth-headers"><c- g="">headers</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">long</c-> <a href="#dom-tdth-cellindex" id="the-td-element:dom-tdth-cellindex"><c- g="">cellIndex</c-></a>;

  [<a href="#cereactions" id="the-td-element:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-th-scope" id="the-td-element:dom-th-scope"><c- g="">scope</c-></a>; // only conforming for th elements
  [<a href="#cereactions" id="the-td-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-td-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-th-abbr" data-dfn-type="attribute"><c- g="">abbr</c-></dfn>;  // only conforming for th elements

  // <a href="#HTMLTableCellElement-partial">also has obsolete members</a>
};</code></pre>

    <p>The
    <code id="the-td-element:htmltablecellelement"><a href="#htmltablecellelement">HTMLTableCellElement</a></code> interface is also used for <code id="the-td-element:the-th-element-2"><a href="#the-th-element">th</a></code> elements.</p>
   </dd></dl>

  <p>The <code id="the-td-element:the-td-element-4"><a href="#the-td-element">td</a></code> element <a href="#represents" id="the-td-element:represents">represents</a> a data <a href="#concept-cell" id="the-td-element:concept-cell">cell</a> in a table.</p>

  

  <p>The <code id="the-td-element:the-td-element-5"><a href="#the-td-element">td</a></code> element and its <code id="the-td-element:attr-tdth-colspan-2"><a href="#attr-tdth-colspan">colspan</a></code>, <code id="the-td-element:attr-tdth-rowspan-2"><a href="#attr-tdth-rowspan">rowspan</a></code>, and <code id="the-td-element:attr-tdth-headers-2"><a href="#attr-tdth-headers">headers</a></code>
  attributes take part in the <a href="#table-model" id="the-td-element:table-model">table model</a>.</p>

  <p>User agents, especially in non-visual environments or where displaying the table as a 2D grid
  is impractical, may give the user context for the cell when rendering the contents of a cell; for
  instance, giving its position in the <a href="#table-model" id="the-td-element:table-model-2">table model</a>, or listing the cell's header cells
  (as determined by the <a href="#algorithm-for-assigning-header-cells" id="the-td-element:algorithm-for-assigning-header-cells">algorithm for assigning header cells</a>). When a cell's header
  cells are being listed, user agents may use the value of <code id="the-td-element:attr-th-abbr"><a href="#attr-th-abbr">abbr</a></code>
  attributes on those header cells, if any, instead of the contents of the header cells
  themselves.</p>

  

  <div class="example">

   <p>In this example, we see a snippet of a web application consisting of a grid of editable cells
   (essentially a simple spreadsheet). One of the cells has been configured to show the sum of the
   cells above it. Three have been marked as headings, which use <code id="the-td-element:the-th-element-3"><a href="#the-th-element">th</a></code> elements instead of
   <code id="the-td-element:the-td-element-6"><a href="#the-td-element">td</a></code> elements. A script would attach event handlers to these elements to maintain the
   total.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Name"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Paid ($)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Jeff"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"14"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Britta"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"9"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Abed"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"25"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Shirley"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"2"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Annie"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"5"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Troy"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"5"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Pierce"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1000"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Total"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">output</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1060"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-th-element"><span class="secno">4.9.10</span> The <dfn data-dfn-type="element"><code>th</code></dfn> element<a href="#the-th-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th" title="The <th> HTML element defines a cell as the header of a group of table cells. The exact nature of this group is defined by the scope and headers attributes.">Element/th</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-th-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-th-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a child of a <code id="the-th-element:the-tr-element"><a href="#the-tr-element">tr</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-th-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-th-element:flow-content-2">Flow content</a>, but with no <code id="the-th-element:the-header-element"><a href="#the-header-element">header</a></code>, <code id="the-th-element:the-footer-element"><a href="#the-footer-element">footer</a></code>,
   <a href="#sectioning-content-2" id="the-th-element:sectioning-content-2">sectioning content</a>, or <a href="#heading-content-2" id="the-th-element:heading-content-2">heading content</a> descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-th-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>A <code id="the-th-element:the-th-element"><a href="#the-th-element">th</a></code> element's <a href="#syntax-end-tag" id="the-th-element:syntax-end-tag">end tag</a> can be omitted if the
  <code id="the-th-element:the-th-element-2"><a href="#the-th-element">th</a></code> element is immediately followed by a <code id="the-th-element:the-td-element"><a href="#the-td-element">td</a></code> or <code id="the-th-element:the-th-element-3"><a href="#the-th-element">th</a></code> element,
  or if there is no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-th-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-th-element:global-attributes">Global attributes</a></dd><dd><code id="the-th-element:attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code> —  Number of columns that the cell is to span
     </dd><dd><code id="the-th-element:attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code> —  Number of rows that the cell is to span
     </dd><dd><code id="the-th-element:attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> —  The header cells for this cell
     </dd><dd><code id="the-th-element:attr-th-scope"><a href="#attr-th-scope">scope</a></code> —  Specifies which cells the header cell applies to
     </dd><dd><code id="the-th-element:attr-th-abbr"><a href="#attr-th-abbr">abbr</a></code> —  Alternative label to use for the header cell when referencing the cell in other contexts
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-th-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-th">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-th">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-th-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-th-element:htmltablecellelement"><a href="#htmltablecellelement">HTMLTableCellElement</a></code>, as defined for <code id="the-th-element:the-td-element-2"><a href="#the-td-element">td</a></code> elements.</dd></dl>

  <p>The <code id="the-th-element:the-th-element-4"><a href="#the-th-element">th</a></code> element <a href="#represents" id="the-th-element:represents">represents</a> a header <a href="#concept-cell" id="the-th-element:concept-cell">cell</a> in a table.</p>

  <p>The <code id="the-th-element:the-th-element-5"><a href="#the-th-element">th</a></code> element may have a <dfn data-dfn-for="th" id="attr-th-scope" data-dfn-type="element-attr"><code>scope</code></dfn> content attribute specified.</p>

  <p>The <code id="the-th-element:attr-th-scope-2"><a href="#attr-th-scope">scope</a></code> attribute is an <a href="#enumerated-attribute" id="the-th-element:enumerated-attribute">enumerated attribute</a>
  with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="th/scope" id="attr-th-scope-row" data-dfn-type="attr-value"><code>row</code></dfn>
     </td><td><dfn id="attr-th-scope-row-state">Row</dfn>
     </td><td>The header cell applies to some of the subsequent cells in the same row(s).
    </td></tr><tr><td><dfn data-dfn-for="th/scope" id="attr-th-scope-col" data-dfn-type="attr-value"><code>col</code></dfn>
     </td><td><dfn id="attr-th-scope-column-state">Column</dfn>
     </td><td>The header cell applies to some of the subsequent cells in the same column(s).
    </td></tr><tr><td><dfn data-dfn-for="th/scope" id="attr-th-scope-rowgroup" data-dfn-type="attr-value"><code>rowgroup</code></dfn>
     </td><td><dfn id="attr-th-scope-rowgroup-state">Row Group</dfn>
     </td><td>The header cell applies to all the remaining cells in the row group.
    </td></tr><tr><td><dfn data-dfn-for="th/scope" id="attr-th-scope-colgroup" data-dfn-type="attr-value"><code>colgroup</code></dfn>
     </td><td><dfn id="attr-th-scope-colgroup-state">Column Group</dfn>
     </td><td>The header cell applies to all the remaining cells in the column group.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-th-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-th-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <dfn id="attr-th-scope-auto-state">Auto</dfn> state. (In this state the header cell applies to a
  set of cells selected based on context.)</p>
  </div>

  <p>A <code id="the-th-element:the-th-element-6"><a href="#the-th-element">th</a></code> element's <code id="the-th-element:attr-th-scope-3"><a href="#attr-th-scope">scope</a></code> attribute must not be in
  the <a href="#attr-th-scope-rowgroup-state" id="the-th-element:attr-th-scope-rowgroup-state">Row Group</a> state if the element is not anchored in
  a <a href="#concept-row-group" id="the-th-element:concept-row-group">row group</a>, nor in the <a href="#attr-th-scope-colgroup-state" id="the-th-element:attr-th-scope-colgroup-state">Column Group</a> state if the element is not anchored in a
  <a href="#concept-column-group" id="the-th-element:concept-column-group">column group</a>.

  </p><p>The <code id="the-th-element:the-th-element-7"><a href="#the-th-element">th</a></code> element may have an <dfn data-dfn-for="th" id="attr-th-abbr" data-dfn-type="element-attr"><code>abbr</code></dfn> content attribute specified. Its value must be an
  alternative label for the header cell, to be used when referencing the cell in other contexts
  (e.g. when describing the header cells that apply to a data cell). It is typically an abbreviated
  form of the full header cell, but can also be an expansion, or merely a different phrasing.</p>

  

  <p>The <code id="the-th-element:the-th-element-8"><a href="#the-th-element">th</a></code> element and its <code id="the-th-element:attr-tdth-colspan-2"><a href="#attr-tdth-colspan">colspan</a></code>, <code id="the-th-element:attr-tdth-rowspan-2"><a href="#attr-tdth-rowspan">rowspan</a></code>, <code id="the-th-element:attr-tdth-headers-2"><a href="#attr-tdth-headers">headers</a></code>, and
  <code id="the-th-element:attr-th-scope-4"><a href="#attr-th-scope">scope</a></code> attributes take part in the <a href="#table-model" id="the-th-element:table-model">table model</a>.</p>

  

  <div class="example">

   <p>The following example shows how the <code id="the-th-element:attr-th-scope-5"><a href="#attr-th-scope">scope</a></code> attribute's <code id="the-th-element:attr-th-scope-rowgroup"><a href="#attr-th-scope-rowgroup">rowgroup</a></code> value affects which data cells a header cell
   applies to.</p>

   <p>Here is a markup fragment showing a table:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> ID <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Measurement <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Average <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Maximum
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">scope</c-><c- o="">=</c-><c- s="">rowgroup</c-><c- p="">&gt;</c-> Cats <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 93 <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Legs <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 3.5 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 4
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 10 <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Tails <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 1 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 1
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">scope</c-><c- o="">=</c-><c- s="">rowgroup</c-><c- p="">&gt;</c-> English speakers <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 32 <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Legs <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 2.67 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 4
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 35 <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Tails <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 0.33 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 1
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

   <p>This would result in the following table:</p>

   <table><thead><tr><th> ID </th><th> Measurement </th><th> Average </th><th> Maximum
    </th></tr></thead><tbody><tr><td> </td><th scope="rowgroup"> Cats </th><td> </td><td>
     </td></tr><tr><td> 93 </td><th> Legs </th><td> 3.5 </td><td> 4
     </td></tr><tr><td> 10 </td><th> Tails </th><td> 1 </td><td> 1
    </td></tr></tbody><tbody><tr><td> </td><th scope="rowgroup"> English speakers </th><td> </td><td>
     </td></tr><tr><td> 32 </td><th> Legs </th><td> 2.67 </td><td> 4
     </td></tr><tr><td> 35 </td><th> Tails </th><td> 0.33 </td><td> 1
   </td></tr></tbody></table>

   <p>The headers in the first row all apply directly down to the rows in their column.</p>

   <p>The headers with a <code id="the-th-element:attr-th-scope-6"><a href="#attr-th-scope">scope</a></code> attribute in the <a href="#attr-th-scope-rowgroup-state" id="the-th-element:attr-th-scope-rowgroup-state-2">Row Group</a> state apply to all the cells in their row
   group other than the cells in the first column.</p>

   <p>The remaining headers apply just to the cells to the right of them.</p>

   
   <img src="/images/table-scope-diagram.png" width="459" alt="" height="256">

  </div>



  <h4 id="attributes-common-to-td-and-th-elements"><span class="secno">4.9.11</span> Attributes common to <code id="attributes-common-to-td-and-th-elements:the-td-element"><a href="#the-td-element">td</a></code> and <code id="attributes-common-to-td-and-th-elements:the-th-element"><a href="#the-th-element">th</a></code> elements<a href="#attributes-common-to-td-and-th-elements" class="self-link"></a></h4>

  <p>The <code id="attributes-common-to-td-and-th-elements:the-td-element-2"><a href="#the-td-element">td</a></code> and <code id="attributes-common-to-td-and-th-elements:the-th-element-2"><a href="#the-th-element">th</a></code> elements may have a <dfn data-dfn-for="td,th" id="attr-tdth-colspan" data-dfn-type="element-attr"><code>colspan</code></dfn> content attribute specified, whose value must be a
  <a href="#valid-non-negative-integer" id="attributes-common-to-td-and-th-elements:valid-non-negative-integer">valid non-negative integer</a> greater than zero and less than or equal to 1000.</p>

  <p>The <code id="attributes-common-to-td-and-th-elements:the-td-element-3"><a href="#the-td-element">td</a></code> and <code id="attributes-common-to-td-and-th-elements:the-th-element-3"><a href="#the-th-element">th</a></code> elements may also have a <dfn data-dfn-for="td,th" id="attr-tdth-rowspan" data-dfn-type="element-attr"><code>rowspan</code></dfn> content attribute specified,
  whose value must be a <a href="#valid-non-negative-integer" id="attributes-common-to-td-and-th-elements:valid-non-negative-integer-2">valid non-negative integer</a> less than or equal to 65534.  For
  this attribute, the value zero means that the cell is to span all the remaining rows in the row
  group.</p> 

  <p>These attributes give the number of columns and rows respectively that the cell is to span.
  These attributes must not be used to overlap cells, as described in the
  description of the <a href="#table-model" id="attributes-common-to-td-and-th-elements:table-model">table model</a>.</p> 

  <hr>

  <p>The <code id="attributes-common-to-td-and-th-elements:the-td-element-4"><a href="#the-td-element">td</a></code> and <code id="attributes-common-to-td-and-th-elements:the-th-element-4"><a href="#the-th-element">th</a></code> element may have a <dfn data-dfn-for="td,th" id="attr-tdth-headers" data-dfn-type="element-attr"><code>headers</code></dfn> content attribute specified. The <code id="attributes-common-to-td-and-th-elements:attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attribute, if specified, must contain a string
  consisting of an <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-common-to-td-and-th-elements:unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</a>, none of which are
  <a id="attributes-common-to-td-and-th-elements:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> another token and each of which must have the value of an <a href="https://dom.spec.whatwg.org/#concept-id" id="attributes-common-to-td-and-th-elements:concept-id" data-x-internal="concept-id">ID</a> of a <code id="attributes-common-to-td-and-th-elements:the-th-element-5"><a href="#the-th-element">th</a></code> element taking part in the same <a href="#concept-table" id="attributes-common-to-td-and-th-elements:concept-table">table</a> as the <code id="attributes-common-to-td-and-th-elements:the-td-element-5"><a href="#the-td-element">td</a></code> or <code id="attributes-common-to-td-and-th-elements:the-th-element-6"><a href="#the-th-element">th</a></code> element (as defined by the <a href="#table-model" id="attributes-common-to-td-and-th-elements:table-model-2">table model</a>).</p>

  <div data-algorithm="">
  <p>A <code id="attributes-common-to-td-and-th-elements:the-th-element-7"><a href="#the-th-element">th</a></code> element with <a href="https://dom.spec.whatwg.org/#concept-id" id="attributes-common-to-td-and-th-elements:concept-id-2" data-x-internal="concept-id">ID</a> <var>id</var> is
  said to be <i>directly targeted</i> by all <code id="attributes-common-to-td-and-th-elements:the-td-element-6"><a href="#the-td-element">td</a></code> and <code id="attributes-common-to-td-and-th-elements:the-th-element-8"><a href="#the-th-element">th</a></code> elements in the
  same <a href="#concept-table" id="attributes-common-to-td-and-th-elements:concept-table-2">table</a> that have <code id="attributes-common-to-td-and-th-elements:attr-tdth-headers-2"><a href="#attr-tdth-headers">headers</a></code> attributes whose values include as one of their tokens
  the <a href="https://dom.spec.whatwg.org/#concept-id" id="attributes-common-to-td-and-th-elements:concept-id-3" data-x-internal="concept-id">ID</a> <var>id</var>. A <code id="attributes-common-to-td-and-th-elements:the-th-element-9"><a href="#the-th-element">th</a></code> element <var>A</var> is said to be <i>targeted</i> by a <code id="attributes-common-to-td-and-th-elements:the-th-element-10"><a href="#the-th-element">th</a></code> or <code id="attributes-common-to-td-and-th-elements:the-td-element-7"><a href="#the-td-element">td</a></code> element
  <var>B</var> if either <var>A</var> is <i>directly targeted</i> by <var>B</var> or if there exists an element <var>C</var> that is itself
  <i>targeted</i> by the element <var>B</var> and <var>A</var> is <i>directly
  targeted</i> by <var>C</var>.</p>
  </div>

  <p>A <code id="attributes-common-to-td-and-th-elements:the-th-element-11"><a href="#the-th-element">th</a></code> element must not be <i>targeted</i> by itself.</p>

  

  <p>The <code id="attributes-common-to-td-and-th-elements:attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code>, <code id="attributes-common-to-td-and-th-elements:attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code>, and <code id="attributes-common-to-td-and-th-elements:attr-tdth-headers-3"><a href="#attr-tdth-headers">headers</a></code>
  attributes take part in the <a href="#table-model" id="attributes-common-to-td-and-th-elements:table-model-3">table model</a>.</p>

  

  <hr>

  <dl class="domintro"><dt><code><var>cell</var>.<a href="#dom-tdth-cellindex" id="dom-tdth-cellindex-dev">cellIndex</a></code></dt><dd>
    <p>Returns the position of the cell in the row's <code id="attributes-common-to-td-and-th-elements:dom-tr-cells"><a href="#dom-tr-cells">cells</a></code> list.
    This does not necessarily correspond to the <var>x</var>-position of the cell in the table,
    since earlier cells might cover multiple rows or columns.</p>

    <p>Returns −1 if the element isn't in a row.</p>
   </dd></dl>

  

  

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-cellindex" data-dfn-type="attribute"><code>cellIndex</code></dfn> IDL attribute must, if the element has a parent
  <code id="attributes-common-to-td-and-th-elements:the-tr-element"><a href="#the-tr-element">tr</a></code> element, return the index of the cell's element in the parent element's <code id="attributes-common-to-td-and-th-elements:dom-tr-cells-2"><a href="#dom-tr-cells">cells</a></code> collection. If there is no such parent element, then the
  attribute must return −1.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTableCellElement" id="dom-th-scope" data-dfn-type="attribute"><code>scope</code></dfn>
  IDL attribute must <a href="#reflect" id="attributes-common-to-td-and-th-elements:reflect">reflect</a> the content attribute of the same name, <a href="#limited-to-only-known-values" id="attributes-common-to-td-and-th-elements:limited-to-only-known-values">limited to
  only known values</a>.</p>
  </div>

  


  

  <h4 id="table-processing-model"><span class="secno">4.9.12</span> <span id="processing-model-2"></span>Processing model<a href="#table-processing-model" class="self-link"></a></h4>

  <p>The various table elements and their content attributes together define the <dfn id="table-model">table
  model</dfn>.</p>

  <div data-algorithm="">
  <p>A <dfn id="concept-table">table</dfn> consists of cells aligned on a two-dimensional grid of
  <dfn id="concept-slots">slots</dfn> with coordinates (<var>x</var>, <var>y</var>). The grid is finite, and is either empty or has one or more slots. If the grid
  has one or more slots, then the <var>x</var> coordinates are always in the range <span>0&nbsp;≤&nbsp;<var>x</var>&nbsp;&lt;&nbsp;<var>x<sub>width</sub></var></span>, and the <var>y</var> coordinates are always in the
  range <span>0&nbsp;≤&nbsp;<var>y</var>&nbsp;&lt;&nbsp;<var>y<sub>height</sub></var></span>. If one or both of <var>x<sub>width</sub></var> and <var>y<sub>height</sub></var> are zero, then the
  table is empty (has no slots). Tables correspond to <code id="table-processing-model:the-table-element"><a href="#the-table-element">table</a></code> elements.</p>

  <p>A <dfn id="concept-cell">cell</dfn> is a set of slots anchored at a slot (<var>cell<sub>x</sub></var>, <var>cell<sub>y</sub></var>), and with
  a particular <var>width</var> and <var>height</var> such that the cell covers
  all the slots with coordinates (<var>x</var>, <var>y</var>) where <span><var>cell<sub>x</sub></var>&nbsp;≤&nbsp;<var>x</var>&nbsp;&lt;&nbsp;<var>cell<sub>x</sub></var>+<var>width</var></span> and <var>cell<sub>y</sub></var>&nbsp;≤&nbsp;<var>y</var>&nbsp;&lt;&nbsp;<var>cell<sub>y</sub></var>+<var>height</var>. Cells can either be <em>data cells</em>
  or <em>header cells</em>. Data cells correspond to <code id="table-processing-model:the-td-element"><a href="#the-td-element">td</a></code> elements, and header cells
  correspond to <code id="table-processing-model:the-th-element"><a href="#the-th-element">th</a></code> elements. Cells of both types can have zero or more associated
  header cells.</p>

  <p>It is possible, in certain error cases, for two cells to occupy the same slot.</p>

  <p>A <dfn id="concept-row">row</dfn> is a complete set of slots from <var>x</var>=0 to <var>x</var>=<var>x<sub>width</sub></var>-1, for a particular value of <var>y</var>. Rows usually
  correspond to <code id="table-processing-model:the-tr-element"><a href="#the-tr-element">tr</a></code> elements, though a <a href="#concept-row-group" id="table-processing-model:concept-row-group">row group</a>
  can have some implied <a href="#concept-row" id="table-processing-model:concept-row">rows</a> at the end in some cases involving
  <a href="#concept-cell" id="table-processing-model:concept-cell">cells</a> spanning multiple rows.</p>

  <p>A <dfn id="concept-column">column</dfn> is a complete set of slots from <var>y</var>=0 to <var>y</var>=<var>y<sub>height</sub></var>-1, for a particular value of <var>x</var>. Columns can
  correspond to <code id="table-processing-model:the-col-element"><a href="#the-col-element">col</a></code> elements. In the absence of <code id="table-processing-model:the-col-element-2"><a href="#the-col-element">col</a></code> elements, columns are
  implied.</p>

  <p>A <dfn id="concept-row-group">row group</dfn> is a set of <a href="#concept-row" id="table-processing-model:concept-row-2">rows</a> anchored at a slot (0, <var>group<sub>y</sub></var>) with a particular <var>height</var> such that the row group
  covers all the slots with coordinates (<var>x</var>, <var>y</var>) where <span>0&nbsp;≤&nbsp;<var>x</var>&nbsp;&lt;&nbsp;<var>x<sub>width</sub></var></span> and <var>group<sub>y</sub></var>&nbsp;≤&nbsp;<var>y</var>&nbsp;&lt;&nbsp;<var>group<sub>y</sub></var>+<var>height</var>. Row groups correspond to
  <code id="table-processing-model:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>, <code id="table-processing-model:the-thead-element"><a href="#the-thead-element">thead</a></code>, and <code id="table-processing-model:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> elements. Not every row is
  necessarily in a row group.</p>

  <p>A <dfn id="concept-column-group">column group</dfn> is a set of <a href="#concept-column" id="table-processing-model:concept-column">columns</a> anchored at a slot (<var>group<sub>x</sub></var>, 0) with a particular <var>width</var> such that the column group
  covers all the slots with coordinates (<var>x</var>, <var>y</var>) where <span><var>group<sub>x</sub></var>&nbsp;≤&nbsp;<var>x</var>&nbsp;&lt;&nbsp;<var>group<sub>x</sub></var>+<var>width</var></span> and <span>0&nbsp;≤&nbsp;<var>y</var>&nbsp;&lt;&nbsp;<var>y<sub>height</sub></var></span>. Column
  groups correspond to <code id="table-processing-model:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> elements. Not every column is necessarily in a column
  group.</p>
  </div>

  <p><a href="#concept-row-group" id="table-processing-model:concept-row-group-2">Row groups</a> cannot overlap each other. Similarly, <a href="#concept-column-group" id="table-processing-model:concept-column-group">column groups</a> cannot overlap each other.</p>

  <p>A <a href="#concept-cell" id="table-processing-model:concept-cell-2">cell</a> cannot cover slots that are from two or more <a href="#concept-row-group" id="table-processing-model:concept-row-group-3">row groups</a>. It is, however, possible for a cell to be in multiple
  <a href="#concept-column-group" id="table-processing-model:concept-column-group-2">column groups</a>. All the slots that form part of one cell
  are part of zero or one <a href="#concept-row-group" id="table-processing-model:concept-row-group-4">row groups</a> and zero or more <a href="#concept-column-group" id="table-processing-model:concept-column-group-3">column groups</a>.</p>

  <p>In addition to <a href="#concept-cell" id="table-processing-model:concept-cell-3">cells</a>, <a href="#concept-column" id="table-processing-model:concept-column-2">columns</a>, <a href="#concept-row" id="table-processing-model:concept-row-3">rows</a>, <a href="#concept-row-group" id="table-processing-model:concept-row-group-5">row groups</a>, and <a href="#concept-column-group" id="table-processing-model:concept-column-group-4">column
  groups</a>, <a href="#concept-table" id="table-processing-model:concept-table">tables</a> can have a <code id="table-processing-model:the-caption-element"><a href="#the-caption-element">caption</a></code> element
  associated with them. This gives the table a heading, or legend.</p>

  <p>A <dfn id="table-model-error">table model error</dfn> is an error with the data represented by <code id="table-processing-model:the-table-element-2"><a href="#the-table-element">table</a></code>
  elements and their descendants. Documents must not have table model errors.</p>


  <h5 id="forming-a-table"><span class="secno">4.9.12.1</span> Forming a table<a href="#forming-a-table" class="self-link"></a></h5>

  <div data-var-scope="">
  <div data-algorithm="">
  <p>To determine which elements correspond to which slots in a <a href="#concept-table" id="forming-a-table:concept-table">table</a> associated with a <code id="forming-a-table:the-table-element"><a href="#the-table-element">table</a></code> element, to determine the
  dimensions of the table (<var>x<sub>width</sub></var> and <var>y<sub>height</sub></var>), and to determine if there are any <a href="#table-model-error" id="forming-a-table:table-model-error">table model errors</a>, user agents must use the following algorithm:</p>

  <ol><li>
    <p>Let <var>x<sub>width</sub></var> be 0.</p>
   </li><li>
    <p>Let <var>y<sub>height</sub></var> be 0.</p>
   </li><li>
    <p>Let <var>pending <code id="forming-a-table:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> elements</var> be a list of <code id="forming-a-table:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code>
    elements, initially empty.</p>
   </li><li>
    <p>Let <var>the table</var> be the <a href="#concept-table" id="forming-a-table:concept-table-2">table</a> represented
    by the <code id="forming-a-table:the-table-element-2"><a href="#the-table-element">table</a></code> element. The <var>x<sub>width</sub></var> and <var>y<sub>height</sub></var> variables give <var>the table</var>'s
    dimensions. <var>The table</var> is initially empty.</p>
   </li><li>
    

    <p>If the <code id="forming-a-table:the-table-element-3"><a href="#the-table-element">table</a></code> element has no children elements, then return <var>the
    table</var> (which will be empty).</p>
   </li><li>
    <p>Associate the first <code id="forming-a-table:the-caption-element"><a href="#the-caption-element">caption</a></code> element child of the <code id="forming-a-table:the-table-element-4"><a href="#the-table-element">table</a></code> element with
    <var>the table</var>. If there are no such children, then it has no associated
    <code id="forming-a-table:the-caption-element-2"><a href="#the-caption-element">caption</a></code> element.</p>
   </li><li>
    <p>Let the <var>current element</var> be the first element child of the
    <code id="forming-a-table:the-table-element-5"><a href="#the-table-element">table</a></code> element.</p>

    <p>If a step in this algorithm ever requires the <var>current element</var> to be <dfn id="concept-table-advance">advanced to the next child of the <code>table</code></dfn> when
    there is no such next child, then the user agent must jump to the step labeled <i>end</i>, near
    the end of this algorithm.</p>
   </li><li>
    <p>While the <var>current element</var> is not one of the following elements, <a href="#concept-table-advance" id="forming-a-table:concept-table-advance">advance</a> the <var>current element</var> to the next
    child of the <code id="forming-a-table:the-table-element-6"><a href="#the-table-element">table</a></code>:</p>

    <ul class="brief"><li><code id="forming-a-table:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code></li><li><code id="forming-a-table:the-thead-element"><a href="#the-thead-element">thead</a></code></li><li><code id="forming-a-table:the-tbody-element"><a href="#the-tbody-element">tbody</a></code></li><li><code id="forming-a-table:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code></li><li><code id="forming-a-table:the-tr-element"><a href="#the-tr-element">tr</a></code></li></ul>
   </li><li>
    <p>If the <var>current element</var> is a <code id="forming-a-table:the-colgroup-element-2"><a href="#the-colgroup-element">colgroup</a></code>, follow these
    substeps:</p>

    <ol><li>
      <p><i>Column groups</i>: Process the <var>current element</var> according to the
      appropriate case below:</p>

      <dl class="switch"><dt>If the <var>current element</var> has any <code id="forming-a-table:the-col-element"><a href="#the-col-element">col</a></code> element children</dt><dd>
        <p>Follow these steps:</p>

        <ol><li>
          <p>Let <var>x<sub>start</sub></var> have the value of <span><var>x<sub>width</sub></var></span>.</p>
         </li><li>
          <p>Let the <var>current column</var> be the first <code id="forming-a-table:the-col-element-2"><a href="#the-col-element">col</a></code> element child
          of the <code id="forming-a-table:the-colgroup-element-3"><a href="#the-colgroup-element">colgroup</a></code> element.</p>
         </li><li>
          <p><i>Columns</i>: If the <var>current column</var> <code id="forming-a-table:the-col-element-3"><a href="#the-col-element">col</a></code> element has
          a <code id="forming-a-table:attr-col-span"><a href="#attr-col-span">span</a></code> attribute, then parse its value using the
          <a href="#rules-for-parsing-non-negative-integers" id="forming-a-table:rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a>.</p>

          <p>If the result of parsing the value is not an error or zero, then let <var>span</var> be that value.</p>

          <p>Otherwise, if the <code id="forming-a-table:the-col-element-4"><a href="#the-col-element">col</a></code> element has no <code id="forming-a-table:attr-col-span-2"><a href="#attr-col-span">span</a></code> attribute, or if trying to parse the attribute's value
          resulted in an error or zero, then let <var>span</var> be 1.</p>

          <p>If <var>span</var> is greater than 1000, let it be 1000 instead.</p>
         </li><li>
          <p>Increase <var>x<sub>width</sub></var> by <var>span</var>.</p>
         </li><li>
          <p>Let the last <var>span</var> <a href="#concept-column" id="forming-a-table:concept-column">columns</a> in
          <var>the table</var> correspond to the <var>current column</var>
          <code id="forming-a-table:the-col-element-5"><a href="#the-col-element">col</a></code> element.</p>
         </li><li>
          <p>If <var>current column</var> is not the last <code id="forming-a-table:the-col-element-6"><a href="#the-col-element">col</a></code> element child of
          the <code id="forming-a-table:the-colgroup-element-4"><a href="#the-colgroup-element">colgroup</a></code> element, then let the <var>current column</var> be the
          next <code id="forming-a-table:the-col-element-7"><a href="#the-col-element">col</a></code> element child of the <code id="forming-a-table:the-colgroup-element-5"><a href="#the-colgroup-element">colgroup</a></code> element, and return to
          the step labeled <i>columns</i>.</p>
         </li><li>
          <p>Let all the last <a href="#concept-column" id="forming-a-table:concept-column-2">columns</a> in <var>the
          table</var> from <span>x=<var>x<sub>start</sub></var></span> to
          <span>x=<var>x<sub>width</sub></var>-1</span> form a new <a href="#concept-column-group" id="forming-a-table:concept-column-group">column group</a>, anchored at the slot (<var>x<sub>start</sub></var>, 0), with width <var>x<sub>width</sub></var>-<var>x<sub>start</sub></var>, corresponding to the <code id="forming-a-table:the-colgroup-element-6"><a href="#the-colgroup-element">colgroup</a></code> element.</p>
         </li></ol>
       </dd><dt>If the <var>current element</var> has no <code id="forming-a-table:the-col-element-8"><a href="#the-col-element">col</a></code> element children</dt><dd>
        <ol><li>
          <p>If the <code id="forming-a-table:the-colgroup-element-7"><a href="#the-colgroup-element">colgroup</a></code> element has a <code id="forming-a-table:attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code>
 attribute, then parse its value using the <a href="#rules-for-parsing-non-negative-integers" id="forming-a-table:rules-for-parsing-non-negative-integers-2">rules for parsing non-negative
          integers</a>.</p>

          <p>If the result of parsing the value is not an error or zero, then let <var>span</var> be that value.</p>

          <p>Otherwise, if the <code id="forming-a-table:the-colgroup-element-8"><a href="#the-colgroup-element">colgroup</a></code> element has no <code id="forming-a-table:attr-colgroup-span-2"><a href="#attr-colgroup-span">span</a></code> attribute, or if trying to parse the attribute's
          value resulted in an error or zero, then let <var>span</var> be 1.</p>

          <p>If <var>span</var> is greater than 1000, let it be 1000 instead.</p>
         </li><li>
          <p>Increase <var>x<sub>width</sub></var> by <var>span</var>.</p>
         </li><li>
          <p>Let the last <var>span</var> <a href="#concept-column" id="forming-a-table:concept-column-3">columns</a> in
          <var>the table</var> form a new <a href="#concept-column-group" id="forming-a-table:concept-column-group-2">column
          group</a>, anchored at the slot (<var>x<sub>width</sub></var>-<var>span</var>, 0), with width <var>span</var>, corresponding to the <code id="forming-a-table:the-colgroup-element-9"><a href="#the-colgroup-element">colgroup</a></code> element.</p>
         </li></ol>
       </dd></dl>
     </li><li>
      <p><a href="#concept-table-advance" id="forming-a-table:concept-table-advance-2">Advance</a> the <var>current element</var>
      to the next child of the <code id="forming-a-table:the-table-element-7"><a href="#the-table-element">table</a></code>.</p>
     </li><li>
      <p>While the <var>current element</var> is not one of the following elements, <a href="#concept-table-advance" id="forming-a-table:concept-table-advance-3">advance</a> the <var>current element</var> to the
      next child of the <code id="forming-a-table:the-table-element-8"><a href="#the-table-element">table</a></code>:</p>

      <ul class="brief"><li><code id="forming-a-table:the-colgroup-element-10"><a href="#the-colgroup-element">colgroup</a></code></li><li><code id="forming-a-table:the-thead-element-2"><a href="#the-thead-element">thead</a></code></li><li><code id="forming-a-table:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code></li><li><code id="forming-a-table:the-tfoot-element-4"><a href="#the-tfoot-element">tfoot</a></code></li><li><code id="forming-a-table:the-tr-element-2"><a href="#the-tr-element">tr</a></code></li></ul>
     </li><li>
      <p>If the <var>current element</var> is a <code id="forming-a-table:the-colgroup-element-11"><a href="#the-colgroup-element">colgroup</a></code> element, jump to the
      step labeled <i>column groups</i> above.</p>
     </li></ol>
   </li><li>
    <p>Let <var>y<sub>current</sub></var> be 0.</p>
   </li><li>
    <p>Let the <var>list of downward-growing cells</var> be an empty list.</p>
   </li><li>
    <p><i>Rows</i>: While the <var>current element</var> is not one of the following
    elements, <a href="#concept-table-advance" id="forming-a-table:concept-table-advance-4">advance</a> the <var>current
    element</var> to the next child of the <code id="forming-a-table:the-table-element-9"><a href="#the-table-element">table</a></code>:</p>

    <ul class="brief"><li><code id="forming-a-table:the-thead-element-3"><a href="#the-thead-element">thead</a></code></li><li><code id="forming-a-table:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code></li><li><code id="forming-a-table:the-tfoot-element-5"><a href="#the-tfoot-element">tfoot</a></code></li><li><code id="forming-a-table:the-tr-element-3"><a href="#the-tr-element">tr</a></code></li></ul>
   </li><li>
    <p>If the <var>current element</var> is a <code id="forming-a-table:the-tr-element-4"><a href="#the-tr-element">tr</a></code>, then run the <a href="#algorithm-for-processing-rows" id="forming-a-table:algorithm-for-processing-rows">algorithm
    for processing rows</a>, <a href="#concept-table-advance" id="forming-a-table:concept-table-advance-5">advance</a> the <var>current element</var> to the next child of the <code id="forming-a-table:the-table-element-10"><a href="#the-table-element">table</a></code>, and return to the
    step labeled <i>rows</i>.</p>
   </li><li>
    <p>Run the <a href="#algorithm-for-ending-a-row-group" id="forming-a-table:algorithm-for-ending-a-row-group">algorithm for ending a row group</a>.</p>
   </li><li>
    <p>If the <var>current element</var> is a <code id="forming-a-table:the-tfoot-element-6"><a href="#the-tfoot-element">tfoot</a></code>, then add that element to
    the list of <var>pending <code id="forming-a-table:the-tfoot-element-7"><a href="#the-tfoot-element">tfoot</a></code> elements</var>, <a href="#concept-table-advance" id="forming-a-table:concept-table-advance-6">advance</a> the <var>current element</var> to the next
    child of the <code id="forming-a-table:the-table-element-11"><a href="#the-table-element">table</a></code>, and return to the step labeled <i>rows</i>.</p>
   </li><li>
    <p>The <var>current element</var> is either a <code id="forming-a-table:the-thead-element-4"><a href="#the-thead-element">thead</a></code> or a
    <code id="forming-a-table:the-tbody-element-4"><a href="#the-tbody-element">tbody</a></code>.</p>

    <p>Run the <a href="#algorithm-for-processing-row-groups" id="forming-a-table:algorithm-for-processing-row-groups">algorithm for processing row groups</a>.</p>
   </li><li>
    <p><a href="#concept-table-advance" id="forming-a-table:concept-table-advance-7">Advance</a> the <var>current element</var> to
    the next child of the <code id="forming-a-table:the-table-element-12"><a href="#the-table-element">table</a></code>.</p>
   </li><li>
    <p>Return to the step labeled <i>rows</i>.</p>
   </li><li>
    <p><i>End</i>: For each <code id="forming-a-table:the-tfoot-element-8"><a href="#the-tfoot-element">tfoot</a></code> element in the list of <var>pending
    <code id="forming-a-table:the-tfoot-element-9"><a href="#the-tfoot-element">tfoot</a></code> elements</var>, in <a id="forming-a-table:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, run the <a href="#algorithm-for-processing-row-groups" id="forming-a-table:algorithm-for-processing-row-groups-2">algorithm for processing row
    groups</a>.</p>
   </li><li>
    <p>If there exists a <a href="#concept-row" id="forming-a-table:concept-row">row</a> or <a href="#concept-column" id="forming-a-table:concept-column-4">column</a> in <var>the table</var> containing only <a href="#concept-slots" id="forming-a-table:concept-slots">slots</a> that do not have a <a href="#concept-cell" id="forming-a-table:concept-cell">cell</a>
    anchored to them, then this is a <a href="#table-model-error" id="forming-a-table:table-model-error-2">table model error</a>.</p>
   </li><li>
    <p>Return <var>the table</var>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="algorithm-for-processing-row-groups">algorithm for processing row groups</dfn>, which is invoked by the set of steps above
  for processing <code id="forming-a-table:the-thead-element-5"><a href="#the-thead-element">thead</a></code>, <code id="forming-a-table:the-tbody-element-5"><a href="#the-tbody-element">tbody</a></code>, and <code id="forming-a-table:the-tfoot-element-10"><a href="#the-tfoot-element">tfoot</a></code> elements, is:</p>

  <ol><li>
    <p>Let <var>y<sub>start</sub></var> have the value of <var>y<sub>height</sub></var>.</p>
   </li><li>
    <p>For each <code id="forming-a-table:the-tr-element-5"><a href="#the-tr-element">tr</a></code> element that is a child of the element being processed, in tree
    order, run the <a href="#algorithm-for-processing-rows" id="forming-a-table:algorithm-for-processing-rows-2">algorithm for processing rows</a>.</p>
   </li><li>
    
    <p>If <var>y<sub>height</sub></var>&nbsp;&gt;&nbsp;<var>y<sub>start</sub></var>, then let all the last <a href="#concept-row" id="forming-a-table:concept-row-2">rows</a> in <var>the table</var> from <span>y=<var>y<sub>start</sub></var></span> to <span>y=<var>y<sub>height</sub></var>-1</span> form a new <a href="#concept-row-group" id="forming-a-table:concept-row-group">row
    group</a>, anchored at the slot with coordinate (0, <var>y<sub>start</sub></var>), with height <var>y<sub>height</sub></var>-<var>y<sub>start</sub></var>, corresponding
    to the element being processed.</p>
   </li><li>
    <p>Run the <a href="#algorithm-for-ending-a-row-group" id="forming-a-table:algorithm-for-ending-a-row-group-2">algorithm for ending a row group</a>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="algorithm-for-ending-a-row-group">algorithm for ending a row group</dfn>, which is invoked by the set of steps above
  when starting and ending a block of rows, is:</p>

  <ol><li>
    <p>While <var>y<sub>current</sub></var> is less than <var>y<sub>height</sub></var>, follow these steps:</p>

    <ol><li>
      <p>Run the <a href="#algorithm-for-growing-downward-growing-cells" id="forming-a-table:algorithm-for-growing-downward-growing-cells">algorithm for growing downward-growing cells</a>.</p>
     </li><li>
      <p>Increase <var>y<sub>current</sub></var> by 1.</p>
     </li></ol>
   </li><li>
    <p>Empty the <var>list of downward-growing cells</var>.</p>
   </li></ol>
  </div>


  <div data-algorithm="">
  <p>The <dfn id="algorithm-for-processing-rows">algorithm for processing rows</dfn>, which is invoked by the set of steps above for
  processing <code id="forming-a-table:the-tr-element-6"><a href="#the-tr-element">tr</a></code> elements, is:</p>

  <ol><li>
    <p>If <var>y<sub>height</sub></var> is equal to <var>y<sub>current</sub></var>, then increase <var>y<sub>height</sub></var> by
    1. (<var>y<sub>current</sub></var> is never <em>greater</em> than <var>y<sub>height</sub></var>.)</p>
   </li><li>
    <p>Let <var>x<sub>current</sub></var> be 0.</p>
   </li><li>
    <p>Run the <a href="#algorithm-for-growing-downward-growing-cells" id="forming-a-table:algorithm-for-growing-downward-growing-cells-2">algorithm for growing downward-growing cells</a>.</p>
   </li><li>
    <p>If the <code id="forming-a-table:the-tr-element-7"><a href="#the-tr-element">tr</a></code> element being processed has no <code id="forming-a-table:the-td-element"><a href="#the-td-element">td</a></code> or <code id="forming-a-table:the-th-element"><a href="#the-th-element">th</a></code>
    element children, then increase <var>y<sub>current</sub></var> by 1, abort
    this set of steps, and return to the algorithm above.</p>
   </li><li>
    <p>Let <var>current cell</var> be the first <code id="forming-a-table:the-td-element-2"><a href="#the-td-element">td</a></code> or <code id="forming-a-table:the-th-element-2"><a href="#the-th-element">th</a></code> element child
    in the <code id="forming-a-table:the-tr-element-8"><a href="#the-tr-element">tr</a></code> element being processed.</p>
   </li><li>
    <p><i>Cells</i>: While <var>x<sub>current</sub></var> is less than <var>x<sub>width</sub></var> and the slot with coordinate (<var>x<sub>current</sub></var>, <var>y<sub>current</sub></var>) already has a
    cell assigned to it, increase <var>x<sub>current</sub></var> by 1.</p>
   </li><li>
    <p>If <var>x<sub>current</sub></var> is equal to <var>x<sub>width</sub></var>, increase <var>x<sub>width</sub></var> by 1. (<var>x<sub>current</sub></var> is never <em>greater</em> than <var>x<sub>width</sub></var>.)</p>
   </li><li>
    <p>If the <var>current cell</var> has a <code id="forming-a-table:attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code>
    attribute, then <a href="#rules-for-parsing-non-negative-integers" id="forming-a-table:rules-for-parsing-non-negative-integers-3">parse that attribute's
    value</a>, and let <var>colspan</var> be the result.</p>

    <p>If parsing that value failed, or returned zero, or if the attribute is absent, then let <var>colspan</var> be 1, instead.</p>

    <p>If <var>colspan</var> is greater than 1000, let it be 1000 instead.</p>
   </li><li>
    <p>If the <var>current cell</var> has a <code id="forming-a-table:attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code>
    attribute, then <a href="#rules-for-parsing-non-negative-integers" id="forming-a-table:rules-for-parsing-non-negative-integers-4">parse that attribute's
    value</a>, and let <var>rowspan</var> be the result.</p>

    <p>If parsing that value failed or if the attribute is absent, then let <var>rowspan</var> be 1, instead.</p>

    <p>If <var>rowspan</var> is greater than 65534, let it be 65534 instead.</p>
   </li><li><p>Let <var>cell grows downward</var> be false.</p></li><li><p>If <var>rowspan</var> is zero, then set <var>cell grows downward</var> to true and set
   <var>rowspan</var> to 1.</p></li><li>
    <p>If <var>x<sub>width</sub></var>&nbsp;&lt;&nbsp;<var>x<sub>current</sub></var>+<var>colspan</var>, then let <var>x<sub>width</sub></var> be <var>x<sub>current</sub></var>+<var>colspan</var>.</p>
   </li><li>
    <p>If <var>y<sub>height</sub></var>&nbsp;&lt;&nbsp;<var>y<sub>current</sub></var>+<var>rowspan</var>, then let <var>y<sub>height</sub></var> be <var>y<sub>current</sub></var>+<var>rowspan</var>.</p>
   </li><li>
    <p>Let the slots with coordinates (<var>x</var>, <var>y</var>) such that <span><var>x<sub>current</sub></var>&nbsp;≤&nbsp;<var>x</var>&nbsp;&lt;&nbsp;<var>x<sub>current</sub></var>+<var>colspan</var></span> and <var>y<sub>current</sub></var>&nbsp;≤&nbsp;<var>y</var>&nbsp;&lt;&nbsp;<var>y<sub>current</sub></var>+<var>rowspan</var> be covered by a
    new <a href="#concept-cell" id="forming-a-table:concept-cell-2">cell</a> <var>c</var>, anchored at (<var>x<sub>current</sub></var>, <var>y<sub>current</sub></var>),
    which has width <var>colspan</var> and height <var>rowspan</var>,
    corresponding to the <var>current cell</var> element.</p>

    <p>If the <var>current cell</var> element is a <code id="forming-a-table:the-th-element-3"><a href="#the-th-element">th</a></code> element, let this new
    cell <var>c</var> be a header cell; otherwise, let it be a data cell.</p>

    <p>To establish which header cells apply to the <var>current cell</var> element, use
    the <a href="#algorithm-for-assigning-header-cells" id="forming-a-table:algorithm-for-assigning-header-cells">algorithm for assigning header cells</a> described in the next section.</p>

    <p>If any of the slots involved already had a <a href="#concept-cell" id="forming-a-table:concept-cell-3">cell</a> covering
    them, then this is a <a href="#table-model-error" id="forming-a-table:table-model-error-3">table model error</a>. Those slots now have two cells
    overlapping.</p>
   </li><li>
    <p>If <var>cell grows downward</var> is true, then add the tuple {<var>c</var>, <var>x<sub>current</sub></var>, <var>colspan</var>}
    to the <var>list of downward-growing cells</var>.</p>
   </li><li>
    <p>Increase <var>x<sub>current</sub></var> by <var>colspan</var>.</p>
   </li><li>
    <p>If <var>current cell</var> is the last <code id="forming-a-table:the-td-element-3"><a href="#the-td-element">td</a></code> or <code id="forming-a-table:the-th-element-4"><a href="#the-th-element">th</a></code> element child in
    the <code id="forming-a-table:the-tr-element-9"><a href="#the-tr-element">tr</a></code> element being processed, then increase <var>y<sub>current</sub></var> by 1, abort this set of steps, and return to the algorithm
    above.</p>
   </li><li>
    <p>Let <var>current cell</var> be the next <code id="forming-a-table:the-td-element-4"><a href="#the-td-element">td</a></code> or <code id="forming-a-table:the-th-element-5"><a href="#the-th-element">th</a></code> element child
    in the <code id="forming-a-table:the-tr-element-10"><a href="#the-tr-element">tr</a></code> element being processed.</p>
   </li><li>
    <p>Return to the step labeled <i>cells</i>.</p>
   </li></ol>
  </div>


  <div data-algorithm="">
  <p>When the algorithms above require the user agent to run the <dfn id="algorithm-for-growing-downward-growing-cells">algorithm for growing
  downward-growing cells</dfn>, the user agent must, for each {<var>cell</var>, <var>cell<sub>x</sub></var>, <var>width</var>} tuple in the <var>list of downward-growing cells</var>, if any, extend the <a href="#concept-cell" id="forming-a-table:concept-cell-4">cell</a> <var>cell</var> so that it also covers the slots with
  coordinates (<var>x</var>, <var>y<sub>current</sub></var>), where <span><var>cell<sub>x</sub></var>&nbsp;≤&nbsp;<var>x</var>&nbsp;&lt;&nbsp;<var>cell<sub>x</sub></var>+<var>width</var></span>.</p>
  </div>
  </div>




  <h5 id="header-and-data-cell-semantics"><span class="secno">4.9.12.2</span> Forming relationships between data cells and header cells<a href="#header-and-data-cell-semantics" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Each cell can be assigned zero or more header cells. The <dfn id="algorithm-for-assigning-header-cells">algorithm for assigning header
  cells</dfn> to a cell <var>principal cell</var> is as follows.</p>

  <ol><li>
    <p>Let <var>header list</var> be an empty list of cells.</p>
   </li><li>
    <p>Let (<var>principal<sub>x</sub></var>, <var>principal<sub>y</sub></var>) be the coordinate of the slot to which the <var>principal
    cell</var> is anchored.</p>
   </li><li>
    <dl class="switch"><dt>If the <var>principal cell</var> has a <code id="header-and-data-cell-semantics:attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attribute specified</dt><dd>
      

      <ol><li>
        <p>Take the value of the <var>principal cell</var>'s <code id="header-and-data-cell-semantics:attr-tdth-headers-2"><a href="#attr-tdth-headers">headers</a></code> attribute and <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="header-and-data-cell-semantics:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">split it on ASCII whitespace</a>, letting <var>id list</var> be the
        list of tokens obtained.</p>
       </li><li>
        
        
        <p>For each token in the <var>id list</var>, if the
        first element in the <code id="header-and-data-cell-semantics:document"><a href="#document">Document</a></code> with an <a href="https://dom.spec.whatwg.org/#concept-id" id="header-and-data-cell-semantics:concept-id" data-x-internal="concept-id">ID</a> equal to
        the token is a cell in the same <a href="#concept-table" id="header-and-data-cell-semantics:concept-table">table</a>, and that cell is not the
        <var>principal cell</var>, then add that cell to <var>header list</var>.</p>
       </li></ol>
     </dd><dt>If <var>principal cell</var> does not have a <code id="header-and-data-cell-semantics:attr-tdth-headers-3"><a href="#attr-tdth-headers">headers</a></code> attribute specified</dt><dd>
      <ol><li>
        <p>Let <var>principal<sub>width</sub></var> be the width of the <var>principal cell</var>.</p>
       </li><li>
        <p>Let <var>principal<sub>height</sub></var> be the height of the <var>principal cell</var>.</p>
       </li><li>
        <p>For each value of <var>y</var> from <var>principal<sub>y</sub></var> to <var>principal<sub>y</sub></var>+<var>principal<sub>height</sub></var>-1, run
        the <a href="#internal-algorithm-for-scanning-and-assigning-header-cells" id="header-and-data-cell-semantics:internal-algorithm-for-scanning-and-assigning-header-cells">internal algorithm for scanning and assigning header cells</a>, with the <var>principal cell</var>, the <var>header list</var>, the initial coordinate
        (<var>principal<sub>x</sub></var>, <var>y</var>), and the
        increments <span>Δ<var>x</var>=−1</span> and <span>Δ<var>y</var>=0</span>.</p>
       </li><li>
        <p>For each value of <var>x</var> from <var>principal<sub>x</sub></var> to <var>principal<sub>x</sub></var>+<var>principal<sub>width</sub></var>-1, run
        the <a href="#internal-algorithm-for-scanning-and-assigning-header-cells" id="header-and-data-cell-semantics:internal-algorithm-for-scanning-and-assigning-header-cells-2">internal algorithm for scanning and assigning header cells</a>, with the <var>principal cell</var>, the <var>header list</var>, the initial coordinate
        (<var>x</var>, <var>principal<sub>y</sub></var>), and the
        increments <span>Δ<var>x</var>=0</span> and <span>Δ<var>y</var>=−1</span>.</p>
       </li><li>
        <p>If the <var>principal cell</var> is anchored in a <a href="#concept-row-group" id="header-and-data-cell-semantics:concept-row-group">row group</a>, then add all header cells that are <a href="#row-group-header" id="header-and-data-cell-semantics:row-group-header">row group headers</a> and are anchored in the same row group
        with an <var>x</var>-coordinate less than or equal to <var>principal<sub>x</sub></var>+<var>principal<sub>width</sub></var>-1 and a <var>y</var>-coordinate less than or
        equal to <var>principal<sub>y</sub></var>+<var>principal<sub>height</sub></var>-1 to <var>header
        list</var>.</p>

        
       </li><li>
        <p>If the <var>principal cell</var> is anchored in a <a href="#concept-column-group" id="header-and-data-cell-semantics:concept-column-group">column group</a>, then add all header cells that are <a href="#column-group-header" id="header-and-data-cell-semantics:column-group-header">column group headers</a> and are anchored in the same column
        group with an <var>x</var>-coordinate less than or equal to <var>principal<sub>x</sub></var>+<var>principal<sub>width</sub></var>-1 and a <var>y</var>-coordinate less than or
        equal to <var>principal<sub>y</sub></var>+<var>principal<sub>height</sub></var>-1 to <var>header
        list</var>.</p>

        
       </li></ol>
     </dd></dl>
   </li><li>
    <p>Remove all the <a href="#empty-cell" id="header-and-data-cell-semantics:empty-cell">empty cells</a> from the <var>header
    list</var>.</p>
   </li><li>
    <p>Remove any duplicates from the <var>header list</var>.</p>
   </li><li>
    <p>Remove <var>principal cell</var> from the <var>header list</var> if it is
    there.</p> 
   </li><li>
    <p>Assign the headers in the <var>header list</var> to the <var>principal
    cell</var>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="internal-algorithm-for-scanning-and-assigning-header-cells">internal algorithm for scanning and assigning header cells</dfn>, given a <var>principal cell</var>, a <var>header list</var>, an initial coordinate (<var>initial<sub>x</sub></var>, <var>initial<sub>y</sub></var>),
  and Δ<var>x</var> and Δ<var>y</var> increments, is as follows:</p>

  <ol><li>
    <p>Let <var>x</var> equal <var>initial<sub>x</sub></var>.</p>
   </li><li>
    <p>Let <var>y</var> equal <var>initial<sub>y</sub></var>.</p>
   </li><li>
    <p>Let <var>opaque headers</var> be an empty list of cells.</p>
   </li><li>
    <dl class="switch"><dt>If <var>principal cell</var> is a header cell</dt><dd><p>Let <var>in header block</var> be true, and let <var>headers from
     current header block</var> be a list of cells containing just the <var>principal
     cell</var>.</p></dd><dt>Otherwise</dt><dd><p>Let <var>in header block</var> be false and let <var>headers from
     current header block</var> be an empty list of cells.</p>
    </dd></dl>
   </li><li>
    <p><i>Loop</i>: Increment <var>x</var> by Δ<var>x</var>; increment <var>y</var> by Δ<var>y</var>.</p>

    <p class="note">For each invocation of this algorithm, one of Δ<var>x</var> and
    Δ<var>y</var> will be −1, and the other will be 0.</p>
   </li><li>
    <p>If either <var>x</var> or <var>y</var> are less than 0, then abort this
    internal algorithm.</p>
   </li><li>
    <p>If there is no cell covering slot (<var>x</var>, <var>y</var>), or if there
    is more than one cell covering slot (<var>x</var>, <var>y</var>), return to
    the substep labeled <i>loop</i>.</p>
   </li><li>
    <p>Let <var>current cell</var> be the cell covering slot (<var>x</var>, <var>y</var>).</p>
   </li><li>
    <dl class="switch"><dt>If <var>current cell</var> is a header cell</dt><dd>
      <ol><li><p>Set <var>in header block</var> to true.</p></li><li><p>Add <var>current cell</var> to <var>headers from current header
       block</var>.</p></li><li><p>Let <var>blocked</var> be false.</p></li><li>
        <dl class="switch"><dt>If Δ<var>x</var> is 0</dt><dd>
          <p>If there are any cells in the <var>opaque headers</var> list anchored with the
          same <var>x</var>-coordinate as the <var>current cell</var>, and with
          the same width as <var>current cell</var>, then let <var>blocked</var>
          be true.</p>

          <p>If the <var>current cell</var> is not a <a href="#column-header" id="header-and-data-cell-semantics:column-header">column header</a>, then let
          <var>blocked</var> be true.</p>
         </dd><dt>If Δ<var>y</var> is 0</dt><dd>
          <p>If there are any cells in the <var>opaque headers</var> list anchored with the
          same <var>y</var>-coordinate as the <var>current cell</var>, and with
          the same height as <var>current cell</var>, then let <var>blocked</var>
          be true.</p>

          <p>If the <var>current cell</var> is not a <a href="#row-header" id="header-and-data-cell-semantics:row-header">row header</a>, then let <var>blocked</var> be true.</p>
         </dd></dl>
       </li><li><p>If <var>blocked</var> is false, then add the <var>current cell</var>
       to the <var>header list</var>.</p></li></ol>
     </dd><dt>If <var>current cell</var> is a data cell and <var>in header block</var> is true</dt><dd><p>Set <var>in header block</var> to false. Add all the cells in <var>headers from current header block</var> to the <var>opaque headers</var>
     list, and empty the <var>headers from current header block</var> list.</p>
    </dd></dl>
   </li><li>
    <p>Return to the step labeled <i>loop</i>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>A header cell anchored at the slot with coordinate (<var>x</var>, <var>y</var>) with width
  <var>width</var> and height <var>height</var> is said to be a <dfn id="column-header">column header</dfn> if any of
  the following are true:</p>

  <ul><li><p>the cell's <code id="header-and-data-cell-semantics:attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute is in the <a href="#attr-th-scope-column-state" id="header-and-data-cell-semantics:attr-th-scope-column-state">Column</a> state; or</p></li><li><p>the cell's <code id="header-and-data-cell-semantics:attr-th-scope-2"><a href="#attr-th-scope">scope</a></code> attribute is in the <a href="#attr-th-scope-auto-state" id="header-and-data-cell-semantics:attr-th-scope-auto-state">Auto</a> state, and there are no data cells in any of the
   cells covering slots with <var>y</var>-coordinates <var>y</var> .. <span><var>y</var>+<var>height</var>-1</span>.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>A header cell anchored at the slot with coordinate (<var>x</var>, <var>y</var>) with width
  <var>width</var> and height <var>height</var> is said to be a <dfn id="row-header">row header</dfn> if any of the
  following are true:</p>

  <ul><li><p>the cell's <code id="header-and-data-cell-semantics:attr-th-scope-3"><a href="#attr-th-scope">scope</a></code> attribute is in the <a href="#attr-th-scope-row-state" id="header-and-data-cell-semantics:attr-th-scope-row-state">Row</a> state; or</p></li><li><p>the cell's <code id="header-and-data-cell-semantics:attr-th-scope-4"><a href="#attr-th-scope">scope</a></code> attribute is in the <a href="#attr-th-scope-auto-state" id="header-and-data-cell-semantics:attr-th-scope-auto-state-2">Auto</a> state, the cell is not a <a href="#column-header" id="header-and-data-cell-semantics:column-header-2">column
   header</a>, and there are no data cells in any of the cells covering slots with
   <var>x</var>-coordinates <var>x</var> .. <var>x</var>+<var>width</var>-1.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>A header cell is said to be a <dfn id="column-group-header">column group header</dfn> if its <code id="header-and-data-cell-semantics:attr-th-scope-5"><a href="#attr-th-scope">scope</a></code> attribute is in the <a href="#attr-th-scope-colgroup-state" id="header-and-data-cell-semantics:attr-th-scope-colgroup-state">Column Group</a> state.</p>
  </div>

  <div data-algorithm="">
  <p>A header cell is said to be a <dfn id="row-group-header">row group header</dfn> if its <code id="header-and-data-cell-semantics:attr-th-scope-6"><a href="#attr-th-scope">scope</a></code> attribute is in the <a href="#attr-th-scope-rowgroup-state" id="header-and-data-cell-semantics:attr-th-scope-rowgroup-state">Row Group</a> state.</p>
  </div>

  <div data-algorithm="">
  <p>A cell is said to be an <dfn id="empty-cell">empty cell</dfn> if it contains no elements and its <a id="header-and-data-cell-semantics:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child
  text content</a>, if any, consists only of <a id="header-and-data-cell-semantics:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p>
  </div>

  

  <h4 id="table-examples"><span class="secno">4.9.13</span> Examples<a href="#table-examples" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>The following shows how one might mark up the bottom part of table 45 of the <cite>Smithsonian
  physical tables, Volume 71</cite>:</p>

   
   
  <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->Specification values: <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->Steel<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->, <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->Castings<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->,
 Ann. A.S.T.M. A27-16, Class B;* P max. 0.06; S max. 0.05.<c- p="">&lt;/</c-><c- f="">caption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">rowspan</c-><c- o="">=</c-><c- s="">2</c-><c- p="">&gt;</c->Grade.<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">rowspan</c-><c- o="">=</c-><c- s="">2</c-><c- p="">&gt;</c->Yield Point.<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">colspan</c-><c- o="">=</c-><c- s="">2</c-><c- p="">&gt;</c->Ultimate tensile strength<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">rowspan</c-><c- o="">=</c-><c- s="">2</c-><c- p="">&gt;</c->Per cent elong. 50.8<c- ni="">&amp;nbsp;</c->mm or 2<c- ni="">&amp;nbsp;</c->in.<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">rowspan</c-><c- o="">=</c-><c- s="">2</c-><c- p="">&gt;</c->Per cent reduct. area.<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->kg/mm<c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">sup</c-><c- p="">&gt;&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->lb/in<c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">sup</c-><c- p="">&gt;&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">thead</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Hard<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->0.45 ultimate<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->56.2<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->80,000<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->15<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->20<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Medium<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->0.45 ultimate<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->49.2<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->70,000<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->18<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->25<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Soft<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->0.45 ultimate<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->42.2<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->60,000<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->22<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->30<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">tbody</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

  <p>This table could look like this:</p>

  <table id="table-example-1"><caption>Specification values: <b>Steel</b>, <b>Castings</b>,
   Ann. A.S.T.M. A27-16, Class B;* P max. 0.06; S max. 0.05.</caption><thead><tr><th rowspan="2">Grade.</th><th rowspan="2">Yield Point.</th><th colspan="2">Ultimate tensile strength</th><th rowspan="2">Per cent elong. 50.8&nbsp;mm or&nbsp;2&nbsp;in.</th><th rowspan="2">Per cent reduct. area.</th></tr><tr><th>kg/mm<sup>2</sup></th><th>lb/in<sup>2</sup></th></tr></thead><tbody><tr><td>Hard</td><td>0.45 ultimate</td><td>56.2</td><td>80,000</td><td>15</td><td>20</td></tr><tr><td>Medium</td><td>0.45 ultimate</td><td>49.2</td><td>70,000</td><td>18</td><td>25</td></tr><tr><td>Soft</td><td>0.45 ultimate</td><td>42.2</td><td>60,000</td><td>22</td><td>30</td></tr></tbody></table>

  <hr>

  <p>The following shows how one might mark up the gross margin table on page 46 of Apple, Inc's
  10-K filing for fiscal year 2008:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->2008
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->2007
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->2006
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Net sales
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->$ 32,479
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->$ 24,006
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->$ 19,315
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Cost of sales
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->  21,334
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->  15,852
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->  13,717
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Gross margin
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->$ 11,145
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->$  8,154
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->$  5,598
 <c- p="">&lt;</c-><c- f="">tfoot</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Gross margin percentage
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->34.3%
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->34.0%
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->29.0%
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

  <p>This table could look like this:</p>

  <table class="apple-table-examples e1"><thead><tr><th>
     </th><th>2008
     </th><th>2007
     </th><th>2006
   </th></tr></thead><tbody><tr><th>Net sales
     </th><td>$ 32,479
     </td><td>$ 24,006
     </td><td>$ 19,315
    </td></tr><tr><th>Cost of sales
     </th><td>  21,334
     </td><td>  15,852
     </td><td>  13,717
   </td></tr></tbody><tbody><tr><th>Gross margin
     </th><td>$ 11,145
     </td><td>$  8,154
     </td><td>$  5,598
   </td></tr></tbody><tfoot><tr><th>Gross margin percentage
     </th><td>34.3%
     </td><td>34.0%
     </td><td>29.0%
  </td></tr></tfoot></table>

  <hr>

  <p>The following shows how one might mark up the operating expenses table from lower on the same
  page of that document:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">colgroup</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">col</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">colgroup</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">col</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">col</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">col</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->2008 <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->2007 <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->2006
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">scope</c-><c- o="">=</c-><c- s="">rowgroup</c-><c- p="">&gt;</c-> Research and development
       <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> $ 1,109 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> $ 782 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> $ 712
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">scope</c-><c- o="">=</c-><c- s="">row</c-><c- p="">&gt;</c-> Percentage of net sales
       <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 3.4% <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 3.3% <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 3.7%
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">scope</c-><c- o="">=</c-><c- s="">rowgroup</c-><c- p="">&gt;</c-> Selling, general, and administrative
       <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> $ 3,761 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> $ 2,963 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> $ 2,433
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">scope</c-><c- o="">=</c-><c- s="">row</c-><c- p="">&gt;</c-> Percentage of net sales
       <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 11.6% <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 12.3% <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> 12.6%
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

  <p>This table could look like this:</p>

  <table class="apple-table-examples e2"><thead><tr><th> </th><th>2008 </th><th>2007 </th><th>2006
   </th></tr></thead><tbody><tr><th scope="rowgroup"> Research and development
         </th><td> $ 1,109 </td><td> $ 782 </td><td> $ 712
    </td></tr><tr><th scope="row"> Percentage of net sales
         </th><td> 3.4% </td><td> 3.3% </td><td> 3.7%
   </td></tr></tbody><tbody><tr><th scope="rowgroup"> Selling, general, and administrative
         </th><td> $ 3,761 </td><td> $ 2,963 </td><td> $ 2,433
    </td></tr><tr><th scope="row"> Percentage of net sales
         </th><td> 11.6% </td><td> 12.3% </td><td> 12.6%
  </td></tr></tbody></table>



  <h3 id="forms"><span class="secno">4.10</span> Forms<a href="#forms" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Forms" title="This page lists all the HTML elements, which are created using tags.">Element#Forms</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>61+</span></span><hr><span class="opera yes"><span>Opera</span><span>52+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>16+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>5+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3.2+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>61+</span></span><span class="webview_android yes"><span>WebView Android</span><span>61+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>8.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div>

  <h4 id="introduction-4"><span class="secno">4.10.1</span> Introduction<a href="#introduction-4" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>A form is a component of a web page that has form controls, such as text, buttons, checkboxes,
  range, or color picker controls. A user can interact with such a form, providing data that can
  then be sent to the server for further processing (e.g. returning the results of a search or
  calculation). No client-side scripting is needed in many cases, though an API is available so that
  scripts can augment the user experience or use forms for purposes other than submitting data to a
  server.</p>

  <p>Writing a form consists of several steps, which can be performed in any order: writing the user
  interface, implementing the server-side processing, and configuring the user interface to
  communicate with the server.</p>


  <h5 id="writing-a-form's-user-interface"><span class="secno">4.10.1.1</span> Writing a form's user interface<a href="#writing-a-form's-user-interface" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>For the purposes of this brief introduction, we will create a pizza ordering form.</p>

  <p>Any form starts with a <code id="writing-a-form's-user-interface:the-form-element"><a href="#the-form-element">form</a></code> element, inside which are placed the controls. Most
  controls are represented by the <code id="writing-a-form's-user-interface:the-input-element"><a href="#the-input-element">input</a></code> element, which by default provides a text
  control. To label a control, the <code id="writing-a-form's-user-interface:the-label-element"><a href="#the-label-element">label</a></code> element is used; the label text and the
  control itself go inside the <code id="writing-a-form's-user-interface:the-label-element-2"><a href="#the-label-element">label</a></code> element. Each part of a form is considered a
  <a href="#paragraph" id="writing-a-form's-user-interface:paragraph">paragraph</a>, and is typically separated from other parts using <code id="writing-a-form's-user-interface:the-p-element"><a href="#the-p-element">p</a></code> elements.
  Putting this together, here is how one might ask for the customer's name:</p>

  <pre><code class="html"><strong><c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></strong></code></pre>

  <p>To let the user select the size of the pizza, we can use a set of radio buttons. Radio buttons
  also use the <code id="writing-a-form's-user-interface:the-input-element-2"><a href="#the-input-element">input</a></code> element, this time with a <code id="writing-a-form's-user-interface:attr-input-type"><a href="#attr-input-type">type</a></code> attribute with the value <code id="writing-a-form's-user-interface:radio-button-state-(type=radio)"><a href="#radio-button-state-(type=radio)">radio</a></code>. To make the radio buttons work as a group, they are
  given a common name using the <code id="writing-a-form's-user-interface:attr-fe-name"><a href="#attr-fe-name">name</a></code> attribute. To group a batch
  of controls together, such as, in this case, the radio buttons, one can use the
  <code id="writing-a-form's-user-interface:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code> element. The title of such a group of controls is given by the first element
  in the <code id="writing-a-form's-user-interface:the-fieldset-element-2"><a href="#the-fieldset-element">fieldset</a></code>, which has to be a <code id="writing-a-form's-user-interface:the-legend-element"><a href="#the-legend-element">legend</a></code> element.</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong> <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p class="note">Changes from the previous step are highlighted.</p>

  <p>To pick toppings, we can use checkboxes. These use the <code id="writing-a-form's-user-interface:the-input-element-3"><a href="#the-input-element">input</a></code> element with a <code id="writing-a-form's-user-interface:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute with the value <code id="writing-a-form's-user-interface:checkbox-state-(type=checkbox)"><a href="#checkbox-state-(type=checkbox)">checkbox</a></code>:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
<strong> <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p>The pizzeria for which this form is being written is always making mistakes, so it needs a way
  to contact the customer. For this purpose, we can use form controls specifically for telephone
  numbers (<code id="writing-a-form's-user-interface:the-input-element-4"><a href="#the-input-element">input</a></code> elements with their <code id="writing-a-form's-user-interface:attr-input-type-3"><a href="#attr-input-type">type</a></code>
  attribute set to <code id="writing-a-form's-user-interface:telephone-state-(type=tel)"><a href="#telephone-state-(type=tel)">tel</a></code>) and email addresses
  (<code id="writing-a-form's-user-interface:the-input-element-5"><a href="#the-input-element">input</a></code> elements with their <code id="writing-a-form's-user-interface:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute set
  to <code id="writing-a-form's-user-interface:email-state-(type=email)"><a href="#email-state-(type=email)">email</a></code>):</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Telephone: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Email address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p>We can use an <code id="writing-a-form's-user-interface:the-input-element-6"><a href="#the-input-element">input</a></code> element with its <code id="writing-a-form's-user-interface:attr-input-type-5"><a href="#attr-input-type">type</a></code>
  attribute set to <code id="writing-a-form's-user-interface:time-state-(type=time)"><a href="#time-state-(type=time)">time</a></code> to ask for a delivery time. Many
  of these form controls have attributes to control exactly what values can be specified; in this
  case, three attributes of particular interest are <code id="writing-a-form's-user-interface:attr-input-min"><a href="#attr-input-min">min</a></code>, <code id="writing-a-form's-user-interface:attr-input-max"><a href="#attr-input-max">max</a></code>, and <code id="writing-a-form's-user-interface:attr-input-step"><a href="#attr-input-step">step</a></code>. These set the
  minimum time, the maximum time, and the interval between allowed values (in seconds). This
  pizzeria only delivers between 11am and 9pm, and doesn't promise anything better than 15 minute
  increments, which we can mark up as follows:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Telephone: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Email address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
<strong> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Preferred delivery time: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"11:00"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"21:00"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"900"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p>The <code id="writing-a-form's-user-interface:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element can be used to provide a multiline text control. In this
  instance, we are going to use it to provide a space for the customer to give delivery
  instructions:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Telephone: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Email address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Preferred delivery time: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"11:00"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"21:00"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"900"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Delivery instructions: <c- p="">&lt;</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p>Finally, to make the form submittable we use the <code id="writing-a-form's-user-interface:the-button-element"><a href="#the-button-element">button</a></code> element:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Telephone: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Email address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Preferred delivery time: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"11:00"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"21:00"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"900"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Delivery instructions: <c- p="">&lt;</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<strong> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Submit order<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></strong>
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>


  <h5 id="implementing-the-server-side-processing-for-a-form"><span class="secno">4.10.1.2</span> Implementing the server-side processing for a form<a href="#implementing-the-server-side-processing-for-a-form" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>The exact details for writing a server-side processor are out of scope for this specification.
  For the purposes of this introduction, we will assume that the script at <code>https://pizza.example.com/order.cgi</code> is configured to accept submissions using the
  <code id="implementing-the-server-side-processing-for-a-form:attr-fs-enctype-urlencoded"><a href="#attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</a></code> format,
  expecting the following parameters sent in an HTTP POST body:</p>

  <dl><dt><code>custname</code></dt><dd>Customer's name</dd><dt><code>custtel</code></dt><dd>Customer's telephone number</dd><dt><code>custemail</code></dt><dd>Customer's email address</dd><dt><code>size</code></dt><dd>The pizza size, either <code>small</code>, <code>medium</code>, or <code>large</code></dd><dt><code>topping</code></dt><dd>A topping, specified once for each selected topping, with the allowed values being <code>bacon</code>, <code>cheese</code>, <code>onion</code>, and <code>mushroom</code></dd><dt><code>delivery</code></dt><dd>The requested delivery time</dd><dt><code>comments</code></dt><dd>The delivery instructions</dd></dl>


  <h5 id="configuring-a-form-to-communicate-with-a-server"><span class="secno">4.10.1.3</span> Configuring a form to communicate with a server<a href="#configuring-a-form-to-communicate-with-a-server" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Form submissions are exposed to servers in a variety of ways, most commonly as HTTP GET or POST
  requests. To specify the exact method used, the <code id="configuring-a-form-to-communicate-with-a-server:attr-fs-method"><a href="#attr-fs-method">method</a></code>
  attribute is specified on the <code id="configuring-a-form-to-communicate-with-a-server:the-form-element"><a href="#the-form-element">form</a></code> element. This doesn't specify how the form data is
  encoded, though; to specify that, you use the <code id="configuring-a-form-to-communicate-with-a-server:attr-fs-enctype"><a href="#attr-fs-enctype">enctype</a></code>
  attribute. You also have to specify the <a id="configuring-a-form-to-communicate-with-a-server:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the service that will handle the
  submitted data, using the <code id="configuring-a-form-to-communicate-with-a-server:attr-fs-action"><a href="#attr-fs-action">action</a></code> attribute.</p>

  <p>For each form control you want submitted, you then have to give a name that will be used to
  refer to the data in the submission. We already specified the name for the group of radio buttons;
  the same attribute (<code id="configuring-a-form-to-communicate-with-a-server:attr-fe-name"><a href="#attr-fe-name">name</a></code>) also specifies the submission name.
  Radio buttons can be distinguished from each other in the submission by giving them different
  values, using the <code id="configuring-a-form-to-communicate-with-a-server:attr-input-value"><a href="#attr-input-value">value</a></code> attribute.</p>

  <p>Multiple controls can have the same name; for example, here we give all the checkboxes the same
  name, and the server distinguishes which checkbox was checked by seeing which values are submitted
  with that name — like the radio buttons, they are also given unique values with the <code id="configuring-a-form-to-communicate-with-a-server:attr-input-value-2"><a href="#attr-input-value">value</a></code> attribute.</p>

  <p>Given the settings in the previous section, this all becomes:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-><strong> <c- e="">method</c-><c- o="">=</c-><c- s="">"post"</c->
      <c- e="">enctype</c-><c- o="">=</c-><c- s="">"application/x-www-form-urlencoded"</c->
      <c- e="">action</c-><c- o="">=</c-><c- s="">"https://pizza.example.com/order.cgi"</c-></strong><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-><strong> <c- e="">name</c-><c- o="">=</c-><c- s="">"custname"</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Telephone: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-><strong> <c- e="">name</c-><c- o="">=</c-><c- s="">"custtel"</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Email address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-><strong> <c- e="">name</c-><c- o="">=</c-><c- s="">"custemail"</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><strong> <c- e="">value</c-><c- o="">=</c-><c- s="">"small"</c-></strong><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><strong> <c- e="">value</c-><c- o="">=</c-><c- s="">"medium"</c-></strong><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><strong> <c- e="">value</c-><c- o="">=</c-><c- s="">"large"</c-></strong><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><strong> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"bacon"</c-></strong><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><strong> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"cheese"</c-></strong><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><strong> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"onion"</c-></strong><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><strong> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"mushroom"</c-></strong><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Preferred delivery time: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"11:00"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"21:00"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"900"</c-><strong> <c- e="">name</c-><c- o="">=</c-><c- s="">"delivery"</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Delivery instructions: <c- p="">&lt;</c-><c- f="">textarea</c-><strong> <c- e="">name</c-><c- o="">=</c-><c- s="">"comments"</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Submit order<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p class="note">There is no particular significance to the way some of the attributes have their
  values quoted and others don't. The HTML syntax allows a variety of equally valid ways to specify
  attributes, as discussed <a href="#syntax-attributes" id="configuring-a-form-to-communicate-with-a-server:syntax-attributes">in the syntax section</a>.</p>

  <p>For example, if the customer entered "Denise Lawrence" as their name, "555-321-8642" as their
  telephone number, did not specify an email address, asked for a medium-sized pizza, selected the
  Extra Cheese and Mushroom toppings, entered a delivery time of 7pm, and left the delivery
  instructions text control blank, the user agent would submit the following to the online web
  service:</p>

  <pre><code class="html">custname=Denise+Lawrence&amp;custtel=555-321-8642&amp;custemail=&amp;size=medium&amp;topping=cheese&amp;topping=mushroom&amp;delivery=19%3A00&amp;comments=</code></pre>


  <h5 id="client-side-form-validation"><span class="secno">4.10.1.4</span> Client-side form validation<a href="#client-side-form-validation" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/Forms/Form_validation" title="Client-side form validation sometimes requires JavaScript if you want to customize styling and error messages, but it always requires you to think carefully about the user. Always remember to help your users correct the data they provide. To that end, be sure to:">Form_validation</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>≤12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>≤37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>≤12.1+</span></span></div></div></div>

  <p><i>This section is non-normative.</i></p>

  <p>Forms can be annotated in such a way that the user agent will check the user's input before the
  form is submitted. The server still has to verify the input is valid (since hostile users can
  easily bypass the form validation), but it allows the user to avoid the wait incurred by having
  the server be the sole checker of the user's input.</p>

  <p>The simplest annotation is the <code id="client-side-form-validation:attr-input-required"><a href="#attr-input-required">required</a></code> attribute,
  which can be specified on <code id="client-side-form-validation:the-input-element"><a href="#the-input-element">input</a></code> elements to indicate that the form is not to be
  submitted until a value is given. By adding this attribute to the customer name, pizza size, and
  delivery time fields, we allow the user agent to notify the user when the user submits the form
  without filling in those fields:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"post"</c->
      <c- e="">enctype</c-><c- o="">=</c-><c- s="">"application/x-www-form-urlencoded"</c->
      <c- e="">action</c-><c- o="">=</c-><c- s="">"https://pizza.example.com/order.cgi"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custname"</c-><strong> <c- e="">required</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Telephone: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custtel"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Email address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custemail"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><strong> <c- e="">required</c-></strong> <c- e="">value</c-><c- o="">=</c-><c- s="">"small"</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><strong> <c- e="">required</c-></strong> <c- e="">value</c-><c- o="">=</c-><c- s="">"medium"</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-><strong> <c- e="">required</c-></strong> <c- e="">value</c-><c- o="">=</c-><c- s="">"large"</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"bacon"</c-><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"cheese"</c-><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"onion"</c-><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"mushroom"</c-><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Preferred delivery time: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"11:00"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"21:00"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"900"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"delivery"</c-><strong> <c- e="">required</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Delivery instructions: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"comments"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Submit order<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p>It is also possible to limit the length of the input, using the <code id="client-side-form-validation:attr-fe-maxlength"><a href="#attr-fe-maxlength">maxlength</a></code> attribute. By adding this to the <code id="client-side-form-validation:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>
  element, we can limit users to 1000 characters, preventing them from writing huge essays to the
  busy delivery drivers instead of staying focused and to the point:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"post"</c->
      <c- e="">enctype</c-><c- o="">=</c-><c- s="">"application/x-www-form-urlencoded"</c->
      <c- e="">action</c-><c- o="">=</c-><c- s="">"https://pizza.example.com/order.cgi"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custname"</c-> <c- e="">required</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Telephone: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custtel"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Email address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custemail"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-> <c- e="">required</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"small"</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-> <c- e="">required</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"medium"</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-> <c- e="">required</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"large"</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"bacon"</c-><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"cheese"</c-><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"onion"</c-><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"mushroom"</c-><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Preferred delivery time: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"11:00"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"21:00"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"900"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"delivery"</c-> <c- e="">required</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Delivery instructions: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"comments"</c-><strong> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">1000</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Submit order<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p class="note">When a form is submitted, <code id="client-side-form-validation:event-invalid"><a href="#event-invalid">invalid</a></code> events are
  fired at each form control that is invalid. This can be useful for displaying a summary of the
  problems with the form, since typically the browser itself will only report one problem at a
  time.</p>



  <h5 id="enabling-client-side-automatic-filling-of-form-controls"><span class="secno">4.10.1.5</span> Enabling client-side automatic filling of form controls<a href="#enabling-client-side-automatic-filling-of-form-controls" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Some browsers attempt to aid the user by automatically filling form controls rather than having
  the user reenter their information each time. For example, a field asking for the user's telephone
  number can be automatically filled with the user's phone number.</p>

  <p>To help the user agent with this, the <code id="enabling-client-side-automatic-filling-of-form-controls:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>
  attribute can be used to describe the field's purpose. In the case of this form, we have three
  fields that can be usefully annotated in this way: the information about who the pizza is to be
  delivered to. Adding this information looks like this:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"post"</c->
      <c- e="">enctype</c-><c- o="">=</c-><c- s="">"application/x-www-form-urlencoded"</c->
      <c- e="">action</c-><c- o="">=</c-><c- s="">"https://pizza.example.com/order.cgi"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custname"</c-> <c- e="">required</c-> <strong><c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"shipping name"</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Telephone: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custtel"</c-> <strong><c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"shipping tel"</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Email address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custemail"</c-> <strong><c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"shipping email"</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-> <c- e="">required</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"small"</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-> <c- e="">required</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"medium"</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-> <c- e="">required</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"large"</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"bacon"</c-><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"cheese"</c-><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"onion"</c-><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"mushroom"</c-><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Preferred delivery time: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"11:00"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"21:00"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"900"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"delivery"</c-> <c- e="">required</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Delivery instructions: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"comments"</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">1000</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Submit order<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>


  <h5 id="improving-the-user-experience-on-mobile-devices"><span class="secno">4.10.1.6</span> Improving the user experience on mobile devices<a href="#improving-the-user-experience-on-mobile-devices" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Some devices, in particular those with virtual keyboards can provide the user with multiple
  input modalities. For example, when typing in a credit card number the user may wish to only see
  keys for digits 0-9, while when typing in their name they may wish to see a form field that by
  default capitalizes each word.</p>

  <p>Using the <code id="improving-the-user-experience-on-mobile-devices:attr-inputmode"><a href="#attr-inputmode">inputmode</a></code> attribute we can select appropriate
  input modalities:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"post"</c->
      <c- e="">enctype</c-><c- o="">=</c-><c- s="">"application/x-www-form-urlencoded"</c->
      <c- e="">action</c-><c- o="">=</c-><c- s="">"https://pizza.example.com/order.cgi"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Customer name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custname"</c-> <c- e="">required</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"shipping name"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Telephone: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custtel"</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"shipping tel"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Buzzer code: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custbuzz"</c-> <strong><c- e="">inputmode</c-><c- o="">=</c-><c- s="">"numeric"</c-></strong><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Email address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"custemail"</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"shipping email"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Size <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-> <c- e="">required</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"small"</c-><c- p="">&gt;</c-> Small <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-> <c- e="">required</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"medium"</c-><c- p="">&gt;</c-> Medium <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">size</c-> <c- e="">required</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"large"</c-><c- p="">&gt;</c-> Large <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> Pizza Toppings <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"bacon"</c-><c- p="">&gt;</c-> Bacon <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"cheese"</c-><c- p="">&gt;</c-> Extra Cheese <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"onion"</c-><c- p="">&gt;</c-> Onion <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"topping"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"mushroom"</c-><c- p="">&gt;</c-> Mushroom <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Preferred delivery time: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"11:00"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"21:00"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"900"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"delivery"</c-> <c- e="">required</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Delivery instructions: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"comments"</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">1000</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Submit order<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>



  <h5 id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality"><span class="secno">4.10.1.7</span> The difference between the field type, the autofill field name, and the input modality<a href="#the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>The <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-input-type"><a href="#attr-input-type">type</a></code>, <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>, and <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-inputmode"><a href="#attr-inputmode">inputmode</a></code> attributes can seem confusingly similar. For instance,
  in all three cases, the string "<code>email</code>" is a valid value. This section
  attempts to illustrate the difference between the three attributes and provides advice suggesting
  how to use them.</p>

  <p>The <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute on <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:the-input-element"><a href="#the-input-element">input</a></code> elements decides
  what kind of control the user agent will use to expose the field. Choosing between different
  values of this attribute is the same choice as choosing whether to use an <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:the-input-element-2"><a href="#the-input-element">input</a></code>
  element, a <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element, a <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:the-select-element"><a href="#the-select-element">select</a></code> element, etc.</p>

  <p>The <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-2"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute, in contrast, describes
  what the value that the user will enter actually represents. Choosing between different values of
  this attribute is the same choice as choosing what the label for the element will be.</p>

  <p>First, consider telephone numbers. If a page is asking for a telephone number from the user,
  the right form control to use is <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:telephone-state-(type=tel)"><a href="#telephone-state-(type=tel)">&lt;input type=tel&gt;</a></code>.
  However, which <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-3"><a href="#attr-fe-autocomplete">autocomplete</a></code> value to use depends on
  which phone number the page is asking for, whether they expect a telephone number in the
  international format or just the local format, and so forth.</p>

  <p>For example, a page that forms part of a checkout process on an e-commerce site for a customer
  buying a gift to be shipped to a friend might need both the buyer's telephone number (in case of
  payment issues) and the friend's telephone number (in case of delivery issues). If the site
  expects international phone numbers (with the country code prefix), this could thus look like
  this:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Your phone number: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">custtel</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"billing tel"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Recipient's phone number: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">shiptel</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"shipping tel"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Please enter complete phone numbers including the country code prefix, as in "+1 555 123 4567".</code></pre>

  <p>But if the site only supports British customers and recipients, it might instead look like this
  (notice the use of <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-tel-national"><a href="#attr-fe-autocomplete-tel-national">tel-national</a></code> rather than
  <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-tel"><a href="#attr-fe-autocomplete-tel">tel</a></code>):</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Your phone number: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">custtel</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"billing tel-national"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Recipient's phone number: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">shiptel</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"shipping tel-national"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Please enter complete UK phone numbers, as in "(01632) 960 123".</code></pre>

  <p>Now, consider a person's preferred languages. The right <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-4"><a href="#attr-fe-autocomplete">autocomplete</a></code> value is <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-language"><a href="#attr-fe-autocomplete-language">language</a></code>. However, there could be a number of
  different form controls used for the purpose: a text control (<code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:text-(type=text)-state-and-search-state-(type=search)"><a href="#text-(type=text)-state-and-search-state-(type=search)">&lt;input type=text&gt;</a></code>), a drop-down list (<code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:the-select-element-2"><a href="#the-select-element">&lt;select&gt;</a></code>), radio buttons (<code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:radio-button-state-(type=radio)"><a href="#radio-button-state-(type=radio)">&lt;input
  type=radio&gt;</a></code>), etc. It only depends on what kind of interface is desired.</p>

  <p>Finally, consider names. If a page just wants one name from the user, then the relevant control
  is <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:text-(type=text)-state-and-search-state-(type=search)-2"><a href="#text-(type=text)-state-and-search-state-(type=search)">&lt;input type=text&gt;</a></code>. If the page is asking for the
  user's full name, then the relevant <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-5"><a href="#attr-fe-autocomplete">autocomplete</a></code> value
  is <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-name"><a href="#attr-fe-autocomplete-name">name</a></code>.

  </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Japanese name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"j"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"section-jp name"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Romanized name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"e"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"section-en name"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

  <p>In this example, the "<code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-section"><a href="#attr-fe-autocomplete-section">section-*</a></code>" keywords in
  the <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-6"><a href="#attr-fe-autocomplete">autocomplete</a></code> attributes' values tell the user agent
  that the two fields expect <em>different</em> names. Without them, the user agent could
  automatically fill the second field with the value given in the first field when the user gave a
  value to the first field.</p>

  <p class="note">The "<code>-jp</code>" and "<code>-en</code>" parts of the
  keywords are opaque to the user agent; the user agent cannot guess, from those, that the two names
  are expected to be in Japanese and English respectively.</p>

  <p>Separate from the choices regarding <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-input-type-3"><a href="#attr-input-type">type</a></code> and <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-fe-autocomplete-7"><a href="#attr-fe-autocomplete">autocomplete</a></code>, the <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:attr-inputmode-2"><a href="#attr-inputmode">inputmode</a></code> attribute decides what kind of input modality (e.g.,
  virtual keyboard) to use, when the control is a text control.</p>

  <p>Consider credit card numbers. The appropriate input type is <em>not</em> <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:number-state-(type=number)"><a href="#number-state-(type=number)">&lt;input type=number&gt;</a></code>, <a href="#when-number-is-not-appropriate">as explained below</a>; it is instead <code id="the-difference-between-the-field-type,-the-autofill-field-name,-and-the-input-modality:text-(type=text)-state-and-search-state-(type=search)-3"><a href="#text-(type=text)-state-and-search-state-(type=search)">&lt;input type=text&gt;</a></code>. To encourage the user agent to use a
  numeric input modality anyway (e.g., a virtual keyboard displaying only digits), the page would
  use</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Credit card number:
                <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"cc"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">inputmode</c-><c- o="">=</c-><c- s="">"numeric"</c-> <c- e="">pattern</c-><c- o="">=</c-><c- s="">"[0-9]{8,19}"</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"cc-number"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>



  <h5 id="input-author-notes"><span class="secno">4.10.1.8</span> Date, time, and number formats<a href="#input-author-notes" class="self-link"></a></h5>
  

  <p><i>This section is non-normative.</i></p>

  <p>In this pizza delivery example, the times are specified in the format "HH:MM": two digits for
  the hour, in 24-hour format, and two digits for the time. (Seconds could also be specified, though
  they are not necessary in this example.)</p>

  <p>In some locales, however, times are often expressed differently when presented to users. For
  example, in the United States, it is still common to use the 12-hour clock with an am/pm
  indicator, as in "2pm". In France, it is common to separate the hours from the minutes using an
  "h" character, as in "14h00".</p>

  <p>Similar issues exist with dates, with the added complication that even the order of the
  components is not always consistent — for example, in Cyprus the first of February 2003
  would typically be written "1/2/03", while that same date in Japan would typically be written as
  "2003年02月01日" — and even with numbers, where locales differ, for
  example, in what punctuation is used as the decimal separator and the thousands separator.</p>

  <p>It is therefore important to distinguish the time, date, and number formats used in HTML and in
  form submissions, which are always the formats defined in this specification (and based on the
  well-established ISO 8601 standard for computer-readable date and time formats), from the time,
  date, and number formats presented to the user by the browser and accepted as input from the user
  by the browser.</p>

  <p>The format used "on the wire", i.e., in HTML markup and in form submissions, is intended to be
  computer-readable and consistent irrespective of the user's locale. Dates, for instance, are
  always written in the format "YYYY-MM-DD", as in "2003-02-01". While some users might see this
  format, others might see it as "01.02.2003" or "February 1, 2003".</p>

  <p>The time, date, or number given by the page in the wire format is then translated to the user's
  preferred presentation (based on user preferences or on the locale of the page itself), before
  being displayed to the user. Similarly, after the user inputs a time, date, or number using their
  preferred format, the user agent converts it back to the wire format before putting it in the DOM
  or submitting it.</p>

  <p>This allows scripts in pages and on servers to process times, dates, and numbers in a
  consistent manner without needing to support dozens of different formats, while still supporting
  the users' needs.</p>

  
  <p class="note">See also the <a href="#input-impl-notes">implementation notes</a> regarding
  localization of form controls.</p>
  


  <h4 id="categories"><span class="secno">4.10.2</span> Categories<a href="#categories" class="self-link"></a></h4>

  <p>Mostly for historical reasons, elements in this section fall into several overlapping (but
  subtly different) categories in addition to the usual ones like <a href="#flow-content-2" id="categories:flow-content-2">flow content</a>,
  <a href="#phrasing-content-2" id="categories:phrasing-content-2">phrasing content</a>, and <a href="#interactive-content-2" id="categories:interactive-content-2">interactive content</a>.</p>

  <p>A number of the elements are <dfn id="form-associated-element">form-associated
  elements</dfn>, which means they can have a <a href="#form-owner" id="categories:form-owner">form owner</a>.

  
  </p><ul class="brief category-list"><li><code id="categories:the-button-element"><a href="#the-button-element">button</a></code></li><li><code id="categories:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code></li><li><code id="categories:the-input-element"><a href="#the-input-element">input</a></code></li><li><code id="categories:the-object-element"><a href="#the-object-element">object</a></code></li><li><code id="categories:the-output-element"><a href="#the-output-element">output</a></code></li><li><code id="categories:the-select-element"><a href="#the-select-element">select</a></code></li><li><code id="categories:the-textarea-element"><a href="#the-textarea-element">textarea</a></code></li><li><code id="categories:the-img-element"><a href="#the-img-element">img</a></code></li><li><a href="#form-associated-custom-element" id="categories:form-associated-custom-element">form-associated custom elements</a></li></ul>

  <p>The <a href="#form-associated-element" id="categories:form-associated-element">form-associated elements</a> fall into several
  subcategories:</p>

  <dl><dt><dfn id="category-listed">Listed elements</dfn></dt><dd>
    <p>Denotes elements that are listed in the <code id="categories:dom-form-elements"><a href="#dom-form-elements"><var>form</var>.elements</a></code> and <code id="categories:dom-fieldset-elements"><a href="#dom-fieldset-elements"><var>fieldset</var>.elements</a></code> APIs. These elements also
    have a <code id="categories:attr-fae-form"><a href="#attr-fae-form">form</a></code> content attribute, and a matching <code id="categories:dom-fae-form"><a href="#dom-fae-form">form</a></code> IDL attribute, that allow authors to specify an explicit
    <a href="#form-owner" id="categories:form-owner-2">form owner</a>.</p>

    
    <ul class="brief category-list"><li><code id="categories:the-button-element-2"><a href="#the-button-element">button</a></code></li><li><code id="categories:the-fieldset-element-2"><a href="#the-fieldset-element">fieldset</a></code></li><li><code id="categories:the-input-element-2"><a href="#the-input-element">input</a></code></li><li><code id="categories:the-object-element-2"><a href="#the-object-element">object</a></code></li><li><code id="categories:the-output-element-2"><a href="#the-output-element">output</a></code></li><li><code id="categories:the-select-element-2"><a href="#the-select-element">select</a></code></li><li><code id="categories:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code></li><li><a href="#form-associated-custom-element" id="categories:form-associated-custom-element-2">form-associated custom elements</a></li></ul>
   </dd><dt><dfn id="category-submit">Submittable elements</dfn></dt><dd>
    <p>Denotes elements that can be used for <a href="#constructing-the-form-data-set" id="categories:constructing-the-form-data-set">constructing the entry list</a> when a
    <code id="categories:the-form-element"><a href="#the-form-element">form</a></code> element is <a href="#concept-form-submit" id="categories:concept-form-submit">submitted</a>.</p>

    
    <ul class="brief category-list"><li><code id="categories:the-button-element-3"><a href="#the-button-element">button</a></code></li><li><code id="categories:the-input-element-3"><a href="#the-input-element">input</a></code></li><li><code id="categories:the-select-element-3"><a href="#the-select-element">select</a></code></li><li><code id="categories:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code></li><li><a href="#form-associated-custom-element" id="categories:form-associated-custom-element-3">form-associated custom elements</a></li></ul>

    <p>Some <a href="#category-submit" id="categories:category-submit">submittable elements</a> can be, depending on their
    attributes, <dfn id="concept-button">buttons</dfn>. The prose below defines when an element
    is a button. Some buttons are specifically <dfn id="concept-submit-button" data-lt="submit button" data-export="">submit buttons</dfn>.</p>
   </dd><dt><dfn id="category-reset">Resettable elements</dfn></dt><dd>
    <p>Denotes elements that can be affected when a <code id="categories:the-form-element-2"><a href="#the-form-element">form</a></code> element is <a href="#concept-form-reset" id="categories:concept-form-reset">reset</a>.</p>

    
    <ul class="brief category-list"><li><code id="categories:the-input-element-4"><a href="#the-input-element">input</a></code></li><li><code id="categories:the-output-element-3"><a href="#the-output-element">output</a></code></li><li><code id="categories:the-select-element-4"><a href="#the-select-element">select</a></code></li><li><code id="categories:the-textarea-element-4"><a href="#the-textarea-element">textarea</a></code></li><li><a href="#form-associated-custom-element" id="categories:form-associated-custom-element-4">form-associated custom elements</a></li></ul>
   </dd><dt><dfn id="category-autocapitalize">Autocapitalize-and-autocorrect-inheriting
   elements</dfn></dt><dd>
    <p>Denotes elements that inherit the <code id="categories:attr-autocapitalize"><a href="#attr-autocapitalize">autocapitalize</a></code>
    and <code id="categories:attr-autocorrect"><a href="#attr-autocorrect">autocorrect</a></code> attributes from their <a href="#form-owner" id="categories:form-owner-3">form
    owner</a>.</p>

    
    <ul class="brief category-list"><li><code id="categories:the-button-element-4"><a href="#the-button-element">button</a></code></li><li><code id="categories:the-fieldset-element-3"><a href="#the-fieldset-element">fieldset</a></code></li><li><code id="categories:the-input-element-5"><a href="#the-input-element">input</a></code></li><li><code id="categories:the-output-element-4"><a href="#the-output-element">output</a></code></li><li><code id="categories:the-select-element-5"><a href="#the-select-element">select</a></code></li><li><code id="categories:the-textarea-element-5"><a href="#the-textarea-element">textarea</a></code></li></ul>
   </dd></dl>

  <p>Some elements, not all of them <a href="#form-associated-element" id="categories:form-associated-element-2">form-associated</a>,
  are categorized as <dfn id="category-label">labelable elements</dfn>. These are elements that
  can be associated with a <code id="categories:the-label-element"><a href="#the-label-element">label</a></code> element.

  
  </p><ul class="brief category-list"><li><code id="categories:the-button-element-5"><a href="#the-button-element">button</a></code></li><li><code id="categories:the-input-element-6"><a href="#the-input-element">input</a></code> (if the <code id="categories:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is <em>not</em> in the <a href="#hidden-state-(type=hidden)" id="categories:hidden-state-(type=hidden)">Hidden</a> state)</li><li><code id="categories:the-meter-element"><a href="#the-meter-element">meter</a></code></li><li><code id="categories:the-output-element-5"><a href="#the-output-element">output</a></code></li><li><code id="categories:the-progress-element"><a href="#the-progress-element">progress</a></code></li><li><code id="categories:the-select-element-6"><a href="#the-select-element">select</a></code></li><li><code id="categories:the-textarea-element-6"><a href="#the-textarea-element">textarea</a></code></li><li><a href="#form-associated-custom-element" id="categories:form-associated-custom-element-5">form-associated custom elements</a></li></ul>


  <h4 id="the-form-element"><span class="secno">4.10.3</span> The <dfn data-dfn-type="element"><code>form</code></dfn> element<a href="#the-form-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form" title="The <form> HTML element represents a document section containing interactive controls for submitting information.">Element/form</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement" title="The HTMLFormElement interface represents a <form> element in the DOM. It allows access to—and, in some cases, modification of—aspects of the form, as well as access to its component elements.">HTMLFormElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/acceptCharset" title="The HTMLFormElement.acceptCharset property represents a list of the supported character encodings for the given <form> element. This list can be comma-separated or space-separated.">HTMLFormElement/acceptCharset</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/name" title="The HTMLFormElement.name property represents the name of the current <form> element as a string.">HTMLFormElement/name</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/target" title="The target property of the HTMLFormElement interface represents the target of the form's action (i.e., the frame in which to render its output).">HTMLFormElement/target</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-form-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-form-element:flow-content-2">Flow content</a>.</dd><dd><a href="#palpable-content-2" id="the-form-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-form-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-form-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-form-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-form-element:flow-content-2-3">Flow content</a>, but with no <code id="the-form-element:the-form-element"><a href="#the-form-element">form</a></code> element descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-form-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-form-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-form-element:global-attributes">Global attributes</a></dd><dd><code id="the-form-element:attr-form-accept-charset"><a href="#attr-form-accept-charset">accept-charset</a></code> —  Character encodings to use for <a href="#form-submission-2" id="the-form-element:form-submission-2">form submission</a>
     </dd><dd><code id="the-form-element:attr-fs-action"><a href="#attr-fs-action">action</a></code> —  <a id="the-form-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> to use for <a href="#form-submission-2" id="the-form-element:form-submission-2-2">form submission</a>
     </dd><dd><code id="the-form-element:attr-form-autocomplete"><a href="#attr-form-autocomplete">autocomplete</a></code> —  Default setting for autofill feature for controls in the form
     </dd><dd><code id="the-form-element:attr-fs-enctype"><a href="#attr-fs-enctype">enctype</a></code> —  <a href="#entry-list" id="the-form-element:entry-list">Entry list</a> encoding type to use for <a href="#form-submission-2" id="the-form-element:form-submission-2-3">form submission</a>
     </dd><dd><code id="the-form-element:attr-fs-method"><a href="#attr-fs-method">method</a></code> —  Variant to use for <a href="#form-submission-2" id="the-form-element:form-submission-2-4">form submission</a>
     </dd><dd><code id="the-form-element:attr-form-name"><a href="#attr-form-name">name</a></code> —  Name of form to use in the <code id="the-form-element:dom-document-forms"><a href="#dom-document-forms">document.forms</a></code> API
     </dd><dd><code id="the-form-element:attr-fs-novalidate"><a href="#attr-fs-novalidate">novalidate</a></code> —  Bypass form control validation for <a href="#form-submission-2" id="the-form-element:form-submission-2-5">form submission</a>
     </dd><dd><code id="the-form-element:attr-fs-target"><a href="#attr-fs-target">target</a></code> —  <a href="#navigable" id="the-form-element:navigable">Navigable</a> for <a href="#form-submission-2" id="the-form-element:form-submission-2-6">form submission</a>
     </dd><dd><code id="the-form-element:attr-form-rel"><a href="#attr-form-rel">rel</a></code></dd><dt><a href="#concept-element-accessibility-considerations" id="the-form-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-form">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-form">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-form-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="the-form-element:legacyoverridebuiltins" href="https://webidl.spec.whatwg.org/#LegacyOverrideBuiltIns" data-x-internal="legacyoverridebuiltins"><c- g="">LegacyOverrideBuiltIns</c-></a>,
 <a id="the-form-element:legacyunenumerablenamedproperties" href="https://webidl.spec.whatwg.org/#LegacyUnenumerableNamedProperties" data-x-internal="legacyunenumerablenamedproperties"><c- g="">LegacyUnenumerableNamedProperties</c-></a>]
<c- b="">interface</c-> <dfn id="htmlformelement" data-dfn-type="interface"><c- g="">HTMLFormElement</c-></dfn> : <a href="#htmlelement" id="the-form-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-form-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-form-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-form-element:xattr-reflect">Reflect</a>="<a href="#attr-form-accept-charset" id="the-form-element:attr-form-accept-charset-2">accept-charset</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFormElement" id="dom-form-acceptcharset" data-dfn-type="attribute"><c- g="">acceptCharset</c-></dfn>;
  [<a href="#cereactions" id="the-form-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-form-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-fs-action" id="the-form-element:dom-fs-action"><c- g="">action</c-></a>;
  [<a href="#cereactions" id="the-form-element:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-form-autocomplete" id="the-form-element:dom-form-autocomplete"><c- g="">autocomplete</c-></a>;
  [<a href="#cereactions" id="the-form-element:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fs-enctype" id="the-form-element:dom-fs-enctype"><c- g="">enctype</c-></a>;
  [<a href="#cereactions" id="the-form-element:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fs-encoding" id="the-form-element:dom-fs-encoding"><c- g="">encoding</c-></a>;
  [<a href="#cereactions" id="the-form-element:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fs-method" id="the-form-element:dom-fs-method"><c- g="">method</c-></a>;
  [<a href="#cereactions" id="the-form-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-form-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFormElement" id="dom-form-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="the-form-element:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-form-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLFormElement" id="dom-fs-novalidate" data-dfn-type="attribute"><c- g="">noValidate</c-></dfn>;
  [<a href="#cereactions" id="the-form-element:cereactions-9"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-form-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFormElement" id="dom-fs-target" data-dfn-type="attribute"><c- g="">target</c-></dfn>;
  [<a href="#cereactions" id="the-form-element:cereactions-10"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-form-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFormElement" id="dom-form-rel" data-dfn-type="attribute"><c- g="">rel</c-></dfn>;
  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-form-element:dom-domtokenlist-value" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-form-element:xattr-reflect-6">Reflect</a>="<a href="#attr-form-rel" id="the-form-element:attr-form-rel-2">rel</a>"] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-form-element:domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLFormElement" id="dom-form-rellist" data-dfn-type="attribute"><c- g="">relList</c-></dfn>;

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformcontrolscollection" id="the-form-element:htmlformcontrolscollection"><c- n="">HTMLFormControlsCollection</c-></a> <a href="#dom-form-elements" id="the-form-element:dom-form-elements"><c- g="">elements</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-form-length" id="the-form-element:dom-form-length"><c- g="">length</c-></a>;
  <a href="#dom-form-item"><c- b="">getter</c-></a> <a id="the-form-element:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a> (<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <a href="#dom-form-nameditem"><c- b="">getter</c-></a> (<a href="#radionodelist" id="the-form-element:radionodelist"><c- n="">RadioNodeList</c-></a> <c- b="">or</c-> <a id="the-form-element:element-2" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a>) (<c- b="">DOMString</c-> <c- g="">name</c->);

  <c- b="">undefined</c-> <a href="#dom-form-submit" id="the-form-element:dom-form-submit"><c- g="">submit</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-form-requestsubmit" id="the-form-element:dom-form-requestsubmit"><c- g="">requestSubmit</c-></a>(<c- b="">optional</c-> <a href="#htmlelement" id="the-form-element:htmlelement-2"><c- n="">HTMLElement</c-></a>? <c- g="">submitter</c-> = <c- b="">null</c->);
  [<a href="#cereactions" id="the-form-element:cereactions-11"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-form-reset" id="the-form-element:dom-form-reset"><c- g="">reset</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-form-checkvalidity" id="the-form-element:dom-form-checkvalidity"><c- g="">checkValidity</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-form-reportvalidity" id="the-form-element:dom-form-reportvalidity"><c- g="">reportValidity</c-></a>();
};</code></pre>
   </dd></dl>

  <p>The <code id="the-form-element:the-form-element-2"><a href="#the-form-element">form</a></code> element <a href="#represents" id="the-form-element:represents">represents</a> a <a href="#hyperlink" id="the-form-element:hyperlink">hyperlink</a> that can be
  manipulated through a collection of <a href="#form-associated-element" id="the-form-element:form-associated-element">form-associated
  elements</a>, some of which can represent editable values that can be submitted to a server for
  processing.</p>

  <p>The <dfn data-dfn-for="form" id="attr-form-accept-charset" data-dfn-type="element-attr"><code>accept-charset</code></dfn> attribute gives the character
  encodings that are to be used for the submission. If specified, the value must be an <a id="the-form-element:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for "<code>UTF-8</code>". <a href="#refsENCODING">[ENCODING]</a></p>

  <p>The <dfn data-dfn-for="form" id="attr-form-name" data-dfn-type="element-attr"><code>name</code></dfn> attribute
  represents the <code id="the-form-element:the-form-element-3"><a href="#the-form-element">form</a></code>'s name within the <code id="the-form-element:dom-document-forms-2"><a href="#dom-document-forms">forms</a></code>
  collection. The value must not be the empty string, and the value must be unique amongst the
  <code id="the-form-element:the-form-element-4"><a href="#the-form-element">form</a></code> elements in the <code id="the-form-element:dom-document-forms-3"><a href="#dom-document-forms">forms</a></code> collection that
  it is in, if any.</p>

  <p>The <dfn data-dfn-for="form" id="attr-form-autocomplete" data-dfn-type="element-attr"><code>autocomplete</code></dfn> attribute is an <a href="#enumerated-attribute" id="the-form-element:enumerated-attribute">enumerated
  attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="form/autocomplete" id="attr-form-autocomplete-on" data-dfn-type="attr-value"><code>on</code></dfn>
     </td><td><dfn id="attr-form-autocomplete-on-state">On</dfn>
     </td><td>Form controls will have their <a href="#autofill-field-name" id="the-form-element:autofill-field-name">autofill field name</a> set to "<code id="the-form-element:attr-fe-autocomplete-on"><a href="#attr-fe-autocomplete-on">on</a></code>" by default.
    </td></tr><tr><td><dfn data-dfn-for="form/autocomplete" id="attr-form-autocomplete-off" data-dfn-type="attr-value"><code>off</code></dfn>
     </td><td><dfn id="attr-form-autocomplete-off-state">Off</dfn>
     </td><td>Form controls will have their <a href="#autofill-field-name" id="the-form-element:autofill-field-name-2">autofill field name</a> set to "<code id="the-form-element:attr-fe-autocomplete-off"><a href="#attr-fe-autocomplete-off">off</a></code>" by default.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-form-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-form-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#attr-form-autocomplete-on-state" id="the-form-element:attr-form-autocomplete-on-state">On</a> state.</p>
  </div>

  <p>The <code id="the-form-element:attr-fs-action-2"><a href="#attr-fs-action">action</a></code>, <code id="the-form-element:attr-fs-enctype-2"><a href="#attr-fs-enctype">enctype</a></code>,
  <code id="the-form-element:attr-fs-method-2"><a href="#attr-fs-method">method</a></code>, <code id="the-form-element:attr-fs-novalidate-2"><a href="#attr-fs-novalidate">novalidate</a></code>,
  and <code id="the-form-element:attr-fs-target-2"><a href="#attr-fs-target">target</a></code> attributes are <a href="#attributes-for-form-submission" id="the-form-element:attributes-for-form-submission">attributes for form
  submission</a>.</p>

  <p>The <dfn data-dfn-for="form" id="attr-form-rel" data-dfn-type="element-attr"><code>rel</code></dfn> attribute on
  <code id="the-form-element:the-form-element-5"><a href="#the-form-element">form</a></code> elements controls what kinds of links the elements create. The attribute's value
  must be a <a href="#unordered-set-of-unique-space-separated-tokens" id="the-form-element:unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</a>. The <a href="#linkTypes">allowed keywords and their meanings</a> are defined in an earlier section.</p>

  <p><code id="the-form-element:attr-form-rel-3"><a href="#attr-form-rel">rel</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="the-form-element:concept-supported-tokens" data-x-internal="concept-supported-tokens">supported
  tokens</a> are the keywords defined in <a href="#linkTypes">HTML link types</a> which are
  allowed on <code id="the-form-element:the-form-element-6"><a href="#the-form-element">form</a></code> elements, impact the processing model, and are supported by the user
  agent. The possible <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="the-form-element:concept-supported-tokens-2" data-x-internal="concept-supported-tokens">supported tokens</a> are <code id="the-form-element:link-type-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code>, <code id="the-form-element:link-type-noopener"><a href="#link-type-noopener">noopener</a></code>, and <code id="the-form-element:link-type-opener"><a href="#link-type-opener">opener</a></code>. <code id="the-form-element:attr-form-rel-4"><a href="#attr-form-rel">rel</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-supported-tokens" id="the-form-element:concept-supported-tokens-3" data-x-internal="concept-supported-tokens">supported tokens</a> must only include the tokens from this
  list that the user agent implements the processing model for.</p>

  <dl class="domintro"><dt><code><var>form</var>.<a href="#dom-form-elements" id="dom-form-elements-dev">elements</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/elements" title="The HTMLFormElement property elements returns an HTMLFormControlsCollection listing all the form controls contained in the <form> element.">HTMLFormElement/elements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="the-form-element:htmlformcontrolscollection-2"><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code> of the form controls in the form
    (excluding image buttons for historical reasons).</p>
   </dd><dt><code><var>form</var>.<a href="#dom-form-length" id="dom-form-length-dev">length</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/length" title="The HTMLFormElement.length read-only property returns the number of controls in the <form> element.">HTMLFormElement/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the number of form controls in the form (excluding image buttons for historical
    reasons).</p>
   </dd><dt><code><var>form</var>[<var>index</var>]</code></dt><dd>
    <p>Returns the <var>index</var>th element in the form (excluding image buttons for historical
    reasons).</p>
   </dd><dt><code><var>form</var>[<var>name</var>]</code></dt><dd>
    <p>Returns the form control (or, if there are several, a <code id="the-form-element:radionodelist-2"><a href="#radionodelist">RadioNodeList</a></code> of the form
    controls) in the form with the given <a href="https://dom.spec.whatwg.org/#concept-id" id="the-form-element:concept-id" data-x-internal="concept-id">ID</a> or <code id="the-form-element:attr-fe-name"><a href="#attr-fe-name">name</a></code> (excluding image buttons for historical reasons); or, if there
    are none, returns the <code id="the-form-element:the-img-element"><a href="#the-img-element">img</a></code> element with the given ID.</p>

    <p>Once an element has been referenced using a particular name, that name will continue being
    available as a way to reference that element in this method, even if the element's actual <a href="https://dom.spec.whatwg.org/#concept-id" id="the-form-element:concept-id-2" data-x-internal="concept-id">ID</a> or <code id="the-form-element:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> changes, for as long as
    the element remains in the <a id="the-form-element:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>.</p>

    <p>If there are multiple matching items, then a <code id="the-form-element:radionodelist-3"><a href="#radionodelist">RadioNodeList</a></code> object containing all
    those elements is returned.</p>
   </dd><dt><code><var>form</var>.<a href="#dom-form-submit" id="dom-form-submit-dev">submit</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit" title="The HTMLFormElement.submit() method submits a given <form>.">HTMLFormElement/submit</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Submits the form, bypassing <a href="#interactively-validate-the-constraints" id="the-form-element:interactively-validate-the-constraints">interactive
    constraint validation</a> and without firing a <code id="the-form-element:event-submit"><a href="#event-submit">submit</a></code>
    event.</p>
   </dd><dt><code><var>form</var>.<a href="#dom-form-requestsubmit" id="dom-form-requestsubmit-dev">requestSubmit</a>([ <var>submitter</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/requestSubmit" title="The HTMLFormElement method requestSubmit() requests that the form be submitted using a specific submit button.">HTMLFormElement/requestSubmit</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>75+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>76+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Requests to submit the form. Unlike <code id="the-form-element:dom-form-submit-2"><a href="#dom-form-submit">submit()</a></code>, this
    method includes <a href="#interactively-validate-the-constraints" id="the-form-element:interactively-validate-the-constraints-2">interactive constraint
    validation</a> and firing a <code id="the-form-element:event-submit-2"><a href="#event-submit">submit</a></code> event, either of which
    can cancel submission.</p>

    <p>The <var>submitter</var> argument can be used to point to a specific <a href="#concept-submit-button" id="the-form-element:concept-submit-button">submit button</a>, whose <code id="the-form-element:attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>, <code id="the-form-element:attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>, <code id="the-form-element:attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>, <code id="the-form-element:attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>, and <code id="the-form-element:attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code> attributes can impact submission. Additionally,
    the submitter will be included when <a href="#constructing-the-form-data-set" id="the-form-element:constructing-the-form-data-set">constructing the entry list</a> for submission;
    normally, buttons are excluded.</p>
   </dd><dt><code><var>form</var>.<a href="#dom-form-reset" id="dom-form-reset-dev">reset</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset" title="The HTMLFormElement.reset() method restores a form element's default values. This method does the same thing as clicking the form's <input type=&quot;reset&quot;> control.">HTMLFormElement/reset</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Resets the form.</p></dd><dt><code><var>form</var>.<a href="#dom-form-checkvalidity" id="dom-form-checkvalidity-dev">checkValidity</a>()</code></dt><dd><p>Returns true if the form's controls are all valid; otherwise, returns false.</p></dd><dt><code><var>form</var>.<a href="#dom-form-reportvalidity" id="dom-form-reportvalidity-dev">reportValidity</a>()</code></dt><dd>
    <p>Returns true if the form's controls are all valid; otherwise, returns false and informs the
    user.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFormElement" id="dom-form-autocomplete" data-dfn-type="attribute"><code>autocomplete</code></dfn> IDL attribute must <a href="#reflect" id="the-form-element:reflect">reflect</a>
  the content attribute of the same name, <a href="#limited-to-only-known-values" id="the-form-element:limited-to-only-known-values">limited to only known values</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFormElement" id="dom-form-elements" data-dfn-type="attribute"><code>elements</code></dfn>
  IDL attribute must return an <code id="the-form-element:htmlformcontrolscollection-3"><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code> rooted at the
  <code id="the-form-element:the-form-element-7"><a href="#the-form-element">form</a></code> element's <a id="the-form-element:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>, whose filter matches <a href="#category-listed" id="the-form-element:category-listed">listed elements</a> whose <a href="#form-owner" id="the-form-element:form-owner">form owner</a> is the
  <code id="the-form-element:the-form-element-8"><a href="#the-form-element">form</a></code> element, with the exception of <code id="the-form-element:the-input-element"><a href="#the-input-element">input</a></code> elements whose <code id="the-form-element:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#image-button-state-(type=image)" id="the-form-element:image-button-state-(type=image)">Image Button</a> state, which must, for historical reasons, be
  excluded from this particular collection.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFormElement" id="dom-form-length" data-dfn-type="attribute"><code>length</code></dfn> IDL
  attribute must return the number of nodes <a href="https://dom.spec.whatwg.org/#represented-by-the-collection" id="the-form-element:represented-by-the-collection" data-x-internal="represented-by-the-collection">represented</a> by the <code id="the-form-element:dom-form-elements-2"><a href="#dom-form-elements">elements</a></code>
  collection.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-form-element:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> at any instant are the indices supported by the
  object returned by the <code id="the-form-element:dom-form-elements-3"><a href="#dom-form-elements">elements</a></code> attribute at that
  instant.</p>
  </div>

  <div data-algorithm="">
  <p id="dom-form-item">To <a id="the-form-element:determine-the-value-of-an-indexed-property" href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-an-indexed-property" data-x-internal="determine-the-value-of-an-indexed-property">determine the value of an indexed property</a> for a
  <code id="the-form-element:the-form-element-9"><a href="#the-form-element">form</a></code> element, the user agent must return the value returned by the <code id="the-form-element:dom-htmlcollection-item"><a data-x-internal="dom-htmlcollection-item" href="https://dom.spec.whatwg.org/#dom-htmlcollection-item">item</a></code> method on the <code id="the-form-element:dom-form-elements-4"><a href="#dom-form-elements">elements</a></code> collection, when invoked with the given index as its
  argument.</p>
  </div>

  <hr>

  <p>Each <code id="the-form-element:the-form-element-10"><a href="#the-form-element">form</a></code> element has a mapping of names to elements called the <dfn id="past-names-map">past names
  map</dfn>. It is used to persist names of controls even when they change names.</p>

  <div data-algorithm="">
  <p>The <a id="the-form-element:supported-property-names" href="https://webidl.spec.whatwg.org/#dfn-supported-property-names" data-x-internal="supported-property-names">supported property names</a> consist of the names obtained from the following
  algorithm, in the order obtained from this algorithm:</p>

  <ol><li><p>Let <var>sourced names</var> be an initially empty ordered list of tuples
   consisting of a string, an element, a source, where the source is either <i>id</i>, <i>name</i>,
   or <i>past</i>, and, if the source is <i>past</i>, an age.</p></li><li>
    <p>For each <a href="#category-listed" id="the-form-element:category-listed-2">listed element</a> <var>candidate</var>
    whose <a href="#form-owner" id="the-form-element:form-owner-2">form owner</a> is the <code id="the-form-element:the-form-element-11"><a href="#the-form-element">form</a></code> element, with the exception of any
    <code id="the-form-element:the-input-element-2"><a href="#the-input-element">input</a></code> elements whose <code id="the-form-element:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the
    <a href="#image-button-state-(type=image)" id="the-form-element:image-button-state-(type=image)-2">Image Button</a> state:</p>

    <ol><li><p>If <var>candidate</var> has an <code id="the-form-element:the-id-attribute"><a href="#the-id-attribute">id</a></code> attribute, add
     an entry to <var>sourced names</var> with that <code id="the-form-element:the-id-attribute-2"><a href="#the-id-attribute">id</a></code>
     attribute's value as the string, <var>candidate</var> as the element, and <i>id</i> as
     the source.</p></li><li><p>If <var>candidate</var> has a <code id="the-form-element:attr-fe-name-3"><a href="#attr-fe-name">name</a></code> attribute,
     add an entry to <var>sourced names</var> with that <code id="the-form-element:attr-fe-name-4"><a href="#attr-fe-name">name</a></code> attribute's value as the string, <var>candidate</var>
     as the element, and <i>name</i> as the source.</p></li></ol>
   </li><li>
    <p>For each <code id="the-form-element:the-img-element-2"><a href="#the-img-element">img</a></code> element <var>candidate</var> whose <a href="#form-owner" id="the-form-element:form-owner-3">form owner</a> is the
    <code id="the-form-element:the-form-element-12"><a href="#the-form-element">form</a></code> element:</p>

    <ol><li><p>If <var>candidate</var> has an <code id="the-form-element:the-id-attribute-3"><a href="#the-id-attribute">id</a></code> attribute, add
     an entry to <var>sourced names</var> with that <code id="the-form-element:the-id-attribute-4"><a href="#the-id-attribute">id</a></code>
     attribute's value as the string, <var>candidate</var> as the element, and <i>id</i> as
     the source.</p></li><li><p>If <var>candidate</var> has a <code id="the-form-element:attr-img-name"><a href="#attr-img-name">name</a></code> attribute,
     add an entry to <var>sourced names</var> with that <code id="the-form-element:attr-img-name-2"><a href="#attr-img-name">name</a></code> attribute's value as the string, <var>candidate</var>
     as the element, and <i>name</i> as the source.</p></li></ol>
   </li><li>
    <p>For each entry <var>past entry</var> in the <a href="#past-names-map" id="the-form-element:past-names-map">past names map</a>, add an entry
    to <var>sourced names</var> with the <var>past entry</var>'s name as the
    string, <var>past entry</var>'s element as the element, <i>past</i> as the source, and
    the length of time <var>past entry</var> has been in the <a href="#past-names-map" id="the-form-element:past-names-map-2">past names map</a> as
    the age.</p>
   </li><li><p>Sort <var>sourced names</var> by <a id="the-form-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> of the element entry of
   each tuple, sorting entries with the same element by putting entries whose source is <i>id</i>
   first, then entries whose source is <i>name</i>, and finally entries whose source is <i>past</i>,
   and sorting entries with the same element and source by their age, oldest first.</p></li><li><p>Remove any entries in <var>sourced names</var> that have the empty string as
   their name.</p></li><li><p>Remove any entries in <var>sourced names</var> that have the same name as an
   earlier entry in the map.</p></li><li><p>Return the list of names from <var>sourced names</var>, maintaining their
   relative order.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="dom-form-nameditem">To <a id="the-form-element:determine-the-value-of-a-named-property" href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-a-named-property" data-x-internal="determine-the-value-of-a-named-property">determine the value of a named property</a> <var>name</var>
  for a <code id="the-form-element:the-form-element-13"><a href="#the-form-element">form</a></code> element, the user agent must run the following steps:</p>

  <ol><li><p>Let <var>candidates</var> be a <a href="#live" id="the-form-element:live">live</a> <code id="the-form-element:radionodelist-4"><a href="#radionodelist">RadioNodeList</a></code> object
   containing all the <a href="#category-listed" id="the-form-element:category-listed-3">listed elements</a>, whose <a href="#form-owner" id="the-form-element:form-owner-4">form
   owner</a> is the <code id="the-form-element:the-form-element-14"><a href="#the-form-element">form</a></code> element, that have either an <code id="the-form-element:the-id-attribute-5"><a href="#the-id-attribute">id</a></code> attribute or a <code id="the-form-element:attr-fe-name-5"><a href="#attr-fe-name">name</a></code> attribute equal
   to <var>name</var>, with the exception of <code id="the-form-element:the-input-element-3"><a href="#the-input-element">input</a></code> elements whose <code id="the-form-element:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#image-button-state-(type=image)" id="the-form-element:image-button-state-(type=image)-3">Image Button</a> state, in <a id="the-form-element:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li><li><p>If <var>candidates</var> is empty, let <var>candidates</var> be a <a href="#live" id="the-form-element:live-2">live</a>
   <code id="the-form-element:radionodelist-5"><a href="#radionodelist">RadioNodeList</a></code> object containing all the <code id="the-form-element:the-img-element-3"><a href="#the-img-element">img</a></code> elements, whose <a href="#form-owner" id="the-form-element:form-owner-5">form
   owner</a> is the <code id="the-form-element:the-form-element-15"><a href="#the-form-element">form</a></code> element, that have either an <code id="the-form-element:the-id-attribute-6"><a href="#the-id-attribute">id</a></code> attribute or a <code id="the-form-element:attr-img-name-3"><a href="#attr-img-name">name</a></code> attribute
   equal to <var>name</var>, in <a id="the-form-element:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li><li><p>If <var>candidates</var> is empty, <var>name</var> is the name of one of
   the entries in the <code id="the-form-element:the-form-element-16"><a href="#the-form-element">form</a></code> element's <a href="#past-names-map" id="the-form-element:past-names-map-3">past names map</a>: return the object
   associated with <var>name</var> in that map.</p></li><li><p>If <var>candidates</var> contains more than one node, return <var>candidates</var>.</p></li><li><p>Otherwise, <var>candidates</var> contains exactly one node. Add a mapping from
   <var>name</var> to the node in <var>candidates</var> in the <code id="the-form-element:the-form-element-17"><a href="#the-form-element">form</a></code>
   element's <a href="#past-names-map" id="the-form-element:past-names-map-4">past names map</a>, replacing the previous entry with the same name, if
   any.</p></li><li><p>Return the node in <var>candidates</var>.</p></li></ol>
  </div>

  <p>If an element listed in a <code id="the-form-element:the-form-element-18"><a href="#the-form-element">form</a></code> element's <a href="#past-names-map" id="the-form-element:past-names-map-5">past names map</a> changes
  <a href="#form-owner" id="the-form-element:form-owner-6">form owner</a>, then its entries must be removed from that map.</p>

  

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFormElement" id="dom-form-submit" data-dfn-type="method"><code>submit()</code></dfn>
  method steps are to <a href="#concept-form-submit" id="the-form-element:concept-form-submit">submit</a> <a id="the-form-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> from
  <a id="the-form-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, with <i id="the-form-element:submit-subbmitted-from-method"><a href="#submit-subbmitted-from-method">submitted from <code>submit()</code> method</a></i> set to true.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFormElement" id="dom-form-requestsubmit" data-dfn-type="method"><code>requestSubmit(<var>submitter</var>)</code></dfn> method, when
  invoked, must run the following steps:</p>

  <ol><li>
    <p>If <var>submitter</var> is not null, then:</p>

    <ol><li><p>If <var>submitter</var> is not a <a href="#concept-submit-button" id="the-form-element:concept-submit-button-2">submit
     button</a>, then throw a <code id="the-form-element:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>.</p></li><li><p>If <var>submitter</var>'s <a href="#form-owner" id="the-form-element:form-owner-7">form owner</a> is not this <code id="the-form-element:the-form-element-19"><a href="#the-form-element">form</a></code> element,
     then throw a <a id="the-form-element:notfounderror" href="https://webidl.spec.whatwg.org/#notfounderror" data-x-internal="notfounderror">"<code>NotFoundError</code>"</a> <code id="the-form-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
   </li><li><p>Otherwise, set <var>submitter</var> to this <code id="the-form-element:the-form-element-20"><a href="#the-form-element">form</a></code> element.</p></li><li><p><a href="#concept-form-submit" id="the-form-element:concept-form-submit-2">Submit</a> this <code id="the-form-element:the-form-element-21"><a href="#the-form-element">form</a></code> element, from
   <var>submitter</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFormElement" id="dom-form-reset" data-dfn-type="method"><code>reset()</code></dfn>
  method, when invoked, must run the following steps:</p>

  <ol><li><p>If the <code id="the-form-element:the-form-element-22"><a href="#the-form-element">form</a></code> element is marked as <i id="the-form-element:locked-for-reset"><a href="#locked-for-reset">locked for reset</a></i>, then return.</p></li><li><p>Mark the <code id="the-form-element:the-form-element-23"><a href="#the-form-element">form</a></code> element as <dfn id="locked-for-reset">locked for reset</dfn>.</p></li><li><p><a href="#concept-form-reset" id="the-form-element:concept-form-reset">Reset</a> the <code id="the-form-element:the-form-element-24"><a href="#the-form-element">form</a></code> element.</p></li><li><p>Unmark the <code id="the-form-element:the-form-element-25"><a href="#the-form-element">form</a></code> element as <i id="the-form-element:locked-for-reset-2"><a href="#locked-for-reset">locked for reset</a></i>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>If the <dfn data-dfn-for="HTMLFormElement" id="dom-form-checkvalidity" data-dfn-type="method"><code>checkValidity()</code></dfn> method is invoked, the user agent
  must <a href="#statically-validate-the-constraints" id="the-form-element:statically-validate-the-constraints">statically validate the constraints</a> of the <code id="the-form-element:the-form-element-26"><a href="#the-form-element">form</a></code> element, and return
  true if the constraint validation returned a <i>positive</i> result, and false if it returned a
  <i>negative</i> result.</p>
  </div>

  <div data-algorithm="">
  <p>If the <dfn data-dfn-for="HTMLFormElement" id="dom-form-reportvalidity" data-dfn-type="method"><code>reportValidity()</code></dfn> method is invoked, the user agent
  must <a href="#interactively-validate-the-constraints" id="the-form-element:interactively-validate-the-constraints-3">interactively validate the constraints</a> of the <code id="the-form-element:the-form-element-27"><a href="#the-form-element">form</a></code> element, and
  return true if the constraint validation returned a <i>positive</i> result, and false if it returned
  a <i>negative</i> result.</p>
  </div>

  

  <div class="example">

   <p>This example shows two search forms:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"https://www.google.com/search"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"get"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Google: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"search"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"q"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"submit"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Search..."</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"https://www.bing.com/search"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"get"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Bing: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"search"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"q"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"submit"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Search..."</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-label-element"><span class="secno">4.10.4</span> The <dfn data-dfn-type="element"><code>label</code></dfn> element<a href="#the-label-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label" title="The <label> HTML element represents a caption for an item in a user interface.">Element/label</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement" title="The HTMLLabelElement interface gives access to properties specific to <label> elements. It inherits methods and properties from the base HTMLElement interface.">HTMLLabelElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/htmlFor" title="The HTMLLabelElement.htmlFor property reflects the value of the for content property. That means that this script-accessible property is used to set and read the value of the content property for, which is the ID of the label's associated control element.">HTMLLabelElement/htmlFor</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-label-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-label-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-label-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#interactive-content-2" id="the-label-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#palpable-content-2" id="the-label-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-label-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-label-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-label-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-label-element:phrasing-content-2-3">Phrasing content</a>, but with no descendant <a href="#category-label" id="the-label-element:category-label">labelable elements</a> unless it is the element's <a href="#labeled-control" id="the-label-element:labeled-control">labeled control</a>, and no descendant <code id="the-label-element:the-label-element"><a href="#the-label-element">label</a></code> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-label-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-label-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-label-element:global-attributes">Global attributes</a></dd><dd><code id="the-label-element:attr-label-for"><a href="#attr-label-for">for</a></code> —  Associate the label with form control
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-label-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-label">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-label">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-label-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmllabelelement" data-dfn-type="interface"><c- g="">HTMLLabelElement</c-></dfn> : <a href="#htmlelement" id="the-label-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-label-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-label-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-label-form" id="the-label-element:dom-label-form"><c- g="">form</c-></a>;
  [<a href="#cereactions" id="the-label-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-label-element:xattr-reflect">Reflect</a>="<a href="#attr-label-for" id="the-label-element:attr-label-for-2">for</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLabelElement" id="dom-label-htmlfor" data-dfn-type="attribute"><c- g="">htmlFor</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlelement" id="the-label-element:htmlelement-2"><c- n="">HTMLElement</c-></a>? <a href="#dom-label-control" id="the-label-element:dom-label-control"><c- g="">control</c-></a>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-label-element:the-label-element-2"><a href="#the-label-element">label</a></code> element <a href="#represents" id="the-label-element:represents">represents</a> a caption in a user interface. The
  caption can be associated with a specific form control, known as the
  <code id="the-label-element:the-label-element-3"><a href="#the-label-element">label</a></code> element's <dfn id="labeled-control">labeled control</dfn>, either using the <code id="the-label-element:attr-label-for-3"><a href="#attr-label-for">for</a></code> attribute, or by putting the form control inside the
  <code id="the-label-element:the-label-element-4"><a href="#the-label-element">label</a></code> element itself.</p>

  

  <p>Except where otherwise specified by the following rules, a <code id="the-label-element:the-label-element-5"><a href="#the-label-element">label</a></code> element has no
  <a href="#labeled-control" id="the-label-element:labeled-control-2">labeled control</a>.</p>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/for" title="The for attribute is an allowed attribute for <label> and <output>. When used on a <label> element it indicates the form element that this label describes. When used on an <output> element it allows for an explicit relationship between the elements that represent values which are used in the output.">Attributes/for</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="label" id="attr-label-for" data-dfn-type="element-attr"><code>for</code></dfn> attribute may
  be specified to indicate a form control with which the caption is to be associated. If the
  attribute is specified, the attribute's value must be the <a href="https://dom.spec.whatwg.org/#concept-id" id="the-label-element:concept-id" data-x-internal="concept-id">ID</a> of a
  <a href="#category-label" id="the-label-element:category-label-2">labelable element</a> in the same <a id="the-label-element:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> as the
  <code id="the-label-element:the-label-element-6"><a href="#the-label-element">label</a></code> element. If the attribute is specified and there is an element in
  the <a id="the-label-element:tree-2" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> whose <a href="https://dom.spec.whatwg.org/#concept-id" id="the-label-element:concept-id-2" data-x-internal="concept-id">ID</a> is equal to the value of the <code id="the-label-element:attr-label-for-4"><a href="#attr-label-for">for</a></code> attribute, and the first such element in <a id="the-label-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
  order</a> is a <a href="#category-label" id="the-label-element:category-label-3">labelable element</a>, then that element is the
  <code id="the-label-element:the-label-element-7"><a href="#the-label-element">label</a></code> element's <a href="#labeled-control" id="the-label-element:labeled-control-3">labeled control</a>.</p>

  

  <div data-algorithm="">
  <p>If the <code id="the-label-element:attr-label-for-5"><a href="#attr-label-for">for</a></code> attribute is not specified, but the
  <code id="the-label-element:the-label-element-8"><a href="#the-label-element">label</a></code> element has a <a href="#category-label" id="the-label-element:category-label-4">labelable element</a> descendant,
  then the first such descendant in <a id="the-label-element:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> is the <code id="the-label-element:the-label-element-9"><a href="#the-label-element">label</a></code> element's
  <a href="#labeled-control" id="the-label-element:labeled-control-4">labeled control</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-label-element:the-label-element-10"><a href="#the-label-element">label</a></code> element's exact default presentation and behavior, in particular what
  its <a id="the-label-element:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> might be, if anything, should match the platform's label
  behavior. The <a id="the-label-element:activation-behaviour-2" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> of a <code id="the-label-element:the-label-element-11"><a href="#the-label-element">label</a></code> element for events targeted
  at <a href="#interactive-content-2" id="the-label-element:interactive-content-2-2">interactive content</a> descendants of a <code id="the-label-element:the-label-element-12"><a href="#the-label-element">label</a></code> element, and any
  descendants of those <a href="#interactive-content-2" id="the-label-element:interactive-content-2-3">interactive content</a> descendants, must be to do nothing.</p>
  </div>

  <p class="note"><a href="#form-associated-custom-element" id="the-label-element:form-associated-custom-element">Form-associated custom
  elements</a> are <a href="#category-label" id="the-label-element:category-label-5">labelable elements</a>, so for user agents
  where the <code id="the-label-element:the-label-element-13"><a href="#the-label-element">label</a></code> element's <a id="the-label-element:activation-behaviour-3" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> impacts the <a href="#labeled-control" id="the-label-element:labeled-control-5">labeled
  control</a>, both built-in and custom elements will be impacted.</p>

  

  <div class="example">

   <p>For example, on platforms where clicking a label activates the form control, clicking the
   <code id="the-label-element:the-label-element-14"><a href="#the-label-element">label</a></code> in the following snippet could trigger the user agent to <a href="#fire-a-click-event" id="the-label-element:fire-a-click-event">fire a <code>click</code> event</a> at the <code id="the-label-element:the-input-element"><a href="#the-input-element">input</a></code> element, as if the
   element itself had been triggered by the user:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">lost</c-><c- p="">&gt;</c-> Lost<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

   <p>Similarly, assuming <code>my-checkbox</code> was declared as a
   <a href="#form-associated-custom-element" id="the-label-element:form-associated-custom-element-2">form-associated custom element</a> (like in <a href="#custom-elements-face-example">this
   example</a>), then the code</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">my-checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">lost</c-><c- p="">&gt;&lt;/</c-><c- f="">my-checkbox</c-><c- p="">&gt;</c-> Lost<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

   <p>would have the same behavior, <a href="#fire-a-click-event" id="the-label-element:fire-a-click-event-2">firing a <code>click</code> event</a> at the <code>my-checkbox</code>
   element.</p>

   <p>On other platforms, the behavior in both cases might be just to focus the control, or to do
   nothing.</p>
  </div>

  

  <div class="example">

   <p>The following example shows three form controls each with a label, two of which have small
   text showing the right format for users to use.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Full name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">fn</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Format: First Last<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Age: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">age</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Post code: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">pc</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Format: AB12 3CD<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <dl class="domintro"><dt><code><var>label</var>.<a href="#dom-label-control" id="dom-label-control-dev">control</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control" title="The read-only HTMLLabelElement.control property returns a reference to the control (in the form of an object of type HTMLElement or one of its derivatives) with which the <label> element is associated, or null if the label isn't associated with a control.">HTMLLabelElement/control</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the form control that is associated with this element.</p></dd><dt><code><var>label</var>.<a href="#dom-label-form" id="dom-label-form-dev">form</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/form" title="The read-only HTMLLabelElement.form property returns an HTMLFormElement object which represents the form of which the label's associated control is a part, or null if there is either no associated control, or if that control isn't in a form.">HTMLLabelElement/form</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="#form-owner" id="the-label-element:form-owner">form owner</a> of the form control that is associated with this
    element.</p>

    <p>Returns null if there isn't one.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLLabelElement" id="dom-label-control" data-dfn-type="attribute"><code>control</code></dfn>
  IDL attribute must return the <code id="the-label-element:the-label-element-15"><a href="#the-label-element">label</a></code> element's <a href="#labeled-control" id="the-label-element:labeled-control-6">labeled control</a>, if any,
  or null if there isn't one.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLLabelElement" id="dom-label-form" data-dfn-type="attribute"><code>form</code></dfn> IDL
  attribute must run the following steps:</p>

  <ol><li><p>If the <code id="the-label-element:the-label-element-16"><a href="#the-label-element">label</a></code> element has no <a href="#labeled-control" id="the-label-element:labeled-control-7">labeled control</a>, then return
   null.</p></li><li><p>If the <code id="the-label-element:the-label-element-17"><a href="#the-label-element">label</a></code> element's <a href="#labeled-control" id="the-label-element:labeled-control-8">labeled control</a> is not a
   <a href="#form-associated-element" id="the-label-element:form-associated-element">form-associated element</a>, then return null.</p></li><li><p>Return the <code id="the-label-element:the-label-element-18"><a href="#the-label-element">label</a></code> element's <a href="#labeled-control" id="the-label-element:labeled-control-9">labeled control</a>'s <a href="#form-owner" id="the-label-element:form-owner-2">form
   owner</a> (which can still be null).</p></li></ol>
  </div>

  

  <p class="note">The <code id="the-label-element:dom-label-form-2"><a href="#dom-label-form">form</a></code> IDL attribute on the
  <code id="the-label-element:the-label-element-19"><a href="#the-label-element">label</a></code> element is different from the <code id="the-label-element:attr-fae-form"><a href="#attr-fae-form">form</a></code> IDL
  attribute on <a href="#category-listed" id="the-label-element:category-listed">listed</a> <a href="#form-associated-element" id="the-label-element:form-associated-element-2">form-associated elements</a>, and the <code id="the-label-element:the-label-element-20"><a href="#the-label-element">label</a></code> element does not have a <code id="the-label-element:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> content attribute.</p>

  <hr>

  <dl class="domintro"><dt><code><var>control</var>.<a href="#dom-lfe-labels" id="dom-lfe-labels-dev">labels</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/labels" title="The HTMLButtonElement.labels read-only property returns a NodeList of the <label> elements associated with the <button> element.">HTMLButtonElement/labels</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels" title="The HTMLInputElement.labels read-only property returns a NodeList of the <label> elements associated with the <input> element, if the element is not hidden. If the element has the type hidden, the property returns null.">HTMLInputElement/labels</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMeterElement/labels" title="The HTMLMeterElement.labels read-only property returns a NodeList of the <label> elements associated with the <meter> element.">HTMLMeterElement/labels</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/labels" title="The HTMLOutputElement.labels read-only property returns a NodeList of the <label> elements associated with the <output> element.">HTMLOutputElement/labels</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>9+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLProgressElement/labels" title="The HTMLProgressElement.labels read-only property returns a NodeList of the <label> elements associated with the <progress> element.">HTMLProgressElement/labels</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/labels" title="The HTMLSelectElement.labels read-only property returns a NodeList of the <label> elements associated with the <select> element.">HTMLSelectElement/labels</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/labels" title="The HTMLTextAreaElement.labels read-only property returns a NodeList of the <label> elements associated with the <textarea> element.">HTMLTextAreaElement/labels</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="the-label-element:nodelist"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> of all the <code id="the-label-element:the-label-element-21"><a href="#the-label-element">label</a></code> elements that the form control
    is associated with.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p><a href="#category-label" id="the-label-element:category-label-6">Labelable elements</a> and all <code id="the-label-element:the-input-element-2"><a href="#the-input-element">input</a></code> elements
  have a <a href="#live" id="the-label-element:live">live</a> <code id="the-label-element:nodelist-2"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> object associated with them that represents the
  list of <code id="the-label-element:the-label-element-22"><a href="#the-label-element">label</a></code> elements, in <a id="the-label-element:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, whose <a href="#labeled-control" id="the-label-element:labeled-control-10">labeled
  control</a> is the element in question. The <dfn data-dfn-for="HTMLInputElement,HTMLButtonElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOutputElement,HTMLProgressElement,HTMLMeterElement" id="dom-lfe-labels" data-dfn-type="attribute"><code>labels</code></dfn> IDL attribute of <a href="#category-label" id="the-label-element:category-label-7">labelable elements</a> that are not <a href="#form-associated-custom-element" id="the-label-element:form-associated-custom-element-3">form-associated custom elements</a>, and the <code id="the-label-element:dom-lfe-labels"><a href="#dom-lfe-labels">labels</a></code> IDL attribute of <code id="the-label-element:the-input-element-3"><a href="#the-input-element">input</a></code> elements, on getting,
  must return that <code id="the-label-element:nodelist-3"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> object, and that same value must always be returned, unless
  this element is an <code id="the-label-element:the-input-element-4"><a href="#the-input-element">input</a></code> element whose <code id="the-label-element:attr-input-type"><a href="#attr-input-type">type</a></code>
  attribute is in the <a href="#hidden-state-(type=hidden)" id="the-label-element:hidden-state-(type=hidden)">Hidden</a> state, in which case it
  must instead return null.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/labels" title="The labels read-only property of the ElementInternals interface returns the labels associated with the element.">ElementInternals/labels</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p><a href="#form-associated-custom-element" id="the-label-element:form-associated-custom-element-4">Form-associated custom elements</a> don't have
  a <code id="the-label-element:dom-lfe-labels-2"><a href="#dom-lfe-labels">labels</a></code> IDL attribute. Instead, their
  <code id="the-label-element:elementinternals"><a href="#elementinternals">ElementInternals</a></code> object has a <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-labels" data-dfn-type="attribute"><code>labels</code></dfn> IDL attribute. On getting, it must throw
  a <a id="the-label-element:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="the-label-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the <a href="#internals-target" id="the-label-element:internals-target">target element</a> is not a <a href="#form-associated-custom-element" id="the-label-element:form-associated-custom-element-5">form-associated custom
  element</a>. Otherwise, it must return that <code id="the-label-element:nodelist-4"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> object, and that same value
  must always be returned.</p>
  </div>

  <div class="example">
   <p>This (non-conforming) example shows what happens to the <code id="the-label-element:nodelist-5"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> and what <code id="the-label-element:dom-lfe-labels-3"><a href="#dom-lfe-labels">labels</a></code> returns when an <code id="the-label-element:the-input-element-5"><a href="#the-input-element">input</a></code> element has its <code id="the-label-element:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute changed.</p>

   <pre><code class="html"><c- cp="">&lt;!doctype html&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">const</c-> input <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- t="">'input'</c-><c- p="">);</c->
 <c- a="">const</c-> labels <c- o="">=</c-> input<c- p="">.</c->labels<c- p="">;</c->
 console<c- p="">.</c->assert<c- p="">(</c->labels<c- p="">.</c->length <c- o="">===</c-> <c- mf="">1</c-><c- p="">);</c->

 input<c- p="">.</c->type <c- o="">=</c-> <c- t="">'hidden'</c-><c- p="">;</c->
 console<c- p="">.</c->assert<c- p="">(</c->labels<c- p="">.</c->length <c- o="">===</c-> <c- mf="">0</c-><c- p="">);</c-> <c- c1="">// the input is no longer the label's </c-><a href="#labeled-control" id="the-label-element:labeled-control-11"><c- c1="">labeled control</c-></a>
 console<c- p="">.</c->assert<c- p="">(</c->input<c- p="">.</c->labels <c- o="">===</c-> <c- kc="">null</c-><c- p="">);</c->

 input<c- p="">.</c->type <c- o="">=</c-> <c- t="">'checkbox'</c-><c- p="">;</c->
 console<c- p="">.</c->assert<c- p="">(</c->labels<c- p="">.</c->length <c- o="">===</c-> <c- mf="">1</c-><c- p="">);</c-> <c- c1="">// the input is once again the label's </c-><a href="#labeled-control" id="the-label-element:labeled-control-12"><c- c1="">labeled control</c-></a>
 console<c- p="">.</c->assert<c- p="">(</c->input<c- p="">.</c->labels <c- o="">===</c-> labels<c- p="">);</c-> <c- c1="">// same value as returned originally</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>

  


  <h4 id="the-input-element"><span class="secno">4.10.5</span> The <dfn data-dfn-type="element"><code>input</code></dfn> element<a href="#the-input-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>1+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input</a></p></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement" title="The HTMLInputElement interface provides special properties and methods for manipulating the options, layout, and presentation of <input> elements.">HTMLInputElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/disabled" title="The HTMLButtonElement.disabled property indicates whether the control is disabled, meaning that it does not accept any clicks.">HTMLButtonElement/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/disabled" title="The HTMLSelectElement.disabled property is a boolean value that reflects the disabled HTML attribute, which indicates whether the control is disabled. If it is disabled, it does not accept clicks. A disabled element is unusable and un-clickable.">HTMLSelectElement/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/multiple" title="The HTMLInputElement.multiple property indicates if an input can have more than one value. Firefox currently only supports multiple for <input type=&quot;file&quot;>.">HTMLInputElement/multiple</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-input-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-input-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-input-element:phrasing-content-2">Phrasing content</a>.</dd><dd>If the <code id="the-input-element:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is <em>not</em> in the <a href="#hidden-state-(type=hidden)" id="the-input-element:hidden-state-(type=hidden)">Hidden</a> state: <a href="#interactive-content-2" id="the-input-element:interactive-content-2">Interactive content</a>.</dd><dd>If the <code id="the-input-element:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is <em>not</em> in the <a href="#hidden-state-(type=hidden)" id="the-input-element:hidden-state-(type=hidden)-2">Hidden</a> state: <a href="#category-listed" id="the-input-element:category-listed">Listed</a>, <a href="#category-label" id="the-input-element:category-label">labelable</a>, <a href="#category-submit" id="the-input-element:category-submit">submittable</a>, <a href="#category-reset" id="the-input-element:category-reset">resettable</a>, and <a href="#category-autocapitalize" id="the-input-element:category-autocapitalize">autocapitalize-and-autocorrect inheriting</a> <a href="#form-associated-element" id="the-input-element:form-associated-element">form-associated element</a>.</dd><dd>If the <code id="the-input-element:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#hidden-state-(type=hidden)" id="the-input-element:hidden-state-(type=hidden)-3">Hidden</a> state: <a href="#category-listed" id="the-input-element:category-listed-2">Listed</a>, <a href="#category-submit" id="the-input-element:category-submit-2">submittable</a>, <a href="#category-reset" id="the-input-element:category-reset-2">resettable</a>, and <a href="#category-autocapitalize" id="the-input-element:category-autocapitalize-2">autocapitalize-and-autocorrect inheriting</a> <a href="#form-associated-element" id="the-input-element:form-associated-element-2">form-associated element</a>.</dd><dd>If the <code id="the-input-element:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute is <em>not</em> in the <a href="#hidden-state-(type=hidden)" id="the-input-element:hidden-state-(type=hidden)-4">Hidden</a> state: <a href="#palpable-content-2" id="the-input-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-input-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-input-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-input-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-input-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-input-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>No <a href="#syntax-end-tag" id="the-input-element:syntax-end-tag">end tag</a>.</dd><dt><a href="#concept-element-attributes" id="the-input-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-input-element:global-attributes">Global attributes</a></dd><dd><code id="the-input-element:attr-input-accept"><a href="#attr-input-accept">accept</a></code> —  Hint for expected file type in <a href="#file-upload-state-(type=file)" id="the-input-element:file-upload-state-(type=file)">file upload controls</a>
     </dd><dd><code id="the-input-element:attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code> —  Allow the color's alpha component to be set
     </dd><dd><code id="the-input-element:attr-input-alt"><a href="#attr-input-alt">alt</a></code> —  Replacement text for use when images are not available
     </dd><dd><code id="the-input-element:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code> —  Hint for form autofill feature
     </dd><dd><code id="the-input-element:attr-input-checked"><a href="#attr-input-checked">checked</a></code> —  Whether the control is checked
     </dd><dd><code id="the-input-element:attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code> —  The color space of the serialized color
     </dd><dd><code id="the-input-element:attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code> —  Name of form control to use for sending the element's <a href="#the-directionality" id="the-input-element:the-directionality">directionality</a> in <a href="#form-submission-2" id="the-input-element:form-submission-2">form submission</a>
     </dd><dd><code id="the-input-element:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code> —  Whether the form control is disabled
     </dd><dd><code id="the-input-element:attr-fae-form"><a href="#attr-fae-form">form</a></code> —  Associates the element with a <code id="the-input-element:the-form-element"><a href="#the-form-element">form</a></code> element
     </dd><dd><code id="the-input-element:attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code> —  <a id="the-input-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> to use for <a href="#form-submission-2" id="the-input-element:form-submission-2-2">form submission</a>
     </dd><dd><code id="the-input-element:attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code> —  <a href="#entry-list" id="the-input-element:entry-list">Entry list</a> encoding type to use for <a href="#form-submission-2" id="the-input-element:form-submission-2-3">form submission</a>
     </dd><dd><code id="the-input-element:attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code> —  Variant to use for <a href="#form-submission-2" id="the-input-element:form-submission-2-4">form submission</a>
     </dd><dd><code id="the-input-element:attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code> —  Bypass form control validation for <a href="#form-submission-2" id="the-input-element:form-submission-2-5">form submission</a>
     </dd><dd><code id="the-input-element:attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code> —  <a href="#navigable" id="the-input-element:navigable">Navigable</a> for <a href="#form-submission-2" id="the-input-element:form-submission-2-6">form submission</a>
     </dd><dd><code id="the-input-element:attr-dim-height"><a href="#attr-dim-height">height</a></code> —  Vertical dimension
     </dd><dd><code id="the-input-element:attr-input-list"><a href="#attr-input-list">list</a></code> —  List of autocomplete options
     </dd><dd><code id="the-input-element:attr-input-max"><a href="#attr-input-max">max</a></code> —  Maximum value
     </dd><dd><code id="the-input-element:attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code> —  Maximum <a id="the-input-element:length" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of value
     </dd><dd><code id="the-input-element:attr-input-min"><a href="#attr-input-min">min</a></code> —  Minimum value
     </dd><dd><code id="the-input-element:attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code> —  Minimum <a id="the-input-element:length-2" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of value
     </dd><dd><code id="the-input-element:attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> —  Whether to allow multiple values
     </dd><dd><code id="the-input-element:attr-fe-name"><a href="#attr-fe-name">name</a></code> —  Name of the element to use for <a href="#form-submission-2" id="the-input-element:form-submission-2-7">form submission</a> and in the <code id="the-input-element:dom-form-elements"><a href="#dom-form-elements">form.elements</a></code> API 
     </dd><dd><code id="the-input-element:attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code> —  Pattern to be matched by the form control's value
     </dd><dd><code id="the-input-element:attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code> —  User-visible label to be placed within the form control
     </dd><dd><code id="the-input-element:attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code> —  Targets a popover element to toggle, show, or hide
     </dd><dd><code id="the-input-element:attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code> —  Indicates whether a targeted popover element is to be toggled, shown, or hidden
     </dd><dd><code id="the-input-element:attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code> —  Whether to allow the value to be edited by the user
     </dd><dd><code id="the-input-element:attr-input-required"><a href="#attr-input-required">required</a></code> —  Whether the control is required for <a href="#form-submission-2" id="the-input-element:form-submission-2-8">form submission</a>
     </dd><dd><code id="the-input-element:attr-input-size"><a href="#attr-input-size">size</a></code> —  Size of the control
     </dd><dd><code id="the-input-element:attr-input-src"><a href="#attr-input-src">src</a></code> —  Address of the resource
     </dd><dd><code id="the-input-element:attr-input-step"><a href="#attr-input-step">step</a></code> —  Granularity to be matched by the form control's value
     </dd><dd><code id="the-input-element:attr-input-type-5"><a href="#attr-input-type">type</a></code> —  Type of form control
     </dd><dd><code id="the-input-element:attr-input-value"><a href="#attr-input-value">value</a></code> —  Value of the form control
     </dd><dd><code id="the-input-element:attr-dim-width"><a href="#attr-dim-width">width</a></code> —  Horizontal dimension
     </dd><dd>Also, the <code id="the-input-element:attr-input-title"><a href="#attr-input-title">title</a></code> attribute <a href="#attr-input-title" id="the-input-element:attr-input-title-2">has special semantics</a> on this element:  Description of pattern (when used with <code id="the-input-element:attr-input-pattern-2"><a href="#attr-input-pattern">pattern</a></code> attribute)
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-input-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><code id="the-input-element:attr-input-type-6"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="the-input-element:hidden-state-(type=hidden)-5">Hidden</a> state: <a href="https://w3c.github.io/html-aria/#el-input-hidden">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-hidden">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-7"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-input-element:text-(type=text)-state-and-search-state-(type=search)">Text</a> state: <a href="https://w3c.github.io/html-aria/#el-input-text">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-text">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-8"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-input-element:text-(type=text)-state-and-search-state-(type=search)-2">Search</a> state: <a href="https://w3c.github.io/html-aria/#el-input-search">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-search">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-9"><a href="#attr-input-type">type</a></code> attribute in the <a href="#telephone-state-(type=tel)" id="the-input-element:telephone-state-(type=tel)">Telephone</a> state: <a href="https://w3c.github.io/html-aria/#el-input-tel">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-tel">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-10"><a href="#attr-input-type">type</a></code> attribute in the <a href="#url-state-(type=url)" id="the-input-element:url-state-(type=url)">URL</a> state: <a href="https://w3c.github.io/html-aria/#el-input-url">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-url">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-11"><a href="#attr-input-type">type</a></code> attribute in the <a href="#email-state-(type=email)" id="the-input-element:email-state-(type=email)">Email</a> state: <a href="https://w3c.github.io/html-aria/#el-input-email">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-email">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-12"><a href="#attr-input-type">type</a></code> attribute in the <a href="#password-state-(type=password)" id="the-input-element:password-state-(type=password)">Password</a> state: <a href="https://w3c.github.io/html-aria/#el-input-password">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-password">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-13"><a href="#attr-input-type">type</a></code> attribute in the <a href="#date-state-(type=date)" id="the-input-element:date-state-(type=date)">Date</a> state: <a href="https://w3c.github.io/html-aria/#el-input-date">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-date">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-14"><a href="#attr-input-type">type</a></code> attribute in the <a href="#month-state-(type=month)" id="the-input-element:month-state-(type=month)">Month</a> state: <a href="https://w3c.github.io/html-aria/#el-input-month">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-month">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-15"><a href="#attr-input-type">type</a></code> attribute in the <a href="#week-state-(type=week)" id="the-input-element:week-state-(type=week)">Week</a> state: <a href="https://w3c.github.io/html-aria/#el-input-week">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-week">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-16"><a href="#attr-input-type">type</a></code> attribute in the <a href="#time-state-(type=time)" id="the-input-element:time-state-(type=time)">Time</a> state: <a href="https://w3c.github.io/html-aria/#el-input-time">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-time">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-17"><a href="#attr-input-type">type</a></code> attribute in the <a href="#local-date-and-time-state-(type=datetime-local)" id="the-input-element:local-date-and-time-state-(type=datetime-local)">Local Date and Time</a> state: <a href="https://w3c.github.io/html-aria/#el-input-datetime-local">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-datetime-local">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-18"><a href="#attr-input-type">type</a></code> attribute in the <a href="#number-state-(type=number)" id="the-input-element:number-state-(type=number)">Number</a> state: <a href="https://w3c.github.io/html-aria/#el-input-number">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-number">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-19"><a href="#attr-input-type">type</a></code> attribute in the <a href="#range-state-(type=range)" id="the-input-element:range-state-(type=range)">Range</a> state: <a href="https://w3c.github.io/html-aria/#el-input-range">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-range">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-20"><a href="#attr-input-type">type</a></code> attribute in the <a href="#color-state-(type=color)" id="the-input-element:color-state-(type=color)">Color</a> state: <a href="https://w3c.github.io/html-aria/#el-input-color">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-color">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-21"><a href="#attr-input-type">type</a></code> attribute in the <a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)">Checkbox</a> state: <a href="https://w3c.github.io/html-aria/#el-input-checkbox">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-checkbox">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-22"><a href="#attr-input-type">type</a></code> attribute in the <a href="#radio-button-state-(type=radio)" id="the-input-element:radio-button-state-(type=radio)">Radio Button</a> state: <a href="https://w3c.github.io/html-aria/#el-input-radio">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-radio">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-23"><a href="#attr-input-type">type</a></code> attribute in the <a href="#file-upload-state-(type=file)" id="the-input-element:file-upload-state-(type=file)-2">File Upload</a> state: <a href="https://w3c.github.io/html-aria/#el-input-file">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-file">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-24"><a href="#attr-input-type">type</a></code> attribute in the <a href="#submit-button-state-(type=submit)" id="the-input-element:submit-button-state-(type=submit)">Submit Button</a> state: <a href="https://w3c.github.io/html-aria/#el-input-submit">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-submit">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-25"><a href="#attr-input-type">type</a></code> attribute in the <a href="#image-button-state-(type=image)" id="the-input-element:image-button-state-(type=image)">Image Button</a> state: <a href="https://w3c.github.io/html-aria/#el-input-image">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-image">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-26"><a href="#attr-input-type">type</a></code> attribute in the <a href="#reset-button-state-(type=reset)" id="the-input-element:reset-button-state-(type=reset)">Reset Button</a> state: <a href="https://w3c.github.io/html-aria/#el-input-reset">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-reset">for implementers</a>.</dd><dd><code id="the-input-element:attr-input-type-27"><a href="#attr-input-type">type</a></code> attribute in the <a href="#button-state-(type=button)" id="the-input-element:button-state-(type=button)">Button</a> state: <a href="https://w3c.github.io/html-aria/#el-input-button">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-input-button">for implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-input-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlinputelement" data-dfn-type="interface"><c- g="">HTMLInputElement</c-></dfn> : <a href="#htmlelement" id="the-input-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-input-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-input-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-accept" data-dfn-type="attribute"><c- g="">accept</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-alpha" data-dfn-type="attribute"><c- g="">alpha</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-alt" data-dfn-type="attribute"><c- g="">alt</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-input-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fe-autocomplete" id="the-input-element:dom-fe-autocomplete"><c- g="">autocomplete</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-4">Reflect</a>="<a href="#attr-input-checked" id="the-input-element:attr-input-checked-2">checked</a>"] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-defaultchecked" data-dfn-type="attribute"><c- g="">defaultChecked</c-></dfn>;
  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-input-checked" id="the-input-element:dom-input-checked"><c- g="">checked</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-input-colorspace" id="the-input-element:dom-input-colorspace"><c- g="">colorSpace</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-dirname" data-dfn-type="attribute"><c- g="">dirName</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-fe-disabled" data-dfn-type="attribute"><c- g="">disabled</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-input-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-fae-form" id="the-input-element:dom-fae-form"><c- g="">form</c-></a>;
  <c- b="">attribute</c-> <a id="the-input-element:filelist" href="https://w3c.github.io/FileAPI/#filelist-section" data-x-internal="filelist"><c- n="">FileList</c-></a>? <a href="#dom-input-files" id="the-input-element:dom-input-files"><c- g="">files</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-9"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-input-element:xattr-reflectsetter-2"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-fs-formaction" id="the-input-element:dom-fs-formaction"><c- g="">formAction</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-10"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fs-formenctype" id="the-input-element:dom-fs-formenctype"><c- g="">formEnctype</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-11"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fs-formmethod" id="the-input-element:dom-fs-formmethod"><c- g="">formMethod</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-12"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-7"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-fs-formnovalidate" data-dfn-type="attribute"><c- g="">formNoValidate</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-13"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-8"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-fs-formtarget" data-dfn-type="attribute"><c- g="">formTarget</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-14"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-input-element:xattr-reflectsetter-3"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-input-height" id="the-input-element:dom-input-height"><c- g="">height</c-></a>;
  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-input-indeterminate" id="the-input-element:dom-input-indeterminate"><c- g="">indeterminate</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmldatalistelement" id="the-input-element:htmldatalistelement"><c- n="">HTMLDataListElement</c-></a>? <a href="#dom-input-list" id="the-input-element:dom-input-list"><c- g="">list</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-15"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-9"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-max" data-dfn-type="attribute"><c- g="">max</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-16"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectnonnegative" id="the-input-element:xattr-reflectnonnegative"><c- g="">ReflectNonNegative</c-></a>] <c- b="">attribute</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-maxlength" data-dfn-type="attribute"><c- g="">maxLength</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-17"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-10"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-min" data-dfn-type="attribute"><c- g="">min</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-18"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectnonnegative" id="the-input-element:xattr-reflectnonnegative-2"><c- g="">ReflectNonNegative</c-></a>] <c- b="">attribute</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-minlength" data-dfn-type="attribute"><c- g="">minLength</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-19"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-11"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-multiple" data-dfn-type="attribute"><c- g="">multiple</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-20"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-12"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-fe-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-21"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-13"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-pattern" data-dfn-type="attribute"><c- g="">pattern</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-22"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-14"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-placeholder" data-dfn-type="attribute"><c- g="">placeholder</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-23"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-15"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-readonly" data-dfn-type="attribute"><c- g="">readOnly</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-24"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-16"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-required" data-dfn-type="attribute"><c- g="">required</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-25"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-17"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-size" data-dfn-type="attribute"><c- g="">size</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-26"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-input-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-src" data-dfn-type="attribute"><c- g="">src</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-27"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-18"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-step" data-dfn-type="attribute"><c- g="">step</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-28"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-input-type" id="the-input-element:dom-input-type"><c- g="">type</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-29"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-input-element:xattr-reflect-19">Reflect</a>="<a href="#attr-input-value" id="the-input-element:attr-input-value-2">value</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-defaultvalue" data-dfn-type="attribute"><c- g="">defaultValue</c-></dfn>;
  [<a href="#cereactions" id="the-input-element:cereactions-30"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> [<a id="the-input-element:legacynulltoemptystring" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <a href="#dom-input-value" id="the-input-element:dom-input-value"><c- g="">value</c-></a>;
  <c- b="">attribute</c-> <a href="https://webidl.spec.whatwg.org/#idl-object" id="the-input-element:idl-object" data-x-internal="idl-object"><c- b="">object</c-></a>? <a href="#dom-input-valueasdate" id="the-input-element:dom-input-valueasdate"><c- g="">valueAsDate</c-></a>;
  <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-input-valueasnumber" id="the-input-element:dom-input-valueasnumber"><c- g="">valueAsNumber</c-></a>;
  [<a href="#cereactions" id="the-input-element:cereactions-31"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-input-element:xattr-reflectsetter-4"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-input-width" id="the-input-element:dom-input-width"><c- g="">width</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-input-stepup" id="the-input-element:dom-input-stepup"><c- g="">stepUp</c-></a>(<c- b="">optional</c-> <c- b="">long</c-> <c- g="">n</c-> = 1);
  <c- b="">undefined</c-> <a href="#dom-input-stepdown" id="the-input-element:dom-input-stepdown"><c- g="">stepDown</c-></a>(<c- b="">optional</c-> <c- b="">long</c-> <c- g="">n</c-> = 1);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-cva-willvalidate" id="the-input-element:dom-cva-willvalidate"><c- g="">willValidate</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#validitystate" id="the-input-element:validitystate"><c- n="">ValidityState</c-></a> <a href="#dom-cva-validity" id="the-input-element:dom-cva-validity"><c- g="">validity</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-cva-validationmessage" id="the-input-element:dom-cva-validationmessage"><c- g="">validationMessage</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-cva-checkvalidity" id="the-input-element:dom-cva-checkvalidity"><c- g="">checkValidity</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-cva-reportvalidity" id="the-input-element:dom-cva-reportvalidity"><c- g="">reportValidity</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-cva-setcustomvalidity" id="the-input-element:dom-cva-setcustomvalidity"><c- g="">setCustomValidity</c-></a>(<c- b="">DOMString</c-> <c- g="">error</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-input-element:nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist" data-x-internal="nodelist"><c- n="">NodeList</c-></a>? <a href="#dom-lfe-labels" id="the-input-element:dom-lfe-labels"><c- g="">labels</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-textarea/input-select" id="the-input-element:dom-textarea/input-select"><c- g="">select</c-></a>();
  <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c->? <a href="#dom-textarea/input-selectionstart" id="the-input-element:dom-textarea/input-selectionstart"><c- g="">selectionStart</c-></a>;
  <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c->? <a href="#dom-textarea/input-selectionend" id="the-input-element:dom-textarea/input-selectionend"><c- g="">selectionEnd</c-></a>;
  <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-textarea/input-selectiondirection" id="the-input-element:dom-textarea/input-selectiondirection"><c- g="">selectionDirection</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-textarea/input-setrangetext" id="the-input-element:dom-textarea/input-setrangetext"><c- g="">setRangeText</c-></a>(<c- b="">DOMString</c-> <c- g="">replacement</c->);
  <c- b="">undefined</c-> <a href="#dom-textarea/input-setrangetext" id="the-input-element:dom-textarea/input-setrangetext-2"><c- g="">setRangeText</c-></a>(<c- b="">DOMString</c-> <c- g="">replacement</c->, <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">start</c->, <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">end</c->, <c- b="">optional</c-> <a href="#selectionmode" id="the-input-element:selectionmode"><c- n="">SelectionMode</c-></a> <c- g="">selectionMode</c-> = "preserve");
  <c- b="">undefined</c-> <a href="#dom-textarea/input-setselectionrange" id="the-input-element:dom-textarea/input-setselectionrange"><c- g="">setSelectionRange</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">start</c->, <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">end</c->, <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">direction</c->);

  <c- b="">undefined</c-> <a href="#dom-input-showpicker" id="the-input-element:dom-input-showpicker"><c- g="">showPicker</c-></a>();

  // <a href="#HTMLInputElement-partial">also has obsolete members</a>
};
<a href="#htmlinputelement" id="the-input-element:htmlinputelement"><c- n="">HTMLInputElement</c-></a> <c- b="">includes</c-> <a href="#popovertargetattributes" id="the-input-element:popovertargetattributes"><c- n="">PopoverTargetAttributes</c-></a>;</code></pre>
   </dd></dl>

  <p>The <code id="the-input-element:the-input-element"><a href="#the-input-element">input</a></code> element <a href="#represents" id="the-input-element:represents">represents</a> a typed data field, usually with a form
  control to allow the user to edit the data.</p>

  <p>The <dfn data-dfn-for="input" id="attr-input-type" data-dfn-type="element-attr"><code>type</code></dfn> attribute
  controls the data type (and associated control) of the element. It is an <a href="#enumerated-attribute" id="the-input-element:enumerated-attribute">enumerated
  attribute</a> with the following keywords and states:</p>

  <table id="attr-input-type-keywords"><thead><tr><th> Keyword
     </th><th> State
     </th><th> Data type
     </th><th> Control type
   </th></tr></thead><tbody><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-hidden-keyword" data-dfn-type="attr-value"><code>hidden</code></dfn>
     </td><td> <a href="#hidden-state-(type=hidden)" id="the-input-element:hidden-state-(type=hidden)-6">Hidden</a>
     </td><td> An arbitrary string
     </td><td> n/a
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-text-keyword" data-dfn-type="attr-value"><code>text</code></dfn>
     </td><td> <a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-input-element:text-(type=text)-state-and-search-state-(type=search)-3">Text</a>
     </td><td> Text with no line breaks
     </td><td> A text control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-search-keyword" data-dfn-type="attr-value"><code>search</code></dfn>
     </td><td> <a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-input-element:text-(type=text)-state-and-search-state-(type=search)-4">Search</a>
     </td><td> Text with no line breaks
     </td><td> Search control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-tel-keyword" data-dfn-type="attr-value"><code>tel</code></dfn>
     </td><td> <a href="#telephone-state-(type=tel)" id="the-input-element:telephone-state-(type=tel)-2">Telephone</a>
     </td><td> Text with no line breaks
     </td><td> A text control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-url-keyword" data-dfn-type="attr-value"><code>url</code></dfn>
     </td><td> <a href="#url-state-(type=url)" id="the-input-element:url-state-(type=url)-2">URL</a>
     </td><td> An absolute URL
     </td><td> A text control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-email-keyword" data-dfn-type="attr-value"><code>email</code></dfn>
     </td><td> <a href="#email-state-(type=email)" id="the-input-element:email-state-(type=email)-2">Email</a>
     </td><td> An email address or list of email addresses
     </td><td> A text control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-password-keyword" data-dfn-type="attr-value"><code>password</code></dfn>
     </td><td> <a href="#password-state-(type=password)" id="the-input-element:password-state-(type=password)-2">Password</a>
     </td><td> Text with no line breaks (sensitive information)
     </td><td> A text control that obscures data entry
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-date-keyword" data-dfn-type="attr-value"><code>date</code></dfn>
     </td><td> <a href="#date-state-(type=date)" id="the-input-element:date-state-(type=date)-2">Date</a>
     </td><td> A date (year, month, day) with no time zone
     </td><td> A date control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-month-keyword" data-dfn-type="attr-value"><code>month</code></dfn>
     </td><td> <a href="#month-state-(type=month)" id="the-input-element:month-state-(type=month)-2">Month</a>
     </td><td> A date consisting of a year and a month with no time zone
     </td><td> A month control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-week-keyword" data-dfn-type="attr-value"><code>week</code></dfn>
     </td><td> <a href="#week-state-(type=week)" id="the-input-element:week-state-(type=week)-2">Week</a>
     </td><td> A date consisting of a week-year number and a week number with no time zone
     </td><td> A week control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-time-keyword" data-dfn-type="attr-value"><code>time</code></dfn>
     </td><td> <a href="#time-state-(type=time)" id="the-input-element:time-state-(type=time)-2">Time</a>
     </td><td> A time (hour, minute, seconds, fractional seconds) with no time zone
     </td><td> A time control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-datetime-local-keyword" data-dfn-type="attr-value"><code>datetime-local</code></dfn>
     </td><td> <a href="#local-date-and-time-state-(type=datetime-local)" id="the-input-element:local-date-and-time-state-(type=datetime-local)-2">Local Date and Time</a>
     </td><td> A date and time (year, month, day, hour, minute, second, fraction of a second) with no time zone
     </td><td> A date and time control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-number-keyword" data-dfn-type="attr-value"><code>number</code></dfn>
     </td><td> <a href="#number-state-(type=number)" id="the-input-element:number-state-(type=number)-2">Number</a>
     </td><td> A numerical value
     </td><td> A text control or spinner control
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-range-keyword" data-dfn-type="attr-value"><code>range</code></dfn>
     </td><td> <a href="#range-state-(type=range)" id="the-input-element:range-state-(type=range)-2">Range</a>
     </td><td> A numerical value, with the extra semantic that the exact value is not important
     </td><td> A slider control or similar
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-color-keyword" data-dfn-type="attr-value"><code>color</code></dfn>
     </td><td> <a href="#color-state-(type=color)" id="the-input-element:color-state-(type=color)-2">Color</a>
     </td><td> An sRGB color with 8-bit red, green, and blue components
     </td><td> A color picker
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-checkbox-keyword" data-dfn-type="attr-value"><code>checkbox</code></dfn>
     </td><td> <a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)-2">Checkbox</a>
     </td><td> A set of zero or more values from a predefined list
     </td><td> A checkbox
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-radio-keyword" data-dfn-type="attr-value"><code>radio</code></dfn>
     </td><td> <a href="#radio-button-state-(type=radio)" id="the-input-element:radio-button-state-(type=radio)-2">Radio Button</a>
     </td><td> An enumerated value
     </td><td> A radio button
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-file-keyword" data-dfn-type="attr-value"><code>file</code></dfn>
     </td><td> <a href="#file-upload-state-(type=file)" id="the-input-element:file-upload-state-(type=file)-3">File Upload</a>
     </td><td> Zero or more files each with a <a id="the-input-element:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> and optionally a filename
     </td><td> A label and a button
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-submit-keyword" data-dfn-type="attr-value"><code>submit</code></dfn>
     </td><td> <a href="#submit-button-state-(type=submit)" id="the-input-element:submit-button-state-(type=submit)-2">Submit Button</a>
     </td><td> An enumerated value, with the extra semantic that it must be the last value selected and initiates form submission
     </td><td> A button
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-image-keyword" data-dfn-type="attr-value"><code>image</code></dfn>
     </td><td> <a href="#image-button-state-(type=image)" id="the-input-element:image-button-state-(type=image)-2">Image Button</a>
     </td><td> A coordinate, relative to a particular image's size, with the extra semantic that it must
     be the last value selected and initiates form submission
     </td><td> Either a clickable image, or a button
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-reset-keyword" data-dfn-type="attr-value"><code>reset</code></dfn>
     </td><td> <a href="#reset-button-state-(type=reset)" id="the-input-element:reset-button-state-(type=reset)-2">Reset Button</a>
     </td><td> n/a
     </td><td> A button
    </td></tr><tr><td> <dfn data-dfn-for="input/type" id="attr-input-type-button-keyword" data-dfn-type="attr-value"><code>button</code></dfn>
     </td><td> <a href="#button-state-(type=button)" id="the-input-element:button-state-(type=button)-2">Button</a>
     </td><td> n/a
     </td><td> A button
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-input-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-input-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-input-element:text-(type=text)-state-and-search-state-(type=search)-5">Text</a> state.</p>
  </div>

  <p>Which of the
   <code id="the-input-element:attr-input-accept-2"><a href="#attr-input-accept">accept</a></code>,
   <code id="the-input-element:attr-input-alpha-2"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="the-input-element:attr-input-alt-2"><a href="#attr-input-alt">alt</a></code>,
   <code id="the-input-element:attr-fe-autocomplete-2"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="the-input-element:attr-input-checked-3"><a href="#attr-input-checked">checked</a></code>,
   <code id="the-input-element:attr-input-colorspace-2"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="the-input-element:attr-fe-dirname-2"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="the-input-element:attr-fs-formaction-2"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="the-input-element:attr-fs-formenctype-2"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="the-input-element:attr-fs-formmethod-2"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="the-input-element:attr-fs-formnovalidate-2"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="the-input-element:attr-fs-formtarget-2"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="the-input-element:attr-dim-height-2"><a href="#attr-dim-height">height</a></code>,
   <code id="the-input-element:attr-input-list-2"><a href="#attr-input-list">list</a></code>,
   <code id="the-input-element:attr-input-max-2"><a href="#attr-input-max">max</a></code>,
   <code id="the-input-element:attr-input-maxlength-2"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="the-input-element:attr-input-min-2"><a href="#attr-input-min">min</a></code>,
   <code id="the-input-element:attr-input-minlength-2"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="the-input-element:attr-input-multiple-2"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="the-input-element:attr-input-pattern-3"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="the-input-element:attr-input-placeholder-2"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="the-input-element:attr-input-readonly-2"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="the-input-element:attr-input-required-2"><a href="#attr-input-required">required</a></code>,
   <code id="the-input-element:attr-input-size-2"><a href="#attr-input-size">size</a></code>,
   <code id="the-input-element:attr-input-src-2"><a href="#attr-input-src">src</a></code>,
   <code id="the-input-element:attr-input-step-2"><a href="#attr-input-step">step</a></code>, and
   <code id="the-input-element:attr-dim-width-2"><a href="#attr-dim-width">width</a></code> content attributes, the
   <code id="the-input-element:dom-input-checked-2"><a href="#dom-input-checked">checked</a></code>,
   <code id="the-input-element:dom-input-files-2"><a href="#dom-input-files">files</a></code>,
   <code id="the-input-element:dom-input-valueasdate-2"><a href="#dom-input-valueasdate">valueAsDate</a></code>,
   <code id="the-input-element:dom-input-valueasnumber-2"><a href="#dom-input-valueasnumber">valueAsNumber</a></code>, and
   <code id="the-input-element:dom-input-list-2"><a href="#dom-input-list">list</a></code> IDL attributes, the
   <code id="the-input-element:dom-textarea/input-select-2"><a href="#dom-textarea/input-select">select()</a></code> method, the
   <code id="the-input-element:dom-textarea/input-selectionstart-2"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="the-input-element:dom-textarea/input-selectionend-2"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>, and
   <code id="the-input-element:dom-textarea/input-selectiondirection-2"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, IDL attributes, the
   <code id="the-input-element:dom-textarea/input-setrangetext-3"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code> and
   <code id="the-input-element:dom-textarea/input-setselectionrange-2"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods, the
   <code id="the-input-element:dom-input-stepup-2"><a href="#dom-input-stepup">stepUp()</a></code> and
   <code id="the-input-element:dom-input-stepdown-2"><a href="#dom-input-stepdown">stepDown()</a></code> methods, and the
   <code id="the-input-element:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and
   <code id="the-input-element:event-change"><a href="#event-change">change</a></code> events <dfn id="concept-input-apply">apply</dfn> to an
   <code id="the-input-element:the-input-element-2"><a href="#the-input-element">input</a></code> element depends on the state of its
   <code id="the-input-element:attr-input-type-28"><a href="#attr-input-type">type</a></code> attribute.
  The subsections that define each type also clearly define in normative "bookkeeping" sections
  which of these feature apply, and which <dfn id="do-not-apply">do not apply</dfn>, to each type. The behavior of
  these features depends on whether they apply or not, as defined in their various sections (q.v.
  for <a href="#common-input-element-attributes">content attributes</a>, for <a href="#common-input-element-apis">APIs</a>, for <a href="#common-input-element-events">events</a>).</p>

  <p>The following table is non-normative and summarizes which of those
  content attributes, IDL attributes, methods, and events <a href="#concept-input-apply" id="the-input-element:concept-input-apply">apply</a> to each state:</p>

  <table id="input-type-attr-summary" class="applies"><thead><tr><th>
     </th><th> <span><a href="#hidden-state-(type=hidden)" id="the-input-element:hidden-state-(type=hidden)-7">Hidden</a></span>
     </th><th> <span><a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-input-element:text-(type=text)-state-and-search-state-(type=search)-6">Text</a>,</span>
          <span><a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-input-element:text-(type=text)-state-and-search-state-(type=search)-7">Search</a></span>
     </th><th> <span><a href="#telephone-state-(type=tel)" id="the-input-element:telephone-state-(type=tel)-3">Telephone</a>,</span>
          <span><a href="#url-state-(type=url)" id="the-input-element:url-state-(type=url)-3">URL</a></span>
     </th><th> <span><a href="#email-state-(type=email)" id="the-input-element:email-state-(type=email)-3">Email</a></span>
     </th><th> <span><a href="#password-state-(type=password)" id="the-input-element:password-state-(type=password)-3">Password</a></span>
     </th><th> <span><a href="#date-state-(type=date)" id="the-input-element:date-state-(type=date)-3">Date</a>,</span>
          <span><a href="#month-state-(type=month)" id="the-input-element:month-state-(type=month)-3">Month</a>,</span>
          <span><a href="#week-state-(type=week)" id="the-input-element:week-state-(type=week)-3">Week</a>,</span>
          <span><a href="#time-state-(type=time)" id="the-input-element:time-state-(type=time)-3">Time</a></span>
     </th><th> <span><a href="#local-date-and-time-state-(type=datetime-local)" id="the-input-element:local-date-and-time-state-(type=datetime-local)-3">Local Date and Time</a></span>
     </th><th> <span><a href="#number-state-(type=number)" id="the-input-element:number-state-(type=number)-3">Number</a></span>
     </th><th> <span><a href="#range-state-(type=range)" id="the-input-element:range-state-(type=range)-3">Range</a></span>
     </th><th> <span><a href="#color-state-(type=color)" id="the-input-element:color-state-(type=color)-3">Color</a></span>
     </th><th> <span><a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)-3">Checkbox</a>,</span>
          <span><a href="#radio-button-state-(type=radio)" id="the-input-element:radio-button-state-(type=radio)-3">Radio Button</a></span>
     </th><th> <span><a href="#file-upload-state-(type=file)" id="the-input-element:file-upload-state-(type=file)-4">File Upload</a></span>
     </th><th> <span><a href="#submit-button-state-(type=submit)" id="the-input-element:submit-button-state-(type=submit)-3">Submit Button</a></span>
     </th><th> <span><a href="#image-button-state-(type=image)" id="the-input-element:image-button-state-(type=image)-3">Image Button</a></span>
     </th><th> <span><a href="#reset-button-state-(type=reset)" id="the-input-element:reset-button-state-(type=reset)-3">Reset Button</a>,</span>
          <span><a href="#button-state-(type=button)" id="the-input-element:button-state-(type=button)-3">Button</a></span>

   </th></tr></thead><tbody><tr><th colspan="16" scope="rowgroup">Content attributes

    </th></tr><tr><th> <code id="the-input-element:attr-input-accept-3"><a href="#attr-input-accept">accept</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-alpha-3"><a href="#attr-input-alpha">alpha</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-alt-3"><a href="#attr-input-alt">alt</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-fe-autocomplete-3"><a href="#attr-fe-autocomplete">autocomplete</a></code>
     </th><td class="yes"> Yes     
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-checked-4"><a href="#attr-input-checked">checked</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-colorspace-3"><a href="#attr-input-colorspace">colorspace</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-fe-dirname-3"><a href="#attr-fe-dirname">dirname</a></code>
     </th><td class="yes"> Yes     
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-fs-formaction-3"><a href="#attr-fs-formaction">formaction</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-fs-formenctype-3"><a href="#attr-fs-formenctype">formenctype</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-fs-formmethod-3"><a href="#attr-fs-formmethod">formmethod</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-fs-formnovalidate-3"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-fs-formtarget-3"><a href="#attr-fs-formtarget">formtarget</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-dim-height-3"><a href="#attr-dim-height">height</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-list-3"><a href="#attr-input-list">list</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-max-3"><a href="#attr-input-max">max</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-maxlength-3"><a href="#attr-input-maxlength">maxlength</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-min-3"><a href="#attr-input-min">min</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-minlength-3"><a href="#attr-input-minlength">minlength</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-multiple-3"><a href="#attr-input-multiple">multiple</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> ·  
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-pattern-4"><a href="#attr-input-pattern">pattern</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-placeholder-3"><a href="#attr-input-placeholder">placeholder</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-popovertarget-2"><a href="#attr-popovertarget">popovertarget</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     


    </td></tr><tr><th> <code id="the-input-element:attr-popovertargetaction-2"><a href="#attr-popovertargetaction">popovertargetaction</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     


    </td></tr><tr><th> <code id="the-input-element:attr-input-readonly-3"><a href="#attr-input-readonly">readonly</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-required-3"><a href="#attr-input-required">required</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-size-3"><a href="#attr-input-size">size</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-src-3"><a href="#attr-input-src">src</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-input-step-3"><a href="#attr-input-step">step</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:attr-dim-width-3"><a href="#attr-dim-width">width</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 


   </td></tr></tbody><tbody><tr><th colspan="16" scope="rowgroup">IDL attributes and methods

    </th></tr><tr><th> <code id="the-input-element:dom-input-checked-3"><a href="#dom-input-checked">checked</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-input-files-3"><a href="#dom-input-files">files</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-input-value-2"><a href="#dom-input-value">value</a></code>
     </th><td class="yes"> <a href="#dom-input-value-default" id="the-input-element:dom-input-value-default">default</a> 
     </td><td class="yes"> <a href="#dom-input-value-value" id="the-input-element:dom-input-value-value">value</a> 

     </td><td class="yes"> <a href="#dom-input-value-value" id="the-input-element:dom-input-value-value-2">value</a> 
     </td><td class="yes"> <a href="#dom-input-value-value" id="the-input-element:dom-input-value-value-3">value</a> 
     </td><td class="yes"> <a href="#dom-input-value-value" id="the-input-element:dom-input-value-value-4">value</a> 
     </td><td class="yes"> <a href="#dom-input-value-value" id="the-input-element:dom-input-value-value-5">value</a> 



     </td><td class="yes"> <a href="#dom-input-value-value" id="the-input-element:dom-input-value-value-6">value</a> 
     </td><td class="yes"> <a href="#dom-input-value-value" id="the-input-element:dom-input-value-value-7">value</a> 
     </td><td class="yes"> <a href="#dom-input-value-value" id="the-input-element:dom-input-value-value-8">value</a> 
     </td><td class="yes"> <a href="#dom-input-value-value" id="the-input-element:dom-input-value-value-9">value</a> 
     </td><td class="yes"> <a href="#dom-input-value-default-on" id="the-input-element:dom-input-value-default-on">default/on</a> 

     </td><td class="yes"> <a href="#dom-input-value-filename" id="the-input-element:dom-input-value-filename">filename</a> 
     </td><td class="yes"> <a href="#dom-input-value-default" id="the-input-element:dom-input-value-default-2">default</a> 
     </td><td class="yes"> <a href="#dom-input-value-default" id="the-input-element:dom-input-value-default-3">default</a> 
     </td><td class="yes"> <a href="#dom-input-value-default" id="the-input-element:dom-input-value-default-4">default</a> 


    </td></tr><tr><th> <code id="the-input-element:dom-input-valueasdate-3"><a href="#dom-input-valueasdate">valueAsDate</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-input-valueasnumber-3"><a href="#dom-input-valueasnumber">valueAsNumber</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-input-list-3"><a href="#dom-input-list">list</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-textarea/input-select-3"><a href="#dom-textarea/input-select">select()</a></code>
     </th><td class="no"> ·     
     </td><td class="yes"> Yes         

     </td><td class="yes"> Yes         
     </td><td class="yes"> Yes† 
     </td><td class="yes"> Yes         
     </td><td class="yes"> Yes† 



     </td><td class="yes"> Yes† 
     </td><td class="yes"> Yes† 
     </td><td class="no"> ·     
     </td><td class="yes"> Yes† 
     </td><td class="no"> ·     

     </td><td class="yes"> Yes† 
     </td><td class="no"> ·     
     </td><td class="no"> ·     
     </td><td class="no"> ·     


    </td></tr><tr><th> <code id="the-input-element:dom-textarea/input-selectionstart-3"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-textarea/input-selectionend-3"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-textarea/input-selectiondirection-3"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-textarea/input-setrangetext-4"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-textarea/input-setselectionrange-3"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="yes"> Yes     
     </td><td class="no"> · 



     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-input-stepdown-3"><a href="#dom-input-stepdown">stepDown()</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <code id="the-input-element:dom-input-stepup-3"><a href="#dom-input-stepup">stepUp()</a></code>
     </th><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 

     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


   </td></tr></tbody><tbody><tr><th colspan="16" scope="rowgroup">Events

    </th></tr><tr><th> <span><code id="the-input-element:event-input-2"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> event</span>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


    </td></tr><tr><th> <span><code id="the-input-element:event-change-2"><a href="#event-change">change</a></code> event</span>
     </th><td class="no"> · 
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     



     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     
     </td><td class="yes"> Yes     

     </td><td class="yes"> Yes     
     </td><td class="no"> · 
     </td><td class="no"> · 
     </td><td class="no"> · 


  </td></tr></tbody></table>

  <p class="tablenote"><small>† If the control has no selectable text, the <code id="the-input-element:dom-textarea/input-select-4"><a href="#dom-textarea/input-select">select()</a></code> method results in a no-op, with no
  <a id="the-input-element:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-input-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</small></p>

  

  <p>Some states of the <code id="the-input-element:attr-input-type-29"><a href="#attr-input-type">type</a></code> attribute define a <dfn id="value-sanitization-algorithm">value
  sanitization algorithm</dfn>.</p>

  <p>Each <code id="the-input-element:the-input-element-3"><a href="#the-input-element">input</a></code> element has a <a href="#concept-fe-value" id="the-input-element:concept-fe-value">value</a>, which is
  exposed by the <code id="the-input-element:dom-input-value-3"><a href="#dom-input-value">value</a></code> IDL attribute. Some states define an
  <dfn id="concept-input-value-string-number">algorithm to convert a string to a number</dfn>,
  an <dfn id="concept-input-value-number-string">algorithm to convert a number to a
  string</dfn>, an <dfn id="concept-input-value-string-date">algorithm to convert a string to a
  <code>Date</code> object</dfn>, and an <dfn id="concept-input-value-date-string">algorithm to
  convert a <code>Date</code> object to a string</dfn>, which are used by <code id="the-input-element:attr-input-max-4"><a href="#attr-input-max">max</a></code>, <code id="the-input-element:attr-input-min-4"><a href="#attr-input-min">min</a></code>, <code id="the-input-element:attr-input-step-4"><a href="#attr-input-step">step</a></code>, <code id="the-input-element:dom-input-valueasdate-4"><a href="#dom-input-valueasdate">valueAsDate</a></code>,
  <code id="the-input-element:dom-input-valueasnumber-4"><a href="#dom-input-valueasnumber">valueAsNumber</a></code>, and <code id="the-input-element:dom-input-stepup-4"><a href="#dom-input-stepup">stepUp()</a></code>.</p>

  <div data-algorithm="">
  <p>An <code id="the-input-element:the-input-element-4"><a href="#the-input-element">input</a></code> element's <a href="#concept-fe-dirty" id="the-input-element:concept-fe-dirty">dirty value flag</a> must be
  set to true whenever the user interacts with the control in a way that changes the <a href="#concept-fe-value" id="the-input-element:concept-fe-value-2">value</a>. (It is also set to true when the value is programmatically
  changed, as described in the definition of the <code id="the-input-element:dom-input-value-4"><a href="#dom-input-value">value</a></code> IDL
  attribute.)</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="input" id="attr-input-value" data-dfn-type="element-attr"><code>value</code></dfn> content
  attribute gives the default <a href="#concept-fe-value" id="the-input-element:concept-fe-value-3">value</a> of the <code id="the-input-element:the-input-element-5"><a href="#the-input-element">input</a></code>
  element. When the <code id="the-input-element:attr-input-value-3"><a href="#attr-input-value">value</a></code> content attribute is
  added, set, or removed, if the control's <a href="#concept-fe-dirty" id="the-input-element:concept-fe-dirty-2">dirty value flag</a>
  is false, the user agent must set the <a href="#concept-fe-value" id="the-input-element:concept-fe-value-4">value</a> of the element
  to the value of the <code id="the-input-element:attr-input-value-4"><a href="#attr-input-value">value</a></code> content attribute, if there is
  one, or the empty string otherwise, and then run the current <a href="#value-sanitization-algorithm" id="the-input-element:value-sanitization-algorithm">value sanitization
  algorithm</a>, if one is defined.</p>
  </div>

  

  <p>Each <code id="the-input-element:the-input-element-6"><a href="#the-input-element">input</a></code> element has a <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked">checkedness</a>,
  which is exposed by the <code id="the-input-element:dom-input-checked-4"><a href="#dom-input-checked">checked</a></code> IDL attribute.</p>

  <div data-algorithm="">
  <p>Each <code id="the-input-element:the-input-element-7"><a href="#the-input-element">input</a></code> element has a boolean <dfn id="concept-input-checked-dirty-flag">dirty checkedness flag</dfn>. When it is true, the
  element is said to have a <dfn id="concept-input-checked-dirty"><i>dirty checkedness</i></dfn>.
  The <a href="#concept-input-checked-dirty-flag" id="the-input-element:concept-input-checked-dirty-flag">dirty checkedness flag</a> must be initially
  set to false when the element is created, and must be set to true whenever the user interacts with
  the control in a way that changes the <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-2">checkedness</a>.</p>
  </div>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#checked" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#checked</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="input" id="attr-input-checked" data-dfn-type="element-attr"><code>checked</code></dfn>
  content attribute is a <a href="#boolean-attribute" id="the-input-element:boolean-attribute">boolean attribute</a> that gives the default <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-3">checkedness</a> of the <code id="the-input-element:the-input-element-8"><a href="#the-input-element">input</a></code> element. When the <code id="the-input-element:attr-input-checked-5"><a href="#attr-input-checked">checked</a></code> content attribute is added, if
  the control does not have <i id="the-input-element:concept-input-checked-dirty"><a href="#concept-input-checked-dirty">dirty checkedness</a></i>, the user
  agent must set the <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-4">checkedness</a> of the element to true;
  when the <code id="the-input-element:attr-input-checked-6"><a href="#attr-input-checked">checked</a></code> content attribute is removed, if the
  control does not have <i id="the-input-element:concept-input-checked-dirty-2"><a href="#concept-input-checked-dirty">dirty checkedness</a></i>, the user
  agent must set the <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-5">checkedness</a> of the element to
  false.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <a href="#concept-form-reset-control" id="the-input-element:concept-form-reset-control">reset algorithm</a> for <code id="the-input-element:the-input-element-9"><a href="#the-input-element">input</a></code>
  elements is to set its <a href="#user-validity" id="the-input-element:user-validity">user validity</a>,
  <a href="#concept-fe-dirty" id="the-input-element:concept-fe-dirty-3">dirty value flag</a>, and
  <a href="#concept-input-checked-dirty-flag" id="the-input-element:concept-input-checked-dirty-flag-2">dirty checkedness flag</a>
  back to false, set the <a href="#concept-fe-value" id="the-input-element:concept-fe-value-5">value</a> of the element to the value
  of the <code id="the-input-element:attr-input-value-5"><a href="#attr-input-value">value</a></code> content attribute, if there is one, or the
  empty string otherwise, set the <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-6">checkedness</a> of the
  element to true if the element has a <code id="the-input-element:attr-input-checked-7"><a href="#attr-input-checked">checked</a></code> content
  attribute and false if it does not, empty the list of <a href="#concept-input-type-file-selected" id="the-input-element:concept-input-type-file-selected">selected files</a>, and then invoke the <a href="#value-sanitization-algorithm" id="the-input-element:value-sanitization-algorithm-2">value
  sanitization algorithm</a>, if the <code id="the-input-element:attr-input-type-30"><a href="#attr-input-type">type</a></code> attribute's
  current state defines one.</p>
  </div>

  <p>Each <code id="the-input-element:the-input-element-10"><a href="#the-input-element">input</a></code> element can be <i id="the-input-element:concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>. Except where
  otherwise specified, an <code id="the-input-element:the-input-element-11"><a href="#the-input-element">input</a></code> element is always <i id="the-input-element:concept-fe-mutable-2"><a href="#concept-fe-mutable">mutable</a></i>. Similarly, except where otherwise specified, the user
  agent should not allow the user to modify the element's <a href="#concept-fe-value" id="the-input-element:concept-fe-value-6">value</a> or <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-7">checkedness</a>.</p>

  <div data-algorithm="">
  <p>When an <code id="the-input-element:the-input-element-12"><a href="#the-input-element">input</a></code> element is <a href="#concept-fe-disabled" id="the-input-element:concept-fe-disabled">disabled</a>, it is not <i id="the-input-element:concept-fe-mutable-3"><a href="#concept-fe-mutable">mutable</a></i>.</p>
  </div>

  <p class="note">The <code id="the-input-element:attr-input-readonly-4"><a href="#attr-input-readonly">readonly</a></code> attribute can also in some
  cases (e.g. for the <a href="#date-state-(type=date)" id="the-input-element:date-state-(type=date)-4">Date</a> state, but not the <a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)-4">Checkbox</a> state) stop an <code id="the-input-element:the-input-element-13"><a href="#the-input-element">input</a></code> element from
  being <i id="the-input-element:concept-fe-mutable-4"><a href="#concept-fe-mutable">mutable</a></i>.</p>

  <p>The <code id="the-input-element:the-input-element-14"><a href="#the-input-element">input</a></code> element can <dfn id="input-support-picker">support a picker</dfn>. A
  picker is a user interface element that allows the end user to choose a value. Whether an
  <code id="the-input-element:the-input-element-15"><a href="#the-input-element">input</a></code> element supports a picker depends on the <code id="the-input-element:attr-input-type-31"><a href="#attr-input-type">type</a></code> attribute state and <a id="the-input-element:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>
  behavior. An <code id="the-input-element:the-input-element-16"><a href="#the-input-element">input</a></code> element must support a picker when its <code id="the-input-element:attr-input-type-32"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#file-upload-state-(type=file)" id="the-input-element:file-upload-state-(type=file)-5">File
  Upload</a> state.</p>

  <div class="note">
   <p>As of the time of this writing, typical browser implementations show such picker UI for:</p>

   <ul><li><p><code id="the-input-element:the-input-element-17"><a href="#the-input-element">input</a></code> elements whose <code id="the-input-element:attr-input-type-33"><a href="#attr-input-type">type</a></code>
    attributes are in the <a href="#date-state-(type=date)" id="the-input-element:date-state-(type=date)-5">Date</a>, <a href="#month-state-(type=month)" id="the-input-element:month-state-(type=month)-4">Month</a>, <a href="#week-state-(type=week)" id="the-input-element:week-state-(type=week)-4">Week</a>,
    <a href="#time-state-(type=time)" id="the-input-element:time-state-(type=time)-4">Time</a>, <a href="#local-date-and-time-state-(type=datetime-local)" id="the-input-element:local-date-and-time-state-(type=datetime-local)-4">Local Date and Time</a>, and <a href="#color-state-(type=color)" id="the-input-element:color-state-(type=color)-4">Color</a> states;</p></li><li><p><code id="the-input-element:the-input-element-18"><a href="#the-input-element">input</a></code> elements in various states that have a <a href="#concept-input-list" id="the-input-element:concept-input-list">suggestions source element</a>;</p></li><li><p><code id="the-input-element:the-input-element-19"><a href="#the-input-element">input</a></code> elements whose <code id="the-input-element:attr-input-type-34"><a href="#attr-input-type">type</a></code> attribute
    is in the <a href="#file-upload-state-(type=file)" id="the-input-element:file-upload-state-(type=file)-6">File Upload</a> state; and</p></li><li><p><code id="the-input-element:the-select-element"><a href="#the-select-element">select</a></code> elements.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>The <a href="https://dom.spec.whatwg.org/#concept-node-clone-ext" id="the-input-element:concept-node-clone-ext" data-x-internal="concept-node-clone-ext">cloning steps</a> for <code id="the-input-element:the-input-element-20"><a href="#the-input-element">input</a></code> elements
  given <var>node</var>, <var>copy</var>, and <var>subtree</var> are to propagate the <a href="#concept-fe-value" id="the-input-element:concept-fe-value-7">value</a>, <a href="#concept-fe-dirty" id="the-input-element:concept-fe-dirty-4">dirty value flag</a>,
  <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-8">checkedness</a>, and <a href="#concept-input-checked-dirty-flag" id="the-input-element:concept-input-checked-dirty-flag-3">dirty checkedness flag</a> from <var>node</var> to
  <var>copy</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-input-element:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> for <code id="the-input-element:the-input-element-21"><a href="#the-input-element">input</a></code> elements <var>element</var>, given
  <var>event</var>, are these steps:</p>

  <ol><li><p>If <var>element</var> is not <i id="the-input-element:concept-fe-mutable-5"><a href="#concept-fe-mutable">mutable</a></i>, and
   <var>element</var>'s <code id="the-input-element:attr-input-type-35"><a href="#attr-input-type">type</a></code> attribute is neither in the <a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)-5">Checkbox</a> nor in the <a href="#radio-button-state-(type=radio)" id="the-input-element:radio-button-state-(type=radio)-4">Radio</a> state, then return.</p></li><li><p>Run <var>element</var>'s <dfn id="input-activation-behavior">input activation behavior</dfn>, if any, and do nothing
   otherwise.</p></li><li><p>If <var>element</var> has a <a href="#form-owner" id="the-input-element:form-owner">form owner</a> and <var>element</var>'s <code id="the-input-element:attr-input-type-36"><a href="#attr-input-type">type</a></code> attribute is not in the <a href="#button-state-(type=button)" id="the-input-element:button-state-(type=button)-4">Button</a> state, then return.</p></li><li><p>Run the <a href="#popover-target-attribute-activation-behavior" id="the-input-element:popover-target-attribute-activation-behavior">popover target attribute activation behavior</a> given <var>element</var>
   and <var>event</var>'s <a href="https://dom.spec.whatwg.org/#concept-event-target" id="the-input-element:concept-event-target" data-x-internal="concept-event-target">target</a>.</p></li></ol>
  </div>

  <p class="note">Recall that an element's <a id="the-input-element:activation-behaviour-2" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> runs for both
  user-initiated activations and for synthetic activations (e.g., via <code>el.click()</code>). User agents might also have behaviors for a given control — not
  specified here — that are triggered only by true user-initiated activations. A common choice is to
  <a href="#show-the-picker,-if-applicable" id="the-input-element:show-the-picker,-if-applicable">show the picker, if applicable</a>, for the control. In contrast, the <a href="#input-activation-behavior" id="the-input-element:input-activation-behavior">input
  activation behavior</a> only shows pickers for the special historical cases of the <a href="#file-upload-state-(type=file)" id="the-input-element:file-upload-state-(type=file)-7">File Upload</a> and <a href="#color-state-(type=color)" id="the-input-element:color-state-(type=color)-5">Color</a> states.</p>

  <div data-algorithm="">
  <p>The <a id="the-input-element:legacy-pre-activation-behavior" href="https://dom.spec.whatwg.org/#eventtarget-legacy-pre-activation-behavior" data-x-internal="legacy-pre-activation-behavior">legacy-pre-activation behavior</a> for <code id="the-input-element:the-input-element-22"><a href="#the-input-element">input</a></code> elements are these
  steps:</p>

  <ol><li><p>If this element's <code id="the-input-element:attr-input-type-37"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)-6">Checkbox state</a>, then set this element's <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-9">checkedness</a> to its opposite value (i.e. true if it is false,
   false if it is true) and set this element's <code id="the-input-element:dom-input-indeterminate-2"><a href="#dom-input-indeterminate">indeterminate</a></code> IDL attribute to false.</p></li><li><p>If this element's <code id="the-input-element:attr-input-type-38"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#radio-button-state-(type=radio)" id="the-input-element:radio-button-state-(type=radio)-5">Radio Button state</a>, then get a reference to the element in
   this element's <a href="#radio-button-group" id="the-input-element:radio-button-group">radio button group</a> that has its <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-10">checkedness</a> set to true, if any, and then set this element's
   <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-11">checkedness</a> to true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-input-element:legacy-canceled-activation-behavior" href="https://dom.spec.whatwg.org/#eventtarget-legacy-canceled-activation-behavior" data-x-internal="legacy-canceled-activation-behavior">legacy-canceled-activation behavior</a> for <code id="the-input-element:the-input-element-23"><a href="#the-input-element">input</a></code> elements are these
  steps:</p>

  <ol><li><p>If the element's <code id="the-input-element:attr-input-type-39"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)-7">Checkbox state</a>, then set the element's <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-12">checkedness</a> and the element's <code id="the-input-element:dom-input-indeterminate-3"><a href="#dom-input-indeterminate">indeterminate</a></code> IDL attribute back to the values they had
   before the <a id="the-input-element:legacy-pre-activation-behavior-2" href="https://dom.spec.whatwg.org/#eventtarget-legacy-pre-activation-behavior" data-x-internal="legacy-pre-activation-behavior">legacy-pre-activation behavior</a> was run.</p></li><li><p>If this element's <code id="the-input-element:attr-input-type-40"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#radio-button-state-(type=radio)" id="the-input-element:radio-button-state-(type=radio)-6">Radio Button state</a>, then if the element to which a
   reference was obtained in the <a id="the-input-element:legacy-pre-activation-behavior-3" href="https://dom.spec.whatwg.org/#eventtarget-legacy-pre-activation-behavior" data-x-internal="legacy-pre-activation-behavior">legacy-pre-activation behavior</a>, if any, is still in
   what is now this element's <a href="#radio-button-group" id="the-input-element:radio-button-group-2">radio button group</a>, if it still has one, and if so,
   set that element's <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-13">checkedness</a> to true; or else, if
   there was no such element, or that element is no longer in this element's <a href="#radio-button-group" id="the-input-element:radio-button-group-3">radio button
   group</a>, or if this element no longer has a <a href="#radio-button-group" id="the-input-element:radio-button-group-4">radio button group</a>, set this
   element's <a href="#concept-fe-checked" id="the-input-element:concept-fe-checked-14">checkedness</a> to false.
  </p></li></ol>
  </div>

  

  <hr>

  <div data-algorithm="">
  <p>When an <code id="the-input-element:the-input-element-24"><a href="#the-input-element">input</a></code> element is first created, the element's rendering and behavior must
  be set to the rendering and behavior defined for the <code id="the-input-element:attr-input-type-41"><a href="#attr-input-type">type</a></code>
  attribute's state, and the <a href="#value-sanitization-algorithm" id="the-input-element:value-sanitization-algorithm-3">value sanitization algorithm</a>, if one is defined for the
  <code id="the-input-element:attr-input-type-42"><a href="#attr-input-type">type</a></code> attribute's state, must be invoked.</p>
  </div>

  

  <div id="input-type-change">

  <div data-algorithm="">
  <p>When an <code id="the-input-element:the-input-element-25"><a href="#the-input-element">input</a></code> element's <code id="the-input-element:attr-input-type-43"><a href="#attr-input-type">type</a></code> attribute
  changes state, the user agent must run the following steps:</p>

  <ol><li><p>If the previous state of the element's <code id="the-input-element:attr-input-type-44"><a href="#attr-input-type">type</a></code> attribute
   put the <code id="the-input-element:dom-input-value-5"><a href="#dom-input-value">value</a></code> IDL attribute in the <i id="the-input-element:dom-input-value-value-10"><a href="#dom-input-value-value">value</a></i> mode, and the element's <a href="#concept-fe-value" id="the-input-element:concept-fe-value-8">value</a> is not the empty string, and the new state of the element's
   <code id="the-input-element:attr-input-type-45"><a href="#attr-input-type">type</a></code> attribute puts the <code id="the-input-element:dom-input-value-6"><a href="#dom-input-value">value</a></code> IDL attribute in either the <i id="the-input-element:dom-input-value-default-5"><a href="#dom-input-value-default">default</a></i> mode or the <i id="the-input-element:dom-input-value-default-on-2"><a href="#dom-input-value-default-on">default/on</a></i> mode, then set the element's <code id="the-input-element:attr-input-value-6"><a href="#attr-input-value">value</a></code> content attribute to the element's <a href="#concept-fe-value" id="the-input-element:concept-fe-value-9">value</a>.</p></li><li><p>Otherwise, if the previous state of the element's <code id="the-input-element:attr-input-type-46"><a href="#attr-input-type">type</a></code> attribute put the <code id="the-input-element:dom-input-value-7"><a href="#dom-input-value">value</a></code>
   IDL attribute in any mode other than the <i id="the-input-element:dom-input-value-value-11"><a href="#dom-input-value-value">value</a></i> mode, and the
   new state of the element's <code id="the-input-element:attr-input-type-47"><a href="#attr-input-type">type</a></code> attribute puts the <code id="the-input-element:dom-input-value-8"><a href="#dom-input-value">value</a></code> IDL attribute in the <i id="the-input-element:dom-input-value-value-12"><a href="#dom-input-value-value">value</a></i> mode, then set the <a href="#concept-fe-value" id="the-input-element:concept-fe-value-10">value</a> of the element to the value of the <code id="the-input-element:attr-input-value-7"><a href="#attr-input-value">value</a></code> content attribute, if there is one, or the empty string
   otherwise, and then set the control's <a href="#concept-fe-dirty" id="the-input-element:concept-fe-dirty-5">dirty value flag</a> to
   false.</p></li><li><p>Otherwise, if the previous state of the element's <code id="the-input-element:attr-input-type-48"><a href="#attr-input-type">type</a></code> attribute put the <code id="the-input-element:dom-input-value-9"><a href="#dom-input-value">value</a></code> IDL attribute in any mode other than the <i id="the-input-element:dom-input-value-filename-2"><a href="#dom-input-value-filename">filename</a></i> mode, and the new state of the element's <code id="the-input-element:attr-input-type-49"><a href="#attr-input-type">type</a></code> attribute puts the <code id="the-input-element:dom-input-value-10"><a href="#dom-input-value">value</a></code> IDL attribute in the <i id="the-input-element:dom-input-value-filename-3"><a href="#dom-input-value-filename">filename</a></i> mode, then set the <a href="#concept-fe-value" id="the-input-element:concept-fe-value-11">value</a> of the element to the empty string.</p></li><li><p>Update the element's rendering and behavior to the new state's.</p></li><li><p><dfn id="signal-a-type-change">Signal a type change</dfn> for the element. (The <a href="#radio-button-state-(type=radio)" id="the-input-element:radio-button-state-(type=radio)-7">Radio Button</a> state uses this, in particular.)</p></li><li><p>Invoke the <a href="#value-sanitization-algorithm" id="the-input-element:value-sanitization-algorithm-4">value sanitization algorithm</a>, if one is defined for the <code id="the-input-element:attr-input-type-50"><a href="#attr-input-type">type</a></code> attribute's new state.</p></li><li><p>Let <var>previouslySelectable</var> be true if <code id="the-input-element:dom-textarea/input-setrangetext-5"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code> previously <a href="#concept-input-apply" id="the-input-element:concept-input-apply-2">applied</a> to the element, and false otherwise.</p></li><li><p>Let <var>nowSelectable</var> be true if <code id="the-input-element:dom-textarea/input-setrangetext-6"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code> now <a href="#concept-input-apply" id="the-input-element:concept-input-apply-3">applies</a> to the element, and false otherwise.</p></li><li><p>If <var>previouslySelectable</var> is false and <var>nowSelectable</var> is true, set the
   element's <a href="#concept-textarea/input-cursor" id="the-input-element:concept-textarea/input-cursor">text entry cursor position</a> to the
   beginning of the text control, and <a href="#set-the-selection-direction" id="the-input-element:set-the-selection-direction">set its selection
   direction</a> to "<code>none</code>".</p></li></ol>
  </div>

  </div>

  <hr>

  <p>
  The <code id="the-input-element:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attribute represents the element's name.
  The <code id="the-input-element:attr-fe-dirname-4"><a href="#attr-fe-dirname">dirname</a></code> attribute controls how the element's <a href="#the-directionality" id="the-input-element:the-directionality-2">directionality</a> is submitted.
  The <code id="the-input-element:attr-fe-disabled-2"><a href="#attr-fe-disabled">disabled</a></code> attribute is used to make the control non-interactive and to prevent its value from being submitted.
  The <code id="the-input-element:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> attribute is used to explicitly associate the <code id="the-input-element:the-input-element-26"><a href="#the-input-element">input</a></code> element with its <a href="#form-owner" id="the-input-element:form-owner-2">form owner</a>.
  The <code id="the-input-element:attr-fe-autocomplete-4"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute controls how the user agent provides autofill behavior.
  </p>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#indeterminate" title="The HTMLInputElement interface provides special properties and methods for manipulating the options, layout, and presentation of <input> elements.">HTMLInputElement#indeterminate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.6+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>≤12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>≤12.1+</span></span><hr><span class="caniuse"><span><a href="https://caniuse.com/#feat=indeterminate-checkbox" title="indeterminate checkbox">caniuse.com table</a></span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement" id="dom-input-indeterminate" data-dfn-type="attribute"><code>indeterminate</code></dfn> IDL attribute must initially be set to
  false. On getting, it must return the last value it was set to. On setting, it must be set to the
  new value. It has no effect except for changing the appearance of <a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)-8">checkbox</a> controls.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement" id="dom-input-colorspace" data-dfn-type="attribute"><code>colorSpace</code></dfn> IDL attribute must <a href="#reflect" id="the-input-element:reflect">reflect</a> the
  <code id="the-input-element:attr-input-colorspace-4"><a href="#attr-input-colorspace">colorspace</a></code> content attribute, <a href="#limited-to-only-known-values" id="the-input-element:limited-to-only-known-values">limited to only
  known values</a>. The <dfn data-dfn-for="HTMLInputElement" id="dom-input-type" data-dfn-type="attribute"><code>type</code></dfn> IDL attribute must <a href="#reflect" id="the-input-element:reflect-2">reflect</a> the respective
  content attribute of the same name, <a href="#limited-to-only-known-values" id="the-input-element:limited-to-only-known-values-2">limited to only known values</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The IDL attributes <dfn data-dfn-for="HTMLInputElement" id="dom-input-width" data-dfn-type="attribute"><code>width</code></dfn> and <dfn data-dfn-for="HTMLInputElement" id="dom-input-height" data-dfn-type="attribute"><code>height</code></dfn> must return the rendered width and height of the
  image, in <a href="https://drafts.csswg.org/css-values/#px" id="the-input-element:'px'" data-x-internal="'px'">CSS pixels</a>, if an image is <a href="#being-rendered" id="the-input-element:being-rendered">being rendered</a>; or
  else the <a href="https://drafts.csswg.org/css-images/#natural-dimensions" id="the-input-element:natural-dimensions" data-x-internal="natural-dimensions">natural width and height</a> of the image, in
  <a href="https://drafts.csswg.org/css-values/#px" id="the-input-element:'px'-2" data-x-internal="'px'">CSS pixels</a>, if an image is <i id="the-input-element:input-img-available"><a href="#input-img-available">available</a></i> but not <a href="#being-rendered" id="the-input-element:being-rendered-2">being rendered</a>; or else 0,
  if no image is <i id="the-input-element:input-img-available-2"><a href="#input-img-available">available</a></i>. When the <code id="the-input-element:the-input-element-27"><a href="#the-input-element">input</a></code>
  element's <code id="the-input-element:attr-input-type-51"><a href="#attr-input-type">type</a></code> attribute is not in the <a href="#image-button-state-(type=image)" id="the-input-element:image-button-state-(type=image)-4">Image Button</a> state, then no image is <i id="the-input-element:input-img-available-3"><a href="#input-img-available">available</a></i>. <a href="#refsCSS">[CSS]</a></p>
  </div>

  <p>The <code id="the-input-element:dom-cva-willvalidate-2"><a href="#dom-cva-willvalidate">willValidate</a></code>, <code id="the-input-element:dom-cva-validity-2"><a href="#dom-cva-validity">validity</a></code>, and <code id="the-input-element:dom-cva-validationmessage-2"><a href="#dom-cva-validationmessage">validationMessage</a></code> IDL attributes, and the <code id="the-input-element:dom-cva-checkvalidity-2"><a href="#dom-cva-checkvalidity">checkValidity()</a></code>, <code id="the-input-element:dom-cva-reportvalidity-2"><a href="#dom-cva-reportvalidity">reportValidity()</a></code>, and <code id="the-input-element:dom-cva-setcustomvalidity-2"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> methods, are part of the
  <a href="#the-constraint-validation-api" id="the-input-element:the-constraint-validation-api">constraint validation API</a>. The <code id="the-input-element:dom-lfe-labels-2"><a href="#dom-lfe-labels">labels</a></code> IDL
  attribute provides a list of the element's <code id="the-input-element:the-label-element"><a href="#the-label-element">label</a></code>s. The <code id="the-input-element:dom-textarea/input-select-5"><a href="#dom-textarea/input-select">select()</a></code>, <code id="the-input-element:dom-textarea/input-selectionstart-4"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>, <code id="the-input-element:dom-textarea/input-selectionend-4"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>, <code id="the-input-element:dom-textarea/input-selectiondirection-4"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, <code id="the-input-element:dom-textarea/input-setrangetext-7"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and <code id="the-input-element:dom-textarea/input-setselectionrange-4"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods and IDL attributes
  expose the element's text selection. The <code id="the-input-element:dom-fe-disabled"><a href="#dom-fe-disabled">disabled</a></code>,
  <code id="the-input-element:dom-fae-form-2"><a href="#dom-fae-form">form</a></code>, and <code id="the-input-element:dom-fe-name"><a href="#dom-fe-name">name</a></code> IDL attributes
  are part of the element's forms API.</p>

  



  <h5 id="states-of-the-type-attribute"><span class="secno">4.10.5.1</span> States of the <code id="states-of-the-type-attribute:attr-input-type"><a href="#attr-input-type">type</a></code> attribute<a href="#states-of-the-type-attribute" class="self-link"></a></h5>


  <h6 id="hidden-state-(type=hidden)"><span class="secno">4.10.5.1.1</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Hidden</dfn> state (<code>type=hidden</code>)<a href="#hidden-state-(type=hidden)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/hidden" title="<input> elements of type hidden let web developers include data that cannot be seen or modified by users when a form is submitted. For example, the ID of the content that is currently being ordered or edited, or a unique security token. Hidden inputs are completely invisible in the rendered page, and there is no way to make it visible in the page's content.">Element/input/hidden</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>2+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="hidden-state-(type=hidden):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="hidden-state-(type=hidden):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#hidden-state-(type=hidden)" id="hidden-state-(type=hidden):hidden-state-(type=hidden)">Hidden</a> state, the rules in this section apply.</p>

  

  <p>The <code id="hidden-state-(type=hidden):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="hidden-state-(type=hidden):represents">represents</a> a value that is not intended to be
  examined or manipulated by the user.</p>

  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If an <code id="hidden-state-(type=hidden):the-input-element-3"><a href="#the-input-element">input</a></code> element's <code id="hidden-state-(type=hidden):attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#hidden-state-(type=hidden)" id="hidden-state-(type=hidden):hidden-state-(type=hidden)-2">Hidden</a> state, it is <a href="#barred-from-constraint-validation" id="hidden-state-(type=hidden):barred-from-constraint-validation">barred from constraint
  validation</a>.</p>
  </div>

  

  <p>If the <code id="hidden-state-(type=hidden):attr-fe-name"><a href="#attr-fe-name">name</a></code> attribute is present and has a value that is an
  <a id="hidden-state-(type=hidden):ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code id="hidden-state-(type=hidden):attr-fe-name-charset"><a href="#attr-fe-name-charset">_charset_</a></code>", then the element's <code id="hidden-state-(type=hidden):attr-input-value"><a href="#attr-input-value">value</a></code> attribute must be omitted.</p>

  <div class="bookkeeping">

   <p>The
   <code id="hidden-state-(type=hidden):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code> and
   <code id="hidden-state-(type=hidden):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>
   content attributes <a href="#concept-input-apply" id="hidden-state-(type=hidden):concept-input-apply">apply</a> to this element.</p>

   <p>The
   <code id="hidden-state-(type=hidden):dom-input-value"><a href="#dom-input-value">value</a></code>
   IDL attribute <a href="#concept-input-apply" id="hidden-state-(type=hidden):concept-input-apply-2">applies</a> to this element and is
   in mode <a href="#dom-input-value-default" id="hidden-state-(type=hidden):dom-input-value-default">default</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="hidden-state-(type=hidden):do-not-apply">do not
   apply</a> to the element:
   <code id="hidden-state-(type=hidden):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="hidden-state-(type=hidden):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="hidden-state-(type=hidden):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="hidden-state-(type=hidden):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-required"><a href="#attr-input-required">required</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="hidden-state-(type=hidden):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="hidden-state-(type=hidden):do-not-apply-2">do not apply</a> to the
   element:
   <code id="hidden-state-(type=hidden):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="hidden-state-(type=hidden):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="hidden-state-(type=hidden):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="hidden-state-(type=hidden):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="hidden-state-(type=hidden):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="hidden-state-(type=hidden):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="hidden-state-(type=hidden):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="hidden-state-(type=hidden):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="hidden-state-(type=hidden):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="hidden-state-(type=hidden):event-change"><a href="#event-change">change</a></code> events <a href="#do-not-apply" id="hidden-state-(type=hidden):do-not-apply-3">do not apply</a>.</p>

  </div>


  <h6 id="text-(type=text)-state-and-search-state-(type=search)"><span class="secno">4.10.5.1.2</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Text</dfn> (<code>type=text</code>) state and <dfn data-dfn-for="input" data-dfn-type="element-state">Search</dfn> state (<code>type=search</code>)<a href="#text-(type=text)-state-and-search-state-(type=search)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/search" title="<input> elements of type search are text fields designed for the user to enter search queries into. These are functionally identical to text inputs, but may be styled differently by the user agent.">Element/input/search</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text" title="<input> elements of type text create basic single-line text fields.">Element/input/text</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  

  <p>When an <code id="text-(type=text)-state-and-search-state-(type=search):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="text-(type=text)-state-and-search-state-(type=search):text-(type=text)-state-and-search-state-(type=search)">Text</a> state or the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="text-(type=text)-state-and-search-state-(type=search):text-(type=text)-state-and-search-state-(type=search)-2">Search</a> state, the rules in this section apply.</p>

  

  <p>The <code id="text-(type=text)-state-and-search-state-(type=search):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="text-(type=text)-state-and-search-state-(type=search):represents">represents</a> a one line plain text edit control for
  the element's <a href="#concept-fe-value" id="text-(type=text)-state-and-search-state-(type=search):concept-fe-value">value</a>.</p>

  <p class="note">The difference between the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="text-(type=text)-state-and-search-state-(type=search):text-(type=text)-state-and-search-state-(type=search)-3">Text</a> state
  and the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="text-(type=text)-state-and-search-state-(type=search):text-(type=text)-state-and-search-state-(type=search)-4">Search</a> state is primarily stylistic: on
  platforms where search controls are distinguished from regular text controls, the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="text-(type=text)-state-and-search-state-(type=search):text-(type=text)-state-and-search-state-(type=search)-5">Search</a> state might result in an appearance consistent with
  the platform's search controls rather than appearing like a regular text control.</p>

  

  <p>If the element is <i id="text-(type=text)-state-and-search-state-(type=search):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, its <a href="#concept-fe-value" id="text-(type=text)-state-and-search-state-(type=search):concept-fe-value-2">value</a> should be editable by the user. User agents must not allow
  users to insert U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters into the element's
  <a href="#concept-fe-value" id="text-(type=text)-state-and-search-state-(type=search):concept-fe-value-3">value</a>.</p>

  
  
  <div data-algorithm="">
  <p>If the element is <i id="text-(type=text)-state-and-search-state-(type=search):concept-fe-mutable-2"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the writing direction of the element, setting it either to a left-to-right writing
  direction or a right-to-left writing direction. If the user does so, the user agent must then run
  the following steps:</p>

  <ol><li><p>Set the element's <code id="text-(type=text)-state-and-search-state-(type=search):attr-dir"><a href="#attr-dir">dir</a></code> attribute to "<code id="text-(type=text)-state-and-search-state-(type=search):attr-dir-ltr"><a href="#attr-dir-ltr">ltr</a></code>" if the user selected a left-to-right writing direction, and
   "<code id="text-(type=text)-state-and-search-state-(type=search):attr-dir-rtl"><a href="#attr-dir-rtl">rtl</a></code>" if the user selected a right-to-left writing
   direction.</p></li><li><p><a href="#queue-an-element-task" id="text-(type=text)-state-and-search-state-(type=search):queue-an-element-task">Queue an element task</a> on the <a href="#user-interaction-task-source" id="text-(type=text)-state-and-search-state-(type=search):user-interaction-task-source">user interaction task source</a> given
   the element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="text-(type=text)-state-and-search-state-(type=search):concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="text-(type=text)-state-and-search-state-(type=search):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the element, with the <code id="text-(type=text)-state-and-search-state-(type=search):dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="text-(type=text)-state-and-search-state-(type=search):dom-event-composed"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code>
   attributes initialized to true.</p></li></ol>
  </div>

  

  <p>The <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified, must have a value that
  contains no U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.</p>

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="text-(type=text)-state-and-search-state-(type=search):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: <a id="text-(type=text)-state-and-search-state-(type=search):strip-newlines" href="https://infra.spec.whatwg.org/#strip-newlines" data-x-internal="strip-newlines">Strip
  newlines</a> from the <a href="#concept-fe-value" id="text-(type=text)-state-and-search-state-(type=search):concept-fe-value-4">value</a>.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The following common <code id="text-(type=text)-state-and-search-state-(type=search):the-input-element-3"><a href="#the-input-element">input</a></code> element content
   attributes, IDL attributes, and methods <a href="#concept-input-apply" id="text-(type=text)-state-and-search-state-(type=search):concept-input-apply">apply</a> to the element:
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-size"><a href="#attr-input-size">size</a></code> content attributes;
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, and
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attributes;
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

   <p>The <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is
   in mode <a href="#dom-input-value-value" id="text-(type=text)-state-and-search-state-(type=search):dom-input-value-value">value</a>.</p>

   <p>The <code id="text-(type=text)-state-and-search-state-(type=search):event-input-2"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="text-(type=text)-state-and-search-state-(type=search):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="text-(type=text)-state-and-search-state-(type=search):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="text-(type=text)-state-and-search-state-(type=search):do-not-apply">do not
   apply</a> to the element:
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="text-(type=text)-state-and-search-state-(type=search):do-not-apply-2">do not apply</a> to the
   element:
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code> and
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

  </div>


  <h6 id="telephone-state-(type=tel)"><span class="secno">4.10.5.1.3</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Telephone</dfn> state (<code>type=tel</code>)<a href="#telephone-state-(type=tel)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel" title="<input> elements of type tel are used to let the user enter and edit a telephone number. Unlike <input type=&quot;email&quot;> and <input type=&quot;url&quot;>, the input value is not automatically validated to a particular format before the form can be submitted, because formats for telephone numbers vary so much around the world.">Element/input/tel</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>Yes</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  

  <p>When an <code id="telephone-state-(type=tel):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="telephone-state-(type=tel):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#telephone-state-(type=tel)" id="telephone-state-(type=tel):telephone-state-(type=tel)">Telephone</a> state, the rules in this section apply.</p>

  

  <p>The <code id="telephone-state-(type=tel):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="telephone-state-(type=tel):represents">represents</a> a control for editing a telephone number
  given in the element's <a href="#concept-fe-value" id="telephone-state-(type=tel):concept-fe-value">value</a>.</p>

  

  <p>If the element is <i id="telephone-state-(type=tel):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, its <a href="#concept-fe-value" id="telephone-state-(type=tel):concept-fe-value-2">value</a> should be editable by the user. User agents may change the
  spacing and, with care, the punctuation of <a href="#concept-fe-value" id="telephone-state-(type=tel):concept-fe-value-3">values</a> that the
  user enters. User agents must not allow users to insert U+000A LINE FEED (LF) or U+000D CARRIAGE
  RETURN (CR) characters into the element's <a href="#concept-fe-value" id="telephone-state-(type=tel):concept-fe-value-4">value</a>.</p>

  

  <p>The <code id="telephone-state-(type=tel):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified, must have a value that
  contains no U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.</p>

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="telephone-state-(type=tel):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: <a id="telephone-state-(type=tel):strip-newlines" href="https://infra.spec.whatwg.org/#strip-newlines" data-x-internal="strip-newlines">Strip
  newlines</a> from the <a href="#concept-fe-value" id="telephone-state-(type=tel):concept-fe-value-5">value</a>.</p>
  </div>

  

  <p class="note">Unlike the <a href="#url-state-(type=url)" id="telephone-state-(type=tel):url-state-(type=url)">URL</a> and <a href="#email-state-(type=email)" id="telephone-state-(type=tel):email-state-(type=email)">Email</a> types, the <a href="#telephone-state-(type=tel)" id="telephone-state-(type=tel):telephone-state-(type=tel)-2">Telephone</a> type does not enforce a particular syntax. This is
  intentional; in practice, telephone number fields tend to be free-form fields, because there are a
  wide variety of valid phone numbers. Systems that need to enforce a particular format are
  encouraged to use the <code id="telephone-state-(type=tel):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code> attribute or the <code id="telephone-state-(type=tel):dom-cva-setcustomvalidity"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> method to hook into the client-side
  validation mechanism.</p>


  <div class="bookkeeping">

   <p>The following common <code id="telephone-state-(type=tel):the-input-element-3"><a href="#the-input-element">input</a></code> element content
   attributes, IDL attributes, and methods <a href="#concept-input-apply" id="telephone-state-(type=tel):concept-input-apply">apply</a> to the element:
   <code id="telephone-state-(type=tel):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="telephone-state-(type=tel):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="telephone-state-(type=tel):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="telephone-state-(type=tel):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="telephone-state-(type=tel):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="telephone-state-(type=tel):attr-input-pattern-2"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="telephone-state-(type=tel):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="telephone-state-(type=tel):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="telephone-state-(type=tel):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="telephone-state-(type=tel):attr-input-size"><a href="#attr-input-size">size</a></code> content attributes;
   <code id="telephone-state-(type=tel):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="telephone-state-(type=tel):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="telephone-state-(type=tel):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="telephone-state-(type=tel):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, and
   <code id="telephone-state-(type=tel):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attributes;
   <code id="telephone-state-(type=tel):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="telephone-state-(type=tel):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="telephone-state-(type=tel):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

   <p>The <code id="telephone-state-(type=tel):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is
   in mode <a href="#dom-input-value-value" id="telephone-state-(type=tel):dom-input-value-value">value</a>.</p>

   <p>The <code id="telephone-state-(type=tel):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="telephone-state-(type=tel):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="telephone-state-(type=tel):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="telephone-state-(type=tel):do-not-apply">do not
   apply</a> to the element:
   <code id="telephone-state-(type=tel):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="telephone-state-(type=tel):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="telephone-state-(type=tel):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="telephone-state-(type=tel):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="telephone-state-(type=tel):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="telephone-state-(type=tel):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="telephone-state-(type=tel):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="telephone-state-(type=tel):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="telephone-state-(type=tel):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="telephone-state-(type=tel):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="telephone-state-(type=tel):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="telephone-state-(type=tel):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="telephone-state-(type=tel):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="telephone-state-(type=tel):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="telephone-state-(type=tel):do-not-apply-2">do not apply</a> to the
   element:
   <code id="telephone-state-(type=tel):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="telephone-state-(type=tel):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="telephone-state-(type=tel):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="telephone-state-(type=tel):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="telephone-state-(type=tel):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code> and
   <code id="telephone-state-(type=tel):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

  </div>


  <h6 id="url-state-(type=url)"><span class="secno">4.10.5.1.4</span> <dfn data-dfn-for="input" data-dfn-type="element-state">URL</dfn> state (<code>type=url</code>)<a href="#url-state-(type=url)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url" title="<input> elements of type url are used to let the user enter and edit a URL.">Element/input/url</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="url-state-(type=url):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="url-state-(type=url):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#url-state-(type=url)" id="url-state-(type=url):url-state-(type=url)">URL</a> state, the rules in this section apply.</p>

  

  <p>The <code id="url-state-(type=url):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="url-state-(type=url):represents">represents</a> a control for editing a single
  <a id="url-state-(type=url):absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a> given in the element's <a href="#concept-fe-value" id="url-state-(type=url):concept-fe-value">value</a>.</p>

  

  <p>If the element is <i id="url-state-(type=url):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the URL represented by its <a href="#concept-fe-value" id="url-state-(type=url):concept-fe-value-2">value</a>. User agents
  may allow the user to set the <a href="#concept-fe-value" id="url-state-(type=url):concept-fe-value-3">value</a> to a string that is not
  a <a href="https://url.spec.whatwg.org/#valid-url-string" id="url-state-(type=url):valid-url-string" data-x-internal="valid-url-string">valid</a> <a id="url-state-(type=url):absolute-url-2" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a>, but may also or instead
  automatically escape characters entered by the user so that the <a href="#concept-fe-value" id="url-state-(type=url):concept-fe-value-4">value</a> is always a <a href="https://url.spec.whatwg.org/#valid-url-string" id="url-state-(type=url):valid-url-string-2" data-x-internal="valid-url-string">valid</a>
  <a id="url-state-(type=url):absolute-url-3" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a> (even if that isn't the actual value seen and edited by the user in the
  interface). User agents should allow the user to set the <a href="#concept-fe-value" id="url-state-(type=url):concept-fe-value-5">value</a> to the empty string. User agents must not allow users to
  insert U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters into the <a href="#concept-fe-value" id="url-state-(type=url):concept-fe-value-6">value</a>.</p>

  

  <p>The <code id="url-state-(type=url):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified and not empty, must
  have a value that is a <a href="#valid-url-potentially-surrounded-by-spaces" id="url-state-(type=url):valid-url-potentially-surrounded-by-spaces">valid URL potentially surrounded by spaces</a> that is also an
  <a id="url-state-(type=url):absolute-url-4" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a>.</p>

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="url-state-(type=url):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: <a id="url-state-(type=url):strip-newlines" href="https://infra.spec.whatwg.org/#strip-newlines" data-x-internal="strip-newlines">Strip
  newlines</a> from the <a href="#concept-fe-value" id="url-state-(type=url):concept-fe-value-7">value</a>, then <a id="url-state-(type=url):strip-leading-and-trailing-ascii-whitespace" href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">strip leading
  and trailing ASCII whitespace</a> from the <a href="#concept-fe-value" id="url-state-(type=url):concept-fe-value-8">value</a>.</p>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: While the <a href="#concept-fe-value" id="url-state-(type=url):concept-fe-value-9">value</a>
  of the element is neither the empty string nor a <a href="https://url.spec.whatwg.org/#valid-url-string" id="url-state-(type=url):valid-url-string-3" data-x-internal="valid-url-string">valid</a>
  <a id="url-state-(type=url):absolute-url-5" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a>, the element is <a href="#suffering-from-a-type-mismatch" id="url-state-(type=url):suffering-from-a-type-mismatch">suffering from a type mismatch</a>.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The following common <code id="url-state-(type=url):the-input-element-3"><a href="#the-input-element">input</a></code> element content
   attributes, IDL attributes, and methods <a href="#concept-input-apply" id="url-state-(type=url):concept-input-apply">apply</a> to the element:
   <code id="url-state-(type=url):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="url-state-(type=url):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="url-state-(type=url):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="url-state-(type=url):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="url-state-(type=url):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="url-state-(type=url):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="url-state-(type=url):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="url-state-(type=url):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="url-state-(type=url):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="url-state-(type=url):attr-input-size"><a href="#attr-input-size">size</a></code> content attributes;
   <code id="url-state-(type=url):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="url-state-(type=url):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="url-state-(type=url):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="url-state-(type=url):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, and
   <code id="url-state-(type=url):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attributes;
   <code id="url-state-(type=url):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="url-state-(type=url):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="url-state-(type=url):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

   <p>The <code id="url-state-(type=url):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is
   in mode <a href="#dom-input-value-value" id="url-state-(type=url):dom-input-value-value">value</a>.</p>

   <p>The <code id="url-state-(type=url):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="url-state-(type=url):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="url-state-(type=url):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="url-state-(type=url):do-not-apply">do not
   apply</a> to the element:
   <code id="url-state-(type=url):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="url-state-(type=url):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="url-state-(type=url):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="url-state-(type=url):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="url-state-(type=url):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="url-state-(type=url):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="url-state-(type=url):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="url-state-(type=url):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="url-state-(type=url):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="url-state-(type=url):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="url-state-(type=url):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="url-state-(type=url):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="url-state-(type=url):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="url-state-(type=url):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="url-state-(type=url):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="url-state-(type=url):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="url-state-(type=url):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="url-state-(type=url):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="url-state-(type=url):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="url-state-(type=url):do-not-apply-2">do not apply</a> to the
   element:
   <code id="url-state-(type=url):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="url-state-(type=url):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="url-state-(type=url):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="url-state-(type=url):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="url-state-(type=url):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code> and
   <code id="url-state-(type=url):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

  </div>

  <div class="example">

   <p>If a document contained the following markup:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"location"</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">"urls"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"urls"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"MIME: Format of Internet Message Bodies"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://www.rfc-editor.org/rfc/rfc2045"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"HTML"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://html.spec.whatwg.org/"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"DOM"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://dom.spec.whatwg.org/"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Fullscreen"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://fullscreen.spec.whatwg.org/"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Media Session"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://mediasession.spec.whatwg.org/"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"The Single UNIX Specification, Version 3"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"http://www.unix.org/version3/"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c-></code></pre>

   <p>...and the user had typed "<kbd>spec.w</kbd>", and the user agent had also found that the user
   had visited <code>https://url.spec.whatwg.org/#url-parsing</code> and <code>https://streams.spec.whatwg.org/</code> in the recent past, then the rendering might look
   like this:</p>

   <p><img class="darkmode-aware" src="/images/sample-url.svg" width="480" alt="A text box with an icon on the left followed by the text &quot;spec.w&quot; and a cursor, with a drop down button on the right hand side; with, below, a drop down box containing a list of six URLs on the left, with the first four having grayed out labels on the right; and a scrollbar to the right of the drop down box, indicating further values are available." height="150"></p>

   <p>The first four URLs in this sample consist of the four URLs in the author-specified list that
   match the text the user has entered, sorted in some <a id="url-state-(type=url):implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner
   (maybe by how frequently the user refers to those URLs). Note how the UA is using the knowledge
   that the values are URLs to allow the user to omit the scheme part and perform intelligent
   matching on the domain name.</p>

   <p>The last two URLs (and probably many more, given the scrollbar's indications of more values
   being available) are the matches from the user agent's session history data. This data is not
   made available to the page DOM. In this particular case, the UA has no titles to provide for
   those values.</p>

  </div>


  <h6 id="email-state-(type=email)"><span class="secno">4.10.5.1.5</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Email</dfn> state (<code>type=email</code>)<span id="e-mail-state-(type=email)"></span><a href="#email-state-(type=email)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email" title="<input> elements of type email are used to let the user enter and edit an email address, or, if the multiple attribute is specified, a list of email addresses.">Element/input/email</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  

  <p>When an <code id="email-state-(type=email):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="email-state-(type=email):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#email-state-(type=email)" id="email-state-(type=email):email-state-(type=email)">Email</a> state, the rules in this section apply.</p>

  

  <p>How the <a href="#email-state-(type=email)" id="email-state-(type=email):email-state-(type=email)-2">Email</a> state operates depends on whether the
  <code id="email-state-(type=email):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> attribute is specified or not.</p>

  <dl class="switch"><dt>When the <code id="email-state-(type=email):attr-input-multiple-2"><a href="#attr-input-multiple">multiple</a></code> attribute is not specified on the
   element</dt><dd>
    <p>The <code id="email-state-(type=email):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="email-state-(type=email):represents">represents</a> a control for editing an email
    address given in the element's <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value">value</a>.</p>

    

    <p>If the element is <i id="email-state-(type=email):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
    user to change the email address represented by its <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-2">value</a>. User agents may allow the user to set the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-3">value</a> to a string that is not a <a href="#valid-e-mail-address" id="email-state-(type=email):valid-e-mail-address">valid email
    address</a>. The user agent should act in a manner consistent with expecting the user to
    provide a single email address. User agents should allow the user to set the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-4">value</a> to the empty string. User agents must not allow users to
    insert U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters into the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-5">value</a>. User agents may transform the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-6">value</a> for display and editing; in particular, user agents should
    convert punycode in the domain labels of the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-7">value</a> to IDN in the display and
    vice versa.</p>

    <div data-algorithm="">
    <p><strong>Constraint validation</strong>: While the user interface is representing input that
    the user agent cannot convert to punycode, the control is <a href="#suffering-from-bad-input" id="email-state-(type=email):suffering-from-bad-input">suffering from bad
    input</a>.</p>
    </div>

    

    <p>The <code id="email-state-(type=email):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified and not empty, must
    have a value that is a single <a href="#valid-e-mail-address" id="email-state-(type=email):valid-e-mail-address-2">valid email address</a>.</p>

    

    <div data-algorithm="">
    <p><strong>The <a href="#value-sanitization-algorithm" id="email-state-(type=email):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: <a id="email-state-(type=email):strip-newlines" href="https://infra.spec.whatwg.org/#strip-newlines" data-x-internal="strip-newlines">Strip
    newlines</a> from the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-8">value</a>, then <a id="email-state-(type=email):strip-leading-and-trailing-ascii-whitespace" href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">strip leading
    and trailing ASCII whitespace</a> from the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-9">value</a>.</p>
    </div>

    <div data-algorithm="">
    <p><strong>Constraint validation</strong>: While the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-10">value</a>
    of the element is neither the empty string nor a single <a href="#valid-e-mail-address" id="email-state-(type=email):valid-e-mail-address-3">valid email address</a>, the
    element is <a href="#suffering-from-a-type-mismatch" id="email-state-(type=email):suffering-from-a-type-mismatch">suffering from a type mismatch</a>.</p>
    </div>

    
   </dd><dt>When the <code id="email-state-(type=email):attr-input-multiple-3"><a href="#attr-input-multiple">multiple</a></code> attribute <em>is</em> specified on
   the element</dt><dd>
    <p>The <code id="email-state-(type=email):the-input-element-3"><a href="#the-input-element">input</a></code> element <a href="#represents" id="email-state-(type=email):represents-2">represents</a> a control for adding, removing, and
    editing the email addresses given in the element's <a href="#concept-fe-values" id="email-state-(type=email):concept-fe-values">value<em>s</em></a>.</p>

    

    <p>If the element is <i id="email-state-(type=email):concept-fe-mutable-2"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
    user to add, remove, and edit the email addresses represented by its <a href="#concept-fe-values" id="email-state-(type=email):concept-fe-values-2">values</a>. User agents may allow the user to set any
    individual value in the list of <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-11">value<em>s</em></a> to a
    string that is not a <a href="#valid-e-mail-address" id="email-state-(type=email):valid-e-mail-address-4">valid email address</a>, but must not allow users to set any
    individual value to a string containing U+002C COMMA (,), U+000A LINE FEED (LF), or U+000D
    CARRIAGE RETURN (CR) characters. User agents should allow the user to remove all the addresses
    in the element's <a href="#concept-fe-values" id="email-state-(type=email):concept-fe-values-3">values</a>. User agents may
    transform the <a href="#concept-fe-values" id="email-state-(type=email):concept-fe-values-4">values</a> for display and editing; in
    particular, user agents should convert punycode in the domain labels of the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-12">value</a> to IDN in the display and vice versa.</p>

    <div data-algorithm="">
    <p><strong>Constraint validation</strong>: While the user interface describes a situation where
    an individual value contains a U+002C COMMA (,) or is representing input that the user agent
    cannot convert to punycode, the control is <a href="#suffering-from-bad-input" id="email-state-(type=email):suffering-from-bad-input-2">suffering from bad input</a>.</p>
    </div>

    <div data-algorithm="">
    <p>Whenever the user changes the element's <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-13">value<em>s</em></a>, the user agent must run the following
    steps:</p>

    <ol><li><p>Let <var>latest values</var> be a copy of the element's <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-14">value<em>s</em></a>.</p></li><li><p><a id="email-state-(type=email):strip-leading-and-trailing-ascii-whitespace-2" href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">Strip leading and trailing ASCII whitespace</a> from each value in <var>latest
     values</var>.</p></li><li><p>Set the element's <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-15">value</a> to the result of
     concatenating all the values in <var>latest values</var>, separating each value from
     the next by a single U+002C COMMA character (,), maintaining the list's order.</p></li></ol>
    </div>

    

    <p>The <code id="email-state-(type=email):attr-input-value-2"><a href="#attr-input-value">value</a></code> attribute, if specified, must have a value
    that is a <a href="#valid-e-mail-address-list" id="email-state-(type=email):valid-e-mail-address-list">valid email address list</a>.</p>

    

    <div data-algorithm="">
    <p><strong>The <a href="#value-sanitization-algorithm" id="email-state-(type=email):value-sanitization-algorithm-2">value sanitization algorithm</a> is as follows</strong>:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#split-on-commas" id="email-state-(type=email):split-a-string-on-commas" data-x-internal="split-a-string-on-commas">Split on commas</a> the element's <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-16">value</a>, <a id="email-state-(type=email):strip-leading-and-trailing-ascii-whitespace-3" href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">strip leading and trailing ASCII
     whitespace</a> from each resulting token, if any, and let the element's <a href="#concept-fe-values" id="email-state-(type=email):concept-fe-values-5">values</a> be the (possibly empty) resulting list of
     (possibly empty) tokens, maintaining the original order.</p></li><li><p>Set the element's <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-17">value</a> to the result of
     concatenating the element's <a href="#concept-fe-values" id="email-state-(type=email):concept-fe-values-6">values</a>, separating
     each value from the next by a single U+002C COMMA character (,), maintaining the list's
     order.</p></li></ol>
    </div>

    <div data-algorithm="">
    <p><strong>Constraint validation</strong>: While the <a href="#concept-fe-value" id="email-state-(type=email):concept-fe-value-18">value</a>
    of the element is not a <a href="#valid-e-mail-address-list" id="email-state-(type=email):valid-e-mail-address-list-2">valid email address list</a>, the element is <a href="#suffering-from-a-type-mismatch" id="email-state-(type=email):suffering-from-a-type-mismatch-2">suffering
    from a type mismatch</a>.</p>
    </div>

    
   </dd></dl>

  <div data-algorithm="">
  <p>When the <code id="email-state-(type=email):attr-input-multiple-4"><a href="#attr-input-multiple">multiple</a></code> attribute is set or removed, the
  user agent must run the <a href="#value-sanitization-algorithm" id="email-state-(type=email):value-sanitization-algorithm-3">value sanitization algorithm</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <dfn id="valid-e-mail-address">valid email address</dfn> is a string that matches the <code>email</code> production of the following ABNF, the character set for which is Unicode.
  This ABNF implements the extensions described in RFC 1123. <a href="#refsABNF">[ABNF]</a> <a href="#refsRFC5322">[RFC5322]</a>
  <a href="#refsRFC1034">[RFC1034]</a> <a href="#refsRFC1123">[RFC1123]</a></p>

  <pre><code class="abnf"><c- nc="">email</c->         <c- o="">=</c-> <c- o="">1*</c-><c- p="">(</c-> <c- nc="">atext</c-> <c- o="">/</c-> <c- l="">"."</c-> <c- p="">)</c-> <c- l="">"@"</c-> <c- nc="">label</c-> <c- o="">*</c-><c- p="">(</c-> <c- l="">"."</c-> <c- nc="">label</c-> <c- p="">)</c->
<c- nc="">label</c->         <c- o="">=</c-> <c- nc="">let-dig</c-> <c- p="">[</c-> <c- p="">[</c-> <c- nc="">ldh-str</c-> <c- p="">]</c-> <c- nc="">let-dig</c-> <c- p="">]</c->  <c- c1="">; limited to a length of 63 characters by </c-><a href="https://www.rfc-editor.org/rfc/rfc1034#section-3.5"><c- c1="">RFC 1034 section 3.5</c-></a>
<c- nc="">atext</c->         <c- o="">=</c-> &lt; <c- nc="">as</c-> <c- nc="">defined</c-> <c- nc="">in</c-> <a href="https://www.rfc-editor.org/rfc/rfc5322#section-3.2.3"><c- nc="">RFC</c-> <c- o="">5322</c-> <c- nc="">section</c-> <c- o="">3</c->.<c- o="">2</c->.<c- o="">3</c-></a> &gt;
<c- nc="">let-dig</c->       <c- o="">=</c-> &lt; <c- nc="">as</c-> <c- nc="">defined</c-> <c- nc="">in</c-> <a href="https://www.rfc-editor.org/rfc/rfc1034#section-3.5"><c- nc="">RFC</c-> <c- o="">1034</c-> <c- nc="">section</c-> <c- o="">3</c->.<c- o="">5</c-></a> &gt;
<c- nc="">ldh-str</c->       <c- o="">=</c-> &lt; <c- nc="">as</c-> <c- nc="">defined</c-> <c- nc="">in</c-> <a href="https://www.rfc-editor.org/rfc/rfc1034#section-3.5"><c- nc="">RFC</c-> <c- o="">1034</c-> <c- nc="">section</c-> <c- o="">3</c->.<c- o="">5</c-></a> &gt;</code></pre>
  </div>

  

  <p class="note">This requirement is a <a id="email-state-(type=email):willful-violation" href="https://infra.spec.whatwg.org/#willful-violation" data-x-internal="willful-violation">willful violation</a> of RFC 5322, which defines a
  syntax for email addresses that is simultaneously too strict (before the "@" character), too
  vague (after the "@" character), and too lax (allowing comments, whitespace characters, and quoted
  strings in manners unfamiliar to most users) to be of practical use here.</p>

  <div class="note">

   <p>The following JavaScript- and Perl-compatible regular expression is an implementation of the
   above definition.</p>

   <pre>/^[a-zA-Z0-9.!#$%&amp;'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/</pre>

   

  </div>

  <div data-algorithm="">
  <p>A <dfn id="valid-e-mail-address-list">valid email address list</dfn> is a <a href="#set-of-comma-separated-tokens" id="email-state-(type=email):set-of-comma-separated-tokens">set of
  comma-separated tokens</a>, where each token is itself a <a href="#valid-e-mail-address" id="email-state-(type=email):valid-e-mail-address-5">valid email address</a>.
  To obtain the list of tokens from a <a href="#valid-e-mail-address-list" id="email-state-(type=email):valid-e-mail-address-list-3">valid email address list</a>, an
  implementation must <a href="https://infra.spec.whatwg.org/#split-on-commas" id="email-state-(type=email):split-a-string-on-commas-2" data-x-internal="split-a-string-on-commas">split the string on
  commas</a>.</p>
  </div>

  <div class="bookkeeping">

   <p>The following common <code id="email-state-(type=email):the-input-element-4"><a href="#the-input-element">input</a></code> element content
   attributes, IDL attributes, and methods <a href="#concept-input-apply" id="email-state-(type=email):concept-input-apply">apply</a> to the element:
   <code id="email-state-(type=email):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="email-state-(type=email):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="email-state-(type=email):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="email-state-(type=email):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="email-state-(type=email):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="email-state-(type=email):attr-input-multiple-5"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="email-state-(type=email):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="email-state-(type=email):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="email-state-(type=email):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="email-state-(type=email):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="email-state-(type=email):attr-input-size"><a href="#attr-input-size">size</a></code> content attributes;
   <code id="email-state-(type=email):dom-input-list"><a href="#dom-input-list">list</a></code> and
   <code id="email-state-(type=email):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attributes;
   <code id="email-state-(type=email):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code> method.</p>



   <p>The <code id="email-state-(type=email):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is
   in mode <a href="#dom-input-value-value" id="email-state-(type=email):dom-input-value-value">value</a>.</p>

   <p>The <code id="email-state-(type=email):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="email-state-(type=email):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="email-state-(type=email):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="email-state-(type=email):do-not-apply">do not
   apply</a> to the element:
   <code id="email-state-(type=email):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="email-state-(type=email):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="email-state-(type=email):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="email-state-(type=email):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="email-state-(type=email):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="email-state-(type=email):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="email-state-(type=email):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="email-state-(type=email):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="email-state-(type=email):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="email-state-(type=email):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="email-state-(type=email):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="email-state-(type=email):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="email-state-(type=email):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="email-state-(type=email):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="email-state-(type=email):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="email-state-(type=email):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="email-state-(type=email):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="email-state-(type=email):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="email-state-(type=email):do-not-apply-2">do not apply</a> to the
   element:
   <code id="email-state-(type=email):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="email-state-(type=email):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="email-state-(type=email):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="email-state-(type=email):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="email-state-(type=email):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="email-state-(type=email):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="email-state-(type=email):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="email-state-(type=email):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="email-state-(type=email):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="email-state-(type=email):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code> and
   <code id="email-state-(type=email):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

  </div>


  <h6 id="password-state-(type=password)"><span class="secno">4.10.5.1.6</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Password</dfn> state (<code>type=password</code>)<a href="#password-state-(type=password)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password" title="<input> elements of type password provide a way for the user to securely enter a password.">Element/input/password</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>2+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>2+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="password-state-(type=password):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="password-state-(type=password):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#password-state-(type=password)" id="password-state-(type=password):password-state-(type=password)">Password</a> state, the rules in this section
  apply.</p>

  

  <p>The <code id="password-state-(type=password):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="password-state-(type=password):represents">represents</a> a one line plain text edit control for
  the element's <a href="#concept-fe-value" id="password-state-(type=password):concept-fe-value">value</a>. The user agent should obscure the value
  so that people other than the user cannot see it.</p>

  

  <p>If the element is <i id="password-state-(type=password):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, its <a href="#concept-fe-value" id="password-state-(type=password):concept-fe-value-2">value</a> should be editable by the user. User agents must not allow
  users to insert U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters into the <a href="#concept-fe-value" id="password-state-(type=password):concept-fe-value-3">value</a>.</p>

  

  <p>The <code id="password-state-(type=password):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified, must have a value that
  contains no U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.</p>

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="password-state-(type=password):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: <a id="password-state-(type=password):strip-newlines" href="https://infra.spec.whatwg.org/#strip-newlines" data-x-internal="strip-newlines">Strip
  newlines</a> from the <a href="#concept-fe-value" id="password-state-(type=password):concept-fe-value-4">value</a>.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The following common <code id="password-state-(type=password):the-input-element-3"><a href="#the-input-element">input</a></code> element content
   attributes, IDL attributes, and methods <a href="#concept-input-apply" id="password-state-(type=password):concept-input-apply">apply</a> to the element:
   <code id="password-state-(type=password):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="password-state-(type=password):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="password-state-(type=password):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="password-state-(type=password):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="password-state-(type=password):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="password-state-(type=password):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="password-state-(type=password):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="password-state-(type=password):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="password-state-(type=password):attr-input-size"><a href="#attr-input-size">size</a></code> content attributes;
   <code id="password-state-(type=password):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="password-state-(type=password):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="password-state-(type=password):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, and
   <code id="password-state-(type=password):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attributes;
   <code id="password-state-(type=password):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="password-state-(type=password):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="password-state-(type=password):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

   <p>The <code id="password-state-(type=password):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is
   in mode <a href="#dom-input-value-value" id="password-state-(type=password):dom-input-value-value">value</a>.</p>

   <p>The <code id="password-state-(type=password):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="password-state-(type=password):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="password-state-(type=password):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="password-state-(type=password):do-not-apply">do not
   apply</a> to the element:
   <code id="password-state-(type=password):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="password-state-(type=password):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="password-state-(type=password):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="password-state-(type=password):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="password-state-(type=password):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="password-state-(type=password):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="password-state-(type=password):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="password-state-(type=password):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="password-state-(type=password):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="password-state-(type=password):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="password-state-(type=password):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="password-state-(type=password):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="password-state-(type=password):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="password-state-(type=password):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="password-state-(type=password):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="password-state-(type=password):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="password-state-(type=password):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="password-state-(type=password):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="password-state-(type=password):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="password-state-(type=password):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="password-state-(type=password):do-not-apply-2">do not apply</a> to the
   element:
   <code id="password-state-(type=password):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="password-state-(type=password):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="password-state-(type=password):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="password-state-(type=password):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="password-state-(type=password):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="password-state-(type=password):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code> and
   <code id="password-state-(type=password):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

  </div>


  <h6 id="date-state-(type=date)"><span class="secno">4.10.5.1.7</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Date</dfn> state (<code>type=date</code>)<a href="#date-state-(type=date)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date" title="<input> elements of type=&quot;date&quot; create input fields that let the user enter a date, either with a textbox that validates the input or a special date picker interface.">Element/input/date</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  

  <p>When an <code id="date-state-(type=date):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="date-state-(type=date):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#date-state-(type=date)" id="date-state-(type=date):date-state-(type=date)">Date</a> state, the rules in this section apply.</p>

  

  <p>The <code id="date-state-(type=date):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="date-state-(type=date):represents">represents</a> a control for setting the element's
  <a href="#concept-fe-value" id="date-state-(type=date):concept-fe-value">value</a> to a string representing a specific <a href="#concept-date" id="date-state-(type=date):concept-date">date</a>.</p>

  

  <p>If the element is <i id="date-state-(type=date):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the <a href="#concept-date" id="date-state-(type=date):concept-date-2">date</a> represented by its <a href="#concept-fe-value" id="date-state-(type=date):concept-fe-value-2">value</a>, as obtained by <a href="#parse-a-date-string" id="date-state-(type=date):parse-a-date-string">parsing a
  date</a> from it. User agents must not allow the user to set the <a href="#concept-fe-value" id="date-state-(type=date):concept-fe-value-3">value</a> to a non-empty string that is not a <a href="#valid-date-string" id="date-state-(type=date):valid-date-string">valid date
  string</a>. If the user agent provides a user interface for selecting a <a href="#concept-date" id="date-state-(type=date):concept-date-3">date</a>, then the <a href="#concept-fe-value" id="date-state-(type=date):concept-fe-value-4">value</a> must be set
  to a <a href="#valid-date-string" id="date-state-(type=date):valid-date-string-2">valid date string</a> representing the user's selection. User agents should allow
  the user to set the <a href="#concept-fe-value" id="date-state-(type=date):concept-fe-value-5">value</a> to the empty string.</p>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: While the user interface describes input that the user
  agent cannot convert to a <a href="#valid-date-string" id="date-state-(type=date):valid-date-string-3">valid date string</a>, the control is <a href="#suffering-from-bad-input" id="date-state-(type=date):suffering-from-bad-input">suffering from bad
  input</a>.</p>
  </div>

  

  <p class="note">See the <a href="#input-author-notes">introduction section</a> for a discussion of
  the difference between the input format and submission format for date, time, and number form
  controls, and the <a href="#input-impl-notes">implementation notes</a>
  regarding localization of form controls.</p>

  <p>The <code id="date-state-(type=date):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified and not empty, must
  have a value that is a <a href="#valid-date-string" id="date-state-(type=date):valid-date-string-4">valid date string</a>.</p> 

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="date-state-(type=date):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: If the <a href="#concept-fe-value" id="date-state-(type=date):concept-fe-value-6">value</a> of the element is not a <a href="#valid-date-string" id="date-state-(type=date):valid-date-string-5">valid date string</a>, then
  set it to the empty string instead.</p>
  </div>

  

  <p>The <code id="date-state-(type=date):attr-input-min"><a href="#attr-input-min">min</a></code> attribute, if specified, must have a value that is
  a <a href="#valid-date-string" id="date-state-(type=date):valid-date-string-6">valid date string</a>. The <code id="date-state-(type=date):attr-input-max"><a href="#attr-input-max">max</a></code> attribute, if
  specified, must have a value that is a <a href="#valid-date-string" id="date-state-(type=date):valid-date-string-7">valid date string</a>.</p>

  <p>The <code id="date-state-(type=date):attr-input-step"><a href="#attr-input-step">step</a></code> attribute is expressed in days. The <a href="#concept-input-step-scale" id="date-state-(type=date):concept-input-step-scale">step scale factor</a> is 86,400,000
  (which converts the days to milliseconds, as used in the other algorithms). The <a href="#concept-input-step-default" id="date-state-(type=date):concept-input-step-default">default step</a> is 1 day.</p>

  

  <p>When the element is <a href="#suffering-from-a-step-mismatch" id="date-state-(type=date):suffering-from-a-step-mismatch">suffering from a step mismatch</a>, the user agent may round the
  element's <a href="#concept-fe-value" id="date-state-(type=date):concept-fe-value-7">value</a> to the nearest <a href="#concept-date" id="date-state-(type=date):concept-date-4">date</a> for which the element would not <a href="#suffering-from-a-step-mismatch" id="date-state-(type=date):suffering-from-a-step-mismatch-2">suffer from a step mismatch</a>.</p>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-number" id="date-state-(type=date):concept-input-value-string-number">algorithm to convert a string to a
  number</a>, given a string <var>input</var>, is as follows</strong>: If <a href="#parse-a-date-string" id="date-state-(type=date):parse-a-date-string-2">parsing a date</a> from <var>input</var> results in an
  error, then return an error; otherwise, return the number of milliseconds elapsed from midnight
  UTC on the morning of 1970-01-01 (the time represented by the value "<code>1970-01-01T00:00:00.0Z</code>") to midnight UTC on the morning of the parsed <a href="#concept-date" id="date-state-(type=date):concept-date-5">date</a>, ignoring leap seconds.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-number-string" id="date-state-(type=date):concept-input-value-number-string">algorithm to convert a number to a
  string</a>, given a number <var>input</var>, is as follows</strong>: Return a
  <a href="#valid-date-string" id="date-state-(type=date):valid-date-string-8">valid date string</a> that represents the <a href="#concept-date" id="date-state-(type=date):concept-date-6">date</a> that, in
  UTC, is current <var>input</var> milliseconds after midnight UTC on the morning of
  1970-01-01 (the time represented by the value "<code>1970-01-01T00:00:00.0Z</code>").</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-date" id="date-state-(type=date):concept-input-value-string-date">algorithm to convert a string to a
  <code>Date</code> object</a>, given a string <var>input</var>, is as follows</strong>:
  If <a href="#parse-a-date-string" id="date-state-(type=date):parse-a-date-string-3">parsing a date</a> from <var>input</var> results
  in an error, then return an error; otherwise, return <a href="#create-a-date-object" id="date-state-(type=date):create-a-date-object">a new
  <code>Date</code> object</a> representing midnight UTC on the morning of the parsed <a href="#concept-date" id="date-state-(type=date):concept-date-7">date</a>.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-date-string" id="date-state-(type=date):concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</a>, given a <code id="date-state-(type=date):date"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object <var>input</var>, is
  as follows</strong>: Return a <a href="#valid-date-string" id="date-state-(type=date):valid-date-string-9">valid date string</a> that represents the <a href="#concept-date" id="date-state-(type=date):concept-date-8">date</a> current at the time represented by <var>input</var> in the UTC
  time zone.</p>
  </div>

  

  <div id="only-contemporary-times" class="note"><a href="#only-contemporary-times" class="self-link"></a>

   <p>The <a href="#date-state-(type=date)" id="date-state-(type=date):date-state-(type=date)-2">Date</a> state (and other date- and time-related
   states described in subsequent sections) is not intended for the entry of values for which a
   precise date and time relative to the contemporary calendar cannot be established. For example,
   it would be inappropriate for the entry of times like "one millisecond after the big bang", "the
   early part of the Jurassic period", or "a winter around 250 BCE".</p>

   <p>For the input of dates before the introduction of the Gregorian calendar, authors are
   encouraged to not use the <a href="#date-state-(type=date)" id="date-state-(type=date):date-state-(type=date)-3">Date</a> state (and the other
   date- and time-related states described in subsequent sections), as user agents are not required
   to support converting dates and times from earlier periods to the Gregorian calendar, and asking
   users to do so manually puts an undue burden on users. (This is complicated by the manner in
   which the Gregorian calendar was phased in, which occurred at different times in different
   countries, ranging from partway through the 16th century all the way to early in the 20th.)
   Instead, authors are encouraged to provide fine-grained input controls using the
   <code id="date-state-(type=date):the-select-element"><a href="#the-select-element">select</a></code> element and <code id="date-state-(type=date):the-input-element-3"><a href="#the-input-element">input</a></code> elements with the <a href="#number-state-(type=number)" id="date-state-(type=date):number-state-(type=number)">Number</a> state.</p>

  </div>

  <div class="bookkeeping">

   <p>The following common <code id="date-state-(type=date):the-input-element-4"><a href="#the-input-element">input</a></code> element content
   attributes, IDL attributes, and methods <a href="#concept-input-apply" id="date-state-(type=date):concept-input-apply">apply</a> to the element:
   <code id="date-state-(type=date):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="date-state-(type=date):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="date-state-(type=date):attr-input-max-2"><a href="#attr-input-max">max</a></code>,
   <code id="date-state-(type=date):attr-input-min-2"><a href="#attr-input-min">min</a></code>,
   <code id="date-state-(type=date):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="date-state-(type=date):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="date-state-(type=date):attr-input-step-2"><a href="#attr-input-step">step</a></code> content attributes;
   <code id="date-state-(type=date):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="date-state-(type=date):dom-input-value"><a href="#dom-input-value">value</a></code>,
   <code id="date-state-(type=date):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="date-state-(type=date):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="date-state-(type=date):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="date-state-(type=date):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="date-state-(type=date):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="date-state-(type=date):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is
   in mode <a href="#dom-input-value-value" id="date-state-(type=date):dom-input-value-value">value</a>.</p>

   <p>The <code id="date-state-(type=date):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="date-state-(type=date):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="date-state-(type=date):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="date-state-(type=date):do-not-apply">do not
   apply</a> to the element:
   <code id="date-state-(type=date):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="date-state-(type=date):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="date-state-(type=date):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="date-state-(type=date):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="date-state-(type=date):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="date-state-(type=date):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="date-state-(type=date):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="date-state-(type=date):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="date-state-(type=date):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="date-state-(type=date):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="date-state-(type=date):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="date-state-(type=date):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="date-state-(type=date):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="date-state-(type=date):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="date-state-(type=date):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="date-state-(type=date):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="date-state-(type=date):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="date-state-(type=date):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="date-state-(type=date):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="date-state-(type=date):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="date-state-(type=date):attr-input-src"><a href="#attr-input-src">src</a></code>, and
   <code id="date-state-(type=date):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="date-state-(type=date):do-not-apply-2">do not apply</a> to the
   element:
   <code id="date-state-(type=date):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="date-state-(type=date):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="date-state-(type=date):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>, and
   <code id="date-state-(type=date):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code> IDL attributes;
   <code id="date-state-(type=date):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="date-state-(type=date):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

  </div>


  <h6 id="month-state-(type=month)"><span class="secno">4.10.5.1.8</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Month</dfn> state (<code>type=month</code>)<a href="#month-state-(type=month)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month" title="<input> elements of type month create input fields that let the user enter a month and year allowing a month and year to be easily entered. The value is a string whose value is in the format &quot;YYYY-MM&quot;, where YYYY is the four-digit year and MM is the month number.">Element/input/month</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>18+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>Yes</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="month-state-(type=month):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="month-state-(type=month):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#month-state-(type=month)" id="month-state-(type=month):month-state-(type=month)">Month</a> state, the rules in this section apply.</p>

  

  <p>The <code id="month-state-(type=month):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="month-state-(type=month):represents">represents</a> a control for setting the element's
  <a href="#concept-fe-value" id="month-state-(type=month):concept-fe-value">value</a> to a string representing a specific <a href="#concept-month" id="month-state-(type=month):concept-month">month</a>.</p>

  

  <p>If the element is <i id="month-state-(type=month):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the <a href="#concept-month" id="month-state-(type=month):concept-month-2">month</a> represented by its <a href="#concept-fe-value" id="month-state-(type=month):concept-fe-value-2">value</a>, as obtained by <a href="#parse-a-month-string" id="month-state-(type=month):parse-a-month-string">parsing a
  month</a> from it. User agents must not allow the user to set the <a href="#concept-fe-value" id="month-state-(type=month):concept-fe-value-3">value</a> to a non-empty string that is not a <a href="#valid-month-string" id="month-state-(type=month):valid-month-string">valid month
  string</a>. If the user agent provides a user interface for selecting a <a href="#concept-month" id="month-state-(type=month):concept-month-3">month</a>, then the <a href="#concept-fe-value" id="month-state-(type=month):concept-fe-value-4">value</a> must be
  set to a <a href="#valid-month-string" id="month-state-(type=month):valid-month-string-2">valid month string</a> representing the user's selection. User agents should
  allow the user to set the <a href="#concept-fe-value" id="month-state-(type=month):concept-fe-value-5">value</a> to the empty string.</p>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: While the user interface describes input that the user
  agent cannot convert to a <a href="#valid-month-string" id="month-state-(type=month):valid-month-string-3">valid month string</a>, the control is <a href="#suffering-from-bad-input" id="month-state-(type=month):suffering-from-bad-input">suffering from bad
  input</a>.</p>
  </div>

  

  <p class="note">See the <a href="#input-author-notes">introduction section</a> for a discussion of
  the difference between the input format and submission format for date, time, and number form
  controls, and the <a href="#input-impl-notes">implementation notes</a>
  regarding localization of form controls.</p>

  <p>The <code id="month-state-(type=month):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified and not empty, must
  have a value that is a <a href="#valid-month-string" id="month-state-(type=month):valid-month-string-4">valid month string</a>.</p> 

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="month-state-(type=month):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: If the <a href="#concept-fe-value" id="month-state-(type=month):concept-fe-value-6">value</a> of the element is not a <a href="#valid-month-string" id="month-state-(type=month):valid-month-string-5">valid month string</a>,
  then set it to the empty string instead.</p>
  </div>

  

  <p>The <code id="month-state-(type=month):attr-input-min"><a href="#attr-input-min">min</a></code> attribute, if specified, must have a value that is
  a <a href="#valid-month-string" id="month-state-(type=month):valid-month-string-6">valid month string</a>. The <code id="month-state-(type=month):attr-input-max"><a href="#attr-input-max">max</a></code> attribute, if
  specified, must have a value that is a <a href="#valid-month-string" id="month-state-(type=month):valid-month-string-7">valid month string</a>.</p>

  <p>The <code id="month-state-(type=month):attr-input-step"><a href="#attr-input-step">step</a></code> attribute is expressed in months. The <a href="#concept-input-step-scale" id="month-state-(type=month):concept-input-step-scale">step scale factor</a> is 1 (there is no
  conversion needed as the algorithms use months). The <a href="#concept-input-step-default" id="month-state-(type=month):concept-input-step-default">default step</a> is 1 month.</p>

  

  <p>When the element is <a href="#suffering-from-a-step-mismatch" id="month-state-(type=month):suffering-from-a-step-mismatch">suffering from a step mismatch</a>, the user agent may round the
  element's <a href="#concept-fe-value" id="month-state-(type=month):concept-fe-value-7">value</a> to the nearest <a href="#concept-month" id="month-state-(type=month):concept-month-4">month</a> for which the element would not <a href="#suffering-from-a-step-mismatch" id="month-state-(type=month):suffering-from-a-step-mismatch-2">suffer from a step mismatch</a>.</p>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-number" id="month-state-(type=month):concept-input-value-string-number">algorithm to convert a string to a
  number</a>, given a string <var>input</var>, is as follows</strong>: If <a href="#parse-a-month-string" id="month-state-(type=month):parse-a-month-string-2">parsing a month</a> from <var>input</var> results in an
  error, then return an error; otherwise, return the number of months between January 1970 and the
  parsed <a href="#concept-month" id="month-state-(type=month):concept-month-5">month</a>.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-number-string" id="month-state-(type=month):concept-input-value-number-string">algorithm to convert a number to a
  string</a>, given a number <var>input</var>, is as follows</strong>: Return a
  <a href="#valid-month-string" id="month-state-(type=month):valid-month-string-8">valid month string</a> that represents the <a href="#concept-month" id="month-state-(type=month):concept-month-6">month</a> that
  has <var>input</var> months between it and January 1970.</p>
  </div>

  

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-date" id="month-state-(type=month):concept-input-value-string-date">algorithm to convert a string to a
  <code>Date</code> object</a>, given a string <var>input</var>, is as follows</strong>:
  If <a href="#parse-a-month-string" id="month-state-(type=month):parse-a-month-string-3">parsing a month</a> from <var>input</var>
  results in an error, then return an error; otherwise, return <a href="#create-a-date-object" id="month-state-(type=month):create-a-date-object">a
  new <code>Date</code> object</a> representing midnight UTC on the morning of the first day of
  the parsed <a href="#concept-month" id="month-state-(type=month):concept-month-7">month</a>.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-date-string" id="month-state-(type=month):concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</a>, given a <code id="month-state-(type=month):date"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object <var>input</var>, is
  as follows</strong>: Return a <a href="#valid-month-string" id="month-state-(type=month):valid-month-string-9">valid month string</a> that represents the <a href="#concept-month" id="month-state-(type=month):concept-month-8">month</a> current at the time represented by <var>input</var> in the UTC
  time zone.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The following common <code id="month-state-(type=month):the-input-element-3"><a href="#the-input-element">input</a></code> element content
   attributes, IDL attributes, and methods <a href="#concept-input-apply" id="month-state-(type=month):concept-input-apply">apply</a> to the element:
   <code id="month-state-(type=month):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="month-state-(type=month):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="month-state-(type=month):attr-input-max-2"><a href="#attr-input-max">max</a></code>,
   <code id="month-state-(type=month):attr-input-min-2"><a href="#attr-input-min">min</a></code>,
   <code id="month-state-(type=month):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="month-state-(type=month):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="month-state-(type=month):attr-input-step-2"><a href="#attr-input-step">step</a></code> content attributes;
   <code id="month-state-(type=month):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="month-state-(type=month):dom-input-value"><a href="#dom-input-value">value</a></code>,
   <code id="month-state-(type=month):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="month-state-(type=month):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="month-state-(type=month):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="month-state-(type=month):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="month-state-(type=month):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="month-state-(type=month):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is
   in mode <a href="#dom-input-value-value" id="month-state-(type=month):dom-input-value-value">value</a>.</p>

   <p>The <code id="month-state-(type=month):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="month-state-(type=month):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="month-state-(type=month):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="month-state-(type=month):do-not-apply">do not
   apply</a> to the element:
   <code id="month-state-(type=month):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="month-state-(type=month):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="month-state-(type=month):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="month-state-(type=month):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="month-state-(type=month):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="month-state-(type=month):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="month-state-(type=month):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="month-state-(type=month):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="month-state-(type=month):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="month-state-(type=month):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="month-state-(type=month):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="month-state-(type=month):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="month-state-(type=month):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="month-state-(type=month):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="month-state-(type=month):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="month-state-(type=month):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="month-state-(type=month):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="month-state-(type=month):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="month-state-(type=month):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="month-state-(type=month):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="month-state-(type=month):attr-input-src"><a href="#attr-input-src">src</a></code>, and
   <code id="month-state-(type=month):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="month-state-(type=month):do-not-apply-2">do not apply</a> to the
   element:
   <code id="month-state-(type=month):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="month-state-(type=month):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="month-state-(type=month):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="month-state-(type=month):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>, and
   <code id="month-state-(type=month):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code> IDL attributes;
   <code id="month-state-(type=month):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="month-state-(type=month):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

  </div>


  <h6 id="week-state-(type=week)"><span class="secno">4.10.5.1.9</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Week</dfn> state (<code>type=week</code>)<a href="#week-state-(type=week)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/week" title="<input> elements of type week create input fields allowing easy entry of a year plus the ISO 8601 week number during that year (i.e., week 1 to 52 or 53).">Element/input/week</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>18+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="week-state-(type=week):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="week-state-(type=week):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#week-state-(type=week)" id="week-state-(type=week):week-state-(type=week)">Week</a> state, the rules in this section apply.</p>

  

  <p>The <code id="week-state-(type=week):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="week-state-(type=week):represents">represents</a> a control for setting the element's
  <a href="#concept-fe-value" id="week-state-(type=week):concept-fe-value">value</a> to a string representing a specific <a href="#concept-week" id="week-state-(type=week):concept-week">week</a>.</p>

  

  <p>If the element is <i id="week-state-(type=week):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the <a href="#concept-week" id="week-state-(type=week):concept-week-2">week</a> represented by its <a href="#concept-fe-value" id="week-state-(type=week):concept-fe-value-2">value</a>, as obtained by <a href="#parse-a-week-string" id="week-state-(type=week):parse-a-week-string">parsing a
  week</a> from it. User agents must not allow the user to set the <a href="#concept-fe-value" id="week-state-(type=week):concept-fe-value-3">value</a> to a non-empty string that is not a <a href="#valid-week-string" id="week-state-(type=week):valid-week-string">valid week
  string</a>. If the user agent provides a user interface for selecting a <a href="#concept-week" id="week-state-(type=week):concept-week-3">week</a>, then the <a href="#concept-fe-value" id="week-state-(type=week):concept-fe-value-4">value</a> must be set
  to a <a href="#valid-week-string" id="week-state-(type=week):valid-week-string-2">valid week string</a> representing the user's selection. User agents should allow
  the user to set the <a href="#concept-fe-value" id="week-state-(type=week):concept-fe-value-5">value</a> to the empty string.</p>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: While the user interface describes input that the user
  agent cannot convert to a <a href="#valid-week-string" id="week-state-(type=week):valid-week-string-3">valid week string</a>, the control is <a href="#suffering-from-bad-input" id="week-state-(type=week):suffering-from-bad-input">suffering from bad
  input</a>.</p>
  </div>

  

  <p class="note">See the <a href="#input-author-notes">introduction section</a> for a discussion of
  the difference between the input format and submission format for date, time, and number form
  controls, and the <a href="#input-impl-notes">implementation notes</a>
  regarding localization of form controls.</p>

  <p>The <code id="week-state-(type=week):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified and not empty, must
  have a value that is a <a href="#valid-week-string" id="week-state-(type=week):valid-week-string-4">valid week string</a>.</p> 

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="week-state-(type=week):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: If the <a href="#concept-fe-value" id="week-state-(type=week):concept-fe-value-6">value</a> of the element is not a <a href="#valid-week-string" id="week-state-(type=week):valid-week-string-5">valid week string</a>, then
  set it to the empty string instead.</p>
  </div>

  

  <p>The <code id="week-state-(type=week):attr-input-min"><a href="#attr-input-min">min</a></code> attribute, if specified, must have a value that is
  a <a href="#valid-week-string" id="week-state-(type=week):valid-week-string-6">valid week string</a>. The <code id="week-state-(type=week):attr-input-max"><a href="#attr-input-max">max</a></code> attribute, if
  specified, must have a value that is a <a href="#valid-week-string" id="week-state-(type=week):valid-week-string-7">valid week string</a>.</p>

  <p>The <code id="week-state-(type=week):attr-input-step"><a href="#attr-input-step">step</a></code> attribute is expressed in weeks. The <a href="#concept-input-step-scale" id="week-state-(type=week):concept-input-step-scale">step scale factor</a> is 604,800,000
  (which converts the weeks to milliseconds, as used in the other algorithms). The <a href="#concept-input-step-default" id="week-state-(type=week):concept-input-step-default">default step</a> is 1 week. The <a href="#concept-input-step-default-base" id="week-state-(type=week):concept-input-step-default-base">default step base</a> is −259,200,000 (the start
  of week 1970-W01).</p>

  

  <p>When the element is <a href="#suffering-from-a-step-mismatch" id="week-state-(type=week):suffering-from-a-step-mismatch">suffering from a step mismatch</a>, the user agent may round the
  element's <a href="#concept-fe-value" id="week-state-(type=week):concept-fe-value-7">value</a> to the nearest <a href="#concept-week" id="week-state-(type=week):concept-week-4">week</a> for which the element would not <a href="#suffering-from-a-step-mismatch" id="week-state-(type=week):suffering-from-a-step-mismatch-2">suffer from a step mismatch</a>.</p>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-number" id="week-state-(type=week):concept-input-value-string-number">algorithm to convert a string to a
  number</a>, given a string <var>input</var>, is as follows</strong>: If <a href="#parse-a-week-string" id="week-state-(type=week):parse-a-week-string-2">parsing a week string</a> from <var>input</var> results in
  an error, then return an error; otherwise, return the number of milliseconds elapsed from midnight
  UTC on the morning of 1970-01-01 (the time represented by the value "<code>1970-01-01T00:00:00.0Z</code>") to midnight UTC on the morning of the Monday of the
  parsed <a href="#concept-week" id="week-state-(type=week):concept-week-5">week</a>, ignoring leap seconds.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-number-string" id="week-state-(type=week):concept-input-value-number-string">algorithm to convert a number to a
  string</a>, given a number <var>input</var>, is as follows</strong>: Return a
  <a href="#valid-week-string" id="week-state-(type=week):valid-week-string-8">valid week string</a> that represents the <a href="#concept-week" id="week-state-(type=week):concept-week-6">week</a> that, in
  UTC, is current <var>input</var> milliseconds after midnight UTC on the morning of
  1970-01-01 (the time represented by the value "<code>1970-01-01T00:00:00.0Z</code>").</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-date" id="week-state-(type=week):concept-input-value-string-date">algorithm to convert a string to a
  <code>Date</code> object</a>, given a string <var>input</var>, is as follows</strong>: If <a href="#parse-a-week-string" id="week-state-(type=week):parse-a-week-string-3">parsing a week</a> from <var>input</var> results in an error, then
  return an error; otherwise, return <a href="#create-a-date-object" id="week-state-(type=week):create-a-date-object">a new <code>Date</code>
  object</a> representing midnight UTC on the morning of the Monday of the parsed <a href="#concept-week" id="week-state-(type=week):concept-week-7">week</a>.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-date-string" id="week-state-(type=week):concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</a>, given a <code id="week-state-(type=week):date"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object <var>input</var>, is
  as follows</strong>: Return a <a href="#valid-week-string" id="week-state-(type=week):valid-week-string-9">valid week string</a> that represents the <a href="#concept-week" id="week-state-(type=week):concept-week-8">week</a> current at the time represented by <var>input</var> in the UTC
  time zone.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The following common <code id="week-state-(type=week):the-input-element-3"><a href="#the-input-element">input</a></code> element content attributes, IDL attributes, and
   methods <a href="#concept-input-apply" id="week-state-(type=week):concept-input-apply">apply</a> to the element:
   <code id="week-state-(type=week):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="week-state-(type=week):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="week-state-(type=week):attr-input-max-2"><a href="#attr-input-max">max</a></code>,
   <code id="week-state-(type=week):attr-input-min-2"><a href="#attr-input-min">min</a></code>,
   <code id="week-state-(type=week):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="week-state-(type=week):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="week-state-(type=week):attr-input-step-2"><a href="#attr-input-step">step</a></code> content attributes;
   <code id="week-state-(type=week):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="week-state-(type=week):dom-input-value"><a href="#dom-input-value">value</a></code>,
   <code id="week-state-(type=week):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="week-state-(type=week):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="week-state-(type=week):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="week-state-(type=week):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="week-state-(type=week):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="week-state-(type=week):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-value" id="week-state-(type=week):dom-input-value-value">value</a>.</p>

   <p>The <code id="week-state-(type=week):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="week-state-(type=week):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="week-state-(type=week):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="week-state-(type=week):do-not-apply">do not apply</a> to the
   element:
   <code id="week-state-(type=week):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="week-state-(type=week):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="week-state-(type=week):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="week-state-(type=week):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="week-state-(type=week):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="week-state-(type=week):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="week-state-(type=week):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="week-state-(type=week):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="week-state-(type=week):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="week-state-(type=week):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="week-state-(type=week):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="week-state-(type=week):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="week-state-(type=week):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="week-state-(type=week):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="week-state-(type=week):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="week-state-(type=week):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="week-state-(type=week):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="week-state-(type=week):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="week-state-(type=week):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="week-state-(type=week):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="week-state-(type=week):attr-input-src"><a href="#attr-input-src">src</a></code>, and
   <code id="week-state-(type=week):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="week-state-(type=week):do-not-apply-2">do not apply</a> to the element:
   <code id="week-state-(type=week):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="week-state-(type=week):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="week-state-(type=week):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="week-state-(type=week):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>, and
   <code id="week-state-(type=week):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code> IDL attributes;
   <code id="week-state-(type=week):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="week-state-(type=week):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

  </div>


  <h6 id="time-state-(type=time)"><span class="secno">4.10.5.1.10</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Time</dfn> state (<code>type=time</code>)<a href="#time-state-(type=time)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time" title="<input> elements of type time create input fields designed to let the user easily enter a time (hours and minutes, and optionally seconds).">Element/input/time</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>10+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  

  <p>When an <code id="time-state-(type=time):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="time-state-(type=time):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#time-state-(type=time)" id="time-state-(type=time):time-state-(type=time)">Time</a> state, the rules in this section apply.</p>

  

  <p>The <code id="time-state-(type=time):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="time-state-(type=time):represents">represents</a> a control for setting the element's
  <a href="#concept-fe-value" id="time-state-(type=time):concept-fe-value">value</a> to a string representing a specific <a href="#concept-time" id="time-state-(type=time):concept-time">time</a>.</p>

  

  <p>If the element is <i id="time-state-(type=time):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the <a href="#concept-time" id="time-state-(type=time):concept-time-2">time</a> represented by its <a href="#concept-fe-value" id="time-state-(type=time):concept-fe-value-2">value</a>, as obtained by <a href="#parse-a-time-string" id="time-state-(type=time):parse-a-time-string">parsing a
  time</a> from it. User agents must not allow the user to set the <a href="#concept-fe-value" id="time-state-(type=time):concept-fe-value-3">value</a> to a non-empty string that is not a <a href="#valid-time-string" id="time-state-(type=time):valid-time-string">valid time
  string</a>. If the user agent provides a user interface for selecting a <a href="#concept-time" id="time-state-(type=time):concept-time-3">time</a>, then the <a href="#concept-fe-value" id="time-state-(type=time):concept-fe-value-4">value</a> must be set
  to a <a href="#valid-time-string" id="time-state-(type=time):valid-time-string-2">valid time string</a> representing the user's selection. User agents should allow
  the user to set the <a href="#concept-fe-value" id="time-state-(type=time):concept-fe-value-5">value</a> to the empty string.</p>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: While the user interface describes input that the user
  agent cannot convert to a <a href="#valid-time-string" id="time-state-(type=time):valid-time-string-3">valid time string</a>, the control is <a href="#suffering-from-bad-input" id="time-state-(type=time):suffering-from-bad-input">suffering from bad
  input</a>.</p>
  </div>

  

  <p class="note">See the <a href="#input-author-notes">introduction section</a> for a discussion of
  the difference between the input format and submission format for date, time, and number form
  controls, and the <a href="#input-impl-notes">implementation notes</a>
  regarding localization of form controls.</p>

  <p>The <code id="time-state-(type=time):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified and not empty, must
  have a value that is a <a href="#valid-time-string" id="time-state-(type=time):valid-time-string-4">valid time string</a>.</p> 

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="time-state-(type=time):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: If the <a href="#concept-fe-value" id="time-state-(type=time):concept-fe-value-6">value</a> of the element is not a <a href="#valid-time-string" id="time-state-(type=time):valid-time-string-5">valid time string</a>, then
  set it to the empty string instead.</p>
  </div>

  <p>The form control <a href="#has-a-periodic-domain" id="time-state-(type=time):has-a-periodic-domain">has a periodic domain</a>.</p>

  

  <p>The <code id="time-state-(type=time):attr-input-min"><a href="#attr-input-min">min</a></code> attribute, if specified, must have a value that is
  a <a href="#valid-time-string" id="time-state-(type=time):valid-time-string-6">valid time string</a>. The <code id="time-state-(type=time):attr-input-max"><a href="#attr-input-max">max</a></code> attribute, if
  specified, must have a value that is a <a href="#valid-time-string" id="time-state-(type=time):valid-time-string-7">valid time string</a>.</p>

  <p>The <code id="time-state-(type=time):attr-input-step"><a href="#attr-input-step">step</a></code> attribute is expressed in seconds. The <a href="#concept-input-step-scale" id="time-state-(type=time):concept-input-step-scale">step scale factor</a> is 1000 (which
  converts the seconds to milliseconds, as used in the other algorithms). The <a href="#concept-input-step-default" id="time-state-(type=time):concept-input-step-default">default step</a> is 60 seconds.</p>

  

  <p>When the element is <a href="#suffering-from-a-step-mismatch" id="time-state-(type=time):suffering-from-a-step-mismatch">suffering from a step mismatch</a>, the user agent may round the
  element's <a href="#concept-fe-value" id="time-state-(type=time):concept-fe-value-7">value</a> to the nearest <a href="#concept-time" id="time-state-(type=time):concept-time-4">time</a> for which the element would not <a href="#suffering-from-a-step-mismatch" id="time-state-(type=time):suffering-from-a-step-mismatch-2">suffer from a step mismatch</a>.</p>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-number" id="time-state-(type=time):concept-input-value-string-number">algorithm to convert a string to a
  number</a>, given a string <var>input</var>, is as follows</strong>: If <a href="#parse-a-time-string" id="time-state-(type=time):parse-a-time-string-2">parsing a time</a> from <var>input</var> results in an
  error, then return an error; otherwise, return the number of milliseconds elapsed from midnight to
  the parsed <a href="#concept-time" id="time-state-(type=time):concept-time-5">time</a> on a day with no time changes.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-number-string" id="time-state-(type=time):concept-input-value-number-string">algorithm to convert a number to a
  string</a>, given a number <var>input</var>, is as follows</strong>: Return a
  <a href="#valid-time-string" id="time-state-(type=time):valid-time-string-8">valid time string</a> that represents the <a href="#concept-time" id="time-state-(type=time):concept-time-6">time</a> that is
  <var>input</var> milliseconds after midnight on a day with no time changes.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-date" id="time-state-(type=time):concept-input-value-string-date">algorithm to convert a string to a
  <code>Date</code> object</a>, given a string <var>input</var>, is as
  follows</strong>: If <a href="#parse-a-time-string" id="time-state-(type=time):parse-a-time-string-3">parsing a time</a> from
  <var>input</var> results
  in an error, then return an error; otherwise, return <a href="#create-a-date-object" id="time-state-(type=time):create-a-date-object">a new
  <code>Date</code> object</a> representing the parsed <a href="#concept-time" id="time-state-(type=time):concept-time-7">time</a> in
  UTC on 1970-01-01.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-date-string" id="time-state-(type=time):concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</a>, given a <code id="time-state-(type=time):date"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object <var>input</var>, is
  as follows</strong>: Return a <a href="#valid-time-string" id="time-state-(type=time):valid-time-string-9">valid time string</a> that represents the UTC <a href="#concept-time" id="time-state-(type=time):concept-time-8">time</a> component that is represented by <var>input</var>.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The following common <code id="time-state-(type=time):the-input-element-3"><a href="#the-input-element">input</a></code> element content attributes, IDL attributes, and
   methods <a href="#concept-input-apply" id="time-state-(type=time):concept-input-apply">apply</a> to the element:
   <code id="time-state-(type=time):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="time-state-(type=time):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="time-state-(type=time):attr-input-max-2"><a href="#attr-input-max">max</a></code>,
   <code id="time-state-(type=time):attr-input-min-2"><a href="#attr-input-min">min</a></code>,
   <code id="time-state-(type=time):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="time-state-(type=time):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="time-state-(type=time):attr-input-step-2"><a href="#attr-input-step">step</a></code> content attributes;
   <code id="time-state-(type=time):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="time-state-(type=time):dom-input-value"><a href="#dom-input-value">value</a></code>,
   <code id="time-state-(type=time):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="time-state-(type=time):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="time-state-(type=time):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="time-state-(type=time):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="time-state-(type=time):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="time-state-(type=time):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-value" id="time-state-(type=time):dom-input-value-value">value</a>.</p>

   <p>The <code id="time-state-(type=time):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="time-state-(type=time):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="time-state-(type=time):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="time-state-(type=time):do-not-apply">do not apply</a> to the
   element:
   <code id="time-state-(type=time):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="time-state-(type=time):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="time-state-(type=time):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="time-state-(type=time):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="time-state-(type=time):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="time-state-(type=time):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="time-state-(type=time):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="time-state-(type=time):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="time-state-(type=time):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="time-state-(type=time):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="time-state-(type=time):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="time-state-(type=time):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="time-state-(type=time):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="time-state-(type=time):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="time-state-(type=time):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="time-state-(type=time):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="time-state-(type=time):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="time-state-(type=time):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="time-state-(type=time):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="time-state-(type=time):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="time-state-(type=time):attr-input-src"><a href="#attr-input-src">src</a></code>, and
   <code id="time-state-(type=time):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="time-state-(type=time):do-not-apply-2">do not apply</a> to the element:
   <code id="time-state-(type=time):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="time-state-(type=time):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="time-state-(type=time):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="time-state-(type=time):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>, and
   <code id="time-state-(type=time):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code> IDL attributes;
   <code id="time-state-(type=time):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="time-state-(type=time):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

  </div>


  <h6 id="local-date-and-time-state-(type=datetime-local)"><span class="secno">4.10.5.1.11</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Local Date and Time</dfn> state (<code>type=datetime-local</code>)<a href="#local-date-and-time-state-(type=datetime-local)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local" title="<input> elements of type datetime-local create input controls that let the user easily enter both a date and a time, including the year, month, and day as well as the time in hours and minutes.">Element/input/datetime-local</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>93+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  

  <p>When an <code id="local-date-and-time-state-(type=datetime-local):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="local-date-and-time-state-(type=datetime-local):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#local-date-and-time-state-(type=datetime-local)" id="local-date-and-time-state-(type=datetime-local):local-date-and-time-state-(type=datetime-local)">Local Date and Time</a> state, the rules in
  this section apply.</p>

  

  <p>The <code id="local-date-and-time-state-(type=datetime-local):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="local-date-and-time-state-(type=datetime-local):represents">represents</a> a control for setting the element's
  <a href="#concept-fe-value" id="local-date-and-time-state-(type=datetime-local):concept-fe-value">value</a> to a string representing a <a href="#concept-datetime-local" id="local-date-and-time-state-(type=datetime-local):concept-datetime-local">local date and time</a>, with no time-zone offset
  information.</p>

  

  <p>If the element is <i id="local-date-and-time-state-(type=datetime-local):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the <a href="#concept-datetime-local" id="local-date-and-time-state-(type=datetime-local):concept-datetime-local-2">date and time</a> represented by its
  <a href="#concept-fe-value" id="local-date-and-time-state-(type=datetime-local):concept-fe-value-2">value</a>, as obtained by <a href="#parse-a-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):parse-a-local-date-and-time-string">parsing a date and time</a> from it. User agents must not allow the user to set
  the <a href="#concept-fe-value" id="local-date-and-time-state-(type=datetime-local):concept-fe-value-3">value</a> to a non-empty string that is not a <a href="#valid-normalised-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):valid-normalised-local-date-and-time-string">valid
  normalized local date and time string</a>. If the user agent provides a user interface for
  selecting a <a href="#concept-datetime-local" id="local-date-and-time-state-(type=datetime-local):concept-datetime-local-3">local date and time</a>, then the <a href="#concept-fe-value" id="local-date-and-time-state-(type=datetime-local):concept-fe-value-4">value</a> must be set to a <a href="#valid-normalised-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):valid-normalised-local-date-and-time-string-2">valid normalized local date and time
  string</a> representing the user's selection. User agents should allow the user to set the
  <a href="#concept-fe-value" id="local-date-and-time-state-(type=datetime-local):concept-fe-value-5">value</a> to the empty string.</p>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: While the user interface describes input that the user
  agent cannot convert to a <a href="#valid-normalised-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):valid-normalised-local-date-and-time-string-3">valid normalized local date and time string</a>, the control is
  <a href="#suffering-from-bad-input" id="local-date-and-time-state-(type=datetime-local):suffering-from-bad-input">suffering from bad input</a>.</p>
  </div>

  

  <p class="note">See the <a href="#input-author-notes">introduction section</a> for a discussion of
  the difference between the input format and submission format for date, time, and number form
  controls, and the <a href="#input-impl-notes">implementation notes</a>
  regarding localization of form controls.</p>

  <p>The <code id="local-date-and-time-state-(type=datetime-local):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified and not empty, must
  have a value that is a <a href="#valid-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):valid-local-date-and-time-string">valid local date and time string</a>.</p> 

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="local-date-and-time-state-(type=datetime-local):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: If the <a href="#concept-fe-value" id="local-date-and-time-state-(type=datetime-local):concept-fe-value-6">value</a> of the element is a <a href="#valid-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):valid-local-date-and-time-string-2">valid local date and time
  string</a>, then set it to a <a href="#valid-normalised-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):valid-normalised-local-date-and-time-string-4">valid normalized local date and time string</a>
  representing the same date and time; otherwise, set it to the empty string instead.</p>
  </div>

  

  <p>The <code id="local-date-and-time-state-(type=datetime-local):attr-input-min"><a href="#attr-input-min">min</a></code> attribute, if specified, must have a value that is
  a <a href="#valid-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):valid-local-date-and-time-string-3">valid local date and time string</a>. The <code id="local-date-and-time-state-(type=datetime-local):attr-input-max"><a href="#attr-input-max">max</a></code>
  attribute, if specified, must have a value that is a <a href="#valid-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):valid-local-date-and-time-string-4">valid local date and time
  string</a>.</p>

  <p>The <code id="local-date-and-time-state-(type=datetime-local):attr-input-step"><a href="#attr-input-step">step</a></code> attribute is expressed in seconds. The <a href="#concept-input-step-scale" id="local-date-and-time-state-(type=datetime-local):concept-input-step-scale">step scale factor</a> is 1000 (which
  converts the seconds to milliseconds, as used in the other algorithms). The <a href="#concept-input-step-default" id="local-date-and-time-state-(type=datetime-local):concept-input-step-default">default step</a> is 60 seconds.</p>

  

  <p>When the element is <a href="#suffering-from-a-step-mismatch" id="local-date-and-time-state-(type=datetime-local):suffering-from-a-step-mismatch">suffering from a step mismatch</a>, the user agent may round the
  element's <a href="#concept-fe-value" id="local-date-and-time-state-(type=datetime-local):concept-fe-value-7">value</a> to the nearest <a href="#concept-datetime-local" id="local-date-and-time-state-(type=datetime-local):concept-datetime-local-4">local date and time</a> for which the element would not <a href="#suffering-from-a-step-mismatch" id="local-date-and-time-state-(type=datetime-local):suffering-from-a-step-mismatch-2">suffer from a step mismatch</a>.</p>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-number" id="local-date-and-time-state-(type=datetime-local):concept-input-value-string-number">algorithm to convert a string to a
  number</a>, given a string <var>input</var>, is as follows</strong>: If <a href="#parse-a-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):parse-a-local-date-and-time-string-2">parsing a date and time</a> from <var>input</var> results in an error, then return an error; otherwise, return the number of
  milliseconds elapsed from midnight on the morning of 1970-01-01 (the time represented by the value
  "<code>1970-01-01T00:00:00.0</code>") to the parsed <a href="#concept-datetime-local" id="local-date-and-time-state-(type=datetime-local):concept-datetime-local-5">local date and time</a>, ignoring leap seconds.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-number-string" id="local-date-and-time-state-(type=datetime-local):concept-input-value-number-string">algorithm to convert a number to a
  string</a>, given a number <var>input</var>, is as follows</strong>: Return a
  <a href="#valid-normalised-local-date-and-time-string" id="local-date-and-time-state-(type=datetime-local):valid-normalised-local-date-and-time-string-5">valid normalized local date and time string</a> that represents the date and time that is
  <var>input</var> milliseconds after midnight on the morning of 1970-01-01 (the time
  represented by the value "<code>1970-01-01T00:00:00.0</code>").</p>
  </div>

  

  <p class="note">See <a href="#only-contemporary-times">the note on historical dates</a> in the
  <a href="#date-state-(type=date)" id="local-date-and-time-state-(type=datetime-local):date-state-(type=date)">Date</a> state section.</p>

  <div class="bookkeeping">

   <p>The following common <code id="local-date-and-time-state-(type=datetime-local):the-input-element-3"><a href="#the-input-element">input</a></code> element content
   attributes, IDL attributes, and methods <a href="#concept-input-apply" id="local-date-and-time-state-(type=datetime-local):concept-input-apply">apply</a> to the element:
   <code id="local-date-and-time-state-(type=datetime-local):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-max-2"><a href="#attr-input-max">max</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-min-2"><a href="#attr-input-min">min</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-step-2"><a href="#attr-input-step">step</a></code> content attributes;
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-value"><a href="#dom-input-value">value</a></code>, and
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="local-date-and-time-state-(type=datetime-local):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is
   in mode <a href="#dom-input-value-value" id="local-date-and-time-state-(type=datetime-local):dom-input-value-value">value</a>.</p>

   <p>The <code id="local-date-and-time-state-(type=datetime-local):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="local-date-and-time-state-(type=datetime-local):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="local-date-and-time-state-(type=datetime-local):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="local-date-and-time-state-(type=datetime-local):do-not-apply">do not
   apply</a> to the element:
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-src"><a href="#attr-input-src">src</a></code>, and
   <code id="local-date-and-time-state-(type=datetime-local):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="local-date-and-time-state-(type=datetime-local):do-not-apply-2">do not apply</a> to the
   element:
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, and
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code> IDL attributes;
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

  </div>

  <div class="example">

   <p>The following example shows part of a flight booking application. The application uses an
   <code id="local-date-and-time-state-(type=datetime-local):the-input-element-4"><a href="#the-input-element">input</a></code> element with its <code id="local-date-and-time-state-(type=datetime-local):attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute set to
   <code id="local-date-and-time-state-(type=datetime-local):local-date-and-time-state-(type=datetime-local)-2"><a href="#local-date-and-time-state-(type=datetime-local)">datetime-local</a></code>, and it then interprets the
   given date and time in the time zone of the selected airport.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Destination<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Airport: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">to</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">airports</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Departure time: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">datetime-local</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">totime</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">3600</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">airports</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">ATL</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Atlanta"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">MEM</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Memphis"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">LHR</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"London Heathrow"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">LAX</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Los Angeles"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">FRA</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Frankfurt"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h6 id="number-state-(type=number)"><span class="secno">4.10.5.1.12</span> <dfn data-dfn-for="input" id="number-state" data-dfn-type="element-state">Number</dfn> state (<code>type=number</code>)<a href="#number-state-(type=number)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number" title="<input> elements of type number are used to let the user enter a number. They include built-in validation to reject non-numerical entries.">Element/input/number</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>7+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="number-state-(type=number):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="number-state-(type=number):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#number-state-(type=number)" id="number-state-(type=number):number-state-(type=number)">Number</a> state, the rules in this section apply.</p>

  

  <p>The <code id="number-state-(type=number):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="number-state-(type=number):represents">represents</a> a control for setting the element's
  <a href="#concept-fe-value" id="number-state-(type=number):concept-fe-value">value</a> to a string representing a number.</p>

  

  <p>If the element is <i id="number-state-(type=number):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the number represented by its <a href="#concept-fe-value" id="number-state-(type=number):concept-fe-value-2">value</a>, as
  obtained from applying the <a href="#rules-for-parsing-floating-point-number-values" id="number-state-(type=number):rules-for-parsing-floating-point-number-values">rules for parsing floating-point number values</a> to it. User
  agents must not allow the user to set the <a href="#concept-fe-value" id="number-state-(type=number):concept-fe-value-3">value</a> to a
  non-empty string that is not a <a href="#valid-floating-point-number" id="number-state-(type=number):valid-floating-point-number">valid floating-point number</a>. If the user agent
  provides a user interface for selecting a number, then the <a href="#concept-fe-value" id="number-state-(type=number):concept-fe-value-4">value</a> must be set to the <a href="#best-representation-of-the-number-as-a-floating-point-number" id="number-state-(type=number):best-representation-of-the-number-as-a-floating-point-number">best representation of the number representing the user's
  selection as a floating-point number</a>. User agents should allow the user to set the <a href="#concept-fe-value" id="number-state-(type=number):concept-fe-value-5">value</a> to the empty string.</p>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: While the user interface describes input that the user
  agent cannot convert to a <a href="#valid-floating-point-number" id="number-state-(type=number):valid-floating-point-number-2">valid floating-point number</a>, the control is <a href="#suffering-from-bad-input" id="number-state-(type=number):suffering-from-bad-input">suffering
  from bad input</a>.</p>
  </div>

  

  <p class="note">This specification does not define what user interface user agents are to use;
  user agent vendors are encouraged to consider what would best serve their users' needs. For
  example, a user agent in Persian or Arabic markets might support Persian and Arabic numeric input
  (converting it to the format required for submission as described above). Similarly, a user agent
  designed for Romans might display the value in Roman numerals rather than in decimal; or (more
  realistically) a user agent designed for the French market might display the value with
  apostrophes between thousands and commas before the decimals, and allow the user to enter a value
  in that manner, internally converting it to the submission format described above.</p>

  <p>The <code id="number-state-(type=number):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified and not empty, must
  have a value that is a <a href="#valid-floating-point-number" id="number-state-(type=number):valid-floating-point-number-3">valid floating-point number</a>.</p> 

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="number-state-(type=number):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: If the <a href="#concept-fe-value" id="number-state-(type=number):concept-fe-value-6">value</a> of the element is not a <a href="#valid-floating-point-number" id="number-state-(type=number):valid-floating-point-number-4">valid floating-point
  number</a>, then set it to the empty string instead.</p>
  </div>

  

  <p>The <code id="number-state-(type=number):attr-input-min"><a href="#attr-input-min">min</a></code> attribute, if specified, must have a value that is
  a <a href="#valid-floating-point-number" id="number-state-(type=number):valid-floating-point-number-5">valid floating-point number</a>. The <code id="number-state-(type=number):attr-input-max"><a href="#attr-input-max">max</a></code> attribute,
  if specified, must have a value that is a <a href="#valid-floating-point-number" id="number-state-(type=number):valid-floating-point-number-6">valid floating-point number</a>.</p>

  <p>The <a href="#concept-input-step-scale" id="number-state-(type=number):concept-input-step-scale">step scale factor</a> is
  1. The <a href="#concept-input-step-default" id="number-state-(type=number):concept-input-step-default">default step</a> is 1 (allowing only
  integers to be selected by the user, unless the <a href="#concept-input-min-zero" id="number-state-(type=number):concept-input-min-zero">step
  base</a> has a non-integer value).</p>

  

  <p>When the element is <a href="#suffering-from-a-step-mismatch" id="number-state-(type=number):suffering-from-a-step-mismatch">suffering from a step mismatch</a>, the user agent may round the
  element's <a href="#concept-fe-value" id="number-state-(type=number):concept-fe-value-7">value</a> to the nearest number for which the element
  would not <a href="#suffering-from-a-step-mismatch" id="number-state-(type=number):suffering-from-a-step-mismatch-2">suffer from a step mismatch</a>. If
  there are two such numbers, user agents are encouraged to pick the one nearest positive
  infinity.</p>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-number" id="number-state-(type=number):concept-input-value-string-number">algorithm to convert a string to a
  number</a>, given a string <var>input</var>, is as follows</strong>: If applying the
  <a href="#rules-for-parsing-floating-point-number-values" id="number-state-(type=number):rules-for-parsing-floating-point-number-values-2">rules for parsing floating-point number values</a> to <var>input</var> results
  in an error, then return an error; otherwise, return the resulting number.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-number-string" id="number-state-(type=number):concept-input-value-number-string">algorithm to convert a number to a
  string</a>, given a number <var>input</var>, is as follows</strong>: Return a
  <a href="#valid-floating-point-number" id="number-state-(type=number):valid-floating-point-number-7">valid floating-point number</a> that represents <var>input</var>.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The following common <code id="number-state-(type=number):the-input-element-3"><a href="#the-input-element">input</a></code> element content attributes, IDL attributes, and
   methods <a href="#concept-input-apply" id="number-state-(type=number):concept-input-apply">apply</a> to the element:
   <code id="number-state-(type=number):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="number-state-(type=number):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="number-state-(type=number):attr-input-max-2"><a href="#attr-input-max">max</a></code>,
   <code id="number-state-(type=number):attr-input-min-2"><a href="#attr-input-min">min</a></code>,
   <code id="number-state-(type=number):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="number-state-(type=number):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="number-state-(type=number):attr-input-required"><a href="#attr-input-required">required</a></code>, and
   <code id="number-state-(type=number):attr-input-step"><a href="#attr-input-step">step</a></code> content attributes;
   <code id="number-state-(type=number):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="number-state-(type=number):dom-input-value"><a href="#dom-input-value">value</a></code>, and
   <code id="number-state-(type=number):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="number-state-(type=number):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="number-state-(type=number):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="number-state-(type=number):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="number-state-(type=number):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-value" id="number-state-(type=number):dom-input-value-value">value</a>.</p>

   <p>The <code id="number-state-(type=number):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="number-state-(type=number):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="number-state-(type=number):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="number-state-(type=number):do-not-apply">do not apply</a> to the
   element:
   <code id="number-state-(type=number):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="number-state-(type=number):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="number-state-(type=number):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="number-state-(type=number):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="number-state-(type=number):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="number-state-(type=number):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="number-state-(type=number):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="number-state-(type=number):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="number-state-(type=number):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="number-state-(type=number):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="number-state-(type=number):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="number-state-(type=number):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="number-state-(type=number):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="number-state-(type=number):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="number-state-(type=number):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="number-state-(type=number):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="number-state-(type=number):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="number-state-(type=number):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="number-state-(type=number):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="number-state-(type=number):attr-input-src"><a href="#attr-input-src">src</a></code>, and
   <code id="number-state-(type=number):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="number-state-(type=number):do-not-apply-2">do not apply</a> to the element:
   <code id="number-state-(type=number):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="number-state-(type=number):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="number-state-(type=number):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="number-state-(type=number):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="number-state-(type=number):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, and
   <code id="number-state-(type=number):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code> IDL attributes;
   <code id="number-state-(type=number):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="number-state-(type=number):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

  </div>

  <div class="example">

   <p>Here is an example of using a numeric input control:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->How much do you want to charge? $<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">0.01</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">price</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

   <p>As described above, a user agent might support numeric input in the user's local format,
   converting it to the format required for submission as described above. This might include
   handling grouping separators (as in "872,000,000,000") and various decimal separators (such as
   "3,99" vs "3.99") or using local digits (such as those in Arabic, Devanagari, Persian, and
   Thai).</p>

  </div>

  <p id="when-number-is-not-appropriate" class="note"><a href="#when-number-is-not-appropriate" class="self-link"></a>The <code>type=number</code> state
  is not appropriate for input that happens to only consist of numbers but isn't strictly speaking a
  number. For example, it would be inappropriate for credit card numbers or US postal codes. A
  simple way of determining whether to use <code>type=number</code> is to consider whether
  it would make sense for the input control to have a spinbox interface (e.g. with "up" and "down"
  arrows). Getting a credit card number wrong by 1 in the last digit isn't a minor mistake, it's as
  wrong as getting every digit incorrect. So it would not make sense for the user to select a credit
  card number using "up" and "down" buttons. When a spinbox interface is not appropriate, <code>type=text</code> is probably the right choice (possibly with an <code id="number-state-(type=number):attr-inputmode"><a href="#attr-inputmode">inputmode</a></code> or <code id="number-state-(type=number):attr-input-pattern-2"><a href="#attr-input-pattern">pattern</a></code>
  attribute).</p>



  <h6 id="range-state-(type=range)"><span class="secno">4.10.5.1.13</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Range</dfn> state (<code>type=range</code>)<a href="#range-state-(type=range)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range" title="<input> elements of type range let the user specify a numeric value which must be no less than a given value, and no more than another given value. The precise value, however, is not considered important. This is typically represented using a slider or dial control rather than a text entry box like the number input type.">Element/input/range</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>23+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>52+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>57+</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  

  <p>When an <code id="range-state-(type=range):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="range-state-(type=range):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#range-state-(type=range)" id="range-state-(type=range):range-state-(type=range)">Range</a> state, the rules in this section apply.</p>

  

  <p>The <code id="range-state-(type=range):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="range-state-(type=range):represents">represents</a> a control for setting the element's
  <a href="#concept-fe-value" id="range-state-(type=range):concept-fe-value">value</a> to a string representing a number, but with the
  caveat that the exact value is not important, letting UAs provide a simpler interface than they
  do for the <a href="#number-state-(type=number)" id="range-state-(type=range):number-state-(type=number)">Number</a> state.</p>

  

  <p>If the element is <i id="range-state-(type=range):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the number represented by its <a href="#concept-fe-value" id="range-state-(type=range):concept-fe-value-2">value</a>, as
  obtained from applying the <a href="#rules-for-parsing-floating-point-number-values" id="range-state-(type=range):rules-for-parsing-floating-point-number-values">rules for parsing floating-point number values</a> to it.
  User agents must not allow the user to set the <a href="#concept-fe-value" id="range-state-(type=range):concept-fe-value-3">value</a> to a
  string that is not a <a href="#valid-floating-point-number" id="range-state-(type=range):valid-floating-point-number">valid floating-point number</a>. If the user agent provides a user
  interface for selecting a number, then the <a href="#concept-fe-value" id="range-state-(type=range):concept-fe-value-4">value</a> must be
  set to a <a href="#best-representation-of-the-number-as-a-floating-point-number" id="range-state-(type=range):best-representation-of-the-number-as-a-floating-point-number">best
  representation of the number representing the user's selection as a floating-point
  number</a>. User agents must not allow the user to set the <a href="#concept-fe-value" id="range-state-(type=range):concept-fe-value-5">value</a> to the empty string.</p>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: While the user interface describes input that the
  user agent cannot convert to a <a href="#valid-floating-point-number" id="range-state-(type=range):valid-floating-point-number-2">valid floating-point number</a>, the control is
  <a href="#suffering-from-bad-input" id="range-state-(type=range):suffering-from-bad-input">suffering from bad input</a>.</p>
  </div>

  

  <p>The <code id="range-state-(type=range):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified, must have a value
  that is a <a href="#valid-floating-point-number" id="range-state-(type=range):valid-floating-point-number-3">valid floating-point number</a>.</p> 

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="range-state-(type=range):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: If the <a href="#concept-fe-value" id="range-state-(type=range):concept-fe-value-6">value</a> of the element is not a <a href="#valid-floating-point-number" id="range-state-(type=range):valid-floating-point-number-4">valid floating-point
  number</a>, then set it to the <a href="#best-representation-of-the-number-as-a-floating-point-number" id="range-state-(type=range):best-representation-of-the-number-as-a-floating-point-number-2">best representation, as a floating-point number</a>, of the <a href="#concept-input-value-default-range" id="range-state-(type=range):concept-input-value-default-range">default value</a>.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn id="concept-input-value-default-range">default value</dfn> is the <a href="#concept-input-min" id="range-state-(type=range):concept-input-min">minimum</a> plus half the difference between the <a href="#concept-input-min" id="range-state-(type=range):concept-input-min-2">minimum</a> and the <a href="#concept-input-max" id="range-state-(type=range):concept-input-max">maximum</a>, unless the <a href="#concept-input-max" id="range-state-(type=range):concept-input-max-2">maximum</a> is less than the <a href="#concept-input-min" id="range-state-(type=range):concept-input-min-3">minimum</a>, in which case the <a href="#concept-input-value-default-range" id="range-state-(type=range):concept-input-value-default-range-2">default value</a> is the <a href="#concept-input-min" id="range-state-(type=range):concept-input-min-4">minimum</a>.</p>
  </div>

  

  <div data-algorithm="">
  <p>When the element is <a href="#suffering-from-an-underflow" id="range-state-(type=range):suffering-from-an-underflow">suffering from an underflow</a>, the user agent must set the
  element's <a href="#concept-fe-value" id="range-state-(type=range):concept-fe-value-7">value</a> to the <a href="#best-representation-of-the-number-as-a-floating-point-number" id="range-state-(type=range):best-representation-of-the-number-as-a-floating-point-number-3">best representation, as a floating-point
  number</a>, of the <a href="#concept-input-min" id="range-state-(type=range):concept-input-min-5">minimum</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When the element is <a href="#suffering-from-an-overflow" id="range-state-(type=range):suffering-from-an-overflow">suffering from an overflow</a>, if the <a href="#concept-input-max" id="range-state-(type=range):concept-input-max-3">maximum</a> is not less than the <a href="#concept-input-min" id="range-state-(type=range):concept-input-min-6">minimum</a>, the user agent must set the element's <a href="#concept-fe-value" id="range-state-(type=range):concept-fe-value-8">value</a> to a <a href="#valid-floating-point-number" id="range-state-(type=range):valid-floating-point-number-5">valid floating-point number</a> that
  represents the <a href="#concept-input-max" id="range-state-(type=range):concept-input-max-4">maximum</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When the element is <a href="#suffering-from-a-step-mismatch" id="range-state-(type=range):suffering-from-a-step-mismatch">suffering from a step mismatch</a>, the user agent must round
  the element's <a href="#concept-fe-value" id="range-state-(type=range):concept-fe-value-9">value</a> to the nearest number for which the
  element would not <a href="#suffering-from-a-step-mismatch" id="range-state-(type=range):suffering-from-a-step-mismatch-2">suffer from a step
  mismatch</a>, and which is greater than or equal to the <a href="#concept-input-min" id="range-state-(type=range):concept-input-min-7">minimum</a>, and, if the <a href="#concept-input-max" id="range-state-(type=range):concept-input-max-5">maximum</a> is not less than the <a href="#concept-input-min" id="range-state-(type=range):concept-input-min-8">minimum</a>, which is less than or equal to the <a href="#concept-input-max" id="range-state-(type=range):concept-input-max-6">maximum</a>, if there is a number that matches these constraints.
  If two numbers match these constraints, then user agents must use the one nearest to positive
  infinity.</p>
  </div>

  <p class="example">For example, the markup
  <code>&lt;input&nbsp;type="range"&nbsp;min=0&nbsp;max=100&nbsp;step=20&nbsp;value=50&gt;</code>
  results in a range control whose initial value is 60.</p>

  

  <div class="example">

   <p>Here is an example of a range control using an autocomplete list with the <code id="range-state-(type=range):attr-input-list"><a href="#attr-input-list">list</a></code> attribute. This could be useful if there are values along
   the full range of the control that are especially important, such as preconfigured light levels
   or typical speed limits in a range control used as a speed control. The following markup
   fragment:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"range"</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"-100"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"100"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"0"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"10"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"power"</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">"powers"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"powers"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"0"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"-30"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"30"</c-><c- p="">&gt;</c->
<span class="bad"> <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"++50"</c-><c- p="">&gt;</c-></span>
<c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c-></code></pre>

   <p>...with the following style sheet applied:</p>

   <pre><code class="css"><c- f="">input </c-><c- p="">{</c-> <c- k="">writing-mode</c-><c- p="">:</c-> vertical-lr<c- p="">;</c-> <c- k="">height</c-><c- p="">:</c-> <c- m="">75</c-><c- l="">px</c-><c- p="">;</c-> <c- k="">width</c-><c- p="">:</c-> <c- m="">49</c-><c- l="">px</c-><c- p="">;</c-> <c- k="">background</c-><c- p="">:</c-> #D5CCBB<c- p="">;</c-> <c- k="">color</c-><c- p="">:</c-> black<c- p="">;</c-> <c- p="">}</c-></code></pre>

   <p>...might render as:</p>

   <p><img src="/images/sample-range.png" width="49" alt="A vertical slider control whose primary color is black and whose background color is beige, with the slider having five tick marks, one long one at each extremity, and three short ones clustered around the midpoint." height="75">

   </p><p>Note how the UA determined the orientation of the control from the ratio of the
   style-sheet-specified height and width properties. The colors were similarly derived from the
   style sheet. The tick marks, however, were derived from the markup. In particular, the <code id="range-state-(type=range):attr-input-step"><a href="#attr-input-step">step</a></code> attribute has not affected the placement of tick marks,
   the UA deciding to only use the author-specified completion values and then adding longer tick
   marks at the extremes.</p>

   <p>Note also how the invalid value <code>++50</code> was ignored.</p>

  </div>

  <div class="example">

   <p>For another example, consider the following markup fragment:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">x</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">range</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">100</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">700</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">9.09090909</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">509.090909</c-><c- p="">&gt;</c-></code></pre>

   <p>A user agent could display in a variety of ways, for instance:</p>

   <p><img src="/images/sample-range-2a.png" width="231" alt="As a dial." height="57"></p>

   <p>Or, alternatively, for instance:</p>

   <p><img src="/images/sample-range-2b.png" width="445" alt="As a long horizontal slider with tick marks." height="56"></p>

   <p>The user agent could pick which one to display based on the dimensions given in the style
   sheet. This would allow it to maintain the same resolution for the tick marks, despite the
   differences in width.</p>

  </div>

  <div class="example">

   <p>Finally, here is an example of a range control with two labeled values:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"range"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"a"</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">"a-values"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"a-values"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"10"</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Low"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"90"</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"High"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c-></code></pre>

   <p>With styles that make the control draw vertically, it might look as follows:</p>

   <p><img src="/images/sample-range-labels.png" width="103" alt="A vertical slider control with two tick marks, one near the top labeled 'High', and one near the bottom labeled 'Low'." height="164">

  </p></div>

  <p class="note">In this state, the range and step constraints are enforced even during user input,
  and there is no way to set the value to the empty string.</p>

  <p>The <code id="range-state-(type=range):attr-input-min"><a href="#attr-input-min">min</a></code> attribute, if specified, must have a value that is
  a <a href="#valid-floating-point-number" id="range-state-(type=range):valid-floating-point-number-6">valid floating-point number</a>. The <a href="#concept-input-min-default" id="range-state-(type=range):concept-input-min-default">default
  minimum</a> is 0. The <code id="range-state-(type=range):attr-input-max"><a href="#attr-input-max">max</a></code> attribute, if specified, must
  have a value that is a <a href="#valid-floating-point-number" id="range-state-(type=range):valid-floating-point-number-7">valid floating-point number</a>. The <a href="#concept-input-max-default" id="range-state-(type=range):concept-input-max-default">default maximum</a> is 100.</p>

  <p>The <a href="#concept-input-step-scale" id="range-state-(type=range):concept-input-step-scale">step scale factor</a> is
  1. The <a href="#concept-input-step-default" id="range-state-(type=range):concept-input-step-default">default step</a> is 1 (allowing only
  integers, unless the <code id="range-state-(type=range):attr-input-min-2"><a href="#attr-input-min">min</a></code> attribute has a non-integer
  value).</p>

  

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-string-number" id="range-state-(type=range):concept-input-value-string-number">algorithm to convert a string to a
  number</a>, given a string <var>input</var>, is as follows</strong>: If applying the
  <a href="#rules-for-parsing-floating-point-number-values" id="range-state-(type=range):rules-for-parsing-floating-point-number-values-2">rules for parsing floating-point number values</a> to <var>input</var> results
  in an error, then return an error; otherwise, return the resulting number.</p>
  </div>

  <div data-algorithm="">
  <p><strong>The <a href="#concept-input-value-number-string" id="range-state-(type=range):concept-input-value-number-string">algorithm to convert a number to a
  string</a>, given a number <var>input</var>, is as follows</strong>: Return the <a href="#best-representation-of-the-number-as-a-floating-point-number" id="range-state-(type=range):best-representation-of-the-number-as-a-floating-point-number-4">best representation, as a
  floating-point number</a>, of <var>input</var>.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The following common <code id="range-state-(type=range):the-input-element-3"><a href="#the-input-element">input</a></code> element content attributes, IDL attributes, and
   methods <a href="#concept-input-apply" id="range-state-(type=range):concept-input-apply">apply</a> to the element:
   <code id="range-state-(type=range):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="range-state-(type=range):attr-input-list-2"><a href="#attr-input-list">list</a></code>,
   <code id="range-state-(type=range):attr-input-max-2"><a href="#attr-input-max">max</a></code>,
   <code id="range-state-(type=range):attr-input-min-3"><a href="#attr-input-min">min</a></code>, and
   <code id="range-state-(type=range):attr-input-step-2"><a href="#attr-input-step">step</a></code> content attributes;
   <code id="range-state-(type=range):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="range-state-(type=range):dom-input-value"><a href="#dom-input-value">value</a></code>, and
   <code id="range-state-(type=range):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="range-state-(type=range):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code> and
   <code id="range-state-(type=range):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="range-state-(type=range):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-value" id="range-state-(type=range):dom-input-value-value">value</a>.</p>

   <p>The <code id="range-state-(type=range):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="range-state-(type=range):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="range-state-(type=range):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="range-state-(type=range):do-not-apply">do not apply</a> to the
   element:
   <code id="range-state-(type=range):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="range-state-(type=range):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="range-state-(type=range):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="range-state-(type=range):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="range-state-(type=range):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="range-state-(type=range):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="range-state-(type=range):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="range-state-(type=range):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="range-state-(type=range):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="range-state-(type=range):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="range-state-(type=range):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="range-state-(type=range):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="range-state-(type=range):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="range-state-(type=range):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="range-state-(type=range):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="range-state-(type=range):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="range-state-(type=range):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="range-state-(type=range):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="range-state-(type=range):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="range-state-(type=range):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="range-state-(type=range):attr-input-required"><a href="#attr-input-required">required</a></code>,
   <code id="range-state-(type=range):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="range-state-(type=range):attr-input-src"><a href="#attr-input-src">src</a></code>, and
   <code id="range-state-(type=range):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="range-state-(type=range):do-not-apply-2">do not apply</a> to the element:
   <code id="range-state-(type=range):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="range-state-(type=range):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="range-state-(type=range):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="range-state-(type=range):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="range-state-(type=range):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, and
   <code id="range-state-(type=range):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code> IDL attributes;
   <code id="range-state-(type=range):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="range-state-(type=range):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and
   <code id="range-state-(type=range):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods.</p>

  </div>



  <h6 id="color-state-(type=color)"><span class="secno">4.10.5.1.14</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Color</dfn> state (<code>type=color</code>)<a href="#color-state-(type=color)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/color" title="<input> elements of type color provide a user interface element that lets a user specify a color, either by using a visual color picker interface or by entering the color into a text field in #rrggbb hexadecimal format.">Element/input/color</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>12.1+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span title="Partial implementation.">🔰 27+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div>

  

  <p>When an <code id="color-state-(type=color):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="color-state-(type=color):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#color-state-(type=color)" id="color-state-(type=color):color-state-(type=color)">Color</a> state, the rules in this section apply.</p>

  

  <p>The <code id="color-state-(type=color):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="color-state-(type=color):represents">represents</a> a color well control, for setting the
  element's <a href="#concept-fe-value" id="color-state-(type=color):concept-fe-value">value</a> to a string representing the serialization
  of a CSS color.</p>

  <p class="note">In this state, there is always a CSS color picked, and there is no way for the end
  user to set the value to the empty string.</p>

  <p>The <dfn data-dfn-for="input" id="attr-input-alpha" data-dfn-type="element-attr"><code>alpha</code></dfn> attribute
  is a <a href="#boolean-attribute" id="color-state-(type=color):boolean-attribute">boolean attribute</a>. If present, it indicates the CSS color's alpha component can
  be manipulated by the end user and does not have to be fully opaque.</p>

  <p>The <dfn data-dfn-for="input" id="attr-input-colorspace" data-dfn-type="element-attr"><code>colorspace</code></dfn>
  attribute indicates the color space of the serialized CSS color. It also hints at the desired user
  interface for selecting a CSS color. It is an <a href="#enumerated-attribute" id="color-state-(type=color):enumerated-attribute">enumerated attribute</a> with the following
  keywords and states:</p>

  <table><thead><tr><th> Keyword
     </th><th> State
     </th><th> Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="input/colorspace" id="attr-input-colorspace-limited-srgb" data-dfn-type="attr-value"><code>limited-srgb</code></dfn>
     </td><td><dfn id="attr-input-colorspace-limited-srgb-state">Limited sRGB</dfn>
     </td><td>The CSS color is converted to the <a id="color-state-(type=color):'srgb'" href="https://drafts.csswg.org/css-color/#valdef-color-srgb" data-x-internal="'srgb'">'srgb'</a> color space and limited to 8-bits per
     component, e.g., "<code>#123456</code>" or "<code>color(srgb 0 1 0 / 0.5)</code>".
    </td></tr><tr><td><dfn data-dfn-for="input/colorspace" id="attr-input-colorspace-display-p3" data-dfn-type="attr-value"><code>display-p3</code></dfn>
     </td><td><dfn id="attr-input-colorspace-display-p3-state">Display P3</dfn>
     </td><td>The CSS color is converted to the <a id="color-state-(type=color):'display-p3'" href="https://drafts.csswg.org/css-color/#valdef-color-display-p3" data-x-internal="'display-p3'">'display-p3'</a> color space, e.g., "<code>color(display-p3 1.84 -0.19 0.72 / 0.6)</code>".
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="color-state-(type=color):missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="color-state-(type=color):invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#attr-input-colorspace-limited-srgb-state" id="color-state-(type=color):attr-input-colorspace-limited-srgb-state">Limited sRGB</a> state.</p>
  </div>

  

  <p>Whenever the element's <code id="color-state-(type=color):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code> or <code id="color-state-(type=color):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code> attributes are changed, the user agent must run
  <a href="#update-a-color-well-control-color" id="color-state-(type=color):update-a-color-well-control-color">update a color well control color</a> given the element.</p>
  

  <p>If the element is <i id="color-state-(type=color):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the color represented by its <a href="#concept-fe-value" id="color-state-(type=color):concept-fe-value-2">value</a>, as
  obtained from <a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value" id="color-state-(type=color):parsed-as-a-css-color-value" data-x-internal="parsed-as-a-css-color-value">parsing</a> it. User agents must not
  allow the user to set the <a href="#concept-fe-value" id="color-state-(type=color):concept-fe-value-3">value</a> to a string that running
  <a href="#update-a-color-well-control-color" id="color-state-(type=color):update-a-color-well-control-color-2">update a color well control color</a> for the element would not set it to. If the user
  agent provides a user interface for selecting a CSS color, then the <a href="#concept-fe-value" id="color-state-(type=color):concept-fe-value-4">value</a> must be set to the result of <a href="#serialize-a-color-well-control-color" id="color-state-(type=color):serialize-a-color-well-control-color">serializing a color well control color</a> given the element and the
  end user's selection.</p>

  <div data-algorithm="">
  <p>The <a href="#input-activation-behavior" id="color-state-(type=color):input-activation-behavior">input activation behavior</a> for such an element <var>element</var> is to
  <a href="#show-the-picker,-if-applicable" id="color-state-(type=color):show-the-picker,-if-applicable">show the picker, if applicable</a>, for <var>element</var>.</p>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: While the element's <a href="#concept-fe-value" id="color-state-(type=color):concept-fe-value-5">value</a> is not the empty string and <a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value" id="color-state-(type=color):parsed-as-a-css-color-value-2" data-x-internal="parsed-as-a-css-color-value">parsing</a> it returns failure, the control is <a href="#suffering-from-bad-input" id="color-state-(type=color):suffering-from-bad-input">suffering from bad
  input</a>.</p>
  </div>

  

  <p>The <code id="color-state-(type=color):attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if specified and not the empty
  string, must have a value that is a CSS color.</p>

  

  <div data-algorithm="">
  <p><strong>The <a href="#value-sanitization-algorithm" id="color-state-(type=color):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: Run <a href="#update-a-color-well-control-color" id="color-state-(type=color):update-a-color-well-control-color-3">update
  a color well control color</a> for the element.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="update-a-color-well-control-color">update a color well control color</dfn>, given an element <var>element</var>:</p>

  <ol><li><p><a id="color-state-(type=color):assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>element</var> is an <code id="color-state-(type=color):the-input-element-3"><a href="#the-input-element">input</a></code> element whose <code id="color-state-(type=color):attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#color-state-(type=color)" id="color-state-(type=color):color-state-(type=color)-2">Color</a> state.</p></li><li><p>Let <var>color</var> be the result of <a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value" id="color-state-(type=color):parsed-as-a-css-color-value-3" data-x-internal="parsed-as-a-css-color-value">parsing</a> <var>element</var>'s <a href="#concept-fe-value" id="color-state-(type=color):concept-fe-value-6">value</a>.</p></li><li><p>If <var>color</var> is failure, then set <var>color</var> to <a id="color-state-(type=color):opaque-black" href="https://drafts.csswg.org/css-color/#opaque-black" data-x-internal="opaque-black">opaque
   black</a>.</p></li><li><p>Set <var>element</var>'s <a href="#concept-fe-value" id="color-state-(type=color):concept-fe-value-7">value</a> to the result of <a href="#serialize-a-color-well-control-color" id="color-state-(type=color):serialize-a-color-well-control-color-2">serializing a color well control color</a> given
   <var>element</var> and <var>color</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="serialize-a-color-well-control-color">serialize a color well control color</dfn>, given an element <var>element</var> and a
  CSS color <var>color</var>:</p>

  <ol><li><p><a id="color-state-(type=color):assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>element</var> is an <code id="color-state-(type=color):the-input-element-4"><a href="#the-input-element">input</a></code> element whose <code id="color-state-(type=color):attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#color-state-(type=color)" id="color-state-(type=color):color-state-(type=color)-3">Color</a> state.</p></li><li><p>Let <var>htmlCompatible</var> be false.</p></li><li><p>If <var>element</var>'s <code id="color-state-(type=color):attr-input-alpha-2"><a href="#attr-input-alpha">alpha</a></code> attribute is not
   specified, then set <var>color</var>'s alpha component to be fully opaque.</p></li><li>
    <p>If <var>element</var>'s <code id="color-state-(type=color):attr-input-colorspace-2"><a href="#attr-input-colorspace">colorspace</a></code> attribute is
    in the <a href="#attr-input-colorspace-limited-srgb-state" id="color-state-(type=color):attr-input-colorspace-limited-srgb-state-2">Limited sRGB</a> state:</p>

    <ol><li><p>Set <var>color</var> to <var>color</var> <a href="https://drafts.csswg.org/css-color/#color-conversion" id="color-state-(type=color):converting-colors" data-x-internal="converting-colors">converted</a> to the <a id="color-state-(type=color):'srgb'-2" href="https://drafts.csswg.org/css-color/#valdef-color-srgb" data-x-internal="'srgb'">'srgb'</a> color space.</p></li><li><p>Round each of <var>color</var>'s components so they are in the range 0 to 255,
     inclusive. Components are to be <a href="https://drafts.csswg.org/css-values-4/#combine-integers">rounded towards +∞</a>.</p></li><li>
      <p>If <var>element</var>'s <code id="color-state-(type=color):attr-input-alpha-3"><a href="#attr-input-alpha">alpha</a></code> attribute is not
      specified, then set <var>htmlCompatible</var> to true.</p>

      <p class="note">This intentionally uses a different serialization path for compatibility with
      an earlier version of the color well control.</p>
     </li><li><p>Otherwise, set <var>color</var> to <var>color</var> converted using the
     <a id="color-state-(type=color):color-function" href="https://drafts.csswg.org/css-color/#color-function" data-x-internal="color-function">'color()'</a> function.</p></li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p><a id="color-state-(type=color):assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>element</var>'s <code id="color-state-(type=color):attr-input-colorspace-3"><a href="#attr-input-colorspace">colorspace</a></code> attribute is in the <a href="#attr-input-colorspace-display-p3-state" id="color-state-(type=color):attr-input-colorspace-display-p3-state">Display P3</a> state.</p></li><li><p>Set <var>color</var> to <var>color</var> <a href="https://drafts.csswg.org/css-color/#color-conversion" id="color-state-(type=color):converting-colors-2" data-x-internal="converting-colors">converted</a> to the <a id="color-state-(type=color):'display-p3'-2" href="https://drafts.csswg.org/css-color/#valdef-color-display-p3" data-x-internal="'display-p3'">'display-p3'</a> color space.</p></li></ol>
   </li><li><p>Return the result of <a href="https://drafts.csswg.org/css-color/#serializing-color-values" id="color-state-(type=color):serialisation-of-a-color" data-x-internal="serialisation-of-a-color">serializing</a>
   <var>color</var>. If <var>htmlCompatible</var> is true, then do so with <a href="https://drafts.csswg.org/css-color/#color-serialization-html-compatible-serialization-is-requested" id="color-state-(type=color):html-compatible-serialization-is-requested" data-x-internal="html-compatible-serialization-is-requested">HTML-compatible serialization
   requested</a>.</p></li></ol>
  </div>

  

  <div class="bookkeeping">

   <p>The following common <code id="color-state-(type=color):the-input-element-5"><a href="#the-input-element">input</a></code> element content attributes and IDL attributes <a href="#concept-input-apply" id="color-state-(type=color):concept-input-apply">apply</a> to the element:
   <code id="color-state-(type=color):attr-input-alpha-4"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="color-state-(type=color):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="color-state-(type=color):attr-input-colorspace-4"><a href="#attr-input-colorspace">colorspace</a></code>, and
   <code id="color-state-(type=color):attr-input-list"><a href="#attr-input-list">list</a></code> content attributes;
   <code id="color-state-(type=color):dom-input-list"><a href="#dom-input-list">list</a></code> and
   <code id="color-state-(type=color):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attributes;
   <code id="color-state-(type=color):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code> method.</p>

   <p>The <code id="color-state-(type=color):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-value" id="color-state-(type=color):dom-input-value-value">value</a>.</p>

   <p>The <code id="color-state-(type=color):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="color-state-(type=color):event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="color-state-(type=color):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="color-state-(type=color):do-not-apply">do not apply</a> to the
   element:
   <code id="color-state-(type=color):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="color-state-(type=color):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="color-state-(type=color):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="color-state-(type=color):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="color-state-(type=color):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="color-state-(type=color):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="color-state-(type=color):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="color-state-(type=color):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="color-state-(type=color):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="color-state-(type=color):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="color-state-(type=color):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="color-state-(type=color):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="color-state-(type=color):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="color-state-(type=color):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="color-state-(type=color):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="color-state-(type=color):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="color-state-(type=color):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="color-state-(type=color):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="color-state-(type=color):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="color-state-(type=color):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="color-state-(type=color):attr-input-required"><a href="#attr-input-required">required</a></code>,
   <code id="color-state-(type=color):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="color-state-(type=color):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="color-state-(type=color):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="color-state-(type=color):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="color-state-(type=color):do-not-apply-2">do not apply</a> to the element:
   <code id="color-state-(type=color):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="color-state-(type=color):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="color-state-(type=color):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="color-state-(type=color):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="color-state-(type=color):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="color-state-(type=color):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code> and,
   <code id="color-state-(type=color):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="color-state-(type=color):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="color-state-(type=color):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="color-state-(type=color):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="color-state-(type=color):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

  </div>


  <h6 id="checkbox-state-(type=checkbox)"><span class="secno">4.10.5.1.15</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Checkbox</dfn> state (<code>type=checkbox</code>)<a href="#checkbox-state-(type=checkbox)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox" title="<input> elements of type checkbox are rendered by default as boxes that are checked (ticked) when activated, like you might see in an official government paper form. The exact appearance depends upon the operating system configuration under which the browser is running. Generally this is a square but it may have rounded corners. A checkbox allows you to select single values for submission in a form (or not).">Element/input/checkbox</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="checkbox-state-(type=checkbox):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="checkbox-state-(type=checkbox):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#checkbox-state-(type=checkbox)" id="checkbox-state-(type=checkbox):checkbox-state-(type=checkbox)">Checkbox</a> state, the rules in this section
  apply.</p>

  

  <p>The <code id="checkbox-state-(type=checkbox):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="checkbox-state-(type=checkbox):represents">represents</a> a two-state control that represents the
  element's <a href="#concept-fe-checked" id="checkbox-state-(type=checkbox):concept-fe-checked">checkedness</a> state. If the element's <a href="#concept-fe-checked" id="checkbox-state-(type=checkbox):concept-fe-checked-2">checkedness</a> state is true, the control represents a positive
  selection, and if it is false, a negative selection. If the element's <code id="checkbox-state-(type=checkbox):dom-input-indeterminate"><a href="#dom-input-indeterminate">indeterminate</a></code> IDL attribute is set to true, then the
  control's selection should be obscured as if the control was in a third, indeterminate, state.</p>

  <p class="note">The control is never a true tri-state control, even if the element's <code id="checkbox-state-(type=checkbox):dom-input-indeterminate-2"><a href="#dom-input-indeterminate">indeterminate</a></code> IDL attribute is set to true. The <code id="checkbox-state-(type=checkbox):dom-input-indeterminate-3"><a href="#dom-input-indeterminate">indeterminate</a></code> IDL attribute only gives the appearance of a
  third state.</p>

  

  <div data-algorithm="">
  <p>The <a href="#input-activation-behavior" id="checkbox-state-(type=checkbox):input-activation-behavior">input activation behavior</a> is to run the following steps:</p>
  <ol><li><p>If the element is not <a id="checkbox-state-(type=checkbox):connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="checkbox-state-(type=checkbox):concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="checkbox-state-(type=checkbox):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the element with the <code id="checkbox-state-(type=checkbox):dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="checkbox-state-(type=checkbox):dom-event-composed"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code>
   attributes initialized to true.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="checkbox-state-(type=checkbox):concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="checkbox-state-(type=checkbox):event-change"><a href="#event-change">change</a></code> at the element with the <code id="checkbox-state-(type=checkbox):dom-event-bubbles-2"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to true.</p></li></ol>
  </div>
  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the element is <i id="checkbox-state-(type=checkbox):concept-input-required"><a href="#concept-input-required">required</a></i> and its <a href="#concept-fe-checked" id="checkbox-state-(type=checkbox):concept-fe-checked-3">checkedness</a> is false, then the element is <a href="#suffering-from-being-missing" id="checkbox-state-(type=checkbox):suffering-from-being-missing">suffering from
  being missing</a>.</p>
  </div>

  

  <dl class="domintro"><dt><code><var>input</var>.<a href="#dom-input-indeterminate" id="dom-input-indeterminate-dev">indeterminate</a> [ = <var>value</var> ]</code></dt><dd>
    <p>When set, overrides the rendering of <a href="#checkbox-state-(type=checkbox)" id="checkbox-state-(type=checkbox):checkbox-state-(type=checkbox)-2">checkbox</a>
    controls so that the current value is not visible.</p>
   </dd></dl>

  <div class="bookkeeping">

   <p>The following common <code id="checkbox-state-(type=checkbox):the-input-element-3"><a href="#the-input-element">input</a></code> element content attributes and IDL attributes <a href="#concept-input-apply" id="checkbox-state-(type=checkbox):concept-input-apply">apply</a> to the element:
   <code id="checkbox-state-(type=checkbox):attr-input-checked"><a href="#attr-input-checked">checked</a></code>, and
   <code id="checkbox-state-(type=checkbox):attr-input-required"><a href="#attr-input-required">required</a></code> content attributes;
   <code id="checkbox-state-(type=checkbox):dom-input-checked"><a href="#dom-input-checked">checked</a></code> and
   <code id="checkbox-state-(type=checkbox):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attributes.</p>

   <p>The <code id="checkbox-state-(type=checkbox):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-default-on" id="checkbox-state-(type=checkbox):dom-input-value-default-on">default/on</a>.</p>

   <p>The <code id="checkbox-state-(type=checkbox):event-input-2"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="checkbox-state-(type=checkbox):event-change-2"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="checkbox-state-(type=checkbox):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="checkbox-state-(type=checkbox):do-not-apply">do not apply</a> to the
   element:
   <code id="checkbox-state-(type=checkbox):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="checkbox-state-(type=checkbox):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="checkbox-state-(type=checkbox):do-not-apply-2">do not apply</a> to the element:
   <code id="checkbox-state-(type=checkbox):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="checkbox-state-(type=checkbox):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="checkbox-state-(type=checkbox):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

  </div>



  <h6 id="radio-button-state-(type=radio)"><span class="secno">4.10.5.1.16</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Radio Button</dfn> state (<code>type=radio</code>)<a href="#radio-button-state-(type=radio)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio" title="<input> elements of type radio are generally used in radio groups—collections of radio buttons describing a set of related options.">Element/input/radio</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="radio-button-state-(type=radio):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="radio-button-state-(type=radio):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#radio-button-state-(type=radio)" id="radio-button-state-(type=radio):radio-button-state-(type=radio)">Radio Button</a> state, the rules in this section
  apply.</p>

  

  <p>The <code id="radio-button-state-(type=radio):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="radio-button-state-(type=radio):represents">represents</a> a control that, when used in conjunction
  with other <code id="radio-button-state-(type=radio):the-input-element-3"><a href="#the-input-element">input</a></code> elements, forms a <i id="radio-button-state-(type=radio):radio-button-group"><a href="#radio-button-group">radio button group</a></i> in which only one
  control can have its <a href="#concept-fe-checked" id="radio-button-state-(type=radio):concept-fe-checked">checkedness</a> state set to true. If
  the element's <a href="#concept-fe-checked" id="radio-button-state-(type=radio):concept-fe-checked-2">checkedness</a> state is true, the control
  represents the selected control in the group, and if it is false, it indicates a control in the
  group that is not selected.</p>

  <div data-algorithm="">
  <p>The <dfn id="radio-button-group"><i>radio button group</i></dfn> that contains an <code id="radio-button-state-(type=radio):the-input-element-4"><a href="#the-input-element">input</a></code> element
  <var>a</var> also contains all the other <code id="radio-button-state-(type=radio):the-input-element-5"><a href="#the-input-element">input</a></code> elements <var>b</var> that fulfill all
  of the following conditions:</p>

  <ul><li>The <code id="radio-button-state-(type=radio):the-input-element-6"><a href="#the-input-element">input</a></code> element <var>b</var>'s <code id="radio-button-state-(type=radio):attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#radio-button-state-(type=radio)" id="radio-button-state-(type=radio):radio-button-state-(type=radio)-2">Radio
   Button</a> state.</li><li>Either <var>a</var> and <var>b</var> have the same <a href="#form-owner" id="radio-button-state-(type=radio):form-owner">form owner</a>,
   or they both have no <a href="#form-owner" id="radio-button-state-(type=radio):form-owner-2">form owner</a>.</li><li>Both <var>a</var> and <var>b</var> are in the same <a id="radio-button-state-(type=radio):tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>.</li><li>They both have a <code id="radio-button-state-(type=radio):attr-fe-name"><a href="#attr-fe-name">name</a></code> attribute, their <code id="radio-button-state-(type=radio):attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attributes are not empty, and the value of <var>a</var>'s <code id="radio-button-state-(type=radio):attr-fe-name-3"><a href="#attr-fe-name">name</a></code> attribute equals the value of <var>b</var>'s <code id="radio-button-state-(type=radio):attr-fe-name-4"><a href="#attr-fe-name">name</a></code> attribute.</li></ul>
  </div>

  <p>A <a id="radio-button-state-(type=radio):tree-2" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> must not contain an <code id="radio-button-state-(type=radio):the-input-element-7"><a href="#the-input-element">input</a></code> element whose <i id="radio-button-state-(type=radio):radio-button-group-2"><a href="#radio-button-group">radio button group</a></i> contains only that element.</p>

  

  <div data-algorithm="">
  <p>When any of the following phenomena occur, if the element's <a href="#concept-fe-checked" id="radio-button-state-(type=radio):concept-fe-checked-3">checkedness</a> state is true after the occurrence, the <a href="#concept-fe-checked" id="radio-button-state-(type=radio):concept-fe-checked-4">checkedness</a> state of all the other elements in the same <i id="radio-button-state-(type=radio):radio-button-group-3"><a href="#radio-button-group">radio
  button group</a></i> must be set to false:</p>

  <ul><li>The element's <a href="#concept-fe-checked" id="radio-button-state-(type=radio):concept-fe-checked-5">checkedness</a> state is set to true (for
   whatever reason).</li><li>The element's <code id="radio-button-state-(type=radio):attr-fe-name-5"><a href="#attr-fe-name">name</a></code> attribute is set, changed, or
   removed.</li><li>The element's <a href="#form-owner" id="radio-button-state-(type=radio):form-owner-3">form owner</a> changes.</li><li><a href="#signal-a-type-change" id="radio-button-state-(type=radio):signal-a-type-change">A type change is signalled</a> for the element.</li><li>The element <a href="#becomes-connected" id="radio-button-state-(type=radio):becomes-connected">becomes connected</a>.</li></ul>
  </div>

  <div data-algorithm="">
  <p>The <a href="#input-activation-behavior" id="radio-button-state-(type=radio):input-activation-behavior">input activation behavior</a> is to run the following steps:</p>
  <ol><li><p>If the element is not <a id="radio-button-state-(type=radio):connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="radio-button-state-(type=radio):concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="radio-button-state-(type=radio):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the element with the <code id="radio-button-state-(type=radio):dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="radio-button-state-(type=radio):dom-event-composed"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code>
   attributes initialized to true.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="radio-button-state-(type=radio):concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="radio-button-state-(type=radio):event-change"><a href="#event-change">change</a></code> at the element with the <code id="radio-button-state-(type=radio):dom-event-bubbles-2"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to true.</p></li></ol>
  </div>
  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If an element in the <i id="radio-button-state-(type=radio):radio-button-group-4"><a href="#radio-button-group">radio button group</a></i> is <i id="radio-button-state-(type=radio):concept-input-required"><a href="#concept-input-required">required</a></i>, and all of the
  <code id="radio-button-state-(type=radio):the-input-element-8"><a href="#the-input-element">input</a></code> elements in the <i id="radio-button-state-(type=radio):radio-button-group-5"><a href="#radio-button-group">radio button group</a></i> have a
  <a href="#concept-fe-checked" id="radio-button-state-(type=radio):concept-fe-checked-6">checkedness</a> that is false, then the element is
  <a href="#suffering-from-being-missing" id="radio-button-state-(type=radio):suffering-from-being-missing">suffering from being missing</a>.</p>
  </div>

  <div class="example">
   <p>The following example, for some reason, has specified that puppers are both <a href="#concept-input-required" id="radio-button-state-(type=radio):concept-input-required-2">required</a> and <a href="#concept-fe-disabled" id="radio-button-state-(type=radio):concept-fe-disabled">disabled</a>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"radio"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"dog-type"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"pupper"</c-> <c- e="">required</c-> <c- e="">disabled</c-><c- p="">&gt;</c-> Pupper<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"radio"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"dog-type"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"doggo"</c-><c- p="">&gt;</c-> Doggo<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Make your choice<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

   <p>If the user tries to submit this form without first selecting "Doggo", then <em>both</em>
   <code id="radio-button-state-(type=radio):the-input-element-9"><a href="#the-input-element">input</a></code> elements will be <a href="#suffering-from-being-missing" id="radio-button-state-(type=radio):suffering-from-being-missing-2">suffering from being missing</a>, since an element
   in the <a href="#radio-button-group" id="radio-button-state-(type=radio):radio-button-group-6">radio button group</a> is <a href="#concept-input-required" id="radio-button-state-(type=radio):concept-input-required-3">required</a>
   (viz. the first element), and both of the elements in the radio button group have a false <a href="#concept-fe-checked" id="radio-button-state-(type=radio):concept-fe-checked-7">checkedness</a>.</p>

   <p>On the other hand, if the user selects "Doggo" and then submits the form, then neither
   <code id="radio-button-state-(type=radio):the-input-element-10"><a href="#the-input-element">input</a></code> element will be <a href="#suffering-from-being-missing" id="radio-button-state-(type=radio):suffering-from-being-missing-3">suffering from being missing</a>, since while one of
   them is <a href="#concept-input-required" id="radio-button-state-(type=radio):concept-input-required-4">required</a>, not all of them have a false <a href="#concept-fe-checked" id="radio-button-state-(type=radio):concept-fe-checked-8">checkedness</a>.</p>
  </div>

  

  <p class="note">If none of the radio buttons in a <a href="#radio-button-group" id="radio-button-state-(type=radio):radio-button-group-7">radio button group</a> are checked,
  then they will all be initially unchecked in the interface, until such time as one of them is
  checked (either by the user or by script).</p>

  <div class="bookkeeping">

   <p>The following common <code id="radio-button-state-(type=radio):the-input-element-11"><a href="#the-input-element">input</a></code> element content attributes and IDL attributes <a href="#concept-input-apply" id="radio-button-state-(type=radio):concept-input-apply">apply</a> to the element:
   <code id="radio-button-state-(type=radio):attr-input-checked"><a href="#attr-input-checked">checked</a></code> and
   <code id="radio-button-state-(type=radio):attr-input-required"><a href="#attr-input-required">required</a></code> content attributes;
   <code id="radio-button-state-(type=radio):dom-input-checked"><a href="#dom-input-checked">checked</a></code> and
   <code id="radio-button-state-(type=radio):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attributes.</p>

   <p>The <code id="radio-button-state-(type=radio):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-default-on" id="radio-button-state-(type=radio):dom-input-value-default-on">default/on</a>.</p>

   <p>The <code id="radio-button-state-(type=radio):event-input-2"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="radio-button-state-(type=radio):event-change-2"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="radio-button-state-(type=radio):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="radio-button-state-(type=radio):do-not-apply">do not apply</a> to the
   element:
   <code id="radio-button-state-(type=radio):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="radio-button-state-(type=radio):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="radio-button-state-(type=radio):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="radio-button-state-(type=radio):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="radio-button-state-(type=radio):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="radio-button-state-(type=radio):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="radio-button-state-(type=radio):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="radio-button-state-(type=radio):do-not-apply-2">do not apply</a> to the element:
   <code id="radio-button-state-(type=radio):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="radio-button-state-(type=radio):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="radio-button-state-(type=radio):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="radio-button-state-(type=radio):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="radio-button-state-(type=radio):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="radio-button-state-(type=radio):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="radio-button-state-(type=radio):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

  </div>



  <h6 id="file-upload-state-(type=file)"><span class="secno">4.10.5.1.17</span> <dfn data-dfn-for="input" data-dfn-type="element-state">File Upload</dfn> state (<code>type=file</code>)<a href="#file-upload-state-(type=file)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file" title="<input> elements with type=&quot;file&quot; let the user choose one or more files from their device storage. Once chosen, the files can be uploaded to a server using form submission, or manipulated using JavaScript code and the File API.">Element/input/file</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  

  

  <p>When an <code id="file-upload-state-(type=file):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="file-upload-state-(type=file):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#file-upload-state-(type=file)" id="file-upload-state-(type=file):file-upload-state-(type=file)">File Upload</a> state, the rules in this section
  apply.</p>

  

  <p>The <code id="file-upload-state-(type=file):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="file-upload-state-(type=file):represents">represents</a> a list of <dfn id="concept-input-type-file-selected">selected files</dfn>, each file consisting of a
  filename, a file type, and a file body (the contents of the file).</p>

  

  <p>Filenames must not contain <a href="#concept-input-file-path" id="file-upload-state-(type=file):concept-input-file-path">path components</a>, even
  in the case that a user has selected an entire directory hierarchy or multiple files with the same
  name from different directories. <dfn id="concept-input-file-path">Path components</dfn>, for
  the purposes of the <a href="#file-upload-state-(type=file)" id="file-upload-state-(type=file):file-upload-state-(type=file)-2">File Upload</a> state, are those parts
  of filenames that are separated by U+005C REVERSE SOLIDUS character (\) characters.</p>

  <p>Unless the <code id="file-upload-state-(type=file):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> attribute is set, there must be
  no more than one file in the list of <a href="#concept-input-type-file-selected" id="file-upload-state-(type=file):concept-input-type-file-selected">selected
  files</a>.</p>

  <div data-algorithm="">
  <p>The <a href="#input-activation-behavior" id="file-upload-state-(type=file):input-activation-behavior">input activation behavior</a> for such an element <var>element</var> is to
  <a href="#show-the-picker,-if-applicable" id="file-upload-state-(type=file):show-the-picker,-if-applicable">show the picker, if applicable</a>, for <var>element</var>.</p>
  </div>

  <p>If the element is <i id="file-upload-state-(type=file):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the
  user to change the files on the list in other ways also, e.g., adding or removing files by
  drag-and-drop. When the user does so, the user agent must <a href="#update-the-file-selection" id="file-upload-state-(type=file):update-the-file-selection">update the file selection</a>
  for the element.</p>

  <p>If the element is not <i id="file-upload-state-(type=file):concept-fe-mutable-2"><a href="#concept-fe-mutable">mutable</a></i>, the user agent must not allow
  the user to change the element's selection.</p>

  <div data-algorithm="">
  <p>To <dfn id="update-the-file-selection">update the file selection</dfn> for an element <var>element</var>:</p>

  <ol><li>
    <p><a href="#queue-an-element-task" id="file-upload-state-(type=file):queue-an-element-task">Queue an element task</a> on the <a href="#user-interaction-task-source" id="file-upload-state-(type=file):user-interaction-task-source">user interaction task source</a> given
    <var>element</var> and the following steps:</p>

    <ol><li><p>Update <var>element</var>'s <a href="#concept-input-type-file-selected" id="file-upload-state-(type=file):concept-input-type-file-selected-2">selected
     files</a> so that it represents the user's selection.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="file-upload-state-(type=file):concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="file-upload-state-(type=file):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the <code id="file-upload-state-(type=file):the-input-element-3"><a href="#the-input-element">input</a></code> element, with the <code id="file-upload-state-(type=file):dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="file-upload-state-(type=file):dom-event-composed"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code>
     attributes initialized to true.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="file-upload-state-(type=file):concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="file-upload-state-(type=file):event-change"><a href="#event-change">change</a></code> at the <code id="file-upload-state-(type=file):the-input-element-4"><a href="#the-input-element">input</a></code> element, with the <code id="file-upload-state-(type=file):dom-event-bubbles-2"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to true.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the element is <i id="file-upload-state-(type=file):concept-input-required"><a href="#concept-input-required">required</a></i> and the list of <a href="#concept-input-type-file-selected" id="file-upload-state-(type=file):concept-input-type-file-selected-3">selected files</a> is empty, then the element is
  <a href="#suffering-from-being-missing" id="file-upload-state-(type=file):suffering-from-being-missing">suffering from being missing</a>.</p>
  </div>

  

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept" title="The accept attribute takes as its value a comma-separated list of one or more file types, or unique file type specifiers, describing which file types to allow.">Attributes/accept</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#attr-accept</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>37+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>26+</span></span><hr><span class="opera yes"><span>Opera</span><span>15+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>37+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>11.3+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>26+</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.5+</span></span><span class="opera_android yes"><span>Opera Android</span><span>15+</span></span></div></div></div><p>The <dfn data-dfn-for="input" id="attr-input-accept" data-dfn-type="element-attr"><code>accept</code></dfn>
  attribute may be specified to provide user agents with a hint of what file types will be
  accepted.</p>

  <p>If specified, the attribute must consist of a <a href="#set-of-comma-separated-tokens" id="file-upload-state-(type=file):set-of-comma-separated-tokens">set of comma-separated tokens</a>, each
  of which must be an <a id="file-upload-state-(type=file):ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the following:</p>

  <dl><dt>The string "<code>audio/*</code>"</dt><dd>Indicates that sound files are accepted.</dd><dt>The string "<code>video/*</code>"</dt><dd>Indicates that video files are accepted.</dd><dt>The string "<code>image/*</code>"</dt><dd>Indicates that image files are accepted.</dd><dt>A <a id="file-upload-state-(type=file):valid-mime-type-string-with-no-parameters" href="https://mimesniff.spec.whatwg.org/#valid-mime-type-with-no-parameters" data-x-internal="valid-mime-type-string-with-no-parameters">valid MIME type string with no parameters</a></dt><dd>Indicates that files of the specified type are accepted.</dd><dt>A string whose first character is a U+002E FULL STOP character (.)</dt><dd>Indicates that files with the specified file extension are accepted.</dd></dl>

  <p>The tokens must not be <a id="file-upload-state-(type=file):ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> matches for any of the other tokens
  (i.e. duplicates are not allowed). To obtain the list of tokens from the
  attribute, the user agent must <a href="https://infra.spec.whatwg.org/#split-on-commas" id="file-upload-state-(type=file):split-a-string-on-commas" data-x-internal="split-a-string-on-commas">split the attribute value on
  commas</a>.</p>

  <p>User agents may use the value of this attribute to display a more appropriate user interface
  than a generic file picker. For instance, given the value <code>image/*</code>, a user
  agent could offer the user the option of using a local camera or selecting a photograph from their
  photo collection; given the value <code>audio/*</code>, a user agent could offer the user
  the option of recording a clip using a headset microphone.</p>

  

  <p>User agents should prevent the user from selecting files that are not accepted by one (or more)
  of these tokens.</p>

  

  <p class="note">Authors are encouraged to specify both any MIME types and any corresponding
  extensions when looking for data in a specific format.</p>

  <div class="example">

   <p>For example, consider an application that converts Microsoft Word documents to Open Document
   Format files. Since Microsoft Word documents are described with a wide variety of MIME types and
   extensions, the site can list several, as follows:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"file"</c-> <c- e="">accept</c-><c- o="">=</c-><c- s="">".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"</c-><c- p="">&gt;</c-></code></pre>

   <p>On platforms that only use file extensions to describe file types, the extensions listed here
   can be used to filter the allowed documents, while the MIME types can be used with the system's
   type registration table (mapping MIME types to extensions used by the system), if any, to
   determine any other extensions to allow. Similarly, on a system that does not have filenames or
   extensions but labels documents with MIME types internally, the MIME types can be used to pick
   the allowed files, while the extensions can be used if the system has an extension registration
   table that maps known extensions to MIME types used by the system.</p>

  </div>

  <p class="warning">Extensions tend to be ambiguous (e.g. there are an untold number of formats
  that use the "<code>.dat</code>" extension, and users can typically quite easily rename
  their files to have a "<code>.doc</code>" extension even if they are not Microsoft Word
  documents), and MIME types tend to be unreliable (e.g. many formats have no formally registered
  types, and many formats are in practice labeled using a number of different MIME types). Authors
  are reminded that, as usual, data received from a client should be treated with caution, as it may
  not be in an expected format even if the user is not hostile and the user agent fully obeyed the
  <code id="file-upload-state-(type=file):attr-input-accept"><a href="#attr-input-accept">accept</a></code> attribute's requirements.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file" title="<input> elements with type=&quot;file&quot; let the user choose one or more files from their device storage. Once chosen, the files can be uploaded to a server using form submission, or manipulated using JavaScript code and the File API.">Element/input/file</a></p></div></div><div id="fakepath-srsly" class="example"><a href="#fakepath-srsly" class="self-link"></a>

   <p>For historical reasons, the <code id="file-upload-state-(type=file):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attribute prefixes
   the filename with the string "<code>C:\fakepath\</code>". Some legacy user agents
   actually included the full path (which was a security vulnerability). As a result of this,
   obtaining the filename from the <code id="file-upload-state-(type=file):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute in a
   backwards-compatible way is non-trivial. The following function extracts the filename in a
   suitably compatible manner:</p>

   <pre><code class="js"><c- a="">function</c-> extractFilename<c- p="">(</c->path<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->path<c- p="">.</c->substr<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">12</c-><c- p="">)</c-> <c- o="">==</c-> <c- u="">"C:\\fakepath\\"</c-><c- p="">)</c->
    <c- k="">return</c-> path<c- p="">.</c->substr<c- p="">(</c-><c- mf="">12</c-><c- p="">);</c-> <c- c1="">// modern browser</c->
  <c- a="">var</c-> x<c- p="">;</c->
  x <c- o="">=</c-> path<c- p="">.</c->lastIndexOf<c- p="">(</c-><c- t="">'/'</c-><c- p="">);</c->
  <c- k="">if</c-> <c- p="">(</c->x <c- o="">&gt;=</c-> <c- mf="">0</c-><c- p="">)</c-> <c- c1="">// Unix-based path</c->
    <c- k="">return</c-> path<c- p="">.</c->substr<c- p="">(</c->x<c- o="">+</c-><c- mf="">1</c-><c- p="">);</c->
  x <c- o="">=</c-> path<c- p="">.</c->lastIndexOf<c- p="">(</c-><c- t="">'\\'</c-><c- p="">);</c->
  <c- k="">if</c-> <c- p="">(</c->x <c- o="">&gt;=</c-> <c- mf="">0</c-><c- p="">)</c-> <c- c1="">// Windows-based path</c->
    <c- k="">return</c-> path<c- p="">.</c->substr<c- p="">(</c->x<c- o="">+</c-><c- mf="">1</c-><c- p="">);</c->
  <c- k="">return</c-> path<c- p="">;</c-> <c- c1="">// just the filename</c->
<c- p="">}</c-></code></pre>

   <p>This can be used as follows:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">file</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">image</c-> <c- e="">onchange</c-><c- o="">=</c-><c- s="">"updateFilename(this.value)"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The name of the file you picked is: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"filename"</c-><c- p="">&gt;</c->(none)<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">function</c-> updateFilename<c- p="">(</c->path<c- p="">)</c-> <c- p="">{</c->
   <c- a="">var</c-> name <c- o="">=</c-> extractFilename<c- p="">(</c->path<c- p="">);</c->
   document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'filename'</c-><c- p="">).</c->textContent <c- o="">=</c-> name<c- p="">;</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   

  </div>

  <hr>

  <div class="bookkeeping">

   <p>The following common <code id="file-upload-state-(type=file):the-input-element-5"><a href="#the-input-element">input</a></code> element content attributes and IDL attributes <a href="#concept-input-apply" id="file-upload-state-(type=file):concept-input-apply">apply</a> to the element:
   <code id="file-upload-state-(type=file):attr-input-accept-2"><a href="#attr-input-accept">accept</a></code>,
   <code id="file-upload-state-(type=file):attr-input-multiple-2"><a href="#attr-input-multiple">multiple</a></code>, and
   <code id="file-upload-state-(type=file):attr-input-required"><a href="#attr-input-required">required</a></code> content attributes;
   <code id="file-upload-state-(type=file):dom-input-files"><a href="#dom-input-files">files</a></code> and
   <code id="file-upload-state-(type=file):dom-input-value-3"><a href="#dom-input-value">value</a></code> IDL attributes;
   <code id="file-upload-state-(type=file):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code> method.</p>

   <p>The <code id="file-upload-state-(type=file):dom-input-value-4"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-filename" id="file-upload-state-(type=file):dom-input-value-filename">filename</a>.</p>

   <p>The <code id="file-upload-state-(type=file):event-input-2"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="file-upload-state-(type=file):event-change-2"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="file-upload-state-(type=file):concept-input-apply-2">apply</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="file-upload-state-(type=file):do-not-apply">do not apply</a> to the
   element:
   <code id="file-upload-state-(type=file):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="file-upload-state-(type=file):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="file-upload-state-(type=file):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="file-upload-state-(type=file):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="file-upload-state-(type=file):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="file-upload-state-(type=file):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="file-upload-state-(type=file):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="file-upload-state-(type=file):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="file-upload-state-(type=file):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="file-upload-state-(type=file):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="file-upload-state-(type=file):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="file-upload-state-(type=file):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="file-upload-state-(type=file):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="file-upload-state-(type=file):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="file-upload-state-(type=file):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="file-upload-state-(type=file):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="file-upload-state-(type=file):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="file-upload-state-(type=file):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="file-upload-state-(type=file):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="file-upload-state-(type=file):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="file-upload-state-(type=file):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The element's <code id="file-upload-state-(type=file):attr-input-value"><a href="#attr-input-value">value</a></code> attribute must be omitted.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="file-upload-state-(type=file):do-not-apply-2">do not apply</a> to the element:
   <code id="file-upload-state-(type=file):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="file-upload-state-(type=file):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="file-upload-state-(type=file):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="file-upload-state-(type=file):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="file-upload-state-(type=file):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="file-upload-state-(type=file):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="file-upload-state-(type=file):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="file-upload-state-(type=file):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="file-upload-state-(type=file):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="file-upload-state-(type=file):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="file-upload-state-(type=file):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

  </div>



  <h6 id="submit-button-state-(type=submit)"><span class="secno">4.10.5.1.18</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Submit Button</dfn> state (<code>type=submit</code>)<a href="#submit-button-state-(type=submit)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit" title="<input> elements of type submit are rendered as buttons. When the click event occurs (typically because the user clicked the button), the user agent attempts to submit the form to the server.">Element/input/submit</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="submit-button-state-(type=submit):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="submit-button-state-(type=submit):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#submit-button-state-(type=submit)" id="submit-button-state-(type=submit):submit-button-state-(type=submit)">Submit Button</a> state, the rules in this section
  apply.</p>

  

  <p>
  <a id="submit-button-state-(type=submit):tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  The <code id="submit-button-state-(type=submit):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="submit-button-state-(type=submit):represents">represents</a> a button that, when activated, submits the
  form. If the element has a <code id="submit-button-state-(type=submit):attr-input-value"><a href="#attr-input-value">value</a></code> attribute,
  the button's label must be the value of that attribute; otherwise, it must be an
  <a id="submit-button-state-(type=submit):implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> string that means "Submit" or some such. The element is
  a <a href="#concept-button" id="submit-button-state-(type=submit):concept-button">button</a>, specifically a <a href="#concept-submit-button" id="submit-button-state-(type=submit):concept-submit-button">submit button</a>.</p>

  <p class="note">Since the default label is <a id="submit-button-state-(type=submit):implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>, and the width of
  the button typically depends on the button's label, the button's width can leak a few bits of
  fingerprintable information. These bits are likely to be strongly correlated to the identity of
  the user agent and the user's locale.</p>

  

  <div data-algorithm="">
  <p>The element's <a href="#concept-fe-optional-value" id="submit-button-state-(type=submit):concept-fe-optional-value">optional value</a> is the value of
  the element's <code id="submit-button-state-(type=submit):attr-button-value"><a href="#attr-button-value">value</a></code> attribute, if there is one; otherwise
  null.</p>
  </div>

  <div data-algorithm="">
  <p>The element's <a href="#input-activation-behavior" id="submit-button-state-(type=submit):input-activation-behavior">input activation behavior</a> given <var>event</var> is as follows:</p>

  <ol><li><p>If the element does not have a <a href="#form-owner" id="submit-button-state-(type=submit):form-owner">form owner</a>, then return.</p></li><li><p>If the element's <a id="submit-button-state-(type=submit):node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="submit-button-state-(type=submit):fully-active">fully active</a>, then
   return.</p></li><li><p><a href="#concept-form-submit" id="submit-button-state-(type=submit):concept-form-submit">Submit</a> the element's <a href="#form-owner" id="submit-button-state-(type=submit):form-owner-2">form owner</a>
   from the element with <i id="submit-button-state-(type=submit):submit-user-involvement"><a href="#submit-user-involvement">userInvolvement</a></i> set to
   <var>event</var>'s <a href="#event-uni" id="submit-button-state-(type=submit):event-uni">user navigation involvement</a>.</p>
  </li></ol>
  </div>

  

  <p>The <code id="submit-button-state-(type=submit):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>, <code id="submit-button-state-(type=submit):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>, <code id="submit-button-state-(type=submit):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>, <code id="submit-button-state-(type=submit):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>, and <code id="submit-button-state-(type=submit):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code> attributes are <a href="#attributes-for-form-submission" id="submit-button-state-(type=submit):attributes-for-form-submission">attributes for form
  submission</a>.</p>

  <p class="note">The <code id="submit-button-state-(type=submit):attr-fs-formnovalidate-2"><a href="#attr-fs-formnovalidate">formnovalidate</a></code> attribute can be
  used to make submit buttons that do not trigger the constraint validation.</p>

  <div class="bookkeeping">

   <p>The following common <code id="submit-button-state-(type=submit):the-input-element-3"><a href="#the-input-element">input</a></code> element content attributes and IDL attributes <a href="#concept-input-apply" id="submit-button-state-(type=submit):concept-input-apply">apply</a> to the element:
   <code id="submit-button-state-(type=submit):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="submit-button-state-(type=submit):attr-fs-formaction-2"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="submit-button-state-(type=submit):attr-fs-formenctype-2"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="submit-button-state-(type=submit):attr-fs-formmethod-2"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="submit-button-state-(type=submit):attr-fs-formnovalidate-3"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="submit-button-state-(type=submit):attr-fs-formtarget-2"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="submit-button-state-(type=submit):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>, and
   <code id="submit-button-state-(type=submit):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code> content
   attributes; <code id="submit-button-state-(type=submit):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attribute.</p>

   <p>The <code id="submit-button-state-(type=submit):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-default" id="submit-button-state-(type=submit):dom-input-value-default">default</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="submit-button-state-(type=submit):do-not-apply">do not apply</a> to the
   element:
   <code id="submit-button-state-(type=submit):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="submit-button-state-(type=submit):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="submit-button-state-(type=submit):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-required"><a href="#attr-input-required">required</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="submit-button-state-(type=submit):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="submit-button-state-(type=submit):do-not-apply-2">do not apply</a> to the element:
   <code id="submit-button-state-(type=submit):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="submit-button-state-(type=submit):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="submit-button-state-(type=submit):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="submit-button-state-(type=submit):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="submit-button-state-(type=submit):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="submit-button-state-(type=submit):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="submit-button-state-(type=submit):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="submit-button-state-(type=submit):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="submit-button-state-(type=submit):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="submit-button-state-(type=submit):event-change"><a href="#event-change">change</a></code> events <a href="#do-not-apply" id="submit-button-state-(type=submit):do-not-apply-3">do not apply</a>.</p>

  </div>


  <h6 id="image-button-state-(type=image)"><span class="secno">4.10.5.1.19</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Image Button</dfn> state (<code>type=image</code>)<a href="#image-button-state-(type=image)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/image" title="<input> elements of type image are used to create graphical submit buttons, i.e. submit buttons that take the form of an image rather than text.">Element/input/image</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="image-button-state-(type=image):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="image-button-state-(type=image):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#image-button-state-(type=image)" id="image-button-state-(type=image):image-button-state-(type=image)">Image Button</a> state, the rules in this section
  apply.</p>

  

  <p>The <code id="image-button-state-(type=image):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="image-button-state-(type=image):represents">represents</a> either an image from which a user can
  select a coordinate and submit the form, or alternatively a button from which the user can submit
  the form. The element is a <a href="#concept-button" id="image-button-state-(type=image):concept-button">button</a>, specifically a <a href="#concept-submit-button" id="image-button-state-(type=image):concept-submit-button">submit button</a>.</p>

  <p class="note">The coordinate is sent to the server <a href="#constructing-the-form-data-set" id="image-button-state-(type=image):constructing-the-form-data-set">during form submission</a> by sending two entries for the element, derived from the name
  of the control but with "<code>.x</code>" and "<code>.y</code>" appended to
  the name with the <var>x</var> and <var>y</var> components of the coordinate respectively.</p>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#src" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#src</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The image is given by the <dfn data-dfn-for="input" id="attr-input-src" data-dfn-type="element-attr"><code>src</code></dfn> attribute. The <code id="image-button-state-(type=image):attr-input-src"><a href="#attr-input-src">src</a></code>
  attribute must be present, and must contain a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="image-button-state-(type=image):valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by
  spaces</a> referencing a non-interactive, optionally animated, image resource that is neither
  paged nor scripted.</p>

  

  <div data-algorithm="">
  <p>When any of these events occur:

  </p><ul><li>the <code id="image-button-state-(type=image):the-input-element-3"><a href="#the-input-element">input</a></code> element's <code id="image-button-state-(type=image):attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is
   first set to the <a href="#image-button-state-(type=image)" id="image-button-state-(type=image):image-button-state-(type=image)-2">Image Button</a> state (possibly when
   the element is first created), and the <code id="image-button-state-(type=image):attr-input-src-2"><a href="#attr-input-src">src</a></code> attribute is
   present</li><li>the <code id="image-button-state-(type=image):the-input-element-4"><a href="#the-input-element">input</a></code> element's <code id="image-button-state-(type=image):attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is
   changed back to the <a href="#image-button-state-(type=image)" id="image-button-state-(type=image):image-button-state-(type=image)-3">Image Button</a> state, and the <code id="image-button-state-(type=image):attr-input-src-3"><a href="#attr-input-src">src</a></code> attribute is present, and its value has changed since the last
   time the <code id="image-button-state-(type=image):attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute was in the <a href="#image-button-state-(type=image)" id="image-button-state-(type=image):image-button-state-(type=image)-4">Image Button</a> state</li><li>the <code id="image-button-state-(type=image):the-input-element-5"><a href="#the-input-element">input</a></code> element's <code id="image-button-state-(type=image):attr-input-type-5"><a href="#attr-input-type">type</a></code> attribute is in
   the <a href="#image-button-state-(type=image)" id="image-button-state-(type=image):image-button-state-(type=image)-5">Image Button</a> state, and the <code id="image-button-state-(type=image):attr-input-src-4"><a href="#attr-input-src">src</a></code> attribute is set or changed</li></ul> 

  <p>then unless the user agent cannot support images, or its support for images has been disabled,
  or the user agent only fetches images on demand, or the <code id="image-button-state-(type=image):attr-input-src-5"><a href="#attr-input-src">src</a></code>
  attribute's value is the empty string, run these steps:

  </p><ol><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="image-button-state-(type=image):encoding-parsing-a-url">encoding-parsing a URL</a> given the <code id="image-button-state-(type=image):attr-input-src-6"><a href="#attr-input-src">src</a></code> attribute's value, relative to the element's <a id="image-button-state-(type=image):node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>.</p></li><li><p>If <var>url</var> is failure, then return.</p></li><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="image-button-state-(type=image):concept-request" data-x-internal="concept-request">request</a> whose <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="image-button-state-(type=image):concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>url</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="image-button-state-(type=image):concept-request-client" data-x-internal="concept-request-client">client</a> is the element's <a id="image-button-state-(type=image):node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
   <a href="#relevant-settings-object" id="image-button-state-(type=image):relevant-settings-object">relevant settings object</a>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="image-button-state-(type=image):concept-request-destination" data-x-internal="concept-request-destination">destination</a> is "<code>image</code>", <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="image-button-state-(type=image):concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator type</a> is "<code>input</code>",
   <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="image-button-state-(type=image):concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> is "<code>include</code>", and whose <a id="image-button-state-(type=image):use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a> is set.</p></li><li>
    <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="image-button-state-(type=image):concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var>, with
    <i id="image-button-state-(type=image):processresponseendofbody"><a data-x-internal="processresponseendofbody" href="https://fetch.spec.whatwg.org/#fetch-processresponseendofbody">processResponseEndOfBody</a></i> set to the following steps
    given <a href="https://fetch.spec.whatwg.org/#concept-response" id="image-button-state-(type=image):concept-response" data-x-internal="concept-response">response</a> <var>response</var>:</p>

    <ol><li><p>If the download was successful and the image is <i id="image-button-state-(type=image):input-img-available"><a href="#input-img-available">available</a></i>, <a href="#queue-an-element-task" id="image-button-state-(type=image):queue-an-element-task">queue an element task</a> on the
      <a href="#user-interaction-task-source" id="image-button-state-(type=image):user-interaction-task-source">user interaction task source</a> given the <code id="image-button-state-(type=image):the-input-element-6"><a href="#the-input-element">input</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="image-button-state-(type=image):concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="image-button-state-(type=image):event-load"><a href="#event-load">load</a></code>
      at the <code id="image-button-state-(type=image):the-input-element-7"><a href="#the-input-element">input</a></code> element.</p></li><li><p>Otherwise, if the fetching process fails without a response from the remote server, or
      completes but the image is not a valid or supported image, then <a href="#queue-an-element-task" id="image-button-state-(type=image):queue-an-element-task-2">queue an element
      task</a> on the <a href="#user-interaction-task-source" id="image-button-state-(type=image):user-interaction-task-source-2">user interaction task source</a> given the <code id="image-button-state-(type=image):the-input-element-8"><a href="#the-input-element">input</a></code>
      element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="image-button-state-(type=image):concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="image-button-state-(type=image):event-error"><a href="#event-error">error</a></code> on the <code id="image-button-state-(type=image):the-input-element-9"><a href="#the-input-element">input</a></code> element.</p></li></ol>
   </li></ol>
  </div>

  
  <div data-algorithm="">
  <p>Fetching the image must <a href="#delay-the-load-event" id="image-button-state-(type=image):delay-the-load-event">delay the load event</a> of the element's <a id="image-button-state-(type=image):node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> until the
  <a href="#concept-task" id="image-button-state-(type=image):concept-task">task</a> that is <a href="#queue-a-task" id="image-button-state-(type=image):queue-a-task">queued</a> by the
  <a href="#networking-task-source" id="image-button-state-(type=image):networking-task-source">networking task source</a> once the resource has been fetched (defined below) has been
  run.</p>
  </div>

  <p>If the image was successfully obtained, with no network errors, and the image's type is a
  supported image type, and the image is a valid image of that type, then the image is said to be
  <dfn id="input-img-available"><i>available</i></dfn>. If this is true before the image is
  completely downloaded, each <a href="#concept-task" id="image-button-state-(type=image):concept-task-2">task</a> that is <a href="#queue-a-task" id="image-button-state-(type=image):queue-a-task-2">queued</a> by the <a href="#networking-task-source" id="image-button-state-(type=image):networking-task-source-2">networking task source</a> while the image is being fetched
  must update the presentation of the image appropriately.</p>

  <p>The user agent should apply the <a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-images-specifically" id="image-button-state-(type=image):content-type-sniffing:-image" data-x-internal="content-type-sniffing:-image">image sniffing
  rules</a> to determine the type of the image, with the image's <a href="#content-type" id="image-button-state-(type=image):content-type">associated Content-Type headers</a> giving the <var>official
  type</var>. If these rules are not applied, then the type of the image must be the type given by
  the image's <a href="#content-type" id="image-button-state-(type=image):content-type-2">associated Content-Type headers</a>.</p>

  <p>User agents must not support non-image resources with the <code id="image-button-state-(type=image):the-input-element-10"><a href="#the-input-element">input</a></code> element. User
  agents must not run executable code embedded in the image resource. User agents must only display
  the first page of a multipage resource. User agents must not allow the resource to act in an
  interactive fashion, but should honor any animation in the resource.</p>
  <hr>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#alt" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#alt</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="input" id="attr-input-alt" data-dfn-type="element-attr"><code>alt</code></dfn> attribute
  provides the textual label for the button for users and user agents who cannot use the image. The
  <code id="image-button-state-(type=image):attr-input-alt"><a href="#attr-input-alt">alt</a></code> attribute must be present, and must contain a non-empty
  string giving the label that would be appropriate for an equivalent button if the image was
  unavailable.</p>

  <p>The <code id="image-button-state-(type=image):the-input-element-11"><a href="#the-input-element">input</a></code> element supports <a href="#dimension-attributes" id="image-button-state-(type=image):dimension-attributes">dimension attributes</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>If the <code id="image-button-state-(type=image):attr-input-src-7"><a href="#attr-input-src">src</a></code> attribute is set, and the image is <i id="image-button-state-(type=image):input-img-available-2"><a href="#input-img-available">available</a></i> and the user agent is configured to display that image,
  then the element <a href="#represents" id="image-button-state-(type=image):represents-2">represents</a> a control for selecting a <a href="#concept-input-type-image-coordinate" id="image-button-state-(type=image):concept-input-type-image-coordinate">coordinate</a> from the image specified by the
  <code id="image-button-state-(type=image):attr-input-src-8"><a href="#attr-input-src">src</a></code> attribute. In that case, if the element is <i id="image-button-state-(type=image):concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, the user agent should allow the user to select this <a href="#concept-input-type-image-coordinate" id="image-button-state-(type=image):concept-input-type-image-coordinate-2">coordinate</a>.</p>

  <p>Otherwise, the element <a href="#represents" id="image-button-state-(type=image):represents-3">represents</a> a submit button whose label is given by the
  value of the <code id="image-button-state-(type=image):attr-input-alt-2"><a href="#attr-input-alt">alt</a></code> attribute.</p>
  </div>

  

  <div data-algorithm="">
  <p>The element's <a href="#input-activation-behavior" id="image-button-state-(type=image):input-activation-behavior">input activation behavior</a> given <var>event</var> is as follows:</p>

  <ol><li><p>If the element does not have a <a href="#form-owner" id="image-button-state-(type=image):form-owner">form owner</a>, then return.</p></li><li><p>If the element's <a id="image-button-state-(type=image):node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="image-button-state-(type=image):fully-active">fully active</a>, then
   return.</p></li><li>
    <p>If the user activated the control while explicitly selecting a coordinate, then set the
    element's <a href="#concept-input-type-image-coordinate" id="image-button-state-(type=image):concept-input-type-image-coordinate-3">selected coordinate</a> to that
    coordinate.</p>

    <p class="note">This is only possible under the conditions outlined above, when the element
    <a href="#represents" id="image-button-state-(type=image):represents-4">represents</a> a control for selecting such a coordinate. Even then, the user
    might activate the control without explicitly selecting a coordinate.</p>
   </li><li><p><a href="#concept-form-submit" id="image-button-state-(type=image):concept-form-submit">Submit</a> the element's <a href="#form-owner" id="image-button-state-(type=image):form-owner-2">form owner</a>
   from the element with <i id="image-button-state-(type=image):submit-user-involvement"><a href="#submit-user-involvement">userInvolvement</a></i> set to
   <var>event</var>'s <a href="#event-uni" id="image-button-state-(type=image):event-uni">user navigation involvement</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The element's <dfn id="concept-input-type-image-coordinate">selected coordinate</dfn>
  consists of an <var>x</var>-component and a <var>y</var>-component. It is initially (0, 0). The
  coordinates represent the position relative to the edge of the element's image, with the
  coordinate space having the positive <var>x</var> direction to the right, and the positive
  <var>y</var> direction downwards.</p>

  <p>The <var>x</var>-component must be a <a href="#valid-integer" id="image-button-state-(type=image):valid-integer">valid integer</a> representing a number
  <var>x</var> in the range <span>−(<var>border<sub>left</sub></var>+<var>padding<sub>left</sub></var>) ≤ <var>x</var> ≤ <var>width</var>+<var>border<sub>right</sub></var>+<var>padding<sub>right</sub></var></span>, where <var>width</var> is the rendered width of the image, <var>border<sub>left</sub></var> is the width of the border on the left of the image, <var>padding<sub>left</sub></var> is the width of the padding on the left of the
  image, <var>border<sub>right</sub></var> is the width of the border on the right
  of the image, and <var>padding<sub>right</sub></var> is the width of the padding
  on the right of the image, with all dimensions given in <a href="https://drafts.csswg.org/css-values/#px" id="image-button-state-(type=image):'px'" data-x-internal="'px'">CSS pixels</a>.</p>

  <p>The <var>y</var>-component must be a <a href="#valid-integer" id="image-button-state-(type=image):valid-integer-2">valid integer</a> representing a number
  <var>y</var> in the range <span>−(<var>border<sub>top</sub></var>+<var>padding<sub>top</sub></var>) ≤ <var>y</var> ≤ <var>height</var>+<var>border<sub>bottom</sub></var>+<var>padding<sub>bottom</sub></var></span>, where
  <var>height</var> is the rendered height of the image, <var>border<sub>top</sub></var> is the width of the border above the image, <var>padding<sub>top</sub></var> is the width of the padding above the image, <var>border<sub>bottom</sub></var> is the width of the border below the image, and <var>padding<sub>bottom</sub></var> is the width of the padding below the image, with
  all dimensions given in <a href="https://drafts.csswg.org/css-values/#px" id="image-button-state-(type=image):'px'-2" data-x-internal="'px'">CSS pixels</a>.</p>
  </div>

  <p>Where a border or padding is missing, its width is zero <a href="https://drafts.csswg.org/css-values/#px" id="image-button-state-(type=image):'px'-3" data-x-internal="'px'">CSS
  pixels</a>.</p>

  <hr>

  

  <p>The <code id="image-button-state-(type=image):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>, <code id="image-button-state-(type=image):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>, <code id="image-button-state-(type=image):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>, <code id="image-button-state-(type=image):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>, and <code id="image-button-state-(type=image):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code> attributes are <a href="#attributes-for-form-submission" id="image-button-state-(type=image):attributes-for-form-submission">attributes for form
  submission</a>.</p>

  <dl class="domintro"><dt><code><var>image</var>.<a href="#dom-input-width" id="dom-input-width-dev">width</a> [ = <var>value</var> ]</code></dt><dt><code><var>image</var>.<a href="#dom-input-height" id="dom-input-height-dev">height</a> [ = <var>value</var> ]</code></dt><dd>
    <p>These attributes return the actual rendered dimensions of the image, or 0 if the dimensions
    are not known.</p>

    <p>They can be set, to change the corresponding content attributes.</p>
   </dd></dl>

  <div class="bookkeeping">

   <p>The following common <code id="image-button-state-(type=image):the-input-element-12"><a href="#the-input-element">input</a></code> element content attributes and IDL attributes <a href="#concept-input-apply" id="image-button-state-(type=image):concept-input-apply">apply</a> to the element:
   <code id="image-button-state-(type=image):attr-input-alt-3"><a href="#attr-input-alt">alt</a></code>,
   <code id="image-button-state-(type=image):attr-fs-formaction-2"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="image-button-state-(type=image):attr-fs-formenctype-2"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="image-button-state-(type=image):attr-fs-formmethod-2"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="image-button-state-(type=image):attr-fs-formnovalidate-2"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="image-button-state-(type=image):attr-fs-formtarget-2"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="image-button-state-(type=image):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="image-button-state-(type=image):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>,
   <code id="image-button-state-(type=image):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>,
   <code id="image-button-state-(type=image):attr-input-src-9"><a href="#attr-input-src">src</a></code>, and
   <code id="image-button-state-(type=image):attr-dim-width"><a href="#attr-dim-width">width</a></code> content attributes;
   <code id="image-button-state-(type=image):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attribute.</p>

   <p>The <code id="image-button-state-(type=image):dom-input-value-2"><a href="#dom-input-value">value</a></code> IDL attribute is in mode <a href="#dom-input-value-default" id="image-button-state-(type=image):dom-input-value-default">default</a>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="image-button-state-(type=image):do-not-apply">do not apply</a> to the
   element:
   <code id="image-button-state-(type=image):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="image-button-state-(type=image):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="image-button-state-(type=image):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="image-button-state-(type=image):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="image-button-state-(type=image):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="image-button-state-(type=image):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="image-button-state-(type=image):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="image-button-state-(type=image):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="image-button-state-(type=image):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="image-button-state-(type=image):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="image-button-state-(type=image):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="image-button-state-(type=image):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="image-button-state-(type=image):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="image-button-state-(type=image):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="image-button-state-(type=image):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="image-button-state-(type=image):attr-input-required"><a href="#attr-input-required">required</a></code>,
   <code id="image-button-state-(type=image):attr-input-size"><a href="#attr-input-size">size</a></code>, and
   <code id="image-button-state-(type=image):attr-input-step"><a href="#attr-input-step">step</a></code>.</p>

   <p>The element's <code id="image-button-state-(type=image):attr-input-value"><a href="#attr-input-value">value</a></code> attribute must be omitted.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="image-button-state-(type=image):do-not-apply-2">do not apply</a> to the element:
   <code id="image-button-state-(type=image):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="image-button-state-(type=image):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="image-button-state-(type=image):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="image-button-state-(type=image):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="image-button-state-(type=image):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="image-button-state-(type=image):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="image-button-state-(type=image):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="image-button-state-(type=image):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="image-button-state-(type=image):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="image-button-state-(type=image):event-change"><a href="#event-change">change</a></code> events <a href="#do-not-apply" id="image-button-state-(type=image):do-not-apply-3">do not apply</a>.</p>

  </div>

  <p class="note">Many aspects of this state's behavior are similar to the behavior of the
  <code id="image-button-state-(type=image):the-img-element"><a href="#the-img-element">img</a></code> element. Readers are encouraged to read that section, where many of the same
  requirements are described in more detail.</p>

  <div class="example">

   <p>Take the following form:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"process.cgi"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">image</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">map.png</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">where</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Show location list"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

   <p>If the user clicked on the image at coordinate (127,40) then the URL used to submit the form
   would be "<code>process.cgi?where.x=127&amp;where.y=40</code>".</p>

   <p>(In this example, it's assumed that for users who don't see the map, and who instead just see
   a button labeled "Show location list", clicking the button will cause the server to show a list
   of locations to pick from instead of the map.)</p>

  </div>



  <h6 id="reset-button-state-(type=reset)"><span class="secno">4.10.5.1.20</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Reset Button</dfn> state (<code>type=reset</code>)<a href="#reset-button-state-(type=reset)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/reset" title="<input> elements of type reset are rendered as buttons, with a default click event handler that resets all inputs in the form to their initial values.">Element/input/reset</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="reset-button-state-(type=reset):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="reset-button-state-(type=reset):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#reset-button-state-(type=reset)" id="reset-button-state-(type=reset):reset-button-state-(type=reset)">Reset Button</a> state, the rules in this section
  apply.</p>

  

  <p>
  <a id="reset-button-state-(type=reset):tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  The <code id="reset-button-state-(type=reset):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="reset-button-state-(type=reset):represents">represents</a> a button that, when activated, resets the
  form. If the element has a <code id="reset-button-state-(type=reset):attr-input-value"><a href="#attr-input-value">value</a></code> attribute,
  the button's label must be the value of that attribute; otherwise, it must be an
  <a id="reset-button-state-(type=reset):implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> string that means "Reset" or some such. The element is
  a <a href="#concept-button" id="reset-button-state-(type=reset):concept-button">button</a>.</p>

  <p class="note">Since the default label is <a id="reset-button-state-(type=reset):implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>, and the width of
  the button typically depends on the button's label, the button's width can leak a few bits of
  fingerprintable information. These bits are likely to be strongly correlated to the identity of
  the user agent and the user's locale.</p>

  

  <div data-algorithm="">
  <p>The element's <a href="#input-activation-behavior" id="reset-button-state-(type=reset):input-activation-behavior">input activation behavior</a> is as follows:</p>

  <ol><li><p>If the element does not have a <a href="#form-owner" id="reset-button-state-(type=reset):form-owner">form owner</a>, then return.</p></li><li><p>If the element's <a id="reset-button-state-(type=reset):node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="reset-button-state-(type=reset):fully-active">fully active</a>, then
   return.</p></li><li><p><a href="#concept-form-reset" id="reset-button-state-(type=reset):concept-form-reset">Reset</a> the <a href="#form-owner" id="reset-button-state-(type=reset):form-owner-2">form owner</a> from the
   element.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: The element is <a href="#barred-from-constraint-validation" id="reset-button-state-(type=reset):barred-from-constraint-validation">barred from constraint
  validation</a>.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The <code id="reset-button-state-(type=reset):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attribute <a href="#concept-input-apply" id="reset-button-state-(type=reset):concept-input-apply">applies</a> to this element and is in mode <a href="#dom-input-value-default" id="reset-button-state-(type=reset):dom-input-value-default">default</a>.</p>

   <p>The following common <code id="reset-button-state-(type=reset):the-input-element-3"><a href="#the-input-element">input</a></code> element content attributes <a href="#concept-input-apply" id="reset-button-state-(type=reset):concept-input-apply-2">apply</a> to the element:
   <code id="reset-button-state-(type=reset):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code> and
   <code id="reset-button-state-(type=reset):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="reset-button-state-(type=reset):do-not-apply">do not apply</a> to the
   element:
   <code id="reset-button-state-(type=reset):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="reset-button-state-(type=reset):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="reset-button-state-(type=reset):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="reset-button-state-(type=reset):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-required"><a href="#attr-input-required">required</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="reset-button-state-(type=reset):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="reset-button-state-(type=reset):do-not-apply-2">do not apply</a> to the element:
   <code id="reset-button-state-(type=reset):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="reset-button-state-(type=reset):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="reset-button-state-(type=reset):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="reset-button-state-(type=reset):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="reset-button-state-(type=reset):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="reset-button-state-(type=reset):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="reset-button-state-(type=reset):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="reset-button-state-(type=reset):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="reset-button-state-(type=reset):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="reset-button-state-(type=reset):event-change"><a href="#event-change">change</a></code> events <a href="#do-not-apply" id="reset-button-state-(type=reset):do-not-apply-3">do not apply</a>.</p>

  </div>


  <h6 id="button-state-(type=button)"><span class="secno">4.10.5.1.21</span> <dfn data-dfn-for="input" data-dfn-type="element-state">Button</dfn> state (<code>type=button</code>)<a href="#button-state-(type=button)" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/button" title="<input> elements of type button are rendered as simple push buttons, which can be programmed to control custom functionality anywhere on a webpage as required when assigned an event handler function (typically for the click event).">Element/input/button</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>When an <code id="button-state-(type=button):the-input-element"><a href="#the-input-element">input</a></code> element's <code id="button-state-(type=button):attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#button-state-(type=button)" id="button-state-(type=button):button-state-(type=button)">Button</a> state, the rules in this section apply.</p>

  

  <p>The <code id="button-state-(type=button):the-input-element-2"><a href="#the-input-element">input</a></code> element <a href="#represents" id="button-state-(type=button):represents">represents</a> a button with no default behavior. A
  label for the button must be provided in the <code id="button-state-(type=button):attr-input-value"><a href="#attr-input-value">value</a></code>
  attribute, though it may be the empty string. If the element has a <code id="button-state-(type=button):attr-input-value-2"><a href="#attr-input-value">value</a></code> attribute, the button's label must be the value of that
  attribute; otherwise, it must be the empty string. The element is a <a href="#concept-button" id="button-state-(type=button):concept-button">button</a>.</p>

  

  <p>The element has no <a href="#input-activation-behavior" id="button-state-(type=button):input-activation-behavior">input activation behavior</a>.</p>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: The element is <a href="#barred-from-constraint-validation" id="button-state-(type=button):barred-from-constraint-validation">barred from constraint
  validation</a>.</p>
  </div>

  

  <div class="bookkeeping">

   <p>The <code id="button-state-(type=button):dom-input-value"><a href="#dom-input-value">value</a></code> IDL attribute <a href="#concept-input-apply" id="button-state-(type=button):concept-input-apply">applies</a> to this element and is in mode <a href="#dom-input-value-default" id="button-state-(type=button):dom-input-value-default">default</a>.</p>

   <p>The following common <code id="button-state-(type=button):the-input-element-3"><a href="#the-input-element">input</a></code> element content attributes <a href="#concept-input-apply" id="button-state-(type=button):concept-input-apply-2">apply</a> to the element:
   <code id="button-state-(type=button):attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code> and
   <code id="button-state-(type=button):attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>.</p>

   <p>The following content attributes must not be specified and <a href="#do-not-apply" id="button-state-(type=button):do-not-apply">do not apply</a> to the
   element:
   <code id="button-state-(type=button):attr-input-accept"><a href="#attr-input-accept">accept</a></code>,
   <code id="button-state-(type=button):attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>,
   <code id="button-state-(type=button):attr-input-alt"><a href="#attr-input-alt">alt</a></code>,
   <code id="button-state-(type=button):attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>,
   <code id="button-state-(type=button):attr-input-checked"><a href="#attr-input-checked">checked</a></code>,
   <code id="button-state-(type=button):attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>,
   <code id="button-state-(type=button):attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>,
   <code id="button-state-(type=button):attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>,
   <code id="button-state-(type=button):attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>,
   <code id="button-state-(type=button):attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>,
   <code id="button-state-(type=button):attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>,
   <code id="button-state-(type=button):attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>,
   <code id="button-state-(type=button):attr-dim-height"><a href="#attr-dim-height">height</a></code>,
   <code id="button-state-(type=button):attr-input-list"><a href="#attr-input-list">list</a></code>,
   <code id="button-state-(type=button):attr-input-max"><a href="#attr-input-max">max</a></code>,
   <code id="button-state-(type=button):attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>,
   <code id="button-state-(type=button):attr-input-min"><a href="#attr-input-min">min</a></code>,
   <code id="button-state-(type=button):attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>,
   <code id="button-state-(type=button):attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>,
   <code id="button-state-(type=button):attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>,
   <code id="button-state-(type=button):attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>,
   <code id="button-state-(type=button):attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>,
   <code id="button-state-(type=button):attr-input-required"><a href="#attr-input-required">required</a></code>,
   <code id="button-state-(type=button):attr-input-size"><a href="#attr-input-size">size</a></code>,
   <code id="button-state-(type=button):attr-input-src"><a href="#attr-input-src">src</a></code>,
   <code id="button-state-(type=button):attr-input-step"><a href="#attr-input-step">step</a></code>, and
   <code id="button-state-(type=button):attr-dim-width"><a href="#attr-dim-width">width</a></code>.</p>

   <p>The following IDL attributes and methods <a href="#do-not-apply" id="button-state-(type=button):do-not-apply-2">do not apply</a> to the element:
   <code id="button-state-(type=button):dom-input-checked"><a href="#dom-input-checked">checked</a></code>,
   <code id="button-state-(type=button):dom-input-files"><a href="#dom-input-files">files</a></code>,
   <code id="button-state-(type=button):dom-input-list"><a href="#dom-input-list">list</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>,
   <code id="button-state-(type=button):dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code>, and
   <code id="button-state-(type=button):dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> IDL attributes;
   <code id="button-state-(type=button):dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code>,
   <code id="button-state-(type=button):dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code>, and
   <code id="button-state-(type=button):dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods.</p>

   <p>The <code id="button-state-(type=button):event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="button-state-(type=button):event-change"><a href="#event-change">change</a></code> events <a href="#do-not-apply" id="button-state-(type=button):do-not-apply-3">do not apply</a>.</p>

  </div>


  

  <h5 id="input-impl-notes"><span class="secno">4.10.5.2</span> Implementation notes regarding localization of form controls<a href="#input-impl-notes" class="self-link"></a></h5>
  

  <p><i>This section is non-normative.</i></p>

  <p>The formats shown to the user in date, time, and number controls is independent of the format
  used for form submission.</p>

  <p>Browsers are encouraged to use user interfaces that present dates, times, and numbers according
  to the conventions of either the locale implied by the <code id="input-impl-notes:the-input-element"><a href="#the-input-element">input</a></code> element's
  <a href="#language" id="input-impl-notes:language">language</a> or the user's preferred locale. Using the page's locale will ensure
  consistency with page-provided data.

  </p><p class="example">For example, it would be confusing to users if an American English page claimed
  that a Cirque De Soleil show was going to be showing on 02/03, but their
  browser, configured to use the British English locale, only showed the date 03/02 in the ticket purchase date picker. Using the page's locale would at least ensure that the
  date was presented in the same format everywhere. (There's still a risk that the user would end up
  arriving a month late, of course, but there's only so much that can be done about such cultural
  differences...)</p>

  



  <h5 id="common-input-element-attributes"><span class="secno">4.10.5.3</span> Common <code id="common-input-element-attributes:the-input-element"><a href="#the-input-element">input</a></code> element attributes<a href="#common-input-element-attributes" class="self-link"></a></h5>

  

  <p>These attributes only <a href="#concept-input-apply" id="common-input-element-attributes:concept-input-apply">apply</a> to an <code id="common-input-element-attributes:the-input-element-2"><a href="#the-input-element">input</a></code>
  element if its <code id="common-input-element-attributes:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in a state whose definition
  declares that the attribute <a href="#concept-input-apply" id="common-input-element-attributes:concept-input-apply-2">applies</a>. When an attribute
  <a href="#do-not-apply" id="common-input-element-attributes:do-not-apply">doesn't apply</a> to an <code id="common-input-element-attributes:the-input-element-3"><a href="#the-input-element">input</a></code> element, user agents must
  <a href="#ignore" id="common-input-element-attributes:ignore">ignore</a> the attribute, regardless of the requirements and definitions below.</p>

  


  <h6 id="the-maxlength-and-minlength-attributes"><span class="secno">4.10.5.3.1</span> The <code id="the-maxlength-and-minlength-attributes:attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code> and <code id="the-maxlength-and-minlength-attributes:attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code> attributes<a href="#the-maxlength-and-minlength-attributes" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/maxlength" title="The maxlength attribute defines the maximum string length that the user can enter into an <input> or <textarea>. The attribute must have an integer value of 0 or higher.">Attributes/maxlength</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/minlength" title="The minlength attribute defines the minimum string length that the user can enter into an <input> or <textarea>. The attribute must have an integer value of 0 or higher.">Attributes/minlength</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>51+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>40+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/maxlength" title="The maxlength attribute defines the maximum string length that the user can enter into an <input> or <textarea>. The attribute must have an integer value of 0 or higher.">Attributes/maxlength</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/minlength" title="The minlength attribute defines the minimum string length that the user can enter into an <input> or <textarea>. The attribute must have an integer value of 0 or higher.">Attributes/minlength</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>51+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>40+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-maxlength" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#attr-maxlength</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>15+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>5+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>9+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.5+</span></span><span class="opera_android yes"><span>Opera Android</span><span>15+</span></span><hr><span class="caniuse"><span><a href="https://caniuse.com/#feat=maxlength" title="maxlength attribute for input and textarea elements">caniuse.com table</a></span></span></div></div></div><p>The <dfn data-dfn-for="input" id="attr-input-maxlength" data-dfn-type="element-attr"><code>maxlength</code></dfn>
  attribute, when it <a href="#concept-input-apply" id="the-maxlength-and-minlength-attributes:concept-input-apply">applies</a>, is a
  <a href="#attr-fe-maxlength" id="the-maxlength-and-minlength-attributes:attr-fe-maxlength">form control <code>maxlength</code>
  attribute</a>.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-minlength" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#attr-minlength</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>51+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>40+</span></span><hr><span class="opera yes"><span>Opera</span><span>27+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>51+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>10.3+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>40+</span></span><span class="webview_android yes"><span>WebView Android</span><span>40+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>4.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>27+</span></span><hr><span class="caniuse"><span><a href="https://caniuse.com/#feat=input-minlength" title="Minimum length attribute for input fields">caniuse.com table</a></span></span></div></div></div><p>The <dfn data-dfn-for="input" id="attr-input-minlength" data-dfn-type="element-attr"><code>minlength</code></dfn>
  attribute, when it <a href="#concept-input-apply" id="the-maxlength-and-minlength-attributes:concept-input-apply-2">applies</a>, is a
  <a href="#attr-fe-minlength" id="the-maxlength-and-minlength-attributes:attr-fe-minlength">form control <code>minlength</code>
  attribute</a>.</p>

  <p>If the <code id="the-maxlength-and-minlength-attributes:the-input-element"><a href="#the-input-element">input</a></code> element has a <a href="#maximum-allowed-value-length" id="the-maxlength-and-minlength-attributes:maximum-allowed-value-length">maximum allowed value length</a>, then the
  <a id="the-maxlength-and-minlength-attributes:length" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the value of the element's <code id="the-maxlength-and-minlength-attributes:attr-input-value"><a href="#attr-input-value">value</a></code>
  attribute must be less than or equal to the element's <a href="#maximum-allowed-value-length" id="the-maxlength-and-minlength-attributes:maximum-allowed-value-length-2">maximum allowed value
  length</a>.</p>

  

  <div class="example">

   <p>The following extract shows how a messaging client's text entry could be arbitrarily
   restricted to a fixed number of characters, thus forcing any conversation through this medium to
   be terse and discouraging intelligent discourse.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->What are you doing? <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">status</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">140</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Here, a password is given a minimum length:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Username: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">u</c-> <c- e="">required</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Password: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">p</c-> <c- e="">required</c-> <c- e="">minlength</c-><c- o="">=</c-><c- s="">12</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h6 id="the-size-attribute"><span class="secno">4.10.5.3.2</span> The <code id="the-size-attribute:attr-input-size"><a href="#attr-input-size">size</a></code> attribute<a href="#the-size-attribute" class="self-link"></a></h6>

  <p>The <dfn data-dfn-for="input" id="attr-input-size" data-dfn-type="element-attr"><code>size</code></dfn> attribute
  gives the number of characters that, in a visual rendering, the user agent is to allow the user to
  see while editing the element's <a href="#concept-fe-value" id="the-size-attribute:concept-fe-value">value</a>.</p>

  <p>The <code id="the-size-attribute:attr-input-size-2"><a href="#attr-input-size">size</a></code> attribute, if specified, must have a value that
  is a <a href="#valid-non-negative-integer" id="the-size-attribute:valid-non-negative-integer">valid non-negative integer</a> greater than zero.</p>

  

  <p>If the attribute is present, then its value must be parsed using the <a href="#rules-for-parsing-non-negative-integers" id="the-size-attribute:rules-for-parsing-non-negative-integers">rules for parsing
  non-negative integers</a>, and if the result is a number greater than zero, then the user agent
  should ensure that at least that many characters are visible.</p>

  <p>The <code id="the-size-attribute:dom-input-size"><a href="#dom-input-size">size</a></code> IDL attribute is <a href="#limited-to-only-non-negative-numbers-greater-than-zero" id="the-size-attribute:limited-to-only-non-negative-numbers-greater-than-zero">limited to only positive
  numbers</a> and has a <a href="#default-value" id="the-size-attribute:default-value">default value</a> of 20.</p>

  



  <h6 id="the-readonly-attribute"><span class="secno">4.10.5.3.3</span> The <code id="the-readonly-attribute:attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code> attribute<a href="#the-readonly-attribute" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly" title="The Boolean readonly attribute, when present, makes the element not mutable, meaning the user can not edit the control.">Attributes/readonly</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly" title="The Boolean readonly attribute, when present, makes the element not mutable, meaning the user can not edit the control.">Attributes/readonly</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly" title="The Boolean readonly attribute, when present, makes the element not mutable, meaning the user can not edit the control.">Attributes/readonly</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>≤4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>≤12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>≤6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>≤12.1+</span></span></div></div></div>

  <p>The <dfn data-dfn-for="input" id="attr-input-readonly" data-dfn-type="element-attr"><code>readonly</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-readonly-attribute:boolean-attribute">boolean attribute</a> that controls whether or not the user can edit the
  form control. When specified, the element is not <i id="the-readonly-attribute:concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>.</p>

  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the <code id="the-readonly-attribute:attr-input-readonly-2"><a href="#attr-input-readonly">readonly</a></code> attribute is specified on an <code id="the-readonly-attribute:the-input-element"><a href="#the-input-element">input</a></code>
  element, the element is <a href="#barred-from-constraint-validation" id="the-readonly-attribute:barred-from-constraint-validation">barred from constraint validation</a>.</p>
  </div>

  

  <div class="note">
   <p>The difference between <code id="the-readonly-attribute:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code> and <code id="the-readonly-attribute:attr-input-readonly-3"><a href="#attr-input-readonly">readonly</a></code> is that read-only controls can still function,
   whereas disabled controls generally do not function as controls until they are enabled. This is
   spelled out in more detail elsewhere in this specification with normative requirements that refer
   to the <a href="#concept-fe-disabled" id="the-readonly-attribute:concept-fe-disabled">disabled</a> concept (for example, the element's
   <a id="the-readonly-attribute:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a>, whether or not it is a <a href="#focusable-area" id="the-readonly-attribute:focusable-area">focusable area</a>, or when
   <a href="#constructing-the-form-data-set" id="the-readonly-attribute:constructing-the-form-data-set">constructing the entry list</a>). Any other behavior related to user interaction with
   disabled controls, such as whether text can be selected or copied, is not defined in this
   standard.</p>

   <p>Only text controls can be made read-only, since for other controls (such as checkboxes and
   buttons) there is no useful distinction between being read-only and being disabled, so the
   <code id="the-readonly-attribute:attr-input-readonly-4"><a href="#attr-input-readonly">readonly</a></code> attribute <a href="#do-not-apply" id="the-readonly-attribute:do-not-apply">does not
   apply</a>.</p>
  </div>

  <div class="example">

   <p>In the following example, the existing product identifiers cannot be modified, but they are
   still displayed as part of the form, for consistency with the row representing a new product
   (where the identifier is not yet filled in).</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"products.cgi"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"post"</c-> <c- e="">enctype</c-><c- o="">=</c-><c- s="">"multipart/form-data"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Product ID <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Product name <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Price <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Action
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">readonly</c-><c- o="">=</c-><c- s="">"readonly"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"1.pid"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"H412"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">required</c-><c- o="">=</c-><c- s="">"required"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"1.pname"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Floor lamp Ulke"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> $<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">required</c-><c- o="">=</c-><c- s="">"required"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"number"</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"0"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"0.01"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"1.pprice"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"49.99"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">formnovalidate</c-><c- o="">=</c-><c- s="">"formnovalidate"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"action"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"delete:1"</c-><c- p="">&gt;</c->Delete<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">readonly</c-><c- o="">=</c-><c- s="">"readonly"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"2.pid"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"FG28"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">required</c-><c- o="">=</c-><c- s="">"required"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"2.pname"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Table lamp Ulke"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> $<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">required</c-><c- o="">=</c-><c- s="">"required"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"number"</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"0"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"0.01"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"2.pprice"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"24.99"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">formnovalidate</c-><c- o="">=</c-><c- s="">"formnovalidate"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"action"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"delete:2"</c-><c- p="">&gt;</c->Delete<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">required</c-><c- o="">=</c-><c- s="">"required"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"3.pid"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">pattern</c-><c- o="">=</c-><c- s="">"[A-Z0-9]+"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">required</c-><c- o="">=</c-><c- s="">"required"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"3.pname"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> $<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">required</c-><c- o="">=</c-><c- s="">"required"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"number"</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"0"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"0.01"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"3.pprice"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">formnovalidate</c-><c- o="">=</c-><c- s="">"formnovalidate"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"action"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"delete:3"</c-><c- p="">&gt;</c->Delete<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">formnovalidate</c-><c- o="">=</c-><c- s="">"formnovalidate"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"action"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"add"</c-><c- p="">&gt;</c->Add<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"action"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"update"</c-><c- p="">&gt;</c->Save<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h6 id="the-required-attribute"><span class="secno">4.10.5.3.4</span> The <code id="the-required-attribute:attr-input-required"><a href="#attr-input-required">required</a></code> attribute<a href="#the-required-attribute" class="self-link"></a></h6>

  <p>The <dfn data-dfn-for="input" id="attr-input-required" data-dfn-type="element-attr"><code>required</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-required-attribute:boolean-attribute">boolean attribute</a>. When specified, the element is <dfn id="concept-input-required"><i>required</i></dfn>.</p>

  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the element is <i id="the-required-attribute:concept-input-required"><a href="#concept-input-required">required</a></i>, and its <code id="the-required-attribute:dom-input-value"><a href="#dom-input-value">value</a></code>
  IDL attribute <a href="#concept-input-apply" id="the-required-attribute:concept-input-apply">applies</a> and is in the mode <a href="#dom-input-value-value" id="the-required-attribute:dom-input-value-value">value</a>, and the element is <i id="the-required-attribute:concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>, and the element's <a href="#concept-fe-value" id="the-required-attribute:concept-fe-value">value</a> is the empty string, then the element is <a href="#suffering-from-being-missing" id="the-required-attribute:suffering-from-being-missing">suffering
  from being missing</a>.</p>
  </div>

  

  <div class="example">

   <p>The following form has two required fields, one for an email address and one for a password.
   It also has a third field that is only considered valid if the user types the same password in
   the password field and this third field.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Create new account<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"/newaccount"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">post</c->
      <c- e="">oninput</c-><c- o="">=</c-><c- s="">"up2.setCustomValidity(up2.value != up.value ? 'Passwords do not match.' : '')"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">"username"</c-><c- p="">&gt;</c->Email address:<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"username"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-> <c- e="">required</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">un</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">"password1"</c-><c- p="">&gt;</c->Password:<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"password1"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">password</c-> <c- e="">required</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">up</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">"password2"</c-><c- p="">&gt;</c->Confirm password:<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"password2"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">password</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">up2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Create account"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>For radio buttons, the <code id="the-required-attribute:attr-input-required-2"><a href="#attr-input-required">required</a></code> attribute is
   satisfied if any of the radio buttons in the <a href="#radio-button-group" id="the-required-attribute:radio-button-group">group</a> is
   selected. Thus, in the following example, any of the radio buttons can be checked, not just the
   one marked as required:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Did the movie pass the Bechdel test?<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"radio"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"bechdel"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"no-characters"</c-><c- p="">&gt;</c-> No, there are not even two female characters in the movie. <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"radio"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"bechdel"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"no-names"</c-><c- p="">&gt;</c-> No, the female characters never talk to each other. <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"radio"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"bechdel"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"no-topic"</c-><c- p="">&gt;</c-> No, when female characters talk to each other it's always about a male character. <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"radio"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"bechdel"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"yes"</c-> <strong><c- e="">required</c-></strong><c- p="">&gt;</c-> Yes. <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"radio"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"bechdel"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"unknown"</c-><c- p="">&gt;</c-> I don't know. <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></code></pre>

   <p>To avoid confusion as to whether a <a href="#radio-button-group" id="the-required-attribute:radio-button-group-2">radio button group</a> is required or not, authors
   are encouraged to specify the attribute on all the radio buttons in a group. Indeed, in general,
   authors are encouraged to avoid having radio button groups that do not have any initially checked
   controls in the first place, as this is a state that the user cannot return to, and is therefore
   generally considered a poor user interface.</p>

  </div>


  <h6 id="the-multiple-attribute"><span class="secno">4.10.5.3.5</span> The <code id="the-multiple-attribute:attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> attribute<a href="#the-multiple-attribute" class="self-link"></a></h6>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple" title="The Boolean multiple attribute, if set, means the form control accepts one or more values. Valid for the email and file input types and the <select>, the manner by which the user opts for multiple values depends on the form control.">Attributes/multiple</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-multiple" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#attr-multiple</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>≤12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>≤37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>≤12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="input" id="attr-input-multiple" data-dfn-type="element-attr"><code>multiple</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-multiple-attribute:boolean-attribute">boolean attribute</a> that indicates whether the user is to be allowed to
  specify more than one value.</p>

  <div class="example">

   <p>The following extract shows how an email client's "To" field could accept multiple email
   addresses.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->To: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-> <c- e="">multiple</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">to</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

   <p>If the user had, amongst many friends in their user contacts database, two friends
   "Spider-Man" (with address "spider@parker.example.net") and "Scarlet Witch" (with address
   "scarlet@avengers.example.net"), then, after the user has typed "<kbd>s</kbd>", the user agent
   might suggest these two email addresses to the user.</p>

   
   <p><img class="darkmode-aware" src="/images/sample-email-1.svg" width="330" alt="" height="100"></p>

   <p>The page could also link in the user's contacts database from the site:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->To: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">email</c-> <c- e="">multiple</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">to</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">contacts</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
...
<c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"contacts"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"hedral@damowmow.com"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"pillar@example.com"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"astrophy@cute.example"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"astronomy@science.example.org"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c-></code></pre>

   <p>Suppose the user had entered "<kbd>bob@example.net</kbd>" into this text control, and then
   started typing a second email address starting with "<kbd>s</kbd>". The user agent might show
   both the two friends mentioned earlier, as well as the "astrophy" and "astronomy" values given in
   the <code id="the-multiple-attribute:the-datalist-element"><a href="#the-datalist-element">datalist</a></code> element.</p>

   
   <p><img class="darkmode-aware" src="/images/sample-email-2.svg" width="330" alt="" height="140"></p>

  </div>

  <div class="example">

   <p>The following extract shows how an email client's "Attachments" field could accept multiple
   files for upload.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Attachments: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">file</c-> <c- e="">multiple</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">att</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h6 id="the-pattern-attribute"><span class="secno">4.10.5.3.6</span> The <code id="the-pattern-attribute:attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code> attribute<a href="#the-pattern-attribute" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern" title="The pattern attribute specifies a regular expression the form control's value should match. If a non-null value doesn't conform to the constraints set by the pattern value, the ValidityState object's read-only patternMismatch property will be true.">Attributes/pattern</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>≤12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>≤37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>≤12.1+</span></span></div></div></div>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern" title="The pattern attribute specifies a regular expression the form control's value should match. If a non-null value doesn't conform to the constraints set by the pattern value, the ValidityState object's read-only patternMismatch property will be true.">Attributes/pattern</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="input" id="attr-input-pattern" data-dfn-type="element-attr"><code>pattern</code></dfn>
  attribute specifies a regular expression against which the control's <a href="#concept-fe-value" id="the-pattern-attribute:concept-fe-value">value</a>, or, when the <code id="the-pattern-attribute:attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> attribute <a href="#concept-input-apply" id="the-pattern-attribute:concept-input-apply">applies</a> and is set, the control's <a href="#concept-fe-values" id="the-pattern-attribute:concept-fe-values">values</a>, are to be checked.</p>

  <p>If specified, the attribute's value must match the JavaScript <i id="the-pattern-attribute:js-prod-pattern"><a data-x-internal="js-prod-pattern" href="https://tc39.es/ecma262/#prod-Pattern">Pattern</a></i><sub><code>[+UnicodeSetsMode, +N]</code></sub> production.</p>

  

  <div data-algorithm="">
  <p>The <dfn id="compiled-pattern-regular-expression">compiled pattern regular expression</dfn> of an <code id="the-pattern-attribute:the-input-element"><a href="#the-input-element">input</a></code> element, if it
  exists, is a JavaScript <code id="the-pattern-attribute:regexp"><a data-x-internal="regexp" href="https://tc39.es/ecma262/#sec-regexp-regular-expression-objects">RegExp</a></code> object. It is determined as follows:</p>

  <ol><li><p>If the element does not have a <code id="the-pattern-attribute:attr-input-pattern-2"><a href="#attr-input-pattern">pattern</a></code> attribute
   specified, then return nothing. The element has no <a href="#compiled-pattern-regular-expression" id="the-pattern-attribute:compiled-pattern-regular-expression">compiled pattern regular
   expression</a>.</p></li><li><p>Let <var>pattern</var> be the value of the <code id="the-pattern-attribute:attr-input-pattern-3"><a href="#attr-input-pattern">pattern</a></code> attribute of the element.</p></li><li><p>Let <var>regexpCompletion</var> be <a id="the-pattern-attribute:regexpcreate" href="https://tc39.es/ecma262/#sec-regexpcreate" data-x-internal="regexpcreate">RegExpCreate</a>(<var>pattern</var>,
   "<code>v</code>").</p></li><li>
    <p>If <var>regexpCompletion</var> is an <a href="https://tc39.es/ecma262/#sec-completion-record-specification-type" id="the-pattern-attribute:completion-record" data-x-internal="completion-record">abrupt
    completion</a>, then return nothing. The element has no <a href="#compiled-pattern-regular-expression" id="the-pattern-attribute:compiled-pattern-regular-expression-2">compiled pattern regular
    expression</a>.</p>

    <p class="note">User agents are encouraged to log this error in a developer console, to aid
    debugging.</p>
   </li><li><p>Let <var>anchoredPattern</var> be the string "<code>^(?:</code>", followed by
   <var>pattern</var>, followed by "<code>)$</code>".</p></li><li><p>Return ! <a id="the-pattern-attribute:regexpcreate-2" href="https://tc39.es/ecma262/#sec-regexpcreate" data-x-internal="regexpcreate">RegExpCreate</a>(<var>anchoredPattern</var>, "<code>v</code>").</p></li></ol>
  </div>

  <p class="note">The reasoning behind these steps, instead of just using the value of the <code id="the-pattern-attribute:attr-input-pattern-4"><a href="#attr-input-pattern">pattern</a></code> attribute directly, is twofold. First, we want to
  ensure that when matched against a string, the regular expression's start is anchored to the start
  of the string and its end to the end of the string. Second, we want to ensure that the regular
  expression is valid in standalone form, instead of only becoming valid after being surrounded by
  the "<code>^(?:</code>" and "<code>)$</code>" anchors.</p>

  <div data-algorithm="">
  <p>A <code id="the-pattern-attribute:regexp-2"><a data-x-internal="regexp" href="https://tc39.es/ecma262/#sec-regexp-regular-expression-objects">RegExp</a></code> object <var>regexp</var> <dfn id="regexp-match-a-string">matches</dfn> a string <var>input</var>, if !
  <a id="the-pattern-attribute:regexpbuiltinexec" href="https://tc39.es/ecma262/#sec-regexpbuiltinexec" data-x-internal="regexpbuiltinexec">RegExpBuiltinExec</a>(<var>regexp</var>, <var>input</var>) is not null.</p>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the element's <a href="#concept-fe-value" id="the-pattern-attribute:concept-fe-value-2">value</a> is not the empty string, and either the element's <code id="the-pattern-attribute:attr-input-multiple-2"><a href="#attr-input-multiple">multiple</a></code> attribute is not specified or it <a href="#do-not-apply" id="the-pattern-attribute:do-not-apply">does not apply</a> to the <code id="the-pattern-attribute:the-input-element-2"><a href="#the-input-element">input</a></code> element given its <code id="the-pattern-attribute:attr-input-type"><a href="#attr-input-type">type</a></code> attribute's current state, and the element has a
  <a href="#compiled-pattern-regular-expression" id="the-pattern-attribute:compiled-pattern-regular-expression-3">compiled pattern regular expression</a> but that regular expression does not <a href="#regexp-match-a-string" id="the-pattern-attribute:regexp-match-a-string">match</a> the element's <a href="#concept-fe-value" id="the-pattern-attribute:concept-fe-value-3">value</a>, then the element is <a href="#suffering-from-a-pattern-mismatch" id="the-pattern-attribute:suffering-from-a-pattern-mismatch">suffering from a pattern
  mismatch</a>.</p>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the element's <a href="#concept-fe-value" id="the-pattern-attribute:concept-fe-value-4">value</a> is not the empty string, and the element's <code id="the-pattern-attribute:attr-input-multiple-3"><a href="#attr-input-multiple">multiple</a></code> attribute is specified and <a href="#concept-input-apply" id="the-pattern-attribute:concept-input-apply-2">applies</a> to the <code id="the-pattern-attribute:the-input-element-3"><a href="#the-input-element">input</a></code> element, and the element has
  a <a href="#compiled-pattern-regular-expression" id="the-pattern-attribute:compiled-pattern-regular-expression-4">compiled pattern regular expression</a> but that regular expression does not <a href="#regexp-match-a-string" id="the-pattern-attribute:regexp-match-a-string-2">match</a> each of the element's <a href="#concept-fe-values" id="the-pattern-attribute:concept-fe-values-2">values</a>, then the element is <a href="#suffering-from-a-pattern-mismatch" id="the-pattern-attribute:suffering-from-a-pattern-mismatch-2">suffering from a pattern
  mismatch</a>.</p>
  </div>

  

  <p>When an <code id="the-pattern-attribute:the-input-element-4"><a href="#the-input-element">input</a></code> element has a <code id="the-pattern-attribute:attr-input-pattern-5"><a href="#attr-input-pattern">pattern</a></code>
  attribute specified, authors should include a <dfn data-dfn-for="input" id="attr-input-title" data-dfn-type="element-attr"><code>title</code></dfn> attribute to give a description of the pattern.  User
  agents may use the contents of this attribute, if it is present, when informing the user that the
  pattern is not matched, or at any other suitable time, such as in a tooltip or read out by
  assistive technology when the control <a href="#gains-focus" id="the-pattern-attribute:gains-focus">gains focus</a>.</p>

  <div class="example">
   <p>For example, the following snippet:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> Part number:
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">pattern</c-><c- o="">=</c-><c- s="">"[0-9][A-Z]{3}"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"part"</c->
        <c- e="">title</c-><c- o="">=</c-><c- s="">"A part number is a digit followed by three uppercase letters."</c-><c- p="">/&gt;</c->
<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>
   <p>...could cause the UA to display an alert such as:</p>
   <pre><samp>A part number is a digit followed by three uppercase letters.
You cannot submit this form when the field is incorrect.</samp></pre>
  </div>

  <p>When a control has a <code id="the-pattern-attribute:attr-input-pattern-6"><a href="#attr-input-pattern">pattern</a></code> attribute, the <code id="the-pattern-attribute:attr-input-title"><a href="#attr-input-title">title</a></code> attribute, if used, must describe the pattern. Additional
  information could also be included, so long as it assists the user in filling in the control.
  Otherwise, assistive technology would be impaired.</p>

  <p class="example">For instance, if the title attribute contained the caption of the control,
  assistive technology could end up saying something like <samp>The text you have entered does not
  match the required pattern. Birthday</samp>, which is not useful.</p>

  <p>UAs may still show the <code id="the-pattern-attribute:attr-title"><a href="#attr-title">title</a></code> in non-error situations (for
  example, as a tooltip when hovering over the control), so authors should be careful not to word
  <code id="the-pattern-attribute:attr-input-title-2"><a href="#attr-input-title">title</a></code>s as if an error has necessarily occurred.</p>


  <h6 id="the-min-and-max-attributes"><span class="secno">4.10.5.3.7</span> The <code id="the-min-and-max-attributes:attr-input-min"><a href="#attr-input-min">min</a></code> and <code id="the-min-and-max-attributes:attr-input-max"><a href="#attr-input-max">max</a></code> attributes<a href="#the-min-and-max-attributes" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max" title="The max attribute defines the maximum value that is acceptable and valid for the input containing the attribute. If the value of the element is greater than this, the element fails validation. This value must be greater than or equal to the value of the min attribute. If the max attribute is present but is not specified or is invalid, no max value is applied. If the max attribute is valid and a non-empty value is greater than the maximum allowed by the max attribute, constraint validation will prevent form submission.">Attributes/max</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>16+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/min" title="The min attribute defines the minimum value that is acceptable and valid for the input containing the attribute. If the value of the element is less than this, the element fails validation. This value must be less than or equal to the value of the max attribute.">Attributes/min</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>16+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  

  <p>Some form controls can have explicit constraints applied limiting the allowed range of values
  that the user can provide. Normally, such a range would be linear and continuous. A form control
  can <dfn id="has-a-periodic-domain">have a periodic domain</dfn>, however, in which case the
  form control's broadest possible range is finite, and authors can specify explicit ranges within
  it that span the boundaries.</p>

  <p class="example">Specifically, the broadest range of a <code id="the-min-and-max-attributes:time-state-(type=time)"><a href="#time-state-(type=time)">type=time</a></code> control is midnight to midnight (24 hours), and
  authors can set both continuous linear ranges (such as 9pm to 11pm) and discontinuous ranges
  spanning midnight (such as 11pm to 1am).</p>

  <p>The <dfn data-dfn-for="input" id="attr-input-min" data-dfn-type="element-attr"><code>min</code></dfn> and <dfn data-dfn-for="input" id="attr-input-max" data-dfn-type="element-attr"><code>max</code></dfn> attributes indicate the
  allowed range of values for the element.</p>

  

  <p>Their syntax is defined by the section that defines the <code id="the-min-and-max-attributes:attr-input-type"><a href="#attr-input-type">type</a></code> attribute's current state.</p>

  <div data-algorithm="">
  <p>If the element has a <code id="the-min-and-max-attributes:attr-input-min-2"><a href="#attr-input-min">min</a></code> attribute, and the result of
  applying the <a href="#concept-input-value-string-number" id="the-min-and-max-attributes:concept-input-value-string-number">algorithm to convert a string to a
  number</a> to the value of the <code id="the-min-and-max-attributes:attr-input-min-3"><a href="#attr-input-min">min</a></code> attribute is a number,
  then that number is the element's <dfn id="concept-input-min">minimum</dfn>; otherwise, if the
  <code id="the-min-and-max-attributes:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute's current state defines a <dfn id="concept-input-min-default">default minimum</dfn>, then that is the <a href="#concept-input-min" id="the-min-and-max-attributes:concept-input-min">minimum</a>; otherwise, the element has no <a href="#concept-input-min" id="the-min-and-max-attributes:concept-input-min-2">minimum</a>.</p>
  </div>

  <p>The <code id="the-min-and-max-attributes:attr-input-min-4"><a href="#attr-input-min">min</a></code> attribute also defines the <a href="#concept-input-min-zero" id="the-min-and-max-attributes:concept-input-min-zero">step base</a>.</p>

  <div data-algorithm="">
  <p>If the element has a <code id="the-min-and-max-attributes:attr-input-max-2"><a href="#attr-input-max">max</a></code> attribute, and the result of
  applying the <a href="#concept-input-value-string-number" id="the-min-and-max-attributes:concept-input-value-string-number-2">algorithm to convert a string to a
  number</a> to the value of the <code id="the-min-and-max-attributes:attr-input-max-3"><a href="#attr-input-max">max</a></code> attribute is a number,
  then that number is the element's <dfn id="concept-input-max">maximum</dfn>; otherwise, if the
  <code id="the-min-and-max-attributes:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute's current state defines a <dfn id="concept-input-max-default">default maximum</dfn>, then that is the <a href="#concept-input-max" id="the-min-and-max-attributes:concept-input-max">maximum</a>; otherwise, the element has no <a href="#concept-input-max" id="the-min-and-max-attributes:concept-input-max-2">maximum</a>.</p>
  </div>

  

  <p>If the element does not <a href="#has-a-periodic-domain" id="the-min-and-max-attributes:has-a-periodic-domain">have a periodic domain</a>, the
  <code id="the-min-and-max-attributes:attr-input-max-4"><a href="#attr-input-max">max</a></code> attribute's value (the <a href="#concept-input-max" id="the-min-and-max-attributes:concept-input-max-3">maximum</a>) must not be less than the <code id="the-min-and-max-attributes:attr-input-min-5"><a href="#attr-input-min">min</a></code> attribute's value (its <a href="#concept-input-min" id="the-min-and-max-attributes:concept-input-min-3">minimum</a>).</p>

  

  <p class="note">If an element that does not <a href="#has-a-periodic-domain" id="the-min-and-max-attributes:has-a-periodic-domain-2">have a periodic
  domain</a> has a <a href="#attr-input-max" id="the-min-and-max-attributes:attr-input-max-5">maximum</a> that is less than its <a href="#attr-input-min" id="the-min-and-max-attributes:attr-input-min-6">minimum</a>, then so long as the element has a <a href="#concept-fe-value" id="the-min-and-max-attributes:concept-fe-value">value</a>, it will either be <a href="#suffering-from-an-underflow" id="the-min-and-max-attributes:suffering-from-an-underflow">suffering from an underflow</a>
  or <a href="#suffering-from-an-overflow" id="the-min-and-max-attributes:suffering-from-an-overflow">suffering from an overflow</a>.</p>

  <div data-algorithm="">
  <p>An element <dfn id="has-a-reversed-range">has a reversed range</dfn> if it <a href="#has-a-periodic-domain" id="the-min-and-max-attributes:has-a-periodic-domain-3">has a periodic domain</a> and its
  <a href="#concept-input-max" id="the-min-and-max-attributes:concept-input-max-4">maximum</a> is less than its <a href="#concept-input-min" id="the-min-and-max-attributes:concept-input-min-4">minimum</a>.</p>
  </div>

  

  <div data-algorithm="">
  <p>An element <dfn id="have-range-limitations">has range limitations</dfn> if it has a defined
  <a href="#concept-input-min" id="the-min-and-max-attributes:concept-input-min-5">minimum</a> or a defined <a href="#concept-input-max" id="the-min-and-max-attributes:concept-input-max-5">maximum</a>.</p>
  </div>

  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: When the element has a <a href="#attr-input-min" id="the-min-and-max-attributes:attr-input-min-7">minimum</a> and does not <a href="#has-a-reversed-range" id="the-min-and-max-attributes:has-a-reversed-range">have a
  reversed range</a>, and the result of applying the <a href="#concept-input-value-string-number" id="the-min-and-max-attributes:concept-input-value-string-number-3">algorithm to convert a string to a number</a> to
  the string given by the element's <a href="#concept-fe-value" id="the-min-and-max-attributes:concept-fe-value-2">value</a> is a number, and
  the number obtained from that algorithm is less than the <a href="#attr-input-min" id="the-min-and-max-attributes:attr-input-min-8">minimum</a>, the element is <a href="#suffering-from-an-underflow" id="the-min-and-max-attributes:suffering-from-an-underflow-2">suffering from an
  underflow</a>.</p>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: When the element has a <a href="#attr-input-max" id="the-min-and-max-attributes:attr-input-max-6">maximum</a> and does not <a href="#has-a-reversed-range" id="the-min-and-max-attributes:has-a-reversed-range-2">have a
  reversed range</a>, and the result of applying the <a href="#concept-input-value-string-number" id="the-min-and-max-attributes:concept-input-value-string-number-4">algorithm to convert a string to a number</a> to
  the string given by the element's <a href="#concept-fe-value" id="the-min-and-max-attributes:concept-fe-value-3">value</a> is a number, and
  the number obtained from that algorithm is more than the <a href="#attr-input-max" id="the-min-and-max-attributes:attr-input-max-7">maximum</a>, the element is <a href="#suffering-from-an-overflow" id="the-min-and-max-attributes:suffering-from-an-overflow-2">suffering from an
  overflow</a>.</p>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: When an element <a href="#has-a-reversed-range" id="the-min-and-max-attributes:has-a-reversed-range-3">has a reversed range</a>,
  and the result of applying the <a href="#concept-input-value-string-number" id="the-min-and-max-attributes:concept-input-value-string-number-5">algorithm to
  convert a string to a number</a> to the string given by the element's <a href="#concept-fe-value" id="the-min-and-max-attributes:concept-fe-value-4">value</a> is a number, and the number obtained from that algorithm
  is more than the <a href="#attr-input-max" id="the-min-and-max-attributes:attr-input-max-8">maximum</a> <em>and</em> less than the <a href="#attr-input-min" id="the-min-and-max-attributes:attr-input-min-9">minimum</a>, the element is simultaneously <a href="#suffering-from-an-underflow" id="the-min-and-max-attributes:suffering-from-an-underflow-3">suffering from an
  underflow</a> and <a href="#suffering-from-an-overflow" id="the-min-and-max-attributes:suffering-from-an-overflow-3">suffering from an overflow</a>.</p>
  </div>

  

  <div class="example">

   <p>The following date control limits input to dates that are before the 1980s:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">bday</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">date</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"1979-12-31"</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The following number control limits input to whole numbers greater than zero:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">quantity</c-> <c- e="">required</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"number"</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"1"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1"</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The following time control limits input to those minutes that occur between 9pm and 6am,
   defaulting to midnight:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"sleepStart"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"21:00"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"06:00"</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">"60"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"00:00"</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h6 id="the-step-attribute"><span class="secno">4.10.5.3.8</span> The <code id="the-step-attribute:attr-input-step"><a href="#attr-input-step">step</a></code> attribute<a href="#the-step-attribute" class="self-link"></a></h6>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step" title="The step attribute is a number that specifies the granularity that the value must adhere to or the keyword any. It is valid for the numeric input types, including the date, month, week, time, datetime-local, number and range types.">Attributes/step</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>16+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="input" id="attr-input-step" data-dfn-type="element-attr"><code>step</code></dfn> attribute
  indicates the granularity that is expected (and required) of the <a href="#concept-fe-value" id="the-step-attribute:concept-fe-value">value</a> or <a href="#concept-fe-values" id="the-step-attribute:concept-fe-values">values</a>, by
  limiting the allowed values. The section that defines the <code id="the-step-attribute:attr-input-type"><a href="#attr-input-type">type</a></code> attribute's current state also defines the <dfn id="concept-input-step-default">default step</dfn>, the <dfn id="concept-input-step-scale">step scale factor</dfn>, and in some cases the <dfn id="concept-input-step-default-base">default step base</dfn>, which are used in processing the
  attribute as described below.</p>

  <p>The <code id="the-step-attribute:attr-input-step-2"><a href="#attr-input-step">step</a></code> attribute, if specified, must either have a
  value that is a <a href="#valid-floating-point-number" id="the-step-attribute:valid-floating-point-number">valid floating-point number</a> that <a href="#rules-for-parsing-floating-point-number-values" id="the-step-attribute:rules-for-parsing-floating-point-number-values">parses</a> to a number that is greater than zero, or must have a
  value that is an <a id="the-step-attribute:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>any</code>".</p>

  

  <div data-algorithm="">
  <p>The attribute provides the <dfn id="concept-input-step">allowed value step</dfn> for the
  element, as follows:</p>

  <ol><li><p>If the attribute does not <a href="#concept-input-apply" id="the-step-attribute:concept-input-apply">apply</a>, then there is
   no <a href="#concept-input-step" id="the-step-attribute:concept-input-step">allowed value step</a>.</p></li><li><p>Otherwise, if the attribute is absent, then the <a href="#concept-input-step" id="the-step-attribute:concept-input-step-2">allowed
   value step</a> is the <a href="#concept-input-step-default" id="the-step-attribute:concept-input-step-default">default step</a> multiplied
   by the <a href="#concept-input-step-scale" id="the-step-attribute:concept-input-step-scale">step scale factor</a>.</p></li><li><p>Otherwise, if the attribute's value is an <a id="the-step-attribute:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the
   string "<code>any</code>", then there is no <a href="#concept-input-step" id="the-step-attribute:concept-input-step-3">allowed
   value step</a>.</p></li><li><p>Otherwise, if the <a href="#rules-for-parsing-floating-point-number-values" id="the-step-attribute:rules-for-parsing-floating-point-number-values-2">rules for parsing floating-point number values</a>, when they are
   applied to the attribute's value, return an error, zero, or a number less than zero, then the
   <a href="#concept-input-step" id="the-step-attribute:concept-input-step-4">allowed value step</a> is the <a href="#concept-input-step-default" id="the-step-attribute:concept-input-step-default-2">default step</a> multiplied by the <a href="#concept-input-step-scale" id="the-step-attribute:concept-input-step-scale-2">step scale factor</a>.</p></li><li><p>Otherwise, the <a href="#concept-input-step" id="the-step-attribute:concept-input-step-5">allowed value step</a> is the number
   returned by the <a href="#rules-for-parsing-floating-point-number-values" id="the-step-attribute:rules-for-parsing-floating-point-number-values-3">rules for parsing floating-point number values</a> when they are applied
   to the attribute's value, multiplied by the <a href="#concept-input-step-scale" id="the-step-attribute:concept-input-step-scale-3">step scale
   factor</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="concept-input-min-zero">step base</dfn> is the value returned by the following
  algorithm:</p>

  <ol><li><p>If the element has a <code id="the-step-attribute:attr-input-min"><a href="#attr-input-min">min</a></code> content attribute, and the
   result of applying the <a href="#concept-input-value-string-number" id="the-step-attribute:concept-input-value-string-number">algorithm to convert a
   string to a number</a> to the value of the <code id="the-step-attribute:attr-input-min-2"><a href="#attr-input-min">min</a></code> content
   attribute is not an error, then return that result.</p></li><li><p>If the element has a <code id="the-step-attribute:attr-input-value"><a href="#attr-input-value">value</a></code> content attribute, and
   the result of applying the <a href="#concept-input-value-string-number" id="the-step-attribute:concept-input-value-string-number-2">algorithm to convert
   a string to a number</a> to the value of the <code id="the-step-attribute:attr-input-value-2"><a href="#attr-input-value">value</a></code>
   content attribute is not an error, then return that result.</p></li><li><p>If a <a href="#concept-input-step-default-base" id="the-step-attribute:concept-input-step-default-base">default step base</a> is defined for
   this element given its <code id="the-step-attribute:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute's state, then return
   it.</p>

   </li><li><p>Return zero.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: When the element has an <a href="#concept-input-step" id="the-step-attribute:concept-input-step-6">allowed value step</a>, and the result of applying the <a href="#concept-input-value-string-number" id="the-step-attribute:concept-input-value-string-number-3">algorithm to convert a string to a number</a> to
  the string given by the element's <a href="#concept-fe-value" id="the-step-attribute:concept-fe-value-2">value</a> is a number, and
  that number subtracted from the <a href="#concept-input-min-zero" id="the-step-attribute:concept-input-min-zero">step base</a> is not an
  integral multiple of the <a href="#concept-input-step" id="the-step-attribute:concept-input-step-7">allowed value step</a>, the
  element is <a href="#suffering-from-a-step-mismatch" id="the-step-attribute:suffering-from-a-step-mismatch">suffering from a step mismatch</a>.</p>
  </div>

  

  <div class="example">

   <p>The following range control only accepts values in the range 0..1, and allows 256 steps in
   that range:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">opacity</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">range</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">1</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">0.00392156863</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The following control allows any time in the day to be selected, with any accuracy (e.g.
   thousandth-of-a-second accuracy or more):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">favtime</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">time</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">any</c-><c- p="">&gt;</c-></code></pre>

   <p>Normally, time controls are limited to an accuracy of one minute.</p>

  </div>



  <h6 id="the-list-attribute"><span class="secno">4.10.5.3.9</span> The <code id="the-list-attribute:attr-input-list"><a href="#attr-input-list">list</a></code> attribute<a href="#the-list-attribute" class="self-link"></a></h6>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#list" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#list</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>12.1+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4.3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="input" id="attr-input-list" data-dfn-type="element-attr"><code>list</code></dfn> attribute is
  used to identify an element that lists predefined options suggested to the user.</p>

  <p>If present, its value must be the <a href="https://dom.spec.whatwg.org/#concept-id" id="the-list-attribute:concept-id" data-x-internal="concept-id">ID</a> of a <code id="the-list-attribute:the-datalist-element"><a href="#the-datalist-element">datalist</a></code>
  element in the same <a id="the-list-attribute:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>.</p>

  

  <div data-algorithm="">
  <p>The <dfn id="concept-input-list">suggestions source element</dfn> is the first element in
  the <a id="the-list-attribute:tree-2" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> in <a id="the-list-attribute:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> to have an <a href="https://dom.spec.whatwg.org/#concept-id" id="the-list-attribute:concept-id-2" data-x-internal="concept-id">ID</a>
  equal to the value of the <code id="the-list-attribute:attr-input-list-2"><a href="#attr-input-list">list</a></code> attribute, if that element
  is a <code id="the-list-attribute:the-datalist-element-2"><a href="#the-datalist-element">datalist</a></code> element. If there is no <code id="the-list-attribute:attr-input-list-3"><a href="#attr-input-list">list</a></code>
  attribute, or if there is no element with that <a href="https://dom.spec.whatwg.org/#concept-id" id="the-list-attribute:concept-id-3" data-x-internal="concept-id">ID</a>, or if the
  first element with that <a href="https://dom.spec.whatwg.org/#concept-id" id="the-list-attribute:concept-id-4" data-x-internal="concept-id">ID</a> is not a <code id="the-list-attribute:the-datalist-element-3"><a href="#the-datalist-element">datalist</a></code>
  element, then there is no <a href="#concept-input-list" id="the-list-attribute:concept-input-list">suggestions source
  element</a>.</p>
  </div>

  <p>If there is a <a href="#concept-input-list" id="the-list-attribute:concept-input-list-2">suggestions source element</a>, then, when
  the user agent is allowing the user to edit the <code id="the-list-attribute:the-input-element"><a href="#the-input-element">input</a></code> element's <a href="#concept-fe-value" id="the-list-attribute:concept-fe-value">value</a>, the user agent should offer the suggestions represented by
  the <a href="#concept-input-list" id="the-list-attribute:concept-input-list-3">suggestions source element</a> to the user in a manner
  suitable for the type of control used. If appropriate, the user agent should use the suggestion's
  <a href="#concept-option-label" id="the-list-attribute:concept-option-label">label</a> and <a href="#concept-option-value" id="the-list-attribute:concept-option-value">value</a> to identify the suggestion to the user.</p>

  <p>User agents are encouraged to filter the suggestions represented by the <a href="#concept-input-list" id="the-list-attribute:concept-input-list-4">suggestions source element</a> when the number of suggestions is
  large, including only the most relevant ones (e.g. based on the user's input so far). No precise
  threshold is defined, but capping the list at four to seven values is reasonable. If filtering
  based on the user's input, user agents should search within both the <a href="#concept-option-label" id="the-list-attribute:concept-option-label-2">label</a> and <a href="#concept-option-value" id="the-list-attribute:concept-option-value-2">value</a>
  of the suggestions for matches. User agents should consider how input variations affect the
  matching process. Unicode normalization should be applied so that different underlying Unicode
  code point sequences, caused by different keyboard- or input-specific mechanisms, do not
  interfere with the matching process. Case variations should be ignored, which may require
  language-specific case mapping. For examples of these, see <cite>Character Model for the World
  Wide Web: String Matching</cite>. User agents may also provide other matching features: for
  illustration, a few examples include matching different forms of kana to each other (or to kanji),
  ignoring accents, or applying spelling correction. <a href="#refsCHARMODNORM">[CHARMODNORM]</a></p>

  <div class="example">
   <p>This text field allows you to choose a type of JavaScript function.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">"function-types"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"function-types"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"function"</c-><c- p="">&gt;</c->function<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"async function"</c-><c- p="">&gt;</c->async function<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"function*"</c-><c- p="">&gt;</c->generator function<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"=&gt;"</c-><c- p="">&gt;</c->arrow function<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"async =&gt;"</c-><c- p="">&gt;</c->async arrow function<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"async function*"</c-><c- p="">&gt;</c->async generator function<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c-></code></pre>

   <p>For user agents that follow the above suggestions, both the <a href="#concept-option-label" id="the-list-attribute:concept-option-label-3">label</a> and <a href="#concept-option-value" id="the-list-attribute:concept-option-value-3">value</a>
   would be shown:</p>

   <p><img class="darkmode-aware" src="/images/sample-datalist.svg" width="280" alt="A text box with a drop down button on the right hand side; with, below, a drop down box containing a list of the six values the left and the six labels on the right." height="150"></p>

   <p>Then, typing "<kbd>arrow</kbd>" or "<kbd>=&gt;</kbd>" would filter the list to the entries with
   labels "arrow function" and "async arrow function". Typing "<kbd>generator</kbd>" or
   "<kbd>*</kbd>" would filter the list to the entries with labels "generator function" and "async
   generator function".</p>
  </div>

  <p class="note">As always, user agents are free to make user interface decisions which are
  appropriate for their particular requirements and for the user's particular circumstances. However,
  this has historically been an area of confusion for implementers, web developers, and users alike,
  so we've given some "should" suggestions above.</p>


  <div data-algorithm="">
  <p>How user selections of suggestions are handled depends on whether the element is a control
  accepting a single value only, or whether it accepts multiple values:</p>

  <dl class="switch"><dt>If the element does not have a <code id="the-list-attribute:attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> attribute
   specified or if the <code id="the-list-attribute:attr-input-multiple-2"><a href="#attr-input-multiple">multiple</a></code> attribute <a href="#do-not-apply" id="the-list-attribute:do-not-apply">does not apply</a></dt><dd>
    <p>When the user selects a suggestion, the <code id="the-list-attribute:the-input-element-2"><a href="#the-input-element">input</a></code> element's <a href="#concept-fe-value" id="the-list-attribute:concept-fe-value-2">value</a> must be set to the selected suggestion's <a href="#concept-option-value" id="the-list-attribute:concept-option-value-4">value</a>, as if the user had written that value themself.</p>
   </dd><dt>If the element's <code id="the-list-attribute:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#email-state-(type=email)" id="the-list-attribute:email-state-(type=email)">Email</a> state and the element has a <code id="the-list-attribute:attr-input-multiple-3"><a href="#attr-input-multiple">multiple</a></code> attribute specified</dt><dd>
    <p>When the user selects a suggestion, the user agent must either add a new entry to the
    <code id="the-list-attribute:the-input-element-3"><a href="#the-input-element">input</a></code> element's <a href="#concept-fe-values" id="the-list-attribute:concept-fe-values">values</a>, whose value
    is the selected suggestion's <a href="#concept-option-value" id="the-list-attribute:concept-option-value-5">value</a>, or change an
    existing entry in the <code id="the-list-attribute:the-input-element-4"><a href="#the-input-element">input</a></code> element's <a href="#concept-fe-values" id="the-list-attribute:concept-fe-values-2">values</a> to have the value given by the selected
    suggestion's <a href="#concept-option-value" id="the-list-attribute:concept-option-value-6">value</a>, as if the user had themself added
    an entry with that value, or edited an existing entry to be that value. Which behavior is to be
    applied depends on the user interface in an <a id="the-list-attribute:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner.</p>
   </dd></dl>
  </div>

  <hr>

  <p>If the <code id="the-list-attribute:attr-input-list-4"><a href="#attr-input-list">list</a></code> attribute <a href="#do-not-apply" id="the-list-attribute:do-not-apply-2">does not
  apply</a>, there is no <a href="#concept-input-list" id="the-list-attribute:concept-input-list-5">suggestions source element</a>.</p>

  

  <div class="example">

   <p>This URL field offers some suggestions.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Homepage: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">hp</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">url</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">hpurls</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">hpurls</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://www.google.com/"</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Google"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://www.reddit.com/"</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"Reddit"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c-></code></pre>

   <p>Other URLs from the user's history might show also; this is up to the user agent.</p>

  </div>

  <div class="example">

   <p>This example demonstrates how to design a form that uses the autocompletion list feature while
   still degrading usefully in legacy user agents.</p>

   <p>If the autocompletion list is merely an aid, and is not important to the content, then simply
   using a <code id="the-list-attribute:the-datalist-element-4"><a href="#the-datalist-element">datalist</a></code> element with children <code id="the-list-attribute:the-option-element"><a href="#the-option-element">option</a></code> elements is enough. To
   prevent the values from being rendered in legacy user agents, they need to be placed inside the
   <code id="the-list-attribute:attr-option-value"><a href="#attr-option-value">value</a></code> attribute instead of inline.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
  Enter a breed:
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"breed"</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">"breeds"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"breeds"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Abyssinian"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Alpaca"</c-><c- p="">&gt;</c->
   <c- c="">&lt;!-- ... --&gt;</c->
  <c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>However, if the values need to be shown in legacy UAs, then fallback content can be placed
   inside the <code id="the-list-attribute:the-datalist-element-5"><a href="#the-datalist-element">datalist</a></code> element, as follows:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
  Enter a breed:
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"breed"</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">"breeds"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"breeds"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
   or select one from the list:
   <c- p="">&lt;</c-><c- f="">select</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"breed"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-> (none selected)
    <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Abyssinian
    <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Alpaca
    <c- c="">&lt;!-- ... --&gt;</c->
   <c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>The fallback content will only be shown in UAs that don't support <code id="the-list-attribute:the-datalist-element-6"><a href="#the-datalist-element">datalist</a></code>. The
   options, on the other hand, will be detected by all UAs, even though they are not children of the
   <code id="the-list-attribute:the-datalist-element-7"><a href="#the-datalist-element">datalist</a></code> element.</p>

   <p>Note that if an <code id="the-list-attribute:the-option-element-2"><a href="#the-option-element">option</a></code> element used in a <code id="the-list-attribute:the-datalist-element-8"><a href="#the-datalist-element">datalist</a></code> is <code id="the-list-attribute:attr-option-selected"><a href="#attr-option-selected">selected</a></code>, it will be selected by default by legacy UAs
   (because it affects the <code id="the-list-attribute:the-select-element"><a href="#the-select-element">select</a></code> element), but it will not have any effect on the
   <code id="the-list-attribute:the-input-element-5"><a href="#the-input-element">input</a></code> element in UAs that support <code id="the-list-attribute:the-datalist-element-9"><a href="#the-datalist-element">datalist</a></code>.</p>

  </div>



  <h6 id="the-placeholder-attribute"><span class="secno">4.10.5.3.10</span> The <code id="the-placeholder-attribute:attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code> attribute<a href="#the-placeholder-attribute" class="self-link"></a></h6>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#placeholder</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-placeholder" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#attr-placeholder</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>≤12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>≤37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>≤12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="input" id="attr-input-placeholder" data-dfn-type="element-attr"><code>placeholder</code></dfn> attribute represents a <em>short</em>
  hint (a word or short phrase) intended to aid the user with data entry when the control has no
  value. A hint could be a sample value or a brief description of the expected format. The
  attribute, if specified, must have a value that contains no U+000A LINE FEED (LF) or U+000D
  CARRIAGE RETURN (CR) characters.</p>

  <p>The <code id="the-placeholder-attribute:attr-input-placeholder-2"><a href="#attr-input-placeholder">placeholder</a></code> attribute should not be used as an
  alternative to a <code id="the-placeholder-attribute:the-label-element"><a href="#the-label-element">label</a></code>. For a longer hint or other advisory text, the <code id="the-placeholder-attribute:attr-title"><a href="#attr-title">title</a></code> attribute is more appropriate.</p>

  <p class="note">These mechanisms are very similar but subtly different: the hint given by the
  control's <code id="the-placeholder-attribute:the-label-element-2"><a href="#the-label-element">label</a></code> is shown at all times; the short hint given in the <code id="the-placeholder-attribute:attr-input-placeholder-3"><a href="#attr-input-placeholder">placeholder</a></code> attribute is shown before the user enters a
  value; and the hint in the <code id="the-placeholder-attribute:attr-title-2"><a href="#attr-title">title</a></code> attribute is shown when the user
  requests further help.</p>

  

  <p>User agents should present this hint to the user, after having <a href="https://infra.spec.whatwg.org/#strip-newlines" id="the-placeholder-attribute:strip-newlines" data-x-internal="strip-newlines">stripped newlines</a> from it, when the element's <a href="#concept-fe-value" id="the-placeholder-attribute:concept-fe-value">value</a> is the empty string, especially if the control is not
  <a href="#focused" id="the-placeholder-attribute:focused">focused</a>.</p>

  <p>If a user agent normally doesn't show this hint to the user when the control is
  <a href="#focused" id="the-placeholder-attribute:focused-2">focused</a>, then the user agent should nonetheless show the hint for the control if it
  was focused as a result of the <code id="the-placeholder-attribute:attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code> attribute, since
  in that case the user will not have had an opportunity to examine the control before focusing
  it.</p>

  

  <div class="example">

   <p>Here is an example of a mail configuration user interface that uses the <code id="the-placeholder-attribute:attr-input-placeholder-4"><a href="#attr-input-placeholder">placeholder</a></code> attribute:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Mail Account<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"fullname"</c-> <c- e="">placeholder</c-><c- o="">=</c-><c- s="">"John Ratzenberger"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Address: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"email"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"address"</c-> <c- e="">placeholder</c-><c- o="">=</c-><c- s="">"john@example.net"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Password: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"password"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"password"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Description: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"desc"</c-> <c- e="">placeholder</c-><c- o="">=</c-><c- s="">"My Email Account"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In situations where the control's content has one directionality but the placeholder needs to
   have a different directionality, Unicode's bidirectional-algorithm formatting characters can be
   used in the attribute value:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">t1</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">placeholder</c-><c- o="">=</c-><c- s="">"</c-><strong><c- s="">&amp;#x202B;</c-></strong><c- s=""> </c-><bdo dir="rtl"><c- s="">رقم&nbsp;الهاتف&nbsp;1</c-></bdo><c- s=""> </c-><strong><c- s="">&amp;#x202E;</c-></strong><c- s="">"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">t2</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">placeholder</c-><c- o="">=</c-><c- s="">"</c-><strong><c- s="">&amp;#x202B;</c-></strong><c- s=""> </c-><bdo dir="rtl"><c- s="">رقم&nbsp;الهاتف&nbsp;2</c-></bdo><c- s=""> </c-><strong><c- s="">&amp;#x202E;</c-></strong><c- s="">"</c-><c- p="">&gt;</c-></code></pre>

   <p>For slightly more clarity, here's the same example using numeric character references instead of inline Arabic:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">t1</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">placeholder</c-><c- o="">=</c-><c- s="">"</c-><strong><c- s="">&amp;#x202B;</c-></strong><c- s="">&amp;#1585;&amp;#1602;&amp;#1605;&nbsp;&amp;#1575;&amp;#1604;&amp;#1607;&amp;#1575;&amp;#1578;&amp;#1601;&nbsp;1</c-><strong><c- s="">&amp;#x202E;</c-></strong><c- s="">"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">t2</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">tel</c-> <c- e="">placeholder</c-><c- o="">=</c-><c- s="">"</c-><strong><c- s="">&amp;#x202B;</c-></strong><c- s="">&amp;#1585;&amp;#1602;&amp;#1605;&nbsp;&amp;#1575;&amp;#1604;&amp;#1607;&amp;#1575;&amp;#1578;&amp;#1601;&nbsp;2</c-><strong><c- s="">&amp;#x202E;</c-></strong><c- s="">"</c-><c- p="">&gt;</c-></code></pre>

  </div>




  <h5 id="common-input-element-apis"><span class="secno">4.10.5.4</span> Common <code id="common-input-element-apis:the-input-element"><a href="#the-input-element">input</a></code> element APIs<a href="#common-input-element-apis" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>input</var>.<a href="#dom-input-value" id="dom-input-value-dev">value</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value">value</a> of the form control.</p>

    <p>Can be set, to change the value.</p>

    <p>Throws an <a id="common-input-element-apis:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if it is
    set to any value other than the empty string when the control is a file upload control.</p>
   </dd><dt><code><var>input</var>.<a href="#dom-input-checked" id="dom-input-checked-dev">checked</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current <a href="#concept-fe-checked" id="common-input-element-apis:concept-fe-checked">checkedness</a> of the form
    control.</p>

    <p>Can be set, to change the <a href="#concept-fe-checked" id="common-input-element-apis:concept-fe-checked-2">checkedness</a>.</p>
   </dd><dt><code><var>input</var>.<a href="#dom-input-files" id="dom-input-files-dev">files</a> [ = <var>files</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/FileList" title="An object of this type is returned by the files property of the HTML <input> element; this lets you access the list of files selected with the <input type=&quot;file&quot;> element. It's also used for a list of files dropped into web content when using the drag and drop API; see the DataTransfer object for details on this usage.">FileList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files" title="The HTMLInputElement.files property allows you to access the FileList selected with the <input type=&quot;file&quot;> element.">HTMLInputElement/files</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Partial implementation.">🔰 10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="common-input-element-apis:filelist"><a data-x-internal="filelist" href="https://w3c.github.io/FileAPI/#filelist-section">FileList</a></code> object listing the <a href="#concept-input-type-file-selected" id="common-input-element-apis:concept-input-type-file-selected">selected files</a> of the form control.</p>

    <p>Returns null if the control isn't a file control.</p>

    <p>Can be set to a <code id="common-input-element-apis:filelist-2"><a data-x-internal="filelist" href="https://w3c.github.io/FileAPI/#filelist-section">FileList</a></code> object to change the <a href="#concept-input-type-file-selected" id="common-input-element-apis:concept-input-type-file-selected-2">selected files</a> of the form control. For
    instance, as the result of a drag-and-drop operation.</p>
   </dd><dt><code><var>input</var>.<a href="#dom-input-valueasdate" id="dom-input-valueasdate-dev">valueAsDate</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns a <code id="common-input-element-apis:date"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object representing the form control's <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-2">value</a>, if applicable; otherwise, returns null.</p>

    <p>Can be set, to change the value.</p>

    <p>Throws an <a id="common-input-element-apis:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    control isn't date- or time-based.</p>
   </dd><dt><code><var>input</var>.<a href="#dom-input-valueasnumber" id="dom-input-valueasnumber-dev">valueAsNumber</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns a number representing the form control's <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-3">value</a>, if applicable; otherwise, returns NaN.</p>

    <p>Can be set, to change the value. Setting this to NaN will set the underlying value to the
    empty string.</p>

    <p>Throws an <a id="common-input-element-apis:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    control is neither date- or time-based nor numeric.</p>
   </dd><dt><code><var>input</var>.<a href="#dom-input-stepup" id="dom-input-stepup-dev">stepUp</a>([ <var>n</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/stepUp" title="The HTMLInputElement.stepUp() method increments the value of a numeric type of <input> element by the value of the step attribute, or the default step value if the step attribute is not explicitly set. The method, when invoked, increments the value by (step * n), where n defaults to 1 if not specified, and step defaults to the default value for step if not specified.">HTMLInputElement/stepUp</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Partial implementation.">🔰 16+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>input</var>.<a href="#dom-input-stepdown" id="dom-input-stepdown-dev">stepDown</a>([ <var>n</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/stepDown" title="The HTMLInputElement.stepDown([n]) method decrements the value of a numeric type of <input> element by the value of the step attribute or up to n multiples of the step attribute if a number is passed as the parameter.">HTMLInputElement/stepDown</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Partial implementation.">🔰 16+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Changes the form control's <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-4">value</a> by the value given in
    the <code id="common-input-element-apis:attr-input-step"><a href="#attr-input-step">step</a></code> attribute, multiplied by <var>n</var>. The
    default value for <var>n</var> is 1.</p>

    <p>Throws <a id="common-input-element-apis:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the control
    is neither date- or time-based nor numeric, or if the <code id="common-input-element-apis:attr-input-step-2"><a href="#attr-input-step">step</a></code>
    attribute's value is "<code>any</code>".</p>
   </dd><dt><code><var>input</var>.<a href="#dom-input-list" id="dom-input-list-dev">list</a></code></dt><dd><p>Returns the <code id="common-input-element-apis:the-datalist-element"><a href="#the-datalist-element">datalist</a></code> element indicated by the <code id="common-input-element-apis:attr-input-list"><a href="#attr-input-list">list</a></code> attribute.</p></dd><dt><code><var>input</var>.<a href="#dom-input-showpicker" id="dom-input-showpicker-dev">showPicker</a>()</code></dt><dd>
    <p>Shows any applicable picker UI for <var>input</var>, so that the user can select a value.</p>

    <p>If <var>input</var> does not <a href="#input-support-picker" id="common-input-element-apis:input-support-picker">support a picker</a>,
    this method does nothing.</p>

    <p>Throws an <a id="common-input-element-apis:invalidstateerror-5" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    <var>input</var> is not <a href="#concept-fe-mutable" id="common-input-element-apis:concept-fe-mutable">mutable</a>.</p>

    <p>Throws a <a id="common-input-element-apis:notallowederror" href="https://webidl.spec.whatwg.org/#notallowederror" data-x-internal="notallowederror">"<code>NotAllowedError</code>"</a> <code id="common-input-element-apis:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if called
    without <a href="#transient-activation" id="common-input-element-apis:transient-activation">transient user activation</a>.</p>

    <p>Throws a <a id="common-input-element-apis:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="common-input-element-apis:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    <var>input</var> is inside a cross-origin <code id="common-input-element-apis:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, unless <var>input</var> is in the
    <a href="#file-upload-state-(type=file)" id="common-input-element-apis:file-upload-state-(type=file)">File Upload</a> or <a href="#color-state-(type=color)" id="common-input-element-apis:color-state-(type=color)">Color</a> states.</p>
  </dd></dl>

  

  <p>The <dfn data-dfn-for="HTMLInputElement" id="dom-input-value" data-dfn-type="attribute"><code>value</code></dfn> IDL
  attribute allows scripts to manipulate the <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-5">value</a> of an
  <code id="common-input-element-apis:the-input-element-2"><a href="#the-input-element">input</a></code> element. The attribute is in one of the following modes, which define its
  behavior:</p>

  <dl><dt><dfn id="dom-input-value-value">value</dfn>

   </dt><dd>
    <div data-algorithm="">
    <p>On getting, return the current <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-6">value</a> of the
    element.</p>
    </div>

    <div data-algorithm="">
    <p>On setting:</p>

    <ol><li><p>Let <var>oldValue</var> be the element's <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-7">value</a>.</p></li><li><p>Set the element's <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-8">value</a> to the new
     value.</p></li><li><p>Set the element's <a href="#concept-fe-dirty" id="common-input-element-apis:concept-fe-dirty">dirty value flag</a> to
     true.</p></li><li><p>Invoke the <a href="#value-sanitization-algorithm" id="common-input-element-apis:value-sanitization-algorithm">value sanitization algorithm</a>, if the element's <code id="common-input-element-apis:attr-input-type"><a href="#attr-input-type">type</a></code> attribute's current state defines one.</p></li><li><p>If the element's <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-9">value</a> (after applying the
     <a href="#value-sanitization-algorithm" id="common-input-element-apis:value-sanitization-algorithm-2">value sanitization algorithm</a>) is different from <var>oldValue</var>, and the
     element has a <a href="#concept-textarea/input-cursor" id="common-input-element-apis:concept-textarea/input-cursor">text entry cursor position</a>,
     move the <a href="#concept-textarea/input-cursor" id="common-input-element-apis:concept-textarea/input-cursor-2">text entry cursor position</a> to the
     end of the text control, unselecting any selected text and <a href="#set-the-selection-direction" id="common-input-element-apis:set-the-selection-direction">resetting the selection direction</a> to "<code>none</code>".</p></li></ol>
    </div>
   </dd><dt><dfn id="dom-input-value-default">default</dfn>

   </dt><dd>
    <div data-algorithm="">
    <p>On getting, if the element has a <code id="common-input-element-apis:attr-input-value"><a href="#attr-input-value">value</a></code> content
    attribute, return that attribute's value; otherwise, return the empty string.</p>
    </div>

    <div data-algorithm="">
    <p>On setting, set the value of the element's <code id="common-input-element-apis:attr-input-value-2"><a href="#attr-input-value">value</a></code>
    content attribute to the new value.</p>
    </div>
   </dd><dt><dfn id="dom-input-value-default-on">default/on</dfn>

   </dt><dd>
    <div data-algorithm="">
    <p>On getting, if the element has a <code id="common-input-element-apis:attr-input-value-3"><a href="#attr-input-value">value</a></code> content
    attribute, return that attribute's value; otherwise, return the string "<code>on</code>".</p>
    </div>

    <div data-algorithm="">
    <p>On setting, set the value of the element's <code id="common-input-element-apis:attr-input-value-4"><a href="#attr-input-value">value</a></code>
    content attribute to the new value.</p>
    </div>
   </dd><dt><dfn id="dom-input-value-filename">filename</dfn>

   </dt><dd id="fakepath-orly">

    <div data-algorithm="">
    <p>On getting, return the string "<code>C:\fakepath\</code>" followed by the name of
    the first file in the list of <a href="#concept-input-type-file-selected" id="common-input-element-apis:concept-input-type-file-selected-3">selected
    files</a>, if any, or the empty string if the list is empty.</p>
    </div>

    <div data-algorithm="">
    <p>On setting, if the new value is the empty string, empty the list of <a href="#concept-input-type-file-selected" id="common-input-element-apis:concept-input-type-file-selected-4">selected files</a>; otherwise, throw an
    <a id="common-input-element-apis:invalidstateerror-6" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
    </div>

    <p class="note">This "fakepath" requirement is a sad accident of history. See <a href="#fakepath-srsly">the example in the File Upload state section</a> for more
    information.</p>

    <p class="note">Since <a href="#concept-input-file-path" id="common-input-element-apis:concept-input-file-path">path components</a> are not
    permitted in filenames in the list of <a href="#concept-input-type-file-selected" id="common-input-element-apis:concept-input-type-file-selected-5">selected
    files</a>, the "\fakepath\" cannot be mistaken for a path component.</p>
   </dd></dl>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement" id="dom-input-checked" data-dfn-type="attribute"><code>checked</code></dfn>
  IDL attribute allows scripts to manipulate the <a href="#concept-fe-checked" id="common-input-element-apis:concept-fe-checked-3">checkedness</a> of an <code id="common-input-element-apis:the-input-element-3"><a href="#the-input-element">input</a></code> element. On getting, it
  must return the current <a href="#concept-fe-checked" id="common-input-element-apis:concept-fe-checked-4">checkedness</a> of the element; and
  on setting, it must set the element's <a href="#concept-fe-checked" id="common-input-element-apis:concept-fe-checked-5">checkedness</a> to the
  new value and set the element's <a href="#concept-input-checked-dirty-flag" id="common-input-element-apis:concept-input-checked-dirty-flag">dirty checkedness
  flag</a> to true.</p>
  </div>

  <hr>

  <p>The <dfn data-dfn-for="HTMLInputElement" id="dom-input-files" data-dfn-type="attribute"><code>files</code></dfn> IDL
  attribute allows scripts to access the element's <a href="#concept-input-type-file-selected" id="common-input-element-apis:concept-input-type-file-selected-6">selected files</a>.

  </p><div data-algorithm="">
  <p>On getting, if the IDL attribute <a href="#concept-input-apply" id="common-input-element-apis:concept-input-apply">applies</a>, it must
  return a <code id="common-input-element-apis:filelist-3"><a data-x-internal="filelist" href="https://w3c.github.io/FileAPI/#filelist-section">FileList</a></code> object that represents the current <a href="#concept-input-type-file-selected" id="common-input-element-apis:concept-input-type-file-selected-7">selected files</a>. The same object must be returned
  until the list of <a href="#concept-input-type-file-selected" id="common-input-element-apis:concept-input-type-file-selected-8">selected files</a> changes.
  If the IDL attribute <a href="#do-not-apply" id="common-input-element-apis:do-not-apply">does not apply</a>, then it must instead
  return null. <a href="#refsFILEAPI">[FILEAPI]</a></p>
  </div>

  <div data-algorithm="">
  <p>On setting, it must run these steps:

  </p><ol><li><p>If the IDL attribute <a href="#do-not-apply" id="common-input-element-apis:do-not-apply-2">does not apply</a> or the given value
   is null, then return.</p></li><li><p>Replace the element's <a href="#concept-input-type-file-selected" id="common-input-element-apis:concept-input-type-file-selected-9">selected
   files</a> with the given value.</p></li></ol>
  </div>

  <hr>

  <p>The <dfn data-dfn-for="HTMLInputElement" id="dom-input-valueasdate" data-dfn-type="attribute"><code>valueAsDate</code></dfn> IDL attribute represents the <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-10">value</a> of the element, interpreted as a date.</p>

  <div data-algorithm="">
  <p>On getting, if the <code id="common-input-element-apis:dom-input-valueasdate"><a href="#dom-input-valueasdate">valueAsDate</a></code> attribute <a href="#do-not-apply" id="common-input-element-apis:do-not-apply-3">does not apply</a>, as defined for the <code id="common-input-element-apis:the-input-element-4"><a href="#the-input-element">input</a></code> element's <code id="common-input-element-apis:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute's current state, then return null. Otherwise, run
  the <a href="#concept-input-value-string-date" id="common-input-element-apis:concept-input-value-string-date">algorithm to convert a string to a
  <code>Date</code> object</a> defined for that state to the element's <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-11">value</a>; if the algorithm returned a <code id="common-input-element-apis:date-2"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object, then
  return it, otherwise, return null.</p>
  </div>

  <div data-algorithm="">
  <p>On setting, if the <code id="common-input-element-apis:dom-input-valueasdate-2"><a href="#dom-input-valueasdate">valueAsDate</a></code> attribute <a href="#do-not-apply" id="common-input-element-apis:do-not-apply-4">does not apply</a>, as defined for the <code id="common-input-element-apis:the-input-element-5"><a href="#the-input-element">input</a></code> element's <code id="common-input-element-apis:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute's current state, then throw an
  <a id="common-input-element-apis:invalidstateerror-7" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>; otherwise, if the new
  value is not null and not a <code id="common-input-element-apis:date-3"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object throw a <code id="common-input-element-apis:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> exception;
  otherwise, if the new value is null or a <code id="common-input-element-apis:date-4"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> object representing the NaN time value,
  then set the <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-12">value</a> of the element to the empty string;
  otherwise, run the <a href="#concept-input-value-date-string" id="common-input-element-apis:concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</a>, as defined for that state, on the new value, and set
  the <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-13">value</a> of the element to the resulting string.</p>
  </div>

  <hr>

  <p>The <dfn data-dfn-for="HTMLInputElement" id="dom-input-valueasnumber" data-dfn-type="attribute"><code>valueAsNumber</code></dfn> IDL attribute represents the <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-14">value</a> of the element, interpreted as a number.</p>

  <div data-algorithm="">
  <p>On getting, if the <code id="common-input-element-apis:dom-input-valueasnumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> attribute <a href="#do-not-apply" id="common-input-element-apis:do-not-apply-5">does not apply</a>, as defined for the <code id="common-input-element-apis:the-input-element-6"><a href="#the-input-element">input</a></code> element's <code id="common-input-element-apis:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute's current state, then return a Not-a-Number (NaN)
  value. Otherwise, run the <a href="#concept-input-value-string-number" id="common-input-element-apis:concept-input-value-string-number">algorithm to convert a
  string to a number</a> defined for that state to the element's <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-15">value</a>; if the algorithm returned a number, then return it,
  otherwise, return a Not-a-Number (NaN) value.</p>
  </div>

  <div data-algorithm="">
  <p>On setting, if the new value is infinite, then throw a <code id="common-input-element-apis:typeerror-2"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> exception.
  Otherwise, if the <code id="common-input-element-apis:dom-input-valueasnumber-2"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> attribute <a href="#do-not-apply" id="common-input-element-apis:do-not-apply-6">does not apply</a>, as defined for the <code id="common-input-element-apis:the-input-element-7"><a href="#the-input-element">input</a></code> element's <code id="common-input-element-apis:attr-input-type-5"><a href="#attr-input-type">type</a></code> attribute's current state, then throw an
  <a id="common-input-element-apis:invalidstateerror-8" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-10"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>. Otherwise, if the new
  value is a Not-a-Number (NaN) value, then set the <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-16">value</a> of
  the element to the empty string. Otherwise, run the <a href="#concept-input-value-number-string" id="common-input-element-apis:concept-input-value-number-string">algorithm to convert a number to a string</a>, as
  defined for that state, on the new value, and set the <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-17">value</a>
  of the element to the resulting string.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement" id="dom-input-stepdown" data-dfn-type="method"><code>stepDown(<var>n</var>)</code></dfn> and <dfn data-dfn-for="HTMLInputElement" id="dom-input-stepup" data-dfn-type="method"><code>stepUp(<var>n</var>)</code></dfn> methods,
  when invoked, must run the following algorithm:</p>

  <ol><li><p>If the <code id="common-input-element-apis:dom-input-stepdown"><a href="#dom-input-stepdown">stepDown()</a></code> and <code id="common-input-element-apis:dom-input-stepup"><a href="#dom-input-stepup">stepUp()</a></code> methods <a href="#do-not-apply" id="common-input-element-apis:do-not-apply-7">do not apply</a>, as defined for the
   <code id="common-input-element-apis:the-input-element-8"><a href="#the-input-element">input</a></code> element's <code id="common-input-element-apis:attr-input-type-6"><a href="#attr-input-type">type</a></code> attribute's current state,
   then throw an <a id="common-input-element-apis:invalidstateerror-9" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-11"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the element has no <a href="#concept-input-step" id="common-input-element-apis:concept-input-step">allowed value step</a>, then
   throw an <a id="common-input-element-apis:invalidstateerror-10" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-12"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the element has a <a href="#concept-input-min" id="common-input-element-apis:concept-input-min">minimum</a> and a <a href="#concept-input-max" id="common-input-element-apis:concept-input-max">maximum</a> and the <a href="#concept-input-min" id="common-input-element-apis:concept-input-min-2">minimum</a>
   is greater than the <a href="#concept-input-max" id="common-input-element-apis:concept-input-max-2">maximum</a>, then return.</p>

   </li><li><p>If the element has a <a href="#concept-input-min" id="common-input-element-apis:concept-input-min-3">minimum</a> and a <a href="#concept-input-max" id="common-input-element-apis:concept-input-max-3">maximum</a> and there is no value greater than or equal to the
   element's <a href="#concept-input-min" id="common-input-element-apis:concept-input-min-4">minimum</a> and less than or equal to the element's
   <a href="#concept-input-max" id="common-input-element-apis:concept-input-max-4">maximum</a> that, when subtracted from the <a href="#concept-input-min-zero" id="common-input-element-apis:concept-input-min-zero">step base</a>, is an integral multiple of the <a href="#concept-input-step" id="common-input-element-apis:concept-input-step-2">allowed value step</a>, then return.</p>

   </li><li><p>If applying the <a href="#concept-input-value-string-number" id="common-input-element-apis:concept-input-value-string-number-2">algorithm to convert a
   string to a number</a> to the string given by the element's <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-18">value</a> does not result in an error, then let <var>value</var> be the result of that algorithm. Otherwise, let <var>value</var>
   be zero.</p></li><li><p>Let <var>valueBeforeStepping</var> be <var>value</var>.</p></li><li>
    <p>If <var>value</var> subtracted from the <a href="#concept-input-min-zero" id="common-input-element-apis:concept-input-min-zero-2">step
    base</a> is not an integral multiple of the <a href="#concept-input-step" id="common-input-element-apis:concept-input-step-3">allowed value
    step</a>, then set <var>value</var> to the nearest value that, when subtracted from
    the <a href="#concept-input-min-zero" id="common-input-element-apis:concept-input-min-zero-3">step base</a>, is an integral multiple of the <a href="#concept-input-step" id="common-input-element-apis:concept-input-step-4">allowed value step</a>, and that is less than <var>value</var> if
    the method invoked was the <code id="common-input-element-apis:dom-input-stepdown-2"><a href="#dom-input-stepdown">stepDown()</a></code> method, and more
    than <var>value</var> otherwise.</p>

    <p>Otherwise (<var>value</var> subtracted from the <a href="#concept-input-min-zero" id="common-input-element-apis:concept-input-min-zero-4">step base</a> is an integral multiple of the <a href="#concept-input-step" id="common-input-element-apis:concept-input-step-5">allowed value step</a>):</p>

    <ol><li><p>Let <var>n</var> be the argument.</p></li><li><p>Let <var>delta</var> be the <a href="#concept-input-step" id="common-input-element-apis:concept-input-step-6">allowed value
     step</a> multiplied by <var>n</var>.</p></li><li><p>If the method invoked was the <code id="common-input-element-apis:dom-input-stepdown-3"><a href="#dom-input-stepdown">stepDown()</a></code> method,
     negate <var>delta</var>.</p></li><li><p>Let <var>value</var> be the result of adding <var>delta</var> to <var>value</var>.</p></li></ol>
   </li><li><p>If the element has a <a href="#concept-input-min" id="common-input-element-apis:concept-input-min-5">minimum</a>, and <var>value</var>
   is less than that <a href="#concept-input-min" id="common-input-element-apis:concept-input-min-6">minimum</a>, then set
   <var>value</var> to the smallest value that, when subtracted from the <a href="#concept-input-min-zero" id="common-input-element-apis:concept-input-min-zero-5">step base</a>, is an integral multiple of the <a href="#concept-input-step" id="common-input-element-apis:concept-input-step-7">allowed value step</a>, and that is more than or equal to
   that <a href="#concept-input-min" id="common-input-element-apis:concept-input-min-7">minimum</a>.</p></li><li><p>If the element has a <a href="#concept-input-max" id="common-input-element-apis:concept-input-max-5">maximum</a>, and <var>value</var>
   is greater than that <a href="#concept-input-max" id="common-input-element-apis:concept-input-max-6">maximum</a>, then
   set <var>value</var> to the largest value that, when subtracted from the <a href="#concept-input-min-zero" id="common-input-element-apis:concept-input-min-zero-6">step base</a>, is an integral multiple of the <a href="#concept-input-step" id="common-input-element-apis:concept-input-step-8">allowed value step</a>, and that is less than or equal to
   that <a href="#concept-input-max" id="common-input-element-apis:concept-input-max-7">maximum</a>.</p></li><li>
    <p>If either the method invoked was the <code id="common-input-element-apis:dom-input-stepdown-4"><a href="#dom-input-stepdown">stepDown()</a></code>
    method and <var>value</var> is greater than <var>valueBeforeStepping</var>, or the method
    invoked was the <code id="common-input-element-apis:dom-input-stepup-2"><a href="#dom-input-stepup">stepUp()</a></code> method and <var>value</var> is
    less than <var>valueBeforeStepping</var>, then return.</p>

    <div class="example">
     <p>This ensures that invoking the <code id="common-input-element-apis:dom-input-stepup-3"><a href="#dom-input-stepup">stepUp()</a></code> method on the
     <code id="common-input-element-apis:the-input-element-9"><a href="#the-input-element">input</a></code> element in the following example does not change the <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-19">value</a> of that element:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">1</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">0</c-><c- p="">&gt;</c-></code></pre>
    </div>
   </li><li><p>Let <var>value as string</var> be the result of running the <a href="#concept-input-value-number-string" id="common-input-element-apis:concept-input-value-number-string-2">algorithm to convert a number to a string</a>, as
   defined for the <code id="common-input-element-apis:the-input-element-10"><a href="#the-input-element">input</a></code> element's <code id="common-input-element-apis:attr-input-type-7"><a href="#attr-input-type">type</a></code>
   attribute's current state, on <var>value</var>.</p></li><li><p>Set the <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-20">value</a> of the element to <var>value
   as string</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement" id="dom-input-list" data-dfn-type="attribute"><code>list</code></dfn> IDL
  attribute must return the current <a href="#concept-input-list" id="common-input-element-apis:concept-input-list">suggestions source
  element</a>, if any, or null otherwise.</p>
  </div>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/showPicker" title="The HTMLInputElement.showPicker() method displays the browser picker for an input element.">HTMLInputElement/showPicker</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>101+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <code id="common-input-element-apis:htmlinputelement"><a href="#htmlinputelement">HTMLInputElement</a></code> <dfn data-dfn-for="HTMLInputElement" id="dom-input-showpicker" data-dfn-type="method"><code>showPicker()</code></dfn> and <code id="common-input-element-apis:htmlselectelement"><a href="#htmlselectelement">HTMLSelectElement</a></code> <dfn data-dfn-for="HTMLSelectElement" id="dom-select-showpicker" data-dfn-type="method"><code>showPicker()</code></dfn>
  method steps are:</p>

  <ol><li><p>If <a id="common-input-element-apis:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is not <a href="#concept-fe-mutable" id="common-input-element-apis:concept-fe-mutable-2">mutable</a>, then throw
   an <a id="common-input-element-apis:invalidstateerror-11" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="common-input-element-apis:domexception-13"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p>If <a id="common-input-element-apis:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="common-input-element-apis:relevant-settings-object">relevant settings object</a>'s <a href="#concept-settings-object-origin" id="common-input-element-apis:concept-settings-object-origin">origin</a> is not <a href="#same-origin" id="common-input-element-apis:same-origin">same origin</a> with
    <a id="common-input-element-apis:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="common-input-element-apis:relevant-settings-object-2">relevant settings object</a>'s <a href="#concept-environment-top-level-origin" id="common-input-element-apis:concept-environment-top-level-origin">top-level origin</a>, and
    <a id="common-input-element-apis:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is a <code id="common-input-element-apis:the-select-element"><a href="#the-select-element">select</a></code> element, or
    <a id="common-input-element-apis:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="common-input-element-apis:attr-input-type-8"><a href="#attr-input-type">type</a></code> attribute is not in the <a href="#file-upload-state-(type=file)" id="common-input-element-apis:file-upload-state-(type=file)-2">File Upload</a> state or <a href="#color-state-(type=color)" id="common-input-element-apis:color-state-(type=color)-2">Color</a> state, then throw a
    <a id="common-input-element-apis:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="common-input-element-apis:domexception-14"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p class="note"><a href="#file-upload-state-(type=file)" id="common-input-element-apis:file-upload-state-(type=file)-3">File</a> and <a href="#color-state-(type=color)" id="common-input-element-apis:color-state-(type=color)-3">Color</a> inputs are exempted from this check for historical
    reason: their <a href="#input-activation-behavior" id="common-input-element-apis:input-activation-behavior">input activation behavior</a> also shows their pickers, and has never
    been guarded by an origin check.</p>
   </li><li><p>If <a id="common-input-element-apis:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="common-input-element-apis:concept-relevant-global">relevant global object</a> does not have <a href="#transient-activation" id="common-input-element-apis:transient-activation-2">transient
   activation</a>, then throw a <a id="common-input-element-apis:notallowederror-2" href="https://webidl.spec.whatwg.org/#notallowederror" data-x-internal="notallowederror">"<code>NotAllowedError</code>"</a>
   <code id="common-input-element-apis:domexception-15"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="common-input-element-apis:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is a <code id="common-input-element-apis:the-select-element-2"><a href="#the-select-element">select</a></code> element, and <a id="common-input-element-apis:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is not
   <a href="#being-rendered" id="common-input-element-apis:being-rendered">being rendered</a>, then throw a <a id="common-input-element-apis:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a>
   <code id="common-input-element-apis:domexception-16"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#show-the-picker,-if-applicable" id="common-input-element-apis:show-the-picker,-if-applicable">Show the picker, if applicable</a>, for <a id="common-input-element-apis:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="show-the-picker,-if-applicable">show the picker, if applicable</dfn> for an <code id="common-input-element-apis:the-input-element-11"><a href="#the-input-element">input</a></code> or <code id="common-input-element-apis:the-select-element-3"><a href="#the-select-element">select</a></code>
  element <var>element</var>:</p>

  <ol><li><p>If <var>element</var>'s <a href="#concept-relevant-global" id="common-input-element-apis:concept-relevant-global-2">relevant global object</a> does not have <a href="#transient-activation" id="common-input-element-apis:transient-activation-3">transient
   activation</a>, then return.</p></li><li><p>If <var>element</var> is not <i id="common-input-element-apis:concept-fe-mutable-3"><a href="#concept-fe-mutable">mutable</a></i>, then
   return.</p></li><li><p><a href="#consume-user-activation" id="common-input-element-apis:consume-user-activation">Consume user activation</a> given <var>element</var>'s <a href="#concept-relevant-global" id="common-input-element-apis:concept-relevant-global-3">relevant global
   object</a>.</p></li><li><p>If <var>element</var> does not <a href="#input-support-picker" id="common-input-element-apis:input-support-picker-2">support a
   picker</a>, then return.</p></li><li>
    <p>If <var>element</var> is an <code id="common-input-element-apis:the-input-element-12"><a href="#the-input-element">input</a></code> element and <var>element</var>'s <code id="common-input-element-apis:attr-input-type-9"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#file-upload-state-(type=file)" id="common-input-element-apis:file-upload-state-(type=file)-4">File Upload</a> state, then run these steps <a href="#in-parallel" id="common-input-element-apis:in-parallel">in
    parallel</a>:</p>

    <ol><li><p>Optionally, wait until any prior execution of this algorithm has terminated.</p></li><li><p>Let <var>dismissed</var> be the result of <a id="common-input-element-apis:webdriver-bidi-file-dialog-opened" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-file-dialog-opened" data-x-internal="webdriver-bidi-file-dialog-opened">WebDriver BiDi file dialog opened</a>
     with <var>element</var>.</p></li><li>
      <p>If <var>dismissed</var> is false:</p>

      <ol><li><p>Display a prompt to the user requesting that the user specify some files. If the <code id="common-input-element-apis:attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> attribute is not set on <var>element</var>, there
       must be no more than one file selected; otherwise, any number may be selected. Files can be
       from the filesystem or created on the fly, e.g., a picture taken from a camera connected to the
       user's device.</p></li><li><p>Wait for the user to have made their selection.</p></li></ol>
     </li><li><p>If <var>dismissed</var> is true or if the user dismissed the prompt without changing
     their selection, then <a href="#queue-an-element-task" id="common-input-element-apis:queue-an-element-task">queue an element task</a> on the <a href="#user-interaction-task-source" id="common-input-element-apis:user-interaction-task-source">user interaction task
     source</a> given <var>element</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="common-input-element-apis:concept-event-fire" data-x-internal="concept-event-fire">fire an
     event</a> named <code id="common-input-element-apis:event-cancel"><a href="#event-cancel">cancel</a></code> at <var>element</var>, with the
     <code id="common-input-element-apis:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to true.</p></li><li><p>Otherwise, <a href="#update-the-file-selection" id="common-input-element-apis:update-the-file-selection">update the file selection</a> for <var>element</var>.</p></li></ol>

    <p class="note">As with all user interface specifications, user agents have a good deal of
    freedom in how they interpret these requirements. The above text implies that a user either
    dismisses the prompt or changes their selection; exactly one of these will be true. But the
    mapping of these possibilities to specific user interface elements is not mandated by the
    standard. For example, a user agent might interpret clicking the "Cancel" button when files were
    previously selected as a change of selection to select zero files, thus firing <code id="common-input-element-apis:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="common-input-element-apis:event-change"><a href="#event-change">change</a></code>. Or it might
    interpret such a click as a dismissal that leaves the selection unchanged, thus firing <code id="common-input-element-apis:event-cancel-2"><a href="#event-cancel">cancel</a></code>. Similarly, it's up to the user agent whether re-selecting
    the same files as were previously selected counts as a dismissal, or as a change of
    selection.</p>
   </li><li>
    <p>Otherwise, the user agent should show the relevant user interface for selecting a value for
    <var>element</var>, in the way it normally would when the user interacts with the control.</p>

    <p>When showing such a user interface, it must respect the requirements stated in the relevant
    parts of the specification for how <var>element</var> behaves given its <code id="common-input-element-apis:attr-input-type-10"><a href="#attr-input-type">type</a></code> attribute state. (For example, various sections describe
    restrictions on the resulting <a href="#concept-fe-value" id="common-input-element-apis:concept-fe-value-21">value</a> string.)</p>

    <p>This step can have side effects, such as closing other pickers that were previously shown by
    this algorithm. (If this closes a file selection picker, then per the above that will lead to
    firing either <code id="common-input-element-apis:event-input-2"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="common-input-element-apis:event-change-2"><a href="#event-change">change</a></code> events, or a <code id="common-input-element-apis:event-cancel-3"><a href="#event-cancel">cancel</a></code>
    event.)</p>
   </li></ol>
  </div>

  


  

  <h5 id="common-input-element-events"><span class="secno">4.10.5.5</span> Common event behaviors<a href="#common-input-element-events" class="self-link"></a></h5>

  <p>When the <code id="common-input-element-events:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> and <code id="common-input-element-events:event-change"><a href="#event-change">change</a></code> events <a href="#concept-input-apply" id="common-input-element-events:concept-input-apply">apply</a>
  (which is the case for all <code id="common-input-element-events:the-input-element"><a href="#the-input-element">input</a></code> controls other than <a href="#concept-button" id="common-input-element-events:concept-button">buttons</a> and those with the <code id="common-input-element-events:attr-input-type"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="common-input-element-events:hidden-state-(type=hidden)">Hidden</a> state), the events are fired to indicate that the
  user has interacted with the control. The <code id="common-input-element-events:event-input-2"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> event fires
  whenever the user has modified the data of the control. The <code id="common-input-element-events:event-change-2"><a href="#event-change">change</a></code> event fires when the value is committed, if that makes sense
  for the control, or else when the control <a href="#unfocus-causes-change-event">loses focus</a>.
  In all cases, the <code id="common-input-element-events:event-input-3"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> event comes before the corresponding
  <code id="common-input-element-events:event-change-3"><a href="#event-change">change</a></code> event (if any).</p>

  <p>When an <code id="common-input-element-events:the-input-element-2"><a href="#the-input-element">input</a></code> element has a defined <a href="#input-activation-behavior" id="common-input-element-events:input-activation-behavior">input activation behavior</a>, the
  rules for dispatching these events, if they <a href="#concept-input-apply" id="common-input-element-events:concept-input-apply-2">apply</a>, are
  given in the section above that defines the <code id="common-input-element-events:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute's
  state. (This is the case for all <code id="common-input-element-events:the-input-element-3"><a href="#the-input-element">input</a></code> controls with the <code id="common-input-element-events:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute in the <a href="#checkbox-state-(type=checkbox)" id="common-input-element-events:checkbox-state-(type=checkbox)">Checkbox</a> state, the <a href="#radio-button-state-(type=radio)" id="common-input-element-events:radio-button-state-(type=radio)">Radio Button</a> state, or the <a href="#file-upload-state-(type=file)" id="common-input-element-events:file-upload-state-(type=file)">File Upload</a> state.)</p>

  <div data-algorithm="">
  <p>For <code id="common-input-element-events:the-input-element-4"><a href="#the-input-element">input</a></code> elements without a defined <a href="#input-activation-behavior" id="common-input-element-events:input-activation-behavior-2">input activation behavior</a>, but
  to which these events <a href="#concept-input-apply" id="common-input-element-events:concept-input-apply-3">apply</a>, and for which the user
  interface involves both interactive manipulation and an explicit commit action, then when the
  user changes the element's <a href="#concept-fe-value" id="common-input-element-events:concept-fe-value">value</a>, the user agent must
  <a href="#queue-an-element-task" id="common-input-element-events:queue-an-element-task">queue an element task</a> on the <a href="#user-interaction-task-source" id="common-input-element-events:user-interaction-task-source">user interaction task source</a> given the
  <code id="common-input-element-events:the-input-element-5"><a href="#the-input-element">input</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="common-input-element-events:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="common-input-element-events:event-input-4"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the <code id="common-input-element-events:the-input-element-6"><a href="#the-input-element">input</a></code> element, with the <code id="common-input-element-events:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="common-input-element-events:dom-event-composed"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code>
  attributes initialized to true, and any time the user commits the change, the user agent must
  <a href="#queue-an-element-task" id="common-input-element-events:queue-an-element-task-2">queue an element task</a> on the <a href="#user-interaction-task-source" id="common-input-element-events:user-interaction-task-source-2">user interaction task source</a> given the
  <code id="common-input-element-events:the-input-element-7"><a href="#the-input-element">input</a></code> element to set its <a href="#user-validity" id="common-input-element-events:user-validity">user validity</a> to true and <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="common-input-element-events:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="common-input-element-events:event-change-4"><a href="#event-change">change</a></code>
  at the <code id="common-input-element-events:the-input-element-8"><a href="#the-input-element">input</a></code> element, with the <code id="common-input-element-events:dom-event-bubbles-2"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code>
  attribute initialized to true.</p>
  </div>

  <p class="example">An example of a user interface involving both interactive manipulation and a
  commit action would be a <a href="#range-state-(type=range)" id="common-input-element-events:range-state-(type=range)">Range</a> controls that use a
  slider, when manipulated using a pointing device. While the user is dragging the control's knob,
  <code id="common-input-element-events:event-input-5"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> events would fire whenever the position changed,
  whereas the <code id="common-input-element-events:event-change-5"><a href="#event-change">change</a></code> event would only fire when the user
  let go of the knob, committing to a specific value.</p>

  <div data-algorithm="">
  <p>For <code id="common-input-element-events:the-input-element-9"><a href="#the-input-element">input</a></code> elements without a defined <a href="#input-activation-behavior" id="common-input-element-events:input-activation-behavior-3">input activation behavior</a>, but
  to which these events <a href="#concept-input-apply" id="common-input-element-events:concept-input-apply-4">apply</a>, and for which the user
  interface involves an explicit commit action but no intermediate manipulation, then any time the
  user commits a change to the element's <a href="#concept-fe-value" id="common-input-element-events:concept-fe-value-2">value</a>, the user
  agent must <a href="#queue-an-element-task" id="common-input-element-events:queue-an-element-task-3">queue an element task</a> on the <a href="#user-interaction-task-source" id="common-input-element-events:user-interaction-task-source-3">user interaction task source</a>
  given the <code id="common-input-element-events:the-input-element-10"><a href="#the-input-element">input</a></code> element to first <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="common-input-element-events:concept-event-fire-3" data-x-internal="concept-event-fire">fire an
  event</a> named <code id="common-input-element-events:event-input-6"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the <code id="common-input-element-events:the-input-element-11"><a href="#the-input-element">input</a></code> element, with
  the <code id="common-input-element-events:dom-event-bubbles-3"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="common-input-element-events:dom-event-composed-2"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code> attributes initialized to true, and then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="common-input-element-events:concept-event-fire-4" data-x-internal="concept-event-fire">fire an event</a> named <code id="common-input-element-events:event-change-6"><a href="#event-change">change</a></code>
  at the <code id="common-input-element-events:the-input-element-12"><a href="#the-input-element">input</a></code> element, with the <code id="common-input-element-events:dom-event-bubbles-4"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code>
  attribute initialized to true.</p>
  </div>

  <p class="example">An example of a user interface with a commit action would be a <a href="#color-state-(type=color)" id="common-input-element-events:color-state-(type=color)">Color</a> control that consists of a single button that brings
  up a color wheel: if the <a href="#concept-fe-value" id="common-input-element-events:concept-fe-value-3">value</a> only changes when the dialog
  is closed, then that would be the explicit commit action. On the other hand, if manipulating the
  control changes the color interactively, then there might be no commit action.</p>

  <p class="example">Another example of a user interface with a commit action would be a <a href="#date-state-(type=date)" id="common-input-element-events:date-state-(type=date)">Date</a> control that allows both text-based user input and user
  selection from a drop-down calendar: while text input might not have an explicit commit step,
  selecting a date from the drop down calendar and then dismissing the drop down would be a commit
  action.</p>

  <div data-algorithm="">
  <p>For <code id="common-input-element-events:the-input-element-13"><a href="#the-input-element">input</a></code> elements without a defined <a href="#input-activation-behavior" id="common-input-element-events:input-activation-behavior-4">input activation behavior</a>, but
  to which these events <a href="#concept-input-apply" id="common-input-element-events:concept-input-apply-5">apply</a>, any time the user causes
  the element's <a href="#concept-fe-value" id="common-input-element-events:concept-fe-value-4">value</a> to change without an explicit commit
  action, the user agent must <a href="#queue-an-element-task" id="common-input-element-events:queue-an-element-task-4">queue an element task</a> on the <a href="#user-interaction-task-source" id="common-input-element-events:user-interaction-task-source-4">user interaction task
  source</a> given the <code id="common-input-element-events:the-input-element-14"><a href="#the-input-element">input</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="common-input-element-events:concept-event-fire-5" data-x-internal="concept-event-fire">fire an
  event</a> named <code id="common-input-element-events:event-input-7"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the <code id="common-input-element-events:the-input-element-15"><a href="#the-input-element">input</a></code> element, with
  the <code id="common-input-element-events:dom-event-bubbles-5"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="common-input-element-events:dom-event-composed-3"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code> attributes initialized to true. The corresponding
  <code id="common-input-element-events:event-change-7"><a href="#event-change">change</a></code> event, if any, will be fired when the control <a href="#unfocus-causes-change-event">loses focus</a>.</p>
  </div>

  <p class="example">Examples of a user changing the element's <a href="#concept-fe-value" id="common-input-element-events:concept-fe-value-5">value</a> would include the user typing into a text control, pasting
  a new value into the control, or undoing an edit in that control. Some user interactions do not
  cause changes to the value, e.g., hitting the "delete" key in an empty text control, or replacing
  some text in the control with text from the clipboard that happens to be exactly the same
  text.</p>

  <p class="example">A <a href="#range-state-(type=range)" id="common-input-element-events:range-state-(type=range)-2">Range</a> control in the form of a
  slider that the user has <a href="#focused" id="common-input-element-events:focused">focused</a> and is interacting with using a keyboard would be
  another example of the user changing the element's <a href="#concept-fe-value" id="common-input-element-events:concept-fe-value-6">value</a>
  without a commit step.</p>

  <p>In the case of <a href="#concept-task" id="common-input-element-events:concept-task">tasks</a> that just fire an <code id="common-input-element-events:event-input-8"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> event, user agents may wait for a suitable break in the user's
  interaction before <a href="#queue-an-element-task" id="common-input-element-events:queue-an-element-task-5">queuing</a> the tasks; for example, a
  user agent could wait for the user to have not hit a key for 100ms, so as to only fire the event
  when the user pauses, instead of continuously for each keystroke. 

  </p><div data-algorithm="">
  <p>When the user agent is to change an <code id="common-input-element-events:the-input-element-16"><a href="#the-input-element">input</a></code> element's <a href="#concept-fe-value" id="common-input-element-events:concept-fe-value-7">value</a> on behalf of the user (e.g. as part of a form prefilling
  feature), the user agent must <a href="#queue-an-element-task" id="common-input-element-events:queue-an-element-task-6">queue an element task</a> on the <a href="#user-interaction-task-source" id="common-input-element-events:user-interaction-task-source-5">user interaction
  task source</a> given the <code id="common-input-element-events:the-input-element-17"><a href="#the-input-element">input</a></code> element to first update the <a href="#concept-fe-value" id="common-input-element-events:concept-fe-value-8">value</a> accordingly, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="common-input-element-events:concept-event-fire-6" data-x-internal="concept-event-fire">fire an
  event</a> named <code id="common-input-element-events:event-input-9"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the <code id="common-input-element-events:the-input-element-18"><a href="#the-input-element">input</a></code> element, with
  the <code id="common-input-element-events:dom-event-bubbles-6"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="common-input-element-events:dom-event-composed-4"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code> attributes initialized to true, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="common-input-element-events:concept-event-fire-7" data-x-internal="concept-event-fire">fire an event</a> named <code id="common-input-element-events:event-change-8"><a href="#event-change">change</a></code>
  at the <code id="common-input-element-events:the-input-element-19"><a href="#the-input-element">input</a></code> element, with the <code id="common-input-element-events:dom-event-bubbles-7"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code>
  attribute initialized to true.</p>
  </div>

  <p class="note">These events are not fired in response to changes made to the values of form
  controls by scripts. (This is to make it easier to update the values of form controls in response
  to the user manipulating the controls, without having to then filter out the script's own changes
  to avoid an infinite loop.)</p>

  <p class="note">These events are also not fired when the browser changes the values of form
  controls as part of <a href="#restore-persisted-state" id="common-input-element-events:restore-persisted-state">state restoration during
  navigation</a>.</p>

  



  <h4 id="the-button-element"><span class="secno">4.10.6</span> The <dfn data-dfn-type="element"><code>button</code></dfn> element<a href="#the-button-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button" title="The <button> HTML element is an interactive element activated by a user with a mouse, keyboard, finger, voice command, or other assistive technology. Once activated, it then performs an action, such as submitting a form or opening a dialog.">Element/button</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>15+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement" title="The HTMLButtonElement interface provides properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <button> elements.">HTMLButtonElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-button-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-button-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-button-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#interactive-content-2" id="the-button-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#category-listed" id="the-button-element:category-listed">Listed</a>, <a href="#category-label" id="the-button-element:category-label">labelable</a>, <a href="#category-submit" id="the-button-element:category-submit">submittable</a>, and <a href="#category-autocapitalize" id="the-button-element:category-autocapitalize">autocapitalize-and-autocorrect inheriting</a> <a href="#form-associated-element" id="the-button-element:form-associated-element">form-associated element</a>.</dd><dd><a href="#palpable-content-2" id="the-button-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-button-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-button-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dd>As the first child of a <code id="the-button-element:the-select-element"><a href="#the-select-element">select</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-button-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-button-element:phrasing-content-2-3">Phrasing content</a>, but there must be no <a href="#interactive-content-2" id="the-button-element:interactive-content-2-2">interactive content</a>
   descendant and no descendant with the <code id="the-button-element:attr-tabindex"><a href="#attr-tabindex">tabindex</a></code> attribute
   specified. If the element is the first child of a <code id="the-button-element:the-select-element-2"><a href="#the-select-element">select</a></code> element, then it may also
   have zero or one descendant <code id="the-button-element:the-selectedcontent-element"><a href="#the-selectedcontent-element">selectedcontent</a></code> element.</dd><dt><a href="#concept-element-tag-omission" id="the-button-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-button-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-button-element:global-attributes">Global attributes</a></dd><dd><code id="the-button-element:attr-button-command"><a href="#attr-button-command">command</a></code> —  Indicates to the targeted element which action to take.
     </dd><dd><code id="the-button-element:attr-button-commandfor"><a href="#attr-button-commandfor">commandfor</a></code> —  Targets another element to be invoked.
     </dd><dd><code id="the-button-element:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code> —  Whether the form control is disabled
     </dd><dd><code id="the-button-element:attr-fae-form"><a href="#attr-fae-form">form</a></code> —  Associates the element with a <code id="the-button-element:the-form-element"><a href="#the-form-element">form</a></code> element
     </dd><dd><code id="the-button-element:attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code> —  <a id="the-button-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> to use for <a href="#form-submission-2" id="the-button-element:form-submission-2">form submission</a>
     </dd><dd><code id="the-button-element:attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code> —  <a href="#entry-list" id="the-button-element:entry-list">Entry list</a> encoding type to use for <a href="#form-submission-2" id="the-button-element:form-submission-2-2">form submission</a>
     </dd><dd><code id="the-button-element:attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code> —  Variant to use for <a href="#form-submission-2" id="the-button-element:form-submission-2-3">form submission</a>
     </dd><dd><code id="the-button-element:attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code> —  Bypass form control validation for <a href="#form-submission-2" id="the-button-element:form-submission-2-4">form submission</a>
     </dd><dd><code id="the-button-element:attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code> —  <a href="#navigable" id="the-button-element:navigable">Navigable</a> for <a href="#form-submission-2" id="the-button-element:form-submission-2-5">form submission</a>
     </dd><dd><code id="the-button-element:attr-fe-name"><a href="#attr-fe-name">name</a></code> —  Name of the element to use for <a href="#form-submission-2" id="the-button-element:form-submission-2-6">form submission</a> and in the <code id="the-button-element:dom-form-elements"><a href="#dom-form-elements">form.elements</a></code> API 
     </dd><dd><code id="the-button-element:attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code> —  Targets a popover element to toggle, show, or hide
     </dd><dd><code id="the-button-element:attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code> —  Indicates whether a targeted popover element is to be toggled, shown, or hidden
     </dd><dd><code id="the-button-element:attr-button-type"><a href="#attr-button-type">type</a></code> —  Type of button
     </dd><dd><code id="the-button-element:attr-button-value"><a href="#attr-button-value">value</a></code> —  Value to be used for <a href="#form-submission-2" id="the-button-element:form-submission-2-7">form submission</a>
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-button-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-button">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-button">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-button-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlbuttonelement" data-dfn-type="interface"><c- g="">HTMLButtonElement</c-></dfn> : <a href="#htmlelement" id="the-button-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-button-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-button-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-button-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-button-command" id="the-button-element:dom-button-command"><c- g="">command</c-></a>;
  [<a href="#cereactions" id="the-button-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-button-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- n="">Element</c->? <dfn data-dfn-for="HTMLButtonElement" id="dom-button-commandforelement" data-dfn-type="attribute"><c- g="">commandForElement</c-></dfn>;
  [<a href="#cereactions" id="the-button-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-button-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLButtonElement" id="dom-button-disabled" data-dfn-type="attribute"><c- g="">disabled</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-button-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-fae-form" id="the-button-element:dom-fae-form"><c- g="">form</c-></a>;
  [<a href="#cereactions" id="the-button-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-button-element:xattr-reflectsetter-2"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-fs-formaction" id="the-button-element:dom-fs-formaction"><c- g="">formAction</c-></a>;
  [<a href="#cereactions" id="the-button-element:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fs-formenctype" id="the-button-element:dom-fs-formenctype"><c- g="">formEnctype</c-></a>;
  [<a href="#cereactions" id="the-button-element:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fs-formmethod" id="the-button-element:dom-fs-formmethod"><c- g="">formMethod</c-></a>;
  [<a href="#cereactions" id="the-button-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-button-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLButtonElement" id="dom-button-formnovalidate" data-dfn-type="attribute"><c- g="">formNoValidate</c-></dfn>;
  [<a href="#cereactions" id="the-button-element:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-button-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLButtonElement" id="dom-button-formtarget" data-dfn-type="attribute"><c- g="">formTarget</c-></dfn>;
  [<a href="#cereactions" id="the-button-element:cereactions-9"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-button-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLButtonElement" id="dom-button-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="the-button-element:cereactions-10"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-button-element:xattr-reflectsetter-3"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-button-type" id="the-button-element:dom-button-type"><c- g="">type</c-></a>;
  [<a href="#cereactions" id="the-button-element:cereactions-11"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-button-element:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLButtonElement" id="dom-button-value" data-dfn-type="attribute"><c- g="">value</c-></dfn>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-cva-willvalidate" id="the-button-element:dom-cva-willvalidate"><c- g="">willValidate</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#validitystate" id="the-button-element:validitystate"><c- n="">ValidityState</c-></a> <a href="#dom-cva-validity" id="the-button-element:dom-cva-validity"><c- g="">validity</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-cva-validationmessage" id="the-button-element:dom-cva-validationmessage"><c- g="">validationMessage</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-cva-checkvalidity" id="the-button-element:dom-cva-checkvalidity"><c- g="">checkValidity</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-cva-reportvalidity" id="the-button-element:dom-cva-reportvalidity"><c- g="">reportValidity</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-cva-setcustomvalidity" id="the-button-element:dom-cva-setcustomvalidity"><c- g="">setCustomValidity</c-></a>(<c- b="">DOMString</c-> <c- g="">error</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-button-element:nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist" data-x-internal="nodelist"><c- n="">NodeList</c-></a> <a href="#dom-lfe-labels" id="the-button-element:dom-lfe-labels"><c- g="">labels</c-></a>;
};
<a href="#htmlbuttonelement" id="the-button-element:htmlbuttonelement"><c- n="">HTMLButtonElement</c-></a> <c- b="">includes</c-> <a href="#popovertargetattributes" id="the-button-element:popovertargetattributes"><c- n="">PopoverTargetAttributes</c-></a>;</code></pre>
   </dd></dl>

  <p>The <code id="the-button-element:the-button-element"><a href="#the-button-element">button</a></code> element <a href="#represents" id="the-button-element:represents">represents</a> a button labeled by its contents.</p>

  <p>The element is a <a href="#concept-button" id="the-button-element:concept-button">button</a>.</p>

  <p>The <dfn data-dfn-for="button" id="attr-button-type" data-dfn-type="element-attr"><code>type</code></dfn> attribute
  controls the behavior of the button when it is activated. It is an <a href="#enumerated-attribute" id="the-button-element:enumerated-attribute">enumerated
  attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th> Keyword
     </th><th> State
     </th><th> Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="button/type" id="attr-button-type-submit" data-dfn-type="attr-value"><code>submit</code></dfn>
     </td><td><dfn id="attr-button-type-submit-state">Submit Button</dfn>
     </td><td>Submits the form.
    </td></tr><tr><td><dfn data-dfn-for="button/type" id="attr-button-type-reset" data-dfn-type="attr-value"><code>reset</code></dfn>
     </td><td><dfn id="attr-button-type-reset-state">Reset Button</dfn>
     </td><td>Resets the form.
    </td></tr><tr><td><dfn data-dfn-for="button/type" id="attr-button-type-button" data-dfn-type="attr-value"><code>button</code></dfn>
     </td><td><dfn id="attr-button-type-button-state">Button</dfn>
     </td><td>Does nothing.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-button-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-button-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <dfn id="attr-button-type-auto-state">Auto</dfn> state.</p>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-button-element:the-button-element-2"><a href="#the-button-element">button</a></code> element is said to be a <a href="#concept-submit-button" id="the-button-element:concept-submit-button">submit button</a> if any of the following are true:</p>

  <ul><li><p>the <code id="the-button-element:attr-button-type-2"><a href="#attr-button-type">type</a></code> attribute is in the <a href="#attr-button-type-auto-state" id="the-button-element:attr-button-type-auto-state">Auto</a> state, both the <code id="the-button-element:attr-button-command-2"><a href="#attr-button-command">command</a></code> and <code id="the-button-element:attr-button-commandfor-2"><a href="#attr-button-commandfor">commandfor</a></code> content attributes are not present, and the
   <a id="the-button-element:parent" href="https://dom.spec.whatwg.org/#concept-tree-parent" data-x-internal="parent">parent</a> node is not a <code id="the-button-element:the-select-element-3"><a href="#the-select-element">select</a></code> element;
   or</p></li><li><p>the <code id="the-button-element:attr-button-type-3"><a href="#attr-button-type">type</a></code> attribute is in the <a href="#attr-button-type-submit-state" id="the-button-element:attr-button-type-submit-state">Submit Button</a> state.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the element is not a <a href="#concept-submit-button" id="the-button-element:concept-submit-button-2">submit button</a>, the element is <a href="#barred-from-constraint-validation" id="the-button-element:barred-from-constraint-validation">barred from constraint
  validation</a>.</p>
  </div>

  <p>If specified, the <dfn data-dfn-for="button" id="attr-button-commandfor" data-dfn-type="element-attr"><code>commandfor</code></dfn> attribute value must be the <a href="https://dom.spec.whatwg.org/#concept-id" id="the-button-element:concept-id" data-x-internal="concept-id">ID</a> of an element in the same <a id="the-button-element:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> as the <a href="#concept-button" id="the-button-element:concept-button-2">button</a> with the <code id="the-button-element:attr-button-commandfor-3"><a href="#attr-button-commandfor">commandfor</a></code> attribute.</p>

  <p>The <dfn data-dfn-for="button" id="attr-button-command" data-dfn-type="element-attr"><code>command</code></dfn>
  attribute is an <a href="#enumerated-attribute" id="the-button-element:enumerated-attribute-2">enumerated attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/command" id="attr-button-command-toggle-popover" data-dfn-type="attr-value"><code>toggle-popover</code></dfn>
     </td><td><dfn id="attr-button-command-toggle-popover-state">Toggle Popover</dfn>
     </td><td>Shows or hides the targeted <code id="the-button-element:attr-popover"><a href="#attr-popover">popover</a></code> element.
    </td></tr><tr><td><dfn data-dfn-for="html-global/command" id="attr-button-command-show-popover" data-dfn-type="attr-value"><code>show-popover</code></dfn>
     </td><td><dfn id="attr-button-command-show-popover-state">Show Popover</dfn>
     </td><td>Shows the targeted <code id="the-button-element:attr-popover-2"><a href="#attr-popover">popover</a></code> element.
    </td></tr><tr><td><dfn data-dfn-for="html-global/command" id="attr-button-command-hide-popover" data-dfn-type="attr-value"><code>hide-popover</code></dfn>
     </td><td><dfn id="attr-button-command-hide-popover-state">Hide Popover</dfn>
     </td><td>Hides the targeted <code id="the-button-element:attr-popover-3"><a href="#attr-popover">popover</a></code> element.
    </td></tr><tr><td><dfn data-dfn-for="html-global/command" id="attr-button-command-close" data-dfn-type="attr-value"><code>close</code></dfn>
     </td><td><dfn id="attr-button-command-close-state">Close</dfn>
     </td><td>Closes the targeted <code id="the-button-element:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> element.
    </td></tr><tr><td><dfn data-dfn-for="html-global/command" id="attr-button-command-request-close" data-dfn-type="attr-value"><code>request-close</code></dfn>
     </td><td><dfn id="attr-button-command-request-close-state">Request Close</dfn>
     </td><td>Requests to close the targeted <code id="the-button-element:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code> element.
    </td></tr><tr><td><dfn data-dfn-for="html-global/command" id="attr-button-command-show-modal" data-dfn-type="attr-value"><code>show-modal</code></dfn>
     </td><td><dfn id="attr-button-command-show-modal-state">Show Modal</dfn>
     </td><td>Opens the targeted <code id="the-button-element:the-dialog-element-3"><a href="#the-dialog-element">dialog</a></code> element as modal.
    </td></tr><tr><td>A <a href="#attr-button-command-custom" id="the-button-element:attr-button-command-custom">custom command keyword</a>
     </td><td><dfn id="attr-button-command-custom-state">Custom</dfn>
     </td><td>Only dispatches the <code id="the-button-element:event-command"><a href="#event-command">command</a></code> event on the targeted
     element.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-button-element:missing-value-default-2"><a href="#missing-value-default">missing value default</a></i> and <i id="the-button-element:invalid-value-default-2"><a href="#invalid-value-default">invalid value default</a></i> are both the <dfn id="attr-button-command-unknown-state">Unknown</dfn> state.</p>
  </div>

  <div data-algorithm="">
  <p>A <dfn id="attr-button-command-custom">custom command keyword</dfn> is a string that
  <a id="the-button-element:starts-with" href="https://infra.spec.whatwg.org/#string-starts-with" data-x-internal="starts-with">starts with</a> "<code>--</code>".</p>
  </div>

  <p>If a <code id="the-button-element:the-button-element-3"><a href="#the-button-element">button</a></code> element is the first <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="the-button-element:concept-tree-child" data-x-internal="concept-tree-child">child</a>
  which is an <a id="the-button-element:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element">element</a> of a <code id="the-button-element:the-select-element-4"><a href="#the-select-element">select</a></code> element, then it is
  <a href="#inert" id="the-button-element:inert">inert</a>.</p>

  

  <div data-algorithm="">
  <p>A <code id="the-button-element:the-button-element-4"><a href="#the-button-element">button</a></code> element <var>element</var>'s <a id="the-button-element:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> given
  <var>event</var> is:</p>

  <ol><li><p>If <var>element</var> is <a href="#concept-fe-disabled" id="the-button-element:concept-fe-disabled">disabled</a>, then
   return.</p></li><li><p>If <var>element</var>'s <a id="the-button-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="the-button-element:fully-active">fully active</a>, then
   return.</p></li><li>
    <p>If <var>element</var> has a <a href="#form-owner" id="the-button-element:form-owner">form owner</a>:</p>

    <ol><li><p>If <var>element</var> is a <a href="#concept-submit-button" id="the-button-element:concept-submit-button-3">submit button</a>,
     then <a href="#concept-form-submit" id="the-button-element:concept-form-submit">submit</a> <var>element</var>'s
     <a href="#form-owner" id="the-button-element:form-owner-2">form owner</a> from <var>element</var> with <i id="the-button-element:submit-user-involvement"><a href="#submit-user-involvement">userInvolvement</a></i> set to <var>event</var>'s <a href="#event-uni" id="the-button-element:event-uni">user navigation involvement</a>, and return.</p></li><li><p>If <var>element</var>'s <code id="the-button-element:attr-button-type-4"><a href="#attr-button-type">type</a></code> attribute is in the
     <a href="#attr-button-type-reset-state" id="the-button-element:attr-button-type-reset-state">Reset Button</a> state, then <a href="#concept-form-reset" id="the-button-element:concept-form-reset">reset</a> <var>element</var>'s <a href="#form-owner" id="the-button-element:form-owner-3">form owner</a>, and
     return.</p></li><li><p>If <var>element</var>'s <code id="the-button-element:attr-button-type-5"><a href="#attr-button-type">type</a></code> attribute is in the
     <a href="#attr-button-type-auto-state" id="the-button-element:attr-button-type-auto-state-2">Auto</a> state, then return.</p></li></ol>
   </li><li><p>Let <var>target</var> be the result of running <var>element</var>'s <a href="#attr-associated-element" id="the-button-element:attr-associated-element">get the <code>commandfor</code>-associated
   element</a>.</p></li><li>
    <p>If <var>target</var> is not null:</p>

    <ol><li><p>Let <var>command</var> be <var>element</var>'s <code id="the-button-element:attr-button-command-3"><a href="#attr-button-command">command</a></code> attribute.</p></li><li><p>If <var>command</var> is in the <a href="#attr-button-command-unknown-state" id="the-button-element:attr-button-command-unknown-state">Unknown</a> state, then return.</p></li><li><p>Let <var>isPopover</var> be true if <var>target</var>'s <code id="the-button-element:attr-popover-4"><a href="#attr-popover">popover</a></code> attribute is not in the <a href="#attr-popover-none-state" id="the-button-element:attr-popover-none-state">No Popover</a> state; otherwise false.</p></li><li>
      <p>If <var>isPopover</var> is false and <var>command</var> is not in the <a href="#attr-button-command-custom-state" id="the-button-element:attr-button-command-custom-state">Custom</a> state:</p>

      <ol><li><p><a id="the-button-element:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>target</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="the-button-element:concept-element-namespace" data-x-internal="concept-element-namespace">namespace</a> is the
       <a id="the-button-element:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>.</p></li><li><p>If this standard does not define <a href="#is-valid-command-steps" id="the-button-element:is-valid-command-steps">is valid command steps</a> for
       <var>target</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="the-button-element:concept-element-local-name" data-x-internal="concept-element-local-name">local name</a>, then
       return.</p></li><li><p>Otherwise, if the result of running <var>target</var>'s corresponding <a href="#is-valid-command-steps" id="the-button-element:is-valid-command-steps-2">is valid
       command steps</a> given <var>command</var> is false, then
       return.</p></li></ol>
     </li><li>
      <p>Let <var>continue</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-button-element:concept-event-fire" data-x-internal="concept-event-fire">firing an
      event</a> named <code id="the-button-element:event-command-2"><a href="#event-command">command</a></code> at <var>target</var>, using
      <code id="the-button-element:commandevent"><a href="#commandevent">CommandEvent</a></code>, with its <code id="the-button-element:dom-commandevent-command"><a href="#dom-commandevent-command">command</a></code>
      attribute initialized to <var>command</var>, its <code id="the-button-element:dom-commandevent-source"><a href="#dom-commandevent-source">source</a></code> attribute initialized to <var>element</var>,
      and its <code id="the-button-element:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to
      true.</p>

      <p class="XXX"><a href="https://github.com/whatwg/dom/issues/1328">DOM standard issue
      #1328</a> tracks how to better standardize associated event data in a way which makes sense on
      Events. Currently an event attribute initialized to a value cannot also have a getter, and so
      an internal slot (or map of additional fields) is required to properly specify this.</p>
     </li><li><p>If <var>continue</var> is false, then return.</p></li><li><p>If <var>target</var> is not <a id="the-button-element:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li><p>If <var>command</var> is in the <a href="#attr-button-command-custom-state" id="the-button-element:attr-button-command-custom-state-2">Custom</a> state, then return.</p></li><li>
      <p>If <var>command</var> is in the <a href="#attr-button-command-hide-popover-state" id="the-button-element:attr-button-command-hide-popover-state">Hide Popover</a> state:</p>

      <ol><li><p>If the result of running <a href="#check-popover-validity" id="the-button-element:check-popover-validity">check popover validity</a> given
       <var>target</var>, true, false, and null is true, then run the
       <a href="#hide-popover-algorithm" id="the-button-element:hide-popover-algorithm">hide popover algorithm</a> given <var>target</var>, true, true, false, and
       <var>element</var>.</p></li></ol>
     </li><li>
      <p>Otherwise, if <var>command</var> is in the <a href="#attr-button-command-toggle-popover-state" id="the-button-element:attr-button-command-toggle-popover-state">Toggle Popover</a> state:</p>

      <ol><li><p>If the result of running <a href="#check-popover-validity" id="the-button-element:check-popover-validity-2">check popover validity</a> given
       <var>target</var>, false, false, and null is true, then run the
       <a href="#show-popover" id="the-button-element:show-popover">show popover algorithm</a> given <var>target</var>, false, and
       <a id="the-button-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>Otherwise, if the result of running <a href="#check-popover-validity" id="the-button-element:check-popover-validity-3">check popover validity</a> given
       <var>target</var>, true, false, and null is true, then run the
       <a href="#hide-popover-algorithm" id="the-button-element:hide-popover-algorithm-2">hide popover algorithm</a> given <var>target</var>, true,
       true, false, and <var>element</var>.</p></li></ol>
     </li><li>
      <p>Otherwise, if <var>command</var> is in the <a href="#attr-button-command-show-popover-state" id="the-button-element:attr-button-command-show-popover-state">Show Popover</a> state:</p>

      <ol><li><p>If the result of running <a href="#check-popover-validity" id="the-button-element:check-popover-validity-4">check popover validity</a> given <var>target</var>,
       false, false, and null is true, then run the <a href="#show-popover" id="the-button-element:show-popover-2">show popover algorithm</a> given <var>target</var>, false, and
       <a id="the-button-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li></ol>
     </li><li><p>Otherwise, if this standard defines <a href="#command-steps" id="the-button-element:command-steps">command steps</a> for
     <var>target</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="the-button-element:concept-element-local-name-2" data-x-internal="concept-element-local-name">local name</a>, then run the
     corresponding <a href="#command-steps" id="the-button-element:command-steps-2">command steps</a> given <var>target</var>, <var>element</var>,
     and <var>command</var>.</p></li></ol>
   </li><li><p>Otherwise, run the <a href="#popover-target-attribute-activation-behavior" id="the-button-element:popover-target-attribute-activation-behavior">popover target attribute activation behavior</a> given
   <var>element</var> and <var>event</var>'s <a href="https://dom.spec.whatwg.org/#concept-event-target" id="the-button-element:concept-event-target" data-x-internal="concept-event-target">target</a>.</p></li></ol>
  </div>

  <p>An <a href="#html-elements" id="the-button-element:html-elements">HTML element</a> can have specific
  <dfn id="is-valid-command-steps">is valid command steps</dfn> and <dfn id="command-steps">command steps</dfn> defined for the
  element's <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="the-button-element:concept-element-local-name-3" data-x-internal="concept-element-local-name">local name</a>.</p>

  

  <p>The <code id="the-button-element:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> attribute is used to explicitly associate the
  <code id="the-button-element:the-button-element-5"><a href="#the-button-element">button</a></code> element with its <a href="#form-owner" id="the-button-element:form-owner-4">form owner</a>. The <code id="the-button-element:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attribute represents the element's name. The <code id="the-button-element:attr-fe-disabled-2"><a href="#attr-fe-disabled">disabled</a></code> attribute is used to make the control non-interactive and
  to prevent its value from being submitted. The <code id="the-button-element:attr-fs-formaction-2"><a href="#attr-fs-formaction">formaction</a></code>,
  <code id="the-button-element:attr-fs-formenctype-2"><a href="#attr-fs-formenctype">formenctype</a></code>, <code id="the-button-element:attr-fs-formmethod-2"><a href="#attr-fs-formmethod">formmethod</a></code>, <code id="the-button-element:attr-fs-formnovalidate-2"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>, and <code id="the-button-element:attr-fs-formtarget-2"><a href="#attr-fs-formtarget">formtarget</a></code> attributes are <a href="#attributes-for-form-submission" id="the-button-element:attributes-for-form-submission">attributes for form
  submission</a>.</p>

  <p class="note">The <code id="the-button-element:attr-fs-formnovalidate-3"><a href="#attr-fs-formnovalidate">formnovalidate</a></code> attribute can be
  used to make submit buttons that do not trigger the constraint validation.</p>

  <p>The <code id="the-button-element:attr-fs-formaction-3"><a href="#attr-fs-formaction">formaction</a></code>, <code id="the-button-element:attr-fs-formenctype-3"><a href="#attr-fs-formenctype">formenctype</a></code>, <code id="the-button-element:attr-fs-formmethod-3"><a href="#attr-fs-formmethod">formmethod</a></code>, <code id="the-button-element:attr-fs-formnovalidate-4"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>, and <code id="the-button-element:attr-fs-formtarget-3"><a href="#attr-fs-formtarget">formtarget</a></code> must not be specified if the element is not
  a <a href="#concept-submit-button" id="the-button-element:concept-submit-button-4">submit button</a>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLButtonElement" id="dom-button-command" data-dfn-type="attribute"><code>command</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>command</var> be <a id="the-button-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-button-element:attr-button-command-4"><a href="#attr-button-command">command</a></code> attribute.</p></li><li><p>If <var>command</var> is in the <a href="#attr-button-command-custom-state" id="the-button-element:attr-button-command-custom-state-3">Custom</a> state, then return <var>command</var>'s
   value.</p></li><li><p>If <var>command</var> is in the <a href="#attr-button-command-unknown-state" id="the-button-element:attr-button-command-unknown-state-2">Unknown</a> state, then return the empty
   string.</p></li><li><p>Return the keyword corresponding to the value of <var>command</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="button" id="attr-button-value" data-dfn-type="element-attr"><code>value</code></dfn>
  attribute gives the element's value for the purposes of form submission. The element's <a href="#concept-fe-value" id="the-button-element:concept-fe-value">value</a> is the value of the element's <code id="the-button-element:attr-button-value-2"><a href="#attr-button-value">value</a></code> attribute, if there is one; otherwise the empty string.
  The element's <a href="#concept-fe-optional-value" id="the-button-element:concept-fe-optional-value">optional value</a> is the value of the
  element's <code id="the-button-element:attr-button-value-3"><a href="#attr-button-value">value</a></code> attribute, if there is one; otherwise
  null.</p>
  </div>

  <p class="note">A button (and its value) is only included in the form submission if the button
  itself was used to initiate the form submission.</p>

  <hr>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLButtonElement" id="dom-button-type" data-dfn-type="attribute"><code>type</code></dfn>
  getter steps are:</p>

  <ol><li><p>If <a id="the-button-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is a <a href="#concept-submit-button" id="the-button-element:concept-submit-button-5">submit button</a>, then
   return "<code>submit</code>".</p></li><li><p>Let <var>state</var> be <a id="the-button-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-button-element:attr-button-type-6"><a href="#attr-button-type">type</a></code>
   attribute.</p></li><li><p><a id="the-button-element:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>state</var> is not in the <a href="#attr-button-type-submit-state" id="the-button-element:attr-button-type-submit-state-2">Submit Button</a> state.</p></li><li><p>If <var>state</var> is in the <a href="#attr-button-type-auto-state" id="the-button-element:attr-button-type-auto-state-3">Auto</a>
   state, then return "<code>button</code>".</p></li><li><p>Return the keyword value corresponding to <var>state</var>.</p></li></ol>
  </div>

  <p>The <code id="the-button-element:dom-cva-willvalidate-2"><a href="#dom-cva-willvalidate">willValidate</a></code>, <code id="the-button-element:dom-cva-validity-2"><a href="#dom-cva-validity">validity</a></code>, and <code id="the-button-element:dom-cva-validationmessage-2"><a href="#dom-cva-validationmessage">validationMessage</a></code> IDL attributes, and the <code id="the-button-element:dom-cva-checkvalidity-2"><a href="#dom-cva-checkvalidity">checkValidity()</a></code>, <code id="the-button-element:dom-cva-reportvalidity-2"><a href="#dom-cva-reportvalidity">reportValidity()</a></code>, and <code id="the-button-element:dom-cva-setcustomvalidity-2"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> methods, are part of the
  <a href="#the-constraint-validation-api" id="the-button-element:the-constraint-validation-api">constraint validation API</a>. The <code id="the-button-element:dom-lfe-labels-2"><a href="#dom-lfe-labels">labels</a></code> IDL
  attribute provides a list of the element's <code id="the-button-element:the-label-element"><a href="#the-label-element">label</a></code>s. The <code id="the-button-element:dom-button-disabled"><a href="#dom-button-disabled">disabled</a></code>, <code id="the-button-element:dom-fae-form-2"><a href="#dom-fae-form">form</a></code>, and <code id="the-button-element:dom-button-name"><a href="#dom-button-name">name</a></code> IDL attributes are part of the element's forms API.</p>

  

  <div class="example">

   <p>The following button is labeled "Show hint" and pops up a dialog box when activated:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c->
        <c- e="">onclick</c-><c- o="">=</c-><c- s="">"alert('This 15-20 minute piece was composed by George Gershwin.')"</c-><c- p="">&gt;</c->
 Show hint
<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">
   <p>The following shows how <a href="#concept-button" id="the-button-element:concept-button-3">buttons</a> can use <code id="the-button-element:attr-button-commandfor-4"><a href="#attr-button-commandfor">commandfor</a></code> to show and hide an element with
   the <code id="the-button-element:attr-popover-5"><a href="#attr-popover">popover</a></code> attribute when activated:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c->
        <c- e="">commandfor</c-><c- o="">=</c-><c- s="">"the-popover"</c->
        <c- e="">command</c-><c- o="">=</c-><c- s="">"show-popover"</c-><c- p="">&gt;</c->
 Show menu
<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">popover</c->
     <c- e="">id</c-><c- o="">=</c-><c- s="">"the-popover"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">commandfor</c-><c- o="">=</c-><c- s="">"the-popover"</c->
         <c- e="">command</c-><c- o="">=</c-><c- s="">"hide-popover"</c-><c- p="">&gt;</c->
  Hide menu
 <c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
    </code></pre>
  </div>

  <div class="example">
   <p>The following shows how buttons can use <code id="the-button-element:attr-button-commandfor-5"><a href="#attr-button-commandfor">commandfor</a></code> with a <a href="#attr-button-command-custom" id="the-button-element:attr-button-command-custom-2">custom command keyword</a> on an element, demonstrating
   how one could use custom commands for unspecified behavior:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c->
        <c- e="">commandfor</c-><c- o="">=</c-><c- s="">"the-image"</c->
        <c- e="">command</c-><c- o="">=</c-><c- s="">"--rotate-landscape"</c-><c- p="">&gt;</c->
 Rotate Left
<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c->
        <c- e="">commandfor</c-><c- o="">=</c-><c- s="">"the-image"</c->
        <c- e="">command</c-><c- o="">=</c-><c- s="">"--rotate-portrait"</c-><c- p="">&gt;</c->
 Rotate Right
<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">img</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"the-image"</c->
     <c- e="">src</c-><c- o="">=</c-><c- s="">"photo.jpg"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">const</c-> image <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- u="">"the-image"</c-><c- p="">);</c->
  image<c- p="">.</c->addEventListener<c- p="">(</c-><c- u="">"command"</c-><c- p="">,</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
   <c- k="">if</c-> <c- p="">(</c-> event<c- p="">.</c->command <c- o="">==</c-> <c- u="">"--rotate-landscape"</c-> <c- p="">)</c-> <c- p="">{</c->
    event<c- p="">.</c->target<c- p="">.</c->style<c- p="">.</c->rotate <c- o="">=</c-> <c- u="">"-90deg"</c->
   <c- p="">}</c-> <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c-> event<c- p="">.</c->command <c- o="">==</c-> <c- u="">"--rotate-portrait"</c-> <c- p="">)</c-> <c- p="">{</c->
    event<c- p="">.</c->target<c- p="">.</c->style<c- p="">.</c->rotate <c- o="">=</c-> <c- u="">"0deg"</c->
   <c- p="">}</c->
  <c- p="">});</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
    </code></pre>
  </div>

  <h4 id="the-select-element"><span class="secno">4.10.7</span> The <dfn data-dfn-type="element"><code>select</code></dfn> element<a href="#the-select-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select" title="The <select> HTML element represents a control that provides a menu of options.">Element/select</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>2+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement" title="The HTMLSelectElement interface represents a <select> HTML Element. These elements also share all of the properties and methods of other HTML elements via the HTMLElement interface.">HTMLSelectElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>2+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>1+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-select-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-select-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-select-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#interactive-content-2" id="the-select-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#category-listed" id="the-select-element:category-listed">Listed</a>, <a href="#category-label" id="the-select-element:category-label">labelable</a>, <a href="#category-submit" id="the-select-element:category-submit">submittable</a>, <a href="#category-reset" id="the-select-element:category-reset">resettable</a>, and <a href="#category-autocapitalize" id="the-select-element:category-autocapitalize">autocapitalize-and-autocorrect inheriting</a> <a href="#form-associated-element" id="the-select-element:form-associated-element">form-associated element</a>.</dd><dd><a href="#palpable-content-2" id="the-select-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-select-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-select-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-select-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or one <code id="the-select-element:the-button-element"><a href="#the-button-element">button</a></code> elements if the <code id="the-select-element:the-select-element"><a href="#the-select-element">select</a></code> is a <a href="#drop-down-box" id="the-select-element:drop-down-box">drop-down
   box</a>, followed by zero or more <a href="#select-element-inner-content-elements-2" id="the-select-element:select-element-inner-content-elements-2"><code>select</code> element inner content
   elements</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-select-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-select-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-select-element:global-attributes">Global attributes</a></dd><dd><code id="the-select-element:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code> —  Hint for form autofill feature
     </dd><dd><code id="the-select-element:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code> —  Whether the form control is disabled
     </dd><dd><code id="the-select-element:attr-fae-form"><a href="#attr-fae-form">form</a></code> —  Associates the element with a <code id="the-select-element:the-form-element"><a href="#the-form-element">form</a></code> element
     </dd><dd><code id="the-select-element:attr-select-multiple"><a href="#attr-select-multiple">multiple</a></code> —  Whether to allow multiple values
     </dd><dd><code id="the-select-element:attr-fe-name"><a href="#attr-fe-name">name</a></code> —  Name of the element to use for <a href="#form-submission-2" id="the-select-element:form-submission-2">form submission</a> and in the <code id="the-select-element:dom-form-elements"><a href="#dom-form-elements">form.elements</a></code> API 
     </dd><dd><code id="the-select-element:attr-select-required"><a href="#attr-select-required">required</a></code> —  Whether the control is required for <a href="#form-submission-2" id="the-select-element:form-submission-2-2">form submission</a>
     </dd><dd><code id="the-select-element:attr-select-size"><a href="#attr-select-size">size</a></code> —  Size of the control
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-select-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd>If the element has a <code id="the-select-element:attr-select-multiple-2"><a href="#attr-select-multiple">multiple</a></code> attribute or a <code id="the-select-element:attr-select-size-2"><a href="#attr-select-size">size</a></code> attribute with a value &gt; 1: <a href="https://w3c.github.io/html-aria/#el-select-multiple-or-size-greater-1">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-select-listbox">for implementers</a>.</dd><dd>Otherwise: <a href="https://w3c.github.io/html-aria/#el-select">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-select-combobox">for implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-select-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlselectelement" data-dfn-type="interface"><c- g="">HTMLSelectElement</c-></dfn> : <a href="#htmlelement" id="the-select-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-select-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-select-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-select-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fe-autocomplete" id="the-select-element:dom-fe-autocomplete"><c- g="">autocomplete</c-></a>;
  [<a href="#cereactions" id="the-select-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-select-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLSelectElement" id="dom-select-disabled" data-dfn-type="attribute"><c- g="">disabled</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-select-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-fae-form" id="the-select-element:dom-fae-form"><c- g="">form</c-></a>;
  [<a href="#cereactions" id="the-select-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-select-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLSelectElement" id="dom-select-multiple" data-dfn-type="attribute"><c- g="">multiple</c-></dfn>;
  [<a href="#cereactions" id="the-select-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-select-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLSelectElement" id="dom-select-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="the-select-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-select-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLSelectElement" id="dom-select-required" data-dfn-type="attribute"><c- g="">required</c-></dfn>;
  [<a href="#cereactions" id="the-select-element:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-select-element:xattr-reflect-5"><c- g="">Reflect</c-></a>, <a href="#xattr-reflectdefault" id="the-select-element:xattr-reflectdefault">ReflectDefault=0</a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLSelectElement" id="dom-select-size" data-dfn-type="attribute"><c- g="">size</c-></dfn>;
  

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-select-type" id="the-select-element:dom-select-type"><c- g="">type</c-></a>;

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmloptionscollection" id="the-select-element:htmloptionscollection"><c- n="">HTMLOptionsCollection</c-></a> <a href="#dom-select-options" id="the-select-element:dom-select-options"><c- g="">options</c-></a>;
  [<a href="#cereactions" id="the-select-element:cereactions-7"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-select-length" id="the-select-element:dom-select-length"><c- g="">length</c-></a>;
  <c- b="">getter</c-> <a href="#htmloptionelement" id="the-select-element:htmloptionelement"><c- n="">HTMLOptionElement</c-></a>? <a href="#dom-select-item" id="the-select-element:dom-select-item"><c- g="">item</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <a href="#htmloptionelement" id="the-select-element:htmloptionelement-2"><c- n="">HTMLOptionElement</c-></a>? <a href="#dom-select-nameditem" id="the-select-element:dom-select-nameditem"><c- g="">namedItem</c-></a>(<c- b="">DOMString</c-> <c- g="">name</c->);
  [<a href="#cereactions" id="the-select-element:cereactions-8"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-select-add" id="the-select-element:dom-select-add"><c- g="">add</c-></a>((<a href="#htmloptionelement" id="the-select-element:htmloptionelement-3"><c- n="">HTMLOptionElement</c-></a> <c- b="">or</c-> <a href="#htmloptgroupelement" id="the-select-element:htmloptgroupelement"><c- n="">HTMLOptGroupElement</c-></a>) <c- g="">element</c->, <c- b="">optional</c-> (<a href="#htmlelement" id="the-select-element:htmlelement-2"><c- n="">HTMLElement</c-></a> <c- b="">or</c-> <c- b="">long</c->)? <c- g="">before</c-> = <c- b="">null</c->);
  [<a href="#cereactions" id="the-select-element:cereactions-9"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-select-remove" id="the-select-element:dom-select-remove"><c- g="">remove</c-></a>(); // ChildNode overload
  [<a href="#cereactions" id="the-select-element:cereactions-10"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-select-remove" id="the-select-element:dom-select-remove-2"><c- g="">remove</c-></a>(<c- b="">long</c-> <c- g="">index</c->);
  [<a href="#cereactions" id="the-select-element:cereactions-11"><c- g="">CEReactions</c-></a>] <a href="#dom-select-setter"><c- b="">setter</c-></a> <c- b="">undefined</c-> (<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->, <a href="#htmloptionelement" id="the-select-element:htmloptionelement-4"><c- n="">HTMLOptionElement</c-></a>? <c- g="">option</c->);

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-select-element:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-select-selectedoptions" id="the-select-element:dom-select-selectedoptions"><c- g="">selectedOptions</c-></a>;
  <c- b="">attribute</c-> <c- b="">long</c-> <a href="#dom-select-selectedindex" id="the-select-element:dom-select-selectedindex"><c- g="">selectedIndex</c-></a>;
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-select-value" id="the-select-element:dom-select-value"><c- g="">value</c-></a>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-cva-willvalidate" id="the-select-element:dom-cva-willvalidate"><c- g="">willValidate</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#validitystate" id="the-select-element:validitystate"><c- n="">ValidityState</c-></a> <a href="#dom-cva-validity" id="the-select-element:dom-cva-validity"><c- g="">validity</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-cva-validationmessage" id="the-select-element:dom-cva-validationmessage"><c- g="">validationMessage</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-cva-checkvalidity" id="the-select-element:dom-cva-checkvalidity"><c- g="">checkValidity</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-cva-reportvalidity" id="the-select-element:dom-cva-reportvalidity"><c- g="">reportValidity</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-cva-setcustomvalidity" id="the-select-element:dom-cva-setcustomvalidity"><c- g="">setCustomValidity</c-></a>(<c- b="">DOMString</c-> <c- g="">error</c->);

  <c- b="">undefined</c-> <a href="#dom-select-showpicker" id="the-select-element:dom-select-showpicker"><c- g="">showPicker</c-></a>();

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-select-element:nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist" data-x-internal="nodelist"><c- n="">NodeList</c-></a> <a href="#dom-lfe-labels" id="the-select-element:dom-lfe-labels"><c- g="">labels</c-></a>;
};</code></pre>
   </dd></dl>
  

  <p>The <code id="the-select-element:the-select-element-2"><a href="#the-select-element">select</a></code> element represents a control for selecting amongst a set of
  options.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple" title="The Boolean multiple attribute, if set, means the form control accepts one or more values. Valid for the email and file input types and the <select>, the manner by which the user opts for multiple values depends on the form control.">Attributes/multiple</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="select" id="attr-select-multiple" data-dfn-type="element-attr"><code>multiple</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-select-element:boolean-attribute">boolean attribute</a>. If the attribute is present, then the
  <code id="the-select-element:the-select-element-3"><a href="#the-select-element">select</a></code> element <a href="#represents" id="the-select-element:represents">represents</a> a control for selecting zero or more options
  from the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list">list of options</a>. If the attribute is
  absent, then the <code id="the-select-element:the-select-element-4"><a href="#the-select-element">select</a></code> element <a href="#represents" id="the-select-element:represents-2">represents</a> a control for selecting a
  single option from the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-2">list of options</a>.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size" title="The size attribute defines the width of the <input> and the height of the <select> element. For the input, if the type attribute is text or password then it's the number of characters. This must be an integer value of 0 or higher. If no size is specified, or an invalid value is specified, the input has no size declared, and the form control will be the default width based on the user agent. If CSS targets the element with properties impacting the width, CSS takes precedence.">Attributes/size</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="select" id="attr-select-size" data-dfn-type="element-attr"><code>size</code></dfn> attribute
  gives the number of options to show to the user. The <code id="the-select-element:attr-select-size-3"><a href="#attr-select-size">size</a></code>
  attribute, if specified, must have a value that is a <a href="#valid-non-negative-integer" id="the-select-element:valid-non-negative-integer">valid non-negative integer</a>
  greater than zero.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required" title="The Boolean required attribute, if present, indicates that the user must specify a value for the input before the owning form can be submitted.">Attributes/required</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="select" id="attr-select-required" data-dfn-type="element-attr"><code>required</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-select-element:boolean-attribute-2">boolean attribute</a>. When specified, the user will be required to select
  a value before submitting the form.</p>

  <p>The <code id="the-select-element:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> attribute is used to explicitly associate the
  <code id="the-select-element:the-select-element-5"><a href="#the-select-element">select</a></code> element with its <a href="#form-owner" id="the-select-element:form-owner">form owner</a>. The <code id="the-select-element:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attribute represents the element's name. The <code id="the-select-element:attr-fe-disabled-2"><a href="#attr-fe-disabled">disabled</a></code> attribute is used to make the control non-interactive
  and to prevent its value from being submitted. The <code id="the-select-element:attr-fe-autocomplete-2"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute controls how the user agent provides
  autofill behavior.</p>

  <div data-algorithm="">
  <p>If a <code id="the-select-element:the-select-element-6"><a href="#the-select-element">select</a></code> element has a <code id="the-select-element:attr-select-required-2"><a href="#attr-select-required">required</a></code>
  attribute specified, does not have a <code id="the-select-element:attr-select-multiple-3"><a href="#attr-select-multiple">multiple</a></code> attribute
  specified, and has a <a href="#concept-select-size" id="the-select-element:concept-select-size">display size</a> of 1; and if the <a href="#concept-option-value" id="the-select-element:concept-option-value">value</a> of the first <code id="the-select-element:the-option-element"><a href="#the-option-element">option</a></code> element in the
  <code id="the-select-element:the-select-element-7"><a href="#the-select-element">select</a></code> element's <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-3">list of options</a> (if
  any) is the empty string, and that <code id="the-select-element:the-option-element-2"><a href="#the-option-element">option</a></code> element's parent node is the
  <code id="the-select-element:the-select-element-8"><a href="#the-select-element">select</a></code> element (and not an <code id="the-select-element:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element), then that
  <code id="the-select-element:the-option-element-3"><a href="#the-option-element">option</a></code> is the <code id="the-select-element:the-select-element-9"><a href="#the-select-element">select</a></code> element's <dfn id="placeholder-label-option">placeholder label option</dfn>.</p>
  </div>

  <div data-algorithm="">
  <p>If a <code id="the-select-element:the-select-element-10"><a href="#the-select-element">select</a></code> element has a <code id="the-select-element:attr-select-required-3"><a href="#attr-select-required">required</a></code>
  attribute specified, does not have a <code id="the-select-element:attr-select-multiple-4"><a href="#attr-select-multiple">multiple</a></code> attribute
  specified, and has a <a href="#concept-select-size" id="the-select-element:concept-select-size-2">display size</a> of 1, then the
  <code id="the-select-element:the-select-element-11"><a href="#the-select-element">select</a></code> element must have a <a href="#placeholder-label-option" id="the-select-element:placeholder-label-option">placeholder label option</a>.</p>
  </div>

  <p class="note">In practice, the requirement stated in the paragraph above can only apply when a
  <code id="the-select-element:the-select-element-12"><a href="#the-select-element">select</a></code> element does not have a <code id="the-select-element:attr-select-size-4"><a href="#attr-select-size">size</a></code> attribute
  with a value greater than 1.</p>

  

  <hr>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the element has its <code id="the-select-element:attr-select-required-4"><a href="#attr-select-required">required</a></code> attribute specified, and either none of the
  <code id="the-select-element:the-option-element-4"><a href="#the-option-element">option</a></code> elements in the <code id="the-select-element:the-select-element-13"><a href="#the-select-element">select</a></code> element's <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-4">list of options</a> have their <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness">selectedness</a> set to true, or the only
  <code id="the-select-element:the-option-element-5"><a href="#the-option-element">option</a></code> element in the <code id="the-select-element:the-select-element-14"><a href="#the-select-element">select</a></code> element's <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-5">list of options</a> with its <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-2">selectedness</a> set to true is the <a href="#placeholder-label-option" id="the-select-element:placeholder-label-option-2">placeholder label
  option</a>, then the element is <a href="#suffering-from-being-missing" id="the-select-element:suffering-from-being-missing">suffering from being missing</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#concept-form-reset-control" id="the-select-element:concept-form-reset-control">reset algorithm</a> for a <code id="the-select-element:the-select-element-15"><a href="#the-select-element">select</a></code>
  element <var>selectElement</var> is:</p>

  <ol><li><p>Set <var>selectElement</var>'s <a href="#user-validity" id="the-select-element:user-validity">user validity</a> to false.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-select-element:list-iterate" data-x-internal="list-iterate">For each</a> <var>optionElement</var> of
    <var>selectElement</var>'s <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-6">list of
    options</a>:</p>

    <ol><li><p>If <var>optionElement</var> has a <code id="the-select-element:attr-option-selected"><a href="#attr-option-selected">selected</a></code>
     attribute, then set <var>optionElement</var>'s <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-3">selectedness</a> to true; otherwise set it to
     false.</p></li><li><p>Set <var>optionElement</var>'s <a href="#concept-option-dirtiness" id="the-select-element:concept-option-dirtiness">dirtiness</a>
     to false.</p></li></ol>
   </li><li><p>Run the <a href="#selectedness-setting-algorithm" id="the-select-element:selectedness-setting-algorithm">selectedness setting algorithm</a> given
   <var>selectElement</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-select-element:the-select-element-16"><a href="#the-select-element">select</a></code> element that is not <a href="#concept-fe-disabled" id="the-select-element:concept-fe-disabled">disabled</a> is
  <i id="the-select-element:concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The user agent should allow the user to pick an <code id="the-select-element:the-option-element-6"><a href="#the-option-element">option</a></code> element from a
  <code id="the-select-element:the-select-element-17"><a href="#the-select-element">select</a></code> element in its <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-7">list of
  options</a> (either through a click, or through unfocusing the element after changing its
  value, or through a <a href="#using-the-option-element-to-define-a-command" id="the-select-element:using-the-option-element-to-define-a-command">menu command</a>, or through any other
  mechanism) by running the <a href="#concept-select-pick" id="the-select-element:concept-select-pick">pick an option</a> algorithm given
  the <code id="the-select-element:the-select-element-18"><a href="#the-select-element">select</a></code> element, the <code id="the-select-element:the-option-element-7"><a href="#the-option-element">option</a></code> element, and if <code id="the-select-element:the-select-element-19"><a href="#the-select-element">select</a></code> and
  its <a href="#select-popover" id="the-select-element:select-popover">select popover</a> are both being rendered with <a id="the-select-element:base-appearance" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base appearance</a>, a
  corresponding <code id="the-select-element:event-keydown"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code> or <code id="the-select-element:event-mouseup"><a data-x-internal="event-mouseup" href="https://w3c.github.io/uievents/#event-type-mouseup">mouseup</a></code> event, otherwise null.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="concept-select-pick">pick an option</dfn> given a <code id="the-select-element:the-select-element-20"><a href="#the-select-element">select</a></code> element
  <var>select</var>, an <code id="the-select-element:the-option-element-8"><a href="#the-option-element">option</a></code> element <var>option</var>, and an <code id="the-select-element:event"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code> or
  null <var>event</var>:</p>

  <ol><li><p>If <var>select</var> has the <code id="the-select-element:attr-select-multiple-5"><a href="#attr-select-multiple">multiple</a></code> attribute
   or <var>select</var> is <a href="#concept-fe-disabled" id="the-select-element:concept-fe-disabled-2">disabled</a>, then return.</p></li><li><p>If <var>event</var> is not null and <var>event</var>'s <a id="the-select-element:canceled-flag" href="https://dom.spec.whatwg.org/#canceled-flag" data-x-internal="canceled-flag">canceled flag</a> is set,
   then return.</p></li><li><p>If <var>event</var> is a <code id="the-select-element:mouseevent"><a data-x-internal="mouseevent" href="https://w3c.github.io/uievents/#mouseevent">MouseEvent</a></code> and <var>event</var>'s <code id="the-select-element:dom-mouseevent-button"><a data-x-internal="dom-mouseevent-button" href="https://w3c.github.io/uievents/#dom-mouseevent-button">button</a></code> attribute is not 1, then return.</p></li><li><p>Set <var>option</var>'s <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-4">selectedness</a> to
   true.</p></li><li><p>Set <var>option</var>'s <a href="#concept-option-dirtiness" id="the-select-element:concept-option-dirtiness-2">dirtiness</a> to
   true.</p></li><li><p><a href="#send-select-update-notifications" id="the-select-element:send-select-update-notifications">Send <code>select</code> update notifications</a> given
   <var>select</var>.</p></li><li><p>If <var>select</var> is being rendered as a <a href="#drop-down-box" id="the-select-element:drop-down-box-2">drop-down box</a> with <a id="the-select-element:base-appearance-2" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base
   appearance</a>, then run the <a href="#hide-popover-algorithm" id="the-select-element:hide-popover-algorithm">hide popover algorithm</a> given <var>select</var>'s
   <a href="#select-popover" id="the-select-element:select-popover-2">select popover</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>If the <code id="the-select-element:attr-select-multiple-6"><a href="#attr-select-multiple">multiple</a></code> attribute is absent, whenever an
  <code id="the-select-element:the-option-element-9"><a href="#the-option-element">option</a></code> element in the <code id="the-select-element:the-select-element-21"><a href="#the-select-element">select</a></code> element's <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-8">list of options</a> has its <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-5">selectedness</a> set to true, and whenever an
  <code id="the-select-element:the-option-element-10"><a href="#the-option-element">option</a></code> element with its <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-6">selectedness</a> set to true is added to the
  <code id="the-select-element:the-select-element-22"><a href="#the-select-element">select</a></code> element's <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-9">list of options</a>,
  the user agent must set the <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-7">selectedness</a> of all
  the other <code id="the-select-element:the-option-element-11"><a href="#the-option-element">option</a></code> elements in its <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-10">list of
  options</a> to false.</p>
  </div>

  <div data-algorithm="">
  <p>If the <code id="the-select-element:attr-select-multiple-7"><a href="#attr-select-multiple">multiple</a></code> attribute is absent and the
  element's <a href="#concept-select-size" id="the-select-element:concept-select-size-3">display size</a> is greater than 1, then the user
  agent should also allow the user to request that the <code id="the-select-element:the-option-element-12"><a href="#the-option-element">option</a></code> whose <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-8">selectedness</a> is true, if any, be unselected. Upon this
  request being conveyed to the user agent, and before the relevant user interaction event  is queued (e.g. before the <code id="the-select-element:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event), the user agent must set the <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-9">selectedness</a> of that <code id="the-select-element:the-option-element-13"><a href="#the-option-element">option</a></code> element to
  false, set its <a href="#concept-option-dirtiness" id="the-select-element:concept-option-dirtiness-3">dirtiness</a> to true, and then
  <a href="#send-select-update-notifications" id="the-select-element:send-select-update-notifications-2">send <code>select</code> update notifications</a>.</p>
  </div>

  <div data-algorithm="">
  <p>If the <code id="the-select-element:the-select-element-23"><a href="#the-select-element">select</a></code> is being rendered as a <a href="#drop-down-box" id="the-select-element:drop-down-box-3">drop-down box</a> with <a id="the-select-element:base-appearance-3" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base
  appearance</a>, then the user agent should allow the user to <dfn id="select-open-picker">open the picker</dfn> given a corresponding <code id="the-select-element:the-select-element-24"><a href="#the-select-element">select</a></code>
  element <var>select</var> and a corresponding <code id="the-select-element:event-mousedown"><a data-x-internal="event-mousedown" href="https://w3c.github.io/uievents/#event-type-mousedown">mousedown</a></code> or
  <code id="the-select-element:event-keydown-2"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code> event <var>event</var>:

  </p><ol><li><p>If <var>event</var>'s <a id="the-select-element:canceled-flag-2" href="https://dom.spec.whatwg.org/#canceled-flag" data-x-internal="canceled-flag">canceled flag</a> is set, then return.</p></li><li><p>If <var>event</var>'s <code id="the-select-element:dom-mouseevent-button-2"><a data-x-internal="dom-mouseevent-button" href="https://w3c.github.io/uievents/#dom-mouseevent-button">button</a></code> attribute is not
   1, then return.</p></li><li><p>Run the <a href="#show-popover" id="the-select-element:show-popover">show popover</a> algorithm given <var>select</var>'s <a href="#select-popover" id="the-select-element:select-popover-3">select
   popover</a>, false, and <var>select</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>If the <code id="the-select-element:the-select-element-25"><a href="#the-select-element">select</a></code> is being rendered as a <a href="#drop-down-box" id="the-select-element:drop-down-box-4">drop-down box</a> with <a id="the-select-element:base-appearance-4" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base
  appearance</a>, then the user agent should allow the user to <dfn id="focus-another-option">focus another option</dfn>
  given the new <code id="the-select-element:the-option-element-14"><a href="#the-option-element">option</a></code> element to focus <var>option</var> and a <code id="the-select-element:event-keydown-3"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code> event <var>event</var>:</p>

  <ol><li><p>If <var>event</var>'s <a id="the-select-element:canceled-flag-3" href="https://dom.spec.whatwg.org/#canceled-flag" data-x-internal="canceled-flag">canceled flag</a> is set, then return.</p></li><li><p>Run the <a href="#focusing-steps" id="the-select-element:focusing-steps">focusing steps</a> on <var>option</var>.</p></li></ol>
  </div>

  <p class="note">Implementations commonly allow the user to focus the next or previous option via
  the arrow-up and arrow-down keys, focus the first or last option via the Home or End keys, or
  focus the first or last option in the viewport of the picker via the PageUp or PageDown keys.</p>

  <p class="note">Which particular keys of the keyboard cause these actions might differ across
  implementations and platforms. The ARIA Authoring Practices Guide has good <a href="https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/">recommendations</a>
  for this behavior.</p>

  <p>If the <code id="the-select-element:attr-select-multiple-8"><a href="#attr-select-multiple">multiple</a></code> attribute is present, and the
  element is not <a href="#concept-fe-disabled" id="the-select-element:concept-fe-disabled-3">disabled</a>, then the user agent should
  allow the user to <dfn id="concept-select-toggle">toggle</dfn> the <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-10">selectedness</a> of the <code id="the-select-element:the-option-element-15"><a href="#the-option-element">option</a></code> elements in
  its <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-11">list of options</a> that are themselves not <a href="#concept-option-disabled" id="the-select-element:concept-option-disabled">disabled</a>. Upon such an element being <a href="#concept-select-toggle" id="the-select-element:concept-select-toggle">toggled</a> (either through a click, or through a <a href="#using-the-option-element-to-define-a-command" id="the-select-element:using-the-option-element-to-define-a-command-2">menu command</a>, or any other mechanism), and before the relevant user
  interaction event  is queued (e.g. before a related <code id="the-select-element:event-click-2"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event), the <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-11">selectedness</a> of the <code id="the-select-element:the-option-element-16"><a href="#the-option-element">option</a></code> element must
  be changed (from true to false or false to true), the <a href="#concept-option-dirtiness" id="the-select-element:concept-option-dirtiness-4">dirtiness</a> of the element must be set to true, and the
  user agent must <a href="#send-select-update-notifications" id="the-select-element:send-select-update-notifications-3">send <code>select</code> update notifications</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="concept-select-size">display size</dfn> of a <code id="the-select-element:the-select-element-26"><a href="#the-select-element">select</a></code> element is the
  result of applying the <a href="#rules-for-parsing-non-negative-integers" id="the-select-element:rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a> to the value of the
  element's <code id="the-select-element:attr-select-size-5"><a href="#attr-select-size">size</a></code> attribute, if it has one and parsing it is
  successful. If applying those rules to the attribute's value is not successful, or if the <code id="the-select-element:attr-select-size-6"><a href="#attr-select-size">size</a></code> attribute is absent, then the element's <a href="#concept-select-size" id="the-select-element:concept-select-size-4">display size</a> is 4 if the element's <code id="the-select-element:attr-select-multiple-9"><a href="#attr-select-multiple">multiple</a></code> content attribute is present, and 1 otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>To get the <dfn id="concept-select-option-list">list of options</dfn> given a
  <code id="the-select-element:the-select-element-27"><a href="#the-select-element">select</a></code> element <var>select</var>:</p>

  <ol><li><p>Let <var>options</var> be « ».</p></li><li><p>Let <var>node</var> be the <a id="the-select-element:first-child" href="https://dom.spec.whatwg.org/#concept-tree-first-child" data-x-internal="first-child">first child</a> of <var>select</var> in <a id="the-select-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
   order</a>.</p></li><li>
    <p><a id="the-select-element:while" href="https://infra.spec.whatwg.org/#iteration-while" data-x-internal="while">While</a> <var>node</var> is not null:</p>

    <ol><li><p>If <var>node</var> is an <code id="the-select-element:the-option-element-17"><a href="#the-option-element">option</a></code> element, then <a href="https://infra.spec.whatwg.org/#list-append" id="the-select-element:list-append" data-x-internal="list-append">append</a> <var>node</var> to <var>options</var>.</p></li><li>
      <p>If any of the following conditions are true:</p>

      <ul><li><p><var>node</var> is a <code id="the-select-element:the-select-element-28"><a href="#the-select-element">select</a></code> element;</p></li><li><p><var>node</var> is an <code id="the-select-element:the-hr-element"><a href="#the-hr-element">hr</a></code> element;</p></li><li><p><var>node</var> is an <code id="the-select-element:the-option-element-18"><a href="#the-option-element">option</a></code> element;</p></li><li><p><var>node</var> is a <code id="the-select-element:the-datalist-element"><a href="#the-datalist-element">datalist</a></code> element;</p></li><li><p><var>node</var> is an <code id="the-select-element:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> element and <var>node</var> has an
       <a id="the-select-element:ancestor" href="https://dom.spec.whatwg.org/#concept-tree-ancestor" data-x-internal="ancestor">ancestor</a> <code id="the-select-element:the-optgroup-element-3"><a href="#the-optgroup-element">optgroup</a></code> in between itself and <var>select</var>,</p></li></ul>

      <p>then set <var>node</var> to the next <a id="the-select-element:descendant" href="https://dom.spec.whatwg.org/#concept-tree-descendant" data-x-internal="descendant">descendant</a> of <var>select</var> in
      <a id="the-select-element:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, excluding <var>node</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="the-select-element:descendant-2" data-x-internal="descendant">descendants</a>, if any such node exists; otherwise null.</p>

      <p>Otherwise, set <var>node</var> to the next <a id="the-select-element:descendant-3" href="https://dom.spec.whatwg.org/#concept-tree-descendant" data-x-internal="descendant">descendant</a> of <var>select</var> in
      <a id="the-select-element:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, if any such node exists; otherwise null.</p>
     </li></ol>
   </li><li><p>Return <var>options</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>If an <code id="the-select-element:the-option-element-19"><a href="#the-option-element">option</a></code> element in the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-12">list of
  options</a> <dfn id="ask-for-a-reset">asks for a reset</dfn>, then run that
  <code id="the-select-element:the-select-element-29"><a href="#the-select-element">select</a></code> element's <a href="#selectedness-setting-algorithm" id="the-select-element:selectedness-setting-algorithm-2">selectedness setting algorithm</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="selectedness-setting-algorithm">selectedness setting algorithm</dfn>, given a <code id="the-select-element:the-select-element-30"><a href="#the-select-element">select</a></code> element
  <var>element</var>, is to run the following steps:</p>

  <ol><li><p>If <var>element</var>'s <code id="the-select-element:attr-select-multiple-10"><a href="#attr-select-multiple">multiple</a></code> attribute is
   absent, and <var>element</var>'s <a href="#concept-select-size" id="the-select-element:concept-select-size-5">display size</a> is 1,
   and no <code id="the-select-element:the-option-element-20"><a href="#the-option-element">option</a></code> elements in the <var>element</var>'s <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-13">list of options</a> have their <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-12">selectedness</a> set to true, then set the <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-13">selectedness</a> of the first <code id="the-select-element:the-option-element-21"><a href="#the-option-element">option</a></code>
   element in the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-14">list of options</a> in
   <a id="the-select-element:tree-order-4" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> that is not <a href="#concept-option-disabled" id="the-select-element:concept-option-disabled-2">disabled</a>,
   if any, to true, and return.</p></li><li><p>If <var>element</var>'s <code id="the-select-element:attr-select-multiple-11"><a href="#attr-select-multiple">multiple</a></code> attribute is
   absent, and two or more <code id="the-select-element:the-option-element-22"><a href="#the-option-element">option</a></code> elements in <var>element</var>'s <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-15">list of options</a> have their <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-14">selectedness</a> set to true, then set the <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-15">selectedness</a> of all but the last <code id="the-select-element:the-option-element-23"><a href="#the-option-element">option</a></code>
   element with its <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-16">selectedness</a> set to true in
   the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-16">list of options</a> in <a id="the-select-element:tree-order-5" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>
   to false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="send-select-update-notifications">send <code>select</code> update notifications</dfn> for a <code id="the-select-element:the-select-element-31"><a href="#the-select-element">select</a></code> element
  <var>element</var>, <a href="#queue-an-element-task" id="the-select-element:queue-an-element-task">queue an element task</a> on the <a href="#user-interaction-task-source" id="the-select-element:user-interaction-task-source">user interaction task
  source</a> given <var>element</var> to run these steps:</p>

  <ol><li>Set <var>element</var>'s <a href="#user-validity" id="the-select-element:user-validity-2">user validity</a> to true.</li><li><p>Run <a href="#update-a-select's-selectedcontent" id="the-select-element:update-a-select's-selectedcontent">update a <code>select</code>'s <code>selectedcontent</code></a> given
   <var>element</var>.</p></li><li><p>Run <a href="#clone-selected-option-into-select-button" id="the-select-element:clone-selected-option-into-select-button">clone selected <code>option</code> into <code>select</code> button</a> given
   <var>element</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-select-element:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-select-element:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at <var>element</var>, with the <code id="the-select-element:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="the-select-element:dom-event-composed"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code>
   attributes initialized to true.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-select-element:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-select-element:event-change"><a href="#event-change">change</a></code> at <var>element</var>, with the <code id="the-select-element:dom-event-bubbles-2"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to true.</p></li></ol>
  </div>

  

  <hr>

  <dl class="domintro"><dt><code><var>select</var>.<a href="#dom-select-type" id="dom-select-type-dev">type</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/type" title="The HTMLSelectElement.type read-only property returns the form control's type.">HTMLSelectElement/type</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>2+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>1+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns "<code>select-multiple</code>" if the element has a <code id="the-select-element:attr-select-multiple-12"><a href="#attr-select-multiple">multiple</a></code> attribute, and "<code>select-one</code>"
    otherwise.</p>
   </dd><dt><code><var>select</var>.<a href="#dom-select-options" id="dom-select-options-dev">options</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/options" title="The HTMLSelectElement.options read-only property returns a HTMLOptionsCollection of the <option> elements contained by the <select> element.">HTMLSelectElement/options</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns an <code id="the-select-element:htmloptionscollection-2"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> of the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-17">list of options</a>.</p></dd><dt><code><var>select</var>.<a href="#dom-select-length" id="dom-select-length-dev">length</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the number of elements in the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-18">list of
    options</a>.</p>

    <p>When set to a smaller number, truncates the number of <code id="the-select-element:the-option-element-24"><a href="#the-option-element">option</a></code> elements in the
    <code id="the-select-element:the-select-element-32"><a href="#the-select-element">select</a></code>.</p>

    <p>When set to a greater number, adds new blank <code id="the-select-element:the-option-element-25"><a href="#the-option-element">option</a></code> elements to the
    <code id="the-select-element:the-select-element-33"><a href="#the-select-element">select</a></code>.</p>
   </dd><dt><code><var>element</var> = <var>select</var>.<a href="#dom-select-item" id="dom-select-item-dev">item</a>(<var>index</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/item" title="The HTMLSelectElement.item() method returns the Element corresponding to the HTMLOptionElement whose position in the options list corresponds to the index given in the parameter, or null if there are none.">HTMLSelectElement/item</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>select</var>[<var>index</var>]</code></dt><dd>
    <p>Returns the item with index <var>index</var> from the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-19">list of options</a>. The items are sorted in <a id="the-select-element:tree-order-6" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
    order</a>.</p>
   </dd><dt><code><var>element</var> = <var>select</var>.<a href="#dom-select-nameditem" id="dom-select-nameditem-dev">namedItem</a>(<var>name</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/namedItem" title="The HTMLSelectElement.namedItem() method returns the HTMLOptionElement corresponding to the HTMLOptionElement whose name or id match the specified name, or null if no option matches.">HTMLSelectElement/namedItem</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the first item with <a href="https://dom.spec.whatwg.org/#concept-id" id="the-select-element:concept-id" data-x-internal="concept-id">ID</a> or <code id="the-select-element:attr-option-name"><a href="#attr-option-name">name</a></code> <var>name</var> from the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-20">list of options</a>.</p>

    <p>Returns null if no element with that <a href="https://dom.spec.whatwg.org/#concept-id" id="the-select-element:concept-id-2" data-x-internal="concept-id">ID</a> could be found.</p>
   </dd><dt><code><var>select</var>.<a href="#dom-select-add" id="dom-select-add-dev">add</a>(<var>element</var> [, <var>before</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/add" title="The HTMLSelectElement.add() method adds an element to the collection of option elements for this select element.">HTMLSelectElement/add</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Inserts <var>element</var> before the node given by <var>before</var>.</p>

    <p>The <var>before</var> argument can be a number, in which case <var>element</var> is inserted
    before the item with that number, or an element from the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-21">list of options</a>, in which case <var>element</var> is
    inserted before that element.</p>

    <p>If <var>before</var> is omitted, null, or a number out of range, then <var>element</var> will
    be added at the end of the list.</p>

    <p>This method will throw a <a id="the-select-element:hierarchyrequesterror" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a>
    <code id="the-select-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if <var>element</var> is an ancestor of the element into which it is
    to be inserted.</p>
   </dd><dt><code><var>select</var>.<a href="#dom-select-selectedoptions" id="dom-select-selectedoptions-dev">selectedOptions</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/selectedOptions" title="The read-only HTMLSelectElement property selectedOptions contains a list of the <option> elements contained within the <select> element that are currently selected. The list of selected options is an HTMLCollection object with one entry per currently selected option.">HTMLSelectElement/selectedOptions</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>26+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>19+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="the-select-element:htmlcollection-2"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-22">list
    of options</a> that are selected.</p>
   </dd><dt><code><var>select</var>.<a href="#dom-select-selectedindex" id="dom-select-selectedindex-dev">selectedIndex</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/selectedIndex" title="The HTMLSelectElement.selectedIndex property is a long that reflects the index of the first or last selected <option> element, depending on the value of multiple. The value -1 indicates that no element is selected.">HTMLSelectElement/selectedIndex</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the index of the first selected item, if any, or −1 if there is no selected
    item.</p>

    <p>Can be set, to change the selection.</p>
   </dd><dt><code><var>select</var>.<a href="#dom-select-value" id="dom-select-value-dev">value</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the <a href="#concept-option-value" id="the-select-element:concept-option-value-2">value</a> of the first selected item, if
    any, or the empty string if there is no selected item.</p>

    <p>Can be set, to change the selection.</p>
   </dd><dt><code><var>select</var>.<a href="#dom-select-showpicker" id="dom-select-showpicker-dev">showPicker</a>()</code></dt><dd>
    <p>Shows any applicable picker UI for <var>select</var>, so that the user can select a value.

    </p><p>Throws an <a id="the-select-element:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-select-element:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    <var>select</var> is not <a href="#concept-fe-mutable" id="the-select-element:concept-fe-mutable-2">mutable</a>.</p>

    <p>Throws a <a id="the-select-element:notallowederror" href="https://webidl.spec.whatwg.org/#notallowederror" data-x-internal="notallowederror">"<code>NotAllowedError</code>"</a> <code id="the-select-element:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if called
    without <a href="#transient-activation" id="the-select-element:transient-activation">transient user activation</a>.</p>

    <p>Throws a <a id="the-select-element:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-select-element:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    <var>select</var> is inside a cross-origin <code id="the-select-element:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>.</p>

    <p>Throws a <a id="the-select-element:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="the-select-element:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    <var>select</var> is not <a href="#being-rendered" id="the-select-element:being-rendered">being rendered</a>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSelectElement" id="dom-select-type" data-dfn-type="attribute"><code>type</code></dfn> IDL
  attribute, on getting, must return the string "<code>select-one</code>" if the <code id="the-select-element:attr-select-multiple-13"><a href="#attr-select-multiple">multiple</a></code> attribute is absent, and the string "<code>select-multiple</code>" if the <code id="the-select-element:attr-select-multiple-14"><a href="#attr-select-multiple">multiple</a></code>
  attribute is present.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSelectElement" id="dom-select-options" data-dfn-type="attribute"><code>options</code></dfn> IDL attribute must return an
  <code id="the-select-element:htmloptionscollection-3"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> rooted at the <code id="the-select-element:the-select-element-34"><a href="#the-select-element">select</a></code> node, whose filter matches
  the elements in the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-23">list of options</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-select-element:dom-select-options-2"><a href="#dom-select-options">options</a></code> collection is also mirrored on the
  <code id="the-select-element:htmlselectelement"><a href="#htmlselectelement">HTMLSelectElement</a></code> object. The <a id="the-select-element:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> at any instant
  are the indices supported by the object returned by the <code id="the-select-element:dom-select-options-3"><a href="#dom-select-options">options</a></code> attribute at that instant.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSelectElement" id="dom-select-length" data-dfn-type="attribute"><code>length</code></dfn>
  IDL attribute must return the number of nodes <a href="https://dom.spec.whatwg.org/#represented-by-the-collection" id="the-select-element:represented-by-the-collection" data-x-internal="represented-by-the-collection">represented</a> by the <code id="the-select-element:dom-select-options-4"><a href="#dom-select-options">options</a></code> collection.
  On setting, it must act like the attribute of the same name on the <code id="the-select-element:dom-select-options-5"><a href="#dom-select-options">options</a></code> collection.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSelectElement" id="dom-select-item" data-dfn-type="method"><code>item(<var>index</var>)</code></dfn> method must return the value returned
  by <a href="https://dom.spec.whatwg.org/#dom-htmlcollection-item" id="the-select-element:dom-htmlcollection-item" data-x-internal="dom-htmlcollection-item">the method of the same name</a> on the <code id="the-select-element:dom-select-options-6"><a href="#dom-select-options">options</a></code> collection, when invoked with the same argument.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSelectElement" id="dom-select-nameditem" data-dfn-type="method"><code>namedItem(<var>name</var>)</code></dfn> method must return the value
  returned by <a href="https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem" id="the-select-element:dom-htmlcollection-nameditem" data-x-internal="dom-htmlcollection-nameditem">the method of the same name</a> on the
  <code id="the-select-element:dom-select-options-7"><a href="#dom-select-options">options</a></code> collection, when invoked with the same
  argument.</p>
  </div>

  <div data-algorithm="">
  <p id="dom-select-setter">When the user agent is to <a id="the-select-element:set-the-value-of-a-new-indexed-property" href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-a-new-indexed-property" data-x-internal="set-the-value-of-a-new-indexed-property">set the value of a new indexed
  property</a> or <a id="the-select-element:set-the-value-of-an-existing-indexed-property" href="https://webidl.spec.whatwg.org/#dfn-set-the-value-of-an-existing-indexed-property" data-x-internal="set-the-value-of-an-existing-indexed-property">set the value of an existing indexed property</a> for a
  <code id="the-select-element:the-select-element-35"><a href="#the-select-element">select</a></code> element, it must instead run <a href="#dom-htmloptionscollection-setter">the
  corresponding algorithm</a> on the <code id="the-select-element:the-select-element-36"><a href="#the-select-element">select</a></code> element's <code id="the-select-element:dom-select-options-8"><a href="#dom-select-options">options</a></code> collection.</p>
  </div>

  <div data-algorithm="">
  <p>Similarly, the <dfn data-dfn-for="HTMLSelectElement" id="dom-select-add" data-dfn-type="method"><code>add(<var>element</var>, <var>before</var>)</code></dfn> method must act
  like its namesake method on that same <code id="the-select-element:dom-select-options-9"><a href="#dom-select-options">options</a></code>
  collection.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/remove" title="The HTMLSelectElement.remove() method removes the element at the specified index from the options collection for this select element.">HTMLSelectElement/remove</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSelectElement" id="dom-select-remove" data-dfn-type="method"><code>remove()</code></dfn>
  method must act like its namesake method on that same <code id="the-select-element:dom-select-options-10"><a href="#dom-select-options">options</a></code> collection when it has arguments, and like its namesake
  method on the <code id="the-select-element:childnode"><a data-x-internal="childnode" href="https://dom.spec.whatwg.org/#interface-childnode">ChildNode</a></code> interface implemented by the <code id="the-select-element:htmlselectelement-2"><a href="#htmlselectelement">HTMLSelectElement</a></code>
  ancestor interface <code id="the-select-element:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> when it has no arguments.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSelectElement" id="dom-select-selectedoptions" data-dfn-type="attribute"><code>selectedOptions</code></dfn> IDL attribute must return an
  <code id="the-select-element:htmlcollection-3"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="the-select-element:the-select-element-37"><a href="#the-select-element">select</a></code> node, whose filter matches the
  elements in the <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-24">list of options</a> that have their
  <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-17">selectedness</a> set to true.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSelectElement" id="dom-select-selectedindex" data-dfn-type="attribute"><code>selectedIndex</code></dfn> getter steps are to return the <a href="#concept-option-index" id="the-select-element:concept-option-index">index</a> of the first <code id="the-select-element:the-option-element-26"><a href="#the-option-element">option</a></code> element in
  <a id="the-select-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-25">list of options</a> in <a id="the-select-element:tree-order-7" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
  order</a> that has its <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-18">selectedness</a> set to
  true, if any. If there isn't one, then return −1.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-select-element:dom-select-selectedindex-2"><a href="#dom-select-selectedindex">selectedIndex</a></code> setter steps are:</p>

  <ol><li><p>Let <var>firstMatchingOption</var> be null.</p></li><li>
    <p>For each <var>option</var> of <a id="the-select-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-26">list of options</a>:</p>

    <ol><li><p>Set <var>option</var>'s <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-19">selectedness</a>
     to false.</p></li><li><p>If <var>firstMatchingOption</var> is null and <var>option</var>'s <a href="#concept-option-index" id="the-select-element:concept-option-index-2">index</a> is equal to the given value, then set
     <var>firstMatchingOption</var> to <var>option</var>.</p></li></ol>
   </li><li><p>If <var>firstMatchingOption</var> is not null, then set <var>firstMatchingOption</var>'s
   <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-20">selectedness</a> to true and set
   <var>firstMatchingOption</var>'s <a href="#concept-option-dirtiness" id="the-select-element:concept-option-dirtiness-5">dirtiness</a> to
   true.</p></li><li><p>Run <a href="#update-a-select's-selectedcontent" id="the-select-element:update-a-select's-selectedcontent-2">update a <code>select</code>'s <code>selectedcontent</code></a> given
   <a id="the-select-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li></ol>
  </div>

  <p class="note">This can result in no element having a <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-21">selectedness</a> set to true even in the case of the
  <code id="the-select-element:the-select-element-38"><a href="#the-select-element">select</a></code> element having no <code id="the-select-element:attr-select-multiple-15"><a href="#attr-select-multiple">multiple</a></code>
  attribute and a <a href="#concept-select-size" id="the-select-element:concept-select-size-6">display size</a> of 1.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSelectElement" id="dom-select-value" data-dfn-type="attribute"><code>value</code></dfn>
  getter steps are to return the <a href="#concept-option-value" id="the-select-element:concept-option-value-3">value</a> of the
  first <code id="the-select-element:the-option-element-27"><a href="#the-option-element">option</a></code> element in <a id="the-select-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-27">list of options</a> in <a id="the-select-element:tree-order-8" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> that has its
  <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-22">selectedness</a> set to true, if any. If there isn't
  one, then return the empty string.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-select-element:dom-select-value-2"><a href="#dom-select-value">value</a></code> setter steps are:</p>

  <ol><li><p>Let <var>firstMatchingOption</var> be null.</p></li><li>
    <p>For each <var>option</var> of <a id="the-select-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-select-option-list" id="the-select-element:concept-select-option-list-28">list of options</a>:</p>

    <ol><li><p>Set <var>option</var>'s <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-23">selectedness</a>
     to false.</p></li><li><p>If <var>firstMatchingOption</var> is null and <var>option</var>'s <a href="#concept-option-value" id="the-select-element:concept-option-value-4">value</a> is equal to the given value, then set
     <var>firstMatchingOption</var> to <var>option</var>.</p></li></ol>
   </li><li><p>If <var>firstMatchingOption</var> is not null, then set <var>firstMatchingOption</var>'s
   <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-24">selectedness</a> to true and set
   <var>firstMatchingOption</var>'s <a href="#concept-option-dirtiness" id="the-select-element:concept-option-dirtiness-6">dirtiness</a> to
   true.</p></li><li><p>Run <a href="#update-a-select's-selectedcontent" id="the-select-element:update-a-select's-selectedcontent-3">update a <code>select</code>'s <code>selectedcontent</code></a> given
   <a id="the-select-element:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li></ol>
  </div>

  <p class="note">This can result in no element having a <a href="#concept-option-selectedness" id="the-select-element:concept-option-selectedness-25">selectedness</a> set to true even in the case of the
  <code id="the-select-element:the-select-element-39"><a href="#the-select-element">select</a></code> element having no <code id="the-select-element:attr-select-multiple-16"><a href="#attr-select-multiple">multiple</a></code>
  attribute and a <a href="#concept-select-size" id="the-select-element:concept-select-size-7">display size</a> of 1.</p>

  <p class="note">For historical reasons, the default value of the <code id="the-select-element:dom-select-size"><a href="#dom-select-size">size</a></code> IDL attribute does not return the actual size used, which, in
  the absence of the <code id="the-select-element:attr-select-size-7"><a href="#attr-select-size">size</a></code> content attribute, is either 1 or 4
  depending on the presence of the <code id="the-select-element:attr-select-multiple-17"><a href="#attr-select-multiple">multiple</a></code>
  attribute.</p>

  <p>The <code id="the-select-element:dom-cva-willvalidate-2"><a href="#dom-cva-willvalidate">willValidate</a></code>, <code id="the-select-element:dom-cva-validity-2"><a href="#dom-cva-validity">validity</a></code>, and <code id="the-select-element:dom-cva-validationmessage-2"><a href="#dom-cva-validationmessage">validationMessage</a></code> IDL attributes, and the <code id="the-select-element:dom-cva-checkvalidity-2"><a href="#dom-cva-checkvalidity">checkValidity()</a></code>, <code id="the-select-element:dom-cva-reportvalidity-2"><a href="#dom-cva-reportvalidity">reportValidity()</a></code>, and <code id="the-select-element:dom-cva-setcustomvalidity-2"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> methods, are part of the
  <a href="#the-constraint-validation-api" id="the-select-element:the-constraint-validation-api">constraint validation API</a>. The <code id="the-select-element:dom-lfe-labels-2"><a href="#dom-lfe-labels">labels</a></code> IDL
  attribute provides a list of the element's <code id="the-select-element:the-label-element"><a href="#the-label-element">label</a></code>s. The <code id="the-select-element:dom-select-disabled"><a href="#dom-select-disabled">disabled</a></code>, <code id="the-select-element:dom-fae-form-2"><a href="#dom-fae-form">form</a></code>, and <code id="the-select-element:dom-select-name"><a href="#dom-select-name">name</a></code> IDL attributes are part of the element's forms API.</p>

  

  <hr>

  <div class="example">

   <p>The following example shows how a <code id="the-select-element:the-select-element-40"><a href="#the-select-element">select</a></code> element can be used to offer the user
   with a set of options from which the user can select a single option. The default option is
   preselected.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">"unittype"</c-><c- p="">&gt;</c->Select unit type:<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">select</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"unittype"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"unittype"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1"</c-><c- p="">&gt;</c-> Miner <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"2"</c-><c- p="">&gt;</c-> Puffer <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"3"</c-> <c- e="">selected</c-><c- p="">&gt;</c-> Snipey <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"4"</c-><c- p="">&gt;</c-> Max <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"5"</c-><c- p="">&gt;</c-> Firebot <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>When there is no default option, a placeholder can be used instead:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">select</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"unittype"</c-> <strong><c- e="">required</c-></strong><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c-> Select unit type <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1"</c-><c- p="">&gt;</c-> Miner <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"2"</c-><c- p="">&gt;</c-> Puffer <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"3"</c-><c- p="">&gt;</c-> Snipey <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"4"</c-><c- p="">&gt;</c-> Max <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"5"</c-><c- p="">&gt;</c-> Firebot <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Here, the user is offered a set of options from which they can select any number. By default,
   all five options are selected.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">"allowedunits"</c-><c- p="">&gt;</c->Select unit types to enable on this map:<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">select</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"allowedunits"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"allowedunits"</c-> <c- e="">multiple</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1"</c-> <c- e="">selected</c-><c- p="">&gt;</c-> Miner <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"2"</c-> <c- e="">selected</c-><c- p="">&gt;</c-> Puffer <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"3"</c-> <c- e="">selected</c-><c- p="">&gt;</c-> Snipey <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"4"</c-> <c- e="">selected</c-><c- p="">&gt;</c-> Max <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"5"</c-> <c- e="">selected</c-><c- p="">&gt;</c-> Firebot <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>Sometimes, a user has to select one or more items. This example shows such an interface.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
 Select the songs from that you would like on your Act II Mix Tape:
 <c- p="">&lt;</c-><c- f="">select</c-> <c- e="">multiple</c-> <c- e="">required</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"act2"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s1"</c-><c- p="">&gt;</c->It Sucks to Be Me (Reprise)
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s2"</c-><c- p="">&gt;</c->There is Life Outside Your Apartment
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s3"</c-><c- p="">&gt;</c->The More You Ruv Someone
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s4"</c-><c- p="">&gt;</c->Schadenfreude
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s5"</c-><c- p="">&gt;</c->I Wish I Could Go Back to College
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s6"</c-><c- p="">&gt;</c->The Money Song
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s7"</c-><c- p="">&gt;</c->School for Monsters
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s8"</c-><c- p="">&gt;</c->The Money Song (Reprise)
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s9"</c-><c- p="">&gt;</c->There's a Fine, Fine Line (Reprise)
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s10"</c-><c- p="">&gt;</c->What Do You Do With a B.A. in English? (Reprise)
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s11"</c-><c- p="">&gt;</c->For Now
 <c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">
   <p>Occasionally it can be useful to have a separator:

   </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
 Select the song to play next:
 <c- p="">&lt;</c-><c- f="">select</c-> <c- e="">required</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"next"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"sr"</c-><c- p="">&gt;</c->Random
  <c- p="">&lt;</c-><c- f="">hr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s1"</c-><c- p="">&gt;</c->It Sucks to Be Me (Reprise)
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"s2"</c-><c- p="">&gt;</c->There is Life Outside Your Apartment
  …</code></pre>
  </div>

  <div id="example-customizable-select" class="example"><a href="#example-customizable-select" class="self-link"></a>
   <p>Here is an example which uses <code id="the-select-element:the-div-element"><a href="#the-div-element">div</a></code>, <code id="the-select-element:the-legend-element"><a href="#the-legend-element">legend</a></code>,
   <code id="the-select-element:the-img-element"><a href="#the-img-element">img</a></code>, <code id="the-select-element:the-button-element-2"><a href="#the-button-element">button</a></code>, and <code id="the-select-element:the-selectedcontent-element"><a href="#the-selectedcontent-element">selectedcontent</a></code> elements:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">select</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">selectedcontent</c-><c- p="">&gt;&lt;/</c-><c- f="">selectedcontent</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"border"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">optgroup</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->WHATWG Specifications<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"html.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->
        HTML
      <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"dom.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->
        DOM
      <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">optgroup</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"border"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">optgroup</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->W3C Specifications<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"forms.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->
        CSS Form Control Styling
      <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"pseudo.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->
        CSS Pseudo-Elements
      <c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">optgroup</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p id="note-first-button-in-select-not-submit" class="note"><a href="#note-first-button-in-select-not-submit" class="self-link"></a>The first child <code id="the-select-element:the-button-element-3"><a href="#the-button-element">button</a></code>
  element as allowed by the content model of <code id="the-select-element:the-select-element-41"><a href="#the-select-element">select</a></code> is not a submit button. It is used
  to replace the in-page rendering of the <code id="the-select-element:the-select-element-42"><a href="#the-select-element">select</a></code> element. Its form submission behavior
  is prevented because it is <a href="#inert" id="the-select-element:inert">inert</a>.</p>



  <h4 id="the-datalist-element"><span class="secno">4.10.8</span> The <dfn data-dfn-type="element"><code>datalist</code></dfn> element<a href="#the-datalist-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist" title="The <datalist> HTML element contains a set of <option> elements that represent the permissible or recommended options available to choose from within other controls.">Element/datalist</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Partial implementation.">🔰 4+</span></span><span class="safari yes"><span>Safari</span><span>12.1+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>9.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span title="Partial implementation.">🔰 79+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>33+</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDataListElement" title="The HTMLDataListElement interface provides special properties (beyond the HTMLElement object interface it also has available to it by inheritance) to manipulate <datalist> elements and their content.">HTMLDataListElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>12.1+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4.3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-datalist-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-datalist-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-datalist-element:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-contexts" id="the-datalist-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-datalist-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-datalist-element:concept-element-content-model">Content model</a>:</dt><dd>Either: <a href="#phrasing-content-2" id="the-datalist-element:phrasing-content-2-3">phrasing content</a>.</dd><dd>Or: Zero or more <code id="the-datalist-element:the-option-element"><a href="#the-option-element">option</a></code> and <a href="#script-supporting-elements-2" id="the-datalist-element:script-supporting-elements-2">script-supporting</a> elements.</dd><dt><a href="#concept-element-tag-omission" id="the-datalist-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-datalist-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-datalist-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-datalist-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-datalist">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-datalist">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-datalist-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmldatalistelement" data-dfn-type="interface"><c- g="">HTMLDataListElement</c-></dfn> : <a href="#htmlelement" id="the-datalist-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-datalist-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-datalist-element:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-datalist-options" id="the-datalist-element:dom-datalist-options"><c- g="">options</c-></a>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-datalist-element:the-datalist-element"><a href="#the-datalist-element">datalist</a></code> element represents a set of <code id="the-datalist-element:the-option-element-2"><a href="#the-option-element">option</a></code> elements that
  represent predefined options for other controls. In the rendering, the <code id="the-datalist-element:the-datalist-element-2"><a href="#the-datalist-element">datalist</a></code>
  element <a href="#represents" id="the-datalist-element:represents">represents</a> nothing and it, along with its children, should
  be hidden.</p>

  <p>The <code id="the-datalist-element:the-datalist-element-3"><a href="#the-datalist-element">datalist</a></code> element can be used in two ways. In the simplest case, the
  <code id="the-datalist-element:the-datalist-element-4"><a href="#the-datalist-element">datalist</a></code> element has just <code id="the-datalist-element:the-option-element-3"><a href="#the-option-element">option</a></code> element children.</p>

  <div class="example">

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
 Animal:
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">animal</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">animals</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">animals</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Cat"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Dog"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>In the more elaborate case, the <code id="the-datalist-element:the-datalist-element-5"><a href="#the-datalist-element">datalist</a></code> element can be given contents that are to
  be displayed for down-level clients that don't support <code id="the-datalist-element:the-datalist-element-6"><a href="#the-datalist-element">datalist</a></code>. In this case, the
  <code id="the-datalist-element:the-option-element-4"><a href="#the-option-element">option</a></code> elements are provided inside a <code id="the-datalist-element:the-select-element"><a href="#the-select-element">select</a></code> element inside the
  <code id="the-datalist-element:the-datalist-element-7"><a href="#the-datalist-element">datalist</a></code> element.</p>

  <div class="example">

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
 Animal:
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">animal</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">animals</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">animals</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
  or select from the list:
  <c- p="">&lt;</c-><c- f="">select</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">animal</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Cat
   <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Dog
  <c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>The <code id="the-datalist-element:the-datalist-element-8"><a href="#the-datalist-element">datalist</a></code> element is hooked up to an <code id="the-datalist-element:the-input-element"><a href="#the-input-element">input</a></code> element using the <code id="the-datalist-element:attr-input-list"><a href="#attr-input-list">list</a></code> attribute on the <code id="the-datalist-element:the-input-element-2"><a href="#the-input-element">input</a></code> element.</p>

  <p>Each <code id="the-datalist-element:the-option-element-5"><a href="#the-option-element">option</a></code> element that is a descendant of the <code id="the-datalist-element:the-datalist-element-9"><a href="#the-datalist-element">datalist</a></code> element,
  that is not <a href="#concept-option-disabled" id="the-datalist-element:concept-option-disabled">disabled</a>, and whose <a href="#concept-option-value" id="the-datalist-element:concept-option-value">value</a> is a string that isn't the empty string, represents a
  suggestion. Each suggestion has a <a href="#concept-option-value" id="the-datalist-element:concept-option-value-2">value</a> and a <a href="#concept-option-label" id="the-datalist-element:concept-option-label">label</a>.

  </p><dl class="domintro"><dt><code><var>datalist</var>.<a href="#dom-datalist-options" id="dom-datalist-options-dev">options</a></code></dt><dd>
    <p>Returns an <code id="the-datalist-element:htmlcollection-2"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the <code id="the-datalist-element:the-option-element-6"><a href="#the-option-element">option</a></code> elements of the
    <code id="the-datalist-element:the-datalist-element-10"><a href="#the-datalist-element">datalist</a></code> element.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLDataListElement" id="dom-datalist-options" data-dfn-type="attribute"><code>options</code></dfn> IDL attribute must return an
  <code id="the-datalist-element:htmlcollection-3"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="the-datalist-element:the-datalist-element-11"><a href="#the-datalist-element">datalist</a></code> node, whose filter matches
  <code id="the-datalist-element:the-option-element-7"><a href="#the-option-element">option</a></code> elements.</p>
  </div>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If an element has a <code id="the-datalist-element:the-datalist-element-12"><a href="#the-datalist-element">datalist</a></code> element
  ancestor, it is <a href="#barred-from-constraint-validation" id="the-datalist-element:barred-from-constraint-validation">barred from constraint validation</a>.</p>
  </div>

  


  <h4 id="the-optgroup-element"><span class="secno">4.10.9</span> The <dfn data-dfn-type="element"><code>optgroup</code></dfn> element<a href="#the-optgroup-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/optgroup" title="The <optgroup> HTML element creates a grouping of options within a <select> element.">Element/optgroup</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptGroupElement" title="The HTMLOptGroupElement interface provides special properties and methods (beyond the regular HTMLElement object interface they also have available to them by inheritance) for manipulating the layout and presentation of <optgroup> elements.">HTMLOptGroupElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-optgroup-element:concept-element-categories">Categories</a>:</dt><dd><a href="#select-element-inner-content-elements-2" id="the-optgroup-element:select-element-inner-content-elements-2"><code>select</code> element inner content elements</a>.</dd><dt><a href="#concept-element-contexts" id="the-optgroup-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a descendant of a <code id="the-optgroup-element:the-select-element"><a href="#the-select-element">select</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-optgroup-element:concept-element-content-model">Content model</a>:</dt><dd>Zero or one <code id="the-optgroup-element:the-legend-element"><a href="#the-legend-element">legend</a></code> element followed by zero or more <a href="#optgroup-element-inner-content-elements-2" id="the-optgroup-element:optgroup-element-inner-content-elements-2"><code>optgroup</code>
   element inner content elements</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-optgroup-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>An <code id="the-optgroup-element:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element's <a href="#syntax-end-tag" id="the-optgroup-element:syntax-end-tag">end tag</a> can be omitted
  if the <code id="the-optgroup-element:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> element  is
  immediately followed by another <code id="the-optgroup-element:the-optgroup-element-3"><a href="#the-optgroup-element">optgroup</a></code> element, if it is immediately followed by an
  <code id="the-optgroup-element:the-hr-element"><a href="#the-hr-element">hr</a></code> element, or if  there is no more content in the parent
  element.</dd><dt><a href="#concept-element-attributes" id="the-optgroup-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-optgroup-element:global-attributes">Global attributes</a></dd><dd><code id="the-optgroup-element:attr-optgroup-disabled"><a href="#attr-optgroup-disabled">disabled</a></code> —  Whether the form control is disabled
     </dd><dd><code id="the-optgroup-element:attr-optgroup-label"><a href="#attr-optgroup-label">label</a></code> —  User-visible label
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-optgroup-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-optgroup">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-optgroup">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-optgroup-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmloptgroupelement" data-dfn-type="interface"><c- g="">HTMLOptGroupElement</c-></dfn> : <a href="#htmlelement" id="the-optgroup-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-optgroup-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-optgroup-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-optgroup-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLOptGroupElement" id="dom-optgroup-disabled" data-dfn-type="attribute"><c- g="">disabled</c-></dfn>;
  [<a href="#cereactions" id="the-optgroup-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-optgroup-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLOptGroupElement" id="dom-optgroup-label" data-dfn-type="attribute"><c- g="">label</c-></dfn>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-optgroup-element:the-optgroup-element-4"><a href="#the-optgroup-element">optgroup</a></code> element <a href="#represents" id="the-optgroup-element:represents">represents</a> a <a href="#optgroup-option-group" id="the-optgroup-element:optgroup-option-group">group of <code>option</code> elements</a> with a common
  label.</p>

  <div data-algorithm="">
  <p>The <dfn id="optgroup-option-group">element's group of <code>option</code> elements</dfn>
  consists of the <code id="the-optgroup-element:the-option-element"><a href="#the-option-element">option</a></code> elements that are descendants of the <code id="the-optgroup-element:the-optgroup-element-5"><a href="#the-optgroup-element">optgroup</a></code>
  element.</p>
  </div>

  

  <p>When showing <code id="the-optgroup-element:the-option-element-2"><a href="#the-option-element">option</a></code> elements in <code id="the-optgroup-element:the-select-element-2"><a href="#the-select-element">select</a></code> elements, user agents should
  show the <code id="the-optgroup-element:the-option-element-3"><a href="#the-option-element">option</a></code> elements of such groups as being related to each other and separate
  from other <code id="the-optgroup-element:the-option-element-4"><a href="#the-option-element">option</a></code> elements.</p>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled" title="The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants.">Attributes/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="optgroup" id="attr-optgroup-disabled" data-dfn-type="element-attr"><code>disabled</code></dfn> attribute is a <a href="#boolean-attribute" id="the-optgroup-element:boolean-attribute">boolean
  attribute</a> and can be used to <a href="#concept-option-disabled" id="the-optgroup-element:concept-option-disabled">disable</a> a <a href="#optgroup-option-group" id="the-optgroup-element:optgroup-option-group-2">group of <code>option</code> elements</a> together.</p>

  <p>The <dfn data-dfn-for="optgroup" id="attr-optgroup-label" data-dfn-type="element-attr"><code>label</code></dfn>
  attribute must be specified if the <code id="the-optgroup-element:the-optgroup-element-6"><a href="#the-optgroup-element">optgroup</a></code> has no child <code id="the-optgroup-element:the-legend-element-2"><a href="#the-legend-element">legend</a></code>
  element.</p>

  <div data-algorithm="">
  <p>To <dfn id="concept-optgroup-label">get an <code>optgroup</code> element's label</dfn>,
  given an <code id="the-optgroup-element:the-optgroup-element-7"><a href="#the-optgroup-element">optgroup</a></code> <var>optgroup</var>:</p>

  <ol><li><p>If <var>optgroup</var> has a child <code id="the-optgroup-element:the-legend-element-3"><a href="#the-legend-element">legend</a></code> element, then return the result of
   <a href="https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace" id="the-optgroup-element:strip-and-collapse-ascii-whitespace" data-x-internal="strip-and-collapse-ascii-whitespace">stripping and collapsing ASCII
   whitespace</a> from the concatenation of <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="the-optgroup-element:concept-cd-data" data-x-internal="concept-cd-data">data</a> of all the
   <code id="the-optgroup-element:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node descendants of <var>optgroup</var>'s first child <code id="the-optgroup-element:the-legend-element-4"><a href="#the-legend-element">legend</a></code>
   element, in <a id="the-optgroup-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, excluding any that are descendants of descendants of the
   <code id="the-optgroup-element:the-legend-element-5"><a href="#the-legend-element">legend</a></code> that are themselves <code id="the-optgroup-element:the-script-element"><a href="#the-script-element">script</a></code> or <a id="the-optgroup-element:svg-script" href="https://svgwg.org/svg2-draft/interact.html#ScriptElement" data-x-internal="svg-script">SVG
   <code>script</code></a> elements.</p></li><li><p>Otherwise, return the value of <var>optgroup</var>'s <code id="the-optgroup-element:attr-optgroup-label-2"><a href="#attr-optgroup-label">label</a></code> attribute.</p></li></ol>
  </div>

  <p>The value of the <a href="#concept-optgroup-label" id="the-optgroup-element:concept-optgroup-label"><code>optgroup</code> label
  algorithm</a> gives the name of the group, for the purposes of the user interface. User agents should use this attribute's value when labeling the group of
  <code id="the-optgroup-element:the-option-element-5"><a href="#the-option-element">option</a></code> elements in a <code id="the-optgroup-element:the-select-element-3"><a href="#the-select-element">select</a></code> element.</p>

  <p class="note">There is no way to select an <code id="the-optgroup-element:the-optgroup-element-8"><a href="#the-optgroup-element">optgroup</a></code> element. Only
  <code id="the-optgroup-element:the-option-element-6"><a href="#the-option-element">option</a></code> elements can be selected. An <code id="the-optgroup-element:the-optgroup-element-9"><a href="#the-optgroup-element">optgroup</a></code> element merely provides a
  label for a group of <code id="the-optgroup-element:the-option-element-7"><a href="#the-option-element">option</a></code> elements.</p>

  <div class="example">

   <p>The following snippet shows how a set of lessons from three courses could be offered in a
   <code id="the-optgroup-element:the-select-element-4"><a href="#the-select-element">select</a></code> drop-down widget:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"courseselector.dll"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"get"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Which course would you like to watch today?
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Course:
  <c- p="">&lt;</c-><c- f="">select</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"c"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">optgroup</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"8.01 Physics I: Classical Mechanics"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8.01.1"</c-><c- p="">&gt;</c->Lecture 01: Powers of Ten
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8.01.2"</c-><c- p="">&gt;</c->Lecture 02: 1D Kinematics
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8.01.3"</c-><c- p="">&gt;</c->Lecture 03: Vectors
   <c- p="">&lt;</c-><c- f="">optgroup</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"8.02 Electricity and Magnetism"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8.02.1"</c-><c- p="">&gt;</c->Lecture 01: What holds our world together?
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8.02.2"</c-><c- p="">&gt;</c->Lecture 02: Electric Field
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8.02.3"</c-><c- p="">&gt;</c->Lecture 03: Electric Flux
   <c- p="">&lt;</c-><c- f="">optgroup</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">"8.03 Physics III: Vibrations and Waves"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8.03.1"</c-><c- p="">&gt;</c->Lecture 01: Periodic Phenomenon
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8.03.2"</c-><c- p="">&gt;</c->Lecture 02: Beats
    <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"8.03.3"</c-><c- p="">&gt;</c->Lecture 03: Forced Oscillations with Damping
  <c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"▶ Play"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-option-element"><span class="secno">4.10.10</span> The <dfn data-dfn-type="element"><code>option</code></dfn> element<a href="#the-option-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option" title="The <option> HTML element is used to define an item contained in a <select>, an <optgroup>, or a <datalist> element. As such, <option> can represent menu items in popups and other lists of items in an HTML document.">Element/option</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement" title="The HTMLOptionElement interface represents <option> elements and inherits all properties and methods of the HTMLElement interface.">HTMLOptionElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-option-element:concept-element-categories">Categories</a>:</dt><dd><a href="#select-element-inner-content-elements-2" id="the-option-element:select-element-inner-content-elements-2"><code>select</code> element inner content elements</a>.</dd><dd><a href="#optgroup-element-inner-content-elements-2" id="the-option-element:optgroup-element-inner-content-elements-2"><code>optgroup</code> element inner content elements</a>.</dd><dt><a href="#concept-element-contexts" id="the-option-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a descendant of a <code id="the-option-element:the-select-element"><a href="#the-select-element">select</a></code> element.</dd><dd>As a descendant of a <code id="the-option-element:the-datalist-element"><a href="#the-datalist-element">datalist</a></code> element.</dd><dd>As a descendant of an <code id="the-option-element:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-option-element:concept-element-content-model">Content model</a>:</dt><dd>If the element has a <code id="the-option-element:attr-option-label"><a href="#attr-option-label">label</a></code> attribute and a <code id="the-option-element:attr-option-value"><a href="#attr-option-value">value</a></code> attribute: <a href="#concept-content-nothing" id="the-option-element:concept-content-nothing">Nothing</a>.</dd><dd>If the element has a <code id="the-option-element:attr-option-label-2"><a href="#attr-option-label">label</a></code> attribute but no <code id="the-option-element:attr-option-value-2"><a href="#attr-option-value">value</a></code> attribute: <a href="#text-content" id="the-option-element:text-content">Text</a>.</dd><dd>If the element has no <code id="the-option-element:attr-option-label-3"><a href="#attr-option-label">label</a></code> attribute and is not a
   descendant of a <code id="the-option-element:the-datalist-element-2"><a href="#the-datalist-element">datalist</a></code> element: Zero or more <a href="#option-element-inner-content-elements-2" id="the-option-element:option-element-inner-content-elements-2"><code>option</code> element
   inner content elements</a>.</dd><dd>If the element has no <code id="the-option-element:attr-option-label-4"><a href="#attr-option-label">label</a></code> attribute and is a
   descendant of a <code id="the-option-element:the-datalist-element-3"><a href="#the-datalist-element">datalist</a></code> element: <a href="#text-content" id="the-option-element:text-content-2">Text</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-option-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>An <code id="the-option-element:the-option-element"><a href="#the-option-element">option</a></code> element's <a href="#syntax-end-tag" id="the-option-element:syntax-end-tag">end tag</a> can be omitted if
  the <code id="the-option-element:the-option-element-2"><a href="#the-option-element">option</a></code> element is immediately followed by another <code id="the-option-element:the-option-element-3"><a href="#the-option-element">option</a></code> element, if
  it is immediately followed by an <code id="the-option-element:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> element, if it is immediately followed by
  an <code id="the-option-element:the-hr-element"><a href="#the-hr-element">hr</a></code> element, or if there is no more content in the parent element.</dd><dt><a href="#concept-element-attributes" id="the-option-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-option-element:global-attributes">Global attributes</a></dd><dd><code id="the-option-element:attr-option-disabled"><a href="#attr-option-disabled">disabled</a></code> —  Whether the form control is disabled
     </dd><dd><code id="the-option-element:attr-option-label-5"><a href="#attr-option-label">label</a></code> —  User-visible label
     </dd><dd><code id="the-option-element:attr-option-selected"><a href="#attr-option-selected">selected</a></code> —  Whether the option is selected by default
     </dd><dd><code id="the-option-element:attr-option-value-3"><a href="#attr-option-value">value</a></code> —  Value to be used for <a href="#form-submission-2" id="the-option-element:form-submission-2">form submission</a>
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-option-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-option">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-option">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-option-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="the-option-element:legacyfactoryfunction" href="https://webidl.spec.whatwg.org/#LegacyFactoryFunction" data-x-internal="legacyfactoryfunction"><c- g="">LegacyFactoryFunction</c-></a>=<a href="#dom-option" id="the-option-element:dom-option"><c- n="">Option</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">text</c-> = "", <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">value</c->, <c- b="">optional</c-> <c- b="">boolean</c-> <c- g="">defaultSelected</c-> = <c- b="">false</c->, <c- b="">optional</c-> <c- b="">boolean</c-> <c- g="">selected</c-> = <c- b="">false</c->)]
<c- b="">interface</c-> <dfn id="htmloptionelement" data-dfn-type="interface"><c- g="">HTMLOptionElement</c-></dfn> : <a href="#htmlelement" id="the-option-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-option-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-option-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-option-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLOptionElement" id="dom-option-disabled" data-dfn-type="attribute"><c- g="">disabled</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-option-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-option-form" id="the-option-element:dom-option-form"><c- g="">form</c-></a>;
  [<a href="#cereactions" id="the-option-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-option-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-option-label" id="the-option-element:dom-option-label"><c- g="">label</c-></a>;
  [<a href="#cereactions" id="the-option-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-option-element:xattr-reflect-2">Reflect</a>="<a href="#attr-option-selected" id="the-option-element:attr-option-selected-2">selected</a>"] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLOptionElement" id="dom-option-defaultselected" data-dfn-type="attribute"><c- g="">defaultSelected</c-></dfn>;
  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-option-selected" id="the-option-element:dom-option-selected"><c- g="">selected</c-></a>;
  [<a href="#cereactions" id="the-option-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-option-element:xattr-reflectsetter-2"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-option-value" id="the-option-element:dom-option-value"><c- g="">value</c-></a>;

  [<a href="#cereactions" id="the-option-element:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-option-text" id="the-option-element:dom-option-text"><c- g="">text</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">long</c-> <a href="#dom-option-index" id="the-option-element:dom-option-index"><c- g="">index</c-></a>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-option-element:the-option-element-4"><a href="#the-option-element">option</a></code> element <a href="#represents" id="the-option-element:represents">represents</a> an option in a <code id="the-option-element:the-select-element-2"><a href="#the-select-element">select</a></code>
  element or as part of a list of suggestions in a <code id="the-option-element:the-datalist-element-4"><a href="#the-datalist-element">datalist</a></code> element.</p>

  <p>In certain circumstances described in the definition of the <code id="the-option-element:the-select-element-3"><a href="#the-select-element">select</a></code> element, an
  <code id="the-option-element:the-option-element-5"><a href="#the-option-element">option</a></code> element can be a <code id="the-option-element:the-select-element-4"><a href="#the-select-element">select</a></code> element's <a href="#placeholder-label-option" id="the-option-element:placeholder-label-option">placeholder label
  option</a>. A <a href="#placeholder-label-option" id="the-option-element:placeholder-label-option-2">placeholder label option</a> does not represent an actual option, but
  instead represents a label for the <code id="the-option-element:the-select-element-5"><a href="#the-select-element">select</a></code> control.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled" title="The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants.">Attributes/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="option" id="attr-option-disabled" data-dfn-type="element-attr"><code>disabled</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-option-element:boolean-attribute">boolean attribute</a>. An <code id="the-option-element:the-option-element-6"><a href="#the-option-element">option</a></code> element <var>option</var> is
  <dfn id="concept-option-disabled">disabled</dfn> if the following steps return true:</p>

  <ol><li><p>If <var>option</var>'s <code id="the-option-element:attr-option-disabled-2"><a href="#attr-option-disabled">disabled</a></code> attribute is
   present, then return true.</p></li><li>
    <p>For each <var>ancestor</var> of <var>option</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-ancestor" id="the-option-element:ancestor" data-x-internal="ancestor">ancestors</a>
    in reverse <a id="the-option-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

    <ol><li><p>If <var>ancestor</var> is a <code id="the-option-element:the-select-element-6"><a href="#the-select-element">select</a></code>, <code id="the-option-element:the-hr-element-2"><a href="#the-hr-element">hr</a></code>, <code id="the-option-element:the-datalist-element-5"><a href="#the-datalist-element">datalist</a></code>,
     or <code id="the-option-element:the-option-element-7"><a href="#the-option-element">option</a></code> element, then return false.</p></li><li><p>If <var>ancestor</var> is an <code id="the-option-element:the-optgroup-element-3"><a href="#the-optgroup-element">optgroup</a></code> element, then return true if
     <var>ancestor</var>'s <code id="the-option-element:attr-optgroup-disabled"><a href="#attr-optgroup-disabled">disabled</a></code> attribute is
     present; otherwise false.</p></li></ol>
   </li><li><p>Return false.</p></li></ol>
  </div>

  

  <p>An <code id="the-option-element:the-option-element-8"><a href="#the-option-element">option</a></code> element that is <a href="#attr-option-disabled" id="the-option-element:attr-option-disabled-3">disabled</a> must
  prevent any <code id="the-option-element:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> events that are <a href="#queue-a-task" id="the-option-element:queue-a-task">queued</a> on the <a href="#user-interaction-task-source" id="the-option-element:user-interaction-task-source">user interaction task source</a> from being dispatched on the
  element.</p>

  

  <p class="note">Being <a href="#concept-option-disabled" id="the-option-element:concept-option-disabled">disabled</a> does not prevent all
  modifications to the <code id="the-option-element:the-option-element-9"><a href="#the-option-element">option</a></code> element. For example, its <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness">selectedness</a> could be modified programmatically from
  JavaScript. Or, it could be indirectly modified by user action, e.g., if other non-disabled
  <code id="the-option-element:the-option-element-10"><a href="#the-option-element">option</a></code> elements in the <code id="the-option-element:the-select-element-7"><a href="#the-select-element">select</a></code> element were modified.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="option" id="attr-option-label" data-dfn-type="element-attr"><code>label</code></dfn>
  attribute provides a label for element. The <dfn id="concept-option-label">label</dfn> of an
  <code id="the-option-element:the-option-element-11"><a href="#the-option-element">option</a></code> element is the value of the <code id="the-option-element:attr-option-label-6"><a href="#attr-option-label">label</a></code>
  content attribute, if there is one and its value is not the empty string, or, otherwise, the value
  of the element's <code id="the-option-element:dom-option-text-2"><a href="#dom-option-text">text</a></code> IDL attribute.</p>
  </div>

  <p>The <code id="the-option-element:attr-option-label-7"><a href="#attr-option-label">label</a></code> content attribute, if specified, must not be
  empty.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="option" id="attr-option-value" data-dfn-type="element-attr"><code>value</code></dfn>
  attribute provides a value for element. The <dfn id="concept-option-value">value</dfn> of an
  <code id="the-option-element:the-option-element-12"><a href="#the-option-element">option</a></code> element is the value of the <code id="the-option-element:attr-option-value-4"><a href="#attr-option-value">value</a></code>
  content attribute, if there is one, or, if there is not, the result of <a href="#collect-option-text" id="the-option-element:collect-option-text">collect option
  text</a> given <a id="the-option-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and false.</p>
  </div>

  <p>The <dfn data-dfn-for="option" id="attr-option-selected" data-dfn-type="element-attr"><code>selected</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-option-element:boolean-attribute-2">boolean attribute</a>. It represents the default <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-2">selectedness</a> of the element.</p>

  

  <p>The <dfn id="concept-option-dirtiness">dirtiness</dfn> of an <code id="the-option-element:the-option-element-13"><a href="#the-option-element">option</a></code> element is
  a boolean state, initially false. It controls whether adding or removing the <code id="the-option-element:attr-option-selected-3"><a href="#attr-option-selected">selected</a></code> content attribute has any effect.</p>

  <div data-algorithm="">
  <p>The <dfn id="concept-option-selectedness">selectedness</dfn> of an <code id="the-option-element:the-option-element-14"><a href="#the-option-element">option</a></code>
  element is a boolean state, initially false. Except where otherwise specified, when the element is
  created, its <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-3">selectedness</a> must be set to true if
  the element has a <code id="the-option-element:attr-option-selected-4"><a href="#attr-option-selected">selected</a></code> attribute. Whenever an
  <code id="the-option-element:the-option-element-15"><a href="#the-option-element">option</a></code> element's <code id="the-option-element:attr-option-selected-5"><a href="#attr-option-selected">selected</a></code> attribute is
  added, if its <a href="#concept-option-dirtiness" id="the-option-element:concept-option-dirtiness">dirtiness</a> is false, its <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-4">selectedness</a> must be set to true. Whenever an
  <code id="the-option-element:the-option-element-16"><a href="#the-option-element">option</a></code> element's <code id="the-option-element:attr-option-selected-6"><a href="#attr-option-selected">selected</a></code> attribute is
  <em>removed</em>, if its <a href="#concept-option-dirtiness" id="the-option-element:concept-option-dirtiness-2">dirtiness</a> is false, its
  <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-5">selectedness</a> must be set to false.</p>
  </div>

  <p class="note">The <code id="the-option-element:dom-option-2"><a href="#dom-option">Option()</a></code> constructor, when called with three
  or fewer arguments, overrides the initial state of the <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-6">selectedness</a> state to always be false even if the third
  argument is true (implying that a <code id="the-option-element:attr-option-selected-7"><a href="#attr-option-selected">selected</a></code> attribute is
  to be set). The fourth argument can be used to explicitly set the initial <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-7">selectedness</a> state when using the constructor.</p>

  

  

  <p>A <code id="the-option-element:the-select-element-8"><a href="#the-select-element">select</a></code> element whose <code id="the-option-element:attr-select-multiple"><a href="#attr-select-multiple">multiple</a></code>
  attribute is not specified must not have more than one descendant <code id="the-option-element:the-option-element-17"><a href="#the-option-element">option</a></code> element with
  its <code id="the-option-element:attr-option-selected-8"><a href="#attr-option-selected">selected</a></code> attribute set.</p>

  

  <div data-algorithm="">
  <p>An <code id="the-option-element:the-option-element-18"><a href="#the-option-element">option</a></code> element's <dfn id="concept-option-index">index</dfn> is the number of
  <code id="the-option-element:the-option-element-19"><a href="#the-option-element">option</a></code> elements that are in the same <a href="#concept-select-option-list" id="the-option-element:concept-select-option-list">list of
  options</a> but that come before it in <a id="the-option-element:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>. If the <code id="the-option-element:the-option-element-20"><a href="#the-option-element">option</a></code>
  element is not in a <a href="#concept-select-option-list" id="the-option-element:concept-select-option-list-2">list of options</a>, then the
  <code id="the-option-element:the-option-element-21"><a href="#the-option-element">option</a></code> element's <a href="#concept-option-index" id="the-option-element:concept-option-index">index</a> is zero.</p>
  </div>

  

  <p>Each <code id="the-option-element:the-option-element-22"><a href="#the-option-element">option</a></code> element has a <dfn id="cached-nearest-ancestor-select-element">cached nearest ancestor <code>select</code>
  element</dfn>, which is a <code id="the-option-element:the-select-element-9"><a href="#the-select-element">select</a></code> element or null, initially set to null.</p>

  <div data-algorithm="">
  <p>To <dfn id="update-an-option's-nearest-ancestor-select">update an <code>option</code>'s nearest ancestor <code>select</code></dfn>, given an
  <code id="the-option-element:the-option-element-23"><a href="#the-option-element">option</a></code> <var>option</var>:</p>

  <ol><li><p>Let <var>oldSelect</var> be <var>option</var>'s <a href="#cached-nearest-ancestor-select-element" id="the-option-element:cached-nearest-ancestor-select-element">cached nearest ancestor
   <code>select</code> element</a>.</p></li><li><p>Let <var>newSelect</var> be <var>option</var>'s <a href="#option-element-nearest-ancestor-select" id="the-option-element:option-element-nearest-ancestor-select"><code>option</code> element
   nearest ancestor <code>select</code></a>.</p></li><li>
    <p>If <var>oldSelect</var> is not <var>newSelect</var>:</p>

    <ol><li><p>If <var>oldSelect</var> is not null, then run the <a href="#selectedness-setting-algorithm" id="the-option-element:selectedness-setting-algorithm">selectedness setting
     algorithm</a> given <var>oldSelect</var>.</p></li><li><p>If <var>newSelect</var> is not null, then run the <a href="#selectedness-setting-algorithm" id="the-option-element:selectedness-setting-algorithm-2">selectedness setting
     algorithm</a> given <var>newSelect</var>.</p></li></ol>
   </li><li><p>Set <var>option</var>'s <a href="#cached-nearest-ancestor-select-element" id="the-option-element:cached-nearest-ancestor-select-element-2">cached nearest ancestor <code>select</code>
   element</a> to <var>newSelect</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-option-element:the-option-element-24"><a href="#the-option-element">option</a></code> <a href="#html-element-insertion-steps" id="the-option-element:html-element-insertion-steps">HTML element insertion steps</a>, given
  <var>insertedOption</var>, are to run <a href="#update-an-option's-nearest-ancestor-select" id="the-option-element:update-an-option's-nearest-ancestor-select">update an <code>option</code>'s nearest ancestor
  <code>select</code></a> given <var>insertedOption</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-option-element:the-option-element-25"><a href="#the-option-element">option</a></code> <a href="#html-element-removing-steps" id="the-option-element:html-element-removing-steps">HTML element removing steps</a>, given
  <var>removedOption</var> and <var>oldParent</var>, are to run <a href="#update-an-option's-nearest-ancestor-select" id="the-option-element:update-an-option's-nearest-ancestor-select-2">update an
  <code>option</code>'s nearest ancestor <code>select</code></a> given
  <var>removedOption</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-option-element:the-option-element-26"><a href="#the-option-element">option</a></code> <a href="#html-element-moving-steps" id="the-option-element:html-element-moving-steps">HTML element moving steps</a>, given <var>movedNode</var> and
  <var>oldParent</var>, are to run <a href="#update-an-option's-nearest-ancestor-select" id="the-option-element:update-an-option's-nearest-ancestor-select-3">update an <code>option</code>'s nearest ancestor
  <code>select</code></a> given <var>movedNode</var>.</p>
  </div>

  <div data-algorithm="">
  <p>To get the <dfn id="option-element-nearest-ancestor-select"><code>option</code> element nearest ancestor <code>select</code></dfn> given an
  <code id="the-option-element:the-option-element-27"><a href="#the-option-element">option</a></code> <var>option</var>, run these steps. They return a <code id="the-option-element:the-select-element-10"><a href="#the-select-element">select</a></code> or
  null.</p>

  <ol><li><p>Let <var>ancestorOptgroup</var> be null.</p></li><li>
    <p>For each <var>ancestor</var> of <var>option</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-ancestor" id="the-option-element:ancestor-2" data-x-internal="ancestor">ancestors</a>,
    in reverse <a id="the-option-element:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

    <ol><li><p>If <var>ancestor</var> is a <code id="the-option-element:the-datalist-element-6"><a href="#the-datalist-element">datalist</a></code>, <code id="the-option-element:the-hr-element-3"><a href="#the-hr-element">hr</a></code>, or
     <code id="the-option-element:the-option-element-28"><a href="#the-option-element">option</a></code> element, then return null.</p></li><li>
      <p>If <var>ancestor</var> is an <code id="the-option-element:the-optgroup-element-4"><a href="#the-optgroup-element">optgroup</a></code> element:</p>

      <ol><li><p>If <var>ancestorOptgroup</var> is not null, then return null.</p></li><li><p>Set <var>ancestorOptgroup</var> to <var>ancestor</var>.</p></li></ol>
     </li><li><p>If <var>ancestor</var> is a <code id="the-option-element:the-select-element-11"><a href="#the-select-element">select</a></code>, then return
     <var>ancestor</var>.</p></li></ol>
   </li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="maybe-clone-an-option-into-selectedcontent">maybe clone an <code>option</code> into <code>selectedcontent</code></dfn>, given an
  <code id="the-option-element:the-option-element-29"><a href="#the-option-element">option</a></code> <var>option</var>:</p>

  <ol><li><p>Let <var>select</var> be <var>option</var>'s <a href="#option-element-nearest-ancestor-select" id="the-option-element:option-element-nearest-ancestor-select-2"><code>option</code> element nearest
   ancestor <code>select</code></a>.</p></li><li>
    <p>If all of the following conditions are true:</p>

    <ul><li><p><var>select</var> is not null;</p></li><li><p><var>option</var>'s <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-8">selectedness</a> is
     true; and</p></li><li><p><var>select</var>'s <a href="#select-enabled-selectedcontent" id="the-option-element:select-enabled-selectedcontent">enabled
     <code>selectedcontent</code></a> is not null,</p></li></ul>

    <p>then run <a href="#clone-an-option-into-a-selectedcontent" id="the-option-element:clone-an-option-into-a-selectedcontent">clone an <code>option</code> into a <code>selectedcontent</code></a> given
    <var>option</var> and <var>select</var>'s <a href="#select-enabled-selectedcontent" id="the-option-element:select-enabled-selectedcontent-2">enabled
    <code>selectedcontent</code></a>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="clone-selected-option-into-select-button">clone selected <code>option</code> into <code>select</code> button</dfn>, given a
  <code id="the-option-element:the-select-element-12"><a href="#the-select-element">select</a></code> element <var>select</var>:</p>

  <ol><li><p>Let <var>option</var> be the first element of <var>select</var>'s <a href="#concept-select-option-list" id="the-option-element:concept-select-option-list-3">option list</a> whose <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-9">selectedness</a> is set to true, if such an element
   exists; otherwise null.</p></li><li><p>Let <var>text</var> be the empty string.</p></li><li><p>If <var>option</var> is not null, then set <var>text</var> to <var>option</var>'s <a href="#dom-option-label" id="the-option-element:dom-option-label-2">label</a>.</p></li><li><p>Set <var>select</var>'s <a href="#select-fallback-button-text" id="the-option-element:select-fallback-button-text">select fallback button text</a> to
   <var>text</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When an <code id="the-option-element:the-option-element-30"><a href="#the-option-element">option</a></code> element is popped off the <a href="#stack-of-open-elements" id="the-option-element:stack-of-open-elements">stack of open elements</a> of an
  <a href="#html-parser" id="the-option-element:html-parser">HTML parser</a> or <a href="#xml-parser" id="the-option-element:xml-parser">XML parser</a>, the user agent must run <a href="#maybe-clone-an-option-into-selectedcontent" id="the-option-element:maybe-clone-an-option-into-selectedcontent">maybe clone an
  option into selectedcontent</a> given the <code id="the-option-element:the-option-element-31"><a href="#the-option-element">option</a></code> element.</p>
  </div>

  <dl class="domintro"><dt><code><var>option</var>.<a href="#dom-option-selected" id="dom-option-selected-dev">selected</a></code></dt><dd>
    <p>Returns true if the element is selected, and false otherwise.</p>

    <p>Can be set, to override the current state of the element.</p>
   </dd><dt><code><var>option</var>.<a href="#dom-option-index" id="dom-option-index-dev">index</a></code></dt><dd><p>Returns the index of the element in its <code id="the-option-element:the-select-element-13"><a href="#the-select-element">select</a></code> element's <code id="the-option-element:dom-select-options"><a href="#dom-select-options">options</a></code> list.</p></dd><dt><code><var>option</var>.<a href="#dom-option-form" id="dom-option-form-dev">form</a></code></dt><dd><p>Returns the element's <code id="the-option-element:the-form-element"><a href="#the-form-element">form</a></code> element, if any, or null otherwise.</p></dd><dt><code><var>option</var>.<a href="#dom-option-text" id="dom-option-text-dev">text</a></code></dt><dd>
    <p>Same as <code id="the-option-element:textcontent"><a data-x-internal="textcontent" href="https://dom.spec.whatwg.org/#dom-node-textcontent">textContent</a></code>, except that spaces are collapsed and <code id="the-option-element:the-script-element"><a href="#the-script-element">script</a></code>
    elements are skipped.</p>
   </dd><dt><code><var>option</var> = new <a href="#dom-option" id="dom-option-dev">Option</a>([ <var>text</var> [, <var>value</var> [, <var>defaultSelected</var> [, <var>selected</var> ] ] ] ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement/Option" title="The Option() constructor creates a new HTMLOptionElement.">HTMLOptionElement/Option</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a new <code id="the-option-element:the-option-element-32"><a href="#the-option-element">option</a></code> element.</p>

    <p>The <var>text</var> argument sets the contents of the element.</p>

    <p>The <var>value</var> argument sets the <code id="the-option-element:attr-option-value-5"><a href="#attr-option-value">value</a></code>
    attribute.</p>

    <p>The <var>defaultSelected</var> argument sets the <code id="the-option-element:attr-option-selected-9"><a href="#attr-option-selected">selected</a></code> attribute.</p>

    <p>The <var>selected</var> argument sets whether or not the element is selected. If it is
    omitted, even if the <var>defaultSelected</var> argument is true, the element is not
    selected.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionElement" id="dom-option-label" data-dfn-type="attribute"><code>label</code></dfn>
  getter steps are:</p>

  <ol><li><p>Let <var>attribute</var> be <a id="the-option-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-option-element:attr-option-label-8"><a href="#attr-option-label">label</a></code> attribute.</p></li><li><p>If <var>attribute</var> is null, then return <a id="the-option-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-option-label" id="the-option-element:concept-option-label">label</a>.</p></li><li><p>Return <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="the-option-element:concept-attribute-value" data-x-internal="concept-attribute-value">value</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionElement" id="dom-option-value" data-dfn-type="attribute"><code>value</code></dfn>
  getter steps are to return <a id="the-option-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-option-value" id="the-option-element:concept-option-value">value</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionElement" id="dom-option-selected" data-dfn-type="attribute"><code>selected</code></dfn> IDL attribute, on getting, must return true if
  the element's <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-10">selectedness</a> is true, and false
  otherwise. On setting, it must set the element's <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-11">selectedness</a> to the new value, set its <a href="#concept-option-dirtiness" id="the-option-element:concept-option-dirtiness-3">dirtiness</a> to true, and then cause the element to
  <a href="#ask-for-a-reset" id="the-option-element:ask-for-a-reset">ask for a reset</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionElement" id="dom-option-index" data-dfn-type="attribute"><code>index</code></dfn>
  IDL attribute must return the element's <a href="#concept-option-index" id="the-option-element:concept-option-index-2">index</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionElement" id="dom-option-text" data-dfn-type="attribute"><code>text</code></dfn>
  getter steps are to return the result of <a href="#collect-option-text" id="the-option-element:collect-option-text-2">collect option text</a> given <a id="the-option-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>
  and false.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-option-element:dom-option-text-3"><a href="#dom-option-text">text</a></code> setter steps are to <a id="the-option-element:string-replace-all" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">string replace
  all</a> with the given value within <a id="the-option-element:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOptionElement" id="dom-option-form" data-dfn-type="attribute"><code>form</code></dfn>
  getter steps are:</p>

  <ol><li><p>Let <var>select</var> be <a id="the-option-element:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#option-element-nearest-ancestor-select" id="the-option-element:option-element-nearest-ancestor-select-3"><code>option</code> element nearest
   ancestor <code>select</code></a>.</p></li><li><p>If <var>select</var> is null, then return null.</p></li><li><p>Return <var>select</var>'s <a href="#form-owner" id="the-option-element:form-owner">form owner</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A legacy factory function is provided for creating <code id="the-option-element:htmloptionelement"><a href="#htmloptionelement">HTMLOptionElement</a></code> objects (in
  addition to the factory methods from DOM such as <code id="the-option-element:dom-document-createelement"><a data-x-internal="dom-document-createelement" href="https://dom.spec.whatwg.org/#dom-document-createelement">createElement()</a></code>): <dfn data-dfn-for="HTMLOptionElement" id="dom-option" data-dfn-type="constructor"><code>Option(<var>text</var>, <var>value</var>,
  <var>defaultSelected</var>, <var>selected</var>)</code></dfn>. When invoked, the legacy factory
  function must perform the following steps:</p>

  <ol><li><p>Let <var>document</var> be the <a href="#current-global-object" id="the-option-element:current-global-object">current global object</a>'s <a href="#concept-document-window" id="the-option-element:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>Let <var>option</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-option-element:create-an-element" data-x-internal="create-an-element">creating an
   element</a> given <var>document</var>, "<code>option</code>", and the <a id="the-option-element:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
   namespace</a>.</p></li><li><p>If <var>text</var> is not the empty string, then append to <var>option</var> a new
   <code id="the-option-element:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node whose data is <var>text</var>.</p></li><li><p>If <var>value</var> is given, then <a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="the-option-element:concept-element-attributes-set-value" data-x-internal="concept-element-attributes-set-value">set
   an attribute value</a> for <var>option</var> using "<code id="the-option-element:attr-option-value-6"><a href="#attr-option-value">value</a></code>" and <var>value</var>.</p></li><li><p>If <var>defaultSelected</var> is true, then <a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="the-option-element:concept-element-attributes-set-value-2" data-x-internal="concept-element-attributes-set-value">set an attribute value</a> for <var>option</var>
   using "<code id="the-option-element:attr-option-selected-10"><a href="#attr-option-selected">selected</a></code>" and the empty string.</p></li><li><p>If <var>selected</var> is true, then set <var>option</var>'s <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-12">selectedness</a> to true; otherwise set its <a href="#concept-option-selectedness" id="the-option-element:concept-option-selectedness-13">selectedness</a> to false (even if
   <var>defaultSelected</var> is true).</p></li><li><p>Return <var>option</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="collect-option-text">collect option text</dfn>, given an <code id="the-option-element:the-option-element-33"><a href="#the-option-element">option</a></code> element <var>option</var> and a
  boolean <var>includeAltText</var>:</p>

  <ol><li><p>Let <var>text</var> be the empty string.</p></li><li>
    <p>For each <a id="the-option-element:descendant" href="https://dom.spec.whatwg.org/#concept-tree-descendant" data-x-internal="descendant">descendant</a> <var>descendant</var> of <var>option</var> in <a id="the-option-element:tree-order-4" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

    <ol><li><p>If <var>descendant</var> is a <code id="the-option-element:the-script-element-2"><a href="#the-script-element">script</a></code> or <a id="the-option-element:svg-script" href="https://svgwg.org/svg2-draft/interact.html#ScriptElement" data-x-internal="svg-script">SVG
     <code>script</code></a> element, then <a id="the-option-element:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a> skipping all <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="the-option-element:descendant-2" data-x-internal="descendant">descendants</a> of <var>descendant</var>.</p></li><li><p>If <var>descendant</var> is a <code id="the-option-element:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, then set <var>text</var> to the
     concatenation of <var>text</var> and <var>descendant</var>'s <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="the-option-element:concept-cd-data" data-x-internal="concept-cd-data">data</a>.</p></li><li>
      <p>If <var>descendant</var> is an <code id="the-option-element:the-img-element"><a href="#the-img-element">img</a></code> element and <var>includeAltText</var> is
      true, then:</p>

      <ol><li><p>If the value of <var>descendant</var>'s <code id="the-option-element:attr-img-alt"><a href="#attr-img-alt">alt</a></code>
       attribute is not empty, then set <var>text</var> to the concatenation of <var>text</var>,
       <code>" "</code>, the value of <var>descendant</var>'s <code id="the-option-element:attr-img-alt-2"><a href="#attr-img-alt">alt</a></code> attribute, and <code>" "</code>.</p></li><li><p><a id="the-option-element:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a> skipping all <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="the-option-element:descendant-3" data-x-internal="descendant">descendants</a> of
       <var>descendant</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Return the result of <a id="the-option-element:strip-and-collapse-ascii-whitespace" href="https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace" data-x-internal="strip-and-collapse-ascii-whitespace">strip and collapse ASCII whitespace</a> given
   <var>text</var>.</p></li></ol>
  </div>

  

  <p id="note-option-no-value" class="note"><a href="#note-option-no-value" class="self-link"></a>When no <code id="the-option-element:attr-option-value-7"><a href="#attr-option-value">value</a></code>
  attribute is set on the <code id="the-option-element:the-option-element-34"><a href="#the-option-element">option</a></code> element, its text contents are used to generate a
  submittable value. In the case that the <code id="the-option-element:the-option-element-35"><a href="#the-option-element">option</a></code> element has child elements, this can
  lead to unexpected results such as <code id="the-option-element:the-option-element-36"><a href="#the-option-element">option</a></code> elements which render differently but have
  the same value. In order to address this, setting the <code id="the-option-element:attr-option-value-8"><a href="#attr-option-value">value</a></code> attribute on <code id="the-option-element:the-option-element-37"><a href="#the-option-element">option</a></code> elements is
  recommended.</p>



  <h4 id="the-textarea-element"><span class="secno">4.10.11</span> The <dfn data-dfn-type="element"><code>textarea</code></dfn> element<a href="#the-textarea-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea" title="The <textarea> HTML element represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text, for example a comment on a review or feedback form.">Element/textarea</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement" title="The HTMLTextAreaElement interface provides special properties and methods for manipulating the layout and presentation of <textarea> elements.">HTMLTextAreaElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-textarea-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-textarea-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-textarea-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#interactive-content-2" id="the-textarea-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#category-listed" id="the-textarea-element:category-listed">Listed</a>, <a href="#category-label" id="the-textarea-element:category-label">labelable</a>, <a href="#category-submit" id="the-textarea-element:category-submit">submittable</a>, <a href="#category-reset" id="the-textarea-element:category-reset">resettable</a>, and <a href="#category-autocapitalize" id="the-textarea-element:category-autocapitalize">autocapitalize-and-autocorrect inheriting</a> <a href="#form-associated-element" id="the-textarea-element:form-associated-element">form-associated element</a>.</dd><dd><a href="#palpable-content-2" id="the-textarea-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-textarea-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-textarea-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-textarea-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#text-content" id="the-textarea-element:text-content">Text</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-textarea-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-textarea-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-textarea-element:global-attributes">Global attributes</a></dd><dd><code id="the-textarea-element:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code> —  Hint for form autofill feature
     </dd><dd><code id="the-textarea-element:attr-textarea-cols"><a href="#attr-textarea-cols">cols</a></code> —  Maximum number of characters per line
     </dd><dd><code id="the-textarea-element:attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code> —  Name of form control to use for sending the element's <a href="#the-directionality" id="the-textarea-element:the-directionality">directionality</a> in <a href="#form-submission-2" id="the-textarea-element:form-submission-2">form submission</a>
     </dd><dd><code id="the-textarea-element:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code> —  Whether the form control is disabled
     </dd><dd><code id="the-textarea-element:attr-fae-form"><a href="#attr-fae-form">form</a></code> —  Associates the element with a <code id="the-textarea-element:the-form-element"><a href="#the-form-element">form</a></code> element
     </dd><dd><code id="the-textarea-element:attr-textarea-maxlength"><a href="#attr-textarea-maxlength">maxlength</a></code> —  Maximum <a id="the-textarea-element:length" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of value
     </dd><dd><code id="the-textarea-element:attr-textarea-minlength"><a href="#attr-textarea-minlength">minlength</a></code> —  Minimum <a id="the-textarea-element:length-2" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of value
     </dd><dd><code id="the-textarea-element:attr-fe-name"><a href="#attr-fe-name">name</a></code> —  Name of the element to use for <a href="#form-submission-2" id="the-textarea-element:form-submission-2-2">form submission</a> and in the <code id="the-textarea-element:dom-form-elements"><a href="#dom-form-elements">form.elements</a></code> API 
     </dd><dd><code id="the-textarea-element:attr-textarea-placeholder"><a href="#attr-textarea-placeholder">placeholder</a></code> —  User-visible label to be placed within the form control
     </dd><dd><code id="the-textarea-element:attr-textarea-readonly"><a href="#attr-textarea-readonly">readonly</a></code> —  Whether to allow the value to be edited by the user
     </dd><dd><code id="the-textarea-element:attr-textarea-required"><a href="#attr-textarea-required">required</a></code> —  Whether the control is required for <a href="#form-submission-2" id="the-textarea-element:form-submission-2-3">form submission</a>
     </dd><dd><code id="the-textarea-element:attr-textarea-rows"><a href="#attr-textarea-rows">rows</a></code> —  Number of lines to show
     </dd><dd><code id="the-textarea-element:attr-textarea-wrap"><a href="#attr-textarea-wrap">wrap</a></code> —  How the value of the form control is to be wrapped for <a href="#form-submission-2" id="the-textarea-element:form-submission-2-4">form submission</a>
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-textarea-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-textarea">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-textarea">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-textarea-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltextareaelement" data-dfn-type="interface"><c- g="">HTMLTextAreaElement</c-></dfn> : <a href="#htmlelement" id="the-textarea-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-textarea-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-textarea-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-textarea-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fe-autocomplete" id="the-textarea-element:dom-fe-autocomplete"><c- g="">autocomplete</c-></a>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectpositivewithfallback" id="the-textarea-element:xattr-reflectpositivewithfallback"><c- g="">ReflectPositiveWithFallback</c-></a>, <a href="#xattr-reflectdefault" id="the-textarea-element:xattr-reflectdefault">ReflectDefault=20</a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-cols" data-dfn-type="attribute"><c- g="">cols</c-></dfn>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-textarea-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-dirname" data-dfn-type="attribute"><c- g="">dirName</c-></dfn>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-textarea-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-disabled" data-dfn-type="attribute"><c- g="">disabled</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-textarea-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-fae-form" id="the-textarea-element:dom-fae-form"><c- g="">form</c-></a>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectnonnegative" id="the-textarea-element:xattr-reflectnonnegative"><c- g="">ReflectNonNegative</c-></a>] <c- b="">attribute</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-maxlength" data-dfn-type="attribute"><c- g="">maxLength</c-></dfn>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectnonnegative" id="the-textarea-element:xattr-reflectnonnegative-2"><c- g="">ReflectNonNegative</c-></a>] <c- b="">attribute</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-minlength" data-dfn-type="attribute"><c- g="">minLength</c-></dfn>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-textarea-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-textarea-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-placeholder" data-dfn-type="attribute"><c- g="">placeholder</c-></dfn>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-9"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-textarea-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-readonly" data-dfn-type="attribute"><c- g="">readOnly</c-></dfn>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-10"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-textarea-element:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-required" data-dfn-type="attribute"><c- g="">required</c-></dfn>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-11"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectpositivewithfallback" id="the-textarea-element:xattr-reflectpositivewithfallback-2"><c- g="">ReflectPositiveWithFallback</c-></a>, <a href="#xattr-reflectdefault" id="the-textarea-element:xattr-reflectdefault-2">ReflectDefault=2</a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-rows" data-dfn-type="attribute"><c- g="">rows</c-></dfn>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-12"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-textarea-element:xattr-reflect-7"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-wrap" data-dfn-type="attribute"><c- g="">wrap</c-></dfn>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-textarea-type" id="the-textarea-element:dom-textarea-type"><c- g="">type</c-></a>;
  [<a href="#cereactions" id="the-textarea-element:cereactions-13"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-textarea-defaultvalue" id="the-textarea-element:dom-textarea-defaultvalue"><c- g="">defaultValue</c-></a>;
  <c- b="">attribute</c-> [<a id="the-textarea-element:legacynulltoemptystring" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <a href="#dom-textarea-value" id="the-textarea-element:dom-textarea-value"><c- g="">value</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-textarea-textlength" id="the-textarea-element:dom-textarea-textlength"><c- g="">textLength</c-></a>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-cva-willvalidate" id="the-textarea-element:dom-cva-willvalidate"><c- g="">willValidate</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#validitystate" id="the-textarea-element:validitystate"><c- n="">ValidityState</c-></a> <a href="#dom-cva-validity" id="the-textarea-element:dom-cva-validity"><c- g="">validity</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-cva-validationmessage" id="the-textarea-element:dom-cva-validationmessage"><c- g="">validationMessage</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-cva-checkvalidity" id="the-textarea-element:dom-cva-checkvalidity"><c- g="">checkValidity</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-cva-reportvalidity" id="the-textarea-element:dom-cva-reportvalidity"><c- g="">reportValidity</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-cva-setcustomvalidity" id="the-textarea-element:dom-cva-setcustomvalidity"><c- g="">setCustomValidity</c-></a>(<c- b="">DOMString</c-> <c- g="">error</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-textarea-element:nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist" data-x-internal="nodelist"><c- n="">NodeList</c-></a> <a href="#dom-lfe-labels" id="the-textarea-element:dom-lfe-labels"><c- g="">labels</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-textarea/input-select" id="the-textarea-element:dom-textarea/input-select"><c- g="">select</c-></a>();
  <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-textarea/input-selectionstart" id="the-textarea-element:dom-textarea/input-selectionstart"><c- g="">selectionStart</c-></a>;
  <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-textarea/input-selectionend" id="the-textarea-element:dom-textarea/input-selectionend"><c- g="">selectionEnd</c-></a>;
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-textarea/input-selectiondirection" id="the-textarea-element:dom-textarea/input-selectiondirection"><c- g="">selectionDirection</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-textarea/input-setrangetext" id="the-textarea-element:dom-textarea/input-setrangetext"><c- g="">setRangeText</c-></a>(<c- b="">DOMString</c-> <c- g="">replacement</c->);
  <c- b="">undefined</c-> <a href="#dom-textarea/input-setrangetext" id="the-textarea-element:dom-textarea/input-setrangetext-2"><c- g="">setRangeText</c-></a>(<c- b="">DOMString</c-> <c- g="">replacement</c->, <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">start</c->, <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">end</c->, <c- b="">optional</c-> <a href="#selectionmode" id="the-textarea-element:selectionmode"><c- n="">SelectionMode</c-></a> <c- g="">selectionMode</c-> = "preserve");
  <c- b="">undefined</c-> <a href="#dom-textarea/input-setselectionrange" id="the-textarea-element:dom-textarea/input-setselectionrange"><c- g="">setSelectionRange</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">start</c->, <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">end</c->, <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">direction</c->);
};</code></pre>
   </dd></dl>

  <p>The <code id="the-textarea-element:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element <a href="#represents" id="the-textarea-element:represents">represents</a> a multiline plain text edit
  control for the element's <dfn id="concept-textarea-raw-value">raw
  value</dfn>. The contents of the control represent the control's default value.</p>

  

  <p>The <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value">raw value</a> of a <code id="the-textarea-element:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code>
  control must be initially the empty string.</p>

  <p class="note">This element <a href="#bidireq">has rendering requirements involving the
  bidirectional algorithm</a>.</p>

  

  <p>The <dfn data-dfn-for="textarea" id="attr-textarea-readonly" data-dfn-type="element-attr"><code>readonly</code></dfn> attribute is a <a href="#boolean-attribute" id="the-textarea-element:boolean-attribute">boolean
  attribute</a> used to control whether the text can be edited by the user or not.</p>

  <div class="example">

   <p>In this example, a text control is marked read-only because it represents a read-only
   file:</p>

   <pre><code class="html">Filename: <c- p="">&lt;</c-><c- f="">code</c-><c- p="">&gt;</c->/etc/bash.bashrc<c- p="">&lt;/</c-><c- f="">code</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"buffer"</c-> <c- e="">readonly</c-><c- p="">&gt;</c->
# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] <c- ni="">&amp;amp;&amp;amp;</c-> return

...<c- p="">&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the <code id="the-textarea-element:attr-textarea-readonly-2"><a href="#attr-textarea-readonly">readonly</a></code> attribute is specified on a <code id="the-textarea-element:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code>
  element, the element is <a href="#barred-from-constraint-validation" id="the-textarea-element:barred-from-constraint-validation">barred from constraint validation</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-textarea-element:the-textarea-element-4"><a href="#the-textarea-element">textarea</a></code> element is <a href="#concept-fe-mutable" id="the-textarea-element:concept-fe-mutable">mutable</a> if it is
  neither <a href="#concept-fe-disabled" id="the-textarea-element:concept-fe-disabled">disabled</a> nor has a <code id="the-textarea-element:attr-textarea-readonly-3"><a href="#attr-textarea-readonly">readonly</a></code> attribute specified.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="the-textarea-element:the-textarea-element-5"><a href="#the-textarea-element">textarea</a></code> is <a href="#concept-fe-mutable" id="the-textarea-element:concept-fe-mutable-2">mutable</a>, its <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-2">raw value</a> should be editable by the user: the user
  agent should allow the user to edit, insert, and remove text, and to insert and remove line breaks
  in the form of U+000A LINE FEED (LF) characters. Any time the user causes the element's <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-3">raw value</a> to change, the user agent must <a href="#queue-an-element-task" id="the-textarea-element:queue-an-element-task">queue an
  element task</a> on the <a href="#user-interaction-task-source" id="the-textarea-element:user-interaction-task-source">user interaction task source</a> given the
  <code id="the-textarea-element:the-textarea-element-6"><a href="#the-textarea-element">textarea</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-textarea-element:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named
  <code id="the-textarea-element:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the <code id="the-textarea-element:the-textarea-element-7"><a href="#the-textarea-element">textarea</a></code> element, with the <code id="the-textarea-element:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="the-textarea-element:dom-event-composed"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code>
  attributes initialized to true. User agents may wait for a suitable break in the user's
  interaction before queuing the task; for example, a user agent could wait for the user to have not
  hit a key for 100ms, so as to only fire the event when the user pauses, instead of continuously
  for each keystroke.</p>
  </div>
  

  <div data-algorithm="">
  <p>A <code id="the-textarea-element:the-textarea-element-8"><a href="#the-textarea-element">textarea</a></code> element's <a href="#concept-fe-dirty" id="the-textarea-element:concept-fe-dirty">dirty value flag</a> must
  be set to true whenever the user interacts with the control in a way that changes the <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-4">raw value</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="https://dom.spec.whatwg.org/#concept-node-clone-ext" id="the-textarea-element:concept-node-clone-ext" data-x-internal="concept-node-clone-ext">cloning steps</a> for <code id="the-textarea-element:the-textarea-element-9"><a href="#the-textarea-element">textarea</a></code>
  elements given <var>node</var>, <var>copy</var>, and <var>subtree</var> are to propagate the <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-5">raw value</a> and <a href="#concept-fe-dirty" id="the-textarea-element:concept-fe-dirty-2">dirty
  value flag</a> from <var>node</var> to <var>copy</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-textarea-element:children-changed-steps" href="https://dom.spec.whatwg.org/#concept-node-children-changed-ext" data-x-internal="children-changed-steps">children changed steps</a> for <code id="the-textarea-element:the-textarea-element-10"><a href="#the-textarea-element">textarea</a></code> elements must, if the
  element's <a href="#concept-fe-dirty" id="the-textarea-element:concept-fe-dirty-3">dirty value flag</a> is false, set the element's
  <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-6">raw value</a> to its <a id="the-textarea-element:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text
  content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#concept-form-reset-control" id="the-textarea-element:concept-form-reset-control">reset algorithm</a> for <code id="the-textarea-element:the-textarea-element-11"><a href="#the-textarea-element">textarea</a></code>
  elements is to set the <a href="#user-validity" id="the-textarea-element:user-validity">user validity</a> to false, the <a href="#concept-fe-dirty" id="the-textarea-element:concept-fe-dirty-4">dirty value flag</a> back to false, and the <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-7">raw value</a> to its <a id="the-textarea-element:child-text-content-2" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text
  content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="the-textarea-element:the-textarea-element-12"><a href="#the-textarea-element">textarea</a></code> element is popped off the <a href="#stack-of-open-elements" id="the-textarea-element:stack-of-open-elements">stack of open elements</a> of
  an <a href="#html-parser" id="the-textarea-element:html-parser">HTML parser</a> or <a href="#xml-parser" id="the-textarea-element:xml-parser">XML parser</a>, then the user agent must invoke the
  element's <a href="#concept-form-reset-control" id="the-textarea-element:concept-form-reset-control-2">reset algorithm</a>.</p>
  </div>

  
  
  <div data-algorithm="">
  <p>If the element is <a href="#concept-fe-mutable" id="the-textarea-element:concept-fe-mutable-3">mutable</a>, the user agent should allow
  the user to change the writing direction of the element, setting it either to a left-to-right
  writing direction or a right-to-left writing direction. If the user does so, the user agent must
  then run the following steps:</p>

  <ol><li><p>Set the element's <code id="the-textarea-element:attr-dir"><a href="#attr-dir">dir</a></code> attribute to "<code id="the-textarea-element:attr-dir-ltr"><a href="#attr-dir-ltr">ltr</a></code>" if the user selected a left-to-right writing direction, and
   "<code id="the-textarea-element:attr-dir-rtl"><a href="#attr-dir-rtl">rtl</a></code>" if the user selected a right-to-left writing
   direction.</p></li><li><p><a href="#queue-an-element-task" id="the-textarea-element:queue-an-element-task-2">Queue an element task</a> on the <a href="#user-interaction-task-source" id="the-textarea-element:user-interaction-task-source-2">user interaction task source</a> given
   the <code id="the-textarea-element:the-textarea-element-13"><a href="#the-textarea-element">textarea</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-textarea-element:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named
   <code id="the-textarea-element:event-input-2"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> at the <code id="the-textarea-element:the-textarea-element-14"><a href="#the-textarea-element">textarea</a></code> element, with the <code id="the-textarea-element:dom-event-bubbles-2"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="the-textarea-element:dom-event-composed-2"><a data-x-internal="dom-event-composed" href="https://dom.spec.whatwg.org/#dom-event-composed">composed</a></code>
   attributes initialized to true.</p></li></ol>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="textarea" id="attr-textarea-cols" data-dfn-type="element-attr"><code>cols</code></dfn>
  attribute specifies the expected maximum number of characters per line. If the <code id="the-textarea-element:attr-textarea-cols-2"><a href="#attr-textarea-cols">cols</a></code> attribute is specified, its value must be a <a href="#valid-non-negative-integer" id="the-textarea-element:valid-non-negative-integer">valid
  non-negative integer</a> greater than zero. If applying the <a href="#rules-for-parsing-non-negative-integers" id="the-textarea-element:rules-for-parsing-non-negative-integers">rules for
  parsing non-negative integers</a> to the attribute's value results in a number greater than
  zero, then the element's <dfn id="attr-textarea-cols-value">character width</dfn> is that
  value; otherwise, it is 20.</p>
  </div>

  

  <p>The user agent may use the <code id="the-textarea-element:the-textarea-element-15"><a href="#the-textarea-element">textarea</a></code> element's <a href="#attr-textarea-cols-value" id="the-textarea-element:attr-textarea-cols-value">character width</a> as a hint to the user as to how many
  characters the server prefers per line (e.g. for visual user agents by making the width of the
  control be that many characters). In visual renderings, the user agent should wrap the user's
  input in the rendering so that each line is no wider than this number of characters.</p>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="textarea" id="attr-textarea-rows" data-dfn-type="element-attr"><code>rows</code></dfn>
  attribute specifies the number of lines to show. If the <code id="the-textarea-element:attr-textarea-rows-2"><a href="#attr-textarea-rows">rows</a></code> attribute is specified, its value must be a <a href="#valid-non-negative-integer" id="the-textarea-element:valid-non-negative-integer-2">valid
  non-negative integer</a> greater than zero. If applying the <a href="#rules-for-parsing-non-negative-integers" id="the-textarea-element:rules-for-parsing-non-negative-integers-2">rules for
  parsing non-negative integers</a> to the attribute's value results in a number greater than
  zero, then the element's <dfn id="attr-textarea-rows-value">character height</dfn> is that
  value; otherwise, it is 2.</p>
  </div>

  

  <p>Visual user agents should set the height of the control to the number of lines given by <a href="#attr-textarea-rows-value" id="the-textarea-element:attr-textarea-rows-value">character height</a>.</p>

  

  <p>The <dfn data-dfn-for="textarea" id="attr-textarea-wrap" data-dfn-type="element-attr"><code>wrap</code></dfn>
  attribute is an <a href="#enumerated-attribute" id="the-textarea-element:enumerated-attribute">enumerated attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="textarea/wrap" id="attr-textarea-wrap-soft" data-dfn-type="attr-value"><code>soft</code></dfn>
     </td><td><dfn id="attr-textarea-wrap-soft-state">Soft</dfn>
     </td><td>Text is not to be wrapped when submitted (though can still be wrapped in the rendering).
    </td></tr><tr><td><dfn data-dfn-for="textarea/wrap" id="attr-textarea-wrap-hard" data-dfn-type="attr-value"><code>hard</code></dfn>
     </td><td><dfn id="attr-textarea-wrap-hard-state">Hard</dfn>
     </td><td>Text is to have newlines added by the user agent so that the text is wrapped when it is
     submitted.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-textarea-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-textarea-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#attr-textarea-wrap-soft-state" id="the-textarea-element:attr-textarea-wrap-soft-state">Soft</a> state.</p>
  </div>

  <p>If the element's <code id="the-textarea-element:attr-textarea-wrap-2"><a href="#attr-textarea-wrap">wrap</a></code> attribute is in the <a href="#attr-textarea-wrap-hard-state" id="the-textarea-element:attr-textarea-wrap-hard-state">Hard</a> state, the <code id="the-textarea-element:attr-textarea-cols-3"><a href="#attr-textarea-cols">cols</a></code> attribute must be specified.</p>

  

  

  <p>For historical reasons, the element's value is normalized in three different ways for three
  different purposes. The <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-8">raw value</a> is the value as
  it was originally set. It is not normalized. The <a href="#concept-fe-api-value" id="the-textarea-element:concept-fe-api-value">API
  value</a> is the value used in the <code id="the-textarea-element:dom-textarea-value-2"><a href="#dom-textarea-value">value</a></code> IDL
  attribute, <code id="the-textarea-element:dom-textarea-textlength-2"><a href="#dom-textarea-textlength">textLength</a></code> IDL attribute, and by the
  <code id="the-textarea-element:attr-fe-maxlength"><a href="#attr-fe-maxlength">maxlength</a></code> and <code id="the-textarea-element:attr-fe-minlength"><a href="#attr-fe-minlength">minlength</a></code> content attributes. It is normalized so that line
  breaks use U+000A LINE FEED (LF) characters. Finally, there is the <a href="#concept-fe-value" id="the-textarea-element:concept-fe-value">value</a>, as used in form submission and other processing models in
  this specification. It is normalized as for the <a href="#concept-fe-api-value" id="the-textarea-element:concept-fe-api-value-2">API
  value</a>, and in addition, if necessary given the element's <code id="the-textarea-element:attr-textarea-wrap-3"><a href="#attr-textarea-wrap">wrap</a></code> attribute, additional line breaks are inserted to wrap the
  text at the given width.</p>

  <div data-algorithm="">
  <p id="textarea-line-break-normalisation-transformation">The algorithm for obtaining
  the element's <a href="#concept-fe-api-value" id="the-textarea-element:concept-fe-api-value-3">API value</a> is to return the element's
  <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-9">raw value</a>, with <a href="https://infra.spec.whatwg.org/#normalize-newlines" id="the-textarea-element:normalize-newlines" data-x-internal="normalize-newlines">newlines normalized</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The element's <a href="#concept-fe-value" id="the-textarea-element:concept-fe-value-2">value</a> is defined to be the element's <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-10">API value</a> with the <a href="#textarea-wrapping-transformation" id="the-textarea-element:textarea-wrapping-transformation">textarea wrapping
  transformation</a> applied. The <dfn id="textarea-wrapping-transformation">textarea wrapping transformation</dfn> is the following
  algorithm, as applied to a string:</p>

  <ol><li><p>If the element's <code id="the-textarea-element:attr-textarea-wrap-4"><a href="#attr-textarea-wrap">wrap</a></code> attribute is in the <a href="#attr-textarea-wrap-hard-state" id="the-textarea-element:attr-textarea-wrap-hard-state-2">Hard</a> state, insert U+000A LINE FEED (LF) characters
   into the string using an <a id="the-textarea-element:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> algorithm so that each line has no
   more than <a href="#attr-textarea-cols-value" id="the-textarea-element:attr-textarea-cols-value-2">character width</a> characters. For the
   purposes of this requirement, lines are delimited by the start of the string, the end of the
   string, and U+000A LINE FEED (LF) characters.</p></li></ol>
  </div>

  

  <p>The <dfn data-dfn-for="textarea" id="attr-textarea-maxlength" data-dfn-type="element-attr"><code>maxlength</code></dfn> attribute is a <a href="#attr-fe-maxlength" id="the-textarea-element:attr-fe-maxlength-2">form control <code>maxlength</code> attribute</a>.</p>

  <p>If the <code id="the-textarea-element:the-textarea-element-16"><a href="#the-textarea-element">textarea</a></code> element has a <a href="#maximum-allowed-value-length" id="the-textarea-element:maximum-allowed-value-length">maximum allowed value length</a>, then the
  element's children must be such that the <a id="the-textarea-element:length-3" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the value of the element's
  <a id="the-textarea-element:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a> with <a href="https://infra.spec.whatwg.org/#normalize-newlines" id="the-textarea-element:normalize-newlines-2" data-x-internal="normalize-newlines">newlines
  normalized</a> is less than or equal to the element's <a href="#maximum-allowed-value-length" id="the-textarea-element:maximum-allowed-value-length-2">maximum allowed value
  length</a>.</p>

  <p>The <dfn data-dfn-for="textarea" id="attr-textarea-minlength" data-dfn-type="element-attr"><code>minlength</code></dfn> attribute is a <a href="#attr-fe-minlength" id="the-textarea-element:attr-fe-minlength-2">form control <code>minlength</code> attribute</a>.</p>

  

  <p>The <dfn data-dfn-for="textarea" id="attr-textarea-required" data-dfn-type="element-attr"><code>required</code></dfn> attribute is a <a href="#boolean-attribute" id="the-textarea-element:boolean-attribute-2">boolean
  attribute</a>. When specified, the user will be required to enter a value before submitting the
  form.</p>

  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the element has its <code id="the-textarea-element:attr-textarea-required-2"><a href="#attr-textarea-required">required</a></code> attribute specified, and the element is <a href="#concept-fe-mutable" id="the-textarea-element:concept-fe-mutable-4">mutable</a>, and the element's <a href="#concept-fe-value" id="the-textarea-element:concept-fe-value-3">value</a> is the empty string, then the element is <a href="#suffering-from-being-missing" id="the-textarea-element:suffering-from-being-missing">suffering
  from being missing</a>.</p>
  </div>

  


  

  <p>The <dfn data-dfn-for="textarea" id="attr-textarea-placeholder" data-dfn-type="element-attr"><code>placeholder</code></dfn> attribute represents a <em>short</em>
  hint (a word or short phrase) intended to aid the user with data entry when the control has no
  value. A hint could be a sample value or a brief description of the expected format.</p>

  <p>The <code id="the-textarea-element:attr-textarea-placeholder-2"><a href="#attr-textarea-placeholder">placeholder</a></code> attribute should not be used as
  an alternative to a <code id="the-textarea-element:the-label-element"><a href="#the-label-element">label</a></code>. For a longer hint or other advisory text, the <code id="the-textarea-element:attr-title"><a href="#attr-title">title</a></code> attribute is more appropriate.</p>

  <p class="note">These mechanisms are very similar but subtly different: the hint given by the
  control's <code id="the-textarea-element:the-label-element-2"><a href="#the-label-element">label</a></code> is shown at all times; the short hint given in the <code id="the-textarea-element:attr-textarea-placeholder-3"><a href="#attr-textarea-placeholder">placeholder</a></code> attribute is shown before the user enters a
  value; and the hint in the <code id="the-textarea-element:attr-title-2"><a href="#attr-title">title</a></code> attribute is shown when the user
  requests further help.</p>

  

  <p>User agents should present this hint to the user when the element's <a href="#concept-fe-value" id="the-textarea-element:concept-fe-value-4">value</a> is the empty string and the control is not
  <a href="#focused" id="the-textarea-element:focused">focused</a> (e.g. by displaying it inside a blank unfocused control). All U+000D CARRIAGE
  RETURN U+000A LINE FEED character pairs (CRLF) in the hint, as well as all other U+000D CARRIAGE
  RETURN (CR) and U+000A LINE FEED (LF) characters in the hint, must be treated as line breaks when
  rendering the hint.</p>

  <p>If a user agent normally doesn't show this hint to the user when the control is
  <a href="#focused" id="the-textarea-element:focused-2">focused</a>, then the user agent should nonetheless show the hint for the control if it
  was focused as a result of the <code id="the-textarea-element:attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code> attribute, since
  in that case the user will not have had an opportunity to examine the control before focusing
  it.</p>

  

  <p>
  The <code id="the-textarea-element:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attribute represents the element's name.
  The <code id="the-textarea-element:attr-fe-dirname-2"><a href="#attr-fe-dirname">dirname</a></code> attribute controls how the element's <a href="#the-directionality" id="the-textarea-element:the-directionality-2">directionality</a> is submitted.
  The <code id="the-textarea-element:attr-fe-disabled-2"><a href="#attr-fe-disabled">disabled</a></code> attribute is used to make the control
  non-interactive and to prevent its value from being submitted.
  The <code id="the-textarea-element:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> attribute is used to explicitly associate the
  <code id="the-textarea-element:the-textarea-element-17"><a href="#the-textarea-element">textarea</a></code> element with its <a href="#form-owner" id="the-textarea-element:form-owner">form owner</a>.
  The <code id="the-textarea-element:attr-fe-autocomplete-2"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute controls how the user agent
  provides autofill behavior.
  </p>

  <dl class="domintro"><dt><code><var>textarea</var>.<a href="#dom-textarea-type" id="dom-textarea-type-dev">type</a></code></dt><dd><p>Returns the string "<code>textarea</code>".</p></dd><dt><code><var>textarea</var>.<a href="#dom-textarea-value" id="dom-textarea-value-dev">value</a></code></dt><dd>
    <p>Returns the current value of the element.</p>

    <p>Can be set, to change the value.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-type" data-dfn-type="attribute"><code>type</code></dfn>
  IDL attribute must return the value "<code>textarea</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-defaultvalue" data-dfn-type="attribute"><code>defaultValue</code></dfn> attribute's getter must return the
  element's <a id="the-textarea-element:child-text-content-3" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a>.
  </p></div>

  <div data-algorithm="">
  <p>The <code id="the-textarea-element:dom-textarea-defaultvalue-2"><a href="#dom-textarea-defaultvalue">defaultValue</a></code> attribute's setter must
  <a id="the-textarea-element:string-replace-all" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">string replace all</a> with the given value within this element.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-value" data-dfn-type="attribute"><code>value</code></dfn> IDL attribute must, on getting, return the
  element's <a href="#concept-fe-api-value" id="the-textarea-element:concept-fe-api-value-4">API value</a>. On setting, it must perform the
  following steps:</p>

  <ol><li><p>Let <var>oldAPIValue</var> be this element's <a href="#concept-fe-api-value" id="the-textarea-element:concept-fe-api-value-5">API value</a>.</p></li><li><p>Set this element's <a href="#concept-textarea-raw-value" id="the-textarea-element:concept-textarea-raw-value-11">raw value</a> to the new
   value.</p></li><li><p>Set this element's <a href="#concept-fe-dirty" id="the-textarea-element:concept-fe-dirty-5">dirty value flag</a> to
   true.</p></li><li><p>If the new <a href="#concept-fe-api-value" id="the-textarea-element:concept-fe-api-value-6">API value</a> is different from
   <var>oldAPIValue</var>, then move the <a href="#concept-textarea/input-cursor" id="the-textarea-element:concept-textarea/input-cursor">text entry
   cursor position</a> to the end of the text control, unselecting any selected text and <a href="#set-the-selection-direction" id="the-textarea-element:set-the-selection-direction">resetting the selection direction</a> to "<code>none</code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTextAreaElement" id="dom-textarea-textlength" data-dfn-type="attribute"><code>textLength</code></dfn> IDL attribute must return the
  <a id="the-textarea-element:length-4" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the element's <a href="#concept-fe-api-value" id="the-textarea-element:concept-fe-api-value-7">API value</a>.</p>
  </div>

  <p>The <code id="the-textarea-element:dom-cva-willvalidate-2"><a href="#dom-cva-willvalidate">willValidate</a></code>, <code id="the-textarea-element:dom-cva-validity-2"><a href="#dom-cva-validity">validity</a></code>, and <code id="the-textarea-element:dom-cva-validationmessage-2"><a href="#dom-cva-validationmessage">validationMessage</a></code> IDL attributes, and the <code id="the-textarea-element:dom-cva-checkvalidity-2"><a href="#dom-cva-checkvalidity">checkValidity()</a></code>, <code id="the-textarea-element:dom-cva-reportvalidity-2"><a href="#dom-cva-reportvalidity">reportValidity()</a></code>, and <code id="the-textarea-element:dom-cva-setcustomvalidity-2"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> methods, are part of the
  <a href="#the-constraint-validation-api" id="the-textarea-element:the-constraint-validation-api">constraint validation API</a>. The <code id="the-textarea-element:dom-lfe-labels-2"><a href="#dom-lfe-labels">labels</a></code> IDL
  attribute provides a list of the element's <code id="the-textarea-element:the-label-element-3"><a href="#the-label-element">label</a></code>s. The <code id="the-textarea-element:dom-textarea/input-select-2"><a href="#dom-textarea/input-select">select()</a></code>, <code id="the-textarea-element:dom-textarea/input-selectionstart-2"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code>, <code id="the-textarea-element:dom-textarea/input-selectionend-2"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code>, <code id="the-textarea-element:dom-textarea/input-selectiondirection-2"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>, <code id="the-textarea-element:dom-textarea/input-setrangetext-3"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code>, and <code id="the-textarea-element:dom-textarea/input-setselectionrange-2"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> methods and IDL
  attributes expose the element's text selection. The <code id="the-textarea-element:dom-textarea-disabled"><a href="#dom-textarea-disabled">disabled</a></code>, <code id="the-textarea-element:dom-fae-form-2"><a href="#dom-fae-form">form</a></code>, and <code id="the-textarea-element:dom-textarea-name"><a href="#dom-textarea-name">name</a></code> IDL attributes are part of the element's forms API.</p>

  

  <div class="example">

   <p>Here is an example of a <code id="the-textarea-element:the-textarea-element-18"><a href="#the-textarea-element">textarea</a></code> being used for unrestricted free-form text input
   in a form:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If you have any comments, please let us know: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">cols</c-><c- o="">=</c-><c- s="">80</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">comments</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>To specify a maximum length for the comments, one can use the <code id="the-textarea-element:attr-textarea-maxlength-2"><a href="#attr-textarea-maxlength">maxlength</a></code> attribute:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If you have any short comments, please let us know: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">cols</c-><c- o="">=</c-><c- s="">80</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">comments</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">200</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>To give a default value, text can be included inside the element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If you have any comments, please let us know: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">cols</c-><c- o="">=</c-><c- s="">80</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">comments</c-><c- p="">&gt;</c->You rock!<c- p="">&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>You can also give a minimum length. Here, a letter needs to be filled out by the user; a
   template (which is shorter than the minimum length) is provided, but is insufficient to submit
   the form:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">required</c-> <c- e="">minlength</c-><c- o="">=</c-><c- s="">"500"</c-><c- p="">&gt;</c->Dear Madam Speaker,

Regarding your letter dated ...

...

Yours Sincerely,

...<c- p="">&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;</c-></code></pre>

   <p>A placeholder can be given as well, to suggest the basic form to the user, without providing
   an explicit template:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">placeholder</c-><c- o="">=</c-><c- s="">"Dear Francine,</c->

<c- s="">They closed the parks this week, so we won't be able to</c->
<c- s="">meet your there. Should we just have dinner?</c->

<c- s="">Love,</c->
<c- s="">Daddy"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;</c-></code></pre>

   <p>To have the browser submit <a href="#the-directionality" id="the-textarea-element:the-directionality-3">the directionality</a> of the element along with the
   value, the <code id="the-textarea-element:attr-fe-dirname-3"><a href="#attr-fe-dirname">dirname</a></code> attribute can be specified:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->If you have any comments, please let us know (you may use either English or Hebrew for your comments):
<c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">cols</c-><c- o="">=</c-><c- s="">80</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">comments</c-> <c- e="">dirname</c-><c- o="">=</c-><c- s="">comments.dir</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-output-element"><span class="secno">4.10.12</span> The <dfn data-dfn-type="element"><code>output</code></dfn> element<a href="#the-output-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/output" title="The <output> HTML element is a container element into which a site or app can inject the results of a calculation or the outcome of a user action.">Element/output</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement" title="The HTMLOutputElement interface provides properties and methods (beyond those inherited from HTMLElement) for manipulating the layout and presentation of <output> elements.">HTMLOutputElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>9+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-output-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-output-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-output-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#category-listed" id="the-output-element:category-listed">Listed</a>, <a href="#category-label" id="the-output-element:category-label">labelable</a>, <a href="#category-reset" id="the-output-element:category-reset">resettable</a>, and <a href="#category-autocapitalize" id="the-output-element:category-autocapitalize">autocapitalize-and-autocorrect inheriting</a> <a href="#form-associated-element" id="the-output-element:form-associated-element">form-associated element</a>.</dd><dd><a href="#palpable-content-2" id="the-output-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-output-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-output-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-output-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-output-element:phrasing-content-2-3">Phrasing content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-output-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-output-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-output-element:global-attributes">Global attributes</a></dd><dd><code id="the-output-element:attr-output-for"><a href="#attr-output-for">for</a></code> —  Specifies controls from which the output was calculated
     </dd><dd><code id="the-output-element:attr-fae-form"><a href="#attr-fae-form">form</a></code> —  Associates the element with a <code id="the-output-element:the-form-element"><a href="#the-form-element">form</a></code> element
     </dd><dd><code id="the-output-element:attr-fe-name"><a href="#attr-fe-name">name</a></code>   — Name of the element to use in the <code id="the-output-element:dom-form-elements"><a href="#dom-form-elements">form.elements</a></code> API.</dd><dt><a href="#concept-element-accessibility-considerations" id="the-output-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-output">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-output">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-output-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmloutputelement" data-dfn-type="interface"><c- g="">HTMLOutputElement</c-></dfn> : <a href="#htmlelement" id="the-output-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-output-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-output-element:dom-domtokenlist-value" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-output-element:xattr-reflect">Reflect</a>="<a href="#attr-output-for" id="the-output-element:attr-output-for-2">for</a>"] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-output-element:domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLOutputElement" id="dom-output-htmlfor" data-dfn-type="attribute"><c- g="">htmlFor</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-output-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-fae-form" id="the-output-element:dom-fae-form"><c- g="">form</c-></a>;
  [<a href="#cereactions" id="the-output-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-output-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLOutputElement" id="dom-output-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-output-type" id="the-output-element:dom-output-type"><c- g="">type</c-></a>;
  [<a href="#cereactions" id="the-output-element:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-output-defaultvalue" id="the-output-element:dom-output-defaultvalue"><c- g="">defaultValue</c-></a>;
  [<a href="#cereactions" id="the-output-element:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-output-value" id="the-output-element:dom-output-value"><c- g="">value</c-></a>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-cva-willvalidate" id="the-output-element:dom-cva-willvalidate"><c- g="">willValidate</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#validitystate" id="the-output-element:validitystate"><c- n="">ValidityState</c-></a> <a href="#dom-cva-validity" id="the-output-element:dom-cva-validity"><c- g="">validity</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-cva-validationmessage" id="the-output-element:dom-cva-validationmessage"><c- g="">validationMessage</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-cva-checkvalidity" id="the-output-element:dom-cva-checkvalidity"><c- g="">checkValidity</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-cva-reportvalidity" id="the-output-element:dom-cva-reportvalidity"><c- g="">reportValidity</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-cva-setcustomvalidity" id="the-output-element:dom-cva-setcustomvalidity"><c- g="">setCustomValidity</c-></a>(<c- b="">DOMString</c-> <c- g="">error</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-output-element:nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist" data-x-internal="nodelist"><c- n="">NodeList</c-></a> <a href="#dom-lfe-labels" id="the-output-element:dom-lfe-labels"><c- g="">labels</c-></a>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-output-element:the-output-element"><a href="#the-output-element">output</a></code> element <a href="#represents" id="the-output-element:represents">represents</a> the result of a calculation performed
  by the application, or the result of a user action.</p>

  <p class="note">This element can be contrasted with the <code id="the-output-element:the-samp-element"><a href="#the-samp-element">samp</a></code> element, which is the
  appropriate element for quoting the output of other programs run previously.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/for" title="The for attribute is an allowed attribute for <label> and <output>. When used on a <label> element it indicates the form element that this label describes. When used on an <output> element it allows for an explicit relationship between the elements that represent values which are used in the output.">Attributes/for</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div><p>The <dfn data-dfn-for="output" id="attr-output-for" data-dfn-type="element-attr"><code>for</code></dfn> content
  attribute allows an explicit relationship to be made between the result of a calculation and the
  elements that represent the values that went into the calculation or that otherwise influenced the
  calculation. The <code id="the-output-element:attr-output-for-3"><a href="#attr-output-for">for</a></code> attribute, if specified, must contain a
  string consisting of an <a href="#unordered-set-of-unique-space-separated-tokens" id="the-output-element:unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</a>, none of which
  are <a id="the-output-element:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> another token and each of which must have the value of an <a href="https://dom.spec.whatwg.org/#concept-id" id="the-output-element:concept-id" data-x-internal="concept-id">ID</a> of an element in the same <a id="the-output-element:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>.</p>

  <p>The <code id="the-output-element:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> attribute is used to explicitly associate the
  <code id="the-output-element:the-output-element-2"><a href="#the-output-element">output</a></code> element with its <a href="#form-owner" id="the-output-element:form-owner">form owner</a>. The <code id="the-output-element:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attribute represents the element's name. The <code id="the-output-element:the-output-element-3"><a href="#the-output-element">output</a></code>
  element is associated with a form so that it can be easily <a href="#referenced" id="the-output-element:referenced">referenced</a> from the event
  handlers of form controls; the element's value itself is not submitted when the form is
  submitted.</p>

  

  <p>The element has a <dfn id="concept-output-default-value-override">default value
  override</dfn> (null or a string). Initially it must be null.</p>

  <div data-algorithm="">
  <p>The element's <dfn id="concept-output-default-value">default value</dfn> is determined by
  the following steps:</p>

  <ol><li><p>If this element's <a href="#concept-output-default-value-override" id="the-output-element:concept-output-default-value-override">default value
   override</a> is non-null, then return it.</p></li><li><p>Return this element's <a id="the-output-element:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#concept-form-reset-control" id="the-output-element:concept-form-reset-control">reset algorithm</a> for <code id="the-output-element:the-output-element-4"><a href="#the-output-element">output</a></code>
  elements is to run these steps:

  </p><ol><li><p><a id="the-output-element:string-replace-all" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">String replace all</a> with this element's <a href="#concept-output-default-value" id="the-output-element:concept-output-default-value">default value</a> within this element.</p></li><li><p>Set this element's <a href="#concept-output-default-value-override" id="the-output-element:concept-output-default-value-override-2">default value
   override</a> to null.</p></li></ol>
  </div>

  

  <dl class="domintro"><dt><code><var>output</var>.<a href="#dom-output-value" id="dom-output-value-dev">value</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the element's current value.</p>

    <p>Can be set, to change the value.</p>
   </dd><dt><code><var>output</var>.<a href="#dom-output-defaultvalue" id="dom-output-defaultvalue-dev">defaultValue</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the element's current default value.</p>

    <p>Can be set, to change the default value.</p>
   </dd><dt><code><var>output</var>.<a href="#dom-output-type" id="dom-output-type-dev">type</a></code></dt><dd><p>Returns the string "<code>output</code>".</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOutputElement" id="dom-output-value" data-dfn-type="attribute"><code>value</code></dfn>
  getter steps are to return <a id="the-output-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-output-element:descendant-text-content-2" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-output-element:dom-output-value-2"><a href="#dom-output-value">value</a></code> setter steps are:</p>

  <ol><li><p>Set <a id="the-output-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-output-default-value-override" id="the-output-element:concept-output-default-value-override-3">default value
   override</a> to its <a href="#concept-output-default-value" id="the-output-element:concept-output-default-value-2">default value</a>.</p></li><li><p><a id="the-output-element:string-replace-all-2" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">String replace all</a> with the given value within <a id="the-output-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOutputElement" id="dom-output-defaultvalue" data-dfn-type="attribute"><code>defaultValue</code></dfn> getter steps are to return the result
  of running <a id="the-output-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-output-default-value" id="the-output-element:concept-output-default-value-3">default
  value</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-output-element:dom-output-defaultvalue-2"><a href="#dom-output-defaultvalue">defaultValue</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-output-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-output-default-value-override" id="the-output-element:concept-output-default-value-override-4">default value
   override</a> is null, then <a id="the-output-element:string-replace-all-3" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">string replace all</a> with the given value within
   <a id="the-output-element:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and return.</p></li><li><p>Set <a id="the-output-element:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-output-default-value-override" id="the-output-element:concept-output-default-value-override-5">default value
   override</a> to the given value.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOutputElement" id="dom-output-type" data-dfn-type="attribute"><code>type</code></dfn>
  getter steps are to return "<code>output</code>".</p>
  </div>

  <p>The <code id="the-output-element:dom-cva-willvalidate-2"><a href="#dom-cva-willvalidate">willValidate</a></code>, <code id="the-output-element:dom-cva-validity-2"><a href="#dom-cva-validity">validity</a></code>, and <code id="the-output-element:dom-cva-validationmessage-2"><a href="#dom-cva-validationmessage">validationMessage</a></code> IDL attributes, and the <code id="the-output-element:dom-cva-checkvalidity-2"><a href="#dom-cva-checkvalidity">checkValidity()</a></code>, <code id="the-output-element:dom-cva-reportvalidity-2"><a href="#dom-cva-reportvalidity">reportValidity()</a></code>, and <code id="the-output-element:dom-cva-setcustomvalidity-2"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> methods, are part of the
  <a href="#the-constraint-validation-api" id="the-output-element:the-constraint-validation-api">constraint validation API</a>. The <code id="the-output-element:dom-lfe-labels-2"><a href="#dom-lfe-labels">labels</a></code> IDL
  attribute provides a list of the element's <code id="the-output-element:the-label-element"><a href="#the-label-element">label</a></code>s. The <code id="the-output-element:dom-fae-form-2"><a href="#dom-fae-form">form</a></code> and <code id="the-output-element:dom-output-name"><a href="#dom-output-name">name</a></code> IDL attributes
  are part of the element's forms API.</p>

  

  <div class="example">

   <p>A simple calculator could use <code id="the-output-element:the-output-element-5"><a href="#the-output-element">output</a></code> for its display of calculated results:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">onsubmit</c-><c- o="">=</c-><c- s="">"return false"</c-> <c- e="">oninput</c-><c- o="">=</c-><c- s="">"o.value = a.valueAsNumber + b.valueAsNumber"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">a</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">any</c-><c- p="">&gt;</c-> +
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">b</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">any</c-><c- p="">&gt;</c-> =
 <c- p="">&lt;</c-><c- f="">output</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">o</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">"a b"</c-><c- p="">&gt;&lt;/</c-><c- f="">output</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In this example, an <code id="the-output-element:the-output-element-6"><a href="#the-output-element">output</a></code> element is used to report the results of a calculation performed by a remote
   server, as they come in:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">output</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"result"</c-><c- p="">&gt;&lt;/</c-><c- f="">output</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> primeSource <c- o="">=</c-> <c- k="">new</c-> WebSocket<c- p="">(</c-><c- t="">'ws://primes.example.net/'</c-><c- p="">);</c->
 primeSource<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
   document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'result'</c-><c- p="">).</c->value <c- o="">=</c-> event<c- p="">.</c->data<c- p="">;</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="the-progress-element"><span class="secno">4.10.13</span> The <dfn data-dfn-type="element"><code>progress</code></dfn> element<a href="#the-progress-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress" title="The <progress> HTML element displays an indicator showing the completion progress of a task, typically displayed as a progress bar.">Element/progress</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLProgressElement" title="The HTMLProgressElement interface provides special properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of <progress> elements.">HTMLProgressElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-progress-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-progress-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-progress-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#category-label" id="the-progress-element:category-label">Labelable element</a>.</dd><dd><a href="#palpable-content-2" id="the-progress-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-progress-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-progress-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-progress-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-progress-element:phrasing-content-2-3">Phrasing content</a>, but there must be no <code id="the-progress-element:the-progress-element"><a href="#the-progress-element">progress</a></code> element descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-progress-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-progress-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-progress-element:global-attributes">Global attributes</a></dd><dd><code id="the-progress-element:attr-progress-value"><a href="#attr-progress-value">value</a></code> —  Current value of the element
     </dd><dd><code id="the-progress-element:attr-progress-max"><a href="#attr-progress-max">max</a></code> —  Upper bound of range
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-progress-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-progress">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-progress">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-progress-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlprogresselement" data-dfn-type="interface"><c- g="">HTMLProgressElement</c-></dfn> : <a href="#htmlelement" id="the-progress-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-progress-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-progress-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-progress-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-progress-value" id="the-progress-element:dom-progress-value"><c- g="">value</c-></a>;
  [<a href="#cereactions" id="the-progress-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectpositive" id="the-progress-element:xattr-reflectpositive"><c- g="">ReflectPositive</c-></a>, <a href="#xattr-reflectdefault" id="the-progress-element:xattr-reflectdefault">ReflectDefault=1.0</a>] <c- b="">attribute</c-> <c- b="">double</c-> <dfn id="dom-progress-max"><c- g="">max</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-progress-position" id="the-progress-element:dom-progress-position"><c- g="">position</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-progress-element:nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist" data-x-internal="nodelist"><c- n="">NodeList</c-></a> <a href="#dom-lfe-labels" id="the-progress-element:dom-lfe-labels"><c- g="">labels</c-></a>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-progress-element:the-progress-element-2"><a href="#the-progress-element">progress</a></code> element <a href="#represents" id="the-progress-element:represents">represents</a> the completion progress of a task.
  The progress is either indeterminate, indicating that progress is being made but that it is not
  clear how much more work remains to be done before the task is complete (e.g. because the task is
  waiting for a remote host to respond), or the progress is a number in the range zero to a maximum,
  giving the fraction of work that has so far been completed.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max" title="The max attribute defines the maximum value that is acceptable and valid for the input containing the attribute. If the value of the element is greater than this, the element fails validation. This value must be greater than or equal to the value of the min attribute. If the max attribute is present but is not specified or is invalid, no max value is applied. If the max attribute is valid and a non-empty value is greater than the maximum allowed by the max attribute, constraint validation will prevent form submission.">Attributes/max</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>7+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div><p>There are two attributes that determine the current task completion represented by the element.
  The <dfn data-dfn-for="progress" id="attr-progress-value" data-dfn-type="element-attr"><code>value</code></dfn>
  attribute specifies how much of the task has been completed, and the <dfn data-dfn-for="progress" id="attr-progress-max" data-dfn-type="element-attr"><code>max</code></dfn> attribute specifies how much work
  the task requires in total. The units are arbitrary and not specified.</p>

  <p class="note">To make a determinate progress bar, add a <code id="the-progress-element:attr-progress-value-2"><a href="#attr-progress-value">value</a></code> attribute with the current progress (either a number from
  0.0 to 1.0, or, if the <code id="the-progress-element:attr-progress-max-2"><a href="#attr-progress-max">max</a></code> attribute is specified, a number
  from 0 to the value of the <code id="the-progress-element:attr-progress-max-3"><a href="#attr-progress-max">max</a></code> attribute). To make an
  indeterminate progress bar, remove the <code id="the-progress-element:attr-progress-value-3"><a href="#attr-progress-value">value</a></code>
  attribute.</p>

  <p>Authors are encouraged to also include the current value and the maximum value inline as text
  inside the element, so that the progress is made available to users of legacy user agents.</p>

  <div class="example">

   <p>Here is a snippet of a web application that shows the progress of some automated task:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Task Progress<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Progress: <c- p="">&lt;</c-><c- f="">progress</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">p</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">100</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-><c- p="">&gt;</c->0<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->%<c- p="">&lt;/</c-><c- f="">progress</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> progressBar <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'p'</c-><c- p="">);</c->
  <c- a="">function</c-> updateProgress<c- p="">(</c->newValue<c- p="">)</c-> <c- p="">{</c->
    progressBar<c- p="">.</c->value <c- o="">=</c-> newValue<c- p="">;</c->
    progressBar<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'span'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">].</c->textContent <c- o="">=</c-> newValue<c- p="">;</c->
  <c- p="">}</c->
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>(The <code>updateProgress()</code> method in this example would be called by some
   other code on the page to update the actual progress bar as the task progressed.)</p>

  </div>

  <p>The <code id="the-progress-element:attr-progress-value-4"><a href="#attr-progress-value">value</a></code> and <code id="the-progress-element:attr-progress-max-4"><a href="#attr-progress-max">max</a></code> attributes, when present, must have values that are <a href="#valid-floating-point-number" id="the-progress-element:valid-floating-point-number">valid floating-point numbers</a>. The <code id="the-progress-element:attr-progress-value-5"><a href="#attr-progress-value">value</a></code> attribute, if present, must have a value greater than or
  equal to zero, and less than or equal to the value of the <code id="the-progress-element:attr-progress-max-5"><a href="#attr-progress-max">max</a></code> attribute, if present, or 1.0, otherwise. The <code id="the-progress-element:attr-progress-max-6"><a href="#attr-progress-max">max</a></code> attribute, if present, must have a value greater than
  zero.</p>

  <p class="note">The <code id="the-progress-element:the-progress-element-3"><a href="#the-progress-element">progress</a></code> element is the wrong element to use for something that
  is just a gauge, as opposed to task progress. For instance, indicating disk space usage using
  <code id="the-progress-element:the-progress-element-4"><a href="#the-progress-element">progress</a></code> would be inappropriate. Instead, the <code id="the-progress-element:the-meter-element"><a href="#the-meter-element">meter</a></code> element is available
  for such use cases.</p>

  

  <div data-algorithm="">
  <p><strong>User agent requirements</strong>: If the <code id="the-progress-element:attr-progress-value-6"><a href="#attr-progress-value">value</a></code>
  attribute is omitted, then the progress bar is an indeterminate progress bar. Otherwise, it is a
  determinate progress bar.</p>
  </div>

  <div data-algorithm="">
  <p>If the progress bar is a determinate progress bar and the element has a <code id="the-progress-element:attr-progress-max-7"><a href="#attr-progress-max">max</a></code> attribute, the user agent must parse the <code id="the-progress-element:attr-progress-max-8"><a href="#attr-progress-max">max</a></code> attribute's value according to the <a href="#rules-for-parsing-floating-point-number-values" id="the-progress-element:rules-for-parsing-floating-point-number-values">rules for parsing
  floating-point number values</a>. If this does not result in an error, and if the parsed value
  is greater than zero, then the <dfn id="concept-progress-maximum">maximum value</dfn> of the
  progress bar is that value. Otherwise, if the element has no <code id="the-progress-element:attr-progress-max-9"><a href="#attr-progress-max">max</a></code> attribute, or if it has one but parsing it resulted in an
  error, or if the parsed value was less than or equal to zero, then the <a href="#concept-progress-maximum" id="the-progress-element:concept-progress-maximum">maximum value</a> of the progress bar is 1.0.</p>
  </div>

  <div data-algorithm="">
  <p>If the progress bar is a determinate progress bar, user agents must parse the <code id="the-progress-element:attr-progress-value-7"><a href="#attr-progress-value">value</a></code> attribute's value according to the <a href="#rules-for-parsing-floating-point-number-values" id="the-progress-element:rules-for-parsing-floating-point-number-values-2">rules for
  parsing floating-point number values</a>. If this does not result in an error and the parsed
  value is greater than zero, then the <dfn id="concept-progress-value">value</dfn> of the
  progress bar is that parsed value. Otherwise, if parsing the <code id="the-progress-element:attr-progress-value-8"><a href="#attr-progress-value">value</a></code> attribute's value resulted in an error or a number less
  than or equal to zero, then the <a href="#concept-progress-value" id="the-progress-element:concept-progress-value">value</a> of the progress
  bar is zero.</p>
  </div>

  <div data-algorithm="">
  <p>If the progress bar is a determinate progress bar, then the <dfn id="concept-progress-current-value">current value</dfn> is the <a href="#concept-progress-maximum" id="the-progress-element:concept-progress-maximum-2">maximum value</a>, if <a href="#concept-progress-value" id="the-progress-element:concept-progress-value-2">value</a> is greater than the <a href="#concept-progress-maximum" id="the-progress-element:concept-progress-maximum-3">maximum value</a>, and <a href="#concept-progress-value" id="the-progress-element:concept-progress-value-3">value</a> otherwise.</p>
  </div>

  <p><strong>UA requirements for showing the progress bar</strong>: When representing a
  <code id="the-progress-element:the-progress-element-5"><a href="#the-progress-element">progress</a></code> element to the user, the UA should indicate whether it is a determinate or
  indeterminate progress bar, and in the former case, should indicate the relative position of the
  <a href="#concept-progress-current-value" id="the-progress-element:concept-progress-current-value">current value</a> relative to the <a href="#concept-progress-maximum" id="the-progress-element:concept-progress-maximum-4">maximum value</a>.</p>

  

  <dl class="domintro"><dt><code><var>progress</var>.<a href="#dom-progress-position" id="dom-progress-position-dev">position</a></code></dt><dd>
    <p>For a determinate progress bar (one with known current and maximum values), returns the
    result of dividing the current value by the maximum value.</p>

    <p>For an indeterminate progress bar, returns −1.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>If the progress bar is an indeterminate progress bar, then the <dfn data-dfn-for="HTMLProgressElement" id="dom-progress-position" data-dfn-type="attribute"><code>position</code></dfn> IDL attribute
  must return −1. Otherwise, it must return the result of dividing the <a href="#concept-progress-current-value" id="the-progress-element:concept-progress-current-value-2">current value</a> by the <a href="#concept-progress-maximum" id="the-progress-element:concept-progress-maximum-5">maximum value</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLProgressElement" id="dom-progress-value" data-dfn-type="attribute"><code>value</code></dfn> getter steps are to return 0 if <a id="the-progress-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>
  is an indeterminate progress bar; otherwise <a id="the-progress-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-progress-value" id="the-progress-element:concept-progress-value-4">current value</a>.</p>
  </div>

  <p class="note">Setting the <code id="the-progress-element:dom-progress-value-2"><a href="#dom-progress-value">value</a></code> IDL attribute to itself
  when the corresponding content attribute is absent would change the progress bar from an
  indeterminate progress bar to a determinate progress bar with no progress.</p>

  <p>The <code id="the-progress-element:dom-lfe-labels-2"><a href="#dom-lfe-labels">labels</a></code> IDL attribute provides a list of the element's
  <code id="the-progress-element:the-label-element"><a href="#the-label-element">label</a></code>s.</p>

  



  <h4 id="the-meter-element"><span class="secno">4.10.14</span> The <dfn data-dfn-type="element"><code>meter</code></dfn> element<a href="#the-meter-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meter" title="The <meter> HTML element represents either a scalar value within a known range or a fractional value.">Element/meter</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>16+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>10.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android no"><span>WebView Android</span><span>No</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>
  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMeterElement" title="The HTML <meter> elements expose the HTMLMeterElement interface, which provides special properties and methods (beyond the HTMLElement object interface they also have available to them by inheritance) for manipulating the layout and presentation of <meter> elements.">HTMLMeterElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>16+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-meter-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-meter-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-meter-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#category-label" id="the-meter-element:category-label">Labelable element</a>.</dd><dd><a href="#palpable-content-2" id="the-meter-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-meter-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-meter-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-meter-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-meter-element:phrasing-content-2-3">Phrasing content</a>, but there must be no <code id="the-meter-element:the-meter-element"><a href="#the-meter-element">meter</a></code> element descendants.</dd><dt><a href="#concept-element-tag-omission" id="the-meter-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-meter-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-meter-element:global-attributes">Global attributes</a></dd><dd><code id="the-meter-element:attr-meter-value"><a href="#attr-meter-value">value</a></code> —  Current value of the element
     </dd><dd><code id="the-meter-element:attr-meter-min"><a href="#attr-meter-min">min</a></code> —  Lower bound of range
     </dd><dd><code id="the-meter-element:attr-meter-max"><a href="#attr-meter-max">max</a></code> —  Upper bound of range
     </dd><dd><code id="the-meter-element:attr-meter-low"><a href="#attr-meter-low">low</a></code> —  High limit of low range
     </dd><dd><code id="the-meter-element:attr-meter-high"><a href="#attr-meter-high">high</a></code> —  Low limit of high range
     </dd><dd><code id="the-meter-element:attr-meter-optimum"><a href="#attr-meter-optimum">optimum</a></code> —  Optimum value in gauge
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-meter-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-meter">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-meter">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-meter-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlmeterelement" data-dfn-type="interface"><c- g="">HTMLMeterElement</c-></dfn> : <a href="#htmlelement" id="the-meter-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-meter-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-meter-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-meter-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-meter-value" id="the-meter-element:dom-meter-value"><c- g="">value</c-></a>;
  [<a href="#cereactions" id="the-meter-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-meter-element:xattr-reflectsetter-2"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-meter-min" id="the-meter-element:dom-meter-min"><c- g="">min</c-></a>;
  [<a href="#cereactions" id="the-meter-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-meter-element:xattr-reflectsetter-3"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-meter-max" id="the-meter-element:dom-meter-max"><c- g="">max</c-></a>;
  [<a href="#cereactions" id="the-meter-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-meter-element:xattr-reflectsetter-4"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-meter-low" id="the-meter-element:dom-meter-low"><c- g="">low</c-></a>;
  [<a href="#cereactions" id="the-meter-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-meter-element:xattr-reflectsetter-5"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-meter-high" id="the-meter-element:dom-meter-high"><c- g="">high</c-></a>;
  [<a href="#cereactions" id="the-meter-element:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-meter-element:xattr-reflectsetter-6"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-meter-optimum" id="the-meter-element:dom-meter-optimum"><c- g="">optimum</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-meter-element:nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist" data-x-internal="nodelist"><c- n="">NodeList</c-></a> <a href="#dom-lfe-labels" id="the-meter-element:dom-lfe-labels"><c- g="">labels</c-></a>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-meter-element:the-meter-element-2"><a href="#the-meter-element">meter</a></code> element <a href="#represents" id="the-meter-element:represents">represents</a> a scalar measurement within a known
  range, or a fractional value; for example disk usage, the relevance of a query result, or the
  fraction of a voting population to have selected a particular candidate.</p>

  <p>This is also known as a gauge.</p>

  <p>The <code id="the-meter-element:the-meter-element-3"><a href="#the-meter-element">meter</a></code> element should not be used to indicate progress (as in a progress bar).
  For that role, HTML provides a separate <code id="the-meter-element:the-progress-element"><a href="#the-progress-element">progress</a></code> element.</p>

  <p class="note">The <code id="the-meter-element:the-meter-element-4"><a href="#the-meter-element">meter</a></code> element also does not represent a scalar value of arbitrary
  range — for example, it would be wrong to use this to report a weight, or height, unless
  there is a known maximum value.</p>

  <p>There are six attributes that determine the semantics of the gauge represented by the
  element.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max" title="The max attribute defines the maximum value that is acceptable and valid for the input containing the attribute. If the value of the element is greater than this, the element fails validation. This value must be greater than or equal to the value of the min attribute. If the max attribute is present but is not specified or is invalid, no max value is applied. If the max attribute is valid and a non-empty value is greater than the maximum allowed by the max attribute, constraint validation will prevent form submission.">Attributes/max</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>16+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>10.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android no"><span>WebView Android</span><span>No</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/min" title="The min attribute defines the minimum value that is acceptable and valid for the input containing the attribute. If the value of the element is less than this, the element fails validation. This value must be less than or equal to the value of the max attribute.">Attributes/min</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>16+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>10.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android no"><span>WebView Android</span><span>No</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div><p>The <dfn data-dfn-for="meter" id="attr-meter-min" data-dfn-type="element-attr"><code>min</code></dfn> attribute
  specifies the lower bound of the range, and the <dfn data-dfn-for="meter" id="attr-meter-max" data-dfn-type="element-attr"><code>max</code></dfn> attribute specifies the upper bound. The <dfn data-dfn-for="meter" id="attr-meter-value" data-dfn-type="element-attr"><code>value</code></dfn> attribute specifies
  the value to have the gauge indicate as the "measured" value.</p>

  <p>The other three attributes can be used to segment the gauge's range into "low", "medium", and
  "high" parts, and to indicate which part of the gauge is the "optimum" part. The <dfn data-dfn-for="meter" id="attr-meter-low" data-dfn-type="element-attr"><code>low</code></dfn> attribute specifies the range that is
  considered to be the "low" part, and the <dfn data-dfn-for="meter" id="attr-meter-high" data-dfn-type="element-attr"><code>high</code></dfn> attribute specifies the range that is considered to be
  the "high" part. The <dfn data-dfn-for="meter" id="attr-meter-optimum" data-dfn-type="element-attr"><code>optimum</code></dfn> attribute gives the position that is "optimum";
  if that is higher than the "high" value then this indicates that the higher the value, the better;
  if it's lower than the "low" mark then it indicates that lower values are better, and naturally if
  it is in between then it indicates that neither high nor low values are good.</p>

  <p><strong>Authoring requirements</strong>: The <code id="the-meter-element:attr-meter-value-2"><a href="#attr-meter-value">value</a></code> attribute must be specified. The <code id="the-meter-element:attr-meter-value-3"><a href="#attr-meter-value">value</a></code>, <code id="the-meter-element:attr-meter-min-2"><a href="#attr-meter-min">min</a></code>, <code id="the-meter-element:attr-meter-low-2"><a href="#attr-meter-low">low</a></code>, <code id="the-meter-element:attr-meter-high-2"><a href="#attr-meter-high">high</a></code>, <code id="the-meter-element:attr-meter-max-2"><a href="#attr-meter-max">max</a></code>, and <code id="the-meter-element:attr-meter-optimum-2"><a href="#attr-meter-optimum">optimum</a></code> attributes,
  when present, must have values that are <a href="#valid-floating-point-number" id="the-meter-element:valid-floating-point-number">valid
  floating-point numbers</a>.</p>

  <div data-algorithm="">
  <p>In addition, the attributes' values are further constrained:</p>

  <p>Let <var>value</var> be the <code id="the-meter-element:attr-meter-value-4"><a href="#attr-meter-value">value</a></code> attribute's
  number.</p>

  <p>If the <code id="the-meter-element:attr-meter-min-3"><a href="#attr-meter-min">min</a></code> attribute is specified, then let <var>minimum</var> be that attribute's value; otherwise, let it be 0.</p>

  <p>If the <code id="the-meter-element:attr-meter-max-3"><a href="#attr-meter-max">max</a></code> attribute is specified, then let <var>maximum</var> be that attribute's value; otherwise, let it be 1.0.</p>

  <p>The following inequalities must hold, as applicable:</p>

  <ul><li><p><var>minimum</var> ≤ <var>value</var> ≤ <var>maximum</var></p></li><li><p><var>minimum</var> ≤ <code id="the-meter-element:attr-meter-low-3"><a href="#attr-meter-low">low</a></code> ≤ <var>maximum</var>
   (if <code id="the-meter-element:attr-meter-low-4"><a href="#attr-meter-low">low</a></code> is specified)</p></li><li><p><var>minimum</var> ≤ <code id="the-meter-element:attr-meter-high-3"><a href="#attr-meter-high">high</a></code> ≤
   <var>maximum</var> (if <code id="the-meter-element:attr-meter-high-4"><a href="#attr-meter-high">high</a></code> is specified)</p></li><li><p><var>minimum</var> ≤ <code id="the-meter-element:attr-meter-optimum-3"><a href="#attr-meter-optimum">optimum</a></code> ≤
   <var>maximum</var> (if <code id="the-meter-element:attr-meter-optimum-4"><a href="#attr-meter-optimum">optimum</a></code> is specified)</p></li><li><p><code id="the-meter-element:attr-meter-low-5"><a href="#attr-meter-low">low</a></code> ≤ <code id="the-meter-element:attr-meter-high-5"><a href="#attr-meter-high">high</a></code>
   (if both <code id="the-meter-element:attr-meter-low-6"><a href="#attr-meter-low">low</a></code> and <code id="the-meter-element:attr-meter-high-6"><a href="#attr-meter-high">high</a></code>
   are specified)</p></li></ul>
  </div>

  <p class="note">If no minimum or maximum is specified, then the range is assumed to be 0..1, and
  the value thus has to be within that range.</p>

  <p>Authors are encouraged to include a textual representation of the gauge's state in the
  element's contents, for users of user agents that do not support the <code id="the-meter-element:the-meter-element-5"><a href="#the-meter-element">meter</a></code>
  element.</p>

  <p>When used with <a href="#microdata" id="the-meter-element:microdata">microdata</a>, the <code id="the-meter-element:the-meter-element-6"><a href="#the-meter-element">meter</a></code> element's <code id="the-meter-element:attr-meter-value-5"><a href="#attr-meter-value">value</a></code> attribute provides the element's machine-readable value.</p>

  <div class="example">

   <p>The following examples show three gauges that would all be three-quarters full:</p>

   <pre><code class="html">Storage space usage: <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">6</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">8</c-><c- p="">&gt;</c->6 blocks used (out of 8 total)<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html">Voter turnout: <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">0.75</c-><c- p="">&gt;&lt;</c-><c- f="">img</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"75%"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"graph75.png"</c-><c- p="">&gt;&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html">Tickets sold: <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">"0"</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"100"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"75"</c-><c- p="">&gt;&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c-></code></pre>

   <p>The following example is incorrect use of the element, because it doesn't give a range (and
   since the default maximum is 1, both of the gauges would end up looking maxed out):</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The grapefruit pie had a radius of <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">12</c-><c- p="">&gt;</c->12cm<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c->
and a height of <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">2</c-><c- p="">&gt;</c->2cm<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- </c-><strong><c- c="">BAD!</c-></strong><c- c=""> --&gt;</c-></code></pre>

   <p>Instead, one would either not include the meter element, or use the meter element with a
   defined range to give the dimensions in context compared to other pies:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The grapefruit pie had a radius of 12cm and a height of
2cm.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Radius: <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">20</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">12</c-><c- p="">&gt;</c->12cm<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Height: <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">10</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">2</c-><c- p="">&gt;</c->2cm<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>There is no explicit way to specify units in the <code id="the-meter-element:the-meter-element-7"><a href="#the-meter-element">meter</a></code> element, but the units may
  be specified in the <code id="the-meter-element:attr-title"><a href="#attr-title">title</a></code> attribute in free-form text.</p>

  <div class="example">

   <p>The example above could be extended to mention the units:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Radius: <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">20</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">12</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"centimeters"</c-><c- p="">&gt;</c->12cm<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Height: <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">10</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">2</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"centimeters"</c-><c- p="">&gt;</c->2cm<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <div data-algorithm="">
  <p><strong>User agent requirements</strong>: User agents must parse the <code id="the-meter-element:attr-meter-min-4"><a href="#attr-meter-min">min</a></code>, <code id="the-meter-element:attr-meter-max-4"><a href="#attr-meter-max">max</a></code>, <code id="the-meter-element:attr-meter-value-6"><a href="#attr-meter-value">value</a></code>, <code id="the-meter-element:attr-meter-low-7"><a href="#attr-meter-low">low</a></code>, <code id="the-meter-element:attr-meter-high-7"><a href="#attr-meter-high">high</a></code>, and <code id="the-meter-element:attr-meter-optimum-5"><a href="#attr-meter-optimum">optimum</a></code>
  attributes using the <a href="#rules-for-parsing-floating-point-number-values" id="the-meter-element:rules-for-parsing-floating-point-number-values">rules for parsing floating-point number values</a>.</p>

  <p>User agents must then use all these numbers to obtain values for six points on the gauge, as
  follows. (The order in which these are evaluated is important, as some of the values refer to
  earlier ones.)</p>

  <dl><dt>The <dfn id="concept-meter-minimum">minimum value</dfn></dt><dd>
    <p>If the <code id="the-meter-element:attr-meter-min-5"><a href="#attr-meter-min">min</a></code> attribute is specified and a value could be
    parsed out of it, then the minimum value is that value. Otherwise, the minimum value is
    zero.</p>
   </dd><dt>The <dfn id="concept-meter-maximum">maximum value</dfn></dt><dd>
    <p>If the <code id="the-meter-element:attr-meter-max-5"><a href="#attr-meter-max">max</a></code> attribute is specified and a value could be
    parsed out of it, then the candidate maximum value is that value. Otherwise, the candidate
    maximum value is 1.0.</p>

    <p>If the candidate maximum value is greater than or equal to the minimum value, then the
    maximum value is the candidate maximum value. Otherwise, the maximum value is the same as the
    minimum value.</p>
   </dd><dt>The <dfn id="concept-meter-actual">actual value</dfn></dt><dd>
    <p>If the <code id="the-meter-element:attr-meter-value-7"><a href="#attr-meter-value">value</a></code> attribute is specified and a value could
    be parsed out of it, then that value is the candidate actual value. Otherwise, the candidate
    actual value is zero.</p>

    <p>If the candidate actual value is less than the minimum value, then the actual value is the
    minimum value.</p>

    <p>Otherwise, if the candidate actual value is greater than the maximum value, then the actual
    value is the maximum value.</p>

    <p>Otherwise, the actual value is the candidate actual value.</p>
   </dd><dt>The <dfn id="concept-meter-low">low boundary</dfn></dt><dd>
    <p>If the <code id="the-meter-element:attr-meter-low-8"><a href="#attr-meter-low">low</a></code> attribute is specified and a value could be
    parsed out of it, then the candidate low boundary is that value. Otherwise, the candidate low
    boundary is the same as the minimum value.</p>

    <p>If the candidate low boundary is less than the minimum value, then the low boundary is the
    minimum value.</p>

    <p>Otherwise, if the candidate low boundary is greater than the maximum value, then the low
    boundary is the maximum value.</p>

    <p>Otherwise, the low boundary is the candidate low boundary.</p>
   </dd><dt>The <dfn id="concept-meter-high">high boundary</dfn></dt><dd>
    <p>If the <code id="the-meter-element:attr-meter-high-8"><a href="#attr-meter-high">high</a></code> attribute is specified and a value could be
    parsed out of it, then the candidate high boundary is that value. Otherwise, the candidate high
    boundary is the same as the maximum value.</p>

    <p>If the candidate high boundary is less than the low boundary, then the high boundary is the
    low boundary.</p>

    <p>Otherwise, if the candidate high boundary is greater than the maximum value, then the high
    boundary is the maximum value.</p>

    <p>Otherwise, the high boundary is the candidate high boundary.</p>
   </dd><dt>The <dfn id="concept-meter-optimum">optimum point</dfn></dt><dd>
    <p>If the <code id="the-meter-element:attr-meter-optimum-6"><a href="#attr-meter-optimum">optimum</a></code> attribute is specified and a value
    could be parsed out of it, then the candidate optimum point is that value. Otherwise, the
    candidate optimum point is the midpoint between the minimum value and the maximum value.</p>

    <p>If the candidate optimum point is less than the minimum value, then the optimum point is the
    minimum value.</p>

    <p>Otherwise, if the candidate optimum point is greater than the maximum value, then the optimum
    point is the maximum value.</p>

    <p>Otherwise, the optimum point is the candidate optimum point.</p>
   </dd></dl>

  <p>All of which will result in the following inequalities all being true:</p>

  <ul><li><p>minimum value ≤ actual value ≤ maximum value</p></li><li><p>minimum value ≤ low boundary ≤ high boundary ≤ maximum value</p></li><li><p>minimum value ≤ optimum point ≤ maximum value</p></li></ul>
  </div>

  <p><strong>UA requirements for regions of the gauge</strong>: If the optimum point is equal to the
  low boundary or the high boundary, or anywhere in between them, then the region between the low
  and high boundaries of the gauge must be treated as the optimum region, and the low and high
  parts, if any, must be treated as suboptimal. Otherwise, if the optimum point is less than the low
  boundary, then the region between the minimum value and the low boundary must be treated as the
  optimum region, the region from the low boundary up to the high boundary must be treated as a
  suboptimal region, and the remaining region must be treated as an even less good region. Finally,
  if the optimum point is higher than the high boundary, then the situation is reversed; the region
  between the high boundary and the maximum value must be treated as the optimum region, the region
  from the high boundary down to the low boundary must be treated as a suboptimal region, and the
  remaining region must be treated as an even less good region.</p>

  <p><strong>UA requirements for showing the gauge</strong>: When representing a <code id="the-meter-element:the-meter-element-8"><a href="#the-meter-element">meter</a></code>
  element to the user, the UA should indicate the relative position of the actual value to the
  minimum and maximum values, and the relationship between the actual value and the three regions of
  the gauge.</p>

  

  <div class="example">
   <p>The following markup:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h3</c-><c- p="">&gt;</c->Suggested groups<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">menu</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?cmd=hsg"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"hideSuggestedGroups()"</c-><c- p="">&gt;</c->Hide suggested groups<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">menu</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/group/comp.infosystems.www.authoring.stylesheets/view"</c-><c- p="">&gt;</c->comp.infosystems.www.authoring.stylesheets<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> -
     <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/group/comp.infosystems.www.authoring.stylesheets/subscribe"</c-><c- p="">&gt;</c->join<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Group description: <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Layout/presentation on the WWW.<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"0.5"</c-><c- p="">&gt;</c->Moderate activity,<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c-></strong> Usenet, 618 subscribers<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/group/netscape.public.mozilla.xpinstall/view"</c-><c- p="">&gt;</c->netscape.public.mozilla.xpinstall<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> -
     <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/group/netscape.public.mozilla.xpinstall/subscribe"</c-><c- p="">&gt;</c->join<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Group description: <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Mozilla XPInstall discussion.<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"0.25"</c-><c- p="">&gt;</c->Low activity,<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c-></strong> Usenet, 22 subscribers<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/group/mozilla.dev.general/view"</c-><c- p="">&gt;</c->mozilla.dev.general<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> -
     <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/group/mozilla.dev.general/subscribe"</c-><c- p="">&gt;</c->join<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"0.25"</c-><c- p="">&gt;</c->Low activity,<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c-></strong> Usenet, 66 subscribers<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>
   <p>Might be rendered as follows:</p>
   <p><img src="/images/sample-meter.png" width="332" alt="With the <meter> elements rendered as inline green bars of varying lengths." height="178"></p>
  </div>

  <p>User agents may combine the value of the <code id="the-meter-element:attr-title-2"><a href="#attr-title">title</a></code> attribute and the other attributes to provide context-sensitive
  help or inline text detailing the actual values.</p>

  <div class="example">
   <p>For example, the following snippet:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">60</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">23.2</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">seconds</c-><c- p="">&gt;&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c-></code></pre>
   <p>...might cause the user agent to display a gauge with a tooltip
   saying "Value: 23.2 out of 60." on one line and "seconds" on a
   second line.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMeterElement" id="dom-meter-value" data-dfn-type="attribute"><code>value</code></dfn>
  getter steps are to return <a id="the-meter-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-meter-actual" id="the-meter-element:concept-meter-actual">actual
  value</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMeterElement" id="dom-meter-min" data-dfn-type="attribute"><code>min</code></dfn> getter
  steps are to return <a id="the-meter-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-meter-minimum" id="the-meter-element:concept-meter-minimum">minimum
  value</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMeterElement" id="dom-meter-max" data-dfn-type="attribute"><code>max</code></dfn> getter
  steps are to return <a id="the-meter-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-meter-maximum" id="the-meter-element:concept-meter-maximum">maximum
  value</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMeterElement" id="dom-meter-low" data-dfn-type="attribute"><code>low</code></dfn> getter
  steps are to return <a id="the-meter-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-meter-low" id="the-meter-element:concept-meter-low">low boundary</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMeterElement" id="dom-meter-high" data-dfn-type="attribute"><code>high</code></dfn>
  getter steps are to return <a id="the-meter-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-meter-high" id="the-meter-element:concept-meter-high">high
  boundary</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMeterElement" id="dom-meter-optimum" data-dfn-type="attribute"><code>optimum</code></dfn>
  getter steps are to return <a id="the-meter-element:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-meter-optimum" id="the-meter-element:concept-meter-optimum">optimum
  value</a>.</p>
  </div>

  <p>The <code id="the-meter-element:dom-lfe-labels-2"><a href="#dom-lfe-labels">labels</a></code> IDL attribute provides a list of the element's
  <code id="the-meter-element:the-label-element"><a href="#the-label-element">label</a></code>s.</p>

  

  <div class="example">

   <p>The following example shows how a gauge could fall back to localized or pretty-printed
   text.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Disk usage: <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">170261928</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">233257824</c-><c- p="">&gt;</c->170 261 928 bytes used
out of 233 257 824 bytes available<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>




  <h4 id="the-fieldset-element"><span class="secno">4.10.15</span> The <dfn data-dfn-type="element"><code>fieldset</code></dfn> element<a href="#the-fieldset-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset" title="The <fieldset> HTML element is used to group several controls as well as labels (<label>) within a web form.">Element/fieldset</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>15+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFieldSetElement" title="The HTMLFieldSetElement interface provides special properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of <fieldset> elements.">HTMLFieldSetElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-fieldset-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-fieldset-element:flow-content-2">Flow content</a>.</dd><dd><a href="#category-listed" id="the-fieldset-element:category-listed">Listed</a> and <a href="#category-autocapitalize" id="the-fieldset-element:category-autocapitalize">autocapitalize-and-autocorrect inheriting</a> <a href="#form-associated-element" id="the-fieldset-element:form-associated-element">form-associated element</a>.</dd><dd><a href="#palpable-content-2" id="the-fieldset-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-fieldset-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-fieldset-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-fieldset-element:concept-element-content-model">Content model</a>:</dt><dd>Optionally, a <code id="the-fieldset-element:the-legend-element"><a href="#the-legend-element">legend</a></code> element, followed by <a href="#flow-content-2" id="the-fieldset-element:flow-content-2-3">flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-fieldset-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-fieldset-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-fieldset-element:global-attributes">Global attributes</a></dd><dd><code id="the-fieldset-element:attr-fieldset-disabled"><a href="#attr-fieldset-disabled">disabled</a></code> —  Whether the descendant form controls, except any inside <code id="the-fieldset-element:the-legend-element-2"><a href="#the-legend-element">legend</a></code>, are disabled
     </dd><dd><code id="the-fieldset-element:attr-fae-form"><a href="#attr-fae-form">form</a></code> —  Associates the element with a <code id="the-fieldset-element:the-form-element"><a href="#the-form-element">form</a></code> element
     </dd><dd><code id="the-fieldset-element:attr-fe-name"><a href="#attr-fe-name">name</a></code>   — Name of the element to use in the <code id="the-fieldset-element:dom-form-elements"><a href="#dom-form-elements">form.elements</a></code> API.</dd><dt><a href="#concept-element-accessibility-considerations" id="the-fieldset-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-fieldset">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-fieldset">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-fieldset-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlfieldsetelement" data-dfn-type="interface"><c- g="">HTMLFieldSetElement</c-></dfn> : <a href="#htmlelement" id="the-fieldset-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-fieldset-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-fieldset-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-fieldset-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLFieldSetElement" id="dom-fieldset-disabled" data-dfn-type="attribute"><c- g="">disabled</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-fieldset-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-fae-form" id="the-fieldset-element:dom-fae-form"><c- g="">form</c-></a>;
  [<a href="#cereactions" id="the-fieldset-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-fieldset-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFieldSetElement" id="dom-fieldset-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-fieldset-type" id="the-fieldset-element:dom-fieldset-type"><c- g="">type</c-></a>;

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-fieldset-element:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-fieldset-elements" id="the-fieldset-element:dom-fieldset-elements"><c- g="">elements</c-></a>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-cva-willvalidate" id="the-fieldset-element:dom-cva-willvalidate"><c- g="">willValidate</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#validitystate" id="the-fieldset-element:validitystate"><c- n="">ValidityState</c-></a> <a href="#dom-cva-validity" id="the-fieldset-element:dom-cva-validity"><c- g="">validity</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-cva-validationmessage" id="the-fieldset-element:dom-cva-validationmessage"><c- g="">validationMessage</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-cva-checkvalidity" id="the-fieldset-element:dom-cva-checkvalidity"><c- g="">checkValidity</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-cva-reportvalidity" id="the-fieldset-element:dom-cva-reportvalidity"><c- g="">reportValidity</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-cva-setcustomvalidity" id="the-fieldset-element:dom-cva-setcustomvalidity"><c- g="">setCustomValidity</c-></a>(<c- b="">DOMString</c-> <c- g="">error</c->);
};</code></pre>
   </dd></dl>

  <p>The <code id="the-fieldset-element:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code> element <a href="#represents" id="the-fieldset-element:represents">represents</a> a set of form controls (or other
  content) grouped together, optionally with a caption. The caption is given by the first
  <code id="the-fieldset-element:the-legend-element-3"><a href="#the-legend-element">legend</a></code> element that is a child of the <code id="the-fieldset-element:the-fieldset-element-2"><a href="#the-fieldset-element">fieldset</a></code> element, if any. The
  remainder of the descendants form the group.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset#attr-disabled" title="The <fieldset> HTML element is used to group several controls as well as labels (<label>) within a web form.">Element/fieldset#attr-disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="fieldset" id="attr-fieldset-disabled" data-dfn-type="element-attr"><code>disabled</code></dfn> attribute, when specified, causes all the
  form control descendants of the <code id="the-fieldset-element:the-fieldset-element-3"><a href="#the-fieldset-element">fieldset</a></code> element, excluding those that are
  descendants of the <code id="the-fieldset-element:the-fieldset-element-4"><a href="#the-fieldset-element">fieldset</a></code> element's first <code id="the-fieldset-element:the-legend-element-4"><a href="#the-legend-element">legend</a></code> element child, if
  any, to be <a href="#concept-fe-disabled" id="the-fieldset-element:concept-fe-disabled">disabled</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-fieldset-element:the-fieldset-element-5"><a href="#the-fieldset-element">fieldset</a></code> element is a <dfn id="concept-fieldset-disabled">disabled
  fieldset</dfn> if it matches any of the following conditions:</p>

  <ul><li>Its <code id="the-fieldset-element:attr-fieldset-disabled-2"><a href="#attr-fieldset-disabled">disabled</a></code> attribute is specified

   </li><li>It is a descendant of another <code id="the-fieldset-element:the-fieldset-element-6"><a href="#the-fieldset-element">fieldset</a></code> element whose <code id="the-fieldset-element:attr-fieldset-disabled-3"><a href="#attr-fieldset-disabled">disabled</a></code> attribute is specified, and is <em>not</em> a
   descendant of that <code id="the-fieldset-element:the-fieldset-element-7"><a href="#the-fieldset-element">fieldset</a></code> element's first <code id="the-fieldset-element:the-legend-element-5"><a href="#the-legend-element">legend</a></code> element child, if
   any.</li></ul>
  </div>

  <p>The <code id="the-fieldset-element:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> attribute is used to explicitly associate the
  <code id="the-fieldset-element:the-fieldset-element-8"><a href="#the-fieldset-element">fieldset</a></code> element with its <a href="#form-owner" id="the-fieldset-element:form-owner">form owner</a>. The <code id="the-fieldset-element:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attribute represents the element's name.</p>

  <dl class="domintro"><dt><code><var>fieldset</var>.<a href="#dom-fieldset-type" id="dom-fieldset-type-dev">type</a></code></dt><dd><p>Returns the string "fieldset".</p></dd><dt><code><var>fieldset</var>.<a href="#dom-fieldset-elements" id="dom-fieldset-elements-dev">elements</a></code></dt><dd><p>Returns an <code id="the-fieldset-element:htmlcollection-2"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> of the form controls in the element.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFieldSetElement" id="dom-fieldset-type" data-dfn-type="attribute"><code>type</code></dfn>
  IDL attribute must return the string "<code>fieldset</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFieldSetElement" id="dom-fieldset-elements" data-dfn-type="attribute"><code>elements</code></dfn> IDL attribute must return an
  <code id="the-fieldset-element:htmlcollection-3"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="the-fieldset-element:the-fieldset-element-9"><a href="#the-fieldset-element">fieldset</a></code> element, whose filter matches
  <a href="#category-listed" id="the-fieldset-element:category-listed-2">listed elements</a>.</p>
  </div>

  <p>The <code id="the-fieldset-element:dom-cva-willvalidate-2"><a href="#dom-cva-willvalidate">willValidate</a></code>, <code id="the-fieldset-element:dom-cva-validity-2"><a href="#dom-cva-validity">validity</a></code>, and <code id="the-fieldset-element:dom-cva-validationmessage-2"><a href="#dom-cva-validationmessage">validationMessage</a></code> attributes, and the <code id="the-fieldset-element:dom-cva-checkvalidity-2"><a href="#dom-cva-checkvalidity">checkValidity()</a></code>, <code id="the-fieldset-element:dom-cva-reportvalidity-2"><a href="#dom-cva-reportvalidity">reportValidity()</a></code>, and <code id="the-fieldset-element:dom-cva-setcustomvalidity-2"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> methods, are part of the
  <a href="#the-constraint-validation-api" id="the-fieldset-element:the-constraint-validation-api">constraint validation API</a>. The <code id="the-fieldset-element:dom-fae-form-2"><a href="#dom-fae-form">form</a></code> and <code id="the-fieldset-element:dom-fieldset-name"><a href="#dom-fieldset-name">name</a></code> IDL attributes are part of the element's forms API.</p>

  

  <div class="example">

   <p>This example shows a <code id="the-fieldset-element:the-fieldset-element-10"><a href="#the-fieldset-element">fieldset</a></code> element being used to group a set of related
   controls:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Display<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">c</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">checked</c-><c- p="">&gt;</c-> Black on White<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">c</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">1</c-><c- p="">&gt;</c-> White on Black<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">g</c-><c- p="">&gt;</c-> Use grayscale<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Enhance contrast <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">range</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">e</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">contrast</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">100</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">1</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">contrast</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">Normal</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">0</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">label</c-><c- o="">=</c-><c- s="">Maximum</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">100</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The following snippet shows a fieldset with a checkbox in the legend that controls whether or
   not the fieldset is enabled. The contents of the fieldset consist of two required text controls
   and an optional year/month control.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"clubfields"</c-> <c- e="">disabled</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">club</c-> <c- e="">onchange</c-><c- o="">=</c-><c- s="">"form.clubfields.disabled = !checked"</c-><c- p="">&gt;</c->
  Use Club Card
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name on card: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">clubname</c-> <c- e="">required</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Card number: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">clubnum</c-> <c- e="">required</c-> <c- e="">pattern</c-><c- o="">=</c-><c- s="">"[-0-9]+"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Expiry date: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">clubexp</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">month</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>You can also nest <code id="the-fieldset-element:the-fieldset-element-11"><a href="#the-fieldset-element">fieldset</a></code> elements. Here is an example expanding on the previous
   one that does so:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"clubfields"</c-> <c- e="">disabled</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">club</c-> <c- e="">onchange</c-><c- o="">=</c-><c- s="">"form.clubfields.disabled = !checked"</c-><c- p="">&gt;</c->
  Use Club Card
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name on card: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">clubname</c-> <c- e="">required</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"numfields"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">checked</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">clubtype</c-> <c- e="">onchange</c-><c- o="">=</c-><c- s="">"form.numfields.disabled = !checked"</c-><c- p="">&gt;</c->
   My card has numbers on it
  <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Card number: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">clubnum</c-> <c- e="">required</c-> <c- e="">pattern</c-><c- o="">=</c-><c- s="">"[-0-9]+"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"letfields"</c-> <c- e="">disabled</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">clubtype</c-> <c- e="">onchange</c-><c- o="">=</c-><c- s="">"form.letfields.disabled = !checked"</c-><c- p="">&gt;</c->
   My card has letters on it
  <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Card code: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">clublet</c-> <c- e="">required</c-> <c- e="">pattern</c-><c- o="">=</c-><c- s="">"[A-Za-z]+"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></code></pre>

   <p>In this example, if the outer "Use Club Card" checkbox is not checked, everything inside the
   outer <code id="the-fieldset-element:the-fieldset-element-12"><a href="#the-fieldset-element">fieldset</a></code>, including the two radio buttons in the legends of the two nested
   <code id="the-fieldset-element:the-fieldset-element-13"><a href="#the-fieldset-element">fieldset</a></code>s, will be disabled. However, if the checkbox is checked, then the radio
   buttons will both be enabled and will let you select which of the two inner
   <code id="the-fieldset-element:the-fieldset-element-14"><a href="#the-fieldset-element">fieldset</a></code>s is to be enabled.</p>

  </div>

  <div class="example">

   <p>This example shows a grouping of controls where the <code id="the-fieldset-element:the-legend-element-6"><a href="#the-legend-element">legend</a></code> element both labels
   the grouping, and the nested heading element surfaces the grouping in the document outline:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->
  How can we best reach you?
 <c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">checked</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">contact_pref</c-><c- p="">&gt;</c->
  Phone
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">contact_pref</c-><c- p="">&gt;</c->
  Text
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">radio</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">contact_pref</c-><c- p="">&gt;</c->
  Email
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-legend-element"><span class="secno">4.10.16</span> The <dfn data-dfn-type="element"><code>legend</code></dfn> element<a href="#the-legend-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/legend" title="The <legend> HTML element represents a caption for the content of its parent <fieldset>.">Element/legend</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLegendElement" title="The HTMLLegendElement is an interface allowing to access properties of the <legend> elements. It inherits properties and methods from the HTMLElement interface.">HTMLLegendElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-legend-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-legend-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As the <a id="the-legend-element:first-child" href="https://dom.spec.whatwg.org/#concept-tree-first-child" data-x-internal="first-child">first child</a> of a <code id="the-legend-element:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code> element.</dd><dd>As the <a id="the-legend-element:first-child-2" href="https://dom.spec.whatwg.org/#concept-tree-first-child" data-x-internal="first-child">first child</a> of an <code id="the-legend-element:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-legend-element:concept-element-content-model">Content model</a>:</dt><dd>If the element is a child of an <code id="the-legend-element:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> element: <a href="#phrasing-content-2" id="the-legend-element:phrasing-content-2">Phrasing content</a>,
   but there must be no <a href="#interactive-content-2" id="the-legend-element:interactive-content-2">interactive content</a> and no descendant with the <code id="the-legend-element:attr-tabindex"><a href="#attr-tabindex">tabindex</a></code> attribute.</dd><dd>Otherwise: <a href="#phrasing-content-2" id="the-legend-element:phrasing-content-2-2">Phrasing content</a>, optionally intermixed with <a href="#heading-content-2" id="the-legend-element:heading-content-2">heading
   content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-legend-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-legend-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-legend-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-legend-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-legend">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-legend">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-legend-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmllegendelement" data-dfn-type="interface"><c- g="">HTMLLegendElement</c-></dfn> : <a href="#htmlelement" id="the-legend-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-legend-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-legend-element:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-legend-form" id="the-legend-element:dom-legend-form"><c- g="">form</c-></a>;

  // <a href="#HTMLLegendElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-legend-element:the-legend-element"><a href="#the-legend-element">legend</a></code> element <a href="#represents" id="the-legend-element:represents">represents</a> a caption for the rest of the contents
  of the <code id="the-legend-element:the-legend-element-2"><a href="#the-legend-element">legend</a></code> element's parent <code id="the-legend-element:the-fieldset-element-2"><a href="#the-fieldset-element">fieldset</a></code> element, if
  any. Otherwise, if the <code id="the-legend-element:the-legend-element-3"><a href="#the-legend-element">legend</a></code> has a parent <code id="the-legend-element:the-optgroup-element-3"><a href="#the-optgroup-element">optgroup</a></code> element, then
  the <code id="the-legend-element:the-legend-element-4"><a href="#the-legend-element">legend</a></code> represents the <code id="the-legend-element:the-optgroup-element-4"><a href="#the-optgroup-element">optgroup</a></code>'s label.</p>

  <dl class="domintro"><dt><code><var>legend</var>.<a href="#dom-legend-form" id="dom-legend-form-dev">form</a></code></dt><dd><p>Returns the element's <code id="the-legend-element:the-form-element"><a href="#the-form-element">form</a></code> element, if any, or null otherwise.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLLegendElement" id="dom-legend-form" data-dfn-type="attribute"><code>form</code></dfn> IDL
  attribute's behavior depends on whether the <code id="the-legend-element:the-legend-element-5"><a href="#the-legend-element">legend</a></code> element is in a
  <code id="the-legend-element:the-fieldset-element-3"><a href="#the-fieldset-element">fieldset</a></code> element or not. If the <code id="the-legend-element:the-legend-element-6"><a href="#the-legend-element">legend</a></code> has a <code id="the-legend-element:the-fieldset-element-4"><a href="#the-fieldset-element">fieldset</a></code>
  element as its parent, then the <code id="the-legend-element:dom-legend-form-2"><a href="#dom-legend-form">form</a></code> IDL attribute must
  return the same value as the <code id="the-legend-element:dom-fae-form"><a href="#dom-fae-form">form</a></code> IDL attribute on that
  <code id="the-legend-element:the-fieldset-element-5"><a href="#the-fieldset-element">fieldset</a></code> element. Otherwise, it must return null.</p>
  </div>

  

  <h4 id="the-selectedcontent-element"><span class="secno">4.10.17</span> The <dfn data-dfn-type="element"><code>selectedcontent</code></dfn> element<a href="#the-selectedcontent-element" class="self-link"></a></h4>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-selectedcontent-element:concept-element-categories">Categories</a>:</dt><dd><a href="#phrasing-content-2" id="the-selectedcontent-element:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-contexts" id="the-selectedcontent-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As a descendant of a <code id="the-selectedcontent-element:the-button-element"><a href="#the-button-element">button</a></code> element which is a child of a <code id="the-selectedcontent-element:the-select-element"><a href="#the-select-element">select</a></code>
   element.</dd><dt><a href="#concept-element-content-model" id="the-selectedcontent-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-selectedcontent-element:concept-content-nothing">Nothing</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-selectedcontent-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-selectedcontent-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-selectedcontent-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-selectedcontent-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-selectedcontent">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-selectedcontent">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-selectedcontent-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlselectedcontentelement" data-dfn-type="interface"><c- g="">HTMLSelectedContentElement</c-></dfn> : <a href="#htmlelement" id="the-selectedcontent-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-selectedcontent-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();
};</code></pre>
   </dd></dl>

  <p>The <code id="the-selectedcontent-element:the-selectedcontent-element"><a href="#the-selectedcontent-element">selectedcontent</a></code> element reflects the contents of a <code id="the-selectedcontent-element:the-select-element-2"><a href="#the-select-element">select</a></code>
  element's currently selected <code id="the-selectedcontent-element:the-option-element"><a href="#the-option-element">option</a></code> element. <code id="the-selectedcontent-element:the-selectedcontent-element-2"><a href="#the-selectedcontent-element">selectedcontent</a></code> elements
  can be used to declaratively show the selected <code id="the-selectedcontent-element:the-option-element-2"><a href="#the-option-element">option</a></code> element's contents within the
  <code id="the-selectedcontent-element:the-select-element-3"><a href="#the-select-element">select</a></code> element's first child <code id="the-selectedcontent-element:the-button-element-2"><a href="#the-button-element">button</a></code> element.</p>

  <p class="note">The <code id="the-selectedcontent-element:the-option-element-3"><a href="#the-option-element">option</a></code> element's <code id="the-selectedcontent-element:attr-option-label"><a href="#attr-option-label">label</a></code>
  attribute can be used to render a visible label for the option, but the
  <code id="the-selectedcontent-element:the-selectedcontent-element-3"><a href="#the-selectedcontent-element">selectedcontent</a></code> element will not reflect the content of the <code id="the-selectedcontent-element:attr-option-label-2"><a href="#attr-option-label">label</a></code> attribute.</p>

  

  <p>Every <code id="the-selectedcontent-element:the-selectedcontent-element-4"><a href="#the-selectedcontent-element">selectedcontent</a></code> element has a <dfn id="selectedcontent-disabled">disabled</dfn> state, which is a boolean, initially set to
  false.</p>

  <div data-algorithm="">
  <p>To <dfn id="update-a-select's-selectedcontent">update a <code>select</code>'s <code>selectedcontent</code></dfn> given a
  <code id="the-selectedcontent-element:the-select-element-4"><a href="#the-select-element">select</a></code> element <var>select</var>:</p>

  <ol><li><p>Let <var>selectedcontent</var> be the result of <a href="#select-enabled-selectedcontent" id="the-selectedcontent-element:select-enabled-selectedcontent">get a <code>select</code>'s enabled
   <code>selectedcontent</code></a> given <var>select</var>.</p></li><li><p>If <var>selectedcontent</var> is null, then return.</p></li><li><p>Let <var>option</var> be the first <code id="the-selectedcontent-element:the-option-element-4"><a href="#the-option-element">option</a></code> in <var>select</var>'s <a href="#concept-select-option-list" id="the-selectedcontent-element:concept-select-option-list">list of options</a> whose <a href="#concept-option-selectedness" id="the-selectedcontent-element:concept-option-selectedness">selectedness</a> is true, if any such <code id="the-selectedcontent-element:the-option-element-5"><a href="#the-option-element">option</a></code>
   exists, otherwise null.</p></li><li><p>If <var>option</var> is null, then run <a href="#clear-a-selectedcontent" id="the-selectedcontent-element:clear-a-selectedcontent">clear a <code>selectedcontent</code></a>
   given <var>selectedcontent</var>.</p></li><li><p>Otherwise, run <a href="#clone-an-option-into-a-selectedcontent" id="the-selectedcontent-element:clone-an-option-into-a-selectedcontent">clone an option into a <code>selectedcontent</code></a> given
   <var>option</var> and <var>selectedcontent</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="select-enabled-selectedcontent">get a <code>select</code>'s enabled
  <code>selectedcontent</code></dfn> given a <code id="the-selectedcontent-element:the-select-element-5"><a href="#the-select-element">select</a></code> element <var>select</var>:</p>

  <ol><li><p>If <var>select</var> has the <code id="the-selectedcontent-element:attr-select-multiple"><a href="#attr-select-multiple">multiple</a></code>
   attribute, then return null.</p></li><li><p>Let <var>selectedcontent</var> be the first <code id="the-selectedcontent-element:the-selectedcontent-element-5"><a href="#the-selectedcontent-element">selectedcontent</a></code> element
   <a id="the-selectedcontent-element:descendant" href="https://dom.spec.whatwg.org/#concept-tree-descendant" data-x-internal="descendant">descendant</a> of <var>select</var> in <a id="the-selectedcontent-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> if any such element
   exists; otherwise return null.</p></li><li><p>If <var>selectedcontent</var> is <a href="#selectedcontent-disabled" id="the-selectedcontent-element:selectedcontent-disabled">disabled</a>,
   then return null.</p></li><li><p>Return <var>selectedcontent</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="clone-an-option-into-a-selectedcontent">clone an <code>option</code> into a <code>selectedcontent</code></dfn>, given an
  <code id="the-selectedcontent-element:the-option-element-6"><a href="#the-option-element">option</a></code> element <var>option</var> and a <code id="the-selectedcontent-element:the-selectedcontent-element-6"><a href="#the-selectedcontent-element">selectedcontent</a></code> element
  <var>selectedcontent</var>:</p>

  <ol><li><p>Let <var>documentFragment</var> be a new <code id="the-selectedcontent-element:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> whose <a id="the-selectedcontent-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a> is <var>option</var>'s <a id="the-selectedcontent-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li>
    <p>For each <var>child</var> of <var>option</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="the-selectedcontent-element:concept-tree-child" data-x-internal="concept-tree-child">children</a>:</p>

    <ol><li><p>Let <var>childClone</var> be the result of running <a href="https://dom.spec.whatwg.org/#concept-node-clone" id="the-selectedcontent-element:concept-node-clone" data-x-internal="concept-node-clone">clone</a> given <var>child</var> with <a href="https://dom.spec.whatwg.org/#clone-a-node-subtree" id="the-selectedcontent-element:concept-node-clone-subtree" data-x-internal="concept-node-clone-subtree">subtree</a> set to true.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-selectedcontent-element:concept-node-append" data-x-internal="concept-node-append">Append</a> <var>childClone</var> to
     <var>documentFragment</var>.</p></li></ol>
   </li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-replace-all" id="the-selectedcontent-element:concept-node-replace-all" data-x-internal="concept-node-replace-all">Replace all</a> with
   <var>documentFragment</var> within <var>selectedcontent</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="clear-a-selectedcontent">clear a <code>selectedcontent</code></dfn> given a <code id="the-selectedcontent-element:the-selectedcontent-element-7"><a href="#the-selectedcontent-element">selectedcontent</a></code> element
  <var>selectedcontent</var>:</p>

  <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-node-replace-all" id="the-selectedcontent-element:concept-node-replace-all-2" data-x-internal="concept-node-replace-all">Replace all</a> with null within
   <var>selectedcontent</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="clear-a-select's-non-primary-selectedcontent-elements">clear a <code>select</code>'s non-primary <code>selectedcontent</code> elements</dfn>,
  given a <code id="the-selectedcontent-element:the-select-element-6"><a href="#the-select-element">select</a></code> element <var>select</var>:</p>

  <ol><li><p>Let <var>passedFirstSelectedcontent</var> be false.</p></li><li>
    <p>For each <var>descendant</var> of <var>select</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="the-selectedcontent-element:descendant-2" data-x-internal="descendant">descendants</a> in <a id="the-selectedcontent-element:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> that is a
    <code id="the-selectedcontent-element:the-selectedcontent-element-8"><a href="#the-selectedcontent-element">selectedcontent</a></code> element:</p>

    <ol><li><p>If <var>passedFirstSelectedcontent</var> is false, then set
     <var>passedFirstSelectedcontent</var> to true.</p></li><li><p>Otherwise, run <a href="#clear-a-selectedcontent" id="the-selectedcontent-element:clear-a-selectedcontent-2">clear a <code>selectedcontent</code></a> given
     <var>descendant</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-selectedcontent-element:the-selectedcontent-element-9"><a href="#the-selectedcontent-element">selectedcontent</a></code> <a href="#html-element-post-connection-steps" id="the-selectedcontent-element:html-element-post-connection-steps">HTML element post-connection steps</a>, given
  <var>selectedcontent</var>, are:</p>

  <ol><li><p>Let <var>nearestSelectAncestor</var> be null.</p></li><li><p>Let <var>ancestor</var> be <var>selectedcontent</var>'s <a id="the-selectedcontent-element:parent" href="https://dom.spec.whatwg.org/#concept-tree-parent" data-x-internal="parent">parent</a>.</p></li><li><p>Set <var>selectedcontent</var>'s <a href="#selectedcontent-disabled" id="the-selectedcontent-element:selectedcontent-disabled-2">disabled</a>
   state to false.</p></li><li>
    <p>For each <var>ancestor</var> of <var>selectedcontent</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-ancestor" id="the-selectedcontent-element:ancestor" data-x-internal="ancestor">ancestors</a>, in reverse <a id="the-selectedcontent-element:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

    <ol><li>
      <p>If <var>ancestor</var> is a <code id="the-selectedcontent-element:the-select-element-7"><a href="#the-select-element">select</a></code> element:</p>

      <ol><li><p>If <var>nearestSelectAncestor</var> is null, then set <var>nearestSelectAncestor</var>
       to <var>select</var>.</p></li><li><p>Otherwise, set <var>selectedcontent</var>'s <a href="#selectedcontent-disabled" id="the-selectedcontent-element:selectedcontent-disabled-3">disabled</a> state to true.</p></li></ol>
     </li><li><p>If <var>ancestor</var> is an <code id="the-selectedcontent-element:the-option-element-7"><a href="#the-option-element">option</a></code> element or a
     <code id="the-selectedcontent-element:the-selectedcontent-element-10"><a href="#the-selectedcontent-element">selectedcontent</a></code> element, then set <var>selectedcontent</var>'s <a href="#selectedcontent-disabled" id="the-selectedcontent-element:selectedcontent-disabled-4">disabled</a> state to true.</p></li></ol>
   </li><li><p>If <var>nearestSelectAncestor</var> is null or <var>nearestSelectAncestor</var> has the
   <code id="the-selectedcontent-element:attr-select-multiple-2"><a href="#attr-select-multiple">multiple</a></code> attribute, then return.</p></li><li><p>Run <a href="#update-a-select's-selectedcontent" id="the-selectedcontent-element:update-a-select's-selectedcontent">update a <code>select</code>'s <code>selectedcontent</code></a> given
   <var>nearestSelectAncestor</var>.</p></li><li><p>Run <a href="#clear-a-select's-non-primary-selectedcontent-elements" id="the-selectedcontent-element:clear-a-select's-non-primary-selectedcontent-elements">clear a <code>select</code>'s non-primary <code>selectedcontent</code>
   elements</a> given <var>nearestSelectAncestor</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-selectedcontent-element:the-selectedcontent-element-11"><a href="#the-selectedcontent-element">selectedcontent</a></code> <a href="#html-element-removing-steps" id="the-selectedcontent-element:html-element-removing-steps">HTML element removing steps</a>, given
  <var>selectedcontent</var> and <var>oldParent</var>, are:</p>

  <ol><li>
    <p>For each <var>ancestor</var> of <var>selectedcontent</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-ancestor" id="the-selectedcontent-element:ancestor-2" data-x-internal="ancestor">ancestors</a>, in reverse <a id="the-selectedcontent-element:tree-order-4" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

    <ol><li><p>If <var>ancestor</var> is a <code id="the-selectedcontent-element:the-select-element-8"><a href="#the-select-element">select</a></code> element, then return.</p></li></ol>
   </li><li>
    <p>For each <var>ancestor</var> of <var>oldParent</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor" id="the-selectedcontent-element:inclusive-ancestor" data-x-internal="inclusive-ancestor">inclusive ancestors</a>, in reverse <a id="the-selectedcontent-element:tree-order-5" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

    <ol><li><p>If <var>ancestor</var> is a <code id="the-selectedcontent-element:the-select-element-9"><a href="#the-select-element">select</a></code> element, then run <a href="#update-a-select's-selectedcontent" id="the-selectedcontent-element:update-a-select's-selectedcontent-2">update a
     <code>select</code>'s <code>selectedcontent</code></a> given <var>ancestor</var> and
     return.</p></li></ol>
   </li></ol>
  </div>



  <h4 id="form-control-infrastructure"><span class="secno">4.10.18</span> Form control infrastructure<a href="#form-control-infrastructure" class="self-link"></a></h4>

  <h5 id="a-form-control's-value"><span class="secno">4.10.18.1</span> A form control's value<a href="#a-form-control's-value" class="self-link"></a></h5>

  <p>Most form controls have a <dfn id="concept-fe-value">value</dfn> and a <dfn id="concept-fe-checked">checkedness</dfn>. (The latter is only used by <code id="a-form-control's-value:the-input-element"><a href="#the-input-element">input</a></code>
  elements.) These are used to describe how the user interacts with the control.</p>

  <p>A control's <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value">value</a> is its internal state. As such, it
  might not match the user's current input.</p>

  <p class="example">For instance, if a user enters the word "<kbd>three</kbd>" into <a href="#number-state-(type=number)" id="a-form-control's-value:number-state-(type=number)">a numeric field</a> that expects digits, the user's input would
  be the string "three" but the control's <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value-2">value</a> would remain
  unchanged. Or, if a user enters the email address "<kbd>&nbsp;&nbsp;awesome@example.com</kbd>"
  (with leading whitespace) into <a href="#email-state-(type=email)" id="a-form-control's-value:email-state-(type=email)">an email field</a>, the
  user's input would be the string "&nbsp;&nbsp;awesome@example.com" but the browser's UI for
  email fields might translate that into a <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value-3">value</a> of "<code>awesome@example.com</code>" (without the leading whitespace).</p>

  <p id="concept-input-value-dirty-flag"><span id="concept-textarea-dirty"></span><code id="a-form-control's-value:the-input-element-2"><a href="#the-input-element">input</a></code>
  and <code id="a-form-control's-value:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements have a <dfn id="concept-fe-dirty">dirty value flag</dfn>.
  This is used to track the interaction between the <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value-4">value</a> and
  default value. If it is false, <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value-5">value</a> mirrors the default
  value. If it is true, the default value is ignored.</p>

  <p>Some form controls also have an <dfn id="concept-fe-optional-value">optional value</dfn>.
  This largely mirrors the <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value-6">value</a> but doesn't normalize to an
  empty string. <span class="note">This ought to be used sparingly, you generally want <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value-7">value</a></span>.</p>

  <p><code id="a-form-control's-value:the-input-element-3"><a href="#the-input-element">input</a></code>, <code id="a-form-control's-value:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code>, and <code id="a-form-control's-value:the-select-element"><a href="#the-select-element">select</a></code> elements have a
  <dfn id="user-validity">user validity</dfn> boolean. It is initially set to false.</p>

  <p>To define the behavior of constraint validation in the face of the <code id="a-form-control's-value:the-input-element-4"><a href="#the-input-element">input</a></code>
  element's <code id="a-form-control's-value:attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> attribute, <code id="a-form-control's-value:the-input-element-5"><a href="#the-input-element">input</a></code> elements
  can also have separately defined <dfn id="concept-fe-values">value<em>s</em></dfn>.</p>

  <p>To define the behavior of the <code id="a-form-control's-value:attr-fe-maxlength"><a href="#attr-fe-maxlength">maxlength</a></code> and <code id="a-form-control's-value:attr-fe-minlength"><a href="#attr-fe-minlength">minlength</a></code> attributes, as well as other APIs specific to the
  <code id="a-form-control's-value:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code> element, all form control with a <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value-8">value</a> also have an algorithm for obtaining an <span id="concept-textarea-api-value"></span><dfn id="concept-fe-api-value">API value</dfn>. By
  default this algorithm is to simply return the control's <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value-9">value</a>.</p>

  <p>The <code id="a-form-control's-value:the-select-element-2"><a href="#the-select-element">select</a></code> element does not have a <a href="#concept-fe-value" id="a-form-control's-value:concept-fe-value-10">value</a>;
  the <a href="#concept-option-selectedness" id="a-form-control's-value:concept-option-selectedness">selectedness</a> of its <code id="a-form-control's-value:the-option-element"><a href="#the-option-element">option</a></code>
  elements is what is used instead.</p>


  <h5 id="mutability"><span class="secno">4.10.18.2</span> Mutability<a href="#mutability" class="self-link"></a></h5>

  <p>A form control can be designated as <dfn id="concept-fe-mutable"><i>mutable</i></dfn>.</p>

  <p class="note">This determines (by means of definitions and requirements in this specification
  that rely on whether an element is so designated) whether or not the user can modify the <a href="#concept-fe-value" id="mutability:concept-fe-value">value</a> or <a href="#concept-fe-checked" id="mutability:concept-fe-checked">checkedness</a> of a
  form control, or whether or not a control can be automatically prefilled.</p>
  


  <h5 id="association-of-controls-and-forms"><span class="secno">4.10.18.3</span> Association of controls and forms<a href="#association-of-controls-and-forms" class="self-link"></a></h5>

  <p>A <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element">form-associated element</a> can have a relationship with a <code id="association-of-controls-and-forms:the-form-element"><a href="#the-form-element">form</a></code>
  element, which is called the element's <dfn data-dfn-for="button,fieldset,input,object,output,select,textarea,img,form-associated custom element" id="form-owner" data-export="">form
  owner</dfn>. If a <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-2">form-associated element</a> is not associated with a <code id="association-of-controls-and-forms:the-form-element-2"><a href="#the-form-element">form</a></code>
  element, its <a href="#form-owner" id="association-of-controls-and-forms:form-owner">form owner</a> is said to be null.</p>

  <p>A <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-3">form-associated element</a> has an associated <dfn id="parser-inserted-flag">parser inserted flag</dfn>.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#form</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes#attr-form" title="Elements in HTML have attributes; these are additional values that configure the elements or adjust their behavior in various ways to meet the criteria the users want.">Attributes#attr-form</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>≤4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>≤12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>≤6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>≤12.1+</span></span></div></div></div><p>A <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-4">form-associated element</a> is, by default, associated with its nearest ancestor <code id="association-of-controls-and-forms:the-form-element-3"><a href="#the-form-element">form</a></code> element (as described
  below), but, if it is <a href="#category-listed" id="association-of-controls-and-forms:category-listed">listed</a>, may have a <dfn data-dfn-for="button,fieldset,input,object,output,select,textarea" id="attr-fae-form" data-dfn-type="element-attr"><code>form</code></dfn> attribute specified to override this.</p>

  <p class="note">This feature allows authors to work around the lack of support for nested
  <code id="association-of-controls-and-forms:the-form-element-4"><a href="#the-form-element">form</a></code> elements.</p>

  <div data-algorithm="">
  <p>If a <a href="#category-listed" id="association-of-controls-and-forms:category-listed-2">listed</a> <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-5">form-associated element</a> has a
  <code id="association-of-controls-and-forms:attr-fae-form"><a href="#attr-fae-form">form</a></code> attribute specified, then that attribute's value must be
  the <a href="https://dom.spec.whatwg.org/#concept-id" id="association-of-controls-and-forms:concept-id" data-x-internal="concept-id">ID</a> of a <code id="association-of-controls-and-forms:the-form-element-5"><a href="#the-form-element">form</a></code> element in the element's
  <a id="association-of-controls-and-forms:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>.</p>
  </div>

  

  <p class="note">The rules in this section are complicated by the fact that although conforming
  documents or <a href="https://dom.spec.whatwg.org/#concept-tree" id="association-of-controls-and-forms:tree-2" data-x-internal="tree">trees</a> will never contain nested <code id="association-of-controls-and-forms:the-form-element-6"><a href="#the-form-element">form</a></code>
  elements, it is quite possible (e.g., using a script that performs DOM manipulation) to generate
  <a href="https://dom.spec.whatwg.org/#concept-tree" id="association-of-controls-and-forms:tree-3" data-x-internal="tree">trees</a> that have such nested elements. They are also complicated by
  rules in the HTML parser that, for historical reasons, can result in a <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-6">form-associated
  element</a> being associated with a <code id="association-of-controls-and-forms:the-form-element-7"><a href="#the-form-element">form</a></code> element that is not its ancestor.</p>

  <div data-algorithm="">
  <p>When a <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-7">form-associated element</a> is created, its <a href="#form-owner" id="association-of-controls-and-forms:form-owner-2">form owner</a> must be
  initialized to null (no owner).</p>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-8">form-associated element</a> is to be <dfn id="concept-form-association">associated</dfn> with a form, its <a href="#form-owner" id="association-of-controls-and-forms:form-owner-3">form owner</a> must
  be set to that form.</p>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#category-listed" id="association-of-controls-and-forms:category-listed-3">listed</a> <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-9">form-associated element</a>'s
  <code id="association-of-controls-and-forms:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> attribute is set, changed, or removed, then the user
  agent must <a href="#reset-the-form-owner" id="association-of-controls-and-forms:reset-the-form-owner">reset the form owner</a> of that element.</p>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#category-listed" id="association-of-controls-and-forms:category-listed-4">listed</a> <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-10">form-associated element</a> has a
  <code id="association-of-controls-and-forms:attr-fae-form-3"><a href="#attr-fae-form">form</a></code> attribute and the <a href="https://dom.spec.whatwg.org/#concept-id" id="association-of-controls-and-forms:concept-id-2" data-x-internal="concept-id">ID</a> of
  any of the elements in the <a id="association-of-controls-and-forms:tree-4" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> changes, then the user agent must <a href="#reset-the-form-owner" id="association-of-controls-and-forms:reset-the-form-owner-2">reset the
  form owner</a> of that <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-11">form-associated element</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When a <a href="#category-listed" id="association-of-controls-and-forms:category-listed-5">listed</a> <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-12">form-associated element</a> has a
  <code id="association-of-controls-and-forms:attr-fae-form-4"><a href="#attr-fae-form">form</a></code> attribute and an element with an <a href="https://dom.spec.whatwg.org/#concept-id" id="association-of-controls-and-forms:concept-id-3" data-x-internal="concept-id">ID</a> is <a href="#insert-an-element-into-a-document" id="association-of-controls-and-forms:insert-an-element-into-a-document">inserted
  into</a> or <a href="#remove-an-element-from-a-document" id="association-of-controls-and-forms:remove-an-element-from-a-document">removed from</a> the
  <code id="association-of-controls-and-forms:document"><a href="#document">Document</a></code>, or its <a href="#html-element-moving-steps" id="association-of-controls-and-forms:html-element-moving-steps">HTML element moving steps</a> are run, then the user agent
  must <a href="#reset-the-form-owner" id="association-of-controls-and-forms:reset-the-form-owner-3">reset the form owner</a> of that <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-13">form-associated element</a>.</p>
  </div>

  <p class="note">The form owner is also reset by the <a href="#html-element-insertion-steps" id="association-of-controls-and-forms:html-element-insertion-steps">HTML element insertion steps</a>,
  <a href="#html-element-removing-steps" id="association-of-controls-and-forms:html-element-removing-steps">HTML element removing steps</a>, and <a href="#html-element-moving-steps" id="association-of-controls-and-forms:html-element-moving-steps-2">HTML element moving steps</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="reset-the-form-owner">reset the form owner</dfn> of a <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-14">form-associated element</a>
  <var>element</var>:</p>

  <ol><li><p>Unset <var>element</var>'s <a href="#parser-inserted-flag" id="association-of-controls-and-forms:parser-inserted-flag">parser inserted flag</a>.</p></li><li>
    <p>If all of the following are true:</p>

    <ul><li><p><var>element</var>'s <a href="#form-owner" id="association-of-controls-and-forms:form-owner-4">form owner</a> is not null;</p></li><li><p><var>element</var> is not <a href="#category-listed" id="association-of-controls-and-forms:category-listed-6">listed</a> or its <code id="association-of-controls-and-forms:attr-fae-form-5"><a href="#attr-fae-form">form</a></code> content attribute is not present; and</p></li><li><p><var>element</var>'s <a href="#form-owner" id="association-of-controls-and-forms:form-owner-5">form owner</a> is its nearest <code id="association-of-controls-and-forms:the-form-element-8"><a href="#the-form-element">form</a></code> element
     ancestor after the change to the ancestor chain,</p></li></ul>

    <p>then return.</p>
   </li><li><p>Set <var>element</var>'s <a href="#form-owner" id="association-of-controls-and-forms:form-owner-6">form owner</a> to null.</p></li><li>
    <p>If <var>element</var> is <a href="#category-listed" id="association-of-controls-and-forms:category-listed-7">listed</a>, has a <code id="association-of-controls-and-forms:attr-fae-form-6"><a href="#attr-fae-form">form</a></code> content attribute, and is <a id="association-of-controls-and-forms:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then:</p>

    <ol><li><p>If the first element in <var>element</var>'s <a id="association-of-controls-and-forms:tree-5" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>, in <a id="association-of-controls-and-forms:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
     order</a>, to have an <a href="https://dom.spec.whatwg.org/#concept-id" id="association-of-controls-and-forms:concept-id-4" data-x-internal="concept-id">ID</a> that is <a id="association-of-controls-and-forms:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a>
     <var>element</var>'s <code id="association-of-controls-and-forms:attr-fae-form-7"><a href="#attr-fae-form">form</a></code> content attribute's value, is a
     <code id="association-of-controls-and-forms:the-form-element-9"><a href="#the-form-element">form</a></code> element, then <a href="#concept-form-association" id="association-of-controls-and-forms:concept-form-association">associate</a> the
     <var>element</var> with that <code id="association-of-controls-and-forms:the-form-element-10"><a href="#the-form-element">form</a></code> element.</p></li></ol>
   </li><li><p>Otherwise, if <var>element</var> has an ancestor <code id="association-of-controls-and-forms:the-form-element-11"><a href="#the-form-element">form</a></code> element, then <a href="#concept-form-association" id="association-of-controls-and-forms:concept-form-association-2">associate</a> <var>element</var> with the nearest such
   ancestor <code id="association-of-controls-and-forms:the-form-element-12"><a href="#the-form-element">form</a></code> element.</p></li></ol>
  </div>

  <div class="example">

   <p>In the following non-conforming snippet</p>

   <pre class="bad"><code class="html">...
 <c- p="">&lt;</c-><c- f="">form</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"b"</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'b'</c-><c- p="">).</c->innerHTML <c- o="">=</c->
     <c- t="">'&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;/form&gt;&lt;form id="c"&gt;&lt;input id="d"&gt;&lt;/table&gt;'</c-> <c- o="">+</c->
     <c- t="">'&lt;input id="e"&gt;'</c-><c- p="">;</c->
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
...</code></pre>

   <p>the <a href="#form-owner" id="association-of-controls-and-forms:form-owner-7">form owner</a> of "d" would be the inner nested form "c", while the <a href="#form-owner" id="association-of-controls-and-forms:form-owner-8">form
   owner</a> of "e" would be the outer form "a".</p>

   <p>This happens as follows: First, the "e" node gets associated with "c" in the <a href="#html-parser" id="association-of-controls-and-forms:html-parser">HTML
   parser</a>. Then, the <code id="association-of-controls-and-forms:dom-element-innerhtml"><a href="#dom-element-innerhtml">innerHTML</a></code> algorithm moves the nodes
   from the temporary document to the "b" element. At this point, the nodes see their ancestor chain
   change, and thus all the "magic" associations done by the parser are reset to normal ancestor
   associations.</p>

   <p>This example is a non-conforming document, though, as it is a violation of the content models
   to nest <code id="association-of-controls-and-forms:the-form-element-13"><a href="#the-form-element">form</a></code> elements, and there is a <a href="#parse-errors" id="association-of-controls-and-forms:parse-errors">parse error</a> for the <code>&lt;/form&gt;</code> tag.</p>

  </div>

  

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-fae-form" id="dom-fae-form-dev">form</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/form" title="The form read-only property of the HTMLObjectElement interface returns a HTMLFormElement representing the object element's form owner, or null if there isn't one.">HTMLObjectElement/form</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/form" title="The HTMLSelectElement.form read-only property returns a HTMLFormElement representing the form that this element is associated with. If the element is not associated with a <form> element, then it returns null.">HTMLSelectElement/form</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the element's <a href="#form-owner" id="association-of-controls-and-forms:form-owner-9">form owner</a>.</p>

    <p>Returns null if there isn't one.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p><a href="#category-listed" id="association-of-controls-and-forms:category-listed-8">Listed</a> <a href="#form-associated-element" id="association-of-controls-and-forms:form-associated-element-15">form-associated elements</a> except for <a href="#form-associated-custom-element" id="association-of-controls-and-forms:form-associated-custom-element">form-associated custom elements</a> have a <dfn data-dfn-for="HTMLObjectElement,HTMLInputElement,HTMLButtonElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOutputElement,HTMLFieldSetElement" id="dom-fae-form" data-dfn-type="attribute"><code>form</code></dfn> IDL attribute, which, on getting, must return the
  element's <a href="#form-owner" id="association-of-controls-and-forms:form-owner-10">form owner</a>, or null if there isn't one.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/form" title="The form read-only property of the ElementInternals interface returns the HTMLFormElement associated with this element.">ElementInternals/form</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p><a href="#form-associated-custom-element" id="association-of-controls-and-forms:form-associated-custom-element-2">Form-associated custom elements</a> don't have
  <code id="association-of-controls-and-forms:dom-fae-form"><a href="#dom-fae-form">form</a></code> IDL attribute. Instead, their
  <code id="association-of-controls-and-forms:elementinternals"><a href="#elementinternals">ElementInternals</a></code> object has a <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-form" data-dfn-type="attribute"><code>form</code></dfn> IDL attribute. On getting, it must throw a
  <a id="association-of-controls-and-forms:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="association-of-controls-and-forms:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the <a href="#internals-target" id="association-of-controls-and-forms:internals-target">target element</a> is not a <a href="#form-associated-custom-element" id="association-of-controls-and-forms:form-associated-custom-element-3">form-associated custom
  element</a>. Otherwise, it must return the element's <a href="#form-owner" id="association-of-controls-and-forms:form-owner-11">form owner</a>, or null if there
  isn't one.</p>
  </div>

  



  <h4 id="attributes-common-to-form-controls"><span class="secno">4.10.19</span> Attributes common to form controls<a href="#attributes-common-to-form-controls" class="self-link"></a></h4>

  <h5 id="naming-form-controls:-the-name-attribute"><span class="secno">4.10.19.1</span> Naming form controls: the <code id="naming-form-controls:-the-name-attribute:attr-fe-name"><a href="#attr-fe-name">name</a></code> attribute<a href="#naming-form-controls:-the-name-attribute" class="self-link"></a></h5>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#name</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="button,fieldset,input,output,select,textarea" id="attr-fe-name" data-dfn-type="element-attr"><code>name</code></dfn> content attribute gives the name of the form control, as
  used in <a href="#form-submission-2" id="naming-form-controls:-the-name-attribute:form-submission-2">form submission</a> and in the <code id="naming-form-controls:-the-name-attribute:the-form-element"><a href="#the-form-element">form</a></code> element's <code id="naming-form-controls:-the-name-attribute:dom-form-elements"><a href="#dom-form-elements">elements</a></code> object. If the attribute is specified, its value must
  not be the empty string or <code>isindex</code>.</p>

  <p class="note">A number of user agents historically implemented special support for first-in-form
  text controls with the name <code>isindex</code>, and this specification previously
  defined related user agent requirements for it. However, some user agents subsequently dropped
  that special support, and the related requirements were removed from this specification. So, to
  avoid problematic reinterpretations in legacy user agents, the name <code>isindex</code>
  is no longer allowed.</p>

  <p>Other than <code>isindex</code>, any non-empty value for <code id="naming-form-controls:-the-name-attribute:attr-form-name"><a href="#attr-form-name">name</a></code> is allowed. An <a id="naming-form-controls:-the-name-attribute:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
  the name <dfn id="attr-fe-name-charset"><code>_charset_</code></dfn> is special: if used as
  the name of a <a href="#hidden-state-(type=hidden)" id="naming-form-controls:-the-name-attribute:hidden-state-(type=hidden)">Hidden</a> control with no <code id="naming-form-controls:-the-name-attribute:attr-input-value"><a href="#attr-input-value">value</a></code> attribute, then during submission the <code id="naming-form-controls:-the-name-attribute:attr-input-value-2"><a href="#attr-input-value">value</a></code> attribute is automatically given a value consisting of the
  submission character encoding.</p>

  <div class="note">
   <p>DOM clobbering is a common cause of security issues. Avoid using the names of
   built-in form properties with the <code id="naming-form-controls:-the-name-attribute:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> content attribute.</p>

   <p>In this example, the <code id="naming-form-controls:-the-name-attribute:the-input-element"><a href="#the-input-element">input</a></code> element overrides the built-in <code id="naming-form-controls:-the-name-attribute:attr-fs-method"><a href="#attr-fs-method">method</a></code> property:</p>

   <pre><code class="js"><c- a="">let</c-> form <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"form"</c-><c- p="">);</c->
<c- a="">let</c-> input <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"input"</c-><c- p="">);</c->
form<c- p="">.</c->appendChild<c- p="">(</c->input<c- p="">);</c->

form<c- p="">.</c->method<c- p="">;</c->           <c- c1="">// =&gt; "get"</c->
input<c- p="">.</c->name <c- o="">=</c-> <c- u="">"method"</c-><c- p="">;</c-> <c- c1="">// DOM clobbering occurs here</c->
form<c- p="">.</c->method <c- o="">===</c-> input<c- p="">;</c-> <c- c1="">// =&gt; true</c-></code></pre>

   <p>Since the input name takes precedence over built-in form properties, the JavaScript reference
   <code>form.method</code> will point to the <code id="naming-form-controls:-the-name-attribute:the-input-element-2"><a href="#the-input-element">input</a></code> element named "method"
   instead of the built-in <code id="naming-form-controls:-the-name-attribute:attr-fs-method-2"><a href="#attr-fs-method">method</a></code> property.</p>
  </div>


  <h5 id="submitting-element-directionality:-the-dirname-attribute"><span class="secno">4.10.19.2</span> Submitting element directionality: the <code id="submitting-element-directionality:-the-dirname-attribute:attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code> attribute<a href="#submitting-element-directionality:-the-dirname-attribute" class="self-link"></a></h5>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#dirname" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#dirname</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>116+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>17+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="input,textarea" id="attr-fe-dirname" data-dfn-type="element-attr"><code>dirname</code></dfn>
  attribute on a form control element enables the submission of <a href="#the-directionality" id="submitting-element-directionality:-the-dirname-attribute:the-directionality">the directionality</a> of
  the element, and gives the name of the control that contains this value during <a href="#form-submission-2" id="submitting-element-directionality:-the-dirname-attribute:form-submission-2">form
  submission</a>. If such an attribute is specified, its value must not be the empty string.</p>

  <div class="example">

   <p>In this example, a form contains a text control and a submission button:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"addcomment.cgi"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">post</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Comment: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"comment"</c-> <c- e="">dirname</c-><c- o="">=</c-><c- s="">"comment.dir"</c-> <c- e="">required</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"mode"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"add"</c-><c- p="">&gt;</c->Post Comment<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

   <p>When the user submits the form, the user agent includes three fields, one called "comment",
   one called "comment.dir", and one called "mode"; so if the user types "Hello", the submission
   body might be something like:</p>

   <pre>comment=Hello&amp;<strong>comment.dir=ltr</strong>&amp;mode=add</pre>

   <p>If the user manually switches to a right-to-left writing direction and enters "<span dir="rtl" lang="ar">مرحبا</span>", the submission body might be
   something like:</p>

   <pre>comment=%D9%85%D8%B1%D8%AD%D8%A8%D8%A7&amp;<strong>comment.dir=rtl</strong>&amp;mode=add</pre>

  </div>


  <h5 id="limiting-user-input-length:-the-maxlength-attribute"><span class="secno">4.10.19.3</span> Limiting user input length: the <code id="limiting-user-input-length:-the-maxlength-attribute:attr-fe-maxlength"><a href="#attr-fe-maxlength">maxlength</a></code> attribute<a href="#limiting-user-input-length:-the-maxlength-attribute" class="self-link"></a></h5>

  <p>A <dfn data-dfn-for="input,textarea" id="attr-fe-maxlength" data-dfn-type="element-attr" data-lt="maxlength">form
  control <code>maxlength</code> attribute</dfn>, controlled by the <a href="#concept-fe-dirty" id="limiting-user-input-length:-the-maxlength-attribute:concept-fe-dirty">dirty value flag</a>, declares a limit on the number of characters a
  user can input. The number of characters is measured using <a id="limiting-user-input-length:-the-maxlength-attribute:length" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> and, in the case
  of <code id="limiting-user-input-length:-the-maxlength-attribute:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements, with all newlines normalized to a single character (as opposed
  to CRLF pairs).</p>

  <div data-algorithm="">
  <p>If an element has its <a href="#attr-fe-maxlength" id="limiting-user-input-length:-the-maxlength-attribute:attr-fe-maxlength-2">form control <code>maxlength</code> attribute</a> specified, the attribute's value must be a <a href="#valid-non-negative-integer" id="limiting-user-input-length:-the-maxlength-attribute:valid-non-negative-integer">valid
  non-negative integer</a>. If the attribute is specified and applying the <a href="#rules-for-parsing-non-negative-integers" id="limiting-user-input-length:-the-maxlength-attribute:rules-for-parsing-non-negative-integers">rules for
  parsing non-negative integers</a> to its value results in a number, then that number is the
  element's <dfn id="maximum-allowed-value-length">maximum allowed value length</dfn>. If the attribute is omitted or parsing its
  value results in an error, then there is no <a href="#maximum-allowed-value-length" id="limiting-user-input-length:-the-maxlength-attribute:maximum-allowed-value-length">maximum allowed value length</a>.</p>
  </div>

  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If an element has a <a href="#maximum-allowed-value-length" id="limiting-user-input-length:-the-maxlength-attribute:maximum-allowed-value-length-2">maximum allowed value
  length</a>, its <a href="#concept-fe-dirty" id="limiting-user-input-length:-the-maxlength-attribute:concept-fe-dirty-2">dirty value flag</a> is true, its <a href="#concept-fe-value" id="limiting-user-input-length:-the-maxlength-attribute:concept-fe-value">value</a> was last changed by a user edit (as opposed to a change
  made by a script), and the <a id="limiting-user-input-length:-the-maxlength-attribute:length-2" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the element's <a href="#concept-fe-api-value" id="limiting-user-input-length:-the-maxlength-attribute:concept-fe-api-value">API value</a> is greater than the element's <a href="#maximum-allowed-value-length" id="limiting-user-input-length:-the-maxlength-attribute:maximum-allowed-value-length-3">maximum allowed
  value length</a>, then the element is <a href="#suffering-from-being-too-long" id="limiting-user-input-length:-the-maxlength-attribute:suffering-from-being-too-long">suffering from being too long</a>.</p>
  </div>

  <p>User agents may prevent the user from causing the element's <a href="#concept-fe-api-value" id="limiting-user-input-length:-the-maxlength-attribute:concept-fe-api-value-2">API value</a> to be set to a value whose <a id="limiting-user-input-length:-the-maxlength-attribute:length-3" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> is
  greater than the element's <a href="#maximum-allowed-value-length" id="limiting-user-input-length:-the-maxlength-attribute:maximum-allowed-value-length-4">maximum allowed value length</a>.</p>

  <p class="note">In the case of <code id="limiting-user-input-length:-the-maxlength-attribute:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> elements, the <a href="#concept-fe-api-value" id="limiting-user-input-length:-the-maxlength-attribute:concept-fe-api-value-3">API value</a> and <a href="#concept-fe-value" id="limiting-user-input-length:-the-maxlength-attribute:concept-fe-value-2">value</a>
  differ. In particular, <a href="https://infra.spec.whatwg.org/#normalize-newlines" id="limiting-user-input-length:-the-maxlength-attribute:normalize-newlines" data-x-internal="normalize-newlines">newline normalization</a> is applied
  before the <a href="#maximum-allowed-value-length" id="limiting-user-input-length:-the-maxlength-attribute:maximum-allowed-value-length-5">maximum allowed value length</a> is checked (whereas the <a href="#textarea-wrapping-transformation" id="limiting-user-input-length:-the-maxlength-attribute:textarea-wrapping-transformation">textarea
  wrapping transformation</a> is not applied).</p>

  


  <h5 id="setting-minimum-input-length-requirements:-the-minlength-attribute"><span class="secno">4.10.19.4</span> Setting minimum input length requirements: the <code id="setting-minimum-input-length-requirements:-the-minlength-attribute:attr-fe-minlength"><a href="#attr-fe-minlength">minlength</a></code> attribute<a href="#setting-minimum-input-length-requirements:-the-minlength-attribute" class="self-link"></a></h5>

  <p>A <dfn data-dfn-for="input,textarea" id="attr-fe-minlength" data-dfn-type="element-attr" data-lt="minlength">form
  control <code>minlength</code> attribute</dfn>, controlled by the <a href="#concept-fe-dirty" id="setting-minimum-input-length-requirements:-the-minlength-attribute:concept-fe-dirty">dirty value flag</a>, declares a lower bound on the number of
  characters a user can input. The "number of characters" is measured using <a id="setting-minimum-input-length-requirements:-the-minlength-attribute:length" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> and,
  in the case of <code id="setting-minimum-input-length-requirements:-the-minlength-attribute:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements, with all newlines normalized to a single character
  (as opposed to CRLF pairs).</p>

  <p class="note">The <code id="setting-minimum-input-length-requirements:-the-minlength-attribute:attr-fe-minlength-2"><a href="#attr-fe-minlength">minlength</a></code> attribute does not imply the
  <code>required</code> attribute. If the form control has no <code>required</code> attribute, then the value can still be omitted; the <code id="setting-minimum-input-length-requirements:-the-minlength-attribute:attr-fe-minlength-3"><a href="#attr-fe-minlength">minlength</a></code> attribute only kicks in once the user has entered a
  value at all. If the empty string is not allowed, then the <code>required</code>
  attribute also needs to be set.</p>

  <div data-algorithm="">
  <p>If an element has its <a href="#attr-fe-minlength" id="setting-minimum-input-length-requirements:-the-minlength-attribute:attr-fe-minlength-4">form control <code>minlength</code> attribute</a> specified, the attribute's value must be a <a href="#valid-non-negative-integer" id="setting-minimum-input-length-requirements:-the-minlength-attribute:valid-non-negative-integer">valid
  non-negative integer</a>. If the attribute is specified and applying the <a href="#rules-for-parsing-non-negative-integers" id="setting-minimum-input-length-requirements:-the-minlength-attribute:rules-for-parsing-non-negative-integers">rules for
  parsing non-negative integers</a> to its value results in a number, then that number is the
  element's <dfn id="minimum-allowed-value-length">minimum allowed value length</dfn>. If the attribute is omitted or parsing its
  value results in an error, then there is no <a href="#minimum-allowed-value-length" id="setting-minimum-input-length-requirements:-the-minlength-attribute:minimum-allowed-value-length">minimum allowed value length</a>.</p>
  </div>

  <p>If an element has both a <a href="#maximum-allowed-value-length" id="setting-minimum-input-length-requirements:-the-minlength-attribute:maximum-allowed-value-length">maximum allowed value length</a> and a <a href="#minimum-allowed-value-length" id="setting-minimum-input-length-requirements:-the-minlength-attribute:minimum-allowed-value-length-2">minimum allowed
  value length</a>, the <a href="#minimum-allowed-value-length" id="setting-minimum-input-length-requirements:-the-minlength-attribute:minimum-allowed-value-length-3">minimum allowed value length</a> must be smaller than or equal
  to the <a href="#maximum-allowed-value-length" id="setting-minimum-input-length-requirements:-the-minlength-attribute:maximum-allowed-value-length-2">maximum allowed value length</a>.</p>

  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If an element has a <a href="#minimum-allowed-value-length" id="setting-minimum-input-length-requirements:-the-minlength-attribute:minimum-allowed-value-length-4">minimum allowed value
  length</a>, its <a href="#concept-fe-dirty" id="setting-minimum-input-length-requirements:-the-minlength-attribute:concept-fe-dirty-2">dirty value flag</a> is true, its <a href="#concept-fe-value" id="setting-minimum-input-length-requirements:-the-minlength-attribute:concept-fe-value">value</a> was last changed by a user edit (as opposed to a change
  made by a script), its <a href="#concept-fe-value" id="setting-minimum-input-length-requirements:-the-minlength-attribute:concept-fe-value-2">value</a> is not the empty string, and
  the <a id="setting-minimum-input-length-requirements:-the-minlength-attribute:length-2" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the element's <a href="#concept-fe-api-value" id="setting-minimum-input-length-requirements:-the-minlength-attribute:concept-fe-api-value">API value</a> is
  less than the element's <a href="#minimum-allowed-value-length" id="setting-minimum-input-length-requirements:-the-minlength-attribute:minimum-allowed-value-length-5">minimum allowed value length</a>, then the element is
  <a href="#suffering-from-being-too-short" id="setting-minimum-input-length-requirements:-the-minlength-attribute:suffering-from-being-too-short">suffering from being too short</a>.</p>
  </div>

  

  <div class="example">

   <p>In this example, there are four text controls. The first is required, and has to be at least 5
   characters long. The other three are optional, but if the user fills one in, the user has to
   enter at least 10 characters.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"/events/menu.cgi"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"post"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name of Event: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">required</c-> <c- e="">minlength</c-><c- o="">=</c-><c- s="">5</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">50</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">event</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Describe what you would like for breakfast, if anything:
    <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"breakfast"</c-> <c- e="">minlength</c-><c- o="">=</c-><c- s="">"10"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Describe what you would like for lunch, if anything:
    <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"lunch"</c-> <c- e="">minlength</c-><c- o="">=</c-><c- s="">"10"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Describe what you would like for dinner, if anything:
    <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"dinner"</c-> <c- e="">minlength</c-><c- o="">=</c-><c- s="">"10"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Submit Request"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>


  </div>


  <h5 id="enabling-and-disabling-form-controls:-the-disabled-attribute"><span class="secno">4.10.19.5</span> Enabling and disabling form controls: the <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code> attribute<a href="#enabling-and-disabling-form-controls:-the-disabled-attribute" class="self-link"></a></h5>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled" title="The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants.">Attributes/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled" title="The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants.">Attributes/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled" title="The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants.">Attributes/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled" title="The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants.">Attributes/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled" title="The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants.">Attributes/disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="button,fieldset,input,object,output,select,textarea" id="attr-fe-disabled" data-dfn-type="element-attr"><code>disabled</code></dfn> content attribute is a <a href="#boolean-attribute" id="enabling-and-disabling-form-controls:-the-disabled-attribute:boolean-attribute">boolean
  attribute</a>.</p>

  <p class="note">The <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:attr-option-disabled"><a href="#attr-option-disabled">disabled</a></code> attribute for
  <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:the-option-element"><a href="#the-option-element">option</a></code> elements and the <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:attr-optgroup-disabled"><a href="#attr-optgroup-disabled">disabled</a></code>
  attribute for <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> elements are defined separately.</p>

  <div data-algorithm="">
  <p>A form control is <dfn id="concept-fe-disabled">disabled</dfn> if any of the following are
  true:</p>

  <ul><li><p>the element is a <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:the-button-element"><a href="#the-button-element">button</a></code>, <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:the-input-element"><a href="#the-input-element">input</a></code>, <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:the-select-element"><a href="#the-select-element">select</a></code>,
   <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>, or <a href="#form-associated-custom-element" id="enabling-and-disabling-form-controls:-the-disabled-attribute:form-associated-custom-element">form-associated custom element</a>, and the <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:attr-fe-disabled-2"><a href="#attr-fe-disabled">disabled</a></code> attribute is specified on this element (regardless of
   its value); or</p></li><li><p>the element is a descendant of a <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code> element whose <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:attr-fieldset-disabled"><a href="#attr-fieldset-disabled">disabled</a></code> attribute is specified, and is <em>not</em> a
   descendant of that <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:the-fieldset-element-2"><a href="#the-fieldset-element">fieldset</a></code> element's first <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:the-legend-element"><a href="#the-legend-element">legend</a></code> element child, if
   any.</p></li></ul>
  </div>

  

  <p>A form control that is <a href="#concept-fe-disabled" id="enabling-and-disabling-form-controls:-the-disabled-attribute:concept-fe-disabled">disabled</a> must prevent any
  <code id="enabling-and-disabling-form-controls:-the-disabled-attribute:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> events that are <a href="#queue-a-task" id="enabling-and-disabling-form-controls:-the-disabled-attribute:queue-a-task">queued</a>
  on the <a href="#user-interaction-task-source" id="enabling-and-disabling-form-controls:-the-disabled-attribute:user-interaction-task-source">user interaction task source</a> from being dispatched on the element.</p>

  

  <p class="note">Being <a href="#concept-fe-disabled" id="enabling-and-disabling-form-controls:-the-disabled-attribute:concept-fe-disabled-2">disabled</a> does not prevent all
  modifications to the form control. For example, the control's <a href="#concept-fe-value" id="enabling-and-disabling-form-controls:-the-disabled-attribute:concept-fe-value">value</a> or <a href="#concept-fe-checked" id="enabling-and-disabling-form-controls:-the-disabled-attribute:concept-fe-checked">checkedness</a>
  could be modified programmatically from JavaScript. Or, they could be indirectly modified by user
  action, e.g., if other non-disabled elements in the control's <a href="#radio-button-group" id="enabling-and-disabling-form-controls:-the-disabled-attribute:radio-button-group">radio button group</a> were
  modified.</p>

  

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If an element is <a href="#concept-fe-disabled" id="enabling-and-disabling-form-controls:-the-disabled-attribute:concept-fe-disabled-3">disabled</a>, it is <a href="#barred-from-constraint-validation" id="enabling-and-disabling-form-controls:-the-disabled-attribute:barred-from-constraint-validation">barred from constraint
  validation</a>.</p>
  </div>

  


  <h5 id="form-submission-attributes"><span class="secno">4.10.19.6</span> Form submission attributes<a href="#form-submission-attributes" class="self-link"></a></h5>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#Attributes_for_form_submission" title="The <form> HTML element represents a document section containing interactive controls for submitting information.">Element/form#Attributes_for_form_submission</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p><dfn id="attributes-for-form-submission">Attributes for form submission</dfn> can be specified both on <code id="form-submission-attributes:the-form-element"><a href="#the-form-element">form</a></code> elements
  and on <a href="#concept-submit-button" id="form-submission-attributes:concept-submit-button">submit buttons</a> (elements that represent buttons
  that submit forms, e.g. an <code id="form-submission-attributes:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="form-submission-attributes:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#submit-button-state-(type=submit)" id="form-submission-attributes:submit-button-state-(type=submit)">Submit Button</a> state).

  </p><p>The <a href="#attributes-for-form-submission" id="form-submission-attributes:attributes-for-form-submission">attributes for form submission</a> that may be specified on <code id="form-submission-attributes:the-form-element-2"><a href="#the-form-element">form</a></code>
  elements are <code id="form-submission-attributes:attr-fs-action"><a href="#attr-fs-action">action</a></code>, <code id="form-submission-attributes:attr-fs-enctype"><a href="#attr-fs-enctype">enctype</a></code>, <code id="form-submission-attributes:attr-fs-method"><a href="#attr-fs-method">method</a></code>, <code id="form-submission-attributes:attr-fs-novalidate"><a href="#attr-fs-novalidate">novalidate</a></code>, and <code id="form-submission-attributes:attr-fs-target"><a href="#attr-fs-target">target</a></code>.</p>

  <p>The corresponding <a href="#attributes-for-form-submission" id="form-submission-attributes:attributes-for-form-submission-2">attributes for form submission</a> that may be specified on <a href="#concept-submit-button" id="form-submission-attributes:concept-submit-button-2">submit buttons</a> are <code id="form-submission-attributes:attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>, <code id="form-submission-attributes:attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>, <code id="form-submission-attributes:attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>, <code id="form-submission-attributes:attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>, and <code id="form-submission-attributes:attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>. When omitted, they default to the values given on
  the corresponding attributes on the <code id="form-submission-attributes:the-form-element-3"><a href="#the-form-element">form</a></code> element.</p>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formaction" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#formaction</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>9+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="form,button" id="attr-fs-action" data-dfn-type="element-attr"><code>action</code></dfn> and
  <dfn data-dfn-for="form,button" id="attr-fs-formaction" data-dfn-type="element-attr"><code>formaction</code></dfn>
  content attributes, if specified, must have a value that is a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="form-submission-attributes:valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL
  potentially surrounded by spaces</a>.</p>

  <p>The <dfn id="concept-fs-action">action</dfn> of an element is the value of the element's
  <code id="form-submission-attributes:attr-fs-formaction-2"><a href="#attr-fs-formaction">formaction</a></code> attribute, if the element is a <a href="#concept-submit-button" id="form-submission-attributes:concept-submit-button-3">submit button</a> and has such an attribute, or the value of its
  <a href="#form-owner" id="form-submission-attributes:form-owner">form owner</a>'s <code id="form-submission-attributes:attr-fs-action-2"><a href="#attr-fs-action">action</a></code> attribute, if <em>it</em> has
  one, or else the empty string.</p>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formmethod" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#formmethod</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>9+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="form,button" id="attr-fs-method" data-dfn-type="element-attr"><code>method</code></dfn> and
  <dfn data-dfn-for="form,button" id="attr-fs-formmethod" data-dfn-type="element-attr"><code>formmethod</code></dfn>
  content attributes are <a href="#enumerated-attribute" id="form-submission-attributes:enumerated-attribute">enumerated attributes</a> with the
  following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="form/method,button/formmethod,input/formmethod" id="attr-fs-method-get-keyword" data-dfn-type="attr-value"><code>get</code></dfn>
     </td><td><dfn id="attr-fs-method-get">GET</dfn>
     </td><td>Indicates the <code id="form-submission-attributes:the-form-element-4"><a href="#the-form-element">form</a></code> will use the HTTP GET method.
    </td></tr><tr><td><dfn data-dfn-for="form/method,button/formmethod,input/formmethod" id="attr-fs-method-post-keyword" data-dfn-type="attr-value"><code>post</code></dfn>
     </td><td><dfn id="attr-fs-method-post">POST</dfn>
     </td><td>Indicates the <code id="form-submission-attributes:the-form-element-5"><a href="#the-form-element">form</a></code> will use the HTTP POST method.
    </td></tr><tr><td><dfn data-dfn-for="form/method,button/formmethod,input/formmethod" id="attr-fs-method-dialog-keyword" data-dfn-type="attr-value"><code>dialog</code></dfn>
     </td><td><dfn id="attr-fs-method-dialog">Dialog</dfn>
     </td><td>Indicates the <code id="form-submission-attributes:the-form-element-6"><a href="#the-form-element">form</a></code> is intended to close the <code id="form-submission-attributes:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> box in which
     the form finds itself, if any, and otherwise not submit.
  </td></tr></tbody></table>

  <p>The <code id="form-submission-attributes:attr-fs-method-2"><a href="#attr-fs-method">method</a></code> attribute's <i id="form-submission-attributes:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="form-submission-attributes:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i>
  are both the <a href="#attr-fs-method-get" id="form-submission-attributes:attr-fs-method-get">GET</a> state.</p>

  <p>The <code id="form-submission-attributes:attr-fs-formmethod-2"><a href="#attr-fs-formmethod">formmethod</a></code> attribute has no <i id="form-submission-attributes:missing-value-default-2"><a href="#missing-value-default">missing value default</a></i>, and its <i id="form-submission-attributes:invalid-value-default-2"><a href="#invalid-value-default">invalid value
  default</a></i> is the <a href="#attr-fs-method-get" id="form-submission-attributes:attr-fs-method-get-2">GET</a> state.</p>

  <div data-algorithm="">
  <p>The <dfn id="concept-fs-method">method</dfn> of an element is one of those states. If the
  element is a <a href="#concept-submit-button" id="form-submission-attributes:concept-submit-button-4">submit button</a> and has a <code id="form-submission-attributes:attr-fs-formmethod-3"><a href="#attr-fs-formmethod">formmethod</a></code> attribute, then the element's <a href="#concept-fs-method" id="form-submission-attributes:concept-fs-method">method</a> is that attribute's state; otherwise, it is the <a href="#form-owner" id="form-submission-attributes:form-owner-2">form
  owner</a>'s <code id="form-submission-attributes:attr-fs-method-3"><a href="#attr-fs-method">method</a></code> attribute's state.</p>
  </div>

  <div class="example">

   <p>Here the <code id="form-submission-attributes:attr-fs-method-4"><a href="#attr-fs-method">method</a></code> attribute is used to explicitly specify
   the default value, "<code id="form-submission-attributes:attr-fs-method-get-keyword"><a href="#attr-fs-method-get-keyword">get</a></code>", so that the search
   query is submitted in the URL:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"get"</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"/search.cgi"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Search terms: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">search</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">q</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>On the other hand, here the <code id="form-submission-attributes:attr-fs-method-5"><a href="#attr-fs-method">method</a></code> attribute is used to
   specify the value "<code id="form-submission-attributes:attr-fs-method-post-keyword"><a href="#attr-fs-method-post-keyword">post</a></code>", so that the user's
   message is submitted in the HTTP request's body:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"post"</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"/post-message.cgi"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Message: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">m</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Submit message"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In this example, a <code id="form-submission-attributes:the-form-element-7"><a href="#the-form-element">form</a></code> is used with a <code id="form-submission-attributes:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code>. The <code id="form-submission-attributes:attr-fs-method-6"><a href="#attr-fs-method">method</a></code> attribute's "<code id="form-submission-attributes:attr-fs-method-dialog-keyword"><a href="#attr-fs-method-dialog-keyword">dialog</a></code>" keyword is used to have the dialog
   automatically close when the form is submitted.</p>

   <pre lang="en-GB"><code class="html"><c- p="">&lt;</c-><c- f="">dialog</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"ship"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">dialog</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->A ship has arrived in the harbour.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"board"</c-><c- p="">&gt;</c->Board the ship<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"call"</c-><c- p="">&gt;</c->Call to the captain<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dialog</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> ship <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'ship'</c-><c- p="">);</c->
 ship<c- p="">.</c->showModal<c- p="">();</c->
 ship<c- p="">.</c->onclose <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
   <c- k="">if</c-> <c- p="">(</c->ship<c- p="">.</c->returnValue <c- o="">==</c-> <c- t="">'board'</c-><c- p="">)</c-> <c- p="">{</c->
     <c- c1="">// ...</c->
   <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
     <c- c1="">// ...</c->
   <c- p="">}</c->
 <c- p="">};</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formenctype" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#formenctype</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>9+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="form,button" id="attr-fs-enctype" data-dfn-type="element-attr"><code>enctype</code></dfn> and
  <dfn data-dfn-for="form,button" id="attr-fs-formenctype" data-dfn-type="element-attr"><code>formenctype</code></dfn>
  content attributes are <a href="#enumerated-attribute" id="form-submission-attributes:enumerated-attribute-2">enumerated attributes</a> with the
  following keywords and states:</p>

  <ul><li>The "<dfn data-dfn-for="form/enctype,button/enctype" id="attr-fs-enctype-urlencoded" data-dfn-type="attr-value"><code>application/x-www-form-urlencoded</code></dfn>" keyword and
   corresponding state.</li><li>The "<dfn data-dfn-for="form/enctype,button/enctype" id="attr-fs-enctype-formdata" data-dfn-type="attr-value"><code>multipart/form-data</code></dfn>" keyword and corresponding
   state.</li><li>The "<dfn data-dfn-for="form/enctype,button/enctype" id="attr-fs-enctype-text" data-dfn-type="attr-value"><code>text/plain</code></dfn>" keyword and corresponding state.</li></ul>

  <div data-algorithm="">
  <p>The attribute's <i id="form-submission-attributes:missing-value-default-3"><a href="#missing-value-default">missing value default</a></i> and <i id="form-submission-attributes:invalid-value-default-3"><a href="#invalid-value-default">invalid value default</a></i> are both the <code id="form-submission-attributes:attr-fs-enctype-urlencoded"><a href="#attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</a></code> state.</p>
  </div>

  <p>The <code id="form-submission-attributes:attr-fs-formenctype-2"><a href="#attr-fs-formenctype">formenctype</a></code> attribute has no <i id="form-submission-attributes:missing-value-default-4"><a href="#missing-value-default">missing value default</a></i>, and its <i id="form-submission-attributes:invalid-value-default-4"><a href="#invalid-value-default">invalid value
  default</a></i> is the <code id="form-submission-attributes:attr-fs-enctype-urlencoded-2"><a href="#attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</a></code> state.</p>

  <div data-algorithm="">
  <p>The <dfn id="concept-fs-enctype">enctype</dfn> of an element is one of those three states.
  If the element is a <a href="#concept-submit-button" id="form-submission-attributes:concept-submit-button-5">submit button</a> and has a <code id="form-submission-attributes:attr-fs-formenctype-3"><a href="#attr-fs-formenctype">formenctype</a></code> attribute, then the element's <a href="#concept-fs-enctype" id="form-submission-attributes:concept-fs-enctype">enctype</a> is that attribute's state; otherwise, it is the
  <a href="#form-owner" id="form-submission-attributes:form-owner-3">form owner</a>'s <code id="form-submission-attributes:attr-fs-enctype-2"><a href="#attr-fs-enctype">enctype</a></code> attribute's state.</p>
  </div>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formtarget" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#formtarget</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>9+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="form,button" id="attr-fs-target" data-dfn-type="element-attr"><code>target</code></dfn> and
  <dfn data-dfn-for="form,button" id="attr-fs-formtarget" data-dfn-type="element-attr"><code>formtarget</code></dfn>
  content attributes, if specified, must have values that are <a href="#valid-navigable-target-name-or-keyword" id="form-submission-attributes:valid-navigable-target-name-or-keyword">valid navigable target names or keywords</a>.</p>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formnovalidate" title="The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.">Element/input#formnovalidate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>The <dfn data-dfn-for="form,button" id="attr-fs-novalidate" data-dfn-type="element-attr"><code>novalidate</code></dfn> and <dfn data-dfn-for="form,button" id="attr-fs-formnovalidate" data-dfn-type="element-attr"><code>formnovalidate</code></dfn> content attributes are <a href="#boolean-attribute" id="form-submission-attributes:boolean-attribute">boolean attributes</a>. If present, they indicate that the form is
  not to be validated during submission.</p>

  <div data-algorithm="">
  <p>The <dfn id="concept-fs-novalidate">no-validate state</dfn> of an element is true if the
  element is a <a href="#concept-submit-button" id="form-submission-attributes:concept-submit-button-6">submit button</a> and the element's <code id="form-submission-attributes:attr-fs-formnovalidate-2"><a href="#attr-fs-formnovalidate">formnovalidate</a></code> attribute is present, or if the element's
  <a href="#form-owner" id="form-submission-attributes:form-owner-4">form owner</a>'s <code id="form-submission-attributes:attr-fs-novalidate-2"><a href="#attr-fs-novalidate">novalidate</a></code> attribute is present,
  and false otherwise.</p>
  </div>

  <div class="example">

   <p>This attribute is useful to include "save" buttons on forms that have validation constraints,
   to allow users to save their progress even though they haven't fully entered the data in the
   form. The following example shows a simple form that has two required fields. There are three
   buttons: one to submit the form, which requires both fields to be filled in; one to save the form
   so that the user can come back and fill it in later; and one to cancel the form altogether.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"editor.cgi"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"post"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">required</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">fn</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Essay: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">required</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">essay</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Submit essay"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">formnovalidate</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">save</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Save essay"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">formnovalidate</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">cancel</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Cancel"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/action" title="The HTMLFormElement.action property represents the action of the <form> element.">HTMLFormElement/action</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFormElement" id="dom-fs-action" data-dfn-type="attribute"><code>action</code></dfn>
  getter steps are:</p>

  <ol><li><p>Let <var>attribute</var> be <a id="form-submission-attributes:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="form-submission-attributes:attr-fs-action-3"><a href="#attr-fs-action">action</a></code> attribute.</p></li><li><p>If <var>attribute</var> is null or <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="form-submission-attributes:concept-attribute-value" data-x-internal="concept-attribute-value">value</a> is the empty string, then return
   <a id="form-submission-attributes:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="form-submission-attributes:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="form-submission-attributes:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li><p>Let <var>urlString</var> be the result of <a href="#encoding-parsing-and-serializing-a-url" id="form-submission-attributes:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing a
   URL</a> given <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="form-submission-attributes:concept-attribute-value-2" data-x-internal="concept-attribute-value">value</a>,
   relative to <a id="form-submission-attributes:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="form-submission-attributes:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>urlString</var> is not failure, then return <var>urlString</var>.</p></li><li><p>Return <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="form-submission-attributes:concept-attribute-value-3" data-x-internal="concept-attribute-value">value</a>, <a href="https://infra.spec.whatwg.org/#javascript-string-convert" id="form-submission-attributes:convert" data-x-internal="convert">converted to a scalar value string</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLButtonElement,HTMLInputElement" id="dom-fs-formaction" data-dfn-type="attribute"><code>formAction</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>attribute</var> be <a id="form-submission-attributes:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="form-submission-attributes:attr-fs-formaction-3"><a href="#attr-fs-formaction">formaction</a></code> attribute.</p></li><li><p>If <var>attribute</var> is null or <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="form-submission-attributes:concept-attribute-value-4" data-x-internal="concept-attribute-value">value</a> is the empty string, then return
   <a id="form-submission-attributes:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="form-submission-attributes:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="form-submission-attributes:the-document's-address-2" data-x-internal="the-document's-address">URL</a>.</p></li><li><p>Let <var>urlString</var> be the result of <a href="#encoding-parsing-and-serializing-a-url" id="form-submission-attributes:encoding-parsing-and-serializing-a-url-2">encoding-parsing-and-serializing a
   URL</a> given <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="form-submission-attributes:concept-attribute-value-5" data-x-internal="concept-attribute-value">value</a>,
   relative to <a id="form-submission-attributes:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="form-submission-attributes:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>urlString</var> is not failure, then return <var>urlString</var>.</p></li><li><p>Return <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="form-submission-attributes:concept-attribute-value-6" data-x-internal="concept-attribute-value">value</a>, <a href="https://infra.spec.whatwg.org/#javascript-string-convert" id="form-submission-attributes:convert-2" data-x-internal="convert">converted to a scalar value string</a>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/method" title="The HTMLFormElement.method property represents the HTTP method used to submit the <form>.">HTMLFormElement/method</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/enctype" title="The HTMLFormElement.enctype property is the MIME type of content that is used to submit the form to the server. Possible values are:">HTMLFormElement/enctype</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/encoding" title="The HTMLFormElement.encoding property is an alternative name for the enctype element on the DOM HTMLFormElement object.">HTMLFormElement/encoding</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFormElement" id="dom-fs-method" data-dfn-type="attribute"><code>method</code></dfn> and
  <dfn data-dfn-for="HTMLFormElement" id="dom-fs-enctype" data-dfn-type="attribute"><code>enctype</code></dfn> IDL
  attributes must <a href="#reflect" id="form-submission-attributes:reflect">reflect</a> the respective content attributes of the same name,
  <a href="#limited-to-only-known-values" id="form-submission-attributes:limited-to-only-known-values">limited to only known values</a>. The <dfn data-dfn-for="HTMLFormElement" id="dom-fs-encoding" data-dfn-type="attribute"><code>encoding</code></dfn> IDL attribute must <a href="#reflect" id="form-submission-attributes:reflect-2">reflect</a> the <code id="form-submission-attributes:attr-fs-enctype-3"><a href="#attr-fs-enctype">enctype</a></code> content attribute, <a href="#limited-to-only-known-values" id="form-submission-attributes:limited-to-only-known-values-2">limited to only known
  values</a>. The <dfn data-dfn-for="HTMLButtonElement,HTMLInputElement" id="dom-fs-formenctype" data-dfn-type="attribute"><code>formEnctype</code></dfn> IDL attribute must <a href="#reflect" id="form-submission-attributes:reflect-3">reflect</a> the
  <code id="form-submission-attributes:attr-fs-formenctype-4"><a href="#attr-fs-formenctype">formenctype</a></code> content attribute, <a href="#limited-to-only-known-values" id="form-submission-attributes:limited-to-only-known-values-3">limited to only
  known values</a>. The <dfn data-dfn-for="HTMLButtonElement,HTMLInputElement" id="dom-fs-formmethod" data-dfn-type="attribute"><code>formMethod</code></dfn> IDL attribute must <a href="#reflect" id="form-submission-attributes:reflect-4">reflect</a> the
  <code id="form-submission-attributes:attr-fs-formmethod-4"><a href="#attr-fs-formmethod">formmethod</a></code> content attribute, <a href="#limited-to-only-known-values" id="form-submission-attributes:limited-to-only-known-values-4">limited to only known
  values</a>.
  </p></div>

  


  <h5 id="autofill"><span class="secno">4.10.19.7</span> Autofill<a href="#autofill" class="self-link"></a></h5>

  <h6 id="autofilling-form-controls:-the-autocomplete-attribute"><span class="secno">4.10.19.7.1</span> Autofilling form controls: the <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute<a href="#autofilling-form-controls:-the-autocomplete-attribute" class="self-link"></a></h6>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete" title="The HTML autocomplete attribute lets web developers specify what if any permission the user agent has to provide automated assistance in filling out form field values, as well as guidance to the browser as to the type of information expected in the field.">Attributes/autocomplete</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>14+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>User agents sometimes have features for helping users fill forms in, for example prefilling the
  user's address based on earlier user input. The <dfn data-dfn-for="button,fieldset,input,object,output,select,textarea" id="attr-fe-autocomplete" data-dfn-type="element-attr"><code>autocomplete</code></dfn> content attribute can be used to hint to
  the user agent how to, or indeed whether to, provide such a feature.</p>

  

  <p>There are two ways this attribute is used. When wearing the <dfn id="autofill-expectation-mantle">autofill expectation
  mantle</dfn>, the <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-2"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute describes what
  input is expected from users. When wearing the <dfn id="autofill-anchor-mantle">autofill anchor mantle</dfn>, the <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-3"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute describes the meaning of the given
  value.</p>

  <p>On an <code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is
  in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)">Hidden</a> state, the <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-4"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute wears the <a href="#autofill-anchor-mantle" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-anchor-mantle">autofill anchor
  mantle</a>. In all other cases, it wears the <a href="#autofill-expectation-mantle" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-expectation-mantle">autofill expectation mantle</a>.</p>

  <p>When wearing the <a href="#autofill-expectation-mantle" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-expectation-mantle-2">autofill expectation mantle</a>, the <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-5"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute, if specified, must have a value that
  is an ordered <a href="#set-of-space-separated-tokens" id="autofilling-form-controls:-the-autocomplete-attribute:set-of-space-separated-tokens">set of space-separated tokens</a> consisting of either a single token that
  is an <a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-off"><a href="#attr-fe-autocomplete-off">off</a></code>", or a single token that is an <a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for the string "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on"><a href="#attr-fe-autocomplete-on">on</a></code>",
  or <a href="#autofill-detail-tokens" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-detail-tokens">autofill detail tokens</a>.</p>

  <p>When wearing the <a href="#autofill-anchor-mantle" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-anchor-mantle-2">autofill anchor
  mantle</a>, the <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-6"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute, if specified, must have a value that is an ordered <a href="#set-of-space-separated-tokens" id="autofilling-form-controls:-the-autocomplete-attribute:set-of-space-separated-tokens-2">set of
  space-separated tokens</a> consisting of just <a href="#autofill-detail-tokens" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-detail-tokens-2">autofill detail tokens</a> (i.e. the
  "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2"><a href="#attr-fe-autocomplete-on">on</a></code>" and "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-off-2"><a href="#attr-fe-autocomplete-off">off</a></code>" keywords are not allowed).</p>

  <div data-algorithm="">
  <p><dfn id="autofill-detail-tokens">Autofill detail tokens</dfn> are the following, in the order given below:</p>

  <ol><li>

    <p>Optionally, a token whose first eight characters are an <a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>
    match for the string "<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-section" data-dfn-type="attr-value"><code>section-</code></dfn>", meaning that the field belongs to
    the named group.</p>

    <div class="example">

     <p>For example, if there are two shipping addresses in the form, then they could be marked up
     as:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Ship the blue gift to...<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> Address:     <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">ba</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"section-blue shipping street-address"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> City:        <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">bc</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"section-blue shipping address-level2"</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> Postal Code: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">bp</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"section-blue shipping postal-code"</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Ship the red gift to...<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> Address:     <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">ra</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"section-red shipping street-address"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> City:        <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">rc</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"section-red shipping address-level2"</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c-> Postal Code: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">rp</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"section-red shipping postal-code"</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></code></pre>

    </div>
   </li><li>
    <p>Optionally, a token that is an <a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the
    following strings:</p>

    <ul class="brief"><li>"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-shipping" data-dfn-type="attr-value"><code>shipping</code></dfn>", meaning the field is part of the
     shipping address or contact information

     </li><li>"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-billing" data-dfn-type="attr-value"><code>billing</code></dfn>", meaning the field is part of the
     billing address or contact information
    </li></ul>
   </li><li>
    <p>Either of the following two options:</p>

    <ul><li>
      <p>A token that is an <a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-case-insensitive-5" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the following
      <a href="#autofill-field" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-field">autofill field</a> names, excluding those that are <a href="#inappropriate-for-the-control" id="autofilling-form-controls:-the-autocomplete-attribute:inappropriate-for-the-control">inappropriate for the
      control</a>:</p>

      <ul class="brief"><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-name"><a href="#attr-fe-autocomplete-name">name</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-honorific-prefix"><a href="#attr-fe-autocomplete-honorific-prefix">honorific-prefix</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-given-name"><a href="#attr-fe-autocomplete-given-name">given-name</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-additional-name"><a href="#attr-fe-autocomplete-additional-name">additional-name</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-family-name"><a href="#attr-fe-autocomplete-family-name">family-name</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-honorific-suffix"><a href="#attr-fe-autocomplete-honorific-suffix">honorific-suffix</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-nickname"><a href="#attr-fe-autocomplete-nickname">nickname</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-username"><a href="#attr-fe-autocomplete-username">username</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-new-password"><a href="#attr-fe-autocomplete-new-password">new-password</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-current-password"><a href="#attr-fe-autocomplete-current-password">current-password</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-one-time-code"><a href="#attr-fe-autocomplete-one-time-code">one-time-code</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-organization-title"><a href="#attr-fe-autocomplete-organization-title">organization-title</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-organization"><a href="#attr-fe-autocomplete-organization">organization</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-street-address"><a href="#attr-fe-autocomplete-street-address">street-address</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-line1"><a href="#attr-fe-autocomplete-address-line1">address-line1</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-line2"><a href="#attr-fe-autocomplete-address-line2">address-line2</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-line3"><a href="#attr-fe-autocomplete-address-line3">address-line3</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-level4"><a href="#attr-fe-autocomplete-address-level4">address-level4</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-level3"><a href="#attr-fe-autocomplete-address-level3">address-level3</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-level2"><a href="#attr-fe-autocomplete-address-level2">address-level2</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-level1"><a href="#attr-fe-autocomplete-address-level1">address-level1</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-country"><a href="#attr-fe-autocomplete-country">country</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-country-name"><a href="#attr-fe-autocomplete-country-name">country-name</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-postal-code"><a href="#attr-fe-autocomplete-postal-code">postal-code</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-name"><a href="#attr-fe-autocomplete-cc-name">cc-name</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-given-name"><a href="#attr-fe-autocomplete-cc-given-name">cc-given-name</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-additional-name"><a href="#attr-fe-autocomplete-cc-additional-name">cc-additional-name</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-family-name"><a href="#attr-fe-autocomplete-cc-family-name">cc-family-name</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-number"><a href="#attr-fe-autocomplete-cc-number">cc-number</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-exp"><a href="#attr-fe-autocomplete-cc-exp">cc-exp</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-exp-month"><a href="#attr-fe-autocomplete-cc-exp-month">cc-exp-month</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-exp-year"><a href="#attr-fe-autocomplete-cc-exp-year">cc-exp-year</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-csc"><a href="#attr-fe-autocomplete-cc-csc">cc-csc</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-type"><a href="#attr-fe-autocomplete-cc-type">cc-type</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-transaction-currency"><a href="#attr-fe-autocomplete-transaction-currency">transaction-currency</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-transaction-amount"><a href="#attr-fe-autocomplete-transaction-amount">transaction-amount</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-language"><a href="#attr-fe-autocomplete-language">language</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-bday"><a href="#attr-fe-autocomplete-bday">bday</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-bday-day"><a href="#attr-fe-autocomplete-bday-day">bday-day</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-bday-month"><a href="#attr-fe-autocomplete-bday-month">bday-month</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-bday-year"><a href="#attr-fe-autocomplete-bday-year">bday-year</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-sex"><a href="#attr-fe-autocomplete-sex">sex</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-url"><a href="#attr-fe-autocomplete-url">url</a></code>"
       </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-photo"><a href="#attr-fe-autocomplete-photo">photo</a></code>"
      </li></ul>

      <p>(See the table below for descriptions of these values.)</p>
     </li><li>
      <p>The following, in the given order:</p>

      <ol><li>
        <p>Optionally, a token that is an <a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-case-insensitive-6" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the
        following strings:</p>

        <ul class="brief"><li>"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-home" data-dfn-type="attr-value"><code>home</code></dfn>", meaning the field is for contacting
         someone at their residence

         </li><li>"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-work" data-dfn-type="attr-value"><code>work</code></dfn>", meaning the field is for contacting
         someone at their workplace

         </li><li>"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-mobile" data-dfn-type="attr-value"><code>mobile</code></dfn>", meaning the
         field is for contacting someone regardless of location

         </li><li>"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-fax" data-dfn-type="attr-value"><code>fax</code></dfn>", meaning the field describes a fax
         machine's contact details

         </li><li>"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-pager" data-dfn-type="attr-value"><code>pager</code></dfn>", meaning the field describes a
         pager's or beeper's contact details
        </li></ul>
       </li><li>
        <p>A token that is an <a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-case-insensitive-7" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the following
        <a href="#autofill-field" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-field-2">autofill field</a> names, excluding those that are <a href="#inappropriate-for-the-control" id="autofilling-form-controls:-the-autocomplete-attribute:inappropriate-for-the-control-2">inappropriate for the
        control</a>:</p>

        <ul class="brief"><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel"><a href="#attr-fe-autocomplete-tel">tel</a></code>"
         </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel-country-code"><a href="#attr-fe-autocomplete-tel-country-code">tel-country-code</a></code>"
         </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel-national"><a href="#attr-fe-autocomplete-tel-national">tel-national</a></code>"
         </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel-area-code"><a href="#attr-fe-autocomplete-tel-area-code">tel-area-code</a></code>"
         </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel-local"><a href="#attr-fe-autocomplete-tel-local">tel-local</a></code>"
         </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel-local-prefix"><a href="#attr-fe-autocomplete-tel-local-prefix">tel-local-prefix</a></code>"
         </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel-local-suffix"><a href="#attr-fe-autocomplete-tel-local-suffix">tel-local-suffix</a></code>"
         </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel-extension"><a href="#attr-fe-autocomplete-tel-extension">tel-extension</a></code>"
         </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-email"><a href="#attr-fe-autocomplete-email">email</a></code>"
         </li><li>"<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-impp"><a href="#attr-fe-autocomplete-impp">impp</a></code>"
        </li></ul>

        <p>(See the table below for descriptions of these values.)</p>
       </li></ol>
     </li></ul>
   </li><li><p>Optionally, a token that is an <a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-case-insensitive-8" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string
   "<dfn id="attr-fe-autocomplete-webauthn"><code>webauthn</code></dfn>", meaning the user agent
   should show <a href="https://w3c.github.io/webauthn/#public-key-credential" id="autofilling-form-controls:-the-autocomplete-attribute:public-key-credential" data-x-internal="public-key-credential">public key credentials</a> available via
   <code id="autofilling-form-controls:-the-autocomplete-attribute:conditional-mediation"><a data-x-internal="conditional-mediation" href="https://w3c.github.io/webappsec-credential-management/#dom-credentialmediationrequirement-conditional">conditional</a></code> mediation when the user interacts with the
   form control. <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-webauthn"><a href="#attr-fe-autocomplete-webauthn">webauthn</a></code> is only valid for
   <code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-2"><a href="#the-input-element">input</a></code> and <code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements.</p></li></ol>
  </div>

  <p>As noted earlier, the meaning of the attribute and its keywords depends on the mantle that the
  attribute is wearing.</p>

  <dl class="switch"><dt>When wearing the <a href="#autofill-expectation-mantle" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-expectation-mantle-3">autofill expectation mantle</a>...

   </dt><dd>
    <p>The "<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-off" data-dfn-type="attr-value"><code>off</code></dfn>" keyword indicates either that the control's
    input data is particularly sensitive (for example the activation code for a nuclear weapon); or
    that it is a value that will never be reused (for example a one-time-key for a bank login) and
    the user will therefore have to explicitly enter the data each time, instead of being able to
    rely on the UA to prefill the value for them; or that the document provides its own autocomplete
    mechanism and does not want the user agent to provide autocompletion values.</p>

    <p>The "<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-on" data-dfn-type="attr-value"><code>on</code></dfn>" keyword indicates that the user agent is
    allowed to provide the user with autocompletion values, but does not provide any further
    information about what kind of data the user might be expected to enter. User agents would have
    to use heuristics to decide what autocompletion values to suggest.</p>

    <p>The <a href="#autofill-field" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-field-3">autofill field</a> listed above indicate that the user agent is allowed to
    provide the user with autocompletion values, and specifies what kind of value is expected. The
    meaning of each such keyword is described in the table below.</p>

    <p>If the <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-7"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute is omitted, the default
    value corresponding to the state of the element's <a href="#form-owner" id="autofilling-form-controls:-the-autocomplete-attribute:form-owner">form owner</a>'s <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-form-autocomplete"><a href="#attr-form-autocomplete">autocomplete</a></code> attribute is used instead (either "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-3"><a href="#attr-fe-autocomplete-on">on</a></code>" or "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-off-3"><a href="#attr-fe-autocomplete-off">off</a></code>"). If there is no <a href="#form-owner" id="autofilling-form-controls:-the-autocomplete-attribute:form-owner-2">form owner</a>, then the
    value "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-4"><a href="#attr-fe-autocomplete-on">on</a></code>" is used.</p>
   </dd><dt>When wearing the <a href="#autofill-anchor-mantle" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-anchor-mantle-3">autofill anchor mantle</a>...

   </dt><dd>
    <p>The <a href="#autofill-field" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-field-4">autofill field</a> listed above indicate that the value of the particular kind
    of value specified is that value provided for this element. The meaning of each such keyword is
    described in the table below.</p>

    <div class="example">

     <p>In this example the page has explicitly specified the currency and amount of the
     transaction. The form requests a credit card and other billing details. The user agent could
     use this information to suggest a credit card that it knows has sufficient balance and that
     supports the relevant currency.</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">post</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"step2.cgi"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">hidden</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">transaction-currency</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"CHF"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">hidden</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">transaction-amount</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"15.00"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Credit card number: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">inputmode</c-><c- o="">=</c-><c- s="">numeric</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">cc-number</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Expiry Date: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">month</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">cc-exp</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Continue..."</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

    </div>
   </dd></dl>

  <p>The <dfn id="autofill-field">autofill field</dfn> keywords relate to each other as described in the table below. Each field name
  listed on a row of this table corresponds to the meaning given in the cell for that row in the
  column labeled "Meaning". Some fields correspond to subparts of other fields; for example, a
  credit card expiry date can be expressed as one field giving both the month and year of expiry
  ("<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-exp-2"><a href="#attr-fe-autocomplete-cc-exp">cc-exp</a></code>"), or as two fields, one giving the
  month ("<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-exp-month-2"><a href="#attr-fe-autocomplete-cc-exp-month">cc-exp-month</a></code>") and one the year
  ("<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-cc-exp-year-2"><a href="#attr-fe-autocomplete-cc-exp-year">cc-exp-year</a></code>"). In such cases, the names of
  the broader fields cover multiple rows, in which the narrower fields are defined.</p>

  <p class="note">Generally, authors are encouraged to use the broader fields rather than the
  narrower fields, as the narrower fields tend to expose Western biases. For example, while it is
  common in some Western cultures to have a given name and a family name, in that order (and thus
  often referred to as a <i>first name</i> and a <i>surname</i>), many cultures put the family name
  first and the given name second, and many others simply have one name (a <i>mononym</i>). Having a
  single field is therefore more flexible.</p>

  <div data-algorithm="">
  <p>Some fields are only appropriate for certain form controls. An <a href="#autofill-field" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-field-5">autofill field</a> name
  is <dfn id="inappropriate-for-the-control">inappropriate for a control</dfn> if the control
  does not belong to the group listed for that <a href="#autofill-field" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-field-6">autofill field</a> in the fifth column of
  the first row describing that <a href="#autofill-field" id="autofilling-form-controls:-the-autocomplete-attribute:autofill-field-7">autofill field</a> in the table below. What controls fall
  into each group is described below the table.</p>
  </div>

  <table><thead><tr><th colspan="4"> Field name
     </th><th> Meaning
     </th><th> Canonical Format
     </th><th> Canonical Format Example
     </th><th> Control group
   </th></tr></thead><tbody><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-name" data-dfn-type="attr-value"><code>name</code></dfn>"
     </td><td>Full name
     </td><td>Free-form text, no newlines
     </td><td>Sir Timothy John Berners-Lee, OM, KBE, FRS, FREng, FRSA
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text">Text</a>
    </td></tr><tr><td class="non-rectangular-cell-indentation" rowspan="5">
      </td><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-honorific-prefix" data-dfn-type="attr-value"><code>honorific-prefix</code></dfn>"
      </td><td>Prefix or title (e.g. "Mr.", "Ms.", "Dr.", "<span lang="fr">M<sup>lle</sup></span>")
      </td><td>Free-form text, no newlines
      </td><td>Sir
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-2">Text</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-given-name" data-dfn-type="attr-value"><code>given-name</code></dfn>"
      </td><td>Given name (in some Western cultures, also known as the <i>first name</i>)
      </td><td>Free-form text, no newlines
      </td><td>Timothy
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-3">Text</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-additional-name" data-dfn-type="attr-value"><code>additional-name</code></dfn>"
      </td><td>Additional names (in some Western cultures, also known as <i>middle names</i>, forenames other than the first name)
      </td><td>Free-form text, no newlines
      </td><td>John
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-4">Text</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-family-name" data-dfn-type="attr-value"><code>family-name</code></dfn>"
      </td><td>Family name (in some Western cultures, also known as the <i>last name</i> or <i>surname</i>)
      </td><td>Free-form text, no newlines
      </td><td>Berners-Lee
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-5">Text</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-honorific-suffix" data-dfn-type="attr-value"><code>honorific-suffix</code></dfn>"
      </td><td>Suffix (e.g. "Jr.", "B.Sc.", "MBASW", "II")
      </td><td>Free-form text, no newlines
      </td><td>OM, KBE, FRS, FREng, FRSA
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-6">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-nickname" data-dfn-type="attr-value"><code>nickname</code></dfn>"
     </td><td>Nickname, screen name, handle: a typically short name used instead of the full name
     </td><td>Free-form text, no newlines
     </td><td>Tim
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-7">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-organization-title" data-dfn-type="attr-value"><code>organization-title</code></dfn>"
     </td><td>Job title (e.g. "Software Engineer", "Senior Vice President", "Deputy Managing Director")
     </td><td>Free-form text, no newlines
     </td><td>Professor
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-8">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-username" data-dfn-type="attr-value"><code>username</code></dfn>"
     </td><td>A username
     </td><td>Free-form text, no newlines
     </td><td>timbl
     </td><td><a href="#control-group-username" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-username">Username</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-new-password" data-dfn-type="attr-value"><code>new-password</code></dfn>"
     </td><td>A new password (e.g. when creating an account or changing a password)
     </td><td>Free-form text, no newlines
     </td><td>GUMFXbadyrS3
     </td><td><a href="#control-group-password" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-password">Password</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-current-password" data-dfn-type="attr-value"><code>current-password</code></dfn>"
     </td><td>The current password for the account identified by the <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-username-2"><a href="#attr-fe-autocomplete-username">username</a></code> field (e.g. when logging in)
     </td><td>Free-form text, no newlines
     </td><td>qwerty 
     </td><td><a href="#control-group-password" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-password-2">Password</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-one-time-code" data-dfn-type="attr-value"><code>one-time-code</code></dfn>"
     </td><td>One-time code used for verifying user identity
     </td><td>Free-form text, no newlines
     </td><td>123456
     </td><td><a href="#control-group-password" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-password-3">Password</a>
   </td></tr></tbody><tbody><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-organization" data-dfn-type="attr-value"><code>organization</code></dfn>"
     </td><td>Company name corresponding to the person, address, or contact information in the other fields associated with this field
     </td><td>Free-form text, no newlines
     </td><td>World Wide Web Consortium
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-9">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-street-address" data-dfn-type="attr-value"><code>street-address</code></dfn>"
     </td><td>Street address (multiple lines, newlines preserved)
     </td><td>Free-form text
     </td><td>32 Vassar Street<br>
MIT Room 32-G524
     </td><td><a href="#control-group-multiline" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-multiline">Multiline</a>
    </td></tr><tr><td class="non-rectangular-cell-indentation" rowspan="3">
      </td><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-address-line1" data-dfn-type="attr-value"><code>address-line1</code></dfn>"
      </td><td rowspan="3">Street address (one line per field)
      </td><td>Free-form text, no newlines
      </td><td>32 Vassar Street
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-10">Text</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-address-line2" data-dfn-type="attr-value"><code>address-line2</code></dfn>"
      </td><td>Free-form text, no newlines
      </td><td>MIT Room 32-G524
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-11">Text</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-address-line3" data-dfn-type="attr-value"><code>address-line3</code></dfn>"
      </td><td>Free-form text, no newlines
      </td><td>
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-12">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-address-level4" data-dfn-type="attr-value"><code>address-level4</code></dfn>"
     </td><td>The most fine-grained <a href="#more-on-address-levels">administrative level</a>, in
     addresses with four administrative levels
     </td><td>Free-form text, no newlines
     </td><td>
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-13">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-address-level3" data-dfn-type="attr-value"><code>address-level3</code></dfn>"
     </td><td>The <a href="#more-on-address-levels">third administrative level</a>, in addresses with
     three or more administrative levels
     </td><td>Free-form text, no newlines
     </td><td>
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-14">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-address-level2" data-dfn-type="attr-value"><code>address-level2</code></dfn>"
     </td><td>The <a href="#more-on-address-levels">second administrative level</a>, in addresses with
     two or more administrative levels; in the countries with two administrative levels, this would
     typically be the city, town, village, or other locality within which the relevant street
     address is found
     </td><td>Free-form text, no newlines
     </td><td>Cambridge
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-15">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-address-level1" data-dfn-type="attr-value"><code>address-level1</code></dfn>"
     </td><td>The broadest <a href="#more-on-address-levels">administrative level</a> in the address,
     i.e. the province within which the locality is found; for example, in the US, this would be the
     state; in Switzerland it would be the canton; in the UK, the post town
     </td><td>Free-form text, no newlines
     </td><td>MA
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-16">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-country" data-dfn-type="attr-value"><code>country</code></dfn>"
     </td><td>Country code
     </td><td>Valid <a href="https://www.iso.org/iso-3166-country-codes.html">ISO 3166-1-alpha-2 country code</a> <a href="#refsISO3166">[ISO3166]</a>
     </td><td>US
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-17">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-country-name" data-dfn-type="attr-value"><code>country-name</code></dfn>"
     </td><td>Country name
     </td><td>Free-form text, no newlines; <a href="#autofill-country">derived from <code>country</code> in some cases</a>
     </td><td>US
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-18">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-postal-code" data-dfn-type="attr-value"><code>postal-code</code></dfn>"
     </td><td>Postal code, post code, ZIP code, CEDEX code (if CEDEX, append "CEDEX", and the <i lang="fr">arrondissement</i>, if relevant, to the <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-level2-2"><a href="#attr-fe-autocomplete-address-level2">address-level2</a></code> field)
     </td><td>Free-form text, no newlines
     </td><td>02139
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-19">Text</a>
   </td></tr></tbody><tbody><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-name" data-dfn-type="attr-value"><code>cc-name</code></dfn>"
     </td><td>Full name as given on the payment instrument
     </td><td>Free-form text, no newlines
     </td><td>Tim Berners-Lee
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-20">Text</a>
    </td></tr><tr><td class="non-rectangular-cell-indentation" rowspan="3">
      </td><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-given-name" data-dfn-type="attr-value"><code>cc-given-name</code></dfn>"
      </td><td>Given name as given on the payment instrument (in some Western cultures, also known as the <i>first name</i>)
      </td><td>Free-form text, no newlines
      </td><td>Tim
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-21">Text</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-additional-name" data-dfn-type="attr-value"><code>cc-additional-name</code></dfn>"
      </td><td>Additional names given on the payment instrument (in some Western cultures, also known as <i>middle names</i>, forenames other than the first name)
      </td><td>Free-form text, no newlines
      </td><td>
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-22">Text</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-family-name" data-dfn-type="attr-value"><code>cc-family-name</code></dfn>"
      </td><td>Family name given on the payment instrument (in some Western cultures, also known as the <i>last name</i> or <i>surname</i>)
      </td><td>Free-form text, no newlines
      </td><td>Berners-Lee
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-23">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-number" data-dfn-type="attr-value"><code>cc-number</code></dfn>"
     </td><td>Code identifying the payment instrument (e.g. the credit card number)
     </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>
     </td><td>4114360123456785 
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-24">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-exp" data-dfn-type="attr-value"><code>cc-exp</code></dfn>"
     </td><td>Expiration date of the payment instrument
     </td><td><a href="#valid-month-string" id="autofilling-form-controls:-the-autocomplete-attribute:valid-month-string">Valid month string</a>
     </td><td>2014-12
     </td><td><a href="#control-group-month" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-month">Month</a>
    </td></tr><tr><td class="non-rectangular-cell-indentation" rowspan="2">
      </td><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-exp-month" data-dfn-type="attr-value"><code>cc-exp-month</code></dfn>"
      </td><td>Month component of the expiration date of the payment instrument
      </td><td><a href="#valid-integer" id="autofilling-form-controls:-the-autocomplete-attribute:valid-integer">Valid integer</a> in the range 1..12
      </td><td>12
      </td><td><a href="#control-group-numeric" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric">Numeric</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-exp-year" data-dfn-type="attr-value"><code>cc-exp-year</code></dfn>"
      </td><td>Year component of the expiration date of the payment instrument
      </td><td><a href="#valid-integer" id="autofilling-form-controls:-the-autocomplete-attribute:valid-integer-2">Valid integer</a> greater than zero
      </td><td>2014
      </td><td><a href="#control-group-numeric" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-2">Numeric</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-csc" data-dfn-type="attr-value"><code>cc-csc</code></dfn>"
     </td><td>Security code for the payment instrument (also known as the card security code (CSC), card validation code (CVC), card verification value (CVV), signature panel code (SPC), credit card ID (CCID), etc.)
     </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>
     </td><td>419
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-25">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-cc-type" data-dfn-type="attr-value"><code>cc-type</code></dfn>"
     </td><td>Type of payment instrument
     </td><td>Free-form text, no newlines
     </td><td>Visa
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-26">Text</a>
   </td></tr></tbody><tbody><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-transaction-currency" data-dfn-type="attr-value"><code>transaction-currency</code></dfn>"
     </td><td>The currency that the user would prefer the transaction to use
     </td><td>ISO 4217 currency code <a href="#refsISO4217">[ISO4217]</a>
     </td><td>GBP
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-27">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-transaction-amount" data-dfn-type="attr-value"><code>transaction-amount</code></dfn>"
     </td><td>The amount that the user would like for the transaction (e.g. when entering a bid or sale price)
     </td><td><a href="#valid-floating-point-number" id="autofilling-form-controls:-the-autocomplete-attribute:valid-floating-point-number">Valid floating-point number</a>
     </td><td>401.00
     </td><td><a href="#control-group-numeric" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-3">Numeric</a>
   </td></tr></tbody><tbody><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-language" data-dfn-type="attr-value"><code>language</code></dfn>"
     </td><td>Preferred language
     </td><td>Valid BCP 47 language tag <a href="#refsBCP47">[BCP47]</a>
     </td><td>en
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-28">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-bday" data-dfn-type="attr-value"><code>bday</code></dfn>"
     </td><td>Birthday
     </td><td><a href="#valid-date-string" id="autofilling-form-controls:-the-autocomplete-attribute:valid-date-string">Valid date string</a>
     </td><td>1955-06-08
     </td><td><a href="#control-group-date" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-date">Date</a>
    </td></tr><tr><td class="non-rectangular-cell-indentation" rowspan="3">
      </td><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-bday-day" data-dfn-type="attr-value"><code>bday-day</code></dfn>"
      </td><td>Day component of birthday
      </td><td><a href="#valid-integer" id="autofilling-form-controls:-the-autocomplete-attribute:valid-integer-3">Valid integer</a> in the range 1..31
      </td><td>8
      </td><td><a href="#control-group-numeric" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-4">Numeric</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-bday-month" data-dfn-type="attr-value"><code>bday-month</code></dfn>"
      </td><td>Month component of birthday
      </td><td><a href="#valid-integer" id="autofilling-form-controls:-the-autocomplete-attribute:valid-integer-4">Valid integer</a> in the range 1..12
      </td><td>6
      </td><td><a href="#control-group-numeric" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-5">Numeric</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-bday-year" data-dfn-type="attr-value"><code>bday-year</code></dfn>"
      </td><td>Year component of birthday
      </td><td><a href="#valid-integer" id="autofilling-form-controls:-the-autocomplete-attribute:valid-integer-5">Valid integer</a> greater than zero
      </td><td>1955
      </td><td><a href="#control-group-numeric" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-6">Numeric</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-sex" data-dfn-type="attr-value"><code>sex</code></dfn>"
     </td><td>Gender identity (e.g. Female, Fa'afafine)
     </td><td>Free-form text, no newlines
     </td><td>Male
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-29">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-url" data-dfn-type="attr-value"><code>url</code></dfn>"
     </td><td>Home page or other web page corresponding to the company, person, address, or contact information in the other fields associated with this field
     </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:valid-url-string" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">Valid URL string</a>
     </td><td>https://www.w3.org/People/Berners-Lee/
     </td><td><a href="#control-group-url" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-url">URL</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-photo" data-dfn-type="attr-value"><code>photo</code></dfn>"
     </td><td>Photograph, icon, or other image corresponding to the company, person, address, or contact information in the other fields associated with this field
     </td><td> <a id="autofilling-form-controls:-the-autocomplete-attribute:valid-url-string-2" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">Valid URL string</a>
     </td><td>https://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg
     </td><td> <a href="#control-group-url" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-url-2">URL</a>
   </td></tr></tbody><tbody><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-tel" data-dfn-type="attr-value"><code>tel</code></dfn>"
     </td><td>Full telephone number, including country code
     </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> and U+0020 SPACE characters, prefixed by a U+002B PLUS SIGN character (+)
     </td><td>+1 617 253 5702
     </td><td><a href="#control-group-tel" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-tel">Tel</a>
    </td></tr><tr><td class="non-rectangular-cell-indentation" rowspan="6">
      </td><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-tel-country-code" data-dfn-type="attr-value"><code>tel-country-code</code></dfn>"
      </td><td>Country code component of the telephone number
      </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits-4" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> prefixed by a U+002B PLUS SIGN character (+)
      </td><td>+1
      </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-30">Text</a>
    </td></tr><tr><td colspan="3">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-tel-national" data-dfn-type="attr-value"><code>tel-national</code></dfn>"
      </td><td>Telephone number without the county code component, with a country-internal prefix applied if applicable
      </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits-5" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> and U+0020 SPACE characters
      </td><td>617 253 5702
      </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-31">Text</a>
    </td></tr><tr><td class="non-rectangular-cell-indentation" rowspan="4">
       </td><td colspan="2">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-tel-area-code" data-dfn-type="attr-value"><code>tel-area-code</code></dfn>"
       </td><td>Area code component of the telephone number, with a country-internal prefix applied if applicable
       </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits-6" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>
       </td><td>617
       </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-32">Text</a>
    </td></tr><tr><td colspan="2">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-tel-local" data-dfn-type="attr-value"><code>tel-local</code></dfn>"
       </td><td>Telephone number without the country code and area code components
       </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits-7" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>
       </td><td>2535702
       </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-33">Text</a>
    </td></tr><tr><td class="non-rectangular-cell-indentation" rowspan="2">
        </td><td>"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-tel-local-prefix" data-dfn-type="attr-value"><code>tel-local-prefix</code></dfn>"
        </td><td>First part of the component of the telephone number that follows the area code, when that component is split into two components
        </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits-8" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>
        </td><td>253
        </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-34">Text</a>
    </td></tr><tr><td>"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-tel-local-suffix" data-dfn-type="attr-value"><code>tel-local-suffix</code></dfn>"
        </td><td>Second part of the component of the telephone number that follows the area code, when that component is split into two components
        </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits-9" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>
        </td><td>5702
        </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-35">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-tel-extension" data-dfn-type="attr-value"><code>tel-extension</code></dfn>"
     </td><td>Telephone number internal extension code
     </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:ascii-digits-10" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>
     </td><td>1000
     </td><td><a href="#control-group-text" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-text-36">Text</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-email" data-dfn-type="attr-value"><code>email</code></dfn>"
     </td><td>Email address
     </td><td><a href="#valid-e-mail-address" id="autofilling-form-controls:-the-autocomplete-attribute:valid-e-mail-address">Valid email address</a>
     </td><td>timbl@w3.org
     </td><td><a href="#control-group-username" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-username-2">Username</a>
    </td></tr><tr><td colspan="4">"<dfn data-dfn-for="button/autocomplete,fieldset/autocomplete,input/autocomplete,object/autocomplete,output/autocomplete,select/autocomplete,textarea/autocomplete" id="attr-fe-autocomplete-impp" data-dfn-type="attr-value"><code>impp</code></dfn>"
     </td><td>URL representing an instant messaging protocol endpoint (for example, "<code>aim:goim?screenname=example</code>" or "<code>xmpp:fred@example.net</code>")
     </td><td><a id="autofilling-form-controls:-the-autocomplete-attribute:valid-url-string-3" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">Valid URL string</a>
     </td><td>irc://example.org/timbl,isuser
     </td><td><a href="#control-group-url" id="autofilling-form-controls:-the-autocomplete-attribute:control-group-url-3">URL</a>
  </td></tr></tbody></table>

  <p>The groups correspond to controls as follows:</p>

  <dl><dt><dfn id="control-group-text">Text</dfn>

   </dt><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-3"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)-2">Hidden</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-4"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)">Text</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-5"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-2">Search</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> elements
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-select-element"><a href="#the-select-element">select</a></code> elements

   </dd><dt><dfn id="control-group-multiline">Multiline</dfn>

   </dt><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-6"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-5"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)-3">Hidden</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code> elements
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-select-element-2"><a href="#the-select-element">select</a></code> elements

   </dd><dt><dfn id="control-group-password">Password</dfn>

   </dt><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-7"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-6"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)-4">Hidden</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-8"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-7"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-3">Text</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-9"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-8"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-4">Search</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-10"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-9"><a href="#attr-input-type">type</a></code> attribute in the <a href="#password-state-(type=password)" id="autofilling-form-controls:-the-autocomplete-attribute:password-state-(type=password)">Password</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-4"><a href="#the-textarea-element">textarea</a></code> elements
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-select-element-3"><a href="#the-select-element">select</a></code> elements

   </dd><dt><dfn id="control-group-url">URL</dfn>

   </dt><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-11"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-10"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)-5">Hidden</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-12"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-11"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-5">Text</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-13"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-12"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-6">Search</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-14"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-13"><a href="#attr-input-type">type</a></code> attribute in the <a href="#url-state-(type=url)" id="autofilling-form-controls:-the-autocomplete-attribute:url-state-(type=url)">URL</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-5"><a href="#the-textarea-element">textarea</a></code> elements
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-select-element-4"><a href="#the-select-element">select</a></code> elements

   </dd><dt><dfn id="control-group-username">Username</dfn><span id="control-group-e-mail"></span>

   </dt><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-15"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-14"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)-6">Hidden</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-16"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-15"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-7">Text</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-17"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-16"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-8">Search</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-18"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-17"><a href="#attr-input-type">type</a></code> attribute in the <a href="#email-state-(type=email)" id="autofilling-form-controls:-the-autocomplete-attribute:email-state-(type=email)">Email</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-6"><a href="#the-textarea-element">textarea</a></code> elements
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-select-element-5"><a href="#the-select-element">select</a></code> elements

   </dd><dt><dfn id="control-group-tel">Tel</dfn>

   </dt><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-19"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-18"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)-7">Hidden</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-20"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-19"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-9">Text</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-21"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-20"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-10">Search</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-22"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-21"><a href="#attr-input-type">type</a></code> attribute in the <a href="#telephone-state-(type=tel)" id="autofilling-form-controls:-the-autocomplete-attribute:telephone-state-(type=tel)">Telephone</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-7"><a href="#the-textarea-element">textarea</a></code> elements
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-select-element-6"><a href="#the-select-element">select</a></code> elements

   </dd><dt><dfn id="control-group-numeric">Numeric</dfn>

   </dt><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-23"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-22"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)-8">Hidden</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-24"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-23"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-11">Text</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-25"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-24"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-12">Search</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-26"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-25"><a href="#attr-input-type">type</a></code> attribute in the <a href="#number-state-(type=number)" id="autofilling-form-controls:-the-autocomplete-attribute:number-state-(type=number)">Number</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-8"><a href="#the-textarea-element">textarea</a></code> elements
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-select-element-7"><a href="#the-select-element">select</a></code> elements

   </dd><dt><dfn id="control-group-month">Month</dfn>

   </dt><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-27"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-26"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)-9">Hidden</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-28"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-27"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-13">Text</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-29"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-28"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-14">Search</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-30"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-29"><a href="#attr-input-type">type</a></code> attribute in the <a href="#month-state-(type=month)" id="autofilling-form-controls:-the-autocomplete-attribute:month-state-(type=month)">Month</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-9"><a href="#the-textarea-element">textarea</a></code> elements
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-select-element-8"><a href="#the-select-element">select</a></code> elements

   </dd><dt><dfn id="control-group-date">Date</dfn>

   </dt><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-31"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-30"><a href="#attr-input-type">type</a></code> attribute in the <a href="#hidden-state-(type=hidden)" id="autofilling-form-controls:-the-autocomplete-attribute:hidden-state-(type=hidden)-10">Hidden</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-32"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-31"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-15">Text</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-33"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-32"><a href="#attr-input-type">type</a></code> attribute in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofilling-form-controls:-the-autocomplete-attribute:text-(type=text)-state-and-search-state-(type=search)-16">Search</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-input-element-34"><a href="#the-input-element">input</a></code> elements with a <code id="autofilling-form-controls:-the-autocomplete-attribute:attr-input-type-33"><a href="#attr-input-type">type</a></code> attribute in the <a href="#date-state-(type=date)" id="autofilling-form-controls:-the-autocomplete-attribute:date-state-(type=date)">Date</a> state
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-10"><a href="#the-textarea-element">textarea</a></code> elements
   </dd><dd><code id="autofilling-form-controls:-the-autocomplete-attribute:the-select-element-9"><a href="#the-select-element">select</a></code> elements


  </dd></dl>

  <p id="more-on-address-levels"><strong>Address levels</strong>: The "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-level1-2"><a href="#attr-fe-autocomplete-address-level1">address-level1</a></code>" – "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-level4-2"><a href="#attr-fe-autocomplete-address-level4">address-level4</a></code>" fields are used to describe
  the locality of the street address. Different locales have different numbers of levels. For
  example, the US uses two levels (state and town), the UK uses one or two depending on the address
  (the post town, and in some cases the locality), and China can use three (province, city,
  district). The "<code id="autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-address-level1-3"><a href="#attr-fe-autocomplete-address-level1">address-level1</a></code>" field
  represents the widest administrative division. Different locales order the fields in different
  ways; for example, in the US the town (level 2) precedes the state (level 1); while in Japan the
  prefecture (level 1) precedes the city (level 2) which precedes the district (level 3). Authors
  are encouraged to provide forms that are presented in a way that matches the country's conventions
  (hiding, showing, and rearranging fields accordingly as the user changes the country).</p>


  

  <h6 id="autofill-processing-model"><span class="secno">4.10.19.7.2</span> <span id="processing-model-3"></span>Processing model<a href="#autofill-processing-model" class="self-link"></a></h6>

  <p>Each <code id="autofill-processing-model:the-input-element"><a href="#the-input-element">input</a></code> element to which the <code id="autofill-processing-model:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute <a href="#concept-input-apply" id="autofill-processing-model:concept-input-apply">applies</a>, each <code id="autofill-processing-model:the-select-element"><a href="#the-select-element">select</a></code> element, and each <code id="autofill-processing-model:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element, has an
  <dfn id="autofill-hint-set">autofill hint set</dfn>, an <dfn id="autofill-scope">autofill scope</dfn>, an <dfn id="autofill-field-name">autofill field name</dfn>, a
  <dfn id="non-autofill-credential-type">non-autofill credential type</dfn>, and an <dfn id="idl-exposed-autofill-value">IDL-exposed autofill value</dfn>.</p>

  <p>The <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name">autofill field name</a> specifies the specific kind of data expected in the field,
  e.g. "<code id="autofill-processing-model:attr-fe-autocomplete-street-address"><a href="#attr-fe-autocomplete-street-address">street-address</a></code>" or "<code id="autofill-processing-model:attr-fe-autocomplete-cc-exp"><a href="#attr-fe-autocomplete-cc-exp">cc-exp</a></code>".</p>

  <p>The <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set">autofill hint set</a> identifies what address or contact information type the user
  agent is to look at, e.g. "<code id="autofill-processing-model:attr-fe-autocomplete-shipping"><a href="#attr-fe-autocomplete-shipping">shipping</a></code> <code id="autofill-processing-model:attr-fe-autocomplete-fax"><a href="#attr-fe-autocomplete-fax">fax</a></code>" or "<code id="autofill-processing-model:attr-fe-autocomplete-billing"><a href="#attr-fe-autocomplete-billing">billing</a></code>".</p>

  <p>The <a href="#non-autofill-credential-type" id="autofill-processing-model:non-autofill-credential-type">non-autofill credential type</a> identifies a type of
  <a href="https://w3c.github.io/webappsec-credential-management/#credential" id="autofill-processing-model:credman-credential" data-x-internal="credman-credential">credential</a> that may be offered by the user agent when the
  user interacts with the field alongside other <a href="#autofill-field" id="autofill-processing-model:autofill-field">autofill field</a> values. If this value is
  "<code>webauthn</code>" instead of null, selecting a credential of that type will resolve
  a pending <code id="autofill-processing-model:conditional-mediation"><a data-x-internal="conditional-mediation" href="https://w3c.github.io/webappsec-credential-management/#dom-credentialmediationrequirement-conditional">conditional</a></code> mediation
  <code id="autofill-processing-model:navigator.credentials.get()"><a data-x-internal="navigator.credentials.get()" href="https://w3c.github.io/webappsec-credential-management/#dom-credentialscontainer-get">navigator.credentials.get()</a></code> request, instead of autofilling the field.</p>

  <div class="example">
   <p>For example, a sign-in page could instruct the user agent to either autofill a saved password,
   or show a <a id="autofill-processing-model:public-key-credential" href="https://w3c.github.io/webauthn/#public-key-credential" data-x-internal="public-key-credential">public key credential</a> that will resolve a pending
   <code id="autofill-processing-model:navigator.credentials.get()-2"><a data-x-internal="navigator.credentials.get()" href="https://w3c.github.io/webappsec-credential-management/#dom-credentialscontainer-get">navigator.credentials.get()</a></code> request. A user can select either to sign-in.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">password</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">password</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"current-password webauthn"</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>The <a href="#autofill-scope" id="autofill-processing-model:autofill-scope">autofill scope</a> identifies the group of fields whose information concerns the
  same subject, and consists of the <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-2">autofill hint set</a> with, if
  applicable, the "<code>section-*</code>" prefix, e.g. "<code>billing</code>",
  "<code>section-parent shipping</code>", or "<code>section-child shipping
  home</code>".</p>

  <div data-algorithm="">
  <p>These values are defined as the result of running the following algorithm:</p>

  <ol><li><p>If the element has no <code id="autofill-processing-model:attr-fe-autocomplete-2"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute,
   then jump to the step labeled <i>default</i>.</p></li><li><p>Let <var>tokens</var> be the result of <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="autofill-processing-model:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">splitting the attribute's value on ASCII whitespace</a>.</p></li><li><p>If <var>tokens</var> is empty, then jump to the step labeled <i>default</i>.</p></li><li><p>Let <var>index</var> be the index of the last token in <var>tokens</var>.</p></li><li><p>Let <var>field</var> be the <var>index</var>th token in <var>tokens</var>.</p></li><li><p>Set the <var>category</var>, <var>maximum tokens</var> pair to the result of <a href="#determine-a-field's-category" id="autofill-processing-model:determine-a-field's-category">determining a field's category</a> given
   <var>field</var>.</p></li><li><p>If <var>category</var> is null, then jump to the step labeled <i>default</i>.</p></li><li><p>If the number of tokens in <var>tokens</var> is greater than <var>maximum tokens</var>,
   then jump to the step labeled <i>default</i>.</p></li><li><p>If <var>category</var> is Off or Automatic but the element's <code id="autofill-processing-model:attr-fe-autocomplete-3"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute is wearing the <a href="#autofill-anchor-mantle" id="autofill-processing-model:autofill-anchor-mantle">autofill anchor
   mantle</a>, then jump to the step labeled <i>default</i>.</p></li><li><p>If <var>category</var> is Off, set the element's <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-2">autofill field name</a>
   to the string "<code>off</code>", set its <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-3">autofill hint set</a> to empty, and
   set its <a href="#idl-exposed-autofill-value" id="autofill-processing-model:idl-exposed-autofill-value">IDL-exposed autofill value</a> to the string "<code>off</code>". Then,
   return.</p>

   </li><li><p>If <var>category</var> is Automatic, set the element's <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-3">autofill field
   name</a> to the string "<code>on</code>", set its <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-4">autofill hint set</a> to
   empty, and set its <a href="#idl-exposed-autofill-value" id="autofill-processing-model:idl-exposed-autofill-value-2">IDL-exposed autofill value</a> to the string "<code>on</code>". Then, return.</p>

   </li><li><p>Let <var>scope tokens</var> be an empty list.</p></li><li><p>Let <var>hint tokens</var> be an empty set.</p></li><li><p>Let <var>credential type</var> be null.</p></li><li><p>Let <var>IDL value</var> have the same value as <var>field</var>.</p></li><li>
    <p>If <var>category</var> is Credential and the <var>index</var>th token in <var>tokens</var> is
    an <a id="autofill-processing-model:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code id="autofill-processing-model:attr-fe-autocomplete-webauthn"><a href="#attr-fe-autocomplete-webauthn">webauthn</a></code>", then run the substeps that follow:</p>
    <ol><li><p>Set <var>credential type</var> to "<code>webauthn</code>".</p></li><li><p>If the <var>index</var>th token in <var>tokens</var> is the first entry,
     then skip to the step labeled <i>done</i>.</p></li><li><p>Decrement <var>index</var> by one.</p></li><li><p>Set the <var>category</var>, <var>maximum tokens</var> pair to the result of <a href="#determine-a-field's-category" id="autofill-processing-model:determine-a-field's-category-2">determining a field's category</a> given
     the <var>index</var>th token in <var>tokens</var>.</p></li><li><p>If <var>category</var> is not Normal and <var>category</var> is not Contact, then jump to
     the step labeled <i>default</i>.</p></li><li><p>If <var>index</var> is greater than <var>maximum tokens</var> minus one (i.e. if the
     number of remaining tokens is greater than <var>maximum tokens</var>), then jump to the step
     labeled <i>default</i>.</p></li><li><p>Set <var>IDL value</var> to the concatenation of the <var>index</var>th token in
     <var>tokens</var>, a U+0020 SPACE character, and the previous value of <var>IDL
     value</var>.</p></li></ol>
   </li><li><p>If the <var>index</var>th token in <var>tokens</var> is the first entry,
   then skip to the step labeled <i>done</i>.</p></li><li><p>Decrement <var>index</var> by one.</p></li><li>
    <p>If <var>category</var> is Contact and the <var>index</var>th token in <var>tokens</var> is an <a id="autofill-processing-model:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the strings in
    the following list, then run the substeps that follow:</p>

    <ul class="brief"><li>"<code id="autofill-processing-model:attr-fe-autocomplete-home"><a href="#attr-fe-autocomplete-home">home</a></code>"
     </li><li>"<code id="autofill-processing-model:attr-fe-autocomplete-work"><a href="#attr-fe-autocomplete-work">work</a></code>"
     </li><li>"<code id="autofill-processing-model:attr-fe-autocomplete-mobile"><a href="#attr-fe-autocomplete-mobile">mobile</a></code>"
     </li><li>"<code id="autofill-processing-model:attr-fe-autocomplete-fax-2"><a href="#attr-fe-autocomplete-fax">fax</a></code>"
     </li><li>"<code id="autofill-processing-model:attr-fe-autocomplete-pager"><a href="#attr-fe-autocomplete-pager">pager</a></code>"
    </li></ul>

    <p>The substeps are:</p>

    <ol><li><p>Let <var>contact</var> be the matching string from the list above.</p></li><li><p>Insert <var>contact</var> at the start of <var>scope
     tokens</var>.</p></li><li><p>Add <var>contact</var> to <var>hint tokens</var>.</p></li><li><p>Let <var>IDL value</var> be the concatenation of <var>contact</var>, a
     U+0020 SPACE character, and the previous value of <var>IDL value</var>.</p></li><li><p>If the <var>index</var>th entry in <var>tokens</var> is the first
     entry, then skip to the step labeled <i>done</i>.</p></li><li><p>Decrement <var>index</var> by one.</p></li></ol>
   </li><li>
    <p>If the <var>index</var>th token in <var>tokens</var> is an <a id="autofill-processing-model:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
    case-insensitive</a> match for one of the strings in the following list, then run the
    substeps that follow:</p>

    <ul class="brief"><li>"<code id="autofill-processing-model:attr-fe-autocomplete-shipping-2"><a href="#attr-fe-autocomplete-shipping">shipping</a></code>"
     </li><li>"<code id="autofill-processing-model:attr-fe-autocomplete-billing-2"><a href="#attr-fe-autocomplete-billing">billing</a></code>"
    </li></ul>

    <p>The substeps are:</p>

    <ol><li><p>Let <var>mode</var> be the matching string from the list above.</p></li><li><p>Insert <var>mode</var> at the start of <var>scope
     tokens</var>.</p></li><li><p>Add <var>mode</var> to <var>hint tokens</var>.</p></li><li><p>Let <var>IDL value</var> be the concatenation of <var>mode</var>, a
     U+0020 SPACE character, and the previous value of <var>IDL value</var>.</p></li><li><p>If the <var>index</var>th entry in <var>tokens</var> is the first
     entry, then skip to the step labeled <i>done</i>.</p></li><li><p>Decrement <var>index</var> by one.</p></li></ol>
   </li><li><p>If the <var>index</var>th entry in <var>tokens</var> is not the first entry, then jump to
   the step labeled <i>default</i>.</p></li><li><p>If the first eight characters of the <var>index</var>th token in <var>tokens</var> are not
   an <a id="autofill-processing-model:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code id="autofill-processing-model:attr-fe-autocomplete-section"><a href="#attr-fe-autocomplete-section">section-</a></code>", then jump to the step labeled
   <i>default</i>.</p></li><li><p>Let <var>section</var> be the <var>index</var>th token in <var>tokens</var>,
   <a id="autofill-processing-model:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>.</p></li><li><p>Insert <var>section</var> at the start of <var>scope tokens</var>.</p></li><li><p>Let <var>IDL value</var> be the concatenation of <var>section</var>, a U+0020 SPACE
   character, and the previous value of <var>IDL value</var>.</p></li><li><p><i>Done</i>: Set the element's <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-5">autofill hint set</a> to <var>hint
   tokens</var>.</p>

   </li><li><p>Set the element's <a href="#non-autofill-credential-type" id="autofill-processing-model:non-autofill-credential-type-2">non-autofill credential type</a> to <var>credential
   type</var>.</p></li><li><p>Set the element's <a href="#autofill-scope" id="autofill-processing-model:autofill-scope-2">autofill scope</a> to <var>scope tokens</var>.</p>

   </li><li><p>Set the element's <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-4">autofill field name</a> to <var>field</var>.</p>

   </li><li><p>Set the element's <a href="#idl-exposed-autofill-value" id="autofill-processing-model:idl-exposed-autofill-value-3">IDL-exposed autofill value</a> to <var>IDL value</var>.</p>

   </li><li><p>Return.</p></li><li><p><i>Default</i>: Set the element's <a href="#idl-exposed-autofill-value" id="autofill-processing-model:idl-exposed-autofill-value-4">IDL-exposed autofill value</a> to the empty
   string, and its <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-6">autofill hint set</a> and <a href="#autofill-scope" id="autofill-processing-model:autofill-scope-3">autofill scope</a> to empty.</p></li><li><p>If the element's <code id="autofill-processing-model:attr-fe-autocomplete-4"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute is
   wearing the <a href="#autofill-anchor-mantle" id="autofill-processing-model:autofill-anchor-mantle-2">autofill anchor mantle</a>, then set the element's <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-5">autofill field
   name</a> to the empty string and return.</p></li><li><p>Let <var>form</var> be the element's <a href="#form-owner" id="autofill-processing-model:form-owner">form owner</a>, if any, or null
   otherwise.</p></li><li>
    <p>If <var>form</var> is not null and <var>form</var>'s <code id="autofill-processing-model:attr-form-autocomplete"><a href="#attr-form-autocomplete">autocomplete</a></code> attribute is in the <a href="#attr-form-autocomplete-off-state" id="autofill-processing-model:attr-form-autocomplete-off-state">Off</a> state, then set the element's
    <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-6">autofill field name</a> to "<code id="autofill-processing-model:attr-fe-autocomplete-off"><a href="#attr-fe-autocomplete-off">off</a></code>".</p>

    <p>Otherwise, set the element's <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-7">autofill field name</a> to "<code id="autofill-processing-model:attr-fe-autocomplete-on"><a href="#attr-fe-autocomplete-on">on</a></code>".</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="determine-a-field's-category">determine a field's category</dfn>, given <var>field</var>:</p>

  <ol><li>
    <p>If the <var>field</var> is not an <a id="autofill-processing-model:ascii-case-insensitive-5" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of the
    tokens given in the first column of the following table, return the pair (null, null).</p>

    <table><thead><tr><th>Token
       </th><th>Maximum number of tokens
       </th><th>Category
     </th></tr></thead><tbody><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-off-2"><a href="#attr-fe-autocomplete-off">off</a></code>"
       </td><td>1
       </td><td>Off
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-on-2"><a href="#attr-fe-autocomplete-on">on</a></code>"
       </td><td>1
       </td><td>Automatic
     </td></tr></tbody><tbody><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-name"><a href="#attr-fe-autocomplete-name">name</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-honorific-prefix"><a href="#attr-fe-autocomplete-honorific-prefix">honorific-prefix</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-given-name"><a href="#attr-fe-autocomplete-given-name">given-name</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-additional-name"><a href="#attr-fe-autocomplete-additional-name">additional-name</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-family-name"><a href="#attr-fe-autocomplete-family-name">family-name</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-honorific-suffix"><a href="#attr-fe-autocomplete-honorific-suffix">honorific-suffix</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-nickname"><a href="#attr-fe-autocomplete-nickname">nickname</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-organization-title"><a href="#attr-fe-autocomplete-organization-title">organization-title</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-username"><a href="#attr-fe-autocomplete-username">username</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-new-password"><a href="#attr-fe-autocomplete-new-password">new-password</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-current-password"><a href="#attr-fe-autocomplete-current-password">current-password</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-one-time-code"><a href="#attr-fe-autocomplete-one-time-code">one-time-code</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-organization"><a href="#attr-fe-autocomplete-organization">organization</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-street-address-2"><a href="#attr-fe-autocomplete-street-address">street-address</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-address-line1"><a href="#attr-fe-autocomplete-address-line1">address-line1</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-address-line2"><a href="#attr-fe-autocomplete-address-line2">address-line2</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-address-line3"><a href="#attr-fe-autocomplete-address-line3">address-line3</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-address-level4"><a href="#attr-fe-autocomplete-address-level4">address-level4</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-address-level3"><a href="#attr-fe-autocomplete-address-level3">address-level3</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-address-level2"><a href="#attr-fe-autocomplete-address-level2">address-level2</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-address-level1"><a href="#attr-fe-autocomplete-address-level1">address-level1</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-country"><a href="#attr-fe-autocomplete-country">country</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-country-name"><a href="#attr-fe-autocomplete-country-name">country-name</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-postal-code"><a href="#attr-fe-autocomplete-postal-code">postal-code</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-name"><a href="#attr-fe-autocomplete-cc-name">cc-name</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-given-name"><a href="#attr-fe-autocomplete-cc-given-name">cc-given-name</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-additional-name"><a href="#attr-fe-autocomplete-cc-additional-name">cc-additional-name</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-family-name"><a href="#attr-fe-autocomplete-cc-family-name">cc-family-name</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-number"><a href="#attr-fe-autocomplete-cc-number">cc-number</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-exp-2"><a href="#attr-fe-autocomplete-cc-exp">cc-exp</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-exp-month"><a href="#attr-fe-autocomplete-cc-exp-month">cc-exp-month</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-exp-year"><a href="#attr-fe-autocomplete-cc-exp-year">cc-exp-year</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-csc"><a href="#attr-fe-autocomplete-cc-csc">cc-csc</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-cc-type"><a href="#attr-fe-autocomplete-cc-type">cc-type</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-transaction-currency"><a href="#attr-fe-autocomplete-transaction-currency">transaction-currency</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-transaction-amount"><a href="#attr-fe-autocomplete-transaction-amount">transaction-amount</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-language"><a href="#attr-fe-autocomplete-language">language</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-bday"><a href="#attr-fe-autocomplete-bday">bday</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-bday-day"><a href="#attr-fe-autocomplete-bday-day">bday-day</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-bday-month"><a href="#attr-fe-autocomplete-bday-month">bday-month</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-bday-year"><a href="#attr-fe-autocomplete-bday-year">bday-year</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-sex"><a href="#attr-fe-autocomplete-sex">sex</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-url"><a href="#attr-fe-autocomplete-url">url</a></code>"
       </td><td>3
       </td><td>Normal
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-photo"><a href="#attr-fe-autocomplete-photo">photo</a></code>"
       </td><td>3
       </td><td>Normal
     </td></tr></tbody><tbody><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-tel"><a href="#attr-fe-autocomplete-tel">tel</a></code>"
       </td><td>4
       </td><td>Contact
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-tel-country-code"><a href="#attr-fe-autocomplete-tel-country-code">tel-country-code</a></code>"
       </td><td>4
       </td><td>Contact
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-tel-national"><a href="#attr-fe-autocomplete-tel-national">tel-national</a></code>"
       </td><td>4
       </td><td>Contact
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-tel-area-code"><a href="#attr-fe-autocomplete-tel-area-code">tel-area-code</a></code>"
       </td><td>4
       </td><td>Contact
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-tel-local"><a href="#attr-fe-autocomplete-tel-local">tel-local</a></code>"
       </td><td>4
       </td><td>Contact
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-tel-local-prefix"><a href="#attr-fe-autocomplete-tel-local-prefix">tel-local-prefix</a></code>"
       </td><td>4
       </td><td>Contact
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-tel-local-suffix"><a href="#attr-fe-autocomplete-tel-local-suffix">tel-local-suffix</a></code>"
       </td><td>4
       </td><td>Contact
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-tel-extension"><a href="#attr-fe-autocomplete-tel-extension">tel-extension</a></code>"
       </td><td>4
       </td><td>Contact
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-email"><a href="#attr-fe-autocomplete-email">email</a></code>"
       </td><td>4
       </td><td>Contact
      </td></tr><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-impp"><a href="#attr-fe-autocomplete-impp">impp</a></code>"
       </td><td>4
       </td><td>Contact
     </td></tr></tbody><tbody><tr><td>"<code id="autofill-processing-model:attr-fe-autocomplete-webauthn-2"><a href="#attr-fe-autocomplete-webauthn">webauthn</a></code>"
       </td><td>5
       </td><td>Credential
    </td></tr></tbody></table>
   </li><li><p>Otherwise, let <var>maximum tokens</var> and <var>category</var> be the values of the
   cells in the second and third columns of that row respectively.</p></li><li><p>Return the pair (<var>category</var>, <var>maximum tokens</var>).</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>For the purposes of autofill, a <dfn id="control's-data">control's data</dfn> depends on the kind of control:</p>

  <dl><dt>An <code id="autofill-processing-model:the-input-element-2"><a href="#the-input-element">input</a></code> element with its <code id="autofill-processing-model:attr-input-type"><a href="#attr-input-type">type</a></code> attribute
   in the <a href="#email-state-(type=email)" id="autofill-processing-model:email-state-(type=email)">Email</a> state and with the <code id="autofill-processing-model:attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> attribute specified</dt><dd>The element's <a href="#concept-fe-values" id="autofill-processing-model:concept-fe-values">value<em>s</em></a>.</dd><dt>Any other <code id="autofill-processing-model:the-input-element-3"><a href="#the-input-element">input</a></code> element</dt><dt>A <code id="autofill-processing-model:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> element</dt><dd>The element's <a href="#concept-fe-value" id="autofill-processing-model:concept-fe-value">value</a>.</dd><dt>A <code id="autofill-processing-model:the-select-element-2"><a href="#the-select-element">select</a></code> element with its <code id="autofill-processing-model:attr-select-multiple"><a href="#attr-select-multiple">multiple</a></code>
   attribute specified</dt><dd>The <code id="autofill-processing-model:the-option-element"><a href="#the-option-element">option</a></code> elements in the <code id="autofill-processing-model:the-select-element-3"><a href="#the-select-element">select</a></code> element's <a href="#concept-select-option-list" id="autofill-processing-model:concept-select-option-list">list of options</a> that have their <a href="#concept-option-selectedness" id="autofill-processing-model:concept-option-selectedness">selectedness</a> set to true.</dd><dt>Any other <code id="autofill-processing-model:the-select-element-4"><a href="#the-select-element">select</a></code> element</dt><dd>The <code id="autofill-processing-model:the-option-element-2"><a href="#the-option-element">option</a></code> element in the <code id="autofill-processing-model:the-select-element-5"><a href="#the-select-element">select</a></code> element's <a href="#concept-select-option-list" id="autofill-processing-model:concept-select-option-list-2">list of options</a> that has its <a href="#concept-option-selectedness" id="autofill-processing-model:concept-option-selectedness-2">selectedness</a> set to true.</dd></dl>
  </div>

  <hr>

  <p>How to process the <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-7">autofill hint set</a>, <a href="#autofill-scope" id="autofill-processing-model:autofill-scope-4">autofill scope</a>, and
  <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-8">autofill field name</a> depends on the mantle that the <code id="autofill-processing-model:attr-fe-autocomplete-5"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute is wearing.</p>

  <dl class="switch"><dt>When wearing the <a href="#autofill-expectation-mantle" id="autofill-processing-model:autofill-expectation-mantle">autofill expectation mantle</a>...

   </dt><dd>
    <p>When an element's <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-9">autofill field name</a> is "<code id="autofill-processing-model:attr-fe-autocomplete-off-3"><a href="#attr-fe-autocomplete-off">off</a></code>", the user agent should not remember the <a href="#control's-data" id="autofill-processing-model:control's-data">control's
    data</a>, and should not offer past values to the user.</p>

    <p class="note">In addition, when an element's <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-10">autofill field name</a> is "<code id="autofill-processing-model:attr-fe-autocomplete-off-4"><a href="#attr-fe-autocomplete-off">off</a></code>", <a href="#history-autocomplete">values are
    reset</a> when <a href="#reactivate-a-document" id="autofill-processing-model:reactivate-a-document">reactivating a document</a>.</p>

    <div class="example">

     <p>Banks frequently do not want UAs to prefill login information:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Account: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"ac"</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"off"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->PIN: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"password"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"pin"</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"off"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

    </div>

    <p>When an element's <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-11">autofill field name</a> is <em>not</em> "<code id="autofill-processing-model:attr-fe-autocomplete-off-5"><a href="#attr-fe-autocomplete-off">off</a></code>", the user agent may store the <a href="#control's-data" id="autofill-processing-model:control's-data-2">control's
    data</a>, and may offer previously stored values to the user.</p>

    <div class="example">

     <p>For example, suppose a user visits a page with this control:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">select</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"country"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Afghanistan
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Albania
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Algeria
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Andorra
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Angola
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Antigua and Barbuda
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Argentina
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Armenia
 <c- c="">&lt;!-- </c-><em><c- c="">...</c-></em><c- c=""> --&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Yemen
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Zambia
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Zimbabwe
<c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c-></code></pre>

     <p>This might render as follows:</p>

     <p><img src="/images/select-country-1.png" alt="A drop-down control with a long alphabetical list of countries."></p>

     <p>Suppose that on the first visit to this page, the user selects "Zambia". On the second visit,
     the user agent could duplicate the entry for Zambia at the top of the list, so that the interface
     instead looks like this:</p>

     <p><img src="/images/select-country-2.png" alt="The same drop-down control with the alphabetical list of countries, but with Zambia as an entry at the top."></p>

    </div>

    <p>When the <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-12">autofill field name</a> is "<code id="autofill-processing-model:attr-fe-autocomplete-on-3"><a href="#attr-fe-autocomplete-on">on</a></code>", the user agent should attempt to use heuristics to
    determine the most appropriate values to offer the user, e.g. based on the element's <code id="autofill-processing-model:attr-fe-name"><a href="#attr-fe-name">name</a></code> value, the position of the element in its <a id="autofill-processing-model:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>,
    what other fields exist in the form, and so forth.</p>

    <p>When the <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-13">autofill field name</a> is one of the names of the <a href="#autofill-field" id="autofill-processing-model:autofill-field-2">autofill fields</a> described above, the user agent should provide suggestions that
    match the meaning of the field name as given in the table earlier in this section. The
    <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-8">autofill hint set</a> should be used to select amongst multiple possible suggestions.</p>

    <p class="example">For example, if a user once entered one address into fields that used the
    "<code id="autofill-processing-model:attr-fe-autocomplete-shipping-3"><a href="#attr-fe-autocomplete-shipping">shipping</a></code>" keyword, and another address into
    fields that used the "<code id="autofill-processing-model:attr-fe-autocomplete-billing-3"><a href="#attr-fe-autocomplete-billing">billing</a></code>" keyword, then in
    subsequent forms only the first address would be suggested for form controls whose <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-9">autofill
    hint set</a> contains the keyword "<code id="autofill-processing-model:attr-fe-autocomplete-shipping-4"><a href="#attr-fe-autocomplete-shipping">shipping</a></code>". Both addresses might be suggested,
    however, for address-related form controls whose <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-10">autofill hint set</a> does not contain
    either keyword.</p>
   </dd><dt>When wearing the <a href="#autofill-anchor-mantle" id="autofill-processing-model:autofill-anchor-mantle-3">autofill anchor mantle</a>...

   </dt><dd>
    <p>When the <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-14">autofill field name</a> is not the empty string, then the user agent must
    act as if the user had specified the <a href="#control's-data" id="autofill-processing-model:control's-data-3">control's data</a> for the given <a href="#autofill-hint-set" id="autofill-processing-model:autofill-hint-set-11">autofill
    hint set</a>, <a href="#autofill-scope" id="autofill-processing-model:autofill-scope-5">autofill scope</a>, and <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-15">autofill field name</a>
    combination.</p>
   </dd></dl>

  <p>When the user agent <dfn id="concept-fe-autofill">autofills form controls</dfn>, elements
  with the same <a href="#form-owner" id="autofill-processing-model:form-owner-2">form owner</a> and the same <a href="#autofill-scope" id="autofill-processing-model:autofill-scope-6">autofill scope</a> must use data
  relating to the same person, address, payment instrument, and contact details. <span id="autofill-country">When a user agent autofills "<code id="autofill-processing-model:attr-fe-autocomplete-country-2"><a href="#attr-fe-autocomplete-country">country</a></code>" and "<code id="autofill-processing-model:attr-fe-autocomplete-country-name-2"><a href="#attr-fe-autocomplete-country-name">country-name</a></code>" fields with the same <a href="#form-owner" id="autofill-processing-model:form-owner-3">form
  owner</a> and <a href="#autofill-scope" id="autofill-processing-model:autofill-scope-7">autofill scope</a>, and the user agent has a value for the <code id="autofill-processing-model:attr-fe-autocomplete-country-3"><a href="#attr-fe-autocomplete-country">country</a></code>" field(s), then the "<code id="autofill-processing-model:attr-fe-autocomplete-country-name-3"><a href="#attr-fe-autocomplete-country-name">country-name</a></code>" field(s) must be filled using a
  human-readable name for the same country.</span> When a user agent fills in multiple fields at
  once, all fields with the same <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-16">autofill field name</a>, <a href="#form-owner" id="autofill-processing-model:form-owner-4">form owner</a>, and
  <a href="#autofill-scope" id="autofill-processing-model:autofill-scope-8">autofill scope</a> must be filled with the same value.</p>

  <p class="example">Suppose a user agent knows of two phone numbers, +1 555 123 1234 and +1 555 666
  7777. It would not be conforming for the user agent to fill a field with <code>autocomplete="shipping tel-local-prefix"</code> with the value "123" and another field
  in the same form with <code>autocomplete="shipping tel-local-suffix"</code> with the
  value "7777". The only valid prefilled values given the aforementioned information would be "123"
  and "1234", or "666" and "7777", respectively.</p>

  <p class="example">Similarly, if a form for some reason contained both a "<code id="autofill-processing-model:attr-fe-autocomplete-cc-exp-3"><a href="#attr-fe-autocomplete-cc-exp">cc-exp</a></code>" field and a "<code id="autofill-processing-model:attr-fe-autocomplete-cc-exp-month-2"><a href="#attr-fe-autocomplete-cc-exp-month">cc-exp-month</a></code>" field, and the user agent
  prefilled the form, then the month component of the former would have to match the latter.</p>

  <div class="example">

   <p>This requirement interacts with the <a href="#autofill-anchor-mantle" id="autofill-processing-model:autofill-anchor-mantle-4">autofill anchor mantle</a> also. Consider the
   following markup snippet:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">hidden</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"nickname"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"TreePlate"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"nickname"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

   <p>The only value that a conforming user agent could suggest in the text control is "TreePlate",
   the value given by the hidden <code id="autofill-processing-model:the-input-element-4"><a href="#the-input-element">input</a></code> element.</p>

  </div>

  <p>The "<code>section-*</code>" tokens in the <a href="#autofill-scope" id="autofill-processing-model:autofill-scope-9">autofill scope</a> are opaque;
  user agents must not attempt to derive meaning from the precise values of these tokens.</p>

  <p class="example">For example, it would not be conforming if the user agent decided that it
  should offer the address it knows to be the user's daughter's address for
  "<code>section-child</code>" and the addresses it knows to be the user's spouses'
  addresses for "<code>section-spouse</code>".</p>

  <p>The autocompletion mechanism must be implemented by the user agent acting as if the user had
  modified the <a href="#control's-data" id="autofill-processing-model:control's-data-4">control's data</a>, and must be done at a time where the element is <i id="autofill-processing-model:concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i> (e.g. just after the element has been inserted into the
  document, or when the user agent <a href="#stop-parsing" id="autofill-processing-model:stop-parsing">stops parsing</a>). User agents
  must only prefill controls using values that the user could have entered.</p>

  <p class="example">For example, if a <code id="autofill-processing-model:the-select-element-6"><a href="#the-select-element">select</a></code> element only has <code id="autofill-processing-model:the-option-element-3"><a href="#the-option-element">option</a></code>
  elements with values "Steve" and "Rebecca", "Jay", and "Bob", and has an <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-17">autofill field
  name</a> "<code id="autofill-processing-model:attr-fe-autocomplete-given-name-2"><a href="#attr-fe-autocomplete-given-name">given-name</a></code>", but the user
  agent's only idea for what to prefill the field with is "Evan", then the user agent cannot prefill
  the field. It would not be conforming to somehow set the <code id="autofill-processing-model:the-select-element-7"><a href="#the-select-element">select</a></code> element to the value
  "Evan", since the user could not have done so themselves.</p>

  <p>A user agent prefilling a form control must not discriminate between form controls that are
  <a id="autofill-processing-model:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a> and those that are <a id="autofill-processing-model:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>; that is, it is not
  conforming to make the decision on whether or not to autofill based on whether the element's
  <a id="autofill-processing-model:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> is a <a id="autofill-processing-model:shadow-root" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a> versus a <code id="autofill-processing-model:document"><a href="#document">Document</a></code>.</p>

  <p>A user agent prefilling a form control's <a href="#concept-fe-value" id="autofill-processing-model:concept-fe-value-2">value</a> must not
  cause that control to <a href="#suffering-from-a-type-mismatch" id="autofill-processing-model:suffering-from-a-type-mismatch">suffer from a type
  mismatch</a>, <a href="#suffering-from-being-too-long" id="autofill-processing-model:suffering-from-being-too-long">suffer from being too long</a>,
  <a href="#suffering-from-being-too-short" id="autofill-processing-model:suffering-from-being-too-short">suffer from being too short</a>, <a href="#suffering-from-an-underflow" id="autofill-processing-model:suffering-from-an-underflow">suffer from an underflow</a>, <a href="#suffering-from-an-overflow" id="autofill-processing-model:suffering-from-an-overflow">suffer from an overflow</a>, or <a href="#suffering-from-a-step-mismatch" id="autofill-processing-model:suffering-from-a-step-mismatch">suffer from a step mismatch</a>. A user agent prefilling a form control's <a href="#concept-fe-value" id="autofill-processing-model:concept-fe-value-3">value</a> must not cause that control to <a href="#suffering-from-a-pattern-mismatch" id="autofill-processing-model:suffering-from-a-pattern-mismatch">suffer from a pattern mismatch</a> either. Where possible given the
  control's constraints, user agents must use the format given as canonical in the aforementioned
  table. Where it's not possible for the canonical format to be used, user agents should use
  heuristics to attempt to convert values so that they can be used.</p>

  <div class="example">

   <p>For example, if the user agent knows that the user's middle name is "Ines", and attempts to
   prefill a form control that looks like this:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">middle-initial</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">1</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"additional-name"</c-><c- p="">&gt;</c-></code></pre>

   <p>...then the user agent could convert "Ines" to "I" and prefill it that way.</p>

  </div>

  <div class="example">

   <p>A more elaborate example would be with month values. If the user agent knows that the user's
   birthday is the 27th of July 2012, then it might try to prefill all of the following controls
   with slightly different values, all driven from this information:</p>

   <table><tbody><tr><td>
      <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">b</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">month</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"bday"</c-><c- p="">&gt;</c-></code></pre>
     </td><td>
      2012-07
     </td><td>
      The day is dropped since the <a href="#month-state-(type=month)" id="autofill-processing-model:month-state-(type=month)">Month</a> state only accepts a
      month/year combination. (Note that this example is non-conforming, because the <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-18">autofill
      field name</a> <code id="autofill-processing-model:attr-fe-autocomplete-bday-2"><a href="#attr-fe-autocomplete-bday">bday</a></code> is not allowed with the
      <a href="#month-state-(type=month)" id="autofill-processing-model:month-state-(type=month)-2">Month</a> state.)
    </td></tr><tr><td>
      <pre><code class="html"><c- p="">&lt;</c-><c- f="">select</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">c</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"bday"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Jan
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Feb
 <em>...</em>
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Jul
 <c- p="">&lt;</c-><c- f="">option</c-><c- p="">&gt;</c->Aug
 <em>...</em>
<c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c-></code></pre>
     </td><td>
      July
     </td><td>
      The user agent picks the month from the listed options, either by noticing there are twelve
      options and picking the 7th, or by recognizing that one of the strings (three characters "Jul"
      followed by a newline and a space) is a close match for the name of the month (July) in one of
      the user agent's supported languages, or through some other similar mechanism.
    </td></tr><tr><td>
      <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">a</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">1</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">12</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"bday-month"</c-><c- p="">&gt;</c-></code></pre>
     </td><td>
      7
     </td><td>
      User agent converts "July" to a month number in the range 1..12, like the field.
    </td></tr><tr><td>
      <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">a</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">11</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"bday-month"</c-><c- p="">&gt;</c-></code></pre>
     </td><td>
      6
     </td><td>
      User agent converts "July" to a month number in the range 0..11, like the field.
    </td></tr><tr><td>
      <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">a</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">1</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">11</c-> <c- e="">autocomplete</c-><c- o="">=</c-><c- s="">"bday-month"</c-><c- p="">&gt;</c-></code></pre>
     </td><td>
     </td><td>
      User agent doesn't fill in the field, since it can't make a good guess as to what the form expects.
   </td></tr></tbody></table>

  </div>

  <p>A user agent may allow the user to override an element's <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-19">autofill field name</a>, e.g.
  to change it from "<code id="autofill-processing-model:attr-fe-autocomplete-off-6"><a href="#attr-fe-autocomplete-off">off</a></code>" to "<code id="autofill-processing-model:attr-fe-autocomplete-on-4"><a href="#attr-fe-autocomplete-on">on</a></code>" to allow values to be remembered and prefilled despite
  the page author's objections, or to always "<code id="autofill-processing-model:attr-fe-autocomplete-off-7"><a href="#attr-fe-autocomplete-off">off</a></code>",
  never remembering values.</p>

  <p>More specifically, user agents may in particular consider replacing the <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-20">autofill field
  name</a> of form controls that match the description given in the first column of the following
  table, when their <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-21">autofill field name</a> is either "<code id="autofill-processing-model:attr-fe-autocomplete-on-5"><a href="#attr-fe-autocomplete-on">on</a></code>" or "<code id="autofill-processing-model:attr-fe-autocomplete-off-8"><a href="#attr-fe-autocomplete-off">off</a></code>", with the value given in the second cell of that
  row. If this table is used, the replacements must be done in <a id="autofill-processing-model:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, since all
  but the first row references the <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-22">autofill field name</a> of earlier elements. When the
  descriptions below refer to form controls being preceded or followed by others, they mean in the
  list of <a href="#category-listed" id="autofill-processing-model:category-listed">listed elements</a> that share the same <a href="#form-owner" id="autofill-processing-model:form-owner-5">form
  owner</a>.</p>

  <table><thead><tr><th>Form control
     </th><th>New <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-23">autofill field name</a>

   </th></tr></thead><tbody><tr><td>

      an <code id="autofill-processing-model:the-input-element-5"><a href="#the-input-element">input</a></code> element whose <code id="autofill-processing-model:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in
      the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="autofill-processing-model:text-(type=text)-state-and-search-state-(type=search)">Text</a> state that is followed by an
      <code id="autofill-processing-model:the-input-element-6"><a href="#the-input-element">input</a></code> element whose <code id="autofill-processing-model:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in
      the <a href="#password-state-(type=password)" id="autofill-processing-model:password-state-(type=password)">Password</a> state

     </td><td>

      "<code id="autofill-processing-model:attr-fe-autocomplete-username-2"><a href="#attr-fe-autocomplete-username">username</a></code>"


    </td></tr><tr><td>

      an <code id="autofill-processing-model:the-input-element-7"><a href="#the-input-element">input</a></code> element whose <code id="autofill-processing-model:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute is in
      the <a href="#password-state-(type=password)" id="autofill-processing-model:password-state-(type=password)-2">Password</a> state that is preceded by an
      <code id="autofill-processing-model:the-input-element-8"><a href="#the-input-element">input</a></code> element whose <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-24">autofill field name</a> is "<code id="autofill-processing-model:attr-fe-autocomplete-username-3"><a href="#attr-fe-autocomplete-username">username</a></code>"

     </td><td>

      "<code id="autofill-processing-model:attr-fe-autocomplete-current-password-2"><a href="#attr-fe-autocomplete-current-password">current-password</a></code>"


    </td></tr><tr><td>

      an <code id="autofill-processing-model:the-input-element-9"><a href="#the-input-element">input</a></code> element whose <code id="autofill-processing-model:attr-input-type-5"><a href="#attr-input-type">type</a></code> attribute is in
      the <a href="#password-state-(type=password)" id="autofill-processing-model:password-state-(type=password)-3">Password</a> state that is preceded by an
      <code id="autofill-processing-model:the-input-element-10"><a href="#the-input-element">input</a></code> element whose <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-25">autofill field name</a> is "<code id="autofill-processing-model:attr-fe-autocomplete-current-password-3"><a href="#attr-fe-autocomplete-current-password">current-password</a></code>"

     </td><td>

      "<code id="autofill-processing-model:attr-fe-autocomplete-new-password-2"><a href="#attr-fe-autocomplete-new-password">new-password</a></code>"


    </td></tr><tr><td>

      an <code id="autofill-processing-model:the-input-element-11"><a href="#the-input-element">input</a></code> element whose <code id="autofill-processing-model:attr-input-type-6"><a href="#attr-input-type">type</a></code> attribute is in
      the <a href="#password-state-(type=password)" id="autofill-processing-model:password-state-(type=password)-4">Password</a> state that is preceded by an
      <code id="autofill-processing-model:the-input-element-12"><a href="#the-input-element">input</a></code> element whose <a href="#autofill-field-name" id="autofill-processing-model:autofill-field-name-26">autofill field name</a> is "<code id="autofill-processing-model:attr-fe-autocomplete-new-password-3"><a href="#attr-fe-autocomplete-new-password">new-password</a></code>"

     </td><td>

      "<code id="autofill-processing-model:attr-fe-autocomplete-new-password-4"><a href="#attr-fe-autocomplete-new-password">new-password</a></code>"


  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement" id="dom-fe-autocomplete" data-dfn-type="attribute"><code>autocomplete</code></dfn> IDL attribute, on getting, must return the
  element's <a href="#idl-exposed-autofill-value" id="autofill-processing-model:idl-exposed-autofill-value-5">IDL-exposed autofill value</a>.</p>
  </div>

  


  <h4 id="textFieldSelection"><span class="secno">4.10.20</span> APIs for the text control selections<a href="#textFieldSelection" class="self-link"></a></h4>

  

  <p>The <code id="textFieldSelection:the-input-element"><a href="#the-input-element">input</a></code> and <code id="textFieldSelection:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements define several attributes and methods
  for handling their selection. Their shared algorithms are defined here.</p>

  

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-textarea/input-select" id="dom-textarea/input-select-dev">select</a>()</code></dt><dd><p>Selects everything in the text control.</p></dd><dt><code><var>element</var>.<a href="#dom-textarea/input-selectionstart" id="dom-textarea/input-selectionstart-dev">selectionStart</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the offset to the start of the selection.</p>

    <p>Can be set, to change the start of the selection.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-textarea/input-selectionend" id="dom-textarea/input-selectionend-dev">selectionEnd</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the offset to the end of the selection.</p>

    <p>Can be set, to change the end of the selection.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-textarea/input-selectiondirection" id="dom-textarea/input-selectiondirection-dev">selectionDirection</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current direction of the selection.</p>

    <p>Can be set, to change the direction of the selection.</p>

    <p>The possible values are "<code>forward</code>", "<code>backward</code>",
    and "<code>none</code>".</p>
   </dd><dt><code><var>element</var>.<a href="#dom-textarea/input-setselectionrange" id="dom-textarea/input-setselectionrange-dev">setSelectionRange</a>(<var>start</var>, <var>end</var> [, <var>direction</var>])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange" title="The HTMLInputElement.setSelectionRange() method sets the start and end positions of the current text selection in an <input> or <textarea> element.">HTMLInputElement/setSelectionRange</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Changes the selection to cover the given substring in the given direction. If the direction
    is omitted, it will be reset to be the platform default (none or forward).</p>
   </dd><dt><code><var>element</var>.<a href="#dom-textarea/input-setrangetext" id="dom-textarea/input-setrangetext-dev">setRangeText</a>(<var>replacement</var> [, <var>start</var>, <var>end</var> [, <var>selectionMode</var> ] ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setRangeText" title="The HTMLInputElement.setRangeText() method replaces a range of text in an <input> or <textarea> element with a new string.">HTMLInputElement/setRangeText</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>27+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>24+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Replaces a range of text with the new text. If the <var>start</var> and <var>end</var>
    arguments are not provided, the range is assumed to be the selection.</p>

    <p>The final argument determines how the selection will be set after the text has been replaced.
    The possible values are:</p>

    <dl><dt>"<code id="dom-selectionmode-select-dev"><a href="#dom-selectionmode-select">select</a></code>"</dt><dd>Selects the newly inserted text.</dd><dt>"<code id="dom-selectionmode-start-dev"><a href="#dom-selectionmode-start">start</a></code>"</dt><dd>Moves the selection to just before the inserted text.</dd><dt>"<code id="dom-selectionmode-end-dev"><a href="#dom-selectionmode-end">end</a></code>"</dt><dd>Moves the selection to just after the selected text.</dd><dt>"<code id="dom-selectionmode-preserve-dev"><a href="#dom-selectionmode-preserve">preserve</a></code>"</dt><dd>Attempts to preserve the selection. This is the default.</dd></dl>
   </dd></dl>

  

  <p>All <code id="textFieldSelection:the-input-element-2"><a href="#the-input-element">input</a></code> elements to which these APIs <a href="#concept-input-apply" id="textFieldSelection:concept-input-apply">apply</a>, and all <code id="textFieldSelection:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> elements, have either a
  <dfn id="concept-textarea/input-selection">selection</dfn> or a <dfn id="concept-textarea/input-cursor">text entry cursor position</dfn> at all times (even for
  elements that are not <a href="#being-rendered" id="textFieldSelection:being-rendered">being rendered</a>), measured in offsets into the <a href="https://infra.spec.whatwg.org/#code-unit" id="textFieldSelection:code-unit" data-x-internal="code-unit">code units</a> of the control's <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value">relevant value</a>. The initial state must
  consist of a <a href="#concept-textarea/input-cursor" id="textFieldSelection:concept-textarea/input-cursor">text entry cursor</a> at the
  beginning of the control.</p>
  

  <p>For <code id="textFieldSelection:the-input-element-3"><a href="#the-input-element">input</a></code> elements, these APIs must operate on the element's <a href="#concept-fe-value" id="textFieldSelection:concept-fe-value">value</a>. For <code id="textFieldSelection:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code> elements, these APIs must
  operate on the element's <a href="#concept-fe-api-value" id="textFieldSelection:concept-fe-api-value">API value</a>. In the below
  algorithms, we call the value string being operated on the <dfn id="concept-textarea/input-relevant-value">relevant value</dfn>.</p>

  <div class="example">
   <p>The use of <a href="#concept-fe-api-value" id="textFieldSelection:concept-fe-api-value-2">API value</a> instead of <a href="#concept-textarea-raw-value" id="textFieldSelection:concept-textarea-raw-value">raw value</a> for <code id="textFieldSelection:the-textarea-element-4"><a href="#the-textarea-element">textarea</a></code> elements means
   that U+000D (CR) characters are normalized away. For example,

   </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"demo"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 demo<c- p="">.</c->value <c- o="">=</c-> <c- u="">"A\r\nB"</c-><c- p="">;</c->
 demo<c- p="">.</c->setRangeText<c- p="">(</c-><c- u="">"replaced"</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">2</c-><c- p="">);</c->
 assert<c- p="">(</c->demo<c- p="">.</c->value <c- o="">===</c-> <c- u="">"replacedB"</c-><c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>If we had operated on the <a href="#concept-textarea-raw-value" id="textFieldSelection:concept-textarea-raw-value-2">raw value</a> of "<code>A\r\nB</code>", then we would have replaced the characters "<code>A\r</code>", ending up with a result of "<code>replaced\nB</code>". But since
   we used the <a href="#concept-fe-api-value" id="textFieldSelection:concept-fe-api-value-3">API value</a> of "<code>A\nB</code>", we replaced the characters "<code>A\n</code>", giving "<code>replacedB</code>".</p>
  </div>

  <p class="note">Characters with no visible rendering, such as U+200D ZERO WIDTH JOINER, still
  count as characters. Thus, for instance, the selection can include just an invisible character,
  and the text insertion cursor can be placed to one side or another of such a character.</p>

  <div data-algorithm="">
  <p>Whenever the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-2">relevant value</a> changes
  for an element to which these APIs apply, run these steps:</p>

  <ol><li>
    <p>If the element has a <a href="#concept-textarea/input-selection" id="textFieldSelection:concept-textarea/input-selection">selection</a>:</p>

    <ol><li><p>If the start of the selection is now past the end of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-3">relevant value</a>, set it to the end of the
     <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-4">relevant value</a>.</p></li><li><p>If the end of the selection is now past the end of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-5">relevant value</a>, set it to the end of the
     <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-6">relevant value</a>.</p></li><li><p>If the user agent does not support empty selection, and both the start and end of the
     selection are now pointing to the end of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-7">relevant value</a>, then instead set the
     element's <a href="#concept-textarea/input-cursor" id="textFieldSelection:concept-textarea/input-cursor-2">text entry cursor position</a> to the
     end of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-8">relevant value</a>, removing
     any selection.</p></li></ol>
   </li><li><p>Otherwise, the element must have a <a href="#concept-textarea/input-cursor" id="textFieldSelection:concept-textarea/input-cursor-3">text entry
   cursor position</a> position. If it is now past the end of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-9">relevant value</a>, set it to the end of the
   <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-10">relevant value</a>.</p></li></ol>
  </div>

  <p class="note">In some cases where the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-11">relevant value</a> changes, other parts of the
  specification will also modify the <a href="#concept-textarea/input-cursor" id="textFieldSelection:concept-textarea/input-cursor-4">text entry cursor
  position</a>, beyond just the clamping steps above. For example, see the <code id="textFieldSelection:dom-textarea-value"><a href="#dom-textarea-value">value</a></code> setter for <code id="textFieldSelection:the-textarea-element-5"><a href="#the-textarea-element">textarea</a></code>.</p>

  <p>Where possible, user interface features for changing the <a href="#concept-textarea/input-selection" id="textFieldSelection:concept-textarea/input-selection-2">text selection</a> in <code id="textFieldSelection:the-input-element-4"><a href="#the-input-element">input</a></code> and
  <code id="textFieldSelection:the-textarea-element-6"><a href="#the-textarea-element">textarea</a></code> elements must be implemented using the <a href="#set-the-selection-range" id="textFieldSelection:set-the-selection-range">set the selection range</a>
  algorithm so that, e.g., all the same events fire.</p>

  <p>The <a href="#concept-textarea/input-selection" id="textFieldSelection:concept-textarea/input-selection-3">selections</a> of <code id="textFieldSelection:the-input-element-5"><a href="#the-input-element">input</a></code> and
  <code id="textFieldSelection:the-textarea-element-7"><a href="#the-textarea-element">textarea</a></code> elements have a <dfn id="selection-direction">selection direction</dfn>, which is either "<code>forward</code>", "<code>backward</code>", or "<code>none</code>".
  The exact meaning of the selection direction depends on the platform. This direction is set when
  the user manipulates the selection.  The initial <a href="#selection-direction" id="textFieldSelection:selection-direction">selection direction</a> must be "<code>none</code>" if the platform supports that direction, or "<code>forward</code>" otherwise.</p>

  <div data-algorithm="">
  <p>To <dfn id="set-the-selection-direction">set the selection direction</dfn> of an element to a given direction, update the
  element's <a href="#selection-direction" id="textFieldSelection:selection-direction-2">selection direction</a> to the given direction, unless the direction is "<code>none</code>" and the platform does not support that direction; in that case, update the
  element's <a href="#selection-direction" id="textFieldSelection:selection-direction-3">selection direction</a> to "<code>forward</code>".</p>
  </div>

  <div class="note">
   <p>On Windows, the direction indicates the position of the caret relative to
   the selection: a "<code>forward</code>" selection has the caret at the end of the
   selection and a "<code>backward</code>" selection has the caret at the start of the
   selection. Windows has no "<code>none</code>" direction.</p>

   <p>On Mac, the direction indicates which end of the selection is affected when the user adjusts
   the size of the selection using the arrow keys with the Shift modifier: the "<code>forward</code>" direction means the end of the selection is modified, and the "<code>backward</code>" direction means the start of the selection is modified. The "<code>none</code>" direction is the default on Mac, it indicates that no particular direction
   has yet been selected. The user sets the direction implicitly when first adjusting the selection,
   based on which directional arrow key was used.</p>
  </div>


  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select" title="The HTMLInputElement.select() method selects all the text in a <textarea> element or in an <input> element that includes a text field.">HTMLInputElement/select</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select" title="The HTMLInputElement.select() method selects all the text in a <textarea> element or in an <input> element that includes a text field.">HTMLInputElement/select</a></p></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement,HTMLTextAreaElement" id="dom-textarea/input-select" data-dfn-type="method"><code>select()</code></dfn> method, when invoked, must run the
  following steps:</p>

  <ol><li>
    <p>If this element is an <code id="textFieldSelection:the-input-element-6"><a href="#the-input-element">input</a></code> element, and either <code id="textFieldSelection:dom-textarea/input-select"><a href="#dom-textarea/input-select">select()</a></code> <a href="#do-not-apply" id="textFieldSelection:do-not-apply">does not
    apply</a> to this element or the corresponding control has no selectable text, return.</p>

    <p class="example">For instance, in a user agent where <code id="textFieldSelection:color-state-(type=color)"><a href="#color-state-(type=color)">&lt;input type=color&gt;</a></code> is rendered as a color well with a
    picker, as opposed to a text control accepting a hexadecimal color code, there would be no
    selectable text, and thus calls to the method are ignored.</p>
   </li><li><p><a href="#set-the-selection-range" id="textFieldSelection:set-the-selection-range-2">Set the selection range</a> with 0 and infinity.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement,HTMLTextAreaElement" id="dom-textarea/input-selectionstart" data-dfn-type="attribute"><code>selectionStart</code></dfn> attribute's getter must run
  the following steps:</p>

  <ol><li><p>If this element is an <code id="textFieldSelection:the-input-element-7"><a href="#the-input-element">input</a></code> element, and <code id="textFieldSelection:dom-textarea/input-selectionstart"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code> <a href="#do-not-apply" id="textFieldSelection:do-not-apply-2">does
   not apply</a> to this element, return null.</p></li><li><p>If there is no <a href="#concept-textarea/input-selection" id="textFieldSelection:concept-textarea/input-selection-4">selection</a>, return
   the <a id="textFieldSelection:code-unit-2" href="https://infra.spec.whatwg.org/#code-unit" data-x-internal="code-unit">code unit</a> offset within the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-12">relevant value</a> to the character that
   immediately follows the <a href="#concept-textarea/input-cursor" id="textFieldSelection:concept-textarea/input-cursor-5">text entry
   cursor</a>.</p></li><li><p>Return the <a id="textFieldSelection:code-unit-3" href="https://infra.spec.whatwg.org/#code-unit" data-x-internal="code-unit">code unit</a> offset within the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-13">relevant value</a> to the character that
   immediately follows the start of the <a href="#concept-textarea/input-selection" id="textFieldSelection:concept-textarea/input-selection-5">selection</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="textFieldSelection:dom-textarea/input-selectionstart-2"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code> attribute's setter
  must run the following steps:</p>

  <ol><li><p>If this element is an <code id="textFieldSelection:the-input-element-8"><a href="#the-input-element">input</a></code> element, and <code id="textFieldSelection:dom-textarea/input-selectionstart-3"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code> <a href="#do-not-apply" id="textFieldSelection:do-not-apply-3">does
   not apply</a> to this element, throw an <a id="textFieldSelection:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="textFieldSelection:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>end</var> be the value of this element's <code id="textFieldSelection:dom-textarea/input-selectionend"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code> attribute.</p></li><li><p>If <var>end</var> is less than the given value, set <var>end</var> to the given
   value.</p></li><li><p><a href="#set-the-selection-range" id="textFieldSelection:set-the-selection-range-3">Set the selection range</a> with the given value, <var>end</var>, and the value
   of this element's <code id="textFieldSelection:dom-textarea/input-selectiondirection"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code>
   attribute.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement,HTMLTextAreaElement" id="dom-textarea/input-selectionend" data-dfn-type="attribute"><code>selectionEnd</code></dfn> attribute's getter must run the
  following steps:</p>

  <ol><li><p>If this element is an <code id="textFieldSelection:the-input-element-9"><a href="#the-input-element">input</a></code> element, and <code id="textFieldSelection:dom-textarea/input-selectionend-2"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code> <a href="#do-not-apply" id="textFieldSelection:do-not-apply-4">does
   not apply</a> to this element, return null.</p></li><li><p>If there is no <a href="#concept-textarea/input-selection" id="textFieldSelection:concept-textarea/input-selection-6">selection</a>, return
   the <a id="textFieldSelection:code-unit-4" href="https://infra.spec.whatwg.org/#code-unit" data-x-internal="code-unit">code unit</a> offset within the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-14">relevant value</a> to the character that
   immediately follows the <a href="#concept-textarea/input-cursor" id="textFieldSelection:concept-textarea/input-cursor-6">text entry
   cursor</a>.</p></li><li><p>Return the <a id="textFieldSelection:code-unit-5" href="https://infra.spec.whatwg.org/#code-unit" data-x-internal="code-unit">code unit</a> offset within the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-15">relevant value</a> to the character that
   immediately follows the end of the <a href="#concept-textarea/input-selection" id="textFieldSelection:concept-textarea/input-selection-7">selection</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="textFieldSelection:dom-textarea/input-selectionend-3"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code> attribute's setter must
  run the following steps:</p>

  <ol><li><p>If this element is an <code id="textFieldSelection:the-input-element-10"><a href="#the-input-element">input</a></code> element, and <code id="textFieldSelection:dom-textarea/input-selectionend-4"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code> <a href="#do-not-apply" id="textFieldSelection:do-not-apply-5">does not
   apply</a> to this element, throw an <a id="textFieldSelection:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="textFieldSelection:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#set-the-selection-range" id="textFieldSelection:set-the-selection-range-4">Set the selection range</a> with the value of this element's <code id="textFieldSelection:dom-textarea/input-selectionstart-4"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code> attribute, the given value, and
   the value of this element's <code id="textFieldSelection:dom-textarea/input-selectiondirection-2"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code> attribute.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement,HTMLTextAreaElement" id="dom-textarea/input-selectiondirection" data-dfn-type="attribute"><code>selectionDirection</code></dfn> attribute's getter
  must run the following steps:</p>

  <ol><li><p>If this element is an <code id="textFieldSelection:the-input-element-11"><a href="#the-input-element">input</a></code> element, and <code id="textFieldSelection:dom-textarea/input-selectiondirection-3"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code> <a href="#do-not-apply" id="textFieldSelection:do-not-apply-6">does not apply</a> to this element, return null.</p></li><li><p>Return this element's <a href="#selection-direction" id="textFieldSelection:selection-direction-4">selection direction</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="textFieldSelection:dom-textarea/input-selectiondirection-4"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code> attribute's
  setter must run the following steps:</p>

  <ol><li><p>If this element is an <code id="textFieldSelection:the-input-element-12"><a href="#the-input-element">input</a></code> element, and <code id="textFieldSelection:dom-textarea/input-selectiondirection-5"><a href="#dom-textarea/input-selectiondirection">selectionDirection</a></code> <a href="#do-not-apply" id="textFieldSelection:do-not-apply-7">does not apply</a> to this element, throw an
   <a id="textFieldSelection:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="textFieldSelection:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#set-the-selection-range" id="textFieldSelection:set-the-selection-range-5">Set the selection range</a> with the value of this element's <code id="textFieldSelection:dom-textarea/input-selectionstart-5"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code> attribute, the value of this
   element's <code id="textFieldSelection:dom-textarea/input-selectionend-5"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code> attribute, and the
   given value.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement,HTMLTextAreaElement" id="dom-textarea/input-setselectionrange" data-dfn-type="method"><code>setSelectionRange(<var>start</var>, <var>end</var>,
  <var>direction</var>)</code></dfn> method, when invoked, must run the following steps:</p>

  <ol><li><p>If this element is an <code id="textFieldSelection:the-input-element-13"><a href="#the-input-element">input</a></code> element, and <code id="textFieldSelection:dom-textarea/input-setselectionrange"><a href="#dom-textarea/input-setselectionrange">setSelectionRange()</a></code> <a href="#do-not-apply" id="textFieldSelection:do-not-apply-8">does not apply</a> to this element, throw an
   <a id="textFieldSelection:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="textFieldSelection:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#set-the-selection-range" id="textFieldSelection:set-the-selection-range-6">Set the selection range</a> with <var>start</var>, <var>end</var>, and
   <var>direction</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="set-the-selection-range">set the selection range</dfn> with an integer or null <var>start</var>, an integer or
  null or the special value infinity <var>end</var>, and optionally a string <var>direction</var>,
  run the following steps:</p>

  <ol><li><p>If <var>start</var> is null, let <var>start</var> be 0.</p></li><li><p>If <var>end</var> is null, let <var>end</var> be 0.</p></li><li><p>Set the <a href="#concept-textarea/input-selection" id="textFieldSelection:concept-textarea/input-selection-8">selection</a> of the text
   control to the sequence of <a href="https://infra.spec.whatwg.org/#code-unit" id="textFieldSelection:code-unit-6" data-x-internal="code-unit">code units</a> within the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-16">relevant value</a> starting with the code unit
   at the <var>start</var>th position (in logical order) and ending with the code unit at the <span>(<var>end</var>-1)</span>th position. Arguments greater than the <a id="textFieldSelection:length" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of
   the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-17">relevant value</a> of the text control
   (including the special value infinity) must be treated as pointing at the end of the text
   control. If <var>end</var> is less than or equal to <var>start</var>, then the start of the
   selection and the end of the selection must both be placed immediately before the character with
   offset <var>end</var>. In UAs where there is no concept of an empty selection, this must set the
   cursor to be just before the character with offset <var>end</var>.</p></li><li><p>If <var>direction</var> is not <a id="textFieldSelection:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> either "<code>backward</code>" or "<code>forward</code>", or if the <var>direction</var>
   argument was not given, set <var>direction</var> to "<code>none</code>".</p></li><li><p><a href="#set-the-selection-direction" id="textFieldSelection:set-the-selection-direction">Set the selection direction</a> of the text control to
   <var>direction</var>.</p></li><li><p>If the previous steps caused the <a href="#concept-textarea/input-selection" id="textFieldSelection:concept-textarea/input-selection-9">selection</a> of the text control to be modified (in
   either extent or <a href="#selection-direction" id="textFieldSelection:selection-direction-5">direction</a>), then <a href="#queue-an-element-task" id="textFieldSelection:queue-an-element-task">queue an
   element task</a> on the <a href="#user-interaction-task-source" id="textFieldSelection:user-interaction-task-source">user interaction task source</a> given the element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="textFieldSelection:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="textFieldSelection:event-select"><a href="#event-select">select</a></code>
   at the element, with the <code id="textFieldSelection:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to
   true.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLInputElement,HTMLTextAreaElement" id="dom-textarea/input-setrangetext" data-dfn-type="method"><code>setRangeText(<var>replacement</var>, <var>start</var>,
  <var>end</var>, <var>selectMode</var>)</code></dfn> method, when invoked, must run the following
  steps:</p>

  <ol><li><p>If this element is an <code id="textFieldSelection:the-input-element-14"><a href="#the-input-element">input</a></code> element, and <code id="textFieldSelection:dom-textarea/input-setrangetext"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code> <a href="#do-not-apply" id="textFieldSelection:do-not-apply-9">does
   not apply</a> to this element, throw an <a id="textFieldSelection:invalidstateerror-5" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="textFieldSelection:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set this element's <a href="#concept-fe-dirty" id="textFieldSelection:concept-fe-dirty">dirty value flag</a> to
   true.</p></li><li>
    <p>If the method has only one argument, then let <var>start</var> and <var>end</var> have the values of the <code id="textFieldSelection:dom-textarea/input-selectionstart-6"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code> attribute and the <code id="textFieldSelection:dom-textarea/input-selectionend-6"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code> attribute respectively.</p>

    <p>Otherwise, let <var>start</var>, <var>end</var> have the values of the
    second and third arguments respectively.</p>
   </li><li><p>If <var>start</var> is greater than <var>end</var>, then throw an
   <a id="textFieldSelection:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="textFieldSelection:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>start</var> is greater than the <a id="textFieldSelection:length-2" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-18">relevant value</a> of the text control, then
   set it to the <a id="textFieldSelection:length-3" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-19">relevant value</a> of the text control.</p></li><li><p>If <var>end</var> is greater than the <a id="textFieldSelection:length-4" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-20">relevant value</a> of the text control, then
   set it to the <a id="textFieldSelection:length-5" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-21">relevant value</a> of the text control.</p></li><li><p>Let <var>selection start</var> be the current value of the <code id="textFieldSelection:dom-textarea/input-selectionstart-7"><a href="#dom-textarea/input-selectionstart">selectionStart</a></code> attribute.</p></li><li><p>Let <var>selection end</var> be the current value of the <code id="textFieldSelection:dom-textarea/input-selectionend-7"><a href="#dom-textarea/input-selectionend">selectionEnd</a></code> attribute.</p></li><li><p>If <var>start</var> is less than <var>end</var>, delete the sequence of <a href="https://infra.spec.whatwg.org/#code-unit" id="textFieldSelection:code-unit-7" data-x-internal="code-unit">code units</a> within the element's <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-22">relevant value</a> starting with the code unit
   at the <var>start</var>th position and ending with the code unit at the <span>(<var>end</var>-1)</span>th position.</p></li><li><p>Insert the value of the first argument into the text of the <a href="#concept-textarea/input-relevant-value" id="textFieldSelection:concept-textarea/input-relevant-value-23">relevant value</a> of the text control,
   immediately before the <var>start</var>th <a id="textFieldSelection:code-unit-8" href="https://infra.spec.whatwg.org/#code-unit" data-x-internal="code-unit">code unit</a>.</p></li><li><p>Let <var>new length</var> be the <a id="textFieldSelection:length-6" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of the value of the first
   argument.</p></li><li><p>Let <var>new end</var> be the sum of <var>start</var> and <var>new length</var>.</p></li><li>
    <p>Run the appropriate set of substeps from the following list:</p>

    <dl class="switch"><dt>If the fourth argument's value is "<dfn data-dfn-for="SelectionMode" id="dom-selectionmode-select" data-dfn-type="enum-value"><code>select</code></dfn>"</dt><dd>
      <p>Let <var>selection start</var> be <var>start</var>.</p>

      <p>Let <var>selection end</var> be <var>new end</var>.</p>
     </dd><dt>If the fourth argument's value is "<dfn data-dfn-for="SelectionMode" id="dom-selectionmode-start" data-dfn-type="enum-value"><code>start</code></dfn>"</dt><dd>
      <p>Let <var>selection start</var> and <var>selection end</var> be <var>start</var>.</p>
     </dd><dt>If the fourth argument's value is "<dfn data-dfn-for="SelectionMode" id="dom-selectionmode-end" data-dfn-type="enum-value"><code>end</code></dfn>"</dt><dd>
      <p>Let <var>selection start</var> and <var>selection end</var> be <var>new end</var>.</p>
     </dd><dt>If the fourth argument's value is "<dfn data-dfn-for="SelectionMode" id="dom-selectionmode-preserve" data-dfn-type="enum-value"><code>preserve</code></dfn>"</dt><dt>If the method has only one argument</dt><dd>
      <ol><li><p>Let <var>old length</var> be <var>end</var> minus <var>start</var>.</p>

       </li><li><p>Let <var>delta</var> be <var>new length</var> minus <var>old length</var>.</p>

       </li><li>
        <p>If <var>selection start</var> is greater than <var>end</var>, then
        increment it by <var>delta</var>. (If <var>delta</var> is negative, i.e.
        the new text is shorter than the old text, then this will <em>decrease</em> the value of
        <var>selection start</var>.)</p>

        <p>Otherwise: if <var>selection start</var> is greater than <var>start</var>, then set it to <var>start</var>. (This snaps the start of the
        selection to the start of the new text if it was in the middle of the text that it
        replaced.)</p>
       </li><li>
        <p>If <var>selection end</var> is greater than <var>end</var>, then
        increment it by <var>delta</var> in the same way.</p>

        <p>Otherwise: if <var>selection end</var> is greater than <var>start</var>, then set it to <var>new end</var>. (This snaps the end of the
        selection to the end of the new text if it was in the middle of the text that it
        replaced.)</p>
       </li></ol>
     </dd></dl>
   </li><li><p><a href="#set-the-selection-range" id="textFieldSelection:set-the-selection-range-7">Set the selection range</a> with <var>selection start</var> and <var>selection
   end</var>.</p></li></ol>
  </div>

  <p>The <code id="textFieldSelection:dom-textarea/input-setrangetext-2"><a href="#dom-textarea/input-setrangetext">setRangeText()</a></code> method uses the
  following enumeration:</p>

  <pre><code class="idl"><c- b="">enum</c-> <dfn id="selectionmode" data-dfn-type="enum"><c- g="">SelectionMode</c-></dfn> {
  <c- s="">"</c-><a href="#dom-selectionmode-select" id="textFieldSelection:dom-selectionmode-select"><c- s="">select</c-></a><c- s="">"</c->,
  <c- s="">"</c-><a href="#dom-selectionmode-start" id="textFieldSelection:dom-selectionmode-start"><c- s="">start</c-></a><c- s="">"</c->,
  <c- s="">"</c-><a href="#dom-selectionmode-end" id="textFieldSelection:dom-selectionmode-end"><c- s="">end</c-></a><c- s="">"</c->,
  <c- s="">"</c-><a href="#dom-selectionmode-preserve" id="textFieldSelection:dom-selectionmode-preserve"><c- s="">preserve</c-></a><c- s="">"</c-> // default
};</code></pre>

  <hr>

  

  <div class="example">

   <p>To obtain the currently selected text, the following JavaScript suffices:</p>

   <pre><code class="js"><c- a="">var</c-> selectionText <c- o="">=</c-> control<c- p="">.</c->value<c- p="">.</c->substring<c- p="">(</c->control<c- p="">.</c->selectionStart<c- p="">,</c-> control<c- p="">.</c->selectionEnd<c- p="">);</c-></code></pre>

   <p>...where <var>control</var> is the <code id="textFieldSelection:the-input-element-15"><a href="#the-input-element">input</a></code> or <code id="textFieldSelection:the-textarea-element-8"><a href="#the-textarea-element">textarea</a></code>
   element.</p>

  </div>

  <div class="example">

   <p>To add some text at the start of a text control, while maintaining the text selection, the
   three attributes must be preserved:</p>

   <pre><code class="js"><c- a="">var</c-> oldStart <c- o="">=</c-> control<c- p="">.</c->selectionStart<c- p="">;</c->
<c- a="">var</c-> oldEnd <c- o="">=</c-> control<c- p="">.</c->selectionEnd<c- p="">;</c->
<c- a="">var</c-> oldDirection <c- o="">=</c-> control<c- p="">.</c->selectionDirection<c- p="">;</c->
<c- a="">var</c-> prefix <c- o="">=</c-> <c- u="">"http://"</c-><c- p="">;</c->
control<c- p="">.</c->value <c- o="">=</c-> prefix <c- o="">+</c-> control<c- p="">.</c->value<c- p="">;</c->
control<c- p="">.</c->setSelectionRange<c- p="">(</c->oldStart <c- o="">+</c-> prefix<c- p="">.</c->length<c- p="">,</c-> oldEnd <c- o="">+</c-> prefix<c- p="">.</c->length<c- p="">,</c-> oldDirection<c- p="">);</c-></code></pre>

   <p>...where <var>control</var> is the <code id="textFieldSelection:the-input-element-16"><a href="#the-input-element">input</a></code> or <code id="textFieldSelection:the-textarea-element-9"><a href="#the-textarea-element">textarea</a></code>
   element.</p>

  </div>



  <h4 id="constraints"><span class="secno">4.10.21</span> Constraints<a href="#constraints" class="self-link"></a></h4>

  

  <h5 id="definitions"><span class="secno">4.10.21.1</span> Definitions<a href="#definitions" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A <a href="#category-submit" id="definitions:category-submit">submittable element</a> is a <dfn id="candidate-for-constraint-validation">candidate for constraint
  validation</dfn> except when a condition has <dfn id="barred-from-constraint-validation">barred
  the element from constraint validation</dfn>. (For example, an element is <a href="#barred-from-constraint-validation" id="definitions:barred-from-constraint-validation">barred from
  constraint validation</a> if it has a <code id="definitions:the-datalist-element"><a href="#the-datalist-element">datalist</a></code> element ancestor.)</p>
  </div>

  <p>An element can have a <dfn id="custom-validity-error-message">custom validity error message</dfn> defined. Initially, an element
  must have its <a href="#custom-validity-error-message" id="definitions:custom-validity-error-message">custom validity error message</a> set to the empty string. When its value
  is not the empty string, the element is <a href="#suffering-from-a-custom-error" id="definitions:suffering-from-a-custom-error">suffering from a custom error</a>. It can be set
  using the <code id="definitions:dom-cva-setcustomvalidity"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> method, except for
  <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element">form-associated custom elements</a>. <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-2">Form-associated custom elements</a> can have a
  <a href="#custom-validity-error-message" id="definitions:custom-validity-error-message-2">custom validity error message</a> set via their <code id="definitions:elementinternals"><a href="#elementinternals">ElementInternals</a></code> object's
  <code id="definitions:dom-elementinternals-setvalidity"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method. The user agent should use the
  <a href="#custom-validity-error-message" id="definitions:custom-validity-error-message-3">custom validity error message</a> when alerting the user to the problem with the
  control.</p>

  <p>An element can be constrained in various ways. The following is the list of <dfn id="validity-states">validity
  states</dfn> that a form control can be in, making the control invalid for the purposes of
  constraint validation. (The definitions below are non-normative; other parts of this specification
  define more precisely when each state applies or does not.)</p>

  <dl><dt> <dfn id="suffering-from-being-missing">Suffering from being missing</dfn> </dt><dd>
    <p>When a control has no <a href="#concept-fe-value" id="definitions:concept-fe-value">value</a> but has a <code>required</code> attribute (<code id="definitions:the-input-element"><a href="#the-input-element">input</a></code> <code id="definitions:attr-input-required"><a href="#attr-input-required">required</a></code>, <code id="definitions:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> <code id="definitions:attr-textarea-required"><a href="#attr-textarea-required">required</a></code>); or, more complicated rules for
    <code id="definitions:the-select-element"><a href="#the-select-element">select</a></code> elements and controls in <a href="#radio-button-group" id="definitions:radio-button-group">radio button
    groups</a>, as specified in their sections.</p>

    <p>When the <code id="definitions:dom-elementinternals-setvalidity-2"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method sets
    <code>valueMissing</code> flag to true for a
    <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-3">form-associated custom element</a>.</p>
   </dd><dt> <dfn id="suffering-from-a-type-mismatch">Suffering from a type mismatch</dfn> </dt><dd>
    <p>When a control that allows arbitrary user input has a <a href="#concept-fe-value" id="definitions:concept-fe-value-2">value</a> that is not in the correct syntax (<a href="#email-state-(type=email)" id="definitions:email-state-(type=email)">Email</a>, <a href="#url-state-(type=url)" id="definitions:url-state-(type=url)">URL</a>).
    </p>

    <p>When the <code id="definitions:dom-elementinternals-setvalidity-3"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method sets
    <code>typeMismatch</code> flag to true for a
    <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-4">form-associated custom element</a>.</p>
   </dd><dt> <dfn id="suffering-from-a-pattern-mismatch">Suffering from a pattern mismatch</dfn> </dt><dd>
    <p>When a control has a <a href="#concept-fe-value" id="definitions:concept-fe-value-3">value</a> that doesn't satisfy the
    <code id="definitions:attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code> attribute.</p>

    <p>When the <code id="definitions:dom-elementinternals-setvalidity-4"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method sets
    <code>patternMismatch</code> flag to true for a
    <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-5">form-associated custom element</a>.</p>
   </dd><dt> <dfn id="suffering-from-being-too-long">Suffering from being too long</dfn> </dt><dd>
    <p>When a control has a <a href="#concept-fe-value" id="definitions:concept-fe-value-4">value</a> that is too long for the
    <a href="#attr-fe-maxlength" id="definitions:attr-fe-maxlength">form control <code>maxlength</code> attribute</a>
    (<code id="definitions:the-input-element-2"><a href="#the-input-element">input</a></code> <code id="definitions:attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>, <code id="definitions:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code>
    <code id="definitions:attr-textarea-maxlength"><a href="#attr-textarea-maxlength">maxlength</a></code>). </p>

    <p>When the <code id="definitions:dom-elementinternals-setvalidity-5"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method sets
    <code>tooLong</code> flag to true for a
    <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-6">form-associated custom element</a>.</p>
   </dd><dt> <dfn id="suffering-from-being-too-short">Suffering from being too short</dfn> </dt><dd>
    <p>When a control has a <a href="#concept-fe-value" id="definitions:concept-fe-value-5">value</a> that is too short for the
    <a href="#attr-fe-minlength" id="definitions:attr-fe-minlength">form control <code>minlength</code> attribute</a>
    (<code id="definitions:the-input-element-3"><a href="#the-input-element">input</a></code> <code id="definitions:attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>, <code id="definitions:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code>
    <code id="definitions:attr-textarea-minlength"><a href="#attr-textarea-minlength">minlength</a></code>). </p>

    <p>When the <code id="definitions:dom-elementinternals-setvalidity-6"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method sets
    <code>tooShort</code> flag to true for a
    <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-7">form-associated custom element</a>.</p>
   </dd><dt> <dfn id="suffering-from-an-underflow">Suffering from an underflow</dfn> </dt><dd>
    <p>When a control has a <a href="#concept-fe-value" id="definitions:concept-fe-value-6">value</a> that is not the empty
    string and is too low for the <code id="definitions:attr-input-min"><a href="#attr-input-min">min</a></code> attribute.</p>

    <p>When the <code id="definitions:dom-elementinternals-setvalidity-7"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method sets
    <code>rangeUnderflow</code> flag to true for a
    <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-8">form-associated custom element</a>.</p>
  </dd><dt> <dfn id="suffering-from-an-overflow">Suffering from an overflow</dfn> </dt><dd>
    <p>When a control has a <a href="#concept-fe-value" id="definitions:concept-fe-value-7">value</a> that is not the empty
    string and is too high for the <code id="definitions:attr-input-max"><a href="#attr-input-max">max</a></code> attribute.</p>

    <p>When the <code id="definitions:dom-elementinternals-setvalidity-8"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method sets
    <code>rangeOverflow</code> flag to true for a
    <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-9">form-associated custom element</a>.</p>
  </dd><dt> <dfn id="suffering-from-a-step-mismatch">Suffering from a step mismatch</dfn> </dt><dd>
    <p>When a control has a <a href="#concept-fe-value" id="definitions:concept-fe-value-8">value</a> that doesn't fit the
    rules given by the <code id="definitions:attr-input-step"><a href="#attr-input-step">step</a></code> attribute.</p>

    <p>When the <code id="definitions:dom-elementinternals-setvalidity-9"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method sets
    <code>stepMismatch</code> flag to true for a
    <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-10">form-associated custom element</a>.</p>
  </dd><dt> <dfn id="suffering-from-bad-input">Suffering from bad input</dfn> </dt><dd>
    <p>When a control has incomplete input and the user agent does not think the user ought to
    be able to submit the form in its current state.</p>

    <p>When the <code id="definitions:dom-elementinternals-setvalidity-10"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method sets
    <code>badInput</code> flag to true for a <a href="#form-associated-custom-element" id="definitions:form-associated-custom-element-11">form-associated custom element</a>.
    </p>
   </dd><dt> <dfn id="suffering-from-a-custom-error">Suffering from a custom error</dfn> </dt><dd> <p>When a control's <a href="#custom-validity-error-message" id="definitions:custom-validity-error-message-4">custom validity error message</a> (as set by the element's
   <code id="definitions:dom-cva-setcustomvalidity-2"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> method or
   <code id="definitions:elementinternals-2"><a href="#elementinternals">ElementInternals</a></code>'s <code id="definitions:dom-elementinternals-setvalidity-11"><a href="#dom-elementinternals-setvalidity">setValidity()</a></code> method) is
   not the empty string.</p> </dd></dl>

  <p class="note">An element can still suffer from these states even when the element is <a href="#concept-fe-disabled" id="definitions:concept-fe-disabled">disabled</a>; thus these states can be represented in the DOM even
  if validating the form during submission wouldn't indicate a problem to the user.</p>

  <div data-algorithm="">
  <p>An element <dfn id="concept-fv-valid">satisfies its constraints</dfn> if it is not suffering
  from any of the above <a href="#validity-states" id="definitions:validity-states">validity states</a>.</p>
  </div>

  



  

  <h5 id="constraint-validation"><span class="secno">4.10.21.2</span> Constraint validation<a href="#constraint-validation" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>When the user agent is required to <dfn id="statically-validate-the-constraints">statically validate the constraints</dfn> of
  <code id="constraint-validation:the-form-element"><a href="#the-form-element">form</a></code> element <var>form</var>, it must run the following steps, which return
  either a <i>positive</i> result (all the controls in the form are valid) or a <i>negative</i>
  result (there are invalid controls) along with a (possibly empty) list of elements that are
  invalid and for which no script has claimed responsibility:</p>

  <ol><li><p>Let <var>controls</var> be a list of all the <a href="#category-submit" id="constraint-validation:category-submit">submittable elements</a> whose <a href="#form-owner" id="constraint-validation:form-owner">form owner</a> is <var>form</var>, in <a id="constraint-validation:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li><li><p>Let <var>invalid controls</var> be an initially empty list of elements.</p></li><li>
    <p>For each element <var>field</var> in <var>controls</var>, in <a id="constraint-validation:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

    <ol><li><p>If <var>field</var> is not a <a href="#candidate-for-constraint-validation" id="constraint-validation:candidate-for-constraint-validation">candidate for constraint validation</a>,
     then move on to the next element.</p></li><li><p>Otherwise, if <var>field</var> <a href="#concept-fv-valid" id="constraint-validation:concept-fv-valid">satisfies its
     constraints</a>, then move on to the next element.</p></li><li><p>Otherwise, add <var>field</var> to <var>invalid
     controls</var>.</p></li></ol>
   </li><li><p>If <var>invalid controls</var> is empty, then return a <i>positive</i> result.</p></li><li><p>Let <var>unhandled invalid controls</var> be an initially empty list of
   elements.</p></li><li>
    <p>For each element <var>field</var> in <var>invalid controls</var>, if any, in <a id="constraint-validation:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
    order</a>:</p>

    <ol><li><p>Let <var>notCanceled</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="constraint-validation:concept-event-fire" data-x-internal="concept-event-fire">firing an
     event</a> named <code id="constraint-validation:event-invalid"><a href="#event-invalid">invalid</a></code> at <var>field</var>, with the
     <code id="constraint-validation:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true.</p></li><li><p>If <var>notCanceled</var> is true, then add <var>field</var> to <var>unhandled invalid
     controls</var>.</p></li></ol>
   </li><li><p>Return a <i>negative</i> result with the list of elements in the <var>unhandled
   invalid controls</var> list.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>If a user agent is to <dfn id="interactively-validate-the-constraints">interactively validate the constraints</dfn> of <code id="constraint-validation:the-form-element-2"><a href="#the-form-element">form</a></code>
  element <var>form</var>, then the user agent must run the following steps:</p>

  <ol><li><p><a href="#statically-validate-the-constraints" id="constraint-validation:statically-validate-the-constraints">Statically validate the constraints</a> of <var>form</var>, and let
   <var>unhandled invalid controls</var> be the list of elements returned if the result was
   <i>negative</i>.</p></li><li><p>If the result was <i>positive</i>, then return that result.</p></li><li>
    <p>Report the problems with the constraints of at least one of the elements given in
    <var>unhandled invalid controls</var> to the user.</p>

    <ul><li><p>User agents may focus one of those elements in the process, by running the
     <a href="#focusing-steps" id="constraint-validation:focusing-steps">focusing steps</a> for that element, and may change the scrolling position of the
     document, or perform some other action that brings the element to the user's attention. For
     elements that are <a href="#form-associated-custom-element" id="constraint-validation:form-associated-custom-element">form-associated custom
     elements</a>, user agents should use their <a href="#face-validation-anchor" id="constraint-validation:face-validation-anchor">validation
     anchor</a> instead, for the purposes of these actions.</p></li><li><p>User agents may report more than one constraint violation.</p></li><li><p>User agents may coalesce related constraint violation reports if appropriate (e.g. if
     multiple radio buttons in a <a href="#radio-button-group" id="constraint-validation:radio-button-group">group</a> are marked as
     required, only one error need be reported).</p></li><li><p>If one of the controls is not <a href="#being-rendered" id="constraint-validation:being-rendered">being rendered</a> (e.g. it has the <code id="constraint-validation:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute set), then user agents may report a script
     error.</p></li></ul>
   </li><li><p>Return a <i>negative</i> result.</p></li></ol>
  </div>

  



  <h5 id="the-constraint-validation-api"><span class="secno">4.10.21.3</span> The <dfn>constraint validation API</dfn><a href="#the-constraint-validation-api" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-cva-willvalidate" id="dom-cva-willvalidate-dev">willValidate</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/willValidate" title="The willValidate read-only property of the HTMLObjectElement interface returns a boolean value that indicates whether the element is a candidate for constraint validation. Always false for HTMLObjectElement objects.">HTMLObjectElement/willValidate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns true if the element will be validated when the form is submitted; false
    otherwise.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-cva-setcustomvalidity" id="dom-cva-setcustomvalidity-dev">setCustomValidity</a>(<var>message</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity" title="The setCustomValidity() method of the HTMLObjectElement interface sets a custom validity message for the element.">HTMLObjectElement/setCustomValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/setCustomValidity" title="The HTMLSelectElement.setCustomValidity() method sets the custom validity message for the selection element to the specified message. Use the empty string to indicate that the element does not have a custom validity error.">HTMLSelectElement/setCustomValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Sets a custom error, so that the element would fail to validate. The given message is the
    message to be shown to the user when reporting the problem to the user.</p>

    <p>If the argument is the empty string, clears the custom error.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity">validity</a>.<a href="#dom-validitystate-valuemissing" id="dom-validitystate-valuemissing-dev">valueMissing</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/valueMissing" title="The read-only valueMissing property of a ValidityState object indicates if a required control, such as an <input>, <select>, or <textarea>, has an empty value.">ValidityState/valueMissing</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns true if the element has no value but is a required field; false
   otherwise.</p></dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-2">validity</a>.<a href="#dom-validitystate-typemismatch" id="dom-validitystate-typemismatch-dev">typeMismatch</a></code></dt><dd><p>Returns true if the element's value is not in the correct syntax; false
   otherwise.</p></dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-3">validity</a>.<a href="#dom-validitystate-patternmismatch" id="dom-validitystate-patternmismatch-dev">patternMismatch</a></code></dt><dd><p>Returns true if the element's value doesn't match the provided pattern; false
   otherwise.</p></dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-4">validity</a>.<a href="#dom-validitystate-toolong" id="dom-validitystate-toolong-dev">tooLong</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/tooLong" title="The read-only tooLong property of a ValidityState object indicates if the value of an <input> or <textarea>, after having been edited by the user, exceeds the maximum code-unit length established by the element's maxlength attribute.">ValidityState/tooLong</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>64+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns true if the element's value is longer than the provided maximum length; false
    otherwise.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-5">validity</a>.<a href="#dom-validitystate-tooshort" id="dom-validitystate-tooshort-dev">tooShort</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/tooShort" title="The read-only tooShort property of a ValidityState object indicates if the value of an <input>, <button>, <select>, <output>, <fieldset> or <textarea>, after having been edited by the user, is less than the minimum code-unit length established by the element's minlength attribute.">ValidityState/tooShort</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>51+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>40+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>64+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>67+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns true if the element's value, if it is not the empty string, is shorter than the
    provided minimum length; false otherwise.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-6">validity</a>.<a href="#dom-validitystate-rangeunderflow" id="dom-validitystate-rangeunderflow-dev">rangeUnderflow</a></code></dt><dd><p>Returns true if the element's value is lower than the provided minimum; false
   otherwise.</p></dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-7">validity</a>.<a href="#dom-validitystate-rangeoverflow" id="dom-validitystate-rangeoverflow-dev">rangeOverflow</a></code></dt><dd><p>Returns true if the element's value is higher than the provided maximum; false
   otherwise.</p></dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-8">validity</a>.<a href="#dom-validitystate-stepmismatch" id="dom-validitystate-stepmismatch-dev">stepMismatch</a></code></dt><dd><p>Returns true if the element's value doesn't fit the rules given by the <code id="the-constraint-validation-api:attr-input-step"><a href="#attr-input-step">step</a></code> attribute; false otherwise.</p></dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-9">validity</a>.<a href="#dom-validitystate-badinput" id="dom-validitystate-badinput-dev">badInput</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/badInput" title="The read-only badInput property of a ValidityState object indicates if the user has provided input that the browser is unable to convert. For example, if you have a number input element whose content is a string.">ValidityState/badInput</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>25+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>64+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns true if the user has provided input in the user interface that the user agent is
    unable to convert to a value; false otherwise.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-10">validity</a>.<a href="#dom-validitystate-customerror" id="dom-validitystate-customerror-dev">customError</a></code></dt><dd><p>Returns true if the element has a custom error; false otherwise.</p></dd><dt><code><var>element</var>.<a href="#dom-cva-validity" id="the-constraint-validation-api:dom-cva-validity-11">validity</a>.<a href="#dom-validitystate-valid" id="dom-validitystate-valid-dev">valid</a></code></dt><dd><p>Returns true if the element's value has no validity problems; false otherwise.</p></dd><dt><code><var>valid</var> = <var>element</var>.<a href="#dom-cva-checkvalidity" id="dom-cva-checkvalidity-dev">checkValidity</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity" title="The HTMLInputElement.checkValidity() method returns a boolean value which indicates validity of the value of the element. If the value is invalid, this method also fires the invalid event on the element.">HTMLInputElement/checkValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/checkValidity" title="The checkValidity() method of the HTMLObjectElement interface returns a boolean value that always is true, because object objects are never candidates for constraint validation.">HTMLObjectElement/checkValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/checkValidity" title="The HTMLSelectElement.checkValidity() method checks whether the element has any constraints and whether it satisfies them. If the element fails its constraints, the browser fires a cancelable invalid event at the element, and then returns false.">HTMLSelectElement/checkValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Returns true if the element's value has no validity problems; false otherwise. Fires an
   <code id="the-constraint-validation-api:event-invalid"><a href="#event-invalid">invalid</a></code> event at the element in the latter case.</p></dd><dt><code><var>valid</var> = <var>element</var>.<a href="#dom-cva-reportvalidity" id="dom-cva-reportvalidity-dev">reportValidity</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reportValidity" title="The HTMLFormElement.reportValidity() method returns true if the element's child controls satisfy their validation constraints. When false is returned, cancelable invalid events are fired for each invalid child and validation problems are reported to the user.">HTMLFormElement/reportValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>40+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity" title="The reportValidity() method of the HTMLInputElement interface performs the same validity checking steps as the checkValidity() method. If the value is invalid, this method also fires the invalid event on the element, and (if the event isn't canceled) reports the problem to the user.">HTMLInputElement/reportValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>40+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>64+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns true if the element's value has no validity problems; otherwise, returns false, fires
    an <code id="the-constraint-validation-api:event-invalid-2"><a href="#event-invalid">invalid</a></code> event at the element, and (if the event isn't
    canceled) reports the problem to the user.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-cva-validationmessage" id="dom-cva-validationmessage-dev">validationMessage</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validationMessage" title="The validationMessage read-only property of the HTMLObjectElement interface returns a string representing a localized message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation (willValidate is false), or it satisfies its constraints.">HTMLObjectElement/validationMessage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the error message that would be shown to the user if the element was to be checked
    for validity.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLObjectElement,HTMLInputElement,HTMLButtonElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOutputElement,HTMLFieldSetElement" id="dom-cva-willvalidate" data-dfn-type="attribute"><code>willValidate</code></dfn> attribute's getter must return true, if
  this element is a <a href="#candidate-for-constraint-validation" id="the-constraint-validation-api:candidate-for-constraint-validation">candidate for constraint validation</a>, and false otherwise (i.e.,
  false if any conditions are <a href="#barred-from-constraint-validation" id="the-constraint-validation-api:barred-from-constraint-validation">barring it from
  constraint validation</a>).</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate" title="The willValidate read-only property of the ElementInternals interface returns true if the element is a submittable element that is a candidate for constraint validation.">ElementInternals/willValidate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-willvalidate" data-dfn-type="attribute"><code>willValidate</code></dfn> attribute of
  <code id="the-constraint-validation-api:elementinternals"><a href="#elementinternals">ElementInternals</a></code> interface, on getting, must throw a
  <a id="the-constraint-validation-api:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="the-constraint-validation-api:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the <a href="#internals-target" id="the-constraint-validation-api:internals-target">target element</a> is not a <a href="#form-associated-custom-element" id="the-constraint-validation-api:form-associated-custom-element">form-associated custom
  element</a>. Otherwise, it must return true if the <a href="#internals-target" id="the-constraint-validation-api:internals-target-2">target
  element</a> is a <a href="#candidate-for-constraint-validation" id="the-constraint-validation-api:candidate-for-constraint-validation-2">candidate for constraint validation</a>, and false otherwise.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity" title="The HTMLInputElement.setCustomValidity() method sets a custom validity message for the element.">HTMLInputElement/setCustomValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLObjectElement,HTMLInputElement,HTMLButtonElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOutputElement,HTMLFieldSetElement" id="dom-cva-setcustomvalidity" data-dfn-type="method"><code>setCustomValidity(<var>error</var>)</code></dfn> method steps
  are:</p>

  <ol><li><p>Set <var>error</var> to the result of <a href="https://infra.spec.whatwg.org/#normalize-newlines" id="the-constraint-validation-api:normalize-newlines" data-x-internal="normalize-newlines">normalizing
   newlines</a> given <var>error</var>.</p></li><li><p>Set the <a href="#custom-validity-error-message" id="the-constraint-validation-api:custom-validity-error-message">custom validity error message</a> to <var>error</var>.</p></li></ol>
  </div>

  

  <div class="example">

   <p>In the following example, a script checks the value of a form control each time it is edited,
   and whenever it is not a valid value, uses the <code id="the-constraint-validation-api:dom-cva-setcustomvalidity"><a href="#dom-cva-setcustomvalidity">setCustomValidity()</a></code> method to set an appropriate
   message.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Feeling: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">f</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">oninput</c-><c- o="">=</c-><c- s="">"check(this)"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">function</c-> check<c- p="">(</c->input<c- p="">)</c-> <c- p="">{</c->
   <c- k="">if</c-> <c- p="">(</c->input<c- p="">.</c->value <c- o="">==</c-> <c- u="">"good"</c-> <c- o="">||</c->
       input<c- p="">.</c->value <c- o="">==</c-> <c- u="">"fine"</c-> <c- o="">||</c->
       input<c- p="">.</c->value <c- o="">==</c-> <c- u="">"tired"</c-><c- p="">)</c-> <c- p="">{</c->
     input<c- p="">.</c->setCustomValidity<c- p="">(</c-><c- t="">'"'</c-> <c- o="">+</c-> input<c- p="">.</c->value <c- o="">+</c-> <c- t="">'" is not a feeling.'</c-><c- p="">);</c->
   <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
     <c- c1="">// input is fine -- reset the error message</c->
     input<c- p="">.</c->setCustomValidity<c- p="">(</c-><c- t="">''</c-><c- p="">);</c->
   <c- p="">}</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity" title="The validity read-only property of the HTMLObjectElement interface returns a ValidityState with the validity states that this element is in.">HTMLObjectElement/validity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLObjectElement,HTMLInputElement,HTMLButtonElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOutputElement,HTMLFieldSetElement" id="dom-cva-validity" data-dfn-type="attribute"><code>validity</code></dfn> attribute's getter must return a
  <code id="the-constraint-validation-api:validitystate"><a href="#validitystate">ValidityState</a></code> object that represents the <a href="#validity-states" id="the-constraint-validation-api:validity-states">validity states</a> of this
  element. This object is <a href="#live" id="the-constraint-validation-api:live">live</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validity" title="The validity read-only property of the ElementInternals interface returns a ValidityState object which represents the different validity states the element can be in, with respect to constraint validation.">ElementInternals/validity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-validity" data-dfn-type="attribute"><code>validity</code></dfn> attribute of
  <code id="the-constraint-validation-api:elementinternals-2"><a href="#elementinternals">ElementInternals</a></code> interface, on getting, must throw a
  <a id="the-constraint-validation-api:notsupportederror-2" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="the-constraint-validation-api:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the <a href="#internals-target" id="the-constraint-validation-api:internals-target-3">target element</a> is not a <a href="#form-associated-custom-element" id="the-constraint-validation-api:form-associated-custom-element-2">form-associated custom
  element</a>. Otherwise, it must return a <code id="the-constraint-validation-api:validitystate-2"><a href="#validitystate">ValidityState</a></code> object that represents the
  <a href="#validity-states" id="the-constraint-validation-api:validity-states-2">validity states</a> of the <a href="#internals-target" id="the-constraint-validation-api:internals-target-4">target element</a>. This
  object is <a href="#live" id="the-constraint-validation-api:live-2">live</a>.</p>
  </div>

<pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="validitystate" data-dfn-type="interface"><c- g="">ValidityState</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-valuemissing" id="the-constraint-validation-api:dom-validitystate-valuemissing"><c- g="">valueMissing</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-typemismatch" id="the-constraint-validation-api:dom-validitystate-typemismatch"><c- g="">typeMismatch</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-patternmismatch" id="the-constraint-validation-api:dom-validitystate-patternmismatch"><c- g="">patternMismatch</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-toolong" id="the-constraint-validation-api:dom-validitystate-toolong"><c- g="">tooLong</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-tooshort" id="the-constraint-validation-api:dom-validitystate-tooshort"><c- g="">tooShort</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-rangeunderflow" id="the-constraint-validation-api:dom-validitystate-rangeunderflow"><c- g="">rangeUnderflow</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-rangeoverflow" id="the-constraint-validation-api:dom-validitystate-rangeoverflow"><c- g="">rangeOverflow</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-stepmismatch" id="the-constraint-validation-api:dom-validitystate-stepmismatch"><c- g="">stepMismatch</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-badinput" id="the-constraint-validation-api:dom-validitystate-badinput"><c- g="">badInput</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-customerror" id="the-constraint-validation-api:dom-validitystate-customerror"><c- g="">customError</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-validitystate-valid" id="the-constraint-validation-api:dom-validitystate-valid"><c- g="">valid</c-></a>;
};</code></pre>

  <div data-algorithm="">
  <p>A <code id="the-constraint-validation-api:validitystate-3"><a href="#validitystate">ValidityState</a></code> object has the following attributes. On getting, they must return
  true if the corresponding condition given in the following list is true, and false otherwise.</p>

  <dl><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-valuemissing" data-dfn-type="attribute"><code>valueMissing</code></dfn></dt><dd> <p>The control is <a href="#suffering-from-being-missing" id="the-constraint-validation-api:suffering-from-being-missing">suffering from being missing</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-typemismatch" data-dfn-type="attribute"><code>typeMismatch</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/typeMismatch" title="The read-only typeMismatch property of a ValidityState object indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's type attribute.">ValidityState/typeMismatch</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd> <p>The control is <a href="#suffering-from-a-type-mismatch" id="the-constraint-validation-api:suffering-from-a-type-mismatch">suffering from a type mismatch</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-patternmismatch" data-dfn-type="attribute"><code>patternMismatch</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/patternMismatch" title="The read-only patternMismatch property of a ValidityState object indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's pattern attribute.">ValidityState/patternMismatch</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd> <p>The control is <a href="#suffering-from-a-pattern-mismatch" id="the-constraint-validation-api:suffering-from-a-pattern-mismatch">suffering from a pattern mismatch</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-toolong" data-dfn-type="attribute"><code>tooLong</code></dfn></dt><dd> <p>The control is <a href="#suffering-from-being-too-long" id="the-constraint-validation-api:suffering-from-being-too-long">suffering from being too long</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-tooshort" data-dfn-type="attribute"><code>tooShort</code></dfn></dt><dd> <p>The control is <a href="#suffering-from-being-too-short" id="the-constraint-validation-api:suffering-from-being-too-short">suffering from being too short</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-rangeunderflow" data-dfn-type="attribute"><code>rangeUnderflow</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/rangeUnderflow" title="The read-only rangeUnderflow property of a ValidityState object indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's min attribute.">ValidityState/rangeUnderflow</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd> <p>The control is <a href="#suffering-from-an-underflow" id="the-constraint-validation-api:suffering-from-an-underflow">suffering from an underflow</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-rangeoverflow" data-dfn-type="attribute"><code>rangeOverflow</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/rangeOverflow" title="The read-only rangeOverflow property of a ValidityState object indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's max attribute.">ValidityState/rangeOverflow</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd> <p>The control is <a href="#suffering-from-an-overflow" id="the-constraint-validation-api:suffering-from-an-overflow">suffering from an overflow</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-stepmismatch" data-dfn-type="attribute"><code>stepMismatch</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/stepMismatch" title="The read-only stepMismatch property of a ValidityState object indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's step attribute.">ValidityState/stepMismatch</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd> <p>The control is <a href="#suffering-from-a-step-mismatch" id="the-constraint-validation-api:suffering-from-a-step-mismatch">suffering from a step mismatch</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-badinput" data-dfn-type="attribute"><code>badInput</code></dfn></dt><dd> <p>The control is <a href="#suffering-from-bad-input" id="the-constraint-validation-api:suffering-from-bad-input">suffering from bad input</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-customerror" data-dfn-type="attribute"><code>customError</code></dfn></dt><dd> <p>The control is <a href="#suffering-from-a-custom-error" id="the-constraint-validation-api:suffering-from-a-custom-error">suffering from a custom error</a>.</p> </dd><dt><dfn data-dfn-for="ValidityState" id="dom-validitystate-valid" data-dfn-type="attribute"><code>valid</code></dfn></dt><dd> <p>None of the other conditions are true.</p> </dd></dl>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="check-validity-steps">check validity steps</dfn> for an element <var>element</var> are:</p>

  <ol><li>
    <p>If <var>element</var> is a <a href="#candidate-for-constraint-validation" id="the-constraint-validation-api:candidate-for-constraint-validation-3">candidate for constraint validation</a> and does not
    <a href="#concept-fv-valid" id="the-constraint-validation-api:concept-fv-valid">satisfy its constraints</a>, then:</p>

    <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-constraint-validation-api:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-constraint-validation-api:event-invalid-3"><a href="#event-invalid">invalid</a></code> at <var>element</var>, with the <code id="the-constraint-validation-api:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true (though canceling
     has no effect).</p></li><li><p>Return false.</p></li></ol>

   </li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLObjectElement,HTMLInputElement,HTMLButtonElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOutputElement,HTMLFieldSetElement" id="dom-cva-checkvalidity" data-dfn-type="method"><code>checkValidity()</code></dfn> method, when invoked, must run the
  <a href="#check-validity-steps" id="the-constraint-validation-api:check-validity-steps">check validity steps</a> on this element.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity" title="The checkValidity() method of the ElementInternals interface checks if the element meets any constraint validation rules applied to it.">ElementInternals/checkValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-checkvalidity" data-dfn-type="method"><code>checkValidity()</code></dfn> method of the
  <code id="the-constraint-validation-api:elementinternals-3"><a href="#elementinternals">ElementInternals</a></code> interface must run these steps:</p>

  <ol><li><p>Let <var>element</var> be this <code id="the-constraint-validation-api:elementinternals-4"><a href="#elementinternals">ElementInternals</a></code>'s <a href="#internals-target" id="the-constraint-validation-api:internals-target-5">target element</a>.</p></li><li><p>If <var>element</var> is not a <a href="#form-associated-custom-element" id="the-constraint-validation-api:form-associated-custom-element-3">form-associated custom element</a>, then throw a
   <a id="the-constraint-validation-api:notsupportederror-3" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="the-constraint-validation-api:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Run the <a href="#check-validity-steps" id="the-constraint-validation-api:check-validity-steps-2">check validity steps</a> on <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="report-validity-steps">report validity steps</dfn> for an element <var>element</var> are:</p>

  <ol><li>
    <p>If <var>element</var> is a <a href="#candidate-for-constraint-validation" id="the-constraint-validation-api:candidate-for-constraint-validation-4">candidate for constraint validation</a> and does not
    <a href="#concept-fv-valid" id="the-constraint-validation-api:concept-fv-valid-2">satisfy its constraints</a>, then:

    </p><ol><li><p>Let <var>report</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-constraint-validation-api:concept-event-fire-2" data-x-internal="concept-event-fire">firing an
     event</a> named <code id="the-constraint-validation-api:event-invalid-4"><a href="#event-invalid">invalid</a></code> at <var>element</var>, with the
     <code id="the-constraint-validation-api:dom-event-cancelable-2"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true.</p></li><li><p>If <var>report</var> is true, then report the problems with the constraints of this
     element to the user. When reporting the problem with the constraints to the user, the user
     agent may run the <a href="#focusing-steps" id="the-constraint-validation-api:focusing-steps">focusing steps</a> for <var>element</var>, and may change the
     scrolling position of the document, or perform some other action that brings <var>element</var>
     to the user's attention. User agents may report more than one constraint violation, if
     <var>element</var> suffers from multiple problems at once.</p>

     </li><li><p>Return false.</p></li></ol>

   </li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLObjectElement,HTMLInputElement,HTMLButtonElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOutputElement,HTMLFieldSetElement" id="dom-cva-reportvalidity" data-dfn-type="method"><code>reportValidity()</code></dfn> method, when invoked, must run the
  <a href="#report-validity-steps" id="the-constraint-validation-api:report-validity-steps">report validity steps</a> on this element.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity" title="The reportValidity() method of the ElementInternals interface checks if the element meets any constraint validation rules applied to it.">ElementInternals/reportValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-reportvalidity" data-dfn-type="method"><code>reportValidity()</code></dfn> method of the
  <code id="the-constraint-validation-api:elementinternals-5"><a href="#elementinternals">ElementInternals</a></code> interface must run these steps:</p>

  <ol><li><p>Let <var>element</var> be this <code id="the-constraint-validation-api:elementinternals-6"><a href="#elementinternals">ElementInternals</a></code>'s <a href="#internals-target" id="the-constraint-validation-api:internals-target-6">target element</a>.</p></li><li><p>If <var>element</var> is not a <a href="#form-associated-custom-element" id="the-constraint-validation-api:form-associated-custom-element-4">form-associated custom element</a>, then throw a
   <a id="the-constraint-validation-api:notsupportederror-4" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="the-constraint-validation-api:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Run the <a href="#report-validity-steps" id="the-constraint-validation-api:report-validity-steps-2">report validity steps</a> on <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLObjectElement,HTMLInputElement,HTMLButtonElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOutputElement,HTMLFieldSetElement" id="dom-cva-validationmessage" data-dfn-type="attribute"><code>validationMessage</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>If this element is not a <a href="#candidate-for-constraint-validation" id="the-constraint-validation-api:candidate-for-constraint-validation-5">candidate for constraint validation</a> or if this
   element <a href="#concept-fv-valid" id="the-constraint-validation-api:concept-fv-valid-3">satisfies its constraints</a>, then return the empty
   string.</p></li><li><p>Return a suitably localized message that the user agent would show the user if this were
   the only form control with a validity constraint problem. If the user agent would not actually
   show a textual message in such a situation (e.g., it would show a graphical cue instead), then
   return a suitably localized message that expresses (one or more of) the validity constraint(s)
   that the control does not satisfy. If the element is a <a href="#candidate-for-constraint-validation" id="the-constraint-validation-api:candidate-for-constraint-validation-6">candidate for constraint
   validation</a> and is <a href="#suffering-from-a-custom-error" id="the-constraint-validation-api:suffering-from-a-custom-error-2">suffering from a custom error</a>, then the
   <a href="#custom-validity-error-message" id="the-constraint-validation-api:custom-validity-error-message-2">custom validity error message</a> should be present in the return value.</p></li></ol>
  </div>

  


  <h5 id="security-forms"><span class="secno">4.10.21.4</span> Security<a href="#security-forms" class="self-link"></a></h5>

  <p id="security-0">Servers should not rely on client-side validation. Client-side validation can
  be intentionally bypassed by hostile users, and unintentionally bypassed by users of older user
  agents or automated tools that do not implement these features. The constraint validation features
  are only intended to improve the user experience, not to provide any kind of security
  mechanism.</p>




  <h4 id="form-submission-2"><span class="secno">4.10.22</span> <dfn id="form-submission">Form submission</dfn><a href="#form-submission-2" class="self-link"></a></h4>

  

  <h5 id="introduction-5"><span class="secno">4.10.22.1</span> Introduction<a href="#introduction-5" class="self-link"></a></h5>

  

  <p><i>This section is non-normative.</i></p>

  <p>When a form is submitted, the data in the form is converted into the structure specified by the
  <a href="#concept-fs-enctype" id="introduction-5:concept-fs-enctype">enctype</a>, and then sent to the destination specified by the
  <a href="#concept-fs-action" id="introduction-5:concept-fs-action">action</a> using the given <a href="#concept-fs-method" id="introduction-5:concept-fs-method">method</a>.</p>

  <p>For example, take the following form:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"/find.cgi"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">get</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">t</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">search</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">q</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p>If the user types in "cats" in the first field and "fur" in the second, and then hits the
  submit button, then the user agent will load <code>/find.cgi?t=cats&amp;q=fur</code>.</p>

  <p>On the other hand, consider this form:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"/find.cgi"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">post</c-> <c- e="">enctype</c-><c- o="">=</c-><c- s="">"multipart/form-data"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">t</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">search</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">q</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  <p>Given the same user input, the result on submission is quite different: the user agent instead
  does an HTTP POST to the given URL, with as the entity body something like the following text:</p>

  <pre>------kYFrd4jNJEgCervE
Content-Disposition: form-data; name="t"

cats
------kYFrd4jNJEgCervE
Content-Disposition: form-data; name="q"

fur
------kYFrd4jNJEgCervE--</pre>



  

  <h5 id="implicit-submission"><span class="secno">4.10.22.2</span> Implicit submission<a href="#implicit-submission" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A <code id="implicit-submission:the-form-element"><a href="#the-form-element">form</a></code> element's <dfn id="default-button">default button</dfn> is the first <a href="#concept-submit-button" id="implicit-submission:concept-submit-button">submit button</a> in <a id="implicit-submission:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> whose <a href="#form-owner" id="implicit-submission:form-owner">form
  owner</a> is that <code id="implicit-submission:the-form-element-2"><a href="#the-form-element">form</a></code> element.</p>
  </div>

  <div data-algorithm="">
  <p>If the user agent supports letting the user submit a form implicitly (for example, on some
  platforms hitting the "enter" key while a text control is <a href="#focused" id="implicit-submission:focused">focused</a> implicitly submits
  the form), then doing so for a form, whose <a href="#default-button" id="implicit-submission:default-button">default button</a> has <a id="implicit-submission:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation
  behavior</a> and is not <a href="#concept-fe-disabled" id="implicit-submission:concept-fe-disabled">disabled</a>, must cause the user
  agent to <a href="#fire-a-click-event" id="implicit-submission:fire-a-click-event">fire a <code>click</code> event</a> at that <a href="#default-button" id="implicit-submission:default-button-2">default
  button</a>.</p>
  </div>

  <p class="note">There are pages on the web that are only usable if there is a way to implicitly
  submit forms, so user agents are strongly encouraged to support this.</p>

  <div data-algorithm="">
  <p>If the form has
  no <a href="#concept-submit-button" id="implicit-submission:concept-submit-button-2">submit button</a>, then the implicit submission
  mechanism must perform the following steps:

  </p><ol><li><p>If the form has more than one <a href="#field-that-blocks-implicit-submission" id="implicit-submission:field-that-blocks-implicit-submission">field that blocks implicit submission</a>, then
   return.</p></li><li><p><a href="#concept-form-submit" id="implicit-submission:concept-form-submit">Submit</a> the <code id="implicit-submission:the-form-element-3"><a href="#the-form-element">form</a></code> element from the
   <code id="implicit-submission:the-form-element-4"><a href="#the-form-element">form</a></code> element itself with <i id="implicit-submission:submit-user-involvement"><a href="#submit-user-involvement">userInvolvement</a></i> set
   to "<code id="implicit-submission:uni-activation"><a href="#uni-activation">activation</a></code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>For the purpose of the previous paragraph, an element is a <dfn id="field-that-blocks-implicit-submission">field that blocks implicit
  submission</dfn> of a <code id="implicit-submission:the-form-element-5"><a href="#the-form-element">form</a></code> element if it is an <code id="implicit-submission:the-input-element"><a href="#the-input-element">input</a></code> element whose
  <a href="#form-owner" id="implicit-submission:form-owner-2">form owner</a> is that <code id="implicit-submission:the-form-element-6"><a href="#the-form-element">form</a></code> element and whose <code id="implicit-submission:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in one of the following states:
  <a href="#text-(type=text)-state-and-search-state-(type=search)" id="implicit-submission:text-(type=text)-state-and-search-state-(type=search)">Text</a>,
  <a href="#text-(type=text)-state-and-search-state-(type=search)" id="implicit-submission:text-(type=text)-state-and-search-state-(type=search)-2">Search</a>,
  <a href="#telephone-state-(type=tel)" id="implicit-submission:telephone-state-(type=tel)">Telephone</a>,
  <a href="#url-state-(type=url)" id="implicit-submission:url-state-(type=url)">URL</a>,
  <a href="#email-state-(type=email)" id="implicit-submission:email-state-(type=email)">Email</a>,
  <a href="#password-state-(type=password)" id="implicit-submission:password-state-(type=password)">Password</a>,
  <a href="#date-state-(type=date)" id="implicit-submission:date-state-(type=date)">Date</a>,
  <a href="#month-state-(type=month)" id="implicit-submission:month-state-(type=month)">Month</a>,
  <a href="#week-state-(type=week)" id="implicit-submission:week-state-(type=week)">Week</a>,
  <a href="#time-state-(type=time)" id="implicit-submission:time-state-(type=time)">Time</a>,
  <a href="#local-date-and-time-state-(type=datetime-local)" id="implicit-submission:local-date-and-time-state-(type=datetime-local)">Local Date and Time</a>,
  <a href="#number-state-(type=number)" id="implicit-submission:number-state-(type=number)">Number</a>
  </p>
  </div>

  


  

  <h5 id="form-submission-algorithm"><span class="secno">4.10.22.3</span> Form submission algorithm<a href="#form-submission-algorithm" class="self-link"></a></h5>

  <p>Each <code id="form-submission-algorithm:the-form-element"><a href="#the-form-element">form</a></code> element has a <dfn id="constructing-entry-list">constructing entry list</dfn> boolean, initially
  false.</p>

  <p>Each <code id="form-submission-algorithm:the-form-element-2"><a href="#the-form-element">form</a></code> element has a <dfn id="firing-submission-events">firing submission events</dfn> boolean, initially
  false.</p>

  <div data-algorithm="">
  <p>To <dfn id="concept-form-submit">submit</dfn> a <code id="form-submission-algorithm:the-form-element-3"><a href="#the-form-element">form</a></code> element <var>form</var>
  from an element <var>submitter</var> (typically a button), given an optional boolean <dfn id="submit-subbmitted-from-method"><var>submitted from <code>submit()</code> method</var></dfn> (default false) and an optional
  <a href="#user-navigation-involvement" id="form-submission-algorithm:user-navigation-involvement">user navigation involvement</a> <dfn id="submit-user-involvement"><var>userInvolvement</var></dfn> (default "<code id="form-submission-algorithm:uni-none"><a href="#uni-none">none</a></code>"):</p>

  <ol><li><p>If <var>form</var> <a href="#cannot-navigate" id="form-submission-algorithm:cannot-navigate">cannot navigate</a>, then return.</p></li><li><p>If <var>form</var>'s <a href="#constructing-entry-list" id="form-submission-algorithm:constructing-entry-list">constructing entry list</a> is true, then return.</p></li><li><p>Let <var>form document</var> be <var>form</var>'s <a id="form-submission-algorithm:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li id="sandboxSubmitBlocked"><p>If <var>form document</var>'s <a href="#active-sandboxing-flag-set" id="form-submission-algorithm:active-sandboxing-flag-set">active sandboxing flag
   set</a> has its <a href="#sandboxed-forms-browsing-context-flag" id="form-submission-algorithm:sandboxed-forms-browsing-context-flag">sandboxed forms browsing context flag</a> set, then return.</p></li><li>
    <p>If <var>submitted from <code id="form-submission-algorithm:dom-form-submit"><a href="#dom-form-submit">submit()</a></code> method</var> is false,
    then:</p>

    <ol><li><p>If <var>form</var>'s <a href="#firing-submission-events" id="form-submission-algorithm:firing-submission-events">firing submission events</a> is true, then
     return.</p></li><li><p>Set <var>form</var>'s <a href="#firing-submission-events" id="form-submission-algorithm:firing-submission-events-2">firing submission events</a> to true.</p></li><li><p>For each element <var>field</var> in the list of
     <a href="#category-submit" id="form-submission-algorithm:category-submit">submittable elements</a> whose <a href="#form-owner" id="form-submission-algorithm:form-owner">form owner</a> is
     <var>form</var>, set <var>field</var>'s <a href="#user-validity" id="form-submission-algorithm:user-validity">user validity</a> to true.

     </p></li><li>
      <p>If the <var>submitter</var> element's <a href="#concept-fs-novalidate" id="form-submission-algorithm:concept-fs-novalidate">no-validate
      state</a> is false, then <a href="#interactively-validate-the-constraints" id="form-submission-algorithm:interactively-validate-the-constraints">interactively validate the constraints</a> of
      <var>form</var> and examine the result. If the result is negative (i.e., the constraint
      validation concluded that there were invalid fields and probably informed the user of this),
      then:</p>

      <ol><li><p>Set <var>form</var>'s <a href="#firing-submission-events" id="form-submission-algorithm:firing-submission-events-3">firing submission events</a> to false.</p></li><li><p>Return.</p></li></ol>
     </li><li><p>Let <var>submitterButton</var> be null if <var>submitter</var> is <var>form</var>.
     Otherwise, let <var>submitterButton</var> be <var>submitter</var>.</p></li><li><p>Let <var>shouldContinue</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="form-submission-algorithm:concept-event-fire" data-x-internal="concept-event-fire">firing an
     event</a> named <code id="form-submission-algorithm:event-submit"><a href="#event-submit">submit</a></code> at <var>form</var> using
     <code id="form-submission-algorithm:submitevent"><a href="#submitevent">SubmitEvent</a></code>, with the <code id="form-submission-algorithm:dom-submitevent-submitter"><a href="#dom-submitevent-submitter">submitter</a></code>
     attribute initialized to <var>submitterButton</var>, the <code id="form-submission-algorithm:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to true, and the <code id="form-submission-algorithm:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true.</p></li><li><p>Set <var>form</var>'s <a href="#firing-submission-events" id="form-submission-algorithm:firing-submission-events-4">firing submission events</a> to false.</p></li><li><p>If <var>shouldContinue</var> is false, then return.</p></li><li>
      <p>If <var>form</var> <a href="#cannot-navigate" id="form-submission-algorithm:cannot-navigate-2">cannot navigate</a>, then return.</p>

      <p class="note"><a href="#cannot-navigate" id="form-submission-algorithm:cannot-navigate-3">Cannot navigate</a> is run again as dispatching the <code id="form-submission-algorithm:event-submit-2"><a href="#event-submit">submit</a></code> event could have changed the outcome.</p>
     </li></ol>
   </li><li><p>Let <var>encoding</var> be the result of <a href="#picking-an-encoding-for-the-form" id="form-submission-algorithm:picking-an-encoding-for-the-form">picking an encoding for the
   form</a>.</p>

   </li><li><p>Let <var>entry list</var> be the result of <a href="#constructing-the-form-data-set" id="form-submission-algorithm:constructing-the-form-data-set">constructing the entry list</a> with
   <var>form</var>, <var>submitter</var>, and <var>encoding</var>.</p></li><li><p><a id="form-submission-algorithm:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>entry list</var> is not null.</p></li><li>
    <p>If <var>form</var> <a href="#cannot-navigate" id="form-submission-algorithm:cannot-navigate-4">cannot navigate</a>, then return.</p>

    <p class="note"><a href="#cannot-navigate" id="form-submission-algorithm:cannot-navigate-5">Cannot navigate</a> is run again as dispatching the <code id="form-submission-algorithm:event-formdata"><a href="#event-formdata">formdata</a></code> event in <a href="#constructing-the-form-data-set" id="form-submission-algorithm:constructing-the-form-data-set-2">constructing the entry list</a>
    could have changed the outcome.</p>
   </li><li><p>Let <var>method</var> be the <var>submitter</var> element's <a href="#concept-fs-method" id="form-submission-algorithm:concept-fs-method">method</a>.</p></li><li>
    <p>If <var>method</var> is <a href="#attr-fs-method-dialog" id="form-submission-algorithm:attr-fs-method-dialog">dialog</a>, then:

    </p><ol><li><p>If <var>form</var> does not have an ancestor <code id="form-submission-algorithm:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> element, then
     return.</p></li><li><p>Let <var>subject</var> be <var>form</var>'s nearest ancestor <code id="form-submission-algorithm:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code>
     element.</p></li><li><p>Let <var>result</var> be null.</p></li><li>
      <p>If <var>submitter</var> is an <code id="form-submission-algorithm:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="form-submission-algorithm:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#image-button-state-(type=image)" id="form-submission-algorithm:image-button-state-(type=image)">Image Button</a> state, then:</p>

      <ol><li><p>Let (<var>x</var>, <var>y</var>) be the <a href="#concept-input-type-image-coordinate" id="form-submission-algorithm:concept-input-type-image-coordinate">selected coordinate</a>.</p></li><li><p>Set <var>result</var> to the concatenation of <var>x</var>, "<code>,</code>", and <var>y</var>.</p></li></ol>
     </li><li><p>Otherwise, if <var>submitter</var> is a <a href="#concept-submit-button" id="form-submission-algorithm:concept-submit-button">submit
     button</a>, then set <var>result</var> to <var>submitter</var>'s <a href="#concept-fe-optional-value" id="form-submission-algorithm:concept-fe-optional-value">optional value</a>.</p></li><li><p><a href="#close-the-dialog" id="form-submission-algorithm:close-the-dialog">Close the dialog</a> <var>subject</var> with <var>result</var> and
     null.</p></li><li><p>Return.</p></li></ol>
   </li><li><p>Let <var>action</var> be the <var>submitter</var> element's <a href="#concept-fs-action" id="form-submission-algorithm:concept-fs-action">action</a>.</p></li><li>
    <p>If <var>action</var> is the empty string, let <var>action</var> be the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="form-submission-algorithm:the-document's-address" data-x-internal="the-document's-address">URL</a> of the <var>form document</var>.</p>

    
   </li><li><p>Let <var>parsed action</var> be the result of <a href="#encoding-parsing-a-url" id="form-submission-algorithm:encoding-parsing-a-url">encoding-parsing a URL</a> given
   <var>action</var>, relative to <var>submitter</var>'s <a id="form-submission-algorithm:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>parsed action</var> is failure, then return.</p></li><li><p>Let <var>scheme</var> be the <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="form-submission-algorithm:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> of
   <var>parsed action</var>.</p></li><li><p>Let <var>enctype</var> be the <var>submitter</var> element's <a href="#concept-fs-enctype" id="form-submission-algorithm:concept-fs-enctype">enctype</a>.</p></li><li><p>Let <var>formTarget</var> be null.</p></li><li><p>If the <var>submitter</var> element is a <a href="#concept-submit-button" id="form-submission-algorithm:concept-submit-button-2">submit
   button</a> and it has a <code id="form-submission-algorithm:attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code> attribute, then
   set <var>formTarget</var> to the <code id="form-submission-algorithm:attr-fs-formtarget-2"><a href="#attr-fs-formtarget">formtarget</a></code> attribute
   value.</p></li><li><p>Let <var>target</var> be the result of <a href="#get-an-element's-target" id="form-submission-algorithm:get-an-element's-target">getting an
   element's target</a> given <var>submitter</var>'s <a href="#form-owner" id="form-submission-algorithm:form-owner-2">form owner</a> and
   <var>formTarget</var>.</p></li><li><p>Let <var>noopener</var> be the result of <a href="#get-an-element's-noopener" id="form-submission-algorithm:get-an-element's-noopener">getting
   an element's noopener</a> with <var>form</var>, <var>parsed action</var>, and
   <var>target</var>.</p></li><li><p>Let <var>targetNavigable</var> be the first return value of applying <a href="#the-rules-for-choosing-a-navigable" id="form-submission-algorithm:the-rules-for-choosing-a-navigable">the rules for
   choosing a navigable</a> given <var>target</var>, <var>form</var>'s <a href="#node-navigable" id="form-submission-algorithm:node-navigable">node
   navigable</a>, and <var>noopener</var>.</p></li><li><p>If <var>targetNavigable</var> is null, then return.</p></li><li><p>Let <var>historyHandling</var> be "<code id="form-submission-algorithm:navigationhistorybehavior-auto"><a href="#navigationhistorybehavior-auto">auto</a></code>".</p></li><li><p>If <var>form document</var> equals <var>targetNavigable</var>'s <a href="#nav-document" id="form-submission-algorithm:nav-document">active document</a>, and <var>form document</var> has not yet
   <a href="#completely-loaded" id="form-submission-algorithm:completely-loaded">completely loaded</a>, then set <var>historyHandling</var> to "<code id="form-submission-algorithm:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p></li><li>
    <p>Select the appropriate row in the table below based on <var>scheme</var> as given by the
    first cell of each row. Then, select the appropriate cell on that row based on <var>method</var>
    as given in the first cell of each column. Then, jump to the steps named in that cell and
    defined below the table.</p>

    <table><thead><tr><td>
      </td><th> <a href="#attr-fs-method-get" id="form-submission-algorithm:attr-fs-method-get">GET</a>
      </th><th> <a href="#attr-fs-method-post" id="form-submission-algorithm:attr-fs-method-post">POST</a>
     </th></tr></thead><tbody><tr><th> <code>http</code>
      </th><td> <a href="#submit-mutate-action" id="form-submission-algorithm:submit-mutate-action">Mutate action URL</a>
      </td><td> <a href="#submit-body" id="form-submission-algorithm:submit-body">Submit as entity body</a>
     </td></tr><tr><th> <code>https</code>
      </th><td> <a href="#submit-mutate-action" id="form-submission-algorithm:submit-mutate-action-2">Mutate action URL</a>
      </td><td> <a href="#submit-body" id="form-submission-algorithm:submit-body-2">Submit as entity body</a>
     </td></tr><tr><th> <code>ftp</code>
      </th><td> <a href="#submit-get-action" id="form-submission-algorithm:submit-get-action">Get action URL</a>
      </td><td> <a href="#submit-get-action" id="form-submission-algorithm:submit-get-action-2">Get action URL</a>
     </td></tr><tr><th> <code>javascript</code>
      </th><td> <a href="#submit-get-action" id="form-submission-algorithm:submit-get-action-3">Get action URL</a>
      </td><td> <a href="#submit-get-action" id="form-submission-algorithm:submit-get-action-4">Get action URL</a>
     </td></tr><tr><th> <code>data</code>
      </th><td> <a href="#submit-mutate-action" id="form-submission-algorithm:submit-mutate-action-3">Mutate action URL</a>
      </td><td> <a href="#submit-get-action" id="form-submission-algorithm:submit-get-action-5">Get action URL</a>
     </td></tr><tr><th> <code>mailto</code>
      </th><td> <a href="#submit-mailto-headers" id="form-submission-algorithm:submit-mailto-headers">Mail with headers</a>
      </td><td> <a href="#submit-mailto-body" id="form-submission-algorithm:submit-mailto-body">Mail as body</a>
    </td></tr></tbody></table>

    <p>If <var>scheme</var> is not one of those listed in this table, then the behavior is
    not defined by this specification. User agents should, in the absence of another specification
    defining this, act in a manner analogous to that defined in this specification for similar
    schemes.</p>

    <p>Each <code id="form-submission-algorithm:the-form-element-4"><a href="#the-form-element">form</a></code> element has a <dfn id="planned-navigation">planned navigation</dfn>, which is either null or a
    <a href="#concept-task" id="form-submission-algorithm:concept-task">task</a>; when the <code id="form-submission-algorithm:the-form-element-5"><a href="#the-form-element">form</a></code> is first created, its
    <a href="#planned-navigation" id="form-submission-algorithm:planned-navigation">planned navigation</a> must be set to null. In the behaviors described below, when the
    user agent is required to <dfn id="plan-to-navigate">plan to navigate</dfn> to a <a id="form-submission-algorithm:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var> given
    an optional <a href="#post-resource" id="form-submission-algorithm:post-resource">POST resource</a>-or-null <var>postResource</var> (default null), it must
    run the following steps:</p>

    <ol><li><p>Let <var>referrerPolicy</var> be the empty string.</p></li><li><p>If the <code id="form-submission-algorithm:the-form-element-6"><a href="#the-form-element">form</a></code> element's <a href="#linkTypes">link types</a> include the <code id="form-submission-algorithm:link-type-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code> keyword, then set <var>referrerPolicy</var> to "<code>no-referrer</code>".</p></li><li><p>If the <code id="form-submission-algorithm:the-form-element-7"><a href="#the-form-element">form</a></code> has a non-null <a href="#planned-navigation" id="form-submission-algorithm:planned-navigation-2">planned navigation</a>, remove it from
     its <a href="#task-queue" id="form-submission-algorithm:task-queue">task queue</a>.</p></li><li>
      <p><a href="#queue-an-element-task" id="form-submission-algorithm:queue-an-element-task">Queue an element task</a> on the <a href="#dom-manipulation-task-source" id="form-submission-algorithm:dom-manipulation-task-source">DOM manipulation task source</a> given
      the <code id="form-submission-algorithm:the-form-element-8"><a href="#the-form-element">form</a></code> element and the following steps:</p>

      <ol><li><p>Set the <code id="form-submission-algorithm:the-form-element-9"><a href="#the-form-element">form</a></code>'s <a href="#planned-navigation" id="form-submission-algorithm:planned-navigation-3">planned navigation</a> to null.</p></li><li><p><a href="#navigate" id="form-submission-algorithm:navigate">Navigate</a> <var>targetNavigable</var> to <var>url</var>
       using the <code id="form-submission-algorithm:the-form-element-10"><a href="#the-form-element">form</a></code> element's <a id="form-submission-algorithm:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, with <i id="form-submission-algorithm:navigation-hh"><a href="#navigation-hh">historyHandling</a></i> set to <var>historyHandling</var>, <i id="form-submission-algorithm:navigation-user-involvement"><a href="#navigation-user-involvement">userInvolvement</a></i> set to <var>userInvolvement</var>,
       <i id="form-submission-algorithm:navigation-source-element"><a href="#navigation-source-element">sourceElement</a></i> set to <var>submitter</var>,
       <i id="form-submission-algorithm:navigation-referrer-policy"><a href="#navigation-referrer-policy">referrerPolicy</a></i> set to <var>referrerPolicy</var>,
       <i id="form-submission-algorithm:navigation-resource"><a href="#navigation-resource">documentResource</a></i> set to <var>postResource</var>, and <i id="form-submission-algorithm:navigation-form-data-entry-list"><a href="#navigation-form-data-entry-list">formDataEntryList</a></i> set to <var>entry
       list</var>.</p>
      </li></ol>
     </li><li><p>Set the <code id="form-submission-algorithm:the-form-element-11"><a href="#the-form-element">form</a></code>'s <a href="#planned-navigation" id="form-submission-algorithm:planned-navigation-4">planned navigation</a> to the just-queued <a href="#concept-task" id="form-submission-algorithm:concept-task-2">task</a>.</p>
    </li></ol>

    <p>The behaviors are as follows:</p>

    <dl><dt><dfn id="submit-mutate-action">Mutate action URL</dfn>
     </dt><dd>
      <p>Let <var>pairs</var> be the result of <a href="#convert-to-a-list-of-name-value-pairs" id="form-submission-algorithm:convert-to-a-list-of-name-value-pairs">converting to a list of name-value pairs</a> with <var>entry list</var>.</p>

      <p>Let <var>query</var> be the result of running the
      <a id="form-submission-algorithm:application/x-www-form-urlencoded-serializer" href="https://url.spec.whatwg.org/#concept-urlencoded-serializer" data-x-internal="application/x-www-form-urlencoded-serializer"><code>application/x-www-form-urlencoded</code> serializer</a> with <var>pairs</var>
      and <var>encoding</var>.</p>

      <p>Set <var>parsed action</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="form-submission-algorithm:concept-url-query" data-x-internal="concept-url-query">query</a>
      component to <var>query</var>.</p>

      <p><a href="#plan-to-navigate" id="form-submission-algorithm:plan-to-navigate">Plan to navigate</a> to <var>parsed action</var>.</p>
     </dd><dt><dfn id="submit-body">Submit as entity body</dfn>
     </dt><dd>
      <p><a id="form-submission-algorithm:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>method</var> is <a href="#attr-fs-method-post" id="form-submission-algorithm:attr-fs-method-post-2">POST</a>.</p>

      <p>Switch on <var>enctype</var>:

      </p><dl class="switch"><dt><code id="form-submission-algorithm:attr-fs-enctype-urlencoded"><a href="#attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</a></code></dt><dd>
        <p>Let <var>pairs</var> be the result of <a href="#convert-to-a-list-of-name-value-pairs" id="form-submission-algorithm:convert-to-a-list-of-name-value-pairs-2">converting to a list of name-value pairs</a> with <var>entry list</var>.</p>

        <p>Let <var>body</var> be the result of running the
        <a id="form-submission-algorithm:application/x-www-form-urlencoded-serializer-2" href="https://url.spec.whatwg.org/#concept-urlencoded-serializer" data-x-internal="application/x-www-form-urlencoded-serializer"><code>application/x-www-form-urlencoded</code> serializer</a> with <var>pairs</var>
        and <var>encoding</var>.</p>

        <p>Set <var>body</var> to the result of <a href="https://encoding.spec.whatwg.org/#utf-8-encode" id="form-submission-algorithm:utf-8-encode" data-x-internal="utf-8-encode">encoding</a>
        <var>body</var>.</p>

        <p>Let <var>mimeType</var> be `<code id="form-submission-algorithm:application/x-www-form-urlencoded"><a data-x-internal="application/x-www-form-urlencoded" href="https://url.spec.whatwg.org/#concept-urlencoded">application/x-www-form-urlencoded</a></code>`.</p>
       </dd><dt><code id="form-submission-algorithm:attr-fs-enctype-formdata"><a href="#attr-fs-enctype-formdata">multipart/form-data</a></code></dt><dd>
        <p>Let <var>body</var> be the result of running the <a href="#multipart/form-data-encoding-algorithm" id="form-submission-algorithm:multipart/form-data-encoding-algorithm"><code>multipart/form-data</code> encoding algorithm</a> with <var>entry list</var>
        and <var>encoding</var>.</p>

        <p>Let <var>mimeType</var> be the <a href="https://infra.spec.whatwg.org/#isomorphic-encode" id="form-submission-algorithm:isomorphic-encode" data-x-internal="isomorphic-encode">isomorphic
        encoding</a> of the concatenation of "<code>multipart/form-data; boundary=</code>" and the <a href="#multipart/form-data-boundary-string" id="form-submission-algorithm:multipart/form-data-boundary-string"><code>multipart/form-data</code> boundary string</a> generated by the <a href="#multipart/form-data-encoding-algorithm" id="form-submission-algorithm:multipart/form-data-encoding-algorithm-2"><code>multipart/form-data</code> encoding algorithm</a>.</p>
       </dd><dt><code id="form-submission-algorithm:attr-fs-enctype-text"><a href="#attr-fs-enctype-text">text/plain</a></code></dt><dd>
        <p>Let <var>pairs</var> be the result of <a href="#convert-to-a-list-of-name-value-pairs" id="form-submission-algorithm:convert-to-a-list-of-name-value-pairs-3">converting to a list of name-value pairs</a> with <var>entry list</var>.</p>

        <p>Let <var>body</var> be the result of running the <a href="#text/plain-encoding-algorithm" id="form-submission-algorithm:text/plain-encoding-algorithm"><code>text/plain</code>
        encoding algorithm</a> with <var>pairs</var>.</p>

        <p>Set <var>body</var> to the result of <a href="https://encoding.spec.whatwg.org/#encode" id="form-submission-algorithm:encode" data-x-internal="encode">encoding</a>
        <var>body</var> using <var>encoding</var>.</p>

        <p>Let <var>mimeType</var> be `<code id="form-submission-algorithm:text/plain"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>`.</p>
       </dd></dl>

      <p><a href="#plan-to-navigate" id="form-submission-algorithm:plan-to-navigate-2">Plan to navigate</a> to <var>parsed action</var> given a <a href="#post-resource" id="form-submission-algorithm:post-resource-2">POST
      resource</a> whose <a href="#post-resource-request-body" id="form-submission-algorithm:post-resource-request-body">request body</a> is
      <var>body</var> and <a href="#post-resource-request-content-type" id="form-submission-algorithm:post-resource-request-content-type">request
      content-type</a> is <var>mimeType</var>.</p>
     </dd><dt><dfn id="submit-get-action">Get action URL</dfn>
     </dt><dd>
      <p><a href="#plan-to-navigate" id="form-submission-algorithm:plan-to-navigate-3">Plan to navigate</a> to <var>parsed action</var>.</p>

      <p class="note"><var>entry list</var> is discarded.</p>
     </dd><dt><dfn id="submit-mailto-headers">Mail with headers</dfn>
     </dt><dd>
      <p>Let <var>pairs</var> be the result of <a href="#convert-to-a-list-of-name-value-pairs" id="form-submission-algorithm:convert-to-a-list-of-name-value-pairs-4">converting to a list of name-value pairs</a> with <var>entry list</var>.</p>

      <p>Let <var>headers</var> be the result of running the
      <a id="form-submission-algorithm:application/x-www-form-urlencoded-serializer-3" href="https://url.spec.whatwg.org/#concept-urlencoded-serializer" data-x-internal="application/x-www-form-urlencoded-serializer"><code>application/x-www-form-urlencoded</code> serializer</a> with <var>pairs</var>
      and <var>encoding</var>.</p>

      <p>Replace occurrences of U+002B PLUS SIGN characters (+) in <var>headers</var> with
      the string "<code>%20</code>".</p>

      <p>Set <var>parsed action</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="form-submission-algorithm:concept-url-query-2" data-x-internal="concept-url-query">query</a> to
      <var>headers</var>.</p>

      <p><a href="#plan-to-navigate" id="form-submission-algorithm:plan-to-navigate-4">Plan to navigate</a> to <var>parsed action</var>.</p>
     </dd><dt><dfn id="submit-mailto-body">Mail as body</dfn>
     </dt><dd>
      <p>Let <var>pairs</var> be the result of <a href="#convert-to-a-list-of-name-value-pairs" id="form-submission-algorithm:convert-to-a-list-of-name-value-pairs-5">converting to a list of name-value pairs</a> with <var>entry list</var>.</p>

      <p>Switch on <var>enctype</var>:

      </p><dl class="switch"><dt><code id="form-submission-algorithm:attr-fs-enctype-text-2"><a href="#attr-fs-enctype-text">text/plain</a></code></dt><dd>
        <p>Let <var>body</var> be the result of running the <a href="#text/plain-encoding-algorithm" id="form-submission-algorithm:text/plain-encoding-algorithm-2"><code>text/plain</code>
        encoding algorithm</a> with <var>pairs</var>.</p>

        <p>Set <var>body</var> to the result of running <a id="form-submission-algorithm:utf-8-percent-encode" href="https://url.spec.whatwg.org/#string-utf-8-percent-encode" data-x-internal="utf-8-percent-encode">UTF-8 percent-encode</a> on
        <var>body</var> using the <a id="form-submission-algorithm:default-encode-set" href="https://url.spec.whatwg.org/#default-encode-set" data-x-internal="default-encode-set">default encode set</a>. <a href="#refsURL">[URL]</a></p>
       </dd><dt>Otherwise</dt><dd><p>Let <var>body</var> be the result of running the
       <a id="form-submission-algorithm:application/x-www-form-urlencoded-serializer-4" href="https://url.spec.whatwg.org/#concept-urlencoded-serializer" data-x-internal="application/x-www-form-urlencoded-serializer"><code>application/x-www-form-urlencoded</code> serializer</a> with <var>pairs</var>
       and <var>encoding</var>.</p></dd></dl>

      <p>If <var>parsed action</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="form-submission-algorithm:concept-url-query-3" data-x-internal="concept-url-query">query</a> is null, then
      set it to the empty string.

      </p><p>If <var>parsed action</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="form-submission-algorithm:concept-url-query-4" data-x-internal="concept-url-query">query</a> is not the
      empty string, then append a single U+0026 AMPERSAND character (&amp;) to it.

      </p><p>Append "<code>body=</code>" to <var>parsed action</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="form-submission-algorithm:concept-url-query-5" data-x-internal="concept-url-query">query</a>.</p>

      <p>Append <var>body</var> to <var>parsed action</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="form-submission-algorithm:concept-url-query-6" data-x-internal="concept-url-query">query</a>.</p>

      <p><a href="#plan-to-navigate" id="form-submission-algorithm:plan-to-navigate-5">Plan to navigate</a> to <var>parsed action</var>.</p>
     </dd></dl>
   </li></ol>
  </div>


  <h5 id="constructing-form-data-set"><span class="secno">4.10.22.4</span> Constructing the entry list<a href="#constructing-form-data-set" class="self-link"></a></h5>

  <p>An <dfn id="entry-list" data-export="">entry list</dfn> is a <a id="constructing-form-data-set:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#form-entry" id="constructing-form-data-set:form-entry">entries</a>, typically representing the contents of a form. An <dfn data-dfn-for="entry list" id="form-entry" data-export="">entry</dfn> is a tuple consisting of a <dfn data-dfn-for="entry list/entry" id="form-entry-name" data-export="">name</dfn> (a <a id="constructing-form-data-set:scalar-value-string" href="https://infra.spec.whatwg.org/#scalar-value-string" data-x-internal="scalar-value-string">scalar value string</a>) and a <dfn data-dfn-for="entry list/entry" id="form-entry-value" data-export="">value</dfn> (either a <a id="constructing-form-data-set:scalar-value-string-2" href="https://infra.spec.whatwg.org/#scalar-value-string" data-x-internal="scalar-value-string">scalar value
  string</a> or a <code id="constructing-form-data-set:file"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object).</p>

  <div data-algorithm="">
  <p id="append-an-entry">To <dfn data-dfn-for="entry list" id="create-an-entry" data-export="">create an entry</dfn> given a string
  <var>name</var>, a string or <code id="constructing-form-data-set:blob"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> object <var>value</var>, and optionally a
  <a id="constructing-form-data-set:scalar-value-string-3" href="https://infra.spec.whatwg.org/#scalar-value-string" data-x-internal="scalar-value-string">scalar value string</a> <var>filename</var>:</p>

  <ol><li><p>Set <var>name</var> to the result of <a href="https://infra.spec.whatwg.org/#javascript-string-convert" id="constructing-form-data-set:convert" data-x-internal="convert">converting</a>
   <var>name</var> into a <a id="constructing-form-data-set:scalar-value-string-4" href="https://infra.spec.whatwg.org/#scalar-value-string" data-x-internal="scalar-value-string">scalar value string</a>.</p></li><li><p>If <var>value</var> is a string, then set <var>value</var> to the result of <a href="https://infra.spec.whatwg.org/#javascript-string-convert" id="constructing-form-data-set:convert-2" data-x-internal="convert">converting</a> <var>value</var> into a <a id="constructing-form-data-set:scalar-value-string-5" href="https://infra.spec.whatwg.org/#scalar-value-string" data-x-internal="scalar-value-string">scalar value
   string</a>.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>If <var>value</var> is not a <code id="constructing-form-data-set:file-2"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object, then set <var>value</var> to a
     new <code id="constructing-form-data-set:file-3"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object, representing the same bytes, whose <code id="constructing-form-data-set:dom-file-name"><a data-x-internal="dom-file-name" href="https://w3c.github.io/FileAPI/#dfn-name">name</a></code> attribute value is "<code>blob</code>".</p></li><li><p>If <var>filename</var> is given, then set <var>value</var> to a new <code id="constructing-form-data-set:file-4"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code>
     object, representing the same bytes, whose <code id="constructing-form-data-set:dom-file-name-2"><a data-x-internal="dom-file-name" href="https://w3c.github.io/FileAPI/#dfn-name">name</a></code> attribute
     is <var>filename</var>.</p></li></ol>

    <p class="note">These operations will create a new <code id="constructing-form-data-set:file-5"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object if either
    <var>filename</var> is given or the passed <code id="constructing-form-data-set:blob-2"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> is not a <code id="constructing-form-data-set:file-6"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object.
    In those cases, the identity of the passed <code id="constructing-form-data-set:blob-3"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> object is not kept.</p>
   </li><li><p>Return an <a href="#form-entry" id="constructing-form-data-set:form-entry-2">entry</a> whose <a href="#form-entry-name" id="constructing-form-data-set:form-entry-name">name</a> is <var>name</var> and whose <a href="#form-entry-value" id="constructing-form-data-set:form-entry-value">value</a> is
   <var>value</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="constructing-the-form-data-set" data-lt="constructing the entry list" data-export="">construct the entry list</dfn> given a <var>form</var>, an
  optional <var>submitter</var> (default null), and an optional <var>encoding</var> (default
  <a id="constructing-form-data-set:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>):

  </p><ol><li><p>If <var>form</var>'s <a href="#constructing-entry-list" id="constructing-form-data-set:constructing-entry-list">constructing entry list</a> is true, then return
   null.</p></li><li><p>Set <var>form</var>'s <a href="#constructing-entry-list" id="constructing-form-data-set:constructing-entry-list-2">constructing entry list</a> to true.</p></li><li><p>Let <var>controls</var> be a list of all the <a href="#category-submit" id="constructing-form-data-set:category-submit">submittable elements</a> whose <a href="#form-owner" id="constructing-form-data-set:form-owner">form owner</a> is <var>form</var>, in <a id="constructing-form-data-set:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li><li><p>Let <var>entry list</var> be a new empty <a href="#entry-list" id="constructing-form-data-set:entry-list">entry list</a>.</p></li><li>
    <p>For each element <var>field</var> in <var>controls</var>, in <a id="constructing-form-data-set:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

    <ol><li>
      <p>If any of the following are true:</p>

      <ul><li><p><var>field</var> has a <code id="constructing-form-data-set:the-datalist-element"><a href="#the-datalist-element">datalist</a></code> element ancestor;</p></li><li><p><var>field</var> is <a href="#concept-fe-disabled" id="constructing-form-data-set:concept-fe-disabled">disabled</a>;</p></li><li><p><var>field</var> is a <a href="#concept-button" id="constructing-form-data-set:concept-button">button</a> but it is not
       <var>submitter</var>;</p></li><li><p><var>field</var> is an <code id="constructing-form-data-set:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="constructing-form-data-set:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#checkbox-state-(type=checkbox)" id="constructing-form-data-set:checkbox-state-(type=checkbox)">Checkbox</a> state and whose <a href="#concept-fe-checked" id="constructing-form-data-set:concept-fe-checked">checkedness</a> is false; or</p></li><li><p><var>field</var> is an <code id="constructing-form-data-set:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="constructing-form-data-set:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#radio-button-state-(type=radio)" id="constructing-form-data-set:radio-button-state-(type=radio)">Radio Button</a> state and whose <a href="#concept-fe-checked" id="constructing-form-data-set:concept-fe-checked-2">checkedness</a> is false,</p></li></ul>

      <p>then <a id="constructing-form-data-set:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p>
     </li><li>
      <p>If the <var>field</var> element is an <code id="constructing-form-data-set:the-input-element-3"><a href="#the-input-element">input</a></code> element whose <code id="constructing-form-data-set:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#image-button-state-(type=image)" id="constructing-form-data-set:image-button-state-(type=image)">Image Button</a> state, then:</p>

      <ol><li><p>If the <var>field</var> element is not <var>submitter</var>, then
       <a id="constructing-form-data-set:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If the <var>field</var> element has a <code id="constructing-form-data-set:attr-fe-name"><a href="#attr-fe-name">name</a></code>
       attribute specified and its value is not the empty string, let <var>name</var> be that value
       followed by U+002E (.). Otherwise, let <var>name</var> be the empty string.</p></li><li><p>Let <var>name<sub>x</sub></var> be the concatenation of <var>name</var> and
       U+0078 (x).</p></li><li><p>Let <var>name<sub>y</sub></var> be the concatenation of <var>name</var> and
       U+0079 (y).</p></li><li><p>Let (<var>x</var>, <var>y</var>) be the <a href="#concept-input-type-image-coordinate" id="constructing-form-data-set:concept-input-type-image-coordinate">selected coordinate</a>.</p></li><li><p><a href="#create-an-entry" id="constructing-form-data-set:create-an-entry">Create an entry</a> with <var>name<sub>x</sub></var> and <var>x</var>, and
       <a href="https://infra.spec.whatwg.org/#list-append" id="constructing-form-data-set:list-append" data-x-internal="list-append">append</a> it to <var>entry list</var>.</p></li><li><p><a href="#create-an-entry" id="constructing-form-data-set:create-an-entry-2">Create an entry</a> with <var>name<sub>y</sub></var> and <var>y</var>, and
       <a href="https://infra.spec.whatwg.org/#list-append" id="constructing-form-data-set:list-append-2" data-x-internal="list-append">append</a> it to <var>entry list</var>.</p></li><li><p><a id="constructing-form-data-set:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
     </li><li><p>If the <var>field</var> is a <a href="#form-associated-custom-element" id="constructing-form-data-set:form-associated-custom-element">form-associated custom element</a>, then perform
     the <a href="#face-entry-construction" id="constructing-form-data-set:face-entry-construction">entry construction algorithm</a> given
     <var>field</var> and <var>entry list</var>, then <a id="constructing-form-data-set:continue-4" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If either the <var>field</var> element does not have a
     <code id="constructing-form-data-set:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attribute specified, or its
     <code id="constructing-form-data-set:attr-fe-name-3"><a href="#attr-fe-name">name</a></code> attribute's value is the empty string, then
     <a id="constructing-form-data-set:continue-5" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>name</var> be the value of the <var>field</var> element's
     <code id="constructing-form-data-set:attr-fe-name-4"><a href="#attr-fe-name">name</a></code> attribute.</p></li><li><p>If the <var>field</var> element is a <code id="constructing-form-data-set:the-select-element"><a href="#the-select-element">select</a></code> element, then for each
     <code id="constructing-form-data-set:the-option-element"><a href="#the-option-element">option</a></code> element in the <code id="constructing-form-data-set:the-select-element-2"><a href="#the-select-element">select</a></code> element's <a href="#concept-select-option-list" id="constructing-form-data-set:concept-select-option-list">list of options</a> whose <a href="#concept-option-selectedness" id="constructing-form-data-set:concept-option-selectedness">selectedness</a> is true and that is not <a href="#concept-option-disabled" id="constructing-form-data-set:concept-option-disabled">disabled</a>, <a href="#create-an-entry" id="constructing-form-data-set:create-an-entry-3">create an entry</a> with
     <var>name</var> and the <a href="#concept-option-value" id="constructing-form-data-set:concept-option-value">value</a> of the
     <code id="constructing-form-data-set:the-option-element-2"><a href="#the-option-element">option</a></code> element, and <a href="https://infra.spec.whatwg.org/#list-append" id="constructing-form-data-set:list-append-3" data-x-internal="list-append">append</a> it to <var>entry
     list</var>.</p></li><li>
      <p>Otherwise, if the <var>field</var> element is an <code id="constructing-form-data-set:the-input-element-4"><a href="#the-input-element">input</a></code> element whose
      <code id="constructing-form-data-set:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#checkbox-state-(type=checkbox)" id="constructing-form-data-set:checkbox-state-(type=checkbox)-2">Checkbox</a> state or the <a href="#radio-button-state-(type=radio)" id="constructing-form-data-set:radio-button-state-(type=radio)-2">Radio Button</a> state, then:</p>

      <ol><li><p>If the <var>field</var> element has a <code id="constructing-form-data-set:attr-input-value"><a href="#attr-input-value">value</a></code> attribute specified, then let <var>value</var>
       be the value of that attribute; otherwise, let <var>value</var> be the string "<code>on</code>".</p></li><li><p><a href="#create-an-entry" id="constructing-form-data-set:create-an-entry-4">Create an entry</a> with <var>name</var> and <var>value</var>, and <a href="https://infra.spec.whatwg.org/#list-append" id="constructing-form-data-set:list-append-4" data-x-internal="list-append">append</a> it to <var>entry list</var>.</p></li></ol>
     </li><li>
      <p>Otherwise, if the <var>field</var> element is an <code id="constructing-form-data-set:the-input-element-5"><a href="#the-input-element">input</a></code> element whose <code id="constructing-form-data-set:attr-input-type-5"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#file-upload-state-(type=file)" id="constructing-form-data-set:file-upload-state-(type=file)">File Upload</a> state, then:</p>

      <ol><li><p>If there are no <a href="#concept-input-type-file-selected" id="constructing-form-data-set:concept-input-type-file-selected">selected files</a>,
       then <a href="#create-an-entry" id="constructing-form-data-set:create-an-entry-5">create an entry</a> with <var>name</var> and a new <code id="constructing-form-data-set:file-7"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object
       with an empty name, <code id="constructing-form-data-set:application/octet-stream"><a data-x-internal="application/octet-stream" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1">application/octet-stream</a></code> as type, and an empty body, and
       <a href="https://infra.spec.whatwg.org/#list-append" id="constructing-form-data-set:list-append-5" data-x-internal="list-append">append</a> it to <var>entry list</var>.</p></li><li><p>Otherwise, for each file in <a href="#concept-input-type-file-selected" id="constructing-form-data-set:concept-input-type-file-selected-2">selected
       files</a>, <a href="#create-an-entry" id="constructing-form-data-set:create-an-entry-6">create an entry</a> with <var>name</var> and a <code id="constructing-form-data-set:file-8"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code>
       object representing the file, and <a href="https://infra.spec.whatwg.org/#list-append" id="constructing-form-data-set:list-append-6" data-x-internal="list-append">append</a> it to <var>entry
       list</var>.</p></li></ol>
     </li><li>
      <p>Otherwise, if the <var>field</var> element is an <code id="constructing-form-data-set:the-input-element-6"><a href="#the-input-element">input</a></code> element whose <code id="constructing-form-data-set:attr-input-type-6"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#hidden-state-(type=hidden)" id="constructing-form-data-set:hidden-state-(type=hidden)">Hidden</a> state and <var>name</var> is an <a id="constructing-form-data-set:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
      case-insensitive</a> match for "<code id="constructing-form-data-set:attr-fe-name-charset"><a href="#attr-fe-name-charset">_charset_</a></code>":</p>

      <ol><li><p>Let <var>charset</var> be the <a href="https://encoding.spec.whatwg.org/#name" id="constructing-form-data-set:encoding-name" data-x-internal="encoding-name">name</a> of
       <var>encoding</var>.</p></li><li><p><a href="#create-an-entry" id="constructing-form-data-set:create-an-entry-7">Create an entry</a> with <var>name</var> and <var>charset</var>, and <a href="https://infra.spec.whatwg.org/#list-append" id="constructing-form-data-set:list-append-7" data-x-internal="list-append">append</a> it to <var>entry list</var>.</p></li></ol>
     </li><li><p>Otherwise, <a href="#create-an-entry" id="constructing-form-data-set:create-an-entry-8">create an entry</a> with <var>name</var> and the <a href="#concept-fe-value" id="constructing-form-data-set:concept-fe-value">value</a> of the <var>field</var> element, and <a href="https://infra.spec.whatwg.org/#list-append" id="constructing-form-data-set:list-append-8" data-x-internal="list-append">append</a> it to <var>entry list</var>.</p></li><li>
      <p>If the element has a <code id="constructing-form-data-set:attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code> attribute, that
      attribute's value is not the empty string, and the element is an <a href="#auto-directionality-form-associated-elements" id="constructing-form-data-set:auto-directionality-form-associated-elements">auto-directionality form-associated
      element</a>:

      </p><ol><li><p>Let <var>dirname</var> be the value of the element's <code id="constructing-form-data-set:attr-fe-dirname-2"><a href="#attr-fe-dirname">dirname</a></code> attribute.</p></li><li><p>Let <var>dir</var> be the string "<code>ltr</code>" if <a href="#the-directionality" id="constructing-form-data-set:the-directionality">the
       directionality</a> of the element is '<a href="#concept-ltr" id="constructing-form-data-set:concept-ltr">ltr</a>', and "<code>rtl</code>" otherwise (i.e., when <a href="#the-directionality" id="constructing-form-data-set:the-directionality-2">the directionality</a> of the element is
       '<a href="#concept-rtl" id="constructing-form-data-set:concept-rtl">rtl</a>').</p></li><li><p><a href="#create-an-entry" id="constructing-form-data-set:create-an-entry-9">Create an entry</a> with <var>dirname</var> and <var>dir</var>, and <a href="https://infra.spec.whatwg.org/#list-append" id="constructing-form-data-set:list-append-9" data-x-internal="list-append">append</a> it to <var>entry list</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Let <var>form data</var> be a new <code id="constructing-form-data-set:formdata"><a data-x-internal="formdata" href="https://xhr.spec.whatwg.org/#formdata">FormData</a></code> object associated with
   <var>entry list</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="constructing-form-data-set:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named
   <code id="constructing-form-data-set:event-formdata"><a href="#event-formdata">formdata</a></code> at <var>form</var> using
   <code id="constructing-form-data-set:formdataevent"><a href="#formdataevent">FormDataEvent</a></code>, with the <code id="constructing-form-data-set:dom-formdataevent-formdata"><a href="#dom-formdataevent-formdata">formData</a></code>
   attribute initialized to <var>form data</var> and the
   <code id="constructing-form-data-set:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to true.</p></li><li><p>Set <var>form</var>'s <a href="#constructing-entry-list" id="constructing-form-data-set:constructing-entry-list-3">constructing entry list</a> to false.</p></li><li><p>Return a <a href="https://infra.spec.whatwg.org/#list-clone" id="constructing-form-data-set:list-clone" data-x-internal="list-clone">clone</a> of <var>entry list</var>.</p></li></ol>
  </div>

  


  

  <h5 id="selecting-a-form-submission-encoding"><span class="secno">4.10.22.5</span> Selecting a form submission encoding<a href="#selecting-a-form-submission-encoding" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>If the user agent is to <dfn id="picking-an-encoding-for-the-form">pick an encoding for a
  form</dfn>, it must run the following steps:</p>

  <ol><li><p>Let <var>encoding</var> be the <a id="selecting-a-form-submission-encoding:document's-character-encoding" href="https://dom.spec.whatwg.org/#concept-document-encoding" data-x-internal="document's-character-encoding">document's character encoding</a>.</p></li><li>
    <p>If the <code id="selecting-a-form-submission-encoding:the-form-element"><a href="#the-form-element">form</a></code> element has an <code id="selecting-a-form-submission-encoding:attr-form-accept-charset"><a href="#attr-form-accept-charset">accept-charset</a></code> attribute, set <var>encoding</var> to
    the return value of running these substeps:</p>

    <ol><li><p>Let <var>input</var> be the value of the <code id="selecting-a-form-submission-encoding:the-form-element-2"><a href="#the-form-element">form</a></code> element's <code id="selecting-a-form-submission-encoding:attr-form-accept-charset-2"><a href="#attr-form-accept-charset">accept-charset</a></code> attribute.</p></li><li><p>Let <var>candidate encoding labels</var> be the result of <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="selecting-a-form-submission-encoding:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">splitting <var>input</var> on ASCII whitespace</a>.</p></li><li><p>Let <var>candidate encodings</var> be an empty list of <a href="https://encoding.spec.whatwg.org/#encoding" id="selecting-a-form-submission-encoding:encoding" data-x-internal="encoding">character
     encodings</a>.</p></li><li><p>For each token in <var>candidate encoding labels</var> in turn (in the order in which
     they were found in <var>input</var>), <a href="https://encoding.spec.whatwg.org/#concept-encoding-get" id="selecting-a-form-submission-encoding:getting-an-encoding" data-x-internal="getting-an-encoding">get an encoding</a>
     for the token and, if this does not result in failure, append the <a id="selecting-a-form-submission-encoding:encoding-2" href="https://encoding.spec.whatwg.org/#encoding" data-x-internal="encoding">encoding</a> to
     <var>candidate encodings</var>.</p></li><li><p>If <var>candidate encodings</var> is empty, return <a id="selecting-a-form-submission-encoding:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>.</p></li><li><p>Return the first encoding in <var>candidate encodings</var>.</p></li></ol>
   </li><li><p>Return the result of <a href="https://encoding.spec.whatwg.org/#get-an-output-encoding" id="selecting-a-form-submission-encoding:get-an-output-encoding" data-x-internal="get-an-output-encoding">getting an output
   encoding</a> from <var>encoding</var>.</p></li></ol>
  </div>

  

  

  <h5 id="converting-an-entry-list-to-a-list-of-name-value-pairs"><span class="secno">4.10.22.6</span> Converting an entry list to a list of name-value pairs<a href="#converting-an-entry-list-to-a-list-of-name-value-pairs" class="self-link"></a></h5>

  <p>The <code id="converting-an-entry-list-to-a-list-of-name-value-pairs:application/x-www-form-urlencoded"><a data-x-internal="application/x-www-form-urlencoded" href="https://url.spec.whatwg.org/#concept-urlencoded">application/x-www-form-urlencoded</a></code> and <code id="converting-an-entry-list-to-a-list-of-name-value-pairs:text/plain-encoding-algorithm"><a href="#text/plain-encoding-algorithm">text/plain</a></code> encoding algorithms take a list of name-value pairs, where the values
  must be strings, rather than an <a href="#entry-list" id="converting-an-entry-list-to-a-list-of-name-value-pairs:entry-list">entry list</a> where the value can be a
  <code id="converting-an-entry-list-to-a-list-of-name-value-pairs:file"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code>. The following algorithm performs the conversion.</p>

  <div data-algorithm="">
  <p>To <dfn id="convert-to-a-list-of-name-value-pairs">convert to a list of name-value pairs</dfn> an <a href="#entry-list" id="converting-an-entry-list-to-a-list-of-name-value-pairs:entry-list-2">entry list</a> <var>entry
  list</var>, run these steps:</p>

  <ol><li><p>Let <var>list</var> be an empty <a id="converting-an-entry-list-to-a-list-of-name-value-pairs:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of name-value pairs.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="converting-an-entry-list-to-a-list-of-name-value-pairs:list-iterate" data-x-internal="list-iterate">For each</a> <var>entry</var> of <var>entry list</var>:</p>

    <ol><li><p>Let <var>name</var> be <var>entry</var>'s <a href="#form-entry-name" id="converting-an-entry-list-to-a-list-of-name-value-pairs:form-entry-name">name</a>,
     with every occurrence of U+000D (CR) not followed by U+000A (LF), and every occurrence of
     U+000A (LF) not preceded by U+000D (CR), replaced by a string consisting of U+000D (CR) and
     U+000A (LF).</p></li><li><p>If <var>entry</var>'s <a href="#form-entry-value" id="converting-an-entry-list-to-a-list-of-name-value-pairs:form-entry-value">value</a> is a
     <code id="converting-an-entry-list-to-a-list-of-name-value-pairs:file-2"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object, then let <var>value</var> be <var>entry</var>'s <a href="#form-entry-value" id="converting-an-entry-list-to-a-list-of-name-value-pairs:form-entry-value-2">value</a>'s <code id="converting-an-entry-list-to-a-list-of-name-value-pairs:dom-file-name"><a data-x-internal="dom-file-name" href="https://w3c.github.io/FileAPI/#dfn-name">name</a></code>. Otherwise, let
     <var>value</var> be <var>entry</var>'s <a href="#form-entry-value" id="converting-an-entry-list-to-a-list-of-name-value-pairs:form-entry-value-3">value</a>.</p></li><li><p>Replace every occurrence of U+000D (CR) not followed by U+000A (LF), and every occurrence
     of U+000A (LF) not preceded by U+000D (CR), in <var>value</var>, by a string consisting of
     U+000D (CR) and U+000A (LF).</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="converting-an-entry-list-to-a-list-of-name-value-pairs:list-append" data-x-internal="list-append">Append</a> to <var>list</var> a new name-value pair whose
     name is <var>name</var> and whose value is <var>value</var>.</p></li></ol>
   </li><li><p>Return <var>list</var>.</p></li></ol>
  </div>

  


  <h5 id="url-encoded-form-data"><span class="secno">4.10.22.7</span> URL-encoded form data<a href="#url-encoded-form-data" class="self-link"></a></h5>

  <p id="application-x-www-form-urlencoded-encoding-algorithm"><span id="application/x-www-form-urlencoded-encoding-algorithm"></span>See <cite>URL</cite> for details
  on <code id="url-encoded-form-data:application/x-www-form-urlencoded"><a data-x-internal="application/x-www-form-urlencoded" href="https://url.spec.whatwg.org/#concept-urlencoded">application/x-www-form-urlencoded</a></code>. <a href="#refsURL">[URL]</a></p>


  <h5 id="multipart-form-data"><span class="secno">4.10.22.8</span> Multipart form data<a href="#multipart-form-data" class="self-link"></a></h5>

  

  

  

  <div data-algorithm="">
  <p>The <dfn id="multipart/form-data-encoding-algorithm" data-export=""><code>multipart/form-data</code> encoding algorithm</dfn>, given an <a href="#entry-list" id="multipart-form-data:entry-list">entry
  list</a> <var>entry list</var> and an <a id="multipart-form-data:encoding" href="https://encoding.spec.whatwg.org/#encoding" data-x-internal="encoding">encoding</a> <var>encoding</var>, is as
  follows:</p>

  <ol><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="multipart-form-data:list-iterate" data-x-internal="list-iterate">For each</a> <var>entry</var> of <var>entry list</var>:</p>

    <ol><li><p>Replace every occurrence of U+000D (CR) not followed by U+000A (LF), and every
     occurrence of U+000A (LF) not preceded by U+000D (CR), in <var>entry</var>'s <a href="#form-entry-name" id="multipart-form-data:form-entry-name">name</a>, by a string consisting of a U+000D (CR) and U+000A (LF).</p></li><li><p>If <var>entry</var>'s <a href="#form-entry-value" id="multipart-form-data:form-entry-value">value</a> is not a
     <code id="multipart-form-data:file"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object, then replace every occurrence of U+000D (CR) not followed by U+000A
     (LF), and every occurrence of U+000A (LF) not preceded by U+000D (CR), in <var>entry</var>'s
     <a href="#form-entry-value" id="multipart-form-data:form-entry-value-2">value</a>, by a string consisting of a U+000D (CR) and
     U+000A (LF).</p></li></ol>
   </li><li>
    <p>Return the byte sequence resulting from encoding the <var>entry list</var> using the rules
    described by RFC 7578, <cite>Returning Values from Forms: <code>multipart/form-data</code></cite>, given the following conditions:
    <a href="#refsRFC7578">[RFC7578]</a></p>

    <ul><li><p>Each <a href="#form-entry" id="multipart-form-data:form-entry">entry</a> in <var>entry list</var> is a <i>field</i>,
     the <a href="#form-entry-name" id="multipart-form-data:form-entry-name-2">name</a> of the entry is the <i>field name</i> and the
     <a href="#form-entry-value" id="multipart-form-data:form-entry-value-3">value</a> of the entry is the <i>field value</i>.</p></li><li><p>The order of parts must be the same as the order of fields in <var>entry list</var>.
     Multiple entries with the same name must be treated as distinct fields.</p></li><li><p>Field names, field values for non-file fields, and filenames for file fields, in the
     generated <code id="multipart-form-data:multipart/form-data"><a href="#multipart/form-data">multipart/form-data</a></code> resource must be set to the result of <a href="https://encoding.spec.whatwg.org/#encode" id="multipart-form-data:encode" data-x-internal="encode">encoding</a> the corresponding entry's name or value with
     <var>encoding</var>, converted to a byte sequence.</p></li><li><p>For field names and filenames for file fields, the result of the encoding in the
     previous bullet point must be escaped by replacing any 0x0A (LF) bytes with the byte sequence
     `<code>%0A</code>`, 0x0D (CR) with `<code>%0D</code>` and 0x22 (") with
     `<code>%22</code>`. The user agent must not perform any other escapes.</p></li><li><p>The parts of the generated <code id="multipart-form-data:multipart/form-data-2"><a href="#multipart/form-data">multipart/form-data</a></code> resource that correspond to
     non-file fields must not have a `<code id="multipart-form-data:content-type"><a href="#content-type">Content-Type</a></code>` header specified.</p></li><li><p>The boundary used by the user agent in generating the return value of this algorithm is
     the <dfn id="multipart/form-data-boundary-string" data-export=""><code>multipart/form-data</code> boundary string</dfn>. (This value is used to
     generate the MIME type of the form submission payload generated by this algorithm.)</p></li></ul>
   </li></ol>
  </div>

  

  <p>For details on how to interpret <code id="multipart-form-data:multipart/form-data-3"><a href="#multipart/form-data">multipart/form-data</a></code> payloads, see RFC 7578.
  <a href="#refsRFC7578">[RFC7578]</a></p>


  <h5 id="plain-text-form-data"><span class="secno">4.10.22.9</span> Plain text form data<a href="#plain-text-form-data" class="self-link"></a></h5>

  

  <div data-algorithm="">
  <p>The <dfn id="text/plain-encoding-algorithm"><code>text/plain</code> encoding algorithm</dfn>, given a list of name-value
  pairs <var>pairs</var>, is as follows:</p>

  <ol><li><p>Let <var>result</var> be the empty string.</p></li><li>
    <p>For each <var>pair</var> in <var>pairs</var>:</p>

    <ol><li><p>Append <var>pair</var>'s name to <var>result</var>.</p></li><li><p>Append a single U+003D EQUALS SIGN character (=) to <var>result</var>.</p></li><li><p>Append <var>pair</var>'s value to <var>result</var>.</p></li><li><p>Append a U+000D CARRIAGE RETURN (CR) U+000A LINE FEED (LF) character pair to <var>result</var>.</p></li></ol>
   </li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  

  <p>Payloads using the <code id="plain-text-form-data:text/plain"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code> format are intended to be human readable. They are
  not reliably interpretable by computer, as the format is ambiguous (for example, there is no way
  to distinguish a literal newline in a value from the newline at the end of the value).</p>

  <h5 id="the-submitevent-interface"><span class="secno">4.10.22.10</span> The <code id="the-submitevent-interface:submitevent"><a href="#submitevent">SubmitEvent</a></code> interface<a href="#the-submitevent-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SubmitEvent" title="The SubmitEvent interface defines the object used to represent an HTML form's submit event. This event is fired at the <form> when the form's submit action is invoked.">SubmitEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>75+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>81+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>81+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SubmitEvent/SubmitEvent" title="The SubmitEvent() constructor creates and returns a new SubmitEvent object, which is used to represent a submit event fired at an HTML form.">SubmitEvent/SubmitEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>75+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>81+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>81+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="submitevent" data-dfn-type="interface"><c- g="">SubmitEvent</c-></dfn> : <a id="the-submitevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#submiteventinit" id="the-submitevent-interface:submiteventinit"><c- n="">SubmitEventInit</c-></a> <c- g="">eventInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlelement" id="the-submitevent-interface:htmlelement"><c- n="">HTMLElement</c-></a>? <a href="#dom-submitevent-submitter" id="the-submitevent-interface:dom-submitevent-submitter"><c- g="">submitter</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="submiteventinit" data-dfn-type="dictionary"><c- g="">SubmitEventInit</c-></dfn> : <a id="the-submitevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <a href="#htmlelement" id="the-submitevent-interface:htmlelement-2"><c- n="">HTMLElement</c-></a>? <c- g="">submitter</c-> = <c- b="">null</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-submitevent-submitter" id="the-submitevent-interface:dom-submitevent-submitter-2">submitter</a></code></dt><dd><p>Returns the element representing the <a href="#concept-submit-button" id="the-submitevent-interface:concept-submit-button">submit
   button</a> that triggered the <a href="#form-submission-2" id="the-submitevent-interface:form-submission-2">form submission</a>, or null if the submission was not
   triggered by a button.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="SubmitEvent" id="dom-submitevent-submitter" data-dfn-type="attribute"><code>submitter</code></dfn> attribute must return the value it was
  initialized to.</p>
  </div>

  

  <h5 id="the-formdataevent-interface"><span class="secno">4.10.22.11</span> The <code id="the-formdataevent-interface:formdataevent"><a href="#formdataevent">FormDataEvent</a></code> interface<a href="#the-formdataevent-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/FormDataEvent/FormDataEvent" title="The FormDataEvent() constructor creates a new FormDataEvent object.">FormDataEvent/FormDataEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>72+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/FormDataEvent" title="The FormDataEvent interface represents a formdata event — such an event is fired on an HTMLFormElement object after the entry list representing the form's data is constructed. This happens when the form is submitted, but can also be triggered by the invocation of a FormData() constructor.">FormDataEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>72+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="formdataevent" data-dfn-type="interface"><c- g="">FormDataEvent</c-></dfn> : <a id="the-formdataevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <a href="#formdataeventinit" id="the-formdataevent-interface:formdataeventinit"><c- n="">FormDataEventInit</c-></a> <c- g="">eventInitDict</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-formdataevent-interface:formdata" href="https://xhr.spec.whatwg.org/#formdata" data-x-internal="formdata"><c- n="">FormData</c-></a> <a href="#dom-formdataevent-formdata" id="the-formdataevent-interface:dom-formdataevent-formdata"><c- g="">formData</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="formdataeventinit" data-dfn-type="dictionary"><c- g="">FormDataEventInit</c-></dfn> : <a id="the-formdataevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- b="">required</c-> <a id="the-formdataevent-interface:formdata-2" href="https://xhr.spec.whatwg.org/#formdata" data-x-internal="formdata"><c- n="">FormData</c-></a> <c- g="">formData</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-formdataevent-formdata" id="the-formdataevent-interface:dom-formdataevent-formdata-2">formData</a></code></dt><dd>
    <p>Returns a <code id="the-formdataevent-interface:formdata-3"><a data-x-internal="formdata" href="https://xhr.spec.whatwg.org/#formdata">FormData</a></code> object representing names and values of elements associated
    to the target <code id="the-formdataevent-interface:the-form-element"><a href="#the-form-element">form</a></code>. Operations on the <code id="the-formdataevent-interface:formdata-4"><a data-x-internal="formdata" href="https://xhr.spec.whatwg.org/#formdata">FormData</a></code> object will affect form
    data to be submitted.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="FormDataEvent" id="dom-formdataevent-formdata" data-dfn-type="attribute"><code>formData</code></dfn> attribute must return the value it was
  initialized to. It represents a <code id="the-formdataevent-interface:formdata-5"><a data-x-internal="formdata" href="https://xhr.spec.whatwg.org/#formdata">FormData</a></code> object associated to the <a href="#entry-list" id="the-formdataevent-interface:entry-list">entry
  list</a> that is <a href="#constructing-the-form-data-set" id="the-formdataevent-interface:constructing-the-form-data-set">constructed</a> when the
  <code id="the-formdataevent-interface:the-form-element-2"><a href="#the-form-element">form</a></code> is submitted.</p>
  </div>

  <h4 id="resetting-a-form"><span class="secno">4.10.23</span> Resetting a form<a href="#resetting-a-form" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When a <code id="resetting-a-form:the-form-element"><a href="#the-form-element">form</a></code> element <var>form</var> is <dfn id="concept-form-reset">reset</dfn>, run these steps:</p>

  <ol><li><p>Let <var>reset</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="resetting-a-form:concept-event-fire" data-x-internal="concept-event-fire">firing an
   event</a> named <code id="resetting-a-form:event-reset"><a href="#event-reset">reset</a></code> at <var>form</var>, with the <code id="resetting-a-form:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="resetting-a-form:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attributes initialized to true.</p></li><li><p>If <var>reset</var> is true, then invoke the <a href="#concept-form-reset-control" id="resetting-a-form:concept-form-reset-control">reset algorithm</a> of each <a href="#category-reset" id="resetting-a-form:category-reset">resettable element</a> whose <a href="#form-owner" id="resetting-a-form:form-owner">form owner</a> is
   <var>form</var>.</p></li></ol>
  </div>

  <p>Each <a href="#category-reset" id="resetting-a-form:category-reset-2">resettable element</a> defines its own <dfn id="concept-form-reset-control">reset algorithm</dfn>. Changes made to form controls as part of
  these algorithms do not count as changes caused by the user (and thus, e.g., do not cause <code id="resetting-a-form:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> events to fire).</p>

  



  <h3 id="interactive-elements"><span class="secno">4.11</span> Interactive elements<a href="#interactive-elements" class="self-link"></a></h3>

  <h4 id="the-details-element"><span class="secno">4.11.1</span> The <dfn data-dfn-type="element"><code>details</code></dfn> element<a href="#the-details-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details" title="The <details> HTML element creates a disclosure widget in which information is visible only when the widget is toggled into an &quot;open&quot; state. A summary or label must be provided using the <summary> element.">Element/details</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>12+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>49+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDetailsElement" title="The HTMLDetailsElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <details> elements.">HTMLDetailsElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDetailsElement/open" title="The open property of the HTMLDetailsElement interface is a boolean value reflecting the open HTML attribute, indicating whether the <details>'s contents (not counting the <summary>) is to be shown to the user.">HTMLDetailsElement/open</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-details-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-details-element:flow-content-2">Flow content</a>.</dd><dd><a href="#interactive-content-2" id="the-details-element:interactive-content-2">Interactive content</a>.</dd><dd><a href="#palpable-content-2" id="the-details-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-details-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-details-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-details-element:concept-element-content-model">Content model</a>:</dt><dd>One <code id="the-details-element:the-summary-element"><a href="#the-summary-element">summary</a></code> element followed by <a href="#flow-content-2" id="the-details-element:flow-content-2-3">flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-details-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-details-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-details-element:global-attributes">Global attributes</a></dd><dd><code id="the-details-element:attr-details-name"><a href="#attr-details-name">name</a></code> —  Name of group of mutually-exclusive <code id="the-details-element:the-details-element"><a href="#the-details-element">details</a></code> elements
     </dd><dd><code id="the-details-element:attr-details-open"><a href="#attr-details-open">open</a></code> —  Whether the details are visible
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-details-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-details">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-details">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-details-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmldetailselement" data-dfn-type="interface"><c- g="">HTMLDetailsElement</c-></dfn> : <a href="#htmlelement" id="the-details-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-details-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-details-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-details-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLDetailsElement" id="dom-details-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="the-details-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-details-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLDetailsElement" id="dom-details-open" data-dfn-type="attribute"><c- g="">open</c-></dfn>;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-details-element:the-details-element-2"><a href="#the-details-element">details</a></code> element <a href="#represents" id="the-details-element:represents">represents</a> a disclosure widget from which the
  user can obtain additional information or controls.</p>

  <p class="note">As with all HTML elements, it is not conforming to use the <code id="the-details-element:the-details-element-3"><a href="#the-details-element">details</a></code>
  element when attempting to represent another type of control. For example, tab widgets and
  menu widgets are not disclosure widgets, so abusing the <code id="the-details-element:the-details-element-4"><a href="#the-details-element">details</a></code> element to
  implement these patterns is incorrect.</p>

  <p class="note">The <code id="the-details-element:the-details-element-5"><a href="#the-details-element">details</a></code> element is not appropriate for footnotes. Please see <a href="#footnotes">the section on footnotes</a> for details on how to mark up footnotes.</p>

  <p>The first <code id="the-details-element:the-summary-element-2"><a href="#the-summary-element">summary</a></code> element child of the element, if any,
  <a href="#represents" id="the-details-element:represents-2">represents</a> the summary or legend of the details. If there is no
  child <code id="the-details-element:the-summary-element-3"><a href="#the-summary-element">summary</a></code> element, the user agent should provide its own legend (e.g.
  "Details").</p>

  <p>The rest of the element's contents <a href="#represents" id="the-details-element:represents-3">represents</a> the additional information or
  controls.</p>

  <p>The <dfn data-dfn-for="details" id="attr-details-name" data-dfn-type="element-attr"><code>name</code></dfn> content
  attribute gives the name of the group of related <code id="the-details-element:the-details-element-6"><a href="#the-details-element">details</a></code> elements that the element is
  a member of. Opening one member of this group causes other members of the group to close. If the
  attribute is specified, its value must not be the empty string.</p>

  <p>Before using this feature, authors should consider whether this grouping of related
  <code id="the-details-element:the-details-element-7"><a href="#the-details-element">details</a></code> elements into an exclusive accordion is helpful or harmful to users.
  While using an exclusive accordion can reduce the maximum amount of space that a set of content
  can occupy, it can also frustrate users who have to open many items to find what they want or
  users who want to look at the contents of multiple items at the same time.</p>

  <p>A document must not contain more than one <code id="the-details-element:the-details-element-8"><a href="#the-details-element">details</a></code> element in the same
  <a href="#details-name-group" id="the-details-element:details-name-group">details name group</a> that has the <code id="the-details-element:attr-details-open-2"><a href="#attr-details-open">open</a></code>
  attribute present.  Authors must not use script to add <code id="the-details-element:the-details-element-9"><a href="#the-details-element">details</a></code> elements to a document
  in a way that would cause a <a href="#details-name-group" id="the-details-element:details-name-group-2">details name group</a> to have more than one
  <code id="the-details-element:the-details-element-10"><a href="#the-details-element">details</a></code> element with the <code id="the-details-element:attr-details-open-3"><a href="#attr-details-open">open</a></code> attribute
  present.</p>

  <p class="note">The group of elements that is created by a common <code id="the-details-element:attr-details-name-2"><a href="#attr-details-name">name</a></code> attribute is exclusive, meaning that at most one of the
  <code id="the-details-element:the-details-element-11"><a href="#the-details-element">details</a></code> elements can be open at once.  While this exclusivity is enforced by user
  agents, the resulting enforcement immediately changes the <code id="the-details-element:attr-details-open-4"><a href="#attr-details-open">open</a></code> attributes in the markup.  This requirement on authors
  forbids such misleading markup.</p>

  <p>A document must not contain a <code id="the-details-element:the-details-element-12"><a href="#the-details-element">details</a></code> element that is a descendant of another
  <code id="the-details-element:the-details-element-13"><a href="#the-details-element">details</a></code> element in the same <a href="#details-name-group" id="the-details-element:details-name-group-3">details name group</a>.</p>

  <p>Documents that use the <code id="the-details-element:attr-details-name-3"><a href="#attr-details-name">name</a></code> attribute to group multiple
  related <code id="the-details-element:the-details-element-14"><a href="#the-details-element">details</a></code> elements should keep those related elements together in a containing
  element (such as a <code id="the-details-element:the-section-element"><a href="#the-section-element">section</a></code> element or <code id="the-details-element:the-article-element"><a href="#the-article-element">article</a></code> element). When it makes
  sense for the group to be introduced with a heading, authors should put that heading in a <a href="#concept-heading" id="the-details-element:concept-heading">heading</a> element at the start of the containing element.</p>

  <p class="note">Visually and programmatically grouping related elements together can be important
  for accessible user experiences. This can help users understand the relationship between such
  elements. When related elements are in disparate sections of a web page rather than being grouped,
  the elements' relationships to each other can be less discoverable or understandable.</p>

  <p>The <dfn data-dfn-for="details" id="attr-details-open" data-dfn-type="element-attr"><code>open</code></dfn> content
  attribute is a <a href="#boolean-attribute" id="the-details-element:boolean-attribute">boolean attribute</a>. If present, it indicates that both the summary and
  the additional information is to be shown to the user. If the attribute is absent, only the
  summary is to be shown.</p>

  

  <p>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.</p>

  <p>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 <a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="the-details-element:concept-element-attributes-set-value" data-x-internal="concept-element-attributes-set-value">set</a> the <code id="the-details-element:attr-details-open-5"><a href="#attr-details-open">open</a></code> attribute on the element to the empty string. To honor a
  request for the information to be hidden, the user agent must <a href="https://dom.spec.whatwg.org/#concept-element-attributes-remove" id="the-details-element:concept-element-attributes-remove" data-x-internal="concept-element-attributes-remove">remove</a> the <code id="the-details-element:attr-details-open-6"><a href="#attr-details-open">open</a></code> attribute from the element.</p>

  <p class="note">This ability to request that additional information be shown or hidden
  may simply be the <a id="the-details-element:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> of the appropriate
  <code id="the-details-element:the-summary-element-4"><a href="#the-summary-element">summary</a></code> 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.</p>

  <div data-algorithm="">
  <p>The <dfn id="details-name-group">details name group</dfn> that contains a <code id="the-details-element:the-details-element-15"><a href="#the-details-element">details</a></code> element <var>a</var>
  also contains all the other <code id="the-details-element:the-details-element-16"><a href="#the-details-element">details</a></code> elements <var>b</var> that fulfill all of the
  following conditions:</p>

  <ul><li>Both <var>a</var> and <var>b</var> are in the same <a id="the-details-element:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>.</li><li>They both have a <code id="the-details-element:attr-details-name-4"><a href="#attr-details-name">name</a></code> attribute, their <code id="the-details-element:attr-details-name-5"><a href="#attr-details-name">name</a></code> attributes are not the empty string, and the value of
   <var>a</var>'s <code id="the-details-element:attr-details-name-6"><a href="#attr-details-name">name</a></code> attribute equals the value of
   <var>b</var>'s <code id="the-details-element:attr-details-name-7"><a href="#attr-details-name">name</a></code> attribute.</li></ul>
  </div>

  <p>Every <code id="the-details-element:the-details-element-17"><a href="#the-details-element">details</a></code> element has a <dfn id="details-toggle-task-tracker">details toggle task tracker</dfn>, which is a
  <a href="#toggle-task-tracker" id="the-details-element:toggle-task-tracker">toggle task tracker</a> or null, initially null.</p>

  <div data-algorithm="">
  <p>The following <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="the-details-element:concept-element-attributes-change-ext" data-x-internal="concept-element-attributes-change-ext">attribute change
  steps</a>, given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
  <var>value</var>, and <var>namespace</var>, are used for all <code id="the-details-element:the-details-element-18"><a href="#the-details-element">details</a></code> elements:</p>

  <ol><li><p>If <var>namespace</var> is not null, then return.</p></li><li><p>If <var>localName</var> is <code id="the-details-element:attr-details-name-8"><a href="#attr-details-name">name</a></code>, then <a href="#ensure-details-exclusivity-by-closing-the-given-element-if-needed" id="the-details-element:ensure-details-exclusivity-by-closing-the-given-element-if-needed">ensure
   details exclusivity by closing the given element if needed</a> given
   <var>element</var>.</p></li><li><p>If <var>localName</var> is <code id="the-details-element:attr-details-open-7"><a href="#attr-details-open">open</a></code>, then:
    </p><ol><li>
      <p>If one of <var>oldValue</var> or <var>value</var> is null and the other is not null,
      run the following steps, which are known as the <dfn id="details-notification-task-steps">details notification task steps</dfn>, for
      this <code id="the-details-element:the-details-element-19"><a href="#the-details-element">details</a></code> element:</p>

      <p class="note">When the <code id="the-details-element:attr-details-open-8"><a href="#attr-details-open">open</a></code> attribute is toggled
      several times in succession, the resulting tasks essentially get coalesced so that only one
      event is fired.</p>

      <ol><li><p>If <var>oldValue</var> is null, <a href="#queue-a-details-toggle-event-task" id="the-details-element:queue-a-details-toggle-event-task">queue a details toggle event task</a> given
        the <code id="the-details-element:the-details-element-20"><a href="#the-details-element">details</a></code> element, "<code>closed</code>", and "<code>open</code>".</p></li><li><p>Otherwise, <a href="#queue-a-details-toggle-event-task" id="the-details-element:queue-a-details-toggle-event-task-2">queue a details toggle event task</a> given the
        <code id="the-details-element:the-details-element-21"><a href="#the-details-element">details</a></code> element, "<code>open</code>", and "<code>closed</code>".</p></li></ol>
     </li><li><p>If <var>oldValue</var> is null and <var>value</var> is not null, then <a href="#ensure-details-exclusivity-by-closing-other-elements-if-needed" id="the-details-element:ensure-details-exclusivity-by-closing-other-elements-if-needed">ensure
     details exclusivity by closing other elements if needed</a> given
     <var>element</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-details-element:the-details-element-22"><a href="#the-details-element">details</a></code> <a href="#html-element-insertion-steps" id="the-details-element:html-element-insertion-steps">HTML element insertion
  steps</a>, given <var>insertedNode</var>, are:</p>

  <ol><li><p><a href="#ensure-details-exclusivity-by-closing-the-given-element-if-needed" id="the-details-element:ensure-details-exclusivity-by-closing-the-given-element-if-needed-2">Ensure details exclusivity by closing the given element if needed</a> given
   <var>insertedNode</var>.</p></li></ol>
  </div>

  <p class="note">To be clear, these attribute change and insertion steps also run when an attribute
  or element is inserted via the parser.</p>

  <div data-algorithm="">
  <p>To <dfn id="queue-a-details-toggle-event-task">queue a details toggle event task</dfn> given a <code id="the-details-element:the-details-element-23"><a href="#the-details-element">details</a></code> element
  <var>element</var>, a string <var>oldState</var>, and a string <var>newState</var>:

  </p><ol><li>
    <p>If <var>element</var>'s <a href="#details-toggle-task-tracker" id="the-details-element:details-toggle-task-tracker">details toggle task tracker</a> is not null, then:</p>

    <ol><li><p>Set <var>oldState</var> to <var>element</var>'s <a href="#details-toggle-task-tracker" id="the-details-element:details-toggle-task-tracker-2">details toggle task
     tracker</a>'s <a href="#toggle-task-old-state" id="the-details-element:toggle-task-old-state">old state</a>.</p></li><li><p>Remove <var>element</var>'s <a href="#details-toggle-task-tracker" id="the-details-element:details-toggle-task-tracker-3">details toggle task tracker</a>'s <a href="#toggle-task-task" id="the-details-element:toggle-task-task">task</a> from its <a href="#task-queue" id="the-details-element:task-queue">task queue</a>.</p></li><li><p>Set <var>element</var>'s <a href="#details-toggle-task-tracker" id="the-details-element:details-toggle-task-tracker-4">details toggle task tracker</a> to null.</p></li></ol>
   </li><li>
    <p><a href="#queue-an-element-task" id="the-details-element:queue-an-element-task">Queue an element task</a> given the <a href="#dom-manipulation-task-source" id="the-details-element:dom-manipulation-task-source">DOM manipulation task source</a> and
    <var>element</var> to run the following steps:</p>

    <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-details-element:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-details-element:event-toggle"><a href="#event-toggle">toggle</a></code> at <var>element</var>, using <code id="the-details-element:toggleevent"><a href="#toggleevent">ToggleEvent</a></code>, with
     the <code id="the-details-element:dom-toggleevent-oldstate"><a href="#dom-toggleevent-oldstate">oldState</a></code> attribute initialized to
     <var>oldState</var> and the <code id="the-details-element:dom-toggleevent-newstate"><a href="#dom-toggleevent-newstate">newState</a></code> attribute
     initialized to <var>newState</var>.</p></li><li><p>Set <var>element</var>'s <a href="#details-toggle-task-tracker" id="the-details-element:details-toggle-task-tracker-5">details toggle task tracker</a> to null.</p></li></ol>
   </li><li><p>Set <var>element</var>'s <a href="#details-toggle-task-tracker" id="the-details-element:details-toggle-task-tracker-6">details toggle task tracker</a> to a struct with <a href="#toggle-task-task" id="the-details-element:toggle-task-task-2">task</a> set to the just-queued <a href="#concept-task" id="the-details-element:concept-task">task</a> and <a href="#toggle-task-old-state" id="the-details-element:toggle-task-old-state-2">old state</a> set
   to <var>oldState</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="ensure-details-exclusivity-by-closing-other-elements-if-needed">ensure details exclusivity by closing other elements if needed</dfn> given a
  <code id="the-details-element:the-details-element-24"><a href="#the-details-element">details</a></code> element <var>element</var>:</p>

  <ol><li><p><a id="the-details-element:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>element</var> has an <code id="the-details-element:attr-details-open-9"><a href="#attr-details-open">open</a></code> attribute.</p></li><li><p>If <var>element</var> does not have a <code id="the-details-element:attr-details-name-9"><a href="#attr-details-name">name</a></code>
   attribute, or its <code id="the-details-element:attr-details-name-10"><a href="#attr-details-name">name</a></code> attribute is the empty string,
   then return.</p></li><li><p>Let <var>groupMembers</var> be a list of elements, containing all elements in
   <var>element</var>'s <a href="#details-name-group" id="the-details-element:details-name-group-4">details name group</a> except for <var>element</var>, in <a id="the-details-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
   order</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-details-element:list-iterate" data-x-internal="list-iterate">For each</a> element <var>otherElement</var> of
    <var>groupMembers</var>:</p>
    <ol><li>
      <p>If the <code id="the-details-element:attr-details-open-10"><a href="#attr-details-open">open</a></code> attribute is set on
      <var>otherElement</var>, then:</p>

      <ol><li><p><a id="the-details-element:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>otherElement</var> is the only element in
       <var>groupMembers</var> that has the <code id="the-details-element:attr-details-open-11"><a href="#attr-details-open">open</a></code> attribute
       set.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-remove" id="the-details-element:concept-element-attributes-remove-2" data-x-internal="concept-element-attributes-remove">Remove</a> the <code id="the-details-element:attr-details-open-12"><a href="#attr-details-open">open</a></code> attribute on <var>otherElement</var>.</p></li><li><p><a id="the-details-element:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">Break</a>.</p></li></ol>
    </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="ensure-details-exclusivity-by-closing-the-given-element-if-needed">ensure details exclusivity by closing the given element if needed</dfn> given a
  <code id="the-details-element:the-details-element-25"><a href="#the-details-element">details</a></code> element <var>element</var>:</p>

  <ol><li><p>If <var>element</var> does not have an <code id="the-details-element:attr-details-open-13"><a href="#attr-details-open">open</a></code>
   attribute, then return.</p></li><li><p>If <var>element</var> does not have a <code id="the-details-element:attr-details-name-11"><a href="#attr-details-name">name</a></code>
   attribute, or its <code id="the-details-element:attr-details-name-12"><a href="#attr-details-name">name</a></code> attribute is the empty string,
   then return.</p></li><li><p>Let <var>groupMembers</var> be a list of elements, containing all elements in
   <var>element</var>'s <a href="#details-name-group" id="the-details-element:details-name-group-5">details name group</a> except for <var>element</var>, in <a id="the-details-element:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
   order</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-details-element:list-iterate-2" data-x-internal="list-iterate">For each</a> element <var>otherElement</var> of
    <var>groupMembers</var>:</p>

    <ol><li>
      <p>If the <code id="the-details-element:attr-details-open-14"><a href="#attr-details-open">open</a></code> attribute is set on
      <var>otherElement</var>, then:</p>

      <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-remove" id="the-details-element:concept-element-attributes-remove-3" data-x-internal="concept-element-attributes-remove">Remove</a> the <code id="the-details-element:attr-details-open-15"><a href="#attr-details-open">open</a></code> attribute on <var>element</var>.</p></li><li><p><a id="the-details-element:break-2" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">Break</a>.</p></li></ol>
     </li></ol>
   </li></ol>
  </div>

  

  <div class="example">

   <p>The following example shows the <code id="the-details-element:the-details-element-26"><a href="#the-details-element">details</a></code> element being used to hide technical
   details in a progress report.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"progress window"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Copying "Really Achieving Your Childhood Dreams"<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">summary</c-><c- p="">&gt;</c->Copying... <c- p="">&lt;</c-><c- f="">progress</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">"375505392"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"97543282"</c-><c- p="">&gt;&lt;/</c-><c- f="">progress</c-><c- p="">&gt;</c-> 25%<c- p="">&lt;/</c-><c- f="">summary</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Transfer rate:<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->452KB/s<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Local filename:<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->/home/rpausch/raycd.m4v<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Remote filename:<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->/var/www/lectures/raycd.m4v<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Duration:<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->01:16:27<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Color profile:<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->SD (6-1-6)<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Dimensions:<c- p="">&lt;/</c-><c- f="">dt</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->320×240<c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The following shows how a <code id="the-details-element:the-details-element-27"><a href="#the-details-element">details</a></code> element can be used to hide some controls by
   default:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">details</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">summary</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">fn</c-><c- p="">&gt;</c->Name &amp; Extension:<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">summary</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">text</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">fn</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">fn</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Pillar Magazine.pdf"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">ext</c-> <c- e="">checked</c-><c- p="">&gt;</c-> Hide extension<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c-></code></pre>

   <p>One could use this in conjunction with other <code id="the-details-element:the-details-element-28"><a href="#the-details-element">details</a></code> in a list to allow the user
   to collapse a set of fields down to a small set of headings, with the ability to open each
   one.</p>

   <p class="details-example"><img src="/images/sample-details-1.png" width="345" alt="" height="611"><img src="/images/sample-details-2.png" width="345" alt="" height="666"></p>

   <p>In these examples, the summary really just summarizes what the controls can change, and not
   the actual values, which is less than ideal.</p>

  </div>

  <div id="example-details-exclusive-accordion" class="example"><a href="#example-details-exclusive-accordion" class="self-link"></a>
   <p>The following example shows the <code id="the-details-element:attr-details-name-13"><a href="#attr-details-name">name</a></code> attribute of the
   <code id="the-details-element:the-details-element-29"><a href="#the-details-element">details</a></code> element being used to create an exclusive accordion, a set of
   <code id="the-details-element:the-details-element-30"><a href="#the-details-element">details</a></code> elements where a user action to open one <code id="the-details-element:the-details-element-31"><a href="#the-details-element">details</a></code> element causes
   any open <code id="the-details-element:the-details-element-32"><a href="#the-details-element">details</a></code> to close.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"characteristics"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"frame-characteristics"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">summary</c-><c- p="">&gt;</c->Material<c- p="">&lt;/</c-><c- f="">summary</c-><c- p="">&gt;</c->
  The picture frame is made of solid oak wood.
 <c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"frame-characteristics"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">summary</c-><c- p="">&gt;</c->Size<c- p="">&lt;/</c-><c- f="">summary</c-><c- p="">&gt;</c->
  The picture frame fits a photo 40cm tall and 30cm wide.
  The frame is 45cm tall, 35cm wide, and 2cm thick.
 <c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"frame-characteristics"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">summary</c-><c- p="">&gt;</c->Color<c- p="">&lt;/</c-><c- f="">summary</c-><c- p="">&gt;</c->
  The picture frame is available in its natural wood
  color, or with black stain.
 <c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div id="example-details-exclusive-accordion-setting-open" class="example"><a href="#example-details-exclusive-accordion-setting-open" class="self-link"></a>
   <p>The following example shows what happens when the <code id="the-details-element:attr-details-open-16"><a href="#attr-details-open">open</a></code>
   attribute is set on a <code id="the-details-element:the-details-element-33"><a href="#the-details-element">details</a></code> element that is part of a set of elements using the
   <code id="the-details-element:attr-details-name-14"><a href="#attr-details-name">name</a></code> attribute to create an exclusive accordion.</p>

   <p>Given the initial markup:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"characteristics"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"frame-characteristics"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"d1"</c-> <c- e="">open</c-><c- p="">&gt;</c->...<c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"frame-characteristics"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"d2"</c-><c- p="">&gt;</c->...<c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"frame-characteristics"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"d3"</c-><c- p="">&gt;</c->...<c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>and the script:</p>

   <pre><code class="js">document<c- p="">.</c->getElementById<c- p="">(</c-><c- u="">"d2"</c-><c- p="">).</c->setAttribute<c- p="">(</c-><c- u="">"open"</c-><c- p="">,</c-> <c- u="">""</c-><c- p="">);</c-></code></pre>

   <p>then the resulting tree after the script executes will be equivalent to the markup:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"characteristics"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"frame-characteristics"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"d1"</c-><c- p="">&gt;</c->...<c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"frame-characteristics"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"d2"</c-> <c- e="">open</c-><c- p="">&gt;</c->...<c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">details</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"frame-characteristics"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"d3"</c-><c- p="">&gt;</c->...<c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>because setting the <code id="the-details-element:attr-details-open-17"><a href="#attr-details-open">open</a></code> attribute on <code>d2</code> removes it from <code>d1</code>.</p>

   <p>The same happens when the user activates the <code id="the-details-element:the-summary-element-5"><a href="#the-summary-element">summary</a></code> element inside of <code>d2</code>.</p>
  </div>

  <div class="example">

   <p>Because the <code id="the-details-element:attr-details-open-18"><a href="#attr-details-open">open</a></code> attribute is added and removed
   automatically as the user interacts with the control, it can be used in CSS to style the element
   differently based on its state. Here, a style sheet is used to animate the color of the summary
   when the element is opened or closed:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
 <c- f="">details</c-> <c- o="">&gt;</c-> <c- f="">summary</c-> <c- p="">{</c-> <c- k="">transition</c-><c- p="">:</c-> <c- kc="">color</c-> <c- mi="">1</c-><c- b="">s</c-><c- p="">;</c-> <c- k="">color</c-><c- p="">:</c-> <c- kc="">black</c-><c- p="">;</c-> <c- p="">}</c->
 <c- f="">details</c-><c- o="">[</c-><c- f="">open</c-><c- o="">]</c-> <c- o="">&gt;</c-> <c- f="">summary</c-> <c- p="">{</c-> <c- k="">color</c-><c- p="">:</c-> <c- kc="">red</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">details</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">summary</c-><c- p="">&gt;</c->Automated Status: Operational<c- p="">&lt;/</c-><c- f="">summary</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Velocity: 12m/s<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Direction: North<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">details</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="the-summary-element"><span class="secno">4.11.2</span> The <dfn data-dfn-type="element"><code>summary</code></dfn> element<a href="#the-summary-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary" title="The <summary> HTML element specifies a summary, caption, or legend for a <details> element's disclosure box. Clicking the <summary> element toggles the state of the parent <details> element open and closed.">Element/summary</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>12+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-summary-element:concept-element-categories">Categories</a>:</dt><dd>None.</dd><dt><a href="#concept-element-contexts" id="the-summary-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>As the <a id="the-summary-element:first-child" href="https://dom.spec.whatwg.org/#concept-tree-first-child" data-x-internal="first-child">first child</a> of a <code id="the-summary-element:the-details-element"><a href="#the-details-element">details</a></code> element.</dd><dt><a href="#concept-element-content-model" id="the-summary-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#phrasing-content-2" id="the-summary-element:phrasing-content-2">Phrasing content</a>, optionally intermixed with <a href="#heading-content-2" id="the-summary-element:heading-content-2">heading content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-summary-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-summary-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-summary-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-summary-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-summary">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-summary">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-summary-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-summary-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-summary-element:the-summary-element"><a href="#the-summary-element">summary</a></code> element <a href="#represents" id="the-summary-element:represents">represents</a> a summary, caption, or legend for the
  rest of the contents of the <code id="the-summary-element:the-summary-element-2"><a href="#the-summary-element">summary</a></code> element's parent <code id="the-summary-element:the-details-element-2"><a href="#the-details-element">details</a></code>
  element, if any.</p>

  

  <div data-algorithm="">
  <p>A <code id="the-summary-element:the-summary-element-3"><a href="#the-summary-element">summary</a></code> element is a <dfn id="summary-for-its-parent-details">summary for its parent details</dfn> if the following
  algorithm returns true:</p>

  <ol><li><p>If this <code id="the-summary-element:the-summary-element-4"><a href="#the-summary-element">summary</a></code> element has no parent, then return false.</p></li><li><p>Let <var>parent</var> be this <code id="the-summary-element:the-summary-element-5"><a href="#the-summary-element">summary</a></code> element's parent.</p></li><li><p>If <var>parent</var> is not a <code id="the-summary-element:the-details-element-3"><a href="#the-details-element">details</a></code> element, then return false.</p></li><li><p>If <var>parent</var>'s first <code id="the-summary-element:the-summary-element-6"><a href="#the-summary-element">summary</a></code> element child is not this
   <code id="the-summary-element:the-summary-element-7"><a href="#the-summary-element">summary</a></code> element, then return false.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-summary-element:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> of <code id="the-summary-element:the-summary-element-8"><a href="#the-summary-element">summary</a></code> elements is to run the following
  steps:</p>

  <ol><li><p>If this <code id="the-summary-element:the-summary-element-9"><a href="#the-summary-element">summary</a></code> element is not the <a href="#summary-for-its-parent-details" id="the-summary-element:summary-for-its-parent-details">summary for its parent
   details</a>, then return.</p></li><li><p>Let <var>parent</var> be this <code id="the-summary-element:the-summary-element-10"><a href="#the-summary-element">summary</a></code> element's parent.</p></li><li>
    <p>If the <code id="the-summary-element:attr-details-open"><a href="#attr-details-open">open</a></code> attribute is present on
    <var>parent</var>, then <a href="https://dom.spec.whatwg.org/#concept-element-attributes-remove" id="the-summary-element:concept-element-attributes-remove" data-x-internal="concept-element-attributes-remove">remove</a> it.
    Otherwise, <a href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value" id="the-summary-element:concept-element-attributes-set-value" data-x-internal="concept-element-attributes-set-value">set</a> <var>parent</var>'s
    <code id="the-summary-element:attr-details-open-2"><a href="#attr-details-open">open</a></code> attribute to the empty string.</p>

    <p class="note">This will then run the <a href="#details-notification-task-steps" id="the-summary-element:details-notification-task-steps">details notification task steps</a>.</p>
   </li></ol>
  </div>

  




  <h4 id="commands"><span class="secno">4.11.3</span> Commands<a href="#commands" class="self-link"></a></h4>

  <h5 id="facets-2"><span class="secno">4.11.3.1</span> Facets<a href="#facets-2" class="self-link"></a></h5>

  <p>A <dfn id="concept-command">command</dfn> is the abstraction behind menu items, buttons, and
  links. Once a command is defined, other parts of the interface can refer to the same command,
  allowing many access points to a single feature to share facets such as the <a href="#command-facet-disabledstate" id="facets-2:command-facet-disabledstate">Disabled State</a>.</p>

  <p id="facets">Commands are defined to have the following <dfn id="concept-facet">facets</dfn>:</p>

  <dl><dt><dfn id="command-facet-label">Label</dfn></dt><dd>The name of the command as seen by the user.</dd><dt><dfn id="command-facet-accesskey">Access Key</dfn></dt><dd>A key combination selected by the user agent that triggers the command. A command might not
   have an Access Key.</dd><dt><dfn id="command-facet-hiddenstate">Hidden State</dfn></dt><dd>Whether the command is hidden or not (basically, whether it should be shown in menus).</dd><dt><dfn id="command-facet-disabledstate">Disabled State</dfn></dt><dd>Whether the command is relevant and can be triggered or not.</dd><dt><dfn id="command-facet-action">Action</dfn></dt><dd>The actual effect that triggering the command will have. This could be a scripted event
   handler, a <a id="facets-2:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> to which to <a href="#navigate" id="facets-2:navigate">navigate</a>, or a form submission.</dd></dl>

  <div data-algorithm="">
  <p id="expose-commands-in-ui">User agents may expose the <a href="#concept-command" id="facets-2:concept-command">commands</a> that match the following criteria:</p>

  <ul><li><p>The <a href="#command-facet-hiddenstate" id="facets-2:command-facet-hiddenstate">Hidden State</a> facet is false
   (visible)</p></li><li><p>The element is <a id="facets-2:in-a-document" href="https://dom.spec.whatwg.org/#in-a-document" data-x-internal="in-a-document">in a document</a> with a non-null <a href="#concept-document-bc" id="facets-2:concept-document-bc">browsing context</a>.</p></li><li><p>Neither the element nor any of its ancestors has a <code id="facets-2:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute specified.</p></li></ul>
  </div>

  <p>User agents are encouraged to do this especially for commands that have <a href="#command-facet-accesskey" id="facets-2:command-facet-accesskey">Access Keys</a>, as a way to advertise those keys to the
  user.</p>

  <p class="example">For example, such commands could be listed in the user agent's menu bar.</p>


  

  <h5 id="using-the-a-element-to-define-a-command"><span class="secno">4.11.3.2</span> <dfn>Using the <code>a</code> element to define a command</dfn><a href="#using-the-a-element-to-define-a-command" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>An <code id="using-the-a-element-to-define-a-command:the-a-element"><a href="#the-a-element">a</a></code> element with an <code id="using-the-a-element-to-define-a-command:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute <a href="#concept-command" id="using-the-a-element-to-define-a-command:concept-command">defines a command</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-label" id="using-the-a-element-to-define-a-command:command-facet-label">Label</a> of the command is the element's
  <a id="using-the-a-element-to-define-a-command:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-accesskey" id="using-the-a-element-to-define-a-command:command-facet-accesskey">Access Key</a> of the command is the element's
  <a href="#assigned-access-key" id="using-the-a-element-to-define-a-command:assigned-access-key">assigned access key</a>, if any.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-hiddenstate" id="using-the-a-element-to-define-a-command:command-facet-hiddenstate">Hidden State</a> of the command is true (hidden)
  if the element has a <code id="using-the-a-element-to-define-a-command:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute, and false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-disabledstate" id="using-the-a-element-to-define-a-command:command-facet-disabledstate">Disabled State</a> facet of the command is
  true if the element or one of its ancestors is <a href="#inert" id="using-the-a-element-to-define-a-command:inert">inert</a>, and false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-action" id="using-the-a-element-to-define-a-command:command-facet-action">Action</a> of the command is to <a href="#fire-a-click-event" id="using-the-a-element-to-define-a-command:fire-a-click-event">fire a <code>click</code> event</a> at the element.</p>
  </div>


  <h5 id="using-the-button-element-to-define-a-command"><span class="secno">4.11.3.3</span> <dfn>Using the <code>button</code> element to define a command</dfn><a href="#using-the-button-element-to-define-a-command" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A <code id="using-the-button-element-to-define-a-command:the-button-element"><a href="#the-button-element">button</a></code> element always <a href="#concept-command" id="using-the-button-element-to-define-a-command:concept-command">defines a
  command</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-label" id="using-the-button-element-to-define-a-command:command-facet-label">Label</a>, <a href="#command-facet-accesskey" id="using-the-button-element-to-define-a-command:command-facet-accesskey">Access Key</a>, <a href="#command-facet-hiddenstate" id="using-the-button-element-to-define-a-command:command-facet-hiddenstate">Hidden State</a>, and <a href="#command-facet-action" id="using-the-button-element-to-define-a-command:command-facet-action">Action</a> facets of the command are determined <a href="#using-the-a-element-to-define-a-command" id="using-the-button-element-to-define-a-command:using-the-a-element-to-define-a-command">as for <code>a</code> elements</a> (see the previous section).</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-disabledstate" id="using-the-button-element-to-define-a-command:command-facet-disabledstate">Disabled State</a> of the command is true if
  the element or one of its ancestors is <a href="#inert" id="using-the-button-element-to-define-a-command:inert">inert</a>, or if the element's <a href="#concept-fe-disabled" id="using-the-button-element-to-define-a-command:concept-fe-disabled">disabled</a> state is set, and false otherwise.</p>
  </div>


  <h5 id="using-the-input-element-to-define-a-command"><span class="secno">4.11.3.4</span> <dfn>Using the <code>input</code> element to define a command</dfn><a href="#using-the-input-element-to-define-a-command" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>An <code id="using-the-input-element-to-define-a-command:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="using-the-input-element-to-define-a-command:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  one of the <a href="#submit-button-state-(type=submit)" id="using-the-input-element-to-define-a-command:submit-button-state-(type=submit)">Submit Button</a>, <a href="#reset-button-state-(type=reset)" id="using-the-input-element-to-define-a-command:reset-button-state-(type=reset)">Reset Button</a>, <a href="#image-button-state-(type=image)" id="using-the-input-element-to-define-a-command:image-button-state-(type=image)">Image
  Button</a>, <a href="#button-state-(type=button)" id="using-the-input-element-to-define-a-command:button-state-(type=button)">Button</a>, <a href="#radio-button-state-(type=radio)" id="using-the-input-element-to-define-a-command:radio-button-state-(type=radio)">Radio Button</a>, or <a href="#checkbox-state-(type=checkbox)" id="using-the-input-element-to-define-a-command:checkbox-state-(type=checkbox)">Checkbox</a> states <a href="#concept-command" id="using-the-input-element-to-define-a-command:concept-command">defines a
  command</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-label" id="using-the-input-element-to-define-a-command:command-facet-label">Label</a> of the command is determined as
  follows:</p>

  <ol><li><p>If the <code id="using-the-input-element-to-define-a-command:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in one of the
    <a href="#submit-button-state-(type=submit)" id="using-the-input-element-to-define-a-command:submit-button-state-(type=submit)-2">Submit Button</a>, <a href="#reset-button-state-(type=reset)" id="using-the-input-element-to-define-a-command:reset-button-state-(type=reset)-2">Reset Button</a>, <a href="#image-button-state-(type=image)" id="using-the-input-element-to-define-a-command:image-button-state-(type=image)-2">Image
    Button</a>, or <a href="#button-state-(type=button)" id="using-the-input-element-to-define-a-command:button-state-(type=button)-2">Button</a> states, then the
    <a href="#command-facet-label" id="using-the-input-element-to-define-a-command:command-facet-label-2">Label</a> is the string given by the
    <code id="using-the-input-element-to-define-a-command:attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if any, and a UA-dependent,
    locale-dependent value that the UA uses to label the button itself if the attribute is
    absent.</p></li><li><p>Otherwise, if the element is a <a href="#labeled-control" id="using-the-input-element-to-define-a-command:labeled-control">labeled control</a>, then the <a href="#command-facet-label" id="using-the-input-element-to-define-a-command:command-facet-label-3">Label</a> is the <a id="using-the-input-element-to-define-a-command:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a> of the
    first <code id="using-the-input-element-to-define-a-command:the-label-element"><a href="#the-label-element">label</a></code> element in <a id="using-the-input-element-to-define-a-command:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> whose <a href="#labeled-control" id="using-the-input-element-to-define-a-command:labeled-control-2">labeled control</a>
    is the element in question. (In JavaScript terms, this is given by <code>element.labels[0].textContent</code>.)</p></li><li><p>Otherwise, if the <code id="using-the-input-element-to-define-a-command:attr-input-value-2"><a href="#attr-input-value">value</a></code> attribute is present, then
    the <a href="#command-facet-label" id="using-the-input-element-to-define-a-command:command-facet-label-4">Label</a> is the value of that attribute.</p></li><li><p>Otherwise, the <a href="#command-facet-label" id="using-the-input-element-to-define-a-command:command-facet-label-5">Label</a> is the empty string.</p></li></ol>
  </div>

  <div class="note">
    <p>Even though the <code id="using-the-input-element-to-define-a-command:attr-input-value-3"><a href="#attr-input-value">value</a></code> attribute on
    <code id="using-the-input-element-to-define-a-command:the-input-element-2"><a href="#the-input-element">input</a></code> elements in the <a href="#image-button-state-(type=image)" id="using-the-input-element-to-define-a-command:image-button-state-(type=image)-3">Image Button</a>
    state is non-conformant, the attribute can still contribute to the <a href="#command-facet-label" id="using-the-input-element-to-define-a-command:command-facet-label-6">Label</a> determination, if it is present and the Image Button's
    <code id="using-the-input-element-to-define-a-command:attr-input-alt"><a href="#attr-input-alt">alt</a></code> attribute is missing.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-accesskey" id="using-the-input-element-to-define-a-command:command-facet-accesskey">Access Key</a> of the command is the element's
  <a href="#assigned-access-key" id="using-the-input-element-to-define-a-command:assigned-access-key">assigned access key</a>, if any.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-hiddenstate" id="using-the-input-element-to-define-a-command:command-facet-hiddenstate">Hidden State</a> of the command is true (hidden)
  if the element has a <code id="using-the-input-element-to-define-a-command:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute, and false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-disabledstate" id="using-the-input-element-to-define-a-command:command-facet-disabledstate">Disabled State</a> of the command is true if
  the element or one of its ancestors is <a href="#inert" id="using-the-input-element-to-define-a-command:inert">inert</a>, or if the element's <a href="#concept-fe-disabled" id="using-the-input-element-to-define-a-command:concept-fe-disabled">disabled</a> state is set, and false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-action" id="using-the-input-element-to-define-a-command:command-facet-action">Action</a> of the command is to <a href="#fire-a-click-event" id="using-the-input-element-to-define-a-command:fire-a-click-event">fire a <code>click</code> event</a> at the element.</p>
  </div>


  <h5 id="using-the-option-element-to-define-a-command"><span class="secno">4.11.3.5</span> <dfn>Using the <code>option</code> element to define a command</dfn><a href="#using-the-option-element-to-define-a-command" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>An <code id="using-the-option-element-to-define-a-command:the-option-element"><a href="#the-option-element">option</a></code> element with an ancestor <code id="using-the-option-element-to-define-a-command:the-select-element"><a href="#the-select-element">select</a></code> element and either no <code id="using-the-option-element-to-define-a-command:attr-option-value"><a href="#attr-option-value">value</a></code> attribute or a <code id="using-the-option-element-to-define-a-command:attr-option-value-2"><a href="#attr-option-value">value</a></code>
  attribute that is not the empty string <a href="#concept-command" id="using-the-option-element-to-define-a-command:concept-command">defines a command</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-label" id="using-the-option-element-to-define-a-command:command-facet-label">Label</a> of the command is the value of the
  <code id="using-the-option-element-to-define-a-command:the-option-element-2"><a href="#the-option-element">option</a></code> element's <code id="using-the-option-element-to-define-a-command:attr-option-label"><a href="#attr-option-label">label</a></code> attribute, if there is
  one, or else the <code id="using-the-option-element-to-define-a-command:the-option-element-3"><a href="#the-option-element">option</a></code> element's <a id="using-the-option-element-to-define-a-command:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a>, with <a href="https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace" id="using-the-option-element-to-define-a-command:strip-and-collapse-ascii-whitespace" data-x-internal="strip-and-collapse-ascii-whitespace">ASCII whitespace stripped and collapsed</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-accesskey" id="using-the-option-element-to-define-a-command:command-facet-accesskey">Access Key</a> of the command is the element's
  <a href="#assigned-access-key" id="using-the-option-element-to-define-a-command:assigned-access-key">assigned access key</a>, if any.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-hiddenstate" id="using-the-option-element-to-define-a-command:command-facet-hiddenstate">Hidden State</a> of the command is true (hidden)
  if the element has a <code id="using-the-option-element-to-define-a-command:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute, and false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-disabledstate" id="using-the-option-element-to-define-a-command:command-facet-disabledstate">Disabled State</a> of the command is true if
  the element is <a href="#concept-option-disabled" id="using-the-option-element-to-define-a-command:concept-option-disabled">disabled</a>, or if its nearest ancestor
  <code id="using-the-option-element-to-define-a-command:the-select-element-2"><a href="#the-select-element">select</a></code> element is <a href="#concept-fe-disabled" id="using-the-option-element-to-define-a-command:concept-fe-disabled">disabled</a>, or if it or one
  of its ancestors is <a href="#inert" id="using-the-option-element-to-define-a-command:inert">inert</a>, and false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>If the <code id="using-the-option-element-to-define-a-command:the-option-element-4"><a href="#the-option-element">option</a></code>'s nearest ancestor <code id="using-the-option-element-to-define-a-command:the-select-element-3"><a href="#the-select-element">select</a></code> element has a <code id="using-the-option-element-to-define-a-command:attr-select-multiple"><a href="#attr-select-multiple">multiple</a></code> attribute, the <a href="#command-facet-action" id="using-the-option-element-to-define-a-command:command-facet-action">Action</a> of the command is to <a href="#concept-select-toggle" id="using-the-option-element-to-define-a-command:concept-select-toggle">toggle</a> the <code id="using-the-option-element-to-define-a-command:the-option-element-5"><a href="#the-option-element">option</a></code> element. Otherwise, the <a href="#command-facet-action" id="using-the-option-element-to-define-a-command:command-facet-action-2">Action</a> is to <a href="#concept-select-pick" id="using-the-option-element-to-define-a-command:concept-select-pick">pick</a> the <code id="using-the-option-element-to-define-a-command:the-option-element-6"><a href="#the-option-element">option</a></code> element.</p>
  </div>


  <h5 id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command"><span class="secno">4.11.3.6</span> <dfn>Using the <code>accesskey</code> attribute
  on a <code>legend</code> element to define a command</dfn><a href="#using-the-accesskey-attribute-on-a-legend-element-to-define-a-command" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A <code id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:the-legend-element"><a href="#the-legend-element">legend</a></code> element <a href="#concept-command" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:concept-command">defines a command</a> if all of
  the following are true:</p>

  <ul><li><p>It has an <a href="#assigned-access-key" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:assigned-access-key">assigned access key</a>.</p></li><li><p>It is a child of a <code id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code> element.</p></li><li><p>Its parent has a descendant that <a href="#concept-command" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:concept-command-2">defines a command</a>
   that is neither a <code id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:the-label-element"><a href="#the-label-element">label</a></code> element nor a <code id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:the-legend-element-2"><a href="#the-legend-element">legend</a></code> element. This element,
   if it exists, is <dfn id="the-legend-element's-accesskey-delegatee">the <code>legend</code> element's <code>accesskey</code>
   delegatee</dfn>.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-label" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:command-facet-label">Label</a> of the command is the element's
  <a id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-accesskey" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:command-facet-accesskey">Access Key</a> of the command is the element's
  <a href="#assigned-access-key" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:assigned-access-key-2">assigned access key</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-hiddenstate" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:command-facet-hiddenstate">Hidden State</a>, <a href="#command-facet-disabledstate" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:command-facet-disabledstate">Disabled State</a>, and <a href="#command-facet-action" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:command-facet-action">Action</a> facets of the command are the same as the respective
  facets of <a href="#the-legend-element's-accesskey-delegatee" id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:the-legend-element's-accesskey-delegatee">the <code>legend</code> element's <code>accesskey</code> delegatee</a>.</p>
  </div>

  <div class="example">
   <p>In this example, the <code id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:the-legend-element-3"><a href="#the-legend-element">legend</a></code> element specifies an <code id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:the-accesskey-attribute"><a href="#the-accesskey-attribute">accesskey</a></code>, which, when activated, will delegate to the
   <code id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:the-input-element"><a href="#the-input-element">input</a></code> element inside the <code id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:the-legend-element-4"><a href="#the-legend-element">legend</a></code> element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">legend</c-> <c- e="">accesskey</c-><c- o="">=</c-><c- s="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->I want <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">pizza</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">1</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">1</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-><c- p="">&gt;</c->
   pizza(s) with these toppings<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">pizza-cheese</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">checked</c-><c- p="">&gt;</c-> Cheese<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">pizza-ham</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">checked</c-><c- p="">&gt;</c-> Ham<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">pizza-pineapple</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Pineapple<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h5 id="using-the-accesskey-attribute-to-define-a-command-on-other-elements"><span class="secno">4.11.3.7</span> <dfn>Using the <code>accesskey</code>
  attribute to define a command on other elements</dfn><a href="#using-the-accesskey-attribute-to-define-a-command-on-other-elements" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>An element that has an <a href="#assigned-access-key" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:assigned-access-key">assigned access key</a> <a href="#concept-command" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:concept-command">defines a
  command</a>.</p>
  </div>

  <p>If one of the earlier sections that define elements that <a href="#concept-command" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:concept-command-2">define
  commands</a> define that this element <a href="#concept-command" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:concept-command-3">defines a command</a>,
  then that section applies to this element, and this section does not. Otherwise, this section
  applies to that element.</p>

  <div data-algorithm="">
  <p>The <a href="#command-facet-label" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:command-facet-label">Label</a> of the command depends on the element. If
  the element is a <a href="#labeled-control" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:labeled-control">labeled control</a>, the <a id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a> of the
  first <code id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:the-label-element"><a href="#the-label-element">label</a></code> element in <a id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> whose <a href="#labeled-control" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:labeled-control-2">labeled control</a> is
  the element in question is the <a href="#command-facet-label" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:command-facet-label-2">Label</a> (in JavaScript
  terms, this is given by <code>element.labels[0].textContent</code>).
  Otherwise, the <a href="#command-facet-label" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:command-facet-label-3">Label</a> is the element's <a id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:descendant-text-content-2" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant
  text content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-accesskey" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:command-facet-accesskey">Access Key</a> of the command is the element's
  <a href="#assigned-access-key" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:assigned-access-key-2">assigned access key</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-hiddenstate" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:command-facet-hiddenstate">Hidden State</a> of the command is true (hidden)
  if the element has a <code id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute, and false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-disabledstate" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:command-facet-disabledstate">Disabled State</a> of the command is true if
  the element or one of its ancestors is <a href="#inert" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:inert">inert</a>, and false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-facet-action" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:command-facet-action">Action</a> of the command is to run the following
  steps:</p>

  <ol><li>Run the <a href="#focusing-steps" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:focusing-steps">focusing steps</a> for the element.</li><li><a href="#fire-a-click-event" id="using-the-accesskey-attribute-to-define-a-command-on-other-elements:fire-a-click-event">Fire a <code>click</code> event</a> at the element.</li></ol>
  </div>

  


  <h4 id="the-dialog-element"><span class="secno">4.11.4</span> The <dfn data-dfn-type="element"><code>dialog</code></dfn> element<a href="#the-dialog-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog" title="The <dialog> HTML element represents a dialog box or other interactive component, such as a dismissible alert, inspector, or subwindow.">Element/dialog</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement" title="The HTMLDialogElement interface provides methods to manipulate <dialog> elements. It inherits properties and methods from the HTMLElement interface.">HTMLDialogElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/open" title="The open property of the HTMLDialogElement interface is a boolean value reflecting the open HTML attribute, indicating whether the <dialog> is available for interaction.">HTMLDialogElement/open</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-dialog-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-dialog-element:flow-content-2">Flow content</a>.</dd><dt><a href="#concept-element-contexts" id="the-dialog-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#flow-content-2" id="the-dialog-element:flow-content-2-2">flow content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-dialog-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#flow-content-2" id="the-dialog-element:flow-content-2-3">Flow content</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-dialog-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-dialog-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-dialog-element:global-attributes">Global attributes</a></dd><dd><code id="the-dialog-element:attr-dialog-closedby"><a href="#attr-dialog-closedby">closedby</a></code> —  Which user actions will close the dialog
     </dd><dd><code id="the-dialog-element:attr-dialog-open"><a href="#attr-dialog-open">open</a></code> —  Whether the dialog box is showing
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-dialog-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-dialog">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-dialog">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-dialog-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmldialogelement" data-dfn-type="interface"><c- g="">HTMLDialogElement</c-></dfn> : <a href="#htmlelement" id="the-dialog-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-dialog-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-dialog-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-dialog-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLDialogElement" id="dom-dialog-open" data-dfn-type="attribute"><c- g="">open</c-></dfn>;
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-dialog-returnvalue" id="the-dialog-element:dom-dialog-returnvalue"><c- g="">returnValue</c-></a>;
  [<a href="#cereactions" id="the-dialog-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflectsetter" id="the-dialog-element:xattr-reflectsetter"><c- g="">ReflectSetter</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-dialog-closedby" id="the-dialog-element:dom-dialog-closedby"><c- g="">closedBy</c-></a>;
  [<a href="#cereactions" id="the-dialog-element:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-dialog-show" id="the-dialog-element:dom-dialog-show"><c- g="">show</c-></a>();
  [<a href="#cereactions" id="the-dialog-element:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-dialog-showmodal" id="the-dialog-element:dom-dialog-showmodal"><c- g="">showModal</c-></a>();
  [<a href="#cereactions" id="the-dialog-element:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-dialog-close" id="the-dialog-element:dom-dialog-close"><c- g="">close</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">returnValue</c->);
  [<a href="#cereactions" id="the-dialog-element:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-dialog-requestclose" id="the-dialog-element:dom-dialog-requestclose"><c- g="">requestClose</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">returnValue</c->);
};</code></pre>
   </dd></dl>

  <p>The <code id="the-dialog-element:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> element represents a transitory part of an application, in the form of
  a small window ("dialog box"), which the user interacts with to perform a task or gather
  information. Once the user is done, the dialog can be automatically closed by the application, or
  manually closed by the user.</p>

  <p>Especially for modal dialogs, which are a familiar pattern across all types of applications,
  authors should work to ensure that dialogs in their web applications behave in a way that is
  familiar to users of non-web applications.</p>

  <p class="note">As with all HTML elements, it is not conforming to use the <code id="the-dialog-element:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code>
  element when attempting to represent another type of control. For example, context menus,
  tooltips, and popup listboxes are not dialog boxes, so abusing the <code id="the-dialog-element:the-dialog-element-3"><a href="#the-dialog-element">dialog</a></code> element to
  implement these patterns is incorrect.</p>

  <p>An important part of user-facing dialog behavior is the placement of initial focus. The
  <a href="#dialog-focusing-steps" id="the-dialog-element:dialog-focusing-steps">dialog focusing steps</a> attempt to pick a good candidate for initial focus when a
  dialog is shown, but might not be a substitute for authors carefully thinking through the correct
  choice to match user expectations for a specific dialog. As such, authors should use the <code id="the-dialog-element:attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code> attribute on the descendant element of the dialog that
  the user is expected to immediately interact with after the dialog opens. If there is no such
  element, then authors should use the <code id="the-dialog-element:attr-fe-autofocus-2"><a href="#attr-fe-autofocus">autofocus</a></code> attribute
  on the <code id="the-dialog-element:the-dialog-element-4"><a href="#the-dialog-element">dialog</a></code> element itself.</p>

  <div class="example">
   <p>In the following example, a dialog is used for editing the details of a product in an
   inventory management web application.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dialog</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Product Number <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">readonly</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Product Name <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">autofocus</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dialog</c-><c- p="">&gt;</c-></code></pre>

   <p>If the <code id="the-dialog-element:attr-fe-autofocus-3"><a href="#attr-fe-autofocus">autofocus</a></code> attribute was not present, the
   Product Number field would have been focused by the dialog focusing steps. Although that is
   reasonable behavior, the author determined that the more relevant field to focus was the Product
   Name field, as the Product Number field is readonly and expects no user input. So, the author
   used autofocus to override the default.</p>

   <p>Even if the author wants to focus the Product Number field by default, they are best off
   explicitly specifying that by using autofocus on that <code id="the-dialog-element:the-input-element"><a href="#the-input-element">input</a></code> element. This makes the
   intent obvious to future readers of the code, and ensures the code stays robust in the face of
   future updates. (For example, if another developer added a close button, and positioned it in the
   node tree before the Product Number field).</p>
  </div>

  <p>Another important aspect of user behavior is whether dialogs are scrollable or not. In some
  cases, overflow (and thus scrollability) cannot be avoided, e.g., when it is caused by the user's
  high text zoom settings. But in general, scrollable dialogs are not expected by users. Adding
  large text nodes directly to dialog elements is particularly bad as this is likely to cause the
  dialog element itself to overflow. Authors are best off avoiding them.</p>

  <div class="example">
   <p>The following terms of service dialog respects the above suggestions.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dialog</c-> <c- e="">style</c-><c- o="">=</c-><c- s="">"height: 80vh;"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">style</c-><c- o="">=</c-><c- s="">"overflow: auto; height: 60vh;"</c-> <c- e="">autofocus</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->By placing an order via this Web site on the first day of the fourth month of the year
    2010 Anno Domini, you agree to grant Us a non-transferable option to claim, for now and for
    ever more, your immortal soul.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Should We wish to exercise this option, you agree to surrender your immortal soul,
    and any claim you may have on it, within 5 (five) working days of receiving written
    notification from  this site or one of its duly authorized minions.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- c="">&lt;!-- ... etc., with many more &lt;p&gt; elements ... --&gt;</c->
  <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"dialog"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"submit"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"agree"</c-><c- p="">&gt;</c->Agree<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"submit"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"disagree"</c-><c- p="">&gt;</c->Disagree<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dialog</c-><c- p="">&gt;</c-></code></pre>

   <p>Note how the <a href="#dialog-focusing-steps" id="the-dialog-element:dialog-focusing-steps-2">dialog focusing steps</a> would have picked the scrollable
   <code id="the-dialog-element:the-div-element"><a href="#the-div-element">div</a></code> element by default, but similarly to the previous example, we have placed <code id="the-dialog-element:attr-fe-autofocus-4"><a href="#attr-fe-autofocus">autofocus</a></code> on the <code id="the-dialog-element:the-div-element-2"><a href="#the-div-element">div</a></code> so as to be more explicit and
   robust against future changes.</p>

   <p>In contrast, if the <code id="the-dialog-element:the-p-element"><a href="#the-p-element">p</a></code> elements expressing the terms of service did not have such
   a wrapper <code id="the-dialog-element:the-div-element-3"><a href="#the-div-element">div</a></code> element, then the <code id="the-dialog-element:the-dialog-element-5"><a href="#the-dialog-element">dialog</a></code> itself would become scrollable,
   violating the above advice. Furthermore, in the absence of any <code id="the-dialog-element:attr-fe-autofocus-5"><a href="#attr-fe-autofocus">autofocus</a></code> attribute, such a markup pattern would have violated
   the above advice and tripped up the <a href="#dialog-focusing-steps" id="the-dialog-element:dialog-focusing-steps-3">dialog focusing steps</a>'s default behavior, and
   caused focus to jump to the Agree <code id="the-dialog-element:the-button-element"><a href="#the-button-element">button</a></code>, which is a bad user experience.</p>
  </div>

  <div class="example">
   <p>This dialog box has some small print. The <code id="the-dialog-element:the-strong-element"><a href="#the-strong-element">strong</a></code> element is used to draw the
   user's attention to the more important part.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dialog</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Add to Wallet<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">amt</c-><c- p="">&gt;</c->How many gold coins do you want to add to your wallet?<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">amt</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">amt</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">number</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">step</c-><c- o="">=</c-><c- s="">0.01</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">100</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->You add coins at your own risk.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">round</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-><c- p="">&gt;</c-> Only add perfectly round coins<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"submit()"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Add Coins"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dialog</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <hr>

  <p>The <dfn data-dfn-for="dialog" id="attr-dialog-open" data-dfn-type="element-attr"><code>open</code></dfn> attribute
  is a <a href="#boolean-attribute" id="the-dialog-element:boolean-attribute">boolean attribute</a>. When specified, it indicates that the <code id="the-dialog-element:the-dialog-element-6"><a href="#the-dialog-element">dialog</a></code>
  element is active and that the user can interact with it.</p>

  <p>The <dfn data-dfn-for="dialog" id="attr-dialog-closedby" data-dfn-type="element-attr"><code>closedby</code></dfn>
  content attribute is an <a href="#enumerated-attribute" id="the-dialog-element:enumerated-attribute">enumerated attribute</a> with the following keywords and
  states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="dialog/closedby" id="attr-dialog-closedby-any" data-dfn-type="attr-value"><code>any</code></dfn>
     </td><td><dfn id="attr-dialog-closedby-any-state">Any</dfn>
     </td><td><a href="#close-request" id="the-dialog-element:close-request">Close requests</a> or clicks outside close the dialog.
    </td></tr><tr><td><dfn data-dfn-for="dialog/closedby" id="attr-dialog-closedby-closerequest" data-dfn-type="attr-value"><code>closerequest</code></dfn>
     </td><td><dfn id="attr-dialog-closedby-closerequest-state">Close Request</dfn>
     </td><td><a href="#close-request" id="the-dialog-element:close-request-2">Close requests</a> close the dialog.
    </td></tr><tr><td><dfn data-dfn-for="dialog/closedby" id="attr-dialog-closedby-none" data-dfn-type="attr-value"><code>none</code></dfn>
     </td><td><dfn id="attr-dialog-closedby-none-state">None</dfn>
     </td><td>No user actions automatically close the dialog.
  </td></tr></tbody></table>

  <p>The <code id="the-dialog-element:attr-dialog-closedby-2"><a href="#attr-dialog-closedby">closedby</a></code> attribute's <i id="the-dialog-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> and <i id="the-dialog-element:missing-value-default"><a href="#missing-value-default">missing value
  default</a></i> are both the <dfn id="attr-dialog-closedby-auto-state">Auto</dfn> state.</p>

  <p class="note">The <a href="#attr-dialog-closedby-auto-state" id="the-dialog-element:attr-dialog-closedby-auto-state">Auto</a> state behaves as
  <a href="#attr-dialog-closedby-closerequest-state" id="the-dialog-element:attr-dialog-closedby-closerequest-state">Close Request</a> state when the
  <code id="the-dialog-element:the-dialog-element-7"><a href="#the-dialog-element">dialog</a></code> was shown using its <code id="the-dialog-element:dom-dialog-showmodal-2"><a href="#dom-dialog-showmodal">showModal()</a></code>
  method; otherwise the <a href="#attr-dialog-closedby-none-state" id="the-dialog-element:attr-dialog-closedby-none-state">None</a> state.</p>

  

  <p>A <code id="the-dialog-element:the-dialog-element-8"><a href="#the-dialog-element">dialog</a></code> element without an <code id="the-dialog-element:attr-dialog-open-2"><a href="#attr-dialog-open">open</a></code> attribute
  specified should not be shown to the user. This requirement may be implemented indirectly through
  the style layer. For example, user agents that <a href="#renderingUA">support the suggested
  default rendering</a> implement this requirement using the CSS rules described in the <a href="#rendering">Rendering section</a>.</p>

  

  <div id="note-dialog-remove-open-attribute" class="note"><a href="#note-dialog-remove-open-attribute" class="self-link"></a>
   <p>Removing the <code id="the-dialog-element:attr-dialog-open-3"><a href="#attr-dialog-open">open</a></code> attribute will usually hide the
   dialog. However, doing so has a number of strange additional consequences:

   </p><ul><li><p>The <code id="the-dialog-element:event-close"><a href="#event-close">close</a></code> event will not be fired.</p></li><li><p>The <code id="the-dialog-element:dom-dialog-close-2"><a href="#dom-dialog-close">close()</a></code> method, and any <a href="#close-request" id="the-dialog-element:close-request-3">close requests</a>, will no longer be able to close the dialog.</p></li><li><p>If the dialog was shown using its <code id="the-dialog-element:dom-dialog-showmodal-3"><a href="#dom-dialog-showmodal">showModal()</a></code>
    method, the <code id="the-dialog-element:document"><a href="#document">Document</a></code> will still be <a href="#blocked-by-a-modal-dialog" id="the-dialog-element:blocked-by-a-modal-dialog">blocked</a>.</p></li></ul>

   <p>For these reasons, it is generally better to never remove the <code id="the-dialog-element:attr-dialog-open-4"><a href="#attr-dialog-open">open</a></code> attribute manually. Instead, use the <code id="the-dialog-element:dom-dialog-requestclose-2"><a href="#dom-dialog-requestclose">requestClose()</a></code> or <code id="the-dialog-element:dom-dialog-close-3"><a href="#dom-dialog-close">close()</a></code> methods to close the dialog, or the <code id="the-dialog-element:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute to hide it.</p>
  </div>

  <p>The <code id="the-dialog-element:attr-tabindex"><a href="#attr-tabindex">tabindex</a></code> attribute must not be specified on
  <code id="the-dialog-element:the-dialog-element-9"><a href="#the-dialog-element">dialog</a></code> elements.</p>

  <hr>

  <dl class="domintro"><dt><code><var>dialog</var>.<a href="#dom-dialog-show" id="dom-dialog-show-dev">show</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/show" title="The show() method of the HTMLDialogElement interface displays the dialog modelessly, i.e. still allowing interaction with content outside of the dialog.">HTMLDialogElement/show</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Displays the <code id="the-dialog-element:the-dialog-element-10"><a href="#the-dialog-element">dialog</a></code> element.</p></dd><dt><code><var>dialog</var>.<a href="#dom-dialog-showmodal" id="dom-dialog-showmodal-dev">showModal</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/showModal" title="The showModal() method of the HTMLDialogElement interface displays the dialog as a modal, over the top of any other dialogs that might be present. It displays in the top layer, along with a ::backdrop pseudo-element. Interaction outside the dialog is blocked and the content outside it is rendered inert.">HTMLDialogElement/showModal</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Displays the <code id="the-dialog-element:the-dialog-element-11"><a href="#the-dialog-element">dialog</a></code> element and makes it the top-most modal dialog.</p>

    <p>This method honors the <code id="the-dialog-element:attr-fe-autofocus-6"><a href="#attr-fe-autofocus">autofocus</a></code> attribute.</p>
   </dd><dt><code><var>dialog</var>.<a href="#dom-dialog-close" id="dom-dialog-close-dev">close</a>([ <var>result</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/close" title="The close() method of the HTMLDialogElement interface closes the <dialog>. An optional string may be passed as an argument, updating the returnValue of the dialog.">HTMLDialogElement/close</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Closes the <code id="the-dialog-element:the-dialog-element-12"><a href="#the-dialog-element">dialog</a></code> element.</p>

    <p>The argument, if provided, provides a return value.</p>
   </dd><dt><code><var>dialog</var>.<a href="#dom-dialog-requestclose" id="dom-dialog-requestclose-dev">requestClose</a>([ <var>result</var> ])</code></dt><dd>
    <p>Acts as if a <a href="#close-request" id="the-dialog-element:close-request-4">close request</a> was sent targeting
    <var>dialog</var>, by first firing a <code id="the-dialog-element:event-cancel"><a href="#event-cancel">cancel</a></code> event, and if
    that event is not canceled with <code id="the-dialog-element:dom-event-preventdefault"><a data-x-internal="dom-event-preventdefault" href="https://dom.spec.whatwg.org/#dom-event-preventdefault">preventDefault()</a></code>,
    proceeding to close the <var>dialog</var> in the same way as the <code id="the-dialog-element:dom-dialog-close-4"><a href="#dom-dialog-close">close()</a></code> method (including firing a <code id="the-dialog-element:event-close-2"><a href="#event-close">close</a></code> event).</p>

    <p>This is a helper utility that can be used to consolidate cancelation and closing logic into
    the <code id="the-dialog-element:event-cancel-2"><a href="#event-cancel">cancel</a></code> and <code id="the-dialog-element:event-close-3"><a href="#event-close">close</a></code> event
    handlers, by having all non-<a href="#close-request" id="the-dialog-element:close-request-5">close request</a> closing
    affordances call this method.</p>

    <p>Note that this method ignores the <code id="the-dialog-element:attr-dialog-closedby-3"><a href="#attr-dialog-closedby">closedby</a></code>
    attribute: that is, even if <code id="the-dialog-element:attr-dialog-closedby-4"><a href="#attr-dialog-closedby">closedby</a></code> is set to
    "<code id="the-dialog-element:attr-dialog-closedby-none"><a href="#attr-dialog-closedby-none">none</a></code>", the same behavior will apply.</p>

    <p>The argument, if provided, provides a return value.</p>
   </dd><dt><code><var>dialog</var>.<a href="#dom-dialog-returnvalue" id="dom-dialog-returnvalue-dev">returnValue</a> [ = <var>result</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue" title="The returnValue property of the HTMLDialogElement interface gets or sets the return value for the <dialog>, usually to indicate which button the user pressed to close it.">HTMLDialogElement/returnValue</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-dialog-element:the-dialog-element-13"><a href="#the-dialog-element">dialog</a></code>'s return value.</p>

    <p>Can be set, to update the return value.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLDialogElement" id="dom-dialog-show" data-dfn-type="method"><code>show()</code></dfn>
  method steps are:</p>

  <ol><li><p>If <a id="the-dialog-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> has an <code id="the-dialog-element:attr-dialog-open-5"><a href="#attr-dialog-open">open</a></code> attribute and
   <a href="#is-modal" id="the-dialog-element:is-modal">is modal</a> of <a id="the-dialog-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is false, then return.</p></li><li><p>If <a id="the-dialog-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> has an <code id="the-dialog-element:attr-dialog-open-6"><a href="#attr-dialog-open">open</a></code> attribute, then
   throw an <a id="the-dialog-element:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-dialog-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-dialog-element:concept-event-fire" data-x-internal="concept-event-fire">firing an event</a> named <code id="the-dialog-element:event-beforetoggle"><a href="#event-beforetoggle">beforetoggle</a></code>, using <code id="the-dialog-element:toggleevent"><a href="#toggleevent">ToggleEvent</a></code>, with the <code id="the-dialog-element:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true, the <code id="the-dialog-element:dom-toggleevent-oldstate"><a href="#dom-toggleevent-oldstate">oldState</a></code> attribute initialized to "<code>closed</code>", and the <code id="the-dialog-element:dom-toggleevent-newstate"><a href="#dom-toggleevent-newstate">newState</a></code>
   attribute initialized to "<code>open</code>" at <a id="the-dialog-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is false, then
   return.</p></li><li><p>If <a id="the-dialog-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> has an <code id="the-dialog-element:attr-dialog-open-7"><a href="#attr-dialog-open">open</a></code> attribute, then
   return.</p></li><li><p><a href="#queue-a-dialog-toggle-event-task" id="the-dialog-element:queue-a-dialog-toggle-event-task">Queue a dialog toggle event task</a> given <a id="the-dialog-element:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, "<code>closed</code>", "<code>open</code>", and null.</p></li><li><p>Add an <code id="the-dialog-element:attr-dialog-open-8"><a href="#attr-dialog-open">open</a></code> attribute to <a id="the-dialog-element:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, whose
   value is the empty string.</p></li><li><p>Set <a id="the-dialog-element:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#previously-focused-element" id="the-dialog-element:previously-focused-element">previously focused element</a> to the
   <a href="#focused" id="the-dialog-element:focused">focused</a> element.</p></li><li><p>Let <var>document</var> be <a id="the-dialog-element:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-dialog-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>Let <var>hideUntil</var> be the result of running <a href="#topmost-popover-ancestor" id="the-dialog-element:topmost-popover-ancestor">topmost popover ancestor</a>
   given <a id="the-dialog-element:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>document</var>'s <a href="#showing-hint-popover-list" id="the-dialog-element:showing-hint-popover-list">showing hint popover list</a>, null, and
   false.</p></li><li><p>If <var>hideUntil</var> is null, then set <var>hideUntil</var> to the result of running
   <a href="#topmost-popover-ancestor" id="the-dialog-element:topmost-popover-ancestor-2">topmost popover ancestor</a> given <a id="the-dialog-element:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>document</var>'s
   <a href="#auto-popover-list" id="the-dialog-element:auto-popover-list">showing auto popover list</a>, null, and false.</p></li><li><p>If <var>hideUntil</var> is null, then set <var>hideUntil</var> to
   <var>document</var>.</p></li><li><p>Run <a href="#hide-all-popovers-until" id="the-dialog-element:hide-all-popovers-until">hide all popovers until</a> given
   <var>hideUntil</var>, false, and true.</p></li><li><p>Run the <a href="#dialog-focusing-steps" id="the-dialog-element:dialog-focusing-steps-4">dialog focusing steps</a> given <a id="the-dialog-element:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLDialogElement" id="dom-dialog-showmodal" data-dfn-type="method"><code>showModal()</code></dfn> method steps are to <a href="#show-a-modal-dialog" id="the-dialog-element:show-a-modal-dialog">show a modal
  dialog</a> given <a id="the-dialog-element:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and null.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLDialogElement" id="dom-dialog-close" data-dfn-type="method"><code>close(<var>returnValue</var>)</code></dfn> method steps are:

  </p><ol><li><p>If <var>returnValue</var> is not given, then set it to null.</p></li><li><p><a href="#close-the-dialog" id="the-dialog-element:close-the-dialog">Close the dialog</a> <a id="the-dialog-element:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> with <var>returnValue</var> and
   null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLDialogElement" id="dom-dialog-requestclose" data-dfn-type="method"><code>requestClose(<var>returnValue</var>)</code></dfn> method steps
  are:</p>

  <ol><li><p>If <var>returnValue</var> is not given, then set it to null.</p></li><li><p><a href="#dialog-request-close" id="the-dialog-element:dialog-request-close">Request to close the dialog</a> <a id="the-dialog-element:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>
   with <var>returnValue</var> and null.</p></li></ol>
  </div>

  <div id="note-dialog-method-names" class="note"><a href="#note-dialog-method-names" class="self-link"></a>
   <p>We use show/close as the verbs for <code id="the-dialog-element:the-dialog-element-14"><a href="#the-dialog-element">dialog</a></code> elements, as opposed to verb pairs that
   are more commonly thought of as antonyms such as show/hide or open/close, due to the following
   constraints:</p>

   <ul><li><p>Hiding a dialog is different from closing one. Closing a dialog gives it a return value,
    fires an event, unblocks the page for other dialogs, and so on. Whereas hiding a dialog is a
    purely visual property, and is something you can already do with the <code id="the-dialog-element:attr-hidden-2"><a href="#attr-hidden">hidden</a></code> attribute or by removing the <code id="the-dialog-element:attr-dialog-open-9"><a href="#attr-dialog-open">open</a></code> attribute. (See also the <a href="#note-dialog-remove-open-attribute">note above</a> about removing the <code id="the-dialog-element:attr-dialog-open-10"><a href="#attr-dialog-open">open</a></code> attribute, and how hiding the dialog in that way is
    generally not desired.)</p></li><li><p>Showing a dialog is different from opening one. Opening a dialog consists of creating
    and showing that dialog (similar to how <code id="the-dialog-element:dom-open"><a href="#dom-open">window.open()</a></code> both
    creates and shows a new window). Whereas showing the dialog is the process of taking a
    <code id="the-dialog-element:the-dialog-element-15"><a href="#the-dialog-element">dialog</a></code> element that is already in the DOM, and making it interactive and visible
    to the user.</p></li><li><p>If we were to have a <code>dialog.open()</code> method despite the above, it
    would conflict with the <code id="the-dialog-element:dom-dialog-open"><a href="#dom-dialog-open">dialog.open</a></code> property.</p></li></ul>

   <p>Furthermore, a <a href="https://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-December/041799.html">survey</a>
   of many other UI frameworks contemporary to the original design of the <code id="the-dialog-element:the-dialog-element-16"><a href="#the-dialog-element">dialog</a></code>
   element made it clear that the show/close verb pair was reasonably common.</p>

   <p>In summary, it turns out that the implications of certain verbs, and how they are used in
   technology contexts, mean that paired actions such as showing and closing a dialog are not
   always expressible as antonyms.</p>
  </div>


  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLDialogElement" id="dom-dialog-returnvalue" data-dfn-type="attribute"><code>returnValue</code></dfn> 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.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLDialogElement" id="dom-dialog-closedby" data-dfn-type="attribute"><code>closedBy</code></dfn> getter steps are to return the keyword
  corresponding to the <a href="#computed-closed-by-state" id="the-dialog-element:computed-closed-by-state">computed closed-by state</a> given <a id="the-dialog-element:this-16" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
  </div>

  <hr>

  <p>Each <code id="the-dialog-element:document-2"><a href="#document">Document</a></code> has a <dfn id="dialog-pointerdown-target">dialog pointerdown target</dfn>, which is an <a href="#htmldialogelement" id="the-dialog-element:htmldialogelement">HTML dialog element</a> or null, initially null.</p>

  <p>Each <a href="#html-elements" id="the-dialog-element:html-elements">HTML element</a> has a <dfn id="previously-focused-element">previously focused
  element</dfn> which is null or an element, and it is initially null. When <code id="the-dialog-element:dom-dialog-showmodal-4"><a href="#dom-dialog-showmodal">showModal()</a></code> and <code id="the-dialog-element:dom-dialog-show-2"><a href="#dom-dialog-show">show()</a></code>
  are called, this element is set to the currently <a href="#focused" id="the-dialog-element:focused-2">focused</a> element before running the
  <a href="#dialog-focusing-steps" id="the-dialog-element:dialog-focusing-steps-5">dialog focusing steps</a>. Elements with the <code id="the-dialog-element:attr-popover"><a href="#attr-popover">popover</a></code>
  attribute set this element to the currently <a href="#focused" id="the-dialog-element:focused-3">focused</a> element during the <a href="#show-popover" id="the-dialog-element:show-popover">show popover algorithm</a>.</p>

  <p>Each <code id="the-dialog-element:the-dialog-element-17"><a href="#the-dialog-element">dialog</a></code> element has a <dfn id="dialog-toggle-task-tracker">dialog toggle task tracker</dfn>, which is a
  <a href="#toggle-task-tracker" id="the-dialog-element:toggle-task-tracker">toggle task tracker</a> or null, initially null.</p>

  <p>Each <code id="the-dialog-element:the-dialog-element-18"><a href="#the-dialog-element">dialog</a></code> element has a <dfn id="dialog-close-watcher">close watcher</dfn>,
  which is a <a href="#close-watcher" id="the-dialog-element:close-watcher">close watcher</a> or null, initially null.</p>

  <p>Each <code id="the-dialog-element:the-dialog-element-19"><a href="#the-dialog-element">dialog</a></code> element has a <dfn id="request-close-return-value">request close return value</dfn>, which is a
  string or null, initially null.</p>

  <p>Each <code id="the-dialog-element:the-dialog-element-20"><a href="#the-dialog-element">dialog</a></code> element has a <dfn id="request-close-source-element">request close source element</dfn>, which is an
  <code id="the-dialog-element:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or null, initially null.</p>

  <p>Each <code id="the-dialog-element:the-dialog-element-21"><a href="#the-dialog-element">dialog</a></code> element has an <dfn id="enable-close-watcher-for-requestclose()">enable close watcher for request close</dfn> boolean,
  initially false.</p>

  <p class="note"><code id="the-dialog-element:the-dialog-element-22"><a href="#the-dialog-element">dialog</a></code>'s <a href="#enable-close-watcher-for-requestclose()" id="the-dialog-element:enable-close-watcher-for-requestclose()">enable close watcher for request close</a> is used
  to force enable the dialog's <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher">close watcher</a> while <a href="#dialog-request-close" id="the-dialog-element:dialog-request-close-2">requesting to close</a> it. A dialog whose <a href="#computed-closed-by-state" id="the-dialog-element:computed-closed-by-state-2">computed
  closed-by state</a> is the <a href="#attr-dialog-closedby-none-state" id="the-dialog-element:attr-dialog-closedby-none-state-2">None</a> state
  would otherwise have a disabled <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher-2">close watcher</a>.</p>

  <p>Each <code id="the-dialog-element:the-dialog-element-23"><a href="#the-dialog-element">dialog</a></code> element has an <dfn id="is-modal">is modal</dfn> boolean, initially false.</p>

  <hr>

  <div data-algorithm="">
  <p>The <code id="the-dialog-element:the-dialog-element-24"><a href="#the-dialog-element">dialog</a></code> <a href="#html-element-insertion-steps" id="the-dialog-element:html-element-insertion-steps">HTML element insertion steps</a>, given
  <var>insertedNode</var>, are:</p>

  <ol><li><p>If <var>insertedNode</var>'s <a id="the-dialog-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="the-dialog-element:fully-active">fully active</a>,
   then return.</p></li><li><p>If <var>insertedNode</var> has an <code id="the-dialog-element:attr-dialog-open-11"><a href="#attr-dialog-open">open</a></code> attribute
   and is <a id="the-dialog-element:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then run the <a href="#dialog-setup-steps" id="the-dialog-element:dialog-setup-steps">dialog setup steps</a> given
   <var>insertedNode</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-dialog-element:the-dialog-element-25"><a href="#the-dialog-element">dialog</a></code> <a href="#html-element-removing-steps" id="the-dialog-element:html-element-removing-steps">HTML element removing steps</a>, given <var>removedNode</var>
  and <var>oldParent</var>, are:</p>

  <ol><li><p>If <var>removedNode</var> has an <code id="the-dialog-element:attr-dialog-open-12"><a href="#attr-dialog-open">open</a></code> attribute,
   then run the <a href="#dialog-cleanup-steps" id="the-dialog-element:dialog-cleanup-steps">dialog cleanup steps</a> given <var>removedNode</var>.</p></li><li><p>If <var>removedNode</var>'s <a id="the-dialog-element:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a id="the-dialog-element:top-layer" href="https://drafts.csswg.org/css-position-4/#document-top-layer" data-x-internal="top-layer">top layer</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="the-dialog-element:list-contains" data-x-internal="list-contains">contains</a> <var>removedNode</var>, then <a id="the-dialog-element:remove-an-element-from-the-top-layer-immediately" href="https://drafts.csswg.org/css-position-4/#remove-an-element-from-the-top-layer-immediately" data-x-internal="remove-an-element-from-the-top-layer-immediately">remove an element from
   the top layer immediately</a> given <var>removedNode</var>.</p></li><li><p>Set <a href="#is-modal" id="the-dialog-element:is-modal-2">is modal</a> of <var>removedNode</var> to false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The following <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="the-dialog-element:concept-element-attributes-change-ext" data-x-internal="concept-element-attributes-change-ext">attribute change
  steps</a>, given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
  <var>value</var>, and <var>namespace</var> are used for <code id="the-dialog-element:the-dialog-element-26"><a href="#the-dialog-element">dialog</a></code> elements:</p>

  <ol><li><p>If <var>namespace</var> is not null, then return.</p></li><li><p>If <var>localName</var> is not <code id="the-dialog-element:attr-dialog-open-13"><a href="#attr-dialog-open">open</a></code>, then
   return.</p></li><li><p>If <var>value</var> is null and <var>oldValue</var> is not null, then run the
   <a href="#dialog-cleanup-steps" id="the-dialog-element:dialog-cleanup-steps-2">dialog cleanup steps</a> given <var>element</var>.</p></li><li><p>If <var>element</var>'s <a id="the-dialog-element:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="the-dialog-element:fully-active-2">fully active</a>, then
   return.</p></li><li>
    <p>If <var>element</var> is not <a id="the-dialog-element:connected-2" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p>

    <p class="note">This ensures that the dialog setup steps are not run on nodes that are
    disconnected, which would result in a <a href="#close-watcher" id="the-dialog-element:close-watcher-2">close watcher</a> being established. The
    <a href="#dialog-cleanup-steps" id="the-dialog-element:dialog-cleanup-steps-3">dialog cleanup steps</a> need no such guard.</p>
   </li><li><p>If <var>value</var> is not null and <var>oldValue</var> is null, then run the
   <a href="#dialog-setup-steps" id="the-dialog-element:dialog-setup-steps-2">dialog setup steps</a> given <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="show-a-modal-dialog">show a modal dialog</dfn> given a <code id="the-dialog-element:the-dialog-element-27"><a href="#the-dialog-element">dialog</a></code> element <var>subject</var> and an
  <code id="the-dialog-element:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or null <var>source</var>:</p>

  <ol><li><p>If <var>subject</var> has an <code id="the-dialog-element:attr-dialog-open-14"><a href="#attr-dialog-open">open</a></code> attribute and
   <a href="#is-modal" id="the-dialog-element:is-modal-3">is modal</a> of <var>subject</var> is true, then return.</p></li><li><p>If <var>subject</var> has an <code id="the-dialog-element:attr-dialog-open-15"><a href="#attr-dialog-open">open</a></code> attribute, then
   throw an <a id="the-dialog-element:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-dialog-element:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>subject</var>'s <a id="the-dialog-element:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="the-dialog-element:fully-active-3">fully active</a>, then
   throw an <a id="the-dialog-element:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-dialog-element:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>subject</var> is not <a id="the-dialog-element:connected-3" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then throw an
   <a id="the-dialog-element:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-dialog-element:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>subject</var> is in the <a href="#popover-showing-state" id="the-dialog-element:popover-showing-state">popover showing
   state</a>, then throw an <a id="the-dialog-element:invalidstateerror-5" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="the-dialog-element:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-dialog-element:concept-event-fire-2" data-x-internal="concept-event-fire">firing an event</a> named <code id="the-dialog-element:event-beforetoggle-2"><a href="#event-beforetoggle">beforetoggle</a></code>, using <code id="the-dialog-element:toggleevent-2"><a href="#toggleevent">ToggleEvent</a></code>, with the <code id="the-dialog-element:dom-event-cancelable-2"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true, the <code id="the-dialog-element:dom-toggleevent-oldstate-2"><a href="#dom-toggleevent-oldstate">oldState</a></code> attribute initialized to "<code>closed</code>", the <code id="the-dialog-element:dom-toggleevent-newstate-2"><a href="#dom-toggleevent-newstate">newState</a></code>
   attribute initialized to "<code>open</code>", and the <code id="the-dialog-element:dom-toggleevent-source"><a href="#dom-toggleevent-source">source</a></code> attribute initialized to <var>source</var> at
   <var>subject</var> is false, then return.</p></li><li><p>If <var>subject</var> has an <code id="the-dialog-element:attr-dialog-open-16"><a href="#attr-dialog-open">open</a></code> attribute,
   then return.</p></li><li><p>If <var>subject</var> is not <a id="the-dialog-element:connected-4" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li><p>If <var>subject</var> is in the <a href="#popover-showing-state" id="the-dialog-element:popover-showing-state-2">popover showing
   state</a>, then return.</p></li><li><p><a href="#queue-a-dialog-toggle-event-task" id="the-dialog-element:queue-a-dialog-toggle-event-task-2">Queue a dialog toggle event task</a> given <var>subject</var>, "<code>closed</code>", "<code>open</code>", and <var>source</var>.</p></li><li><p>Add an <code id="the-dialog-element:attr-dialog-open-17"><a href="#attr-dialog-open">open</a></code> attribute to <var>subject</var>, whose
   value is the empty string.</p></li><li><p><a id="the-dialog-element:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>subject</var>'s <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher-3">close
   watcher</a> is not null.</p></li><li><p>Set <a href="#is-modal" id="the-dialog-element:is-modal-4">is modal</a> of <var>subject</var> to true.</p></li><li>
    <p>Set <var>subject</var>'s <a id="the-dialog-element:node-document-6" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> to be <a href="#blocked-by-a-modal-dialog" id="the-dialog-element:blocked-by-a-modal-dialog-2">blocked by the modal dialog</a> <var>subject</var>.</p>

    <p id="note-dialog-plus-focus-fixup" class="note"><a href="#note-dialog-plus-focus-fixup" class="self-link"></a>This will cause the <a href="#focused-area-of-the-document" id="the-dialog-element:focused-area-of-the-document">focused area of the
    document</a> to become <a href="#inert" id="the-dialog-element:inert">inert</a> (unless that currently focused area is a
    <a id="the-dialog-element:shadow-including-descendant" href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant" data-x-internal="shadow-including-descendant">shadow-including descendant</a> of <var>subject</var>). In such cases, the
    <a href="#focused-area-of-the-document" id="the-dialog-element:focused-area-of-the-document-2">focused area of the document</a> will soon be <a href="#focus-fixup-rule">reset</a> to
    the <a id="the-dialog-element:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>. In a couple steps we will attempt to find a better candidate to
    focus.</p>
   </li><li><p>If <var>subject</var>'s <a id="the-dialog-element:node-document-7" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a id="the-dialog-element:top-layer-2" href="https://drafts.csswg.org/css-position-4/#document-top-layer" data-x-internal="top-layer">top layer</a> does not
   already <a href="https://infra.spec.whatwg.org/#list-contain" id="the-dialog-element:list-contains-2" data-x-internal="list-contains">contain</a> <var>subject</var>, then <a id="the-dialog-element:add-an-element-to-the-top-layer" href="https://drafts.csswg.org/css-position-4/#add-an-element-to-the-top-layer" data-x-internal="add-an-element-to-the-top-layer">add an element
   to the top layer</a> given <var>subject</var>.</p></li><li><p>Set <var>subject</var>'s <a href="#previously-focused-element" id="the-dialog-element:previously-focused-element-2">previously focused element</a> to the
   <a href="#focused" id="the-dialog-element:focused-4">focused</a> element.</p></li><li><p>Let <var>document</var> be <var>subject</var>'s <a id="the-dialog-element:node-document-8" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>Let <var>hideUntil</var> be the result of running <a href="#topmost-popover-ancestor" id="the-dialog-element:topmost-popover-ancestor-3">topmost popover ancestor</a>
   given <var>subject</var>, <var>document</var>'s <a href="#showing-hint-popover-list" id="the-dialog-element:showing-hint-popover-list-2">showing hint popover list</a>, null, and
   false.</p></li><li><p>If <var>hideUntil</var> is null, then set <var>hideUntil</var> to the result of running
   <a href="#topmost-popover-ancestor" id="the-dialog-element:topmost-popover-ancestor-4">topmost popover ancestor</a> given <var>subject</var>, <var>document</var>'s
   <a href="#auto-popover-list" id="the-dialog-element:auto-popover-list-2">showing auto popover list</a>, null, and false.</p></li><li><p>If <var>hideUntil</var> is null, then set <var>hideUntil</var> to
   <var>document</var>.</p></li><li><p>Run <a href="#hide-all-popovers-until" id="the-dialog-element:hide-all-popovers-until-2">hide all popovers until</a> given
   <var>hideUntil</var>, false, and true.</p></li><li><p>Run the <a href="#dialog-focusing-steps" id="the-dialog-element:dialog-focusing-steps-6">dialog focusing steps</a> given <var>subject</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="canceling-dialogs">To <dfn id="set-the-dialog-close-watcher">set the dialog close watcher</dfn>, given a <code id="the-dialog-element:the-dialog-element-28"><a href="#the-dialog-element">dialog</a></code>
  element <var>dialog</var>:</p>

  <ol><li><p><a id="the-dialog-element:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>dialog</var>'s <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher-4">close
   watcher</a> is null.</p></li><li><p><a id="the-dialog-element:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>dialog</var> has an <code id="the-dialog-element:attr-dialog-open-18"><a href="#attr-dialog-open">open</a></code>
   attribute and <var>dialog</var>'s <a id="the-dialog-element:node-document-9" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is <a href="#fully-active" id="the-dialog-element:fully-active-4">fully active</a>.</p>
   </li><li>
    <p>Set <var>dialog</var>'s <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher-5">close watcher</a> to the
    result of <a href="#establish-a-close-watcher" id="the-dialog-element:establish-a-close-watcher">establishing a close watcher</a> given
    <var>dialog</var>'s <a href="#concept-relevant-global" id="the-dialog-element:concept-relevant-global">relevant global object</a>, with:</p>

    <ul><li><p><i id="the-dialog-element:create-close-watcher-cancelaction"><a href="#create-close-watcher-cancelaction">cancelAction</a></i> given
     <var>canPreventClose</var> being to return the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-dialog-element:concept-event-fire-3" data-x-internal="concept-event-fire">firing an event</a> named <code id="the-dialog-element:event-cancel-3"><a href="#event-cancel">cancel</a></code> at <var>dialog</var>, with the <code id="the-dialog-element:dom-event-cancelable-3"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to
     <var>canPreventClose</var>.</p></li><li><p><i id="the-dialog-element:create-close-watcher-closeaction"><a href="#create-close-watcher-closeaction">closeAction</a></i> being to <a href="#close-the-dialog" id="the-dialog-element:close-the-dialog-2">close the
     dialog</a> given <var>dialog</var>, <var>dialog</var>'s <a href="#request-close-return-value" id="the-dialog-element:request-close-return-value">request close return
     value</a>, and <var>dialog</var>'s <a href="#request-close-source-element" id="the-dialog-element:request-close-source-element">request close source element</a>.</p></li><li><p><i id="the-dialog-element:create-close-watcher-getenabledstate"><a href="#create-close-watcher-getenabledstate">getEnabledState</a></i> being to return
     true if <var>dialog</var>'s <a href="#enable-close-watcher-for-requestclose()" id="the-dialog-element:enable-close-watcher-for-requestclose()-2">enable close watcher for request close</a> is true or
     <var>dialog</var>'s <a href="#computed-closed-by-state" id="the-dialog-element:computed-closed-by-state-3">computed closed-by state</a> is not <a href="#attr-dialog-closedby-none-state" id="the-dialog-element:attr-dialog-closedby-none-state-3">None</a>; otherwise false.</p></li></ul>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#is-valid-command-steps" id="the-dialog-element:is-valid-command-steps">is valid command steps</a> for <code id="the-dialog-element:the-dialog-element-29"><a href="#the-dialog-element">dialog</a></code> elements, given a <code id="the-dialog-element:attr-button-command"><a href="#attr-button-command">command</a></code> attribute <var>command</var>, are:</p>

  <ol><li><p>If <var>command</var> is in the <a href="#attr-button-command-close-state" id="the-dialog-element:attr-button-command-close-state">Close</a> state, the <a href="#attr-button-command-request-close-state" id="the-dialog-element:attr-button-command-request-close-state">Request Close</a> state, or the <a href="#attr-button-command-show-modal-state" id="the-dialog-element:attr-button-command-show-modal-state">Show Modal</a> state, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#command-steps" id="the-dialog-element:command-steps">command steps</a> for <code id="the-dialog-element:the-dialog-element-30"><a href="#the-dialog-element">dialog</a></code> elements, given an element
  <var>element</var>, an element <var>source</var>, and a <code id="the-dialog-element:attr-button-command-2"><a href="#attr-button-command">command</a></code> attribute <var>command</var>, are:</p>

  <ol><li><p>If <var>element</var> is in the <a href="#popover-showing-state" id="the-dialog-element:popover-showing-state-3">popover showing</a> state, then return.</p></li><li><p>If <var>command</var> is in the <a href="#attr-button-command-close-state" id="the-dialog-element:attr-button-command-close-state-2">Close</a> state and <var>element</var> has an <code id="the-dialog-element:attr-dialog-open-19"><a href="#attr-dialog-open">open</a></code> attribute, then <a href="#close-the-dialog" id="the-dialog-element:close-the-dialog-3">close the dialog</a>
   <var>element</var> with <var>source</var>'s <a href="#concept-fe-optional-value" id="the-dialog-element:concept-fe-optional-value">optional
   value</a> and <var>source</var>.</p></li><li><p>If <var>command</var> is in the <a href="#attr-button-command-request-close-state" id="the-dialog-element:attr-button-command-request-close-state-2">Request Close</a> state and
   <var>element</var> has an <code id="the-dialog-element:attr-dialog-open-20"><a href="#attr-dialog-open">open</a></code> attribute, then <a href="#dialog-request-close" id="the-dialog-element:dialog-request-close-3">request to close the dialog</a> <var>element</var> with
   <var>source</var>'s <a href="#concept-fe-optional-value" id="the-dialog-element:concept-fe-optional-value-2">optional value</a> and
   <var>source</var>.</p></li><li><p>If <var>command</var> is the <a href="#attr-button-command-show-modal-state" id="the-dialog-element:attr-button-command-show-modal-state-2">Show Modal</a> state and <var>element</var> does
   not have an <code id="the-dialog-element:attr-dialog-open-21"><a href="#attr-dialog-open">open</a></code> attribute, then
   <a href="#show-a-modal-dialog" id="the-dialog-element:show-a-modal-dialog-2">show a modal dialog</a> given <var>element</var> and <var>source</var>.</p></li></ol>
  </div>

  <div class="example">
   <p>The following buttons use <code id="the-dialog-element:attr-button-commandfor"><a href="#attr-button-commandfor">commandfor</a></code> to open and
   close a "confirm" <code id="the-dialog-element:the-dialog-element-31"><a href="#the-dialog-element">dialog</a></code> as modal when activated:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c->
        <c- e="">commandfor</c-><c- o="">=</c-><c- s="">"the-dialog"</c->
        <c- e="">command</c-><c- o="">=</c-><c- s="">"show-modal"</c-><c- p="">&gt;</c->
 Delete
<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">dialog</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"the-dialog"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"/delete"</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"POST"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"submit"</c-><c- p="">&gt;</c->
   Delete
  <c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">commandfor</c-><c- o="">=</c-><c- s="">"the-dialog"</c->
          <c- e="">command</c-><c- o="">=</c-><c- s="">"close"</c-><c- p="">&gt;</c->
   Cancel
  <c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dialog</c-><c- p="">&gt;</c->
    </code></pre>
  </div>

  <div data-algorithm="">
  <p>When a <code id="the-dialog-element:the-dialog-element-32"><a href="#the-dialog-element">dialog</a></code> element <var>subject</var> is to be <dfn id="close-the-dialog">closed</dfn>, with null or a string <var>result</var> and an <code id="the-dialog-element:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or null
  <var>source</var>, run these steps:</p>

  <ol><li><p>If <var>subject</var> does not have an <code id="the-dialog-element:attr-dialog-open-22"><a href="#attr-dialog-open">open</a></code>
   attribute, then return.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-dialog-element:concept-event-fire-4" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-dialog-element:event-beforetoggle-3"><a href="#event-beforetoggle">beforetoggle</a></code>, using <code id="the-dialog-element:toggleevent-3"><a href="#toggleevent">ToggleEvent</a></code>, with the <code id="the-dialog-element:dom-toggleevent-oldstate-3"><a href="#dom-toggleevent-oldstate">oldState</a></code> attribute initialized to "<code>open</code>", the <code id="the-dialog-element:dom-toggleevent-newstate-3"><a href="#dom-toggleevent-newstate">newState</a></code> attribute
   initialized to "<code>closed</code>", and the <code id="the-dialog-element:dom-toggleevent-source-2"><a href="#dom-toggleevent-source">source</a></code> attribute initialized to <var>source</var> at
   <var>subject</var>.</p></li><li><p>If <var>subject</var> does not have an <code id="the-dialog-element:attr-dialog-open-23"><a href="#attr-dialog-open">open</a></code>
   attribute, then return.</p></li><li><p><a href="#queue-a-dialog-toggle-event-task" id="the-dialog-element:queue-a-dialog-toggle-event-task-3">Queue a dialog toggle event task</a> given <var>subject</var>, "<code>open</code>", "<code>closed</code>", and <var>source</var>.</p></li><li><p>Remove <var>subject</var>'s <code id="the-dialog-element:attr-dialog-open-24"><a href="#attr-dialog-open">open</a></code>
   attribute.</p></li><li><p>If <a href="#is-modal" id="the-dialog-element:is-modal-5">is modal</a> of <var>subject</var> is true, then <a id="the-dialog-element:request-an-element-to-be-removed-from-the-top-layer" href="https://drafts.csswg.org/css-position-4/#request-an-element-to-be-removed-from-the-top-layer" data-x-internal="request-an-element-to-be-removed-from-the-top-layer">request an
   element to be removed from the top layer</a> given <var>subject</var>.</p></li><li><p>Let <var>wasModal</var> be the value of <var>subject</var>'s <a href="#is-modal" id="the-dialog-element:is-modal-6">is
   modal</a> flag.</p></li><li><p>Set <a href="#is-modal" id="the-dialog-element:is-modal-7">is modal</a> of <var>subject</var> to false.</p></li><li><p>If <var>result</var> is not null, then set <var>subject</var>'s <code id="the-dialog-element:dom-dialog-returnvalue-2"><a href="#dom-dialog-returnvalue">returnValue</a></code> attribute to <var>result</var>.</p></li><li><p>Set <var>subject</var>'s <a href="#request-close-return-value" id="the-dialog-element:request-close-return-value-2">request close return value</a> to null.</p></li><li><p>Set <var>subject</var>'s <a href="#request-close-source-element" id="the-dialog-element:request-close-source-element-2">request close source element</a> to null.</p></li><li>
    <p>If <var>subject</var>'s <a href="#previously-focused-element" id="the-dialog-element:previously-focused-element-3">previously focused element</a> is not null, then:</p>

    <ol><li><p>Let <var>element</var> be <var>subject</var>'s <a href="#previously-focused-element" id="the-dialog-element:previously-focused-element-4">previously focused
     element</a>.</p></li><li><p>Set <var>subject</var>'s <a href="#previously-focused-element" id="the-dialog-element:previously-focused-element-5">previously focused element</a> to null.</p></li><li><p>If <var>subject</var>'s <a id="the-dialog-element:node-document-10" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#focused-area-of-the-document" id="the-dialog-element:focused-area-of-the-document-3">focused area of the
     document</a>'s <a href="#dom-anchor" id="the-dialog-element:dom-anchor">DOM anchor</a> is a <a id="the-dialog-element:shadow-including-inclusive-descendant" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant" data-x-internal="shadow-including-inclusive-descendant">shadow-including inclusive
     descendant</a> of <var>subject</var>, or <var>wasModal</var> is true, then run the
     <a href="#focusing-steps" id="the-dialog-element:focusing-steps">focusing steps</a> for <var>element</var>; the viewport should not be scrolled by
     doing this step.</p></li></ol>
   </li><li><p><a href="#queue-an-element-task" id="the-dialog-element:queue-an-element-task">Queue an element task</a> on the <a href="#user-interaction-task-source" id="the-dialog-element:user-interaction-task-source">user interaction task source</a> given the
   <var>subject</var> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-dialog-element:concept-event-fire-5" data-x-internal="concept-event-fire">fire an event</a> named
   <code id="the-dialog-element:event-close-4"><a href="#event-close">close</a></code> at <var>subject</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="dialog-request-close">request to close</dfn> <code id="the-dialog-element:the-dialog-element-33"><a href="#the-dialog-element">dialog</a></code> element
  <var>subject</var>, given null or a string <var>returnValue</var> and null or an
  <code id="the-dialog-element:element-4"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> <var>source</var>:</p>

  <ol><li><p>If <var>subject</var> does not have an <code id="the-dialog-element:attr-dialog-open-25"><a href="#attr-dialog-open">open</a></code>
   attribute, then return.</p></li><li><p>If <var>subject</var> is not <a id="the-dialog-element:connected-5" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a> or <var>subject</var>'s
   <a id="the-dialog-element:node-document-11" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="the-dialog-element:fully-active-5">fully active</a>, then return.</p></li><li><p><a id="the-dialog-element:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>subject</var>'s <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher-6">close
   watcher</a> is not null.</p></li><li><p>Set <var>subject</var>'s <a href="#enable-close-watcher-for-requestclose()" id="the-dialog-element:enable-close-watcher-for-requestclose()-3">enable close watcher for request close</a> to
   true.</p></li><li><p>Set <var>subject</var>'s <a href="#request-close-return-value" id="the-dialog-element:request-close-return-value-3">request close return value</a> to
   <var>returnValue</var>.</p></li><li><p>Set <var>subject</var>'s <a href="#request-close-source-element" id="the-dialog-element:request-close-source-element-3">request close source element</a> to
   <var>source</var>.</p></li><li><p><a href="#close-watcher-request-close" id="the-dialog-element:close-watcher-request-close">Request to close</a> <var>subject</var>'s
   <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher-7">close watcher</a> with false.</p></li><li><p>Set <var>subject</var>'s <a href="#enable-close-watcher-for-requestclose()" id="the-dialog-element:enable-close-watcher-for-requestclose()-4">enable close watcher for request close</a> to
   false.</p></li></ol>
  </div>

  

  <div data-algorithm="">
  <p>To <dfn id="queue-a-dialog-toggle-event-task">queue a dialog toggle event task</dfn> given a <code id="the-dialog-element:the-dialog-element-34"><a href="#the-dialog-element">dialog</a></code> element
  <var>element</var>, a string <var>oldState</var>, a string <var>newState</var>, and an
  <code id="the-dialog-element:element-5"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or null <var>source</var>:</p>

  <ol><li>
    <p>If <var>element</var>'s <a href="#dialog-toggle-task-tracker" id="the-dialog-element:dialog-toggle-task-tracker">dialog toggle task tracker</a> is not null, then:</p>

    <ol><li><p>Set <var>oldState</var> to <var>element</var>'s <a href="#dialog-toggle-task-tracker" id="the-dialog-element:dialog-toggle-task-tracker-2">dialog toggle task
     tracker</a>'s <a href="#toggle-task-old-state" id="the-dialog-element:toggle-task-old-state">old state</a>.</p></li><li><p>Remove <var>element</var>'s <a href="#dialog-toggle-task-tracker" id="the-dialog-element:dialog-toggle-task-tracker-3">dialog toggle task tracker</a>'s <a href="#toggle-task-task" id="the-dialog-element:toggle-task-task">task</a> from its <a href="#task-queue" id="the-dialog-element:task-queue">task queue</a>.</p></li><li><p>Set <var>element</var>'s <a href="#dialog-toggle-task-tracker" id="the-dialog-element:dialog-toggle-task-tracker-4">dialog toggle task tracker</a> to null.</p></li></ol>
   </li><li>
    <p><a href="#queue-an-element-task" id="the-dialog-element:queue-an-element-task-2">Queue an element task</a> given the <a href="#dom-manipulation-task-source" id="the-dialog-element:dom-manipulation-task-source">DOM manipulation task source</a> and
    <var>element</var> to run the following steps:</p>

    <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-dialog-element:concept-event-fire-6" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-dialog-element:event-toggle"><a href="#event-toggle">toggle</a></code> at <var>element</var>, using <code id="the-dialog-element:toggleevent-4"><a href="#toggleevent">ToggleEvent</a></code>, with
     the <code id="the-dialog-element:dom-toggleevent-oldstate-4"><a href="#dom-toggleevent-oldstate">oldState</a></code> attribute initialized to
     <var>oldState</var>, the <code id="the-dialog-element:dom-toggleevent-newstate-4"><a href="#dom-toggleevent-newstate">newState</a></code> attribute
     initialized to <var>newState</var>, and the <code id="the-dialog-element:dom-toggleevent-source-3"><a href="#dom-toggleevent-source">source</a></code> attribute initialized to
     <var>source</var>.</p></li><li><p>Set <var>element</var>'s <a href="#dialog-toggle-task-tracker" id="the-dialog-element:dialog-toggle-task-tracker-5">dialog toggle task tracker</a> to null.</p></li></ol>
   </li><li><p>Set <var>element</var>'s <a href="#dialog-toggle-task-tracker" id="the-dialog-element:dialog-toggle-task-tracker-6">dialog toggle task tracker</a> to a struct with <a href="#toggle-task-task" id="the-dialog-element:toggle-task-task-2">task</a> set to the just-queued <a href="#concept-task" id="the-dialog-element:concept-task">task</a> and <a href="#toggle-task-old-state" id="the-dialog-element:toggle-task-old-state-2">old state</a> set
   to <var>oldState</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To retrieve a dialog's <dfn id="computed-closed-by-state">computed closed-by state</dfn>, given a <code id="the-dialog-element:the-dialog-element-35"><a href="#the-dialog-element">dialog</a></code>
  <var>dialog</var>:

  </p><ol><li>
    <p>If the state of <var>dialog</var>'s <code id="the-dialog-element:attr-dialog-closedby-5"><a href="#attr-dialog-closedby">closedby</a></code>
    attribute is <a href="#attr-dialog-closedby-auto-state" id="the-dialog-element:attr-dialog-closedby-auto-state-2">Auto</a>:</p>

    <ol><li><p>If <var>dialog</var>'s <a href="#is-modal" id="the-dialog-element:is-modal-8">is modal</a> is true, then return <a href="#attr-dialog-closedby-closerequest-state" id="the-dialog-element:attr-dialog-closedby-closerequest-state-2">Close Request</a>.</p></li><li><p>Return <a href="#attr-dialog-closedby-none-state" id="the-dialog-element:attr-dialog-closedby-none-state-4">None</a>.</p></li></ol>
   </li><li><p>Return the state of <var>dialog</var>'s <code id="the-dialog-element:attr-dialog-closedby-6"><a href="#attr-dialog-closedby">closedby</a></code> attribute.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="dialog-focusing-steps">dialog focusing steps</dfn>, given a <code id="the-dialog-element:the-dialog-element-36"><a href="#the-dialog-element">dialog</a></code> element <var>subject</var>,
  are as follows:</p>

  <ol><li><p>If the <a href="#allow-focus-steps" id="the-dialog-element:allow-focus-steps">allow focus steps</a> given <var>subject</var>'s <a id="the-dialog-element:node-document-12" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a> return false, then return.</p></li><li><p>Let <var>control</var> be null.</p></li><li><p>If <var>subject</var> has the <code id="the-dialog-element:attr-fe-autofocus-7"><a href="#attr-fe-autofocus">autofocus</a></code>
   attribute, then set <var>control</var> to <var>subject</var>.</p></li><li><p>If <var>control</var> is null, then set <var>control</var> to the <a href="#focus-delegate" id="the-dialog-element:focus-delegate">focus
   delegate</a> of <var>subject</var>.</p></li><li><p>If <var>control</var> is null, then set <var>control</var> to <var>subject</var>.</p></li><li>
    <p>Run the <a href="#focusing-steps" id="the-dialog-element:focusing-steps-2">focusing steps</a> for <var>control</var>.</p>

    <p class="note">If <var>control</var> is not <a href="#focusable" id="the-dialog-element:focusable">focusable</a>, this will do nothing. This
    would only happen if subject had no focus delegate, and the user agent decided that
    <code id="the-dialog-element:the-dialog-element-37"><a href="#the-dialog-element">dialog</a></code> elements were not generally focusable. In that case, any <a href="#note-dialog-plus-focus-fixup">earlier modifications</a> to the <a href="#focused-area-of-the-document" id="the-dialog-element:focused-area-of-the-document-4">focused area of the
    document</a> will apply.</p>
   </li><li><p>Let <var>topDocument</var> be <var>control</var>'s <a href="#node-navigable" id="the-dialog-element:node-navigable">node navigable</a>'s <a href="#nav-top" id="the-dialog-element:nav-top">top-level traversable</a>'s <a href="#nav-document" id="the-dialog-element:nav-document">active
   document</a>.</p></li><li><p>If <var>control</var>'s <a id="the-dialog-element:node-document-13" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-dialog-element:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is not the <a href="#same-origin" id="the-dialog-element:same-origin">same</a>
   as the <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-dialog-element:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> of <var>topDocument</var>, then
   return.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-empty" id="the-dialog-element:list-empty" data-x-internal="list-empty">Empty</a> <var>topDocument</var>'s
   <a href="#autofocus-candidates" id="the-dialog-element:autofocus-candidates">autofocus candidates</a>.</p></li><li><p>Set <var>topDocument</var>'s <a href="#autofocus-processed-flag" id="the-dialog-element:autofocus-processed-flag">autofocus processed flag</a> to true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="dialog-setup-steps">dialog setup steps</dfn>, given a <code id="the-dialog-element:the-dialog-element-38"><a href="#the-dialog-element">dialog</a></code> element <var>subject</var>, are
  as follows:</p>

  <ol><li><p><a id="the-dialog-element:assert-5" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>subject</var> has an <code id="the-dialog-element:attr-dialog-open-26"><a href="#attr-dialog-open">open</a></code>
   attribute.</p></li><li><p><a id="the-dialog-element:assert-6" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>subject</var> is <a id="the-dialog-element:connected-6" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>.</p></li><li><p><a id="the-dialog-element:assert-7" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>subject</var>'s <a id="the-dialog-element:node-document-14" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#open-dialogs-list" id="the-dialog-element:open-dialogs-list">open dialogs
   list</a> does not <a href="https://infra.spec.whatwg.org/#list-contain" id="the-dialog-element:list-contains-3" data-x-internal="list-contains">contain</a> <var>subject</var>.</p></li><li><p>Add <var>subject</var> to <var>subject</var>'s <a id="the-dialog-element:node-document-15" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#open-dialogs-list" id="the-dialog-element:open-dialogs-list-2">open
   dialogs list</a>.</p></li><li><p><a href="#set-the-dialog-close-watcher" id="the-dialog-element:set-the-dialog-close-watcher">Set the dialog close watcher</a> with <var>subject</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="dialog-cleanup-steps">dialog cleanup steps</dfn>, given a <code id="the-dialog-element:the-dialog-element-39"><a href="#the-dialog-element">dialog</a></code> element <var>subject</var>,
  are as follows:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="the-dialog-element:list-remove" data-x-internal="list-remove">Remove</a> <var>subject</var> from <var>subject</var>'s
   <a id="the-dialog-element:node-document-16" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#open-dialogs-list" id="the-dialog-element:open-dialogs-list-3">open dialogs list</a>.</p></li><li>
    <p>If <var>subject</var>'s <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher-8">close watcher</a> is not
    null, then:</p>

    <ol><li><p><a href="#close-watcher-destroy" id="the-dialog-element:close-watcher-destroy">Destroy</a> <var>subject</var>'s <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher-9">close watcher</a>.</p></li><li><p>Set <var>subject</var>'s <a href="#dialog-close-watcher" id="the-dialog-element:dialog-close-watcher-10">close watcher</a> to
     null.</p></li></ol>
   </li></ol>
  </div>

  <h4 id="dialog-light-dismiss"><span class="secno">4.11.5</span> <dfn>Dialog light dismiss</dfn><a href="#dialog-light-dismiss" class="self-link"></a></h4>

  <p class="note">"Light dismiss" means that clicking outside of a <code id="dialog-light-dismiss:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> element whose <code id="dialog-light-dismiss:attr-dialog-closedby"><a href="#attr-dialog-closedby">closedby</a></code> attribute is in the <a href="#attr-dialog-closedby-any-state" id="dialog-light-dismiss:attr-dialog-closedby-any-state">Any</a> state will close the <code id="dialog-light-dismiss:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code> element. This
  is in addition to how such <code id="dialog-light-dismiss:the-dialog-element-3"><a href="#the-dialog-element">dialog</a></code>s respond to <a href="#close-request" id="dialog-light-dismiss:close-request">close requests</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="light-dismiss-open-dialogs">light dismiss open dialogs</dfn>, given a <code id="dialog-light-dismiss:pointerevent"><a data-x-internal="pointerevent" href="https://w3c.github.io/pointerevents/#pointerevent-interface">PointerEvent</a></code> <var>event</var>:</p>

  <ol><li><p><a id="dialog-light-dismiss:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var>'s <code id="dialog-light-dismiss:dom-event-istrusted"><a data-x-internal="dom-event-istrusted" href="https://dom.spec.whatwg.org/#dom-event-istrusted">isTrusted</a></code> attribute is true.</p></li><li><p>Let <var>document</var> be <var>event</var>'s <a href="https://dom.spec.whatwg.org/#concept-event-target" id="dialog-light-dismiss:concept-event-target" data-x-internal="concept-event-target">target</a>'s <a id="dialog-light-dismiss:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>document</var>'s <a href="#open-dialogs-list" id="dialog-light-dismiss:open-dialogs-list">open dialogs list</a> is <a href="https://infra.spec.whatwg.org/#list-is-empty" id="dialog-light-dismiss:list-is-empty" data-x-internal="list-is-empty">empty</a>, then return.</p></li><li><p>Let <var>ancestor</var> be the result of running <a href="#nearest-clicked-dialog" id="dialog-light-dismiss:nearest-clicked-dialog">nearest clicked dialog</a>
   given <var>event</var>.</p></li><li><p>If <var>event</var>'s <code id="dialog-light-dismiss:dom-event-type"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> is
   "<code id="dialog-light-dismiss:event-pointerdown"><a data-x-internal="event-pointerdown" href="https://w3c.github.io/pointerevents/#the-pointerdown-event">pointerdown</a></code>", then set <var>document</var>'s
   <a href="#dialog-pointerdown-target" id="dialog-light-dismiss:dialog-pointerdown-target">dialog pointerdown target</a> to <var>ancestor</var>.</p></li><li>
    <p>If <var>event</var>'s <code id="dialog-light-dismiss:dom-event-type-2"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> is
    "<code id="dialog-light-dismiss:event-pointerup"><a data-x-internal="event-pointerup" href="https://w3c.github.io/pointerevents/#the-pointerup-event">pointerup</a></code>", then:</p>

    <ol><li><p>Let <var>sameTarget</var> be true if <var>ancestor</var> is <var>document</var>'s
     <a href="#dialog-pointerdown-target" id="dialog-light-dismiss:dialog-pointerdown-target-2">dialog pointerdown target</a>.</p></li><li><p>Set <var>document</var>'s <a href="#dialog-pointerdown-target" id="dialog-light-dismiss:dialog-pointerdown-target-3">dialog pointerdown target</a> to null.</p></li><li><p>If <var>sameTarget</var> is false, then return.</p></li><li><p>Let <var>topmostDialog</var> be the last element of <var>document</var>'s <a href="#open-dialogs-list" id="dialog-light-dismiss:open-dialogs-list-2">open
     dialogs list</a>.</p></li><li><p>If <var>ancestor</var> is <var>topmostDialog</var>, then return.</p></li><li><p>If <var>topmostDialog</var>'s <a href="#computed-closed-by-state" id="dialog-light-dismiss:computed-closed-by-state">computed closed-by state</a> is not <a href="#attr-dialog-closedby-any-state" id="dialog-light-dismiss:attr-dialog-closedby-any-state-2">Any</a>, then return.</p></li><li><p><a id="dialog-light-dismiss:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>topmostDialog</var>'s <a href="#dialog-close-watcher" id="dialog-light-dismiss:dialog-close-watcher">close watcher</a> is not null.</p></li><li><p><a href="#close-watcher-request-close" id="dialog-light-dismiss:close-watcher-request-close">Request to close</a>
     <var>topmostDialog</var>'s <a href="#dialog-close-watcher" id="dialog-light-dismiss:dialog-close-watcher-2">close watcher</a> with
     false.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="run-light-dismiss-activities">run light dismiss activities</dfn>, given a <code id="dialog-light-dismiss:pointerevent-2"><a data-x-internal="pointerevent" href="https://w3c.github.io/pointerevents/#pointerevent-interface">PointerEvent</a></code>
  <var>event</var>:</p>

  <ol><li><p>Run <a href="#light-dismiss-open-popovers" id="dialog-light-dismiss:light-dismiss-open-popovers">light dismiss open popovers</a> with <var>event</var>.</p></li><li><p>Run <a href="#light-dismiss-open-dialogs" id="dialog-light-dismiss:light-dismiss-open-dialogs">light dismiss open dialogs</a> with <var>event</var>.</p></li></ol>
  </div>

  <p class="XXX"><a href="#run-light-dismiss-activities" id="dialog-light-dismiss:run-light-dismiss-activities">Run light dismiss activities</a> will be called by the <a href="https://github.com/w3c/pointerevents/pull/460">Pointer Events spec</a> when the user clicks
  or touches anywhere on the page.</p>

  <div data-algorithm="">
  <p>To find the <dfn id="nearest-clicked-dialog">nearest clicked dialog</dfn>, given a <code id="dialog-light-dismiss:pointerevent-3"><a data-x-internal="pointerevent" href="https://w3c.github.io/pointerevents/#pointerevent-interface">PointerEvent</a></code>
  <var>event</var>:</p>

  <ol><li><p>Let <var>target</var> be <var>event</var>'s <a href="https://dom.spec.whatwg.org/#concept-event-target" id="dialog-light-dismiss:concept-event-target-2" data-x-internal="concept-event-target">target</a>.</p></li><li><p>If <var>target</var> is a <code id="dialog-light-dismiss:the-dialog-element-4"><a href="#the-dialog-element">dialog</a></code> element, <var>target</var> has an <code id="dialog-light-dismiss:attr-dialog-open"><a href="#attr-dialog-open">open</a></code> attribute, <var>target</var>'s <a href="#is-modal" id="dialog-light-dismiss:is-modal">is modal</a> is
   true, and <var>event</var>'s <code id="dialog-light-dismiss:mouseevent-clientx"><a data-x-internal="mouseevent-clientx" href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clientx">clientX</a></code> and
   <code id="dialog-light-dismiss:mouseevent-clienty"><a data-x-internal="mouseevent-clienty" href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clienty">clientY</a></code> are outside the bounds of <var>target</var>,
   then return null.

   </p><p class="note">The check for <code id="dialog-light-dismiss:mouseevent-clientx-2"><a data-x-internal="mouseevent-clientx" href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clientx">clientX</a></code> and <code id="dialog-light-dismiss:mouseevent-clienty-2"><a data-x-internal="mouseevent-clienty" href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clienty">clientY</a></code> is because a pointer event that hits the <code>::backdrop</code> pseudo element of a dialog will result in <var>event</var> having a
   target of the dialog element itself.</p>

   </li><li><p>Let <var>currentNode</var> be <var>target</var>.</p></li><li>
    <p>While <var>currentNode</var> is not null:</p>

    <ol><li><p>If <var>currentNode</var> is a <code id="dialog-light-dismiss:the-dialog-element-5"><a href="#the-dialog-element">dialog</a></code> element and <var>currentNode</var>
     has an <code id="dialog-light-dismiss:attr-dialog-open-2"><a href="#attr-dialog-open">open</a></code> attribute, then return
     <var>currentNode</var>.</p></li><li><p>Set <var>currentNode</var> to <var>currentNode</var>'s parent in the <a id="dialog-light-dismiss:flat-tree" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat
     tree</a>.</p></li></ol>
   </li><li><p>Return null.</p></li></ol>
  </div>

  <h3 id="scripting-3"><span class="secno">4.12</span> Scripting<a href="#scripting-3" class="self-link"></a></h3>

  <p>Scripts allow authors to add interactivity to their documents.</p>

  <p>Authors are encouraged to use declarative alternatives to scripting where possible, as
  declarative mechanisms are often more maintainable, and many users disable scripting.</p>

  <div class="example">

   <p>For example, instead of using a script to show or hide a section to show more details, the
   <code id="scripting-3:the-details-element"><a href="#the-details-element">details</a></code> element could be used.</p>

  </div>

  <p>Authors are also encouraged to make their applications degrade gracefully in the absence of
  scripting support.</p>

  <div class="example">

   <p>For example, if an author provides a link in a table header to dynamically resort the table,
   the link could also be made to function without scripts by requesting the sorted table from the
   server.</p>

  </div>


  <h4 id="the-script-element"><span class="secno">4.12.1</span> The <dfn id="script" data-dfn-type="element"><code>script</code></dfn> element<a href="#the-script-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script" title="The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The <script> element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON.">Element/script</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement" title="HTML <script> elements expose the HTMLScriptElement interface, which provides special properties and methods for manipulating the behavior and execution of <script> elements (beyond the inherited HTMLElement interface).">HTMLScriptElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-script-element:concept-element-categories">Categories</a>:</dt><dd><a href="#metadata-content-2" id="the-script-element:metadata-content-2">Metadata content</a>.</dd><dd><a href="#flow-content-2" id="the-script-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-script-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#script-supporting-elements-2" id="the-script-element:script-supporting-elements-2">Script-supporting element</a>.</dd><dt><a href="#concept-element-contexts" id="the-script-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#metadata-content-2" id="the-script-element:metadata-content-2-2">metadata content</a> is expected.</dd><dd>Where <a href="#phrasing-content-2" id="the-script-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dd>Where <a href="#script-supporting-elements-2" id="the-script-element:script-supporting-elements-2-2">script-supporting elements</a> are expected.</dd><dt><a href="#concept-element-content-model" id="the-script-element:concept-element-content-model">Content model</a>:</dt><dd>If there is no <code id="the-script-element:attr-script-src"><a href="#attr-script-src">src</a></code>
   attribute, depends on the value of the <code id="the-script-element:attr-script-type"><a href="#attr-script-type">type</a></code> attribute, but must match
   <a href="#restrictions-for-contents-of-script-elements" id="the-script-element:restrictions-for-contents-of-script-elements">script content restrictions</a>.</dd><dd>If there <em>is</em> a <code id="the-script-element:attr-script-src-2"><a href="#attr-script-src">src</a></code>
   attribute, the element must be either empty or contain only
   <a href="#inline-documentation-for-external-scripts" id="the-script-element:inline-documentation-for-external-scripts">script documentation</a> that also matches <a href="#restrictions-for-contents-of-script-elements" id="the-script-element:restrictions-for-contents-of-script-elements-2">script
   content restrictions</a>.</dd><dt><a href="#concept-element-tag-omission" id="the-script-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-script-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-script-element:global-attributes">Global attributes</a></dd><dd><code id="the-script-element:attr-script-type-2"><a href="#attr-script-type">type</a></code> —  Type of script
     </dd><dd><code id="the-script-element:attr-script-src-3"><a href="#attr-script-src">src</a></code> —  Address of the resource
     </dd><dd><code id="the-script-element:attr-script-nomodule"><a href="#attr-script-nomodule">nomodule</a></code> —  Prevents execution in user agents that support <a href="#module-script" id="the-script-element:module-script">module scripts</a>
     </dd><dd><code id="the-script-element:attr-script-async"><a href="#attr-script-async">async</a></code> —  Execute script when available, without blocking while fetching
     </dd><dd><code id="the-script-element:attr-script-defer"><a href="#attr-script-defer">defer</a></code> —  Defer script execution
     </dd><dd><code id="the-script-element:attr-script-blocking"><a href="#attr-script-blocking">blocking</a></code> —  Whether the element is <a href="#potentially-render-blocking" id="the-script-element:potentially-render-blocking">potentially render-blocking</a>
     </dd><dd><code id="the-script-element:attr-script-crossorigin"><a href="#attr-script-crossorigin">crossorigin</a></code> —  How the element handles crossorigin requests
     </dd><dd><code id="the-script-element:attr-script-referrerpolicy"><a href="#attr-script-referrerpolicy">referrerpolicy</a></code> —  <a id="the-script-element:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">Referrer policy</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-script-element:concept-fetch" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </dd><dd><code id="the-script-element:attr-script-integrity"><a href="#attr-script-integrity">integrity</a></code> —  Integrity metadata used in <cite>Subresource Integrity</cite> checks <a href="#refsSRI">[SRI]</a>
     </dd><dd><code id="the-script-element:attr-script-fetchpriority"><a href="#attr-script-fetchpriority">fetchpriority</a></code> —  Sets the <a href="https://fetch.spec.whatwg.org/#request-priority" id="the-script-element:concept-request-priority" data-x-internal="concept-request-priority">priority</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-script-element:concept-fetch-2" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-script-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-script">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-script">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-script-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlscriptelement" data-dfn-type="interface"><c- g="">HTMLScriptElement</c-></dfn> : <a href="#htmlelement" id="the-script-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-script-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-script-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-script-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLScriptElement" id="dom-script-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;
  [<a href="#cereactions" id="the-script-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="the-script-element:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLScriptElement" id="dom-script-src" data-dfn-type="attribute"><c- g="">src</c-></dfn>;
  [<a href="#cereactions" id="the-script-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-script-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLScriptElement" id="dom-script-nomodule" data-dfn-type="attribute"><c- g="">noModule</c-></dfn>;
  [<a href="#cereactions" id="the-script-element:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-script-async" id="the-script-element:dom-script-async"><c- g="">async</c-></a>;
  [<a href="#cereactions" id="the-script-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-script-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLScriptElement" id="dom-script-defer" data-dfn-type="attribute"><c- g="">defer</c-></dfn>;
  [<c- g="">SameObject</c->, <c- g="">PutForwards</c->=<a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="the-script-element:dom-domtokenlist-value" data-x-internal="dom-domtokenlist-value"><c- n="">value</c-></a>, <a href="#xattr-reflect" id="the-script-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-script-element:domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist" data-x-internal="domtokenlist"><c- n="">DOMTokenList</c-></a> <dfn data-dfn-for="HTMLScriptElement" id="dom-script-blocking" data-dfn-type="attribute"><c- g="">blocking</c-></dfn>;
  [<a href="#cereactions" id="the-script-element:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-script-crossorigin" id="the-script-element:dom-script-crossorigin"><c- g="">crossOrigin</c-></a>;
  [<a href="#cereactions" id="the-script-element:cereactions-7"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-script-referrerpolicy" id="the-script-element:dom-script-referrerpolicy"><c- g="">referrerPolicy</c-></a>;
  [<a href="#cereactions" id="the-script-element:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-script-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLScriptElement" id="dom-script-integrity" data-dfn-type="attribute"><c- g="">integrity</c-></dfn>;
  [<a href="#cereactions" id="the-script-element:cereactions-9"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-script-fetchpriority" id="the-script-element:dom-script-fetchpriority"><c- g="">fetchPriority</c-></a>;

  [<a href="#cereactions" id="the-script-element:cereactions-10"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-script-text" id="the-script-element:dom-script-text"><c- g="">text</c-></a>;

  <c- b="">static</c-> <c- b="">boolean</c-> <a href="#dom-script-supports" id="the-script-element:dom-script-supports"><c- g="">supports</c-></a>(<c- b="">DOMString</c-> <c- g="">type</c->);

  // <a href="#HTMLScriptElement-partial">also has obsolete members</a>
};</code></pre>
   </dd></dl>

  <p>The <code id="the-script-element:the-script-element"><a href="#the-script-element">script</a></code> element allows authors to include dynamic script, instructions to the
  user agent, and data blocks in their documents. The element does not <a href="#represents" id="the-script-element:represents">represent</a> content for the user.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type" title="The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The <script> element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON.">Element/script#attr-type</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>≤4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The script element has two core attributes. The <dfn data-dfn-for="script" id="attr-script-type" data-dfn-type="element-attr"><code>type</code></dfn> attribute allows customization of the type of script
  represented:</p>

  <ul><li><p>Omitting the attribute, setting it to the empty string, or setting it to a
    <a id="the-script-element:javascript-mime-type-essence-match" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match" data-x-internal="javascript-mime-type-essence-match">JavaScript MIME type essence match</a> means that the script is a <a href="#classic-script" id="the-script-element:classic-script">classic
    script</a>, to be interpreted according to the JavaScript <i id="the-script-element:js-prod-script"><a data-x-internal="js-prod-script" href="https://tc39.es/ecma262/#prod-Script">Script</a></i> top-level production. Authors should omit the <code id="the-script-element:attr-script-type-3"><a href="#attr-script-type">type</a></code> attribute instead of redundantly setting it.</p></li><li><p>Setting the attribute to an <a id="the-script-element:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>module</code>" means that the script is a <a href="#javascript-module-script" id="the-script-element:javascript-module-script">JavaScript module script</a>, to
    be interpreted according to the JavaScript <i id="the-script-element:js-prod-module"><a data-x-internal="js-prod-module" href="https://tc39.es/ecma262/#prod-Module">Module</a></i> top-level
    production.</p></li><li><p>Setting the attribute to an <a id="the-script-element:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>importmap</code>" means that the script is an <a href="#import-map" id="the-script-element:import-map">import map</a>, containing
    JSON that will be used to control the behavior of <a href="#resolve-a-module-specifier" id="the-script-element:resolve-a-module-specifier">module specifier resolution</a>.</p></li><li><p>Setting the attribute to an <a id="the-script-element:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>speculationrules</code>" means that the script defines a <a href="#speculation-rule-set" id="the-script-element:speculation-rule-set">speculation rule
    set</a>, containing JSON that will be used to describe <a href="#speculative-loading">speculative loads</a>.</p></li><li>
     <p>Setting the attribute to any other value means that the script is a <dfn id="data-block">data block</dfn>,
     which is not processed by the user agent, but instead by author script or other tools. Authors
     must use a <a id="the-script-element:valid-mime-type-string" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">valid MIME type string</a> that is not a <a id="the-script-element:javascript-mime-type-essence-match-2" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match" data-x-internal="javascript-mime-type-essence-match">JavaScript MIME type essence
     match</a> to denote data blocks.</p>

     <p class="note">The requirement that <a href="#data-block" id="the-script-element:data-block">data blocks</a>
     must be denoted using a <a id="the-script-element:valid-mime-type-string-2" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">valid MIME type string</a> is in place to
     avoid potential future collisions. Values for the <code id="the-script-element:attr-script-type-4"><a href="#attr-script-type">type</a></code>
     attribute that are not MIME types, like "<code>module</code>" or "<code>importmap</code>", are used by the standard to denote types of scripts which have
     special behavior in user agents. By using a valid MIME type string now, you ensure that your
     data block will not ever be reinterpreted as a different script type, even in future user
     agents.</p>
    </li></ul>

  <p>The second core attribute is the <dfn data-dfn-for="script" id="attr-script-src" data-dfn-type="element-attr"><code>src</code></dfn> attribute. It must only be specified for <a href="#classic-script" id="the-script-element:classic-script-2">classic scripts</a> and <a href="#javascript-module-script" id="the-script-element:javascript-module-script-2">JavaScript module scripts</a>, and denotes that instead of using the element's
  <a id="the-script-element:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> as the script content, the script will be fetched from the
  specified <a id="the-script-element:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>. If <code id="the-script-element:attr-script-src-4"><a href="#attr-script-src">src</a></code> is specified, it must be
  a <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="the-script-element:valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by spaces</a>.</p>

  <p>Which other attributes may be specified on a given <code id="the-script-element:the-script-element-2"><a href="#the-script-element">script</a></code> element is determined by
  the following table:</p>

  <table class="yesno"><thead><tr><th></th><th><code id="the-script-element:attr-script-nomodule-2"><a href="#attr-script-nomodule">nomodule</a></code>
     </th><th><code id="the-script-element:attr-script-async-2"><a href="#attr-script-async">async</a></code>
     </th><th><code id="the-script-element:attr-script-defer-2"><a href="#attr-script-defer">defer</a></code>
     </th><th><code id="the-script-element:attr-script-blocking-2"><a href="#attr-script-blocking">blocking</a></code>
     </th><th><code id="the-script-element:attr-script-crossorigin-2"><a href="#attr-script-crossorigin">crossorigin</a></code>
     </th><th><code id="the-script-element:attr-script-referrerpolicy-2"><a href="#attr-script-referrerpolicy">referrerpolicy</a></code>
     </th><th><code id="the-script-element:attr-script-integrity-2"><a href="#attr-script-integrity">integrity</a></code>
     </th><th><code id="the-script-element:attr-script-fetchpriority-2"><a href="#attr-script-fetchpriority">fetchpriority</a></code>
   </th></tr></thead><tbody><tr><th>External classic scripts</th><td class="yes">Yes</td><td class="yes">Yes</td><td class="yes">Yes</td><td class="yes">Yes</td><td class="yes">Yes</td><td class="yes">Yes</td><td class="yes">Yes</td><td class="yes">Yes</td></tr><tr><th>Inline classic scripts</th><td class="yes">Yes</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="yes">Yes*</td><td class="yes">Yes*</td><td class="no">·</td><td class="no">·†</td></tr><tr><th>External module scripts</th><td class="no">·</td><td class="yes">Yes</td><td class="no">·</td><td class="yes">Yes</td><td class="yes">Yes</td><td class="yes">Yes</td><td class="yes">Yes</td><td class="yes">Yes</td></tr><tr><th>Inline module scripts</th><td class="no">·</td><td class="yes">Yes</td><td class="no">·</td><td class="no">·</td><td class="yes">Yes*</td><td class="yes">Yes*</td><td class="no">·</td><td class="no">·†</td></tr><tr><th>Import maps</th><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td></tr><tr><th>Speculation rules</th><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td></tr><tr><th>Data blocks</th><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td><td class="no">·</td></tr></tbody></table>

  <p class="tablenote"><small>* Although inline scripts have no initial fetches, the <code id="the-script-element:attr-script-crossorigin-3"><a href="#attr-script-crossorigin">crossorigin</a></code> and <code id="the-script-element:attr-script-referrerpolicy-3"><a href="#attr-script-referrerpolicy">referrerpolicy</a></code> attribute on inline scripts affects the
  <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="the-script-element:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> and <a id="the-script-element:referrer-policy-2" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer
  policy</a> used by module imports, including dynamic <code id="the-script-element:import()"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code>.</small></p>

  <p class="tablenote"><small>† Unlike <code id="the-script-element:attr-script-crossorigin-4"><a href="#attr-script-crossorigin">crossorigin</a></code> and <code id="the-script-element:attr-script-referrerpolicy-4"><a href="#attr-script-referrerpolicy">referrerpolicy</a></code>, <code id="the-script-element:attr-script-fetchpriority-3"><a href="#attr-script-fetchpriority">fetchpriority</a></code> does not affect module imports. See some discussion in <a href="https://github.com/whatwg/html/issues/10276">issue #10276</a>.</small></p>

  <hr>

  <p>The contents of inline <code id="the-script-element:the-script-element-3"><a href="#the-script-element">script</a></code> elements, or the external script resource, must
  conform with the requirements of the JavaScript specification's <i id="the-script-element:js-prod-script-2"><a data-x-internal="js-prod-script" href="https://tc39.es/ecma262/#prod-Script">Script</a></i> or <i id="the-script-element:js-prod-module-2"><a data-x-internal="js-prod-module" href="https://tc39.es/ecma262/#prod-Module">Module</a></i> productions, for <a href="#classic-script" id="the-script-element:classic-script-3">classic scripts</a> and <a href="#javascript-module-script" id="the-script-element:javascript-module-script-3">JavaScript module scripts</a> respectively. <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <p>The contents of inline <code id="the-script-element:the-script-element-4"><a href="#the-script-element">script</a></code> elements for <a href="#import-map" id="the-script-element:import-map-2">import
  maps</a> must conform with the <a href="#import-map-authoring-requirements" id="the-script-element:import-map-authoring-requirements">import map authoring requirements</a>.</p>

  <p>The contents of inline <code id="the-script-element:the-script-element-5"><a href="#the-script-element">script</a></code> elements for <a href="#speculation-rule-set" id="the-script-element:speculation-rule-set-2">speculation rule sets</a> must conform with the <a href="#speculation-rule-set-authoring-requirements" id="the-script-element:speculation-rule-set-authoring-requirements">speculation rule set authoring
  requirements</a>.</p>

  <p>When used to include <a href="#data-block" id="the-script-element:data-block-2">data blocks</a>, the data must be embedded
  inline, the format of the data must be given using the <code id="the-script-element:attr-script-type-5"><a href="#attr-script-type">type</a></code>
  attribute, and the contents of the <code id="the-script-element:the-script-element-6"><a href="#the-script-element">script</a></code> element must conform to the requirements
  defined for the format used.</p>

  <hr>

  <p>The <dfn data-dfn-for="script" id="attr-script-nomodule" data-dfn-type="element-attr"><code>nomodule</code></dfn>
  attribute is a <a href="#boolean-attribute" id="the-script-element:boolean-attribute">boolean attribute</a> that prevents a script from being executed in user
  agents that support <a href="#module-script" id="the-script-element:module-script-2">module scripts</a>. This allows selective
  execution of <a href="#module-script" id="the-script-element:module-script-3">module scripts</a> in modern user agents and <a href="#classic-script" id="the-script-element:classic-script-4">classic scripts</a> in older user agents, <a href="#script-nomodule-example">as shown below</a>.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-async" title="The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The <script> element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON.">Element/script#attr-async</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>≤4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-defer" title="The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The <script> element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON.">Element/script#attr-defer</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="script" id="attr-script-async" data-dfn-type="element-attr"><code>async</code></dfn> and
  <dfn data-dfn-for="script" id="attr-script-defer" data-dfn-type="element-attr"><code>defer</code></dfn> attributes are
  <a href="#boolean-attribute" id="the-script-element:boolean-attribute-2">boolean attributes</a> that indicate how the script should be
  evaluated. There are several possible modes that can be selected using these attributes, depending
  on the script's type.</p>

  <p>For external <a href="#classic-script" id="the-script-element:classic-script-5">classic scripts</a>, if the <code id="the-script-element:attr-script-async-3"><a href="#attr-script-async">async</a></code> attribute is present, then the classic script will be
  fetched <a href="#in-parallel" id="the-script-element:in-parallel">in parallel</a> to parsing and evaluated as soon as it is available (potentially
  before parsing completes). If the <code id="the-script-element:attr-script-async-4"><a href="#attr-script-async">async</a></code> attribute is not
  present but the <code id="the-script-element:attr-script-defer-3"><a href="#attr-script-defer">defer</a></code> attribute is present, then the
  classic script will be fetched <a href="#in-parallel" id="the-script-element:in-parallel-2">in parallel</a> and evaluated when the page has finished
  parsing. If neither attribute is present, then the script is fetched and evaluated immediately,
  blocking parsing until these are both complete.</p>

  <p>For <a href="#module-script" id="the-script-element:module-script-4">module scripts</a>, if the <code id="the-script-element:attr-script-async-5"><a href="#attr-script-async">async</a></code> attribute is present, then the module script and all its
  dependencies will be fetched <a href="#in-parallel" id="the-script-element:in-parallel-3">in parallel</a> to parsing, and the module script will
  be evaluated as soon as it is available (potentially before parsing completes). Otherwise, the
  module script and its dependencies will be fetched <a href="#in-parallel" id="the-script-element:in-parallel-4">in parallel</a> to parsing and
  evaluated when the page has finished parsing. (The <code id="the-script-element:attr-script-defer-4"><a href="#attr-script-defer">defer</a></code>
  attribute has no effect on module scripts.)</p>

  <p>This is all summarized in the following schematic diagram:</p>

  <p><img class="darkmode-aware" src="/images/asyncdefer.svg" alt="With <script>, parsing is interrupted by fetching and execution. With <script defer>, fetching is parallel to parsing and execution takes place after all parsing has finished. And with <script async>, fetching is parallel to parsing but once it finishes parsing is interrupted to execute the script. The story for <script type=&quot;module&quot;> is similar to <script defer>, but the dependencies will be fetched as well, and the story for <script type=&quot;module&quot; async> is similar to <script async> with the extra dependency fetching." style="width: 80%; min-width: 820px;"></p>

  <p class="note">The exact processing details for these attributes are, for mostly
  historical reasons, somewhat non-trivial, involving a number of aspects of HTML. The
  implementation requirements are therefore by necessity scattered throughout the specification. The
  algorithms <a href="#script-processing-model">below</a> describe the core of this processing, but
  these algorithms reference and are referenced by the parsing rules for <code id="the-script-element:the-script-element-7"><a href="#the-script-element">script</a></code> <a href="#scriptTag">start</a> and <a href="#scriptEndTag">end</a> tags in HTML, <a href="#scriptForeignEndTag">in foreign content</a>, and <a href="#scriptTagXML">in XML</a>, the
  rules for the <code id="the-script-element:dom-document-write"><a href="#dom-document-write">document.write()</a></code> method, the handling of <a href="#scripting">scripting</a>, etc.</p>

  <p class="note">When inserted using the <code id="the-script-element:dom-document-write-2"><a href="#dom-document-write">document.write()</a></code>
  method, <code id="the-script-element:the-script-element-8"><a href="#the-script-element">script</a></code> elements <a href="#document-written-scripts-intervention">usually</a>
  execute (typically blocking further script execution or HTML parsing). When inserted using the
  <code id="the-script-element:dom-element-innerhtml"><a href="#dom-element-innerhtml">innerHTML</a></code> and <code id="the-script-element:dom-element-outerhtml"><a href="#dom-element-outerhtml">outerHTML</a></code> attributes, they do not execute at all.</p>

  <p>The <code id="the-script-element:attr-script-defer-5"><a href="#attr-script-defer">defer</a></code> attribute may be specified even if the <code id="the-script-element:attr-script-async-6"><a href="#attr-script-async">async</a></code> attribute is specified, to cause legacy web browsers that
  only support <code id="the-script-element:attr-script-defer-6"><a href="#attr-script-defer">defer</a></code> (and not <code id="the-script-element:attr-script-async-7"><a href="#attr-script-async">async</a></code>) to fall back to the <code id="the-script-element:attr-script-defer-7"><a href="#attr-script-defer">defer</a></code> behavior instead of the blocking behavior that
  is the default.</p>

  <p>The <dfn data-dfn-for="script" id="attr-script-blocking" data-dfn-type="element-attr"><code>blocking</code></dfn>
  attribute is a <a href="#blocking-attribute" id="the-script-element:blocking-attribute">blocking attribute</a>.</p>

  <p>The <dfn data-dfn-for="script" id="attr-script-crossorigin" data-dfn-type="element-attr"><code>crossorigin</code></dfn> attribute is a <a href="#cors-settings-attribute" id="the-script-element:cors-settings-attribute">CORS settings
  attribute</a>. For external <a href="#classic-script" id="the-script-element:classic-script-6">classic scripts</a>, it controls
  whether error information will be exposed, when the script is obtained from other <a href="#concept-origin" id="the-script-element:concept-origin">origins</a>. For external <a href="#module-script" id="the-script-element:module-script-5">module scripts</a>,
  it controls the <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="the-script-element:concept-request-credentials-mode-2" data-x-internal="concept-request-credentials-mode">credentials mode</a> used for
  the initial fetch of the module source, if cross-origin. For both <a href="#classic-script" id="the-script-element:classic-script-7">classic</a> and <a href="#module-script" id="the-script-element:module-script-6">module scripts</a>, it controls the
  <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="the-script-element:concept-request-credentials-mode-3" data-x-internal="concept-request-credentials-mode">credentials mode</a> used for cross-origin
  module imports.</p>

  <p class="note">Unlike <a href="#classic-script" id="the-script-element:classic-script-8">classic scripts</a>, <a href="#module-script" id="the-script-element:module-script-7">module scripts</a> require the use of the <a href="https://fetch.spec.whatwg.org/#http-cors-protocol" id="the-script-element:cors-protocol" data-x-internal="cors-protocol">CORS protocol</a> for cross-origin fetching.</p>

  <p>The <dfn data-dfn-for="script" id="attr-script-referrerpolicy" data-dfn-type="element-attr"><code>referrerpolicy</code></dfn> attribute is a <a href="#referrer-policy-attribute" id="the-script-element:referrer-policy-attribute">referrer
  policy attribute</a>. Its sets the <a id="the-script-element:referrer-policy-3" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a> used for the initial fetch of
  an external script, as well as the fetching of any imported module scripts.
  <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p>

  <div class="example">
   <p>An example of a <code id="the-script-element:the-script-element-9"><a href="#the-script-element">script</a></code> element's referrer policy being used when fetching
   imported scripts but not other subresources:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">referrerpolicy</c-><c- o="">=</c-><c- s="">"origin"</c-><c- p="">&gt;</c->
  fetch<c- p="">(</c-><c- t="">'/api/data'</c-><c- p="">);</c->    <c- c1="">// not fetched with &lt;script&gt;'s referrer policy</c->
  <c- k="">import</c-><c- p="">(</c-><c- t="">'./utils.mjs'</c-><c- p="">);</c-> <c- c1="">// is fetched with &lt;script&gt;'s referrer policy ("origin" in this case)</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>The <dfn data-dfn-for="script" id="attr-script-integrity" data-dfn-type="element-attr"><code>integrity</code></dfn>
  attribute sets the <a href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata" id="the-script-element:concept-request-integrity-metadata" data-x-internal="concept-request-integrity-metadata">integrity metadata</a>
  used for the initial fetch of an external script. The value must match <a id="the-script-element:the-requirements-of-the-integrity-attribute" href="https://w3c.github.io/webappsec-subresource-integrity/#the-integrity-attribute" data-x-internal="the-requirements-of-the-integrity-attribute">the requirements of
  the integrity attribute</a>. <a href="#refsSRI">[SRI]</a></p>

  <p>The <dfn data-dfn-for="script" id="attr-script-fetchpriority" data-dfn-type="element-attr"><code>fetchpriority</code></dfn> attribute is a <a href="#fetch-priority-attribute" id="the-script-element:fetch-priority-attribute">fetch priority
  attribute</a>. Its sets the <a href="https://fetch.spec.whatwg.org/#request-priority" id="the-script-element:concept-request-priority-2" data-x-internal="concept-request-priority">priority</a> used for
  the initial fetch of an external script.</p>

  <p>Changing any of these attributes dynamically has no direct effect; these attributes are only
  used at specific times described in the <a href="#script-processing-model">processing model</a>.</p>

  <hr>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLScriptElement" id="dom-script-crossorigin" data-dfn-type="attribute"><code>crossOrigin</code></dfn> IDL attribute must <a href="#reflect" id="the-script-element:reflect">reflect</a>
  the <code id="the-script-element:attr-script-crossorigin-5"><a href="#attr-script-crossorigin">crossorigin</a></code> content attribute, <a href="#limited-to-only-known-values" id="the-script-element:limited-to-only-known-values">limited to
  only known values</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/referrerPolicy" title="The referrerPolicy property of the HTMLScriptElement interface reflects the HTML referrerpolicy of the <script> element, which defines how the referrer is set when fetching the script and any scripts it imports.">HTMLScriptElement/referrerPolicy</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>65+</span></span><span class="safari yes"><span>Safari</span><span>14+</span></span><span class="chrome yes"><span>Chrome</span><span>70+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLScriptElement" id="dom-script-referrerpolicy" data-dfn-type="attribute"><code>referrerPolicy</code></dfn> IDL attribute must
  <a href="#reflect" id="the-script-element:reflect-2">reflect</a> the <code id="the-script-element:attr-script-referrerpolicy-5"><a href="#attr-script-referrerpolicy">referrerpolicy</a></code> content
  attribute, <a href="#limited-to-only-known-values" id="the-script-element:limited-to-only-known-values-2">limited to only known values</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLScriptElement" id="dom-script-fetchpriority" data-dfn-type="attribute"><code>fetchPriority</code></dfn> IDL attribute must
  <a href="#reflect" id="the-script-element:reflect-3">reflect</a> the <code id="the-script-element:attr-script-fetchpriority-4"><a href="#attr-script-fetchpriority">fetchpriority</a></code>
  content attribute, <a href="#limited-to-only-known-values" id="the-script-element:limited-to-only-known-values-3">limited to only known values</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLScriptElement" id="dom-script-async" data-dfn-type="attribute"><code>async</code></dfn>
  getter steps are:</p>

  <ol><li><p>If <a id="the-script-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#script-force-async" id="the-script-element:script-force-async">force async</a> is true, then
   return true.</p></li><li><p>If <a id="the-script-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-script-element:attr-script-async-8"><a href="#attr-script-async">async</a></code> content attribute is
   present, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-script-element:dom-script-async-2"><a href="#dom-script-async">async</a></code> setter steps are:</p>

  <ol><li><p>Set <a id="the-script-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#script-force-async" id="the-script-element:script-force-async-2">force async</a> to
   false.</p></li><li><p>If the given value is true, then set <a id="the-script-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-script-element:attr-script-async-9"><a href="#attr-script-async">async</a></code> content attribute to the empty string.</p></li><li><p>Otherwise, remove <a id="the-script-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-script-element:attr-script-async-10"><a href="#attr-script-async">async</a></code>
   content attribute.</p></li></ol>
  </div>

  

  <dl class="domintro"><dt><code><var>script</var>.<a href="#dom-script-text" id="dom-script-text-dev">text</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the <a id="the-script-element:child-text-content-2" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> of the element.</p>
   </dd><dt><code><var>script</var>.<a href="#dom-script-text" id="the-script-element:dom-script-text-2">text</a> = <var>value</var></code></dt><dd>
    <p>Replaces the element's children with the text given by <var>value</var>.</p>
   </dd><dt><code><code id="the-script-element:htmlscriptelement"><a href="#htmlscriptelement">HTMLScriptElement</a></code>.<a href="#dom-script-supports" id="dom-script-supports-dev">supports</a>(<var>type</var>)</code></dt><dd>
    <p>Returns true if the given <var>type</var> is a script type supported by the user agent. The
    possible script types in this specification are "<code>classic</code>", "<code>module</code>", and "<code>importmap</code>", but others might be added in
    the future.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLScriptElement" id="dom-script-text" data-dfn-type="attribute"><code>text</code></dfn>
  getter steps are to return <a id="the-script-element:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-script-element:child-text-content-3" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-script-element:dom-script-text-3"><a href="#dom-script-text">text</a></code> setter steps are to <a id="the-script-element:string-replace-all" href="https://dom.spec.whatwg.org/#string-replace-all" data-x-internal="string-replace-all">string replace
  all</a> with the given value within <a id="the-script-element:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/supports_static" title="The supports() static method of the HTMLScriptElement interface provides a simple and consistent method to feature-detect what types of scripts are supported by the user agent.">HTMLScriptElement/supports_static</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>94+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>96+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>96+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The static <dfn data-dfn-for="HTMLScriptElement" id="dom-script-supports" data-dfn-type="method"><code>supports(<var>type</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If <var>type</var> <a id="the-script-element:is" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="is">is</a> "<code>classic</code>", then return
   true.</p></li><li><p>If <var>type</var> <a id="the-script-element:is-2" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="is">is</a> "<code>module</code>", then return
   true.</p></li><li><p>If <var>type</var> <a id="the-script-element:is-3" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="is">is</a> "<code>importmap</code>", then return
   true.</p></li><li><p>If <var>type</var> <a id="the-script-element:is-4" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="is">is</a> "<code>speculationrules</code>", then return
   true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  

  <p class="note">The <var>type</var> argument has to exactly match these values; we do not
  perform an <a id="the-script-element:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match. This is different from how <code id="the-script-element:attr-script-type-6"><a href="#attr-script-type">type</a></code> content attribute values are treated, and how
  <code id="the-script-element:domtokenlist-2"><a data-x-internal="domtokenlist" href="https://dom.spec.whatwg.org/#interface-domtokenlist">DOMTokenList</a></code>'s <code id="the-script-element:dom-domtokenlist-supports"><a data-x-internal="dom-domtokenlist-supports" href="https://dom.spec.whatwg.org/#dom-domtokenlist-supports">supports()</a></code> method
  works, but it aligns with the <code id="the-script-element:workertype"><a href="#workertype">WorkerType</a></code> enumeration used in the <code id="the-script-element:dom-worker"><a href="#dom-worker">Worker()</a></code> constructor.</p>

  <hr>

  <div class="example">

   <p>In this example, two <code id="the-script-element:the-script-element-10"><a href="#the-script-element">script</a></code> elements are used. One embeds an external
   <a href="#classic-script" id="the-script-element:classic-script-9">classic script</a>, and the other includes some data as a <a href="#data-block" id="the-script-element:data-block-3">data block</a>.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"game-engine.js"</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text/x-game-map"</c-><c- p="">&gt;</c->
<c- p="">........</c->U<c- p="">.........</c->e
o<c- p="">............</c->A<c- p="">....</c->e
<c- p="">.....</c->A<c- p="">.....</c->AAA<c- p="">....</c->e
<c- p="">.</c->A<c- p="">..</c->AAA<c- p="">...</c->AAAAA<c- p="">...</c->e
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>The data in this case might be used by the script to generate the map of a video game. The
   data doesn't have to be used that way, though; maybe the map data is actually embedded in other
   parts of the page's markup, and the data block here is just used by the site's search engine to
   help users who are looking for particular features in their game maps.</p>

  </div>

  <div class="example">

   <p>The following sample shows how a <code id="the-script-element:the-script-element-11"><a href="#the-script-element">script</a></code> element can be used to define a function
   that is then used by other parts of the document, as part of a <a href="#classic-script" id="the-script-element:classic-script-10">classic script</a>. It
   also shows how a <code id="the-script-element:the-script-element-12"><a href="#the-script-element">script</a></code> element can be used to invoke script while the document is
   being parsed, in this case to initialize the form's output.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">function</c-> calculate<c- p="">(</c->form<c- p="">)</c-> <c- p="">{</c->
   <c- a="">var</c-> price <c- o="">=</c-> <c- mf="">52000</c-><c- p="">;</c->
   <c- k="">if</c-> <c- p="">(</c->form<c- p="">.</c->elements<c- p="">.</c->brakes<c- p="">.</c->checked<c- p="">)</c->
     price <c- o="">+=</c-> <c- mf="">1000</c-><c- p="">;</c->
   <c- k="">if</c-> <c- p="">(</c->form<c- p="">.</c->elements<c- p="">.</c->radio<c- p="">.</c->checked<c- p="">)</c->
     price <c- o="">+=</c-> <c- mf="">2500</c-><c- p="">;</c->
   <c- k="">if</c-> <c- p="">(</c->form<c- p="">.</c->elements<c- p="">.</c->turbo<c- p="">.</c->checked<c- p="">)</c->
     price <c- o="">+=</c-> <c- mf="">5000</c-><c- p="">;</c->
   <c- k="">if</c-> <c- p="">(</c->form<c- p="">.</c->elements<c- p="">.</c->sticker<c- p="">.</c->checked<c- p="">)</c->
     price <c- o="">+=</c-> <c- mf="">250</c-><c- p="">;</c->
   form<c- p="">.</c->elements<c- p="">.</c->result<c- p="">.</c->value <c- o="">=</c-> price<c- p="">;</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">form</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"pricecalc"</c-> <c- e="">onsubmit</c-><c- o="">=</c-><c- s="">"return false"</c-> <c- e="">onchange</c-><c- o="">=</c-><c- s="">"calculate(this)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Work out the price of your car<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Base cost: £52000.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Select additional options:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">brakes</c-><c- p="">&gt;</c-> Ceramic brakes (£1000)<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">radio</c-><c- p="">&gt;</c-> Satellite radio (£2500)<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">turbo</c-><c- p="">&gt;</c-> Turbo charger (£5000)<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">sticker</c-><c- p="">&gt;</c-> "XZ" sticker (£250)<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Total: £<c- p="">&lt;</c-><c- f="">output</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">result</c-><c- p="">&gt;&lt;/</c-><c- f="">output</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  calculate<c- p="">(</c->document<c- p="">.</c->forms<c- p="">.</c->pricecalc<c- p="">);</c->
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div id="script-type-module-example-1" class="example"><a href="#script-type-module-example-1" class="self-link"></a>

   <p>The following sample shows how a <code id="the-script-element:the-script-element-13"><a href="#the-script-element">script</a></code> element can be used to include an
   external <a href="#javascript-module-script" id="the-script-element:javascript-module-script-4">JavaScript module script</a>.

   </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"module"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"app.mjs"</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>This module, and all its dependencies (expressed through JavaScript <code>import</code> statements in the source file), will be fetched. Once the entire
   resulting module graph has been imported, and the document has finished parsing, the contents of
   <code>app.mjs</code> will be evaluated.</p>

   <p>Additionally, if code from another <code id="the-script-element:the-script-element-14"><a href="#the-script-element">script</a></code> element in the same <code id="the-script-element:window"><a href="#window">Window</a></code>
   imports the module from <code>app.mjs</code> (e.g. via <code>import
   "./app.mjs";</code>), then the same <a href="#javascript-module-script" id="the-script-element:javascript-module-script-5">JavaScript module script</a> created by the
   former <code id="the-script-element:the-script-element-15"><a href="#the-script-element">script</a></code> element will be imported.</p>

  </div>

  <div id="script-nomodule-example" class="example"><a href="#script-nomodule-example" class="self-link"></a>

  <p>This example shows how to include a <a href="#javascript-module-script" id="the-script-element:javascript-module-script-6">JavaScript module script</a> for modern user
  agents, and a <a href="#classic-script" id="the-script-element:classic-script-11">classic script</a> for older user agents:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"module"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"app.mjs"</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-> <c- e="">nomodule</c-> <c- e="">defer</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"classic-app-bundle.js"</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  <p>In modern user agents that support <a href="#javascript-module-script" id="the-script-element:javascript-module-script-7">JavaScript module
  scripts</a>, the <code id="the-script-element:the-script-element-16"><a href="#the-script-element">script</a></code> element with the <code id="the-script-element:attr-script-nomodule-3"><a href="#attr-script-nomodule">nomodule</a></code> attribute will be ignored, and the
  <code id="the-script-element:the-script-element-17"><a href="#the-script-element">script</a></code> element with a <code id="the-script-element:attr-script-type-7"><a href="#attr-script-type">type</a></code> of "<code>module</code>" will be fetched and evaluated (as a <a href="#javascript-module-script" id="the-script-element:javascript-module-script-8">JavaScript module
  script</a>). Conversely, older user agents will ignore the <code id="the-script-element:the-script-element-18"><a href="#the-script-element">script</a></code> element with a
  <code id="the-script-element:attr-script-type-8"><a href="#attr-script-type">type</a></code> of "<code>module</code>", as that is an
  unknown script type for them — but they will have no problem fetching and evaluating the other
  <code id="the-script-element:the-script-element-19"><a href="#the-script-element">script</a></code> element (as a <a href="#classic-script" id="the-script-element:classic-script-12">classic script</a>), since they do not implement the
  <code id="the-script-element:attr-script-nomodule-4"><a href="#attr-script-nomodule">nomodule</a></code> attribute.</p>

  </div>

  <div id="script-type-module-example-2" class="example"><a href="#script-type-module-example-2" class="self-link"></a>

   <p>The following sample shows how a <code id="the-script-element:the-script-element-20"><a href="#the-script-element">script</a></code> element can be used to write an inline
   <a href="#javascript-module-script" id="the-script-element:javascript-module-script-9">JavaScript module script</a> that performs a number of substitutions on the document's
   text, in order to make for a more interesting reading experience (e.g. on a news site):
   <a href="#refsXKCD1288">[XKCD1288]</a></p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"module"</c-><c- p="">&gt;</c->
 <c- k="">import</c-> <c- p="">{</c-> walkAllTextNodeDescendants <c- p="">}</c-> <c- k="">from</c-> <c- u="">"./dom-utils.mjs"</c-><c- p="">;</c->

 <c- a="">const</c-> substitutions <c- o="">=</c-> <c- k="">new</c-> Map<c- p="">([</c->
   <c- p="">[</c-><c- u="">"witnesses"</c-><c- p="">,</c-> <c- u="">"these dudes I know"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"allegedly"</c-><c- p="">,</c-> <c- u="">"kinda probably"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"new study"</c-><c- p="">,</c-> <c- u="">"Tumblr post"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"rebuild"</c-><c- p="">,</c-> <c- u="">"avenge"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"space"</c-><c- p="">,</c-> <c- u="">"spaaace"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"Google glass"</c-><c- p="">,</c-> <c- u="">"Virtual Boy"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"smartphone"</c-><c- p="">,</c-> <c- u="">"Pokédex"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"electric"</c-><c- p="">,</c-> <c- u="">"atomic"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"Senator"</c-><c- p="">,</c-> <c- u="">"Elf-Lord"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"car"</c-><c- p="">,</c-> <c- u="">"cat"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"election"</c-><c- p="">,</c-> <c- u="">"eating contest"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"Congressional leaders"</c-><c- p="">,</c-> <c- u="">"river spirits"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"homeland security"</c-><c- p="">,</c-> <c- u="">"Homestar Runner"</c-><c- p="">]</c->
   <c- p="">[</c-><c- u="">"could not be reached for comment"</c-><c- p="">,</c-> <c- u="">"is guilty and everyone knows it"</c-><c- p="">]</c->
 <c- p="">]);</c->

 <c- a="">function</c-> substitute<c- p="">(</c->textNode<c- p="">)</c-> <c- p="">{</c->
   <c- k="">for</c-> <c- p="">(</c-><c- a="">const</c-> <c- p="">[</c->before<c- p="">,</c-> after<c- p="">]</c-> <c- k="">of</c-> substitutions<c- p="">.</c->entries<c- p="">())</c-> <c- p="">{</c->
     textNode<c- p="">.</c->data <c- o="">=</c-> textNode<c- p="">.</c->data<c- p="">.</c->replace<c- p="">(</c-><c- k="">new</c-> RegExp<c- p="">(</c-><c- sb="">`\\b</c-><c- si="">${</c->before<c- si="">}</c-><c- sb="">\\b`</c-><c- p="">,</c-> <c- u="">"ig"</c-><c- p="">),</c-> after<c- p="">);</c->
   <c- p="">}</c->
 <c- p="">}</c->

 walkAllTextNodeDescendants<c- p="">(</c->document<c- p="">.</c->body<c- p="">,</c-> substitute<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>Some notable features gained by using a JavaScript module script include the ability to import
   functions from other JavaScript modules, strict mode by default, and how top-level declarations
   do not introduce new properties onto the <a href="#global-object" id="the-script-element:global-object">global object</a>. Also note that no matter
   where this <code id="the-script-element:the-script-element-21"><a href="#the-script-element">script</a></code> element appears in the document, it will not be evaluated until
   both document parsing has complete and its dependency (<code>dom-utils.mjs</code>) has
   been fetched and evaluated.</p>
  </div>

  <div id="json-module-script-example" class="example"><a href="#json-module-script-example" class="self-link"></a>
   <p>The following sample shows how a <a href="#json-module-script" id="the-script-element:json-module-script">JSON module script</a> can be imported from inside
   a <a href="#javascript-module-script" id="the-script-element:javascript-module-script-10">JavaScript module script</a>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"module"</c-><c- p="">&gt;</c->
 <c- k="">import</c-> peopleInSpace <c- k="">from</c-> <c- u="">"http://api.open-notify.org/astros.json"</c-> <c- a="">with</c-> <c- p="">{</c-> type<c- o="">:</c-> <c- u="">"json"</c-> <c- p="">};</c->

 <c- a="">const</c-> list <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"#people-in-space"</c-><c- p="">);</c->
 <c- k="">for</c-> <c- p="">(</c-><c- a="">const</c-> <c- p="">{</c-> craft<c- p="">,</c-> name <c- p="">}</c-> <c- k="">of</c-> peopleInSpace<c- p="">.</c->people<c- p="">)</c-> <c- p="">{</c->
   <c- a="">const</c-> li <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"li"</c-><c- p="">);</c->
   li<c- p="">.</c->textContent <c- o="">=</c-> <c- sb="">`</c-><c- si="">${</c->name<c- si="">}</c-><c- sb=""> / </c-><c- si="">${</c->craft<c- si="">}</c-><c- sb="">`</c-><c- p="">;</c->
   list<c- p="">.</c->append<c- p="">(</c->li<c- p="">);</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>MIME type checking for module scripts is strict. In order for the fetch of the <a href="#json-module-script" id="the-script-element:json-module-script-2">JSON
   module script</a> to succeed, the HTTP response must have a <a id="the-script-element:json-mime-type" href="https://mimesniff.spec.whatwg.org/#json-mime-type" data-x-internal="json-mime-type">JSON MIME type</a>, for
   example <code>Content-Type: text/json</code>. On the other hand, if the <code>with { type: "json" }</code> part of the statement is omitted, it is assumed that the
   intent is to import a <a href="#javascript-module-script" id="the-script-element:javascript-module-script-11">JavaScript module script</a>, and the fetch will fail if the HTTP
   response has a MIME type that is not a <a id="the-script-element:javascript-mime-type" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type" data-x-internal="javascript-mime-type">JavaScript MIME type</a>.</p>
  </div>

  

  <h5 id="script-processing-model"><span class="secno">4.12.1.1</span> Processing model<a href="#script-processing-model" class="self-link"></a></h5>

  <p>A <code id="script-processing-model:the-script-element"><a href="#the-script-element">script</a></code> element has several associated pieces of state.</p>

  <p>A <code id="script-processing-model:the-script-element-2"><a href="#the-script-element">script</a></code> element has a <dfn id="parser-document">parser document</dfn>, which is either null or a
  <code id="script-processing-model:document"><a href="#document">Document</a></code>, initially null. It is set by the <a href="#html-parser" id="script-processing-model:html-parser">HTML parser</a> and the
  <a href="#xml-parser" id="script-processing-model:xml-parser">XML parser</a> on <code id="script-processing-model:the-script-element-3"><a href="#the-script-element">script</a></code> elements they insert, and affects the processing
  of those elements. <code id="script-processing-model:the-script-element-4"><a href="#the-script-element">script</a></code> elements with non-null <a href="#parser-document" id="script-processing-model:parser-document">parser documents</a> are known as <dfn data-dfn-for="script" id="parser-inserted" data-export="">parser-inserted</dfn>.</p>

  <p>A <code id="script-processing-model:the-script-element-5"><a href="#the-script-element">script</a></code> element has a <dfn id="preparation-time-document">preparation-time document</dfn>, which is either null
  or a <code id="script-processing-model:document-2"><a href="#document">Document</a></code>, initially null. It is used to prevent scripts that move between
  documents during <a href="#prepare-the-script-element" id="script-processing-model:prepare-the-script-element">preparation</a> from <a href="#execute-the-script-element" id="script-processing-model:execute-the-script-element">executing</a>.</p>

  <p id="non-blocking">A <code id="script-processing-model:the-script-element-6"><a href="#the-script-element">script</a></code> element has a <dfn id="script-force-async">force
  async</dfn> boolean, initially true. It is set to false by the <a href="#html-parser" id="script-processing-model:html-parser-2">HTML parser</a> and the
  <a href="#xml-parser" id="script-processing-model:xml-parser-2">XML parser</a> on <code id="script-processing-model:the-script-element-7"><a href="#the-script-element">script</a></code> elements they insert, and when the element gets an
  <code id="script-processing-model:attr-script-async"><a href="#attr-script-async">async</a></code> content attribute added.</p>

  <p>A <code id="script-processing-model:the-script-element-8"><a href="#the-script-element">script</a></code> element has a <dfn id="concept-script-external">from an external
  file</dfn> boolean, initially false. It is determined when the script is <a href="#prepare-the-script-element" id="script-processing-model:prepare-the-script-element-2">prepared</a>, based on the <code id="script-processing-model:attr-script-src"><a href="#attr-script-src">src</a></code>
  attribute of the element at that time.</p>

  <p>A <code id="script-processing-model:the-script-element-9"><a href="#the-script-element">script</a></code> element has a <dfn id="ready-to-be-parser-executed">ready to be parser-executed</dfn> boolean, initially
  false. This is used only used for elements that are also <a href="#parser-inserted" id="script-processing-model:parser-inserted">parser-inserted</a>, to let the
  parser know when to execute the script.</p>

  <p>A <code id="script-processing-model:the-script-element-10"><a href="#the-script-element">script</a></code> element has an <dfn id="already-started">already started</dfn> boolean, initially false.</p>

  <p>A <code id="script-processing-model:the-script-element-11"><a href="#the-script-element">script</a></code> element has a <dfn id="concept-script-delay-load">delaying the
  load event</dfn> boolean, initially false.</p>

  <p>A <code id="script-processing-model:the-script-element-12"><a href="#the-script-element">script</a></code> element has a <dfn id="concept-script-type">type</dfn>, which is
  either null, "<code>classic</code>", "<code>module</code>", "<code>importmap</code>", or "<code>speculationrules</code>", initially null. It is
  determined when the element is <a href="#prepare-the-script-element" id="script-processing-model:prepare-the-script-element-3">prepared</a>, based on
  the <code id="script-processing-model:attr-script-type"><a href="#attr-script-type">type</a></code> attribute of the element at that time.</p>

  <p id="concept-script-script">A <code id="script-processing-model:the-script-element-13"><a href="#the-script-element">script</a></code> element has a <dfn id="concept-script-result">result</dfn>, which is either "<code>uninitialized</code>", null (representing an error), a <a href="#concept-script" id="script-processing-model:concept-script">script</a>, an <a href="#import-map-parse-result" id="script-processing-model:import-map-parse-result">import map parse result</a>, or a
  <a href="#speculation-rules-parse-result" id="script-processing-model:speculation-rules-parse-result">speculation rules parse result</a>. It is initially "<code>uninitialized</code>".</p>

  <div data-algorithm="">
  <p id="the-script-is-ready">A <code id="script-processing-model:the-script-element-14"><a href="#the-script-element">script</a></code> element has <dfn id="steps-to-run-when-the-result-is-ready">steps to run when the result
  is ready</dfn>, which are a series of steps or null, initially null. To <dfn id="mark-as-ready">mark as ready</dfn> a
  <code id="script-processing-model:the-script-element-15"><a href="#the-script-element">script</a></code> element <var>el</var> given a <var>result</var>:</p>

  <ol><li><p>Set <var>el</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result">result</a> to
   <var>result</var>.</p></li><li><p>If <var>el</var>'s <a href="#steps-to-run-when-the-result-is-ready" id="script-processing-model:steps-to-run-when-the-result-is-ready">steps to run when the result is ready</a> are not null, then
   run them.</p></li><li><p>Set <var>el</var>'s <a href="#steps-to-run-when-the-result-is-ready" id="script-processing-model:steps-to-run-when-the-result-is-ready-2">steps to run when the result is ready</a> to null.</p></li><li><p>Set <var>el</var>'s <a href="#concept-script-delay-load" id="script-processing-model:concept-script-delay-load">delaying the load
   event</a> to false.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>A <code id="script-processing-model:the-script-element-16"><a href="#the-script-element">script</a></code> element <var>el</var> is <a href="#implicitly-potentially-render-blocking" id="script-processing-model:implicitly-potentially-render-blocking">implicitly potentially
  render-blocking</a> if <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type">type</a> is
  "<code>classic</code>", <var>el</var> is <a href="#parser-inserted" id="script-processing-model:parser-inserted-2">parser-inserted</a>, and
  <var>el</var> does not have an <code id="script-processing-model:attr-script-async-2"><a href="#attr-script-async">async</a></code> or <code id="script-processing-model:attr-script-defer"><a href="#attr-script-defer">defer</a></code> attribute.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="https://dom.spec.whatwg.org/#concept-node-clone-ext" id="script-processing-model:concept-node-clone-ext" data-x-internal="concept-node-clone-ext">cloning steps</a> for <code id="script-processing-model:the-script-element-17"><a href="#the-script-element">script</a></code>
  elements given <var>node</var>, <var>copy</var>, and <var>subtree</var> are to set
  <var>copy</var>'s <a href="#already-started" id="script-processing-model:already-started">already started</a> to <var>node</var>'s <a href="#already-started" id="script-processing-model:already-started-2">already
  started</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When an <code id="script-processing-model:attr-script-async-3"><a href="#attr-script-async">async</a></code> attribute is added to a
  <code id="script-processing-model:the-script-element-18"><a href="#the-script-element">script</a></code> element <var>el</var>, the user agent must set <var>el</var>'s
  <a href="#script-force-async" id="script-processing-model:script-force-async">force async</a> to false.</p>
  </div>
  

  <div data-algorithm="">
  <p>Whenever a <code id="script-processing-model:the-script-element-19"><a href="#the-script-element">script</a></code> element <var>el</var>'s <a href="#concept-script-delay-load" id="script-processing-model:concept-script-delay-load-2">delaying the load event</a> is true, the user agent must
  <a href="#delay-the-load-event" id="script-processing-model:delay-the-load-event">delay the load event</a> of <var>el</var>'s <a href="#preparation-time-document" id="script-processing-model:preparation-time-document">preparation-time document</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <code id="script-processing-model:the-script-element-20"><a href="#the-script-element">script</a></code> <a href="#html-element-post-connection-steps" id="script-processing-model:html-element-post-connection-steps">HTML element post-connection steps</a>, given
  <var>insertedNode</var>, are:</p>

  <ol><li><p>If <var>insertedNode</var> is <a href="#parser-inserted" id="script-processing-model:parser-inserted-3">parser-inserted</a>, then return.</p></li><li><p><a href="#prepare-the-script-element" id="script-processing-model:prepare-the-script-element-4">Prepare the script element</a> given <var>insertedNode</var>.</p></li></ol>
  </div>

  <div class="example">
   <p>The <a href="#html-element-post-connection-steps" id="script-processing-model:html-element-post-connection-steps-2">HTML element post-connection steps</a> only run when the inserted element is
   still <a id="script-processing-model:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, which protects against cases where an earlier-inserted
   <code id="script-processing-model:the-script-element-21"><a href="#the-script-element">script</a></code> removes a later-inserted <code id="script-processing-model:the-script-element-22"><a href="#the-script-element">script</a></code>. For instance:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- a="">const</c-> script1 <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'script'</c-><c- p="">);</c->
script1<c- p="">.</c->innerText <c- o="">=</c-> <c- sb="">`</c->
<c- sb="">  document.querySelector('#script2').remove();</c->
<c- sb="">`</c-><c- p="">;</c->

<c- a="">const</c-> script2 <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'script'</c-><c- p="">);</c->
script2<c- p="">.</c->id <c- o="">=</c-> <c- t="">'script2'</c-><c- p="">;</c->
script2<c- p="">.</c->textContent <c- o="">=</c-> <c- sb="">`console.log('script#2 running')`</c-><c- p="">;</c->

document<c- p="">.</c->body<c- p="">.</c->append<c- p="">(</c->script1<c- p="">,</c-> script2<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>Nothing is printed to the console in this example. By the time the <a href="#html-element-post-connection-steps" id="script-processing-model:html-element-post-connection-steps-3">HTML element
   post-connection steps</a> run for the first <code id="script-processing-model:the-script-element-23"><a href="#the-script-element">script</a></code> that was atomically inserted
   by <code id="script-processing-model:dom-node-append"><a data-x-internal="dom-node-append" href="https://dom.spec.whatwg.org/#dom-node-append">append()</a></code>, it can observe that the second
   <code id="script-processing-model:the-script-element-24"><a href="#the-script-element">script</a></code> is already <a id="script-processing-model:connected-2" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a> to the DOM, and it removes it from the DOM.
   Because the second <code id="script-processing-model:the-script-element-25"><a href="#the-script-element">script</a></code> is no longer <a id="script-processing-model:connected-3" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, its <a href="#html-element-post-connection-steps" id="script-processing-model:html-element-post-connection-steps-4">HTML
   element post-connection steps</a> do not run, and it does not get <a href="#prepare-the-script-element" id="script-processing-model:prepare-the-script-element-5">prepared</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="script-processing-model:the-script-element-26"><a href="#the-script-element">script</a></code> <a href="#html-element-removing-steps" id="script-processing-model:html-element-removing-steps">HTML element removing steps</a> given <var>removedNode</var>
  are:</p>

  <ol><li>
    <p>If <var>removedNode</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-2">result</a> is a
    <a href="#speculation-rules-parse-result" id="script-processing-model:speculation-rules-parse-result-2">speculation rules parse result</a>, then:</p>

    <ol><li><p><a href="#unregister-speculation-rules" id="script-processing-model:unregister-speculation-rules">Unregister speculation rules</a> given <var>removedNode</var>'s <a href="#concept-relevant-global" id="script-processing-model:concept-relevant-global">relevant
     global object</a> and <var>removedNode</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-3">result</a>.</p></li><li><p>Set <var>removedNode</var>'s <a href="#already-started" id="script-processing-model:already-started-3">already started</a> to false.</p></li><li><p>Set <var>removedNode</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-4">result</a> to
     null.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="script-processing-model:the-script-element-27"><a href="#the-script-element">script</a></code> <a id="script-processing-model:children-changed-steps" href="https://dom.spec.whatwg.org/#concept-node-children-changed-ext" data-x-internal="children-changed-steps">children changed steps</a> given <var>changedNode</var>
  are:</p>

  <ol><li><p>If the <code id="script-processing-model:the-script-element-28"><a href="#the-script-element">script</a></code> element is not <a id="script-processing-model:connected-4" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li><p>Run the <code id="script-processing-model:the-script-element-29"><a href="#the-script-element">script</a></code> <a href="#html-element-post-connection-steps" id="script-processing-model:html-element-post-connection-steps-5">HTML element post-connection steps</a>, given
   <var>changedNode</var>.</p></li></ol>
  </div>

  <div class="example">
   <p>This has an interesting implication on the execution order of a <code id="script-processing-model:the-script-element-30"><a href="#the-script-element">script</a></code> element
   and any newly-inserted child <code id="script-processing-model:the-script-element-31"><a href="#the-script-element">script</a></code> elements. Consider the following snippet:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">outer-script</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">const</c-> outerScript <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- t="">'#outer-script'</c-><c- p="">);</c->

  <c- a="">const</c-> start <c- o="">=</c-> <c- k="">new</c-> Text<c- p="">(</c-><c- t="">'console.log(1);'</c-><c- p="">);</c->
  <c- a="">const</c-> innerScript <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'script'</c-><c- p="">);</c->
  innerScript<c- p="">.</c->textContent <c- o="">=</c-> <c- sb="">`console.log('inner script executing')`</c-><c- p="">;</c->
  <c- a="">const</c-> end <c- o="">=</c-> <c- k="">new</c-> Text<c- p="">(</c-><c- t="">'console.log(2);'</c-><c- p="">);</c->

  outerScript<c- p="">.</c->append<c- p="">(</c->start<c- p="">,</c-> innerScript<c- p="">,</c-> end<c- p="">);</c->

  <c- c1="">// Logs:</c->
  <c- c1="">// 1</c->
  <c- c1="">// 2</c->
  <c- c1="">// inner script executing</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>By the time the second script block executes, the <code>outer-script</code> has
   already been <a href="#prepare-the-script-element" id="script-processing-model:prepare-the-script-element-6">prepared</a>, but because it is empty,
   it did not execute and therefore is not marked as <a href="#already-started" id="script-processing-model:already-started-4">already started</a>. The atomic
   insertion of the <code id="script-processing-model:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes and nested <code id="script-processing-model:the-script-element-32"><a href="#the-script-element">script</a></code> element have the
   following effects:</p>

   <ol><li><p>All three child nodes get atomically inserted as children of <code>outer-script</code>; all of their <a href="https://dom.spec.whatwg.org/#concept-node-insert-ext" id="script-processing-model:concept-node-insert-ext" data-x-internal="concept-node-insert-ext">insertion
    steps</a> run, which have no observable consequences in this case.</p></li><li><p>The <code>outer-script</code>'s <a id="script-processing-model:children-changed-steps-2" href="https://dom.spec.whatwg.org/#concept-node-children-changed-ext" data-x-internal="children-changed-steps">children changed steps</a> run, which
    <a href="#prepare-the-script-element" id="script-processing-model:prepare-the-script-element-7">prepares</a> that script; because its body is now
    non-empty, this executes the contents of the two <code id="script-processing-model:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes, in order.</p></li><li><p>The <code id="script-processing-model:the-script-element-33"><a href="#the-script-element">script</a></code> <a href="#html-element-post-connection-steps" id="script-processing-model:html-element-post-connection-steps-6">HTML element post-connection steps</a> finally run for
    <code>innerScript</code>, causing its body to execute.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The following <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="script-processing-model:concept-element-attributes-change-ext" data-x-internal="concept-element-attributes-change-ext">attribute change
  steps</a>, given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
  <var>value</var>, and <var>namespace</var>, are used for all <code id="script-processing-model:the-script-element-34"><a href="#the-script-element">script</a></code> elements:</p>

  <ol><li><p>If <var>namespace</var> is not null, then return.</p></li><li><p>If <var>localName</var> is <code id="script-processing-model:attr-script-src-2"><a href="#attr-script-src">src</a></code> and
   <var>element</var> is <a id="script-processing-model:connected-5" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then run the <code id="script-processing-model:the-script-element-35"><a href="#the-script-element">script</a></code> <a href="#html-element-post-connection-steps" id="script-processing-model:html-element-post-connection-steps-7">HTML element
   post-connection steps</a>, given <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="prepare-a-script">To <dfn id="prepare-the-script-element">prepare the script element</dfn> given a <code id="script-processing-model:the-script-element-36"><a href="#the-script-element">script</a></code>
  element <var>el</var>:</p>

  <ol><li><p>If <var>el</var>'s <a href="#already-started" id="script-processing-model:already-started-5">already started</a> is true, then return.</p></li><li><p>Let <var>parser document</var> be <var>el</var>'s <a href="#parser-document" id="script-processing-model:parser-document-2">parser document</a>.</p></li><li>
    <p>Set <var>el</var>'s <a href="#parser-document" id="script-processing-model:parser-document-3">parser document</a> to null.</p>

    <p class="note">This is done so that if parser-inserted <code id="script-processing-model:the-script-element-37"><a href="#the-script-element">script</a></code> elements fail to run
    when the parser tries to run them, e.g. because they are empty or specify an unsupported
    scripting language, another script can later mutate them and cause them to run again.</p>
   </li><li>
    <p>If <var>parser document</var> is non-null and <var>el</var> does not have an <code id="script-processing-model:attr-script-async-4"><a href="#attr-script-async">async</a></code> attribute, then set <var>el</var>'s <a href="#script-force-async" id="script-processing-model:script-force-async-2">force async</a> to true.</p>

    <p class="note">This is done so that if a parser-inserted <code id="script-processing-model:the-script-element-38"><a href="#the-script-element">script</a></code> element fails to
    run when the parser tries to run it, but it is later executed after a script dynamically
    updates it, it will execute in an async fashion even if the <code id="script-processing-model:attr-script-async-5"><a href="#attr-script-async">async</a></code> attribute isn't set.</p>
   </li><li><p>Let <var>source text</var> be <var>el</var>'s <a id="script-processing-model:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a>.</p></li><li id="script-processing-empty"><p>If <var>el</var> has no <code id="script-processing-model:attr-script-src-3"><a href="#attr-script-src">src</a></code> attribute, and <var>source text</var> is the empty string,
   then return.</p></li><li><p>If <var>el</var> is not <a id="script-processing-model:connected-6" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li id="script-processing-prepare">
    <p>If any of the following are true:</p>

    <ul><li><p><var>el</var> has a <code id="script-processing-model:attr-script-type-2"><a href="#attr-script-type">type</a></code> attribute whose value is
     the empty string;</p></li><li><p><var>el</var> has no <code id="script-processing-model:attr-script-type-3"><a href="#attr-script-type">type</a></code> attribute but it has a
     <code id="script-processing-model:attr-script-language"><a href="#attr-script-language">language</a></code> attribute and <em>that</em> attribute's
     value is the empty string; or</p></li><li><p><var>el</var> has neither a <code id="script-processing-model:attr-script-type-4"><a href="#attr-script-type">type</a></code> attribute nor a
     <code id="script-processing-model:attr-script-language-2"><a href="#attr-script-language">language</a></code> attribute,</p></li></ul>

    <p>then let <var>the script block's type string</var> for this <code id="script-processing-model:the-script-element-39"><a href="#the-script-element">script</a></code> element be
    "<code>text/javascript</code>".</p>

    <p>Otherwise, if <var>el</var> has a <code id="script-processing-model:attr-script-type-5"><a href="#attr-script-type">type</a></code> attribute, then
    let <var>the script block's type string</var> be the value of that attribute with <a href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" id="script-processing-model:strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">leading and trailing ASCII whitespace
    stripped</a>.</p>

    <p>Otherwise, <var>el</var> has a non-empty <code id="script-processing-model:attr-script-language-3"><a href="#attr-script-language">language</a></code>
    attribute; let <var>the script block's type string</var> be the concatenation of "<code>text/</code>" and the value of <var>el</var>'s <code id="script-processing-model:attr-script-language-4"><a href="#attr-script-language">language</a></code> attribute.</p>
    

    <p class="note">The <code id="script-processing-model:attr-script-language-5"><a href="#attr-script-language">language</a></code> attribute is never
    conforming, and is always ignored if there is a <code id="script-processing-model:attr-script-type-6"><a href="#attr-script-type">type</a></code>
    attribute present.</p>
   </li><li><p>If <var>the script block's type string</var> is a <a id="script-processing-model:javascript-mime-type-essence-match" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match" data-x-internal="javascript-mime-type-essence-match">JavaScript MIME type essence
   match</a>, then set <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-2">type</a> to "<code>classic</code>".</p></li><li><p>Otherwise, if <var>the script block's type string</var> is an <a id="script-processing-model:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
   case-insensitive</a> match for the string "<code>module</code>", then set
   <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-3">type</a> to "<code>module</code>".</p></li><li><p>Otherwise, if <var>the script block's type string</var> is an <a id="script-processing-model:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
   case-insensitive</a> match for the string "<code>importmap</code>", then set
   <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-4">type</a> to "<code>importmap</code>".</p></li><li><p>Otherwise, if <var>the script block's type string</var> is an <a id="script-processing-model:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
   case-insensitive</a> match for the string "<code>speculationrules</code>", then set
   <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-5">type</a> to "<code>speculationrules</code>".</p></li><li><p>Otherwise, return. (No script is executed, and <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-6">type</a> is left as null.)</p></li><li><p>If <var>parser document</var> is non-null, then set <var>el</var>'s <a href="#parser-document" id="script-processing-model:parser-document-4">parser
   document</a> back to <var>parser document</var> and set <var>el</var>'s <a href="#script-force-async" id="script-processing-model:script-force-async-3">force async</a> to false.</p></li><li id="script-processing-start"><p>Set <var>el</var>'s <a href="#already-started" id="script-processing-model:already-started-6">already started</a> to
   true.</p></li><li><p>Set <var>el</var>'s <a href="#preparation-time-document" id="script-processing-model:preparation-time-document-2">preparation-time document</a> to its <a id="script-processing-model:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a>.</p>

   </li><li><p>If <var>parser document</var> is non-null, and <var>parser document</var> is not equal to
   <var>el</var>'s <a href="#preparation-time-document" id="script-processing-model:preparation-time-document-3">preparation-time document</a>, then return.</p></li><li id="script-processing-noscript"> <p>If <a href="#concept-n-noscript" id="script-processing-model:concept-n-noscript">scripting is
   disabled</a> for <var>el</var>, then return.</p>

    <p class="note">The definition of <a href="#concept-n-noscript" id="script-processing-model:concept-n-noscript-2">scripting is
    disabled</a> means that, amongst others, the following scripts will not execute: scripts in
    <code id="script-processing-model:xmlhttprequest"><a data-x-internal="xmlhttprequest" href="https://xhr.spec.whatwg.org/#xmlhttprequest">XMLHttpRequest</a></code>'s <code id="script-processing-model:dom-xmlhttprequest-responsexml"><a data-x-internal="dom-xmlhttprequest-responsexml" href="https://xhr.spec.whatwg.org/#dom-xmlhttprequest-responsexml">responseXML</a></code>
    documents, scripts in <code id="script-processing-model:domparser"><a href="#domparser">DOMParser</a></code>-created documents, scripts in documents created by
    <code id="script-processing-model:xsltprocessor"><a href="#xsltprocessor">XSLTProcessor</a></code>'s <code id="script-processing-model:dom-xsltprocessor-transformtodocument"><a href="#dom-xsltprocessor-transformtodocument">transformToDocument</a></code> feature, and scripts
    that are first inserted by a script into a <code id="script-processing-model:document-3"><a href="#document">Document</a></code> that was created using the
    <code id="script-processing-model:dom-domimplementation-createdocument"><a data-x-internal="dom-domimplementation-createdocument" href="https://dom.spec.whatwg.org/#dom-domimplementation-createdocument">createDocument()</a></code> API. <a href="#refsXHR">[XHR]</a>
    <a href="#refsDOMPARSING">[DOMPARSING]</a> <a href="#refsXSLTP">[XSLTP]</a> <a href="#refsDOM">[DOM]</a></p>
   </li><li>
    <p>If <var>el</var> has a <code id="script-processing-model:attr-script-nomodule"><a href="#attr-script-nomodule">nomodule</a></code> content attribute
    and its <a href="#concept-script-type" id="script-processing-model:concept-script-type-7">type</a> is "<code>classic</code>",
    then return.</p>

    <p class="note">This means specifying <code id="script-processing-model:attr-script-nomodule-2"><a href="#attr-script-nomodule">nomodule</a></code> on a
    <a href="#module-script" id="script-processing-model:module-script">module script</a> has no effect; the algorithm continues onward.</p>
   </li><li><p>Let <var>cspType</var> be "<code>script speculationrules</code>" if
   <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-8">type</a> is "<code>speculationrules</code>"; otherwise, "<code>script</code>".</p></li><li id="script-processing-csp"><p>If <var>el</var> does not have a <code id="script-processing-model:attr-script-src-4"><a href="#attr-script-src">src</a></code> content attribute, and the <a id="script-processing-model:should-element's-inline-behavior-be-blocked-by-content-security-policy" href="https://w3c.github.io/webappsec-csp/#should-block-inline" data-x-internal="should-element's-inline-behavior-be-blocked-by-content-security-policy">Should element's inline
   behavior be blocked by Content Security Policy?</a> algorithm returns "<code>Blocked</code>" when given <var>el</var>, <var>cspType</var>, and <var>source
   text</var>, then return. <a href="#refsCSP">[CSP]</a></p></li><li id="script-processing-for">
    <p>If <var>el</var> has an <code id="script-processing-model:attr-script-event"><a href="#attr-script-event">event</a></code> attribute and a <code id="script-processing-model:attr-script-for"><a href="#attr-script-for">for</a></code> attribute, and <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-9">type</a> is "<code>classic</code>", then:</p>

    <ol><li><p>Let <var>for</var> be the value of <var>el</var>'s <code id="script-processing-model:attr-script-for-2"><a href="#attr-script-for">for</a></code> attribute.</p></li><li><p>Let <var>event</var> be the value of <var>el</var>'s <code id="script-processing-model:attr-script-event-2"><a href="#attr-script-event">event</a></code> attribute.</p></li><li><p><a id="script-processing-model:strip-leading-and-trailing-ascii-whitespace-2" href="https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace" data-x-internal="strip-leading-and-trailing-ascii-whitespace">Strip leading and trailing ASCII whitespace</a> from <var>event</var> and
     <var>for</var>.</p></li><li><p>If <var>for</var> is not an <a id="script-processing-model:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string
     "<code>window</code>", then return.</p></li><li><p>If <var>event</var> is not an <a id="script-processing-model:ascii-case-insensitive-5" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for either the
     string "<code>onload</code>" or the string "<code>onload()</code>", then
     return.</p></li></ol>
   </li><li id="script-processing-encoding">
    <p>If <var>el</var> has a <code id="script-processing-model:attr-script-charset"><a href="#attr-script-charset">charset</a></code> attribute, then let
    <var>encoding</var> be the result of <a id="script-processing-model:getting-an-encoding" href="https://encoding.spec.whatwg.org/#concept-encoding-get" data-x-internal="getting-an-encoding">getting an encoding</a> from the value of the
    <code id="script-processing-model:attr-script-charset-2"><a href="#attr-script-charset">charset</a></code> attribute.</p>

    <p>If <var>el</var> does not have a <code id="script-processing-model:attr-script-charset-3"><a href="#attr-script-charset">charset</a></code>
    attribute, or if <a id="script-processing-model:getting-an-encoding-2" href="https://encoding.spec.whatwg.org/#concept-encoding-get" data-x-internal="getting-an-encoding">getting an encoding</a> failed, then let <var>encoding</var> be
    <var>el</var>'s <a id="script-processing-model:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="script-processing-model:document's-character-encoding" data-x-internal="document's-character-encoding">the
    encoding</a>.</p>

    <p class="note">If <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-10">type</a> is "<code>module</code>", this encoding will be ignored.</p>
   </li><li><p>Let <var>classic script CORS setting</var> be the current state of <var>el</var>'s <code id="script-processing-model:attr-script-crossorigin"><a href="#attr-script-crossorigin">crossorigin</a></code> content attribute.</p></li><li><p>Let <var>module script credentials mode</var> be the <a href="#cors-settings-attribute-credentials-mode" id="script-processing-model:cors-settings-attribute-credentials-mode">CORS settings attribute
   credentials mode</a> for <var>el</var>'s <code id="script-processing-model:attr-script-crossorigin-2"><a href="#attr-script-crossorigin">crossorigin</a></code> content attribute.</p>

   </li><li><p>Let <var>cryptographic nonce</var> be <var>el</var>'s <a href="#cryptographicnonce" id="script-processing-model:cryptographicnonce">[[CryptographicNonce]]</a>
   internal slot's value.</p></li><li>
    <p>If <var>el</var> has an <code id="script-processing-model:attr-script-integrity"><a href="#attr-script-integrity">integrity</a></code> attribute,
    then let <var>integrity metadata</var> be that attribute's value.</p>

    <p>Otherwise, let <var>integrity metadata</var> be the empty string.</p>
   </li><li><p>Let <var>referrer policy</var> be the current state of <var>el</var>'s <code id="script-processing-model:attr-script-referrerpolicy"><a href="#attr-script-referrerpolicy">referrerpolicy</a></code> content attribute.</p></li><li><p>Let <var>fetch priority</var> be the current state of <var>el</var>'s <code id="script-processing-model:attr-script-fetchpriority"><a href="#attr-script-fetchpriority">fetchpriority</a></code> content attribute.</p></li><li><p>Let <var>parser metadata</var> be "<code>parser-inserted</code>" if
   <var>el</var> is <a href="#parser-inserted" id="script-processing-model:parser-inserted-4">parser-inserted</a>, and "<code>not-parser-inserted</code>"
   otherwise.</p></li><li><p>Let <var>options</var> be a <a href="#script-fetch-options" id="script-processing-model:script-fetch-options">script fetch options</a> whose <a href="#concept-script-fetch-options-nonce" id="script-processing-model:concept-script-fetch-options-nonce">cryptographic nonce</a> is <var>cryptographic
   nonce</var>, <a href="#concept-script-fetch-options-integrity" id="script-processing-model:concept-script-fetch-options-integrity">integrity metadata</a> is
   <var>integrity metadata</var>, <a href="#concept-script-fetch-options-parser" id="script-processing-model:concept-script-fetch-options-parser">parser
   metadata</a> is <var>parser metadata</var>, <a href="#concept-script-fetch-options-credentials" id="script-processing-model:concept-script-fetch-options-credentials">credentials mode</a> is <var>module script
   credentials mode</var>, <a href="#concept-script-fetch-options-referrer-policy" id="script-processing-model:concept-script-fetch-options-referrer-policy">referrer
   policy</a> is <var>referrer policy</var>, and <a href="#concept-script-fetch-options-fetch-priority" id="script-processing-model:concept-script-fetch-options-fetch-priority">fetch priority</a> is <var>fetch
   priority</var>.</p></li><li><p>Let <var>settings object</var> be <var>el</var>'s <a id="script-processing-model:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
   <a href="#relevant-settings-object" id="script-processing-model:relevant-settings-object">relevant settings object</a>.</p></li><li id="script-processing-src-prepare">
    <p>If <var>el</var> has a <code id="script-processing-model:attr-script-src-5"><a href="#attr-script-src">src</a></code> content attribute, then:</p>

    <ol><li>
      <p>If <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-11">type</a> is "<code>importmap</code>" or "<code>speculationrules</code>", then <a href="#queue-an-element-task" id="script-processing-model:queue-an-element-task">queue an
      element task</a> on the <a href="#dom-manipulation-task-source" id="script-processing-model:dom-manipulation-task-source">DOM manipulation task source</a> given <var>el</var> to
      <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="script-processing-model:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="script-processing-model:event-error"><a href="#event-error">error</a></code> at <var>el</var>, and return.</p>

      <p class="note">External import maps and speculation rules are not currently supported. See <a href="https://github.com/WICG/import-maps/issues/235">WICG/import-maps issue #235</a> and <a href="https://github.com/WICG/nav-speculation/issues/348">WICG/nav-speculation issue #348</a>
      for discussions on adding support.</p>
     </li><li><p>Let <var>src</var> be the value of <var>el</var>'s <code id="script-processing-model:attr-script-src-6"><a href="#attr-script-src">src</a></code> attribute.</p></li><li><p>If <var>src</var> is the empty string, then <a href="#queue-an-element-task" id="script-processing-model:queue-an-element-task-2">queue an element task</a> on the
     <a href="#dom-manipulation-task-source" id="script-processing-model:dom-manipulation-task-source-2">DOM manipulation task source</a> given <var>el</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="script-processing-model:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="script-processing-model:event-error-2"><a href="#event-error">error</a></code>
     at <var>el</var>, and return.</p></li><li><p>Set <var>el</var>'s <a href="#concept-script-external" id="script-processing-model:concept-script-external">from an external file</a>
     to true.</p></li><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="script-processing-model:encoding-parsing-a-url">encoding-parsing a URL</a> given
     <var>src</var>, relative to <var>el</var>'s <a id="script-processing-model:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>url</var> is failure, then <a href="#queue-an-element-task" id="script-processing-model:queue-an-element-task-3">queue an element task</a> on the <a href="#dom-manipulation-task-source" id="script-processing-model:dom-manipulation-task-source-3">DOM
     manipulation task source</a> given <var>el</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="script-processing-model:concept-event-fire-3" data-x-internal="concept-event-fire">fire
     an event</a> named <code id="script-processing-model:event-error-3"><a href="#event-error">error</a></code> at <var>el</var>, and
     return.</p></li><li><p>If <var>el</var> is <a href="#potentially-render-blocking" id="script-processing-model:potentially-render-blocking">potentially render-blocking</a>, then <a href="#block-rendering" id="script-processing-model:block-rendering">block
     rendering</a> on <var>el</var>.</p></li><li><p>Set <var>el</var>'s <a href="#concept-script-delay-load" id="script-processing-model:concept-script-delay-load-3">delaying the load
     event</a> to true.</p></li><li><p>If <var>el</var> is currently <a href="#render-blocking" id="script-processing-model:render-blocking">render-blocking</a>, then set
     <var>options</var>'s <a href="#concept-script-fetch-options-render-blocking" id="script-processing-model:concept-script-fetch-options-render-blocking">
     render-blocking</a> to true.</p></li><li>
      <p>Let <var>onComplete</var> given <var>result</var> be the following steps:</p>

      <ol><li><p><a href="#mark-as-ready" id="script-processing-model:mark-as-ready">Mark as ready</a> <var>el</var> given <var>result</var>.</p></li></ol>
     </li><li>
      <p>Switch on <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-12">type</a>:</p>

      <dl class="switch"><dt>"<code>classic</code>"</dt><dd>
        <p><a href="#fetch-a-classic-script" id="script-processing-model:fetch-a-classic-script">Fetch a classic script</a> given <var>url</var>, <var>settings object</var>,
        <var>options</var>, <var>classic script CORS setting</var>, <var>encoding</var>, and
        <var>onComplete</var>.</p>
       </dd><dt>"<code>module</code>"</dt><dd>
        <p>If <var>el</var> does not have an <code id="script-processing-model:attr-script-integrity-2"><a href="#attr-script-integrity">integrity</a></code>
        attribute, then set <var>options</var>'s <a href="#concept-script-fetch-options-integrity" id="script-processing-model:concept-script-fetch-options-integrity-2">integrity metadata</a> to the result of
        <a href="#resolving-a-module-integrity-metadata" id="script-processing-model:resolving-a-module-integrity-metadata">resolving a module integrity metadata</a> with <var>url</var> and <var>settings
        object</var>.</p>

        <p><a href="#fetch-a-module-script-tree" id="script-processing-model:fetch-a-module-script-tree">Fetch an external module script graph</a> given <var>url</var>, <var>settings
        object</var>, <var>options</var>, and <var>onComplete</var>.</p>
       </dd></dl>

      <p>For performance reasons, user agents may start fetching the classic script or module graph
      (as defined above) as soon as the <code id="script-processing-model:attr-script-src-7"><a href="#attr-script-src">src</a></code> attribute is set,
      instead, in the hope that <var>el</var> will become connected (and that the <code id="script-processing-model:attr-script-crossorigin-3"><a href="#attr-script-crossorigin">crossorigin</a></code> attribute won't change value in the
      meantime). Either way, once <var>el</var> <a href="#becomes-connected" id="script-processing-model:becomes-connected">becomes connected</a>, the load must have
      started as described in this step. If the UA performs such prefetching, but <var>el</var>
      never becomes connected, or the <code id="script-processing-model:attr-script-src-8"><a href="#attr-script-src">src</a></code> attribute is
      dynamically changed,  or the <code id="script-processing-model:attr-script-crossorigin-4"><a href="#attr-script-crossorigin">crossorigin</a></code> attribute is dynamically changed, then the
      user agent will not execute the script so obtained, and the fetching process will have been
      effectively wasted.</p>
     </li></ol>
   </li><li id="establish-script-block-source">
    <p>If <var>el</var> does not have a <code id="script-processing-model:attr-script-src-9"><a href="#attr-script-src">src</a></code> content
    attribute:</p>

    <ol><li><p>Let <var>base URL</var> be <var>el</var>'s <a id="script-processing-model:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#document-base-url" id="script-processing-model:document-base-url">document
     base URL</a>.</p></li><li>
      <p>Switch on <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-13">type</a>:</p>

      <dl class="switch"><dt>"<code>classic</code>"</dt><dd>
        <ol><li><p>Let <var>script</var> be the result of <a href="#creating-a-classic-script" id="script-processing-model:creating-a-classic-script">creating a classic script</a> using
         <var>source text</var>, <var>settings object</var>, <var>base URL</var>, and
         <var>options</var>.</p></li><li><p><a href="#mark-as-ready" id="script-processing-model:mark-as-ready-2">Mark as ready</a> <var>el</var> given <var>script</var>.</p></li></ol>
       </dd><dt>"<code>module</code>"</dt><dd>
        <ol><li><p>Set <var>el</var>'s <a href="#concept-script-delay-load" id="script-processing-model:concept-script-delay-load-4">delaying the load
         event</a> to true.</p></li><li>
          <p>If <var>el</var> is <a href="#potentially-render-blocking" id="script-processing-model:potentially-render-blocking-2">potentially render-blocking</a>, then:</p>

          <ol><li><p><a href="#block-rendering" id="script-processing-model:block-rendering-2">Block rendering</a> on <var>el</var>.</p></li><li><p>Set <var>options</var>'s <a href="#concept-script-fetch-options-render-blocking" id="script-processing-model:concept-script-fetch-options-render-blocking-2">render-blocking</a> to
           true.</p></li></ol>
         </li><li>
          <p><a href="#fetch-an-inline-module-script-graph" id="script-processing-model:fetch-an-inline-module-script-graph">Fetch an inline module script graph</a>, given <var>source text</var>,
          <var>base URL</var>, <var>settings object</var>, <var>options</var>, and with the
          following steps given <var>result</var>:</p>

          <ol><li>
            <p><a href="#queue-an-element-task" id="script-processing-model:queue-an-element-task-4">Queue an element task</a> on the <a href="#networking-task-source" id="script-processing-model:networking-task-source">networking task source</a>
            given <var>el</var> to perform the following steps:</p>

            <ol><li><p><a href="#mark-as-ready" id="script-processing-model:mark-as-ready-3">Mark as ready</a> <var>el</var> given <var>result</var>.</p></li></ol>

            <p class="note">Queueing a task here means that, even if the inline module script has
            no dependencies or synchronously results in a parse error, we won't proceed to
            <a href="#execute-the-script-element" id="script-processing-model:execute-the-script-element-2">execute the script element</a> synchronously.</p>
           </li></ol>
         </li></ol>
       </dd><dt>"<code>importmap</code>"</dt><dd>
        <ol><li><p>Let <var>result</var> be the result of <a href="#create-an-import-map-parse-result" id="script-processing-model:create-an-import-map-parse-result">creating an import map parse result</a> given <var>source text</var> and
         <var>base URL</var>.</p></li><li><p><a href="#mark-as-ready" id="script-processing-model:mark-as-ready-4">Mark as ready</a> <var>el</var> given <var>result</var>.</p></li></ol>
       </dd><dt>"<code>speculationrules</code>"</dt><dd>
        <ol><li><p>Let <var>result</var> be the result of <a href="#create-a-speculation-rules-parse-result" id="script-processing-model:create-a-speculation-rules-parse-result">creating a speculation rules parse result</a> given <var>source text</var>
         and <var>el</var>'s <a id="script-processing-model:node-document-6" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p><a href="#mark-as-ready" id="script-processing-model:mark-as-ready-5">Mark as ready</a> <var>el</var> given <var>result</var>.</p></li></ol>
       </dd></dl>
     </li></ol>
   </li><li>
    <p>If <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-14">type</a> is "<code>classic</code>" and <var>el</var> has a <code id="script-processing-model:attr-script-src-10"><a href="#attr-script-src">src</a></code>
    attribute, or <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-15">type</a> is "<code>module</code>":</p>

    <ol><li><p><a id="script-processing-model:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>el</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-5">result</a>
     is "<code>uninitialized</code>".</p></li><li id="script-processing-src">
      <p id="script-processing-module-async">If <var>el</var> has an <code id="script-processing-model:attr-script-async-6"><a href="#attr-script-async">async</a></code> attribute or <var>el</var>'s <a href="#script-force-async" id="script-processing-model:script-force-async-4">force async</a> is true:</p>

      <ol><li><p>Let <var>scripts</var> be <var>el</var>'s <a href="#preparation-time-document" id="script-processing-model:preparation-time-document-4">preparation-time document</a>'s
       <a href="#set-of-scripts-that-will-execute-as-soon-as-possible" id="script-processing-model:set-of-scripts-that-will-execute-as-soon-as-possible">set of scripts that will execute as soon as possible</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="script-processing-model:set-append" data-x-internal="set-append">Append</a> <var>el</var> to <var>scripts</var>.</p></li><li>
        <p>Set <var>el</var>'s <a href="#steps-to-run-when-the-result-is-ready" id="script-processing-model:steps-to-run-when-the-result-is-ready-3">steps to run when the result is ready</a> to the
        following:</p>

        <ol><li><p><a href="#execute-the-script-element" id="script-processing-model:execute-the-script-element-3">Execute the script element</a> <var>el</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="script-processing-model:list-remove" data-x-internal="list-remove">Remove</a> <var>el</var> from
         <var>scripts</var>.</p></li></ol>
       </li></ol>
     </li><li id="script-processing-src-sync">
      <p id="script-processing-module-noasync">Otherwise, if <var>el</var> is not
      <a href="#parser-inserted" id="script-processing-model:parser-inserted-5">parser-inserted</a>:</p>

      <ol><li><p>Let <var>scripts</var> be <var>el</var>'s <a href="#preparation-time-document" id="script-processing-model:preparation-time-document-5">preparation-time document</a>'s
       <a href="#list-of-scripts-that-will-execute-in-order-as-soon-as-possible" id="script-processing-model:list-of-scripts-that-will-execute-in-order-as-soon-as-possible">list of scripts that will execute in order as soon as possible</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="script-processing-model:list-append" data-x-internal="list-append">Append</a> <var>el</var> to <var>scripts</var>.</p></li><li>
        <p>Set <var>el</var>'s <a href="#steps-to-run-when-the-result-is-ready" id="script-processing-model:steps-to-run-when-the-result-is-ready-4">steps to run when the result is ready</a> to the
        following:</p>

        <ol><li><p>If <var>scripts</var>[0] is not <var>el</var>, then abort these steps.</p></li><li>
          <p>While <var>scripts</var> is not empty, and <var>scripts</var>[0]'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-6">result</a> is not "<code>uninitialized</code>":</p>

          <ol><li><p><a href="#execute-the-script-element" id="script-processing-model:execute-the-script-element-4">Execute the script element</a> <var>scripts</var>[0].</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="script-processing-model:list-remove-2" data-x-internal="list-remove">Remove</a> <var>scripts</var>[0].</p></li></ol>
         </li></ol>
       </li></ol>
     </li><li id="script-processing-defer">
      <p id="script-processing-module-noasync-parser-inserted">Otherwise, if <var>el</var> has a
      <code id="script-processing-model:attr-script-defer-2"><a href="#attr-script-defer">defer</a></code> attribute or <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-16">type</a> is "<code>module</code>":</p>


      <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="script-processing-model:list-append-2" data-x-internal="list-append">Append</a> <var>el</var> to its <a href="#parser-document" id="script-processing-model:parser-document-5">parser
       document</a>'s <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing" id="script-processing-model:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the document has finished
       parsing</a>.</p></li><li><p>Set <var>el</var>'s <a href="#steps-to-run-when-the-result-is-ready" id="script-processing-model:steps-to-run-when-the-result-is-ready-5">steps to run when the result is ready</a> to the
       following: set <var>el</var>'s <a href="#ready-to-be-parser-executed" id="script-processing-model:ready-to-be-parser-executed">ready to be parser-executed</a> to true. (The parser
       will handle executing the script.)</p></li></ol>
     </li><li id="script-processing-parser-inserted">
      <p>Otherwise:</p>

      <ol><li><p>Set <var>el</var>'s <a href="#parser-document" id="script-processing-model:parser-document-6">parser document</a>'s <a href="#pending-parsing-blocking-script" id="script-processing-model:pending-parsing-blocking-script">pending parsing-blocking
       script</a> to <var>el</var>.</p></li><li><p><a href="#block-rendering" id="script-processing-model:block-rendering-3">Block rendering</a> on <var>el</var>.</p></li><li><p>Set <var>el</var>'s <a href="#steps-to-run-when-the-result-is-ready" id="script-processing-model:steps-to-run-when-the-result-is-ready-6">steps to run when the result is ready</a> to the
       following: set <var>el</var>'s <a href="#ready-to-be-parser-executed" id="script-processing-model:ready-to-be-parser-executed-2">ready to be parser-executed</a> to true. (The parser
       will handle executing the script.)</p></li></ol>
     </li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p><a id="script-processing-model:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>el</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-7">result</a>
     is <em>not</em> "<code>uninitialized</code>".</p></li><li id="script-processing-style-delayed">
      <p>If all of the following are true:</p>

      <ul><li><var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-17">type</a> is "<code>classic</code>";</li><li><var>el</var> is <a href="#parser-inserted" id="script-processing-model:parser-inserted-6">parser-inserted</a>;</li><li><var>el</var>'s <a href="#parser-document" id="script-processing-model:parser-document-7">parser document</a> <a href="#has-a-style-sheet-that-is-blocking-scripts" id="script-processing-model:has-a-style-sheet-that-is-blocking-scripts">has a style sheet that is blocking
       scripts</a>; and</li><li>either the parser that created <var>el</var> is an <a href="#xml-parser" id="script-processing-model:xml-parser-3">XML parser</a>, or it's an
       <a href="#html-parser" id="script-processing-model:html-parser-3">HTML parser</a> whose <a href="#script-nesting-level" id="script-processing-model:script-nesting-level">script nesting level</a> is not greater than
       one,</li></ul>

      <p>then:</p>

      <ol><li><p>Set <var>el</var>'s <a href="#parser-document" id="script-processing-model:parser-document-8">parser document</a>'s <a href="#pending-parsing-blocking-script" id="script-processing-model:pending-parsing-blocking-script-2">pending parsing-blocking
       script</a> to <var>el</var>.</p></li><li><p>Set <var>el</var>'s <a href="#ready-to-be-parser-executed" id="script-processing-model:ready-to-be-parser-executed-3">ready to be parser-executed</a> to true. (The parser
       will handle executing the script.)</p></li></ol>
     </li><li id="script-processing-inline"><p>Otherwise, <a href="#immediately" id="script-processing-model:immediately">immediately</a> <a href="#execute-the-script-element" id="script-processing-model:execute-the-script-element-5">execute the
     script element</a> <var>el</var>, even if other scripts are already executing.</p></li></ol>
   </li></ol>
  </div>

  <p>Each <code id="script-processing-model:document-4"><a href="#document">Document</a></code> has a <dfn id="pending-parsing-blocking-script">pending parsing-blocking script</dfn>, which is a
  <code id="script-processing-model:the-script-element-40"><a href="#the-script-element">script</a></code> element or null, initially null.</p>

  <p>Each <code id="script-processing-model:document-5"><a href="#document">Document</a></code> has a <dfn id="set-of-scripts-that-will-execute-as-soon-as-possible">set of scripts that will execute as soon as
  possible</dfn>, which is a <a id="script-processing-model:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <code id="script-processing-model:the-script-element-41"><a href="#the-script-element">script</a></code> elements, initially empty.</p>

  <p>Each <code id="script-processing-model:document-6"><a href="#document">Document</a></code> has a <dfn id="list-of-scripts-that-will-execute-in-order-as-soon-as-possible">list of scripts that will execute in order as soon as
  possible</dfn>, which is a <a id="script-processing-model:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <code id="script-processing-model:the-script-element-42"><a href="#the-script-element">script</a></code> elements, initially
  empty.</p>

  <p>Each <code id="script-processing-model:document-7"><a href="#document">Document</a></code> has a <dfn id="list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the document has
  finished parsing</dfn>, which is a <a id="script-processing-model:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <code id="script-processing-model:the-script-element-43"><a href="#the-script-element">script</a></code> elements, initially
  empty.</p>

  <p class="note">If a <code id="script-processing-model:the-script-element-44"><a href="#the-script-element">script</a></code> element that blocks a parser gets moved to another
  <code id="script-processing-model:document-8"><a href="#document">Document</a></code> before it would normally have stopped blocking that parser, it nonetheless
  continues blocking that parser until the condition that causes it to be blocking the parser no
  longer applies (e.g., if the script is a <a href="#pending-parsing-blocking-script" id="script-processing-model:pending-parsing-blocking-script-3">pending parsing-blocking script</a> because the
  original <code id="script-processing-model:document-9"><a href="#document">Document</a></code> <a href="#has-a-style-sheet-that-is-blocking-scripts" id="script-processing-model:has-a-style-sheet-that-is-blocking-scripts-2">has a style sheet that is blocking scripts</a> when it was
  parsed, but then the script is moved to another <code id="script-processing-model:document-10"><a href="#document">Document</a></code> before the blocking style
  sheet(s) loaded, the script still blocks the parser until the style sheets are all loaded, at
  which time the script executes and the parser is unblocked).</p>

  

  <div data-algorithm="">
  <p id="execute-the-script-block">To <dfn id="execute-the-script-element">execute the script element</dfn> given a
  <code id="script-processing-model:the-script-element-45"><a href="#the-script-element">script</a></code> element <var>el</var>:</p>

  <ol><li><p>Let <var>document</var> be <var>el</var>'s <a id="script-processing-model:node-document-7" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>el</var>'s <a href="#preparation-time-document" id="script-processing-model:preparation-time-document-6">preparation-time document</a> is not equal to
   <var>document</var>, then return.</p></li><li><p><a href="#unblock-rendering" id="script-processing-model:unblock-rendering">Unblock rendering</a> on <var>el</var>.</p></li><li><p>If <var>el</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-8">result</a> is null, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="script-processing-model:concept-event-fire-4" data-x-internal="concept-event-fire">fire an event</a> named <code id="script-processing-model:event-error-4"><a href="#event-error">error</a></code>
   at <var>el</var>, and return.</p></li><li><p>If <var>el</var>'s <a href="#concept-script-external" id="script-processing-model:concept-script-external-2">from an external file</a> is
   true, or <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-18">type</a> is "<code>module</code>", then increment <var>document</var>'s <a href="#ignore-destructive-writes-counter" id="script-processing-model:ignore-destructive-writes-counter">ignore-destructive-writes
   counter</a>.</p></li><li>
    <p>Switch on <var>el</var>'s <a href="#concept-script-type" id="script-processing-model:concept-script-type-19">type</a>:</p>

    <dl class="switch"><dt>"<code>classic</code>"</dt><dd>
      <ol><li><p>Let <var>oldCurrentScript</var> be the value to which <var>document</var>'s <code id="script-processing-model:dom-document-currentscript"><a href="#dom-document-currentscript">currentScript</a></code> object was most recently
       set.</p></li><li>
        <p>If <var>el</var>'s <a id="script-processing-model:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> is <em>not</em> a <a id="script-processing-model:shadow-root" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a>, then
        set <var>document</var>'s <code id="script-processing-model:dom-document-currentscript-2"><a href="#dom-document-currentscript">currentScript</a></code>
        attribute to <var>el</var>. Otherwise, set it to null.</p>

        <p class="note">This does not use the <a id="script-processing-model:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a> check, as
        <var>el</var> could have been removed from the document prior to execution, and in that
        scenario <code id="script-processing-model:dom-document-currentscript-3"><a href="#dom-document-currentscript">currentScript</a></code> still needs to
        point to it.</p>
       </li><li><p><a href="#run-a-classic-script" id="script-processing-model:run-a-classic-script">Run the classic script</a> given by
       <var>el</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-9">result</a>.</p></li><li><p>Set <var>document</var>'s <code id="script-processing-model:dom-document-currentscript-4"><a href="#dom-document-currentscript">currentScript</a></code> attribute to
       <var>oldCurrentScript</var>.</p></li></ol>
     </dd><dt>"<code>module</code>"</dt><dd>
      <ol><li><p><a id="script-processing-model:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var>'s <code id="script-processing-model:dom-document-currentscript-5"><a href="#dom-document-currentscript">currentScript</a></code> attribute is null.</p></li><li><p><a href="#run-a-module-script" id="script-processing-model:run-a-module-script">Run the module script</a> given by
       <var>el</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-10">result</a>.</p></li></ol>
     </dd><dt>"<code>importmap</code>"</dt><dd>
      <ol><li><p><a href="#register-an-import-map" id="script-processing-model:register-an-import-map">Register an import map</a> given <var>el</var>'s <a href="#concept-relevant-global" id="script-processing-model:concept-relevant-global-2">relevant global
       object</a> and <var>el</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-11">result</a>.</p></li></ol>
     </dd><dt>"<code>speculationrules</code>"</dt><dd>
      <ol><li><p><a href="#register-speculation-rules" id="script-processing-model:register-speculation-rules">Register speculation rules</a> given <var>el</var>'s <a href="#concept-relevant-global" id="script-processing-model:concept-relevant-global-3">relevant global
       object</a> and <var>el</var>'s <a href="#concept-script-result" id="script-processing-model:concept-script-result-12">result</a>.</p></li></ol>
     </dd></dl>
   </li><li><p>Decrement the <a href="#ignore-destructive-writes-counter" id="script-processing-model:ignore-destructive-writes-counter-2">ignore-destructive-writes counter</a> of <var>document</var>, if
   it was incremented in the earlier step.</p></li><li><p>If <var>el</var>'s <a href="#concept-script-external" id="script-processing-model:concept-script-external-3">from an external file</a> is
   true, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="script-processing-model:concept-event-fire-5" data-x-internal="concept-event-fire">fire an event</a> named <code id="script-processing-model:event-load"><a href="#event-load">load</a></code> at <var>el</var>.</p></li></ol>
  </div>

  


  <h5 id="scriptingLanguages"><span class="secno">4.12.1.2</span> Scripting languages<a href="#scriptingLanguages" class="self-link"></a></h5>

  <p>User agents are not required to support JavaScript. This standard needs to be updated
  if a language other than JavaScript comes along and gets similar wide adoption by web browsers.
  Until such a time, implementing other languages is in conflict with this standard, given the
  processing model defined for the <code id="scriptingLanguages:the-script-element"><a href="#the-script-element">script</a></code> element.</p>

  <p>Servers should use <code id="scriptingLanguages:text/javascript"><a href="#text/javascript">text/javascript</a></code> for JavaScript resources, in accordance with
  <cite>Updates to ECMAScript Media Types</cite>. Servers should not use other
  <a href="https://mimesniff.spec.whatwg.org/#javascript-mime-type" id="scriptingLanguages:javascript-mime-type" data-x-internal="javascript-mime-type">JavaScript MIME types</a> for JavaScript resources, and
  must not use non-<a href="https://mimesniff.spec.whatwg.org/#javascript-mime-type" id="scriptingLanguages:javascript-mime-type-2" data-x-internal="javascript-mime-type">JavaScript MIME types</a>.
  <a href="#refsRFC9239">[RFC9239]</a></p>

  

  <p>For external JavaScript resources, MIME type parameters in `<code id="scriptingLanguages:content-type"><a href="#content-type">Content-Type</a></code>` headers
  are generally ignored. (In some cases the `<code>charset</code>` parameter has an
  effect.) However, for the <code id="scriptingLanguages:the-script-element-2"><a href="#the-script-element">script</a></code> element's <code id="scriptingLanguages:attr-script-type"><a href="#attr-script-type">type</a></code> attribute they are significant; it uses the <a id="scriptingLanguages:javascript-mime-type-essence-match" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match" data-x-internal="javascript-mime-type-essence-match">JavaScript
  MIME type essence match</a> concept.</p>

  <p class="note">For example, scripts with their <code id="scriptingLanguages:attr-script-type-2"><a href="#attr-script-type">type</a></code>
  attribute set to "<code>text/javascript; charset=utf-8</code>" will not be
  evaluated, even though that is a valid <a id="scriptingLanguages:javascript-mime-type-3" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type" data-x-internal="javascript-mime-type">JavaScript MIME type</a> when parsed.</p>

  <p>Furthermore, again for external JavaScript resources, special considerations apply around
  `<code id="scriptingLanguages:content-type-2"><a href="#content-type">Content-Type</a></code>` header processing as detailed in the <a href="#prepare-the-script-element" id="scriptingLanguages:prepare-the-script-element">prepare the script
  element</a> algorithm and <cite>Fetch</cite>. <a href="#refsFETCH">[FETCH]</a>

  </p>


  <h5 id="restrictions-for-contents-of-script-elements"><span class="secno">4.12.1.3</span> <dfn>Restrictions for contents of <code>script</code> elements</dfn><a href="#restrictions-for-contents-of-script-elements" class="self-link"></a></h5>

  <p class="note">The easiest and safest way to avoid the rather strange restrictions described in
  this section is to always escape an ASCII case-insensitive match for "<code>&lt;!--</code>" as "<code>\x3C!--</code>", "<code>&lt;script</code>" as "<code>\x3Cscript</code>", and "<code>&lt;/script</code>" as "<code>\x3C/script</code>" when these sequences appear
  in literals in scripts (e.g. in strings, regular expressions, or comments), and to avoid writing
  code that uses such constructs in expressions. Doing so avoids the pitfalls that the restrictions
  in this section are prone to triggering: namely, that, for historical reasons, parsing of
  <code id="restrictions-for-contents-of-script-elements:the-script-element"><a href="#the-script-element">script</a></code> blocks in HTML is a strange and exotic practice that acts unintuitively in the
  face of these sequences.</p>

  <p>The <code id="restrictions-for-contents-of-script-elements:the-script-element-2"><a href="#the-script-element">script</a></code> element's <a id="restrictions-for-contents-of-script-elements:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a> must match the <code>script</code> production in the following ABNF, the character set for which is Unicode.
  <a href="#refsABNF">[ABNF]</a></p>

  <pre><code class="abnf"><c- nc="">script</c->        <c- o="">=</c-> <c- nc="">outer</c-> <c- o="">*</c-><c- p="">(</c-> <c- nc="">comment-open</c-> <c- nc="">inner</c-> <c- nc="">comment-close</c-> <c- nc="">outer</c-> <c- p="">)</c->

<c- nc="">outer</c->         <c- o="">=</c-> &lt; <c- nc="">any</c-> <c- nc="">string</c-> <c- nc="">that</c-> <c- nc="">doesn</c->'t <c- nc="">contain</c-> a <c- nc="">substring</c-> <c- nc="">that</c-> <c- nc="">matches</c-> <c- nc="">not-in-outer</c-> &gt;
<c- nc="">not-in-outer</c->  <c- o="">=</c-> <c- nc="">comment-open</c->
<c- nc="">inner</c->         <c- o="">=</c-> &lt; <c- nc="">any</c-> <c- nc="">string</c-> <c- nc="">that</c-> <c- nc="">doesn</c->'t <c- nc="">contain</c-> a <c- nc="">substring</c-> <c- nc="">that</c-> <c- nc="">matches</c-> <c- nc="">not-in-inner</c-> &gt;
<c- nc="">not-in-inner</c->  <c- o="">=</c-> <c- nc="">comment-close</c-> <c- o="">/</c-> <c- nc="">script-open</c->

<c- nc="">comment-open</c->  <c- o="">=</c-> <c- l="">"&lt;!--"</c->
<c- nc="">comment-close</c-> <c- o="">=</c-> <c- l="">"--&gt;"</c->
<c- nc="">script-open</c->   <c- o="">=</c-> <c- l="">"&lt;"</c-> s c r i p t <c- nc="">tag-end</c->

s             <c- o="">=</c->  <c- l="">%x0053</c-> <c- c1="">; U+0053 LATIN CAPITAL LETTER S</c->
s             <c- o="">=/</c-> <c- l="">%x0073</c-> <c- c1="">; U+0073 LATIN SMALL LETTER S</c->
c             <c- o="">=</c->  <c- l="">%x0043</c-> <c- c1="">; U+0043 LATIN CAPITAL LETTER C</c->
c             <c- o="">=/</c-> <c- l="">%x0063</c-> <c- c1="">; U+0063 LATIN SMALL LETTER C</c->
r             <c- o="">=</c->  <c- l="">%x0052</c-> <c- c1="">; U+0052 LATIN CAPITAL LETTER R</c->
r             <c- o="">=/</c-> <c- l="">%x0072</c-> <c- c1="">; U+0072 LATIN SMALL LETTER R</c->
i             <c- o="">=</c->  <c- l="">%x0049</c-> <c- c1="">; U+0049 LATIN CAPITAL LETTER I</c->
i             <c- o="">=/</c-> <c- l="">%x0069</c-> <c- c1="">; U+0069 LATIN SMALL LETTER I</c->
p             <c- o="">=</c->  <c- l="">%x0050</c-> <c- c1="">; U+0050 LATIN CAPITAL LETTER P</c->
p             <c- o="">=/</c-> <c- l="">%x0070</c-> <c- c1="">; U+0070 LATIN SMALL LETTER P</c->
t             <c- o="">=</c->  <c- l="">%x0054</c-> <c- c1="">; U+0054 LATIN CAPITAL LETTER T</c->
t             <c- o="">=/</c-> <c- l="">%x0074</c-> <c- c1="">; U+0074 LATIN SMALL LETTER T</c->

<c- nc="">tag-end</c->       <c- o="">=</c->  <c- l="">%x0009</c-> <c- c1="">; U+0009 CHARACTER TABULATION (tab)</c->
<c- nc="">tag-end</c->       <c- o="">=/</c-> <c- l="">%x000A</c-> <c- c1="">; U+000A LINE FEED (LF)</c->
<c- nc="">tag-end</c->       <c- o="">=/</c-> <c- l="">%x000C</c-> <c- c1="">; U+000C FORM FEED (FF)</c->
<c- nc="">tag-end</c->       <c- o="">=/</c-> <c- l="">%x0020</c-> <c- c1="">; U+0020 SPACE</c->
<c- nc="">tag-end</c->       <c- o="">=/</c-> <c- l="">%x002F</c-> <c- c1="">; U+002F SOLIDUS (/)</c->
<c- nc="">tag-end</c->       <c- o="">=/</c-> <c- l="">%x003E</c-> <c- c1="">; U+003E GREATER-THAN SIGN (&gt;)</c-></code></pre>

  <p>When a <code id="restrictions-for-contents-of-script-elements:the-script-element-3"><a href="#the-script-element">script</a></code> element contains <a href="#inline-documentation-for-external-scripts" id="restrictions-for-contents-of-script-elements:inline-documentation-for-external-scripts">script documentation</a>, there are
  further restrictions on the contents of the element, as described in the section below.</p>

  <div class="example">

   <p>The following script illustrates this issue. Suppose you have a script that contains a string,
   as in:</p>

   <pre><code class="js"><c- a="">const</c-> example <c- o="">=</c-> <c- t="">'Consider this string: &lt;!-- &lt;script&gt;'</c-><c- p="">;</c->
console<c- p="">.</c->log<c- p="">(</c->example<c- p="">);</c-></code></pre>

   <p>If one were to put this string directly in a <code id="restrictions-for-contents-of-script-elements:the-script-element-4"><a href="#the-script-element">script</a></code> block, it would violate the
   restrictions above:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">const</c-> example <c- o="">=</c-> <c- t="">'Consider this string: &lt;!-- &lt;script&gt;'</c-><c- p="">;</c->
  console<c- p="">.</c->log<c- p="">(</c->example<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>The bigger problem, though, and the reason why it would violate those restrictions, is that
   actually the script would get parsed weirdly: <em>the script block above is not terminated</em>.
   That is, what looks like a "<code>&lt;/script&gt;</code>" end tag in this snippet is
   actually still part of the <code id="restrictions-for-contents-of-script-elements:the-script-element-5"><a href="#the-script-element">script</a></code> block. The script doesn't execute (since it's not
   terminated); if it somehow were to execute, as it might if the markup looked as follows, it would
   fail because the script (highlighted here) is not valid JavaScript:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c-><mark>
  <c- a="">const</c-> example <c- o="">=</c-> <c- t="">'Consider this string: &lt;!-- &lt;script&gt;'</c-><c- p="">;</c->
  console<c- p="">.</c->log<c- p="">(</c->example<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- c="">&lt;!-- despite appearances, this is actually part of the script still! --&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">...</c-> <c- c1="">// this is the same script block still...</c->
</mark><c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>What is going on here is that for legacy reasons, "<code>&lt;!--</code>" and "<code>&lt;script</code>" strings in <code id="restrictions-for-contents-of-script-elements:the-script-element-6"><a href="#the-script-element">script</a></code> elements in HTML need to be balanced
   in order for the parser to consider closing the block.</p>

   <p>By escaping the problematic strings as mentioned at the top of this section, the problem is
   avoided entirely:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c-><mark>
  <c- c1="">// Note: `\x3C` is an escape sequence for `&lt;`.</c->
  <c- a="">const</c-> example <c- o="">=</c-> <c- t="">'Consider this string: \x3C!-- \x3Cscript&gt;'</c-><c- p="">;</c->
  console<c- p="">.</c->log<c- p="">(</c->example<c- p="">);</c->
</mark><c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- c="">&lt;!-- this is just a comment between script blocks --&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c-><mark>
 <c- p="">...</c-> <c- c1="">// this is a new script block</c->
</mark><c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>It is possible for these sequences to naturally occur in script expressions, as in the
   following examples:</p>

   <pre><code class="js"><c- k="">if</c-> <c- p="">(</c->x<c- c="">&lt;!--</c->y<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c->
<c- k="">if</c-> <c- p="">(</c-> player<c- o="">&lt;</c->script <c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c-></code></pre>

   <p>In such cases the characters cannot be escaped, but the expressions can be rewritten so that
   the sequences don't occur, as in:</p>

   <pre><code class="js"><c- k="">if</c-> <c- p="">(</c->x <c- o="">&lt;</c-> <c- o="">!--</c->y<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c->
<c- k="">if</c-> <c- p="">(</c-><c- o="">!--</c->y <c- o="">&gt;</c-> x<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c->
<c- k="">if</c-> <c- p="">(</c-><c- o="">!</c-><c- p="">(</c-><c- o="">--</c->y<c- p="">)</c-> <c- o="">&gt;</c-> x<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c->
<c- k="">if</c-> <c- p="">(</c->player <c- o="">&lt;</c-> script<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c->
<c- k="">if</c-> <c- p="">(</c->script <c- o="">&gt;</c-> player<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c-></code></pre>

   <p>Doing this also avoids a different pitfall as well: for related historical reasons, the string
   "&lt;!--" in <a href="#classic-script" id="restrictions-for-contents-of-script-elements:classic-script">classic scripts</a> is actually treated as a line
   comment start, just like "//".</p>

  </div>


  <h5 id="inline-documentation-for-external-scripts"><span class="secno">4.12.1.4</span> <dfn>Inline documentation for external scripts</dfn><a href="#inline-documentation-for-external-scripts" class="self-link"></a></h5>

  <p>If a <code id="inline-documentation-for-external-scripts:the-script-element"><a href="#the-script-element">script</a></code> element's <code id="inline-documentation-for-external-scripts:attr-script-src"><a href="#attr-script-src">src</a></code> attribute is
  specified, then the contents of the <code id="inline-documentation-for-external-scripts:the-script-element-2"><a href="#the-script-element">script</a></code> element, if any, must be such that the
  value of the <code id="inline-documentation-for-external-scripts:dom-script-text"><a href="#dom-script-text">text</a></code> IDL attribute, which is derived from the
  element's contents, matches the <code>documentation</code> production in the following
  ABNF, the character set for which is Unicode. <a href="#refsABNF">[ABNF]</a></p>

  <pre><code class="abnf"><c- nc="">documentation</c-> <c- o="">=</c-> <c- o="">*</c-><c- p="">(</c-> <c- o="">*</c-><c- p="">(</c-> <c- nc="">space</c-> <c- o="">/</c-> <c- nc="">tab</c-> <c- o="">/</c-> <c- nc="">comment</c-> <c- p="">)</c-> <c- p="">[</c-> <c- nc="">line-comment</c-> <c- p="">]</c-> <c- nc="">newline</c-> <c- p="">)</c->
<c- nc="">comment</c->       <c- o="">=</c-> <c- nc="">slash</c-> <c- nc="">star</c-> <c- o="">*</c-><c- p="">(</c-> <c- nc="">not-star</c-> <c- o="">/</c-> <c- nc="">star</c-> <c- nc="">not-slash</c-> <c- p="">)</c-> <c- o="">1*</c-><c- nc="">star</c-> <c- nc="">slash</c->
<c- nc="">line-comment</c->  <c- o="">=</c-> <c- nc="">slash</c-> <c- nc="">slash</c-> <c- o="">*</c-><c- nc="">not-newline</c->

<c- c1="">; characters</c->
<c- nc="">tab</c->           <c- o="">=</c-> <c- l="">%x0009</c-> <c- c1="">; U+0009 CHARACTER TABULATION (tab)</c->
<c- nc="">newline</c->       <c- o="">=</c-> <c- l="">%x000A</c-> <c- c1="">; U+000A LINE FEED (LF)</c->
<c- nc="">space</c->         <c- o="">=</c-> <c- l="">%x0020</c-> <c- c1="">; U+0020 SPACE</c->
<c- nc="">star</c->          <c- o="">=</c-> <c- l="">%x002A</c-> <c- c1="">; U+002A ASTERISK (*)</c->
<c- nc="">slash</c->         <c- o="">=</c-> <c- l="">%x002F</c-> <c- c1="">; U+002F SOLIDUS (/)</c->
<c- nc="">not-newline</c->   <c- o="">=</c-> <c- l="">%x0000-0009</c-> <c- o="">/</c-> <c- l="">%x000B-10FFFF</c->
                <c- c1="">; a </c-><a id="inline-documentation-for-external-scripts:scalar-value" href="https://infra.spec.whatwg.org/#scalar-value" data-x-internal="scalar-value"><c- c1="">scalar value</c-></a><c- c1=""> other than U+000A LINE FEED (LF)</c->
<c- nc="">not-star</c->      <c- o="">=</c-> <c- l="">%x0000-0029</c-> <c- o="">/</c-> <c- l="">%x002B-10FFFF</c->
                <c- c1="">; a </c-><a id="inline-documentation-for-external-scripts:scalar-value-2" href="https://infra.spec.whatwg.org/#scalar-value" data-x-internal="scalar-value"><c- c1="">scalar value</c-></a><c- c1=""> other than U+002A ASTERISK (*)</c->
<c- nc="">not-slash</c->     <c- o="">=</c-> <c- l="">%x0000-002E</c-> <c- o="">/</c-> <c- l="">%x0030-10FFFF</c->
                <c- c1="">; a </c-><a id="inline-documentation-for-external-scripts:scalar-value-3" href="https://infra.spec.whatwg.org/#scalar-value" data-x-internal="scalar-value"><c- c1="">scalar value</c-></a><c- c1=""> other than U+002F SOLIDUS (/)</c-></code></pre>

  <p class="note">This corresponds to putting the contents of the element in JavaScript
  comments.</p>

  <p class="note">This requirement is in addition to the earlier restrictions on the syntax of
  contents of <code id="inline-documentation-for-external-scripts:the-script-element-3"><a href="#the-script-element">script</a></code> elements.</p>

  <div class="example">

   <p>This allows authors to include documentation, such as license information or API information,
   inside their documents while still referring to external script files. The syntax is constrained
   so that authors don't accidentally include what looks like valid script while also providing a
   <code id="inline-documentation-for-external-scripts:attr-script-src-2"><a href="#attr-script-src">src</a></code> attribute.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"cool-effects.js"</c-><c- p="">&gt;</c->
 <c- c1="">// create new instances using:</c->
 <c- c1="">//    var e = new Effect();</c->
 <c- c1="">// start the effect using .play, stop using .stop:</c->
 <c- c1="">//    e.play();</c->
 <c- c1="">//    e.stop();</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  </div>


  

  <h5 id="scriptTagXSLT"><span class="secno">4.12.1.5</span> Interaction of <code id="scriptTagXSLT:the-script-element"><a href="#the-script-element">script</a></code> elements and XSLT<a href="#scriptTagXSLT" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>This specification does not define how XSLT interacts with the <code id="scriptTagXSLT:the-script-element-2"><a href="#the-script-element">script</a></code> element.
  However, in the absence of another specification actually defining this, here are some guidelines
  for implementers, based on existing implementations:</p>

  <ul><li><p>When an XSLT transformation program is triggered by an <code>&lt;?xml-stylesheet?&gt;</code> processing instruction and the browser implements a
   direct-to-DOM transformation, <code id="scriptTagXSLT:the-script-element-3"><a href="#the-script-element">script</a></code> elements created by the XSLT processor need to
   have its <a href="#parser-document" id="scriptTagXSLT:parser-document">parser document</a> set correctly, and run in document order (modulo scripts
   marked <code id="scriptTagXSLT:attr-script-defer"><a href="#attr-script-defer">defer</a></code> or <code id="scriptTagXSLT:attr-script-async"><a href="#attr-script-async">async</a></code>), <a href="#immediately" id="scriptTagXSLT:immediately">immediately</a>, as the transformation is
   occurring.</p></li><li><p>The <code id="scriptTagXSLT:xsltprocessor"><a href="#xsltprocessor">XSLTProcessor</a></code> <code id="scriptTagXSLT:dom-xsltprocessor-transformtodocument"><a href="#dom-xsltprocessor-transformtodocument">transformToDocument()</a></code> method adds elements
   to a <code id="scriptTagXSLT:document"><a href="#document">Document</a></code> object with a null <a href="#concept-document-bc" id="scriptTagXSLT:concept-document-bc">browsing
   context</a>, and, accordingly, any <code id="scriptTagXSLT:the-script-element-4"><a href="#the-script-element">script</a></code> elements they create need to have
   their <a href="#already-started" id="scriptTagXSLT:already-started">already started</a> set to true in the <a href="#prepare-the-script-element" id="scriptTagXSLT:prepare-the-script-element">prepare the script element</a>
   algorithm and never get executed (<a href="#concept-environment-noscript" id="scriptTagXSLT:concept-environment-noscript">scripting is
   disabled</a>). Such <code id="scriptTagXSLT:the-script-element-5"><a href="#the-script-element">script</a></code> elements still need to have their <a href="#parser-document" id="scriptTagXSLT:parser-document-2">parser
   document</a> set, though, such that their <code id="scriptTagXSLT:dom-script-async"><a href="#dom-script-async">async</a></code> IDL
   attribute will return false in the absence of an <code id="scriptTagXSLT:attr-script-async-2"><a href="#attr-script-async">async</a></code>
   content attribute.</p></li><li><p>The <code id="scriptTagXSLT:xsltprocessor-2"><a href="#xsltprocessor">XSLTProcessor</a></code> <code id="scriptTagXSLT:dom-xsltprocessor-transformtofragment"><a href="#dom-xsltprocessor-transformtofragment">transformToFragment()</a></code> method needs to
   create a fragment that is equivalent to one built manually by creating the elements using <code id="scriptTagXSLT:dom-document-createelementns"><a data-x-internal="dom-document-createelementns" href="https://dom.spec.whatwg.org/#dom-document-createelementns">document.createElementNS()</a></code>. For instance, it needs
   to create <code id="scriptTagXSLT:the-script-element-6"><a href="#the-script-element">script</a></code> elements with null <a href="#parser-document" id="scriptTagXSLT:parser-document-3">parser document</a> and with their
   <a href="#already-started" id="scriptTagXSLT:already-started-2">already started</a> set to false, so that they will execute when the fragment is
   inserted into a document.</p></li></ul>

  <p>The main distinction between the first two cases and the last case is that the first two
  operate on <code id="scriptTagXSLT:document-2"><a href="#document">Document</a></code>s and the last operates on a fragment.</p>

  



  <h4 id="the-noscript-element"><span class="secno">4.12.2</span> The <dfn data-dfn-type="element"><code>noscript</code></dfn> element<a href="#the-noscript-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript" title="The <noscript> HTML element defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.">Element/noscript</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="element"><dt><a href="#concept-element-categories" id="the-noscript-element:concept-element-categories">Categories</a>:</dt><dd><a href="#metadata-content-2" id="the-noscript-element:metadata-content-2">Metadata content</a>.</dd><dd><a href="#flow-content-2" id="the-noscript-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-noscript-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#select-element-inner-content-elements-2" id="the-noscript-element:select-element-inner-content-elements-2"><code>select</code> element inner content elements</a>.</dd><dd><a href="#optgroup-element-inner-content-elements-2" id="the-noscript-element:optgroup-element-inner-content-elements-2"><code>optgroup</code> element inner content elements</a>.</dd><dt><a href="#concept-element-contexts" id="the-noscript-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>In a <code id="the-noscript-element:the-head-element"><a href="#the-head-element">head</a></code> element of an <a href="https://dom.spec.whatwg.org/#html-document" id="the-noscript-element:html-documents" data-x-internal="html-documents">HTML document</a>, if there are no ancestor <code id="the-noscript-element:the-noscript-element"><a href="#the-noscript-element">noscript</a></code> elements.</dd><dd>Where <a href="#phrasing-content-2" id="the-noscript-element:phrasing-content-2-2">phrasing content</a> is expected in <a id="the-noscript-element:html-documents-2" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>, if there are no ancestor <code id="the-noscript-element:the-noscript-element-2"><a href="#the-noscript-element">noscript</a></code> elements.</dd><dt><a href="#concept-element-content-model" id="the-noscript-element:concept-element-content-model">Content model</a>:</dt><dd>When <a href="#concept-n-noscript" id="the-noscript-element:concept-n-noscript">scripting is disabled</a>, in a <code id="the-noscript-element:the-head-element-2"><a href="#the-head-element">head</a></code> element: in any order, zero or more <code id="the-noscript-element:the-link-element"><a href="#the-link-element">link</a></code> elements, zero or more <code id="the-noscript-element:the-style-element"><a href="#the-style-element">style</a></code> elements, and zero or more <code id="the-noscript-element:the-meta-element"><a href="#the-meta-element">meta</a></code> elements.</dd><dd>When <a href="#concept-n-noscript" id="the-noscript-element:concept-n-noscript-2">scripting is disabled</a>, not in a <code id="the-noscript-element:the-head-element-3"><a href="#the-head-element">head</a></code> element: <a href="#transparent" id="the-noscript-element:transparent">transparent</a>, but there must be no <code id="the-noscript-element:the-noscript-element-3"><a href="#the-noscript-element">noscript</a></code> element descendants.</dd><dd>Otherwise: text that conforms to the requirements given in the prose.</dd><dt><a href="#concept-element-tag-omission" id="the-noscript-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-noscript-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-noscript-element:global-attributes">Global attributes</a></dd><dt><a href="#concept-element-accessibility-considerations" id="the-noscript-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-noscript">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-noscript">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-noscript-element:concept-element-dom">DOM interface</a>:</dt><dd>Uses <code id="the-noscript-element:htmlelement"><a href="#htmlelement">HTMLElement</a></code>.</dd></dl>

  <p>The <code id="the-noscript-element:the-noscript-element-4"><a href="#the-noscript-element">noscript</a></code> element <a href="#represents" id="the-noscript-element:represents">represents</a> nothing if <a href="#concept-n-script" id="the-noscript-element:concept-n-script">scripting is enabled</a>, and <a href="#represents" id="the-noscript-element:represents-2">represents</a> its children if
  <a href="#concept-n-noscript" id="the-noscript-element:concept-n-noscript-3">scripting is disabled</a>. It is used to present different
  markup to user agents that support scripting and those that don't support scripting, by affecting
  how the document is parsed.</p>

  <p>When used in <a id="the-noscript-element:html-documents-3" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>, the allowed content model is as follows:</p>

  <dl><dt>In a <code id="the-noscript-element:the-head-element-4"><a href="#the-head-element">head</a></code> element, if <a href="#concept-n-noscript" id="the-noscript-element:concept-n-noscript-4">scripting is
   disabled</a> for the <code id="the-noscript-element:the-noscript-element-5"><a href="#the-noscript-element">noscript</a></code> element</dt><dd><p>The <code id="the-noscript-element:the-noscript-element-6"><a href="#the-noscript-element">noscript</a></code> element must contain only <code id="the-noscript-element:the-link-element-2"><a href="#the-link-element">link</a></code>, <code id="the-noscript-element:the-style-element-2"><a href="#the-style-element">style</a></code>,
   and <code id="the-noscript-element:the-meta-element-2"><a href="#the-meta-element">meta</a></code> elements.</p></dd><dt>In a <code id="the-noscript-element:the-head-element-5"><a href="#the-head-element">head</a></code> element, if <a href="#concept-n-script" id="the-noscript-element:concept-n-script-2">scripting is enabled</a>
   for the <code id="the-noscript-element:the-noscript-element-7"><a href="#the-noscript-element">noscript</a></code> element</dt><dd><p>The <code id="the-noscript-element:the-noscript-element-8"><a href="#the-noscript-element">noscript</a></code> element must contain only text, except that invoking the
   <a href="#html-fragment-parsing-algorithm" id="the-noscript-element:html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>  with
   the <code id="the-noscript-element:the-noscript-element-9"><a href="#the-noscript-element">noscript</a></code> element as the <var id="the-noscript-element:concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var>
   element and the text contents as the <var>input</var> must result in a list of nodes
   that consists only of <code id="the-noscript-element:the-link-element-3"><a href="#the-link-element">link</a></code>, <code id="the-noscript-element:the-style-element-3"><a href="#the-style-element">style</a></code>, and <code id="the-noscript-element:the-meta-element-3"><a href="#the-meta-element">meta</a></code> elements that
   would be conforming if they were children of the <code id="the-noscript-element:the-noscript-element-10"><a href="#the-noscript-element">noscript</a></code> element, and no <a href="#parse-errors" id="the-noscript-element:parse-errors">parse errors</a>.</p></dd><dt>Outside of <code id="the-noscript-element:the-head-element-6"><a href="#the-head-element">head</a></code> elements, if <a href="#concept-n-noscript" id="the-noscript-element:concept-n-noscript-5">scripting is
   disabled</a> for the <code id="the-noscript-element:the-noscript-element-11"><a href="#the-noscript-element">noscript</a></code> element</dt><dd><p>The <code id="the-noscript-element:the-noscript-element-12"><a href="#the-noscript-element">noscript</a></code> element's content model is <a href="#transparent" id="the-noscript-element:transparent-2">transparent</a>, with the
   additional restriction that a <code id="the-noscript-element:the-noscript-element-13"><a href="#the-noscript-element">noscript</a></code> element must not have a <code id="the-noscript-element:the-noscript-element-14"><a href="#the-noscript-element">noscript</a></code>
   element as an ancestor (that is, <code id="the-noscript-element:the-noscript-element-15"><a href="#the-noscript-element">noscript</a></code> can't be nested).</p></dd><dt>Outside of <code id="the-noscript-element:the-head-element-7"><a href="#the-head-element">head</a></code> elements, if <a href="#concept-n-script" id="the-noscript-element:concept-n-script-3">scripting is
   enabled</a> for the <code id="the-noscript-element:the-noscript-element-16"><a href="#the-noscript-element">noscript</a></code> element</dt><dd>
    <p>The <code id="the-noscript-element:the-noscript-element-17"><a href="#the-noscript-element">noscript</a></code> element must contain only text, except that the text must be such
    that running the following algorithm results in a conforming document with no
    <code id="the-noscript-element:the-noscript-element-18"><a href="#the-noscript-element">noscript</a></code> elements and no <code id="the-noscript-element:the-script-element"><a href="#the-script-element">script</a></code> elements, and such that no step in the
    algorithm throws an exception or causes an <a href="#html-parser" id="the-noscript-element:html-parser">HTML parser</a> to flag a <a href="#parse-errors" id="the-noscript-element:parse-errors-2">parse
    error</a>:</p>
    

    <div data-algorithm="">
    <ol><li>Remove every <code id="the-noscript-element:the-script-element-2"><a href="#the-script-element">script</a></code> element from the document.</li><li>Make a list of every <code id="the-noscript-element:the-noscript-element-19"><a href="#the-noscript-element">noscript</a></code> element in the document. For every
     <code id="the-noscript-element:the-noscript-element-20"><a href="#the-noscript-element">noscript</a></code> element in that list, perform the following steps:

      <ol><li>Let <var>s</var> be the <a id="the-noscript-element:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> of the <code id="the-noscript-element:the-noscript-element-21"><a href="#the-noscript-element">noscript</a></code>
       element.</li><li>Set the <code id="the-noscript-element:dom-element-outerhtml"><a href="#dom-element-outerhtml">outerHTML</a></code> attribute of the
       <code id="the-noscript-element:the-noscript-element-22"><a href="#the-noscript-element">noscript</a></code> element to the value of <var>s</var>. (This, as a side-effect, causes
       the <code id="the-noscript-element:the-noscript-element-23"><a href="#the-noscript-element">noscript</a></code> element to be removed from the document.)</li></ol>
     </li></ol>
    </div>
   </dd></dl>

  <p class="note">All these contortions are required because, for historical reasons, the
  <code id="the-noscript-element:the-noscript-element-24"><a href="#the-noscript-element">noscript</a></code> element is handled differently by the <a href="#html-parser" id="the-noscript-element:html-parser-2">HTML parser</a> based on
  whether <a href="#scripting-flag" id="the-noscript-element:scripting-flag">scripting was enabled or not</a> when the parser was
  invoked.</p>

  <p>The <code id="the-noscript-element:the-noscript-element-25"><a href="#the-noscript-element">noscript</a></code> element must not be used in <a id="the-noscript-element:xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a>.</p>

  <p class="note">The <code id="the-noscript-element:the-noscript-element-26"><a href="#the-noscript-element">noscript</a></code> element is only effective in <a href="#syntax" id="the-noscript-element:syntax">the HTML
  syntax</a>, it has no effect in <a href="#the-xhtml-syntax" id="the-noscript-element:the-xhtml-syntax">the XML syntax</a>. This is because the way it works
  is by essentially "turning off" the parser when scripts are enabled, so that the contents of the
  element are treated as pure text and not as real elements. XML does not define a mechanism by
  which to do this.</p>

  

  <p>The <code id="the-noscript-element:the-noscript-element-27"><a href="#the-noscript-element">noscript</a></code> element has no other requirements. In particular, children of the
  <code id="the-noscript-element:the-noscript-element-28"><a href="#the-noscript-element">noscript</a></code> element are not exempt from <a href="#form-submission-2" id="the-noscript-element:form-submission-2">form submission</a>, scripting, and so
  forth, even when <a href="#concept-n-script" id="the-noscript-element:concept-n-script-4">scripting is enabled</a> for the element.</p>

  

  <div class="example">

   <p>In the following example, a <code id="the-noscript-element:the-noscript-element-29"><a href="#the-noscript-element">noscript</a></code> element is
   used to provide fallback for a script.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"calcSquare.php"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">x</c-><c- p="">&gt;</c->Number<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->:
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"x"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"x"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"number"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> x <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'x'</c-><c- p="">);</c->
  <c- a="">var</c-> output <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'p'</c-><c- p="">);</c->
  output<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'Type a number; it will be squared right then!'</c-><c- p="">;</c->
  x<c- p="">.</c->form<c- p="">.</c->appendChild<c- p="">(</c->output<c- p="">);</c->
  x<c- p="">.</c->form<c- p="">.</c->onsubmit <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- kc="">false</c-><c- p="">;</c-> <c- p="">}</c->
  x<c- p="">.</c->oninput <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
    <c- a="">var</c-> v <c- o="">=</c-> x<c- p="">.</c->valueAsNumber<c- p="">;</c->
    output<c- p="">.</c->textContent <c- o="">=</c-> v <c- o="">+</c-> <c- t="">' squared is '</c-> <c- o="">+</c-> v <c- o="">*</c-> v<c- p="">;</c->
  <c- p="">};</c->
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">noscript</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Calculate Square"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">noscript</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

   <p>When script is disabled, a button appears to do the calculation on the server side. When
   script is enabled, the value is computed on-the-fly instead.</p>

   <p>The <code id="the-noscript-element:the-noscript-element-30"><a href="#the-noscript-element">noscript</a></code> element is a blunt instrument. Sometimes, scripts might be enabled,
   but for some reason the page's script might fail. For this reason, it's generally better to avoid
   using <code id="the-noscript-element:the-noscript-element-31"><a href="#the-noscript-element">noscript</a></code>, and to instead design the script to change the page from being a
   scriptless page to a scripted page on the fly, as in the next example:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"calcSquare.php"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">x</c-><c- p="">&gt;</c->Number<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->:
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"x"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"x"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"number"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <strong><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"submit"</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Calculate Square"</c-><c- p="">&gt;</c-></strong>
 <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> x <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'x'</c-><c- p="">);</c->
  <c- a="">var</c-> output <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'p'</c-><c- p="">);</c->
  output<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'Type a number; it will be squared right then!'</c-><c- p="">;</c->
  x<c- p="">.</c->form<c- p="">.</c->appendChild<c- p="">(</c->output<c- p="">);</c->
  x<c- p="">.</c->form<c- p="">.</c->onsubmit <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- kc="">false</c-><c- p="">;</c-> <c- p="">}</c->
  x<c- p="">.</c->oninput <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
    <c- a="">var</c-> v <c- o="">=</c-> x<c- p="">.</c->valueAsNumber<c- p="">;</c->
    output<c- p="">.</c->textContent <c- o="">=</c-> v <c- o="">+</c-> <c- t="">' squared is '</c-> <c- o="">+</c-> v <c- o="">*</c-> v<c- p="">;</c->
  <c- p="">};</c->
<strong>  <c- a="">var</c-> submit <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'submit'</c-><c- p="">);</c->
  submit<c- p="">.</c->parentNode<c- p="">.</c->removeChild<c- p="">(</c->submit<c- p="">);</c-></strong>
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

   <p>The above technique is also useful in <a id="the-noscript-element:xml-documents-2" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a>, since <code id="the-noscript-element:the-noscript-element-32"><a href="#the-noscript-element">noscript</a></code>
   is not allowed there.</p>

  </div>


  <h4 id="the-template-element"><span class="secno">4.12.3</span> The <dfn data-dfn-type="element"><code>template</code></dfn> element<a href="#the-template-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template" title="The <template> HTML element is a mechanism for holding HTML that is not to be rendered immediately when a page is loaded but may be instantiated subsequently during runtime using JavaScript.">Element/template</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>26+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>Yes</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement" title="The HTMLTemplateElement interface enables access to the contents of an HTML <template> element.">HTMLTemplateElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>26+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-template-element:concept-element-categories">Categories</a>:</dt><dd><a href="#metadata-content-2" id="the-template-element:metadata-content-2">Metadata content</a>.</dd><dd><a href="#flow-content-2" id="the-template-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-template-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#script-supporting-elements-2" id="the-template-element:script-supporting-elements-2">Script-supporting element</a>.</dd><dt><a href="#concept-element-contexts" id="the-template-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#metadata-content-2" id="the-template-element:metadata-content-2-2">metadata content</a> is expected.</dd><dd>Where <a href="#phrasing-content-2" id="the-template-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dd>Where <a href="#script-supporting-elements-2" id="the-template-element:script-supporting-elements-2-2">script-supporting elements</a> are expected.</dd><dd>As a child of a <code id="the-template-element:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> element that doesn't have a <code id="the-template-element:attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code> attribute.</dd><dt><a href="#concept-element-content-model" id="the-template-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#concept-content-nothing" id="the-template-element:concept-content-nothing">Nothing</a> (for clarification, <a href="#template-example">see example</a>).</dd><dt><a href="#concept-element-tag-omission" id="the-template-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-template-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-template-element:global-attributes">Global attributes</a></dd><dd><code id="the-template-element:attr-template-shadowrootmode"><a href="#attr-template-shadowrootmode">shadowrootmode</a></code> —  Enables streaming declarative shadow roots
     </dd><dd><code id="the-template-element:attr-template-shadowrootdelegatesfocus"><a href="#attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus</a></code> —  Sets <a id="the-template-element:delegates-focus" href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus" data-x-internal="delegates-focus">delegates focus</a> on a declarative shadow root
     </dd><dd><code id="the-template-element:attr-template-shadowrootclonable"><a href="#attr-template-shadowrootclonable">shadowrootclonable</a></code> —  Sets <a id="the-template-element:clonable" href="https://dom.spec.whatwg.org/#shadowroot-clonable" data-x-internal="clonable">clonable</a> on a declarative shadow root
     </dd><dd><code id="the-template-element:attr-template-shadowrootserializable"><a href="#attr-template-shadowrootserializable">shadowrootserializable</a></code> —  Sets <a href="https://dom.spec.whatwg.org/#shadowroot-serializable" id="the-template-element:shadow-serializable" data-x-internal="shadow-serializable">serializable</a> on a declarative shadow root
     </dd><dd><code id="the-template-element:attr-template-shadowrootcustomelementregistry"><a href="#attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</a></code> —  Enables declarative shadow roots to indicate they will use a custom element registry
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-template-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-template">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-template">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-template-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmltemplateelement" data-dfn-type="interface"><c- g="">HTMLTemplateElement</c-></dfn> : <a href="#htmlelement" id="the-template-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-template-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-template-element:documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment" data-x-internal="documentfragment"><c- n="">DocumentFragment</c-></a> <a href="#dom-template-content" id="the-template-element:dom-template-content"><c- g="">content</c-></a>;
  [<a href="#cereactions" id="the-template-element:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-template-shadowrootmode" id="the-template-element:dom-template-shadowrootmode"><c- g="">shadowRootMode</c-></a>;
  [<a href="#cereactions" id="the-template-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-template-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLTemplateElement" id="dom-template-shadowrootdelegatesfocus" data-dfn-type="attribute"><c- g="">shadowRootDelegatesFocus</c-></dfn>;
  [<a href="#cereactions" id="the-template-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-template-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLTemplateElement" id="dom-template-shadowrootclonable" data-dfn-type="attribute"><c- g="">shadowRootClonable</c-></dfn>;
  [<a href="#cereactions" id="the-template-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-template-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLTemplateElement" id="dom-template-shadowrootserializable" data-dfn-type="attribute"><c- g="">shadowRootSerializable</c-></dfn>;
  [<a href="#cereactions" id="the-template-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-template-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTemplateElement" id="dom-template-shadowrootcustomelementregistry" data-dfn-type="attribute"><c- g="">shadowRootCustomElementRegistry</c-></dfn>;
};</code></pre>
</dd></dl>

  <p>The <code id="the-template-element:the-template-element"><a href="#the-template-element">template</a></code> element is used to declare fragments of HTML that can be cloned and
  inserted in the document by script.</p>

  <p>In a rendering, the <code id="the-template-element:the-template-element-2"><a href="#the-template-element">template</a></code> element <a href="#represents" id="the-template-element:represents">represents</a> nothing.</p>

  <p>The <dfn data-dfn-for="template" id="attr-template-shadowrootmode" data-dfn-type="element-attr"><code>shadowrootmode</code></dfn> content attribute is an
  <a href="#enumerated-attribute" id="the-template-element:enumerated-attribute">enumerated attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="template/shadowrootmode" id="attr-shadowrootmode-open" data-dfn-type="attr-value"><code>open</code></dfn>
     </td><td><dfn id="attr-shadowrootmode-open-state">Open</dfn>
     </td><td>The template element represents an open declarative shadow root.
    </td></tr><tr><td><dfn data-dfn-for="template/shadowrootmode" id="attr-shadowrootmode-closed" data-dfn-type="attr-value"><code>closed</code></dfn>
     </td><td><dfn id="attr-shadowrootmode-closed-state">Closed</dfn>
     </td><td>The template element represents a closed declarative shadow root.
  </td></tr></tbody></table>

  <p>The <code id="the-template-element:attr-template-shadowrootmode-2"><a href="#attr-template-shadowrootmode">shadowrootmode</a></code> attribute's <i id="the-template-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> and <i id="the-template-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> are both the <dfn id="attr-shadowrootmode-none-state">None</dfn> state.</p>

  <p>The <dfn data-dfn-for="template" id="attr-template-shadowrootdelegatesfocus" data-dfn-type="element-attr"><code>shadowrootdelegatesfocus</code></dfn> content
  attribute is a <a href="#boolean-attribute" id="the-template-element:boolean-attribute">boolean attribute</a>.</p>

  <p>The <dfn data-dfn-for="template" id="attr-template-shadowrootclonable" data-dfn-type="element-attr"><code>shadowrootclonable</code></dfn> content attribute is a
  <a href="#boolean-attribute" id="the-template-element:boolean-attribute-2">boolean attribute</a>.</p>

  <p>The <dfn data-dfn-for="template" id="attr-template-shadowrootserializable" data-dfn-type="element-attr"><code>shadowrootserializable</code></dfn> content
  attribute is a <a href="#boolean-attribute" id="the-template-element:boolean-attribute-3">boolean attribute</a>.</p>

  <p>The <dfn data-dfn-for="template" id="attr-template-shadowrootcustomelementregistry" data-dfn-type="element-attr"><code>shadowrootcustomelementregistry</code></dfn>
  content attribute is a <a href="#boolean-attribute" id="the-template-element:boolean-attribute-4">boolean attribute</a>.</p>

  <p>The <a href="#template-contents" id="the-template-element:template-contents">template contents</a> of a <code id="the-template-element:the-template-element-3"><a href="#the-template-element">template</a></code> element <a href="#template-syntax">are not children of the element itself</a>.</p>

  <p class="note">It is also possible, as a result of DOM manipulation, for a <code id="the-template-element:the-template-element-4"><a href="#the-template-element">template</a></code>
  element to contain <code id="the-template-element:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes and element nodes; however, having any is a violation
  of the <code id="the-template-element:the-template-element-5"><a href="#the-template-element">template</a></code> element's content model, since its content model is defined as <a href="#concept-content-nothing" id="the-template-element:concept-content-nothing-2">nothing</a>.</p>

  <div id="template-example" class="example"><a href="#template-example" class="self-link"></a>

   <p>For example, consider the following document:</p>

   

   <pre><code class="html"><c- cp="">&lt;!doctype html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Homework<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">template</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"template"</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Smile!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">template</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">let</c-> num <c- o="">=</c-> <c- mf="">3</c-><c- p="">;</c->
   <c- a="">const</c-> fragment <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'template'</c-><c- p="">).</c->content<c- p="">.</c->cloneNode<c- p="">(</c-><c- kc="">true</c-><c- p="">);</c->
   <c- k="">while</c-> <c- p="">(</c->num<c- o="">--</c-> <c- o="">&gt;</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
     fragment<c- p="">.</c->firstChild<c- p="">.</c->before<c- p="">(</c->fragment<c- p="">.</c->firstChild<c- p="">.</c->cloneNode<c- p="">(</c-><c- kc="">true</c-><c- p="">));</c->
     fragment<c- p="">.</c->firstChild<c- p="">.</c->textContent <c- o="">+=</c-> fragment<c- p="">.</c->lastChild<c- p="">.</c->textContent<c- p="">;</c->
   <c- p="">}</c->
   document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->fragment<c- p="">);</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>The <code id="the-template-element:the-p-element"><a href="#the-p-element">p</a></code> element in the <code id="the-template-element:the-template-element-6"><a href="#the-template-element">template</a></code> is <em>not</em> a child of the
   <code id="the-template-element:the-template-element-7"><a href="#the-template-element">template</a></code> in the DOM; it is a child of the <code id="the-template-element:documentfragment-2"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> returned by
   the <code id="the-template-element:the-template-element-8"><a href="#the-template-element">template</a></code> element's <code id="the-template-element:dom-template-content-2"><a href="#dom-template-content">content</a></code> IDL
   attribute.</p>

   <p>If the script were to call <code id="the-template-element:dom-node-appendchild"><a data-x-internal="dom-node-appendchild" href="https://dom.spec.whatwg.org/#dom-node-appendchild">appendChild()</a></code> on the
   <code id="the-template-element:the-template-element-9"><a href="#the-template-element">template</a></code> element, that would add a child to the <code id="the-template-element:the-template-element-10"><a href="#the-template-element">template</a></code> element (as
   for any other element); however, doing so is a violation of the <code id="the-template-element:the-template-element-11"><a href="#the-template-element">template</a></code> element's
   content model.</p>

  </div>

  <dl class="domintro"><dt><code><var>template</var>.<a href="#dom-template-content" id="dom-template-content-dev">content</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content" title="The HTMLTemplateElement.content property returns a <template> element's template contents (a DocumentFragment).">HTMLTemplateElement/content</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>26+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the <a href="#template-contents" id="the-template-element:template-contents-2">template contents</a> (a <code id="the-template-element:documentfragment-3"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code>).</p></dd></dl>

  

  <div data-algorithm="">
  <p>Each <code id="the-template-element:the-template-element-12"><a href="#the-template-element">template</a></code> element has an associated <code id="the-template-element:documentfragment-4"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> object that
  is its <dfn id="template-contents">template contents</dfn>. The <a href="#template-contents" id="the-template-element:template-contents-3">template contents</a> have <a href="#no-browsing-context">no conformance requirements</a>. When a <code id="the-template-element:the-template-element-13"><a href="#the-template-element">template</a></code> element
  is created, the user agent must run the following steps to establish the <a href="#template-contents" id="the-template-element:template-contents-4">template
  contents</a>:</p>

  <ol><li><p>Let <var>doc</var> be the <code id="the-template-element:the-template-element-14"><a href="#the-template-element">template</a></code> element's <a id="the-template-element:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#appropriate-template-contents-owner-document" id="the-template-element:appropriate-template-contents-owner-document">appropriate template contents owner
   document</a>.</p></li><li><p>Create a <code id="the-template-element:documentfragment-5"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> object whose <a id="the-template-element:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is
   <var>doc</var> and <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="the-template-element:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">host</a> is the
   <code id="the-template-element:the-template-element-15"><a href="#the-template-element">template</a></code> element.</p></li><li><p>Set the <code id="the-template-element:the-template-element-16"><a href="#the-template-element">template</a></code> element's <a href="#template-contents" id="the-template-element:template-contents-5">template contents</a> to the newly
   created <code id="the-template-element:documentfragment-6"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> object.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-template-element:document"><a href="#document">Document</a></code> <var>doc</var>'s <dfn id="appropriate-template-contents-owner-document">appropriate template contents owner
  document</dfn> is the <code id="the-template-element:document-2"><a href="#document">Document</a></code> returned by the following algorithm:</p>

  <ol><li>
    <p>If <var>doc</var> is not a <code id="the-template-element:document-3"><a href="#document">Document</a></code> created by this algorithm, then:</p>

    <ol><li>
      <p>If <var>doc</var> does not yet have an <dfn id="associated-inert-template-document">associated inert template document</dfn>,
      then:</p>

      <ol><li><p>Let <var>new doc</var> be a new <code id="the-template-element:document-4"><a href="#document">Document</a></code> (whose <a href="#concept-document-bc" id="the-template-element:concept-document-bc">browsing context</a> is null). This is "a
       <code id="the-template-element:document-5"><a href="#document">Document</a></code> created by this algorithm" for the purposes of the step above.</p></li><li><p>If <var>doc</var> is an <a href="https://dom.spec.whatwg.org/#html-document" id="the-template-element:html-documents" data-x-internal="html-documents">HTML document</a>, mark
       <var>new doc</var> as an <a href="https://dom.spec.whatwg.org/#html-document" id="the-template-element:html-documents-2" data-x-internal="html-documents">HTML document</a>
       also.</p></li><li><p>Set <var>doc</var>'s <a href="#associated-inert-template-document" id="the-template-element:associated-inert-template-document">associated inert template document</a> to <var>new doc</var>.</p></li></ol>
     </li><li><p>Set <var>doc</var> to <var>doc</var>'s <a href="#associated-inert-template-document" id="the-template-element:associated-inert-template-document-2">associated inert
     template document</a>.</p></li></ol>

    <p class="note">Each <code id="the-template-element:document-6"><a href="#document">Document</a></code> not created by this algorithm thus gets a single
    <code id="the-template-element:document-7"><a href="#document">Document</a></code> to act as its proxy for owning the <a href="#template-contents" id="the-template-element:template-contents-6">template contents</a> of all
    its <code id="the-template-element:the-template-element-17"><a href="#the-template-element">template</a></code> elements, so that they aren't in a <a href="#browsing-context" id="the-template-element:browsing-context">browsing context</a> and
    thus remain inert (e.g. scripts do not run). Meanwhile, <code id="the-template-element:the-template-element-18"><a href="#the-template-element">template</a></code> elements inside
    <code id="the-template-element:document-8"><a href="#document">Document</a></code> objects that <em>are</em> created by this algorithm just reuse the same
    <code id="the-template-element:document-9"><a href="#document">Document</a></code> owner for their contents.</p>
   </li><li><p>Return <var>doc</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="template-adopting-steps">The <a href="https://dom.spec.whatwg.org/#concept-node-adopt-ext" id="the-template-element:concept-node-adopt-ext" data-x-internal="concept-node-adopt-ext">adopting steps</a>
  (with <var>node</var> and <var>oldDocument</var> as parameters) for <code id="the-template-element:the-template-element-19"><a href="#the-template-element">template</a></code> elements
  are the following:</p>

  <ol><li>
    <p>Let <var>doc</var> be <var>node</var>'s <a id="the-template-element:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s
    <a href="#appropriate-template-contents-owner-document" id="the-template-element:appropriate-template-contents-owner-document-2">appropriate template contents owner document</a>.</p>

    <p class="note"><var>node</var>'s <a id="the-template-element:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is the <code id="the-template-element:document-10"><a href="#document">Document</a></code> object
    that <var>node</var> was just adopted <em>into</em>.</p>
   </li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-adopt" id="the-template-element:concept-node-adopt" data-x-internal="concept-node-adopt">Adopt</a> <var>node</var>'s
   <a href="#template-contents" id="the-template-element:template-contents-7">template contents</a> (a <code id="the-template-element:documentfragment-7"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> object) into <var>doc</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTemplateElement" id="dom-template-content" data-dfn-type="attribute"><code>content</code></dfn> getter steps are to return
  <code id="the-template-element:the-template-element-20"><a href="#the-template-element">template</a></code>'s <a href="#template-contents" id="the-template-element:template-contents-8">template contents</a>, if the <a href="#template-contents" id="the-template-element:template-contents-9">template contents</a> is
  not a <code id="the-template-element:shadowroot"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code> node; otherwise null.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLTemplateElement" id="dom-template-shadowrootmode" data-dfn-type="attribute"><code>shadowRootMode</code></dfn> IDL attribute must
  <a href="#reflect" id="the-template-element:reflect">reflect</a> the <code id="the-template-element:attr-template-shadowrootmode-3"><a href="#attr-template-shadowrootmode">shadowrootmode</a></code> content
  attribute, <a href="#limited-to-only-known-values" id="the-template-element:limited-to-only-known-values">limited to only known values</a>.</p>
  </div>

  <p class="note">The <a href="#dom-template-shadowrootcustomelementregistry" id="the-template-element:dom-template-shadowrootcustomelementregistry">shadowRootCustomElementRegistry</a> IDL
  attribute intentionally does not have a boolean type so it can be extended.</p>

  <hr>

  <div data-algorithm="">
  <p>The <a href="https://dom.spec.whatwg.org/#concept-node-clone-ext" id="the-template-element:concept-node-clone-ext" data-x-internal="concept-node-clone-ext">cloning steps</a> for <code id="the-template-element:the-template-element-21"><a href="#the-template-element">template</a></code>
  elements given <var>node</var>, <var>copy</var>, and <var>subtree</var> are:</p>

  <ol><li><p>If <var>subtree</var> is false, then return.</p></li><li><p>For each <var>child</var> of <var>node</var>'s <a href="#template-contents" id="the-template-element:template-contents-10">template contents</a>'s <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="the-template-element:concept-tree-child" data-x-internal="concept-tree-child">children</a>, in <a id="the-template-element:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>: <a href="https://dom.spec.whatwg.org/#concept-node-clone" id="the-template-element:concept-node-clone" data-x-internal="concept-node-clone">clone a node</a> given <var>child</var> with <a href="https://dom.spec.whatwg.org/#clone-a-node-document" id="the-template-element:concept-node-clone-document" data-x-internal="concept-node-clone-document"><i>document</i></a> set to <var>copy</var>'s
   <a href="#template-contents" id="the-template-element:template-contents-11">template contents</a>'s <a id="the-template-element:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, <a href="https://dom.spec.whatwg.org/#clone-a-node-subtree" id="the-template-element:concept-node-clone-subtree" data-x-internal="concept-node-clone-subtree"><i>subtree</i></a> set to true, and <a href="https://dom.spec.whatwg.org/#clone-a-node-parent" id="the-template-element:concept-node-clone-parent" data-x-internal="concept-node-clone-parent"><i>parent</i></a> set to <var>copy</var>'s <a href="#template-contents" id="the-template-element:template-contents-12">template
   contents</a>.</p></li></ol>
  </div>

  

  <div class="example">

   <p>In this example, a script populates a table four-column with data from a data structure, using
   a <code id="the-template-element:the-template-element-22"><a href="#the-template-element">template</a></code> to provide the element structure instead of manually generating the
   structure from markup.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">'en'</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Cat data<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- c1="">// Data is hard-coded here, but could come from the server</c->
 <c- a="">var</c-> data <c- o="">=</c-> <c- p="">[</c->
   <c- p="">{</c-> name<c- o="">:</c-> <c- t="">'Pillar'</c-><c- p="">,</c-> color<c- o="">:</c-> <c- t="">'Ticked Tabby'</c-><c- p="">,</c-> sex<c- o="">:</c-> <c- t="">'Female (neutered)'</c-><c- p="">,</c-> legs<c- o="">:</c-> <c- mf="">3</c-> <c- p="">},</c->
   <c- p="">{</c-> name<c- o="">:</c-> <c- t="">'Hedral'</c-><c- p="">,</c-> color<c- o="">:</c-> <c- t="">'Tuxedo'</c-><c- p="">,</c-> sex<c- o="">:</c-> <c- t="">'Male (neutered)'</c-><c- p="">,</c-> legs<c- o="">:</c-> <c- mf="">4</c-> <c- p="">},</c->
 <c- p="">];</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Name <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Color <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Sex <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Legs
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">template</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"row"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">template</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> template <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- t="">'#row'</c-><c- p="">);</c->
 <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> i <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> i <c- o="">&lt;</c-> data<c- p="">.</c->length<c- p="">;</c-> i <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
   <c- a="">var</c-> cat <c- o="">=</c-> data<c- p="">[</c->i<c- p="">];</c->
   <c- a="">var</c-> clone <c- o="">=</c-> template<c- p="">.</c->content<c- p="">.</c->cloneNode<c- p="">(</c-><c- kc="">true</c-><c- p="">);</c->
   <c- a="">var</c-> cells <c- o="">=</c-> clone<c- p="">.</c->querySelectorAll<c- p="">(</c-><c- t="">'td'</c-><c- p="">);</c->
   cells<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->textContent <c- o="">=</c-> cat<c- p="">.</c->name<c- p="">;</c->
   cells<c- p="">[</c-><c- mf="">1</c-><c- p="">].</c->textContent <c- o="">=</c-> cat<c- p="">.</c->color<c- p="">;</c->
   cells<c- p="">[</c-><c- mf="">2</c-><c- p="">].</c->textContent <c- o="">=</c-> cat<c- p="">.</c->sex<c- p="">;</c->
   cells<c- p="">[</c-><c- mf="">3</c-><c- p="">].</c->textContent <c- o="">=</c-> cat<c- p="">.</c->legs<c- p="">;</c->
   template<c- p="">.</c->parentNode<c- p="">.</c->appendChild<c- p="">(</c->clone<c- p="">);</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>This example uses <code id="the-template-element:dom-node-clonenode"><a data-x-internal="dom-node-clonenode" href="https://dom.spec.whatwg.org/#dom-node-clonenode">cloneNode()</a></code> on the
   <code id="the-template-element:the-template-element-23"><a href="#the-template-element">template</a></code>'s contents; it could equivalently have used <code id="the-template-element:dom-document-importnode"><a data-x-internal="dom-document-importnode" href="https://dom.spec.whatwg.org/#dom-document-importnode">document.importNode()</a></code>, which does the same thing. The
   only difference between these two APIs is when the <a id="the-template-element:node-document-6" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is updated: with
   <code id="the-template-element:dom-node-clonenode-2"><a data-x-internal="dom-node-clonenode" href="https://dom.spec.whatwg.org/#dom-node-clonenode">cloneNode()</a></code> it is updated when the nodes are appended
   with <code id="the-template-element:dom-node-appendchild-2"><a data-x-internal="dom-node-appendchild" href="https://dom.spec.whatwg.org/#dom-node-appendchild">appendChild()</a></code>, with <code id="the-template-element:dom-document-importnode-2"><a data-x-internal="dom-document-importnode" href="https://dom.spec.whatwg.org/#dom-document-importnode">document.importNode()</a></code> it is updated when the nodes are
   cloned.</p>

  </div>



  

  <h5 id="template-XSLT-XPath"><span class="secno">4.12.3.1</span> Interaction of <code id="template-XSLT-XPath:the-template-element"><a href="#the-template-element">template</a></code> elements with XSLT and XPath<a href="#template-XSLT-XPath" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>This specification does not define how XSLT and XPath interact with the <code id="template-XSLT-XPath:the-template-element-2"><a href="#the-template-element">template</a></code>
  element. However, in the absence of another specification actually defining this, here are some
  guidelines for implementers, which are intended to be consistent with other processing described
  in this specification:</p>

  <ul><li><p>An XSLT processor based on an XML parser that acts <a href="#xml-parser" id="template-XSLT-XPath:xml-parser">as described
   in this specification</a> needs to act as if <code id="template-XSLT-XPath:the-template-element-3"><a href="#the-template-element">template</a></code> elements contain as
   descendants their <a href="#template-contents" id="template-XSLT-XPath:template-contents">template contents</a> for the purposes of the transform.</p></li><li><p>An XSLT processor that outputs a DOM needs to ensure that nodes that would go into a
   <code id="template-XSLT-XPath:the-template-element-4"><a href="#the-template-element">template</a></code> element are instead placed into the element's <a href="#template-contents" id="template-XSLT-XPath:template-contents-2">template
   contents</a>.</p></li><li><p>XPath evaluation using the XPath DOM API when applied to a <code id="template-XSLT-XPath:document"><a href="#document">Document</a></code> parsed
   using the <a href="#html-parser" id="template-XSLT-XPath:html-parser">HTML parser</a> or the <a href="#xml-parser" id="template-XSLT-XPath:xml-parser-2">XML parser</a> described in this specification
   needs to ignore <a href="#template-contents" id="template-XSLT-XPath:template-contents-3">template contents</a>.</p>
  </li></ul>

  



  <h4 id="the-slot-element"><span class="secno">4.12.4</span> The <dfn data-dfn-type="element"><code>slot</code></dfn> element<a href="#the-slot-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot" title="The <slot> HTML element—part of the Web Components technology suite—is a placeholder inside a web component that you can fill with your own markup, which lets you create separate DOM trees and present them together.">Element/slot</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>53+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement" title="The HTMLSlotElement interface of the Shadow DOM API enables access to the name and assigned nodes of an HTML <slot> element.">HTMLSlotElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>53+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-slot-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-slot-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-slot-element:phrasing-content-2">Phrasing content</a>.</dd><dt><a href="#concept-element-contexts" id="the-slot-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="the-slot-element:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-slot-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#transparent" id="the-slot-element:transparent">Transparent</a></dd><dt><a href="#concept-element-tag-omission" id="the-slot-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-slot-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-slot-element:global-attributes">Global attributes</a></dd><dd><code id="the-slot-element:attr-slot-name"><a href="#attr-slot-name">name</a></code> —  Name of shadow tree slot
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-slot-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-slot">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-slot">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-slot-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlslotelement" data-dfn-type="interface"><c- g="">HTMLSlotElement</c-></dfn> : <a href="#htmlelement" id="the-slot-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-slot-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-slot-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-slot-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLSlotElement" id="dom-slot-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  <c- b="">sequence</c->&lt;<c- n="">Node</c->&gt; <a href="#dom-slot-assignednodes" id="the-slot-element:dom-slot-assignednodes"><c- g="">assignedNodes</c-></a>(<c- b="">optional</c-> <a href="#assignednodesoptions" id="the-slot-element:assignednodesoptions"><c- n="">AssignedNodesOptions</c-></a> <c- g="">options</c-> = {});
  <c- b="">sequence</c->&lt;<c- n="">Element</c->&gt; <a href="#dom-slot-assignedelements" id="the-slot-element:dom-slot-assignedelements"><c- g="">assignedElements</c-></a>(<c- b="">optional</c-> <a href="#assignednodesoptions" id="the-slot-element:assignednodesoptions-2"><c- n="">AssignedNodesOptions</c-></a> <c- g="">options</c-> = {});
  <c- b="">undefined</c-> <a href="#dom-slot-assign" id="the-slot-element:dom-slot-assign"><c- g="">assign</c-></a>((<a id="the-slot-element:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a> <c- b="">or</c-> <a id="the-slot-element:text" href="https://dom.spec.whatwg.org/#interface-text" data-x-internal="text"><c- n="">Text</c-></a>)... <c- g="">nodes</c->);
};

<c- b="">dictionary</c-> <dfn id="assignednodesoptions" data-dfn-type="dictionary"><c- g="">AssignedNodesOptions</c-></dfn> {
  <c- b="">boolean</c-> <dfn data-dfn-for="AssignedNodeOptions" id="dom-assignednodesoptions-flatten" data-dfn-type="dict-member"><c- g="">flatten</c-></dfn> = <c- b="">false</c->;
};</code></pre>
   </dd></dl>

  <p>The <code id="the-slot-element:the-slot-element"><a href="#the-slot-element">slot</a></code> element defines a <a href="https://dom.spec.whatwg.org/#concept-slot" id="the-slot-element:concept-slot" data-x-internal="concept-slot">slot</a>. It is
  typically used in a <a id="the-slot-element:shadow-tree" href="https://dom.spec.whatwg.org/#concept-shadow-tree" data-x-internal="shadow-tree">shadow tree</a>. A <code id="the-slot-element:the-slot-element-2"><a href="#the-slot-element">slot</a></code> element <a href="#represents" id="the-slot-element:represents">represents</a>
  its <a id="the-slot-element:assigned-nodes" href="https://dom.spec.whatwg.org/#slot-assigned-nodes" data-x-internal="assigned-nodes">assigned nodes</a>, if any, and its contents otherwise.</p>

  <p>The <dfn data-dfn-for="slot" id="attr-slot-name" data-dfn-type="element-attr"><code>name</code></dfn> content
  attribute may contain any string value. It represents a <a href="https://dom.spec.whatwg.org/#concept-slot" id="the-slot-element:concept-slot-2" data-x-internal="concept-slot">slot</a>'s
  <a href="https://dom.spec.whatwg.org/#slot-name" id="the-slot-element:slot-name" data-x-internal="slot-name">name</a>.</p>

  <p class="note">The <code id="the-slot-element:attr-slot-name-2"><a href="#attr-slot-name">name</a></code> attribute is used to <a href="https://dom.spec.whatwg.org/#assign-a-slot" id="the-slot-element:assign-a-slot" data-x-internal="assign-a-slot">assign slots</a> to other elements: a <code id="the-slot-element:the-slot-element-3"><a href="#the-slot-element">slot</a></code> element with a
  <code id="the-slot-element:attr-slot-name-3"><a href="#attr-slot-name">name</a></code> attribute creates a named <a href="https://dom.spec.whatwg.org/#concept-slot" id="the-slot-element:concept-slot-3" data-x-internal="concept-slot">slot</a> to which any element is <a href="https://dom.spec.whatwg.org/#assign-a-slot" id="the-slot-element:assign-a-slot-2" data-x-internal="assign-a-slot">assigned</a> if that element has a <code id="the-slot-element:attr-slot"><a href="#attr-slot">slot</a></code> attribute whose
  value matches that <code id="the-slot-element:attr-slot-name-4"><a href="#attr-slot-name">name</a></code> attribute's value, and the
  <code id="the-slot-element:the-slot-element-4"><a href="#the-slot-element">slot</a></code> element is a child of the <a id="the-slot-element:shadow-tree-2" href="https://dom.spec.whatwg.org/#concept-shadow-tree" data-x-internal="shadow-tree">shadow tree</a> whose <a id="the-slot-element:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>'s
  <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="the-slot-element:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">host</a> has that corresponding <code id="the-slot-element:attr-slot-2"><a href="#attr-slot">slot</a></code> attribute value.</p>

  <dl class="domintro"><dt><code><var>slot</var>.<a href="#dom-slot-name" id="dom-slot-name-dev">name</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/name" title="The name property of the HTMLSlotElement interface returns or sets the slot name. A slot is a placeholder inside a web component that users can fill with their own markup.">HTMLSlotElement/name</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>53+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>Can be used to get and set <var>slot</var>'s <a href="https://dom.spec.whatwg.org/#slot-name" id="the-slot-element:slot-name-2" data-x-internal="slot-name">name</a>.</dd><dt><code><var>slot</var>.<a href="#dom-slot-assignednodes" id="dom-slot-assignednodes-dev">assignedNodes</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedNodes" title="The assignedNodes() method of the HTMLSlotElement interface returns a sequence of the nodes assigned to this slot.">HTMLSlotElement/assignedNodes</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>53+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>Returns <var>slot</var>'s <a id="the-slot-element:assigned-nodes-2" href="https://dom.spec.whatwg.org/#slot-assigned-nodes" data-x-internal="assigned-nodes">assigned nodes</a>.</dd><dt><code><var>slot</var>.<a href="#dom-slot-assignednodes" id="the-slot-element:dom-slot-assignednodes-2">assignedNodes</a>({ flatten: true })</code></dt><dd>Returns <var>slot</var>'s <a id="the-slot-element:assigned-nodes-3" href="https://dom.spec.whatwg.org/#slot-assigned-nodes" data-x-internal="assigned-nodes">assigned nodes</a>, if any, and <var>slot</var>'s children
   otherwise, and does the same for any <code id="the-slot-element:the-slot-element-5"><a href="#the-slot-element">slot</a></code> elements encountered therein, recursively,
   until there are no <code id="the-slot-element:the-slot-element-6"><a href="#the-slot-element">slot</a></code> elements left.</dd><dt><code><var>slot</var>.<a href="#dom-slot-assignedelements" id="dom-slot-assignedelements-dev">assignedElements</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements" title="The assignedElements() method of the HTMLSlotElement interface returns a sequence of the elements assigned to this slot (and no other nodes).">HTMLSlotElement/assignedElements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>66+</span></span><span class="safari yes"><span>Safari</span><span>12.1+</span></span><span class="chrome yes"><span>Chrome</span><span>65+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>Returns <var>slot</var>'s <a id="the-slot-element:assigned-nodes-4" href="https://dom.spec.whatwg.org/#slot-assigned-nodes" data-x-internal="assigned-nodes">assigned nodes</a>, limited to elements.</dd><dt><code><var>slot</var>.<a href="#dom-slot-assignedelements" id="the-slot-element:dom-slot-assignedelements-2">assignedElements</a>({ flatten: true })</code></dt><dd>Returns the same as <code id="the-slot-element:dom-slot-assignednodes-3"><a href="#dom-slot-assignednodes">assignedNodes({ flatten: true
   })</a></code>, limited to elements.</dd><dt><code><var>slot</var>.<a href="#dom-slot-assign" id="the-slot-element:dom-slot-assign-2">assign</a>(...<var>nodes</var>)</code></dt><dd><p>Sets <var>slot</var>'s <a href="#manually-assigned-nodes" id="the-slot-element:manually-assigned-nodes">manually assigned nodes</a> to the given
   <var>nodes</var>.</p></dd></dl>

  <p>The <code id="the-slot-element:the-slot-element-7"><a href="#the-slot-element">slot</a></code> element has <dfn data-dfn-for="HTMLSlotElement" id="manually-assigned-nodes" data-export="">manually assigned
  nodes</dfn>, which is an <a href="https://infra.spec.whatwg.org/#ordered-set" id="the-slot-element:set" data-x-internal="set">ordered set</a> of <a href="https://dom.spec.whatwg.org/#concept-slotable" id="the-slot-element:slottable" data-x-internal="slottable">slottables</a> set by <code id="the-slot-element:dom-slot-assign-3"><a href="#dom-slot-assign">assign()</a></code>.
  This set is initially empty.</p>

  <p class="note">The <a href="#manually-assigned-nodes" id="the-slot-element:manually-assigned-nodes-2">manually assigned nodes</a> set can be implemented using weak
  references to the <a href="https://dom.spec.whatwg.org/#concept-slotable" id="the-slot-element:slottable-2" data-x-internal="slottable">slottables</a>, because this set is not
  directly accessible from script.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSlotElement" id="dom-slot-assignednodes" data-dfn-type="method"><code>assignedNodes(<var>options</var>)</code></dfn> method steps
  are:</p>

  <ol><li><p>If <var>options</var>["<code id="the-slot-element:dom-assignednodesoptions-flatten"><a href="#dom-assignednodesoptions-flatten">flatten</a></code>"] is
   false, then return <a id="the-slot-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-slot-element:assigned-nodes-5" href="https://dom.spec.whatwg.org/#slot-assigned-nodes" data-x-internal="assigned-nodes">assigned nodes</a>.</p></li><li><p>Return the result of <a id="the-slot-element:finding-flattened-slottables" href="https://dom.spec.whatwg.org/#find-flattened-slotables" data-x-internal="finding-flattened-slottables">finding flattened slottables</a> with
   <a id="the-slot-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSlotElement" id="dom-slot-assignedelements" data-dfn-type="method"><code>assignedElements(<var>options</var>)</code></dfn> method
  steps are:</p>

  <ol><li><p>If <var>options</var>["<code id="the-slot-element:dom-assignednodesoptions-flatten-2"><a href="#dom-assignednodesoptions-flatten">flatten</a></code>"] is
   false, then return <a id="the-slot-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-slot-element:assigned-nodes-6" href="https://dom.spec.whatwg.org/#slot-assigned-nodes" data-x-internal="assigned-nodes">assigned nodes</a>, filtered to contain only
   <code id="the-slot-element:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> nodes.</p></li><li><p>Return the result of <a id="the-slot-element:finding-flattened-slottables-2" href="https://dom.spec.whatwg.org/#find-flattened-slotables" data-x-internal="finding-flattened-slottables">finding flattened slottables</a> with <a id="the-slot-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>,
   filtered to contain only <code id="the-slot-element:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> nodes.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assign" title="The assign() method of the HTMLSlotElement interface sets the slot's manually assigned nodes to an ordered set of slottables. The manually assigned nodes set is initially empty until nodes are assigned using assign().">HTMLSlotElement/assign</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>92+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>86+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>86+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLSlotElement" id="dom-slot-assign" data-dfn-type="method"><code>assign(...<var>nodes</var>)</code></dfn> method steps are:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-slot-element:list-iterate" data-x-internal="list-iterate">For each</a> <var>node</var> of <a id="the-slot-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a href="#manually-assigned-nodes" id="the-slot-element:manually-assigned-nodes-3">manually assigned nodes</a>, set <var>node</var>'s <a id="the-slot-element:manual-slot-assignment" href="https://dom.spec.whatwg.org/#slottable-manual-slot-assignment" data-x-internal="manual-slot-assignment">manual slot assignment</a>
   to null.</p></li><li><p>Let <var>nodesSet</var> be a new <a href="https://infra.spec.whatwg.org/#ordered-set" id="the-slot-element:set-2" data-x-internal="set">ordered set</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-slot-element:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>node</var> of <var>nodes</var>:</p>

    <ol><li><p>If <var>node</var>'s <a id="the-slot-element:manual-slot-assignment-2" href="https://dom.spec.whatwg.org/#slottable-manual-slot-assignment" data-x-internal="manual-slot-assignment">manual slot assignment</a> refers to a <a href="#the-slot-element" id="the-slot-element:the-slot-element-8">slot</a>,
     then remove <var>node</var> from that <a href="#the-slot-element" id="the-slot-element:the-slot-element-9">slot</a>'s
     <a href="#manually-assigned-nodes" id="the-slot-element:manually-assigned-nodes-4">manually assigned nodes</a>.</p></li><li><p>Set <var>node</var>'s <a id="the-slot-element:manual-slot-assignment-3" href="https://dom.spec.whatwg.org/#slottable-manual-slot-assignment" data-x-internal="manual-slot-assignment">manual slot assignment</a> to <a id="the-slot-element:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="the-slot-element:set-append" data-x-internal="set-append">Append</a> <var>node</var> to <var>nodesSet</var>.</p></li></ol>
   </li><li><p>Set <a id="the-slot-element:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#manually-assigned-nodes" id="the-slot-element:manually-assigned-nodes-5">manually assigned nodes</a> to
   <var>nodesSet</var>.</p></li><li><p>Run <a id="the-slot-element:assign-slottables-for-a-tree" href="https://dom.spec.whatwg.org/#assign-slotables-for-a-tree" data-x-internal="assign-slottables-for-a-tree">assign slottables for a tree</a> for <a id="the-slot-element:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a id="the-slot-element:root-2" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>.</p></li></ol>
  </div>


  <h4 id="the-canvas-element"><span class="secno">4.12.5</span> The <dfn id="canvas" data-dfn-type="element"><code>canvas</code></dfn> element<a href="#the-canvas-element" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas" title="Use the HTML <canvas> element with either the canvas scripting API or the WebGL API to draw graphics and animations.">Element/canvas</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement" title="The HTMLCanvasElement interface provides properties and methods for manipulating the layout and presentation of <canvas> elements. The HTMLCanvasElement interface also inherits the properties and methods of the HTMLElement interface.">HTMLCanvasElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><dl class="element"><dt><a href="#concept-element-categories" id="the-canvas-element:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="the-canvas-element:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="the-canvas-element:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#embedded-content-category" id="the-canvas-element:embedded-content-category">Embedded content</a>.</dd><dd><a href="#palpable-content-2" id="the-canvas-element:palpable-content-2">Palpable content</a>.</dd><dt><a href="#concept-element-contexts" id="the-canvas-element:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#embedded-content-category" id="the-canvas-element:embedded-content-category-2">embedded content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="the-canvas-element:concept-element-content-model">Content model</a>:</dt><dd><a href="#transparent" id="the-canvas-element:transparent">Transparent</a>, but with no <a href="#interactive-content-2" id="the-canvas-element:interactive-content-2">interactive content</a> descendants except
   for <code id="the-canvas-element:the-a-element"><a href="#the-a-element">a</a></code> elements, <code id="the-canvas-element:the-img-element"><a href="#the-img-element">img</a></code> elements with
   <code id="the-canvas-element:attr-hyperlink-usemap"><a href="#attr-hyperlink-usemap">usemap</a></code> attributes, <code id="the-canvas-element:the-button-element"><a href="#the-button-element">button</a></code> elements,
   <code id="the-canvas-element:the-input-element"><a href="#the-input-element">input</a></code> elements whose <code id="the-canvas-element:attr-input-type"><a href="#attr-input-type">type</a></code> attribute are in
   the <a href="#checkbox-state-(type=checkbox)" id="the-canvas-element:checkbox-state-(type=checkbox)">Checkbox</a> or <a href="#radio-button-state-(type=radio)" id="the-canvas-element:radio-button-state-(type=radio)">Radio Button</a> states, <code id="the-canvas-element:the-input-element-2"><a href="#the-input-element">input</a></code> elements that are
   <a href="#concept-button" id="the-canvas-element:concept-button">buttons</a>, and <code id="the-canvas-element:the-select-element"><a href="#the-select-element">select</a></code> elements with a <code id="the-canvas-element:attr-select-multiple"><a href="#attr-select-multiple">multiple</a></code> attribute or a <a href="#concept-select-size" id="the-canvas-element:concept-select-size">display size</a> greater than 1.</dd><dt><a href="#concept-element-tag-omission" id="the-canvas-element:concept-element-tag-omission">Tag omission in text/html</a>:</dt><dd>Neither tag is omissible.</dd><dt><a href="#concept-element-attributes" id="the-canvas-element:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="the-canvas-element:global-attributes">Global attributes</a></dd><dd><code id="the-canvas-element:attr-canvas-width"><a href="#attr-canvas-width">width</a></code> —  Horizontal dimension
     </dd><dd><code id="the-canvas-element:attr-canvas-height"><a href="#attr-canvas-height">height</a></code> —  Vertical dimension
     </dd><dt><a href="#concept-element-accessibility-considerations" id="the-canvas-element:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd><a href="https://w3c.github.io/html-aria/#el-canvas">For authors</a>.</dd><dd><a href="https://w3c.github.io/html-aam/#el-canvas">For implementers</a>.</dd><dt><a href="#concept-element-dom" id="the-canvas-element:concept-element-dom">DOM interface</a>:</dt><dd>
    <pre><code class="idl"><c- b="">typedef</c-> (<a href="#canvasrenderingcontext2d" id="the-canvas-element:canvasrenderingcontext2d"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">or</c-> <a href="#imagebitmaprenderingcontext" id="the-canvas-element:imagebitmaprenderingcontext"><c- n="">ImageBitmapRenderingContext</c-></a> <c- b="">or</c-> <a id="the-canvas-element:webglrenderingcontext" href="https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContext" data-x-internal="webglrenderingcontext"><c- n="">WebGLRenderingContext</c-></a> <c- b="">or</c-> <a id="the-canvas-element:webgl2renderingcontext" href="https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext" data-x-internal="webgl2renderingcontext"><c- n="">WebGL2RenderingContext</c-></a> <c- b="">or</c-> <a id="the-canvas-element:gpucanvascontext" href="https://gpuweb.github.io/gpuweb/#canvas-context" data-x-internal="gpucanvascontext"><c- n="">GPUCanvasContext</c-></a>) <dfn id="renderingcontext" data-dfn-type="typedef"><c- g="">RenderingContext</c-></dfn>;

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlcanvaselement" data-dfn-type="interface"><c- g="">HTMLCanvasElement</c-></dfn> : <a href="#htmlelement" id="the-canvas-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-canvas-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-canvas-element:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-canvas-width" id="the-canvas-element:dom-canvas-width"><c- g="">width</c-></a>;
  [<a href="#cereactions" id="the-canvas-element:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-canvas-height" id="the-canvas-element:dom-canvas-height"><c- g="">height</c-></a>;

  <a href="#renderingcontext" id="the-canvas-element:renderingcontext"><c- n="">RenderingContext</c-></a>? <a href="#dom-canvas-getcontext" id="the-canvas-element:dom-canvas-getcontext"><c- g="">getContext</c-></a>(<c- b="">DOMString</c-> <c- g="">contextId</c->, <c- b="">optional</c-> <c- b="">any</c-> <c- g="">options</c-> = <c- b="">null</c->);

  <c- b="">USVString</c-> <a href="#dom-canvas-todataurl" id="the-canvas-element:dom-canvas-todataurl"><c- g="">toDataURL</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">type</c-> = "image/png", <c- b="">optional</c-> <c- b="">any</c-> <c- g="">quality</c->);
  <c- b="">undefined</c-> <a href="#dom-canvas-toblob" id="the-canvas-element:dom-canvas-toblob"><c- g="">toBlob</c-></a>(<a href="#blobcallback" id="the-canvas-element:blobcallback"><c- n="">BlobCallback</c-></a> <c- g="">_callback</c->, <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">type</c-> = "image/png", <c- b="">optional</c-> <c- b="">any</c-> <c- g="">quality</c->);
  <a href="#offscreencanvas" id="the-canvas-element:offscreencanvas"><c- n="">OffscreenCanvas</c-></a> <a href="#dom-canvas-transfercontroltooffscreen" id="the-canvas-element:dom-canvas-transfercontroltooffscreen"><c- g="">transferControlToOffscreen</c-></a>();
};

<c- b="">callback</c-> <dfn id="blobcallback" data-dfn-type="callback"><c- g="">BlobCallback</c-></dfn> = <c- b="">undefined</c-> (<a id="the-canvas-element:blob" href="https://w3c.github.io/FileAPI/#dfn-Blob" data-x-internal="blob"><c- n="">Blob</c-></a>? <c- g="">blob</c->);</code></pre>
   </dd></dl>

  <p>The <code id="the-canvas-element:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element provides scripts with a resolution-dependent bitmap canvas,
  which can be used for rendering graphs, game graphics, art, or other visual images on the fly.</p>

  <p>Authors should not use the <code id="the-canvas-element:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> element in a document when a more suitable
  element is available. For example, it is inappropriate to use a <code id="the-canvas-element:the-canvas-element-3"><a href="#the-canvas-element">canvas</a></code> element to
  render a page heading: if the desired presentation of the heading is graphically intense, it
  should be marked up using appropriate elements (typically <code id="the-canvas-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>) and then styled using
  CSS and supporting technologies such as <a href="https://dom.spec.whatwg.org/#concept-shadow-tree" id="the-canvas-element:shadow-tree" data-x-internal="shadow-tree">shadow trees</a>.</p>

  <p>When authors use the <code id="the-canvas-element:the-canvas-element-4"><a href="#the-canvas-element">canvas</a></code> element, they must also provide content that, when
  presented to the user, conveys essentially the same function or purpose as the
  <code id="the-canvas-element:the-canvas-element-5"><a href="#the-canvas-element">canvas</a></code>'s bitmap. This content may be placed as content of the <code id="the-canvas-element:the-canvas-element-6"><a href="#the-canvas-element">canvas</a></code>
  element. The contents of the <code id="the-canvas-element:the-canvas-element-7"><a href="#the-canvas-element">canvas</a></code> element, if any, are the element's <a href="#fallback-content" id="the-canvas-element:fallback-content">fallback
  content</a>.</p>

  <hr>

  <p>In interactive visual media, if <a href="#concept-n-script" id="the-canvas-element:concept-n-script">scripting is enabled</a> for
  the <code id="the-canvas-element:the-canvas-element-8"><a href="#the-canvas-element">canvas</a></code> element, and if support for <code id="the-canvas-element:the-canvas-element-9"><a href="#the-canvas-element">canvas</a></code> elements has been enabled,
  then the <code id="the-canvas-element:the-canvas-element-10"><a href="#the-canvas-element">canvas</a></code> element <a href="#represents" id="the-canvas-element:represents">represents</a> <a href="#embedded-content-category" id="the-canvas-element:embedded-content-category-3">embedded content</a>
  consisting of a dynamically created image, the element's bitmap.</p>

  <p>In non-interactive, static, visual media, if the <code id="the-canvas-element:the-canvas-element-11"><a href="#the-canvas-element">canvas</a></code> element has been
  previously associated with a rendering context (e.g. if the page was viewed in an interactive
  visual medium and is now being printed, or if some script that ran during the page layout process
  painted on the element), then the <code id="the-canvas-element:the-canvas-element-12"><a href="#the-canvas-element">canvas</a></code> element <a href="#represents" id="the-canvas-element:represents-2">represents</a>
  <a href="#embedded-content-category" id="the-canvas-element:embedded-content-category-4">embedded content</a> with the element's current bitmap and size. Otherwise, the element
  represents its <a href="#fallback-content" id="the-canvas-element:fallback-content-2">fallback content</a> instead.</p>

  <p>In non-visual media, and in visual media if <a href="#concept-n-noscript" id="the-canvas-element:concept-n-noscript">scripting is
  disabled</a> for the <code id="the-canvas-element:the-canvas-element-13"><a href="#the-canvas-element">canvas</a></code> element or if support for <code id="the-canvas-element:the-canvas-element-14"><a href="#the-canvas-element">canvas</a></code> elements
  has been disabled, the <code id="the-canvas-element:the-canvas-element-15"><a href="#the-canvas-element">canvas</a></code> element <a href="#represents" id="the-canvas-element:represents-3">represents</a> its <a href="#fallback-content" id="the-canvas-element:fallback-content-3">fallback
  content</a> instead.</p>

  
  <p>When a <code id="the-canvas-element:the-canvas-element-16"><a href="#the-canvas-element">canvas</a></code> element <a href="#represents" id="the-canvas-element:represents-4">represents</a> <a href="#embedded-content-category" id="the-canvas-element:embedded-content-category-5">embedded content</a>, the
  user can still focus descendants of the <code id="the-canvas-element:the-canvas-element-17"><a href="#the-canvas-element">canvas</a></code> element (in the <a href="#fallback-content" id="the-canvas-element:fallback-content-4">fallback
  content</a>). When an element is <a href="#focused" id="the-canvas-element:focused">focused</a>, it is the target of keyboard interaction
  events (even though the element itself is not visible). This allows authors to make an interactive
  canvas keyboard-accessible: authors should have a one-to-one mapping of interactive regions to <i id="the-canvas-element:focusable-area"><a href="#focusable-area">focusable areas</a></i> in the <a href="#fallback-content" id="the-canvas-element:fallback-content-5">fallback content</a>. (Focus has no
  effect on mouse interaction events.) <a href="#refsUIEVENTS">[UIEVENTS]</a></p> 

  <div data-algorithm="">
  <p>An element whose nearest <code id="the-canvas-element:the-canvas-element-18"><a href="#the-canvas-element">canvas</a></code> element ancestor is <a href="#being-rendered" id="the-canvas-element:being-rendered">being rendered</a>
  and <a href="#represents" id="the-canvas-element:represents-5">represents</a> <a href="#embedded-content-category" id="the-canvas-element:embedded-content-category-6">embedded content</a> is an element that is <dfn id="being-used-as-relevant-canvas-fallback-content">being used as
  relevant canvas fallback content</dfn>.</p>
  </div>

  <hr>

  <p>The <code id="the-canvas-element:the-canvas-element-19"><a href="#the-canvas-element">canvas</a></code> element has two attributes to control the size of the element's bitmap:
  <dfn data-dfn-for="canvas" id="attr-canvas-width" data-dfn-type="element-attr"><code>width</code></dfn> and <dfn data-dfn-for="canvas" id="attr-canvas-height" data-dfn-type="element-attr"><code>height</code></dfn>. These attributes,
  when specified, must have values that are <a href="#valid-non-negative-integer" id="the-canvas-element:valid-non-negative-integer">valid
  non-negative integers</a>.  The <a href="#rules-for-parsing-non-negative-integers" id="the-canvas-element:rules-for-parsing-non-negative-integers">rules for parsing non-negative
  integers</a> must be used to <dfn id="obtain-numeric-values">obtain their numeric
  values</dfn>. If an attribute is missing, or if parsing its value returns an error, then the
  default value must be used instead. The <code id="the-canvas-element:attr-canvas-width-2"><a href="#attr-canvas-width">width</a></code>
  attribute defaults to 300, and the <code id="the-canvas-element:attr-canvas-height-2"><a href="#attr-canvas-height">height</a></code> attribute
  defaults to 150.</p>

  <div data-algorithm="">
  <p>When setting the value of the <code id="the-canvas-element:attr-canvas-width-3"><a href="#attr-canvas-width">width</a></code> or <code id="the-canvas-element:attr-canvas-height-3"><a href="#attr-canvas-height">height</a></code> attribute, if the <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode">context mode</a> of the <code id="the-canvas-element:the-canvas-element-20"><a href="#the-canvas-element">canvas</a></code>
  element is set to <a href="#concept-canvas-placeholder" id="the-canvas-element:concept-canvas-placeholder">placeholder</a>, the
  user agent must throw an <a id="the-canvas-element:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-canvas-element:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>
  and leave the attribute's value unchanged.</p>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-canvas-element:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> of the <code id="the-canvas-element:the-canvas-element-21"><a href="#the-canvas-element">canvas</a></code> element when it
  <a href="#represents" id="the-canvas-element:represents-6">represents</a> <a href="#embedded-content-category" id="the-canvas-element:embedded-content-category-7">embedded content</a> are equal to the dimensions of the
  element's bitmap.</p>
  </div>

  <p>The user agent must use a square pixel density consisting of one pixel of image data per
  coordinate space unit for the bitmaps of a <code id="the-canvas-element:the-canvas-element-22"><a href="#the-canvas-element">canvas</a></code> and its rendering contexts.</p>

  <p class="note">A <code id="the-canvas-element:the-canvas-element-23"><a href="#the-canvas-element">canvas</a></code> element can be sized arbitrarily by a style sheet, its
  bitmap is then subject to the <a id="the-canvas-element:'object-fit'" href="https://drafts.csswg.org/css-images/#the-object-fit" data-x-internal="'object-fit'">'object-fit'</a> CSS property.</p>

  

  <hr>

  <p>The bitmaps of <code id="the-canvas-element:the-canvas-element-24"><a href="#the-canvas-element">canvas</a></code> elements, the bitmaps of <code id="the-canvas-element:imagebitmap"><a href="#imagebitmap">ImageBitmap</a></code> objects,
  as well as some of the bitmaps of rendering contexts, such as those described in the sections on
  the <code id="the-canvas-element:canvasrenderingcontext2d-2"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code>, <code id="the-canvas-element:offscreencanvasrenderingcontext2d"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code>, and
  <code id="the-canvas-element:imagebitmaprenderingcontext-2"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> objects below, have an <dfn id="concept-canvas-origin-clean">origin-clean</dfn> flag, which can be set to true or false.
  Initially, when the <code id="the-canvas-element:the-canvas-element-25"><a href="#the-canvas-element">canvas</a></code> element or <code id="the-canvas-element:imagebitmap-2"><a href="#imagebitmap">ImageBitmap</a></code> object is created, its
  bitmap's <a href="#concept-canvas-origin-clean" id="the-canvas-element:concept-canvas-origin-clean">origin-clean</a> flag must be set to
  true.</p>

  <p>A <code id="the-canvas-element:the-canvas-element-26"><a href="#the-canvas-element">canvas</a></code> element can have a rendering context bound to it. Initially, it does not
  have a bound rendering context. To keep track of whether it has a rendering context or not, and
  what kind of rendering context it is, a <code id="the-canvas-element:the-canvas-element-27"><a href="#the-canvas-element">canvas</a></code> also has a <dfn id="concept-canvas-context-mode">canvas context mode</dfn>, which is initially <dfn id="concept-canvas-none">none</dfn> but can be changed to either <dfn id="concept-canvas-placeholder">placeholder</dfn>, <dfn id="concept-canvas-2d">2d</dfn>, <dfn id="concept-canvas-bitmaprenderer">bitmaprenderer</dfn>, <dfn id="concept-canvas-webgl">webgl</dfn>, <dfn id="concept-canvas-webgl2">webgl2</dfn>, or <dfn id="concept-canvas-webgpu">webgpu</dfn> by algorithms defined in this specification.</p>

  <p>When its <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-2">canvas context mode</a> is <a href="#concept-canvas-none" id="the-canvas-element:concept-canvas-none">none</a>, a <code id="the-canvas-element:the-canvas-element-28"><a href="#the-canvas-element">canvas</a></code> element has no rendering context,
  and its bitmap must be <a id="the-canvas-element:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> with a <a id="the-canvas-element:natural-width" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> equal
  to <a href="#obtain-numeric-values" id="the-canvas-element:obtain-numeric-values">the numeric value</a> of the element's <code id="the-canvas-element:attr-canvas-width-4"><a href="#attr-canvas-width">width</a></code> attribute and a <a id="the-canvas-element:natural-height" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a> equal to
  <a href="#obtain-numeric-values" id="the-canvas-element:obtain-numeric-values-2">the numeric value</a> of the element's <code id="the-canvas-element:attr-canvas-height-4"><a href="#attr-canvas-height">height</a></code> attribute, those values being interpreted in <a href="https://drafts.csswg.org/css-values/#px" id="the-canvas-element:'px'" data-x-internal="'px'">CSS pixels</a>, and being updated as the attributes are set, changed, or
  removed.</p>

  <p>When its <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-3">canvas context mode</a> is <a href="#concept-canvas-placeholder" id="the-canvas-element:concept-canvas-placeholder-2">placeholder</a>, a <code id="the-canvas-element:the-canvas-element-29"><a href="#the-canvas-element">canvas</a></code> element has no
  rendering context. It serves as a placeholder for an <code id="the-canvas-element:offscreencanvas-2"><a href="#offscreencanvas">OffscreenCanvas</a></code> object, and
  the content of the <code id="the-canvas-element:the-canvas-element-30"><a href="#the-canvas-element">canvas</a></code> element is updated by the <code id="the-canvas-element:offscreencanvas-3"><a href="#offscreencanvas">OffscreenCanvas</a></code>
  object's rendering context.</p>

  <p>When a <code id="the-canvas-element:the-canvas-element-31"><a href="#the-canvas-element">canvas</a></code> element represents <a href="#embedded-content-category" id="the-canvas-element:embedded-content-category-8">embedded content</a>, it provides a
  <a id="the-canvas-element:paint-source" href="https://drafts.csswg.org/css-images-4/#paint-source" data-x-internal="paint-source">paint source</a> whose width is the element's <a id="the-canvas-element:natural-width-2" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a>, whose height
  is the element's <a id="the-canvas-element:natural-height-2" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a>, and whose appearance is the element's bitmap.</p>

  <div data-algorithm="">
  <p>Whenever the <code id="the-canvas-element:attr-canvas-width-5"><a href="#attr-canvas-width">width</a></code> and <code id="the-canvas-element:attr-canvas-height-5"><a href="#attr-canvas-height">height</a></code> content attributes are set, removed, changed, or
  redundantly set to the value they already have, then the user agent must perform the action
  from the row of the following table that corresponds to the <code id="the-canvas-element:the-canvas-element-32"><a href="#the-canvas-element">canvas</a></code> element's <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-4">context mode</a>.</p>

  <table><thead><tr><th>
      <p><a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-5">Context Mode</a></p>
     </th><th>
      <p>Action</p>

   </th></tr></thead><tbody><tr><th>
      <p><a href="#concept-canvas-2d" id="the-canvas-element:concept-canvas-2d">2d</a></p>
     </th><td>
      <p>Follow the steps to <a href="#concept-canvas-set-bitmap-dimensions" id="the-canvas-element:concept-canvas-set-bitmap-dimensions">set bitmap
      dimensions</a> to <a href="#obtain-numeric-values" id="the-canvas-element:obtain-numeric-values-3">the numeric values</a>
      of the <code id="the-canvas-element:attr-canvas-width-6"><a href="#attr-canvas-width">width</a></code> and <code id="the-canvas-element:attr-canvas-height-6"><a href="#attr-canvas-height">height</a></code> content attributes.</p>

    </td></tr><tr><th>
      <p><a href="#concept-canvas-webgl" id="the-canvas-element:concept-canvas-webgl">webgl</a> or <a href="#concept-canvas-webgl2" id="the-canvas-element:concept-canvas-webgl2">webgl2</a></p>
     </th><td>
      <p>Follow the behavior defined in the WebGL specifications. <a href="#refsWEBGL">[WEBGL]</a></p>

    </td></tr><tr><th>
      <p><a href="#concept-canvas-webgpu" id="the-canvas-element:concept-canvas-webgpu">webgpu</a></p>
     </th><td>
      <p>Follow the behavior defined in <cite>WebGPU</cite>. <a href="#refsWEBGPU">[WEBGPU]</a></p>

    </td></tr><tr><th>
      <p><a href="#concept-canvas-bitmaprenderer" id="the-canvas-element:concept-canvas-bitmaprenderer">bitmaprenderer</a></p>
     </th><td>
      <p>If the context's <a href="#concept-imagebitmaprenderingcontext-bitmap-mode" id="the-canvas-element:concept-imagebitmaprenderingcontext-bitmap-mode">bitmap
      mode</a> is set to <a href="#concept-imagebitmaprenderingcontext-blank" id="the-canvas-element:concept-imagebitmaprenderingcontext-blank">blank</a>,
      run the steps to <a href="#set-an-imagebitmaprenderingcontext's-output-bitmap" id="the-canvas-element:set-an-imagebitmaprenderingcontext's-output-bitmap">set an <code>ImageBitmapRenderingContext</code>'s output bitmap</a>,
      passing the <code id="the-canvas-element:the-canvas-element-33"><a href="#the-canvas-element">canvas</a></code> element's rendering context.</p>

    </td></tr><tr><th>
      <p><a href="#concept-canvas-placeholder" id="the-canvas-element:concept-canvas-placeholder-3">placeholder</a></p>
     </th><td>
      <p>Do nothing.</p>

    </td></tr><tr><th>
      <p><a href="#concept-canvas-none" id="the-canvas-element:concept-canvas-none-2">none</a></p>
     </th><td>
      <p>Do nothing.</p>
  </td></tr></tbody></table>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/height" title="The HTMLCanvasElement.height property is a positive integer reflecting the height HTML attribute of the <canvas> element interpreted in CSS pixels. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 150 is used.">HTMLCanvasElement/height</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/width" title="The HTMLCanvasElement.width property is a positive integer reflecting the width HTML attribute of the <canvas> element interpreted in CSS pixels. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 300 is used.">HTMLCanvasElement/width</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLCanvasElement" id="dom-canvas-width" data-dfn-type="attribute"><code>width</code></dfn>
  and <dfn data-dfn-for="HTMLCanvasElement" id="dom-canvas-height" data-dfn-type="attribute"><code>height</code></dfn>
  IDL attributes must <a href="#reflect" id="the-canvas-element:reflect">reflect</a> the respective content attributes of the same name, with
  the same defaults.</p>
  </div>

  

  <hr>

  <dl class="domintro"><dt><code><var>context</var> = <var>canvas</var>.<a href="#dom-canvas-getcontext" id="dom-canvas-getcontext-dev">getContext</a>(<var>contextId</var> [, <var>options</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext" title="The HTMLCanvasElement.getContext() method returns a drawing context on the canvas, or null if the context identifier is not supported, or the canvas has already been set to a different context mode.">HTMLCanvasElement/getContext</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns an object that exposes an API for drawing on the canvas. <var>contextId</var>
    specifies the desired API: "<code id="the-canvas-element:canvas-context-2d"><a href="#canvas-context-2d">2d</a></code>", "<code id="the-canvas-element:canvas-context-bitmaprenderer"><a href="#canvas-context-bitmaprenderer">bitmaprenderer</a></code>", "<code id="the-canvas-element:canvas-context-webgl"><a href="#canvas-context-webgl">webgl</a></code>", "<code id="the-canvas-element:canvas-context-webgl2"><a href="#canvas-context-webgl2">webgl2</a></code>", or "<code id="the-canvas-element:canvas-context-webgpu"><a href="#canvas-context-webgpu">webgpu</a></code>". <var>options</var> is handled by that API.</p>

    <p>This specification defines the "<code id="the-canvas-element:canvas-context-2d-2"><a href="#canvas-context-2d">2d</a></code>" and "<code id="the-canvas-element:canvas-context-bitmaprenderer-2"><a href="#canvas-context-bitmaprenderer">bitmaprenderer</a></code>" contexts below. The WebGL
    specifications define the "<code id="the-canvas-element:canvas-context-webgl-2"><a href="#canvas-context-webgl">webgl</a></code>" and "<code id="the-canvas-element:canvas-context-webgl2-2"><a href="#canvas-context-webgl2">webgl2</a></code>" contexts. <cite>WebGPU</cite> defines the "<code id="the-canvas-element:canvas-context-webgpu-2"><a href="#canvas-context-webgpu">webgpu</a></code>" context. <a href="#refsWEBGL">[WEBGL]</a> <a href="#refsWEBGPU">[WEBGPU]</a></p>

    <p>Returns null if <var>contextId</var> is not supported, or if the canvas has already been
    initialized with another context type (e.g., trying to get a "<code id="the-canvas-element:canvas-context-2d-3"><a href="#canvas-context-2d">2d</a></code>" context after getting a "<code id="the-canvas-element:canvas-context-webgl-3"><a href="#canvas-context-webgl">webgl</a></code>" context).</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLCanvasElement" id="dom-canvas-getcontext" data-dfn-type="method"><code>getContext(<var>contextId</var>, <var>options</var>)</code></dfn>
  method of the <code id="the-canvas-element:the-canvas-element-34"><a href="#the-canvas-element">canvas</a></code> element, when invoked, must run these steps:

  </p><ol><li><p>If <var>options</var> is not an <a href="https://webidl.spec.whatwg.org/#idl-object" id="the-canvas-element:idl-object" data-x-internal="idl-object">object</a>, then set
   <var>options</var> to null.</p></li><li><p>Set <var>options</var> to the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="the-canvas-element:concept-idl-convert" data-x-internal="concept-idl-convert">converting</a> <var>options</var> to a JavaScript value.</p></li><li>
    <p>Run the steps in the cell of the following table whose column header matches this
    <code id="the-canvas-element:the-canvas-element-35"><a href="#the-canvas-element">canvas</a></code> element's <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-6">canvas context
    mode</a> and whose row header matches <var>contextId</var>:</p>

    <table><thead><tr><td>
       </td><th><a href="#concept-canvas-none" id="the-canvas-element:concept-canvas-none-3">none</a>
       </th><th><a href="#concept-canvas-2d" id="the-canvas-element:concept-canvas-2d-2">2d</a>
       </th><th><a href="#concept-canvas-bitmaprenderer" id="the-canvas-element:concept-canvas-bitmaprenderer-2">bitmaprenderer</a>
       </th><th><a href="#concept-canvas-webgl" id="the-canvas-element:concept-canvas-webgl-2">webgl</a> or <a href="#concept-canvas-webgl2" id="the-canvas-element:concept-canvas-webgl2-2">webgl2</a>
       </th><th><a href="#concept-canvas-webgpu" id="the-canvas-element:concept-canvas-webgpu-2">webgpu</a>
       </th><th><a href="#concept-canvas-placeholder" id="the-canvas-element:concept-canvas-placeholder-4">placeholder</a>
     </th></tr></thead><tbody><tr><th>"<dfn id="canvas-context-2d"><code>2d</code></dfn>"
       </th><td>
        <ol><li><p>Let <var>context</var> be the result of running the <a href="#2d-context-creation-algorithm" id="the-canvas-element:2d-context-creation-algorithm">2D context
         creation algorithm</a> given <a id="the-canvas-element:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and <var>options</var>.</p></li><li><p>Set <a id="the-canvas-element:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-7">context
         mode</a> to <a href="#concept-canvas-2d" id="the-canvas-element:concept-canvas-2d-3">2d</a>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
       </td><td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Throw an <a id="the-canvas-element:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-canvas-element:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
      </td></tr><tr><th>"<dfn id="canvas-context-bitmaprenderer"><code>bitmaprenderer</code></dfn>"
       </th><td>
        <ol><li><p>Let <var>context</var> be the result of running the
         <a href="#imagebitmaprenderingcontext-creation-algorithm" id="the-canvas-element:imagebitmaprenderingcontext-creation-algorithm"><code>ImageBitmapRenderingContext</code> creation algorithm</a> given
         <a id="the-canvas-element:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and <var>options</var>.</p></li><li><p>Set <a id="the-canvas-element:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-8">context
         mode</a> to <a href="#concept-canvas-bitmaprenderer" id="the-canvas-element:concept-canvas-bitmaprenderer-3">bitmaprenderer</a>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
       </td><td>
        Return null.
       </td><td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Throw an <a id="the-canvas-element:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-canvas-element:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
      </td></tr><tr><th>"<dfn id="canvas-context-webgl"><code>webgl</code></dfn>" or "<dfn id="canvas-context-webgl2"><code>webgl2</code></dfn>", if the user agent supports the WebGL
       feature in its current configuration
       </th><td>
        <ol><li><p>Let <var>context</var> be the result of following the instructions given in
         the WebGL specifications' <i>Context Creation</i> sections. <a href="#refsWEBGL">[WEBGL]</a></p></li><li><p>If <var>context</var> is null, then return null; otherwise set <a id="the-canvas-element:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
         <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-9">context mode</a> to <a href="#concept-canvas-webgl" id="the-canvas-element:concept-canvas-webgl-3">webgl</a> or <a href="#concept-canvas-webgl2" id="the-canvas-element:concept-canvas-webgl2-3">webgl2</a>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       </td><td>
        Return null.
       </td><td>
        Throw an <a id="the-canvas-element:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-canvas-element:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
      </td></tr><tr><th>"<dfn id="canvas-context-webgpu"><code>webgpu</code></dfn>", if the user
       agent supports the WebGPU feature in its current configuration
       </th><td>
        <ol><li><p>Let <var>context</var> be the result of following the instructions given
         in <cite>WebGPU</cite>'s <a href="https://gpuweb.github.io/gpuweb/#canvas-rendering">Canvas Rendering</a>
         section. <a href="#refsWEBGPU">[WEBGPU]</a></p></li><li><p>If <var>context</var> is null, then return null; otherwise set
         <a id="the-canvas-element:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-10">context mode</a> to
         <a href="#concept-canvas-webgpu" id="the-canvas-element:concept-canvas-webgpu-3">webgpu</a>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       </td><td>
        Throw an <a id="the-canvas-element:invalidstateerror-5" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-canvas-element:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
      </td></tr><tr><th>An unsupported value*
       </th><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Throw an <a id="the-canvas-element:invalidstateerror-6" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-canvas-element:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
    </td></tr></tbody></table>

    <p class="tablenote"><small>* For example, the "<code id="the-canvas-element:canvas-context-webgl-4"><a href="#canvas-context-webgl">webgl</a></code>" or "<code id="the-canvas-element:canvas-context-webgl2-3"><a href="#canvas-context-webgl2">webgl2</a></code>" value in the case of a user agent having exhausted
    the graphics hardware's abilities and having no software fallback implementation.</small></p>
   </li></ol>
  </div>

  <hr>

  

  <dl class="domintro"><dt><code><var>url</var> = <var>canvas</var>.<a href="#dom-canvas-todataurl" id="dom-canvas-todataurl-dev">toDataURL</a>([ <var>type</var> [, <var>quality</var> ] ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL" title="The HTMLCanvasElement.toDataURL() method returns a data URL containing a representation of the image in the format specified by the type parameter.">HTMLCanvasElement/toDataURL</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <a href="https://www.rfc-editor.org/rfc/rfc2397#section-2" id="the-canvas-element:data-protocol" data-x-internal="data-protocol"><code>data:</code> URL</a> for the image in the
    canvas.</p>

    <p>The first argument, if provided, controls the type of the image to be returned (e.g. PNG or
    JPEG). The default is "<code id="the-canvas-element:image/png"><a href="#image/png">image/png</a></code>"; that type is also used if the given type isn't
    supported. The second argument applies if the type is an image format that supports variable
    quality (such as "<code id="the-canvas-element:image/jpeg"><a href="#image/jpeg">image/jpeg</a></code>"), and is a number in the range 0.0 to 1.0 inclusive
    indicating the desired quality level for the resulting image.</p>

    <p>When trying to use types other than "<code id="the-canvas-element:image/png-2"><a href="#image/png">image/png</a></code>", authors can check if the image
    was really returned in the requested format by checking to see if the returned string starts
    with one of the exact strings "<code>data:image/png,</code>" or "<code>data:image/png;</code>". If it does, the image is PNG, and thus the requested type was
    not supported. (The one exception to this is if the canvas has either no height or no width, in
    which case the result might simply be "<code>data:,</code>".)</p>
   </dd><dt><code><var>canvas</var>.<a href="#dom-canvas-toblob" id="dom-canvas-toblob-dev">toBlob</a>(<var>callback</var> [, <var>type</var> [, quality ] ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob" title="The HTMLCanvasElement.toBlob() method creates a Blob object representing the image contained in the canvas. This file may be cached on the disk or stored in memory at the discretion of the user agent.">HTMLCanvasElement/toBlob</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>18+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>50+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Requires a prefix or alternative name.">🔰 10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Creates a <code id="the-canvas-element:blob-2"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> object representing a file containing the image in the canvas,
    and invokes a callback with a handle to that object.</p>

    <p>The second argument, if provided, controls the type of the image to be returned (e.g. PNG or
    JPEG). The default is "<code id="the-canvas-element:image/png-3"><a href="#image/png">image/png</a></code>"; that type is also used if the given type isn't
    supported. The third argument applies if the type is an image format that supports variable
    quality (such as "<code id="the-canvas-element:image/jpeg-2"><a href="#image/jpeg">image/jpeg</a></code>"), and is a number in the range 0.0 to 1.0 inclusive
    indicating the desired quality level for the resulting image.</p>
   </dd><dt><code><var>canvas</var>.<a href="#dom-canvas-transfercontroltooffscreen" id="dom-canvas-transfercontroltooffscreen-dev">transferControlToOffscreen</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen" title="The HTMLCanvasElement.transferControlToOffscreen() method transfers control to an OffscreenCanvas object, either on the main thread or on a worker.">HTMLCanvasElement/transferControlToOffscreen</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>105+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns a newly created <code id="the-canvas-element:offscreencanvas-4"><a href="#offscreencanvas">OffscreenCanvas</a></code> object that uses the
    <code id="the-canvas-element:the-canvas-element-36"><a href="#the-canvas-element">canvas</a></code> element as a placeholder. Once the <code id="the-canvas-element:the-canvas-element-37"><a href="#the-canvas-element">canvas</a></code> element has become a
    placeholder for an <code id="the-canvas-element:offscreencanvas-5"><a href="#offscreencanvas">OffscreenCanvas</a></code> object, its natural size can no longer be
    changed, and it cannot have a rendering context. The content of the placeholder canvas is
    updated on the <code id="the-canvas-element:offscreencanvas-6"><a href="#offscreencanvas">OffscreenCanvas</a></code>'s <a href="#relevant-agent" id="the-canvas-element:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="the-canvas-element:concept-agent-event-loop">event loop</a>'s <a href="#update-the-rendering" id="the-canvas-element:update-the-rendering">update the rendering</a>
    steps.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLCanvasElement" id="dom-canvas-todataurl" data-dfn-type="method"><code>toDataURL(<var>type</var>, <var>quality</var>)</code></dfn> method,
  when invoked, must run these steps:</p>

  <ol><li><p>If this <code id="the-canvas-element:the-canvas-element-38"><a href="#the-canvas-element">canvas</a></code> element's bitmap's <a href="#concept-canvas-origin-clean" id="the-canvas-element:concept-canvas-origin-clean-2">origin-clean</a> flag is set to false, then throw a
   <a id="the-canvas-element:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-canvas-element:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

   </li><li><p>If this <code id="the-canvas-element:the-canvas-element-39"><a href="#the-canvas-element">canvas</a></code> element's bitmap has no pixels (i.e. either its horizontal
   dimension or its vertical dimension is zero), then return the string "<code>data:,</code>". (This is the shortest <a href="https://www.rfc-editor.org/rfc/rfc2397#section-2" id="the-canvas-element:data-protocol-2" data-x-internal="data-protocol"><code>data:</code> URL</a>; it represents the empty string in a <code>text/plain</code> resource.)</p></li><li><p>Let <var>file</var> be <a href="#a-serialisation-of-the-bitmap-as-a-file" id="the-canvas-element:a-serialisation-of-the-bitmap-as-a-file">a
   serialization of this <code>canvas</code> element's bitmap as a file</a>, passing
   <var>type</var> and <var>quality</var> if given.</p></li><li><p>If <var>file</var> is null, then return "<code>data:,</code>".</p></li><li><p>Return a <a href="https://www.rfc-editor.org/rfc/rfc2397#section-2" id="the-canvas-element:data-protocol-3" data-x-internal="data-protocol"><code>data:</code> URL</a> representing
   <var>file</var>. <a href="#refsRFC2397">[RFC2397]</a></p>

   
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLCanvasElement" id="dom-canvas-toblob" data-dfn-type="method"><code>toBlob(<var>callback</var>, <var>type</var>,
  <var>quality</var>)</code></dfn> method, when invoked, must run these steps:</p>

  <ol><li><p>If this <code id="the-canvas-element:the-canvas-element-40"><a href="#the-canvas-element">canvas</a></code> element's bitmap's <a href="#concept-canvas-origin-clean" id="the-canvas-element:concept-canvas-origin-clean-3">origin-clean</a> flag is set to false, then throw a
   <a id="the-canvas-element:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-canvas-element:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>result</var> be null.</p></li><li><p>If this <code id="the-canvas-element:the-canvas-element-41"><a href="#the-canvas-element">canvas</a></code> element's bitmap has pixels (i.e., neither its horizontal
   dimension nor its vertical dimension is zero), then set <var>result</var> to a copy of this
   <code id="the-canvas-element:the-canvas-element-42"><a href="#the-canvas-element">canvas</a></code> element's bitmap.

   </p></li><li>
    <p>Run these steps <a href="#in-parallel" id="the-canvas-element:in-parallel">in parallel</a>:</p>

    <ol><li><p>If <var>result</var> is non-null, then set <var>result</var> to <a href="#a-serialisation-of-the-bitmap-as-a-file" id="the-canvas-element:a-serialisation-of-the-bitmap-as-a-file-2">a serialization of <var>result</var> as a file</a>
     with <var>type</var> and <var>quality</var> if given.</p></li><li>
      <p><a href="#queue-an-element-task" id="the-canvas-element:queue-an-element-task">Queue an element task</a> on the
      <dfn id="canvas-blob-serialisation-task-source">canvas blob serialization task
      source</dfn> given the <code id="the-canvas-element:the-canvas-element-43"><a href="#the-canvas-element">canvas</a></code> element to run these steps:</p>

      <ol><li><p>If <var>result</var> is non-null, then set <var>result</var> to a new
       <code id="the-canvas-element:blob-3"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> object, created in the <a href="#concept-relevant-realm" id="the-canvas-element:concept-relevant-realm">relevant
       realm</a> of this <code id="the-canvas-element:the-canvas-element-44"><a href="#the-canvas-element">canvas</a></code> element, representing <var>result</var>.
       <a href="#refsFILEAPI">[FILEAPI]</a></p></li><li><p><a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="the-canvas-element:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">Invoke</a> <var>callback</var> with
       « <var>result</var> » and "<code>report</code>".</p></li></ol>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLCanvasElement" id="dom-canvas-transfercontroltooffscreen" data-dfn-type="method"><code>transferControlToOffscreen()</code></dfn> method,
  when invoked, must run these steps:</p>

  <ol><li><p>If this <code id="the-canvas-element:the-canvas-element-45"><a href="#the-canvas-element">canvas</a></code> element's <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-11">context
   mode</a> is not set to <a href="#concept-canvas-none" id="the-canvas-element:concept-canvas-none-4">none</a>, throw an
   <a id="the-canvas-element:invalidstateerror-7" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-canvas-element:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>offscreenCanvas</var> be a new <code id="the-canvas-element:offscreencanvas-7"><a href="#offscreencanvas">OffscreenCanvas</a></code> object with its
   width and height equal to the values of the <code id="the-canvas-element:attr-canvas-width-7"><a href="#attr-canvas-width">width</a></code>
   and <code id="the-canvas-element:attr-canvas-height-7"><a href="#attr-canvas-height">height</a></code> content attributes of this
   <code id="the-canvas-element:the-canvas-element-46"><a href="#the-canvas-element">canvas</a></code> element.</p></li><li><p>Set the <var>offscreenCanvas</var>'s <a href="#offscreencanvas-placeholder" id="the-canvas-element:offscreencanvas-placeholder">placeholder <code>canvas</code> element</a>
   to a weak reference to this <code id="the-canvas-element:the-canvas-element-47"><a href="#the-canvas-element">canvas</a></code> element.</p></li><li><p>Set this <code id="the-canvas-element:the-canvas-element-48"><a href="#the-canvas-element">canvas</a></code> element's <a href="#concept-canvas-context-mode" id="the-canvas-element:concept-canvas-context-mode-12">context
   mode</a> to <a href="#concept-canvas-placeholder" id="the-canvas-element:concept-canvas-placeholder-5">placeholder</a>.</p></li><li><p>Set the <var>offscreenCanvas</var>'s <a href="#offscreencanvas-inherited-lang" id="the-canvas-element:offscreencanvas-inherited-lang">inherited language</a> to the
   <a href="#language" id="the-canvas-element:language">language</a> of this <code id="the-canvas-element:the-canvas-element-49"><a href="#the-canvas-element">canvas</a></code> element.</p></li><li><p>Set the <var>offscreenCanvas</var>'s <a href="#offscreencanvas-inherited-direction" id="the-canvas-element:offscreencanvas-inherited-direction">inherited direction</a> to the <a href="#the-directionality" id="the-canvas-element:the-directionality">directionality</a> of this <code id="the-canvas-element:the-canvas-element-50"><a href="#the-canvas-element">canvas</a></code> element.</p></li><li><p>Return <var>offscreenCanvas</var>.</p></li></ol>
  </div>

  


  <h5 id="2dcontext"><span class="secno">4.12.5.1</span> The 2D rendering context<a href="#2dcontext" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D" title="The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a <canvas> element. It is used for drawing shapes, text, images, and other objects.">CanvasRenderingContext2D</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource" title="The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a <canvas> element. It is used for drawing shapes, text, images, and other objects.">CanvasImageSource</a></p></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient" title="The CanvasGradient interface represents an opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient(), CanvasRenderingContext2D.createConicGradient() or CanvasRenderingContext2D.createRadialGradient().">CanvasGradient</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern" title="The CanvasPattern interface represents an opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method.">CanvasPattern</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics" title="The TextMetrics interface represents the dimensions of a piece of text in the canvas; a TextMetrics instance can be retrieved using the CanvasRenderingContext2D.measureText() method.">TextMetrics</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>31+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><pre><code class="idl"><c- b="">typedef</c-> (<a href="#htmlimageelement" id="2dcontext:htmlimageelement"><c- n="">HTMLImageElement</c-></a> <c- b="">or</c->
         <a id="2dcontext:svgimageelement" href="https://svgwg.org/svg2-draft/embedded.html#InterfaceSVGImageElement" data-x-internal="svgimageelement"><c- n="">SVGImageElement</c-></a>) <dfn id="htmlorsvgimageelement" data-dfn-type="typedef"><c- g="">HTMLOrSVGImageElement</c-></dfn>;

<c- b="">typedef</c-> (<a href="#htmlorsvgimageelement" id="2dcontext:htmlorsvgimageelement"><c- n="">HTMLOrSVGImageElement</c-></a> <c- b="">or</c->
         <a href="#htmlvideoelement" id="2dcontext:htmlvideoelement"><c- n="">HTMLVideoElement</c-></a> <c- b="">or</c->
         <a href="#htmlcanvaselement" id="2dcontext:htmlcanvaselement"><c- n="">HTMLCanvasElement</c-></a> <c- b="">or</c->
         <a href="#imagebitmap" id="2dcontext:imagebitmap"><c- n="">ImageBitmap</c-></a> <c- b="">or</c->
         <a href="#offscreencanvas" id="2dcontext:offscreencanvas"><c- n="">OffscreenCanvas</c-></a> <c- b="">or</c->
         <a id="2dcontext:videoframe" href="https://w3c.github.io/webcodecs/#videoframe-interface" data-x-internal="videoframe"><c- n="">VideoFrame</c-></a>) <dfn id="canvasimagesource" data-dfn-type="typedef"><c- g="">CanvasImageSource</c-></dfn>;

<c- b="">enum</c-> <dfn id="canvascolortype" data-dfn-type="enum"><c- g="">CanvasColorType</c-></dfn> { <c- s="">"</c-><a href="#dom-canvascolortype-unorm8" id="2dcontext:dom-canvascolortype-unorm8"><c- s="">unorm8</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-canvascolortype-float16" id="2dcontext:dom-canvascolortype-float16"><c- s="">float16</c-></a><c- s="">"</c-> };

<c- b="">enum</c-> <dfn id="canvasfillrule" data-dfn-type="enum"><c- g="">CanvasFillRule</c-></dfn> { <c- s="">"</c-><a href="#dom-context-2d-fillrule-nonzero" id="2dcontext:dom-context-2d-fillrule-nonzero"><c- s="">nonzero</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fillrule-evenodd" id="2dcontext:dom-context-2d-fillrule-evenodd"><c- s="">evenodd</c-></a><c- s="">"</c-> };

<c- b="">dictionary</c-> <dfn id="canvasrenderingcontext2dsettings" data-dfn-type="dictionary"><c- g="">CanvasRenderingContext2DSettings</c-></dfn> {
  <c- b="">boolean</c-> <a href="#dom-canvasrenderingcontext2dsettings-alpha" id="2dcontext:dom-canvasrenderingcontext2dsettings-alpha"><c- g="">alpha</c-></a> = <c- b="">true</c->;
  <c- b="">boolean</c-> <a href="#dom-canvasrenderingcontext2dsettings-desynchronized" id="2dcontext:dom-canvasrenderingcontext2dsettings-desynchronized"><c- g="">desynchronized</c-></a> = <c- b="">false</c->;
  <a href="#predefinedcolorspace" id="2dcontext:predefinedcolorspace"><c- n="">PredefinedColorSpace</c-></a> <a href="#dom-canvasrenderingcontext2dsettings-colorspace" id="2dcontext:dom-canvasrenderingcontext2dsettings-colorspace"><c- g="">colorSpace</c-></a> = "<a href="#dom-predefinedcolorspace-srgb" id="2dcontext:dom-predefinedcolorspace-srgb">srgb</a>";
  <a href="#canvascolortype" id="2dcontext:canvascolortype"><c- n="">CanvasColorType</c-></a> <a href="#dom-canvasrenderingcontext2dsettings-colortype" id="2dcontext:dom-canvasrenderingcontext2dsettings-colortype"><c- g="">colorType</c-></a> = "<a href="#dom-canvascolortype-unorm8" id="2dcontext:dom-canvascolortype-unorm8-2">unorm8</a>";
  <c- b="">boolean</c-> <a href="#dom-canvasrenderingcontext2dsettings-willreadfrequently" id="2dcontext:dom-canvasrenderingcontext2dsettings-willreadfrequently"><c- g="">willReadFrequently</c-></a> = <c- b="">false</c->;
};

<c- b="">enum</c-> <dfn id="imagesmoothingquality" data-dfn-type="enum"><c- g="">ImageSmoothingQuality</c-></dfn> { <c- s="">"</c-><a href="#dom-context-2d-imagesmoothingquality-low" id="2dcontext:dom-context-2d-imagesmoothingquality-low"><c- s="">low</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-imagesmoothingquality-medium" id="2dcontext:dom-context-2d-imagesmoothingquality-medium"><c- s="">medium</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-imagesmoothingquality-high" id="2dcontext:dom-context-2d-imagesmoothingquality-high"><c- s="">high</c-></a><c- s="">"</c-> };

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="canvasrenderingcontext2d" data-dfn-type="interface"><c- g="">CanvasRenderingContext2D</c-></dfn> {
  // back-reference to the canvas
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlcanvaselement" id="2dcontext:htmlcanvaselement-2"><c- n="">HTMLCanvasElement</c-></a> <a href="#dom-context-2d-canvas" id="2dcontext:dom-context-2d-canvas"><c- g="">canvas</c-></a>;
};
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvassettings" id="2dcontext:canvassettings"><c- n="">CanvasSettings</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-2"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasstate" id="2dcontext:canvasstate"><c- n="">CanvasState</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-3"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvastransform" id="2dcontext:canvastransform"><c- n="">CanvasTransform</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-4"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvascompositing" id="2dcontext:canvascompositing"><c- n="">CanvasCompositing</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-5"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasimagesmoothing" id="2dcontext:canvasimagesmoothing"><c- n="">CanvasImageSmoothing</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-6"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasfillstrokestyles" id="2dcontext:canvasfillstrokestyles"><c- n="">CanvasFillStrokeStyles</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-7"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasshadowstyles" id="2dcontext:canvasshadowstyles"><c- n="">CanvasShadowStyles</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-8"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasfilters" id="2dcontext:canvasfilters"><c- n="">CanvasFilters</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-9"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasrect" id="2dcontext:canvasrect"><c- n="">CanvasRect</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-10"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasdrawpath" id="2dcontext:canvasdrawpath"><c- n="">CanvasDrawPath</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-11"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasuserinterface" id="2dcontext:canvasuserinterface"><c- n="">CanvasUserInterface</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-12"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvastext" id="2dcontext:canvastext"><c- n="">CanvasText</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-13"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasdrawimage" id="2dcontext:canvasdrawimage"><c- n="">CanvasDrawImage</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-14"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasimagedata" id="2dcontext:canvasimagedata"><c- n="">CanvasImageData</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-15"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvaspathdrawingstyles" id="2dcontext:canvaspathdrawingstyles"><c- n="">CanvasPathDrawingStyles</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-16"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvastextdrawingstyles" id="2dcontext:canvastextdrawingstyles"><c- n="">CanvasTextDrawingStyles</c-></a>;
<a href="#canvasrenderingcontext2d" id="2dcontext:canvasrenderingcontext2d-17"><c- n="">CanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvaspath" id="2dcontext:canvaspath"><c- n="">CanvasPath</c-></a>;

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvassettings" data-dfn-type="interface"><c- g="">CanvasSettings</c-></dfn> {
  // settings
  <a href="#canvasrenderingcontext2dsettings" id="2dcontext:canvasrenderingcontext2dsettings"><c- n="">CanvasRenderingContext2DSettings</c-></a> <a href="#dom-context-2d-canvas-getcontextattributes" id="2dcontext:dom-context-2d-canvas-getcontextattributes"><c- g="">getContextAttributes</c-></a>();
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasstate" data-dfn-type="interface"><c- g="">CanvasState</c-></dfn> {
  // state
  <c- b="">undefined</c-> <a href="#dom-context-2d-save" id="2dcontext:dom-context-2d-save"><c- g="">save</c-></a>(); // push state on state stack
  <c- b="">undefined</c-> <a href="#dom-context-2d-restore" id="2dcontext:dom-context-2d-restore"><c- g="">restore</c-></a>(); // pop state stack and restore state
  <c- b="">undefined</c-> <a href="#dom-context-2d-reset" id="2dcontext:dom-context-2d-reset"><c- g="">reset</c-></a>(); // <a href="#reset-the-rendering-context-to-its-default-state" id="2dcontext:reset-the-rendering-context-to-its-default-state">reset the rendering context to its default state</a>
  <c- b="">boolean</c-> <a href="#dom-context-2d-iscontextlost" id="2dcontext:dom-context-2d-iscontextlost"><c- g="">isContextLost</c-></a>(); // return whether context is lost
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvastransform" data-dfn-type="interface"><c- g="">CanvasTransform</c-></dfn> {
  // transformations (default transform is the identity matrix)
  <c- b="">undefined</c-> <a href="#dom-context-2d-scale" id="2dcontext:dom-context-2d-scale"><c- g="">scale</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-rotate" id="2dcontext:dom-context-2d-rotate"><c- g="">rotate</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">angle</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-translate" id="2dcontext:dom-context-2d-translate"><c- g="">translate</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-transform" id="2dcontext:dom-context-2d-transform"><c- g="">transform</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">a</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">b</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">c</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">d</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">e</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">f</c->);

  [<c- g="">NewObject</c->] <a id="2dcontext:dommatrix" href="https://drafts.fxtf.org/geometry/#dommatrix" data-x-internal="dommatrix"><c- n="">DOMMatrix</c-></a> <a href="#dom-context-2d-gettransform" id="2dcontext:dom-context-2d-gettransform"><c- g="">getTransform</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-context-2d-settransform" id="2dcontext:dom-context-2d-settransform"><c- g="">setTransform</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">a</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">b</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">c</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">d</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">e</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">f</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-settransform-matrix" id="2dcontext:dom-context-2d-settransform-matrix"><c- g="">setTransform</c-></a>(<c- b="">optional</c-> <a id="2dcontext:dommatrix2dinit" href="https://drafts.fxtf.org/geometry/#dictdef-dommatrix2dinit" data-x-internal="dommatrix2dinit"><c- n="">DOMMatrix2DInit</c-></a> <c- g="">transform</c-> = {});
  <c- b="">undefined</c-> <a href="#dom-context-2d-resettransform" id="2dcontext:dom-context-2d-resettransform"><c- g="">resetTransform</c-></a>();

};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvascompositing" data-dfn-type="interface"><c- g="">CanvasCompositing</c-></dfn> {
  // compositing
  <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-context-2d-globalalpha" id="2dcontext:dom-context-2d-globalalpha"><c- g="">globalAlpha</c-></a>; // (default 1.0)
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-context-2d-globalcompositeoperation" id="2dcontext:dom-context-2d-globalcompositeoperation"><c- g="">globalCompositeOperation</c-></a>; // (default "source-over")
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasimagesmoothing" data-dfn-type="interface"><c- g="">CanvasImageSmoothing</c-></dfn> {
  // image smoothing
  <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-context-2d-imagesmoothingenabled" id="2dcontext:dom-context-2d-imagesmoothingenabled"><c- g="">imageSmoothingEnabled</c-></a>; // (default true)
  <c- b="">attribute</c-> <a href="#imagesmoothingquality" id="2dcontext:imagesmoothingquality"><c- n="">ImageSmoothingQuality</c-></a> <a href="#dom-context-2d-imagesmoothingquality" id="2dcontext:dom-context-2d-imagesmoothingquality"><c- g="">imageSmoothingQuality</c-></a>; // (default low)

};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasfillstrokestyles" data-dfn-type="interface"><c- g="">CanvasFillStrokeStyles</c-></dfn> {
  // colors and styles (see also the <a href="#canvaspathdrawingstyles" id="2dcontext:canvaspathdrawingstyles-2">CanvasPathDrawingStyles</a> and <a href="#canvastextdrawingstyles" id="2dcontext:canvastextdrawingstyles-2">CanvasTextDrawingStyles</a> interfaces)
  <c- b="">attribute</c-> (<c- b="">DOMString</c-> <c- b="">or</c-> <c- n="">CanvasGradient</c-> <c- b="">or</c-> <c- n="">CanvasPattern</c->) <a href="#dom-context-2d-strokestyle" id="2dcontext:dom-context-2d-strokestyle"><c- g="">strokeStyle</c-></a>; // (default black)
  <c- b="">attribute</c-> (<c- b="">DOMString</c-> <c- b="">or</c-> <c- n="">CanvasGradient</c-> <c- b="">or</c-> <c- n="">CanvasPattern</c->) <a href="#dom-context-2d-fillstyle" id="2dcontext:dom-context-2d-fillstyle"><c- g="">fillStyle</c-></a>; // (default black)
  <a href="#canvasgradient" id="2dcontext:canvasgradient"><c- n="">CanvasGradient</c-></a> <a href="#dom-context-2d-createlineargradient" id="2dcontext:dom-context-2d-createlineargradient"><c- g="">createLinearGradient</c-></a>(<c- b="">double</c-> <c- g="">x0</c->, <c- b="">double</c-> <c- g="">y0</c->, <c- b="">double</c-> <c- g="">x1</c->, <c- b="">double</c-> <c- g="">y1</c->);
  <a href="#canvasgradient" id="2dcontext:canvasgradient-2"><c- n="">CanvasGradient</c-></a> <a href="#dom-context-2d-createradialgradient" id="2dcontext:dom-context-2d-createradialgradient"><c- g="">createRadialGradient</c-></a>(<c- b="">double</c-> <c- g="">x0</c->, <c- b="">double</c-> <c- g="">y0</c->, <c- b="">double</c-> <c- g="">r0</c->, <c- b="">double</c-> <c- g="">x1</c->, <c- b="">double</c-> <c- g="">y1</c->, <c- b="">double</c-> <c- g="">r1</c->);
  <a href="#canvasgradient" id="2dcontext:canvasgradient-3"><c- n="">CanvasGradient</c-></a> <a href="#dom-context-2d-createconicgradient" id="2dcontext:dom-context-2d-createconicgradient"><c- g="">createConicGradient</c-></a>(<c- b="">double</c-> <c- g="">startAngle</c->, <c- b="">double</c-> <c- g="">x</c->, <c- b="">double</c-> <c- g="">y</c->);
  <a href="#canvaspattern" id="2dcontext:canvaspattern"><c- n="">CanvasPattern</c-></a>? <a href="#dom-context-2d-createpattern" id="2dcontext:dom-context-2d-createpattern"><c- g="">createPattern</c-></a>(<a href="#canvasimagesource" id="2dcontext:canvasimagesource"><c- n="">CanvasImageSource</c-></a> <c- g="">image</c->, [<a id="2dcontext:legacynulltoemptystring" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <c- g="">repetition</c->);

};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasshadowstyles" data-dfn-type="interface"><c- g="">CanvasShadowStyles</c-></dfn> {
  // shadows
  <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-context-2d-shadowoffsetx" id="2dcontext:dom-context-2d-shadowoffsetx"><c- g="">shadowOffsetX</c-></a>; // (default 0)
  <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-context-2d-shadowoffsety" id="2dcontext:dom-context-2d-shadowoffsety"><c- g="">shadowOffsetY</c-></a>; // (default 0)
  <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-context-2d-shadowblur" id="2dcontext:dom-context-2d-shadowblur"><c- g="">shadowBlur</c-></a>; // (default 0)
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-context-2d-shadowcolor" id="2dcontext:dom-context-2d-shadowcolor"><c- g="">shadowColor</c-></a>; // (default <a id="2dcontext:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>)
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasfilters" data-dfn-type="interface"><c- g="">CanvasFilters</c-></dfn> {
  // filters
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-context-2d-filter" id="2dcontext:dom-context-2d-filter"><c- g="">filter</c-></a>; // (default "none")
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasrect" data-dfn-type="interface"><c- g="">CanvasRect</c-></dfn> {
  // rects
  <c- b="">undefined</c-> <a href="#dom-context-2d-clearrect" id="2dcontext:dom-context-2d-clearrect"><c- g="">clearRect</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">w</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">h</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-fillrect" id="2dcontext:dom-context-2d-fillrect"><c- g="">fillRect</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">w</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">h</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-strokerect" id="2dcontext:dom-context-2d-strokerect"><c- g="">strokeRect</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">w</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">h</c->);
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasdrawpath" data-dfn-type="interface"><c- g="">CanvasDrawPath</c-></dfn> {
  // path API (see also <a href="#canvaspath" id="2dcontext:canvaspath-2">CanvasPath</a>)
  <c- b="">undefined</c-> <a href="#dom-context-2d-beginpath" id="2dcontext:dom-context-2d-beginpath"><c- g="">beginPath</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-context-2d-fill" id="2dcontext:dom-context-2d-fill"><c- g="">fill</c-></a>(<c- b="">optional</c-> <a href="#canvasfillrule" id="2dcontext:canvasfillrule"><c- n="">CanvasFillRule</c-></a> <c- g="">fillRule</c-> = "<a href="#dom-context-2d-fillrule-nonzero" id="2dcontext:dom-context-2d-fillrule-nonzero-2">nonzero</a>");
  <c- b="">undefined</c-> <a href="#dom-context-2d-fill-path" id="2dcontext:dom-context-2d-fill-path"><c- g="">fill</c-></a>(<a href="#path2d" id="2dcontext:path2d"><c- n="">Path2D</c-></a> <c- g="">path</c->, <c- b="">optional</c-> <a href="#canvasfillrule" id="2dcontext:canvasfillrule-2"><c- n="">CanvasFillRule</c-></a> <c- g="">fillRule</c-> = "<a href="#dom-context-2d-fillrule-nonzero" id="2dcontext:dom-context-2d-fillrule-nonzero-3">nonzero</a>");
  <c- b="">undefined</c-> <a href="#dom-context-2d-stroke" id="2dcontext:dom-context-2d-stroke"><c- g="">stroke</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-context-2d-stroke-path" id="2dcontext:dom-context-2d-stroke-path"><c- g="">stroke</c-></a>(<a href="#path2d" id="2dcontext:path2d-2"><c- n="">Path2D</c-></a> <c- g="">path</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-clip" id="2dcontext:dom-context-2d-clip"><c- g="">clip</c-></a>(<c- b="">optional</c-> <a href="#canvasfillrule" id="2dcontext:canvasfillrule-3"><c- n="">CanvasFillRule</c-></a> <c- g="">fillRule</c-> = "<a href="#dom-context-2d-fillrule-nonzero" id="2dcontext:dom-context-2d-fillrule-nonzero-4">nonzero</a>");
  <c- b="">undefined</c-> <a href="#dom-context-2d-clip-path" id="2dcontext:dom-context-2d-clip-path"><c- g="">clip</c-></a>(<a href="#path2d" id="2dcontext:path2d-3"><c- n="">Path2D</c-></a> <c- g="">path</c->, <c- b="">optional</c-> <a href="#canvasfillrule" id="2dcontext:canvasfillrule-4"><c- n="">CanvasFillRule</c-></a> <c- g="">fillRule</c-> = "<a href="#dom-context-2d-fillrule-nonzero" id="2dcontext:dom-context-2d-fillrule-nonzero-5">nonzero</a>");
  <c- b="">boolean</c-> <a href="#dom-context-2d-ispointinpath" id="2dcontext:dom-context-2d-ispointinpath"><c- g="">isPointInPath</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">optional</c-> <a href="#canvasfillrule" id="2dcontext:canvasfillrule-5"><c- n="">CanvasFillRule</c-></a> <c- g="">fillRule</c-> = "<a href="#dom-context-2d-fillrule-nonzero" id="2dcontext:dom-context-2d-fillrule-nonzero-6">nonzero</a>");
  <c- b="">boolean</c-> <a href="#dom-context-2d-ispointinpath-path" id="2dcontext:dom-context-2d-ispointinpath-path"><c- g="">isPointInPath</c-></a>(<a href="#path2d" id="2dcontext:path2d-4"><c- n="">Path2D</c-></a> <c- g="">path</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">optional</c-> <a href="#canvasfillrule" id="2dcontext:canvasfillrule-6"><c- n="">CanvasFillRule</c-></a> <c- g="">fillRule</c-> = "<a href="#dom-context-2d-fillrule-nonzero" id="2dcontext:dom-context-2d-fillrule-nonzero-7">nonzero</a>");
  <c- b="">boolean</c-> <a href="#dom-context-2d-ispointinstroke" id="2dcontext:dom-context-2d-ispointinstroke"><c- g="">isPointInStroke</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->);
  <c- b="">boolean</c-> <a href="#dom-context-2d-ispointinstroke-path" id="2dcontext:dom-context-2d-ispointinstroke-path"><c- g="">isPointInStroke</c-></a>(<a href="#path2d" id="2dcontext:path2d-5"><c- n="">Path2D</c-></a> <c- g="">path</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->);
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasuserinterface" data-dfn-type="interface"><c- g="">CanvasUserInterface</c-></dfn> {
  <c- b="">undefined</c-> <a href="#dom-context-2d-drawfocusifneeded" id="2dcontext:dom-context-2d-drawfocusifneeded"><c- g="">drawFocusIfNeeded</c-></a>(<a id="2dcontext:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a> <c- g="">element</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-drawfocusifneeded-path-element" id="2dcontext:dom-context-2d-drawfocusifneeded-path-element"><c- g="">drawFocusIfNeeded</c-></a>(<a href="#path2d" id="2dcontext:path2d-6"><c- n="">Path2D</c-></a> <c- g="">path</c->, <a id="2dcontext:element-2" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a> <c- g="">element</c->);
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvastext" data-dfn-type="interface"><c- g="">CanvasText</c-></dfn> {
  // text (see also the <a href="#canvaspathdrawingstyles" id="2dcontext:canvaspathdrawingstyles-3">CanvasPathDrawingStyles</a> and <a href="#canvastextdrawingstyles" id="2dcontext:canvastextdrawingstyles-3">CanvasTextDrawingStyles</a> interfaces)
  <c- b="">undefined</c-> <a href="#dom-context-2d-filltext" id="2dcontext:dom-context-2d-filltext"><c- g="">fillText</c-></a>(<c- b="">DOMString</c-> <c- g="">text</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">optional</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">maxWidth</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-stroketext" id="2dcontext:dom-context-2d-stroketext"><c- g="">strokeText</c-></a>(<c- b="">DOMString</c-> <c- g="">text</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">optional</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">maxWidth</c->);
  <a href="#textmetrics" id="2dcontext:textmetrics"><c- n="">TextMetrics</c-></a> <a href="#dom-context-2d-measuretext" id="2dcontext:dom-context-2d-measuretext"><c- g="">measureText</c-></a>(<c- b="">DOMString</c-> <c- g="">text</c->);
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasdrawimage" data-dfn-type="interface"><c- g="">CanvasDrawImage</c-></dfn> {
  // drawing images
  <c- b="">undefined</c-> <a href="#dom-context-2d-drawimage" id="2dcontext:dom-context-2d-drawimage"><c- g="">drawImage</c-></a>(<a href="#canvasimagesource" id="2dcontext:canvasimagesource-2"><c- n="">CanvasImageSource</c-></a> <c- g="">image</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dx</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dy</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-drawimage" id="2dcontext:dom-context-2d-drawimage-2"><c- g="">drawImage</c-></a>(<a href="#canvasimagesource" id="2dcontext:canvasimagesource-3"><c- n="">CanvasImageSource</c-></a> <c- g="">image</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dx</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dy</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dw</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dh</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-drawimage" id="2dcontext:dom-context-2d-drawimage-3"><c- g="">drawImage</c-></a>(<a href="#canvasimagesource" id="2dcontext:canvasimagesource-4"><c- n="">CanvasImageSource</c-></a> <c- g="">image</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">sx</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">sy</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">sw</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">sh</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dx</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dy</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dw</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">dh</c->);
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvasimagedata" data-dfn-type="interface"><c- g="">CanvasImageData</c-></dfn> {
  // <a href="#pixel-manipulation" id="2dcontext:pixel-manipulation">pixel manipulation</a>
  <a href="#imagedata" id="2dcontext:imagedata"><c- n="">ImageData</c-></a> <a href="#dom-context-2d-createimagedata" id="2dcontext:dom-context-2d-createimagedata"><c- g="">createImageData</c-></a>([<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">sw</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">sh</c->, <c- b="">optional</c-> <a href="#imagedatasettings" id="2dcontext:imagedatasettings"><c- n="">ImageDataSettings</c-></a> <c- g="">settings</c-> = {});
  <a href="#imagedata" id="2dcontext:imagedata-2"><c- n="">ImageData</c-></a> <a href="#dom-context-2d-createimagedata-imagedata" id="2dcontext:dom-context-2d-createimagedata-imagedata"><c- g="">createImageData</c-></a>(<a href="#imagedata" id="2dcontext:imagedata-3"><c- n="">ImageData</c-></a> <c- g="">imageData</c->);
  <a href="#imagedata" id="2dcontext:imagedata-4"><c- n="">ImageData</c-></a> <a href="#dom-context-2d-getimagedata" id="2dcontext:dom-context-2d-getimagedata"><c- g="">getImageData</c-></a>([<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">sx</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">sy</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">sw</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">sh</c->, <c- b="">optional</c-> <a href="#imagedatasettings" id="2dcontext:imagedatasettings-2"><c- n="">ImageDataSettings</c-></a> <c- g="">settings</c-> = {});
  <c- b="">undefined</c-> <a href="#dom-context-2d-putimagedata-short" id="2dcontext:dom-context-2d-putimagedata-short"><c- g="">putImageData</c-></a>(<a href="#imagedata" id="2dcontext:imagedata-5"><c- n="">ImageData</c-></a> <c- g="">imageData</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">dx</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">dy</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-putimagedata" id="2dcontext:dom-context-2d-putimagedata"><c- g="">putImageData</c-></a>(<a href="#imagedata" id="2dcontext:imagedata-6"><c- n="">ImageData</c-></a> <c- g="">imageData</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">dx</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">dy</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">dirtyX</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">dirtyY</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">dirtyWidth</c->, [<c- g="">EnforceRange</c->] <c- b="">long</c-> <c- g="">dirtyHeight</c->);
};

<c- b="">enum</c-> <dfn id="canvaslinecap" data-dfn-type="enum"><c- g="">CanvasLineCap</c-></dfn> { <c- s="">"butt"</c->, <c- s="">"round"</c->, <c- s="">"square"</c-> };
<c- b="">enum</c-> <dfn id="canvaslinejoin" data-dfn-type="enum"><c- g="">CanvasLineJoin</c-></dfn> { <c- s="">"round"</c->, <c- s="">"bevel"</c->, <c- s="">"miter"</c-> };
<c- b="">enum</c-> <dfn id="canvastextalign" data-dfn-type="enum"><c- g="">CanvasTextAlign</c-></dfn> { <c- s="">"</c-><a href="#dom-context-2d-textalign-start" id="2dcontext:dom-context-2d-textalign-start"><c- s="">start</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textalign-end" id="2dcontext:dom-context-2d-textalign-end"><c- s="">end</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textalign-left" id="2dcontext:dom-context-2d-textalign-left"><c- s="">left</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textalign-right" id="2dcontext:dom-context-2d-textalign-right"><c- s="">right</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textalign-center" id="2dcontext:dom-context-2d-textalign-center"><c- s="">center</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="canvastextbaseline" data-dfn-type="enum"><c- g="">CanvasTextBaseline</c-></dfn> { <c- s="">"</c-><a href="#dom-context-2d-textbaseline-top" id="2dcontext:dom-context-2d-textbaseline-top"><c- s="">top</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textbaseline-hanging" id="2dcontext:dom-context-2d-textbaseline-hanging"><c- s="">hanging</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textbaseline-middle" id="2dcontext:dom-context-2d-textbaseline-middle"><c- s="">middle</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textbaseline-alphabetic" id="2dcontext:dom-context-2d-textbaseline-alphabetic"><c- s="">alphabetic</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textbaseline-ideographic" id="2dcontext:dom-context-2d-textbaseline-ideographic"><c- s="">ideographic</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textbaseline-bottom" id="2dcontext:dom-context-2d-textbaseline-bottom"><c- s="">bottom</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="canvasdirection" data-dfn-type="enum"><c- g="">CanvasDirection</c-></dfn> { <c- s="">"</c-><a href="#dom-context-2d-direction-ltr" id="2dcontext:dom-context-2d-direction-ltr"><c- s="">ltr</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-direction-rtl" id="2dcontext:dom-context-2d-direction-rtl"><c- s="">rtl</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-direction-inherit" id="2dcontext:dom-context-2d-direction-inherit"><c- s="">inherit</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="canvasfontkerning" data-dfn-type="enum"><c- g="">CanvasFontKerning</c-></dfn> { <c- s="">"</c-><a href="#dom-context-2d-fontkerning-auto" id="2dcontext:dom-context-2d-fontkerning-auto"><c- s="">auto</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontkerning-normal" id="2dcontext:dom-context-2d-fontkerning-normal"><c- s="">normal</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontkerning-none" id="2dcontext:dom-context-2d-fontkerning-none"><c- s="">none</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="canvasfontstretch" data-dfn-type="enum"><c- g="">CanvasFontStretch</c-></dfn> { <c- s="">"</c-><a href="#dom-context-2d-fontstretch-ultra-condensed" id="2dcontext:dom-context-2d-fontstretch-ultra-condensed"><c- s="">ultra-condensed</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontstretch-extra-condensed" id="2dcontext:dom-context-2d-fontstretch-extra-condensed"><c- s="">extra-condensed</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontstretch-condensed" id="2dcontext:dom-context-2d-fontstretch-condensed"><c- s="">condensed</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontstretch-semi-condensed" id="2dcontext:dom-context-2d-fontstretch-semi-condensed"><c- s="">semi-condensed</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontstretch-normal" id="2dcontext:dom-context-2d-fontstretch-normal"><c- s="">normal</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontstretch-semi-expanded" id="2dcontext:dom-context-2d-fontstretch-semi-expanded"><c- s="">semi-expanded</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontstretch-expanded" id="2dcontext:dom-context-2d-fontstretch-expanded"><c- s="">expanded</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontstretch-extra-expanded" id="2dcontext:dom-context-2d-fontstretch-extra-expanded"><c- s="">extra-expanded</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontstretch-ultra-expanded" id="2dcontext:dom-context-2d-fontstretch-ultra-expanded"><c- s="">ultra-expanded</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="canvasfontvariantcaps" data-dfn-type="enum"><c- g="">CanvasFontVariantCaps</c-></dfn> { <c- s="">"</c-><a href="#dom-context-2d-fontvariantcaps-normal" id="2dcontext:dom-context-2d-fontvariantcaps-normal"><c- s="">normal</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontvariantcaps-small-caps" id="2dcontext:dom-context-2d-fontvariantcaps-small-caps"><c- s="">small-caps</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontvariantcaps-all-small-caps" id="2dcontext:dom-context-2d-fontvariantcaps-all-small-caps"><c- s="">all-small-caps</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontvariantcaps-petite-caps" id="2dcontext:dom-context-2d-fontvariantcaps-petite-caps"><c- s="">petite-caps</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontvariantcaps-all-petite-caps" id="2dcontext:dom-context-2d-fontvariantcaps-all-petite-caps"><c- s="">all-petite-caps</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontvariantcaps-unicase" id="2dcontext:dom-context-2d-fontvariantcaps-unicase"><c- s="">unicase</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-fontvariantcaps-titling-caps" id="2dcontext:dom-context-2d-fontvariantcaps-titling-caps"><c- s="">titling-caps</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="canvastextrendering" data-dfn-type="enum"><c- g="">CanvasTextRendering</c-></dfn> { <c- s="">"</c-><a href="#dom-context-2d-textrendering-auto" id="2dcontext:dom-context-2d-textrendering-auto"><c- s="">auto</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textrendering-optimizespeed" id="2dcontext:dom-context-2d-textrendering-optimizespeed"><c- s="">optimizeSpeed</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textrendering-optimizelegibility" id="2dcontext:dom-context-2d-textrendering-optimizelegibility"><c- s="">optimizeLegibility</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-context-2d-textrendering-geometricprecision" id="2dcontext:dom-context-2d-textrendering-geometricprecision"><c- s="">geometricPrecision</c-></a><c- s="">"</c-> };

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvaspathdrawingstyles" data-dfn-type="interface"><c- g="">CanvasPathDrawingStyles</c-></dfn> {
  // line caps/joins
  <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-context-2d-linewidth" id="2dcontext:dom-context-2d-linewidth"><c- g="">lineWidth</c-></a>; // (default 1)
  <c- b="">attribute</c-> <a href="#canvaslinecap" id="2dcontext:canvaslinecap"><c- n="">CanvasLineCap</c-></a> <a href="#dom-context-2d-linecap" id="2dcontext:dom-context-2d-linecap"><c- g="">lineCap</c-></a>; // (default "butt")
  <c- b="">attribute</c-> <a href="#canvaslinejoin" id="2dcontext:canvaslinejoin"><c- n="">CanvasLineJoin</c-></a> <a href="#dom-context-2d-linejoin" id="2dcontext:dom-context-2d-linejoin"><c- g="">lineJoin</c-></a>; // (default "miter")
  <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-context-2d-miterlimit" id="2dcontext:dom-context-2d-miterlimit"><c- g="">miterLimit</c-></a>; // (default 10)

  // dashed lines
  <c- b="">undefined</c-> <a href="#dom-context-2d-setlinedash" id="2dcontext:dom-context-2d-setlinedash"><c- g="">setLineDash</c-></a>(<c- b="">sequence</c->&lt;<c- b="">unrestricted</c-> <c- b="">double</c->&gt; <c- g="">segments</c->); // default empty
  <c- b="">sequence</c->&lt;<c- b="">unrestricted</c-> <c- b="">double</c->&gt; <a href="#dom-context-2d-getlinedash" id="2dcontext:dom-context-2d-getlinedash"><c- g="">getLineDash</c-></a>();
  <c- b="">attribute</c-> <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#dom-context-2d-linedashoffset" id="2dcontext:dom-context-2d-linedashoffset"><c- g="">lineDashOffset</c-></a>;
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvastextdrawingstyles" data-dfn-type="interface"><c- g="">CanvasTextDrawingStyles</c-></dfn> {
  // text
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-context-2d-lang" id="2dcontext:dom-context-2d-lang"><c- g="">lang</c-></a>; // (default: "inherit")
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-context-2d-font" id="2dcontext:dom-context-2d-font"><c- g="">font</c-></a>; // (default 10px sans-serif)
  <c- b="">attribute</c-> <a href="#canvastextalign" id="2dcontext:canvastextalign"><c- n="">CanvasTextAlign</c-></a> <a href="#dom-context-2d-textalign" id="2dcontext:dom-context-2d-textalign"><c- g="">textAlign</c-></a>; // (default: "start")
  <c- b="">attribute</c-> <a href="#canvastextbaseline" id="2dcontext:canvastextbaseline"><c- n="">CanvasTextBaseline</c-></a> <a href="#dom-context-2d-textbaseline" id="2dcontext:dom-context-2d-textbaseline"><c- g="">textBaseline</c-></a>; // (default: "alphabetic")
  <c- b="">attribute</c-> <a href="#canvasdirection" id="2dcontext:canvasdirection"><c- n="">CanvasDirection</c-></a> <a href="#dom-context-2d-direction" id="2dcontext:dom-context-2d-direction"><c- g="">direction</c-></a>; // (default: "inherit")
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-context-2d-letterspacing" id="2dcontext:dom-context-2d-letterspacing"><c- g="">letterSpacing</c-></a>; // (default: "0px")
  <c- b="">attribute</c-> <a href="#canvasfontkerning" id="2dcontext:canvasfontkerning"><c- n="">CanvasFontKerning</c-></a> <a href="#dom-context-2d-fontkerning" id="2dcontext:dom-context-2d-fontkerning"><c- g="">fontKerning</c-></a>; // (default: "auto")
  <c- b="">attribute</c-> <a href="#canvasfontstretch" id="2dcontext:canvasfontstretch"><c- n="">CanvasFontStretch</c-></a> <a href="#dom-context-2d-fontstretch" id="2dcontext:dom-context-2d-fontstretch"><c- g="">fontStretch</c-></a>; // (default: "normal")
  <c- b="">attribute</c-> <a href="#canvasfontvariantcaps" id="2dcontext:canvasfontvariantcaps"><c- n="">CanvasFontVariantCaps</c-></a> <a href="#dom-context-2d-fontvariantcaps" id="2dcontext:dom-context-2d-fontvariantcaps"><c- g="">fontVariantCaps</c-></a>; // (default: "normal")
  <c- b="">attribute</c-> <a href="#canvastextrendering" id="2dcontext:canvastextrendering"><c- n="">CanvasTextRendering</c-></a> <a href="#dom-context-2d-textrendering" id="2dcontext:dom-context-2d-textrendering"><c- g="">textRendering</c-></a>; // (default: "auto")
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-context-2d-wordspacing" id="2dcontext:dom-context-2d-wordspacing"><c- g="">wordSpacing</c-></a>; // (default: "0px")
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="canvaspath" data-dfn-type="interface"><c- g="">CanvasPath</c-></dfn> {
  // shared path API methods
  <c- b="">undefined</c-> <a href="#dom-context-2d-closepath" id="2dcontext:dom-context-2d-closepath"><c- g="">closePath</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-context-2d-moveto" id="2dcontext:dom-context-2d-moveto"><c- g="">moveTo</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-lineto" id="2dcontext:dom-context-2d-lineto"><c- g="">lineTo</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-quadraticcurveto" id="2dcontext:dom-context-2d-quadraticcurveto"><c- g="">quadraticCurveTo</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">cpx</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">cpy</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-beziercurveto" id="2dcontext:dom-context-2d-beziercurveto"><c- g="">bezierCurveTo</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">cp1x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">cp1y</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">cp2x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">cp2y</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-arcto" id="2dcontext:dom-context-2d-arcto"><c- g="">arcTo</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x1</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y1</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x2</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y2</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">radius</c->); 
  <c- b="">undefined</c-> <a href="#dom-context-2d-rect" id="2dcontext:dom-context-2d-rect"><c- g="">rect</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">w</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">h</c->);
  <c- b="">undefined</c-> <a href="#dom-context-2d-roundrect" id="2dcontext:dom-context-2d-roundrect"><c- g="">roundRect</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">w</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">h</c->, <c- b="">optional</c-> (<c- b="">unrestricted</c-> <c- b="">double</c-> <c- b="">or</c-> <a id="2dcontext:dompointinit" href="https://drafts.fxtf.org/geometry/#dictdef-dompointinit" data-x-internal="dompointinit"><c- n="">DOMPointInit</c-></a> <c- b="">or</c-> <c- b="">sequence</c->&lt;(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- b="">or</c-> <a id="2dcontext:dompointinit-2" href="https://drafts.fxtf.org/geometry/#dictdef-dompointinit" data-x-internal="dompointinit"><c- n="">DOMPointInit</c-></a>)&gt;) <c- g="">radii</c-> = 0);
  <c- b="">undefined</c-> <a href="#dom-context-2d-arc" id="2dcontext:dom-context-2d-arc"><c- g="">arc</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">radius</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">startAngle</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">endAngle</c->, <c- b="">optional</c-> <c- b="">boolean</c-> <c- g="">counterclockwise</c-> = <c- b="">false</c->); 
  <c- b="">undefined</c-> <a href="#dom-context-2d-ellipse" id="2dcontext:dom-context-2d-ellipse"><c- g="">ellipse</c-></a>(<c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">x</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">y</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">radiusX</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">radiusY</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">rotation</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">startAngle</c->, <c- b="">unrestricted</c-> <c- b="">double</c-> <c- g="">endAngle</c->, <c- b="">optional</c-> <c- b="">boolean</c-> <c- g="">counterclockwise</c-> = <c- b="">false</c->); 
};

[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="canvasgradient" data-dfn-type="interface"><c- g="">CanvasGradient</c-></dfn> {
  // opaque object
  <c- b="">undefined</c-> <a href="#dom-canvasgradient-addcolorstop" id="2dcontext:dom-canvasgradient-addcolorstop"><c- g="">addColorStop</c-></a>(<c- b="">double</c-> <c- g="">offset</c->, <c- b="">DOMString</c-> <c- g="">color</c->);
};

[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="canvaspattern" data-dfn-type="interface"><c- g="">CanvasPattern</c-></dfn> {
  // opaque object
  <c- b="">undefined</c-> <a href="#dom-canvaspattern-settransform" id="2dcontext:dom-canvaspattern-settransform"><c- g="">setTransform</c-></a>(<c- b="">optional</c-> <a id="2dcontext:dommatrix2dinit-2" href="https://drafts.fxtf.org/geometry/#dictdef-dommatrix2dinit" data-x-internal="dommatrix2dinit"><c- n="">DOMMatrix2DInit</c-></a> <c- g="">transform</c-> = {});
};

[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="textmetrics" data-dfn-type="interface"><c- g="">TextMetrics</c-></dfn> {
  // x-direction
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-width" id="2dcontext:dom-textmetrics-width"><c- g="">width</c-></a>; // advance width
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-actualboundingboxleft" id="2dcontext:dom-textmetrics-actualboundingboxleft"><c- g="">actualBoundingBoxLeft</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-actualboundingboxright" id="2dcontext:dom-textmetrics-actualboundingboxright"><c- g="">actualBoundingBoxRight</c-></a>;

  // y-direction
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-fontboundingboxascent" id="2dcontext:dom-textmetrics-fontboundingboxascent"><c- g="">fontBoundingBoxAscent</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-fontboundingboxdescent" id="2dcontext:dom-textmetrics-fontboundingboxdescent"><c- g="">fontBoundingBoxDescent</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-actualboundingboxascent" id="2dcontext:dom-textmetrics-actualboundingboxascent"><c- g="">actualBoundingBoxAscent</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-actualboundingboxdescent" id="2dcontext:dom-textmetrics-actualboundingboxdescent"><c- g="">actualBoundingBoxDescent</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-emheightascent" id="2dcontext:dom-textmetrics-emheightascent"><c- g="">emHeightAscent</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-emheightdescent" id="2dcontext:dom-textmetrics-emheightdescent"><c- g="">emHeightDescent</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-hangingbaseline" id="2dcontext:dom-textmetrics-hangingbaseline"><c- g="">hangingBaseline</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-alphabeticbaseline" id="2dcontext:dom-textmetrics-alphabeticbaseline"><c- g="">alphabeticBaseline</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">double</c-> <a href="#dom-textmetrics-ideographicbaseline" id="2dcontext:dom-textmetrics-ideographicbaseline"><c- g="">ideographicBaseline</c-></a>;
};

[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="path2d" data-dfn-type="interface"><c- g="">Path2D</c-></dfn> {
  <a href="#dom-path2d" id="2dcontext:dom-path2d"><c- g="">constructor</c-></a>(<c- b="">optional</c-> (<a href="#path2d" id="2dcontext:path2d-7"><c- n="">Path2D</c-></a> <c- b="">or</c-> <c- b="">DOMString</c->) <c- g="">path</c->);

  <c- b="">undefined</c-> <a href="#dom-path2d-addpath" id="2dcontext:dom-path2d-addpath"><c- g="">addPath</c-></a>(<a href="#path2d" id="2dcontext:path2d-8"><c- n="">Path2D</c-></a> <c- g="">path</c->, <c- b="">optional</c-> <a id="2dcontext:dommatrix2dinit-3" href="https://drafts.fxtf.org/geometry/#dictdef-dommatrix2dinit" data-x-internal="dommatrix2dinit"><c- n="">DOMMatrix2DInit</c-></a> <c- g="">transform</c-> = {});
};
<a href="#path2d" id="2dcontext:path2d-9"><c- n="">Path2D</c-></a> <c- b="">includes</c-> <a href="#canvaspath" id="2dcontext:canvaspath-3"><c- n="">CanvasPath</c-></a>;</code></pre>

 

  <p class="note">To maintain compatibility with existing web content, user agents need to
  enumerate methods defined in <code id="2dcontext:canvasuserinterface-2"><a href="#canvasuserinterface">CanvasUserInterface</a></code> immediately after the <code id="2dcontext:dom-context-2d-stroke-2"><a href="#dom-context-2d-stroke">stroke()</a></code> method on <code id="2dcontext:canvasrenderingcontext2d-18"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code>
  objects.</p>

  <dl class="domintro"><dt><code><var>context</var> = <var>canvas</var>.<a href="#dom-canvas-getcontext" id="2dcontext:dom-canvas-getcontext">getContext</a>('2d' [, { [ <a href="#dom-canvasrenderingcontext2dsettings-alpha" id="2dcontext:dom-canvasrenderingcontext2dsettings-alpha-2">alpha</a>: true ] [, <a href="#dom-canvasrenderingcontext2dsettings-desynchronized" id="2dcontext:dom-canvasrenderingcontext2dsettings-desynchronized-2">desynchronized</a>: false ] [, <a href="#dom-canvasrenderingcontext2dsettings-colorspace" id="2dcontext:dom-canvasrenderingcontext2dsettings-colorspace-2">colorSpace</a>: 'srgb'] [, <a href="#dom-canvasrenderingcontext2dsettings-willreadfrequently" id="2dcontext:dom-canvasrenderingcontext2dsettings-willreadfrequently-2">willReadFrequently</a>: false ]} ])</code></dt><dd>
    <p>Returns a <code id="2dcontext:canvasrenderingcontext2d-19"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> object that is permanently bound to a
    particular <code id="2dcontext:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element.</p>

    <p>If the <code id="2dcontext:dom-canvasrenderingcontext2dsettings-alpha-3"><a href="#dom-canvasrenderingcontext2dsettings-alpha">alpha</a></code> member is
    false, then the context is forced to always be opaque.</p>

    <p>If the <code id="2dcontext:dom-canvasrenderingcontext2dsettings-desynchronized-3"><a href="#dom-canvasrenderingcontext2dsettings-desynchronized">desynchronized</a></code> member is
    true, then the context might be <a href="#concept-canvas-desynchronized" id="2dcontext:concept-canvas-desynchronized">desynchronized</a>.</p>

    <p>The <code id="2dcontext:dom-canvasrenderingcontext2dsettings-colorspace-3"><a href="#dom-canvasrenderingcontext2dsettings-colorspace">colorSpace</a></code> member
    specifies the <a href="#concept-canvas-color-space" id="2dcontext:concept-canvas-color-space">color space</a> of the rendering
    context.</p>

    <p>The <code id="2dcontext:dom-canvasrenderingcontext2dsettings-colortype-2"><a href="#dom-canvasrenderingcontext2dsettings-colortype">colorType</a></code> member
    specifies the <a href="#concept-canvas-color-type" id="2dcontext:concept-canvas-color-type">color type</a> of the rendering
    context.</p>

    <p>If the <code id="2dcontext:dom-canvasrenderingcontext2dsettings-willreadfrequently-3"><a href="#dom-canvasrenderingcontext2dsettings-willreadfrequently">willReadFrequently</a></code>
    member is true, then the context is marked for <a href="#concept-canvas-will-read-frequently" id="2dcontext:concept-canvas-will-read-frequently">readback optimization</a>.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-canvas" id="dom-context-2d-canvas-dev">canvas</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/canvas" title="The CanvasRenderingContext2D.canvas property, part of the Canvas API, is a read-only reference to the HTMLCanvasElement object that is associated with a given context. It might be null if there is no associated <canvas> element.">CanvasRenderingContext2D/canvas</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the <code id="2dcontext:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> element.</p></dd><dt><code><var>attributes</var> = <var>context</var>.<a href="#dom-context-2d-canvas-getcontextattributes" id="2dcontext:dom-context-2d-canvas-getcontextattributes-2">getContextAttributes</a>()</code></dt><dd>
    <p>Returns an object whose:</p>

    <ul><li><code id="2dcontext:concept-canvas-alpha"><a href="#concept-canvas-alpha">alpha</a></code> member is true if the context has an alpha
     component that is not 1.0; otherwise false.</li><li><code id="2dcontext:dom-canvasrenderingcontext2dsettings-desynchronized-4"><a href="#dom-canvasrenderingcontext2dsettings-desynchronized">desynchronized</a></code>
     member is true if the context can be <a href="#concept-canvas-desynchronized" id="2dcontext:concept-canvas-desynchronized-2">desynchronized</a>.</li><li><code id="2dcontext:dom-canvasrenderingcontext2dsettings-colorspace-4"><a href="#dom-canvasrenderingcontext2dsettings-colorspace">colorSpace</a></code> member is
     a string indicating the context's <a href="#concept-canvas-color-space" id="2dcontext:concept-canvas-color-space-2">color
     space</a>.</li><li><code id="2dcontext:dom-canvasrenderingcontext2dsettings-colortype-3"><a href="#dom-canvasrenderingcontext2dsettings-colortype">colorType</a></code> member is
     a string indicating the context's <a href="#concept-canvas-color-type" id="2dcontext:concept-canvas-color-type-2">color
     type</a>.</li><li><code id="2dcontext:dom-canvasrenderingcontext2dsettings-willreadfrequently-4"><a href="#dom-canvasrenderingcontext2dsettings-willreadfrequently">willReadFrequently</a></code>
     member is true if the context is marked for <a href="#concept-canvas-will-read-frequently" id="2dcontext:concept-canvas-will-read-frequently-2">readback
     optimization</a>.</li></ul>
   </dd></dl>

  

  <hr>

  <div data-algorithm="">
  <p>The <code id="2dcontext:canvasrenderingcontext2d-20"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> 2D rendering context represents a flat linear
  Cartesian surface whose origin (0,0) is at the top left corner, with the coordinate space having
  <var>x</var> values increasing when going right, and <var>y</var> values increasing when going
  down. The <var>x</var>-coordinate of the right-most edge is equal to the width of the rendering
  context's <a href="#output-bitmap" id="2dcontext:output-bitmap">output bitmap</a> in <a href="https://drafts.csswg.org/css-values/#px" id="2dcontext:'px'" data-x-internal="'px'">CSS pixels</a>; similarly, the
  <var>y</var>-coordinate of the bottom-most edge is equal to the height of the rendering context's
  <a href="#output-bitmap" id="2dcontext:output-bitmap-2">output bitmap</a> in <a href="https://drafts.csswg.org/css-values/#px" id="2dcontext:'px'-2" data-x-internal="'px'">CSS pixels</a>.</p>
  </div>

  <p>The size of the coordinate space does not necessarily represent the size of the actual bitmaps
  that the user agent will use internally or during rendering. On high-definition displays, for
  instance, the user agent may internally use bitmaps with four device pixels per unit in the
  coordinate space, so that the rendering remains at high quality throughout. Anti-aliasing can
  similarly be implemented using oversampling with bitmaps of a higher resolution than the final
  image on the display.</p>

  <div class="example">
   <p>Using <a href="https://drafts.csswg.org/css-values/#px" id="2dcontext:'px'-3" data-x-internal="'px'">CSS pixels</a> to describe the size of a rendering context's
   <a href="#output-bitmap" id="2dcontext:output-bitmap-3">output bitmap</a> does not mean that when rendered the canvas will cover an equivalent
   area in <a href="https://drafts.csswg.org/css-values/#px" id="2dcontext:'px'-4" data-x-internal="'px'">CSS pixels</a>. <a href="https://drafts.csswg.org/css-values/#px" id="2dcontext:'px'-5" data-x-internal="'px'">CSS pixels</a> are reused
   for ease of integration with CSS features, such as text layout.</p>

   <p>In other words, the <code id="2dcontext:the-canvas-element-3"><a href="#the-canvas-element">canvas</a></code> element below's rendering context has a 200x200
   <a href="#output-bitmap" id="2dcontext:output-bitmap-4">output bitmap</a> (which internally uses <a href="https://drafts.csswg.org/css-values/#px" id="2dcontext:'px'-6" data-x-internal="'px'">CSS pixels</a> as a
   unit for ease of integration with CSS) and is rendered as 100x100 <a href="https://drafts.csswg.org/css-values/#px" id="2dcontext:'px'-7" data-x-internal="'px'">CSS
   pixels</a>:

   </p><pre><code class="html"><c- p="">&lt;</c-><c- f="">canvas</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">200</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">200</c-> <c- e="">style</c-><c- o="">=</c-><c- s="">width:100px;height:100px</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="2d-context-creation-algorithm">2D context creation algorithm</dfn>, which is passed a <var>target</var> (a
  <code id="2dcontext:the-canvas-element-4"><a href="#the-canvas-element">canvas</a></code> element) and <var>options</var>, consists of running these steps:</p>

  <ol><li><p>Let <var>settings</var> be the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="2dcontext:concept-idl-convert" data-x-internal="concept-idl-convert">converting</a> <var>options</var> to the dictionary type
   <code id="2dcontext:canvasrenderingcontext2dsettings-2"><a href="#canvasrenderingcontext2dsettings">CanvasRenderingContext2DSettings</a></code>. (This can throw an exception.)</p></li><li><p>Let <var>context</var> be a new <code id="2dcontext:canvasrenderingcontext2d-21"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> object.</p></li><li><p>Initialize <var>context</var>'s <code id="2dcontext:dom-context-2d-canvas-2"><a href="#dom-context-2d-canvas">canvas</a></code>
   attribute to point to <var>target</var>.</p></li><li><p>Set <var>context</var>'s <a href="#output-bitmap" id="2dcontext:output-bitmap-5">output bitmap</a> to the same bitmap as
   <var>target</var>'s bitmap (so that they are shared).</p></li><li><p><a href="#concept-canvas-set-bitmap-dimensions" id="2dcontext:concept-canvas-set-bitmap-dimensions">Set bitmap dimensions</a> to
   <a href="#obtain-numeric-values" id="2dcontext:obtain-numeric-values">the numeric values</a> of <var>target</var>'s <code id="2dcontext:attr-canvas-width"><a href="#attr-canvas-width">width</a></code> and <code id="2dcontext:attr-canvas-height"><a href="#attr-canvas-height">height</a></code>
   content attributes.</p></li><li><p>Run the <a href="#canvas-setting-init-bitmap" id="2dcontext:canvas-setting-init-bitmap">canvas settings output bitmap
   initialization algorithm</a>, given <var>context</var> and <var>settings</var>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>When the user agent is to <dfn id="concept-canvas-set-bitmap-dimensions">set bitmap
  dimensions</dfn> to <var>width</var> and <var>height</var>, it must run these steps:</p>

  <ol><li><p><a href="#reset-the-rendering-context-to-its-default-state" id="2dcontext:reset-the-rendering-context-to-its-default-state-2">Reset the rendering context to its default state</a>.</p></li><li><p>Resize the <a href="#output-bitmap" id="2dcontext:output-bitmap-6">output bitmap</a> to the new <var>width</var> and
   <var>height</var>.</p></li><li><p>Let <var>canvas</var> be the <code id="2dcontext:the-canvas-element-5"><a href="#the-canvas-element">canvas</a></code> element to which the rendering
   context's <code id="2dcontext:dom-context-2d-canvas-3"><a href="#dom-context-2d-canvas">canvas</a></code> attribute was initialized.</p></li><li><p>If <a href="#obtain-numeric-values" id="2dcontext:obtain-numeric-values-2">the numeric value</a> of
   <var>canvas</var>'s <code id="2dcontext:attr-canvas-width-2"><a href="#attr-canvas-width">width</a></code> content
   attribute differs from <var>width</var>, then set <var>canvas</var>'s <code id="2dcontext:attr-canvas-width-3"><a href="#attr-canvas-width">width</a></code> content attribute to the shortest possible string
   representing <var>width</var> as a <a href="#valid-non-negative-integer" id="2dcontext:valid-non-negative-integer">valid non-negative integer</a>.</p></li><li><p>If <a href="#obtain-numeric-values" id="2dcontext:obtain-numeric-values-3">the numeric value</a> of
   <var>canvas</var>'s <code id="2dcontext:attr-canvas-height-2"><a href="#attr-canvas-height">height</a></code> content
   attribute differs from <var>height</var>, then set <var>canvas</var>'s <code id="2dcontext:attr-canvas-height-3"><a href="#attr-canvas-height">height</a></code> content attribute to the shortest possible string
   representing <var>height</var> as a <a href="#valid-non-negative-integer" id="2dcontext:valid-non-negative-integer-2">valid non-negative integer</a>.</p></li></ol>
  </div>

  <div class="example">
   <p>Only one square appears to be drawn in the following example:</p>
   <pre><code class="js"><c- c1="">// canvas is a reference to a &lt;canvas&gt; element</c->
<c- a="">var</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">);</c->
context<c- p="">.</c->fillRect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-><c- mf="">0</c-><c- p="">,</c-><c- mf="">50</c-><c- p="">,</c-><c- mf="">50</c-><c- p="">);</c->
canvas<c- p="">.</c->setAttribute<c- p="">(</c-><c- t="">'width'</c-><c- p="">,</c-> <c- t="">'300'</c-><c- p="">);</c-> <c- c1="">// clears the canvas</c->
context<c- p="">.</c->fillRect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-><c- mf="">100</c-><c- p="">,</c-><c- mf="">50</c-><c- p="">,</c-><c- mf="">50</c-><c- p="">);</c->
canvas<c- p="">.</c->width <c- o="">=</c-> canvas<c- p="">.</c->width<c- p="">;</c-> <c- c1="">// clears the canvas</c->
context<c- p="">.</c->fillRect<c- p="">(</c-><c- mf="">100</c-><c- p="">,</c-><c- mf="">0</c-><c- p="">,</c-><c- mf="">50</c-><c- p="">,</c-><c- mf="">50</c-><c- p="">);</c-> <c- c1="">// only this square remains</c-></code></pre>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasRenderingContext2D" id="dom-context-2d-canvas" data-dfn-type="attribute"><code>canvas</code></dfn> attribute must return the value it was
  initialized to when the object was created.</p>
  </div>

  

  <hr>

  <p>The <code id="2dcontext:canvascolortype-2"><a href="#canvascolortype">CanvasColorType</a></code> enumeration is used to specify the <a href="#concept-canvas-color-type" id="2dcontext:concept-canvas-color-type-3">color type</a> of the canvas's backing store.</p>

  <p>The "<dfn data-dfn-for="CanvasColorType" id="dom-canvascolortype-unorm8" data-dfn-type="enum-value"><code>unorm8</code></dfn>" value indicates that the type
  for all color components is 8-bit unsigned normalized.</p>

  <p>The "<dfn data-dfn-for="CanvasColorType" id="dom-canvascolortype-float16" data-dfn-type="enum-value"><code>float16</code></dfn>" value indicates that the type
  for all color components is 16-bit floating point.</p>

  <hr>

  <p>The <code id="2dcontext:canvasfillrule-7"><a href="#canvasfillrule">CanvasFillRule</a></code> enumeration is used to select the <dfn id="fill-rule">fill rule</dfn>
  algorithm by which to determine if a point is inside or outside a path.</p>

  <p>The "<dfn data-dfn-for="CanvasFillRule" id="dom-context-2d-fillrule-nonzero" data-dfn-type="enum-value"><code>nonzero</code></dfn>" value indicates the nonzero winding
  rule, wherein

     a point is considered to be outside a shape if the number of times a half-infinite straight
     line drawn from that point crosses the shape's path going in one direction is equal to the
     number of times it crosses the path going in the other direction.

  </p>


  <p>The "<dfn data-dfn-for="CanvasFillRule" id="dom-context-2d-fillrule-evenodd" data-dfn-type="enum-value"><code>evenodd</code></dfn>" value indicates the even-odd rule,
  wherein

     a point is considered to be outside a shape if the number of times a half-infinite straight
     line drawn from that point crosses the shape's path is even.

  </p>

  <p>If a point is not outside a shape, it is inside the shape.</p>


  <hr>

  <p>The <code id="2dcontext:imagesmoothingquality-2"><a href="#imagesmoothingquality">ImageSmoothingQuality</a></code> enumeration is used to express a preference for the
  interpolation quality to use when smoothing images.</p>

  <p>The "<dfn data-dfn-for="ImageSmoothingQuality" id="dom-context-2d-imagesmoothingquality-low" data-dfn-type="enum-value"><code>low</code></dfn>" value indicates a preference
  for a low level of image interpolation quality. Low-quality image interpolation may be more
  computationally efficient than higher settings.</p>

  <p>The "<dfn data-dfn-for="ImageSmoothingQuality" id="dom-context-2d-imagesmoothingquality-medium" data-dfn-type="enum-value"><code>medium</code></dfn>" value indicates a
  preference for a medium level of image interpolation quality.</p>

  <p>The "<dfn data-dfn-for="ImageSmoothingQuality" id="dom-context-2d-imagesmoothingquality-high" data-dfn-type="enum-value"><code>high</code></dfn>" value indicates a preference
  for a high level of image interpolation quality. High-quality image interpolation may be more
  computationally expensive than lower settings.</p>

  <p class="note">Bilinear scaling is an example of a relatively fast, lower-quality image-smoothing
  algorithm. Bicubic or Lanczos scaling are examples of image-smoothing algorithms that produce
  higher-quality output. This specification does not mandate that specific interpolation algorithms
  be used.</p>


  <h6 id="implementation-notes"><span class="secno">4.12.5.1.1</span> Implementation notes<a href="#implementation-notes" class="self-link"></a></h6>

  <p><i>This section is non-normative.</i></p>

  <p>The <a href="#output-bitmap" id="implementation-notes:output-bitmap">output bitmap</a>, when it is not directly displayed by the user agent,
  implementations can, instead of updating this bitmap, merely remember the sequence of drawing
  operations that have been applied to it until such time as the bitmap's actual data is needed
  (for example because of a call to <code id="implementation-notes:dom-context-2d-drawimage"><a href="#dom-context-2d-drawimage">drawImage()</a></code>, or
  the <code id="implementation-notes:dom-createimagebitmap"><a href="#dom-createimagebitmap">createImageBitmap()</a></code> factory method). In many
  cases, this will be more memory efficient.</p>

  <p>The bitmap of a <code id="implementation-notes:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element is the one bitmap that's pretty much always going
  to be needed in practice. The <a href="#output-bitmap" id="implementation-notes:output-bitmap-2">output bitmap</a> of a rendering context, when it has one,
  is always just an alias to a <code id="implementation-notes:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> element's bitmap.</p>

  <p>Additional bitmaps are sometimes needed, e.g. to enable fast drawing when the canvas is being
  painted at a different size than its <a href="https://drafts.csswg.org/css-images/#natural-dimensions" id="implementation-notes:natural-dimensions" data-x-internal="natural-dimensions">natural size</a>,
  or to enable double buffering so that graphics updates, like page scrolling for example, can be
  processed concurrently while canvas draw commands are being executed.</p>

  <h6 id="the-canvas-settings"><span class="secno">4.12.5.1.2</span> The canvas settings<a href="#the-canvas-settings" class="self-link"></a></h6>

  <p>A <code id="the-canvas-settings:canvassettings"><a href="#canvassettings">CanvasSettings</a></code> object has an <dfn id="output-bitmap">output bitmap</dfn> that is initialized when
  the object is created.</p>

  <p>The <a href="#output-bitmap" id="the-canvas-settings:output-bitmap">output bitmap</a> has an <a href="#concept-canvas-origin-clean" id="the-canvas-settings:concept-canvas-origin-clean">origin-clean</a> flag, which can be set to true or false.
  Initially, when one of these bitmaps is created, its <a href="#concept-canvas-origin-clean" id="the-canvas-settings:concept-canvas-origin-clean-2">origin-clean</a> flag must be set to true.</p>

  <p>The <code id="the-canvas-settings:canvassettings-2"><a href="#canvassettings">CanvasSettings</a></code> object also has an <dfn id="concept-canvas-alpha">alpha</dfn> boolean. When a <code id="the-canvas-settings:canvassettings-3"><a href="#canvassettings">CanvasSettings</a></code> object's
  <a href="#concept-canvas-alpha" id="the-canvas-settings:concept-canvas-alpha">alpha</a> is false, then its alpha component must be fixed
  to 1.0 (fully opaque) for all pixels, and attempts to change the alpha component of any pixel must
  be silently ignored.</p>

  <p class="note">Thus, the bitmap of such a context starts off as <a id="the-canvas-settings:opaque-black" href="https://drafts.csswg.org/css-color/#opaque-black" data-x-internal="opaque-black">opaque black</a> instead
  of <a id="the-canvas-settings:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>; <code id="the-canvas-settings:dom-context-2d-clearrect"><a href="#dom-context-2d-clearrect">clearRect()</a></code>
  always results in <a id="the-canvas-settings:opaque-black-2" href="https://drafts.csswg.org/css-color/#opaque-black" data-x-internal="opaque-black">opaque black</a> pixels, every fourth byte from <code id="the-canvas-settings:dom-context-2d-getimagedata"><a href="#dom-context-2d-getimagedata">getImageData()</a></code> is always 255, the <code id="the-canvas-settings:dom-context-2d-putimagedata"><a href="#dom-context-2d-putimagedata">putImageData()</a></code> method effectively ignores every fourth
  byte in its input, and so on. However, the alpha component of styles and images drawn onto the
  canvas are still honoured up to the point where they would impact the <a href="#output-bitmap" id="the-canvas-settings:output-bitmap-2">output bitmap</a>'s
  alpha component; for instance, drawing a 50% transparent white square on a freshly created
  <a href="#output-bitmap" id="the-canvas-settings:output-bitmap-3">output bitmap</a> with its <a href="#concept-canvas-alpha" id="the-canvas-settings:concept-canvas-alpha-2">alpha</a> set to false
  will result in a fully-opaque gray square.</p>

  <p>The <code id="the-canvas-settings:canvassettings-4"><a href="#canvassettings">CanvasSettings</a></code> object also has a <dfn id="concept-canvas-desynchronized">desynchronized</dfn> boolean. When a
  <code id="the-canvas-settings:canvassettings-5"><a href="#canvassettings">CanvasSettings</a></code> object's <a href="#concept-canvas-desynchronized" id="the-canvas-settings:concept-canvas-desynchronized">desynchronized</a> is true, then the user agent may
  optimize the rendering of the canvas to reduce the latency, as measured from input events to
  rasterization, by desynchronizing the canvas paint cycle from the event loop, bypassing the
  ordinary user agent rendering algorithm, or both. Insofar as this mode involves bypassing the
  usual paint mechanisms, rasterization, or both, it might introduce visible tearing artifacts.</p>

  <p class="note">The user agent usually renders on a buffer which is not being displayed, quickly
  swapping it and the one being scanned out for presentation; the former buffer is called back
  buffer and the latter <i>front buffer</i>. A popular technique for reducing latency is called
  front buffer rendering, also known as <i>single buffer</i> rendering, where rendering happens in
  parallel and racily with the scanning out process. This technique reduces the latency at the price
  of potentially introducing tearing artifacts and can be used to implement in total or part of the
  <a href="#concept-canvas-desynchronized" id="the-canvas-settings:concept-canvas-desynchronized-2">desynchronized</a> boolean.
  <a href="#refsMULTIPLEBUFFERING">[MULTIPLEBUFFERING]</a></p>

  <p class="note">The <a href="#concept-canvas-desynchronized" id="the-canvas-settings:concept-canvas-desynchronized-3">desynchronized</a> boolean can
  be useful when implementing certain kinds of applications, such as drawing applications, where the
  latency between input and rasterization is critical.</p>

  <p>The <code id="the-canvas-settings:canvassettings-6"><a href="#canvassettings">CanvasSettings</a></code> object also has a <dfn id="concept-canvas-will-read-frequently">will read frequently</dfn> boolean. When a
  <code id="the-canvas-settings:canvassettings-7"><a href="#canvassettings">CanvasSettings</a></code> object's <a href="#concept-canvas-will-read-frequently" id="the-canvas-settings:concept-canvas-will-read-frequently">will read
  frequently</a> is true, the user agent may optimize the canvas for readback operations.</p>

  <p class="note">On most devices the user agent needs to decide whether to store the canvas's
  <a href="#output-bitmap" id="the-canvas-settings:output-bitmap-4">output bitmap</a> on the GPU (this is also called "hardware accelerated"), or on the CPU
  (also called "software"). Most rendering operations are more performant for accelerated canvases,
  with the major exception being readback with <code id="the-canvas-settings:dom-context-2d-getimagedata-2"><a href="#dom-context-2d-getimagedata">getImageData()</a></code>, <code id="the-canvas-settings:dom-canvas-todataurl"><a href="#dom-canvas-todataurl">toDataURL()</a></code>, or <code id="the-canvas-settings:dom-canvas-toblob"><a href="#dom-canvas-toblob">toBlob()</a></code>. <code id="the-canvas-settings:canvassettings-8"><a href="#canvassettings">CanvasSettings</a></code> objects with <a href="#concept-canvas-will-read-frequently" id="the-canvas-settings:concept-canvas-will-read-frequently-2">will read frequently</a> equal to true tell the
  user agent that the webpage is likely to perform many readback operations and that it is
  advantageous to use a software canvas.</p>

  <p>The <code id="the-canvas-settings:canvassettings-9"><a href="#canvassettings">CanvasSettings</a></code> object also has a <dfn id="concept-canvas-color-space">color space</dfn> setting of type
  <code id="the-canvas-settings:predefinedcolorspace"><a href="#predefinedcolorspace">PredefinedColorSpace</a></code>. The <code id="the-canvas-settings:canvassettings-10"><a href="#canvassettings">CanvasSettings</a></code> object's <a href="#concept-canvas-color-space" id="the-canvas-settings:concept-canvas-color-space">color space</a> indicates the color space for the
  <a href="#output-bitmap" id="the-canvas-settings:output-bitmap-5">output bitmap</a>.</p>

  <p>The <code id="the-canvas-settings:canvassettings-11"><a href="#canvassettings">CanvasSettings</a></code> object also has a <dfn id="concept-canvas-color-type">color type</dfn> setting of type
  <code id="the-canvas-settings:canvascolortype"><a href="#canvascolortype">CanvasColorType</a></code>. The <code id="the-canvas-settings:canvassettings-12"><a href="#canvassettings">CanvasSettings</a></code> object's <a href="#concept-canvas-color-type" id="the-canvas-settings:concept-canvas-color-type">color type</a> indicates the data type of the
  color and alpha components of the pixels of the <a href="#output-bitmap" id="the-canvas-settings:output-bitmap-6">output bitmap</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="canvas-setting-init-bitmap">initialize a <code>CanvasSettings</code> output
  bitmap</dfn>, given a <code id="the-canvas-settings:canvassettings-13"><a href="#canvassettings">CanvasSettings</a></code> <var>context</var> and a
  <code id="the-canvas-settings:canvasrenderingcontext2dsettings"><a href="#canvasrenderingcontext2dsettings">CanvasRenderingContext2DSettings</a></code> <var>settings</var>:</p>

  <ol><li><p>Set <var>context</var>'s <a href="#concept-canvas-alpha" id="the-canvas-settings:concept-canvas-alpha-3">alpha</a> to
   <var>settings</var>["<dfn data-dfn-for="CanvasRenderingContext2DSettings" id="dom-canvasrenderingcontext2dsettings-alpha" data-dfn-type="dict-member"><code>alpha</code></dfn>"].</p></li><li><p>Set <var>context</var>'s <a href="#concept-canvas-desynchronized" id="the-canvas-settings:concept-canvas-desynchronized-4">desynchronized</a> to <var>settings</var>["<dfn data-dfn-for="CanvasRenderingContext2DSettings" id="dom-canvasrenderingcontext2dsettings-desynchronized" data-dfn-type="dict-member"><code>desynchronized</code></dfn>"].</p></li><li><p>Set <var>context</var>'s <a href="#concept-canvas-color-space" id="the-canvas-settings:concept-canvas-color-space-2">color space</a> to
   <var>settings</var>["<dfn data-dfn-for="CanvasRenderingContext2DSettings" id="dom-canvasrenderingcontext2dsettings-colorspace" data-dfn-type="dict-member"><code>colorSpace</code></dfn>"].</p></li><li><p>Set <var>context</var>'s <a href="#concept-canvas-color-type" id="the-canvas-settings:concept-canvas-color-type-2">color type</a> to
   <var>settings</var>["<dfn data-dfn-for="CanvasRenderingContext2DSettings" id="dom-canvasrenderingcontext2dsettings-colortype" data-dfn-type="dict-member"><code>colorType</code></dfn>"].</p></li><li><p>Set <var>context</var>'s <a href="#concept-canvas-will-read-frequently" id="the-canvas-settings:concept-canvas-will-read-frequently-3">will read
   frequently</a> to <var>settings</var>["<dfn data-dfn-for="CanvasRenderingContext2DSettings" id="dom-canvasrenderingcontext2dsettings-willreadfrequently" data-dfn-type="dict-member"><code>willReadFrequently</code></dfn>"].</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasSettings" id="dom-context-2d-canvas-getcontextattributes" data-dfn-type="method"><code>getContextAttributes()</code></dfn> method
  steps are to return «[ "<code id="the-canvas-settings:dom-canvasrenderingcontext2dsettings-alpha"><a href="#dom-canvasrenderingcontext2dsettings-alpha">alpha</a></code>" →
  <a id="the-canvas-settings:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-alpha" id="the-canvas-settings:concept-canvas-alpha-4">alpha</a>, "<code id="the-canvas-settings:dom-canvasrenderingcontext2dsettings-desynchronized"><a href="#dom-canvasrenderingcontext2dsettings-desynchronized">desynchronized</a></code>" →
  <a id="the-canvas-settings:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-desynchronized" id="the-canvas-settings:concept-canvas-desynchronized-5">desynchronized</a>, "<code id="the-canvas-settings:dom-canvasrenderingcontext2dsettings-colorspace"><a href="#dom-canvasrenderingcontext2dsettings-colorspace">colorSpace</a></code>" → <a id="the-canvas-settings:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#concept-canvas-color-space" id="the-canvas-settings:concept-canvas-color-space-3">color space</a>, "<code id="the-canvas-settings:dom-canvasrenderingcontext2dsettings-colortype"><a href="#dom-canvasrenderingcontext2dsettings-colortype">colorType</a></code>" → <a id="the-canvas-settings:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#concept-canvas-color-type" id="the-canvas-settings:concept-canvas-color-type-3">color type</a>, "<code id="the-canvas-settings:dom-canvasrenderingcontext2dsettings-willreadfrequently"><a href="#dom-canvasrenderingcontext2dsettings-willreadfrequently">willReadFrequently</a></code>" →
  <a id="the-canvas-settings:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-will-read-frequently" id="the-canvas-settings:concept-canvas-will-read-frequently-4">will read frequently</a>
  ]».</p>
  </div>

  <h6 id="the-canvas-state"><span class="secno">4.12.5.1.3</span> The canvas state<a href="#the-canvas-state" class="self-link"></a></h6>

  <p>Objects that implement the <code id="the-canvas-state:canvasstate"><a href="#canvasstate">CanvasState</a></code> interface maintain a stack of drawing
  states. <dfn id="drawing-state">Drawing states</dfn> consist of:</p>

  <ul><li><p>The current <a href="#transformations" id="the-canvas-state:transformations">transformation
   matrix</a>.</p></li><li><p>The current <a href="#clipping-region" id="the-canvas-state:clipping-region">clipping region</a>.</p></li><li><p>The current <a href="#concept-canvastextdrawingstyles-letter-spacing" id="the-canvas-state:concept-canvastextdrawingstyles-letter-spacing">letter
   spacing</a>, <a href="#concept-canvastextdrawingstyles-word-spacing" id="the-canvas-state:concept-canvastextdrawingstyles-word-spacing">word spacing</a>,
   <a href="#concept-canvasfillstrokestyles-fill-style" id="the-canvas-state:concept-canvasfillstrokestyles-fill-style">fill style</a>, <a href="#concept-canvasfillstrokestyles-stroke-style" id="the-canvas-state:concept-canvasfillstrokestyles-stroke-style">stroke style</a>, <a href="#concept-canvas-current-filter" id="the-canvas-state:concept-canvas-current-filter">filter</a>, <a href="#concept-canvas-global-alpha" id="the-canvas-state:concept-canvas-global-alpha">global alpha</a>, <a href="#current-compositing-and-blending-operator" id="the-canvas-state:current-compositing-and-blending-operator">compositing and blending operator</a>, and <a href="#concept-canvasshadowstyles-shadow-color" id="the-canvas-state:concept-canvasshadowstyles-shadow-color">shadow color</a>.</p></li><li><p>The current values of the following attributes: <code id="the-canvas-state:dom-context-2d-linewidth"><a href="#dom-context-2d-linewidth">lineWidth</a></code>, <code id="the-canvas-state:dom-context-2d-linecap"><a href="#dom-context-2d-linecap">lineCap</a></code>, <code id="the-canvas-state:dom-context-2d-linejoin"><a href="#dom-context-2d-linejoin">lineJoin</a></code>, <code id="the-canvas-state:dom-context-2d-miterlimit"><a href="#dom-context-2d-miterlimit">miterLimit</a></code>, <code id="the-canvas-state:dom-context-2d-linedashoffset"><a href="#dom-context-2d-linedashoffset">lineDashOffset</a></code>, <code id="the-canvas-state:dom-context-2d-shadowoffsetx"><a href="#dom-context-2d-shadowoffsetx">shadowOffsetX</a></code>, <code id="the-canvas-state:dom-context-2d-shadowoffsety"><a href="#dom-context-2d-shadowoffsety">shadowOffsetY</a></code>, <code id="the-canvas-state:dom-context-2d-shadowblur"><a href="#dom-context-2d-shadowblur">shadowBlur</a></code>, <code id="the-canvas-state:dom-context-2d-lang"><a href="#dom-context-2d-lang">lang</a></code>, <code id="the-canvas-state:dom-context-2d-font"><a href="#dom-context-2d-font">font</a></code>, <code id="the-canvas-state:dom-context-2d-textalign"><a href="#dom-context-2d-textalign">textAlign</a></code>, <code id="the-canvas-state:dom-context-2d-textbaseline"><a href="#dom-context-2d-textbaseline">textBaseline</a></code>, <code id="the-canvas-state:dom-context-2d-direction"><a href="#dom-context-2d-direction">direction</a></code>, <code id="the-canvas-state:dom-context-2d-fontkerning"><a href="#dom-context-2d-fontkerning">fontKerning</a></code>, <code id="the-canvas-state:dom-context-2d-fontstretch"><a href="#dom-context-2d-fontstretch">fontStretch</a></code>, <code id="the-canvas-state:dom-context-2d-fontvariantcaps"><a href="#dom-context-2d-fontvariantcaps">fontVariantCaps</a></code>, <code id="the-canvas-state:dom-context-2d-textrendering"><a href="#dom-context-2d-textrendering">textRendering</a></code>, <code id="the-canvas-state:dom-context-2d-imagesmoothingenabled"><a href="#dom-context-2d-imagesmoothingenabled">imageSmoothingEnabled</a></code>, <code id="the-canvas-state:dom-context-2d-imagesmoothingquality"><a href="#dom-context-2d-imagesmoothingquality">imageSmoothingQuality</a></code>.</p></li><li><p>The current <a href="#dash-list" id="the-canvas-state:dash-list">dash list</a>.</p></li></ul>

  <p class="note">The rendering context's bitmaps are not part of the drawing state, as they
  depend on whether and how the rendering context is bound to a <code id="the-canvas-state:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element.</p>

  <p>Objects that implement the <code id="the-canvas-state:canvasstate-2"><a href="#canvasstate">CanvasState</a></code> mixin have a <dfn id="concept-canvas-context-lost">context lost</dfn> boolean, that is initialized to false
  when the object is created. The <a href="#concept-canvas-context-lost" id="the-canvas-state:concept-canvas-context-lost">context lost</a>
  value is updated in the <a href="#context-lost-steps" id="the-canvas-state:context-lost-steps">context lost steps</a>.</p>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-save" id="dom-context-2d-save-dev">save</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save" title="The CanvasRenderingContext2D.save() method of the Canvas 2D API saves the entire state of the canvas by pushing the current state onto a stack.">CanvasRenderingContext2D/save</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Pushes the current state onto the stack.</p></dd><dt><code><var>context</var>.<a href="#dom-context-2d-restore" id="dom-context-2d-restore-dev">restore</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/restore" title="The CanvasRenderingContext2D.restore() method of the Canvas 2D API restores the most recently saved canvas state by popping the top entry in the drawing state stack. If there is no saved state, this method does nothing.">CanvasRenderingContext2D/restore</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Pops the top state on the stack, restoring the context to that state.</p></dd><dt><code><var>context</var>.<a href="#dom-context-2d-reset" id="dom-context-2d-reset-dev">reset</a>()</code></dt><dd><p>Resets the rendering context, which includes the backing buffer, the drawing state stack,
   path, and styles.</p></dd><dt><code><var>context</var>.<a href="#dom-context-2d-iscontextlost" id="dom-context-2d-iscontextlost-dev">isContextLost</a>()</code></dt><dd><p>Returns true if the rendering context was lost. Context loss can occur due to driver
   crashes, running out of memory, etc. In these cases, the canvas loses its backing storage and
   takes steps to <a href="#reset-the-rendering-context-to-its-default-state" id="the-canvas-state:reset-the-rendering-context-to-its-default-state">reset the rendering context to its default state</a>.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasState" id="dom-context-2d-save" data-dfn-type="method"><code>save()</code></dfn> method
  steps are to push a copy of the current drawing state onto the drawing state stack.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasState" id="dom-context-2d-restore" data-dfn-type="method"><code>restore()</code></dfn>
  method steps are to pop the top entry in the drawing state stack, and reset the drawing state it
  describes. If there is no saved state, then the method must do nothing.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/reset" title="The CanvasRenderingContext2D.reset() method of the Canvas 2D API resets the rendering context to its default state, allowing it to be reused for drawing something else without having to explicitly reset all the properties.">CanvasRenderingContext2D/reset</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>113+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvasRenderingContext2D#canvasrenderingcontext2d.reset" title="The OffscreenCanvasRenderingContext2D interface is a CanvasRenderingContext2D rendering context for drawing to the bitmap of an OffscreenCanvas object. It is similar to the CanvasRenderingContext2D object, with the following differences:">OffscreenCanvasRenderingContext2D#canvasrenderingcontext2d.reset</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>113+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasState" id="dom-context-2d-reset" data-dfn-type="method"><code>reset()</code></dfn>
  method steps are to <a href="#reset-the-rendering-context-to-its-default-state" id="the-canvas-state:reset-the-rendering-context-to-its-default-state-2">reset the rendering context to its default state</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="reset-the-rendering-context-to-its-default-state">reset the rendering context to its default state</dfn>:</p>

  <ol><li><p>Clear canvas's bitmap to <a id="the-canvas-state:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>.</p></li><li><p>Empty the list of subpaths in context's <a href="#current-default-path" id="the-canvas-state:current-default-path">current default path</a>.</p></li><li><p>Clear the context's drawing state stack.</p></li><li><p>Reset everything that <a href="#drawing-state" id="the-canvas-state:drawing-state">drawing state</a> consists of to their initial
   values.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/isContextLost" title="The CanvasRenderingContext2D.isContextLost() method of the Canvas 2D API returns true if the rendering context is lost (and has not yet been reset). This might occur due to driver crashes, running out of memory, and so on.">CanvasRenderingContext2D/isContextLost</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasState" id="dom-context-2d-iscontextlost" data-dfn-type="method"><code>isContextLost()</code></dfn> method steps are to return
  <a id="the-canvas-state:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-context-lost" id="the-canvas-state:concept-canvas-context-lost-2">context lost</a>.</p>
  </div>

  

  <h6 id="line-styles"><span class="secno">4.12.5.1.4</span> Line styles<a href="#line-styles" class="self-link"></a></h6>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-linewidth" id="dom-context-2d-linewidth-dev">lineWidth</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineWidth" title="The CanvasRenderingContext2D.lineWidth property of the Canvas 2D API sets the thickness of lines.">CanvasRenderingContext2D/lineWidth</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-linewidth" id="line-styles:dom-context-2d-linewidth">lineWidth</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current line width.</p>

    <p>Can be set, to change the line width. Values that are not finite values greater than zero are
    ignored.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-linecap" id="dom-context-2d-linecap-dev">lineCap</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap" title="The CanvasRenderingContext2D.lineCap property of the Canvas 2D API determines the shape used to draw the end points of lines.">CanvasRenderingContext2D/lineCap</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-linecap" id="line-styles:dom-context-2d-linecap">lineCap</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current line cap style.</p>

    <p>Can be set, to change the line cap style.</p>

    <p>The possible line cap styles are "<code>butt</code>", "<code>round</code>", and "<code>square</code>". Other values are ignored.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-linejoin" id="dom-context-2d-linejoin-dev">lineJoin</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin" title="The CanvasRenderingContext2D.lineJoin property of the Canvas 2D API determines the shape used to join two line segments where they meet.">CanvasRenderingContext2D/lineJoin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-linejoin" id="line-styles:dom-context-2d-linejoin">lineJoin</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current line join style.</p>

    <p>Can be set, to change the line join style.</p>

    <p>The possible line join styles are "<code>bevel</code>", "<code>round</code>", and "<code>miter</code>". Other values are ignored.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-miterlimit" id="dom-context-2d-miterlimit-dev">miterLimit</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit" title="The CanvasRenderingContext2D.miterLimit property of the Canvas 2D API sets the miter limit ratio.">CanvasRenderingContext2D/miterLimit</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-miterlimit" id="line-styles:dom-context-2d-miterlimit">miterLimit</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current miter limit ratio.</p>

    <p>Can be set, to change the miter limit ratio. Values that are not finite values greater than
    zero are ignored.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-setlinedash" id="dom-context-2d-setlinedash-dev">setLineDash</a>(<var>segments</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash" title="The setLineDash() method of the Canvas 2D API's CanvasRenderingContext2D interface sets the line dash pattern used when stroking lines. It uses an array of values that specify alternating lengths of lines and gaps which describe the pattern.">CanvasRenderingContext2D/setLineDash</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>27+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-setlinedash" id="line-styles:dom-context-2d-setlinedash">setLineDash</a>(<var>segments</var>)</code></dt><dd>
    <p>Sets the current line dash pattern (as used when stroking). The argument is a list of
    distances for which to alternately have the line on and the line off.</p>
   </dd><dt><code><var>segments</var> = <var>context</var>.<a href="#dom-context-2d-getlinedash" id="dom-context-2d-getlinedash-dev">getLineDash</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getLineDash" title="The getLineDash() method of the Canvas 2D API's CanvasRenderingContext2D interface gets the current line dash pattern.">CanvasRenderingContext2D/getLineDash</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>27+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>segments</var> = <var>styles</var>.<a href="#dom-context-2d-getlinedash" id="line-styles:dom-context-2d-getlinedash">getLineDash</a>()</code></dt><dd>
    <p>Returns a copy of the current line dash pattern. The array returned will always have an even
    number of entries (i.e. the pattern is normalized).</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-linedashoffset" id="dom-context-2d-linedashoffset-dev">lineDashOffset</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset" title="The CanvasRenderingContext2D.lineDashOffset property of the Canvas 2D API sets the line dash offset, or &quot;phase.&quot;">CanvasRenderingContext2D/lineDashOffset</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>27+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>23+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-linedashoffset" id="line-styles:dom-context-2d-linedashoffset">lineDashOffset</a></code></dt><dd>
    <p>Returns the phase offset (in the same units as the line dash pattern).</p>

    <p>Can be set, to change the phase offset. Values that are not finite values are ignored.</p>
   </dd></dl>

  

  <p>Objects that implement the <code id="line-styles:canvaspathdrawingstyles"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> interface have attributes and
  methods (defined in this section) that control how lines are treated by the object.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPathDrawingStyles" id="dom-context-2d-linewidth" data-dfn-type="attribute"><code>lineWidth</code></dfn> attribute gives the width of lines, in
  coordinate space units. On getting, it must return the current value. On setting, zero, negative,
  infinite, and NaN values must be ignored, leaving the value unchanged; other values must change
  the current value to the new value.</p>
  </div>

  <p>When the object implementing the <code id="line-styles:canvaspathdrawingstyles-2"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> interface is created, the
  <code id="line-styles:dom-context-2d-linewidth-2"><a href="#dom-context-2d-linewidth">lineWidth</a></code> attribute must initially have the value
  1.0.</p>

  <hr>

  <p>The <dfn data-dfn-for="CanvasPathDrawingStyles" id="dom-context-2d-linecap" data-dfn-type="attribute"><code>lineCap</code></dfn> attribute defines the type of endings that
  UAs will place on the end of lines. The three valid values are "<code>butt</code>",
  "<code>round</code>", and "<code>square</code>".</p>

  <div data-algorithm="">
  <p>On getting, it must return the current value. On setting, the current value must be changed
  to the new value.</p>
  </div>

  <p>When the object implementing the <code id="line-styles:canvaspathdrawingstyles-3"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> interface is created, the
  <code id="line-styles:dom-context-2d-linecap-2"><a href="#dom-context-2d-linecap">lineCap</a></code> attribute must initially have the value
  "<code>butt</code>".</p>

  <hr>

  <p>The <dfn data-dfn-for="CanvasPathDrawingStyles" id="dom-context-2d-linejoin" data-dfn-type="attribute"><code>lineJoin</code></dfn> attribute defines the type of corners that
  UAs will place where two lines meet. The three valid values are "<code>bevel</code>",
  "<code>round</code>", and "<code>miter</code>".</p>

  <div data-algorithm="">
  <p>On getting, it must return the current value. On setting, the current value must be changed
  to the new value.</p>
  </div>

  <p>When the object implementing the <code id="line-styles:canvaspathdrawingstyles-4"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> interface is created, the
  <code id="line-styles:dom-context-2d-linejoin-2"><a href="#dom-context-2d-linejoin">lineJoin</a></code> attribute must initially have the value
  "<code>miter</code>".</p>

  <hr>

  <div data-algorithm="">
  <p>When the <code id="line-styles:dom-context-2d-linejoin-3"><a href="#dom-context-2d-linejoin">lineJoin</a></code> attribute has the value "<code>miter</code>", strokes use the miter limit ratio to decide how to render joins. The
  miter limit ratio can be explicitly set using the <dfn data-dfn-for="CanvasPathDrawingStyles" id="dom-context-2d-miterlimit" data-dfn-type="attribute"><code>miterLimit</code></dfn>
  attribute. On getting, it must return the current value. On setting, zero, negative, infinite, and
  NaN values must be ignored, leaving the value unchanged; other values must change the current
  value to the new value.</p>
  </div>
  

  <p>When the object implementing the <code id="line-styles:canvaspathdrawingstyles-5"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> interface is created, the
  <code id="line-styles:dom-context-2d-miterlimit-2"><a href="#dom-context-2d-miterlimit">miterLimit</a></code> attribute must initially have the value
  10.0.</p>

  <hr>

  <p>Each <code id="line-styles:canvaspathdrawingstyles-6"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> object has a <dfn id="dash-list">dash list</dfn>, which is either
  empty or consists of an even number of non-negative numbers. Initially, the <a href="#dash-list" id="line-styles:dash-list">dash list</a>
  must be empty.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPathDrawingStyles" id="dom-context-2d-setlinedash" data-dfn-type="method"><code>setLineDash(<var>segments</var>)</code></dfn> method, when invoked, must run
  these steps:</p>

  <ol><li><p>If any value in <var>segments</var> is not finite (e.g. an Infinity or a NaN value), or
   if any value is negative (less than zero), then return (without throwing an exception;
   user agents could show a message on a developer console, though, as that would be helpful for
   debugging).</p></li><li><p>If the number of elements in <var>segments</var> is odd, then let <var>segments</var>
   be the concatenation of two copies of <var>segments</var>.</p></li><li><p>Set the object's <a href="#dash-list" id="line-styles:dash-list-2">dash list</a> to <var>segments</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the <dfn data-dfn-for="CanvasPathDrawingStyles" id="dom-context-2d-getlinedash" data-dfn-type="method"><code>getLineDash()</code></dfn> method is invoked, it must return a
  sequence whose values are the values of the object's <a href="#dash-list" id="line-styles:dash-list-3">dash list</a>, in the same
  order.</p>
  </div>

  <div data-algorithm="">
  <p>It is sometimes useful to change the "phase" of the dash pattern, e.g. to achieve a "marching
  ants" effect. The phase can be set using the <dfn data-dfn-for="CanvasPathDrawingStyles" id="dom-context-2d-linedashoffset" data-dfn-type="attribute"><code>lineDashOffset</code></dfn> attribute. On getting, it must
  return the current value. On setting, infinite and NaN values must be ignored, leaving the value
  unchanged; other values must change the current value to the new value.</p>
  </div>

  <p>When the object implementing the <code id="line-styles:canvaspathdrawingstyles-7"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> interface is created, the
  <code id="line-styles:dom-context-2d-linedashoffset-2"><a href="#dom-context-2d-linedashoffset">lineDashOffset</a></code> attribute must initially have
  the value 0.0.</p>

  <hr>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="trace-a-path">trace a path</dfn>, given an object <var>style</var>
  that implements the <code id="line-styles:canvaspathdrawingstyles-8"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> interface, it must run the following
  algorithm. This algorithm returns a new <a href="#concept-path" id="line-styles:concept-path">path</a>.</p>

  <ol><li><p>Let <var>path</var> be a copy of the path being traced.</p></li><li><p>Prune all zero-length <a href="#line-segments" id="line-styles:line-segments">line segments</a> from <var>path</var>.</p></li><li><p>Remove from <var>path</var> any subpaths containing no lines (i.e. subpaths with
   just one point).</p></li><li><p>Replace each point in each subpath of <var>path</var> other than the first point
   and the last point of each subpath by a <i>join</i> that joins the line leading to that point to
   the line leading out of that point, such that the subpaths all consist of two points (a starting
   point with a line leading out of it, and an ending point with a line leading into it), one or
   more lines (connecting the points and the joins), and zero or more joins (each connecting one
   line to another), connected together such that each subpath is a series of one or more lines with
   a join between each one and a point on each end.</p></li><li><p>Add a straight closing line to each closed subpath in <var>path</var> connecting
   the last point and the first point of that subpath; change the last point to a join (from the
   previously last line to the newly added closing line), and change the first point to a join (from
   the newly added closing line to the first line).</p>

   </li><li><p>If <var>style</var>'s <a href="#dash-list" id="line-styles:dash-list-4">dash list</a> is empty, then jump to the step
   labeled <i>convert</i>.</p></li><li><p>Let <var>pattern width</var> be the concatenation of all the entries of
   <var>style</var>'s <a href="#dash-list" id="line-styles:dash-list-5">dash list</a>, in coordinate space units.</p>

   </li><li><p>For each subpath <var>subpath</var> in <var>path</var>, run the
   following substeps. These substeps mutate the subpaths in <var>path</var> <i>in
   vivo</i>.</p>

    <ol><li><p>Let <var>subpath width</var> be the length of all the lines of <var>subpath</var>, in coordinate space units.</p>

     </li><li><p>Let <var>offset</var> be the value of <var>style</var>'s <code id="line-styles:dom-context-2d-linedashoffset-3"><a href="#dom-context-2d-linedashoffset">lineDashOffset</a></code>, in coordinate space
     units.</p></li><li>
      <p>While <var>offset</var> is greater than <var>pattern width</var>,
      decrement it by <var>pattern width</var>.</p>

      <p>While <var>offset</var> is less than zero, increment it by <var>pattern
      width</var>.</p>
     </li><li><p>Define <var>L</var> to be a linear coordinate line defined along all lines in
     <var>subpath</var>, such that the start of the first line in the subpath is defined
     as coordinate 0, and the end of the last line in the subpath is defined as coordinate <var>subpath width</var>.</p></li><li><p>Let <var>position</var> be 0 minus <var>offset</var>.</p></li><li><p>Let <var>index</var> be 0.</p></li><li><p>Let <var>current state</var> be <i>off</i> (the other states being <i>on</i>
     and <i>zero-on</i>).</p></li><li><p><i>Dash on</i>: Let <var>segment length</var> be
     the value of <var>style</var>'s <a href="#dash-list" id="line-styles:dash-list-6">dash
     list</a>'s <var>index</var>th entry.</p></li><li><p>Increment <var>position</var> by <var>segment length</var>.</p></li><li><p>If <var>position</var> is greater than <var>subpath width</var>,
     then end these substeps for this subpath and start them again for the next subpath; if there
     are no more subpaths, then jump to the step labeled <i>convert</i> instead.</p></li><li><p>If <var>segment length</var> is nonzero, then let <var>current state</var> be
     <i>on</i>.</p></li><li><p>Increment <var>index</var> by one.</p></li><li><p><i>Dash off</i>: Let <var>segment
     length</var> be the value of <var>style</var>'s <a href="#dash-list" id="line-styles:dash-list-7">dash list</a>'s <var>index</var>th entry.</p></li><li><p>Let <var>start</var> be the offset <var>position</var> on <var>L</var>.</p></li><li><p>Increment <var>position</var> by <var>segment length</var>.</p></li><li><p>If <var>position</var> is less than zero, then jump to the step labeled
     <i>post-cut</i>.</p></li><li><p>If <var>start</var> is less than zero, then let <var>start</var> be
     zero.</p></li><li><p>If <var>position</var> is greater than <var>subpath width</var>,
     then let <var>end</var> be the offset <var>subpath width</var> on <var>L</var>. Otherwise, let <var>end</var> be the offset <var>position</var> on <var>L</var>.</p></li><li>
      <p>Jump to the first appropriate step:</p>

      <dl class="switch"><dt>If <var>segment length</var> is zero and <var>current state</var> is
       <i>off</i></dt><dd>
        <p>Do nothing, just continue to the next step.</p>
       </dd><dt>If <var>current state</var> is <i>off</i></dt><dd>
        <p>Cut the line on which <var>end</var> finds itself short at <var>end</var> and place a point there, cutting in two the subpath that it was in;
        remove all line segments, joins, points, and subpaths that are between <var>start</var> and <var>end</var>; and finally place a single point at <var>start</var> with no lines connecting to it.</p>

        <p>The point has a <i>directionality</i> for the purposes of drawing line caps (see below).
        The directionality is the direction that the original line had at that point (i.e. when <var>L</var> was defined above).</p>
       </dd><dt>Otherwise</dt><dd>
        <p>Cut the line on which <var>start</var> finds itself into two at <var>start</var> and place a point there, cutting in two the subpath that it was in, and
        similarly cut the line on which <var>end</var> finds itself short at <var>end</var> and place a point there, cutting in two the subpath that <em>it</em> was in,
        and then remove all line segments, joins, points, and subpaths that are between <var>start</var> and <var>end</var>.</p>

        <p>If <var>start</var> and <var>end</var> are the same point, then this
        results in just the line being cut in two and two points being inserted there, with nothing
        being removed, unless a join also happens to be at that point, in which case the join must
        be removed.</p>
       </dd></dl>
     </li><li><p><i>Post-cut</i>: If <var>position</var> is greater than <var>subpath width</var>, then jump to the step labeled <i>convert</i>.</p></li><li><p>Increment <var>index</var> by one. If it is equal to the number of entries in
     <var>style</var>'s <a href="#dash-list" id="line-styles:dash-list-8">dash list</a>, then let <var>index</var> be
     0.</p></li><li><p>Return to the step labeled <i>dash on</i>.</p></li></ol>
   </li><li>
    <p><i>Convert</i>: This is the step that converts the path to a new path that represents its
    stroke.</p>

    <p>Create a new <a href="#concept-path" id="line-styles:concept-path-2">path</a> that describes the edge of the areas
    that would be covered if a straight line of length equal to <var>style</var>'s
    <code id="line-styles:dom-context-2d-linewidth-3"><a href="#dom-context-2d-linewidth">lineWidth</a></code> was swept along each subpath in <var>path</var> while being kept at an angle such that the line is orthogonal to the path
    being swept, replacing each point with the end cap necessary to satisfy <var>style</var>'s <code id="line-styles:dom-context-2d-linecap-3"><a href="#dom-context-2d-linecap">lineCap</a></code> attribute as
    described previously and elaborated below, and replacing each join with the join necessary to
    satisfy <var>style</var>'s <code id="line-styles:dom-context-2d-linejoin-4"><a href="#dom-context-2d-linejoin">lineJoin</a></code>
    type, as defined below.</p>

    <p><strong>Caps</strong>: Each point has a flat edge perpendicular to the direction of the line
    coming out of it. This is then augmented according to the value of <var>style</var>'s <code id="line-styles:dom-context-2d-linecap-4"><a href="#dom-context-2d-linecap">lineCap</a></code>. The "<code>butt</code>" value means that no additional line cap is added. The "<code>round</code>" value means that a semi-circle with the diameter equal to
    <var>style</var>'s <code id="line-styles:dom-context-2d-linewidth-4"><a href="#dom-context-2d-linewidth">lineWidth</a></code> width must
    additionally be placed on to the line coming out of each point. The "<code>square</code>" value means that a rectangle with the length of <var>style</var>'s <code id="line-styles:dom-context-2d-linewidth-5"><a href="#dom-context-2d-linewidth">lineWidth</a></code> width and the
    width of half <var>style</var>'s <code id="line-styles:dom-context-2d-linewidth-6"><a href="#dom-context-2d-linewidth">lineWidth</a></code> width, placed flat against the edge
    perpendicular to the direction of the line coming out of the point, must be added at each
    point.</p>

    <p>Points with no lines coming out of them must have two caps placed back-to-back as if it was
    really two points connected to each other by an infinitesimally short straight line in the
    direction of the point's <i>directionality</i> (as defined above).</p>

    <p><strong>Joins</strong>: In addition to the point where a join occurs, two additional points
    are relevant to each join, one for each line: the two corners found half the line width away
    from the join point, one perpendicular to each line, each on the side furthest from the other
    line.</p>

    <p>A triangle connecting these two opposite corners with a straight line, with the third point
    of the triangle being the join point, must be added at all joins. The <code id="line-styles:dom-context-2d-linejoin-5"><a href="#dom-context-2d-linejoin">lineJoin</a></code> attribute controls whether anything else is
    rendered. The three aforementioned values have the following meanings:</p>

    <p>The "<code>bevel</code>" value means that this is all that is rendered at
    joins.</p>

    <p>The "<code>round</code>" value means that an arc connecting the two aforementioned
    corners of the join, abutting (and not overlapping) the aforementioned triangle, with the
    diameter equal to the line width and the origin at the point of the join, must be added at
    joins.</p>

    <p>The "<code>miter</code>" value means that a second triangle must (if it can given
    the miter length) be added at the join, with one line being the line between the two
    aforementioned corners, abutting the first triangle, and the other two being continuations of
    the outside edges of the two joining lines, as long as required to intersect without going over
    the miter length.</p>

    <p>The miter length is the distance from the point where the join occurs to the intersection of
    the line edges on the outside of the join. The miter limit ratio is the maximum allowed ratio of
    the miter length to half the line width. If the miter length would cause the miter limit ratio
    (as set by <var>style</var>'s <code id="line-styles:dom-context-2d-miterlimit-3"><a href="#dom-context-2d-miterlimit">miterLimit</a></code> attribute) to be exceeded, then this second
    triangle must not be added.</p> 



    <p>The subpaths in the newly created path must be oriented such that for any point, the number
    of times a half-infinite straight line drawn from that point crosses a subpath is even if and
    only if the number of times a half-infinite straight line drawn from that same point crosses a
    subpath going in one direction is equal to the number of times it crosses a subpath going in the
    other direction.</p>
   </li><li><p>Return the newly created path.</p></li></ol>
  </div>



  


  <h6 id="text-styles"><span class="secno">4.12.5.1.5</span> Text styles<a href="#text-styles" class="self-link"></a></h6>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-lang" id="dom-context-2d-lang-dev">lang</a> [ = <var>value</var> ]</code></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-lang" id="text-styles:dom-context-2d-lang">lang</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current language setting.</p>

    <p>Can be set to a BCP 47 language tag, the empty string, or "<code id="text-styles:dom-context-2d-lang-inherit"><a href="#dom-context-2d-lang-inherit">inherit</a></code>", to change the language used when
    resolving fonts. "<code id="text-styles:dom-context-2d-lang-inherit-2"><a href="#dom-context-2d-lang-inherit">inherit</a></code>" takes the language
    from the <code id="text-styles:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element's language, or the associated <a id="text-styles:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document
    element</a> when there is no <code id="text-styles:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> element.</p>

    <p>The default is "<code id="text-styles:dom-context-2d-lang-inherit-3"><a href="#dom-context-2d-lang-inherit">inherit</a></code>".</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-font" id="dom-context-2d-font-dev">font</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font" title="The CanvasRenderingContext2D.font property of the Canvas 2D API specifies the current text style to use when drawing text. This string uses the same syntax as the CSS font specifier.">CanvasRenderingContext2D/font</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-font" id="text-styles:dom-context-2d-font">font</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current font settings.</p>

    <p>Can be set, to change the font. The syntax is the same as for the CSS <a id="text-styles:'font'" href="https://drafts.csswg.org/css-fonts/#font-prop" data-x-internal="'font'">'font'</a>
    property; values that cannot be parsed as CSS font values are ignored. The default is "10px
    sans-serif".</p>

    <p>Relative keywords and lengths are computed relative to the font of the <code id="text-styles:the-canvas-element-3"><a href="#the-canvas-element">canvas</a></code>
    element.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-textalign" id="dom-context-2d-textalign-dev">textAlign</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign" title="The CanvasRenderingContext2D.textAlign property of the Canvas 2D API specifies the current text alignment used when drawing text.">CanvasRenderingContext2D/textAlign</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-textalign" id="text-styles:dom-context-2d-textalign">textAlign</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current text alignment settings.</p>

    <p>Can be set, to change the alignment. The possible values are and their meanings are given
    below. Other values are ignored. The default is "<code>start</code>".</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-textbaseline" id="dom-context-2d-textbaseline-dev">textBaseline</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textBaseline" title="The CanvasRenderingContext2D.textBaseline property of the Canvas 2D API specifies the current text baseline used when drawing text.">CanvasRenderingContext2D/textBaseline</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-textbaseline" id="text-styles:dom-context-2d-textbaseline">textBaseline</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current baseline alignment settings.</p>

    <p>Can be set, to change the baseline alignment. The possible values and their meanings are
    given below. Other values are ignored. The default is "<code id="text-styles:dom-context-2d-textbaseline-alphabetic"><a href="#dom-context-2d-textbaseline-alphabetic">alphabetic</a></code>".</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-direction" id="dom-context-2d-direction-dev">direction</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/direction" title="The CanvasRenderingContext2D.direction property of the Canvas 2D API specifies the current text direction used to draw text.">CanvasRenderingContext2D/direction</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>101+</span></span><span class="safari yes"><span>Safari</span><span>9+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-direction" id="text-styles:dom-context-2d-direction">direction</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current directionality.</p>

    <p>Can be set, to change the directionality. The possible values and their meanings are given
    below. Other values are ignored. The default is "<code id="text-styles:dom-context-2d-direction-inherit"><a href="#dom-context-2d-direction-inherit">inherit</a></code>".</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-letterspacing" id="dom-context-2d-letterspacing-dev">letterSpacing</a> [ = <var>value</var> ]</code></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-letterspacing" id="text-styles:dom-context-2d-letterspacing">letterSpacing</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current spacing between characters in the text.</p>

    <p>Can be set, to change spacing between characters. Values that cannot be parsed as a CSS
    <a id="text-styles:length-2" href="https://drafts.csswg.org/css-values/#lengths" data-x-internal="length-2">&lt;length&gt;</a> are ignored. The default is "<code>0px</code>".</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-fontkerning" id="dom-context-2d-fontkerning-dev">fontKerning</a> [ = <var>value</var> ]</code></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-fontkerning" id="text-styles:dom-context-2d-fontkerning">fontKerning</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current font kerning settings.</p>

    <p>Can be set, to change the font kerning. The possible values and their meanings are given
    below. Other values are ignored. The default is "<code id="text-styles:dom-context-2d-fontkerning-auto"><a href="#dom-context-2d-fontkerning-auto">auto</a></code>".</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-fontstretch" id="dom-context-2d-fontstretch-dev">fontStretch</a> [ = <var>value</var> ]</code></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-fontstretch" id="text-styles:dom-context-2d-fontstretch">fontStretch</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current font stretch settings.</p>

    <p>Can be set, to change the font stretch. The possible values and their meanings are given
    below. Other values are ignored. The default is "<code id="text-styles:dom-context-2d-fontstretch-normal"><a href="#dom-context-2d-fontstretch-normal">normal</a></code>".</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-fontvariantcaps" id="dom-context-2d-fontvariantcaps-dev">fontVariantCaps</a> [ = <var>value</var> ]</code></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-fontvariantcaps" id="text-styles:dom-context-2d-fontvariantcaps">fontVariantCaps</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current font variant caps settings.</p>

    <p>Can be set, to change the font variant caps. The possible values and their meanings are given
    below. Other values are ignored. The default is "<code id="text-styles:dom-context-2d-fontvariantcaps-normal"><a href="#dom-context-2d-fontvariantcaps-normal">normal</a></code>".</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-textrendering" id="dom-context-2d-textrendering-dev">textRendering</a> [ = <var>value</var> ]</code></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-textrendering" id="text-styles:dom-context-2d-textrendering">textRendering</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current text rendering settings.</p>

    <p>Can be set, to change the text rendering. The possible values and their meanings are given
    below. Other values are ignored. The default is "<code id="text-styles:dom-context-2d-textrendering-auto"><a href="#dom-context-2d-textrendering-auto">auto</a></code>".</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-wordspacing" id="dom-context-2d-wordspacing-dev">wordSpacing</a> [ = <var>value</var> ]</code></dt><dt><code><var>styles</var>.<a href="#dom-context-2d-wordspacing" id="text-styles:dom-context-2d-wordspacing">wordSpacing</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current spacing between words in the text.</p>

    <p>Can be set, to change spacing between words. Values that cannot be parsed as a CSS
    <a id="text-styles:length-2-2" href="https://drafts.csswg.org/css-values/#lengths" data-x-internal="length-2">&lt;length&gt;</a> are ignored. The default is "<code>0px</code>".</p>
   </dd></dl>

  

  <p>Objects that implement the <code id="text-styles:canvastextdrawingstyles"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface have attributes
  (defined in this section) that control how text is laid out (rasterized or outlined) by the
  object. Such objects can also have a <dfn id="font-style-source-object">font style source object</dfn>. For
  <code id="text-styles:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> objects, this is the <code id="text-styles:the-canvas-element-4"><a href="#the-canvas-element">canvas</a></code> element given by
  the value of the context's <code id="text-styles:dom-context-2d-canvas"><a href="#dom-context-2d-canvas">canvas</a></code> attribute. For
  <code id="text-styles:offscreencanvasrenderingcontext2d"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code> objects, this is the <a href="#associated-offscreencanvas-object" id="text-styles:associated-offscreencanvas-object">associated
  <code>OffscreenCanvas</code> object</a>.</p>

  <div data-algorithm="">
  <p>Font resolution for the <a href="#font-style-source-object" id="text-styles:font-style-source-object">font style source object</a> requires a <a id="text-styles:font-source" href="https://drafts.csswg.org/css-font-loading/#font-source" data-x-internal="font-source">font
  source</a>. This is determined for a given <var>object</var> implementing
  <code id="text-styles:canvastextdrawingstyles-2"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> by the following steps: <a href="#refsCSSFONTLOAD">[CSSFONTLOAD]</a></p>

  <ol><li><p>If <var>object</var>'s <a href="#font-style-source-object" id="text-styles:font-style-source-object-2">font style source object</a> is a <code id="text-styles:the-canvas-element-5"><a href="#the-canvas-element">canvas</a></code>
   element, return the element's <a id="text-styles:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li>
    <p>Otherwise, <var>object</var>'s <a href="#font-style-source-object" id="text-styles:font-style-source-object-3">font style source object</a> is an
    <code id="text-styles:offscreencanvas"><a href="#offscreencanvas">OffscreenCanvas</a></code> object:</p>

    <ol><li><p>Let <var>global</var> be <var>object</var>'s <a href="#concept-relevant-global" id="text-styles:concept-relevant-global">relevant global
     object</a>.</p></li><li><p>If <var>global</var> is a <code id="text-styles:window"><a href="#window">Window</a></code> object, then return <var>global</var>'s
     <a href="#concept-document-window" id="text-styles:concept-document-window">associated <code>Document</code></a>.</p></li><li><p><a id="text-styles:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>global</var> implements
     <code id="text-styles:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code>.</p></li><li><p>Return <var>global</var>.</p></li></ol>
   </li></ol>
  </div>

  <div class="example">
   <p>This is an example of font resolution with a regular <code id="text-styles:the-canvas-element-6"><a href="#the-canvas-element">canvas</a></code> element with ID <code>c1</code>.</p>

   <pre><code class="js"><c- a="">const</c-> font <c- o="">=</c-> <c- k="">new</c-> FontFace<c- p="">(</c-><c- u="">"MyCanvasFont"</c-><c- p="">,</c-> <c- u="">"url(mycanvasfont.ttf)"</c-><c- p="">);</c->
documents<c- p="">.</c->fonts<c- p="">.</c->add<c- p="">(</c->font<c- p="">);</c->

<c- a="">const</c-> context <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- u="">"c1"</c-><c- p="">).</c->getContext<c- p="">(</c-><c- u="">"2d"</c-><c- p="">);</c->
document<c- p="">.</c->fonts<c- p="">.</c->ready<c- p="">.</c->then<c- p="">(</c-><c- a="">function</c-><c- p="">()</c-> <c- p="">{</c->
  context<c- p="">.</c->font <c- o="">=</c-> <c- u="">"64px MyCanvasFont"</c-><c- p="">;</c->
  context<c- p="">.</c->fillText<c- p="">(</c-><c- u="">"hello"</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->
<c- p="">});</c-></code></pre>

   <p>In this example, the canvas will display text using <code>mycanvasfont.ttf</code> as
   its font.</p>
  </div>

  <div class="example">
   <p>This is an example of how font resolution can happen using <code id="text-styles:offscreencanvas-2"><a href="#offscreencanvas">OffscreenCanvas</a></code>.
   Assuming a <code id="text-styles:the-canvas-element-7"><a href="#the-canvas-element">canvas</a></code> element with ID <code>c2</code> which is transferred to
   a worker like so:</p>

   <pre><code class="js"><c- a="">const</c-> offscreenCanvas <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- u="">"c2"</c-><c- p="">).</c->transferControlToOffscreen<c- p="">();</c->
worker<c- p="">.</c->postMessage<c- p="">(</c->offscreenCanvas<c- p="">,</c-> <c- p="">[</c->offscreenCanvas<c- p="">]);</c-></code></pre>

   <p>Then, in the worker:</p>
   <pre><code class="js">self<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->ev<c- p="">)</c-> <c- p="">{</c->
  <c- a="">const</c-> transferredCanvas <c- o="">=</c-> ev<c- p="">.</c->data<c- p="">;</c->
  <c- a="">const</c-> context <c- o="">=</c-> transferredCanvas<c- p="">.</c->getContext<c- p="">(</c-><c- u="">"2d"</c-><c- p="">);</c->
  <c- a="">const</c-> font <c- o="">=</c-> <c- k="">new</c-> FontFace<c- p="">(</c-><c- u="">"MyFont"</c-><c- p="">,</c-> <c- u="">"url(myfont.ttf)"</c-><c- p="">);</c->
  self<c- p="">.</c->fonts<c- p="">.</c->add<c- p="">(</c->font<c- p="">);</c->
  self<c- p="">.</c->fonts<c- p="">.</c->ready<c- p="">.</c->then<c- p="">(</c-><c- a="">function</c-><c- p="">()</c-> <c- p="">{</c->
    context<c- p="">.</c->font <c- o="">=</c-> <c- u="">"64px MyFont"</c-><c- p="">;</c->
    context<c- p="">.</c->fillText<c- p="">(</c-><c- u="">"hello"</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->
  <c- p="">});</c->
<c- p="">};</c-></code></pre>

   <p>In this example, the canvas will display a text using <code>myfont.ttf</code>.
   Notice that the font is only loaded inside the worker, and not in the document context.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-font" data-dfn-type="attribute"><code>font</code></dfn> IDL attribute, on setting, must be <a href="https://drafts.csswg.org/css-syntax/#parse-grammar" id="text-styles:parse-something-according-to-a-css-grammar" data-x-internal="parse-something-according-to-a-css-grammar">parsed as a CSS &lt;'font'&gt; value</a> (but
  without supporting property-independent style sheet syntax like 'inherit'), and the resulting font
  must be assigned to the context, with the <a id="text-styles:'line-height'" href="https://drafts.csswg.org/css2/#propdef-line-height" data-x-internal="'line-height'">'line-height'</a> component forced to 'normal',
  with the <a id="text-styles:'font-size'" href="https://drafts.csswg.org/css-fonts/#font-size-prop" data-x-internal="'font-size'">'font-size'</a> component converted to <a href="https://drafts.csswg.org/css-values/#px" id="text-styles:'px'" data-x-internal="'px'">CSS pixels</a>,
  and with system fonts being computed to explicit values. If the new value is syntactically
  incorrect (including using property-independent style sheet syntax like 'inherit' or 'initial'),
  then it must be ignored, without assigning a new font value. <a href="#refsCSS">[CSS]</a></p>
  </div>

  <p>Font family names must be interpreted in the context of the <a href="#font-style-source-object" id="text-styles:font-style-source-object-4">font style source
  object</a> when the font is to be used; any fonts embedded using <code>@font-face</code> or loaded using <code id="text-styles:fontface"><a href="#fontface">FontFace</a></code> objects that are visible to the
  <a href="#font-style-source-object" id="text-styles:font-style-source-object-5">font style source object</a> must therefore be available once they are loaded. (Each <a href="#font-style-source-object" id="text-styles:font-style-source-object-6">font style source
  object</a> has a <a id="text-styles:font-source-2" href="https://drafts.csswg.org/css-font-loading/#font-source" data-x-internal="font-source">font source</a>, which determines what fonts are available.) If a font
  is used before it is fully loaded, or if the <a href="#font-style-source-object" id="text-styles:font-style-source-object-7">font style source object</a> does not have
  that font in scope at the time the font is to be used, then it must be treated as if it was an
  unknown font, falling back to another as described by the relevant CSS specifications.
  <a href="#refsCSSFONTS">[CSSFONTS]</a> <a href="#refsCSSFONTLOAD">[CSSFONTLOAD]</a></p>

  <div data-algorithm="">
  <p>On getting, the <code id="text-styles:dom-context-2d-font-2"><a href="#dom-context-2d-font">font</a></code> attribute must return the <a href="https://drafts.csswg.org/cssom/#serialize-a-css-value" id="text-styles:serializing-a-css-value" data-x-internal="serializing-a-css-value">serialized form</a> of the current font of the context (with
  no <a id="text-styles:'line-height'-2" href="https://drafts.csswg.org/css2/#propdef-line-height" data-x-internal="'line-height'">'line-height'</a> component). <a href="#refsCSSOM">[CSSOM]</a></p>
  </div>

  <div class="example">

   <p>For example, after the following statement:</p>

   <pre><code class="js">context<c- p="">.</c->font <c- o="">=</c-> <c- t="">'italic 400 12px/2 Unknown Font, sans-serif'</c-><c- p="">;</c-></code></pre>

   <p>...the expression <code>context.font</code> would evaluate to the string "<code>italic&nbsp;12px&nbsp;"Unknown&nbsp;Font",&nbsp;sans-serif</code>". The "400"
   font-weight doesn't appear because that is the default value. The line-height doesn't appear
   because it is forced to "normal", the default value.</p>

  </div>

  <p>When the object implementing the <code id="text-styles:canvastextdrawingstyles-3"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface is created, the
  font of the context must be set to 10px sans-serif. When the <a id="text-styles:'font-size'-2" href="https://drafts.csswg.org/css-fonts/#font-size-prop" data-x-internal="'font-size'">'font-size'</a> component is
  set to lengths using percentages, <a id="text-styles:'em'" href="https://drafts.csswg.org/css-values/#em" data-x-internal="'em'">'em'</a> or <a id="text-styles:'ex'" href="https://drafts.csswg.org/css-values/#ex" data-x-internal="'ex'">'ex'</a> units, or the 'larger' or
  'smaller' keywords, these must be interpreted relative to the <a id="text-styles:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of the
  <a id="text-styles:'font-size'-3" href="https://drafts.csswg.org/css-fonts/#font-size-prop" data-x-internal="'font-size'">'font-size'</a> property of the <a href="#font-style-source-object" id="text-styles:font-style-source-object-8">font style source object</a> at the time that
  the attribute is set, if it is an element. When the <a id="text-styles:'font-weight'" href="https://drafts.csswg.org/css-fonts/#font-weight-prop" data-x-internal="'font-weight'">'font-weight'</a> component is set to
  the relative values 'bolder' and 'lighter', these must be interpreted relative to the
  <a id="text-styles:computed-value-2" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of the <a id="text-styles:'font-weight'-2" href="https://drafts.csswg.org/css-fonts/#font-weight-prop" data-x-internal="'font-weight'">'font-weight'</a> property of the <a href="#font-style-source-object" id="text-styles:font-style-source-object-9">font style
  source object</a> at the time that the attribute is set, if it is an element. If the <a href="https://drafts.csswg.org/css-cascade/#computed-value" id="text-styles:computed-value-3" data-x-internal="computed-value">computed values</a> are undefined for a particular case (e.g. because
  the <a href="#font-style-source-object" id="text-styles:font-style-source-object-10">font style source object</a> is not an element or is not <a href="#being-rendered" id="text-styles:being-rendered">being
  rendered</a>), then the relative keywords must be interpreted relative to the normal-weight
  10px sans-serif default.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-textalign" data-dfn-type="attribute"><code>textAlign</code></dfn> IDL attribute, on getting, must return
  the current value. On setting, the current value must be changed to the new value. When the object
  implementing the <code id="text-styles:canvastextdrawingstyles-4"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface is created, the <code id="text-styles:dom-context-2d-textalign-2"><a href="#dom-context-2d-textalign">textAlign</a></code> attribute must initially have the value <code id="text-styles:dom-context-2d-textalign-start"><a href="#dom-context-2d-textalign-start">start</a></code>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-textbaseline" data-dfn-type="attribute"><code>textBaseline</code></dfn> IDL attribute, on getting, must
  return the current value. On setting, the current value must be changed to the new value. When the
  object implementing the <code id="text-styles:canvastextdrawingstyles-5"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface is created, the <code id="text-styles:dom-context-2d-textbaseline-2"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute must initially have the value
  <code id="text-styles:dom-context-2d-textbaseline-alphabetic-2"><a href="#dom-context-2d-textbaseline-alphabetic">alphabetic</a></code>.</p>
  </div>

  <p>Objects that implement the <code id="text-styles:canvastextdrawingstyles-6"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface have an associated
  <dfn id="concept-canvastextdrawingstyles-language">language</dfn> value used to localize font
  rendering. Valid values are a BCP 47 language tag, the empty string, or "<dfn id="dom-context-2d-lang-inherit">inherit</dfn>" where the language comes from the
  <code id="text-styles:the-canvas-element-8"><a href="#the-canvas-element">canvas</a></code> element's language, or the associated <a id="text-styles:document-element-2" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> when there
  is no <code id="text-styles:the-canvas-element-9"><a href="#the-canvas-element">canvas</a></code> element. Initially, the <a href="#concept-canvastextdrawingstyles-language" id="text-styles:concept-canvastextdrawingstyles-language">language</a> must be "<code id="text-styles:dom-context-2d-lang-inherit-4"><a href="#dom-context-2d-lang-inherit">inherit</a></code>".</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-lang" data-dfn-type="attribute"><code>lang</code></dfn> getter steps are to return
  <a id="text-styles:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvastextdrawingstyles-language" id="text-styles:concept-canvastextdrawingstyles-language-2">language</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="text-styles:dom-context-2d-lang-2"><a href="#dom-context-2d-lang">lang</a></code> setter steps are to set <a id="text-styles:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#concept-canvastextdrawingstyles-language" id="text-styles:concept-canvastextdrawingstyles-language-3">language</a> to the given value.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-direction" data-dfn-type="attribute"><code>direction</code></dfn> IDL attribute, on getting, must return
  the current value. On setting, the current value must be changed to the new value. When the object
  implementing the <code id="text-styles:canvastextdrawingstyles-7"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface is created, the <code id="text-styles:dom-context-2d-direction-2"><a href="#dom-context-2d-direction">direction</a></code> attribute must initially have the value "<code id="text-styles:dom-context-2d-direction-inherit-2"><a href="#dom-context-2d-direction-inherit">inherit</a></code>".</p>
  </div>

  <p>Objects that implement the <code id="text-styles:canvastextdrawingstyles-8"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface have attributes that
  control the spacing between letters and words. Such objects have associated <dfn id="concept-canvastextdrawingstyles-letter-spacing">letter spacing</dfn> and <dfn id="concept-canvastextdrawingstyles-word-spacing">word spacing</dfn> values, which are CSS
  <a id="text-styles:length-2-3" href="https://drafts.csswg.org/css-values/#lengths" data-x-internal="length-2">&lt;length&gt;</a> values. Initially, both must be the result of <a href="https://drafts.csswg.org/css-syntax/#parse-grammar" id="text-styles:parse-something-according-to-a-css-grammar-2" data-x-internal="parse-something-according-to-a-css-grammar">parsing</a> "<code>0px</code>" as a CSS
  <a id="text-styles:length-2-4" href="https://drafts.csswg.org/css-values/#lengths" data-x-internal="length-2">&lt;length&gt;</a>.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/letterSpacing" title="The CanvasRenderingContext2D.letterSpacing property of the Canvas API specifies the spacing between letters when drawing text.">CanvasRenderingContext2D/letterSpacing</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-letterspacing" data-dfn-type="attribute"><code>letterSpacing</code></dfn> getter steps are to return
  the <a href="https://drafts.csswg.org/cssom/#serialize-a-css-value" id="text-styles:serializing-a-css-value-2" data-x-internal="serializing-a-css-value">serialized form</a> of <a id="text-styles:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvastextdrawingstyles-letter-spacing" id="text-styles:concept-canvastextdrawingstyles-letter-spacing">letter spacing</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="text-styles:dom-context-2d-letterspacing-2"><a href="#dom-context-2d-letterspacing">letterSpacing</a></code> setter steps are:</p>

  <ol><li><p>Let <var>parsed</var> be the result of <a href="https://drafts.csswg.org/css-syntax/#parse-grammar" id="text-styles:parse-something-according-to-a-css-grammar-3" data-x-internal="parse-something-according-to-a-css-grammar">parsing</a> the given value as a CSS <a id="text-styles:length-2-5" href="https://drafts.csswg.org/css-values/#lengths" data-x-internal="length-2">&lt;length&gt;</a>.</p></li><li><p>If <var>parsed</var> is failure, then return.</p></li><li><p>Set <a id="text-styles:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvastextdrawingstyles-letter-spacing" id="text-styles:concept-canvastextdrawingstyles-letter-spacing-2">letter spacing</a> to
   <var>parsed</var>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/wordSpacing" title="The CanvasRenderingContext2D.wordSpacing property of the Canvas API specifies the spacing between words when drawing text.">CanvasRenderingContext2D/wordSpacing</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-wordspacing" data-dfn-type="attribute"><code>wordSpacing</code></dfn> getter steps are to return the
  <a href="https://drafts.csswg.org/cssom/#serialize-a-css-value" id="text-styles:serializing-a-css-value-3" data-x-internal="serializing-a-css-value">serialized form</a> of <a id="text-styles:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvastextdrawingstyles-word-spacing" id="text-styles:concept-canvastextdrawingstyles-word-spacing">word spacing</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="text-styles:dom-context-2d-wordspacing-2"><a href="#dom-context-2d-wordspacing">wordSpacing</a></code> setter steps are:</p>

  <ol><li><p>Let <var>parsed</var> be the result of <a href="https://drafts.csswg.org/css-syntax/#parse-grammar" id="text-styles:parse-something-according-to-a-css-grammar-4" data-x-internal="parse-something-according-to-a-css-grammar">parsing</a> the given value as a CSS <a id="text-styles:length-2-6" href="https://drafts.csswg.org/css-values/#lengths" data-x-internal="length-2">&lt;length&gt;</a>.</p></li><li><p>If <var>parsed</var> is failure, then return.</p></li><li><p>Set <a id="text-styles:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvastextdrawingstyles-word-spacing" id="text-styles:concept-canvastextdrawingstyles-word-spacing-2">word
   spacing</a> to <var>parsed</var>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fontKerning" title="The CanvasRenderingContext2D.fontKerning property of the Canvas API specifies how font kerning information is used.">CanvasRenderingContext2D/fontKerning</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>104+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-fontkerning" data-dfn-type="attribute"><code>fontKerning</code></dfn> IDL attribute, on
  getting, must return the current value. On setting, the current value must be changed to the new
  value. When the object implementing the <code id="text-styles:canvastextdrawingstyles-9"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface is created,
  the <code id="text-styles:dom-context-2d-fontkerning-2"><a href="#dom-context-2d-fontkerning">fontKerning</a></code> attribute must
  initially have the value "<code id="text-styles:dom-context-2d-fontkerning-auto-2"><a href="#dom-context-2d-fontkerning-auto">auto</a></code>".</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fontStretch" title="The CanvasRenderingContext2D.fontStretch property of the Canvas API specifies how the font may be expanded or condensed when drawing text.">CanvasRenderingContext2D/fontStretch</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-fontstretch" data-dfn-type="attribute"><code>fontStretch</code></dfn> IDL attribute, on
  getting, must return the current value. On setting, the current value must be changed to the new
  value. When the object implementing the <code id="text-styles:canvastextdrawingstyles-10"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface is created,
  the <code id="text-styles:dom-context-2d-fontstretch-2"><a href="#dom-context-2d-fontstretch">fontStretch</a></code> attribute must
  initially have the value "<code id="text-styles:dom-context-2d-fontstretch-normal-2"><a href="#dom-context-2d-fontstretch-normal">normal</a></code>".</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fontVariantCaps" title="The CanvasRenderingContext2D.fontVariantCaps property of the Canvas API specifies an alternative capitalization of the rendered text.">CanvasRenderingContext2D/fontVariantCaps</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-fontvariantcaps" data-dfn-type="attribute"><code>fontVariantCaps</code></dfn> IDL attribute, on
  getting, must return the current value. On setting, the current value must be changed to the new
  value. When the object implementing the <code id="text-styles:canvastextdrawingstyles-11"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface is created,
  the <code id="text-styles:dom-context-2d-fontvariantcaps-2"><a href="#dom-context-2d-fontvariantcaps">fontVariantCaps</a></code> attribute must
  initially have the value "<code id="text-styles:dom-context-2d-fontvariantcaps-normal-2"><a href="#dom-context-2d-fontvariantcaps-normal">normal</a></code>".</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textRendering" title="The CanvasRenderingContext2D.textRendering property of the Canvas API provides information to the rendering engine about what to optimize for when rendering text.">CanvasRenderingContext2D/textRendering</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTextDrawingStyles" id="dom-context-2d-textrendering" data-dfn-type="attribute"><code>textRendering</code></dfn> IDL attribute, on
  getting, must return the current value. On setting, the current value must be changed to the new
  value. When the object implementing the <code id="text-styles:canvastextdrawingstyles-12"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interface is created,
  the <code id="text-styles:dom-context-2d-textrendering-2"><a href="#dom-context-2d-textrendering">textRendering</a></code> attribute must
  initially have the value "<code id="text-styles:dom-context-2d-textrendering-auto-2"><a href="#dom-context-2d-textrendering-auto">auto</a></code>".</p>
  </div>
  

  <p>The <code id="text-styles:dom-context-2d-textalign-3"><a href="#dom-context-2d-textalign">textAlign</a></code> attribute's allowed keywords are
  as follows:</p>

  <dl><dt><dfn data-dfn-for="CanvasTextAlign" id="dom-context-2d-textalign-start" data-dfn-type="enum-value"><code>start</code></dfn>
   </dt><dd><p>Align to the start edge of the text (left side in left-to-right text, right side in
   right-to-left text).</p></dd><dt><dfn data-dfn-for="CanvasTextAlign" id="dom-context-2d-textalign-end" data-dfn-type="enum-value"><code>end</code></dfn>
   </dt><dd><p>Align to the end edge of the text (right side in left-to-right text, left side in
   right-to-left text).</p></dd><dt><dfn data-dfn-for="CanvasTextAlign" id="dom-context-2d-textalign-left" data-dfn-type="enum-value"><code>left</code></dfn>
   </dt><dd><p>Align to the left.</p></dd><dt><dfn data-dfn-for="CanvasTextAlign" id="dom-context-2d-textalign-right" data-dfn-type="enum-value"><code>right</code></dfn>
   </dt><dd><p>Align to the right.</p></dd><dt><dfn data-dfn-for="CanvasTextAlign" id="dom-context-2d-textalign-center" data-dfn-type="enum-value"><code>center</code></dfn>
   </dt><dd><p>Align to the center.</p></dd></dl>

  <p>The <code id="text-styles:dom-context-2d-textbaseline-3"><a href="#dom-context-2d-textbaseline">textBaseline</a></code>
  attribute's allowed keywords correspond to alignment points in the
  font:</p>

  <p><img src="/images/baselines.png" width="738" alt="The em-over baseline is roughly at the top of the glyphs in a font, the hanging baseline is where some glyphs like आ are anchored, the middle is half-way between the em-over and em-under baselines, the alphabetic baseline is where characters like Á, ÿ, f, and Ω are anchored, the ideographic-under baseline is where glyphs like 私 and 達 are anchored, and the em-under baseline is roughly at the bottom of the glyphs in a font. The top and bottom of the bounding box can be far from these baselines, due to glyphs extending far outside em-over and em-under baselines." height="300"></p>

  <p>The keywords map to these alignment points as follows:</p>

  <dl><dt><dfn data-dfn-for="CanvasTextBaseline" id="dom-context-2d-textbaseline-top" data-dfn-type="enum-value"><code>top</code></dfn>
   </dt><dd>The <a id="text-styles:em-over-baseline" href="https://drafts.csswg.org/css-inline/#em-over-baseline" data-x-internal="em-over-baseline">em-over baseline</a></dd><dt><dfn data-dfn-for="CanvasTextBaseline" id="dom-context-2d-textbaseline-hanging" data-dfn-type="enum-value"><code>hanging</code></dfn>
   </dt><dd>The <a id="text-styles:hanging-baseline" href="https://drafts.csswg.org/css-inline/#hanging-baseline" data-x-internal="hanging-baseline">hanging baseline</a></dd><dt><dfn data-dfn-for="CanvasTextBaseline" id="dom-context-2d-textbaseline-middle" data-dfn-type="enum-value"><code>middle</code></dfn>
   </dt><dd>Halfway between the <a id="text-styles:em-over-baseline-2" href="https://drafts.csswg.org/css-inline/#em-over-baseline" data-x-internal="em-over-baseline">em-over baseline</a> and the <a id="text-styles:em-under-baseline" href="https://drafts.csswg.org/css-inline/#em-under-baseline" data-x-internal="em-under-baseline">em-under baseline</a></dd><dt><dfn data-dfn-for="CanvasTextBaseline" id="dom-context-2d-textbaseline-alphabetic" data-dfn-type="enum-value"><code>alphabetic</code></dfn>
   </dt><dd>The <a id="text-styles:alphabetic-baseline" href="https://drafts.csswg.org/css-inline/#alphabetic-baseline" data-x-internal="alphabetic-baseline">alphabetic baseline</a></dd><dt><dfn data-dfn-for="CanvasTextBaseline" id="dom-context-2d-textbaseline-ideographic" data-dfn-type="enum-value"><code>ideographic</code></dfn>
   </dt><dd>The <a id="text-styles:ideographic-under-baseline" href="https://drafts.csswg.org/css-inline/#ideographic-under-baseline" data-x-internal="ideographic-under-baseline">ideographic-under baseline</a></dd><dt><dfn data-dfn-for="CanvasTextBaseline" id="dom-context-2d-textbaseline-bottom" data-dfn-type="enum-value"><code>bottom</code></dfn>
   </dt><dd>The <a id="text-styles:em-under-baseline-2" href="https://drafts.csswg.org/css-inline/#em-under-baseline" data-x-internal="em-under-baseline">em-under baseline</a></dd></dl>

  <p>The <code id="text-styles:dom-context-2d-direction-3"><a href="#dom-context-2d-direction">direction</a></code> attribute's allowed keywords are
  as follows:</p>

  <dl><dt><dfn data-dfn-for="CanvasDirection" id="dom-context-2d-direction-ltr" data-dfn-type="enum-value"><code>ltr</code></dfn>

   </dt><dd><p>Treat input to the <a href="#text-preparation-algorithm" id="text-styles:text-preparation-algorithm">text preparation algorithm</a> as left-to-right text.</p></dd><dt><dfn data-dfn-for="CanvasDirection" id="dom-context-2d-direction-rtl" data-dfn-type="enum-value"><code>rtl</code></dfn>

   </dt><dd><p>Treat input to the <a href="#text-preparation-algorithm" id="text-styles:text-preparation-algorithm-2">text preparation algorithm</a> as right-to-left text.</p></dd><dt><dfn data-dfn-for="CanvasDirection" id="dom-context-2d-direction-inherit" data-dfn-type="enum-value"><code>inherit</code></dfn>

   </dt><dd><p>Use the process in the <a href="#text-preparation-algorithm" id="text-styles:text-preparation-algorithm-3">text preparation algorithm</a> to obtain the text
   direction from the <code id="text-styles:the-canvas-element-10"><a href="#the-canvas-element">canvas</a></code> element, <a href="#offscreencanvas-placeholder" id="text-styles:offscreencanvas-placeholder">placeholder <code>canvas</code> element</a>, or
   <a id="text-styles:document-element-3" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>.</p></dd></dl>

  <p>The <code id="text-styles:dom-context-2d-fontkerning-3"><a href="#dom-context-2d-fontkerning">fontKerning</a></code> attribute's allowed keywords
  are as follows:</p>

  <dl><dt><dfn data-dfn-for="CanvasFontKerning" id="dom-context-2d-fontkerning-auto" data-dfn-type="enum-value"><code>auto</code></dfn>
   </dt><dd><p>Kerning is applied at the discretion of the user agent.</p></dd><dt><dfn data-dfn-for="CanvasFontKerning" id="dom-context-2d-fontkerning-normal" data-dfn-type="enum-value"><code>normal</code></dfn>
   </dt><dd><p>Kerning is applied.</p></dd><dt><dfn data-dfn-for="CanvasFontKerning" id="dom-context-2d-fontkerning-none" data-dfn-type="enum-value"><code>none</code></dfn>
   </dt><dd><p>Kerning is not applied.</p></dd></dl>

  <p>The <code id="text-styles:dom-context-2d-fontstretch-3"><a href="#dom-context-2d-fontstretch">fontStretch</a></code> attribute's allowed keywords
  are as follows:</p>

  <dl><dt><dfn data-dfn-for="CanvasFontStretch" id="dom-context-2d-fontstretch-ultra-condensed" data-dfn-type="enum-value"><code>ultra-condensed</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-stretch'" href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch" data-x-internal="'font-stretch'">'font-stretch'</a> <a id="text-styles:'ultra-condensed'" href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-ultra-condensed" data-x-internal="'ultra-condensed'">'ultra-condensed'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontStretch" id="dom-context-2d-fontstretch-extra-condensed" data-dfn-type="enum-value"><code>extra-condensed</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-stretch'-2" href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch" data-x-internal="'font-stretch'">'font-stretch'</a> <a id="text-styles:'extra-condensed'" href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-extra-condensed" data-x-internal="'extra-condensed'">'extra-condensed'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontStretch" id="dom-context-2d-fontstretch-condensed" data-dfn-type="enum-value"><code>condensed</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-stretch'-3" href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch" data-x-internal="'font-stretch'">'font-stretch'</a> <a id="text-styles:'condensed'" href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-condensed" data-x-internal="'condensed'">'condensed'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontStretch" id="dom-context-2d-fontstretch-semi-condensed" data-dfn-type="enum-value"><code>semi-condensed</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-stretch'-4" href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch" data-x-internal="'font-stretch'">'font-stretch'</a> <a id="text-styles:'semi-condensed'" href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-semi-condensed" data-x-internal="'semi-condensed'">'semi-condensed'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontStretch" id="dom-context-2d-fontstretch-normal" data-dfn-type="enum-value"><code>normal</code></dfn>
   </dt><dd><p>The default setting, where width of the glyphs is at 100%.</p></dd><dt><dfn data-dfn-for="CanvasFontStretch" id="dom-context-2d-fontstretch-semi-expanded" data-dfn-type="enum-value"><code>semi-expanded</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-stretch'-5" href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch" data-x-internal="'font-stretch'">'font-stretch'</a> <a id="text-styles:'semi-expanded'" href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-semi-expanded" data-x-internal="'semi-expanded'">'semi-expanded'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontStretch" id="dom-context-2d-fontstretch-expanded" data-dfn-type="enum-value"><code>expanded</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-stretch'-6" href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch" data-x-internal="'font-stretch'">'font-stretch'</a> <a id="text-styles:'expanded'" href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-expanded" data-x-internal="'expanded'">'expanded'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontStretch" id="dom-context-2d-fontstretch-extra-expanded" data-dfn-type="enum-value"><code>extra-expanded</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-stretch'-7" href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch" data-x-internal="'font-stretch'">'font-stretch'</a> <a id="text-styles:'extra-expanded'" href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-extra-expanded" data-x-internal="'extra-expanded'">'extra-expanded'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontStretch" id="dom-context-2d-fontstretch-ultra-expanded" data-dfn-type="enum-value"><code>ultra-expanded</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-stretch'-8" href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch" data-x-internal="'font-stretch'">'font-stretch'</a> <a id="text-styles:'ultra-expanded'" href="https://drafts.csswg.org/css-fonts/#valdef-font-stretch-ultra-expanded" data-x-internal="'ultra-expanded'">'ultra-expanded'</a> setting.</p></dd></dl>

  <p>The <code id="text-styles:dom-context-2d-fontvariantcaps-3"><a href="#dom-context-2d-fontvariantcaps">fontVariantCaps</a></code> attribute's allowed
  keywords are as follows:</p>

  <dl><dt><dfn data-dfn-for="CanvasFontVariantCaps" id="dom-context-2d-fontvariantcaps-normal" data-dfn-type="enum-value"><code>normal</code></dfn>
   </dt><dd><p>None of the features listed below are enabled.</p></dd><dt><dfn data-dfn-for="CanvasFontVariantCaps" id="dom-context-2d-fontvariantcaps-small-caps" data-dfn-type="enum-value"><code>small-caps</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-variant-caps'" href="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps" data-x-internal="'font-variant-caps'">'font-variant-caps'</a> <a id="text-styles:'small-caps'" href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-small-caps" data-x-internal="'small-caps'">'small-caps'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontVariantCaps" id="dom-context-2d-fontvariantcaps-all-small-caps" data-dfn-type="enum-value"><code>all-small-caps</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-variant-caps'-2" href="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps" data-x-internal="'font-variant-caps'">'font-variant-caps'</a> <a id="text-styles:'all-small-caps'" href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-all-small-caps" data-x-internal="'all-small-caps'">'all-small-caps'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontVariantCaps" id="dom-context-2d-fontvariantcaps-petite-caps" data-dfn-type="enum-value"><code>petite-caps</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-variant-caps'-3" href="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps" data-x-internal="'font-variant-caps'">'font-variant-caps'</a> <a id="text-styles:'petite-caps'" href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-petite-caps" data-x-internal="'petite-caps'">'petite-caps'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontVariantCaps" id="dom-context-2d-fontvariantcaps-all-petite-caps" data-dfn-type="enum-value"><code>all-petite-caps</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-variant-caps'-4" href="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps" data-x-internal="'font-variant-caps'">'font-variant-caps'</a> <a id="text-styles:'all-petite-caps'" href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-all-petite-caps" data-x-internal="'all-petite-caps'">'all-petite-caps'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontVariantCaps" id="dom-context-2d-fontvariantcaps-unicase" data-dfn-type="enum-value"><code>unicase</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-variant-caps'-5" href="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps" data-x-internal="'font-variant-caps'">'font-variant-caps'</a> <a id="text-styles:'unicase'" href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-unicase" data-x-internal="'unicase'">'unicase'</a> setting.</p></dd><dt><dfn data-dfn-for="CanvasFontVariantCaps" id="dom-context-2d-fontvariantcaps-titling-caps" data-dfn-type="enum-value"><code>titling-caps</code></dfn>
   </dt><dd><p>Same as CSS <a id="text-styles:'font-variant-caps'-6" href="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps" data-x-internal="'font-variant-caps'">'font-variant-caps'</a> <a id="text-styles:'titling-caps'" href="https://drafts.csswg.org/css-fonts/#valdef-font-variant-caps-titling-caps" data-x-internal="'titling-caps'">'titling-caps'</a> setting.</p></dd></dl>

  <p>The <code id="text-styles:dom-context-2d-textrendering-3"><a href="#dom-context-2d-textrendering">textRendering</a></code> attribute's allowed
  keywords are as follows:</p>

  <dl><dt><dfn data-dfn-for="CanvasTextRendering" id="dom-context-2d-textrendering-auto" data-dfn-type="enum-value"><code>auto</code></dfn>
    </dt><dd><p>Same as 'auto' in <a id="text-styles:svg-text-rendering" href="https://svgwg.org/svg2-draft/painting.html#TextRendering" data-x-internal="svg-text-rendering">SVG text-rendering</a> property.</p></dd><dt><dfn data-dfn-for="CanvasTextRendering" id="dom-context-2d-textrendering-optimizespeed" data-dfn-type="enum-value"><code>optimizeSpeed</code></dfn>
    </dt><dd><p>Same as 'optimizeSpeed' in <a id="text-styles:svg-text-rendering-2" href="https://svgwg.org/svg2-draft/painting.html#TextRendering" data-x-internal="svg-text-rendering">SVG text-rendering</a> property.</p></dd><dt><dfn data-dfn-for="CanvasTextRendering" id="dom-context-2d-textrendering-optimizelegibility" data-dfn-type="enum-value"><code>optimizeLegibility</code></dfn>
    </dt><dd><p>Same as 'optimizeLegibility' in <a id="text-styles:svg-text-rendering-3" href="https://svgwg.org/svg2-draft/painting.html#TextRendering" data-x-internal="svg-text-rendering">SVG text-rendering</a> property.</p></dd><dt><dfn data-dfn-for="CanvasTextRendering" id="dom-context-2d-textrendering-geometricprecision" data-dfn-type="enum-value"><code>geometricPrecision</code></dfn>
    </dt><dd><p>Same as 'geometricPrecision' in <a id="text-styles:svg-text-rendering-4" href="https://svgwg.org/svg2-draft/painting.html#TextRendering" data-x-internal="svg-text-rendering">SVG text-rendering</a> property.</p></dd></dl>

  <div data-algorithm="">
  <p>The <dfn id="text-preparation-algorithm">text preparation algorithm</dfn> is as follows. It takes as input a string <var>text</var>,
  a <code id="text-styles:canvastextdrawingstyles-13"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> object <var>target</var>, and an optional length
  <var>maxWidth</var>. It returns an array of glyph shapes, each positioned on a common coordinate
  space, a <var>physical alignment</var> whose value is one of <i>left</i>, <i>right</i>, and
  <i>center</i>, and an <a id="text-styles:inline-box" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>. (Most callers of this algorithm ignore the
  <var>physical alignment</var> and the <a id="text-styles:inline-box-2" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>.)</p>

  <ol><li><p>If <var>maxWidth</var> was provided but is less than or equal to zero or equal to NaN,
   then return an empty array.</p></li><li><p>Replace all <a id="text-styles:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> in <var>text</var> with U+0020 SPACE
   characters.</p></li><li><p>Let <var>font</var> be the current font of <var>target</var>, as given
   by that object's <code id="text-styles:dom-context-2d-font-3"><a href="#dom-context-2d-font">font</a></code> attribute.</p></li><li><p>Let <var>language</var> be the <var>target</var>'s <a href="#concept-canvastextdrawingstyles-language" id="text-styles:concept-canvastextdrawingstyles-language-4">language</a>.</p></li><li>
    <p>If <var>language</var> is "<code id="text-styles:dom-context-2d-lang-inherit-5"><a href="#dom-context-2d-lang-inherit">inherit</a></code>":</p>

    <ol><li><p>Let <var>sourceObject</var> be <var>object</var>'s <a href="#font-style-source-object" id="text-styles:font-style-source-object-11">font style source
     object</a>.</p></li><li><p>If <var>sourceObject</var> is a <code id="text-styles:the-canvas-element-11"><a href="#the-canvas-element">canvas</a></code>
     element, then set <var>language</var> to the <var>sourceObject</var>'s
     <a href="#language" id="text-styles:language">language</a>.</p></li><li>
      <p>Otherwise:</p>

      <ol><li><p><a id="text-styles:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>sourceObject</var> is an <code id="text-styles:offscreencanvas-3"><a href="#offscreencanvas">OffscreenCanvas</a></code> object.</p></li><li><p>Set <var>language</var> to the <var>sourceObject</var>'s
       <a href="#offscreencanvas-inherited-lang" id="text-styles:offscreencanvas-inherited-lang">inherited language</a>.</p></li></ol>
     </li></ol>
   </li><li><p>If <var>language</var> is the empty string, then set <var>language</var> to
   <a href="#concept-explicitly-unknown" id="text-styles:concept-explicitly-unknown">explicitly unknown</a>.</p></li><li>
    <p>Apply the appropriate step from the following list to determine the value of
    <var>direction</var>:</p>

    <dl class="switch"><dt>If the <var>target</var> object's <code id="text-styles:dom-context-2d-direction-4"><a href="#dom-context-2d-direction">direction</a></code> attribute has the value "<code id="text-styles:dom-context-2d-direction-ltr"><a href="#dom-context-2d-direction-ltr">ltr</a></code>"</dt><dd>Let <var>direction</var> be '<a href="#concept-ltr" id="text-styles:concept-ltr">ltr</a>'.</dd><dt>If the <var>target</var> object's <code id="text-styles:dom-context-2d-direction-5"><a href="#dom-context-2d-direction">direction</a></code> attribute has the value "<code id="text-styles:dom-context-2d-direction-rtl"><a href="#dom-context-2d-direction-rtl">rtl</a></code>"</dt><dd>Let <var>direction</var> be '<a href="#concept-rtl" id="text-styles:concept-rtl">rtl</a>'.</dd><dt>If the <var>target</var> object's <code id="text-styles:dom-context-2d-direction-6"><a href="#dom-context-2d-direction">direction</a></code> attribute has the value "<code id="text-styles:dom-context-2d-direction-inherit-3"><a href="#dom-context-2d-direction-inherit">inherit</a></code>"</dt><dd>
      <ol><li><p>Let <var>sourceObject</var> be <var>object</var>'s <a href="#font-style-source-object" id="text-styles:font-style-source-object-12">font style source
       object</a>.</p></li><li><p>If <var>sourceObject</var> is a <code id="text-styles:the-canvas-element-12"><a href="#the-canvas-element">canvas</a></code>
       element, then let <var>direction</var> be <var>sourceObject</var>'s
       <a href="#the-directionality" id="text-styles:the-directionality">directionality</a>.</p></li><li>
        <p>Otherwise:</p>
        <ol><li><p><a id="text-styles:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>sourceObject</var> is an <code id="text-styles:offscreencanvas-4"><a href="#offscreencanvas">OffscreenCanvas</a></code> object.</p></li><li><p>Let <var>direction</var> be <var>sourceObject</var>'s
         <a href="#offscreencanvas-inherited-direction" id="text-styles:offscreencanvas-inherited-direction">inherited direction</a>.</p></li></ol>
       </li></ol>
     </dd></dl>
   </li><li>
    <p>Form a hypothetical infinitely-wide CSS <a id="text-styles:line-box" href="https://drafts.csswg.org/css2/#line-box" data-x-internal="line-box">line box</a> containing a single
    <a id="text-styles:inline-box-3" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a> containing the text <var>text</var>, with the CSS
    <a id="text-styles:content-language" href="https://drafts.csswg.org/css-text-4/#content-language" data-x-internal="content-language">content language</a> set to <var>language</var>, and with its CSS properties set as
    follows:</p>

    <table><thead><tr><th>Property</th><th>Source</th></tr></thead><tbody><tr><td><a id="text-styles:'direction'" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a></td><td><var>direction</var></td></tr><tr><td><a id="text-styles:'font'-2" href="https://drafts.csswg.org/css-fonts/#font-prop" data-x-internal="'font'">'font'</a></td><td><var>font</var></td></tr><tr><td><a id="text-styles:'font-kerning'" href="https://drafts.csswg.org/css-fonts/#propdef-font-kerning" data-x-internal="'font-kerning'">'font-kerning'</a></td><td><var>target</var>'s <code id="text-styles:dom-context-2d-fontkerning-4"><a href="#dom-context-2d-fontkerning">fontKerning</a></code></td></tr><tr><td><a id="text-styles:'font-stretch'-9" href="https://drafts.csswg.org/css-fonts/#propdef-font-stretch" data-x-internal="'font-stretch'">'font-stretch'</a></td><td><var>target</var>'s <code id="text-styles:dom-context-2d-fontstretch-4"><a href="#dom-context-2d-fontstretch">fontStretch</a></code></td></tr><tr><td><a id="text-styles:'font-variant-caps'-7" href="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps" data-x-internal="'font-variant-caps'">'font-variant-caps'</a></td><td><var>target</var>'s <code id="text-styles:dom-context-2d-fontvariantcaps-4"><a href="#dom-context-2d-fontvariantcaps">fontVariantCaps</a></code></td></tr><tr><td><a id="text-styles:'letter-spacing'" href="https://drafts.csswg.org/css-text/#letter-spacing-property" data-x-internal="'letter-spacing'">'letter-spacing'</a></td><td><var>target</var>'s <a href="#concept-canvastextdrawingstyles-letter-spacing" id="text-styles:concept-canvastextdrawingstyles-letter-spacing-3">letter spacing</a></td></tr><tr><td><a id="text-styles:svg-text-rendering-5" href="https://svgwg.org/svg2-draft/painting.html#TextRendering" data-x-internal="svg-text-rendering">SVG text-rendering</a></td><td><var>target</var>'s <code id="text-styles:dom-context-2d-textrendering-4"><a href="#dom-context-2d-textrendering">textRendering</a></code></td></tr><tr><td><a id="text-styles:'white-space'" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a></td><td>'pre'</td></tr><tr><td><a id="text-styles:'word-spacing'" href="https://drafts.csswg.org/css-text/#propdef-word-spacing" data-x-internal="'word-spacing'">'word-spacing'</a></td><td><var>target</var>'s <a href="#concept-canvastextdrawingstyles-word-spacing" id="text-styles:concept-canvastextdrawingstyles-word-spacing-3">word spacing</a></td></tr></tbody></table>

    <p>and with all other properties set to their initial values.</p>
   </li><li><p>If <var>maxWidth</var> was provided and the hypothetical width of the
   <a id="text-styles:inline-box-4" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a> in the hypothetical <a id="text-styles:line-box-2" href="https://drafts.csswg.org/css2/#line-box" data-x-internal="line-box">line box</a> is greater than
   <var>maxWidth</var> <a href="https://drafts.csswg.org/css-values/#px" id="text-styles:'px'-2" data-x-internal="'px'">CSS pixels</a>, then change <var>font</var> to have a
   more condensed font (if one is available or if a reasonably readable one can be synthesized by
   applying a horizontal scale factor to the font) or a smaller font, and return to the previous
   step.</p></li><li>
    <p>The <var>anchor point</var> is a point on the <a id="text-styles:inline-box-5" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, and the <var>physical
    alignment</var> is one of the values <i>left</i>, <i>right</i>, and <i>center</i>. These
    variables are determined by the <code id="text-styles:dom-context-2d-textalign-4"><a href="#dom-context-2d-textalign">textAlign</a></code> and
    <code id="text-styles:dom-context-2d-textbaseline-4"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> values as follows:</p>

    <p>Horizontal position:</p>

    <dl><dt>If <code id="text-styles:dom-context-2d-textalign-5"><a href="#dom-context-2d-textalign">textAlign</a></code> is <code id="text-styles:dom-context-2d-textalign-left"><a href="#dom-context-2d-textalign-left">left</a></code></dt><dt>If <code id="text-styles:dom-context-2d-textalign-6"><a href="#dom-context-2d-textalign">textAlign</a></code> is <code id="text-styles:dom-context-2d-textalign-start-2"><a href="#dom-context-2d-textalign-start">start</a></code> and <var>direction</var> is
     'ltr'</dt><dt>If <code id="text-styles:dom-context-2d-textalign-7"><a href="#dom-context-2d-textalign">textAlign</a></code> is <code id="text-styles:dom-context-2d-textalign-end"><a href="#dom-context-2d-textalign-end">end</a></code> and <var>direction</var> is 'rtl'</dt><dd>Set the <var>anchor point</var>'s horizontal position to the left edge of the
     <a id="text-styles:inline-box-6" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, and let <var>physical alignment</var> be <i>left</i>.</dd><dt>If <code id="text-styles:dom-context-2d-textalign-8"><a href="#dom-context-2d-textalign">textAlign</a></code> is <code id="text-styles:dom-context-2d-textalign-right"><a href="#dom-context-2d-textalign-right">right</a></code></dt><dt>If <code id="text-styles:dom-context-2d-textalign-9"><a href="#dom-context-2d-textalign">textAlign</a></code> is <code id="text-styles:dom-context-2d-textalign-end-2"><a href="#dom-context-2d-textalign-end">end</a></code> and <var>direction</var> is 'ltr'</dt><dt>If <code id="text-styles:dom-context-2d-textalign-10"><a href="#dom-context-2d-textalign">textAlign</a></code> is <code id="text-styles:dom-context-2d-textalign-start-3"><a href="#dom-context-2d-textalign-start">start</a></code> and <var>direction</var> is
     'rtl'</dt><dd>Set the <var>anchor point</var>'s horizontal position to the right edge of the
     <a id="text-styles:inline-box-7" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, and let <var>physical alignment</var> be <i>right</i>.</dd><dt>If <code id="text-styles:dom-context-2d-textalign-11"><a href="#dom-context-2d-textalign">textAlign</a></code> is <code id="text-styles:dom-context-2d-textalign-center"><a href="#dom-context-2d-textalign-center">center</a></code></dt><dd>Set the <var>anchor point</var>'s horizontal position to half way between the left
     and right edges of the <a id="text-styles:inline-box-8" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, and let <var>physical alignment</var> be
     <i>center</i>.</dd></dl>

    <p>Vertical position:</p>

    <dl><dt>If <code id="text-styles:dom-context-2d-textbaseline-5"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> is <code id="text-styles:dom-context-2d-textbaseline-top"><a href="#dom-context-2d-textbaseline-top">top</a></code></dt><dd>Set the <var>anchor point</var>'s vertical position to the top of the em box of
     the <a id="text-styles:first-available-font" href="https://drafts.csswg.org/css-fonts/#first-available-font" data-x-internal="first-available-font">first available font</a> of the <a id="text-styles:inline-box-9" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>.</dd><dt>If <code id="text-styles:dom-context-2d-textbaseline-6"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> is <code id="text-styles:dom-context-2d-textbaseline-hanging"><a href="#dom-context-2d-textbaseline-hanging">hanging</a></code></dt><dd>Set the <var>anchor point</var>'s vertical position to the <a id="text-styles:hanging-baseline-2" href="https://drafts.csswg.org/css-inline/#hanging-baseline" data-x-internal="hanging-baseline">hanging baseline</a> of
     the <a id="text-styles:first-available-font-2" href="https://drafts.csswg.org/css-fonts/#first-available-font" data-x-internal="first-available-font">first available font</a> of the <a id="text-styles:inline-box-10" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>.</dd><dt>If <code id="text-styles:dom-context-2d-textbaseline-7"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> is <code id="text-styles:dom-context-2d-textbaseline-middle"><a href="#dom-context-2d-textbaseline-middle">middle</a></code></dt><dd>Set the <var>anchor point</var>'s vertical position to half way between the bottom
     and the top of the em box of the <a id="text-styles:first-available-font-3" href="https://drafts.csswg.org/css-fonts/#first-available-font" data-x-internal="first-available-font">first available font</a> of the <a id="text-styles:inline-box-11" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline
     box</a>.</dd><dt>If <code id="text-styles:dom-context-2d-textbaseline-8"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> is <code id="text-styles:dom-context-2d-textbaseline-alphabetic-3"><a href="#dom-context-2d-textbaseline-alphabetic">alphabetic</a></code></dt><dd>Set the <var>anchor point</var>'s vertical position to the <a id="text-styles:alphabetic-baseline-2" href="https://drafts.csswg.org/css-inline/#alphabetic-baseline" data-x-internal="alphabetic-baseline">alphabetic baseline</a>
     of the <a id="text-styles:first-available-font-4" href="https://drafts.csswg.org/css-fonts/#first-available-font" data-x-internal="first-available-font">first available font</a> of the <a id="text-styles:inline-box-12" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>.</dd><dt>If <code id="text-styles:dom-context-2d-textbaseline-9"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> is <code id="text-styles:dom-context-2d-textbaseline-ideographic"><a href="#dom-context-2d-textbaseline-ideographic">ideographic</a></code></dt><dd>Set the <var>anchor point</var>'s vertical position to the <a id="text-styles:ideographic-under-baseline-2" href="https://drafts.csswg.org/css-inline/#ideographic-under-baseline" data-x-internal="ideographic-under-baseline">ideographic-under
     baseline</a> of the <a id="text-styles:first-available-font-5" href="https://drafts.csswg.org/css-fonts/#first-available-font" data-x-internal="first-available-font">first available font</a> of the <a id="text-styles:inline-box-13" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>.</dd><dt>If <code id="text-styles:dom-context-2d-textbaseline-10"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> is <code id="text-styles:dom-context-2d-textbaseline-bottom"><a href="#dom-context-2d-textbaseline-bottom">bottom</a></code></dt><dd>Set the <var>anchor point</var>'s vertical position to the bottom of the em box of
     the <a id="text-styles:first-available-font-6" href="https://drafts.csswg.org/css-fonts/#first-available-font" data-x-internal="first-available-font">first available font</a> of the <a id="text-styles:inline-box-14" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>.</dd></dl>
   </li><li>
    <p>Let <var>result</var> be an array constructed by iterating over each glyph in the
    <a id="text-styles:inline-box-15" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a> from left to right (if any), adding to the array, for each glyph, the
    shape of the glyph as it is in the <a id="text-styles:inline-box-16" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, positioned on a coordinate space
    using <a href="https://drafts.csswg.org/css-values/#px" id="text-styles:'px'-3" data-x-internal="'px'">CSS pixels</a> with its origin at the <var>anchor
    point</var>.</p>
   </li><li><p>Return <var>result</var>, <var>physical alignment</var>, and the inline
   box.</p></li></ol>
  </div>


  <h6 id="building-paths"><span class="secno">4.12.5.1.6</span> Building paths<a href="#building-paths" class="self-link"></a></h6>

  <p>Objects that implement the <code id="building-paths:canvaspath"><a href="#canvaspath">CanvasPath</a></code> interface have a <a href="#concept-path" id="building-paths:concept-path">path</a>. A <dfn id="concept-path">path</dfn> has a list of zero or
  more subpaths. Each subpath consists of a list of one or more points, connected by straight or
  curved <dfn id="line-segments">line segments</dfn>, and a flag indicating whether the subpath is closed or not. A
  closed subpath is one where the last point of the subpath is connected to the first point of the
  subpath by a straight line. Subpaths with only one point are ignored when painting the path.</p>

  <p><a href="#concept-path" id="building-paths:concept-path-2">Paths</a> have a <dfn id="need-new-subpath">need new subpath</dfn> flag. When this
  flag is set, certain APIs create a new subpath rather than extending the previous one. When a
  <a href="#concept-path" id="building-paths:concept-path-3">path</a> is created, its <a href="#need-new-subpath" id="building-paths:need-new-subpath">need new subpath</a> flag must be
  set.</p>

  <p>When an object implementing the <code id="building-paths:canvaspath-2"><a href="#canvaspath">CanvasPath</a></code> interface is created, its <a href="#concept-path" id="building-paths:concept-path-4">path</a> must be initialized to zero subpaths.</p>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-moveto" id="dom-context-2d-moveto-dev">moveTo</a>(<var>x</var>, <var>y</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/moveTo" title="The CanvasRenderingContext2D.moveTo() method of the Canvas 2D API begins a new sub-path at the point specified by the given (x, y) coordinates.">CanvasRenderingContext2D/moveTo</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dt><code><var>path</var>.<a href="#dom-context-2d-moveto" id="building-paths:dom-context-2d-moveto">moveTo</a>(<var>x</var>, <var>y</var>)</code></dt><dd><p>Creates a new subpath with the given point.</p></dd><dt><code><var>context</var>.<a href="#dom-context-2d-closepath" id="dom-context-2d-closepath-dev">closePath</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/closePath" title="The CanvasRenderingContext2D.closePath() method of the Canvas 2D API attempts to add a straight line from the current point to the start of the current sub-path. If the shape has already been closed or has only one point, this function does nothing.">CanvasRenderingContext2D/closePath</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dt><code><var>path</var>.<a href="#dom-context-2d-closepath" id="building-paths:dom-context-2d-closepath">closePath</a>()</code></dt><dd>
    <p>Marks the current subpath as closed, and starts a new subpath with a point the same as the
    start and end of the newly closed subpath.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-lineto" id="dom-context-2d-lineto-dev">lineTo</a>(<var>x</var>, <var>y</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineTo" title="The CanvasRenderingContext2D method lineTo(), part of the Canvas 2D API, adds a straight line to the current sub-path by connecting the sub-path's last point to the specified (x, y) coordinates.">CanvasRenderingContext2D/lineTo</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dt><code><var>path</var>.<a href="#dom-context-2d-lineto" id="building-paths:dom-context-2d-lineto">lineTo</a>(<var>x</var>, <var>y</var>)</code></dt><dd>
    <p>Adds the given point to the current subpath, connected to the previous one by a straight
    line.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-quadraticcurveto" id="dom-context-2d-quadraticcurveto-dev">quadraticCurveTo</a>(<var>cpx</var>, <var>cpy</var>, <var>x</var>, <var>y</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/quadraticCurveTo" title="The CanvasRenderingContext2D.quadraticCurveTo() method of the Canvas 2D API adds a quadratic Bézier curve to the current sub-path. It requires two points: the first one is a control point and the second one is the end point. The starting point is the latest point in the current path, which can be changed using moveTo() before creating the quadratic Bézier curve.">CanvasRenderingContext2D/quadraticCurveTo</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dt><code><var>path</var>.<a href="#dom-context-2d-quadraticcurveto" id="building-paths:dom-context-2d-quadraticcurveto">quadraticCurveTo</a>(<var>cpx</var>, <var>cpy</var>, <var>x</var>, <var>y</var>)</code></dt><dd>
    <p>Adds the given point to the current subpath, connected to the previous one by a quadratic
    Bézier curve with the given control point.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-beziercurveto" id="dom-context-2d-beziercurveto-dev">bezierCurveTo</a>(<var>cp1x</var>, <var>cp1y</var>, <var>cp2x</var>, <var>cp2y</var>, <var>x</var>, <var>y</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/bezierCurveTo" title="The CanvasRenderingContext2D.bezierCurveTo() method of the Canvas 2D API adds a cubic Bézier curve to the current sub-path. It requires three points: the first two are control points and the third one is the end point. The starting point is the latest point in the current path, which can be changed using moveTo() before creating the Bézier curve.">CanvasRenderingContext2D/bezierCurveTo</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dt><code><var>path</var>.<a href="#dom-context-2d-beziercurveto" id="building-paths:dom-context-2d-beziercurveto">bezierCurveTo</a>(<var>cp1x</var>, <var>cp1y</var>, <var>cp2x</var>, <var>cp2y</var>, <var>x</var>, <var>y</var>)</code></dt><dd>
    <p>Adds the given point to the current subpath, connected to the previous one by a cubic Bézier
    curve with the given control points.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-arcto" id="dom-context-2d-arcto-dev">arcTo</a>(<var>x1</var>, <var>y1</var>, <var>x2</var>, <var>y2</var>, <var>radius</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/arcTo" title="The CanvasRenderingContext2D.arcTo() method of the Canvas 2D API adds a circular arc to the current sub-path, using the given control points and radius. The arc is automatically connected to the path's latest point with a straight line, if necessary for the specified parameters.">CanvasRenderingContext2D/arcTo</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dt><code><var>path</var>.<a href="#dom-context-2d-arcto" id="building-paths:dom-context-2d-arcto">arcTo</a>(<var>x1</var>, <var>y1</var>, <var>x2</var>, <var>y2</var>, <var>radius</var>)</code></dt><dd>
    <p>Adds an arc with the given control points and radius to the current subpath, connected to the
    previous point by a straight line.</p>

    <p>Throws an <a id="building-paths:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="building-paths:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the given
    radius is negative.</p>

    <figure class="diagrams">
     
     <img width="357" src="/images/arcTo1.png" height="254" alt="">
     <img width="468" src="/images/arcTo2.png" height="310" alt="">
     <img width="513" src="/images/arcTo3.png" height="233" alt="">
    </figure>


   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-arc" id="dom-context-2d-arc-dev">arc</a>(<var>x</var>, <var>y</var>, <var>radius</var>, <var>startAngle</var>, <var>endAngle</var> [, <var>counterclockwise</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/arc" title="The CanvasRenderingContext2D.arc() method of the Canvas 2D API adds a circular arc to the current sub-path.">CanvasRenderingContext2D/arc</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dt><code><var>path</var>.<a href="#dom-context-2d-arc" id="building-paths:dom-context-2d-arc">arc</a>(<var>x</var>, <var>y</var>, <var>radius</var>, <var>startAngle</var>, <var>endAngle</var> [, <var>counterclockwise</var> ])</code></dt><dd>
    <p>Adds points to the subpath such that the arc described by the circumference of the circle
    described by the arguments, starting at the given start angle and ending at the given end angle,
    going in the given direction (defaulting to clockwise), is added to the path, connected to the
    previous point by a straight line.</p>

    <p>Throws an <a id="building-paths:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="building-paths:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the given
    radius is negative.</p>

    <figure class="diagrams">
     
     <img width="590" src="/images/arc1.png" height="255" alt="">
    </figure>


   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-ellipse" id="dom-context-2d-ellipse-dev">ellipse</a>(<var>x</var>, <var>y</var>, <var>radiusX</var>, <var>radiusY</var>, <var>rotation</var>, <var>startAngle</var>, <var>endAngle</var> [, <var>counterclockwise</var>])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse" title="The CanvasRenderingContext2D.ellipse() method of the Canvas 2D API adds an elliptical arc to the current sub-path.">CanvasRenderingContext2D/ellipse</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>48+</span></span><span class="safari yes"><span>Safari</span><span>9+</span></span><span class="chrome yes"><span>Chrome</span><span>31+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>path</var>.<a href="#dom-context-2d-ellipse" id="building-paths:dom-context-2d-ellipse">ellipse</a>(<var>x</var>, <var>y</var>, <var>radiusX</var>, <var>radiusY</var>, <var>rotation</var>, <var>startAngle</var>, <var>endAngle</var> [, <var>counterclockwise</var>])</code></dt><dd>
    <p>Adds points to the subpath such that the arc described by the circumference of the ellipse
    described by the arguments, starting at the given start angle and ending at the given end angle,
    going in the given direction (defaulting to clockwise), is added to the path, connected to the
    previous point by a straight line.</p>

    <p>Throws an <a id="building-paths:indexsizeerror-3" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="building-paths:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the given
    radius is negative.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-rect" id="dom-context-2d-rect-dev">rect</a>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/rect" title="The CanvasRenderingContext2D.rect() method of the Canvas 2D API adds a rectangle to the current path.">CanvasRenderingContext2D/rect</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dt><code><var>path</var>.<a href="#dom-context-2d-rect" id="building-paths:dom-context-2d-rect">rect</a>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)</code></dt><dd><p>Adds a new closed subpath to the path, representing the given rectangle.</p></dd><dt><code><var>context</var>.<a href="#dom-context-2d-roundrect" id="dom-context-2d-roundrect-dev">roundRect</a>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>, <var>radii</var>)</code></dt><dt><code><var>path</var>.<a href="#dom-context-2d-roundrect" id="building-paths:dom-context-2d-roundrect">roundRect</a>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>, <var>radii</var>)</code></dt><dd>
    <p>Adds a new closed subpath to the path representing the given rounded rectangle.
    <var>radii</var> is either a list of radii or a single radius representing the corners of the
    rectangle in pixels. If a list is provided, the number and order of these radii function in the
    same way as the CSS <a id="building-paths:'border-radius'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-radius" data-x-internal="'border-radius'">'border-radius'</a> property. A single radius behaves the same way
    as a list with a single element.</p>

    <p>If <var>w</var> and <var>h</var> are both greater than or equal to 0, or if both are smaller
    than 0, then the path is drawn clockwise. Otherwise, it is drawn counterclockwise.</p>

    <p>When <var>w</var> is negative, the rounded rectangle is flipped horizontally, which means
    that the radius values that normally apply to the left corners are used on the right and vice
    versa. Similarly, when <var>h</var> is negative, the rounded rect is flipped vertically.</p>

    <p>When a value <var>r</var> in <var>radii</var> is a number, the corresponding corner(s) are
    drawn as circular arcs of radius <var>r</var>.</p>

    <p>When a value <var>r</var> in <var>radii</var> is an object with <code>{ x, y
    }</code> properties, the corresponding corner(s) are drawn as elliptical arcs whose <var>x</var>
    and <var>y</var> radii are equal to <var>r.x</var> and <var>r.y</var>, respectively.</p>

    <p>When the sum of the <var>radii</var> of two corners of the same edge is greater than the
    length of the edge, all the <var>radii</var> of the rounded rectangle are scaled by a factor of
    length / (<var>r1</var> + <var>r2</var>). If multiple edges have this property, the scale factor
    of the edge with the smallest scale factor is used. This is consistent with CSS behavior.</p>

    <p>Throws a <code id="building-paths:js-rangeerror"><a data-x-internal="js-rangeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror">RangeError</a></code> if <var>radii</var> is a list whose
    size is not one, two, three, or four.</p>

    <p>Throws a <code id="building-paths:js-rangeerror-2"><a data-x-internal="js-rangeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror">RangeError</a></code> if a value in <var>radii</var> is a
    negative number, or is an <code>{ x, y }</code> object whose <code>x</code>
    or <code>y</code> properties are negative numbers.</p>

    
    
   </dd></dl>

  

  <p>The following methods allow authors to manipulate the <a href="#concept-path" id="building-paths:concept-path-5">paths</a>
  of objects implementing the <code id="building-paths:canvaspath-3"><a href="#canvaspath">CanvasPath</a></code> interface.</p>

  <p>For objects implementing the <code id="building-paths:canvasdrawpath"><a href="#canvasdrawpath">CanvasDrawPath</a></code> and <code id="building-paths:canvastransform"><a href="#canvastransform">CanvasTransform</a></code>
  interfaces, the points passed to the methods, and the resulting lines added to <a href="#current-default-path" id="building-paths:current-default-path">current
  default path</a> by these methods, must be transformed according to the <a href="#transformations" id="building-paths:transformations">current transformation matrix</a> before being added to
  the path.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-moveto" data-dfn-type="method"><code>moveTo(<var>x</var>,
  <var>y</var>)</code></dfn> method, when invoked, must run these steps:</p>

  <ol><li><p>If either of the arguments are infinite or NaN, then return.</p></li><li><p>Create a new subpath with the specified point as its first (and only) point.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the user agent is to <dfn id="ensure-there-is-a-subpath">ensure there is a subpath</dfn> for a coordinate (<var>x</var>,
  <var>y</var>) on a <a href="#concept-path" id="building-paths:concept-path-6">path</a>, the user agent must check to see if
  the <a href="#concept-path" id="building-paths:concept-path-7">path</a> has its <a href="#need-new-subpath" id="building-paths:need-new-subpath-2">need new subpath</a> flag set. If it
  does, then the user agent must create a new subpath with the point (<var>x</var>, <var>y</var>) as
  its first (and only) point, as if the <code id="building-paths:dom-context-2d-moveto-2"><a href="#dom-context-2d-moveto">moveTo()</a></code> method
  had been called, and must then unset the <a href="#concept-path" id="building-paths:concept-path-8">path</a>'s <a href="#need-new-subpath" id="building-paths:need-new-subpath-3">need new
  subpath</a> flag.</p>
  </div>


  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-closepath" data-dfn-type="method"><code>closePath()</code></dfn> method, when invoked, must do nothing
  if the object's path has no subpaths. Otherwise, it must mark the last subpath as closed, create a
  new subpath whose first point is the same as the previous subpath's first point, and finally add
  this new subpath to the path.</p>
  </div>

  <p class="note">If the last subpath had more than one point in its list of points, then this is
  equivalent to adding a straight line connecting the last point back to the first point of the last
  subpath, thus "closing" the subpath.</p>

  <hr>

  <p>New points and the lines connecting them are added to subpaths using the methods described
  below. In all cases, the methods only modify the last subpath in the object's path.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-lineto" data-dfn-type="method"><code>lineTo(<var>x</var>,
  <var>y</var>)</code></dfn> method, when invoked, must run these steps:</p>

  <ol><li><p>If either of the arguments are infinite or NaN, then return.</p></li><li><p>If the object's path has no subpaths, then <a href="#ensure-there-is-a-subpath" id="building-paths:ensure-there-is-a-subpath">ensure there is a subpath</a> for
   <span>(<var>x</var>, <var>y</var>)</span>.</p></li><li><p>Otherwise, connect the last point in the subpath to the given point (<var>x</var>,
   <var>y</var>) using a straight line, and then add the given point (<var>x</var>, <var>y</var>) to
   the subpath.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-quadraticcurveto" data-dfn-type="method"><code>quadraticCurveTo(<var>cpx</var>, <var>cpy</var>,
  <var>x</var>, <var>y</var>)</code></dfn> method, when invoked, must run these steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p><a href="#ensure-there-is-a-subpath" id="building-paths:ensure-there-is-a-subpath-2">Ensure there is a subpath</a> for <span>(<var>cpx</var>,
   <var>cpy</var>)</span>.</p></li><li><p>Connect the last point in the subpath to the given point (<var>x</var>, <var>y</var>)
   using a quadratic Bézier curve with control point (<var>cpx</var>, <var>cpy</var>).
   <a href="#refsBEZIER">[BEZIER]</a></p></li><li><p>Add the given point (<var>x</var>, <var>y</var>) to the subpath.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-beziercurveto" data-dfn-type="method"><code>bezierCurveTo(<var>cp1x</var>, <var>cp1y</var>,
  <var>cp2x</var>, <var>cp2y</var>, <var>x</var>, <var>y</var>)</code></dfn> method, when invoked,
  must run these steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p><a href="#ensure-there-is-a-subpath" id="building-paths:ensure-there-is-a-subpath-3">Ensure there is a subpath</a> for <span>(<var>cp1x</var>,
   <var>cp1y</var>)</span>.</p></li><li><p>Connect the last point in the subpath to the given point (<var>x</var>, <var>y</var>)
   using a cubic Bézier curve with control points (<var>cp1x</var>, <var>cp1y</var>) and
   (<var>cp2x</var>, <var>cp2y</var>). <a href="#refsBEZIER">[BEZIER]</a></p></li><li><p>Add the point (<var>x</var>, <var>y</var>) to the subpath.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-arcto" data-dfn-type="method"><code>arcTo(<var>x1</var>,
  <var>y1</var>, <var>x2</var>, <var>y2</var>, <var>radius</var>)</code></dfn> method, when invoked,
  must run these steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p><a href="#ensure-there-is-a-subpath" id="building-paths:ensure-there-is-a-subpath-4">Ensure there is a subpath</a> for <span>(<var>x1</var>,
   <var>y1</var>)</span>.</p></li><li><p>If <var>radius</var> is negative, then throw an <a id="building-paths:indexsizeerror-4" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a>
   <code id="building-paths:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let the point (<var>x0</var>, <var>y0</var>) be the last point in the subpath, transformed
   by the inverse of the <a href="#transformations" id="building-paths:transformations-2">current transformation
   matrix</a> (so that it is in the same coordinate system as the points passed to the
   method).</p></li><li><p>If the point (<var>x0</var>, <var>y0</var>) is equal to the point (<var>x1</var>,
   <var>y1</var>), or if the point (<var>x1</var>, <var>y1</var>) is equal to the point
   (<var>x2</var>, <var>y2</var>), or if <var>radius</var> is zero, then add the point
   (<var>x1</var>, <var>y1</var>) to the subpath, and connect that point to the previous point
   (<var>x0</var>, <var>y0</var>) by a straight line.</p></li><li><p>Otherwise, if the points (<var>x0</var>, <var>y0</var>), (<var>x1</var>, <var>y1</var>),
   and (<var>x2</var>, <var>y2</var>) all lie on a single straight line, then add the point
   (<var>x1</var>, <var>y1</var>) to the subpath, and connect that point to the previous point
   (<var>x0</var>, <var>y0</var>) by a straight line.</p></li><li><p>Otherwise, let <var>The Arc</var> be the shortest arc given by circumference of the circle
   that has radius <var>radius</var>, and that has one point tangent to the half-infinite line that
   crosses the point (<var>x0</var>, <var>y0</var>) and ends at the point (<var>x1</var>,
   <var>y1</var>), and that has a different point tangent to the half-infinite line that ends at the
   point (<var>x1</var>, <var>y1</var>) and crosses the point (<var>x2</var>, <var>y2</var>). The
   points at which this circle touches these two lines are called the start and end tangent points
   respectively. Connect the point (<var>x0</var>, <var>y0</var>) to the start tangent point by a
   straight line, adding the start tangent point to the subpath, and then connect the start tangent
   point to the end tangent point by <var>The Arc</var>, adding the end tangent point to the
   subpath.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-arc" data-dfn-type="method"><code>arc(<var>x</var>,
  <var>y</var>, <var>radius</var>, <var>startAngle</var>, <var>endAngle</var>,
  <var>counterclockwise</var>)</code></dfn> method, when invoked, must run the <a href="#ellipse-method-steps" id="building-paths:ellipse-method-steps">ellipse method
  steps</a> with <a id="building-paths:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>x</var>, <var>y</var>, <var>radius</var>, <var>radius</var>, 0,
  <var>startAngle</var>, <var>endAngle</var>, and <var>counterclockwise</var>.</p>
  </div>

  <p class="note">This makes it equivalent to <code id="building-paths:dom-context-2d-ellipse-2"><a href="#dom-context-2d-ellipse">ellipse()</a></code>
  except that both radii are equal and <var>rotation</var> is 0.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-ellipse" data-dfn-type="method"><code>ellipse(<var>x</var>,
  <var>y</var>, <var>radiusX</var>, <var>radiusY</var>, <var>rotation</var>, <var>startAngle</var>,
  <var>endAngle</var>, <var>counterclockwise</var>)</code></dfn> method, when invoked, must run the
  <a href="#ellipse-method-steps" id="building-paths:ellipse-method-steps-2">ellipse method steps</a> with <a id="building-paths:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>x</var>, <var>y</var>, <var>radiusX</var>,
  <var>radiusY</var>, <var>rotation</var>, <var>startAngle</var>, <var>endAngle</var>, and
  <var>counterclockwise</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="determine-the-point-on-an-ellipse-steps">determine the point on an ellipse steps</dfn>, given <var>ellipse</var>, and
  <var>angle</var>, are:</p>

  <ol><li><p>Let <var>eccentricCircle</var> be the circle that shares its origin with
   <var>ellipse</var>, with a radius equal to the semi-major axis of <var>ellipse</var>.</p></li><li><p>Let <var>outerPoint</var> be the point on <var>eccentricCircle</var>'s circumference at
   <var>angle</var> measured in radians clockwise from <var>ellipse</var>'s semi-major
   axis.</p></li><li><p>Let <var>chord</var> be the line perpendicular to <var>ellipse</var>'s major axis between
   this axis and <var>outerPoint</var>.</p></li><li><p>Return the point on <var>chord</var> that crosses <var>ellipse</var>'s
   circumference.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="ellipse-method-steps">ellipse method steps</dfn>, given <var>canvasPath</var>, <var>x</var>, <var>y</var>,
  <var>radiusX</var>, <var>radiusY</var>, <var>rotation</var>, <var>startAngle</var>,
  <var>endAngle</var>, and <var>counterclockwise</var>, are:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p>If either <var>radiusX</var> or <var>radiusY</var> are negative, then throw an
   <a id="building-paths:indexsizeerror-5" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="building-paths:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>canvasPath</var>'s path has any subpaths, then add a straight line from the last
   point in the subpath to the start point of the arc.</p></li><li>
    <p>Add the start and end points of the arc to the subpath, and connect them with an arc. The
    arc and its start and end points are defined as follows:</p>

    <p>Consider an ellipse that has its origin at (<var>x</var>, <var>y</var>), that has a
    major-axis radius <var>radiusX</var> and a minor-axis radius <var>radiusY</var>, and that is
    rotated about its origin such that its semi-major axis is inclined <var>rotation</var> radians
    clockwise from the x-axis.</p>

    <p>If <var>counterclockwise</var> is false and <span><var>endAngle</var> −
    <var>startAngle</var></span> is greater than or equal to <span>2π</span>, or, if
    <var>counterclockwise</var> is <em>true</em> and <span><var>startAngle</var> −
    <var>endAngle</var></span> is greater than or equal to <span>2π</span>, then the
    arc is the whole circumference of this ellipse, and both the start point and the end point are
    the result of running the <a href="#determine-the-point-on-an-ellipse-steps" id="building-paths:determine-the-point-on-an-ellipse-steps">determine the point on an ellipse steps</a> given this
    ellipse and <var>startAngle</var>.</p>

    <p>Otherwise, the start point is the result of running the <a href="#determine-the-point-on-an-ellipse-steps" id="building-paths:determine-the-point-on-an-ellipse-steps-2">determine the point on an
    ellipse steps</a> given this ellipse and <var>startAngle</var>, the end point is the result
    of running the <a href="#determine-the-point-on-an-ellipse-steps" id="building-paths:determine-the-point-on-an-ellipse-steps-3">determine the point on an ellipse steps</a> given this ellipse and
    <var>endAngle</var>, and the arc is the path along the circumference of this ellipse from the
    start point to the end point, going counterclockwise if <var>counterclockwise</var> is true,
    and clockwise otherwise. Since the points are on the ellipse, as opposed to being simply angles
    from zero, the arc can never cover an angle greater than <span>2π</span>
    radians.</p>

    <p class="note">Even if the arc covers the entire circumference of the ellipse and there are no
    other points in the subpath, the path is not closed unless the <code id="building-paths:dom-context-2d-closepath-2"><a href="#dom-context-2d-closepath">closePath()</a></code> method is appropriately invoked.</p>
   </li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-rect" data-dfn-type="method"><code>rect(<var>x</var>,
  <var>y</var>, <var>w</var>, <var>h</var>)</code></dfn> method, when invoked, must run these
  steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p>Create a new subpath containing just the four points (<var>x</var>, <var>y</var>),
   (<var>x</var>+<var>w</var>, <var>y</var>), (<var>x</var>+<var>w</var>,
   <var>y</var>+<var>h</var>), (<var>x</var>, <var>y</var>+<var>h</var>), in that order, with those
   four points connected by straight lines.</p></li><li><p>Mark the subpath as closed.</p></li><li><p>Create a new subpath with the point (<var>x</var>, <var>y</var>) as the only point in the
   subpath.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/roundRect" title="The CanvasRenderingContext2D.roundRect() method of the Canvas 2D API adds a rounded rectangle to the current path.">CanvasRenderingContext2D/roundRect</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>112+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPath" id="dom-context-2d-roundrect" data-dfn-type="method"><code>roundRect(<var>x</var>, <var>y</var>, <var>w</var>,
  <var>h</var>, <var>radii</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If any of <var>x</var>, <var>y</var>, <var>w</var>, or <var>h</var> are infinite or NaN,
   then return.</p></li><li><p>If <var>radii</var> is an <code id="building-paths:idl-unrestricted-double"><a data-x-internal="idl-unrestricted-double" href="https://webidl.spec.whatwg.org/#idl-unrestricted-double">unrestricted
   double</a></code> or <code id="building-paths:dompointinit"><a data-x-internal="dompointinit" href="https://drafts.fxtf.org/geometry/#dictdef-dompointinit">DOMPointInit</a></code>, then set <var>radii</var> to « <var>radii</var>
   ».</p></li><li><p>If <var>radii</var> is not a list of size one, two, three, or four, then throw a <code id="building-paths:js-rangeerror-3"><a data-x-internal="js-rangeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror">RangeError</a></code>.</p></li><li><p>Let <var>normalizedRadii</var> be an empty list.</p></li><li>
    <p>For each <var>radius</var> of <var>radii</var>:</p>

    <ol><li>
      <p>If <var>radius</var> is a <code id="building-paths:dompointinit-2"><a data-x-internal="dompointinit" href="https://drafts.fxtf.org/geometry/#dictdef-dompointinit">DOMPointInit</a></code>:</p>

      <ol><li><p>If <var>radius</var>["<code id="building-paths:dompointinit-x"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"] or
       <var>radius</var>["<code id="building-paths:dompointinit-y"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"] is infinite or NaN, then
       return.</p></li><li><p>If <var>radius</var>["<code id="building-paths:dompointinit-x-2"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"] or
       <var>radius</var>["<code id="building-paths:dompointinit-y-2"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"] is negative, then throw a <code id="building-paths:js-rangeerror-4"><a data-x-internal="js-rangeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror">RangeError</a></code>.</p></li><li><p>Otherwise, append <var>radius</var> to <var>normalizedRadii</var>.</p></li></ol>
     </li><li>
      <p>If <var>radius</var> is a <code id="building-paths:idl-unrestricted-double-2"><a data-x-internal="idl-unrestricted-double" href="https://webidl.spec.whatwg.org/#idl-unrestricted-double">unrestricted
      double</a></code>:</p>

      <ol><li><p>If <var>radius</var> is infinite or NaN, then return.</p></li><li><p>If <var>radius</var> is negative, then throw a <code id="building-paths:js-rangeerror-5"><a data-x-internal="js-rangeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror">RangeError</a></code>.</p></li><li><p>Otherwise, append «[ "<code id="building-paths:dompointinit-x-3"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>" → <var>radius</var>,
       "<code id="building-paths:dompointinit-x-4"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">y</a></code>" → <var>radius</var> ]» to
       <var>normalizedRadii</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Let <var>upperLeft</var>, <var>upperRight</var>, <var>lowerRight</var>, and
   <var>lowerLeft</var> be null.</p></li><li><p>If <var>normalizedRadii</var>'s size is 4, then set <var>upperLeft</var> to
   <var>normalizedRadii</var>[0], set <var>upperRight</var> to <var>normalizedRadii</var>[1], set
   <var>lowerRight</var> to <var>normalizedRadii</var>[2], and set <var>lowerLeft</var> to
   <var>normalizedRadii</var>[3].</p></li><li><p>If <var>normalizedRadii</var>'s size is 3, then set <var>upperLeft</var> to
   <var>normalizedRadii</var>[0], set <var>upperRight</var> and <var>lowerLeft</var> to
   <var>normalizedRadii</var>[1], and set <var>lowerRight</var> to
   <var>normalizedRadii</var>[2].</p></li><li><p>If <var>normalizedRadii</var>'s size is 2, then set <var>upperLeft</var> and
   <var>lowerRight</var> to <var>normalizedRadii</var>[0] and set <var>upperRight</var> and
   <var>lowerLeft</var> to <var>normalizedRadii</var>[1].</p></li><li><p>If <var>normalizedRadii</var>'s size is 1, then set <var>upperLeft</var>,
   <var>upperRight</var>, <var>lowerRight</var>, and <var>lowerLeft</var> to
   <var>normalizedRadii</var>[0].</p></li><li>
    <p>Corner curves must not overlap. Scale all radii to prevent this:</p>

    <ol><li><p>Let <var>top</var> be <var>upperLeft</var>["<code id="building-paths:dompointinit-x-5"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"] +
     <var>upperRight</var>["<code id="building-paths:dompointinit-x-6"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"].</p></li><li><p>Let <var>right</var> be <var>upperRight</var>["<code id="building-paths:dompointinit-y-3"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"] + <var>lowerRight</var>["<code id="building-paths:dompointinit-y-4"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"].</p></li><li><p>Let <var>bottom</var> be <var>lowerRight</var>["<code id="building-paths:dompointinit-x-7"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"] + <var>lowerLeft</var>["<code id="building-paths:dompointinit-x-8"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"].</p></li><li><p>Let <var>left</var> be <var>upperLeft</var>["<code id="building-paths:dompointinit-y-5"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"]
     + <var>lowerLeft</var>["<code id="building-paths:dompointinit-y-6"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"].</p></li><li><p>Let <var>scale</var> be the minimum value of the ratios <var>w</var> / <var>top</var>,
     <var>h</var> / <var>right</var>, <var>w</var> / <var>bottom</var>, <var>h</var> /
     <var>left</var>.</p></li><li><p>If <var>scale</var> is less than 1, then set the <code id="building-paths:dompointinit-x-9"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>
     and <code id="building-paths:dompointinit-y-7"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code> members of <var>upperLeft</var>,
     <var>upperRight</var>, <var>lowerLeft</var>, and <var>lowerRight</var> to their current values
     multiplied by <var>scale</var>.</p></li></ol>
   </li><li>
    <p>Create a new subpath:</p>

    <ol><li><p>Move to the point (<var>x</var> + <var>upperLeft</var>["<code id="building-paths:dompointinit-x-10"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"], <var>y</var>).</p></li><li><p>Draw a straight line to the point (<var>x</var> + <var>w</var> −
     <var>upperRight</var>["<code id="building-paths:dompointinit-x-11"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"], <var>y</var>).</p></li><li><p>Draw an arc to the point (<var>x</var> + <var>w</var>, <var>y</var> +
     <var>upperRight</var>["<code id="building-paths:dompointinit-y-8"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"]).</p></li><li><p>Draw a straight line to the point (<var>x</var> + <var>w</var>, <var>y</var> +
     <var>h</var> − <var>lowerRight</var>["<code id="building-paths:dompointinit-y-9"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"]).</p></li><li><p>Draw an arc to the point (<var>x</var> + <var>w</var> −
     <var>lowerRight</var>["<code id="building-paths:dompointinit-x-12"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"], <var>y</var> +
     <var>h</var>).</p></li><li><p>Draw a straight line to the point (<var>x</var> + <var>lowerLeft</var>["<code id="building-paths:dompointinit-x-13"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"], <var>y</var> + <var>h</var>).</p></li><li><p>Draw an arc to the point (<var>x</var>, <var>y</var> + <var>h</var> −
     <var>lowerLeft</var>["<code id="building-paths:dompointinit-y-10"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"]).</p></li><li><p>Draw a straight line to the point (<var>x</var>, <var>y</var> +
     <var>upperLeft</var>["<code id="building-paths:dompointinit-y-11"><a data-x-internal="dompointinit-y" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</a></code>"]).</p></li><li><p>Draw an arc to the point (<var>x</var> + <var>upperLeft</var>["<code id="building-paths:dompointinit-x-14"><a data-x-internal="dompointinit-x" href="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</a></code>"], <var>y</var>).</p></li></ol>
   </li><li><p>Mark the subpath as closed.</p></li><li><p>Create a new subpath with the point (<var>x</var>, <var>y</var>) as the only point in the
   subpath.</p></li></ol>
  </div>

  <p class="note">This is designed to behave similarly to the CSS <a href="https://drafts.csswg.org/css-backgrounds/#propdef-border-radius" id="building-paths:'border-radius'-2" data-x-internal="'border-radius'">'border-radius'</a> property.</p>

  

  



  <h6 id="path2d-objects"><span class="secno">4.12.5.1.7</span> <code id="path2d-objects:path2d"><a href="#path2d">Path2D</a></code> objects<a href="#path2d-objects" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Path2D" title="The Path2D interface of the Canvas 2D API is used to declare a path that can then be used on a CanvasRenderingContext2D object. The path methods of the CanvasRenderingContext2D interface are also present on this interface, which gives you the convenience of being able to retain and replay your path whenever desired.">Path2D</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>36+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p><code id="path2d-objects:path2d-2"><a href="#path2d">Path2D</a></code> objects can be used to declare paths that are then later used on
  objects implementing the <code id="path2d-objects:canvasdrawpath"><a href="#canvasdrawpath">CanvasDrawPath</a></code> interface. In addition to many of the APIs
  described in earlier sections, <code id="path2d-objects:path2d-3"><a href="#path2d">Path2D</a></code> objects have methods to combine paths, and to
  add text to paths.</p>

  <dl class="domintro"><dt><code><var>path</var> = new <a href="#dom-path2d" id="dom-path2d-dev">Path2D</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D" title="The Path2D() constructor returns a newly instantiated Path2D object, optionally with another path as an argument (creates a copy), or optionally with a string consisting of SVG path data.">Path2D/Path2D</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>36+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Creates a new empty <code id="path2d-objects:path2d-4"><a href="#path2d">Path2D</a></code> object.</p></dd><dt><code><var>path</var> = new <a href="#dom-path2d" id="path2d-objects:dom-path2d">Path2D</a>(<var>path</var>)</code></dt><dd>
    <p>When <var>path</var> is a <code id="path2d-objects:path2d-5"><a href="#path2d">Path2D</a></code> object, returns a copy.</p>

    <p>When <var>path</var> is a string, creates the path described by the argument, interpreted as
    SVG path data. <a href="#refsSVG">[SVG]</a>
   </p></dd><dt><code><var>path</var>.<a href="#dom-path2d-addpath" id="dom-path2d-addpath-dev">addPath</a>(<var>path</var> [, <var>transform</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Path2D/addPath" title="The Path2D.addPath() method of the Canvas 2D API adds one Path2D object to another Path2D object.">Path2D/addPath</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>34+</span></span><span class="safari yes"><span>Safari</span><span>9+</span></span><span class="chrome yes"><span>Chrome</span><span>68+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Adds to the path the path given by the argument.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Path2D" id="dom-path2d" data-dfn-type="constructor"><code>Path2D(<var>path</var>)</code></dfn> constructor, when invoked, must run these
  steps:</p>

  <ol><li><p>Let <var>output</var> be a new <code id="path2d-objects:path2d-6"><a href="#path2d">Path2D</a></code> object.</p></li><li><p>If <var>path</var> is not given, then return <var>output</var>.</p></li><li><p>If <var>path</var> is a <code id="path2d-objects:path2d-7"><a href="#path2d">Path2D</a></code> object, then add all subpaths of
   <var>path</var> to <var>output</var> and return <var>output</var>. (In other words, it returns a
   copy of the argument.)</p></li><li>
    <p>Let <var>svgPath</var> be the result of parsing and interpreting <var>path</var> according to
    <cite>SVG 2</cite>'s rules for path data. <a href="#refsSVG">[SVG]</a></p>

    <p class="note">The resulting path could be empty. SVG defines error handling rules for parsing
    and applying path data.</p>
   </li><li><p>Let (<var>x</var>, <var>y</var>) be the last point in <var>svgPath</var>.</p></li><li><p>Add all the subpaths, if any, from <var>svgPath</var> to <var>output</var>.</p></li><li><p>Create a new subpath in <var>output</var> with (<var>x</var>, <var>y</var>) as the only
   point in the subpath.</p></li><li><p>Return <var>output</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Path2D" id="dom-path2d-addpath" data-dfn-type="method"><code>addPath(<var>path</var>,
  <var>transform</var>)</code></dfn> method, when invoked on a <code id="path2d-objects:path2d-8"><a href="#path2d">Path2D</a></code> object
  <var>a</var>, must run these steps:</p>

  <ol><li><p>If the <code id="path2d-objects:path2d-9"><a href="#path2d">Path2D</a></code> object <var>path</var> has no subpaths, then return.</p></li><li><p>Let <var>matrix</var> be the result of <a href="https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-2d-dictionary" id="path2d-objects:create-a-dommatrix-from-a-2d-dictionary" data-x-internal="create-a-dommatrix-from-a-2d-dictionary">creating a <code>DOMMatrix</code> from the 2D dictionary</a>
   <var>transform</var>.</p></li><li><p>If one or more of <var>matrix</var>'s <a id="path2d-objects:m11-element" href="https://drafts.fxtf.org/geometry/#matrix-m11-element" data-x-internal="m11-element">m11 element</a>, <a id="path2d-objects:m12-element" href="https://drafts.fxtf.org/geometry/#matrix-m12-element" data-x-internal="m12-element">m12 element</a>,
   <a id="path2d-objects:m21-element" href="https://drafts.fxtf.org/geometry/#matrix-m21-element" data-x-internal="m21-element">m21 element</a>, <a id="path2d-objects:m22-element" href="https://drafts.fxtf.org/geometry/#matrix-m22-element" data-x-internal="m22-element">m22 element</a>, <a id="path2d-objects:m41-element" href="https://drafts.fxtf.org/geometry/#matrix-m41-element" data-x-internal="m41-element">m41 element</a>, or <a id="path2d-objects:m42-element" href="https://drafts.fxtf.org/geometry/#matrix-m42-element" data-x-internal="m42-element">m42
   element</a> are infinite or NaN, then return.</p></li><li><p>Create a copy of all the subpaths in <var>path</var>. Let <var>c</var> be this
   copy.</p></li><li><p>Transform all the coordinates and lines in <var>c</var> by the transform matrix
   <var>matrix</var>.</p></li><li><p>Let (<var>x</var>, <var>y</var>) be the last point in the last subpath
   of <var>c</var>.</p></li><li><p>Add all the subpaths in <var>c</var> to <var>a</var>.</p></li><li><p>Create a new subpath in <var>a</var> with (<var>x</var>, <var>y</var>) as the only point
   in the subpath.</p></li></ol>
  </div>

  


  <h6 id="transformations"><span class="secno">4.12.5.1.8</span> <dfn>Transformations</dfn><a href="#transformations" class="self-link"></a></h6>

  <p>Objects that implement the <code id="transformations:canvastransform"><a href="#canvastransform">CanvasTransform</a></code> interface have a <dfn id="current-transformation-matrix">current
  transformation matrix</dfn>, as well as methods (described in this section) to manipulate it. When
  an object implementing the <code id="transformations:canvastransform-2"><a href="#canvastransform">CanvasTransform</a></code> interface is created, its transformation
  matrix must be initialized to the identity matrix.</p>

  <p>The <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix">current transformation matrix</a> is applied to coordinates when creating the
  <a href="#current-default-path" id="transformations:current-default-path">current default path</a>, and when painting text, shapes, and <code id="transformations:path2d"><a href="#path2d">Path2D</a></code>
  objects, on objects implementing the <code id="transformations:canvastransform-3"><a href="#canvastransform">CanvasTransform</a></code> interface.</p>
  

  

  <p>The transformations must be performed in reverse order.</p>

  <p class="note">For instance, if a scale transformation that doubles the width is applied to the
  canvas, followed by a rotation transformation that rotates drawing operations by a quarter turn,
  and a rectangle twice as wide as it is tall is then drawn on the canvas, the actual result will be
  a square.</p> 

  

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-scale" id="dom-context-2d-scale-dev">scale</a>(<var>x</var>, <var>y</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/scale" title="The CanvasRenderingContext2D.scale() method of the Canvas 2D API adds a scaling transformation to the canvas units horizontally and/or vertically.">CanvasRenderingContext2D/scale</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Changes the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-2">current transformation matrix</a> to apply a scaling transformation with
    the given characteristics.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-rotate" id="dom-context-2d-rotate-dev">rotate</a>(<var>angle</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/rotate" title="The CanvasRenderingContext2D.rotate() method of the Canvas 2D API adds a rotation to the transformation matrix.">CanvasRenderingContext2D/rotate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Changes the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-3">current transformation matrix</a> to apply a rotation transformation
    with the given characteristics. The angle is in radians.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-translate" id="dom-context-2d-translate-dev">translate</a>(<var>x</var>, <var>y</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/translate" title="The CanvasRenderingContext2D.translate() method of the Canvas 2D API adds a translation transformation to the current matrix.">CanvasRenderingContext2D/translate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Changes the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-4">current transformation matrix</a> to apply a translation transformation
    with the given characteristics.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-transform" id="dom-context-2d-transform-dev">transform</a>(<var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var>, <var>f</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform" title="The CanvasRenderingContext2D.transform() method of the Canvas 2D API multiplies the current transformation with the matrix described by the arguments of this method. This lets you scale, rotate, translate (move), and skew the context.">CanvasRenderingContext2D/transform</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Changes the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-5">current transformation matrix</a> to apply the matrix given by the
    arguments as described below.</p>
   </dd><dt><code><var>matrix</var> = <var>context</var>.<a href="#dom-context-2d-gettransform" id="dom-context-2d-gettransform-dev">getTransform</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getTransform" title="The CanvasRenderingContext2D.getTransform() method of the Canvas 2D API retrieves the current transformation matrix being applied to the context.">CanvasRenderingContext2D/getTransform</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>70+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>68+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns a copy of the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-6">current transformation matrix</a>, as a newly created
    <code id="transformations:dommatrix"><a data-x-internal="dommatrix" href="https://drafts.fxtf.org/geometry/#dommatrix">DOMMatrix</a></code> object.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-settransform" id="dom-context-2d-settransform-dev">setTransform</a>(<var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var>, <var>f</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform" title="The CanvasRenderingContext2D.setTransform() method of the Canvas 2D API resets (overrides) the current transformation to the identity matrix, and then invokes a transformation described by the arguments of this method. This lets you scale, rotate, translate (move), and skew the context.">CanvasRenderingContext2D/setTransform</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Changes the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-7">current transformation matrix</a> <em>to</em> the matrix given by the
    arguments as described below.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-settransform-matrix" id="dom-context-2d-settransform-matrix-dev">setTransform</a>(<var>transform</var>)</code></dt><dd>
    <p>Changes the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-8">current transformation matrix</a> <em>to</em> the matrix represented by
    the passed <code id="transformations:dommatrix2dinit"><a data-x-internal="dommatrix2dinit" href="https://drafts.fxtf.org/geometry/#dictdef-dommatrix2dinit">DOMMatrix2DInit</a></code> dictionary.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-resettransform" id="dom-context-2d-resettransform-dev">resetTransform</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/resetTransform" title="The CanvasRenderingContext2D.resetTransform() method of the Canvas 2D API resets the current transform to the identity matrix.">CanvasRenderingContext2D/resetTransform</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>36+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>31+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Changes the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-9">current transformation matrix</a> to the identity matrix.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTransform" id="dom-context-2d-scale" data-dfn-type="method"><code>scale(<var>x</var>,
  <var>y</var>)</code></dfn> method, when invoked, must run these steps:</p>

  <ol><li><p>If either of the arguments are infinite or NaN, then return.</p></li><li><p>Add the scaling transformation described by the arguments to the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-10">current
   transformation matrix</a>. The <var>x</var> argument represents the scale factor in the
   horizontal direction and the <var>y</var> argument represents the scale factor in the vertical
   direction. The factors are multiples.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTransform" id="dom-context-2d-rotate" data-dfn-type="method"><code>rotate(<var>angle</var>)</code></dfn> method, when invoked, must
  run these steps:</p>

  <ol><li><p>If <var>angle</var> is infinite or NaN, then return.</p></li><li><p>Add the rotation transformation described by the argument to the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-11">current
   transformation matrix</a>. The <var>angle</var> argument represents a clockwise rotation angle
   expressed in radians.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTransform" id="dom-context-2d-translate" data-dfn-type="method"><code>translate(<var>x</var>, <var>y</var>)</code></dfn> method, when
  invoked, must run these steps:</p>

  <ol><li><p>If either of the arguments are infinite or NaN, then return.</p></li><li><p>Add the translation transformation described by the arguments to the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-12">current
   transformation matrix</a>. The <var>x</var> argument represents the translation distance in
   the horizontal direction and the <var>y</var> argument represents the translation distance in the
   vertical direction. The arguments are in coordinate space units.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTransform" id="dom-context-2d-transform" data-dfn-type="method"><code>transform(<var>a</var>, <var>b</var>, <var>c</var>,
  <var>d</var>, <var>e</var>, <var>f</var>)</code></dfn> method, when invoked, must run these
  steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li>
    <p>Replace the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-13">current transformation matrix</a> with the result of <a href="https://drafts.fxtf.org/geometry/#matrix-multiply" id="transformations:matrix-multiplication" data-x-internal="matrix-multiplication">multiplying</a> the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-14">current transformation matrix</a>
    with the matrix described by:</p>

    <table class="matrix"><tbody><tr><td><var>a</var></td><td><var>c</var></td><td><var>e</var></td></tr><tr><td><var>b</var></td><td><var>d</var></td><td><var>f</var></td></tr><tr><td>0</td><td>0</td><td>1</td></tr></tbody></table>
   </li></ol>
  </div>

  

  <p data-var-scope="" class="note">The arguments <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>,
  <var>e</var>, and <var>f</var> are sometimes called <var>m11</var>, <var>m12</var>,
  <var>m21</var>, <var>m22</var>, <var>dx</var>, and <var>dy</var> or <var>m11</var>,
  <var>m21</var>, <var>m12</var>, <var>m22</var>, <var>dx</var>, and <var>dy</var>. Care ought to be
  taken in particular with the order of the second and third arguments (<var>b</var> and
  <var>c</var>) as their order varies from API to API and APIs sometimes use the notation
  <var>m12</var>/<var>m21</var> and sometimes <var>m21</var>/<var>m12</var> for those positions.</p>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTransform" id="dom-context-2d-gettransform" data-dfn-type="method"><code>getTransform()</code></dfn> method, when invoked, must return
  a newly created <code id="transformations:dommatrix-2"><a data-x-internal="dommatrix" href="https://drafts.fxtf.org/geometry/#dommatrix">DOMMatrix</a></code> representing a copy of the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-15">current transformation
  matrix</a> matrix of the context.</p>
  </div>

  <p class="note">This returned object is not live, so updating it will not affect the
  <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-16">current transformation matrix</a>, and updating the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-17">current transformation
  matrix</a> will not affect an already returned <code id="transformations:dommatrix-3"><a data-x-internal="dommatrix" href="https://drafts.fxtf.org/geometry/#dommatrix">DOMMatrix</a></code>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTransform" id="dom-context-2d-settransform" data-dfn-type="method"><code>setTransform(<var>a</var>, <var>b</var>, <var>c</var>,
  <var>d</var>, <var>e</var>, <var>f</var>)</code></dfn> method, when invoked, must run these
  steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li>
    <p>Reset the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-18">current transformation matrix</a> to the matrix described by:</p>

    <table class="matrix"><tbody><tr><td><var>a</var></td><td><var>c</var></td><td><var>e</var></td></tr><tr><td><var>b</var></td><td><var>d</var></td><td><var>f</var></td></tr><tr><td>0</td><td>0</td><td>1</td></tr></tbody></table>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTransform" id="dom-context-2d-settransform-matrix" data-dfn-type="method"><code>setTransform(<var>transform</var>)</code></dfn>
  method, when invoked, must run these steps:</p>

  <ol><li><p>Let <var>matrix</var> be the result of <a href="https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-2d-dictionary" id="transformations:create-a-dommatrix-from-a-2d-dictionary" data-x-internal="create-a-dommatrix-from-a-2d-dictionary">creating a <code>DOMMatrix</code> from the 2D dictionary</a>
   <var>transform</var>.</p>

   </li><li><p>If one or more of <var>matrix</var>'s <a id="transformations:m11-element" href="https://drafts.fxtf.org/geometry/#matrix-m11-element" data-x-internal="m11-element">m11 element</a>, <a id="transformations:m12-element" href="https://drafts.fxtf.org/geometry/#matrix-m12-element" data-x-internal="m12-element">m12 element</a>,
   <a id="transformations:m21-element" href="https://drafts.fxtf.org/geometry/#matrix-m21-element" data-x-internal="m21-element">m21 element</a>, <a id="transformations:m22-element" href="https://drafts.fxtf.org/geometry/#matrix-m22-element" data-x-internal="m22-element">m22 element</a>, <a id="transformations:m41-element" href="https://drafts.fxtf.org/geometry/#matrix-m41-element" data-x-internal="m41-element">m41 element</a>, or <a id="transformations:m42-element" href="https://drafts.fxtf.org/geometry/#matrix-m42-element" data-x-internal="m42-element">m42
   element</a> are infinite or NaN, then return.</p></li><li><p>Reset the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-19">current transformation matrix</a> to <var>matrix</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasTransform" id="dom-context-2d-resettransform" data-dfn-type="method"><code>resetTransform()</code></dfn> method, when invoked, must
  reset the <a href="#current-transformation-matrix" id="transformations:current-transformation-matrix-20">current transformation matrix</a> to the identity matrix.</p>
  </div>

  

  <div data-var-scope="" class="note">
   <p>Given a matrix of the form created by the <code id="transformations:dom-context-2d-transform"><a href="#dom-context-2d-transform">transform()</a></code> and <code id="transformations:dom-context-2d-settransform"><a href="#dom-context-2d-settransform">setTransform()</a></code> methods, i.e.,</p>

   <table class="matrix"><tbody><tr><td><var>a</var></td><td><var>c</var></td><td><var>e</var></td></tr><tr><td><var>b</var></td><td><var>d</var></td><td><var>f</var></td></tr><tr><td>0</td><td>0</td><td>1</td></tr></tbody></table>

   <p>the resulting transformed coordinates after transform matrix multiplication will be</p>

   <p class="equations">
    <var>x</var><sub>new</sub> = <var>a</var> <var>x</var> + <var>c</var> <var>y</var> + <var>e</var><br>
    <var>y</var><sub>new</sub> = <var>b</var> <var>x</var> + <var>d</var> <var>y</var> + <var>f</var>
   </p>
  </div>



  <h6 id="image-sources-for-2d-rendering-contexts"><span class="secno">4.12.5.1.9</span> Image sources for 2D rendering contexts<a href="#image-sources-for-2d-rendering-contexts" class="self-link"></a></h6>

  <p>Some methods on the <code id="image-sources-for-2d-rendering-contexts:canvasdrawimage"><a href="#canvasdrawimage">CanvasDrawImage</a></code> and <code id="image-sources-for-2d-rendering-contexts:canvasfillstrokestyles"><a href="#canvasfillstrokestyles">CanvasFillStrokeStyles</a></code>
  interfaces take the union type <code id="image-sources-for-2d-rendering-contexts:canvasimagesource"><a href="#canvasimagesource">CanvasImageSource</a></code> as an argument.</p>

  <p>This union type allows objects implementing any of the following interfaces to be used as image
  sources:</p>

  <ul><li><code id="image-sources-for-2d-rendering-contexts:htmlorsvgimageelement"><a href="#htmlorsvgimageelement">HTMLOrSVGImageElement</a></code> (<code id="image-sources-for-2d-rendering-contexts:the-img-element"><a href="#the-img-element">img</a></code> or <a id="image-sources-for-2d-rendering-contexts:svg-image" href="https://svgwg.org/svg2-draft/embedded.html#ImageElement" data-x-internal="svg-image">SVG <code>image</code></a>
   elements)</li><li><code id="image-sources-for-2d-rendering-contexts:htmlvideoelement"><a href="#htmlvideoelement">HTMLVideoElement</a></code> (<code id="image-sources-for-2d-rendering-contexts:the-video-element"><a href="#the-video-element">video</a></code> elements)</li><li><code id="image-sources-for-2d-rendering-contexts:htmlcanvaselement"><a href="#htmlcanvaselement">HTMLCanvasElement</a></code> (<code id="image-sources-for-2d-rendering-contexts:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> elements)</li><li><code id="image-sources-for-2d-rendering-contexts:offscreencanvas"><a href="#offscreencanvas">OffscreenCanvas</a></code></li><li><code id="image-sources-for-2d-rendering-contexts:imagebitmap"><a href="#imagebitmap">ImageBitmap</a></code></li><li><code id="image-sources-for-2d-rendering-contexts:videoframe"><a data-x-internal="videoframe" href="https://w3c.github.io/webcodecs/#videoframe-interface">VideoFrame</a></code></li></ul>

  <p class="note">Although not formally specified as such, <a id="image-sources-for-2d-rendering-contexts:svg-image-2" href="https://svgwg.org/svg2-draft/embedded.html#ImageElement" data-x-internal="svg-image">SVG <code>image</code></a>
  elements are expected to be implemented nearly identical to <code id="image-sources-for-2d-rendering-contexts:the-img-element-2"><a href="#the-img-element">img</a></code> elements. That is,
  <a id="image-sources-for-2d-rendering-contexts:svg-image-3" href="https://svgwg.org/svg2-draft/embedded.html#ImageElement" data-x-internal="svg-image">SVG <code>image</code></a> elements share the fundamental concepts and features of
  <code id="image-sources-for-2d-rendering-contexts:the-img-element-3"><a href="#the-img-element">img</a></code> elements.</p>

  <p class="note">The <code id="image-sources-for-2d-rendering-contexts:imagebitmap-2"><a href="#imagebitmap">ImageBitmap</a></code> interface can be created from a number of other
  image-representing types, including <code id="image-sources-for-2d-rendering-contexts:imagedata"><a href="#imagedata">ImageData</a></code>.</p>

  <div data-algorithm="">
  <p>To <dfn id="check-the-usability-of-the-image-argument">check the usability of the <var>image</var> argument</dfn>, where <var>image</var>
  is a <code id="image-sources-for-2d-rendering-contexts:canvasimagesource-2"><a href="#canvasimagesource">CanvasImageSource</a></code> object, run these steps:</p>

  <ol><li>
    <p>Switch on <var>image</var>:</p>

    <dl class="switch"><dt><code id="image-sources-for-2d-rendering-contexts:htmlorsvgimageelement-2"><a href="#htmlorsvgimageelement">HTMLOrSVGImageElement</a></code></dt><dd>
      <p>If <var>image</var>'s <a href="#current-request" id="image-sources-for-2d-rendering-contexts:current-request">current request</a>'s <a href="#img-req-state" id="image-sources-for-2d-rendering-contexts:img-req-state">state</a> is <a href="#img-error" id="image-sources-for-2d-rendering-contexts:img-error">broken</a>, then
      throw an <a id="image-sources-for-2d-rendering-contexts:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="image-sources-for-2d-rendering-contexts:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

      <p>If <var>image</var> is not <a href="#img-good" id="image-sources-for-2d-rendering-contexts:img-good">fully decodable</a>,
      then return <i>bad</i>.</p>

      <p>If <var>image</var> has a <a id="image-sources-for-2d-rendering-contexts:natural-width" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> or <a id="image-sources-for-2d-rendering-contexts:natural-height" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a>
      (or both) equal to zero, then return <i>bad</i>.</p> 
     </dd><dt><code id="image-sources-for-2d-rendering-contexts:htmlvideoelement-2"><a href="#htmlvideoelement">HTMLVideoElement</a></code></dt><dd><p>If <var>image</var>'s <code id="image-sources-for-2d-rendering-contexts:dom-media-readystate"><a href="#dom-media-readystate">readyState</a></code>
     attribute is either <code id="image-sources-for-2d-rendering-contexts:dom-media-have_nothing"><a href="#dom-media-have_nothing">HAVE_NOTHING</a></code> or <code id="image-sources-for-2d-rendering-contexts:dom-media-have_metadata"><a href="#dom-media-have_metadata">HAVE_METADATA</a></code>, then return <i>bad</i>.</p></dd><dt><code id="image-sources-for-2d-rendering-contexts:htmlcanvaselement-2"><a href="#htmlcanvaselement">HTMLCanvasElement</a></code></dt><dt><code id="image-sources-for-2d-rendering-contexts:offscreencanvas-2"><a href="#offscreencanvas">OffscreenCanvas</a></code></dt><dd><p>If <var>image</var> has either a horizontal dimension or a vertical dimension
     equal to zero, then throw an <a id="image-sources-for-2d-rendering-contexts:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
     <code id="image-sources-for-2d-rendering-contexts:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></dd><dt><code id="image-sources-for-2d-rendering-contexts:imagebitmap-3"><a href="#imagebitmap">ImageBitmap</a></code></dt><dt><code id="image-sources-for-2d-rendering-contexts:videoframe-2"><a data-x-internal="videoframe" href="https://w3c.github.io/webcodecs/#videoframe-interface">VideoFrame</a></code></dt><dd><p>If <var>image</var>'s <a href="#detached" id="image-sources-for-2d-rendering-contexts:detached">[[Detached]]</a> internal slot value
     is set to true, then throw an <a id="image-sources-for-2d-rendering-contexts:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
     <code id="image-sources-for-2d-rendering-contexts:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></dd></dl>
   </li><li>
    <p>Return <i>good</i>.</p>
   </li></ol>
  </div>

  <p>When a <code id="image-sources-for-2d-rendering-contexts:canvasimagesource-3"><a href="#canvasimagesource">CanvasImageSource</a></code> object represents an <code id="image-sources-for-2d-rendering-contexts:htmlorsvgimageelement-3"><a href="#htmlorsvgimageelement">HTMLOrSVGImageElement</a></code>,
  the element's image must be used as the source image.</p>

  <p>Specifically, when a <code id="image-sources-for-2d-rendering-contexts:canvasimagesource-4"><a href="#canvasimagesource">CanvasImageSource</a></code> object represents an animated image in an
  <code id="image-sources-for-2d-rendering-contexts:htmlorsvgimageelement-4"><a href="#htmlorsvgimageelement">HTMLOrSVGImageElement</a></code>, the user agent must use the default image of the animation
  (the one that the format defines is to be used when animation is not supported or is disabled),
  or, if there is no such image, the first frame of the animation, when rendering the image for
  <code id="image-sources-for-2d-rendering-contexts:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> APIs.</p>

  <p>When a <code id="image-sources-for-2d-rendering-contexts:canvasimagesource-5"><a href="#canvasimagesource">CanvasImageSource</a></code> object represents an <code id="image-sources-for-2d-rendering-contexts:htmlvideoelement-3"><a href="#htmlvideoelement">HTMLVideoElement</a></code>, then
  the frame at the <a href="#current-playback-position" id="image-sources-for-2d-rendering-contexts:current-playback-position">current playback position</a> when the method with the argument is
  invoked must be used as the source image when rendering the image for
  <code id="image-sources-for-2d-rendering-contexts:canvasrenderingcontext2d-2"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> APIs, and the source image's dimensions must be the <a href="#concept-video-intrinsic-width" id="image-sources-for-2d-rendering-contexts:concept-video-intrinsic-width">natural width</a> and <a href="#concept-video-intrinsic-height" id="image-sources-for-2d-rendering-contexts:concept-video-intrinsic-height">natural height</a> of the <a href="#media-resource" id="image-sources-for-2d-rendering-contexts:media-resource">media resource</a>
  (i.e., after any aspect-ratio correction has been applied).</p>

  <p>When a <code id="image-sources-for-2d-rendering-contexts:canvasimagesource-6"><a href="#canvasimagesource">CanvasImageSource</a></code> object represents an <code id="image-sources-for-2d-rendering-contexts:htmlcanvaselement-3"><a href="#htmlcanvaselement">HTMLCanvasElement</a></code>, the
  element's bitmap must be used as the source image.</p>

  <p>When a <code id="image-sources-for-2d-rendering-contexts:canvasimagesource-7"><a href="#canvasimagesource">CanvasImageSource</a></code> object represents an element that is <a href="#being-rendered" id="image-sources-for-2d-rendering-contexts:being-rendered">being
  rendered</a> and that element has been resized, the original image data of the source image
  must be used, not the image as it is rendered (e.g. <code id="image-sources-for-2d-rendering-contexts:attr-dim-width"><a href="#attr-dim-width">width</a></code> and
  <code id="image-sources-for-2d-rendering-contexts:attr-dim-height"><a href="#attr-dim-height">height</a></code> attributes on the source element have no effect on how
  the object is interpreted when rendering the image for <code id="image-sources-for-2d-rendering-contexts:canvasrenderingcontext2d-3"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code>
  APIs).</p>

  <p>When a <code id="image-sources-for-2d-rendering-contexts:canvasimagesource-8"><a href="#canvasimagesource">CanvasImageSource</a></code> object represents an <code id="image-sources-for-2d-rendering-contexts:imagebitmap-4"><a href="#imagebitmap">ImageBitmap</a></code>, the
  object's bitmap image data must be used as the source image.</p>

  <p>When a <code id="image-sources-for-2d-rendering-contexts:canvasimagesource-9"><a href="#canvasimagesource">CanvasImageSource</a></code> object represents an <code id="image-sources-for-2d-rendering-contexts:offscreencanvas-3"><a href="#offscreencanvas">OffscreenCanvas</a></code>, the
  object's bitmap must be used as the source image.</p>

  <p>When a <code id="image-sources-for-2d-rendering-contexts:canvasimagesource-10"><a href="#canvasimagesource">CanvasImageSource</a></code> object represents a <code id="image-sources-for-2d-rendering-contexts:videoframe-3"><a data-x-internal="videoframe" href="https://w3c.github.io/webcodecs/#videoframe-interface">VideoFrame</a></code>, the object's
  pixel data must be used as the source image, and the source image's dimensions must be the
  object's <a id="image-sources-for-2d-rendering-contexts:display-width" href="https://w3c.github.io/webcodecs/#dom-videoframe-display-width-slot" data-x-internal="display-width">[[display width]]</a> and <a id="image-sources-for-2d-rendering-contexts:display-height" href="https://w3c.github.io/webcodecs/#dom-videoframe-display-height-slot" data-x-internal="display-height">[[display height]]</a>.</p>

  <div data-algorithm="">
  <p>An object <var>image</var> <dfn id="the-image-argument-is-not-origin-clean">is not
  origin-clean</dfn> if, switching on <var>image</var>'s type:</p>

  <dl class="switch"><dt><code id="image-sources-for-2d-rendering-contexts:htmlorsvgimageelement-5"><a href="#htmlorsvgimageelement">HTMLOrSVGImageElement</a></code>
   </dt><dd><p><var>image</var>'s <a href="#current-request" id="image-sources-for-2d-rendering-contexts:current-request-2">current request</a>'s <a href="#img-req-data" id="image-sources-for-2d-rendering-contexts:img-req-data">image
   data</a> is <a href="#cors-cross-origin" id="image-sources-for-2d-rendering-contexts:cors-cross-origin">CORS-cross-origin</a>.</p></dd><dt><code id="image-sources-for-2d-rendering-contexts:htmlvideoelement-4"><a href="#htmlvideoelement">HTMLVideoElement</a></code>
   </dt><dd><p><var>image</var>'s <a href="#media-data" id="image-sources-for-2d-rendering-contexts:media-data">media data</a> is <a href="#cors-cross-origin" id="image-sources-for-2d-rendering-contexts:cors-cross-origin-2">CORS-cross-origin</a>.</p></dd><dt><code id="image-sources-for-2d-rendering-contexts:htmlcanvaselement-4"><a href="#htmlcanvaselement">HTMLCanvasElement</a></code>
   </dt><dt><code id="image-sources-for-2d-rendering-contexts:imagebitmap-5"><a href="#imagebitmap">ImageBitmap</a></code>
   </dt><dt><code id="image-sources-for-2d-rendering-contexts:offscreencanvas-4"><a href="#offscreencanvas">OffscreenCanvas</a></code>
   </dt><dd><p><var>image</var>'s bitmap's <a href="#concept-canvas-origin-clean" id="image-sources-for-2d-rendering-contexts:concept-canvas-origin-clean">origin-clean</a>
   flag is false.</p></dd></dl>
  </div>



  <h6 id="fill-and-stroke-styles"><span class="secno">4.12.5.1.10</span> Fill and stroke styles<a href="#fill-and-stroke-styles" class="self-link"></a></h6>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-fillstyle" id="dom-context-2d-fillstyle-dev">fillStyle</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle" title="The CanvasRenderingContext2D.fillStyle property of the Canvas 2D API specifies the color, gradient, or pattern to use inside shapes. The default style is #000 (black).">CanvasRenderingContext2D/fillStyle</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the current style used for filling shapes.</p>

    <p>Can be set, to change the <a href="#concept-canvasfillstrokestyles-fill-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-fill-style">fill
    style</a>.</p>

    <p>The style can be either a string containing a CSS color, or a <code id="fill-and-stroke-styles:canvasgradient"><a href="#canvasgradient">CanvasGradient</a></code> or
    <code id="fill-and-stroke-styles:canvaspattern"><a href="#canvaspattern">CanvasPattern</a></code> object. Invalid values are ignored.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-strokestyle" id="dom-context-2d-strokestyle-dev">strokeStyle</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle" title="The CanvasRenderingContext2D.strokeStyle property of the Canvas 2D API specifies the color, gradient, or pattern to use for the strokes (outlines) around shapes. The default is #000 (black).">CanvasRenderingContext2D/strokeStyle</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the current style used for stroking shapes.</p>

    <p>Can be set, to change the <a href="#concept-canvasfillstrokestyles-stroke-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-stroke-style">stroke
    style.</a></p>

    <p>The style can be either a string containing a CSS color, or a <code id="fill-and-stroke-styles:canvasgradient-2"><a href="#canvasgradient">CanvasGradient</a></code> or
    <code id="fill-and-stroke-styles:canvaspattern-2"><a href="#canvaspattern">CanvasPattern</a></code> object. Invalid values are ignored.</p>
   </dd></dl>

  

  

  <p>Objects that implement the <code id="fill-and-stroke-styles:canvasfillstrokestyles"><a href="#canvasfillstrokestyles">CanvasFillStrokeStyles</a></code> interface have attributes and
  methods (defined in this section) that control how shapes are treated by the object.</p>

  <p>Such objects have associated <dfn id="concept-canvasfillstrokestyles-fill-style">fill
  style</dfn> and <dfn id="concept-canvasfillstrokestyles-stroke-style">stroke style</dfn>
  values, which are either CSS colors, <code id="fill-and-stroke-styles:canvaspattern-3"><a href="#canvaspattern">CanvasPattern</a></code>s, or <code id="fill-and-stroke-styles:canvasgradient-3"><a href="#canvasgradient">CanvasGradient</a></code>s.
  Initially, both must be the result of <a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value" id="fill-and-stroke-styles:parsed-as-a-css-color-value" data-x-internal="parsed-as-a-css-color-value">parsing</a>
  the string "<code>#000000</code>".</p>

  <p>When the value is a CSS color, it must not be affected by the transformation matrix when used
  to draw on bitmaps.</p> 

  <p class="note">When set to a <code id="fill-and-stroke-styles:canvaspattern-4"><a href="#canvaspattern">CanvasPattern</a></code> or <code id="fill-and-stroke-styles:canvasgradient-4"><a href="#canvasgradient">CanvasGradient</a></code> object,
  changes made to the object after the assignment do affect subsequent stroking or filling of
  shapes.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasFillStrokeStyles" id="dom-context-2d-fillstyle" data-dfn-type="attribute"><code>fillStyle</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="fill-and-stroke-styles:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-fill-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-fill-style-2">fill
   style</a> is a CSS color, then return the <a href="https://drafts.csswg.org/css-color/#serializing-color-values" id="fill-and-stroke-styles:serialisation-of-a-color" data-x-internal="serialisation-of-a-color">serialization</a> of that color with <a href="https://drafts.csswg.org/css-color/#color-serialization-html-compatible-serialization-is-requested" id="fill-and-stroke-styles:html-compatible-serialization-is-requested" data-x-internal="html-compatible-serialization-is-requested">HTML-compatible serialization requested</a>.</p></li><li><p>Return <a id="fill-and-stroke-styles:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-fill-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-fill-style-3">fill
   style</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="fill-and-stroke-styles:dom-context-2d-fillstyle"><a href="#dom-context-2d-fillstyle">fillStyle</a></code> setter steps are:</p>

  <ol><li>
    <p>If the given value is a string, then:</p>

    <ol><li><p>Let <var>context</var> be <a id="fill-and-stroke-styles:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="fill-and-stroke-styles:dom-context-2d-canvas"><a href="#dom-context-2d-canvas">canvas</a></code> attribute's value, if that is an element;
     otherwise null.</p></li><li><p>Let <var>parsedValue</var> be the result of <a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value" id="fill-and-stroke-styles:parsed-as-a-css-color-value-2" data-x-internal="parsed-as-a-css-color-value">parsing</a> the given value with <var>context</var> if non-null.</p></li><li><p>If <var>parsedValue</var> is failure, then return.</p></li><li><p>Set <a id="fill-and-stroke-styles:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-fill-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-fill-style-4">fill
     style</a> to <var>parsedValue</var>.</p></li><li><p>Return.</p></li></ol>
   </li><li><p>If the given value is a <code id="fill-and-stroke-styles:canvaspattern-5"><a href="#canvaspattern">CanvasPattern</a></code> object that is marked as <a href="#concept-canvas-pattern-not-origin-clean" id="fill-and-stroke-styles:concept-canvas-pattern-not-origin-clean">not origin-clean</a>, then set
   <a id="fill-and-stroke-styles:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-origin-clean" id="fill-and-stroke-styles:concept-canvas-origin-clean">origin-clean</a> flag to
   false.</p></li><li><p>Set <a id="fill-and-stroke-styles:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-fill-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-fill-style-5">fill
   style</a> to the given value.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasFillStrokeStyles" id="dom-context-2d-strokestyle" data-dfn-type="attribute"><code>strokeStyle</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="fill-and-stroke-styles:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-stroke-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-stroke-style-2">stroke
   style</a> is a CSS color, then return the <a href="https://drafts.csswg.org/css-color/#serializing-color-values" id="fill-and-stroke-styles:serialisation-of-a-color-2" data-x-internal="serialisation-of-a-color">serialization</a> of that color with <a href="https://drafts.csswg.org/css-color/#color-serialization-html-compatible-serialization-is-requested" id="fill-and-stroke-styles:html-compatible-serialization-is-requested-2" data-x-internal="html-compatible-serialization-is-requested">HTML-compatible serialization requested</a>.</p></li><li><p>Return <a id="fill-and-stroke-styles:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-stroke-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-stroke-style-3">stroke
   style</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="fill-and-stroke-styles:dom-context-2d-strokestyle"><a href="#dom-context-2d-strokestyle">strokeStyle</a></code> setter steps are:</p>

  <ol><li>
    <p>If the given value is a string, then:</p>

    <ol><li><p>Let <var>context</var> be <a id="fill-and-stroke-styles:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="fill-and-stroke-styles:dom-context-2d-canvas-2"><a href="#dom-context-2d-canvas">canvas</a></code> attribute's value, if that is an element;
     otherwise null.</p></li><li><p>Let <var>parsedValue</var> be the result of <a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value" id="fill-and-stroke-styles:parsed-as-a-css-color-value-3" data-x-internal="parsed-as-a-css-color-value">parsing</a> the given value with <var>context</var> if non-null.</p></li><li><p>If <var>parsedValue</var> is failure, then return.</p></li><li><p>Set <a id="fill-and-stroke-styles:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-stroke-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-stroke-style-4">stroke style</a> to
     <var>parsedValue</var>.</p></li><li><p>Return.</p></li></ol>
   </li><li><p>If the given value is a <code id="fill-and-stroke-styles:canvaspattern-6"><a href="#canvaspattern">CanvasPattern</a></code> object that is marked as <a href="#concept-canvas-pattern-not-origin-clean" id="fill-and-stroke-styles:concept-canvas-pattern-not-origin-clean-2">not origin-clean</a>, then set
   <a id="fill-and-stroke-styles:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-origin-clean" id="fill-and-stroke-styles:concept-canvas-origin-clean-2">origin-clean</a> flag to
   false.</p></li><li><p>Set <a id="fill-and-stroke-styles:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-stroke-style" id="fill-and-stroke-styles:concept-canvasfillstrokestyles-stroke-style-5">stroke
   style</a> to the given value.</p></li></ol>
  </div>

  

  <hr>

  <p>There are three types of gradients, linear gradients, radial gradients, and conic gradients,
  represented by objects implementing the opaque <code id="fill-and-stroke-styles:canvasgradient-5"><a href="#canvasgradient">CanvasGradient</a></code> interface.</p>

  <p id="interpolation">Once a gradient has been created (see below), stops are placed along it to
  define how the colors are distributed along the gradient. The color of the
  gradient at each stop is the color specified for that stop, <a href="https://drafts.csswg.org/css-color/#color-conversion" id="fill-and-stroke-styles:converting-colors" data-x-internal="converting-colors">converted</a> to the <a href="#concept-canvas-color-space" id="fill-and-stroke-styles:concept-canvas-color-space">context's color space</a>. Between each such stop, the
  colors and the alpha component must be linearly interpolated in the <a href="#concept-canvas-color-space" id="fill-and-stroke-styles:concept-canvas-color-space-2">context's color space</a> without premultiplying the
  alpha value to find the color to use at that offset. Before the first stop, the color must be the
  color of the first stop. After the last stop, the color must be the color of the last stop. When
  there are no stops, the gradient is <a id="fill-and-stroke-styles:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>.</p>

  <dl class="domintro"><dt><code><var>gradient</var>.<a href="#dom-canvasgradient-addcolorstop" id="dom-canvasgradient-addcolorstop-dev">addColorStop</a>(<var>offset</var>, <var>color</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient/addColorStop" title="The CanvasGradient.addColorStop() method adds a new color stop, defined by an offset and a color, to a given canvas gradient.">CanvasGradient/addColorStop</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset
    at one end of the gradient, 1.0 is the offset at the other end.</p>

    <p>Throws an <a id="fill-and-stroke-styles:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="fill-and-stroke-styles:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the offset
    is out of range. Throws a <a id="fill-and-stroke-styles:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="fill-and-stroke-styles:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    the color cannot be parsed.</p>
   </dd><dt><code><var>gradient</var> = <var>context</var>.<a href="#dom-context-2d-createlineargradient" id="dom-context-2d-createlineargradient-dev">createLinearGradient</a>(<var>x0</var>, <var>y0</var>, <var>x1</var>, <var>y1</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient" title="The CanvasRenderingContext2D.createLinearGradient() method of the Canvas 2D API creates a gradient along the line connecting two given coordinates.">CanvasRenderingContext2D/createLinearGradient</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="fill-and-stroke-styles:canvasgradient-6"><a href="#canvasgradient">CanvasGradient</a></code> object that represents a linear gradient that paints
    along the line given by the coordinates represented by the arguments.</p>
   </dd><dt><code><var>gradient</var> = <var>context</var>.<a href="#dom-context-2d-createradialgradient" id="dom-context-2d-createradialgradient-dev">createRadialGradient</a>(<var>x0</var>, <var>y0</var>, <var>r0</var>, <var>x1</var>, <var>y1</var>, <var>r1</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient" title="The CanvasRenderingContext2D.createRadialGradient() method of the Canvas 2D API creates a radial gradient using the size and coordinates of two circles.">CanvasRenderingContext2D/createRadialGradient</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="fill-and-stroke-styles:canvasgradient-7"><a href="#canvasgradient">CanvasGradient</a></code> object that represents a radial gradient that paints
    along the cone given by the circles represented by the arguments.</p>

    <p>If either of the radii are negative, throws an <a id="fill-and-stroke-styles:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a>
    <code id="fill-and-stroke-styles:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd><dt><code><var>gradient</var> = <var>context</var>.<a href="#dom-context-2d-createconicgradient" id="dom-context-2d-createconicgradient-dev">createConicGradient</a>(<var>startAngle</var>, <var>x</var>, <var>y</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createConicGradient" title="The CanvasRenderingContext2D.createConicGradient() method of the Canvas 2D API creates a gradient around a point with given coordinates.">CanvasRenderingContext2D/createConicGradient</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>112+</span></span><span class="safari yes"><span>Safari</span><span>16.1+</span></span><span class="chrome yes"><span>Chrome</span><span>99+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>99+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns a <code id="fill-and-stroke-styles:canvasgradient-8"><a href="#canvasgradient">CanvasGradient</a></code> object that represents a conic gradient that paints
   clockwise along the rotation around the center represented by the arguments.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasGradient" id="dom-canvasgradient-addcolorstop" data-dfn-type="method"><code>addColorStop(<var>offset</var>,
  <var>color</var>)</code></dfn> method on the <code id="fill-and-stroke-styles:canvasgradient-9"><a href="#canvasgradient">CanvasGradient</a></code>, when invoked, must run
  these steps:</p>

  <ol><li><p>If the <var>offset</var> is less than 0 or greater than 1, then throw an
   <a id="fill-and-stroke-styles:indexsizeerror-3" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="fill-and-stroke-styles:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p>Let <var>parsed color</var> be the result of <a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value" id="fill-and-stroke-styles:parsed-as-a-css-color-value-4" data-x-internal="parsed-as-a-css-color-value">parsing</a> <var>color</var>.</p>

    <p class="note">No element is passed to the parser because <code id="fill-and-stroke-styles:canvasgradient-10"><a href="#canvasgradient">CanvasGradient</a></code> objects
    are <code id="fill-and-stroke-styles:the-canvas-element"><a href="#the-canvas-element">canvas</a></code>-neutral — a <code id="fill-and-stroke-styles:canvasgradient-11"><a href="#canvasgradient">CanvasGradient</a></code> object created by one
    <code id="fill-and-stroke-styles:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> can be used by another, and there is therefore no way to know which is the
    "element in question" at the time that the color is specified.</p>
   </li><li><p>If <var>parsed color</var> is failure, throw a <a id="fill-and-stroke-styles:syntaxerror-2" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="fill-and-stroke-styles:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p>Place a new stop on the gradient, at offset <var>offset</var> relative to the whole gradient,
    and with the color <var>parsed color</var>.</p>

    <p>If multiple stops are added at the same offset on a gradient, then they must be placed in the
    order added, with the first one closest to the start of the gradient, and each subsequent one
    infinitesimally further along towards the end point (in effect causing all but the first and
    last stop added at each point to be ignored).</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasFillStrokeStyles" id="dom-context-2d-createlineargradient" data-dfn-type="method"><code>createLinearGradient(<var>x0</var>, <var>y0</var>,
  <var>x1</var>, <var>y1</var>)</code></dfn> method takes four arguments that represent the start
  point (<var>x0</var>, <var>y0</var>) and end point (<var>x1</var>, <var>y1</var>) of the gradient.
  The method, when invoked, must return a linear <code id="fill-and-stroke-styles:canvasgradient-12"><a href="#canvasgradient">CanvasGradient</a></code> initialized with the
  specified line.</p>

  <p>Linear gradients must be rendered such that all points on a line perpendicular to the line that
  crosses the start and end points have the color at the point where those two lines cross (with the
  colors coming from the <a href="#interpolation">interpolation and extrapolation</a> described
  above). The points in the linear gradient must be transformed as described by the <a href="#transformations" id="fill-and-stroke-styles:transformations">current transformation matrix</a> when rendering.</p>

  <p>If <var>x0</var>&nbsp;=&nbsp;<var>x1</var> and
  <var>y0</var>&nbsp;=&nbsp;<var>y1</var>, then the linear
  gradient must paint nothing.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasFillStrokeStyles" id="dom-context-2d-createradialgradient" data-dfn-type="method"><code>createRadialGradient(<var>x0</var>, <var>y0</var>,
  <var>r0</var>, <var>x1</var>, <var>y1</var>, <var>r1</var>)</code></dfn> method takes six
  arguments, the first three representing the start circle with origin (<var>x0</var>,
  <var>y0</var>) and radius <var>r0</var>, and the last three representing the end circle with
  origin (<var>x1</var>, <var>y1</var>) and radius <var>r1</var>. The values are in coordinate space
  units. If either of <var>r0</var> or <var>r1</var> are negative, then an
  <a id="fill-and-stroke-styles:indexsizeerror-4" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="fill-and-stroke-styles:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> must be thrown. Otherwise,
  the method, when invoked, must return a radial <code id="fill-and-stroke-styles:canvasgradient-13"><a href="#canvasgradient">CanvasGradient</a></code> initialized with the
  two specified circles.</p>
  </div>

  <div data-algorithm="">
  <p>Radial gradients must be rendered by following these steps:</p>

  <ol><li><p>If <var>x<sub>0</sub></var>&nbsp;=&nbsp;<var>x<sub>1</sub></var> and <var>y<sub>0</sub></var>&nbsp;=&nbsp;<var>y<sub>1</sub></var> and <var>r<sub>0</sub></var>&nbsp;=&nbsp;<var>r<sub>1</sub></var>, then the radial gradient must
   paint nothing. Return.</p></li><li>
    <p>Let x(<var>ω</var>)&nbsp;=&nbsp;(<var>x<sub>1</sub></var>-<var>x<sub>0</sub></var>)<var>ω</var>&nbsp;+&nbsp;<var>x<sub>0</sub></var>.</p>

    <p>Let y(<var>ω</var>)&nbsp;=&nbsp;(<var>y<sub>1</sub></var>-<var>y<sub>0</sub></var>)<var>ω</var>&nbsp;+&nbsp;<var>y<sub>0</sub></var>.</p>

    <p>Let r(<var>ω</var>)&nbsp;=&nbsp;(<var>r<sub>1</sub></var>-<var>r<sub>0</sub></var>)<var>ω</var>&nbsp;+&nbsp;<var>r<sub>0</sub></var>.</p>

    <p>Let the color at <var>ω</var> be the color at that position on the gradient
    (with the colors coming from the <a href="#interpolation">interpolation and extrapolation</a>
    described above).</p>
   </li><li><p>For all values of <var>ω</var> where r(<var>ω</var>)&nbsp;&gt;&nbsp;0, starting with the value of <var>ω</var> nearest to positive infinity and ending with the value of <var>ω</var> nearest to negative infinity, draw the circumference of the circle with
   radius r(<var>ω</var>) at position (x(<var>ω</var>), y(<var>ω</var>)), with the
   color at <var>ω</var>, but only painting on the parts of the bitmap that have not
   yet been painted on by earlier circles in this step for this rendering of the gradient.</p></li></ol>
  </div>

  <p class="note">This effectively creates a cone, touched by the two circles defined in the
  creation of the gradient, with the part of the cone before the start circle (0.0) using the color
  of the first offset, the part of the cone after the end circle (1.0) using the color of the last
  offset, and areas outside the cone untouched by the gradient (<a id="fill-and-stroke-styles:transparent-black-2" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>).</p>

  <p>The resulting radial gradient must then be transformed as described by the <a href="#transformations" id="fill-and-stroke-styles:transformations-2">current transformation matrix</a> when rendering.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasFillStrokeStyles" id="dom-context-2d-createconicgradient" data-dfn-type="method"><code>createConicGradient(<var>startAngle</var>,
  <var>x</var>, <var>y</var>)</code></dfn> method takes three arguments, the first argument,
  <var>startAngle</var>, represents the angle in radians at which the gradient begins, and the last
  two arguments, (<var>x</var>, <var>y</var>), represent the center of the gradient in <a href="https://drafts.csswg.org/css-values/#px" id="fill-and-stroke-styles:'px'" data-x-internal="'px'">CSS pixels</a>. The method, when invoked, must return a conic
  <code id="fill-and-stroke-styles:canvasgradient-14"><a href="#canvasgradient">CanvasGradient</a></code> initialized with the specified center and angle.</p>

  <p>It follows the same rendering rule as CSS <a id="fill-and-stroke-styles:'conic-gradient'" href="https://drafts.csswg.org/css-images-4/#funcdef-conic-gradient" data-x-internal="'conic-gradient'">'conic-gradient'</a> and it is
  equivalent to CSS 'conic-gradient(from <var>adjustedStartAngle</var>rad at
  <var>x</var>px <var>y</var>px, <var>angularColorStopList</var>)'. Here:</p>

  <ul><li><p><var>adjustedStartAngle</var> is given by <var>startAngle</var> + π/2;</p></li><li><p><var>angularColorStopList</var> is given by the color stops that have been added to the
   <code id="fill-and-stroke-styles:canvasgradient-15"><a href="#canvasgradient">CanvasGradient</a></code> using <code id="fill-and-stroke-styles:dom-canvasgradient-addcolorstop"><a href="#dom-canvasgradient-addcolorstop">addColorStop()</a></code>, with the color stop offsets
   interpreted as percentages.</p></li></ul>
  </div>

  <p>Gradients must be painted only where the relevant stroking or filling effects requires that
  they be drawn.</p>

  

  <hr>

  <p>Patterns are represented by objects implementing the opaque <code id="fill-and-stroke-styles:canvaspattern-7"><a href="#canvaspattern">CanvasPattern</a></code>
  interface.</p>

  <dl class="domintro"><dt><code><var>pattern</var> = <var>context</var>.<a href="#dom-context-2d-createpattern" id="dom-context-2d-createpattern-dev">createPattern</a>(<var>image</var>, <var>repetition</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createPattern" title="The CanvasRenderingContext2D.createPattern() method of the Canvas 2D API creates a pattern using the specified image and repetition. This method returns a CanvasPattern.">CanvasRenderingContext2D/createPattern</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="fill-and-stroke-styles:canvaspattern-8"><a href="#canvaspattern">CanvasPattern</a></code> object that uses the given image and repeats in the
    direction(s) given by the <var>repetition</var> argument.</p>

    <p>The allowed values for <var>repetition</var> are <code>repeat</code> (both
    directions), <code>repeat-x</code> (horizontal only), <code>repeat-y</code>
    (vertical only), and <code>no-repeat</code> (neither). If the <var>repetition</var>
    argument is empty, the value <code>repeat</code> is used.</p>

    <p>If the image isn't yet fully decoded, then nothing is drawn. If the image is a canvas with no
    data, throws an <a id="fill-and-stroke-styles:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="fill-and-stroke-styles:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd><dt><code><var>pattern</var>.<a href="#dom-canvaspattern-settransform" id="dom-canvaspattern-settransform-dev">setTransform</a>(<var>transform</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern/setTransform" title="The CanvasPattern.setTransform() method uses a DOMMatrix object as the pattern's transformation matrix and invokes it on the pattern.">CanvasPattern/setTransform</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>33+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>68+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Sets the transformation matrix that will be used when rendering the pattern during a fill or
    stroke painting operation.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasFillStrokeStyles" id="dom-context-2d-createpattern" data-dfn-type="method"><code>createPattern(<var>image</var>,
  <var>repetition</var>)</code></dfn> method, when invoked, must run these steps:</p>

  <ol><li><p>Let <var>usability</var> be the result of <a href="#check-the-usability-of-the-image-argument" id="fill-and-stroke-styles:check-the-usability-of-the-image-argument">checking the usability of</a> <var>image</var>.</p></li><li><p>If <var>usability</var> is <i>bad</i>, then return null.</p></li><li><p><a id="fill-and-stroke-styles:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>usability</var> is <i>good</i>.</p></li><li><p>If <var>repetition</var> is the empty string, then set it to "<code>repeat</code>".</p>

   </li><li><p>If <var>repetition</var> is not <a id="fill-and-stroke-styles:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> one of "<code>repeat</code>", "<code>repeat-x</code>", "<code>repeat-y</code>",
   or "<code>no-repeat</code>", then throw a
   <a id="fill-and-stroke-styles:syntaxerror-3" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="fill-and-stroke-styles:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>pattern</var> be a new <code id="fill-and-stroke-styles:canvaspattern-9"><a href="#canvaspattern">CanvasPattern</a></code> object with the image
   <var>image</var> and the repetition behavior given by <var>repetition</var>.</p></li><li><p>If <var>image</var> <a href="#the-image-argument-is-not-origin-clean" id="fill-and-stroke-styles:the-image-argument-is-not-origin-clean">is not origin-clean</a>, then mark <var>pattern</var> as <dfn id="concept-canvas-pattern-not-origin-clean">not origin-clean</dfn>.</p></li><li><p>Return <var>pattern</var>.</p></li></ol>

  <p>Modifying the <var>image</var> used when creating a <code id="fill-and-stroke-styles:canvaspattern-10"><a href="#canvaspattern">CanvasPattern</a></code> object
  after calling the <code id="fill-and-stroke-styles:dom-context-2d-createpattern"><a href="#dom-context-2d-createpattern">createPattern()</a></code> method must
  not affect the pattern(s) rendered by the <code id="fill-and-stroke-styles:canvaspattern-11"><a href="#canvaspattern">CanvasPattern</a></code> object.</p>
  </div>

  <p>Patterns have a transformation matrix, which controls how the pattern is used when it is
  painted. Initially, a pattern's transformation matrix must be the identity matrix.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasPattern" id="dom-canvaspattern-settransform" data-dfn-type="method"><code>setTransform(<var>transform</var>)</code></dfn> method,
  when invoked, must run these steps:</p>

  <ol><li><p>Let <var>matrix</var> be the result of <a href="https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-2d-dictionary" id="fill-and-stroke-styles:create-a-dommatrix-from-a-2d-dictionary" data-x-internal="create-a-dommatrix-from-a-2d-dictionary">creating a <code>DOMMatrix</code> from the 2D dictionary</a>
   <var>transform</var>.</p>

   </li><li><p>If one or more of <var>matrix</var>'s <a id="fill-and-stroke-styles:m11-element" href="https://drafts.fxtf.org/geometry/#matrix-m11-element" data-x-internal="m11-element">m11 element</a>, <a id="fill-and-stroke-styles:m12-element" href="https://drafts.fxtf.org/geometry/#matrix-m12-element" data-x-internal="m12-element">m12 element</a>,
   <a id="fill-and-stroke-styles:m21-element" href="https://drafts.fxtf.org/geometry/#matrix-m21-element" data-x-internal="m21-element">m21 element</a>, <a id="fill-and-stroke-styles:m22-element" href="https://drafts.fxtf.org/geometry/#matrix-m22-element" data-x-internal="m22-element">m22 element</a>, <a id="fill-and-stroke-styles:m41-element" href="https://drafts.fxtf.org/geometry/#matrix-m41-element" data-x-internal="m41-element">m41 element</a>, or <a id="fill-and-stroke-styles:m42-element" href="https://drafts.fxtf.org/geometry/#matrix-m42-element" data-x-internal="m42-element">m42
   element</a> are infinite or NaN, then return.</p></li><li><p>Reset the pattern's transformation matrix to <var>matrix</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When a pattern is to be rendered within an area, the user agent must run the following steps to
  determine what is rendered:</p>

  <ol><li><p>Create an infinite <a id="fill-and-stroke-styles:transparent-black-3" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> bitmap.</p></li><li>
    <p>Place a copy of the image on the bitmap, anchored such that its top left corner is at the
    origin of the coordinate space, with one coordinate space unit per <a href="https://drafts.csswg.org/css-values/#px" id="fill-and-stroke-styles:'px'-2" data-x-internal="'px'">CSS
    pixel</a> of the image, then place repeated copies of this image horizontally to the left and
    right, if the repetition behavior is "<code>repeat-x</code>", or vertically up and
    down, if the repetition behavior is "<code>repeat-y</code>", or in all four
    directions all over the bitmap, if the repetition behavior is "<code>repeat</code>".</p>

    <p>If the original image data is a bitmap image, then the value painted at a point in the area
    of the repetitions is computed by filtering the original image data. When scaling up, if the
    <code id="fill-and-stroke-styles:dom-context-2d-imagesmoothingenabled"><a href="#dom-context-2d-imagesmoothingenabled">imageSmoothingEnabled</a></code> attribute is
    set to false, then the image must be rendered using nearest-neighbor interpolation. Otherwise,
    the user agent may use any filtering algorithm (for example bilinear interpolation or
    nearest-neighbor). User agents which support multiple filtering algorithms may use the value of
    the <code id="fill-and-stroke-styles:dom-context-2d-imagesmoothingquality"><a href="#dom-context-2d-imagesmoothingquality">imageSmoothingQuality</a></code> attribute
    to guide the choice of filtering algorithm. When such a filtering algorithm requires a pixel
    value from outside the original image data, it must instead use the value from wrapping the
    pixel's coordinates to the original image's dimensions. (That is, the filter uses 'repeat'
    behavior, regardless of the value of the pattern's repetition behavior.)</p> 
   </li><li><p>Transform the resulting bitmap according to the pattern's transformation matrix.</p></li><li><p>Transform the resulting bitmap again, this time according to the <a href="#transformations" id="fill-and-stroke-styles:transformations-3">current transformation matrix</a>.</p></li><li><p>Replace any part of the image outside the area in which the pattern is to be rendered with
   <a id="fill-and-stroke-styles:transparent-black-4" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>.</p></li><li><p>The resulting bitmap is what is to be rendered, with the same origin and same
   scale.</p></li></ol>
  </div>

  <hr>

  <p>If a radial gradient or repeated pattern is used when the transformation matrix is singular,
  then the resulting style must be <a id="fill-and-stroke-styles:transparent-black-5" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> (otherwise the gradient or pattern
  would be collapsed to a point or line, leaving the other pixels undefined). Linear gradients and
  solid colors always define all points even with singular transformation matrices.</p>

  




  <h6 id="drawing-rectangles-to-the-bitmap"><span class="secno">4.12.5.1.11</span> Drawing rectangles to the bitmap<a href="#drawing-rectangles-to-the-bitmap" class="self-link"></a></h6>

  <p data-var-scope="">Objects that implement the <code id="drawing-rectangles-to-the-bitmap:canvasrect"><a href="#canvasrect">CanvasRect</a></code> interface provide the following methods for
  immediately drawing rectangles to the bitmap. The methods each take four arguments; the first two
  give the <var>x</var> and <var>y</var> coordinates of the top left of the rectangle, and the
  second two give the width <var>w</var> and height <var>h</var> of the rectangle, respectively.</p>

  

  <div data-algorithm="">
  <p>The <a href="#transformations" id="drawing-rectangles-to-the-bitmap:transformations">current transformation matrix</a> must be
  applied to the following four coordinates, which form the path that must then be closed to get the
  specified rectangle: <span>(<var>x</var>, <var>y</var>)</span>, <span>(<var>x</var>+<var>w</var>, <var>y</var>)</span>, <span>(<var>x</var>+<var>w</var>, <var>y</var>+<var>h</var>)</span>, <span>(<var>x</var>, <var>y</var>+<var>h</var>)</span>.</p>
  </div>

  <p>Shapes are painted without affecting the <a href="#current-default-path" id="drawing-rectangles-to-the-bitmap:current-default-path">current default path</a>, and are subject to
  the <a href="#clipping-region" id="drawing-rectangles-to-the-bitmap:clipping-region">clipping region</a>, and, with the exception of <code id="drawing-rectangles-to-the-bitmap:dom-context-2d-clearrect"><a href="#dom-context-2d-clearrect">clearRect()</a></code>, also <a href="#shadows" id="drawing-rectangles-to-the-bitmap:shadows">shadow
  effects</a>, <a href="#concept-canvas-global-alpha" id="drawing-rectangles-to-the-bitmap:concept-canvas-global-alpha">global alpha</a>, and the
  <a href="#current-compositing-and-blending-operator" id="drawing-rectangles-to-the-bitmap:current-compositing-and-blending-operator">current compositing and blending operator</a>.</p>

  

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-clearrect" id="dom-context-2d-clearrect-dev">clearRect</a>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clearRect" title="The CanvasRenderingContext2D.clearRect() method of the Canvas 2D API erases the pixels in a rectangular area by setting them to transparent black.">CanvasRenderingContext2D/clearRect</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Clears all pixels on the bitmap in the given rectangle to <a id="drawing-rectangles-to-the-bitmap:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent
   black</a>.</p></dd><dt><code><var>context</var>.<a href="#dom-context-2d-fillrect" id="dom-context-2d-fillrect-dev">fillRect</a>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillRect" title="The CanvasRenderingContext2D.fillRect() method of the Canvas 2D API draws a rectangle that is filled according to the current fillStyle.">CanvasRenderingContext2D/fillRect</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Paints the given rectangle onto the bitmap, using the current fill style.</p></dd><dt><code><var>context</var>.<a href="#dom-context-2d-strokerect" id="dom-context-2d-strokerect-dev">strokeRect</a>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeRect" title="The CanvasRenderingContext2D.strokeRect() method of the Canvas 2D API draws a rectangle that is stroked (outlined) according to the current strokeStyle and other context settings.">CanvasRenderingContext2D/strokeRect</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Paints the box that outlines the given rectangle onto the bitmap, using the current stroke
    style.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasRect" id="dom-context-2d-clearrect" data-dfn-type="method"><code>clearRect(<var>x</var>, <var>y</var>, <var>w</var>,
  <var>h</var>)</code></dfn> method, when invoked, must run these steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p>Let <var>pixels</var> be the set of pixels in the specified rectangle that also
   intersect the current <a href="#clipping-region" id="drawing-rectangles-to-the-bitmap:clipping-region-2">clipping region</a>.</p></li><li><p>Clear the pixels in <var>pixels</var> to a <a id="drawing-rectangles-to-the-bitmap:transparent-black-2" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>, erasing any
   previous image.</p></li></ol>
  </div>

  <p class="note">If either height or width are zero, this method has no effect, since the set of
  pixels would be empty.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasRect" id="dom-context-2d-fillrect" data-dfn-type="method"><code>fillRect(<var>x</var>,
  <var>y</var>, <var>w</var>, <var>h</var>)</code></dfn> method, when invoked, must run these
  steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p>If either <var>w</var> or <var>h</var> are zero, then return.</p></li><li><p>Paint the specified rectangular area using <a id="drawing-rectangles-to-the-bitmap:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-fill-style" id="drawing-rectangles-to-the-bitmap:concept-canvasfillstrokestyles-fill-style">fill style</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasRect" id="dom-context-2d-strokerect" data-dfn-type="method"><code>strokeRect(<var>x</var>, <var>y</var>, <var>w</var>,
  <var>h</var>)</code></dfn> method, when invoked, must run these steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p>Take the result of <a href="#trace-a-path" id="drawing-rectangles-to-the-bitmap:trace-a-path">tracing the path</a> described below,
   using the <code id="drawing-rectangles-to-the-bitmap:canvaspathdrawingstyles"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> interface's line styles, and fill it with
   <a id="drawing-rectangles-to-the-bitmap:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-stroke-style" id="drawing-rectangles-to-the-bitmap:concept-canvasfillstrokestyles-stroke-style">stroke
   style</a>.</p></li></ol>

  <p>If both <var>w</var> and <var>h</var> are zero, the path has a single subpath
  with just one point (<var>x</var>, <var>y</var>), and no lines, and this method
  thus has no effect (the <a href="#trace-a-path" id="drawing-rectangles-to-the-bitmap:trace-a-path-2">trace a path</a> algorithm returns an empty path in that
  case).</p>

  <p>If just one of either <var>w</var> or <var>h</var> is zero, then the path has
  a single subpath consisting of two points, with coordinates (<var>x</var>, <var>y</var>) and (<var>x</var>+<var>w</var>, <var>y</var>+<var>h</var>), in that order, connected by a single straight line.</p>

  <p>Otherwise, the path has a single subpath consisting of four points, with coordinates (<span><var>x</var></span>, <var>y</var>), (<span><var>x</var>+<var>w</var></span>, <var>y</var>), (<var>x</var>+<var>w</var>,
  <var>y</var>+<var>h</var>), and (<var>x</var>, <var>y</var>+<var>h</var>),
  connected to each other in that order by straight lines.</p>
  </div>

  



  <h6 id="drawing-text-to-the-bitmap"><span class="secno">4.12.5.1.12</span> Drawing text to the bitmap<a href="#drawing-text-to-the-bitmap" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D" title="The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a <canvas> element. It is used for drawing shapes, text, images, and other objects.">CanvasRenderingContext2D</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <dl id="text-0" class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-filltext" id="dom-context-2d-filltext-dev">fillText</a>(<var>text</var>, <var>x</var>, <var>y</var> [, <var>maxWidth</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillText" title="The CanvasRenderingContext2D method fillText(), part of the Canvas 2D API, draws a text string at the specified coordinates, filling the string's characters with the current fillStyle. An optional parameter allows specifying a maximum width for the rendered text, which the user agent will achieve by condensing the text or by using a lower font size.">CanvasRenderingContext2D/fillText</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>context</var>.<a href="#dom-context-2d-stroketext" id="dom-context-2d-stroketext-dev">strokeText</a>(<var>text</var>, <var>x</var>, <var>y</var> [, <var>maxWidth</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeText" title="The CanvasRenderingContext2D method strokeText(), part of the Canvas 2D API, strokes — that is, draws the outlines of — the characters of a text string at the specified coordinates. An optional parameter allows specifying a maximum width for the rendered text, which the user agent will achieve by condensing the text or by using a lower font size.">CanvasRenderingContext2D/strokeText</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Fills or strokes (respectively) the given text at the given position. If a maximum width is
    provided, the text will be scaled to fit that width if necessary.</p>
   </dd><dt><code><var>metrics</var> = <var>context</var>.<a href="#dom-context-2d-measuretext" id="dom-context-2d-measuretext-dev">measureText</a>(<var>text</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/measureText" title="The CanvasRenderingContext2D.measureText() method returns a TextMetrics object that contains information about the measured text (such as its width, for example).">CanvasRenderingContext2D/measureText</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="drawing-text-to-the-bitmap:textmetrics"><a href="#textmetrics">TextMetrics</a></code> object with the metrics of the given text in the current
    font.</p>
   </dd><dt><code><var>metrics</var>.<a href="#dom-textmetrics-width" id="dom-textmetrics-width-dev">width</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/width" title="The read-only width property of the TextMetrics interface contains the text's advance width (the width of that inline box) in CSS pixels.">TextMetrics/width</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>31+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-actualboundingboxleft" id="dom-textmetrics-actualboundingboxleft-dev">actualBoundingBoxLeft</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/actualBoundingBoxLeft" title="The read-only actualBoundingBoxLeft property of the TextMetrics interface is a double giving the distance parallel to the baseline from the alignment point given by the CanvasRenderingContext2D.textAlign property to the left side of the bounding rectangle of the given text, in CSS pixels; positive numbers indicating a distance going left from the given alignment point.">TextMetrics/actualBoundingBoxLeft</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>74+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-actualboundingboxright" id="dom-textmetrics-actualboundingboxright-dev">actualBoundingBoxRight</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/actualBoundingBoxRight" title="The read-only actualBoundingBoxRight property of the TextMetrics interface is a double giving the distance parallel to the baseline from the alignment point given by the CanvasRenderingContext2D.textAlign property to the right side of the bounding rectangle of the given text, in CSS pixels.">TextMetrics/actualBoundingBoxRight</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>74+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-fontboundingboxascent" id="dom-textmetrics-fontboundingboxascent-dev">fontBoundingBoxAscent</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/fontBoundingBoxAscent" title="The read-only fontBoundingBoxAscent property of the TextMetrics interface returns the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline attribute, to the top of the highest bounding rectangle of all the fonts used to render the text, in CSS pixels.">TextMetrics/fontBoundingBoxAscent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>116+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>87+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>87+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-fontboundingboxdescent" id="dom-textmetrics-fontboundingboxdescent-dev">fontBoundingBoxDescent</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/fontBoundingBoxDescent" title="The read-only fontBoundingBoxDescent property of the TextMetrics interface returns the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline attribute to the bottom of the bounding rectangle of all the fonts used to render the text, in CSS pixels.">TextMetrics/fontBoundingBoxDescent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>116+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>87+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>87+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-actualboundingboxascent" id="dom-textmetrics-actualboundingboxascent-dev">actualBoundingBoxAscent</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/actualBoundingBoxAscent" title="The read-only actualBoundingBoxAscent property of the TextMetrics interface is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline attribute to the top of the bounding rectangle used to render the text, in CSS pixels.">TextMetrics/actualBoundingBoxAscent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>74+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-actualboundingboxdescent" id="dom-textmetrics-actualboundingboxdescent-dev">actualBoundingBoxDescent</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/actualBoundingBoxDescent" title="The read-only actualBoundingBoxDescent property of the TextMetrics interface is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline attribute to the bottom of the bounding rectangle used to render the text, in CSS pixels.">TextMetrics/actualBoundingBoxDescent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>74+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-emheightascent" id="dom-textmetrics-emheightascent-dev">emHeightAscent</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/emHeightAscent" title="The read-only emHeightAscent property of the TextMetrics interface is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the top of the em square in the line box, in CSS pixels.">TextMetrics/emHeightAscent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 74+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 35+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-emheightdescent" id="dom-textmetrics-emheightdescent-dev">emHeightDescent</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/emHeightDescent" title="The read-only emHeightDescent property of the TextMetrics interface is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the bottom of the em square in the line box, in CSS pixels.">TextMetrics/emHeightDescent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 74+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires setting a user preference or runtime flag.">🔰 35+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires setting a user preference or runtime flag.">🔰 79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-hangingbaseline" id="dom-textmetrics-hangingbaseline-dev">hangingBaseline</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/hangingBaseline" title="The read-only hangingBaseline property of the TextMetrics interface is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the hanging baseline of the line box, in CSS pixels.">TextMetrics/hangingBaseline</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 74+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-alphabeticbaseline" id="dom-textmetrics-alphabeticbaseline-dev">alphabeticBaseline</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/alphabeticBaseline" title="The read-only alphabeticBaseline property of the TextMetrics interface is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the alphabetic baseline of the line box, in CSS pixels.">TextMetrics/alphabeticBaseline</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 74+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>metrics</var>.<a href="#dom-textmetrics-ideographicbaseline" id="dom-textmetrics-ideographicbaseline-dev">ideographicBaseline</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/ideographicBaseline" title="The read-only ideographicBaseline property of the TextMetrics interface is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the ideographic baseline of the line box, in CSS pixels.">TextMetrics/ideographicBaseline</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 74+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the measurement described below.</p></dd></dl>

  

  <p>Objects that implement the <code id="drawing-text-to-the-bitmap:canvastext"><a href="#canvastext">CanvasText</a></code> interface provide the following methods for
  rendering text.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasText" id="dom-context-2d-filltext" data-dfn-type="method"><code>fillText(<var>text</var>, <var>x</var>, <var>y</var>,
  <var>maxWidth</var>)</code></dfn> and <dfn data-dfn-for="CanvasText" id="dom-context-2d-stroketext" data-dfn-type="method"><code>strokeText(<var>text</var>, <var>x</var>, <var>y</var>,
  <var>maxWidth</var>)</code></dfn> methods render the given
  <var>text</var> at the given (<var>x</var>, <var>y</var>) coordinates ensuring that the text isn't
  wider than <var>maxWidth</var> if specified, using the current <code id="drawing-text-to-the-bitmap:dom-context-2d-font"><a href="#dom-context-2d-font">font</a></code>, <code id="drawing-text-to-the-bitmap:dom-context-2d-textalign"><a href="#dom-context-2d-textalign">textAlign</a></code>, and <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> values. Specifically, when the methods
  are invoked, the user agent must run these steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p>Run the <a href="#text-preparation-algorithm" id="drawing-text-to-the-bitmap:text-preparation-algorithm">text preparation algorithm</a>, passing it <var>text</var>, the object
   implementing the <code id="drawing-text-to-the-bitmap:canvastext-2"><a href="#canvastext">CanvasText</a></code> interface, and, if the <var>maxWidth</var> argument was
   provided, that argument. Let <var>glyphs</var> be the result.</p>

   </li><li><p>Move all the shapes in <var>glyphs</var> to the right by <var>x</var>
   <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'" data-x-internal="'px'">CSS pixels</a> and down by <var>y</var> <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-2" data-x-internal="'px'">CSS
   pixels</a>.</p></li><li>
    <p>Paint the shapes given in <var>glyphs</var>, as transformed by the <a href="#transformations" id="drawing-text-to-the-bitmap:transformations">current transformation matrix</a>, with each <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-3" data-x-internal="'px'">CSS pixel</a> in the coordinate space of <var>glyphs</var> mapped to one
    coordinate space unit.</p>

    <p>For <code id="drawing-text-to-the-bitmap:dom-context-2d-filltext"><a href="#dom-context-2d-filltext">fillText()</a></code>, <a id="drawing-text-to-the-bitmap:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-fill-style" id="drawing-text-to-the-bitmap:concept-canvasfillstrokestyles-fill-style">fill style</a> must be applied to the
    shapes and <a id="drawing-text-to-the-bitmap:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-stroke-style" id="drawing-text-to-the-bitmap:concept-canvasfillstrokestyles-stroke-style">stroke
    style</a> must be ignored. For <code id="drawing-text-to-the-bitmap:dom-context-2d-stroketext"><a href="#dom-context-2d-stroketext">strokeText()</a></code>,
    the reverse holds: <a id="drawing-text-to-the-bitmap:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-stroke-style" id="drawing-text-to-the-bitmap:concept-canvasfillstrokestyles-stroke-style-2">stroke style</a> must be applied to the
    result of <a href="#trace-a-path" id="drawing-text-to-the-bitmap:trace-a-path">tracing</a> the shapes using the object implementing
    the <code id="drawing-text-to-the-bitmap:canvastext-3"><a href="#canvastext">CanvasText</a></code> interface for the line styles, and <a id="drawing-text-to-the-bitmap:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasfillstrokestyles-fill-style" id="drawing-text-to-the-bitmap:concept-canvasfillstrokestyles-fill-style-2">fill style</a> must be ignored.</p>

    <p>These shapes are painted without affecting the current path, and are subject to <a href="#shadows" id="drawing-text-to-the-bitmap:shadows">shadow effects</a>, <a href="#concept-canvas-global-alpha" id="drawing-text-to-the-bitmap:concept-canvas-global-alpha">global
    alpha</a>, the <a href="#clipping-region" id="drawing-text-to-the-bitmap:clipping-region">clipping region</a>, and the <a href="#current-compositing-and-blending-operator" id="drawing-text-to-the-bitmap:current-compositing-and-blending-operator">current compositing and blending
    operator</a>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>
  <a id="drawing-text-to-the-bitmap:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  The <dfn data-dfn-for="CanvasText" id="dom-context-2d-measuretext" data-dfn-type="method"><code>measureText(<var>text</var>)</code></dfn> method steps are to
  run the <a href="#text-preparation-algorithm" id="drawing-text-to-the-bitmap:text-preparation-algorithm-2">text preparation algorithm</a>, passing it <var>text</var> and the object
  implementing the <code id="drawing-text-to-the-bitmap:canvastext-4"><a href="#canvastext">CanvasText</a></code> interface, and then using the returned <a id="drawing-text-to-the-bitmap:inline-box" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline
  box</a> return a new <code id="drawing-text-to-the-bitmap:textmetrics-2"><a href="#textmetrics">TextMetrics</a></code> object with members behaving as described in
  the following list: <a href="#refsCSS">[CSS]</a></p>
  </div>

  

  <dl><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-width" data-dfn-type="attribute"><code>width</code></dfn>
   attribute</dt><dd><p>The width of that <a id="drawing-text-to-the-bitmap:inline-box-2" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-4" data-x-internal="'px'">CSS pixels</a>. (The
   text's advance width.)</p></dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-actualboundingboxleft" data-dfn-type="attribute"><code>actualBoundingBoxLeft</code></dfn> attribute</dt><dd>
    <p>The distance parallel to the baseline from the alignment point given by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textalign-2"><a href="#dom-context-2d-textalign">textAlign</a></code> attribute to the left side of the bounding
    rectangle of the given text, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-5" data-x-internal="'px'">CSS pixels</a>; positive numbers
    indicating a distance going left from the given alignment point.

    </p><p class="note">The sum of this value and the next (<code id="drawing-text-to-the-bitmap:dom-textmetrics-actualboundingboxright"><a href="#dom-textmetrics-actualboundingboxright">actualBoundingBoxRight</a></code>) can be wider than
    the width of the <a id="drawing-text-to-the-bitmap:inline-box-3" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a> (<code id="drawing-text-to-the-bitmap:dom-textmetrics-width"><a href="#dom-textmetrics-width">width</a></code>), in
    particular with slanted fonts where characters overhang their advance width.</p>
   </dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-actualboundingboxright" data-dfn-type="attribute"><code>actualBoundingBoxRight</code></dfn> attribute</dt><dd>
    <p>The distance parallel to the baseline from the alignment point given by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textalign-3"><a href="#dom-context-2d-textalign">textAlign</a></code> attribute to the right side of the bounding
    rectangle of the given text, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-6" data-x-internal="'px'">CSS pixels</a>; positive numbers
    indicating a distance going right from the given alignment point.</p>
   </dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-fontboundingboxascent" data-dfn-type="attribute"><code>fontBoundingBoxAscent</code></dfn> attribute</dt><dd>
    <p>The distance from the horizontal line indicated by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-2"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute to the <a id="drawing-text-to-the-bitmap:ascent-metric" href="https://drafts.csswg.org/css-inline/#ascent-metric" data-x-internal="ascent-metric">ascent
    metric</a> of the <a id="drawing-text-to-the-bitmap:first-available-font" href="https://drafts.csswg.org/css-fonts/#first-available-font" data-x-internal="first-available-font">first available font</a>, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-7" data-x-internal="'px'">CSS
    pixels</a>; positive numbers indicating a distance going up from the given baseline.</p>

    <p class="note">This value and the next are useful when rendering a background that have to have
    a consistent height even if the exact text being rendered changes. The <code id="drawing-text-to-the-bitmap:dom-textmetrics-actualboundingboxascent"><a href="#dom-textmetrics-actualboundingboxascent">actualBoundingBoxAscent</a></code> attribute (and
    its corresponding attribute for the descent) are useful when drawing a bounding box around
    specific text.</p>
   </dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-fontboundingboxdescent" data-dfn-type="attribute"><code>fontBoundingBoxDescent</code></dfn> attribute</dt><dd><p>The distance from the horizontal line indicated by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-3"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute to the <a id="drawing-text-to-the-bitmap:descent-metric" href="https://drafts.csswg.org/css-inline/#descent-metric" data-x-internal="descent-metric">descent
   metric</a> of the <a id="drawing-text-to-the-bitmap:first-available-font-2" href="https://drafts.csswg.org/css-fonts/#first-available-font" data-x-internal="first-available-font">first available font</a>, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-8" data-x-internal="'px'">CSS pixels</a>;
   positive numbers indicating a distance going down from the given baseline.</p></dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-actualboundingboxascent" data-dfn-type="attribute"><code>actualBoundingBoxAscent</code></dfn> attribute</dt><dd>
    <p>The distance from the horizontal line indicated by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-4"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute to the top of the bounding
    rectangle of the given text, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-9" data-x-internal="'px'">CSS pixels</a>; positive numbers
    indicating a distance going up from the given baseline.

    </p><p class="note">This number can vary greatly based on the input text, even if the first font
    specified covers all the characters in the input. For example, the <code id="drawing-text-to-the-bitmap:dom-textmetrics-actualboundingboxascent-2"><a href="#dom-textmetrics-actualboundingboxascent">actualBoundingBoxAscent</a></code> of a lowercase
    "o" from an <a id="drawing-text-to-the-bitmap:alphabetic-baseline" href="https://drafts.csswg.org/css-inline/#alphabetic-baseline" data-x-internal="alphabetic-baseline">alphabetic baseline</a> would be less than that of an uppercase "F". The
    value can easily be negative; for example, the distance from the top of the em box (<code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-5"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> value "<code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-top"><a href="#dom-context-2d-textbaseline-top">top</a></code>") to the top of the bounding rectangle when
    the given text is just a single comma "<code>,</code>" would likely (unless the font is
    quite unusual) be negative.</p>
   </dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-actualboundingboxdescent" data-dfn-type="attribute"><code>actualBoundingBoxDescent</code></dfn> attribute</dt><dd><p>The distance from the horizontal line indicated by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-6"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute to the bottom of the bounding
   rectangle of the given text, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-10" data-x-internal="'px'">CSS pixels</a>; positive numbers
   indicating a distance going down from the given baseline.</p></dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-emheightascent" data-dfn-type="attribute"><code>emHeightAscent</code></dfn> attribute</dt><dd><p>The distance from the horizontal line indicated by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-7"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute to the <a id="drawing-text-to-the-bitmap:em-over-baseline" href="https://drafts.csswg.org/css-inline/#em-over-baseline" data-x-internal="em-over-baseline">em-over
   baseline</a> in the <a id="drawing-text-to-the-bitmap:inline-box-4" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-11" data-x-internal="'px'">CSS pixels</a>;
   positive numbers indicating that the given baseline is below the <a id="drawing-text-to-the-bitmap:em-over-baseline-2" href="https://drafts.csswg.org/css-inline/#em-over-baseline" data-x-internal="em-over-baseline">em-over baseline</a>
   (so this value will usually be positive). Zero if the given baseline is the <a id="drawing-text-to-the-bitmap:em-over-baseline-3" href="https://drafts.csswg.org/css-inline/#em-over-baseline" data-x-internal="em-over-baseline">em-over
   baseline</a>; half the font size if the given baseline is halfway between the <a id="drawing-text-to-the-bitmap:em-over-baseline-4" href="https://drafts.csswg.org/css-inline/#em-over-baseline" data-x-internal="em-over-baseline">em-over
   baseline</a> and the <a id="drawing-text-to-the-bitmap:em-under-baseline" href="https://drafts.csswg.org/css-inline/#em-under-baseline" data-x-internal="em-under-baseline">em-under baseline</a>.</p></dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-emheightdescent" data-dfn-type="attribute"><code>emHeightDescent</code></dfn> attribute</dt><dd><p>The distance from the horizontal line indicated by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-8"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute to the <a id="drawing-text-to-the-bitmap:em-under-baseline-2" href="https://drafts.csswg.org/css-inline/#em-under-baseline" data-x-internal="em-under-baseline">em-under
   baseline</a> in the <a id="drawing-text-to-the-bitmap:inline-box-5" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-12" data-x-internal="'px'">CSS pixels</a>;
   positive numbers indicating that the given baseline is above the <a id="drawing-text-to-the-bitmap:em-under-baseline-3" href="https://drafts.csswg.org/css-inline/#em-under-baseline" data-x-internal="em-under-baseline">em-under baseline</a>.
   (Zero if the given baseline is the <a id="drawing-text-to-the-bitmap:em-under-baseline-4" href="https://drafts.csswg.org/css-inline/#em-under-baseline" data-x-internal="em-under-baseline">em-under baseline</a>.)</p></dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-hangingbaseline" data-dfn-type="attribute"><code>hangingBaseline</code></dfn> attribute</dt><dd><p>The distance from the horizontal line indicated by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-9"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute to the <a id="drawing-text-to-the-bitmap:hanging-baseline" href="https://drafts.csswg.org/css-inline/#hanging-baseline" data-x-internal="hanging-baseline">hanging
   baseline</a> of the <a id="drawing-text-to-the-bitmap:inline-box-6" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-13" data-x-internal="'px'">CSS pixels</a>;
   positive numbers indicating that the given baseline is below the <a id="drawing-text-to-the-bitmap:hanging-baseline-2" href="https://drafts.csswg.org/css-inline/#hanging-baseline" data-x-internal="hanging-baseline">hanging baseline</a>.
   (Zero if the given baseline is the <a id="drawing-text-to-the-bitmap:hanging-baseline-3" href="https://drafts.csswg.org/css-inline/#hanging-baseline" data-x-internal="hanging-baseline">hanging baseline</a>.)</p></dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-alphabeticbaseline" data-dfn-type="attribute"><code>alphabeticBaseline</code></dfn> attribute</dt><dd><p>The distance from the horizontal line indicated by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-10"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute to the <a id="drawing-text-to-the-bitmap:alphabetic-baseline-2" href="https://drafts.csswg.org/css-inline/#alphabetic-baseline" data-x-internal="alphabetic-baseline">alphabetic
   baseline</a> of the <a id="drawing-text-to-the-bitmap:inline-box-7" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-14" data-x-internal="'px'">CSS pixels</a>;
   positive numbers indicating that the given baseline is below the <a id="drawing-text-to-the-bitmap:alphabetic-baseline-3" href="https://drafts.csswg.org/css-inline/#alphabetic-baseline" data-x-internal="alphabetic-baseline">alphabetic
   baseline</a>. (Zero if the given baseline is the <a id="drawing-text-to-the-bitmap:alphabetic-baseline-4" href="https://drafts.csswg.org/css-inline/#alphabetic-baseline" data-x-internal="alphabetic-baseline">alphabetic baseline</a>.)</p></dd><dt><dfn data-dfn-for="TextMetrics" id="dom-textmetrics-ideographicbaseline" data-dfn-type="attribute"><code>ideographicBaseline</code></dfn> attribute</dt><dd><p>The distance from the horizontal line indicated by the <code id="drawing-text-to-the-bitmap:dom-context-2d-textbaseline-11"><a href="#dom-context-2d-textbaseline">textBaseline</a></code> attribute to the <a id="drawing-text-to-the-bitmap:ideographic-under-baseline" href="https://drafts.csswg.org/css-inline/#ideographic-under-baseline" data-x-internal="ideographic-under-baseline">ideographic-under
   baseline</a> of the <a id="drawing-text-to-the-bitmap:inline-box-8" href="https://drafts.csswg.org/css2/#inline-box" data-x-internal="inline-box">inline box</a>, in <a href="https://drafts.csswg.org/css-values/#px" id="drawing-text-to-the-bitmap:'px'-15" data-x-internal="'px'">CSS pixels</a>;
   positive numbers indicating that the given baseline is below the <a id="drawing-text-to-the-bitmap:ideographic-under-baseline-2" href="https://drafts.csswg.org/css-inline/#ideographic-under-baseline" data-x-internal="ideographic-under-baseline">ideographic-under
   baseline</a>. (Zero if the given baseline is the <a id="drawing-text-to-the-bitmap:ideographic-under-baseline-3" href="https://drafts.csswg.org/css-inline/#ideographic-under-baseline" data-x-internal="ideographic-under-baseline">ideographic-under
   baseline</a>.)</p></dd></dl>

  <p class="note">Glyphs rendered using <code id="drawing-text-to-the-bitmap:dom-context-2d-filltext-2"><a href="#dom-context-2d-filltext">fillText()</a></code> and
  <code id="drawing-text-to-the-bitmap:dom-context-2d-stroketext-2"><a href="#dom-context-2d-stroketext">strokeText()</a></code> can spill out of the box given by the
  font size and the width returned by <code id="drawing-text-to-the-bitmap:dom-context-2d-measuretext"><a href="#dom-context-2d-measuretext">measureText()</a></code>
  (the text width). Authors are encouraged to use the bounding box values described above if this is
  an issue.</p>

  <p class="note">A future version of the 2D context API might provide a way to render fragments of
  documents, rendered using CSS, straight to the canvas. This would be provided in preference to a
  dedicated way of doing multiline layout.</p>



  <h6 id="drawing-paths-to-the-canvas"><span class="secno">4.12.5.1.13</span> Drawing paths to the canvas<a href="#drawing-paths-to-the-canvas" class="self-link"></a></h6>

  <p>Objects that implement the <code id="drawing-paths-to-the-canvas:canvasdrawpath"><a href="#canvasdrawpath">CanvasDrawPath</a></code> interface have a <dfn id="current-default-path">current default
  path</dfn>. There is only one <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path">current default path</a>, it is not part of the
  <a href="#drawing-state" id="drawing-paths-to-the-canvas:drawing-state">drawing state</a>. The <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-2">current default path</a> is a <a href="#concept-path" id="drawing-paths-to-the-canvas:concept-path">path</a>, as described above.</p>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-beginpath" id="dom-context-2d-beginpath-dev">beginPath</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/beginPath" title="The CanvasRenderingContext2D.beginPath() method of the Canvas 2D API starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path.">CanvasRenderingContext2D/beginPath</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Resets the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-3">current default path</a>.</p></dd><dt><code><var>context</var>.<a href="#dom-context-2d-fill" id="dom-context-2d-fill-dev">fill</a>([ <var>fillRule</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fill" title="The CanvasRenderingContext2D.fill() method of the Canvas 2D API fills the current or given path with the current fillStyle.">CanvasRenderingContext2D/fill</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>context</var>.<a href="#dom-context-2d-fill" id="drawing-paths-to-the-canvas:dom-context-2d-fill">fill</a>(<var>path</var> [, <var>fillRule</var> ])</code></dt><dd>
    <p>Fills the subpaths of the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-4">current default path</a> or the given path with the
    current fill style, obeying the given fill rule.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-stroke" id="dom-context-2d-stroke-dev">stroke</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/stroke" title="The CanvasRenderingContext2D.stroke() method of the Canvas 2D API strokes (outlines) the current or given path with the current stroke style.">CanvasRenderingContext2D/stroke</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>context</var>.<a href="#dom-context-2d-stroke" id="drawing-paths-to-the-canvas:dom-context-2d-stroke">stroke</a>(<var>path</var>)</code></dt><dd>
    <p>Strokes the subpaths of the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-5">current default path</a> or the given path with the
    current stroke style.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-clip" id="dom-context-2d-clip-dev">clip</a>([ <var>fillRule</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clip" title="The CanvasRenderingContext2D.clip() method of the Canvas 2D API turns the current or given path into the current clipping region. The previous clipping region, if any, is intersected with the current or given path to create the new clipping region.">CanvasRenderingContext2D/clip</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>context</var>.<a href="#dom-context-2d-clip" id="drawing-paths-to-the-canvas:dom-context-2d-clip">clip</a>(<var>path</var> [, <var>fillRule</var> ])</code></dt><dd>
    <p>Further constrains the clipping region to the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-6">current default path</a> or the given
    path, using the given fill rule to determine what points are in the path.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-ispointinpath" id="dom-context-2d-ispointinpath-dev">isPointInPath</a>(<var>x</var>, <var>y</var> [, <var>fillRule</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/isPointInPath" title="The CanvasRenderingContext2D.isPointInPath() method of the Canvas 2D API reports whether or not the specified point is contained in the current path.">CanvasRenderingContext2D/isPointInPath</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>context</var>.<a href="#dom-context-2d-ispointinpath" id="drawing-paths-to-the-canvas:dom-context-2d-ispointinpath">isPointInPath</a>(<var>path</var>, <var>x</var>, <var>y</var> [, <var>fillRule</var> ])</code></dt><dd>
    <p>Returns true if the given point is in the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-7">current default path</a> or the given
    path, using the given fill rule to determine what points are in the path.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-ispointinstroke" id="dom-context-2d-ispointinstroke-dev">isPointInStroke</a>(<var>x</var>, <var>y</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/isPointInStroke" title="The CanvasRenderingContext2D.isPointInStroke() method of the Canvas 2D API reports whether or not the specified point is inside the area contained by the stroking of a path.">CanvasRenderingContext2D/isPointInStroke</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>19+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>26+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>context</var>.<a href="#dom-context-2d-ispointinstroke" id="drawing-paths-to-the-canvas:dom-context-2d-ispointinstroke">isPointInStroke</a>(<var>path</var>, <var>x</var>, <var>y</var>)</code></dt><dd>
    <p>Returns true if the given point would be in the region covered by the stroke of the
    <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-8">current default path</a> or the given path, given the current stroke style.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-beginpath" data-dfn-type="method"><code>beginPath()</code></dfn> method steps are to empty the list of
  subpaths in <a id="drawing-paths-to-the-canvas:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-9">current default path</a> so that it once again has zero
  subpaths.</p>
  </div>

  <div data-algorithm="">
  <p>Where the following method definitions use the term <dfn id="intended-path">intended path</dfn> for a
  <code id="drawing-paths-to-the-canvas:path2d"><a href="#path2d">Path2D</a></code>-or-null <var>path</var>, it means <var>path</var> itself if it is a
  <code id="drawing-paths-to-the-canvas:path2d-2"><a href="#path2d">Path2D</a></code> object, or the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-10">current default path</a> otherwise.</p>
  </div>

  <p>When the <a href="#intended-path" id="drawing-paths-to-the-canvas:intended-path">intended path</a> is a <code id="drawing-paths-to-the-canvas:path2d-3"><a href="#path2d">Path2D</a></code> object, the coordinates and lines
  of its subpaths must be transformed according to the <a href="#transformations" id="drawing-paths-to-the-canvas:transformations"> current transformation matrix</a> on the object
  implementing the <code id="drawing-paths-to-the-canvas:canvastransform"><a href="#canvastransform">CanvasTransform</a></code> interface when used by these methods (without
  affecting the <code id="drawing-paths-to-the-canvas:path2d-4"><a href="#path2d">Path2D</a></code> object itself). When the intended path is the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-11">current
  default path</a>, it is not affected by the transform. (This is because transformations
  already affect the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-12">current default path</a> when it is constructed, so applying it when
  it is painted as well would result in a double transformation.)</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-fill" data-dfn-type="method"><code>fill(<var>fillRule</var>)</code></dfn> method steps are to run the
  <a href="#fill-steps" id="drawing-paths-to-the-canvas:fill-steps">fill steps</a> given <a id="drawing-paths-to-the-canvas:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, null, and <var>fillRule</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-fill-path" data-dfn-type="method"><code>fill(<var>path</var>, <var>fillRule</var>)</code></dfn> method
  steps are to run the <a href="#fill-steps" id="drawing-paths-to-the-canvas:fill-steps-2">fill steps</a> given <a id="drawing-paths-to-the-canvas:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>path</var>, and
  <var>fillRule</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="fill-steps">fill steps</dfn>, given a <code id="drawing-paths-to-the-canvas:canvasdrawpath-2"><a href="#canvasdrawpath">CanvasDrawPath</a></code> <var>context</var>, a
  <code id="drawing-paths-to-the-canvas:path2d-5"><a href="#path2d">Path2D</a></code>-or-null <var>path</var>, and a <a href="#fill-rule" id="drawing-paths-to-the-canvas:fill-rule">fill rule</a> <var>fillRule</var>,
  are to fill all the subpaths of the <a href="#intended-path" id="drawing-paths-to-the-canvas:intended-path-2">intended path</a> for <var>path</var>, using
  <var>context</var>'s <a href="#concept-canvasfillstrokestyles-fill-style" id="drawing-paths-to-the-canvas:concept-canvasfillstrokestyles-fill-style">fill style</a>,
  and using the <a href="#fill-rule" id="drawing-paths-to-the-canvas:fill-rule-2">fill rule</a> indicated by <var>fillRule</var>. Open subpaths must be
  implicitly closed when being filled (without affecting the actual subpaths).</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-stroke" data-dfn-type="method"><code>stroke()</code></dfn> method steps are to run the <a href="#stroke-steps" id="drawing-paths-to-the-canvas:stroke-steps">stroke
  steps</a> given <a id="drawing-paths-to-the-canvas:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and null.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-stroke-path" data-dfn-type="method"><code>stroke(<var>path</var>)</code></dfn> method steps are to run
  the <a href="#stroke-steps" id="drawing-paths-to-the-canvas:stroke-steps-2">stroke steps</a> given <a id="drawing-paths-to-the-canvas:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and <var>path</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="stroke-steps">stroke steps</dfn>, given a <code id="drawing-paths-to-the-canvas:canvasdrawpath-3"><a href="#canvasdrawpath">CanvasDrawPath</a></code> <var>context</var> and a
  <code id="drawing-paths-to-the-canvas:path2d-6"><a href="#path2d">Path2D</a></code>-or-null <var>path</var>, are to <a href="#trace-a-path" id="drawing-paths-to-the-canvas:trace-a-path">trace</a> the
  <a href="#intended-path" id="drawing-paths-to-the-canvas:intended-path-3">intended path</a> for <var>path</var>, using <var>context</var>'s line styles as set by
  its <code id="drawing-paths-to-the-canvas:canvaspathdrawingstyles"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> mixin, and then fill the resulting path using
  <var>context</var>'s <a href="#concept-canvasfillstrokestyles-stroke-style" id="drawing-paths-to-the-canvas:concept-canvasfillstrokestyles-stroke-style">stroke
  style</a>, using the <a href="#dom-context-2d-fillrule-nonzero" id="drawing-paths-to-the-canvas:dom-context-2d-fillrule-nonzero">nonzero winding
  rule</a>.</p>
  </div>

  <p class="note">As a result of how the algorithm to <a href="#trace-a-path" id="drawing-paths-to-the-canvas:trace-a-path-2">trace a path</a> is defined,
  overlapping parts of the paths in one stroke operation are treated as if their union was what was
  painted.</p>

  <p class="note">The stroke <em>style</em> is affected by the transformation during painting, even
  if the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-13">current default path</a> is used.</p>

  <p>Paths, when filled or stroked, must be painted without affecting the <a href="#current-default-path" id="drawing-paths-to-the-canvas:current-default-path-14">current default
  path</a> or any <code id="drawing-paths-to-the-canvas:path2d-7"><a href="#path2d">Path2D</a></code> objects, and must be subject to <a href="#shadows" id="drawing-paths-to-the-canvas:shadows">shadow effects</a>, <a href="#concept-canvas-global-alpha" id="drawing-paths-to-the-canvas:concept-canvas-global-alpha">global
  alpha</a>, the <a href="#clipping-region" id="drawing-paths-to-the-canvas:clipping-region">clipping region</a>, and the <a href="#current-compositing-and-blending-operator" id="drawing-paths-to-the-canvas:current-compositing-and-blending-operator">current compositing and blending
  operator</a>. (The effect of transformations is described above and varies based on which path
  is being used.)</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-clip" data-dfn-type="method"><code>clip(<var>fillRule</var>)</code></dfn> method steps are to run the
  <a href="#clip-steps" id="drawing-paths-to-the-canvas:clip-steps">clip steps</a> given <a id="drawing-paths-to-the-canvas:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, null, and <var>fillRule</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-clip-path" data-dfn-type="method"><code>clip(<var>path</var>, <var>fillRule</var>)</code></dfn> method
  steps are to run the <a href="#clip-steps" id="drawing-paths-to-the-canvas:clip-steps-2">clip steps</a> given <a id="drawing-paths-to-the-canvas:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>path</var>, and
  <var>fillRule</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="clip-steps">clip steps</dfn>, given a <code id="drawing-paths-to-the-canvas:canvasdrawpath-4"><a href="#canvasdrawpath">CanvasDrawPath</a></code> <var>context</var>, a
  <code id="drawing-paths-to-the-canvas:path2d-8"><a href="#path2d">Path2D</a></code>-or-null <var>path</var>, and a <a href="#fill-rule" id="drawing-paths-to-the-canvas:fill-rule-3">fill rule</a> <var>fillRule</var>,
  are to create a new <dfn id="clipping-region">clipping region</dfn> by calculating the intersection of
  <var>context</var>'s current clipping region and the area described by the <a href="#intended-path" id="drawing-paths-to-the-canvas:intended-path-4">intended
  path</a> for <var>path</var>, using the <a href="#fill-rule" id="drawing-paths-to-the-canvas:fill-rule-4">fill rule</a> indicated by
  <var>fillRule</var>. Open subpaths must be implicitly closed when computing the clipping region,
  without affecting the actual subpaths. The new clipping region replaces the current clipping
  region.</p>
  </div>

  <p>When the context is initialized, its current clipping region must be set to the largest
  infinite surface (i.e. by default, no clipping occurs).</p>

  

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-ispointinpath" data-dfn-type="method"><code>isPointInPath(<var>x</var>, <var>y</var>,
  <var>fillRule</var>)</code></dfn> method steps are to return the result of the <a href="#is-point-in-path-steps" id="drawing-paths-to-the-canvas:is-point-in-path-steps">is point in
  path steps</a> given <a id="drawing-paths-to-the-canvas:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, null, <var>x</var>, <var>y</var>, and
  <var>fillRule</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-ispointinpath-path" data-dfn-type="method"><code>isPointInPath(<var>path</var>, <var>x</var>,
  <var>y</var>, <var>fillRule</var>)</code></dfn> method steps are to return the result of the
  <a href="#is-point-in-path-steps" id="drawing-paths-to-the-canvas:is-point-in-path-steps-2">is point in path steps</a> given <a id="drawing-paths-to-the-canvas:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>path</var>, <var>x</var>, <var>y</var>,
  and <var>fillRule</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="is-point-in-path-steps">is point in path steps</dfn>, given a <code id="drawing-paths-to-the-canvas:canvasdrawpath-5"><a href="#canvasdrawpath">CanvasDrawPath</a></code> <var>context</var>,
  a <code id="drawing-paths-to-the-canvas:path2d-9"><a href="#path2d">Path2D</a></code>-or-null <var>path</var>, two numbers <var>x</var> and <var>y</var>, and a
  <a href="#fill-rule" id="drawing-paths-to-the-canvas:fill-rule-5">fill rule</a> <var>fillRule</var>, are:</p>

  <ol><li><p>If <var>x</var> or <var>y</var> are infinite or NaN, then return false.</p></li><li><p>If the point given by the <var>x</var> and <var>y</var> coordinates, when treated as
   coordinates in the canvas coordinate space unaffected by the current transformation, is inside
   the <a href="#intended-path" id="drawing-paths-to-the-canvas:intended-path-5">intended path</a> for <var>path</var> as determined by the <a href="#fill-rule" id="drawing-paths-to-the-canvas:fill-rule-6">fill rule</a>
   indicated by <var>fillRule</var>, then return true. Open subpaths must be implicitly closed when
   computing the area inside the path, without affecting the actual subpaths. Points on the path
   itself must be considered to be inside the path.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-ispointinstroke" data-dfn-type="method"><code>isPointInStroke(<var>x</var>, <var>y</var>)</code></dfn>
  method steps are to return the result of the <a href="#is-point-in-stroke-steps" id="drawing-paths-to-the-canvas:is-point-in-stroke-steps">is point in stroke steps</a> given
  <a id="drawing-paths-to-the-canvas:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, null, <var>x</var>, and <var>y</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasDrawPath" id="dom-context-2d-ispointinstroke-path" data-dfn-type="method"><code>isPointInStroke(<var>path</var>, <var>x</var>,
  <var>y</var>)</code></dfn> method steps are to return the result of the <a href="#is-point-in-stroke-steps" id="drawing-paths-to-the-canvas:is-point-in-stroke-steps-2">is point in stroke
  steps</a> given <a id="drawing-paths-to-the-canvas:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>path</var>, <var>x</var>, and <var>y</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="is-point-in-stroke-steps">is point in stroke steps</dfn>, given a <code id="drawing-paths-to-the-canvas:canvasdrawpath-6"><a href="#canvasdrawpath">CanvasDrawPath</a></code>
  <var>context</var>, a <code id="drawing-paths-to-the-canvas:path2d-10"><a href="#path2d">Path2D</a></code>-or-null <var>path</var>, and two numbers <var>x</var>
  and <var>y</var>, are:</p>

  <ol><li><p>If <var>x</var> or <var>y</var> are infinite or NaN, then return false.</p></li><li><p>If the point given by the <var>x</var> and <var>y</var> coordinates, when treated as
   coordinates in the canvas coordinate space unaffected by the current transformation, is inside
   the path that results from <a href="#trace-a-path" id="drawing-paths-to-the-canvas:trace-a-path-3">tracing</a> the <a href="#intended-path" id="drawing-paths-to-the-canvas:intended-path-6">intended
   path</a> for <var>path</var>, using the <a href="#dom-context-2d-fillrule-nonzero" id="drawing-paths-to-the-canvas:dom-context-2d-fillrule-nonzero-2">nonzero winding rule</a>, and using
   <var>context</var>'s line styles as set by its <code id="drawing-paths-to-the-canvas:canvaspathdrawingstyles-2"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code> mixin, then
   return true. Points on the resulting path must be considered to be inside the path.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <hr>

  

  <div id="drawCustomFocusRingExample" class="example"><a href="#drawCustomFocusRingExample" class="self-link"></a>

   <p>This <code id="drawing-paths-to-the-canvas:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element has a couple of checkboxes. The path-related commands are
   highlighted:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">canvas</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">400</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">750</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">showA</c-><c- p="">&gt;</c-> Show As<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">checkbox</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">showB</c-><c- p="">&gt;</c-> Show Bs<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- c="">&lt;!-- ... --&gt;</c->
<c- p="">&lt;/</c-><c- f="">canvas</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">function</c-> drawCheckbox<c- p="">(</c->context<c- p="">,</c-> element<c- p="">,</c-> x<c- p="">,</c-> y<c- p="">,</c-> paint<c- p="">)</c-> <c- p="">{</c->
   context<c- p="">.</c->save<c- p="">();</c->
   context<c- p="">.</c->font <c- o="">=</c-> <c- t="">'10px sans-serif'</c-><c- p="">;</c->
   context<c- p="">.</c->textAlign <c- o="">=</c-> <c- t="">'left'</c-><c- p="">;</c->
   context<c- p="">.</c->textBaseline <c- o="">=</c-> <c- t="">'middle'</c-><c- p="">;</c->
   <c- a="">var</c-> metrics <c- o="">=</c-> context<c- p="">.</c->measureText<c- p="">(</c->element<c- p="">.</c->labels<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->textContent<c- p="">);</c->
   <c- k="">if</c-> <c- p="">(</c->paint<c- p="">)</c-> <c- p="">{</c->
<strong>     context<c- p="">.</c->beginPath<c- p="">();</c->
     context<c- p="">.</c->strokeStyle <c- o="">=</c-> <c- t="">'black'</c-><c- p="">;</c->
     context<c- p="">.</c->rect<c- p="">(</c->x<c- o="">-</c-><c- mf="">5</c-><c- p="">,</c-> y<c- o="">-</c-><c- mf="">5</c-><c- p="">,</c-> <c- mf="">10</c-><c- p="">,</c-> <c- mf="">10</c-><c- p="">);</c->
     context<c- p="">.</c->stroke<c- p="">();</c->
</strong>     <c- k="">if</c-> <c- p="">(</c->element<c- p="">.</c->checked<c- p="">)</c-> <c- p="">{</c->
<strong>       context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- t="">'black'</c-><c- p="">;</c->
       context<c- p="">.</c->fill<c- p="">();</c->
</strong>     <c- p="">}</c->
     context<c- p="">.</c->fillText<c- p="">(</c->element<c- p="">.</c->labels<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->textContent<c- p="">,</c-> x<c- o="">+</c-><c- mf="">5</c-><c- p="">,</c-> y<c- p="">);</c->
   <c- p="">}</c->
<strong>   context<c- p="">.</c->beginPath<c- p="">();</c->
   context<c- p="">.</c->rect<c- p="">(</c->x<c- o="">-</c-><c- mf="">7</c-><c- p="">,</c-> y<c- o="">-</c-><c- mf="">7</c-><c- p="">,</c-> <c- mf="">12</c-> <c- o="">+</c-> metrics<c- p="">.</c->width<c- o="">+</c-><c- mf="">2</c-><c- p="">,</c-> <c- mf="">14</c-><c- p="">);</c->
</strong>
   context<c- p="">.</c->drawFocusIfNeeded<c- p="">(</c->element<c- p="">);</c->
   context<c- p="">.</c->restore<c- p="">();</c->
 <c- p="">}</c->
 <c- a="">function</c-> drawBase<c- p="">()</c-> <c- p="">{</c-> <c- d="">/* ... */</c-> <c- p="">}</c->
 <c- a="">function</c-> drawAs<c- p="">()</c-> <c- p="">{</c-> <c- d="">/* ... */</c-> <c- p="">}</c->
 <c- a="">function</c-> drawBs<c- p="">()</c-> <c- p="">{</c-> <c- d="">/* ... */</c-> <c- p="">}</c->
 <c- a="">function</c-> redraw<c- p="">()</c-> <c- p="">{</c->
   <c- a="">var</c-> canvas <c- o="">=</c-> document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
   <c- a="">var</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">);</c->
   context<c- p="">.</c->clearRect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> canvas<c- p="">.</c->width<c- p="">,</c-> canvas<c- p="">.</c->height<c- p="">);</c->
   drawCheckbox<c- p="">(</c->context<c- p="">,</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showA'</c-><c- p="">),</c-> <c- mf="">20</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- kc="">true</c-><c- p="">);</c->
   drawCheckbox<c- p="">(</c->context<c- p="">,</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showB'</c-><c- p="">),</c-> <c- mf="">20</c-><c- p="">,</c-> <c- mf="">60</c-><c- p="">,</c-> <c- kc="">true</c-><c- p="">);</c->
   drawBase<c- p="">();</c->
   <c- k="">if</c-> <c- p="">(</c->document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showA'</c-><c- p="">).</c->checked<c- p="">)</c->
     drawAs<c- p="">();</c->
   <c- k="">if</c-> <c- p="">(</c->document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showB'</c-><c- p="">).</c->checked<c- p="">)</c->
     drawBs<c- p="">();</c->
 <c- p="">}</c->
 <c- a="">function</c-> processClick<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
   <c- a="">var</c-> canvas <c- o="">=</c-> document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
   <c- a="">var</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">);</c->
   <c- a="">var</c-> x <c- o="">=</c-> event<c- p="">.</c->clientX<c- p="">;</c->
   <c- a="">var</c-> y <c- o="">=</c-> event<c- p="">.</c->clientY<c- p="">;</c->
   <c- a="">var</c-> node <c- o="">=</c-> event<c- p="">.</c->target<c- p="">;</c->
   <c- k="">while</c-> <c- p="">(</c->node<c- p="">)</c-> <c- p="">{</c->
     x <c- o="">-=</c-> node<c- p="">.</c->offsetLeft <c- o="">-</c-> node<c- p="">.</c->scrollLeft<c- p="">;</c->
     y <c- o="">-=</c-> node<c- p="">.</c->offsetTop <c- o="">-</c-> node<c- p="">.</c->scrollTop<c- p="">;</c->
     node <c- o="">=</c-> node<c- p="">.</c->offsetParent<c- p="">;</c->
   <c- p="">}</c->
   drawCheckbox<c- p="">(</c->context<c- p="">,</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showA'</c-><c- p="">),</c-> <c- mf="">20</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->
   <c- k="">if</c-> <c- p="">(</c-><strong>context<c- p="">.</c->isPointInPath<c- p="">(</c->x<c- p="">,</c-> y<c- p="">)</c-></strong><c- p="">)</c->
     document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showA'</c-><c- p="">).</c->checked <c- o="">=</c-> <c- o="">!</c-><c- p="">(</c->document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showA'</c-><c- p="">).</c->checked<c- p="">);</c->
   drawCheckbox<c- p="">(</c->context<c- p="">,</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showB'</c-><c- p="">),</c-> <c- mf="">20</c-><c- p="">,</c-> <c- mf="">60</c-><c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->
   <c- k="">if</c-> <c- p="">(</c-><strong>context<c- p="">.</c->isPointInPath<c- p="">(</c->x<c- p="">,</c-> y<c- p="">)</c-></strong><c- p="">)</c->
     document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showB'</c-><c- p="">).</c->checked <c- o="">=</c-> <c- o="">!</c-><c- p="">(</c->document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'showB'</c-><c- p="">).</c->checked<c- p="">);</c->
   redraw<c- p="">();</c->
 <c- p="">}</c->
 document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">].</c->addEventListener<c- p="">(</c-><c- t="">'focus'</c-><c- p="">,</c-> redraw<c- p="">,</c-> <c- kc="">true</c-><c- p="">);</c->
 document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">].</c->addEventListener<c- p="">(</c-><c- t="">'blur'</c-><c- p="">,</c-> redraw<c- p="">,</c-> <c- kc="">true</c-><c- p="">);</c->
 document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">].</c->addEventListener<c- p="">(</c-><c- t="">'change'</c-><c- p="">,</c-> redraw<c- p="">,</c-> <c- kc="">true</c-><c- p="">);</c->
 document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">].</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> processClick<c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->
 redraw<c- p="">();</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>


  </div>

  <h6 id="drawing-focus-rings-and-scrolling-paths-into-view"><span class="secno">4.12.5.1.14</span> Drawing focus rings<a href="#drawing-focus-rings-and-scrolling-paths-into-view" class="self-link"></a></h6>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-drawfocusifneeded" id="dom-context-2d-drawfocusifneeded-dev">drawFocusIfNeeded</a>(<var>element</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawFocusIfNeeded" title="The CanvasRenderingContext2D.drawFocusIfNeeded() method of the Canvas 2D API draws a focus ring around the current or given path, if the specified element is focused.">CanvasRenderingContext2D/drawFocusIfNeeded</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>32+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>If <var>element</var> is <a href="#focused" id="drawing-focus-rings-and-scrolling-paths-into-view:focused">focused</a>, draws a focus ring around the <a href="#current-default-path" id="drawing-focus-rings-and-scrolling-paths-into-view:current-default-path">current
    default path</a>, following the platform conventions for focus rings.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-drawfocusifneeded-path-element" id="dom-context-2d-drawfocusifneeded-path-element-dev">drawFocusIfNeeded</a>(<var>path</var>, <var>element</var>)</code></dt><dd>
    <p>If <var>element</var> is <a href="#focused" id="drawing-focus-rings-and-scrolling-paths-into-view:focused-2">focused</a>, draws a focus ring around <var>path</var>,
    following the platform conventions for focus rings.</p>
   </dd></dl>

  

  <p>Objects that implement the <code id="drawing-focus-rings-and-scrolling-paths-into-view:canvasuserinterface"><a href="#canvasuserinterface">CanvasUserInterface</a></code> interface provide the following
  methods to draw focus rings.</p>

  <div data-algorithm="">
  <p id="dom-context-2d-drawosfocusring">The <dfn data-dfn-for="CanvasUserInterface" id="dom-context-2d-drawfocusifneeded" data-dfn-type="method"><code>drawFocusIfNeeded(<var>element</var>)</code></dfn>
  method steps are to <a href="#draw-focus-if-needed" id="drawing-focus-rings-and-scrolling-paths-into-view:draw-focus-if-needed">draw focus if needed</a> given <a id="drawing-focus-rings-and-scrolling-paths-into-view:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>,
  <var>element</var>, and <a id="drawing-focus-rings-and-scrolling-paths-into-view:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#current-default-path" id="drawing-focus-rings-and-scrolling-paths-into-view:current-default-path-2">current default path</a>.</p>
  </div>

  
  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasUserInterface" id="dom-context-2d-drawfocusifneeded-path-element" data-dfn-type="method"><code>drawFocusIfNeeded(<var>path</var>,
  <var>element</var>)</code></dfn> method steps are to <a href="#draw-focus-if-needed" id="drawing-focus-rings-and-scrolling-paths-into-view:draw-focus-if-needed-2">draw focus if needed</a> given
  <a id="drawing-focus-rings-and-scrolling-paths-into-view:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>element</var>, and <var>path</var>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="draw-focus-if-needed">draw focus if needed</dfn>, given an object implementing
  <code id="drawing-focus-rings-and-scrolling-paths-into-view:canvasuserinterface-2"><a href="#canvasuserinterface">CanvasUserInterface</a></code> <var>context</var>, an element <var>element</var>, and a <a href="#concept-path" id="drawing-focus-rings-and-scrolling-paths-into-view:concept-path">path</a> <var>path</var>:</p>

  <ol><li><p>If <var>element</var> is not <a href="#focused" id="drawing-focus-rings-and-scrolling-paths-into-view:focused-3">focused</a> or is not a descendant of
   <var>context</var>'s <code id="drawing-focus-rings-and-scrolling-paths-into-view:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element, then return.</p></li><li>
    <p>Draw a focus ring of the appropriate style along <var>path</var>, following platform
    conventions.</p>

    <p class="note">Some platforms only draw focus rings around elements that have been focused from
    the keyboard, and not those focused from the mouse. Other platforms simply don't draw focus
    rings around some elements at all unless relevant accessibility features are enabled. This API
    is intended to follow these conventions. User agents that implement distinctions based on the
    manner in which the element was focused are encouraged to classify focus driven by the <code id="drawing-focus-rings-and-scrolling-paths-into-view:dom-focus"><a href="#dom-focus">focus()</a></code> method based on the kind of user interaction event from which
    the call was triggered (if any).</p>

    <p>The focus ring should not be subject to the <a href="#shadows" id="drawing-focus-rings-and-scrolling-paths-into-view:shadows">shadow effects</a>,
    the <a href="#concept-canvas-global-alpha" id="drawing-focus-rings-and-scrolling-paths-into-view:concept-canvas-global-alpha">global alpha</a>, the <a href="#current-compositing-and-blending-operator" id="drawing-focus-rings-and-scrolling-paths-into-view:current-compositing-and-blending-operator">current
    compositing and blending operator</a>, the <a href="#concept-canvasfillstrokestyles-fill-style" id="drawing-focus-rings-and-scrolling-paths-into-view:concept-canvasfillstrokestyles-fill-style">fill style</a>, the <a href="#concept-canvasfillstrokestyles-stroke-style" id="drawing-focus-rings-and-scrolling-paths-into-view:concept-canvasfillstrokestyles-stroke-style">stroke style</a>, or any of the members
    in the <code id="drawing-focus-rings-and-scrolling-paths-into-view:canvaspathdrawingstyles"><a href="#canvaspathdrawingstyles">CanvasPathDrawingStyles</a></code>, <code id="drawing-focus-rings-and-scrolling-paths-into-view:canvastextdrawingstyles"><a href="#canvastextdrawingstyles">CanvasTextDrawingStyles</a></code> interfaces,
    but <em>should</em> be subject to the <a href="#clipping-region" id="drawing-focus-rings-and-scrolling-paths-into-view:clipping-region">clipping region</a>. (The effect of
    transformations is described above and varies based on which path is being used.)</p>
   </li><li><p><a href="#inform">Inform the user</a> that the focus is at the location given by the
   intended path. User agents may wait until the next time the <a href="#event-loop" id="drawing-focus-rings-and-scrolling-paths-into-view:event-loop">event loop</a> reaches its
   <a href="#update-the-rendering" id="drawing-focus-rings-and-scrolling-paths-into-view:update-the-rendering">update the rendering</a> step to optionally inform the user.</p></li></ol>
  </div>

  <p>User agents should not implicitly close open subpaths in the intended path when drawing the
  focus ring.</p>

  <p class="note">This might be a moot point, however. For example, if the focus ring is drawn as an
  axis-aligned bounding rectangle around the points in the intended path, then whether the subpaths
  are closed or not has no effect. This specification intentionally does not specify precisely how
  focus rings are to be drawn: user agents are expected to honor their platform's native
  conventions.</p>

  <p id="inform">"Inform the user", as used in this section, does not imply any persistent state
  change. It could mean, for instance, calling a system accessibility API to notify assistive
  technologies such as magnification tools so that the user's magnifier moves to the given area of
  the canvas. However, it does not associate the path with the element, or provide a region for
  tactile feedback, etc.</p>

  

  <h6 id="drawing-images"><span class="secno">4.12.5.1.15</span> Drawing images<a href="#drawing-images" class="self-link"></a></h6>

  <p>Objects that implement the <code id="drawing-images:canvasdrawimage"><a href="#canvasdrawimage">CanvasDrawImage</a></code> interface have the <dfn data-dfn-for="CanvasDrawImage" id="dom-context-2d-drawimage" data-dfn-type="method"><code>drawImage()</code></dfn> method to
  draw images.</p>

  

  <p>This method can be invoked with three different sets of arguments:</p>

  <ul data-var-scope="" class="brief"><li><code>drawImage(<var>image</var>, <var>dx</var>, <var>dy</var>)</code>
   </li><li><code>drawImage(<var>image</var>, <var>dx</var>, <var>dy</var>, <var>dw</var>, <var>dh</var>)</code>
   </li><li><code>drawImage(<var>image</var>, <var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var>, <var>dx</var>, <var>dy</var>, <var>dw</var>, <var>dh</var>)</code>
  </li></ul>

  

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-drawimage" id="dom-context-2d-drawimage-dev">drawImage</a>(<var>image</var>, <var>dx</var>, <var>dy</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage" title="The CanvasRenderingContext2D.drawImage() method of the Canvas 2D API provides different ways to draw an image onto the canvas.">CanvasRenderingContext2D/drawImage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dt><code><var>context</var>.<a href="#dom-context-2d-drawimage" id="drawing-images:dom-context-2d-drawimage">drawImage</a>(<var>image</var>, <var>dx</var>, <var>dy</var>, <var>dw</var>, <var>dh</var>)</code></dt><dt><code><var>context</var>.<a href="#dom-context-2d-drawimage" id="drawing-images:dom-context-2d-drawimage-2">drawImage</a>(<var>image</var>, <var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var>, <var>dx</var>, <var>dy</var>, <var>dw</var>, <var>dh</var>)</code></dt><dd>
    <p>Draws the given image onto the canvas. The arguments are interpreted as follows:</p>

    <p><img src="/images/drawImage.png" width="356" alt="The sx and sy parameters give
    the x and y coordinates of the source rectangle; the sw and sh arguments give the width and
    height of the source rectangle; the dx and dy give the x and y coordinates of the destination
    rectangle; and the dw and dh arguments give the width and height of the destination
    rectangle." height="356"></p>

    <p>If the image isn't yet fully decoded, then nothing is drawn. If the image is a canvas with no
    data, throws an <a id="drawing-images:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="drawing-images:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>When the <code id="drawing-images:dom-context-2d-drawimage-3"><a href="#dom-context-2d-drawimage">drawImage()</a></code> method is invoked, the user
  agent must run these steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.</p></li><li><p>Let <var>usability</var> be the result of <a href="#check-the-usability-of-the-image-argument" id="drawing-images:check-the-usability-of-the-image-argument">checking the usability of <var>image</var></a>.</p></li><li><p>If <var>usability</var> is <i>bad</i>, then return (without drawing anything).</p></li><li>
    <p>Establish the source and destination rectangles as follows:</p>

    <p>If not specified, the <var>dw</var> and <var>dh</var> arguments must default to the values of
    <var>sw</var> and <var>sh</var>, interpreted such that one <a href="https://drafts.csswg.org/css-values/#px" id="drawing-images:'px'" data-x-internal="'px'">CSS pixel</a>
    in the image is treated as one unit in the <a href="#output-bitmap" id="drawing-images:output-bitmap">output bitmap</a>'s coordinate space. If the
    <var>sx</var>, <var>sy</var>, <var>sw</var>, and <var>sh</var> arguments are omitted, then they
    must default to 0, 0, the image's <a id="drawing-images:natural-width" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> in image pixels, and the image's
    <a id="drawing-images:natural-height" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a> in image pixels, respectively. If the image has no <a id="drawing-images:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural
    dimensions</a>, then the <i>concrete object size</i> must be used instead, as determined
    using the CSS "<a href="https://drafts.csswg.org/css-images/#default-sizing">Concrete Object
    Size Resolution</a>" algorithm, with the <i>specified size</i> having neither a definite width
    nor height, nor any additional constraints, the object's natural properties being those of the
    <var>image</var> argument, and the <a id="drawing-images:default-object-size" href="https://drafts.csswg.org/css-images/#default-object-size" data-x-internal="default-object-size">default object size</a> being the size of the
    <a href="#output-bitmap" id="drawing-images:output-bitmap-2">output bitmap</a>. <a href="#refsCSSIMAGES">[CSSIMAGES]</a></p>

    <p>The source rectangle is the rectangle whose corners are the four points (<var>sx</var>, <var>sy</var>), (<var>sx</var>+<var>sw</var>, <var>sy</var>), (<var>sx</var>+<var>sw</var>, <var>sy</var>+<var>sh</var>),
    (<var>sx</var>, <var>sy</var>+<var>sh</var>).</p>

    <p>The destination rectangle is the rectangle whose corners are the four points (<var>dx</var>, <var>dy</var>), (<var>dx</var>+<var>dw</var>, <var>dy</var>), (<var>dx</var>+<var>dw</var>, <var>dy</var>+<var>dh</var>),
    (<var>dx</var>, <var>dy</var>+<var>dh</var>).</p>

    <p>When the source rectangle is outside the source image, the source rectangle must be clipped
    to the source image and the destination rectangle must be clipped in the same proportion.</p>

    <p class="note">When the destination rectangle is outside the destination image (the
    <a href="#output-bitmap" id="drawing-images:output-bitmap-3">output bitmap</a>), the pixels that land outside the <a href="#output-bitmap" id="drawing-images:output-bitmap-4">output bitmap</a> are
    discarded, as if the destination was an infinite canvas whose rendering was clipped to the
    dimensions of the <a href="#output-bitmap" id="drawing-images:output-bitmap-5">output bitmap</a>.</p>
   </li><li><p>If one of the <var>sw</var> or <var>sh</var> arguments is zero, then return. Nothing is
   painted.</p></li><li>
    <p>Paint the region of the <var>image</var> argument specified by the source rectangle
    on the region of the rendering context's <a href="#output-bitmap" id="drawing-images:output-bitmap-6">output bitmap</a> specified by the
    destination rectangle, after applying the <a href="#transformations" id="drawing-images:transformations">current
    transformation matrix</a> to the destination rectangle.</p>

    <p>The image data must be processed in the original direction, even if the dimensions given are
    negative. </p>

    <p>When scaling up, if the <code id="drawing-images:dom-context-2d-imagesmoothingenabled"><a href="#dom-context-2d-imagesmoothingenabled">imageSmoothingEnabled</a></code> attribute is set to
    true, the user agent should attempt to apply a smoothing algorithm to the image data when it is
    scaled. User agents which support multiple filtering algorithms may use the value of the <code id="drawing-images:dom-context-2d-imagesmoothingquality"><a href="#dom-context-2d-imagesmoothingquality">imageSmoothingQuality</a></code> attribute to guide
    the choice of filtering algorithm when the <code id="drawing-images:dom-context-2d-imagesmoothingenabled-2"><a href="#dom-context-2d-imagesmoothingenabled">imageSmoothingEnabled</a></code> attribute is set to
    true. Otherwise, the image must be rendered using nearest-neighbor interpolation.</p>

    <p class="note">This specification does not define the precise algorithm to use when scaling an
    image down, or when scaling an image up when the <code id="drawing-images:dom-context-2d-imagesmoothingenabled-3"><a href="#dom-context-2d-imagesmoothingenabled">imageSmoothingEnabled</a></code> attribute is set to
    true.</p>

    <p class="note">When a <code id="drawing-images:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element is drawn onto itself, the <a href="#drawing-model" id="drawing-images:drawing-model">drawing
    model</a> requires the source to be copied before the image is drawn, so it is possible to
    copy parts of a <code id="drawing-images:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> element onto overlapping parts of itself.</p>

    <p>If the original image data is a bitmap image, then the value painted at a point in the
    destination rectangle is computed by filtering the original image data. The user agent may use
    any filtering algorithm (for example bilinear interpolation or nearest-neighbor). When the
    filtering algorithm requires a pixel value from outside the original image data, it must instead
    use the value from the nearest edge pixel. (That is, the filter uses 'clamp-to-edge' behavior.)
    When the filtering algorithm requires a pixel value from outside the source rectangle but inside
    the original image data, then the value from the original image data must be used.</p>
    
    

    <p class="note">Thus, scaling an image in parts or in whole will have the same effect. This does
    mean that when sprites coming from a single sprite sheet are to be scaled, adjacent images in
    the sprite sheet can interfere. This can be avoided by ensuring each sprite in the sheet is
    surrounded by a border of <a id="drawing-images:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>, or by copying sprites to be scaled
    into temporary <code id="drawing-images:the-canvas-element-3"><a href="#the-canvas-element">canvas</a></code> elements and drawing the scaled sprites from there.</p>

    <p>Images are painted without affecting the current path, and are subject to <a href="#shadows" id="drawing-images:shadows">shadow effects</a>, <a href="#concept-canvas-global-alpha" id="drawing-images:concept-canvas-global-alpha">global
    alpha</a>, the <a href="#clipping-region" id="drawing-images:clipping-region">clipping region</a>, and the <a href="#current-compositing-and-blending-operator" id="drawing-images:current-compositing-and-blending-operator">current compositing and blending
    operator</a>.</p>
   </li><li><p>If <var>image</var> <a href="#the-image-argument-is-not-origin-clean" id="drawing-images:the-image-argument-is-not-origin-clean">is not origin-clean</a>, then set the
   <code id="drawing-images:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code>'s <a href="#concept-canvas-origin-clean" id="drawing-images:concept-canvas-origin-clean">origin-clean</a> flag to false.</p></li></ol>
  </div>

  


  <h6 id="pixel-manipulation"><span class="secno">4.12.5.1.16</span> <dfn>Pixel manipulation</dfn><a href="#pixel-manipulation" class="self-link"></a></h6>

  <dl class="domintro"><dt><code><var>imageData</var> = <var>context</var>.<a href="#dom-context-2d-createimagedata-imagedata" id="dom-context-2d-createimagedata-imagedata-dev">createImageData</a>(<var>imageData</var>)</code></dt><dd><p>Returns an <code id="pixel-manipulation:imagedata"><a href="#imagedata">ImageData</a></code> object with the same dimensions and color space as the
   argument. All the pixels in the returned object are <a id="pixel-manipulation:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>.</p></dd><dt><code><var>imageData</var> = <var>context</var>.<a href="#dom-context-2d-createimagedata" id="dom-context-2d-createimagedata-dev">createImageData</a>(<var>sw</var>, <var>sh</var> [, <var>settings</var>])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createImageData" title="The CanvasRenderingContext2D.createImageData() method of the Canvas 2D API creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are transparent black.">CanvasRenderingContext2D/createImageData</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="pixel-manipulation:imagedata-2"><a href="#imagedata">ImageData</a></code> object with the given dimensions. The color space of the
    returned object is the <a href="#concept-canvas-color-space" id="pixel-manipulation:concept-canvas-color-space">color space</a> of
    <var>context</var> unless overridden by <var>settings</var>. All the pixels in the returned
    object are <a id="pixel-manipulation:transparent-black-2" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>.</p>

    <p>Throws an <a id="pixel-manipulation:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="pixel-manipulation:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if either of
    the width or height arguments are zero.</p>
   </dd><dt><code><var>imageData</var> = <var>context</var>.<a href="#dom-context-2d-getimagedata" id="dom-context-2d-getimagedata-dev">getImageData</a>(<var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var> [, <var>settings</var>])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData" title="The CanvasRenderingContext2D method getImageData() of the Canvas 2D API returns an ImageData object representing the underlying pixel data for a specified portion of the canvas.">CanvasRenderingContext2D/getImageData</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>9.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="pixel-manipulation:imagedata-3"><a href="#imagedata">ImageData</a></code> object containing the image data for the given rectangle of
    the bitmap. The color space of the returned object is the <a href="#concept-canvas-color-space" id="pixel-manipulation:concept-canvas-color-space-2">color space</a> of <var>context</var> unless overridden
    by <var>settings</var>.</p>

    <p>Throws an <a id="pixel-manipulation:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="pixel-manipulation:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the either
    of the width or height arguments are zero.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-putimagedata" id="dom-context-2d-putimagedata-dev">putImageData</a>(<var>imageData</var>, <var>dx</var>, <var>dy</var> [, <var>dirtyX</var>, <var>dirtyY</var>, <var>dirtyWidth</var>, <var>dirtyHeight</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/putImageData" title="The CanvasRenderingContext2D.putImageData() method of the Canvas 2D API paints data from the given ImageData object onto the canvas. If a dirty rectangle is provided, only the pixels from that rectangle are painted. This method is not affected by the canvas transformation matrix.">CanvasRenderingContext2D/putImageData</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Paints the data from the given <code id="pixel-manipulation:imagedata-4"><a href="#imagedata">ImageData</a></code> object onto the bitmap. If a dirty
    rectangle is provided, only the pixels from that rectangle are painted.</p>

    <p>The <code id="pixel-manipulation:dom-context-2d-globalalpha"><a href="#dom-context-2d-globalalpha">globalAlpha</a></code> and <code id="pixel-manipulation:dom-context-2d-globalcompositeoperation"><a href="#dom-context-2d-globalcompositeoperation">globalCompositeOperation</a></code> properties, as
    well as the <a href="#shadows" id="pixel-manipulation:shadows">shadow attributes</a>, are ignored for the purposes of
    this method call; pixels in the canvas are replaced wholesale, with no composition, alpha
    blending, no shadows, etc.</p>

    <p>Throws an <a id="pixel-manipulation:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="pixel-manipulation:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    <var>imageData</var> object's <code id="pixel-manipulation:dom-imagedata-data"><a href="#dom-imagedata-data">data</a></code> attribute value's
    [[ViewedArrayBuffer]] internal slot is detached.</p>
   </dd></dl>

  

  <p>Objects that implement the <code id="pixel-manipulation:canvasimagedata"><a href="#canvasimagedata">CanvasImageData</a></code> interface provide the following methods
  for reading and writing pixel data to the bitmap.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasImageData" id="dom-context-2d-createimagedata" data-dfn-type="method"><code>createImageData(<var>sw</var>, <var>sh</var>,
  <var>settings</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If one or both of <var>sw</var> and <var>sh</var> are zero, then throw an
   <a id="pixel-manipulation:indexsizeerror-3" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="pixel-manipulation:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>newImageData</var> be a <a id="pixel-manipulation:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="pixel-manipulation:imagedata-5"><a href="#imagedata">ImageData</a></code> object.</p></li><li><p><a href="#initialize-an-imagedata-object" id="pixel-manipulation:initialize-an-imagedata-object">Initialize</a> <var>newImageData</var>
   given the absolute magnitude of <var>sw</var>, the absolute magnitude of <var>sh</var>,
   <var>settings</var>, and <i><a href="#initialize-imagedata-defaultcolorspace" id="pixel-manipulation:initialize-imagedata-defaultcolorspace">
   defaultColorSpace</a></i> set to <a id="pixel-manipulation:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a href="#concept-canvas-color-space" id="pixel-manipulation:concept-canvas-color-space-3">color space</a>.</p></li><li><p>Initialize the image data of <var>newImageData</var> to <a id="pixel-manipulation:transparent-black-3" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent
   black</a>.</p></li><li><p>Return <var>newImageData</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasImageData" id="dom-context-2d-createimagedata-imagedata" data-dfn-type="method"><code>createImageData(<var>imageData</var>)</code></dfn>
  method steps are:</p>

  <ol><li><p>Let <var>newImageData</var> be a <a id="pixel-manipulation:new-2" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="pixel-manipulation:imagedata-6"><a href="#imagedata">ImageData</a></code> object.</p></li><li><p>Let <var>settings</var> be the <code id="pixel-manipulation:imagedatasettings"><a href="#imagedatasettings">ImageDataSettings</a></code> object «[
   "<code id="pixel-manipulation:dom-imagedatasettings-colorspace"><a href="#dom-imagedatasettings-colorspace">colorSpace</a></code>" →
   <a id="pixel-manipulation:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#dom-imagedata-colorspace" id="pixel-manipulation:dom-imagedata-colorspace">colorSpace</a>,
   "<code id="pixel-manipulation:dom-imagedatasettings-pixelformat"><a href="#dom-imagedatasettings-pixelformat">pixelFormat</a></code>" →
   <a id="pixel-manipulation:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#dom-imagedata-pixelformat" id="pixel-manipulation:dom-imagedata-pixelformat">pixelFormat</a> ]».</p></li><li><p><a href="#initialize-an-imagedata-object" id="pixel-manipulation:initialize-an-imagedata-object-2">Initialize</a> <var>newImageData</var>
   given the value of <var>imageData</var>'s <code id="pixel-manipulation:dom-imagedata-width"><a href="#dom-imagedata-width">width</a></code>
   attribute, the value of <var>imageData</var>'s <code id="pixel-manipulation:dom-imagedata-height"><a href="#dom-imagedata-height">height</a></code>
   attribute, and <var>settings</var>.</p></li><li><p>Initialize the image data of <var>newImageData</var> to <a id="pixel-manipulation:transparent-black-4" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent
   black</a>.</p></li><li><p>Return <var>newImageData</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasImageData" id="dom-context-2d-getimagedata" data-dfn-type="method"><code>getImageData(<var>sx</var>, <var>sy</var>, <var>sw</var>,
  <var>sh</var>, <var>settings</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If either the <var>sw</var> or <var>sh</var> arguments are zero, then throw an
   <a id="pixel-manipulation:indexsizeerror-4" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="pixel-manipulation:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the <code id="pixel-manipulation:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code>'s <a href="#concept-canvas-origin-clean" id="pixel-manipulation:concept-canvas-origin-clean">origin-clean</a> flag is set to false, then throw a
   <a id="pixel-manipulation:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="pixel-manipulation:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>imageData</var> be a <a id="pixel-manipulation:new-3" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="pixel-manipulation:imagedata-7"><a href="#imagedata">ImageData</a></code> object.</p></li><li><p><a href="#initialize-an-imagedata-object" id="pixel-manipulation:initialize-an-imagedata-object-3">Initialize</a> <var>imageData</var> given
   <var>sw</var>, <var>sh</var>, <var>settings</var>, and
   <i><a href="#initialize-imagedata-defaultcolorspace" id="pixel-manipulation:initialize-imagedata-defaultcolorspace-2">defaultColorSpace</a></i> set to
   <a id="pixel-manipulation:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-color-space" id="pixel-manipulation:concept-canvas-color-space-4">color space</a>.</p></li><li><p>Let the source rectangle be the rectangle whose corners are the four points
   (<var>sx</var>, <var>sy</var>), (<span><var>sx</var>+<var>sw</var></span>,
   <var>sy</var>), (<span><var>sx</var>+<var>sw</var></span>, <span><var>sy</var>+<var>sh</var></span>), (<var>sx</var>,
   <var>sy</var>+<var>sh</var>).</p></li><li><p>Set the pixel values of <var>imageData</var> to be the pixels of <a id="pixel-manipulation:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a href="#output-bitmap" id="pixel-manipulation:output-bitmap">output bitmap</a> in the area specified by the source rectangle in the bitmap's
   coordinate space units, converted from <a id="pixel-manipulation:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-color-space" id="pixel-manipulation:concept-canvas-color-space-5">color space</a> to <var>imageData</var>'s <code id="pixel-manipulation:dom-imagedata-colorspace-2"><a href="#dom-imagedata-colorspace">colorSpace</a></code> using <a id="pixel-manipulation:'relative-colorimetric'" href="https://drafts.csswg.org/css-color-5/#valdef-color-profile-rendering-intent-relative-colorimetric" data-x-internal="'relative-colorimetric'">'relative-colorimetric'</a>
   rendering intent.</p></li><li><p>Set the pixels values of <var>imageData</var> for areas of the source rectangle that are
   outside of the <a href="#output-bitmap" id="pixel-manipulation:output-bitmap-2">output bitmap</a> to <a id="pixel-manipulation:transparent-black-5" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>.</p></li><li><p>Return <var>imageData</var>.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasImageData" id="dom-context-2d-putimagedata-short" data-dfn-type="method"><code>putImageData(<var>imageData</var>,
  <var>dx</var>, <var>dy</var>)</code></dfn> method steps are to
  <a href="#dom-context2d-putimagedata-common" id="pixel-manipulation:dom-context2d-putimagedata-common">put pixels from an
  <code>ImageData</code> onto a bitmap</a>, given
  <var>imageData</var>, <a id="pixel-manipulation:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#output-bitmap" id="pixel-manipulation:output-bitmap-3">output bitmap</a>,
  <var>dx</var>, <var>dy</var>, 0, 0,
  <var>imageData</var>'s <code id="pixel-manipulation:dom-imagedata-width-2"><a href="#dom-imagedata-width">width</a></code>, and
  <var>imageData</var>'s <code id="pixel-manipulation:dom-imagedata-height-2"><a href="#dom-imagedata-height">height</a></code>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasImageData" id="dom-context-2d-putimagedata" data-dfn-type="method"><code>putImageData(<var>imageData</var>,
  <var>dx</var>, <var>dy</var>, <var>dirtyX</var>, <var>dirtyY</var>,
  <var>dirtyWidth</var>, <var>dirtyHeight</var>)</code></dfn> method steps are to
  <a href="#dom-context2d-putimagedata-common" id="pixel-manipulation:dom-context2d-putimagedata-common-2">put pixels from an
  <code>ImageData</code> onto a bitmap</a>, given
  <var>imageData</var>, <a id="pixel-manipulation:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#output-bitmap" id="pixel-manipulation:output-bitmap-4">output bitmap</a>,
  <var>dx</var>, <var>dy</var>, <var>dirtyX</var>, <var>dirtyY</var>,
  <var>dirtyWidth</var>, and <var>dirtyHeight</var>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="dom-context2d-putimagedata-common">put pixels from an <code>ImageData</code>
  onto a bitmap</dfn>, given an <code id="pixel-manipulation:imagedata-8"><a href="#imagedata">ImageData</a></code> <var>imageData</var>,
  an <a href="#output-bitmap" id="pixel-manipulation:output-bitmap-5">output bitmap</a> <var>bitmap</var>, and numbers <var>dx</var>, <var>dy</var>,
  <var>dirtyX</var>, <var>dirtyY</var>, <var>dirtyWidth</var>, and <var>dirtyHeight</var>:</p>

  <ol><li><p>Let <var>buffer</var> be <var>imageData</var>'s <code id="pixel-manipulation:dom-imagedata-data-2"><a href="#dom-imagedata-data">data</a></code> attribute value's [[ViewedArrayBuffer]] internal
   slot.</p></li><li><p>If <a id="pixel-manipulation:isdetachedbuffer" href="https://tc39.es/ecma262/#sec-isdetachedbuffer" data-x-internal="isdetachedbuffer">IsDetachedBuffer</a>(<var>buffer</var>) is true, then throw an
   <a id="pixel-manipulation:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="pixel-manipulation:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p>If <var>dirtyWidth</var> is negative, then let <var>dirtyX</var> be <span><var>dirtyX</var>+<var>dirtyWidth</var></span>, and let <var>dirtyWidth</var> be equal
    to the absolute magnitude of <var>dirtyWidth</var>.</p>

    <p>If <var>dirtyHeight</var> is negative, then let <var>dirtyY</var> be <span><var>dirtyY</var>+<var>dirtyHeight</var></span>, and let <var>dirtyHeight</var> be
    equal to the absolute magnitude of <var>dirtyHeight</var>.</p>
   </li><li>
    <p>If <var>dirtyX</var> is negative, then let <var>dirtyWidth</var> be <span><var>dirtyWidth</var>+<var>dirtyX</var></span>, and let <var>dirtyX</var> be 0.</p>

    <p>If <var>dirtyY</var> is negative, then let <var>dirtyHeight</var> be <span><var>dirtyHeight</var>+<var>dirtyY</var></span>, and let <var>dirtyY</var> be 0.</p>
   </li><li>
    <p>If <var>dirtyX</var>+<var>dirtyWidth</var> is greater than the <code id="pixel-manipulation:dom-imagedata-width-3"><a href="#dom-imagedata-width">width</a></code> attribute of the <var>imageData</var> argument, then
    let <var>dirtyWidth</var> be the value of that <code id="pixel-manipulation:dom-imagedata-width-4"><a href="#dom-imagedata-width">width</a></code>
    attribute, minus the value of <var>dirtyX</var>.</p>

    <p>If <var>dirtyY</var>+<var>dirtyHeight</var> is greater than the <code id="pixel-manipulation:dom-imagedata-height-3"><a href="#dom-imagedata-height">height</a></code> attribute of the <var>imageData</var> argument, then
    let <var>dirtyHeight</var> be the value of that <code id="pixel-manipulation:dom-imagedata-height-4"><a href="#dom-imagedata-height">height</a></code> attribute, minus the value of <var>dirtyY</var>.</p>
   </li><li>
    <p>If, after those changes, either <var>dirtyWidth</var> or <var>dirtyHeight</var> are negative
    or zero, then return without affecting any bitmaps.</p>
   </li><li><p>For all integer values of <var>x</var> and <var>y</var> where <span><var>dirtyX</var>&nbsp;≤&nbsp;<var>x</var>&nbsp;&lt;&nbsp;<span><var>dirtyX</var>+<var>dirtyWidth</var></span></span> and <span><var>dirtyY</var>&nbsp;≤&nbsp;<var>y</var>&nbsp;&lt;&nbsp;<span><var>dirtyY</var>+<var>dirtyHeight</var></span></span>,
   set the pixel with coordinate (<span><var>dx</var>+<var>x</var></span>,
   <var>dy</var>+<var>y</var>) in <var>bitmap</var> to the color of the pixel at coordinate
   (<var>x</var>, <var>y</var>) in the <var>imageData</var> data structure's
   <a href="#concept-imagedata-bitmap-representation" id="pixel-manipulation:concept-imagedata-bitmap-representation">bitmap</a>,
   converted from <var>imageData</var>'s <code id="pixel-manipulation:dom-imagedata-colorspace-3"><a href="#dom-imagedata-colorspace">colorSpace</a></code>
   to the <a href="#concept-canvas-color-space" id="pixel-manipulation:concept-canvas-color-space-6">color space</a> of <var>bitmap</var>
   using <a id="pixel-manipulation:'relative-colorimetric'-2" href="https://drafts.csswg.org/css-color-5/#valdef-color-profile-rendering-intent-relative-colorimetric" data-x-internal="'relative-colorimetric'">'relative-colorimetric'</a> rendering intent.</p></li></ol>
  </div>

  <p class="note">Due to the lossy nature of converting between color spaces and converting to and
  from <a href="#concept-premultiplied-alpha" id="pixel-manipulation:concept-premultiplied-alpha">premultiplied alpha</a> color values, pixels
  that have just been set using <code id="pixel-manipulation:dom-context-2d-putimagedata"><a href="#dom-context-2d-putimagedata">putImageData()</a></code>,
  and are not completely opaque, might be returned to an equivalent <code id="pixel-manipulation:dom-context-2d-getimagedata"><a href="#dom-context-2d-getimagedata">getImageData()</a></code> as different values.</p>

  <p>The current path, <a href="#transformations" id="pixel-manipulation:transformations">transformation matrix</a>,
  <a href="#shadows" id="pixel-manipulation:shadows-2">shadow attributes</a>, <a href="#concept-canvas-global-alpha" id="pixel-manipulation:concept-canvas-global-alpha">global
  alpha</a>, the <a href="#clipping-region" id="pixel-manipulation:clipping-region">clipping region</a>, and <a href="#current-compositing-and-blending-operator" id="pixel-manipulation:current-compositing-and-blending-operator">current compositing and blending
  operator</a> must not affect the methods described in this section.</p>

  

  <div class="example">
   <p>In the following example, the script generates an <code id="pixel-manipulation:imagedata-9"><a href="#imagedata">ImageData</a></code> object so that it can
   draw onto it.</p>

   <pre><code class="js"><c- c1="">// canvas is a reference to a &lt;canvas&gt; element</c->
<c- a="">var</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">);</c->

<c- c1="">// create a blank slate</c->
<c- a="">var</c-> data <c- o="">=</c-> context<c- p="">.</c->createImageData<c- p="">(</c->canvas<c- p="">.</c->width<c- p="">,</c-> canvas<c- p="">.</c->height<c- p="">);</c->

<c- c1="">// create some plasma</c->
FillPlasma<c- p="">(</c->data<c- p="">,</c-> <c- t="">'green'</c-><c- p="">);</c-> <c- c1="">// green plasma</c->

<c- c1="">// add a cloud to the plasma</c->
AddCloud<c- p="">(</c->data<c- p="">,</c-> data<c- p="">.</c->width<c- o="">/</c-><c- mf="">2</c-><c- p="">,</c-> data<c- p="">.</c->height<c- o="">/</c-><c- mf="">2</c-><c- p="">);</c-> <c- c1="">// put a cloud in the middle</c->

<c- c1="">// paint the plasma+cloud on the canvas</c->
context<c- p="">.</c->putImageData<c- p="">(</c->data<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->

<c- c1="">// support methods</c->
<c- a="">function</c-> FillPlasma<c- p="">(</c->data<c- p="">,</c-> color<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c->
<c- a="">function</c-> AddCloud<c- p="">(</c->data<c- p="">,</c-> x<c- p="">,</c-> y<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c-></code></pre>
  </div>

  <div class="example">
   <p>Here is an example of using <code id="pixel-manipulation:dom-context-2d-getimagedata-2"><a href="#dom-context-2d-getimagedata">getImageData()</a></code> and <code id="pixel-manipulation:dom-context-2d-putimagedata-2"><a href="#dom-context-2d-putimagedata">putImageData()</a></code> to implement an edge detection
   filter.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Edge detection demo<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">var</c-> image <c- o="">=</c-> <c- k="">new</c-> Image<c- p="">();</c->
   <c- a="">function</c-> init<c- p="">()</c-> <c- p="">{</c->
     image<c- p="">.</c->onload <c- o="">=</c-> demo<c- p="">;</c->
     image<c- p="">.</c->src <c- o="">=</c-> <c- u="">"image.jpeg"</c-><c- p="">;</c->
   <c- p="">}</c->
   <c- a="">function</c-> demo<c- p="">()</c-> <c- p="">{</c->
     <c- a="">var</c-> canvas <c- o="">=</c-> document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
     <c- a="">var</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">);</c->

     <c- c1="">// draw the image onto the canvas</c->
     context<c- p="">.</c->drawImage<c- p="">(</c->image<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->

     <c- c1="">// get the image data to manipulate</c->
     <c- a="">var</c-> input <c- o="">=</c-> context<c- p="">.</c->getImageData<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> canvas<c- p="">.</c->width<c- p="">,</c-> canvas<c- p="">.</c->height<c- p="">);</c->

     <c- c1="">// get an empty slate to put the data into</c->
     <c- a="">var</c-> output <c- o="">=</c-> context<c- p="">.</c->createImageData<c- p="">(</c->canvas<c- p="">.</c->width<c- p="">,</c-> canvas<c- p="">.</c->height<c- p="">);</c->

     <c- c1="">// alias some variables for convenience</c->
     <c- c1="">// In this case input.width and input.height</c->
     <c- c1="">// match canvas.width and canvas.height</c->
     <c- c1="">// but we'll use the former to keep the code generic.</c->
     <c- a="">var</c-> w <c- o="">=</c-> input<c- p="">.</c->width<c- p="">,</c-> h <c- o="">=</c-> input<c- p="">.</c->height<c- p="">;</c->
     <c- a="">var</c-> inputData <c- o="">=</c-> input<c- p="">.</c->data<c- p="">;</c->
     <c- a="">var</c-> outputData <c- o="">=</c-> output<c- p="">.</c->data<c- p="">;</c->

     <c- c1="">// edge detection</c->
     <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> y <c- o="">=</c-> <c- mf="">1</c-><c- p="">;</c-> y <c- o="">&lt;</c-> h<c- o="">-</c-><c- mf="">1</c-><c- p="">;</c-> y <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
       <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> x <c- o="">=</c-> <c- mf="">1</c-><c- p="">;</c-> x <c- o="">&lt;</c-> w<c- o="">-</c-><c- mf="">1</c-><c- p="">;</c-> x <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
         <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> c <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> c <c- o="">&lt;</c-> <c- mf="">3</c-><c- p="">;</c-> c <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
           <c- a="">var</c-> i <c- o="">=</c-> <c- p="">(</c->y<c- o="">*</c->w <c- o="">+</c-> x<c- p="">)</c-><c- o="">*</c-><c- mf="">4</c-> <c- o="">+</c-> c<c- p="">;</c->
           outputData<c- p="">[</c->i<c- p="">]</c-> <c- o="">=</c-> <c- mf="">127</c-> <c- o="">+</c-> <c- o="">-</c->inputData<c- p="">[</c->i <c- o="">-</c-> w<c- o="">*</c-><c- mf="">4</c-> <c- o="">-</c-> <c- mf="">4</c-><c- p="">]</c-> <c- o="">-</c->   inputData<c- p="">[</c->i <c- o="">-</c-> w<c- o="">*</c-><c- mf="">4</c-><c- p="">]</c-> <c- o="">-</c-> inputData<c- p="">[</c->i <c- o="">-</c-> w<c- o="">*</c-><c- mf="">4</c-> <c- o="">+</c-> <c- mf="">4</c-><c- p="">]</c-> <c- o="">+</c->
                                 <c- o="">-</c->inputData<c- p="">[</c->i <c- o="">-</c-> <c- mf="">4</c-><c- p="">]</c->       <c- o="">+</c-> <c- mf="">8</c-><c- o="">*</c->inputData<c- p="">[</c->i<c- p="">]</c->       <c- o="">-</c-> inputData<c- p="">[</c->i <c- o="">+</c-> <c- mf="">4</c-><c- p="">]</c-> <c- o="">+</c->
                                 <c- o="">-</c->inputData<c- p="">[</c->i <c- o="">+</c-> w<c- o="">*</c-><c- mf="">4</c-> <c- o="">-</c-> <c- mf="">4</c-><c- p="">]</c-> <c- o="">-</c->   inputData<c- p="">[</c->i <c- o="">+</c-> w<c- o="">*</c-><c- mf="">4</c-><c- p="">]</c-> <c- o="">-</c-> inputData<c- p="">[</c->i <c- o="">+</c-> w<c- o="">*</c-><c- mf="">4</c-> <c- o="">+</c-> <c- mf="">4</c-><c- p="">];</c->
         <c- p="">}</c->
         outputData<c- p="">[(</c->y<c- o="">*</c->w <c- o="">+</c-> x<c- p="">)</c-><c- o="">*</c-><c- mf="">4</c-> <c- o="">+</c-> <c- mf="">3</c-><c- p="">]</c-> <c- o="">=</c-> <c- mf="">255</c-><c- p="">;</c-> <c- c1="">// alpha</c->
       <c- p="">}</c->
     <c- p="">}</c->

     <c- c1="">// put the image data back after manipulation</c->
     context<c- p="">.</c->putImageData<c- p="">(</c->output<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->
   <c- p="">}</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-> <c- e="">onload</c-><c- o="">=</c-><c- s="">"init()"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">canvas</c-><c- p="">&gt;&lt;/</c-><c- f="">canvas</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>Here is an example of color space conversion applied when drawing a solid color and
   reading the result back using and <code id="pixel-manipulation:dom-context-2d-getimagedata-3"><a href="#dom-context-2d-getimagedata">getImageData()</a></code>.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Color space image data demo<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">canvas</c-><c- p="">&gt;&lt;/</c-><c- f="">canvas</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- a="">const</c-> canvas <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">);</c->
<c- a="">const</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">,</c-> <c- p="">{</c->colorSpace<c- o="">:</c-><c- t="">'display-p3'</c-><c- p="">});</c->

<c- c1="">// Draw a red rectangle. Note that the hex color notation</c->
<c- c1="">// specifies sRGB colors.</c->
context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- u="">"#FF0000"</c-><c- p="">;</c->
context<c- p="">.</c->fillRect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">64</c-><c- p="">,</c-> <c- mf="">64</c-><c- p="">);</c->

<c- c1="">// Get the image data.</c->
<c- a="">const</c-> pixels <c- o="">=</c-> context<c- p="">.</c->getImageData<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">);</c->

<c- c1="">// This will print 'display-p3', reflecting the default behavior</c->
<c- c1="">// of returning image data in the canvas's color space.</c->
console<c- p="">.</c->log<c- p="">(</c->pixels<c- p="">.</c->colorSpace<c- p="">);</c->

<c- c1="">// This will print the values 234, 51, and 35, reflecting the</c->
<c- c1="">// red fill color, converted to 'display-p3'.</c->
console<c- p="">.</c->log<c- p="">(</c->pixels<c- p="">.</c->data<c- p="">[</c-><c- mf="">0</c-><c- p="">]);</c->
console<c- p="">.</c->log<c- p="">(</c->pixels<c- p="">.</c->data<c- p="">[</c-><c- mf="">1</c-><c- p="">]);</c->
console<c- p="">.</c->log<c- p="">(</c->pixels<c- p="">.</c->data<c- p="">[</c-><c- mf="">2</c-><c- p="">]);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>



  <h6 id="compositing"><span class="secno">4.12.5.1.17</span> Compositing<a href="#compositing" class="self-link"></a></h6>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-globalalpha" id="dom-context-2d-globalalpha-dev">globalAlpha</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalAlpha" title="The CanvasRenderingContext2D.globalAlpha property of the Canvas 2D API specifies the alpha (transparency) value that is applied to shapes and images before they are drawn onto the canvas.">CanvasRenderingContext2D/globalAlpha</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the current <a href="#concept-canvas-global-alpha" id="compositing:concept-canvas-global-alpha">global alpha</a> value
    applied to rendering operations.</p>

    <p>Can be set, to change the <a href="#concept-canvas-global-alpha" id="compositing:concept-canvas-global-alpha-2">global alpha</a>
    value. Values outside of the range 0.0 .. 1.0 are ignored.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-globalcompositeoperation" id="dom-context-2d-globalcompositeoperation-dev">globalCompositeOperation</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation" title="The CanvasRenderingContext2D.globalCompositeOperation property of the Canvas 2D API sets the type of compositing operation to apply when drawing new shapes.">CanvasRenderingContext2D/globalCompositeOperation</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="#current-compositing-and-blending-operator" id="compositing:current-compositing-and-blending-operator">current compositing and blending operator</a>, from the values defined
    in <cite>Compositing and Blending</cite>. <a href="#refsCOMPOSITE">[COMPOSITE]</a></p>

    <p>Can be set, to change the <a href="#current-compositing-and-blending-operator" id="compositing:current-compositing-and-blending-operator-2">current compositing and blending operator</a>. Unknown
    values are ignored.</p>
   </dd></dl>

  

  <p>Objects that implement the <code id="compositing:canvascompositing"><a href="#canvascompositing">CanvasCompositing</a></code> interface have a <a href="#concept-canvas-global-alpha" id="compositing:concept-canvas-global-alpha-3">global alpha</a> value and a <a href="#current-compositing-and-blending-operator" id="compositing:current-compositing-and-blending-operator-3">current compositing
  and blending operator</a> value that both affect all the drawing operations on this
  object.</p>

  

  <p>The <dfn id="concept-canvas-global-alpha">global alpha</dfn> value gives an alpha value
  that is applied to shapes and images before they are composited onto the <a href="#output-bitmap" id="compositing:output-bitmap">output bitmap</a>.
  The value ranges from 0.0 (fully transparent) to 1.0 (no additional transparency). It must
  initially have the value 1.0.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasCompositing" id="dom-context-2d-globalalpha" data-dfn-type="attribute"><code>globalAlpha</code></dfn> getter steps are to return
  <a id="compositing:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-global-alpha" id="compositing:concept-canvas-global-alpha-4">global alpha</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="compositing:dom-context-2d-globalalpha"><a href="#dom-context-2d-globalalpha">globalAlpha</a></code> setter steps are:

  </p><ol><li><p>If the given value is either infinite, NaN, or not in the range 0.0 to 1.0, then
   return.</p></li><li><p>Otherwise, set <a id="compositing:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-global-alpha" id="compositing:concept-canvas-global-alpha-5">global
   alpha</a> to the given value.</p></li></ol>
  </div>

  <p>The <dfn id="current-compositing-and-blending-operator">current compositing and blending operator</dfn> value controls how shapes and images
  are drawn onto the <a href="#output-bitmap" id="compositing:output-bitmap-2">output bitmap</a>, once they have had the <a href="#concept-canvas-global-alpha" id="compositing:concept-canvas-global-alpha-6">global alpha</a> and the <a href="#current-transformation-matrix" id="compositing:current-transformation-matrix">current transformation
  matrix</a> applied. Initially, it must be set to "<code id="compositing:gcop-source-over"><a data-x-internal="gcop-source-over" href="https://drafts.fxtf.org/compositing/#porterduffcompositingoperators_srcover">source-over</a></code>".</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasCompositing" id="dom-context-2d-globalcompositeoperation" data-dfn-type="attribute"><code>globalCompositeOperation</code></dfn> getter
  steps are to return <a id="compositing:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#current-compositing-and-blending-operator" id="compositing:current-compositing-and-blending-operator-4">current compositing and blending
  operator</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="compositing:dom-context-2d-globalcompositeoperation"><a href="#dom-context-2d-globalcompositeoperation">globalCompositeOperation</a></code> setter steps
  are:</p>

  <ol><li><p>If the given value is not <a id="compositing:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> any of the values that the
   <a id="compositing:blend-mode" href="https://drafts.fxtf.org/compositing/#ltblendmodegt" data-x-internal="blend-mode">&lt;blend-mode&gt;</a> or the <a id="compositing:composite-mode" href="https://drafts.fxtf.org/compositing/#compositemode" data-x-internal="composite-mode">&lt;composite-mode&gt;</a> properties are defined
   to take, then return. <a href="#refsCOMPOSITE">[COMPOSITE]</a></p></li><li><p>Otherwise, set <a id="compositing:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#current-compositing-and-blending-operator" id="compositing:current-compositing-and-blending-operator-5">current compositing and blending operator</a>
   to the given value.</p></li></ol>
  </div>

  


  <h6 id="image-smoothing"><span class="secno">4.12.5.1.18</span> Image smoothing<a href="#image-smoothing" class="self-link"></a></h6>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-imagesmoothingenabled" id="dom-context-2d-imagesmoothingenabled-dev">imageSmoothingEnabled</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled" title="The imageSmoothingEnabled property of the CanvasRenderingContext2D interface, part of the Canvas API, determines whether scaled images are smoothed (true, default) or not (false). On getting the imageSmoothingEnabled property, the last value it was set to is returned.">CanvasRenderingContext2D/imageSmoothingEnabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>51+</span></span><span class="safari yes"><span>Safari</span><span>9.1+</span></span><span class="chrome yes"><span>Chrome</span><span>30+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>15+</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Requires a prefix or alternative name.">🔰 11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns whether pattern fills and the <code id="image-smoothing:dom-context-2d-drawimage"><a href="#dom-context-2d-drawimage">drawImage()</a></code> method will attempt to smooth images if
    their pixels don't line up exactly with the display, when scaling images up.</p>

    <p>Can be set, to change whether images are smoothed (true) or not (false).</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-imagesmoothingquality" id="dom-context-2d-imagesmoothingquality-dev">imageSmoothingQuality</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality" title="The imageSmoothingQuality property of the CanvasRenderingContext2D interface, part of the Canvas API, lets you set the quality of image smoothing.">CanvasRenderingContext2D/imageSmoothingQuality</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span>9.1+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the current image-smoothing-quality preference.</p>

    <p>Can be set, to change the preferred quality of image smoothing. The possible values are
    "<code id="image-smoothing:dom-context-2d-imagesmoothingquality-low"><a href="#dom-context-2d-imagesmoothingquality-low">low</a></code>", "<code id="image-smoothing:dom-context-2d-imagesmoothingquality-medium"><a href="#dom-context-2d-imagesmoothingquality-medium">medium</a></code>" and "<code id="image-smoothing:dom-context-2d-imagesmoothingquality-high"><a href="#dom-context-2d-imagesmoothingquality-high">high</a></code>". Unknown values are ignored.</p>
   </dd></dl>

  

  <p>Objects that implement the <code id="image-smoothing:canvasimagesmoothing"><a href="#canvasimagesmoothing">CanvasImageSmoothing</a></code> interface have attributes that
  control how image smoothing is performed.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasImageSmoothing" id="dom-context-2d-imagesmoothingenabled" data-dfn-type="attribute"><code>imageSmoothingEnabled</code></dfn> attribute, on
  getting, must return the last value it was set to. On setting, it must be set to the new value.
  When the object implementing the <code id="image-smoothing:canvasimagesmoothing-2"><a href="#canvasimagesmoothing">CanvasImageSmoothing</a></code> interface is created, the
  attribute must be set to true.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasImageSmoothing" id="dom-context-2d-imagesmoothingquality" data-dfn-type="attribute"><code>imageSmoothingQuality</code></dfn> attribute, on
  getting, must return the last value it was set to. On setting, it must be set to the new value.
  When the object implementing the <code id="image-smoothing:canvasimagesmoothing-3"><a href="#canvasimagesmoothing">CanvasImageSmoothing</a></code> interface is created, the
  attribute must be set to "<code id="image-smoothing:dom-context-2d-imagesmoothingquality-low-2"><a href="#dom-context-2d-imagesmoothingquality-low">low</a></code>".</p>
  </div>

  


  <h6 id="shadows"><span class="secno">4.12.5.1.19</span> <dfn>Shadows</dfn><a href="#shadows" class="self-link"></a></h6>

  <p>All drawing operations on an object which implements the <code id="shadows:canvasshadowstyles"><a href="#canvasshadowstyles">CanvasShadowStyles</a></code>
  interface are affected by the four global shadow attributes.</p>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-shadowcolor" id="dom-context-2d-shadowcolor-dev">shadowColor</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowColor" title="The CanvasRenderingContext2D.shadowColor property of the Canvas 2D API specifies the color of shadows.">CanvasRenderingContext2D/shadowColor</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the current shadow color.</p>

    <p>Can be set, to change the shadow color. Values that cannot be parsed as CSS colors are
    ignored.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-shadowoffsetx" id="dom-context-2d-shadowoffsetx-dev">shadowOffsetX</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowOffsetX" title="The CanvasRenderingContext2D.shadowOffsetX property of the Canvas 2D API specifies the distance that shadows will be offset horizontally.">CanvasRenderingContext2D/shadowOffsetX</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>context</var>.<a href="#dom-context-2d-shadowoffsety" id="dom-context-2d-shadowoffsety-dev">shadowOffsetY</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowOffsetY" title="The CanvasRenderingContext2D.shadowOffsetY property of the Canvas 2D API specifies the distance that shadows will be offset vertically.">CanvasRenderingContext2D/shadowOffsetY</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the current shadow offset.</p>

    <p>Can be set, to change the shadow offset. Values that are not finite numbers are ignored.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-context-2d-shadowblur" id="dom-context-2d-shadowblur-dev">shadowBlur</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowBlur" title="The CanvasRenderingContext2D.shadowBlur property of the Canvas 2D API specifies the amount of blur applied to shadows. The default is 0 (no blur).">CanvasRenderingContext2D/shadowBlur</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the current level of blur applied to shadows.</p>

    <p>Can be set, to change the blur level. Values that are not finite numbers greater than or
    equal to zero are ignored.</p>
   </dd></dl>

  

  <p>Objects which implement the <code id="shadows:canvasshadowstyles-2"><a href="#canvasshadowstyles">CanvasShadowStyles</a></code> interface have an associated <dfn id="concept-canvasshadowstyles-shadow-color">shadow color</dfn>, which is a CSS color.
  Initially, it must be <a id="shadows:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CanvasShadowStyles" id="dom-context-2d-shadowcolor" data-dfn-type="attribute"><code>shadowColor</code></dfn> getter steps are to return the <a href="https://drafts.csswg.org/css-color/#serializing-color-values" id="shadows:serialisation-of-a-color" data-x-internal="serialisation-of-a-color">serialization</a> of <a id="shadows:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasshadowstyles-shadow-color" id="shadows:concept-canvasshadowstyles-shadow-color">shadow color</a> with <a href="https://drafts.csswg.org/css-color/#color-serialization-html-compatible-serialization-is-requested" id="shadows:html-compatible-serialization-is-requested" data-x-internal="html-compatible-serialization-is-requested">HTML-compatible serialization
  requested</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="shadows:dom-context-2d-shadowcolor"><a href="#dom-context-2d-shadowcolor">shadowColor</a></code> setter steps are:</p>

  <ol><li><p>Let <var>context</var> be <a id="shadows:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="shadows:dom-context-2d-canvas"><a href="#dom-context-2d-canvas">canvas</a></code> attribute's value, if that is an element; otherwise
   null.</p></li><li><p>Let <var>parsedValue</var> be the result of <a href="https://drafts.csswg.org/css-color/#parse-a-css-color-value" id="shadows:parsed-as-a-css-color-value" data-x-internal="parsed-as-a-css-color-value">parsing</a> the given value with <var>context</var> if non-null.</p></li><li><p>If <var>parsedValue</var> is failure, then return.</p></li><li><p>Set <a id="shadows:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvasshadowstyles-shadow-color" id="shadows:concept-canvasshadowstyles-shadow-color-2">shadow
   color</a> to <var>parsedValue</var>.</p></li></ol>
  </div>

  <p>The <dfn data-dfn-for="CanvasShadowStyles" id="dom-context-2d-shadowoffsetx" data-dfn-type="attribute"><code>shadowOffsetX</code></dfn> and <dfn data-dfn-for="CanvasShadowStyles" id="dom-context-2d-shadowoffsety" data-dfn-type="attribute"><code>shadowOffsetY</code></dfn>
  attributes specify the distance that the shadow will be offset in the positive horizontal and
  positive vertical distance respectively. Their values are in coordinate space units. They are not
  affected by the current transformation matrix.</p>

  <p>When the context is created, the shadow offset attributes must initially have the value
  0.</p>

  <div data-algorithm="">
  <p>On getting, they must return their current value. On setting, the attribute being set must be
  set to the new value, except if the value is infinite or NaN, in which case the new value must be
  ignored.</p>
  </div>

  <p>The <dfn data-dfn-for="CanvasShadowStyles" id="dom-context-2d-shadowblur" data-dfn-type="attribute"><code>shadowBlur</code></dfn> attribute specifies the level of the
  blurring effect. (The units do not map to coordinate space units, and are not affected by the
  current transformation matrix.)</p>

  <p>When the context is created, the <code id="shadows:dom-context-2d-shadowblur"><a href="#dom-context-2d-shadowblur">shadowBlur</a></code>
  attribute must initially have the value 0.</p>

  <div data-algorithm="">
  <p>On getting, the attribute must return its current value. On setting, the attribute must be set
  to the new value, except if the value is negative, infinite or NaN, in which case the new value
  must be ignored.</p>
  </div>

  <div data-algorithm="">
  <p><dfn id="when-shadows-are-drawn">Shadows are only drawn if</dfn> the opacity component of
  the alpha component of the <a href="#concept-canvasshadowstyles-shadow-color" id="shadows:concept-canvasshadowstyles-shadow-color-3">shadow
  color</a> is nonzero and either the <code id="shadows:dom-context-2d-shadowblur-2"><a href="#dom-context-2d-shadowblur">shadowBlur</a></code>
  is nonzero, or the <code id="shadows:dom-context-2d-shadowoffsetx"><a href="#dom-context-2d-shadowoffsetx">shadowOffsetX</a></code> is nonzero, or
  the <code id="shadows:dom-context-2d-shadowoffsety"><a href="#dom-context-2d-shadowoffsety">shadowOffsetY</a></code> is nonzero.</p>
  </div>

  <div data-algorithm="">
  <p><a href="#when-shadows-are-drawn" id="shadows:when-shadows-are-drawn">When shadows are drawn</a>, they must be rendered as follows:</p>

  <ol><li><p>Let <var>A</var> be an infinite <a id="shadows:transparent-black-2" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> bitmap on which the source
   image for which a shadow is being created has been rendered.</p></li><li><p>Let <var>B</var> be an infinite <a id="shadows:transparent-black-3" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> bitmap, with a coordinate
   space and an origin identical to <var>A</var>.</p></li><li><p>Copy the alpha component of <var>A</var> to <var>B</var>, offset by <code id="shadows:dom-context-2d-shadowoffsetx-2"><a href="#dom-context-2d-shadowoffsetx">shadowOffsetX</a></code> in the positive <var>x</var>
   direction, and <code id="shadows:dom-context-2d-shadowoffsety-2"><a href="#dom-context-2d-shadowoffsety">shadowOffsetY</a></code> in the positive
   <var>y</var> direction.</p></li><li>
    <p>If <code id="shadows:dom-context-2d-shadowblur-3"><a href="#dom-context-2d-shadowblur">shadowBlur</a></code> is greater than 0:</p>

    <ol><li><p>Let <var>σ</var> be half the value of <code id="shadows:dom-context-2d-shadowblur-4"><a href="#dom-context-2d-shadowblur">shadowBlur</a></code>.</p></li><li><p>Perform a 2D Gaussian Blur on <var>B</var>, using <var>σ</var>
     as the standard deviation.</p>  </li></ol>

    <p>User agents may limit values of <var>σ</var> to an implementation-specific
    maximum value to avoid exceeding hardware limitations during the Gaussian blur operation.</p>
   </li><li><p>Set the red, green, and blue components of every pixel in <var>B</var> to the
   red, green, and blue components (respectively) of the <a href="#concept-canvasshadowstyles-shadow-color" id="shadows:concept-canvasshadowstyles-shadow-color-4">shadow color</a>.</p></li><li><p>Multiply the alpha component of every pixel in <var>B</var> by the alpha
   component of the <a href="#concept-canvasshadowstyles-shadow-color" id="shadows:concept-canvasshadowstyles-shadow-color-5">shadow
   color</a>.</p></li><li><p>The shadow is in the bitmap <var>B</var>, and is rendered as part of the
   <a href="#drawing-model" id="shadows:drawing-model">drawing model</a> described below.</p></li></ol>
  </div>

  

  <p>If the <a href="#current-compositing-and-blending-operator" id="shadows:current-compositing-and-blending-operator">current compositing and blending operator</a> is "<code id="shadows:gcop-copy"><a data-x-internal="gcop-copy" href="https://drafts.fxtf.org/compositing/#porterduffcompositingoperators_src">copy</a></code>", then shadows effectively won't render (since the shape will
  overwrite the shadow).</p>

  <h6 id="filters"><span class="secno">4.12.5.1.20</span> Filters<a href="#filters" class="self-link"></a></h6>

  <p>All drawing operations on an object which implements the <code id="filters:canvasfilters"><a href="#canvasfilters">CanvasFilters</a></code>
  interface are affected by the global <dfn data-dfn-for="CanvasFilters" id="dom-context-2d-filter" data-dfn-type="attribute"><code>filter</code></dfn> attribute.</p>

  <dl class="domintro"><dt><code><var>context</var>.<a href="#dom-context-2d-filter" id="dom-context-2d-filter-dev">filter</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter" title="The CanvasRenderingContext2D.filter property of the Canvas 2D API provides filter effects such as blurring and grayscaling. It is similar to the CSS filter property and accepts the same values.">CanvasRenderingContext2D/filter</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>52+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the current filter.</p>


    <p>Can be set, to change the filter. Values can either be the string "<code>none</code>" or a string parseable as a <a id="filters:filter-value-list" href="https://drafts.fxtf.org/filter-effects/#typedef-filter-value-list" data-x-internal="filter-value-list">&lt;filter-value-list&gt;</a>. Other
    values are ignored.</p>
   </dd></dl>

  

  <p>Such objects have an associated <dfn id="concept-canvas-current-filter">current
  filter</dfn>, which is a string. Initially the <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter">current filter</a> is set to the string "<code>none</code>". Whenever the value of the <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter-2">current filter</a> is the string "<code>none</code>" filters will be disabled for the context.</p>

  <div data-algorithm="">
  <p>The <code id="filters:dom-context-2d-filter"><a href="#dom-context-2d-filter">filter</a></code> getter steps are to return
  <a id="filters:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter-3">current filter</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="filters:dom-context-2d-filter-2"><a href="#dom-context-2d-filter">filter</a></code> setter steps are:</p>

  <ol><li><p>If the given value is "<code>none</code>", then set <a id="filters:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter-4">current filter</a> to "<code>none</code>"
   and return.</p></li><li><p>Let <var>parsedValue</var> be the result of <a href="https://drafts.csswg.org/css-syntax/#parse-grammar" id="filters:parse-something-according-to-a-css-grammar" data-x-internal="parse-something-according-to-a-css-grammar">parsing</a> the given values as a <a id="filters:filter-value-list-2" href="https://drafts.fxtf.org/filter-effects/#typedef-filter-value-list" data-x-internal="filter-value-list">&lt;filter-value-list&gt;</a>. If any
   property-independent style sheet syntax like 'inherit' or 'initial' is present, then this
   parsing must return failure.</p></li><li><p>If <var>parsedValue</var> is failure, then return.</p></li><li><p>Set <a id="filters:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter-5">current
   filter</a> to the given value.</p></li></ol>
  </div>

  

  <p data-var-scope="" class="note">Though <code><var>context</var>.<code id="filters:dom-context-2d-filter-3"><a href="#dom-context-2d-filter">filter</a></code> = "<code>none</code>"</code> will disable
  filters for the context, <code><var>context</var>.<code id="filters:dom-context-2d-filter-4"><a href="#dom-context-2d-filter">filter</a></code> = ""</code>, <code><var>context</var>.<code id="filters:dom-context-2d-filter-5"><a href="#dom-context-2d-filter">filter</a></code> = null</code>,
  and <code><var>context</var>.<code id="filters:dom-context-2d-filter-6"><a href="#dom-context-2d-filter">filter</a></code> =
  undefined</code> are all treated as unparseable inputs and the value of the <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter-6">current filter</a> is left unchanged.</p>

  <p>Coordinates used in the value of the <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter-7">current
  filter</a> are interpreted such that one pixel is equivalent to one SVG user space unit and to
  one canvas coordinate space unit. Filter coordinates are not affected by the <a href="#transformations" id="filters:transformations">current transformation matrix</a>. The current
  transformation matrix affects only the input to the filter. Filters are applied in the
  <a href="#output-bitmap" id="filters:output-bitmap">output bitmap</a>'s coordinate space.</p>

  

  <p>When the value of the <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter-8">current filter</a> is a
  string parsable as a <a id="filters:filter-value-list-3" href="https://drafts.fxtf.org/filter-effects/#typedef-filter-value-list" data-x-internal="filter-value-list">&lt;filter-value-list&gt;</a> which defines lengths using
  percentages or using <a id="filters:'em'" href="https://drafts.csswg.org/css-values/#em" data-x-internal="'em'">'em'</a> or <a id="filters:'ex'" href="https://drafts.csswg.org/css-values/#ex" data-x-internal="'ex'">'ex'</a> units, these must be interpreted
  relative to the <a id="filters:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of the <a id="filters:'font-size'" href="https://drafts.csswg.org/css-fonts/#font-size-prop" data-x-internal="'font-size'">'font-size'</a> property of the
  <a href="#font-style-source-object" id="filters:font-style-source-object">font style source object</a> at the time that the attribute is set. If the <a href="https://drafts.csswg.org/css-cascade/#computed-value" id="filters:computed-value-2" data-x-internal="computed-value">computed values</a> are undefined for a particular case (e.g. because
  the <a href="#font-style-source-object" id="filters:font-style-source-object-2">font style source object</a> is not an element or is not <a href="#being-rendered" id="filters:being-rendered">being
  rendered</a>), then the relative keywords must be interpreted relative to the default value of
  the <code id="filters:dom-context-2d-font"><a href="#dom-context-2d-font">font</a></code> attribute. The 'larger' and 'smaller' keywords
  are not supported.</p>

  <p>If the value of the <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter-9">current filter</a> is a
  string parseable as a <a id="filters:filter-value-list-4" href="https://drafts.fxtf.org/filter-effects/#typedef-filter-value-list" data-x-internal="filter-value-list">&lt;filter-value-list&gt;</a> with a reference to an SVG filter in
  the same document, and this SVG filter changes, then the changed filter is used for the next draw
  operation.</p>

  <p>If the value of the <a href="#concept-canvas-current-filter" id="filters:concept-canvas-current-filter-10">current filter</a> is a
  string parseable as a <a id="filters:filter-value-list-5" href="https://drafts.fxtf.org/filter-effects/#typedef-filter-value-list" data-x-internal="filter-value-list">&lt;filter-value-list&gt;</a> with a reference to an SVG filter in
  an external resource document and that document is not loaded when a drawing operation is
  invoked, then the drawing operation must proceed with no filtering.</p>

  

  <h6 id="working-with-externally-defined-svg-filters"><span class="secno">4.12.5.1.21</span> Working with externally-defined SVG filters<a href="#working-with-externally-defined-svg-filters" class="self-link"></a></h6>

  <p><i>This section is non-normative.</i></p>

  <p>Since drawing is performed using filter value "<code>none</code>" until an
  externally-defined filter has finished loading, authors might wish to determine whether such a
  filter has finished loading before proceeding with a drawing operation. One way to accomplish
  this is to load the externally-defined filter elsewhere within the same page in some element that
  sends a <code>load</code> event (for example, an <a id="working-with-externally-defined-svg-filters:svg-use" href="https://svgwg.org/svg2-draft/struct.html#UseElement" data-x-internal="svg-use">SVG <code>use</code></a>
  element), and wait for the <code>load</code> event to be dispatched.</p>

  

  <h6 id="drawing-model"><span class="secno">4.12.5.1.22</span> <dfn>Drawing model</dfn><a href="#drawing-model" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When a shape or image is painted, user agents must follow these steps, in the order given (or
  act as if they do):</p>

  <ol><li><p>Render the shape or image onto an infinite <a id="drawing-model:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> bitmap, creating
   image <var>A</var>, as described in the previous sections. For shapes, the current fill, stroke,
   and line styles must be honored, and the stroke must itself also be subjected to the current
   transformation matrix.</p></li><li>
    <p>Convert the image <var>A</var> to the <a href="#concept-canvas-color-space" id="drawing-model:concept-canvas-color-space">context's
    color space</a>.</p>

    <p class="note">There do not exist any inputs to a 2D context for which the color space is
    undefined. The color space for CSS colors is defined in <cite>CSS Color</cite>. The color space
    for images that specify no color profile information is <a id="drawing-model:'srgb'" href="https://drafts.csswg.org/css-color/#valdef-color-srgb" data-x-internal="'srgb'">'srgb'</a>, as
    specified in the <a href="https://drafts.csswg.org/css-color/#untagged">Color Spaces of Untagged
    Colors</a> section of <cite>CSS Color</cite>. <a href="#refsCSSCOLOR">[CSSCOLOR]</a></p>
   </li><li><p>Multiply the alpha component of every pixel in <var>A</var> by <code id="drawing-model:concept-canvas-global-alpha"><a href="#concept-canvas-global-alpha">global alpha</a></code>.</p></li><li>
    <p>When the <a href="#concept-canvas-current-filter" id="drawing-model:concept-canvas-current-filter">current filter</a> is set to a
    value other than "<code>none</code>" and all the externally-defined filters it
    references, if any, are in documents that are currently loaded, then use image <var>A</var> as
    the input to the <a href="#concept-canvas-current-filter" id="drawing-model:concept-canvas-current-filter-2">current filter</a>, creating
    image <var>B</var>. If the <a href="#concept-canvas-current-filter" id="drawing-model:concept-canvas-current-filter-3">current filter</a>
    is a string parseable as a <a id="drawing-model:filter-value-list" href="https://drafts.fxtf.org/filter-effects/#typedef-filter-value-list" data-x-internal="filter-value-list">&lt;filter-value-list&gt;</a>, then draw using the <a href="#concept-canvas-current-filter" id="drawing-model:concept-canvas-current-filter-4">current filter</a> in the same manner as SVG.</p>

    <p>Otherwise, let <var>B</var> be an alias for <var>A</var>.</p>
   </li><li><p><a href="#when-shadows-are-drawn" id="drawing-model:when-shadows-are-drawn">When shadows are drawn</a>, render the shadow from image <var>B</var>,
   using the current shadow styles, creating image <var>C</var>.</p></li><li><p><a href="#when-shadows-are-drawn" id="drawing-model:when-shadows-are-drawn-2">When shadows are drawn</a>, composite <var>C</var> within the
   <a href="#clipping-region" id="drawing-model:clipping-region">clipping region</a> over the current <a href="#output-bitmap" id="drawing-model:output-bitmap">output bitmap</a> using the <a href="#current-compositing-and-blending-operator" id="drawing-model:current-compositing-and-blending-operator">current
   compositing and blending operator</a>.</p></li><li><p>Composite <var>B</var> within the <a href="#clipping-region" id="drawing-model:clipping-region-2">clipping region</a> over the current
   <a href="#output-bitmap" id="drawing-model:output-bitmap-2">output bitmap</a> using the <a href="#current-compositing-and-blending-operator" id="drawing-model:current-compositing-and-blending-operator-2">current compositing and blending
   operator</a>.</p></li></ol>
  </div>

  <p>When compositing onto the <a href="#output-bitmap" id="drawing-model:output-bitmap-3">output bitmap</a>, pixels that would fall outside of the
  <a href="#output-bitmap" id="drawing-model:output-bitmap-4">output bitmap</a> must be discarded.</p>

  




  <h6 id="best-practices"><span class="secno">4.12.5.1.23</span> Best practices<a href="#best-practices" class="self-link"></a></h6>

  <p>When a canvas is interactive, authors should include <a href="#focusable" id="best-practices:focusable">focusable</a> elements in the
  element's fallback content corresponding to each <a href="#focusable" id="best-practices:focusable-2">focusable</a> part of the canvas, as in
  the <a href="#drawCustomFocusRingExample">example above</a>.</p>

  <p>When rendering focus rings, to ensure that focus rings have the appearance of native focus
  rings, authors should use the <code id="best-practices:dom-context-2d-drawfocusifneeded"><a href="#dom-context-2d-drawfocusifneeded">drawFocusIfNeeded()</a></code> method, passing it the
  element for which a ring is being drawn. This method only draws the focus ring if the element is
  <a href="#focused" id="best-practices:focused">focused</a>, so that it can simply be called whenever drawing the element, without
  checking whether the element is focused or not first.</p>

  <p id="no-text-editing-in-canvas-please">Authors should avoid implementing text editing controls
  using the <code id="best-practices:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element. Doing so has a large number of disadvantages:</p>

  <ul><li>Mouse placement of the caret has to be reimplemented.</li><li>Keyboard movement of the caret has to be reimplemented (possibly across lines, for multiline
   text input).</li><li>Scrolling of the text control has to be implemented (horizontally for long lines, vertically
   for multiline input).</li><li>Native features such as copy-and-paste have to be reimplemented.</li><li>Native features such as spell-checking have to be reimplemented.</li><li>Native features such as drag-and-drop have to be reimplemented.</li><li>Native features such as page-wide text search have to be reimplemented.</li><li>Native features specific to the user, for example custom text services, have to be
   reimplemented. This is close to impossible since each user might have different services
   installed, and there is an unbounded set of possible such services.</li><li>Bidirectional text editing has to be reimplemented.</li><li>For multiline text editing, line wrapping has to be implemented for all relevant
   languages.</li><li>Text selection has to be reimplemented.</li><li>Dragging of bidirectional text selections has to be reimplemented.</li><li>Platform-native keyboard shortcuts have to be reimplemented.</li><li>Platform-native input method editors (IMEs) have to be reimplemented.</li><li>Undo and redo functionality has to be reimplemented.</li><li>Accessibility features such as magnification following the caret or selection have to be
   reimplemented.</li></ul>

  <p>This is a huge amount of work, and authors are most strongly encouraged to avoid doing any of
  it by instead using the <code id="best-practices:the-input-element"><a href="#the-input-element">input</a></code> element, the <code id="best-practices:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element, or the
  <code id="best-practices:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code> attribute.</p>


  <h6 id="examples"><span class="secno">4.12.5.1.24</span> Examples<a href="#examples" class="self-link"></a></h6>

  <p><i>This section is non-normative.</i></p>

  <div class="example">

  <p>Here is an example of a script that uses canvas to draw <a href="data:text/html;charset=utf-8;base64,PCFET0NUWVBFIEhUTUw%2BDQo8aHRtbCBsYW5nPSJlbiI%2BDQogPGhlYWQ%2BDQogIDx0aXRsZT5QcmV0dHkgR2xvd2luZyBMaW5lczwvdGl0bGU%2BDQogPC9oZWFkPg0KIDxib2R5Pg0KPGNhbnZhcyB3aWR0aD0iODAwIiBoZWlnaHQ9IjQ1MCI%2BPC9jYW52YXM%2BDQo8c2NyaXB0Pg0KDQogdmFyIGNvbnRleHQgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgnY2FudmFzJylbMF0uZ2V0Q29udGV4dCgnMmQnKTsNCg0KIHZhciBsYXN0WCA9IGNvbnRleHQuY2FudmFzLndpZHRoICogTWF0aC5yYW5kb20oKTsNCiB2YXIgbGFzdFkgPSBjb250ZXh0LmNhbnZhcy5oZWlnaHQgKiBNYXRoLnJhbmRvbSgpOw0KIHZhciBodWUgPSAwOw0KIGZ1bmN0aW9uIGxpbmUoKSB7DQogICBjb250ZXh0LnNhdmUoKTsNCiAgIGNvbnRleHQudHJhbnNsYXRlKGNvbnRleHQuY2FudmFzLndpZHRoLzIsIGNvbnRleHQuY2FudmFzLmhlaWdodC8yKTsNCiAgIGNvbnRleHQuc2NhbGUoMC45LCAwLjkpOw0KICAgY29udGV4dC50cmFuc2xhdGUoLWNvbnRleHQuY2FudmFzLndpZHRoLzIsIC1jb250ZXh0LmNhbnZhcy5oZWlnaHQvMik7DQogICBjb250ZXh0LmJlZ2luUGF0aCgpOw0KICAgY29udGV4dC5saW5lV2lkdGggPSA1ICsgTWF0aC5yYW5kb20oKSAqIDEwOw0KICAgY29udGV4dC5tb3ZlVG8obGFzdFgsIGxhc3RZKTsNCiAgIGxhc3RYID0gY29udGV4dC5jYW52YXMud2lkdGggKiBNYXRoLnJhbmRvbSgpOw0KICAgbGFzdFkgPSBjb250ZXh0LmNhbnZhcy5oZWlnaHQgKiBNYXRoLnJhbmRvbSgpOw0KICAgY29udGV4dC5iZXppZXJDdXJ2ZVRvKGNvbnRleHQuY2FudmFzLndpZHRoICogTWF0aC5yYW5kb20oKSwNCiAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0LmNhbnZhcy5oZWlnaHQgKiBNYXRoLnJhbmRvbSgpLA0KICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQuY2FudmFzLndpZHRoICogTWF0aC5yYW5kb20oKSwNCiAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0LmNhbnZhcy5oZWlnaHQgKiBNYXRoLnJhbmRvbSgpLA0KICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3RYLCBsYXN0WSk7DQoNCiAgIGh1ZSA9IGh1ZSArIDEwICogTWF0aC5yYW5kb20oKTsNCiAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSAnaHNsKCcgKyBodWUgKyAnLCA1MCUsIDUwJSknOw0KICAgY29udGV4dC5zaGFkb3dDb2xvciA9ICd3aGl0ZSc7DQogICBjb250ZXh0LnNoYWRvd0JsdXIgPSAxMDsNCiAgIGNvbnRleHQuc3Ryb2tlKCk7DQogICBjb250ZXh0LnJlc3RvcmUoKTsNCiB9DQogc2V0SW50ZXJ2YWwobGluZSwgNTApOw0KDQogZnVuY3Rpb24gYmxhbmsoKSB7DQogICBjb250ZXh0LmZpbGxTdHlsZSA9ICdyZ2JhKDAsMCwwLDAuMSknOw0KICAgY29udGV4dC5maWxsUmVjdCgwLCAwLCBjb250ZXh0LmNhbnZhcy53aWR0aCwgY29udGV4dC5jYW52YXMuaGVpZ2h0KTsNCiB9DQogc2V0SW50ZXJ2YWwoYmxhbmssIDQwKTsNCg0KPC9zY3JpcHQ%2BDQogPC9ib2R5Pg0KPC9odG1sPg0K">pretty glowing lines</a>.</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">canvas</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">"800"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"450"</c-><c- p="">&gt;&lt;/</c-><c- f="">canvas</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->

 <c- a="">var</c-> context <c- o="">=</c-> document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">].</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">);</c->

 <c- a="">var</c-> lastX <c- o="">=</c-> context<c- p="">.</c->canvas<c- p="">.</c->width <c- o="">*</c-> Math<c- p="">.</c->random<c- p="">();</c->
 <c- a="">var</c-> lastY <c- o="">=</c-> context<c- p="">.</c->canvas<c- p="">.</c->height <c- o="">*</c-> Math<c- p="">.</c->random<c- p="">();</c->
 <c- a="">var</c-> hue <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
 <c- a="">function</c-> line<c- p="">()</c-> <c- p="">{</c->
   context<c- p="">.</c->save<c- p="">();</c->
   context<c- p="">.</c->translate<c- p="">(</c->context<c- p="">.</c->canvas<c- p="">.</c->width<c- o="">/</c-><c- mf="">2</c-><c- p="">,</c-> context<c- p="">.</c->canvas<c- p="">.</c->height<c- o="">/</c-><c- mf="">2</c-><c- p="">);</c->
   context<c- p="">.</c->scale<c- p="">(</c-><c- mf="">0.9</c-><c- p="">,</c-> <c- mf="">0.9</c-><c- p="">);</c->
   context<c- p="">.</c->translate<c- p="">(</c-><c- o="">-</c->context<c- p="">.</c->canvas<c- p="">.</c->width<c- o="">/</c-><c- mf="">2</c-><c- p="">,</c-> <c- o="">-</c->context<c- p="">.</c->canvas<c- p="">.</c->height<c- o="">/</c-><c- mf="">2</c-><c- p="">);</c->
   context<c- p="">.</c->beginPath<c- p="">();</c->
   context<c- p="">.</c->lineWidth <c- o="">=</c-> <c- mf="">5</c-> <c- o="">+</c-> Math<c- p="">.</c->random<c- p="">()</c-> <c- o="">*</c-> <c- mf="">10</c-><c- p="">;</c->
   context<c- p="">.</c->moveTo<c- p="">(</c->lastX<c- p="">,</c-> lastY<c- p="">);</c->
   lastX <c- o="">=</c-> context<c- p="">.</c->canvas<c- p="">.</c->width <c- o="">*</c-> Math<c- p="">.</c->random<c- p="">();</c->
   lastY <c- o="">=</c-> context<c- p="">.</c->canvas<c- p="">.</c->height <c- o="">*</c-> Math<c- p="">.</c->random<c- p="">();</c->
   context<c- p="">.</c->bezierCurveTo<c- p="">(</c->context<c- p="">.</c->canvas<c- p="">.</c->width <c- o="">*</c-> Math<c- p="">.</c->random<c- p="">(),</c->
                         context<c- p="">.</c->canvas<c- p="">.</c->height <c- o="">*</c-> Math<c- p="">.</c->random<c- p="">(),</c->
                         context<c- p="">.</c->canvas<c- p="">.</c->width <c- o="">*</c-> Math<c- p="">.</c->random<c- p="">(),</c->
                         context<c- p="">.</c->canvas<c- p="">.</c->height <c- o="">*</c-> Math<c- p="">.</c->random<c- p="">(),</c->
                         lastX<c- p="">,</c-> lastY<c- p="">);</c->

   hue <c- o="">=</c-> hue <c- o="">+</c-> <c- mf="">10</c-> <c- o="">*</c-> Math<c- p="">.</c->random<c- p="">();</c->
   context<c- p="">.</c->strokeStyle <c- o="">=</c-> <c- t="">'hsl('</c-> <c- o="">+</c-> hue <c- o="">+</c-> <c- t="">', 50%, 50%)'</c-><c- p="">;</c->
   context<c- p="">.</c->shadowColor <c- o="">=</c-> <c- t="">'white'</c-><c- p="">;</c->
   context<c- p="">.</c->shadowBlur <c- o="">=</c-> <c- mf="">10</c-><c- p="">;</c->
   context<c- p="">.</c->stroke<c- p="">();</c->
   context<c- p="">.</c->restore<c- p="">();</c->
 <c- p="">}</c->
 setInterval<c- p="">(</c->line<c- p="">,</c-> <c- mf="">50</c-><c- p="">);</c->

 <c- a="">function</c-> blank<c- p="">()</c-> <c- p="">{</c->
   context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- t="">'rgba(0,0,0,0.1)'</c-><c- p="">;</c->
   context<c- p="">.</c->fillRect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> context<c- p="">.</c->canvas<c- p="">.</c->width<c- p="">,</c-> context<c- p="">.</c->canvas<c- p="">.</c->height<c- p="">);</c->
 <c- p="">}</c->
 setInterval<c- p="">(</c->blank<c- p="">,</c-> <c- mf="">40</c-><c- p="">);</c->

<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The 2D rendering context for <code id="examples:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> is often used for sprite-based games. The
   following example demonstrates this:</p>

   <iframe src="/demos/canvas/blue-robot/index-idle.html" width="396" height="216"></iframe>

   <p>Here is the source for this example:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Blue Robot Demo<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
  <c- f="">html</c-> <c- p="">{</c-> <c- k="">overflow</c-><c- p="">:</c-> <c- kc="">hidden</c-><c- p="">;</c-> <c- k="">min-height</c-><c- p="">:</c-> <c- mi="">200</c-><c- b="">px</c-><c- p="">;</c-> <c- k="">min-width</c-><c- p="">:</c-> <c- mi="">380</c-><c- b="">px</c-><c- p="">;</c-> <c- p="">}</c->
  <c- f="">body</c-> <c- p="">{</c-> <c- k="">height</c-><c- p="">:</c-> <c- mi="">200</c-><c- b="">px</c-><c- p="">;</c-> <c- k="">position</c-><c- p="">:</c-> <c- kc="">relative</c-><c- p="">;</c-> <c- k="">margin</c-><c- p="">:</c-> <c- mi="">8</c-><c- b="">px</c-><c- p="">;</c-> <c- p="">}</c->
  <c- p="">.</c-><c- nc="">buttons</c-> <c- p="">{</c-> <c- k="">position</c-><c- p="">:</c-> <c- kc="">absolute</c-><c- p="">;</c-> <c- k="">bottom</c-><c- p="">:</c-> <c- mi="">0</c-><c- b="">px</c-><c- p="">;</c-> <c- k="">left</c-><c- p="">:</c-> <c- mi="">0</c-><c- b="">px</c-><c- p="">;</c-> <c- k="">margin</c-><c- p="">:</c-> <c- mi="">4</c-><c- b="">px</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">canvas</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">"380"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">"200"</c-><c- p="">&gt;&lt;/</c-><c- f="">canvas</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> Landscape <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->context<c- p="">,</c-> width<c- p="">,</c-> height<c- p="">)</c-> <c- p="">{</c->
   <c- k="">this</c-><c- p="">.</c->offset <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
   <c- k="">this</c-><c- p="">.</c->width <c- o="">=</c-> width<c- p="">;</c->
   <c- k="">this</c-><c- p="">.</c->advance <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->dx<c- p="">)</c-> <c- p="">{</c->
     <c- k="">this</c-><c- p="">.</c->offset <c- o="">+=</c-> dx<c- p="">;</c->
   <c- p="">};</c->
   <c- k="">this</c-><c- p="">.</c->horizon <c- o="">=</c-> height <c- o="">*</c-> <c- mf="">0.7</c-><c- p="">;</c->
   <c- c1="">// This creates the sky gradient (from a darker blue to white at the bottom)</c->
   <c- k="">this</c-><c- p="">.</c->sky <c- o="">=</c-> context<c- p="">.</c->createLinearGradient<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->horizon<c- p="">);</c->
   <c- k="">this</c-><c- p="">.</c->sky<c- p="">.</c->addColorStop<c- p="">(</c-><c- mf="">0.0</c-><c- p="">,</c-> <c- t="">'rgb(55,121,179)'</c-><c- p="">);</c->
   <c- k="">this</c-><c- p="">.</c->sky<c- p="">.</c->addColorStop<c- p="">(</c-><c- mf="">0.7</c-><c- p="">,</c-> <c- t="">'rgb(121,194,245)'</c-><c- p="">);</c->
   <c- k="">this</c-><c- p="">.</c->sky<c- p="">.</c->addColorStop<c- p="">(</c-><c- mf="">1.0</c-><c- p="">,</c-> <c- t="">'rgb(164,200,214)'</c-><c- p="">);</c->
   <c- c1="">// this creates the grass gradient (from a darker green to a lighter green)</c->
   <c- k="">this</c-><c- p="">.</c->earth <c- o="">=</c-> context<c- p="">.</c->createLinearGradient<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->horizon<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> height<c- p="">);</c->
   <c- k="">this</c-><c- p="">.</c->earth<c- p="">.</c->addColorStop<c- p="">(</c-><c- mf="">0.0</c-><c- p="">,</c-> <c- t="">'rgb(81,140,20)'</c-><c- p="">);</c->
   <c- k="">this</c-><c- p="">.</c->earth<c- p="">.</c->addColorStop<c- p="">(</c-><c- mf="">1.0</c-><c- p="">,</c-> <c- t="">'rgb(123,177,57)'</c-><c- p="">);</c->
   <c- k="">this</c-><c- p="">.</c->paintBackground <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->context<c- p="">,</c-> width<c- p="">,</c-> height<c- p="">)</c-> <c- p="">{</c->
     <c- c1="">// first, paint the sky and grass rectangles</c->
     context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->sky<c- p="">;</c->
     context<c- p="">.</c->fillRect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> width<c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->horizon<c- p="">);</c->
     context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->earth<c- p="">;</c->
     context<c- p="">.</c->fillRect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->horizon<c- p="">,</c-> width<c- p="">,</c-> height<c- o="">-</c-><c- k="">this</c-><c- p="">.</c->horizon<c- p="">);</c->
     <c- c1="">// then, draw the cloudy banner</c->
     <c- c1="">// we make it cloudy by having the draw text off the top of the</c->
     <c- c1="">// canvas, and just having the blurred shadow shown on the canvas</c->
     context<c- p="">.</c->save<c- p="">();</c->
     context<c- p="">.</c->translate<c- p="">(</c->width<c- o="">-</c-><c- p="">((</c-><c- k="">this</c-><c- p="">.</c->offset<c- o="">+</c-><c- p="">(</c-><c- k="">this</c-><c- p="">.</c->width<c- o="">*</c-><c- mf="">3.2</c-><c- p="">))</c-> <c- o="">%</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->width<c- o="">*</c-><c- mf="">4.0</c-><c- p="">))</c-><c- o="">+</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->
     context<c- p="">.</c->shadowColor <c- o="">=</c-> <c- t="">'white'</c-><c- p="">;</c->
     context<c- p="">.</c->shadowOffsetY <c- o="">=</c-> <c- mf="">30</c-><c- o="">+</c-><c- k="">this</c-><c- p="">.</c->horizon<c- o="">/</c-><c- mf="">3</c-><c- p="">;</c-> <c- c1="">// offset down on canvas</c->
     context<c- p="">.</c->shadowBlur <c- o="">=</c-> <c- t="">'5'</c-><c- p="">;</c->
     context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- t="">'white'</c-><c- p="">;</c->
     context<c- p="">.</c->textAlign <c- o="">=</c-> <c- t="">'left'</c-><c- p="">;</c->
     context<c- p="">.</c->textBaseline <c- o="">=</c-> <c- t="">'top'</c-><c- p="">;</c->
     context<c- p="">.</c->font <c- o="">=</c-> <c- t="">'20px sans-serif'</c-><c- p="">;</c->
     context<c- p="">.</c->fillText<c- p="">(</c-><c- t="">'WHATWG ROCKS'</c-><c- p="">,</c-> <c- mf="">10</c-><c- p="">,</c-> <c- o="">-</c-><c- mf="">30</c-><c- p="">);</c-> <c- c1="">// text up above canvas</c->
     context<c- p="">.</c->restore<c- p="">();</c->
     <c- c1="">// then, draw the background tree</c->
     context<c- p="">.</c->save<c- p="">();</c->
     context<c- p="">.</c->translate<c- p="">(</c->width<c- o="">-</c-><c- p="">((</c-><c- k="">this</c-><c- p="">.</c->offset<c- o="">+</c-><c- p="">(</c-><c- k="">this</c-><c- p="">.</c->width<c- o="">*</c-><c- mf="">0.2</c-><c- p="">))</c-> <c- o="">%</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->width<c- o="">*</c-><c- mf="">1.5</c-><c- p="">))</c-><c- o="">+</c-><c- mf="">30</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->
     context<c- p="">.</c->beginPath<c- p="">();</c->
     context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- t="">'rgb(143,89,2)'</c-><c- p="">;</c->
     context<c- p="">.</c->lineStyle <c- o="">=</c-> <c- t="">'rgb(10,10,10)'</c-><c- p="">;</c->
     context<c- p="">.</c->lineWidth <c- o="">=</c-> <c- mf="">2</c-><c- p="">;</c->
     context<c- p="">.</c->rect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->horizon<c- o="">+</c-><c- mf="">5</c-><c- p="">,</c-> <c- mf="">10</c-><c- p="">,</c-> <c- o="">-</c-><c- mf="">50</c-><c- p="">);</c-> <c- c1="">// trunk</c->
     context<c- p="">.</c->fill<c- p="">();</c->
     context<c- p="">.</c->stroke<c- p="">();</c->
     context<c- p="">.</c->beginPath<c- p="">();</c->
     context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- t="">'rgb(78,154,6)'</c-><c- p="">;</c->
     context<c- p="">.</c->arc<c- p="">(</c-><c- mf="">5</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->horizon<c- o="">-</c-><c- mf="">60</c-><c- p="">,</c-> <c- mf="">30</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> Math<c- p="">.</c->PI<c- o="">*</c-><c- mf="">2</c-><c- p="">);</c-> <c- c1="">// leaves</c->
     context<c- p="">.</c->fill<c- p="">();</c->
     context<c- p="">.</c->stroke<c- p="">();</c->
     context<c- p="">.</c->restore<c- p="">();</c->
   <c- p="">};</c->
   <c- k="">this</c-><c- p="">.</c->paintForeground <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->context<c- p="">,</c-> width<c- p="">,</c-> height<c- p="">)</c-> <c- p="">{</c->
     <c- c1="">// draw the box that goes in front</c->
     context<c- p="">.</c->save<c- p="">();</c->
     context<c- p="">.</c->translate<c- p="">(</c->width<c- o="">-</c-><c- p="">((</c-><c- k="">this</c-><c- p="">.</c->offset<c- o="">+</c-><c- p="">(</c-><c- k="">this</c-><c- p="">.</c->width<c- o="">*</c-><c- mf="">0.7</c-><c- p="">))</c-> <c- o="">%</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->width<c- o="">*</c-><c- mf="">1.1</c-><c- p="">))</c-><c- o="">+</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->
     context<c- p="">.</c->beginPath<c- p="">();</c->
     context<c- p="">.</c->rect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->horizon <c- o="">-</c-> <c- mf="">5</c-><c- p="">,</c-> <c- mf="">25</c-><c- p="">,</c-> <c- mf="">25</c-><c- p="">);</c->
     context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- t="">'rgb(220,154,94)'</c-><c- p="">;</c->
     context<c- p="">.</c->lineStyle <c- o="">=</c-> <c- t="">'rgb(10,10,10)'</c-><c- p="">;</c->
     context<c- p="">.</c->lineWidth <c- o="">=</c-> <c- mf="">2</c-><c- p="">;</c->
     context<c- p="">.</c->fill<c- p="">();</c->
     context<c- p="">.</c->stroke<c- p="">();</c->
     context<c- p="">.</c->restore<c- p="">();</c->
   <c- p="">};</c->
 <c- p="">};</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> BlueRobot <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
   <c- k="">this</c-><c- p="">.</c->sprites <c- o="">=</c-> <c- k="">new</c-> Image<c- p="">();</c->
   <c- k="">this</c-><c- p="">.</c->sprites<c- p="">.</c->src <c- o="">=</c-> <c- t="">'blue-robot.png'</c-><c- p="">;</c-> <c- c1="">// this sprite sheet has 8 cells</c->
   <c- k="">this</c-><c- p="">.</c->targetMode <c- o="">=</c-> <c- t="">'idle'</c-><c- p="">;</c->
   <c- k="">this</c-><c- p="">.</c->walk <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
     <c- k="">this</c-><c- p="">.</c->targetMode <c- o="">=</c-> <c- t="">'walk'</c-><c- p="">;</c->
   <c- p="">};</c->
   <c- k="">this</c-><c- p="">.</c->stop <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
     <c- k="">this</c-><c- p="">.</c->targetMode <c- o="">=</c-> <c- t="">'idle'</c-><c- p="">;</c->
   <c- p="">};</c->
   <c- k="">this</c-><c- p="">.</c->frameIndex <c- o="">=</c-> <c- p="">{</c->
     <c- t="">'idle'</c-><c- o="">:</c-> <c- p="">[</c-><c- mf="">0</c-><c- p="">],</c-> <c- c1="">// first cell is the idle frame</c->
     <c- t="">'walk'</c-><c- o="">:</c-> <c- p="">[</c-><c- mf="">1</c-><c- p="">,</c-><c- mf="">2</c-><c- p="">,</c-><c- mf="">3</c-><c- p="">,</c-><c- mf="">4</c-><c- p="">,</c-><c- mf="">5</c-><c- p="">,</c-><c- mf="">6</c-><c- p="">],</c-> <c- c1="">// the walking animation is cells 1-6</c->
     <c- t="">'stop'</c-><c- o="">:</c-> <c- p="">[</c-><c- mf="">7</c-><c- p="">],</c-> <c- c1="">// last cell is the stopping animation</c->
   <c- p="">};</c->
   <c- k="">this</c-><c- p="">.</c->mode <c- o="">=</c-> <c- t="">'idle'</c-><c- p="">;</c->
   <c- k="">this</c-><c- p="">.</c->frame <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> <c- c1="">// index into frameIndex</c->
   <c- k="">this</c-><c- p="">.</c->tick <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
     <c- c1="">// this advances the frame and the robot</c->
     <c- c1="">// the return value is how many pixels the robot has moved</c->
     <c- k="">this</c-><c- p="">.</c->frame <c- o="">+=</c-> <c- mf="">1</c-><c- p="">;</c->
     <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->frame <c- o="">&gt;=</c-> <c- k="">this</c-><c- p="">.</c->frameIndex<c- p="">[</c-><c- k="">this</c-><c- p="">.</c->mode<c- p="">].</c->length<c- p="">)</c-> <c- p="">{</c->
       <c- c1="">// we've reached the end of this animation cycle</c->
       <c- k="">this</c-><c- p="">.</c->frame <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
       <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->mode <c- o="">!=</c-> <c- k="">this</c-><c- p="">.</c->targetMode<c- p="">)</c-> <c- p="">{</c->
         <c- c1="">// switch to next cycle</c->
         <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->mode <c- o="">==</c-> <c- t="">'walk'</c-><c- p="">)</c-> <c- p="">{</c->
           <c- c1="">// we need to stop walking before we decide what to do next</c->
           <c- k="">this</c-><c- p="">.</c->mode <c- o="">=</c-> <c- t="">'stop'</c-><c- p="">;</c->
         <c- p="">}</c-> <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->mode <c- o="">==</c-> <c- t="">'stop'</c-><c- p="">)</c-> <c- p="">{</c->
           <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->targetMode <c- o="">==</c-> <c- t="">'walk'</c-><c- p="">)</c->
             <c- k="">this</c-><c- p="">.</c->mode <c- o="">=</c-> <c- t="">'walk'</c-><c- p="">;</c->
           <c- k="">else</c->
             <c- k="">this</c-><c- p="">.</c->mode <c- o="">=</c-> <c- t="">'idle'</c-><c- p="">;</c->
         <c- p="">}</c-> <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->mode <c- o="">==</c-> <c- t="">'idle'</c-><c- p="">)</c-> <c- p="">{</c->
           <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->targetMode <c- o="">==</c-> <c- t="">'walk'</c-><c- p="">)</c->
             <c- k="">this</c-><c- p="">.</c->mode <c- o="">=</c-> <c- t="">'walk'</c-><c- p="">;</c->
         <c- p="">}</c->
       <c- p="">}</c->
     <c- p="">}</c->
     <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->mode <c- o="">==</c-> <c- t="">'walk'</c-><c- p="">)</c->
       <c- k="">return</c-> <c- mf="">8</c-><c- p="">;</c->
     <c- k="">return</c-> <c- mf="">0</c-><c- p="">;</c->
   <c- p="">},</c->
   <c- k="">this</c-><c- p="">.</c->paint <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->context<c- p="">,</c-> x<c- p="">,</c-> y<c- p="">)</c-> <c- p="">{</c->
     <c- k="">if</c-> <c- p="">(</c-><c- o="">!</c-><c- k="">this</c-><c- p="">.</c->sprites<c- p="">.</c->complete<c- p="">)</c-> <c- k="">return</c-><c- p="">;</c->
     <c- c1="">// draw the right frame out of the sprite sheet onto the canvas</c->
     <c- c1="">// we assume each frame is as high as the sprite sheet</c->
     <c- c1="">// the x,y coordinates give the position of the bottom center of the sprite</c->
     context<c- p="">.</c->drawImage<c- p="">(</c-><c- k="">this</c-><c- p="">.</c->sprites<c- p="">,</c->
                       <c- k="">this</c-><c- p="">.</c->frameIndex<c- p="">[</c-><c- k="">this</c-><c- p="">.</c->mode<c- p="">][</c-><c- k="">this</c-><c- p="">.</c->frame<c- p="">]</c-> <c- o="">*</c-> <c- k="">this</c-><c- p="">.</c->sprites<c- p="">.</c->height<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->sprites<c- p="">.</c->height<c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->sprites<c- p="">.</c->height<c- p="">,</c->
                       x<c- o="">-</c-><c- k="">this</c-><c- p="">.</c->sprites<c- p="">.</c->height<c- o="">/</c-><c- mf="">2</c-><c- p="">,</c-> y<c- o="">-</c-><c- k="">this</c-><c- p="">.</c->sprites<c- p="">.</c->height<c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->sprites<c- p="">.</c->height<c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->sprites<c- p="">.</c->height<c- p="">);</c->
   <c- p="">};</c->
 <c- p="">};</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> canvas <c- o="">=</c-> document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
 <c- a="">var</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">);</c->
 <c- a="">var</c-> landscape <c- o="">=</c-> <c- k="">new</c-> Landscape<c- p="">(</c->context<c- p="">,</c-> canvas<c- p="">.</c->width<c- p="">,</c-> canvas<c- p="">.</c->height<c- p="">);</c->
 <c- a="">var</c-> blueRobot <c- o="">=</c-> <c- k="">new</c-> BlueRobot<c- p="">();</c->
 <c- c1="">// paint when the browser wants us to, using requestAnimationFrame()</c->
 <c- a="">function</c-> paint<c- p="">()</c-> <c- p="">{</c->
   context<c- p="">.</c->clearRect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> canvas<c- p="">.</c->width<c- p="">,</c-> canvas<c- p="">.</c->height<c- p="">);</c->
   landscape<c- p="">.</c->paintBackground<c- p="">(</c->context<c- p="">,</c-> canvas<c- p="">.</c->width<c- p="">,</c-> canvas<c- p="">.</c->height<c- p="">);</c->
   blueRobot<c- p="">.</c->paint<c- p="">(</c->context<c- p="">,</c-> canvas<c- p="">.</c->width<c- o="">/</c-><c- mf="">2</c-><c- p="">,</c-> landscape<c- p="">.</c->horizon<c- o="">*</c-><c- mf="">1.1</c-><c- p="">);</c->
   landscape<c- p="">.</c->paintForeground<c- p="">(</c->context<c- p="">,</c-> canvas<c- p="">.</c->width<c- p="">,</c-> canvas<c- p="">.</c->height<c- p="">);</c->
   requestAnimationFrame<c- p="">(</c->paint<c- p="">);</c->
 <c- p="">}</c->
 paint<c- p="">();</c->
 <c- c1="">// but tick every 100ms, so that we don't slow down when we don't paint</c->
 setInterval<c- p="">(</c-><c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
   <c- a="">var</c-> dx <c- o="">=</c-> blueRobot<c- p="">.</c->tick<c- p="">();</c->
   landscape<c- p="">.</c->advance<c- p="">(</c->dx<c- p="">);</c->
 <c- p="">},</c-> <c- mf="">100</c-><c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"buttons"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Walk"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"blueRobot.walk()"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Stop"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"blueRobot.stop()"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">small</c-><c- p="">&gt;</c-> Blue Robot Player Sprite by <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://johncolburn.deviantart.com/"</c-><c- p="">&gt;</c->JohnColburn<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.
 Licensed under the terms of the Creative Commons Attribution Share-Alike 3.0 Unported license.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">small</c-><c- p="">&gt;</c-> This work is itself licensed under a <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">rel</c-><c- o="">=</c-><c- s="">"license"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://creativecommons.org/licenses/by-sa/3.0/"</c-><c- p="">&gt;</c->Creative
 Commons Attribution-ShareAlike 3.0 Unported License<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
</code></pre>

  </div>




  <h5 id="the-imagebitmap-rendering-context"><span class="secno">4.12.5.2</span> The <code id="the-imagebitmap-rendering-context:imagebitmap"><a href="#imagebitmap">ImageBitmap</a></code> rendering context<a href="#the-imagebitmap-rendering-context" class="self-link"></a></h5>

  <h6 id="introduction-6"><span class="secno">4.12.5.2.1</span> Introduction<a href="#introduction-6" class="self-link"></a></h6>

  <p><code id="introduction-6:imagebitmaprenderingcontext"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> is a performance-oriented interface that provides a
  low overhead method for displaying the contents of <code id="introduction-6:imagebitmap"><a href="#imagebitmap">ImageBitmap</a></code> objects. It uses
  transfer semantics to reduce overall memory consumption. It also streamlines performance by
  avoiding intermediate compositing, unlike the <code id="introduction-6:dom-context-2d-drawimage"><a href="#dom-context-2d-drawimage">drawImage()</a></code> method of
  <code id="introduction-6:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code>.</p>

  <p>Using an <code id="introduction-6:the-img-element"><a href="#the-img-element">img</a></code> element as an intermediate for getting an image resource into a
  canvas, for example, would result in two copies of the decoded image existing in memory at the
  same time: the <code id="introduction-6:the-img-element-2"><a href="#the-img-element">img</a></code> element's copy, and the one in the canvas's backing store. This
  memory cost can be prohibitive when dealing with extremely large images. This can be avoided by
  using <code id="introduction-6:imagebitmaprenderingcontext-2"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code>.</p>

  <div class="example">
   <p>Using <code id="introduction-6:imagebitmaprenderingcontext-3"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code>, here is how to transcode an image to the JPEG
   format in a memory- and CPU-efficient way:</p>

   <pre><code class="js">createImageBitmap<c- p="">(</c->inputImageBlob<c- p="">).</c->then<c- p="">(</c->image <c- p="">=&gt;</c-> <c- p="">{</c->
  <c- a="">const</c-> canvas <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'canvas'</c-><c- p="">);</c->
  <c- a="">const</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'bitmaprenderer'</c-><c- p="">);</c->
  context<c- p="">.</c->transferFromImageBitmap<c- p="">(</c->image<c- p="">);</c->

  canvas<c- p="">.</c->toBlob<c- p="">(</c->outputJPEGBlob <c- p="">=&gt;</c-> <c- p="">{</c->
    <c- c1="">// Do something with outputJPEGBlob.</c->
  <c- p="">},</c-> <c- t="">'image/jpeg'</c-><c- p="">);</c->
<c- p="">});</c-></code></pre>
  </div>

  <h6 id="the-imagebitmaprenderingcontext-interface"><span class="secno">4.12.5.2.2</span> The <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> interface<a href="#the-imagebitmaprenderingcontext-interface" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmapRenderingContext" title="The ImageBitmapRenderingContext interface is a canvas rendering context that provides the functionality to replace the canvas's contents with the given ImageBitmap. Its context id (the first argument to HTMLCanvasElement.getContext() or OffscreenCanvas.getContext()) is &quot;bitmaprenderer&quot;.">ImageBitmapRenderingContext</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>46+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>66+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="imagebitmaprenderingcontext" data-dfn-type="interface"><c- g="">ImageBitmapRenderingContext</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> (<a href="#htmlcanvaselement" id="the-imagebitmaprenderingcontext-interface:htmlcanvaselement"><c- n="">HTMLCanvasElement</c-></a> <c- b="">or</c-> <a href="#offscreencanvas" id="the-imagebitmaprenderingcontext-interface:offscreencanvas"><c- n="">OffscreenCanvas</c-></a>) <a href="#dom-imagebitmaprenderingcontext-canvas" id="the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontext-canvas"><c- g="">canvas</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-imagebitmaprenderingcontext-transferfromimagebitmap" id="the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontext-transferfromimagebitmap"><c- g="">transferFromImageBitmap</c-></a>(<a href="#imagebitmap" id="the-imagebitmaprenderingcontext-interface:imagebitmap"><c- n="">ImageBitmap</c-></a>? <c- g="">bitmap</c->);
};

<c- b="">dictionary</c-> <dfn id="imagebitmaprenderingcontextsettings" data-dfn-type="dictionary"><c- g="">ImageBitmapRenderingContextSettings</c-></dfn> {
  <c- b="">boolean</c-> <a href="#dom-imagebitmaprenderingcontextsettings-alpha" id="the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontextsettings-alpha"><c- g="">alpha</c-></a> = <c- b="">true</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>context</var> = <var>canvas</var>.<a href="#dom-canvas-getcontext" id="the-imagebitmaprenderingcontext-interface:dom-canvas-getcontext">getContext</a>('bitmaprenderer' [, { [ <a href="#dom-imagebitmaprenderingcontextsettings-alpha" id="the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontextsettings-alpha-2">alpha</a>: false ] } ])</code></dt><dd>
    <p>Returns an <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext-2"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> object that is permanently bound to a
    particular <code id="the-imagebitmaprenderingcontext-interface:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element.</p>

    <p>If the <code id="the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontextsettings-alpha-3"><a href="#dom-imagebitmaprenderingcontextsettings-alpha">alpha</a></code> setting is
    provided and set to false, then the canvas is forced to always be opaque.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-imagebitmaprenderingcontext-canvas" id="dom-imagebitmaprenderingcontext-canvas-dev">canvas</a></code></dt><dd><p>Returns the <code id="the-imagebitmaprenderingcontext-interface:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> element that the context is bound to.</p></dd><dt><code><var>context</var>.<a href="#dom-imagebitmaprenderingcontext-transferfromimagebitmap" id="dom-imagebitmaprenderingcontext-transferfromimagebitmap-dev">transferFromImageBitmap</a>(imageBitmap)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmapRenderingContext/transferFromImageBitmap" title="The ImageBitmapRenderingContext.transferFromImageBitmap() method displays the given ImageBitmap in the canvas associated with this rendering context. The ownership of the ImageBitmap is transferred to the canvas as well.">ImageBitmapRenderingContext/transferFromImageBitmap</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>66+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Transfers the underlying <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmap-bitmap-data">bitmap data</a>
    from <var>imageBitmap</var> to <var>context</var>, and the bitmap becomes the contents of the
    <code id="the-imagebitmaprenderingcontext-interface:the-canvas-element-3"><a href="#the-canvas-element">canvas</a></code> element to which <var>context</var> is bound.</p>
   </dd><dt><code><var>context</var>.<a href="#dom-imagebitmaprenderingcontext-transferfromimagebitmap" id="the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontext-transferfromimagebitmap-2">transferFromImageBitmap</a>(null)</code></dt><dd>
    <p>Replaces contents of the <code id="the-imagebitmaprenderingcontext-interface:the-canvas-element-4"><a href="#the-canvas-element">canvas</a></code> element to which <var>context</var> is bound
    with a <a id="the-imagebitmaprenderingcontext-interface:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> bitmap whose size corresponds to the <code id="the-imagebitmaprenderingcontext-interface:attr-canvas-width"><a href="#attr-canvas-width">width</a></code> and <code id="the-imagebitmaprenderingcontext-interface:attr-canvas-height"><a href="#attr-canvas-height">height</a></code>
    content attributes of the <code id="the-imagebitmaprenderingcontext-interface:the-canvas-element-5"><a href="#the-canvas-element">canvas</a></code> element.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ImageBitmapRenderingContext" id="dom-imagebitmaprenderingcontext-canvas" data-dfn-type="attribute"><code>canvas</code></dfn> attribute must return the
  value it was initialized to when the object was created.</p>
  </div>

  <p>An <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext-3"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> object has an <dfn id="concept-imagebitmaprenderingcontext-output-bitmap">output bitmap</dfn>, which is a
  reference to <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmap-bitmap-data-2">bitmap data</a>.</p>

  <p>An <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext-4"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> object has a <dfn id="concept-imagebitmaprenderingcontext-bitmap-mode">bitmap mode</dfn>, which can be set to
  <dfn id="concept-imagebitmaprenderingcontext-valid">valid</dfn> or <dfn id="concept-imagebitmaprenderingcontext-blank">blank</dfn>. A value of <a href="#concept-imagebitmaprenderingcontext-valid" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-valid">valid</a> indicates that the context's
  <a href="#concept-imagebitmaprenderingcontext-output-bitmap" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-output-bitmap">output bitmap</a> refers to
  <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmap-bitmap-data-3">bitmap data</a> that was acquired via <code id="the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontext-transferfromimagebitmap-3"><a href="#dom-imagebitmaprenderingcontext-transferfromimagebitmap">transferFromImageBitmap()</a></code>.
  A value <a href="#concept-imagebitmaprenderingcontext-blank" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-blank">blank</a> indicates that the
  context's <a href="#concept-imagebitmaprenderingcontext-output-bitmap" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-output-bitmap-2">output
  bitmap</a> is a default transparent bitmap.</p>

  <div data-algorithm="">
  <p>An <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext-5"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> object also has an <dfn id="concept-imagebitmaprenderingcontext-alpha">alpha</dfn> flag, which can be set to true or
  false. When an <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext-6"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> object has its <a href="#concept-imagebitmaprenderingcontext-alpha" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-alpha">alpha</a> flag set to false, the contents
  of the <code id="the-imagebitmaprenderingcontext-interface:the-canvas-element-6"><a href="#the-canvas-element">canvas</a></code> element to which the context is bound are obtained by
  compositing the context's <a href="#concept-imagebitmaprenderingcontext-output-bitmap" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-output-bitmap-3">output bitmap</a> onto an
  <a id="the-imagebitmaprenderingcontext-interface:opaque-black" href="https://drafts.csswg.org/css-color/#opaque-black" data-x-internal="opaque-black">opaque black</a> bitmap of the same size using the <a href="https://drafts.fxtf.org/compositing/#porterduffcompositingoperators_srcover" id="the-imagebitmaprenderingcontext-interface:gcop-source-over" data-x-internal="gcop-source-over">source-over</a> compositing operator. If the <a href="#concept-imagebitmaprenderingcontext-alpha" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-alpha-2">alpha</a> flag is set to true, then the
  <a href="#concept-imagebitmaprenderingcontext-output-bitmap" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-output-bitmap-4">output bitmap</a> is used as
  the contents of the <code id="the-imagebitmaprenderingcontext-interface:the-canvas-element-7"><a href="#the-canvas-element">canvas</a></code> element to which the context is bound.
  <a href="#refsCOMPOSITE">[COMPOSITE]</a></p>
  </div>

  <p class="note">The step of compositing over an <a id="the-imagebitmaprenderingcontext-interface:opaque-black-2" href="https://drafts.csswg.org/css-color/#opaque-black" data-x-internal="opaque-black">opaque black</a> bitmap ought to be
  elided whenever equivalent results can be obtained more efficiently by other means.</p>

  <hr>

  <div data-algorithm="">
  <p>When a user agent is required to <dfn id="set-an-imagebitmaprenderingcontext's-output-bitmap">set an <code>ImageBitmapRenderingContext</code>'s output
  bitmap</dfn>, with a <var>context</var> argument that is an
  <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext-7"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> object and an optional argument <var>bitmap</var> that
  refers to <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmap-bitmap-data-4">bitmap data</a>, it must run these
  steps:</p>

  <ol><li><p>If a <var>bitmap</var> argument was not provided, then:</p>

    <ol><li><p>Set <var>context</var>'s <a href="#concept-imagebitmaprenderingcontext-bitmap-mode" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-bitmap-mode">bitmap mode</a> to <a href="#concept-imagebitmaprenderingcontext-blank" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-blank-2">blank</a>.</p></li><li><p>Let <var>canvas</var> be the <code id="the-imagebitmaprenderingcontext-interface:the-canvas-element-8"><a href="#the-canvas-element">canvas</a></code> element to which <var>context</var>
     is bound.</p></li><li><p>Set <var>context</var>'s <a href="#concept-imagebitmaprenderingcontext-output-bitmap" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-output-bitmap-5">output bitmap</a> to be
     <a id="the-imagebitmaprenderingcontext-interface:transparent-black-2" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> with a <a id="the-imagebitmaprenderingcontext-interface:natural-width" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> equal to <a href="#obtain-numeric-values" id="the-imagebitmaprenderingcontext-interface:obtain-numeric-values">the numeric value</a> of <var>canvas</var>'s <code id="the-imagebitmaprenderingcontext-interface:attr-canvas-width-2"><a href="#attr-canvas-width">width</a></code> attribute and a <a id="the-imagebitmaprenderingcontext-interface:natural-height" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a> equal
     to <a href="#obtain-numeric-values" id="the-imagebitmaprenderingcontext-interface:obtain-numeric-values-2">the numeric value</a> of <var>canvas</var>'s
     <code id="the-imagebitmaprenderingcontext-interface:attr-canvas-height-2"><a href="#attr-canvas-height">height</a></code> attribute, those values being interpreted
     in <a href="https://drafts.csswg.org/css-values/#px" id="the-imagebitmaprenderingcontext-interface:'px'" data-x-internal="'px'">CSS pixels</a>.</p></li><li><p>Set the <a href="#concept-imagebitmaprenderingcontext-output-bitmap" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-output-bitmap-6">output bitmap</a>'s <a href="#concept-canvas-origin-clean" id="the-imagebitmaprenderingcontext-interface:concept-canvas-origin-clean">origin-clean</a> flag to true.</p></li></ol>
   </li><li><p>If a <var>bitmap</var> argument was provided, then:</p>

    <ol><li><p>Set <var>context</var>'s <a href="#concept-imagebitmaprenderingcontext-bitmap-mode" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-bitmap-mode-2">bitmap mode</a> to <a href="#concept-imagebitmaprenderingcontext-valid" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-valid-2">valid</a>.</p></li><li>
      <p>Set <var>context</var>'s <a href="#concept-imagebitmaprenderingcontext-output-bitmap" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-output-bitmap-7">output bitmap</a> to refer
      to the same underlying bitmap data as <var>bitmap</var>, without making a copy.</p>

      <p class="note">The <a href="#concept-canvas-origin-clean" id="the-imagebitmaprenderingcontext-interface:concept-canvas-origin-clean-2">origin-clean</a> flag of
      <var>bitmap</var> is included in the bitmap data to be referenced by <var>context</var>'s
      <a href="#concept-imagebitmaprenderingcontext-output-bitmap" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-output-bitmap-8">output bitmap</a>.</p>
     </li></ol>
   </li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="imagebitmaprenderingcontext-creation-algorithm"><code>ImageBitmapRenderingContext</code> creation algorithm</dfn>, which is passed a
  <var>target</var> and <var>options</var>, consists of running these steps:</p>

  <ol><li><p>Let <var>settings</var> be the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="the-imagebitmaprenderingcontext-interface:concept-idl-convert" data-x-internal="concept-idl-convert">converting</a> <var>options</var> to the dictionary type
   <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontextsettings"><a href="#imagebitmaprenderingcontextsettings">ImageBitmapRenderingContextSettings</a></code>. (This can throw an exception.)</p></li><li><p>Let <var>context</var> be a new <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext-8"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> object.</p></li><li><p>Initialize <var>context</var>'s <code id="the-imagebitmaprenderingcontext-interface:dom-context-2d-canvas"><a href="#dom-context-2d-canvas">canvas</a></code>
   attribute to point to <var>target</var>.</p></li><li><p>Set <var>context</var>'s <a href="#concept-imagebitmaprenderingcontext-output-bitmap" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-output-bitmap-9">output bitmap</a> to the same
   bitmap as <var>target</var>'s bitmap (so that they are shared).</p></li><li><p>Run the steps to <a href="#set-an-imagebitmaprenderingcontext's-output-bitmap" id="the-imagebitmaprenderingcontext-interface:set-an-imagebitmaprenderingcontext's-output-bitmap">set an <code>ImageBitmapRenderingContext</code>'s output
   bitmap</a> with <var>context</var>.</p></li><li><p>Initialize <var>context</var>'s <a href="#concept-imagebitmaprenderingcontext-alpha" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-alpha-3">alpha</a> flag to true.

   </p></li><li>
    <p>Process each of the members of <var>settings</var> as follows:</p>

    <dl><dt><dfn data-dfn-for="ImageBitmapRenderingContextSettings" id="dom-imagebitmaprenderingcontextsettings-alpha" data-dfn-type="dict-member"><code>alpha</code></dfn></dt><dd>If false, then set <var>context</var>'s <a href="#concept-imagebitmaprenderingcontext-alpha" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmaprenderingcontext-alpha-4">alpha</a> flag to false.</dd></dl>
   </li><li><p>Return <var>context</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ImageBitmapRenderingContext" id="dom-imagebitmaprenderingcontext-transferfromimagebitmap" data-dfn-type="method"><code>transferFromImageBitmap(<var>bitmap</var>)</code></dfn>
  method, when invoked, must run these steps:</p>

  <ol><li><p>Let <var>bitmapContext</var> be the <code id="the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext-9"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code> object on
   which the <code id="the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontext-transferfromimagebitmap-4"><a href="#dom-imagebitmaprenderingcontext-transferfromimagebitmap">transferFromImageBitmap()</a></code>
   method was called.</p></li><li><p>If <var>bitmap</var> is null, then run the steps to <a href="#set-an-imagebitmaprenderingcontext's-output-bitmap" id="the-imagebitmaprenderingcontext-interface:set-an-imagebitmaprenderingcontext's-output-bitmap-2">set an
   ImageBitmapRenderingContext's output bitmap</a>, with <var>bitmapContext</var> as the
   <i>context</i> argument and no <i>bitmap</i> argument, then return.</p></li><li><p>If the value of <var>bitmap</var>'s <a href="#detached" id="the-imagebitmaprenderingcontext-interface:detached">[[Detached]]</a> internal slot is set to
   true, then throw an <a id="the-imagebitmaprenderingcontext-interface:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-imagebitmaprenderingcontext-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Run the steps to <a href="#set-an-imagebitmaprenderingcontext's-output-bitmap" id="the-imagebitmaprenderingcontext-interface:set-an-imagebitmaprenderingcontext's-output-bitmap-3">set an <code>ImageBitmapRenderingContext</code>'s output
   bitmap</a>, with the <i>context</i> argument equal to <var>bitmapContext</var>, and the
   <i>bitmap</i> argument referring to <var>bitmap</var>'s underlying <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmap-bitmap-data-5">bitmap data</a>.

   </p></li><li><p>Set the value of <var>bitmap</var>'s <a href="#detached" id="the-imagebitmaprenderingcontext-interface:detached-2">[[Detached]]</a> internal slot to
   true.</p></li><li><p>Unset <var>bitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmaprenderingcontext-interface:concept-imagebitmap-bitmap-data-6">bitmap
   data</a>.</p></li></ol>
  </div>

  




  <h5 id="the-offscreencanvas-interface"><span class="secno">4.12.5.3</span> The <code id="the-offscreencanvas-interface:offscreencanvas"><a href="#offscreencanvas">OffscreenCanvas</a></code> interface<a href="#the-offscreencanvas-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas" title="When using the <canvas> element or the Canvas API, rendering, animation, and user interaction usually happen on the main execution thread of a web application. The computation relating to canvas animations and rendering can have a significant impact on application performance.">OffscreenCanvas</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>105+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <pre><code class="idl"><c- b="">typedef</c-> (<a href="#offscreencanvasrenderingcontext2d" id="the-offscreencanvas-interface:offscreencanvasrenderingcontext2d"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">or</c-> <a href="#imagebitmaprenderingcontext" id="the-offscreencanvas-interface:imagebitmaprenderingcontext"><c- n="">ImageBitmapRenderingContext</c-></a> <c- b="">or</c-> <a id="the-offscreencanvas-interface:webglrenderingcontext" href="https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContext" data-x-internal="webglrenderingcontext"><c- n="">WebGLRenderingContext</c-></a> <c- b="">or</c-> <a id="the-offscreencanvas-interface:webgl2renderingcontext" href="https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext" data-x-internal="webgl2renderingcontext"><c- n="">WebGL2RenderingContext</c-></a> <c- b="">or</c-> <a id="the-offscreencanvas-interface:gpucanvascontext" href="https://gpuweb.github.io/gpuweb/#canvas-context" data-x-internal="gpucanvascontext"><c- n="">GPUCanvasContext</c-></a>) <dfn id="offscreenrenderingcontext" data-dfn-type="typedef"><c- g="">OffscreenRenderingContext</c-></dfn>;

<c- b="">dictionary</c-> <dfn id="imageencodeoptions" data-dfn-type="dictionary"><c- g="">ImageEncodeOptions</c-></dfn> {
  <c- b="">DOMString</c-> <a href="#image-encode-options-type" id="the-offscreencanvas-interface:image-encode-options-type"><c- g="">type</c-></a> = "image/png";
  <c- b="">unrestricted</c-> <c- b="">double</c-> <a href="#image-encode-options-quality" id="the-offscreencanvas-interface:image-encode-options-quality"><c- g="">quality</c-></a>;
};

<c- b="">enum</c-> <dfn id="offscreenrenderingcontextid" data-dfn-type="enum"><c- g="">OffscreenRenderingContextId</c-></dfn> { <c- s="">"</c-><a href="#offscreen-context-type-2d" id="the-offscreencanvas-interface:offscreen-context-type-2d"><c- s="">2d</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#offscreen-context-type-bitmaprenderer" id="the-offscreencanvas-interface:offscreen-context-type-bitmaprenderer"><c- s="">bitmaprenderer</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#offscreen-context-type-webgl" id="the-offscreencanvas-interface:offscreen-context-type-webgl"><c- s="">webgl</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#offscreen-context-type-webgl2" id="the-offscreencanvas-interface:offscreen-context-type-webgl2"><c- s="">webgl2</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#offscreen-context-type-webgpu" id="the-offscreencanvas-interface:offscreen-context-type-webgpu"><c- s="">webgpu</c-></a><c- s="">"</c-> };

[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->), <a href="#transferable" id="the-offscreencanvas-interface:transferable"><c- g="">Transferable</c-></a>]
<c- b="">interface</c-> <dfn id="offscreencanvas" data-dfn-type="interface"><c- g="">OffscreenCanvas</c-></dfn> : <a id="the-offscreencanvas-interface:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <a href="#dom-offscreencanvas" id="the-offscreencanvas-interface:dom-offscreencanvas"><c- g="">constructor</c-></a>([<c- g="">EnforceRange</c->] <c- b="">unsigned</c-> <c- b="">long</c-> <c- b="">long</c-> <c- g="">width</c->, [<c- g="">EnforceRange</c->] <c- b="">unsigned</c-> <c- b="">long</c-> <c- b="">long</c-> <c- g="">height</c->);

  <c- b="">attribute</c-> [<c- g="">EnforceRange</c->] <c- b="">unsigned</c-> <c- b="">long</c-> <c- b="">long</c-> <a href="#dom-offscreencanvas-width" id="the-offscreencanvas-interface:dom-offscreencanvas-width"><c- g="">width</c-></a>;
  <c- b="">attribute</c-> [<c- g="">EnforceRange</c->] <c- b="">unsigned</c-> <c- b="">long</c-> <c- b="">long</c-> <a href="#dom-offscreencanvas-height" id="the-offscreencanvas-interface:dom-offscreencanvas-height"><c- g="">height</c-></a>;

  <a href="#offscreenrenderingcontext" id="the-offscreencanvas-interface:offscreenrenderingcontext"><c- n="">OffscreenRenderingContext</c-></a>? <a href="#dom-offscreencanvas-getcontext" id="the-offscreencanvas-interface:dom-offscreencanvas-getcontext"><c- g="">getContext</c-></a>(<a href="#offscreenrenderingcontextid" id="the-offscreencanvas-interface:offscreenrenderingcontextid"><c- n="">OffscreenRenderingContextId</c-></a> <c- g="">contextId</c->, <c- b="">optional</c-> <c- b="">any</c-> <c- g="">options</c-> = <c- b="">null</c->);
  <a href="#imagebitmap" id="the-offscreencanvas-interface:imagebitmap"><c- n="">ImageBitmap</c-></a> <a href="#dom-offscreencanvas-transfertoimagebitmap" id="the-offscreencanvas-interface:dom-offscreencanvas-transfertoimagebitmap"><c- g="">transferToImageBitmap</c-></a>();
  <a href="https://webidl.spec.whatwg.org/#idl-promise" id="the-offscreencanvas-interface:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<a id="the-offscreencanvas-interface:blob" href="https://w3c.github.io/FileAPI/#dfn-Blob" data-x-internal="blob"><c- n="">Blob</c-></a>&gt; <a href="#dom-offscreencanvas-converttoblob" id="the-offscreencanvas-interface:dom-offscreencanvas-converttoblob"><c- g="">convertToBlob</c-></a>(<c- b="">optional</c-> <a href="#imageencodeoptions" id="the-offscreencanvas-interface:imageencodeoptions"><c- n="">ImageEncodeOptions</c-></a> <c- g="">options</c-> = {});

  <c- b="">attribute</c-> <a href="#eventhandler" id="the-offscreencanvas-interface:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-offscreencanvas-oncontextlost" id="the-offscreencanvas-interface:handler-offscreencanvas-oncontextlost"><c- g="">oncontextlost</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-offscreencanvas-interface:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-offscreencanvas-oncontextrestored" id="the-offscreencanvas-interface:handler-offscreencanvas-oncontextrestored"><c- g="">oncontextrestored</c-></a>;
};</code></pre>

  <p class="note"><code id="the-offscreencanvas-interface:offscreencanvas-2"><a href="#offscreencanvas">OffscreenCanvas</a></code> is an <code id="the-offscreencanvas-interface:eventtarget-2"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code>, so both
  <code id="the-offscreencanvas-interface:offscreencanvasrenderingcontext2d-2"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code> and WebGL can fire events at it.
  <code id="the-offscreencanvas-interface:offscreencanvasrenderingcontext2d-3"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code> can fire <code id="the-offscreencanvas-interface:event-contextlost"><a href="#event-contextlost">contextlost</a></code> and <code id="the-offscreencanvas-interface:event-contextrestored"><a href="#event-contextrestored">contextrestored</a></code>, and WebGL can fire <code>webglcontextlost</code> and <code>webglcontextrestored</code>.
  <a href="#refsWEBGL">[WEBGL]</a></p>

  <p><code id="the-offscreencanvas-interface:offscreencanvas-3"><a href="#offscreencanvas">OffscreenCanvas</a></code> objects are used to create rendering contexts, much like an
  <code id="the-offscreencanvas-interface:htmlcanvaselement"><a href="#htmlcanvaselement">HTMLCanvasElement</a></code>, but with no connection to the DOM. This makes it possible to
  use canvas rendering contexts in <a href="#workers">workers</a>.</p>

  <p>An <code id="the-offscreencanvas-interface:offscreencanvas-4"><a href="#offscreencanvas">OffscreenCanvas</a></code> object may hold a weak reference to a <dfn id="offscreencanvas-placeholder">placeholder <code>canvas</code> element</dfn>, which is
  typically in the DOM, whose embedded content is provided by the <code id="the-offscreencanvas-interface:offscreencanvas-5"><a href="#offscreencanvas">OffscreenCanvas</a></code>
  object. The bitmap of the <code id="the-offscreencanvas-interface:offscreencanvas-6"><a href="#offscreencanvas">OffscreenCanvas</a></code> object is pushed to the <a href="#offscreencanvas-placeholder" id="the-offscreencanvas-interface:offscreencanvas-placeholder">placeholder <code>canvas</code> element</a> as part of
  the <code id="the-offscreencanvas-interface:offscreencanvas-7"><a href="#offscreencanvas">OffscreenCanvas</a></code>'s <a href="#relevant-agent" id="the-offscreencanvas-interface:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="the-offscreencanvas-interface:concept-agent-event-loop">event loop</a>'s <a href="#update-the-rendering" id="the-offscreencanvas-interface:update-the-rendering">update the rendering</a>
  steps.</p>

  <dl class="domintro"><dt><code><var>offscreenCanvas</var> = new <a href="#dom-offscreencanvas" id="dom-offscreencanvas-dev">OffscreenCanvas</a>(<var>width</var>,
   <var>height</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/OffscreenCanvas" title="The OffscreenCanvas() constructor returns a newly instantiated OffscreenCanvas object.">OffscreenCanvas/OffscreenCanvas</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>105+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns a new <code id="the-offscreencanvas-interface:offscreencanvas-8"><a href="#offscreencanvas">OffscreenCanvas</a></code> object that is not linked to a <a href="#offscreencanvas-placeholder" id="the-offscreencanvas-interface:offscreencanvas-placeholder-2">placeholder <code>canvas</code> element</a>, and whose
    bitmap's size is determined by the <var>width</var> and <var>height</var> arguments.</p>
   </dd><dt><code><var>context</var> = <var>offscreenCanvas</var>.<a href="#dom-offscreencanvas-getcontext" id="dom-offscreencanvas-getcontext-dev">getContext</a>(<var>contextId</var> [,
   <var>options</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext" title="The OffscreenCanvas.getContext() method returns a drawing context for an offscreen canvas, or null if the context identifier is not supported.">OffscreenCanvas/getContext</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>105+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns an object that exposes an API for drawing on the <code id="the-offscreencanvas-interface:offscreencanvas-9"><a href="#offscreencanvas">OffscreenCanvas</a></code> object.
    <var>contextId</var> specifies the desired API: "<code id="the-offscreencanvas-interface:offscreen-context-type-2d-2"><a href="#offscreen-context-type-2d">2d</a></code>", "<code id="the-offscreencanvas-interface:offscreen-context-type-bitmaprenderer-2"><a href="#offscreen-context-type-bitmaprenderer">bitmaprenderer</a></code>", "<code id="the-offscreencanvas-interface:offscreen-context-type-webgl-2"><a href="#offscreen-context-type-webgl">webgl</a></code>", "<code id="the-offscreencanvas-interface:offscreen-context-type-webgl2-2"><a href="#offscreen-context-type-webgl2">webgl2</a></code>", or "<code id="the-offscreencanvas-interface:offscreen-context-type-webgpu-2"><a href="#offscreen-context-type-webgpu">webgpu</a></code>". <var>options</var> is handled by that
    API.</p>

    <p>This specification defines the "<code id="the-offscreencanvas-interface:canvas-context-2d"><a href="#canvas-context-2d">2d</a></code>" context below,
    which is similar but distinct from the "<code id="the-offscreencanvas-interface:offscreen-context-type-2d-3"><a href="#offscreen-context-type-2d">2d</a></code>"
    context that is created from a <code id="the-offscreencanvas-interface:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element. The WebGL specifications define the
    "<code id="the-offscreencanvas-interface:offscreen-context-type-webgl-3"><a href="#offscreen-context-type-webgl">webgl</a></code>" and "<code id="the-offscreencanvas-interface:offscreen-context-type-webgl2-3"><a href="#offscreen-context-type-webgl2">webgl2</a></code>" contexts. <cite>WebGPU</cite> defines the
    "<code id="the-offscreencanvas-interface:offscreen-context-type-webgpu-3"><a href="#offscreen-context-type-webgpu">webgpu</a></code>" context. <a href="#refsWEBGL">[WEBGL]</a>
    <a href="#refsWEBGPU">[WEBGPU]</a></p>

    <p>Returns null if the canvas has already been initialized with another context type (e.g.,
    trying to get a "<code id="the-offscreencanvas-interface:offscreen-context-type-2d-4"><a href="#offscreen-context-type-2d">2d</a></code>" context after getting a
    "<code id="the-offscreencanvas-interface:offscreen-context-type-webgl-4"><a href="#offscreen-context-type-webgl">webgl</a></code>" context).</p>
   </dd></dl>

  

  <p>An <code id="the-offscreencanvas-interface:offscreencanvas-10"><a href="#offscreencanvas">OffscreenCanvas</a></code> object has an internal <dfn id="offscreencanvas-bitmap">bitmap</dfn> that is initialized when the object
  is created. The width and height of the <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap">bitmap</a> are
  equal to the values of the <code id="the-offscreencanvas-interface:dom-offscreencanvas-width-2"><a href="#dom-offscreencanvas-width">width</a></code> and <code id="the-offscreencanvas-interface:dom-offscreencanvas-height-2"><a href="#dom-offscreencanvas-height">height</a></code> attributes of the <code id="the-offscreencanvas-interface:offscreencanvas-11"><a href="#offscreencanvas">OffscreenCanvas</a></code>
  object. Initially, all the bitmap's pixels are <a id="the-offscreencanvas-interface:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>.</p>

  <p>An <code id="the-offscreencanvas-interface:offscreencanvas-12"><a href="#offscreencanvas">OffscreenCanvas</a></code> object has an internal <dfn id="offscreencanvas-inherited-lang">inherited language</dfn> and <dfn id="offscreencanvas-inherited-direction">inherited direction</dfn> set when
  the <code id="the-offscreencanvas-interface:offscreencanvas-13"><a href="#offscreencanvas">OffscreenCanvas</a></code> is created.</p>

  <p>An <code id="the-offscreencanvas-interface:offscreencanvas-14"><a href="#offscreencanvas">OffscreenCanvas</a></code> object can have a rendering context bound to it. Initially,
  it does not have a bound rendering context. To keep track of whether it has a rendering context
  or not, and what kind of rendering context it is, an <code id="the-offscreencanvas-interface:offscreencanvas-15"><a href="#offscreencanvas">OffscreenCanvas</a></code> object also
  has a <dfn id="offscreencanvas-context-mode">context mode</dfn>, which is initially <dfn id="offscreencanvas-context-none">none</dfn> but can be changed to either <dfn id="offscreencanvas-context-2d">2d</dfn>, <dfn id="offscreencanvas-context-bitmaprenderer">bitmaprenderer</dfn>, <dfn id="offscreencanvas-context-webgl">webgl</dfn>, <dfn id="offscreencanvas-context-webgl2">webgl2</dfn>, <dfn id="offscreencanvas-context-webgpu">webgpu</dfn>, or <dfn id="offscreencanvas-context-detached">detached</dfn> by algorithms defined in this
  specification.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="OffscreenCanvas" id="dom-offscreencanvas" data-dfn-type="constructor"><code>new OffscreenCanvas(<var>width</var>,
  <var>height</var>)</code></dfn> constructor steps are:</p>

  <ol><li><p>Initialize the <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-2">bitmap</a> of <a id="the-offscreencanvas-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>
   to a rectangular array of <a id="the-offscreencanvas-interface:transparent-black-2" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> pixels of the dimensions specified
   by <var>width</var> and <var>height</var>.</p></li><li><p>Initialize the <code id="the-offscreencanvas-interface:dom-offscreencanvas-width-3"><a href="#dom-offscreencanvas-width">width</a></code> of <a id="the-offscreencanvas-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>
   to <var>width</var>.</p></li><li><p>Initialize the <code id="the-offscreencanvas-interface:dom-offscreencanvas-height-3"><a href="#dom-offscreencanvas-height">height</a></code> of
   <a id="the-offscreencanvas-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to <var>height</var>.</p></li><li><p>Set <a id="the-offscreencanvas-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#offscreencanvas-inherited-lang" id="the-offscreencanvas-interface:offscreencanvas-inherited-lang">inherited
   language</a> to <a href="#concept-explicitly-unknown" id="the-offscreencanvas-interface:concept-explicitly-unknown">explicitly unknown</a>.</p></li><li><p>Set <a id="the-offscreencanvas-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#offscreencanvas-inherited-direction" id="the-offscreencanvas-interface:offscreencanvas-inherited-direction">inherited
   direction</a> to "<code>ltr</code>".</p></li><li><p>Let <var>global</var> be the <a href="#concept-relevant-global" id="the-offscreencanvas-interface:concept-relevant-global">relevant global object</a> of
   <a id="the-offscreencanvas-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li>
    <p>If <var>global</var> is a <code id="the-offscreencanvas-interface:window"><a href="#window">Window</a></code> object:</p>

    <ol><li><p>Let <var>element</var> be the <a id="the-offscreencanvas-interface:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> of <var>global</var>'s
     <a href="#concept-document-window" id="the-offscreencanvas-interface:concept-document-window">associated <code>Document</code></a>.</p></li><li>
      <p>If <var>element</var> is not null:</p>

      <ol><li><p>Set the <a href="#offscreencanvas-inherited-lang" id="the-offscreencanvas-interface:offscreencanvas-inherited-lang-2">inherited language</a>
       of <a id="the-offscreencanvas-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to <var>element</var>'s <a href="#language" id="the-offscreencanvas-interface:language">language</a>.</p></li><li><p>Set the <a href="#offscreencanvas-inherited-direction" id="the-offscreencanvas-interface:offscreencanvas-inherited-direction-2">inherited
       direction</a> of <a id="the-offscreencanvas-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to <var>element</var>'s <a href="#the-directionality" id="the-offscreencanvas-interface:the-directionality">directionality</a>.</p></li></ol>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p><code id="the-offscreencanvas-interface:offscreencanvas-16"><a href="#offscreencanvas">OffscreenCanvas</a></code> objects are <a href="#transferable-objects" id="the-offscreencanvas-interface:transferable-objects">transferable</a>. Their <a href="#transfer-steps" id="the-offscreencanvas-interface:transfer-steps">transfer steps</a>, given <var>value</var> and
  <var>dataHolder</var>, are as follows:</p>

  <ol><li><p>If <var>value</var>'s <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode">context mode</a> is
   not equal to <a href="#offscreencanvas-context-none" id="the-offscreencanvas-interface:offscreencanvas-context-none">none</a>, then throw an
   <a id="the-offscreencanvas-interface:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-offscreencanvas-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>value</var>'s <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode-2">context mode</a> to
   <a href="#offscreencanvas-context-detached" id="the-offscreencanvas-interface:offscreencanvas-context-detached">detached</a>.</p></li><li><p>Let <var>width</var> and <var>height</var> be the dimensions of <var>value</var>'s <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-3">bitmap</a>.</p></li><li><p>Let <var>language</var> and <var>direction</var> be the values of <var>value</var>'s
   <a href="#offscreencanvas-inherited-lang" id="the-offscreencanvas-interface:offscreencanvas-inherited-lang-3">inherited language</a> and
   <a href="#offscreencanvas-inherited-direction" id="the-offscreencanvas-interface:offscreencanvas-inherited-direction-3">inherited direction</a>.</p></li><li><p>Unset <var>value</var>'s <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-4">bitmap</a>.</p></li><li><p>Set <var>dataHolder</var>.[[Width]] to <var>width</var> and
   <var>dataHolder</var>.[[Height]] to <var>height</var>.</p></li><li><p>Set <var>dataHolder</var>.[[Language]] to <var>language</var> and
   <var>dataHolder</var>.[[Direction]] to <var>direction</var>.</p></li><li><p>Set <var>dataHolder</var>.[[PlaceholderCanvas]] to be a weak reference to
   <var>value</var>'s <a href="#offscreencanvas-placeholder" id="the-offscreencanvas-interface:offscreencanvas-placeholder-3">placeholder <code>canvas</code>
   element</a>, if <var>value</var> has one, or null if it does not.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Their <a href="#transfer-receiving-steps" id="the-offscreencanvas-interface:transfer-receiving-steps">transfer-receiving steps</a>, given <var>dataHolder</var> and <var>value</var>,
  are:</p>

  <ol><li><p>Initialize <var>value</var>'s <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-5">bitmap</a> to a
   rectangular array of <a id="the-offscreencanvas-interface:transparent-black-3" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> pixels with width given by
   <var>dataHolder</var>.[[Width]] and height given by <var>dataHolder</var>.[[Height]].</p></li><li><p>Set <var>value</var>'s <a href="#offscreencanvas-inherited-lang" id="the-offscreencanvas-interface:offscreencanvas-inherited-lang-4">inherited
   language</a> to <var>dataHolder</var>.[[Language]] and its <a href="#offscreencanvas-inherited-direction" id="the-offscreencanvas-interface:offscreencanvas-inherited-direction-4">inherited direction</a> to
   <var>dataHolder</var>.[[Direction]].</p></li><li><p>If <var>dataHolder</var>.[[PlaceholderCanvas]] is not null, set <var>value</var>'s <a href="#offscreencanvas-placeholder" id="the-offscreencanvas-interface:offscreencanvas-placeholder-4">placeholder <code>canvas</code> element</a> to
   <var>dataHolder</var>.[[PlaceholderCanvas]] (while maintaining the weak reference
   semantics).</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="OffscreenCanvas" id="dom-offscreencanvas-getcontext" data-dfn-type="method"><code>getContext(<var>contextId</var>,
  <var>options</var>)</code></dfn> method of an <code id="the-offscreencanvas-interface:offscreencanvas-17"><a href="#offscreencanvas">OffscreenCanvas</a></code> object, when invoked,
  must run these steps:</p>

  <ol><li><p>If <var>options</var> is not an <a href="https://webidl.spec.whatwg.org/#idl-object" id="the-offscreencanvas-interface:idl-object" data-x-internal="idl-object">object</a>, then set
   <var>options</var> to null.</p></li><li><p>Set <var>options</var> to the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="the-offscreencanvas-interface:concept-idl-convert" data-x-internal="concept-idl-convert">converting</a> <var>options</var> to a JavaScript value.</p></li><li>
    <p>Run the steps in the cell of the following table whose column header matches this
    <code id="the-offscreencanvas-interface:offscreencanvas-18"><a href="#offscreencanvas">OffscreenCanvas</a></code> object's <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode-3">context
    mode</a> and whose row header matches <var>contextId</var>:</p>

    <table><thead><tr><td>
       </td><th><a href="#offscreencanvas-context-none" id="the-offscreencanvas-interface:offscreencanvas-context-none-2">none</a>
       </th><th><a href="#offscreencanvas-context-2d" id="the-offscreencanvas-interface:offscreencanvas-context-2d">2d</a>
       </th><th><a href="#offscreencanvas-context-bitmaprenderer" id="the-offscreencanvas-interface:offscreencanvas-context-bitmaprenderer">bitmaprenderer</a>
       </th><th><a href="#offscreencanvas-context-webgl" id="the-offscreencanvas-interface:offscreencanvas-context-webgl">webgl</a> or <a href="#offscreencanvas-context-webgl2" id="the-offscreencanvas-interface:offscreencanvas-context-webgl2">webgl2</a>
       </th><th><a href="#offscreencanvas-context-webgpu" id="the-offscreencanvas-interface:offscreencanvas-context-webgpu">webgpu</a>
       </th><th><a href="#offscreencanvas-context-detached" id="the-offscreencanvas-interface:offscreencanvas-context-detached-2">detached</a>
     </th></tr></thead><tbody><tr><th>"<dfn id="offscreen-context-type-2d"><code>2d</code></dfn>"
       </th><td>
        <ol><li><p>Let <var>context</var> be the result of running the
         <a href="#offscreen-2d-context-creation-algorithm" id="the-offscreencanvas-interface:offscreen-2d-context-creation-algorithm">offscreen 2D context creation algorithm</a> given
         <a id="the-offscreencanvas-interface:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and <var>options</var>.</p></li><li><p>Set <a id="the-offscreencanvas-interface:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode-4">context
         mode</a> to <a href="#offscreencanvas-context-2d" id="the-offscreencanvas-interface:offscreencanvas-context-2d-2">2d</a>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
       </td><td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Throw an <a id="the-offscreencanvas-interface:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-offscreencanvas-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
      </td></tr><tr><th>"<dfn id="offscreen-context-type-bitmaprenderer"><code>bitmaprenderer</code></dfn>"
       </th><td>
        <ol><li><p>Let <var>context</var> be the result of running the
         <a href="#imagebitmaprenderingcontext-creation-algorithm" id="the-offscreencanvas-interface:imagebitmaprenderingcontext-creation-algorithm"><code>ImageBitmapRenderingContext</code> creation
         algorithm</a> given <a id="the-offscreencanvas-interface:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and <var>options</var>.</p></li><li><p>Set <a id="the-offscreencanvas-interface:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode-5">context
         mode</a> to <a href="#offscreencanvas-context-bitmaprenderer" id="the-offscreencanvas-interface:offscreencanvas-context-bitmaprenderer-2">bitmaprenderer</a>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
       </td><td>
        Return null.
       </td><td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Throw an <a id="the-offscreencanvas-interface:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-offscreencanvas-interface:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
      </td></tr><tr><th>"<dfn id="offscreen-context-type-webgl"><code>webgl</code></dfn>" or "<dfn id="offscreen-context-type-webgl2"><code>webgl2</code></dfn>"
       </th><td>
        <ol><li><p>Let <var>context</var> be the result of following the instructions given in the
         WebGL specifications' <i>Context Creation</i> sections. <a href="#refsWEBGL">[WEBGL]</a></p></li><li><p>If <var>context</var> is null, then return null; otherwise set
         <a id="the-offscreencanvas-interface:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode-6">context
         mode</a> to <a href="#offscreencanvas-context-webgl" id="the-offscreencanvas-interface:offscreencanvas-context-webgl-2">webgl</a> or <a href="#offscreencanvas-context-webgl2" id="the-offscreencanvas-interface:offscreencanvas-context-webgl2-2">webgl2</a>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return the same value as was returned the last time the method was invoked with this same
        first argument.
       </td><td>
        Return null.
       </td><td>
        Throw an <a id="the-offscreencanvas-interface:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-offscreencanvas-interface:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
      </td></tr><tr><th>"<dfn id="offscreen-context-type-webgpu"><code>webgpu</code></dfn>"
       </th><td>
        <ol><li><p>Let <var>context</var> be the result of following the instructions given in
         <cite>WebGPU</cite>'s <a href="https://gpuweb.github.io/gpuweb/#canvas-rendering">Canvas Rendering</a> section.
         <a href="#refsWEBGPU">[WEBGPU]</a></p></li><li><p>If <var>context</var> is null, then return null; otherwise set <a id="the-offscreencanvas-interface:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
         <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode-7">context mode</a> to <a href="#offscreencanvas-context-webgpu" id="the-offscreencanvas-interface:offscreencanvas-context-webgpu-2">webgpu</a>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return null.
       </td><td>
        Return the same value as was returned the last time the method was invoked with this same
        first argument.
       </td><td>
        Throw an <a id="the-offscreencanvas-interface:invalidstateerror-5" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-offscreencanvas-interface:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
    </td></tr></tbody></table>
   </li></ol>
  </div>

  <hr>

  

  <dl class="domintro"><dt><code><var>offscreenCanvas</var>.<a href="#dom-offscreencanvas-width" id="dom-offscreencanvas-width-dev">width</a> [
   = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/width" title="The width property returns and sets the width of an OffscreenCanvas object.">OffscreenCanvas/width</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>105+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>offscreenCanvas</var>.<a href="#dom-offscreencanvas-height" id="dom-offscreencanvas-height-dev">height</a> [
   = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/height" title="The height property returns and sets the height of an OffscreenCanvas object.">OffscreenCanvas/height</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>105+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>These attributes return the dimensions of the <code id="the-offscreencanvas-interface:offscreencanvas-19"><a href="#offscreencanvas">OffscreenCanvas</a></code> object's <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-6">bitmap</a>.</p>

    <p>They can be set, to replace the <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-7">bitmap</a> with a
    new, <a id="the-offscreencanvas-interface:transparent-black-4" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> bitmap of the specified dimensions (effectively resizing
    it).</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>If either the <dfn data-dfn-for="OffscreenCanvas" id="dom-offscreencanvas-width" data-dfn-type="attribute"><code>width</code></dfn> or <dfn data-dfn-for="OffscreenCanvas" id="dom-offscreencanvas-height" data-dfn-type="attribute"><code>height</code></dfn> attributes of
  an <code id="the-offscreencanvas-interface:offscreencanvas-20"><a href="#offscreencanvas">OffscreenCanvas</a></code> object are set (to a new value or to the same value as before) and
  the <code id="the-offscreencanvas-interface:offscreencanvas-21"><a href="#offscreencanvas">OffscreenCanvas</a></code> object's <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode-8">context
  mode</a> is <a href="#offscreencanvas-context-2d" id="the-offscreencanvas-interface:offscreencanvas-context-2d-3">2d</a>, then <a href="#reset-the-rendering-context-to-its-default-state" id="the-offscreencanvas-interface:reset-the-rendering-context-to-its-default-state">reset the rendering
  context to its default state</a> and resize the <code id="the-offscreencanvas-interface:offscreencanvas-22"><a href="#offscreencanvas">OffscreenCanvas</a></code> object's <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-8">bitmap</a> to the new values of the <code id="the-offscreencanvas-interface:dom-offscreencanvas-width-4"><a href="#dom-offscreencanvas-width">width</a></code> and <code id="the-offscreencanvas-interface:dom-offscreencanvas-height-4"><a href="#dom-offscreencanvas-height">height</a></code> attributes.</p>
  </div>

  <p>The resizing behavior for "<code id="the-offscreencanvas-interface:offscreen-context-type-webgl-5"><a href="#offscreen-context-type-webgl">webgl</a></code>" and "<code id="the-offscreencanvas-interface:offscreen-context-type-webgl2-4"><a href="#offscreen-context-type-webgl2">webgl2</a></code>" contexts is defined in the WebGL
  specifications. <a href="#refsWEBGL">[WEBGL]</a></p>

  <p>The resizing behavior for "<code id="the-offscreencanvas-interface:offscreen-context-type-webgpu-4"><a href="#offscreen-context-type-webgpu">webgpu</a></code>" context
  is defined in <cite>WebGPU</cite>. <a href="#refsWEBGPU">[WEBGPU]</a></p>

  

  <p class="note">If an <code id="the-offscreencanvas-interface:offscreencanvas-23"><a href="#offscreencanvas">OffscreenCanvas</a></code> object whose dimensions were changed has
  a <a href="#offscreencanvas-placeholder" id="the-offscreencanvas-interface:offscreencanvas-placeholder-5">placeholder <code>canvas</code> element</a>, then
  the <a href="#offscreencanvas-placeholder" id="the-offscreencanvas-interface:offscreencanvas-placeholder-6">placeholder <code>canvas</code> element</a>'s
  <a href="https://drafts.csswg.org/css-images/#natural-dimensions" id="the-offscreencanvas-interface:natural-dimensions" data-x-internal="natural-dimensions">natural size</a> will only be updated during the
  <code id="the-offscreencanvas-interface:offscreencanvas-24"><a href="#offscreencanvas">OffscreenCanvas</a></code>'s <a href="#relevant-agent" id="the-offscreencanvas-interface:relevant-agent-2">relevant agent</a>'s <a href="#concept-agent-event-loop" id="the-offscreencanvas-interface:concept-agent-event-loop-2">event loop</a>'s <a href="#update-the-rendering" id="the-offscreencanvas-interface:update-the-rendering-2">update the rendering</a> steps.</p>

  <dl class="domintro"><dt><code><var>promise</var> = <var>offscreenCanvas</var>.<a href="#dom-offscreencanvas-converttoblob" id="dom-offscreencanvas-converttoblob-dev">convertToBlob</a>([<var>options</var>])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/convertToBlob" title="The OffscreenCanvas.convertToBlob() method creates a Blob object representing the image contained in the canvas.">OffscreenCanvas/convertToBlob</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>105+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns a promise that will fulfill with a new <code id="the-offscreencanvas-interface:blob-2"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> object representing a file
    containing the image in the <code id="the-offscreencanvas-interface:offscreencanvas-25"><a href="#offscreencanvas">OffscreenCanvas</a></code> object.</p>

    <p>The argument, if provided, is a dictionary that controls the encoding options of the image
    file to be created. The <code id="the-offscreencanvas-interface:image-encode-options-type-2"><a href="#image-encode-options-type">type</a></code> field specifies the
    file format and has a default value of "<code id="the-offscreencanvas-interface:image/png"><a href="#image/png">image/png</a></code>"; that type is also used if the
    requested type isn't supported. If the image format supports variable quality (such as
    "<code id="the-offscreencanvas-interface:image/jpeg"><a href="#image/jpeg">image/jpeg</a></code>"), then the <code id="the-offscreencanvas-interface:image-encode-options-quality-2"><a href="#image-encode-options-quality">quality</a></code>
    field is a number in the range 0.0 to 1.0 inclusive indicating the desired quality level for the
    resulting image.</p>
   </dd><dt><code><var>canvas</var>.<a href="#dom-offscreencanvas-transfertoimagebitmap" id="dom-offscreencanvas-transfertoimagebitmap-dev">transferToImageBitmap</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/transferToImageBitmap" title="The OffscreenCanvas.transferToImageBitmap() method creates an ImageBitmap object from the most recently rendered image of the OffscreenCanvas. The OffscreenCanvas allocates a new image for its subsequent rendering.">OffscreenCanvas/transferToImageBitmap</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>105+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns a newly created <code id="the-offscreencanvas-interface:imagebitmap-2"><a href="#imagebitmap">ImageBitmap</a></code> object with the image in the
    <code id="the-offscreencanvas-interface:offscreencanvas-26"><a href="#offscreencanvas">OffscreenCanvas</a></code> object. The image in the <code id="the-offscreencanvas-interface:offscreencanvas-27"><a href="#offscreencanvas">OffscreenCanvas</a></code> object is
    replaced with a new blank image.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="OffscreenCanvas" id="dom-offscreencanvas-converttoblob" data-dfn-type="method"><code>convertToBlob(<var>options</var>)</code></dfn> method
  steps are:</p>

  <ol><li><p>If the value of <a id="the-offscreencanvas-interface:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#detached" id="the-offscreencanvas-interface:detached">[[Detached]]</a> internal slot is true, then
   return <a id="the-offscreencanvas-interface:a-promise-rejected-with" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> an <a id="the-offscreencanvas-interface:invalidstateerror-6" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="the-offscreencanvas-interface:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="the-offscreencanvas-interface:this-16" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode-9">context mode</a> is
   <a href="#offscreencanvas-context-2d" id="the-offscreencanvas-interface:offscreencanvas-context-2d-4">2d</a> and the rendering context's <a href="#output-bitmap" id="the-offscreencanvas-interface:output-bitmap">output
   bitmap</a>'s <a href="#concept-canvas-origin-clean" id="the-offscreencanvas-interface:concept-canvas-origin-clean">origin-clean</a> flag is set to
   false, then return <a id="the-offscreencanvas-interface:a-promise-rejected-with-2" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> a
   <a id="the-offscreencanvas-interface:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-offscreencanvas-interface:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

   </li><li><p>If <a id="the-offscreencanvas-interface:this-17" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-9">bitmap</a> has no pixels
   (i.e., either its horizontal dimension or its vertical dimension is zero), then return <a id="the-offscreencanvas-interface:a-promise-rejected-with-3" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a
   promise rejected with</a> an <a id="the-offscreencanvas-interface:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a>
   <code id="the-offscreencanvas-interface:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>bitmap</var> be a copy of <a id="the-offscreencanvas-interface:this-18" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-10">bitmap</a>.</p></li><li><p>Let <var>result</var> be a new promise object.</p></li><li><p>Let <var>global</var> be <a id="the-offscreencanvas-interface:this-19" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-offscreencanvas-interface:concept-relevant-global-2">relevant global object</a>.</p></li><li>
    <p>Run these steps <a href="#in-parallel" id="the-offscreencanvas-interface:in-parallel">in parallel</a>:</p>

    <ol><li><p>Let <var>file</var> be <a href="#a-serialisation-of-the-bitmap-as-a-file" id="the-offscreencanvas-interface:a-serialisation-of-the-bitmap-as-a-file">a
     serialization of <var>bitmap</var> as a file</a>, with <var>options</var>'s <dfn id="image-encode-options-type"><code>type</code></dfn> and <dfn id="image-encode-options-quality"><code>quality</code></dfn> if present.</p></li><li>
      <p><a href="#queue-a-global-task" id="the-offscreencanvas-interface:queue-a-global-task">Queue a global task</a> on the <a href="#canvas-blob-serialisation-task-source" id="the-offscreencanvas-interface:canvas-blob-serialisation-task-source">canvas blob serialization task source</a>
      given <var>global</var> to run these steps:</p>

      <ol><li><p>If <var>file</var> is null, then reject <var>result</var> with an
       <a id="the-offscreencanvas-interface:encodingerror" href="https://webidl.spec.whatwg.org/#encodingerror" data-x-internal="encodingerror">"<code>EncodingError</code>"</a> <code id="the-offscreencanvas-interface:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Otherwise, resolve <var>result</var> with a new <code id="the-offscreencanvas-interface:blob-3"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> object, created in
       <var>global</var>'s <a href="#concept-relevant-realm" id="the-offscreencanvas-interface:concept-relevant-realm">relevant realm</a>, representing
       <var>file</var>. <a href="#refsFILEAPI">[FILEAPI]</a></p></li></ol>
     </li></ol>
   </li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="OffscreenCanvas" id="dom-offscreencanvas-transfertoimagebitmap" data-dfn-type="method"><code>transferToImageBitmap()</code></dfn> method,
  when invoked, must run the following steps:</p>
  <ol><li><p>If the value of this <code id="the-offscreencanvas-interface:offscreencanvas-28"><a href="#offscreencanvas">OffscreenCanvas</a></code> object's <a href="#detached" id="the-offscreencanvas-interface:detached-2">[[Detached]]</a>
   internal slot is set to true, then throw an <a id="the-offscreencanvas-interface:invalidstateerror-7" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="the-offscreencanvas-interface:domexception-10"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If this <code id="the-offscreencanvas-interface:offscreencanvas-29"><a href="#offscreencanvas">OffscreenCanvas</a></code> object's <a href="#offscreencanvas-context-mode" id="the-offscreencanvas-interface:offscreencanvas-context-mode-10">context mode</a> is set to <a href="#offscreencanvas-context-none" id="the-offscreencanvas-interface:offscreencanvas-context-none-3">none</a>, then throw an
   <a id="the-offscreencanvas-interface:invalidstateerror-8" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-offscreencanvas-interface:domexception-11"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>image</var> be a newly created <code id="the-offscreencanvas-interface:imagebitmap-3"><a href="#imagebitmap">ImageBitmap</a></code> object that references
   the same underlying bitmap data as this <code id="the-offscreencanvas-interface:offscreencanvas-30"><a href="#offscreencanvas">OffscreenCanvas</a></code> object's <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-11">bitmap</a>.</p></li><li>
    <p>Set this <code id="the-offscreencanvas-interface:offscreencanvas-31"><a href="#offscreencanvas">OffscreenCanvas</a></code> object's <a href="#offscreencanvas-bitmap" id="the-offscreencanvas-interface:offscreencanvas-bitmap-12">bitmap</a> to reference a newly created bitmap of the same
    dimensions and color space as the previous bitmap, and with its pixels initialized to
    <a id="the-offscreencanvas-interface:transparent-black-5" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>, or <a id="the-offscreencanvas-interface:opaque-black" href="https://drafts.csswg.org/css-color/#opaque-black" data-x-internal="opaque-black">opaque black</a> if the rendering context's <a href="#concept-canvas-alpha" id="the-offscreencanvas-interface:concept-canvas-alpha">alpha</a> is false.</p>

    <p class="note">This means that if the rendering context of this <code id="the-offscreencanvas-interface:offscreencanvas-32"><a href="#offscreencanvas">OffscreenCanvas</a></code> is
    a <code id="the-offscreencanvas-interface:webglrenderingcontext-2"><a data-x-internal="webglrenderingcontext" href="https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContext">WebGLRenderingContext</a></code>, the value of <code id="the-offscreencanvas-interface:webglcontextattributes"><a data-x-internal="webglcontextattributes" href="https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLContextAttributes">preserveDrawingBuffer</a></code> will have no effect.
    <a href="#refsWEBGL">[WEBGL]</a></p>
   </li><li><p>Return <var>image</var>.</p></li></ol>
  </div>
  

  <p>The following are the <a href="#event-handlers" id="the-offscreencanvas-interface:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="the-offscreencanvas-interface:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="the-offscreencanvas-interface:event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the
  <code id="the-offscreencanvas-interface:offscreencanvas-33"><a href="#offscreencanvas">OffscreenCanvas</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="the-offscreencanvas-interface:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="the-offscreencanvas-interface:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="OffscreenCanvas" id="handler-offscreencanvas-oncontextlost" data-dfn-type="attribute"><code>oncontextlost</code></dfn> </td><td> <code id="the-offscreencanvas-interface:event-contextlost-2"><a href="#event-contextlost">contextlost</a></code>
    </td></tr><tr><td><dfn data-dfn-for="OffscreenCanvas" id="handler-offscreencanvas-oncontextrestored" data-dfn-type="attribute"><code>oncontextrestored</code></dfn> </td><td> <code id="the-offscreencanvas-interface:event-contextrestored-2"><a href="#event-contextrestored">contextrestored</a></code>
  </td></tr></tbody></table>

  <h6 id="the-offscreen-2d-rendering-context"><span class="secno">4.12.5.3.1</span> The offscreen 2D rendering context<a href="#the-offscreen-2d-rendering-context" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvasRenderingContext2D" title="The OffscreenCanvasRenderingContext2D interface is a CanvasRenderingContext2D rendering context for drawing to the bitmap of an OffscreenCanvas object. It is similar to the CanvasRenderingContext2D object, with the following differences:">OffscreenCanvasRenderingContext2D</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>105+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="offscreencanvasrenderingcontext2d" data-dfn-type="interface"><c- g="">OffscreenCanvasRenderingContext2D</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#offscreencanvas" id="the-offscreen-2d-rendering-context:offscreencanvas"><c- n="">OffscreenCanvas</c-></a> <a href="#offscreencontext2d-canvas" id="the-offscreen-2d-rendering-context:offscreencontext2d-canvas"><c- g="">canvas</c-></a>;
};

<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvassettings" id="the-offscreen-2d-rendering-context:canvassettings"><c- n="">CanvasSettings</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-2"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasstate" id="the-offscreen-2d-rendering-context:canvasstate"><c- n="">CanvasState</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-3"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvastransform" id="the-offscreen-2d-rendering-context:canvastransform"><c- n="">CanvasTransform</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-4"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvascompositing" id="the-offscreen-2d-rendering-context:canvascompositing"><c- n="">CanvasCompositing</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-5"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasimagesmoothing" id="the-offscreen-2d-rendering-context:canvasimagesmoothing"><c- n="">CanvasImageSmoothing</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-6"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasfillstrokestyles" id="the-offscreen-2d-rendering-context:canvasfillstrokestyles"><c- n="">CanvasFillStrokeStyles</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-7"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasshadowstyles" id="the-offscreen-2d-rendering-context:canvasshadowstyles"><c- n="">CanvasShadowStyles</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-8"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasfilters" id="the-offscreen-2d-rendering-context:canvasfilters"><c- n="">CanvasFilters</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-9"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasrect" id="the-offscreen-2d-rendering-context:canvasrect"><c- n="">CanvasRect</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-10"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasdrawpath" id="the-offscreen-2d-rendering-context:canvasdrawpath"><c- n="">CanvasDrawPath</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-11"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvastext" id="the-offscreen-2d-rendering-context:canvastext"><c- n="">CanvasText</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-12"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasdrawimage" id="the-offscreen-2d-rendering-context:canvasdrawimage"><c- n="">CanvasDrawImage</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-13"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvasimagedata" id="the-offscreen-2d-rendering-context:canvasimagedata"><c- n="">CanvasImageData</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-14"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvaspathdrawingstyles" id="the-offscreen-2d-rendering-context:canvaspathdrawingstyles"><c- n="">CanvasPathDrawingStyles</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-15"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvastextdrawingstyles" id="the-offscreen-2d-rendering-context:canvastextdrawingstyles"><c- n="">CanvasTextDrawingStyles</c-></a>;
<a href="#offscreencanvasrenderingcontext2d" id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-16"><c- n="">OffscreenCanvasRenderingContext2D</c-></a> <c- b="">includes</c-> <a href="#canvaspath" id="the-offscreen-2d-rendering-context:canvaspath"><c- n="">CanvasPath</c-></a>;</code></pre>

  <p>The <code id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-17"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code> object is a rendering context for drawing to
  the <a href="#offscreencanvas-bitmap" id="the-offscreen-2d-rendering-context:offscreencanvas-bitmap">bitmap</a> of an <code id="the-offscreen-2d-rendering-context:offscreencanvas-2"><a href="#offscreencanvas">OffscreenCanvas</a></code> object.
  It is similar to the <code id="the-offscreen-2d-rendering-context:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> object, with the following
  differences:</p>

  <ul><li><p>there is no support for <a href="#canvasuserinterface" id="the-offscreen-2d-rendering-context:canvasuserinterface">user interface</a>
   features;</p></li><li><p>its <code id="the-offscreen-2d-rendering-context:offscreencontext2d-canvas-2"><a href="#offscreencontext2d-canvas">canvas</a></code> attribute refers to an
   <code id="the-offscreen-2d-rendering-context:offscreencanvas-3"><a href="#offscreencanvas">OffscreenCanvas</a></code> object rather than a <code id="the-offscreen-2d-rendering-context:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element;</p></li></ul>

  <p>An <code id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-18"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code> object has an <dfn id="associated-offscreencanvas-object">associated
  <code>OffscreenCanvas</code> object</dfn>, which is the <code id="the-offscreen-2d-rendering-context:offscreencanvas-4"><a href="#offscreencanvas">OffscreenCanvas</a></code> object
  from which the <code id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-19"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code> object was created.

  </p><dl class="domintro"><dt><code><var>offscreenCanvas</var> = <var>offscreenCanvasRenderingContext2D</var>.<a href="#offscreencontext2d-canvas" id="offscreencontext2d-canvas-dev">canvas</a></code></dt><dd><p>Returns the <a href="#associated-offscreencanvas-object" id="the-offscreen-2d-rendering-context:associated-offscreencanvas-object">associated <code>OffscreenCanvas</code> object</a>.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn id="offscreen-2d-context-creation-algorithm">offscreen 2D context creation algorithm</dfn>, which is passed a
  <var>target</var> (an <code id="the-offscreen-2d-rendering-context:offscreencanvas-5"><a href="#offscreencanvas">OffscreenCanvas</a></code> object) and optionally some arguments,
  consists of running the following steps:</p>

  <ol><li><p>If the algorithm was passed some arguments, let <var>arg</var> be the first such
   argument. Otherwise, let <var>arg</var> be undefined.</p></li><li><p>Let <var>settings</var> be the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="the-offscreen-2d-rendering-context:concept-idl-convert" data-x-internal="concept-idl-convert">converting</a> <var>arg</var> to the dictionary type
   <code id="the-offscreen-2d-rendering-context:canvasrenderingcontext2dsettings"><a href="#canvasrenderingcontext2dsettings">CanvasRenderingContext2DSettings</a></code>. (This can throw an exception.)</p></li><li><p>Let <var>context</var> be a new <code id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-20"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code>
   object.</p></li><li><p>Set <var>context</var>'s <a href="#associated-offscreencanvas-object" id="the-offscreen-2d-rendering-context:associated-offscreencanvas-object-2">associated <code>OffscreenCanvas</code> object</a> to
   <var>target</var>.</p></li><li><p>Run the <a href="#canvas-setting-init-bitmap" id="the-offscreen-2d-rendering-context:canvas-setting-init-bitmap">canvas settings output bitmap
   initialization algorithm</a>, given <var>context</var> and <var>settings</var>.</p></li><li><p>Set <var>context</var>'s <a href="#output-bitmap" id="the-offscreen-2d-rendering-context:output-bitmap">output bitmap</a> to a newly created bitmap with the
   dimensions specified by the <code id="the-offscreen-2d-rendering-context:dom-offscreencanvas-width"><a href="#dom-offscreencanvas-width">width</a></code> and <code id="the-offscreen-2d-rendering-context:dom-offscreencanvas-height"><a href="#dom-offscreencanvas-height">height</a></code> attributes of <var>target</var>, and set
   <var>target</var>'s bitmap to the same bitmap (so that they are shared).</p></li><li><p>If <var>context</var>'s <a href="#concept-canvas-alpha" id="the-offscreen-2d-rendering-context:concept-canvas-alpha">alpha</a> flag is set to
   true, initialize all the pixels of <var>context</var>'s <a href="#output-bitmap" id="the-offscreen-2d-rendering-context:output-bitmap-2">output bitmap</a> to
   <a id="the-offscreen-2d-rendering-context:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>. Otherwise, initialize the pixels to <a id="the-offscreen-2d-rendering-context:opaque-black" href="https://drafts.csswg.org/css-color/#opaque-black" data-x-internal="opaque-black">opaque
   black</a>.</p></li><li><p>Return <var>context</var>.</p></li></ol>
  </div>

  <p class="note">Implementations are encouraged to short-circuit the graphics update steps of
  the <a href="#window-event-loop" id="the-offscreen-2d-rendering-context:window-event-loop">window event loop</a> for the purposes of updating the contents of a <a href="#offscreencanvas-placeholder" id="the-offscreen-2d-rendering-context:offscreencanvas-placeholder">placeholder <code>canvas</code> element</a> to the
  display. This could mean, for example, that the bitmap contents are copied directly to a graphics
  buffer that is mapped to the physical display location of the <a href="#offscreencanvas-placeholder" id="the-offscreen-2d-rendering-context:offscreencanvas-placeholder-2">placeholder <code>canvas</code> element</a>. This or
  similar short-circuiting approaches can significantly reduce display latency, especially in cases
  where the <code id="the-offscreen-2d-rendering-context:offscreencanvas-6"><a href="#offscreencanvas">OffscreenCanvas</a></code> is updated from a
  <a href="#worker-event-loop-2" id="the-offscreen-2d-rendering-context:worker-event-loop-2">worker event loop</a> and the <a href="#window-event-loop" id="the-offscreen-2d-rendering-context:window-event-loop-2">window event loop</a> of the <a href="#offscreencanvas-placeholder" id="the-offscreen-2d-rendering-context:offscreencanvas-placeholder-3">placeholder <code>canvas</code> element</a> is busy.
  However, such shortcuts cannot have any script-observable side-effects. This means that the
  committed bitmap still needs to be sent to the <a href="#offscreencanvas-placeholder" id="the-offscreen-2d-rendering-context:offscreencanvas-placeholder-4">placeholder <code>canvas</code> element</a>, in case the
  element is used as a <code id="the-offscreen-2d-rendering-context:canvasimagesource"><a href="#canvasimagesource">CanvasImageSource</a></code>, as an <code id="the-offscreen-2d-rendering-context:imagebitmapsource"><a href="#imagebitmapsource">ImageBitmapSource</a></code>, or in
  case <code id="the-offscreen-2d-rendering-context:dom-canvas-todataurl"><a href="#dom-canvas-todataurl">toDataURL()</a></code> or <code id="the-offscreen-2d-rendering-context:dom-canvas-toblob"><a href="#dom-canvas-toblob">toBlob()</a></code> are called on it.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="OffscreenCanvas" id="offscreencontext2d-canvas" data-dfn-type="attribute"><code>canvas</code></dfn> attribute, on getting, must return this
  <code id="the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-21"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code>'s <a href="#associated-offscreencanvas-object" id="the-offscreen-2d-rendering-context:associated-offscreencanvas-object-3">associated <code>OffscreenCanvas</code>
  object</a>.
  </p></div>

  

  

  <h5 id="colour-spaces-and-colour-correction"><span class="secno">4.12.5.4</span> Color spaces and color space
  conversion<a href="#colour-spaces-and-colour-correction" class="self-link"></a></h5>

  <pre><code class="idl"><c- b="">enum</c-> <dfn id="predefinedcolorspace" data-dfn-type="enum"><c- g="">PredefinedColorSpace</c-></dfn> { <c- s="">"</c-><a href="#dom-predefinedcolorspace-srgb" id="colour-spaces-and-colour-correction:dom-predefinedcolorspace-srgb"><c- s="">srgb</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-predefinedcolorspace-display-p3" id="colour-spaces-and-colour-correction:dom-predefinedcolorspace-display-p3"><c- s="">display-p3</c-></a><c- s="">"</c-> };</code></pre>

  <p>The <code id="colour-spaces-and-colour-correction:predefinedcolorspace"><a href="#predefinedcolorspace">PredefinedColorSpace</a></code> enumeration is used to specify the <a href="#concept-canvas-color-space" id="colour-spaces-and-colour-correction:concept-canvas-color-space">color space</a> of the canvas's backing store.</p>

  <p>The "<dfn data-dfn-for="PredefinedColorSpace" id="dom-predefinedcolorspace-srgb" data-dfn-type="enum-value"><code>srgb</code></dfn>" value indicates the <a id="colour-spaces-and-colour-correction:'srgb'" href="https://drafts.csswg.org/css-color/#valdef-color-srgb" data-x-internal="'srgb'">'srgb'</a>
  color space.</p>

  <p>The "<dfn data-dfn-for="PredefinedColorSpace" id="dom-predefinedcolorspace-display-p3" data-dfn-type="enum-value"><code>display-p3</code></dfn>" value indicates the
  <a id="colour-spaces-and-colour-correction:'display-p3'" href="https://drafts.csswg.org/css-color/#valdef-color-display-p3" data-x-internal="'display-p3'">'display-p3'</a> color space.</p>

  <p><a href="https://drafts.csswg.org/css-color/#color-conversion" id="colour-spaces-and-colour-correction:converting-colors" data-x-internal="converting-colors">Color space conversion</a> must be applied to the canvas's
  backing store when rendering the canvas to the output device.</p>

  <p class="note">The algorithm for converting between color spaces can be found in the
  <a id="colour-spaces-and-colour-correction:converting-colors-2" href="https://drafts.csswg.org/css-color/#color-conversion" data-x-internal="converting-colors">Converting Colors</a> section of <cite>CSS Color</cite>. This color space conversion is
  identical to the color space conversion that would be applied to an <code id="colour-spaces-and-colour-correction:the-img-element"><a href="#the-img-element">img</a></code> element with
  a color profile that specifies the same <a href="#concept-canvas-color-space" id="colour-spaces-and-colour-correction:concept-canvas-color-space-2">color
  space</a> as the canvas's backing store. <a href="#refsCSSCOLOR">[CSSCOLOR]</a></p>

  



  <h5 id="serialising-bitmaps-to-a-file"><span class="secno">4.12.5.5</span> Serializing bitmaps to a file<a href="#serialising-bitmaps-to-a-file" class="self-link"></a></h5>

  

  <div data-var-scope="">
  <p>When a user agent is to create <dfn id="a-serialisation-of-the-bitmap-as-a-file">a
  serialization of the bitmap as a file</dfn>, given a <var>type</var> and an optional
  <var>quality</var>, it must create an image file in the format given by <var>type</var>. If an
  error occurs during the creation of the image file (e.g. an internal encoder error), then the
  result of the serialization is null. <a href="#refsPNG">[PNG]</a></p>

  <p>The image file's pixel data must be the bitmap's pixel data scaled to one image pixel per
  coordinate space unit, and if the file format used supports encoding resolution metadata, the
  resolution must be given as 96dpi (one image pixel per <a href="https://drafts.csswg.org/css-values/#px" id="serialising-bitmaps-to-a-file:'px'" data-x-internal="'px'">CSS pixel</a>).</p>

  <p>If <var>type</var> is supplied, then it must be interpreted as a <a href="https://mimesniff.spec.whatwg.org/#mime-type" id="serialising-bitmaps-to-a-file:mime-type" data-x-internal="mime-type">MIME
  type</a> giving the format to use. If the type has any parameters, then it must be treated as
  not supported.</p>

  <p class="example">For example, the value "<code id="serialising-bitmaps-to-a-file:image/png"><a href="#image/png">image/png</a></code>" would mean to generate a PNG
  image, the value "<code id="serialising-bitmaps-to-a-file:image/jpeg"><a href="#image/jpeg">image/jpeg</a></code>" would mean to generate a JPEG image, and the value
  "<code id="serialising-bitmaps-to-a-file:image/svg+xml"><a href="#image/svg+xml">image/svg+xml</a></code>" would mean to generate an SVG image (which would require that the
  user agent track how the bitmap was generated, an unlikely, though potentially awesome,
  feature).</p>

  <p>User agents must support PNG ("<code id="serialising-bitmaps-to-a-file:image/png-2"><a href="#image/png">image/png</a></code>"). User agents may support other types.
  If the user agent does not support the requested type, then it must create the file using the PNG
  format. <a href="#refsPNG">[PNG]</a></p>

  <p>User agents must <a href="https://infra.spec.whatwg.org/#ascii-lowercase" id="serialising-bitmaps-to-a-file:converted-to-ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">convert the provided type to ASCII
  lowercase</a> before establishing if they support that type.</p>

  <p>For image types that do not support an alpha component, the serialized image must be the bitmap
  image composited onto an <a id="serialising-bitmaps-to-a-file:opaque-black" href="https://drafts.csswg.org/css-color/#opaque-black" data-x-internal="opaque-black">opaque black</a> background using the <a href="https://drafts.fxtf.org/compositing/#porterduffcompositingoperators_srcover" id="serialising-bitmaps-to-a-file:gcop-source-over" data-x-internal="gcop-source-over">source-over</a> compositing operator.</p>

  <p>For image types that support color profiles, the serialized image must include a color profile
  indicating the color space of the underlying bitmap. For image types that do not support color
  profiles, the serialized image must be <a href="https://drafts.csswg.org/css-color/#color-conversion" id="serialising-bitmaps-to-a-file:converting-colors" data-x-internal="converting-colors">converted</a> to the
  <a id="serialising-bitmaps-to-a-file:'srgb'" href="https://drafts.csswg.org/css-color/#valdef-color-srgb" data-x-internal="'srgb'">'srgb'</a> color space using <a id="serialising-bitmaps-to-a-file:'relative-colorimetric'" href="https://drafts.csswg.org/css-color-5/#valdef-color-profile-rendering-intent-relative-colorimetric" data-x-internal="'relative-colorimetric'">'relative-colorimetric'</a> rendering intent.</p>

  <p class="note">Thus, in the 2D context, calling the <code id="serialising-bitmaps-to-a-file:dom-context-2d-drawimage"><a href="#dom-context-2d-drawimage">drawImage()</a></code> method to render the output of the <code id="serialising-bitmaps-to-a-file:dom-canvas-todataurl"><a href="#dom-canvas-todataurl">toDataURL()</a></code> or <code id="serialising-bitmaps-to-a-file:dom-canvas-toblob"><a href="#dom-canvas-toblob">toBlob()</a></code> method to the canvas, given the appropriate dimensions,
  has no visible effect beyond, at most, clipping colors of the canvas to a more narrow gamut.</p>

  <p>For image types that support multiple bit depths, the serialized image must use the bit depth
  that best preserves content of the underlying bitmap.</p>

  <p class="example">For example, when serializing a 2D context that has
  <a href="#concept-canvas-color-type" id="serialising-bitmaps-to-a-file:concept-canvas-color-type">color type</a> of
  <a href="#dom-canvascolortype-float16" id="serialising-bitmaps-to-a-file:dom-canvascolortype-float16">float16</a> to <var>type</var>
  "<code id="serialising-bitmaps-to-a-file:image/png-3"><a href="#image/png">image/png</a></code>", the resulting image would have 16 bits per sample.
  This serialization will still lose significant detail (all values less than 0.5/65535
  would be clamped to 0, and all values greater than 1 would be clamped to 1).</p>

  <p>If <var>type</var> is an image format that supports variable quality (such as
  "<code id="serialising-bitmaps-to-a-file:image/jpeg-2"><a href="#image/jpeg">image/jpeg</a></code>"), <var>quality</var> is given, and <var>type</var> is not
  "<code id="serialising-bitmaps-to-a-file:image/png-4"><a href="#image/png">image/png</a></code>", then, if <var>quality</var> <a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type" id="serialising-bitmaps-to-a-file:js-number" data-x-internal="js-number">is a Number</a>
  in the range 0.0 to 1.0 inclusive, the user agent must treat <var>quality</var> as the desired
  quality level. Otherwise, the user agent must use its default quality value, as if the
  <var>quality</var> argument had not been given.</p>

  <p class="note">The use of type-testing here, instead of simply declaring <var>quality</var> as
  a Web IDL <code>double</code>, is a historical artifact.</p>
  </div>

  <p class="note">Different implementations can have slightly different interpretations of
  "quality". When the quality is not specified, an implementation-specific default is used that
  represents a reasonable compromise between compression ratio, image quality, and encoding
  time.</p>

  


  

  <h5 id="security-with-canvas-elements"><span class="secno">4.12.5.6</span> Security with <code id="security-with-canvas-elements:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> elements<a href="#security-with-canvas-elements" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p><strong>Information leakage</strong> can occur if scripts from one <a href="#concept-origin" id="security-with-canvas-elements:concept-origin">origin</a> can
  access information (e.g. read pixels) from images from another origin (one that isn't the <a href="#same-origin" id="security-with-canvas-elements:same-origin">same</a>).</p>

  <p>To mitigate this, bitmaps used with <code id="security-with-canvas-elements:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> elements, <code id="security-with-canvas-elements:offscreencanvas"><a href="#offscreencanvas">OffscreenCanvas</a></code>
  objects, and <code id="security-with-canvas-elements:imagebitmap"><a href="#imagebitmap">ImageBitmap</a></code> objects are defined to have a flag indicating whether they
  are <a href="#concept-canvas-origin-clean" id="security-with-canvas-elements:concept-canvas-origin-clean">origin-clean</a>. All bitmaps start with their
  <a href="#concept-canvas-origin-clean" id="security-with-canvas-elements:concept-canvas-origin-clean-2">origin-clean</a> set to true. The flag is set to
  false when cross-origin images are used.</p>

  <p>The <code id="security-with-canvas-elements:dom-canvas-todataurl"><a href="#dom-canvas-todataurl">toDataURL()</a></code>, <code id="security-with-canvas-elements:dom-canvas-toblob"><a href="#dom-canvas-toblob">toBlob()</a></code>, and <code id="security-with-canvas-elements:dom-context-2d-getimagedata"><a href="#dom-context-2d-getimagedata">getImageData()</a></code> methods check the flag and will
  throw a <a id="security-with-canvas-elements:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="security-with-canvas-elements:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> rather than leak
  cross-origin data.</p>

  <p>The value of the <a href="#concept-canvas-origin-clean" id="security-with-canvas-elements:concept-canvas-origin-clean-3">origin-clean</a> flag is
  propagated from a source's bitmap to a new <code id="security-with-canvas-elements:imagebitmap-2"><a href="#imagebitmap">ImageBitmap</a></code> object by <code id="security-with-canvas-elements:dom-createimagebitmap"><a href="#dom-createimagebitmap">createImageBitmap()</a></code>. Conversely, a destination <code id="security-with-canvas-elements:the-canvas-element-3"><a href="#the-canvas-element">canvas</a></code> element's bitmap will have its <a href="#concept-canvas-origin-clean" id="security-with-canvas-elements:concept-canvas-origin-clean-4">origin-clean</a> flags set to false by <code id="security-with-canvas-elements:dom-context-2d-drawimage"><a href="#dom-context-2d-drawimage">drawImage</a></code> if the source image is an
  <code id="security-with-canvas-elements:imagebitmap-3"><a href="#imagebitmap">ImageBitmap</a></code> object whose bitmap has its <a href="#concept-canvas-origin-clean" id="security-with-canvas-elements:concept-canvas-origin-clean-5">origin-clean</a> flag set to false.</p>

  <p>The flag can be reset in certain situations; for example, when changing the value of the
  <code id="security-with-canvas-elements:attr-canvas-width"><a href="#attr-canvas-width">width</a></code> or the <code id="security-with-canvas-elements:attr-canvas-height"><a href="#attr-canvas-height">height</a></code> content attribute of the <code id="security-with-canvas-elements:the-canvas-element-4"><a href="#the-canvas-element">canvas</a></code> element
  to which a <code id="security-with-canvas-elements:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> is bound, the bitmap is
  cleared and its <a href="#concept-canvas-origin-clean" id="security-with-canvas-elements:concept-canvas-origin-clean-6">origin-clean</a> flag is reset.</p>

  <p>When using an <code id="security-with-canvas-elements:imagebitmaprenderingcontext"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code>, the value of the <a href="#concept-canvas-origin-clean" id="security-with-canvas-elements:concept-canvas-origin-clean-7">origin-clean</a> flag is propagated from
  <code id="security-with-canvas-elements:imagebitmap-4"><a href="#imagebitmap">ImageBitmap</a></code> objects when they are transferred to the <code id="security-with-canvas-elements:the-canvas-element-5"><a href="#the-canvas-element">canvas</a></code>
  via <a href="#dom-imagebitmaprenderingcontext-transferfromimagebitmap" id="security-with-canvas-elements:dom-imagebitmaprenderingcontext-transferfromimagebitmap">transferFromImageBitmap()</a>.</p>

  

  <h5 id="premultiplied-alpha-and-the-2d-rendering-context"><span class="secno">4.12.5.7</span> Premultiplied alpha and the 2D rendering context<a href="#premultiplied-alpha-and-the-2d-rendering-context" class="self-link"></a></h5>

  <p><dfn id="concept-premultiplied-alpha">Premultiplied alpha</dfn> refers to one way of
  representing transparency in an image, the other being non-premultiplied alpha.</p>

  <p>Under non-premultiplied alpha, the red, green, and blue components of a pixel represent that
  pixel's color, and its alpha component represents that pixel's opacity.</p>

  <p>Under premultiplied alpha, however, the red, green, and blue components of a pixel represent
  the amounts of color that the pixel adds to the image, and its alpha component represents the
  amount that the pixel obscures whatever is behind it.</p>

  <div class="example">
   <p>For instance, assuming the color components range from 0 (off) to 255 (full intensity), these
   example colors are represented in the following ways:</p>

   <table><thead><tr><th>CSS color representation
      </th><th>Premultiplied representation
      </th><th>Non-premultiplied representation
      </th><th>Description of color
      </th><th>Image of color blended above other content
    </th></tr></thead><tbody><tr><td>rgba(255, 127, 0, 1)
      </td><td>255, 127, 0, 255
      </td><td>255, 127, 0, 255
      </td><td>Completely-opaque orange
      </td><td><img src="images/premultiplied-example-1.png" width="96" alt="An opaque orange circle sits atop a background" height="96">
     </td></tr><tr><td>rgba(255, 255, 0, 0.5)
      </td><td>127, 127, 0, 127
      </td><td>255, 255, 0, 127
      </td><td>Halfway-opaque yellow
      </td><td><img src="images/premultiplied-example-2.png" width="96" alt="A yellow circle, halfway transparent, sits atop a background" height="96">
     </td></tr><tr><td>Unrepresentable
      </td><td>255, 127, 0, 127
      </td><td>Unrepresentable
      </td><td>Additive halfway-opaque orange
      </td><td><img src="images/premultiplied-example-3.png" width="96" alt="An orange circle somewhat brightens the background that it sits atop" height="96">
     </td></tr><tr><td>Unrepresentable
      </td><td>255, 127, 0, 0
      </td><td>Unrepresentable
      </td><td>Additive fully-transparent orange
      </td><td><img src="images/premultiplied-example-4.png" width="96" alt="An orange circle completely brightens the background that it sits atop" height="96">
     </td></tr><tr><td>rgba(255, 127, 0, 0)
      </td><td>0, 0, 0, 0
      </td><td>255, 127, 0, 0
      </td><td>Fully-transparent ("invisible") orange
      </td><td><img src="images/premultiplied-example-5.png" width="96" alt="An empty background with nothing atop it" height="96">
     </td></tr><tr><td>rgba(0, 127, 255, 0)
      </td><td>0, 0, 0, 0
      </td><td>255, 127, 0, 0
      </td><td>Fully-transparent ("invisible") turquoise
      </td><td><img src="images/premultiplied-example-5.png" width="96" alt="An empty background with nothing atop it" height="96">
   </td></tr></tbody></table>
  </div>

  <p><dfn id="convert-to-premultiplied">Converting a color value from a non-premultiplied
  representation to a premultiplied one</dfn> involves multiplying the color's red, green, and
  blue components by its alpha component (remapping the range of the alpha component such that
  "fully transparent" is 0, and "fully opaque" is 1).</p>

  <p><dfn id="convert-from-premultiplied">Converting a color value from a premultiplied
  representation to a non-premultiplied one</dfn> involves the inverse: dividing the color's red,
  green, and blue components by its alpha component.</p>

  <p>As certain colors can only be represented under premultiplied alpha (for instance, additive
  colors), and others can only be represented under non-premultiplied alpha (for instance,
  "invisible" colors which hold certain red, green, and blue values even with no opacity); and
  division and multiplication using finite precision entails a loss of accuracy, converting between
  premultiplied and non-premultiplied alpha is a lossy operation on colors that are not fully
  opaque.</p>

  <p>A <code id="premultiplied-alpha-and-the-2d-rendering-context:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code>'s <a href="#output-bitmap" id="premultiplied-alpha-and-the-2d-rendering-context:output-bitmap">output bitmap</a> and an
  <code id="premultiplied-alpha-and-the-2d-rendering-context:offscreencanvasrenderingcontext2d"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code>'s <a href="#output-bitmap" id="premultiplied-alpha-and-the-2d-rendering-context:output-bitmap-2">output bitmap</a> must use premultiplied
  alpha to represent transparent colors.</p>

  <p class="note">It is important for canvas bitmaps to represent colors using premultiplied alpha
  because it affects the range of representable colors. While additive colors cannot currently be
  drawn onto canvases directly because CSS colors are non-premultiplied and cannot represent them,
  it is still possible to, for instance, draw additive colors onto a WebGL canvas and then draw that
  WebGL canvas onto a 2D canvas via <code id="premultiplied-alpha-and-the-2d-rendering-context:dom-context-2d-drawimage"><a href="#dom-context-2d-drawimage">drawImage()</a></code>.</p>

  <h3 id="custom-elements"><span class="secno">4.13</span> Custom elements<a href="#custom-elements" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements" title="One of the key features of the Web Components standard is the ability to create custom elements that encapsulate your functionality on an HTML page, rather than having to make do with a long, nested batch of elements that together provide a custom page feature. This article introduces the use of the Custom Elements API.">Using_custom_elements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <h4 id="custom-elements-intro"><span class="secno">4.13.1</span> Introduction<a href="#custom-elements-intro" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p><a href="#custom-element" id="custom-elements-intro:custom-element">Custom elements</a> provide a way for authors to build their
  own fully-featured DOM elements. Although authors could always use non-standard elements in their
  documents, with application-specific behavior added after the fact by scripting or similar, such
  elements have historically been non-conforming and not very functional. By <a href="#element-definition" id="custom-elements-intro:element-definition">defining</a> a custom element, authors can inform the parser how to
  properly construct an element and how elements of that class should react to changes.</p>

  <p>Custom elements are part of a larger effort to "rationalise the platform", by explaining
  existing platform features (like the elements of HTML) in terms of lower-level author-exposed
  extensibility points (like custom element definition). Although today there are many limitations
  on the capabilities of custom elements—both functionally and semantically—that prevent them from
  fully explaining the behaviors of HTML's existing elements, we hope to shrink this gap over
  time.</p>

  <h5 id="custom-elements-autonomous-example"><span class="secno">4.13.1.1</span> Creating an autonomous custom element<a href="#custom-elements-autonomous-example" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>For the purposes of illustrating how to create an <a href="#autonomous-custom-element" id="custom-elements-autonomous-example:autonomous-custom-element">autonomous custom element</a>, let's
  define a custom element that encapsulates rendering a small icon for a country flag. Our goal is
  to be able to use it like so:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">flag-icon</c-> <c- e="">country</c-><c- o="">=</c-><c- s="">"nl"</c-><c- p="">&gt;&lt;/</c-><c- f="">flag-icon</c-><c- p="">&gt;</c-></code></pre>

  <p>To do this, we first declare a class for the custom element, extending
  <code id="custom-elements-autonomous-example:htmlelement"><a href="#htmlelement">HTMLElement</a></code>:</p>

  <pre><code class="js"><c- a="">class</c-> FlagIcon <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->_countryCode <c- o="">=</c-> <c- kc="">null</c-><c- p="">;</c->
  <c- p="">}</c->

  <c- k="">static</c-> observedAttributes <c- o="">=</c-> <c- p="">[</c-><c- u="">"country"</c-><c- p="">];</c->

  attributeChangedCallback<c- p="">(</c->name<c- p="">,</c-> oldValue<c- p="">,</c-> newValue<c- p="">)</c-> <c- p="">{</c->
    <c- c1="">// name will always be "country" due to observedAttributes</c->
    <c- k="">this</c-><c- p="">.</c->_countryCode <c- o="">=</c-> newValue<c- p="">;</c->
    <c- k="">this</c-><c- p="">.</c->_updateRendering<c- p="">();</c->
  <c- p="">}</c->
  connectedCallback<c- p="">()</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->_updateRendering<c- p="">();</c->
  <c- p="">}</c->

  get country<c- p="">()</c-> <c- p="">{</c->
    <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->_countryCode<c- p="">;</c->
  <c- p="">}</c->
  set country<c- p="">(</c->v<c- p="">)</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->setAttribute<c- p="">(</c-><c- u="">"country"</c-><c- p="">,</c-> v<c- p="">);</c->
  <c- p="">}</c->

  _updateRendering<c- p="">()</c-> <c- p="">{</c->
    <c- c1="">// Left as an exercise for the reader. But, you'll probably want to</c->
    <c- c1="">// check this.ownerDocument.defaultView to see if we've been</c->
    <c- c1="">// inserted into a document with a browsing context, and avoid</c->
    <c- c1="">// doing any work if not.</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

  <p>We then need to use this class to define the element:</p>

  <pre><code class="js">customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"flag-icon"</c-><c- p="">,</c-> FlagIcon<c- p="">);</c-></code></pre>

  <p>At this point, our above code will work! The parser, whenever it sees the <code>flag-icon</code> tag, will construct a new instance of our <code>FlagIcon</code> class, and tell our code about its new <code>country</code>
  attribute, which we then use to set the element's internal state and update its rendering (when
  appropriate).</p>

  <p>You can also create <code>flag-icon</code> elements using the DOM API:</p>

  <pre><code class="js"><c- a="">const</c-> flagIcon <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"flag-icon"</c-><c- p="">)</c->
flagIcon<c- p="">.</c->country <c- o="">=</c-> <c- u="">"jp"</c->
document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->flagIcon<c- p="">)</c-></code></pre>

  <p>Finally, we can also use the <a href="#custom-element-constructor" id="custom-elements-autonomous-example:custom-element-constructor">custom element constructor</a> itself. That is, the above
  code is equivalent to:</p>

  <pre><code class="js"><c- a="">const</c-> flagIcon <c- o="">=</c-> <c- k="">new</c-> FlagIcon<c- p="">()</c->
flagIcon<c- p="">.</c->country <c- o="">=</c-> <c- u="">"jp"</c->
document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->flagIcon<c- p="">)</c-></code></pre>

  <h5 id="custom-elements-face-example"><span class="secno">4.13.1.2</span> Creating a form-associated custom element<a href="#custom-elements-face-example" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Adding a static <code>formAssociated</code> property, with a true value, makes an
  <a href="#autonomous-custom-element" id="custom-elements-face-example:autonomous-custom-element">autonomous custom element</a> a <a href="#form-associated-custom-element" id="custom-elements-face-example:form-associated-custom-element">form-associated custom element</a>. The
  <code id="custom-elements-face-example:elementinternals"><a href="#elementinternals">ElementInternals</a></code> interface helps you to implement functions and properties common
  to form control elements.</p>

  <pre><code class="js"><c- a="">class</c-> MyCheckbox <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  <c- k="">static</c-> formAssociated <c- o="">=</c-> <c- kc="">true</c-><c- p="">;</c->
  <c- k="">static</c-> observedAttributes <c- o="">=</c-> <c- p="">[</c-><c- t="">'checked'</c-><c- p="">];</c->

  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->_internals <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->attachInternals<c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->_onClick<c- p="">.</c->bind<c- p="">(</c-><c- k="">this</c-><c- p="">));</c->
  <c- p="">}</c->

  get form<c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->form<c- p="">;</c-> <c- p="">}</c->
  get name<c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->getAttribute<c- p="">(</c-><c- t="">'name'</c-><c- p="">);</c-> <c- p="">}</c->
  get type<c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->localName<c- p="">;</c-> <c- p="">}</c->

  get checked<c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->hasAttribute<c- p="">(</c-><c- t="">'checked'</c-><c- p="">);</c-> <c- p="">}</c->
  set checked<c- p="">(</c->flag<c- p="">)</c-> <c- p="">{</c-> <c- k="">this</c-><c- p="">.</c->toggleAttribute<c- p="">(</c-><c- t="">'checked'</c-><c- p="">,</c-> Boolean<c- p="">(</c->flag<c- p="">));</c-> <c- p="">}</c->

  attributeChangedCallback<c- p="">(</c->name<c- p="">,</c-> oldValue<c- p="">,</c-> newValue<c- p="">)</c-> <c- p="">{</c->
    <c- c1="">// name will always be "checked" due to observedAttributes</c->
    <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->setFormValue<c- p="">(</c-><c- k="">this</c-><c- p="">.</c->checked <c- o="">?</c-> <c- t="">'on'</c-> <c- o="">:</c-> <c- kc="">null</c-><c- p="">);</c->
  <c- p="">}</c->

  _onClick<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->checked <c- o="">=</c-> <c- o="">!</c-><c- k="">this</c-><c- p="">.</c->checked<c- p="">;</c->
  <c- p="">}</c->
<c- p="">}</c->
customElements<c- p="">.</c->define<c- p="">(</c-><c- t="">'my-checkbox'</c-><c- p="">,</c-> MyCheckbox<c- p="">);</c-></code></pre>

  <p>You can use the custom element <code>my-checkbox</code> like a built-in
  form-associated element. For example, putting it in <code id="custom-elements-face-example:the-form-element"><a href="#the-form-element">form</a></code> or <code id="custom-elements-face-example:the-label-element"><a href="#the-label-element">label</a></code>
  associates the <code>my-checkbox</code> element with them, and submitting the
  <code id="custom-elements-face-example:the-form-element-2"><a href="#the-form-element">form</a></code> will send data provided by <code>my-checkbox</code> implementation.
  </p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"..."</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">"..."</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;&lt;</c-><c- f="">my-checkbox</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"agreed"</c-><c- p="">&gt;&lt;/</c-><c- f="">my-checkbox</c-><c- p="">&gt;</c-> I read the agreement.<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"submit"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
</code></pre>

  <h5 id="custom-elements-accessibility-example"><span class="secno">4.13.1.3</span> Creating a custom element with default accessible roles, states, and properties<a href="#custom-elements-accessibility-example" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>By using the appropriate properties of <code id="custom-elements-accessibility-example:elementinternals"><a href="#elementinternals">ElementInternals</a></code>, your custom element can
  have default accessibility semantics. The following code expands our form-associated checkbox from
  the previous section to properly set its default role and checkedness, as viewed by accessibility
  technology:</p>

  <pre><code class="js"><c- a="">class</c-> MyCheckbox <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  <c- k="">static</c-> formAssociated <c- o="">=</c-> <c- kc="">true</c-><c- p="">;</c->
  <c- k="">static</c-> observedAttributes <c- o="">=</c-> <c- p="">[</c-><c- t="">'checked'</c-><c- p="">];</c->

  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->_internals <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->attachInternals<c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->_onClick<c- p="">.</c->bind<c- p="">(</c-><c- k="">this</c-><c- p="">));</c->

<mark>    <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->role <c- o="">=</c-> <c- t="">'checkbox'</c-><c- p="">;</c->
    <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->ariaChecked <c- o="">=</c-> <c- t="">'false'</c-><c- p="">;</c-></mark>
  <c- p="">}</c->

  get form<c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->form<c- p="">;</c-> <c- p="">}</c->
  get name<c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->getAttribute<c- p="">(</c-><c- t="">'name'</c-><c- p="">);</c-> <c- p="">}</c->
  get type<c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->localName<c- p="">;</c-> <c- p="">}</c->

  get checked<c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->hasAttribute<c- p="">(</c-><c- t="">'checked'</c-><c- p="">);</c-> <c- p="">}</c->
  set checked<c- p="">(</c->flag<c- p="">)</c-> <c- p="">{</c-> <c- k="">this</c-><c- p="">.</c->toggleAttribute<c- p="">(</c-><c- t="">'checked'</c-><c- p="">,</c-> Boolean<c- p="">(</c->flag<c- p="">));</c-> <c- p="">}</c->

  attributeChangedCallback<c- p="">(</c->name<c- p="">,</c-> oldValue<c- p="">,</c-> newValue<c- p="">)</c-> <c- p="">{</c->
    <c- c1="">// name will always be "checked" due to observedAttributes</c->
    <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->setFormValue<c- p="">(</c-><c- k="">this</c-><c- p="">.</c->checked <c- o="">?</c-> <c- t="">'on'</c-> <c- o="">:</c-> <c- kc="">null</c-><c- p="">);</c->
<mark>    <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->ariaChecked <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->checked<c- p="">;</c-></mark>
  <c- p="">}</c->

  _onClick<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->checked <c- o="">=</c-> <c- o="">!</c-><c- k="">this</c-><c- p="">.</c->checked<c- p="">;</c->
  <c- p="">}</c->
<c- p="">}</c->
customElements<c- p="">.</c->define<c- p="">(</c-><c- t="">'my-checkbox'</c-><c- p="">,</c-> MyCheckbox<c- p="">);</c-></code></pre>

  <p>Note that, like for built-in elements, these are only defaults, and can be overridden by the
  page author using the <code id="custom-elements-accessibility-example:attr-aria-role"><a href="#attr-aria-role">role</a></code> and <code id="custom-elements-accessibility-example:attr-aria-*"><a href="#attr-aria-*">aria-*</a></code> attributes:</p>

  <pre class="bad"><code class="html"><c- c="">&lt;!-- This markup is non-conforming --&gt;</c->
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"checkbox"</c-> <c- e="">checked</c-> <c- e="">role</c-><c- o="">=</c-><c- s="">"button"</c-> <c- e="">aria-checked</c-><c- o="">=</c-><c- s="">"false"</c-><c- p="">&gt;</c-></code></pre>

<pre class="bad"><code class="html"><c- c="">&lt;!-- This markup is probably not what the custom element author intended --&gt;</c->
<c- p="">&lt;</c-><c- f="">my-checkbox</c-> <c- e="">role</c-><c- o="">=</c-><c- s="">"button"</c-> <c- e="">checked</c-> <c- e="">aria-checked</c-><c- o="">=</c-><c- s="">"false"</c-><c- p="">&gt;</c-></code></pre>

  <p>Custom element authors are encouraged to state what aspects of their accessibility semantics
  are strong native semantics, i.e., should not be overridden by users of the custom element. In our
  example, the author of the <code>my-checkbox</code> element would state that its
  <a id="custom-elements-accessibility-example:role" href="https://w3c.github.io/aria/#dfn-role" data-x-internal="role">role</a> and <code id="custom-elements-accessibility-example:attr-aria-checked"><a data-x-internal="attr-aria-checked" href="https://w3c.github.io/aria/#aria-checked">aria-checked</a></code> values are strong
  native semantics, thus discouraging code such as the above.</p>

  <h5 id="custom-elements-customized-builtin-example"><span class="secno">4.13.1.4</span> Creating a customized built-in element<a href="#custom-elements-customized-builtin-example" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p><a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element">Customized built-in elements</a> are a distinct
  kind of <a href="#custom-element" id="custom-elements-customized-builtin-example:custom-element">custom element</a>, which are defined slightly differently and used very
  differently compared to <a href="#autonomous-custom-element" id="custom-elements-customized-builtin-example:autonomous-custom-element">autonomous custom
  elements</a>. They exist to allow reuse of behaviors from the existing elements of HTML, by
  extending those elements with new custom functionality. This is important since many of the
  existing behaviors of HTML elements can unfortunately not be duplicated by using purely <a href="#autonomous-custom-element" id="custom-elements-customized-builtin-example:autonomous-custom-element-2">autonomous custom elements</a>. Instead, <a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element-2">customized built-in elements</a> allow the installation of
  custom construction behavior, lifecycle hooks, and prototype chain onto existing elements,
  essentially "mixing in" these capabilities on top of the already-existing element.</p>

  <p><a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element-3">Customized built-in elements</a> require a
  distinct syntax from <a href="#autonomous-custom-element" id="custom-elements-customized-builtin-example:autonomous-custom-element-3">autonomous custom elements</a>
  because user agents and other software key off an element's local name in order to identify the
  element's semantics and behavior. That is, the concept of <a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element-4">customized built-in elements</a> building on top of existing behavior depends
  crucially on the extended elements retaining their original local name.</p>

  <p>In this example, we'll be creating a <a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element-5">customized built-in element</a> named <code>plastic-button</code>, which behaves like a normal button but gets fancy animation
  effects added whenever you click on it. We start by defining a class, just like before, although
  this time we extend <code id="custom-elements-customized-builtin-example:htmlbuttonelement"><a href="#htmlbuttonelement">HTMLButtonElement</a></code> instead of <code id="custom-elements-customized-builtin-example:htmlelement"><a href="#htmlelement">HTMLElement</a></code>:</p>

  <pre><code class="js"><c- a="">class</c-> PlasticButton <c- k="">extends</c-> HTMLButtonElement <c- p="">{</c->
  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->

    <c- k="">this</c-><c- p="">.</c->addEventListener<c- p="">(</c-><c- u="">"click"</c-><c- p="">,</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- c1="">// Draw some fancy animation effects!</c->
    <c- p="">});</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

  <p>When defining our custom element, we have to also specify the <code id="custom-elements-customized-builtin-example:dom-elementdefinitionoptions-extends"><a href="#dom-elementdefinitionoptions-extends">extends</a></code> option:</p>

  <pre><code class="js">customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"plastic-button"</c-><c- p="">,</c-> PlasticButton<c- p="">,</c-> <c- p="">{</c-> <c- k="">extends</c-><c- o="">:</c-> <c- u="">"button"</c-> <c- p="">});</c-></code></pre>

  <p>In general, the name of the element being extended cannot be determined simply by looking at
  what element interface it extends, as many elements share the same interface (such as
  <code id="custom-elements-customized-builtin-example:the-q-element"><a href="#the-q-element">q</a></code> and <code id="custom-elements-customized-builtin-example:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code> both sharing <code id="custom-elements-customized-builtin-example:htmlquoteelement"><a href="#htmlquoteelement">HTMLQuoteElement</a></code>).</p>

  <p>To construct our <a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element-6">customized built-in element</a> from parsed HTML source text, we use
  the <code id="custom-elements-customized-builtin-example:attr-is"><a href="#attr-is">is</a></code> attribute on a <code id="custom-elements-customized-builtin-example:the-button-element"><a href="#the-button-element">button</a></code> element:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">is</c-><c- o="">=</c-><c- s="">"plastic-button"</c-><c- p="">&gt;</c->Click Me!<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-></code></pre>

  <p>Trying to use a <a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element-7">customized built-in element</a> as an <a href="#autonomous-custom-element" id="custom-elements-customized-builtin-example:autonomous-custom-element-4">autonomous custom
  element</a> will <em>not</em> work; that is, <code>&lt;plastic-button&gt;Click
  me?&lt;/plastic-button&gt;</code> will simply create an <code id="custom-elements-customized-builtin-example:htmlelement-2"><a href="#htmlelement">HTMLElement</a></code> with no special
  behavior.</p>

  <p>If you need to create a customized built-in element programmatically, you can use the following
  form of <code id="custom-elements-customized-builtin-example:dom-document-createelement"><a data-x-internal="dom-document-createelement" href="https://dom.spec.whatwg.org/#dom-document-createelement">createElement()</a></code>:</p>

  <pre><code class="js"><c- a="">const</c-> plasticButton <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"button"</c-><c- p="">,</c-> <c- p="">{</c-> is<c- o="">:</c-> <c- u="">"plastic-button"</c-> <c- p="">});</c->
plasticButton<c- p="">.</c->textContent <c- o="">=</c-> <c- u="">"Click me!"</c-><c- p="">;</c-></code></pre>

  <p>And as before, the constructor will also work:</p>

  <pre><code class="js"><c- a="">const</c-> plasticButton2 <c- o="">=</c-> <c- k="">new</c-> PlasticButton<c- p="">();</c->
console<c- p="">.</c->log<c- p="">(</c->plasticButton2<c- p="">.</c->localName<c- p="">);</c->  <c- c1="">// will output "button"</c->
console<c- p="">.</c->assert<c- p="">(</c->plasticButton2 <c- k="">instanceof</c-> PlasticButton<c- p="">);</c->
console<c- p="">.</c->assert<c- p="">(</c->plasticButton2 <c- k="">instanceof</c-> HTMLButtonElement<c- p="">);</c-></code></pre>

  <p>Note that when creating a customized built-in element programmatically, the <code id="custom-elements-customized-builtin-example:attr-is-2"><a href="#attr-is">is</a></code> attribute will not be present in the DOM, since it was not explicitly
  set. However, <a href="#attr-is-during-serialization">it will be added to the output when
  serializing</a>:</p>

  <pre><code class="js">console<c- p="">.</c->assert<c- p="">(</c-><c- o="">!</c->plasticButton<c- p="">.</c->hasAttribute<c- p="">(</c-><c- u="">"is"</c-><c- p="">));</c->
console<c- p="">.</c->log<c- p="">(</c->plasticButton<c- p="">.</c->outerHTML<c- p="">);</c-> <c- c1="">// will output '&lt;button is="plastic-button"&gt;&lt;/button&gt;'</c-></code></pre>

  <p>Regardless of how it is created, all of the ways in which <code id="custom-elements-customized-builtin-example:the-button-element-2"><a href="#the-button-element">button</a></code> is special
  apply to such "plastic buttons" as well: their focus behavior, ability to participate in <a href="#concept-form-submit" id="custom-elements-customized-builtin-example:concept-form-submit">form submission</a>, the <code id="custom-elements-customized-builtin-example:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code> attribute, and so on.</p>

  <p id="customized-built-in-element-restrictions"><a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element-8">Customized built-in elements</a> are designed to allow extension of existing HTML
  elements that have useful user-agent supplied behavior or APIs. As such, they can only extend
  existing HTML elements defined in this specification, and cannot extend legacy elements such as
  <code id="custom-elements-customized-builtin-example:bgsound"><a href="#bgsound">bgsound</a></code>, <code id="custom-elements-customized-builtin-example:blink"><a href="#blink">blink</a></code>, <code id="custom-elements-customized-builtin-example:isindex"><a href="#isindex">isindex</a></code>, <code id="custom-elements-customized-builtin-example:keygen"><a href="#keygen">keygen</a></code>,
  <code id="custom-elements-customized-builtin-example:multicol"><a href="#multicol">multicol</a></code>, <code id="custom-elements-customized-builtin-example:nextid"><a href="#nextid">nextid</a></code>, or <code id="custom-elements-customized-builtin-example:spacer"><a href="#spacer">spacer</a></code> that have been defined to use
  <code id="custom-elements-customized-builtin-example:htmlunknownelement"><a href="#htmlunknownelement">HTMLUnknownElement</a></code> as their <a id="custom-elements-customized-builtin-example:element-interface" href="https://dom.spec.whatwg.org/#concept-element-interface" data-x-internal="element-interface">element interface</a>.</p>

  <p>One reason for this requirement is future-compatibility: if a <a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element-9">customized built-in
  element</a> was defined that extended a currently-unknown element, for example <code>combobox</code>, this would prevent this specification from defining a <code>combobox</code> element in the future, as consumers of the derived <a href="#customized-built-in-element" id="custom-elements-customized-builtin-example:customized-built-in-element-10">customized
  built-in element</a> would have come to depend on their base element having no interesting
  user-agent-supplied behavior.</p>

  <h5 id="custom-elements-autonomous-drawbacks"><span class="secno">4.13.1.5</span> Drawbacks of autonomous custom elements<a href="#custom-elements-autonomous-drawbacks" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>As specified below, and alluded to above, simply defining and using an element called
  <code>taco-button</code> does not mean that such elements <a href="#represents" id="custom-elements-autonomous-drawbacks:represents">represent</a> buttons. That is, tools such as web browsers, search engines,
  or accessibility technology will not automatically treat the resulting element as a button just
  based on its defined name.</p>

  <p>To convey the desired button semantics to a variety of users, while still using an
  <a href="#autonomous-custom-element" id="custom-elements-autonomous-drawbacks:autonomous-custom-element">autonomous custom element</a>, a number of techniques would need to be employed:</p>

  <ul><li><p>The addition of the <code id="custom-elements-autonomous-drawbacks:attr-tabindex"><a href="#attr-tabindex">tabindex</a></code> attribute would make the
   <code>taco-button</code> <a href="#focusable" id="custom-elements-autonomous-drawbacks:focusable">focusable</a>. Note that if the
   <code>taco-button</code> were to become logically disabled, the <code id="custom-elements-autonomous-drawbacks:attr-tabindex-2"><a href="#attr-tabindex">tabindex</a></code> attribute would need to be removed.</p></li><li><p>The addition of an ARIA role and various ARIA states and properties helps convey semantics
   to accessibility technology. For example, setting the <a id="custom-elements-autonomous-drawbacks:role" href="https://w3c.github.io/aria/#dfn-role" data-x-internal="role">role</a> to "<code id="custom-elements-autonomous-drawbacks:attr-aria-role-button"><a data-x-internal="attr-aria-role-button" href="https://w3c.github.io/aria/#button">button</a></code>" will convey the semantics that this is a button,
   enabling users to successfully interact with the control using usual button-like interactions in
   their accessibility technology. Setting the <code id="custom-elements-autonomous-drawbacks:attr-aria-label"><a data-x-internal="attr-aria-label" href="https://w3c.github.io/aria/#aria-label">aria-label</a></code>
   property is necessary to give the button an <a href="https://w3c.github.io/aria/#dfn-accessible-name" id="custom-elements-autonomous-drawbacks:concept-accessible-name" data-x-internal="concept-accessible-name">accessible
   name</a>, instead of having accessibility technology traverse its child text nodes and
   announce them. And setting the <code id="custom-elements-autonomous-drawbacks:attr-aria-disabled"><a data-x-internal="attr-aria-disabled" href="https://w3c.github.io/aria/#aria-disabled">aria-disabled</a></code> state to
   "<code>true</code>" when the button is logically disabled conveys to accessibility
   technology the button's disabled state.</p></li><li><p>The addition of event handlers to handle commonly-expected button behaviors helps convey
   the semantics of the button to web browser users. In this case, the most relevant event handler
   would be one that proxies appropriate <code id="custom-elements-autonomous-drawbacks:event-keydown"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code> events to
   become <code id="custom-elements-autonomous-drawbacks:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> events, so that you can activate the button both
   with keyboard and by clicking.</p></li><li><p>In addition to any default visual styling provided for <code>taco-button</code>
   elements, the visual styling will also need to be updated to reflect changes in logical state,
   such as becoming disabled; that is, whatever style sheet has rules for <code>taco-button</code> will also need to have rules for <code>taco-button[disabled]</code>.</p></li></ul>

  <p>With these points in mind, a full-featured <code>taco-button</code> that took on the
  responsibility of conveying button semantics (including the ability to be disabled) might look
  something like this:</p>

  <pre id="custom-elements-autonomous-drawbacks-example"><code class="js"><c- a="">class</c-> TacoButton <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  <c- k="">static</c-> observedAttributes <c- o="">=</c-> <c- p="">[</c-><c- u="">"disabled"</c-><c- p="">];</c->

  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->_internals <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->attachInternals<c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->role <c- o="">=</c-> <c- u="">"button"</c-><c- p="">;</c->

    <c- k="">this</c-><c- p="">.</c->addEventListener<c- p="">(</c-><c- u="">"keydown"</c-><c- p="">,</c-> e <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->code <c- o="">===</c-> <c- u="">"Enter"</c-> <c- o="">||</c-> e<c- p="">.</c->code <c- o="">===</c-> <c- u="">"Space"</c-><c- p="">)</c-> <c- p="">{</c->
        <c- k="">this</c-><c- p="">.</c->dispatchEvent<c- p="">(</c-><c- k="">new</c-> PointerEvent<c- p="">(</c-><c- u="">"click"</c-><c- p="">,</c-> <c- p="">{</c->
          bubbles<c- o="">:</c-> <c- kc="">true</c-><c- p="">,</c->
          cancelable<c- o="">:</c-> <c- kc="">true</c->
        <c- p="">}));</c->
      <c- p="">}</c->
    <c- p="">});</c->

    <c- k="">this</c-><c- p="">.</c->addEventListener<c- p="">(</c-><c- u="">"click"</c-><c- p="">,</c-> e <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->disabled<c- p="">)</c-> <c- p="">{</c->
        e<c- p="">.</c->preventDefault<c- p="">();</c->
        e<c- p="">.</c->stopImmediatePropagation<c- p="">();</c->
      <c- p="">}</c->
    <c- p="">});</c->

    <c- k="">this</c-><c- p="">.</c->_observer <c- o="">=</c-> <c- k="">new</c-> MutationObserver<c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->ariaLabel <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->textContent<c- p="">;</c->
    <c- p="">});</c->
  <c- p="">}</c->

  connectedCallback<c- p="">()</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->setAttribute<c- p="">(</c-><c- u="">"tabindex"</c-><c- p="">,</c-> <c- u="">"0"</c-><c- p="">);</c->

    <c- k="">this</c-><c- p="">.</c->_observer<c- p="">.</c->observe<c- p="">(</c-><c- k="">this</c-><c- p="">,</c-> <c- p="">{</c->
      childList<c- o="">:</c-> <c- kc="">true</c-><c- p="">,</c->
      characterData<c- o="">:</c-> <c- kc="">true</c-><c- p="">,</c->
      subtree<c- o="">:</c-> <c- kc="">true</c->
    <c- p="">});</c->
  <c- p="">}</c->

  disconnectedCallback<c- p="">()</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->_observer<c- p="">.</c->disconnect<c- p="">();</c->
  <c- p="">}</c->

  get disabled<c- p="">()</c-> <c- p="">{</c->
    <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->hasAttribute<c- p="">(</c-><c- u="">"disabled"</c-><c- p="">);</c->
  <c- p="">}</c->
  set disabled<c- p="">(</c->flag<c- p="">)</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->toggleAttribute<c- p="">(</c-><c- u="">"disabled"</c-><c- p="">,</c-> Boolean<c- p="">(</c->flag<c- p="">));</c->
  <c- p="">}</c->

  attributeChangedCallback<c- p="">(</c->name<c- p="">,</c-> oldValue<c- p="">,</c-> newValue<c- p="">)</c-> <c- p="">{</c->
    <c- c1="">// name will always be "disabled" due to observedAttributes</c->
    <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->disabled<c- p="">)</c-> <c- p="">{</c->
      <c- k="">this</c-><c- p="">.</c->removeAttribute<c- p="">(</c-><c- u="">"tabindex"</c-><c- p="">);</c->
      <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->ariaDisabled <c- o="">=</c-> <c- u="">"true"</c-><c- p="">;</c->
    <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
      <c- k="">this</c-><c- p="">.</c->setAttribute<c- p="">(</c-><c- u="">"tabindex"</c-><c- p="">,</c-> <c- u="">"0"</c-><c- p="">);</c->
      <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->ariaDisabled <c- o="">=</c-> <c- u="">"false"</c-><c- p="">;</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

  <p>Even with this rather-complicated element definition, the element is not a pleasure to use for
  consumers: it will be continually "sprouting" <code id="custom-elements-autonomous-drawbacks:attr-tabindex-3"><a href="#attr-tabindex">tabindex</a></code>
  attributes of its own volition, and its choice of <code>tabindex="0"</code> focusability
  behavior may not match the <code id="custom-elements-autonomous-drawbacks:the-button-element"><a href="#the-button-element">button</a></code> behavior on the current platform. This is because
  as of now there is no way to specify default focus behavior for custom elements, forcing the use
  of the <code id="custom-elements-autonomous-drawbacks:attr-tabindex-4"><a href="#attr-tabindex">tabindex</a></code> attribute to do so (even though it is usually
  reserved for allowing the consumer to override default behavior).</p>

  <p>In contrast, a simple <a href="#customized-built-in-element" id="custom-elements-autonomous-drawbacks:customized-built-in-element">customized built-in element</a>, as shown in the previous
  section, would automatically inherit the semantics and behavior of the <code id="custom-elements-autonomous-drawbacks:the-button-element-2"><a href="#the-button-element">button</a></code>
  element, with no need to implement these behaviors manually. In general, for any elements with
  nontrivial behavior and semantics that build on top of existing elements of HTML, <a href="#customized-built-in-element" id="custom-elements-autonomous-drawbacks:customized-built-in-element-2">customized built-in elements</a> will be easier to
  develop, maintain, and consume.</p>

  <h5 id="custom-elements-upgrades-examples"><span class="secno">4.13.1.6</span> Upgrading elements after their creation<a href="#custom-elements-upgrades-examples" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Because <a href="#element-definition" id="custom-elements-upgrades-examples:element-definition">element definition</a> can occur at any time, a non-custom element could be
  <a href="https://dom.spec.whatwg.org/#concept-create-element" id="custom-elements-upgrades-examples:create-an-element" data-x-internal="create-an-element">created</a>, and then later become a <a href="#custom-element" id="custom-elements-upgrades-examples:custom-element">custom
  element</a> after an appropriate <a href="#custom-element-definition" id="custom-elements-upgrades-examples:custom-element-definition">definition</a> is
  registered. We call this process "upgrading" the element, from a normal element into a custom
  element.</p>

  <p><a href="#upgrades" id="custom-elements-upgrades-examples:upgrades">Upgrades</a> enable scenarios where it may be
  preferable for <a href="#custom-element-definition" id="custom-elements-upgrades-examples:custom-element-definition-2">custom element definitions</a> to be
  registered after relevant elements have been initially created, such as by the parser. They allow
  progressive enhancement of the content in the custom element. For example, in the following HTML
  document the element definition for <code>img-viewer</code> is loaded
  asynchronously:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Image viewer example<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">img-viewer</c-> <c- e="">filter</c-><c- o="">=</c-><c- s="">"Kelvin"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/tree.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"A beautiful tree towering over an empty savannah"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">img-viewer</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"js/elements/img-viewer.js"</c-> <c- e="">async</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  <p>The definition for the <code>img-viewer</code> element here is loaded using a
  <code id="custom-elements-upgrades-examples:the-script-element"><a href="#the-script-element">script</a></code> element marked with the <code id="custom-elements-upgrades-examples:attr-script-async"><a href="#attr-script-async">async</a></code>
  attribute, placed after the <code>&lt;img-viewer&gt;</code> tag in the markup. While the
  script is loading, the <code>img-viewer</code> element will be treated as an undefined
  element, similar to a <code id="custom-elements-upgrades-examples:the-span-element"><a href="#the-span-element">span</a></code>. Once the script loads, it will define the <code>img-viewer</code> element, and the existing <code>img-viewer</code> element on
  the page will be upgraded, applying the custom element's definition (which presumably includes
  applying an image filter identified by the string "Kelvin", enhancing the image's visual
  appearance).</p>

  <hr>

  <p>Note that <a href="#upgrades" id="custom-elements-upgrades-examples:upgrades-2">upgrades</a> only apply to elements in the
  document tree. (Formally, elements that are <a id="custom-elements-upgrades-examples:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>.) An element that is not
  inserted into a document will stay un-upgraded. An example illustrates this point:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Upgrade edge-cases example<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">example-element</c-><c- p="">&gt;&lt;/</c-><c- f="">example-element</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- u="">"use strict"</c-><c- p="">;</c->

  <c- a="">const</c-> inDocument <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"example-element"</c-><c- p="">);</c->
  <c- a="">const</c-> outOfDocument <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"example-element"</c-><c- p="">);</c->

  <c- c1="">// Before the element definition, both are HTMLElement:</c->
  console<c- p="">.</c->assert<c- p="">(</c->inDocument <c- k="">instanceof</c-> HTMLElement<c- p="">);</c->
  console<c- p="">.</c->assert<c- p="">(</c->outOfDocument <c- k="">instanceof</c-> HTMLElement<c- p="">);</c->

  <c- a="">class</c-> ExampleElement <c- k="">extends</c-> HTMLElement <c- p="">{}</c->
  customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"example-element"</c-><c- p="">,</c-> ExampleElement<c- p="">);</c->

  <c- c1="">// After element definition, the in-document element was upgraded:</c->
  console<c- p="">.</c->assert<c- p="">(</c->inDocument <c- k="">instanceof</c-> ExampleElement<c- p="">);</c->
  console<c- p="">.</c->assert<c- p="">(</c-><c- o="">!</c-><c- p="">(</c->outOfDocument <c- k="">instanceof</c-> ExampleElement<c- p="">));</c->

  document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->outOfDocument<c- p="">);</c->

  <c- c1="">// Now that we've moved the element into the document, it too was upgraded:</c->
  console<c- p="">.</c->assert<c- p="">(</c->outOfDocument <c- k="">instanceof</c-> ExampleElement<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  <h5 id="scoped-custom-element-registries"><span class="secno">4.13.1.7</span> Scoped custom element registries<a href="#scoped-custom-element-registries" class="self-link"></a></h5>

  <p>To allow multiple libraries to co-exist without explicit coordination,
  <code id="scoped-custom-element-registries:customelementregistry"><a href="#customelementregistry">CustomElementRegistry</a></code> can be used in a scoped fashion as well.</p>

  <pre><code class="js"><c- a="">const</c-> scoped <c- o="">=</c-> <c- k="">new</c-> CustomElementRegistry<c- p="">();</c->
scoped<c- p="">.</c->define<c- p="">(</c-><c- u="">"example-element"</c-><c- p="">,</c-> ExampleElement<c- p="">);</c->

<c- a="">const</c-> element <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"example-element"</c-><c- p="">,</c-> <c- p="">{</c-> customElementRegistry<c- o="">:</c-> scoped <c- p="">});</c-></code></pre>

  <p>A node with an associated scoped <code id="scoped-custom-element-registries:customelementregistry-2"><a href="#customelementregistry">CustomElementRegistry</a></code> will use that registry for
  all its operations, such as when invoking <code id="scoped-custom-element-registries:dom-element-sethtmlunsafe"><a href="#dom-element-sethtmlunsafe">setHTMLUnsafe()</a></code>.</p>

  <h5 id="exposing-custom-element-states"><span class="secno">4.13.1.8</span> Exposing custom element states<a href="#exposing-custom-element-states" class="self-link"></a></h5>

  <p>Built-in elements provided by user agents have certain states that can change over time
  depending on user interaction and other factors, and are exposed to web authors through <a href="https://drafts.csswg.org/selectors/#pseudo-class" id="exposing-custom-element-states:pseudo-class" data-x-internal="pseudo-class">pseudo-classes</a>. For example, some form controls have the "invalid"
  state, which is exposed through the <code id="exposing-custom-element-states:selector-invalid"><a href="#selector-invalid">:invalid</a></code>
  <a id="exposing-custom-element-states:pseudo-class-2" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a>.</p>

  <p>Like built-in elements, <a href="#custom-element" id="exposing-custom-element-states:custom-element">custom elements</a> can have various
  states to be in too, and <a href="#custom-element" id="exposing-custom-element-states:custom-element-2">custom element</a> authors want to expose these states in a
  similar fashion as the built-in elements.</p>

  <p>This is done via the <code id="exposing-custom-element-states:selector-custom"><a href="#selector-custom">:state()</a></code> pseudo-class. A custom
  element author can use the <code id="exposing-custom-element-states:dom-elementinternals-states"><a href="#dom-elementinternals-states">states</a></code> property of
  <code id="exposing-custom-element-states:elementinternals"><a href="#elementinternals">ElementInternals</a></code> to add and remove such custom states, which are then exposed as
  arguments to the <code id="exposing-custom-element-states:selector-custom-2"><a href="#selector-custom">:state()</a></code> pseudo-class.

  </p><div class="example">
   <p>The following shows how <code id="exposing-custom-element-states:selector-custom-3"><a href="#selector-custom">:state()</a></code> can be used to style a
   custom checkbox element. Assume that <code>LabeledCheckbox</code> doesn't expose its
   "checked" state via a content attribute.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- a="">class</c-> LabeledCheckbox <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->_internals <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->attachInternals<c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->_onClick<c- p="">.</c->bind<c- p="">(</c-><c- k="">this</c-><c- p="">));</c->

    <c- a="">const</c-> shadowRoot <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->attachShadow<c- p="">({</c->mode<c- o="">:</c-> <c- t="">'closed'</c-><c- p="">});</c->
    shadowRoot<c- p="">.</c->innerHTML <c- o="">=</c->
      <c- sb="">`&lt;style&gt;</c->
<c- sb="">       :host::before {</c->
<c- sb="">         content: '[ ]';</c->
<c- sb="">         white-space: pre;</c->
<c- sb="">         font-family: monospace;</c->
<c- sb="">       }</c->
<c- sb="">       :host(:state(checked))::before { content: '[x]' }</c->
<c- sb="">       &lt;/style&gt;</c->
<c- sb="">       &lt;slot&gt;Label&lt;/slot&gt;`</c-><c- p="">;</c->
  <c- p="">}</c->

  get checked<c- p="">()</c-> <c- p="">{</c-> <c- k="">return</c-> <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->states<c- p="">.</c->has<c- p="">(</c-><c- t="">'checked'</c-><c- p="">);</c-> <c- p="">}</c->

  set checked<c- p="">(</c->flag<c- p="">)</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->flag<c- p="">)</c->
      <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->states<c- p="">.</c->add<c- p="">(</c-><c- t="">'checked'</c-><c- p="">);</c->
    <c- k="">else</c->
      <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->states<c- p="">.</c-><c- k="">delete</c-><c- p="">(</c-><c- t="">'checked'</c-><c- p="">);</c->
  <c- p="">}</c->

  _onClick<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->checked <c- o="">=</c-> <c- o="">!</c-><c- k="">this</c-><c- p="">.</c->checked<c- p="">;</c->
  <c- p="">}</c->
<c- p="">}</c->

customElements<c- p="">.</c->define<c- p="">(</c-><c- t="">'labeled-checkbox'</c-><c- p="">,</c-> LabeledCheckbox<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- f="">labeled-checkbox</c-> <c- p="">{</c-> <c- k="">border</c-><c- p="">:</c-> <c- kc="">dashed</c-> <c- kc="">red</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">labeled-checkbox</c-><c- p="">:</c-><c- nd="">state</c-><c- o="">(</c-><c- f="">checked</c-><c- o="">)</c-> <c- p="">{</c-> <c- k="">border</c-><c- p="">:</c-> <c- kc="">solid</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">labeled-checkbox</c-><c- p="">&gt;</c->You need to check this<c- p="">&lt;/</c-><c- f="">labeled-checkbox</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>Custom pseudo-classes can even target shadow parts. An extension of the above example shows
   this:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- a="">class</c-> QuestionBox <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->
    <c- a="">const</c-> shadowRoot <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->attachShadow<c- p="">({</c->mode<c- o="">:</c-> <c- t="">'closed'</c-><c- p="">});</c->
    shadowRoot<c- p="">.</c->innerHTML <c- o="">=</c->
      <c- sb="">`&lt;div&gt;&lt;slot&gt;Question&lt;/slot&gt;&lt;/div&gt;</c->
<c- sb="">       &lt;labeled-checkbox part='checkbox'&gt;Yes&lt;/labeled-checkbox&gt;`</c-><c- p="">;</c->
  <c- p="">}</c->
<c- p="">}</c->
customElements<c- p="">.</c->define<c- p="">(</c-><c- t="">'question-box'</c-><c- p="">,</c-> QuestionBox<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- f="">question-box</c-><c- p="">::</c-><c- nd="">part</c-><c- o="">(</c-><c- f="">checkbox</c-><c- o="">)</c-> <c- p="">{</c-> <c- k="">color</c-><c- p="">:</c-> <c- kc="">red</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">question-box</c-><c- p="">::</c-><c- nd="">part</c-><c- o="">(</c-><c- f="">checkbox</c-><c- o="">)</c-><c- p="">:</c-><c- nd="">state</c-><c- o="">(</c-><c- f="">checked</c-><c- o="">)</c-> <c- p="">{</c-> <c- k="">color</c-><c- p="">:</c-> <c- kc="">green</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">question-box</c-><c- p="">&gt;</c->Continue?<c- p="">&lt;/</c-><c- f="">question-box</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <h4 id="custom-element-conformance"><span class="secno">4.13.2</span> Requirements for custom element constructors and
  reactions<a href="#custom-element-conformance" class="self-link"></a></h4>

  <p>When authoring <a href="#custom-element-constructor" id="custom-element-conformance:custom-element-constructor">custom element constructors</a>,
  authors are bound by the following conformance requirements:</p>

  <ul><li><p>A parameter-less call to <code>super()</code> must be the first statement in the
   constructor body, to establish the correct prototype chain and <b>this</b> value before any
   further code is run.</p></li><li><p>A <code>return</code> statement must not appear anywhere inside the constructor
   body, unless it is a simple early-return (<code>return</code> or <code>return
   this</code>).</p></li><li><p>The constructor must not use the <code id="custom-element-conformance:dom-document-write"><a href="#dom-document-write">document.write()</a></code>
   or <code id="custom-element-conformance:dom-document-open"><a href="#dom-document-open">document.open()</a></code> methods.</p></li><li><p>The element's attributes and children must not be inspected, as in the non-<a href="#upgrades" id="custom-element-conformance:upgrades">upgrade</a> case none will be present, and relying on
   upgrades makes the element less usable.</p></li><li><p>The element must not gain any attributes or children, as this violates the expectations of
   consumers who use the <code id="custom-element-conformance:dom-document-createelement"><a data-x-internal="dom-document-createelement" href="https://dom.spec.whatwg.org/#dom-document-createelement">createElement</a></code> or <code id="custom-element-conformance:dom-document-createelementns"><a data-x-internal="dom-document-createelementns" href="https://dom.spec.whatwg.org/#dom-document-createelementns">createElementNS</a></code> methods.</p></li><li><p>In general, work should be deferred to <code>connectedCallback</code> as much as
   possible—especially work involving fetching resources or rendering. However, note that <code>connectedCallback</code> can be called more than once, so any initialization work that
   is truly one-time will need a guard to prevent it from running twice.</p></li><li><p>In general, the constructor should be used to set up initial state and default values, and
   to set up event listeners and possibly a <a id="custom-element-conformance:shadow-root" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a>.</p></li></ul>

  <p>Several of these requirements are checked during <a href="https://dom.spec.whatwg.org/#concept-create-element" id="custom-element-conformance:create-an-element" data-x-internal="create-an-element">element
  creation</a>, either directly or indirectly, and failing to follow them will result in a custom
  element that cannot be instantiated by the parser or DOM APIs. This is true even if the work is
  done inside a constructor-initiated <a href="#microtask" id="custom-element-conformance:microtask">microtask</a>, as a <a href="#perform-a-microtask-checkpoint" id="custom-element-conformance:perform-a-microtask-checkpoint">microtask checkpoint</a> can occur immediately after construction.</p>

  <p>When authoring <a href="#concept-custom-element-reaction" id="custom-element-conformance:concept-custom-element-reaction">custom element reactions</a>,
  authors should avoid manipulating the node tree as this can lead to unexpected results.</p>

  <div class="example">
   <p>An element's <code>connectedCallback</code> can be queued before the element is
   disconnected, but as the callback queue is still processed, it results in a <code>connectedCallback</code> for an element that is no longer connected:</p>

   <pre><code class="js"><c- a="">class</c-> CParent <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  connectedCallback<c- p="">()</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->firstChild<c- p="">.</c->remove<c- p="">();</c->
  <c- p="">}</c->
<c- p="">}</c->
customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"c-parent"</c-><c- p="">,</c-> CParent<c- p="">);</c->

<c- a="">class</c-> CChild <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  connectedCallback<c- p="">()</c-> <c- p="">{</c->
    console<c- p="">.</c->log<c- p="">(</c-><c- u="">"CChild connectedCallback: isConnected ="</c-><c- p="">,</c-> <c- k="">this</c-><c- p="">.</c->isConnected<c- p="">);</c->
  <c- p="">}</c->
<c- p="">}</c->
customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"c-child"</c-><c- p="">,</c-> CChild<c- p="">);</c->

<c- a="">const</c-> parent <c- o="">=</c-> <c- k="">new</c-> CParent<c- p="">(),</c->
      child <c- o="">=</c-> <c- k="">new</c-> CChild<c- p="">();</c->
parent<c- p="">.</c->append<c- p="">(</c->child<c- p="">);</c->
document<c- p="">.</c->body<c- p="">.</c->append<c- p="">(</c->parent<c- p="">);</c->

<c- c1="">// Logs:</c->
<c- c1="">// CChild connectedCallback: isConnected = false</c-></code></pre>
  </div>

  <h5 id="preserving-custom-element-state-when-moved"><span class="secno">4.13.2.1</span> Preserving custom element state when moved<a href="#preserving-custom-element-state-when-moved" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>When manipulating the DOM tree, an element can be <a href="https://dom.spec.whatwg.org/#concept-node-move-ext" id="preserving-custom-element-state-when-moved:concept-node-move-ext" data-x-internal="concept-node-move-ext">moved</a> in the tree while connected. This applies to custom
  elements as well. By default, the "<code>disconnectedCallback</code>" and "<code>connectedCallback</code>" would be called on the element, one after the other. This is
  done to maintain compatibility with existing custom elements that predate the <code id="preserving-custom-element-state-when-moved:dom-parentnode-movebefore"><a data-x-internal="dom-parentnode-movebefore" href="https://dom.spec.whatwg.org/#dom-parentnode-movebefore">moveBefore()</a></code> method. This means that by default, custom
  elements reset their state as if they were removed and re-inserted. In the example <a href="#custom-elements-autonomous-drawbacks-example">above</a>, the impact would be that the
  observer would be disconnected and re-connected, and the tab index would be reset.</p>

  <p>To opt in to a state-preserving behavior while <a href="https://dom.spec.whatwg.org/#concept-node-move-ext" id="preserving-custom-element-state-when-moved:concept-node-move-ext-2" data-x-internal="concept-node-move-ext">moving</a>, the author can implement a "<code>connectedMoveCallback</code>". The existence of this callback, even if empty, would
  supersede the default behavior of calling "<code>disconnectedCallback</code>" and "<code>connectedCallback</code>". "<code>connectedMoveCallback</code>" can also be an
  appropriate place to execute logic that depends on the element's ancestors. For example:</p>

  <pre><code class="js"><c- a="">class</c-> TacoButton <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  <c- k="">static</c-> observedAttributes <c- o="">=</c-> <c- p="">[</c-><c- u="">"disabled"</c-><c- p="">];</c->

  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->_internals <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->attachInternals<c- p="">();</c->
    <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->role <c- o="">=</c-> <c- u="">"button"</c-><c- p="">;</c->

    <c- k="">this</c-><c- p="">.</c->_observer <c- o="">=</c-> <c- k="">new</c-> MutationObserver<c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->ariaLabel <c- o="">=</c-> <c- k="">this</c-><c- p="">.</c->textContent<c- p="">;</c->
    <c- p="">});</c->
  <c- p="">}</c->

  _notifyMain<c- p="">()</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->parentElement<c- p="">.</c->tagName <c- o="">===</c-> <c- u="">"MAIN"</c-><c- p="">)</c-> <c- p="">{</c->
      <c- c1="">// Execute logic that depends on ancestors.</c->
    <c- p="">}</c->
  <c- p="">}</c->

  connectedCallback<c- p="">()</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->setAttribute<c- p="">(</c-><c- u="">"tabindex"</c-><c- p="">,</c-> <c- u="">"0"</c-><c- p="">);</c->

    <c- k="">this</c-><c- p="">.</c->_observer<c- p="">.</c->observe<c- p="">(</c-><c- k="">this</c-><c- p="">,</c-> <c- p="">{</c->
      childList<c- o="">:</c-> <c- kc="">true</c-><c- p="">,</c->
      characterData<c- o="">:</c-> <c- kc="">true</c-><c- p="">,</c->
      subtree<c- o="">:</c-> <c- kc="">true</c->
    <c- p="">});</c->

    <c- k="">this</c-><c- p="">.</c->_notifyMain<c- p="">();</c->
  <c- p="">}</c->

  disconnectedCallback<c- p="">()</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->_observer<c- p="">.</c->disconnect<c- p="">();</c->
  <c- p="">}</c->

  <c- c1="">// Implementing this function would avoid resetting the tab index or re-registering the</c->
  <c- c1="">// mutation observer when this element is moved inside the DOM without being disconnected.</c->
  connectedMoveCallback<c- p="">()</c-> <c- p="">{</c->
    <c- c1="">// The parent can change during a state-preserving move.</c->
    <c- k="">this</c-><c- p="">.</c->_notifyMain<c- p="">();</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

  <h4 id="custom-elements-core-concepts"><span class="secno">4.13.3</span> Core concepts<a href="#custom-elements-core-concepts" class="self-link"></a></h4>

  <p>A <dfn id="custom-element" data-export="">custom element</dfn> is an element that is <a href="https://dom.spec.whatwg.org/#concept-element-custom" id="custom-elements-core-concepts:concept-element-custom" data-x-internal="concept-element-custom">custom</a>. Informally, this means that its constructor and
  prototype are defined by the author, instead of by the user agent. This author-supplied
  constructor function is called the <dfn id="custom-element-constructor" data-export="">custom element constructor</dfn>.</p>

  <p>Two distinct types of <a href="#custom-element" id="custom-elements-core-concepts:custom-element">custom elements</a> can be defined:</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/is" title="The is global attribute allows you to specify that a standard HTML element should behave like a defined custom built-in element (see Using custom elements for more details).">Global_attributes/is</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>67+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><ul><li><p>An <dfn id="autonomous-custom-element" data-export="">autonomous custom element</dfn>, which is defined with no <code id="custom-elements-core-concepts:dom-elementdefinitionoptions-extends"><a href="#dom-elementdefinitionoptions-extends">extends</a></code> option. These types of custom
   elements have a local name equal to their <a href="#concept-custom-element-definition-name" id="custom-elements-core-concepts:concept-custom-element-definition-name">defined name</a>.</p></li><li><p>A <dfn id="customized-built-in-element" data-export="">customized built-in element</dfn>, which is defined with an <code id="custom-elements-core-concepts:dom-elementdefinitionoptions-extends-2"><a href="#dom-elementdefinitionoptions-extends">extends</a></code> option. These types of custom
   elements have a local name equal to the value passed in their <code id="custom-elements-core-concepts:dom-elementdefinitionoptions-extends-3"><a href="#dom-elementdefinitionoptions-extends">extends</a></code> option, and their <a href="#concept-custom-element-definition-name" id="custom-elements-core-concepts:concept-custom-element-definition-name-2">defined name</a> is used as the value of the
   <dfn data-dfn-for="html-global" id="attr-is" data-dfn-type="element-attr"><code>is</code></dfn> attribute, which
   therefore must be a <a href="#valid-custom-element-name" id="custom-elements-core-concepts:valid-custom-element-name">valid custom element name</a>.</p></li></ul>

  <p>After a <a href="#custom-element" id="custom-elements-core-concepts:custom-element-2">custom element</a> is <a href="https://dom.spec.whatwg.org/#concept-create-element" id="custom-elements-core-concepts:create-an-element" data-x-internal="create-an-element">created</a>,
  changing the value of the <code id="custom-elements-core-concepts:attr-is"><a href="#attr-is">is</a></code> attribute does not
  change the element's behavior, as it is saved on the element as its <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="custom-elements-core-concepts:concept-element-is-value" data-x-internal="concept-element-is-value"><code>is</code> value</a>.</p>

  <p><a href="#autonomous-custom-element" id="custom-elements-core-concepts:autonomous-custom-element">Autonomous custom elements</a> have the following
  element definition:</p>

  <dl class="element"><dt><a href="#concept-element-categories" id="custom-elements-core-concepts:concept-element-categories">Categories</a>:</dt><dd><a href="#flow-content-2" id="custom-elements-core-concepts:flow-content-2">Flow content</a>.</dd><dd><a href="#phrasing-content-2" id="custom-elements-core-concepts:phrasing-content-2">Phrasing content</a>.</dd><dd><a href="#palpable-content-2" id="custom-elements-core-concepts:palpable-content-2">Palpable content</a>.</dd><dd>For <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element">form-associated custom elements</a>: <a href="#category-listed" id="custom-elements-core-concepts:category-listed">Listed</a>, <a href="#category-label" id="custom-elements-core-concepts:category-label">labelable</a>, <a href="#category-submit" id="custom-elements-core-concepts:category-submit">submittable</a>, and <a href="#category-reset" id="custom-elements-core-concepts:category-reset">resettable</a> <a href="#form-associated-element" id="custom-elements-core-concepts:form-associated-element">form-associated element</a>.</dd><dt><a href="#concept-element-contexts" id="custom-elements-core-concepts:concept-element-contexts">Contexts in which this element can be used</a>:</dt><dd>Where <a href="#phrasing-content-2" id="custom-elements-core-concepts:phrasing-content-2-2">phrasing content</a> is expected.</dd><dt><a href="#concept-element-content-model" id="custom-elements-core-concepts:concept-element-content-model">Content model</a>:</dt><dd><a href="#transparent" id="custom-elements-core-concepts:transparent">Transparent</a>.</dd><dt><a href="#concept-element-attributes" id="custom-elements-core-concepts:concept-element-attributes">Content attributes</a>:</dt><dd><a href="#global-attributes" id="custom-elements-core-concepts:global-attributes">Global attributes</a>, except the <code id="custom-elements-core-concepts:attr-is-2"><a href="#attr-is">is</a></code> attribute</dd><dd><code id="custom-elements-core-concepts:attr-fae-form"><a href="#attr-fae-form">form</a></code>, for <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-2">form-associated custom elements</a> —  Associates the element with a <code id="custom-elements-core-concepts:the-form-element"><a href="#the-form-element">form</a></code> element
     </dd><dd><code id="custom-elements-core-concepts:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code>, for <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-3">form-associated custom elements</a> —  Whether the form control is disabled
     </dd><dd><code id="custom-elements-core-concepts:attr-face-readonly"><a href="#attr-face-readonly">readonly</a></code>, for <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-4">form-associated custom elements</a> —  Affects <code id="custom-elements-core-concepts:dom-elementinternals-willvalidate"><a href="#dom-elementinternals-willvalidate">willValidate</a></code>, plus any behavior added by the custom element author
     </dd><dd><code id="custom-elements-core-concepts:attr-fe-name"><a href="#attr-fe-name">name</a></code>, for <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-5">form-associated custom elements</a> —  Name of the element to use for <a href="#form-submission-2" id="custom-elements-core-concepts:form-submission-2">form submission</a> and in the <code id="custom-elements-core-concepts:dom-form-elements"><a href="#dom-form-elements">form.elements</a></code> API 
     </dd><dd>Any other attribute that has no namespace (see prose).</dd><dt><a href="#concept-element-accessibility-considerations" id="custom-elements-core-concepts:concept-element-accessibility-considerations">Accessibility considerations</a>:</dt><dd>For <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-6">form-associated custom elements</a>: <a href="https://w3c.github.io/html-aria/#el-form-associated-custom-element">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-form-associated-custom-element">for implementers</a>.</dd><dd>Otherwise: <a href="https://w3c.github.io/html-aria/#el-autonomous-custom-element">for authors</a>; <a href="https://w3c.github.io/html-aam/#el-autonomous-custom-element">for implementers</a>.</dd><dt><a href="#concept-element-dom" id="custom-elements-core-concepts:concept-element-dom">DOM interface</a>:</dt><dd>Supplied by the element's author (inherits from <code id="custom-elements-core-concepts:htmlelement"><a href="#htmlelement">HTMLElement</a></code>)</dd></dl>


  <p>An <a href="#autonomous-custom-element" id="custom-elements-core-concepts:autonomous-custom-element-2">autonomous custom element</a> does not have any special meaning: it
  <a href="#represents" id="custom-elements-core-concepts:represents">represents</a> its children. A <a href="#customized-built-in-element" id="custom-elements-core-concepts:customized-built-in-element">customized built-in element</a> inherits the
  semantics of the element that it extends.</p>

  <p>Any namespace-less attribute that is relevant to the element's functioning, as determined by
  the element's author, may be specified on an <a href="#autonomous-custom-element" id="custom-elements-core-concepts:autonomous-custom-element-3">autonomous custom element</a>, so long as
  the attribute name is a <a id="custom-elements-core-concepts:valid-attribute-local-name" href="https://dom.spec.whatwg.org/#valid-attribute-local-name" data-x-internal="valid-attribute-local-name">valid attribute local name</a> and contains no <a href="https://infra.spec.whatwg.org/#ascii-upper-alpha" id="custom-elements-core-concepts:uppercase-ascii-letters" data-x-internal="uppercase-ascii-letters">ASCII upper alphas</a>. The exception is the <code id="custom-elements-core-concepts:attr-is-3"><a href="#attr-is">is</a></code> attribute, which must not be specified on an <a href="#autonomous-custom-element" id="custom-elements-core-concepts:autonomous-custom-element-4">autonomous custom
  element</a> (and which will have no effect if it is).</p>

  <p><a href="#customized-built-in-element" id="custom-elements-core-concepts:customized-built-in-element-2">Customized built-in elements</a> follow the
  normal requirements for attributes, based on the elements they extend. To add custom
  attribute-based behavior, use <code id="custom-elements-core-concepts:attr-data-*"><a href="#attr-data-*">data-*</a></code> attributes.</p>

  <hr>

  <div data-algorithm="">
  <p>An <a href="#autonomous-custom-element" id="custom-elements-core-concepts:autonomous-custom-element-5">autonomous custom element</a> is called a <dfn id="form-associated-custom-element" data-export="">form-associated custom
  element</dfn> if the element is associated with a <a href="#custom-element-definition" id="custom-elements-core-concepts:custom-element-definition">custom element definition</a> whose
  <a href="#concept-custom-element-definition-form-associated" id="custom-elements-core-concepts:concept-custom-element-definition-form-associated">form-associated</a> field is
  set to true.</p>
  </div>

  <p>The <code id="custom-elements-core-concepts:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> attribute represents the <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-7">form-associated
  custom element</a>'s name. The <code id="custom-elements-core-concepts:attr-fe-disabled-2"><a href="#attr-fe-disabled">disabled</a></code> attribute is
  used to make the <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-8">form-associated custom element</a> non-interactive and to prevent its
  <a href="#face-submission-value" id="custom-elements-core-concepts:face-submission-value">submission value</a> from being submitted. The <code id="custom-elements-core-concepts:attr-fae-form-2"><a href="#attr-fae-form">form</a></code> attribute is used to explicitly associate the
  <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-9">form-associated custom element</a> with its <a href="#form-owner" id="custom-elements-core-concepts:form-owner">form owner</a>.</p>

  <p>The <dfn data-dfn-for="form-associated custom elements" id="attr-face-readonly" data-dfn-type="element-attr"><code>readonly</code></dfn> attribute of <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-10">form-associated custom elements</a> specifies that the element is <a href="#barred-from-constraint-validation" id="custom-elements-core-concepts:barred-from-constraint-validation">barred
  from constraint validation</a>. User agents don't provide any other behavior for the attribute,
  but custom element authors should, where possible, use its presence to make their control
  non-editable in some appropriate fashion, similar to the behavior for the <a href="#attr-input-readonly" id="custom-elements-core-concepts:attr-input-readonly">readonly</a> attribute on built-in form controls.</p>

  <div data-algorithm="">
  <p><strong>Constraint validation</strong>: If the <code id="custom-elements-core-concepts:attr-face-readonly-2"><a href="#attr-face-readonly">readonly</a></code> attribute is specified on a <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-11">form-associated
  custom element</a>, the element is <a href="#barred-from-constraint-validation" id="custom-elements-core-concepts:barred-from-constraint-validation-2">barred from constraint validation</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#concept-form-reset-control" id="custom-elements-core-concepts:concept-form-reset-control">reset algorithm</a> for <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-12">form-associated custom elements</a> is to <a href="#enqueue-a-custom-element-callback-reaction" id="custom-elements-core-concepts:enqueue-a-custom-element-callback-reaction">enqueue
  a custom element callback reaction</a> with the element, callback name "<code>formResetCallback</code>", and « ».</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>A string <var>name</var> is a <dfn id="valid-custom-element-name" data-export="">valid custom element name</dfn> if all of the
  following are true:</p>

  <ul><li>
    <p><var>name</var> is a <a id="custom-elements-core-concepts:valid-element-local-name" href="https://dom.spec.whatwg.org/#valid-element-local-name" data-x-internal="valid-element-local-name">valid element local name</a>;</p>

    <p class="note">This ensures the custom element can be created with <code id="custom-elements-core-concepts:dom-document-createelement"><a data-x-internal="dom-document-createelement" href="https://dom.spec.whatwg.org/#dom-document-createelement">createElement()</a></code>.</p>
   </li><li>
    <p><var>name</var>'s 0th <a id="custom-elements-core-concepts:code-point" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> is an <a id="custom-elements-core-concepts:lowercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-lower-alpha" data-x-internal="lowercase-ascii-letters">ASCII lower alpha</a>;</p>

    <p class="note">This ensures the HTML parser will treat the name as a tag name instead of as
    text.</p>
   </li><li>
    <p><var>name</var> does not contain any <a href="https://infra.spec.whatwg.org/#ascii-upper-alpha" id="custom-elements-core-concepts:uppercase-ascii-letters-2" data-x-internal="uppercase-ascii-letters">ASCII upper
    alphas</a>;</p>

    <p class="note">This ensures the user agent can always treat HTML elements
    ASCII-case-insensitively.</p>
   </li><li>
    <p><var>name</var> contains a U+002D (-); and</p>

    <p class="note">This is used for namespacing and to ensure forward compatibility (since no
    elements will be added to HTML, SVG, or MathML with hyphen-containing local names going
    forward).</p>
   </li><li>
    <p><var>name</var> is not one of the following:</p>

    <ul class="brief"><li>"<code>annotation-xml</code>"</li><li>"<code>color-profile</code>"</li><li>"<code>font-face</code>"</li><li>"<code>font-face-src</code>"</li><li>"<code>font-face-uri</code>"</li><li>"<code>font-face-format</code>"</li><li>"<code>font-face-name</code>"</li><li>"<code>missing-glyph</code>"</li></ul>

    <p class="note">The list of names above is the summary of all hyphen-containing element names
    from the <a href="#other-applicable-specifications" id="custom-elements-core-concepts:other-applicable-specifications">applicable specifications</a>, namely
    <cite>SVG 2</cite> and <cite>MathML</cite>. <a href="#refsSVG">[SVG]</a> <a href="#refsMATHML">[MATHML]</a></p>
   </li></ul>
  </div>

  <p>Apart from these restrictions, a large variety of names is allowed, to give maximum
  flexibility for use cases like <code>&lt;math-α&gt;</code> or <code>&lt;emotion-😍&gt;</code>.</p>

  

  <hr>

  <p>A <dfn id="custom-element-definition" data-export="">custom element definition</dfn> describes a <a href="#custom-element" id="custom-elements-core-concepts:custom-element-3">custom element</a> and
  consists of:</p>

  <dl><dt>A <dfn data-dfn-for="custom element definition" id="concept-custom-element-definition-name" data-export="">name</dfn></dt><dd>A <a href="#valid-custom-element-name" id="custom-elements-core-concepts:valid-custom-element-name-2">valid custom element name</a></dd><dt>A <dfn data-dfn-for="custom element definition" id="concept-custom-element-definition-local-name" data-export="">local name</dfn></dt><dd>A local name</dd><dt>A <dfn data-dfn-for="custom element definition" id="concept-custom-element-definition-constructor" data-export="">constructor</dfn></dt><dd>A Web IDL <code id="custom-elements-core-concepts:customelementconstructor"><a href="#customelementconstructor">CustomElementConstructor</a></code> callback function type value wrapping
   the <a href="#custom-element-constructor" id="custom-elements-core-concepts:custom-element-constructor">custom element constructor</a></dd><dt>A list of <dfn id="concept-custom-element-definition-observed-attributes">observed
   attributes</dfn></dt><dd>A <code>sequence&lt;DOMString&gt;</code></dd><dt>A collection of <dfn id="concept-custom-element-definition-lifecycle-callbacks">lifecycle callbacks</dfn></dt><dd>A map, whose keys are the strings "<code>connectedCallback</code>", "<code>disconnectedCallback</code>", "<code>adoptedCallback</code>", "<code>connectedMoveCallback</code>", "<code>attributeChangedCallback</code>",
   "<code>formAssociatedCallback</code>", "<code>formDisabledCallback</code>",
   "<code>formResetCallback</code>", and "<code>formStateRestoreCallback</code>". The corresponding values are either a Web IDL <code id="custom-elements-core-concepts:idl-function"><a data-x-internal="idl-function" href="https://webidl.spec.whatwg.org/#common-Function">Function</a></code> callback function type value, or null. By default the value
   of each entry is null.</dd><dt>A <dfn id="concept-custom-element-definition-construction-stack">construction
   stack</dfn></dt><dd>A list, initially empty, that is manipulated by the <a href="#concept-upgrade-an-element" id="custom-elements-core-concepts:concept-upgrade-an-element">upgrade an element</a> algorithm and the <a href="#html-element-constructors">HTML element constructors</a>. Each entry in the list will be
   either an element or an <dfn id="concept-already-constructed-marker"><i>already
   constructed</i> marker</dfn>.</dd><dt>A <dfn id="concept-custom-element-definition-form-associated">form-associated</dfn>
   boolean</dt><dd>If this is true, user agent treats elements associated to this
   <a href="#custom-element-definition" id="custom-elements-core-concepts:custom-element-definition-2">custom element definition</a> as <a href="#form-associated-custom-element" id="custom-elements-core-concepts:form-associated-custom-element-13">form-associated custom elements</a>.</dd><dt>A <dfn id="concept-custom-element-definition-disable-internals">disable
   internals</dfn> boolean</dt><dd>Controls <code id="custom-elements-core-concepts:dom-attachinternals"><a href="#dom-attachinternals">attachInternals()</a></code>.

   </dd><dt>A <dfn data-dfn-for="custom element definition" id="concept-custom-element-definition-disable-shadow" data-export="">disable shadow</dfn> boolean</dt><dd>Controls <code id="custom-elements-core-concepts:dom-element-attachshadow"><a data-x-internal="dom-element-attachshadow" href="https://dom.spec.whatwg.org/#dom-element-attachshadow">attachShadow()</a></code>.
  </dd></dl>

  <div data-algorithm="">
  <p>To <dfn id="look-up-a-custom-element-definition" data-export="">look up a custom element definition</dfn>, given null or a
  <code id="custom-elements-core-concepts:customelementregistry"><a href="#customelementregistry">CustomElementRegistry</a></code> object <var>registry</var>, string-or-null
  <var>namespace</var>, string <var>localName</var>, and string-or-null <var>is</var>, perform the
  following steps. They will return either a <a href="#custom-element-definition" id="custom-elements-core-concepts:custom-element-definition-3">custom element definition</a> or null:</p>

  <ol><li><p>If <var>registry</var> is null, then return null.</p></li><li><p>If <var>namespace</var> is not the <a id="custom-elements-core-concepts:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, then return null.</p></li><li><p>If <var>registry</var>'s <a href="#custom-element-definition-set" id="custom-elements-core-concepts:custom-element-definition-set">custom element definition set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="custom-elements-core-concepts:list-contains" data-x-internal="list-contains">contains</a> an item with <a href="#concept-custom-element-definition-name" id="custom-elements-core-concepts:concept-custom-element-definition-name-3">name</a> and <a href="#concept-custom-element-definition-local-name" id="custom-elements-core-concepts:concept-custom-element-definition-local-name">local name</a> both equal to
   <var>localName</var>, then return that item.</p></li><li><p>If <var>registry</var>'s <a href="#custom-element-definition-set" id="custom-elements-core-concepts:custom-element-definition-set-2">custom element definition set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="custom-elements-core-concepts:list-contains-2" data-x-internal="list-contains">contains</a> an item with <a href="#concept-custom-element-definition-name" id="custom-elements-core-concepts:concept-custom-element-definition-name-4">name</a> equal to <var>is</var> and <a href="#concept-custom-element-definition-local-name" id="custom-elements-core-concepts:concept-custom-element-definition-local-name-2">local name</a> equal to
   <var>localName</var>, then return that item.</p></li><li><p>Return null.</p></li></ol>
  </div>

  

  <h4 id="custom-elements-api"><span class="secno">4.13.4</span> The <code id="custom-elements-api:customelementregistry"><a href="#customelementregistry">CustomElementRegistry</a></code> interface<a href="#custom-elements-api" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry" title="The CustomElementRegistry interface provides methods for registering custom elements and querying registered elements. To get an instance of it, use the window.customElements property.">CustomElementRegistry</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  

  <p>Each <a href="#similar-origin-window-agent" id="custom-elements-api:similar-origin-window-agent">similar-origin window agent</a> has an associated <dfn data-dfn-for="similar-origin
  window agent" id="active-custom-element-constructor-map" data-export="">active custom element constructor map</dfn>, which is a <a href="https://infra.spec.whatwg.org/#ordered-map" id="custom-elements-api:ordered-map" data-x-internal="ordered-map">map</a> of constructors to <code id="custom-elements-api:customelementregistry-2"><a href="#customelementregistry">CustomElementRegistry</a></code> objects.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/customElements" title="The customElements read-only property of the Window interface returns a reference to the CustomElementRegistry object, which can be used to register new custom elements and get information about previously registered custom elements.">Window/customElements</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <code id="custom-elements-api:window"><a href="#window">Window</a></code> <dfn data-dfn-for="Window" id="dom-window-customelements" data-dfn-type="attribute"><code>customElements</code></dfn> getter steps are:</p>

  <ol><li>
    <p><a id="custom-elements-api:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <a id="custom-elements-api:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="custom-elements-api:concept-document-window">associated
    <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="custom-elements-api:document-custom-element-registry" data-x-internal="document-custom-element-registry">custom element
    registry</a> is a <code id="custom-elements-api:customelementregistry-3"><a href="#customelementregistry">CustomElementRegistry</a></code> object.</p>

    <p class="note">A <code id="custom-elements-api:window-2"><a href="#window">Window</a></code>'s <a href="#concept-document-window" id="custom-elements-api:concept-document-window-2">associated
    <code>Document</code></a> is always created with a new
    <code id="custom-elements-api:customelementregistry-4"><a href="#customelementregistry">CustomElementRegistry</a></code> object.</p>
   </li><li><p>Return <a id="custom-elements-api:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="custom-elements-api:concept-document-window-3">associated
   <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="custom-elements-api:document-custom-element-registry-2" data-x-internal="document-custom-element-registry">custom element
   registry</a>.</p></li></ol>
  </div>

  <pre><code data-var-scope="" class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="customelementregistry" data-dfn-type="interface"><c- g="">CustomElementRegistry</c-></dfn> {
  <a href="#dom-customelementregistry" id="custom-elements-api:dom-customelementregistry"><c- g="">constructor</c-></a>();

  [<a href="#cereactions" id="custom-elements-api:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-customelementregistry-define" id="custom-elements-api:dom-customelementregistry-define"><c- g="">define</c-></a>(<c- b="">DOMString</c-> <var><c- g="">name</c-></var>, <a href="#customelementconstructor" id="custom-elements-api:customelementconstructor"><c- n="">CustomElementConstructor</c-></a> <var><c- g="">constructor</c-></var>, <c- b="">optional</c-> <a href="#elementdefinitionoptions" id="custom-elements-api:elementdefinitionoptions"><c- n="">ElementDefinitionOptions</c-></a> <var><c- g="">options</c-></var> = {});
  (<a href="#customelementconstructor" id="custom-elements-api:customelementconstructor-2"><c- n="">CustomElementConstructor</c-></a> <c- b="">or</c-> <c- b="">undefined</c->) <a href="#dom-customelementregistry-get" id="custom-elements-api:dom-customelementregistry-get"><c- g="">get</c-></a>(<c- b="">DOMString</c-> <var><c- g="">name</c-></var>);
  <c- b="">DOMString</c->? <a href="#dom-customelementregistry-getname" id="custom-elements-api:dom-customelementregistry-getname"><c- g="">getName</c-></a>(<c- n="">CustomElementConstructor</c-> <var><c- g="">constructor</c-></var>);
  <a href="https://webidl.spec.whatwg.org/#idl-promise" id="custom-elements-api:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<a href="#customelementconstructor" id="custom-elements-api:customelementconstructor-3"><c- n="">CustomElementConstructor</c-></a>&gt; <a href="#dom-customelementregistry-whendefined" id="custom-elements-api:dom-customelementregistry-whendefined"><c- g="">whenDefined</c-></a>(<c- b="">DOMString</c-> <var><c- g="">name</c-></var>);
  [<a href="#cereactions" id="custom-elements-api:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-customelementregistry-upgrade" id="custom-elements-api:dom-customelementregistry-upgrade"><c- g="">upgrade</c-></a>(<a id="custom-elements-api:node" href="https://dom.spec.whatwg.org/#interface-node" data-x-internal="node"><c- n="">Node</c-></a> <var><c- g="">root</c-></var>);
  <c- b="">undefined</c-> <a href="#dom-customelementregistry-initialize" id="custom-elements-api:dom-customelementregistry-initialize"><c- g="">initialize</c-></a>(<a id="custom-elements-api:node-2" href="https://dom.spec.whatwg.org/#interface-node" data-x-internal="node"><c- n="">Node</c-></a> <var><c- g="">root</c-></var>);
};

<c- b="">callback</c-> <dfn id="customelementconstructor" data-dfn-type="callback"><c- g="">CustomElementConstructor</c-></dfn> = <a href="#htmlelement" id="custom-elements-api:htmlelement"><c- n="">HTMLElement</c-></a> ();

<c- b="">dictionary</c-> <dfn id="elementdefinitionoptions" data-dfn-type="dictionary"><c- g="">ElementDefinitionOptions</c-></dfn> {
  <c- b="">DOMString</c-> <dfn data-dfn-for="ElementDefinitionOptions" id="dom-elementdefinitionoptions-extends" data-dfn-type="dict-member"><c- g="">extends</c-></dfn>;
};</code></pre>

  <p>Every <code id="custom-elements-api:customelementregistry-5"><a href="#customelementregistry">CustomElementRegistry</a></code> has an <dfn data-dfn-for="CustomElementRegistry" id="is-scoped" data-export="">is
  scoped</dfn>, a boolean, initially false.</p>

  <p>Every <code id="custom-elements-api:customelementregistry-6"><a href="#customelementregistry">CustomElementRegistry</a></code> has a <dfn data-dfn-for="CustomElementRegistry" id="scoped-document-set" data-export="">scoped
  document set</dfn>, a <a id="custom-elements-api:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <code id="custom-elements-api:document"><a href="#document">Document</a></code> objects, initially « ».</p>

  <p>Every <code id="custom-elements-api:customelementregistry-7"><a href="#customelementregistry">CustomElementRegistry</a></code> has a <dfn id="custom-element-definition-set">custom element definition set</dfn>, a
  <a id="custom-elements-api:set-2" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <a href="#custom-element-definition" id="custom-elements-api:custom-element-definition">custom element definitions</a>,
  initially « ». Lookup of items in this <a id="custom-elements-api:set-3" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> uses their <a href="#concept-custom-element-definition-name" id="custom-elements-api:concept-custom-element-definition-name">name</a>, <a href="#concept-custom-element-definition-local-name" id="custom-elements-api:concept-custom-element-definition-local-name">local name</a>, or <a href="#concept-custom-element-definition-constructor" id="custom-elements-api:concept-custom-element-definition-constructor">constructor</a>.</p>

  <p>Every <code id="custom-elements-api:customelementregistry-8"><a href="#customelementregistry">CustomElementRegistry</a></code> also has an <dfn id="element-definition-is-running">element definition is running</dfn>
  boolean which is used to prevent reentrant invocations of <a href="#element-definition" id="custom-elements-api:element-definition">element definition</a>. It is
  initially false.</p>

  <p>Every <code id="custom-elements-api:customelementregistry-9"><a href="#customelementregistry">CustomElementRegistry</a></code> also has a <dfn id="when-defined-promise-map">when-defined promise map</dfn>, a
  <a href="https://infra.spec.whatwg.org/#ordered-map" id="custom-elements-api:ordered-map-2" data-x-internal="ordered-map">map</a> of <a href="#valid-custom-element-name" id="custom-elements-api:valid-custom-element-name">valid custom
  element names</a> to promises. It is used to implement the <code id="custom-elements-api:dom-customelementregistry-whendefined-2"><a href="#dom-customelementregistry-whendefined">whenDefined()</a></code> method.</p>

  <div data-algorithm="">
  <p>To <dfn id="look-up-a-custom-element-registry" data-export="">look up a custom element registry</dfn>, given a <code id="custom-elements-api:node-3"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code> object
  <var>node</var>:</p>

  <ol><li><p>If <var>node</var> is an <code id="custom-elements-api:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> object, then return <var>node</var>'s <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="custom-elements-api:element-custom-element-registry" data-x-internal="element-custom-element-registry">custom element registry</a>.</p></li><li><p>If <var>node</var> is a <code id="custom-elements-api:shadowroot"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code> object, then return <var>node</var>'s
   <a href="https://dom.spec.whatwg.org/#shadowroot-custom-element-registry" id="custom-elements-api:shadow-root-custom-element-registry" data-x-internal="shadow-root-custom-element-registry">custom element registry</a>.</p></li><li><p>If <var>node</var> is a <code id="custom-elements-api:document-2"><a href="#document">Document</a></code> object, then return <var>node</var>'s <a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="custom-elements-api:document-custom-element-registry-3" data-x-internal="document-custom-element-registry">custom element registry</a>.</p></li><li><p>Return null.</p></li></ol>
  </div>

  

  <dl class="domintro"><dt><code><var>registry</var> = <var>window</var>.<a href="#dom-window-customelements" id="dom-window-customelements-dev">customElements</a></code></dt><dd>Returns the global's associated <code id="custom-elements-api:document-3"><a href="#document">Document</a></code>'s <code id="custom-elements-api:customelementregistry-10"><a href="#customelementregistry">CustomElementRegistry</a></code>
   object.</dd><dt><code><var>registry</var> = new <a href="#dom-customelementregistry" id="dom-customelementregistry-dev">CustomElementRegistry</a>()</code></dt><dd>Constructs a new <code id="custom-elements-api:customelementregistry-11"><a href="#customelementregistry">CustomElementRegistry</a></code> object, for scoped usage.</dd><dt><code><var>registry</var>.<a href="#dom-customelementregistry-define" id="dom-customelementregistry-define-dev">define</a>(<var>name</var>,
   <var>constructor</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define" title="The define() method of the CustomElementRegistry interface defines a new custom element.">CustomElementRegistry/define</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>Defines a new <a href="#custom-element" id="custom-elements-api:custom-element">custom element</a>, mapping the given name to the given constructor
   as an <a href="#autonomous-custom-element" id="custom-elements-api:autonomous-custom-element">autonomous custom element</a>.</dd><dt><code><var>registry</var>.<a href="#dom-customelementregistry-define" id="custom-elements-api:dom-customelementregistry-define-2">define</a>(<var>name</var>, <var>constructor</var>,
   { extends: <var>baseLocalName</var> })</code></dt><dd>Defines a new <a href="#custom-element" id="custom-elements-api:custom-element-2">custom element</a>, mapping the given name to the given constructor as
   a <a href="#customized-built-in-element" id="custom-elements-api:customized-built-in-element">customized built-in element</a> for the <a href="#element-type" id="custom-elements-api:element-type">element type</a> identified by the
   supplied <var>baseLocalName</var>. A <a id="custom-elements-api:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a>
   <code id="custom-elements-api:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> will be thrown upon trying to extend a <a href="#custom-element" id="custom-elements-api:custom-element-3">custom element</a> or
   an unknown element, or when <var>registry</var> is not a global
   <code id="custom-elements-api:customelementregistry-12"><a href="#customelementregistry">CustomElementRegistry</a></code> object.</dd><dt><code><var>registry</var>.<a href="#dom-customelementregistry-get" id="dom-customelementregistry-get-dev">get</a>(<var>name</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/get" title="The get() method of the CustomElementRegistry interface returns the constructor for a previously-defined custom element.">CustomElementRegistry/get</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>Retrieves the <a href="#custom-element-constructor" id="custom-elements-api:custom-element-constructor">custom element constructor</a> defined for the given <a href="#concept-custom-element-definition-name" id="custom-elements-api:concept-custom-element-definition-name-2">name</a>. Returns undefined if there is no
   <a href="#custom-element-definition" id="custom-elements-api:custom-element-definition-2">custom element definition</a> with the given <a href="#concept-custom-element-definition-name" id="custom-elements-api:concept-custom-element-definition-name-3">name</a>.</dd><dt><code><var>registry</var>.<a href="#dom-customelementregistry-getname" id="dom-customelementregistry-getname-dev">getName</a>(<var>constructor</var>)</code></dt><dd>Retrieves the given name for a <a href="#custom-element" id="custom-elements-api:custom-element-4">custom element</a> defined for the given <a href="#concept-custom-element-definition-constructor" id="custom-elements-api:concept-custom-element-definition-constructor-2">constructor</a>. Returns null if there is no
   <a href="#custom-element-definition" id="custom-elements-api:custom-element-definition-3">custom element definition</a> with the given <a href="#concept-custom-element-definition-constructor" id="custom-elements-api:concept-custom-element-definition-constructor-3">constructor</a>.</dd><dt><code><var>registry</var>.<a href="#dom-customelementregistry-whendefined" id="dom-customelementregistry-whendefined-dev">whenDefined</a>(<var>name</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/whenDefined" title="The whenDefined() method of the CustomElementRegistry interface returns a Promise that resolves when the named element is defined.">CustomElementRegistry/whenDefined</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>Returns a promise that will be fulfilled with the <a href="#custom-element" id="custom-elements-api:custom-element-5">custom element</a>'s constructor
   when a <a href="#custom-element" id="custom-elements-api:custom-element-6">custom element</a> becomes defined with the given name. (If such a <a href="#custom-element" id="custom-elements-api:custom-element-7">custom
   element</a> is already defined, the returned promise will be immediately fulfilled.) Returns a
   promise rejected with a <a id="custom-elements-api:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="custom-elements-api:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if not
   given a <a href="#valid-custom-element-name" id="custom-elements-api:valid-custom-element-name-2">valid custom element name</a>.</dd><dt><code><var>registry</var>.<a href="#dom-customelementregistry-upgrade" id="dom-customelementregistry-upgrade-dev">upgrade</a>(<var>root</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/upgrade" title="The upgrade() method of the CustomElementRegistry interface upgrades all shadow-containing custom elements in a Node subtree, even before they are connected to the main document.">CustomElementRegistry/upgrade</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>12.1+</span></span><span class="chrome yes"><span>Chrome</span><span>68+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><a href="#concept-try-upgrade" id="custom-elements-api:concept-try-upgrade">Tries to upgrade</a> all <a id="custom-elements-api:shadow-including-inclusive-descendant" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant" data-x-internal="shadow-including-inclusive-descendant">shadow-including
   inclusive descendant</a> elements of <var>root</var>, even if they are not
   <a id="custom-elements-api:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>.</dd><dt><code><var>registry</var>.<a href="#dom-customelementregistry-initialize" id="dom-customelementregistry-initialize-dev">initialize</a>(<var>root</var>)</code></dt><dd>Each <a id="custom-elements-api:inclusive-descendant" href="https://dom.spec.whatwg.org/#concept-tree-inclusive-descendant" data-x-internal="inclusive-descendant">inclusive descendant</a> of <var>root</var> with a null registry will have it
   updated to this <code id="custom-elements-api:customelementregistry-13"><a href="#customelementregistry">CustomElementRegistry</a></code> object. A
   <a id="custom-elements-api:notsupportederror-2" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="custom-elements-api:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> will be thrown if this
   <code id="custom-elements-api:customelementregistry-14"><a href="#customelementregistry">CustomElementRegistry</a></code> object is not for scoped usage and either <var>root</var> is a
   <code id="custom-elements-api:document-4"><a href="#document">Document</a></code> node or <var>root</var>'s <a id="custom-elements-api:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="custom-elements-api:document-custom-element-registry-4" data-x-internal="document-custom-element-registry">custom element registry</a> is not this
   <code id="custom-elements-api:customelementregistry-15"><a href="#customelementregistry">CustomElementRegistry</a></code> object.</dd></dl>

  <div data-algorithm="">
  <p>The <dfn id="dom-customelementregistry"><code>new CustomElementRegistry()</code></dfn> constructor
  steps are to set <a id="custom-elements-api:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#is-scoped" id="custom-elements-api:is-scoped">is scoped</a> to true.</p>
  </div>

  <p><dfn id="element-definition">Element definition</dfn> is a process of adding a <a href="#custom-element-definition" id="custom-elements-api:custom-element-definition-4">custom element definition</a>
  to the <code id="custom-elements-api:customelementregistry-16"><a href="#customelementregistry">CustomElementRegistry</a></code>. This is accomplished by the <code id="custom-elements-api:dom-customelementregistry-define-3"><a href="#dom-customelementregistry-define">define()</a></code> method.</p>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CustomElementRegistry" id="dom-customelementregistry-define" data-dfn-type="method"><code>define(<var>name</var>, <var>constructor</var>,
  <var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="custom-elements-api:isconstructor" href="https://tc39.es/ecma262/#sec-isconstructor" data-x-internal="isconstructor">IsConstructor</a>(<var>constructor</var>) is false, then throw a
   <code id="custom-elements-api:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>.</p></li><li><p>If <var>name</var> is not a <a href="#valid-custom-element-name" id="custom-elements-api:valid-custom-element-name-3">valid custom element name</a>, then throw a
   <a id="custom-elements-api:syntaxerror-2" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="custom-elements-api:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="custom-elements-api:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#custom-element-definition-set" id="custom-elements-api:custom-element-definition-set">custom element definition set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="custom-elements-api:list-contains" data-x-internal="list-contains">contains</a> an item with <a href="#concept-custom-element-definition-name" id="custom-elements-api:concept-custom-element-definition-name-4">name</a> <var>name</var>, then throw a
   <a id="custom-elements-api:notsupportederror-3" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="custom-elements-api:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="custom-elements-api:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#custom-element-definition-set" id="custom-elements-api:custom-element-definition-set-2">custom element definition set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="custom-elements-api:list-contains-2" data-x-internal="list-contains">contains</a> an item with <a href="#concept-custom-element-definition-constructor" id="custom-elements-api:concept-custom-element-definition-constructor-4">constructor</a> <var>constructor</var>,
   then throw a <a id="custom-elements-api:notsupportederror-4" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="custom-elements-api:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>localName</var> be <var>name</var>.</p></li><li><p>Let <var>extends</var> be <var>options</var>["<code id="custom-elements-api:dom-elementdefinitionoptions-extends"><a href="#dom-elementdefinitionoptions-extends">extends</a></code>"] if it <a href="https://infra.spec.whatwg.org/#map-exists" id="custom-elements-api:map-exists" data-x-internal="map-exists">exists</a>; otherwise null.</p></li><li>
    <p>If <var>extends</var> is not null:</p>

    <ol><li><p>If <a id="custom-elements-api:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#is-scoped" id="custom-elements-api:is-scoped-2">is scoped</a> is true, then throw a
     <a id="custom-elements-api:notsupportederror-5" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="custom-elements-api:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>extends</var> is a <a href="#valid-custom-element-name" id="custom-elements-api:valid-custom-element-name-4">valid custom element name</a>, then throw a
     <a id="custom-elements-api:notsupportederror-6" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="custom-elements-api:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the <a id="custom-elements-api:element-interface" href="https://dom.spec.whatwg.org/#concept-element-interface" data-x-internal="element-interface">element interface</a> for <var>extends</var> and the <a id="custom-elements-api:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
     namespace</a> is <code id="custom-elements-api:htmlunknownelement"><a href="#htmlunknownelement">HTMLUnknownElement</a></code> (e.g., if <var>extends</var> does not
     indicate an element definition in this specification), then throw a
     <a id="custom-elements-api:notsupportederror-7" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="custom-elements-api:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>localName</var> to <var>extends</var>.</p></li></ol>
   </li><li><p>If <a id="custom-elements-api:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#element-definition-is-running" id="custom-elements-api:element-definition-is-running">element definition is running</a> is true, then throw
   a <a id="custom-elements-api:notsupportederror-8" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="custom-elements-api:domexception-10"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <a id="custom-elements-api:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#element-definition-is-running" id="custom-elements-api:element-definition-is-running-2">element definition is running</a> to true.</p></li><li><p>Let <var>formAssociated</var> be false.</p></li><li><p>Let <var>disableInternals</var> be false.

   </p></li><li><p>Let <var>disableShadow</var> be false.

   </p></li><li><p>Let <var>observedAttributes</var> be an empty <code>sequence&lt;DOMString&gt;</code>.</p></li><li>
    <p>Run the following steps while catching any exceptions:</p>

    <ol><li><p>Let <var>prototype</var> be ? <a href="https://tc39.es/ecma262/#sec-get-o-p" id="custom-elements-api:js-get" data-x-internal="js-get">Get</a>(<var>constructor</var>,
     "prototype").</p></li><li><p>If <var>prototype</var> <a href="https://tc39.es/ecma262/#sec-object-type" id="custom-elements-api:js-object" data-x-internal="js-object">is not an Object</a>, then throw a
     <code id="custom-elements-api:typeerror-2"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> exception.</p></li><li><p>Let <var>lifecycleCallbacks</var> be the <a id="custom-elements-api:ordered-map-3" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> «[ "<code>connectedCallback</code>" → null, "<code>disconnectedCallback</code>" →
     null, "<code>adoptedCallback</code>" → null, "<code>connectedMoveCallback</code>" → null, "<code>attributeChangedCallback</code>" → null ]».</p>

     </li><li>
      <p>For each <var>callbackName</var> of <a href="https://infra.spec.whatwg.org/#map-getting-the-keys" id="custom-elements-api:map-get-the-keys" data-x-internal="map-get-the-keys">the keys</a> of
      <var>lifecycleCallbacks</var>:</p>

      <ol><li><p>Let <var>callbackValue</var> be ? <a href="https://tc39.es/ecma262/#sec-get-o-p" id="custom-elements-api:js-get-2" data-x-internal="js-get">Get</a>(<var>prototype</var>,
       <var>callbackName</var>).</p>

       </li><li><p>If <var>callbackValue</var> is not undefined, then <a href="https://infra.spec.whatwg.org/#map-set" id="custom-elements-api:map-set" data-x-internal="map-set">set</a>
       <var>lifecycleCallbacks</var>[<var>callbackName</var>] to the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="custom-elements-api:concept-idl-convert" data-x-internal="concept-idl-convert">converting</a> <var>callbackValue</var> to the Web IDL <code id="custom-elements-api:idl-function"><a data-x-internal="idl-function" href="https://webidl.spec.whatwg.org/#common-Function">Function</a></code> callback type.</p></li></ol>
     </li><li>
      <p>If <var>lifecycleCallbacks</var>["<code>attributeChangedCallback</code>"] is not
      null:</p>

      <ol><li><p>Let <var>observedAttributesIterable</var> be ? <a href="https://tc39.es/ecma262/#sec-get-o-p" id="custom-elements-api:js-get-3" data-x-internal="js-get">Get</a>(<var>constructor</var>, "observedAttributes").</p></li><li><p>If <var>observedAttributesIterable</var> is not undefined, then set
       <var>observedAttributes</var> to the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="custom-elements-api:concept-idl-convert-2" data-x-internal="concept-idl-convert">converting</a> <var>observedAttributesIterable</var> to a
       <code>sequence&lt;DOMString&gt;</code>. Rethrow any exceptions from the
       conversion.</p></li></ol>

     </li><li><p>Let <var>disabledFeatures</var> be an empty <code>sequence&lt;DOMString&gt;</code>.</p></li><li><p>Let <var>disabledFeaturesIterable</var> be ? <a href="https://tc39.es/ecma262/#sec-get-o-p" id="custom-elements-api:js-get-4" data-x-internal="js-get">Get</a>(<var>constructor</var>, "disabledFeatures").</p></li><li><p>If <var>disabledFeaturesIterable</var> is not undefined, then set
     <var>disabledFeatures</var> to the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="custom-elements-api:concept-idl-convert-3" data-x-internal="concept-idl-convert">converting</a> <var>disabledFeaturesIterable</var> to a <code>sequence&lt;DOMString&gt;</code>. Rethrow any exceptions from the conversion.</p></li><li><p>If <var>disabledFeatures</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="custom-elements-api:list-contains-3" data-x-internal="list-contains">contains</a> "<code>internals</code>", then set <var>disableInternals</var> to true.</p></li><li><p>If <var>disabledFeatures</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="custom-elements-api:list-contains-4" data-x-internal="list-contains">contains</a> "<code>shadow</code>", then set <var>disableShadow</var> to true.</p></li><li><p>Let <var>formAssociatedValue</var> be ? <a href="https://tc39.es/ecma262/#sec-get-o-p" id="custom-elements-api:js-get-5" data-x-internal="js-get">Get</a>(
     <var>constructor</var>, "formAssociated").</p></li><li><p>Set <var>formAssociated</var> to the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="custom-elements-api:concept-idl-convert-4" data-x-internal="concept-idl-convert">converting</a> <var>formAssociatedValue</var> to a <code>boolean</code>.</p></li><li>
      <p>If <var>formAssociated</var> is true, then for each <var>callbackName</var> of « "<code>formAssociatedCallback</code>", "<code>formResetCallback</code>", "<code>formDisabledCallback</code>", "<code>formStateRestoreCallback</code>"
      »:</p>

      <ol><li><p>Let <var>callbackValue</var> be ? <a href="https://tc39.es/ecma262/#sec-get-o-p" id="custom-elements-api:js-get-6" data-x-internal="js-get">Get</a>(<var>prototype</var>,
       <var>callbackName</var>).</p></li><li><p>If <var>callbackValue</var> is not undefined, then <a href="https://infra.spec.whatwg.org/#map-set" id="custom-elements-api:map-set-2" data-x-internal="map-set">set</a>
       <var>lifecycleCallbacks</var>[<var>callbackName</var>] to the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="custom-elements-api:concept-idl-convert-5" data-x-internal="concept-idl-convert">converting</a> <var>callbackValue</var> to the Web IDL <code id="custom-elements-api:idl-function-2"><a data-x-internal="idl-function" href="https://webidl.spec.whatwg.org/#common-Function">Function</a></code> callback type.</p></li></ol>
     </li></ol>

    <p>Then, regardless of whether the above steps threw an exception or not: set
    <a id="custom-elements-api:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#element-definition-is-running" id="custom-elements-api:element-definition-is-running-3">element definition is running</a> to false.</p>

    <p>Finally, if the steps threw an exception, rethrow that exception.</p>
   </li><li><p>Let <var>definition</var> be a new <a href="#custom-element-definition" id="custom-elements-api:custom-element-definition-5">custom element definition</a> with <a href="#concept-custom-element-definition-name" id="custom-elements-api:concept-custom-element-definition-name-5">name</a> <var>name</var>, <a href="#concept-custom-element-definition-local-name" id="custom-elements-api:concept-custom-element-definition-local-name-2">local name</a> <var>localName</var>,
   <a href="#concept-custom-element-definition-constructor" id="custom-elements-api:concept-custom-element-definition-constructor-5">constructor</a>
   <var>constructor</var>, <a href="#concept-custom-element-definition-observed-attributes" id="custom-elements-api:concept-custom-element-definition-observed-attributes">observed attributes</a>
   <var>observedAttributes</var>, <a href="#concept-custom-element-definition-lifecycle-callbacks" id="custom-elements-api:concept-custom-element-definition-lifecycle-callbacks">lifecycle callbacks</a>
   <var>lifecycleCallbacks</var>,
   <a href="#concept-custom-element-definition-form-associated" id="custom-elements-api:concept-custom-element-definition-form-associated">form-associated</a>
   <var>formAssociated</var>, <a href="#concept-custom-element-definition-disable-internals" id="custom-elements-api:concept-custom-element-definition-disable-internals">disable internals</a>
   <var>disableInternals</var>, and <a href="#concept-custom-element-definition-disable-shadow" id="custom-elements-api:concept-custom-element-definition-disable-shadow">disable shadow</a>
   <var>disableShadow</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="custom-elements-api:set-append" data-x-internal="set-append">Append</a> <var>definition</var> to <a id="custom-elements-api:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a href="#custom-element-definition-set" id="custom-elements-api:custom-element-definition-set-3">custom element definition set</a>.</p></li><li><p>If <a id="custom-elements-api:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#is-scoped" id="custom-elements-api:is-scoped-3">is scoped</a> is true, then for each <var>document</var>
   of <a id="custom-elements-api:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#scoped-document-set" id="custom-elements-api:scoped-document-set">scoped document set</a>: <a href="#upgrade-particular-elements-within-a-document" id="custom-elements-api:upgrade-particular-elements-within-a-document">upgrade particular elements within
   a document</a> given <a id="custom-elements-api:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>document</var>, <var>definition</var>, and
   <var>localName</var>.</p></li><li><p>Otherwise, <a href="#upgrade-particular-elements-within-a-document" id="custom-elements-api:upgrade-particular-elements-within-a-document-2">upgrade particular elements within a document</a> given
   <a id="custom-elements-api:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <a id="custom-elements-api:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="custom-elements-api:concept-relevant-global">relevant global object</a>'s <a href="#concept-document-window" id="custom-elements-api:concept-document-window-4">associated <code>Document</code></a>, <var>definition</var>,
   <var>localName</var>, and <var>name</var>.</p></li><li>
    <p>If <a id="custom-elements-api:this-16" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#when-defined-promise-map" id="custom-elements-api:when-defined-promise-map">when-defined promise map</a>[<var>name</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="custom-elements-api:map-exists-2" data-x-internal="map-exists">exists</a>:</p>

    <ol><li><p>Resolve <a id="custom-elements-api:this-17" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#when-defined-promise-map" id="custom-elements-api:when-defined-promise-map-2">when-defined promise map</a>[<var>name</var>] with
     <var>constructor</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="custom-elements-api:map-remove" data-x-internal="map-remove">Remove</a> <a id="custom-elements-api:this-18" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#when-defined-promise-map" id="custom-elements-api:when-defined-promise-map-3">when-defined promise
     map</a>[<var>name</var>].</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="upgrade-particular-elements-within-a-document">upgrade particular elements within a document</dfn> given a
  <code id="custom-elements-api:customelementregistry-17"><a href="#customelementregistry">CustomElementRegistry</a></code> object <var>registry</var>, a <code id="custom-elements-api:document-5"><a href="#document">Document</a></code> object
  <var>document</var>, a <a href="#custom-element-definition" id="custom-elements-api:custom-element-definition-6">custom element definition</a> <var>definition</var>, a string
  <var>localName</var>, and optionally a string <var>name</var> (default <var>localName</var>):</p>

  <ol><li><p>Let <var>upgradeCandidates</var> be all elements that are <a href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant" id="custom-elements-api:shadow-including-descendant" data-x-internal="shadow-including-descendant">shadow-including descendants</a> of <var>document</var>, whose <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="custom-elements-api:element-custom-element-registry-2" data-x-internal="element-custom-element-registry">custom element registry</a> is <var>registry</var>,
   whose namespace is the <a id="custom-elements-api:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, and whose local name is <var>localName</var>,
   in <a id="custom-elements-api:shadow-including-tree-order" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>. Additionally, if <var>name</var> is not
   <var>localName</var>, only include elements whose <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="custom-elements-api:concept-element-is-value" data-x-internal="concept-element-is-value"><code>is</code> value</a> is equal to <var>name</var>.</p></li><li><p>For each element <var>element</var> of <var>upgradeCandidates</var>: <a href="#enqueue-a-custom-element-upgrade-reaction" id="custom-elements-api:enqueue-a-custom-element-upgrade-reaction">enqueue a
   custom element upgrade reaction</a> given <var>element</var> and
   <var>definition</var>.</p></li></ol>
  
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CustomElementRegistry" id="dom-customelementregistry-get" data-dfn-type="method"><code>get(<var>name</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="custom-elements-api:this-19" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#custom-element-definition-set" id="custom-elements-api:custom-element-definition-set-4">custom element definition set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="custom-elements-api:list-contains-5" data-x-internal="list-contains">contains</a> an item with <a href="#concept-custom-element-definition-name" id="custom-elements-api:concept-custom-element-definition-name-6">name</a> <var>name</var>, then return that
   item's <a href="#concept-custom-element-definition-constructor" id="custom-elements-api:concept-custom-element-definition-constructor-6">constructor</a>.</p></li><li><p>Return undefined.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/getName" title="The getName() method of the CustomElementRegistry interface returns the name for a previously-defined custom element.">CustomElementRegistry/getName</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>116+</span></span><span class="safari yes"><span>Safari</span><span title="Partial implementation.">🔰 preview+</span></span><span class="chrome yes"><span>Chrome</span><span>117+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>117+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="CustomElementRegistry" id="dom-customelementregistry-getname" data-dfn-type="method"><code>getName(<var>constructor</var>)</code></dfn> method
  steps are:</p>

  <ol><li><p>If <a id="custom-elements-api:this-20" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#custom-element-definition-set" id="custom-elements-api:custom-element-definition-set-5">custom element definition set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="custom-elements-api:list-contains-6" data-x-internal="list-contains">contains</a> an item with <a href="#concept-custom-element-definition-constructor" id="custom-elements-api:concept-custom-element-definition-constructor-7">constructor</a>
   <var>constructor</var>, then return that item's <a href="#concept-custom-element-definition-name" id="custom-elements-api:concept-custom-element-definition-name-7">name</a>.</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CustomElementRegistry" id="dom-customelementregistry-whendefined" data-dfn-type="method"><code>whenDefined(<var>name</var>)</code></dfn> method
  steps are:</p>

  <ol><li><p>If <var>name</var> is not a <a href="#valid-custom-element-name" id="custom-elements-api:valid-custom-element-name-5">valid custom element name</a>, then return <a id="custom-elements-api:a-promise-rejected-with" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a
   promise rejected with</a> a <a id="custom-elements-api:syntaxerror-3" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="custom-elements-api:domexception-11"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="custom-elements-api:this-21" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#custom-element-definition-set" id="custom-elements-api:custom-element-definition-set-6">custom element definition set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="custom-elements-api:list-contains-7" data-x-internal="list-contains">contains</a> an item with <a href="#concept-custom-element-definition-name" id="custom-elements-api:concept-custom-element-definition-name-8">name</a> <var>name</var>, then return <a id="custom-elements-api:a-promise-resolved-with" href="https://webidl.spec.whatwg.org/#a-promise-resolved-with" data-x-internal="a-promise-resolved-with">a
   promise resolved with</a> that item's <a href="#concept-custom-element-definition-constructor" id="custom-elements-api:concept-custom-element-definition-constructor-8">constructor</a>.</p></li><li><p>If <a id="custom-elements-api:this-22" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#when-defined-promise-map" id="custom-elements-api:when-defined-promise-map-4">when-defined promise map</a>[<var>name</var>] does not
   <a href="https://infra.spec.whatwg.org/#map-exists" id="custom-elements-api:map-exists-3" data-x-internal="map-exists">exist</a>, then <a href="https://infra.spec.whatwg.org/#map-set" id="custom-elements-api:map-set-3" data-x-internal="map-set">set</a>
   <a id="custom-elements-api:this-23" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#when-defined-promise-map" id="custom-elements-api:when-defined-promise-map-5">when-defined promise map</a>[<var>name</var>] to a new
   promise.</p></li><li><p>Return <a id="custom-elements-api:this-24" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#when-defined-promise-map" id="custom-elements-api:when-defined-promise-map-6">when-defined promise
   map</a>[<var>name</var>].</p></li></ol>
  </div>

  

  <div class="example">
   <p>The <code id="custom-elements-api:dom-customelementregistry-whendefined-3"><a href="#dom-customelementregistry-whendefined">whenDefined()</a></code> method can be
   used to avoid performing an action until all appropriate <a href="#custom-element" id="custom-elements-api:custom-element-8">custom
   elements</a> are <a href="https://dom.spec.whatwg.org/#concept-element-defined" id="custom-elements-api:concept-element-defined" data-x-internal="concept-element-defined">defined</a>. In this example, we
   combine it with the <code id="custom-elements-api:selector-defined"><a href="#selector-defined">:defined</a></code> pseudo-class to hide a
   dynamically-loaded article's contents until we're sure that all of the <a href="#autonomous-custom-element" id="custom-elements-api:autonomous-custom-element-2">autonomous custom elements</a> it uses are defined.</p>

   <pre><code class="js">articleContainer<c- p="">.</c->hidden <c- o="">=</c-> <c- kc="">true</c-><c- p="">;</c->

fetch<c- p="">(</c->articleURL<c- p="">)</c->
  <c- p="">.</c->then<c- p="">(</c->response <c- p="">=&gt;</c-> response<c- p="">.</c->text<c- p="">())</c->
  <c- p="">.</c->then<c- p="">(</c->text <c- p="">=&gt;</c-> <c- p="">{</c->
    articleContainer<c- p="">.</c->innerHTML <c- o="">=</c-> text<c- p="">;</c->

    <c- k="">return</c-> Promise<c- p="">.</c->all<c- p="">(</c->
      <c- p="">[...</c->articleContainer<c- p="">.</c->querySelectorAll<c- p="">(</c-><c- u="">":not(:defined)"</c-><c- p="">)]</c->
        <c- p="">.</c->map<c- p="">(</c->el <c- p="">=&gt;</c-> customElements<c- p="">.</c->whenDefined<c- p="">(</c->el<c- p="">.</c->localName<c- p="">))</c->
    <c- p="">);</c->
  <c- p="">})</c->
  <c- p="">.</c->then<c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
    articleContainer<c- p="">.</c->hidden <c- o="">=</c-> <c- kc="">false</c-><c- p="">;</c->
  <c- p="">});</c-></code></pre>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CustomElementRegistry" id="dom-customelementregistry-upgrade" data-dfn-type="method"><code>upgrade(<var>root</var>)</code></dfn> method steps
  are:</p>

  <ol><li><p>Let <var>candidates</var> be a <a id="custom-elements-api:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of all of <var>root</var>'s
   <a id="custom-elements-api:shadow-including-inclusive-descendant-2" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant" data-x-internal="shadow-including-inclusive-descendant">shadow-including inclusive descendant</a> elements, in <a id="custom-elements-api:shadow-including-tree-order-2" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree
   order</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="custom-elements-api:list-iterate" data-x-internal="list-iterate">For each</a> <var>candidate</var> of <var>candidates</var>,
   <a href="#concept-try-upgrade" id="custom-elements-api:concept-try-upgrade-2">try to upgrade</a> <var>candidate</var>.</p></li></ol>
  </div>

  

  <div class="example">
   <p>The <code id="custom-elements-api:dom-customelementregistry-upgrade-2"><a href="#dom-customelementregistry-upgrade">upgrade()</a></code> method allows upgrading
   of elements at will. Normally elements are automatically upgraded when they become
   <a id="custom-elements-api:connected-2" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, but this method can be used if you need to upgrade before you're ready to
   connect the element.</p>

   <pre><code class="js"><c- a="">const</c-> el <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"spider-man"</c-><c- p="">);</c->

<c- a="">class</c-> SpiderMan <c- k="">extends</c-> HTMLElement <c- p="">{}</c->
customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"spider-man"</c-><c- p="">,</c-> SpiderMan<c- p="">);</c->

console<c- p="">.</c->assert<c- p="">(</c-><c- o="">!</c-><c- p="">(</c->el <c- k="">instanceof</c-> SpiderMan<c- p="">));</c-> <c- c1="">// not yet upgraded</c->

customElements<c- p="">.</c->upgrade<c- p="">(</c->el<c- p="">);</c->
console<c- p="">.</c->assert<c- p="">(</c->el <c- k="">instanceof</c-> SpiderMan<c- p="">);</c->    <c- c1="">// upgraded!</c-></code></pre>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CustomElementRegistry" id="dom-customelementregistry-initialize" data-dfn-type="method"><code>initialize(<var>root</var>)</code></dfn> method
  steps are:</p>

  <ol><li><p>If <a id="custom-elements-api:this-25" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#is-scoped" id="custom-elements-api:is-scoped-4">is scoped</a> is false and either <var>root</var> is a
   <code id="custom-elements-api:document-6"><a href="#document">Document</a></code> node or <var>root</var>'s <a id="custom-elements-api:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="custom-elements-api:document-custom-element-registry-5" data-x-internal="document-custom-element-registry">custom element registry</a> is not
   <a id="custom-elements-api:this-26" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, then throw a <a id="custom-elements-api:notsupportederror-9" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a>
   <code id="custom-elements-api:domexception-12"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>root</var> is a <code id="custom-elements-api:document-7"><a href="#document">Document</a></code> node whose <a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="custom-elements-api:document-custom-element-registry-6" data-x-internal="document-custom-element-registry">custom element registry</a> is null, then set
   <var>root</var>'s <a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="custom-elements-api:document-custom-element-registry-7" data-x-internal="document-custom-element-registry">custom element registry</a>
   to <a id="custom-elements-api:this-27" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>Otherwise, if <var>root</var> is a <code id="custom-elements-api:shadowroot-2"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code> node whose <a href="https://dom.spec.whatwg.org/#shadowroot-custom-element-registry" id="custom-elements-api:shadow-root-custom-element-registry-2" data-x-internal="shadow-root-custom-element-registry">custom element registry</a> is null, then set
   <var>root</var>'s <a href="https://dom.spec.whatwg.org/#shadowroot-custom-element-registry" id="custom-elements-api:shadow-root-custom-element-registry-3" data-x-internal="shadow-root-custom-element-registry">custom element
   registry</a> to <a id="custom-elements-api:this-28" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li>
    <p>For each <a id="custom-elements-api:inclusive-descendant-2" href="https://dom.spec.whatwg.org/#concept-tree-inclusive-descendant" data-x-internal="inclusive-descendant">inclusive descendant</a> <var>inclusiveDescendant</var> of <var>root</var>:
    if <var>inclusiveDescendant</var> is an <code id="custom-elements-api:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> node whose <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="custom-elements-api:element-custom-element-registry-3" data-x-internal="element-custom-element-registry">custom element registry</a> is null:</p>

    <ol><li><p>Set <var>inclusiveDescendant</var>'s <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="custom-elements-api:element-custom-element-registry-4" data-x-internal="element-custom-element-registry">custom element registry</a> to
     <a id="custom-elements-api:this-29" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>If <a id="custom-elements-api:this-30" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#is-scoped" id="custom-elements-api:is-scoped-5">is scoped</a> is true, then <a href="https://infra.spec.whatwg.org/#set-append" id="custom-elements-api:set-append-2" data-x-internal="set-append">append</a> <var>inclusiveDescendant</var>'s <a id="custom-elements-api:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> to
     <a id="custom-elements-api:this-31" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#scoped-document-set" id="custom-elements-api:scoped-document-set-2">scoped document set</a>.</p></li></ol>
   </li></ol>
  </div>

  <p class="note">Once the custom element registry of a node is initialized to a
  <code id="custom-elements-api:customelementregistry-18"><a href="#customelementregistry">CustomElementRegistry</a></code> object, it intentionally cannot be changed any further. This
  simplifies reasoning about code and allows implementations to optimize.</p>


  <h4 id="upgrades"><span class="secno">4.13.5</span> <dfn>Upgrades</dfn><a href="#upgrades" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>To <dfn id="concept-upgrade-an-element" data-export="">upgrade an element</dfn>, given as input a
  <a href="#custom-element-definition" id="upgrades:custom-element-definition">custom element definition</a> <var>definition</var> and an element <var>element</var>,
  run the following steps:</p>

  <ol><li id="concept-upgrade-an-element-early-exit">
    <p>If <var>element</var>'s <a id="upgrades:custom-element-state" href="https://dom.spec.whatwg.org/#concept-element-custom-element-state" data-x-internal="custom-element-state">custom element state</a> is not "<code>undefined</code>" or "<code>uncustomized</code>", then return.</p>

    <div class="example">
     <p>One scenario where this can occur due to reentrant invocation of this algorithm, as in the
     following example:</p>

     <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">x-foo</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;&lt;/</c-><c- f="">x-foo</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">x-foo</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"b"</c-><c- p="">&gt;&lt;/</c-><c- f="">x-foo</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- c1="">// Defining enqueues upgrade reactions for both "a" and "b"</c->
customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"x-foo"</c-><c- p="">,</c-> <c- a="">class</c-> <c- k="">extends</c-> HTMLElement <c- p="">{</c->
  constructor<c- p="">()</c-> <c- p="">{</c->
    <c- k="">super</c-><c- p="">();</c->

    <c- a="">const</c-> b <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"#b"</c-><c- p="">);</c->
    b<c- p="">.</c->remove<c- p="">();</c->

    <c- c1="">// While this constructor is running for "a", "b" is still</c->
    <c- c1="">// undefined, and so inserting it into the document will enqueue a</c->
    <c- c1="">// second upgrade reaction for "b" in addition to the one enqueued</c->
    <c- c1="">// by defining x-foo.</c->
    document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->b<c- p="">);</c->
  <c- p="">}</c->
<c- p="">})</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

     <p>This step will thus bail out the algorithm early when <a href="#concept-upgrade-an-element" id="upgrades:concept-upgrade-an-element">upgrade an element</a> is invoked
     with "<code>b</code>" a second time.</p>
    </div>
   </li><li><p>Set <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-custom-element-definition" id="upgrades:concept-element-custom-element-definition" data-x-internal="concept-element-custom-element-definition">custom
   element definition</a> to <var>definition</var>.</p></li><li>
    <p>Set <var>element</var>'s <a id="upgrades:custom-element-state-2" href="https://dom.spec.whatwg.org/#concept-element-custom-element-state" data-x-internal="custom-element-state">custom element state</a> to "<code>failed</code>".</p>

    <p class="note">It will be set to "<code>custom</code>" <a href="#concept-upgrade-an-element-set-state-to-custom">after the upgrade succeeds</a>. For now,
    we set it to "<code>failed</code>" so that any reentrant invocations will hit <a href="#concept-upgrade-an-element-early-exit">the above early-exit step</a>.</p>
   </li><li><p>For each <var>attribute</var> in <var>element</var>'s <a id="upgrades:attribute-list" href="https://dom.spec.whatwg.org/#concept-element-attribute" data-x-internal="attribute-list">attribute list</a>, in
   order, <a href="#enqueue-a-custom-element-callback-reaction" id="upgrades:enqueue-a-custom-element-callback-reaction">enqueue a custom element callback reaction</a> with <var>element</var>, callback
   name "<code>attributeChangedCallback</code>", and « <var>attribute</var>'s local name,
   null, <var>attribute</var>'s value, <var>attribute</var>'s namespace ».</p></li><li><p>If <var>element</var> is <a id="upgrades:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then <a href="#enqueue-a-custom-element-callback-reaction" id="upgrades:enqueue-a-custom-element-callback-reaction-2">enqueue a custom element
   callback reaction</a> with <var>element</var>, callback name "<code>connectedCallback</code>", and « ».</p></li><li><p>Add <var>element</var> to the end of <var>definition</var>'s <a href="#concept-custom-element-definition-construction-stack" id="upgrades:concept-custom-element-definition-construction-stack">construction stack</a>.</p></li><li><p>Let <var>C</var> be <var>definition</var>'s <a href="#concept-custom-element-definition-constructor" id="upgrades:concept-custom-element-definition-constructor">constructor</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="upgrades:map-set" data-x-internal="map-set">Set</a> the <a id="upgrades:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s <a href="#active-custom-element-constructor-map" id="upgrades:active-custom-element-constructor-map">active custom
   element constructor map</a>[<var>C</var>] to <var>element</var>'s <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="upgrades:element-custom-element-registry" data-x-internal="element-custom-element-registry">custom element registry</a>.</p></li><li>
    <p>Run the following steps while catching any exceptions:</p>

    <ol><li>
      <p>If <var>definition</var>'s <a href="#concept-custom-element-definition-disable-shadow" id="upgrades:concept-custom-element-definition-disable-shadow">disable shadow</a> is true and
      <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="upgrades:concept-element-shadow-root" data-x-internal="concept-element-shadow-root">shadow root</a> is
      non-null, then throw a <a id="upgrades:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a>
      <code id="upgrades:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

      <p class="note">This is needed as <code id="upgrades:dom-element-attachshadow"><a data-x-internal="dom-element-attachshadow" href="https://dom.spec.whatwg.org/#dom-element-attachshadow">attachShadow()</a></code> does not use <a href="#look-up-a-custom-element-definition" id="upgrades:look-up-a-custom-element-definition">look up a custom
      element definition</a> while <code id="upgrades:dom-attachinternals"><a href="#dom-attachinternals">attachInternals()</a></code>
      does.</p>
     </li><li><p>Set <var>element</var>'s <a id="upgrades:custom-element-state-3" href="https://dom.spec.whatwg.org/#concept-element-custom-element-state" data-x-internal="custom-element-state">custom element state</a> to "<code>precustomized</code>".</p></li><li>
      <p>Let <var>constructResult</var> be the result of <a href="https://webidl.spec.whatwg.org/#construct-a-callback-function" id="upgrades:es-constructing-callback-functions" data-x-internal="es-constructing-callback-functions">constructing</a> <var>C</var>, with no
      arguments.</p>

      <p class="note">If <var>C</var> <a href="#custom-element-conformance">non-conformantly</a>
      uses an API decorated with the <code id="upgrades:cereactions"><a href="#cereactions">[CEReactions]</a></code> extended
      attribute, then the reactions enqueued at the beginning of this algorithm will execute during
      this step, before <var>C</var> finishes and control returns to this algorithm. Otherwise, they
      will execute after <var>C</var> and the rest of the upgrade process finishes.</p>
     </li><li>
      <p>If <a id="upgrades:samevalue" href="https://tc39.es/ecma262/#sec-samevalue" data-x-internal="samevalue">SameValue</a>(<var>constructResult</var>, <var>element</var>) is false, then
      throw a <code id="upgrades:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>.</p>

      <p class="note">This can occur if <var>C</var> constructs another instance of the same custom
      element before calling <code>super()</code>, or if <var>C</var> uses JavaScript's
      <code>return</code>-override feature to return an arbitrary <code id="upgrades:htmlelement"><a href="#htmlelement">HTMLElement</a></code>
      object from the constructor.</p>
     </li></ol>

    <p>Then, perform the following steps, regardless of whether the above steps threw an exception
    or not:</p>

    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#map-remove" id="upgrades:map-remove" data-x-internal="map-remove">Remove</a> the <a id="upgrades:surrounding-agent-2" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s <a href="#active-custom-element-constructor-map" id="upgrades:active-custom-element-constructor-map-2">active
      custom element constructor map</a>[<var>C</var>].</p>

      <p class="note">This is a no-op if <var>C</var> immediately calls <code>super()</code> as it ought to do.</p>
     </li><li>
      <p>Remove the last entry from the end of <var>definition</var>'s <a href="#concept-custom-element-definition-construction-stack" id="upgrades:concept-custom-element-definition-construction-stack-2">construction stack</a>.</p>

      <div class="note">
       <p>Assuming <var>C</var> calls <code>super()</code> (as it will if it is <a href="#custom-element-conformance">conformant</a>), and that the call succeeds, this will be
       the <a href="#concept-already-constructed-marker" id="upgrades:concept-already-constructed-marker"><i>already
       constructed</i> marker</a> that replaced the <var>element</var> we pushed at the beginning
       of this algorithm. (The <a href="#html-element-constructors">HTML element constructor</a>
       carries out this replacement.)</p>

       <p>If <var>C</var> does not call <code>super()</code> (i.e. it is not <a href="#custom-element-conformance">conformant</a>), or if any step in the <a href="#html-element-constructors">HTML element constructor</a> throws, then this entry will
       still be <var>element</var>.</p>
      </div>
     </li></ol>

    <p>Finally, if the above steps threw an exception, then:</p>

    <ol><li><p>Set <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-custom-element-definition" id="upgrades:concept-element-custom-element-definition-2" data-x-internal="concept-element-custom-element-definition">custom
     element definition</a> to null.</p></li><li><p>Empty <var>element</var>'s <a href="#custom-element-reaction-queue" id="upgrades:custom-element-reaction-queue">custom element reaction queue</a>.</p>

     </li><li><p>Rethrow the exception (thus terminating this algorithm).</p></li></ol>

    <p class="note">If the above steps threw an exception, then <var>element</var>'s <a id="upgrades:custom-element-state-4" href="https://dom.spec.whatwg.org/#concept-element-custom-element-state" data-x-internal="custom-element-state">custom
    element state</a> will remain "<code>failed</code>" or "<code>precustomized</code>".</p>
   </li><li>
    <p>If <var>element</var> is a <a href="#form-associated-custom-element" id="upgrades:form-associated-custom-element">form-associated custom element</a>, then:</p>
    <ol><li><p><a href="#reset-the-form-owner" id="upgrades:reset-the-form-owner">Reset the form owner</a> of <var>element</var>. If <var>element</var> is
     associated with a <code id="upgrades:the-form-element"><a href="#the-form-element">form</a></code> element, then
     <a href="#enqueue-a-custom-element-callback-reaction" id="upgrades:enqueue-a-custom-element-callback-reaction-3">enqueue a custom element callback reaction</a> with <var>element</var>, callback
     name "<code>formAssociatedCallback</code>", and « the associated <code id="upgrades:the-form-element-2"><a href="#the-form-element">form</a></code>
     ».</p></li><li><p>If <var>element</var> is <a href="#concept-fe-disabled" id="upgrades:concept-fe-disabled">disabled</a>, then
     <a href="#enqueue-a-custom-element-callback-reaction" id="upgrades:enqueue-a-custom-element-callback-reaction-4">enqueue a custom element callback reaction</a> with <var>element</var>, callback name
     "<code>formDisabledCallback</code>", and « true ».</p></li></ol>
   </li><li id="concept-upgrade-an-element-set-state-to-custom"><p>Set <var>element</var>'s <a id="upgrades:custom-element-state-5" href="https://dom.spec.whatwg.org/#concept-element-custom-element-state" data-x-internal="custom-element-state">custom
   element state</a> to "<code>custom</code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="concept-try-upgrade" data-export="">try to upgrade an element</dfn> given an element
  <var>element</var>:</p>

  <ol><li><p>Let <var>definition</var> be the result of <a href="#look-up-a-custom-element-definition" id="upgrades:look-up-a-custom-element-definition-2">looking up a custom element definition</a> given <var>element</var>'s <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="upgrades:element-custom-element-registry-2" data-x-internal="element-custom-element-registry">custom element registry</a>, <var>element</var>'s
   <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="upgrades:concept-element-namespace" data-x-internal="concept-element-namespace">namespace</a>, <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="upgrades:concept-element-local-name" data-x-internal="concept-element-local-name">local name</a>, and <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="upgrades:concept-element-is-value" data-x-internal="concept-element-is-value"><code>is</code> value</a>.</p></li><li><p>If <var>definition</var> is not null, then <a href="#enqueue-a-custom-element-upgrade-reaction" id="upgrades:enqueue-a-custom-element-upgrade-reaction">enqueue a custom element upgrade
   reaction</a> given <var>element</var> and <var>definition</var>.</p></li></ol>
  </div>

  

  <h4 id="custom-element-reactions"><span class="secno">4.13.6</span> Custom element reactions<a href="#custom-element-reactions" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A <a href="#custom-element" id="custom-element-reactions:custom-element">custom element</a> possesses the ability to respond to certain occurrences by
  running author code:</p>

  <ul><li><p>When <a href="#upgrades" id="custom-element-reactions:upgrades">upgraded</a>, its <a href="#custom-element-constructor" id="custom-element-reactions:custom-element-constructor">constructor</a> is run, with no arguments.</p></li><li><p>When it <a href="#becomes-connected" id="custom-element-reactions:becomes-connected">becomes connected</a>, its <code>connectedCallback</code> is
   called, with no arguments.</p></li><li><p>When it <a href="#becomes-disconnected" id="custom-element-reactions:becomes-disconnected">becomes disconnected</a>, its <code>disconnectedCallback</code>
   is called, with no arguments.</p></li><li><p>When it is <a href="https://dom.spec.whatwg.org/#concept-node-move-ext" id="custom-element-reactions:concept-node-move-ext" data-x-internal="concept-node-move-ext">moved</a>, its <code>connectedMoveCallback</code> is called, with no arguments.</p></li><li><p>When it is <a href="https://dom.spec.whatwg.org/#concept-node-adopt" id="custom-element-reactions:concept-node-adopt" data-x-internal="concept-node-adopt">adopted</a> into a new document, its <code>adoptedCallback</code> is called, given the old document and new document as
   arguments.</p></li><li><p>When any of its attributes are <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change" id="custom-element-reactions:concept-element-attributes-change" data-x-internal="concept-element-attributes-change">changed</a>, <a href="https://dom.spec.whatwg.org/#concept-element-attributes-append" id="custom-element-reactions:concept-element-attributes-append" data-x-internal="concept-element-attributes-append">appended</a>, <a href="https://dom.spec.whatwg.org/#concept-element-attributes-remove" id="custom-element-reactions:concept-element-attributes-remove" data-x-internal="concept-element-attributes-remove">removed</a>, or <a href="https://dom.spec.whatwg.org/#concept-element-attributes-replace" id="custom-element-reactions:concept-element-attributes-replace" data-x-internal="concept-element-attributes-replace">replaced</a>, its <code>attributeChangedCallback</code> is called, given the attribute's local name, old value,
   new value, and namespace as arguments. (An attribute's old or new value is considered to be null
   when the attribute is added or removed, respectively.)</p></li><li><p>When the user agent <a href="#reset-the-form-owner" id="custom-element-reactions:reset-the-form-owner">resets the form owner</a> of a
   <a href="#form-associated-custom-element" id="custom-element-reactions:form-associated-custom-element">form-associated custom element</a> and doing so changes the form owner, its <code>formAssociatedCallback</code> is called, given the new form owner (or null if no owner)
   as an argument.</p></li><li><p>When the form owner of a <a href="#form-associated-custom-element" id="custom-element-reactions:form-associated-custom-element-2">form-associated custom element</a> is <a href="#concept-form-reset" id="custom-element-reactions:concept-form-reset">reset</a>, its <code>formResetCallback</code> is
   called.</p></li><li><p>When the <a href="#concept-fe-disabled" id="custom-element-reactions:concept-fe-disabled">disabled</a> state of a
   <a href="#form-associated-custom-element" id="custom-element-reactions:form-associated-custom-element-3">form-associated custom element</a> is changed, its <code>formDisabledCallback</code> is called, given the new state as an
   argument.</p></li><li><p>When the user agent updates a <a href="#form-associated-custom-element" id="custom-element-reactions:form-associated-custom-element-4">form-associated custom element</a>'s value on behalf of
   a user or <a href="#restore-persisted-state" id="custom-element-reactions:restore-persisted-state">as part of navigation</a>, its <code>formStateRestoreCallback</code> is called, given the new state and a string indicating
   a reason, "<code>autocomplete</code>" or "<code>restore</code>", as
   arguments.</p></li></ul>

  <p>We call these reactions collectively <dfn id="concept-custom-element-reaction">custom
  element reactions</dfn>.</p>
  </div>

  <p>The way in which <a href="#concept-custom-element-reaction" id="custom-element-reactions:concept-custom-element-reaction">custom element reactions</a>
  are invoked is done with special care, to avoid running author code during the middle of delicate
  operations. Effectively, they are delayed until "just before returning to user script". This means
  that for most purposes they appear to execute synchronously, but in the case of complicated
  composite operations (like <a href="https://dom.spec.whatwg.org/#concept-node-clone" id="custom-element-reactions:concept-node-clone" data-x-internal="concept-node-clone">cloning</a>, or <a href="https://dom.spec.whatwg.org/#concept-range" id="custom-element-reactions:concept-range" data-x-internal="concept-range">range</a> manipulation), they will instead be delayed until after all
  the relevant user agent processing steps have completed, and then run together as a batch.</p>

  <p>Additionally, the precise ordering of these reactions is managed via a
  somewhat-complicated stack-of-queues system, described below. The intention behind this system is
  to guarantee that <a href="#concept-custom-element-reaction" id="custom-element-reactions:concept-custom-element-reaction-2">custom element reactions</a> always are invoked in the
  same order as their triggering actions, at least within the local context of a single <a href="#custom-element" id="custom-element-reactions:custom-element-2">custom
  element</a>. (Because <a href="#concept-custom-element-reaction" id="custom-element-reactions:concept-custom-element-reaction-3">custom element
  reaction</a> code can perform its own mutations, it is not possible to give a global ordering
  guarantee across multiple elements.)</p>

  

  <hr>

  <p>Each <a href="#similar-origin-window-agent" id="custom-element-reactions:similar-origin-window-agent">similar-origin window agent</a> has a <dfn id="custom-element-reactions-stack">custom element reactions stack</dfn>,
  which is initially empty. A <a href="#similar-origin-window-agent" id="custom-element-reactions:similar-origin-window-agent-2">similar-origin window agent</a>'s <dfn id="current-element-queue">current element
  queue</dfn> is the <a href="#element-queue" id="custom-element-reactions:element-queue">element queue</a> at the top of its <a href="#custom-element-reactions-stack" id="custom-element-reactions:custom-element-reactions-stack">custom element reactions
  stack</a>. Each item in the stack is an <dfn id="element-queue">element queue</dfn>, which is initially empty as
  well. Each item in an <a href="#element-queue" id="custom-element-reactions:element-queue-2">element queue</a> is an element. (The elements are not necessarily
  <a href="https://dom.spec.whatwg.org/#concept-element-custom" id="custom-element-reactions:concept-element-custom" data-x-internal="concept-element-custom">custom</a> yet, since this queue is used for <a href="#upgrades" id="custom-element-reactions:upgrades-2">upgrades</a> as well.)</p>

  <p>Each <a href="#custom-element-reactions-stack" id="custom-element-reactions:custom-element-reactions-stack-2">custom element reactions stack</a> has an associated <dfn id="backup-element-queue">backup element
  queue</dfn>, which is an initially-empty <a href="#element-queue" id="custom-element-reactions:element-queue-3">element queue</a>. Elements are pushed onto the
  <a href="#backup-element-queue" id="custom-element-reactions:backup-element-queue">backup element queue</a> during operations that affect the DOM without going through an
  API decorated with <code id="custom-element-reactions:cereactions"><a href="#cereactions">[CEReactions]</a></code>, or through the parser's
  <a href="#create-an-element-for-the-token" id="custom-element-reactions:create-an-element-for-the-token">create an element for the token</a> algorithm. An example of this is a user-initiated
  editing operation which modifies the descendants or attributes of an <a id="custom-element-reactions:editable" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a>
  element. To prevent reentrancy when processing the <a href="#backup-element-queue" id="custom-element-reactions:backup-element-queue-2">backup element queue</a>, each
  <a href="#custom-element-reactions-stack" id="custom-element-reactions:custom-element-reactions-stack-3">custom element reactions stack</a> also has a <dfn id="processing-the-backup-element-queue">processing the backup element
  queue</dfn> flag, initially unset.</p>

  <p>All elements have an associated <dfn id="custom-element-reaction-queue">custom element reaction queue</dfn>, initially empty. Each
  item in the <a href="#custom-element-reaction-queue" id="custom-element-reactions:custom-element-reaction-queue">custom element reaction queue</a> is of one of two types:</p>

  <ul><li><p>An <dfn id="upgrade-reaction">upgrade reaction</dfn>, which will <a href="#upgrades" id="custom-element-reactions:upgrades-3">upgrade</a> the custom element and contains a <a href="#custom-element-definition" id="custom-element-reactions:custom-element-definition">custom
   element definition</a>; or</p></li><li><p>A <dfn id="callback-reaction">callback reaction</dfn>, which will call a lifecycle callback, and contains a
   callback function as well as a list of arguments.</p></li></ul>

  <p>This is all summarized in the following schematic diagram:</p>

  <p><img class="darkmode-aware" src="/images/custom-element-reactions.svg" alt="A custom element reactions stack consists of a stack of element queues. Zooming in on a particular queue, we see that it contains a number of elements (in our example, <x-a>, then <x-b>, then <x-c>). Any particular element in the queue then has a custom element reaction queue. Zooming in on the custom element reaction queue, we see that it contains a variety of queued-up reactions (in our example, upgrade, then attribute changed, then another attribute changed, then connected)." style="width: 80%; max-width: 580px;"></p>

  <div data-algorithm="">
  <p>To <dfn id="enqueue-an-element-on-the-appropriate-element-queue">enqueue an element on the appropriate element queue</dfn>, given an element
  <var>element</var>, run the following steps:</p>

  <ol><li><p>Let <var>reactionsStack</var> be <var>element</var>'s <a href="#relevant-agent" id="custom-element-reactions:relevant-agent">relevant agent</a>'s
   <a href="#custom-element-reactions-stack" id="custom-element-reactions:custom-element-reactions-stack-4">custom element reactions stack</a>.</p></li><li>
    <p>If <var>reactionsStack</var> is empty, then:</p>

    <ol><li><p>Add <var>element</var> to <var>reactionsStack</var>'s <a href="#backup-element-queue" id="custom-element-reactions:backup-element-queue-3">backup element
     queue</a>.</p></li><li><p>If <var>reactionsStack</var>'s <a href="#processing-the-backup-element-queue" id="custom-element-reactions:processing-the-backup-element-queue">processing the backup element queue</a> flag is
     set, then return.</p></li><li><p>Set <var>reactionsStack</var>'s <a href="#processing-the-backup-element-queue" id="custom-element-reactions:processing-the-backup-element-queue-2">processing the backup element queue</a>
     flag.</p></li><li>
      <p><a href="#queue-a-microtask" id="custom-element-reactions:queue-a-microtask">Queue a microtask</a> to perform the following steps:</p>

      <ol><li><p><a href="#invoke-custom-element-reactions" id="custom-element-reactions:invoke-custom-element-reactions">Invoke custom element reactions</a> in <var>reactionsStack</var>'s
       <a href="#backup-element-queue" id="custom-element-reactions:backup-element-queue-4">backup element queue</a>.</p></li><li><p>Unset <var>reactionsStack</var>'s <a href="#processing-the-backup-element-queue" id="custom-element-reactions:processing-the-backup-element-queue-3">processing the backup element queue</a>
       flag.</p></li></ol>
     </li></ol>
   </li><li><p>Otherwise, add <var>element</var> to <var>element</var>'s <a href="#relevant-agent" id="custom-element-reactions:relevant-agent-2">relevant agent</a>'s
   <a href="#current-element-queue" id="custom-element-reactions:current-element-queue">current element queue</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="enqueue-a-custom-element-callback-reaction" data-export="">enqueue a custom element callback reaction</dfn>, given a <a href="#custom-element" id="custom-element-reactions:custom-element-3">custom
  element</a> <var>element</var>, a callback name <var>callbackName</var>, and a list of
  arguments <var>args</var>, run the following steps:</p>

  <ol><li><p>Let <var>definition</var> be <var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-custom-element-definition" id="custom-element-reactions:concept-element-custom-element-definition" data-x-internal="concept-element-custom-element-definition">custom element definition</a>.</p>

   </li><li><p>Let <var>callback</var> be the value of the entry in <var>definition</var>'s <a href="#concept-custom-element-definition-lifecycle-callbacks" id="custom-element-reactions:concept-custom-element-definition-lifecycle-callbacks">lifecycle callbacks</a> with
   key <var>callbackName</var>.</p></li><li>
    <p>If <var>callbackName</var> is "<code>connectedMoveCallback</code>" and
    <var>callback</var> is null:

    </p><ol><li><p>Let <var>disconnectedCallback</var> be the value of the entry in <var>definition</var>'s
     <a href="#concept-custom-element-definition-lifecycle-callbacks" id="custom-element-reactions:concept-custom-element-definition-lifecycle-callbacks-2">lifecycle callbacks</a>
     with key "<code>disconnectedCallback</code>".</p></li><li><p>Let <var>connectedCallback</var> be the value of the entry in <var>definition</var>'s
     <a href="#concept-custom-element-definition-lifecycle-callbacks" id="custom-element-reactions:concept-custom-element-definition-lifecycle-callbacks-3">lifecycle callbacks</a>
     with key "<code>connectedCallback</code>".</p></li><li><p>If <var>connectedCallback</var> and <var>disconnectedCallback</var> are null, then
     return.</p></li><li>
      <p>Set <var>callback</var> to the following steps:</p>

      <ol><li><p>If <var>disconnectedCallback</var> is not null, then call
       <var>disconnectedCallback</var> with no arguments.</p></li><li><p>If <var>connectedCallback</var> is not null, then call <var>connectedCallback</var>
       with no arguments.</p></li></ol>
     </li></ol>
   </li><li><p>If <var>callback</var> is null, then return.</p></li><li>
    <p>If <var>callbackName</var> is "<code>attributeChangedCallback</code>":</p>

    <ol><li><p>Let <var>attributeName</var> be the first element of <var>args</var>.</p></li><li><p>If <var>definition</var>'s <a href="#concept-custom-element-definition-observed-attributes" id="custom-element-reactions:concept-custom-element-definition-observed-attributes">observed attributes</a> does
     not contain <var>attributeName</var>, then return.</p></li></ol>
   </li><li><p>Add a new <a href="#callback-reaction" id="custom-element-reactions:callback-reaction">callback reaction</a> to <var>element</var>'s <a href="#custom-element-reaction-queue" id="custom-element-reactions:custom-element-reaction-queue-2">custom element
   reaction queue</a>, with callback function <var>callback</var> and arguments
   <var>args</var>.</p></li><li><p><a href="#enqueue-an-element-on-the-appropriate-element-queue" id="custom-element-reactions:enqueue-an-element-on-the-appropriate-element-queue">Enqueue an element on the appropriate element queue</a> given
   <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="enqueue-a-custom-element-upgrade-reaction" data-export="">enqueue a custom element upgrade reaction</dfn>, given an element
  <var>element</var> and <a href="#custom-element-definition" id="custom-element-reactions:custom-element-definition-2">custom element definition</a> <var>definition</var>, run the
  following steps:</p>

  <ol><li><p>Add a new <a href="#upgrade-reaction" id="custom-element-reactions:upgrade-reaction">upgrade reaction</a> to <var>element</var>'s <a href="#custom-element-reaction-queue" id="custom-element-reactions:custom-element-reaction-queue-3">custom element
   reaction queue</a>, with <a href="#custom-element-definition" id="custom-element-reactions:custom-element-definition-3">custom element definition</a>
   <var>definition</var>.</p></li><li><p><a href="#enqueue-an-element-on-the-appropriate-element-queue" id="custom-element-reactions:enqueue-an-element-on-the-appropriate-element-queue-2">Enqueue an element on the appropriate element queue</a> given
   <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="invoke-custom-element-reactions">invoke custom element reactions</dfn> in an <a href="#element-queue" id="custom-element-reactions:element-queue-4">element queue</a>
  <var>queue</var>, run the following steps:</p>

  <ol><li>
    <p>While <var>queue</var> is not <a href="https://infra.spec.whatwg.org/#list-is-empty" id="custom-element-reactions:list-is-empty" data-x-internal="list-is-empty">empty</a>:</p>

    <ol><li><p>Let <var>element</var> be the result of <a href="https://infra.spec.whatwg.org/#queue-dequeue" id="custom-element-reactions:dequeue" data-x-internal="dequeue">dequeuing</a>
     from <var>queue</var>.</p></li><li><p>Let <var>reactions</var> be <var>element</var>'s <a href="#custom-element-reaction-queue" id="custom-element-reactions:custom-element-reaction-queue-4">custom element reaction
     queue</a>.</p></li><li>
      <p>Repeat until <var>reactions</var> is empty:</p>

      <ol><li>
        <p>Remove the first element of <var>reactions</var>, and let <var>reaction</var> be that
        element. Switch on <var>reaction</var>'s type:</p>

        <dl class="switch"><dt><a href="#upgrade-reaction" id="custom-element-reactions:upgrade-reaction-2">upgrade reaction</a></dt><dd>
          <p><a href="#concept-upgrade-an-element" id="custom-element-reactions:concept-upgrade-an-element">Upgrade</a> <var>element</var> using
          <var>reaction</var>'s <a href="#custom-element-definition" id="custom-element-reactions:custom-element-definition-4">custom element definition</a>.</p>

          <p>If this throws an exception, catch it, and <a href="#report-an-exception" id="custom-element-reactions:report-an-exception">report</a> it for <var>reaction</var>'s <a href="#custom-element-definition" id="custom-element-reactions:custom-element-definition-5">custom element
          definition</a>'s <a href="#concept-custom-element-definition-constructor" id="custom-element-reactions:concept-custom-element-definition-constructor">constructor</a>'s corresponding
          JavaScript object's <a id="custom-element-reactions:associated-realm" href="https://webidl.spec.whatwg.org/#dfn-associated-realm" data-x-internal="associated-realm">associated realm</a>'s <a href="#concept-realm-global" id="custom-element-reactions:concept-realm-global">global object</a>.</p>
         </dd><dt><a href="#callback-reaction" id="custom-element-reactions:callback-reaction-2">callback reaction</a></dt><dd>
          <p><a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="custom-element-reactions:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">Invoke</a> <var>reaction</var>'s
          callback function with <var>reaction</var>'s arguments and "<code>report</code>", and <i id="custom-element-reactions:dfn-callback-this-value"><a data-x-internal="dfn-callback-this-value" href="https://webidl.spec.whatwg.org/#dfn-callback-this-value">callback this value</a></i>
          set to <var>element</var>.</p>
         </dd></dl>
       </li></ol>
     </li></ol>
   </li></ol>
  </div>

  <hr>

  <p>To ensure <a href="#concept-custom-element-reaction" id="custom-element-reactions:concept-custom-element-reaction-4">custom element reactions</a> are
  triggered appropriately, we introduce the <dfn id="cereactions" data-dfn-type="extended-attribute" data-lt="CEReactions"><code>[CEReactions]</code></dfn> IDL <a id="custom-element-reactions:extended-attribute" href="https://webidl.spec.whatwg.org/#dfn-extended-attribute" data-x-internal="extended-attribute">extended attribute</a>. It
  indicates that the relevant algorithm is to be supplemented with additional steps in order to
  appropriately track and invoke <a href="#concept-custom-element-reaction" id="custom-element-reactions:concept-custom-element-reaction-5">custom element
  reactions</a>.</p>

  <p>The <code id="custom-element-reactions:cereactions-2"><a href="#cereactions">[CEReactions]</a></code> extended attribute must take no
  arguments, and must not appear on anything other than an operation, attribute, setter, or deleter.
  Additionally, it must not appear on readonly attributes.</p>

  <div data-algorithm="">
  <p>Operations, attributes, setters, or deleters annotated with the <code id="custom-element-reactions:cereactions-3"><a href="#cereactions">[CEReactions]</a></code> extended attribute must run the following steps in place
  of the ones specified in their description:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#stack-push" id="custom-element-reactions:stack-push" data-x-internal="stack-push">Push</a> a new <a href="#element-queue" id="custom-element-reactions:element-queue-5">element queue</a> onto this object's
   <a href="#relevant-agent" id="custom-element-reactions:relevant-agent-3">relevant agent</a>'s <a href="#custom-element-reactions-stack" id="custom-element-reactions:custom-element-reactions-stack-5">custom element reactions stack</a>.</p></li><li><p>Run the originally-specified steps for this construct, catching any exceptions. If the
   steps return a value, let <var>value</var> be the returned value. If they throw an exception, let
   <var>exception</var> be the thrown exception.</p></li><li><p>Let <var>queue</var> be the result of <a href="https://infra.spec.whatwg.org/#stack-pop" id="custom-element-reactions:stack-pop" data-x-internal="stack-pop">popping</a> from this
   object's <a href="#relevant-agent" id="custom-element-reactions:relevant-agent-4">relevant agent</a>'s <a href="#custom-element-reactions-stack" id="custom-element-reactions:custom-element-reactions-stack-6">custom element reactions stack</a>.</p></li><li><p><a href="#invoke-custom-element-reactions" id="custom-element-reactions:invoke-custom-element-reactions-2">Invoke custom element reactions</a> in <var>queue</var>.</p></li><li><p>If an exception <var>exception</var> was thrown by the original steps, rethrow
   <var>exception</var>.</p></li><li><p>If a value <var>value</var> was returned from the original steps, return
   <var>value</var>.</p></li></ol>
  </div>

  <div class="note">
   <p>The intent behind this extended attribute is somewhat subtle. One way of accomplishing its
   goals would be to say that every operation, attribute, setter, and deleter on the platform
   must have these steps inserted, and to allow implementers to optimize away
   unnecessary cases (where no DOM mutation is possible that could cause <a href="#concept-custom-element-reaction" id="custom-element-reactions:concept-custom-element-reaction-6">custom element reactions</a> to occur).</p>

   <p>However, in practice this imprecision could lead to non-interoperable implementations of <a href="#concept-custom-element-reaction" id="custom-element-reactions:concept-custom-element-reaction-7">custom element reactions</a>, as some implementations
   might forget to invoke these steps in some cases. Instead, we settled on the approach of
   explicitly annotating all relevant IDL constructs, as a way of ensuring interoperable behavior
   and helping implementations easily pinpoint all cases where these steps are necessary.</p>
  </div>

  <p>Any nonstandard APIs introduced by the user agent that could modify the DOM in such a way as to
  cause <a href="#enqueue-a-custom-element-callback-reaction" id="custom-element-reactions:enqueue-a-custom-element-callback-reaction">enqueuing a custom element
  callback reaction</a> or <a href="#enqueue-a-custom-element-upgrade-reaction" id="custom-element-reactions:enqueue-a-custom-element-upgrade-reaction">enqueuing a
  custom element upgrade reaction</a>, for example by modifying any attributes or child elements,
  must also be decorated with the <code id="custom-element-reactions:cereactions-4"><a href="#cereactions">[CEReactions]</a></code> attribute.</p>

  <div class="note">
   <p>As of the time of this writing, the following nonstandard or not-yet-standardized APIs are
   known to fall into this category:</p>

   <ul><li><p><code id="custom-element-reactions:htmlinputelement"><a href="#htmlinputelement">HTMLInputElement</a></code>'s <code>webkitdirectory</code> and <code>incremental</code> IDL attributes</p></li><li><p><code id="custom-element-reactions:htmllinkelement"><a href="#htmllinkelement">HTMLLinkElement</a></code>'s <code>scope</code> IDL attribute</p></li></ul>
  </div>

  

  <h4 id="element-internals"><span class="secno">4.13.7</span> Element internals<a href="#element-internals" class="self-link"></a></h4>

  <p>Certain capabilities are meant to be available to a custom element author, but not to a custom
  element consumer. These are provided by the <code id="element-internals:dom-attachinternals"><a href="#dom-attachinternals">element.attachInternals()</a></code> method, which returns an instance of
  <code id="element-internals:elementinternals"><a href="#elementinternals">ElementInternals</a></code>. The properties and methods of <code id="element-internals:elementinternals-2"><a href="#elementinternals">ElementInternals</a></code> allow
  control over internal features which the user agent provides to all elements.</p>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-attachinternals" id="dom-attachinternals-dev">attachInternals()</a></code></dt><dd><p>Returns an <code id="element-internals:elementinternals-3"><a href="#elementinternals">ElementInternals</a></code> object targeting the <a href="#custom-element" id="element-internals:custom-element">custom element</a>
   <var>element</var>. Throws an exception if <var>element</var> is not a <a href="#custom-element" id="element-internals:custom-element-2">custom
   element</a>, if the "<code>internals</code>" feature was disabled as part of the
   element definition, or if it is called twice on the same element.</p></dd></dl>

  

  <p>Each <code id="element-internals:htmlelement"><a href="#htmlelement">HTMLElement</a></code> has an <dfn id="attached-internals">attached internals</dfn> (null or an
  <code id="element-internals:elementinternals-4"><a href="#elementinternals">ElementInternals</a></code> object), initially null.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals" title="The HTMLElement.attachInternals() method returns an ElementInternals object. This method allows a custom element to participate in HTML forms. The ElementInternals interface provides utilities for working with these elements in the same way you would work with any standard HTML form element, and also exposes the Accessibility Object Model to the element.">HTMLElement/attachInternals</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>93+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-attachinternals" data-dfn-type="method"><code>attachInternals()</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="element-internals:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="element-internals:concept-element-is-value" data-x-internal="concept-element-is-value"><code>is</code>
   value</a> is not null, then throw a <a id="element-internals:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a>
   <code id="element-internals:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>definition</var> be the result of <a href="#look-up-a-custom-element-definition" id="element-internals:look-up-a-custom-element-definition">looking up a custom element definition</a> given <a id="element-internals:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="element-internals:element-custom-element-registry" data-x-internal="element-custom-element-registry">custom element registry</a>, <a id="element-internals:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="element-internals:concept-element-namespace" data-x-internal="concept-element-namespace">namespace</a>, <a id="element-internals:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="element-internals:concept-element-local-name" data-x-internal="concept-element-local-name">local name</a>, and null.</p></li><li><p>If <var>definition</var> is null, then throw a
   <a id="element-internals:notsupportederror-2" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="element-internals:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>definition</var>'s <a href="#concept-custom-element-definition-disable-internals" id="element-internals:concept-custom-element-definition-disable-internals">disable internals</a> is true,
   then throw a <a id="element-internals:notsupportederror-3" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="element-internals:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="element-internals:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#attached-internals" id="element-internals:attached-internals">attached internals</a> is non-null, then throw a
   <a id="element-internals:notsupportederror-4" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="element-internals:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="element-internals:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="element-internals:custom-element-state" href="https://dom.spec.whatwg.org/#concept-element-custom-element-state" data-x-internal="custom-element-state">custom element state</a> is not "<code>precustomized</code>" or "<code>custom</code>", then throw a
   <a id="element-internals:notsupportederror-5" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="element-internals:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <a id="element-internals:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#attached-internals" id="element-internals:attached-internals-2">attached internals</a> to a new
   <code id="element-internals:elementinternals-5"><a href="#elementinternals">ElementInternals</a></code> instance whose <a href="#internals-target" id="element-internals:internals-target">target
   element</a> is <a id="element-internals:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>Return <a id="element-internals:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#attached-internals" id="element-internals:attached-internals-3">attached internals</a>.</p></li></ol>
  </div>

  <h5 id="the-elementinternals-interface"><span class="secno">4.13.7.1</span> The <code id="the-elementinternals-interface:elementinternals"><a href="#elementinternals">ElementInternals</a></code> interface<a href="#the-elementinternals-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals" title="The ElementInternals interface of the Document Object Model gives web developers a way to allow custom elements to fully participate in HTML forms. It provides utilities for working with these elements in the same way you would work with any standard HTML form element, and also exposes the Accessibility Object Model to the element.">ElementInternals</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>93+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The IDL for the <code id="the-elementinternals-interface:elementinternals-2"><a href="#elementinternals">ElementInternals</a></code> interface is as follows, with the various operations and attributes
  defined in the following sections:</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="elementinternals" data-dfn-type="interface"><c- g="">ElementInternals</c-></dfn> {
  // <a href="#shadow-root-access">Shadow root access</a>
  <c- b="">readonly</c-> <c- b="">attribute</c-> <code id="the-elementinternals-interface:shadowroot"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot"><c- n="">ShadowRoot</c-></a></code>? <a href="#dom-elementinternals-shadowroot" id="the-elementinternals-interface:dom-elementinternals-shadowroot"><c- g="">shadowRoot</c-></a>;

  // <a href="#form-associated-custom-elements">Form-associated custom elements</a>
  <c- b="">undefined</c-> <a href="#dom-elementinternals-setformvalue" id="the-elementinternals-interface:dom-elementinternals-setformvalue"><c- g="">setFormValue</c-></a>((<a id="the-elementinternals-interface:file" href="https://w3c.github.io/FileAPI/#dfn-file" data-x-internal="file"><c- n="">File</c-></a> <c- b="">or</c-> <a href="https://webidl.spec.whatwg.org/#idl-USVString" id="the-elementinternals-interface:idl-usvstring" data-x-internal="idl-usvstring"><c- b="">USVString</c-></a> <c- b="">or</c-> <a id="the-elementinternals-interface:formdata" href="https://xhr.spec.whatwg.org/#formdata" data-x-internal="formdata"><c- n="">FormData</c-></a>)? <c- g="">value</c->,
                         <c- b="">optional</c-> (<a id="the-elementinternals-interface:file-2" href="https://w3c.github.io/FileAPI/#dfn-file" data-x-internal="file"><c- n="">File</c-></a> <c- b="">or</c-> <a href="https://webidl.spec.whatwg.org/#idl-USVString" id="the-elementinternals-interface:idl-usvstring-2" data-x-internal="idl-usvstring"><c- b="">USVString</c-></a> <c- b="">or</c-> <a id="the-elementinternals-interface:formdata-2" href="https://xhr.spec.whatwg.org/#formdata" data-x-internal="formdata"><c- n="">FormData</c-></a>)? <c- g="">state</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlformelement" id="the-elementinternals-interface:htmlformelement"><c- n="">HTMLFormElement</c-></a>? <a href="#dom-elementinternals-form" id="the-elementinternals-interface:dom-elementinternals-form"><c- g="">form</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-elementinternals-setvalidity" id="the-elementinternals-interface:dom-elementinternals-setvalidity"><c- g="">setValidity</c-></a>(<c- b="">optional</c-> <a href="#validitystateflags" id="the-elementinternals-interface:validitystateflags"><c- n="">ValidityStateFlags</c-></a> <c- g="">flags</c-> = {},
                        <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">message</c->,
                        <c- b="">optional</c-> <a href="#htmlelement" id="the-elementinternals-interface:htmlelement"><c- n="">HTMLElement</c-></a> <c- g="">anchor</c->);
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-elementinternals-willvalidate" id="the-elementinternals-interface:dom-elementinternals-willvalidate"><c- g="">willValidate</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#validitystate" id="the-elementinternals-interface:validitystate"><c- n="">ValidityState</c-></a> <a href="#dom-elementinternals-validity" id="the-elementinternals-interface:dom-elementinternals-validity"><c- g="">validity</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-elementinternals-validationmessage" id="the-elementinternals-interface:dom-elementinternals-validationmessage"><c- g="">validationMessage</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-elementinternals-checkvalidity" id="the-elementinternals-interface:dom-elementinternals-checkvalidity"><c- g="">checkValidity</c-></a>();
  <c- b="">boolean</c-> <a href="#dom-elementinternals-reportvalidity" id="the-elementinternals-interface:dom-elementinternals-reportvalidity"><c- g="">reportValidity</c-></a>();

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-elementinternals-interface:nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist" data-x-internal="nodelist"><c- n="">NodeList</c-></a> <a href="#dom-elementinternals-labels" id="the-elementinternals-interface:dom-elementinternals-labels"><c- g="">labels</c-></a>;

  // <a href="#custom-state-pseudo-class">Custom state pseudo-class</a>
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#customstateset" id="the-elementinternals-interface:customstateset"><c- n="">CustomStateSet</c-></a> <a href="#dom-elementinternals-states" id="the-elementinternals-interface:dom-elementinternals-states"><c- g="">states</c-></a>;
};

// <a href="#accessibility-semantics">Accessibility semantics</a>
<a href="#elementinternals" id="the-elementinternals-interface:elementinternals-3"><c- n="">ElementInternals</c-></a> <c- b="">includes</c-> <a id="the-elementinternals-interface:ariamixin" href="https://w3c.github.io/aria/#ARIAMixin" data-x-internal="ariamixin"><c- n="">ARIAMixin</c-></a>;

<c- b="">dictionary</c-> <dfn id="validitystateflags" data-dfn-type="dictionary"><c- g="">ValidityStateFlags</c-></dfn> {
  <c- b="">boolean</c-> <c- g="">valueMissing</c-> = <c- b="">false</c->;
  <c- b="">boolean</c-> <c- g="">typeMismatch</c-> = <c- b="">false</c->;
  <c- b="">boolean</c-> <c- g="">patternMismatch</c-> = <c- b="">false</c->;
  <c- b="">boolean</c-> <c- g="">tooLong</c-> = <c- b="">false</c->;
  <c- b="">boolean</c-> <c- g="">tooShort</c-> = <c- b="">false</c->;
  <c- b="">boolean</c-> <c- g="">rangeUnderflow</c-> = <c- b="">false</c->;
  <c- b="">boolean</c-> <c- g="">rangeOverflow</c-> = <c- b="">false</c->;
  <c- b="">boolean</c-> <c- g="">stepMismatch</c-> = <c- b="">false</c->;
  <c- b="">boolean</c-> <c- g="">badInput</c-> = <c- b="">false</c->;
  <c- b="">boolean</c-> <c- g="">customError</c-> = <c- b="">false</c->;
};</code></pre>

  <p>Each <code id="the-elementinternals-interface:elementinternals-4"><a href="#elementinternals">ElementInternals</a></code> has a <dfn id="internals-target">target element</dfn>,
  which is a <a href="#custom-element" id="the-elementinternals-interface:custom-element">custom element</a>.</p>

  

  <h5 id="shadow-root-access"><span class="secno">4.13.7.2</span> Shadow root access<a href="#shadow-root-access" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>internals</var>.<a href="#dom-elementinternals-shadowroot" id="shadow-root-access:dom-elementinternals-shadowroot">shadowRoot</a></code></dt><dd><p>Returns the <code id="shadow-root-access:shadowroot"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code> for <var>internals</var>'s <a href="#internals-target" id="shadow-root-access:internals-target">target element</a>, if the <a href="#internals-target" id="shadow-root-access:internals-target-2">target
   element</a> is a <a id="shadow-root-access:shadow-host" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a>, or null otherwise.</p></dd></dl>

  
  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/shadowRoot" title="The shadowRoot read-only property of the ElementInternals interface returns the ShadowRoot for this element.">ElementInternals/shadowRoot</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>93+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>88+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>88+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-shadowroot" data-dfn-type="attribute"><code>shadowRoot</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>target</var> be <a id="shadow-root-access:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#internals-target" id="shadow-root-access:internals-target-3">target
   element</a>.</p></li><li><p>If <var>target</var> is not a <a id="shadow-root-access:shadow-host-2" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a>, then return null.</p></li><li><p>Let <var>shadow</var> be <var>target</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="shadow-root-access:concept-element-shadow-root" data-x-internal="concept-element-shadow-root">shadow root</a>.</p></li><li><p>If <var>shadow</var>'s <a id="shadow-root-access:available-to-element-internals" href="https://dom.spec.whatwg.org/#shadowroot-available-to-element-internals" data-x-internal="available-to-element-internals">available to element internals</a> is false, then return
   null.</p></li><li><p>Return <var>shadow</var>.</p></li></ol>
  </div>
  

  <h5 id="form-associated-custom-elements"><span class="secno">4.13.7.3</span> Form-associated custom elements<a href="#form-associated-custom-elements" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>internals</var>.<a href="#dom-elementinternals-setformvalue" id="form-associated-custom-elements:dom-elementinternals-setformvalue">setFormValue</a>(<var>value</var>)</code></dt><dd>
    <p>Sets both the <a href="#face-state" id="form-associated-custom-elements:face-state">state</a> and <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value">submission value</a> of <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target">target element</a> to <var>value</var>.</p>

    <p>If <var>value</var> is null, the element won't participate in form submission.</p>
   </dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-setformvalue" id="form-associated-custom-elements:dom-elementinternals-setformvalue-2">setFormValue</a>(<var>value</var>,
   <var>state</var>)</code></dt><dd>
    <p>Sets the <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-2">submission value</a> of
    <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-2">target element</a> to
    <var>value</var>, and its <a href="#face-state" id="form-associated-custom-elements:face-state-2">state</a> to <var>state</var>.</p>

    <p>If <var>value</var> is null, the element won't participate in form submission.</p>
   </dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-form" id="form-associated-custom-elements:dom-elementinternals-form">form</a></code></dt><dd><p>Returns the <a href="#form-owner" id="form-associated-custom-elements:form-owner">form owner</a> of <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-3">target element</a>.</p></dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-setvalidity" id="form-associated-custom-elements:dom-elementinternals-setvalidity">setValidity</a>(<var>flags</var>,
   <var>message</var> [, <var>anchor</var> ])</code></dt><dd><p>Marks <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-4">target element</a> as
   suffering from the constraints indicated by the <var>flags</var> argument, and sets the element's
   validation message to <var>message</var>. If <var>anchor</var> is specified, the user agent might
   use it to indicate problems with the constraints of <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-5">target element</a> when the <a href="#form-owner" id="form-associated-custom-elements:form-owner-2">form owner</a> is validated
   interactively or <code id="form-associated-custom-elements:dom-elementinternals-reportvalidity"><a href="#dom-elementinternals-reportvalidity">reportValidity()</a></code> is
   called.</p></dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-setvalidity" id="form-associated-custom-elements:dom-elementinternals-setvalidity-2">setValidity</a>({})</code></dt><dd><p>Marks <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-6">target element</a> as
   <a href="#concept-fv-valid" id="form-associated-custom-elements:concept-fv-valid">satisfying its constraints</a>.</p></dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-willvalidate" id="form-associated-custom-elements:dom-elementinternals-willvalidate">willValidate</a></code></dt><dd><p>Returns true if <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-7">target
   element</a> will be validated when the form is submitted; false otherwise.</p></dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-validity" id="form-associated-custom-elements:dom-elementinternals-validity">validity</a></code></dt><dd><p>Returns the <code id="form-associated-custom-elements:validitystate"><a href="#validitystate">ValidityState</a></code> object for <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-8">target element</a>.</p></dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-validationmessage" id="form-associated-custom-elements:dom-elementinternals-validationmessage">validationMessage</a></code></dt><dd><p>Returns the error message that would be shown to the user if <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-9">target element</a> was to be checked for validity.</p></dd><dt><code><var>valid</var> = <var>internals</var>.<a href="#dom-elementinternals-checkvalidity" id="form-associated-custom-elements:dom-elementinternals-checkvalidity">checkValidity()</a></code></dt><dd><p>Returns true if <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-10">target
   element</a> has no validity problems; false otherwise. Fires an <code id="form-associated-custom-elements:event-invalid"><a href="#event-invalid">invalid</a></code> event at the element in the latter case.</p></dd><dt><code><var>valid</var> = <var>internals</var>.<a href="#dom-elementinternals-reportvalidity" id="form-associated-custom-elements:dom-elementinternals-reportvalidity-2">reportValidity()</a></code></dt><dd><p>Returns true if <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-11">target
   element</a> has no validity problems; otherwise, returns false, fires an <code id="form-associated-custom-elements:event-invalid-2"><a href="#event-invalid">invalid</a></code> event at the element, and (if the event isn't canceled)
   reports the problem to the user.</p></dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-labels" id="form-associated-custom-elements:dom-elementinternals-labels">labels</a></code></dt><dd><p>Returns a <code id="form-associated-custom-elements:nodelist"><a data-x-internal="nodelist" href="https://dom.spec.whatwg.org/#interface-nodelist">NodeList</a></code> of all the <code id="form-associated-custom-elements:the-label-element"><a href="#the-label-element">label</a></code> elements that
   <var>internals</var>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-12">target element</a> is associated
   with.</p></dd></dl>

  <p>Each <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element">form-associated custom element</a> has <dfn id="face-submission-value">submission value</dfn>. It is used to provide one or more
  <a href="#form-entry" id="form-associated-custom-elements:form-entry">entries</a> on form submission.
  The initial value of <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-3">submission value</a> is null, and
  <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-4">submission value</a> can be null, a string, a
  <code id="form-associated-custom-elements:file"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code>, or a <a id="form-associated-custom-elements:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#form-entry" id="form-associated-custom-elements:form-entry-2">entries</a>.</p>

  <p>Each <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-2">form-associated custom element</a> has <dfn id="face-state">state</dfn>.
  It is information with which the user agent can restore a user's input for the element.
  The initial value of <a href="#face-state" id="form-associated-custom-elements:face-state-3">state</a> is null, and <a href="#face-state" id="form-associated-custom-elements:face-state-4">state</a> can be null, a string, a <code id="form-associated-custom-elements:file-2"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code>, or a
  <a id="form-associated-custom-elements:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#form-entry" id="form-associated-custom-elements:form-entry-3">entries</a>.</p>

  <p>The <code id="form-associated-custom-elements:dom-elementinternals-setformvalue-3"><a href="#dom-elementinternals-setformvalue">setFormValue()</a></code> method is used by
  the custom element author to set the element's <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-5">submission
  value</a> and <a href="#face-state" id="form-associated-custom-elements:face-state-5">state</a>, thus communicating these to the user
  agent.</p>

  <p>When the user agent believes it is a good idea to restore a <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-3">form-associated custom
  element</a>'s <a href="#face-state" id="form-associated-custom-elements:face-state-6">state</a>, for example <a href="#restore-persisted-state" id="form-associated-custom-elements:restore-persisted-state">after navigation</a> or restarting the user agent, they may <a href="#enqueue-a-custom-element-callback-reaction" id="form-associated-custom-elements:enqueue-a-custom-element-callback-reaction">enqueue a
  custom element callback reaction</a> with that element, callback name "<code>formStateRestoreCallback</code>", and « the state to be restored, "<code>restore</code>" ».</p>

  <p>If the user agent has a form-filling assist feature, then when the feature is invoked, it may
  <a href="#enqueue-a-custom-element-callback-reaction" id="form-associated-custom-elements:enqueue-a-custom-element-callback-reaction-2">enqueue a custom element callback reaction</a> with a <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-4">form-associated custom
  element</a>, callback name "<code>formStateRestoreCallback</code>", and « the state
  value determined by history of state value and some heuristics, "<code>autocomplete</code>" ».</p>

  <p>In general, the <a href="#face-state" id="form-associated-custom-elements:face-state-7">state</a> is information specified by a user, and
  the <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-6">submission value</a> is a value after canonicalization
  or sanitization, suitable for submission to the server. The following examples makes this
  concrete:</p>

  <p class="example">Suppose that we have a <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-5">form-associated custom element</a> which asks a
  user to specify a date. The user specifies <kbd>"3/15/2019"</kbd>, but the control wishes to
  submit <code>"2019-03-15"</code> to the server. <kbd>"3/15/2019"</kbd> would be a <a href="#face-state" id="form-associated-custom-elements:face-state-8">state</a> of the element, and <code>"2019-03-15"</code> would be
  a <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-7">submission value</a>.</p>

  <p class="example">Suppose you develop a custom element emulating a the behavior of the existing
  <a href="#checkbox-state-(type=checkbox)" id="form-associated-custom-elements:checkbox-state-(type=checkbox)">checkbox</a> <code id="form-associated-custom-elements:the-input-element"><a href="#the-input-element">input</a></code> type. Its <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-8">submission value</a> would be the value of its <code>value</code> content attribute, or the string <code>"on"</code>. Its <a href="#face-state" id="form-associated-custom-elements:face-state-9">state</a> would be one of <code>"checked"</code>, <code>"unchecked"</code>, <code>"checked/indeterminate"</code>, or <code>"unchecked/indeterminate"</code>.</p>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setFormValue" title="The setFormValue() method of the ElementInternals interface sets the element's submission value and state, communicating these to the user agent.">ElementInternals/setFormValue</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-setformvalue" data-dfn-type="method"><code>setFormValue(<var>value</var>,
  <var>state</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>element</var> be <a id="form-associated-custom-elements:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-13">target
   element</a>.</p></li><li><p>If <var>element</var> is not a <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-6">form-associated custom element</a>, then throw a
   <a id="form-associated-custom-elements:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="form-associated-custom-elements:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>element</var>'s <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-9">submission value</a> to <var>value</var> if <var>value</var> is
   not a <code id="form-associated-custom-elements:formdata"><a data-x-internal="formdata" href="https://xhr.spec.whatwg.org/#formdata">FormData</a></code> object, or to a <a href="https://infra.spec.whatwg.org/#list-clone" id="form-associated-custom-elements:list-clone" data-x-internal="list-clone">clone</a> of
   <var>value</var>'s <a href="https://xhr.spec.whatwg.org/#concept-formdata-entry-list" id="form-associated-custom-elements:formdata-entry-list" data-x-internal="formdata-entry-list">entry list</a> otherwise.</p></li><li><p>If the <var>state</var> argument of the function is omitted, set <var>element</var>'s
   <a href="#face-state" id="form-associated-custom-elements:face-state-10">state</a> to its <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-10">submission
   value</a>.

   </p></li><li><p>Otherwise, if <var>state</var> is a <code id="form-associated-custom-elements:formdata-2"><a data-x-internal="formdata" href="https://xhr.spec.whatwg.org/#formdata">FormData</a></code> object, set <var>element</var>'s
   <a href="#face-state" id="form-associated-custom-elements:face-state-11">state</a> to a <a href="https://infra.spec.whatwg.org/#list-clone" id="form-associated-custom-elements:list-clone-2" data-x-internal="list-clone">clone</a> of
   <var>state</var>'s <a href="https://xhr.spec.whatwg.org/#concept-formdata-entry-list" id="form-associated-custom-elements:formdata-entry-list-2" data-x-internal="formdata-entry-list">entry list</a>.</p></li><li><p>Otherwise, set <var>element</var>'s <a href="#face-state" id="form-associated-custom-elements:face-state-12">state</a> to
   <var>state</var>.</p></li></ol>
  </div>

  <hr>

  <p>Each <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-7">form-associated custom element</a> has validity flags named
  <code>valueMissing</code>, <code>typeMismatch</code>,
  <code>patternMismatch</code>, <code>tooLong</code>,
  <code>tooShort</code>, <code>rangeUnderflow</code>,
  <code>rangeOverflow</code>, <code>stepMismatch</code>, and
  <code>customError</code>. They are false initially.</p>

  <p>Each <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-8">form-associated custom element</a> has a
  <dfn id="face-validation-message">validation message</dfn> string. It is the empty string
  initially.</p>

  <p>Each <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-9">form-associated custom element</a> has a
  <dfn id="face-validation-anchor">validation anchor</dfn> element. It is null initially.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setValidity" title="The setValidity() method of the ElementInternals interface sets the validity of the element.">ElementInternals/setValidity</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-setvalidity" data-dfn-type="method"><code>setValidity(<var>flags</var>, <var>message</var>,
  <var>anchor</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>element</var> be <a id="form-associated-custom-elements:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-14">target
   element</a>.</p></li><li><p>If <var>element</var> is not a <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-10">form-associated custom element</a>, then throw a
   <a id="form-associated-custom-elements:notsupportederror-2" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="form-associated-custom-elements:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>flags</var> contains one or more true values and <var>message</var> is not given
   or is the empty string, then throw a <code id="form-associated-custom-elements:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>.</p></li><li><p>For each entry <var>flag</var> → <var>value</var> of <var>flags</var>, set
   <var>element</var>'s validity flag with the name <var>flag</var> to <var>value</var>.</p></li><li><p>Set <var>element</var>'s <a href="#face-validation-message" id="form-associated-custom-elements:face-validation-message">validation message</a>
   to the empty string if <var>message</var> is not given or all of <var>element</var>'s validity
   flags are false, or to <var>message</var> otherwise.</p></li><li><p>If <var>element</var>'s <code>customError</code> validity flag is true, then set
   <var>element</var>'s <a href="#custom-validity-error-message" id="form-associated-custom-elements:custom-validity-error-message">custom validity error message</a> to <var>element</var>'s
   <a href="#face-validation-message" id="form-associated-custom-elements:face-validation-message-2">validation message</a>. Otherwise, set
   <var>element</var>'s <a href="#custom-validity-error-message" id="form-associated-custom-elements:custom-validity-error-message-2">custom validity error message</a> to the empty string.</p></li><li><p>If <var>anchor</var> is not given, then set it to <var>element</var>.</p></li><li><p>Otherwise, if <var>anchor</var> is not a <a id="form-associated-custom-elements:shadow-including-inclusive-descendant" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant" data-x-internal="shadow-including-inclusive-descendant">shadow-including inclusive
   descendant</a> of <var>element</var>, then throw a <a id="form-associated-custom-elements:notfounderror" href="https://webidl.spec.whatwg.org/#notfounderror" data-x-internal="notfounderror">"<code>NotFoundError</code>"</a>
   <code id="form-associated-custom-elements:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>element</var>'s <a href="#face-validation-anchor" id="form-associated-custom-elements:face-validation-anchor">validation anchor</a> to
   <var>anchor</var>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage" title="The validationMessage read-only property of the ElementInternals interface returns the validation message for the element.">ElementInternals/validationMessage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementInternals" id="dom-elementinternals-validationmessage" data-dfn-type="attribute"><code>validationMessage</code></dfn> getter steps
  are:</p>

  <ol><li><p>Let <var>element</var> be <a id="form-associated-custom-elements:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#internals-target" id="form-associated-custom-elements:internals-target-15">target
   element</a>.</p></li><li><p>If <var>element</var> is not a <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-11">form-associated custom element</a>, then throw a
   <a id="form-associated-custom-elements:notsupportederror-3" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="form-associated-custom-elements:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return <var>element</var>'s <a href="#face-validation-message" id="form-associated-custom-elements:face-validation-message-3">validation
   message</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="face-entry-construction">entry construction algorithm</dfn> for a
  <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-12">form-associated custom element</a>, given an element <var>element</var> and an
  <a href="#entry-list" id="form-associated-custom-elements:entry-list">entry list</a> <var>entry list</var>, consists of the following steps:</p>

  <ol><li>
    <p>If <var>element</var>'s <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-11">submission value</a> is a
    <a id="form-associated-custom-elements:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#form-entry" id="form-associated-custom-elements:form-entry-4">entries</a>, then <a href="https://infra.spec.whatwg.org/#list-append" id="form-associated-custom-elements:list-append" data-x-internal="list-append">append</a> each item of <var>element</var>'s <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-12">submission value</a> to <var>entry list</var>, and return.</p>

    <p class="note">In this case, user agent does not refer to the
    <code id="form-associated-custom-elements:attr-fe-name"><a href="#attr-fe-name">name</a></code> content attribute value. An implementation of
    <a href="#form-associated-custom-element" id="form-associated-custom-elements:form-associated-custom-element-13">form-associated custom element</a> is responsible to decide names of
    <a href="#form-entry" id="form-associated-custom-elements:form-entry-5">entries</a>. They can be the
    <code id="form-associated-custom-elements:attr-fe-name-2"><a href="#attr-fe-name">name</a></code> content attribute value, they can be strings based on
    the <code id="form-associated-custom-elements:attr-fe-name-3"><a href="#attr-fe-name">name</a></code> content attribute value, or they can be unrelated
    to the <code id="form-associated-custom-elements:attr-fe-name-4"><a href="#attr-fe-name">name</a></code> content attribute.</p>
   </li><li><p>If the element does not have a <code id="form-associated-custom-elements:attr-fe-name-5"><a href="#attr-fe-name">name</a></code> attribute
   specified, or its <code id="form-associated-custom-elements:attr-fe-name-6"><a href="#attr-fe-name">name</a></code> attribute's value is the empty string,
   then return.</p></li><li><p>If the element's <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-13">submission value</a> is not
   null, <a href="#create-an-entry" id="form-associated-custom-elements:create-an-entry">create an entry</a> with the <code id="form-associated-custom-elements:attr-fe-name-7"><a href="#attr-fe-name">name</a></code> attribute
   value and the <a href="#face-submission-value" id="form-associated-custom-elements:face-submission-value-14">submission value</a>, and <a href="https://infra.spec.whatwg.org/#list-append" id="form-associated-custom-elements:list-append-2" data-x-internal="list-append">append</a> it to <var>entry list</var>.</p></li></ol>
  </div>

  

  <h5 id="accessibility-semantics"><span class="secno">4.13.7.4</span> Accessibility semantics<a href="#accessibility-semantics" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>internals</var>.<a href="https://w3c.github.io/aria/#idl-def-ariamixin-role" id="accessibility-semantics:dom-ariamixin-role" data-x-internal="dom-ariamixin-role">role</a> [ = <var>value</var> ]</code></dt><dd><p>Sets or retrieves the default ARIA role for <var>internals</var>'s <a href="#internals-target" id="accessibility-semantics:internals-target">target element</a>, which will be used unless the page author
   overrides it using the <code id="accessibility-semantics:attr-aria-role"><a href="#attr-aria-role">role</a></code> attribute.</p></dd><dt><code><var>internals</var>.<a href="https://w3c.github.io/aria/#idl-def-ariamixin-ariaactivedescendantelement" id="accessibility-semantics:dom-ariamixin-aria*" data-x-internal="dom-ariamixin-aria*">aria*</a> [ = <var>value</var> ]</code></dt><dd><p>Sets or retrieves various default ARIA states or property values for
   <var>internals</var>'s <a href="#internals-target" id="accessibility-semantics:internals-target-2">target element</a>, which will be used
   unless the page author overrides them using the <code id="accessibility-semantics:attr-aria-*"><a href="#attr-aria-*">aria-*</a></code>
   attributes.</p></dd></dl>

  

  

  <p>Each <a href="#custom-element" id="accessibility-semantics:custom-element">custom element</a> has an <dfn id="internal-content-attribute-map">internal content attribute map</dfn>, which is a
  <a href="https://infra.spec.whatwg.org/#ordered-map" id="accessibility-semantics:ordered-map" data-x-internal="ordered-map">map</a>, initially empty. See the <a href="#wai-aria">Requirements
  related to ARIA and to platform accessibility APIs</a> section for information on how this impacts
  platform accessibility APIs.</p>

  

  <h5 id="custom-state-pseudo-class"><span class="secno">4.13.7.5</span> Custom state pseudo-class<a href="#custom-state-pseudo-class" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states">states</a>.add(<var>value</var>)</code></dt><dd>
    <p>Adds the string <var>value</var> to the element's <a href="#states-set" id="custom-state-pseudo-class:states-set">states set</a> to be exposed as a
    pseudo-class.</p>
   </dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states-2">states</a>.has(<var>value</var>)</code></dt><dd>
    <p>Returns true if <var>value</var> is in the element's <a href="#states-set" id="custom-state-pseudo-class:states-set-2">states set</a>, otherwise
    false.</p>
   </dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states-3">states</a>.delete(<var>value</var>)</code></dt><dd>
    <p>If the element's <a href="#states-set" id="custom-state-pseudo-class:states-set-3">states set</a> has <var>value</var>, then it will be removed and
    true will be returned. Otherwise, false will be returned.</p>
   </dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states-4">states</a>.clear()</code></dt><dd>
    <p>Removes all values from the element's <a href="#states-set" id="custom-state-pseudo-class:states-set-4">states set</a>.</p>
   </dd><dt><code>for (const <var>stateName</var> of <var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states-5">states</a>)</code></dt><dt><code>for (const <var>stateName</var> of <var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states-6">states</a>.entries())</code></dt><dt><code>for (const <var>stateName</var> of <var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states-7">states</a>.keys())</code></dt><dt><code>for (const <var>stateName</var> of <var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states-8">states</a>.values())</code></dt><dd>
    <p>Iterates over all values in the element's <a href="#states-set" id="custom-state-pseudo-class:states-set-5">states set</a>.</p>
   </dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states-9">states</a>.forEach(<var>callback</var>)</code></dt><dd>
    <p>Iterates over all values in the element's <a href="#states-set" id="custom-state-pseudo-class:states-set-6">states set</a> by calling
    <var>callback</var> once for each value.</p>
   </dd><dt><code><var>internals</var>.<a href="#dom-elementinternals-states" id="custom-state-pseudo-class:dom-elementinternals-states-10">states</a>.size</code></dt><dd>
    <p>Returns the number of values in the element's <a href="#states-set" id="custom-state-pseudo-class:states-set-7">states set</a>.</p>
   </dd></dl>

  
   <p>Each <a href="#custom-element" id="custom-state-pseudo-class:custom-element">custom element</a> has a <dfn id="states-set">states set</dfn>, which is a
   <code id="custom-state-pseudo-class:customstateset"><a href="#customstateset">CustomStateSet</a></code>, initially empty.</p>

   <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="customstateset" data-dfn-type="interface"><c- g="">CustomStateSet</c-></dfn> {
  <c- b="">setlike</c->&lt;<c- b="">DOMString</c->&gt;;
};</code></pre>

   <div data-algorithm="">
   <p>The <dfn data-dfn-for="HTMLElement" id="dom-elementinternals-states" data-dfn-type="attribute"><code>states</code></dfn> getter steps are to return
   <a id="custom-state-pseudo-class:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#internals-target" id="custom-state-pseudo-class:internals-target">target element</a>'s <a href="#states-set" id="custom-state-pseudo-class:states-set-8">states
   set</a>.</p>
   </div>
  

  <div class="example">
   <p>The <a href="#states-set" id="custom-state-pseudo-class:states-set-9">states set</a> can expose boolean states represented by existence/non-existence
   of string values. If an author wants to expose a state which can have three values, it can be
   converted to three exclusive boolean states. For example, a state called <code>readyState</code> with <code>"loading"</code>, <code>"interactive"</code>, and <code>"complete"</code> values can be mapped to
   three exclusive boolean states, <code>"loading"</code>, <code>"interactive"</code>, and <code>"complete"</code>:</p>

   <pre><code class="js"><c- c1="">// Change the readyState from anything to "complete".</c->
<c- k="">this</c-><c- p="">.</c->_readyState <c- o="">=</c-> <c- u="">"complete"</c-><c- p="">;</c->
<c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->states<c- p="">.</c-><c- k="">delete</c-><c- p="">(</c-><c- u="">"loading"</c-><c- p="">);</c->
<c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->states<c- p="">.</c-><c- k="">delete</c-><c- p="">(</c-><c- u="">"interactive"</c-><c- p="">);</c->
<c- k="">this</c-><c- p="">.</c->_internals<c- p="">.</c->states<c- p="">.</c->add<c- p="">(</c-><c- u="">"complete"</c-><c- p="">);</c-></code></pre>
  </div>

  <h3 id="common-idioms"><span class="secno">4.14</span> Common idioms without dedicated elements<a href="#common-idioms" class="self-link"></a></h3>

  <h4 id="rel-up"><span class="secno">4.14.1</span> Breadcrumb navigation<a href="#rel-up" class="self-link"></a></h4>

  <p>This specification does not provide a machine-readable way of describing breadcrumb navigation
  menus. Authors are encouraged to just use a series of links in a paragraph. The <code id="rel-up:the-nav-element"><a href="#the-nav-element">nav</a></code>
  element can be used to mark the section containing these paragraphs as being navigation
  blocks.</p>

  

  <div class="example">

   <p>In the following example, the current page can be reached via two paths.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/"</c-><c- p="">&gt;</c->Main<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> ▸
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/products/"</c-><c- p="">&gt;</c->Products<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> ▸
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/products/dishwashers/"</c-><c- p="">&gt;</c->Dishwashers<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> ▸
  <c- p="">&lt;</c-><c- f="">a</c-><c- p="">&gt;</c->Second hand<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/"</c-><c- p="">&gt;</c->Main<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> ▸
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/second-hand/"</c-><c- p="">&gt;</c->Second hand<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> ▸
  <c- p="">&lt;</c-><c- f="">a</c-><c- p="">&gt;</c->Dishwashers<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="tag-clouds"><span class="secno">4.14.2</span> Tag clouds<a href="#tag-clouds" class="self-link"></a></h4>

  <p id="tag-cloud">This specification does not define any markup specifically for marking up lists
  of keywords that apply to a group of pages (also known as <i>tag clouds</i>). In general, authors
  are encouraged to either mark up such lists using <code id="tag-clouds:the-ul-element"><a href="#the-ul-element">ul</a></code> elements with explicit inline
  counts that are then hidden and turned into a presentational effect using a style sheet, or to use
  SVG.</p>

  <div class="example">

   <p>Here, three tags are included in a short tag cloud:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
<c- p="">.</c-><c- nc="">tag-cloud</c-> <c- o="">&gt;</c-> <c- f="">li</c-> <c- o="">&gt;</c-> <c- f="">span</c-> <c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> <c- kc="">none</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">.</c-><c- nc="">tag-cloud</c-> <c- o="">&gt;</c-> <c- f="">li</c-> <c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> <c- kc="">inline</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">.</c-><c- nc="">tag-cloud-1</c-> <c- p="">{</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- mf="">0.7</c-><c- b="">em</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">.</c-><c- nc="">tag-cloud-2</c-> <c- p="">{</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- mf="">0.9</c-><c- b="">em</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">.</c-><c- nc="">tag-cloud-3</c-> <c- p="">{</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- mf="">1.1</c-><c- b="">em</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">.</c-><c- nc="">tag-cloud-4</c-> <c- p="">{</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- mf="">1.3</c-><c- b="">em</c-><c- p="">;</c-> <c- p="">}</c->
<c- p="">.</c-><c- nc="">tag-cloud-5</c-> <c- p="">{</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- mf="">1.5</c-><c- b="">em</c-><c- p="">;</c-> <c- p="">}</c->

<c- p="">@</c-><c- k="">media</c-> <c- f="">speech</c-> <c- p="">{</c->
  <c- p="">.</c-><c- nc="">tag-cloud</c-> <c- o="">&gt;</c-> <c- f="">li</c-> <c- o="">&gt;</c-> <c- f="">span</c-> <c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-><c- kc="">inline</c-> <c- p="">}</c->
<c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
...
<c- p="">&lt;</c-><c- f="">ul</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"tag-cloud"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"tag-cloud-4"</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"28 instances"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/t/apple"</c-><c- p="">&gt;</c->apple<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-><c- p="">&gt;</c->(popular)<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"tag-cloud-2"</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"6 instances"</c->  <c- e="">href</c-><c- o="">=</c-><c- s="">"/t/kiwi"</c-><c- p="">&gt;</c->kiwi<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-><c- p="">&gt;</c->(rare)<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"tag-cloud-5"</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"41 instances"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/t/pear"</c-><c- p="">&gt;</c->pear<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-><c- p="">&gt;</c->(very popular)<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>

   <p>The actual frequency of each tag is given using the <code id="tag-clouds:attr-title"><a href="#attr-title">title</a></code>
   attribute. A CSS style sheet is provided to convert the markup into a cloud of differently-sized
   words, but for user agents that do not support CSS or are not visual, the markup contains
   annotations like "(popular)" or "(rare)" to categorize the various tags by frequency, thus
   enabling all users to benefit from the information.</p>

   <p>The <code id="tag-clouds:the-ul-element-2"><a href="#the-ul-element">ul</a></code> element is used (rather than <code id="tag-clouds:the-ol-element"><a href="#the-ol-element">ol</a></code>) because the order is not
   particularly important: while the list is in fact ordered alphabetically, it would convey the
   same information if ordered by, say, the length of the tag.</p>

   <p>The <code id="tag-clouds:link-type-tag"><a href="#link-type-tag">tag</a></code> <code id="tag-clouds:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code>-keyword is
   <em>not</em> used on these <code id="tag-clouds:the-a-element"><a href="#the-a-element">a</a></code> elements because they do not represent tags that apply
   to the page itself; they are just part of an index listing the tags themselves.</p>

  </div>


  <h4 id="conversations"><span class="secno">4.14.3</span> Conversations<a href="#conversations" class="self-link"></a></h4>

  

  <p>This specification does not define a specific element for marking up conversations, meeting
  minutes, chat transcripts, dialogues in screenplays, instant message logs, and other situations
  where different players take turns in discourse.</p>

  <p>Instead, authors are encouraged to mark up conversations using <code id="conversations:the-p-element"><a href="#the-p-element">p</a></code> elements and
  punctuation. Authors who need to mark the speaker for styling purposes are encouraged to use
  <code id="conversations:the-span-element"><a href="#the-span-element">span</a></code> or <code id="conversations:the-b-element"><a href="#the-b-element">b</a></code>. Paragraphs with their text wrapped in the <code id="conversations:the-i-element"><a href="#the-i-element">i</a></code>
  element can be used for marking up stage directions.</p>

  <div class="example">

   <p>This example demonstrates this using an extract from Abbot and Costello's famous sketch,
   <cite>Who's on first</cite>:</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Costello: Look, you gotta first baseman?
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Abbott: Certainly.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Costello: Who's playing first?
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Abbott: That's right.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Costello becomes exasperated.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Costello: When you pay off the first baseman every month, who gets the money?
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Abbott: Every dollar of it.</code></pre>

  </div>

  <div class="example">

   <p>The following extract shows how an IM conversation log could be marked up, using the
   <code id="conversations:the-data-element"><a href="#the-data-element">data</a></code> element to provide Unix timestamps for each line. Note that the timestamps are
   provided in a format that the <code id="conversations:the-time-element"><a href="#the-time-element">time</a></code> element does not support, so the
   <code id="conversations:the-data-element-2"><a href="#the-data-element">data</a></code> element is used instead (namely, Unix <code>time_t</code> timestamps).
   Had the author wished to mark up the data using one of the date and time formats supported by the
   <code id="conversations:the-time-element-2"><a href="#the-time-element">time</a></code> element, that element could have been used instead of <code id="conversations:the-data-element-3"><a href="#the-data-element">data</a></code>. This
   could be advantageous as it would allow data analysis tools to detect the timestamps
   unambiguously, without coordination with the page author.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1319898155"</c-><c- p="">&gt;</c->14:22<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->egof<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> I'm not that nerdy, I've only seen 30% of the star trek episodes
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1319898192"</c-><c- p="">&gt;</c->14:23<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->kaj<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> if you know what percentage of the star trek episodes you have seen, you are inarguably nerdy
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1319898200"</c-><c- p="">&gt;</c->14:23<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->egof<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> it's unarguably
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1319898228"</c-><c- p="">&gt;</c->14:23<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->* kaj blinks<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"1319898260"</c-><c- p="">&gt;</c->14:24<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->kaj<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c-> you are not helping your case</code></pre>
   

  </div>

  <div class="example">

   <p>HTML does not have a good way to mark up graphs, so descriptions of interactive conversations
   from games are more difficult to mark up. This example shows one possible convention using
   <code id="conversations:the-dl-element"><a href="#the-dl-element">dl</a></code> elements to list the possible responses at each point in the conversation.
   Another option to consider is describing the conversation in the form of a DOT file, and
   outputting the result as an SVG image to place in the document. <a href="#refsDOT">[DOT]</a></p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Next, you meet a fisher. You can say one of several greetings:
<c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "Hello there!"
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> She responds with "Hello, how may I help you?"; you can respond with:
  <c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "I would like to buy a fish."
   <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> She sells you a fish and the conversation finishes.
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "Can I borrow your boat?"
   <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> She is surprised and asks "What are you offering in return?".
    <c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "Five gold." (if you have enough)
     <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "Ten gold." (if you have enough)
     <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "Fifteen gold." (if you have enough)
     <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> She lends you her boat. The conversation ends.
     <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "A fish." (if you have one)
     <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "A newspaper." (if you have one)
     <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "A pebble." (if you have one)
     <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> "No thanks", she replies. Your conversation options
     at this point are the same as they were after asking to borrow
     her boat, minus any options you've suggested before.
    <c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "Vote for me in the next election!"
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> She turns away. The conversation finishes.
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "Madam, are you aware that your fish are running away?"
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> She looks at you skeptically and says "Fish cannot run, miss".
  <c- p="">&lt;</c-><c- f="">dl</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "You got me!"
   <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> The fisher sighs and the conversation ends.
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "Only kidding."
   <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> "Good one!" she retorts. Your conversation options at this
   point are the same as those following "Hello there!" above.
   <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c-> "Oh, then what are they doing?"
   <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> She looks at her fish, giving you an opportunity to steal
   her boat, which you do. The conversation ends.
  <c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">dd</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In some games, conversations are simpler: each character merely has a fixed set of lines that
   they say. In this example, a game FAQ/walkthrough lists some of the known possible responses for
   each character:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Dialogue<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Some characters repeat their lines in order each time you interact
 with them, others randomly pick from amongst their lines. Those who respond in
 order have numbered entries in the lists below.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->The Shopkeeper<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->How may I help you?
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Fresh apples!
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->A loaf of bread for madam?
 <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->The pilot<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Before the accident:
 <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->I'm about to fly out, sorry!
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Sorry, I'm just waiting for flight clearance and then I'll be off!
 <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->After the accident:
 <c- p="">&lt;</c-><c- f="">ol</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->I'm about to fly out, sorry!
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Ok, I'm not leaving right now, my plane is being cleaned.
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Ok, it's not being cleaned, it needs a minor repair first.
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Ok, ok, stop bothering me! Truth is, I had a crash.
 <c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Clan Leader<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->During the first clan meeting:
 <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Hey, have you seen my daughter? I bet she's up to something nefarious again...
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Nice weather we're having today, eh?
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->The name is Bailey, Jeff Bailey. How can I help you today?
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->A glass of water? Fresh from the well!
 <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->After the earthquake:
 <c- p="">&lt;</c-><c- f="">ol</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->Everyone is safe in the shelter, we just have to put out the fire!
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->I'll go and tell the fire brigade, you keep hosing it down!
 <c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="footnotes"><span class="secno">4.14.4</span> Footnotes<a href="#footnotes" class="self-link"></a></h4>

  <p>HTML does not have a dedicated mechanism for marking up footnotes. Here are the suggested
  alternatives.</p>

  <hr>

  <p>For short inline annotations, the <code id="footnotes:attr-title"><a href="#attr-title">title</a></code> attribute could  be used.</p>

  <div class="example">

   <p>In this example, two parts of a dialogue are annotated with footnote-like content using the
   <code id="footnotes:attr-title-2"><a href="#attr-title">title</a></code> attribute.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->Customer<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->: Hello! I wish to register a complaint. Hello. Miss?
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->Shopkeeper<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->: <strong><c- p="">&lt;</c-><c- f="">span</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Colloquial pronunciation of 'What do you'"</c-></strong>
<c- p="">&gt;</c->Watcha<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> mean, miss?
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->Customer<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->: Uh, I'm sorry, I have a cold. I wish to make a complaint.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->Shopkeeper<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->: Sorry, <c- p="">&lt;</c-><c- f="">span</c-> <strong><c- e="">title</c-><c- o="">=</c-><c- s="">"This is, of course, a lie."</c-></strong><c- p="">&gt;</c->we're
closing for lunch<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.</code></pre>

  </div>

  
  <p class="note">Unfortunately, relying on the <code id="footnotes:attr-title-3"><a href="#attr-title">title</a></code> attribute is
  currently discouraged as many user agents do not expose the attribute in an accessible manner as
  required by this specification (e.g. requiring a pointing device such as a mouse to cause a
  tooltip to appear, which excludes keyboard-only users and touch-only users, such as anyone with a
  modern phone or tablet).</p>

  <p class="note">If the <code id="footnotes:attr-title-4"><a href="#attr-title">title</a></code> attribute is used, CSS can be used to
  draw the reader's attention to the elements with the attribute.</p>

  <div class="example">

   <p>For example, the following CSS places a dashed line below elements that have a <code id="footnotes:attr-title-5"><a href="#attr-title">title</a></code> attribute.</p>

   <pre><code class="css"><c- f="">[title] </c-><c- p="">{</c-> <c- k="">border-bottom</c-><c- p="">:</c-> thin dashed<c- p="">;</c-> <c- p="">}</c-></code></pre>

  </div>

  <hr>

  <p>For longer annotations, the <code id="footnotes:the-a-element"><a href="#the-a-element">a</a></code> element should be used, pointing to an element later
  in the document. The convention is that the contents of the link be a number in square
  brackets.</p>

  <div class="example">

   <p>In this example, a footnote in the dialogue links to a paragraph below the dialogue. The
   paragraph then reciprocally links back to the dialogue, allowing the user to return to the
   location of the footnote.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Announcer: Number 16: The <c- p="">&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->hand<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c->.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Interviewer: Good evening. I have with me in the studio tonight
Mr Norman St John Polevaulter, who for the past few years has been
contradicting people. Mr Polevaulter, why <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->do<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> you
contradict people?
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Norman: I don't. <c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#fn1"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"r1"</c-><c- p="">&gt;</c->[1]<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">sup</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> Interviewer: You told me you did!
<em>...</em>
<c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"fn1"</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#r1"</c-><c- p="">&gt;</c->[1]<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> This is, naturally, a lie,
 but paradoxically if it were true he could not say so without
 contradicting the interviewer and thus making it false.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <hr>

  <p>For side notes, longer annotations that apply to entire sections of the text rather than just
  specific words or sentences, the <code id="footnotes:the-aside-element"><a href="#the-aside-element">aside</a></code> element should be used.</p>

  <div class="example">

   <p>In this example, a sidebar is given after a dialogue, giving it some context.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"speaker"</c-><c- p="">&gt;</c->Customer<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->: I will not buy this record, it is scratched.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"speaker"</c-><c- p="">&gt;</c->Shopkeeper<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->: I'm sorry?
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"speaker"</c-><c- p="">&gt;</c->Customer<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->: I will not buy this record, it is scratched.
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"speaker"</c-><c- p="">&gt;</c->Shopkeeper<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->: No no no, this's'a tobacconist's.
<c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->In 1970, the British Empire lay in ruins, and foreign
 nationalists frequented the streets — many of them Hungarians
 (not the streets — the foreign nationals). Sadly, Alexander
 Yalt has been publishing incompetently-written phrase books.
<c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <hr>

  <p>For figures or tables, footnotes can be included in the relevant <code id="footnotes:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code> or
  <code id="footnotes:the-caption-element"><a href="#the-caption-element">caption</a></code> element, or in surrounding prose.</p>

  <div class="example">

   <p>In this example, a  table has cells with footnotes that are given in prose. A
   <code id="footnotes:the-figure-element"><a href="#the-figure-element">figure</a></code> element is used to give a single legend to the combination of the table and
   its footnotes.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->Table 1. Alternative activities for knights.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Activity
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Location
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c-> Cost
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Dance
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Wherever possible
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> £0<c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#fn1"</c-><c- p="">&gt;</c->1<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">sup</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Routines, chorus scenes<c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#fn2"</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">sup</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Undisclosed
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Undisclosed
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Dining<c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#fn3"</c-><c- p="">&gt;</c->3<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">sup</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Camelot
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c-> Cost of ham, jam, and spam<c- p="">&lt;</c-><c- f="">sup</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#fn4"</c-><c- p="">&gt;</c->4<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">sup</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"fn1"</c-><c- p="">&gt;</c->1. Assumed.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"fn2"</c-><c- p="">&gt;</c->2. Footwork impeccable.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"fn3"</c-><c- p="">&gt;</c->3. Quality described as "well".<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"fn4"</c-><c- p="">&gt;</c->4. A lot.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h3 id="disabled-elements"><span class="secno">4.15</span> Disabled elements<a href="#disabled-elements" class="self-link"></a></h3>

  <div data-algorithm="">
  <p>An element is said to be <dfn id="concept-element-disabled">actually disabled</dfn> if it
  is one of the following:</p>

  <ul><li>a <code id="disabled-elements:the-button-element"><a href="#the-button-element">button</a></code> element that is <a href="#concept-fe-disabled" id="disabled-elements:concept-fe-disabled">disabled</a></li><li>an <code id="disabled-elements:the-input-element"><a href="#the-input-element">input</a></code> element that is <a href="#concept-fe-disabled" id="disabled-elements:concept-fe-disabled-2">disabled</a></li><li>a <code id="disabled-elements:the-select-element"><a href="#the-select-element">select</a></code> element that is <a href="#concept-fe-disabled" id="disabled-elements:concept-fe-disabled-3">disabled</a></li><li>a <code id="disabled-elements:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element that is <a href="#concept-fe-disabled" id="disabled-elements:concept-fe-disabled-4">disabled</a></li><li>an <code id="disabled-elements:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element that has a <code id="disabled-elements:attr-optgroup-disabled"><a href="#attr-optgroup-disabled">disabled</a></code> attribute</li><li>an <code id="disabled-elements:the-option-element"><a href="#the-option-element">option</a></code> element that is <a href="#concept-option-disabled" id="disabled-elements:concept-option-disabled">disabled</a></li><li>a <code id="disabled-elements:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code> element that is a <a href="#concept-fieldset-disabled" id="disabled-elements:concept-fieldset-disabled">disabled fieldset</a></li><li>a <a href="#form-associated-custom-element" id="disabled-elements:form-associated-custom-element">form-associated custom element</a> that is
   <a href="#concept-fe-disabled" id="disabled-elements:concept-fe-disabled-5">disabled</a></li></ul>
  </div>

  <p class="note">This definition is used to determine what elements are <a href="#focusable" id="disabled-elements:focusable">focusable</a> and
  which elements match the <code id="disabled-elements:selector-enabled"><a href="#selector-enabled">:enabled</a></code> and
  <code id="disabled-elements:selector-disabled"><a href="#selector-disabled">:disabled</a></code> <a href="https://drafts.csswg.org/selectors/#pseudo-class" id="disabled-elements:pseudo-class" data-x-internal="pseudo-class">pseudo
  classes</a>.</p>


  

  <h3 id="selectors"><span class="secno">4.16</span> Matching HTML elements using selectors and CSS<a href="#selectors" class="self-link"></a></h3>

  <h4 id="case-sensitivity-of-the-css-'attr()'-function"><span class="secno">4.16.1</span> Case-sensitivity of the CSS <a id="case-sensitivity-of-the-css-'attr()'-function:'attr()'" href="https://drafts.csswg.org/css-values/#funcdef-attr" data-x-internal="'attr()'">'attr()'</a> function<a href="#case-sensitivity-of-the-css-'attr()'-function" class="self-link"></a></h4>

  <p><cite>CSS Values and Units</cite> leaves the case-sensitivity of attribute names for the
  purpose of the <a id="case-sensitivity-of-the-css-'attr()'-function:'attr()'-2" href="https://drafts.csswg.org/css-values/#funcdef-attr" data-x-internal="'attr()'">'attr()'</a> function to be defined by the host language.
  <a href="#refsCSSVALUES">[CSSVALUES]</a></p>

  <p>When comparing the attribute name part of a CSS <a id="case-sensitivity-of-the-css-'attr()'-function:'attr()'-3" href="https://drafts.csswg.org/css-values/#funcdef-attr" data-x-internal="'attr()'">'attr()'</a> function to the names of
  namespace-less attributes on <a href="#html-elements" id="case-sensitivity-of-the-css-'attr()'-function:html-elements">HTML elements</a> in <a id="case-sensitivity-of-the-css-'attr()'-function:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>, the name
  part of the CSS <a id="case-sensitivity-of-the-css-'attr()'-function:'attr()'-4" href="https://drafts.csswg.org/css-values/#funcdef-attr" data-x-internal="'attr()'">'attr()'</a> function must first be <a id="case-sensitivity-of-the-css-'attr()'-function:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
  lowercase</a>. The same function when compared to other attributes must be compared according
  to its original case. In both cases, to match, the values must be <a id="case-sensitivity-of-the-css-'attr()'-function:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> each
  other (and therefore the comparison is case sensitive).</p>

  <p class="note">This is the same as comparing the name part of a CSS <a id="case-sensitivity-of-the-css-'attr()'-function:attribute-selector" href="https://drafts.csswg.org/selectors/#attribute-selector" data-x-internal="attribute-selector">attribute
  selector</a>, specified in the next section.</p>


  <h4 id="case-sensitivity-of-selectors"><span class="secno">4.16.2</span> Case-sensitivity of selectors<a href="#case-sensitivity-of-selectors" class="self-link"></a></h4>

  <p><cite>Selectors</cite> leaves the case-sensitivity of element names, attribute names, and
  attribute values to be defined by the host language. <a href="#refsSELECTORS">[SELECTORS]</a></p>

  <p>When comparing a CSS element <a id="case-sensitivity-of-selectors:type-selector" href="https://drafts.csswg.org/selectors/#type-selector" data-x-internal="type-selector">type selector</a> to the names of <a href="#html-elements" id="case-sensitivity-of-selectors:html-elements">HTML
  elements</a> in <a id="case-sensitivity-of-selectors:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>, the CSS element <a id="case-sensitivity-of-selectors:type-selector-2" href="https://drafts.csswg.org/selectors/#type-selector" data-x-internal="type-selector">type selector</a> must
  first be <a id="case-sensitivity-of-selectors:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>. The same selector when compared to other
  elements must be compared according to its original case. In both cases, to match, the values must
  be <a id="case-sensitivity-of-selectors:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> each other (and therefore the comparison is case sensitive).</p>
  

  <p>When comparing the name part of a CSS <a id="case-sensitivity-of-selectors:attribute-selector" href="https://drafts.csswg.org/selectors/#attribute-selector" data-x-internal="attribute-selector">attribute selector</a> to the names of
  attributes on <a href="#html-elements" id="case-sensitivity-of-selectors:html-elements-2">HTML elements</a> in <a id="case-sensitivity-of-selectors:html-documents-2" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>, the name
  part of the CSS <a id="case-sensitivity-of-selectors:attribute-selector-2" href="https://drafts.csswg.org/selectors/#attribute-selector" data-x-internal="attribute-selector">attribute selector</a> must first be <a id="case-sensitivity-of-selectors:converted-to-ascii-lowercase-2" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
  lowercase</a>. The same selector when compared to other attributes must be compared according
  to its original case. In both cases, the comparison is case-sensitive.</p>
  

  <p><a href="https://drafts.csswg.org/selectors/#attribute-selector" id="case-sensitivity-of-selectors:attribute-selector-3" data-x-internal="attribute-selector">Attribute selectors</a> on an <a href="#html-elements" id="case-sensitivity-of-selectors:html-elements-3">HTML element</a> in an <a href="https://dom.spec.whatwg.org/#html-document" id="case-sensitivity-of-selectors:html-documents-3" data-x-internal="html-documents">HTML
  document</a> must treat the <em>values</em> of attributes with the following names as
  <a id="case-sensitivity-of-selectors:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>:</p>

  
  
  <ul class="brief"><li><code>accept</code>
   </li><li><code>accept-charset</code>
   </li><li><code>align</code>
   </li><li><code>alink</code>
   </li><li><code>axis</code>
   </li><li><code>bgcolor</code>
   </li><li><code>charset</code>
   </li><li><code>checked</code>
   </li><li><code>clear</code>
   </li><li><code>codetype</code>
   </li><li><code>color</code>
   </li><li><code>compact</code>
   </li><li><code>declare</code>
   </li><li><code>defer</code>
   </li><li><code>dir</code>
   </li><li><code>direction</code> 
   </li><li><code>disabled</code>
   </li><li><code>enctype</code>
   </li><li><code>face</code>
   </li><li><code>frame</code>
   </li><li><code>hreflang</code>
   </li><li><code>http-equiv</code>
   </li><li><code>lang</code>
   </li><li><code>language</code>
   </li><li><code>link</code>
   </li><li><code>media</code>
   </li><li><code>method</code>
   </li><li><code>multiple</code>
   </li><li><code>nohref</code>
   </li><li><code>noresize</code>
   </li><li><code>noshade</code>
   </li><li><code>nowrap</code>
   </li><li><code>readonly</code>
   </li><li><code>rel</code>
   </li><li><code>rev</code>
   </li><li><code>rules</code>
   </li><li><code>scope</code>
   </li><li><code>scrolling</code>
   </li><li><code>selected</code>
   </li><li><code>shape</code>
   </li><li><code>target</code>
   </li><li><code>text</code>
   </li><li><code>type</code>
   </li><li><code>valign</code>
   </li><li><code>valuetype</code>
   </li><li><code>vlink</code>
  </li></ul>

  <div class="example">
   <p>For example, the selector <code>[bgcolor="#ffffff"]</code> will match any HTML
   element with a <code>bgcolor</code> attribute with values including <code>#ffffff</code>, <code>#FFFFFF</code> and <code>#fffFFF</code>. This
   happens even if <code>bgcolor</code> has no effect for a given element (e.g.,
   <code id="case-sensitivity-of-selectors:the-div-element"><a href="#the-div-element">div</a></code>).</p>

   <p>The selector <code>[type=a s]</code> will match any
   HTML element with a <code>type</code> attribute whose value is <code>a</code>, but not whose value is <code>A</code>, due to the <code>s</code> flag.</p>
  </div>

  <p>All other attribute values and everything else must be treated as entirely <a id="case-sensitivity-of-selectors:identical-to-2" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical
  to</a> each other for the purposes of selector matching. This includes:</p>

  <ul><li><p><a href="https://dom.spec.whatwg.org/#concept-id" id="case-sensitivity-of-selectors:concept-id" data-x-internal="concept-id">IDs</a> and <a href="https://dom.spec.whatwg.org/#concept-class" id="case-sensitivity-of-selectors:concept-class" data-x-internal="concept-class">classes</a>
   in <a id="case-sensitivity-of-selectors:no-quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-no-quirks" data-x-internal="no-quirks-mode">no-quirks mode</a> and <a id="case-sensitivity-of-selectors:limited-quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-limited-quirks" data-x-internal="limited-quirks-mode">limited-quirks mode</a></p></li><li><p>the names of elements not in the <a id="case-sensitivity-of-selectors:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></p></li><li><p>the names of <a href="#html-elements" id="case-sensitivity-of-selectors:html-elements-4">HTML elements</a> in <a id="case-sensitivity-of-selectors:xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a></p></li><li><p>the names of attributes of elements not in the <a id="case-sensitivity-of-selectors:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></p></li><li><p>the names of attributes of <a href="#html-elements" id="case-sensitivity-of-selectors:html-elements-5">HTML elements</a> in <a id="case-sensitivity-of-selectors:xml-documents-2" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a></p></li><li><p>the names of attributes that themselves have namespaces</p></li></ul>

  <p class="note"><cite>Selectors</cite> defines that ID and class selectors (such as <code>#foo</code> and <code>.bar</code>), when matched against elements in documents
  that are in <a id="case-sensitivity-of-selectors:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, will be matched in an <a id="case-sensitivity-of-selectors:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>
  manner. However, this does not apply for attribute selectors with "<code>id</code>" or
  "<code>class</code>" as the name part. The selector <code>[class="foobar"]</code> will treat its value as case-sensitive even in
  <a id="case-sensitivity-of-selectors:quirks-mode-2" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>.</p>


  <h4 id="pseudo-classes"><span class="secno">4.16.3</span> Pseudo-classes<a href="#pseudo-classes" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes" title="A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s). For example, the pseudo-class :hover can be used to select a button when a user's pointer hovers over the button and this selected button can then be styled.">Pseudo-classes</a></p></div></div>

  <p>There are a number of dynamic selectors that can be used with HTML. This section defines when
  these selectors match HTML elements. <a href="#refsSELECTORS">[SELECTORS]</a> <a href="#refsCSSUI">[CSSUI]</a></p>

  <dl><dt><dfn id="selector-defined" data-dfn-type="selector" data-noexport=""><code>:defined</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:defined" title="The :defined CSS pseudo-class represents any element that has been defined. This includes any standard element built in to the browser, and custom elements that have been successfully defined (i.e. with the CustomElementRegistry.define() method).">:defined</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-defined"><a href="#selector-defined">:defined</a></code> <a id="pseudo-classes:pseudo-class" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match
    any element that is <a href="https://dom.spec.whatwg.org/#concept-element-defined" id="pseudo-classes:concept-element-defined" data-x-internal="concept-element-defined">defined</a>.</p>
   </dd><dt><dfn id="selector-link" data-dfn-type="selector" data-noexport=""><code>:link</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:link" title="The :link CSS pseudo-class represents an element that has not yet been visited. It matches every unvisited <a> or <area> element that has an href attribute.">:link</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3.2+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>1.5+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><dfn id="selector-visited" data-dfn-type="selector" data-noexport=""><code>:visited</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:visited" title="The :visited CSS pseudo-class applies once the link has been visited by the user. For privacy reasons, the styles that can be modified using this selector are very limited. The :visited pseudo-class applies only <a> and <area> elements that have an href attribute.">:visited</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>All <code id="pseudo-classes:the-a-element"><a href="#the-a-element">a</a></code> elements that have an <code id="pseudo-classes:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code>
    attribute, and all <code id="pseudo-classes:the-area-element"><a href="#the-area-element">area</a></code> elements that have an <code id="pseudo-classes:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> attribute, must match one of <code id="pseudo-classes:selector-link"><a href="#selector-link">:link</a></code> and <code id="pseudo-classes:selector-visited"><a href="#selector-visited">:visited</a></code>.</p>

    <p>Other specifications might apply more specific rules regarding how these elements are to
    match these <a href="https://drafts.csswg.org/selectors/#pseudo-class" id="pseudo-classes:pseudo-class-2" data-x-internal="pseudo-class">pseudo-classes</a>, to mitigate some privacy concerns
    that apply with straightforward implementations of this requirement.</p>
   </dd><dt><dfn id="selector-active" data-dfn-type="selector" data-noexport=""><code>:active</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:active" title="The :active CSS pseudo-class represents an element (such as a button) that is being activated by the user. When using a mouse, &quot;activation&quot; typically starts when the user presses down the primary mouse button.">:active</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-active"><a href="#selector-active">:active</a></code> <a id="pseudo-classes:pseudo-class-3" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> is defined to
    match an element <q cite="https://drafts.csswg.org/selectors/#the-active-pseudo">while an
    element is <dfn id="concept-selector-active"><i>being activated</i></dfn> by the
    user</q>.</p>

    <div data-algorithm="">
    <p>To determine whether a particular element is <i id="pseudo-classes:concept-selector-active"><a href="#concept-selector-active">being
    activated</a></i> for the purposes of defining the <code id="pseudo-classes:selector-active-2"><a href="#selector-active">:active</a></code>
    <a id="pseudo-classes:pseudo-class-4" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> only, an HTML user agent must use the first relevant entry in the
    following list.</p>

    <dl><dt>If the element is a <code id="pseudo-classes:the-button-element"><a href="#the-button-element">button</a></code> element</dt><dt>If the element is an <code id="pseudo-classes:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="pseudo-classes:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#submit-button-state-(type=submit)" id="pseudo-classes:submit-button-state-(type=submit)">Submit Button</a>, <a href="#image-button-state-(type=image)" id="pseudo-classes:image-button-state-(type=image)">Image Button</a>, <a href="#reset-button-state-(type=reset)" id="pseudo-classes:reset-button-state-(type=reset)">Reset
     Button</a>, or <a href="#button-state-(type=button)" id="pseudo-classes:button-state-(type=button)">Button</a> state</dt><dt>If the element is an <code id="pseudo-classes:the-a-element-2"><a href="#the-a-element">a</a></code> element that has an <code id="pseudo-classes:attr-hyperlink-href-3"><a href="#attr-hyperlink-href">href</a></code> attribute</dt><dt>If the element is an <code id="pseudo-classes:the-area-element-2"><a href="#the-area-element">area</a></code> element that has an <code id="pseudo-classes:attr-hyperlink-href-4"><a href="#attr-hyperlink-href">href</a></code> attribute</dt><dt>If the element is <a href="#focusable" id="pseudo-classes:focusable">focusable</a></dt><dd>
      <p>The element is <i id="pseudo-classes:concept-selector-active-2"><a href="#concept-selector-active">being activated</a></i> if it is <a href="#in-a-formal-activation-state" id="pseudo-classes:in-a-formal-activation-state">in a
      formal activation state</a>.</p>

      <p class="example">For example, if the user is using a keyboard to push a <code id="pseudo-classes:the-button-element-2"><a href="#the-button-element">button</a></code>
      element by pressing the space bar, the element would match this <a id="pseudo-classes:pseudo-class-5" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> in
      between the time that the element received the <code id="pseudo-classes:event-keydown"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code>
      event and the time the element received the <code id="pseudo-classes:event-keyup"><a data-x-internal="event-keyup" href="https://w3c.github.io/uievents/#event-type-keyup">keyup</a></code> event.</p>
     </dd><dt>If the element is <a href="#being-actively-pointed-at" id="pseudo-classes:being-actively-pointed-at">being actively pointed at</a></dt><dd><p>The element is <i id="pseudo-classes:concept-selector-active-3"><a href="#concept-selector-active">being activated</a></i>.</p></dd></dl>
    </div>

    <div data-algorithm="">
    <p>An element is said to be <dfn id="in-a-formal-activation-state">in a formal activation state</dfn> between the time the user
    begins to indicate an intent to trigger the element's <a id="pseudo-classes:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> and
    either the time the user stops indicating an intent to trigger the element's <a id="pseudo-classes:activation-behaviour-2" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation
    behavior</a>, or the time the element's <a id="pseudo-classes:activation-behaviour-3" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> has finished
    running, which ever comes first.</p>
    </div>

    <div data-algorithm="">
    <p>An element is said to be <dfn id="being-actively-pointed-at">being actively pointed at</dfn> while the user indicates the
    element using a pointing device while that pointing device is in the "down" state (e.g. for a
    mouse, between the time the mouse button is pressed and the time it is released; for a finger
    in a multitouch environment, while the finger is touching the display surface).</p>
    </div>

    <p class="note">Per the definition in <cite>Selectors</cite>, <code id="pseudo-classes:selector-active-3"><a href="#selector-active">:active</a></code> also matches <a id="pseudo-classes:flat-tree" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a> ancestors of
    elements that are <i id="pseudo-classes:concept-selector-active-4"><a href="#concept-selector-active">being activated</a></i>.
    <a href="#refsSELECTORS">[SELECTORS]</a></p>

    <p>Additionally, any element that is the <a href="#labeled-control" id="pseudo-classes:labeled-control">labeled control</a> of a <code id="pseudo-classes:the-label-element"><a href="#the-label-element">label</a></code>
    element that is currently matching <code id="pseudo-classes:selector-active-4"><a href="#selector-active">:active</a></code>, also matches
    <code id="pseudo-classes:selector-active-5"><a href="#selector-active">:active</a></code>. (But, it does not count as being <i id="pseudo-classes:concept-selector-active-5"><a href="#concept-selector-active">being activated</a></i>.)</p>
   </dd><dt><dfn id="selector-hover" data-dfn-type="selector" data-noexport=""><code>:hover</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:hover" title="The :hover CSS pseudo-class matches when the user interacts with an element with a pointing device, but does not necessarily activate it. It is generally triggered when the user hovers over an element with the cursor (mouse pointer).">:hover</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-hover"><a href="#selector-hover">:hover</a></code> <a id="pseudo-classes:pseudo-class-6" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> is defined to
    match an element <q cite="https://drafts.csswg.org/selectors/#the-hover-pseudo">while the user
    <dfn id="concept-selector-hover"><i>designates</i></dfn> an element with a pointing
    device</q>. For the purposes of defining the <code id="pseudo-classes:selector-hover-2"><a href="#selector-hover">:hover</a></code>
    <a id="pseudo-classes:pseudo-class-7" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> only, an HTML user agent must consider an element as being one that
    the user <i id="pseudo-classes:concept-selector-hover"><a href="#concept-selector-hover">designates</a></i> if it is an element that the user
    indicates using a pointing device.</p>

    <p class="note">Per the definition in <cite>Selectors</cite>, <code id="pseudo-classes:selector-hover-3"><a href="#selector-hover">:hover</a></code> also matches <a id="pseudo-classes:flat-tree-2" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a> ancestors of elements
    that are <i id="pseudo-classes:concept-selector-hover-2"><a href="#concept-selector-hover">designated</a></i>. <a href="#refsSELECTORS">[SELECTORS]</a></p>

    <p>Additionally, any element that is the <a href="#labeled-control" id="pseudo-classes:labeled-control-2">labeled control</a> of a <code id="pseudo-classes:the-label-element-2"><a href="#the-label-element">label</a></code>
    element that is currently matching <code id="pseudo-classes:selector-hover-4"><a href="#selector-hover">:hover</a></code>, also matches
    <code id="pseudo-classes:selector-hover-5"><a href="#selector-hover">:hover</a></code>. (But, it does not count as being <i id="pseudo-classes:concept-selector-hover-3"><a href="#concept-selector-hover">designated</a></i>.)</p>



    <div class="example">
     <p>Consider in particular a fragment such as:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">c</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">a</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">b</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">c</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

     <p>If the user designates the element with ID "<code>a</code>" with their pointing
     device, then the <code id="pseudo-classes:the-p-element"><a href="#the-p-element">p</a></code> element (and all its ancestors not shown in the snippet
     above), the <code id="pseudo-classes:the-label-element-3"><a href="#the-label-element">label</a></code> element, the element with ID "<code>a</code>", and
     the element with ID "<code>c</code>" will match the <code id="pseudo-classes:selector-hover-6"><a href="#selector-hover">:hover</a></code> <a id="pseudo-classes:pseudo-class-8" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a>. The element with ID "<code>a</code>" matches it by being <i id="pseudo-classes:concept-selector-hover-4"><a href="#concept-selector-hover">designated</a></i>; the
     <code id="pseudo-classes:the-label-element-4"><a href="#the-label-element">label</a></code> and <code id="pseudo-classes:the-p-element-2"><a href="#the-p-element">p</a></code> elements match it because of the condition in
     <cite>Selectors</cite> about flat tree ancestors; and the element with ID "<code>c</code>" matches it through the additional condition above on <a href="#labeled-control" id="pseudo-classes:labeled-control-3">labeled controls</a> (i.e., its <code id="pseudo-classes:the-label-element-5"><a href="#the-label-element">label</a></code> element matches <code id="pseudo-classes:selector-hover-7"><a href="#selector-hover">:hover</a></code>). However, the element with ID "<code>b</code>" does <em>not</em> match <code id="pseudo-classes:selector-hover-8"><a href="#selector-hover">:hover</a></code>: its
     flat tree descendant is not designated, even though that flat tree descendant matches <code id="pseudo-classes:selector-hover-9"><a href="#selector-hover">:hover</a></code>.</p>
    </div>
   </dd><dt><dfn id="selector-focus" data-dfn-type="selector" data-noexport=""><code>:focus</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:focus" title="The :focus CSS pseudo-class represents an element (such as a form input) that has received focus. It is generally triggered when the user clicks or taps on an element or selects it with the keyboard's Tab key.">:focus</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>7+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <div data-algorithm="">
    <p>For the purposes of the CSS <code id="pseudo-classes:selector-focus"><a href="#selector-focus">:focus</a></code>
    <a id="pseudo-classes:pseudo-class-9" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a>, an <dfn id="element-has-the-focus">element has the focus</dfn> when:</p>

    <ul><li><p>it is not itself a <a href="#navigable-container" id="pseudo-classes:navigable-container">navigable container</a>; and</p></li><li>
      <p>any of the following are true:</p>
      <ul><li><p>it is one of the elements listed in the <a href="#current-focus-chain-of-a-top-level-traversable" id="pseudo-classes:current-focus-chain-of-a-top-level-traversable">current focus chain of the top-level traversable</a>; or</p></li><li><p>its <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="pseudo-classes:concept-element-shadow-root" data-x-internal="concept-element-shadow-root">shadow root</a>
       <var>shadowRoot</var> is not null and <var>shadowRoot</var> is the <a id="pseudo-classes:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> of at
       least one element that <a href="#element-has-the-focus" id="pseudo-classes:element-has-the-focus">has the focus</a>.</p></li></ul>
     </li></ul>
    </div>
   </dd><dt><dfn id="selector-target" data-dfn-type="selector" data-noexport=""><code>:target</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:target" title="The :target CSS pseudo-class represents a unique element (the target element) with an id matching the URL's fragment.">:target</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>2+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>2+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <div data-algorithm="">
    <p>For the purposes of the CSS <code id="pseudo-classes:selector-target"><a href="#selector-target">:target</a></code>
    <a id="pseudo-classes:pseudo-class-10" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a>, the <code id="pseudo-classes:document"><a href="#document">Document</a></code>'s <i>target elements</i> are a list
    containing the <code id="pseudo-classes:document-2"><a href="#document">Document</a></code>'s <a href="#target-element" id="pseudo-classes:target-element">target element</a>, if it is not null, or
    containing no elements, if it is. <a href="#refsSELECTORS">[SELECTORS]</a></p>
    </div>
   </dd><dt><dfn id="selector-popover-open" data-dfn-type="selector" data-noexport=""><code>:popover-open</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:popover-open" title="The :popover-open CSS pseudo-class represents a popover element (i.e. one with a popover attribute) that is in the showing state. You can use this to apply style to popover elements only when they are shown.">:popover-open</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>preview+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-popover-open"><a href="#selector-popover-open">:popover-open</a></code> <a id="pseudo-classes:pseudo-class-11" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> is
    defined to match any <a href="#html-elements" id="pseudo-classes:html-elements">HTML element</a> whose <code id="pseudo-classes:attr-popover"><a href="#attr-popover">popover</a></code> attribute is not in the <a href="#attr-popover-none-state" id="pseudo-classes:attr-popover-none-state">No Popover</a> state and whose <a href="#popover-visibility-state" id="pseudo-classes:popover-visibility-state">popover visibility
    state</a> is <a href="#popover-showing-state" id="pseudo-classes:popover-showing-state">showing</a>.</p>
   </dd><dt><dfn id="selector-enabled" data-dfn-type="selector" data-noexport=""><code>:enabled</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:enabled" title="The :enabled CSS pseudo-class represents any enabled element. An element is enabled if it can be activated (selected, clicked on, typed into, etc.) or accept focus. The element also has a disabled state, in which it can't be activated or accept focus.">:enabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>2+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-enabled"><a href="#selector-enabled">:enabled</a></code> <a id="pseudo-classes:pseudo-class-12" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match any
    <code id="pseudo-classes:the-button-element-3"><a href="#the-button-element">button</a></code>, <code id="pseudo-classes:the-input-element-2"><a href="#the-input-element">input</a></code>, <code id="pseudo-classes:the-select-element"><a href="#the-select-element">select</a></code>, <code id="pseudo-classes:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>,
    <code id="pseudo-classes:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code>, <code id="pseudo-classes:the-option-element"><a href="#the-option-element">option</a></code>, <code id="pseudo-classes:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code> element, or
    <a href="#form-associated-custom-element" id="pseudo-classes:form-associated-custom-element">form-associated custom element</a> that is not <a href="#concept-element-disabled" id="pseudo-classes:concept-element-disabled">actually disabled</a>.</p>
   </dd><dt><dfn id="selector-disabled" data-dfn-type="selector" data-noexport=""><code>:disabled</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:disabled" title="The :disabled CSS pseudo-class represents any disabled element. An element is disabled if it can't be activated (selected, clicked on, typed into, etc.) or accept focus. The element also has an enabled state, in which it can be activated or accept focus.">:disabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>2+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-disabled"><a href="#selector-disabled">:disabled</a></code> <a id="pseudo-classes:pseudo-class-13" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match
    any element that is <a href="#concept-element-disabled" id="pseudo-classes:concept-element-disabled-2">actually disabled</a>.</p>
   </dd><dt><dfn id="selector-checked" data-dfn-type="selector" data-noexport=""><code>:checked</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:checked" title="The :checked CSS pseudo-class selector represents any radio (<input type=&quot;radio&quot;>), checkbox (<input type=&quot;checkbox&quot;>), or option (<option> in a <select>) element that is checked or toggled to an on state.">:checked</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android yes"><span>WebView Android</span><span>2+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-checked"><a href="#selector-checked">:checked</a></code> <a id="pseudo-classes:pseudo-class-14" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match any
    element falling into one of the following categories:</p>

    <ul><li><code id="pseudo-classes:the-input-element-3"><a href="#the-input-element">input</a></code> elements whose <code id="pseudo-classes:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in
     the <a href="#checkbox-state-(type=checkbox)" id="pseudo-classes:checkbox-state-(type=checkbox)">Checkbox</a> state and whose <a href="#concept-fe-checked" id="pseudo-classes:concept-fe-checked">checkedness</a> state is true</li><li><code id="pseudo-classes:the-input-element-4"><a href="#the-input-element">input</a></code> elements whose <code id="pseudo-classes:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in
     the <a href="#radio-button-state-(type=radio)" id="pseudo-classes:radio-button-state-(type=radio)">Radio Button</a> state and whose <a href="#concept-fe-checked" id="pseudo-classes:concept-fe-checked-2">checkedness</a> state is true</li><li><code id="pseudo-classes:the-option-element-2"><a href="#the-option-element">option</a></code> elements whose <a href="#concept-option-selectedness" id="pseudo-classes:concept-option-selectedness">selectedness</a> is true</li></ul>
   </dd><dt><dfn id="selector-indeterminate" data-dfn-type="selector" data-noexport=""><code>:indeterminate</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:indeterminate" title="The :indeterminate CSS pseudo-class represents any form element whose state is indeterminate, such as checkboxes which have their HTML indeterminate attribute set to true, radio buttons which are members of a group in which all radio buttons are unchecked, and indeterminate <progress> elements.">:indeterminate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-indeterminate"><a href="#selector-indeterminate">:indeterminate</a></code> <a id="pseudo-classes:pseudo-class-15" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a>
    must match any element falling into one of the following categories:</p>

    <ul><li><code id="pseudo-classes:the-input-element-5"><a href="#the-input-element">input</a></code> elements whose <code id="pseudo-classes:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute is in
     the <a href="#checkbox-state-(type=checkbox)" id="pseudo-classes:checkbox-state-(type=checkbox)-2">Checkbox</a> state and whose <code id="pseudo-classes:dom-input-indeterminate"><a href="#dom-input-indeterminate">indeterminate</a></code> IDL attribute is set to true</li><li><code id="pseudo-classes:the-input-element-6"><a href="#the-input-element">input</a></code> elements whose <code id="pseudo-classes:attr-input-type-5"><a href="#attr-input-type">type</a></code> attribute is in
     the <a href="#radio-button-state-(type=radio)" id="pseudo-classes:radio-button-state-(type=radio)-2">Radio Button</a> state and whose <a href="#radio-button-group" id="pseudo-classes:radio-button-group">radio button
     group</a> contains no <code id="pseudo-classes:the-input-element-7"><a href="#the-input-element">input</a></code> elements whose <a href="#concept-fe-checked" id="pseudo-classes:concept-fe-checked-3">checkedness</a> state is true.</li><li><code id="pseudo-classes:the-progress-element"><a href="#the-progress-element">progress</a></code> elements with no <code id="pseudo-classes:attr-progress-value"><a href="#attr-progress-value">value</a></code>
     content attribute</li></ul>
   </dd><dt><dfn id="selector-default" data-dfn-type="selector" data-noexport=""><code>:default</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:default" title="The :default CSS pseudo-class selects form elements that are the default in a group of related elements.">:default</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>10+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-default"><a href="#selector-default">:default</a></code> <a id="pseudo-classes:pseudo-class-16" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match any
    element falling into one of the following categories:</p>

    <ul><li><a href="#concept-submit-button" id="pseudo-classes:concept-submit-button">Submit buttons</a> that are <a href="#default-button" id="pseudo-classes:default-button">default buttons</a> of their <a href="#form-owner" id="pseudo-classes:form-owner">form owner</a>.</li><li><code id="pseudo-classes:the-input-element-8"><a href="#the-input-element">input</a></code> elements to which the <code id="pseudo-classes:attr-input-checked"><a href="#attr-input-checked">checked</a></code>
     attribute applies and that have a <code id="pseudo-classes:attr-input-checked-2"><a href="#attr-input-checked">checked</a></code>
     attribute</li><li><code id="pseudo-classes:the-option-element-3"><a href="#the-option-element">option</a></code> elements that have a <code id="pseudo-classes:attr-option-selected"><a href="#attr-option-selected">selected</a></code>
     attribute</li></ul>
   </dd><dt><dfn id="selector-placeholder-shown" data-dfn-type="selector" data-noexport=""><code>:placeholder-shown</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-placeholder-shown"><a href="#selector-placeholder-shown">:placeholder-shown</a></code>
    <a id="pseudo-classes:pseudo-class-17" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match any element falling into one of the following
    categories:</p>

    <ul><li><code id="pseudo-classes:the-input-element-9"><a href="#the-input-element">input</a></code> elements that have a <code id="pseudo-classes:attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code> attribute whose value is currently being
     presented to the user</li><li><code id="pseudo-classes:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> elements that have a <code id="pseudo-classes:attr-textarea-placeholder"><a href="#attr-textarea-placeholder">placeholder</a></code> attribute whose value is currently being
     presented to the user</li></ul>
   </dd><dt><dfn id="selector-valid" data-dfn-type="selector" data-noexport=""><code>:valid</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:valid" title="The :valid CSS pseudo-class represents any <input> or other <form> element whose contents validate successfully. This allows to easily make valid fields adopt an appearance that helps the user confirm that their data is formatted properly.">:valid</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>10+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-valid"><a href="#selector-valid">:valid</a></code> <a id="pseudo-classes:pseudo-class-18" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match any
    element falling into one of the following categories:</p>

    <ul><li>elements that are <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation">candidates for
     constraint validation</a> and that <a href="#concept-fv-valid" id="pseudo-classes:concept-fv-valid">satisfy their
     constraints</a></li><li><code id="pseudo-classes:the-form-element"><a href="#the-form-element">form</a></code> elements that are not the <a href="#form-owner" id="pseudo-classes:form-owner-2">form owner</a> of any elements that
     themselves are <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation-2">candidates for constraint
     validation</a> but do not <a href="#concept-fv-valid" id="pseudo-classes:concept-fv-valid-2">satisfy their
     constraints</a></li><li><code id="pseudo-classes:the-fieldset-element-2"><a href="#the-fieldset-element">fieldset</a></code> elements that have no descendant elements that themselves are <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation-3">candidates for constraint validation</a> but do
     not <a href="#concept-fv-valid" id="pseudo-classes:concept-fv-valid-3">satisfy their constraints</a></li></ul>
   </dd><dt><dfn id="selector-invalid" data-dfn-type="selector" data-noexport=""><code>:invalid</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid" title="The :invalid CSS pseudo-class represents any <form>, <fieldset>, <input> or other <form> element whose contents fail to validate.">:invalid</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>10+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-invalid"><a href="#selector-invalid">:invalid</a></code> <a id="pseudo-classes:pseudo-class-19" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match any
    element falling into one of the following categories:</p>

    <ul><li>elements that are <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation-4">candidates for
     constraint validation</a> but that do not <a href="#concept-fv-valid" id="pseudo-classes:concept-fv-valid-4">satisfy their
     constraints</a></li><li><code id="pseudo-classes:the-form-element-2"><a href="#the-form-element">form</a></code> elements that are the <a href="#form-owner" id="pseudo-classes:form-owner-3">form owner</a> of one or more elements
     that themselves are <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation-5">candidates for constraint
     validation</a> but do not <a href="#concept-fv-valid" id="pseudo-classes:concept-fv-valid-5">satisfy their
     constraints</a></li><li><code id="pseudo-classes:the-fieldset-element-3"><a href="#the-fieldset-element">fieldset</a></code> elements that have of one or more descendant elements that themselves
     are <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation-6">candidates for constraint
     validation</a> but do not <a href="#concept-fv-valid" id="pseudo-classes:concept-fv-valid-6">satisfy their
     constraints</a></li></ul>
   </dd><dt><dfn id="selector-user-valid" data-dfn-type="selector" data-noexport=""><code>:user-valid</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-user-valid"><a href="#selector-user-valid">:user-valid</a></code> <a id="pseudo-classes:pseudo-class-20" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must
    match <code id="pseudo-classes:the-input-element-10"><a href="#the-input-element">input</a></code>, <code id="pseudo-classes:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code>, and <code id="pseudo-classes:the-select-element-2"><a href="#the-select-element">select</a></code> elements whose
    <a href="#user-validity" id="pseudo-classes:user-validity">user validity</a> is true, are
    <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation-7">candidates for constraint validation</a>,
    and that <a href="#concept-fv-valid" id="pseudo-classes:concept-fv-valid-7">satisfy their constraints</a>.</p>
   </dd><dt><dfn id="selector-user-invalid" data-dfn-type="selector" data-noexport=""><code>:user-invalid</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-user-invalid"><a href="#selector-user-invalid">:user-invalid</a></code> <a id="pseudo-classes:pseudo-class-21" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must
    match <code id="pseudo-classes:the-input-element-11"><a href="#the-input-element">input</a></code>, <code id="pseudo-classes:the-textarea-element-4"><a href="#the-textarea-element">textarea</a></code>, and <code id="pseudo-classes:the-select-element-3"><a href="#the-select-element">select</a></code> elements whose
    <a href="#user-validity" id="pseudo-classes:user-validity-2">user validity</a> is true, are
    <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation-8">candidates for constraint validation</a>
    but do not <a href="#concept-fv-valid" id="pseudo-classes:concept-fv-valid-8">satisfy their constraints</a>.</p>
   </dd><dt><dfn id="selector-in-range" data-dfn-type="selector" data-noexport=""><code>:in-range</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:in-range" title="The :in-range CSS pseudo-class represents an <input> element whose current value is within the range limits specified by the min and max attributes.">:in-range</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>16+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>2.2+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-in-range"><a href="#selector-in-range">:in-range</a></code> <a id="pseudo-classes:pseudo-class-22" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match
    all elements that are <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation-9">candidates for
    constraint validation</a>, <a href="#have-range-limitations" id="pseudo-classes:have-range-limitations">have range limitations</a>, and that are neither
    <a href="#suffering-from-an-underflow" id="pseudo-classes:suffering-from-an-underflow">suffering from an underflow</a> nor <a href="#suffering-from-an-overflow" id="pseudo-classes:suffering-from-an-overflow">suffering from an overflow</a>.</p>
   </dd><dt><dfn id="selector-out-of-range" data-dfn-type="selector" data-noexport=""><code>:out-of-range</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:out-of-range" title="The :out-of-range CSS pseudo-class represents an <input> element whose current value is outside the range limits specified by the min and max attributes.">:out-of-range</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>16+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>2.2+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-out-of-range"><a href="#selector-out-of-range">:out-of-range</a></code> <a id="pseudo-classes:pseudo-class-23" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must
    match all elements that are <a href="#candidate-for-constraint-validation" id="pseudo-classes:candidate-for-constraint-validation-10">candidates for
    constraint validation</a>, <a href="#have-range-limitations" id="pseudo-classes:have-range-limitations-2">have range limitations</a>, and that are either
    <a href="#suffering-from-an-underflow" id="pseudo-classes:suffering-from-an-underflow-2">suffering from an underflow</a> or <a href="#suffering-from-an-overflow" id="pseudo-classes:suffering-from-an-overflow-2">suffering from an overflow</a>.</p>
   </dd><dt><dfn id="selector-required" data-dfn-type="selector" data-noexport=""><code>:required</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:required" title="The :required CSS pseudo-class represents any <input>, <select>, or <textarea> element that has the required attribute set on it.">:required</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>10+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4.3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-required"><a href="#selector-required">:required</a></code> <a id="pseudo-classes:pseudo-class-24" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match
    any element falling into one of the following categories:</p>

    <ul><li><code id="pseudo-classes:the-input-element-12"><a href="#the-input-element">input</a></code> elements that are <i id="pseudo-classes:concept-input-required"><a href="#concept-input-required">required</a></i></li><li><code id="pseudo-classes:the-select-element-4"><a href="#the-select-element">select</a></code> elements that have a <code id="pseudo-classes:attr-select-required"><a href="#attr-select-required">required</a></code>
     attribute</li><li><code id="pseudo-classes:the-textarea-element-5"><a href="#the-textarea-element">textarea</a></code> elements that have a <code id="pseudo-classes:attr-textarea-required"><a href="#attr-textarea-required">required</a></code> attribute</li></ul>
   </dd><dt><dfn id="selector-optional" data-dfn-type="selector" data-noexport=""><code>:optional</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:optional" title="The :optional CSS pseudo-class represents any <input>, <select>, or <textarea> element that does not have the required attribute set on it.">:optional</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>10+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-optional"><a href="#selector-optional">:optional</a></code> <a id="pseudo-classes:pseudo-class-25" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match
    any element falling into one of the following categories:</p>

    <ul><li><code id="pseudo-classes:the-input-element-13"><a href="#the-input-element">input</a></code> elements to which the <code id="pseudo-classes:attr-input-required"><a href="#attr-input-required">required</a></code>
     attribute applies that are not <i id="pseudo-classes:concept-input-required-2"><a href="#concept-input-required">required</a></i></li><li><code id="pseudo-classes:the-select-element-5"><a href="#the-select-element">select</a></code> elements that do not have a <code id="pseudo-classes:attr-select-required-2"><a href="#attr-select-required">required</a></code> attribute</li><li><code id="pseudo-classes:the-textarea-element-6"><a href="#the-textarea-element">textarea</a></code> elements that do not have a <code id="pseudo-classes:attr-textarea-required-2"><a href="#attr-textarea-required">required</a></code> attribute</li></ul>
   </dd><dt><dfn id="selector-autofill" data-dfn-type="selector" data-noexport=""><code>:autofill</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:autofill" title="The :autofill CSS pseudo-class matches when an <input> element has its value autofilled by the browser. The class stops matching if the user edits the field.">:autofill</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>86+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span title="Requires a prefix or alternative name.">🔰 1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span title="Requires a prefix or alternative name.">🔰 79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>15+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><dfn id="selector-webkit-autofill" data-dfn-type="selector" data-noexport=""><code>:-webkit-autofill</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-autofill"><a href="#selector-autofill">:autofill</a></code> and <code id="pseudo-classes:selector-webkit-autofill"><a href="#selector-webkit-autofill">:-webkit-autofill</a></code> <a href="https://drafts.csswg.org/selectors/#pseudo-class" id="pseudo-classes:pseudo-class-26" data-x-internal="pseudo-class">pseudo-classes</a> must match <code id="pseudo-classes:the-input-element-14"><a href="#the-input-element">input</a></code> elements which have
    been autofilled by user agent. These pseudo-classes must stop matching if the user edits the
    autofilled field.</p>

    <p class="note">One way such autofilling might happen is via the <code id="pseudo-classes:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code> attribute, but user agents could autofill even
    without that attribute being involved.</p>
   </dd><dt><dfn id="selector-read-only" data-dfn-type="selector" data-noexport=""><code>:read-only</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:read-only" title="The :read-only CSS pseudo-class represents an element (such as input or textarea) that is not editable by the user.">:read-only</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>78+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span title="Requires a prefix or alternative name.">🔰 4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dt><dfn id="selector-read-write" data-dfn-type="selector" data-noexport=""><code>:read-write</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:read-write" title="The :read-write CSS pseudo-class represents an element (such as input or textarea) that is editable by the user.">:read-write</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>78+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>13+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span title="Requires a prefix or alternative name.">🔰 4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-read-write"><a href="#selector-read-write">:read-write</a></code> <a id="pseudo-classes:pseudo-class-27" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must
    match any element falling into one of the following categories, which for the purposes of
    Selectors are thus considered <i>user-alterable</i>: <a href="#refsSELECTORS">[SELECTORS]</a></p>

    <ul><li><code id="pseudo-classes:the-input-element-15"><a href="#the-input-element">input</a></code> elements to which the <code id="pseudo-classes:attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>
     attribute applies, and that are <i id="pseudo-classes:concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i> (i.e. that do not
     have the <code id="pseudo-classes:attr-input-readonly-2"><a href="#attr-input-readonly">readonly</a></code> attribute specified and that are not
     <a href="#concept-fe-disabled" id="pseudo-classes:concept-fe-disabled">disabled</a>)</li><li><code id="pseudo-classes:the-textarea-element-7"><a href="#the-textarea-element">textarea</a></code> elements that do not have a <code id="pseudo-classes:attr-textarea-readonly"><a href="#attr-textarea-readonly">readonly</a></code> attribute, and that are not <a href="#concept-fe-disabled" id="pseudo-classes:concept-fe-disabled-2">disabled</a></li><li>elements that are <a href="#editing-host" id="pseudo-classes:editing-host">editing hosts</a> or <a id="pseudo-classes:editable" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a>
     and are neither <code id="pseudo-classes:the-input-element-16"><a href="#the-input-element">input</a></code> elements nor <code id="pseudo-classes:the-textarea-element-8"><a href="#the-textarea-element">textarea</a></code> elements</li></ul>

    <p>The <code id="pseudo-classes:selector-read-only"><a href="#selector-read-only">:read-only</a></code> <a id="pseudo-classes:pseudo-class-28" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match
    all other <a href="#html-elements" id="pseudo-classes:html-elements-2">HTML elements</a>.</p>
   </dd><dt><dfn id="selector-modal" data-dfn-type="selector" data-noexport=""><code>:modal</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-modal"><a href="#selector-modal">:modal</a></code> <a id="pseudo-classes:pseudo-class-29" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match any
    element falling into one of the following categories:</p>

    <ul><li><code id="pseudo-classes:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> elements whose <a href="#is-modal" id="pseudo-classes:is-modal">is modal</a> is true</li><li>elements whose <a id="pseudo-classes:fullscreen-flag" href="https://fullscreen.spec.whatwg.org/#fullscreen-flag" data-x-internal="fullscreen-flag">fullscreen flag</a> is true</li></ul>
   </dd><dt><dfn id="selector-ltr" data-dfn-type="selector" data-noexport=""><code>:dir(ltr)</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:dir" title="The :dir() CSS pseudo-class matches elements based on the directionality of the text contained in them.">:dir</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>The <code id="pseudo-classes:selector-ltr"><a href="#selector-ltr">:dir(ltr)</a></code> <a id="pseudo-classes:pseudo-class-30" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match all
    elements whose <a href="#the-directionality" id="pseudo-classes:the-directionality">directionality</a> is '<a href="#concept-ltr" id="pseudo-classes:concept-ltr">ltr</a>'.</p>
   </dd><dt><dfn id="selector-rtl" data-dfn-type="selector" data-noexport=""><code>:dir(rtl)</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-rtl"><a href="#selector-rtl">:dir(rtl)</a></code> <a id="pseudo-classes:pseudo-class-31" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match all
    elements whose <a href="#the-directionality" id="pseudo-classes:the-directionality-2">directionality</a> is '<a href="#concept-rtl" id="pseudo-classes:concept-rtl">rtl</a>'.</p>
   </dd><dt><dfn id="selector-custom" data-dfn-type="selector" data-noexport="">Custom state pseudo-class</dfn></dt><dd>
    <p data-var-scope="">The <code id="pseudo-classes:selector-custom"><a href="#selector-custom">:state(<var>identifier</var>)</a></code> pseudo-class must
    match all <a href="#custom-element" id="pseudo-classes:custom-element">custom element</a>s whose <a href="#states-set" id="pseudo-classes:states-set">states set</a>'s <a id="pseudo-classes:set-entries" href="https://webidl.spec.whatwg.org/#dfn-set-entries" data-x-internal="set-entries">set entries</a>
    contains <var>identifier</var>.</p>
   </dd><dt><dfn id="selector-heading" data-dfn-type="selector" data-noexport="">:heading</dfn></dt><dd><p>The <code id="pseudo-classes:selector-heading"><a href="#selector-heading">:heading</a></code> pseudo-class must match all
   <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>, <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>, <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>, and
   <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> elements.</p></dd><dt data-var-scope=""><dfn id="selector-heading-functional" data-dfn-type="selector" data-noexport="">:heading(<var>integer</var>#)</dfn></dt><dd data-var-scope=""><p>The <code id="pseudo-classes:selector-heading-functional"><a href="#selector-heading-functional">:heading(<var>integer</var>#)</a></code>
   pseudo-class must match all <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-7"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-8"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>, <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-9"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-10"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>,
   <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-11"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>, and <code id="pseudo-classes:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-12"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> elements that have a <a href="#heading-level" id="pseudo-classes:heading-level">heading level</a> of
   <var>integer</var>. <a href="#refsCSSSYNTAX">[CSSSYNTAX]</a> <a href="#refsCSSVALUES">[CSSVALUES]</a></p></dd><dt><dfn id="selector-playing" data-dfn-type="selector" data-noexport=""><code>:playing</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-playing"><a href="#selector-playing">:playing</a></code> <a id="pseudo-classes:pseudo-class-32" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match all
    <a href="#media-element" id="pseudo-classes:media-element">media elements</a> whose <code id="pseudo-classes:dom-media-paused"><a href="#dom-media-paused">paused</a></code> attribute is false.</p>
    
   </dd><dt><dfn id="selector-paused" data-dfn-type="selector" data-noexport=""><code>:paused</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-paused"><a href="#selector-paused">:paused</a></code> <a id="pseudo-classes:pseudo-class-33" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match all
    <a href="#media-element" id="pseudo-classes:media-element-2">media elements</a> whose <code id="pseudo-classes:dom-media-paused-2"><a href="#dom-media-paused">paused</a></code> attribute is true.</p>
    
   </dd><dt><dfn id="selector-seeking" data-dfn-type="selector" data-noexport=""><code>:seeking</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-seeking"><a href="#selector-seeking">:seeking</a></code> <a id="pseudo-classes:pseudo-class-34" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match all
    <a href="#media-element" id="pseudo-classes:media-element-3">media elements</a> whose <code id="pseudo-classes:dom-media-seeking"><a href="#dom-media-seeking">seeking</a></code> attribute is true.</p>
    
   </dd><dt><dfn id="selector-buffering" data-dfn-type="selector" data-noexport=""><code>:buffering</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-buffering"><a href="#selector-buffering">:buffering</a></code> <a id="pseudo-classes:pseudo-class-35" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match
    all <a href="#media-element" id="pseudo-classes:media-element-4">media elements</a> whose <code id="pseudo-classes:dom-media-paused-3"><a href="#dom-media-paused">paused</a></code> attribute is false, <code id="pseudo-classes:dom-media-networkstate"><a href="#dom-media-networkstate">networkState</a></code> attribute is <code id="pseudo-classes:dom-media-network_loading"><a href="#dom-media-network_loading">NETWORK_LOADING</a></code>, and ready state is <code id="pseudo-classes:dom-media-have_current_data"><a href="#dom-media-have_current_data">HAVE_CURRENT_DATA</a></code> or less.</p>
    
   </dd><dt><dfn id="selector-stalled" data-dfn-type="selector" data-noexport=""><code>:stalled</code></dfn></dt><dd><p>The <code id="pseudo-classes:selector-stalled"><a href="#selector-stalled">:stalled</a></code> <a id="pseudo-classes:pseudo-class-36" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match
   all <a href="#media-element" id="pseudo-classes:media-element-5">media elements</a> that match the <code id="pseudo-classes:selector-buffering-2"><a href="#selector-buffering">:buffering</a></code> <a id="pseudo-classes:pseudo-class-37" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> and whose <a href="#is-currently-stalled" id="pseudo-classes:is-currently-stalled">is
   currently stalled</a> is true.</p></dd><dt><dfn id="selector-muted" data-dfn-type="selector" data-noexport=""><code>:muted</code></dfn></dt><dd><p>The <code id="pseudo-classes:selector-muted"><a href="#selector-muted">:muted</a></code> <a id="pseudo-classes:pseudo-class-38" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match all
   <a href="#media-element" id="pseudo-classes:media-element-6">media elements</a> that are <a href="#concept-media-muted" id="pseudo-classes:concept-media-muted">muted</a>.</p></dd><dt><dfn id="selector-volume-locked" data-dfn-type="selector" data-noexport=""><code>:volume-locked</code></dfn></dt><dd><p>The <code id="pseudo-classes:selector-volume-locked"><a href="#selector-volume-locked">:volume-locked</a></code> <a id="pseudo-classes:pseudo-class-39" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a>
   must match all <a href="#media-element" id="pseudo-classes:media-element-7">media elements</a> when the user agent's
   <a href="#volume-locked" id="pseudo-classes:volume-locked">volume locked</a> is true.</p></dd><dt><dfn id="selector-open" data-dfn-type="selector"><code>:open</code></dfn></dt><dd>
    <p>The <code id="pseudo-classes:selector-open"><a href="#selector-open">:open</a></code> <a id="pseudo-classes:pseudo-class-40" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> must match any
    element falling into one of the following categories:</p>

    <ul><li><p><code id="pseudo-classes:the-details-element"><a href="#the-details-element">details</a></code> elements that have an <code id="pseudo-classes:attr-details-open"><a href="#attr-details-open">open</a></code>
     attribute</p></li><li><p><code id="pseudo-classes:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code> elements that have an <code id="pseudo-classes:attr-dialog-open"><a href="#attr-dialog-open">open</a></code>
     attribute</p></li><li><p><code id="pseudo-classes:the-select-element-6"><a href="#the-select-element">select</a></code> elements that are a <a href="#drop-down-box" id="pseudo-classes:drop-down-box">drop-down box</a> and whose drop-down
     boxes are open</p></li><li><p><code id="pseudo-classes:the-input-element-17"><a href="#the-input-element">input</a></code> elements that <a href="#input-support-picker" id="pseudo-classes:input-support-picker">support a
     picker</a> and whose pickers are open</p></li></ul>
   </dd></dl>

  <p class="note">This specification does not define when an element matches the <code>:lang()</code> dynamic <a id="pseudo-classes:pseudo-class-41" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a>, as it is defined in
  sufficient detail in a language-agnostic fashion in <cite>Selectors</cite>.
  <a href="#refsSELECTORS">[SELECTORS]</a></p>

  



  <h2 id="microdata"><span class="secno">5</span> <dfn>Microdata</dfn><a href="#microdata" class="self-link"></a></h2>





  <h3 id="introduction-7"><span class="secno">5.1</span> Introduction<a href="#introduction-7" class="self-link"></a></h3>

  <h4 id="overview"><span class="secno">5.1.1</span> Overview<a href="#overview" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Sometimes, it is desirable to annotate content with specific machine-readable labels, e.g. to
  allow generic scripts to provide services that are customized to the page, or to enable content
  from a variety of cooperating authors to be processed by a single script in a consistent
  manner.</p>

  <p>For this purpose, authors can use the microdata features described in this section. Microdata
  allows nested groups of name-value pairs to be added to documents, in parallel with the existing
  content.</p>


  <h4 id="the-basic-syntax"><span class="secno">5.1.2</span> The basic syntax<a href="#the-basic-syntax" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>At a high level, microdata consists of a group of name-value pairs. The groups are called <a href="#concept-item" id="the-basic-syntax:concept-item">items</a>, and each name-value pair is a property. Items and properties
  are represented by regular elements.</p>

  <p>To create an item, the <code id="the-basic-syntax:attr-itemscope"><a href="#attr-itemscope">itemscope</a></code> attribute is used.</p>

  <p>To add a property to an item, the <code id="the-basic-syntax:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is used
  on one of the <a href="#concept-item" id="the-basic-syntax:concept-item-2">item's</a> descendants.</p>

  <div class="example">

   <p>Here there are two items, each of which has the property "name":</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My name is <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Elizabeth<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My name is <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Daniel<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Markup without the microdata-related attributes does not have any effect on the microdata
  model.</p>

  <div class="example">

   <p>These two examples are exactly equivalent, at a microdata level, as the previous two examples
   respectively:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My <c- p="">&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->name<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c-> is <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->E<c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->liz<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->abeth<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">aside</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My name is <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/?user=daniel"</c-><c- p="">&gt;</c->Daniel<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">aside</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Properties generally have values that are strings.</p>

  <div class="example">

   <p>Here the item has three properties:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My name is <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Neil<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->My band is called <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"band"</c-><c- p="">&gt;</c->Four Parts Water<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I am <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"nationality"</c-><c- p="">&gt;</c->British<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>When a string value is a <a id="the-basic-syntax:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, it is expressed using the <code id="the-basic-syntax:the-a-element"><a href="#the-a-element">a</a></code> element and
  its <code id="the-basic-syntax:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute, the <code id="the-basic-syntax:the-img-element"><a href="#the-img-element">img</a></code> element and its
  <code id="the-basic-syntax:attr-img-src"><a href="#attr-img-src">src</a></code> attribute, or other elements that link to or embed external
  resources.</p>

  <div class="example">

   <p>In this example, the item has one property, "image", whose value is a URL:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"image"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"google-logo.png"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Google"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>When a string value is in some machine-readable format unsuitable for human consumption, it is
  expressed using the <code id="the-basic-syntax:attr-data-value"><a href="#attr-data-value">value</a></code> attribute of the <code id="the-basic-syntax:the-data-element"><a href="#the-data-element">data</a></code>
  element, with the human-readable version given in the element's contents.</p>

  <div class="example">

   <p>Here, there is an item with a property whose value is a product ID. The ID is not
   human-friendly, so the product's name is used the human-visible text instead of the ID.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">h1</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">data</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"product-id"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"9678AOU879"</c-><c- p="">&gt;</c->The Instigator 2000<c- p="">&lt;/</c-><c- f="">data</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>For numeric data, the <code id="the-basic-syntax:the-meter-element"><a href="#the-meter-element">meter</a></code> element and its <code id="the-basic-syntax:attr-meter-value"><a href="#attr-meter-value">value</a></code> attribute can be used instead.</p>

  <div class="example">

   <p>Here a rating is given using a <code id="the-basic-syntax:the-meter-element-2"><a href="#the-meter-element">meter</a></code> element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Product"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Panasonic White 60L Refrigerator<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"panasonic-fridge-60l-white.jpg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"aggregateRating"</c->
       <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/AggregateRating"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">meter</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"ratingValue"</c-> <c- e="">min</c-><c- o="">=</c-><c- s="">0</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">3.5</c-> <c- e="">max</c-><c- o="">=</c-><c- s="">5</c-><c- p="">&gt;</c->Rated 3.5/5<c- p="">&lt;/</c-><c- f="">meter</c-><c- p="">&gt;</c->
   (based on <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"reviewCount"</c-><c- p="">&gt;</c->11<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> customer reviews)
  <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Similarly, for date- and time-related data, the <code id="the-basic-syntax:the-time-element"><a href="#the-time-element">time</a></code> element and its <code id="the-basic-syntax:attr-time-datetime"><a href="#attr-time-datetime">datetime</a></code> attribute can be used instead.</p>

  <div class="example">

   <p>In this example, the item has one property, "birthday", whose value is a date:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 I was born on <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"birthday"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-05-10"</c-><c- p="">&gt;</c->May 10th 2009<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->.
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>Properties can also themselves be groups of name-value pairs, by putting the <code id="the-basic-syntax:attr-itemscope-2"><a href="#attr-itemscope">itemscope</a></code> attribute on the element that declares the property.</p>

  <p>Items that are not part of others are called <a href="#top-level-microdata-items" id="the-basic-syntax:top-level-microdata-items">top-level microdata items</a>.</p>

  <div class="example">

   <p>In this example, the outer item represents a person, and the inner one represents a band:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Name: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Amanda<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Band: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"band"</c-> <c- e="">itemscope</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Jazz Band<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> (<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"size"</c-><c- p="">&gt;</c->12<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> players)<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

   <p>The outer item here has two properties, "name" and "band". The "name" is "Amanda", and the
   "band" is an item in its own right, with two properties, "name" and "size". The "name" of the
   band is "Jazz Band", and the "size" is "12".</p>

   <p>The outer item in this example is a top-level microdata item.</p>

  </div>

  <p>Properties that are not descendants of the element with the <code id="the-basic-syntax:attr-itemscope-3"><a href="#attr-itemscope">itemscope</a></code> attribute can be associated with the <a href="#concept-item" id="the-basic-syntax:concept-item-3">item</a> using the <code id="the-basic-syntax:attr-itemref"><a href="#attr-itemref">itemref</a></code> attribute.
  This attribute takes a list of IDs of elements to crawl in addition to crawling the children of
  the element with the <code id="the-basic-syntax:attr-itemscope-4"><a href="#attr-itemscope">itemscope</a></code> attribute.</p>

  <div class="example">

   <p>This example is the same as the previous one, but all the properties are separated from their
   <a href="#concept-item" id="the-basic-syntax:concept-item-4">items</a>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"amanda"</c-> <c- e="">itemref</c-><c- o="">=</c-><c- s="">"a b"</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->Name: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Amanda<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"b"</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"band"</c-> <c- e="">itemscope</c-> <c- e="">itemref</c-><c- o="">=</c-><c- s="">"c"</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"c"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Band: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Jazz Band<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Size: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"size"</c-><c- p="">&gt;</c->12<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> players<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

   <p>This gives the same result as the previous example. The first item has two properties, "name",
   set to "Amanda", and "band", set to another item. That second item has two further properties,
   "name", set to "Jazz Band", and "size", set to "12".</p>

  </div>

  <p>An <a href="#concept-item" id="the-basic-syntax:concept-item-5">item</a> can have multiple properties with the same name and
  different values.</p>

  <div class="example">

   <p>This example describes an ice cream, with two flavors:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Flavors in my favorite ice cream:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"flavor"</c-><c- p="">&gt;</c->Lemon sorbet<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"flavor"</c-><c- p="">&gt;</c->Apricot sorbet<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

   <p>This thus results in an item with two properties, both "flavor", having the values "Lemon
   sorbet" and "Apricot sorbet".</p>

  </div>

  <p>An element introducing a property can also introduce multiple properties at once, to avoid
  duplication when some of the properties have the same value.</p>

  <div class="example">

   <p>Here we see an item with two properties, "favorite-color" and "favorite-fruit", both set to
   the value "orange":</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"favorite-color favorite-fruit"</c-><c- p="">&gt;</c->orange<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>It's important to note that there is no relationship between the microdata and the content of
  the document where the microdata is marked up.</p>

  <div class="example">

   <p>There is no semantic difference, for instance, between the following two examples:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"castle.jpeg"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">itemscope</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->The Castle<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> (1986)<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemscope</c-><c- p="">&gt;&lt;</c-><c- f="">meta</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"The Castle"</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">figure</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"castle.jpeg"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->The Castle (1986)<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

   <p>Both have a figure with a caption, and both, completely unrelated to the figure, have an item
   with a name-value pair with the name "name" and the value "The Castle". The only difference is
   that if the user drags the caption out of the document, in the former case, the item will be
   included in the drag-and-drop data. In neither case is the image in any way associated with the
   item.</p>

  </div>


  <h4 id="typed-items"><span class="secno">5.1.3</span> Typed items<a href="#typed-items" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>The examples in the previous section show how information could be marked up on a page that
  doesn't expect its microdata to be re-used. Microdata is most useful, though, when it is used in
  contexts where other authors and readers are able to cooperate to make new uses of the markup.</p>

  <p>For this purpose, it is necessary to give each <a href="#concept-item" id="typed-items:concept-item">item</a> a type,
  such as "https://example.com/person", or "https://example.org/cat", or
  "https://band.example.net/". Types are identified as <a href="https://url.spec.whatwg.org/#concept-url" id="typed-items:url" data-x-internal="url">URLs</a>.</p>

  <p>The type for an <a href="#concept-item" id="typed-items:concept-item-2">item</a> is given as the value of an <code id="typed-items:attr-itemtype"><a href="#attr-itemtype">itemtype</a></code> attribute on the same element as the <code id="typed-items:attr-itemscope"><a href="#attr-itemscope">itemscope</a></code> attribute.</p>

  <div class="example">

   <p>Here, the item's type is "https://example.org/animals#cat":</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"https://example.org/animals#cat"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Hedral<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"desc"</c-><c- p="">&gt;</c->Hedral is a male american domestic
 shorthair, with a fluffy black fur with white paws and belly.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"img"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"hedral.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Hedral, age 18 months"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>In this example the "https://example.org/animals#cat" item has three properties, a "name"
   ("Hedral"), a "desc" ("Hedral is..."), and an "img" ("hedral.jpeg").</p>

  </div>

  <p>The type gives the context for the properties, thus selecting a vocabulary: a property named
  "class" given for an item with the type "https://census.example/person" might refer to the economic
  class of an individual, while a property named "class" given for an item with the type
  "https://example.com/school/teacher" might refer to the classroom a teacher has been assigned.
  Several types can share a vocabulary. For example, the types "<code>https://example.org/people/teacher</code>" and "<code>https://example.org/people/engineer</code>" could be defined to use the same vocabulary
  (though maybe some properties would not be especially useful in both cases, e.g. maybe the "<code>https://example.org/people/engineer</code>" type might not typically be used with the
  "<code>classroom</code>" property). Multiple types defined to use the same vocabulary can
  be given for a single item by listing the URLs as a space-separated list in the attribute' value.
  An item cannot be given two types if they do not use the same vocabulary, however.</p>


  <h4 id="global-identifiers-for-items"><span class="secno">5.1.4</span> Global identifiers for items<a href="#global-identifiers-for-items" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Sometimes, an <a href="#concept-item" id="global-identifiers-for-items:concept-item">item</a> gives information about a topic that has a
  global identifier. For example, books can be identified by their ISBN number.</p>

  <p>Vocabularies (as identified by the <code id="global-identifiers-for-items:attr-itemtype"><a href="#attr-itemtype">itemtype</a></code> attribute) can
  be designed such that <a href="#concept-item" id="global-identifiers-for-items:concept-item-2">items</a> get associated with their global
  identifier in an unambiguous way by expressing the global identifiers as <a href="https://url.spec.whatwg.org/#concept-url" id="global-identifiers-for-items:url" data-x-internal="url">URLs</a> given in an <code id="global-identifiers-for-items:attr-itemid"><a href="#attr-itemid">itemid</a></code> attribute.</p>

  <p>The exact meaning of the <a href="https://url.spec.whatwg.org/#concept-url" id="global-identifiers-for-items:url-2" data-x-internal="url">URLs</a> given in <code id="global-identifiers-for-items:attr-itemid-2"><a href="#attr-itemid">itemid</a></code> attributes depends on the vocabulary used.</p>

  <div class="example">

   <p>Here, an item is talking about a particular book:</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-> <c- e="">itemscope</c->
    <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"https://vocab.example.net/book"</c->
    <strong><c- e="">itemid</c-><c- o="">=</c-><c- s="">"urn:isbn:0-330-34032-8"</c-></strong><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Title
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"title"</c-><c- p="">&gt;</c->The Reality Dysfunction
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Author
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"author"</c-><c- p="">&gt;</c->Peter F. Hamilton
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Publication date
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"pubdate"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"1996-01-26"</c-><c- p="">&gt;</c->26 January 1996<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

   <p>The "<code>https://vocab.example.net/book</code>" vocabulary in this example would
   define that the <code id="global-identifiers-for-items:attr-itemid-3"><a href="#attr-itemid">itemid</a></code> attribute takes a <code id="global-identifiers-for-items:urn-protocol"><a data-x-internal="urn-protocol" href="https://www.rfc-editor.org/rfc/rfc2141#section-2">urn:</a></code> <a id="global-identifiers-for-items:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> pointing to the ISBN of the book.</p>

  </div>

  



  <h4 id="selecting-names-when-defining-vocabularies"><span class="secno">5.1.5</span> Selecting names when defining vocabularies<a href="#selecting-names-when-defining-vocabularies" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Using microdata means using a vocabulary. For some purposes, an ad-hoc vocabulary is adequate.
  For others, a vocabulary will need to be designed. Where possible, authors are encouraged to
  re-use existing vocabularies, as this makes content re-use easier.</p>

  <p>When designing new vocabularies, identifiers can be created either using <a href="https://url.spec.whatwg.org/#concept-url" id="selecting-names-when-defining-vocabularies:url" data-x-internal="url">URLs</a>, or, for properties, as plain words (with no dots or colons). For URLs,
  conflicts with other vocabularies can be avoided by only using identifiers that correspond to
  pages that the author has control over.</p>

  <div class="example">

   <p>For instance, if Jon and Adam both write content at <code>example.com</code>, at <code>https://example.com/~jon/...</code> and <code>https://example.com/~adam/...</code> respectively, then
   they could select identifiers of the form
   "https://example.com/~jon/name" and "https://example.com/~adam/name"
   respectively.</p>

  </div>

  <p>Properties whose names are just plain words can only be used within the context of the types
  for which they are intended; properties named using URLs can be reused in items of any type. If an
  item has no type, and is not part of another item, then if its properties have names that are just
  plain words, they are not intended to be globally unique, and are instead only intended for
  limited use. Generally speaking, authors are encouraged to use either properties with globally
  unique names (URLs) or ensure that their items are typed.</p>

  <div class="example">

   <p>Here, an item is an "https://example.org/animals#cat", and most of the properties have names
   that are words defined in the context of that type. There are also a few additional properties
   whose names come from other vocabularies.</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"https://example.org/animals#cat"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name https://example.com/fn"</c-><c- p="">&gt;</c->Hedral<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"desc"</c-><c- p="">&gt;</c->Hedral is a male American domestic
 shorthair, with a fluffy <c- p="">&lt;</c-><c- f="">span</c->
 <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"https://example.com/color"</c-><c- p="">&gt;</c->black<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> fur with <c- p="">&lt;</c-><c- f="">span</c->
 <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"https://example.com/color"</c-><c- p="">&gt;</c->white<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> paws and belly.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"img"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"hedral.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Hedral, age 18 months"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>This example has one item with the type "https://example.org/animals#cat" and the following
   properties:</p>

   <table><thead><tr><td>Property
      </td><td>Value
    </td></tr></thead><tbody><tr><td>name
      </td><td>Hedral
     </td></tr><tr><td>https://example.com/fn
      </td><td>Hedral
     </td></tr><tr><td>desc
      </td><td>Hedral is a male American domestic shorthair, with a fluffy black fur with white paws and belly.
     </td></tr><tr><td>https://example.com/color
      </td><td>black
     </td></tr><tr><td>https://example.com/color
      </td><td>white
     </td></tr><tr><td>img
      </td><td>.../hedral.jpeg
   </td></tr></tbody></table>

  </div>



  <h3 id="encoding-microdata"><span class="secno">5.2</span> Encoding microdata<a href="#encoding-microdata" class="self-link"></a></h3>


  <h4 id="the-microdata-model"><span class="secno">5.2.1</span> The microdata model<a href="#the-microdata-model" class="self-link"></a></h4>

  <p>The microdata model consists of groups of name-value pairs known as <a href="#concept-item" id="the-microdata-model:concept-item">items</a>.</p>

  <p>Each group is known as an <a href="#concept-item" id="the-microdata-model:concept-item-2">item</a>. Each <a href="#concept-item" id="the-microdata-model:concept-item-3">item</a> can have <a href="#item-types" id="the-microdata-model:item-types">item types</a>, a <a href="#global-identifier" id="the-microdata-model:global-identifier">global
  identifier</a> (if the vocabulary specified by the <a href="#item-types" id="the-microdata-model:item-types-2">item types</a> <a href="#support-global-identifiers-for-items" id="the-microdata-model:support-global-identifiers-for-items">support global
  identifiers for items</a>), and a list of name-value pairs. Each name in the name-value pair is
  known as a <a href="#the-properties-of-an-item" id="the-microdata-model:the-properties-of-an-item">property</a>, and each <a href="#the-properties-of-an-item" id="the-microdata-model:the-properties-of-an-item-2">property</a> has one or more <a href="#concept-property-value" id="the-microdata-model:concept-property-value">values</a>. Each <a href="#concept-property-value" id="the-microdata-model:concept-property-value-2">value</a> is either a string or itself a group of name-value
  pairs (an <a href="#concept-item" id="the-microdata-model:concept-item-4">item</a>). The names are unordered relative to each other,
  but if a particular name has multiple values, they do have a relative order.</p>



  <h4 id="items"><span class="secno">5.2.2</span> Items<a href="#items" class="self-link"></a></h4>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemscope" title="itemscope is a boolean global attribute that defines the scope of associated metadata. Specifying the itemscope attribute for an element creates a new item, which results in a number of name-value pairs that are associated with the element.">Global_attributes/itemscope</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>Yes</span></span><span class="safari yes"><span>Safari</span><span>Yes</span></span><span class="chrome yes"><span>Chrome</span><span>Yes</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>Yes</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>Every <a href="#html-elements" id="items:html-elements">HTML element</a> may have an <dfn data-dfn-for="html-global" id="attr-itemscope" data-dfn-type="element-attr"><code>itemscope</code></dfn> attribute specified. The
  <code id="items:attr-itemscope"><a href="#attr-itemscope">itemscope</a></code> attribute is a <a href="#boolean-attribute" id="items:boolean-attribute">boolean attribute</a>.</p>

  <p>An element with the <code id="items:attr-itemscope-2"><a href="#attr-itemscope">itemscope</a></code> attribute specified creates a
  new <dfn id="concept-item">item</dfn>, a group of name-value pairs.</p>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemtype" title="The global attribute itemtype specifies the URL of the vocabulary that will be used to define itemprop's (item properties) in the data structure.">Global_attributes/itemtype</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>Yes</span></span><span class="safari yes"><span>Safari</span><span>Yes</span></span><span class="chrome yes"><span>Chrome</span><span>Yes</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>Yes</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>Elements with an <code id="items:attr-itemscope-3"><a href="#attr-itemscope">itemscope</a></code> attribute may have an <dfn data-dfn-for="html-global" id="attr-itemtype" data-dfn-type="element-attr"><code>itemtype</code></dfn> attribute
  specified, to give the <a href="#item-types" id="items:item-types">item types</a> of the <a href="#concept-item" id="items:concept-item">item</a>.</p>

  <p>The <code id="items:attr-itemtype"><a href="#attr-itemtype">itemtype</a></code> attribute, if specified, must have a value that
  is an <a href="#unordered-set-of-unique-space-separated-tokens" id="items:unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</a>, none of which are
  <a id="items:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> another token and each of which is a <a id="items:valid-url-string" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL string</a> that
  is an <a id="items:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a>, and all of which are defined to use the same vocabulary. The
  attribute's value must have at least one token.</p>

  <div data-algorithm="">
  <p>The <dfn id="item-types">item types</dfn> of an <a href="#concept-item" id="items:concept-item-2">item</a> are the tokens obtained
  by <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="items:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">splitting the element's <code>itemtype</code> attribute's value on ASCII whitespace</a>. If the <code id="items:attr-itemtype-2"><a href="#attr-itemtype">itemtype</a></code> attribute is missing or parsing it in this way finds no
  tokens, the <a href="#concept-item" id="items:concept-item-3">item</a> is said to have no <a href="#item-types" id="items:item-types-2">item types</a>.</p>
  </div>

  <p>The <a href="#item-types" id="items:item-types-3">item types</a> must all be types defined in <a href="#other-applicable-specifications" id="items:other-applicable-specifications">applicable specifications</a> and must all be defined to use the same
  vocabulary.</p>

  

   <p>Except if otherwise specified by that specification, the <a href="https://url.spec.whatwg.org/#concept-url" id="items:url" data-x-internal="url">URLs</a> given
   as the <a href="#item-types" id="items:item-types-4">item types</a> should not be automatically dereferenced.</p>

   <p class="note">A specification could define that its <a href="#item-types" id="items:item-types-5">item type</a>
   can be dereferenced to provide the user with help information, for example. In fact, vocabulary
   authors are encouraged to provide useful information at the given <a id="items:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p>

   <p><a href="#item-types" id="items:item-types-6">Item types</a> are opaque identifiers, and user agents must not dereference unknown
   <a href="#item-types" id="items:item-types-7">item types</a>, or otherwise deconstruct them, in order to determine how to process
   <a href="#concept-item" id="items:concept-item-4">items</a> that use them.</p>

  

  <p>The <code id="items:attr-itemtype-3"><a href="#attr-itemtype">itemtype</a></code> attribute must not be specified on elements
  that do not have an <code id="items:attr-itemscope-4"><a href="#attr-itemscope">itemscope</a></code> attribute specified.</p>

  <hr>

  <div data-algorithm="">
  <p>An <a href="#concept-item" id="items:concept-item-5">item</a> is said to be a <dfn id="typed-item">typed item</dfn> when either it
  has an <a href="#item-types" id="items:item-types-8">item type</a>, or it is the <a href="#concept-property-value" id="items:concept-property-value">value</a> of a <a href="#the-properties-of-an-item" id="items:the-properties-of-an-item">property</a> of a <a href="#typed-item" id="items:typed-item">typed item</a>. The <dfn id="relevant-types">relevant types</dfn> for a
  <a href="#typed-item" id="items:typed-item-2">typed item</a> is the <a href="#concept-item" id="items:concept-item-6">item</a>'s <a href="#item-types" id="items:item-types-9">item types</a>,
  if it has any, or else is the <a href="#relevant-types" id="items:relevant-types">relevant types</a> of the <a href="#concept-item" id="items:concept-item-7">item</a> for which it is a <a href="#the-properties-of-an-item" id="items:the-properties-of-an-item-2">property</a>'s <a href="#concept-property-value" id="items:concept-property-value-2">value</a>.</p>
  </div>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemid" title="The itemid global attribute provides microdata in the form of a unique, global identifier of an item.">Global_attributes/itemid</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>Yes</span></span><span class="safari yes"><span>Safari</span><span>Yes</span></span><span class="chrome yes"><span>Chrome</span><span>Yes</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>Yes</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>Elements with an <code id="items:attr-itemscope-5"><a href="#attr-itemscope">itemscope</a></code> attribute and an <code id="items:attr-itemtype-4"><a href="#attr-itemtype">itemtype</a></code> attribute that references a vocabulary that is defined to
  <dfn id="support-global-identifiers-for-items">support global identifiers for items</dfn> may also have an <dfn data-dfn-for="html-global" id="attr-itemid" data-dfn-type="element-attr"><code>itemid</code></dfn> attribute specified, to give a
  global identifier for the <a href="#concept-item" id="items:concept-item-8">item</a>, so that it can be related to
  other <a href="#concept-item" id="items:concept-item-9">items</a> on pages elsewhere on the web.</p>

  <p>The <code id="items:attr-itemid"><a href="#attr-itemid">itemid</a></code> attribute, if specified, must have a value that is
  a <a href="#valid-url-potentially-surrounded-by-spaces" id="items:valid-url-potentially-surrounded-by-spaces">valid URL potentially surrounded by spaces</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="global-identifier">global identifier</dfn> of an <a href="#concept-item" id="items:concept-item-10">item</a> is the value of
  its element's <code id="items:attr-itemid-2"><a href="#attr-itemid">itemid</a></code> attribute, if it has one, <a href="#encoding-parsing-a-url" id="items:encoding-parsing-a-url">parsed</a> relative to the <a id="items:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> of the
  element on which the attribute is specified. If the <code id="items:attr-itemid-3"><a href="#attr-itemid">itemid</a></code>
  attribute is missing or if parsing it returns failure, it is said to have no <a href="#global-identifier" id="items:global-identifier">global
  identifier</a>.</p>
  </div>

  <p>The <code id="items:attr-itemid-4"><a href="#attr-itemid">itemid</a></code> attribute must not be specified on elements that do
  not have both an <code id="items:attr-itemscope-6"><a href="#attr-itemscope">itemscope</a></code> attribute and an <code id="items:attr-itemtype-5"><a href="#attr-itemtype">itemtype</a></code> attribute specified, and must not be specified on elements
  with an <code id="items:attr-itemscope-7"><a href="#attr-itemscope">itemscope</a></code> attribute whose <code id="items:attr-itemtype-6"><a href="#attr-itemtype">itemtype</a></code> attribute specifies a vocabulary that does not <a href="#support-global-identifiers-for-items" id="items:support-global-identifiers-for-items">support
  global identifiers for items</a>, as defined by that vocabulary's specification.</p>

  <p>The exact meaning of a <a href="#global-identifier" id="items:global-identifier-2">global identifier</a> is determined by the vocabulary's
  specification. It is up to such specifications to define whether multiple items with the same
  global identifier (whether on the same page or on different pages) are allowed to exist, and what
  the processing rules for that vocabulary are with respect to handling the case of multiple items
  with the same ID.</p>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemref" title="Properties that are not descendants of an element with the itemscope attribute can be associated with an item using the global attribute itemref.">Global_attributes/itemref</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>Yes</span></span><span class="safari yes"><span>Safari</span><span>Yes</span></span><span class="chrome yes"><span>Chrome</span><span>Yes</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>Yes</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>Elements with an <code id="items:attr-itemscope-8"><a href="#attr-itemscope">itemscope</a></code> attribute may have an <dfn data-dfn-for="html-global" id="attr-itemref" data-dfn-type="element-attr"><code>itemref</code></dfn> attribute
  specified, to give a list of additional elements to crawl to find the name-value pairs of the
  <a href="#concept-item" id="items:concept-item-11">item</a>.</p>

  <p>The <code id="items:attr-itemref"><a href="#attr-itemref">itemref</a></code> attribute, if specified, must have a value that
  is an <a href="#unordered-set-of-unique-space-separated-tokens" id="items:unordered-set-of-unique-space-separated-tokens-2">unordered set of unique space-separated tokens</a> none of which are
  <a id="items:identical-to-2" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> another token and consisting of <a href="https://dom.spec.whatwg.org/#concept-id" id="items:concept-id" data-x-internal="concept-id">IDs</a> of
  elements in the same <a id="items:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>.</p>

  <p>The <code id="items:attr-itemref-2"><a href="#attr-itemref">itemref</a></code> attribute must not be specified on elements that
  do not have an <code id="items:attr-itemscope-9"><a href="#attr-itemscope">itemscope</a></code> attribute specified.</p>

  <p class="note">The <code id="items:attr-itemref-3"><a href="#attr-itemref">itemref</a></code> attribute is not part of the
  microdata data model. It is merely a syntactic construct to aid authors in adding annotations to
  pages where the data to be annotated does not follow a convenient tree structure. For example, it
  allows authors to mark up data in a table so that each column defines a separate <a href="#concept-item" id="items:concept-item-12">item</a>, while keeping the properties in the cells.</p>

  <div class="example">

   <p>This example shows a simple vocabulary used to describe the products of a model railway
   manufacturer. The vocabulary has just five property names:</p>

   <dl><dt>product-code</dt><dd>An integer that names the product in the manufacturer's catalog.</dd><dt>name</dt><dd>A brief description of the product.</dd><dt>scale</dt><dd>One of "HO", "1", or "Z" (potentially with leading or trailing
    whitespace), indicating the scale of the product.</dd><dt>digital</dt><dd>If present, one of "Digital", "Delta", or "Systems"
    (potentially with leading or trailing whitespace) indicating that
    the product has a digital decoder of the given type.</dd><dt>track-type</dt><dd>For track-specific products, one of "K", "M", "C" (potentially
    with leading or trailing whitespace) indicating the type of track
    for which the product is intended.</dd></dl>

   <p>This vocabulary has four defined <a href="#item-types" id="items:item-types-10">item types</a>:</p>

   <dl><dt>https://md.example.com/loco</dt><dd>Rolling stock with an engine</dd><dt>https://md.example.com/passengers</dt><dd>Passenger rolling stock</dd><dt>https://md.example.com/track</dt><dd>Track pieces</dd><dt>https://md.example.com/lighting</dt><dd>Equipment with lighting</dd></dl>

   <p>Each <a href="#concept-item" id="items:concept-item-13">item</a> that uses this vocabulary can be given one or more
   of these types, depending on what the product is.</p>

   <p>Thus, a locomotive might be marked up as:</p>

<pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"https://md.example.com/loco</c->
<c- s="">                        https://md.example.com/lighting"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Name:
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Tank Locomotive (DB 80)
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Product code:
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"product-code"</c-><c- p="">&gt;</c->33041
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Scale:
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"scale"</c-><c- p="">&gt;</c->HO
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Digital:
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"digital"</c-><c- p="">&gt;</c->Delta
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

   <p>A turnout lantern retrofit kit might be marked up as:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"https://md.example.com/track</c->
<c- s="">                        https://md.example.com/lighting"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Name:
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Turnout Lantern Kit
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Product code:
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"product-code"</c-><c- p="">&gt;</c->74470
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Purpose:
 <c- p="">&lt;</c-><c- f="">dd</c-><c- p="">&gt;</c->For retrofitting 2 <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"track-type"</c-><c- p="">&gt;</c->C<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> Track
 turnouts. <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"scale"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"HO"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

   <p>A passenger car with no lighting might be marked up as:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">dl</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"https://md.example.com/passengers"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Name:
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Express Train Passenger Car (DB Am 203)
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Product code:
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"product-code"</c-><c- p="">&gt;</c->8710
 <c- p="">&lt;</c-><c- f="">dt</c-><c- p="">&gt;</c->Scale:
 <c- p="">&lt;</c-><c- f="">dd</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"scale"</c-><c- p="">&gt;</c->Z
<c- p="">&lt;/</c-><c- f="">dl</c-><c- p="">&gt;</c-></code></pre>

   <p>Great care is necessary when creating new vocabularies. Often, a hierarchical approach to
   types can be taken that results in a vocabulary where each item only ever has a single type,
   which is generally much simpler to manage.</p>

  </div>


  <h4 id="names:-the-itemprop-attribute"><span class="secno">5.2.3</span> Names: the <dfn data-dfn-for="html-global" data-dfn-type="element-attr"><code>itemprop</code></dfn> attribute<a href="#names:-the-itemprop-attribute" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemprop" title="The itemprop global attribute is used to add properties to an item. Every HTML element can have an itemprop attribute specified, and an itemprop consists of a name-value pair. Each name-value pair is called a property, and a group of one or more properties forms an item. Property values are either a string or a URL and can be associated with a very wide range of elements including <audio>, <embed>, <iframe>, <img>, <link>, <object>, <source>, <track>, and <video>.">Global_attributes/itemprop</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>Yes</span></span><span class="safari yes"><span>Safari</span><span>Yes</span></span><span class="chrome yes"><span>Chrome</span><span>Yes</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>Yes</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>Every <a href="#html-elements" id="names:-the-itemprop-attribute:html-elements">HTML element</a> may have an <code id="names:-the-itemprop-attribute:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute specified, if doing so <a href="#the-properties-of-an-item" id="names:-the-itemprop-attribute:the-properties-of-an-item">adds one or more properties</a> to one or more <a href="#concept-item" id="names:-the-itemprop-attribute:concept-item">items</a> (as defined below).</p>

  <p>The <code id="names:-the-itemprop-attribute:names:-the-itemprop-attribute-2"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute, if specified, must have a value
  that is an <a href="#unordered-set-of-unique-space-separated-tokens" id="names:-the-itemprop-attribute:unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</a> none of which are
  <a id="names:-the-itemprop-attribute:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> another token, representing the names of the name-value pairs that it
  adds. The attribute's value must have at least one token.</p>

  <p>Each token must be either:</p>

  <ul><li>If the item is a <a href="#typed-item" id="names:-the-itemprop-attribute:typed-item">typed item</a>: a <dfn id="defined-property-name">defined property name</dfn> allowed in this
   situation according to the specification that defines the <a href="#relevant-types" id="names:-the-itemprop-attribute:relevant-types">relevant types</a> for the
   item, or</li><li>A <a id="names:-the-itemprop-attribute:valid-url-string" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL string</a> that is an <a id="names:-the-itemprop-attribute:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a> defined as an item
   property name allowed in this situation by a vocabulary specification, or</li><li>A <a id="names:-the-itemprop-attribute:valid-url-string-2" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL string</a> that is an <a id="names:-the-itemprop-attribute:absolute-url-2" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a>, used as a proprietary
   item property name (i.e. one used by the author for private purposes, not defined in a public
   specification), or</li><li>If the item is not a <a href="#typed-item" id="names:-the-itemprop-attribute:typed-item-2">typed item</a>: a string that contains no U+002E FULL STOP
   characters (.) and no U+003A COLON characters (:), used as a proprietary item property name (i.e.
   one used by the author for private purposes, not defined in a public specification).</li></ul>

  <p>Specifications that introduce <a href="#defined-property-name" id="names:-the-itemprop-attribute:defined-property-name">defined property names</a>
  must ensure all such property names contain no U+002E FULL STOP characters (.), no U+003A COLON
  characters (:), and no <a id="names:-the-itemprop-attribute:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p>

  <p class="note">The rules above disallow U+003A COLON characters (:) in non-URL values because
  otherwise they could not be distinguished from URLs. Values with U+002E FULL STOP characters (.)
  are reserved for future extensions. <a id="names:-the-itemprop-attribute:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> are disallowed because otherwise
  the values would be parsed as multiple tokens.</p>

  <p>When an element with an <code id="names:-the-itemprop-attribute:names:-the-itemprop-attribute-3"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute <a href="#the-properties-of-an-item" id="names:-the-itemprop-attribute:the-properties-of-an-item-2">adds a property</a> to multiple <a href="#concept-item" id="names:-the-itemprop-attribute:concept-item-2">items</a>,
  the requirement above regarding the tokens applies for each <a href="#concept-item" id="names:-the-itemprop-attribute:concept-item-3">item</a>
  individually.</p>

  

  <div data-algorithm="">
  <p>The <dfn id="property-names">property names</dfn> of an element are the tokens that the element's <code id="names:-the-itemprop-attribute:names:-the-itemprop-attribute-4"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is found to contain when its value is <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="names:-the-itemprop-attribute:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">split on ASCII whitespace</a>, with the order
  preserved but with duplicates removed (leaving only the first occurrence of each name).</p>
  </div>

  <p>Within an <a href="#concept-item" id="names:-the-itemprop-attribute:concept-item-4">item</a>, the properties are unordered with respect to
  each other, except for properties with the same name, which are ordered in the order they are
  given by the algorithm that defines <a href="#the-properties-of-an-item" id="names:-the-itemprop-attribute:the-properties-of-an-item-3">the properties of an item</a>.</p>

  <div class="example">

   <p>In the following example, the "a" property has the values "1" and "2", <em>in that order</em>,
   but whether the "a" property comes before the "b" property or not is not important:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->1<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"b"</c-><c- p="">&gt;</c->test<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

   <p>Thus, the following is equivalent:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"b"</c-><c- p="">&gt;</c->test<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->1<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

   <p>As is the following:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->1<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"b"</c-><c- p="">&gt;</c->test<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

   <p>And the following:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"x"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->1<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-> <c- e="">itemref</c-><c- o="">=</c-><c- s="">"x"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"b"</c-><c- p="">&gt;</c->test<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>



  <h4 id="values"><span class="secno">5.2.4</span> Values<a href="#values" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>The <dfn id="concept-property-value">property value</dfn> of a name-value pair added by an
  element with an <code id="values:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is as given for the first
  matching case in the following list:</p>

  <dl class="switch"><dt>If the element also has an <code id="values:attr-itemscope"><a href="#attr-itemscope">itemscope</a></code> attribute</dt><dd>
    <p>The value is the <a href="#concept-item" id="values:concept-item">item</a> created by the element.</p>
   </dd><dt>If the element is a <code id="values:the-meta-element"><a href="#the-meta-element">meta</a></code> element</dt><dd>
    <p>The value is the value of the element's <code id="values:attr-meta-content"><a href="#attr-meta-content">content</a></code>
    attribute, if any, or the empty string if there is no such attribute.</p>
   </dd><dt>If the element is an <code id="values:the-audio-element"><a href="#the-audio-element">audio</a></code>, <code id="values:the-embed-element"><a href="#the-embed-element">embed</a></code>, <code id="values:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>,
   <code id="values:the-img-element"><a href="#the-img-element">img</a></code>, <code id="values:the-source-element"><a href="#the-source-element">source</a></code>, <code id="values:the-track-element"><a href="#the-track-element">track</a></code>, or <code id="values:the-video-element"><a href="#the-video-element">video</a></code> element</dt><dd>
    <p>The value is the result of <a href="#encoding-parsing-and-serializing-a-url" id="values:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing a URL</a> given the
    element's <code>src</code> attribute's value, relative to the element's <a id="values:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
    document</a>, at the time the attribute is set, or the empty string if there is no such
    attribute or the result is failure.</p>
   </dd><dt>If the element is an <code id="values:the-a-element"><a href="#the-a-element">a</a></code>, <code id="values:the-area-element"><a href="#the-area-element">area</a></code>, or <code id="values:the-link-element"><a href="#the-link-element">link</a></code> element</dt><dd>
    <p>The value is the result of <a href="#encoding-parsing-and-serializing-a-url" id="values:encoding-parsing-and-serializing-a-url-2">encoding-parsing-and-serializing a URL</a> given the
    element's <code>href</code> attribute's value, relative to the element's <a id="values:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
    document</a>, at the time the attribute is set, or the empty string if there is no such
    attribute or the result is failure.</p>
   </dd><dt>If the element is an <code id="values:the-object-element"><a href="#the-object-element">object</a></code> element</dt><dd>
    <p>The value is the result of <a href="#encoding-parsing-and-serializing-a-url" id="values:encoding-parsing-and-serializing-a-url-3">encoding-parsing-and-serializing a URL</a> given the
    element's <code>data</code> attribute's value, relative to the element's <a id="values:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
    document</a>, at the time the attribute is set, or the empty string if there is no such
    attribute or the result is failure.</p>
   </dd><dt>If the element is a <code id="values:the-data-element"><a href="#the-data-element">data</a></code> element</dt><dd>
    <p>The value is the value of the element's <code id="values:attr-data-value"><a href="#attr-data-value">value</a></code> attribute,
    if it has one, or the empty string otherwise.</p>
   </dd><dt>If the element is a <code id="values:the-meter-element"><a href="#the-meter-element">meter</a></code> element</dt><dd>
    <p>The value is the value of the element's <code id="values:attr-meter-value"><a href="#attr-meter-value">value</a></code> attribute,
    if it has one, or the empty string otherwise.</p>
   </dd><dt>If the element is a <code id="values:the-time-element"><a href="#the-time-element">time</a></code> element</dt><dd>
    <p>The value is the element's <a href="#datetime-value" id="values:datetime-value">datetime value</a>.</p>
   </dd><dt>Otherwise</dt><dd>
    <p>The value is the element's <a id="values:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant text content</a>.</p>
   </dd></dl>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="url-property-elements">URL property elements</dfn> are the <code id="values:the-a-element-2"><a href="#the-a-element">a</a></code>, <code id="values:the-area-element-2"><a href="#the-area-element">area</a></code>,
  <code id="values:the-audio-element-2"><a href="#the-audio-element">audio</a></code>, <code id="values:the-embed-element-2"><a href="#the-embed-element">embed</a></code>, <code id="values:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>, <code id="values:the-img-element-2"><a href="#the-img-element">img</a></code>, <code id="values:the-link-element-2"><a href="#the-link-element">link</a></code>,
  <code id="values:the-object-element-2"><a href="#the-object-element">object</a></code>, <code id="values:the-source-element-2"><a href="#the-source-element">source</a></code>, <code id="values:the-track-element-2"><a href="#the-track-element">track</a></code>, and <code id="values:the-video-element-2"><a href="#the-video-element">video</a></code> elements.</p>
  </div>

  <p>If a property's <a href="#concept-property-value" id="values:concept-property-value">value</a>, as defined by the property's
  definition, is an <a id="values:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a>, the property must be specified using a <a href="#url-property-elements" id="values:url-property-elements">URL property element</a>.</p>

  <p class="note">These requirements do not apply just because a property value happens to match the
  syntax for a URL. They only apply if the property is explicitly defined as taking such a
  value.</p>

  <p class="example">For example, a book about the first moon landing  could be
  called "mission:moon". A "title" property from a vocabulary that defines a title as being a string
  would not expect the title to be given in an <code id="values:the-a-element-3"><a href="#the-a-element">a</a></code> element, even though it looks like a
  <a id="values:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>. On the other hand, if there was a (rather narrowly scoped!) vocabulary for
  "books whose titles look like URLs" which had a "title" property defined to take a URL, then the
  property <em>would</em> expect the title to be given in an <code id="values:the-a-element-4"><a href="#the-a-element">a</a></code> element (or one of the
  other <a href="#url-property-elements" id="values:url-property-elements-2">URL property elements</a>), because of the requirement above.</p>


  

  <h4 id="associating-names-with-items"><span class="secno">5.2.5</span> Associating names with items<a href="#associating-names-with-items" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>To find <dfn id="the-properties-of-an-item">the properties of an item</dfn> defined by the element <var>root</var>,
  the user agent must run the following steps. These steps are also used to flag <a href="#microdata-error" id="associating-names-with-items:microdata-error">microdata errors</a>.</p>

  <ol><li><p>Let <var>results</var>, <var>memory</var>, and <var>pending</var> be empty lists of elements.</p></li><li><p>Add the element <var>root</var> to <var>memory</var>.</p></li><li><p>Add the child elements of <var>root</var>, if any, to <var>pending</var>.</p></li><li><p>If <var>root</var> has an <code id="associating-names-with-items:attr-itemref"><a href="#attr-itemref">itemref</a></code> attribute, <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="associating-names-with-items:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">split the value of that <code>itemref</code> attribute on ASCII whitespace</a>. For each resulting
   token <var>ID</var>, if there is an element in the <a id="associating-names-with-items:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> of <var>root</var> with the
   <a href="https://dom.spec.whatwg.org/#concept-id" id="associating-names-with-items:concept-id" data-x-internal="concept-id">ID</a> <var>ID</var>, then add the first such element to
   <var>pending</var>.</p></li><li>
    <p>While <var>pending</var> is not empty:</p>

    <ol><li><p>Remove an element from <var>pending</var> and let <var>current</var> be that
     element.</p></li><li><p>If <var>current</var> is already in <var>memory</var>, there is a
     <a href="#microdata-error" id="associating-names-with-items:microdata-error-2">microdata error</a>; <a id="associating-names-with-items:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Add <var>current</var> to <var>memory</var>.</p></li><li><p>If <var>current</var> does not have an <code id="associating-names-with-items:attr-itemscope"><a href="#attr-itemscope">itemscope</a></code>
     attribute, then: add all the child elements of <var>current</var> to
     <var>pending</var>.</p></li><li><p>If <var>current</var> has an <code id="associating-names-with-items:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute
     specified and has one or more <a href="#property-names" id="associating-names-with-items:property-names">property names</a>, then add <var>current</var> to
     <var>results</var>.</p></li></ol>

   </li><li><p>Sort <var>results</var> in <a id="associating-names-with-items:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li><li><p>Return <var>results</var>.</p></li></ol>
  </div>

  <p>A document must not contain any <a href="#concept-item" id="associating-names-with-items:concept-item">items</a> for which the algorithm
  to find <a href="#the-properties-of-an-item" id="associating-names-with-items:the-properties-of-an-item">the properties of an item</a> finds any <dfn id="microdata-error">microdata
  errors</dfn>.</p>

  <div data-algorithm="">
  <p>An <a href="#concept-item" id="associating-names-with-items:concept-item-2">item</a> is a <dfn id="top-level-microdata-items">top-level
  microdata item</dfn> if its element does not have an <code id="associating-names-with-items:names:-the-itemprop-attribute-2"><a href="#names:-the-itemprop-attribute">itemprop</a></code>
  attribute.</p>
  </div>



  <p>All <code id="associating-names-with-items:attr-itemref-2"><a href="#attr-itemref">itemref</a></code> attributes in a <code id="associating-names-with-items:document"><a href="#document">Document</a></code> must be
  such that there are no cycles in the graph formed from representing each <a href="#concept-item" id="associating-names-with-items:concept-item-3">item</a> in the <code id="associating-names-with-items:document-2"><a href="#document">Document</a></code> as a node in the graph and each
  <a href="#the-properties-of-an-item" id="associating-names-with-items:the-properties-of-an-item-2">property</a> of an item whose <a href="#concept-property-value" id="associating-names-with-items:concept-property-value">value</a> is another item as an edge in the graph connecting
  those two items.</p>

  
  <p>A document must not contain any elements that have an <code id="associating-names-with-items:names:-the-itemprop-attribute-3"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute that would not be found to be a property of any of
  the <a href="#concept-item" id="associating-names-with-items:concept-item-4">items</a> in that document were their <a href="#the-properties-of-an-item" id="associating-names-with-items:the-properties-of-an-item-3">properties</a> all to be determined.</p>

  <div class="example">

   <p>In this example, a single license statement is applied to two works, using <code id="associating-names-with-items:attr-itemref-3"><a href="#attr-itemref">itemref</a></code> from the items representing the works:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Photo gallery<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->My photos<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">figure</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://n.whatwg.org/work"</c-> <c- e="">itemref</c-><c- o="">=</c-><c- s="">"licenses"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"work"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/house.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"A white house, boarded up, sits in a forest."</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">figcaption</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"title"</c-><c- p="">&gt;</c->The house I found.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">figure</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://n.whatwg.org/work"</c-> <c- e="">itemref</c-><c- o="">=</c-><c- s="">"licenses"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"work"</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/mailbox.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Outside the house is a mailbox. It has a leaflet inside."</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">figcaption</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"title"</c-><c- p="">&gt;</c->The mailbox.<c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"licenses"</c-><c- p="">&gt;</c->All images licensed under the <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"license"</c->
   <c- e="">href</c-><c- o="">=</c-><c- s="">"http://www.opensource.org/licenses/mit-license.php"</c-><c- p="">&gt;</c->MIT
   license<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>The above results in two items with the type "<code>http://n.whatwg.org/work</code>",
   one with:</p>

   <dl class="brief"><dt>work
    </dt><dd><code>images/house.jpeg</code>
    </dd><dt>title
    </dt><dd>The house I found.
    </dd><dt>license
    </dt><dd><code>http://www.opensource.org/licenses/mit-license.php</code>
   </dd></dl>

   <p>...and one with:</p>

   <dl class="brief"><dt>work
    </dt><dd><code>images/mailbox.jpeg</code>
    </dd><dt>title
    </dt><dd>The mailbox.
    </dd><dt>license
    </dt><dd><code>http://www.opensource.org/licenses/mit-license.php</code>
   </dd></dl>

  </div>

   


  <h4 id="microdata-and-other-namespaces"><span class="secno">5.2.6</span> Microdata and other namespaces<a href="#microdata-and-other-namespaces" class="self-link"></a></h4>

  <p>Currently, the <code id="microdata-and-other-namespaces:attr-itemscope"><a href="#attr-itemscope">itemscope</a></code>, <code id="microdata-and-other-namespaces:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code>, and other microdata attributes are only defined for
  <a href="#html-elements" id="microdata-and-other-namespaces:html-elements">HTML elements</a>. This means that attributes with the literal names "<code>itemscope</code>", "<code>itemprop</code>", etc, do not cause microdata
  processing to occur on elements in other namespaces, such as SVG.</p>

  <div class="example">

   <p>Thus, in the following example there is only one item, not
   two.</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemscope</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- this is an item (with no properties and no type) --&gt;</c->
<c- p="">&lt;</c-><c- f="">svg</c-> <c- e="">itemscope</c-><c- p="">&gt;&lt;/</c-><c- f="">svg</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- this is not, it's just an </c-><a id="microdata-and-other-namespaces:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg"><c- c="">SVG </c-><code><c- c="">svg</c-></code></a><c- c=""> element with an invalid unknown attribute --&gt;</c-></code></pre>

  </div>


  <h3 id="mdvocabs"><span class="secno">5.3</span> Sample microdata vocabularies<a href="#mdvocabs" class="self-link"></a></h3>

  <p>The vocabularies in this section are primarily intended to demonstrate how a vocabulary is
  specified, though they are also usable in their own right.</p>


  <h4 id="vcard"><span class="secno">5.3.1</span> vCard<a href="#vcard" class="self-link"></a></h4>

  <p>An item with the <a href="#item-types" id="vcard:item-types">item type</a> <dfn id="md-vcard"><code>http://microformats.org/profile/hcard</code></dfn> represents a person's or
  organization's contact information.</p>

  <p>This vocabulary does not <a href="#support-global-identifiers-for-items" id="vcard:support-global-identifiers-for-items">support global identifiers for items</a>.</p>

  <p>The following are the type's <a href="#defined-property-name" id="vcard:defined-property-name">defined property
  names</a>. They are based on the vocabulary defined in <cite>vCard Format Specification</cite>
  (<cite>vCard</cite>) and its extensions, where more information on how to interpret the values can
  be found. <a href="#refsRFC6350">[RFC6350]</a></p>

  <dl><dt><dfn id="md-vcard-kind"><code>kind</code></dfn></dt><dd>
    <p>Describes what kind of contact the item represents.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value">value</a> must be text that is <a id="vcard:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical
    to</a> one of the <a href="#kind-strings" id="vcard:kind-strings">kind strings</a>.</p>

    <p>A single property with the name <code id="vcard:md-vcard-kind"><a href="#md-vcard-kind">kind</a></code> may be present within
    each <a href="#concept-item" id="vcard:concept-item">item</a> with the type <code id="vcard:md-vcard"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-fn"><code>fn</code></dfn></dt><dd>
    <p>Gives the formatted text corresponding to the name of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-2">value</a> must be text.</p>

    <p>Exactly one property with the name <code id="vcard:md-vcard-fn"><a href="#md-vcard-fn">fn</a></code> must be present within
    each <a href="#concept-item" id="vcard:concept-item-2">item</a> with the type <code id="vcard:md-vcard-2"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-n"><code>n</code></dfn></dt><dd>
    <p>Gives the structured name of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-3">value</a> must be an <a href="#concept-item" id="vcard:concept-item-3">item</a> with zero or more of each of the <code id="vcard:md-vcard-n-family-name"><a href="#md-vcard-n-family-name">family-name</a></code>, <code id="vcard:md-vcard-n-given-name"><a href="#md-vcard-n-given-name">given-name</a></code>, <code id="vcard:md-vcard-n-additional-name"><a href="#md-vcard-n-additional-name">additional-name</a></code>, <code id="vcard:md-vcard-n-honorific-prefix"><a href="#md-vcard-n-honorific-prefix">honorific-prefix</a></code>, and <code id="vcard:md-vcard-n-honorific-suffix"><a href="#md-vcard-n-honorific-suffix">honorific-suffix</a></code> properties.</p>

    <p>Exactly one property with the name <code id="vcard:md-vcard-n"><a href="#md-vcard-n">n</a></code> must be present within
    each <a href="#concept-item" id="vcard:concept-item-4">item</a> with the type <code id="vcard:md-vcard-3"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-n-family-name"><code>family-name</code></dfn> (inside <code id="vcard:md-vcard-n-2"><a href="#md-vcard-n">n</a></code>)</dt><dd>
    <p>Gives the family name of the person, or the full name of the organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-4">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-n-family-name-2"><a href="#md-vcard-n-family-name">family-name</a></code> may be present within the <a href="#concept-item" id="vcard:concept-item-5">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-5">value</a> of the <code id="vcard:md-vcard-n-3"><a href="#md-vcard-n">n</a></code> property of
    an <a href="#concept-item" id="vcard:concept-item-6">item</a> with the type <code id="vcard:md-vcard-4"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-n-given-name"><code>given-name</code></dfn> (inside <code id="vcard:md-vcard-n-4"><a href="#md-vcard-n">n</a></code>)</dt><dd>
    <p>Gives the given-name of the person.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-6">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-n-given-name-2"><a href="#md-vcard-n-given-name">given-name</a></code>
    may be present within the <a href="#concept-item" id="vcard:concept-item-7">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-7">value</a> of the <code id="vcard:md-vcard-n-5"><a href="#md-vcard-n">n</a></code> property of
    an <a href="#concept-item" id="vcard:concept-item-8">item</a> with the type <code id="vcard:md-vcard-5"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-n-additional-name"><code>additional-name</code></dfn> (inside <code id="vcard:md-vcard-n-6"><a href="#md-vcard-n">n</a></code>)</dt><dd>
    <p>Gives the any additional names of the person.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-8">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-n-additional-name-2"><a href="#md-vcard-n-additional-name">additional-name</a></code> may be present within the <a href="#concept-item" id="vcard:concept-item-9">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-9">value</a> of the <code id="vcard:md-vcard-n-7"><a href="#md-vcard-n">n</a></code> property of
    an <a href="#concept-item" id="vcard:concept-item-10">item</a> with the type <code id="vcard:md-vcard-6"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-n-honorific-prefix"><code>honorific-prefix</code></dfn> (inside <code id="vcard:md-vcard-n-8"><a href="#md-vcard-n">n</a></code>)</dt><dd>
    <p>Gives the honorific prefix of the person.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-10">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-n-honorific-prefix-2"><a href="#md-vcard-n-honorific-prefix">honorific-prefix</a></code> may be present within the <a href="#concept-item" id="vcard:concept-item-11">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-11">value</a> of the <code id="vcard:md-vcard-n-9"><a href="#md-vcard-n">n</a></code> property of
    an <a href="#concept-item" id="vcard:concept-item-12">item</a> with the type <code id="vcard:md-vcard-7"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-n-honorific-suffix"><code>honorific-suffix</code></dfn> (inside <code id="vcard:md-vcard-n-10"><a href="#md-vcard-n">n</a></code>)</dt><dd>
    <p>Gives the honorific suffix of the person.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-12">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-n-honorific-suffix-2"><a href="#md-vcard-n-honorific-suffix">honorific-suffix</a></code> may be present within the <a href="#concept-item" id="vcard:concept-item-13">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-13">value</a> of the <code id="vcard:md-vcard-n-11"><a href="#md-vcard-n">n</a></code> property of
    an <a href="#concept-item" id="vcard:concept-item-14">item</a> with the type <code id="vcard:md-vcard-8"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-nickname"><code>nickname</code></dfn></dt><dd>
    <p>Gives the nickname of the person or organization.</p>

    
    <p class="note">The nickname is the descriptive name given instead of or in addition to the one
    belonging to a person, place, or thing. It can also be used to specify a familiar form of a
    proper name specified by the <code id="vcard:md-vcard-fn-2"><a href="#md-vcard-fn">fn</a></code> or <code id="vcard:md-vcard-n-12"><a href="#md-vcard-n">n</a></code> properties.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-14">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-nickname"><a href="#md-vcard-nickname">nickname</a></code> may be
    present within each <a href="#concept-item" id="vcard:concept-item-15">item</a> with the type <code id="vcard:md-vcard-9"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-photo"><code>photo</code></dfn></dt><dd>
    <p>Gives a photograph of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-15">value</a> must be an <a id="vcard:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-photo"><a href="#md-vcard-photo">photo</a></code> may be
    present within each <a href="#concept-item" id="vcard:concept-item-16">item</a> with the type <code id="vcard:md-vcard-10"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-bday"><code>bday</code></dfn></dt><dd>
    <p>Gives the birth date of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-16">value</a> must be a <a href="#valid-date-string" id="vcard:valid-date-string">valid date
    string</a>.</p>

    <p>A single property with the name <code id="vcard:md-vcard-bday"><a href="#md-vcard-bday">bday</a></code> may be present within
    each <a href="#concept-item" id="vcard:concept-item-17">item</a> with the type <code id="vcard:md-vcard-11"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-anniversary"><code>anniversary</code></dfn></dt><dd>
    <p>Gives the birth date of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-17">value</a> must be a <a href="#valid-date-string" id="vcard:valid-date-string-2">valid date
    string</a>.</p>

    <p>A single property with the name <code id="vcard:md-vcard-anniversary"><a href="#md-vcard-anniversary">anniversary</a></code> may be
    present within each <a href="#concept-item" id="vcard:concept-item-18">item</a> with the type <code id="vcard:md-vcard-12"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-sex"><code>sex</code></dfn></dt><dd>
    <p>Gives the biological sex of the person.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-18">value</a> must be one of
    <code>F</code>, meaning "female",
    <code>M</code>, meaning "male",
    <code>N</code>, meaning "none or not applicable",
    <code>O</code>, meaning "other", or
    <code>U</code>, meaning "unknown".</p>

    <p>A single property with the name <code id="vcard:md-vcard-sex"><a href="#md-vcard-sex">sex</a></code> may be present within
    each <a href="#concept-item" id="vcard:concept-item-19">item</a> with the type <code id="vcard:md-vcard-13"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-gender-identity"><code>gender-identity</code></dfn></dt><dd>
    <p>Gives the gender identity of the person.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-19">value</a> must be text.</p>

    <p>A single property with the name <code id="vcard:md-vcard-gender-identity"><a href="#md-vcard-gender-identity">gender-identity</a></code>
    may be present within each <a href="#concept-item" id="vcard:concept-item-20">item</a> with the type <code id="vcard:md-vcard-14"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-adr"><code>adr</code></dfn></dt><dd>
    <p>Gives the delivery address of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-20">value</a> must be an <a href="#concept-item" id="vcard:concept-item-21">item</a> with zero or more <code id="vcard:md-vcard-adr-type"><a href="#md-vcard-adr-type">type</a></code>,
    <code id="vcard:md-vcard-adr-post-office-box"><a href="#md-vcard-adr-post-office-box">post-office-box</a></code>, <code id="vcard:md-vcard-adr-extended-address"><a href="#md-vcard-adr-extended-address">extended-address</a></code>, and <code id="vcard:md-vcard-adr-street-address"><a href="#md-vcard-adr-street-address">street-address</a></code> properties, and optionally a <code id="vcard:md-vcard-adr-locality"><a href="#md-vcard-adr-locality">locality</a></code> property, optionally a <code id="vcard:md-vcard-adr-region"><a href="#md-vcard-adr-region">region</a></code> property, optionally a <code id="vcard:md-vcard-adr-postal-code"><a href="#md-vcard-adr-postal-code">postal-code</a></code> property, and optionally a <code id="vcard:md-vcard-adr-country-name"><a href="#md-vcard-adr-country-name">country-name</a></code> property.</p>

    <p>If no <code id="vcard:md-vcard-adr-type-2"><a href="#md-vcard-adr-type">type</a></code> properties are present within an <a href="#concept-item" id="vcard:concept-item-22">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-21">value</a> of an <code id="vcard:md-vcard-adr"><a href="#md-vcard-adr">adr</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-23">item</a> with the type <code id="vcard:md-vcard-15"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>, then the <a href="#address-type-strings" id="vcard:address-type-strings">address type string</a> <code id="vcard:md-vcard-type-adr-work"><a href="#md-vcard-type-adr-work">work</a></code> is
    implied.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-adr-2"><a href="#md-vcard-adr">adr</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-24">item</a> with the type <code id="vcard:md-vcard-16"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-adr-type"><code>type</code></dfn> (inside <code id="vcard:md-vcard-adr-3"><a href="#md-vcard-adr">adr</a></code>)</dt><dd>
    <p>Gives the type of delivery address.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-22">value</a> must be text that is <a id="vcard:identical-to-2" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical
    to</a> one of the <a href="#address-type-strings" id="vcard:address-type-strings-2">address type strings</a>.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-adr-type-3"><a href="#md-vcard-adr-type">type</a></code> may be
    present within the <a href="#concept-item" id="vcard:concept-item-25">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-23">value</a> of an <code id="vcard:md-vcard-adr-4"><a href="#md-vcard-adr">adr</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-26">item</a> with the type <code id="vcard:md-vcard-17"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>, but within each such <code id="vcard:md-vcard-adr-5"><a href="#md-vcard-adr">adr</a></code> property <a href="#concept-item" id="vcard:concept-item-27">item</a> there must only
    be one <code id="vcard:md-vcard-adr-type-4"><a href="#md-vcard-adr-type">type</a></code> property per distinct value.</p>
   </dd><dt><dfn id="md-vcard-adr-post-office-box"><code>post-office-box</code></dfn> (inside <code id="vcard:md-vcard-adr-6"><a href="#md-vcard-adr">adr</a></code>)</dt><dd>
    <p>Gives the post office box component of the delivery address of the person or
    organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-24">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-adr-post-office-box-2"><a href="#md-vcard-adr-post-office-box">post-office-box</a></code> may be present within the <a href="#concept-item" id="vcard:concept-item-28">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-25">value</a> of an <code id="vcard:md-vcard-adr-7"><a href="#md-vcard-adr">adr</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-29">item</a> with the type <code id="vcard:md-vcard-18"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>

    <p class="note"><cite>vCard</cite> urges authors not to use this field.</p>
   </dd><dt><dfn id="md-vcard-adr-extended-address"><code>extended-address</code></dfn> (inside <code id="vcard:md-vcard-adr-8"><a href="#md-vcard-adr">adr</a></code>)</dt><dd>
    <p>Gives an additional component of the delivery address of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-26">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-adr-extended-address-2"><a href="#md-vcard-adr-extended-address">extended-address</a></code> may be present within the <a href="#concept-item" id="vcard:concept-item-30">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-27">value</a> of an <code id="vcard:md-vcard-adr-9"><a href="#md-vcard-adr">adr</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-31">item</a> with the type <code id="vcard:md-vcard-19"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>

    <p class="note"><cite>vCard</cite> urges authors not to use this field.</p>
   </dd><dt><dfn id="md-vcard-adr-street-address"><code>street-address</code></dfn> (inside <code id="vcard:md-vcard-adr-10"><a href="#md-vcard-adr">adr</a></code>)</dt><dd>
    <p>Gives the street address component of the delivery address of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-28">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-adr-street-address-2"><a href="#md-vcard-adr-street-address">street-address</a></code> may be present within the <a href="#concept-item" id="vcard:concept-item-32">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-29">value</a> of an <code id="vcard:md-vcard-adr-11"><a href="#md-vcard-adr">adr</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-33">item</a> with the type <code id="vcard:md-vcard-20"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-adr-locality"><code>locality</code></dfn> (inside <code id="vcard:md-vcard-adr-12"><a href="#md-vcard-adr">adr</a></code>)</dt><dd>
    <p>Gives the locality component (e.g. city) of the delivery address of the person or
    organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-30">value</a> must be text.</p>

    <p>A single property with the name <code id="vcard:md-vcard-adr-locality-2"><a href="#md-vcard-adr-locality">locality</a></code> may be
    present within the <a href="#concept-item" id="vcard:concept-item-34">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-31">value</a> of an <code id="vcard:md-vcard-adr-13"><a href="#md-vcard-adr">adr</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-35">item</a> with the type <code id="vcard:md-vcard-21"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-adr-region"><code>region</code></dfn> (inside <code id="vcard:md-vcard-adr-14"><a href="#md-vcard-adr">adr</a></code>)</dt><dd>
    <p>Gives the region component (e.g. state or province) of the delivery address of the person or
    organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-32">value</a> must be text.</p>

    <p>A single property with the name <code id="vcard:md-vcard-adr-region-2"><a href="#md-vcard-adr-region">region</a></code> may be
    present within the <a href="#concept-item" id="vcard:concept-item-36">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-33">value</a> of an <code id="vcard:md-vcard-adr-15"><a href="#md-vcard-adr">adr</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-37">item</a> with the type <code id="vcard:md-vcard-22"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-adr-postal-code"><code>postal-code</code></dfn> (inside <code id="vcard:md-vcard-adr-16"><a href="#md-vcard-adr">adr</a></code>)</dt><dd>
    <p>Gives the postal code component of the delivery address of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-34">value</a> must be text.</p>

    <p>A single property with the name <code id="vcard:md-vcard-adr-postal-code-2"><a href="#md-vcard-adr-postal-code">postal-code</a></code> may
    be present within the <a href="#concept-item" id="vcard:concept-item-38">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-35">value</a> of an <code id="vcard:md-vcard-adr-17"><a href="#md-vcard-adr">adr</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-39">item</a> with the type <code id="vcard:md-vcard-23"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-adr-country-name"><code>country-name</code></dfn> (inside <code id="vcard:md-vcard-adr-18"><a href="#md-vcard-adr">adr</a></code>)</dt><dd>
    <p>Gives the country name component of the delivery address of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-36">value</a> must be text.</p>

    <p>A single property with the name <code id="vcard:md-vcard-adr-country-name-2"><a href="#md-vcard-adr-country-name">country-name</a></code>
    may be present within the <a href="#concept-item" id="vcard:concept-item-40">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-37">value</a> of an <code id="vcard:md-vcard-adr-19"><a href="#md-vcard-adr">adr</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-41">item</a> with the type <code id="vcard:md-vcard-24"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-tel"><code>tel</code></dfn></dt><dd>
    <p>Gives the telephone number of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-38">value</a> must be either text that can be
    interpreted as a telephone number as defined in the CCITT specifications E.163 and X.121, or an
    <a href="#concept-item" id="vcard:concept-item-42">item</a> with zero or more <code id="vcard:md-vcard-tel-type"><a href="#md-vcard-tel-type">type</a></code> properties and exactly one <code id="vcard:md-vcard-tel-value"><a href="#md-vcard-tel-value">value</a></code> property. <a href="#refsE163">[E163]</a> <a href="#refsX121">[X121]</a></p>

    <p>If no <code id="vcard:md-vcard-tel-type-2"><a href="#md-vcard-tel-type">type</a></code> properties are present within an <a href="#concept-item" id="vcard:concept-item-43">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-39">value</a> of a <code id="vcard:md-vcard-tel"><a href="#md-vcard-tel">tel</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-44">item</a> with the type <code id="vcard:md-vcard-25"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>, or if the <a href="#concept-property-value" id="vcard:concept-property-value-40">value</a> of such a <code id="vcard:md-vcard-tel-2"><a href="#md-vcard-tel">tel</a></code>
    property is text, then the <a href="#telephone-type-strings" id="vcard:telephone-type-strings">telephone type string</a>
    <code id="vcard:md-vcard-type-tel-voice"><a href="#md-vcard-type-tel-voice">voice</a></code> is implied.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-tel-3"><a href="#md-vcard-tel">tel</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-45">item</a> with the type <code id="vcard:md-vcard-26"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-tel-type"><code>type</code></dfn> (inside <code id="vcard:md-vcard-tel-4"><a href="#md-vcard-tel">tel</a></code>)</dt><dd>
    <p>Gives the type of telephone number.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-41">value</a> must be text that is <a id="vcard:identical-to-3" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical
    to</a> one of the <a href="#telephone-type-strings" id="vcard:telephone-type-strings-2">telephone type strings</a>.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-tel-type-3"><a href="#md-vcard-tel-type">type</a></code> may be
    present within the <a href="#concept-item" id="vcard:concept-item-46">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-42">value</a> of a <code id="vcard:md-vcard-tel-5"><a href="#md-vcard-tel">tel</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-47">item</a> with the type <code id="vcard:md-vcard-27"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>, but within each such <code id="vcard:md-vcard-tel-6"><a href="#md-vcard-tel">tel</a></code> property <a href="#concept-item" id="vcard:concept-item-48">item</a> there must only
    be one <code id="vcard:md-vcard-tel-type-4"><a href="#md-vcard-tel-type">type</a></code> property per distinct value.</p>
   </dd><dt><dfn id="md-vcard-tel-value"><code>value</code></dfn> (inside <code id="vcard:md-vcard-tel-7"><a href="#md-vcard-tel">tel</a></code>)</dt><dd>
    <p>Gives the actual telephone number of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-43">value</a> must be text that can be interpreted
    as a telephone number as defined in the CCITT specifications E.163 and X.121. <a href="#refsE163">[E163]</a>
    <a href="#refsX121">[X121]</a></p>

    <p>Exactly one property with the name <code id="vcard:md-vcard-tel-value-2"><a href="#md-vcard-tel-value">value</a></code> must be
    present within the <a href="#concept-item" id="vcard:concept-item-49">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-44">value</a> of a <code id="vcard:md-vcard-tel-8"><a href="#md-vcard-tel">tel</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-50">item</a> with the type <code id="vcard:md-vcard-28"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-email"><code>email</code></dfn></dt><dd>
    <p>Gives the email address of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-45">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-email"><a href="#md-vcard-email">email</a></code> may be
    present within each <a href="#concept-item" id="vcard:concept-item-51">item</a> with the type <code id="vcard:md-vcard-29"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-impp"><code>impp</code></dfn></dt><dd>
    <p>Gives a <a id="vcard:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> for instant messaging and presence protocol communications with the
    person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-46">value</a> must be an <a id="vcard:absolute-url-2" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-impp"><a href="#md-vcard-impp">impp</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-52">item</a> with the type <code id="vcard:md-vcard-30"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-lang"><code>lang</code></dfn></dt><dd>
    <p>Gives a language understood by the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-47">value</a> must be a valid BCP 47 language tag.
    <a href="#refsBCP47">[BCP47]</a></p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-lang"><a href="#md-vcard-lang">lang</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-53">item</a> with the type <code id="vcard:md-vcard-31"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-tz"><code>tz</code></dfn></dt><dd>
    <p>Gives the time zone of the person or organization.</p>

    <div data-algorithm="">
    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-48">value</a> must be text and must match the
    following syntax:</p>

    <ol><li>Either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character (-).</li><li>A <a href="#valid-non-negative-integer" id="vcard:valid-non-negative-integer">valid non-negative integer</a> that is exactly two digits long and that
     represents a number in the range 00..23.</li><li>A U+003A COLON character (:).</li><li>A <a href="#valid-non-negative-integer" id="vcard:valid-non-negative-integer-2">valid non-negative integer</a> that is exactly two digits long and that
     represents a number in the range 00..59.</li></ol>
    </div>

    <p>Any number of properties with the name <code id="vcard:md-vcard-tz"><a href="#md-vcard-tz">tz</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-54">item</a> with the type <code id="vcard:md-vcard-32"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-geo"><code>geo</code></dfn></dt><dd>
    <p>Gives the geographical position of the person or organization.</p>

    <div data-algorithm="">
    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-49">value</a> must be text and must match the
    following syntax:</p>

    <ol><li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character
     (-).</li><li>One or more <a id="vcard:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>.</li><li>Optionally*, a U+002E FULL STOP character (.) followed by one or more <a id="vcard:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
     digits</a>.</li><li>A U+003B SEMICOLON character (;).</li><li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character
     (-).</li><li>One or more <a id="vcard:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>.</li><li>Optionally*, a U+002E FULL STOP character (.) followed by one or more <a id="vcard:ascii-digits-4" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
     digits</a>.</li></ol>
    </div>

    <p>The optional components marked with an asterisk (*) should be included, and should have six
    digits each.</p>

    
    <p class="note">The value specifies latitude and longitude, in that order (i.e., "LAT LON"
    ordering), in decimal degrees. The longitude represents the location east and west of the prime
    meridian as a positive or negative real number, respectively. The latitude represents the
    location north and south of the equator as a positive or negative real number, respectively.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-geo"><a href="#md-vcard-geo">geo</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-55">item</a> with the type <code id="vcard:md-vcard-33"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-title"><code>title</code></dfn></dt><dd>
    <p>Gives the job title, functional position or function of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-50">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-title"><a href="#md-vcard-title">title</a></code> may be
    present within each <a href="#concept-item" id="vcard:concept-item-56">item</a> with the type <code id="vcard:md-vcard-34"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-role"><code>role</code></dfn></dt><dd>
    <p>Gives the role, occupation, or business category of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-51">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-role"><a href="#md-vcard-role">role</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-57">item</a> with the type <code id="vcard:md-vcard-35"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-logo"><code>logo</code></dfn></dt><dd>
    <p>Gives the logo of the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-52">value</a> must be an <a id="vcard:absolute-url-3" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-logo"><a href="#md-vcard-logo">logo</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-58">item</a> with the type <code id="vcard:md-vcard-36"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-agent"><code>agent</code></dfn></dt><dd>
    <p>Gives the contact information of another person who will act on behalf of the person or
    organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-53">value</a> must be either an <a href="#concept-item" id="vcard:concept-item-59">item</a> with the type <code id="vcard:md-vcard-37"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>, or an <a id="vcard:absolute-url-4" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a>,
    or text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-agent"><a href="#md-vcard-agent">agent</a></code> may be
    present within each <a href="#concept-item" id="vcard:concept-item-60">item</a> with the type <code id="vcard:md-vcard-38"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-org"><code>org</code></dfn></dt><dd>
    <p>Gives the name and units of the organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-54">value</a> must be either text or an <a href="#concept-item" id="vcard:concept-item-61">item</a> with one <code id="vcard:md-vcard-org-organization-name"><a href="#md-vcard-org-organization-name">organization-name</a></code> property and zero or more <code id="vcard:md-vcard-org-organization-unit"><a href="#md-vcard-org-organization-unit">organization-unit</a></code> properties.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-org"><a href="#md-vcard-org">org</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-62">item</a> with the type <code id="vcard:md-vcard-39"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-org-organization-name"><code>organization-name</code></dfn> (inside <code id="vcard:md-vcard-org-2"><a href="#md-vcard-org">org</a></code>)</dt><dd>
    <p>Gives the name of the organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-55">value</a> must be text.</p>

    <p>Exactly one property with the name <code id="vcard:md-vcard-org-organization-name-2"><a href="#md-vcard-org-organization-name">organization-name</a></code> must be present within the <a href="#concept-item" id="vcard:concept-item-63">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-56">value</a> of an <code id="vcard:md-vcard-org-3"><a href="#md-vcard-org">org</a></code> property
    of an <a href="#concept-item" id="vcard:concept-item-64">item</a> with the type <code id="vcard:md-vcard-40"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-org-organization-unit"><code>organization-unit</code></dfn> (inside <code id="vcard:md-vcard-org-4"><a href="#md-vcard-org">org</a></code>)</dt><dd>
    <p>Gives the name of the organization unit.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-57">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-org-organization-unit-2"><a href="#md-vcard-org-organization-unit">organization-unit</a></code> may be present within the <a href="#concept-item" id="vcard:concept-item-65">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-58">value</a> of the <code id="vcard:md-vcard-org-5"><a href="#md-vcard-org">org</a></code>
    property of an <a href="#concept-item" id="vcard:concept-item-66">item</a> with the type <code id="vcard:md-vcard-41"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-member"><code>member</code></dfn></dt><dd>
    <p>Gives a <a id="vcard:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> that represents a member of the group.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-59">value</a> must be an <a id="vcard:absolute-url-5" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-member"><a href="#md-vcard-member">member</a></code> may be
    present within each <a href="#concept-item" id="vcard:concept-item-67">item</a> with the type <code id="vcard:md-vcard-42"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code> if the <a href="#concept-item" id="vcard:concept-item-68">item</a> also has a property with the name <code id="vcard:md-vcard-kind-2"><a href="#md-vcard-kind">kind</a></code> whose value is "<code id="vcard:md-vcard-kind-group"><a href="#md-vcard-kind-group">group</a></code>".</p>
   </dd><dt><dfn id="md-vcard-related"><code>related</code></dfn></dt><dd>
    <p>Gives a relationship to another entity.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-60">value</a> must be an <a href="#concept-item" id="vcard:concept-item-69">item</a> with one <code id="vcard:md-vcard-related-url"><a href="#md-vcard-related-url">url</a></code>
    property and one <code id="vcard:md-vcard-related-rel"><a href="#md-vcard-related-rel">rel</a></code> properties.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-related"><a href="#md-vcard-related">related</a></code> may be
    present within each <a href="#concept-item" id="vcard:concept-item-70">item</a> with the type <code id="vcard:md-vcard-43"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-related-url"><code>url</code></dfn> (inside <code id="vcard:md-vcard-related-2"><a href="#md-vcard-related">related</a></code>)</dt><dd>
    <p>Gives the <a id="vcard:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> for the related entity.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-61">value</a> must be an <a id="vcard:absolute-url-6" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Exactly one property with the name <code id="vcard:md-vcard-related-url-2"><a href="#md-vcard-related-url">url</a></code> must be
    present within the <a href="#concept-item" id="vcard:concept-item-71">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-62">value</a> of a <code id="vcard:md-vcard-related-3"><a href="#md-vcard-related">related</a></code>
    property of an <a href="#concept-item" id="vcard:concept-item-72">item</a> with the type <code id="vcard:md-vcard-44"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-related-rel"><code>rel</code></dfn> (inside <code id="vcard:md-vcard-related-4"><a href="#md-vcard-related">related</a></code>)</dt><dd>
    <p>Gives the relationship between the entity and the related entity.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-63">value</a> must be text that is <a id="vcard:identical-to-4" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical
    to</a> one of the <a href="#relationship-strings" id="vcard:relationship-strings">relationship strings</a>.</p>

    <p>Exactly one property with the name <code id="vcard:md-vcard-related-rel-2"><a href="#md-vcard-related-rel">rel</a></code> must be
    present within the <a href="#concept-item" id="vcard:concept-item-73">item</a> that forms the <a href="#concept-property-value" id="vcard:concept-property-value-64">value</a> of a <code id="vcard:md-vcard-related-5"><a href="#md-vcard-related">related</a></code>
    property of an <a href="#concept-item" id="vcard:concept-item-74">item</a> with the type <code id="vcard:md-vcard-45"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-categories"><code>categories</code></dfn></dt><dd>
    <p>Gives the name of a category or tag that the person or organization could be classified
    as.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-65">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-categories"><a href="#md-vcard-categories">categories</a></code>
    may be present within each <a href="#concept-item" id="vcard:concept-item-75">item</a> with the type <code id="vcard:md-vcard-46"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-note"><code>note</code></dfn></dt><dd>
    <p>Gives supplemental information or a comment about the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-66">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-note"><a href="#md-vcard-note">note</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-76">item</a> with the type <code id="vcard:md-vcard-47"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-rev"><code>rev</code></dfn></dt><dd>
    <p>Gives the revision date and time of the contact information.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-67">value</a> must be text that is a <a href="#valid-global-date-and-time-string" id="vcard:valid-global-date-and-time-string">valid
    global date and time string</a>.</p>

    
    <p class="note">The value distinguishes the current revision of the information for other
    renditions of the information.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-rev"><a href="#md-vcard-rev">rev</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-77">item</a> with the type <code id="vcard:md-vcard-48"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-sound"><code>sound</code></dfn></dt><dd>
    <p>Gives a sound file relating to the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-68">value</a> must be an <a id="vcard:absolute-url-7" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-sound"><a href="#md-vcard-sound">sound</a></code> may be
    present within each <a href="#concept-item" id="vcard:concept-item-78">item</a> with the type <code id="vcard:md-vcard-49"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-uid"><code>uid</code></dfn></dt><dd>
    <p>Gives a globally unique identifier corresponding to the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-69">value</a> must be text.</p>

    <p>A single property with the name <code id="vcard:md-vcard-uid"><a href="#md-vcard-uid">uid</a></code> may be present within
    each <a href="#concept-item" id="vcard:concept-item-79">item</a> with the type <code id="vcard:md-vcard-50"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd><dt><dfn id="md-vcard-url"><code>url</code></dfn></dt><dd>
    <p>Gives a <a id="vcard:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> relating to the person or organization.</p>

    <p>The <a href="#concept-property-value" id="vcard:concept-property-value-70">value</a> must be an <a id="vcard:absolute-url-8" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Any number of properties with the name <code id="vcard:md-vcard-url"><a href="#md-vcard-url">url</a></code> may be present
    within each <a href="#concept-item" id="vcard:concept-item-80">item</a> with the type <code id="vcard:md-vcard-51"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p>
   </dd></dl>

  <p>The <dfn id="kind-strings">kind strings</dfn> are:</p>

  <dl><dt><dfn id="md-vcard-kind-individual"><code>individual</code></dfn></dt><dd>
    <p>Indicates a single entity (e.g. a person).</p>
   </dd><dt><dfn id="md-vcard-kind-group"><code>group</code></dfn></dt><dd>
    <p>Indicates multiple entities (e.g. a mailing list).</p>
   </dd><dt><dfn id="md-vcard-kind-org"><code>org</code></dfn></dt><dd>
    <p>Indicates a single entity that is not a person (e.g. a company).</p>
   </dd><dt><dfn id="md-vcard-kind-location"><code>location</code></dfn></dt><dd>
    <p>Indicates a geographical place (e.g. an office building).</p>
   </dd></dl>

  <p>The <dfn id="address-type-strings">address type strings</dfn> are:</p>

  <dl><dt><dfn id="md-vcard-type-adr-home"><code>home</code></dfn></dt><dd>
    <p>Indicates a delivery address for a residence.</p>
   </dd><dt><dfn id="md-vcard-type-adr-work"><code>work</code></dfn></dt><dd>
    <p>Indicates a delivery address for a place of work.</p>
   </dd></dl>

  <p>The <dfn id="telephone-type-strings">telephone type strings</dfn> are:</p>

  <dl><dt><dfn id="md-vcard-type-tel-home"><code>home</code></dfn></dt><dd>
    <p>Indicates a residential number.</p>
   </dd><dt><dfn id="md-vcard-type-tel-work"><code>work</code></dfn></dt><dd>
    <p>Indicates a telephone number for a place of work.</p>
   </dd><dt><dfn id="md-vcard-type-tel-text"><code>text</code></dfn></dt><dd>
    <p>Indicates that the telephone number supports text messages (SMS).</p>
   </dd><dt><dfn id="md-vcard-type-tel-voice"><code>voice</code></dfn></dt><dd>
    <p>Indicates a voice telephone number.</p>
   </dd><dt><dfn id="md-vcard-type-tel-fax"><code>fax</code></dfn></dt><dd>
    <p>Indicates a facsimile telephone number.</p>
   </dd><dt><dfn id="md-vcard-type-tel-cell"><code>cell</code></dfn></dt><dd>
    <p>Indicates a cellular telephone number.</p>
   </dd><dt><dfn id="md-vcard-type-tel-video"><code>video</code></dfn></dt><dd>
    <p>Indicates a video conferencing telephone number.</p>
   </dd><dt><dfn id="md-vcard-type-tel-pager"><code>pager</code></dfn></dt><dd>
    <p>Indicates a paging device telephone number.</p>
   </dd><dt><dfn id="md-vcard-type-tel-textphone"><code>textphone</code></dfn></dt><dd>
    <p>Indicates a telecommunication device for people with hearing or speech difficulties.</p>
   </dd></dl>

  <p>The <dfn id="relationship-strings">relationship strings</dfn> are:</p>

  <dl><dt><dfn id="md-vcard-rel-emergency"><code>emergency</code></dfn></dt><dd>
    <p>An emergency contact.</p>
   </dd><dt><dfn id="md-vcard-rel-agent"><code>agent</code></dfn></dt><dd>
    <p>Another entity that acts on behalf of this entity.</p>
   </dd><dt><dfn id="md-vcard-rel-contact">contact</dfn></dt><dt><dfn id="md-vcard-rel-acquaintance">acquaintance</dfn></dt><dt><dfn id="md-vcard-rel-friend">friend</dfn></dt><dt><dfn id="md-vcard-rel-met">met</dfn></dt><dt><dfn id="md-vcard-rel-co-worker">worker</dfn></dt><dt><dfn id="md-vcard-rel-colleague">colleague</dfn></dt><dt><dfn id="md-vcard-rel-co-resident">resident</dfn></dt><dt><dfn id="md-vcard-rel-neighbor">neighbor</dfn></dt><dt><dfn id="md-vcard-rel-child">child</dfn></dt><dt><dfn id="md-vcard-rel-parent">parent</dfn></dt><dt><dfn id="md-vcard-rel-sibling">sibling</dfn></dt><dt><dfn id="md-vcard-rel-spouse">spouse</dfn></dt><dt><dfn id="md-vcard-rel-kin">kin</dfn></dt><dt><dfn id="md-vcard-rel-muse">muse</dfn></dt><dt><dfn id="md-vcard-rel-crush">crush</dfn></dt><dt><dfn id="md-vcard-rel-date">date</dfn></dt><dt><dfn id="md-vcard-rel-sweetheart">sweetheart</dfn></dt><dt><dfn id="md-vcard-rel-me">me</dfn></dt><dd>
    <p>Has the meaning defined in XFN. <a href="#refsXFN">[XFN]</a></p>
   </dd></dl>


  <h5 id="conversion-to-vcard"><span class="secno">5.3.1.1</span> Conversion to vCard<a href="#conversion-to-vcard" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Given a list of nodes <var>nodes</var> in a <code id="conversion-to-vcard:document"><a href="#document">Document</a></code>, a user agent must
  run the following algorithm to <dfn id="extracting-a-vcard">extract any vCard data represented
  by those nodes</dfn> (only the first vCard is returned):</p>

  <ol><li><p>If none of the nodes in <var>nodes</var> are <a href="#concept-item" id="conversion-to-vcard:concept-item">items</a> with the <a href="#item-types" id="conversion-to-vcard:item-types">item type</a> <code id="conversion-to-vcard:md-vcard"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>, then there is no vCard. Abort the
   algorithm, returning nothing.</p></li><li><p>Let <var>node</var> be the first node in <var>nodes</var> that is an
   <a href="#concept-item" id="conversion-to-vcard:concept-item-2">item</a> with the <a href="#item-types" id="conversion-to-vcard:item-types-2">item type</a> <code id="conversion-to-vcard:md-vcard-2"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>.</p></li><li><p>Let <var>output</var> be an empty string.</p></li><li><p><a href="#add-a-vcard-line" id="conversion-to-vcard:add-a-vcard-line">Add a vCard line</a> with the type "<code>BEGIN</code>" and the value
   "<code>VCARD</code>" to <var>output</var>.</p></li><li><p><a href="#add-a-vcard-line" id="conversion-to-vcard:add-a-vcard-line-2">Add a vCard line</a> with the type "<code>PROFILE</code>" and the value
   "<code>VCARD</code>" to <var>output</var>.</p></li><li><p><a href="#add-a-vcard-line" id="conversion-to-vcard:add-a-vcard-line-3">Add a vCard line</a> with the type "<code>VERSION</code>" and the value
   "<code>4.0</code>" to <var>output</var>.</p></li><li><p><a href="#add-a-vcard-line" id="conversion-to-vcard:add-a-vcard-line-4">Add a vCard line</a> with the type "<code>SOURCE</code>" and the result
   of <a href="#escaping-the-vcard-text-string" id="conversion-to-vcard:escaping-the-vcard-text-string">escaping the vCard text string</a> that is the document's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="conversion-to-vcard:the-document's-address" data-x-internal="the-document's-address">URL</a> as the value to <var>output</var>.</p></li><li><p>If <a href="#the-title-element-2" id="conversion-to-vcard:the-title-element-2">the <code>title</code> element</a> is not null, <a href="#add-a-vcard-line" id="conversion-to-vcard:add-a-vcard-line-5">add a vCard line</a>
   with the type "<code>NAME</code>" and with the result of <a href="#escaping-the-vcard-text-string" id="conversion-to-vcard:escaping-the-vcard-text-string-2">escaping the vCard text
   string</a> obtained from <a href="#the-title-element-2" id="conversion-to-vcard:the-title-element-2-2">the <code>title</code> element</a>'s <a id="conversion-to-vcard:descendant-text-content" href="https://dom.spec.whatwg.org/#concept-descendant-text-content" data-x-internal="descendant-text-content">descendant
   text content</a> as the value to <var>output</var>.</p></li><li><p>Let <var>sex</var> be the empty string.</p></li><li><p>Let <var>gender-identity</var> be the empty string.</p></li><li>
    <p>For each element <var>element</var> that is <a href="#the-properties-of-an-item" id="conversion-to-vcard:the-properties-of-an-item">a property of the item</a> <var>node</var>: for each name <var>name</var> in <var>element</var>'s <a href="#property-names" id="conversion-to-vcard:property-names">property names</a>, run the
    following substeps:</p>

    <ol><li><p>Let <var>parameters</var> be an empty set of name-value pairs.</p></li><li>
      <p>Run the appropriate set of substeps from the following list. The steps will set a variable
      <var>value</var>, which is used in the next step.</p>

      <dl><dt>If the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value">value</a> is an <a href="#concept-item" id="conversion-to-vcard:concept-item-3">item</a> <var>subitem</var> and <var>name</var> is
       <code id="conversion-to-vcard:md-vcard-n"><a href="#md-vcard-n">n</a></code></dt><dd>
        <ol><li><p>Let <var>value</var> be the empty string.</p></li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-n-family-name"><a href="#md-vcard-n-family-name">family-name</a></code> in <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-2">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-n-given-name"><a href="#md-vcard-n-given-name">given-name</a></code> in <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-3">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-n-additional-name"><a href="#md-vcard-n-additional-name">additional-name</a></code> in
         <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-4">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-n-honorific-prefix"><a href="#md-vcard-n-honorific-prefix">honorific-prefix</a></code>
         in <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-5">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-n-honorific-suffix"><a href="#md-vcard-n-honorific-suffix">honorific-suffix</a></code>
         in <var>subitem</var>.</p>
        </li></ol>
       </dd><dt>If the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-2">value</a> is an <a href="#concept-item" id="conversion-to-vcard:concept-item-4">item</a> <var>subitem</var> and <var>name</var> is
       <code id="conversion-to-vcard:md-vcard-adr"><a href="#md-vcard-adr">adr</a></code></dt><dd>
        <ol><li><p>Let <var>value</var> be the empty string.</p></li><li><p>Append to <var>value</var> the result of <a href="#collecting-vcard-subproperties" id="conversion-to-vcard:collecting-vcard-subproperties">collecting vCard
         subproperties</a> named <code id="conversion-to-vcard:md-vcard-adr-post-office-box"><a href="#md-vcard-adr-post-office-box">post-office-box</a></code> in <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-vcard-subproperties" id="conversion-to-vcard:collecting-vcard-subproperties-2">collecting vCard
         subproperties</a> named <code id="conversion-to-vcard:md-vcard-adr-extended-address"><a href="#md-vcard-adr-extended-address">extended-address</a></code> in <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-vcard-subproperties" id="conversion-to-vcard:collecting-vcard-subproperties-3">collecting vCard
         subproperties</a> named <code id="conversion-to-vcard:md-vcard-adr-street-address"><a href="#md-vcard-adr-street-address">street-address</a></code>
         in <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-6">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-adr-locality"><a href="#md-vcard-adr-locality">locality</a></code> in <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-7">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-adr-region"><a href="#md-vcard-adr-region">region</a></code> in <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-8">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-adr-postal-code"><a href="#md-vcard-adr-postal-code">postal-code</a></code> in <var>subitem</var>.</p>

         </li><li>Append a U+003B SEMICOLON character (;) to <var>value</var>.</li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-9">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-adr-country-name"><a href="#md-vcard-adr-country-name">country-name</a></code> in
         <var>subitem</var>.</p>

         </li><li><p>If there is a property named <code id="conversion-to-vcard:md-vcard-adr-type"><a href="#md-vcard-adr-type">type</a></code> in
         <var>subitem</var>, and the first such property has a <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-3">value</a> that is not an <a href="#concept-item" id="conversion-to-vcard:concept-item-5">item</a> and whose value consists only of <a href="https://infra.spec.whatwg.org/#ascii-alphanumeric" id="conversion-to-vcard:alphanumeric-ascii-characters" data-x-internal="alphanumeric-ascii-characters">ASCII alphanumerics</a>, then add a parameter named "<code>TYPE</code>" whose value is the <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-4">value</a> of that property to
         <var>parameters</var>.</p></li></ol>
       </dd><dt>If the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-5">value</a> is an <a href="#concept-item" id="conversion-to-vcard:concept-item-6">item</a> <var>subitem</var> and <var>name</var> is
       <code id="conversion-to-vcard:md-vcard-org"><a href="#md-vcard-org">org</a></code></dt><dd>
        <ol><li><p>Let <var>value</var> be the empty string.</p></li><li><p>Append to <var>value</var> the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-10">collecting the first vCard
         subproperty</a> named <code id="conversion-to-vcard:md-vcard-org-organization-name"><a href="#md-vcard-org-organization-name">organization-name</a></code> in <var>subitem</var>.</p>

         </li><li>
          <p>For each property named <code id="conversion-to-vcard:md-vcard-org-organization-unit"><a href="#md-vcard-org-organization-unit">organization-unit</a></code> in <var>subitem</var>, run the following steps:</p>

          <ol><li><p>If the <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-6">value</a> of the property is an
           <a href="#concept-item" id="conversion-to-vcard:concept-item-7">item</a>, then skip this property.</p></li><li><p>Append a U+003B SEMICOLON character (;) to <var>value</var>.</p></li><li><p>Append the result of <a href="#escaping-the-vcard-text-string" id="conversion-to-vcard:escaping-the-vcard-text-string-3">escaping the vCard text string</a> given by the
           <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-7">value</a> of the property to <var>value</var>.</p></li></ol>
         </li></ol>
       </dd><dt>If the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-8">value</a> is an <a href="#concept-item" id="conversion-to-vcard:concept-item-8">item</a> <var>subitem</var> with the <a href="#item-types" id="conversion-to-vcard:item-types-3">item type</a> <code id="conversion-to-vcard:md-vcard-3"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>
       and <var>name</var> is <code id="conversion-to-vcard:md-vcard-related"><a href="#md-vcard-related">related</a></code></dt><dd>
        <ol><li><p>Let <var>value</var> be the empty string.</p></li><li><p>If there is a property named <code id="conversion-to-vcard:md-vcard-related-url"><a href="#md-vcard-related-url">url</a></code> in
         <var>subitem</var>, and its element is a <a href="#url-property-elements" id="conversion-to-vcard:url-property-elements">URL property
         element</a>, then append the result of <a href="#escaping-the-vcard-text-string" id="conversion-to-vcard:escaping-the-vcard-text-string-4">escaping the vCard text string</a> given
         by the <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-9">value</a> of the first such property to
         <var>value</var>, and add a parameter with the name "<code>VALUE</code>" and the
         value "<code>URI</code>" to <var>parameters</var>.</p></li><li><p>If there is a property named <code id="conversion-to-vcard:md-vcard-related-rel"><a href="#md-vcard-related-rel">rel</a></code> in
         <var>subitem</var>, and the first such property has a <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-10">value</a> that is not an <a href="#concept-item" id="conversion-to-vcard:concept-item-9">item</a> and whose value consists only of <a href="https://infra.spec.whatwg.org/#ascii-alphanumeric" id="conversion-to-vcard:alphanumeric-ascii-characters-2" data-x-internal="alphanumeric-ascii-characters">ASCII alphanumerics</a>, then add a parameter named "<code>RELATION</code>" whose value is the <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-11">value</a> of that property to
         <var>parameters</var>.</p></li></ol>
       </dd><dt>If the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-12">value</a> is an <a href="#concept-item" id="conversion-to-vcard:concept-item-10">item</a> and <var>name</var> is none of the above</dt><dd>
        <ol><li><p>Let <var>value</var> be the result of <a href="#collecting-the-first-vcard-subproperty" id="conversion-to-vcard:collecting-the-first-vcard-subproperty-11">collecting the first vCard
         subproperty</a> named <code>value</code> in <var>subitem</var>.</p>

         </li><li><p>If there is a property named <code>type</code> in <var>subitem</var>, and
         the first such property has a <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-13">value</a> that is
         not an <a href="#concept-item" id="conversion-to-vcard:concept-item-11">item</a> and whose value consists only of <a href="https://infra.spec.whatwg.org/#ascii-alphanumeric" id="conversion-to-vcard:alphanumeric-ascii-characters-3" data-x-internal="alphanumeric-ascii-characters">ASCII alphanumerics</a>, then add a parameter named "<code>TYPE</code>" whose value is the <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-14">value</a> of that property to
         <var>parameters</var>.</p></li></ol>
       </dd><dt>If the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-15">value</a> is not an <a href="#concept-item" id="conversion-to-vcard:concept-item-12">item</a> and its <var>name</var> is <code id="conversion-to-vcard:md-vcard-sex"><a href="#md-vcard-sex">sex</a></code></dt><dd>
        <p>If this is the first such property to be found, set <var>sex</var> to the
        property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-16">value</a>.</p>
       </dd><dt>If the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-17">value</a> is not an <a href="#concept-item" id="conversion-to-vcard:concept-item-13">item</a> and its <var>name</var> is <code id="conversion-to-vcard:md-vcard-gender-identity"><a href="#md-vcard-gender-identity">gender-identity</a></code></dt><dd>
        <p>If this is the first such property to be found, set <var>gender-identity</var>
        to the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-18">value</a>.</p>
       </dd><dt>Otherwise (the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-19">value</a> is not an
       <a href="#concept-item" id="conversion-to-vcard:concept-item-14">item</a>)</dt><dd>
        <ol><li><p>Let <var>value</var> be the property's <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-20">value</a>.</p></li><li><p>If <var>element</var> is one of the <a href="#url-property-elements" id="conversion-to-vcard:url-property-elements-2">URL property elements</a>, add
         a parameter with the name "<code>VALUE</code>" and the value "<code>URI</code>" to <var>parameters</var>.</p></li><li><p>Otherwise, if <var>name</var> is <code id="conversion-to-vcard:md-vcard-bday"><a href="#md-vcard-bday">bday</a></code> or
         <code id="conversion-to-vcard:md-vcard-anniversary"><a href="#md-vcard-anniversary">anniversary</a></code> and the <var>value</var> is
         a <a href="#valid-date-string" id="conversion-to-vcard:valid-date-string">valid date string</a>, add a parameter with the name "<code>VALUE</code>" and the value "<code>DATE</code>" to <var>parameters</var>.</p></li><li><p>Otherwise, if <var>name</var> is <code id="conversion-to-vcard:md-vcard-rev"><a href="#md-vcard-rev">rev</a></code> and
         the <var>value</var> is a <a href="#valid-global-date-and-time-string" id="conversion-to-vcard:valid-global-date-and-time-string">valid global date and time string</a>, add a
         parameter with the name "<code>VALUE</code>" and the value "<code>DATE-TIME</code>" to <var>parameters</var>.</p></li><li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in <var>value</var> with
         another U+005C REVERSE SOLIDUS character (\).</p></li><li><p>Prefix every U+002C COMMA character (,) in <var>value</var> with a U+005C
         REVERSE SOLIDUS character (\).</p></li><li><p>Unless <var>name</var> is <code id="conversion-to-vcard:md-vcard-geo"><a href="#md-vcard-geo">geo</a></code>, prefix
         every U+003B SEMICOLON character (;) in <var>value</var> with a U+005C REVERSE
         SOLIDUS character (\).</p></li><li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED character pair (CRLF) in <var>value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN
         SMALL LETTER N character (n).</p></li><li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or U+000A LINE FEED (LF)
         character in <var>value</var> with a U+005C REVERSE SOLIDUS character (\) followed
         by a U+006E LATIN SMALL LETTER N character (n).</p></li></ol>
       </dd></dl>
     </li><li>
      <p><a href="#add-a-vcard-line" id="conversion-to-vcard:add-a-vcard-line-6">Add a vCard line</a> with the type <var>name</var>, the parameters <var>parameters</var>, and the value <var>value</var> to <var>output</var>.</p>
     </li></ol>
   </li><li><p>If either <var>sex</var> or <var>gender-identity</var> has a value that
   is not the empty string, <a href="#add-a-vcard-line" id="conversion-to-vcard:add-a-vcard-line-7">add a vCard line</a> with the type "<code>GENDER</code>" and the value consisting of the concatenation of <var>sex</var>,
   a U+003B SEMICOLON character (;), and <var>gender-identity</var> to <var>output</var>.</p></li><li><p><a href="#add-a-vcard-line" id="conversion-to-vcard:add-a-vcard-line-8">Add a vCard line</a> with the type "<code>END</code>" and the value
   "<code>VCARD</code>" to <var>output</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the above algorithm says that the user agent is to <dfn id="add-a-vcard-line">add a vCard line</dfn> consisting
  of a type <var>type</var>, optionally some parameters, and a value <var>value</var> to a string <var>output</var>, it must run the following steps:</p>

  <ol><li><p>Let <var>line</var> be an empty string.

   </p></li><li><p>Append <var>type</var>, <a id="conversion-to-vcard:converted-to-ascii-uppercase" href="https://infra.spec.whatwg.org/#ascii-uppercase" data-x-internal="converted-to-ascii-uppercase">converted to ASCII uppercase</a>, to <var>line</var>.</p></li><li>
    <p>If there are any parameters, then for each parameter, in the order that they were added, run
    these substeps:</p>

    <ol><li><p>Append a U+003B SEMICOLON character (;) to <var>line</var>.</p></li><li><p>Append the parameter's name to <var>line</var>.</p></li><li><p>Append a U+003D EQUALS SIGN character (=) to <var>line</var>.</p></li><li><p>Append the parameter's value to <var>line</var>.</p></li></ol>
   </li><li><p>Append a U+003A COLON character (:) to <var>line</var>.</p></li><li><p>Append <var>value</var> to <var>line</var>.</p></li><li><p>Let <var>maximum length</var> be 75.</p></li><li>
    <p>While <var>line</var>'s <a id="conversion-to-vcard:code-point-length" href="https://infra.spec.whatwg.org/#string-code-point-length" data-x-internal="code-point-length">code point length</a> is greater than <var>maximum
    length</var>:</p>

    <ol><li><p>Append the first <var>maximum length</var> code points of <var>line</var> to
     <var>output</var>.</p></li><li><p>Remove the first <var>maximum length</var> code points from <var>line</var>.</p></li><li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var>output</var>.</p></li><li><p>Append a U+000A LINE FEED character (LF) to <var>output</var>.</p></li><li><p>Append a U+0020 SPACE character to <var>output</var>.</p></li><li><p>Let <var>maximum length</var> be 74.</p></li></ol>
   </li><li><p>Append (what remains of) <var>line</var> to <var>output</var>.</p></li><li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var>output</var>.</p></li><li><p>Append a U+000A LINE FEED character (LF) to <var>output</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the steps above require the user agent to obtain the result of <dfn id="collecting-vcard-subproperties">collecting vCard
  subproperties</dfn> named <var>subname</var> in <var>subitem</var>, the user
  agent must run the following steps:</p>

  <ol><li><p>Let <var>value</var> be the empty string.</p></li><li>
    <p>For each property named <var>subname</var> in the item <var>subitem</var>,
    run the following substeps:</p>

    <ol><li><p>If the <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-21">value</a> of the property is itself an
     <a href="#concept-item" id="conversion-to-vcard:concept-item-15">item</a>, then skip this property.</p></li><li><p>If this is not the first property named <var>subname</var> in <var>subitem</var> (ignoring any that were skipped by the previous step), then append a
     U+002C COMMA character (,) to <var>value</var>.</p></li><li><p>Append the result of <a href="#escaping-the-vcard-text-string" id="conversion-to-vcard:escaping-the-vcard-text-string-5">escaping the vCard text string</a> given by the <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-22">value</a> of the property to <var>value</var>.</p></li></ol>
   </li><li><p>Return <var>value</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the steps above require the user agent to obtain the result of <dfn id="collecting-the-first-vcard-subproperty">collecting the first
  vCard subproperty</dfn> named <var>subname</var> in <var>subitem</var>, the user
  agent must run the following steps:</p>

  <ol><li><p>If there are no properties named <var>subname</var> in <var>subitem</var>, then return the
   empty string.</p></li><li><p>If the <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-23">value</a> of the first property named
   <var>subname</var> in <var>subitem</var> is an <a href="#concept-item" id="conversion-to-vcard:concept-item-16">item</a>, then
   return the empty string.</p></li><li><p>Return the result of <a href="#escaping-the-vcard-text-string" id="conversion-to-vcard:escaping-the-vcard-text-string-6">escaping the vCard text string</a> given by the <a href="#concept-property-value" id="conversion-to-vcard:concept-property-value-24">value</a> of the first property named <var>subname</var> in
   <var>subitem</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the above algorithms say the user agent is to <dfn id="escaping-the-vcard-text-string">escape the vCard text string</dfn> <var>value</var>, the user agent must use the
  following steps:</p>

  <ol><li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in <var>value</var> with
   another U+005C REVERSE SOLIDUS character (\).</p></li><li><p>Prefix every U+002C COMMA character (,) in <var>value</var> with a U+005C REVERSE
   SOLIDUS character (\).</p></li><li><p>Prefix every U+003B SEMICOLON character (;) in <var>value</var> with a U+005C
   REVERSE SOLIDUS character (\).</p></li><li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED character pair (CRLF) in <var>value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL
   LETTER N character (n).</p></li><li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or U+000A LINE FEED (LF) character in
   <var>value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN
   SMALL LETTER N character (n).</p></li><li><p>Return the mutated <var>value</var>.</p></li></ol>
  </div>

  <p class="note">This algorithm can generate invalid vCard output, if the input does not conform to
  the rules described for the <code id="conversion-to-vcard:md-vcard-4"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>
  <a href="#item-types" id="conversion-to-vcard:item-types-4">item type</a> and <a href="#defined-property-name" id="conversion-to-vcard:defined-property-name">defined property
  names</a>.</p> 



  <h5 id="examples-2"><span class="secno">5.3.1.2</span> Examples<a href="#examples-2" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <div class="example">

   <p>Here is a long example vCard for a fictional character called "Jack Bauer":</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"jack"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://microformats.org/profile/hcard"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h1</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"fn"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"n"</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"given-name"</c-><c- p="">&gt;</c->Jack<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"family-name"</c-><c- p="">&gt;</c->Bauer<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"photo"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"jack-bauer.jpg"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"org"</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"organization-name"</c-><c- p="">&gt;</c->Counter-Terrorist Unit<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
  (<c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"organization-unit"</c-><c- p="">&gt;</c->Los Angeles Division<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->)
 <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"adr"</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"street-address"</c-><c- p="">&gt;</c->10201 W. Pico Blvd.<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"locality"</c-><c- p="">&gt;</c->Los Angeles<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->,
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"region"</c-><c- p="">&gt;</c->CA<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"postal-code"</c-><c- p="">&gt;</c->90064<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"country-name"</c-><c- p="">&gt;</c->United States<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"geo"</c-><c- p="">&gt;</c->34.052339;-118.410623<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Assorted Contact Methods<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"tel"</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"value"</c-><c- p="">&gt;</c->+1 (310) 597 3781<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"type"</c-><c- p="">&gt;</c->work<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"type"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"voice"</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"https://en.wikipedia.org/wiki/Jack_Bauer"</c-><c- p="">&gt;</c->I'm on Wikipedia<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  so you can leave a message on my user talk page.<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"http://www.jackbauerfacts.com/"</c-><c- p="">&gt;</c->Jack Bauer Facts<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"email"</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"mailto:j.bauer@la.ctu.gov.invalid"</c-><c- p="">&gt;</c->j.bauer@la.ctu.gov.invalid<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"tel"</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"value"</c-><c- p="">&gt;</c->+1 (310) 555 3781<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"type"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"cell"</c-><c- p="">&gt;</c->mobile phone<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ins</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2008-07-20 21:00:00+01:00"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"rev"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"2008-07-20 21:00:00+01:00"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"tel"</c-> <c- e="">itemscope</c-><c- p="">&gt;&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->Update!<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->
  My new <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"type"</c-><c- p="">&gt;</c->home<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> phone number is
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"value"</c-><c- p="">&gt;</c->01632 960 123<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">ins</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <p>The odd line wrapping is needed because newlines are meaningful in microdata: newlines would
   be preserved in a conversion to, for example, the vCard format.</p>

  </div>

  <div class="example">

   <p>This example shows a site's contact details (using the <code id="examples-2:the-address-element"><a href="#the-address-element">address</a></code> element)
   containing an address with two street components:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">address</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://microformats.org/profile/hcard"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">strong</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"fn"</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"n"</c-> <c- e="">itemscope</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"given-name"</c-><c- p="">&gt;</c->Alfred<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"family-name"</c-><c- p="">&gt;</c->Person<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"adr"</c-> <c- e="">itemscope</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"street-address"</c-><c- p="">&gt;</c->1600 Amphitheatre Parkway<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"street-address"</c-><c- p="">&gt;</c->Building 43, Second Floor<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">br</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"locality"</c-><c- p="">&gt;</c->Mountain View<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->,
   <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"region"</c-><c- p="">&gt;</c->CA<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"postal-code"</c-><c- p="">&gt;</c->94043<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">address</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>The vCard vocabulary can be used to just mark up people's names:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://microformats.org/profile/hcard"</c->
<c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">fn</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"n"</c-> <c- e="">itemscope</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"given-name"</c->
<c- p="">&gt;</c->George<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"family-name"</c-><c- p="">&gt;</c->Washington<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c->
<c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-></code></pre>

   <p>This creates a single item with a two name-value pairs, one with the name "fn" and the value
   "George Washington", and the other with the name "n" and a second item as its value, the second
   item having the two name-value pairs "given-name" and "family-name" with the values "George" and
   "Washington" respectively. This is defined to map to the following vCard:</p>

   <pre>BEGIN:VCARD
PROFILE:VCARD
VERSION:4.0
SOURCE:<var>document's address</var>
FN:George Washington
N:Washington;George;;;
END:VCARD</pre>

  </div>


  <h4 id="vevent"><span class="secno">5.3.2</span> vEvent<a href="#vevent" class="self-link"></a></h4>

  <p>An item with the <a href="#item-types" id="vevent:item-types">item type</a> <dfn id="md-vevent"><code>http://microformats.org/profile/hcalendar#vevent</code></dfn> represents
  an event.</p>

  <p>This vocabulary does not <a href="#support-global-identifiers-for-items" id="vevent:support-global-identifiers-for-items">support global identifiers for items</a>.</p>

  <p>The following are the type's <a href="#defined-property-name" id="vevent:defined-property-name">defined property
  names</a>. They are based on the vocabulary defined in <cite>Internet Calendaring and
  Scheduling Core Object Specification</cite> (<cite>iCalendar</cite>), where more information on
  how to interpret the values can be found. <a href="#refsRFC5545">[RFC5545]</a></p>

  <p class="note">Only the parts of the iCalendar vocabulary relating to events are used here; this
  vocabulary cannot express a complete iCalendar instance.</p>

  <dl><dt><dfn id="md-vevent-attach"><code>attach</code></dfn></dt><dd>
    <p>Gives the address of an associated document for the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value">value</a> must be an <a id="vevent:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Any number of properties with the name <code id="vevent:md-vevent-attach"><a href="#md-vevent-attach">attach</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item">item</a> with the type <code id="vevent:md-vevent"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-categories"><code>categories</code></dfn></dt><dd>
    <p>Gives the name of a category or tag that the event could be classified as.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-2">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vevent:md-vevent-categories"><a href="#md-vevent-categories">categories</a></code>
    may be present within each <a href="#concept-item" id="vevent:concept-item-2">item</a> with the type <code id="vevent:md-vevent-2"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-class"><code>class</code></dfn></dt><dd>
    <p>Gives the access classification of the information regarding the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-3">value</a> must be text with one of the following
    values:</p>

    <ul class="brief"><li><code>public</code></li><li><code>private</code></li><li><code>confidential</code></li></ul>

    <p class="warning">This is merely advisory and cannot be considered a confidentiality
    measure.</p>

    <p>A single property with the name <code id="vevent:md-vevent-class"><a href="#md-vevent-class">class</a></code> may be present
    within each <a href="#concept-item" id="vevent:concept-item-3">item</a> with the type <code id="vevent:md-vevent-3"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-comment"><code>comment</code></dfn></dt><dd>
    <p>Gives a comment regarding the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-4">value</a> must be text.</p>

    <p>Any number of properties with the name <code id="vevent:md-vevent-comment"><a href="#md-vevent-comment">comment</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item-4">item</a> with the type <code id="vevent:md-vevent-4"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-description"><code>description</code></dfn></dt><dd>
    <p>Gives a detailed description of the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-5">value</a> must be text.</p>

    <p>A single property with the name <code id="vevent:md-vevent-description"><a href="#md-vevent-description">description</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item-5">item</a> with the type <code id="vevent:md-vevent-5"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-geo"><code>geo</code></dfn></dt><dd>
    <p>Gives the geographical position of the event.</p>

    <div data-algorithm="">
    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-6">value</a> must be text and must match the
    following syntax:</p>

    <ol><li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character
     (-).</li><li>One or more <a id="vevent:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>.</li><li>Optionally*, a U+002E FULL STOP character (.) followed by one or more <a id="vevent:ascii-digits-2" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
     digits</a>.</li><li>A U+003B SEMICOLON character (;).</li><li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character
     (-).</li><li>One or more <a id="vevent:ascii-digits-3" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>.</li><li>Optionally*, a U+002E FULL STOP character (.) followed by one or more <a id="vevent:ascii-digits-4" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII
     digits</a>.</li></ol>
    </div>

    <p>The optional components marked with an asterisk (*) should be included, and should have six
    digits each.</p> 

    
    <p class="note">The value specifies latitude and longitude, in that order (i.e., "LAT LON"
    ordering), in decimal degrees. The longitude represents the location east and west of the prime
    meridian as a positive or negative real number, respectively. The latitude represents the
    location north and south of the equator as a positive or negative real number, respectively.</p>

    <p>A single property with the name <code id="vevent:md-vevent-geo"><a href="#md-vevent-geo">geo</a></code> may be present within
    each <a href="#concept-item" id="vevent:concept-item-6">item</a> with the type <code id="vevent:md-vevent-6"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-location"><code>location</code></dfn></dt><dd>
    <p>Gives the location of the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-7">value</a> must be text.</p> 

    <p>A single property with the name <code id="vevent:md-vevent-location"><a href="#md-vevent-location">location</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item-7">item</a> with the type <code id="vevent:md-vevent-7"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-resources"><code>resources</code></dfn></dt><dd>
    <p>Gives a resource that will be needed for the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-8">value</a> must be text.</p> 

    <p>Any number of properties with the name <code id="vevent:md-vevent-resources"><a href="#md-vevent-resources">resources</a></code> may
    be present within each <a href="#concept-item" id="vevent:concept-item-8">item</a> with the type <code id="vevent:md-vevent-8"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-status"><code>status</code></dfn></dt><dd>
    <p>Gives the confirmation status of the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-9">value</a> must be text with one of the following
    values:</p>

    <ul class="brief"><li><code>tentative</code></li><li><code>confirmed</code></li><li><code>canceled</code></li></ul>

    <p>A single property with the name <code id="vevent:md-vevent-status"><a href="#md-vevent-status">status</a></code> may be present
    within each <a href="#concept-item" id="vevent:concept-item-9">item</a> with the type <code id="vevent:md-vevent-9"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-summary"><code>summary</code></dfn></dt><dd>
    <p>Gives a short summary of the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-10">value</a> must be text.</p>

    <p>User agents should replace U+000A LINE FEED (LF) characters in the <a href="#concept-property-value" id="vevent:concept-property-value-11">value</a> by U+0020 SPACE characters when using the value.</p>

    <p>A single property with the name <code id="vevent:md-vevent-summary"><a href="#md-vevent-summary">summary</a></code> may be present
    within each <a href="#concept-item" id="vevent:concept-item-10">item</a> with the type <code id="vevent:md-vevent-10"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-dtend"><code>dtend</code></dfn></dt><dd>
    <p>Gives the date and time by which the event ends.</p>

    <p>If the property with the name <code id="vevent:md-vevent-dtend"><a href="#md-vevent-dtend">dtend</a></code> is present within an
    <a href="#concept-item" id="vevent:concept-item-11">item</a> with the type <code id="vevent:md-vevent-11"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code> that has a property
    with the name <code id="vevent:md-vevent-dtstart"><a href="#md-vevent-dtstart">dtstart</a></code> whose value is a <a href="#valid-date-string" id="vevent:valid-date-string">valid date
    string</a>, then the <a href="#concept-property-value" id="vevent:concept-property-value-12">value</a> of the property with
    the name <code id="vevent:md-vevent-dtend-2"><a href="#md-vevent-dtend">dtend</a></code> must be text that is a <a href="#valid-date-string" id="vevent:valid-date-string-2">valid date
    string</a> also. Otherwise, the <a href="#concept-property-value" id="vevent:concept-property-value-13">value</a> of the
    property must be text that is a <a href="#valid-global-date-and-time-string" id="vevent:valid-global-date-and-time-string">valid global date and time string</a>.</p>

    <p>In either case, the <a href="#concept-property-value" id="vevent:concept-property-value-14">value</a> be later in time than
    the value of the <code id="vevent:md-vevent-dtstart-2"><a href="#md-vevent-dtstart">dtstart</a></code> property of the same <a href="#concept-item" id="vevent:concept-item-12">item</a>.</p>

    <p class="note">The time given by the <code id="vevent:md-vevent-dtend-3"><a href="#md-vevent-dtend">dtend</a></code> property is not
    inclusive. For day-long events, therefore, the <code id="vevent:md-vevent-dtend-4"><a href="#md-vevent-dtend">dtend</a></code>
    property's <a href="#concept-property-value" id="vevent:concept-property-value-15">value</a> will be the day <em>after</em> the
    end of the event.</p>

    <p>A single property with the name <code id="vevent:md-vevent-dtend-5"><a href="#md-vevent-dtend">dtend</a></code> may be present
    within each <a href="#concept-item" id="vevent:concept-item-13">item</a> with the type <code id="vevent:md-vevent-12"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>, so long as that <code id="vevent:md-vevent-13"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code> does not have a
    property with the name <code id="vevent:md-vevent-duration"><a href="#md-vevent-duration">duration</a></code>.</p>
   </dd><dt><dfn id="md-vevent-dtstart"><code>dtstart</code></dfn></dt><dd>
    <p>Gives the date and time at which the event starts.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-16">value</a> must be text that is either a
    <a href="#valid-date-string" id="vevent:valid-date-string-3">valid date string</a> or a <a href="#valid-global-date-and-time-string" id="vevent:valid-global-date-and-time-string-2">valid global date and time string</a>.</p>

    <p>Exactly one property with the name <code id="vevent:md-vevent-dtstart-3"><a href="#md-vevent-dtstart">dtstart</a></code> must be
    present within each <a href="#concept-item" id="vevent:concept-item-14">item</a> with the type <code id="vevent:md-vevent-14"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-duration"><code>duration</code></dfn></dt><dd>
    <p>Gives the duration of the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-17">value</a> must be text that is a <a href="#valid-vevent-duration-string" id="vevent:valid-vevent-duration-string">valid
    vevent duration string</a>.</p>

    <p>The duration represented is the sum of all the durations represented by integers in the
    value.</p>

    <p>A single property with the name <code id="vevent:md-vevent-duration-2"><a href="#md-vevent-duration">duration</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item-15">item</a> with the type <code id="vevent:md-vevent-15"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>, so long as that <code id="vevent:md-vevent-16"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code> does not have a
    property with the name <code id="vevent:md-vevent-dtend-6"><a href="#md-vevent-dtend">dtend</a></code>.</p>
   </dd><dt><dfn id="md-vevent-transp"><code>transp</code></dfn></dt><dd>
    <p>Gives whether the event is to be considered as consuming time on a calendar, for the purpose
    of free-busy time searches.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-18">value</a> must be text with one of the following
    values:</p>

    <ul class="brief"><li><code>opaque</code></li><li><code>transparent</code></li></ul>

    <p>A single property with the name <code id="vevent:md-vevent-transp"><a href="#md-vevent-transp">transp</a></code> may be present
    within each <a href="#concept-item" id="vevent:concept-item-16">item</a> with the type <code id="vevent:md-vevent-17"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-contact"><code>contact</code></dfn></dt><dd>
    <p>Gives the contact information for the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-19">value</a> must be text.</p> 

    <p>Any number of properties with the name <code id="vevent:md-vevent-contact"><a href="#md-vevent-contact">contact</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item-17">item</a> with the type <code id="vevent:md-vevent-18"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-url"><code>url</code></dfn></dt><dd>
    <p>Gives a <a id="vevent:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> for the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-20">value</a> must be an <a id="vevent:absolute-url-2" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>A single property with the name <code id="vevent:md-vevent-url"><a href="#md-vevent-url">url</a></code> may be present within
    each <a href="#concept-item" id="vevent:concept-item-18">item</a> with the type <code id="vevent:md-vevent-19"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-uid"><code>uid</code></dfn></dt><dd>
    <p>Gives a globally unique identifier corresponding to the event.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-21">value</a> must be text.</p>

    <p>A single property with the name <code id="vevent:md-vevent-uid"><a href="#md-vevent-uid">uid</a></code> may be present within
    each <a href="#concept-item" id="vevent:concept-item-19">item</a> with the type <code id="vevent:md-vevent-20"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-exdate"><code>exdate</code></dfn></dt><dd>
    <p>Gives a date and time at which the event does not occur despite the recurrence rules.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-22">value</a> must be text that is either a
    <a href="#valid-date-string" id="vevent:valid-date-string-4">valid date string</a> or a <a href="#valid-global-date-and-time-string" id="vevent:valid-global-date-and-time-string-3">valid global date and time string</a>.</p>

    <p>Any number of properties with the name <code id="vevent:md-vevent-exdate"><a href="#md-vevent-exdate">exdate</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item-20">item</a> with the type <code id="vevent:md-vevent-21"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-rdate"><code>rdate</code></dfn></dt><dd>
    <p>Gives a date and time at which the event recurs.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-23">value</a> must be text that is one of the
    following:

    </p><ul><li>A <a href="#valid-date-string" id="vevent:valid-date-string-5">valid date string</a>.</li><li>A <a href="#valid-global-date-and-time-string" id="vevent:valid-global-date-and-time-string-4">valid global date and time string</a>.</li><li>A <a href="#valid-global-date-and-time-string" id="vevent:valid-global-date-and-time-string-5">valid global date and time string</a> followed by a U+002F SOLIDUS character (/)
     followed by a second <a href="#valid-global-date-and-time-string" id="vevent:valid-global-date-and-time-string-6">valid global date and time string</a> representing a later
     time.</li><li>A <a href="#valid-global-date-and-time-string" id="vevent:valid-global-date-and-time-string-7">valid global date and time string</a> followed by a U+002F SOLIDUS character (/)
     followed by a <a href="#valid-vevent-duration-string" id="vevent:valid-vevent-duration-string-2">valid vevent duration string</a>.</li></ul>

    <p>Any number of properties with the name <code id="vevent:md-vevent-rdate"><a href="#md-vevent-rdate">rdate</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item-21">item</a> with the type <code id="vevent:md-vevent-22"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-rrule"><code>rrule</code></dfn></dt><dd>
    <p>Gives a rule for finding dates and times at which the event occurs.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-24">value</a> must be text that matches the RECUR
    value type defined in <cite>iCalendar</cite>. <a href="#refsRFC5545">[RFC5545]</a></p>

    <p>A single property with the name <code id="vevent:md-vevent-rrule"><a href="#md-vevent-rrule">rrule</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item-22">item</a> with the type <code id="vevent:md-vevent-23"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-created"><code>created</code></dfn></dt><dd>
    <p>Gives the date and time at which the event information was first created in a calendaring
    system.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-25">value</a> must be text that is a <a href="#valid-global-date-and-time-string" id="vevent:valid-global-date-and-time-string-8">valid
    global date and time string</a>.</p>

    <p>A single property with the name <code id="vevent:md-vevent-created"><a href="#md-vevent-created">created</a></code> may be present
    within each <a href="#concept-item" id="vevent:concept-item-23">item</a> with the type <code id="vevent:md-vevent-24"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-last-modified"><code>last-modified</code></dfn></dt><dd>
    <p>Gives the date and time at which the event information was last modified in a calendaring
    system.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-26">value</a> must be text that is a <a href="#valid-global-date-and-time-string" id="vevent:valid-global-date-and-time-string-9">valid
    global date and time string</a>.</p>

    <p>A single property with the name <code id="vevent:md-vevent-last-modified"><a href="#md-vevent-last-modified">last-modified</a></code>
    may be present within each <a href="#concept-item" id="vevent:concept-item-24">item</a> with the type <code id="vevent:md-vevent-25"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd><dt><dfn id="md-vevent-sequence"><code>sequence</code></dfn></dt><dd>
    <p>Gives a revision number for the event information.</p>

    <p>The <a href="#concept-property-value" id="vevent:concept-property-value-27">value</a> must be text that is a <a href="#valid-non-negative-integer" id="vevent:valid-non-negative-integer">valid
    non-negative integer</a>.</p>

    <p>A single property with the name <code id="vevent:md-vevent-sequence"><a href="#md-vevent-sequence">sequence</a></code> may be
    present within each <a href="#concept-item" id="vevent:concept-item-25">item</a> with the type <code id="vevent:md-vevent-26"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>.</p>
   </dd></dl>

  <div data-algorithm="">
  <p>A string is a <dfn id="valid-vevent-duration-string">valid vevent duration string</dfn> if it matches the following pattern:</p>

  <ol><li><p>A U+0050 LATIN CAPITAL LETTER P character (P).</p></li><li>
    <p>One of the following:</p>

    <ul><li><p>A <a href="#valid-non-negative-integer" id="vevent:valid-non-negative-integer-2">valid non-negative integer</a> followed by a U+0057 LATIN CAPITAL LETTER W
     character (W). The integer represents a duration of that number of weeks.</p></li><li>
      <p>At least one, and possible both in this order, of the following:</p>

      <ol><li><p>A <a href="#valid-non-negative-integer" id="vevent:valid-non-negative-integer-3">valid non-negative integer</a> followed by a U+0044 LATIN CAPITAL LETTER D
       character (D). The integer represents a duration of that number of days.</p></li><li>
        <p>A U+0054 LATIN CAPITAL LETTER T character (T) followed by any one of the following, or
        the first and second of the following in that order, or the second and third of the
        following in that order, or all three of the following in this order:</p>

        <ol><li><p>A <a href="#valid-non-negative-integer" id="vevent:valid-non-negative-integer-4">valid non-negative integer</a> followed by a U+0048 LATIN CAPITAL LETTER
         H character (H). The integer represents a duration of that number of hours.</p></li><li><p>A <a href="#valid-non-negative-integer" id="vevent:valid-non-negative-integer-5">valid non-negative integer</a> followed by a U+004D LATIN CAPITAL LETTER
         M character (M). The integer represents a duration of that number of minutes.</p></li><li><p>A <a href="#valid-non-negative-integer" id="vevent:valid-non-negative-integer-6">valid non-negative integer</a> followed by a U+0053 LATIN CAPITAL LETTER
         S character (S). The integer represents a duration of that number of seconds.</p></li></ol>
      </li></ol>
     </li></ul>
   </li></ol>
  </div>


  <h5 id="conversion-to-icalendar"><span class="secno">5.3.2.1</span> Conversion to iCalendar<a href="#conversion-to-icalendar" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Given a list of nodes <var>nodes</var> in a <code id="conversion-to-icalendar:document"><a href="#document">Document</a></code>, a user agent must
  run the following algorithm to <dfn id="extracting-vevent-data">extract any vEvent data
  represented by those nodes</dfn>:</p>

  <ol><li><p>If none of the nodes in <var>nodes</var> are <a href="#concept-item" id="conversion-to-icalendar:concept-item">items</a> with the type <code id="conversion-to-icalendar:md-vevent"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>, then there is no
   vEvent data. Abort the algorithm, returning nothing.</p></li><li><p>Let <var>output</var> be an empty string.</p></li><li><p><a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line">Add an iCalendar line</a> with the type "<code>BEGIN</code>" and the
   value "<code>VCALENDAR</code>" to <var>output</var>.</p></li><li><p><a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line-2">Add an iCalendar line</a> with the type "<code>PRODID</code>" and the
   value equal to a user-agent-specific string representing the user agent to <var>output</var>.</p></li><li><p><a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line-3">Add an iCalendar line</a> with the type "<code>VERSION</code>" and the
   value "<code>2.0</code>" to <var>output</var>.</p></li><li>
    <p>For each node <var>node</var> in <var>nodes</var> that is an <a href="#concept-item" id="conversion-to-icalendar:concept-item-2">item</a> with the type <code id="conversion-to-icalendar:md-vevent-2"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code>, run the following
    steps:</p>

    <ol><li><p><a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line-4">Add an iCalendar line</a> with the type "<code>BEGIN</code>" and the
     value "<code>VEVENT</code>" to <var>output</var>.</p></li><li><p><a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line-5">Add an iCalendar line</a> with the type "<code>DTSTAMP</code>" and a
     value consisting of an iCalendar DATE-TIME string representing the current date and time, with
     the annotation "<code>VALUE=DATE-TIME</code>", to <var>output</var>.
     <a href="#refsRFC5545">[RFC5545]</a></p></li><li>
      <p>For each element <var>element</var> that is <a href="#the-properties-of-an-item" id="conversion-to-icalendar:the-properties-of-an-item">a property of the item</a> <var>node</var>: for each name <var>name</var> in <var>element</var>'s <a href="#property-names" id="conversion-to-icalendar:property-names">property names</a>, run the
      appropriate set of substeps from the following list:</p>

      <dl><dt>If the property's <a href="#concept-property-value" id="conversion-to-icalendar:concept-property-value">value</a> is an <a href="#concept-item" id="conversion-to-icalendar:concept-item-3">item</a></dt><dd>
        <p>Skip the property.</p>
       </dd><dt>If the property is <code id="conversion-to-icalendar:md-vevent-dtend"><a href="#md-vevent-dtend">dtend</a></code></dt><dt>If the property is <code id="conversion-to-icalendar:md-vevent-dtstart"><a href="#md-vevent-dtstart">dtstart</a></code></dt><dt>If the property is <code id="conversion-to-icalendar:md-vevent-exdate"><a href="#md-vevent-exdate">exdate</a></code></dt><dt>If the property is <code id="conversion-to-icalendar:md-vevent-rdate"><a href="#md-vevent-rdate">rdate</a></code></dt><dt>If the property is <code id="conversion-to-icalendar:md-vevent-created"><a href="#md-vevent-created">created</a></code></dt><dt>If the property is <code id="conversion-to-icalendar:md-vevent-last-modified"><a href="#md-vevent-last-modified">last-modified</a></code></dt><dd>
        <p>Let <var>value</var> be the result of stripping all U+002D HYPHEN-MINUS (-) and
        U+003A COLON (:) characters from the property's <a href="#concept-property-value" id="conversion-to-icalendar:concept-property-value-2">value</a>.</p>

        <p>If the property's <a href="#concept-property-value" id="conversion-to-icalendar:concept-property-value-3">value</a> is a <a href="#valid-date-string" id="conversion-to-icalendar:valid-date-string">valid date
        string</a>, then <a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line-6">add an iCalendar line</a> with the type <var>name</var>
        and the value <var>value</var> to <var>output</var>, with the annotation
        "<code>VALUE=DATE</code>".</p>

        <p>Otherwise, if the property's <a href="#concept-property-value" id="conversion-to-icalendar:concept-property-value-4">value</a> is a
        <a href="#valid-global-date-and-time-string" id="conversion-to-icalendar:valid-global-date-and-time-string">valid global date and time string</a>, then <a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line-7">add an iCalendar line</a> with
        the type <var>name</var> and the value <var>value</var> to <var>output</var>, with the annotation "<code>VALUE=DATE-TIME</code>".</p>

        <p>Otherwise, skip the property.</p>
       </dd><dt>Otherwise</dt><dd>
        <p><a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line-8">Add an iCalendar line</a> with the type <var>name</var> and the
        property's <a href="#concept-property-value" id="conversion-to-icalendar:concept-property-value-5">value</a> to <var>output</var>.</p>
       </dd></dl>
     </li><li><p><a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line-9">Add an iCalendar line</a> with the type "<code>END</code>" and the
     value "<code>VEVENT</code>" to <var>output</var>.</p></li></ol>
   </li><li><p><a href="#add-an-icalendar-line" id="conversion-to-icalendar:add-an-icalendar-line-10">Add an iCalendar line</a> with the type "<code>END</code>" and the value
   "<code>VCALENDAR</code>" to <var>output</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the above algorithm says that the user agent is to <dfn id="add-an-icalendar-line">add an iCalendar line</dfn>
  consisting of a type <var>type</var>, a value <var>value</var>, and optionally
  an annotation, to a string <var>output</var>, it must run the following steps:</p>

  <ol><li><p>Let <var>line</var> be an empty string.</p></li><li><p>Append <var>type</var>, <a id="conversion-to-icalendar:converted-to-ascii-uppercase" href="https://infra.spec.whatwg.org/#ascii-uppercase" data-x-internal="converted-to-ascii-uppercase">converted to ASCII uppercase</a>, to <var>line</var>.</p></li><li>
    <p>If there is an annotation:</p>

    <ol><li><p>Append a U+003B SEMICOLON character (;) to <var>line</var>.</p></li><li><p>Append the annotation to <var>line</var>.</p></li></ol>
   </li><li><p>Append a U+003A COLON character (:) to <var>line</var>.</p></li><li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in <var>value</var> with
   another U+005C REVERSE SOLIDUS character (\).</p></li><li><p>Prefix every U+002C COMMA character (,) in <var>value</var> with a U+005C REVERSE
   SOLIDUS character (\).</p></li><li><p>Prefix every U+003B SEMICOLON character (;) in <var>value</var> with a U+005C
   REVERSE SOLIDUS character (\).</p></li><li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED character pair (CRLF) in <var>value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL
   LETTER N character (n).</p></li><li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or U+000A LINE FEED (LF) character in
   <var>value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN
   SMALL LETTER N character (n).</p></li><li><p>Append <var>value</var> to <var>line</var>.</p></li><li><p>Let <var>maximum length</var> be 75.</p></li><li>
    <p>While <var>line</var>'s <a id="conversion-to-icalendar:code-point-length" href="https://infra.spec.whatwg.org/#string-code-point-length" data-x-internal="code-point-length">code point length</a> is greater than <var>maximum
    length</var>:</p>

    <ol><li><p>Append the first <var>maximum length</var> code points of <var>line</var> to
     <var>output</var>.</p></li><li><p>Remove the first <var>maximum length</var> code points from <var>line</var>.</p></li><li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var>output</var>.</p></li><li><p>Append a U+000A LINE FEED character (LF) to <var>output</var>.</p></li><li><p>Append a U+0020 SPACE character to <var>output</var>.</p></li><li><p>Let <var>maximum length</var> be 74.</p></li></ol>
   </li><li><p>Append (what remains of) <var>line</var> to <var>output</var>.</p></li><li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var>output</var>.</p></li><li><p>Append a U+000A LINE FEED character (LF) to <var>output</var>.</p></li></ol>
  </div>

  <p class="note">This algorithm can generate invalid iCalendar output, if the input does not
  conform to the rules described for the <code id="conversion-to-icalendar:md-vevent-3"><a href="#md-vevent">http://microformats.org/profile/hcalendar#vevent</a></code> <a href="#item-types" id="conversion-to-icalendar:item-types">item type</a> and <a href="#defined-property-name" id="conversion-to-icalendar:defined-property-name">defined property names</a>.</p>
  



  <h5 id="examples-3"><span class="secno">5.3.2.2</span> Examples<a href="#examples-3" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>



  <div class="example">

   <p>Here is an example of a page that uses the vEvent vocabulary to mark up an event:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://microformats.org/profile/hcalendar#vevent"</c-><c- p="">&gt;</c->
 ...
 <c- p="">&lt;</c-><c- f="">h1</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"summary"</c-><c- p="">&gt;</c->Bluesday Tuesday: Money Road<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
 ...
 <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"dtstart"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-05-05T19:00:00Z"</c-><c- p="">&gt;</c->May 5th @ 7pm<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->
 (until <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"dtend"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-05-05T21:00:00Z"</c-><c- p="">&gt;</c->9pm<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->)
 ...
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"http://livebrum.co.uk/2009/05/05/bluesday-tuesday-money-road"</c->
    <c- e="">rel</c-><c- o="">=</c-><c- s="">"bookmark"</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-><c- p="">&gt;</c->Link to this page<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 ...
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Location: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"location"</c-><c- p="">&gt;</c->The RoadHouse<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 ...
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Add to Calendar"</c->
           <c- e="">onclick</c-><c- o="">=</c-><c- s="">"location = getCalendar(this)"</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 ...
 <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"description"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"via livebrum.co.uk"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c-></code></pre>

   <p>The <code>getCalendar()</code> function is left as an exercise for the reader.</p>

   <p>The same page could offer some markup, such as the following,
   for copy-and-pasting into blogs:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://microformats.org/profile/hcalendar#vevent"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->I'm going to
 <c- p="">&lt;</c-><c- f="">strong</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"summary"</c-><c- p="">&gt;</c->Bluesday Tuesday: Money Road<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;</c->,
 <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"dtstart"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-05-05T19:00:00Z"</c-><c- p="">&gt;</c->May 5th at 7pm<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->
 to <c- p="">&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"dtend"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2009-05-05T21:00:00Z"</c-><c- p="">&gt;</c->9pm<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;</c->,
 at <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"location"</c-><c- p="">&gt;</c->The RoadHouse<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"http://livebrum.co.uk/2009/05/05/bluesday-tuesday-money-road"</c->
       <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-><c- p="">&gt;</c->See this event on livebrum.co.uk<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"description"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"via livebrum.co.uk"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="licensing-works"><span class="secno">5.3.3</span> Licensing works<a href="#licensing-works" class="self-link"></a></h4>

  <p>An item with the <a href="#item-types" id="licensing-works:item-types">item type</a> <dfn id="md-work"><code>http://n.whatwg.org/work</code></dfn> represents a work (e.g. an article, an
  image, a video, a song, etc.). This type is primarily intended to allow authors to include
  licensing information for works.</p>

  <p>The following are the type's <a href="#defined-property-name" id="licensing-works:defined-property-name">defined property
  names</a>.</p>

  <dl><dt><dfn id="md-work-work"><code>work</code></dfn></dt><dd>
    <p>Identifies the work being described.</p>

    <p>The <a href="#concept-property-value" id="licensing-works:concept-property-value">value</a> must be an <a id="licensing-works:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Exactly one property with the name <code id="licensing-works:md-work-work"><a href="#md-work-work">work</a></code> must be present
    within each <a href="#concept-item" id="licensing-works:concept-item">item</a> with the type <code id="licensing-works:md-work"><a href="#md-work">http://n.whatwg.org/work</a></code>.</p>
   </dd><dt><dfn id="md-work-title"><code>title</code></dfn></dt><dd>
    <p>Gives the name of the work.</p>

    <p>A single property with the name <code id="licensing-works:md-work-title"><a href="#md-work-title">title</a></code> may be present
    within each <a href="#concept-item" id="licensing-works:concept-item-2">item</a> with the type <code id="licensing-works:md-work-2"><a href="#md-work">http://n.whatwg.org/work</a></code>.</p>
   </dd><dt><dfn id="md-work-author"><code>author</code></dfn></dt><dd>
    <p>Gives the name or contact information of one of the authors or creators of the work.</p>

    <p>The <a href="#concept-property-value" id="licensing-works:concept-property-value-2">value</a> must be either an <a href="#concept-item" id="licensing-works:concept-item-3">item</a> with the type <code id="licensing-works:md-vcard"><a href="#md-vcard">http://microformats.org/profile/hcard</a></code>, or text.</p>

    <p>Any number of properties with the name <code id="licensing-works:md-work-author"><a href="#md-work-author">author</a></code> may be
    present within each <a href="#concept-item" id="licensing-works:concept-item-4">item</a> with the type <code id="licensing-works:md-work-3"><a href="#md-work">http://n.whatwg.org/work</a></code>.</p>
   </dd><dt><dfn id="md-work-license"><code>license</code></dfn></dt><dd>
    <p>Identifies one of the licenses under which the work is available.</p>

    <p>The <a href="#concept-property-value" id="licensing-works:concept-property-value-3">value</a> must be an <a id="licensing-works:absolute-url-2" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute
    URL</a>.</p>

    <p>Any number of properties with the name <code id="licensing-works:md-work-license"><a href="#md-work-license">license</a></code> may be
    present within each <a href="#concept-item" id="licensing-works:concept-item-5">item</a> with the type <code id="licensing-works:md-work-4"><a href="#md-work">http://n.whatwg.org/work</a></code>.</p>
   </dd></dl>




  <h5 id="examples-4"><span class="secno">5.3.3.1</span> Examples<a href="#examples-4" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <div class="example">

   <p>This example shows an embedded image entitled <cite>My Pond</cite>, licensed under the
   Creative Commons Attribution-Share Alike 4.0 International License and the MIT license
   simultaneously.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">figure</c-> <strong><c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://n.whatwg.org/work"</c-></strong><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">img</c-> <strong><c- e="">itemprop</c-><c- o="">=</c-><c- s="">"work"</c-></strong> <c- e="">src</c-><c- o="">=</c-><c- s="">"mypond.jpeg"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">cite</c-> <strong><c- e="">itemprop</c-><c- o="">=</c-><c- s="">"title"</c-></strong><c- p="">&gt;</c->My Pond<c- p="">&lt;/</c-><c- f="">cite</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">small</c-><c- p="">&gt;</c->Licensed under the <c- p="">&lt;</c-><c- f="">a</c-> <strong><c- e="">itemprop</c-><c- o="">=</c-><c- s="">"license"</c-></strong>
  <c- e="">href</c-><c- o="">=</c-><c- s="">"https://creativecommons.org/licenses/by-sa/4.0/"</c-><c- p="">&gt;</c->Creative
  Commons Attribution-Share Alike 4.0 International License<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
  and the <c- p="">&lt;</c-><c- f="">a</c-> <strong><c- e="">itemprop</c-><c- o="">=</c-><c- s="">"license"</c-></strong>
  <c- e="">href</c-><c- o="">=</c-><c- s="">"http://www.opensource.org/licenses/mit-license.php"</c-><c- p="">&gt;</c->MIT
  license<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->.<c- p="">&lt;/</c-><c- f="">small</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">figcaption</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">figure</c-><c- p="">&gt;</c-></code></pre>

  </div>


  

  <h3 id="converting-html-to-other-formats"><span class="secno">5.4</span> Converting HTML to other formats<a href="#converting-html-to-other-formats" class="self-link"></a></h3>

  <h4 id="json"><span class="secno">5.4.1</span> JSON<a href="#json" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>Given a list of nodes <var>nodes</var> in a <code id="json:document"><a href="#document">Document</a></code>, a user agent must
  run the following algorithm to <dfn id="extracting-json">extract the microdata from those nodes
  into a JSON form</dfn>:</p>

  <ol><li><p>Let <var>result</var> be an empty object.</p></li><li><p>Let <var>items</var> be an empty array.</p></li><li><p>For each <var>node</var> in <var>nodes</var>, check if the element is a
   <a href="#top-level-microdata-items" id="json:top-level-microdata-items">top-level microdata item</a>, and if it is then
   <a href="#get-the-object" id="json:get-the-object">get the object</a> for that element and add it to <var>items</var>.</p></li><li><p>Add an entry to <var>result</var> called "<code>items</code>" whose
   value is the array <var>items</var>.</p></li><li><p>Return the result of serializing <var>result</var> to JSON in the shortest
   possible way (meaning no whitespace between tokens, no unnecessary zero digits in numbers, and
   only using Unicode escapes in strings for characters that do not have a dedicated escape
   sequence), and with a lowercase "<code>e</code>" used, when appropriate, in the
   representation of any numbers. <a href="#refsJSON">[JSON]</a></p></li></ol>
  </div>

  <p class="note">This algorithm returns an object with a single property that is an array, instead
  of just returning an array, so that it is possible to extend the algorithm in the future if
  necessary.</p>

  <div data-algorithm="">
  <p>When the user agent is to <dfn id="get-the-object">get the object</dfn> for an item <var>item</var>,
  optionally with a list of elements <var>memory</var>, it must run the following
  substeps:</p>

  <ol><li><p>Let <var>result</var> be an empty object.</p></li><li><p>If no <var>memory</var> was passed to the algorithm, let <var>memory</var> be an empty list.</p></li><li><p>Add <var>item</var> to <var>memory</var>.</p></li><li><p>If the <var>item</var> has any <a href="#item-types" id="json:item-types">item types</a>, add an entry to <var>result</var> called "<code>type</code>" whose value is an array listing the
   <a href="#item-types" id="json:item-types-2">item types</a> of <var>item</var>, in the order they were specified on the
   <code id="json:attr-itemtype"><a href="#attr-itemtype">itemtype</a></code> attribute.</p>

   </li><li><p>If the <var>item</var> has a <a href="#global-identifier" id="json:global-identifier">global identifier</a>, add an entry to <var>result</var> called "<code>id</code>" whose value is the <a href="#global-identifier" id="json:global-identifier-2">global
   identifier</a> of <var>item</var>.</p></li><li><p>Let <var>properties</var> be an empty object.</p></li><li>
    <p>For each element <var>element</var> that has one or more <a href="#property-names" id="json:property-names">property names</a>
    and is one of <a href="#the-properties-of-an-item" id="json:the-properties-of-an-item">the properties of the item</a> <var>item</var>, in the order those elements are given by the algorithm that returns
    <a href="#the-properties-of-an-item" id="json:the-properties-of-an-item-2">the properties of an item</a>, run the following substeps:</p>

    <ol><li><p>Let <var>value</var> be the <a href="#concept-property-value" id="json:concept-property-value">property
     value</a> of <var>element</var>.</p></li><li><p>If <var>value</var> is an <a href="#concept-item" id="json:concept-item">item</a>, then: If <var>value</var> is in <var>memory</var>, then let <var>value</var> be
     the string "<code>ERROR</code>". Otherwise, <a href="#get-the-object" id="json:get-the-object-2">get the object</a> for <var>value</var>, passing a copy of <var>memory</var>, and then replace <var>value</var> with the object returned from those steps.</p></li><li>
      <p>For each name <var>name</var> in <var>element</var>'s <a href="#property-names" id="json:property-names-2">property
      names</a>, run the following substeps:</p>

      <ol><li><p>If there is no entry named <var>name</var> in <var>properties</var>,
       then add an entry named <var>name</var> to <var>properties</var> whose
       value is an empty array.</p></li><li><p>Append <var>value</var> to the entry named <var>name</var> in <var>properties</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Add an entry to <var>result</var> called "<code>properties</code>" whose
   value is the object <var>properties</var>.</p></li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <div class="example">

   <p>For example, take this markup:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->My Blog<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/BlogPosting"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">header</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"headline"</c-><c- p="">&gt;</c->Progress report<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"datePublished"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2013-08-29"</c-><c- p="">&gt;</c->today<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?comments=0"</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">header</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->All in all, he's doing well with his swim lessons. The biggest thing was he had trouble
 putting his head in, but we got it down.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Comments<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"comment"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/UserComments"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"c1"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#c1"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Posted by: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"creator"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Person"</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Greg<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"commentTime"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2013-08-29"</c-><c- p="">&gt;</c->15 minutes ago<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Ha!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">article</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"comment"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/UserComments"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"c2"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">link</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"#c2"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">footer</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Posted by: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"creator"</c-> <c- e="">itemscope</c-> <c- e="">itemtype</c-><c- o="">=</c-><c- s="">"http://schema.org/Person"</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"name"</c-><c- p="">&gt;</c->Charlotte<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">time</c-> <c- e="">itemprop</c-><c- o="">=</c-><c- s="">"commentTime"</c-> <c- e="">datetime</c-><c- o="">=</c-><c- s="">"2013-08-29"</c-><c- p="">&gt;</c->5 minutes ago<c- p="">&lt;/</c-><c- f="">time</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">footer</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->When you say "we got it down"...<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <p>It would be turned into the following JSON by the algorithm above (supposing that the page's
   URL was <code>https://blog.example.com/progress-report</code>):</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"items"</c-><c- o="">:</c-> <c- p="">[</c->
    <c- p="">{</c->
      <c- u="">"type"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"http://schema.org/BlogPosting"</c-> <c- p="">],</c->
      <c- u="">"properties"</c-><c- o="">:</c-> <c- p="">{</c->
        <c- u="">"headline"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"Progress report"</c-> <c- p="">],</c->
        <c- u="">"datePublished"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"2013-08-29"</c-> <c- p="">],</c->
        <c- u="">"url"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"https://blog.example.com/progress-report?comments=0"</c-> <c- p="">],</c->
        <c- u="">"comment"</c-><c- o="">:</c-> <c- p="">[</c->
          <c- p="">{</c->
            <c- u="">"type"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"http://schema.org/UserComments"</c-> <c- p="">],</c->
            <c- u="">"properties"</c-><c- o="">:</c-> <c- p="">{</c->
              <c- u="">"url"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"https://blog.example.com/progress-report#c1"</c-> <c- p="">],</c->
              <c- u="">"creator"</c-><c- o="">:</c-> <c- p="">[</c->
                <c- p="">{</c->
                  <c- u="">"type"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"http://schema.org/Person"</c-> <c- p="">],</c->
                  <c- u="">"properties"</c-><c- o="">:</c-> <c- p="">{</c->
                    <c- u="">"name"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"Greg"</c-> <c- p="">]</c->
                  <c- p="">}</c->
                <c- p="">}</c->
              <c- p="">],</c->
              <c- u="">"commentTime"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"2013-08-29"</c-> <c- p="">]</c->
            <c- p="">}</c->
          <c- p="">},</c->
          <c- p="">{</c->
            <c- u="">"type"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"http://schema.org/UserComments"</c-> <c- p="">],</c->
            <c- u="">"properties"</c-><c- o="">:</c-> <c- p="">{</c->
              <c- u="">"url"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"https://blog.example.com/progress-report#c2"</c-> <c- p="">],</c->
              <c- u="">"creator"</c-><c- o="">:</c-> <c- p="">[</c->
                <c- p="">{</c->
                  <c- u="">"type"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"http://schema.org/Person"</c-> <c- p="">],</c->
                  <c- u="">"properties"</c-><c- o="">:</c-> <c- p="">{</c->
                    <c- u="">"name"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"Charlotte"</c-> <c- p="">]</c->
                  <c- p="">}</c->
                <c- p="">}</c->
              <c- p="">],</c->
              <c- u="">"commentTime"</c-><c- o="">:</c-> <c- p="">[</c-> <c- u="">"2013-08-29"</c-> <c- p="">]</c->
            <c- p="">}</c->
          <c- p="">}</c->
        <c- p="">]</c->
      <c- p="">}</c->
    <c- p="">}</c->
  <c- p="">]</c->
<c- p="">}</c-></code></pre>

  </div>

  




  <h2 id="editing"><span class="secno">6</span> <dfn>User interaction</dfn><a href="#editing" class="self-link"></a></h2>


  <h3 id="the-hidden-attribute"><span class="secno">6.1</span> The <code id="the-hidden-attribute:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute<a href="#the-hidden-attribute" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden" title="The hidden global attribute is an enumerated attribute indicating that the browser should not render the contents of the element. For example, it can be used to hide elements of the page that can't be used until the login process has been completed.">Global_attributes/hidden</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>102+</span></span><hr><span class="opera no"><span>Opera</span><span>No</span></span><span class="edge_blink yes"><span>Edge</span><span>102+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden" title="The hidden global attribute is an enumerated attribute indicating that the browser should not render the contents of the element. For example, it can be used to hide elements of the page that can't be used until the login process has been completed.">Global_attributes/hidden</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>All <a href="#html-elements" id="the-hidden-attribute:html-elements">HTML elements</a> may have the <dfn data-dfn-for="html-global" id="attr-hidden" data-dfn-type="element-attr"><code>hidden</code></dfn> content attribute set. The <code id="the-hidden-attribute:attr-hidden-2"><a href="#attr-hidden">hidden</a></code> attribute is an <a href="#enumerated-attribute" id="the-hidden-attribute:enumerated-attribute">enumerated attribute</a> with the
  following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/hidden" id="attr-hidden-hidden" data-dfn-type="attr-value"><code>hidden</code></dfn>
     </td><td><dfn id="attr-hidden-hidden-state">Hidden</dfn>
     </td><td>Will not be rendered.
    </td></tr><tr><td><dfn data-dfn-for="html-global/hidden" id="attr-hidden-until-found" data-dfn-type="attr-value"><code>until-found</code></dfn>
     </td><td><dfn id="attr-hidden-until-found-state">Hidden Until Found</dfn>
     </td><td>Will not be rendered, but content inside will be accessible to <a href="#find-in-page-2" id="the-hidden-attribute:find-in-page-2">find-in-page</a>
     and <a href="#navigate-fragid" id="the-hidden-attribute:navigate-fragid">fragment navigation</a>.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-hidden-attribute:missing-value-default"><a href="#missing-value-default">missing value default</a></i> is the <dfn id="attr-hidden-not-hidden-state">Not Hidden</dfn> state, and its <i id="the-hidden-attribute:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> and <i id="the-hidden-attribute:empty-value-default"><a href="#empty-value-default">empty value default</a></i> are
  both the <a href="#attr-hidden-hidden-state" id="the-hidden-attribute:attr-hidden-hidden-state">Hidden</a> state.</p>
  </div>

  <p>When an element has the <code id="the-hidden-attribute:attr-hidden-3"><a href="#attr-hidden">hidden</a></code> attribute in the <a href="#attr-hidden-hidden-state" id="the-hidden-attribute:attr-hidden-hidden-state-2">Hidden</a> 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 <a href="#attr-hidden-hidden-state" id="the-hidden-attribute:attr-hidden-hidden-state-3">Hidden</a> state.</p>

  

  <p class="note">The requirement for user agents not to render elements that are in the <a href="#attr-hidden-hidden-state" id="the-hidden-attribute:attr-hidden-hidden-state-4">Hidden</a> state can be implemented indirectly through the
  style layer. For example, a web browser could implement these requirements <a href="#hiddenCSS">using the rules suggested in the Rendering section</a>.</p>

  

  <p>When an element has the <code id="the-hidden-attribute:attr-hidden-4"><a href="#attr-hidden">hidden</a></code> attribute in the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state">Hidden Until Found</a> state, it indicates that the
  element is hidden like the <a href="#attr-hidden-hidden-state" id="the-hidden-attribute:attr-hidden-hidden-state-5">Hidden</a> state but the
  content inside the element will be accessible to <a href="#find-in-page-2" id="the-hidden-attribute:find-in-page-2-2">find-in-page</a> and <a href="#navigate-fragid" id="the-hidden-attribute:navigate-fragid-2">fragment navigation</a>. When these features attempt to scroll to a
  target which is in the element's subtree, the user agent will remove the <code id="the-hidden-attribute:attr-hidden-5"><a href="#attr-hidden">hidden</a></code> attribute in order to reveal the content before scrolling to
  it by running the <a href="#ancestor-revealing-algorithm" id="the-hidden-attribute:ancestor-revealing-algorithm">ancestor revealing algorithm</a> on the target node.</p>

  

  <p class="note">Web browsers will use 'content-visibility: hidden' instead of 'display: none'
  when the <code id="the-hidden-attribute:attr-hidden-6"><a href="#attr-hidden">hidden</a></code> attribute is in the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-2">Hidden Until Found</a> state, as specified in the <a href="#hiddenCSS">Rendering section</a>.</p>

  


  <div class="note">
   <p>Because this attribute is typically implemented using CSS, it's also possible to override it
   using CSS. For instance, a rule that applies 'display: block' to all elements will cancel the
   effects of the <a href="#attr-hidden-hidden-state" id="the-hidden-attribute:attr-hidden-hidden-state-6">Hidden</a> state. Authors therefore
   have to take care when writing their style sheets to make sure that the attribute is still styled
   as expected. In addition, legacy user agents which don't support the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-3">Hidden Until Found</a> 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 <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-4">Hidden Until Found</a> elements.</p>

   <p>Since elements with the <code id="the-hidden-attribute:attr-hidden-7"><a href="#attr-hidden">hidden</a></code> attribute in the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-5">Hidden Until Found</a> state use 'content-visibility:
   hidden' instead of 'display: none', there are two caveats of the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-6">Hidden Until Found</a> state that make it different
   from the <a href="#attr-hidden-hidden-state" id="the-hidden-attribute:attr-hidden-hidden-state-7">Hidden</a> state:</p>

   <ol><li><p>The element needs to be affected by <a id="the-hidden-attribute:layout-containment" href="https://drafts.csswg.org/css-contain/#containment-layout" data-x-internal="layout-containment">layout containment</a> in order to be
    revealed by find-in-page. This means that if the element in the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-7">Hidden Until Found</a> state has a 'display' value of
    'none', 'contents', or 'inline', then the element will not be revealed by find-in-page.</p></li><li><p>The element will still have a <a href="https://drafts.csswg.org/css2/#propdef-visibility" id="the-hidden-attribute:'visibility'" data-x-internal="'visibility'">generated box</a> when in
    the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-8">Hidden Until Found</a> state, which means
    that borders, margin, and padding will still be rendered around the element.</p></li></ol>
  </div>

  <div class="example">

   <p>In the following skeletal example, the attribute is used to hide the web game's main screen
   until the user logs in:</p>

   <pre><code class="html">  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->The Example Game<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">section</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"login"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Login<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
    ...
    <c- c="">&lt;!-- calls login() once the user's credentials have been checked --&gt;</c->
   <c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
    <c- a="">function</c-> login<c- p="">()</c-> <c- p="">{</c->
      <c- c1="">// switch screens</c->
      document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'login'</c-><c- p="">).</c->hidden <c- o="">=</c-> <c- kc="">true</c-><c- p="">;</c->
      document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'game'</c-><c- p="">).</c->hidden <c- o="">=</c-> <c- kc="">false</c-><c- p="">;</c->
    <c- p="">}</c->
   <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">section</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"game"</c-> <c- e="">hidden</c-><c- p="">&gt;</c->
   ...
  <c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>The <code id="the-hidden-attribute:attr-hidden-8"><a href="#attr-hidden">hidden</a></code> attribute must not be used to hide content that
  could legitimately be shown in another presentation. For example, it is incorrect to use <code id="the-hidden-attribute:attr-hidden-9"><a href="#attr-hidden">hidden</a></code> to hide panels in a tabbed dialog, because the tabbed interface
  is merely a kind of overflow presentation — one could equally well just show all the form
  controls in one big page with a scrollbar. It is similarly incorrect to use this attribute to hide
  content just from one presentation — if something is marked <code id="the-hidden-attribute:attr-hidden-10"><a href="#attr-hidden">hidden</a></code>, it is hidden from all presentations, including, for instance,
  screen readers.</p>

  
  

  <p>Elements that are not themselves <code id="the-hidden-attribute:attr-hidden-11"><a href="#attr-hidden">hidden</a></code> must not
  <a href="#hyperlink" id="the-hidden-attribute:hyperlink">hyperlink</a> to elements that are <code id="the-hidden-attribute:attr-hidden-12"><a href="#attr-hidden">hidden</a></code>. The <code>for</code> attributes of <code id="the-hidden-attribute:the-label-element"><a href="#the-label-element">label</a></code> and <code id="the-hidden-attribute:the-output-element"><a href="#the-output-element">output</a></code> elements that are not
  themselves <code id="the-hidden-attribute:attr-hidden-13"><a href="#attr-hidden">hidden</a></code> must similarly not refer to elements that are
  <code id="the-hidden-attribute:attr-hidden-14"><a href="#attr-hidden">hidden</a></code>. In both cases, such references would cause user
  confusion.</p>

  <p>Elements and scripts may, however, refer to elements that are <code id="the-hidden-attribute:attr-hidden-15"><a href="#attr-hidden">hidden</a></code> in other contexts.</p>

  <div class="example">

   <p>For example, it would be incorrect to use the <code id="the-hidden-attribute:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code>
   attribute to link to a section marked with the <code id="the-hidden-attribute:attr-hidden-16"><a href="#attr-hidden">hidden</a></code> attribute.
   If the content is not applicable or relevant, then there is no reason to link to it.</p>

   <p>It would be fine, however, to use the ARIA <code id="the-hidden-attribute:attr-aria-describedby"><a data-x-internal="attr-aria-describedby" href="https://w3c.github.io/aria/#aria-describedby">aria-describedby</a></code> attribute to refer to descriptions that are
   themselves <code id="the-hidden-attribute:attr-hidden-17"><a href="#attr-hidden">hidden</a></code>. While hiding the descriptions implies that
   they are not useful alone, they could be written in such a way that they are useful in the
   specific context of being referenced from the elements that they describe.</p>

   <p>Similarly, a <code id="the-hidden-attribute:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element with the <code id="the-hidden-attribute:attr-hidden-18"><a href="#attr-hidden">hidden</a></code>
   attribute could be used by a scripted graphics engine as an off-screen buffer, and a form control
   could refer to a hidden <code id="the-hidden-attribute:the-form-element"><a href="#the-form-element">form</a></code> element using its <code id="the-hidden-attribute:attr-fae-form"><a href="#attr-fae-form">form</a></code> attribute.</p>

  </div>

  <p>Elements in a section hidden by the <code id="the-hidden-attribute:attr-hidden-19"><a href="#attr-hidden">hidden</a></code> attribute are still
  active, e.g. scripts and form controls in such sections still execute and submit respectively.
  Only their presentation to the user changes.</p>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/hidden" title="The HTMLElement property hidden reflects the value of the element's hidden attribute.">HTMLElement/hidden</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-hidden" data-dfn-type="attribute"><code>hidden</code></dfn> getter steps
  are:</p>

  <ol><li><p>If the <code id="the-hidden-attribute:attr-hidden-20"><a href="#attr-hidden">hidden</a></code> attribute is in the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-9">Hidden Until Found</a> state, then return "<code id="the-hidden-attribute:attr-hidden-until-found"><a href="#attr-hidden-until-found">until-found</a></code>".</p></li><li><p>If the <code id="the-hidden-attribute:attr-hidden-21"><a href="#attr-hidden">hidden</a></code> attribute is set, then return
   true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-hidden-attribute:dom-hidden"><a href="#dom-hidden">hidden</a></code> setter steps are:</p>

  <ol><li><p>If the given value is a string that is an <a id="the-hidden-attribute:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
   "<code id="the-hidden-attribute:attr-hidden-until-found-2"><a href="#attr-hidden-until-found">until-found</a></code>", then set the <code id="the-hidden-attribute:attr-hidden-22"><a href="#attr-hidden">hidden</a></code> attribute to "<code id="the-hidden-attribute:attr-hidden-until-found-3"><a href="#attr-hidden-until-found">until-found</a></code>".</p></li><li><p>Otherwise, if the given value is false, then remove the <code id="the-hidden-attribute:attr-hidden-23"><a href="#attr-hidden">hidden</a></code> attribute.</p></li><li><p>Otherwise, if the given value is the empty string, then remove the <code id="the-hidden-attribute:attr-hidden-24"><a href="#attr-hidden">hidden</a></code> attribute.</p></li><li><p>Otherwise, if the given value is null, then remove the <code id="the-hidden-attribute:attr-hidden-25"><a href="#attr-hidden">hidden</a></code> attribute.</p></li><li><p>Otherwise, if the given value is 0, then remove the <code id="the-hidden-attribute:attr-hidden-26"><a href="#attr-hidden">hidden</a></code> attribute.</p></li><li><p>Otherwise, if the given value is NaN, then remove the <code id="the-hidden-attribute:attr-hidden-27"><a href="#attr-hidden">hidden</a></code> attribute.</p></li><li><p>Otherwise, set the <code id="the-hidden-attribute:attr-hidden-28"><a href="#attr-hidden">hidden</a></code> attribute to the empty
   string.</p></li></ol>
  </div>

  <p>An <dfn id="ancestor-reveal-pair">ancestor reveal pair</dfn> is a <a id="the-hidden-attribute:tuple" href="https://infra.spec.whatwg.org/#tuple" data-x-internal="tuple">tuple</a> consisting of a <dfn id="ancestor-reveal-pair-node">node</dfn> and a <dfn id="ancestor-reveal-pair-string">string</dfn>.</p>

  <div data-algorithm="">
  <p>The <dfn id="ancestor-revealing-algorithm">ancestor revealing algorithm</dfn> given a node <var>target</var> is:</p>

  <ol><li><p>Let <var>ancestorsToReveal</var> be « ».</p></li><li><p>Let <var>ancestor</var> be <var>target</var>.</p></li><li>
    <p>While <var>ancestor</var> has a parent node within the <a id="the-hidden-attribute:flat-tree" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a>:</p>

    <ol><li><p>If <var>ancestor</var> has a <code id="the-hidden-attribute:attr-hidden-29"><a href="#attr-hidden">hidden</a></code> attribute in the
     <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-10">Hidden Until Found</a> state, then <a href="https://infra.spec.whatwg.org/#list-append" id="the-hidden-attribute:list-append" data-x-internal="list-append">append</a> (<var>ancestor</var>, "<code>until-found</code>")
     to <var>ancestorsToReveal</var>.</p></li><li><p>If <var>ancestor</var> is slotted into the second slot of a <code id="the-hidden-attribute:the-details-element"><a href="#the-details-element">details</a></code>
     element which does not have an <code id="the-hidden-attribute:attr-details-open"><a href="#attr-details-open">open</a></code> attribute, then
     <a href="https://infra.spec.whatwg.org/#list-append" id="the-hidden-attribute:list-append-2" data-x-internal="list-append">append</a> (<var>ancestor</var>'s parent node, "<code>details</code>") to <var>ancestorsToReveal</var>.</p></li><li><p>Set <var>ancestor</var> to the parent node of <var>ancestor</var> within the
     <a id="the-hidden-attribute:flat-tree-2" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a>.</p></li></ol>
   </li><li>
    <p>For each (<var>ancestorToReveal</var>, <var>revealType</var>) of
    <var>ancestorsToReveal</var>:</p>

    <ol><li><p>If <var>ancestorToReveal</var> is not <a id="the-hidden-attribute:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li>
      <p>If <var>revealType</var> is "<code>until-found</code>":</p>

      <ol><li><p>If <var>ancestorToReveal</var>'s <code id="the-hidden-attribute:attr-hidden-30"><a href="#attr-hidden">hidden</a></code> attribute is
       not in the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-11">Hidden Until Found</a> state, then
       return.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-hidden-attribute:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-hidden-attribute:event-beforematch"><a href="#event-beforematch">beforematch</a></code> at <var>ancestorToReveal</var> with the <code id="the-hidden-attribute:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to true.</p></li><li><p>If <var>ancestorToReveal</var> is not <a id="the-hidden-attribute:connected-2" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>, then return.</p></li><li><p>If <var>ancestorToReveal</var>'s <code id="the-hidden-attribute:attr-hidden-31"><a href="#attr-hidden">hidden</a></code> attribute is
       not in the <a href="#attr-hidden-until-found-state" id="the-hidden-attribute:attr-hidden-until-found-state-12">Hidden Until Found</a> state, then
       return.</p></li><li><p>Remove the <code id="the-hidden-attribute:attr-hidden-32"><a href="#attr-hidden">hidden</a></code> attribute from
       <var>ancestorToReveal</var>.</p></li></ol>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p><a id="the-hidden-attribute:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>revealType</var> is "<code>details</code>".</p></li><li><p>If <var>ancestorToReveal</var> has an <code id="the-hidden-attribute:attr-details-open-2"><a href="#attr-details-open">open</a></code>
       attribute, then return.</p></li><li><p>Set <var>ancestorToReveal</var>'s <code id="the-hidden-attribute:attr-details-open-3"><a href="#attr-details-open">open</a></code>
       attribute to the empty string.</p></li></ol>
     </li></ol>
   </li></ol>
  </div>

  

  <h3 id="page-visibility"><span class="secno">6.2</span> Page visibility<a href="#page-visibility" class="self-link"></a></h3>

  <p>A <a href="#traversable-navigable" id="page-visibility:traversable-navigable">traversable navigable</a>'s <a href="#system-visibility-state" id="page-visibility:system-visibility-state">system visibility state</a>, including its
  initial value upon creation, is determined by the user agent. It represents, for example, whether
  the browser window is minimized, a browser tab is currently in the background, or a system
  element such as a task switcher obscures the page.</p>

  <div data-algorithm="">
  <p>When a user agent determines that the <a href="#system-visibility-state" id="page-visibility:system-visibility-state-2">system visibility state</a> for
  <a href="#traversable-navigable" id="page-visibility:traversable-navigable-2">traversable navigable</a> <var>traversable</var> has changed to <var>newState</var>, it
  must run the following steps:</p>

  <ol><li><p>Let <var>navigables</var> be the <a href="#inclusive-descendant-navigables" id="page-visibility:inclusive-descendant-navigables">inclusive descendant navigables</a> of
   <var>traversable</var>'s <a href="#nav-document" id="page-visibility:nav-document">active document</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="page-visibility:list-iterate" data-x-internal="list-iterate">For each</a> <var>navigable</var> of <var>navigables</var>
    <span class="XXX">in what order?</span>:</p>

    <ol><li><p>Let <var>document</var> be <var>navigable</var>'s <a href="#nav-document" id="page-visibility:nav-document-2">active
     document</a>.</p></li><li><p><a href="#queue-a-global-task" id="page-visibility:queue-a-global-task">Queue a global task</a> on the <a href="#user-interaction-task-source" id="page-visibility:user-interaction-task-source">user interaction task source</a> given
     <var>document</var>'s <a href="#concept-relevant-global" id="page-visibility:concept-relevant-global">relevant global object</a> to <a href="#update-the-visibility-state" id="page-visibility:update-the-visibility-state">update the visibility
     state</a> of <var>document</var> with <var>newState</var>.</p></li></ol>
   </li></ol>
  </div>

  <p>A <code id="page-visibility:document"><a href="#document">Document</a></code> has a <dfn data-dfn-for="Document" id="visibility-state" data-export="">visibility state</dfn>, which is
  either "<code>hidden</code>" or "<code>visible</code>", initially set to
  "<code>hidden</code>".</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState" title="The Document.visibilityState read-only property returns the visibility of the document, that is in which context this element is now visible. It is useful to know if the document is in the background or an invisible tab, or only loaded for pre-rendering.">Document/visibilityState</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>18+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>33+</span></span><hr><span class="opera yes"><span>Opera</span><span>20+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4.3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>20+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-visibilitystate" data-dfn-type="attribute"><code>visibilityState</code></dfn> getter steps are to return
  <a id="page-visibility:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#visibility-state" id="page-visibility:visibility-state">visibility state</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/hidden" title="The Document.hidden read-only property returns a Boolean value indicating if the page is considered hidden or not.">Document/hidden</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>18+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>33+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4.3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-hidden" data-dfn-type="attribute"><code>hidden</code></dfn> getter
  steps are to return true if <a id="page-visibility:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#visibility-state" id="page-visibility:visibility-state-2">visibility state</a> is
  "<code>hidden</code>", otherwise false.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="update-the-visibility-state">update the visibility state</dfn> of <code id="page-visibility:document-2"><a href="#document">Document</a></code> <var>document</var> to
  <var>visibilityState</var>:</p>

  <ol><li><p>If <var>document</var>'s <a href="#visibility-state" id="page-visibility:visibility-state-3">visibility state</a> equals <var>visibilityState</var>,
   then return.</p></li><li><p>Set <var>document</var>'s <a href="#visibility-state" id="page-visibility:visibility-state-4">visibility state</a> to
   <var>visibilityState</var>.</p></li><li><p><a href="https://w3c.github.io/performance-timeline/#queue-a-performanceentry" id="page-visibility:queue-a-performance-entry" data-x-internal="queue-a-performance-entry">Queue</a> a new
   <code id="page-visibility:visibilitystateentry"><a href="#visibilitystateentry">VisibilityStateEntry</a></code> whose
   <a href="#visibilitystateentry-state" id="page-visibility:visibilitystateentry-state">visibility state</a> is
   <var>visibilityState</var> and whose <a href="#visibilitystateentry-timestamp" id="page-visibility:visibilitystateentry-timestamp">timestamp</a> is
   the <a id="page-visibility:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given <var>document</var>'s
   <a href="#concept-relevant-global" id="page-visibility:concept-relevant-global-2">relevant global object</a>.</p>

   </li><li><p>Run the <a id="page-visibility:screen-orientation-change-steps" href="https://w3c.github.io/screen-orientation/#dfn-screen-orientation-change-steps" data-x-internal="screen-orientation-change-steps">screen orientation change steps</a> with <var>document</var>.
   <a href="#refsSCREENORIENTATION">[SCREENORIENTATION]</a></p></li><li><p>Run the <a id="page-visibility:view-transition-page-visibility-change-steps" href="https://drafts.csswg.org/css-view-transitions/#view-transition-page-visibility-change-steps" data-x-internal="view-transition-page-visibility-change-steps">view transition page visibility change steps</a> with
   <var>document</var>.</p></li><li>
    <p>Run any <dfn id="page-visibility-change-steps" data-export="">page visibility change steps</dfn> which may be defined in other
    specifications, with <a href="#visibility-state" id="page-visibility:visibility-state-5">visibility state</a> and <var>document</var>.</p>

    <p class="XXX">It would be better if specification authors sent a pull request to add calls
    from here into their specifications directly, instead of using the <a href="#page-visibility-change-steps" id="page-visibility:page-visibility-change-steps">page visibility change
    steps</a> hook, to ensure well-defined cross-specification call order. As of the time of
    this writing the following specifications are known to have <a href="#page-visibility-change-steps" id="page-visibility:page-visibility-change-steps-2">page visibility change
    steps</a>, which will be run in an unspecified order: <cite>Device Posture API</cite> and
    <cite>Web NFC</cite>. <a href="#refsDEVICEPOSTURE">[DEVICEPOSTURE]</a> <a href="#refsWEBNFC">[WEBNFC]</a></p>
   </li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="page-visibility:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="page-visibility:event-visibilitychange"><a href="#event-visibilitychange">visibilitychange</a></code> at
   <var>document</var>, with its <code id="page-visibility:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute
   initialized to true.</p></li></ol>
  </div>

  <h4 id="the-visibilitystateentry-interface"><span class="secno">6.2.1</span> The <code id="the-visibilitystateentry-interface:visibilitystateentry"><a href="#visibilitystateentry">VisibilityStateEntry</a></code> interface<a href="#the-visibilitystateentry-interface" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/VisibilityStateEntry" title="The VisibilityStateEntry interface provides timings of page visibility state changes, i.e., when a tab changes from the foreground to the background or vice versa.">VisibilityStateEntry</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>115+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>115+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="the-visibilitystateentry-interface:visibilitystateentry-2"><a href="#visibilitystateentry">VisibilityStateEntry</a></code> interface exposes visibility changes to the document,
  from the moment the document becomes active.</p>

  <div class="example">For example, this allows JavaScript code in the page to examine correlation
  between visibility changes and paint timing:

  <pre><code class="js"><c- a="">function</c-> wasHiddenBeforeFirstContentfulPaint<c- p="">()</c-> <c- p="">{</c->
    <c- a="">const</c-> fcpEntry <c- o="">=</c-> performance<c- p="">.</c->getEntriesByName<c- p="">(</c-><c- u="">"first-contentful-paint"</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
    <c- a="">const</c-> visibilityStateEntries <c- o="">=</c-> performance<c- p="">.</c->getEntriesByType<c- p="">(</c-><c- u="">"visibility-state"</c-><c- p="">);</c->
    <c- k="">return</c-> visibilityStateEntries<c- p="">.</c->some<c- p="">(</c->e <c- p="">=&gt;</c->
                                            e<c- p="">.</c->startTime <c- o="">&lt;</c-> fcpEntry<c- p="">.</c->startTime <c- o="">&amp;&amp;</c->
                                            e<c- p="">.</c->name <c- o="">===</c-> <c- u="">"hidden"</c-><c- p="">);</c->
<c- p="">}</c-></code></pre>
  </div>

  <p class="note">Since hiding a page can cause throttling of rendering and other user-agent
  operations, it is common to use visibility changes as an indication that such throttling has
  occurred. However, other things could also cause throttling in different browsers, such as
  long periods of inactivity.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->)]
<c- b="">interface</c-> <dfn id="visibilitystateentry" data-dfn-type="interface"><c- g="">VisibilityStateEntry</c-></dfn> : <a id="the-visibilitystateentry-interface:performanceentry" href="https://w3c.github.io/performance-timeline/#dom-performanceentry" data-x-internal="performanceentry"><c- n="">PerformanceEntry</c-></a> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#visibilitystateentry-name" id="the-visibilitystateentry-interface:visibilitystateentry-name"><c- g="">name</c-></a>;                 // shadows inherited <a href="https://w3c.github.io/performance-timeline/#dom-performanceentry-name" id="the-visibilitystateentry-interface:performanceentry-name" data-x-internal="performanceentry-name">name</a>
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#visibilitystateentry-entrytype" id="the-visibilitystateentry-interface:visibilitystateentry-entrytype"><c- g="">entryType</c-></a>;            // shadows inherited <a href="https://w3c.github.io/performance-timeline/#dom-performanceentry-entrytype" id="the-visibilitystateentry-interface:performanceentry-entrytype" data-x-internal="performanceentry-entrytype">entryType</a>
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- n="">DOMHighResTimeStamp</c-> <a href="#visibilitystateentry-starttime" id="the-visibilitystateentry-interface:visibilitystateentry-starttime"><c- g="">startTime</c-></a>;  // shadows inherited <a href="https://w3c.github.io/performance-timeline/#dom-performanceentry-starttime" id="the-visibilitystateentry-interface:performanceentry-starttime" data-x-internal="performanceentry-starttime">startTime</a>
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#visibilitystateentry-duration" id="the-visibilitystateentry-interface:visibilitystateentry-duration"><c- g="">duration</c-></a>;         // shadows inherited <a href="https://w3c.github.io/performance-timeline/#dom-performanceentry-duration" id="the-visibilitystateentry-interface:performanceentry-duration" data-x-internal="performanceentry-duration">duration</a>
};</code></pre>

  <p>The <code id="the-visibilitystateentry-interface:visibilitystateentry-3"><a href="#visibilitystateentry">VisibilityStateEntry</a></code> has an associated
  <a id="the-visibilitystateentry-interface:domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp" data-x-internal="domhighrestimestamp"><code>DOMHighResTimeStamp</code></a>
  <dfn id="visibilitystateentry-timestamp">timestamp</dfn>.</p>

  <p>The <code id="the-visibilitystateentry-interface:visibilitystateentry-4"><a href="#visibilitystateentry">VisibilityStateEntry</a></code> has an associated "<code>visible</code>" or
  "<code>hidden</code>" <dfn id="visibilitystateentry-state">visibility
  state</dfn>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="VisibilityStateEntry" id="visibilitystateentry-name" data-dfn-type="attribute"><code>name</code></dfn> getter steps are to return
  <a id="the-visibilitystateentry-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#visibilitystateentry-state" id="the-visibilitystateentry-interface:visibilitystateentry-state">visibility state</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="VisibilityStateEntry" id="visibilitystateentry-entrytype" data-dfn-type="attribute"><code>entryType</code></dfn> getter steps are to return
  "<code>visibility-state</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="VisibilityStateEntry" id="visibilitystateentry-starttime" data-dfn-type="attribute"><code>startTime</code></dfn> getter steps are to return
  <a id="the-visibilitystateentry-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#visibilitystateentry-timestamp" id="the-visibilitystateentry-interface:visibilitystateentry-timestamp">timestamp</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="VisibilityStateEntry" id="visibilitystateentry-duration" data-dfn-type="attribute"><code>duration</code></dfn> getter steps are to return
  zero.</p>
  </div>


  <h3 id="inert-subtrees"><span class="secno">6.3</span> Inert subtrees<a href="#inert-subtrees" class="self-link"></a></h3>

  <p class="note">See also <code id="inert-subtrees:the-inert-attribute"><a href="#the-inert-attribute">inert</a></code> for an explanation of the
  attribute of the same name.</p>

  <p>A node (in particular elements and text nodes) can be <dfn id="inert">inert</dfn>. When a node is
  <a href="#inert" id="inert-subtrees:inert">inert</a>:</p>

  <ul><li><p>Hit-testing must act as if the <a id="inert-subtrees:'pointer-events'" href="https://drafts.csswg.org/css-ui-4/#pointer-events-control" data-x-internal="'pointer-events'">'pointer-events'</a> CSS property were set to
   'none'.</p></li><li><p>Text selection functionality must act as if the <a id="inert-subtrees:'user-select'" href="https://drafts.csswg.org/css-ui-4/#content-selection" data-x-internal="'user-select'">'user-select'</a> CSS property
   were set to 'none'.</p></li><li><p>If it is <a id="inert-subtrees:editable" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a>, the node behaves as if it were non-editable.</p></li><li><p>The user agent should ignore the node for the purposes of <a href="#find-in-page-2" id="inert-subtrees:find-in-page-2">find-in-page</a>.</p></li></ul>

  <p class="note">Inert nodes generally cannot be focused, and user agents do not expose the inert
  nodes to accessibility APIs or assistive technologies. Inert nodes that are <a href="#concept-command" id="inert-subtrees:concept-command">commands</a> will become inoperable to users, in the manner described
  above.</p>

  <p>User agents may allow the user to override the restrictions on <a href="#find-in-page-2" id="inert-subtrees:find-in-page-2-2">find-in-page</a> and
  text selection, however.</p>

  <p>By default, a node is not <a href="#inert" id="inert-subtrees:inert-2">inert</a>.</p>

  <h4 id="modal-dialogs-and-inert-subtrees"><span class="secno">6.3.1</span> Modal dialogs and inert subtrees<a href="#modal-dialogs-and-inert-subtrees" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A <code id="modal-dialogs-and-inert-subtrees:document"><a href="#document">Document</a></code> <var>document</var> is <dfn id="blocked-by-a-modal-dialog">blocked by a modal dialog</dfn>
  <var>subject</var> if <var>subject</var> is the topmost <code id="modal-dialogs-and-inert-subtrees:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> element in
  <var>document</var>'s <a id="modal-dialogs-and-inert-subtrees:top-layer" href="https://drafts.csswg.org/css-position-4/#document-top-layer" data-x-internal="top-layer">top layer</a>. While <var>document</var> is so blocked, every node
  that is <a id="modal-dialogs-and-inert-subtrees:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a> to <var>document</var>, with the exception of the
  <var>subject</var> element and its <a id="modal-dialogs-and-inert-subtrees:flat-tree" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a> descendants, must become
  <a href="#inert" id="modal-dialogs-and-inert-subtrees:inert">inert</a>.</p>
  </div>

  <div data-algorithm="">
  <p><var>subject</var> can additionally become <a href="#inert" id="modal-dialogs-and-inert-subtrees:inert-2">inert</a> via the <code id="modal-dialogs-and-inert-subtrees:the-inert-attribute"><a href="#the-inert-attribute">inert</a></code> attribute, but only if specified on <var>subject</var> itself
  (i.e., <var>subject</var> escapes inertness of ancestors); <var>subject</var>'s <a id="modal-dialogs-and-inert-subtrees:flat-tree-2" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat
  tree</a> descendants can become <a href="#inert" id="modal-dialogs-and-inert-subtrees:inert-3">inert</a> in a similar fashion.</p>
  </div>

  <p class="note">The <code id="modal-dialogs-and-inert-subtrees:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code> element's <code id="modal-dialogs-and-inert-subtrees:dom-dialog-showmodal"><a href="#dom-dialog-showmodal">showModal()</a></code> method causes this mechanism to trigger, by <a href="https://drafts.csswg.org/css-position-4/#add-an-element-to-the-top-layer" id="modal-dialogs-and-inert-subtrees:add-an-element-to-the-top-layer" data-x-internal="add-an-element-to-the-top-layer">adding</a> the <code id="modal-dialogs-and-inert-subtrees:the-dialog-element-3"><a href="#the-dialog-element">dialog</a></code> element to its
  <a id="modal-dialogs-and-inert-subtrees:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a id="modal-dialogs-and-inert-subtrees:top-layer-2" href="https://drafts.csswg.org/css-position-4/#document-top-layer" data-x-internal="top-layer">top layer</a>.</p>

  <h4 id="the-inert-attribute"><span class="secno">6.3.2</span> The <dfn><code>inert</code></dfn> attribute<a href="#the-inert-attribute" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inert" title="The inert global attribute is a Boolean attribute indicating that the browser will ignore the element. With the inert attribute, all of the element's flat tree descendants (such as modal <dialog>s) that don't otherwise escape inertness are ignored. The inert attribute also makes the browser ignore input events sent by the user, including focus-related events and events from assistive technologies.">Global_attributes/inert</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>112+</span></span><span class="safari yes"><span>Safari</span><span>15.5+</span></span><span class="chrome yes"><span>Chrome</span><span>102+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>102+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="the-inert-attribute:the-inert-attribute"><a href="#the-inert-attribute">inert</a></code> attribute is a <a href="#boolean-attribute" id="the-inert-attribute:boolean-attribute">boolean attribute</a> that
  indicates, by its presence, that the element and all its <a id="the-inert-attribute:flat-tree" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a> descendants which
  don't otherwise escape inertness (such as modal dialogs) are to be made <a href="#inert" id="the-inert-attribute:inert">inert</a> by the
  user agent.</p>

  <p>An inert subtree should not contain any content or controls which are critical to
  understanding or using aspects of the page which are not in the inert state. Content in an inert
  subtree will not be perceivable by all users, or interactive. Authors should not specify elements
  as inert unless the content they represent are also visually obscured in some way. In most cases,
  authors should not specify the <code id="the-inert-attribute:inert-2"><a href="#inert">inert</a></code> attribute on individual form controls. In these
  instances, the <code id="the-inert-attribute:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code> attribute is probably more
  appropriate.</p>

  <div class="example">
   <p>The following example shows how to mark partially loaded content, visually obscured by a
   "loading" message, as inert.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">section</c-> <c- e="">aria-labelledby</c-><c- o="">=</c-><c- s="">s1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h3</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">s1</c-><c- p="">&gt;</c->Population by City<c- p="">&lt;/</c-><c- f="">h3</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">container</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">loading</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Loading...<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">inert</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">form</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
          <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Date range<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
          <c- p="">&lt;</c-><c- f="">div</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">start</c-><c- p="">&gt;</c->Start<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">date</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">start</c-><c- p="">&gt;</c->
          <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
          <c- p="">&lt;</c-><c- f="">div</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">label</c-> <c- e="">for</c-><c- o="">=</c-><c- s="">end</c-><c- p="">&gt;</c->End<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">date</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">end</c-><c- p="">&gt;</c->
          <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
          <c- p="">&lt;</c-><c- f="">div</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Apply<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
          <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
        <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
      <c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->From 20-- to 20--<c- p="">&lt;/</c-><c- f="">caption</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
          <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->City<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->State<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->20-- Population<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->20-- Population<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
            <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Percentage change<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
          <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
        <c- p="">&lt;/</c-><c- f="">thead</c-><c- p="">&gt;</c->
        <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
          <c- c="">&lt;!-- ... --&gt;</c->
        <c- p="">&lt;/</c-><c- f="">tbody</c-><c- p="">&gt;</c->
      <c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">section</c-><c- p="">&gt;</c-></code></pre>

   <img src="/images/inert-example-loading-section.png" width="947" alt="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." height="243">

   <p>The "loading" overlay obscures the inert content, making it visually apparent that the inert
   content is not presently accessible. Notice that the heading and "loading" text are not
   descendants of the element with the <code id="the-inert-attribute:inert-3"><a href="#inert">inert</a></code> attribute. This will ensure this text is
   accessible to all users, while the inert content cannot be interacted with by anyone.</p>
  </div>

  <div class="note">
   <p>By default, there is no persistent visual indication of an element or its subtree being
   inert. Appropriate visual styles for such content is often context-dependent. For instance, an
   inert off-screen navigation panel would not require a default style, as its off-screen position
   visually obscures the content. Similarly, a modal <code id="the-inert-attribute:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> element's backdrop will
   serve as the means to visually obscure the inert content of the web page, rather than styling
   the inert content specifically.</p>

   <p>However, for many other situations authors are strongly encouraged to clearly mark what parts
   of their document are active and which are inert, to avoid user confusion. In particular, it is
   worth remembering that not all users can see all parts of a page at once; for example, users of
   screen readers, users on small devices or with magnifiers, and even users using particularly
   small windows might not be able to see the active part of a page and might get frustrated if
   inert sections are not obviously inert.</p>
  </div>

  <h3 id="tracking-user-activation"><span class="secno">6.4</span> Tracking <dfn data-export="">user activation</dfn><a href="#tracking-user-activation" class="self-link"></a></h3>

  <p>To prevent abuse of certain APIs that could be annoying to users (e.g., opening popups or
  vibrating phones), user agents allow these APIs only when the user is actively interacting with
  the web page or has interacted with the page at least once. This "active interaction" state is
  maintained through the mechanisms defined in this section.</p>

  

  <h4 id="user-activation-data-model"><span class="secno">6.4.1</span> Data model<a href="#user-activation-data-model" class="self-link"></a></h4>

  <div data-var-scope="">
  <p>For the purpose of tracking user activation, each <code id="user-activation-data-model:window"><a href="#window">Window</a></code> <var>W</var> has two
  relevant values:</p>

  <ul><li><p>A <dfn id="last-activation-timestamp">last activation timestamp</dfn>, which is either a
   <code id="user-activation-data-model:domhighrestimestamp"><a data-x-internal="domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp">DOMHighResTimeStamp</a></code>, positive infinity (indicating that <var>W</var> has never been
   activated), or negative infinity (indicating that the activation has been <a href="#consume-user-activation" id="user-activation-data-model:consume-user-activation">consumed</a>). Initially positive infinity.</p></li><li><p>A <dfn id="last-history-action-activation-timestamp">last history-action activation timestamp</dfn>, which is either a
   <code id="user-activation-data-model:domhighrestimestamp-2"><a data-x-internal="domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp">DOMHighResTimeStamp</a></code> or positive infinity, initially positive infinity.</p></li></ul>
  </div>

  <p>A user agent also defines a <dfn id="transient-activation-duration">transient activation duration</dfn>, which is a constant
  number indicating how long a user activation is available for certain <a href="#user-activation-gated-apis">user activation-gated APIs</a> (e.g., for opening popups).</p>

  <p class="note">The <a href="#transient-activation-duration" id="user-activation-data-model:transient-activation-duration">transient activation duration</a> is expected be at most a few
  seconds, so that the user can possibly perceive the link between an interaction with the page and
  the page calling the activation-gated API.</p>

  <div data-var-scope="">
  <p>We then have the following boolean user activation states for <var>W</var>:</p>

  <dl><dt><dfn id="sticky-activation" data-export="">Sticky activation</dfn></dt><dd>
    <div data-algorithm="">
    <p>When the <a id="user-activation-data-model:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given <var>W</var> is greater than or
    equal to the <a href="#last-activation-timestamp" id="user-activation-data-model:last-activation-timestamp">last activation timestamp</a> in <var>W</var>, <var>W</var> is said to
    have <a href="#sticky-activation" id="user-activation-data-model:sticky-activation">sticky activation</a>.</p>
    </div>

    <p>This is <var>W</var>'s historical activation state, indicating whether the user has ever
    interacted in <var>W</var>. It starts false, then changes to true (and never changes back to
    false) when <var>W</var> gets the very first <a href="#activation-notification" id="user-activation-data-model:activation-notification">activation notification</a>.</p>
   </dd><dt><dfn id="transient-activation" data-export="">Transient activation</dfn></dt><dd>
    <div data-algorithm="">
    <p>When the <a id="user-activation-data-model:current-high-resolution-time-2" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given <var>W</var> is greater than or
    equal to the <a href="#last-activation-timestamp" id="user-activation-data-model:last-activation-timestamp-2">last activation timestamp</a> in <var>W</var>, and less than the
    <a href="#last-activation-timestamp" id="user-activation-data-model:last-activation-timestamp-3">last activation timestamp</a> in <var>W</var> plus the <a href="#transient-activation-duration" id="user-activation-data-model:transient-activation-duration-2">transient activation
    duration</a>, then <var>W</var> is said to have <a href="#transient-activation" id="user-activation-data-model:transient-activation">transient activation</a>.</p>
    </div>

    <p>This is <var>W</var>'s current activation state, indicating whether the user has interacted
    in <var>W</var> recently. This starts with a false value, and remains true for a limited time
    after every <a href="#activation-notification" id="user-activation-data-model:activation-notification-2">activation notification</a> <var>W</var> gets.</p>

    <div data-algorithm="">
    <p>The <a href="#transient-activation" id="user-activation-data-model:transient-activation-2">transient activation</a> state is considered <dfn id="activation-expiry">expired</dfn> if it becomes false because the <a href="#transient-activation-duration" id="user-activation-data-model:transient-activation-duration-3">transient
    activation duration</a> time has elapsed since the last user activation. Note that it can
    become false even before the expiry time through an <a href="#consume-user-activation" id="user-activation-data-model:consume-user-activation-2">activation consumption</a>.</p>
    </div>
   </dd><dt><dfn id="history-action-activation">History-action activation</dfn></dt><dd>
    <div data-algorithm="">
    <p>When the <a href="#last-history-action-activation-timestamp" id="user-activation-data-model:last-history-action-activation-timestamp">last history-action activation timestamp</a> of <var>W</var> is not equal
    to the <a href="#last-activation-timestamp" id="user-activation-data-model:last-activation-timestamp-4">last activation timestamp</a> of <var>W</var>, then <var>W</var> is said to have
    <a href="#history-action-activation" id="user-activation-data-model:history-action-activation">history-action activation</a>.</p>
    </div>

    <p>This is a special variant of user activation, used to allow access to certain session history
    APIs which, if used too frequently, would make it harder for the user to traverse back using <a href="#nav-traversal-ui">browser UI</a>. It starts with a false value, and becomes true whenever
    the user interacts with <var>W</var>, but is reset to false through <a href="#consume-history-action-user-activation" id="user-activation-data-model:consume-history-action-user-activation">history-action activation consumption</a>. This ensures such
    APIs cannot be used multiple times in a row without an intervening user activation. But unlike
    <a href="#transient-activation" id="user-activation-data-model:transient-activation-3">transient activation</a>, there is no time limit within which such APIs must be
    used.</p>
   </dd></dl>
  </div>

  <p class="note">The <a href="#last-activation-timestamp" id="user-activation-data-model:last-activation-timestamp-5">last activation timestamp</a> and <a href="#last-history-action-activation-timestamp" id="user-activation-data-model:last-history-action-activation-timestamp-2">last history-action
  activation timestamp</a> are retained even after the <code id="user-activation-data-model:document"><a href="#document">Document</a></code> changes its
  <a href="#fully-active" id="user-activation-data-model:fully-active">fully active</a> status (e.g., after navigating away from a <code id="user-activation-data-model:document-2"><a href="#document">Document</a></code>, or
  navigating to a cached <code id="user-activation-data-model:document-3"><a href="#document">Document</a></code>). This means <a href="#sticky-activation" id="user-activation-data-model:sticky-activation-2">sticky activation</a> state
  spans multiple navigations as long as the same <code id="user-activation-data-model:document-4"><a href="#document">Document</a></code> gets reused. For the
  transient activation state, the original <a href="#activation-expiry" id="user-activation-data-model:activation-expiry">expiry</a> time
  remains unchanged (i.e., the state still expires within the <a href="#transient-activation-duration" id="user-activation-data-model:transient-activation-duration-4">transient activation
  duration</a> limit from the original <a href="#activation-triggering-input-event" id="user-activation-data-model:activation-triggering-input-event">activation triggering input event</a>). It is
  important to consider this when deciding whether to base certain things off <a href="#sticky-activation" id="user-activation-data-model:sticky-activation-3">sticky
  activation</a> or <a href="#transient-activation" id="user-activation-data-model:transient-activation-4">transient activation</a>.</p>

  <h4 id="user-activation-processing-model"><span class="secno">6.4.2</span> Processing model<a href="#user-activation-processing-model" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When a user interaction causes firing of an <a href="#activation-triggering-input-event" id="user-activation-processing-model:activation-triggering-input-event">activation triggering input
  event</a> in a <code id="user-activation-processing-model:document"><a href="#document">Document</a></code> <var>document</var>, the user agent must perform the
  following <dfn id="activation-notification">activation notification</dfn> steps <em>before</em> <a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="user-activation-processing-model:concept-event-dispatch" data-x-internal="concept-event-dispatch">dispatching</a> the event:</p>

  <ol><li><p><a id="user-activation-processing-model:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var> is <a href="#fully-active" id="user-activation-processing-model:fully-active">fully active</a>.</p></li><li><p>Let <var>windows</var> be « <var>document</var>'s <a href="#concept-relevant-global" id="user-activation-processing-model:concept-relevant-global">relevant global object</a>
   ».</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-extend" id="user-activation-processing-model:list-extend" data-x-internal="list-extend">Extend</a> <var>windows</var> with the <a href="#nav-window" id="user-activation-processing-model:nav-window">active window</a> of each of <var>document</var>'s <a href="#ancestor-navigables" id="user-activation-processing-model:ancestor-navigables">ancestor
   navigables</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-extend" id="user-activation-processing-model:list-extend-2" data-x-internal="list-extend">Extend</a> <var>windows</var> with the <a href="#nav-window" id="user-activation-processing-model:nav-window-2">active window</a> of each of <var>document</var>'s <a href="#descendant-navigables" id="user-activation-processing-model:descendant-navigables">descendant
   navigables</a>, filtered to include only those <a href="#navigable" id="user-activation-processing-model:navigable">navigables</a>
   whose <a href="#nav-document" id="user-activation-processing-model:nav-document">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="user-activation-processing-model:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is <a href="#same-origin" id="user-activation-processing-model:same-origin">same origin</a> with
   <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="user-activation-processing-model:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="user-activation-processing-model:list-iterate" data-x-internal="list-iterate">For each</a> <var>window</var> in <var>windows</var>:</p>

    <ol><li><p>Set <var>window</var>'s <a href="#last-activation-timestamp" id="user-activation-processing-model:last-activation-timestamp">last activation timestamp</a> to the <a id="user-activation-processing-model:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current
     high resolution time</a>.</p></li><li><p><a href="#notify-the-close-watcher-manager-about-user-activation" id="user-activation-processing-model:notify-the-close-watcher-manager-about-user-activation">Notify the close watcher manager about user activation</a> given
     <var>window</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>An <dfn id="activation-triggering-input-event">activation triggering input event</dfn> is any event whose <code id="user-activation-processing-model:dom-event-istrusted"><a data-x-internal="dom-event-istrusted" href="https://dom.spec.whatwg.org/#dom-event-istrusted">isTrusted</a></code> attribute is true and whose <code id="user-activation-processing-model:dom-event-type"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> is one of:</p>

  <ul><li><p>"<code id="user-activation-processing-model:event-keydown"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code>", provided the key is neither the
   <kbd>Esc</kbd> key nor a shortcut key reserved by the user agent;</p></li><li><p>"<code id="user-activation-processing-model:event-mousedown"><a data-x-internal="event-mousedown" href="https://w3c.github.io/uievents/#event-type-mousedown">mousedown</a></code>";</p></li><li><p>"<code id="user-activation-processing-model:event-pointerdown"><a data-x-internal="event-pointerdown" href="https://w3c.github.io/pointerevents/#the-pointerdown-event">pointerdown</a></code>", provided the event's
   <code id="user-activation-processing-model:pointertype"><a data-x-internal="pointertype" href="https://w3c.github.io/pointerevents/#dom-pointerevent-pointertype">pointerType</a></code> is "<code>mouse</code>";</p></li><li><p>"<code id="user-activation-processing-model:event-pointerup"><a data-x-internal="event-pointerup" href="https://w3c.github.io/pointerevents/#the-pointerup-event">pointerup</a></code>", provided the event's
   <code id="user-activation-processing-model:pointertype-2"><a data-x-internal="pointertype" href="https://w3c.github.io/pointerevents/#dom-pointerevent-pointertype">pointerType</a></code> is not "<code>mouse</code>"; or</p></li><li><p>"<code id="user-activation-processing-model:event-touchend"><a data-x-internal="event-touchend" href="https://w3c.github.io/touch-events/#event-touchend">touchend</a></code>".</p></li></ul>
  </div>

  <div data-algorithm="">
  <p><a href="#activation-consuming-api" id="user-activation-processing-model:activation-consuming-api">Activation consuming APIs</a> defined in this and
  other specifications can <dfn id="consume-user-activation" data-export="">consume user activation</dfn> by performing the following
  steps, given a <code id="user-activation-processing-model:window"><a href="#window">Window</a></code> <var>W</var>:</p>

  <ol><li><p>If <var>W</var>'s <a href="#window-navigable" id="user-activation-processing-model:window-navigable">navigable</a> is null, then
   return.</p></li><li><p>Let <var>top</var> be <var>W</var>'s <a href="#window-navigable" id="user-activation-processing-model:window-navigable-2">navigable</a>'s
   <a href="#nav-top" id="user-activation-processing-model:nav-top">top-level traversable</a>.</p></li><li><p>Let <var>navigables</var> be the <a href="#inclusive-descendant-navigables" id="user-activation-processing-model:inclusive-descendant-navigables">inclusive descendant navigables</a> of
   <var>top</var>'s <a href="#nav-document" id="user-activation-processing-model:nav-document-2">active document</a>.</p></li><li><p>Let <var>windows</var> be the list of <code id="user-activation-processing-model:window-2"><a href="#window">Window</a></code> objects constructed by taking
   the <a href="#nav-window" id="user-activation-processing-model:nav-window-3">active window</a> of each item in
   <var>navigables</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="user-activation-processing-model:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>window</var> in <var>windows</var>, if
   <var>window</var>'s <a href="#last-activation-timestamp" id="user-activation-processing-model:last-activation-timestamp-2">last activation timestamp</a> is not positive infinity, then set
   <var>window</var>'s <a href="#last-activation-timestamp" id="user-activation-processing-model:last-activation-timestamp-3">last activation timestamp</a> to negative infinity.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p><a href="#history-action-activation-consuming-api" id="user-activation-processing-model:history-action-activation-consuming-api">History-action activation-consuming
  APIs</a> can <dfn id="consume-history-action-user-activation">consume history-action user activation</dfn> by performing the following
  steps, given a <code id="user-activation-processing-model:window-3"><a href="#window">Window</a></code> <var>W</var>:</p>

  <ol><li><p>If <var>W</var>'s <a href="#window-navigable" id="user-activation-processing-model:window-navigable-3">navigable</a> is null, then
   return.</p></li><li><p>Let <var>top</var> be <var>W</var>'s <a href="#window-navigable" id="user-activation-processing-model:window-navigable-4">navigable</a>'s
   <a href="#nav-top" id="user-activation-processing-model:nav-top-2">top-level traversable</a>.</p></li><li><p>Let <var>navigables</var> be the <a href="#inclusive-descendant-navigables" id="user-activation-processing-model:inclusive-descendant-navigables-2">inclusive descendant navigables</a> of
   <var>top</var>'s <a href="#nav-document" id="user-activation-processing-model:nav-document-3">active document</a>.</p></li><li><p>Let <var>windows</var> be the list of <code id="user-activation-processing-model:window-4"><a href="#window">Window</a></code> objects constructed by taking
   the <a href="#nav-window" id="user-activation-processing-model:nav-window-4">active window</a> of each item in
   <var>navigables</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="user-activation-processing-model:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>window</var> in <var>windows</var>, set
   <var>window</var>'s <a href="#last-history-action-activation-timestamp" id="user-activation-processing-model:last-history-action-activation-timestamp">last history-action activation timestamp</a> to <var>window</var>'s
   <a href="#last-activation-timestamp" id="user-activation-processing-model:last-activation-timestamp-4">last activation timestamp</a>.</p></li></ol>
  </div>

  <p class="note">Note the asymmetry in the sets of <a href="#browsing-context" id="user-activation-processing-model:browsing-context">browsing
  contexts</a> in the page that are affected by an <a href="#activation-notification" id="user-activation-processing-model:activation-notification">activation notification</a> vs an
  <a href="#consume-user-activation" id="user-activation-processing-model:consume-user-activation">activation consumption</a>: an activation consumption
  changes (to false) the <a href="#transient-activation" id="user-activation-processing-model:transient-activation">transient activation</a> states for all browsing contexts in the
  page, but an activation notification changes (to true) the states for a subset of those browsing
  contexts. The exhaustive nature of consumption here is deliberate: it prevents malicious sites
  from making multiple calls to an <a href="#activation-consuming-api" id="user-activation-processing-model:activation-consuming-api-2">activation consuming API</a> from a single user
  activation (possibly by exploiting a deep hierarchy of <code id="user-activation-processing-model:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s).</p>

  <h4 id="user-activation-gated-apis"><span class="secno">6.4.3</span> APIs gated by user activation<a href="#user-activation-gated-apis" class="self-link"></a></h4>

  

  <p>APIs that are dependent on user activation are classified into different levels:</p>

  <dl><dt><dfn id="sticky-activation-gated-api" data-lt="sticky activation-gated API" data-export="">Sticky activation-gated APIs</dfn></dt><dd><p>These APIs require the <a href="#sticky-activation" id="user-activation-gated-apis:sticky-activation">sticky activation</a> state to be true, so they are
   blocked until the very first user activation.</p></dd><dt><dfn id="transient-activation-gated-api" data-lt="transient activation-gated
   API" data-export="">Transient activation-gated APIs</dfn></dt><dd><p>These APIs require the <a href="#transient-activation" id="user-activation-gated-apis:transient-activation">transient activation</a> state to be true, but they don't
   <a href="#consume-user-activation" id="user-activation-gated-apis:consume-user-activation">consume</a> it, so multiple calls are allowed per user
   activation until the transient state <a href="#activation-expiry" id="user-activation-gated-apis:activation-expiry">expires</a>.</p></dd><dt><dfn id="activation-consuming-api" data-lt="transient activation-consuming API" data-export="">Transient activation-consuming APIs</dfn></dt><dd><p>These APIs require the <a href="#transient-activation" id="user-activation-gated-apis:transient-activation-2">transient activation</a> state to be true, and they
   <a href="#consume-user-activation" id="user-activation-gated-apis:consume-user-activation-2">consume user activation</a> in each call to prevent multiple calls per user
   activation.</p></dd><dt><dfn id="history-action-activation-consuming-api" data-lt="history-action activation-consuming API" data-export="">History-action activation-consuming APIs</dfn></dt><dd><p>These APIs require the <a href="#history-action-activation" id="user-activation-gated-apis:history-action-activation">history-action activation</a> state to be true, and they
   <a href="#consume-history-action-user-activation" id="user-activation-gated-apis:consume-history-action-user-activation">consume history-action user activation</a> in each call to prevent multiple calls per
   user activation.</p></dd></dl>


  <h4 id="the-useractivation-interface"><span class="secno">6.4.4</span> The <code id="the-useractivation-interface:useractivation"><a href="#useractivation">UserActivation</a></code> interface<a href="#the-useractivation-interface" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/UserActivation" title="The UserActivation interface allows querying information about a window's user activation state.">UserActivation</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>72+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <div data-algorithm="">
  <p>Each <code id="the-useractivation-interface:window"><a href="#window">Window</a></code> has an <dfn id="associated-useractivation">associated <code>UserActivation</code></dfn>, which is a
  <code id="the-useractivation-interface:useractivation-2"><a href="#useractivation">UserActivation</a></code> object. Upon creation of the <code id="the-useractivation-interface:window-2"><a href="#window">Window</a></code> object, its
  <a href="#associated-useractivation" id="the-useractivation-interface:associated-useractivation">associated <code>UserActivation</code></a> must be set to a <a id="the-useractivation-interface:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a>
  <code id="the-useractivation-interface:useractivation-3"><a href="#useractivation">UserActivation</a></code> object created in the <code id="the-useractivation-interface:window-3"><a href="#window">Window</a></code> object's <a href="#concept-relevant-realm" id="the-useractivation-interface:concept-relevant-realm">relevant realm</a>.</p>
  </div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="useractivation" data-dfn-type="interface"><c- g="">UserActivation</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-useractivation-hasbeenactive" id="the-useractivation-interface:dom-useractivation-hasbeenactive"><c- g="">hasBeenActive</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-useractivation-isactive" id="the-useractivation-interface:dom-useractivation-isactive"><c- g="">isActive</c-></a>;
};

<c- b="">partial</c-> <c- b="">interface</c-> <a href="#navigator" id="NavigatorUserActivation-partial"><c- g="">Navigator</c-></a> {
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <code id="the-useractivation-interface:useractivation-4"><a href="#useractivation"><c- n="">UserActivation</c-></a></code> <a href="#dom-navigator-useractivation" id="the-useractivation-interface:dom-navigator-useractivation"><c- g="">userActivation</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><a href="#dom-navigator" id="the-useractivation-interface:dom-navigator">navigator</a>.<a href="#dom-navigator-useractivation" id="dom-navigator-useractivation-dev">userActivation</a>.<a href="#dom-useractivation-hasbeenactive" id="dom-useractivation-hasbeenactive-dev">hasBeenActive</a></code></dt><dd>
    <p>Returns whether the window has <a href="#sticky-activation" id="the-useractivation-interface:sticky-activation">sticky activation</a>.</p>
   </dd><dt><code><a href="#dom-navigator" id="the-useractivation-interface:dom-navigator-2">navigator</a>.<a href="#dom-navigator-useractivation" id="the-useractivation-interface:dom-navigator-useractivation-2">userActivation</a>.<a href="#dom-useractivation-isactive" id="dom-useractivation-isactive-dev">isActive</a></code></dt><dd>
    <p>Returns whether the window has <a href="#transient-activation" id="the-useractivation-interface:transient-activation">transient activation</a>.</p>
   </dd></dl>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userActivation" title="The read-only userActivation property of the Navigator interface returns a UserActivation object which contains information about the current window's user activation state.">Navigator/userActivation</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>72+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigator" id="dom-navigator-useractivation" data-dfn-type="attribute"><code>userActivation</code></dfn> getter steps are to return
  <a id="the-useractivation-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-useractivation-interface:concept-relevant-global">relevant global object</a>'s <a href="#associated-useractivation" id="the-useractivation-interface:associated-useractivation-2">associated
  <code>UserActivation</code></a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/UserActivation/hasBeenActive" title="The read-only hasBeenActive property of the UserActivation interface indicates whether the current window has sticky user activation (see sticky activation).">UserActivation/hasBeenActive</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>72+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="UserActivation" id="dom-useractivation-hasbeenactive" data-dfn-type="attribute"><code>hasBeenActive</code></dfn> getter steps are to return
  true if <a id="the-useractivation-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-useractivation-interface:concept-relevant-global-2">relevant global object</a> has <a href="#sticky-activation" id="the-useractivation-interface:sticky-activation-2">sticky
  activation</a>, and false otherwise.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/UserActivation/hasBeenActive" title="The read-only hasBeenActive property of the UserActivation interface indicates whether the current window has sticky user activation (see sticky activation).">UserActivation/hasBeenActive</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>72+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="UserActivation" id="dom-useractivation-isactive" data-dfn-type="attribute"><code>isActive</code></dfn> getter steps are to return true if
  <a id="the-useractivation-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-useractivation-interface:concept-relevant-global-3">relevant global object</a> has <a href="#transient-activation" id="the-useractivation-interface:transient-activation-2">transient activation</a>,
  and false otherwise.</p>
  </div>


  <h4 id="user-activation-user-agent-automation"><span class="secno">6.4.5</span> User agent automation<a href="#user-activation-user-agent-automation" class="self-link"></a></h4>

  <p>For the purposes of user-agent automation and application testing, this specification defines
  the following <a id="user-activation-user-agent-automation:extension-command" href="https://w3c.github.io/webdriver/#dfn-extension-commands" data-x-internal="extension-command">extension command</a> for the <cite>Web Driver</cite> specification. It is
  optional for a user agent to support the following <a id="user-activation-user-agent-automation:extension-command-2" href="https://w3c.github.io/webdriver/#dfn-extension-commands" data-x-internal="extension-command">extension command</a>.
  <a href="#refsWEBDRIVER">[WEBDRIVER]</a></p>

  <table class="data"><thead><tr><th>HTTP Method</th><th>URI Template</th></tr></thead><tbody><tr><td>`<code>POST</code>`</td><td><code>/session/{<var>session id</var>}/window/consume-user-activation</code></td></tr></tbody></table>

  <div data-algorithm="">
  <p>The <a id="user-activation-user-agent-automation:remote-end-steps" href="https://w3c.github.io/webdriver/#dfn-remote-end-steps" data-x-internal="remote-end-steps">remote end steps</a> are:</p>

  <ol><li><p>Let <var>window</var> be the <a href="https://w3c.github.io/webdriver/#dfn-current-browsing-context" id="user-activation-user-agent-automation:webdriver-current-browsing-context" data-x-internal="webdriver-current-browsing-context">current
   browsing context</a>'s <a href="#active-window" id="user-activation-user-agent-automation:active-window">active window</a>.</p></li><li><p>Let <var>consume</var> be true if <var>window</var> has <a href="#transient-activation" id="user-activation-user-agent-automation:transient-activation">transient activation</a>;
   otherwise false.</p></li><li><p>If <var>consume</var> is true, then <a href="#consume-user-activation" id="user-activation-user-agent-automation:consume-user-activation">consume user activation</a> of
   <var>window</var>.</p></li><li><p>Return <a href="https://w3c.github.io/webdriver/#dfn-success" id="user-activation-user-agent-automation:success-value" data-x-internal="success-value">success</a> with data <var>consume</var>.</p></li></ol>
  </div>

  


  <h3 id="activation"><span class="secno">6.5</span> Activation behavior of elements<a href="#activation" class="self-link"></a></h3>

  <p>Certain elements in HTML have an <a id="activation:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a>, which means that the user
  can activate them. This is always caused by a <code id="activation:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event.</p>

  

  <p>The user agent should allow the user to manually trigger elements that have an <a id="activation:activation-behaviour-2" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation
  behavior</a>, for instance using keyboard or voice input, or through mouse clicks. When the
  user triggers an element with a defined <a id="activation:activation-behaviour-3" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> in a manner other than
  clicking it, the default action of the interaction event must be to <a href="#fire-a-click-event" id="activation:fire-a-click-event">fire a <code>click</code> event</a> at the element.</p>

  

  

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-click" id="dom-click-dev">click</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click" title="The HTMLElement.click() method simulates a mouse click on an element.">HTMLElement/click</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>9+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Acts as if the element was clicked.</p></dd></dl>

  

  <p>Each element has an associated <dfn id="click-in-progress-flag">click in progress flag</dfn>, which is initially unset.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-click" data-dfn-type="method"><code>click()</code></dfn> method must run
  the following steps:</p>

  <ol><li><p>If this element is a form control that is <a href="#concept-fe-disabled" id="activation:concept-fe-disabled">disabled</a>, then return.</p></li><li><p>If this element's <a href="#click-in-progress-flag" id="activation:click-in-progress-flag">click in progress flag</a> is set, then return.</p></li><li><p>Set this element's <a href="#click-in-progress-flag" id="activation:click-in-progress-flag-2">click in progress flag</a>.</p></li><li><p><a href="#fire-a-synthetic-pointer-event" id="activation:fire-a-synthetic-pointer-event">Fire a synthetic pointer event</a> named <code id="activation:event-click-2"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code>
   at this element, with the <i>not trusted flag</i> set.</p></li><li><p>Unset this element's <a href="#click-in-progress-flag" id="activation:click-in-progress-flag-3">click in progress flag</a>.</p></li></ol>
  </div>

  

  <h4 id="the-toggleevent-interface"><span class="secno">6.5.1</span> The <code id="the-toggleevent-interface:toggleevent"><a href="#toggleevent">ToggleEvent</a></code> interface<a href="#the-toggleevent-interface" class="self-link"></a></h4>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ToggleEvent/ToggleEvent" title="The ToggleEvent() constructor creates a new ToggleEvent object.">ToggleEvent/ToggleEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ToggleEvent" title="The ToggleEvent interface represents an event notifying the user when a popover element's state toggles between showing and hidden.">ToggleEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="toggleevent" data-dfn-type="interface"><c- g="">ToggleEvent</c-></dfn> : <a id="the-toggleevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#toggleeventinit" id="the-toggleevent-interface:toggleeventinit"><c- n="">ToggleEventInit</c-></a> <c- g="">eventInitDict</c-> = {});
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-toggleevent-oldstate" id="the-toggleevent-interface:dom-toggleevent-oldstate"><c- g="">oldState</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-toggleevent-newstate" id="the-toggleevent-interface:dom-toggleevent-newstate"><c- g="">newState</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- n="">Element</c->? <a href="#dom-toggleevent-source" id="the-toggleevent-interface:dom-toggleevent-source"><c- g="">source</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="toggleeventinit" data-dfn-type="dictionary"><c- g="">ToggleEventInit</c-></dfn> : <a id="the-toggleevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- b="">DOMString</c-> <c- g="">oldState</c-> = "";
  <c- b="">DOMString</c-> <c- g="">newState</c-> = "";
  <c- n="">Element</c->? <c- g="">source</c-> = <c- b="">null</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-toggleevent-oldstate" id="dom-toggleevent-oldstate-dev">oldState</a></code></dt><dd>
    <p>Set to "<code>closed</code>" when transitioning from closed to open, or set to
    "<code>open</code>" when transitioning from open to closed.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-toggleevent-newstate" id="dom-toggleevent-newstate-dev">newState</a></code></dt><dd>
    <p>Set to "<code>open</code>" when transitioning from closed to open, or set to "<code>closed</code>" when transitioning from open to closed.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-toggleevent-source" id="dom-toggleevent-source-dev">source</a></code></dt><dd>
    <p>Set to the element which initiated the toggle, which can be set up with the <code id="the-toggleevent-interface:attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code> and <code id="the-toggleevent-interface:attr-button-commandfor"><a href="#attr-button-commandfor">commandfor</a></code> attributes. If there is no source element,
    then it is set to null.</p>
   </dd></dl>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ToggleEvent/oldState" title="The oldState read-only property of the ToggleEvent interface is a string representing the state the element is transitioning from.">ToggleEvent/oldState</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ToggleEvent/newState" title="The newState read-only property of the ToggleEvent interface is a string representing the state the element is transitioning to.">ToggleEvent/newState</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ToggleEvent" id="dom-toggleevent-oldstate" data-dfn-type="attribute"><code>oldState</code></dfn> and <dfn data-dfn-for="ToggleEvent" id="dom-toggleevent-newstate" data-dfn-type="attribute"><code>newState</code></dfn> attributes must return the values they are
  initialized to.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ToggleEvent" id="dom-toggleevent-source" data-dfn-type="attribute"><code>source</code></dfn> getter steps are to return the result of
  <a href="https://dom.spec.whatwg.org/#retarget" id="the-toggleevent-interface:dom-retarget" data-x-internal="dom-retarget">retargeting</a> <code id="the-toggleevent-interface:dom-toggleevent-source-2"><a href="#dom-toggleevent-source">source</a></code> against <a id="the-toggleevent-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-toggleevent-interface:dom-event-currenttarget"><a data-x-internal="dom-event-currenttarget" href="https://dom.spec.whatwg.org/#dom-event-currenttarget">currentTarget</a></code>.</p>
  </div>

  <p class="XXX"><a href="https://github.com/whatwg/dom/issues/1328">DOM standard issue #1328</a>
  tracks how to better standardize associated event data in a way which makes sense on Events.
  Currently an event attribute initialized to a value cannot also have a getter, and so an internal
  slot (or map of additional fields) is required to properly specify this.</p>

  <p>A <dfn id="toggle-task-tracker">toggle task tracker</dfn> is a <a id="the-toggleevent-interface:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> which has:</p>

  <dl><dt><dfn id="toggle-task-task">task</dfn></dt><dd>A <a href="#concept-task" id="the-toggleevent-interface:concept-task">task</a> which fires a <code id="the-toggleevent-interface:toggleevent-2"><a href="#toggleevent">ToggleEvent</a></code>.</dd><dt><dfn id="toggle-task-old-state">old state</dfn></dt><dd>A string which represents the <a href="#toggle-task-task" id="the-toggleevent-interface:toggle-task-task">task</a>'s event's value for
   the <code id="the-toggleevent-interface:dom-toggleevent-oldstate-2"><a href="#dom-toggleevent-oldstate">oldState</a></code> attribute.</dd></dl>

  <h4 id="the-commandevent-interface"><span class="secno">6.5.2</span> The <code id="the-commandevent-interface:commandevent"><a href="#commandevent">CommandEvent</a></code> interface<a href="#the-commandevent-interface" class="self-link"></a></h4>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="commandevent" data-dfn-type="interface"><c- g="">CommandEvent</c-></dfn> : <a id="the-commandevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#commandeventinit" id="the-commandevent-interface:commandeventinit"><c- n="">CommandEventInit</c-></a> <c- g="">eventInitDict</c-> = {});
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- n="">Element</c->? <a href="#dom-commandevent-source" id="the-commandevent-interface:dom-commandevent-source"><c- g="">source</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-commandevent-command" id="the-commandevent-interface:dom-commandevent-command"><c- g="">command</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="commandeventinit" data-dfn-type="dictionary"><c- g="">CommandEventInit</c-></dfn> : <a id="the-commandevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- n="">Element</c->? <c- g="">source</c-> = <c- b="">null</c->;
  <c- b="">DOMString</c-> <c- g="">command</c-> = "";
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-commandevent-command" id="dom-commandevent-command-dev">command</a></code></dt><dd>
    <p>Returns what action the element can take.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-commandevent-source" id="dom-commandevent-source-dev">source</a></code></dt><dd>
    <p>Returns the <code id="the-commandevent-interface:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> that was interacted with in order to cause this event.</p>
   </dd></dl>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CommandEvent" id="dom-commandevent-command" data-dfn-type="attribute"><code>command</code></dfn> attribute must return the value it was
  initialized to.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CommandEvent" id="dom-commandevent-source" data-dfn-type="attribute"><code>source</code></dfn> getter steps are to
  return the result of <a href="https://dom.spec.whatwg.org/#retarget" id="the-commandevent-interface:dom-retarget" data-x-internal="dom-retarget">retargeting</a> <code id="the-commandevent-interface:dom-commandevent-source-2"><a href="#dom-commandevent-source">source</a></code> against <a id="the-commandevent-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-commandevent-interface:dom-event-currenttarget"><a data-x-internal="dom-event-currenttarget" href="https://dom.spec.whatwg.org/#dom-event-currenttarget">currentTarget</a></code>.</p>
  </div>

  <p class="XXX"><a href="https://github.com/whatwg/dom/issues/1328">DOM standard issue #1328</a>
  tracks how to better standardize associated event data in a way which makes sense on Events.
  Currently an event attribute initialized to a value cannot also have a getter, and so an internal
  slot (or map of additional fields) is required to properly specify this.</p>

  <h3 id="focus"><span class="secno">6.6</span> Focus<a href="#focus" class="self-link"></a></h3>

  
  
  
  

  

  <h4 id="introduction-8"><span class="secno">6.6.1</span> Introduction<a href="#introduction-8" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>An HTML user interface typically consists of multiple interactive widgets, such as form
  controls, scrollable regions, links, dialog boxes, browser tabs, and so forth. These widgets form
  a hierarchy, with some (e.g. browser tabs, dialog boxes) containing others (e.g. links, form
  controls).</p>

  <p>When interacting with an interface using a keyboard, key input is channeled from the system,
  through the hierarchy of interactive widgets, to an active widget, which is said to be
  <a href="#focused" id="introduction-8:focused">focused</a>.</p>

  <div class="example">

   <p>Consider an HTML application running in a browser tab running in a graphical environment.
   Suppose this application had a page with some text controls and links, and was currently showing
   a modal dialog, which itself had a text control and a button.</p>

   <p>The hierarchy of focusable widgets, in this scenario, would include the browser window, which
   would have, amongst its children, the browser tab containing the HTML application. The tab itself
   would have as its children the various links and text controls, as well as the dialog. The dialog
   itself would have as its children the text control and the button.</p>

   <p><img width="800" src="/images/focus-tree.png" height="450" alt=""> 

   </p><p>If the widget with <a href="#focused" id="introduction-8:focused-2">focus</a> in this example was the text control in
   the dialog box, then key input would be channeled from the graphical system to ① the web
   browser, then to ② the tab, then to ③ the dialog, and finally to ④ the text
   control.</p>

  </div>

  <p>Keyboard <em>events</em> are always targeted at this <a href="#focused" id="introduction-8:focused-3">focused</a> element.</p>


  <h4 id="data-model"><span class="secno">6.6.2</span> Data model<a href="#data-model" class="self-link"></a></h4>

  <div data-algorithm="">
  <p id="tlbc-system-focus">A <a href="#top-level-traversable" id="data-model:top-level-traversable">top-level traversable</a> has <dfn data-dfn-for="top-level
  traversable" id="system-focus" data-export="">system focus</dfn> when it can receive keyboard input channeled from the operating
  system, possibly targeted at one of its <a href="#nav-document" id="data-model:nav-document">active document</a>'s
  <a href="#descendant-navigables" id="data-model:descendant-navigables">descendant navigables</a>.</p>
  </div>

  <p>A <a href="#top-level-traversable" id="data-model:top-level-traversable-2">top-level traversable</a> has <dfn data-dfn-for="top-level traversable" id="user-attention">user attention</dfn>
  when its <a href="#system-visibility-state" id="data-model:system-visibility-state">system visibility state</a> is "<code>visible</code>", and it either
  has <a href="#system-focus" id="data-model:system-focus">system focus</a> or user agent widgets directly related to it can receive keyboard
  input channeled from the operating system.</p>
  

  <p class="note">User attention is lost when a browser window loses focus, whereas system focus
  might also be lost to other system widgets in the browser window such as a location bar.</p>

  <div data-algorithm="">
  <p>A <code id="data-model:document"><a href="#document">Document</a></code> <var>d</var> is a <dfn data-dfn-for="Document" id="fully-active-descendant-of-a-top-level-traversable-with-user-attention" data-export="">fully active descendant of
  a top-level traversable with user attention</dfn> when <var>d</var> is <a href="#fully-active" id="data-model:fully-active">fully active</a>
  and <var>d</var>'s <a href="#node-navigable" id="data-model:node-navigable">node navigable</a>'s <a href="#nav-top" id="data-model:nav-top">top-level
  traversable</a> has <a href="#user-attention" id="data-model:user-attention">user attention</a>.</p>
  </div>

  <p>The term <dfn id="focusable-area">focusable area</dfn> is used to refer to regions of the interface that can further become
  the target of such keyboard input. Focusable areas can be elements, parts of elements, or other regions
  managed by the user agent.</p>

  <p>Each <a href="#focusable-area" id="data-model:focusable-area">focusable area</a> has a <dfn id="dom-anchor">DOM anchor</dfn>, which is a <code id="data-model:node"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code> object
  that represents the position of the <a href="#focusable-area" id="data-model:focusable-area-2">focusable area</a> in the DOM. (When the <a href="#focusable-area" id="data-model:focusable-area-3">focusable
  area</a> is itself a <code id="data-model:node-2"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code>, it is its own <a href="#dom-anchor" id="data-model:dom-anchor">DOM anchor</a>.) The <a href="#dom-anchor" id="data-model:dom-anchor-2">DOM anchor</a> is
  used in some APIs as a substitute for the <a href="#focusable-area" id="data-model:focusable-area-4">focusable area</a> when there is no other DOM object
  to represent the <a href="#focusable-area" id="data-model:focusable-area-5">focusable area</a>.</p>

  <p>The following table describes what objects can be <a href="#focusable-area" id="data-model:focusable-area-6">focusable
  areas</a>. The cells in the left column describe objects that can be <a href="#focusable-area" id="data-model:focusable-area-7">focusable areas</a>; the cells in the right column describe the <a href="#dom-anchor" id="data-model:dom-anchor-3">DOM
  anchors</a> for those elements. (The cells that span both columns are non-normative examples.)</p>

  <table id="table-fa"><thead><tr><th id="th-fa-area"><a href="#focusable-area" id="data-model:focusable-area-8">Focusable area</a>
     </th><th id="th-fa-dom-rep"><a href="#dom-anchor" id="data-model:dom-anchor-4">DOM anchor</a>
    </th></tr><tr><th colspan="2" id="th-fa-examples">Examples

   </th></tr></thead><tbody><tr><th headers="th-fa-area" id="td-fa-1" class="data-header">
     Elements that meet all the following criteria:

     <ul class="brief"><li>the element's <a href="#tabindex-value" id="data-model:tabindex-value">tabindex value</a> is non-null, or the element is determined by the
      user agent to be focusable;</li><li>the element is either not a <a id="data-model:shadow-host" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a>, or has a <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="data-model:concept-element-shadow-root" data-x-internal="concept-element-shadow-root">shadow root</a> whose <a id="data-model:delegates-focus" href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus" data-x-internal="delegates-focus">delegates focus</a> is
      false;</li><li>the element is not <a href="#concept-element-disabled" id="data-model:concept-element-disabled">actually disabled</a>;</li><li>the element is not <a href="#inert" id="data-model:inert">inert</a>;</li><li>the element is either <a href="#being-rendered" id="data-model:being-rendered">being rendered</a>, <a href="#delegating-its-rendering-to-its-children" id="data-model:delegating-its-rendering-to-its-children">delegating its rendering to its
      children</a>, or <a href="#being-used-as-relevant-canvas-fallback-content" id="data-model:being-used-as-relevant-canvas-fallback-content">being used as relevant canvas fallback content</a>.</li></ul>
     </th><td headers="td-fa-1 th-fa-dom-rep">
     The element itself.
    </td></tr><tr><td colspan="2" headers="td-fa-1 th-fa-examples">
     <p class="example"><code id="data-model:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, <code id="data-model:the-dialog-element"><a href="#the-dialog-element">dialog</a></code>, <code id="data-model:text-(type=text)-state-and-search-state-(type=search)"><a href="#text-(type=text)-state-and-search-state-(type=search)">&lt;input type=text&gt;</a></code>, sometimes <code id="data-model:the-a-element"><a href="#the-a-element">&lt;a
     href=""&gt;</a></code> (depending on platform conventions).

   </p></td></tr></tbody><tbody><tr><th headers="th-fa-area" id="td-fa-2" class="data-header">
     The shapes of <code id="data-model:the-area-element"><a href="#the-area-element">area</a></code> elements in an <a href="#image-map" id="data-model:image-map">image map</a> associated with an
     <code id="data-model:the-img-element"><a href="#the-img-element">img</a></code> element that is <a href="#being-rendered" id="data-model:being-rendered-2">being rendered</a> and is not <a href="#inert" id="data-model:inert-2">inert</a>.
     </th><td headers="td-fa-2 th-fa-dom-rep">
     The <code id="data-model:the-img-element-2"><a href="#the-img-element">img</a></code> element.
    </td></tr><tr><td colspan="2" headers="td-fa-2 th-fa-examples">
     <div class="example">
      <p>In the following example, the <code id="data-model:the-area-element-2"><a href="#the-area-element">area</a></code> element creates two shapes, one on each
      image. The <a href="#dom-anchor" id="data-model:dom-anchor-5">DOM anchor</a> of the first shape is the first <code id="data-model:the-img-element-3"><a href="#the-img-element">img</a></code> element, and the
      <a href="#dom-anchor" id="data-model:dom-anchor-6">DOM anchor</a> of the second shape is the second <code id="data-model:the-img-element-4"><a href="#the-img-element">img</a></code> element.</p>
      <pre><code class="html"><c- p="">&lt;</c-><c- f="">map</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">wallmap</c-><c- p="">&gt;&lt;</c-><c- f="">area</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Enter Door"</c-> <c- e="">coords</c-><c- o="">=</c-><c- s="">"10,10,100,200"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"door.html"</c-><c- p="">&gt;&lt;/</c-><c- f="">map</c-><c- p="">&gt;</c->
...
<c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/innerwall.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"There is a white wall here, with a door."</c-> <c- e="">usemap</c-><c- o="">=</c-><c- s="">"#wallmap"</c-><c- p="">&gt;</c->
...
<c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"images/outerwall.jpeg"</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"There is a red wall here, with a door."</c-> <c- e="">usemap</c-><c- o="">=</c-><c- s="">"#wallmap"</c-><c- p="">&gt;</c-></code></pre>
     </div>

   </td></tr></tbody><tbody><tr><th headers="th-fa-area" id="td-fa-3" class="data-header">
     The user-agent provided subwidgets of elements that are <a href="#being-rendered" id="data-model:being-rendered-3">being rendered</a> and are not
     <a href="#concept-element-disabled" id="data-model:concept-element-disabled-2">actually disabled</a> or <a href="#inert" id="data-model:inert-3">inert</a>.
     </th><td headers="td-fa-3 th-fa-dom-rep">
     The element for which the <a href="#focusable-area" id="data-model:focusable-area-9">focusable area</a> is a subwidget.
    </td></tr><tr><td colspan="2" headers="td-fa-3 th-fa-examples">
     <p class="example">The <a href="#expose-a-user-interface-to-the-user" id="data-model:expose-a-user-interface-to-the-user">controls in the user
     interface</a> for a <code id="data-model:the-video-element"><a href="#the-video-element">video</a></code> element, the up and down buttons in a spin-control
     version of <code id="data-model:number-state-(type=number)"><a href="#number-state-(type=number)">&lt;input type=number&gt;</a></code>, the part of a
     <code id="data-model:the-details-element"><a href="#the-details-element">details</a></code> element's rendering that enables the element to be opened or closed using
     keyboard input.</p>

   </td></tr></tbody><tbody><tr><th headers="th-fa-area" id="td-fa-4" class="data-header">
     The scrollable regions of elements that are <a href="#being-rendered" id="data-model:being-rendered-4">being rendered</a> and are not
     <a href="#inert" id="data-model:inert-4">inert</a>. 
     </th><td headers="td-fa-4 th-fa-dom-rep">
     The element for which the box that the scrollable region scrolls was created.
    </td></tr><tr><td colspan="2" headers="td-fa-4 th-fa-examples">
     <p class="example">The CSS <a id="data-model:'overflow'" href="https://drafts.csswg.org/css-overflow/#propdef-overflow" data-x-internal="'overflow'">'overflow'</a> property's 'scroll' value typically creates
     a scrollable region.</p>

   </td></tr></tbody><tbody><tr><th headers="th-fa-area" id="td-fa-5" class="data-header">
     The <a id="data-model:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> of a <code id="data-model:document-2"><a href="#document">Document</a></code> that has a non-null <a href="#concept-document-bc" id="data-model:concept-document-bc">browsing context</a> and is not <a href="#inert" id="data-model:inert-5">inert</a>.
     </th><td headers="td-fa-5 th-fa-dom-rep">
     The <code id="data-model:document-3"><a href="#document">Document</a></code> for which the <a id="data-model:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> was created.
    </td></tr><tr><td colspan="2" headers="td-fa-5 th-fa-examples">
     <p class="example">The contents of an <code id="data-model:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>.</p>

   </td></tr></tbody><tbody><tr><th headers="th-fa-area" id="td-fa-6" class="data-header">
     Any other element or part of an element determined by the user agent to be a focusable area,
     especially to aid with accessibility or to better match platform conventions.
     </th><td headers="td-fa-6 th-fa-dom-rep">
     The element.
    </td></tr><tr><td colspan="2" headers="td-fa-6 th-fa-examples">
     <p class="example">A user agent could make all list item bullets <a href="#sequentially-focusable" id="data-model:sequentially-focusable">sequentially
     focusable</a>, so that a user can more easily navigate lists.</p>
     <p class="example">Similarly, a user agent could make all elements with <code id="data-model:attr-title"><a href="#attr-title">title</a></code> attributes <a href="#sequentially-focusable" id="data-model:sequentially-focusable-2">sequentially focusable</a>, so that their
     advisory information can be accessed.</p>

  </td></tr></tbody></table>

  <p id="bc-focus-ergo-bcc-focus" class="note"><a href="#bc-focus-ergo-bcc-focus" class="self-link"></a>A <a href="#navigable-container" id="data-model:navigable-container">navigable container</a> (e.g. an
  <code id="data-model:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code>) is a <a href="#focusable-area" id="data-model:focusable-area-10">focusable area</a>, but key events routed to a <a href="#navigable-container" id="data-model:navigable-container-2">navigable
  container</a> get immediately routed to its <a href="#content-navigable" id="data-model:content-navigable">content navigable</a>'s <a href="#nav-document" id="data-model:nav-document-2">active document</a>. Similarly, in sequential focus navigation a
  <a href="#navigable-container" id="data-model:navigable-container-3">navigable container</a> essentially acts merely as a placeholder for its <a href="#content-navigable" id="data-model:content-navigable-2">content
  navigable</a>'s <a href="#nav-document" id="data-model:nav-document-3">active document</a>.</p>

  <hr>

  <p>One <a href="#focusable-area" id="data-model:focusable-area-11">focusable area</a> in each <code id="data-model:document-4"><a href="#document">Document</a></code> is designated the <dfn id="focused-area-of-the-document">focused
  area of the document</dfn>. Which control is so designated changes over time, based on algorithms
  in this specification.</p>

  <p class="note">Even if a document is not <a href="#fully-active" id="data-model:fully-active-2">fully active</a> and not shown to the user, it
  can still have a <a href="#focused-area-of-the-document" id="data-model:focused-area-of-the-document">focused area of the document</a>. If a document's <a href="#fully-active" id="data-model:fully-active-3">fully
  active</a> state changes, its <a href="#focused-area-of-the-document" id="data-model:focused-area-of-the-document-2">focused area of the document</a> will stay the same.</p>

  <div data-algorithm="">
  <p id="currently-focused-area-of-a-top-level-browsing-context">The <dfn id="currently-focused-area-of-a-top-level-traversable">currently focused area of
  a top-level traversable</dfn> <var>traversable</var> is the <a href="#focusable-area" id="data-model:focusable-area-12">focusable area</a>-or-null
  returned by this algorithm:</p>

  <ol><li><p>If <var>traversable</var> does not have <a href="#system-focus" id="data-model:system-focus-2">system focus</a>, then return
   null.</p></li><li><p>Let <var>candidate</var> be <var>traversable</var>'s <a href="#nav-document" id="data-model:nav-document-4">active
   document</a>.</p></li><li><p>While <var>candidate</var>'s <a href="#focused-area-of-the-document" id="data-model:focused-area-of-the-document-3">focused
   area</a> is a <a href="#navigable-container" id="data-model:navigable-container-4">navigable container</a> with a non-null <a href="#content-navigable" id="data-model:content-navigable-3">content
   navigable</a>: set <var>candidate</var> to the <a href="#nav-document" id="data-model:nav-document-5">active
   document</a> of that <a href="#navigable-container" id="data-model:navigable-container-5">navigable container</a>'s <a href="#content-navigable" id="data-model:content-navigable-4">content
   navigable</a>.</p></li><li><p>If <var>candidate</var>'s <a href="#focused-area-of-the-document" id="data-model:focused-area-of-the-document-4">focused area</a>
   is non-null, set <var>candidate</var> to <var>candidate</var>'s <a href="#focused-area-of-the-document" id="data-model:focused-area-of-the-document-5">focused area</a>.</p></li><li><p>Return <var>candidate</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="current-focus-chain-of-a-top-level-browsing-context">The <dfn id="current-focus-chain-of-a-top-level-traversable">current focus chain of a
  top-level traversable</dfn> <var>traversable</var> is the <a href="#focus-chain" id="data-model:focus-chain">focus chain</a> of the <a href="#currently-focused-area-of-a-top-level-traversable" id="data-model:currently-focused-area-of-a-top-level-traversable">currently focused area</a> of
  <var>traversable</var>, if <var>traversable</var> is non-null, or an empty list otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>An element that is the <a href="#dom-anchor" id="data-model:dom-anchor-7">DOM anchor</a> of a <a href="#focusable-area" id="data-model:focusable-area-13">focusable area</a> is said to
  <dfn id="gains-focus">gain focus</dfn> when that <a href="#focusable-area" id="data-model:focusable-area-14">focusable area</a> becomes the
  <a href="#currently-focused-area-of-a-top-level-traversable" id="data-model:currently-focused-area-of-a-top-level-traversable-2">currently focused area of a top-level traversable</a>. When an element is the <a href="#dom-anchor" id="data-model:dom-anchor-8">DOM
  anchor</a> of a <a href="#focusable-area" id="data-model:focusable-area-15">focusable area</a> of the <a href="#currently-focused-area-of-a-top-level-traversable" id="data-model:currently-focused-area-of-a-top-level-traversable-3">currently focused area of a top-level
  traversable</a>, it is <dfn id="focused">focused</dfn>.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn id="focus-chain">focus chain</dfn> of a <a href="#focusable-area" id="data-model:focusable-area-16">focusable area</a> <var>subject</var> is the ordered
  list constructed as follows:</p>

  <ol><li><p>Let <var>output</var> be an empty <a id="data-model:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>Let <var>currentObject</var> be <var>subject</var>.</p></li><li>
    <p>While true:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="data-model:list-append" data-x-internal="list-append">Append</a> <var>currentObject</var> to
     <var>output</var>.</p></li><li>
      <p>If <var>currentObject</var> is an <code id="data-model:the-area-element-3"><a href="#the-area-element">area</a></code> element's shape, then <a href="https://infra.spec.whatwg.org/#list-append" id="data-model:list-append-2" data-x-internal="list-append">append</a> that <code id="data-model:the-area-element-4"><a href="#the-area-element">area</a></code> element to <var>output</var>.</p>

      <p>Otherwise, if <var>currentObject</var>'s <a href="#dom-anchor" id="data-model:dom-anchor-9">DOM anchor</a> is an element that is not
      <var>currentObject</var> itself, then <a href="https://infra.spec.whatwg.org/#list-append" id="data-model:list-append-3" data-x-internal="list-append">append</a>
      <var>currentObject</var>'s <a href="#dom-anchor" id="data-model:dom-anchor-10">DOM anchor</a> to <var>output</var>.</p>
     </li><li>
      <p>If <var>currentObject</var> is a <a href="#focusable-area" id="data-model:focusable-area-17">focusable area</a>, then set
      <var>currentObject</var> to <var>currentObject</var>'s <a href="#dom-anchor" id="data-model:dom-anchor-11">DOM anchor</a>'s <a id="data-model:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
      document</a>.</p>

      <p>Otherwise, if <var>currentObject</var> is a <code id="data-model:document-5"><a href="#document">Document</a></code> whose <a href="#node-navigable" id="data-model:node-navigable-2">node
      navigable</a>'s <a href="#nav-parent" id="data-model:nav-parent">parent</a> is non-null, then set
      <var>currentObject</var> to <var>currentObject</var>'s <a href="#node-navigable" id="data-model:node-navigable-3">node navigable</a>'s <a href="#nav-parent" id="data-model:nav-parent-2">parent</a>.</p>

      <p>Otherwise, <a id="data-model:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p>
     </li></ol>
   </li><li>
    <p>Return <var>output</var>.</p>

    <p class="note">The chain starts with <var>subject</var> and (if <var>subject</var> is or can be
    the <a href="#currently-focused-area-of-a-top-level-traversable" id="data-model:currently-focused-area-of-a-top-level-traversable-4">currently focused area of a top-level traversable</a>) continues up the focus
    hierarchy up to the <code id="data-model:document-6"><a href="#document">Document</a></code> of the <a href="#top-level-traversable" id="data-model:top-level-traversable-3">top-level traversable</a>.</p>
   </li></ol>
  </div>

  <p>All elements that are <a href="#focusable-area" id="data-model:focusable-area-18">focusable areas</a> are said to be
  <dfn id="focusable">focusable</dfn>.</p>

  <p>There are two special types of focusability for <a href="#focusable-area" id="data-model:focusable-area-19">focusable
  areas</a>:</p>
  <ul><li>
    <div data-algorithm="">
    <p>A <a href="#focusable-area" id="data-model:focusable-area-20">focusable area</a> is said to be <dfn id="sequentially-focusable">sequentially focusable</dfn> if it is
    included in its <code id="data-model:document-7"><a href="#document">Document</a></code>'s <a href="#sequential-focus-navigation-order" id="data-model:sequential-focus-navigation-order">sequential focus navigation order</a> and
    the user agent determines that it is sequentially focusable.</p>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>A <a href="#focusable-area" id="data-model:focusable-area-21">focusable area</a> is said to be <dfn id="click-focusable">click focusable</dfn> if the user agent
    determines that it is click focusable. User agents should consider focusable areas with non-null
    <a href="#tabindex-value" id="data-model:tabindex-value-2">tabindex values</a> to be click focusable.</p>
    </div>
   </li></ul>

  <p class="note">Elements which are not <a href="#focusable" id="data-model:focusable">focusable</a> are not <a href="#focusable-area" id="data-model:focusable-area-22">focusable areas</a>, and thus not <a href="#sequentially-focusable" id="data-model:sequentially-focusable-3">sequentially focusable</a> and not <a href="#click-focusable" id="data-model:click-focusable">click
  focusable</a>.</p>

  <div class="note">
   <p>Being <a href="#focusable" id="data-model:focusable-2">focusable</a> is a statement about whether an element can be focused
   programmatically, e.g. via the <code id="data-model:dom-focus"><a href="#dom-focus">focus()</a></code> method or <code id="data-model:attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code> attribute. In contrast, <a href="#sequentially-focusable" id="data-model:sequentially-focusable-4">sequentially
   focusable</a> and <a href="#click-focusable" id="data-model:click-focusable-2">click focusable</a> govern how the user agent responds to user
   interaction: respectively, to <a href="#sequential-focus-navigation" id="data-model:sequential-focus-navigation">sequential focus navigation</a> and as
   <a id="data-model:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a>.</p>

   <p>The user agent might determine that an element is not <a href="#sequentially-focusable" id="data-model:sequentially-focusable-5">sequentially focusable</a> even
   if it is <a href="#focusable" id="data-model:focusable-3">focusable</a> and is included in its <code id="data-model:document-8"><a href="#document">Document</a></code>'s <a href="#sequential-focus-navigation-order" id="data-model:sequential-focus-navigation-order-2">sequential
   focus navigation order</a>, according to user preferences. For example, macOS users can set
   the user agent to skip non-form control elements, or can skip links when doing <a href="#sequential-focus-navigation" id="data-model:sequential-focus-navigation-2">sequential
   focus navigation</a> with just the <kbd>Tab</kbd> key (as opposed to using both the
   <kbd>Option</kbd> and <kbd>Tab</kbd> keys).</p>

   <p>Similarly, the user agent might determine that an element is not <a href="#click-focusable" id="data-model:click-focusable-3">click focusable</a>
   even if it is <a href="#focusable" id="data-model:focusable-4">focusable</a>. For example, in some user agents, clicking on a
   non-editable form control does not focus it, i.e. the user agent has determined that such
   controls are not click focusable.</p>

   <p>Thus, an element can be <a href="#focusable" id="data-model:focusable-5">focusable</a>, but neither <a href="#sequentially-focusable" id="data-model:sequentially-focusable-6">sequentially
   focusable</a> nor <a href="#click-focusable" id="data-model:click-focusable-4">click focusable</a>. For example, in some user agents, a
   non-editable form-control with a negative-integer <a href="#tabindex-value" id="data-model:tabindex-value-3">tabindex value</a> would not be
   focusable via user interaction, only via programmatic APIs.</p>
  </div>

  <div data-algorithm="">
  <p>When a user <a href="#activation">activates</a> a <a href="#click-focusable" id="data-model:click-focusable-5">click focusable</a> <a href="#focusable-area" id="data-model:focusable-area-23">focusable
  area</a>, the user agent must run the <a href="#focusing-steps" id="data-model:focusing-steps">focusing steps</a> on the <a href="#focusable-area" id="data-model:focusable-area-24">focusable
  area</a> with <i>focus trigger</i> set to "<code>click</code>".</p>
  </div>

  <p class="note">Note that focusing is not an <a id="data-model:activation-behaviour-2" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a>, i.e. calling the
  <code id="data-model:dom-click"><a href="#dom-click">click()</a></code> method on an element or dispatching a synthetic <code id="data-model:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event on it won't cause the element to get focused.</p>

  <hr>

  <div data-algorithm="">
  <p>A node is a <dfn id="focus-navigation-scope-owner">focus navigation scope owner</dfn> if it is a <code id="data-model:document-9"><a href="#document">Document</a></code>, a
  <a id="data-model:shadow-host-2" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a>, a <a href="#the-slot-element" id="data-model:the-slot-element">slot</a>, or an element which is the <a href="#popover-trigger" id="data-model:popover-trigger">popover
  trigger</a> of an element in the <a href="#popover-showing-state" id="data-model:popover-showing-state">popover showing
  state</a>.</p>
  </div>

  <div data-algorithm="">
  <p>Each <a href="#focus-navigation-scope-owner" id="data-model:focus-navigation-scope-owner">focus navigation scope owner</a> has a <dfn id="focus-navigation-scope">focus navigation scope</dfn>, which
  is a list of elements. Its contents are determined as follows:</p>

  <p>Every element <var>element</var> has an <dfn id="associated-focus-navigation-owner">associated focus navigation owner</dfn>, which is
  either null or a <a href="#focus-navigation-scope-owner" id="data-model:focus-navigation-scope-owner-2">focus navigation scope owner</a>. It is determined by the following
  algorithm:</p>

  <ol><li><p>If <var>element</var>'s parent is null, then return null.</p></li><li><p>If <var>element</var>'s parent is a <a id="data-model:shadow-host-3" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a>, then return
   <var>element</var>'s <a id="data-model:assigned-slot" href="https://dom.spec.whatwg.org/#slotable-assigned-slot" data-x-internal="assigned-slot">assigned slot</a>.</p></li><li><p>If <var>element</var>'s parent is a <a id="data-model:shadow-root" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a>, then return the parent's
   <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="data-model:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">host</a>.</p></li><li><p>If <var>element</var>'s parent is the <a id="data-model:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>, then return the
   parent's <a id="data-model:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>element</var> is in the <a href="#popover-showing-state" id="data-model:popover-showing-state-2">popover showing
   state</a> and has a <a href="#popover-trigger" id="data-model:popover-trigger-2">popover trigger</a> set, then return <var>element</var>'s
   <a href="#popover-trigger" id="data-model:popover-trigger-3">popover trigger</a>.</p></li><li><p>Return <var>element</var>'s parent's <a href="#associated-focus-navigation-owner" id="data-model:associated-focus-navigation-owner">associated focus navigation owner</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Then, the contents of a given <a href="#focus-navigation-scope-owner" id="data-model:focus-navigation-scope-owner-3">focus navigation scope owner</a> <var>owner</var>'s
  <a href="#focus-navigation-scope" id="data-model:focus-navigation-scope">focus navigation scope</a> are all elements whose <a href="#associated-focus-navigation-owner" id="data-model:associated-focus-navigation-owner-2">associated focus navigation
  owner</a> is <var>owner</var>.</p>
  </div>

  <p class="note">The order of elements within a <a href="#focus-navigation-scope" id="data-model:focus-navigation-scope-2">focus navigation scope</a> does not impact
  any of the algorithms in this specification. Ordering only becomes important for the
  <a href="#tabindex-ordered-focus-navigation-scope" id="data-model:tabindex-ordered-focus-navigation-scope">tabindex-ordered focus navigation scope</a> and <a href="#flattened-tabindex-ordered-focus-navigation-scope" id="data-model:flattened-tabindex-ordered-focus-navigation-scope">flattened tabindex-ordered focus
  navigation scope</a> concepts defined below.</p>

  <div data-algorithm="">
  <p>A <dfn id="tabindex-ordered-focus-navigation-scope">tabindex-ordered focus navigation scope</dfn> is a list of <a href="#focusable-area" id="data-model:focusable-area-25">focusable areas</a> and <a href="#focus-navigation-scope-owner" id="data-model:focus-navigation-scope-owner-4">focus navigation
  scope owners</a>. Every <a href="#focus-navigation-scope-owner" id="data-model:focus-navigation-scope-owner-5">focus navigation scope owner</a> <var>owner</var> has
  <a href="#tabindex-ordered-focus-navigation-scope" id="data-model:tabindex-ordered-focus-navigation-scope-2">tabindex-ordered focus navigation scope</a>, whose contents are determined as
  follows:</p>

  <ul><li><p>It contains all elements in <var>owner</var>'s <a href="#focus-navigation-scope" id="data-model:focus-navigation-scope-3">focus navigation scope</a> that
   are themselves <a href="#focus-navigation-scope-owner" id="data-model:focus-navigation-scope-owner-6">focus navigation scope owners</a>,
   except the elements whose <a href="#tabindex-value" id="data-model:tabindex-value-4">tabindex value</a> is a negative integer.</p></li><li><p>It contains all of the <a href="#focusable-area" id="data-model:focusable-area-26">focusable areas</a> whose
   <a href="#dom-anchor" id="data-model:dom-anchor-12">DOM anchor</a> is an element in <var>owner</var>'s <a href="#focus-navigation-scope" id="data-model:focus-navigation-scope-4">focus navigation scope</a>,
   except the <a href="#focusable-area" id="data-model:focusable-area-27">focusable areas</a> whose <a href="#tabindex-value" id="data-model:tabindex-value-5">tabindex value</a>
   is a negative integer.</p></li></ul>
  </div>

  <p>The order within a <a href="#tabindex-ordered-focus-navigation-scope" id="data-model:tabindex-ordered-focus-navigation-scope-3">tabindex-ordered focus navigation scope</a> is determined by each
  element's <a href="#tabindex-value" id="data-model:tabindex-value-6">tabindex value</a>, as described in the section below.</p>

  <p class="note">The rules there do not give a precise ordering, as they are composed mostly of
  "should" statements and relative orderings.</p>

  <div data-algorithm="">
  <p>A <dfn id="flattened-tabindex-ordered-focus-navigation-scope">flattened tabindex-ordered focus navigation scope</dfn> is a list of <a href="#focusable-area" id="data-model:focusable-area-28">focusable areas</a>. Every <a href="#focus-navigation-scope-owner" id="data-model:focus-navigation-scope-owner-7">focus navigation scope owner</a>
  <var>owner</var> owns a distinct <a href="#flattened-tabindex-ordered-focus-navigation-scope" id="data-model:flattened-tabindex-ordered-focus-navigation-scope-2">flattened tabindex-ordered focus navigation scope</a>,
  whose contents are determined by the following algorithm:</p>

  <ol><li><p>Let <var>result</var> be a <a href="https://infra.spec.whatwg.org/#list-clone" id="data-model:list-clone" data-x-internal="list-clone">clone</a> of <var>owner</var>'s
   <a href="#tabindex-ordered-focus-navigation-scope" id="data-model:tabindex-ordered-focus-navigation-scope-4">tabindex-ordered focus navigation scope</a>.</p></li><li>
    <p>For each <var>item</var> of <var>result</var>:</p>

    <ol><li><p>If <var>item</var> is not a <a href="#focus-navigation-scope-owner" id="data-model:focus-navigation-scope-owner-8">focus navigation scope owner</a>, then
     <a id="data-model:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>item</var> is not a <a href="#focusable-area" id="data-model:focusable-area-29">focusable area</a>, then replace <var>item</var>
     with all of the items in <var>item</var>'s <a href="#flattened-tabindex-ordered-focus-navigation-scope" id="data-model:flattened-tabindex-ordered-focus-navigation-scope-3">flattened tabindex-ordered focus navigation
     scope</a>.</p></li><li><p>Otherwise, insert the contents of <var>item</var>'s <a href="#flattened-tabindex-ordered-focus-navigation-scope" id="data-model:flattened-tabindex-ordered-focus-navigation-scope-4">flattened tabindex-ordered
     focus navigation scope</a> after <var>item</var>.</p></li></ol>
   </li></ol>
  </div>

  

  <h4 id="the-tabindex-attribute"><span class="secno">6.6.3</span> The <code id="the-tabindex-attribute:attr-tabindex"><a href="#attr-tabindex">tabindex</a></code> attribute<a href="#the-tabindex-attribute" class="self-link"></a></h4>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex" title="The tabindex global attribute allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the Tab key, hence the name) and determine their relative ordering for sequential focus navigation.">Global_attributes/tabindex</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="htmlsvg-global" id="attr-tabindex" data-dfn-type="element-attr"><code>tabindex</code></dfn>
  content attribute allows authors to make an element and regions that have the element as its
  <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor">DOM anchor</a> be <a href="#focusable-area" id="the-tabindex-attribute:focusable-area">focusable areas</a>, allow or prevent
  them from being <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable">sequentially focusable</a>, and determine their relative ordering for
  <a href="#sequential-focus-navigation" id="the-tabindex-attribute:sequential-focus-navigation">sequential focus navigation</a>.</p>

  <p>The name "tab index" comes from the common use of the <kbd>Tab</kbd> key to navigate through
  the focusable elements. The term "tabbing" refers to moving forward through <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable-2">sequentially
  focusable</a> <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-2">focusable areas</a>.</p>

  <p>The <code id="the-tabindex-attribute:attr-tabindex-2"><a href="#attr-tabindex">tabindex</a></code> attribute, if specified, must have a value
  that is a <a href="#valid-integer" id="the-tabindex-attribute:valid-integer">valid integer</a>. Positive numbers specify the relative position of the
  element's <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-3">focusable areas</a> in the <a href="#sequential-focus-navigation-order" id="the-tabindex-attribute:sequential-focus-navigation-order">sequential focus
  navigation order</a>, and negative numbers indicate that the control is not
  <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable-3">sequentially focusable</a>.</p>

  <p>Developers should use caution when using values other than 0 or −1 for their <code id="the-tabindex-attribute:attr-tabindex-3"><a href="#attr-tabindex">tabindex</a></code> attributes as this is complicated to do correctly.</p>

  <div class="note">
   <p>The following provides a non-normative summary of the behaviors of the
   possible <code id="the-tabindex-attribute:attr-tabindex-4"><a href="#attr-tabindex">tabindex</a></code> attribute values. The below
   processing model gives the more precise rules.</p>

   <dl><dt>omitted (or non-integer values)</dt><dd>The user agent will decide whether the element is <a href="#focusable" id="the-tabindex-attribute:focusable">focusable</a>, and if it is,
    whether it is <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable-4">sequentially focusable</a> or <a href="#click-focusable" id="the-tabindex-attribute:click-focusable">click focusable</a> (or both).</dd><dt>−1 (or other negative integer values)</dt><dd>Causes the element to be <a href="#focusable" id="the-tabindex-attribute:focusable-2">focusable</a>, and indicates that the author would prefer
    the element to be <a href="#click-focusable" id="the-tabindex-attribute:click-focusable-2">click focusable</a> but not <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable-5">sequentially focusable</a>. The
    user agent might ignore this preference for click and sequential focusability, e.g., for
    specific element types according to platform conventions, or for keyboard-only users.</dd><dt>0</dt><dd>Causes the element to be <a href="#focusable" id="the-tabindex-attribute:focusable-3">focusable</a>, and indicates that the author would prefer
    the element to be both <a href="#click-focusable" id="the-tabindex-attribute:click-focusable-3">click focusable</a> and <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable-6">sequentially focusable</a>. The
    user agent might ignore this preference for click and sequential focusability.</dd><dt>positive integer values</dt><dd>Behaves the same as 0, but in addition creates a relative ordering within a
    <a href="#tabindex-ordered-focus-navigation-scope" id="the-tabindex-attribute:tabindex-ordered-focus-navigation-scope">tabindex-ordered focus navigation scope</a>, so that elements with higher <code id="the-tabindex-attribute:attr-tabindex-5"><a href="#attr-tabindex">tabindex</a></code> attribute value come later.</dd></dl>

   <p>Note that the <code id="the-tabindex-attribute:attr-tabindex-6"><a href="#attr-tabindex">tabindex</a></code> attribute cannot be used to make
   an element non-focusable. The only way a page author can do that is by <a href="#concept-element-disabled" id="the-tabindex-attribute:concept-element-disabled">disabling</a> the element, or making it
   <a href="#inert" id="the-tabindex-attribute:inert">inert</a>.</p>
  </div>

  

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="tabindex-value">tabindex value</dfn> of an element is the value of its <code id="the-tabindex-attribute:attr-tabindex-7"><a href="#attr-tabindex">tabindex</a></code> attribute, parsed using the <a href="#rules-for-parsing-integers" id="the-tabindex-attribute:rules-for-parsing-integers">rules for parsing
  integers</a>. If parsing fails or the attribute is not specified, then the <a href="#tabindex-value" id="the-tabindex-attribute:tabindex-value">tabindex
  value</a> is null.</p>
  </div>

  <div data-algorithm="">
  <p>The <a href="#tabindex-value" id="the-tabindex-attribute:tabindex-value-2">tabindex value</a> of a <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-4">focusable area</a> is the <a href="#tabindex-value" id="the-tabindex-attribute:tabindex-value-3">tabindex
  value</a> of its <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-2">DOM anchor</a>.</p>
  </div>

  <p>The <a href="#tabindex-value" id="the-tabindex-attribute:tabindex-value-4">tabindex value</a> of an element must be interpreted as follows:</p>

  <dl><dt>If the value is null</dt><dd>
    <p>The user agent should follow platform conventions to determine if the element should be
    considered as a <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-5">focusable area</a> and if so, whether the element and any <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-6">focusable areas</a> that have the element as their
    <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-3">DOM anchor</a> are <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable-7">sequentially focusable</a>, and if so, what their relative
    position in their <a href="#tabindex-ordered-focus-navigation-scope" id="the-tabindex-attribute:tabindex-ordered-focus-navigation-scope-2">tabindex-ordered focus navigation scope</a> is to be. If the element
    is a <a href="#focus-navigation-scope-owner" id="the-tabindex-attribute:focus-navigation-scope-owner">focus navigation scope owner</a>, it must be included in its
    <a href="#tabindex-ordered-focus-navigation-scope" id="the-tabindex-attribute:tabindex-ordered-focus-navigation-scope-3">tabindex-ordered focus navigation scope</a> even if it is not a <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-7">focusable
    area</a>.</p>

    <p>The relative ordering within a <a href="#tabindex-ordered-focus-navigation-scope" id="the-tabindex-attribute:tabindex-ordered-focus-navigation-scope-4">tabindex-ordered focus navigation scope</a> for
    elements and <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-8">focusable areas</a> that belong to the same
    <a href="#focus-navigation-scope" id="the-tabindex-attribute:focus-navigation-scope">focus navigation scope</a> and whose <a href="#tabindex-value" id="the-tabindex-attribute:tabindex-value-5">tabindex value</a> is null should be in
    <a id="the-tabindex-attribute:shadow-including-tree-order" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>.</p>

    <p>Modulo platform conventions, it is suggested that the following elements should be considered
    as <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-9">focusable areas</a> and be <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable-8">sequentially
    focusable</a>:</p>

    <ul><li><code id="the-tabindex-attribute:the-a-element"><a href="#the-a-element">a</a></code> elements that have an <code id="the-tabindex-attribute:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code>
     attribute</li><li><code id="the-tabindex-attribute:the-button-element"><a href="#the-button-element">button</a></code> elements</li><li><code id="the-tabindex-attribute:the-input-element"><a href="#the-input-element">input</a></code> elements whose <code id="the-tabindex-attribute:attr-input-type"><a href="#attr-input-type">type</a></code> attribute are
     not in the <a href="#hidden-state-(type=hidden)" id="the-tabindex-attribute:hidden-state-(type=hidden)">Hidden</a> state</li><li><code id="the-tabindex-attribute:the-select-element"><a href="#the-select-element">select</a></code> elements</li><li><code id="the-tabindex-attribute:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements</li><li><code id="the-tabindex-attribute:the-summary-element"><a href="#the-summary-element">summary</a></code> elements that are the first <code id="the-tabindex-attribute:the-summary-element-2"><a href="#the-summary-element">summary</a></code> element child of a
     <code id="the-tabindex-attribute:the-details-element"><a href="#the-details-element">details</a></code> element</li><li>Elements with a <code id="the-tabindex-attribute:attr-draggable"><a href="#attr-draggable">draggable</a></code> attribute set, if that would
     enable the user agent to allow the user to begin drag operations for those elements without
     the use of a pointing device</li><li><a href="#editing-host" id="the-tabindex-attribute:editing-host">Editing hosts</a></li><li><a href="#navigable-container" id="the-tabindex-attribute:navigable-container">Navigable containers</a></li></ul>
   </dd><dt id="negative-tabindex">If the value is a negative integer</dt><dd>
    <p>The user agent must consider the element as a <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-10">focusable area</a>, but should omit
    the element from any <a href="#tabindex-ordered-focus-navigation-scope" id="the-tabindex-attribute:tabindex-ordered-focus-navigation-scope-5">tabindex-ordered focus navigation scope</a>.</p>

    <p class="note">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 control with a negative <code id="the-tabindex-attribute:attr-tabindex-8"><a href="#attr-tabindex">tabindex</a></code>, so that
    user's user agent would be well justified in allowing the user to tab to the control
    regardless.</p>
   </dd><dt>If the value is a zero</dt><dd>
    <p>The user agent must allow the element to be considered as a <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-11">focusable area</a> and
    should allow the element and any <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-12">focusable areas</a> that have
    the element as their <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-4">DOM anchor</a> to be <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable-9">sequentially focusable</a>.</p>

    <p>The relative ordering within a <a href="#tabindex-ordered-focus-navigation-scope" id="the-tabindex-attribute:tabindex-ordered-focus-navigation-scope-6">tabindex-ordered focus navigation scope</a> for
    elements and <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-13">focusable areas</a> that belong to the same
    <a href="#focus-navigation-scope" id="the-tabindex-attribute:focus-navigation-scope-2">focus navigation scope</a> and whose <a href="#tabindex-value" id="the-tabindex-attribute:tabindex-value-6">tabindex value</a> is zero should be in
    <a id="the-tabindex-attribute:shadow-including-tree-order-2" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>.</p>
   </dd><dt>If the value is greater than zero</dt><dd data-var-scope="">
    <p>The user agent must allow the element to be considered as a <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-14">focusable area</a> and
    should allow the element and any <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-15">focusable areas</a> that have
    the element as their <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-5">DOM anchor</a> to be <a href="#sequentially-focusable" id="the-tabindex-attribute:sequentially-focusable-10">sequentially focusable</a>, and
    should place the element — referenced as <var>candidate</var> below — and the
    aforementioned <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-16">focusable areas</a> in the
    <a href="#tabindex-ordered-focus-navigation-scope" id="the-tabindex-attribute:tabindex-ordered-focus-navigation-scope-7">tabindex-ordered focus navigation scope</a> where the element is a part of so that,
    relative to other elements and <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-17">focusable areas</a> that belong
    to the same <a href="#focus-navigation-scope" id="the-tabindex-attribute:focus-navigation-scope-3">focus navigation scope</a>, they are:</p>

    <ul><li>before any <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-18">focusable area</a> whose <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-6">DOM anchor</a> is an element whose <code id="the-tabindex-attribute:attr-tabindex-9"><a href="#attr-tabindex">tabindex</a></code> attribute has been omitted or whose value, when parsed,
     returns an error,</li><li>before any <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-19">focusable area</a> whose <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-7">DOM anchor</a> is an element whose <code id="the-tabindex-attribute:attr-tabindex-10"><a href="#attr-tabindex">tabindex</a></code> attribute has a value less than or equal to zero,</li><li>after any <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-20">focusable area</a> whose <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-8">DOM anchor</a> is an element whose <code id="the-tabindex-attribute:attr-tabindex-11"><a href="#attr-tabindex">tabindex</a></code> attribute has a value greater than zero but less than
     the value of the <code id="the-tabindex-attribute:attr-tabindex-12"><a href="#attr-tabindex">tabindex</a></code> attribute on <var>candidate</var>,</li><li>after any <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-21">focusable area</a> whose <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-9">DOM anchor</a> is an element whose <code id="the-tabindex-attribute:attr-tabindex-13"><a href="#attr-tabindex">tabindex</a></code> attribute has a value equal to the value of the <code id="the-tabindex-attribute:attr-tabindex-14"><a href="#attr-tabindex">tabindex</a></code> attribute on <var>candidate</var> but that is
     located earlier than <var>candidate</var> in <a id="the-tabindex-attribute:shadow-including-tree-order-3" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>,</li><li>before any <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-22">focusable area</a> whose <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-10">DOM anchor</a> is an element whose <code id="the-tabindex-attribute:attr-tabindex-15"><a href="#attr-tabindex">tabindex</a></code> attribute has a value equal to the value of the <code id="the-tabindex-attribute:attr-tabindex-16"><a href="#attr-tabindex">tabindex</a></code> attribute on <var>candidate</var> but that is
     located later than <var>candidate</var> in <a id="the-tabindex-attribute:shadow-including-tree-order-4" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>, and</li><li>before any <a href="#focusable-area" id="the-tabindex-attribute:focusable-area-23">focusable area</a> whose <a href="#dom-anchor" id="the-tabindex-attribute:dom-anchor-11">DOM anchor</a> is an element whose <code id="the-tabindex-attribute:attr-tabindex-17"><a href="#attr-tabindex">tabindex</a></code> attribute has a value greater than the value of the
     <code id="the-tabindex-attribute:attr-tabindex-18"><a href="#attr-tabindex">tabindex</a></code> attribute on <var>candidate</var>.</li></ul>
   </dd></dl>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex" title="The tabIndex property of the HTMLElement interface represents the tab order of the current element.">HTMLElement/tabIndex</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Partial implementation.">🔰 5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLOrSVGElement" id="dom-tabindex" data-dfn-type="attribute"><code>tabIndex</code></dfn>
  getter steps are:</p>

  <ol><li><p>Let <var>attribute</var> be <a id="the-tabindex-attribute:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-tabindex-attribute:attr-tabindex-19"><a href="#attr-tabindex">tabindex</a></code> attribute.</p></li><li>
    <p>If <var>attribute</var> is not null:</p>

    <ol><li><p>Let <var>parsedValue</var> be the result of <a href="#rules-for-parsing-integers" id="the-tabindex-attribute:rules-for-parsing-integers-2">integer parsing</a> <var>attribute</var>'s <a href="https://dom.spec.whatwg.org/#concept-attribute-value" id="the-tabindex-attribute:concept-attribute-value" data-x-internal="concept-attribute-value">value</a>.</p></li><li><p>If <var>parsedValue</var> is not an error and is within the <code id="the-tabindex-attribute:idl-long"><a data-x-internal="idl-long" href="https://webidl.spec.whatwg.org/#idl-long">long</a></code> range, then return <var>parsedValue</var>.</p></li></ol>
   </li><li><p>Return 0 if <a id="the-tabindex-attribute:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is an <code id="the-tabindex-attribute:the-a-element-2"><a href="#the-a-element">a</a></code>, <code id="the-tabindex-attribute:the-area-element"><a href="#the-area-element">area</a></code>,
   <code id="the-tabindex-attribute:the-button-element-2"><a href="#the-button-element">button</a></code>, <code id="the-tabindex-attribute:frame"><a href="#frame">frame</a></code>, <code id="the-tabindex-attribute:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, <code id="the-tabindex-attribute:the-input-element-2"><a href="#the-input-element">input</a></code>,
   <code id="the-tabindex-attribute:the-object-element"><a href="#the-object-element">object</a></code>, <code id="the-tabindex-attribute:the-select-element-2"><a href="#the-select-element">select</a></code>, <code id="the-tabindex-attribute:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code>, or <a id="the-tabindex-attribute:svg-a" href="https://svgwg.org/svg2-draft/linking.html#AElement" data-x-internal="svg-a">SVG
   <code>a</code></a> element, or is a <code id="the-tabindex-attribute:the-summary-element-3"><a href="#the-summary-element">summary</a></code> element that is a <a href="#summary-for-its-parent-details" id="the-tabindex-attribute:summary-for-its-parent-details">summary for
   its parent details</a>; otherwise 1.</p></li></ol>
  </div>

  <p class="note">The varying default value based on element type is a historical artifact.</p>

  


  

  <h4 id="focus-processing-model"><span class="secno">6.6.4</span> <span id="processing-model-5"></span>Processing model<a href="#focus-processing-model" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>To <dfn id="get-the-focusable-area">get the focusable area</dfn> for a <var>focus target</var> that is either an element
  that is not a <a href="#focusable-area" id="focus-processing-model:focusable-area">focusable area</a>, or is a <a href="#navigable" id="focus-processing-model:navigable">navigable</a>, given an
  optional string <var>focus trigger</var> (default "<code>other</code>"), run the first
  matching set of steps from the following list:</p>

  <dl class="switch"><dt>If <var>focus target</var> is an <code id="focus-processing-model:the-area-element"><a href="#the-area-element">area</a></code> element with one or more shapes that are
   <a href="#focusable-area" id="focus-processing-model:focusable-area-2">focusable areas</a></dt><dd><p>Return the shape corresponding to the first <code id="focus-processing-model:the-img-element"><a href="#the-img-element">img</a></code> element in <a id="focus-processing-model:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
   order</a> that uses the image map to which the <code id="focus-processing-model:the-area-element-2"><a href="#the-area-element">area</a></code> element belongs.</p></dd><dt>If <var>focus target</var> is an element with one or more scrollable regions that are <a href="#focusable-area" id="focus-processing-model:focusable-area-3">focusable areas</a></dt><dd><p>Return the element's first scrollable region, according to a pre-order, depth-first
   traversal of the <a id="focus-processing-model:flat-tree" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a>. <a href="#refsCSSSCOPING">[CSSSCOPING]</a></p></dd><dt>If <var>focus target</var> is the <a id="focus-processing-model:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> of its
   <code id="focus-processing-model:document"><a href="#document">Document</a></code></dt><dd><p>Return the <code id="focus-processing-model:document-2"><a href="#document">Document</a></code>'s <a id="focus-processing-model:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>.</p></dd><dt>If <var>focus target</var> is a <a href="#navigable" id="focus-processing-model:navigable-2">navigable</a></dt><dd><p>Return the <a href="#navigable" id="focus-processing-model:navigable-3">navigable</a>'s <a href="#nav-document" id="focus-processing-model:nav-document">active
   document</a>.</p></dd><dt>If <var>focus target</var> is a <a href="#navigable-container" id="focus-processing-model:navigable-container">navigable container</a> with a non-null
   <a href="#content-navigable" id="focus-processing-model:content-navigable">content navigable</a></dt><dd><p>Return the <a href="#navigable-container" id="focus-processing-model:navigable-container-2">navigable container</a>'s <a href="#content-navigable" id="focus-processing-model:content-navigable-2">content navigable</a>'s <a href="#nav-document" id="focus-processing-model:nav-document-2">active document</a>.</p></dd><dt>If <var>focus target</var> is a <a id="focus-processing-model:shadow-host" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a> whose <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="focus-processing-model:concept-element-shadow-root" data-x-internal="concept-element-shadow-root">shadow root</a>'s <a id="focus-processing-model:delegates-focus" href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus" data-x-internal="delegates-focus">delegates focus</a> is
   true</dt><dd>
    <ol><li><p>Let <var>focusedElement</var> be the <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable">currently focused area of a top-level
     traversable</a>'s <a href="#dom-anchor" id="focus-processing-model:dom-anchor">DOM anchor</a>.</p></li><li><p>If <var>focus target</var> is a <a id="focus-processing-model:shadow-including-inclusive-ancestor" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-ancestor" data-x-internal="shadow-including-inclusive-ancestor">shadow-including inclusive ancestor</a> of
     <var>focusedElement</var>, then return <var>focusedElement</var>.</p></li><li><p>Return the <a href="#focus-delegate" id="focus-processing-model:focus-delegate">focus delegate</a> for <var>focus target</var> given <var>focus
     trigger</var>.</p></li></ol>

    <p class="note">For <a href="#sequentially-focusable" id="focus-processing-model:sequentially-focusable">sequential focusability</a>, the
    handling of <a href="https://dom.spec.whatwg.org/#element-shadow-host" id="focus-processing-model:shadow-host-2" data-x-internal="shadow-host">shadow hosts</a> and <a id="focus-processing-model:delegates-focus-2" href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus" data-x-internal="delegates-focus">delegates focus</a> is
    done when constructing the <a href="#sequential-focus-navigation-order" id="focus-processing-model:sequential-focus-navigation-order">sequential focus navigation order</a>. That is, the
    <a href="#focusing-steps" id="focus-processing-model:focusing-steps">focusing steps</a> will never be called on such <a href="https://dom.spec.whatwg.org/#element-shadow-host" id="focus-processing-model:shadow-host-3" data-x-internal="shadow-host">shadow
    hosts</a> as part of sequential focus navigation.</p>
   </dd><dt>Otherwise</dt><dd><p>Return null.</p></dd></dl>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="focus-delegate">focus delegate</dfn> for a <var>focusTarget</var>, given an optional string
  <var>focusTrigger</var> (default "<code>other</code>"), is given by the following steps:</p>

  <ol><li><p>If <var>focusTarget</var> is a <a id="focus-processing-model:shadow-host-4" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a> and its <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="focus-processing-model:concept-element-shadow-root-2" data-x-internal="concept-element-shadow-root">shadow root</a>'s <a id="focus-processing-model:delegates-focus-3" href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus" data-x-internal="delegates-focus">delegates focus</a> is false,
   then return null.</p></li><li><p>Let <var>whereToLook</var> be <var>focusTarget</var>.</p></li><li><p>If <var>whereToLook</var> is a <a id="focus-processing-model:shadow-host-5" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a>, then set <var>whereToLook</var>
   to <var>whereToLook</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="focus-processing-model:concept-element-shadow-root-3" data-x-internal="concept-element-shadow-root">shadow
   root</a>.</p></li><li><p>Let <var>autofocusDelegate</var> be the <a href="#autofocus-delegate" id="focus-processing-model:autofocus-delegate">autofocus delegate</a> for
   <var>whereToLook</var> given <var>focusTrigger</var>.</p></li><li><p>If <var>autofocusDelegate</var> is not null, then return
   <var>autofocusDelegate</var>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="focus-processing-model:list-iterate" data-x-internal="list-iterate">For each</a> <var>descendant</var> of
    <var>whereToLook</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="focus-processing-model:descendant" data-x-internal="descendant">descendants</a>, in <a id="focus-processing-model:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
    order</a>:</p>

    <ol><li><p>Let <var>focusableArea</var> be null.</p></li><li><p>If <var>focusTarget</var> is a <code id="focus-processing-model:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> element and <var>descendant</var> is
     <a href="#sequentially-focusable" id="focus-processing-model:sequentially-focusable-2">sequentially focusable</a>, then set <var>focusableArea</var> to
     <var>descendant</var>.</p></li><li><p>Otherwise, if <var>focusTarget</var> is not a <code id="focus-processing-model:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code> and
     <var>descendant</var> is a <a href="#focusable-area" id="focus-processing-model:focusable-area-4">focusable area</a>, set <var>focusableArea</var> to
     <var>descendant</var>.</p></li><li>
      <p>Otherwise, set <var>focusableArea</var> to the result of <a href="#get-the-focusable-area" id="focus-processing-model:get-the-focusable-area">getting the focusable area</a> for <var>descendant</var> given
      <var>focusTrigger</var>.</p>

      <p class="note">This step can end up recursing, i.e., the <a href="#get-the-focusable-area" id="focus-processing-model:get-the-focusable-area-2">get the focusable area</a>
      steps might return the <a href="#focus-delegate" id="focus-processing-model:focus-delegate-2">focus delegate</a> of <var>descendant</var>.</p>
     </li><li><p>If <var>focusableArea</var> is not null, then return <var>focusableArea</var>.</p></li></ol>

    <p class="note">It's important that we are <em>not</em> looking at the <a href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant" id="focus-processing-model:shadow-including-descendant" data-x-internal="shadow-including-descendant">shadow-including descendants</a> here, but instead only
    at the <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="focus-processing-model:descendant-2" data-x-internal="descendant">descendants</a>. <a href="https://dom.spec.whatwg.org/#element-shadow-host" id="focus-processing-model:shadow-host-6" data-x-internal="shadow-host">Shadow
    hosts</a> are instead handled by the recursive case mentioned above.</p>
   </li><li><p>Return null.</p></li></ol>

  <p class="note">The above algorithm essentially returns the first suitable <a href="#focusable-area" id="focus-processing-model:focusable-area-5">focusable
  area</a> where the path between its <a href="#dom-anchor" id="focus-processing-model:dom-anchor-2">DOM anchor</a> and <var>focusTarget</var>
  delegates focus at any shadow tree boundaries.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="autofocus-delegate">autofocus delegate</dfn> for a <var>focus target</var> given a <var>focus
  trigger</var> is given by the following steps:</p>

  <ol><li>
    <p>For each <a id="focus-processing-model:descendant-3" href="https://dom.spec.whatwg.org/#concept-tree-descendant" data-x-internal="descendant">descendant</a> <var>descendant</var> of <var>focus target</var>, in
    <a id="focus-processing-model:tree-order-3" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>:</p>

    <ol><li><p>If <var>descendant</var> does not have an <code id="focus-processing-model:attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code> content attribute, then
     <a id="focus-processing-model:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>focusable area</var> be <var>descendant</var>, if <var>descendant</var> is a
     <a href="#focusable-area" id="focus-processing-model:focusable-area-6">focusable area</a>; otherwise let <var>focusable area</var> be the result of <a href="#get-the-focusable-area" id="focus-processing-model:get-the-focusable-area-3">getting the focusable area</a> for <var>descendant</var>
     given <var>focus trigger</var>.</p></li><li><p>If <var>focusable area</var> is null, then <a id="focus-processing-model:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>focusable area</var> is not <a href="#click-focusable" id="focus-processing-model:click-focusable">click focusable</a> and <var>focus
     trigger</var> is "<code>click</code>", then <a id="focus-processing-model:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Return <var>focusable area</var>.</p></li></ol>
   </li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="focusing-steps" data-export="">focusing steps</dfn> for an object <var>new focus target</var> that is either a
  <a href="#focusable-area" id="focus-processing-model:focusable-area-7">focusable area</a>, or an element that is not a <a href="#focusable-area" id="focus-processing-model:focusable-area-8">focusable area</a>, or a
  <a href="#navigable" id="focus-processing-model:navigable-4">navigable</a>, are as follows. They can optionally be run with a <var>fallback
  target</var> and a string <var>focus trigger</var>.</p>

  <ol><li><p>If <var>new focus target</var> is not a <a href="#focusable-area" id="focus-processing-model:focusable-area-9">focusable area</a>, then set <var>new
   focus target</var> to the result of <a href="#get-the-focusable-area" id="focus-processing-model:get-the-focusable-area-4">getting the focusable
   area</a> for <var>new focus target</var>, given <var>focus trigger</var> if it was
   passed.</p></li><li>
    <p>If <var>new focus target</var> is null, then:</p>

    <ol><li><p>If no <var>fallback target</var> was specified, then return.</p></li><li><p>Otherwise, set <var>new focus target</var> to the <var>fallback
     target</var>.</p></li></ol>
   </li><li><p>If <var>new focus target</var> is a <a href="#navigable-container" id="focus-processing-model:navigable-container-3">navigable container</a> with non-null
   <a href="#content-navigable" id="focus-processing-model:content-navigable-3">content navigable</a>, then set <var>new focus target</var> to the <a href="#content-navigable" id="focus-processing-model:content-navigable-4">content
   navigable</a>'s <a href="#nav-document" id="focus-processing-model:nav-document-3">active document</a>.</p></li><li><p>If <var>new focus target</var> is a <a href="#focusable-area" id="focus-processing-model:focusable-area-10">focusable area</a> and its <a href="#dom-anchor" id="focus-processing-model:dom-anchor-3">DOM
   anchor</a> is <a href="#inert" id="focus-processing-model:inert">inert</a>, then return.</p></li><li><p>If <var>new focus target</var> is the <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable-2">currently focused area of a top-level
   traversable</a>, then return.</p></li><li><p>Let <var>old chain</var> be the <a href="#current-focus-chain-of-a-top-level-traversable" id="focus-processing-model:current-focus-chain-of-a-top-level-traversable">current focus chain of the top-level traversable</a> in which <var>new focus
   target</var> finds itself.</p></li><li><p>Let <var>new chain</var> be the <a href="#focus-chain" id="focus-processing-model:focus-chain">focus chain</a> of <var>new
   focus target</var>.</p></li><li><p>Run the <a href="#focus-update-steps" id="focus-processing-model:focus-update-steps">focus update steps</a> with <var>old chain</var>, <var>new chain</var>,
   and <var>new focus target</var> respectively.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>User agents must <a href="#immediately" id="focus-processing-model:immediately">immediately</a> run the <a href="#focusing-steps" id="focus-processing-model:focusing-steps-2">focusing steps</a> for a
  <a href="#focusable-area" id="focus-processing-model:focusable-area-11">focusable area</a> or <a href="#navigable" id="focus-processing-model:navigable-5">navigable</a> <var>candidate</var> whenever the
  user attempts to move the focus to <var>candidate</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="unfocusing-steps">unfocusing steps</dfn> for an object <var>old focus target</var> that is
  either a <a href="#focusable-area" id="focus-processing-model:focusable-area-12">focusable area</a> or an element that is not a <a href="#focusable-area" id="focus-processing-model:focusable-area-13">focusable area</a> are as
  follows:</p>

  <ol><li><p>If <var>old focus target</var> is a <a id="focus-processing-model:shadow-host-7" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a> whose <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="focus-processing-model:concept-element-shadow-root-4" data-x-internal="concept-element-shadow-root">shadow root</a>'s <a id="focus-processing-model:delegates-focus-4" href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus" data-x-internal="delegates-focus">delegates focus</a> is true,
   and <var>old focus target</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="focus-processing-model:concept-element-shadow-root-5" data-x-internal="concept-element-shadow-root">shadow root</a>
   is a <a id="focus-processing-model:shadow-including-inclusive-ancestor-2" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-ancestor" data-x-internal="shadow-including-inclusive-ancestor">shadow-including inclusive ancestor</a> of the <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable-3">currently focused area of a
   top-level traversable</a>'s <a href="#dom-anchor" id="focus-processing-model:dom-anchor-4">DOM anchor</a>, then set <var>old focus target</var> to
   that <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable-4">currently focused area of a top-level traversable</a>.</p></li><li><p>If <var>old focus target</var> is <a href="#inert" id="focus-processing-model:inert-2">inert</a>, then return.</p></li><li><p>If <var>old focus target</var> is an <code id="focus-processing-model:the-area-element-3"><a href="#the-area-element">area</a></code> element and one of its shapes is
   the <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable-5">currently focused area of a top-level traversable</a>, or, if <var>old focus
   target</var> is an element with one or more scrollable regions, and one of them is the
   <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable-6">currently focused area of a top-level traversable</a>, then let <var>old focus
   target</var> be that <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable-7">currently focused area of a top-level traversable</a>.</p></li><li><p>Let <var>old chain</var> be the <a href="#current-focus-chain-of-a-top-level-traversable" id="focus-processing-model:current-focus-chain-of-a-top-level-traversable-2">current focus chain of the top-level traversable</a> in which <var>old focus
   target</var> finds itself.</p></li><li><p>If <var>old focus target</var> is not one of the entries in <var>old
   chain</var>, then return.</p></li><li><p>If <var>old focus target</var> is not a <a href="#focusable-area" id="focus-processing-model:focusable-area-14">focusable area</a>, then return.</p></li><li><p>Let <var>topDocument</var> be <var>old chain</var>'s last entry.</p></li><li>
    <p>If <var>topDocument</var>'s <a href="#node-navigable" id="focus-processing-model:node-navigable">node navigable</a> has <a href="#system-focus" id="focus-processing-model:system-focus">system focus</a>, then
    run the <a href="#focusing-steps" id="focus-processing-model:focusing-steps-3">focusing steps</a> for <var>topDocument</var>'s <a id="focus-processing-model:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>.</p>

    <p>Otherwise, apply any relevant platform-specific conventions for removing <a href="#system-focus" id="focus-processing-model:system-focus-2">system
    focus</a> from <var>topDocument</var>'s <a href="#node-navigable" id="focus-processing-model:node-navigable-2">node navigable</a>, and run the <a href="#focus-update-steps" id="focus-processing-model:focus-update-steps-2">focus
    update steps</a> given <var>old chain</var>, an empty list, and null.</p>
   </li></ol>
  </div>

  <p class="note">The <a href="#unfocusing-steps" id="focus-processing-model:unfocusing-steps">unfocusing steps</a> do not always result in the focus changing, even
  when applied to the <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable-8">currently focused area of a top-level traversable</a>. For
  example, if the <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable-9">currently focused area of a top-level traversable</a> is a
  <a id="focus-processing-model:viewport-3" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>, then it will usually keep its focus regardless until another
  <a href="#focusable-area" id="focus-processing-model:focusable-area-15">focusable area</a> is explicitly focused with the <a href="#focusing-steps" id="focus-processing-model:focusing-steps-4">focusing steps</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="focus-update-steps">focus update steps</dfn>, given an <var>old chain</var>, a <var>new chain</var>, and a <var>new focus target</var> respectively, are as
  follows:</p>

  <ol><li><p>If the last entry in <var>old chain</var> and the last entry in <var>new chain</var> are the same, pop the last entry from <var>old chain</var>
   and the last entry from <var>new chain</var> and redo this step.</p></li><li>
    <p>For each entry <var>entry</var> in <var>old chain</var>, in order, run
    these substeps:</p>

    <ol><li>
      <p>If <var>entry</var> is an <code id="focus-processing-model:the-input-element"><a href="#the-input-element">input</a></code> element, and the <code id="focus-processing-model:event-change"><a href="#event-change">change</a></code> event <a href="#concept-input-apply" id="focus-processing-model:concept-input-apply">applies</a>
      to the element, and the element does not have a defined <a id="focus-processing-model:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a>, and
      the user has changed the element's <a href="#concept-fe-value" id="focus-processing-model:concept-fe-value">value</a> or its list
      of <a href="#concept-input-type-file-selected" id="focus-processing-model:concept-input-type-file-selected">selected files</a> while the control
      was focused without committing that change (such that it is different to what it was when the
      control was first focused), then:</p>

      <ol><li><p>Set <var>entry</var>'s <a href="#user-validity" id="focus-processing-model:user-validity">user validity</a> to true.</p></li><li id="unfocus-causes-change-event"><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="focus-processing-model:concept-event-fire" data-x-internal="concept-event-fire">Fire an
       event</a> named <code id="focus-processing-model:event-change-2"><a href="#event-change">change</a></code> at the element, with the <code id="focus-processing-model:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to true.</p></li></ol>
     </li><li>
      <p>If <var>entry</var> is an element, let <var>blur event target</var> be
      <var>entry</var>.</p>

      <p>If <var>entry</var> is a <code id="focus-processing-model:document-3"><a href="#document">Document</a></code> object, let <var>blur event target</var> be
      that <code id="focus-processing-model:document-4"><a href="#document">Document</a></code> object's <a href="#concept-relevant-global" id="focus-processing-model:concept-relevant-global">relevant global object</a>.</p>

      <p>Otherwise, let <var>blur event target</var> be null.</p>
     </li><li><p>If <var>entry</var> is the last entry in <var>old chain</var>, and
     <var>entry</var> is an <code id="focus-processing-model:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>, and the last entry in <var>new
     chain</var> is also an <code id="focus-processing-model:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>, then let <var>related blur target</var>
     be the last entry in <var>new chain</var>. Otherwise, let <var>related blur
     target</var> be null.</p></li><li>
      <p>If <var>blur event target</var> is not null, <a href="#fire-a-focus-event" id="focus-processing-model:fire-a-focus-event">fire a focus event</a>
      named <code id="focus-processing-model:event-blur"><a href="#event-blur">blur</a></code> at <var>blur event target</var>, with
      <var>related blur target</var> as the related target.</p>

      <p id="note-sometimes-no-blur-event" class="note"><a href="#note-sometimes-no-blur-event" class="self-link"></a>In some cases, e.g., if <var>entry</var> is
      an <code id="focus-processing-model:the-area-element-4"><a href="#the-area-element">area</a></code> element's shape, a scrollable region, or a <a id="focus-processing-model:viewport-4" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>, no
      event is fired.</p>
     </li></ol>
   </li><li><p>Apply any relevant platform-specific conventions for focusing <var>new focus target</var>.
   (For example, some platforms select the contents of a text control when that control is
   focused.)</p></li><li>
    <p>For each entry <var>entry</var> in <var>new chain</var>, in reverse
    order, run these substeps:</p>

    <ol><li>
      <p>If <var>entry</var> is a <a href="#focusable-area" id="focus-processing-model:focusable-area-16">focusable area</a>, and the <a href="#focused-area-of-the-document" id="focus-processing-model:focused-area-of-the-document">focused area of the
      document</a> is not <var>entry</var>:</p>

      <ol><li><p>Set <var>document</var>'s <a href="#concept-relevant-global" id="focus-processing-model:concept-relevant-global-2">relevant global object</a>'s <a href="#window-navigation-api" id="focus-processing-model:window-navigation-api">navigation API</a>'s <a href="#focus-changed-during-ongoing-navigation" id="focus-processing-model:focus-changed-during-ongoing-navigation">focus changed during ongoing
       navigation</a> to true.</p></li><li><p>Designate <var>entry</var> as the <a href="#focused-area-of-the-document" id="focus-processing-model:focused-area-of-the-document-2">focused area of the document</a>.</p>
      </li></ol>
     </li><li>
      <p>If <var>entry</var> is an element, let <var>focus event target</var> be
      <var>entry</var>.</p>

      <p>If <var>entry</var> is a <code id="focus-processing-model:document-5"><a href="#document">Document</a></code> object, let <var>focus event target</var> be
      that <code id="focus-processing-model:document-6"><a href="#document">Document</a></code> object's <a href="#concept-relevant-global" id="focus-processing-model:concept-relevant-global-3">relevant global object</a>.</p>

      <p>Otherwise, let <var>focus event target</var> be null.</p>
     </li><li><p>If <var>entry</var> is the last entry in <var>new chain</var>, and
     <var>entry</var> is an <code id="focus-processing-model:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>, and the last entry in <var>old
     chain</var> is also an <code id="focus-processing-model:element-4"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>, then let <var>related focus target</var>
     be the last entry in <var>old chain</var>. Otherwise, let <var>related
     focus target</var> be null.</p></li><li>
      <p>If <var>focus event target</var> is not null, <a href="#fire-a-focus-event" id="focus-processing-model:fire-a-focus-event-2">fire a focus event</a>
      named <code id="focus-processing-model:event-focus"><a href="#event-focus">focus</a></code> at <var>focus event target</var>, with
      <var>related focus target</var> as the related target.</p>

      <p class="note">In some cases, e.g. if <var>entry</var> is an <code id="focus-processing-model:the-area-element-5"><a href="#the-area-element">area</a></code>
      element's shape, a scrollable region, or a <a id="focus-processing-model:viewport-5" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>, no event is fired.</p>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fire-a-focus-event">fire a focus event</dfn> named <var>e</var> at an element <var>t</var> with a given
  related target <var>r</var>, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="focus-processing-model:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named
  <var>e</var> at <var>t</var>, using <code id="focus-processing-model:focusevent"><a data-x-internal="focusevent" href="https://w3c.github.io/uievents/#focusevent">FocusEvent</a></code>, with the <code id="focus-processing-model:dom-focusevent-relatedtarget"><a data-x-internal="dom-focusevent-relatedtarget" href="https://w3c.github.io/uievents/#dom-focusevent-relatedtarget">relatedTarget</a></code> attribute initialized to <var>r</var>,
  the <code id="focus-processing-model:dom-uievent-view"><a data-x-internal="dom-uievent-view" href="https://w3c.github.io/uievents/#dom-uievent-view">view</a></code> attribute initialized to <var>t</var>'s
  <a id="focus-processing-model:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#concept-relevant-global" id="focus-processing-model:concept-relevant-global-4">relevant global object</a>, and the <a id="focus-processing-model:composed-flag" href="https://dom.spec.whatwg.org/#composed-flag" data-x-internal="composed-flag">composed
  flag</a> set.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>When a key event is to be routed in a <a href="#top-level-traversable" id="focus-processing-model:top-level-traversable">top-level traversable</a>, the user agent must
  run the following steps:</p>

  

  <ol><li><p>Let <var>target area</var> be the <a href="#currently-focused-area-of-a-top-level-traversable" id="focus-processing-model:currently-focused-area-of-a-top-level-traversable-10">currently focused area of the top-level traversable</a>.</p></li><li><p><a id="focus-processing-model:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>target area</var> is not null, since key events are only routed
   to <a href="#top-level-traversable" id="focus-processing-model:top-level-traversable-2">top-level traversables</a> that have <a href="#system-focus" id="focus-processing-model:system-focus-3">system
   focus</a>. Therefore, <var>target area</var> is a <a href="#focusable-area" id="focus-processing-model:focusable-area-17">focusable area</a>.</p></li><li><p>Let <var>target node</var> be <var>target area</var>'s <a href="#dom-anchor" id="focus-processing-model:dom-anchor-5">DOM anchor</a>.</p></li><li>
    <p>If <var>target node</var> is a <code id="focus-processing-model:document-7"><a href="#document">Document</a></code> that has a <a href="#the-body-element-2" id="focus-processing-model:the-body-element-2">body element</a>, then let <var>target node</var> be <a href="#the-body-element-2" id="focus-processing-model:the-body-element-2-2">the body
    element</a> of that <code id="focus-processing-model:document-8"><a href="#document">Document</a></code>.</p>

    <p>Otherwise, if <var>target node</var> is a <code id="focus-processing-model:document-9"><a href="#document">Document</a></code> object that has a non-null
    <a id="focus-processing-model:document-element-2" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>, then let <var>target node</var> be that <a id="focus-processing-model:document-element-3" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document
    element</a>.</p>
   </li><li>
    <p>If <var>target node</var> is not <a href="#inert" id="focus-processing-model:inert-3">inert</a>, then:</p>
    <ol><li><p>Let <var>canHandle</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="focus-processing-model:concept-event-dispatch" data-x-internal="concept-event-dispatch">dispatching</a> the key event at <var>target
     node</var>.</p></li><li><p>If <var>canHandle</var> is true, then let <var>target area</var> handle the key event.
     This might include <a href="#fire-a-click-event" id="focus-processing-model:fire-a-click-event">firing a <code>click</code> event</a> at <var>target node</var>.</p></li></ol>
   </li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="has-focus-steps" data-export="">has focus steps</dfn>, given a <code id="focus-processing-model:document-10"><a href="#document">Document</a></code> object <var>target</var>,
  are as follows:</p>

  <ol><li><p>If <var>target</var>'s <a href="#node-navigable" id="focus-processing-model:node-navigable-3">node navigable</a>'s <a href="#nav-top" id="focus-processing-model:nav-top">top-level
   traversable</a> does not have <a href="#system-focus" id="focus-processing-model:system-focus-4">system focus</a>, then return false.</p></li><li><p>Let <var>candidate</var> be <var>target</var>'s <a href="#node-navigable" id="focus-processing-model:node-navigable-4">node navigable</a>'s <a href="#nav-top" id="focus-processing-model:nav-top-2">top-level traversable</a>'s <a href="#active-document" id="focus-processing-model:active-document">active document</a>.</p></li><li>
    <p>While true:</p>

    <ol><li><p>If <var>candidate</var> is <var>target</var>, then return true.</p></li><li><p>If the <a href="#focused-area-of-the-document" id="focus-processing-model:focused-area-of-the-document-3">focused area</a> of
     <var>candidate</var> is a <a href="#navigable-container" id="focus-processing-model:navigable-container-4">navigable container</a> with a non-null <a href="#content-navigable" id="focus-processing-model:content-navigable-5">content
     navigable</a>, then set <var>candidate</var> to the <a href="#nav-document" id="focus-processing-model:nav-document-4">active
     document</a> of that <a href="#navigable-container" id="focus-processing-model:navigable-container-5">navigable container</a>'s <a href="#content-navigable" id="focus-processing-model:content-navigable-6">content
     navigable</a>.</p></li><li><p>Otherwise, return false.</p></li></ol>
   </li></ol>
  </div>



  <h4 id="sequential-focus-navigation"><span class="secno">6.6.5</span> <dfn>Sequential focus navigation</dfn><a href="#sequential-focus-navigation" class="self-link"></a></h4>

  <p>Each <code id="sequential-focus-navigation:document"><a href="#document">Document</a></code> has a <dfn id="sequential-focus-navigation-order">sequential focus navigation order</dfn>, which orders
  some or all of the <a href="#focusable-area" id="sequential-focus-navigation:focusable-area">focusable areas</a> in the
  <code id="sequential-focus-navigation:document-2"><a href="#document">Document</a></code> relative to each other. Its contents and ordering are given by the
  <a href="#flattened-tabindex-ordered-focus-navigation-scope" id="sequential-focus-navigation:flattened-tabindex-ordered-focus-navigation-scope">flattened tabindex-ordered focus navigation scope</a> of the <code id="sequential-focus-navigation:document-3"><a href="#document">Document</a></code>.</p>

  <p class="note">Per the rules defining the <a href="#flattened-tabindex-ordered-focus-navigation-scope" id="sequential-focus-navigation:flattened-tabindex-ordered-focus-navigation-scope-2">flattened tabindex-ordered focus navigation
  scope</a>, the ordering is not necessarily related to the <a id="sequential-focus-navigation:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> of the
  <code id="sequential-focus-navigation:document-4"><a href="#document">Document</a></code>.</p>

  <p>If a <a href="#focusable-area" id="sequential-focus-navigation:focusable-area-2">focusable area</a> is omitted from the <a href="#sequential-focus-navigation-order" id="sequential-focus-navigation:sequential-focus-navigation-order">sequential focus navigation
  order</a> of its <code id="sequential-focus-navigation:document-5"><a href="#document">Document</a></code>, then it is unreachable via <a href="#sequential-focus-navigation" id="sequential-focus-navigation:sequential-focus-navigation">sequential focus
  navigation</a>.</p>

  <p>There can also be a <dfn id="sequential-focus-navigation-starting-point">sequential focus navigation starting point</dfn>. It is initially
  unset. The user agent may set it when the user indicates that it should be moved.</p>

  <p class="example">For example, the user agent could set it to the position of the user's click if
  the user clicks on the document contents.</p>

  <p class="note">User agents are required to set the <a href="#sequential-focus-navigation-starting-point" id="sequential-focus-navigation:sequential-focus-navigation-starting-point">sequential focus navigation starting
  point</a> to the <a href="#target-element" id="sequential-focus-navigation:target-element">target element</a> when <a href="#navigate-fragid" id="sequential-focus-navigation:navigate-fragid">navigating
  to a fragment</a>.</p>

  <p>A <dfn id="sequential-focus-direction">sequential focus direction</dfn> is one of two possible values: "<dfn id="sequential-focus-forward"><code>forward</code></dfn>", or "<dfn id="sequential-focus-backward"><code>backward</code></dfn>". They are used in the below algorithms
  to describe the direction in which sequential focus travels at the user's request.</p>

  <p>A <dfn id="selection-mechanism">selection mechanism</dfn> is one of two possible values: "<dfn id="selection-mechanism-dom"><code>DOM</code></dfn>", or
  "<dfn id="selection-mechanism-sequential"><code>sequential</code></dfn>". They are used to
  describe how the <a href="#sequential-navigation-search-algorithm" id="sequential-focus-navigation:sequential-navigation-search-algorithm">sequential navigation search algorithm</a> finds the <a href="#focusable-area" id="sequential-focus-navigation:focusable-area-3">focusable
  area</a> it returns.</p>

  <div data-algorithm="">
  <p>When the user requests that focus move from the <a href="#currently-focused-area-of-a-top-level-traversable" id="sequential-focus-navigation:currently-focused-area-of-a-top-level-traversable">currently focused area of a top-level
  traversable</a> to the next or previous <a href="#focusable-area" id="sequential-focus-navigation:focusable-area-4">focusable area</a> (e.g., as the default
  action of pressing the <kbd><kbd>tab</kbd></kbd> key), or when the user requests that focus
  sequentially move to a <a href="#top-level-traversable" id="sequential-focus-navigation:top-level-traversable">top-level traversable</a> in the first place (e.g., from the
  browser's location bar), the user agent must use the following algorithm:</p>

  <ol><li><p>Let <var>starting point</var> be the <a href="#currently-focused-area-of-a-top-level-traversable" id="sequential-focus-navigation:currently-focused-area-of-a-top-level-traversable-2">currently focused area of a top-level
   traversable</a>, if the user requested to move focus sequentially from there, or else the
   <a href="#top-level-traversable" id="sequential-focus-navigation:top-level-traversable-2">top-level traversable</a> itself, if the user instead requested to move focus from
   outside the <a href="#top-level-traversable" id="sequential-focus-navigation:top-level-traversable-3">top-level traversable</a>.</p></li><li><p>If there is a <a href="#sequential-focus-navigation-starting-point" id="sequential-focus-navigation:sequential-focus-navigation-starting-point-2">sequential focus navigation starting point</a> defined and it is
   inside <var>starting point</var>, then let <var>starting point</var> be the <a href="#sequential-focus-navigation-starting-point" id="sequential-focus-navigation:sequential-focus-navigation-starting-point-3">sequential
   focus navigation starting point</a> instead.</p></li><li>
    <p>Let <var>direction</var> be "<code id="sequential-focus-navigation:sequential-focus-forward"><a href="#sequential-focus-forward">forward</a></code>" if the
    user requested the next control, and "<code id="sequential-focus-navigation:sequential-focus-backward"><a href="#sequential-focus-backward">backward</a></code>" if the user requested the previous
    control.</p>

    <p class="note">Typically, pressing <kbd><kbd>tab</kbd></kbd> requests the next control, and
    pressing <kbd><kbd>shift</kbd> + <kbd>tab</kbd></kbd> requests the previous control.</p>
   </li><li>
    <p><i>Loop</i>: Let <var>selection mechanism</var> be "<code id="sequential-focus-navigation:selection-mechanism-sequential"><a href="#selection-mechanism-sequential">sequential</a></code>" if <var>starting point</var> is a
    <a href="#navigable" id="sequential-focus-navigation:navigable">navigable</a> or if <var>starting point</var> is in its <code id="sequential-focus-navigation:document-6"><a href="#document">Document</a></code>'s
    <a href="#sequential-focus-navigation-order" id="sequential-focus-navigation:sequential-focus-navigation-order-2">sequential focus navigation order</a>.</p>

    <p>Otherwise, <var>starting point</var> is not in its <code id="sequential-focus-navigation:document-7"><a href="#document">Document</a></code>'s <a href="#sequential-focus-navigation-order" id="sequential-focus-navigation:sequential-focus-navigation-order-3">sequential
    focus navigation order</a>; let <var>selection mechanism</var> be "<code id="sequential-focus-navigation:selection-mechanism-dom"><a href="#selection-mechanism-dom">DOM</a></code>".</p>
   </li><li><p>Let <var>candidate</var> be the result of running the <a href="#sequential-navigation-search-algorithm" id="sequential-focus-navigation:sequential-navigation-search-algorithm-2">sequential navigation search
   algorithm</a> with <var>starting point</var>, <var>direction</var>, and <var>selection
   mechanism</var>.</p></li><li><p>If <var>candidate</var> is not null, then run the <a href="#focusing-steps" id="sequential-focus-navigation:focusing-steps">focusing steps</a> for
   <var>candidate</var> and return.</p></li><li><p>Otherwise, unset the <a href="#sequential-focus-navigation-starting-point" id="sequential-focus-navigation:sequential-focus-navigation-starting-point-4">sequential focus navigation starting point</a>.</p></li><li>
    <p>If <var>starting point</var> is a <a href="#top-level-traversable" id="sequential-focus-navigation:top-level-traversable-4">top-level traversable</a>, or a
    <a href="#focusable-area" id="sequential-focus-navigation:focusable-area-5">focusable area</a> in the <a href="#top-level-traversable" id="sequential-focus-navigation:top-level-traversable-5">top-level traversable</a>, the user agent
    should transfer focus to its own controls appropriately (if any), honouring
    <var>direction</var>, and then return.</p>

    <p class="example">For example, if <var>direction</var> is <i>backward</i>, then the last
    <a href="#sequentially-focusable" id="sequential-focus-navigation:sequentially-focusable">sequentially focusable</a> control before the browser's rendering area would be the
    control to focus.</p>

    <p>If the user agent has no <a href="#sequentially-focusable" id="sequential-focus-navigation:sequentially-focusable-2">sequentially focusable</a> controls — a kiosk-mode
    browser, for instance — then the user agent may instead restart these steps with the
    <var>starting point</var> being the <a href="#top-level-traversable" id="sequential-focus-navigation:top-level-traversable-6">top-level traversable</a> itself.</p>

    
   </li><li><p>Otherwise, <var>starting point</var> is a <a href="#focusable-area" id="sequential-focus-navigation:focusable-area-6">focusable area</a> in a <a href="#child-navigable" id="sequential-focus-navigation:child-navigable">child
   navigable</a>. Set <var>starting point</var> to that <a href="#child-navigable" id="sequential-focus-navigation:child-navigable-2">child navigable</a>'s <a href="#nav-parent" id="sequential-focus-navigation:nav-parent">parent</a> and return to the step labeled <i>loop</i>.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>The <dfn id="sequential-navigation-search-algorithm">sequential navigation search algorithm</dfn>, given a <a href="#focusable-area" id="sequential-focus-navigation:focusable-area-7">focusable area</a>
  <var>starting point</var>, <a href="#sequential-focus-direction" id="sequential-focus-navigation:sequential-focus-direction">sequential focus direction</a> <var>direction</var>, and
  <a href="#selection-mechanism" id="sequential-focus-navigation:selection-mechanism">selection mechanism</a> <var>selection mechanism</var>, consists of the following steps.
  They return a <a href="#focusable-area" id="sequential-focus-navigation:focusable-area-8">focusable area</a>-or-null.</p>

  <ol><li>
    <p>Pick the appropriate cell from the following table, and follow the instructions in that
    cell.</p>

    <p>The appropriate cell is the one that is from the column whose header describes
    <var>direction</var> and from the first row whose header describes <var>starting point</var> and
    <var>selection mechanism</var>.</p>

    <table><thead><tr><th>
       </th><th><var>direction</var> is "<code id="sequential-focus-navigation:sequential-focus-forward-2"><a href="#sequential-focus-forward">forward</a></code>"
       </th><th><var>direction</var> is "<code id="sequential-focus-navigation:sequential-focus-backward-2"><a href="#sequential-focus-backward">backward</a></code>"
     </th></tr></thead><tbody><tr><th><var>starting point</var> is a <a href="#navigable" id="sequential-focus-navigation:navigable-2">navigable</a>
       </th><td>Let <var>candidate</var> be the first <a href="#suitable-sequentially-focusable-area" id="sequential-focus-navigation:suitable-sequentially-focusable-area">suitable sequentially focusable area</a>
       in <var>starting point</var>'s <a href="#nav-document" id="sequential-focus-navigation:nav-document">active document</a>, if any; or
       else null
       </td><td>Let <var>candidate</var> be the last <a href="#suitable-sequentially-focusable-area" id="sequential-focus-navigation:suitable-sequentially-focusable-area-2">suitable sequentially focusable area</a>
       in <var>starting point</var>'s <a href="#nav-document" id="sequential-focus-navigation:nav-document-2">active document</a>, if any; or
       else null
      </td></tr><tr><th><var>selection mechanism</var> is "<code id="sequential-focus-navigation:selection-mechanism-dom-2"><a href="#selection-mechanism-dom">DOM</a></code>"
       </th><td>
        <p>Let <var>candidate</var> be the <a href="#suitable-sequentially-focusable-area" id="sequential-focus-navigation:suitable-sequentially-focusable-area-3">suitable sequentially focusable area</a>, that
        appears nearest after <var>starting point</var> in <var>starting point</var>'s
        <code id="sequential-focus-navigation:document-8"><a href="#document">Document</a></code>, in <a id="sequential-focus-navigation:shadow-including-tree-order" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>, if any; or else null</p>

        <p class="note">In this case, <var>starting point</var> does not necessarily belong to its
        <code id="sequential-focus-navigation:document-9"><a href="#document">Document</a></code>'s <a href="#sequential-focus-navigation-order" id="sequential-focus-navigation:sequential-focus-navigation-order-4">sequential focus navigation order</a>, so we'll select the
        <a href="#suitable-sequentially-focusable-area" id="sequential-focus-navigation:suitable-sequentially-focusable-area-4">suitable</a> <a href="https://infra.spec.whatwg.org/#list-item" id="sequential-focus-navigation:list-item" data-x-internal="list-item">item</a> from that list that comes <em>after</em> <var>starting point</var> in
        <a id="sequential-focus-navigation:shadow-including-tree-order-2" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>.</p>
       </td><td>Let <var>candidate</var> be the <a href="#suitable-sequentially-focusable-area" id="sequential-focus-navigation:suitable-sequentially-focusable-area-5">suitable sequentially focusable area</a>, that
       appears nearest before <var>starting point</var> in <var>starting point</var>'s
       <code id="sequential-focus-navigation:document-10"><a href="#document">Document</a></code>, in <a id="sequential-focus-navigation:shadow-including-tree-order-3" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>, if any; or else null
      </td></tr><tr><th><var>selection mechanism</var> is "<code id="sequential-focus-navigation:selection-mechanism-sequential-2"><a href="#selection-mechanism-sequential">sequential</a></code>"
       </th><td>Let <var>candidate</var> be the first <a href="#suitable-sequentially-focusable-area" id="sequential-focus-navigation:suitable-sequentially-focusable-area-6">suitable sequentially focusable area</a>
       after <var>starting point</var>, in <var>starting point</var>'s <code id="sequential-focus-navigation:document-11"><a href="#document">Document</a></code>'s
       <a href="#sequential-focus-navigation-order" id="sequential-focus-navigation:sequential-focus-navigation-order-5">sequential focus navigation order</a>, if any; or else null
       </td><td>Let <var>candidate</var> be the last <a href="#suitable-sequentially-focusable-area" id="sequential-focus-navigation:suitable-sequentially-focusable-area-7">suitable sequentially focusable area</a>
       before <var>starting point</var>, in <var>starting point</var>'s <code id="sequential-focus-navigation:document-12"><a href="#document">Document</a></code>'s
       <a href="#sequential-focus-navigation-order" id="sequential-focus-navigation:sequential-focus-navigation-order-6">sequential focus navigation order</a>, if any; or else null
    </td></tr></tbody></table>

    <p>A <dfn id="suitable-sequentially-focusable-area">suitable sequentially focusable area</dfn> is a <a href="#focusable-area" id="sequential-focus-navigation:focusable-area-9">focusable area</a> whose
    <a href="#dom-anchor" id="sequential-focus-navigation:dom-anchor">DOM anchor</a> is not <a href="#inert" id="sequential-focus-navigation:inert">inert</a> and is <a href="#sequentially-focusable" id="sequential-focus-navigation:sequentially-focusable-3">sequentially
    focusable</a>.</p>
   </li><li>
    <p>If <var>candidate</var> is a <a href="#navigable-container" id="sequential-focus-navigation:navigable-container">navigable container</a> with a non-null <a href="#content-navigable" id="sequential-focus-navigation:content-navigable">content
    navigable</a>, then:</p>

    <ol><li><p>Let <var>recursive candidate</var> be the result of running the <a href="#sequential-navigation-search-algorithm" id="sequential-focus-navigation:sequential-navigation-search-algorithm-3">sequential
     navigation search algorithm</a> with <var>candidate</var>'s <a href="#content-navigable" id="sequential-focus-navigation:content-navigable-2">content navigable</a>,
     <var>direction</var>, and "<code id="sequential-focus-navigation:selection-mechanism-sequential-3"><a href="#selection-mechanism-sequential">sequential</a></code>".</p></li><li><p>If <var>recursive candidate</var> is null, then return the result of running the
     <a href="#sequential-navigation-search-algorithm" id="sequential-focus-navigation:sequential-navigation-search-algorithm-4">sequential navigation search algorithm</a> with <var>candidate</var>,
     <var>direction</var>, and <var>selection mechanism</var>.</p></li><li><p>Otherwise, set <var>candidate</var> to <var>recursive candidate</var>.</p></li></ol>
   </li><li><p>Return <var>candidate</var>.</p></li></ol>
  </div>

  


  <h4 id="focus-management-apis"><span class="secno">6.6.6</span> Focus management APIs<a href="#focus-management-apis" class="self-link"></a></h4>

  <pre><code class="idl"><c- b="">dictionary</c-> <dfn id="focusoptions" data-dfn-type="dictionary"><c- g="">FocusOptions</c-></dfn> {
  <c- b="">boolean</c-> <a href="#dom-focusoptions-preventscroll" id="focus-management-apis:dom-focusoptions-preventscroll"><c- g="">preventScroll</c-></a> = <c- b="">false</c->;
  <c- b="">boolean</c-> <a href="#dom-focusoptions-focusvisible" id="focus-management-apis:dom-focusoptions-focusvisible"><c- g="">focusVisible</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>documentOrShadowRoot</var>.<a href="#dom-documentorshadowroot-activeelement" id="dom-documentorshadowroot-activeelement-dev">activeElement</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement" title="The activeElement read-only property of the Document interface returns the Element within the DOM that currently has focus.">Document/activeElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/activeElement" title="The activeElement read-only property of the ShadowRoot interface returns the element within the shadow tree that has focus.">ShadowRoot/activeElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>53+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the deepest element in <var>documentOrShadowRoot</var> through which or to which key
    events are being routed. This is, roughly speaking, the focused element in the document.</p>

    <p>For the purposes of this API, when a <a href="#child-navigable" id="focus-management-apis:child-navigable">child navigable</a> is focused, its <a href="#nav-container" id="focus-management-apis:nav-container">container</a> is <a href="#bc-focus-ergo-bcc-focus">focused</a>
    within its <a href="#nav-parent" id="focus-management-apis:nav-parent">parent</a>'s <a href="#nav-document" id="focus-management-apis:nav-document">active
    document</a>. For example, if the user moves the focus to a text control in an
    <code id="focus-management-apis:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, the <code id="focus-management-apis:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> is the element returned by the <code id="focus-management-apis:dom-documentorshadowroot-activeelement"><a href="#dom-documentorshadowroot-activeelement">activeElement</a></code> API in the
    <code id="focus-management-apis:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code>'s <a id="focus-management-apis:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p>

    <p>Similarly, when the focused element is in a different <a id="focus-management-apis:node-tree" href="https://dom.spec.whatwg.org/#concept-node-tree" data-x-internal="node-tree">node tree</a> than
    <var>documentOrShadowRoot</var>, the element returned will be the <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="focus-management-apis:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">host</a> that's located in the same <a id="focus-management-apis:node-tree-2" href="https://dom.spec.whatwg.org/#concept-node-tree" data-x-internal="node-tree">node
    tree</a> as <var>documentOrShadowRoot</var> if  <var>documentOrShadowRoot</var> is a
    <a id="focus-management-apis:shadow-including-inclusive-ancestor" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-ancestor" data-x-internal="shadow-including-inclusive-ancestor">shadow-including inclusive ancestor</a> of the focused element, and null if not.</p>
   </dd><dt><code><var>document</var>.<a href="#dom-document-hasfocus" id="dom-document-hasfocus-dev">hasFocus</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus" title="The hasFocus() method of the Document interface returns a boolean value indicating whether the document or any element inside the document has focus. This method can be used to determine whether the active element in a document has focus.">Document/hasFocus</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns true if key events are being routed through or to <var>document</var>; otherwise,
    returns false. Roughly speaking, this corresponds to <var>document</var>, or a document nested
    inside <var>document</var>, being focused.</p>
   </dd><dt><code><var>window</var>.<a href="#dom-window-focus" id="dom-window-focus-dev">focus</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/focus" title="Makes a request to bring the window to the front. It may fail due to user settings and the window isn't guaranteed to be frontmost before this method returns.">Window/focus</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    

    <p>Moves the focus to <var>window</var>'s <a href="#window-navigable" id="focus-management-apis:window-navigable">navigable</a>, if
    any.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-focus" id="dom-focus-dev">focus</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus" title="The HTMLElement.focus() method sets focus on the specified element, if it can be focused. The focused element is the element that will receive keyboard and similar events by default.">HTMLElement/focus</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dt><code><var>element</var>.<a href="#dom-focus" id="focus-management-apis:dom-focus">focus</a>({ <a href="#dom-focusoptions-preventscroll" id="focus-management-apis:dom-focusoptions-preventscroll-2">preventScroll</a>, <a href="#dom-focusoptions-focusvisible" id="focus-management-apis:dom-focusoptions-focusvisible-2">focusVisible</a> })</code></dt><dd>
    <p>Moves the focus to <var>element</var>.</p>

    <p>If <var>element</var> is a <a href="#navigable-container" id="focus-management-apis:navigable-container">navigable container</a>, moves the focus to its
    <a href="#content-navigable" id="focus-management-apis:content-navigable">content navigable</a> instead.</p>

    <p>By default, this method also scrolls <var>element</var> into view. Providing the <code id="focus-management-apis:dom-focusoptions-preventscroll-3"><a href="#dom-focusoptions-preventscroll">preventScroll</a></code> option and setting it to true
    prevents this behavior.</p>

    <p>By default, user agents use <a id="focus-management-apis:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> heuristics to determine
    whether to <a id="focus-management-apis:indicate-focus" href="https://drafts.csswg.org/selectors/#indicate-focus" data-x-internal="indicate-focus">indicate focus</a> via a focus ring. Providing the <code id="focus-management-apis:dom-focusoptions-focusvisible-3"><a href="#dom-focusoptions-focusvisible">focusVisible</a></code> option and setting it to true will
    ensure the focus ring is always visible.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-blur" id="dom-blur-dev">blur</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur" title="The HTMLElement.blur() method removes keyboard focus from the current element.">HTMLElement/blur</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Moves the focus to the <a id="focus-management-apis:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>. Use of this method is discouraged; if you want
    to focus the <a id="focus-management-apis:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>, call the <code id="focus-management-apis:dom-focus-2"><a href="#dom-focus">focus()</a></code> method on
    the <code id="focus-management-apis:document"><a href="#document">Document</a></code>'s <a id="focus-management-apis:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>.</p>

    <p>Do not use this method to hide the focus ring if you find the focus ring unsightly. Instead,
    use the <code id="focus-management-apis::focus-visible"><a data-x-internal=":focus-visible" href="https://drafts.csswg.org/selectors/#the-focus-visible-pseudo">:focus-visible</a></code> pseudo-class to override the <a id="focus-management-apis:'outline'" href="https://drafts.csswg.org/css-ui/#outline" data-x-internal="'outline'">'outline'</a>
    property, and provide a different way to show what element is focused. Be aware that if an
    alternative focusing style isn't made available, the page will be significantly less usable for
    people who primarily navigate pages using a keyboard, or those with reduced vision who use focus
    outlines to help them navigate the page.</p>

    

    <div class="example">

     <p>For example, to hide the outline from <code id="focus-management-apis:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements and instead use a
     yellow background to indicate focus, you could use:</p>

     <pre><code class="css"><c- f="">textarea:focus-visible </c-><c- p="">{</c-> <c- k="">outline</c-><c- p="">:</c-> none<c- p="">;</c-> <c- k="">background</c-><c- p="">:</c-> yellow<c- p="">;</c-> <c- k="">color</c-><c- p="">:</c-> black<c- p="">;</c-> <c- p="">}</c-></code></pre>

    </div>
   </dd></dl>

  

  <div data-algorithm="">
  <p id="dom-document-activeelement">The <code id="focus-management-apis:documentorshadowroot"><a href="#documentorshadowroot">DocumentOrShadowRoot</a></code> <dfn data-dfn-for="DocumentOrShadowRoot" id="dom-documentorshadowroot-activeelement" data-dfn-type="attribute"><code>activeElement</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>candidate</var> be <a id="focus-management-apis:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="focus-management-apis:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#focused-area-of-the-document" id="focus-management-apis:focused-area-of-the-document">focused area</a>'s <a href="#dom-anchor" id="focus-management-apis:dom-anchor">DOM anchor</a>.</p></li><li><p>Set <var>candidate</var> to the result of <a href="https://dom.spec.whatwg.org/#retarget" id="focus-management-apis:dom-retarget" data-x-internal="dom-retarget">retargeting</a>
   <var>candidate</var> against <a id="focus-management-apis:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>If <var>candidate</var>'s <a id="focus-management-apis:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> is not <a id="focus-management-apis:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, then return
   null.</p></li><li><p>If <var>candidate</var> is not a <code id="focus-management-apis:document-2"><a href="#document">Document</a></code> object, then return
   <var>candidate</var>.</p></li><li><p>If <var>candidate</var> has a <a href="#the-body-element-2" id="focus-management-apis:the-body-element-2">body element</a>, then
   return that <a href="#the-body-element-2" id="focus-management-apis:the-body-element-2-2">body element</a>.</p></li><li><p>If <var>candidate</var>'s <a id="focus-management-apis:document-element-2" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> is non-null, then return that
   <a id="focus-management-apis:document-element-3" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>.</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="focus-management-apis:document-3"><a href="#document">Document</a></code> <dfn data-dfn-for="Document" id="dom-document-hasfocus" data-dfn-type="method"><code>hasFocus()</code></dfn> method steps are to return the result of
  running the <a href="#has-focus-steps" id="focus-management-apis:has-focus-steps">has focus steps</a> given <a id="focus-management-apis:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <code id="focus-management-apis:window"><a href="#window">Window</a></code> <dfn data-dfn-for="Window" id="dom-window-focus" data-dfn-type="method"><code>focus()</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>current</var> be <a id="focus-management-apis:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="focus-management-apis:window-navigable-2">navigable</a>.</p></li><li><p>If <var>current</var> is null, then return.</p></li><li><p>If the <a href="#allow-focus-steps" id="focus-management-apis:allow-focus-steps">allow focus steps</a> given <var>current</var>'s <a href="#nav-document" id="focus-management-apis:nav-document-2">active document</a> return false, then return.</p></li><li><p>Run the <a href="#focusing-steps" id="focus-management-apis:focusing-steps">focusing steps</a> with <var>current</var>.</p></li><li><p>If <var>current</var> is a <a href="#top-level-traversable" id="focus-management-apis:top-level-traversable">top-level traversable</a>, user agents are encouraged
   to trigger some sort of notification to indicate to the user that the page is attempting to gain
   focus.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/blur" title="Shifts focus away from the window.">Window/blur</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <code id="focus-management-apis:window-2"><a href="#window">Window</a></code> <dfn data-dfn-for="Window" id="dom-window-blur" data-dfn-type="method"><code>blur()</code></dfn> method steps are to do nothing.</p>
  </div>

  <p class="note">Historically, the <code id="focus-management-apis:dom-window-focus"><a href="#dom-window-focus">focus()</a></code> and <code id="focus-management-apis:dom-window-blur"><a href="#dom-window-blur">blur()</a></code> methods actually affected the system-level focus of the
  system widget (e.g., tab or window) that contained the <a href="#navigable" id="focus-management-apis:navigable">navigable</a>, but hostile sites
  widely abuse this behavior to the user's detriment.</p>

  <hr>

  <div data-algorithm="">
  <p>The <code id="focus-management-apis:htmlorsvgelement"><a href="#htmlorsvgelement">HTMLOrSVGElement</a></code> <dfn data-dfn-for="HTMLOrSVGElement" id="dom-focus" data-dfn-type="method"><code>focus(<var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If the <a href="#allow-focus-steps" id="focus-management-apis:allow-focus-steps-2">allow focus steps</a> given <a id="focus-management-apis:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="focus-management-apis:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>
   return false, then return.</p></li><li><p>Run the <a href="#focusing-steps" id="focus-management-apis:focusing-steps-2">focusing steps</a> for <a id="focus-management-apis:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>If <var>options</var>["<dfn data-dfn-for="FocusOptions" id="dom-focusoptions-focusvisible" data-dfn-type="dict-member"><code>focusVisible</code></dfn>"] is true, or does not <a href="https://infra.spec.whatwg.org/#map-exists" id="focus-management-apis:map-exists" data-x-internal="map-exists">exist</a> but in an <a id="focus-management-apis:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> way the user agent
   determines it would be best to do so, then <a id="focus-management-apis:indicate-focus-2" href="https://drafts.csswg.org/selectors/#indicate-focus" data-x-internal="indicate-focus">indicate focus</a>.</p></li><li><p>If <var>options</var>["<dfn data-dfn-for="FocusOptions" id="dom-focusoptions-preventscroll" data-dfn-type="dict-member"><code>preventScroll</code></dfn>"] is false, then <a id="focus-management-apis:scroll-a-target-into-view" href="https://drafts.csswg.org/cssom-view/#scroll-a-target-into-view" data-x-internal="scroll-a-target-into-view">scroll
   a target into view</a> given <a id="focus-management-apis:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, "<code>auto</code>", "<code>center</code>", and "<code>center</code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="focus-management-apis:htmlorsvgelement-2"><a href="#htmlorsvgelement">HTMLOrSVGElement</a></code> <dfn data-dfn-for="HTMLOrSVGElement" id="dom-blur" data-dfn-type="method"><code>blur()</code></dfn> method steps are:</p>

  <ol><li>
    <p>The user agent should run the <a href="#unfocusing-steps" id="focus-management-apis:unfocusing-steps">unfocusing steps</a> given <a id="focus-management-apis:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>

    <p>User agents may instead selectively or uniformly do nothing, for usability reasons.</p>
   </li></ol>
  </div>

  <p class="example">For example, if the <code id="focus-management-apis:dom-blur"><a href="#dom-blur">blur()</a></code> 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.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="allow-focus-steps" data-export="">allow focus steps</dfn>, given a <code id="focus-management-apis:document-4"><a href="#document">Document</a></code> object
  <var>target</var>, are:</p>

  <ol><li><p>If <var>target</var> is <a href="#allowed-to-use" id="focus-management-apis:allowed-to-use">allowed to use</a> the "<code id="focus-management-apis:focus-without-user-activation-feature"><a href="#focus-without-user-activation-feature">focus-without-user-activation</a></code>" feature,
   then return true.</p></li><li><p>If <var>target</var>'s <a href="#concept-relevant-global" id="focus-management-apis:concept-relevant-global">relevant global object</a> has <a href="#transient-activation" id="focus-management-apis:transient-activation">transient
   activation</a>, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  


  <h4 id="the-autofocus-attribute"><span class="secno">6.6.7</span> <span id="autofocusing-a-form-control:-the-autofocus-attribute"></span>The <code id="the-autofocus-attribute:attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code> attribute<a href="#the-autofocus-attribute" class="self-link"></a></h4>

  <p>The <dfn data-dfn-for="html-global" id="attr-fe-autofocus" data-dfn-type="element-attr"><code>autofocus</code></dfn>
  content attribute allows the author to indicate that an element is to be focused as soon as the
  page is loaded, allowing the user to just start typing without having to manually focus the main
  element.</p>

  <p>When the <code id="the-autofocus-attribute:attr-fe-autofocus-2"><a href="#attr-fe-autofocus">autofocus</a></code> attribute is specified on an element
  inside <code id="the-autofocus-attribute:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> elements or <a href="#html-elements" id="the-autofocus-attribute:html-elements">HTML elements</a> whose <code id="the-autofocus-attribute:attr-popover"><a href="#attr-popover">popover</a></code> attribute is set, then it will be focused when the dialog or
  popover becomes shown.</p>

  <p>The <code id="the-autofocus-attribute:attr-fe-autofocus-3"><a href="#attr-fe-autofocus">autofocus</a></code> attribute is a <a href="#boolean-attribute" id="the-autofocus-attribute:boolean-attribute">boolean
  attribute</a>.</p>

  <div data-algorithm="">
  <p>To find the <dfn id="nearest-ancestor-autofocus-scoping-root-element">nearest ancestor autofocus scoping root element</dfn> given an
  <code id="the-autofocus-attribute:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> <var>element</var>:</p>

  <ol><li><p>If <var>element</var> is a <code id="the-autofocus-attribute:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code> element, then return
   <var>element</var>.</p></li><li><p>If <var>element</var>'s <code id="the-autofocus-attribute:attr-popover-2"><a href="#attr-popover">popover</a></code> attribute is not in the
   <a href="#attr-popover-none-state" id="the-autofocus-attribute:attr-popover-none-state">No Popover</a> state, then return
   <var>element</var>.</p></li><li><p>Let <var>ancestor</var> be <var>element</var>.</p></li><li>
    <p>While <var>ancestor</var> has a <a id="the-autofocus-attribute:parent-element" href="https://dom.spec.whatwg.org/#parent-element" data-x-internal="parent-element">parent element</a>:</p>

    <ol><li><p>Set <var>ancestor</var> to <var>ancestor</var>'s <a id="the-autofocus-attribute:parent-element-2" href="https://dom.spec.whatwg.org/#parent-element" data-x-internal="parent-element">parent element</a>.</p></li><li><p>If <var>ancestor</var> is a <code id="the-autofocus-attribute:the-dialog-element-3"><a href="#the-dialog-element">dialog</a></code> element, then return
     <var>ancestor</var>.</p></li><li><p>If <var>ancestor</var>'s <code id="the-autofocus-attribute:attr-popover-3"><a href="#attr-popover">popover</a></code> attribute is not in
     the <a href="#attr-popover-none-state" id="the-autofocus-attribute:attr-popover-none-state-2">No Popover</a> state, then return
     <var>ancestor</var>.</p></li></ol>
   </li><li><p>Return <var>ancestor</var>.</p></li></ol>
  </div>

  <p>There must not be two elements with the same <a href="#nearest-ancestor-autofocus-scoping-root-element" id="the-autofocus-attribute:nearest-ancestor-autofocus-scoping-root-element">nearest ancestor autofocus scoping root
  element</a> that both have the <code id="the-autofocus-attribute:attr-fe-autofocus-4"><a href="#attr-fe-autofocus">autofocus</a></code> attribute
  specified.</p>

  

  <p>Each <code id="the-autofocus-attribute:document"><a href="#document">Document</a></code> has an <dfn id="autofocus-candidates">autofocus candidates</dfn> <a id="the-autofocus-attribute:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>,
  initially empty.</p>

  <p>Each <code id="the-autofocus-attribute:document-2"><a href="#document">Document</a></code> has an <dfn id="autofocus-processed-flag">autofocus processed flag</dfn> boolean, initially
  false.</p>

  <div data-algorithm="">
  <p>When an element with the <code id="the-autofocus-attribute:attr-fe-autofocus-5"><a href="#attr-fe-autofocus">autofocus</a></code> attribute specified
  is <a href="#insert-an-element-into-a-document" id="the-autofocus-attribute:insert-an-element-into-a-document">inserted into a document</a>, run the
  following steps:</p>

  <ol><li><p>If the user has indicated (for example, by starting to type in a form control) that they
   do not wish focus to be changed, then optionally return.</p></li><li><p>Let <var>target</var> be the element's <a id="the-autofocus-attribute:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>target</var> is not <a href="#fully-active" id="the-autofocus-attribute:fully-active">fully active</a>, then return.</p></li><li><p>If <var>target</var>'s <a href="#active-sandboxing-flag-set" id="the-autofocus-attribute:active-sandboxing-flag-set">active sandboxing flag set</a> has the
   <a href="#sandboxed-automatic-features-browsing-context-flag" id="the-autofocus-attribute:sandboxed-automatic-features-browsing-context-flag">sandboxed automatic features browsing context flag</a>, then return.</p></li><li><p>If the <a href="#allow-focus-steps" id="the-autofocus-attribute:allow-focus-steps">allow focus steps</a> given <var>target</var> return false, then
   return.</p></li><li><p>Let <var>topDocument</var> be <var>target</var>'s <a href="#node-navigable" id="the-autofocus-attribute:node-navigable">node navigable</a>'s <a href="#nav-top" id="the-autofocus-attribute:nav-top">top-level traversable</a>'s <a href="#nav-document" id="the-autofocus-attribute:nav-document">active
   document</a>.</p></li><li><p>If <var>topDocument</var>'s <a href="#autofocus-processed-flag" id="the-autofocus-attribute:autofocus-processed-flag">autofocus processed flag</a> is false, then
   <a href="https://infra.spec.whatwg.org/#list-remove" id="the-autofocus-attribute:list-remove" data-x-internal="list-remove">remove</a> the element from <var>topDocument</var>'s
   <a href="#autofocus-candidates" id="the-autofocus-attribute:autofocus-candidates">autofocus candidates</a>, and <a href="https://infra.spec.whatwg.org/#list-append" id="the-autofocus-attribute:list-append" data-x-internal="list-append">append</a> the element to
   <var>topDocument</var>'s <a href="#autofocus-candidates" id="the-autofocus-attribute:autofocus-candidates-2">autofocus candidates</a>.</p></li></ol>
  </div>

  <p class="note">We do not check if an element is a <a href="#focusable-area" id="the-autofocus-attribute:focusable-area">focusable area</a> before storing it
  in the <a href="#autofocus-candidates" id="the-autofocus-attribute:autofocus-candidates-3">autofocus candidates</a> list, because even if it is not a focusable area when it
  is inserted, it could become one by the time <a href="#flush-autofocus-candidates" id="the-autofocus-attribute:flush-autofocus-candidates">flush autofocus candidates</a> sees it.</p>

  <div data-algorithm="">
  <p>To <dfn id="flush-autofocus-candidates">flush autofocus candidates</dfn> for a document <var>topDocument</var>, run these
  steps:</p>

  <ol><li><p>If <var>topDocument</var>'s <a href="#autofocus-processed-flag" id="the-autofocus-attribute:autofocus-processed-flag-2">autofocus processed flag</a> is true, then
   return.</p></li><li><p>Let <var>candidates</var> be <var>topDocument</var>'s <a href="#autofocus-candidates" id="the-autofocus-attribute:autofocus-candidates-4">autofocus
   candidates</a>.</p></li><li><p>If <var>candidates</var> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="the-autofocus-attribute:list-is-empty" data-x-internal="list-is-empty">is empty</a>, then
   return.</p></li><li>
    <p>If <var>topDocument</var>'s <a href="#focused-area-of-the-document" id="the-autofocus-attribute:focused-area-of-the-document">focused area</a>
    is not <var>topDocument</var> itself, or <var>topDocument</var> has non-null
    <a href="#target-element" id="the-autofocus-attribute:target-element">target element</a>, then:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-empty" id="the-autofocus-attribute:list-empty" data-x-internal="list-empty">Empty</a> <var>candidates</var>.</p></li><li><p>Set <var>topDocument</var>'s <a href="#autofocus-processed-flag" id="the-autofocus-attribute:autofocus-processed-flag-3">autofocus processed flag</a> to true.</p></li><li><p>Return.</p></li></ol>
   </li><li>
    <p>While <var>candidates</var> is not <a href="https://infra.spec.whatwg.org/#list-is-empty" id="the-autofocus-attribute:list-is-empty-2" data-x-internal="list-is-empty">empty</a>:</p>

    <ol><li><p>Let <var>element</var> be <var>candidates</var>[0].</p></li><li><p>Let <var>doc</var> be <var>element</var>'s <a id="the-autofocus-attribute:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>doc</var> is not <a href="#fully-active" id="the-autofocus-attribute:fully-active-2">fully active</a>, then
     <a href="https://infra.spec.whatwg.org/#list-remove" id="the-autofocus-attribute:list-remove-2" data-x-internal="list-remove">remove</a> <var>element</var> from <var>candidates</var>, and
     <a id="the-autofocus-attribute:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>doc</var>'s <a href="#node-navigable" id="the-autofocus-attribute:node-navigable-2">node navigable</a>'s <a href="#nav-top" id="the-autofocus-attribute:nav-top-2">top-level
     traversable</a> is not the same as <var>topDocument</var>'s <a href="#node-navigable" id="the-autofocus-attribute:node-navigable-3">node navigable</a>,
     then <a href="https://infra.spec.whatwg.org/#list-remove" id="the-autofocus-attribute:list-remove-3" data-x-internal="list-remove">remove</a> <var>element</var> from <var>candidates</var>,
     and <a id="the-autofocus-attribute:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li>
      <p>If <var>doc</var>'s <a href="#script-blocking-style-sheet-set" id="the-autofocus-attribute:script-blocking-style-sheet-set">script-blocking style sheet set</a> is not <a href="https://infra.spec.whatwg.org/#list-is-empty" id="the-autofocus-attribute:list-is-empty-3" data-x-internal="list-is-empty">empty</a>, then return.</p>

      <p class="note">In this case, <var>element</var> is the currently-best candidate, but
      <var>doc</var> is not ready for autofocusing. We'll try again next time <a href="#flush-autofocus-candidates" id="the-autofocus-attribute:flush-autofocus-candidates-2">flush
      autofocus candidates</a> is called.</p>
     </li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="the-autofocus-attribute:list-remove-4" data-x-internal="list-remove">Remove</a> <var>element</var> from
     <var>candidates</var>.</p></li><li><p>Let <var>inclusiveAncestorDocuments</var> be a <a id="the-autofocus-attribute:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> consisting of the
     <a href="#nav-document" id="the-autofocus-attribute:nav-document-2">active document</a> of <var>doc</var>'s <a href="#inclusive-ancestor-navigables" id="the-autofocus-attribute:inclusive-ancestor-navigables">inclusive
     ancestor navigables</a>.</p></li><li><p>If any <code id="the-autofocus-attribute:document-3"><a href="#document">Document</a></code> in <var>inclusiveAncestorDocuments</var> has non-null
     <a href="#target-element" id="the-autofocus-attribute:target-element-2">target element</a>, then <a id="the-autofocus-attribute:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>target</var> be <var>element</var>.</p></li><li>
      <p>If <var>target</var> is not a <a href="#focusable-area" id="the-autofocus-attribute:focusable-area-2">focusable area</a>, then set <var>target</var> to
      the result of <a href="#get-the-focusable-area" id="the-autofocus-attribute:get-the-focusable-area">getting the focusable area</a> for
      <var>target</var>.</p>

      <p class="note"><a href="#autofocus-candidates" id="the-autofocus-attribute:autofocus-candidates-5">Autofocus candidates</a> can <a href="https://infra.spec.whatwg.org/#list-contain" id="the-autofocus-attribute:list-contains" data-x-internal="list-contains">contain</a> elements which are not <a href="#focusable-area" id="the-autofocus-attribute:focusable-area-3">focusable
      areas</a>. In addition to the special cases handled in the <a href="#get-the-focusable-area" id="the-autofocus-attribute:get-the-focusable-area-2">get the focusable
      area</a> algorithm, this can happen because a non-<a href="#focusable-area" id="the-autofocus-attribute:focusable-area-4">focusable area</a> element with
      an <code id="the-autofocus-attribute:attr-fe-autofocus-6"><a href="#attr-fe-autofocus">autofocus</a></code> attribute was <a href="#insert-an-element-into-a-document" id="the-autofocus-attribute:insert-an-element-into-a-document-2">inserted into a document</a> and it never became focusable, or
      because the element was focusable but its status changed while it was stored in
      <a href="#autofocus-candidates" id="the-autofocus-attribute:autofocus-candidates-6">autofocus candidates</a>.</p>
     </li><li>
      <p>If <var>target</var> is not null, then:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#list-empty" id="the-autofocus-attribute:list-empty-2" data-x-internal="list-empty">Empty</a> <var>candidates</var>.</p></li><li><p>Set <var>topDocument</var>'s <a href="#autofocus-processed-flag" id="the-autofocus-attribute:autofocus-processed-flag-4">autofocus processed flag</a> to true.</p></li><li><p>Run the <a href="#focusing-steps" id="the-autofocus-attribute:focusing-steps">focusing steps</a> for <var>target</var>.</p></li></ol>
     </li></ol>
   </li></ol>
  </div>

  <p class="note">This handles the automatic focusing during document load. The <code id="the-autofocus-attribute:dom-dialog-show"><a href="#dom-dialog-show">show()</a></code> and <code id="the-autofocus-attribute:dom-dialog-showmodal"><a href="#dom-dialog-showmodal">showModal()</a></code>
  methods of <code id="the-autofocus-attribute:the-dialog-element-4"><a href="#the-dialog-element">dialog</a></code> elements also processes the <code id="the-autofocus-attribute:attr-fe-autofocus-7"><a href="#attr-fe-autofocus">autofocus</a></code> attribute.</p>

  <p class="note">Focusing the element does not imply that the user agent has to focus the browser
  window if it has lost focus.</p>

  

  <div class="example">
   <p>In the following snippet, the text control would be focused when
   the document was loaded.</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">maxlength</c-><c- o="">=</c-><c- s="">"256"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"q"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">""</c-> <c- e="">autofocus</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"submit"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Search"</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>The <code id="the-autofocus-attribute:attr-fe-autofocus-8"><a href="#attr-fe-autofocus">autofocus</a></code> attribute applies to all elements, not
   just to form controls. This allows examples such as the following:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">contenteditable</c-> <c- e="">autofocus</c-><c- p="">&gt;</c->Edit <c- p="">&lt;</c-><c- f="">strong</c-><c- p="">&gt;</c->me!<c- p="">&lt;/</c-><c- f="">strong</c-><c- p="">&gt;&lt;</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>
  </div>



  <h3 id="assigning-keyboard-shortcuts"><span class="secno">6.7</span> Assigning keyboard shortcuts<a href="#assigning-keyboard-shortcuts" class="self-link"></a></h3>

  <h4 id="introduction-9"><span class="secno">6.7.1</span> Introduction<a href="#introduction-9" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Each element that can be activated or focused can be assigned a single key combination to
  activate it, using the <code id="introduction-9:the-accesskey-attribute"><a href="#the-accesskey-attribute">accesskey</a></code> attribute.</p>

  <p>The exact shortcut is determined by the user agent, based on information about the user's
  keyboard, what keyboard shortcuts already exist on the platform, and what other shortcuts have
  been specified on the page, using the information provided in the <code id="introduction-9:the-accesskey-attribute-2"><a href="#the-accesskey-attribute">accesskey</a></code> attribute as a guide.</p>

  <p>In order to ensure that a relevant keyboard shortcut is available on a wide variety of input
  devices, the author can provide a number of alternatives in the <code id="introduction-9:the-accesskey-attribute-3"><a href="#the-accesskey-attribute">accesskey</a></code> attribute.</p>

  <p>Each alternative consists of a single character, such as a letter or digit.</p>

  <p>User agents can provide users with a list of the keyboard shortcuts, but authors are encouraged
  to do so also. The <code id="introduction-9:dom-accesskeylabel"><a href="#dom-accesskeylabel">accessKeyLabel</a></code> IDL attribute returns a
  string representing the actual key combination assigned by the user agent.</p>

  <div class="example">

   <p>In this example, an author has provided a button that can be invoked using a shortcut key. To
   support full keyboards, the author has provided "C" as a possible key. To support devices
   equipped only with numeric keypads, the author has provided "1" as another possible key.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">Collect</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"collect()"</c->
       <strong><c- e="">accesskey</c-><c- o="">=</c-><c- s="">"C 1"</c-></strong> <c- e="">id</c-><c- o="">=</c-><c- s="">c</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>To tell the user what the shortcut key is, the author has here opted to explicitly
   add the key combination to the button's label:</p>

   <pre><code class="js"><c- a="">function</c-> addShortcutKeyLabel<c- p="">(</c->button<c- p="">)</c-> <c- p="">{</c->
<strong>  <c- k="">if</c-> <c- p="">(</c->button<c- p="">.</c->accessKeyLabel <c- o="">!=</c-> <c- t="">''</c-><c- p="">)</c->
    button<c- p="">.</c->value <c- o="">+=</c-> <c- t="">' ('</c-> <c- o="">+</c-> button<c- p="">.</c->accessKeyLabel <c- o="">+</c-> <c- t="">')'</c-><c- p="">;</c-></strong>
<c- p="">}</c->
addShortcutKeyLabel<c- p="">(</c->document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'c'</c-><c- p="">));</c-></code></pre>

   <p>Browsers on different platforms will show different labels, even for the same key combination,
   based on the convention prevalent on that platform. For example, if the key combination is the
   Control key, the Shift key, and the letter C, a Windows browser might display
   "<samp>Ctrl+Shift+C</samp>", whereas a Mac browser might display "<samp>^⇧C</samp>", while
   an Emacs browser might just display "<samp>C-C</samp>". Similarly, if the key combination is the
   Alt key and the Escape key, Windows might use "<samp>Alt+Esc</samp>", Mac might use
   "<samp>⌥⎋</samp>", and an Emacs browser might use "<samp>M-ESC</samp>" or
   "<samp>ESC ESC</samp>".</p>

   <p>In general, therefore, it is unwise to attempt to parse the value returned from the <code id="introduction-9:dom-accesskeylabel-2"><a href="#dom-accesskeylabel">accessKeyLabel</a></code> IDL attribute.</p>

  </div>


  <h4 id="the-accesskey-attribute"><span class="secno">6.7.2</span> The <dfn data-dfn-for="html-global" data-dfn-type="element-attr"><code>accesskey</code></dfn>
  attribute<a href="#the-accesskey-attribute" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey" title="The accesskey global attribute provides a hint for generating a keyboard shortcut for the current element. The attribute value must consist of a single printable character (which includes accented and other characters that can be generated by the keyboard).">Global_attributes/accesskey</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>All <a href="#html-elements" id="the-accesskey-attribute:html-elements">HTML elements</a> may have the <code id="the-accesskey-attribute:the-accesskey-attribute"><a href="#the-accesskey-attribute">accesskey</a></code>
  content attribute set. The <code id="the-accesskey-attribute:the-accesskey-attribute-2"><a href="#the-accesskey-attribute">accesskey</a></code> attribute's value is used
  by the user agent as a guide for creating a keyboard shortcut that activates or focuses the
  element.</p>

  <p>If specified, the value must be an <a href="#ordered-set-of-unique-space-separated-tokens" id="the-accesskey-attribute:ordered-set-of-unique-space-separated-tokens">ordered set of unique space-separated tokens</a>
  none of which are <a id="the-accesskey-attribute:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> another token and each of which must be exactly one
  code point in length.</p>

  <div class="example">

   <p>In the following example, a variety of links are given with access keys so that keyboard users
   familiar with the site can more quickly navigate to the relevant pages:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">nav</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Consortium Activities"</c-> <c- e="">accesskey</c-><c- o="">=</c-><c- s="">"A"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/Consortium/activities"</c-><c- p="">&gt;</c->Activities<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> |
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Technical Reports and Recommendations"</c-> <c- e="">accesskey</c-><c- o="">=</c-><c- s="">"T"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/TR/"</c-><c- p="">&gt;</c->Technical Reports<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> |
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Alphabetical Site Index"</c-> <c- e="">accesskey</c-><c- o="">=</c-><c- s="">"S"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/Consortium/siteindex"</c-><c- p="">&gt;</c->Site Index<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> |
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"About This Site"</c-> <c- e="">accesskey</c-><c- o="">=</c-><c- s="">"B"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/Consortium/"</c-><c- p="">&gt;</c->About Consortium<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> |
  <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">title</c-><c- o="">=</c-><c- s="">"Contact Consortium"</c-> <c- e="">accesskey</c-><c- o="">=</c-><c- s="">"C"</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"/Consortium/contact"</c-><c- p="">&gt;</c->Contact<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">nav</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following example, the search field is given two possible access keys, "s" and "0" (in
   that order). A user agent on a device with a full keyboard might pick <kbd><kbd>Ctrl</kbd> +
   <kbd>Alt</kbd> + <kbd>S</kbd></kbd> as the shortcut key, while a user agent on a small device
   with just a numeric keypad might pick just the plain unadorned key <kbd><kbd>0</kbd></kbd>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">action</c-><c- o="">=</c-><c- s="">"/search"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Search: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"search"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"q"</c-> <c- e="">accesskey</c-><c- o="">=</c-><c- s="">"s 0"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"submit"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <div class="example">

   <p>In the following example, a button has possible access keys described. A script then tries to
   update the button's label to advertise the key combination the user agent selected.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">submit</c-> <c- e="">accesskey</c-><c- o="">=</c-><c- s="">"N @ 1"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Compose"</c-><c- p="">&gt;</c->
...
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">function</c-> labelButton<c- p="">(</c->button<c- p="">)</c-> <c- p="">{</c->
   <c- k="">if</c-> <c- p="">(</c->button<c- p="">.</c->accessKeyLabel<c- p="">)</c->
     button<c- p="">.</c->value <c- o="">+=</c-> <c- t="">' ('</c-> <c- o="">+</c-> button<c- p="">.</c->accessKeyLabel <c- o="">+</c-> <c- t="">')'</c-><c- p="">;</c->
 <c- p="">}</c->
 <c- a="">var</c-> inputs <c- o="">=</c-> document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'input'</c-><c- p="">);</c->
 <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> i <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> i <c- o="">&lt;</c-> inputs<c- p="">.</c->length<c- p="">;</c-> i <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
   <c- k="">if</c-> <c- p="">(</c->inputs<c- p="">[</c->i<c- p="">].</c->type <c- o="">==</c-> <c- u="">"submit"</c-><c- p="">)</c->
     labelButton<c- p="">(</c->inputs<c- p="">[</c->i<c- p="">]);</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>On one user agent, the button's label might become "<samp>Compose (⌘N)</samp>". On
   another, it might become "<samp>Compose (Alt+⇧+1)</samp>". If the user agent doesn't
   assign a key, it will be just "<samp>Compose</samp>". The exact string depends on what the
   <a href="#assigned-access-key" id="the-accesskey-attribute:assigned-access-key">assigned access key</a> is, and on how the user agent represents that key
   combination.</p>

  </div>


  

  <h4 id="keyboard-shortcuts-processing-model"><span class="secno">6.7.3</span> <span id="processing-model-6"></span>Processing
  model<a href="#keyboard-shortcuts-processing-model" class="self-link"></a></h4>

  <p>An element's <dfn id="assigned-access-key">assigned access key</dfn> is a key combination derived from the element's
  <code id="keyboard-shortcuts-processing-model:the-accesskey-attribute"><a href="#the-accesskey-attribute">accesskey</a></code> content attribute. Initially, an element must not
  have an <a href="#assigned-access-key" id="keyboard-shortcuts-processing-model:assigned-access-key">assigned access key</a>.</p>

  <div data-algorithm="">
  <p>Whenever an element's <code id="keyboard-shortcuts-processing-model:the-accesskey-attribute-2"><a href="#the-accesskey-attribute">accesskey</a></code> attribute is set, changed,
  or removed, the user agent must update the element's <a href="#assigned-access-key" id="keyboard-shortcuts-processing-model:assigned-access-key-2">assigned access key</a> by running
  the following steps:</p>

  <ol><li><p>If the element has no <code id="keyboard-shortcuts-processing-model:the-accesskey-attribute-3"><a href="#the-accesskey-attribute">accesskey</a></code> attribute, then skip
   to the <i>fallback</i> step below.</p></li><li><p>Otherwise, <a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="keyboard-shortcuts-processing-model:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">split the attribute's value
   on ASCII whitespace</a>, and let <var>keys</var> be the resulting tokens.</p></li><li>
    <p>For each value in <var>keys</var> in turn, in the order the tokens appeared in the
    attribute's value, run the following substeps:</p>

    <ol><li><p>If the value is not a string exactly one code point in length, then skip the remainder
     of these steps for this value.</p></li><li><p>If the value does not correspond to a key on the system's keyboard, then skip the
     remainder of these steps for this value.</p></li><li><p>
     <a id="keyboard-shortcuts-processing-model:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
     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 <a href="#assigned-access-key" id="keyboard-shortcuts-processing-model:assigned-access-key-3">assigned access key</a> and
     return.</p></li></ol>
   </li><li><p><i>Fallback</i>: Optionally, the user agent may assign a key combination of its choosing
   as the element's <a href="#assigned-access-key" id="keyboard-shortcuts-processing-model:assigned-access-key-4">assigned access key</a> and then return.</p></li><li><p>If this step is reached, the element has no <a href="#assigned-access-key" id="keyboard-shortcuts-processing-model:assigned-access-key-5">assigned access key</a>.</p></li></ol>
  </div>

  <p>Once a user agent has selected and assigned an access key for an element, the user agent should
  not change the element's <a href="#assigned-access-key" id="keyboard-shortcuts-processing-model:assigned-access-key-6">assigned access key</a> unless the <code id="keyboard-shortcuts-processing-model:the-accesskey-attribute-4"><a href="#the-accesskey-attribute">accesskey</a></code> content attribute is changed or the element is moved to
  another <code id="keyboard-shortcuts-processing-model:document"><a href="#document">Document</a></code>.</p>

  <div data-algorithm="">
  <p>When the user presses the key combination corresponding to the <a href="#assigned-access-key" id="keyboard-shortcuts-processing-model:assigned-access-key-7">assigned access key</a>
  for an element, if the element <a href="#concept-command" id="keyboard-shortcuts-processing-model:concept-command">defines a command</a>, the
  command's <a href="#command-facet-hiddenstate" id="keyboard-shortcuts-processing-model:command-facet-hiddenstate">Hidden State</a> facet is false (visible),
  the command's <a href="#command-facet-disabledstate" id="keyboard-shortcuts-processing-model:command-facet-disabledstate">Disabled State</a> facet is also false
  (enabled), the element is <a id="keyboard-shortcuts-processing-model:in-a-document" href="https://dom.spec.whatwg.org/#in-a-document" data-x-internal="in-a-document">in a document</a> that has a non-null <a href="#concept-document-bc" id="keyboard-shortcuts-processing-model:concept-document-bc">browsing context</a>, and neither the element nor any of its
  ancestors has a <code id="keyboard-shortcuts-processing-model:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute specified, then the user agent
  must trigger the <a href="#command-facet-action" id="keyboard-shortcuts-processing-model:command-facet-action">Action</a> of the command.</p>
  </div>

  <p class="note">User agents <a href="#expose-commands-in-ui">might expose</a> elements that have
  an <code id="keyboard-shortcuts-processing-model:the-accesskey-attribute-5"><a href="#the-accesskey-attribute">accesskey</a></code> attribute in other ways as well, e.g. in a menu
  displayed in response to a specific key combination.</p> 

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/accessKeyLabel" title="The HTMLElement.accessKeyLabel read-only property returns a string containing the element's browser-assigned access key (if any); otherwise it returns an empty string.">HTMLElement/accessKeyLabel</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>8+</span></span><span class="safari yes"><span>Safari</span><span>14+</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-accesskeylabel" data-dfn-type="attribute"><code>accessKeyLabel</code></dfn> IDL attribute must return a string that
  represents the element's <a href="#assigned-access-key" id="keyboard-shortcuts-processing-model:assigned-access-key-8">assigned access key</a>, if any. If the element does not have
  one, then the IDL attribute must return the empty string.</p>
  </div>

  



  <h3 id="editing-2"><span class="secno">6.8</span> Editing<a href="#editing-2" class="self-link"></a></h3>

  <h4 id="contenteditable"><span class="secno">6.8.1</span> Making document regions editable: The <code id="contenteditable:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code> content attribute<a href="#contenteditable" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/contentEditable" title="The contentEditable property of the HTMLElement interface specifies whether or not the element is editable.">HTMLElement/contentEditable</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="elementcontenteditable" data-dfn-type="interface"><c- g="">ElementContentEditable</c-></dfn> {
  [<a href="#cereactions" id="contenteditable:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-contenteditable" id="contenteditable:dom-contenteditable"><c- g="">contentEditable</c-></a>;
  [<a href="#cereactions" id="contenteditable:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-enterkeyhint" id="contenteditable:dom-enterkeyhint"><c- g="">enterKeyHint</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-iscontenteditable" id="contenteditable:dom-iscontenteditable"><c- g="">isContentEditable</c-></a>;
  [<a href="#cereactions" id="contenteditable:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-inputmode" id="contenteditable:dom-inputmode"><c- g="">inputMode</c-></a>;
};</code></pre>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable" title="The contenteditable global attribute is an enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing.">Global_attributes/contenteditable</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="html-global" id="attr-contenteditable" data-dfn-type="element-attr"><code>contenteditable</code></dfn> content attribute is an
  <a href="#enumerated-attribute" id="contenteditable:enumerated-attribute">enumerated attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/contenteditable" id="attr-contenteditable-true" data-dfn-type="attr-value"><code>true</code></dfn>
     </td><td><dfn id="attr-contenteditable-true-state">True</dfn>
     </td><td>The element is editable.
    </td></tr><tr><td><dfn data-dfn-for="html-global/contenteditable" id="attr-contenteditable-false" data-dfn-type="attr-value"><code>false</code></dfn>
     </td><td><dfn id="attr-contenteditable-false-state">False</dfn>
     </td><td>The element is not editable.
    </td></tr><tr><td><dfn data-dfn-for="html-global/contenteditable" id="attr-contenteditable-plaintextonly" data-dfn-type="attr-value"><code>plaintext-only</code></dfn>
     </td><td><dfn id="attr-contenteditable-plaintextonly-state">Plaintext-Only</dfn>
     </td><td>Only the element's raw text content is editable; rich formatting is disabled.
  </td></tr></tbody></table>


  <div data-algorithm="">
  <p>The attribute's <i id="contenteditable:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="contenteditable:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <dfn id="attr-contenteditable-inherit-state">Inherit</dfn> state. The inherit state indicates that
  the element is editable (or not) based on the parent element's state. The attribute's <i id="contenteditable:empty-value-default"><a href="#empty-value-default">empty value default</a></i> is the <a href="#attr-contenteditable-true-state" id="contenteditable:attr-contenteditable-true-state">True</a> state.</p>
  </div>

  <div class="example">
   <p>For example, consider a page that has a <code id="contenteditable:the-form-element"><a href="#the-form-element">form</a></code> and a <code id="contenteditable:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> to
   publish a new article, where the user is expected to write the article using HTML:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">POST</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->New article<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">article</c-><c- p="">&gt;</c-><c- ni="">&amp;lt;</c->p&gt;Hello world.<c- ni="">&amp;lt;</c->/p&gt;<c- p="">&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Publish<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

   <p>When scripting is enabled, the <code id="contenteditable:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> element could be replaced with a rich
   text control instead, using the <code id="contenteditable:attr-contenteditable-2"><a href="#attr-contenteditable">contenteditable</a></code>
   attribute:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">method</c-><c- o="">=</c-><c- s="">POST</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->New article<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">textarea</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">article</c-><c- p="">&gt;</c-><c- ni="">&amp;lt;</c->p&gt;Hello world.<c- ni="">&amp;lt;</c->/p&gt;<c- p="">&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">div</c-> <c- e="">style</c-><c- o="">=</c-><c- s="">"white-space: pre-wrap"</c-> <c- e="">hidden</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Hello world.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">let</c-> textarea <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- u="">"textarea"</c-><c- p="">);</c->
   <c- a="">let</c-> div <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- u="">"div"</c-><c- p="">);</c->
   textarea<c- p="">.</c->hidden <c- o="">=</c-> <c- kc="">true</c-><c- p="">;</c->
   div<c- p="">.</c->hidden <c- o="">=</c-> <c- kc="">false</c-><c- p="">;</c->
   div<c- p="">.</c->contentEditable <c- o="">=</c-> <c- u="">"true"</c-><c- p="">;</c->
   div<c- p="">.</c->oninput <c- o="">=</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
     textarea<c- p="">.</c->value <c- o="">=</c-> div<c- p="">.</c->innerHTML<c- p="">;</c->
   <c- p="">};</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Publish<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>

   <p>Features to enable, e.g., inserting links, can be implemented using the <code id="contenteditable:execCommand"><a data-x-internal="execCommand" href="https://w3c.github.io/editing/docs/execCommand/#execcommand%28%29">document.execCommand()</a></code> API, or using
   <code id="contenteditable:selection"><a data-x-internal="selection" href="https://w3c.github.io/selection-api/#selection-interface">Selection</a></code> APIs and other DOM APIs. <a href="#refsEXECCOMMAND">[EXECCOMMAND]</a> <a href="#refsSELECTION">[SELECTION]</a>
   <a href="#refsDOM">[DOM]</a></p>
  </div>

  <div class="example">
   <p>The <code id="contenteditable:attr-contenteditable-3"><a href="#attr-contenteditable">contenteditable</a></code> attribute can also be used to
   great effect:</p>

   <pre><code class="html"><c- cp="">&lt;!doctype html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">en</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Live CSS editing!<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">style</c-> <c- e="">style</c-><c- o="">=</c-><c- s="">white-space:pre</c-> <c- e="">contenteditable</c-><c- p="">&gt;</c->
<c- f="">html</c-> <c- p="">{</c-> <c- k="">margin</c-><c- p="">:</c-><c- mf="">.2</c-><c- b="">em</c-><c- p="">;</c-> <c- k="">font-size</c-><c- p="">:</c-><c- mi="">2</c-><c- b="">em</c-><c- p="">;</c-> <c- k="">color</c-><c- p="">:</c-><c- kc="">lime</c-><c- p="">;</c-> <c- k="">background</c-><c- p="">:</c-><c- kc="">purple</c-> <c- p="">}</c->
<c- f="">head</c-><c- o="">,</c-> <c- f="">title</c-><c- o="">,</c-> <c- f="">style</c-> <c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-><c- kc="">block</c-> <c- p="">}</c->
<c- f="">body</c-> <c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-><c- kc="">none</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-contenteditable" id="dom-contenteditable-dev">contentEditable</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns "<code>true</code>", "<code>plaintext-only</code>", "<code>false</code>", or "<code>inherit</code>",
    based on the state of the <code id="contenteditable:attr-contenteditable-4"><a href="#attr-contenteditable">contenteditable</a></code>
    attribute.</p>

    <p>Can be set, to change that state.</p>

    <p>Throws a <a id="contenteditable:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="contenteditable:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the new value
    isn't one of those strings.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-iscontenteditable" id="dom-iscontenteditable-dev">isContentEditable</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/isContentEditable" title="The HTMLElement.isContentEditable read-only property returns a boolean value that is true if the contents of the element are editable; otherwise it returns false.">HTMLElement/isContentEditable</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns true if the element is editable; otherwise, returns false.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementContentEditable" id="dom-contenteditable" data-dfn-type="attribute"><code>contentEditable</code></dfn> IDL attribute, on getting, must return
  the string "<code>true</code>" if the content attribute is set to the <a href="#attr-contenteditable-true-state" id="contenteditable:attr-contenteditable-true-state-2">True</a> state, "<code>plaintext-only</code>" if the content attribute is set to the <a href="#attr-contenteditable-plaintextonly-state" id="contenteditable:attr-contenteditable-plaintextonly-state">Plaintext-Only</a> state, "<code>false</code>" if the content attribute is set to the <a href="#attr-contenteditable-false-state" id="contenteditable:attr-contenteditable-false-state">False</a> state, and "<code>inherit</code>" otherwise. On setting, if the new
  value is an <a id="contenteditable:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>inherit</code>", then the content attribute must be removed, if the new value is an
  <a id="contenteditable:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>true</code>", then the
  content attribute must be set to the string "<code>true</code>", if the new value is an
  <a id="contenteditable:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>plaintext-only</code>",
  then the content attribute must be set to the string "<code>plaintext-only</code>", if
  the new value is an <a id="contenteditable:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>false</code>", then the content attribute must be set to the string "<code>false</code>", and otherwise the attribute setter must throw a
  <a id="contenteditable:syntaxerror-2" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="contenteditable:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementContentEditable" id="dom-iscontenteditable" data-dfn-type="attribute"><code>isContentEditable</code></dfn> IDL attribute, on getting, must
  return true if the element is either an <a href="#editing-host" id="contenteditable:editing-host">editing host</a> or <a id="contenteditable:editable" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a>, and
  false otherwise.</p>
  </div>

  



  <h4 id="making-entire-documents-editable:-the-designmode-idl-attribute"><span class="secno">6.8.2</span> Making entire documents
  editable: the <code id="making-entire-documents-editable:-the-designmode-idl-attribute:designMode"><a href="#designMode">designMode</a></code> getter and setter<a href="#making-entire-documents-editable:-the-designmode-idl-attribute" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#designMode" id="dom-document-designmode-dev">designMode</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/designMode" title="document.designMode controls whether the entire document is editable. Valid values are &quot;on&quot; and &quot;off&quot;. According to the specification, this property is meant to default to &quot;off&quot;. Firefox follows this standard. The earlier versions of Chrome and IE default to &quot;inherit&quot;. Starting in Chrome 43, the default is &quot;off&quot; and &quot;inherit&quot; is no longer supported. In IE6-10, the value is capitalized.">Document/designMode</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns "<code>on</code>" if the document is editable, and "<code>off</code>" if it isn't.</p>

    <p>Can be set, to change the document's current state. This focuses the document and resets the
    selection in that document.</p>
   </dd></dl>

  

  <p><code id="making-entire-documents-editable:-the-designmode-idl-attribute:document"><a href="#document">Document</a></code> objects have an associated <dfn id="design-mode-enabled">design mode enabled</dfn>, which is a
  boolean. It is initially false.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="designMode" data-dfn-type="attribute"><code>designMode</code></dfn> getter steps are to return "<code>on</code>" if <a id="making-entire-documents-editable:-the-designmode-idl-attribute:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#design-mode-enabled" id="making-entire-documents-editable:-the-designmode-idl-attribute:design-mode-enabled">design mode enabled</a> is true; otherwise
  "<code>off</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="making-entire-documents-editable:-the-designmode-idl-attribute:designMode-2"><a href="#designMode">designMode</a></code> setter steps are:</p>

  <ol><li><p>Let <var>value</var> be the given value, <a id="making-entire-documents-editable:-the-designmode-idl-attribute:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
   lowercase</a>.</p></li><li>
    <p>If <var>value</var> is "<code>on</code>" and <a id="making-entire-documents-editable:-the-designmode-idl-attribute:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#design-mode-enabled" id="making-entire-documents-editable:-the-designmode-idl-attribute:design-mode-enabled-2">design mode
    enabled</a> is false, then:</p>

    <ol><li><p>Set <a id="making-entire-documents-editable:-the-designmode-idl-attribute:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#design-mode-enabled" id="making-entire-documents-editable:-the-designmode-idl-attribute:design-mode-enabled-3">design mode enabled</a> to true.</p></li><li><p>Reset <a id="making-entire-documents-editable:-the-designmode-idl-attribute:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="making-entire-documents-editable:-the-designmode-idl-attribute:active-range" href="https://w3c.github.io/editing/docs/execCommand/#active-range" data-x-internal="active-range">active range</a>'s start and end boundary points to
     be at the start of <a id="making-entire-documents-editable:-the-designmode-idl-attribute:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>Run the <a href="#focusing-steps" id="making-entire-documents-editable:-the-designmode-idl-attribute:focusing-steps">focusing steps</a> for <a id="making-entire-documents-editable:-the-designmode-idl-attribute:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="making-entire-documents-editable:-the-designmode-idl-attribute:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document
     element</a>, if non-null.</p></li></ol>
   </li><li><p>If <var>value</var> is "<code>off</code>", then set <a id="making-entire-documents-editable:-the-designmode-idl-attribute:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a href="#design-mode-enabled" id="making-entire-documents-editable:-the-designmode-idl-attribute:design-mode-enabled-4">design mode enabled</a> to false.</p></li></ol>
  </div>

  


  <h4 id="best-practices-for-in-page-editors"><span class="secno">6.8.3</span> Best practices for in-page editors<a href="#best-practices-for-in-page-editors" class="self-link"></a></h4>

  <p>Authors are encouraged to set the <a id="best-practices-for-in-page-editors:'white-space'" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> property on <a href="#editing-host" id="best-practices-for-in-page-editors:editing-host">editing hosts</a> and on markup that was originally created through these editing
  mechanisms to the value 'pre-wrap'. Default HTML whitespace handling is not well suited to WYSIWYG
  editing, and line wrapping will not work correctly in some corner cases if
  <a id="best-practices-for-in-page-editors:'white-space'-2" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> is left at its default value.</p>

  <div class="example">

   <p>As an example of problems that occur if the default 'normal' value is used instead, consider
   the case of the user typing "<kbd>yellow␣␣ball</kbd>", with two spaces (here
   represented by "␣") between the words. With the editing rules in place for the default
   value of <a id="best-practices-for-in-page-editors:'white-space'-3" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> ('normal'), the resulting markup will either consist of
   "<samp>yellow&amp;nbsp;&nbsp;ball</samp>" or "<samp>yellow&nbsp;&amp;nbsp;ball</samp>"; i.e.,
   there will be a non-breaking space between the two words in addition to the regular space. This
   is necessary because the 'normal' value for <a id="best-practices-for-in-page-editors:'white-space'-4" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> requires adjacent regular
   spaces to be collapsed together.</p>

   <p>In the former case, "<samp>yellow⍽</samp>" might wrap to the next line ("⍽"
   being used here to represent a non-breaking space) even though "<samp>yellow</samp>" alone might
   fit at the end of the line; in the latter case, "<samp>⍽ball</samp>", if wrapped to the
   start of the line, would have visible indentation from the non-breaking space.</p>

   <p>When <a id="best-practices-for-in-page-editors:'white-space'-5" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> is set to 'pre-wrap', however, the editing rules will instead
   simply put two regular spaces between the words, and should the two words be split at the end of
   a line, the spaces would be neatly removed from the rendering.</p>

  </div>

  

  <h4 id="editing-apis"><span class="secno">6.8.4</span> Editing APIs<a href="#editing-apis" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>An <dfn id="editing-host" data-export="">editing host</dfn> is either an <a href="#html-elements" id="editing-apis:html-elements">HTML element</a>
  with its <code id="editing-apis:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code> attribute in the <i>true</i>
  state or <i>plaintext-only</i> state, or a <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="editing-apis:concept-tree-child" data-x-internal="concept-tree-child">child</a> <a href="#html-elements" id="editing-apis:html-elements-2">HTML element</a> of a <code id="editing-apis:document"><a href="#document">Document</a></code> whose <a href="#design-mode-enabled" id="editing-apis:design-mode-enabled">design mode
  enabled</a> is true.</p>
  </div>

  <p>The definition of the terms <dfn id="active-range"><a href="https://w3c.github.io/editing/docs/execCommand/#active-range">active range</a></dfn>, <dfn id="editing-host-of"><a href="https://w3c.github.io/editing/docs/execCommand/#editing-host-of">editing host
  of</a></dfn>, and <dfn id="editable"><a href="https://w3c.github.io/editing/docs/execCommand/#editable">editable</a></dfn>, the user
  interface requirements of elements that are <a href="#editing-host" id="editing-apis:editing-host">editing hosts</a> or
  <a id="editing-apis:editable" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a>, the

  <dfn id="execCommand"><a href="https://w3c.github.io/editing/docs/execCommand/#execcommand%28%29"><code>execCommand()</code></a></dfn>,
  <dfn id="dom-document-querycommandenabled"><a href="https://w3c.github.io/editing/docs/execCommand/#querycommandenabled%28%29"><code>queryCommandEnabled()</code></a></dfn>,
  <dfn id="dom-document-querycommandindeterm"><a href="https://w3c.github.io/editing/docs/execCommand/#querycommandindeterm%28%29"><code>queryCommandIndeterm()</code></a></dfn>,
  <dfn id="dom-document-querycommandstate"><a href="https://w3c.github.io/editing/docs/execCommand/#querycommandstate%28%29"><code>queryCommandState()</code></a></dfn>,
  <dfn id="dom-document-querycommandsupported"><a href="https://w3c.github.io/editing/docs/execCommand/#querycommandsupported%28%29"><code>queryCommandSupported()</code></a></dfn>, and
  <dfn id="dom-document-querycommandvalue"><a href="https://w3c.github.io/editing/docs/execCommand/#querycommandvalue%28%29"><code>queryCommandValue()</code></a></dfn>

  methods, text selections, and the <dfn id="delete-the-selection"><a href="https://w3c.github.io/editing/docs/execCommand/#delete-the-selection">delete the
  selection</a></dfn> algorithm are defined in <cite>execCommand</cite>. <a href="#refsEXECCOMMAND">[EXECCOMMAND]</a></p>

  

  <h4 id="spelling-and-grammar-checking"><span class="secno">6.8.5</span> Spelling and grammar checking<a href="#spelling-and-grammar-checking" class="self-link"></a></h4>

  

  <p>User agents can support the checking of spelling and grammar of editable text, either in form
  controls (such as the value of <code id="spelling-and-grammar-checking:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements), or in elements in an <a href="#editing-host" id="spelling-and-grammar-checking:editing-host">editing
  host</a> (e.g. using <code id="spelling-and-grammar-checking:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code>).</p>

  <p>For each element, user agents must establish a <dfn id="concept-spellcheck-default">default
  behavior</dfn>, either through defaults or through preferences expressed by the user. There are
  three possible default behaviors for each element:</p>

  <dl><dt><dfn id="concept-spellcheck-default-true">true-by-default</dfn>

   </dt><dd>The element will be checked for spelling and grammar if its contents are editable and
   spellchecking is not explicitly disabled through the <code id="spelling-and-grammar-checking:attr-spellcheck"><a href="#attr-spellcheck">spellcheck</a></code> attribute.

   </dd><dt><dfn id="concept-spellcheck-default-false">false-by-default</dfn>

   </dt><dd>The element will never be checked for spelling and grammar unless spellchecking is
   explicitly enabled through the <code id="spelling-and-grammar-checking:attr-spellcheck-2"><a href="#attr-spellcheck">spellcheck</a></code> attribute.

   </dd><dt><dfn id="concept-spellcheck-default-inherit">inherit-by-default</dfn>

   </dt><dd>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.
  </dd></dl>

  <hr>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck" title="The spellcheck global attribute is an enumerated attribute that defines whether the element may be checked for spelling errors.">Global_attributes/spellcheck</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>Yes</span></span><span class="safari yes"><span>Safari</span><span>Yes</span></span><span class="chrome yes"><span>Chrome</span><span>9+</span></span><hr><span class="opera yes"><span>Opera</span><span>Yes</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>57+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>9.3+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>47+</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>37+</span></span></div></div></div><p>The <dfn data-dfn-for="html-global" id="attr-spellcheck" data-dfn-type="element-attr"><code>spellcheck</code></dfn>
  attribute is an <a href="#enumerated-attribute" id="spelling-and-grammar-checking:enumerated-attribute">enumerated attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/spellcheck" id="attr-spellcheck-true" data-dfn-type="attr-value"><code>true</code></dfn>
     </td><td><dfn id="attr-spellcheck-true-state">True</dfn>
     </td><td>Spelling and grammar will be checked.
    </td></tr><tr><td><dfn data-dfn-for="html-global/spellcheck" id="attr-spellcheck-false" data-dfn-type="attr-value"><code>false</code></dfn>
     </td><td><dfn id="attr-spellcheck-false-state">False</dfn>
     </td><td>Spelling and grammar will not be checked.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="spelling-and-grammar-checking:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="spelling-and-grammar-checking:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <dfn id="attr-spellcheck-default-state">Default</dfn> state. The default state indicates that the
  element is to act according to a default behavior, possibly based on the parent element's own
  <code id="spelling-and-grammar-checking:attr-spellcheck-3"><a href="#attr-spellcheck">spellcheck</a></code> state, as defined below. The attribute's <i id="spelling-and-grammar-checking:empty-value-default"><a href="#empty-value-default">empty value default</a></i> is the <a href="#attr-spellcheck-true-state" id="spelling-and-grammar-checking:attr-spellcheck-true-state">True</a> state.</p>
  </div>

  

  <hr>

  

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-spellcheck" id="dom-spellcheck-dev">spellcheck</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns true if the element is to have its spelling and grammar checked; otherwise, returns
    false.</p>

    <p>Can be set, to override the default and set the <code id="spelling-and-grammar-checking:attr-spellcheck-4"><a href="#attr-spellcheck">spellcheck</a></code> content attribute.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-spellcheck" data-dfn-type="attribute"><code>spellcheck</code></dfn> IDL
  attribute, on getting, must return true if the element's <code id="spelling-and-grammar-checking:attr-spellcheck-5"><a href="#attr-spellcheck">spellcheck</a></code> content attribute is in the <a href="#attr-spellcheck-true-state" id="spelling-and-grammar-checking:attr-spellcheck-true-state-2">True</a> state, or if the element's <code id="spelling-and-grammar-checking:attr-spellcheck-6"><a href="#attr-spellcheck">spellcheck</a></code> content attribute is in the <a href="#attr-spellcheck-default-state" id="spelling-and-grammar-checking:attr-spellcheck-default-state">Default</a> state and the element's <a href="#concept-spellcheck-default" id="spelling-and-grammar-checking:concept-spellcheck-default">default behavior</a> is <a href="#concept-spellcheck-default-true" id="spelling-and-grammar-checking:concept-spellcheck-default-true">true-by-default</a>, or if the element's <code id="spelling-and-grammar-checking:attr-spellcheck-7"><a href="#attr-spellcheck">spellcheck</a></code> content attribute is in the <a href="#attr-spellcheck-default-state" id="spelling-and-grammar-checking:attr-spellcheck-default-state-2">Default</a> state and the element's <a href="#concept-spellcheck-default" id="spelling-and-grammar-checking:concept-spellcheck-default-2">default behavior</a> is <a href="#concept-spellcheck-default-inherit" id="spelling-and-grammar-checking:concept-spellcheck-default-inherit">inherit-by-default</a> and the element's parent
  element's <code id="spelling-and-grammar-checking:dom-spellcheck"><a href="#dom-spellcheck">spellcheck</a></code> IDL attribute would return true;
  otherwise, if none of those conditions applies, then the attribute must instead return false.</p>
  </div>

  <p class="note">The <code id="spelling-and-grammar-checking:dom-spellcheck-2"><a href="#dom-spellcheck">spellcheck</a></code> IDL attribute is not affected
  by user preferences that override the <code id="spelling-and-grammar-checking:attr-spellcheck-8"><a href="#attr-spellcheck">spellcheck</a></code> content
  attribute, and therefore might not reflect the actual spellchecking state.</p>

  <div data-algorithm="">
  <p>On setting, if the new value is true, then the element's <code id="spelling-and-grammar-checking:attr-spellcheck-9"><a href="#attr-spellcheck">spellcheck</a></code> content attribute must be set to
  "<code>true</code>", otherwise it must be set to "<code>false</code>".
  </p></div>

  <hr>

  <p>User agents should only consider the following pieces of text as checkable for the purposes of
  this feature:</p>

  <ul><li>The <a href="#concept-fe-value" id="spelling-and-grammar-checking:concept-fe-value">value</a> of <code id="spelling-and-grammar-checking:the-input-element"><a href="#the-input-element">input</a></code> elements whose <code id="spelling-and-grammar-checking:attr-input-type"><a href="#attr-input-type">type</a></code> attributes are in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="spelling-and-grammar-checking:text-(type=text)-state-and-search-state-(type=search)">Text</a>, <a href="#text-(type=text)-state-and-search-state-(type=search)" id="spelling-and-grammar-checking:text-(type=text)-state-and-search-state-(type=search)-2">Search</a>,
   <a href="#url-state-(type=url)" id="spelling-and-grammar-checking:url-state-(type=url)">URL</a>, or <a href="#email-state-(type=email)" id="spelling-and-grammar-checking:email-state-(type=email)">Email</a> states and that are <i id="spelling-and-grammar-checking:concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i> (i.e. that do not have the <code id="spelling-and-grammar-checking:attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code> attribute specified and that are not <a href="#concept-fe-disabled" id="spelling-and-grammar-checking:concept-fe-disabled">disabled</a>).</li><li>The <a href="#concept-fe-value" id="spelling-and-grammar-checking:concept-fe-value-2">value</a> of <code id="spelling-and-grammar-checking:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> elements that do not
   have a <code id="spelling-and-grammar-checking:attr-textarea-readonly"><a href="#attr-textarea-readonly">readonly</a></code> attribute and that are not <a href="#concept-fe-disabled" id="spelling-and-grammar-checking:concept-fe-disabled-2">disabled</a>.</li><li>Text in <code id="spelling-and-grammar-checking:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes that are children of <a href="#editing-host" id="spelling-and-grammar-checking:editing-host-2">editing
   hosts</a> or <a id="spelling-and-grammar-checking:editable" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a> elements.</li><li>Text in attributes of <a id="spelling-and-grammar-checking:editable-2" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a> elements.</li></ul>

  <p>For text that is part of a <code id="spelling-and-grammar-checking:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> 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 <code id="spelling-and-grammar-checking:the-input-element-2"><a href="#the-input-element">input</a></code> and <code id="spelling-and-grammar-checking:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code> elements, it is the element itself.</p>

  <div data-algorithm="">
  <p>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:</p>

  <ol><li>If the user has disabled the checking for this text, then the checking is disabled.</li><li>Otherwise, if the user has forced the checking for this text to always be enabled, then the
   checking is enabled.</li><li>Otherwise, if the element with which the text is associated has a <code id="spelling-and-grammar-checking:attr-spellcheck-10"><a href="#attr-spellcheck">spellcheck</a></code> content attribute, then: if that attribute is in the
   <a href="#attr-spellcheck-true-state" id="spelling-and-grammar-checking:attr-spellcheck-true-state-3">True</a> state, then checking is enabled; otherwise, if that attribute is in the <a href="#attr-spellcheck-false-state" id="spelling-and-grammar-checking:attr-spellcheck-false-state">False</a>
   state, then checking is disabled.</li><li>Otherwise, if there is an ancestor element with a <code id="spelling-and-grammar-checking:attr-spellcheck-11"><a href="#attr-spellcheck">spellcheck</a></code> content attribute that is not in the <a href="#attr-spellcheck-default-state" id="spelling-and-grammar-checking:attr-spellcheck-default-state-3">Default</a>
   state, then: if the nearest such ancestor's <code id="spelling-and-grammar-checking:attr-spellcheck-12"><a href="#attr-spellcheck">spellcheck</a></code>
   content attribute is in the <a href="#attr-spellcheck-true-state" id="spelling-and-grammar-checking:attr-spellcheck-true-state-4">True</a> state, then
   checking is enabled; otherwise, checking is disabled.</li><li>Otherwise, if the element's <a href="#concept-spellcheck-default" id="spelling-and-grammar-checking:concept-spellcheck-default-3">default behavior</a>
   is <a href="#concept-spellcheck-default-true" id="spelling-and-grammar-checking:concept-spellcheck-default-true-2">true-by-default</a>, then checking is
   enabled.</li><li>Otherwise, if the element's <a href="#concept-spellcheck-default" id="spelling-and-grammar-checking:concept-spellcheck-default-4">default behavior</a>
   is <a href="#concept-spellcheck-default-false" id="spelling-and-grammar-checking:concept-spellcheck-default-false">false-by-default</a>, then checking is
   disabled.</li><li>Otherwise, if the element's parent element has <em>its</em> checking enabled, then checking
   is enabled.</li><li>Otherwise, checking is disabled.</li></ol>
  </div>

  <p>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 <code id="spelling-and-grammar-checking:the-input-element-3"><a href="#the-input-element">input</a></code> element attributes such as <code id="spelling-and-grammar-checking:attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code> to ensure that the resulting value is valid, where
  possible.</p>

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

  <div class="example">

   <p>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.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">contenteditable</c-><c- o="">=</c-><c- s="">"true"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">spellcheck</c-><c- o="">=</c-><c- s="">"false"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"a"</c-><c- p="">&gt;</c->Hell<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;</c-><c- f="">em</c-><c- p="">&gt;</c->o!<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

   <p>The element with ID "b" in the following example would have checking enabled (the leading
   space character in the attribute's value on the <code id="spelling-and-grammar-checking:the-input-element-4"><a href="#the-input-element">input</a></code> element causes the attribute
   to be ignored, so the ancestor's value is used instead, regardless of the default).</p>

   <pre class="bad"><code class="html"><c- p="">&lt;</c-><c- f="">p</c-> <c- e="">spellcheck</c-><c- o="">=</c-><c- s="">"true"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Name: <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">spellcheck</c-><c- o="">=</c-><c- s="">" false"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"b"</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <p class="note">This specification does not define the user interface for spelling and grammar
  checkers. A user agent could offer on-demand checking, could perform continuous checking while the
  checking is enabled, or could use other interfaces.</p>

  <h4 id="writing-suggestions"><span class="secno">6.8.6</span> Writing suggestions<a href="#writing-suggestions" class="self-link"></a></h4>

  <p>User agents offer writing suggestions as users type into editable regions, either in form
  controls (e.g., the <code id="writing-suggestions:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element) or in elements in an <a href="#editing-host" id="writing-suggestions:editing-host"> editing host</a>.</p>

  <p>The <dfn data-dfn-for="html-global" id="attr-writingsuggestions" data-dfn-type="element-attr"><code>writingsuggestions</code></dfn> content attribute is an
  <a href="#enumerated-attribute" id="writing-suggestions:enumerated-attribute">enumerated attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/writingsuggestions" id="attr-writingsuggestions-true" data-dfn-type="attr-value"><code>true</code></dfn>
     </td><td><dfn id="attr-writingsuggestions-true-state">True</dfn>
     </td><td>Writing suggestions should be offered on this element.
    </td></tr><tr><td><dfn data-dfn-for="html-global/writingsuggestions" id="attr-writingsuggestions-false" data-dfn-type="attr-value"><code>false</code></dfn>
     </td><td><dfn id="attr-writingsuggestions-false-state">False</dfn>
     </td><td>Writing suggestions should not be offered on this element.
    </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="writing-suggestions:missing-value-default"><a href="#missing-value-default">missing value default</a></i> is the <dfn id="attr-writingsuggestions-default-state">Default</dfn> state. The default state indicates
  that the element is to act according to a default behavior, possibly based on the parent
  element's own <code id="writing-suggestions:attr-writingsuggestions"><a href="#attr-writingsuggestions">writingsuggestions</a></code> state, as defined
  below.</p>
  </div>

  <div data-algorithm="">
  <p>The attribute's <i id="writing-suggestions:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> and <i id="writing-suggestions:empty-value-default"><a href="#empty-value-default">empty value default</a></i> are both the <a href="#attr-writingsuggestions-true-state" id="writing-suggestions:attr-writingsuggestions-true-state">True</a> state.</p>
  </div>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-writingsuggestions" id="dom-writingsuggestions-dev">writingSuggestions</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns "<code>true</code>" if the user agent is to offer writing suggestions under
    the scope of the element; otherwise, returns "<code>false</code>".</p>

    <p>Can be set, to override the default and set the <code id="writing-suggestions:attr-writingsuggestions-2"><a href="#attr-writingsuggestions">
    writingsuggestions</a></code> content attribute.</p>
   </dd></dl>

  
  <div data-algorithm="">
  <p>The <dfn id="computed-writing-suggestions-value">computed writing suggestions value</dfn> of a given <var>element</var> is
  determined by running the following steps:</p>

  <ol><li><p>If <var>element</var>'s <code id="writing-suggestions:attr-writingsuggestions-3"><a href="#attr-writingsuggestions">writingsuggestions</a></code>
   content attribute is in the <a href="#attr-writingsuggestions-false-state" id="writing-suggestions:attr-writingsuggestions-false-state">False</a>
   state, return "<code>false</code>".</p></li><li><p>If <var>element</var>'s <code id="writing-suggestions:attr-writingsuggestions-4"><a href="#attr-writingsuggestions">writingsuggestions</a></code> content attribute is in the <a href="#attr-writingsuggestions-default-state" id="writing-suggestions:attr-writingsuggestions-default-state">Default</a> state, <var>element</var> has a
   parent element, and the <a href="#computed-writing-suggestions-value" id="writing-suggestions:computed-writing-suggestions-value">computed writing suggestions value</a> of
   <var>element</var>'s parent element is "<code>false</code>", then return
   "<code>false</code>".</p></li><li><p>Return "<code>true</code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-writingsuggestions" data-dfn-type="attribute"><code>writingSuggestions</code></dfn> getter steps are:</p>

  <ol><li><p>Return <a id="writing-suggestions:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#computed-writing-suggestions-value" id="writing-suggestions:computed-writing-suggestions-value-2">computed writing suggestions value</a>.</p></li></ol>
  </div>

  <p class="note">The <code id="writing-suggestions:dom-writingsuggestions"><a href="#dom-writingsuggestions">writingSuggestions</a></code> IDL
  attribute is not affected by user preferences that override the <code id="writing-suggestions:attr-writingsuggestions-5"><a href="#attr-writingsuggestions">writingsuggestions</a></code> content attribute, and therefore
  might not reflect the actual writing suggestions state.</p>
  

  <hr>

  <div data-algorithm="">
  <p>User agents should only offer suggestions within an element's scope if the
  result of running the following algorithm given <var>element</var> returns true:</p>

  <ol><li><p>If the user has disabled writing suggestions, then return false.</p></li><li>
    <p>If none of the following conditions are true:</p>

    <ul><li><p><var>element</var> is an <code id="writing-suggestions:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="writing-suggestions:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in either the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="writing-suggestions:text-(type=text)-state-and-search-state-(type=search)">Text</a>, <a href="#text-(type=text)-state-and-search-state-(type=search)" id="writing-suggestions:text-(type=text)-state-and-search-state-(type=search)-2">Search</a>, <a href="#telephone-state-(type=tel)" id="writing-suggestions:telephone-state-(type=tel)">Telephone</a>, <a href="#url-state-(type=url)" id="writing-suggestions:url-state-(type=url)">URL</a>,
     or <a href="#email-state-(type=email)" id="writing-suggestions:email-state-(type=email)">Email</a> state and is <i id="writing-suggestions:concept-fe-mutable"><a href="#concept-fe-mutable">mutable</a></i>;</p></li><li><p><var>element</var> is a <code id="writing-suggestions:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> element that is <i id="writing-suggestions:concept-fe-mutable-2"><a href="#concept-fe-mutable">mutable</a></i>; or</p></li><li><p><var>element</var> is an <a href="#editing-host" id="writing-suggestions:editing-host-2">editing host</a> or is
     <a id="writing-suggestions:editable" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a>,</p></li></ul>

    <p>then return false.</p>
   </li><li><p>If <var>element</var> has an <a id="writing-suggestions:inclusive-ancestor" href="https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor" data-x-internal="inclusive-ancestor">inclusive ancestor</a> with a <code id="writing-suggestions:attr-writingsuggestions-6"><a href="#attr-writingsuggestions">writingsuggestions</a></code> content attribute that's not in the
   <a href="#attr-writingsuggestions-default-state" id="writing-suggestions:attr-writingsuggestions-default-state-2">Default</a> and the nearest such
   ancestor's <code id="writing-suggestions:attr-writingsuggestions-7"><a href="#attr-writingsuggestions">writingsuggestions</a></code> content attribute is
   in the <a href="#attr-writingsuggestions-false-state" id="writing-suggestions:attr-writingsuggestions-false-state-2">False</a> state, then return
   false.</p></li><li><p>Otherwise, return true.</p></li></ol>
  </div>

  <p class="note">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.</p>

  <h4 id="autocapitalization"><span class="secno">6.8.7</span> Autocapitalization<a href="#autocapitalization" class="self-link"></a></h4>

  <p>Some methods of entering text, for example virtual keyboards on mobile devices, and also voice
  input, often assist users by automatically capitalizing the first letter of sentences (when
  composing text in a language with this convention). A virtual keyboard that implements
  autocapitalization might automatically switch to showing uppercase letters (but allow the user to
  toggle it back to lowercase) when a letter that should be autocapitalized is about to be typed.
  Other types of input, for example voice input, may perform autocapitalization in a way that does
  not give users an option to intervene first. The <code id="autocapitalization:attr-autocapitalize"><a href="#attr-autocapitalize">autocapitalize</a></code> attribute allows authors to control such
  behavior.</p>

  <p>The <code id="autocapitalization:attr-autocapitalize-2"><a href="#attr-autocapitalize">autocapitalize</a></code> attribute, as typically
  implemented, does not affect behavior when typing on a physical keyboard. (For this reason, as
  well as the ability for users to override the autocapitalization behavior in some cases or edit
  the text after initial input, the attribute must not be relied on for any sort of input
  validation.)</p>

  <p>The <code id="autocapitalization:attr-autocapitalize-3"><a href="#attr-autocapitalize">autocapitalize</a></code> attribute can be used on an <a href="#editing-host" id="autocapitalization:editing-host">editing host</a> to control autocapitalization behavior for the hosted
  editable region, on an <code id="autocapitalization:the-input-element"><a href="#the-input-element">input</a></code> or <code id="autocapitalization:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element to control the behavior
  for inputting text into that element, or on a <code id="autocapitalization:the-form-element"><a href="#the-form-element">form</a></code> element to control the default
  behavior for all <a href="#category-autocapitalize" id="autocapitalization:category-autocapitalize">autocapitalize-and-autocorrect inheriting
  elements</a> associated with the <code id="autocapitalization:the-form-element-2"><a href="#the-form-element">form</a></code> element.

  </p><p>The <code id="autocapitalization:attr-autocapitalize-4"><a href="#attr-autocapitalize">autocapitalize</a></code> attribute never causes
  autocapitalization to be enabled for <code id="autocapitalization:the-input-element-2"><a href="#the-input-element">input</a></code> elements whose <code id="autocapitalization:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in one of the <a href="#url-state-(type=url)" id="autocapitalization:url-state-(type=url)">URL</a>, <a href="#email-state-(type=email)" id="autocapitalization:email-state-(type=email)">Email</a>, or <a href="#password-state-(type=password)" id="autocapitalization:password-state-(type=password)">Password</a> states. (This behavior is included
  in the <a href="#used-autocapitalization-hint" id="autocapitalization:used-autocapitalization-hint">used autocapitalization hint</a> algorithm
  below.)</p>

  <p>The autocapitalization processing model is based on selecting among five
  <dfn id="autocapitalization-hint">autocapitalization hints</dfn>, defined as follows:</p>

  <dl><dt><dfn id="autocap-hint-default">Default</dfn></dt><dd><p>The user agent and input method should make their own determination of whether or not to
   enable autocapitalization.</p></dd><dt><dfn id="autocap-hint-none">None</dfn></dt><dd><p>No autocapitalization should be applied (all letters should default to
   lowercase).</p></dd><dt><dfn id="autocap-hint-sentences">Sentences</dfn></dt><dd><p>The first letter of each sentence should default to a capital letter; all other letters
   should default to lowercase.</p></dd><dt><dfn id="autocap-hint-words">Words</dfn></dt><dd><p>The first letter of each word should default to a capital letter; all other letters should
   default to lowercase.</p></dd><dt><dfn id="autocap-hint-characters">Characters</dfn></dt><dd><p>All letters should default to uppercase.</p></dd></dl>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autocapitalize" title="The autocapitalize global attribute is an enumerated attribute that controls whether and how text input is automatically capitalized as it is entered/edited by the user.">Global_attributes/autocapitalize</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>111+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>43+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie unknown"><span>Internet Explorer</span><span>?</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="html-global" id="attr-autocapitalize" data-dfn-type="element-attr"><code>autocapitalize</code></dfn> attribute is an <a href="#enumerated-attribute" id="autocapitalization:enumerated-attribute">enumerated
  attribute</a> whose states are the possible <a href="#autocapitalization-hint" id="autocapitalization:autocapitalization-hint">autocapitalization hints</a>. The <a href="#autocapitalization-hint" id="autocapitalization:autocapitalization-hint-2">autocapitalization hint</a> specified by the
  attribute's state combines with other considerations to form the <a href="#used-autocapitalization-hint" id="autocapitalization:used-autocapitalization-hint-2">used autocapitalization
  hint</a>, which informs the behavior of the user agent. The keywords for this attribute and
  their state mappings are as follows:</p>

  <table><thead><tr><th> Keyword
     </th><th> State
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/autocapitalize" id="attr-autocapitalize-off" data-dfn-type="attr-value"><code>off</code></dfn>

     </td><td rowspan="2"><a href="#autocap-hint-none" id="autocapitalization:autocap-hint-none">None</a>
    </td></tr><tr><td><dfn data-dfn-for="html-global/autocapitalize" id="attr-autocapitalize-none" data-dfn-type="attr-value"><code>none</code></dfn>
    </td></tr><tr><td><dfn data-dfn-for="html-global/autocapitalize" id="attr-autocapitalize-on" data-dfn-type="attr-value"><code>on</code></dfn>

     </td><td rowspan="2"><a href="#autocap-hint-sentences" id="autocapitalization:autocap-hint-sentences">Sentences</a>
    </td></tr><tr><td><dfn data-dfn-for="html-global/autocapitalize" id="attr-autocapitalize-sentences" data-dfn-type="attr-value"><code>sentences</code></dfn>
    </td></tr><tr><td><dfn data-dfn-for="html-global/autocapitalize" id="attr-autocapitalize-words" data-dfn-type="attr-value"><code>words</code></dfn>

     </td><td><a href="#autocap-hint-words" id="autocapitalization:autocap-hint-words">Words</a>
    </td></tr><tr><td><dfn data-dfn-for="html-global/autocapitalize" id="attr-autocapitalize-characters" data-dfn-type="attr-value"><code>characters</code></dfn>

     </td><td><a href="#autocap-hint-characters" id="autocapitalization:autocap-hint-characters">Characters</a>
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="autocapitalization:missing-value-default"><a href="#missing-value-default">missing value default</a></i> is the <a href="#autocap-hint-default" id="autocapitalization:autocap-hint-default">Default</a> state, and its <i id="autocapitalization:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> is the <a href="#autocap-hint-sentences" id="autocapitalization:autocap-hint-sentences-2">Sentences</a>
  state.
  </p></div>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-autocapitalize" id="dom-autocapitalize-dev">autocapitalize</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns the current autocapitalization state for the element, or an empty string if it hasn't
    been set. Note that for <code id="autocapitalization:the-input-element-3"><a href="#the-input-element">input</a></code> and <code id="autocapitalization:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> elements that inherit their
    state from a <code id="autocapitalization:the-form-element-3"><a href="#the-form-element">form</a></code> element, this will return the autocapitalization state of the
    <code id="autocapitalization:the-form-element-4"><a href="#the-form-element">form</a></code> element, but for an element in an editable region, this will not return the
    autocapitalization state of the editing host (unless this element is, in fact, the <a href="#editing-host" id="autocapitalization:editing-host-2">editing
    host</a>).</p>

    <p>Can be set, to set the <code id="autocapitalization:attr-autocapitalize-5"><a href="#attr-autocapitalize">autocapitalize</a></code> content
    attribute (and thereby change the autocapitalization behavior for the element).</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>To compute the <dfn id="own-autocapitalization-hint">own autocapitalization hint</dfn> of an element <var>element</var>, run the
  following steps:</p>

  <ol><li><p>If the <code id="autocapitalization:attr-autocapitalize-6"><a href="#attr-autocapitalize">autocapitalize</a></code> content attribute is
   present on <var>element</var>, and its value is not the empty string, return the state of the
   attribute.</p></li><li><p>If <var>element</var> is an <a href="#category-autocapitalize" id="autocapitalization:category-autocapitalize-2">autocapitalize-and-autocorrect inheriting
   element</a> and has a non-null <a href="#form-owner" id="autocapitalization:form-owner">form owner</a>, return the <a href="#own-autocapitalization-hint" id="autocapitalization:own-autocapitalization-hint">own
   autocapitalization hint</a> of <var>element</var>'s <a href="#form-owner" id="autocapitalization:form-owner-2">form owner</a>.</p></li><li><p>Return <a href="#autocap-hint-default" id="autocapitalization:autocap-hint-default-2">Default</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-autocapitalize" data-dfn-type="attribute"><code>autocapitalize</code></dfn> getter steps are to:</p>

  <ol><li><p>Let <var>state</var> be the <a href="#own-autocapitalization-hint" id="autocapitalization:own-autocapitalization-hint-2">own autocapitalization hint</a> of
   <a id="autocapitalization:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>If <var>state</var> is <a href="#autocap-hint-default" id="autocapitalization:autocap-hint-default-3">Default</a>, then return the
   empty string.</p></li><li><p>If <var>state</var> is <a href="#autocap-hint-none" id="autocapitalization:autocap-hint-none-2">None</a>, then return "<code id="autocapitalization:attr-autocapitalize-none"><a href="#attr-autocapitalize-none">none</a></code>".</p></li><li><p>If <var>state</var> is <a href="#autocap-hint-sentences" id="autocapitalization:autocap-hint-sentences-3">Sentences</a>, then return
   "<code id="autocapitalization:attr-autocapitalize-sentences"><a href="#attr-autocapitalize-sentences">sentences</a></code>".</p></li><li><p>Return the keyword value corresponding to <var>state</var>.</p></li></ol>
  </div>

  <hr>

  <p>User agents that support customizable autocapitalization behavior for a text input method and
  wish to allow web developers to control this functionality should, during text input into an
  element, compute the <dfn id="used-autocapitalization-hint">used autocapitalization hint</dfn> for the element. This will be an
  <a href="#autocapitalization-hint" id="autocapitalization:autocapitalization-hint-3">autocapitalization hint</a> that describes the recommended autocapitalization behavior
  for text input into the element.</p>

  <p>User agents or input methods may choose to ignore or override the <a href="#used-autocapitalization-hint" id="autocapitalization:used-autocapitalization-hint-3">used autocapitalization
  hint</a> in certain circumstances.</p>

  <div data-algorithm="">
  <p>The <a href="#used-autocapitalization-hint" id="autocapitalization:used-autocapitalization-hint-4">used autocapitalization hint</a> for an element <var>element</var> is computed
  using the following algorithm:</p>

  <ol><li><p>If <var>element</var> is an <code id="autocapitalization:the-input-element-4"><a href="#the-input-element">input</a></code> element whose <code id="autocapitalization:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in one of the <a href="#url-state-(type=url)" id="autocapitalization:url-state-(type=url)-2">URL</a>, <a href="#email-state-(type=email)" id="autocapitalization:email-state-(type=email)-2">Email</a>, or
   <a href="#password-state-(type=password)" id="autocapitalization:password-state-(type=password)-2">Password</a> states, then return <a href="#autocap-hint-default" id="autocapitalization:autocap-hint-default-4">Default</a>.</p></li><li><p>If <var>element</var> is an <code id="autocapitalization:the-input-element-5"><a href="#the-input-element">input</a></code> element or a <code id="autocapitalization:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code> element,
   then return <var>element</var>'s <a href="#own-autocapitalization-hint" id="autocapitalization:own-autocapitalization-hint-3">own autocapitalization hint</a>.</p></li><li><p>If <var>element</var> is an <a href="#editing-host" id="autocapitalization:editing-host-3">editing host</a> or an <a id="autocapitalization:editable" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a> element,
   then return the <a href="#own-autocapitalization-hint" id="autocapitalization:own-autocapitalization-hint-4">own autocapitalization hint</a> of the <a id="autocapitalization:editing-host-of" href="https://w3c.github.io/editing/docs/execCommand/#editing-host-of" data-x-internal="editing-host-of">editing host of</a>
   <var>element</var>.</p></li><li><p><a id="autocapitalization:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this step is never reached, since text input only occurs in elements
   that meet one of the above criteria.</p></li></ol>
  </div>

  


  <h4 id="autocorrection"><span class="secno">6.8.8</span> Autocorrection<a href="#autocorrection" class="self-link"></a></h4>

  <p>Some methods of entering text assist users by automatically correcting misspelled words while
  typing, a process also known as autocorrection. User agents can support autocorrection of editable
  text, either in form controls (such as the value of <code id="autocorrection:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements), or in
  elements in an <a href="#editing-host" id="autocorrection:editing-host">editing host</a> (e.g., using <code id="autocorrection:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code>). Autocorrection may be accompanied by user
  interfaces indicating that text is about to be autocorrected or has been autocorrected, and is
  commonly performed when inserting punctuation characters, spaces, or new paragraphs after
  misspelled words. The <code id="autocorrection:attr-autocorrect"><a href="#attr-autocorrect">autocorrect</a></code> attribute allows authors
  to control such behavior.</p>

  <p>The <code id="autocorrection:attr-autocorrect-2"><a href="#attr-autocorrect">autocorrect</a></code> attribute can be used on an editing host
  to control autocorrection behavior for the hosted editable region, on an <code id="autocorrection:the-input-element"><a href="#the-input-element">input</a></code> or
  <code id="autocorrection:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> element to control the behavior when inserting text into that element, or on
  a <code id="autocorrection:the-form-element"><a href="#the-form-element">form</a></code> element to control the default behavior for all <a href="#category-autocapitalize" id="autocorrection:category-autocapitalize">autocapitalize-and-autocorrect inheriting
  elements</a> associated with the <code id="autocorrection:the-form-element-2"><a href="#the-form-element">form</a></code> element.</p>

  <p>The <code id="autocorrection:attr-autocorrect-3"><a href="#attr-autocorrect">autocorrect</a></code> attribute never causes autocorrection to
  be enabled for <code id="autocorrection:the-input-element-2"><a href="#the-input-element">input</a></code> elements whose <code id="autocorrection:attr-input-type"><a href="#attr-input-type">type</a></code>
  attribute is in one of the <a href="#url-state-(type=url)" id="autocorrection:url-state-(type=url)">URL</a>, <a href="#email-state-(type=email)" id="autocorrection:email-state-(type=email)">Email</a>, or <a href="#password-state-(type=password)" id="autocorrection:password-state-(type=password)">Password</a> states. (This behavior is included
  in the <a href="#used-autocorrection-state" id="autocorrection:used-autocorrection-state">used autocorrection state</a> algorithm below.)</p>

  <p>The <dfn data-dfn-for="html-global" id="attr-autocorrect" data-dfn-type="element-attr"><code>autocorrect</code></dfn> attribute is an enumerated attribute with the
  following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/autocorrect" id="attr-autocorrect-on" data-dfn-type="attr-value"><code>on</code></dfn>
     </td><td><dfn id="concept-autocorrection-on">On</dfn>
     </td><td>The user agent is permitted to automatically correct spelling errors while the user types.
     Whether spelling is automatically corrected while typing left is for the user agent to decide,
     and may depend on the element as well as the user's preferences.
    </td></tr><tr><td><dfn data-dfn-for="html-global/autocorrect" id="attr-autocorrect-off" data-dfn-type="attr-value"><code>off</code></dfn>
     </td><td><dfn id="concept-autocorrection-off">Off</dfn>
     </td><td>The user agent is not allowed to automatically correct spelling while the user types.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="autocorrection:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i>, <i id="autocorrection:missing-value-default"><a href="#missing-value-default">missing value default</a></i>, and <i id="autocorrection:empty-value-default"><a href="#empty-value-default">empty value
  default</a></i> are all the <a href="#concept-autocorrection-on" id="autocorrection:concept-autocorrection-on">On</a> state.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-autocorrect" data-dfn-type="attribute"><code>autocorrect</code></dfn>
  getter steps are: return true if the element's <a href="#used-autocorrection-state" id="autocorrection:used-autocorrection-state-2">used autocorrection state</a> is <a href="#concept-autocorrection-on" id="autocorrection:concept-autocorrection-on-2">On</a> and false if the element's <a href="#used-autocorrection-state" id="autocorrection:used-autocorrection-state-3">used autocorrection
  state</a> is <a href="#concept-autocorrection-off" id="autocorrection:concept-autocorrection-off">Off</a>. The setter steps are: if the
  given value is true, then the element's <code id="autocorrection:attr-autocorrect-4"><a href="#attr-autocorrect">autocorrect</a></code>
  attribute must be set to "<code>on</code>"; otherwise it must be set to "<code>off</code>".</p>
  </div>

  <div data-algorithm="">
  <p>To compute the <dfn id="used-autocorrection-state">used autocorrection state</dfn> of an element <var>element</var>, run these
  steps:</p>

  <ol><li><p>If <var>element</var> is an <code id="autocorrection:the-input-element-3"><a href="#the-input-element">input</a></code> element whose <code id="autocorrection:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in one of the <a href="#url-state-(type=url)" id="autocorrection:url-state-(type=url)-2">URL</a>, <a href="#email-state-(type=email)" id="autocorrection:email-state-(type=email)-2">Email</a>, or
   <a href="#password-state-(type=password)" id="autocorrection:password-state-(type=password)-2">Password</a> states, then return <a href="#concept-autocorrection-off" id="autocorrection:concept-autocorrection-off-2">Off</a>.</p></li><li><p>If the <code id="autocorrection:attr-autocorrect-5"><a href="#attr-autocorrect">autocorrect</a></code> content attribute is present on
   <var>element</var>, then return the state of the attribute.</p></li><li><p>If <var>element</var> is an <a href="#category-autocapitalize" id="autocorrection:category-autocapitalize-2">autocapitalize-and-autocorrect inheriting
   element</a> and has a non-null <a href="#form-owner" id="autocorrection:form-owner">form owner</a>, then return the state of
   <var>element</var>'s <a href="#form-owner" id="autocorrection:form-owner-2">form owner</a>'s <code id="autocorrection:attr-autocorrect-6"><a href="#attr-autocorrect">autocorrect</a></code>
   attribute.</p></li><li><p>Return <a href="#concept-autocorrection-on" id="autocorrection:concept-autocorrection-on-3">On</a>.</p></li></ol>
  </div>

  <dl class="domintro"><dt><var>element</var> . <code id="dom-autocorrect-dev"><a href="#dom-autocorrect">autocorrect</a></code></dt><dd><p>Returns the autocorrection behavior of the element. Note that for <a href="#category-autocapitalize" id="autocorrection:category-autocapitalize-3">autocapitalize-and-autocorrect inheriting
   elements</a> that inherit their state from a <code id="autocorrection:the-form-element-3"><a href="#the-form-element">form</a></code> element, this will return the
   autocorrection behavior of the <code id="autocorrection:the-form-element-4"><a href="#the-form-element">form</a></code> element, but for an element in an editable
   region, this will not return the autocorrection behavior of the <a href="#editing-host" id="autocorrection:editing-host-2">editing host</a> (unless
   this element is, in fact, the <a href="#editing-host" id="autocorrection:editing-host-3">editing host</a>).</p></dd><dt><var>element</var> . <code id="autocorrection:dom-autocorrect"><a href="#dom-autocorrect">autocorrect</a></code> =
   <var>value</var></dt><dd><p>Updates the <code id="autocorrection:attr-autocorrect-7"><a href="#attr-autocorrect">autocorrect</a></code> content attribute (and
   thereby changes the autocorrection behavior of the element).</p></dd></dl>

  <div class="example">
   <p>The <code id="autocorrection:the-input-element-4"><a href="#the-input-element">input</a></code> element in the following example would not allow autocorrection, since
   it does not have an <code id="autocorrection:attr-autocorrect-8"><a href="#attr-autocorrect">autocorrect</a></code> content attribute and
   therefore inherits from the <code id="autocorrection:the-form-element-5"><a href="#the-form-element">form</a></code> element, which has an attribute of "<code id="autocorrection:attr-autocorrect-off"><a href="#attr-autocorrect-off">off</a></code>". However, the <code id="autocorrection:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code> element would allow
   autocorrection, since it has an <code id="autocorrection:attr-autocorrect-9"><a href="#attr-autocorrect">autocorrect</a></code> content
   attribute with a value of "<code id="autocorrection:attr-autocorrect-on"><a href="#attr-autocorrect-on">on</a></code>".</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">autocorrect</c-><c- o="">=</c-><c- s="">"off"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"search"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">autocorrect</c-><c- o="">=</c-><c- s="">"on"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h4 id="input-modalities:-the-inputmode-attribute"><span class="secno">6.8.9</span> Input modalities: the <code id="input-modalities:-the-inputmode-attribute:attr-inputmode"><a href="#attr-inputmode">inputmode</a></code> attribute<a href="#input-modalities:-the-inputmode-attribute" class="self-link"></a></h4>

  <p>User agents can support the <code id="input-modalities:-the-inputmode-attribute:attr-inputmode-2"><a href="#attr-inputmode">inputmode</a></code> attribute on form
  controls (such as the value of <code id="input-modalities:-the-inputmode-attribute:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements), or in elements in an <a href="#editing-host" id="input-modalities:-the-inputmode-attribute:editing-host">editing
  host</a> (e.g., using <code id="input-modalities:-the-inputmode-attribute:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code>).</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode" title="The inputmode global attribute is an enumerated attribute that hints at the type of data that might be entered by the user while editing the element or its contents. This allows a browser to display an appropriate virtual keyboard.">Global_attributes/inputmode</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>95+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>66+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>79+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>12.2+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The <dfn data-dfn-for="html-global" id="attr-inputmode" data-dfn-type="element-attr"><code>inputmode</code></dfn>
  content attribute is an <a href="#enumerated-attribute" id="input-modalities:-the-inputmode-attribute:enumerated-attribute">enumerated attribute</a> that specifies what kind of input
  mechanism would be most helpful for users entering content.</p>

  <table><thead><tr><th> Keyword
     </th><th> Description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/inputmode" id="attr-inputmode-keyword-none" data-dfn-type="attr-value"><code>none</code></dfn>

     </td><td>The user agent should not display a virtual keyboard. This keyword is useful for content
     that renders its own keyboard control.
    </td></tr><tr><td><dfn data-dfn-for="html-global/inputmode" id="attr-inputmode-keyword-text" data-dfn-type="attr-value"><code>text</code></dfn>

     </td><td>The user agent should display a virtual keyboard capable of text input in the user's locale.
    </td></tr><tr><td><dfn data-dfn-for="html-global/inputmode" id="attr-inputmode-keyword-tel" data-dfn-type="attr-value"><code>tel</code></dfn>

     </td><td> The user agent should display a virtual keyboard capable of telephone number input. This
     should including keys for the digits 0 to 9, the "#" character, and the "*" character. In some
     locales, this can also include alphabetic mnemonic labels (e.g., in the US, the key labeled
     "2" is historically also labeled with the letters A, B, and C).
    </td></tr><tr><td><dfn data-dfn-for="html-global/inputmode" id="attr-inputmode-keyword-url" data-dfn-type="attr-value"><code>url</code></dfn>

     </td><td>The user agent should display a virtual keyboard capable of text input in the user's locale,
     with keys for aiding in the input of <a href="https://url.spec.whatwg.org/#concept-url" id="input-modalities:-the-inputmode-attribute:url" data-x-internal="url">URLs</a>, such as that for the "/"
     and "." characters and for quick input of strings commonly found in domain names such as
     "www." or ".com".
    </td></tr><tr><td><dfn data-dfn-for="html-global/inputmode" id="attr-inputmode-keyword-email" data-dfn-type="attr-value"><code>email</code></dfn>

     </td><td>The user agent should display a virtual keyboard capable of text input in the user's locale,
     with keys for aiding in the input of email addresses, such as that for the "@" character
     and the "." character.
    </td></tr><tr><td><dfn data-dfn-for="html-global/inputmode" id="attr-inputmode-keyword-numeric" data-dfn-type="attr-value"><code>numeric</code></dfn>

     </td><td> The user agent should display a virtual keyboard capable of numeric input. This keyword
     is useful for PIN entry.
    </td></tr><tr><td><dfn data-dfn-for="html-global/inputmode" id="attr-inputmode-keyword-decimal" data-dfn-type="attr-value"><code>decimal</code></dfn>

     </td><td> The user agent should display a virtual keyboard capable of fractional numeric input.
     Numeric keys and the format separator for the locale should be shown.
    </td></tr><tr><td><dfn data-dfn-for="html-global/inputmode" id="attr-inputmode-keyword-search" data-dfn-type="attr-value"><code>search</code></dfn>

     </td><td>The user agent should display a virtual keyboard optimized for search.
  </td></tr></tbody></table>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inputMode" title="The HTMLElement property inputMode reflects the value of the element's inputmode attribute.">HTMLElement/inputMode</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>95+</span></span><span class="safari yes"><span>Safari</span><span>12.1+</span></span><span class="chrome yes"><span>Chrome</span><span>66+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>79+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementContentEditable" id="dom-inputmode" data-dfn-type="attribute"><code>inputMode</code></dfn> IDL attribute must <a href="#reflect" id="input-modalities:-the-inputmode-attribute:reflect">reflect</a> the <code id="input-modalities:-the-inputmode-attribute:attr-inputmode-3"><a href="#attr-inputmode">inputmode</a></code> content attribute, <a href="#limited-to-only-known-values" id="input-modalities:-the-inputmode-attribute:limited-to-only-known-values">limited to only known
  values</a>.</p>
  </div>

  <p>When <code id="input-modalities:-the-inputmode-attribute:attr-inputmode-4"><a href="#attr-inputmode">inputmode</a></code> is unspecified (or is in a state not
  supported by the user agent), the user agent should determine the default virtual keyboard to be
  shown. Contextual information such as the input <code id="input-modalities:-the-inputmode-attribute:attr-input-type"><a href="#attr-input-type">type</a></code> or
  <code id="input-modalities:-the-inputmode-attribute:attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code> attributes should be used to determine which type
  of virtual keyboard should be presented to the user.</p>

  

  <h4 id="input-modalities:-the-enterkeyhint-attribute"><span class="secno">6.8.10</span> Input modalities: the <code id="input-modalities:-the-enterkeyhint-attribute:attr-enterkeyhint"><a href="#attr-enterkeyhint">enterkeyhint</a></code>
  attribute<a href="#input-modalities:-the-enterkeyhint-attribute" class="self-link"></a></h4>

  <p>User agents can support the <code id="input-modalities:-the-enterkeyhint-attribute:attr-enterkeyhint-2"><a href="#attr-enterkeyhint">enterkeyhint</a></code>
  attribute on form controls (such as the value of <code id="input-modalities:-the-enterkeyhint-attribute:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements), or in elements
  in an <a href="#editing-host" id="input-modalities:-the-enterkeyhint-attribute:editing-host">editing host</a> (e.g., using <code id="input-modalities:-the-enterkeyhint-attribute:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code>).</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint" title="The enterkeyhint global attribute is an enumerated attribute defining what action label (or icon) to present for the enter key on virtual keyboards.">Global_attributes/enterkeyhint</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>94+</span></span><span class="safari yes"><span>Safari</span><span>13.1+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera yes"><span>Opera</span><span>66+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>57+</span></span></div></div></div><p>The <dfn data-dfn-for="html-global" id="attr-enterkeyhint" data-dfn-type="element-attr"><code>enterkeyhint</code></dfn> content attribute is an <a href="#enumerated-attribute" id="input-modalities:-the-enterkeyhint-attribute:enumerated-attribute">enumerated
  attribute</a> that specifies what action label (or icon) to present for the enter key on
  virtual keyboards. This allows authors to customize the presentation of the enter key in order to
  make it more helpful for users.</p>

  <table><thead><tr><th> Keyword
     </th><th> Description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/enterkeyhint" id="attr-enterkeyhint-keyword-enter" data-dfn-type="attr-value"><code>enter</code></dfn>

     </td><td>The user agent should present a cue for the operation 'enter', typically
     inserting a new line.
    </td></tr><tr><td><dfn data-dfn-for="html-global/enterkeyhint" id="attr-enterkeyhint-keyword-done" data-dfn-type="attr-value"><code>done</code></dfn>

     </td><td>The user agent should present a cue for the operation 'done', typically
     meaning there is nothing more to input and the input method editor (IME)
     will be closed.
    </td></tr><tr><td><dfn data-dfn-for="html-global/enterkeyhint" id="attr-enterkeyhint-keyword-go" data-dfn-type="attr-value"><code>go</code></dfn>

     </td><td> The user agent should present a cue for the operation 'go', typically
     meaning to take the user to the target of the text they typed.
    </td></tr><tr><td><dfn data-dfn-for="html-global/enterkeyhint" id="attr-enterkeyhint-keyword-next" data-dfn-type="attr-value"><code>next</code></dfn>

     </td><td>The user agent should present a cue for the operation 'next', typically
     taking the user to the next field that will accept text.
    </td></tr><tr><td><dfn data-dfn-for="html-global/enterkeyhint" id="attr-enterkeyhint-keyword-previous" data-dfn-type="attr-value"><code>previous</code></dfn>

     </td><td>The user agent should present a cue for the operation 'previous', typically
     taking the user to the previous field that will accept text.
    </td></tr><tr><td><dfn data-dfn-for="html-global/enterkeyhint" id="attr-enterkeyhint-keyword-search" data-dfn-type="attr-value"><code>search</code></dfn>

     </td><td>The user agent should present a cue for the operation 'search', typically
     taking the user to the results of searching for the text they have typed.
    </td></tr><tr><td><dfn data-dfn-for="html-global/enterkeyhint" id="attr-enterkeyhint-keyword-send" data-dfn-type="attr-value"><code>send</code></dfn>

     </td><td> The user agent should present a cue for the operation 'send', typically
     delivering the text to its target.
  </td></tr></tbody></table>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/enterKeyHint" title="The enterKeyHint property is an enumerated property defining what action label (or icon) to present for the enter key on virtual keyboards. It reflects the enterkeyhint HTML global attribute and is an enumerated property, only accepting the following values as a string:">HTMLElement/enterKeyHint</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>94+</span></span><span class="safari yes"><span>Safari</span><span>13.1+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="ElementContentEditable" id="dom-enterkeyhint" data-dfn-type="attribute"><code>enterKeyHint</code></dfn> IDL attribute must <a href="#reflect" id="input-modalities:-the-enterkeyhint-attribute:reflect">reflect</a> the
  <code id="input-modalities:-the-enterkeyhint-attribute:attr-enterkeyhint-3"><a href="#attr-enterkeyhint">enterkeyhint</a></code> content attribute, <a href="#limited-to-only-known-values" id="input-modalities:-the-enterkeyhint-attribute:limited-to-only-known-values">limited to only
  known values</a>.</p>
  </div>

  <p>When <code id="input-modalities:-the-enterkeyhint-attribute:attr-enterkeyhint-4"><a href="#attr-enterkeyhint">enterkeyhint</a></code> is unspecified (or is in a state not
  supported by the user agent), the user agent should determine the default action label (or icon)
  to present. Contextual information such as the <code id="input-modalities:-the-enterkeyhint-attribute:attr-inputmode"><a href="#attr-inputmode">inputmode</a></code>,
  <code id="input-modalities:-the-enterkeyhint-attribute:attr-input-type"><a href="#attr-input-type">type</a></code>, or <code id="input-modalities:-the-enterkeyhint-attribute:attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>
  attributes should be used to determine which action label (or icon) to present on the virtual
  keyboard.</p>

  

  <h3 id="find-in-page"><span class="secno">6.9</span> Find-in-page<a href="#find-in-page" class="self-link"></a></h3>

  <h4 id="introduction-10"><span class="secno">6.9.1</span> Introduction<a href="#introduction-10" class="self-link"></a></h4>

  <p>This section defines <dfn id="find-in-page-2">find-in-page</dfn> — a common user-agent mechanism which allows users
  to search through the contents of the page for particular information.</p>

  <p>Access to the <a href="#find-in-page-2" id="introduction-10:find-in-page-2">find-in-page</a> feature is provided via a <dfn id="find-in-page-interface">find-in-page
  interface</dfn>. This is a user-agent provided user interface, which allows the user to specify
  input and the parameters of the search. This interface can appear as a result of a shortcut or a
  menu selection.</p>

  <p>A combination of text input and settings in the <a href="#find-in-page-interface" id="introduction-10:find-in-page-interface">find-in-page interface</a> represents
  the user <dfn id="fip-query">query</dfn>. This typically includes the text that the user wants
  to search for, as well as optional settings (e.g., the ability to restrict the search to whole
  words only).</p>

  <p>The user-agent processes page contents for a given <a href="#fip-query" id="introduction-10:fip-query">query</a>, and
  identifies zero or more <dfn id="fip-matches">matches</dfn>, which are content ranges that
  satisfy the user <a href="#fip-query" id="introduction-10:fip-query-2">query</a>.</p>

  <p>One of the <a href="#fip-matches" id="introduction-10:fip-matches">matches</a> is identified to the user as the <dfn id="fip-active-match">active match</dfn>. It is highlighted and scrolled into view. The user
  can navigate through the <a href="#fip-matches" id="introduction-10:fip-matches-2">matches</a> by advancing the <a href="#fip-active-match" id="introduction-10:fip-active-match">active match</a> using the <a href="#find-in-page-interface" id="introduction-10:find-in-page-interface-2">find-in-page interface</a>.</p>

  <p class="XXX"><a href="https://github.com/whatwg/html/issues/3539">Issue #3539</a> tracks
  standardizing how <a href="#find-in-page-2" id="introduction-10:find-in-page-2-2">find-in-page</a> underlies the currently-unspecified <code>window.find()</code> API.</p>

  <h4 id="interaction-with-details-and-hidden=until-found"><span class="secno">6.9.2</span> Interaction with <code id="interaction-with-details-and-hidden=until-found:the-details-element"><a href="#the-details-element">details</a></code> and <code id="interaction-with-details-and-hidden=until-found:attr-hidden-until-found-state"><a href="#attr-hidden-until-found-state">hidden=until-found</a></code><a href="#interaction-with-details-and-hidden=until-found" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When find-in-page begins searching for matches, all <code id="interaction-with-details-and-hidden=until-found:the-details-element-2"><a href="#the-details-element">details</a></code> elements in the page
  which do not have their <code id="interaction-with-details-and-hidden=until-found:attr-details-open"><a href="#attr-details-open">open</a></code> attribute set should have the
  <a href="https://drafts.csswg.org/css-contain/#skips-its-contents" id="interaction-with-details-and-hidden=until-found:skips-its-contents" data-x-internal="skips-its-contents">skipped contents</a> of their second slot become accessible,
  without modifying the <code id="interaction-with-details-and-hidden=until-found:attr-details-open-2"><a href="#attr-details-open">open</a></code> attribute, in order to make
  find-in-page able to search through it. Similarly, all HTML elements with the <code id="interaction-with-details-and-hidden=until-found:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute in the <a href="#attr-hidden-until-found-state" id="interaction-with-details-and-hidden=until-found:attr-hidden-until-found-state-2">Hidden Until Found</a> state should have their <a href="https://drafts.csswg.org/css-contain/#skips-its-contents" id="interaction-with-details-and-hidden=until-found:skips-its-contents-2" data-x-internal="skips-its-contents">skipped contents</a> become accessible without modifying the <code id="interaction-with-details-and-hidden=until-found:attr-hidden-2"><a href="#attr-hidden">hidden</a></code> attribute in order to make find-in-page able to search through
  them. After find-in-page finishes searching for matches, the <code id="interaction-with-details-and-hidden=until-found:the-details-element-3"><a href="#the-details-element">details</a></code> elements and the
  elements with the <code id="interaction-with-details-and-hidden=until-found:attr-hidden-3"><a href="#attr-hidden">hidden</a></code> attribute in the <a href="#attr-hidden-until-found-state" id="interaction-with-details-and-hidden=until-found:attr-hidden-until-found-state-3">Hidden Until Found</a> state should have their contents
  become skipped again. This entire process must happen synchronously (and so is not observable to
  users or to author code). <a href="#refsCSSCONTAIN">[CSSCONTAIN]</a></p>
  </div>

  <div data-algorithm="">
  <p>When find-in-page chooses a new <a href="#fip-active-match" id="interaction-with-details-and-hidden=until-found:fip-active-match">active match</a>, perform
  the following steps:</p>

  <ol><li><p>Let <var>node</var> be the first node in the <a href="#fip-active-match" id="interaction-with-details-and-hidden=until-found:fip-active-match-2">active
   match</a>.</p></li><li><p><a href="#queue-a-global-task" id="interaction-with-details-and-hidden=until-found:queue-a-global-task">Queue a global task</a> on the <a href="#user-interaction-task-source" id="interaction-with-details-and-hidden=until-found:user-interaction-task-source">user interaction task source</a> given
   <var>node</var>'s <a href="#concept-relevant-global" id="interaction-with-details-and-hidden=until-found:concept-relevant-global">relevant global object</a> to run the <a href="#ancestor-revealing-algorithm" id="interaction-with-details-and-hidden=until-found:ancestor-revealing-algorithm">ancestor revealing
   algorithm</a> on <var>node</var>.</p></li></ol>
  </div>

  <p class="warning">
  <a id="interaction-with-details-and-hidden=until-found:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  When find-in-page auto-expands a <code id="interaction-with-details-and-hidden=until-found:the-details-element-4"><a href="#the-details-element">details</a></code> element like this, it will fire a <code id="interaction-with-details-and-hidden=until-found:event-toggle"><a href="#event-toggle">toggle</a></code> event. As with the separate <code id="interaction-with-details-and-hidden=until-found:event-scroll"><a data-x-internal="event-scroll" href="https://drafts.csswg.org/cssom-view/#eventdef-document-scroll">scroll</a></code> 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 <code id="interaction-with-details-and-hidden=until-found:the-details-element-5"><a href="#the-details-element">details</a></code> element, the page could listen to <code id="interaction-with-details-and-hidden=until-found:event-toggle-2"><a href="#event-toggle">toggle</a></code> events instead of <code id="interaction-with-details-and-hidden=until-found:event-scroll-2"><a data-x-internal="event-scroll" href="https://drafts.csswg.org/cssom-view/#eventdef-document-scroll">scroll</a></code>
  events. This attack could be addressed for both events by not acting on every character the user
  types into the find-in-page dialog.</p>

  <h4 id="interaction-with-selection"><span class="secno">6.9.3</span> Interaction with selection<a href="#interaction-with-selection" class="self-link"></a></h4>

  <p>The find-in-page process is invoked in the context of a document, and may have an effect on
  the <a href="https://w3c.github.io/selection-api/#dfn-selection" id="interaction-with-selection:document-selection" data-x-internal="document-selection">selection</a> of that document. Specifically, the range
  that defines the <a href="#fip-active-match" id="interaction-with-selection:fip-active-match">active match</a> can dictate the current
  selection. These selection updates, however, can happen at different times during the
  find-in-page process (e.g. upon the <a href="#find-in-page-interface" id="interaction-with-selection:find-in-page-interface">find-in-page interface</a> dismissal or upon a change
  in the <a href="#fip-active-match" id="interaction-with-selection:fip-active-match-2">active match</a> range).

  


  </p><h3 id="close-requests-and-close-watchers"><span class="secno">6.10</span> Close requests and close watchers<a href="#close-requests-and-close-watchers" class="self-link"></a></h3>

  <h4 id="close-requests"><span class="secno">6.10.1</span> Close requests<a href="#close-requests" class="self-link"></a></h4>

  <p>In an <a id="close-requests:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> (and likely device-specific) manner, a user can send
  a <dfn id="close-request" data-export="">close request</dfn> 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.</p>

  <div class="example">
   <p>Some example close requests are:</p>

   <ul><li><p>The <kbd>Esc</kbd> key on desktop platforms.</p></li><li><p>The back button or gesture on certain mobile platforms such as Android.</p></li><li><p>Any assistive technology's dismiss gesture, such as iOS VoiceOver's two-finger scrub "z"
    gesture.</p></li><li><p>A game controller's canonical "back" button, such as the circle button on a DualShock
    gamepad.</p></li></ul>
  </div>

  

  <div data-algorithm="">
  <p>Whenever the user agent receives a potential close request targeted at a <code id="close-requests:document"><a href="#document">Document</a></code>
  <var>document</var>, it must <a href="#queue-a-global-task" id="close-requests:queue-a-global-task">queue a global task</a> on the <a href="#user-interaction-task-source" id="close-requests:user-interaction-task-source">user interaction task
  source</a> given <var>document</var>'s <a href="#concept-relevant-global" id="close-requests:concept-relevant-global">relevant global object</a> to perform the
  following <dfn id="close-request-steps" data-export="">close request steps</dfn>:</p>

  <ol><li>
    <p>If <var>document</var>'s <a id="close-requests:fullscreen-element" href="https://fullscreen.spec.whatwg.org/#fullscreen-element" data-x-internal="fullscreen-element">fullscreen element</a> is not null, then:</p>

    <ol><li><p><a id="close-requests:fully-exit-fullscreen" href="https://fullscreen.spec.whatwg.org/#fully-exit-fullscreen" data-x-internal="fully-exit-fullscreen">Fully exit fullscreen</a> given <var>document</var>'s <a href="#node-navigable" id="close-requests:node-navigable">node
     navigable</a>'s <a href="#nav-top" id="close-requests:nav-top">top-level traversable</a>'s <a href="#nav-document" id="close-requests:nav-document">active document</a>.</p></li><li><p>Return.</p>
    </li></ol>

    <p class="note">This does <em>not</em> fire any relevant event, such as <code id="close-requests:event-keydown"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code>; it only causes <code id="close-requests:event-fullscreenchange"><a data-x-internal="event-fullscreenchange" href="https://fullscreen.spec.whatwg.org/#eventdef-document-fullscreenchange">fullscreenchange</a></code> to be eventually fired.</p>
   </li><li>
    <p>Optionally, skip to the step labeled <a href="#close-request-fallback">alternative
    processing</a>.</p>

    <p class="note">For example, if the user agent detects user frustration at repeated close
    request interception by the current web page, it might take this path.</p>
   </li><li>
    <p>Fire any relevant events, per <cite>UI Events</cite> or other relevant specifications.
    <a href="#refsUIEVENTS">[UIEVENTS]</a></p>

    <p class="example">An example of a relevant event in the <cite>UI Events</cite> model would be
    the <code id="close-requests:event-keydown-2"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code>  event that <cite>UI Events</cite> <a href="https://w3c.github.io/uievents/#events-keyboard-event-order">suggests</a> firing when the
    user presses the <kbd>Esc</kbd> key on their keyboard. On most platforms with keyboards, this
    is treated as a <a href="#close-request" id="close-requests:close-request">close request</a>, and so would trigger these <a href="#close-request-steps" id="close-requests:close-request-steps">close request
    steps</a>.</p>

    <p class="example">An example of relevant events that are outside of the model given in
    <cite>UI Events</cite> would be assistive technology synthesizing an <kbd>Esc</kbd> <code id="close-requests:event-keydown-3"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code> event when the user sends a <a href="#close-request" id="close-requests:close-request-2">close request</a> by
    using a dismiss gesture.</p>
   </li><li><p>Let <var>event</var> be null if no such events are fired, or the <code id="close-requests:event"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
   object representing one of the fired events otherwise. If multiple events are fired, which one
   is chosen is <a id="close-requests:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>.</p></li><li><p>If <var>event</var> is not null, and its <a id="close-requests:canceled-flag" href="https://dom.spec.whatwg.org/#canceled-flag" data-x-internal="canceled-flag">canceled flag</a> is set, then
   return.</p></li><li>
    <p>If <var>document</var> is not <a href="#fully-active" id="close-requests:fully-active">fully active</a>, then return.</p>

    <p class="note">This step is necessary because, if <var>event</var> is not null, then an event
    listener might have caused <var>document</var> to no longer be <a href="#fully-active" id="close-requests:fully-active-2">fully active</a>.</p>
   </li><li><p>Let <var>closedSomething</var> be the result of <a href="#process-close-watchers" id="close-requests:process-close-watchers">processing close watchers</a> on <var>document</var>'s <a href="#concept-relevant-global" id="close-requests:concept-relevant-global-2">relevant global
   object</a>.</p></li><li><p>If <var>closedSomething</var> is true, then return.</p></li><li id="close-request-fallback"><p><i>Alternative processing</i>: Otherwise, there was nothing
   watching for a <a href="#close-request" id="close-requests:close-request-3">close request</a>. The user agent may instead interpret this interaction
   as some other action, instead of interpreting it as a close request.</p></li></ol>
  </div>

  

  <p>On platforms where pressing the <kbd>Esc</kbd> key is interpreted as a <a href="#close-request" id="close-requests:close-request-4">close
  request</a>, the user agent must interpret the key being pressed <em>down</em> as the close
  request, instead of the key being released. Thus, in the above algorithm, the "relevant events"
  that are fired must be the single <code id="close-requests:event-keydown-4"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code> event.</p>

  <p class="example">On platforms where <kbd>Esc</kbd> is the <a href="#close-request" id="close-requests:close-request-5">close request</a>, the user
  agent will first fire an appropriately-initialized <code id="close-requests:event-keydown-5"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code>
  event. If the web developer cancels the event by calling <code id="close-requests:dom-event-preventdefault"><a data-x-internal="dom-event-preventdefault" href="https://dom.spec.whatwg.org/#dom-event-preventdefault">preventDefault()</a></code>, then nothing further happens. But if
  the event fires without being canceled, then the user agent proceeds to <a href="#process-close-watchers" id="close-requests:process-close-watchers-2">process close
  watchers</a>.</p>

  <p class="example">On platforms where a back button is a potential <a href="#close-request" id="close-requests:close-request-6">close request</a>, no
  event is involved, so when the back button is pressed, the user agent proceeds directly to
  <a href="#process-close-watchers" id="close-requests:process-close-watchers-3">process close watchers</a>. If there is an <a href="#close-watcher-active" id="close-requests:close-watcher-active">active</a> <a href="#close-watcher" id="close-requests:close-watcher">close watcher</a>, 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 <a href="#traverse-the-history-by-a-delta" id="close-requests:traverse-the-history-by-a-delta">traverse the history by a delta</a> of −1.</p>


  

  <h4 id="close-watcher-infrastructure"><span class="secno">6.10.2</span> Close watcher infrastructure<a href="#close-watcher-infrastructure" class="self-link"></a></h4>

  <p>Each <code id="close-watcher-infrastructure:window"><a href="#window">Window</a></code> has a <dfn id="close-watcher-manager">close watcher manager</dfn>, which is a
  <a id="close-watcher-infrastructure:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="close-watcher-infrastructure:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="close-watcher-manager-groups">Groups</dfn>, a <a id="close-watcher-infrastructure:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="https://infra.spec.whatwg.org/#list" id="close-watcher-infrastructure:list-2" data-x-internal="list">lists</a> of <a href="#close-watcher" id="close-watcher-infrastructure:close-watcher">close watchers</a>, initially
   empty.</p></li><li><p><dfn id="close-watcher-manager-allowed-number-of-groups">Allowed number of
   groups</dfn>, a number, initially 1.</p></li><li><p><dfn id="close-watcher-manager-next">Next user interaction allows a new group</dfn>,
   a boolean, initially true.</p></li></ul>

  <p>Most of the complexity of the <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager">close watcher manager</a> comes from anti-abuse
  protections designed to prevent developers from disabling users' history traversal abilities, for
  platforms where a <a href="#close-request" id="close-watcher-infrastructure:close-request">close request</a>'s <a href="#close-request-fallback">fallback
  action</a> is the main mechanism of history traversal. In particular:</p>

  <p>The grouping of <a href="#close-watcher" id="close-watcher-infrastructure:close-watcher-2">close watchers</a> is designed so that if
  multiple close watchers are created without <a href="#history-action-activation" id="close-watcher-infrastructure:history-action-activation">history-action activation</a>, they are
  grouped together, so that a user-triggered <a href="#close-request" id="close-watcher-infrastructure:close-request-2">close request</a> will close all of the close
  watchers in a group. This ensures that web developers can't intercept an unlimited number of
  close requests by creating close watchers; instead they can create a number equal to at most 1 +
  the number of times the <a href="#tracking-user-activation" id="close-watcher-infrastructure:tracking-user-activation">user activates the page</a>.</p>

  <p>The <a href="#close-watcher-manager-next" id="close-watcher-infrastructure:close-watcher-manager-next">next user interaction allows a new group</a>
  boolean encourages web developers to create <a href="#close-watcher" id="close-watcher-infrastructure:close-watcher-3">close watchers</a> in
  a way that is tied to individual <a href="#tracking-user-activation" id="close-watcher-infrastructure:tracking-user-activation-2">user activations</a>. Without
  it, each user activation would increase the <a href="#close-watcher-manager-allowed-number-of-groups" id="close-watcher-infrastructure:close-watcher-manager-allowed-number-of-groups">allowed number of groups</a>, even if the web developer isn't "using" those user
  activations to create close watchers. In short:</p>

  <ul><li><p>Allowed: user interaction; create a close watcher in its own group; user interaction;
   create a close watcher in a second independent group.</p></li><li><p>Disallowed: user interaction; user interaction; create a close watcher in its own group;
   create a close watcher in a second independent group.</p></li><li><p>Allowed: user interaction; user interaction; create a close watcher in its own group;
   create a close watcher grouped with the previous one.</p></li></ul>

  <p>This protection is <em>not</em> important for upholding our desired invariant of creating at
  most (1 + the number of times the <a href="#tracking-user-activation" id="close-watcher-infrastructure:tracking-user-activation-3">user activates the page</a>)
  groups. A determined abuser will just create one close watcher per user interaction, "banking"
  them for future abuse. But this system causes more predictable behavior for the normal case, and
  encourages non-abusive developers to create close watchers directly in response to user
  interactions.</p>

  <div data-algorithm="">
  <p>To <dfn id="notify-the-close-watcher-manager-about-user-activation">notify the close watcher manager about user activation</dfn> given a
  <code id="close-watcher-infrastructure:window-2"><a href="#window">Window</a></code> <var>window</var>:</p>

  <ol><li><p>Let <var>manager</var> be <var>window</var>'s <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager-2">close watcher manager</a>.</p></li><li><p>If <var>manager</var>'s <a href="#close-watcher-manager-next" id="close-watcher-infrastructure:close-watcher-manager-next-2">next user interaction
   allows a new group</a> is true, then increment <var>manager</var>'s <a href="#close-watcher-manager-allowed-number-of-groups" id="close-watcher-infrastructure:close-watcher-manager-allowed-number-of-groups-2">allowed number of groups</a>.</p></li><li><p>Set <var>manager</var>'s <a href="#close-watcher-manager-next" id="close-watcher-infrastructure:close-watcher-manager-next-3">next user interaction
   allows a new group</a> to false.</p></li></ol>
  </div>

  <hr>

  <p>A <dfn id="close-watcher" data-export="">close watcher</dfn> is a <a id="close-watcher-infrastructure:struct-2" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="close-watcher-infrastructure:struct-item-2" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p>A <dfn id="close-watcher-window">window</dfn>, a <code id="close-watcher-infrastructure:window-3"><a href="#window">Window</a></code>.</p></li><li><p>A <dfn id="close-watcher-cancel-action">cancel action</dfn>, an algorithm accepting a
   boolean argument and returning a boolean. The argument indicates whether or not the cancel
   action algorithm can prevent the close request from proceeding via the algorithm's return value.
   If the boolean argument is true, then the algorithm can return either true to indicate that the
   caller will proceed to the <a href="#close-watcher-close-action" id="close-watcher-infrastructure:close-watcher-close-action">close action</a>, or
   false to indicate that the caller will bail out. If the argument is false, then the return value
   is always false. This algorithm can never throw an exception.</p></li><li><p>A <dfn id="close-watcher-close-action">close action</dfn>, an algorithm accepting no
   arguments and returning nothing. This algorithm can never throw an exception.</p></li><li><p>An <dfn id="close-watcher-is-running-cancel">is running cancel action</dfn>
   boolean.</p></li><li><p>A <dfn id="close-watcher-get-enabled-state">get enabled state</dfn>, an algorithm
   accepting no arguments and returning a boolean. This algorithm can never throw an
   exception.</p></li></ul>

  <div data-algorithm="">
  <p>A <a href="#close-watcher" id="close-watcher-infrastructure:close-watcher-4">close watcher</a> <var>closeWatcher</var> <dfn id="close-watcher-active">is
  active</dfn> if <var>closeWatcher</var>'s <a href="#close-watcher-window" id="close-watcher-infrastructure:close-watcher-window">window</a>'s
  <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager-3">close watcher manager</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="close-watcher-infrastructure:list-contains" data-x-internal="list-contains">contains</a> any list which
  <a href="https://infra.spec.whatwg.org/#list-contain" id="close-watcher-infrastructure:list-contains-2" data-x-internal="list-contains">contains</a> <var>closeWatcher</var>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="establish-a-close-watcher">establish a close watcher</dfn> given a <code id="close-watcher-infrastructure:window-4"><a href="#window">Window</a></code> <var>window</var>, a list
  of steps <dfn id="create-close-watcher-cancelaction"><var>cancelAction</var></dfn>, a
  list of steps <dfn id="create-close-watcher-closeaction"><var>closeAction</var></dfn>,
  and an algorithm that returns a boolean <dfn id="create-close-watcher-getenabledstate"><var>getEnabledState</var></dfn>:</p>

  <ol><li><p><a id="close-watcher-infrastructure:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>window</var>'s <a href="#concept-document-window" id="close-watcher-infrastructure:concept-document-window">associated <code>Document</code></a> is <a href="#fully-active" id="close-watcher-infrastructure:fully-active">fully
   active</a>.</p></li><li>
    <p>Let <var>closeWatcher</var> be a new <a href="#close-watcher" id="close-watcher-infrastructure:close-watcher-5">close watcher</a>, with</p>

    <dl class="props"><dt><a href="#close-watcher-window" id="close-watcher-infrastructure:close-watcher-window-2">window</a></dt><dd><var>window</var></dd><dt><a href="#close-watcher-cancel-action" id="close-watcher-infrastructure:close-watcher-cancel-action">cancel action</a></dt><dd><var>cancelAction</var></dd><dt><a href="#close-watcher-close-action" id="close-watcher-infrastructure:close-watcher-close-action-2">close action</a></dt><dd><var>closeAction</var></dd><dt><a href="#close-watcher-is-running-cancel" id="close-watcher-infrastructure:close-watcher-is-running-cancel">is running cancel action</a></dt><dd>false</dd><dt><a href="#close-watcher-get-enabled-state" id="close-watcher-infrastructure:close-watcher-get-enabled-state">get enabled state</a></dt><dd><var>getEnabledState</var></dd></dl>
   </li><li><p>Let <var>manager</var> be <var>window</var>'s <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager-4">close watcher manager</a>.</p></li><li><p>If <var>manager</var>'s <a href="#close-watcher-manager-groups" id="close-watcher-infrastructure:close-watcher-manager-groups">groups</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="close-watcher-infrastructure:list-size" data-x-internal="list-size">size</a> is less than <var>manager</var>'s <a href="#close-watcher-manager-allowed-number-of-groups" id="close-watcher-infrastructure:close-watcher-manager-allowed-number-of-groups-3">allowed number of groups</a>, then <a href="https://infra.spec.whatwg.org/#list-append" id="close-watcher-infrastructure:list-append" data-x-internal="list-append">append</a> « <var>closeWatcher</var> » to <var>manager</var>'s <a href="#close-watcher-manager-groups" id="close-watcher-infrastructure:close-watcher-manager-groups-2">groups</a>.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p><a id="close-watcher-infrastructure:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>manager</var>'s <a href="#close-watcher-manager-groups" id="close-watcher-infrastructure:close-watcher-manager-groups-3">groups</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="close-watcher-infrastructure:list-size-2" data-x-internal="list-size">size</a> is at least 1 in this branch,
     since <var>manager</var>'s <a href="#close-watcher-manager-allowed-number-of-groups" id="close-watcher-infrastructure:close-watcher-manager-allowed-number-of-groups-4">allowed number of groups</a> is always at least 1.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="close-watcher-infrastructure:list-append-2" data-x-internal="list-append">Append</a> <var>closeWatcher</var> to
     <var>manager</var>'s <a href="#close-watcher-manager-groups" id="close-watcher-infrastructure:close-watcher-manager-groups-4">groups</a>'s last <a href="https://infra.spec.whatwg.org/#list-item" id="close-watcher-infrastructure:list-item" data-x-internal="list-item">item</a>.</p></li></ol>
   </li><li><p>Set <var>manager</var>'s <a href="#close-watcher-manager-next" id="close-watcher-infrastructure:close-watcher-manager-next-4">next user interaction
   allows a new group</a> to true.</p></li><li><p>Return <var>closeWatcher</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="close-watcher-request-close">request to close</dfn> a <a href="#close-watcher" id="close-watcher-infrastructure:close-watcher-6">close
  watcher</a> <var>closeWatcher</var> with boolean <var>requireHistoryActionActivation</var>:</p>

  <ol><li><p>If <var>closeWatcher</var> <a href="#close-watcher-active" id="close-watcher-infrastructure:close-watcher-active">is not active</a>, then
   return true.</p></li><li><p>If the result of running <var>closeWatcher</var>'s <a href="#close-watcher-get-enabled-state" id="close-watcher-infrastructure:close-watcher-get-enabled-state-2">get enabled state</a> is false, then return
   true.</p></li><li><p>If <var>closeWatcher</var>'s <a href="#close-watcher-is-running-cancel" id="close-watcher-infrastructure:close-watcher-is-running-cancel-2">is running
   cancel action</a> is true, then return true.</p></li><li><p>Let <var>window</var> be <var>closeWatcher</var>'s <a href="#close-watcher-window" id="close-watcher-infrastructure:close-watcher-window-3">window</a>.</p></li><li><p>If <var>window</var>'s <a href="#concept-document-window" id="close-watcher-infrastructure:concept-document-window-2">associated
   <code>Document</code></a> is not <a href="#fully-active" id="close-watcher-infrastructure:fully-active-2">fully active</a>, then return true.</p></li><li><p>Let <var>canPreventClose</var> be true if <var>requireHistoryActionActivation</var> is
   false, or if <var>window</var>'s <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager-5">close watcher manager</a>'s <a href="#close-watcher-manager-groups" id="close-watcher-infrastructure:close-watcher-manager-groups-5">groups</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="close-watcher-infrastructure:list-size-3" data-x-internal="list-size">size</a> is
   less than <var>window</var>'s <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager-6">close watcher manager</a>'s <a href="#close-watcher-manager-allowed-number-of-groups" id="close-watcher-infrastructure:close-watcher-manager-allowed-number-of-groups-5">allowed number of groups</a>, and
   <var>window</var> has <a href="#history-action-activation" id="close-watcher-infrastructure:history-action-activation-2">history-action activation</a>; otherwise false.</p></li><li><p>Set <var>closeWatcher</var>'s <a href="#close-watcher-is-running-cancel" id="close-watcher-infrastructure:close-watcher-is-running-cancel-3">is running
   cancel action</a> to true.</p></li><li><p>Let <var>shouldContinue</var> be the result of running <var>closeWatcher</var>'s <a href="#close-watcher-cancel-action" id="close-watcher-infrastructure:close-watcher-cancel-action-2">cancel action</a> given
   <var>canPreventClose</var>.</p></li><li><p>Set <var>closeWatcher</var>'s <a href="#close-watcher-is-running-cancel" id="close-watcher-infrastructure:close-watcher-is-running-cancel-4">is running
   cancel action</a> to false.</p></li><li>
    <p>If <var>shouldContinue</var> is false, then:</p>

    <ol><li><p><a id="close-watcher-infrastructure:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>canPreventClose</var> is true.</p></li><li><p><a href="#consume-history-action-user-activation" id="close-watcher-infrastructure:consume-history-action-user-activation">Consume history-action user activation</a> given <var>window</var>.</p></li><li><p>Return false.</p></li></ol>

    <p class="note">Note that since these substeps <a href="#consume-history-action-user-activation" id="close-watcher-infrastructure:consume-history-action-user-activation-2">consume history-action user
    activation</a>, <a href="#close-watcher-request-close" id="close-watcher-infrastructure:close-watcher-request-close">requesting to close</a> a
    <a href="#close-watcher" id="close-watcher-infrastructure:close-watcher-7">close watcher</a> twice without any intervening <a href="#tracking-user-activation" id="close-watcher-infrastructure:tracking-user-activation-4">user activation</a> will
    result in <var>canPreventClose</var> being false the second time.</p>
   </li><li><p><a href="#close-watcher-close" id="close-watcher-infrastructure:close-watcher-close">Close</a> <var>closeWatcher</var>.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="close-watcher-close">close</dfn> a <a href="#close-watcher" id="close-watcher-infrastructure:close-watcher-8">close watcher</a>
  <var>closeWatcher</var>:</p>

  <ol><li><p>If <var>closeWatcher</var> <a href="#close-watcher-active" id="close-watcher-infrastructure:close-watcher-active-2">is not active</a>, then
   return.</p></li><li><p>If the result of running <var>closeWatcher</var>'s <a href="#close-watcher-get-enabled-state" id="close-watcher-infrastructure:close-watcher-get-enabled-state-3">get enabled state</a> is false, then return.</p></li><li><p>If <var>closeWatcher</var>'s <a href="#close-watcher-window" id="close-watcher-infrastructure:close-watcher-window-4">window</a>'s <a href="#concept-document-window" id="close-watcher-infrastructure:concept-document-window-3">associated <code>Document</code></a> is not <a href="#fully-active" id="close-watcher-infrastructure:fully-active-3">fully
   active</a>, then return.</p></li><li><p><a href="#close-watcher-destroy" id="close-watcher-infrastructure:close-watcher-destroy">Destroy</a> <var>closeWatcher</var>.</p></li><li><p>Run <var>closeWatcher</var>'s <a href="#close-watcher-close-action" id="close-watcher-infrastructure:close-watcher-close-action-3">close
   action</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="close-watcher-destroy">destroy</dfn> a <a href="#close-watcher" id="close-watcher-infrastructure:close-watcher-9">close watcher</a>
  <var>closeWatcher</var>:</p>

  <ol><li><p>Let <var>manager</var> be <var>closeWatcher</var>'s <a href="#close-watcher-window" id="close-watcher-infrastructure:close-watcher-window-5">window</a>'s <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager-7">close watcher manager</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="close-watcher-infrastructure:list-iterate" data-x-internal="list-iterate">For each</a> <var>group</var> of <var>manager</var>'s
   <a href="#close-watcher-manager-groups" id="close-watcher-infrastructure:close-watcher-manager-groups-6">groups</a>: <a href="https://infra.spec.whatwg.org/#list-remove" id="close-watcher-infrastructure:list-remove" data-x-internal="list-remove">remove</a> <var>closeWatcher</var> from <var>group</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="close-watcher-infrastructure:list-remove-2" data-x-internal="list-remove">Remove</a> any item from <var>manager</var>'s <a href="#close-watcher-manager-groups" id="close-watcher-infrastructure:close-watcher-manager-groups-7">groups</a> that <a href="https://infra.spec.whatwg.org/#list-is-empty" id="close-watcher-infrastructure:list-is-empty" data-x-internal="list-is-empty">is
   empty</a>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="process-close-watchers">process close watchers</dfn> given a <code id="close-watcher-infrastructure:window-5"><a href="#window">Window</a></code> <var>window</var>:</p>

  <ol><li><p>Let <var>processedACloseWatcher</var> be false.</p></li><li>
    <p>If <var>window</var>'s <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager-8">close watcher manager</a>'s <a href="#close-watcher-manager-groups" id="close-watcher-infrastructure:close-watcher-manager-groups-8">groups</a> is not empty:</p>

    <ol><li><p>Let <var>group</var> be the last <a href="https://infra.spec.whatwg.org/#list-item" id="close-watcher-infrastructure:list-item-2" data-x-internal="list-item">item</a> in
     <var>window</var>'s <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager-9">close watcher manager</a>'s <a href="#close-watcher-manager-groups" id="close-watcher-infrastructure:close-watcher-manager-groups-9">groups</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="close-watcher-infrastructure:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>closeWatcher</var> of <var>group</var>,
      in reverse order:</p>

      <ol><li><p>If the result of running <var>closeWatcher</var>'s <a href="#close-watcher-get-enabled-state" id="close-watcher-infrastructure:close-watcher-get-enabled-state-4">get enabled state</a> is true, set
       <var>processedACloseWatcher</var> to true.</p></li><li><p>Let <var>shouldProceed</var> be the result of <a href="#close-watcher-request-close" id="close-watcher-infrastructure:close-watcher-request-close-2">requesting to close</a>
       <var>closeWatcher</var> with true.</p></li><li><p>If <var>shouldProceed</var> is false, then <a id="close-watcher-infrastructure:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li></ol>
     </li></ol>
   </li><li><p>If <var>window</var>'s <a href="#close-watcher-manager" id="close-watcher-infrastructure:close-watcher-manager-10">close watcher manager</a>'s <a href="#close-watcher-manager-allowed-number-of-groups" id="close-watcher-infrastructure:close-watcher-manager-allowed-number-of-groups-6">allowed number of groups</a> is greater than 1, decrement
   it by 1.</p></li><li><p>Return <var>processedACloseWatcher</var>.</p></li></ol>
  </div>

  


  <h4 id="the-closewatcher-interface"><span class="secno">6.10.3</span> The <code id="the-closewatcher-interface:closewatcher"><a href="#closewatcher">CloseWatcher</a></code> interface<a href="#the-closewatcher-interface" class="self-link"></a></h4>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="closewatcher" data-dfn-type="interface"><c- g="">CloseWatcher</c-></dfn> : <a id="the-closewatcher-interface:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <a href="#dom-closewatcher" id="the-closewatcher-interface:dom-closewatcher"><c- g="">constructor</c-></a>(<c- b="">optional</c-> <a href="#closewatcheroptions" id="the-closewatcher-interface:closewatcheroptions"><c- n="">CloseWatcherOptions</c-></a> <c- g="">options</c-> = {});

  <c- b="">undefined</c-> <a href="#dom-closewatcher-requestclose" id="the-closewatcher-interface:dom-closewatcher-requestclose"><c- g="">requestClose</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-closewatcher-close" id="the-closewatcher-interface:dom-closewatcher-close"><c- g="">close</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-closewatcher-destroy" id="the-closewatcher-interface:dom-closewatcher-destroy"><c- g="">destroy</c-></a>();

  <c- b="">attribute</c-> <a href="#eventhandler" id="the-closewatcher-interface:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-closewatcher-oncancel" id="the-closewatcher-interface:handler-closewatcher-oncancel"><c- g="">oncancel</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-closewatcher-interface:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-closewatcher-onclose" id="the-closewatcher-interface:handler-closewatcher-onclose"><c- g="">onclose</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="closewatcheroptions" data-dfn-type="dictionary"><c- g="">CloseWatcherOptions</c-></dfn> {
  <a id="the-closewatcher-interface:abortsignal" href="https://dom.spec.whatwg.org/#abortsignal" data-x-internal="abortsignal"><c- n="">AbortSignal</c-></a> <dfn data-dfn-for="CloseWatcherOptions" id="dom-closewatcheroptions-signal" data-dfn-type="dict-member"><c- g="">signal</c-></dfn>;
};</code></pre>

  <dl class="domintro"><dt><code><var>watcher</var> = new <a href="#dom-closewatcher" id="dom-closewatcher-dev">CloseWatcher</a>()</code></dt><dt><code><var>watcher</var> = new <a href="#dom-closewatcher" id="the-closewatcher-interface:dom-closewatcher-2">CloseWatcher</a>({ <a href="#dom-closewatcheroptions-signal" id="dom-closewatcheroptions-signal-dev">signal</a> })</code></dt><dd>
    <p>Creates a new <code id="the-closewatcher-interface:closewatcher-2"><a href="#closewatcher">CloseWatcher</a></code> instance.</p>

    <p>If the <code id="the-closewatcher-interface:dom-closewatcheroptions-signal"><a href="#dom-closewatcheroptions-signal">signal</a></code> option is provided, then
    <var>watcher</var> can be destroyed (as if by <code id="the-closewatcher-interface:dom-closewatcher-destroy-2"><a href="#dom-closewatcher-destroy">watcher.destroy()</a></code>) by aborting the given
    <code id="the-closewatcher-interface:abortsignal-2"><a data-x-internal="abortsignal" href="https://dom.spec.whatwg.org/#abortsignal">AbortSignal</a></code>.</p>

    <p>If any <a href="#close-watcher" id="the-closewatcher-interface:close-watcher">close watcher</a> is already active, and the <code id="the-closewatcher-interface:window"><a href="#window">Window</a></code> does not
    have <a href="#history-action-activation" id="the-closewatcher-interface:history-action-activation">history-action activation</a>, then the resulting <code id="the-closewatcher-interface:closewatcher-3"><a href="#closewatcher">CloseWatcher</a></code> will
    be closed together with that already-active <a href="#close-watcher" id="the-closewatcher-interface:close-watcher-2">close watcher</a> in response to any
    <a href="#close-request" id="the-closewatcher-interface:close-request">close request</a>. (This already-active <a href="#close-watcher" id="the-closewatcher-interface:close-watcher-3">close watcher</a> does not
    necessarily have to be a <code id="the-closewatcher-interface:closewatcher-4"><a href="#closewatcher">CloseWatcher</a></code> object; it could be a modal
    <code id="the-closewatcher-interface:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> element, or a popover generated by an element with the <code id="the-closewatcher-interface:attr-popover"><a href="#attr-popover">popover</a></code> attribute.)</p>
   </dd><dt><code><var>watcher</var>.<a href="#dom-closewatcher-requestclose" id="dom-closewatcher-requestclose-dev">requestClose</a>()</code></dt><dd>
    <p>Acts as if a <a href="#close-request" id="the-closewatcher-interface:close-request-2">close request</a> was sent targeting <var>watcher</var>, by first
    firing a <code id="the-closewatcher-interface:event-cancel"><a href="#event-cancel">cancel</a></code> event, and if that event is not canceled
    with <code id="the-closewatcher-interface:dom-event-preventdefault"><a data-x-internal="dom-event-preventdefault" href="https://dom.spec.whatwg.org/#dom-event-preventdefault">preventDefault()</a></code>, proceeding to fire a
    <code id="the-closewatcher-interface:event-close"><a href="#event-close">close</a></code> event before deactivating the close watcher as if <code id="the-closewatcher-interface:dom-closewatcher-destroy-3"><a href="#dom-closewatcher-destroy">watcher.destroy()</a></code> was called.</p>

    <p>This is a helper utility that can be used to consolidate cancelation and closing logic into
    the <code id="the-closewatcher-interface:event-cancel-2"><a href="#event-cancel">cancel</a></code> and <code id="the-closewatcher-interface:event-close-2"><a href="#event-close">close</a></code> event
    handlers, by having all non-<a href="#close-request" id="the-closewatcher-interface:close-request-3">close request</a> closing affordances call this method.</p>
   </dd><dt><code><var>watcher</var>.<a href="#dom-closewatcher-close" id="dom-closewatcher-close-dev">close</a>()</code></dt><dd>
    <p>Immediately fires the <code id="the-closewatcher-interface:event-close-3"><a href="#event-close">close</a></code> event, and then deactivates
    the close watcher as if <code id="the-closewatcher-interface:dom-closewatcher-destroy-4"><a href="#dom-closewatcher-destroy">watcher.destroy()</a></code> was
    called.</p>

    <p>This is a helper utility that can be used trigger the closing logic into the <code id="the-closewatcher-interface:event-close-4"><a href="#event-close">close</a></code> event handler, skipping any logic in the <code id="the-closewatcher-interface:event-cancel-3"><a href="#event-cancel">cancel</a></code> event handler.</p>
   </dd><dt><code><var>watcher</var>.<a href="#dom-closewatcher-destroy" id="dom-closewatcher-destroy-dev">destroy</a>()</code></dt><dd>
    <p>Deactivates <var>watcher</var>, so that it will no longer receive <code id="the-closewatcher-interface:event-close-5"><a href="#event-close">close</a></code> events and so that new independent <code id="the-closewatcher-interface:closewatcher-5"><a href="#closewatcher">CloseWatcher</a></code>
    instances can be constructed.</p>

    <p>This is intended to be called if the relevant UI element is torn down in some other way than
    being closed.</p>
   </dd></dl>

  

  <p>Each <code id="the-closewatcher-interface:closewatcher-6"><a href="#closewatcher">CloseWatcher</a></code> instance has an <dfn id="internal-close-watcher">internal close watcher</dfn>, which is a
  <a href="#close-watcher" id="the-closewatcher-interface:close-watcher-4">close watcher</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="dom-closewatcher"><code>new CloseWatcher(<var>options</var>)</code></dfn>
  constructor steps are:</p>

  <ol><li><p>If <a id="the-closewatcher-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-closewatcher-interface:concept-relevant-global">relevant global object</a>'s <a href="#concept-document-window" id="the-closewatcher-interface:concept-document-window">associated <code>Document</code></a> is not <a href="#fully-active" id="the-closewatcher-interface:fully-active">fully
   active</a>, then throw an <a id="the-closewatcher-interface:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="the-closewatcher-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p>Let <var>closeWatcher</var> be the result of <a href="#establish-a-close-watcher" id="the-closewatcher-interface:establish-a-close-watcher">establishing a close watcher</a> given <a id="the-closewatcher-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-closewatcher-interface:concept-relevant-global-2">relevant global
    object</a>, with:</p>

    <ul><li><p><i id="the-closewatcher-interface:create-close-watcher-cancelaction"><a href="#create-close-watcher-cancelaction">cancelAction</a></i> given
     <var>canPreventClose</var> being to return the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-closewatcher-interface:concept-event-fire" data-x-internal="concept-event-fire">firing an event</a> named <code id="the-closewatcher-interface:event-cancel-4"><a href="#event-cancel">cancel</a></code> at <a id="the-closewatcher-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, with the <code id="the-closewatcher-interface:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to
     <var>canPreventClose</var>.</p></li><li><p><i id="the-closewatcher-interface:create-close-watcher-closeaction"><a href="#create-close-watcher-closeaction">closeAction</a></i> being to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-closewatcher-interface:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-closewatcher-interface:event-close-6"><a href="#event-close">close</a></code>
     at <a id="the-closewatcher-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p><i id="the-closewatcher-interface:close-watcher-get-enabled-state"><a href="#close-watcher-get-enabled-state">getEnabledState</a></i> being to return
     true.</p></li></ul>
   </li><li>
    <p>If <var>options</var>["<code id="the-closewatcher-interface:dom-closewatcheroptions-signal-2"><a href="#dom-closewatcheroptions-signal">signal</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-closewatcher-interface:map-exists" data-x-internal="map-exists">exists</a>, then:</p>

    <ol><li><p>If <var>options</var>["<code id="the-closewatcher-interface:dom-closewatcheroptions-signal-3"><a href="#dom-closewatcheroptions-signal">signal</a></code>"] is
     <a href="https://dom.spec.whatwg.org/#abortsignal-aborted" id="the-closewatcher-interface:abortsignal-aborted" data-x-internal="abortsignal-aborted">aborted</a>, then <a href="#close-watcher-destroy" id="the-closewatcher-interface:close-watcher-destroy">destroy</a> <var>closeWatcher</var>.</p></li><li>
      <p><a href="https://dom.spec.whatwg.org/#abortsignal-add" id="the-closewatcher-interface:abortsignal-add" data-x-internal="abortsignal-add">Add</a> the following steps to <var>options</var>["<code id="the-closewatcher-interface:dom-closewatcheroptions-signal-4"><a href="#dom-closewatcheroptions-signal">signal</a></code>"]:</p>

      <ol><li><p><a href="#close-watcher-destroy" id="the-closewatcher-interface:close-watcher-destroy-2">Destroy</a> <var>closeWatcher</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Set <a id="the-closewatcher-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#internal-close-watcher" id="the-closewatcher-interface:internal-close-watcher">internal close watcher</a> to
   <var>closeWatcher</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CloseWatcher" id="dom-closewatcher-requestclose" data-dfn-type="method"><code>requestClose()</code></dfn> method steps are to <a href="#close-watcher-request-close" id="the-closewatcher-interface:close-watcher-request-close">request to close</a> <a id="the-closewatcher-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#internal-close-watcher" id="the-closewatcher-interface:internal-close-watcher-2">internal
  close watcher</a> with false.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CloseWatcher" id="dom-closewatcher-close" data-dfn-type="method"><code>close()</code></dfn>
  method steps are to <a href="#close-watcher-close" id="the-closewatcher-interface:close-watcher-close">close</a> <a id="the-closewatcher-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#internal-close-watcher" id="the-closewatcher-interface:internal-close-watcher-3">internal close watcher</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="CloseWatcher" id="dom-closewatcher-destroy" data-dfn-type="method"><code>destroy()</code></dfn> method steps are to <a href="#close-watcher-destroy" id="the-closewatcher-interface:close-watcher-destroy-3">destroy</a> <a id="the-closewatcher-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#internal-close-watcher" id="the-closewatcher-interface:internal-close-watcher-4">internal close
  watcher</a>.</p>
  </div>

  

  <p>The following are the <a href="#event-handlers" id="the-closewatcher-interface:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="the-closewatcher-interface:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="the-closewatcher-interface:event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the
  <code id="the-closewatcher-interface:closewatcher-7"><a href="#closewatcher">CloseWatcher</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="the-closewatcher-interface:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="the-closewatcher-interface:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="CloseWatcher" id="handler-closewatcher-oncancel" data-dfn-type="attribute"><code>oncancel</code></dfn> </td><td> <code id="the-closewatcher-interface:event-cancel-5"><a href="#event-cancel">cancel</a></code>
    </td></tr><tr><td><dfn data-dfn-for="CloseWatcher" id="handler-closewatcher-onclose" data-dfn-type="attribute"><code>onclose</code></dfn> </td><td> <code id="the-closewatcher-interface:event-close-7"><a href="#event-close">close</a></code>
  </td></tr></tbody></table>

  <div id="example-CloseWatcher-basic" class="example"><a href="#example-CloseWatcher-basic" class="self-link"></a>
   <p>If one wanted to implement a custom picker control, which closed itself on a user-provided
   <a href="#close-request" id="the-closewatcher-interface:close-request-4">close request</a> as well as when a close button is pressed, the following code shows how
   one would use the <code id="the-closewatcher-interface:closewatcher-8"><a href="#closewatcher">CloseWatcher</a></code> API to process close requests:</p>

   <pre><code class="js"><c- a="">const</c-> watcher <c- o="">=</c-> <c- k="">new</c-> CloseWatcher<c- p="">();</c->
<c- a="">const</c-> picker <c- o="">=</c-> setUpAndShowPickerDOMElement<c- p="">();</c->

<c- a="">let</c-> chosenValue <c- o="">=</c-> <c- kc="">null</c-><c- p="">;</c->

watcher<c- p="">.</c->onclose <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
  chosenValue <c- o="">=</c-> picker<c- p="">.</c->querySelector<c- p="">(</c-><c- t="">'input'</c-><c- p="">).</c->value<c- p="">;</c->
  picker<c- p="">.</c->remove<c- p="">();</c->
<c- p="">};</c->

picker<c- p="">.</c->querySelector<c- p="">(</c-><c- t="">'.close-button'</c-><c- p="">).</c->onclick <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> watcher<c- p="">.</c->requestClose<c- p="">();</c-></code></pre>

   <p>Note how the logic to gather the chosen value is centralized in the <code id="the-closewatcher-interface:closewatcher-9"><a href="#closewatcher">CloseWatcher</a></code>
   object's <code id="the-closewatcher-interface:event-close-8"><a href="#event-close">close</a></code> event handler, with the <code id="the-closewatcher-interface:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event handler for the close button delegating to that logic by
   calling <code id="the-closewatcher-interface:dom-closewatcher-requestclose-2"><a href="#dom-closewatcher-requestclose">requestClose()</a></code>.</p>
  </div>

  <div id="example-CloseWatcher-cancel" class="example"><a href="#example-CloseWatcher-cancel" class="self-link"></a>
   <p>The <code id="the-closewatcher-interface:event-cancel-6"><a href="#event-cancel">cancel</a></code> event on <code id="the-closewatcher-interface:closewatcher-10"><a href="#closewatcher">CloseWatcher</a></code> objects can
   be used to prevent the <code id="the-closewatcher-interface:event-close-9"><a href="#event-close">close</a></code> event from firing, and the
   <code id="the-closewatcher-interface:closewatcher-11"><a href="#closewatcher">CloseWatcher</a></code> from being destroying. A typical use case is as follows:</p>

   <pre><code class="js">watcher<c- p="">.</c->oncancel <c- o="">=</c-> <c- k="">async</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->hasUnsavedData <c- o="">&amp;&amp;</c-> e<c- p="">.</c->cancelable<c- p="">)</c-> <c- p="">{</c->
    e<c- p="">.</c->preventDefault<c- p="">();</c->

    <c- a="">const</c-> userReallyWantsToClose <c- o="">=</c-> <c- k="">await</c-> askForConfirmation<c- p="">(</c-><c- u="">"Are you sure you want to close?"</c-><c- p="">);</c->
    <c- k="">if</c-> <c- p="">(</c->userReallyWantsToClose<c- p="">)</c-> <c- p="">{</c->
      hasUnsavedData <c- o="">=</c-> <c- kc="">false</c-><c- p="">;</c->
      watcher<c- p="">.</c->close<c- p="">();</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">};</c-></code></pre>

   <p>For abuse prevention purposes, this event is only <code id="the-closewatcher-interface:dom-event-cancelable-2"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> if the page has <a href="#history-action-activation" id="the-closewatcher-interface:history-action-activation-2">history-action
   activation</a>, which will be lost after any given <a href="#close-request" id="the-closewatcher-interface:close-request-5">close request</a>. 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 any <code id="the-closewatcher-interface:event-cancel-7"><a href="#event-cancel">cancel</a></code> event handler's attempt to call <code id="the-closewatcher-interface:dom-event-preventdefault-2"><a data-x-internal="dom-event-preventdefault" href="https://dom.spec.whatwg.org/#dom-event-preventdefault">preventDefault()</a></code> and proceeds to close the
   <code id="the-closewatcher-interface:closewatcher-12"><a href="#closewatcher">CloseWatcher</a></code>.</p>
  </div>

  <p>Combined, the above two examples show how <code id="the-closewatcher-interface:dom-closewatcher-requestclose-3"><a href="#dom-closewatcher-requestclose">requestClose()</a></code> and <code id="the-closewatcher-interface:dom-closewatcher-close-2"><a href="#dom-closewatcher-close">close()</a></code> differ. Because we used <code id="the-closewatcher-interface:dom-closewatcher-requestclose-4"><a href="#dom-closewatcher-requestclose">requestClose()</a></code> in the <code id="the-closewatcher-interface:event-click-2"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event handler for the close button, clicking that button will
  trigger the <code id="the-closewatcher-interface:closewatcher-13"><a href="#closewatcher">CloseWatcher</a></code>'s <code id="the-closewatcher-interface:event-cancel-8"><a href="#event-cancel">cancel</a></code> event, and thus
  potentially ask the user for confirmation if there is unsaved data. If we had used <code id="the-closewatcher-interface:dom-closewatcher-close-3"><a href="#dom-closewatcher-close">close()</a></code>, then this check would be skipped. Sometimes that
  is appropriate, but usually <code id="the-closewatcher-interface:dom-closewatcher-requestclose-5"><a href="#dom-closewatcher-requestclose">requestClose()</a></code> is
  the better option for user-triggered close requests.</p>

  <div id="example-CloseWatcher-grouping" class="example"><a href="#example-CloseWatcher-grouping" class="self-link"></a>
   <p>In addition to the <a href="#tracking-user-activation" id="the-closewatcher-interface:tracking-user-activation">user activation</a> restrictions for <code id="the-closewatcher-interface:event-cancel-9"><a href="#event-cancel">cancel</a></code> events, there is a more subtle form of user activation gating
   for <code id="the-closewatcher-interface:closewatcher-14"><a href="#closewatcher">CloseWatcher</a></code> construction. If one creates more than one
   <code id="the-closewatcher-interface:closewatcher-15"><a href="#closewatcher">CloseWatcher</a></code> without user activation, then the newly-created one will get grouped
   together with the most-recently-created <a href="#close-watcher" id="the-closewatcher-interface:close-watcher-5">close watcher</a>, so that a single <a href="#close-request" id="the-closewatcher-interface:close-request-6">close
   request</a> will close them both:</p>

   <pre><code class="js">window<c- p="">.</c->onload <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
  <c- c1="">// This will work as normal: it is the first close watcher created without user activation.</c->
  <c- p="">(</c-><c- k="">new</c-> CloseWatcher<c- p="">()).</c->onclose <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c-> <c- d="">/* ... */</c-> <c- p="">};</c->
<c- p="">};</c->

button1<c- p="">.</c->onclick <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
  <c- c1="">// This will work as normal: the button click counts as user activation.</c->
  <c- p="">(</c-><c- k="">new</c-> CloseWatcher<c- p="">()).</c->onclose <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c-> <c- d="">/* ... */</c-> <c- p="">};</c->
<c- p="">};</c->

button2<c- p="">.</c->onclick <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
  <c- c1="">// These will be grouped together, and both will close in response to a single close request.</c->
  <c- p="">(</c-><c- k="">new</c-> CloseWatcher<c- p="">()).</c->onclose <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c-> <c- d="">/* ... */</c-> <c- p="">};</c->
  <c- p="">(</c-><c- k="">new</c-> CloseWatcher<c- p="">()).</c->onclose <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c-> <c- d="">/* ... */</c-> <c- p="">};</c->
<c- p="">};</c-></code></pre>

   <p>This means that calling <code id="the-closewatcher-interface:dom-closewatcher-destroy-5"><a href="#dom-closewatcher-destroy">destroy()</a></code>, <code id="the-closewatcher-interface:dom-closewatcher-close-4"><a href="#dom-closewatcher-close">close()</a></code>, or <code id="the-closewatcher-interface:dom-closewatcher-requestclose-6"><a href="#dom-closewatcher-requestclose">requestClose()</a></code> 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.</p>
  </div>


  <h3 id="dnd"><span class="secno">6.11</span> <dfn>Drag and drop</dfn><a href="#dnd" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API" title="HTML Drag and Drop interfaces enable applications to use drag-and-drop features in browsers.">HTML_Drag_and_Drop_API</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>2+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.5+</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div>



  <p>This section defines an event-based drag-and-drop mechanism.</p>

  <p>This specification does not define exactly what a <em>drag-and-drop operation</em> actually
  is.</p>

  <p>On a visual medium with a pointing device, a drag operation could be the default action of a
  <code id="dnd:event-mousedown"><a data-x-internal="event-mousedown" href="https://w3c.github.io/uievents/#event-type-mousedown">mousedown</a></code> event that is followed by a series of <code id="dnd:event-mousemove"><a data-x-internal="event-mousemove" href="https://w3c.github.io/uievents/#event-type-mousemove">mousemove</a></code> events, and the drop could be triggered by the mouse
  being released.</p>

  <p>When using an input modality other than a pointing device, users would probably have to
  explicitly indicate their intention to perform a drag-and-drop operation, stating what they wish
  to drag and where they wish to drop it, respectively.</p>

  

  <p>However it is implemented, drag-and-drop operations must have a starting point (e.g. where the
  mouse was clicked, or the start of the selection or element that was selected for the drag), may
  have any number of intermediate steps (elements that the mouse moves over during a drag, or
  elements that the user picks as possible drop points as they cycle through possibilities), and must
  either have an end point (the element above which the mouse button was released, or the element
  that was finally selected), or be canceled. The end point must be the last element selected as a
  possible drop point before the drop occurs (so if the operation is not canceled, there must be at
  least one element in the middle step).</p>

  


  <h4 id="event-drag"><span class="secno">6.11.1</span> Introduction<a href="#event-drag" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>To make an element draggable, give the element a <code id="event-drag:attr-draggable"><a href="#attr-draggable">draggable</a></code>
  attribute, and set an event listener for <code id="event-drag:event-dnd-dragstart"><a href="#event-dnd-dragstart">dragstart</a></code> that
  stores the data being dragged.</p>

  <p>The event handler typically needs to check that it's not a text selection that is being
  dragged, and then needs to store data into the <code id="event-drag:datatransfer"><a href="#datatransfer">DataTransfer</a></code> object and set the
  allowed effects (copy, move, link, or some combination).</p>

  <p>For example:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->What fruits do you like?<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ol</c-> <c- e="">ondragstart</c-><c- o="">=</c-><c- s="">"dragStartHandler(event)"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">draggable</c-><c- o="">=</c-><c- s="">"true"</c-> <c- e="">data-value</c-><c- o="">=</c-><c- s="">"fruit-apple"</c-><c- p="">&gt;</c->Apples<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">draggable</c-><c- o="">=</c-><c- s="">"true"</c-> <c- e="">data-value</c-><c- o="">=</c-><c- s="">"fruit-orange"</c-><c- p="">&gt;</c->Oranges<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">li</c-> <c- e="">draggable</c-><c- o="">=</c-><c- s="">"true"</c-> <c- e="">data-value</c-><c- o="">=</c-><c- s="">"fruit-pear"</c-><c- p="">&gt;</c->Pears<c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> internalDNDType <c- o="">=</c-> <c- t="">'text/x-example'</c-><c- p="">;</c-> <c- c1="">// set this to something specific to your site</c->
  <c- a="">function</c-> dragStartHandler<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->target <c- k="">instanceof</c-> HTMLLIElement<c- p="">)</c-> <c- p="">{</c->
      <c- c1="">// use the element's data-value="" attribute as the value to be moving:</c->
      event<c- p="">.</c->dataTransfer<c- p="">.</c->setData<c- p="">(</c->internalDNDType<c- p="">,</c-> event<c- p="">.</c->target<c- p="">.</c->dataset<c- p="">.</c->value<c- p="">);</c->
      event<c- p="">.</c->dataTransfer<c- p="">.</c->effectAllowed <c- o="">=</c-> <c- t="">'move'</c-><c- p="">;</c-> <c- c1="">// only allow moves</c->
    <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
      event<c- p="">.</c->preventDefault<c- p="">();</c-> <c- c1="">// don't allow selection to be dragged</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  <hr>

  <p>To accept a drop, the drop target has to listen to the following events:</p>

  <ol><li>The <code id="event-drag:event-dnd-dragenter"><a href="#event-dnd-dragenter">dragenter</a></code> event handler reports
    whether or not the drop target is potentially willing to accept the drop, by canceling the
    event.</li><li>The <code id="event-drag:event-dnd-dragover"><a href="#event-dnd-dragover">dragover</a></code> event handler specifies what feedback
    will be shown to the user, by setting the <code id="event-drag:dom-datatransfer-dropeffect"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code> attribute of the
    <code id="event-drag:datatransfer-2"><a href="#datatransfer">DataTransfer</a></code> associated with the event. This event also needs to be canceled.</li><li>The <code id="event-drag:event-dnd-drop"><a href="#event-dnd-drop">drop</a></code> event handler has a final chance to accept or
    reject the drop. If the drop is accepted, the event handler must perform the drop operation on
    the target. This event needs to be canceled, so that the <code id="event-drag:dom-datatransfer-dropeffect-2"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code> attribute's value can be used by the
    source. Otherwise, the drop operation is rejected.</li></ol>

  <p>For example:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Drop your favorite fruits below:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ol</c-> <c- e="">ondragenter</c-><c- o="">=</c-><c- s="">"dragEnterHandler(event)"</c-> <c- e="">ondragover</c-><c- o="">=</c-><c- s="">"dragOverHandler(event)"</c->
    <c- e="">ondrop</c-><c- o="">=</c-><c- s="">"dropHandler(event)"</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> internalDNDType <c- o="">=</c-> <c- t="">'text/x-example'</c-><c- p="">;</c-> <c- c1="">// set this to something specific to your site</c->
  <c- a="">function</c-> dragEnterHandler<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- a="">var</c-> items <c- o="">=</c-> event<c- p="">.</c->dataTransfer<c- p="">.</c->items<c- p="">;</c->
    <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> i <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> i <c- o="">&lt;</c-> items<c- p="">.</c->length<c- p="">;</c-> <c- o="">++</c->i<c- p="">)</c-> <c- p="">{</c->
      <c- a="">var</c-> item <c- o="">=</c-> items<c- p="">[</c->i<c- p="">];</c->
      <c- k="">if</c-> <c- p="">(</c->item<c- p="">.</c->kind <c- o="">==</c-> <c- t="">'string'</c-> <c- o="">&amp;&amp;</c-> item<c- p="">.</c->type <c- o="">==</c-> internalDNDType<c- p="">)</c-> <c- p="">{</c->
        event<c- p="">.</c->preventDefault<c- p="">();</c->
        <c- k="">return</c-><c- p="">;</c->
      <c- p="">}</c->
    <c- p="">}</c->
  <c- p="">}</c->
  <c- a="">function</c-> dragOverHandler<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    event<c- p="">.</c->dataTransfer<c- p="">.</c->dropEffect <c- o="">=</c-> <c- t="">'move'</c-><c- p="">;</c->
    event<c- p="">.</c->preventDefault<c- p="">();</c->
  <c- p="">}</c->
  <c- a="">function</c-> dropHandler<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- a="">var</c-> li <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'li'</c-><c- p="">);</c->
    <c- a="">var</c-> data <c- o="">=</c-> event<c- p="">.</c->dataTransfer<c- p="">.</c->getData<c- p="">(</c->internalDNDType<c- p="">);</c->
    <c- k="">if</c-> <c- p="">(</c->data <c- o="">==</c-> <c- t="">'fruit-apple'</c-><c- p="">)</c-> <c- p="">{</c->
      li<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'Apples'</c-><c- p="">;</c->
    <c- p="">}</c-> <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c->data <c- o="">==</c-> <c- t="">'fruit-orange'</c-><c- p="">)</c-> <c- p="">{</c->
      li<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'Oranges'</c-><c- p="">;</c->
    <c- p="">}</c-> <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c->data <c- o="">==</c-> <c- t="">'fruit-pear'</c-><c- p="">)</c-> <c- p="">{</c->
      li<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'Pears'</c-><c- p="">;</c->
    <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
      li<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'Unknown Fruit'</c-><c- p="">;</c->
    <c- p="">}</c->
    event<c- p="">.</c->target<c- p="">.</c->appendChild<c- p="">(</c->li<c- p="">);</c->
  <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  <hr>

  <p>To remove the original element (the one that was dragged) from the display, the <code id="event-drag:event-dnd-dragend"><a href="#event-dnd-dragend">dragend</a></code> event can be used.</p>

  <p>For our example here, that means updating the original markup to handle that event:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->What fruits do you like?<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">ol</c-> <c- e="">ondragstart</c-><c- o="">=</c-><c- s="">"dragStartHandler(event)"</c-> <c- e="">ondragend</c-><c- o="">=</c-><c- s="">"dragEndHandler(event)"</c-><c- p="">&gt;</c->
 <em>...as before...</em>
<c- p="">&lt;/</c-><c- f="">ol</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">function</c-> dragStartHandler<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- c1="">// </c-><em><c- c1="">...as before...</c-></em>
  <c- p="">}</c->
  <c- a="">function</c-> dragEndHandler<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->dataTransfer<c- p="">.</c->dropEffect <c- o="">==</c-> <c- t="">'move'</c-><c- p="">)</c-> <c- p="">{</c->
      <c- c1="">// remove the dragged element</c->
      event<c- p="">.</c->target<c- p="">.</c->parentNode<c- p="">.</c->removeChild<c- p="">(</c->event<c- p="">.</c->target<c- p="">);</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>



  <h4 id="the-drag-data-store"><span class="secno">6.11.2</span> The drag data store<a href="#the-drag-data-store" class="self-link"></a></h4>

  <p>The data that underlies a drag-and-drop operation, known as the <dfn id="drag-data-store">drag data store</dfn>,
  consists of the following information:</p>

  <ul><li><p>A <dfn id="drag-data-store-item-list">drag data store item list</dfn>, which is a list of items representing the dragged
   data, each consisting of the following information:</p>

    <dl><dt><dfn id="the-drag-data-item-kind">The drag data item kind</dfn></dt><dd>
      <p>The kind of data:</p>

      <dl><dt><i>Text</i></dt><dd>
        <p>Text.</p>
       </dd><dt><i>File</i></dt><dd>
        <p>Binary data with a filename.</p>
       </dd></dl>
     </dd><dt><dfn id="the-drag-data-item-type-string">The drag data item type string</dfn></dt><dd>
      <p>A Unicode string giving the type or format of the data, generally given by a <a id="the-drag-data-store:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME
      type</a>. Some values that are not <a href="https://mimesniff.spec.whatwg.org/#mime-type" id="the-drag-data-store:mime-type-2" data-x-internal="mime-type">MIME types</a> are
      special-cased for legacy reasons. The API does not enforce the use of <a href="https://mimesniff.spec.whatwg.org/#mime-type" id="the-drag-data-store:mime-type-3" data-x-internal="mime-type">MIME types</a>; other values can be used as well. In all cases, however, the values
      are all <a id="the-drag-data-store:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a> by the API.</p>

      <p>There is a limit of one <i>text</i> item per <a href="#the-drag-data-item-type-string" id="the-drag-data-store:the-drag-data-item-type-string">item type string</a>.</p> 
     </dd><dt>The actual data</dt><dd><p>A Unicode or binary string, in some cases with a filename (itself a Unicode string),
      as per <a href="#the-drag-data-item-kind" id="the-drag-data-store:the-drag-data-item-kind">the drag data item kind</a>.</p></dd></dl>

    <p>The <a href="#drag-data-store-item-list" id="the-drag-data-store:drag-data-store-item-list">drag data store item list</a> is ordered in the order that the items were added
    to the list; most recently added last.</p>
   </li><li>
    <p>The following information, used to generate the UI feedback during the drag:</p>

    <ul><li>User-agent-defined default feedback information, known as the <dfn id="drag-data-store-default-feedback">drag data store default
     feedback</dfn>.</li><li>Optionally, a bitmap image and the coordinate of a point within that image, known as the
     <dfn id="drag-data-store-bitmap">drag data store bitmap</dfn> and <dfn id="drag-data-store-hot-spot-coordinate">drag data store hot spot coordinate</dfn>.</li></ul>
   </li><li>
    <p>A <dfn id="drag-data-store-mode">drag data store mode</dfn>, which is one of the following:</p>

    <dl><dt><dfn id="concept-dnd-rw">Read/write mode</dfn></dt><dd>
      <p>For the <code id="the-drag-data-store:event-dnd-dragstart"><a href="#event-dnd-dragstart">dragstart</a></code> event. New data can be added to the
      <a href="#drag-data-store" id="the-drag-data-store:drag-data-store">drag data store</a>.</p>
     </dd><dt><dfn id="concept-dnd-ro">Read-only mode</dfn></dt><dd>
      <p>For the <code id="the-drag-data-store:event-dnd-drop"><a href="#event-dnd-drop">drop</a></code> event. The list of items representing dragged
      data can be read, including the data. No new data can be added.</p>
     </dd><dt><dfn id="concept-dnd-p">Protected mode</dfn></dt><dd>
      <p>For all other events. The formats and kinds in the <a href="#drag-data-store" id="the-drag-data-store:drag-data-store-2">drag data store</a> list of
      items representing dragged data can be enumerated, but the data itself is unavailable and no
      new data can be added.</p>
     </dd></dl>
   </li><li>
    <p>A <dfn id="drag-data-store-allowed-effects-state">drag data store allowed effects state</dfn>, which is a string.</p>
   </li></ul>

  <div data-algorithm="">
  <p>When a <a href="#drag-data-store" id="the-drag-data-store:drag-data-store-3">drag data store</a> is <dfn id="create-a-drag-data-store">created</dfn>, it
  must be initialized such that its <a href="#drag-data-store-item-list" id="the-drag-data-store:drag-data-store-item-list-2">drag data store item list</a> is empty, it has no
  <a href="#drag-data-store-default-feedback" id="the-drag-data-store:drag-data-store-default-feedback">drag data store default feedback</a>, it has no <a href="#drag-data-store-bitmap" id="the-drag-data-store:drag-data-store-bitmap">drag data store bitmap</a> and
  <a href="#drag-data-store-hot-spot-coordinate" id="the-drag-data-store:drag-data-store-hot-spot-coordinate">drag data store hot spot coordinate</a>, its <a href="#drag-data-store-mode" id="the-drag-data-store:drag-data-store-mode">drag data store mode</a> is <a href="#concept-dnd-p" id="the-drag-data-store:concept-dnd-p">protected mode</a>, and its <a href="#drag-data-store-allowed-effects-state" id="the-drag-data-store:drag-data-store-allowed-effects-state">drag data store allowed effects
  state</a> is the string "<code id="the-drag-data-store:dom-datatransfer-effectallowed-uninitialized"><a href="#dom-datatransfer-effectallowed-uninitialized">uninitialized</a></code>".</p>
  </div>


  <h4 id="the-datatransfer-interface"><span class="secno">6.11.3</span> The <code id="the-datatransfer-interface:datatransfer"><a href="#datatransfer">DataTransfer</a></code> interface<a href="#the-datatransfer-interface" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer" title="The DataTransfer object is used to hold the data that is being dragged during a drag and drop operation. It may hold one or more data items, each of one or more data types. For more information about drag and drop, see HTML Drag and Drop API.">DataTransfer</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div>

  <p><code id="the-datatransfer-interface:datatransfer-2"><a href="#datatransfer">DataTransfer</a></code> objects are used to expose the <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store">drag data store</a> that
  underlies a drag-and-drop operation.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="datatransfer" data-dfn-type="interface"><c- g="">DataTransfer</c-></dfn> {
  <a href="#dom-datatransfer" id="the-datatransfer-interface:dom-datatransfer"><c- g="">constructor</c-></a>();

  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-datatransfer-dropeffect" id="the-datatransfer-interface:dom-datatransfer-dropeffect"><c- g="">dropEffect</c-></a>;
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-datatransfer-effectallowed" id="the-datatransfer-interface:dom-datatransfer-effectallowed"><c- g="">effectAllowed</c-></a>;

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#datatransferitemlist" id="the-datatransfer-interface:datatransferitemlist"><c- n="">DataTransferItemList</c-></a> <a href="#dom-datatransfer-items" id="the-datatransfer-interface:dom-datatransfer-items"><c- g="">items</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-datatransfer-setdragimage" id="the-datatransfer-interface:dom-datatransfer-setdragimage"><c- g="">setDragImage</c-></a>(<c- n="">Element</c-> <c- g="">image</c->, <c- b="">long</c-> <c- g="">x</c->, <c- b="">long</c-> <c- g="">y</c->);

  /* old interface */
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">FrozenArray</c->&lt;<c- b="">DOMString</c->&gt; <a href="#dom-datatransfer-types" id="the-datatransfer-interface:dom-datatransfer-types"><c- g="">types</c-></a>;
  <c- b="">DOMString</c-> <a href="#dom-datatransfer-getdata" id="the-datatransfer-interface:dom-datatransfer-getdata"><c- g="">getData</c-></a>(<c- b="">DOMString</c-> <c- g="">format</c->);
  <c- b="">undefined</c-> <a href="#dom-datatransfer-setdata" id="the-datatransfer-interface:dom-datatransfer-setdata"><c- g="">setData</c-></a>(<c- b="">DOMString</c-> <c- g="">format</c->, <c- b="">DOMString</c-> <c- g="">data</c->);
  <c- b="">undefined</c-> <a href="#dom-datatransfer-cleardata" id="the-datatransfer-interface:dom-datatransfer-cleardata"><c- g="">clearData</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">format</c->);
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-datatransfer-interface:filelist" href="https://w3c.github.io/FileAPI/#filelist-section" data-x-internal="filelist"><c- n="">FileList</c-></a> <a href="#dom-datatransfer-files" id="the-datatransfer-interface:dom-datatransfer-files"><c- g="">files</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>dataTransfer</var> = new <a href="#dom-datatransfer" id="dom-datatransfer-dev">DataTransfer</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/DataTransfer" title="The DataTransfer constructor creates a new DataTransfer object instance.">DataTransfer/DataTransfer</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>62+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>59+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>8.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>44+</span></span></div></div></div></dt><dd>
    <p>Creates a new <code id="the-datatransfer-interface:datatransfer-3"><a href="#datatransfer">DataTransfer</a></code> object with an empty <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-2">drag data
    store</a>.</p>
   </dd><dt><code><var>dataTransfer</var>.<a href="#dom-datatransfer-dropeffect" id="dom-datatransfer-dropeffect-dev">dropEffect</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/dropEffect" title="The DataTransfer.dropEffect property controls the feedback (typically visual) the user is given during a drag and drop operation. It will affect which cursor is displayed while dragging. For example, when the user hovers over a target drop element, the browser's cursor may indicate which type of operation will occur.">DataTransfer/dropEffect</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the kind of operation that is currently selected. If the kind of operation isn't one
    of those that is allowed by the <code id="the-datatransfer-interface:dom-datatransfer-effectallowed-2"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code> attribute, then the operation will
    fail.</p>

    <p>Can be set, to change the selected operation.</p>

    <p>The possible values are "<code id="the-datatransfer-interface:dom-datatransfer-dropeffect-none"><a href="#dom-datatransfer-dropeffect-none">none</a></code>", "<code id="the-datatransfer-interface:dom-datatransfer-dropeffect-copy"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>", "<code id="the-datatransfer-interface:dom-datatransfer-dropeffect-link"><a href="#dom-datatransfer-dropeffect-link">link</a></code>", and "<code id="the-datatransfer-interface:dom-datatransfer-dropeffect-move"><a href="#dom-datatransfer-dropeffect-move">move</a></code>".</p>
   </dd><dt><code><var>dataTransfer</var>.<a href="#dom-datatransfer-effectallowed" id="dom-datatransfer-effectallowed-dev">effectAllowed</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/effectAllowed" title="The DataTransfer.effectAllowed property specifies the effect that is allowed for a drag operation. The copy operation is used to indicate that the data being dragged will be copied from its present location to the drop location. The move operation is used to indicate that the data being dragged will be moved, and the link operation is used to indicate that some form of relationship or connection will be created between the source and drop locations.">DataTransfer/effectAllowed</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the kinds of operations that are to be allowed.</p>

    <p>Can be set (during the <code id="the-datatransfer-interface:event-dnd-dragstart"><a href="#event-dnd-dragstart">dragstart</a></code> event), to change
    the allowed operations.</p>

    <p>The possible values are "<code id="the-datatransfer-interface:dom-datatransfer-effectallowed-none"><a href="#dom-datatransfer-effectallowed-none">none</a></code>",
    "<code id="the-datatransfer-interface:dom-datatransfer-effectallowed-copy"><a href="#dom-datatransfer-effectallowed-copy">copy</a></code>", "<code id="the-datatransfer-interface:dom-datatransfer-effectallowed-copylink"><a href="#dom-datatransfer-effectallowed-copylink">copyLink</a></code>", "<code id="the-datatransfer-interface:dom-datatransfer-effectallowed-copymove"><a href="#dom-datatransfer-effectallowed-copymove">copyMove</a></code>", "<code id="the-datatransfer-interface:dom-datatransfer-effectallowed-link"><a href="#dom-datatransfer-effectallowed-link">link</a></code>", "<code id="the-datatransfer-interface:dom-datatransfer-effectallowed-linkmove"><a href="#dom-datatransfer-effectallowed-linkmove">linkMove</a></code>", "<code id="the-datatransfer-interface:dom-datatransfer-effectallowed-move"><a href="#dom-datatransfer-effectallowed-move">move</a></code>", "<code id="the-datatransfer-interface:dom-datatransfer-effectallowed-all"><a href="#dom-datatransfer-effectallowed-all">all</a></code>", and "<code id="the-datatransfer-interface:dom-datatransfer-effectallowed-uninitialized"><a href="#dom-datatransfer-effectallowed-uninitialized">uninitialized</a></code>",</p>
   </dd><dt><code><var>dataTransfer</var>.<a href="#dom-datatransfer-items" id="dom-datatransfer-items-dev">items</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/items" title="The read-only DataTransfer property items property is a list of the data transfer items in a drag operation. The list includes one item for each item in the operation and if the operation had no items, the list is empty.">DataTransfer/items</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>52+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dd><p>Returns a <code id="the-datatransfer-interface:datatransferitemlist-2"><a href="#datatransferitemlist">DataTransferItemList</a></code> object, with the drag data.</p></dd><dt><code><var>dataTransfer</var>.<a href="#dom-datatransfer-setdragimage" id="dom-datatransfer-setdragimage-dev">setDragImage</a>(<var>element</var>, <var>x</var>, <var>y</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage" title="When a drag occurs, a translucent image is generated from the drag target (the element the dragstart event is fired at), and follows the mouse pointer during the drag. This image is created automatically, so you do not need to create it yourself. However, if a custom image is desired, the DataTransfer.setDragImage() method can be used to set the custom image to be used. The image will typically be an <img> element but it can also be a <canvas> or any other visible element.">DataTransfer/setDragImage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Uses the given element to update the drag feedback, replacing any previously specified
    feedback.</p>
   </dd><dt><code><var>dataTransfer</var>.<a href="#dom-datatransfer-types" id="dom-datatransfer-types-dev">types</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types" title="The DataTransfer.types read-only property returns the available types that exist in the items.">DataTransfer/types</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns a <a id="the-datatransfer-interface:frozen-array" href="https://webidl.spec.whatwg.org/#dfn-frozen-array-type" data-x-internal="frozen-array">frozen array</a> listing the formats that were set in the <code id="the-datatransfer-interface:event-dnd-dragstart-2"><a href="#event-dnd-dragstart">dragstart</a></code> event. In addition, if any files are being
    dragged, then one of the types will be the string "<code>Files</code>".</p>
   </dd><dt><code><var>data</var> = <var>dataTransfer</var>.<a href="#dom-datatransfer-getdata" id="dom-datatransfer-getdata-dev">getData</a>(<var>format</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/getData" title="The DataTransfer.getData() method retrieves drag data (as a string) for the specified type. If the drag operation does not include data, this method returns an empty string.">DataTransfer/getData</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the specified data. If there is no such data, returns the empty string.</p></dd><dt><code><var>dataTransfer</var>.<a href="#dom-datatransfer-setdata" id="dom-datatransfer-setdata-dev">setData</a>(<var>format</var>, <var>data</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setData" title="The DataTransfer.setData() method sets the drag operation's drag data to the specified data and type. If data for the given type does not exist, it is added at the end of the drag data store, such that the last item in the types list will be the new type. If data for the given type already exists, the existing data is replaced in the same position. That is, the order of the types list is not changed when replacing data of the same type.">DataTransfer/setData</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dd><p>Adds the specified data.</p></dd><dt><code><var>dataTransfer</var>.<a href="#dom-datatransfer-cleardata" id="dom-datatransfer-cleardata-dev">clearData</a>([ <var>format</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/clearData" title="The DataTransfer.clearData() method removes the drag operation's drag data for the given type. If data for the given type does not exist, this method does nothing.">DataTransfer/clearData</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Removes the data of the specified formats. Removes all data if the argument is
   omitted.</p></dd><dt><code><var>dataTransfer</var>.<a href="#dom-datatransfer-files" id="dom-datatransfer-files-dev">files</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/files" title="The files property of DataTransfer objects is a list of the files in the drag operation. If the operation includes no files, the list is empty.">DataTransfer/files</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns a <code id="the-datatransfer-interface:filelist-2"><a data-x-internal="filelist" href="https://w3c.github.io/FileAPI/#filelist-section">FileList</a></code> of the files being dragged, if any.</p></dd></dl>

  <p><code id="the-datatransfer-interface:datatransfer-4"><a href="#datatransfer">DataTransfer</a></code> objects that are created as part of <a href="#dndevents">drag-and-drop events</a> are only valid while those events are being fired.</p>

  

  <p>A <code id="the-datatransfer-interface:datatransfer-5"><a href="#datatransfer">DataTransfer</a></code> object is associated with a <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-3">drag data store</a> while it
  is valid.</p>

  <div data-algorithm="">
  <p>A <code id="the-datatransfer-interface:datatransfer-6"><a href="#datatransfer">DataTransfer</a></code> object has an associated <dfn id="concept-datatransfer-types">types array</dfn>, which is a
  <code id="the-datatransfer-interface:frozen-array-2"><a data-x-internal="frozen-array" href="https://webidl.spec.whatwg.org/#dfn-frozen-array-type">FrozenArray&lt;DOMString&gt;</a></code>, initially empty. When the contents
  of the <code id="the-datatransfer-interface:datatransfer-7"><a href="#datatransfer">DataTransfer</a></code> object's <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list">drag data store item list</a> change, or when
  the <code id="the-datatransfer-interface:datatransfer-8"><a href="#datatransfer">DataTransfer</a></code> object becomes no longer associated with a <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-4">drag data
  store</a>, run the following steps:</p>

  <ol><li><p>Let <var>L</var> be an empty sequence.</p></li><li>
    <p>If the <code id="the-datatransfer-interface:datatransfer-9"><a href="#datatransfer">DataTransfer</a></code> object is still associated with a <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-5">drag data
    store</a>, then:</p>

    <ol><li><p>For each item in the <code id="the-datatransfer-interface:datatransfer-10"><a href="#datatransfer">DataTransfer</a></code> object's <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-2">drag data store item
     list</a>  whose <a href="#the-drag-data-item-kind" id="the-datatransfer-interface:the-drag-data-item-kind">kind</a>
     is <i>text</i>, add an entry to <var>L</var> consisting of the item's <a href="#the-drag-data-item-type-string" id="the-datatransfer-interface:the-drag-data-item-type-string">type string</a>.</p></li><li><p>If there are any items in the <code id="the-datatransfer-interface:datatransfer-11"><a href="#datatransfer">DataTransfer</a></code> object's <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-3">drag data store
     item list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransfer-interface:the-drag-data-item-kind-2">kind</a> is <i>File</i>, then
     add an entry to <var>L</var> consisting of the string "<code>Files</code>". (This
     value can be distinguished from the other values because it is not lowercase.)</p></li></ol>
   </li><li><p>Set the <code id="the-datatransfer-interface:datatransfer-12"><a href="#datatransfer">DataTransfer</a></code> object's <a href="#concept-datatransfer-types" id="the-datatransfer-interface:concept-datatransfer-types">types
   array</a> to the result of <a id="the-datatransfer-interface:creating-a-frozen-array" href="https://webidl.spec.whatwg.org/#dfn-create-frozen-array" data-x-internal="creating-a-frozen-array">creating a frozen array</a> from <var>L</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer" data-dfn-type="constructor"><code>DataTransfer()</code></dfn> constructor, when invoked, must return a
  newly created <code id="the-datatransfer-interface:datatransfer-13"><a href="#datatransfer">DataTransfer</a></code> object initialized as follows:</p>

  <ol><li><p>Set the <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-6">drag data store</a>'s <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-4">item
   list</a> to be an empty list.</p></li><li><p>Set the <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-7">drag data store</a>'s <a href="#drag-data-store-mode" id="the-datatransfer-interface:drag-data-store-mode">mode</a> to
   <a href="#concept-dnd-rw" id="the-datatransfer-interface:concept-dnd-rw">read/write mode</a>.</p></li><li><p>Set the <code id="the-datatransfer-interface:dom-datatransfer-dropeffect-2"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code> and
   <code id="the-datatransfer-interface:dom-datatransfer-effectallowed-3"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code> to "none".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer-dropeffect" data-dfn-type="attribute"><code>dropEffect</code></dfn> attribute controls the drag-and-drop
  feedback that the user is given during a drag-and-drop operation. When the
  <code id="the-datatransfer-interface:datatransfer-14"><a href="#datatransfer">DataTransfer</a></code> object is created, the <code id="the-datatransfer-interface:dom-datatransfer-dropeffect-3"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code> attribute is set to a string value. On
  getting, it must return its current value. On setting, if the new value is one of "<dfn id="dom-datatransfer-dropeffect-none"><code>none</code></dfn>", "<dfn id="dom-datatransfer-dropeffect-copy"><code>copy</code></dfn>", "<dfn id="dom-datatransfer-dropeffect-link"><code>link</code></dfn>", or "<dfn id="dom-datatransfer-dropeffect-move"><code>move</code></dfn>", then the attribute's current value
  must be set to the new value. Other values must be ignored.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer-effectallowed" data-dfn-type="attribute"><code>effectAllowed</code></dfn> attribute is used in the
  drag-and-drop processing model to initialize the <code id="the-datatransfer-interface:dom-datatransfer-dropeffect-4"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code> attribute during the <code id="the-datatransfer-interface:event-dnd-dragenter"><a href="#event-dnd-dragenter">dragenter</a></code> and <code id="the-datatransfer-interface:event-dnd-dragover"><a href="#event-dnd-dragover">dragover</a></code> events. When the <code id="the-datatransfer-interface:datatransfer-15"><a href="#datatransfer">DataTransfer</a></code> object is
  created, the <code id="the-datatransfer-interface:dom-datatransfer-effectallowed-4"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code> attribute is set
  to a string value. On getting, it must return its current value. On setting, if the <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-8">drag data
  store</a>'s <a href="#drag-data-store-mode" id="the-datatransfer-interface:drag-data-store-mode-2">mode</a> is the <a href="#concept-dnd-rw" id="the-datatransfer-interface:concept-dnd-rw-2">read/write mode</a> and the new value is one of "<dfn id="dom-datatransfer-effectallowed-none"><code>none</code></dfn>", "<dfn id="dom-datatransfer-effectallowed-copy"><code>copy</code></dfn>", "<dfn id="dom-datatransfer-effectallowed-copylink"><code>copyLink</code></dfn>", "<dfn id="dom-datatransfer-effectallowed-copymove"><code>copyMove</code></dfn>", "<dfn id="dom-datatransfer-effectallowed-link"><code>link</code></dfn>", "<dfn id="dom-datatransfer-effectallowed-linkmove"><code>linkMove</code></dfn>", "<dfn id="dom-datatransfer-effectallowed-move"><code>move</code></dfn>", "<dfn id="dom-datatransfer-effectallowed-all"><code>all</code></dfn>", or "<dfn id="dom-datatransfer-effectallowed-uninitialized"><code>uninitialized</code></dfn>", then the attribute's
  current value must be set to the new value. Otherwise, it must be left unchanged.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer-items" data-dfn-type="attribute"><code>items</code></dfn>
  attribute must return a <code id="the-datatransfer-interface:datatransferitemlist-3"><a href="#datatransferitemlist">DataTransferItemList</a></code> object associated with the
  <code id="the-datatransfer-interface:datatransfer-16"><a href="#datatransfer">DataTransfer</a></code> object.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer-setdragimage" data-dfn-type="method"><code>setDragImage(<var>image</var>, <var>x</var>,
  <var>y</var>)</code></dfn> method must run the following steps:</p>

  <ol><li><p>If the <code id="the-datatransfer-interface:datatransfer-17"><a href="#datatransfer">DataTransfer</a></code> object is no longer associated with a <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-9">drag data
   store</a>, return. Nothing happens.</p></li><li><p>If the <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-10">drag data store</a>'s <a href="#drag-data-store-mode" id="the-datatransfer-interface:drag-data-store-mode-3">mode</a> is
   not the <a href="#concept-dnd-rw" id="the-datatransfer-interface:concept-dnd-rw-3">read/write mode</a>, return. Nothing
   happens.</p></li><li><p>If <var>image</var> is an <code id="the-datatransfer-interface:the-img-element"><a href="#the-img-element">img</a></code> element, then set the <a href="#drag-data-store-bitmap" id="the-datatransfer-interface:drag-data-store-bitmap">drag data store
   bitmap</a> to the element's image (at its <a href="https://drafts.csswg.org/css-images/#natural-dimensions" id="the-datatransfer-interface:natural-dimensions" data-x-internal="natural-dimensions">natural
   size</a>); otherwise, set the <a href="#drag-data-store-bitmap" id="the-datatransfer-interface:drag-data-store-bitmap-2">drag data store bitmap</a> to an image generated from
   the given element (the exact mechanism for doing so is not currently specified).</p></li><li><p>Set the <a href="#drag-data-store-hot-spot-coordinate" id="the-datatransfer-interface:drag-data-store-hot-spot-coordinate">drag data store hot spot coordinate</a> to the given <var>x</var>,
   <var>y</var> coordinate.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer-types" data-dfn-type="attribute"><code>types</code></dfn>
  attribute must return this <code id="the-datatransfer-interface:datatransfer-18"><a href="#datatransfer">DataTransfer</a></code> object's <a href="#concept-datatransfer-types" id="the-datatransfer-interface:concept-datatransfer-types-2">types array</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer-getdata" data-dfn-type="method"><code>getData(<var>format</var>)</code></dfn> method must run the
  following steps:</p>

  <ol><li><p>If the <code id="the-datatransfer-interface:datatransfer-19"><a href="#datatransfer">DataTransfer</a></code> object is no longer associated with a <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-11">drag data
   store</a>, then return the empty string.</p></li><li><p>If the <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-12">drag data store</a>'s <a href="#drag-data-store-mode" id="the-datatransfer-interface:drag-data-store-mode-4">mode</a> is
   the <a href="#concept-dnd-p" id="the-datatransfer-interface:concept-dnd-p">protected mode</a>, then return the empty string.</p></li><li><p>Let <var>format</var> be the first argument, <a id="the-datatransfer-interface:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
   lowercase</a>.</p></li><li><p>Let <var>convert-to-URL</var> be false.</p></li><li><p>If <var>format</var> equals "<code>text</code>", change it to "<code>text/plain</code>".</p></li><li><p>If <var>format</var> equals "<code>url</code>", change it to "<code>text/uri-list</code>" and set <var>convert-to-URL</var> to true.</p></li><li><p>If there is no item in the <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-5">drag data store item list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransfer-interface:the-drag-data-item-kind-3">kind</a> is <i>text</i> and whose <a href="#the-drag-data-item-type-string" id="the-datatransfer-interface:the-drag-data-item-type-string-2">type string</a> is equal to <var>format</var>, return the empty string.</p></li><li><p>Let <var>result</var> be the data of the item in the <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-6">drag data store item
   list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransfer-interface:the-drag-data-item-kind-4">kind</a> is <i>Plain Unicode
   string</i> and whose <a href="#the-drag-data-item-type-string" id="the-datatransfer-interface:the-drag-data-item-type-string-3">type string</a> is equal to
   <var>format</var>.</p></li><li><p>If <var>convert-to-URL</var> is true, then parse <var>result</var> as appropriate for
   <code>text/uri-list</code> data, and then set <var>result</var> to the first URL from
   the list, if any, or the empty string otherwise. <a href="#refsRFC2483">[RFC2483]</a></p></li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer-setdata" data-dfn-type="method"><code>setData(<var>format</var>, <var>data</var>)</code></dfn> method
  must run the following steps:</p>

  <ol><li><p>If the <code id="the-datatransfer-interface:datatransfer-20"><a href="#datatransfer">DataTransfer</a></code> object is no longer associated with a <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-13">drag data
   store</a>, return. Nothing happens.</p></li><li><p>If the <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-14">drag data store</a>'s <a href="#drag-data-store-mode" id="the-datatransfer-interface:drag-data-store-mode-5">mode</a> is
   not the <a href="#concept-dnd-rw" id="the-datatransfer-interface:concept-dnd-rw-4">read/write mode</a>, return. Nothing
   happens.</p></li><li><p>Let <var>format</var> be the first argument, <a id="the-datatransfer-interface:converted-to-ascii-lowercase-2" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
   lowercase</a>.</p></li><li>
    <p>If <var>format</var> equals "<code>text</code>", change it to "<code>text/plain</code>".</p>

    <p>If <var>format</var> equals "<code>url</code>", change it to "<code>text/uri-list</code>".</p>
   </li><li><p>Remove the item in the <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-7">drag data store item list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransfer-interface:the-drag-data-item-kind-5">kind</a> is <i>text</i> and whose <a href="#the-drag-data-item-type-string" id="the-datatransfer-interface:the-drag-data-item-type-string-4">type string</a> is equal to <var>format</var>, if there is
   one.</p></li><li><p>Add an item to the <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-8">drag data store item list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransfer-interface:the-drag-data-item-kind-6">kind</a> is <i>text</i>, whose <a href="#the-drag-data-item-type-string" id="the-datatransfer-interface:the-drag-data-item-type-string-5">type string</a> is equal to <var>format</var>, and whose data is the string
   given by the method's second argument.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer-cleardata" data-dfn-type="method"><code>clearData(<var>format</var>)</code></dfn> method must run the
  following steps:</p>

  <ol><li><p>If the <code id="the-datatransfer-interface:datatransfer-21"><a href="#datatransfer">DataTransfer</a></code> object is no longer associated with a <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-15">drag data
   store</a>, return. Nothing happens.</p></li><li><p>If the <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-16">drag data store</a>'s <a href="#drag-data-store-mode" id="the-datatransfer-interface:drag-data-store-mode-6">mode</a> is
   not the <a href="#concept-dnd-rw" id="the-datatransfer-interface:concept-dnd-rw-5">read/write mode</a>, return. Nothing
   happens.</p></li><li><p>If the method was called with no arguments, remove each item in the <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-9">drag data store
   item list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransfer-interface:the-drag-data-item-kind-7">kind</a> is <i>Plain Unicode
   string</i>, and return.</p></li><li><p>Set <var>format</var> to <var>format</var>, <a id="the-datatransfer-interface:converted-to-ascii-lowercase-3" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
   lowercase</a>.</p></li><li>
    <p>If <var>format</var> equals "<code>text</code>", change it to "<code>text/plain</code>".</p>

    <p>If <var>format</var> equals "<code>url</code>", change it to "<code>text/uri-list</code>".</p>
   </li><li><p>Remove the item in the <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-10">drag data store item list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransfer-interface:the-drag-data-item-kind-8">kind</a> is <i>text</i> and whose <a href="#the-drag-data-item-type-string" id="the-datatransfer-interface:the-drag-data-item-type-string-6">type string</a> is equal to <var>format</var>, if there is
   one.</p></li></ol>
  </div>

  <p class="note">The <code id="the-datatransfer-interface:dom-datatransfer-cleardata-2"><a href="#dom-datatransfer-cleardata">clearData()</a></code> method does not
  affect whether any files were included in the drag, so the <code id="the-datatransfer-interface:dom-datatransfer-types-2"><a href="#dom-datatransfer-types">types</a></code> attribute's list might still not be empty after
  calling <code id="the-datatransfer-interface:dom-datatransfer-cleardata-3"><a href="#dom-datatransfer-cleardata">clearData()</a></code> (it would still contain the
  "<code>Files</code>" string if any files were included in the drag).</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransfer" id="dom-datatransfer-files" data-dfn-type="attribute"><code>files</code></dfn>
  attribute must return a <a href="#live" id="the-datatransfer-interface:live">live</a> <code id="the-datatransfer-interface:filelist-3"><a data-x-internal="filelist" href="https://w3c.github.io/FileAPI/#filelist-section">FileList</a></code> sequence consisting of
  <code id="the-datatransfer-interface:file"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> objects representing the files found by the following steps. Furthermore, for a
  given <code id="the-datatransfer-interface:filelist-4"><a data-x-internal="filelist" href="https://w3c.github.io/FileAPI/#filelist-section">FileList</a></code> object and a given underlying file, the same <code id="the-datatransfer-interface:file-2"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object
  must be used each time.</p>

  <ol><li><p>Start with an empty list <var>L</var>.</p></li><li><p>If the <code id="the-datatransfer-interface:datatransfer-22"><a href="#datatransfer">DataTransfer</a></code> object is no longer associated with a <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-17">drag data
   store</a>, the <code id="the-datatransfer-interface:filelist-5"><a data-x-internal="filelist" href="https://w3c.github.io/FileAPI/#filelist-section">FileList</a></code> is empty. Return the empty list <var>L</var>.</p></li><li><p>If the <a href="#drag-data-store" id="the-datatransfer-interface:drag-data-store-18">drag data store</a>'s <a href="#drag-data-store-mode" id="the-datatransfer-interface:drag-data-store-mode-7">mode</a> is
   the <a href="#concept-dnd-p" id="the-datatransfer-interface:concept-dnd-p-2">protected mode</a>, return the empty list
   <var>L</var>.</p></li><li><p>For each item in the <a href="#drag-data-store-item-list" id="the-datatransfer-interface:drag-data-store-item-list-11">drag data store item list</a> 
   whose <a href="#the-drag-data-item-kind" id="the-datatransfer-interface:the-drag-data-item-kind-9">kind</a> is <i>File</i>, add the item's data (the file, in particular its name and contents, as well as
   its <a href="#the-drag-data-item-type-string" id="the-datatransfer-interface:the-drag-data-item-type-string-7">type</a>) to the list <var>L</var>.</p></li><li><p>The files found by these steps are those in the list <var>L</var>.</p></li></ol>
  </div>

  <p class="note">This version of the API does not expose the types of the files during the
  drag.</p>

  


  <h5 id="the-datatransferitemlist-interface"><span class="secno">6.11.3.1</span> The <code id="the-datatransferitemlist-interface:datatransferitemlist"><a href="#datatransferitemlist">DataTransferItemList</a></code> interface<a href="#the-datatransferitemlist-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItemList" title="The DataTransferItemList object is a list of DataTransferItem objects representing items being dragged. During a drag operation, each DragEvent has a dataTransfer property and that property is a DataTransferItemList.">DataTransferItemList</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>13+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div>

  <p>Each <code id="the-datatransferitemlist-interface:datatransfer"><a href="#datatransfer">DataTransfer</a></code> object is associated with a <code id="the-datatransferitemlist-interface:datatransferitemlist-2"><a href="#datatransferitemlist">DataTransferItemList</a></code>
  object.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="datatransferitemlist" data-dfn-type="interface"><c- g="">DataTransferItemList</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-datatransferitemlist-length" id="the-datatransferitemlist-interface:dom-datatransferitemlist-length"><c- g="">length</c-></a>;
  <a href="#dom-datatransferitemlist-item"><c- b="">getter</c-></a> <a href="#datatransferitem" id="the-datatransferitemlist-interface:datatransferitem"><c- n="">DataTransferItem</c-></a> (<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <a href="#datatransferitem" id="the-datatransferitemlist-interface:datatransferitem-2"><c- n="">DataTransferItem</c-></a>? <a href="#dom-datatransferitemlist-add" id="the-datatransferitemlist-interface:dom-datatransferitemlist-add"><c- g="">add</c-></a>(<c- b="">DOMString</c-> <c- g="">data</c->, <c- b="">DOMString</c-> <c- g="">type</c->);
  <a href="#datatransferitem" id="the-datatransferitemlist-interface:datatransferitem-3"><c- n="">DataTransferItem</c-></a>? <a href="#dom-datatransferitemlist-add" id="the-datatransferitemlist-interface:dom-datatransferitemlist-add-2"><c- g="">add</c-></a>(<a id="the-datatransferitemlist-interface:file" href="https://w3c.github.io/FileAPI/#dfn-file" data-x-internal="file"><c- n="">File</c-></a> <c- g="">data</c->);
  <c- b="">undefined</c-> <a href="#dom-datatransferitemlist-remove" id="the-datatransferitemlist-interface:dom-datatransferitemlist-remove"><c- g="">remove</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <c- b="">undefined</c-> <a href="#dom-datatransferitemlist-clear" id="the-datatransferitemlist-interface:dom-datatransferitemlist-clear"><c- g="">clear</c-></a>();
};</code></pre>

  <dl class="domintro"><dt><code><var>items</var>.<a href="#dom-datatransferitemlist-length" id="dom-datatransferitemlist-length-dev">length</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItemList/length" title="The read-only length property of the DataTransferItemList interface returns the number of items currently in the drag item list.">DataTransferItemList/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>13+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div></dt><dd><p>Returns the number of items in the <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store">drag data store</a>.</p></dd><dt><code><var>items</var>[<var>index</var>]</code></dt><dd>
    <p>Returns the <code id="the-datatransferitemlist-interface:datatransferitem-4"><a href="#datatransferitem">DataTransferItem</a></code> object representing the <var>index</var>th entry in
    the <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-2">drag data store</a>.</p>
   </dd><dt><code><var>items</var>.<a href="#dom-datatransferitemlist-remove" id="dom-datatransferitemlist-remove-dev">remove</a>(<var>index</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItemList/remove" title="The DataTransferItemList.remove() method removes the DataTransferItem at the specified index from the list. If the index is less than zero or greater than one less than the length of the list, the list will not be changed.">DataTransferItemList/remove</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>31+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div></dt><dd><p>Removes the <var>index</var>th entry in the <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-3">drag data store</a>.</p></dd><dt><code><var>items</var>.<a href="#dom-datatransferitemlist-clear" id="dom-datatransferitemlist-clear-dev">clear</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItemList/clear" title="The DataTransferItemList method clear() removes all DataTransferItem objects from the drag data items list, leaving the list empty.">DataTransferItemList/clear</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>13+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div></dt><dd><p>Removes all the entries in the <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-4">drag data store</a>.</p></dd><dt><code><var>items</var>.<a href="#dom-datatransferitemlist-add" id="dom-datatransferitemlist-add-dev">add</a>(<var>data</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItemList/add" title="The DataTransferItemList.add() method creates a new DataTransferItem using the specified data and adds it to the drag data list. The item may be a File or a string of a given type. If the item is successfully added to the list, the newly-created DataTransferItem object is returned.">DataTransferItemList/add</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>13+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div></dt><dt><code><var>items</var>.<a href="#dom-datatransferitemlist-add" id="the-datatransferitemlist-interface:dom-datatransferitemlist-add-3">add</a>(<var>data</var>, <var>type</var>)</code></dt><dd>
    <p>Adds a new entry for the given data to the <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-5">drag data store</a>. If the data is plain
    text  then a <var>type</var> string has to be provided also.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>While the <code id="the-datatransferitemlist-interface:datatransferitemlist-3"><a href="#datatransferitemlist">DataTransferItemList</a></code> object's <code id="the-datatransferitemlist-interface:datatransfer-2"><a href="#datatransfer">DataTransfer</a></code> object is
  associated with a <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-6">drag data store</a>, the <code id="the-datatransferitemlist-interface:datatransferitemlist-4"><a href="#datatransferitemlist">DataTransferItemList</a></code> object's
  <i>mode</i> is the same as the <a href="#drag-data-store-mode" id="the-datatransferitemlist-interface:drag-data-store-mode">drag data store mode</a>. When the
  <code id="the-datatransferitemlist-interface:datatransferitemlist-5"><a href="#datatransferitemlist">DataTransferItemList</a></code> object's <code id="the-datatransferitemlist-interface:datatransfer-3"><a href="#datatransfer">DataTransfer</a></code> object is <em>not</em>
  associated with a <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-7">drag data store</a>, the <code id="the-datatransferitemlist-interface:datatransferitemlist-6"><a href="#datatransferitemlist">DataTransferItemList</a></code> object's
  <i>mode</i> is the <i>disabled mode</i>. The <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-8">drag data store</a> referenced in this
  section (which is used only when the <code id="the-datatransferitemlist-interface:datatransferitemlist-7"><a href="#datatransferitemlist">DataTransferItemList</a></code> object is not in the
  <i>disabled mode</i>) is the <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-9">drag data store</a> with which the
  <code id="the-datatransferitemlist-interface:datatransferitemlist-8"><a href="#datatransferitemlist">DataTransferItemList</a></code> object's <code id="the-datatransferitemlist-interface:datatransfer-4"><a href="#datatransfer">DataTransfer</a></code> object is associated.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransferItemList" id="dom-datatransferitemlist-length" data-dfn-type="attribute"><code>length</code></dfn> attribute must return zero if the
  object is in the <i>disabled mode</i>; otherwise it must return the number of items in the
  <a href="#drag-data-store-item-list" id="the-datatransferitemlist-interface:drag-data-store-item-list">drag data store item list</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="the-datatransferitemlist-interface:datatransferitemlist-9"><a href="#datatransferitemlist">DataTransferItemList</a></code> object is not in the <i>disabled mode</i>, its
  <a id="the-datatransferitemlist-interface:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> are the <a id="the-datatransferitemlist-interface:indices" href="https://infra.spec.whatwg.org/#list-get-the-indices" data-x-internal="indices">indices</a> of the <a href="#drag-data-store-item-list" id="the-datatransferitemlist-interface:drag-data-store-item-list-2">drag data store
  item list</a>.</p>
  </div>

  <div data-algorithm="">
  <p id="dom-datatransferitemlist-item">To <a id="the-datatransferitemlist-interface:determine-the-value-of-an-indexed-property" href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-an-indexed-property" data-x-internal="determine-the-value-of-an-indexed-property">determine the value of an indexed property</a>
  <var>i</var> of a <code id="the-datatransferitemlist-interface:datatransferitemlist-10"><a href="#datatransferitemlist">DataTransferItemList</a></code> object, the user agent must return a
  <code id="the-datatransferitemlist-interface:datatransferitem-5"><a href="#datatransferitem">DataTransferItem</a></code> object representing the <var>i</var>th item in the
  <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-10">drag data store</a>. The same object must be returned each time a particular item is
  obtained from this <code id="the-datatransferitemlist-interface:datatransferitemlist-11"><a href="#datatransferitemlist">DataTransferItemList</a></code> object. The <code id="the-datatransferitemlist-interface:datatransferitem-6"><a href="#datatransferitem">DataTransferItem</a></code>
  object must be associated with the same <code id="the-datatransferitemlist-interface:datatransfer-5"><a href="#datatransfer">DataTransfer</a></code> object as the
  <code id="the-datatransferitemlist-interface:datatransferitemlist-12"><a href="#datatransferitemlist">DataTransferItemList</a></code> object when it is first created.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransferItemList" id="dom-datatransferitemlist-add" data-dfn-type="method"><code>add()</code></dfn> method must run the following steps:</p>

  <ol><li><p>If the <code id="the-datatransferitemlist-interface:datatransferitemlist-13"><a href="#datatransferitemlist">DataTransferItemList</a></code> object is not in the <i id="the-datatransferitemlist-interface:concept-dnd-rw"><a href="#concept-dnd-rw">read/write mode</a></i>, return null.</p></li><li>
    <p>Jump to the appropriate set of steps from the following list:</p>

    <dl class="switch"><dt>If the first argument to the method is a string</dt><dd>
      <p>If there is already an item in the <a href="#drag-data-store-item-list" id="the-datatransferitemlist-interface:drag-data-store-item-list-3">drag data store item list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransferitemlist-interface:the-drag-data-item-kind">kind</a> is <i>text</i> and whose <a href="#the-drag-data-item-type-string" id="the-datatransferitemlist-interface:the-drag-data-item-type-string">type string</a> is equal to the value of the
      method's second argument, <a id="the-datatransferitemlist-interface:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>, then throw a
      <a id="the-datatransferitemlist-interface:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="the-datatransferitemlist-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

      <p>Otherwise, add an item to the <a href="#drag-data-store-item-list" id="the-datatransferitemlist-interface:drag-data-store-item-list-4">drag data store item list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransferitemlist-interface:the-drag-data-item-kind-2">kind</a> is <i>text</i>, whose <a href="#the-drag-data-item-type-string" id="the-datatransferitemlist-interface:the-drag-data-item-type-string-2">type string</a> is equal to the value of the method's second
      argument, <a id="the-datatransferitemlist-interface:converted-to-ascii-lowercase-2" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>, and whose data is the string given by the
      method's first argument.</p>
     </dd><dt>If the first argument to the method is a <code id="the-datatransferitemlist-interface:file-2"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code></dt><dd>
      <p>Add an item to the <a href="#drag-data-store-item-list" id="the-datatransferitemlist-interface:drag-data-store-item-list-5">drag data store item list</a> whose <a href="#the-drag-data-item-kind" id="the-datatransferitemlist-interface:the-drag-data-item-kind-3">kind</a> is <i>File</i>, whose <a href="#the-drag-data-item-type-string" id="the-datatransferitemlist-interface:the-drag-data-item-type-string-3">type
      string</a> is the <code id="the-datatransferitemlist-interface:dom-blob-type"><a data-x-internal="dom-blob-type" href="https://w3c.github.io/FileAPI/#dfn-type">type</a></code> of the <code id="the-datatransferitemlist-interface:file-3"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code>,
      <a id="the-datatransferitemlist-interface:converted-to-ascii-lowercase-3" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>, and whose data is the same as the
      <code id="the-datatransferitemlist-interface:file-4"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code>'s data.</p>
     </dd></dl>
   </li><li><p><a href="#dom-datatransferitemlist-item">Determine the value of the indexed property</a>
   corresponding to the newly added item, and return that value (a newly created
   <code id="the-datatransferitemlist-interface:datatransferitem-7"><a href="#datatransferitem">DataTransferItem</a></code> object).</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransferItemList" id="dom-datatransferitemlist-remove" data-dfn-type="method"><code>remove(<var>index</var>)</code></dfn> method must run
  these steps:</p>

  <ol><li><p>If the <code id="the-datatransferitemlist-interface:datatransferitemlist-14"><a href="#datatransferitemlist">DataTransferItemList</a></code> object is not in the <i id="the-datatransferitemlist-interface:concept-dnd-rw-2"><a href="#concept-dnd-rw">read/write mode</a></i>, throw an
   <a id="the-datatransferitemlist-interface:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-datatransferitemlist-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-11">drag data store</a> does not contain an <var>index</var>th item, then
   return.</p></li><li><p>Remove the <var>index</var>th item from the <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-12">drag data store</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransferItemList" id="dom-datatransferitemlist-clear" data-dfn-type="method"><code>clear()</code></dfn> method, if the
  <code id="the-datatransferitemlist-interface:datatransferitemlist-15"><a href="#datatransferitemlist">DataTransferItemList</a></code> object is in the <i id="the-datatransferitemlist-interface:concept-dnd-rw-3"><a href="#concept-dnd-rw">read/write mode</a></i>,
  must remove all the items from the <a href="#drag-data-store" id="the-datatransferitemlist-interface:drag-data-store-13">drag data store</a>. Otherwise, it must do
  nothing.</p>
  </div>

  


  <h5 id="the-datatransferitem-interface"><span class="secno">6.11.3.2</span> The <code id="the-datatransferitem-interface:datatransferitem"><a href="#datatransferitem">DataTransferItem</a></code> interface<a href="#the-datatransferitem-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem" title="The DataTransferItem object represents one drag data item. During a drag operation, each drag event has a dataTransfer property which contains a list of drag data items. Each item in the list is a DataTransferItem object.">DataTransferItem</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>11+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div>

  <p>Each <code id="the-datatransferitem-interface:datatransferitem-2"><a href="#datatransferitem">DataTransferItem</a></code> object is associated with a <code id="the-datatransferitem-interface:datatransfer"><a href="#datatransfer">DataTransfer</a></code>
  object.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="datatransferitem" data-dfn-type="interface"><c- g="">DataTransferItem</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-datatransferitem-kind" id="the-datatransferitem-interface:dom-datatransferitem-kind"><c- g="">kind</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-datatransferitem-type" id="the-datatransferitem-interface:dom-datatransferitem-type"><c- g="">type</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-datatransferitem-getasstring" id="the-datatransferitem-interface:dom-datatransferitem-getasstring"><c- g="">getAsString</c-></a>(<a href="#functionstringcallback" id="the-datatransferitem-interface:functionstringcallback"><c- n="">FunctionStringCallback</c-></a>? <c- g="">_callback</c->);
  <a id="the-datatransferitem-interface:file" href="https://w3c.github.io/FileAPI/#dfn-file" data-x-internal="file"><c- n="">File</c-></a>? <a href="#dom-datatransferitem-getasfile" id="the-datatransferitem-interface:dom-datatransferitem-getasfile"><c- g="">getAsFile</c-></a>();
};

<c- b="">callback</c-> <dfn id="functionstringcallback" data-dfn-type="callback"><c- g="">FunctionStringCallback</c-></dfn> = <c- b="">undefined</c-> (<c- b="">DOMString</c-> <c- g="">data</c->);</code></pre>

  <dl class="domintro"><dt><code><var>item</var>.<a href="#dom-datatransferitem-kind" id="dom-datatransferitem-kind-dev">kind</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/kind" title="The read-only DataTransferItem.kind property returns a DataTransferItem representing the drag data item kind: some text or some file.">DataTransferItem/kind</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>11+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div></dt><dd>
    <p>Returns <a href="#the-drag-data-item-kind" id="the-datatransferitem-interface:the-drag-data-item-kind">the drag data item kind</a>, one of: "string", 
    "file".</p>
   </dd><dt><code><var>item</var>.<a href="#dom-datatransferitem-type" id="dom-datatransferitem-type-dev">type</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/type" title="The read-only DataTransferItem.type property returns the type (format) of the DataTransferItem object representing the drag data item. The type is a Unicode string generally given by a MIME type, although a MIME type is not required.">DataTransferItem/type</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>11+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div></dt><dd><p>Returns <a href="#the-drag-data-item-type-string" id="the-datatransferitem-interface:the-drag-data-item-type-string">the drag data item type string</a>.</p></dd><dt><code><var>item</var>.<a href="#dom-datatransferitem-getasstring" id="dom-datatransferitem-getasstring-dev">getAsString</a>(<var>callback</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/getAsString" title="The DataTransferItem.getAsString() method invokes the given callback with the drag data item's string data as the argument if the item's kind is a Plain unicode string (i.e. kind is string).">DataTransferItem/getAsString</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>11+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div></dt><dd>
    <p>Invokes the callback with the string data as the argument, if <a href="#the-drag-data-item-kind" id="the-datatransferitem-interface:the-drag-data-item-kind-2">the drag data item
    kind</a> is <i>text</i>.</p>
   </dd><dt><code><var>file</var> = <var>item</var>.<a href="#dom-datatransferitem-getasfile" id="dom-datatransferitem-getasfile-dev">getAsFile</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/getAsFile" title="If the item is a file, the DataTransferItem.getAsFile() method returns the drag data item's File object. If the item is not a file, this method returns null.">DataTransferItem/getAsFile</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>11+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="the-datatransferitem-interface:file-2"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object, if <a href="#the-drag-data-item-kind" id="the-datatransferitem-interface:the-drag-data-item-kind-3">the drag data item kind</a> is
    <i>File</i>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>While the <code id="the-datatransferitem-interface:datatransferitem-3"><a href="#datatransferitem">DataTransferItem</a></code> object's <code id="the-datatransferitem-interface:datatransfer-2"><a href="#datatransfer">DataTransfer</a></code> object is associated
  with a <a href="#drag-data-store" id="the-datatransferitem-interface:drag-data-store">drag data store</a> and that <a href="#drag-data-store" id="the-datatransferitem-interface:drag-data-store-2">drag data store</a>'s <a href="#drag-data-store-item-list" id="the-datatransferitem-interface:drag-data-store-item-list">drag data store
  item list</a> still contains the item that the <code id="the-datatransferitem-interface:datatransferitem-4"><a href="#datatransferitem">DataTransferItem</a></code> object represents,
  the <code id="the-datatransferitem-interface:datatransferitem-5"><a href="#datatransferitem">DataTransferItem</a></code> object's <i>mode</i> is the same as the <a href="#drag-data-store-mode" id="the-datatransferitem-interface:drag-data-store-mode">drag data store
  mode</a>. When the <code id="the-datatransferitem-interface:datatransferitem-6"><a href="#datatransferitem">DataTransferItem</a></code> object's <code id="the-datatransferitem-interface:datatransfer-3"><a href="#datatransfer">DataTransfer</a></code> object is
  <em>not</em> associated with a <a href="#drag-data-store" id="the-datatransferitem-interface:drag-data-store-3">drag data store</a>, or if the item that the
  <code id="the-datatransferitem-interface:datatransferitem-7"><a href="#datatransferitem">DataTransferItem</a></code> object represents has been removed from the relevant <a href="#drag-data-store-item-list" id="the-datatransferitem-interface:drag-data-store-item-list-2">drag data
  store item list</a>, the <code id="the-datatransferitem-interface:datatransferitem-8"><a href="#datatransferitem">DataTransferItem</a></code> object's <i>mode</i> is the <i>disabled
  mode</i>. The <a href="#drag-data-store" id="the-datatransferitem-interface:drag-data-store-4">drag data store</a> referenced in this section (which is used only when the
  <code id="the-datatransferitem-interface:datatransferitem-9"><a href="#datatransferitem">DataTransferItem</a></code> object is not in the <i>disabled mode</i>) is the <a href="#drag-data-store" id="the-datatransferitem-interface:drag-data-store-5">drag data
  store</a> with which the <code id="the-datatransferitem-interface:datatransferitem-10"><a href="#datatransferitem">DataTransferItem</a></code> object's <code id="the-datatransferitem-interface:datatransfer-4"><a href="#datatransfer">DataTransfer</a></code>
  object is associated.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransferItem" id="dom-datatransferitem-kind" data-dfn-type="attribute"><code>kind</code></dfn> attribute must return the empty string if the
  <code id="the-datatransferitem-interface:datatransferitem-11"><a href="#datatransferitem">DataTransferItem</a></code> object is in the <i>disabled mode</i>; otherwise it must return the
  string given in the cell from the second column of the following table from the row whose cell in
  the first column contains <a href="#the-drag-data-item-kind" id="the-datatransferitem-interface:the-drag-data-item-kind-4">the drag data item kind</a> of the item represented by the
  <code id="the-datatransferitem-interface:datatransferitem-12"><a href="#datatransferitem">DataTransferItem</a></code> object:</p>

  <table><thead><tr><th> Kind </th><th> String
   </th></tr></thead><tbody><tr><td> <i>Text</i> </td><td> "<code>string</code>"

    </td></tr><tr><td> <i>File</i> </td><td> "<code>file</code>"

  </td></tr></tbody></table>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransferItem" id="dom-datatransferitem-type" data-dfn-type="attribute"><code>type</code></dfn> attribute must return the empty string if the
  <code id="the-datatransferitem-interface:datatransferitem-13"><a href="#datatransferitem">DataTransferItem</a></code> object is in the <i>disabled mode</i>; otherwise it must return
  <a href="#the-drag-data-item-type-string" id="the-datatransferitem-interface:the-drag-data-item-type-string-2">the drag data item type string</a> of the item represented by the
  <code id="the-datatransferitem-interface:datatransferitem-14"><a href="#datatransferitem">DataTransferItem</a></code> object.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransferItem" id="dom-datatransferitem-getasstring" data-dfn-type="method"><code>getAsString(<var>callback</var>)</code></dfn> method
  must run the following steps:</p>

  <ol><li><p>If the <var>callback</var> is null, return.</p></li><li><p>If the <code id="the-datatransferitem-interface:datatransferitem-15"><a href="#datatransferitem">DataTransferItem</a></code> object is not in the <i id="the-datatransferitem-interface:concept-dnd-rw"><a href="#concept-dnd-rw">read/write mode</a></i> or the <i id="the-datatransferitem-interface:concept-dnd-ro"><a href="#concept-dnd-ro">read-only mode</a></i>,
   return. The callback is never invoked.</p></li><li><p>If <a href="#the-drag-data-item-kind" id="the-datatransferitem-interface:the-drag-data-item-kind-5">the drag data item kind</a> is not <i>text</i>, then return.
   The callback is never invoked.</p></li><li><p>Otherwise, <a href="#queue-a-task" id="the-datatransferitem-interface:queue-a-task">queue a task</a> to invoke <var>callback</var>, passing the
   actual data of the item represented by the <code id="the-datatransferitem-interface:datatransferitem-16"><a href="#datatransferitem">DataTransferItem</a></code> object as the
   argument.</p></li></ol>
  </div>



  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DataTransferItem" id="dom-datatransferitem-getasfile" data-dfn-type="method"><code>getAsFile()</code></dfn> method must run the following
  steps:</p>

  <ol><li><p>If the <code id="the-datatransferitem-interface:datatransferitem-17"><a href="#datatransferitem">DataTransferItem</a></code> object is not in the <i id="the-datatransferitem-interface:concept-dnd-rw-2"><a href="#concept-dnd-rw">read/write mode</a></i> or the <i id="the-datatransferitem-interface:concept-dnd-ro-2"><a href="#concept-dnd-ro">read-only mode</a></i>,
   then return null.</p></li><li><p>If <a href="#the-drag-data-item-kind" id="the-datatransferitem-interface:the-drag-data-item-kind-6">the drag data item kind</a> is not <i>File</i>, then return null.</p></li><li><p>Return a new <code id="the-datatransferitem-interface:file-3"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> object representing the actual data of the item represented
   by the <code id="the-datatransferitem-interface:datatransferitem-18"><a href="#datatransferitem">DataTransferItem</a></code> object.</p>
  </li></ol>
  </div>



  



  <h4 id="the-dragevent-interface"><span class="secno">6.11.4</span> The <code id="the-dragevent-interface:dragevent"><a href="#dragevent">DragEvent</a></code> interface<a href="#the-dragevent-interface" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent" title="This constructor is used to create a synthetic DragEvent object.">DragEvent/DragEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>14+</span></span><span class="chrome yes"><span>Chrome</span><span>46+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios no"><span>Safari iOS</span><span>No</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DragEvent" title="The DragEvent interface is a DOM event that represents a drag and drop interaction. The user initiates a drag by placing a pointer device (such as a mouse) on the touch surface and then dragging the pointer to a new location (such as another DOM element). Applications are free to interpret a drag and drop interaction in an application-specific way.">DragEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>14+</span></span><span class="chrome yes"><span>Chrome</span><span>46+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios no"><span>Safari iOS</span><span>No</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The drag-and-drop processing model involves several events. They all use the
  <code id="the-dragevent-interface:dragevent-2"><a href="#dragevent">DragEvent</a></code> interface.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="dragevent" data-dfn-type="interface"><c- g="">DragEvent</c-></dfn> : <a id="the-dragevent-interface:mouseevent" href="https://w3c.github.io/uievents/#mouseevent" data-x-internal="mouseevent"><c- n="">MouseEvent</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#drageventinit" id="the-dragevent-interface:drageventinit"><c- n="">DragEventInit</c-></a> <c- g="">eventInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#datatransfer" id="the-dragevent-interface:datatransfer"><c- n="">DataTransfer</c-></a>? <a href="#dom-dragevent-datatransfer" id="the-dragevent-interface:dom-dragevent-datatransfer"><c- g="">dataTransfer</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="drageventinit" data-dfn-type="dictionary"><c- g="">DragEventInit</c-></dfn> : <a id="the-dragevent-interface:mouseeventinit" href="https://w3c.github.io/uievents/#dictdef-mouseeventinit" data-x-internal="mouseeventinit"><c- n="">MouseEventInit</c-></a> {
  <a href="#datatransfer" id="the-dragevent-interface:datatransfer-2"><c- n="">DataTransfer</c-></a>? <c- g="">dataTransfer</c-> = <c- b="">null</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-dragevent-datatransfer" id="dom-dragevent-datatransfer-dev">dataTransfer</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/dataTransfer" title="The DragEvent.dataTransfer property holds the drag operation's data (as a DataTransfer object).">DragEvent/dataTransfer</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>14+</span></span><span class="chrome yes"><span>Chrome</span><span>46+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Partial implementation.">🔰 10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios no"><span>Safari iOS</span><span>No</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the <code id="the-dragevent-interface:datatransfer-3"><a href="#datatransfer">DataTransfer</a></code> object for the event.</p></dd></dl>

  <p class="note">Although, for consistency with other event interfaces, the <code id="the-dragevent-interface:dragevent-3"><a href="#dragevent">DragEvent</a></code>
  interface has a constructor, it is not particularly useful. In particular, there's no way to
  create a useful <code id="the-dragevent-interface:datatransfer-4"><a href="#datatransfer">DataTransfer</a></code> object from script, as <code id="the-dragevent-interface:datatransfer-5"><a href="#datatransfer">DataTransfer</a></code> objects
  have a processing and security model that is coordinated by the browser during drag-and-drops.</p>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DragEvent" id="dom-dragevent-datatransfer" data-dfn-type="attribute"><code>dataTransfer</code></dfn> attribute of the
  <code id="the-dragevent-interface:dragevent-4"><a href="#dragevent">DragEvent</a></code> interface must return the value it was initialized to. It represents the
  context information for the event.</p>
  </div>

  

  

  <div data-algorithm="">
  <p>When a user agent is required to <dfn id="fire-a-dnd-event">fire a DND event</dfn> named <var>e</var> at an element,
  using a particular <a href="#drag-data-store" id="the-dragevent-interface:drag-data-store">drag data store</a>, and optionally with a specific <var>related
  target</var>, the user agent must run the following steps:</p>

  <ol><li>Let <var>dataDragStoreWasChanged</var> be false.</li><li><p>If no specific <var>related target</var> was provided, set <var>related target</var> to
   null.</p></li><li><p>Let <var>window</var> be the <a href="#concept-relevant-global" id="the-dragevent-interface:concept-relevant-global">relevant global object</a> of the
   <code id="the-dragevent-interface:document"><a href="#document">Document</a></code> object of the specified target element.</p></li><li>
    <p>If <var>e</var> is <code id="the-dragevent-interface:event-dnd-dragstart"><a href="#event-dnd-dragstart">dragstart</a></code>, then set the
    <a href="#drag-data-store-mode" id="the-dragevent-interface:drag-data-store-mode">drag data store mode</a> to the <a href="#concept-dnd-rw" id="the-dragevent-interface:concept-dnd-rw">read/write mode</a>
    and set <var>dataDragStoreWasChanged</var> to true.</p>

    <p>If <var>e</var> is <code id="the-dragevent-interface:event-dnd-drop"><a href="#event-dnd-drop">drop</a></code>, set the <a href="#drag-data-store-mode" id="the-dragevent-interface:drag-data-store-mode-2">drag data store
    mode</a> to the <a href="#concept-dnd-ro" id="the-dragevent-interface:concept-dnd-ro">read-only mode</a>.</p>
   </li><li><p>Let <var>dataTransfer</var> be a newly created <code id="the-dragevent-interface:datatransfer-6"><a href="#datatransfer">DataTransfer</a></code> object
   associated with the given <a href="#drag-data-store" id="the-dragevent-interface:drag-data-store-2">drag data store</a>.</p></li><li><p id="effectAllowed-initialisation">Set the <code id="the-dragevent-interface:dom-datatransfer-effectallowed"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code> attribute to the <a href="#drag-data-store" id="the-dragevent-interface:drag-data-store-3">drag data
   store</a>'s <a href="#drag-data-store-allowed-effects-state" id="the-dragevent-interface:drag-data-store-allowed-effects-state">drag data store allowed effects state</a>.</p></li><li>
    <p id="dropEffect-initialisation">Set the <code id="the-dragevent-interface:dom-datatransfer-dropeffect"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code> attribute to "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-none"><a href="#dom-datatransfer-dropeffect-none">none</a></code>" if <var>e</var> is <code id="the-dragevent-interface:event-dnd-dragstart-2"><a href="#event-dnd-dragstart">dragstart</a></code>, <code id="the-dragevent-interface:event-dnd-drag"><a href="#event-dnd-drag">drag</a></code>, or
    <code id="the-dragevent-interface:event-dnd-dragleave"><a href="#event-dnd-dragleave">dragleave</a></code>; to the value corresponding to the
    <a href="#current-drag-operation" id="the-dragevent-interface:current-drag-operation">current drag operation</a> if <var>e</var> is <code id="the-dragevent-interface:event-dnd-drop-2"><a href="#event-dnd-drop">drop</a></code>
    or <code id="the-dragevent-interface:event-dnd-dragend"><a href="#event-dnd-dragend">dragend</a></code>; and to a value based on the <code id="the-dragevent-interface:dom-datatransfer-effectallowed-2"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code> attribute's value and the
    drag-and-drop source, as given by the following table, otherwise (i.e. if <var>e</var> is <code id="the-dragevent-interface:event-dnd-dragenter"><a href="#event-dnd-dragenter">dragenter</a></code> or <code id="the-dragevent-interface:event-dnd-dragover"><a href="#event-dnd-dragover">dragover</a></code>):</p>

    <table><thead><tr><th><code id="the-dragevent-interface:dom-datatransfer-effectallowed-3"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code></th><th><code id="the-dragevent-interface:dom-datatransfer-dropeffect-2"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code></th></tr></thead><tbody><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-none"><a href="#dom-datatransfer-effectallowed-none">none</a></code>"</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-none-2"><a href="#dom-datatransfer-dropeffect-none">none</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-copy"><a href="#dom-datatransfer-effectallowed-copy">copy</a></code>"</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-copy"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-copylink"><a href="#dom-datatransfer-effectallowed-copylink">copyLink</a></code>"</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-copy-2"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>", or, <a href="#concept-platform-dropeffect-override" id="the-dragevent-interface:concept-platform-dropeffect-override">if appropriate</a>, "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-link"><a href="#dom-datatransfer-dropeffect-link">link</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-copymove"><a href="#dom-datatransfer-effectallowed-copymove">copyMove</a></code>"</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-copy-3"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>", or, <a href="#concept-platform-dropeffect-override" id="the-dragevent-interface:concept-platform-dropeffect-override-2">if appropriate</a>, "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-move"><a href="#dom-datatransfer-dropeffect-move">move</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-all"><a href="#dom-datatransfer-effectallowed-all">all</a></code>"</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-copy-4"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>", or, <a href="#concept-platform-dropeffect-override" id="the-dragevent-interface:concept-platform-dropeffect-override-3">if appropriate</a>, either "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-link-2"><a href="#dom-datatransfer-dropeffect-link">link</a></code>" or "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-move-2"><a href="#dom-datatransfer-dropeffect-move">move</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-link"><a href="#dom-datatransfer-effectallowed-link">link</a></code>"</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-link-3"><a href="#dom-datatransfer-dropeffect-link">link</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-linkmove"><a href="#dom-datatransfer-effectallowed-linkmove">linkMove</a></code>"</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-link-4"><a href="#dom-datatransfer-dropeffect-link">link</a></code>", or, <a href="#concept-platform-dropeffect-override" id="the-dragevent-interface:concept-platform-dropeffect-override-4">if appropriate</a>, "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-move-3"><a href="#dom-datatransfer-dropeffect-move">move</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-move"><a href="#dom-datatransfer-effectallowed-move">move</a></code>"</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-move-4"><a href="#dom-datatransfer-dropeffect-move">move</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-uninitialized"><a href="#dom-datatransfer-effectallowed-uninitialized">uninitialized</a></code>" when what is being dragged is a selection from a text control</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-move-5"><a href="#dom-datatransfer-dropeffect-move">move</a></code>", or, <a href="#concept-platform-dropeffect-override" id="the-dragevent-interface:concept-platform-dropeffect-override-5">if appropriate</a>, either "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-copy-5"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>" or "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-link-5"><a href="#dom-datatransfer-dropeffect-link">link</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-uninitialized-2"><a href="#dom-datatransfer-effectallowed-uninitialized">uninitialized</a></code>" when what is being dragged is a selection</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-copy-6"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>", or, <a href="#concept-platform-dropeffect-override" id="the-dragevent-interface:concept-platform-dropeffect-override-6">if appropriate</a>, either "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-link-6"><a href="#dom-datatransfer-dropeffect-link">link</a></code>" or "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-move-6"><a href="#dom-datatransfer-dropeffect-move">move</a></code>"</td></tr><tr><td>"<code id="the-dragevent-interface:dom-datatransfer-effectallowed-uninitialized-3"><a href="#dom-datatransfer-effectallowed-uninitialized">uninitialized</a></code>" when what is being dragged is an <code id="the-dragevent-interface:the-a-element"><a href="#the-a-element">a</a></code> element with an <code id="the-dragevent-interface:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-link-7"><a href="#dom-datatransfer-dropeffect-link">link</a></code>", or, <a href="#concept-platform-dropeffect-override" id="the-dragevent-interface:concept-platform-dropeffect-override-7">if appropriate</a>, either "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-copy-7"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>" or "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-move-7"><a href="#dom-datatransfer-dropeffect-move">move</a></code>"</td></tr><tr><td>Any other case</td><td>"<code id="the-dragevent-interface:dom-datatransfer-dropeffect-copy-8"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>", or, <a href="#concept-platform-dropeffect-override" id="the-dragevent-interface:concept-platform-dropeffect-override-8">if appropriate</a>, either "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-link-8"><a href="#dom-datatransfer-dropeffect-link">link</a></code>" or "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-move-8"><a href="#dom-datatransfer-dropeffect-move">move</a></code>"</td></tr></tbody></table>

    <p>Where the table above provides <dfn id="concept-platform-dropeffect-override">possibly
    appropriate alternatives</dfn>, user agents may instead use the listed alternative values if
    platform conventions dictate that the user has requested those alternate effects.</p>

    <p class="example">For example, Windows platform conventions are such that dragging while
    holding the "alt" key indicates a preference for linking the data, rather than moving or copying
    it. Therefore, on a Windows system, if "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-link-9"><a href="#dom-datatransfer-dropeffect-link">link</a></code>" is an option according to
    the table above while the "alt" key is depressed, the user agent could select that instead of
    "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-copy-9"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>" or "<code id="the-dragevent-interface:dom-datatransfer-dropeffect-move-9"><a href="#dom-datatransfer-dropeffect-move">move</a></code>".</p>
   </li><li><p>Let <var>event</var> be the result of <a id="the-dragevent-interface:creating-an-event" href="https://dom.spec.whatwg.org/#concept-event-create" data-x-internal="creating-an-event">creating an event</a> using
   <code id="the-dragevent-interface:dragevent-5"><a href="#dragevent">DragEvent</a></code>.</p></li><li><p>Initialize <var>event</var>'s <code id="the-dragevent-interface:dom-event-type"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute to
   <var>e</var>, its <code id="the-dragevent-interface:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute to true, its <code id="the-dragevent-interface:dom-uievent-view"><a data-x-internal="dom-uievent-view" href="https://w3c.github.io/uievents/#dom-uievent-view">view</a></code> attribute to <var>window</var>, its <code id="the-dragevent-interface:dom-mouseevent-relatedtarget"><a data-x-internal="dom-mouseevent-relatedtarget" href="https://w3c.github.io/uievents/#dom-mouseevent-relatedtarget">relatedTarget</a></code> attribute to <var>related
   target</var>, and its <code id="the-dragevent-interface:dom-dragevent-datatransfer-2"><a href="#dom-dragevent-datatransfer">dataTransfer</a></code> attribute to
   <var>dataTransfer</var>.</p></li><li><p>If <var>e</var> is not <code id="the-dragevent-interface:event-dnd-dragleave-2"><a href="#event-dnd-dragleave">dragleave</a></code> or <code id="the-dragevent-interface:event-dnd-dragend-2"><a href="#event-dnd-dragend">dragend</a></code>, then initialize <var>event</var>'s <code id="the-dragevent-interface:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute to true.</p></li><li>
    <p>Initialize <var>event</var>'s mouse and key attributes according to the state of
    the input devices as they would be for user interaction events.</p>

    

    <p>If there is no relevant pointing device, then initialize <var>event</var>'s <code>screenX</code>, <code>screenY</code>, <code id="the-dragevent-interface:mouseevent-clientx"><a data-x-internal="mouseevent-clientx" href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clientx">clientX</a></code>, <code id="the-dragevent-interface:mouseevent-clienty"><a data-x-internal="mouseevent-clienty" href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clienty">clientY</a></code>,
    and <code>button</code> attributes to 0.</p>
   </li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="the-dragevent-interface:concept-event-dispatch" data-x-internal="concept-event-dispatch">Dispatch</a> <var>event</var> at the specified
   target element.</p></li><li><p>Set the <a href="#drag-data-store-allowed-effects-state" id="the-dragevent-interface:drag-data-store-allowed-effects-state-2">drag data store allowed effects state</a> to the current value of
   <var>dataTransfer</var>'s <code id="the-dragevent-interface:dom-datatransfer-effectallowed-4"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code>
   attribute. (It can only have changed value if <var>e</var> is <code id="the-dragevent-interface:event-dnd-dragstart-3"><a href="#event-dnd-dragstart">dragstart</a></code>.)</p></li><li><p>If <var>dataDragStoreWasChanged</var> is true, then set the <a href="#drag-data-store-mode" id="the-dragevent-interface:drag-data-store-mode-3">drag data store
   mode</a> back to the <a href="#concept-dnd-p" id="the-dragevent-interface:concept-dnd-p">protected mode</a>.</p></li><li><p>Break the association between <var>dataTransfer</var> and the <a href="#drag-data-store" id="the-dragevent-interface:drag-data-store-4">drag data
   store</a>.</p></li></ol>
  </div>

  


  

  <h4 id="drag-and-drop-processing-model"><span class="secno">6.11.5</span> Processing model<a href="#drag-and-drop-processing-model" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When the user attempts to begin a drag operation, the user agent must run the following steps.
  User agents must act as if these steps were run even if the drag actually started in another
  document or application and the user agent was not aware that the drag was occurring until it
  intersected with a document under the user agent's purview.</p>

  <ol><li>
    <p>Determine what is being dragged, as follows:</p>

    <p>If the drag operation was invoked on a selection, then it is the selection that is being
    dragged.</p>

    <p>Otherwise, if the drag operation was invoked on a <code id="drag-and-drop-processing-model:document"><a href="#document">Document</a></code>, it is the first
    element, going up the ancestor chain, starting at the node that the user tried to drag, that has
    the IDL attribute <code id="drag-and-drop-processing-model:dom-draggable"><a href="#dom-draggable">draggable</a></code> set to true. If there is no such
    element, then nothing is being dragged; return, the drag-and-drop operation is never
    started.</p>

    <p>Otherwise, the drag operation was invoked outside the user agent's purview. What is being
    dragged is defined by the document or application where the drag was started.</p>

    <p class="note"><code id="drag-and-drop-processing-model:the-img-element"><a href="#the-img-element">img</a></code> elements and <code id="drag-and-drop-processing-model:the-a-element"><a href="#the-a-element">a</a></code> elements with an <code id="drag-and-drop-processing-model:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute have their <code id="drag-and-drop-processing-model:dom-draggable-2"><a href="#dom-draggable">draggable</a></code> attribute set to true by default.</p>
   </li><li><p><a href="#create-a-drag-data-store" id="drag-and-drop-processing-model:create-a-drag-data-store">Create a drag data store</a>. All the DND events fired subsequently by the steps
   in this section must use this <a href="#drag-data-store" id="drag-and-drop-processing-model:drag-data-store">drag data store</a>.</p></li><li>
    <p>Establish which DOM node is the <dfn id="source-node">source node</dfn>, as follows:</p>

    <p>If it is a selection that is being dragged, then the <a href="#source-node" id="drag-and-drop-processing-model:source-node">source node</a> is the
    <code id="drag-and-drop-processing-model:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node that the user started the drag on (typically the <code id="drag-and-drop-processing-model:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node
    that the user originally clicked). If the user did not specify a particular node, for example if
    the user just told the user agent to begin a drag of "the selection", then the <a href="#source-node" id="drag-and-drop-processing-model:source-node-2">source
    node</a> is the first <code id="drag-and-drop-processing-model:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node containing a part of the selection.</p>

    <p>Otherwise, if it is an element that is being dragged, then the <a href="#source-node" id="drag-and-drop-processing-model:source-node-3">source node</a> is
    the element that is being dragged.</p>

    <p>Otherwise, the <a href="#source-node" id="drag-and-drop-processing-model:source-node-4">source node</a> is part of another document or application. When this
    specification requires that an event be dispatched at the <a href="#source-node" id="drag-and-drop-processing-model:source-node-5">source node</a> in this case,
    the user agent must instead follow the platform-specific conventions relevant to that
    situation.</p>

    <p class="note">Multiple events are fired on the <a href="#source-node" id="drag-and-drop-processing-model:source-node-6">source node</a> during the course of
    the drag-and-drop operation.</p>
   </li><li>
    <p>Determine the <dfn id="list-of-dragged-nodes">list of dragged nodes</dfn>, as follows:</p>

    <p>If it is a selection that is being dragged, then the <a href="#list-of-dragged-nodes" id="drag-and-drop-processing-model:list-of-dragged-nodes">list of dragged nodes</a>
    contains, in <a id="drag-and-drop-processing-model:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, every node that is partially or completely included in the
    selection (including all their ancestors).</p>

    <p>Otherwise, the <a href="#list-of-dragged-nodes" id="drag-and-drop-processing-model:list-of-dragged-nodes-2">list of dragged nodes</a> contains only the <a href="#source-node" id="drag-and-drop-processing-model:source-node-7">source node</a>,
    if any.</p>
   </li><li>
    <p>If it is a selection that is being dragged, then add an item to the <a href="#drag-data-store-item-list" id="drag-and-drop-processing-model:drag-data-store-item-list">drag data store
    item list</a>, with its properties set as follows:</p>

    <dl><dt><a href="#the-drag-data-item-type-string" id="drag-and-drop-processing-model:the-drag-data-item-type-string">The drag data item type string</a>
     </dt><dd>"<code id="drag-and-drop-processing-model:text/plain"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>"</dd><dt><a href="#the-drag-data-item-kind" id="drag-and-drop-processing-model:the-drag-data-item-kind">The drag data item kind</a>
     </dt><dd><i>Text</i></dd><dt>The actual data</dt><dd>The text of the selection</dd></dl>

    <p>Otherwise, if any files are being dragged, then add one item per file to the <a href="#drag-data-store-item-list" id="drag-and-drop-processing-model:drag-data-store-item-list-2">drag data
    store item list</a>, with their properties set as follows:</p>

    <dl><dt><a href="#the-drag-data-item-type-string" id="drag-and-drop-processing-model:the-drag-data-item-type-string-2">The drag data item type string</a>
     </dt><dd>The MIME type of the file, if known, or "<code id="drag-and-drop-processing-model:application/octet-stream"><a data-x-internal="application/octet-stream" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1">application/octet-stream</a></code>" otherwise.</dd><dt><a href="#the-drag-data-item-kind" id="drag-and-drop-processing-model:the-drag-data-item-kind-2">The drag data item kind</a>
     </dt><dd><i>File</i></dd><dt>The actual data</dt><dd>The file's contents and name.</dd></dl>

    <p class="note">Dragging files can currently only happen from outside a <a href="#navigable" id="drag-and-drop-processing-model:navigable">navigable</a>,
    for example from a file system manager application.</p>

    <p>If the drag initiated outside of the application, the user agent must add items to the
    <a href="#drag-data-store-item-list" id="drag-and-drop-processing-model:drag-data-store-item-list-3">drag data store item list</a> as appropriate for the data being dragged, honoring
    platform conventions where appropriate; however, if the platform conventions do not use <a href="https://mimesniff.spec.whatwg.org/#mime-type" id="drag-and-drop-processing-model:mime-type" data-x-internal="mime-type">MIME types</a> to label dragged data, the user agent must make a
    best-effort attempt to map the types to MIME types, and, in any case, all the <a href="#the-drag-data-item-type-string" id="drag-and-drop-processing-model:the-drag-data-item-type-string-3">drag data item type strings</a> must be <a id="drag-and-drop-processing-model:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
    lowercase</a>.</p>

    <p>User agents may also add one or more items representing the selection or dragged element(s)
    in other forms, e.g. as HTML.</p>
   </li><li>
    <p>If the <a href="#list-of-dragged-nodes" id="drag-and-drop-processing-model:list-of-dragged-nodes-3">list of dragged nodes</a> is not empty, then <a href="#extracting-json" id="drag-and-drop-processing-model:extracting-json">extract the microdata from those nodes into a JSON form</a>, and add one item to the
    <a href="#drag-data-store-item-list" id="drag-and-drop-processing-model:drag-data-store-item-list-4">drag data store item list</a>, with its properties set as follows:</p>

    <dl><dt><a href="#the-drag-data-item-type-string" id="drag-and-drop-processing-model:the-drag-data-item-type-string-4">The drag data item type string</a>
     </dt><dd><code id="drag-and-drop-processing-model:application/microdata+json"><a href="#application/microdata+json">application/microdata+json</a></code></dd><dt><a href="#the-drag-data-item-kind" id="drag-and-drop-processing-model:the-drag-data-item-kind-3">The drag data item kind</a>
     </dt><dd><i>Text</i></dd><dt>The actual data</dt><dd>The resulting JSON string.</dd></dl>
   </li><li>
    <p>Run the following substeps:</p>

    <ol><li><p>Let <var>urls</var> be « ».</p></li><li>
      <p>For each <var>node</var> in the <a href="#list-of-dragged-nodes" id="drag-and-drop-processing-model:list-of-dragged-nodes-4">list of dragged nodes</a>:</p>

      <dl><dt>If the node is an <code id="drag-and-drop-processing-model:the-a-element-2"><a href="#the-a-element">a</a></code> element with an <code id="drag-and-drop-processing-model:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> attribute</dt><dd>Add to <var>urls</var> the result of <a href="#encoding-parsing-and-serializing-a-url" id="drag-and-drop-processing-model:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing a URL</a>
       given the element's <code id="drag-and-drop-processing-model:attr-hyperlink-href-3"><a href="#attr-hyperlink-href">href</a></code> content attribute's value,
       relative to the element's <a id="drag-and-drop-processing-model:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</dd><dt>If the node is an <code id="drag-and-drop-processing-model:the-img-element-2"><a href="#the-img-element">img</a></code> element with a <code id="drag-and-drop-processing-model:attr-img-src"><a href="#attr-img-src">src</a></code>
       attribute</dt><dd>Add to <var>urls</var> the result of <a href="#encoding-parsing-and-serializing-a-url" id="drag-and-drop-processing-model:encoding-parsing-and-serializing-a-url-2">encoding-parsing-and-serializing a URL</a>
       given the element's <code id="drag-and-drop-processing-model:attr-img-src-2"><a href="#attr-img-src">src</a></code> content attribute's value, relative to
       the element's <a id="drag-and-drop-processing-model:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</dd></dl>
     </li><li><p>If <var>urls</var> is still empty, then return.</p></li><li><p>Let <var>url string</var> be the result of concatenating the strings in <var>urls</var>,
     in the order they were added, separated by a U+000D CARRIAGE RETURN U+000A LINE FEED character
     pair (CRLF).</p></li><li><p>Add one item to the <a href="#drag-data-store-item-list" id="drag-and-drop-processing-model:drag-data-store-item-list-5">drag data store item list</a>, with its properties set as
     follows:</p>

      <dl><dt><a href="#the-drag-data-item-type-string" id="drag-and-drop-processing-model:the-drag-data-item-type-string-5">The drag data item type string</a>
       </dt><dd><code id="drag-and-drop-processing-model:text/uri-list"><a href="#text/uri-list">text/uri-list</a></code></dd><dt><a href="#the-drag-data-item-kind" id="drag-and-drop-processing-model:the-drag-data-item-kind-4">The drag data item kind</a>
       </dt><dd><i>Text</i></dd><dt>The actual data</dt><dd><var>url string</var></dd></dl>
     </li></ol>
   </li><li>
    <p>Update the <a href="#drag-data-store-default-feedback" id="drag-and-drop-processing-model:drag-data-store-default-feedback">drag data store default feedback</a> as appropriate for the user agent
    (if the user is dragging the selection, then the selection would likely be the basis for this
    feedback; if the user is dragging an element, then that element's rendering would be used; if
    the drag began outside the user agent, then the platform conventions for determining the drag
    feedback should be used).</p>
   </li><li>
    <p><a href="#fire-a-dnd-event" id="drag-and-drop-processing-model:fire-a-dnd-event">Fire a DND event</a> named <code id="drag-and-drop-processing-model:event-dnd-dragstart"><a href="#event-dnd-dragstart">dragstart</a></code> at the
    <a href="#source-node" id="drag-and-drop-processing-model:source-node-8">source node</a>.</p>

    <p>If the event is canceled, then the drag-and-drop operation should not occur; return.</p>
    

    <p class="note">Since events with no event listeners registered are, almost by definition, never
    canceled, drag-and-drop is always available to the user if the author does not specifically
    prevent it.</p>
   </li><li><p><a id="drag-and-drop-processing-model:fire-a-pointer-event" href="https://w3c.github.io/pointerevents/#dfn-fire-a-pointer-event" data-x-internal="fire-a-pointer-event">Fire a pointer event</a> at the <a href="#source-node" id="drag-and-drop-processing-model:source-node-9">source node</a> named <code id="drag-and-drop-processing-model:event-pointercancel"><a data-x-internal="event-pointercancel" href="https://w3c.github.io/pointerevents/#the-pointercancel-event">pointercancel</a></code>, and fire any other follow-up events as
   required by <cite>Pointer Events</cite>. <a href="#refsPOINTEREVENTS">[POINTEREVENTS]</a></p></li><li>
    <p><a href="#initiate-the-drag-and-drop-operation" id="drag-and-drop-processing-model:initiate-the-drag-and-drop-operation">Initiate the drag-and-drop operation</a> in a manner consistent with platform
    conventions, and as described below.</p>

    <p id="base-dnd-feedback">The drag-and-drop feedback must be generated from the first of the
    following sources that is available:</p>

    <ol><li>The <a href="#drag-data-store-bitmap" id="drag-and-drop-processing-model:drag-data-store-bitmap">drag data store bitmap</a>, if any. In this case, the <a href="#drag-data-store-hot-spot-coordinate" id="drag-and-drop-processing-model:drag-data-store-hot-spot-coordinate">drag data store
     hot spot coordinate</a> should be used as hints for where to put the cursor relative to the
     resulting image. The values are expressed as distances in <a href="https://drafts.csswg.org/css-values/#px" id="drag-and-drop-processing-model:'px'" data-x-internal="'px'">CSS pixels</a>
     from the left side and from the top side of the image respectively. <a href="#refsCSS">[CSS]</a></li><li>The <a href="#drag-data-store-default-feedback" id="drag-and-drop-processing-model:drag-data-store-default-feedback-2">drag data store default feedback</a>.</li></ol>
   </li></ol>
  </div>

  <p>From the moment that the user agent is to <dfn id="initiate-the-drag-and-drop-operation">initiate the drag-and-drop operation</dfn>,
  until the end of the drag-and-drop operation, device input events (e.g. mouse and keyboard events)
  must be suppressed.</p>

  <p>During the drag operation, the element directly indicated by the user as the drop target is
  called the <dfn id="immediate-user-selection">immediate user selection</dfn>. (Only elements can be selected by the user; other
  nodes must not be made available as drop targets.) However, the <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection">immediate user
  selection</a> is not necessarily the <dfn id="current-target-element">current target element</dfn>, which is the element
  currently selected for the drop part of the drag-and-drop operation.</p>

  <p>The <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-2">immediate user selection</a> changes as the user selects different elements
  (either by pointing at them with a pointing device, or by selecting them in some other way). The
  <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element">current target element</a> changes when the <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-3">immediate user selection</a>
  changes, based on the results of event listeners in the document, as described below.</p>

  <p>Both the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-2">current target element</a> and the <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-4">immediate user selection</a> can
  be null, which means no target element is selected. They can also both be elements in other
  (DOM-based) documents, or other (non-web) programs altogether. (For example, a user could drag
  text to a word-processor.) The <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-3">current target element</a> is initially null.</p>

  <p>In addition, there is also a <dfn id="current-drag-operation">current drag operation</dfn>, which can take on the values
  "<dfn id="concept-current-drag-operation-none"><code>none</code></dfn>", "<dfn id="concept-current-drag-operation-copy"><code>copy</code></dfn>", "<dfn id="concept-current-drag-operation-link"><code>link</code></dfn>", and "<dfn id="concept-current-drag-operation-move"><code>move</code></dfn>". Initially, it has the value
  "<code id="drag-and-drop-processing-model:concept-current-drag-operation-none"><a href="#concept-current-drag-operation-none">none</a></code>". It is updated by the user agent
  as described in the steps below.</p>

  <div data-algorithm="">
  <p>User agents must, as soon as the drag operation is <a href="#initiate-the-drag-and-drop-operation" id="drag-and-drop-processing-model:initiate-the-drag-and-drop-operation-2">initiated</a> and every 350ms (±200ms) thereafter for as long as the drag
  operation is ongoing, <a href="#queue-a-task" id="drag-and-drop-processing-model:queue-a-task">queue a task</a> to perform the following steps in sequence:</p>

  <ol><li>
    <p>If the user agent is still performing the previous iteration of the sequence (if any) when
    the next iteration becomes due, return for this iteration (effectively "skipping
    missed frames" of the drag-and-drop operation).</p>
   </li><li>
    <p><a href="#fire-a-dnd-event" id="drag-and-drop-processing-model:fire-a-dnd-event-2">Fire a DND event</a> named <code id="drag-and-drop-processing-model:event-dnd-drag"><a href="#event-dnd-drag">drag</a></code> at the
    <a href="#source-node" id="drag-and-drop-processing-model:source-node-10">source node</a>. If this event is canceled, the user agent must set the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation">current
    drag operation</a> to "<code id="drag-and-drop-processing-model:concept-current-drag-operation-none-2"><a href="#concept-current-drag-operation-none">none</a></code>" (no
    drag operation).</p>
   </li><li>
    <p>If the <code id="drag-and-drop-processing-model:event-dnd-drag-2"><a href="#event-dnd-drag">drag</a></code> event was not canceled and the user has not
    ended the drag-and-drop operation, check the state of the drag-and-drop operation, as
    follows:</p>

    <ol><li>
      <p>If the user is indicating a different <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-5">immediate user selection</a> than during the
      last iteration (or if this is the first iteration), and if this <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-6">immediate user
      selection</a> is not the same as the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-4">current target element</a>, then update the
      <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-5">current target element</a> as follows:</p>

      <dl class="switch"><dt>If the new <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-7">immediate user selection</a> is null</dt><dd><p>Set the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-6">current target element</a> to null also.</p></dd><dt>If the new <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-8">immediate user selection</a> is in a non-DOM document or
       application</dt><dd><p>Set the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-7">current target element</a> to the <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-9">immediate user
       selection</a>.</p></dd><dt>Otherwise</dt><dd>
        <p><a href="#fire-a-dnd-event" id="drag-and-drop-processing-model:fire-a-dnd-event-3">Fire a DND event</a> named <code id="drag-and-drop-processing-model:event-dnd-dragenter"><a href="#event-dnd-dragenter">dragenter</a></code>
        at the <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-10">immediate user selection</a>.</p>

        <p>If the event is canceled, then set the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-8">current target element</a> to the
        <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-11">immediate user selection</a>.</p>

        <p>Otherwise, run the appropriate step from the following list:</p>

        <dl class="switch"><dt>If the <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-12">immediate user selection</a> is a text control (e.g.,
         <code id="drag-and-drop-processing-model:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>, or an <code id="drag-and-drop-processing-model:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="drag-and-drop-processing-model:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="drag-and-drop-processing-model:text-(type=text)-state-and-search-state-(type=search)">Text</a> state) or an <a href="#editing-host" id="drag-and-drop-processing-model:editing-host">editing host</a> or
         <a id="drag-and-drop-processing-model:editable" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a> element, and the <a href="#drag-data-store-item-list" id="drag-and-drop-processing-model:drag-data-store-item-list-6">drag data store item list</a> has an item
         with <a href="#the-drag-data-item-type-string" id="drag-and-drop-processing-model:the-drag-data-item-type-string-6">the drag data item type string</a> "<code id="drag-and-drop-processing-model:text/plain-2"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>" and <a href="#the-drag-data-item-kind" id="drag-and-drop-processing-model:the-drag-data-item-kind-5">the
         drag data item kind</a> <i>text</i></dt><dd><p>Set the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-9">current target element</a> to the <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-13">immediate user
         selection</a> anyway.</p></dd><dt>If the <a href="#immediate-user-selection" id="drag-and-drop-processing-model:immediate-user-selection-14">immediate user selection</a> is <a href="#the-body-element-2" id="drag-and-drop-processing-model:the-body-element-2">the body element</a></dt><dd><p>Leave the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-10">current target element</a> unchanged.</p></dd><dt>Otherwise</dt><dd>
          <p><a href="#fire-a-dnd-event" id="drag-and-drop-processing-model:fire-a-dnd-event-4">Fire a DND event</a> named <code id="drag-and-drop-processing-model:event-dnd-dragenter-2"><a href="#event-dnd-dragenter">dragenter</a></code>
          at <a href="#the-body-element-2" id="drag-and-drop-processing-model:the-body-element-2-2">the body element</a>, if there is one, or at the <code id="drag-and-drop-processing-model:document-2"><a href="#document">Document</a></code> object,
          if not. Then, set the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-11">current target element</a> to <a href="#the-body-element-2" id="drag-and-drop-processing-model:the-body-element-2-3">the body
          element</a>, regardless of whether that event was canceled or not.</p>
         </dd></dl>
       </dd></dl>
     </li><li>
      <p>If the previous step caused the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-12">current target element</a> to change, and if the
      previous target element was not null or a part of a non-DOM document, then <a href="#fire-a-dnd-event" id="drag-and-drop-processing-model:fire-a-dnd-event-5">fire a DND
      event</a> named <code id="drag-and-drop-processing-model:event-dnd-dragleave"><a href="#event-dnd-dragleave">dragleave</a></code> at the previous target
      element, with the new <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-13">current target element</a> as the specific <i>related
      target</i>.</p>
     </li><li>
      <p>If the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-14">current target element</a> is a DOM element, then <a href="#fire-a-dnd-event" id="drag-and-drop-processing-model:fire-a-dnd-event-6">fire a DND
      event</a> named <code id="drag-and-drop-processing-model:event-dnd-dragover"><a href="#event-dnd-dragover">dragover</a></code> at this <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-15">current
      target element</a>.</p>

      <p>If the <code id="drag-and-drop-processing-model:event-dnd-dragover-2"><a href="#event-dnd-dragover">dragover</a></code> event is not canceled, run the
      appropriate step from the following list:</p>

      <dl class="switch"><dt>If the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-16">current target element</a> is a text control (e.g.,
       <code id="drag-and-drop-processing-model:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code>, or an <code id="drag-and-drop-processing-model:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="drag-and-drop-processing-model:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="drag-and-drop-processing-model:text-(type=text)-state-and-search-state-(type=search)-2">Text</a> state) or an <a href="#editing-host" id="drag-and-drop-processing-model:editing-host-2">editing host</a> or
       <a id="drag-and-drop-processing-model:editable-2" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a> element, and the <a href="#drag-data-store-item-list" id="drag-and-drop-processing-model:drag-data-store-item-list-7">drag data store item list</a> has an item
       with <a href="#the-drag-data-item-type-string" id="drag-and-drop-processing-model:the-drag-data-item-type-string-7">the drag data item type string</a> "<code id="drag-and-drop-processing-model:text/plain-3"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>" and <a href="#the-drag-data-item-kind" id="drag-and-drop-processing-model:the-drag-data-item-kind-6">the drag
       data item kind</a> <i>text</i></dt><dd><p>Set the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-2">current drag operation</a> to either "<code id="drag-and-drop-processing-model:concept-current-drag-operation-copy"><a href="#concept-current-drag-operation-copy">copy</a></code>" or "<code id="drag-and-drop-processing-model:concept-current-drag-operation-move"><a href="#concept-current-drag-operation-move">move</a></code>", as appropriate given the platform
       conventions.</p></dd><dt>Otherwise</dt><dd><p>Reset the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-3">current drag operation</a> to "<code id="drag-and-drop-processing-model:concept-current-drag-operation-none-3"><a href="#concept-current-drag-operation-none">none</a></code>".</p></dd></dl>

      <p>Otherwise (if the <code id="drag-and-drop-processing-model:event-dnd-dragover-3"><a href="#event-dnd-dragover">dragover</a></code> event <em>is</em>
      canceled), set the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-4">current drag operation</a> based on the values of the <code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code> and <code id="drag-and-drop-processing-model:dom-datatransfer-dropeffect"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code> attributes of the
      <code id="drag-and-drop-processing-model:dragevent"><a href="#dragevent">DragEvent</a></code> object's <code id="drag-and-drop-processing-model:dom-dragevent-datatransfer"><a href="#dom-dragevent-datatransfer">dataTransfer</a></code>
      object as they stood after the event <a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="drag-and-drop-processing-model:concept-event-dispatch" data-x-internal="concept-event-dispatch">dispatch</a>
      finished, as per the following table:</p>

      <table><thead><tr><th><code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-2"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code></th><th><code id="drag-and-drop-processing-model:dom-datatransfer-dropeffect-2"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code></th><th>Drag operation</th></tr></thead><tbody><tr><td>"<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-uninitialized"><a href="#dom-datatransfer-effectallowed-uninitialized">uninitialized</a></code>", "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-copy"><a href="#dom-datatransfer-effectallowed-copy">copy</a></code>", "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-copylink"><a href="#dom-datatransfer-effectallowed-copylink">copyLink</a></code>", "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-copymove"><a href="#dom-datatransfer-effectallowed-copymove">copyMove</a></code>", or "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-all"><a href="#dom-datatransfer-effectallowed-all">all</a></code>"</td><td>"<code id="drag-and-drop-processing-model:dom-datatransfer-dropeffect-copy"><a href="#dom-datatransfer-dropeffect-copy">copy</a></code>"</td><td>"<code id="drag-and-drop-processing-model:concept-current-drag-operation-copy-2"><a href="#concept-current-drag-operation-copy">copy</a></code>"</td></tr><tr><td>"<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-uninitialized-2"><a href="#dom-datatransfer-effectallowed-uninitialized">uninitialized</a></code>", "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-link"><a href="#dom-datatransfer-effectallowed-link">link</a></code>", "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-copylink-2"><a href="#dom-datatransfer-effectallowed-copylink">copyLink</a></code>", "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-linkmove"><a href="#dom-datatransfer-effectallowed-linkmove">linkMove</a></code>", or "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-all-2"><a href="#dom-datatransfer-effectallowed-all">all</a></code>"</td><td>"<code id="drag-and-drop-processing-model:dom-datatransfer-dropeffect-link"><a href="#dom-datatransfer-dropeffect-link">link</a></code>"</td><td>"<code id="drag-and-drop-processing-model:concept-current-drag-operation-link"><a href="#concept-current-drag-operation-link">link</a></code>"</td></tr><tr><td>"<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-uninitialized-3"><a href="#dom-datatransfer-effectallowed-uninitialized">uninitialized</a></code>", "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-move"><a href="#dom-datatransfer-effectallowed-move">move</a></code>", "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-copymove-2"><a href="#dom-datatransfer-effectallowed-copymove">copyMove</a></code>", "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-linkmove-2"><a href="#dom-datatransfer-effectallowed-linkmove">linkMove</a></code>", or "<code id="drag-and-drop-processing-model:dom-datatransfer-effectallowed-all-3"><a href="#dom-datatransfer-effectallowed-all">all</a></code>"</td><td>"<code id="drag-and-drop-processing-model:dom-datatransfer-dropeffect-move"><a href="#dom-datatransfer-dropeffect-move">move</a></code>"</td><td>"<code id="drag-and-drop-processing-model:concept-current-drag-operation-move-2"><a href="#concept-current-drag-operation-move">move</a></code>"</td></tr><tr><td colspan="2">Any other case</td><td>"<code id="drag-and-drop-processing-model:concept-current-drag-operation-none-4"><a href="#concept-current-drag-operation-none">none</a></code>"</td></tr></tbody></table>
     </li><li>
      <p>Otherwise, if the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-17">current target element</a> is not a DOM element, use
      platform-specific mechanisms to determine what drag operation is being performed (none, copy,
      link, or move), and set the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-5">current drag operation</a> accordingly.</p>
     </li><li>
      <p>Update the drag feedback (e.g. the mouse cursor) to match the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-6">current drag
      operation</a>, as follows:</p>

      <table><thead><tr><th>Drag operation</th><th>Feedback</th></tr></thead><tbody><tr><td>"<code id="drag-and-drop-processing-model:concept-current-drag-operation-copy-3"><a href="#concept-current-drag-operation-copy">copy</a></code>"</td><td>Data will be copied if dropped here.</td></tr><tr><td>"<code id="drag-and-drop-processing-model:concept-current-drag-operation-link-2"><a href="#concept-current-drag-operation-link">link</a></code>"</td><td>Data will be linked if dropped here.</td></tr><tr><td>"<code id="drag-and-drop-processing-model:concept-current-drag-operation-move-3"><a href="#concept-current-drag-operation-move">move</a></code>"</td><td>Data will be moved if dropped here.</td></tr><tr><td>"<code id="drag-and-drop-processing-model:concept-current-drag-operation-none-5"><a href="#concept-current-drag-operation-none">none</a></code>"</td><td>No operation allowed, dropping here will cancel the drag-and-drop operation.</td></tr></tbody></table>
     </li></ol>
   </li><li>
    <p>Otherwise, if the user ended the drag-and-drop operation (e.g. by releasing the mouse button
    in a mouse-driven drag-and-drop interface), or if the <code id="drag-and-drop-processing-model:event-dnd-drag-3"><a href="#event-dnd-drag">drag</a></code>
    event was canceled, then this will be the last iteration. Run the following steps, then stop the
    drag-and-drop operation:</p>

    <ol><li>
      <p>If the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-7">current drag operation</a> is "<code id="drag-and-drop-processing-model:concept-current-drag-operation-none-6"><a href="#concept-current-drag-operation-none">none</a></code>" (no drag operation), or if the user
      ended the drag-and-drop operation by canceling it (e.g. by hitting the <kbd><kbd>Escape</kbd></kbd> key),
      or if the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-18">current target element</a> is null, then the drag operation failed. Run
      these substeps:</p>

      <ol><li><p>Let <var>dropped</var> be false.</p></li><li><p>If the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-19">current target element</a> is a DOM element, <a href="#fire-a-dnd-event" id="drag-and-drop-processing-model:fire-a-dnd-event-7">fire a DND
       event</a> named <code id="drag-and-drop-processing-model:event-dnd-dragleave-2"><a href="#event-dnd-dragleave">dragleave</a></code> at it; otherwise, if
       it is not null, use platform-specific conventions for drag cancelation.</p></li><li><p>Set the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-8">current drag operation</a> to "<code id="drag-and-drop-processing-model:concept-current-drag-operation-none-7"><a href="#concept-current-drag-operation-none">none</a></code>".</p></li></ol>

      <p>Otherwise, the drag operation might be a success; run these substeps:</p>

      <ol><li><p>Let <var>dropped</var> be true.</p></li><li><p>If the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-20">current target element</a> is a DOM element, <a href="#fire-a-dnd-event" id="drag-and-drop-processing-model:fire-a-dnd-event-8">fire a DND
       event</a> named <code id="drag-and-drop-processing-model:event-dnd-drop"><a href="#event-dnd-drop">drop</a></code> at it; otherwise, use
       platform-specific conventions for indicating a drop.</p></li><li>
        <p>If the event is canceled, set the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-9">current drag operation</a> to the value of the
        <code id="drag-and-drop-processing-model:dom-datatransfer-dropeffect-3"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code> attribute of the
        <code id="drag-and-drop-processing-model:dragevent-2"><a href="#dragevent">DragEvent</a></code> object's <code id="drag-and-drop-processing-model:dom-dragevent-datatransfer-2"><a href="#dom-dragevent-datatransfer">dataTransfer</a></code>
        object as it stood after the event <a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="drag-and-drop-processing-model:concept-event-dispatch-2" data-x-internal="concept-event-dispatch">dispatch</a>
        finished.</p>

        <p>Otherwise, the event is not canceled; perform the event's default action, which depends
        on the exact target as follows:</p>

        <dl class="switch"><dt>If the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-21">current target element</a> is a text control (e.g.,
         <code id="drag-and-drop-processing-model:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code>, or an <code id="drag-and-drop-processing-model:the-input-element-3"><a href="#the-input-element">input</a></code> element whose <code id="drag-and-drop-processing-model:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="drag-and-drop-processing-model:text-(type=text)-state-and-search-state-(type=search)-3">Text</a> state) or an <a href="#editing-host" id="drag-and-drop-processing-model:editing-host-3">editing host</a> or
         <a id="drag-and-drop-processing-model:editable-3" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a> element, and the <a href="#drag-data-store-item-list" id="drag-and-drop-processing-model:drag-data-store-item-list-8">drag data store item list</a> has an item
         with <a href="#the-drag-data-item-type-string" id="drag-and-drop-processing-model:the-drag-data-item-type-string-8">the drag data item type string</a> "<code id="drag-and-drop-processing-model:text/plain-4"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>" and <a href="#the-drag-data-item-kind" id="drag-and-drop-processing-model:the-drag-data-item-kind-7">the
         drag data item kind</a> <i>text</i></dt><dd><p>Insert the actual data of the first item in the <a href="#drag-data-store-item-list" id="drag-and-drop-processing-model:drag-data-store-item-list-9">drag data store item
         list</a> to have <a href="#the-drag-data-item-type-string" id="drag-and-drop-processing-model:the-drag-data-item-type-string-9">a drag data item type
         string</a> of "<code id="drag-and-drop-processing-model:text/plain-5"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>" and <a href="#the-drag-data-item-kind" id="drag-and-drop-processing-model:the-drag-data-item-kind-8">a drag
         data item kind</a> that is <i>text</i> into the text control or
         <a href="#editing-host" id="drag-and-drop-processing-model:editing-host-4">editing host</a> or <a id="drag-and-drop-processing-model:editable-4" href="https://w3c.github.io/editing/docs/execCommand/#editable" data-x-internal="editable">editable</a> element in a manner consistent with
         platform-specific conventions (e.g. inserting it at the current mouse cursor position, or
         inserting it at the end of the field).</p></dd><dt>Otherwise</dt><dd><p>Reset the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-10">current drag operation</a> to "<code id="drag-and-drop-processing-model:concept-current-drag-operation-none-8"><a href="#concept-current-drag-operation-none">none</a></code>".</p></dd></dl>
       </li></ol>
     </li><li>
      <p><a href="#fire-a-dnd-event" id="drag-and-drop-processing-model:fire-a-dnd-event-9">Fire a DND event</a> named <code id="drag-and-drop-processing-model:event-dnd-dragend"><a href="#event-dnd-dragend">dragend</a></code> at the
      <a href="#source-node" id="drag-and-drop-processing-model:source-node-11">source node</a>.</p>
     </li><li>
      <p>Run the appropriate steps from the following list as the default action of the <code id="drag-and-drop-processing-model:event-dnd-dragend-2"><a href="#event-dnd-dragend">dragend</a></code> event:</p>

      <dl class="switch"><dt>If <var>dropped</var> is true, the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-22">current target element</a> is a <i>text
       control</i> (see below), the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-11">current drag operation</a> is "<code id="drag-and-drop-processing-model:concept-current-drag-operation-move-4"><a href="#concept-current-drag-operation-move">move</a></code>", and the source of the
       drag-and-drop operation is a selection in the DOM that is entirely contained within an
       <a href="#editing-host" id="drag-and-drop-processing-model:editing-host-5">editing host</a></dt><dd><p><a id="drag-and-drop-processing-model:delete-the-selection" href="https://w3c.github.io/editing/docs/execCommand/#delete-the-selection" data-x-internal="delete-the-selection">Delete the selection</a>.</p></dd><dt>If <var>dropped</var> is true, the <a href="#current-target-element" id="drag-and-drop-processing-model:current-target-element-23">current target element</a> is a <i>text
       control</i> (see below), the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-12">current drag operation</a> is "<code id="drag-and-drop-processing-model:concept-current-drag-operation-move-5"><a href="#concept-current-drag-operation-move">move</a></code>", and the source of the
       drag-and-drop operation is a selection in a text control</dt><dd><p>The user agent should delete the dragged selection from the relevant text
       control.</p></dd><dt>If <var>dropped</var> is false or if the <a href="#current-drag-operation" id="drag-and-drop-processing-model:current-drag-operation-13">current drag operation</a> is "<code id="drag-and-drop-processing-model:concept-current-drag-operation-none-9"><a href="#concept-current-drag-operation-none">none</a></code>"</dt><dd><p>The drag was canceled. If the platform conventions dictate that this be represented to
       the user (e.g. by animating the dragged selection going back to the source of the
       drag-and-drop operation), then do so.</p></dd><dt>Otherwise</dt><dd><p>The event has no default action.</p></dd></dl>

      <p>For the purposes of this step, a <i>text control</i> is a <code id="drag-and-drop-processing-model:the-textarea-element-4"><a href="#the-textarea-element">textarea</a></code> element or
      an <code id="drag-and-drop-processing-model:the-input-element-4"><a href="#the-input-element">input</a></code> element whose <code id="drag-and-drop-processing-model:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute is in
      one of the
      <a href="#text-(type=text)-state-and-search-state-(type=search)" id="drag-and-drop-processing-model:text-(type=text)-state-and-search-state-(type=search)-4">Text</a>,
      <a href="#text-(type=text)-state-and-search-state-(type=search)" id="drag-and-drop-processing-model:text-(type=text)-state-and-search-state-(type=search)-5">Search</a>,
      <a href="#telephone-state-(type=tel)" id="drag-and-drop-processing-model:telephone-state-(type=tel)">Tel</a>,
      <a href="#url-state-(type=url)" id="drag-and-drop-processing-model:url-state-(type=url)">URL</a>,
      <a href="#email-state-(type=email)" id="drag-and-drop-processing-model:email-state-(type=email)">Email</a>,
      <a href="#password-state-(type=password)" id="drag-and-drop-processing-model:password-state-(type=password)">Password</a>, or
      <a href="#number-state-(type=number)" id="drag-and-drop-processing-model:number-state-(type=number)">Number</a>
      states.</p>
     </li></ol>
   </li></ol>
  </div>

  <p class="note">User agents are encouraged to consider how to react to drags near the edge of
  scrollable regions. For example, if a user drags a link to the bottom of the <a id="drag-and-drop-processing-model:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>
  on a long page, it might make sense to scroll the page so that the user can drop the link lower on
  the page.</p>

  <p class="note">This model is independent of which <code id="drag-and-drop-processing-model:document-3"><a href="#document">Document</a></code> object the nodes involved
  are from; the events are fired as described above and the rest of the processing model runs as
  described above, irrespective of how many documents are involved in the operation.</p>

  


  <h4 id="dndevents"><span class="secno">6.11.6</span> Events summary<a href="#dndevents" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>The following events are involved in the drag-and-drop
  model.</p>

  <table><thead><tr><th> Event name </th><th> Target </th><th> Cancelable? </th><th> <a href="#drag-data-store-mode" id="dndevents:drag-data-store-mode">Drag data store mode</a> </th><th> <code id="dndevents:dom-datatransfer-dropeffect"><a href="#dom-datatransfer-dropeffect">dropEffect</a></code> </th><th> Default Action </th></tr></thead><tbody><tr><td><dfn data-dfn-for="GlobalEventHandlers,Text" id="event-dnd-dragstart" data-dfn-type="event"><code>dragstart</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragstart_event" title="The dragstart event is fired when the user starts dragging an element or text selection.">HTMLElement/dragstart_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td><a href="#source-node" id="dndevents:source-node">Source node</a></td><td>✓ Cancelable</td><td><a href="#concept-dnd-rw" id="dndevents:concept-dnd-rw">Read/write mode</a>
     </td><td>"<code id="dndevents:dom-datatransfer-dropeffect-none"><a href="#dom-datatransfer-dropeffect-none">none</a></code>"</td><td>Initiate the drag-and-drop operation</td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers,Text" id="event-dnd-drag" data-dfn-type="event"><code>drag</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event" title="The drag event is fired every few hundred milliseconds as an element or text selection is being dragged by the user.">HTMLElement/drag_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td><a href="#source-node" id="dndevents:source-node-2">Source node</a></td><td>✓ Cancelable</td><td><a href="#concept-dnd-p" id="dndevents:concept-dnd-p">Protected mode</a>
     </td><td>"<code id="dndevents:dom-datatransfer-dropeffect-none-2"><a href="#dom-datatransfer-dropeffect-none">none</a></code>"</td><td>Continue the drag-and-drop operation</td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="event-dnd-dragenter" data-dfn-type="event"><code>dragenter</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragenter_event" title="The dragenter event is fired when a dragged element or text selection enters a valid drop target.">HTMLElement/dragenter_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td><a href="#immediate-user-selection" id="dndevents:immediate-user-selection">Immediate user selection</a> or <a href="#the-body-element-2" id="dndevents:the-body-element-2">the body element</a></td><td>✓ Cancelable</td><td><a href="#concept-dnd-p" id="dndevents:concept-dnd-p-2">Protected mode</a>
     </td><td><a href="#dropEffect-initialisation">Based on <code>effectAllowed</code> value</a></td><td>Reject <a href="#immediate-user-selection" id="dndevents:immediate-user-selection-2">immediate user selection</a> as potential <a href="#current-target-element" id="dndevents:current-target-element">target element</a></td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="event-dnd-dragleave" data-dfn-type="event"><code>dragleave</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragleave_event" title="The dragleave event is fired when a dragged element or text selection leaves a valid drop target.">HTMLElement/dragleave_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td><a href="#current-target-element" id="dndevents:current-target-element-2">Previous target element</a></td><td>—</td><td><a href="#concept-dnd-p" id="dndevents:concept-dnd-p-3">Protected mode</a>
     </td><td>"<code id="dndevents:dom-datatransfer-dropeffect-none-3"><a href="#dom-datatransfer-dropeffect-none">none</a></code>"</td><td>None</td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="event-dnd-dragover" data-dfn-type="event"><code>dragover</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragover_event" title="The dragover event is fired when an element or text selection is being dragged over a valid drop target (every few hundred milliseconds).">HTMLElement/dragover_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td><a href="#current-target-element" id="dndevents:current-target-element-3">Current target element</a></td><td>✓ Cancelable</td><td><a href="#concept-dnd-p" id="dndevents:concept-dnd-p-4">Protected mode</a>
     </td><td><a href="#dropEffect-initialisation">Based on <code>effectAllowed</code> value</a></td><td>Reset the <a href="#current-drag-operation" id="dndevents:current-drag-operation">current drag operation</a> to "none"</td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="event-dnd-drop" data-dfn-type="event"><code>drop</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drop_event" title="The drop event is fired when an element or text selection is dropped on a valid drop target. To ensure that the drop event always fires as expected, you should always include a preventDefault() call in the part of your code which handles the dragover event.">HTMLElement/drop_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td><a href="#current-target-element" id="dndevents:current-target-element-4">Current target element</a></td><td>✓ Cancelable</td><td><a href="#concept-dnd-ro" id="dndevents:concept-dnd-ro">Read-only mode</a>
     </td><td><a href="#current-drag-operation" id="dndevents:current-drag-operation-2">Current drag operation</a></td><td>Varies</td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers,Text" id="event-dnd-dragend" data-dfn-type="event"><code>dragend</code></dfn><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragend_event" title="The dragend event is fired when a drag operation is being ended (by releasing a mouse button or hitting the escape key).">HTMLElement/dragend_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td><a href="#source-node" id="dndevents:source-node-3">Source node</a></td><td>—</td><td><a href="#concept-dnd-p" id="dndevents:concept-dnd-p-5">Protected mode</a>
     
     </td><td><a href="#current-drag-operation" id="dndevents:current-drag-operation-3">Current drag operation</a></td><td>Varies</td></tr></tbody></table>

  <p>All of these events bubble, are composed, and the <code id="dndevents:dom-datatransfer-effectallowed"><a href="#dom-datatransfer-effectallowed">effectAllowed</a></code> attribute always has the value it had
  after the <code id="dndevents:event-dnd-dragstart"><a href="#event-dnd-dragstart">dragstart</a></code> event, defaulting to "<code id="dndevents:dom-datatransfer-effectallowed-uninitialized"><a href="#dom-datatransfer-effectallowed-uninitialized">uninitialized</a></code>" in the <code id="dndevents:event-dnd-dragstart-2"><a href="#event-dnd-dragstart">dragstart</a></code> event.</p>



  <h4 id="the-draggable-attribute"><span class="secno">6.11.7</span> The <code id="the-draggable-attribute:attr-draggable"><a href="#attr-draggable">draggable</a></code> attribute<a href="#the-draggable-attribute" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable" title="The draggable global attribute is an enumerated attribute that indicates whether the element can be dragged, either with native browser behavior or the HTML Drag and Drop API.">Global_attributes/draggable</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>Yes</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>All <a href="#html-elements" id="the-draggable-attribute:html-elements">HTML elements</a> may have the <dfn data-dfn-for="html-global" id="attr-draggable" data-dfn-type="element-attr"><code>draggable</code></dfn> content attribute set. The <code id="the-draggable-attribute:attr-draggable-2"><a href="#attr-draggable">draggable</a></code> attribute is an <a href="#enumerated-attribute" id="the-draggable-attribute:enumerated-attribute">enumerated attribute</a> with
  the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/draggable" id="attr-draggable-true" data-dfn-type="attr-value"><code>true</code></dfn>
     </td><td><dfn id="attr-draggable-true-state">True</dfn>
     </td><td>The element will be draggable.
    </td></tr><tr><td><dfn data-dfn-for="html-global/draggable" id="attr-draggable-false" data-dfn-type="attr-value"><code>false</code></dfn>
     </td><td><dfn id="attr-draggable-false-state">False</dfn>
     </td><td>The element will not be draggable.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-draggable-attribute:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-draggable-attribute:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <dfn id="attr-draggable-auto-state">Auto</dfn> state. The auto state uses the default behavior of
  the user agent.</p>
  </div>

  <p>An element with a <code id="the-draggable-attribute:attr-draggable-3"><a href="#attr-draggable">draggable</a></code> attribute should also have a
  <code id="the-draggable-attribute:attr-title"><a href="#attr-title">title</a></code> attribute that names the element for the purpose of
  non-visual interactions. </p>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-draggable" id="dom-draggable-dev">draggable</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns true if the element is draggable; otherwise, returns false.</p>

    <p>Can be set, to override the default and set the <code id="the-draggable-attribute:attr-draggable-4"><a href="#attr-draggable">draggable</a></code> content attribute.</p>
   </dd></dl>

  

  <p>The <dfn data-dfn-for="HTMLElement" id="dom-draggable" data-dfn-type="attribute"><code>draggable</code></dfn> IDL
  attribute, whose value depends on the content attribute's in the way described below, controls
  whether or not the element is draggable. Generally, only text selections are draggable, but
  elements whose <code id="the-draggable-attribute:dom-draggable"><a href="#dom-draggable">draggable</a></code> IDL attribute is true become
  draggable as well.</p>

  <div data-algorithm="">
  <p>If an element's <code id="the-draggable-attribute:attr-draggable-5"><a href="#attr-draggable">draggable</a></code> content attribute has the state
  <a href="#attr-draggable-true-state" id="the-draggable-attribute:attr-draggable-true-state">True</a>, the <code id="the-draggable-attribute:dom-draggable-2"><a href="#dom-draggable">draggable</a></code> IDL attribute must return true.</p>

  <p>Otherwise, if the element's <code id="the-draggable-attribute:attr-draggable-6"><a href="#attr-draggable">draggable</a></code> content attribute
  has the state <a href="#attr-draggable-false-state" id="the-draggable-attribute:attr-draggable-false-state">False</a>, the <code id="the-draggable-attribute:dom-draggable-3"><a href="#dom-draggable">draggable</a></code> IDL attribute must return false.</p>

  <p>Otherwise, the element's <code id="the-draggable-attribute:attr-draggable-7"><a href="#attr-draggable">draggable</a></code> content attribute has
  the state <a href="#attr-draggable-auto-state" id="the-draggable-attribute:attr-draggable-auto-state">Auto</a>. If the element is an
  <code id="the-draggable-attribute:the-img-element"><a href="#the-img-element">img</a></code> element, an <code id="the-draggable-attribute:the-object-element"><a href="#the-object-element">object</a></code> element that <a href="#represents" id="the-draggable-attribute:represents">represents</a> an image, or
  an <code id="the-draggable-attribute:the-a-element"><a href="#the-a-element">a</a></code> element with an <code id="the-draggable-attribute:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> content
  attribute, the <code id="the-draggable-attribute:dom-draggable-4"><a href="#dom-draggable">draggable</a></code> IDL attribute must return true;
  otherwise, the <code id="the-draggable-attribute:dom-draggable-5"><a href="#dom-draggable">draggable</a></code> IDL attribute must return false.</p>
  </div>

  <div data-algorithm="">
  <p>If the <code id="the-draggable-attribute:dom-draggable-6"><a href="#dom-draggable">draggable</a></code> IDL attribute is set to the value false,
  the <code id="the-draggable-attribute:attr-draggable-8"><a href="#attr-draggable">draggable</a></code> content attribute must be set to the literal
  value "<code>false</code>". If the <code id="the-draggable-attribute:dom-draggable-7"><a href="#dom-draggable">draggable</a></code> IDL
  attribute is set to the value true, the <code id="the-draggable-attribute:attr-draggable-9"><a href="#attr-draggable">draggable</a></code> content
  attribute must be set to the literal value "<code>true</code>".</p>
  </div>

  



  

  <h4 id="security-risks-in-the-drag-and-drop-model"><span class="secno">6.11.8</span> Security risks in the drag-and-drop model<a href="#security-risks-in-the-drag-and-drop-model" class="self-link"></a></h4>

  <p>User agents must not make the data added to the <code id="security-risks-in-the-drag-and-drop-model:datatransfer"><a href="#datatransfer">DataTransfer</a></code> object during the
  <code id="security-risks-in-the-drag-and-drop-model:event-dnd-dragstart"><a href="#event-dnd-dragstart">dragstart</a></code> event available to scripts until the <code id="security-risks-in-the-drag-and-drop-model:event-dnd-drop"><a href="#event-dnd-drop">drop</a></code> event, because otherwise, if a user were to drag sensitive
  information from one document to a second document, crossing a hostile third document in the
  process, the hostile document could intercept the data.</p>

  <p>For the same reason, user agents must consider a drop to be successful only if the user
  specifically ended the drag operation — if any scripts end the drag operation, it must be
  considered unsuccessful (canceled) and the <code id="security-risks-in-the-drag-and-drop-model:event-dnd-drop-2"><a href="#event-dnd-drop">drop</a></code> event must not be
  fired.</p>

  <p>User agents should take care to not start drag-and-drop operations in response to script
  actions. For example, in a mouse-and-window environment, if a script moves a window while the user
  has their mouse button depressed, the UA would not consider that to start a drag. This is important
  because otherwise UAs could cause data to be dragged from sensitive sources and dropped into
  hostile documents without the user's consent.</p>

  <p>User agents should filter potentially active (scripted) content (e.g. HTML) when it is dragged
  and when it is dropped, using a safelist of known-safe features. Similarly, <a href="https://url.spec.whatwg.org/#syntax-url-relative" id="security-risks-in-the-drag-and-drop-model:relative-url" data-x-internal="relative-url">relative URLs</a> should be turned into absolute URLs to avoid references changing in
  unexpected ways. This specification does not specify how this is performed.</p>

  <div class="example">

   <p>Consider a hostile page providing some content and getting the user to select and drag and
   drop (or indeed, copy and paste) that content to a victim page's <code id="security-risks-in-the-drag-and-drop-model:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code> region. If the browser does not ensure that
   only safe content is dragged, potentially unsafe content such as scripts and event handlers in
   the selection, once dropped (or pasted) into the victim site, get the privileges of the victim
   site. This would thus enable a cross-site scripting attack.</p>

  </div>

  

  <h3 id="the-popover-attribute"><span class="secno">6.12</span> The <code id="the-popover-attribute:attr-popover"><a href="#attr-popover">popover</a></code> attribute<a href="#the-popover-attribute" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/popover" title="The popover global attribute is used to designate an element as a popover element.">Global_attributes/popover</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>preview+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>All <a href="#html-elements" id="the-popover-attribute:html-elements">HTML elements</a> may have the <dfn data-dfn-for="html-global" id="attr-popover" data-dfn-type="element-attr"><code>popover</code></dfn> content attribute set. When specified, the element
  won't be rendered until it becomes shown, at which point it will be rendered on top of other page
  content.</p>

  <div class="example">
   <p>The <code id="the-popover-attribute:attr-popover-2"><a href="#attr-popover">popover</a></code> attribute is a global attribute that allows
   authors flexibility to ensure popover functionality can be applied to elements with the most
   relevant semantics.</p>

   <p>The following demonstrates how one might create a popover sub-navigation list of
   links, within the global navigation for a website.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">...</c-><c- p="">&gt;</c->All Products<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">popovertarget</c-><c- o="">=</c-><c- s="">sub-nav</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">img</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">down-arrow.png</c-> <c- e="">alt</c-><c- o="">=</c-><c- s="">"Product pages"</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">ul</c-> <c- e="">popover</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">sub-nav</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">...</c-><c- p="">&gt;</c->Shirts<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">...</c-><c- p="">&gt;</c->Shoes<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
     <c- p="">&lt;</c-><c- f="">li</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">...</c-><c- p="">&gt;</c->Hats etc.<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">li</c-><c- p="">&gt;</c->
  <c- c="">&lt;!-- other list items and links here --&gt;</c->
<c- p="">&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>When using <code id="the-popover-attribute:attr-popover-3"><a href="#attr-popover">popover</a></code> on elements without accessibility
  semantics, for instance the <code id="the-popover-attribute:the-div-element"><a href="#the-div-element">div</a></code> element, authors should use the appropriate ARIA
  attributes to ensure the popover is accessible.</p>

  <div class="example">
   <p>The following shows the baseline markup to create a custom menu popover, where the first
   menuitem will receive keyboard focus when the popover is invoked due to the use of the
   <code>autofocus</code> attribute. Navigating the menuitems with arrow keys and
   activation behaviors would still need author scripting. Additional requirements for building
   custom menus widgets are defined in the <a href="https://w3c.github.io/aria/#menu">WAI-ARIA
   specification</a>.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">popovertarget</c-><c- o="">=</c-><c- s="">m</c-><c- p="">&gt;</c->Actions<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">role</c-><c- o="">=</c-><c- s="">menu</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">m</c-> <c- e="">popover</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">role</c-><c- o="">=</c-><c- s="">menuitem</c-> <c- e="">tabindex</c-><c- o="">=</c-><c- s="">-1</c-> <c- e="">autofocus</c-><c- p="">&gt;</c->Edit<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">role</c-><c- o="">=</c-><c- s="">menuitem</c-> <c- e="">tabindex</c-><c- o="">=</c-><c- s="">-1</c-><c- p="">&gt;</c->Hide<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">role</c-><c- o="">=</c-><c- s="">menuitem</c-> <c- e="">tabindex</c-><c- o="">=</c-><c- s="">-1</c-><c- p="">&gt;</c->Delete<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>

   <p>A popover can be useful for rendering a status message, confirming the action performed by
   the user. The following demonstrates how one could reveal a popover in an <code id="the-popover-attribute:the-output-element"><a href="#the-output-element">output</a></code>
   element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">submit</c-><c- p="">&gt;</c->Submit<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">output</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-> <c- e="">popover</c-><c- o="">=</c-><c- s="">manual</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">output</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">const</c-> sBtn <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- u="">"submit"</c-><c- p="">);</c->
 <c- a="">const</c-> outSpan <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"output [popover=manual]"</c-><c- p="">);</c->
 <c- a="">let</c-> successMessage<c- p="">;</c->
 <c- a="">let</c-> errorMessage<c- p="">;</c->

 <c- d="">/* define logic for determining success of action</c->
<c- d="">  and determining the appropriate success or error</c->
<c- d="">  messages to use */</c->

 sBtn<c- p="">.</c->addEventListener<c- p="">(</c-><c- u="">"click"</c-><c- p="">,</c-> <c- p="">()=&gt;</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c-> success <c- p="">)</c-> <c- p="">{</c->
   outSpan<c- p="">.</c->textContent <c- o="">=</c-> successMessage<c- p="">;</c->
  <c- p="">}</c->
  <c- k="">else</c-> <c- p="">{</c->
   outSpan<c- p="">.</c->textContent <c- o="">=</c-> errorMessage<c- p="">;</c->
  <c- p="">}</c->
  outSpan<c- p="">.</c->showPopover<c- p="">();</c->

  setTimeout<c- p="">(</c-><c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
   outSpan<c- p="">.</c->hidePopover<c- p="">();</c->
  <c- p="">},</c-> <c- mf="">10000</c-><c- p="">);</c->
 <c- p="">});</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p class="note">Inserting a popover element into an <code id="the-popover-attribute:the-output-element-2"><a href="#the-output-element">output</a></code> element will generally
  cause screen readers to announce the content when it becomes visible. Depending on the complexity
  or frequency of the content, this could be either useful or annoying to users of these
  assistive technologies. Keep this in mind when using the <code id="the-popover-attribute:the-output-element-3"><a href="#the-output-element">output</a></code> element or other
  ARIA live regions to ensure the best user experience.</p>

  <p>The <code id="the-popover-attribute:attr-popover-4"><a href="#attr-popover">popover</a></code> attribute is an <a href="#enumerated-attribute" id="the-popover-attribute:enumerated-attribute">enumerated
  attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/popover" id="attr-popover-auto" data-dfn-type="attr-value"><code>auto</code></dfn>
     </td><td><dfn id="attr-popover-auto-state">Auto</dfn>
     </td><td>Closes other popovers when opened; has <a href="#popover-light-dismiss" id="the-popover-attribute:popover-light-dismiss">light
     dismiss</a> and responds to <a href="#close-request" id="the-popover-attribute:close-request">close requests</a>.
    </td></tr><tr><td><dfn data-dfn-for="html-global/popover" id="attr-popover-manual" data-dfn-type="attr-value"><code>manual</code></dfn>
     </td><td><dfn id="attr-popover-manual-state">Manual</dfn>
     </td><td>Does not close other popovers; does not <a href="#popover-light-dismiss" id="the-popover-attribute:popover-light-dismiss-2">light
     dismiss</a> or respond to <a href="#close-request" id="the-popover-attribute:close-request-2">close requests</a>.
    </td></tr><tr><td><dfn data-dfn-for="html-global/popover" id="attr-popover-hint" data-dfn-type="attr-value"><code>hint</code></dfn></td><td><dfn id="attr-popover-hint-state">Hint</dfn></td><td>Closes other hint popovers when opened, but not other auto popovers; has <a href="#popover-light-dismiss" id="the-popover-attribute:popover-light-dismiss-3">light dismiss</a> and responds to <a href="#close-request" id="the-popover-attribute:close-request-3">close requests</a>.</td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-popover-attribute:missing-value-default"><a href="#missing-value-default">missing value default</a></i> is the <dfn id="attr-popover-none-state">No Popover</dfn> state, its <i id="the-popover-attribute:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> is the <a href="#attr-popover-manual-state" id="the-popover-attribute:attr-popover-manual-state">Manual</a>
  state, and its <i id="the-popover-attribute:empty-value-default"><a href="#empty-value-default">empty value default</a></i> is the <a href="#attr-popover-auto-state" id="the-popover-attribute:attr-popover-auto-state">Auto</a> state.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/popover" title="The popover property of the HTMLElement interface gets and sets an element's popover state via JavaScript (&quot;auto&quot; or &quot;manual&quot;), and can be used for feature detection.">HTMLElement/popover</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-popover" data-dfn-type="attribute"><code>popover</code></dfn> IDL
  attribute must <a href="#reflect" id="the-popover-attribute:reflect">reflect</a> the <a href="#attr-popover" id="the-popover-attribute:attr-popover-5">popover</a> attribute,
  <a href="#limited-to-only-known-values" id="the-popover-attribute:limited-to-only-known-values">limited to only known values</a>.</p>
  </div>

  <p>Every <a href="#html-elements" id="the-popover-attribute:html-elements-2">HTML element</a> has a <dfn id="popover-visibility-state" data-export="">popover visibility
  state</dfn>, initially <a href="#popover-hidden-state" id="the-popover-attribute:popover-hidden-state">hidden</a>, with these potential
  values:</p>

  <ul><li><p><dfn data-dfn-for="popover visibility state" id="popover-hidden-state" data-export="">hidden</dfn></p></li><li><p><dfn data-dfn-for="popover visibility state" id="popover-showing-state" data-export="">showing</dfn></p></li></ul>

  <p>Every <code id="the-popover-attribute:document"><a href="#document">Document</a></code> has a <dfn id="popover-pointerdown-target">popover pointerdown target</dfn>, which is an <a href="#html-elements" id="the-popover-attribute:html-elements-3">HTML element</a> or null, initially null.</p>

  <p>Every <a href="#html-elements" id="the-popover-attribute:html-elements-4">HTML element</a> has a <dfn id="popover-trigger">popover trigger</dfn>, which
  is an <a href="#html-elements" id="the-popover-attribute:html-elements-5">HTML element</a> or null, initially set to null.</p>

  <p>Every <a href="#html-elements" id="the-popover-attribute:html-elements-6">HTML element</a> has a <dfn id="popover-showing-or-hiding">popover showing or
  hiding</dfn>, which is a boolean, initially set to false.</p>

  <p>Every <a href="#html-elements" id="the-popover-attribute:html-elements-7">HTML element</a> <dfn id="popover-toggle-task-tracker">popover toggle task tracker</dfn>,
  which is a <a href="#toggle-task-tracker" id="the-popover-attribute:toggle-task-tracker">toggle task tracker</a> or null, initially null.</p>

  <p>Every <a href="#html-elements" id="the-popover-attribute:html-elements-8">HTML element</a> has a <dfn id="popover-close-watcher">popover close watcher</dfn>,
  which is a <a href="#close-watcher" id="the-popover-attribute:close-watcher">close watcher</a> or null, initially null.</p>

  <p>Every <a href="#html-elements" id="the-popover-attribute:html-elements-9">HTML element</a> has an <dfn id="opened-in-popover-mode">opened in popover
  mode</dfn>, which is a string or null, initially null.</p>

  <div data-algorithm="">
  <p>The following <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="the-popover-attribute:concept-element-attributes-change-ext" data-x-internal="concept-element-attributes-change-ext">attribute change
  steps</a>, given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
  <var>value</var>, and <var>namespace</var>, are used for all <a href="#html-elements" id="the-popover-attribute:html-elements-10">HTML elements</a>:</p>

  <ol><li><p>If <var>namespace</var> is not null, then return.</p></li><li><p>If <var>localName</var> is not <code id="the-popover-attribute:attr-popover-6"><a href="#attr-popover">popover</a></code>, then
   return.</p></li><li><p>If <var>element</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state">popover visibility state</a> is in the <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state">showing state</a> and <var>oldValue</var> and <var>value</var>
   are in different <a href="#attr-popover" id="the-popover-attribute:attr-popover-7">states</a>, then run the <a href="#hide-popover-algorithm" id="the-popover-attribute:hide-popover-algorithm">hide popover
   algorithm</a> given <var>element</var>, true, true, false, and null.</p></li></ol>
  </div>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-showpopover" id="dom-showpopover-dev">showPopover</a>()</code></dt><dd>Shows the popover <var>element</var> by adding it to the top layer. If <var>element</var>'s
   <code id="the-popover-attribute:attr-popover-8"><a href="#attr-popover">popover</a></code> attribute is in the <a href="#attr-popover-auto-state" id="the-popover-attribute:attr-popover-auto-state-2">Auto</a> state, then this will also close all other <a href="#attr-popover-auto-state" id="the-popover-attribute:attr-popover-auto-state-3">Auto</a> popovers unless they are an ancestor of
   <var>element</var> according to the <a href="#topmost-popover-ancestor" id="the-popover-attribute:topmost-popover-ancestor">topmost popover ancestor</a> algorithm.</dd><dt><code><var>element</var>.<a href="#dom-hidepopover" id="dom-hidepopover-dev">hidePopover</a>()</code></dt><dd>Hides the popover <var>element</var> by removing it from the top layer and applying
   <code>display: none</code> to it.</dd><dt><code><var>element</var>.<a href="#dom-togglepopover" id="dom-togglepopover-dev">togglePopover</a>()</code></dt><dd>If the popover <var>element</var> is not showing, then this method shows it. Otherwise, this
   method hides it. This method returns true if the popover is open after calling it, otherwise
   false.</dd></dl>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/showPopover" title="The showPopover() method of the HTMLElement interface shows a popover element (i.e. one that has a valid popover attribute) by adding it to the top layer.">HTMLElement/showPopover</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-showpopover" data-dfn-type="method"><code>showPopover(<var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>source</var> be <var>options</var>["<code id="the-popover-attribute:dom-showpopoveroptions-source"><a href="#dom-showpopoveroptions-source">source</a></code>"] if it <a href="https://infra.spec.whatwg.org/#map-exists" id="the-popover-attribute:map-exists" data-x-internal="map-exists">exists</a>; otherwise, null.</p></li><li><p>Run <a href="#show-popover" id="the-popover-attribute:show-popover">show popover</a> given <a id="the-popover-attribute:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, true, and
   <var>source</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="show-popover">show popover</dfn>, given an <a href="#html-elements" id="the-popover-attribute:html-elements-11">HTML element</a>
  <var>element</var>, a boolean <var>throwExceptions</var>, and an <a href="#html-elements" id="the-popover-attribute:html-elements-12">HTML
  element</a> or null <var>source</var>:</p>

  <ol><li><p>If the result of running <a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity">check popover validity</a> given <var>element</var>,
   false, <var>throwExceptions</var>, and null is false, then return.</p></li><li><p>Let <var>document</var> be <var>element</var>'s <a id="the-popover-attribute:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p><a id="the-popover-attribute:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>element</var>'s <a href="#popover-trigger" id="the-popover-attribute:popover-trigger">popover trigger</a> is null.</p></li><li><p><a id="the-popover-attribute:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>element</var> is not in <var>document</var>'s <a id="the-popover-attribute:top-layer" href="https://drafts.csswg.org/css-position-4/#document-top-layer" data-x-internal="top-layer">top
   layer</a>.</p></li><li><p>Let <var>nestedShow</var> be <var>element</var>'s <a href="#popover-showing-or-hiding" id="the-popover-attribute:popover-showing-or-hiding">popover showing or
   hiding</a>.</p></li><li><p>Let <var>fireEvents</var> be the boolean negation of <var>nestedShow</var>.</p></li><li><p>Set <var>element</var>'s <a href="#popover-showing-or-hiding" id="the-popover-attribute:popover-showing-or-hiding-2">popover showing or hiding</a> to true.</p></li><li>
    <p>Let <var>cleanupShowingFlag</var> be the following steps:</p>

    <ol><li><p>If <var>nestedShow</var> is false, then set <var>element</var>'s <a href="#popover-showing-or-hiding" id="the-popover-attribute:popover-showing-or-hiding-3">popover showing
     or hiding</a> to false.</p></li></ol>
   </li><li><p>If the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-popover-attribute:concept-event-fire" data-x-internal="concept-event-fire">firing an event</a> named <code id="the-popover-attribute:event-beforetoggle"><a href="#event-beforetoggle">beforetoggle</a></code>, using <code id="the-popover-attribute:toggleevent"><a href="#toggleevent">ToggleEvent</a></code>, with the <code id="the-popover-attribute:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true, the <code id="the-popover-attribute:dom-toggleevent-oldstate"><a href="#dom-toggleevent-oldstate">oldState</a></code> attribute initialized to "<code>closed</code>", the <code id="the-popover-attribute:dom-toggleevent-newstate"><a href="#dom-toggleevent-newstate">newState</a></code> attribute
   initialized to "<code>open</code>", and the <code id="the-popover-attribute:dom-toggleevent-source"><a href="#dom-toggleevent-source">source</a></code> attribute initialized to <var>source</var> at
   <var>element</var> is false, then run <var>cleanupShowingFlag</var> and return.</p></li><li>
    <p>If the result of running <a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-2">check popover validity</a> given <var>element</var>, false,
    <var>throwExceptions</var>, and <var>document</var> is false, then run
    <var>cleanupShowingFlag</var> and return.</p>

    <p class="note"><a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-3">Check popover validity</a> is called again because firing the <code id="the-popover-attribute:event-beforetoggle-2"><a href="#event-beforetoggle">beforetoggle</a></code> event could have disconnected this element or
    changed its <code id="the-popover-attribute:attr-popover-9"><a href="#attr-popover">popover</a></code> attribute.</p>
   </li><li><p>Let <var>shouldRestoreFocus</var> be false.</p></li><li><p>Let <var>originalType</var> be the current state of <var>element</var>'s <code id="the-popover-attribute:attr-popover-10"><a href="#attr-popover">popover</a></code> attribute.</p></li><li><p>Let <var>stackToAppendTo</var> be null.</p></li><li><p>Let <var>autoAncestor</var> be the result of running the <a href="#topmost-popover-ancestor" id="the-popover-attribute:topmost-popover-ancestor-2">topmost popover
   ancestor</a> algorithm given <var>element</var>, <var>document</var>'s <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list">showing auto
   popover list</a>, <var>source</var>, and true.</p></li><li><p>Let <var>hintAncestor</var> be the result of running the <a href="#topmost-popover-ancestor" id="the-popover-attribute:topmost-popover-ancestor-3">topmost popover
   ancestor</a> algorithm given <var>element</var>, <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list">showing hint
   popover list</a>, <var>source</var>, and true.</p></li><li>
    <p>If <var>originalType</var> is the <a href="#attr-popover-auto-state" id="the-popover-attribute:attr-popover-auto-state-4">Auto</a> state,
    then:</p>

    <ol><li><p>Run <a href="#close-entire-popover-list" id="the-popover-attribute:close-entire-popover-list">close entire popover list</a> given <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list-2">showing
     hint popover list</a>, <var>shouldRestoreFocus</var>, and <var>fireEvents</var>.</p></li><li><p>Let <var>ancestor</var> be the result of running the <a href="#topmost-popover-ancestor" id="the-popover-attribute:topmost-popover-ancestor-4">topmost popover
     ancestor</a> algorithm given <var>element</var>, <var>document</var>'s <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-2">showing auto
     popover list</a>, <var>source</var>, and true.</p></li><li><p>If <var>ancestor</var> is null, then set <var>ancestor</var> to
     <var>document</var>.</p></li><li><p>Run <a href="#hide-all-popovers-until" id="the-popover-attribute:hide-all-popovers-until">hide all popovers until</a> given
     <var>ancestor</var>, <var>shouldRestoreFocus</var>, and <var>fireEvents</var>.</p></li><li><p>Set <var>stackToAppendTo</var> to "<code>auto</code>".</p></li></ol>
   </li><li>
    <p>If <var>originalType</var> is the <a href="#attr-popover-hint-state" id="the-popover-attribute:attr-popover-hint-state">Hint</a> state,
    then:</p>

    <ol><li>
      <p>If <var>hintAncestor</var> is not null, then:</p>

      <ol><li><p>Run <a href="#hide-all-popovers-until" id="the-popover-attribute:hide-all-popovers-until-2">hide all popovers until</a> given
       <var>hintAncestor</var>, <var>shouldRestoreFocus</var>, and <var>fireEvents</var>.</p></li><li><p>Set <var>stackToAppendTo</var> to "<code>hint</code>".</p></li></ol>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p>Run <a href="#close-entire-popover-list" id="the-popover-attribute:close-entire-popover-list-2">close entire popover list</a> given <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list-3">showing
       hint popover list</a>, <var>shouldRestoreFocus</var>, and <var>fireEvents</var>.</p></li><li>
        <p>If <var>autoAncestor</var> is not null, then:</p>

        <ol><li><p>Run <a href="#hide-all-popovers-until" id="the-popover-attribute:hide-all-popovers-until-3">hide all popovers until</a> given
         <var>autoAncestor</var>, <var>shouldRestoreFocus</var>, and <var>fireEvents</var>.</p></li><li><p>Set <var>stackToAppendTo</var> to "<code>auto</code>".</p></li></ol>
       </li><li><p>Otherwise, set <var>stackToAppendTo</var> to "<code>hint</code>".</p></li></ol>
     </li></ol>
   </li><li>
    <p>If <var>originalType</var> is <a href="#attr-popover-auto-state" id="the-popover-attribute:attr-popover-auto-state-5">Auto</a> or <a href="#attr-popover-hint-state" id="the-popover-attribute:attr-popover-hint-state-2">Hint</a>, then:</p>

    <ol><li><p><a id="the-popover-attribute:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>stackToAppendTo</var> is not null.</p></li><li>
      <p>If <var>originalType</var> is not equal to the value of <var>element</var>'s <code id="the-popover-attribute:attr-popover-11"><a href="#attr-popover">popover</a></code> attribute, then:</p>

      <ol><li><p>If <var>throwExceptions</var> is true, then throw an
       <a id="the-popover-attribute:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-popover-attribute:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return.</p></li></ol>
     </li><li>
      <p>If the result of running <a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-4">check popover validity</a> given <var>element</var>,
      false, <var>throwExceptions</var>, and <var>document</var> is false, then run
      <var>cleanupShowingFlag</var> and return.</p>

      <p class="note"><a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-5">Check popover validity</a> is called again because running <a href="#hide-all-popovers-until" id="the-popover-attribute:hide-all-popovers-until-4">hide all popovers until</a> above could have fired the
      <code id="the-popover-attribute:event-beforetoggle-3"><a href="#event-beforetoggle">beforetoggle</a></code> event, and an event handler could have
      disconnected this element or changed its <code id="the-popover-attribute:attr-popover-12"><a href="#attr-popover">popover</a></code>
      attribute.</p>
     </li><li>
      <p>If the result of running <a href="#topmost-auto-popover" id="the-popover-attribute:topmost-auto-popover">topmost auto or hint
      popover</a> on <var>document</var> is null, then set <var>shouldRestoreFocus</var> to
      true.</p>

      <p class="note">This ensures that focus is returned to the previously-focused element only for
      the first popover in a stack.</p>
     </li><li>
      <p>If <var>stackToAppendTo</var> is "<code>auto</code>":</p>

      <ol><li><p><a id="the-popover-attribute:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var>'s <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-3">showing auto popover list</a> does
       not contain <var>element</var>.</p></li><li><p>Set <var>element</var>'s <a href="#opened-in-popover-mode" id="the-popover-attribute:opened-in-popover-mode">opened in popover mode</a> to "<code>auto</code>".</p></li></ol>

      <p>Otherwise:</p>

      <ol><li><p><a id="the-popover-attribute:assert-5" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>stackToAppendTo</var> is "<code>hint</code>".</p></li><li><p><a id="the-popover-attribute:assert-6" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list-4">showing hint popover list</a> does
       not contain <var>element</var>.</p></li><li><p>Set <var>element</var>'s <a href="#opened-in-popover-mode" id="the-popover-attribute:opened-in-popover-mode-2">opened in popover mode</a> to "<code>hint</code>".</p></li></ol>
     </li><li id="canceling-popovers">
      <p>Set <var>element</var>'s <a href="#popover-close-watcher" id="the-popover-attribute:popover-close-watcher">popover close watcher</a> to the result of <a href="#establish-a-close-watcher" id="the-popover-attribute:establish-a-close-watcher">establishing a close watcher</a> given
      <var>element</var>'s <a href="#concept-relevant-global" id="the-popover-attribute:concept-relevant-global">relevant global object</a>, with:</p>

      <ul><li><p><i id="the-popover-attribute:create-close-watcher-cancelaction"><a href="#create-close-watcher-cancelaction">cancelAction</a></i> being to return
       true.</p></li><li><p><i id="the-popover-attribute:create-close-watcher-closeaction"><a href="#create-close-watcher-closeaction">closeAction</a></i> being to <a href="#hide-popover-algorithm" id="the-popover-attribute:hide-popover-algorithm-2">hide a popover</a> given <var>element</var>, true, true,
       false, and null.</p></li><li><p><i id="the-popover-attribute:create-close-watcher-getenabledstate"><a href="#create-close-watcher-getenabledstate">getEnabledState</a></i> being to return
       true.</p></li></ul>
     </li></ol>
   </li><li><p>Set <var>element</var>'s <a href="#previously-focused-element" id="the-popover-attribute:previously-focused-element">previously focused element</a> to null.</p></li><li><p>Let <var>originallyFocusedElement</var> be <var>document</var>'s <a href="#focused-area-of-the-document" id="the-popover-attribute:focused-area-of-the-document">focused area of the
   document</a>'s <a href="#dom-anchor" id="the-popover-attribute:dom-anchor">DOM anchor</a>.</p></li><li><p><a id="the-popover-attribute:add-an-element-to-the-top-layer" href="https://drafts.csswg.org/css-position-4/#add-an-element-to-the-top-layer" data-x-internal="add-an-element-to-the-top-layer">Add an element to the top layer</a> given <var>element</var>.</p></li><li><p>Set <var>element</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-2">popover visibility state</a> to <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-2">showing</a>.</p></li><li><p>Set <var>element</var>'s <a href="#popover-trigger" id="the-popover-attribute:popover-trigger-2">popover trigger</a> to <var>source</var>.</p></li><li><p>Set <var>element</var>'s <a id="the-popover-attribute:implicit-anchor-element" href="https://drafts.csswg.org/css-anchor-position/#implicit-anchor-element" data-x-internal="implicit-anchor-element">implicit anchor element</a> to
   <var>source</var>.</p></li><li><p>Run the <a href="#popover-focusing-steps" id="the-popover-attribute:popover-focusing-steps">popover focusing steps</a> given <var>element</var>.</p></li><li><p>If <var>shouldRestoreFocus</var> is true and <var>element</var>'s <code id="the-popover-attribute:attr-popover-13"><a href="#attr-popover">popover</a></code> attribute is not in the <a href="#attr-popover-none-state" id="the-popover-attribute:attr-popover-none-state">No Popover</a> state, then set <var>element</var>'s
   <a href="#previously-focused-element" id="the-popover-attribute:previously-focused-element-2">previously focused element</a> to <var>originallyFocusedElement</var>.</p></li><li><p><a href="#queue-a-popover-toggle-event-task" id="the-popover-attribute:queue-a-popover-toggle-event-task">Queue a popover toggle event task</a> given <var>element</var>, "<code>closed</code>", "<code>open</code>", and <var>source</var>.</p></li><li><p>Run <var>cleanupShowingFlag</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="queue-a-popover-toggle-event-task">queue a popover toggle event task</dfn> given an element <var>element</var>, a string
  <var>oldState</var>, a string <var>newState</var>, and an <code id="the-popover-attribute:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or null
  <var>source</var>:

  </p><ol><li>
    <p>If <var>element</var>'s <a href="#popover-toggle-task-tracker" id="the-popover-attribute:popover-toggle-task-tracker">popover toggle task tracker</a> is not null, then:</p>

    <ol><li><p>Set <var>oldState</var> to <var>element</var>'s <a href="#popover-toggle-task-tracker" id="the-popover-attribute:popover-toggle-task-tracker-2">popover toggle task
     tracker</a>'s <a href="#toggle-task-old-state" id="the-popover-attribute:toggle-task-old-state">old state</a>.</p></li><li><p>Remove <var>element</var>'s <a href="#popover-toggle-task-tracker" id="the-popover-attribute:popover-toggle-task-tracker-3">popover toggle task tracker</a>'s <a href="#toggle-task-task" id="the-popover-attribute:toggle-task-task">task</a> from its <a href="#task-queue" id="the-popover-attribute:task-queue">task queue</a>.</p></li><li><p>Set <var>element</var>'s <a href="#popover-toggle-task-tracker" id="the-popover-attribute:popover-toggle-task-tracker-4">popover toggle task tracker</a> to null.</p></li></ol>
   </li><li>
    <p><a href="#queue-an-element-task" id="the-popover-attribute:queue-an-element-task">Queue an element task</a> given the <a href="#dom-manipulation-task-source" id="the-popover-attribute:dom-manipulation-task-source">DOM manipulation task source</a> and
    <var>element</var> to run the following steps:</p>

    <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-popover-attribute:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-popover-attribute:event-toggle"><a href="#event-toggle">toggle</a></code> at <var>element</var>, using <code id="the-popover-attribute:toggleevent-2"><a href="#toggleevent">ToggleEvent</a></code>, with
     the <code id="the-popover-attribute:dom-toggleevent-oldstate-2"><a href="#dom-toggleevent-oldstate">oldState</a></code> attribute initialized to
     <var>oldState</var>, the <code id="the-popover-attribute:dom-toggleevent-newstate-2"><a href="#dom-toggleevent-newstate">newState</a></code> attribute
     initialized to <var>newState</var>, and the <code id="the-popover-attribute:dom-toggleevent-source-2"><a href="#dom-toggleevent-source">source</a></code> attribute initialized to
     <var>source</var>.</p></li><li><p>Set <var>element</var>'s <a href="#popover-toggle-task-tracker" id="the-popover-attribute:popover-toggle-task-tracker-5">popover toggle task tracker</a> to null.</p></li></ol>
   </li><li><p>Set <var>element</var>'s <a href="#popover-toggle-task-tracker" id="the-popover-attribute:popover-toggle-task-tracker-6">popover toggle task tracker</a> to a struct with <a href="#toggle-task-task" id="the-popover-attribute:toggle-task-task-2">task</a> set to the just-queued <a href="#concept-task" id="the-popover-attribute:concept-task">task</a> and <a href="#toggle-task-old-state" id="the-popover-attribute:toggle-task-old-state-2">old state</a> set
   to <var>oldState</var>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/hidePopover" title="The hidePopover() method of the HTMLElement interface hides a popover element (i.e. one that has a valid popover attribute) by removing it from the top layer and styling it with display: none.">HTMLElement/hidePopover</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-hidepopover" data-dfn-type="method"><code>hidePopover()</code></dfn>
  method steps are:</p>

  <ol><li><p>Run the <a href="#hide-popover-algorithm" id="the-popover-attribute:hide-popover-algorithm-3">hide popover algorithm</a> given <a id="the-popover-attribute:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, true, true, true, and
   null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="hide-popover-algorithm">hide a popover</dfn> given an <a href="#html-elements" id="the-popover-attribute:html-elements-13">HTML element</a> <var>element</var>, a boolean <var>focusPreviousElement</var>, a
  boolean <var>fireEvents</var>, a boolean <var>throwExceptions</var>, and an <a href="#html-elements" id="the-popover-attribute:html-elements-14">HTML element</a> or null <var>source</var>:</p>

  <ol><li><p>If the result of running <a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-6">check popover validity</a> given <var>element</var>,
   true, <var>throwExceptions</var>, and null is false, then return.</p></li><li><p>Let <var>document</var> be <var>element</var>'s <a id="the-popover-attribute:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>Let <var>nestedHide</var> be <var>element</var>'s <a href="#popover-showing-or-hiding" id="the-popover-attribute:popover-showing-or-hiding-4">popover showing or
   hiding</a>.</p></li><li><p>Set <var>element</var>'s <a href="#popover-showing-or-hiding" id="the-popover-attribute:popover-showing-or-hiding-5">popover showing or hiding</a> to true.</p></li><li><p>If <var>nestedHide</var> is true, then set <var>fireEvents</var> to false.</p></li><li>
    <p>Let <var>cleanupSteps</var> be the following steps:</p>

    <ol><li><p>If <var>nestedHide</var> is false, then set <var>element</var>'s <a href="#popover-showing-or-hiding" id="the-popover-attribute:popover-showing-or-hiding-6">popover showing
     or hiding</a> to false.</p></li><li>
      <p>If <var>element</var>'s <a href="#popover-close-watcher" id="the-popover-attribute:popover-close-watcher-2">popover close watcher</a> is not null, then:</p>

      <ol><li><p><a href="#close-watcher-destroy" id="the-popover-attribute:close-watcher-destroy">Destroy</a> <var>element</var>'s <a href="#popover-close-watcher" id="the-popover-attribute:popover-close-watcher-3">popover
       close watcher</a>.</p></li><li><p>Set <var>element</var>'s <a href="#popover-close-watcher" id="the-popover-attribute:popover-close-watcher-4">popover close watcher</a> to null.</p></li></ol>
     </li></ol>
   </li><li>
    <p>If <var>element</var>'s <a href="#opened-in-popover-mode" id="the-popover-attribute:opened-in-popover-mode-3">opened in popover mode</a> is "<code>auto</code>"
    or "<code>hint</code>", then:</p>

    <ol><li><p>Run <a href="#hide-all-popovers-until" id="the-popover-attribute:hide-all-popovers-until-5">hide all popovers until</a> given
     <var>element</var>, <var>focusPreviousElement</var>, and <var>fireEvents</var>.</p></li><li>
      <p>If the result of running <a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-7">check popover validity</a> given <var>element</var>,
      true, and <var>throwExceptions</var> is false, then run <var>cleanupSteps</var> and
      return.</p>

      <p class="note"><a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-8">Check popover validity</a> is called again because running <a href="#hide-all-popovers-until" id="the-popover-attribute:hide-all-popovers-until-6">hide all popovers until</a> could have disconnected
      <var>element</var> or changed its <code id="the-popover-attribute:attr-popover-14"><a href="#attr-popover">popover</a></code> attribute.</p>
     </li></ol>
   </li><li><p>Let <var>autoPopoverListContainsElement</var> be true if <var>document</var>'s
   <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-4">showing auto popover list</a>'s last item is <var>element</var>, otherwise
   false.</p></li><li>
    <p>If <var>fireEvents</var> is true:</p>

    <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-popover-attribute:concept-event-fire-3" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-popover-attribute:event-beforetoggle-4"><a href="#event-beforetoggle">beforetoggle</a></code>, using <code id="the-popover-attribute:toggleevent-3"><a href="#toggleevent">ToggleEvent</a></code>, with the <code id="the-popover-attribute:dom-toggleevent-oldstate-3"><a href="#dom-toggleevent-oldstate">oldState</a></code> attribute initialized to "<code>open</code>", the <code id="the-popover-attribute:dom-toggleevent-newstate-3"><a href="#dom-toggleevent-newstate">newState</a></code>
     attribute initialized to "<code>closed</code>", and the <code id="the-popover-attribute:dom-toggleevent-source-3"><a href="#dom-toggleevent-source">source</a></code> attribute set to <var>source</var> at
     <var>element</var>.</p></li><li><p>If <var>autoPopoverListContainsElement</var> is true and <var>document</var>'s
     <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-5">showing auto popover list</a>'s last item is not <var>element</var>, then run <a href="#hide-all-popovers-until" id="the-popover-attribute:hide-all-popovers-until-7">hide all popovers until</a> given <var>element</var>,
     <var>focusPreviousElement</var>, and false.</p></li><li>
      <p>If the result of running <a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-9">check popover validity</a> given <var>element</var>,
      true, <var>throwExceptions</var>, and null is false, then run <var>cleanupSteps</var> and
      return.</p>

      <p class="note"><a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-10">Check popover validity</a> is called again because firing the <code id="the-popover-attribute:event-beforetoggle-5"><a href="#event-beforetoggle">beforetoggle</a></code> event could have disconnected
      <var>element</var> or changed its <code id="the-popover-attribute:attr-popover-15"><a href="#attr-popover">popover</a></code> attribute.</p>
     </li><li><p><a id="the-popover-attribute:request-an-element-to-be-removed-from-the-top-layer" href="https://drafts.csswg.org/css-position-4/#request-an-element-to-be-removed-from-the-top-layer" data-x-internal="request-an-element-to-be-removed-from-the-top-layer">Request an element to be removed from the top layer</a> given
     <var>element</var>.</p></li><li><p>Set <var>element</var>'s <a id="the-popover-attribute:implicit-anchor-element-2" href="https://drafts.csswg.org/css-anchor-position/#implicit-anchor-element" data-x-internal="implicit-anchor-element">implicit anchor element</a> to null.</p></li></ol>
   </li><li><p>Otherwise, <a id="the-popover-attribute:remove-an-element-from-the-top-layer-immediately" href="https://drafts.csswg.org/css-position-4/#remove-an-element-from-the-top-layer-immediately" data-x-internal="remove-an-element-from-the-top-layer-immediately">remove an element from the top layer immediately</a> given
   <var>element</var>.</p></li><li><p>Set <var>element</var>'s <a href="#popover-trigger" id="the-popover-attribute:popover-trigger-3">popover trigger</a> to null.</p></li><li><p>Set <var>element</var>'s <a href="#opened-in-popover-mode" id="the-popover-attribute:opened-in-popover-mode-4">opened in popover mode</a> to null.</p></li><li><p>Set <var>element</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-3">popover visibility state</a> to <a href="#popover-hidden-state" id="the-popover-attribute:popover-hidden-state-2">hidden</a>.</p></li><li><p>If <var>fireEvents</var> is true, then <a href="#queue-a-popover-toggle-event-task" id="the-popover-attribute:queue-a-popover-toggle-event-task-2">queue a popover toggle event task</a>
   given <var>element</var>, "<code>open</code>", "<code>closed</code>", and
   <var>source</var>.</p></li><li><p>Let <var>previouslyFocusedElement</var> be <var>element</var>'s <a href="#previously-focused-element" id="the-popover-attribute:previously-focused-element-3">previously focused
   element</a>.</p></li><li>
    <p>If <var>previouslyFocusedElement</var> is not null, then:</p>

    <ol><li><p>Set <var>element</var>'s <a href="#previously-focused-element" id="the-popover-attribute:previously-focused-element-4">previously focused element</a> to null.</p></li><li><p>If <var>focusPreviousElement</var> is true and <var>document</var>'s <a href="#focused-area-of-the-document" id="the-popover-attribute:focused-area-of-the-document-2">focused area
     of the document</a>'s <a href="#dom-anchor" id="the-popover-attribute:dom-anchor-2">DOM anchor</a> is a <a id="the-popover-attribute:shadow-including-inclusive-descendant" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant" data-x-internal="shadow-including-inclusive-descendant">shadow-including inclusive
     descendant</a> of <var>element</var>, then run the <a href="#focusing-steps" id="the-popover-attribute:focusing-steps">focusing steps</a> for
     <var>previouslyFocusedElement</var>; the viewport should not be scrolled by doing this
     step.</p></li></ol>
   </li><li><p>Run <var>cleanupSteps</var>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/togglePopover" title="The togglePopover() method of the HTMLElement interface toggles a popover element (i.e. one that has a valid popover attribute) between the hidden and showing states.">HTMLElement/togglePopover</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-togglepopover" data-dfn-type="method"><code>togglePopover(<var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>force</var> be null.</p></li><li><p>If <var>options</var> is a boolean, set <var>force</var> to <var>options</var>.</p></li><li><p>Otherwise, if <var>options</var>["<code id="the-popover-attribute:dom-togglepopoveroptions-force"><a href="#dom-togglepopoveroptions-force">force</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-popover-attribute:map-exists-2" data-x-internal="map-exists">exists</a>,
   set <var>force</var> to <var>options</var>["<code id="the-popover-attribute:dom-togglepopoveroptions-force-2"><a href="#dom-togglepopoveroptions-force">force</a></code>"].</p></li><li><p>Let <var>source</var> be <var>options</var>["<code id="the-popover-attribute:dom-showpopoveroptions-source-2"><a href="#dom-showpopoveroptions-source">source</a></code>"] if it <a href="https://infra.spec.whatwg.org/#map-exists" id="the-popover-attribute:map-exists-3" data-x-internal="map-exists">exists</a>; otherwise, null.</p></li><li><p>If <a id="the-popover-attribute:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-4">popover visibility state</a> is <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-3">showing</a>, and <var>force</var> is null or false, then run
   the <a href="#hide-popover-algorithm" id="the-popover-attribute:hide-popover-algorithm-4">hide popover algorithm</a> given <a id="the-popover-attribute:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, true, true, true, and
   null.</p></li><li><p>Otherwise, if <var>force</var> is null or true, then run <a href="#show-popover" id="the-popover-attribute:show-popover-2">show popover</a> given
   <a id="the-popover-attribute:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, true, and <var>source</var>.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>expectedToBeShowing</var> be true if <a id="the-popover-attribute:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-5">popover
     visibility state</a> is <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-4">showing</a>; otherwise
     false.</p></li><li><p>Run <a href="#check-popover-validity" id="the-popover-attribute:check-popover-validity-11">check popover validity</a> given <var>expectedToBeShowing</var>, true, and
     null.</p></li></ol>
   </li><li><p>Return true if <a id="the-popover-attribute:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-6">popover visibility state</a> is <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-5">showing</a>; otherwise false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="hide-all-popovers-until" data-export="">hide all popovers until</dfn>, given an <a href="#html-elements" id="the-popover-attribute:html-elements-15">HTML element</a> or <code id="the-popover-attribute:document-2"><a href="#document">Document</a></code> <var>endpoint</var>, a boolean
  <var>focusPreviousElement</var>, and a boolean <var>fireEvents</var>:</p>

  <ol><li><p>If <var>endpoint</var> is an <a href="#html-elements" id="the-popover-attribute:html-elements-16">HTML element</a> and
   <var>endpoint</var> is not in the <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-6">popover showing
   state</a>, then return.</p></li><li><p>Let <var>document</var> be <var>endpoint</var>'s <a id="the-popover-attribute:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p><a id="the-popover-attribute:assert-7" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>endpoint</var> is a <code id="the-popover-attribute:document-3"><a href="#document">Document</a></code> or
   <var>endpoint</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-7">popover visibility state</a> is <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-7">showing</a>.</p></li><li><p><a id="the-popover-attribute:assert-8" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>endpoint</var> is a <code id="the-popover-attribute:document-4"><a href="#document">Document</a></code> or
   <var>endpoint</var>'s <code id="the-popover-attribute:attr-popover-16"><a href="#attr-popover">popover</a></code> attribute is in the <a href="#attr-popover-auto-state" id="the-popover-attribute:attr-popover-auto-state-6">Auto</a> state or <var>endpoint</var>'s <code id="the-popover-attribute:attr-popover-17"><a href="#attr-popover">popover</a></code> attribute is in the <a href="#attr-popover-hint-state" id="the-popover-attribute:attr-popover-hint-state-3">Hint</a> state.</p></li><li>
    <p>If <var>endpoint</var> is a <code id="the-popover-attribute:document-5"><a href="#document">Document</a></code>:</p>

    <ol><li><p>Run <a href="#close-entire-popover-list" id="the-popover-attribute:close-entire-popover-list-3">close entire popover list</a> given <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list-5">showing
     hint popover list</a>, <var>focusPreviousElement</var>, and <var>fireEvents</var>.</p></li><li><p>Run <a href="#close-entire-popover-list" id="the-popover-attribute:close-entire-popover-list-4">close entire popover list</a> given <var>document</var>'s <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-6">showing
     auto popover list</a>, <var>focusPreviousElement</var>, and <var>fireEvents</var>.</p></li><li><p>Return.</p></li></ol>
   </li><li>
    <p>If <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list-6">showing hint popover list</a> contains
    <var>endpoint</var>:</p>

    <ol><li><p><a id="the-popover-attribute:assert-9" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>endpoint</var>'s <code id="the-popover-attribute:attr-popover-18"><a href="#attr-popover">popover</a></code>
     attribute is in the <a href="#attr-popover-hint-state" id="the-popover-attribute:attr-popover-hint-state-4">Hint</a> state.</p></li><li><p>Run <a href="#hide-popover-stack-until" id="the-popover-attribute:hide-popover-stack-until">hide popover stack until</a> given <var>endpoint</var>,
     <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list-7">showing hint popover list</a>, <var>focusPreviousElement</var>,
     and <var>fireEvents</var>.</p></li><li><p>Return.</p></li></ol>
   </li><li><p>Run <a href="#close-entire-popover-list" id="the-popover-attribute:close-entire-popover-list-5">close entire popover list</a> given <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list-8">showing hint
   popover list</a>, <var>focusPreviousElement</var>, and <var>fireEvents</var>.</p></li><li><p>If <var>document</var>'s <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-7">showing auto popover list</a> does not contain
   <var>endpoint</var>, then return.</p></li><li><p>Run <a href="#hide-popover-stack-until" id="the-popover-attribute:hide-popover-stack-until-2">hide popover stack until</a> given <var>endpoint</var>, <var>document</var>'s
   <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-8">showing auto popover list</a>, <var>focusPreviousElement</var>, and
   <var>fireEvents</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="hide-popover-stack-until">hide popover stack until</dfn>, given an <a href="#html-elements" id="the-popover-attribute:html-elements-17">HTML
  element</a> <var>endpoint</var>, a <a id="the-popover-attribute:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> <var>popoverList</var>, a boolean
  <var>focusPreviousElement</var>, and a boolean <var>fireEvents</var>:</p>

  <ol><li><p>Let <var>repeatingHide</var> be false.</p></li><li>
    <p>Perform the following steps at least once:</p>

    <ol><li><p>Let <var>lastToHide</var> be null.</p></li><li>
      <p>For each <var>popover</var> in <var>popoverList</var>:</p>

      <ol><li><p>If <var>popover</var> is <var>endpoint</var>, then <a id="the-popover-attribute:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li><li><p>Set <var>lastToHide</var> to <var>popover</var>.</p></li></ol>
     </li><li><p>If <var>lastToHide</var> is null, then return.</p></li><li>
      <p><a id="the-popover-attribute:while" href="https://infra.spec.whatwg.org/#iteration-while" data-x-internal="while">While</a> <var>lastToHide</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-8">popover visibility state</a> is <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-8">showing</a>:</p>

      <ol><li><p><a id="the-popover-attribute:assert-10" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>popoverList</var> is not empty.</p></li><li><p>Run the <a href="#hide-popover-algorithm" id="the-popover-attribute:hide-popover-algorithm-5">hide popover algorithm</a> given the last item in
       <var>popoverList</var>, <var>focusPreviousElement</var>, <var>fireEvents</var>, false, and
       null.</p></li></ol>
     </li><li><p><a id="the-popover-attribute:assert-11" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>repeatingHide</var> is false or <var>popoverList</var>'s last
     item is <var>endpoint</var>.</p></li><li><p>Set <var>repeatingHide</var> to true if <var>popoverList</var> contains
     <var>endpoint</var> and <var>popoverList</var>'s last item is not <var>endpoint</var>,
     otherwise false.</p></li><li><p>If <var>repeatingHide</var> is true, then set <var>fireEvents</var> to false.</p></li></ol>

    <p>and keep performing them <a id="the-popover-attribute:while-2" href="https://infra.spec.whatwg.org/#iteration-while" data-x-internal="while">while</a> <var>repeatingHide</var> is true.</p>
   </li></ol>
  </div>

  <p class="note">The <a href="#hide-all-popovers-until" id="the-popover-attribute:hide-all-popovers-until-8">hide all popovers until
  algorithm</a> is used in several cases to hide all popovers that don't stay open when something
  happens. For example, during light-dismiss of a popover, this algorithm ensures that we close only
  the popovers that aren't related to the node clicked by the user.</p>

  <div data-algorithm="">
  <p>To find the <dfn id="topmost-popover-ancestor" data-export="">topmost popover ancestor</dfn>, given a <code id="the-popover-attribute:node"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code>
  <var>newPopoverOrTopLayerElement</var>, a <a id="the-popover-attribute:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> <var>popoverList</var>, an <a href="#html-elements" id="the-popover-attribute:html-elements-18">HTML element</a> or null <var>source</var>, and a boolean
  <var>isPopover</var>, perform the following steps. They return an <a href="#html-elements" id="the-popover-attribute:html-elements-19">HTML element</a> or null.</p>

  <div class="note">
   <p>The <a href="#topmost-popover-ancestor" id="the-popover-attribute:topmost-popover-ancestor-5">topmost popover ancestor</a> algorithm will return the topmost (latest in the
   <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-9">showing auto popover list</a>) ancestor popover for the provided popover or top layer
   element. Popovers can be related to each other in several ways, creating a tree of popovers.
   There are two paths through which one popover (call it the "child" popover) can have a topmost
   ancestor popover (call it the "parent" popover):</p>

   <ol><li><p>The popovers are nested within each other in the node tree. In this case, the descendant
    popover is the "child" and its topmost ancestor popover is the "parent".</p></li><li><p>A popover trigger element (e.g., a <code id="the-popover-attribute:the-button-element"><a href="#the-button-element">button</a></code>) has a <code id="the-popover-attribute:attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code> attribute pointing to a popover. In this case,
    the popover is the "child", and the popover subtree the trigger element is in is the
    "parent". The trigger element has to be in a popover and reference an open popover.</p></li></ol>

   <p>In each of the relationships formed above, the parent popover has to be strictly earlier in
   the <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-10">showing auto popover list</a> than the child popover, or it does not form a valid
   ancestral relationship. This eliminates non-showing popovers and self-pointers (e.g., a popover
   containing an invoking element that points back to the containing popover), and it allows for the
   construction of a well-formed tree from the (possibly cyclic) graph of connections. Only <a href="#attr-popover-auto-state" id="the-popover-attribute:attr-popover-auto-state-7">Auto</a> popovers are considered.</p>

   <p>If the provided element is a top layer element such as a <code id="the-popover-attribute:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> which is not
   showing as a popover, then <a href="#topmost-popover-ancestor" id="the-popover-attribute:topmost-popover-ancestor-6">topmost popover ancestor</a> will only look in the node tree
   to find the first popover.</p>
  </div>

  <ol><li>
    <p>If <var>isPopover</var> is true:</p>

    <ol><li><p><a id="the-popover-attribute:assert-12" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>newPopoverOrTopLayerElement</var> is an <a href="#html-elements" id="the-popover-attribute:html-elements-20">HTML element</a>.</p></li><li><p><a id="the-popover-attribute:assert-13" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>newPopoverOrTopLayerElement</var>'s <code id="the-popover-attribute:attr-popover-19"><a href="#attr-popover">popover</a></code> attribute is not in the <a href="#attr-popover-none-state" id="the-popover-attribute:attr-popover-none-state-2">No Popover State</a> or the <a href="#attr-popover-manual-state" id="the-popover-attribute:attr-popover-manual-state-2">Manual</a> state.</p></li><li><p><a id="the-popover-attribute:assert-14" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>newPopoverOrTopLayerElement</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-9">popover visibility
     state</a> is not in the <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-9">popover showing
     state</a>.</p></li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p><a id="the-popover-attribute:assert-15" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>source</var> is null.</p></li></ol>
   </li><li><p>Let <var>popoverPositions</var> be an empty <a id="the-popover-attribute:ordered-map" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>.</p></li><li><p>Let <var>index</var> be 0.</p></li><li>
    <p>For each <var>popover</var> of <var>popoverList</var>:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="the-popover-attribute:map-set" data-x-internal="map-set">Set</a> <var>popoverPositions</var>[<var>popover</var>] to
     <var>index</var>.</p></li><li><p>Increment <var>index</var> by 1.</p></li></ol>
   </li><li><p>If <var>isPopover</var> is true, then <a href="https://infra.spec.whatwg.org/#map-set" id="the-popover-attribute:map-set-2" data-x-internal="map-set">set</a>
   <var>popoverPositions</var>[<var>newPopoverOrTopLayerElement</var>] to <var>index</var>.</p></li><li><p>Increment <var>index</var> by 1.</p></li><li><p>Let <var>topmostPopoverAncestor</var> be null.</p></li><li>
    <p>Let <var>checkAncestor</var> be an algorithm which performs the following steps given
    <var>candidate</var>:</p>

    <ol><li><p>If <var>candidate</var> is null, then return.</p></li><li><p>Let <var>okNesting</var> be false.</p></li><li><p>Let <var>candidateAncestor</var> be null.</p></li><li>
      <p><a id="the-popover-attribute:while-3" href="https://infra.spec.whatwg.org/#iteration-while" data-x-internal="while">While</a> <var>okNesting</var> is false:</p>

      <ol><li><p>Set <var>candidateAncestor</var> to the result of running <a href="#nearest-inclusive-open-popover" id="the-popover-attribute:nearest-inclusive-open-popover">nearest inclusive open
       popover</a> given <var>candidate</var>.</p></li><li><p>If <var>candidateAncestor</var> is null or <var>popoverPositions</var> does not
       contain <var>candidateAncestor</var>, then return.</p></li><li><p><a id="the-popover-attribute:assert-16" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>candidateAncestor</var>'s <code id="the-popover-attribute:attr-popover-20"><a href="#attr-popover">popover</a></code> attribute is not in the <a href="#attr-popover-manual-state" id="the-popover-attribute:attr-popover-manual-state-3">Manual</a> or <a href="#attr-popover-none-state" id="the-popover-attribute:attr-popover-none-state-3">None</a> state.</p></li><li><p>Set <var>okNesting</var> to true if <var>isPopover</var> is false,
       <var>newPopoverOrTopLayerElement</var>'s <code id="the-popover-attribute:attr-popover-21"><a href="#attr-popover">popover</a></code> attribute
       is in the <a href="#attr-popover-hint-state" id="the-popover-attribute:attr-popover-hint-state-5">Hint</a> state, or
       <var>candidateAncestor</var>'s <code id="the-popover-attribute:attr-popover-22"><a href="#attr-popover">popover</a></code> attribute is in the
       <a href="#attr-popover-auto-state" id="the-popover-attribute:attr-popover-auto-state-8">Auto</a> state.</p></li><li><p>If <var>okNesting</var> is false, then set <var>candidate</var> to
       <var>candidateAncestor</var>'s parent in the <a id="the-popover-attribute:flat-tree" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a>.</p></li></ol>
     </li><li><p>Let <var>candidatePosition</var> be
     <var>popoverPositions</var>[<var>candidateAncestor</var>].</p></li><li><p>If <var>topmostPopoverAncestor</var> is null or
     <var>popoverPositions</var>[<var>topmostPopoverAncestor</var>] is less than
     <var>candidatePosition</var>, then set <var>topmostPopoverAncestor</var> to
     <var>candidateAncestor</var>.</p></li></ol>
   </li><li><p>Run <var>checkAncestor</var> given <var>newPopoverOrTopLayerElement</var>'s parent node
   within the <a id="the-popover-attribute:flat-tree-2" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat tree</a>.</p></li><li><p>Run <var>checkAncestor</var> given <var>source</var>.</p></li><li><p>Return <var>topmostPopoverAncestor</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To find the <dfn id="nearest-inclusive-open-popover">nearest inclusive open popover</dfn> given a <code id="the-popover-attribute:node-2"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code>
  <var>node</var>, perform the following steps. They return an <a href="#html-elements" id="the-popover-attribute:html-elements-21">HTML
  element</a> or null.</p>

  <ol><li><p>Let <var>currentNode</var> be <var>node</var>.</p></li><li>
    <p>While <var>currentNode</var> is not null:</p>

    <ol><li><p>If <var>currentNode</var>'s <code id="the-popover-attribute:attr-popover-23"><a href="#attr-popover">popover</a></code> attribute is in
     the <a href="#attr-popover-auto-state" id="the-popover-attribute:attr-popover-auto-state-9">Auto</a> state or the <a href="#attr-popover-hint-state" id="the-popover-attribute:attr-popover-hint-state-6">Hint</a> state, and <var>currentNode</var>'s
     <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-10">popover visibility state</a> is <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-10">showing</a>,
     then return <var>currentNode</var>.</p></li><li><p>Set <var>currentNode</var> to <var>currentNode</var>'s parent in the <a id="the-popover-attribute:flat-tree-3" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat
     tree</a>.</p></li></ol>
   </li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="topmost-auto-popover">find the topmost auto or hint popover</dfn> given a
  <code id="the-popover-attribute:document-6"><a href="#document">Document</a></code> <var>document</var>, perform the following steps. They return an <a href="#html-elements" id="the-popover-attribute:html-elements-22">HTML element</a> or null.</p>

  <ol><li><p>If <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list-9">showing hint popover list</a> is not empty, then return
   <var>document</var>'s <a href="#showing-hint-popover-list" id="the-popover-attribute:showing-hint-popover-list-10">showing hint popover list</a>'s last element.</p></li><li><p>If <var>document</var>'s <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-11">showing auto popover list</a> is not empty, then return
   <var>document</var>'s <a href="#auto-popover-list" id="the-popover-attribute:auto-popover-list-12">showing auto popover list</a>'s last element.</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To perform the <dfn id="popover-focusing-steps">popover focusing steps</dfn> for an <a href="#html-elements" id="the-popover-attribute:html-elements-23">HTML
  element</a> <var>subject</var>:</p>

  <ol><li><p>If the <a href="#allow-focus-steps" id="the-popover-attribute:allow-focus-steps">allow focus steps</a> given <var>subject</var>'s <a id="the-popover-attribute:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a> return false, then return.</p></li><li><p>If <var>subject</var> is a <code id="the-popover-attribute:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code> element, then run the <a href="#dialog-focusing-steps" id="the-popover-attribute:dialog-focusing-steps">dialog focusing
   steps</a> given <var>subject</var> and return.</p></li><li><p>If <var>subject</var> has the <code id="the-popover-attribute:attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code>
   attribute, then let <var>control</var> be <var>subject</var>.

   </p></li><li><p>Otherwise, let <var>control</var> be the <a href="#autofocus-delegate" id="the-popover-attribute:autofocus-delegate">autofocus delegate</a> for
   <var>subject</var> given "<code>other</code>".</p></li><li><p>If <var>control</var> is null, then return.</p></li><li><p>Run the <a href="#focusing-steps" id="the-popover-attribute:focusing-steps-2">focusing steps</a> given <var>control</var>.</p></li><li><p>Let <var>topDocument</var> be <var>control</var>'s <a href="#node-navigable" id="the-popover-attribute:node-navigable">node navigable</a>'s <a href="#nav-top" id="the-popover-attribute:nav-top">top-level traversable</a>'s <a href="#nav-document" id="the-popover-attribute:nav-document">active
   document</a>.</p></li><li><p>If <var>control</var>'s <a id="the-popover-attribute:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-popover-attribute:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is not the <a href="#same-origin" id="the-popover-attribute:same-origin">same</a>
   as the <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-popover-attribute:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> of <var>topDocument</var>, then
   return.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-empty" id="the-popover-attribute:list-empty" data-x-internal="list-empty">Empty</a> <var>topDocument</var>'s
   <a href="#autofocus-candidates" id="the-popover-attribute:autofocus-candidates">autofocus candidates</a>.</p></li><li><p>Set <var>topDocument</var>'s <a href="#autofocus-processed-flag" id="the-popover-attribute:autofocus-processed-flag">autofocus processed flag</a> to true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="check-popover-validity">check popover validity</dfn> for an <a href="#html-elements" id="the-popover-attribute:html-elements-24">HTML element</a>
  <var>element</var> given a boolean <var>expectedToBeShowing</var>, a boolean
  <var>throwExceptions</var>, and a <code id="the-popover-attribute:document-7"><a href="#document">Document</a></code> or null <var>expectedDocument</var>,
  perform the following steps. They throw an exception or return a boolean.</p>

  <ol><li>
    <p>If <var>element</var>'s <code id="the-popover-attribute:attr-popover-24"><a href="#attr-popover">popover</a></code> attribute is in the <a href="#attr-popover-none-state" id="the-popover-attribute:attr-popover-none-state-4">No Popover</a> state, then:</p>

    <ol><li><p>If <var>throwExceptions</var> is true, then throw a
     <a id="the-popover-attribute:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="the-popover-attribute:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return false.</p></li></ol>
   </li><li>
    <p>If any of the following are true:</p>

    <ul><li><p><var>expectedToBeShowing</var> is true and <var>element</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-11">popover visibility
     state</a> is not <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-11">showing</a>; or</p></li><li><p><var>expectedToBeShowing</var> is false and <var>element</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-12">popover
     visibility state</a> is not <a href="#popover-hidden-state" id="the-popover-attribute:popover-hidden-state-3">hidden</a>,</p></li></ul>

    <p>then return false.</p>
   </li><li>
    <p>If any of the following are true:</p>

    <ul><li><p><var>element</var> is not <a id="the-popover-attribute:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>;</p></li><li><p><var>element</var>'s <a id="the-popover-attribute:node-document-6" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not <a href="#fully-active" id="the-popover-attribute:fully-active">fully
     active</a>;</p></li><li><p><var>expectedDocument</var> is not null and <var>element</var>'s <a id="the-popover-attribute:node-document-7" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
     document</a> is not <var>expectedDocument</var>;</p></li><li><p><var>element</var> is a <code id="the-popover-attribute:the-dialog-element-3"><a href="#the-dialog-element">dialog</a></code> element and its <a href="#is-modal" id="the-popover-attribute:is-modal">is modal</a>
     is set to true; or</p></li><li><p><var>element</var>'s <a id="the-popover-attribute:fullscreen-flag" href="https://fullscreen.spec.whatwg.org/#fullscreen-flag" data-x-internal="fullscreen-flag">fullscreen flag</a> is set,</p></li></ul>

    <p>then:</p>

    <ol><li><p>If <var>throwExceptions</var> is true, then throw an
     <a id="the-popover-attribute:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-popover-attribute:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return false.</p></li></ol>
   </li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To get the <dfn id="auto-popover-list">showing auto popover list</dfn> for a
  <code id="the-popover-attribute:document-8"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p>Let <var>popovers</var> be « ».</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-popover-attribute:list-iterate" data-x-internal="list-iterate">For each</a> <code id="the-popover-attribute:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> <var>element</var> in
    <var>document</var>'s <a id="the-popover-attribute:top-layer-2" href="https://drafts.csswg.org/css-position-4/#document-top-layer" data-x-internal="top-layer">top layer</a>:</p>

    <ol><li>
      <p>If all of the following are true:</p>

      <ul><li><p><var>element</var> is an <a href="#html-elements" id="the-popover-attribute:html-elements-25">HTML element</a>;</p></li><li><p><var>element</var>'s <a href="#opened-in-popover-mode" id="the-popover-attribute:opened-in-popover-mode-5">opened in popover mode</a> is "<code>auto</code>"; and</p></li><li><p><var>element</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-13">popover visibility state</a> is <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-12">showing</a>,</p></li></ul>

      <p>then <a href="https://infra.spec.whatwg.org/#list-append" id="the-popover-attribute:list-append" data-x-internal="list-append">append</a> <var>element</var> to
      <var>popovers</var>.</p>
     </li></ol>
   </li><li><p>Return <var>popovers</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To get the <dfn id="showing-hint-popover-list">showing hint popover list</dfn> for a <code id="the-popover-attribute:document-9"><a href="#document">Document</a></code>
  <var>document</var>:</p>

  <ol><li><p>Let <var>popovers</var> be « ».</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-popover-attribute:list-iterate-2" data-x-internal="list-iterate">For each</a> <code id="the-popover-attribute:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> <var>element</var> in
    <var>document</var>'s <a id="the-popover-attribute:top-layer-3" href="https://drafts.csswg.org/css-position-4/#document-top-layer" data-x-internal="top-layer">top layer</a>:</p>

    <ol><li>
      <p>If all of the following are true:</p>

      <ul><li><p><var>element</var> is an <a href="#html-elements" id="the-popover-attribute:html-elements-26">HTML element</a>;</p></li><li><p><var>element</var>'s <a href="#opened-in-popover-mode" id="the-popover-attribute:opened-in-popover-mode-6">opened in popover mode</a> is "<code>hint</code>"; and</p></li><li><p><var>element</var>'s <a href="#popover-visibility-state" id="the-popover-attribute:popover-visibility-state-14">popover visibility state</a> is <a href="#popover-showing-state" id="the-popover-attribute:popover-showing-state-13">showing</a>,</p></li></ul>

      <p>then <a href="https://infra.spec.whatwg.org/#list-append" id="the-popover-attribute:list-append-2" data-x-internal="list-append">append</a> <var>element</var> to
      <var>popovers</var>.</p>
     </li></ol>
   </li><li><p>Return <var>popovers</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="close-entire-popover-list">close entire popover list</dfn> given a <a id="the-popover-attribute:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> <var>popoverList</var>, a
  boolean <var>focusPreviousElement</var>, and a boolean <var>fireEvents</var>:</p>

  <ol><li>
    <p>While <var>popoverList</var> is not empty:</p>

    <ol><li><p>Run the <a href="#hide-popover-algorithm" id="the-popover-attribute:hide-popover-algorithm-6">hide popover algorithm</a> given <var>popoverList</var>'s last item,
     <var>focusPreviousElement</var>, <var>fireEvents</var>, false, and null.</p></li></ol>
   </li></ol>
  </div>

  <h4 id="the-popover-target-attributes"><span class="secno">6.12.1</span> The popover target attributes<a href="#the-popover-target-attributes" class="self-link"></a></h4>

  <p><a href="#concept-button" id="the-popover-target-attributes:concept-button">Buttons</a> may have the following content attributes:</p>

  <ul><li><p><dfn data-dfn-for="html-global" id="attr-popovertarget" data-dfn-type="element-attr"><code>popovertarget</code></dfn></p></li><li><p><dfn data-dfn-for="html-global" id="attr-popovertargetaction" data-dfn-type="element-attr"><code>popovertargetaction</code></dfn></p></li></ul>

  <p>If specified, the <code id="the-popover-target-attributes:attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code> attribute value must
  be the <a href="https://dom.spec.whatwg.org/#concept-id" id="the-popover-target-attributes:concept-id" data-x-internal="concept-id">ID</a> of an element with a <code id="the-popover-target-attributes:attr-popover"><a href="#attr-popover">popover</a></code> attribute in the same <a id="the-popover-target-attributes:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> as the <a href="#concept-button" id="the-popover-target-attributes:concept-button-2">button</a> with the <code id="the-popover-target-attributes:attr-popovertarget-2"><a href="#attr-popovertarget">popovertarget</a></code> attribute.</p>

  <p>The <code id="the-popover-target-attributes:attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code> attribute is an
  <a href="#enumerated-attribute" id="the-popover-target-attributes:enumerated-attribute">enumerated attribute</a> with the following keywords and states:</p>

  <table><thead><tr><th>Keyword
     </th><th>State
     </th><th>Brief description
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="html-global/popovertargetaction" id="attr-popovertargetaction-toggle" data-dfn-type="attr-value"><code>toggle</code></dfn>
     </td><td><dfn id="attr-popovertargetaction-toggle-state">Toggle</dfn>
     </td><td>Shows or hides the targeted popover element.
    </td></tr><tr><td><dfn data-dfn-for="html-global/popovertargetaction" id="attr-popovertargetaction-show" data-dfn-type="attr-value"><code>show</code></dfn>
     </td><td><dfn id="attr-popovertargetaction-show-state">Show</dfn>
     </td><td>Shows the targeted popover element.
    </td></tr><tr><td><dfn data-dfn-for="html-global/popovertargetaction" id="attr-popovertargetaction-hide" data-dfn-type="attr-value"><code>hide</code></dfn>
     </td><td><dfn id="attr-popovertargetaction-hide-state">Hide</dfn>
     </td><td>Hides the targeted popover element.
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-popover-target-attributes:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-popover-target-attributes:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#attr-popovertargetaction-toggle-state" id="the-popover-target-attributes:attr-popovertargetaction-toggle-state">Toggle</a> state.</p>
  </div>

  <p class="note">Whenever possible ensure the popover element is placed immediately after its
  triggering element in the DOM. Doing so will help ensure that the popover is exposed in a logical
  programmatic reading order for users of assistive technology, such as screen readers.</p>

  <div class="example">
   <p>The following shows how the <code id="the-popover-target-attributes:attr-popovertarget-3"><a href="#attr-popovertarget">popovertarget</a></code> attribute
   in combination with the <code id="the-popover-target-attributes:attr-popovertargetaction-2"><a href="#attr-popovertargetaction">popovertargetaction</a></code>
   attribute can be used to show and close a popover:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">popovertarget</c-><c- o="">=</c-><c- s="">"foo"</c-> <c- e="">popovertargetaction</c-><c- o="">=</c-><c- s="">"show"</c-><c- p="">&gt;</c->
  Show a popover
<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">article</c-> <c- e="">popover</c-><c- o="">=</c-><c- s="">"auto"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"foo"</c-><c- p="">&gt;</c->
  This is a popover article!
  <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">popovertarget</c-><c- o="">=</c-><c- s="">"foo"</c-> <c- e="">popovertargetaction</c-><c- o="">=</c-><c- s="">"hide"</c-><c- p="">&gt;</c->Close<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">article</c-><c- p="">&gt;</c-></code></pre>

   <p>If a <code id="the-popover-target-attributes:attr-popovertargetaction-3"><a href="#attr-popovertargetaction">popovertargetaction</a></code> attribute is not
   specified, the default action will be to toggle the associated popover. The following shows
   how only specifying the <code id="the-popover-target-attributes:attr-popovertarget-4"><a href="#attr-popovertarget">popovertarget</a></code> attribute on its
   invoking button can toggle a manual popover between its opened and closed states. A manual
   popover will not respond to <a href="#popover-light-dismiss" id="the-popover-target-attributes:popover-light-dismiss">light dismiss</a> or <a href="#close-request" id="the-popover-target-attributes:close-request">close requests</a>:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"button"</c-> <c- e="">popovertarget</c-><c- o="">=</c-><c- s="">"foo"</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"Toggle the popover"</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">popover</c-><c- o="">=</c-><c- s="">manual</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"foo"</c-><c- p="">&gt;</c->
  This is a popover!
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <a href="#concept-element-dom" id="the-popover-target-attributes:concept-element-dom">DOM interface</a>:
  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/popoverTargetElement" title="The popoverTargetElement property of the HTMLButtonElement interface gets and sets the popover element to control via a button.">HTMLButtonElement/popoverTargetElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/popoverTargetElement" title="The popoverTargetElement property of the HTMLInputElement interface gets and sets the popover element to control via an <input> element of type=&quot;button&quot;.">HTMLInputElement/popoverTargetElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="popovertargetattributes" data-dfn-type="interface"><c- g="">PopoverTargetAttributes</c-></dfn> {
  [<a href="#cereactions" id="the-popover-target-attributes:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-popover-target-attributes:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- n="">Element</c->? <dfn data-dfn-for="HTMLElement" id="dom-popovertargetelement" data-dfn-type="attribute"><c- g="">popoverTargetElement</c-></dfn>;
  [<a href="#cereactions" id="the-popover-target-attributes:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-popovertargetaction" id="the-popover-target-attributes:dom-popovertargetaction"><c- g="">popoverTargetAction</c-></a>;
};</code></pre>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/popoverTargetAction" title="The popoverTargetAction property of the HTMLButtonElement interface gets and sets the action to be performed (&quot;hide&quot;, &quot;show&quot;, or &quot;toggle&quot;) on a popover element being controlled by a button.">HTMLButtonElement/popoverTargetAction</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/popoverTargetAction" title="The popoverTargetAction property of the HTMLInputElement interface gets and sets the action to be performed (&quot;hide&quot;, &quot;show&quot;, or &quot;toggle&quot;) on a popover element being controlled by an <input> element of type=&quot;button&quot;.">HTMLInputElement/popoverTargetAction</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>17+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLElement" id="dom-popovertargetaction" data-dfn-type="attribute"><code>popoverTargetAction</code></dfn> IDL attribute must
  <a href="#reflect" id="the-popover-target-attributes:reflect">reflect</a> the <code id="the-popover-target-attributes:attr-popovertargetaction-4"><a href="#attr-popovertargetaction">popovertargetaction</a></code>
  attribute, <a href="#limited-to-only-known-values" id="the-popover-target-attributes:limited-to-only-known-values">limited to only known values</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To run the <dfn id="popover-target-attribute-activation-behavior">popover target attribute activation behavior</dfn> given a <code id="the-popover-target-attributes:node"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code>
  <var>node</var> and a <code id="the-popover-target-attributes:node-2"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code> <var>eventTarget</var>:</p>

  <ol><li><p>Let <var>popover</var> be <var>node</var>'s <a href="#popover-target-element" id="the-popover-target-attributes:popover-target-element">popover target element</a>.</p></li><li><p>If <var>popover</var> is null, then return.</p></li><li><p>If <var>eventTarget</var> is a <a id="the-popover-target-attributes:shadow-including-inclusive-descendant" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant" data-x-internal="shadow-including-inclusive-descendant">shadow-including inclusive descendant</a> of
   <var>popover</var> and <var>popover</var> is a
   <a href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant" id="the-popover-target-attributes:shadow-including-descendant" data-x-internal="shadow-including-descendant">shadow-including descendant</a> of <var>node</var>,
   then return.</p></li><li><p>If <var>node</var>'s <code id="the-popover-target-attributes:attr-popovertargetaction-5"><a href="#attr-popovertargetaction">popovertargetaction</a></code>
   attribute is in the <a href="#attr-popovertargetaction-show" id="the-popover-target-attributes:attr-popovertargetaction-show">show</a> state and
   <var>popover</var>'s <a href="#popover-visibility-state" id="the-popover-target-attributes:popover-visibility-state">popover visibility state</a> is <a href="#popover-showing-state" id="the-popover-target-attributes:popover-showing-state">showing</a>, then return.</p></li><li><p>If <var>node</var>'s <code id="the-popover-target-attributes:attr-popovertargetaction-6"><a href="#attr-popovertargetaction">popovertargetaction</a></code>
   attribute is in the <a href="#attr-popovertargetaction-hide" id="the-popover-target-attributes:attr-popovertargetaction-hide">hide</a> state and
   <var>popover</var>'s <a href="#popover-visibility-state" id="the-popover-target-attributes:popover-visibility-state-2">popover visibility state</a> is <a href="#popover-hidden-state" id="the-popover-target-attributes:popover-hidden-state">hidden</a>, then return.</p></li><li><p>If <var>popover</var>'s <a href="#popover-visibility-state" id="the-popover-target-attributes:popover-visibility-state-3">popover visibility state</a> is <a href="#popover-showing-state" id="the-popover-target-attributes:popover-showing-state-2">showing</a>, then run the <a href="#hide-popover-algorithm" id="the-popover-target-attributes:hide-popover-algorithm">hide popover algorithm</a>
   given <var>popover</var>, true, true, false, and <var>node</var>.</p></li><li><p>Otherwise, if <var>popover</var>'s <a href="#popover-visibility-state" id="the-popover-target-attributes:popover-visibility-state-4">popover visibility state</a> is <a href="#popover-hidden-state" id="the-popover-target-attributes:popover-hidden-state-2">hidden</a> and the result of running <a href="#check-popover-validity" id="the-popover-target-attributes:check-popover-validity">check popover
   validity</a> given <var>popover</var>, false, false, and null is true, then run <a href="#show-popover" id="the-popover-target-attributes:show-popover">show
   popover</a> given <var>popover</var>, false, and <var>node</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To get the <dfn id="popover-target-element">popover target element</dfn> given a <code id="the-popover-target-attributes:node-3"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code> <var>node</var>, perform
  the following steps. They return an <a href="#html-elements" id="the-popover-target-attributes:html-elements">HTML element</a> or null.</p>

  <ol><li><p>If <var>node</var> is not a <a href="#concept-button" id="the-popover-target-attributes:concept-button-3">button</a>, then return
   null.</p></li><li><p>If <var>node</var> is <a href="#concept-fe-disabled" id="the-popover-target-attributes:concept-fe-disabled">disabled</a>, then return
   null.</p></li><li><p>If <var>node</var> has a <a href="#form-owner" id="the-popover-target-attributes:form-owner">form owner</a> and <var>node</var> is a <a href="#concept-submit-button" id="the-popover-target-attributes:concept-submit-button">submit button</a>, then return null.</p></li><li><p>Let <var>popoverElement</var> be the result of running <var>node</var>'s <a href="#attr-associated-element" id="the-popover-target-attributes:attr-associated-element">get the <code>popovertarget</code>-associated
   element</a>.</p></li><li><p>If <var>popoverElement</var> is null, then return null.</p></li><li><p>If <var>popoverElement</var>'s <code id="the-popover-target-attributes:attr-popover-2"><a href="#attr-popover">popover</a></code> attribute is in
   the <a href="#attr-popover-none-state" id="the-popover-target-attributes:attr-popover-none-state">No Popover</a> state, then return null.</p></li><li><p>Return <var>popoverElement</var>.</p></li></ol>
  </div>

  <h4 id="popover-light-dismiss"><span class="secno">6.12.2</span> <dfn>Popover light dismiss</dfn><a href="#popover-light-dismiss" class="self-link"></a></h4>

  <p class="note">"Light dismiss" means that clicking outside of a popover whose <code id="popover-light-dismiss:attr-popover"><a href="#attr-popover">popover</a></code> attribute is in the <a href="#attr-popover-auto-state" id="popover-light-dismiss:attr-popover-auto-state">Auto</a> state will close the popover. This is in addition to
  how such popovers respond to <a href="#close-request" id="popover-light-dismiss:close-request">close requests</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="light-dismiss-open-popovers">light dismiss open popovers</dfn>, given a <code id="popover-light-dismiss:pointerevent"><a data-x-internal="pointerevent" href="https://w3c.github.io/pointerevents/#pointerevent-interface">PointerEvent</a></code>
  <var>event</var>:</p>

  <ol><li><p><a id="popover-light-dismiss:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var>'s <code id="popover-light-dismiss:dom-event-istrusted"><a data-x-internal="dom-event-istrusted" href="https://dom.spec.whatwg.org/#dom-event-istrusted">isTrusted</a></code> attribute is true.</p></li><li><p>Let <var>target</var> be <var>event</var>'s <a href="https://dom.spec.whatwg.org/#concept-event-target" id="popover-light-dismiss:concept-event-target" data-x-internal="concept-event-target">target</a>.</p></li><li><p>Let <var>document</var> be <var>target</var>'s <a id="popover-light-dismiss:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>Let <var>topmostPopover</var> be the result of running <a href="#topmost-auto-popover" id="popover-light-dismiss:topmost-auto-popover">topmost auto popover</a>
   given <var>document</var>.</p></li><li><p>If <var>topmostPopover</var> is null, then return.</p></li><li><p>If <var>event</var>'s <code id="popover-light-dismiss:dom-event-type"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> is "<code id="popover-light-dismiss:event-pointerdown"><a data-x-internal="event-pointerdown" href="https://w3c.github.io/pointerevents/#the-pointerdown-event">pointerdown</a></code>", then: set <var>document</var>'s <a href="#popover-pointerdown-target" id="popover-light-dismiss:popover-pointerdown-target">popover
   pointerdown target</a> to the result of running <a href="#topmost-clicked-popover" id="popover-light-dismiss:topmost-clicked-popover">topmost clicked popover</a> given
   <var>target</var>.</p></li><li>
    <p>If <var>event</var>'s <code id="popover-light-dismiss:dom-event-type-2"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> is "<code id="popover-light-dismiss:event-pointerup"><a data-x-internal="event-pointerup" href="https://w3c.github.io/pointerevents/#the-pointerup-event">pointerup</a></code>", then:</p>

    <ol><li><p>Let <var>ancestor</var> be the result of running <a href="#topmost-clicked-popover" id="popover-light-dismiss:topmost-clicked-popover-2">topmost clicked popover</a>
     given <var>target</var>.</p></li><li><p>Let <var>sameTarget</var> be true if <var>ancestor</var> is <var>document</var>'s
     <a href="#popover-pointerdown-target" id="popover-light-dismiss:popover-pointerdown-target-2">popover pointerdown target</a>.</p></li><li><p>Set <var>document</var>'s <a href="#popover-pointerdown-target" id="popover-light-dismiss:popover-pointerdown-target-3">popover pointerdown target</a> to null.</p></li><li><p>If <var>ancestor</var> is null, then set <var>ancestor</var> to
     <var>document</var>.</p></li><li><p>If <var>sameTarget</var> is true, then run <a href="#hide-all-popovers-until" id="popover-light-dismiss:hide-all-popovers-until">hide
     all popovers until</a> given <var>ancestor</var>, false, and true.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To find the <dfn id="topmost-clicked-popover">topmost clicked popover</dfn>, given a <code id="popover-light-dismiss:node"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code> <var>node</var>:</p>

  <ol><li><p>Let <var>clickedPopover</var> be the result of running <a href="#nearest-inclusive-open-popover" id="popover-light-dismiss:nearest-inclusive-open-popover">nearest inclusive open
   popover</a> given <var>node</var>.</p></li><li><p>Let <var>targetPopover</var> be the result of running <a href="#nearest-inclusive-target-popover" id="popover-light-dismiss:nearest-inclusive-target-popover">nearest inclusive target
   popover</a> given <var>node</var>.</p></li><li><p>If the result of <a href="#get-the-popover-stack-position" id="popover-light-dismiss:get-the-popover-stack-position">getting the popover stack
   position</a> given <var>clickedPopover</var> is greater than the result of <a href="#get-the-popover-stack-position" id="popover-light-dismiss:get-the-popover-stack-position-2">getting the popover stack position</a> given
   <var>targetPopover</var>, then return <var>clickedPopover</var>.</p></li><li><p>Return <var>targetPopover</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="get-the-popover-stack-position">get the popover stack position</dfn>, given an <a href="#html-elements" id="popover-light-dismiss:html-elements">HTML
  element</a> <var>popover</var>:</p>

  <ol><li><p>Let <var>hintList</var> be <var>popover</var>'s <a id="popover-light-dismiss:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#showing-hint-popover-list" id="popover-light-dismiss:showing-hint-popover-list">showing
   hint popover list</a>.</p></li><li><p>Let <var>autoList</var> be <var>popover</var>'s <a id="popover-light-dismiss:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#auto-popover-list" id="popover-light-dismiss:auto-popover-list">showing
   auto popover list</a>.</p></li><li><p>If <var>popover</var> is in <var>hintList</var>, then return the index of
   <var>popover</var> in <var>hintList</var> + the size of <var>autoList</var> + 1.</p></li><li><p>If <var>popover</var> is in <var>autoList</var>, then return the index of
   <var>popover</var> in <var>autoList</var> + 1.</p></li><li><p>Return 0.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To find the <dfn id="nearest-inclusive-target-popover">nearest inclusive target popover</dfn> given a <code id="popover-light-dismiss:node-2"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code>
  <var>node</var>:</p>

  <ol><li><p>Let <var>currentNode</var> be <var>node</var>.</p></li><li>
    <p>While <var>currentNode</var> is not null:</p>

    <ol><li><p>Let <var>targetPopover</var> be <var>currentNode</var>'s <a href="#popover-target-element" id="popover-light-dismiss:popover-target-element">popover target
     element</a>.</p></li><li><p>If <var>targetPopover</var> is not null and <var>targetPopover</var>'s <code id="popover-light-dismiss:attr-popover-2"><a href="#attr-popover">popover</a></code> attribute is in the <a href="#attr-popover-auto-state" id="popover-light-dismiss:attr-popover-auto-state-2">Auto</a> state or the <a href="#attr-popover-hint-state" id="popover-light-dismiss:attr-popover-hint-state">Hint</a> state, and <var>targetPopover</var>'s
     <a href="#popover-visibility-state" id="popover-light-dismiss:popover-visibility-state">popover visibility state</a> is <a href="#popover-showing-state" id="popover-light-dismiss:popover-showing-state">showing</a>,
     then return <var>targetPopover</var>.</p></li><li><p>Set <var>currentNode</var> to <var>currentNode</var>'s ancestor in the <a id="popover-light-dismiss:flat-tree" href="https://drafts.csswg.org/css-scoping/#flat-tree" data-x-internal="flat-tree">flat
     tree</a>.</p></li></ol>
   </li></ol>
  </div>


  <h2 id="browsers"><span class="secno">7</span> Loading web pages<a href="#browsers" class="self-link"></a></h2>

  

  <p>This section describes features that apply most directly to web browsers. Having said that,
  except where specified otherwise, the requirements defined in this section <em>do</em> apply to
  all user agents, whether they are web browsers or not.</p>

  

  <h3 id="loading-web-pages-supporting-concepts"><span class="secno">7.1</span> Supporting concepts<a href="#loading-web-pages-supporting-concepts" class="self-link"></a></h3>

  <h4 id="origin"><span class="secno">7.1.1</span> Origins<a href="#origin" class="self-link"></a></h4>
  

  <p>Origins are the fundamental currency of the web's security model. Two actors in the web
  platform that share an origin are assumed to trust each other and to have the same authority.
  Actors with differing origins are considered potentially hostile versus each other, and are
  isolated from each other to varying degrees.</p>

  <p class="example">For example, if Example Bank's web site, hosted at <code>bank.example.com</code>, tries to examine the DOM of Example Charity's web site, hosted
  at <code>charity.example.org</code>, a <a id="origin:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
  <code id="origin:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> will be raised.</p>

  <hr>

  <p id="origin-2">An <dfn id="concept-origin" data-export="">origin</dfn> is one of the following:</p>

  <dl><dt>An <dfn id="concept-origin-opaque" data-export="">opaque origin</dfn></dt><dd><p>An internal value, with no serialization it can be recreated from (it is serialized as
   "<code>null</code>" per <a href="#ascii-serialisation-of-an-origin" id="origin:ascii-serialisation-of-an-origin">serialization of an origin</a>), for which the only
   meaningful operation is testing for equality.</p></dd><dt>A <dfn id="concept-origin-tuple" data-export="">tuple origin</dfn></dt><dd>
    <p>A <a id="origin:tuple" href="https://infra.spec.whatwg.org/#tuple" data-x-internal="tuple">tuple</a> consisting of:

    </p><ul class="brief"><li>A <dfn data-dfn-for="origin" id="concept-origin-scheme" data-export="">scheme</dfn> (an <a id="origin:ascii-string" href="https://infra.spec.whatwg.org/#ascii-string" data-x-internal="ascii-string">ASCII
     string</a>).</li><li>A <dfn data-dfn-for="origin" id="concept-origin-host" data-export="">host</dfn> (a <a href="https://url.spec.whatwg.org/#concept-host" id="origin:concept-host" data-x-internal="concept-host">host</a>).</li><li>A <dfn data-dfn-for="origin" id="concept-origin-port" data-export="">port</dfn> (null or a 16-bit
     unsigned integer).</li><li>A <dfn data-dfn-for="origin" id="concept-origin-domain" data-export="">domain</dfn> (null or a <a href="https://url.spec.whatwg.org/#concept-domain" id="origin:concept-domain" data-x-internal="concept-domain">domain</a>). Null unless stated otherwise.</li></ul>
   </dd></dl>

  <p class="note"><a href="#concept-origin" id="origin:concept-origin">Origins</a> can be shared, e.g., among multiple
  <code id="origin:document"><a href="#document">Document</a></code> objects. Furthermore, <a href="#concept-origin" id="origin:concept-origin-2">origins</a> are generally
  immutable. Only the <a href="#concept-origin-domain" id="origin:concept-origin-domain">domain</a> of a <a href="#concept-origin-tuple" id="origin:concept-origin-tuple">tuple origin</a> can be changed, and only through the <code id="origin:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code> API.</p>

  

  <div data-algorithm="">
  <p>The <dfn id="concept-origin-effective-domain" data-export="">effective domain</dfn> of an
  <a href="#concept-origin" id="origin:concept-origin-3">origin</a> <var>origin</var> is computed as follows:</p>

  <ol><li><p>If <var>origin</var> is an <a href="#concept-origin-opaque" id="origin:concept-origin-opaque">opaque origin</a>,
   then return null.</p></li><li><p>If <var>origin</var>'s <a href="#concept-origin-domain" id="origin:concept-origin-domain-2">domain</a> is non-null,
   then return <var>origin</var>'s <a href="#concept-origin-domain" id="origin:concept-origin-domain-3">domain</a>.</p></li><li><p>Return <var>origin</var>'s <a href="#concept-origin-host" id="origin:concept-origin-host">host</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="ascii-serialisation-of-an-origin" data-lt="serialization of an
  origin|ASCII serialization of an origin" data-export="">serialization of an origin</dfn> is the string obtained
  by applying the following algorithm to the given <a href="#concept-origin" id="origin:concept-origin-4">origin</a> <var>origin</var>:</p>

  <ol><li><p>If <var>origin</var> is an <a href="#concept-origin-opaque" id="origin:concept-origin-opaque-2">opaque origin</a>,
   then return "<code>null</code>".</p></li><li><p>Otherwise, let <var>result</var> be <var>origin</var>'s <a href="#concept-origin-scheme" id="origin:concept-origin-scheme">scheme</a>.</p></li><li><p>Append "<code>://</code>" to <var>result</var>.</p></li><li><p>Append <var>origin</var>'s <a href="#concept-origin-host" id="origin:concept-origin-host-2">host</a>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="origin:host-serializer" data-x-internal="host-serializer">serialized</a>, to <var>result</var>.</p></li><li><p>If <var>origin</var>'s <a href="#concept-origin-port" id="origin:concept-origin-port">port</a> is non-null, append
   a U+003A COLON character (:), and <var>origin</var>'s <a href="#concept-origin-port" id="origin:concept-origin-port-2">port</a>, <a href="https://url.spec.whatwg.org/#serialize-an-integer" id="origin:serialize-an-integer" data-x-internal="serialize-an-integer">serialized</a>,
   to <var>result</var>.</p></li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  

  <p class="example">The <a href="#ascii-serialisation-of-an-origin" id="origin:ascii-serialisation-of-an-origin-2">serialization</a> of ("<code>https</code>", "<code>xn--maraa-rta.example</code>", null, null) is "<code>https://xn--maraa-rta.example</code>".</p>

  

  <p id="unicode-serialisation-of-an-origin" class="note"><a href="#unicode-serialisation-of-an-origin" class="self-link"></a>There used to also be a
  <i>Unicode serialization of an origin</i>. However, it was never widely adopted.</p>

  <hr>

  <div data-algorithm="">
  <p>Two <a href="#concept-origin" id="origin:concept-origin-5">origins</a>, <var>A</var> and <var>B</var>, are said to be <dfn id="same-origin" data-export="">same origin</dfn> if the following algorithm returns true:</p>

  <ol><li><p>If <var>A</var> and <var>B</var> are the same <a href="#concept-origin-opaque" id="origin:concept-origin-opaque-3">opaque
   origin</a>, then return true.</p></li><li><p>If <var>A</var> and <var>B</var> are both <a href="#concept-origin-tuple" id="origin:concept-origin-tuple-2">tuple
   origins</a> and their <a href="#concept-origin-scheme" id="origin:concept-origin-scheme-2">schemes</a>, <a href="#concept-origin-host" id="origin:concept-origin-host-3">hosts</a>, and <a href="#concept-origin-port" id="origin:concept-origin-port-3">port</a>
   are identical, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Two <a href="#concept-origin" id="origin:concept-origin-6">origins</a>, <var>A</var> and <var>B</var>, are said to be <dfn id="same-origin-domain" data-export="">same origin-domain</dfn> if the following algorithm returns true:</p>

  <ol><li><p>If <var>A</var> and <var>B</var> are the same <a href="#concept-origin-opaque" id="origin:concept-origin-opaque-4">opaque
   origin</a>, then return true.</p></li><li>
    <p>If <var>A</var> and <var>B</var> are both <a href="#concept-origin-tuple" id="origin:concept-origin-tuple-3">tuple
    origins</a>:</p>

    <ol><li><p>If <var>A</var> and <var>B</var>'s <a href="#concept-origin-scheme" id="origin:concept-origin-scheme-3">schemes</a>
     are identical, and their <a href="#concept-origin-domain" id="origin:concept-origin-domain-4">domains</a> are identical and
     non-null, then return true.</p></li><li><p>Otherwise, if <var>A</var> and <var>B</var> are <a href="#same-origin" id="origin:same-origin">same origin</a> and their
     <a href="#concept-origin-domain" id="origin:concept-origin-domain-5">domains</a> are both null, return true.</p></li></ol>

   </li><li><p>Return false.</p></li></ol>
  </div>

  

  <div class="example">
   

   <table><tbody><tr><th><var>A</var>
     </th><th><var>B</var>
     </th><th><a href="#same-origin" id="origin:same-origin-2">same origin</a>
     </th><th><a href="#same-origin-domain" id="origin:same-origin-domain">same origin-domain</a>
    </th></tr><tr><td>("<code>https</code>", "<code>example.org</code>", null, null)
     </td><td>("<code>https</code>", "<code>example.org</code>", null, null)
     </td><td>✅
     </td><td>✅
    </td></tr><tr><td>("<code>https</code>", "<code>example.org</code>", 314, null)
     </td><td>("<code>https</code>", "<code>example.org</code>", 420, null)
     </td><td>❌
     </td><td>❌
    </td></tr><tr><td>("<code>https</code>", "<code>example.org</code>", 314, "<code>example.org</code>")
     </td><td>("<code>https</code>", "<code>example.org</code>", 420, "<code>example.org</code>")
     </td><td>❌
     </td><td>✅
    </td></tr><tr><td>("<code>https</code>", "<code>example.org</code>", null, null)
     </td><td>("<code>https</code>", "<code>example.org</code>", null, "<code>example.org</code>")
     </td><td>✅
     </td><td>❌
    </td></tr><tr><td>("<code>https</code>", "<code>example.org</code>", null, "<code>example.org</code>")
     </td><td>("<code>http</code>", "<code>example.org</code>", null, "<code>example.org</code>")
     </td><td>❌
     </td><td>❌
   </td></tr></tbody></table>
  </div>


  <h5 id="sites"><span class="secno">7.1.1.1</span> Sites<a href="#sites" class="self-link"></a></h5>

  <p>A <dfn id="scheme-and-host">scheme-and-host</dfn> is a <a id="sites:tuple" href="https://infra.spec.whatwg.org/#tuple" data-x-internal="tuple">tuple</a> of a <dfn id="concept-scheme-and-host-scheme">scheme</dfn> (an <a id="sites:ascii-string" href="https://infra.spec.whatwg.org/#ascii-string" data-x-internal="ascii-string">ASCII string</a>) and a <dfn id="concept-scheme-and-host-host">host</dfn> (a <a href="https://url.spec.whatwg.org/#concept-host" id="sites:concept-host" data-x-internal="concept-host">host</a>).</p>

  <p>A <dfn id="site" data-export="">site</dfn> is an <a href="#concept-origin-opaque" id="sites:concept-origin-opaque">opaque origin</a> or a
  <a href="#scheme-and-host" id="sites:scheme-and-host">scheme-and-host</a>.</p>

  

  <div data-algorithm="">
  <p>To <dfn id="obtain-a-site" data-export="">obtain a site</dfn>, given an origin <var>origin</var>, run these steps:</p>

  <ol><li><p>If <var>origin</var> is an <a href="#concept-origin-opaque" id="sites:concept-origin-opaque-2">opaque origin</a>,
   then return <var>origin</var>.</p></li><li><p>If <var>origin</var>'s <a href="#concept-origin-host" id="sites:concept-origin-host">host</a>'s <a id="sites:registrable-domain" href="https://url.spec.whatwg.org/#host-registrable-domain" data-x-internal="registrable-domain">registrable
   domain</a> is null, then return (<var>origin</var>'s <a href="#concept-origin-scheme" id="sites:concept-origin-scheme">scheme</a>, <var>origin</var>'s <a href="#concept-origin-host" id="sites:concept-origin-host-2">host</a>).</p></li><li><p>Return (<var>origin</var>'s <a href="#concept-origin-scheme" id="sites:concept-origin-scheme-2">scheme</a>,
   <var>origin</var>'s <a href="#concept-origin-host" id="sites:concept-origin-host-3">host</a>'s <a id="sites:registrable-domain-2" href="https://url.spec.whatwg.org/#host-registrable-domain" data-x-internal="registrable-domain">registrable
   domain</a>).</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Two <a href="#site" id="sites:site">sites</a>, <var>A</var> and <var>B</var>, are said to be <dfn data-dfn-for="site" id="concept-site-same-site" data-export="">same site</dfn> if the following algorithm
  returns true:</p>

  <ol><li><p>If <var>A</var> and <var>B</var> are the same <a href="#concept-origin-opaque" id="sites:concept-origin-opaque-3">opaque
   origin</a>, then return true.</p></li><li><p>If <var>A</var> or <var>B</var> is an <a href="#concept-origin-opaque" id="sites:concept-origin-opaque-4">opaque
   origin</a>, then return false.</p></li><li><p>If <var>A</var>'s and <var>B</var>'s <a href="#concept-scheme-and-host-scheme" id="sites:concept-scheme-and-host-scheme">scheme</a> values are different, then return
   false.</p></li><li><p>If <var>A</var>'s and <var>B</var>'s <a href="#concept-scheme-and-host-host" id="sites:concept-scheme-and-host-host">host</a> values are not <a href="https://url.spec.whatwg.org/#concept-host-equals" id="sites:host-equals" data-x-internal="host-equals">equal</a>, then return false.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="serialization-of-a-site" data-export="">serialization of a site</dfn> is the string obtained by applying the following
  algorithm to the given <a href="#site" id="sites:site-2">site</a> <var>site</var>:</p>

  <ol><li><p>If <var>site</var> is an <a href="#concept-origin-opaque" id="sites:concept-origin-opaque-5">opaque origin</a>, then
   return "<code>null</code>".</p></li><li><p>Let <var>result</var> be <var>site</var>[0].</p></li><li><p>Append "<code>://</code>" to <var>result</var>.</p></li><li><p>Append <var>site</var>[1], <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="sites:host-serializer" data-x-internal="host-serializer">serialized</a>, to
   <var>result</var>.</p></li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <p class="warning">It needs to be clear from context that the serialized value is a site, not an
  origin, as there is not necessarily a syntactic difference between the two. For example, the
  origin ("<code>https</code>", "<code>shop.example</code>", null, null) and
  the site ("<code>https</code>", "<code>shop.example</code>") have the same
  serialization: "<code>https://shop.example</code>".</p>

  <div data-algorithm="">
  <p>Two <a href="#concept-origin" id="sites:concept-origin">origins</a>, <var>A</var> and <var>B</var>, are said to be <dfn id="schemelessly-same-site" data-export="">schemelessly same site</dfn> if the following algorithm returns true:</p>

  <ol><li><p>If <var>A</var> and <var>B</var> are the same <a href="#concept-origin-opaque" id="sites:concept-origin-opaque-6">opaque
   origin</a>, then return true.</p></li><li>
    <p>If <var>A</var> and <var>B</var> are both <a href="#concept-origin-tuple" id="sites:concept-origin-tuple">tuple
    origins</a>, then:</p>

    <ol><li><p>Let <var>hostA</var> be <var>A</var>'s <a href="#concept-origin-host" id="sites:concept-origin-host-4">host</a>,
     and let <var>hostB</var> be <var>B</var>'s <a href="#concept-origin-host" id="sites:concept-origin-host-5">host</a>.</p></li><li><p>If <var>hostA</var> <a href="https://url.spec.whatwg.org/#concept-host-equals" id="sites:host-equals-2" data-x-internal="host-equals">equals</a> <var>hostB</var> and
     <var>hostA</var>'s <a id="sites:registrable-domain-3" href="https://url.spec.whatwg.org/#host-registrable-domain" data-x-internal="registrable-domain">registrable domain</a> is null, then return true.</p></li><li><p>If <var>hostA</var>'s <a id="sites:registrable-domain-4" href="https://url.spec.whatwg.org/#host-registrable-domain" data-x-internal="registrable-domain">registrable domain</a> <a href="https://url.spec.whatwg.org/#concept-host-equals" id="sites:host-equals-3" data-x-internal="host-equals">equals</a> <var>hostB</var>'s <a id="sites:registrable-domain-5" href="https://url.spec.whatwg.org/#host-registrable-domain" data-x-internal="registrable-domain">registrable domain</a> and is non-null, then
     return true.</p></li></ol>
   </li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Two <a href="#concept-origin" id="sites:concept-origin-2">origins</a>, <var>A</var> and <var>B</var>, are said to be <dfn id="same-site" data-export="">same site</dfn> if the following algorithm returns true:</p>

  <ol><li><p>Let <var>siteA</var> be the result of <a href="#obtain-a-site" id="sites:obtain-a-site">obtaining a
   site</a> given <var>A</var>.</p></li><li><p>Let <var>siteB</var> be the result of <a href="#obtain-a-site" id="sites:obtain-a-site-2">obtaining a
   site</a> given <var>B</var>.</p></li><li><p>If <var>siteA</var> is <a href="#concept-site-same-site" id="sites:concept-site-same-site">same site</a> with
   <var>siteB</var>, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  

  <p class="note">Unlike the <a href="#same-origin" id="sites:same-origin">same origin</a> and <a href="#same-origin-domain" id="sites:same-origin-domain">same origin-domain</a> concepts,
  for <a href="#schemelessly-same-site" id="sites:schemelessly-same-site">schemelessly same site</a> and <a href="#same-site" id="sites:same-site">same site</a>, the <a href="#concept-origin-port" id="sites:concept-origin-port">port</a> and <a href="#concept-origin-domain" id="sites:concept-origin-domain">domain</a>
  components are ignored.</p>

  <p class="warning">For the reasons <a href="https://url.spec.whatwg.org/#warning-avoid-psl">explained in <cite>URL</cite></a>, the
  <a href="#same-site" id="sites:same-site-2">same site</a> and <a href="#schemelessly-same-site" id="sites:schemelessly-same-site-2">schemelessly same site</a> concepts should be avoided when
  possible, in favor of <a href="#same-origin" id="sites:same-origin-2">same origin</a> checks.</p>

  <div id="example-same-site" class="example"><a href="#example-same-site" class="self-link"></a>
   

  <p>Given that <code>wildlife.museum</code>, <code>museum</code>, and <code>com</code> are <a href="https://url.spec.whatwg.org/#host-public-suffix" id="sites:public-suffix" data-x-internal="public-suffix">public suffixes</a> and that <code>example.com</code> is not:</p>

   <table><tbody><tr><th><var>A</var>
     </th><th><var>B</var>
     </th><th><a href="#schemelessly-same-site" id="sites:schemelessly-same-site-3">schemelessly same site</a>
     </th><th><a href="#same-site" id="sites:same-site-3">same site</a>
    </th></tr><tr><td>("<code>https</code>", "<code>example.com</code>")
     </td><td>("<code>https</code>", "<code>sub.example.com</code>")
     </td><td>✅
     </td><td>✅
    </td></tr><tr><td>("<code>https</code>", "<code>example.com</code>")
     </td><td>("<code>https</code>", "<code>sub.other.example.com</code>")
     </td><td>✅
     </td><td>✅
    </td></tr><tr><td>("<code>https</code>", "<code>example.com</code>")
     </td><td>("<code>http</code>", "<code>non-secure.example.com</code>")
     </td><td>✅
     </td><td>❌
    </td></tr><tr><td>("<code>https</code>", "<code>r.wildlife.museum</code>")
     </td><td>("<code>https</code>", "<code>sub.r.wildlife.museum</code>")
     </td><td>✅
     </td><td>✅
    </td></tr><tr><td>("<code>https</code>", "<code>r.wildlife.museum</code>")
     </td><td>("<code>https</code>", "<code>sub.other.r.wildlife.museum</code>")
     </td><td>✅
     </td><td>✅
    </td></tr><tr><td>("<code>https</code>", "<code>r.wildlife.museum</code>")
     </td><td>("<code>https</code>", "<code>other.wildlife.museum</code>")
     </td><td>❌
     </td><td>❌
    </td></tr><tr><td>("<code>https</code>", "<code>r.wildlife.museum</code>")
     </td><td>("<code>https</code>", "<code>wildlife.museum</code>")
     </td><td>❌
     </td><td>❌
    </td></tr><tr><td>("<code>https</code>", "<code>wildlife.museum</code>")
     </td><td>("<code>https</code>", "<code>wildlife.museum</code>")
     </td><td>✅
     </td><td>✅
    </td></tr><tr><td>("<code>https</code>", "<code>example.com</code>")
     </td><td>("<code>https</code>", "<code>example.com.</code>")
     </td><td>❌
     </td><td>❌
   </td></tr></tbody></table>

   <p>(Here we have omitted the <a href="#concept-origin-port" id="sites:concept-origin-port-2">port</a> and <a href="#concept-origin-domain" id="sites:concept-origin-domain-2">domain</a> components since they are not considered.)</p>
  </div>


  <h5 id="relaxing-the-same-origin-restriction"><span class="secno">7.1.1.2</span> Relaxing the same-origin restriction<a href="#relaxing-the-same-origin-restriction" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-domain" id="dom-document-domain-dev">domain</a> [ = <var>domain</var> ]</code></dt><dd>
    <p>Returns the current domain used for security checks.</p>

    <p>Can be set to a value that removes subdomains, to change the <a href="#concept-origin" id="relaxing-the-same-origin-restriction:concept-origin">origin</a>'s <a href="#concept-origin-domain" id="relaxing-the-same-origin-restriction:concept-origin-domain">domain</a> to allow pages on other subdomains of the same
    domain (if they do the same thing) to access each other. This enables pages on different hosts
    of a domain to synchronously access each other's DOMs.</p>

    <p>In sandboxed <code id="relaxing-the-same-origin-restriction:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s, <code id="relaxing-the-same-origin-restriction:document"><a href="#document">Document</a></code>s with <a href="#concept-origin-opaque" id="relaxing-the-same-origin-restriction:concept-origin-opaque">opaque origins</a>, and <code id="relaxing-the-same-origin-restriction:document-2"><a href="#document">Document</a></code>s without a <a href="#concept-document-bc" id="relaxing-the-same-origin-restriction:concept-document-bc">browsing context</a>, the setter will
    throw a <a id="relaxing-the-same-origin-restriction:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> exception. In cases where <code id="relaxing-the-same-origin-restriction:dom-crossoriginisolated"><a href="#dom-crossoriginisolated">crossOriginIsolated</a></code> or <code id="relaxing-the-same-origin-restriction:dom-originagentcluster"><a href="#dom-originagentcluster">originAgentCluster</a></code> return true, the setter will do
    nothing.</p>
   </dd></dl>

  <div class="critical">
   <p>Avoid using the <code id="relaxing-the-same-origin-restriction:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code> setter. It
   undermines the security protections provided by the same-origin policy. This is especially acute
   when using shared hosting; for example, if an untrusted third party is able to host an HTTP
   server at the same IP address but on a different port, then the same-origin protection that
   normally protects two different sites on the same host will fail, as the ports are ignored when
   comparing origins after the <code id="relaxing-the-same-origin-restriction:dom-document-domain-2"><a href="#dom-document-domain">document.domain</a></code> setter has
   been used.</p>

   <p>Because of these security pitfalls, this feature is in the process of being removed from the
   web platform. (This is a long process that takes many years.)</p>

   <p>Instead, use <code id="relaxing-the-same-origin-restriction:dom-window-postmessage"><a href="#dom-window-postmessage">postMessage()</a></code> or
   <code id="relaxing-the-same-origin-restriction:messagechannel"><a href="#messagechannel">MessageChannel</a></code> objects to communicate across origins in a safe manner.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-domain" data-dfn-type="attribute"><code>domain</code></dfn>
  getter steps are:</p>

  <ol><li><p>Let <var>effectiveDomain</var> be <a id="relaxing-the-same-origin-restriction:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="relaxing-the-same-origin-restriction:concept-document-origin" data-x-internal="concept-document-origin">origin</a>'s <a href="#concept-origin-effective-domain" id="relaxing-the-same-origin-restriction:concept-origin-effective-domain">effective domain</a>.

   </p></li><li><p>If <var>effectiveDomain</var> is null, then return the empty string.</p></li><li><p>Return <var>effectiveDomain</var>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="relaxing-the-same-origin-restriction:host-serializer" data-x-internal="host-serializer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="relaxing-the-same-origin-restriction:dom-document-domain-3"><a href="#dom-document-domain">domain</a></code> setter steps are:</p>

  <ol><li><p>If <a id="relaxing-the-same-origin-restriction:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-bc" id="relaxing-the-same-origin-restriction:concept-document-bc-2">browsing context</a> is
   null, then throw a <a id="relaxing-the-same-origin-restriction:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="relaxing-the-same-origin-restriction:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="relaxing-the-same-origin-restriction:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#active-sandboxing-flag-set" id="relaxing-the-same-origin-restriction:active-sandboxing-flag-set">active sandboxing flag set</a> has its <a href="#sandboxed-document.domain-browsing-context-flag" id="relaxing-the-same-origin-restriction:sandboxed-document.domain-browsing-context-flag">sandboxed
   <code>document.domain</code> browsing context flag</a> set, then
   throw a <a id="relaxing-the-same-origin-restriction:securityerror-3" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="relaxing-the-same-origin-restriction:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>effectiveDomain</var> be <a id="relaxing-the-same-origin-restriction:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="relaxing-the-same-origin-restriction:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>'s <a href="#concept-origin-effective-domain" id="relaxing-the-same-origin-restriction:concept-origin-effective-domain-2">effective domain</a>.

   </p></li><li><p>If <var>effectiveDomain</var> is null, then throw a
   <a id="relaxing-the-same-origin-restriction:securityerror-4" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="relaxing-the-same-origin-restriction:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the given value <a href="#is-a-registrable-domain-suffix-of-or-is-equal-to" id="relaxing-the-same-origin-restriction:is-a-registrable-domain-suffix-of-or-is-equal-to">is not
   a registrable domain suffix of and is not equal to</a> <var>effectiveDomain</var>, then throw
   a <a id="relaxing-the-same-origin-restriction:securityerror-5" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="relaxing-the-same-origin-restriction:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the <a id="relaxing-the-same-origin-restriction:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s <a id="relaxing-the-same-origin-restriction:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>'s <a href="#is-origin-keyed" id="relaxing-the-same-origin-restriction:is-origin-keyed">is
   origin-keyed</a> is true, then return.</p></li><li><p>Set <a id="relaxing-the-same-origin-restriction:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="relaxing-the-same-origin-restriction:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a>'s <a href="#concept-origin-domain" id="relaxing-the-same-origin-restriction:concept-origin-domain-2">domain</a> to the result of <a href="https://url.spec.whatwg.org/#concept-host-parser" id="relaxing-the-same-origin-restriction:host-parser" data-x-internal="host-parser">parsing</a> the given value.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To determine if a <a id="relaxing-the-same-origin-restriction:scalar-value-string" href="https://infra.spec.whatwg.org/#scalar-value-string" data-x-internal="scalar-value-string">scalar value string</a> <var>hostSuffixString</var> <dfn id="is-a-registrable-domain-suffix-of-or-is-equal-to" data-lt="is a registrable domain suffix of or is equal to|is not a registrable domain suffix of
  and is not equal to" data-export="">is a registrable domain suffix of or is equal to</dfn> a <a href="https://url.spec.whatwg.org/#concept-host" id="relaxing-the-same-origin-restriction:concept-host" data-x-internal="concept-host">host</a> <var>originalHost</var>:</p>
  

  <ol><li><p>If <var>hostSuffixString</var> is the empty string, then return false.</p></li><li><p>Let <var>hostSuffix</var> be the result of <a href="https://url.spec.whatwg.org/#concept-host-parser" id="relaxing-the-same-origin-restriction:host-parser-2" data-x-internal="host-parser">parsing</a>
   <var>hostSuffixString</var>.</p></li><li><p>If <var>hostSuffix</var> is failure, then return false.</p></li><li>
    <p>If <var>hostSuffix</var> does not <a href="https://url.spec.whatwg.org/#concept-host-equals" id="relaxing-the-same-origin-restriction:host-equals" data-x-internal="host-equals">equal</a>
    <var>originalHost</var>, then:</p>

    <ol><li>
      <p>If <var>hostSuffix</var> or <var>originalHost</var> is not a <a href="https://url.spec.whatwg.org/#concept-domain" id="relaxing-the-same-origin-restriction:concept-domain" data-x-internal="concept-domain">domain</a>, then return false.</p>

      <p class="note">This excludes <a href="https://url.spec.whatwg.org/#concept-host" id="relaxing-the-same-origin-restriction:concept-host-2" data-x-internal="concept-host">hosts</a> that are <a href="https://url.spec.whatwg.org/#ip-address" id="relaxing-the-same-origin-restriction:ip-address" data-x-internal="ip-address">IP addresses</a>.</p>
     </li><li><p>If <var>hostSuffix</var>, prefixed by U+002E (.), does not match the end of
     <var>originalHost</var>, then return false.</p></li><li>
      <p>If any of the following are true:</p>

      <ul><li><p><var>hostSuffix</var> <a href="https://url.spec.whatwg.org/#concept-host-equals" id="relaxing-the-same-origin-restriction:host-equals-2" data-x-internal="host-equals">equals</a>
       <var>hostSuffix</var>'s <a id="relaxing-the-same-origin-restriction:public-suffix" href="https://url.spec.whatwg.org/#host-public-suffix" data-x-internal="public-suffix">public suffix</a>; or</p></li><li><p><var>hostSuffix</var>, prefixed by U+002E (.), matches the end of
       <var>originalHost</var>'s <a id="relaxing-the-same-origin-restriction:public-suffix-2" href="https://url.spec.whatwg.org/#host-public-suffix" data-x-internal="public-suffix">public suffix</a>,</p></li></ul>

      <p>then return false. <a href="#refsURL">[URL]</a></p>
     </li><li><p><a id="relaxing-the-same-origin-restriction:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>originalHost</var>'s <a id="relaxing-the-same-origin-restriction:public-suffix-3" href="https://url.spec.whatwg.org/#host-public-suffix" data-x-internal="public-suffix">public suffix</a>, prefixed by
     U+002E (.), matches the end of <var>hostSuffix</var>.</p></li></ol>
   </li><li><p>Return true.</p></li></ol>
  </div>

  <div id="example-registrable-domain-suffix" class="example"><a href="#example-registrable-domain-suffix" class="self-link"></a>
   <table><tbody><tr><th><var>hostSuffixString</var></th><th><var>originalHost</var></th><th>Outcome of <a href="#is-a-registrable-domain-suffix-of-or-is-equal-to" id="relaxing-the-same-origin-restriction:is-a-registrable-domain-suffix-of-or-is-equal-to-2">is a registrable domain suffix of or is equal to</a></th><th>Notes</th></tr><tr><td>"<code>0.0.0.0</code>"</td><td><code>0.0.0.0</code></td><td>✅</td><td></td></tr><tr><td>"<code>0x10203</code>"</td><td><code>0.1.2.3</code></td><td>✅</td><td></td></tr><tr><td>"<code>[0::1]</code>"</td><td><code>::1</code></td><td>✅</td><td></td></tr><tr><td>"<code>example.com</code>"</td><td><code>example.com</code></td><td>✅</td><td></td></tr><tr><td>"<code>example.com</code>"</td><td><code>example.com.</code></td><td>❌</td><td rowspan="2">Trailing dot is significant.</td></tr><tr><td>"<code>example.com.</code>"</td><td><code>example.com</code></td><td>❌</td></tr><tr><td>"<code>example.com</code>"</td><td><code>www.example.com</code></td><td>✅</td><td></td></tr><tr><td>"<code>com</code>"</td><td><code>example.com</code></td><td>❌</td><td>At the time of writing, <code>com</code> is a public suffix.</td></tr><tr><td>"<code>example</code>"</td><td><code>example</code></td><td>✅</td><td></td></tr><tr><td>"<code>compute.amazonaws.com</code>"</td><td><code>example.compute.amazonaws.com</code></td><td>❌</td><td rowspan="3">At the time of writing, <code><var>*</var>.compute.amazonaws.com</code> is a public suffix.</td></tr><tr><td>"<code>example.compute.amazonaws.com</code>"</td><td><code>www.example.compute.amazonaws.com</code></td><td>❌</td></tr><tr><td>"<code>amazonaws.com</code>"</td><td><code>www.example.compute.amazonaws.com</code></td><td>❌</td></tr><tr><td>"<code>amazonaws.com</code>"</td><td><code>test.amazonaws.com</code></td><td>✅</td><td>At the time of writing, <code>amazonaws.com</code> is a registrable domain.</td></tr></tbody></table>
  </div>

  


  <h4 id="origin-keyed-agent-clusters"><span class="secno">7.1.2</span> <span id="origin-isolation"></span>Origin-keyed agent clusters<a href="#origin-keyed-agent-clusters" class="self-link"></a></h4>

  <dl class="domintro"><dt><code>window.<a href="#dom-originagentcluster" id="dom-originagentcluster-dev">originAgentCluster</a></code></dt><dd>
    <p>Returns true if this <code id="origin-keyed-agent-clusters:window"><a href="#window">Window</a></code> belongs to an <a id="origin-keyed-agent-clusters:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a> which is
    <a href="#concept-origin" id="origin-keyed-agent-clusters:concept-origin">origin</a>-<a href="#agent-cluster-key" id="origin-keyed-agent-clusters:agent-cluster-key">keyed</a>, in the manner described in
    this section.</p>
   </dd></dl>

  <p>A <code id="origin-keyed-agent-clusters:document"><a href="#document">Document</a></code> delivered over a <a href="#secure-context" id="origin-keyed-agent-clusters:secure-context">secure context</a> can request that it be
  placed in an <a href="#concept-origin" id="origin-keyed-agent-clusters:concept-origin-2">origin</a>-<a href="#agent-cluster-key" id="origin-keyed-agent-clusters:agent-cluster-key-2">keyed</a> <a id="origin-keyed-agent-clusters:agent-cluster-2" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent
  cluster</a>, by using the `<dfn id="origin-agent-cluster" data-dfn-type="http-header"><code>Origin-Agent-Cluster</code></dfn>` HTTP
  response header. This header is a <a href="https://httpwg.org/specs/rfc8941.html" id="origin-keyed-agent-clusters:http-structured-header" data-x-internal="http-structured-header">structured header</a>
  whose value must be a <a href="https://httpwg.org/specs/rfc8941.html#boolean" id="origin-keyed-agent-clusters:http-structured-header-boolean" data-x-internal="http-structured-header-boolean">boolean</a>.
  <a href="#refsSTRUCTURED-FIELDS">[STRUCTURED-FIELDS]</a></p>

  <p>Per the processing model in the <a href="#initialise-the-document-object" id="origin-keyed-agent-clusters:initialise-the-document-object">create
  and initialize a new <code>Document</code> object</a>, values
  that are not the <a href="https://httpwg.org/specs/rfc8941.html#boolean" id="origin-keyed-agent-clusters:http-structured-header-boolean-2" data-x-internal="http-structured-header-boolean">structured header boolean</a>
  true value (i.e., `<code>?1</code>`) will be ignored.</p>

  <p>The consequences of using this header are that the resulting
  <code id="origin-keyed-agent-clusters:document-2"><a href="#document">Document</a></code>'s <a href="#agent-cluster-key" id="origin-keyed-agent-clusters:agent-cluster-key-3">agent cluster key</a> is its <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="origin-keyed-agent-clusters:concept-document-origin" data-x-internal="concept-document-origin">origin</a>, instead of the <a href="#obtain-a-site" id="origin-keyed-agent-clusters:obtain-a-site">corresponding site</a>. In terms of observable effects, this means that
  attempting to <a href="#relaxing-the-same-origin-restriction">relax the same-origin
  restriction</a> using <code id="origin-keyed-agent-clusters:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code> will instead do
  nothing, and it will not be possible to send <code id="origin-keyed-agent-clusters:webassembly.module"><a data-x-internal="webassembly.module" href="https://webassembly.github.io/spec/js-api/#module">WebAssembly.Module</a></code> objects to
  cross-origin <code id="origin-keyed-agent-clusters:document-3"><a href="#document">Document</a></code>s (even if they are <a href="#same-site" id="origin-keyed-agent-clusters:same-site">same site</a>). Behind the scenes,
  this isolation can allow user agents to allocate implementation-specific resources corresponding
  to <a href="https://tc39.es/ecma262/#sec-agent-clusters" id="origin-keyed-agent-clusters:agent-cluster-3" data-x-internal="agent-cluster">agent clusters</a>, such as processes or threads, more
  efficiently.</p>

  <p>Note that within a <a href="#browsing-context-group" id="origin-keyed-agent-clusters:browsing-context-group">browsing context group</a>, the
  `<code id="origin-keyed-agent-clusters:origin-agent-cluster"><a href="#origin-agent-cluster">Origin-Agent-Cluster</a></code>` header can never cause same-origin <code id="origin-keyed-agent-clusters:document-4"><a href="#document">Document</a></code>
  objects to end up in different <a href="https://tc39.es/ecma262/#sec-agent-clusters" id="origin-keyed-agent-clusters:agent-cluster-4" data-x-internal="agent-cluster">agent clusters</a>, even if one
  sends the header and the other doesn't. This is prevented by means of the
  <a href="#historical-agent-cluster-key-map" id="origin-keyed-agent-clusters:historical-agent-cluster-key-map">historical agent cluster key map</a>.</p>

  <p class="note">This means that the <code id="origin-keyed-agent-clusters:dom-originagentcluster"><a href="#dom-originagentcluster">originAgentCluster</a></code> getter can return false, even if the
  header is set, if the header was omitted on a previously-loaded same-origin page in the same
  <a href="#browsing-context-group" id="origin-keyed-agent-clusters:browsing-context-group-2">browsing context group</a>. Similarly, it can return true even when the header is not
  set.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-originagentcluster" data-dfn-type="attribute"><code>originAgentCluster</code></dfn> getter steps are to return the
  <a id="origin-keyed-agent-clusters:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s <a id="origin-keyed-agent-clusters:agent-cluster-5" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>'s <a href="#is-origin-keyed" id="origin-keyed-agent-clusters:is-origin-keyed">is origin-keyed</a>.</p>
  </div>

  <p class="note"><code id="origin-keyed-agent-clusters:document-5"><a href="#document">Document</a></code>s with an <a href="#concept-origin-opaque" id="origin-keyed-agent-clusters:concept-origin-opaque">opaque
  origin</a> can be considered unconditionally origin-keyed; for them the header has no effect,
  and the <code id="origin-keyed-agent-clusters:dom-originagentcluster-2"><a href="#dom-originagentcluster">originAgentCluster</a></code> getter will always return
  true.</p>

  <p class="note">Similarly, <code id="origin-keyed-agent-clusters:document-6"><a href="#document">Document</a></code>s whose <a id="origin-keyed-agent-clusters:agent-cluster-6" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>'s <a href="#agent-cluster-cross-origin-isolation" id="origin-keyed-agent-clusters:agent-cluster-cross-origin-isolation">cross-origin isolation mode</a> is not "<code id="origin-keyed-agent-clusters:cross-origin-isolation-none"><a href="#cross-origin-isolation-none">none</a></code>" are automatically origin-keyed. The
  `<code id="origin-keyed-agent-clusters:origin-agent-cluster-2"><a href="#origin-agent-cluster">Origin-Agent-Cluster</a></code>` header might be useful as an additional hint to
  implementations about resource allocation, since the `<code id="origin-keyed-agent-clusters:cross-origin-opener-policy-2"><a href="#cross-origin-opener-policy-2">Cross-Origin-Opener-Policy</a></code>`
  and `<code id="origin-keyed-agent-clusters:cross-origin-embedder-policy"><a href="#cross-origin-embedder-policy">Cross-Origin-Embedder-Policy</a></code>` headers used to achieve cross-origin isolation
  are more about ensuring that everything in the same address space opts in to being there. But
  adding it would have no additional observable effects on author code.</p>


  <h4 id="cross-origin-opener-policies"><span class="secno">7.1.3</span> Cross-origin opener policies<a href="#cross-origin-opener-policies" class="self-link"></a></h4>

  <p>An <dfn id="cross-origin-opener-policy-value">opener policy value</dfn> allows a document which
  is navigated to in a <a href="#top-level-browsing-context" id="cross-origin-opener-policies:top-level-browsing-context">top-level browsing context</a> to force the creation of a new
  <a href="#top-level-browsing-context" id="cross-origin-opener-policies:top-level-browsing-context-2">top-level browsing context</a>, and a corresponding <a href="#tlbc-group" id="cross-origin-opener-policies:tlbc-group">group</a>. The possible values are:</p>

  <dl><dt>"<dfn id="coop-unsafe-none"><code>unsafe-none</code></dfn>"</dt><dd><p>This is the (current) default and means that the document will occupy the same
   <a href="#top-level-browsing-context" id="cross-origin-opener-policies:top-level-browsing-context-3">top-level browsing context</a> as its predecessor, unless that document specified a
   different <a href="#cross-origin-opener-policy" id="cross-origin-opener-policies:cross-origin-opener-policy">opener policy</a>.</p></dd><dt>"<dfn id="coop-same-origin-allow-popups"><code>same-origin-allow-popups</code></dfn>"</dt><dd><p>This forces the creation of a new <a href="#top-level-browsing-context" id="cross-origin-opener-policies:top-level-browsing-context-4">top-level browsing context</a> for the
   document, unless its predecessor specified the same <a href="#cross-origin-opener-policy" id="cross-origin-opener-policies:cross-origin-opener-policy-2">opener policy</a> and they are
   <a href="#same-origin" id="cross-origin-opener-policies:same-origin">same origin</a>.</p></dd><dt>"<dfn id="coop-same-origin"><code>same-origin</code></dfn>"</dt><dd><p>This behaves the same as "<code id="cross-origin-opener-policies:coop-same-origin-allow-popups"><a href="#coop-same-origin-allow-popups">same-origin-allow-popups</a></code>", with the addition that
   any <a href="#auxiliary-browsing-context" id="cross-origin-opener-policies:auxiliary-browsing-context">auxiliary browsing context</a> created needs to contain <a href="#same-origin" id="cross-origin-opener-policies:same-origin-2">same origin</a>
   documents that also have the same <a href="#cross-origin-opener-policy" id="cross-origin-opener-policies:cross-origin-opener-policy-3">opener policy</a> or it will appear closed to the
   opener.</p></dd><dt>"<dfn id="coop-same-origin-plus-coep"><code>same-origin-plus-COEP</code></dfn>"</dt><dd>
    <p>This behaves the same as "<code id="cross-origin-opener-policies:coop-same-origin"><a href="#coop-same-origin">same-origin</a></code>", with the
    addition that it sets the (new) <a href="#top-level-browsing-context" id="cross-origin-opener-policies:top-level-browsing-context-5">top-level browsing context</a>'s <a href="#tlbc-group" id="cross-origin-opener-policies:tlbc-group-2">group</a>'s <a href="#bcg-cross-origin-isolation" id="cross-origin-opener-policies:bcg-cross-origin-isolation">cross-origin isolation
    mode</a> to one of "<code id="cross-origin-opener-policies:cross-origin-isolation-logical"><a href="#cross-origin-isolation-logical">logical</a></code>" or "<code id="cross-origin-opener-policies:cross-origin-isolation-concrete"><a href="#cross-origin-isolation-concrete">concrete</a></code>".</p>

    <p class="note">"<code id="cross-origin-opener-policies:coop-same-origin-plus-coep"><a href="#coop-same-origin-plus-coep">same-origin-plus-COEP</a></code>" cannot
    be directly set via the `<code id="cross-origin-opener-policies:cross-origin-opener-policy-2-2"><a href="#cross-origin-opener-policy-2">Cross-Origin-Opener-Policy</a></code>` header, but results from a
    combination of setting both `<code><a href="#cross-origin-opener-policy-2" id="cross-origin-opener-policies:cross-origin-opener-policy-2-3">Cross-Origin-Opener-Policy</a>: <a href="#coop-same-origin" id="cross-origin-opener-policies:coop-same-origin-2">same-origin</a></code>` and a
    `<code id="cross-origin-opener-policies:cross-origin-embedder-policy"><a href="#cross-origin-embedder-policy">Cross-Origin-Embedder-Policy</a></code>` header whose value is <a href="#compatible-with-cross-origin-isolation" id="cross-origin-opener-policies:compatible-with-cross-origin-isolation">compatible with
    cross-origin isolation</a> together.</p>
   </dd><dt>"<dfn id="coop-noopener-allow-popups"><code>noopener-allow-popups</code></dfn>"</dt><dd>
    <p>This forces the creation of a new <a href="#top-level-browsing-context" id="cross-origin-opener-policies:top-level-browsing-context-6">top-level browsing context</a> for the document,
    regardless of its predecessor.</p>

    <div class="note">
     <p>While including a <code id="cross-origin-opener-policies:coop-noopener-allow-popups"><a href="#coop-noopener-allow-popups">noopener-allow-popups</a></code> value severs the opener
     relationship between the document on which it is applied and its opener, it does not create a
     robust security boundary between those same-origin documents.</p>

     <p>Other risks from same-origin applications include:</p>

     <ul><li><p>Same-origin requests fetching the document's content — could be mitigated through
      Fetch Metadata filtering. <a href="#refsFETCHMETADATA">[FETCHMETADATA]</a></p></li><li><p>Same-origin framing - could be mitigated through <code id="cross-origin-opener-policies:x-frame-options"><a href="#x-frame-options">X-Frame-Options</a></code> or CSP
      <code id="cross-origin-opener-policies:frame-ancestors-directive"><a data-x-internal="frame-ancestors-directive" href="https://w3c.github.io/webappsec-csp/#frame-ancestors">frame-ancestors</a></code>.</p></li><li><p>JavaScript accessible cookies - can be mitigated by ensuring all cookies are <code>httponly</code>.</p></li><li><p><code id="cross-origin-opener-policies:dom-localstorage"><a href="#dom-localstorage">localStorage</a></code> access to sensitive data.</p></li><li><p>Service worker installation.</p></li><li><p><a href="https://w3c.github.io/ServiceWorker/#cache">Cache API</a> manipulation or
      access to sensitive data. <a href="#refsSW">[SW]</a></p></li><li><p><code>postMessage</code> or <code id="cross-origin-opener-policies:broadcastchannel"><a href="#broadcastchannel">BroadcastChannel</a></code> messaging that
      exposes sensitive information.</p></li><li><p>Autofill which may not require user interaction for same-origin documents.</p></li></ul>

     <p>Developers using <code id="cross-origin-opener-policies:coop-noopener-allow-popups-2"><a href="#coop-noopener-allow-popups">noopener-allow-popups</a></code>
     need to make sure that their sensitive applications don't rely on client-side features
     accessible to other same-origin documents, e.g., <code id="cross-origin-opener-policies:dom-localstorage-2"><a href="#dom-localstorage">localStorage</a></code> and other client-side storage APIs,
     <code id="cross-origin-opener-policies:broadcastchannel-2"><a href="#broadcastchannel">BroadcastChannel</a></code> and related same-origin communication mechanisms. They also need
     to make sure that their server-side endpoints don't return sensitive data to non-navigation
     requests, whose response content is accessible to same-origin
     documents.</p>
    </div>
   </dd></dl>

  

  <p>An <dfn id="cross-origin-opener-policy">opener policy</dfn> consists of:</p>

  <ul><li><p>A <dfn id="coop-struct-value">value</dfn>, which is an <a href="#cross-origin-opener-policy-value" id="cross-origin-opener-policies:cross-origin-opener-policy-value">opener policy value</a>, initially "<code id="cross-origin-opener-policies:coop-unsafe-none"><a href="#coop-unsafe-none">unsafe-none</a></code>".</p></li><li><p>A <dfn id="coop-struct-report-endpoint">reporting endpoint</dfn>, which is string or
   null, initially null.</p></li><li><p>A <dfn id="coop-struct-report-only-value">report-only value</dfn>, which is an <a href="#cross-origin-opener-policy-value" id="cross-origin-opener-policies:cross-origin-opener-policy-value-2">opener policy value</a>, initially "<code id="cross-origin-opener-policies:coop-unsafe-none-2"><a href="#coop-unsafe-none">unsafe-none</a></code>".</p></li><li><p>A <dfn id="coop-struct-report-only-endpoint">report-only reporting endpoint</dfn>,
   which is a string or null, initially null.</p></li></ul>

  <div data-algorithm="">
  <p>To <dfn id="matching-coop">match opener policy values</dfn>, given an <a href="#cross-origin-opener-policy-value" id="cross-origin-opener-policies:cross-origin-opener-policy-value-3">opener policy
  value</a> <var>documentCOOP</var>, an <a href="#concept-origin" id="cross-origin-opener-policies:concept-origin">origin</a> <var>documentOrigin</var>, an
  <a href="#cross-origin-opener-policy-value" id="cross-origin-opener-policies:cross-origin-opener-policy-value-4">opener policy value</a> <var>responseCOOP</var>, and an <a href="#concept-origin" id="cross-origin-opener-policies:concept-origin-2">origin</a>
  <var>responseOrigin</var>:</p>

  <ol><li><p>If <var>documentCOOP</var> is "<code id="cross-origin-opener-policies:coop-unsafe-none-3"><a href="#coop-unsafe-none">unsafe-none</a></code>" and
   <var>responseCOOP</var> is "<code id="cross-origin-opener-policies:coop-unsafe-none-4"><a href="#coop-unsafe-none">unsafe-none</a></code>", then return
   true.</p></li><li><p>If <var>documentCOOP</var> is "<code id="cross-origin-opener-policies:coop-unsafe-none-5"><a href="#coop-unsafe-none">unsafe-none</a></code>" or
   <var>responseCOOP</var> is "<code id="cross-origin-opener-policies:coop-unsafe-none-6"><a href="#coop-unsafe-none">unsafe-none</a></code>", then return
   false.</p></li><li><p>If <var>documentCOOP</var> is <var>responseCOOP</var> and <var>documentOrigin</var> is
   <a href="#same-origin" id="cross-origin-opener-policies:same-origin-3">same origin</a> with <var>responseOrigin</var>, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  


  <h5 id="the-coop-headers"><span class="secno">7.1.3.1</span> The headers<a href="#the-coop-headers" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy" title="The HTTP Cross-Origin-Opener-Policy (COOP) response header allows you to ensure a top-level document does not share a browsing context group with cross-origin documents.">Headers/Cross-Origin-Opener-Policy</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>79+</span></span><span class="safari yes"><span>Safari</span><span>15.2+</span></span><span class="chrome yes"><span>Chrome</span><span>83+</span></span><hr><span class="opera no"><span>Opera</span><span>No</span></span><span class="edge_blink yes"><span>Edge</span><span>83+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android no"><span>WebView Android</span><span>No</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Android</span><span>No</span></span></div></div></div>

  <p>A <code id="the-coop-headers:document"><a href="#document">Document</a></code>'s <a href="#concept-document-coop" id="the-coop-headers:concept-document-coop">cross-origin opener
  policy</a> is derived from the `<dfn id="cross-origin-opener-policy-2" data-dfn-type="http-header"><code>Cross-Origin-Opener-Policy</code></dfn>` and `<dfn id="cross-origin-opener-policy-report-only" data-dfn-type="http-header"><code>Cross-Origin-Opener-Policy-Report-Only</code></dfn>` HTTP response headers.
  These headers are <a href="https://httpwg.org/specs/rfc8941.html" id="the-coop-headers:http-structured-header" data-x-internal="http-structured-header">structured headers</a> whose value must
  be a <a href="https://httpwg.org/specs/rfc8941.html#token" id="the-coop-headers:http-structured-header-token" data-x-internal="http-structured-header-token">token</a>. <a href="#refsSTRUCTURED-FIELDS">[STRUCTURED-FIELDS]</a></p>

  <p>The valid <a href="https://httpwg.org/specs/rfc8941.html#token" id="the-coop-headers:http-structured-header-token-2" data-x-internal="http-structured-header-token">token</a> values are the <a href="#cross-origin-opener-policy-value" id="the-coop-headers:cross-origin-opener-policy-value">opener policy values</a>. The token may also have
  attached <a href="https://httpwg.org/specs/rfc8941.html#param" id="the-coop-headers:http-structured-header-parameters" data-x-internal="http-structured-header-parameters">parameters</a>; of these, the "<dfn id="coop-report-to"><code>report-to</code></dfn>" parameter can have a <a id="the-coop-headers:valid-url-string" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL
  string</a> identifying an appropriate reporting endpoint. <a href="#refsREPORTING">[REPORTING]</a></p>

  <p class="note">Per the processing model described below, user agents will ignore this header if it contains an invalid value. Likewise, user
  agents will ignore this header if the value cannot be parsed as a <a href="https://httpwg.org/specs/rfc8941.html#token" id="the-coop-headers:http-structured-header-token-3" data-x-internal="http-structured-header-token">token</a>.</p>

  

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="obtain-coop">obtain an opener policy</dfn> given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-coop-headers:concept-response" data-x-internal="concept-response">response</a> <var>response</var> and an <a href="#environment" id="the-coop-headers:environment">environment</a>
  <var>reservedEnvironment</var>:</p>

  <ol><li><p>Let <var>policy</var> be a new <a href="#cross-origin-opener-policy" id="the-coop-headers:cross-origin-opener-policy">opener policy</a>.</p></li><li><p>If <var>reservedEnvironment</var> is a <a href="#non-secure-context" id="the-coop-headers:non-secure-context">non-secure context</a>, then return
   <var>policy</var>.</p></li><li><p>Let <var>parsedItem</var> be the result of <a id="the-coop-headers:getting-a-structured-field-value" href="https://fetch.spec.whatwg.org/#concept-header-list-get-structured-header" data-x-internal="getting-a-structured-field-value">getting a structured field value</a>
   given `<code id="the-coop-headers:cross-origin-opener-policy-2"><a href="#cross-origin-opener-policy-2">Cross-Origin-Opener-Policy</a></code>` and "<code>item</code>" from
   <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="the-coop-headers:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a>.</p></li><li>
    <p>If <var>parsedItem</var> is not null, then:</p>

    <ol><li>
      <p>If <var>parsedItem</var>[0] is "<code id="the-coop-headers:coop-same-origin"><a href="#coop-same-origin">same-origin</a></code>",
      then:</p>

      <ol><li><p>Let <var>coep</var> be the result of <a href="#obtain-an-embedder-policy" id="the-coop-headers:obtain-an-embedder-policy">obtaining a cross-origin embedder policy</a> from <var>response</var> and
       <var>reservedEnvironment</var>.</p></li><li><p>If <var>coep</var>'s <a href="#embedder-policy-value-2" id="the-coop-headers:embedder-policy-value-2">value</a> is
       <a href="#compatible-with-cross-origin-isolation" id="the-coop-headers:compatible-with-cross-origin-isolation">compatible with cross-origin isolation</a>, then set <var>policy</var>'s <a href="#coop-struct-value" id="the-coop-headers:coop-struct-value">value</a> to "<code id="the-coop-headers:coop-same-origin-plus-coep"><a href="#coop-same-origin-plus-coep">same-origin-plus-COEP</a></code>".</p></li><li><p>Otherwise, set <var>policy</var>'s <a href="#coop-struct-value" id="the-coop-headers:coop-struct-value-2">value</a> to
       "<code id="the-coop-headers:coop-same-origin-2"><a href="#coop-same-origin">same-origin</a></code>".</p></li></ol>
     </li><li><p>If <var>parsedItem</var>[0] is "<code id="the-coop-headers:coop-same-origin-allow-popups"><a href="#coop-same-origin-allow-popups">same-origin-allow-popups</a></code>", then set
     <var>policy</var>'s <a href="#coop-struct-value" id="the-coop-headers:coop-struct-value-3">value</a> to "<code id="the-coop-headers:coop-same-origin-allow-popups-2"><a href="#coop-same-origin-allow-popups">same-origin-allow-popups</a></code>".</p></li><li><p>If <var>parsedItem</var>[0] is "<code id="the-coop-headers:coop-noopener-allow-popups"><a href="#coop-noopener-allow-popups">noopener-allow-popups</a></code>", then set
     <var>policy</var>'s <a href="#coop-struct-value" id="the-coop-headers:coop-struct-value-4">value</a> to "<code id="the-coop-headers:coop-noopener-allow-popups-2"><a href="#coop-noopener-allow-popups">noopener-allow-popups</a></code>".</p></li><li><p>If <var>parsedItem</var>[1]["<code id="the-coop-headers:coop-report-to"><a href="#coop-report-to">report-to</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-coop-headers:map-exists" data-x-internal="map-exists">exists</a> and it is a string, then set <var>policy</var>'s <a href="#coop-struct-report-endpoint" id="the-coop-headers:coop-struct-report-endpoint">reporting endpoint</a> to
     <var>parsedItem</var>[1]["<code id="the-coop-headers:coop-report-to-2"><a href="#coop-report-to">report-to</a></code>"].</p></li></ol>
   </li><li><p>Set <var>parsedItem</var> to the result of <a id="the-coop-headers:getting-a-structured-field-value-2" href="https://fetch.spec.whatwg.org/#concept-header-list-get-structured-header" data-x-internal="getting-a-structured-field-value">getting a structured field value</a>
   given `<code id="the-coop-headers:cross-origin-opener-policy-report-only"><a href="#cross-origin-opener-policy-report-only">Cross-Origin-Opener-Policy-Report-Only</a></code>` and "<code>item</code>"
   from <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="the-coop-headers:concept-response-header-list-2" data-x-internal="concept-response-header-list">header
   list</a>.</p></li><li>
    <p>If <var>parsedItem</var> is not null, then:</p>

    <ol><li>
      <p>If <var>parsedItem</var>[0] is "<code id="the-coop-headers:coop-same-origin-3"><a href="#coop-same-origin">same-origin</a></code>",
      then:</p>

      <ol><li><p>Let <var>coep</var> be the result of <a href="#obtain-an-embedder-policy" id="the-coop-headers:obtain-an-embedder-policy-2">obtaining a cross-origin embedder policy</a> from <var>response</var> and
       <var>reservedEnvironment</var>.</p></li><li>
        <p>If <var>coep</var>'s <a href="#embedder-policy-value-2" id="the-coop-headers:embedder-policy-value-2-2">value</a> is
        <a href="#compatible-with-cross-origin-isolation" id="the-coop-headers:compatible-with-cross-origin-isolation-2">compatible with cross-origin isolation</a> or <var>coep</var>'s <a href="#embedder-policy-report-only-value" id="the-coop-headers:embedder-policy-report-only-value">report-only value</a> is <a href="#compatible-with-cross-origin-isolation" id="the-coop-headers:compatible-with-cross-origin-isolation-3">compatible
        with cross-origin isolation</a>, then set <var>policy</var>'s <a href="#coop-struct-report-only-value" id="the-coop-headers:coop-struct-report-only-value">report-only value</a> to "<code id="the-coop-headers:coop-same-origin-plus-coep-2"><a href="#coop-same-origin-plus-coep">same-origin-plus-COEP</a></code>".</p>

        <p class="note">Report only COOP also considers report-only COEP to assign the special
        "<code id="the-coop-headers:coop-same-origin-plus-coep-3"><a href="#coop-same-origin-plus-coep">same-origin-plus-COEP</a></code>" value. This allows
        developers more freedom in the order of deployment of COOP and COEP.</p>
       </li><li><p>Otherwise, set <var>policy</var>'s <a href="#coop-struct-report-only-value" id="the-coop-headers:coop-struct-report-only-value-2">report-only value</a> to "<code id="the-coop-headers:coop-same-origin-4"><a href="#coop-same-origin">same-origin</a></code>".</p></li></ol>
     </li><li><p>If <var>parsedItem</var>[0] is "<code id="the-coop-headers:coop-same-origin-allow-popups-3"><a href="#coop-same-origin-allow-popups">same-origin-allow-popups</a></code>", then set
     <var>policy</var>'s <a href="#coop-struct-report-only-value" id="the-coop-headers:coop-struct-report-only-value-3">report-only value</a> to
     "<code id="the-coop-headers:coop-same-origin-allow-popups-4"><a href="#coop-same-origin-allow-popups">same-origin-allow-popups</a></code>".</p></li><li><p>If <var>parsedItem</var>[1]["<code id="the-coop-headers:coop-report-to-3"><a href="#coop-report-to">report-to</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-coop-headers:map-exists-2" data-x-internal="map-exists">exists</a> and it is a string, then set <var>policy</var>'s <a href="#coop-struct-report-only-endpoint" id="the-coop-headers:coop-struct-report-only-endpoint">report-only reporting endpoint</a> to
     <var>parsedItem</var>[1]["<code id="the-coop-headers:coop-report-to-4"><a href="#coop-report-to">report-to</a></code>"].</p></li></ol>
   </li><li><p>Return <var>policy</var>.</p></li></ol>
  </div>


  <h5 id="browsing-context-group-switches-due-to-cross-origin-opener-policy"><span class="secno">7.1.3.2</span> Browsing context group
  switches due to opener policy<a href="#browsing-context-group-switches-due-to-cross-origin-opener-policy" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="check-browsing-context-group-switch-coop-value-popup">check if popup COOP
  values require a browsing context group switch</dfn>, given two <a href="#concept-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:concept-origin">origins</a> <var>responseOrigin</var> and
  <var>activeDocumentNavigationOrigin</var>, and two <a href="#coop-struct-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-value">opener policy
  values</a> <var>responseCOOPValue</var> and <var>activeDocumentCOOPValue</var>:</p>
  <ol><li><p>If <var>responseCOOPValue</var> is "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-noopener-allow-popups"><a href="#coop-noopener-allow-popups">noopener-allow-popups</a></code>", then return true.</p></li><li>
    <p>If all of the following are true:</p>

    <ul><li><p><var>activeDocumentCOOPValue</var>'s <a href="#coop-struct-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-value-2">value</a> is
     "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-same-origin-allow-popups"><a href="#coop-same-origin-allow-popups">same-origin-allow-popups</a></code>" or
     "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-noopener-allow-popups-2"><a href="#coop-noopener-allow-popups">noopener-allow-popups</a></code>"; and</p></li><li><p><var>responseCOOPValue</var> is "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-unsafe-none"><a href="#coop-unsafe-none">unsafe-none</a></code>",</p></li></ul>

    <p>then return false.</p>
   </li><li><p>If the result of <a href="#matching-coop" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:matching-coop">matching</a>
   <var>activeDocumentCOOPValue</var>, <var>activeDocumentNavigationOrigin</var>,
   <var>responseCOOPValue</var>, and <var>responseOrigin</var> is true, then return false.</p></li><li><p>Return true.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="check-browsing-context-group-switch-coop-value">check if COOP values require a
  browsing context group switch</dfn>, given a boolean <var>isInitialAboutBlank</var>, two <a href="#concept-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:concept-origin-2">origins</a> <var>responseOrigin</var> and
  <var>activeDocumentNavigationOrigin</var>, and two <a href="#coop-struct-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-value-3">opener policy
  values</a> <var>responseCOOPValue</var> and <var>activeDocumentCOOPValue</var>:</p>

  <ol><li><p>If <var>isInitialAboutBlank</var> is true, then return the result of <a href="#check-browsing-context-group-switch-coop-value-popup" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:check-browsing-context-group-switch-coop-value-popup">checking if popup COOP values
   requires a browsing context group switch</a> with <var>responseOrigin</var>,
   <var>activeDocumentNavigationOrigin</var>, <var>responseCOOPValue</var>, and
   <var>activeDocumentCOOPValue</var>.</p></li><li>
    <p class="note">Here we are dealing with a non-popup navigation.</p>

    <p>If the result of <a href="#matching-coop" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:matching-coop-2">matching</a>
    <var>activeDocumentCOOPValue</var>, <var>activeDocumentNavigationOrigin</var>,
    <var>responseCOOPValue</var>, and <var>responseOrigin</var> is true, then return false.</p>
   </li><li><p>Return true.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="check-bcg-switch-navigation-report-only">check if enforcing report-only COOP
  would require a browsing context group switch</dfn>, given a boolean
  <var>isInitialAboutBlank</var>, two <a href="#concept-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:concept-origin-3">origins</a>
  <var>responseOrigin</var>, <var>activeDocumentNavigationOrigin</var>, and two <a href="#cross-origin-opener-policy" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:cross-origin-opener-policy">opener policies</a> <var>responseCOOP</var> and <var>activeDocumentCOOP</var>:</p>

  <ol><li>
    <p>If the result of <a href="#check-browsing-context-group-switch-coop-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:check-browsing-context-group-switch-coop-value">checking if
    COOP values require a browsing context group switch</a> given
    <var>isInitialAboutBlank</var>, <var>responseOrigin</var>,
    <var>activeDocumentNavigationOrigin</var>, <var>responseCOOP</var>'s <a href="#coop-struct-report-only-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-report-only-value">report-only value</a>, and
    <var>activeDocumentCOOPReportOnly</var>'s <a href="#coop-struct-report-only-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-report-only-value-2">report-only value</a> is false, then return
    false.</p>

    <p class="note">Matching report-only policies allows a website to specify the same report-only
    opener policy on all its pages and not receive violation reports for navigations between these
    pages.</p>
   </li><li><p>If the result of <a href="#check-browsing-context-group-switch-coop-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:check-browsing-context-group-switch-coop-value-2">checking
   if COOP values require a browsing context group switch</a> given
   <var>isInitialAboutBlank</var>, <var>responseOrigin</var>,
   <var>activeDocumentNavigationOrigin</var>, <var>responseCOOP</var>'s <a href="#coop-struct-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-value-4">value</a>, and <var>activeDocumentCOOPReportOnly</var>'s <a href="#coop-struct-report-only-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-report-only-value-3">report-only value</a> is true, then return
   true.</p></li><li><p>If the result of <a href="#check-browsing-context-group-switch-coop-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:check-browsing-context-group-switch-coop-value-3">checking
   if COOP values require a browsing context group switch</a> given
   <var>isInitialAboutBlank</var>, <var>responseOrigin</var>,
   <var>activeDocumentNavigationOrigin</var>, <var>responseCOOP</var>'s <a href="#coop-struct-report-only-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-report-only-value-4">report-only value</a>, and
   <var>activeDocumentCOOPReportOnly</var>'s <a href="#coop-struct-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-value-5">value</a> is true,
   then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <p>An <dfn id="coop-enforcement-result">opener policy enforcement result</dfn> is a
  <a id="browsing-context-group-switches-due-to-cross-origin-opener-policy:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p>A boolean <dfn id="coop-enforcement-bcg-switch">needs a browsing context group
   switch</dfn>, initially false.</p></li><li><p>A boolean <dfn id="coop-enforcement-bcg-switch-report-only">would need a browsing
   context group switch due to report-only</dfn>, initially false.</p></li><li><p>A <a id="browsing-context-group-switches-due-to-cross-origin-opener-policy:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <dfn id="coop-enforcement-url">url</dfn>.</p></li><li><p>An <a href="#concept-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:concept-origin-4">origin</a> <dfn id="coop-enforcement-origin">origin</dfn>.</p></li><li><p>An <a href="#cross-origin-opener-policy" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:cross-origin-opener-policy-2">opener policy</a> <dfn id="coop-enforcement-coop">opener
   policy</dfn>.</p></li><li><p>A boolean <dfn id="coop-enforcement-source">current context is navigation
   source</dfn>, initially false.</p></li></ul>

  <div data-algorithm="">
  <p>To <dfn id="coop-enforce">enforce a response's opener policy</dfn>, given a <a href="#browsing-context" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:browsing-context">browsing
  context</a> <var>browsingContext</var>, a <a id="browsing-context-group-switches-due-to-cross-origin-opener-policy:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>responseURL</var>, an
  <a href="#concept-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:concept-origin-5">origin</a> <var>responseOrigin</var>, an <a href="#cross-origin-opener-policy" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:cross-origin-opener-policy-3">opener policy</a>
  <var>responseCOOP</var>, an <a href="#coop-enforcement-result" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-result">opener policy enforcement
  result</a> <var>currentCOOPEnforcementResult</var>, and a <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:concept-request-referrer" data-x-internal="concept-request-referrer">referrer</a> <var>referrer</var>:</p>

  <ol><li>
    <p>Let <var>newCOOPEnforcementResult</var> be a new <a href="#coop-enforcement-result" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-result-2">opener policy enforcement result</a> with</p>

    <dl class="props"><dt><a href="#coop-enforcement-bcg-switch" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-bcg-switch">needs a browsing context group switch</a></dt><dd><var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-bcg-switch" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-bcg-switch-2">needs
     a browsing context group switch</a></dd><dt><a href="#coop-enforcement-bcg-switch-report-only" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-bcg-switch-report-only">would need a browsing context group switch due to report-only</a></dt><dd><var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-bcg-switch-report-only" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-bcg-switch-report-only-2">would need a browsing context group switch
     due to report-only</a></dd><dt><a href="#coop-enforcement-url" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-url">url</a></dt><dd><var>responseURL</var></dd><dt><a href="#coop-enforcement-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-origin">origin</a></dt><dd><var>responseOrigin</var></dd><dt><a href="#coop-enforcement-coop" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-coop">opener policy</a></dt><dd><var>responseCOOP</var></dd><dt><a href="#coop-enforcement-source" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-source">current context is navigation source</a></dt><dd>true</dd></dl>
   </li><li><p>Let <var>isInitialAboutBlank</var> be <var>browsingContext</var>'s <a href="#active-document" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:active-document">active
   document</a>'s <a href="#is-initial-about:blank" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:is-initial-about:blank">is initial <code>about:blank</code></a>.</p></li><li><p>If <var>isInitialAboutBlank</var> is true and <var>browsingContext</var>'s <a href="#browsing-context-initial-url" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:browsing-context-initial-url">initial URL</a> is null, set
   <var>browsingContext</var>'s <a href="#browsing-context-initial-url" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:browsing-context-initial-url-2">initial URL</a> to
   <var>responseURL</var>.</p></li><li>
    <p>If the result of <a href="#check-browsing-context-group-switch-coop-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:check-browsing-context-group-switch-coop-value-4">checking if
    COOP values require a browsing context group switch</a> given
    <var>isInitialAboutBlank</var>, <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-coop" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-coop-2">opener policy</a>'s <a href="#coop-struct-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-value-6">value</a>, <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-origin-2">origin</a>, <var>responseCOOP</var>'s <a href="#coop-struct-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-value-7">value</a>, and <var>responseOrigin</var> is true, then:</p>

    <ol><li><p>Set <var>newCOOPEnforcementResult</var>'s <a href="#coop-enforcement-bcg-switch" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-bcg-switch-3">needs a browsing context group switch</a> to
     true.</p></li><li>
      <p>If <var>browsingContext</var>'s <a href="#tlbc-group" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:tlbc-group">group</a>'s <a href="#browsing-context-set" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:browsing-context-set">browsing
      context set</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:list-size" data-x-internal="list-size">size</a> is greater than 1, then:</p>

      <ol><li><p><a href="#coop-violation-navigation-to" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-violation-navigation-to">Queue a violation report for browsing
       context group switch when navigating to a COOP response</a> with <var>responseCOOP</var>,
       "<code>enforce</code>", <var>responseURL</var>,
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-url" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-url-2">url</a>,
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-origin-3">origin</a>, <var>responseOrigin</var>, and
       <var>referrer</var>.</p></li><li><p><a href="#coop-violation-navigation-from" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-violation-navigation-from">Queue a violation report for browsing
       context group switch when navigating away from a COOP response</a> with
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-coop" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-coop-3">opener
       policy</a>, "<code>enforce</code>", <var>currentCOOPEnforcementResult</var>'s
       <a href="#coop-enforcement-url" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-url-3">url</a>, <var>responseURL</var>,
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-origin-4">origin</a>, <var>responseOrigin</var>, and
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-source" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-source-2">current
       context is navigation source</a>.</p></li></ol>
     </li></ol>
   </li><li>
    <p>If the result of <a href="#check-bcg-switch-navigation-report-only" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:check-bcg-switch-navigation-report-only">checking if
    enforcing report-only COOP would require a browsing context group switch</a> given
    <var>isInitialAboutBlank</var>, <var>responseOrigin</var>,
    <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-origin-5">origin</a>,
    <var>responseCOOP</var>, and <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-coop" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-coop-4">opener policy</a>, is true, then:</p>

    <ol><li><p>Set <var>newCOOPEnforcementResult</var>'s <a href="#coop-enforcement-bcg-switch-report-only" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-bcg-switch-report-only-3">would
     need a browsing context group switch due to report-only</a> to true.</p></li><li>
      <p>If <var>browsingContext</var>'s <a href="#tlbc-group" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:tlbc-group-2">group</a>'s <a href="#browsing-context-set" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:browsing-context-set-2">browsing
      context set</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:list-size-2" data-x-internal="list-size">size</a> is greater than 1, then:</p>

      <ol><li><p><a href="#coop-violation-navigation-to" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-violation-navigation-to-2">Queue a violation report for browsing
       context group switch when navigating to a COOP response</a> with <var>responseCOOP</var>,
       "<code>reporting</code>", <var>responseURL</var>,
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-url" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-url-4">url</a>,
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-origin-6">origin</a>, <var>responseOrigin</var>, and
       <var>referrer</var>.</p></li><li><p><a href="#coop-violation-navigation-from" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-violation-navigation-from-2">Queue a violation report for browsing
       context group switch when navigating away from a COOP response</a> with
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-coop" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-coop-5">opener
       policy</a>, "<code>reporting</code>",
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-url" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-url-5">url</a>,
       <var>responseURL</var>, <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-origin-7">origin</a>, <var>responseOrigin</var>, and
       <var>currentCOOPEnforcementResult</var>'s <a href="#coop-enforcement-source" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-source-3">current
       context is navigation source</a>.</p></li></ol>
     </li></ol>
   </li><li><p>Return <var>newCOOPEnforcementResult</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="obtain-browsing-context-navigation">obtain a browsing context to use for a
  navigation response</dfn>, given <a href="#navigation-params" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:navigation-params">navigation params</a> <var>navigationParams</var>:</p>

  <ol><li><p>Let <var>browsingContext</var> be <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:navigation-params-navigable">navigable</a>'s <a href="#nav-bc" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:nav-bc">active browsing
   context</a>.</p></li><li><p>If <var>browsingContext</var> is not a <a href="#top-level-browsing-context" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:top-level-browsing-context">top-level browsing context</a>, then
   return <var>browsingContext</var>.</p></li><li><p>Let <var>coopEnforcementResult</var> be <var>navigationParams</var>'s <a href="#navigation-params-coop-enforcement-result" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:navigation-params-coop-enforcement-result">COOP enforcement result</a>.</p></li><li><p>Let <var>swapGroup</var> be <var>coopEnforcementResult</var>'s <a href="#coop-enforcement-bcg-switch" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-bcg-switch-4">needs a browsing context group switch</a>.</p></li><li><p>Let <var>sourceOrigin</var> be <var>browsingContext</var>'s
   <a href="#active-document" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:active-document-2">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:concept-document-origin" data-x-internal="concept-document-origin">origin</a>.</p></li><li><p>Let <var>destinationOrigin</var> be <var>navigationParams</var>'s <a href="#navigation-params-origin" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:navigation-params-origin">origin</a>.</p></li><li>
    <p>If <var>sourceOrigin</var> is not <a href="#same-site" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:same-site">same site</a> with
    <var>destinationOrigin</var>:</p>

    <ol><li>
      <p>If either of <var>sourceOrigin</var> or <var>destinationOrigin</var> have a <a href="#concept-origin-scheme" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:concept-origin-scheme">scheme</a> that is not an <a id="browsing-context-group-switches-due-to-cross-origin-opener-policy:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a> and
      the user agent considers it necessary for <var>sourceOrigin</var> and
      <var>destinationOrigin</var> to be isolated from each other (for
      <a id="browsing-context-group-switches-due-to-cross-origin-opener-policy:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> reasons), optionally set <var>swapGroup</var> to true.</p>

      <p class="note">For example, if a user navigates from <code>about:settings</code> to
      <code>https://example.com</code>, the user agent could force a swap.</p>

      <p class="XXX"><a href="https://github.com/whatwg/html/issues/10842">Issue #10842</a> tracks
      settling on an interoperable behavior here, instead of letting this be optional.</p>
     </li><li>
      <p>If <var>navigationParams</var>'s <a href="#navigation-params-user-involvement" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:navigation-params-user-involvement"> user
      involvement</a> is "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:uni-browser-ui"><a href="#uni-browser-ui">browser UI</a></code>", optionally set
      <var>swapGroup</var> to true.</p>

      <p class="XXX"><a href="https://github.com/whatwg/html/issues/6356">Issue #6356</a> tracks
      settling on an interoperable behavior here, instead of letting this be optional.</p>
     </li></ol>
   </li><li>
    <p>If <var>browsingContext</var>'s <a href="#tlbc-group" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:tlbc-group-3">group</a>'s <a href="#browsing-context-set" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:browsing-context-set-3">browsing
    context set</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:list-size-3" data-x-internal="list-size">size</a> is 1, optionally set
    <var>swapGroup</var> to true.</p>

    <p class="note">Some implementations swap browsing context groups here for performance
    reasons.</p>

    <p class="note">The check for other contexts that could script this one is not sufficient to
    prevent differences in behavior that could affect a web page. Even if there are currently no
    other contexts, the destination page could open a window, then if the user navigates back, the
    previous page could expect to be able to script the opened window. Doing a swap here would break
    that use case.</p>
   </li><li>
    <p>If <var>swapGroup</var> is false, then:</p>

    <ol><li><p>If <var>coopEnforcementResult</var>'s <a href="#coop-enforcement-bcg-switch-report-only" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-enforcement-bcg-switch-report-only-4">would need a browsing context group switch
     due to report-only</a> is true, set <var>browsingContext</var>'s <a href="#virtual-browsing-context-group-id" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:virtual-browsing-context-group-id">virtual browsing context group ID</a> to a new
     unique identifier.</p></li><li><p>Return <var>browsingContext</var>.</p></li></ol>
   </li><li>
    <p>Let <var>newBrowsingContext</var> be the first return value of <a href="#creating-a-new-top-level-browsing-context" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:creating-a-new-top-level-browsing-context">creating a new
    top-level browsing context and document</a>.</p>

    <p class="note">In this case we are going to perform a browsing context group swap.
    <var>browsingContext</var> will not be used by the new <code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:document"><a href="#document">Document</a></code> that we are about
    to <a href="#initialise-the-document-object" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:initialise-the-document-object">create</a>. If it is not used by other
    <code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:document-2"><a href="#document">Document</a></code>s either (such as ones in the back/forward cache), then the user agent
    might <a href="#a-browsing-context-is-discarded">destroy it</a> at this point.</p>
   </li><li><p>Let <var>navigationCOOP</var> be <var>navigationParams</var>'s <a href="#navigation-params-coop" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:navigation-params-coop">cross-origin opener policy</a>.</p></li><li>
    <p>If <var>navigationCOOP</var>'s <a href="#coop-struct-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-value-8">value</a> is "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-same-origin-plus-coep"><a href="#coop-same-origin-plus-coep">same-origin-plus-COEP</a></code>", then set
    <var>newBrowsingContext</var>'s <a href="#tlbc-group" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:tlbc-group-4">group</a>'s <a href="#bcg-cross-origin-isolation" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:bcg-cross-origin-isolation">cross-origin isolation mode</a> to either "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:cross-origin-isolation-logical"><a href="#cross-origin-isolation-logical">logical</a></code>" or "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:cross-origin-isolation-concrete"><a href="#cross-origin-isolation-concrete">concrete</a></code>". The choice of which is
    <a id="browsing-context-group-switches-due-to-cross-origin-opener-policy:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>.</p>

    <p class="note">It is difficult on some platforms to provide the security properties required
    by the <a href="#concept-settings-object-cross-origin-isolated-capability" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:concept-settings-object-cross-origin-isolated-capability">cross-origin
    isolated capability</a>. "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:cross-origin-isolation-concrete-2"><a href="#cross-origin-isolation-concrete">concrete</a></code>"
    grants access to it and "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:cross-origin-isolation-logical-2"><a href="#cross-origin-isolation-logical">logical</a></code>" does
    not.</p>
   </li><li><p>Let <var>sandboxFlags</var> be a <a href="https://infra.spec.whatwg.org/#list-clone" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:list-clone" data-x-internal="list-clone">clone</a> of
   <var>navigationParams</var>'s <a href="#navigation-params-sandboxing" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:navigation-params-sandboxing">final sandboxing flag set</a>.</p></li><li>
    <p>If <var>sandboxFlags</var> is not empty, then:</p>
    <ol><li><p><a id="browsing-context-group-switches-due-to-cross-origin-opener-policy:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigationCOOP</var>'s <a href="#coop-struct-value" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-struct-value-9">value</a> is
     "<code id="browsing-context-group-switches-due-to-cross-origin-opener-policy:coop-unsafe-none-2"><a href="#coop-unsafe-none">unsafe-none</a></code>".</p></li><li><p><a id="browsing-context-group-switches-due-to-cross-origin-opener-policy:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>newBrowsingContext</var>'s <a href="#popup-sandboxing-flag-set" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:popup-sandboxing-flag-set">popup sandboxing flag
     set</a> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:list-is-empty" data-x-internal="list-is-empty">is empty</a>.</p></li><li><p>Set <var>newBrowsingContext</var>'s <a href="#popup-sandboxing-flag-set" id="browsing-context-group-switches-due-to-cross-origin-opener-policy:popup-sandboxing-flag-set-2">popup sandboxing flag set</a> to
     <var>sandboxFlags</var>.</p></li></ol>
   </li><li><p>Return <var>newBrowsingContext</var>.</p></li></ol>
  </div>


  <h5 id="coop-reporting"><span class="secno">7.1.3.3</span> <span id="reporting"></span>Reporting<a href="#coop-reporting" class="self-link"></a></h5>

  <p>An <dfn id="accessor-accessed-relationship">accessor-accessed relationship</dfn> is an enum that describes the relationship
  between two <a href="#browsing-context" id="coop-reporting:browsing-context">browsing contexts</a> between which an access
  happened. It can take the following values:</p>

  <dl><dt><dfn id="accessor-accessed-opener">accessor is opener</dfn></dt><dd><p>The accessor <a href="#browsing-context" id="coop-reporting:browsing-context-2">browsing context</a> or one of its <a href="#ancestor-browsing-context" id="coop-reporting:ancestor-browsing-context">ancestors</a> is the <a href="#opener-browsing-context" id="coop-reporting:opener-browsing-context">opener browsing context</a> of the accessed
   <a href="#browsing-context" id="coop-reporting:browsing-context-3">browsing context</a>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc">top-level browsing
   context</a>.</p></dd><dt><dfn id="accessor-accessed-openee">accessor is openee</dfn></dt><dd><p>The accessed <a href="#browsing-context" id="coop-reporting:browsing-context-4">browsing context</a> or one of its <a href="#ancestor-browsing-context" id="coop-reporting:ancestor-browsing-context-2">ancestors</a> is the <a href="#opener-browsing-context" id="coop-reporting:opener-browsing-context-2">opener browsing context</a> of the accessor
   <a href="#browsing-context" id="coop-reporting:browsing-context-5">browsing context</a>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-2">top-level browsing
   context</a>.</p></dd><dt><dfn id="accessor-accessed-none">none</dfn></dt><dd><p>There is no opener relationship between the accessor <a href="#browsing-context" id="coop-reporting:browsing-context-6">browsing context</a>, the
   accessor <a href="#browsing-context" id="coop-reporting:browsing-context-7">browsing context</a>, or any of their <a href="#ancestor-browsing-context" id="coop-reporting:ancestor-browsing-context-3">ancestors</a>.</p></dd></dl>

  <div data-algorithm="">
  <p>To <dfn id="coop-check-access-report">check if an access between two browsing contexts
  should be reported</dfn>, given two <a href="#browsing-context" id="coop-reporting:browsing-context-8">browsing contexts</a>
  <var>accessor</var> and <var>accessed</var>, a JavaScript property name <var>P</var>, and an
  <a href="#environment-settings-object" id="coop-reporting:environment-settings-object">environment settings object</a> <var>environment</var>:</p>

  <ol><li><p>If <var>P</var> is not a <a href="#cross-origin-accessible-window-property-name" id="coop-reporting:cross-origin-accessible-window-property-name">cross-origin accessible window property name</a>, then
   return.</p></li><li><p><a id="coop-reporting:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>accessor</var>'s <a href="#active-document" id="coop-reporting:active-document">active document</a> and
   <var>accessed</var>'s <a href="#active-document" id="coop-reporting:active-document-2">active document</a> are both <a href="#fully-active" id="coop-reporting:fully-active">fully active</a>.</p></li><li><p>Let <var>accessorTopDocument</var> be <var>accessor</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-3">top-level browsing context</a>'s <a href="#active-document" id="coop-reporting:active-document-3">active document</a>.</p></li><li><p>Let <var>accessorInclusiveAncestorOrigins</var> be the list obtained by taking the <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="coop-reporting:concept-document-origin" data-x-internal="concept-document-origin">origin</a> of the <a href="#nav-document" id="coop-reporting:nav-document">active
   document</a> of each of <var>accessor</var>'s <a href="#active-document" id="coop-reporting:active-document-4">active document</a>'s <a href="#inclusive-ancestor-navigables" id="coop-reporting:inclusive-ancestor-navigables">inclusive
   ancestor navigables</a>.</p></li><li><p>Let <var>accessedTopDocument</var> be <var>accessed</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-4">top-level browsing context</a>'s <a href="#active-document" id="coop-reporting:active-document-5">active document</a>.</p></li><li><p>Let <var>accessedInclusiveAncestorOrigins</var> be the list obtained by taking the <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="coop-reporting:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> of the <a href="#nav-document" id="coop-reporting:nav-document-2">active
   document</a> of each of <var>accessed</var>'s <a href="#active-document" id="coop-reporting:active-document-6">active document</a>'s <a href="#inclusive-ancestor-navigables" id="coop-reporting:inclusive-ancestor-navigables-2">inclusive
   ancestor navigables</a>.</p></li><li>
    <p>If any of <var>accessorInclusiveAncestorOrigins</var> are not <a href="#same-origin" id="coop-reporting:same-origin">same origin</a> with
    <var>accessorTopDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="coop-reporting:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a>, or if
    any of <var>accessedInclusiveAncestorOrigins</var> are not <a href="#same-origin" id="coop-reporting:same-origin-2">same origin</a> with
    <var>accessedTopDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="coop-reporting:concept-document-origin-4" data-x-internal="concept-document-origin">origin</a>, then
    return.</p>

    <p class="note">This avoids leaking information about cross-origin iframes to a top level frame
    with opener policy reporting.</p>
   </li><li><p>If <var>accessor</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-5">top-level browsing context</a>'s <a href="#virtual-browsing-context-group-id" id="coop-reporting:virtual-browsing-context-group-id">virtual browsing context group ID</a> is
   <var>accessed</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-6">top-level browsing context</a>'s <a href="#virtual-browsing-context-group-id" id="coop-reporting:virtual-browsing-context-group-id-2">virtual browsing context group ID</a>, then
   return.</p></li><li><p>Let <var>accessorAccessedRelationship</var> be a new <a href="#accessor-accessed-relationship" id="coop-reporting:accessor-accessed-relationship">accessor-accessed
   relationship</a> with value <a href="#accessor-accessed-none" id="coop-reporting:accessor-accessed-none">none</a>.</p></li><li><p>If <var>accessed</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-7">top-level browsing context</a>'s
   <a href="#opener-browsing-context" id="coop-reporting:opener-browsing-context-3">opener browsing context</a> is <var>accessor</var> or is an <a href="#ancestor-browsing-context" id="coop-reporting:ancestor-browsing-context-4">ancestor</a> of <var>accessor</var>, then set
   <var>accessorAccessedRelationship</var> to <a href="#accessor-accessed-opener" id="coop-reporting:accessor-accessed-opener">accessor is
   opener</a>.</p></li><li><p>If <var>accessor</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-8">top-level browsing context</a>'s
   <a href="#opener-browsing-context" id="coop-reporting:opener-browsing-context-4">opener browsing context</a> is <var>accessed</var> or is an <a href="#ancestor-browsing-context" id="coop-reporting:ancestor-browsing-context-5">ancestor</a> of <var>accessed</var>, then set
   <var>accessorAccessedRelationship</var> to <a href="#accessor-accessed-openee" id="coop-reporting:accessor-accessed-openee">accessor is
   openee</a>.</p></li><li><p><a href="#coop-violation-access" id="coop-reporting:coop-violation-access">Queue violation reports for accesses</a>, given
   <var>accessorAccessedRelationship</var>, <var>accessorTopDocument</var>'s <a href="#concept-document-coop" id="coop-reporting:concept-document-coop">opener policy</a>, <var>accessedTopDocument</var>'s <a href="#concept-document-coop" id="coop-reporting:concept-document-coop-2">opener policy</a>, <var>accessor</var>'s <a href="#active-document" id="coop-reporting:active-document-7">active
   document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="coop-reporting:the-document's-address" data-x-internal="the-document's-address">URL</a>, <var>accessed</var>'s
   <a href="#active-document" id="coop-reporting:active-document-8">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="coop-reporting:the-document's-address-2" data-x-internal="the-document's-address">URL</a>,
   <var>accessor</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-9">top-level browsing context</a>'s <a href="#browsing-context-initial-url" id="coop-reporting:browsing-context-initial-url">initial URL</a>, <var>accessed</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-10">top-level browsing context</a>'s <a href="#browsing-context-initial-url" id="coop-reporting:browsing-context-initial-url-2">initial URL</a>, <var>accessor</var>'s <a href="#active-document" id="coop-reporting:active-document-9">active
   document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="coop-reporting:concept-document-origin-5" data-x-internal="concept-document-origin">origin</a>, <var>accessed</var>'s
   <a href="#active-document" id="coop-reporting:active-document-10">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="coop-reporting:concept-document-origin-6" data-x-internal="concept-document-origin">origin</a>,
   <var>accessor</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-11">top-level browsing context</a>'s <a href="#opener-origin-at-creation" id="coop-reporting:opener-origin-at-creation">opener origin at creation</a>, <var>accessed</var>'s <a href="#bc-tlbc" id="coop-reporting:bc-tlbc-12">top-level browsing context</a>'s <a href="#opener-origin-at-creation" id="coop-reporting:opener-origin-at-creation-2">opener origin at creation</a>,
   <var>accessorTopDocument</var>'s <a href="#dom-document-referrer" id="coop-reporting:dom-document-referrer">referrer</a>,
   <var>accessedTopDocument</var>'s <a href="#dom-document-referrer" id="coop-reporting:dom-document-referrer-2">referrer</a>,
   <var>P</var>, and <var>environment</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="sanitize-url-report">sanitize a URL to send in a report</dfn> given a
  <a id="coop-reporting:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>:</p>

  <ol><li><p>Let <var>sanitizedURL</var> be a copy of <var>url</var>.</p></li><li><p><a href="https://url.spec.whatwg.org/#set-the-username" id="coop-reporting:set-the-username" data-x-internal="set-the-username">Set the username</a> given <var>sanitizedURL</var> and
   the empty string.

   </p></li><li><p><a href="https://url.spec.whatwg.org/#set-the-password" id="coop-reporting:set-the-password" data-x-internal="set-the-password">Set the password</a> given <var>sanitizedURL</var> and
   the empty string.

   </p></li><li><p>Return the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="coop-reporting:concept-url-serializer" data-x-internal="concept-url-serializer">serialization</a> of
   <var>sanitizedURL</var> with <a href="https://url.spec.whatwg.org/#url-serializer-exclude-fragment" id="coop-reporting:url-serializer-exclude-fragment" data-x-internal="url-serializer-exclude-fragment"><i>exclude
   fragment</i></a> set to true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="coop-violation-navigation-to">queue a violation report for browsing context
  group switch when navigating to a COOP response</dfn> given an <a href="#cross-origin-opener-policy" id="coop-reporting:cross-origin-opener-policy">opener
  policy</a> <var>coop</var>, a string <var>disposition</var>, a <a id="coop-reporting:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>
  <var>coopURL</var>, a <a id="coop-reporting:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>previousResponseURL</var>, two <a href="#concept-origin" id="coop-reporting:concept-origin">origins</a> <var>coopOrigin</var> and <var>previousResponseOrigin</var>, and a
  <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="coop-reporting:concept-request-referrer" data-x-internal="concept-request-referrer">referrer</a> <var>referrer</var>:</p>

  <ol><li><p>If <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint">reporting endpoint</a>
   is null, return.</p></li><li><p>Let <var>coopValue</var> be <var>coop</var>'s <a href="#coop-struct-value" id="coop-reporting:coop-struct-value">value</a>.</p></li><li><p>If <var>disposition</var> is "<code>reporting</code>", then set
   <var>coopValue</var> to <var>coop</var>'s <a href="#coop-struct-report-only-value" id="coop-reporting:coop-struct-report-only-value">report-only value</a>.</p></li><li><p>Let <var>serializedReferrer</var> be an empty string.</p></li><li><p>If <var>referrer</var> is a <a id="coop-reporting:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, set <var>serializedReferrer</var> to the
   <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="coop-reporting:concept-url-serializer-2" data-x-internal="concept-url-serializer">serialization</a> of <var>referrer</var>.

   </p></li><li>
    <p>Let <var>body</var> be a new object containing the following properties:</p>

    <table class="data"><thead><tr><th>key</th><th>value</th></tr></thead><tbody><tr><td>disposition</td><td><var>disposition</var></td></tr><tr><td>effectivePolicy</td><td><var>coopValue</var></td></tr><tr><td>previousResponseURL</td><td>If <var>coopOrigin</var> and <var>previousResponseOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-3">same origin</a> this is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report">sanitization</a> of <var>previousResponseURL</var>, null otherwise.</td></tr><tr><td>referrer</td><td><var>serializedReferrer</var></td></tr><tr><td>type</td><td>"<code>navigation-to-response</code>"</td></tr></tbody></table>
   </li><li><p><a href="https://w3c.github.io/reporting/#queue-report" id="coop-reporting:queue-a-report" data-x-internal="queue-a-report">Queue</a> <var>body</var> as "<code>coop</code>" for <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-2">reporting endpoint</a> with <var>coopURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="coop-violation-navigation-from">queue a violation report for browsing context
  group switch when navigating away from a COOP response</dfn> given an <a href="#cross-origin-opener-policy" id="coop-reporting:cross-origin-opener-policy-2">opener policy</a> <var>coop</var>, a string <var>disposition</var>, a <a id="coop-reporting:url-5" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>
  <var>coopURL</var>, a <a id="coop-reporting:url-6" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>nextResponseURL</var>, two <a href="#concept-origin" id="coop-reporting:concept-origin-2">origins</a> <var>coopOrigin</var> and <var>nextResponseOrigin</var>, and a
  boolean <var>isCOOPResponseNavigationSource</var>:</p>

  <ol><li><p>If <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-3">reporting endpoint</a>
   is null, return.</p></li><li><p>Let <var>coopValue</var> be <var>coop</var>'s <a href="#coop-struct-value" id="coop-reporting:coop-struct-value-2">value</a>.</p></li><li><p>If <var>disposition</var> is "<code>reporting</code>", then set
   <var>coopValue</var> to <var>coop</var>'s <a href="#coop-struct-report-only-value" id="coop-reporting:coop-struct-report-only-value-2">report-only value</a>.</p></li><li>
    <p>Let <var>body</var> be a new object containing the following properties:</p>

    <table class="data"><thead><tr><th>key</th><th>value</th></tr></thead><tbody><tr><td>disposition</td><td><var>disposition</var></td></tr><tr><td>effectivePolicy</td><td><var>coopValue</var></td></tr><tr><td>nextResponseURL</td><td>If <var>coopOrigin</var> and <var>nextResponseOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-4">same origin</a>
       or <var>isCOOPResponseNavigationSource</var> is true, this is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report-2">sanitization</a> of <var>nextResponseURL</var>, null otherwise.</td></tr><tr><td>type</td><td>"<code>navigation-from-response</code>"</td></tr></tbody></table>
   </li><li><p><a href="https://w3c.github.io/reporting/#queue-report" id="coop-reporting:queue-a-report-2" data-x-internal="queue-a-report">Queue</a> <var>body</var> as "<code>coop</code>" for <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-4">reporting endpoint</a> with <var>coopURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="coop-violation-access">queue violation reports for accesses</dfn>, given an
  <a href="#accessor-accessed-relationship" id="coop-reporting:accessor-accessed-relationship-2">accessor-accessed relationship</a> <var>accessorAccessedRelationship</var>, two <a href="#cross-origin-opener-policy" id="coop-reporting:cross-origin-opener-policy-3">opener policies</a> <var>accessorCOOP</var> and <var>accessedCOOP</var>,
  four <a href="https://url.spec.whatwg.org/#concept-url" id="coop-reporting:url-7" data-x-internal="url">URLs</a> <var>accessorURL</var>, <var>accessedURL</var>,
  <var>accessorInitialURL</var>, <var>accessedInitialURL</var>, four <a href="#concept-origin" id="coop-reporting:concept-origin-3">origins</a> <var>accessorOrigin</var>, <var>accessedOrigin</var>,
  <var>accessorCreatorOrigin</var> and <var>accessedCreatorOrigin</var>, two <a href="#dom-document-referrer" id="coop-reporting:dom-document-referrer-3">referrers</a> <var>accessorReferrer</var> and
  <var>accessedReferrer</var>, a string <var>propertyName</var>, and an <a href="#environment-settings-object" id="coop-reporting:environment-settings-object-2">environment settings
  object</a> <var>environment</var>:</p>

  <ol><li><p>If <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-5">reporting endpoint</a>
   is null, return.</p></li><li><p>Let <var>coopValue</var> be <var>coop</var>'s <a href="#coop-struct-value" id="coop-reporting:coop-struct-value-3">value</a>.</p></li><li><p>If <var>disposition</var> is "<code>reporting</code>", then set
   <var>coopValue</var> to <var>coop</var>'s <a href="#coop-struct-report-only-value" id="coop-reporting:coop-struct-report-only-value-3">report-only value</a>.</p></li><li>
    <p>If <var>accessorAccessedRelationship</var> is <a href="#accessor-accessed-opener" id="coop-reporting:accessor-accessed-opener-2">accessor is opener</a>:</p>

    <ol><li><p><a href="#coop-violation-access-to-opened" id="coop-reporting:coop-violation-access-to-opened">Queue a violation report
     for access to an opened window</a>, given <var>accessorCOOP</var>, <var>accessorURL</var>,
     <var>accessedURL</var>, <var>accessedInitialURL</var>, <var>accessorOrigin</var>,
     <var>accessedOrigin</var>, <var>accessedCreatorOrigin</var>, <var>propertyName</var>,
     and <var>environment</var>.</p></li><li><p><a href="#coop-violation-access-from-opener" id="coop-reporting:coop-violation-access-from-opener">Queue a violation report for access
     from the opener</a>, given <var>accessedCOOP</var>, <var>accessedURL</var>,
     <var>accessorURL</var>, <var>accessedOrigin</var>, <var>accessorOrigin</var>,
     <var>propertyName</var>, and <var>accessedReferrer</var>.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>accessorAccessedRelationship</var> is <a href="#accessor-accessed-openee" id="coop-reporting:accessor-accessed-openee-2">accessor is openee</a>:</p>

    <ol><li><p><a href="#coop-violation-access-to-opener" id="coop-reporting:coop-violation-access-to-opener">Queue a violation report for access to
     the opener</a>, given <var>accessorCOOP</var>, <var>accessorURL</var>,
     <var>accessedURL</var>, <var>accessorOrigin</var>, <var>accessedOrigin</var>,
     <var>propertyName</var>, <var>accessorReferrer</var>, and <var>environment</var>.</p></li><li><p><a href="#coop-violation-access-from-opened" id="coop-reporting:coop-violation-access-from-opened">Queue a violation report for access
     from an opened window</a>, given <var>accessedCOOP</var>, <var>accessedURL</var>,
     <var>accessorURL</var>, <var>accessorInitialURL</var>, <var>accessedOrigin</var>,
     <var>accessorOrigin</var>, <var>accessorCreatorOrigin</var>, and
     <var>propertyName</var>.</p></li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p><a href="#coop-violation-access-to-opened" id="coop-reporting:coop-violation-access-to-opened-2">Queue a violation report for
     access to another window</a>, given <var>accessorCOOP</var>, <var>accessorURL</var>,
     <var>accessedURL</var>, <var>accessorOrigin</var>, <var>accessedOrigin</var>,
     <var>propertyName</var>, and <var>environment</var>.</p></li><li><p><a href="#coop-violation-access-from-other" id="coop-reporting:coop-violation-access-from-other">Queue a violation report for
     access from another window</a>, given <var>accessedCOOP</var>, <var>accessedURL</var>,
     <var>accessorURL</var>, <var>accessedOrigin</var>, <var>accessorOrigin</var>, and
     <var>propertyName</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="coop-violation-access-to-opener">queue a violation report for access to the
  opener</dfn>, given an <a href="#cross-origin-opener-policy" id="coop-reporting:cross-origin-opener-policy-4">opener policy</a> <var>coop</var>, two
  <a href="https://url.spec.whatwg.org/#concept-url" id="coop-reporting:url-8" data-x-internal="url">URLs</a> <var>coopURL</var> and <var>openerURL</var>, two <a href="#concept-origin" id="coop-reporting:concept-origin-4">origins</a> <var>coopOrigin</var> and <var>openerOrigin</var>, a string
  <var>propertyName</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="coop-reporting:concept-request-referrer-2" data-x-internal="concept-request-referrer">referrer</a>
  <var>referrer</var>, and an <a href="#environment-settings-object" id="coop-reporting:environment-settings-object-3">environment settings object</a> <var>environment</var>:</p>

  <ol><li><p>Let <var>sourceFile</var>, <var>lineNumber</var>, and <var>columnNumber</var> be the
   relevant script URL and problematic position which triggered this report.</p></li><li><p>Let <var>serializedReferrer</var> be an empty string.</p></li><li><p>If <var>referrer</var> is a <a id="coop-reporting:url-9" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, set <var>serializedReferrer</var> to the
   <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="coop-reporting:concept-url-serializer-3" data-x-internal="concept-url-serializer">serialization</a> of <var>referrer</var>.

   </p></li><li>
    <p>Let <var>body</var> be a new object containing the following properties:</p>

    <table class="data"><thead><tr><th>key</th><th>value</th></tr></thead><tbody><tr><td>disposition</td><td>"<code>reporting</code>"</td></tr><tr><td>effectivePolicy</td><td><var>coop</var>'s <a href="#coop-struct-report-only-value" id="coop-reporting:coop-struct-report-only-value-4">report-only
       value</a></td></tr><tr><td>property</td><td><var>propertyName</var></td></tr><tr><td>openerURL</td><td>If <var>coopOrigin</var> and <var>openerOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-5">same origin</a>, this
       is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report-3">sanitization</a> of <var>openerURL</var>, null
       otherwise.</td></tr><tr><td>referrer</td><td><var>serializedReferrer</var></td></tr><tr><td>sourceFile</td><td><var>sourceFile</var></td></tr><tr><td>lineNumber</td><td><var>lineNumber</var></td></tr><tr><td>columnNumber</td><td><var>columnNumber</var></td></tr><tr><td>type</td><td>"<code>access-to-opener</code>"</td></tr></tbody></table>
   </li><li><p><a href="https://w3c.github.io/reporting/#queue-report" id="coop-reporting:queue-a-report-3" data-x-internal="queue-a-report">Queue</a> <var>body</var> as "<code>coop</code>" for <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-6">reporting endpoint</a> with <var>coopURL</var> and
   <var>environment</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="coop-violation-access-to-opened">queue a violation report for access to an
  opened window</dfn>, given an <a href="#cross-origin-opener-policy" id="coop-reporting:cross-origin-opener-policy-5">opener policy</a> <var>coop</var>,
  three <a href="https://url.spec.whatwg.org/#concept-url" id="coop-reporting:url-10" data-x-internal="url">URLs</a> <var>coopURL</var>, <var>openedWindowURL</var> and
  <var>initialWindowURL</var>, three <a href="#concept-origin" id="coop-reporting:concept-origin-5">origins</a> <var>coopOrigin</var>,
  <var>openedWindowOrigin</var>, and <var>openerInitialOrigin</var>, a string
  <var>propertyName</var>, and an <a href="#environment-settings-object" id="coop-reporting:environment-settings-object-4">environment settings object</a>
  <var>environment</var>:</p>

  <ol><li><p>Let <var>sourceFile</var>, <var>lineNumber</var>, and <var>columnNumber</var> be the
   relevant script URL and problematic position which triggered this report.</p></li><li>
    <p>Let <var>body</var> be a new object containing the following properties:</p>

    <table class="data"><thead><tr><th>key</th><th>value</th></tr></thead><tbody><tr><td>disposition</td><td>"<code>reporting</code>"</td></tr><tr><td>effectivePolicy</td><td><var>coop</var>'s <a href="#coop-struct-report-only-value" id="coop-reporting:coop-struct-report-only-value-5">report-only
       value</a></td></tr><tr><td>property</td><td><var>propertyName</var></td></tr><tr><td>openedWindowURL</td><td>If <var>coopOrigin</var> and <var>openedWindowOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-6">same origin</a>, this
       is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report-4">sanitization</a> of <var>openedWindowURL</var>,
       null otherwise.</td></tr><tr><td>openedWindowInitialURL</td><td>If <var>coopOrigin</var> and <var>openerInitialOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-7">same origin</a>,
       this is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report-5">sanitization</a> of
       <var>initialWindowURL</var>, null otherwise.</td></tr><tr><td>sourceFile</td><td><var>sourceFile</var></td></tr><tr><td>lineNumber</td><td><var>lineNumber</var></td></tr><tr><td>columnNumber</td><td><var>columnNumber</var></td></tr><tr><td>type</td><td>"<code>access-to-opener</code>"</td></tr></tbody></table>
   </li><li><p><a href="https://w3c.github.io/reporting/#queue-report" id="coop-reporting:queue-a-report-4" data-x-internal="queue-a-report">Queue</a> <var>body</var> as "<code>coop</code>"
   for <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-7">reporting endpoint</a> with
   <var>coopURL</var> and <var>environment</var>.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>To <dfn id="coop-violation-access-to-other">queue a violation report for access to another
  window</dfn>, given an <a href="#cross-origin-opener-policy" id="coop-reporting:cross-origin-opener-policy-6">opener policy</a> <var>coop</var>, two
  <a href="https://url.spec.whatwg.org/#concept-url" id="coop-reporting:url-11" data-x-internal="url">URLs</a> <var>coopURL</var> and <var>otherURL</var>, two <a href="#concept-origin" id="coop-reporting:concept-origin-6">origins</a> <var>coopOrigin</var> and <var>otherOrigin</var>, a string
  <var>propertyName</var>, and an <a href="#environment-settings-object" id="coop-reporting:environment-settings-object-5">environment settings object</a>
  <var>environment</var>:</p>

  <ol><li><p>Let <var>sourceFile</var>, <var>lineNumber</var>, and <var>columnNumber</var> be the
   relevant script URL and problematic position which triggered this report.</p></li><li>
    <p>Let <var>body</var> be a new object containing the following properties:</p>

    <table class="data"><thead><tr><th>key</th><th>value</th></tr></thead><tbody><tr><td>disposition</td><td>"<code>reporting</code>"</td></tr><tr><td>effectivePolicy</td><td><var>coop</var>'s <a href="#coop-struct-report-only-value" id="coop-reporting:coop-struct-report-only-value-6">report-only
       value</a></td></tr><tr><td>property</td><td><var>propertyName</var></td></tr><tr><td>otherURL</td><td>If <var>coopOrigin</var> and <var>otherOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-8">same origin</a>, this
       is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report-6">sanitization</a> of <var>otherURL</var>, null
       otherwise.</td></tr><tr><td>sourceFile</td><td><var>sourceFile</var></td></tr><tr><td>lineNumber</td><td><var>lineNumber</var></td></tr><tr><td>columnNumber</td><td><var>columnNumber</var></td></tr><tr><td>type</td><td>"<code>access-to-opener</code>"</td></tr></tbody></table>
   </li><li><p><a href="https://w3c.github.io/reporting/#queue-report" id="coop-reporting:queue-a-report-5" data-x-internal="queue-a-report">Queue</a> <var>body</var> as "<code>coop</code>"
   for <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-8">reporting endpoint</a> with
   <var>coopURL</var> and <var>environment</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="coop-violation-access-from-opener">queue a violation report for access from the
  opener</dfn>, given an <a href="#cross-origin-opener-policy" id="coop-reporting:cross-origin-opener-policy-7">opener policy</a> <var>coop</var>, two
  <a href="https://url.spec.whatwg.org/#concept-url" id="coop-reporting:url-12" data-x-internal="url">URLs</a> <var>coopURL</var> and <var>openerURL</var>, two <a href="#concept-origin" id="coop-reporting:concept-origin-7">origins</a> <var>coopOrigin</var> and <var>openerOrigin</var>, a string
  <var>propertyName</var>, and a <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="coop-reporting:concept-request-referrer-3" data-x-internal="concept-request-referrer">referrer</a>
  <var>referrer</var>:</p>

  <ol><li><p>If <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-9">reporting endpoint</a>
   is null, return.</p></li><li><p>Let <var>serializedReferrer</var> be an empty string.</p></li><li><p>If <var>referrer</var> is a <a id="coop-reporting:url-13" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, set <var>serializedReferrer</var> to the
   <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="coop-reporting:concept-url-serializer-4" data-x-internal="concept-url-serializer">serialization</a> of <var>referrer</var>.

   </p></li><li>
    <p>Let <var>body</var> be a new object containing the following properties:</p>

    <table class="data"><thead><tr><th>key</th><th>value</th></tr></thead><tbody><tr><td>disposition</td><td>"<code>reporting</code>"</td></tr><tr><td>effectivePolicy</td><td><var>coop</var>'s <a href="#coop-struct-report-only-value" id="coop-reporting:coop-struct-report-only-value-7">report-only
       value</a></td></tr><tr><td>property</td><td><var>propertyName</var></td></tr><tr><td>openerURL</td><td>If <var>coopOrigin</var> and <var>openerOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-9">same origin</a>, this
       is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report-7">sanitization</a> of <var>openerURL</var>, null
       otherwise.</td></tr><tr><td>referrer</td><td><var>serializedReferrer</var></td></tr><tr><td>type</td><td>"<code>access-to-opener</code>"</td></tr></tbody></table>
   </li><li><p><a href="https://w3c.github.io/reporting/#queue-report" id="coop-reporting:queue-a-report-6" data-x-internal="queue-a-report">Queue</a> <var>body</var> as "<code>coop</code>"
   for <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-10">reporting endpoint</a> with
   <var>coopURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="coop-violation-access-from-opened">queue a violation report for access from an
  opened window</dfn>, given an <a href="#cross-origin-opener-policy" id="coop-reporting:cross-origin-opener-policy-8">opener policy</a> <var>coop</var>,
  three <a href="https://url.spec.whatwg.org/#concept-url" id="coop-reporting:url-14" data-x-internal="url">URLs</a> <var>coopURL</var>, <var>openedWindowURL</var> and
  <var>initialWindowURL</var>, three <a href="#concept-origin" id="coop-reporting:concept-origin-8">origins</a> <var>coopOrigin</var>,
  <var>openedWindowOrigin</var>, and <var>openerInitialOrigin</var>, and a string
  <var>propertyName</var>:</p>

  <ol><li><p>If <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-11">reporting endpoint</a>
   is null, return.</p></li><li>
    <p>Let <var>body</var> be a new object containing the following properties:</p>

    <table class="data"><thead><tr><th>key</th><th>value</th></tr></thead><tbody><tr><td>disposition</td><td>"<code>reporting</code>"</td></tr><tr><td>effectivePolicy</td><td><var>coopValue</var></td></tr><tr><td>property</td><td><var>coop</var>'s <a href="#coop-struct-report-only-value" id="coop-reporting:coop-struct-report-only-value-8">report-only
       value</a></td></tr><tr><td>openedWindowURL</td><td>If <var>coopOrigin</var> and <var>openedWindowOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-10">same origin</a>, this
       is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report-8">sanitization</a> of <var>openedWindowURL</var>,
       null otherwise.</td></tr><tr><td>openedWindowInitialURL</td><td>If <var>coopOrigin</var> and <var>openerInitialOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-11">same origin</a>,
       this is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report-9">sanitization</a> of
       <var>initialWindowURL</var>, null otherwise.</td></tr><tr><td>type</td><td>"<code>access-to-opener</code>"</td></tr></tbody></table>
   </li><li><p><a href="https://w3c.github.io/reporting/#queue-report" id="coop-reporting:queue-a-report-7" data-x-internal="queue-a-report">Queue</a> <var>body</var> as "<code>coop</code>"
   for <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-12">reporting endpoint</a> with
   <var>coopURL</var>.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>To <dfn id="coop-violation-access-from-other">queue a violation report for access from
  another window</dfn>, given an <a href="#cross-origin-opener-policy" id="coop-reporting:cross-origin-opener-policy-9">opener policy</a> <var>coop</var>,
  two <a href="https://url.spec.whatwg.org/#concept-url" id="coop-reporting:url-15" data-x-internal="url">URLs</a> <var>coopURL</var> and <var>otherURL</var>, two <a href="#concept-origin" id="coop-reporting:concept-origin-9">origins</a> <var>coopOrigin</var> and <var>otherOrigin</var>, and a string
  <var>propertyName</var>:</p>

  <ol><li><p>If <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-13">reporting endpoint</a>
   is null, return.</p></li><li>
    <p>Let <var>body</var> be a new object containing the following properties:</p>

    <table class="data"><thead><tr><th>key</th><th>value</th></tr></thead><tbody><tr><td>disposition</td><td>"<code>reporting</code>"</td></tr><tr><td>effectivePolicy</td><td><var>coop</var>'s <a href="#coop-struct-report-only-value" id="coop-reporting:coop-struct-report-only-value-9">report-only
       value</a></td></tr><tr><td>property</td><td><var>propertyName</var></td></tr><tr><td>otherURL</td><td>If <var>coopOrigin</var> and <var>otherOrigin</var> are <a href="#same-origin" id="coop-reporting:same-origin-12">same origin</a>, this
       is the <a href="#sanitize-url-report" id="coop-reporting:sanitize-url-report-10">sanitization</a> of <var>otherURL</var>, null
       otherwise.</td></tr><tr><td>type</td><td><code>access-to-opener</code></td></tr></tbody></table>
   </li><li><p><a href="https://w3c.github.io/reporting/#queue-report" id="coop-reporting:queue-a-report-8" data-x-internal="queue-a-report">Queue</a> <var>body</var> as "<code>coop</code>"
   for <var>coop</var>'s <a href="#coop-struct-report-endpoint" id="coop-reporting:coop-struct-report-endpoint-14">reporting endpoint</a> with
   <var>coopURL</var>.</p></li></ol>
  </div>

  


  <h4 id="coep"><span class="secno">7.1.4</span> Cross-origin embedder policies<a href="#coep" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy" title="The HTTP Cross-Origin-Embedder-Policy (COEP) response header configures embedding cross-origin resources into the document.">Headers/Cross-Origin-Embedder-Policy</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>79+</span></span><span class="safari yes"><span>Safari</span><span>15.2+</span></span><span class="chrome yes"><span>Chrome</span><span>83+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>83+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>86+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>An <dfn id="embedder-policy-value" data-export="">embedder policy value</dfn> is one of three strings that controls the fetching
  of cross-origin resources without explicit permission from resource owners.</p>

  <dl><dt>"<dfn data-dfn-for="embedder policy value" id="coep-unsafe-none" data-export=""><code>unsafe-none</code></dfn>"</dt><dd><p>This is the default value. When this value is used, cross-origin resources can be fetched
   without giving explicit permission through the <a id="coep:cors-protocol" href="https://fetch.spec.whatwg.org/#http-cors-protocol" data-x-internal="cors-protocol">CORS protocol</a> or the
   `<code id="coep:cross-origin-resource-policy"><a data-x-internal="cross-origin-resource-policy" href="https://fetch.spec.whatwg.org/#http-cross-origin-resource-policy">Cross-Origin-Resource-Policy</a></code>` header.</p></dd><dt>"<dfn data-dfn-for="embedder policy value" id="coep-require-corp" data-export=""><code>require-corp</code></dfn>"</dt><dd><p>When this value is used, fetching cross-origin resources requires the server's
   explicit permission through the <a id="coep:cors-protocol-2" href="https://fetch.spec.whatwg.org/#http-cors-protocol" data-x-internal="cors-protocol">CORS protocol</a> or the
   `<code id="coep:cross-origin-resource-policy-2"><a data-x-internal="cross-origin-resource-policy" href="https://fetch.spec.whatwg.org/#http-cross-origin-resource-policy">Cross-Origin-Resource-Policy</a></code>` header.</p></dd><dt>"<dfn data-dfn-for="embedder policy value" id="coep-credentialless" data-export=""><code>credentialless</code></dfn>"</dt><dd><p>When this value is used, fetching cross-origin no-CORS resources omits credentials. In
   exchange, an explicit `<code id="coep:cross-origin-resource-policy-3"><a data-x-internal="cross-origin-resource-policy" href="https://fetch.spec.whatwg.org/#http-cross-origin-resource-policy">Cross-Origin-Resource-Policy</a></code>` header is not required. Other
   requests sent with credentials require the server's explicit permission through the <a id="coep:cors-protocol-3" href="https://fetch.spec.whatwg.org/#http-cors-protocol" data-x-internal="cors-protocol">CORS
   protocol</a> or the `<code id="coep:cross-origin-resource-policy-4"><a data-x-internal="cross-origin-resource-policy" href="https://fetch.spec.whatwg.org/#http-cross-origin-resource-policy">Cross-Origin-Resource-Policy</a></code>` header.</p></dd></dl>

  <div class="warning">
   <p>Before supporting "<code id="coep:coep-credentialless"><a href="#coep-credentialless">credentialless</a></code>", implementers are
   strongly encouraged to support both:

   </p><ul class="brief"><li><a href="https://wicg.github.io/private-network-access/">Private Network Access</a></li><li><a href="https://github.com/annevk/orb">Opaque Response Blocking</a></li></ul>

   <p>Otherwise, it would allow attackers to leverage the client's network position to read non
   public resources, using the <a href="#concept-settings-object-cross-origin-isolated-capability" id="coep:concept-settings-object-cross-origin-isolated-capability">cross-origin isolated
   capability</a>.</p>
  </div>

  <div data-algorithm="">
  <p>An <a href="#embedder-policy-value" id="coep:embedder-policy-value">embedder policy value</a> is <dfn id="compatible-with-cross-origin-isolation">compatible with cross-origin isolation</dfn> if
  it is "<code id="coep:coep-credentialless-2"><a href="#coep-credentialless">credentialless</a></code>" or "<code id="coep:coep-require-corp"><a href="#coep-require-corp">require-corp</a></code>".</p>
  </div>

  

  <p>An <dfn id="embedder-policy" data-export="">embedder policy</dfn> consists of:</p>

  <ul><li><p>A <dfn data-dfn-for="embedder policy" id="embedder-policy-value-2" data-export="">value</dfn>, which is an <a href="#embedder-policy-value" id="coep:embedder-policy-value-2">embedder policy value</a>, initially "<code id="coep:coep-unsafe-none"><a href="#coep-unsafe-none">unsafe-none</a></code>".</p></li><li><p>A <dfn data-dfn-for="embedder policy" id="embedder-policy-reporting-endpoint" data-export="">reporting endpoint</dfn> string, initially the empty string.</p></li><li><p>A <dfn data-dfn-for="embedder policy" id="embedder-policy-report-only-value" data-export="">report only value</dfn>, which is an <a href="#embedder-policy-value" id="coep:embedder-policy-value-3">embedder policy value</a>, initially
   "<code id="coep:coep-unsafe-none-2"><a href="#coep-unsafe-none">unsafe-none</a></code>".</p></li><li><p>A <dfn data-dfn-for="embedder
   policy" id="embedder-policy-report-only-reporting-endpoint" data-export="">report only reporting endpoint</dfn> string, initially the empty
   string.</p></li></ul>

  <p>The <dfn id="coep-report-type" data-export="">"<code>coep</code>" report type</dfn> is a <a id="coep:report-type" href="https://w3c.github.io/reporting/#report-type" data-x-internal="report-type">report type</a> whose value
  is "<code>coep</code>". It is <a id="coep:visible-to-reportingobservers" href="https://w3c.github.io/reporting/#visible-to-reportingobservers" data-x-internal="visible-to-reportingobservers">visible to
  <code>ReportingObserver</code>s</a>.</p>

  


  <h5 id="the-coep-headers"><span class="secno">7.1.4.1</span> The headers<a href="#the-coep-headers" class="self-link"></a></h5>

  <p>The `<dfn id="cross-origin-embedder-policy" data-dfn-type="http-header"><code>Cross-Origin-Embedder-Policy</code></dfn>` and
  `<dfn id="cross-origin-embedder-policy-report-only" data-dfn-type="http-header"><code>Cross-Origin-Embedder-Policy-Report-Only</code></dfn>` HTTP response
  headers allow a server to declare an <a href="#embedder-policy" id="the-coep-headers:embedder-policy">embedder policy</a> for an <a href="#environment-settings-object" id="the-coep-headers:environment-settings-object">environment
  settings object</a>. These headers are <a href="https://httpwg.org/specs/rfc8941.html" id="the-coep-headers:http-structured-header" data-x-internal="http-structured-header">structured
  headers</a> whose values must be <a href="https://httpwg.org/specs/rfc8941.html#token" id="the-coep-headers:http-structured-header-token" data-x-internal="http-structured-header-token">token</a>.
  <a href="#refsSTRUCTURED-FIELDS">[STRUCTURED-FIELDS]</a>

  </p><p>The valid <a href="https://httpwg.org/specs/rfc8941.html#token" id="the-coep-headers:http-structured-header-token-2" data-x-internal="http-structured-header-token">token</a> values are the <a href="#embedder-policy-value" id="the-coep-headers:embedder-policy-value">embedder policy values</a>. The token may also have attached <a href="https://httpwg.org/specs/rfc8941.html#param" id="the-coep-headers:http-structured-header-parameters" data-x-internal="http-structured-header-parameters">parameters</a>; of these, the "<dfn id="coep-report-to"><code>report-to</code></dfn>" parameter can have a <a id="the-coep-headers:valid-url-string" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL
  string</a> identifying an appropriate reporting endpoint. <a href="#refsREPORTING">[REPORTING]</a></p>

  <div class="note">
   <p>The <a href="#obtain-an-embedder-policy" id="the-coep-headers:obtain-an-embedder-policy">processing model</a> fails open (by defaulting
   to "<code id="the-coep-headers:coep-unsafe-none"><a href="#coep-unsafe-none">unsafe-none</a></code>") in the presence of a header that cannot
   be parsed as a token. This includes inadvertent lists created by combining multiple instances of
   the `<code id="the-coep-headers:cross-origin-embedder-policy"><a href="#cross-origin-embedder-policy">Cross-Origin-Embedder-Policy</a></code>` header present in a given response:</p>

   <table class="data"><thead><tr><th>`<code id="the-coep-headers:cross-origin-embedder-policy-2"><a href="#cross-origin-embedder-policy">Cross-Origin-Embedder-Policy</a></code>`</th><th>Final <a href="#embedder-policy-value" id="the-coep-headers:embedder-policy-value-2">embedder policy value</a></th></tr></thead><tbody><tr><td><em>No header delivered</em></td><td>"<code id="the-coep-headers:coep-unsafe-none-2"><a href="#coep-unsafe-none">unsafe-none</a></code>"</td></tr><tr><td>`<code>require-corp</code>`</td><td>"<code id="the-coep-headers:coep-require-corp"><a href="#coep-require-corp">require-corp</a></code>"</td></tr><tr><td>`<code>unknown-value</code>`</td><td>"<code id="the-coep-headers:coep-unsafe-none-3"><a href="#coep-unsafe-none">unsafe-none</a></code>"</td></tr><tr><td>`<code>require-corp, unknown-value</code>`</td><td>"<code id="the-coep-headers:coep-unsafe-none-4"><a href="#coep-unsafe-none">unsafe-none</a></code>"</td></tr><tr><td>`<code>unknown-value, unknown-value</code>`</td><td>"<code id="the-coep-headers:coep-unsafe-none-5"><a href="#coep-unsafe-none">unsafe-none</a></code>"</td></tr><tr><td>`<code>unknown-value, require-corp</code>`</td><td>"<code id="the-coep-headers:coep-unsafe-none-6"><a href="#coep-unsafe-none">unsafe-none</a></code>"</td></tr><tr><td>`<code>require-corp, require-corp</code>`</td><td>"<code id="the-coep-headers:coep-unsafe-none-7"><a href="#coep-unsafe-none">unsafe-none</a></code>"</td></tr></tbody></table>

   <p>(The same applies to `<code id="the-coep-headers:cross-origin-embedder-policy-report-only"><a href="#cross-origin-embedder-policy-report-only">Cross-Origin-Embedder-Policy-Report-Only</a></code>`.)</p>
  </div>

  

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="obtain-an-embedder-policy" data-export="">obtain an embedder policy</dfn> from a <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-coep-headers:concept-response" data-x-internal="concept-response">response</a> <var>response</var> and an <a href="#environment" id="the-coep-headers:environment">environment</a>
  <var>environment</var>:</p>

  <ol><li><p>Let <var>policy</var> be a new <a href="#embedder-policy" id="the-coep-headers:embedder-policy-2">embedder policy</a>.</p></li><li><p>If <var>environment</var> is a <a href="#non-secure-context" id="the-coep-headers:non-secure-context">non-secure context</a>, then return
   <var>policy</var>.</p></li><li><p>Let <var>parsedItem</var> be the result of <a id="the-coep-headers:getting-a-structured-field-value" href="https://fetch.spec.whatwg.org/#concept-header-list-get-structured-header" data-x-internal="getting-a-structured-field-value">getting a structured field value</a>
   with `<code id="the-coep-headers:cross-origin-embedder-policy-3"><a href="#cross-origin-embedder-policy">Cross-Origin-Embedder-Policy</a></code>` and "<code>item</code>" from
   <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="the-coep-headers:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a>.</p></li><li>
    <p>If <var>parsedItem</var> is non-null and <var>parsedItem</var>[0] is <a href="#compatible-with-cross-origin-isolation" id="the-coep-headers:compatible-with-cross-origin-isolation">compatible with
    cross-origin isolation</a>:</p>

    <ol><li><p>Set <var>policy</var>'s <a href="#embedder-policy-value-2" id="the-coep-headers:embedder-policy-value-2-2">value</a> to
     <var>parsedItem</var>[0].</p></li><li><p>If <var>parsedItem</var>[1]["<code id="the-coep-headers:coep-report-to"><a href="#coep-report-to">report-to</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-coep-headers:map-exists" data-x-internal="map-exists">exists</a>, then set <var>policy</var>'s <a href="#embedder-policy-reporting-endpoint" id="the-coep-headers:embedder-policy-reporting-endpoint">endpoint</a> to
     <var>parsedItem</var>[1]["<code id="the-coep-headers:coep-report-to-2"><a href="#coep-report-to">report-to</a></code>"].</p></li></ol>
   </li><li><p>Set <var>parsedItem</var> to the result of <a id="the-coep-headers:getting-a-structured-field-value-2" href="https://fetch.spec.whatwg.org/#concept-header-list-get-structured-header" data-x-internal="getting-a-structured-field-value">getting a structured field value</a>
   with `<code id="the-coep-headers:cross-origin-embedder-policy-report-only-2"><a href="#cross-origin-embedder-policy-report-only">Cross-Origin-Embedder-Policy-Report-Only</a></code>` and "<code>item</code>"
   from <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="the-coep-headers:concept-response-header-list-2" data-x-internal="concept-response-header-list">header
   list</a>.</p></li><li>
    <p>If <var>parsedItem</var> is non-null and <var>parsedItem</var>[0] is <a href="#compatible-with-cross-origin-isolation" id="the-coep-headers:compatible-with-cross-origin-isolation-2">compatible with
    cross-origin isolation</a>:</p>

    <ol><li><p>Set <var>policy</var>'s <a href="#embedder-policy-report-only-value" id="the-coep-headers:embedder-policy-report-only-value">report only value</a> to
     <var>parsedItem</var>[0].</p></li><li><p>If <var>parsedItem</var>[1]["<code id="the-coep-headers:coep-report-to-3"><a href="#coep-report-to">report-to</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-coep-headers:map-exists-2" data-x-internal="map-exists">exists</a>, then set <var>policy</var>'s <a href="#embedder-policy-report-only-reporting-endpoint" id="the-coep-headers:embedder-policy-report-only-reporting-endpoint">endpoint</a> to
     <var>parsedItem</var>[1]["<code id="the-coep-headers:coep-report-to-4"><a href="#coep-report-to">report-to</a></code>"].</p></li></ol>
   </li><li><p>Return <var>policy</var>.</p></li></ol>
  </div>


  <h5 id="embedder-policy-checks"><span class="secno">7.1.4.2</span> Embedder policy checks<a href="#embedder-policy-checks" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="check-a-navigation-response's-adherence-to-its-embedder-policy">check a navigation response's adherence to its embedder policy</dfn> given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="embedder-policy-checks:concept-response" data-x-internal="concept-response">response</a> <var>response</var>, a <a href="#navigable" id="embedder-policy-checks:navigable">navigable</a>
  <var>navigable</var>, and an <a href="#embedder-policy" id="embedder-policy-checks:embedder-policy">embedder policy</a> <var>responsePolicy</var>:</p>

  <ol><li><p>If <var>navigable</var> is not a <a href="#child-navigable" id="embedder-policy-checks:child-navigable">child navigable</a>, then return
   true.</p></li><li><p>Let <var>parentPolicy</var> be <var>navigable</var>'s <a href="#nav-container-document" id="embedder-policy-checks:nav-container-document">container document</a>'s <a href="#concept-document-policy-container" id="embedder-policy-checks:concept-document-policy-container">policy container</a>'s <a href="#policy-container-embedder-policy" id="embedder-policy-checks:policy-container-embedder-policy">embedder policy</a>.</p></li><li><p>If <var>parentPolicy</var>'s <a href="#embedder-policy-report-only-value" id="embedder-policy-checks:embedder-policy-report-only-value">report-only
   value</a> is <a href="#compatible-with-cross-origin-isolation" id="embedder-policy-checks:compatible-with-cross-origin-isolation">compatible with cross-origin isolation</a> and
   <var>responsePolicy</var>'s <a href="#embedder-policy-value-2" id="embedder-policy-checks:embedder-policy-value-2">value</a> is not, then
   <a href="#queue-a-cross-origin-embedder-policy-inheritance-violation" id="embedder-policy-checks:queue-a-cross-origin-embedder-policy-inheritance-violation">queue a cross-origin embedder policy inheritance violation</a> with <var>response</var>,
   "<code>navigation</code>", <var>parentPolicy</var>'s <a href="#embedder-policy-report-only-reporting-endpoint" id="embedder-policy-checks:embedder-policy-report-only-reporting-endpoint">report only reporting endpoint</a>,
   "<code>reporting</code>", and <var>navigable</var>'s <a href="#nav-container-document" id="embedder-policy-checks:nav-container-document-2">container document</a>'s <a href="#relevant-settings-object" id="embedder-policy-checks:relevant-settings-object">relevant settings
   object</a>.</p></li><li><p>If <var>parentPolicy</var>'s <a href="#embedder-policy-value-2" id="embedder-policy-checks:embedder-policy-value-2-2">value</a> is not
   <a href="#compatible-with-cross-origin-isolation" id="embedder-policy-checks:compatible-with-cross-origin-isolation-2">compatible with cross-origin isolation</a> or <var>responsePolicy</var>'s <a href="#embedder-policy-value-2" id="embedder-policy-checks:embedder-policy-value-2-3">value</a> is <a href="#compatible-with-cross-origin-isolation" id="embedder-policy-checks:compatible-with-cross-origin-isolation-3">compatible with cross-origin
   isolation</a>, then return true.</p></li><li><p><a href="#queue-a-cross-origin-embedder-policy-inheritance-violation" id="embedder-policy-checks:queue-a-cross-origin-embedder-policy-inheritance-violation-2">Queue a cross-origin embedder policy inheritance violation</a> with
   <var>response</var>, "<code>navigation</code>", <var>parentPolicy</var>'s <a href="#embedder-policy-reporting-endpoint" id="embedder-policy-checks:embedder-policy-reporting-endpoint">reporting endpoint</a>,
   "<code>enforce</code>", and <var>navigable</var>'s
   <a href="#nav-container-document" id="embedder-policy-checks:nav-container-document-3">container document</a>'s <a href="#relevant-settings-object" id="embedder-policy-checks:relevant-settings-object-2">relevant settings
   object</a>.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="check-a-global-object's-embedder-policy">check a global object's embedder policy</dfn> given a <code id="embedder-policy-checks:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code>
  <var>workerGlobalScope</var>, an <a href="#environment-settings-object" id="embedder-policy-checks:environment-settings-object">environment settings object</a> <var>owner</var>, and
  a <a href="https://fetch.spec.whatwg.org/#concept-response" id="embedder-policy-checks:concept-response-2" data-x-internal="concept-response">response</a> <var>response</var>:</p>

  <ol><li><p>If <var>workerGlobalScope</var> is not a <code id="embedder-policy-checks:dedicatedworkerglobalscope"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> object,
   then return true.</p></li><li><p>Let <var>policy</var> be <var>workerGlobalScope</var>'s <a href="#concept-workerglobalscope-embedder-policy" id="embedder-policy-checks:concept-workerglobalscope-embedder-policy">embedder policy</a>.

   </p></li><li><p>Let <var>ownerPolicy</var> be <var>owner</var>'s <a href="#concept-settings-object-policy-container" id="embedder-policy-checks:concept-settings-object-policy-container">policy container</a>'s <a href="#policy-container-embedder-policy" id="embedder-policy-checks:policy-container-embedder-policy-2">embedder policy</a>.

   </p></li><li><p>If <var>ownerPolicy</var>'s <a href="#embedder-policy-report-only-value" id="embedder-policy-checks:embedder-policy-report-only-value-2">report-only
   value</a> is <a href="#compatible-with-cross-origin-isolation" id="embedder-policy-checks:compatible-with-cross-origin-isolation-4">compatible with cross-origin isolation</a> and <var>policy</var>'s
   <a href="#embedder-policy-value-2" id="embedder-policy-checks:embedder-policy-value-2-4">value</a> is not, then <a href="#queue-a-cross-origin-embedder-policy-inheritance-violation" id="embedder-policy-checks:queue-a-cross-origin-embedder-policy-inheritance-violation-3">queue a cross-origin
   embedder policy inheritance violation</a> with <var>response</var>, "<code>worker
   initialization</code>", <var>ownerPolicy</var>'s <a href="#embedder-policy-report-only-reporting-endpoint" id="embedder-policy-checks:embedder-policy-report-only-reporting-endpoint-2">report only reporting endpoint</a>,
   "<code>reporting</code>", and <var>owner</var>.</p></li><li><p>If <var>ownerPolicy</var>'s <a href="#embedder-policy-value-2" id="embedder-policy-checks:embedder-policy-value-2-5">value</a> is not
   <a href="#compatible-with-cross-origin-isolation" id="embedder-policy-checks:compatible-with-cross-origin-isolation-5">compatible with cross-origin isolation</a> or <var>policy</var>'s <a href="#embedder-policy-value-2" id="embedder-policy-checks:embedder-policy-value-2-6">value</a> is <a href="#compatible-with-cross-origin-isolation" id="embedder-policy-checks:compatible-with-cross-origin-isolation-6">compatible with cross-origin
   isolation</a>, then return true.</p></li><li><p><a href="#queue-a-cross-origin-embedder-policy-inheritance-violation" id="embedder-policy-checks:queue-a-cross-origin-embedder-policy-inheritance-violation-4">Queue a cross-origin embedder policy inheritance violation</a> with
   <var>response</var>, "<code>worker initialization</code>", <var>ownerPolicy</var>'s
   <a href="#embedder-policy-reporting-endpoint" id="embedder-policy-checks:embedder-policy-reporting-endpoint-2">reporting endpoint</a>,
   "<code>enforce</code>", and <var>owner</var>.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="queue-a-cross-origin-embedder-policy-inheritance-violation">queue a cross-origin embedder policy inheritance violation</dfn> given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="embedder-policy-checks:concept-response-3" data-x-internal="concept-response">response</a> <var>response</var>, a string <var>type</var>, a string
  <var>endpoint</var>, a string <var>disposition</var>, and an <a href="#environment-settings-object" id="embedder-policy-checks:environment-settings-object-2">environment settings
  object</a> <var>settings</var>:</p>

  <ol><li><p>Let <var>serialized</var> be the result of <a href="https://fetch.spec.whatwg.org/#serialize-a-response-url-for-reporting" id="embedder-policy-checks:serialize-a-response-url-for-reporting" data-x-internal="serialize-a-response-url-for-reporting">serializing a response URL for
   reporting</a> with <var>response</var>.</p></li><li>
    <p>Let <var>body</var> be a new object containing the following properties:</p>

    <table class="data"><thead><tr><th>key</th><th>value</th></tr></thead><tbody><tr><td>type</td><td><var>type</var></td></tr><tr><td>blockedURL</td><td><var>serialized</var></td></tr><tr><td>disposition</td><td><var>disposition</var></td></tr></tbody></table>
   </li><li><p><a href="https://w3c.github.io/reporting/#queue-report" id="embedder-policy-checks:queue-a-report" data-x-internal="queue-a-report">Queue</a> <var>body</var> as the
   <a href="#coep-report-type" id="embedder-policy-checks:coep-report-type">"<code>coep</code>" report type</a> for <var>endpoint</var> on <var>settings</var>.
  </p></li></ol>
  </div>

  


  <h4 id="sandboxing"><span class="secno">7.1.5</span> Sandboxing<a href="#sandboxing" class="self-link"></a></h4>

  <p>A <dfn id="sandboxing-flag-set" data-export="">sandboxing flag set</dfn> is a set of zero or more of the following flags, which
  are used to restrict the abilities that potentially untrusted resources have:</p>

  <dl><dt>The <dfn id="sandboxed-navigation-browsing-context-flag" data-export="">sandboxed navigation browsing context flag</dfn></dt><dd>
    <p>This flag <a href="#sandboxLinks">prevents content from navigating browsing contexts other
    than the sandboxed browsing context itself</a> (or browsing contexts further nested inside it),
    <a href="#auxiliary-browsing-context" id="sandboxing:auxiliary-browsing-context">auxiliary browsing contexts</a> (which are protected
    by the <a href="#sandboxed-auxiliary-navigation-browsing-context-flag" id="sandboxing:sandboxed-auxiliary-navigation-browsing-context-flag">sandboxed auxiliary navigation browsing context flag</a> defined next), and the
    <a href="#top-level-browsing-context" id="sandboxing:top-level-browsing-context">top-level browsing context</a> (which is protected by the <a href="#sandboxed-top-level-navigation-without-user-activation-browsing-context-flag" id="sandboxing:sandboxed-top-level-navigation-without-user-activation-browsing-context-flag">sandboxed top-level
    navigation without user activation browsing context flag</a> and <a href="#sandboxed-top-level-navigation-with-user-activation-browsing-context-flag" id="sandboxing:sandboxed-top-level-navigation-with-user-activation-browsing-context-flag">sandboxed top-level
    navigation with user activation browsing context flag</a> defined below).</p>

    <p>If the <a href="#sandboxed-auxiliary-navigation-browsing-context-flag" id="sandboxing:sandboxed-auxiliary-navigation-browsing-context-flag-2">sandboxed auxiliary navigation browsing context flag</a> is not set, then in
    certain cases the restrictions nonetheless allow popups (new <a href="#top-level-browsing-context" id="sandboxing:top-level-browsing-context-2">top-level browsing contexts</a>) to be opened. These <a href="#browsing-context" id="sandboxing:browsing-context">browsing contexts</a> always have <dfn id="one-permitted-sandboxed-navigator">one permitted sandboxed navigator</dfn>, set
    when the browsing context is created, which allows the <a href="#browsing-context" id="sandboxing:browsing-context-2">browsing context</a> that
    created them to actually navigate them. (Otherwise, the <a href="#sandboxed-navigation-browsing-context-flag" id="sandboxing:sandboxed-navigation-browsing-context-flag">sandboxed navigation browsing
    context flag</a> would prevent them from being navigated even if they were opened.)</p>
   </dd><dt>The <dfn id="sandboxed-auxiliary-navigation-browsing-context-flag" data-export="">sandboxed auxiliary navigation browsing context flag</dfn></dt><dd>
    <p>This flag <a href="#sandboxWindowOpen">prevents content from creating new auxiliary browsing
    contexts</a>, e.g. using the <code id="sandboxing:attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code> attribute or
    the <code id="sandboxing:dom-open"><a href="#dom-open">window.open()</a></code> method.</p>
   </dd><dt>The <dfn id="sandboxed-top-level-navigation-without-user-activation-browsing-context-flag" data-export="">sandboxed top-level navigation without user activation browsing
   context flag</dfn></dt><dd>
    <p>This flag <a href="#sandboxLinks">prevents content from navigating their <span>top-level
    browsing context</span></a> and <a href="#sandboxClose">prevents content from closing their
    <span>top-level browsing context</span></a>. It is consulted only when the sandboxed browsing
    context's <a href="#active-window" id="sandboxing:active-window">active window</a> does not have <a href="#transient-activation" id="sandboxing:transient-activation">transient activation</a>.</p>

    <p>When the <a href="#sandboxed-top-level-navigation-without-user-activation-browsing-context-flag" id="sandboxing:sandboxed-top-level-navigation-without-user-activation-browsing-context-flag-2">sandboxed top-level navigation without user activation browsing context
    flag</a> is <em>not</em> set, content can navigate its <a href="#top-level-browsing-context" id="sandboxing:top-level-browsing-context-3">top-level browsing
    context</a>, but other <a href="#browsing-context" id="sandboxing:browsing-context-3">browsing contexts</a> are still
    protected by the <a href="#sandboxed-navigation-browsing-context-flag" id="sandboxing:sandboxed-navigation-browsing-context-flag-2">sandboxed navigation browsing context flag</a> and possibly
    the <a href="#sandboxed-auxiliary-navigation-browsing-context-flag" id="sandboxing:sandboxed-auxiliary-navigation-browsing-context-flag-3">sandboxed auxiliary navigation browsing context flag</a>.</p>
   </dd><dt>The <dfn id="sandboxed-top-level-navigation-with-user-activation-browsing-context-flag" data-export="">sandboxed top-level navigation with user activation browsing context
   flag</dfn></dt><dd>
    <p>This flag <a href="#sandboxLinks">prevents content from navigating their <span>top-level
    browsing context</span></a> and <a href="#sandboxClose">prevents content from closing their
    <span>top-level browsing context</span></a>. It is consulted only when the sandboxed browsing
    context's <a href="#active-window" id="sandboxing:active-window-2">active window</a> has <a href="#transient-activation" id="sandboxing:transient-activation-2">transient activation</a>.</p>

    <p>As with the <a href="#sandboxed-top-level-navigation-without-user-activation-browsing-context-flag" id="sandboxing:sandboxed-top-level-navigation-without-user-activation-browsing-context-flag-3">sandboxed top-level navigation without user activation browsing context
    flag</a>, this flag only affects the <a href="#top-level-browsing-context" id="sandboxing:top-level-browsing-context-4">top-level browsing context</a>; if it is not
    set, other <a href="#browsing-context" id="sandboxing:browsing-context-4">browsing contexts</a> might still be protected by
    other flags.</p>
   </dd><dt>The <dfn id="sandboxed-origin-browsing-context-flag" data-export="">sandboxed origin browsing context flag</dfn></dt><dd>
    <p>This flag <a href="#sandboxOrigin">forces content into an opaque origin</a>, thus preventing
    it from accessing other content from the same <a href="#concept-origin" id="sandboxing:concept-origin">origin</a>.</p>

    <p>This flag also <a href="#sandboxCookies">prevents script from reading from or writing to the
    <code>document.cookie</code> IDL attribute</a>, and blocks access
    to <code id="sandboxing:dom-localstorage"><a href="#dom-localstorage">localStorage</a></code>.</p>
   </dd><dt>The <dfn id="sandboxed-forms-browsing-context-flag" data-export="">sandboxed forms browsing context flag</dfn></dt><dd>
    <p>This flag <a href="#sandboxSubmitBlocked">blocks form submission</a>.</p>
   </dd><dt>The <dfn id="sandboxed-pointer-lock-browsing-context-flag" data-export="">sandboxed pointer lock browsing context flag</dfn></dt><dd>
    <p>This flag disables the Pointer Lock API. <a href="#refsPOINTERLOCK">[POINTERLOCK]</a></p>
   </dd><dt>The <dfn id="sandboxed-scripts-browsing-context-flag" data-export="">sandboxed scripts browsing context flag</dfn></dt><dd>
    <p>This flag <a href="#sandboxScriptBlocked">blocks script execution</a>.</p>
   </dd><dt>The <dfn id="sandboxed-automatic-features-browsing-context-flag" data-export="">sandboxed automatic features browsing context flag</dfn></dt><dd>
    <p>This flag blocks features that trigger automatically, such as <a href="#attr-media-autoplay" id="sandboxing:attr-media-autoplay">automatically playing a video</a> or <a href="#attr-fe-autofocus" id="sandboxing:attr-fe-autofocus">automatically focusing a form control</a>.</p>
   </dd><dt>The <dfn id="sandboxed-document.domain-browsing-context-flag" data-export="">sandboxed <code>document.domain</code>
   browsing context flag</dfn></dt><dd>
    <p>This flag prevents content from using the
    <code id="sandboxing:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code> setter.</p>
   </dd><dt>The <dfn id="sandbox-propagates-to-auxiliary-browsing-contexts-flag" data-export="">sandbox propagates to auxiliary browsing contexts flag</dfn></dt><dd>
    <p>This flag prevents content from escaping the sandbox by ensuring that any
    <a href="#auxiliary-browsing-context" id="sandboxing:auxiliary-browsing-context-2">auxiliary browsing context</a> it creates inherits the content's
    <a href="#active-sandboxing-flag-set" id="sandboxing:active-sandboxing-flag-set">active sandboxing flag set</a>.</p>
   </dd><dt>The <dfn id="sandboxed-modals-flag" data-export="">sandboxed modals flag</dfn></dt><dd>
    <p>This flag prevents content from using any of the following features to produce modal
    dialogs:</p>

    <ul><li><code id="sandboxing:dom-alert"><a href="#dom-alert">window.alert()</a></code></li><li><code id="sandboxing:dom-confirm"><a href="#dom-confirm">window.confirm()</a></code></li><li><code id="sandboxing:dom-print"><a href="#dom-print">window.print()</a></code></li><li><code id="sandboxing:dom-prompt"><a href="#dom-prompt">window.prompt()</a></code></li><li>the <code id="sandboxing:event-beforeunload"><a href="#event-beforeunload">beforeunload</a></code> event</li></ul>
   </dd><dt>The <dfn id="sandboxed-orientation-lock-browsing-context-flag" data-export="">sandboxed orientation lock browsing context flag</dfn></dt><dd>
    <p>This flag disables the ability to lock the screen orientation.
    <a href="#refsSCREENORIENTATION">[SCREENORIENTATION]</a></p>
   </dd><dt>The <dfn id="sandboxed-presentation-browsing-context-flag" data-export="">sandboxed presentation browsing context flag</dfn></dt><dd>
    <p>This flag disables the Presentation API. <a href="#refsPRESENTATION">[PRESENTATION]</a></p>
   </dd><dt>The <dfn id="sandboxed-downloads-browsing-context-flag" data-export="">sandboxed downloads browsing context flag</dfn></dt><dd>
    <p>This flag prevents content from initiating or instantiating downloads, whether through <a href="#downloading-hyperlinks" id="sandboxing:downloading-hyperlinks">downloading hyperlinks</a> or through <a href="#navigation-as-a-download">navigation</a> that gets <a href="#handle-as-a-download" id="sandboxing:handle-as-a-download">handled as a download</a>.</p>
   </dd><dt>The <dfn id="sandboxed-custom-protocols-navigation-browsing-context-flag" data-export="">sandboxed custom protocols navigation browsing context flag</dfn></dt><dd>
    <p>This flag prevents navigations toward non <a href="https://fetch.spec.whatwg.org/#fetch-scheme" id="sandboxing:fetch-scheme" data-x-internal="fetch-scheme">fetch schemes</a>
    from being <a href="#hand-off-to-external-software" id="sandboxing:hand-off-to-external-software">handed off to external
    software</a>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>When the user agent is to <dfn id="parse-a-sandboxing-directive" data-export="">parse a sandboxing directive</dfn>, given a string
  <var>input</var> and a <a href="#sandboxing-flag-set" id="sandboxing:sandboxing-flag-set">sandboxing flag set</a> <var>output</var>, it must run the following
  steps:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#split-on-ascii-whitespace" id="sandboxing:split-a-string-on-spaces" data-x-internal="split-a-string-on-spaces">Split <var>input</var> on ASCII
   whitespace</a>, to obtain <var>tokens</var>.</p></li><li><p>Let <var>output</var> be empty.</p></li><li>
    <p>Add the following flags to <var>output</var>:</p>

    <ul><li><p>The <a href="#sandboxed-navigation-browsing-context-flag" id="sandboxing:sandboxed-navigation-browsing-context-flag-3">sandboxed navigation browsing context flag</a>.</p></li><li><p>The <a href="#sandboxed-auxiliary-navigation-browsing-context-flag" id="sandboxing:sandboxed-auxiliary-navigation-browsing-context-flag-4">sandboxed auxiliary navigation browsing context flag</a>, unless
     <var>tokens</var> contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-popups" data-dfn-type="attr-value"><code>allow-popups</code></dfn> keyword.</p></li><li><p>The <a href="#sandboxed-top-level-navigation-without-user-activation-browsing-context-flag" id="sandboxing:sandboxed-top-level-navigation-without-user-activation-browsing-context-flag-4">sandboxed top-level navigation without user activation browsing context
     flag</a>, unless <var>tokens</var> contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-top-navigation" data-dfn-type="attr-value"><code>allow-top-navigation</code></dfn>
     keyword.</p></li><li>
      <p>The <a href="#sandboxed-top-level-navigation-with-user-activation-browsing-context-flag" id="sandboxing:sandboxed-top-level-navigation-with-user-activation-browsing-context-flag-2">sandboxed top-level navigation with user activation browsing context flag</a>,
      unless <var>tokens</var> contains either the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-top-navigation-by-user-activation" data-dfn-type="attr-value"><code>allow-top-navigation-by-user-activation</code></dfn>
      keyword or the <code id="sandboxing:attr-iframe-sandbox-allow-top-navigation"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code> keyword.</p>

      <p class="note">This means that if the <code id="sandboxing:attr-iframe-sandbox-allow-top-navigation-2"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code> is present, the <code id="sandboxing:attr-iframe-sandbox-allow-top-navigation-by-user-activation"><a href="#attr-iframe-sandbox-allow-top-navigation-by-user-activation">allow-top-navigation-by-user-activation</a></code>
      keyword will have no effect. For this reason, specifying both is a document conformance error.</p>
     </li><li>
      <p>The <a href="#sandboxed-origin-browsing-context-flag" id="sandboxing:sandboxed-origin-browsing-context-flag">sandboxed origin browsing context flag</a>, unless the <var>tokens</var>
      contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-same-origin" data-dfn-type="attr-value"><code>allow-same-origin</code></dfn> keyword.</p>

      <div class="note">
       <p>The <code id="sandboxing:attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code> keyword
       is intended for two cases.</p>

       <p>First, it can be used to allow content from the same site to be sandboxed to disable
       scripting, while still allowing access to the DOM of the sandboxed content.</p>

       <p>Second, it can be used to embed content from a third-party site, sandboxed to prevent that
       site from opening popups, etc, without preventing the embedded page from communicating back
       to its originating site, using the database APIs to store data, etc.</p>
      </div>
     </li><li><p>The <a href="#sandboxed-forms-browsing-context-flag" id="sandboxing:sandboxed-forms-browsing-context-flag">sandboxed forms browsing context flag</a>, unless <var>tokens</var>
     contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-forms" data-dfn-type="attr-value"><code>allow-forms</code></dfn> keyword.</p></li><li><p>The <a href="#sandboxed-pointer-lock-browsing-context-flag" id="sandboxing:sandboxed-pointer-lock-browsing-context-flag">sandboxed pointer lock browsing context flag</a>, unless <var>tokens</var>
     contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-pointer-lock" data-dfn-type="attr-value"><code>allow-pointer-lock</code></dfn>
     keyword.</p></li><li><p>The <a href="#sandboxed-scripts-browsing-context-flag" id="sandboxing:sandboxed-scripts-browsing-context-flag">sandboxed scripts browsing context flag</a>, unless <var>tokens</var>
     contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-scripts" data-dfn-type="attr-value"><code>allow-scripts</code></dfn> keyword.</p></li><li>
      <p>The <a href="#sandboxed-automatic-features-browsing-context-flag" id="sandboxing:sandboxed-automatic-features-browsing-context-flag">sandboxed automatic features browsing context flag</a>, unless
      <var>tokens</var> contains the <code id="sandboxing:attr-iframe-sandbox-allow-scripts"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code> keyword (defined above).</p>

      <p class="note">This flag is relaxed by the same keyword as scripts, because when scripts are
      enabled these features are trivially possible anyway, and it would be unfortunate to force
      authors to use script to do them when sandboxed rather than allowing them to use the
      declarative features.</p>
     </li><li><p>The <a href="#sandboxed-document.domain-browsing-context-flag" id="sandboxing:sandboxed-document.domain-browsing-context-flag">sandboxed <code>document.domain</code> browsing
     context flag</a>.</p></li><li><p>The <a href="#sandbox-propagates-to-auxiliary-browsing-contexts-flag" id="sandboxing:sandbox-propagates-to-auxiliary-browsing-contexts-flag">sandbox propagates to auxiliary browsing contexts flag</a>, unless
     <var>tokens</var> contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-popups-to-escape-sandbox" data-dfn-type="attr-value"><code>allow-popups-to-escape-sandbox</code></dfn>
     keyword.</p></li><li><p>The <a href="#sandboxed-modals-flag" id="sandboxing:sandboxed-modals-flag">sandboxed modals flag</a>, unless <var>tokens</var> contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-modals" data-dfn-type="attr-value"><code>allow-modals</code></dfn> keyword.</p></li><li><p>The <a href="#sandboxed-orientation-lock-browsing-context-flag" id="sandboxing:sandboxed-orientation-lock-browsing-context-flag">sandboxed orientation lock browsing context flag</a>, unless
     <var>tokens</var> contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-orientation-lock" data-dfn-type="attr-value"><code>allow-orientation-lock</code></dfn>
     keyword.</p></li><li><p>The <a href="#sandboxed-presentation-browsing-context-flag" id="sandboxing:sandboxed-presentation-browsing-context-flag">sandboxed presentation browsing context flag</a>, unless <var>tokens</var>
     contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-presentation" data-dfn-type="attr-value"><code>allow-presentation</code></dfn>
     keyword.</p></li><li><p>The <a href="#sandboxed-downloads-browsing-context-flag" id="sandboxing:sandboxed-downloads-browsing-context-flag">sandboxed downloads browsing context flag</a>, unless <var>tokens</var>
     contains the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-downloads" data-dfn-type="attr-value"><code>allow-downloads</code></dfn> keyword.</p></li><li><p>The <a href="#sandboxed-custom-protocols-navigation-browsing-context-flag" id="sandboxing:sandboxed-custom-protocols-navigation-browsing-context-flag">sandboxed custom protocols navigation browsing context flag</a>, unless
     <var>tokens</var> contains either the <dfn data-dfn-for="iframe/sandbox" id="attr-iframe-sandbox-allow-top-navigation-to-custom-protocols" data-dfn-type="attr-value"><code>allow-top-navigation-to-custom-protocols</code></dfn>
     keyword, the <code id="sandboxing:attr-iframe-sandbox-allow-popups"><a href="#attr-iframe-sandbox-allow-popups">allow-popups</a></code> keyword, or
     the <code id="sandboxing:attr-iframe-sandbox-allow-top-navigation-3"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code>
     keyword.</p></li></ul>
   </li></ol>
  </div>

  <hr>

  <p>Every <a href="#top-level-browsing-context" id="sandboxing:top-level-browsing-context-5">top-level browsing context</a> has a <dfn id="popup-sandboxing-flag-set">popup sandboxing flag set</dfn>, which
  is a <a href="#sandboxing-flag-set" id="sandboxing:sandboxing-flag-set-2">sandboxing flag set</a>. When a <a href="#browsing-context" id="sandboxing:browsing-context-5">browsing context</a> is created, its
  <a href="#popup-sandboxing-flag-set" id="sandboxing:popup-sandboxing-flag-set">popup sandboxing flag set</a> must be empty. It is populated by <a href="#the-rules-for-choosing-a-navigable" id="sandboxing:the-rules-for-choosing-a-navigable">the rules for
  choosing a navigable</a> and the <a href="#obtain-browsing-context-navigation" id="sandboxing:obtain-browsing-context-navigation">obtain
  a browsing context to use for a navigation response</a> algorithm.</p>

  <p>Every <code id="sandboxing:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element has an <dfn id="iframe-sandboxing-flag-set"><code>iframe</code> sandboxing flag set</dfn>,
  which is a <a href="#sandboxing-flag-set" id="sandboxing:sandboxing-flag-set-3">sandboxing flag set</a>. Which flags in an <a href="#iframe-sandboxing-flag-set" id="sandboxing:iframe-sandboxing-flag-set"><code>iframe</code>
  sandboxing flag set</a> are set at any particular time is determined by the <code id="sandboxing:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>
  element's <code id="sandboxing:attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute.</p>

  <p>Every <code id="sandboxing:document"><a href="#document">Document</a></code> has an <dfn data-dfn-for="Document" id="active-sandboxing-flag-set" data-export="">active sandboxing flag set</dfn>,
  which is a <a href="#sandboxing-flag-set" id="sandboxing:sandboxing-flag-set-4">sandboxing flag set</a>. When the <code id="sandboxing:document-2"><a href="#document">Document</a></code> is created, its
  <a href="#active-sandboxing-flag-set" id="sandboxing:active-sandboxing-flag-set-2">active sandboxing flag set</a> must be empty. It is populated by the <a href="#navigate" id="sandboxing:navigate">navigation algorithm</a>.</p>

  <div data-algorithm="">
  <p id="forced-sandboxing-flag-set">Every <a href="https://w3c.github.io/webappsec-csp/#csp-list" id="sandboxing:concept-csp-list" data-x-internal="concept-csp-list">CSP list</a>
  <var>cspList</var> has <dfn id="csp-derived-sandboxing-flags">CSP-derived sandboxing flags</dfn>, which is a <a href="#sandboxing-flag-set" id="sandboxing:sandboxing-flag-set-5">sandboxing flag
  set</a>. It is the return value of the following algorithm:</p>

  <ol><li><p>Let <var>directives</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-set" id="sandboxing:set" data-x-internal="set">ordered set</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="sandboxing:list-iterate" data-x-internal="list-iterate">For each</a> policy in <var>cspList</var>:</p>

    <ol><li><p>If <var>policy</var>'s <a href="https://w3c.github.io/webappsec-csp/#policy-disposition" id="sandboxing:csp-disposition" data-x-internal="csp-disposition">disposition</a> is not "<code>enforce</code>", then <a id="sandboxing:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>policy</var>'s <a href="https://w3c.github.io/webappsec-csp/#policy-directive-set" id="sandboxing:csp-directive-set" data-x-internal="csp-directive-set">directive set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="sandboxing:list-contains" data-x-internal="list-contains">contains</a> a <a href="https://w3c.github.io/webappsec-csp/#directives" id="sandboxing:content-security-policy-directive" data-x-internal="content-security-policy-directive">directive</a> whose name is "<code id="sandboxing:sandbox-directive"><a data-x-internal="sandbox-directive" href="https://w3c.github.io/webappsec-csp/#sandbox">sandbox</a></code>",
     then <a href="https://infra.spec.whatwg.org/#list-append" id="sandboxing:list-append" data-x-internal="list-append">append</a> that directive to
     <var>directives</var>.</p></li></ol>
   </li><li><p>If <var>directives</var> is empty, then return an empty <a href="#sandboxing-flag-set" id="sandboxing:sandboxing-flag-set-6">sandboxing flag
   set</a>.</p></li><li><p>Let <var>directive</var> be <var>directives</var>[<var>directives</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="sandboxing:list-size" data-x-internal="list-size">size</a> − 1].</p></li><li><p>Return the result of <a href="#parse-a-sandboxing-directive" id="sandboxing:parse-a-sandboxing-directive">parsing the sandboxing
   directive</a> <var>directive</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="determining-the-creation-sandboxing-flags">determine the creation sandboxing
  flags</dfn> for a <a href="#concept-document-bc" id="sandboxing:concept-document-bc">browsing context</a> <var>browsing
  context</var>, given null or an element <var>embedder</var>, return the <a href="https://infra.spec.whatwg.org/#set-union" id="sandboxing:set-union" data-x-internal="set-union">union</a> of the flags that are present in the following <a href="#sandboxing-flag-set" id="sandboxing:sandboxing-flag-set-7">sandboxing flag sets</a>:</p>

  <ul><li><p>If <var>embedder</var> is null, then: the flags set on <var>browsing context</var>'s
   <a href="#popup-sandboxing-flag-set" id="sandboxing:popup-sandboxing-flag-set-2">popup sandboxing flag set</a>.</p></li><li><p>If <var>embedder</var> is an element, then: the flags set on <var>embedder</var>'s
   <a href="#iframe-sandboxing-flag-set" id="sandboxing:iframe-sandboxing-flag-set-2"><code>iframe</code> sandboxing flag set</a>.</p></li><li><p>If <var>embedder</var> is an element, then: the flags set on <var>embedder</var>'s
   <a id="sandboxing:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#active-sandboxing-flag-set" id="sandboxing:active-sandboxing-flag-set-3">active sandboxing flag set</a>.</p></li></ul>
  </div>


  <h4 id="policy-containers"><span class="secno">7.1.6</span> Policy containers<a href="#policy-containers" class="self-link"></a></h4>

  <p>A <dfn id="policy-container" data-export="">policy container</dfn> is a <a id="policy-containers:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> containing policies that apply to
  a <code id="policy-containers:document"><a href="#document">Document</a></code>, a <code id="policy-containers:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code>, or a <code id="policy-containers:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>.
  It has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="policy-containers:struct-item" data-x-internal="struct-item">items</a>:</p>

  

  <ul><li><p>A <dfn data-dfn-for="policy container" id="policy-container-csp-list" data-export="">CSP list</dfn>,
   which is a <a href="https://w3c.github.io/webappsec-csp/#csp-list" id="policy-containers:concept-csp-list" data-x-internal="concept-csp-list">CSP list</a>. It is initially empty.</p></li><li><p>An <dfn data-dfn-for="policy container" id="policy-container-embedder-policy" data-export="">embedder
   policy</dfn>, which is an <a href="#embedder-policy" id="policy-containers:embedder-policy">embedder policy</a>. It is initially a new <a href="#embedder-policy" id="policy-containers:embedder-policy-2">embedder
   policy</a>.</p></li><li><p>A <dfn data-dfn-for="policy container" id="policy-container-referrer-policy" data-export="">referrer
   policy</dfn>, which is a <a id="policy-containers:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>. It is initially the <a id="policy-containers:default-referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#default-referrer-policy" data-x-internal="default-referrer-policy">default referrer
   policy</a>.</p></li><li><p>An <dfn data-dfn-for="policy container" id="policy-container-integrity-policy" data-export="">integrity
   policy</dfn>, which is an <a href="https://w3c.github.io/webappsec-subresource-integrity/#integrity-policy" id="policy-containers:integrity-policy" data-x-internal="integrity-policy">integrity policy</a>, initially a new
   <a href="https://w3c.github.io/webappsec-subresource-integrity/#integrity-policy" id="policy-containers:integrity-policy-2" data-x-internal="integrity-policy">integrity policy</a>.</p></li><li><p>A <dfn data-dfn-for="policy container" id="policy-container-report-only-integrity-policy" data-export="">report only integrity policy</dfn>, which
   is an <a href="https://w3c.github.io/webappsec-subresource-integrity/#integrity-policy" id="policy-containers:integrity-policy-3" data-x-internal="integrity-policy">integrity policy</a>, initially a new <a href="https://w3c.github.io/webappsec-subresource-integrity/#integrity-policy" id="policy-containers:integrity-policy-4" data-x-internal="integrity-policy">integrity policy</a>.</p></li></ul>

  <p class="XXX">Move other policies into the policy container.</p>

  <div data-algorithm="">
  <p>To <dfn id="clone-a-policy-container" data-export="">clone a policy container</dfn> given a <a href="#policy-container" id="policy-containers:policy-container">policy container</a>
  <var>policyContainer</var>:</p>

  <ol><li><p>Let <var>clone</var> be a new <a href="#policy-container" id="policy-containers:policy-container-2">policy container</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="policy-containers:list-iterate" data-x-internal="list-iterate">For each</a> <var>policy</var> in
   <var>policyContainer</var>'s <a href="#policy-container-csp-list" id="policy-containers:policy-container-csp-list">CSP list</a>, <a href="https://infra.spec.whatwg.org/#list-append" id="policy-containers:list-append" data-x-internal="list-append">append</a> a copy of <var>policy</var> into <var>clone</var>'s <a href="#policy-container-csp-list" id="policy-containers:policy-container-csp-list-2">CSP list</a>.</p></li><li><p>Set <var>clone</var>'s <a href="#policy-container-embedder-policy" id="policy-containers:policy-container-embedder-policy">embedder
   policy</a> to a copy of <var>policyContainer</var>'s <a href="#policy-container-embedder-policy" id="policy-containers:policy-container-embedder-policy-2">embedder policy</a>.</p></li><li><p>Set <var>clone</var>'s <a href="#policy-container-referrer-policy" id="policy-containers:policy-container-referrer-policy">referrer
   policy</a> to <var>policyContainer</var>'s <a href="#policy-container-referrer-policy" id="policy-containers:policy-container-referrer-policy-2">referrer policy</a>.</p></li><li><p>Set <var>clone</var>'s <a href="#policy-container-integrity-policy" id="policy-containers:policy-container-integrity-policy">integrity
   policy</a> to a copy of <var>policyContainer</var>'s <a href="#policy-container-integrity-policy" id="policy-containers:policy-container-integrity-policy-2">integrity policy</a>.</p></li><li><p>Return <var>clone</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To determine whether a <a id="policy-containers:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var> <dfn id="requires-storing-the-policy-container-in-history">requires storing the policy
  container in history</dfn>:</p>

  <ol><li><p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="policy-containers:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is "<code>blob</code>", then return false.</p></li><li><p>If <var>url</var> <a href="https://fetch.spec.whatwg.org/#is-local" id="policy-containers:is-local" data-x-internal="is-local">is local</a>, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-policy-container-from-a-fetch-response" data-lt="creating a policy container from a fetch response" data-export="">create a policy container from a fetch response</dfn>
  given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="policy-containers:concept-response" data-x-internal="concept-response">response</a> <var>response</var> and an
  <a href="#environment" id="policy-containers:environment">environment</a>-or-null <var>environment</var>:</p>

  <ol><li><p>If <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="policy-containers:concept-response-url" data-x-internal="concept-response-url">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="policy-containers:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a> is "<code>blob</code>", then return a <a href="#clone-a-policy-container" id="policy-containers:clone-a-policy-container">clone</a> of <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="policy-containers:concept-response-url-2" data-x-internal="concept-response-url">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-blob-entry" id="policy-containers:concept-url-blob-entry" data-x-internal="concept-url-blob-entry">blob URL
   entry</a>'s <a href="https://w3c.github.io/FileAPI/#blob-url-entry-environment" id="policy-containers:blob-url-entry-environment" data-x-internal="blob-url-entry-environment">environment</a>'s <a href="#policy-container" id="policy-containers:policy-container-3">policy
   container</a>.</p></li><li><p>Let <var>result</var> be a new <a href="#policy-container" id="policy-containers:policy-container-4">policy container</a>.</p></li><li><p>Set <var>result</var>'s <a href="#policy-container-csp-list" id="policy-containers:policy-container-csp-list-3">CSP list</a> to the
   result of <a href="https://w3c.github.io/webappsec-csp/#parse-response-csp" id="policy-containers:parse-response-csp" data-x-internal="parse-response-csp">parsing a response's Content Security Policies</a>
   given <var>response</var>.</p></li><li><p>If <var>environment</var> is non-null, then set <var>result</var>'s <a href="#policy-container-embedder-policy" id="policy-containers:policy-container-embedder-policy-3">embedder policy</a> to the result of <a href="#obtain-an-embedder-policy" id="policy-containers:obtain-an-embedder-policy">obtaining an embedder policy</a> given <var>response</var>
   and <var>environment</var>. Otherwise, set it to "<code id="policy-containers:coep-unsafe-none"><a href="#coep-unsafe-none">unsafe-none</a></code>".</p></li><li><p>Set <var>result</var>'s <a href="#policy-container-referrer-policy" id="policy-containers:policy-container-referrer-policy-3">referrer
   policy</a> to the result of <a href="https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header" id="policy-containers:parse-referrer-policy-header" data-x-internal="parse-referrer-policy-header">parsing the
   `<code>Referrer-Policy</code>` header</a> given <var>response</var>.
   <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p></li><li><p><a href="https://w3c.github.io/webappsec-subresource-integrity/#parse-integrity-policy-headers" id="policy-containers:parse-integrity-policy-headers" data-x-internal="parse-integrity-policy-headers">Parse Integrity-Policy headers</a> with
   <var>response</var> and <var>result</var>.</p></li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="determining-navigation-params-policy-container">determine navigation params
  policy container</dfn> given a <a id="policy-containers:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>responseURL</var> and four <a href="#policy-container" id="policy-containers:policy-container-5">policy container</a>-or-nulls <var>historyPolicyContainer</var>,
  <var>initiatorPolicyContainer</var>, <var>parentPolicyContainer</var>, and
  <var>responsePolicyContainer</var>:</p>

  <ol><li>
    <p>If <var>historyPolicyContainer</var> is not null, then:</p>

    <ol><li><p><a id="policy-containers:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>responseURL</var> <a href="#requires-storing-the-policy-container-in-history" id="policy-containers:requires-storing-the-policy-container-in-history">requires storing the policy container
     in history</a>.</p></li><li><p>Return a <a href="#clone-a-policy-container" id="policy-containers:clone-a-policy-container-2">clone</a> of
     <var>historyPolicyContainer</var>.</p></li></ol>
   </li><li>
    <p>If <var>responseURL</var> is <code id="policy-containers:about:srcdoc"><a href="#about:srcdoc">about:srcdoc</a></code>, then:</p>

    <ol><li><p><a id="policy-containers:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>parentPolicyContainer</var> is not null.</p></li><li><p>Return a <a href="#clone-a-policy-container" id="policy-containers:clone-a-policy-container-3">clone</a> of
     <var>parentPolicyContainer</var>.</p></li></ol>
   </li><li><p>If <var>responseURL</var> <a href="https://fetch.spec.whatwg.org/#is-local" id="policy-containers:is-local-2" data-x-internal="is-local">is local</a> and
   <var>initiatorPolicyContainer</var> is not null, then return a <a href="#clone-a-policy-container" id="policy-containers:clone-a-policy-container-4">clone</a> of <var>initiatorPolicyContainer</var>.</p></li><li><p>If <var>responsePolicyContainer</var> is not null, then return
   <var>responsePolicyContainer</var>.</p></li><li><p>Return a new <a href="#policy-container" id="policy-containers:policy-container-6">policy container</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="initialize-worker-policy-container">initialize a worker global scope's policy
  container</dfn> given a <code id="policy-containers:workerglobalscope-2"><a href="#workerglobalscope">WorkerGlobalScope</a></code> <var>workerGlobalScope</var>, a <a href="https://fetch.spec.whatwg.org/#concept-response" id="policy-containers:concept-response-2" data-x-internal="concept-response">response</a> <var>response</var>, and an <a href="#environment" id="policy-containers:environment-2">environment</a>
  <var>environment</var>:</p>

  <ol><li>
    <p>If <var>workerGlobalScope</var>'s <a href="#concept-workerglobalscope-url" id="policy-containers:concept-workerglobalscope-url">url</a>
    <a href="https://fetch.spec.whatwg.org/#is-local" id="policy-containers:is-local-3" data-x-internal="is-local">is local</a> but its <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="policy-containers:concept-url-scheme-3" data-x-internal="concept-url-scheme">scheme</a>
    is not "<code>blob</code>":</p>

    <ol><li><p><a id="policy-containers:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>workerGlobalScope</var>'s <a href="#concept-WorkerGlobalScope-owner-set" id="policy-containers:concept-WorkerGlobalScope-owner-set">owner set</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="policy-containers:list-size" data-x-internal="list-size">size</a> is 1.</p></li><li><p>Set <var>workerGlobalScope</var>'s <a href="#concept-workerglobalscope-policy-container" id="policy-containers:concept-workerglobalscope-policy-container">policy container</a> to a <a href="#clone-a-policy-container" id="policy-containers:clone-a-policy-container-5">clone</a> of <var>workerGlobalScope</var>'s <a href="#concept-WorkerGlobalScope-owner-set" id="policy-containers:concept-WorkerGlobalScope-owner-set-2">owner
     set</a>[0]'s <a href="#relevant-settings-object" id="policy-containers:relevant-settings-object">relevant settings object</a>'s <a href="#concept-settings-object-policy-container" id="policy-containers:concept-settings-object-policy-container">policy container</a>.</p></li></ol>
   </li><li><p>Otherwise, set <var>workerGlobalScope</var>'s <a href="#concept-workerglobalscope-policy-container" id="policy-containers:concept-workerglobalscope-policy-container-2">policy container</a> to the result of
   <a href="#creating-a-policy-container-from-a-fetch-response" id="policy-containers:creating-a-policy-container-from-a-fetch-response">creating a policy container from a fetch response</a> given
   <var>response</var> and <var>environment</var>.</p></li></ol>
  </div>

  


  <h3 id="nav-traversal-apis"><span class="secno">7.2</span> APIs related to navigation and
  session history<a href="#nav-traversal-apis" class="self-link"></a></h3>

  

  <h4 id="cross-origin-objects"><span class="secno">7.2.1</span> Security infrastructure for <code id="cross-origin-objects:window"><a href="#window">Window</a></code>,
  <code id="cross-origin-objects:windowproxy"><a href="#windowproxy">WindowProxy</a></code>, and <code id="cross-origin-objects:location"><a href="#location">Location</a></code> objects<a href="#cross-origin-objects" class="self-link"></a></h4>

  <p>Although typically objects cannot be accessed across <a href="#concept-origin" id="cross-origin-objects:concept-origin">origins</a>, the
  web platform would not be true to itself if it did not have some legacy exceptions to that rule
  that the web depends upon.</p>

  <p>This section uses the terminology and typographic conventions from the JavaScript
  specification. <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>


  <h5 id="integration-with-idl"><span class="secno">7.2.1.1</span> Integration with IDL<a href="#integration-with-idl" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>When <a id="integration-with-idl:perform-a-security-check" href="https://webidl.spec.whatwg.org/#dfn-perform-a-security-check" data-x-internal="perform-a-security-check">perform a security check</a> is invoked, with a <var>platformObject</var>,
  <var>identifier</var>, and <var>type</var>, run these steps:</p>

  <ol><li><p>If <var>platformObject</var> is not a <code id="integration-with-idl:window"><a href="#window">Window</a></code> or <code id="integration-with-idl:location"><a href="#location">Location</a></code> object,
   then return.</p></li><li>
    <p>For each <var>e</var> of <a href="#crossoriginproperties-(-o-)" id="integration-with-idl:crossoriginproperties-(-o-)">CrossOriginProperties</a>(<var>platformObject</var>):</p>

    <ol><li>
      <p>If <a id="integration-with-idl:samevalue" href="https://tc39.es/ecma262/#sec-samevalue" data-x-internal="samevalue">SameValue</a>(<var>e</var>.[[Property]], <var>identifier</var>) is true,
      then:</p>

      <ol><li><p>If <var>type</var> is "<code>method</code>" and <var>e</var> has neither
       [[NeedsGet]] nor [[NeedsSet]], then return.</p></li><li><p>Otherwise, if <var>type</var> is "<code>getter</code>" and
       <var>e</var>.[[NeedsGet]] is true, then return.</p></li><li><p>Otherwise, if <var>type</var> is "<code>setter</code>" and
       <var>e</var>.[[NeedsSet]] is true, then return.</p></li></ol>
     </li></ol>
   </li><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="integration-with-idl:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<var>platformObject</var>) is false, then
   throw a <a id="integration-with-idl:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="integration-with-idl:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
  </div>


  <h5 id="shared-internal-slot:-crossoriginpropertydescriptormap"><span class="secno">7.2.1.2</span> Shared internal slot: [[CrossOriginPropertyDescriptorMap]]<a href="#shared-internal-slot:-crossoriginpropertydescriptormap" class="self-link"></a></h5>

  <p><code id="shared-internal-slot:-crossoriginpropertydescriptormap:window"><a href="#window">Window</a></code> and <code id="shared-internal-slot:-crossoriginpropertydescriptormap:location"><a href="#location">Location</a></code> objects both have a
  <dfn id="crossoriginpropertydescriptormap">[[CrossOriginPropertyDescriptorMap]]</dfn> internal slot, whose value is initially an empty
  map.</p>

  <div data-algorithm="">
  <p>The <a href="#crossoriginpropertydescriptormap" id="shared-internal-slot:-crossoriginpropertydescriptormap:crossoriginpropertydescriptormap">[[CrossOriginPropertyDescriptorMap]]</a> internal slot contains a map
  with entries whose keys are (<var>currentGlobal</var>, <var>objectGlobal</var>,
  <var>propertyKey</var>)-tuples and values are property descriptors, as a memoization of what is
  visible to scripts when <var>currentGlobal</var> inspects a <code id="shared-internal-slot:-crossoriginpropertydescriptormap:window-2"><a href="#window">Window</a></code> or
  <code id="shared-internal-slot:-crossoriginpropertydescriptormap:location-2"><a href="#location">Location</a></code> object from <var>objectGlobal</var>. It is filled lazily by
  <a href="#crossorigingetownpropertyhelper-(-o,-p-)" id="shared-internal-slot:-crossoriginpropertydescriptormap:crossorigingetownpropertyhelper-(-o,-p-)">CrossOriginGetOwnPropertyHelper</a>, which consults it on future lookups.</p>
  </div>

  <p>User agents should allow a value held in the map to be garbage collected along with its
  corresponding key when nothing holds a reference to any part of the value. That is, as long as
  garbage collection is not observable.</p>

  <p class="example">For example, with <code>const href =
  Object.getOwnPropertyDescriptor(crossOriginLocation, "href").set</code> the value and its
  corresponding key in the map cannot be garbage collected as that would be observable.</p>

  <p>User agents may have an optimization whereby they remove key-value pairs from the map when
  <code id="shared-internal-slot:-crossoriginpropertydescriptormap:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code> is set. This is not observable as <code id="shared-internal-slot:-crossoriginpropertydescriptormap:dom-document-domain-2"><a href="#dom-document-domain">document.domain</a></code> cannot revisit an earlier value.</p>

  <p class="example">For example, setting <code id="shared-internal-slot:-crossoriginpropertydescriptormap:dom-document-domain-3"><a href="#dom-document-domain">document.domain</a></code>
  to "<code>example.com</code>" on www.example.com means user agents can remove all
  key-value pairs from the map where part of the key is www.example.com, as that can never be part
  of the <a href="#concept-origin" id="shared-internal-slot:-crossoriginpropertydescriptormap:concept-origin">origin</a> again and therefore the corresponding value could never be retrieved
  from the map.</p>


  <h5 id="shared-abstract-operations"><span class="secno">7.2.1.3</span> Shared abstract operations<a href="#shared-abstract-operations" class="self-link"></a></h5>

  <div data-algorithm="">
  <h6 id="crossoriginproperties-(-o-)"><span class="secno">7.2.1.3.1</span> <dfn>CrossOriginProperties</dfn> ( <var>O</var> )<a href="#crossoriginproperties-(-o-)" class="self-link"></a></h6>

  <ol><li><p><a id="crossoriginproperties-(-o-):assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>O</var> is a <code id="crossoriginproperties-(-o-):location"><a href="#location">Location</a></code> or <code id="crossoriginproperties-(-o-):window"><a href="#window">Window</a></code>
   object.</p></li><li><p>If <var>O</var> is a <code id="crossoriginproperties-(-o-):location-2"><a href="#location">Location</a></code> object, then return «
   { [[Property]]: "<code>href</code>", [[NeedsGet]]: false, [[NeedsSet]]: true },
   { [[Property]]: "<code>replace</code>" } ».</p></li><li><p>Return «
   { [[Property]]: "<code>window</code>", [[NeedsGet]]: true, [[NeedsSet]]: false },
   { [[Property]]: "<code>self</code>", [[NeedsGet]]: true, [[NeedsSet]]: false },
   { [[Property]]: "<code>location</code>", [[NeedsGet]]: true, [[NeedsSet]]: true },
   { [[Property]]: "<code>close</code>" },
   { [[Property]]: "<code>closed</code>", [[NeedsGet]]: true, [[NeedsSet]]: false },
   { [[Property]]: "<code>focus</code>" },
   { [[Property]]: "<code>blur</code>" },
   { [[Property]]: "<code>frames</code>", [[NeedsGet]]: true, [[NeedsSet]]: false },
   { [[Property]]: "<code>length</code>", [[NeedsGet]]: true, [[NeedsSet]]: false },
   { [[Property]]: "<code>top</code>", [[NeedsGet]]: true, [[NeedsSet]]: false },
   { [[Property]]: "<code>opener</code>", [[NeedsGet]]: true, [[NeedsSet]]: false },
   { [[Property]]: "<code>parent</code>", [[NeedsGet]]: true, [[NeedsSet]]: false },
   { [[Property]]: "<code>postMessage</code>" } ».</p></li></ol>
  </div>

  <p class="note">This abstract operation does not return a <a id="crossoriginproperties-(-o-):completion-record" href="https://tc39.es/ecma262/#sec-completion-record-specification-type" data-x-internal="completion-record">Completion Record</a>.</p>

  <p class="note">Indexed properties do not need to be safelisted in this algorithm, as they are
  handled directly by the <code id="crossoriginproperties-(-o-):windowproxy"><a href="#windowproxy">WindowProxy</a></code> object.</p>

  <div data-algorithm="">
  <p>A JavaScript property name <var>P</var> is a <dfn id="cross-origin-accessible-window-property-name">cross-origin accessible window property
  name</dfn> if it is "<code>window</code>", "<code>self</code>", "<code>location</code>", "<code>close</code>", "<code>closed</code>",
  "<code>focus</code>", "<code>blur</code>", "<code>frames</code>",
  "<code>length</code>", "<code>top</code>", "<code>opener</code>",
  "<code>parent</code>", "<code>postMessage</code>", or an <a id="crossoriginproperties-(-o-):array-index-property-name" href="https://webidl.spec.whatwg.org/#dfn-array-index-property-name" data-x-internal="array-index-property-name">array index
  property name</a>.</p>
  </div>

  <div data-algorithm="">
  <h6 id="crossoriginpropertyfallback-(-p-)"><span class="secno">7.2.1.3.2</span> <dfn>CrossOriginPropertyFallback</dfn> ( <var>P</var> )<a href="#crossoriginpropertyfallback-(-p-)" class="self-link"></a></h6>

  <ol><li><p>If <var>P</var> is "<code>then</code>", <a href="#symbol.tostringtag" id="crossoriginpropertyfallback-(-p-):symbol.tostringtag">%Symbol.toStringTag%</a>,
   <a href="#symbol.hasinstance" id="crossoriginpropertyfallback-(-p-):symbol.hasinstance">%Symbol.hasInstance%</a>, or <a href="#symbol.isconcatspreadable" id="crossoriginpropertyfallback-(-p-):symbol.isconcatspreadable">%Symbol.isConcatSpreadable%</a>, then return
   <a id="crossoriginpropertyfallback-(-p-):propertydescriptor" href="https://tc39.es/ecma262/#sec-property-descriptor-specification-type" data-x-internal="propertydescriptor">PropertyDescriptor</a> {
   [[Value]]: undefined,
   [[Writable]]: false,
   [[Enumerable]]: false,
   [[Configurable]]: true }.</p></li><li><p>Throw a <a id="crossoriginpropertyfallback-(-p-):securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="crossoriginpropertyfallback-(-p-):domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="isplatformobjectsameorigin-(-o-)"><span class="secno">7.2.1.3.3</span> <dfn>IsPlatformObjectSameOrigin</dfn> ( <var>O</var> )<a href="#isplatformobjectsameorigin-(-o-)" class="self-link"></a></h6>

  <ol><li><p>Return true if the <a href="#current-settings-object" id="isplatformobjectsameorigin-(-o-):current-settings-object">current settings object</a>'s <a href="#concept-settings-object-origin" id="isplatformobjectsameorigin-(-o-):concept-settings-object-origin">origin</a> is <a href="#same-origin-domain" id="isplatformobjectsameorigin-(-o-):same-origin-domain">same origin-domain</a> with
   <var>O</var>'s <a href="#relevant-settings-object" id="isplatformobjectsameorigin-(-o-):relevant-settings-object">relevant settings object</a>'s <a href="#concept-settings-object-origin" id="isplatformobjectsameorigin-(-o-):concept-settings-object-origin-2">origin</a>, and false otherwise.</p></li></ol>
  </div>

  <p class="note">This abstract operation does not return a <a id="isplatformobjectsameorigin-(-o-):completion-record" href="https://tc39.es/ecma262/#sec-completion-record-specification-type" data-x-internal="completion-record">Completion Record</a>.</p>

  <p class="note">Here the <a href="#current-settings-object" id="isplatformobjectsameorigin-(-o-):current-settings-object-2">current settings object</a> roughly corresponds to the "caller",
  because this check occurs before the <a href="https://tc39.es/ecma262/#sec-execution-contexts" id="isplatformobjectsameorigin-(-o-):javascript-execution-context" data-x-internal="javascript-execution-context">execution
  context</a> for the getter/setter/method in question makes its way onto the <a id="isplatformobjectsameorigin-(-o-):javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript
  execution context stack</a>. For example, in the code <code>w.document</code>, this
  step is invoked before the <code id="isplatformobjectsameorigin-(-o-):dom-document-2"><a href="#dom-document-2">document</a></code> getter is reached as part
  of the <a href="#windowproxy-get">[[Get]]</a> algorithm for the <code id="isplatformobjectsameorigin-(-o-):windowproxy"><a href="#windowproxy">WindowProxy</a></code>
  <var>w</var>.</p>

  <div data-algorithm="">
  <h6 id="crossorigingetownpropertyhelper-(-o,-p-)"><span class="secno">7.2.1.3.4</span> <dfn>CrossOriginGetOwnPropertyHelper</dfn> ( <var>O</var>, <var>P</var> )<a href="#crossorigingetownpropertyhelper-(-o,-p-)" class="self-link"></a></h6>

  <p class="note">If this abstract operation returns undefined and there is no custom behavior, the
  caller needs to throw a <a id="crossorigingetownpropertyhelper-(-o,-p-):securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="crossorigingetownpropertyhelper-(-o,-p-):domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>. In
  practice this is handled by the caller calling <a href="#crossoriginpropertyfallback-(-p-)" id="crossorigingetownpropertyhelper-(-o,-p-):crossoriginpropertyfallback-(-p-)">CrossOriginPropertyFallback</a>.</p>

  <ol><li><p>Let <var>crossOriginKey</var> be a tuple consisting of the <a href="#current-settings-object" id="crossorigingetownpropertyhelper-(-o,-p-):current-settings-object">current settings
   object</a>, <var>O</var>'s <a href="#relevant-settings-object" id="crossorigingetownpropertyhelper-(-o,-p-):relevant-settings-object">relevant settings object</a>, and <var>P</var>.</p></li><li>
    <p>For each <var>e</var> of <a href="#crossoriginproperties-(-o-)" id="crossorigingetownpropertyhelper-(-o,-p-):crossoriginproperties-(-o-)">CrossOriginProperties</a>(<var>O</var>):</p>

    <ol><li>
      <p>If <a id="crossorigingetownpropertyhelper-(-o,-p-):samevalue" href="https://tc39.es/ecma262/#sec-samevalue" data-x-internal="samevalue">SameValue</a>(<var>e</var>.[[Property]], <var>P</var>) is true, then:</p>

      <ol><li><p>If the value of the <a href="#crossoriginpropertydescriptormap" id="crossorigingetownpropertyhelper-(-o,-p-):crossoriginpropertydescriptormap">[[CrossOriginPropertyDescriptorMap]]</a> internal slot of
       <var>O</var> contains an entry whose key is <var>crossOriginKey</var>, then return that
       entry's value.</p></li><li><p>Let <var>originalDesc</var> be <a id="crossorigingetownpropertyhelper-(-o,-p-):ordinarygetownproperty" href="https://tc39.es/ecma262/#sec-ordinarygetownproperty" data-x-internal="ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<var>O</var>,
       <var>P</var>).</p></li><li><p>Let <var>crossOriginDesc</var> be undefined.</p></li><li>
        <p>If <var>e</var>.[[NeedsGet]] and <var>e</var>.[[NeedsSet]] are absent, then:</p>

        <ol><li><p>Let <var>value</var> be <var>originalDesc</var>.[[Value]].</p></li><li><p>If <a id="crossorigingetownpropertyhelper-(-o,-p-):iscallable" href="https://tc39.es/ecma262/#sec-iscallable" data-x-internal="iscallable">IsCallable</a>(<var>value</var>) is true, then set <var>value</var> to
         an anonymous built-in function, created in the <a id="crossorigingetownpropertyhelper-(-o,-p-):current-realm" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a>, that performs
         the same steps as the IDL operation <var>P</var> on object <var>O</var>.</p></li><li><p>Set <var>crossOriginDesc</var> to <a id="crossorigingetownpropertyhelper-(-o,-p-):propertydescriptor" href="https://tc39.es/ecma262/#sec-property-descriptor-specification-type" data-x-internal="propertydescriptor">PropertyDescriptor</a> {
         [[Value]]: <var>value</var>,
         [[Enumerable]]: false,
         [[Writable]]: false,
         [[Configurable]]: true }.</p></li></ol>
       </li><li>
        <p>Otherwise:</p>

        <ol><li><p>Let <var>crossOriginGet</var> be undefined.</p></li><li><p>If <var>e</var>.[[NeedsGet]] is true, then set <var>crossOriginGet</var> to an
         anonymous built-in function, created in the <a id="crossorigingetownpropertyhelper-(-o,-p-):current-realm-2" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a>, that performs the
         same steps as the getter of the IDL attribute <var>P</var> on object
         <var>O</var>.</p></li><li><p>Let <var>crossOriginSet</var> be undefined.</p></li><li><p>If <var>e</var>.[[NeedsSet]] is true, then set <var>crossOriginSet</var> to an
         anonymous built-in function, created in the <a id="crossorigingetownpropertyhelper-(-o,-p-):current-realm-3" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a>, that performs the
         same steps as the setter of the IDL attribute <var>P</var> on object
         <var>O</var>.</p></li><li><p>Set <var>crossOriginDesc</var> to <a id="crossorigingetownpropertyhelper-(-o,-p-):propertydescriptor-2" href="https://tc39.es/ecma262/#sec-property-descriptor-specification-type" data-x-internal="propertydescriptor">PropertyDescriptor</a> {
         [[Get]]: <var>crossOriginGet</var>,
         [[Set]]: <var>crossOriginSet</var>,
         [[Enumerable]]: false,
         [[Configurable]]: true }.</p></li></ol>
       </li><li><p>Create an entry in the value of the <a href="#crossoriginpropertydescriptormap" id="crossorigingetownpropertyhelper-(-o,-p-):crossoriginpropertydescriptormap-2">[[CrossOriginPropertyDescriptorMap]]</a>
       internal slot of <var>O</var> with key <var>crossOriginKey</var> and value
       <var>crossOriginDesc</var>.</p></li><li><p>Return <var>crossOriginDesc</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Return undefined.</p></li></ol>
  </div>

  <p class="note">This abstract operation does not return a <a id="crossorigingetownpropertyhelper-(-o,-p-):completion-record" href="https://tc39.es/ecma262/#sec-completion-record-specification-type" data-x-internal="completion-record">Completion Record</a>.</p>

  <p class="note">The reason that the property descriptors produced here are configurable is to
  preserve the <a id="crossorigingetownpropertyhelper-(-o,-p-):invariants-of-the-essential-internal-methods" href="https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods" data-x-internal="invariants-of-the-essential-internal-methods">invariants of the essential internal methods</a> required by the JavaScript
  specification. In particular, since the value of the property can change as a consequence of
  navigation, it is required that the property be configurable. (However, see <a href="https://github.com/tc39/ecma262/issues/672">tc39/ecma262 issue #672</a> and references to it
  elsewhere in this specification for cases where we are not able to preserve these invariants, for
  compatibility with existing web content.) <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <p class="note">The reason the property descriptors are non-enumerable, despite this mismatching
  the same-origin behavior, is for compatibility with existing web content. See <a href="https://github.com/whatwg/html/issues/3183">issue #3183</a> for details.</p>

  <div data-algorithm="">
  <h6 id="crossoriginget-(-o,-p,-receiver-)"><span class="secno">7.2.1.3.5</span> <dfn>CrossOriginGet</dfn> ( <var>O</var>, <var>P</var>, <var>Receiver</var> )<a href="#crossoriginget-(-o,-p,-receiver-)" class="self-link"></a></h6>

  <ol><li><p>Let <var>desc</var> be ? <var>O</var>.[[GetOwnProperty]](<var>P</var>).</p></li><li><p><a id="crossoriginget-(-o,-p,-receiver-):assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>desc</var> is not undefined.</p></li><li><p>If <a id="crossoriginget-(-o,-p,-receiver-):isdatadescriptor" href="https://tc39.es/ecma262/#sec-isdatadescriptor" data-x-internal="isdatadescriptor">IsDataDescriptor</a>(<var>desc</var>) is true, then return
   <var>desc</var>.[[Value]].</p></li><li><p><a id="crossoriginget-(-o,-p,-receiver-):assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <a id="crossoriginget-(-o,-p,-receiver-):isaccessordescriptor" href="https://tc39.es/ecma262/#sec-isaccessordescriptor" data-x-internal="isaccessordescriptor">IsAccessorDescriptor</a>(<var>desc</var>) is true.</p></li><li><p>Let <var>getter</var> be <var>desc</var>.[[Get]].</p></li><li><p>If <var>getter</var> is undefined, then throw a <a id="crossoriginget-(-o,-p,-receiver-):securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
   <code id="crossoriginget-(-o,-p,-receiver-):domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return ? <a id="crossoriginget-(-o,-p,-receiver-):call" href="https://tc39.es/ecma262/#sec-call" data-x-internal="call">Call</a>(<var>getter</var>, <var>Receiver</var>).</p></li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="crossoriginset-(-o,-p,-v,-receiver-)"><span class="secno">7.2.1.3.6</span> <dfn>CrossOriginSet</dfn> ( <var>O</var>, <var>P</var>, <var>V</var>,
  <var>Receiver</var> )<a href="#crossoriginset-(-o,-p,-v,-receiver-)" class="self-link"></a></h6>

  <ol><li><p>Let <var>desc</var> be ? <var>O</var>.[[GetOwnProperty]](<var>P</var>).</p></li><li><p><a id="crossoriginset-(-o,-p,-v,-receiver-):assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>desc</var> is not undefined.</p></li><li>
    <p>If <var>desc</var>.[[Set]] is present and its value is not undefined, then:

    </p><ol><li><p>Perform ? <a id="crossoriginset-(-o,-p,-v,-receiver-):call" href="https://tc39.es/ecma262/#sec-call" data-x-internal="call">Call</a>(<var>desc</var>.[[Set]], <var>Receiver</var>,
     « <var>V</var> »).</p></li><li><p>Return true.</p></li></ol>
   </li><li><p>Throw a <a id="crossoriginset-(-o,-p,-v,-receiver-):securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="crossoriginset-(-o,-p,-v,-receiver-):domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="crossoriginownpropertykeys-(-o-)"><span class="secno">7.2.1.3.7</span> <dfn>CrossOriginOwnPropertyKeys</dfn> ( <var>O</var> )<a href="#crossoriginownpropertykeys-(-o-)" class="self-link"></a></h6>

  <ol><li><p>Let <var>keys</var> be a new empty <a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" id="crossoriginownpropertykeys-(-o-):js-list" data-x-internal="js-list">List</a>.</p></li><li><p>For each <var>e</var> of <a href="#crossoriginproperties-(-o-)" id="crossoriginownpropertykeys-(-o-):crossoriginproperties-(-o-)">CrossOriginProperties</a>(<var>O</var>), <a href="https://infra.spec.whatwg.org/#list-append" id="crossoriginownpropertykeys-(-o-):list-append" data-x-internal="list-append">append</a> <var>e</var>.[[Property]] to <var>keys</var>.</p></li><li><p>Return the concatenation of <var>keys</var> and « "<code>then</code>",
   <a href="#symbol.tostringtag" id="crossoriginownpropertykeys-(-o-):symbol.tostringtag">%Symbol.toStringTag%</a>, <a href="#symbol.hasinstance" id="crossoriginownpropertykeys-(-o-):symbol.hasinstance">%Symbol.hasInstance%</a>, <a href="#symbol.isconcatspreadable" id="crossoriginownpropertykeys-(-o-):symbol.isconcatspreadable">%Symbol.isConcatSpreadable%</a>
   ».</p></li></ol>
  </div>

  <p class="note">This abstract operation does not return a <a id="crossoriginownpropertykeys-(-o-):completion-record" href="https://tc39.es/ecma262/#sec-completion-record-specification-type" data-x-internal="completion-record">Completion Record</a>.</p>

  


  <h4 id="the-window-object"><span class="secno">7.2.2</span> The <code id="the-window-object:window"><a href="#window">Window</a></code> object<a href="#the-window-object" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window" title="The Window interface represents a window containing a DOM document; the document property points to the DOM document loaded in that window.">Window</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Global</c->=<c- n="">Window</c->,
 <c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="the-window-object:legacyunenumerablenamedproperties" href="https://webidl.spec.whatwg.org/#LegacyUnenumerableNamedProperties" data-x-internal="legacyunenumerablenamedproperties"><c- g="">LegacyUnenumerableNamedProperties</c-></a>]
<c- b="">interface</c-> <dfn id="window" data-dfn-type="interface"><c- g="">Window</c-></dfn> : <a id="the-window-object:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  // the current browsing context
  [<a id="the-window-object:legacyunforgeable" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#windowproxy" id="the-window-object:windowproxy"><c- n="">WindowProxy</c-></a> <a href="#dom-window" id="the-window-object:dom-window"><c- g="">window</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#windowproxy" id="the-window-object:windowproxy-2"><c- n="">WindowProxy</c-></a> <a href="#dom-self" id="the-window-object:dom-self"><c- g="">self</c-></a>;
  [<a id="the-window-object:legacyunforgeable-2" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#document" id="the-window-object:document"><c- n="">Document</c-></a> <a href="#dom-document-2" id="the-window-object:dom-document-2"><c- g="">document</c-></a>;
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-name" id="the-window-object:dom-name"><c- g="">name</c-></a>; 
  [<c- g="">PutForwards</c->=<a href="#dom-location-href" id="the-window-object:dom-location-href"><c- n="">href</c-></a>, <a id="the-window-object:legacyunforgeable-3" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#location" id="the-window-object:location"><c- n="">Location</c-></a> <a href="#dom-location" id="the-window-object:dom-location"><c- g="">location</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#history-3" id="the-window-object:history-3"><c- n="">History</c-></a> <a href="#dom-history" id="the-window-object:dom-history"><c- g="">history</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigation" id="the-window-object:navigation"><c- n="">Navigation</c-></a> <a href="#dom-navigation" id="the-window-object:dom-navigation"><c- g="">navigation</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#customelementregistry" id="the-window-object:customelementregistry"><c- n="">CustomElementRegistry</c-></a> <a href="#dom-window-customelements" id="the-window-object:dom-window-customelements"><c- g="">customElements</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#barprop" id="the-window-object:barprop"><c- n="">BarProp</c-></a> <a href="#dom-window-locationbar" id="the-window-object:dom-window-locationbar"><c- g="">locationbar</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#barprop" id="the-window-object:barprop-2"><c- n="">BarProp</c-></a> <a href="#dom-window-menubar" id="the-window-object:dom-window-menubar"><c- g="">menubar</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#barprop" id="the-window-object:barprop-3"><c- n="">BarProp</c-></a> <a href="#dom-window-personalbar" id="the-window-object:dom-window-personalbar"><c- g="">personalbar</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#barprop" id="the-window-object:barprop-4"><c- n="">BarProp</c-></a> <a href="#dom-window-scrollbars" id="the-window-object:dom-window-scrollbars"><c- g="">scrollbars</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#barprop" id="the-window-object:barprop-5"><c- n="">BarProp</c-></a> <a href="#dom-window-statusbar" id="the-window-object:dom-window-statusbar"><c- g="">statusbar</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#barprop" id="the-window-object:barprop-6"><c- n="">BarProp</c-></a> <a href="#dom-window-toolbar" id="the-window-object:dom-window-toolbar"><c- g="">toolbar</c-></a>;
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-window-status" id="the-window-object:dom-window-status"><c- g="">status</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-window-close" id="the-window-object:dom-window-close"><c- g="">close</c-></a>();
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-window-closed" id="the-window-object:dom-window-closed"><c- g="">closed</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-window-stop" id="the-window-object:dom-window-stop"><c- g="">stop</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-window-focus" id="the-window-object:dom-window-focus"><c- g="">focus</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-window-blur" id="the-window-object:dom-window-blur"><c- g="">blur</c-></a>();

  // other browsing contexts
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#windowproxy" id="the-window-object:windowproxy-3"><c- n="">WindowProxy</c-></a> <a href="#dom-frames" id="the-window-object:dom-frames"><c- g="">frames</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-length" id="the-window-object:dom-length"><c- g="">length</c-></a>;
  [<a id="the-window-object:legacyunforgeable-4" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#windowproxy" id="the-window-object:windowproxy-4"><c- n="">WindowProxy</c-></a>? <a href="#dom-top" id="the-window-object:dom-top"><c- g="">top</c-></a>;
  <c- b="">attribute</c-> <c- b="">any</c-> <a href="#dom-opener" id="the-window-object:dom-opener"><c- g="">opener</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#windowproxy" id="the-window-object:windowproxy-5"><c- n="">WindowProxy</c-></a>? <a href="#dom-parent" id="the-window-object:dom-parent"><c- g="">parent</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-window-object:element" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- n="">Element</c-></a>? <a href="#dom-frameelement" id="the-window-object:dom-frameelement"><c- g="">frameElement</c-></a>;
  <a href="#windowproxy" id="the-window-object:windowproxy-6"><c- n="">WindowProxy</c-></a>? <a href="#dom-open" id="the-window-object:dom-open"><c- g="">open</c-></a>(<c- b="">optional</c-> <c- b="">USVString</c-> <c- g="">url</c-> = "", <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">target</c-> = "_blank", <c- b="">optional</c-> [<a id="the-window-object:legacynulltoemptystring" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <c- g="">features</c-> = "");

  // Since this is the global object, the IDL named getter adds a NamedPropertiesObject exotic
  // object on the prototype chain. Indeed, this does not make the global object an exotic object.
  // Indexed access is taken care of by the <a href="#windowproxy" id="the-window-object:windowproxy-7">WindowProxy</a> exotic object.
  <a href="#dom-window-nameditem"><c- b="">getter</c-></a> <a href="https://webidl.spec.whatwg.org/#idl-object" id="the-window-object:idl-object" data-x-internal="idl-object"><c- b="">object</c-></a> (<c- b="">DOMString</c-> <c- g="">name</c->);

  // the user agent
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigator" id="the-window-object:navigator"><c- n="">Navigator</c-></a> <a href="#dom-navigator" id="the-window-object:dom-navigator"><c- g="">navigator</c-></a>;
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigator" id="the-window-object:navigator-2"><c- n="">Navigator</c-></a> <a href="#dom-clientinformation" id="the-window-object:dom-clientinformation"><c- g="">clientInformation</c-></a>; // legacy alias of .navigator
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-originagentcluster" id="the-window-object:dom-originagentcluster"><c- g="">originAgentCluster</c-></a>;

  // user prompts
  <c- b="">undefined</c-> <a href="#dom-alert-noargs" id="the-window-object:dom-alert-noargs"><c- g="">alert</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-alert" id="the-window-object:dom-alert"><c- g="">alert</c-></a>(<c- b="">DOMString</c-> <c- g="">message</c->);
  <c- b="">boolean</c-> <a href="#dom-confirm" id="the-window-object:dom-confirm"><c- g="">confirm</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">message</c-> = "");
  <c- b="">DOMString</c->? <a href="#dom-prompt" id="the-window-object:dom-prompt"><c- g="">prompt</c-></a>(<c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">message</c-> = "", <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">default</c-> = "");
  <c- b="">undefined</c-> <a href="#dom-print" id="the-window-object:dom-print"><c- g="">print</c-></a>();

  <c- b="">undefined</c-> <a href="#dom-window-postmessage" id="the-window-object:dom-window-postmessage"><c- g="">postMessage</c-></a>(<c- b="">any</c-> <c- g="">message</c->, <c- b="">USVString</c-> <c- g="">targetOrigin</c->, <c- b="">optional</c-> <c- b="">sequence</c->&lt;<a href="https://webidl.spec.whatwg.org/#idl-object" id="the-window-object:idl-object-2" data-x-internal="idl-object"><c- b="">object</c-></a>&gt; <c- g="">transfer</c-> = []);
  <c- b="">undefined</c-> <a href="#dom-window-postmessage-options" id="the-window-object:dom-window-postmessage-options"><c- g="">postMessage</c-></a>(<c- b="">any</c-> <c- g="">message</c->, <c- b="">optional</c-> <a href="#windowpostmessageoptions" id="the-window-object:windowpostmessageoptions"><c- n="">WindowPostMessageOptions</c-></a> <c- g="">options</c-> = {});

  // <a href="#Window-partial">also has obsolete members</a>
};
<a href="#window" id="the-window-object:window-2"><c- n="">Window</c-></a> <c- b="">includes</c-> <a href="#globaleventhandlers" id="the-window-object:globaleventhandlers"><c- n="">GlobalEventHandlers</c-></a>;
<a href="#window" id="the-window-object:window-3"><c- n="">Window</c-></a> <c- b="">includes</c-> <a href="#windoweventhandlers" id="the-window-object:windoweventhandlers"><c- n="">WindowEventHandlers</c-></a>;

<c- b="">dictionary</c-> <dfn id="windowpostmessageoptions" data-dfn-type="dictionary"><c- g="">WindowPostMessageOptions</c-></dfn> : <a href="#structuredserializeoptions" id="the-window-object:structuredserializeoptions"><c- n="">StructuredSerializeOptions</c-></a> {
  <c- b="">USVString</c-> <dfn data-dfn-for="WindowPostMessageOptions" id="dom-windowpostmessageoptions-targetorigin" data-dfn-type="dict-member"><c- g="">targetOrigin</c-></dfn> = "/";
};</code></pre>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-window" id="dom-window-dev">window</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/window" title="The window property of a Window object points to the window object itself.">Window/window</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>window</var>.<a href="#dom-frames" id="dom-frames-dev">frames</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/frames" title="Returns the window itself, which is an array-like object, listing the direct sub-frames of the current window.">Window/frames</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>window</var>.<a href="#dom-self" id="dom-self-dev">self</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/self" title="The Window.self read-only property returns the window itself, as a WindowProxy. It can be used with dot notation on a window object (that is, window.self) or standalone (self). The advantage of the standalone notation is that a similar notation exists for non-window contexts, such as in Web Workers. By using self, you can refer to the global scope in a way that will work not only in a window context (self will resolve to window.self) but also in a worker context (self will then resolve to WorkerGlobalScope.self).">Window/self</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>These attributes all return <var>window</var>.</p></dd><dt><code><var>window</var>.<a href="#dom-document-2" id="dom-document-dev">document</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/document" title="window.document returns a reference to the document contained in the window.">Window/document</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the <code id="the-window-object:document-2"><a href="#document">Document</a></code> associated with <var>window</var>.</p></dd><dt><code><var>document</var>.<a href="#dom-document-defaultview" id="dom-document-defaultview-dev">defaultView</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView" title="In browsers, document.defaultView returns the window object associated with a document, or null if none is available.">Document/defaultView</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the <code id="the-window-object:window-4"><a href="#window">Window</a></code> associated with <var>document</var>, if there is one, or null otherwise.</p></dd></dl>

  

  <p>The <code id="the-window-object:window-5"><a href="#window">Window</a></code> object has an <dfn id="concept-document-window" data-export="">associated
  <code>Document</code></dfn>, which is a <code id="the-window-object:document-3"><a href="#document">Document</a></code> object. It is set when the
  <code id="the-window-object:window-6"><a href="#window">Window</a></code> object is created, and only ever changed during <a href="#navigate" id="the-window-object:navigate">navigation</a> from the <a href="#is-initial-about:blank" id="the-window-object:is-initial-about:blank">initial
  <code>about:blank</code></a> <code id="the-window-object:document-4"><a href="#document">Document</a></code>.</p>

  <div data-algorithm="">
  <p>A <code id="the-window-object:window-7"><a href="#window">Window</a></code>'s <dfn data-dfn-for="Window" id="window-bc" data-export="">browsing context</dfn> is
  its <a href="#concept-document-window" id="the-window-object:concept-document-window">associated <code>Document</code></a>'s <a href="#concept-document-bc" id="the-window-object:concept-document-bc">browsing context</a>. <span class="note">It is either null or a
  <a href="#browsing-context" id="the-window-object:browsing-context">browsing context</a>.</span></p>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-window-object:window-8"><a href="#window">Window</a></code>'s <dfn data-dfn-for="Window" id="window-navigable" data-export="">navigable</dfn> is
  the <a href="#navigable" id="the-window-object:navigable">navigable</a> whose <a href="#nav-document" id="the-window-object:nav-document">active document</a> is the
  <code id="the-window-object:window-9"><a href="#window">Window</a></code>'s <a href="#concept-document-window" id="the-window-object:concept-document-window-2">associated
  <code>Document</code></a>'s, or null if there is no such <a href="#navigable" id="the-window-object:navigable-2">navigable</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window" data-dfn-type="attribute"><code>window</code></dfn>, <dfn data-dfn-for="Window" id="dom-frames" data-dfn-type="attribute"><code>frames</code></dfn>, and <dfn data-dfn-for="Window" id="dom-self" data-dfn-type="attribute"><code>self</code></dfn> getter steps are to return <a id="the-window-object:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-realm" id="the-window-object:concept-relevant-realm">relevant realm</a>.[[GlobalEnv]].[[GlobalThisValue]].</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-document-2" data-dfn-type="attribute"><code>document</code></dfn> getter steps
  are to return <a id="the-window-object:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="the-window-object:concept-document-window-3">associated
  <code>Document</code></a>.</p>
  </div>

  <p class="note">The <code id="the-window-object:document-5"><a href="#document">Document</a></code> object associated with a <code id="the-window-object:window-10"><a href="#window">Window</a></code> object can
  change in exactly one case: when the <a href="#navigate" id="the-window-object:navigate-2">navigate</a> algorithm <a href="#initialise-the-document-object" id="the-window-object:initialise-the-document-object">creates a new <code>Document</code> object</a> for the
  first page loaded in a <a href="#browsing-context" id="the-window-object:browsing-context-2">browsing context</a>. In that specific case, the
  <code id="the-window-object:window-11"><a href="#window">Window</a></code> object of the <a href="#is-initial-about:blank" id="the-window-object:is-initial-about:blank-2">initial
  <code>about:blank</code></a> page is reused and gets a new <code id="the-window-object:document-6"><a href="#document">Document</a></code> object.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-defaultview" data-dfn-type="attribute"><code>defaultView</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-window-object:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-bc" id="the-window-object:concept-document-bc-2">browsing context</a> is null,
   then return null.</p></li><li><p>Return <a id="the-window-object:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-bc" id="the-window-object:concept-document-bc-3">browsing context</a>'s
   <code id="the-window-object:windowproxy-8"><a href="#windowproxy">WindowProxy</a></code> object.</p></li></ol>
  </div>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDocument" title="For historical reasons, Window objects have a window.HTMLDocument property whose value is the Document interface. So you can think of HTMLDocument as an alias for Document, and you can find documentation for HTMLDocument members under the documentation for the Document interface.">HTMLDocument</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><p>For historical reasons, <code id="the-window-object:window-12"><a href="#window">Window</a></code> objects must also have a writable, configurable,
  non-enumerable property named <dfn id="htmldocument"><code>HTMLDocument</code></dfn> whose value is the
  <code id="the-window-object:document-7"><a href="#document">Document</a></code> <a id="the-window-object:interface-object" href="https://webidl.spec.whatwg.org/#dfn-interface-object" data-x-internal="interface-object">interface object</a>.</p>

  


  <h5 id="apis-for-creating-and-navigating-browsing-contexts-by-name"><span class="secno">7.2.2.1</span> Opening and closing windows<a href="#apis-for-creating-and-navigating-browsing-contexts-by-name" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>window</var> = <var>window</var>.<a href="#dom-open" id="dom-open-dev">open</a>([ <var>url</var> [, <var>target</var> [, <var>features</var> ] ] ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/open" title="The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name.">Window/open</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Opens a window to show <var>url</var> (defaults to "<code id="apis-for-creating-and-navigating-browsing-contexts-by-name:about:blank"><a href="#about:blank">about:blank</a></code>"), and returns
    it. <var>target</var> (defaults to "<code>_blank</code>") gives the name of the new
    window. If a window already exists with that name, it is reused. The <var>features</var>
    argument can contain a <a href="#set-of-comma-separated-tokens" id="apis-for-creating-and-navigating-browsing-contexts-by-name:set-of-comma-separated-tokens">set of comma-separated tokens</a>:</p>

    <dl><dt>"<code>noopener</code>"</dt><dt>"<code>noreferrer</code>"</dt><dd><p>These behave equivalently to the <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:link-type-noopener"><a href="#link-type-noopener">noopener</a></code> and <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:link-type-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code> link types on <a href="#hyperlink" id="apis-for-creating-and-navigating-browsing-contexts-by-name:hyperlink">hyperlinks</a>.</p></dd><dt>"<code>popup</code>"</dt><dd><p>Encourages user agents to provide a minimal web browser user interface for the new
     window. (Impacts the <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:dom-barprop-visible"><a href="#dom-barprop-visible">visible</a></code> getter on all
     <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:barprop"><a href="#barprop">BarProp</a></code> objects as well.)</p></dd></dl>

    <pre class="example"><code class="js">globalThis<c- p="">.</c->open<c- p="">(</c-><c- u="">"https://email.example/message/CAOOOkFcWW97r8yg=SsWg7GgCmp4suVX9o85y8BvNRqMjuc5PXg"</c-><c- p="">,</c-> <c- kc="">undefined</c-><c- p="">,</c-> <c- u="">"noopener,popup"</c-><c- p="">);</c-></code></pre>
   </dd><dt><code><var>window</var>.<a href="#dom-name" id="dom-name-dev">name</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/name" title="The Window.name property gets/sets the name of the window's browsing context.">Window/name</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the name of the window.</p>

    <p>Can be set, to change the name.</p>
   </dd><dt><code><var>window</var>.<a href="#dom-window-close" id="dom-window-close-dev">close</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/close" title="The Window.close() method closes the current window, or the window on which it was called.">Window/close</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Closes the window.</p></dd><dt><code><var>window</var>.<a href="#dom-window-closed" id="dom-window-closed-dev">closed</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/closed" title="The Window.closed read-only property indicates whether the referenced window is closed or not.">Window/closed</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns true if the window has been closed, false otherwise.</p></dd><dt><code><var>window</var>.<a href="#dom-window-stop" id="dom-window-stop-dev">stop</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/stop" title="The window.stop() stops further resource loading in the current browsing context, equivalent to the stop button in the browser.">Window/stop</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Cancels the document load.</p></dd></dl>

  

  <div data-algorithm="">
  <p>To <dfn id="get-noopener-for-window-open">get noopener for window open</dfn>, given a <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:document"><a href="#document">Document</a></code>
  <var>sourceDocument</var>, an <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:ordered-map" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> <var>tokenizedFeatures</var>, and a
  <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a>-or-null <var>url</var>, perform the following steps. They return a
  boolean.</p>

  <ol><li>
    <p>If <var>url</var> is not null and <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-blob-entry" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-url-blob-entry" data-x-internal="concept-url-blob-entry">blob URL entry</a> is not null:</p>

    <ol><li><p>Let <var>blobOrigin</var> be <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-blob-entry" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-url-blob-entry-2" data-x-internal="concept-url-blob-entry">blob URL entry</a>'s <a href="https://w3c.github.io/FileAPI/#blob-url-entry-environment" id="apis-for-creating-and-navigating-browsing-contexts-by-name:blob-url-entry-environment" data-x-internal="blob-url-entry-environment">environment</a>'s <a href="#concept-settings-object-origin" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-settings-object-origin">origin</a>.</p></li><li><p>Let <var>topLevelOrigin</var> be <var>sourceDocument</var>'s <a href="#relevant-settings-object" id="apis-for-creating-and-navigating-browsing-contexts-by-name:relevant-settings-object">relevant settings
     object</a>'s <a href="#concept-environment-top-level-origin" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-environment-top-level-origin">top-level origin</a>.</p></li><li><p>If <var>blobOrigin</var> is not <a href="#same-site" id="apis-for-creating-and-navigating-browsing-contexts-by-name:same-site">same site</a> with <var>topLevelOrigin</var>,
     then return true.</p></li></ol>
   </li><li><p>Let <var>noopener</var> be false.</p></li><li><p>If <var>tokenizedFeatures</var>["<code>noopener</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="apis-for-creating-and-navigating-browsing-contexts-by-name:map-exists" data-x-internal="map-exists">exists</a>, then set <var>noopener</var> to the result of <a href="#concept-window-open-features-parse-boolean" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-window-open-features-parse-boolean">parsing <var>tokenizedFeatures</var>["<code>noopener</code>"] as a boolean feature</a>.</p></li><li><p>Return <var>noopener</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="window-open-steps">window open steps</dfn>, given a string <var>url</var>, a string <var>target</var>,
  and a string <var>features</var>, are as follows:</p>

  <ol><li><p>If the <a href="#event-loop" id="apis-for-creating-and-navigating-browsing-contexts-by-name:event-loop">event loop</a>'s <a href="#termination-nesting-level" id="apis-for-creating-and-navigating-browsing-contexts-by-name:termination-nesting-level">termination nesting level</a> is nonzero,
   then return null.</p></li><li><p>Let <var>sourceDocument</var> be the <a href="#entry-global-object" id="apis-for-creating-and-navigating-browsing-contexts-by-name:entry-global-object">entry global object</a>'s <a href="#concept-document-window" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>Let <var>urlRecord</var> be null.</p></li><li>
    <p>If <var>url</var> is not the empty string, then:</p>

    <ol><li><p>Set <var>urlRecord</var> to the result of <a href="#encoding-parsing-a-url" id="apis-for-creating-and-navigating-browsing-contexts-by-name:encoding-parsing-a-url">encoding-parsing a URL</a> given
     <var>url</var>, relative to <var>sourceDocument</var>.</p></li><li><p>If <var>urlRecord</var> is failure, then throw a <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
     <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
   </li><li><p>If <var>target</var> is the empty string, then set <var>target</var> to "<code>_blank</code>".</p></li><li><p>Let <var>tokenizedFeatures</var> be the result of <a href="#concept-window-open-features-tokenize" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-window-open-features-tokenize">tokenizing</a> <var>features</var>.</p></li><li><p>Let <var>noreferrer</var> be false.</p></li><li><p>If <var>tokenizedFeatures</var>["<code>noreferrer</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="apis-for-creating-and-navigating-browsing-contexts-by-name:map-exists-2" data-x-internal="map-exists">exists</a>, then set <var>noreferrer</var> to the result of <a href="#concept-window-open-features-parse-boolean" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-window-open-features-parse-boolean-2">parsing <var>tokenizedFeatures</var>["<code>noreferrer</code>"] as a boolean feature</a>.</p></li><li><p>Let <var>noopener</var> be the result of <a href="#get-noopener-for-window-open" id="apis-for-creating-and-navigating-browsing-contexts-by-name:get-noopener-for-window-open">getting noopener for window open</a> with
   <var>sourceDocument</var>, <var>tokenizedFeatures</var>, and <var>urlRecord</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="apis-for-creating-and-navigating-browsing-contexts-by-name:map-remove" data-x-internal="map-remove">Remove</a> <var>tokenizedFeatures</var>["<code>noopener</code>"] and <var>tokenizedFeatures</var>["<code>noreferrer</code>"].</p></li><li><p>Let <var>referrerPolicy</var> be the empty string.</p></li><li><p>If <var>noreferrer</var> is true, then set <var>noopener</var> to true and set
   <var>referrerPolicy</var> to "<code>no-referrer</code>".</p></li><li>
    <p>Let <var>targetNavigable</var> and <var>windowType</var> be the result of applying <a href="#the-rules-for-choosing-a-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:the-rules-for-choosing-a-navigable">the
    rules for choosing a navigable</a> given <var>target</var>, <var>sourceDocument</var>'s
    <a href="#node-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:node-navigable">node navigable</a>, and <var>noopener</var>.</p>

    <p class="example">If there is a user agent that supports control-clicking a link to open it in
    a new tab, and the user control-clicks on an element whose <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:handler-onclick"><a href="#handler-onclick">onclick</a></code> handler uses the <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:dom-open"><a href="#dom-open">window.open()</a></code> API to open a page in an <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element,
    the user agent could override the selection of the target browsing context to instead target a
    new tab.</p>
   </li><li><p>If <var>targetNavigable</var> is null, then return null.</p></li><li>
    <p>If <var>windowType</var> is either "<code>new and unrestricted</code>" or "<code>new with no opener</code>", then:</p>

    <ol><li><p>Set <var>targetNavigable</var>'s <a href="#nav-bc" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-bc">active browsing context</a>'s
     <a href="#is-popup" id="apis-for-creating-and-navigating-browsing-contexts-by-name:is-popup">is popup</a> to the result of <a href="#popup-window-is-requested" id="apis-for-creating-and-navigating-browsing-contexts-by-name:popup-window-is-requested">checking if a
     popup window is requested</a>, given <var>tokenizedFeatures</var>.</p></li><li><p><a id="apis-for-creating-and-navigating-browsing-contexts-by-name:set-up-browsing-context-features" href="https://drafts.csswg.org/cssom-view/#set-up-browsing-context-features" data-x-internal="set-up-browsing-context-features">Set up browsing context features</a> for <var>targetNavigable</var>'s <a href="#nav-bc" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-bc-2">active browsing context</a> given
     <var>tokenizedFeatures</var>. <a href="#refsCSSOMVIEW">[CSSOMVIEW]</a></p></li><li><p>If <var>urlRecord</var> is null, then set <var>urlRecord</var> to a <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:url-record-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL
     record</a> representing <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:about:blank-2"><a href="#about:blank">about:blank</a></code>.</p></li><li>
      <p>If <var>urlRecord</var> <a href="#matches-about:blank" id="apis-for-creating-and-navigating-browsing-contexts-by-name:matches-about:blank">matches <code>about:blank</code></a>, then perform the
      <a href="#url-and-history-update-steps" id="apis-for-creating-and-navigating-browsing-contexts-by-name:url-and-history-update-steps">URL and history update steps</a> given <var>targetNavigable</var>'s <a href="#nav-document" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-document">active document</a> and <var>urlRecord</var>.</p>

      <p class="note">This is necessary in case <var>url</var> is something like <code>about:blank?foo</code>. If <var>url</var> is just plain <code>about:blank</code>, this will do nothing.</p>
     </li><li><p>Otherwise, <a href="#navigate" id="apis-for-creating-and-navigating-browsing-contexts-by-name:navigate">navigate</a> <var>targetNavigable</var>
     to <var>urlRecord</var> using <var>sourceDocument</var>, with <i id="apis-for-creating-and-navigating-browsing-contexts-by-name:navigation-referrer-policy"><a href="#navigation-referrer-policy">referrerPolicy</a></i> set to <var>referrerPolicy</var> and
     <i><a href="#exceptions-enabled" id="apis-for-creating-and-navigating-browsing-contexts-by-name:exceptions-enabled">exceptionsEnabled</a></i> set to true.</p></li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p>If <var>urlRecord</var> is not null, then
     <a href="#navigate" id="apis-for-creating-and-navigating-browsing-contexts-by-name:navigate-2">navigate</a> <var>targetNavigable</var> to <var>urlRecord</var> using
     <var>sourceDocument</var>, with <i id="apis-for-creating-and-navigating-browsing-contexts-by-name:navigation-referrer-policy-2"><a href="#navigation-referrer-policy">referrerPolicy</a></i> set
     to <var>referrerPolicy</var> and <i><a href="#exceptions-enabled" id="apis-for-creating-and-navigating-browsing-contexts-by-name:exceptions-enabled-2">exceptionsEnabled</a></i> set to true.</p></li><li><p>If <var>noopener</var> is false, then set <var>targetNavigable</var>'s <a href="#nav-bc" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-bc-3">active browsing context</a>'s <a href="#opener-browsing-context" id="apis-for-creating-and-navigating-browsing-contexts-by-name:opener-browsing-context">opener browsing context</a> to
     <var>sourceDocument</var>'s <a href="#concept-document-bc" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-document-bc">browsing
     context</a>.</p></li></ol>
   </li><li><p>If <var>noopener</var> is true or <var>windowType</var> is "<code>new with no
   opener</code>", then return null.</p></li><li><p>Return <var>targetNavigable</var>'s <a href="#nav-wp" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-wp">active
   <code>WindowProxy</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-open" data-dfn-type="method"><code>open(<var>url</var>, <var>target</var>,
  <var>features</var>)</code></dfn> method steps are to run the <a href="#window-open-steps" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-open-steps">window open steps</a> with
  <var>url</var>, <var>target</var>, and <var>features</var>.</p>
  </div>

  <p class="note">The method provides a mechanism for <a href="#navigate" id="apis-for-creating-and-navigating-browsing-contexts-by-name:navigate-3">navigating</a> an
  existing <a href="#browsing-context" id="apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context">browsing context</a> or opening and navigating an <a href="#auxiliary-browsing-context" id="apis-for-creating-and-navigating-browsing-contexts-by-name:auxiliary-browsing-context">auxiliary browsing
  context</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="concept-window-open-features-tokenize">tokenize the <var>features</var>
  argument</dfn>:</p>

  <ol><li><p>Let <var>tokenizedFeatures</var> be a new <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:ordered-map-2" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>.</p></li><li><p>Let <var>position</var> point at the first code point of <var>features</var>.</p></li><li>
    <p><a id="apis-for-creating-and-navigating-browsing-contexts-by-name:while" href="https://infra.spec.whatwg.org/#iteration-while" data-x-internal="while">While</a> <var>position</var> is not past the end of <var>features</var>:</p>

    <ol><li><p>Let <var>name</var> be the empty string.</p></li><li><p>Let <var>value</var> be the empty string.</p></li><li><p><a id="apis-for-creating-and-navigating-browsing-contexts-by-name:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a href="#feature-separator" id="apis-for-creating-and-navigating-browsing-contexts-by-name:feature-separator">feature separators</a> from <var>features</var> given <var>position</var>. This
     skips past leading separators before the name.</p></li><li><p><a id="apis-for-creating-and-navigating-browsing-contexts-by-name:collect-a-sequence-of-code-points-2" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are not <a href="#feature-separator" id="apis-for-creating-and-navigating-browsing-contexts-by-name:feature-separator-2">feature separators</a> from <var>features</var> given <var>position</var>. Set
     <var>name</var> to the collected characters, <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>.</p></li><li><p>Set <var>name</var> to the result of <a href="#normalizing-the-feature-name" id="apis-for-creating-and-navigating-browsing-contexts-by-name:normalizing-the-feature-name">normalizing the feature name</a>
     <var>name</var>.</p></li><li>
      <p><a id="apis-for-creating-and-navigating-browsing-contexts-by-name:while-2" href="https://infra.spec.whatwg.org/#iteration-while" data-x-internal="while">While</a> <var>position</var> is not past the end of <var>features</var> and the
      code point at <var>position</var> in <var>features</var> is not U+003D (=):</p>

      <ol><li><p>If the code point at <var>position</var> in <var>features</var> is U+002C (,), or if
       it is not a <a href="#feature-separator" id="apis-for-creating-and-navigating-browsing-contexts-by-name:feature-separator-3">feature separator</a>, then <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li><li><p>Advance <var>position</var> by 1.</p></li></ol>

      <p class="note">This skips to the first U+003D (=) but does not skip past a U+002C (,) or a
      non-separator.</p>
     </li><li>
      <p>If the code point at <var>position</var> in <var>features</var> is a <a href="#feature-separator" id="apis-for-creating-and-navigating-browsing-contexts-by-name:feature-separator-4">feature
      separator</a>:</p>

      <ol><li>
        <p>While <var>position</var> is not past the end of <var>features</var> and the code point
        at <var>position</var> in <var>features</var> is a <a href="#feature-separator" id="apis-for-creating-and-navigating-browsing-contexts-by-name:feature-separator-5">feature separator</a>:</p>

        <ol><li><p>If the code point at <var>position</var> in <var>features</var> is U+002C (,), then
         <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:break-2" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li><li><p>Advance <var>position</var> by 1.</p></li></ol>

        <p class="note">This skips to the first non-separator but does not skip past a U+002C
        (,).</p>
       </li><li><p><a id="apis-for-creating-and-navigating-browsing-contexts-by-name:collect-a-sequence-of-code-points-3" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are not <a href="#feature-separator" id="apis-for-creating-and-navigating-browsing-contexts-by-name:feature-separator-6">feature separators</a> code points from <var>features</var> given
       <var>position</var>. Set <var>value</var> to the collected code points, <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:converted-to-ascii-lowercase-2" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to
       ASCII lowercase</a>.</p></li></ol>
     </li><li><p>If <var>name</var> is not the empty string, then set
     <var>tokenizedFeatures</var>[<var>name</var>] to <var>value</var>.</p></li></ol>
   </li><li><p>Return <var>tokenizedFeatures</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="window-feature-is-set">check if a window feature is set</dfn>, given
  <var>tokenizedFeatures</var>, <var>featureName</var>, and <var>defaultValue</var>:</p>

  <ol><li><p>If <var>tokenizedFeatures</var>[<var>featureName</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="apis-for-creating-and-navigating-browsing-contexts-by-name:map-exists-3" data-x-internal="map-exists">exists</a>, then return the result of <a href="#concept-window-open-features-parse-boolean" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-window-open-features-parse-boolean-3">parsing
   <var>tokenizedFeatures</var>[<var>featureName</var>] as a boolean feature</a>.</p></li><li><p>Return <var>defaultValue</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="popup-window-is-requested">check if a popup window is requested</dfn>, given
  <var>tokenizedFeatures</var>:</p>

  <ol><li><p>If <var>tokenizedFeatures</var> is <a href="https://infra.spec.whatwg.org/#map-is-empty" id="apis-for-creating-and-navigating-browsing-contexts-by-name:map-empty" data-x-internal="map-empty">empty</a>, then return
   false.</p></li><li><p>If <var>tokenizedFeatures</var>["<code>popup</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="apis-for-creating-and-navigating-browsing-contexts-by-name:map-exists-4" data-x-internal="map-exists">exists</a>, then return the result of <a href="#concept-window-open-features-parse-boolean" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-window-open-features-parse-boolean-4">parsing
   <var>tokenizedFeatures</var>["<code>popup</code>"] as a boolean
   feature</a>.</p></li><li><p>Let <var>location</var> be the result of <a href="#window-feature-is-set" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-feature-is-set">checking if
   a window feature is set</a>, given <var>tokenizedFeatures</var>, "<code>location</code>", and false.</p></li><li><p>Let <var>toolbar</var> be the result of <a href="#window-feature-is-set" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-feature-is-set-2">checking if
   a window feature is set</a>, given <var>tokenizedFeatures</var>, "<code>toolbar</code>", and false.</p></li><li><p>If <var>location</var> and <var>toolbar</var> are both false, then return true.</p></li><li><p>Let <var>menubar</var> be the result of <a href="#window-feature-is-set" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-feature-is-set-3">checking if
   a window feature is set</a>, given <var>tokenizedFeatures</var>, "<code>menubar</code>", and false.</p></li><li><p>If <var>menubar</var> is false, then return true.</p></li><li><p>Let <var>resizable</var> be the result of <a href="#window-feature-is-set" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-feature-is-set-4">checking if
   a window feature is set</a>, given <var>tokenizedFeatures</var>, "<code>resizable</code>", and true.</p></li><li><p>If <var>resizable</var> is false, then return true.</p></li><li><p>Let <var>scrollbars</var> be the result of <a href="#window-feature-is-set" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-feature-is-set-5">checking
   if a window feature is set</a>, given <var>tokenizedFeatures</var>, "<code>scrollbars</code>", and false.</p></li><li><p>If <var>scrollbars</var> is false, then return true.</p></li><li><p>Let <var>status</var> be the result of <a href="#window-feature-is-set" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-feature-is-set-6">checking if
   a window feature is set</a>, given <var>tokenizedFeatures</var>, "<code>status</code>", and false.</p></li><li><p>If <var>status</var> is false, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A code point is a <dfn id="feature-separator">feature separator</dfn> if it is <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, U+003D
  (=), or U+002C (,).</p>
  </div>

  <div data-algorithm="">
  <p>For legacy reasons, there are some aliases of some feature names. To <dfn id="normalizing-the-feature-name">normalize a feature name</dfn> <var>name</var>, switch on <var>name</var>:</p>

  <dl class="switch"><dt>"<code>screenx</code>"
   </dt><dd>Return "<code>left</code>".
   </dd><dt>"<code>screeny</code>"
   </dt><dd>Return "<code>top</code>".
   </dd><dt>"<code>innerwidth</code>"
   </dt><dd>Return "<code>width</code>".
   </dd><dt>"<code>innerheight</code>"
   </dt><dd>Return "<code>height</code>".
   </dd><dt>Anything else
   </dt><dd>Return <var>name</var>.
  </dd></dl>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="concept-window-open-features-parse-boolean">parse a boolean feature</dfn> given
  a string <var>value</var>:</p>

  <ol><li><p>If <var>value</var> is the empty string, then return true.</p></li><li><p>If <var>value</var> <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:is" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="is">is</a> "<code>yes</code>", then return
   true.</p></li><li><p>If <var>value</var> <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:is-2" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="is">is</a> "<code>true</code>", then return
   true.</p></li><li><p>Let <var>parsed</var> be the result of <a href="#rules-for-parsing-integers" id="apis-for-creating-and-navigating-browsing-contexts-by-name:rules-for-parsing-integers">parsing
   <var>value</var> as an integer</a>.</p></li><li><p>If <var>parsed</var> is an error, then set it to 0.</p></li><li><p>Return false if <var>parsed</var> is 0, and true otherwise.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-name" data-dfn-type="attribute"><code>name</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-navigable">navigable</a> is null, then
   return the empty string.</p></li><li><p>Return <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-navigable-2">navigable</a>'s <a href="#nav-target" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-target">target name</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="apis-for-creating-and-navigating-browsing-contexts-by-name:dom-name"><a href="#dom-name">name</a></code> setter steps are:</p>

  <ol><li><p>If <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-navigable-3">navigable</a> is null, then
   return.</p></li><li><p>Set <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-navigable-4">navigable</a>'s <a href="#nav-active-history-entry" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-active-history-entry">active session history entry</a>'s <a href="#she-document-state" id="apis-for-creating-and-navigating-browsing-contexts-by-name:she-document-state">document state</a>'s <a href="#document-state-nav-target-name" id="apis-for-creating-and-navigating-browsing-contexts-by-name:document-state-nav-target-name">navigable target name</a> to the given value.</p></li></ol>
  </div>

  <p class="note">The name <a href="#resetBCName">gets reset</a> when the navigable is <a href="#navigate" id="apis-for-creating-and-navigating-browsing-contexts-by-name:navigate-4">navigated</a> to another <a href="#concept-origin" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-origin">origin</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-close" data-dfn-type="method"><code>close()</code></dfn> method steps
  are:</p>

  <ol><li><p>Let <var>thisTraversable</var> be <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-navigable-5">navigable</a>.</p></li><li><p>If <var>thisTraversable</var> is not a <a href="#top-level-traversable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:top-level-traversable">top-level traversable</a>, then
   return.</p></li><li><p>If <var>thisTraversable</var>'s <a href="#is-closing" id="apis-for-creating-and-navigating-browsing-contexts-by-name:is-closing">is closing</a> is true, then return.</p></li><li><p>Let <var>browsingContext</var> be <var>thisTraversable</var>'s <a href="#nav-bc" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-bc-4">active browsing context</a>.</p></li><li><p>Let <var>sourceSnapshotParams</var> be the result of <a href="#snapshotting-source-snapshot-params" id="apis-for-creating-and-navigating-browsing-contexts-by-name:snapshotting-source-snapshot-params">snapshotting source snapshot
   params</a> given <var>thisTraversable</var>'s <a href="#nav-document" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-document-2">active
   document</a>.</p></li><li>
    <p>If all the following are true:</p>

    <ul><li><p><var>thisTraversable</var> is <a href="#script-closable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:script-closable">script-closable</a>;</p></li><li><p>the <a href="#concept-incumbent-global" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-incumbent-global">incumbent global object</a>'s <a href="#window-bc" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-bc">browsing context</a> is <a href="#familiar-with" id="apis-for-creating-and-navigating-browsing-contexts-by-name:familiar-with">familiar with</a>
     <var>browsingContext</var>; and</p></li><li id="sandboxClose"><p>the <a href="#concept-incumbent-global" id="apis-for-creating-and-navigating-browsing-contexts-by-name:concept-incumbent-global-2">incumbent global
     object</a>'s <a href="#window-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-navigable-6">navigable</a> is <a href="#allowed-to-navigate" id="apis-for-creating-and-navigating-browsing-contexts-by-name:allowed-to-navigate">allowed by
     sandboxing to navigate</a> <var>thisTraversable</var>, given
     <var>sourceSnapshotParams</var>,</p></li></ul>

    <p>then:</p>

    <ol><li><p>Set <var>thisTraversable</var>'s <a href="#is-closing" id="apis-for-creating-and-navigating-browsing-contexts-by-name:is-closing-2">is closing</a> to true.</p></li><li><p><a href="#queue-a-task" id="apis-for-creating-and-navigating-browsing-contexts-by-name:queue-a-task">Queue a task</a> on the <a href="#dom-manipulation-task-source" id="apis-for-creating-and-navigating-browsing-contexts-by-name:dom-manipulation-task-source">DOM manipulation task source</a> to <a href="#definitely-close-a-top-level-traversable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:definitely-close-a-top-level-traversable">definitely close</a>
     <var>thisTraversable</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>A <a href="#navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:navigable">navigable</a> is <dfn id="script-closable">script-closable</dfn> if it is a <a href="#top-level-traversable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:top-level-traversable-2">top-level
  traversable</a>, and any of the following are true:</p>

  <ul><li>its <a href="#is-created-by-web-content" id="apis-for-creating-and-navigating-browsing-contexts-by-name:is-created-by-web-content">is created by web content</a> is true; or</li><li>its <a href="#tn-session-history-entries" id="apis-for-creating-and-navigating-browsing-contexts-by-name:tn-session-history-entries">session history entries</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="apis-for-creating-and-navigating-browsing-contexts-by-name:list-size" data-x-internal="list-size">size</a> is 1.</li></ul>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-closed" data-dfn-type="attribute"><code>closed</code></dfn> getter
  steps are to return true if <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-bc" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-bc-2">browsing context</a>
  is null or its <a href="#is-closing" id="apis-for-creating-and-navigating-browsing-contexts-by-name:is-closing-3">is closing</a> is true; otherwise false.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-stop" data-dfn-type="method"><code>stop()</code></dfn> method steps
  are:</p>

  <ol><li><p>If <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-navigable-7">navigable</a> is null, then
   return.</p></li><li><p><a href="#nav-stop" id="apis-for-creating-and-navigating-browsing-contexts-by-name:nav-stop">Stop loading</a> <a id="apis-for-creating-and-navigating-browsing-contexts-by-name:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="apis-for-creating-and-navigating-browsing-contexts-by-name:window-navigable-8">navigable</a>.</p></li></ol>
  </div>

  


  <h5 id="accessing-other-browsing-contexts"><span class="secno">7.2.2.2</span> Indexed access on the <code id="accessing-other-browsing-contexts:window"><a href="#window">Window</a></code> object<a href="#accessing-other-browsing-contexts" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-length" id="dom-length-dev">length</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/length" title="Returns the number of frames (either <frame> or <iframe> elements) in the window.">Window/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the number of <a href="#document-tree-child-navigables" id="accessing-other-browsing-contexts:document-tree-child-navigables">document-tree child navigables</a>.</p></dd><dt><code><var>window</var>[<var>index</var>]</code></dt><dd><p>Returns the <code id="accessing-other-browsing-contexts:windowproxy"><a href="#windowproxy">WindowProxy</a></code> corresponding to the indicated <a href="#document-tree-child-navigables" id="accessing-other-browsing-contexts:document-tree-child-navigables-2">document-tree child navigables</a>.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-length" data-dfn-type="attribute"><code>length</code></dfn> getter steps are
  to return <a id="accessing-other-browsing-contexts:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="accessing-other-browsing-contexts:concept-document-window">associated
  <code>Document</code></a>'s <a href="#document-tree-child-navigables" id="accessing-other-browsing-contexts:document-tree-child-navigables-3">document-tree child navigables</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="accessing-other-browsing-contexts:list-size" data-x-internal="list-size">size</a>.</p>
  </div>

  <p class="note">Indexed access to <a href="#document-tree-child-navigables" id="accessing-other-browsing-contexts:document-tree-child-navigables-4">document-tree child navigables</a> is defined through
  the <a href="#windowproxy-getownproperty">[[GetOwnProperty]]</a> internal method of the
  <code id="accessing-other-browsing-contexts:windowproxy-2"><a href="#windowproxy">WindowProxy</a></code> object.</p>

  


  <h5 id="named-access-on-the-window-object"><span class="secno">7.2.2.3</span> Named access on the <code id="named-access-on-the-window-object:window"><a href="#window">Window</a></code> object<a href="#named-access-on-the-window-object" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>window</var>[<var>name</var>]</code></dt><dd>
    <p>Returns the indicated element or collection of elements.</p>

    <p>As a general rule, relying on this will lead to brittle code. Which IDs end up mapping to
    this API can vary over time, as new features are added to the web platform, for example. Instead
    of this, use <code>document.getElementById()</code> or <code>document.querySelector()</code>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p id="child-browsing-context-name-property-set"><span id="document-tree-child-browsing-context-name-property-set"></span>The <dfn id="document-tree-child-navigable-target-name-property-set">document-tree child
  navigable target name property set</dfn> of a <code id="named-access-on-the-window-object:window-2"><a href="#window">Window</a></code> object <var>window</var> is the
  return value of running these steps:</p>

  <ol><li><p>Let <var>children</var> be the <a href="#document-tree-child-navigables" id="named-access-on-the-window-object:document-tree-child-navigables">document-tree child navigables</a> of
   <var>window</var>'s <a href="#concept-document-window" id="named-access-on-the-window-object:concept-document-window">associated
   <code>Document</code></a>.</p></li><li><p>Let <var>firstNamedChildren</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-set" id="named-access-on-the-window-object:set" data-x-internal="set">ordered
   set</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="named-access-on-the-window-object:list-iterate" data-x-internal="list-iterate">For each</a> <var>navigable</var> of <var>children</var>:</p>

    <ol><li><p>Let <var>name</var> be <var>navigable</var>'s <a href="#nav-target" id="named-access-on-the-window-object:nav-target">target name</a>.</p></li><li><p>If <var>name</var> is the empty string, then <a id="named-access-on-the-window-object:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>firstNamedChildren</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="named-access-on-the-window-object:list-contains" data-x-internal="list-contains">contains</a> a
     <a href="#navigable" id="named-access-on-the-window-object:navigable">navigable</a> whose <a href="#nav-target" id="named-access-on-the-window-object:nav-target-2">target name</a> is <var>name</var>,
     then <a id="named-access-on-the-window-object:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="named-access-on-the-window-object:list-append" data-x-internal="list-append">Append</a> <var>navigable</var> to
     <var>firstNamedChildren</var>.</p></li></ol>
   </li><li><p>Let <var>names</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-set" id="named-access-on-the-window-object:set-2" data-x-internal="set">ordered set</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="named-access-on-the-window-object:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>navigable</var> of
    <var>firstNamedChildren</var>:</p>

    <ol><li><p>Let <var>name</var> be <var>navigable</var>'s <a href="#nav-target" id="named-access-on-the-window-object:nav-target-3">target name</a>.</p></li><li><p>If <var>navigable</var>'s <a href="#nav-document" id="named-access-on-the-window-object:nav-document">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="named-access-on-the-window-object:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is <a href="#same-origin" id="named-access-on-the-window-object:same-origin">same origin</a> with
     <var>window</var>'s <a href="#relevant-settings-object" id="named-access-on-the-window-object:relevant-settings-object">relevant settings object</a>'s <a href="#concept-settings-object-origin" id="named-access-on-the-window-object:concept-settings-object-origin">origin</a>, then <a href="https://infra.spec.whatwg.org/#list-append" id="named-access-on-the-window-object:list-append-2" data-x-internal="list-append">append</a> <var>name</var> to <var>names</var>.</p></li></ol>
   </li><li><p>Return <var>names</var>.</p></li></ol>
  </div>

  <div class="example">
   <p>The two seperate iterations mean that in the following example, hosted on <code>https://example.org/</code>, assuming <code>https://elsewhere.example/</code>
   sets <code id="named-access-on-the-window-object:dom-name"><a href="#dom-name">window.name</a></code> to "<code>spices</code>", evaluating
   <code>window.spices</code> after everything has loaded will yield undefined:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">https://elsewhere.example.com/</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">spices</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div data-algorithm="">
  <p>The <code id="named-access-on-the-window-object:window-3"><a href="#window">Window</a></code> object <a href="https://webidl.spec.whatwg.org/#dfn-support-named-properties" id="named-access-on-the-window-object:support-named-properties" data-x-internal="support-named-properties">supports named
  properties</a>. The <a id="named-access-on-the-window-object:supported-property-names" href="https://webidl.spec.whatwg.org/#dfn-supported-property-names" data-x-internal="supported-property-names">supported property names</a> of a <code id="named-access-on-the-window-object:window-4"><a href="#window">Window</a></code> object
  <var>window</var> at any moment consist of the following, in <a id="named-access-on-the-window-object:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a> according to
  the element that contributed them, ignoring later duplicates:</p>

  
  <ul><li><p><var>window</var>'s <a href="#document-tree-child-navigable-target-name-property-set" id="named-access-on-the-window-object:document-tree-child-navigable-target-name-property-set">document-tree child navigable target name property
   set</a>;</p></li><li><p>the value of the <code>name</code> content attribute for all <code id="named-access-on-the-window-object:the-embed-element"><a href="#the-embed-element">embed</a></code>,
   <code id="named-access-on-the-window-object:the-form-element"><a href="#the-form-element">form</a></code>, <code id="named-access-on-the-window-object:the-img-element"><a href="#the-img-element">img</a></code>, and <code id="named-access-on-the-window-object:the-object-element"><a href="#the-object-element">object</a></code> elements that
   have a non-empty <code>name</code> content attribute and are <a id="named-access-on-the-window-object:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document
   tree</a> with <var>window</var>'s <a href="#concept-document-window" id="named-access-on-the-window-object:concept-document-window-2">associated
   <code>Document</code></a> as their <a id="named-access-on-the-window-object:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>; and</p></li><li><p>the value of the <code id="named-access-on-the-window-object:the-id-attribute"><a href="#the-id-attribute">id</a></code> content attribute for all <a href="#html-elements" id="named-access-on-the-window-object:html-elements">HTML
   elements</a> that have a non-empty <code id="named-access-on-the-window-object:the-id-attribute-2"><a href="#the-id-attribute">id</a></code> content attribute and are
   <a id="named-access-on-the-window-object:in-a-document-tree-2" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a> with <var>window</var>'s <a href="#concept-document-window" id="named-access-on-the-window-object:concept-document-window-3">associated <code>Document</code></a> as their
   <a id="named-access-on-the-window-object:root-2" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p id="dom-window-nameditem">To <a id="named-access-on-the-window-object:determine-the-value-of-a-named-property" href="https://webidl.spec.whatwg.org/#dfn-determine-the-value-of-a-named-property" data-x-internal="determine-the-value-of-a-named-property">determine the value of a named property</a>
  <var>name</var> in a <code id="named-access-on-the-window-object:window-5"><a href="#window">Window</a></code> object <var>window</var>, the user agent must return the
  value obtained using the following steps:</p>

  <ol><li>
    <p>Let <var>objects</var> be the list of <a href="#dom-window-nameditem-filter" id="named-access-on-the-window-object:dom-window-nameditem-filter">named
    objects</a> of <var>window</var> with the name <var>name</var>.</p>

    <p class="note">There will be at least one such object, since the algorithm would otherwise not
    have been <a href="https://webidl.spec.whatwg.org/#named-properties-object-getownproperty" id="named-access-on-the-window-object:named-properties-object-getownproperty" data-x-internal="named-properties-object-getownproperty">invoked by Web IDL</a>.</p>
   </li><li>
    <p>If <var>objects</var> contains a <a href="#navigable" id="named-access-on-the-window-object:navigable-2">navigable</a>, then:</p>

    <ol><li><p>Let <var>container</var> be the first <a href="#navigable-container" id="named-access-on-the-window-object:navigable-container">navigable container</a> in
     <var>window</var>'s <a href="#concept-document-window" id="named-access-on-the-window-object:concept-document-window-4">associated
     <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="named-access-on-the-window-object:descendant" data-x-internal="descendant">descendants</a> whose
     <a href="#content-navigable" id="named-access-on-the-window-object:content-navigable">content navigable</a> is in <var>objects</var>.</p></li><li><p>Return <var>container</var>'s <a href="#content-navigable" id="named-access-on-the-window-object:content-navigable-2">content navigable</a>'s <a href="#nav-wp" id="named-access-on-the-window-object:nav-wp">active <code>WindowProxy</code></a>.</p></li></ol>
   </li><li><p>Otherwise, if <var>objects</var> has only one element, return that element.</p></li><li><p>Otherwise, return an <code id="named-access-on-the-window-object:htmlcollection"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at <var>window</var>'s <a href="#concept-document-window" id="named-access-on-the-window-object:concept-document-window-5">associated <code>Document</code></a>, whose filter matches
   only <a href="#dom-window-nameditem-filter" id="named-access-on-the-window-object:dom-window-nameditem-filter-2">named objects</a> of <var>window</var> with
   the name <var>name</var>. (By definition, these will all be elements.)</p></li></ol>
  </div>

  <div data-algorithm="">
  <p><dfn id="dom-window-nameditem-filter">Named objects</dfn> of <code id="named-access-on-the-window-object:window-6"><a href="#window">Window</a></code> object
  <var>window</var> with the name <var>name</var>, for the purposes of the above algorithm, consist
  of the following:</p>

  
  <ul><li><p><a href="#document-tree-child-navigables" id="named-access-on-the-window-object:document-tree-child-navigables-2">document-tree child navigables</a> of <var>window</var>'s <a href="#concept-document-window" id="named-access-on-the-window-object:concept-document-window-6">associated <code>Document</code></a> whose <a href="#nav-target" id="named-access-on-the-window-object:nav-target-4">target name</a> is <var>name</var>;</p></li><li><p><code id="named-access-on-the-window-object:the-embed-element-2"><a href="#the-embed-element">embed</a></code>, <code id="named-access-on-the-window-object:the-form-element-2"><a href="#the-form-element">form</a></code>, <code id="named-access-on-the-window-object:the-img-element-2"><a href="#the-img-element">img</a></code>, or
   <code id="named-access-on-the-window-object:the-object-element-2"><a href="#the-object-element">object</a></code> elements that have a <code>name</code> content attribute whose
   value is <var>name</var> and are <a id="named-access-on-the-window-object:in-a-document-tree-3" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a> with <var>window</var>'s <a href="#concept-document-window" id="named-access-on-the-window-object:concept-document-window-7">associated <code>Document</code></a> as their
   <a id="named-access-on-the-window-object:root-3" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>; and</p></li><li><p><a href="#html-elements" id="named-access-on-the-window-object:html-elements-2">HTML elements</a> that have an <code id="named-access-on-the-window-object:the-id-attribute-3"><a href="#the-id-attribute">id</a></code> content attribute
   whose value is <var>name</var> and are <a id="named-access-on-the-window-object:in-a-document-tree-4" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a> with <var>window</var>'s
   <a href="#concept-document-window" id="named-access-on-the-window-object:concept-document-window-8">associated <code>Document</code></a> as their
   <a id="named-access-on-the-window-object:root-4" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>.</p></li></ul>
  </div>

  <p class="note">Since the <code id="named-access-on-the-window-object:window-7"><a href="#window">Window</a></code> interface has the <code id="named-access-on-the-window-object:global"><a data-x-internal="global" href="https://webidl.spec.whatwg.org/#Global">[Global]</a></code> extended attribute, its named properties follow the rules for
  <a href="https://webidl.spec.whatwg.org/#dfn-named-properties-object" id="named-access-on-the-window-object:named-properties-object" data-x-internal="named-properties-object">named properties objects</a> rather than <a href="https://webidl.spec.whatwg.org/#dfn-legacy-platform-object" id="named-access-on-the-window-object:legacy-platform-object" data-x-internal="legacy-platform-object">legacy platform objects</a>.</p>

  


  <h5 id="navigating-nested-browsing-contexts-in-the-dom"><span class="secno">7.2.2.4</span> Accessing related windows<a href="#navigating-nested-browsing-contexts-in-the-dom" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-top" id="dom-top-dev">top</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/top" title="Returns a reference to the topmost window in the window hierarchy.">Window/top</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the <code id="navigating-nested-browsing-contexts-in-the-dom:windowproxy"><a href="#windowproxy">WindowProxy</a></code> for the <a href="#top-level-traversable" id="navigating-nested-browsing-contexts-in-the-dom:top-level-traversable">top-level traversable</a>.</p></dd><dt><code><var>window</var>.<a href="#dom-opener" id="dom-opener-dev">opener</a> [ = <var>value</var> ]</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/opener" title="The Window interface's opener property returns a reference to the window that opened the window, either with open(), or by navigating a link with a target attribute.">Window/opener</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="navigating-nested-browsing-contexts-in-the-dom:windowproxy-2"><a href="#windowproxy">WindowProxy</a></code> for the <a href="#opener-browsing-context" id="navigating-nested-browsing-contexts-in-the-dom:opener-browsing-context">opener browsing context</a>.</p>

    <p>Returns null if there isn't one or if it has been set to null.</p>

    <p>Can be set to null.</p>
   </dd><dt><code><var>window</var>.<a href="#dom-parent" id="dom-parent-dev">parent</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/parent" title="The Window.parent property is a reference to the parent of the current window or subframe.">Window/parent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Returns the <code id="navigating-nested-browsing-contexts-in-the-dom:windowproxy-3"><a href="#windowproxy">WindowProxy</a></code> for the <a href="#nav-parent" id="navigating-nested-browsing-contexts-in-the-dom:nav-parent">parent
   navigable</a>.</p></dd><dt><code><var>window</var>.<a href="#dom-frameelement" id="dom-frameelement-dev">frameElement</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/frameElement" title="The Window.frameElement property returns the element (such as <iframe> or <object>) in which the window is embedded.">Window/frameElement</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="#navigable-container" id="navigating-nested-browsing-contexts-in-the-dom:navigable-container">navigable container</a> element.</p>

    <p>Returns null if there isn't one, and in cross-origin situations.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-top" data-dfn-type="attribute"><code>top</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="navigating-nested-browsing-contexts-in-the-dom:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="navigating-nested-browsing-contexts-in-the-dom:window-navigable">navigable</a> is null, then
   return null.</p></li><li><p>Return <a id="navigating-nested-browsing-contexts-in-the-dom:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="navigating-nested-browsing-contexts-in-the-dom:window-navigable-2">navigable</a>'s <a href="#nav-top" id="navigating-nested-browsing-contexts-in-the-dom:nav-top">top-level traversable</a>'s <a href="#nav-wp" id="navigating-nested-browsing-contexts-in-the-dom:nav-wp">active
   <code>WindowProxy</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-opener" data-dfn-type="attribute"><code>opener</code></dfn> getter steps
  are:</p>

  <ol><li><p>Let <var>current</var> be <a id="navigating-nested-browsing-contexts-in-the-dom:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-bc" id="navigating-nested-browsing-contexts-in-the-dom:window-bc">browsing
   context</a>.</p></li><li><p>If <var>current</var> is null, then return null.</p></li><li><p>If <var>current</var>'s <a href="#opener-browsing-context" id="navigating-nested-browsing-contexts-in-the-dom:opener-browsing-context-2">opener browsing context</a> is null, then return
   null.</p></li><li><p>Return <var>current</var>'s <a href="#opener-browsing-context" id="navigating-nested-browsing-contexts-in-the-dom:opener-browsing-context-3">opener browsing context</a>'s
   <code id="navigating-nested-browsing-contexts-in-the-dom:windowproxy-4"><a href="#windowproxy">WindowProxy</a></code> object.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="navigating-nested-browsing-contexts-in-the-dom:dom-opener"><a href="#dom-opener">opener</a></code> setter steps are:</p>

  <ol><li><p>If the given value is null and <a id="navigating-nested-browsing-contexts-in-the-dom:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-bc" id="navigating-nested-browsing-contexts-in-the-dom:window-bc-2">browsing
   context</a> is non-null, then set <a id="navigating-nested-browsing-contexts-in-the-dom:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-bc" id="navigating-nested-browsing-contexts-in-the-dom:window-bc-3">browsing
   context</a>'s <a href="#opener-browsing-context" id="navigating-nested-browsing-contexts-in-the-dom:opener-browsing-context-4">opener browsing context</a> to null.</p></li><li><p>If the given value is non-null, then perform ?
   <a id="navigating-nested-browsing-contexts-in-the-dom:definepropertyorthrow" href="https://tc39.es/ecma262/#sec-definepropertyorthrow" data-x-internal="definepropertyorthrow">DefinePropertyOrThrow</a>(<a id="navigating-nested-browsing-contexts-in-the-dom:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, "<code>opener</code>", {
   [[Value]]: the given value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true
   }).</p></li></ol>
  </div>

  <div class="note">
   <p>Setting <code id="navigating-nested-browsing-contexts-in-the-dom:dom-opener-2"><a href="#dom-opener">window.opener</a></code> to null clears the <a href="#opener-browsing-context" id="navigating-nested-browsing-contexts-in-the-dom:opener-browsing-context-5">opener
   browsing context</a> reference. In practice, this prevents future scripts from accessing their
   <a href="#opener-browsing-context" id="navigating-nested-browsing-contexts-in-the-dom:opener-browsing-context-6">opener browsing context</a>'s <code id="navigating-nested-browsing-contexts-in-the-dom:window"><a href="#window">Window</a></code> object.</p>

   <p>By default, scripts can access their <a href="#opener-browsing-context" id="navigating-nested-browsing-contexts-in-the-dom:opener-browsing-context-7">opener browsing context</a>'s
   <code id="navigating-nested-browsing-contexts-in-the-dom:window-2"><a href="#window">Window</a></code> object through the <code id="navigating-nested-browsing-contexts-in-the-dom:dom-opener-3"><a href="#dom-opener">window.opener</a></code> getter.
   E.g., a script can set <code>window.opener.location</code>, causing the <a href="#opener-browsing-context" id="navigating-nested-browsing-contexts-in-the-dom:opener-browsing-context-8">opener
   browsing context</a> to navigate.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-parent" data-dfn-type="attribute"><code>parent</code></dfn> getter steps
  are:</p>

  <ol><li><p>Let <var>navigable</var> be <a id="navigating-nested-browsing-contexts-in-the-dom:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigable" id="navigating-nested-browsing-contexts-in-the-dom:window-navigable-3">navigable</a>.</p></li><li><p>If <var>navigable</var> is null, then return null.</p></li><li><p>If <var>navigable</var>'s <a href="#nav-parent" id="navigating-nested-browsing-contexts-in-the-dom:nav-parent-2">parent</a> is not null, then set
   <var>navigable</var> to <var>navigable</var>'s <a href="#nav-parent" id="navigating-nested-browsing-contexts-in-the-dom:nav-parent-3">parent</a>.</p></li><li><p>Return <var>navigable</var>'s <a href="#nav-wp" id="navigating-nested-browsing-contexts-in-the-dom:nav-wp-2">active
   <code>WindowProxy</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-frameelement" data-dfn-type="attribute"><code>frameElement</code></dfn>
  getter steps are:</p>

  <ol><li><p>Let <var>current</var> be <a id="navigating-nested-browsing-contexts-in-the-dom:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#node-navigable" id="navigating-nested-browsing-contexts-in-the-dom:node-navigable">node navigable</a>.</p></li><li><p>If <var>current</var> is null, then return null.</p></li><li><p>Let <var>container</var> be <var>current</var>'s <a href="#nav-container" id="navigating-nested-browsing-contexts-in-the-dom:nav-container">container</a>.</p></li><li><p>If <var>container</var> is null, then return null.</p></li><li><p>If <var>container</var>'s <a id="navigating-nested-browsing-contexts-in-the-dom:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="navigating-nested-browsing-contexts-in-the-dom:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="navigating-nested-browsing-contexts-in-the-dom:same-origin-domain">same origin-domain</a> with the
   <a href="#current-settings-object" id="navigating-nested-browsing-contexts-in-the-dom:current-settings-object">current settings object</a>'s <a href="#concept-settings-object-origin" id="navigating-nested-browsing-contexts-in-the-dom:concept-settings-object-origin">origin</a>, then return null.</p></li><li><p>Return <var>container</var>.</p></li></ol>
  </div>

  <div class="example">
   <p>An example of when these properties can return null is as follows:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- u="">"use strict"</c-><c- p="">;</c->
<c- a="">const</c-> element <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"iframe"</c-><c- p="">);</c->
<c- a="">const</c-> iframeWindow <c- o="">=</c-> element<c- p="">.</c->contentWindow<c- p="">;</c->
element<c- p="">.</c->remove<c- p="">();</c->

console<c- p="">.</c->assert<c- p="">(</c->iframeWindow<c- p="">.</c->top <c- o="">===</c-> <c- kc="">null</c-><c- p="">);</c->
console<c- p="">.</c->assert<c- p="">(</c->iframeWindow<c- p="">.</c->parent <c- o="">===</c-> <c- kc="">null</c-><c- p="">);</c->
console<c- p="">.</c->assert<c- p="">(</c->iframeWindow<c- p="">.</c->frameElement <c- o="">===</c-> <c- kc="">null</c-><c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>Here the <a href="#browsing-context" id="navigating-nested-browsing-contexts-in-the-dom:browsing-context">browsing context</a> corresponding to <code>iframeWindow</code>
   was <a href="#destroy-a-document" id="navigating-nested-browsing-contexts-in-the-dom:destroy-a-document">nulled out</a> when <code>element</code> was
   removed from the document.</p>
  </div>

  


  <h5 id="browser-interface-elements"><span class="secno">7.2.2.5</span> Historical browser interface element APIs<a href="#browser-interface-elements" class="self-link"></a></h5>

  <p>For historical reasons, the <code id="browser-interface-elements:window"><a href="#window">Window</a></code> interface had some properties that represented
  the visibility of certain web browser interface elements.</p>

  <p>For privacy and interoperability reasons, those properties now return values that
  represent whether the <code id="browser-interface-elements:window-2"><a href="#window">Window</a></code>'s <a href="#window-bc" id="browser-interface-elements:window-bc">browsing context</a>'s
  <a href="#is-popup" id="browser-interface-elements:is-popup">is popup</a> property is true or false.</p>

  

  <p>Each interface element is represented by a <code id="browser-interface-elements:barprop"><a href="#barprop">BarProp</a></code> object:</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BarProp" title="The BarProp interface of the Document Object Model represents the web browser user interface elements that are exposed to scripts in web pages. Each of the following interface elements are represented by a BarProp object.">BarProp</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="barprop" data-dfn-type="interface"><c- g="">BarProp</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-barprop-visible" id="browser-interface-elements:dom-barprop-visible"><c- g="">visible</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-window-locationbar" id="dom-window-locationbar-dev">locationbar</a>.<a href="#dom-barprop-visible" id="dom-barprop-visible-dev">visible</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/locationbar" title="Returns the locationbar object.">Window/locationbar</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>window</var>.<a href="#dom-window-menubar" id="dom-window-menubar-dev">menubar</a>.<a href="#dom-barprop-visible" id="browser-interface-elements:dom-barprop-visible-2">visible</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/menubar" title="Returns the menubar object.">Window/menubar</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>window</var>.<a href="#dom-window-personalbar" id="dom-window-personalbar-dev">personalbar</a>.<a href="#dom-barprop-visible" id="browser-interface-elements:dom-barprop-visible-3">visible</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/personalbar" title="Returns the personalbar object.">Window/personalbar</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>window</var>.<a href="#dom-window-scrollbars" id="dom-window-scrollbars-dev">scrollbars</a>.<a href="#dom-barprop-visible" id="browser-interface-elements:dom-barprop-visible-4">visible</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollbars" title="Returns the scrollbars object.">Window/scrollbars</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dt><code><var>window</var>.<a href="#dom-window-statusbar" id="dom-window-statusbar-dev">statusbar</a>.<a href="#dom-barprop-visible" id="browser-interface-elements:dom-barprop-visible-5">visible</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/statusbar" title="Returns the statusbar object.">Window/statusbar</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>window</var>.<a href="#dom-window-toolbar" id="dom-window-toolbar-dev">toolbar</a>.<a href="#dom-barprop-visible" id="browser-interface-elements:dom-barprop-visible-6">visible</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/toolbar" title="Returns the toolbar object.">Window/toolbar</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns true if the <code id="browser-interface-elements:window-3"><a href="#window">Window</a></code> is not a popup; otherwise, returns false.</p></dd></dl>

  

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BarProp/visible" title="The visible read-only property of the BarProp interface returns true if the user interface element it represents is visible.">BarProp/visible</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="BarProp" id="dom-barprop-visible" data-dfn-type="attribute"><code>visible</code></dfn> getter
  steps are:</p>

  <ol><li><p>Let <var>browsingContext</var> be <a id="browser-interface-elements:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="browser-interface-elements:concept-relevant-global">relevant global
   object</a>'s <a href="#window-bc" id="browser-interface-elements:window-bc-2">browsing context</a>.</p></li><li><p>If <var>browsingContext</var> is null, then return true.</p></li><li><p>Return the negation of <var>browsingContext</var>'s <a href="#bc-tlbc" id="browser-interface-elements:bc-tlbc">top-level
   browsing context</a>'s <a href="#is-popup" id="browser-interface-elements:is-popup-2">is popup</a>.</p></li></ol>
  </div>

  <p>The following <code id="browser-interface-elements:barprop-2"><a href="#barprop">BarProp</a></code> objects must exist for each <code id="browser-interface-elements:window-4"><a href="#window">Window</a></code> object:</p>

  <dl><dt><dfn id="the-location-bar-barprop-object">The location bar <code>BarProp</code> object</dfn></dt><dd>Historically represented the user interface element that contains a control that displays the
   browser's location bar.</dd><dt><dfn id="the-menu-bar-barprop-object">The menu bar <code>BarProp</code> object</dfn></dt><dd>Historically represented the user interface element that contains a list of commands in menu
   form, or some similar interface concept.</dd><dt><dfn id="the-personal-bar-barprop-object">The personal bar <code>BarProp</code> object</dfn></dt><dd>Historically represented the user interface element that contains links to the user's
   favorite pages, or some similar interface concept.</dd><dt><dfn id="the-scrollbar-barprop-object">The scrollbar <code>BarProp</code> object</dfn></dt><dd>Historically represented the user interface element that contains a scrolling mechanism, or
   some similar interface concept.</dd><dt><dfn id="the-status-bar-barprop-object">The status bar <code>BarProp</code> object</dfn></dt><dd>Historically represented a user interface element found immediately below or after the
   document, as appropriate for the user's media, which typically provides information about ongoing
   network activity or information about elements that the user's pointing device is currently
   indicating.</dd><dt><dfn id="the-toolbar-barprop-object">The toolbar <code>BarProp</code> object</dfn></dt><dd>Historically represented the user interface element found immediately above or before the
   document, as appropriate for the user's media, which typically provides <a href="#apply-the-traverse-history-step" id="browser-interface-elements:apply-the-traverse-history-step">session history traversal</a> controls (back and forward buttons,
   reload buttons, etc.).</dd></dl>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-locationbar" data-dfn-type="attribute"><code>locationbar</code></dfn>
  attribute must return <a href="#the-location-bar-barprop-object" id="browser-interface-elements:the-location-bar-barprop-object">the location bar <code>BarProp</code> object</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-menubar" data-dfn-type="attribute"><code>menubar</code></dfn>
  attribute must return <a href="#the-menu-bar-barprop-object" id="browser-interface-elements:the-menu-bar-barprop-object">the menu bar <code>BarProp</code> object</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-personalbar" data-dfn-type="attribute"><code>personalbar</code></dfn>
  attribute must return <a href="#the-personal-bar-barprop-object" id="browser-interface-elements:the-personal-bar-barprop-object">the personal bar <code>BarProp</code> object</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-scrollbars" data-dfn-type="attribute"><code>scrollbars</code></dfn>
  attribute must return <a href="#the-scrollbar-barprop-object" id="browser-interface-elements:the-scrollbar-barprop-object">the scrollbar <code>BarProp</code> object</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-statusbar" data-dfn-type="attribute"><code>statusbar</code></dfn>
  attribute must return <a href="#the-status-bar-barprop-object" id="browser-interface-elements:the-status-bar-barprop-object">the status bar <code>BarProp</code> object</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-toolbar" data-dfn-type="attribute"><code>toolbar</code></dfn>
  attribute must return <a href="#the-toolbar-barprop-object" id="browser-interface-elements:the-toolbar-barprop-object">the toolbar <code>BarProp</code> object</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>For historical reasons, the <dfn data-dfn-for="Window" id="dom-window-status" data-dfn-type="attribute"><code>status</code></dfn> attribute on the <code id="browser-interface-elements:window-5"><a href="#window">Window</a></code> object must,
  on getting, return the last string it was set to, and on setting, must set itself to the new
  value. When the <code id="browser-interface-elements:window-6"><a href="#window">Window</a></code> object is created, the attribute must be set to the empty
  string. It does not do anything else.</p>
  </div>


  <h5 id="script-settings-for-window-objects"><span class="secno">7.2.2.6</span> Script settings for <code id="script-settings-for-window-objects:window"><a href="#window">Window</a></code> objects<a href="#script-settings-for-window-objects" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="set-up-a-window-environment-settings-object">set up a window environment settings object</dfn>, given a <a id="script-settings-for-window-objects:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>
  <var>creationURL</var>, a <a id="script-settings-for-window-objects:javascript-execution-context" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript execution context</a> <var>execution context</var>,
  null or an <a href="#environment" id="script-settings-for-window-objects:environment">environment</a> <var>reservedEnvironment</var>, a <a id="script-settings-for-window-objects:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>
  <var>topLevelCreationURL</var>, and an <a href="#concept-origin" id="script-settings-for-window-objects:concept-origin">origin</a> <var>topLevelOrigin</var>, run these
  steps:</p>

  <ol><li><p>Let <var>realm</var> be the value of <var>execution context</var>'s Realm
   component.</p></li><li><p>Let <var>window</var> be <var>realm</var>'s <a href="#concept-realm-global" id="script-settings-for-window-objects:concept-realm-global">global
   object</a>.</p></li><li>
    <p>Let <var>settings object</var> be a new <a href="#environment-settings-object" id="script-settings-for-window-objects:environment-settings-object">environment settings object</a> whose
    algorithms are defined as follows:</p>

    <dl><dt>The <a href="#realm-execution-context" id="script-settings-for-window-objects:realm-execution-context">realm execution context</a></dt><dd>
      <p>Return <var>execution context</var>.</p>
     </dd><dt>The <a href="#concept-settings-object-module-map" id="script-settings-for-window-objects:concept-settings-object-module-map">module map</a></dt><dd>
      <p>Return the <a href="#concept-document-module-map" id="script-settings-for-window-objects:concept-document-module-map">module map</a> of
      <var>window</var>'s <a href="#concept-document-window" id="script-settings-for-window-objects:concept-document-window">associated
      <code>Document</code></a>.</p>
     </dd><dt>The <a href="#api-base-url" id="script-settings-for-window-objects:api-base-url">API base URL</a></dt><dd>
      <p>Return the current <a href="#document-base-url" id="script-settings-for-window-objects:document-base-url">base URL</a> of <var>window</var>'s
      <a href="#concept-document-window" id="script-settings-for-window-objects:concept-document-window-2">associated <code>Document</code></a>.</p>
     </dd><dt>The <a href="#concept-settings-object-origin" id="script-settings-for-window-objects:concept-settings-object-origin">origin</a></dt><dd>
      <p>Return the <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="script-settings-for-window-objects:concept-document-origin" data-x-internal="concept-document-origin">origin</a> of <var>window</var>'s
      <a href="#concept-document-window" id="script-settings-for-window-objects:concept-document-window-3">associated <code>Document</code></a>.</p>
     </dd><dt>The <a href="#concept-settings-object-has-cross-site-ancestor" id="script-settings-for-window-objects:concept-settings-object-has-cross-site-ancestor">has cross-site
     ancestor</a></dt><dd>
      <ol><li><p>If <var>window</var>'s <a href="#navigable" id="script-settings-for-window-objects:navigable">navigable</a>'s <a href="#nav-parent" id="script-settings-for-window-objects:nav-parent">parent</a> is null, then return false.</p></li><li><p>Let <var>parentDocument</var> be <var>window</var>'s <a href="#navigable" id="script-settings-for-window-objects:navigable-2">navigable</a>'s <a href="#nav-parent" id="script-settings-for-window-objects:nav-parent-2">parent</a>'s <a href="#nav-document" id="script-settings-for-window-objects:nav-document">active
       document</a>.</p></li><li><p>If <var>parentDocument</var>'s <a href="#relevant-settings-object" id="script-settings-for-window-objects:relevant-settings-object">relevant settings object</a>'s <a href="#concept-settings-object-has-cross-site-ancestor" id="script-settings-for-window-objects:concept-settings-object-has-cross-site-ancestor-2">has cross-site ancestor</a> is
       true, then return true.</p></li><li><p>If <var>parentDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="script-settings-for-window-objects:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>
       is not <a href="#same-site" id="script-settings-for-window-objects:same-site">same site</a> with <var>window</var>'s <a href="#concept-document-window" id="script-settings-for-window-objects:concept-document-window-4">associated <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="script-settings-for-window-objects:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a>, then return true.</p></li><li><p>Return false.</p></li></ol>
     </dd><dt>The <a href="#concept-settings-object-policy-container" id="script-settings-for-window-objects:concept-settings-object-policy-container">policy container</a></dt><dd>
      <p>Return the <a href="#concept-document-policy-container" id="script-settings-for-window-objects:concept-document-policy-container">policy container</a> of
      <var>window</var>'s <a href="#concept-document-window" id="script-settings-for-window-objects:concept-document-window-5">associated
      <code>Document</code></a>.</p>
     </dd><dt>The <a href="#concept-settings-object-cross-origin-isolated-capability" id="script-settings-for-window-objects:concept-settings-object-cross-origin-isolated-capability">cross-origin
     isolated capability</a></dt><dd>
      <p>Return true if both of the following hold, and false otherwise:</p>
      <ul><li><p><var>realm</var>'s <a id="script-settings-for-window-objects:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>'s <a href="#agent-cluster-cross-origin-isolation" id="script-settings-for-window-objects:agent-cluster-cross-origin-isolation">cross-origin-isolation mode</a> is "<code id="script-settings-for-window-objects:cross-origin-isolation-concrete"><a href="#cross-origin-isolation-concrete">concrete</a></code>", and</p></li><li><p><var>window</var>'s <a href="#concept-document-window" id="script-settings-for-window-objects:concept-document-window-6">associated
       <code>Document</code></a> is <a href="#allowed-to-use" id="script-settings-for-window-objects:allowed-to-use">allowed to use</a> the "<code id="script-settings-for-window-objects:cross-origin-isolated-feature"><a href="#cross-origin-isolated-feature">cross-origin-isolated</a></code>" feature.</p></li></ul>
     </dd><dt>The <a href="#concept-settings-object-time-origin" id="script-settings-for-window-objects:concept-settings-object-time-origin">time origin</a></dt><dd>
      <p>Return <var>window</var>'s <a href="#concept-document-window" id="script-settings-for-window-objects:concept-document-window-7">associated
      <code>Document</code></a>'s <a href="#load-timing-info" id="script-settings-for-window-objects:load-timing-info">load timing info</a>'s <a href="#navigation-start-time" id="script-settings-for-window-objects:navigation-start-time">navigation start
      time</a>.</p>
     </dd></dl>
   </li><li>
    <p>If <var>reservedEnvironment</var> is non-null, then:</p>

    <ol><li><p>Set <var>settings object</var>'s <a href="#concept-environment-id" id="script-settings-for-window-objects:concept-environment-id">id</a> to
     <var>reservedEnvironment</var>'s <a href="#concept-environment-id" id="script-settings-for-window-objects:concept-environment-id-2">id</a>, <a href="#concept-environment-target-browsing-context" id="script-settings-for-window-objects:concept-environment-target-browsing-context">target browsing context</a> to
     <var>reservedEnvironment</var>'s <a href="#concept-environment-target-browsing-context" id="script-settings-for-window-objects:concept-environment-target-browsing-context-2">target browsing context</a>, and <a href="#concept-environment-active-service-worker" id="script-settings-for-window-objects:concept-environment-active-service-worker">active service worker</a> to
     <var>reservedEnvironment</var>'s <a href="#concept-environment-active-service-worker" id="script-settings-for-window-objects:concept-environment-active-service-worker-2">active service worker</a>.</p></li><li>
      <p>Set <var>reservedEnvironment</var>'s <a href="#concept-environment-id" id="script-settings-for-window-objects:concept-environment-id-3">id</a> to
      the empty string.</p>

      <p class="note">The identity of the reserved environment is considered to be fully
      transferred to the created <a href="#environment-settings-object" id="script-settings-for-window-objects:environment-settings-object-2">environment settings object</a>. The reserved environment
      is not searchable by the <a href="#environment" id="script-settings-for-window-objects:environment-2">environment</a>’s <a href="#concept-environment-id" id="script-settings-for-window-objects:concept-environment-id-4">id</a> from this point on.</p>
     </li></ol>
   </li><li><p>Otherwise, set <var>settings object</var>'s <a href="#concept-environment-id" id="script-settings-for-window-objects:concept-environment-id-5">id</a> to a new unique opaque string, <var>settings
   object</var>'s <a href="#concept-environment-target-browsing-context" id="script-settings-for-window-objects:concept-environment-target-browsing-context-3">target browsing
   context</a> to null, and <var>settings object</var>'s <a href="#concept-environment-active-service-worker" id="script-settings-for-window-objects:concept-environment-active-service-worker-3">active service worker</a> to null.</p></li><li><p>Set <var>settings object</var>'s <a href="#concept-environment-creation-url" id="script-settings-for-window-objects:concept-environment-creation-url">creation
   URL</a> to <var>creationURL</var>, <var>settings object</var>'s <a href="#concept-environment-top-level-creation-url" id="script-settings-for-window-objects:concept-environment-top-level-creation-url">top-level creation
   URL</a> to <var>topLevelCreationURL</var>, and <var>settings object</var>'s <a href="#concept-environment-top-level-origin" id="script-settings-for-window-objects:concept-environment-top-level-origin">top-level
   origin</a> to <var>topLevelOrigin</var>.</p></li><li><p>Set <var>realm</var>'s [[HostDefined]] field to <var>settings object</var>.</p></li></ol>
  </div>

  


  <h4 id="the-windowproxy-exotic-object"><span class="secno">7.2.3</span> The <code id="the-windowproxy-exotic-object:windowproxy"><a href="#windowproxy">WindowProxy</a></code> exotic object<a href="#the-windowproxy-exotic-object" class="self-link"></a></h4>

  <p>A <dfn id="windowproxy" data-dfn-type="interface"><code>WindowProxy</code></dfn> is an exotic object that wraps a
  <code id="the-windowproxy-exotic-object:window"><a href="#window">Window</a></code> ordinary object, indirecting most operations through to the wrapped object.
  Each <a href="#browsing-context" id="the-windowproxy-exotic-object:browsing-context">browsing context</a> has an associated <code id="the-windowproxy-exotic-object:windowproxy-2"><a href="#windowproxy">WindowProxy</a></code> object. When the
  <a href="#browsing-context" id="the-windowproxy-exotic-object:browsing-context-2">browsing context</a> is <a href="#navigate" id="the-windowproxy-exotic-object:navigate">navigated</a>, the <code id="the-windowproxy-exotic-object:window-2"><a href="#window">Window</a></code>
  object wrapped by the <a href="#browsing-context" id="the-windowproxy-exotic-object:browsing-context-3">browsing context</a>'s associated <code id="the-windowproxy-exotic-object:windowproxy-3"><a href="#windowproxy">WindowProxy</a></code> object
  is changed.</p>

  

  <p>The <code id="the-windowproxy-exotic-object:windowproxy-4"><a href="#windowproxy">WindowProxy</a></code> exotic object must use the ordinary internal methods except where
  it is explicitly specified otherwise below.</p>

  <p>There is no <code id="the-windowproxy-exotic-object:windowproxy-5"><a href="#windowproxy">WindowProxy</a></code> <a id="the-windowproxy-exotic-object:interface-object" href="https://webidl.spec.whatwg.org/#dfn-interface-object" data-x-internal="interface-object">interface object</a>.</p>

  <p>Every <code id="the-windowproxy-exotic-object:windowproxy-6"><a href="#windowproxy">WindowProxy</a></code> object has a <dfn id="concept-windowproxy-window" data-export="">[[Window]]</dfn> internal slot representing the wrapped <code id="the-windowproxy-exotic-object:window-3"><a href="#window">Window</a></code> object.</p>

  <p class="note">Although <code id="the-windowproxy-exotic-object:windowproxy-7"><a href="#windowproxy">WindowProxy</a></code> is named as a "proxy", it does not do
  polymorphic dispatch on its target's internal methods as a real proxy would, due to a desire to
  reuse machinery between <code id="the-windowproxy-exotic-object:windowproxy-8"><a href="#windowproxy">WindowProxy</a></code> and <code id="the-windowproxy-exotic-object:location"><a href="#location">Location</a></code> objects. As long as the
  <code id="the-windowproxy-exotic-object:window-4"><a href="#window">Window</a></code> object remains an ordinary object this is unobservable and can be implemented
  either way.</p>

  <div data-algorithm="">
  <h5 id="windowproxy-getprototypeof"><span class="secno">7.2.3.1</span> [[GetPrototypeOf]] ( )<a href="#windowproxy-getprototypeof" class="self-link"></a></h5>

  <ol><li><p>Let <var>W</var> be the value of the
   <a href="#concept-windowproxy-window" id="windowproxy-getprototypeof:concept-windowproxy-window">[[Window]]</a> internal slot of
   <b>this</b>.</p></li><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="windowproxy-getprototypeof:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return !
   <a id="windowproxy-getprototypeof:ordinarygetprototypeof" href="https://tc39.es/ecma262/#sec-ordinarygetprototypeof" data-x-internal="ordinarygetprototypeof">OrdinaryGetPrototypeOf</a>(<var>W</var>).</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="windowproxy-setprototypeof"><span class="secno">7.2.3.2</span> [[SetPrototypeOf]] ( <var>V</var> )<a href="#windowproxy-setprototypeof" class="self-link"></a></h5>

  <ol><li><p>Return ! <a id="windowproxy-setprototypeof:setimmutableprototype" href="https://tc39.es/ecma262/#sec-set-immutable-prototype" data-x-internal="setimmutableprototype">SetImmutablePrototype</a>(<b>this</b>, <var>V</var>).</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="windowproxy-isextensible"><span class="secno">7.2.3.3</span> [[IsExtensible]] ( )<a href="#windowproxy-isextensible" class="self-link"></a></h5>

  <ol><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="windowproxy-preventextensions"><span class="secno">7.2.3.4</span> [[PreventExtensions]] ( )<a href="#windowproxy-preventextensions" class="self-link"></a></h5>

  <ol><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="windowproxy-getownproperty"><span class="secno">7.2.3.5</span> [[GetOwnProperty]] ( <var>P</var> )<a href="#windowproxy-getownproperty" class="self-link"></a></h5>

  <ol><li><p>Let <var>W</var> be the value of the
   <a href="#concept-windowproxy-window" id="windowproxy-getownproperty:concept-windowproxy-window">[[Window]]</a> internal slot of
   <b>this</b>.</p></li><li>
    <p>If <var>P</var> is an <a id="windowproxy-getownproperty:array-index-property-name" href="https://webidl.spec.whatwg.org/#dfn-array-index-property-name" data-x-internal="array-index-property-name">array index property name</a>, then:</p>

    <ol><li><p>Let <var>index</var> be ! <a id="windowproxy-getownproperty:touint32" href="https://tc39.es/ecma262/#sec-touint32" data-x-internal="touint32">ToUint32</a>(<var>P</var>).</p></li><li><p>Let <var>children</var> be the <a href="#document-tree-child-navigables" id="windowproxy-getownproperty:document-tree-child-navigables">document-tree child navigables</a> of
     <var>W</var>'s <a href="#concept-document-window" id="windowproxy-getownproperty:concept-document-window">associated
     <code>Document</code></a>.</p></li><li><p>Let <var>value</var> be undefined.</p></li><li>
      <p>If <var>index</var> is less than <var>children</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="windowproxy-getownproperty:list-size" data-x-internal="list-size">size</a>, then:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#list-sort-in-ascending-order" id="windowproxy-getownproperty:list-sort" data-x-internal="list-sort">Sort</a> <var>children</var> in ascending order, with
       <var>navigableA</var> being less than <var>navigableB</var> if <var>navigableA</var>'s <a href="#nav-container" id="windowproxy-getownproperty:nav-container">container</a> was inserted into <var>W</var>'s <a href="#concept-document-window" id="windowproxy-getownproperty:concept-document-window-2">associated <code>Document</code></a> earlier than
       <var>navigableB</var>'s <a href="#nav-container" id="windowproxy-getownproperty:nav-container-2">container</a> was.</p></li><li><p>Set <var>value</var> to <var>children</var>[<var>index</var>]'s <a href="#nav-wp" id="windowproxy-getownproperty:nav-wp">active <code>WindowProxy</code></a>.</p></li></ol>
     </li><li>
      <p>If <var>value</var> is undefined, then:</p>

      <ol><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="windowproxy-getownproperty:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return
       undefined.</p></li><li><p>Throw a <a id="windowproxy-getownproperty:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="windowproxy-getownproperty:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
     </li><li><p>Return <a id="windowproxy-getownproperty:propertydescriptor" href="https://tc39.es/ecma262/#sec-property-descriptor-specification-type" data-x-internal="propertydescriptor">PropertyDescriptor</a> {
     [[Value]]: <var>value</var>,
     [[Writable]]: false,
     [[Enumerable]]: true,
     [[Configurable]]: true }.</p></li></ol>
   </li><li>
    <p>If <a href="#isplatformobjectsameorigin-(-o-)" id="windowproxy-getownproperty:isplatformobjectsameorigin-(-o-)-2">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return !
    <a id="windowproxy-getownproperty:ordinarygetownproperty" href="https://tc39.es/ecma262/#sec-ordinarygetownproperty" data-x-internal="ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<var>W</var>, <var>P</var>).</p>

    <p class="note">This is a <a id="windowproxy-getownproperty:willful-violation" href="https://infra.spec.whatwg.org/#willful-violation" data-x-internal="willful-violation">willful violation</a> of the JavaScript specification's
    <a id="windowproxy-getownproperty:invariants-of-the-essential-internal-methods" href="https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods" data-x-internal="invariants-of-the-essential-internal-methods">invariants of the essential internal methods</a> to maintain compatibility with
    existing web content. See <a href="https://github.com/tc39/ecma262/issues/672">tc39/ecma262
    issue #672</a> for more information. <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>
   </li><li><p>Let <var>property</var> be <a href="#crossorigingetownpropertyhelper-(-o,-p-)" id="windowproxy-getownproperty:crossorigingetownpropertyhelper-(-o,-p-)">CrossOriginGetOwnPropertyHelper</a>(<var>W</var>,
   <var>P</var>).</p></li><li><p>If <var>property</var> is not undefined, then return <var>property</var>.</p></li><li>
    <p>If <var>property</var> is undefined and <var>P</var> is in <var>W</var>'s <a href="#document-tree-child-navigable-target-name-property-set" id="windowproxy-getownproperty:document-tree-child-navigable-target-name-property-set">document-tree
    child navigable target name property set</a>, then:</p>

    <ol><li><p>Let <var>value</var> be the <a href="#nav-wp" id="windowproxy-getownproperty:nav-wp-2">active
     <code>WindowProxy</code></a> of the <a href="#dom-window-nameditem-filter" id="windowproxy-getownproperty:dom-window-nameditem-filter">named
     object</a> of <var>W</var> with the name <var>P</var>.</p></li><li>
      <p>Return <a id="windowproxy-getownproperty:propertydescriptor-2" href="https://tc39.es/ecma262/#sec-property-descriptor-specification-type" data-x-internal="propertydescriptor">PropertyDescriptor</a> {
      [[Value]]: <var>value</var>,
      [[Enumerable]]: false,
      [[Writable]]: false,
      [[Configurable]]: true }.</p>

      <p class="note">The reason the property descriptors are non-enumerable, despite this
      mismatching the same-origin behavior, is for compatibility with existing web content. See <a href="https://github.com/whatwg/html/issues/3183">issue #3183</a> for details.</p>
     </li></ol>

   </li><li><p>Return ? <a href="#crossoriginpropertyfallback-(-p-)" id="windowproxy-getownproperty:crossoriginpropertyfallback-(-p-)">CrossOriginPropertyFallback</a>(<var>P</var>).</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="windowproxy-defineownproperty"><span class="secno">7.2.3.6</span> [[DefineOwnProperty]] ( <var>P</var>, <var>Desc</var>
  )<a href="#windowproxy-defineownproperty" class="self-link"></a></h5>

  <ol><li><p>Let <var>W</var> be the value of the
   <a href="#concept-windowproxy-window" id="windowproxy-defineownproperty:concept-windowproxy-window">[[Window]]</a> internal slot of
   <b>this</b>.</p></li><li>
    <p>If <a href="#isplatformobjectsameorigin-(-o-)" id="windowproxy-defineownproperty:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then:

    </p><ol><li><p>If <var>P</var> is an <a id="windowproxy-defineownproperty:array-index-property-name" href="https://webidl.spec.whatwg.org/#dfn-array-index-property-name" data-x-internal="array-index-property-name">array index property name</a>, return false.</p></li><li>
      <p>Return ? <a id="windowproxy-defineownproperty:ordinarydefineownproperty" href="https://tc39.es/ecma262/#sec-ordinarydefineownproperty" data-x-internal="ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<var>W</var>, <var>P</var>,
      <var>Desc</var>).</p>

      <p class="note">This is a <a id="windowproxy-defineownproperty:willful-violation" href="https://infra.spec.whatwg.org/#willful-violation" data-x-internal="willful-violation">willful violation</a> of the JavaScript specification's
      <a id="windowproxy-defineownproperty:invariants-of-the-essential-internal-methods" href="https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods" data-x-internal="invariants-of-the-essential-internal-methods">invariants of the essential internal methods</a> to maintain compatibility with
      existing web content. See <a href="https://github.com/tc39/ecma262/issues/672">tc39/ecma262
      issue #672</a> for more information. <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>
     </li></ol>

   </li><li><p>Throw a <a id="windowproxy-defineownproperty:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="windowproxy-defineownproperty:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="windowproxy-get"><span class="secno">7.2.3.7</span> [[Get]] ( <var>P</var>, <var>Receiver</var> )<a href="#windowproxy-get" class="self-link"></a></h5>

  <ol><li><p>Let <var>W</var> be the value of the
   <a href="#concept-windowproxy-window" id="windowproxy-get:concept-windowproxy-window">[[Window]]</a> internal slot of
   <b>this</b>.</p></li><li><p><a href="#coop-check-access-report" id="windowproxy-get:coop-check-access-report">Check if an access between two browsing contexts
   should be reported</a>, given the <a href="#current-global-object" id="windowproxy-get:current-global-object">current global object</a>'s
   <a href="#window-bc" id="windowproxy-get:window-bc">browsing context</a>, <var>W</var>'s <a href="#window-bc" id="windowproxy-get:window-bc-2">browsing context</a>, <var>P</var>, and the <a href="#current-settings-object" id="windowproxy-get:current-settings-object">current settings
   object</a>.</p></li><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="windowproxy-get:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return ?
   <a id="windowproxy-get:ordinaryget" href="https://tc39.es/ecma262/#sec-ordinaryget" data-x-internal="ordinaryget">OrdinaryGet</a>(<b>this</b>, <var>P</var>, <var>Receiver</var>).</p></li><li><p>Return ? <a href="#crossoriginget-(-o,-p,-receiver-)" id="windowproxy-get:crossoriginget-(-o,-p,-receiver-)">CrossOriginGet</a>(<b>this</b>, <var>P</var>,
   <var>Receiver</var>).</p></li></ol>

  <p class="note"><b>this</b> is passed rather than <var>W</var> as <a id="windowproxy-get:ordinaryget-2" href="https://tc39.es/ecma262/#sec-ordinaryget" data-x-internal="ordinaryget">OrdinaryGet</a> and
  <a href="#crossoriginget-(-o,-p,-receiver-)" id="windowproxy-get:crossoriginget-(-o,-p,-receiver-)-2">CrossOriginGet</a> will invoke the <a href="#windowproxy-getownproperty">[[GetOwnProperty]]</a> internal method.</p>
  </div>

  <div data-algorithm="">
  <h5 id="windowproxy-set"><span class="secno">7.2.3.8</span> [[Set]] ( <var>P</var>, <var>V</var>, <var>Receiver</var> )<a href="#windowproxy-set" class="self-link"></a></h5>

  <ol><li><p>Let <var>W</var> be the value of the
   <a href="#concept-windowproxy-window" id="windowproxy-set:concept-windowproxy-window">[[Window]]</a> internal slot of
   <b>this</b>.</p></li><li><p><a href="#coop-check-access-report" id="windowproxy-set:coop-check-access-report">Check if an access between two browsing contexts
   should be reported</a>, given the <a href="#current-global-object" id="windowproxy-set:current-global-object">current global object</a>'s <a href="#browsing-context" id="windowproxy-set:browsing-context">browsing
   context</a>, <var>W</var>'s <a href="#browsing-context" id="windowproxy-set:browsing-context-2">browsing context</a>, <var>P</var>,
   and the <a href="#current-settings-object" id="windowproxy-set:current-settings-object">current settings object</a>.</p></li><li>
    <p>If <a href="#isplatformobjectsameorigin-(-o-)" id="windowproxy-set:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then:</p>

    <ol><li><p>If <var>P</var> is an <a id="windowproxy-set:array-index-property-name" href="https://webidl.spec.whatwg.org/#dfn-array-index-property-name" data-x-internal="array-index-property-name">array index property name</a>,
     then return false.</p></li><li><p>Return ? <a id="windowproxy-set:ordinaryset" href="https://tc39.es/ecma262/#sec-ordinaryset" data-x-internal="ordinaryset">OrdinarySet</a>(<var>W</var>, <var>P</var>, <var>V</var>,
     <var>Receiver</var>).</p></li></ol>
   </li><li>
    <p>Return ? <a href="#crossoriginset-(-o,-p,-v,-receiver-)" id="windowproxy-set:crossoriginset-(-o,-p,-v,-receiver-)">CrossOriginSet</a>(<b>this</b>, <var>P</var>, <var>V</var>,
    <var>Receiver</var>).</p>

    <p class="note"><b>this</b> is passed rather than <var>W</var> as <a href="#crossoriginset-(-o,-p,-v,-receiver-)" id="windowproxy-set:crossoriginset-(-o,-p,-v,-receiver-)-2">CrossOriginSet</a>
    will invoke the <a href="#windowproxy-getownproperty">[[GetOwnProperty]]</a>
    internal method.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="windowproxy-delete"><span class="secno">7.2.3.9</span> [[Delete]] ( <var>P</var> )<a href="#windowproxy-delete" class="self-link"></a></h5>

  <ol><li><p>Let <var>W</var> be the value of the
   <a href="#concept-windowproxy-window" id="windowproxy-delete:concept-windowproxy-window">[[Window]]</a> internal slot of
   <b>this</b>.</p></li><li>
    <p>If <a href="#isplatformobjectsameorigin-(-o-)" id="windowproxy-delete:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then:

    </p><ol><li>
      <p>If <var>P</var> is an <a id="windowproxy-delete:array-index-property-name" href="https://webidl.spec.whatwg.org/#dfn-array-index-property-name" data-x-internal="array-index-property-name">array index property name</a>, then:</p>

      <ol><li><p>Let <var>desc</var> be ! <b>this</b>.[[GetOwnProperty]](<var>P</var>).</p></li><li><p>If <var>desc</var> is undefined, then return true.</p></li><li><p>Return false.</p></li></ol>
     </li><li><p>Return ? <a id="windowproxy-delete:ordinarydelete" href="https://tc39.es/ecma262/#sec-ordinarydelete" data-x-internal="ordinarydelete">OrdinaryDelete</a>(<var>W</var>, <var>P</var>).</p></li></ol>

   </li><li><p>Throw a <a id="windowproxy-delete:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="windowproxy-delete:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="windowproxy-ownpropertykeys"><span class="secno">7.2.3.10</span> [[OwnPropertyKeys]] ( )<a href="#windowproxy-ownpropertykeys" class="self-link"></a></h5>

  <ol><li><p>Let <var>W</var> be the value of the <a href="#concept-windowproxy-window" id="windowproxy-ownpropertykeys:concept-windowproxy-window">[[Window]]</a> internal slot of <b>this</b>.</p></li><li><p>Let <var>maxProperties</var> be <var>W</var>'s <a href="#concept-document-window" id="windowproxy-ownpropertykeys:concept-document-window">associated <code>Document</code></a>'s <a href="#document-tree-child-navigables" id="windowproxy-ownpropertykeys:document-tree-child-navigables">document-tree
   child navigables</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="windowproxy-ownpropertykeys:list-size" data-x-internal="list-size">size</a>.</p></li><li><p>Let <var>keys</var> be <a href="https://infra.spec.whatwg.org/#the-exclusive-range" id="windowproxy-ownpropertykeys:exclusive-range" data-x-internal="exclusive-range">the range</a> 0 to
   <var>maxProperties</var>, exclusive.</p></li><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="windowproxy-ownpropertykeys:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return the
   concatenation of <var>keys</var> and
   <a id="windowproxy-ownpropertykeys:ordinaryownpropertykeys" href="https://tc39.es/ecma262/#sec-ordinaryownpropertykeys" data-x-internal="ordinaryownpropertykeys">OrdinaryOwnPropertyKeys</a>(<var>W</var>).</p></li><li><p>Return the concatenation of <var>keys</var> and !
   <a href="#crossoriginownpropertykeys-(-o-)" id="windowproxy-ownpropertykeys:crossoriginownpropertykeys-(-o-)">CrossOriginOwnPropertyKeys</a>(<var>W</var>).</p></li></ol>
  </div>

  


  <h4 id="the-location-interface"><span class="secno">7.2.4</span> The <code id="the-location-interface:location"><a href="#location">Location</a></code> interface<a href="#the-location-interface" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/location" title="The Document.location read-only property returns a Location object, which contains information about the URL of the document and provides methods for changing that URL and loading another URL.">Document/location</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location" title="The Location interface represents the location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Both the Document and Window interface have such a linked Location, accessible via Document.location and Window.location respectively.">Location</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/location" title="The Window.location read-only property returns a Location object with information about the current location of the document.">Window/location</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <p>Each <code id="the-location-interface:window"><a href="#window">Window</a></code> object is associated with a unique instance of a <code id="the-location-interface:location-2"><a href="#location">Location</a></code>
  object, allocated when the <code id="the-location-interface:window-2"><a href="#window">Window</a></code> object is created.</p>

  

  <p class="warning">The <code id="the-location-interface:location-3"><a href="#location">Location</a></code> exotic object is defined through a mishmash of IDL,
  invocation of JavaScript internal methods post-creation, and overridden JavaScript internal
  methods. Coupled with its scary security policy, please take extra care while implementing
  this excrescence.</p>

  <div data-algorithm="">
  <p>To create a <code id="the-location-interface:location-4"><a href="#location">Location</a></code> object, run these steps:</p>

  <ol><li><p>Let <var>location</var> be a new <code id="the-location-interface:location-5"><a href="#location">Location</a></code> <a id="the-location-interface:platform-object" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform
   object</a>.</p></li><li><p>Let <var>valueOf</var> be <var>location</var>'s <a href="#concept-relevant-realm" id="the-location-interface:concept-relevant-realm">relevant
   realm</a>.[[Intrinsics]].[[<a id="the-location-interface:object.prototype.valueof" href="https://tc39.es/ecma262/#sec-object.prototype.valueof" data-x-internal="object.prototype.valueof">%Object.prototype.valueOf%</a>]].</p></li><li><p>Perform ! <var>location</var>.[[DefineOwnProperty]]("<code>valueOf</code>", {
   [[Value]]: <var>valueOf</var>,
   [[Writable]]: false,
   [[Enumerable]]: false,
   [[Configurable]]: false }).</p></li><li><p>Perform ! <var>location</var>.[[DefineOwnProperty]](<a href="#symbol.toprimitive" id="the-location-interface:symbol.toprimitive">%Symbol.toPrimitive%</a>, {
   [[Value]]: undefined,
   [[Writable]]: false,
   [[Enumerable]]: false,
   [[Configurable]]: false }).</p></li><li><p>Set the value of the <a href="#defaultproperties" id="the-location-interface:defaultproperties">[[DefaultProperties]]</a> internal slot of
   <var>location</var> to <var>location</var>.[[OwnPropertyKeys]]().</p></li><li><p>Return <var>location</var>.</p></li></ol>
  </div>

  <p class="note">The addition of <code>valueOf</code> and <a href="#symbol.toprimitive" id="the-location-interface:symbol.toprimitive-2">%Symbol.toPrimitive%</a> own
  data properties, as well as the fact that all of <code id="the-location-interface:location-6"><a href="#location">Location</a></code>'s IDL attributes are marked
  <code>[<a id="the-location-interface:legacyunforgeable" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable">LegacyUnforgeable</a>]</code>, is required by legacy code that consulted
  the <code id="the-location-interface:location-7"><a href="#location">Location</a></code> interface, or stringified it, to determine the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-location-interface:the-document's-address" data-x-internal="the-document's-address">document URL</a>, and then used it in a security-sensitive way.
  In particular, the <code>valueOf</code>, <a href="#symbol.toprimitive" id="the-location-interface:symbol.toprimitive-3">%Symbol.toPrimitive%</a>, and <code>[<a id="the-location-interface:legacyunforgeable-2" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable">LegacyUnforgeable</a>]</code> stringifier mitigations ensure that code such as
  <code>foo[location] = bar</code> or <code>location + ""</code> cannot be
  misdirected.</p>

  

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-location" id="dom-document-location-dev">location</a> [ = <var>value</var> ]</code></dt><dt><code><var>window</var>.<a href="#dom-location" id="dom-location-dev">location</a> [ = <var>value</var> ]</code></dt><dd>
    <p>Returns a <code id="the-location-interface:location-8"><a href="#location">Location</a></code> object with the current page's location.</p>

    <p>Can be set, to navigate to another page.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <code id="the-location-interface:document"><a href="#document">Document</a></code> object's <dfn data-dfn-for="Document" id="dom-document-location" data-dfn-type="attribute"><code>location</code></dfn> getter steps are to return
  <a id="the-location-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-location-interface:concept-relevant-global">relevant global object</a>'s <code id="the-location-interface:location-9"><a href="#location">Location</a></code> object, if
  <a id="the-location-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is <a href="#fully-active" id="the-location-interface:fully-active">fully active</a>, and null otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-location-interface:window-3"><a href="#window">Window</a></code> object's <dfn data-dfn-for="Window" id="dom-location" data-dfn-type="attribute"><code>location</code></dfn> getter steps are to return <a id="the-location-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <code id="the-location-interface:location-10"><a href="#location">Location</a></code> object.</p>
  </div>

  

  <p><code id="the-location-interface:location-11"><a href="#location">Location</a></code> objects provide a representation of the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-location-interface:the-document's-address-2" data-x-internal="the-document's-address">URL</a> of their associated <code id="the-location-interface:document-2"><a href="#document">Document</a></code>, as well as
  methods for <a href="#navigate" id="the-location-interface:navigate">navigating</a> and <a href="#reload" id="the-location-interface:reload">reloading</a>
  the associated <a href="#navigable" id="the-location-interface:navigable">navigable</a>.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="location" data-dfn-type="interface"><c- g="">Location</c-></dfn> { // but see also <a href="#the-location-interface">additional creation steps</a> and <a href="#location-internal-methods">overridden internal methods</a>
  [<a id="the-location-interface:legacyunforgeable-3" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">stringifier</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-location-href" id="the-location-interface:dom-location-href"><c- g="">href</c-></a>;
  [<a id="the-location-interface:legacyunforgeable-4" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-location-origin" id="the-location-interface:dom-location-origin"><c- g="">origin</c-></a>;
  [<a id="the-location-interface:legacyunforgeable-5" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-location-protocol" id="the-location-interface:dom-location-protocol"><c- g="">protocol</c-></a>;
  [<a id="the-location-interface:legacyunforgeable-6" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-location-host" id="the-location-interface:dom-location-host"><c- g="">host</c-></a>;
  [<a id="the-location-interface:legacyunforgeable-7" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-location-hostname" id="the-location-interface:dom-location-hostname"><c- g="">hostname</c-></a>;
  [<a id="the-location-interface:legacyunforgeable-8" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-location-port" id="the-location-interface:dom-location-port"><c- g="">port</c-></a>;
  [<a id="the-location-interface:legacyunforgeable-9" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-location-pathname" id="the-location-interface:dom-location-pathname"><c- g="">pathname</c-></a>;
  [<a id="the-location-interface:legacyunforgeable-10" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-location-search" id="the-location-interface:dom-location-search"><c- g="">search</c-></a>;
  [<a id="the-location-interface:legacyunforgeable-11" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-location-hash" id="the-location-interface:dom-location-hash"><c- g="">hash</c-></a>;

  [<a id="the-location-interface:legacyunforgeable-12" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">undefined</c-> <a href="#dom-location-assign" id="the-location-interface:dom-location-assign"><c- g="">assign</c-></a>(<c- b="">USVString</c-> <c- g="">url</c->);
  [<a id="the-location-interface:legacyunforgeable-13" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">undefined</c-> <a href="#dom-location-replace" id="the-location-interface:dom-location-replace"><c- g="">replace</c-></a>(<c- b="">USVString</c-> <c- g="">url</c->);
  [<a id="the-location-interface:legacyunforgeable-14" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>] <c- b="">undefined</c-> <a href="#dom-location-reload" id="the-location-interface:dom-location-reload"><c- g="">reload</c-></a>();

  [<a id="the-location-interface:legacyunforgeable-15" href="https://webidl.spec.whatwg.org/#LegacyUnforgeable" data-x-internal="legacyunforgeable"><c- g="">LegacyUnforgeable</c-></a>, <c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#domstringlist" id="the-location-interface:domstringlist"><c- n="">DOMStringList</c-></a> <a href="#dom-location-ancestororigins" id="the-location-interface:dom-location-ancestororigins"><c- g="">ancestorOrigins</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>location</var>.<span>toString()</span></code></dt><dt><code><var>location</var>.<a href="#dom-location-href" id="dom-location-href-dev">href</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/href" title="The href property of the Location interface is a stringifier that returns a string containing the whole URL, and allows the href to be updated.">Location/href</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/toString" title="The toString() stringifier method of the Location interface returns a string containing the whole URL. It is a read-only version of Location.href.">Location/toString</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>52+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-location-interface:location-12"><a href="#location">Location</a></code> object's URL.</p>

    <p>Can be set, to navigate to the given URL.</p>
   </dd><dt><code><var>location</var>.<a href="#dom-location-origin" id="dom-location-origin-dev">origin</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/origin" title="The origin read-only property of the Location interface is a string containing the Unicode serialization of the origin of the represented URL.">Location/origin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>21+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the <code id="the-location-interface:location-13"><a href="#location">Location</a></code> object's URL's origin.</p></dd><dt><code><var>location</var>.<a href="#dom-location-protocol" id="dom-location-protocol-dev">protocol</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/protocol" title="The protocol property of the Location interface is a string representing the protocol scheme of the URL, including the final ':'.">Location/protocol</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-location-interface:location-14"><a href="#location">Location</a></code> object's URL's scheme.</p>

    <p>Can be set, to navigate to the same URL with a changed scheme.</p>
   </dd><dt><code><var>location</var>.<a href="#dom-location-host" id="dom-location-host-dev">host</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/host" title="The host property of the Location interface is a string containing the host, that is the hostname, and then, if the port of the URL is nonempty, a ':', and the port of the URL.">Location/host</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-location-interface:location-15"><a href="#location">Location</a></code> object's URL's host and port (if different from the default
    port for the scheme).</p>

    <p>Can be set, to navigate to the same URL with a changed host and port.</p>
   </dd><dt><code><var>location</var>.<a href="#dom-location-hostname" id="dom-location-hostname-dev">hostname</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/hostname" title="The hostname property of the Location interface is a string containing the domain of the URL.">Location/hostname</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-location-interface:location-16"><a href="#location">Location</a></code> object's URL's host.</p>

    <p>Can be set, to navigate to the same URL with a changed host.</p>
   </dd><dt><code><var>location</var>.<a href="#dom-location-port" id="dom-location-port-dev">port</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/port" title="The port property of the Location interface is a string containing the port number of the URL. If the URL does not contain an explicit port number, it will be set to ''.">Location/port</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-location-interface:location-17"><a href="#location">Location</a></code> object's URL's port.</p>

    <p>Can be set, to navigate to the same URL with a changed port.</p>
   </dd><dt><code><var>location</var>.<a href="#dom-location-pathname" id="dom-location-pathname-dev">pathname</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/pathname" title="The pathname property of the Location interface is a string containing the path of the URL for the location. If there is no path, pathname will be empty: otherwise, pathname contains an initial '/' followed by the path of the URL, not including the query string or fragment.">Location/pathname</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-location-interface:location-18"><a href="#location">Location</a></code> object's URL's path.</p>

    <p>Can be set, to navigate to the same URL with a changed path.</p>
   </dd><dt><code><var>location</var>.<a href="#dom-location-search" id="dom-location-search-dev">search</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/search" title="The search property of the Location interface is a search string, also called a query string; that is, a string containing a '?' followed by the parameters of the URL.">Location/search</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-location-interface:location-19"><a href="#location">Location</a></code> object's URL's query (includes leading "<code>?</code>" if non-empty).</p>

    <p>Can be set, to navigate to the same URL with a changed query (ignores leading "<code>?</code>").</p>
   </dd><dt><code><var>location</var>.<a href="#dom-location-hash" id="dom-location-hash-dev">hash</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/hash" title="The hash property of the Location interface returns a string containing a '#' followed by the fragment identifier of the URL — the ID on the page that the URL is trying to target.">Location/hash</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>3+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-location-interface:location-20"><a href="#location">Location</a></code> object's URL's fragment (includes leading "<code>#</code>" if non-empty).</p>

    <p>Can be set, to navigate to the same URL with a changed fragment (ignores leading "<code>#</code>").</p>
   </dd><dt><code><var>location</var>.<a href="#dom-location-assign" id="dom-location-assign-dev">assign</a>(<var>url</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/assign" title="The Location.assign() method causes the window to load and display the document at the URL specified. After the navigation occurs, the user can navigate back to the page that called Location.assign() by pressing the &quot;back&quot; button.">Location/assign</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Navigates to the given URL.</p></dd><dt><code><var>location</var>.<a href="#dom-location-replace" id="dom-location-replace-dev">replace</a>(<var>url</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/replace" title="The replace() method of the Location interface replaces the current resource with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it.">Location/replace</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Removes the current page from the session history and navigates to the given URL.</p></dd><dt><code><var>location</var>.<a href="#dom-location-reload" id="dom-location-reload-dev">reload</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/reload" title="The location.reload() method reloads the current URL, like the Refresh button.">Location/reload</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Reloads the current page.</p></dd><dt><code><var>location</var>.<a href="#dom-location-ancestororigins" id="dom-location-ancestororigins-dev">ancestorOrigins</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Location/ancestorOrigins" title="The ancestorOrigins read-only property of the Location interface is a static DOMStringList containing, in reverse order, the origins of all ancestor browsing contexts of the document associated with the given Location object.">Location/ancestorOrigins</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>20+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns a <code id="the-location-interface:domstringlist-2"><a href="#domstringlist">DOMStringList</a></code> object listing the origins of the <a href="#ancestor-navigables" id="the-location-interface:ancestor-navigables">ancestor navigables</a>' <a href="#nav-document" id="the-location-interface:nav-document">active documents</a>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>A <code id="the-location-interface:location-21"><a href="#location">Location</a></code> object has an associated <dfn id="relevant-document">relevant <code>Document</code></dfn>,
  which is its <a href="#concept-relevant-global" id="the-location-interface:concept-relevant-global-2">relevant global object</a>'s <a href="#window-bc" id="the-location-interface:window-bc">browsing context</a>'s <a href="#active-document" id="the-location-interface:active-document">active document</a>, if this
  <code id="the-location-interface:location-22"><a href="#location">Location</a></code> object's <a href="#concept-relevant-global" id="the-location-interface:concept-relevant-global-3">relevant global object</a>'s <a href="#window-bc" id="the-location-interface:window-bc-2">browsing context</a> is non-null, and null otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-location-interface:location-23"><a href="#location">Location</a></code> object has an associated <dfn id="concept-location-url">url</dfn>,
  which is this <code id="the-location-interface:location-24"><a href="#location">Location</a></code> object's <a href="#relevant-document" id="the-location-interface:relevant-document">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-location-interface:the-document's-address-3" data-x-internal="the-document's-address">URL</a>, if this <code id="the-location-interface:location-25"><a href="#location">Location</a></code> object's <a href="#relevant-document" id="the-location-interface:relevant-document-2">relevant
  <code>Document</code></a> is non-null, and <code id="the-location-interface:about:blank"><a href="#about:blank">about:blank</a></code> otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-location-interface:location-26"><a href="#location">Location</a></code> object has an associated <dfn id="concept-location-ancestor-origins-list">ancestor origins list</dfn>. When a
  <code id="the-location-interface:location-27"><a href="#location">Location</a></code> object is created, its <a href="#concept-location-ancestor-origins-list" id="the-location-interface:concept-location-ancestor-origins-list">ancestor origins list</a> must be set to a
  <code id="the-location-interface:domstringlist-3"><a href="#domstringlist">DOMStringList</a></code> object whose associated list is the <a id="the-location-interface:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of strings that
  the following steps would produce:</p>

  <ol><li><p>Let <var>output</var> be a new <a id="the-location-interface:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of strings.</p></li><li><p>Let <var>current</var> be the <code id="the-location-interface:location-28"><a href="#location">Location</a></code> object's <a href="#relevant-document" id="the-location-interface:relevant-document-3">relevant
   <code>Document</code></a>.</p></li><li>
    <p>While <var>current</var>'s <a href="#doc-container-document" id="the-location-interface:doc-container-document">container document</a>
    is non-null:</p>

    <ol><li><p>Set <var>current</var> to <var>current</var>'s <a href="#doc-container-document" id="the-location-interface:doc-container-document-2">container document</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="the-location-interface:list-append" data-x-internal="list-append">Append</a> the <a href="#ascii-serialisation-of-an-origin" id="the-location-interface:ascii-serialisation-of-an-origin">serialization</a> of <var>current</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin" data-x-internal="concept-document-origin">origin</a> to <var>output</var>.</p></li></ol>
   </li><li><p>Return <var>output</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="location-object-navigate"><code>Location</code>-object navigate</dfn> a <code id="the-location-interface:location-29"><a href="#location">Location</a></code> object
  <var>location</var> to a <a id="the-location-interface:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, optionally given a <code id="the-location-interface:navigationhistorybehavior"><a href="#navigationhistorybehavior">NavigationHistoryBehavior</a></code> <var>historyHandling</var>
  (default "<code id="the-location-interface:navigationhistorybehavior-auto"><a href="#navigationhistorybehavior-auto">auto</a></code>"):</p>

  <ol><li><p>Let <var>navigable</var> be <var>location</var>'s <a href="#concept-relevant-global" id="the-location-interface:concept-relevant-global-4">relevant global object</a>'s
   <a href="#window-navigable" id="the-location-interface:window-navigable">navigable</a>.</p></li><li><p>Let <var>sourceDocument</var> be the <a href="#concept-incumbent-global" id="the-location-interface:concept-incumbent-global">incumbent
   global object</a>'s <a href="#concept-document-window" id="the-location-interface:concept-document-window">associated
   <code>Document</code></a>.</p></li><li><p>If <var>location</var>'s <a href="#relevant-document" id="the-location-interface:relevant-document-4">relevant <code>Document</code></a> is not yet
   <a href="#completely-loaded" id="the-location-interface:completely-loaded">completely loaded</a>, and the <a href="#concept-incumbent-global" id="the-location-interface:concept-incumbent-global-2">incumbent global
   object</a> does not have <a href="#transient-activation" id="the-location-interface:transient-activation">transient activation</a>, then set
   <var>historyHandling</var> to "<code id="the-location-interface:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p></li><li><p><a href="#navigate" id="the-location-interface:navigate-2">Navigate</a> <var>navigable</var> to <var>url</var> using
   <var>sourceDocument</var>, with <i><a href="#exceptions-enabled" id="the-location-interface:exceptions-enabled">exceptionsEnabled</a></i> set to true and <i id="the-location-interface:navigation-hh"><a href="#navigation-hh">historyHandling</a></i> set to <var>historyHandling</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-href" data-dfn-type="attribute"><code>href</code></dfn> getter
  steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-5">relevant <code>Document</code></a> is non-null and its
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain">same origin-domain</a> with
   the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin">origin</a>, then throw a
   <a id="the-location-interface:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return <a id="the-location-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url">url</a>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-location-interface:concept-url-serializer" data-x-internal="concept-url-serializer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-location-interface:dom-location-href-2"><a href="#dom-location-href">href</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-6">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>Let <var>url</var> be the result of <a href="#encoding-parsing-a-url" id="the-location-interface:encoding-parsing-a-url">encoding-parsing a URL</a> given the given
   value, relative to the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-2">entry settings object</a>.</p></li><li><p>If <var>url</var> is failure, then throw a <a id="the-location-interface:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="the-location-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>url</var>.</p></li></ol>
  </div>

  <p class="note">The <code id="the-location-interface:dom-location-href-3"><a href="#dom-location-href">href</a></code> setter intentionally has no
  security check.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-origin" data-dfn-type="attribute"><code>origin</code></dfn>
  getter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-7">relevant <code>Document</code></a> is non-null and its
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-2">same origin-domain</a> with
   the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-3">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-2">origin</a>, then throw a
   <a id="the-location-interface:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return the <a href="#ascii-serialisation-of-an-origin" id="the-location-interface:ascii-serialisation-of-an-origin-2">serialization</a> of
   <a id="the-location-interface:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-2">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="the-location-interface:concept-url-origin" data-x-internal="concept-url-origin">origin</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-protocol" data-dfn-type="attribute"><code>protocol</code></dfn>
  getter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-8">relevant <code>Document</code></a> is non-null and its
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-4" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-3">same origin-domain</a> with
   the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-4">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-3">origin</a>, then throw a
   <a id="the-location-interface:securityerror-3" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return <a id="the-location-interface:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-3">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="the-location-interface:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a>, followed by "<code>:</code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-location-interface:dom-location-protocol-2"><a href="#dom-location-protocol">protocol</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-9">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>If <a id="the-location-interface:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-10">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-5" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-4">same origin-domain</a> with the
   <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-5">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-4">origin</a>, then throw a
   <a id="the-location-interface:securityerror-4" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>copyURL</var> be a copy of <a id="the-location-interface:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-4">url</a>.</p></li><li>
    <p>Let <var>possibleFailure</var> be the result of <a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="the-location-interface:basic-url-parser" data-x-internal="basic-url-parser">basic URL
    parsing</a> the given value, followed by "<code>:</code>", with <var>copyURL</var>
    as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="the-location-interface:basic-url-parser-url" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="the-location-interface:scheme-start-state" href="https://url.spec.whatwg.org/#scheme-start-state" data-x-internal="scheme-start-state">scheme start state</a> as
    <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="the-location-interface:basic-url-parser-state-override" data-x-internal="basic-url-parser-state-override"><i>state override</i></a>.</p>

    <p class="note">Because the URL parser ignores multiple consecutive colons, providing a value
    of "<code>https:</code>" (or even "<code>https::::</code>") is the same as
    providing a value of "<code>https</code>".</p>
   </li><li><p>If <var>possibleFailure</var> is failure, then throw a
   <a id="the-location-interface:syntaxerror-2" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="the-location-interface:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>copyURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="the-location-interface:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a> is not an
   <a id="the-location-interface:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>, then terminate these steps.</p></li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate-2"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>copyURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-host" data-dfn-type="attribute"><code>host</code></dfn> getter
  steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-16" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-11">relevant <code>Document</code></a> is non-null and its
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-6" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-5">same origin-domain</a> with
   the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-6">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-5">origin</a>, then throw a
   <a id="the-location-interface:securityerror-5" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>url</var> be <a id="the-location-interface:this-17" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-5">url</a>.</p></li><li><p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="the-location-interface:concept-url-host" data-x-internal="concept-url-host">host</a> is null, return the empty
   string.</p></li><li><p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="the-location-interface:concept-url-port" data-x-internal="concept-url-port">port</a> is null, return
   <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="the-location-interface:concept-url-host-2" data-x-internal="concept-url-host">host</a>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="the-location-interface:host-serializer" data-x-internal="host-serializer">serialized</a>.</p></li><li><p>Return <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="the-location-interface:concept-url-host-3" data-x-internal="concept-url-host">host</a>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="the-location-interface:host-serializer-2" data-x-internal="host-serializer">serialized</a>, followed by "<code>:</code>" and <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="the-location-interface:concept-url-port-2" data-x-internal="concept-url-port">port</a>, <a href="https://url.spec.whatwg.org/#serialize-an-integer" id="the-location-interface:serialize-an-integer" data-x-internal="serialize-an-integer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-location-interface:dom-location-host-2"><a href="#dom-location-host">host</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-18" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-12">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>If <a id="the-location-interface:this-19" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-13">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-7" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-6">same origin-domain</a> with the
   <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-7">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-6">origin</a>, then throw a
   <a id="the-location-interface:securityerror-6" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>copyURL</var> be a copy of <a id="the-location-interface:this-20" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-6">url</a>.</p></li><li><p>If <var>copyURL</var> has an <a id="the-location-interface:opaque-path" href="https://url.spec.whatwg.org/#url-opaque-path" data-x-internal="opaque-path">opaque path</a>, then return.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="the-location-interface:basic-url-parser-2" data-x-internal="basic-url-parser">Basic URL parse</a> the given value, with
   <var>copyURL</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="the-location-interface:basic-url-parser-url-2" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="the-location-interface:host-state" href="https://url.spec.whatwg.org/#host-state" data-x-internal="host-state">host
   state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="the-location-interface:basic-url-parser-state-override-2" data-x-internal="basic-url-parser-state-override"><i>state
   override</i></a>.</p></li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate-3"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-21" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>copyURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-hostname" data-dfn-type="attribute"><code>hostname</code></dfn>
  getter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-22" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-14">relevant <code>Document</code></a> is non-null and its
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-8" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-7">same origin-domain</a> with
   the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-8">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-7">origin</a>, then throw a
   <a id="the-location-interface:securityerror-7" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="the-location-interface:this-23" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-7">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="the-location-interface:concept-url-host-4" data-x-internal="concept-url-host">host</a> is null, return the empty string.</p></li><li><p>Return <a id="the-location-interface:this-24" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-8">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="the-location-interface:concept-url-host-5" data-x-internal="concept-url-host">host</a>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="the-location-interface:host-serializer-3" data-x-internal="host-serializer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-location-interface:dom-location-hostname-2"><a href="#dom-location-hostname">hostname</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-25" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-15">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>If <a id="the-location-interface:this-26" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-16">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-9" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-8">same origin-domain</a> with the
   <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-9">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-8">origin</a>, then throw a
   <a id="the-location-interface:securityerror-8" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-10"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>copyURL</var> be a copy of <a id="the-location-interface:this-27" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-9">url</a>.</p></li><li><p>If <var>copyURL</var> has an <a id="the-location-interface:opaque-path-2" href="https://url.spec.whatwg.org/#url-opaque-path" data-x-internal="opaque-path">opaque path</a>, then return.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="the-location-interface:basic-url-parser-3" data-x-internal="basic-url-parser">Basic URL parse</a> the given value, with
   <var>copyURL</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="the-location-interface:basic-url-parser-url-3" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="the-location-interface:hostname-state" href="https://url.spec.whatwg.org/#hostname-state" data-x-internal="hostname-state">hostname
   state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="the-location-interface:basic-url-parser-state-override-3" data-x-internal="basic-url-parser-state-override"><i>state
   override</i></a>.</p></li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate-4"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-28" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>copyURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-port" data-dfn-type="attribute"><code>port</code></dfn> getter
  steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-29" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-17">relevant <code>Document</code></a> is non-null and its
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-10" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-9">same origin-domain</a> with
   the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-10">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-9">origin</a>, then throw a
   <a id="the-location-interface:securityerror-9" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-11"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="the-location-interface:this-30" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-10">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="the-location-interface:concept-url-port-3" data-x-internal="concept-url-port">port</a> is null, return the empty string.</p></li><li><p>Return <a id="the-location-interface:this-31" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-11">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="the-location-interface:concept-url-port-4" data-x-internal="concept-url-port">port</a>, <a href="https://url.spec.whatwg.org/#serialize-an-integer" id="the-location-interface:serialize-an-integer-2" data-x-internal="serialize-an-integer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-location-interface:dom-location-port-2"><a href="#dom-location-port">port</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-32" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-18">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>If <a id="the-location-interface:this-33" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-19">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-11" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-10">same origin-domain</a> with the
   <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-11">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-10">origin</a>, then throw a
   <a id="the-location-interface:securityerror-10" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-12"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>copyURL</var> be a copy of <a id="the-location-interface:this-34" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-12">url</a>.</p></li><li><p>If <var>copyURL</var> <a id="the-location-interface:cannot-have-a-username/password/port" href="https://url.spec.whatwg.org/#cannot-have-a-username-password-port" data-x-internal="cannot-have-a-username/password/port">cannot have a username/password/port</a>, then
   return.</p></li><li><p>If the given value is the empty string, then set <var>copyURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="the-location-interface:concept-url-port-5" data-x-internal="concept-url-port">port</a> to null.</p></li><li><p>Otherwise, <a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="the-location-interface:basic-url-parser-4" data-x-internal="basic-url-parser">basic URL parse</a> the given value, with
   <var>copyURL</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="the-location-interface:basic-url-parser-url-4" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="the-location-interface:port-state" href="https://url.spec.whatwg.org/#port-state" data-x-internal="port-state">port
   state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="the-location-interface:basic-url-parser-state-override-4" data-x-internal="basic-url-parser-state-override"><i>state
   override</i></a>.</p></li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate-5"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-35" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>copyURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-pathname" data-dfn-type="attribute"><code>pathname</code></dfn>
  getter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-36" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-20">relevant <code>Document</code></a> is non-null and its
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-12" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-11">same origin-domain</a> with
   the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-12">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-11">origin</a>, then throw a
   <a id="the-location-interface:securityerror-11" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-13"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return the result of <a href="https://url.spec.whatwg.org/#url-path-serializer" id="the-location-interface:url-path-serializer" data-x-internal="url-path-serializer">URL path serializing</a> this
   <code id="the-location-interface:location-30"><a href="#location">Location</a></code> object's <a href="#concept-location-url" id="the-location-interface:concept-location-url-13">url</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-location-interface:dom-location-pathname-2"><a href="#dom-location-pathname">pathname</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-37" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-21">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>If <a id="the-location-interface:this-38" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-22">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-13" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-12">same origin-domain</a> with the
   <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-13">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-12">origin</a>, then throw a
   <a id="the-location-interface:securityerror-12" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-14"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>copyURL</var> be a copy of <a id="the-location-interface:this-39" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-14">url</a>.</p></li><li><p>If <var>copyURL</var> has an <a id="the-location-interface:opaque-path-3" href="https://url.spec.whatwg.org/#url-opaque-path" data-x-internal="opaque-path">opaque path</a>, then return.</p></li><li><p>Set <var>copyURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-path" id="the-location-interface:concept-url-path" data-x-internal="concept-url-path">path</a> to the empty
   list.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="the-location-interface:basic-url-parser-5" data-x-internal="basic-url-parser">Basic URL parse</a> the given value, with
   <var>copyURL</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="the-location-interface:basic-url-parser-url-5" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="the-location-interface:path-start-state" href="https://url.spec.whatwg.org/#path-start-state" data-x-internal="path-start-state">path start
   state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="the-location-interface:basic-url-parser-state-override-5" data-x-internal="basic-url-parser-state-override"><i>state
   override</i></a>.</p></li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate-6"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-40" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>copyURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-search" data-dfn-type="attribute"><code>search</code></dfn>
  getter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-41" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-23">relevant <code>Document</code></a> is non-null and its
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-14" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-13">same origin-domain</a> with
   the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-14">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-13">origin</a>, then throw a
   <a id="the-location-interface:securityerror-13" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-15"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="the-location-interface:this-42" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-15">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="the-location-interface:concept-url-query" data-x-internal="concept-url-query">query</a> is either null or the empty string, return the empty
   string.</p></li><li><p>Return "<code>?</code>", followed by <a id="the-location-interface:this-43" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-16">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="the-location-interface:concept-url-query-2" data-x-internal="concept-url-query">query</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-location-interface:dom-location-search-2"><a href="#dom-location-search">search</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-44" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-24">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>If <a id="the-location-interface:this-45" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-25">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-15" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-14">same origin-domain</a> with the
   <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-15">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-14">origin</a>, then throw a
   <a id="the-location-interface:securityerror-14" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-16"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>copyURL</var> be a copy of <a id="the-location-interface:this-46" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-17">url</a>.</p></li><li><p>If the given value is the empty string, set <var>copyURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="the-location-interface:concept-url-query-3" data-x-internal="concept-url-query">query</a> to null.

   </p></li><li>
    <p>Otherwise, run these substeps:</p>

    <ol><li><p>Let <var>input</var> be the given value with a single leading "<code>?</code>" removed, if any.</p></li><li><p>Set <var>copyURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="the-location-interface:concept-url-query-4" data-x-internal="concept-url-query">query</a> to the empty
     string.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="the-location-interface:basic-url-parser-6" data-x-internal="basic-url-parser">Basic URL parse</a> <var>input</var>, with null, the
     <a href="#relevant-document" id="the-location-interface:relevant-document-26">relevant <code>Document</code></a>'s <a id="the-location-interface:document's-character-encoding" href="https://dom.spec.whatwg.org/#concept-document-encoding" data-x-internal="document's-character-encoding">document's character encoding</a>,
     <var>copyURL</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="the-location-interface:basic-url-parser-url-6" data-x-internal="basic-url-parser-url"><i>url</i></a>, and <a id="the-location-interface:query-state" href="https://url.spec.whatwg.org/#query-state" data-x-internal="query-state">query
     state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="the-location-interface:basic-url-parser-state-override-6" data-x-internal="basic-url-parser-state-override"><i>state
     override</i></a>.</p></li></ol>
   </li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate-7"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-47" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>copyURL</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-hash" data-dfn-type="attribute"><code>hash</code></dfn> getter
  steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-48" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-27">relevant <code>Document</code></a> is non-null and its
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-16" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-15">same origin-domain</a> with
   the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-16">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-15">origin</a>, then throw a
   <a id="the-location-interface:securityerror-15" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-17"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="the-location-interface:this-49" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-18">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-location-interface:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> is either null or the empty string, return the
   empty string.</p></li><li><p>Return "<code>#</code>", followed by <a id="the-location-interface:this-50" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-19">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-location-interface:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-location-interface:dom-location-hash-2"><a href="#dom-location-hash">hash</a></code> setter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-51" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-28">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>If <a id="the-location-interface:this-52" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-29">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-17" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-16">same origin-domain</a> with the
   <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-17">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-16">origin</a>, then throw a
   <a id="the-location-interface:securityerror-16" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-18"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>copyURL</var> be a copy of <a id="the-location-interface:this-53" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-url" id="the-location-interface:concept-location-url-20">url</a>.</p></li><li><p>Let <var>thisURLFragment</var> be <var>copyURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-location-interface:concept-url-fragment-3" data-x-internal="concept-url-fragment">fragment</a> if it is non-null; otherwise the empty
   string.</p></li><li><p>Let <var>input</var> be the given value with a single leading "<code>#</code>"
   removed, if any.</p></li><li><p>Set <var>copyURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-location-interface:concept-url-fragment-4" data-x-internal="concept-url-fragment">fragment</a> to the empty
   string.</p></li><li><p><a href="https://url.spec.whatwg.org/#concept-basic-url-parser" id="the-location-interface:basic-url-parser-7" data-x-internal="basic-url-parser">Basic URL parse</a> <var>input</var>, with
   <var>copyURL</var> as <a href="https://url.spec.whatwg.org/#basic-url-parser-url" id="the-location-interface:basic-url-parser-url-7" data-x-internal="basic-url-parser-url"><i>url</i></a> and <a id="the-location-interface:fragment-state" href="https://url.spec.whatwg.org/#fragment-state" data-x-internal="fragment-state">fragment
   state</a> as <a href="https://url.spec.whatwg.org/#basic-url-parser-state-override" id="the-location-interface:basic-url-parser-state-override-7" data-x-internal="basic-url-parser-state-override"><i>state
   override</i></a>.</p></li><li>
    <p>If <var>copyURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-location-interface:concept-url-fragment-5" data-x-internal="concept-url-fragment">fragment</a> is
    <var>thisURLFragment</var>, then return.</p>

    <p class="note">This bailout is necessary for compatibility with deployed content, which <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1733797#c2">redundantly sets <code>location.hash</code> on scroll</a>. It does not apply to other
    mechanisms of fragment navigation, such as the <code id="the-location-interface:dom-location-href-4"><a href="#dom-location-href">location.href</a></code> setter or <code id="the-location-interface:dom-location-assign-2"><a href="#dom-location-assign">location.assign()</a></code>.</p>
   </li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate-8"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-54" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>copyURL</var>.</p></li></ol>
  </div>

  <p class="note">Unlike the equivalent API for the <code id="the-location-interface:the-a-element"><a href="#the-a-element">a</a></code> and <code id="the-location-interface:the-area-element"><a href="#the-area-element">area</a></code> elements,
  the <code id="the-location-interface:dom-location-hash-3"><a href="#dom-location-hash">hash</a></code> setter does not special case the empty string, to
  remain compatible with deployed scripts.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-assign" data-dfn-type="method"><code>assign(<var>url</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-55" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-30">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>If <a id="the-location-interface:this-56" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-31">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-18" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-17">same origin-domain</a> with the
   <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-18">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-17">origin</a>, then throw a
   <a id="the-location-interface:securityerror-17" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-19"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>urlRecord</var> be the result of <a href="#encoding-parsing-a-url" id="the-location-interface:encoding-parsing-a-url-2">encoding-parsing a URL</a> given
   <var>url</var>, relative to the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-19">entry settings object</a>.</p></li><li><p>If <var>urlRecord</var> is failure, then throw a <a id="the-location-interface:syntaxerror-3" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="the-location-interface:domexception-20"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate-9"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-57" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>urlRecord</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-replace" data-dfn-type="method"><code>replace(<var>url</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-58" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-32">relevant <code>Document</code></a> is null, then
   return.</p></li><li><p>Let <var>urlRecord</var> be the result of <a href="#encoding-parsing-a-url" id="the-location-interface:encoding-parsing-a-url-3">encoding-parsing a URL</a> given
   <var>url</var>, relative to the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-20">entry settings object</a>.</p></li><li><p>If <var>urlRecord</var> is failure, then throw a <a id="the-location-interface:syntaxerror-4" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="the-location-interface:domexception-21"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#location-object-navigate" id="the-location-interface:location-object-navigate-10"><code>Location</code>-object navigate</a> <a id="the-location-interface:this-59" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to
   <var>urlRecord</var> given "<code id="the-location-interface:navigationhistorybehavior-replace-2"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p></li></ol>
  </div>

  <p class="note">The <code id="the-location-interface:dom-location-replace-2"><a href="#dom-location-replace">replace()</a></code> method intentionally has
  no security check.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-reload" data-dfn-type="method"><code>reload()</code></dfn> method
  steps are:</p>

  <ol><li><p>Let <var>document</var> be <a id="the-location-interface:this-60" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-33">relevant
   <code>Document</code></a>.</p></li><li><p>If <var>document</var> is null, then return.</p></li><li><p>If <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-19" data-x-internal="concept-document-origin">origin</a> is not
   <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-18">same origin-domain</a> with the <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-21">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-18">origin</a>, then throw a
   <a id="the-location-interface:securityerror-18" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-22"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#reload" id="the-location-interface:reload-2">Reload</a> <var>document</var>'s <a href="#node-navigable" id="the-location-interface:node-navigable">node navigable</a>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Location" id="dom-location-ancestororigins" data-dfn-type="attribute"><code>ancestorOrigins</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-location-interface:this-61" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-34">relevant <code>Document</code></a> is null, then return
   an empty <a id="the-location-interface:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>If <a id="the-location-interface:this-62" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-document" id="the-location-interface:relevant-document-35">relevant <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-location-interface:concept-document-origin-20" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin-domain" id="the-location-interface:same-origin-domain-19">same origin-domain</a> with the
   <a href="#entry-settings-object" id="the-location-interface:entry-settings-object-22">entry settings object</a>'s <a href="#concept-settings-object-origin" id="the-location-interface:concept-settings-object-origin-19">origin</a>, then throw a
   <a id="the-location-interface:securityerror-19" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-location-interface:domexception-23"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Otherwise, return <a id="the-location-interface:this-63" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-location-ancestor-origins-list" id="the-location-interface:concept-location-ancestor-origins-list-2">ancestor origins list</a>.</p></li></ol>
  </div>

  <p class="warning">The details of how the <code id="the-location-interface:dom-location-ancestororigins-2"><a href="#dom-location-ancestororigins">ancestorOrigins</a></code> attribute works are still
  controversial and might change. See <a href="https://github.com/whatwg/html/issues/1918">issue
  #1918</a> for more information.</p>

  <hr>

  <p id="location-internal-methods">As explained earlier, the <code id="the-location-interface:location-31"><a href="#location">Location</a></code> exotic object
  requires additional logic beyond IDL for security purposes. The <code id="the-location-interface:location-32"><a href="#location">Location</a></code> object must
  use the ordinary internal methods except where it is explicitly specified otherwise below.</p>

  <p>Also, every <code id="the-location-interface:location-33"><a href="#location">Location</a></code> object has a <dfn id="defaultproperties">[[DefaultProperties]]</dfn> internal slot
  representing its own properties at time of its creation.</p>

  <div data-algorithm="">
  <h5 id="location-getprototypeof"><span class="secno">7.2.4.1</span> [[GetPrototypeOf]] ( )<a href="#location-getprototypeof" class="self-link"></a></h5>

  <ol><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="location-getprototypeof:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<b>this</b>) is true, then return !
   <a id="location-getprototypeof:ordinarygetprototypeof" href="https://tc39.es/ecma262/#sec-ordinarygetprototypeof" data-x-internal="ordinarygetprototypeof">OrdinaryGetPrototypeOf</a>(<b>this</b>).</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="location-setprototypeof"><span class="secno">7.2.4.2</span> [[SetPrototypeOf]] ( <var>V</var> )<a href="#location-setprototypeof" class="self-link"></a></h5>

  <ol><li><p>Return ! <a id="location-setprototypeof:setimmutableprototype" href="https://tc39.es/ecma262/#sec-set-immutable-prototype" data-x-internal="setimmutableprototype">SetImmutablePrototype</a>(<b>this</b>, <var>V</var>).</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="location-isextensible"><span class="secno">7.2.4.3</span> [[IsExtensible]] ( )<a href="#location-isextensible" class="self-link"></a></h5>

  <ol><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="location-preventextensions"><span class="secno">7.2.4.4</span> [[PreventExtensions]] ( )<a href="#location-preventextensions" class="self-link"></a></h5>

  <ol><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="location-getownproperty"><span class="secno">7.2.4.5</span> [[GetOwnProperty]] ( <var>P</var> )<a href="#location-getownproperty" class="self-link"></a></h5>

  <ol><li>
    <p>If <a href="#isplatformobjectsameorigin-(-o-)" id="location-getownproperty:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<b>this</b>) is true, then:</p>

    <ol><li><p>Let <var>desc</var> be <a id="location-getownproperty:ordinarygetownproperty" href="https://tc39.es/ecma262/#sec-ordinarygetownproperty" data-x-internal="ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<b>this</b>,
     <var>P</var>).</p></li><li><p>If the value of the <a href="#defaultproperties" id="location-getownproperty:defaultproperties">[[DefaultProperties]]</a> internal slot of <b>this</b>
     contains <var>P</var>, then set <var>desc</var>.[[Configurable]] to true.</p></li><li><p>Return <var>desc</var>.</p></li></ol>
   </li><li><p>Let <var>property</var> be <a href="#crossorigingetownpropertyhelper-(-o,-p-)" id="location-getownproperty:crossorigingetownpropertyhelper-(-o,-p-)">CrossOriginGetOwnPropertyHelper</a>(<b>this</b>,
   <var>P</var>).</p></li><li><p>If <var>property</var> is not undefined, then return <var>property</var>.</p></li><li><p>Return ? <a href="#crossoriginpropertyfallback-(-p-)" id="location-getownproperty:crossoriginpropertyfallback-(-p-)">CrossOriginPropertyFallback</a>(<var>P</var>).</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="location-defineownproperty"><span class="secno">7.2.4.6</span> [[DefineOwnProperty]] ( <var>P</var>, <var>Desc</var> )<a href="#location-defineownproperty" class="self-link"></a></h5>

  <ol><li>
    <p>If <a href="#isplatformobjectsameorigin-(-o-)" id="location-defineownproperty:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<b>this</b>) is true, then:</p>

    <ol><li><p>If the value of the <a href="#defaultproperties" id="location-defineownproperty:defaultproperties">[[DefaultProperties]]</a> internal slot of <b>this</b>
     contains <var>P</var>, then return false.</p></li><li><p>Return ? <a id="location-defineownproperty:ordinarydefineownproperty" href="https://tc39.es/ecma262/#sec-ordinarydefineownproperty" data-x-internal="ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<b>this</b>, <var>P</var>,
     <var>Desc</var>).</p></li></ol>
   </li><li><p>Throw a <a id="location-defineownproperty:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="location-defineownproperty:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="location-get"><span class="secno">7.2.4.7</span> [[Get]] ( <var>P</var>, <var>Receiver</var> )<a href="#location-get" class="self-link"></a></h5>

  <ol><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="location-get:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<b>this</b>) is true, then return ?
   <a id="location-get:ordinaryget" href="https://tc39.es/ecma262/#sec-ordinaryget" data-x-internal="ordinaryget">OrdinaryGet</a>(<b>this</b>, <var>P</var>, <var>Receiver</var>).</p></li><li><p>Return ? <a href="#crossoriginget-(-o,-p,-receiver-)" id="location-get:crossoriginget-(-o,-p,-receiver-)">CrossOriginGet</a>(<b>this</b>, <var>P</var>,
   <var>Receiver</var>).</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="location-set"><span class="secno">7.2.4.8</span> [[Set]] ( <var>P</var>, <var>V</var>, <var>Receiver</var> )<a href="#location-set" class="self-link"></a></h5>

  <ol><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="location-set:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<b>this</b>) is true, then return ?
   <a id="location-set:ordinaryset" href="https://tc39.es/ecma262/#sec-ordinaryset" data-x-internal="ordinaryset">OrdinarySet</a>(<b>this</b>, <var>P</var>, <var>V</var>, <var>Receiver</var>).</p></li><li><p>Return ? <a href="#crossoriginset-(-o,-p,-v,-receiver-)" id="location-set:crossoriginset-(-o,-p,-v,-receiver-)">CrossOriginSet</a>(<b>this</b>, <var>P</var>, <var>V</var>,
   <var>Receiver</var>).</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="location-delete"><span class="secno">7.2.4.9</span> [[Delete]] ( <var>P</var> )<a href="#location-delete" class="self-link"></a></h5>

  <ol><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="location-delete:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<b>this</b>) is true, then return ?
   <a id="location-delete:ordinarydelete" href="https://tc39.es/ecma262/#sec-ordinarydelete" data-x-internal="ordinarydelete">OrdinaryDelete</a>(<b>this</b>, <var>P</var>).</p></li><li><p>Throw a <a id="location-delete:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="location-delete:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="location-ownpropertykeys"><span class="secno">7.2.4.10</span> [[OwnPropertyKeys]] ( )<a href="#location-ownpropertykeys" class="self-link"></a></h5>

  <ol><li><p>If <a href="#isplatformobjectsameorigin-(-o-)" id="location-ownpropertykeys:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>(<b>this</b>) is true, then return
   <a id="location-ownpropertykeys:ordinaryownpropertykeys" href="https://tc39.es/ecma262/#sec-ordinaryownpropertykeys" data-x-internal="ordinaryownpropertykeys">OrdinaryOwnPropertyKeys</a>(<b>this</b>).</p></li><li><p>Return <a href="#crossoriginownpropertykeys-(-o-)" id="location-ownpropertykeys:crossoriginownpropertykeys-(-o-)">CrossOriginOwnPropertyKeys</a>(<b>this</b>).</p></li></ol>
  </div>

  


  <h4 id="the-history-interface"><span class="secno">7.2.5</span> The <code id="the-history-interface:history-3"><a href="#history-3">History</a></code> interface<a href="#the-history-interface" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/History" title="The History interface allows manipulation of the browser session history, that is the pages visited in the tab or frame that the current page is loaded in.">History</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/history" title="The Window.history read-only property returns a reference to the History object, which provides an interface for manipulating the browser session history (pages visited in the tab or frame that the current page is loaded in).">Window/history</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <pre><code class="idl"><c- b="">enum</c-> <dfn id="scrollrestoration" data-dfn-type="enum"><c- g="">ScrollRestoration</c-></dfn> { <c- s="">"</c-><a href="#dom-scrollrestoration-auto" id="the-history-interface:dom-scrollrestoration-auto"><c- s="">auto</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-scrollrestoration-manual" id="the-history-interface:dom-scrollrestoration-manual"><c- s="">manual</c-></a><c- s="">"</c-> };

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="history-3" data-dfn-type="interface"><c- g="">History</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-history-length" id="the-history-interface:dom-history-length"><c- g="">length</c-></a>;
  <c- b="">attribute</c-> <a href="#scrollrestoration" id="the-history-interface:scrollrestoration"><c- n="">ScrollRestoration</c-></a> <a href="#dom-history-scroll-restoration" id="the-history-interface:dom-history-scroll-restoration"><c- g="">scrollRestoration</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">any</c-> <a href="#dom-history-state" id="the-history-interface:dom-history-state"><c- g="">state</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-history-go" id="the-history-interface:dom-history-go"><c- g="">go</c-></a>(<c- b="">optional</c-> <c- b="">long</c-> <c- g="">delta</c-> = 0);
  <c- b="">undefined</c-> <a href="#dom-history-back" id="the-history-interface:dom-history-back"><c- g="">back</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-history-forward" id="the-history-interface:dom-history-forward"><c- g="">forward</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-history-pushstate" id="the-history-interface:dom-history-pushstate"><c- g="">pushState</c-></a>(<c- b="">any</c-> <c- g="">data</c->, <c- b="">DOMString</c-> <c- g="">unused</c->, <c- b="">optional</c-> <c- b="">USVString</c->? <c- g="">url</c-> = <c- b="">null</c->);
  <c- b="">undefined</c-> <a href="#dom-history-replacestate" id="the-history-interface:dom-history-replacestate"><c- g="">replaceState</c-></a>(<c- b="">any</c-> <c- g="">data</c->, <c- b="">DOMString</c-> <c- g="">unused</c->, <c- b="">optional</c-> <c- b="">USVString</c->? <c- g="">url</c-> = <c- b="">null</c->);
};</code></pre>

  <dl class="domintro"><dt><code><a href="#dom-history" id="dom-history-dev">history</a>.<a href="#dom-history-length" id="dom-history-length-dev">length</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/History/length" title="The History.length read-only property returns an integer representing the number of elements in the session history, including the currently loaded page.">History/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the number of overall <a href="#tn-session-history-entries" id="the-history-interface:tn-session-history-entries">session history
   entries</a> for the current <a href="#traversable-navigable" id="the-history-interface:traversable-navigable">traversable navigable</a>.</p></dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history">history</a>.<a href="#dom-history-scroll-restoration" id="dom-history-scroll-restoration-dev">scrollRestoration</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/History/scrollRestoration" title="The scrollRestoration property of History interface allows web applications to explicitly set default scroll restoration behavior on history navigation.">History/scrollRestoration</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>46+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>46+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the <a href="#she-scroll-restoration-mode" id="the-history-interface:she-scroll-restoration-mode">scroll restoration mode</a> of
   the <a href="#nav-active-history-entry" id="the-history-interface:nav-active-history-entry">active session history entry</a>.</p></dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-2">history</a>.<a href="#dom-history-scroll-restoration" id="the-history-interface:dom-history-scroll-restoration-2">scrollRestoration</a> = <var>value</var></code></dt><dd><p>Set the <a href="#she-scroll-restoration-mode" id="the-history-interface:she-scroll-restoration-mode-2">scroll restoration mode</a> of the
   <a href="#nav-active-history-entry" id="the-history-interface:nav-active-history-entry-2">active session history entry</a> to
   <var>value</var>.</p></dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-3">history</a>.<a href="#dom-history-state" id="dom-history-state-dev">state</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/History/state" title="The History.state property returns a value representing the state at the top of the history stack. This is a way to look at the state without having to wait for a popstate event.">History/state</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>19+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the <a href="#she-classic-history-api-state" id="the-history-interface:she-classic-history-api-state">classic history API state</a>
   of the <a href="#nav-active-history-entry" id="the-history-interface:nav-active-history-entry-3">active session history entry</a>, deserialized
   into a JavaScript value.</p></dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-4">history</a>.<a href="#dom-history-go" id="the-history-interface:dom-history-go-2">go</a>()</code></dt><dd><p>Reloads the current page.</p></dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-5">history</a>.<a href="#dom-history-go" id="dom-history-go-dev">go</a>(<var>delta</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/History/go" title="The History.go() method loads a specific page from the session history. You can use it to move forwards and backwards through the history depending on the value of a parameter.">History/go</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Goes back or forward the specified number of steps in the overall <a href="#tn-session-history-entries" id="the-history-interface:tn-session-history-entries-2">session history entries</a> list for the current
    <a href="#traversable-navigable" id="the-history-interface:traversable-navigable-2">traversable navigable</a>.</p>

    <p>A zero delta will reload the current page.</p>

    <p>If the delta is out of range, does nothing.</p>
   </dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-6">history</a>.<a href="#dom-history-back" id="dom-history-back-dev">back</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/History/back" title="The History.back() method causes the browser to move back one page in the session history.">History/back</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Goes back one step in the overall <a href="#tn-session-history-entries" id="the-history-interface:tn-session-history-entries-3">session history
    entries</a> list for the current <a href="#traversable-navigable" id="the-history-interface:traversable-navigable-3">traversable navigable</a>.</p>

    <p>If there is no previous page, does nothing.</p>
   </dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-7">history</a>.<a href="#dom-history-forward" id="dom-history-forward-dev">forward</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/History/forward" title="The History.forward() method causes the browser to move forward one page in the session history. It has the same effect as calling history.go(1).">History/forward</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Goes forward one step in the overall <a href="#tn-session-history-entries" id="the-history-interface:tn-session-history-entries-4">session
    history entries</a> list for the current <a href="#traversable-navigable" id="the-history-interface:traversable-navigable-4">traversable navigable</a>.</p>

    <p>If there is no next page, does nothing.</p>
   </dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-8">history</a>.<a href="#dom-history-pushstate" id="dom-history-pushstate-dev">pushState</a>(<var>data</var>, "")</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/History/pushState" title="In an HTML document, the history.pushState() method adds an entry to the browser's session history stack.">History/pushState</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.5+</span></span></div></div></div></dt><dd>
    <p>Adds a new entry into session history with its <a href="#she-classic-history-api-state" id="the-history-interface:she-classic-history-api-state-2">classic history API state</a> set to a serialization
    of <var>data</var>. The <a href="#nav-active-history-entry" id="the-history-interface:nav-active-history-entry-4">active history entry</a>'s
    <a href="#she-url" id="the-history-interface:she-url">URL</a> will be copied over and used for the new entry's URL.</p>

    <p>(The second parameter exists for historical reasons, and cannot be omitted; passing the
    empty string is traditional.)</p>
   </dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-9">history</a>.<a href="#dom-history-pushstate" id="the-history-interface:dom-history-pushstate-2">pushState</a>(<var>data</var>, "", <var>url</var>)</code></dt><dd>
    <p>Adds a new entry into session history with its <a href="#she-classic-history-api-state" id="the-history-interface:she-classic-history-api-state-3">classic history API state</a> set to a serialization
    of <var>data</var>, and with its <a href="#she-url" id="the-history-interface:she-url-2">URL</a> set to <var>url</var>.</p>

    <p>If the current <code id="the-history-interface:document"><a href="#document">Document</a></code> <a href="#can-have-its-url-rewritten" id="the-history-interface:can-have-its-url-rewritten">cannot have
    its URL rewritten</a> to <var>url</var>, a <a id="the-history-interface:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
    <code id="the-history-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> will be thrown.</p>

    <p>(The second parameter exists for historical reasons, and cannot be omitted; passing the
    empty string is traditional.)</p>
   </dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-10">history</a>.<a href="#dom-history-replacestate" id="dom-history-replacestate-dev">replaceState</a>(<var>data</var>, "")</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState" title="The History.replaceState() method modifies the current history entry, replacing it with the state object and URL passed in the method parameters. This method is particularly useful when you want to update the state object or URL of the current history entry in response to some user action.">History/replaceState</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.5+</span></span></div></div></div></dt><dd>
    <p>Updates the <a href="#she-classic-history-api-state" id="the-history-interface:she-classic-history-api-state-4">classic history API state</a> of
    the <a href="#nav-active-history-entry" id="the-history-interface:nav-active-history-entry-5">active session history entry</a> to a structured
    clone of <var>data</var>.</p>

    <p>(The second parameter exists for historical reasons, and cannot be omitted; passing the
    empty string is traditional.)</p>
   </dd><dt><code><a href="#dom-history" id="the-history-interface:dom-history-11">history</a>.<a href="#dom-history-replacestate" id="the-history-interface:dom-history-replacestate-2">replaceState</a>(<var>data</var>, "", <var>url</var>)</code></dt><dd>
    <p>Updates the <a href="#she-classic-history-api-state" id="the-history-interface:she-classic-history-api-state-5">classic history API state</a> of
    the <a href="#nav-active-history-entry" id="the-history-interface:nav-active-history-entry-6">active session history entry</a> to a structured
    clone of <var>data</var>, and its <a href="#she-url" id="the-history-interface:she-url-3">URL</a> to <var>url</var>.</p>

    <p>If the current <code id="the-history-interface:document-2"><a href="#document">Document</a></code> <a href="#can-have-its-url-rewritten" id="the-history-interface:can-have-its-url-rewritten-2">cannot have
    its URL rewritten</a> to <var>url</var>, a <a id="the-history-interface:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
    <code id="the-history-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> will be thrown.</p>

    <p>(The second parameter exists for historical reasons, and cannot be omitted; passing the
    empty string is traditional.)</p>
   </dd></dl>

  

  <p>A <code id="the-history-interface:document-3"><a href="#document">Document</a></code> has a <dfn id="doc-history">history object</dfn>, a
  <code id="the-history-interface:history-3-2"><a href="#history-3">History</a></code> object.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-history" data-dfn-type="attribute"><code>history</code></dfn> getter steps
  are to return <a id="the-history-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="the-history-interface:concept-document-window">associated
  <code>Document</code></a>'s <a href="#doc-history" id="the-history-interface:doc-history">history object</a>.</p>
  </div>

  <hr>

  <p>Each <code id="the-history-interface:history-3-3"><a href="#history-3">History</a></code> object has <dfn id="concept-history-state">state</dfn>,
  initially null.</p>

  <p>Each <code id="the-history-interface:history-3-4"><a href="#history-3">History</a></code> object has a <dfn id="concept-history-length">length</dfn>, a
  non-negative integer, initially 0.</p>

  <p>Each <code id="the-history-interface:history-3-5"><a href="#history-3">History</a></code> object has an <dfn id="concept-history-index">index</dfn>, a
  non-negative integer, initially 0.</p>

  <p class="note">Although the <a href="#concept-history-index" id="the-history-interface:concept-history-index">index</a> is not directly
  exposed, it can be inferred from changes to the <a href="#concept-history-length" id="the-history-interface:concept-history-length">length</a> during synchronous navigations. In fact, that is
  what it's used for.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="History" id="dom-history-length" data-dfn-type="attribute"><code>length</code></dfn> getter
  steps are:</p>

  <ol><li><p>If <a id="the-history-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-history-interface:concept-relevant-global">relevant global object</a>'s <a href="#concept-document-window" id="the-history-interface:concept-document-window-2">associated <code>Document</code></a> is not <a href="#fully-active" id="the-history-interface:fully-active">fully
   active</a>, then throw a <a id="the-history-interface:securityerror-3" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
   <code id="the-history-interface:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return <a id="the-history-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-history-length" id="the-history-interface:concept-history-length-2">length</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="History" id="dom-history-scroll-restoration" data-dfn-type="attribute"><code>scrollRestoration</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-history-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-history-interface:concept-relevant-global-2">relevant global object</a>'s <a href="#concept-document-window" id="the-history-interface:concept-document-window-3">associated <code>Document</code></a> is not <a href="#fully-active" id="the-history-interface:fully-active-2">fully
   active</a>, then throw a <a id="the-history-interface:securityerror-4" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
   <code id="the-history-interface:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return <a id="the-history-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-history-interface:concept-relevant-global-3">relevant global object</a>'s <a href="#window-navigable" id="the-history-interface:window-navigable">navigable</a>'s <a href="#nav-active-history-entry" id="the-history-interface:nav-active-history-entry-7">active session history
   entry</a>'s <a href="#she-scroll-restoration-mode" id="the-history-interface:she-scroll-restoration-mode-3">scroll restoration
   mode</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="the-history-interface:dom-history-scroll-restoration-3"><a href="#dom-history-scroll-restoration">scrollRestoration</a></code> setter steps
  are:</p>

  <ol><li><p>If <a id="the-history-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-history-interface:concept-relevant-global-4">relevant global object</a>'s <a href="#concept-document-window" id="the-history-interface:concept-document-window-4">associated <code>Document</code></a> is not <a href="#fully-active" id="the-history-interface:fully-active-3">fully
   active</a>, then throw a <a id="the-history-interface:securityerror-5" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
   <code id="the-history-interface:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <a id="the-history-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-history-interface:concept-relevant-global-5">relevant global object</a>'s <a href="#window-navigable" id="the-history-interface:window-navigable-2">navigable</a>'s <a href="#nav-active-history-entry" id="the-history-interface:nav-active-history-entry-8">active session history
   entry</a>'s <a href="#she-scroll-restoration-mode" id="the-history-interface:she-scroll-restoration-mode-4">scroll restoration mode</a> to the
   given value.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="History" id="dom-history-state" data-dfn-type="attribute"><code>state</code></dfn> getter
  steps are:</p>

  <ol><li><p>If <a id="the-history-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-history-interface:concept-relevant-global-6">relevant global object</a>'s <a href="#concept-document-window" id="the-history-interface:concept-document-window-5">associated <code>Document</code></a> is not <a href="#fully-active" id="the-history-interface:fully-active-4">fully
   active</a>, then throw a <a id="the-history-interface:securityerror-6" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
   <code id="the-history-interface:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return <a id="the-history-interface:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-history-state" id="the-history-interface:concept-history-state">state</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="History" id="dom-history-go" data-dfn-type="method"><code>go(<var>delta</var>)</code></dfn>
  method steps are to <a href="#delta-traverse" id="the-history-interface:delta-traverse">delta traverse</a> <a id="the-history-interface:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> given <var>delta</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="History" id="dom-history-back" data-dfn-type="method"><code>back()</code></dfn> method steps
  are to <a href="#delta-traverse" id="the-history-interface:delta-traverse-2">delta traverse</a> <a id="the-history-interface:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> given −1.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="History" id="dom-history-forward" data-dfn-type="method"><code>forward()</code></dfn> method
  steps are to <a href="#delta-traverse" id="the-history-interface:delta-traverse-3">delta traverse</a> <a id="the-history-interface:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> given +1.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="delta-traverse">delta traverse</dfn> a <code id="the-history-interface:history-3-6"><a href="#history-3">History</a></code> object <var>history</var> given an integer
  <var>delta</var>:</p>

  <ol><li><p>Let <var>document</var> be <var>history</var>'s <a href="#concept-relevant-global" id="the-history-interface:concept-relevant-global-7">relevant global object</a>'s
   <a href="#concept-document-window" id="the-history-interface:concept-document-window-6">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var> is not <a href="#fully-active" id="the-history-interface:fully-active-5">fully active</a>, then throw a
   <a id="the-history-interface:securityerror-7" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-history-interface:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>delta</var> is 0, then <a href="#reload" id="the-history-interface:reload">reload</a> <var>document</var>'s <a href="#node-navigable" id="the-history-interface:node-navigable">node
   navigable</a>, and return.</p></li><li><p><a href="#traverse-the-history-by-a-delta" id="the-history-interface:traverse-the-history-by-a-delta">Traverse the history by a delta</a> given <var>document</var>'s <a href="#node-navigable" id="the-history-interface:node-navigable-2">node
   navigable</a>'s <a href="#nav-traversable" id="the-history-interface:nav-traversable">traversable navigable</a>, <var>delta</var>,
   and with <i id="the-history-interface:traverse-sourcedocument"><a href="#traverse-sourcedocument">sourceDocument</a></i> set to
   <var>document</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="History" id="dom-history-pushstate" data-dfn-type="method"><code>pushState(<var>data</var>,
  <var>unused</var>, <var>url</var>)</code></dfn> method steps are to run the <a href="#shared-history-push/replace-state-steps" id="the-history-interface:shared-history-push/replace-state-steps">shared history
  push/replace state steps</a> given <a id="the-history-interface:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>data</var>, <var>url</var>, and
  "<code id="the-history-interface:navigationhistorybehavior-push"><a href="#navigationhistorybehavior-push">push</a></code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="History" id="dom-history-replacestate" data-dfn-type="method"><code>replaceState(<var>data</var>, <var>unused</var>,
  <var>url</var>)</code></dfn> method steps are to run the <a href="#shared-history-push/replace-state-steps" id="the-history-interface:shared-history-push/replace-state-steps-2">shared history push/replace state
  steps</a> given <a id="the-history-interface:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>data</var>, <var>url</var>, and "<code id="the-history-interface:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="shared-history-push/replace-state-steps">shared history push/replace state steps</dfn>, given a <code id="the-history-interface:history-3-7"><a href="#history-3">History</a></code>
  <var>history</var>, a value <var>data</var>, a <a id="the-history-interface:scalar-value-string" href="https://infra.spec.whatwg.org/#scalar-value-string" data-x-internal="scalar-value-string">scalar value string</a>-or-null
  <var>url</var>, and a <a href="#history-handling-behavior" id="the-history-interface:history-handling-behavior">history handling behavior</a> <var>historyHandling</var>, are:</p>

  <ol><li><p>Let <var>document</var> be <var>history</var>'s <a href="#concept-relevant-global" id="the-history-interface:concept-relevant-global-8">relevant global object</a>'s
   <a href="#concept-document-window" id="the-history-interface:concept-document-window-7">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var> is not <a href="#fully-active" id="the-history-interface:fully-active-6">fully active</a>, then throw a
   <a id="the-history-interface:securityerror-8" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-history-interface:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Optionally, throw a <a id="the-history-interface:securityerror-9" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-history-interface:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.
   (For example, the user agent might disallow calls to these methods that are invoked on a timer,
   or from event listeners that are not triggered in response to a clear user action, or that are
   invoked in rapid succession.)</p></li><li><p>Let <var>serializedData</var> be
   <a href="#structuredserializeforstorage" id="the-history-interface:structuredserializeforstorage">StructuredSerializeForStorage</a>(<var>data</var>). Rethrow any exceptions.</p></li><li><p>Let <var>newURL</var> be <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-history-interface:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li>
    <p>If <var>url</var> is not null or the empty string, then:</p>

    <ol><li><p>Set <var>newURL</var> to the result of <a href="#encoding-parsing-a-url" id="the-history-interface:encoding-parsing-a-url">encoding-parsing a URL</a> given
     <var>url</var>, relative to the <a href="#relevant-settings-object" id="the-history-interface:relevant-settings-object">relevant settings object</a> of
     <var>history</var>.</p></li><li><p>If <var>newURL</var> is failure, then throw a <a id="the-history-interface:securityerror-10" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
     <code id="the-history-interface:domexception-10"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>document</var> <a href="#can-have-its-url-rewritten" id="the-history-interface:can-have-its-url-rewritten-3">cannot have its URL
     rewritten</a> to <var>newURL</var>, then throw a <a id="the-history-interface:securityerror-11" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
     <code id="the-history-interface:domexception-11"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>

    <p class="note">The special case for the empty string here is historical, and leads to
    different resulting URLs when comparing code such as <code>location.href = ""</code>
    (which performs URL parsing on the empty string) versus <code>history.pushState(null, "", "")</code> (which bypasses it).</p>
   </li><li><p>Let <var>navigation</var> be <var>history</var>'s <a href="#concept-relevant-global" id="the-history-interface:concept-relevant-global-9">relevant global object</a>'s
   <a href="#window-navigation-api" id="the-history-interface:window-navigation-api">navigation API</a>.</p></li><li><p>Let <var>continue</var> be the result of <a href="#fire-a-push/replace/reload-navigate-event" id="the-history-interface:fire-a-push/replace/reload-navigate-event">firing a push/replace/reload <code>navigate</code> event</a> at
   <var>navigation</var> with <i id="the-history-interface:fire-navigate-prr-navigationtype"><a href="#fire-navigate-prr-navigationtype">navigationType</a></i> set to
   <var>historyHandling</var>, <i id="the-history-interface:fire-navigate-prr-issamedocument"><a href="#fire-navigate-prr-issamedocument">isSameDocument</a></i> set
   to true, <i id="the-history-interface:fire-navigate-prr-destinationurl"><a href="#fire-navigate-prr-destinationurl">destinationURL</a></i> set to
   <var>newURL</var>, and <i id="the-history-interface:fire-navigate-prr-classichistoryapistate"><a href="#fire-navigate-prr-classichistoryapistate">classicHistoryAPIState</a></i> set to
   <var>serializedData</var>.</p></li><li><p>If <var>continue</var> is false, then return.</p>

   </li><li><p>Run the <a href="#url-and-history-update-steps" id="the-history-interface:url-and-history-update-steps">URL and history update steps</a> given <var>document</var> and
   <var>newURL</var>, with <i id="the-history-interface:uhus-serializeddata"><a href="#uhus-serializeddata">serializedData</a></i> set to
   <var>serializedData</var> and <i id="the-history-interface:uhus-historyhandling"><a href="#uhus-historyhandling">historyHandling</a></i> set to
   <var>historyHandling</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>User agents may limit the number of state objects added to the session history per page. If a
  page hits the <a id="the-history-interface:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> limit, user agents must remove the entry
  immediately after the first entry for that <code id="the-history-interface:document-4"><a href="#document">Document</a></code> object in the session history
  after having added the new entry. (Thus the state history acts as a FIFO buffer for eviction, but
  as a LIFO buffer for navigation.)</p>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-history-interface:document-5"><a href="#document">Document</a></code> <var>document</var> <dfn id="can-have-its-url-rewritten">can have its URL rewritten</dfn> to a
  <a id="the-history-interface:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>targetURL</var> if the following algorithm returns true:</p>

  <ol><li><p>Let <var>documentURL</var> be <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-history-interface:the-document's-address-2" data-x-internal="the-document's-address">URL</a>.</p></li><li><p>If <var>targetURL</var> and <var>documentURL</var> differ in their <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="the-history-interface:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a>, <a href="https://url.spec.whatwg.org/#concept-url-username" id="the-history-interface:concept-url-username" data-x-internal="concept-url-username">username</a>,
   <a href="https://url.spec.whatwg.org/#concept-url-password" id="the-history-interface:concept-url-password" data-x-internal="concept-url-password">password</a>, <a href="https://url.spec.whatwg.org/#concept-url-host" id="the-history-interface:concept-url-host" data-x-internal="concept-url-host">host</a>, or <a href="https://url.spec.whatwg.org/#concept-url-port" id="the-history-interface:concept-url-port" data-x-internal="concept-url-port">port</a>
   components, then return false.</p></li><li>
    <p>If <var>targetURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="the-history-interface:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a> is an
    <a id="the-history-interface:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>, then return true.</p>

    <p class="note">Differences in <a href="https://url.spec.whatwg.org/#concept-url-path" id="the-history-interface:concept-url-path" data-x-internal="concept-url-path">path</a>, <a href="https://url.spec.whatwg.org/#concept-url-query" id="the-history-interface:concept-url-query" data-x-internal="concept-url-query">query</a>, and <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-history-interface:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> are allowed for <code id="the-history-interface:http-protocol"><a data-x-internal="http-protocol" href="https://httpwg.org/specs/rfc7230.html#http.uri">http:</a></code> and <code id="the-history-interface:https-protocol"><a data-x-internal="https-protocol" href="https://httpwg.org/specs/rfc7230.html#https.uri">https:</a></code> URLs.</p>
   </li><li>
    <p>If <var>targetURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="the-history-interface:concept-url-scheme-3" data-x-internal="concept-url-scheme">scheme</a> is "<code>file</code>", then:</p>

    <ol><li><p>If <var>targetURL</var> and <var>documentURL</var> differ in their <a href="https://url.spec.whatwg.org/#concept-url-path" id="the-history-interface:concept-url-path-2" data-x-internal="concept-url-path">path</a> component, then return false.</p></li><li><p>Return true.</p></li></ol>

    <p class="note">Differences in <a href="https://url.spec.whatwg.org/#concept-url-query" id="the-history-interface:concept-url-query-2" data-x-internal="concept-url-query">query</a> and <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-history-interface:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a> are allowed for <code>file:</code>
    URLs.</p>
   </li><li>
    <p>If <var>targetURL</var> and <var>documentURL</var> differ in their <a href="https://url.spec.whatwg.org/#concept-url-path" id="the-history-interface:concept-url-path-3" data-x-internal="concept-url-path">path</a> component or <a href="https://url.spec.whatwg.org/#concept-url-query" id="the-history-interface:concept-url-query-3" data-x-internal="concept-url-query">query</a> components, then return false.</p>

    <p class="note">Only differences in <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-history-interface:concept-url-fragment-3" data-x-internal="concept-url-fragment">fragment</a> are
    allowed for other types of URLs.</p>
   </li><li><p>Return true.</p></li></ol>
  </div>

  

  <div class="example">
   <table><thead><tr><th><var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-history-interface:the-document's-address-3" data-x-internal="the-document's-address">URL</a>
      </th><th><var>targetURL</var>
      </th><th><a href="#can-have-its-url-rewritten" id="can-have-its-url-rewritten-dev">can have its URL rewritten</a>
    </th></tr></thead><tbody><tr><td><code>https://example.com/home</code>
      </td><td><code>https://example.com/home#about</code>
      </td><td>✅
     </td></tr><tr><td><code>https://example.com/home</code>
      </td><td><code>https://example.com/home?page=shop</code>
      </td><td>✅
     </td></tr><tr><td><code>https://example.com/home</code>
      </td><td><code>https://example.com/shop</code>
      </td><td>✅
     </td></tr><tr><td><code>https://example.com/home</code>
      </td><td><code>https://user:pass@example.com/home</code>
      </td><td>❌
     </td></tr><tr><td><code>https://example.com/home</code>
      </td><td><code>http://example.com/home</code>
      </td><td>❌
     </td></tr><tr><td><code>file:///path/to/x</code>
      </td><td><code>file:///path/to/x#hash</code>
      </td><td>✅
     </td></tr><tr><td><code>file:///path/to/x</code>
      </td><td><code>file:///path/to/x?search</code>
      </td><td>✅
     </td></tr><tr><td><code>file:///path/to/x</code>
      </td><td><code>file:///path/to/y</code>
      </td><td>❌
     </td></tr><tr><td><code>about:blank</code>
      </td><td><code>about:blank#hash</code>
      </td><td>✅
     </td></tr><tr><td><code>about:blank</code>
      </td><td><code>about:blank?search</code>
      </td><td>❌
     </td></tr><tr><td><code>about:blank</code>
      </td><td><code>about:srcdoc</code>
      </td><td>❌
     </td></tr><tr><td><code>data:text/html,foo</code>
      </td><td><code>data:text/html,foo#hash</code>
      </td><td>✅
     </td></tr><tr><td><code>data:text/html,foo</code>
      </td><td><code>data:text/html,foo?search</code>
      </td><td>❌
     </td></tr><tr><td><code>data:text/html,foo</code>
      </td><td><code>data:text/html,bar</code>
      </td><td>❌
     </td></tr><tr><td><code>data:text/html,foo</code>
      </td><td><code>data:bar</code>
      </td><td>❌
     </td></tr><tr><td><code>blob:https://example.com/77becafe-657b-4fdc-8bd3-e83aaa5e8f43</code>
      </td><td><code>blob:https://example.com/77becafe-657b-4fdc-8bd3-e83aaa5e8f43#hash</code>
      </td><td>✅
     </td></tr><tr><td><code>blob:https://example.com/77becafe-657b-4fdc-8bd3-e83aaa5e8f43</code>
      </td><td><code>blob:https://example.com/77becafe-657b-4fdc-8bd3-e83aaa5e8f43?search</code>
      </td><td>❌
     </td></tr><tr><td><code>blob:https://example.com/77becafe-657b-4fdc-8bd3-e83aaa5e8f43</code>
      </td><td><code>blob:https://example.com/anything</code>
      </td><td>❌
     </td></tr><tr><td><code>blob:https://example.com/77becafe-657b-4fdc-8bd3-e83aaa5e8f43</code>
      </td><td><code>blob:path</code>
      </td><td>❌
   </td></tr></tbody></table>

   <p>Note how only the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-history-interface:the-document's-address-4" data-x-internal="the-document's-address">URL</a> of the <code id="the-history-interface:document-6"><a href="#document">Document</a></code>
   matters, and not its <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-history-interface:concept-document-origin" data-x-internal="concept-document-origin">origin</a>. They can mismatch in
   cases like <code id="the-history-interface:about:blank"><a href="#about:blank">about:blank</a></code> <code id="the-history-interface:document-7"><a href="#document">Document</a></code>s with inherited origins, in sandboxed
   <code id="the-history-interface:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s, or when the <code id="the-history-interface:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code>
   setter has been used.</p>
  </div>

  <div class="example">

   <p>Consider a game where the user can navigate along a line, such that the user is always at some
   coordinate, and such that the user can bookmark the page corresponding to a particular
   coordinate, to return to it later.</p>

   <p>A static page implementing the x=5 position in such a game could look like the following:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- c="">&lt;!-- this is https://example.com/line?x=5 --&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Line Game - 5<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You are at coordinate 5 on the line.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?x=6"</c-><c- p="">&gt;</c->Advance to 6<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> or
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?x=4"</c-><c- p="">&gt;</c->retreat to 4<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->?
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>The problem with such a system is that each time the user clicks, the whole page has to be
   reloaded. Here instead is another way of doing it, using script:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- c="">&lt;!-- this starts off as https://example.com/line?x=5 --&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Line Game - 5<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You are at coordinate <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"coord"</c-><c- p="">&gt;</c->5<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-> on the line.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?x=6"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"go(1); return false;"</c-><c- p="">&gt;</c->Advance to 6<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-> or
 <c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"?x=4"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"go(-1); return false;"</c-><c- p="">&gt;</c->retreat to 4<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c->?
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> currentPage <c- o="">=</c-> <c- mf="">5</c-><c- p="">;</c-> <c- c1="">// prefilled by server</c->
 <c- a="">function</c-> go<c- p="">(</c->d<c- p="">)</c-> <c- p="">{</c->
   setupPage<c- p="">(</c->currentPage <c- o="">+</c-> d<c- p="">);</c->
   history<c- p="">.</c->pushState<c- p="">(</c->currentPage<c- p="">,</c-> <c- u="">""</c-><c- p="">,</c-> <c- t="">'?x='</c-> <c- o="">+</c-> currentPage<c- p="">);</c->
 <c- p="">}</c->
 onpopstate <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
   setupPage<c- p="">(</c->event<c- p="">.</c->state<c- p="">);</c->
 <c- p="">}</c->
 <c- a="">function</c-> setupPage<c- p="">(</c->page<c- p="">)</c-> <c- p="">{</c->
   currentPage <c- o="">=</c-> page<c- p="">;</c->
   document<c- p="">.</c->title <c- o="">=</c-> <c- t="">'Line Game - '</c-> <c- o="">+</c-> currentPage<c- p="">;</c->
   document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'coord'</c-><c- p="">).</c->textContent <c- o="">=</c-> currentPage<c- p="">;</c->
   document<c- p="">.</c->links<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->href <c- o="">=</c-> <c- t="">'?x='</c-> <c- o="">+</c-> <c- p="">(</c->currentPage<c- o="">+</c-><c- mf="">1</c-><c- p="">);</c->
   document<c- p="">.</c->links<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->textContent <c- o="">=</c-> <c- t="">'Advance to '</c-> <c- o="">+</c-> <c- p="">(</c->currentPage<c- o="">+</c-><c- mf="">1</c-><c- p="">);</c->
   document<c- p="">.</c->links<c- p="">[</c-><c- mf="">1</c-><c- p="">].</c->href <c- o="">=</c-> <c- t="">'?x='</c-> <c- o="">+</c-> <c- p="">(</c->currentPage<c- o="">-</c-><c- mf="">1</c-><c- p="">);</c->
   document<c- p="">.</c->links<c- p="">[</c-><c- mf="">1</c-><c- p="">].</c->textContent <c- o="">=</c-> <c- t="">'retreat to '</c-> <c- o="">+</c-> <c- p="">(</c->currentPage<c- o="">-</c-><c- mf="">1</c-><c- p="">);</c->
 <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>In systems without script, this still works like the previous example. However, users that
   <em>do</em> have script support can now navigate much faster, since there is no network access
   for the same experience. Furthermore, contrary to the experience the user would have with just a
   naïve script-based approach, bookmarking and navigating the session history still work.</p>

   <p>In the example above, the <var>data</var> argument to the <code id="the-history-interface:dom-history-pushstate-3"><a href="#dom-history-pushstate">pushState()</a></code> method is the same information as would be sent
   to the server, but in a more convenient form, so that the script doesn't have to parse the URL
   each time the user navigates.</p>

  </div>

  <div class="example">
   <p>Most applications want to use the same <a href="#scroll-restoration-mode" id="the-history-interface:scroll-restoration-mode">scroll restoration mode</a> value for all of
   their history entries. To achieve this they can set the <code id="the-history-interface:dom-history-scroll-restoration-4"><a href="#dom-history-scroll-restoration">scrollRestoration</a></code> attribute as soon as possible
   (e.g., in the first <code id="the-history-interface:the-script-element"><a href="#the-script-element">script</a></code> element in the document's <code id="the-history-interface:the-head-element"><a href="#the-head-element">head</a></code> element) to
   ensure that any entry added to the history session gets the desired scroll restoration mode.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
       <c- k="">if</c-> <c- p="">(</c-><c- t="">'scrollRestoration'</c-> <c- k="">in</c-> history<c- p="">)</c->
            history<c- p="">.</c->scrollRestoration <c- o="">=</c-> <c- t="">'manual'</c-><c- p="">;</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
   </code></pre>
  </div>


  <h4 id="navigation-api"><span class="secno">7.2.6</span> The navigation API<a href="#navigation-api" class="self-link"></a></h4>

  <h5 id="navigation-api-intro"><span class="secno">7.2.6.1</span> Introduction<a href="#navigation-api-intro" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>The navigation API, provided by the global <code id="navigation-api-intro:dom-navigation"><a href="#dom-navigation">navigation</a></code>
  property, provides a modern and web application-focused way of managing navigations and history entries. It is a successor to the classic <code id="navigation-api-intro:dom-location"><a href="#dom-location">location</a></code> and <code id="navigation-api-intro:dom-history"><a href="#dom-history">history</a></code> APIs.</p>

  <p>One ability the API provides is inspecting <a href="#session-history-entry" id="navigation-api-intro:session-history-entry">session history entries</a>. For example, the following will display the entries' URLs in an ordered list:</p>

  <pre><code class="js"><c- a="">const</c-> ol <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"ol"</c-><c- p="">);</c->
ol<c- p="">.</c->start <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> <c- c1="">// so that the list items' ordinal values match up with the entry indices</c->

<c- k="">for</c-> <c- p="">(</c-><c- a="">const</c-> entry <c- k="">of</c-> navigation<c- p="">.</c->entries<c- p="">())</c-> <c- p="">{</c->
  <c- a="">const</c-> li <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"li"</c-><c- p="">);</c->

  <c- k="">if</c-> <c- p="">(</c->entry<c- p="">.</c->index <c- o="">&lt;</c-> navigation<c- p="">.</c->currentEntry<c- p="">.</c->index<c- p="">)</c-> <c- p="">{</c->
    li<c- p="">.</c->className <c- o="">=</c-> <c- u="">"backward"</c-><c- p="">;</c->
  <c- p="">}</c-> <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c->entry<c- p="">.</c->index <c- o="">&gt;</c-> navigation<c- p="">.</c->currentEntry<c- p="">.</c->index<c- p="">)</c-> <c- p="">{</c->
    li<c- p="">.</c->className <c- o="">=</c-> <c- u="">"forward"</c-><c- p="">;</c->
  <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
    li<c- p="">.</c->className <c- o="">=</c-> <c- u="">"current"</c-><c- p="">;</c->
  <c- p="">}</c->

  li<c- p="">.</c->textContent <c- o="">=</c-> entry<c- p="">.</c->url<c- p="">;</c->
  ol<c- p="">.</c->append<c- p="">(</c->li<c- p="">);</c->
<c- p="">}</c-></code></pre>

  <p>The <code id="navigation-api-intro:dom-navigation-entries"><a href="#dom-navigation-entries">navigation.entries()</a></code> array contains <code id="navigation-api-intro:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> instances, which have other useful properties in addition to the <code id="navigation-api-intro:dom-navigationhistoryentry-url"><a href="#dom-navigationhistoryentry-url">url</a></code> and <code id="navigation-api-intro:dom-navigationhistoryentry-index"><a href="#dom-navigationhistoryentry-index">index</a></code> properties shown here. Note that the array only contains <code id="navigation-api-intro:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> objects that represent the current <a href="#navigable" id="navigation-api-intro:navigable">navigable</a>, and thus its contents are not impacted by navigations inside <a href="#navigable-container" id="navigation-api-intro:navigable-container">navigable containers</a> such as <code id="navigation-api-intro:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s, or by navigations of the <a href="#nav-parent" id="navigation-api-intro:nav-parent">parent navigable</a> in cases where the navigation API is itself being used inside an <code id="navigation-api-intro:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>. Additionally, it only contains <code id="navigation-api-intro:navigationhistoryentry-3"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> objects representing same-<a href="#concept-origin" id="navigation-api-intro:concept-origin">origin</a> <a href="#session-history-entry" id="navigation-api-intro:session-history-entry-2">session history entries</a>, meaning that if the user has visited other origins before or after the current one, there will not be corresponding <code id="navigation-api-intro:navigationhistoryentry-4"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>s.</p>

  <hr>

  <p>The navigation API can also be used to navigate, reload, or traverse through the history:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"navigation.reload()"</c-><c- p="">&gt;</c->Reload<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"navigationURL"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"navigation.navigate(navigationURL.value)"</c-><c- p="">&gt;</c->Navigate<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"backButton"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"navigation.back()"</c-><c- p="">&gt;</c->Back<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"forwardButton"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"navigation.forward()"</c-><c- p="">&gt;</c->Forward<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">select</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"traversalDestinations"</c-><c- p="">&gt;&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"goButton"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"navigation.traverseTo(traversalDestinations.value)"</c-><c- p="">&gt;</c->Traverse To<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
backButton<c- p="">.</c->disabled <c- o="">=</c-> <c- o="">!</c->navigation<c- p="">.</c->canGoBack<c- p="">;</c->
forwardButton<c- p="">.</c->disabled <c- o="">=</c-> <c- o="">!</c->navigation<c- p="">.</c->canGoForward<c- p="">;</c->

<c- k="">for</c-> <c- p="">(</c-><c- a="">const</c-> entry <c- k="">of</c-> navigation<c- p="">.</c->entries<c- p="">())</c-> <c- p="">{</c->
  traversalDestinations<c- p="">.</c->append<c- p="">(</c-><c- k="">new</c-> Option<c- p="">(</c->entry<c- p="">.</c->url<c- p="">,</c-> entry<c- p="">.</c->key<c- p="">));</c->
<c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  <p>Note that traversals are again limited to same-<a href="#concept-origin" id="navigation-api-intro:concept-origin-2">origin</a> destinations, meaning that, for example, <code id="navigation-api-intro:dom-navigation-cangoback"><a href="#dom-navigation-cangoback">navigation.canGoBack</a></code> will be false if the previous <a href="#session-history-entry" id="navigation-api-intro:session-history-entry-3">session history entry</a> is for a page from another origin.</p>

  <hr>

  <p>The most powerful part of the navigation API is the <code id="navigation-api-intro:event-navigate"><a href="#event-navigate">navigate</a></code> event, which fires whenever almost any navigation or traversal occurs in the current <a href="#navigable" id="navigation-api-intro:navigable-2">navigable</a>:</p>

  <pre><code class="js">navigation<c- p="">.</c->onnavigate <c- o="">=</c-> event <c- p="">=&gt;</c-> <c- p="">{</c->
  console<c- p="">.</c->log<c- p="">(</c->event<c- p="">.</c->navigationType<c- p="">);</c-> <c- c1="">// "push", "replace", "reload", or "traverse"</c->
  console<c- p="">.</c->log<c- p="">(</c->event<c- p="">.</c->destination<c- p="">.</c->url<c- p="">);</c->
  console<c- p="">.</c->log<c- p="">(</c->event<c- p="">.</c->userInitiated<c- p="">);</c->
  <c- c1="">// ... and </c-><a href="#the-navigateevent-interface"><c- c1="">other useful properties</c-></a>
<c- p="">};</c-></code></pre>

  <p>(The event will not fire for <a href="#nav-traversal-ui">location bar-initiated navigations</a>, or navigations initiated from other windows, when the destination of the navigation is a new document.)</p>

  <p>Much of the time, the event's <code id="navigation-api-intro:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> property will be true, meaning this event can be canceled using <code id="navigation-api-intro:dom-event-preventdefault"><a data-x-internal="dom-event-preventdefault" href="https://dom.spec.whatwg.org/#dom-event-preventdefault">preventDefault()</a></code>:</p>

  <pre><code class="js">navigation<c- p="">.</c->onnavigate <c- o="">=</c-> event <c- p="">=&gt;</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->cancelable <c- o="">&amp;&amp;</c-> isDisallowedURL<c- p="">(</c->event<c- p="">.</c->destination<c- p="">.</c->url<c- p="">))</c-> <c- p="">{</c->
    alert<c- p="">(</c-><c- sb="">`Please don't go to </c-><c- si="">${</c->event<c- p="">.</c->destination<c- p="">.</c->url<c- si="">}</c-><c- sb="">!`</c-><c- p="">);</c->
    event<c- p="">.</c->preventDefault<c- p="">();</c->
  <c- p="">}</c->
<c- p="">};</c->
</code></pre>

  <p>The <code id="navigation-api-intro:dom-event-cancelable-2"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> property will be false for some "<code id="navigation-api-intro:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigations, such as those taking place inside <a href="#child-navigable" id="navigation-api-intro:child-navigable">child navigables</a>, those crossing to new origins, or when the user attempts to traverse again shortly after a previous call to <code id="navigation-api-intro:dom-event-preventdefault-2"><a data-x-internal="dom-event-preventdefault" href="https://dom.spec.whatwg.org/#dom-event-preventdefault">preventDefault()</a></code> prevented them from doing so.</p>

  <p>The <code id="navigation-api-intro:navigateevent"><a href="#navigateevent">NavigateEvent</a></code>'s <code id="navigation-api-intro:dom-navigateevent-intercept"><a href="#dom-navigateevent-intercept">intercept()</a></code> method allows intercepting a navigation and converting it into a same-document navigation:</p>

  <pre><code class="js">navigation<c- p="">.</c->addEventListener<c- p="">(</c-><c- u="">"navigate"</c-><c- p="">,</c-> e <c- p="">=&gt;</c-> <c- p="">{</c->
  <c- c1="">// Some navigations, e.g. cross-origin navigations, we cannot intercept.</c->
  <c- c1="">// Let the browser handle those normally.</c->
  <c- k="">if</c-> <c- p="">(</c-><c- o="">!</c->e<c- p="">.</c->canIntercept<c- p="">)</c-> <c- p="">{</c->
    <c- k="">return</c-><c- p="">;</c->
  <c- p="">}</c->

  <c- c1="">// Similarly, don't intercept fragment navigations or downloads.</c->
  <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->hashChange <c- o="">||</c-> e<c- p="">.</c->downloadRequest <c- o="">!==</c-> <c- kc="">null</c-><c- p="">)</c-> <c- p="">{</c->
    <c- k="">return</c-><c- p="">;</c->
  <c- p="">}</c->

  <c- a="">const</c-> url <c- o="">=</c-> <c- k="">new</c-> URL<c- p="">(</c->event<c- p="">.</c->destination<c- p="">.</c->url<c- p="">);</c->

  <c- k="">if</c-> <c- p="">(</c->url<c- p="">.</c->pathname<c- p="">.</c->startsWith<c- p="">(</c-><c- u="">"/articles/"</c-><c- p="">))</c-> <c- p="">{</c->
    e<c- p="">.</c->intercept<c- p="">({</c->
      <c- k="">async</c-> handler<c- p="">()</c-> <c- p="">{</c->
        <c- c1="">// The URL has already changed, so show a placeholder while</c->
        <c- c1="">// fetching the new content, such as a spinner or loading page.</c->
        renderArticlePagePlaceholder<c- p="">();</c->

        <c- c1="">// Fetch the new content and display when ready.</c->
        <c- a="">const</c-> articleContent <c- o="">=</c-> <c- k="">await</c-> getArticleContent<c- p="">(</c->url<c- p="">.</c->pathname<c- p="">,</c-> <c- p="">{</c-> signal<c- o="">:</c-> e<c- p="">.</c->signal <c- p="">});</c->
        renderArticlePage<c- p="">(</c->articleContent<c- p="">);</c->
      <c- p="">}</c->
    <c- p="">});</c->
  <c- p="">}</c->
<c- p="">});</c-></code></pre>

  <p>Note that the <code id="navigation-api-intro:dom-navigationinterceptoptions-handler"><a href="#dom-navigationinterceptoptions-handler">handler</a></code> function can return a promise to represent the asynchronous progress, and success or failure, of the navigation. While the promise is still pending, browser UI can treat the navigation as ongoing (e.g., by presenting a loading spinner). Other parts of the navigation API are also sensitive to these promises, such as the return value of <code id="navigation-api-intro:dom-navigation-navigate"><a href="#dom-navigation-navigate">navigation.navigate()</a></code>:

  </p><pre><code class="js"><c- a="">const</c-> <c- p="">{</c-> committed<c- p="">,</c-> finished <c- p="">}</c-> <c- o="">=</c-> <c- k="">await</c-> navigation<c- p="">.</c->navigate<c- p="">(</c-><c- u="">"/articles/the-navigation-api-is-cool"</c-><c- p="">);</c->

<c- c1="">// The committed promise will fulfill once the URL has changed, which happens</c->
<c- c1="">// immediately (as long as the NavigateEvent wasn't canceled).</c->
<c- k="">await</c-> committed<c- p="">;</c->

<c- c1="">// The finished promise will fulfill once the Promise returned by handler() has</c->
<c- c1="">// fulfilled, which happens once the article is downloaded and rendered. (Or,</c->
<c- c1="">// it will reject, if handler() fails along the way).</c->
<c- k="">await</c-> finished<c- p="">;</c-></code></pre>

  <h5 id="navigation-interface"><span class="secno">7.2.6.2</span> The <code id="navigation-interface:navigation"><a href="#navigation">Navigation</a></code> interface<a href="#navigation-interface" class="self-link"></a></h5>

  

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="navigation" data-dfn-type="interface"><c- g="">Navigation</c-></dfn> : <a id="navigation-interface:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <c- b="">sequence</c->&lt;<a href="#navigationhistoryentry" id="navigation-interface:navigationhistoryentry"><c- n="">NavigationHistoryEntry</c-></a>&gt; <a href="#dom-navigation-entries" id="navigation-interface:dom-navigation-entries"><c- g="">entries</c-></a>();
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationhistoryentry" id="navigation-interface:navigationhistoryentry-2"><c- n="">NavigationHistoryEntry</c-></a>? <a href="#dom-navigation-currententry" id="navigation-interface:dom-navigation-currententry"><c- g="">currentEntry</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-navigation-updatecurrententry" id="navigation-interface:dom-navigation-updatecurrententry"><c- g="">updateCurrentEntry</c-></a>(<a href="#navigationupdatecurrententryoptions" id="navigation-interface:navigationupdatecurrententryoptions"><c- n="">NavigationUpdateCurrentEntryOptions</c-></a> <c- g="">options</c->);
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationtransition" id="navigation-interface:navigationtransition"><c- n="">NavigationTransition</c-></a>? <a href="#dom-navigation-transition" id="navigation-interface:dom-navigation-transition"><c- g="">transition</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationactivation" id="navigation-interface:navigationactivation"><c- n="">NavigationActivation</c-></a>? <a href="#dom-navigation-activation" id="navigation-interface:dom-navigation-activation"><c- g="">activation</c-></a>;

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigation-cangoback" id="navigation-interface:dom-navigation-cangoback"><c- g="">canGoBack</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigation-cangoforward" id="navigation-interface:dom-navigation-cangoforward"><c- g="">canGoForward</c-></a>;

  <a href="#navigationresult" id="navigation-interface:navigationresult"><c- n="">NavigationResult</c-></a> <a href="#dom-navigation-navigate" id="navigation-interface:dom-navigation-navigate"><c- g="">navigate</c-></a>(<c- b="">USVString</c-> <c- g="">url</c->, <c- b="">optional</c-> <a href="#navigationnavigateoptions" id="navigation-interface:navigationnavigateoptions"><c- n="">NavigationNavigateOptions</c-></a> <c- g="">options</c-> = {});
  <a href="#navigationresult" id="navigation-interface:navigationresult-2"><c- n="">NavigationResult</c-></a> <a href="#dom-navigation-reload" id="navigation-interface:dom-navigation-reload"><c- g="">reload</c-></a>(<c- b="">optional</c-> <a href="#navigationreloadoptions" id="navigation-interface:navigationreloadoptions"><c- n="">NavigationReloadOptions</c-></a> <c- g="">options</c-> = {});

  <a href="#navigationresult" id="navigation-interface:navigationresult-3"><c- n="">NavigationResult</c-></a> <a href="#dom-navigation-traverseto" id="navigation-interface:dom-navigation-traverseto"><c- g="">traverseTo</c-></a>(<c- b="">DOMString</c-> <c- g="">key</c->, <c- b="">optional</c-> <a href="#navigationoptions" id="navigation-interface:navigationoptions"><c- n="">NavigationOptions</c-></a> <c- g="">options</c-> = {});
  <a href="#navigationresult" id="navigation-interface:navigationresult-4"><c- n="">NavigationResult</c-></a> <a href="#dom-navigation-back" id="navigation-interface:dom-navigation-back"><c- g="">back</c-></a>(<c- b="">optional</c-> <a href="#navigationoptions" id="navigation-interface:navigationoptions-2"><c- n="">NavigationOptions</c-></a> <c- g="">options</c-> = {});
  <a href="#navigationresult" id="navigation-interface:navigationresult-5"><c- n="">NavigationResult</c-></a> <a href="#dom-navigation-forward" id="navigation-interface:dom-navigation-forward"><c- g="">forward</c-></a>(<c- b="">optional</c-> <a href="#navigationoptions" id="navigation-interface:navigationoptions-3"><c- n="">NavigationOptions</c-></a> <c- g="">options</c-> = {});

  <c- b="">attribute</c-> <a href="#eventhandler" id="navigation-interface:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-navigation-onnavigate" id="navigation-interface:handler-navigation-onnavigate"><c- g="">onnavigate</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="navigation-interface:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-navigation-onnavigatesuccess" id="navigation-interface:handler-navigation-onnavigatesuccess"><c- g="">onnavigatesuccess</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="navigation-interface:eventhandler-3"><c- n="">EventHandler</c-></a> <a href="#handler-navigation-onnavigateerror" id="navigation-interface:handler-navigation-onnavigateerror"><c- g="">onnavigateerror</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="navigation-interface:eventhandler-4"><c- n="">EventHandler</c-></a> <a href="#handler-navigation-oncurrententrychange" id="navigation-interface:handler-navigation-oncurrententrychange"><c- g="">oncurrententrychange</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="navigationupdatecurrententryoptions" data-dfn-type="dictionary"><c- g="">NavigationUpdateCurrentEntryOptions</c-></dfn> {
  <c- b="">required</c-> <c- b="">any</c-> <dfn data-dfn-for="NavigationUpdateCurrentEntryOptions" id="dom-navigationupdatecurrententryoptions-state" data-dfn-type="dict-member"><c- g="">state</c-></dfn>;
};

<c- b="">dictionary</c-> <dfn id="navigationoptions" data-dfn-type="dictionary"><c- g="">NavigationOptions</c-></dfn> {
  <c- b="">any</c-> <dfn data-dfn-for="NavigationOptions" id="dom-navigationoptions-info" data-dfn-type="dict-member"><c- g="">info</c-></dfn>;
};

<c- b="">dictionary</c-> <dfn id="navigationnavigateoptions" data-dfn-type="dictionary"><c- g="">NavigationNavigateOptions</c-></dfn> : <a href="#navigationoptions" id="navigation-interface:navigationoptions-4"><c- n="">NavigationOptions</c-></a> {
  <c- b="">any</c-> <dfn data-dfn-for="NavigationNavigateOptions" id="dom-navigationnavigateoptions-state" data-dfn-type="dict-member"><c- g="">state</c-></dfn>;
  <a href="#navigationhistorybehavior" id="navigation-interface:navigationhistorybehavior"><c- n="">NavigationHistoryBehavior</c-></a> <dfn data-dfn-for="NavigationNavigateOptions" id="dom-navigationnavigateoptions-history" data-dfn-type="dict-member"><c- g="">history</c-></dfn> = "<a href="#navigationhistorybehavior-auto" id="navigation-interface:navigationhistorybehavior-auto">auto</a>";
};

<c- b="">dictionary</c-> <dfn id="navigationreloadoptions" data-dfn-type="dictionary"><c- g="">NavigationReloadOptions</c-></dfn> : <a href="#navigationoptions" id="navigation-interface:navigationoptions-5"><c- n="">NavigationOptions</c-></a> {
  <c- b="">any</c-> <dfn data-dfn-for="NavigationNavigateOptions" id="dom-navigationreloadoptions-state" data-dfn-type="dict-member"><c- g="">state</c-></dfn>;
};

<c- b="">dictionary</c-> <dfn id="navigationresult" data-dfn-type="dictionary"><c- g="">NavigationResult</c-></dfn> {
  <a href="https://webidl.spec.whatwg.org/#idl-promise" id="navigation-interface:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<a href="#navigationhistoryentry" id="navigation-interface:navigationhistoryentry-3"><c- n="">NavigationHistoryEntry</c-></a>&gt; <dfn data-dfn-for="NavigationResult" id="dom-navigationresult-committed" data-dfn-type="dict-member"><c- g="">committed</c-></dfn>;
  <a href="https://webidl.spec.whatwg.org/#idl-promise" id="navigation-interface:idl-promise-2" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<a href="#navigationhistoryentry" id="navigation-interface:navigationhistoryentry-4"><c- n="">NavigationHistoryEntry</c-></a>&gt; <dfn data-dfn-for="NavigationResult" id="dom-navigationresult-finished" data-dfn-type="dict-member"><c- g="">finished</c-></dfn>;
};

<c- b="">enum</c-> <dfn id="navigationhistorybehavior" data-dfn-type="enum"><c- g="">NavigationHistoryBehavior</c-></dfn> {
  <c- s="">"</c-><a href="#navigationhistorybehavior-auto" id="navigation-interface:navigationhistorybehavior-auto-2"><c- s="">auto</c-></a><c- s="">"</c->,
  <c- s="">"</c-><a href="#navigationhistorybehavior-push" id="navigation-interface:navigationhistorybehavior-push"><c- s="">push</c-></a><c- s="">"</c->,
  <c- s="">"</c-><a href="#navigationhistorybehavior-replace" id="navigation-interface:navigationhistorybehavior-replace"><c- s="">replace</c-></a><c- s="">"</c->
};</code></pre>

  <div data-algorithm="">
  <p>Each <code id="navigation-interface:window"><a href="#window">Window</a></code> has an associated <dfn id="window-navigation-api">navigation
  API</dfn>, which is a <code id="navigation-interface:navigation-2"><a href="#navigation">Navigation</a></code> object. Upon creation of the <code id="navigation-interface:window-2"><a href="#window">Window</a></code>
  object, its <a href="#window-navigation-api" id="navigation-interface:window-navigation-api">navigation API</a> must be set to a
  <a id="navigation-interface:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigation-interface:navigation-3"><a href="#navigation">Navigation</a></code> object created in the <code id="navigation-interface:window-3"><a href="#window">Window</a></code> object's <a href="#concept-relevant-realm" id="navigation-interface:concept-relevant-realm">relevant realm</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-navigation" data-dfn-type="attribute"><code>navigation</code></dfn> getter
  steps are to return <a id="navigation-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#window-navigation-api" id="navigation-interface:window-navigation-api-2">navigation
  API</a>.</p>
  </div>

  

  <p>The following are the <a href="#event-handlers" id="navigation-interface:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="navigation-interface:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="navigation-interface:event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the
  <code id="navigation-interface:navigation-4"><a href="#navigation">Navigation</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="navigation-interface:event-handlers-2">Event handler</a>
     </th><th><a href="#event-handler-event-type" id="navigation-interface:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="Navigation" id="handler-navigation-onnavigate" data-dfn-type="attribute"><code>onnavigate</code></dfn>
     </td><td><code id="navigation-interface:event-navigate"><a href="#event-navigate">navigate</a></code>
    </td></tr><tr><td><dfn data-dfn-for="Navigation" id="handler-navigation-onnavigatesuccess" data-dfn-type="attribute"><code>onnavigatesuccess</code></dfn>
     </td><td><code id="navigation-interface:event-navigatesuccess"><a href="#event-navigatesuccess">navigatesuccess</a></code>
    </td></tr><tr><td><dfn data-dfn-for="Navigation" id="handler-navigation-onnavigateerror" data-dfn-type="attribute"><code>onnavigateerror</code></dfn>
     </td><td><code id="navigation-interface:event-navigateerror"><a href="#event-navigateerror">navigateerror</a></code>
    </td></tr><tr><td><dfn data-dfn-for="Navigation" id="handler-navigation-oncurrententrychange" data-dfn-type="attribute"><code>oncurrententrychange</code></dfn>
     </td><td><code id="navigation-interface:event-currententrychange"><a href="#event-currententrychange">currententrychange</a></code>
  </td></tr></tbody></table>

  <h5 id="navigation-api-core"><span class="secno">7.2.6.3</span> Core infrastructure<a href="#navigation-api-core" class="self-link"></a></h5>

  

  <p>Each <code id="navigation-api-core:navigation"><a href="#navigation">Navigation</a></code> has an associated <dfn id="navigation-entry-list">entry
  list</dfn>, a <a id="navigation-api-core:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <code id="navigation-api-core:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> objects, initially
  empty.</p>

  <p>Each <code id="navigation-api-core:navigation-2"><a href="#navigation">Navigation</a></code> has an associated <dfn id="navigation-current-entry-index">current entry index</dfn>, an integer, initially
  −1.</p>

  <div data-algorithm="">
  <p>The <dfn id="navigation-current-entry">current entry</dfn> of a <code id="navigation-api-core:navigation-3"><a href="#navigation">Navigation</a></code>
  <var>navigation</var> is the result of running the following steps:</p>

  <ol><li><p>If <var>navigation</var> <a href="#has-entries-and-events-disabled" id="navigation-api-core:has-entries-and-events-disabled">has entries and events disabled</a>, then return
   null.</p></li><li><p><a id="navigation-api-core:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-core:navigation-current-entry-index">current entry index</a> is not −1.</p></li><li><p>Return <var>navigation</var>'s <a href="#navigation-entry-list" id="navigation-api-core:navigation-entry-list">entry
   list</a>[<var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-core:navigation-current-entry-index-2">current entry
   index</a>].</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <code id="navigation-api-core:navigation-4"><a href="#navigation">Navigation</a></code> <var>navigation</var> <dfn id="has-entries-and-events-disabled">has entries and events disabled</dfn> if
  the following steps return true:</p>

  <ol><li><p>Let <var>document</var> be <var>navigation</var>'s <a href="#concept-relevant-global" id="navigation-api-core:concept-relevant-global">relevant global object</a>'s
   <a href="#concept-document-window" id="navigation-api-core:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var> is not <a href="#fully-active" id="navigation-api-core:fully-active">fully active</a>, then return true.</p></li><li><p>If <var>document</var>'s <a href="#is-initial-about:blank" id="navigation-api-core:is-initial-about:blank">is initial <code>about:blank</code></a> is true, then
   return true.</p></li><li><p>If <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="navigation-api-core:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is <a href="#concept-origin-opaque" id="navigation-api-core:concept-origin-opaque">opaque</a>, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="getting-the-navigation-api-entry-index">get the navigation API entry
  index</dfn> of a <a href="#session-history-entry" id="navigation-api-core:session-history-entry">session history entry</a> <var>she</var> within a
  <code id="navigation-api-core:navigation-5"><a href="#navigation">Navigation</a></code> <var>navigation</var>:</p>

  <ol><li><p>Let <var>index</var> be 0.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigation-api-core:list-iterate" data-x-internal="list-iterate">For each</a> <var>nhe</var> of <var>navigation</var>'s <a href="#navigation-entry-list" id="navigation-api-core:navigation-entry-list-2">entry list</a>:</p>

    <ol><li><p>If <var>nhe</var>'s <a href="#nhe-she" id="navigation-api-core:nhe-she">session history entry</a> is equal to
     <var>she</var>, then return <var>index</var>.</p></li><li><p>Increment <var>index</var> by 1.</p></li></ol>
   </li><li><p>Return −1.</p></li></ol>
  </div>

  <hr>

  

  <p>A key type used throughout the navigation API is the <code id="navigation-api-core:navigationtype"><a href="#navigationtype">NavigationType</a></code>
  enumeration:</p>

  <pre><code class="idl"><c- b="">enum</c-> <dfn id="navigationtype" data-dfn-type="enum"><c- g="">NavigationType</c-></dfn> {
 <c- s="">"</c-><a href="#dom-navigationtype-push" id="navigation-api-core:dom-navigationtype-push"><c- s="">push</c-></a><c- s="">"</c->,
 <c- s="">"</c-><a href="#dom-navigationtype-replace" id="navigation-api-core:dom-navigationtype-replace"><c- s="">replace</c-></a><c- s="">"</c->,
 <c- s="">"</c-><a href="#dom-navigationtype-reload" id="navigation-api-core:dom-navigationtype-reload"><c- s="">reload</c-></a><c- s="">"</c->,
 <c- s="">"</c-><a href="#dom-navigationtype-traverse" id="navigation-api-core:dom-navigationtype-traverse"><c- s="">traverse</c-></a><c- s="">"</c->
};</code></pre>

  <p>This captures the main web developer-visible types of "navigations", which (as <a href="#note-meaning-of-navigate">noted elsewhere</a>) do not exactly correspond to this standard's
  singular <a href="#navigate" id="navigation-api-core:navigate">navigate</a> algorithm. The meaning of each value is the following:</p>

  <dl><dt>"<dfn data-dfn-for="NavigationType" id="dom-navigationtype-push" data-dfn-type="enum-value"><code>push</code></dfn>"</dt><dd>Corresponds to calls to <a href="#navigate" id="navigation-api-core:navigate-2">navigate</a> where the <a href="#history-handling-behavior" id="navigation-api-core:history-handling-behavior">history handling
   behavior</a> ends up as "<code id="navigation-api-core:navigationhistorybehavior-push"><a href="#navigationhistorybehavior-push">push</a></code>", or to
   <code id="navigation-api-core:dom-history-pushstate"><a href="#dom-history-pushstate">history.pushState()</a></code>.</dd><dt>"<dfn data-dfn-for="NavigationType" id="dom-navigationtype-replace" data-dfn-type="enum-value"><code>replace</code></dfn>"</dt><dd>Corresponds to calls to <a href="#navigate" id="navigation-api-core:navigate-3">navigate</a> where the <a href="#history-handling-behavior" id="navigation-api-core:history-handling-behavior-2">history handling
   behavior</a> ends up as "<code id="navigation-api-core:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>", or
   to <code id="navigation-api-core:dom-history-pushstate-2"><a href="#dom-history-pushstate">history.replaceState()</a></code>.</dd><dt>"<dfn data-dfn-for="NavigationType" id="dom-navigationtype-reload" data-dfn-type="enum-value"><code>reload</code></dfn>"</dt><dd>Corresponds to calls to <a href="#reload" id="navigation-api-core:reload">reload</a>.</dd><dt>"<dfn data-dfn-for="NavigationType" id="dom-navigationtype-traverse" data-dfn-type="enum-value"><code>traverse</code></dfn>"</dt><dd>Corresponds to calls to <a href="#traverse-the-history-by-a-delta" id="navigation-api-core:traverse-the-history-by-a-delta">traverse the history by a delta</a>.</dd></dl>

  

  <p class="note">The value space of the <code id="navigation-api-core:navigationtype-2"><a href="#navigationtype">NavigationType</a></code> enumeration is a superset of
  the value space of the specification-internal <a href="#history-handling-behavior" id="navigation-api-core:history-handling-behavior-3">history handling behavior</a> type. Several
  parts of this standard make use of this overlap, by passing in a <a href="#history-handling-behavior" id="navigation-api-core:history-handling-behavior-4">history handling
  behavior</a> to an algorithm that expects a <code id="navigation-api-core:navigationtype-3"><a href="#navigationtype">NavigationType</a></code>.</p>


  <h5 id="navigation-api-entry-updates"><span class="secno">7.2.6.4</span> Initializing and updating the entry list<a href="#navigation-api-entry-updates" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="initialize-the-navigation-api-entries-for-a-new-document">initialize the navigation API entries for a new document</dfn> given a
  <code id="navigation-api-entry-updates:navigation"><a href="#navigation">Navigation</a></code> <var>navigation</var>, a <a id="navigation-api-entry-updates:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#session-history-entry" id="navigation-api-entry-updates:session-history-entry">session history entries</a> <var>newSHEs</var>, and a <a href="#session-history-entry" id="navigation-api-entry-updates:session-history-entry-2">session history
  entry</a> <var>initialSHE</var>:</p>

  <ol><li><p><a id="navigation-api-entry-updates:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigation</var>'s <a href="#navigation-entry-list" id="navigation-api-entry-updates:navigation-entry-list">entry
   list</a> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="navigation-api-entry-updates:list-is-empty" data-x-internal="list-is-empty">is empty</a>.</p></li><li><p><a id="navigation-api-entry-updates:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-entry-updates:navigation-current-entry-index">current entry index</a> is −1.</p></li><li><p>If <var>navigation</var> <a href="#has-entries-and-events-disabled" id="navigation-api-entry-updates:has-entries-and-events-disabled">has entries and events disabled</a>, then
   return.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigation-api-entry-updates:list-iterate" data-x-internal="list-iterate">For each</a> <var>newSHE</var> of <var>newSHEs</var>:</p>

    <ol><li><p>Let <var>newNHE</var> be a <a id="navigation-api-entry-updates:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigation-api-entry-updates:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> created
     in the <a href="#concept-relevant-realm" id="navigation-api-entry-updates:concept-relevant-realm">relevant realm</a> of
     <var>navigation</var>.</p></li><li><p>Set <var>newNHE</var>'s <a href="#nhe-she" id="navigation-api-entry-updates:nhe-she">session history entry</a> to
     <var>newSHE</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="navigation-api-entry-updates:list-append" data-x-internal="list-append">Append</a> <var>newNHE</var> to <var>navigation</var>'s
     <a href="#navigation-entry-list" id="navigation-api-entry-updates:navigation-entry-list-2">entry list</a>.</p></li></ol>

    <p class="note"><var>newSHEs</var> will have originally come from <a href="#getting-session-history-entries-for-the-navigation-api" id="navigation-api-entry-updates:getting-session-history-entries-for-the-navigation-api">getting session history
    entries for the navigation API</a>, and thus each <var>newSHE</var> will be contiguous <a href="#same-origin" id="navigation-api-entry-updates:same-origin">same</a> <a href="#document-state-origin" id="navigation-api-entry-updates:document-state-origin">origin</a> with
    <var>initialSHE</var>.</p>
   </li><li><p>Set <var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-entry-updates:navigation-current-entry-index-2">current entry
   index</a> to the result of <a href="#getting-the-navigation-api-entry-index" id="navigation-api-entry-updates:getting-the-navigation-api-entry-index">getting the navigation API entry index</a> of
   <var>initialSHE</var> within <var>navigation</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="update-the-navigation-api-entries-for-reactivation">update the navigation API entries for reactivation</dfn> given a
  <code id="navigation-api-entry-updates:navigation-2"><a href="#navigation">Navigation</a></code> <var>navigation</var>, a <a id="navigation-api-entry-updates:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#session-history-entry" id="navigation-api-entry-updates:session-history-entry-3">session history entries</a> <var>newSHEs</var>, and a <a href="#session-history-entry" id="navigation-api-entry-updates:session-history-entry-4">session history
  entry</a> <var>reactivatedSHE</var>:</p>

  <ol><li><p>If <var>navigation</var> <a href="#has-entries-and-events-disabled" id="navigation-api-entry-updates:has-entries-and-events-disabled-2">has entries and events disabled</a>, then
   return.</p></li><li><p>Let <var>newNHEs</var> be a new empty <a id="navigation-api-entry-updates:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>Let <var>oldNHEs</var> be a <a href="https://infra.spec.whatwg.org/#list-clone" id="navigation-api-entry-updates:list-clone" data-x-internal="list-clone">clone</a> of
   <var>navigation</var>'s <a href="#navigation-entry-list" id="navigation-api-entry-updates:navigation-entry-list-3">entry list</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigation-api-entry-updates:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>newSHE</var> of <var>newSHEs</var>:</p>

    <ol><li><p>Let <var>newNHE</var> be null.</p></li><li>
      <p>If <var>oldNHEs</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="navigation-api-entry-updates:list-contains" data-x-internal="list-contains">contains</a> a
      <code id="navigation-api-entry-updates:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> <var>matchingOldNHE</var> whose <a href="#nhe-she" id="navigation-api-entry-updates:nhe-she-2">session history entry</a> is <var>newSHE</var>, then:</p>

      <ol><li><p>Set <var>newNHE</var> to <var>matchingOldNHE</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="navigation-api-entry-updates:list-remove" data-x-internal="list-remove">Remove</a> <var>matchingOldNHE</var> from
       <var>oldNHEs</var>.</p></li></ol>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p>Set <var>newNHE</var> to a <a id="navigation-api-entry-updates:new-2" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigation-api-entry-updates:navigationhistoryentry-3"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>
       created in the <a href="#concept-relevant-realm" id="navigation-api-entry-updates:concept-relevant-realm-2">relevant realm</a> of
       <var>navigation</var>.</p></li><li><p>Set <var>newNHE</var>'s <a href="#nhe-she" id="navigation-api-entry-updates:nhe-she-3">session history entry</a> to
       <var>newSHE</var>.</p></li></ol>
     </li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="navigation-api-entry-updates:list-append-2" data-x-internal="list-append">Append</a> <var>newNHE</var> to
     <var>newNHEs</var>.</p></li></ol>

    <p class="note"><var>newSHEs</var> will have originally come from <a href="#getting-session-history-entries-for-the-navigation-api" id="navigation-api-entry-updates:getting-session-history-entries-for-the-navigation-api-2">getting session history
    entries for the navigation API</a>, and thus each <var>newSHE</var> will be contiguous <a href="#same-origin" id="navigation-api-entry-updates:same-origin-2">same</a> <a href="#document-state-origin" id="navigation-api-entry-updates:document-state-origin-2">origin</a> with
    <var>reactivatedSHE</var>.</p>

    <p class="note">By the end of this loop, all <code id="navigation-api-entry-updates:navigationhistoryentry-4"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>s that remain in
    <var>oldNHEs</var> represent <a href="#session-history-entry" id="navigation-api-entry-updates:session-history-entry-5">session history entries</a>
    which have been disposed while the <code id="navigation-api-entry-updates:document"><a href="#document">Document</a></code> was in <a href="#note-bfcache">bfcache</a>.</p>
   </li><li><p>Set <var>navigation</var>'s <a href="#entry-list" id="navigation-api-entry-updates:entry-list">entry list</a> to <var>newNHEs</var>.</p></li><li><p>Set <var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-entry-updates:navigation-current-entry-index-3">current entry
   index</a> to the result of <a href="#getting-the-navigation-api-entry-index" id="navigation-api-entry-updates:getting-the-navigation-api-entry-index-2">getting the navigation API entry index</a> of
   <var>reactivatedSHE</var> within <var>navigation</var>.</p></li><li>
    <p><a href="#queue-a-global-task" id="navigation-api-entry-updates:queue-a-global-task">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="navigation-api-entry-updates:navigation-and-traversal-task-source">navigation and traversal task source</a>
    given <var>navigation</var>'s <a href="#concept-relevant-global" id="navigation-api-entry-updates:concept-relevant-global">relevant global object</a> to run the following
    steps:</p>

    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigation-api-entry-updates:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>disposedNHE</var> of
      <var>oldNHEs</var>:</p>

      <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="navigation-api-entry-updates:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="navigation-api-entry-updates:event-dispose"><a href="#event-dispose">dispose</a></code> at <var>disposedNHE</var>.</p></li></ol>
     </li></ol>

    <div class="note">
     <p>We delay these steps by a task to ensure that <code id="navigation-api-entry-updates:event-dispose-2"><a href="#event-dispose">dispose</a></code>
     events will fire after the <code id="navigation-api-entry-updates:event-pageshow"><a href="#event-pageshow">pageshow</a></code> event. This ensures
     that <code id="navigation-api-entry-updates:event-pageshow-2"><a href="#event-pageshow">pageshow</a></code> is the first event a page receives upon
     <a href="#reactivate-a-document" id="navigation-api-entry-updates:reactivate-a-document">reactivation</a>.</p>

     <p>(However, the rest of this algorithm runs before the <code id="navigation-api-entry-updates:event-pageshow-3"><a href="#event-pageshow">pageshow</a></code> event fires. This ensures that <code id="navigation-api-entry-updates:dom-navigation-entries"><a href="#dom-navigation-entries">navigation.entries()</a></code> and <code id="navigation-api-entry-updates:dom-navigation-currententry"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> will have correctly-updated
     values during any <code id="navigation-api-entry-updates:event-pageshow-4"><a href="#event-pageshow">pageshow</a></code> event handlers.)</p>
    </div>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="update-the-navigation-api-entries-for-a-same-document-navigation">update the navigation API entries for a same-document navigation</dfn> given a
  <code id="navigation-api-entry-updates:navigation-3"><a href="#navigation">Navigation</a></code> <var>navigation</var>, a <a href="#session-history-entry" id="navigation-api-entry-updates:session-history-entry-6">session history entry</a>
  <var>destinationSHE</var>, and a <code id="navigation-api-entry-updates:navigationtype"><a href="#navigationtype">NavigationType</a></code> <var>navigationType</var>:</p>

  <ol><li><p>If <var>navigation</var> <a href="#has-entries-and-events-disabled" id="navigation-api-entry-updates:has-entries-and-events-disabled-3">has entries and events disabled</a>, then
   return.</p></li><li><p>Let <var>oldCurrentNHE</var> be the <a href="#navigation-current-entry" id="navigation-api-entry-updates:navigation-current-entry">current
   entry</a> of <var>navigation</var>.</p></li><li><p>Let <var>disposedNHEs</var> be a new empty <a id="navigation-api-entry-updates:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p>If <var>navigationType</var> is "<code id="navigation-api-entry-updates:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>",
    then:</p>

    <ol><li><p>Set <var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-entry-updates:navigation-current-entry-index-4">current entry
     index</a> to the result of <a href="#getting-the-navigation-api-entry-index" id="navigation-api-entry-updates:getting-the-navigation-api-entry-index-3">getting the navigation API entry index</a> of
     <var>destinationSHE</var> within <var>navigation</var>.</p></li><li><p><a id="navigation-api-entry-updates:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-entry-updates:navigation-current-entry-index-5">current entry index</a> is not −1.</p></li></ol>

    <p class="note">This algorithm is only called for same-document traversals. Cross-document
    traversals will instead call either <a href="#initialize-the-navigation-api-entries-for-a-new-document" id="navigation-api-entry-updates:initialize-the-navigation-api-entries-for-a-new-document">initialize the navigation API entries for a new
    document</a> or <a href="#update-the-navigation-api-entries-for-reactivation" id="navigation-api-entry-updates:update-the-navigation-api-entries-for-reactivation">update the navigation API entries for reactivation</a>.</p>
   </li><li>
    <p>Otherwise, if <var>navigationType</var> is "<code id="navigation-api-entry-updates:dom-navigationtype-push"><a href="#dom-navigationtype-push">push</a></code>", then:</p>

    <ol><li><p>Set <var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-entry-updates:navigation-current-entry-index-6">current entry
     index</a> to <var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-entry-updates:navigation-current-entry-index-7">current
     entry index</a> + 1.</p></li><li><p>Let <var>i</var> be <var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-entry-updates:navigation-current-entry-index-8">current entry index</a>.</p></li><li>
      <p><a id="navigation-api-entry-updates:while" href="https://infra.spec.whatwg.org/#iteration-while" data-x-internal="while">While</a> <var>i</var> &lt; <var>navigation</var>'s <a href="#navigation-entry-list" id="navigation-api-entry-updates:navigation-entry-list-4">entry list</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="navigation-api-entry-updates:list-size" data-x-internal="list-size">size</a>:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="navigation-api-entry-updates:list-append-3" data-x-internal="list-append">Append</a> <var>navigation</var>'s <a href="#navigation-entry-list" id="navigation-api-entry-updates:navigation-entry-list-5">entry list</a>[<var>i</var>] to
       <var>disposedNHEs</var>.</p></li><li><p>Set <var>i</var> to <var>i</var> + 1.</p></li></ol>
     </li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="navigation-api-entry-updates:list-remove-2" data-x-internal="list-remove">Remove</a> all items in <var>disposedNHEs</var> from
     <var>navigation</var>'s <a href="#navigation-entry-list" id="navigation-api-entry-updates:navigation-entry-list-6">entry list</a>.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>navigationType</var> is "<code id="navigation-api-entry-updates:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>", then:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="navigation-api-entry-updates:list-append-4" data-x-internal="list-append">Append</a> <var>oldCurrentNHE</var> to
     <var>disposedNHEs</var>.</p></li></ol>
   </li><li>
    <p>If <var>navigationType</var> is "<code id="navigation-api-entry-updates:dom-navigationtype-push-2"><a href="#dom-navigationtype-push">push</a></code>" or
    "<code id="navigation-api-entry-updates:dom-navigationtype-replace-2"><a href="#dom-navigationtype-replace">replace</a></code>", then:</p>

    <ol><li><p>Let <var>newNHE</var> be a <a id="navigation-api-entry-updates:new-3" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigation-api-entry-updates:navigationhistoryentry-5"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> created
     in the <a href="#concept-relevant-realm" id="navigation-api-entry-updates:concept-relevant-realm-3">relevant realm</a> of
     <var>navigation</var>.</p></li><li><p>Set <var>newNHE</var>'s <a href="#nhe-she" id="navigation-api-entry-updates:nhe-she-4">session history entry</a> to
     <var>destinationSHE</var>.</p></li><li><p>Set <var>navigation</var>'s <a href="#navigation-entry-list" id="navigation-api-entry-updates:navigation-entry-list-7">entry
     list</a>[<var>navigation</var>'s <a href="#navigation-current-entry-index" id="navigation-api-entry-updates:navigation-current-entry-index-9">current entry
     index</a>] to <var>newNHE</var>.</p></li></ol>
   </li><li>
    <p>If <var>navigation</var>'s <a href="#ongoing-api-method-tracker" id="navigation-api-entry-updates:ongoing-api-method-tracker">ongoing API method tracker</a> is non-null, then
    <a href="#notify-about-the-committed-to-entry" id="navigation-api-entry-updates:notify-about-the-committed-to-entry">notify about the committed-to entry</a> given <var>navigation</var>'s <a href="#ongoing-api-method-tracker" id="navigation-api-entry-updates:ongoing-api-method-tracker-2">ongoing API
    method tracker</a> and the <a href="#navigation-current-entry" id="navigation-api-entry-updates:navigation-current-entry-2">current entry</a> of
    <var>navigation</var>.</p>

    <p class="note">It is important to do this before firing the <code id="navigation-api-entry-updates:event-dispose-3"><a href="#event-dispose">dispose</a></code> or <code id="navigation-api-entry-updates:event-currententrychange"><a href="#event-currententrychange">currententrychange</a></code> events, since event handlers could
    start another navigation, or otherwise change the value of <var>navigation</var>'s <a href="#ongoing-api-method-tracker" id="navigation-api-entry-updates:ongoing-api-method-tracker-3">ongoing
    API method tracker</a>.</p>
   </li><li>
    <p><a href="#prepare-to-run-script" id="navigation-api-entry-updates:prepare-to-run-script">Prepare to run script</a> given <var>navigation</var>'s <a href="#relevant-settings-object" id="navigation-api-entry-updates:relevant-settings-object">relevant settings
    object</a>.</p>

    <p class="note">See <a href="#note-suppress-microtasks-during-navigation-events">the discussion
    for other navigation API events</a> to understand why we do this.</p>
   </li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="navigation-api-entry-updates:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="navigation-api-entry-updates:event-currententrychange-2"><a href="#event-currententrychange">currententrychange</a></code> at <var>navigation</var> using
   <code id="navigation-api-entry-updates:navigationcurrententrychangeevent"><a href="#navigationcurrententrychangeevent">NavigationCurrentEntryChangeEvent</a></code>, with its <code id="navigation-api-entry-updates:dom-navigationcurrententrychangeevent-navigationtype"><a href="#dom-navigationcurrententrychangeevent-navigationtype">navigationType</a></code> attribute
   initialized to <var>navigationType</var> and its <code id="navigation-api-entry-updates:dom-navigationcurrententrychangeevent-from"><a href="#dom-navigationcurrententrychangeevent-from">from</a></code> initialized to
   <var>oldCurrentNHE</var>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigation-api-entry-updates:list-iterate-4" data-x-internal="list-iterate">For each</a> <var>disposedNHE</var> of
    <var>disposedNHEs</var>:</p>

    <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="navigation-api-entry-updates:concept-event-fire-3" data-x-internal="concept-event-fire">Fire an event</a> named <code id="navigation-api-entry-updates:event-dispose-4"><a href="#event-dispose">dispose</a></code> at <var>disposedNHE</var>.</p></li></ol>
   </li><li><p><a href="#clean-up-after-running-script" id="navigation-api-entry-updates:clean-up-after-running-script">Clean up after running script</a> given <var>navigation</var>'s <a href="#relevant-settings-object" id="navigation-api-entry-updates:relevant-settings-object-2">relevant
   settings object</a>.</p></li></ol>
  </div>

  <p class="XXX">In implementations, same-document navigations can cause <a href="#session-history-entry" id="navigation-api-entry-updates:session-history-entry-7">session history entries</a> to be disposed by falling off the back of the
  session history entry list. This is not yet handled by the above algorithm (or by any other part
  of this standard). See <a href="https://github.com/whatwg/html/issues/8620">issue #8620</a> to
  track progress on defining the correct behavior in such cases.</p>

  


  <h5 id="the-navigationhistoryentry-interface"><span class="secno">7.2.6.5</span> The <code id="the-navigationhistoryentry-interface:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> interface<a href="#the-navigationhistoryentry-interface" class="self-link"></a></h5>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="navigationhistoryentry" data-dfn-type="interface"><c- g="">NavigationHistoryEntry</c-></dfn> : <a id="the-navigationhistoryentry-interface:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c->? <a href="#dom-navigationhistoryentry-url" id="the-navigationhistoryentry-interface:dom-navigationhistoryentry-url"><c- g="">url</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigationhistoryentry-key" id="the-navigationhistoryentry-interface:dom-navigationhistoryentry-key"><c- g="">key</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigationhistoryentry-id" id="the-navigationhistoryentry-interface:dom-navigationhistoryentry-id"><c- g="">id</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">long</c-> <c- b="">long</c-> <a href="#dom-navigationhistoryentry-index" id="the-navigationhistoryentry-interface:dom-navigationhistoryentry-index"><c- g="">index</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigationhistoryentry-samedocument" id="the-navigationhistoryentry-interface:dom-navigationhistoryentry-samedocument"><c- g="">sameDocument</c-></a>;

  <c- b="">any</c-> <a href="#dom-navigationhistoryentry-getstate" id="the-navigationhistoryentry-interface:dom-navigationhistoryentry-getstate"><c- g="">getState</c-></a>();

  <c- b="">attribute</c-> <a href="#eventhandler" id="the-navigationhistoryentry-interface:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-navigationhistoryentry-ondispose" id="the-navigationhistoryentry-interface:handler-navigationhistoryentry-ondispose"><c- g="">ondispose</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>entry</var>.<a href="#dom-navigationhistoryentry-url" id="dom-navigationhistoryentry-url-dev">url</a></code></dt><dd>
    <p>The URL of this navigation history entry.</p>

    <p>This can return null if the entry corresponds to a different <code id="the-navigationhistoryentry-interface:document"><a href="#document">Document</a></code> than the
    current one (i.e., if <code id="the-navigationhistoryentry-interface:dom-navigationhistoryentry-samedocument-2"><a href="#dom-navigationhistoryentry-samedocument">sameDocument</a></code>
    is false), and that <code id="the-navigationhistoryentry-interface:document-2"><a href="#document">Document</a></code> was fetched with a <a id="the-navigationhistoryentry-interface:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a> of
    "<code>no-referrer</code>" or "<code>origin</code>", since that indicates
    the <code id="the-navigationhistoryentry-interface:document-3"><a href="#document">Document</a></code> in question is hiding its URL even from other same-origin pages.</p>
   </dd><dt><code><var>entry</var>.<a href="#dom-navigationhistoryentry-key" id="dom-navigationhistoryentry-key-dev">key</a></code></dt><dd>
    <p>A user agent-generated random UUID string representing this navigation history entry's place
    in the navigation history list. This value will be reused by other
    <code id="the-navigationhistoryentry-interface:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> instances that replace this one due to "<code id="the-navigationhistoryentry-interface:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>" navigations, and will survive reloads and
    session restores.</p>

    <p>This is useful for navigating back to this entry in the navigation history list, using <code id="the-navigationhistoryentry-interface:dom-navigation-traverseto"><a href="#dom-navigation-traverseto">navigation.traverseTo(key)</a></code>.</p>
   </dd><dt><code><var>entry</var>.<a href="#dom-navigationhistoryentry-id" id="dom-navigationhistoryentry-id-dev">id</a></code></dt><dd>
    <p>A user agent-generated random UUID string representing this specific navigation history
    entry. This value will <em>not</em> be reused by other <code id="the-navigationhistoryentry-interface:navigationhistoryentry-3"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>
    instances. This value will survive reloads and session restores.</p>

    <p>This is useful for associating data with this navigation history entry using other storage
    APIs.</p>
   </dd><dt><code><var>entry</var>.<a href="#dom-navigationhistoryentry-index" id="dom-navigationhistoryentry-index-dev">index</a></code></dt><dd><p>The index of this <code id="the-navigationhistoryentry-interface:navigationhistoryentry-4"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> within <code id="the-navigationhistoryentry-interface:dom-navigation-entries"><a href="#dom-navigation-entries">navigation.entries()</a></code>, or −1 if the entry is not in
   the navigation history entry list.</p></dd><dt><code><var>entry</var>.<a href="#dom-navigationhistoryentry-samedocument" id="dom-navigationhistoryentry-samedocument-dev">sameDocument</a></code></dt><dd><p>Indicates whether or not this navigation history entry is for the same
   <code id="the-navigationhistoryentry-interface:document-4"><a href="#document">Document</a></code> as the current one, or not. This will be true, for example, when the entry
   represents a fragment navigation or single-page app navigation.</p></dd><dt><code><var>entry</var>.<a href="#dom-navigationhistoryentry-getstate" id="dom-navigationhistoryentry-getstate-dev">getState</a>()</code></dt><dd>
    <p>Returns the <a href="#structureddeserialize" id="the-navigationhistoryentry-interface:structureddeserialize">deserialization</a> of the state stored
    in this entry, which was added to the entry using <code id="the-navigationhistoryentry-interface:dom-navigation-navigate"><a href="#dom-navigation-navigate">navigation.navigate()</a></code> or <code id="the-navigationhistoryentry-interface:dom-navigation-updatecurrententry"><a href="#dom-navigation-updatecurrententry">navigation.updateCurrentEntry()</a></code>. This state
    survives reloads and session restores.</p>

    <p>Note that in general, unless the state value is a primitive, <code class="js">entry.getState() !== entry.getState()</code>, since a fresh deserialization is
    returned each time.</p>

    <p>This state is unrelated to the classic history API's <code id="the-navigationhistoryentry-interface:dom-history-state"><a href="#dom-history-state">history.state</a></code>.</p>
   </dd></dl>

  

  <p>Each <code id="the-navigationhistoryentry-interface:navigationhistoryentry-5"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> has an associated <dfn id="nhe-she">session
  history entry</dfn>, which is a <a href="#session-history-entry" id="the-navigationhistoryentry-interface:session-history-entry">session history entry</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="concept-navigationhistoryentry-key">key</dfn> of a
  <code id="the-navigationhistoryentry-interface:navigationhistoryentry-6"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> <var>nhe</var> is given by the return value of the following
  algorithm:</p>

  <ol><li><p>If <var>nhe</var>'s <a href="#concept-relevant-global" id="the-navigationhistoryentry-interface:concept-relevant-global">relevant global object</a>'s <a href="#concept-document-window" id="the-navigationhistoryentry-interface:concept-document-window">associated <code>Document</code></a> is not <a href="#fully-active" id="the-navigationhistoryentry-interface:fully-active">fully
   active</a>, then return the empty string.</p></li><li><p>Return <var>nhe</var>'s <a href="#nhe-she" id="the-navigationhistoryentry-interface:nhe-she">session history entry</a>'s <a href="#she-navigation-api-key" id="the-navigationhistoryentry-interface:she-navigation-api-key">navigation API key</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="concept-navigationhistoryentry-id">ID</dfn> of a
  <code id="the-navigationhistoryentry-interface:navigationhistoryentry-7"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> <var>nhe</var> is given by the return value of the following
  algorithm:</p>

  <ol><li><p>If <var>nhe</var>'s <a href="#concept-relevant-global" id="the-navigationhistoryentry-interface:concept-relevant-global-2">relevant global object</a>'s <a href="#concept-document-window" id="the-navigationhistoryentry-interface:concept-document-window-2">associated <code>Document</code></a> is not <a href="#fully-active" id="the-navigationhistoryentry-interface:fully-active-2">fully
   active</a>, then return the empty string.</p></li><li><p>Return <var>nhe</var>'s <a href="#nhe-she" id="the-navigationhistoryentry-interface:nhe-she-2">session history entry</a>'s <a href="#she-navigation-api-id" id="the-navigationhistoryentry-interface:she-navigation-api-id">navigation API ID</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="concept-navigationhistoryentry-index">index</dfn> of a
  <code id="the-navigationhistoryentry-interface:navigationhistoryentry-8"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> <var>nhe</var> is given by the return value of the following
  algorithm:</p>

  <ol><li><p>If <var>nhe</var>'s <a href="#concept-relevant-global" id="the-navigationhistoryentry-interface:concept-relevant-global-3">relevant global object</a>'s <a href="#concept-document-window" id="the-navigationhistoryentry-interface:concept-document-window-3">associated <code>Document</code></a> is not <a href="#fully-active" id="the-navigationhistoryentry-interface:fully-active-3">fully
   active</a>, then return −1.</p></li><li><p>Return the result of <a href="#getting-the-navigation-api-entry-index" id="the-navigationhistoryentry-interface:getting-the-navigation-api-entry-index">getting the navigation API entry index</a> of
   <a id="the-navigationhistoryentry-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#nhe-she" id="the-navigationhistoryentry-interface:nhe-she-3">session history entry</a> within
   <a id="the-navigationhistoryentry-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-navigationhistoryentry-interface:concept-relevant-global-4">relevant global object</a>'s <a href="#window-navigation-api" id="the-navigationhistoryentry-interface:window-navigation-api">navigation API</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationHistoryEntry" id="dom-navigationhistoryentry-url" data-dfn-type="attribute"><code>url</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>document</var> be <a id="the-navigationhistoryentry-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-navigationhistoryentry-interface:concept-relevant-global-5">relevant global object</a>'s <a href="#concept-document-window" id="the-navigationhistoryentry-interface:concept-document-window-4">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var> is not <a href="#fully-active" id="the-navigationhistoryentry-interface:fully-active-4">fully active</a>, then return the empty
   string.</p></li><li><p>Let <var>she</var> be <a id="the-navigationhistoryentry-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#nhe-she" id="the-navigationhistoryentry-interface:nhe-she-4">session history
   entry</a>.</p></li><li><p>If <var>she</var>'s <a href="#she-document" id="the-navigationhistoryentry-interface:she-document">document</a> does not equal
   <var>document</var>, and <var>she</var>'s <a href="#she-document-state" id="the-navigationhistoryentry-interface:she-document-state">document
   state</a>'s <a href="#document-state-request-referrer-policy" id="the-navigationhistoryentry-interface:document-state-request-referrer-policy">request referrer
   policy</a> is "<code>no-referrer</code>" or "<code>origin</code>", then
   return null.</p></li><li><p>Return <var>she</var>'s <a href="#she-url" id="the-navigationhistoryentry-interface:she-url">URL</a>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-navigationhistoryentry-interface:concept-url-serializer" data-x-internal="concept-url-serializer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationHistoryEntry" id="dom-navigationhistoryentry-key" data-dfn-type="attribute"><code>key</code></dfn> getter steps are to return
  <a id="the-navigationhistoryentry-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationhistoryentry-key" id="the-navigationhistoryentry-interface:concept-navigationhistoryentry-key">key</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationHistoryEntry" id="dom-navigationhistoryentry-id" data-dfn-type="attribute"><code>id</code></dfn> getter steps are to return
  <a id="the-navigationhistoryentry-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationhistoryentry-id" id="the-navigationhistoryentry-interface:concept-navigationhistoryentry-id">ID</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationHistoryEntry" id="dom-navigationhistoryentry-index" data-dfn-type="attribute"><code>index</code></dfn> getter steps are to return
  <a id="the-navigationhistoryentry-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationhistoryentry-index" id="the-navigationhistoryentry-interface:concept-navigationhistoryentry-index">index</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationHistoryEntry" id="dom-navigationhistoryentry-samedocument" data-dfn-type="attribute"><code>sameDocument</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>document</var> be <a id="the-navigationhistoryentry-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-navigationhistoryentry-interface:concept-relevant-global-6">relevant global object</a>'s <a href="#concept-document-window" id="the-navigationhistoryentry-interface:concept-document-window-5">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var> is not <a href="#fully-active" id="the-navigationhistoryentry-interface:fully-active-5">fully active</a>, then return false.</p></li><li><p>Return true if <a id="the-navigationhistoryentry-interface:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#nhe-she" id="the-navigationhistoryentry-interface:nhe-she-5">session history entry</a>'s
   <a href="#she-document" id="the-navigationhistoryentry-interface:she-document-2">document</a> equals <var>document</var>, and false
   otherwise.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationHistoryEntry" id="dom-navigationhistoryentry-getstate" data-dfn-type="method"><code>getState()</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="the-navigationhistoryentry-interface:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-navigationhistoryentry-interface:concept-relevant-global-7">relevant global object</a>'s <a href="#concept-document-window" id="the-navigationhistoryentry-interface:concept-document-window-6">associated <code>Document</code></a> is not <a href="#fully-active" id="the-navigationhistoryentry-interface:fully-active-6">fully
   active</a>, then return undefined.</p></li><li>
    <p>Return <a href="#structureddeserialize" id="the-navigationhistoryentry-interface:structureddeserialize-2">StructuredDeserialize</a>(<a id="the-navigationhistoryentry-interface:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#nhe-she" id="the-navigationhistoryentry-interface:nhe-she-6">session
    history entry</a>'s <a href="#she-navigation-api-state" id="the-navigationhistoryentry-interface:she-navigation-api-state">navigation API state</a>).
    Rethrow any exceptions.</p>

    <p class="note">This can in theory throw an exception, if attempting to deserialize a large
    <code id="the-navigationhistoryentry-interface:idl-arraybuffer"><a data-x-internal="idl-arraybuffer" href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer">ArrayBuffer</a></code> when not enough memory is available.</p>
   </li></ol>
  </div>

  

  <p>The following are the <a href="#event-handlers" id="the-navigationhistoryentry-interface:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="the-navigationhistoryentry-interface:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="the-navigationhistoryentry-interface:event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the
  <code id="the-navigationhistoryentry-interface:navigationhistoryentry-9"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="the-navigationhistoryentry-interface:event-handlers-2">Event handler</a>
     </th><th><a href="#event-handler-event-type" id="the-navigationhistoryentry-interface:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="NavigationHistoryEntry" id="handler-navigationhistoryentry-ondispose" data-dfn-type="attribute"><code>ondispose</code></dfn>
     </td><td><code id="the-navigationhistoryentry-interface:event-dispose"><a href="#event-dispose">dispose</a></code>
  </td></tr></tbody></table>


  <h5 id="the-history-entry-list"><span class="secno">7.2.6.6</span> The history entry list<a href="#the-history-entry-list" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>entries</var> = <a href="#dom-navigation" id="the-history-entry-list:dom-navigation">navigation</a>.<a href="#dom-navigation-entries" id="dom-navigation-entries-dev">entries()</a></code></dt><dd><p>Returns an array of <code id="the-history-entry-list:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> instances represent the current
   navigation history entry list, i.e., all <a href="#session-history-entry" id="the-history-entry-list:session-history-entry">session history
   entries</a> for this <a href="#navigable" id="the-history-entry-list:navigable">navigable</a> that are <a href="#same-origin" id="the-history-entry-list:same-origin">same origin</a> and contiguous
   to the <a href="#nav-current-history-entry" id="the-history-entry-list:nav-current-history-entry">current session history entry</a>.</p>

   </dd><dt><code><a href="#dom-navigation" id="the-history-entry-list:dom-navigation-2">navigation</a>.<a href="#dom-navigation-currententry" id="dom-navigation-currententry-dev">currentEntry</a></code></dt><dd><p>Returns the <code id="the-history-entry-list:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> corresponding to the <a href="#nav-current-history-entry" id="the-history-entry-list:nav-current-history-entry-2">current session history entry</a>.</p>

   </dd><dt><code><a href="#dom-navigation" id="the-history-entry-list:dom-navigation-3">navigation</a>.<a href="#dom-navigation-updatecurrententry" id="dom-navigation-updatecurrententry-dev">updateCurrentEntry</a>({ <a href="#dom-navigationupdatecurrententryoptions-state" id="the-history-entry-list:dom-navigationupdatecurrententryoptions-state">state</a> })</code></dt><dd>
    <p>Updates the <a href="#she-navigation-api-state" id="the-history-entry-list:she-navigation-api-state">navigation API state</a> of the <a href="#nav-current-history-entry" id="the-history-entry-list:nav-current-history-entry-3">current session history entry</a>, without performing a
    navigation like <code id="the-history-entry-list:dom-navigation-reload"><a href="#dom-navigation-reload">navigation.reload()</a></code> would do.</p>

    <p>This method is best used to capture updates to the page that have already happened, and need
    to be reflected into the navigation API state. For cases where the state update is meant to
    drive a page update, instead use <code id="the-history-entry-list:dom-navigation-navigate"><a href="#dom-navigation-navigate">navigation.navigate()</a></code> or <code id="the-history-entry-list:dom-navigation-reload-2"><a href="#dom-navigation-reload">navigation.reload()</a></code>, which will trigger a <code id="the-history-entry-list:event-navigate"><a href="#event-navigate">navigate</a></code> event.</p>
   </dd><dt><code><a href="#dom-navigation" id="the-history-entry-list:dom-navigation-4">navigation</a>.<a href="#dom-navigation-cangoback" id="dom-navigation-cangoback-dev">canGoBack</a></code></dt><dd><p>Returns true if the current <a href="#nav-current-history-entry" id="the-history-entry-list:nav-current-history-entry-4">current session
   history entry</a> (i.e., <code id="the-history-entry-list:dom-navigation-currententry"><a href="#dom-navigation-currententry">currentEntry</a></code>) is
   not the first one in the navigation history entry list (i.e., in <code id="the-history-entry-list:dom-navigation-entries"><a href="#dom-navigation-entries">entries()</a></code>). This means that there is a previous
   <a href="#session-history-entry" id="the-history-entry-list:session-history-entry-2">session history entry</a> for this <a href="#navigable" id="the-history-entry-list:navigable-2">navigable</a>, and its <a href="#she-document-state" id="the-history-entry-list:she-document-state">document state</a>'s <a href="#document-state-origin" id="the-history-entry-list:document-state-origin">origin</a> is <a href="#same-origin" id="the-history-entry-list:same-origin-2">same origin</a> with the current
   <code id="the-history-entry-list:document"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-history-entry-list:concept-document-origin" data-x-internal="concept-document-origin">origin</a>.</p>

   </dd><dt><code><a href="#dom-navigation" id="the-history-entry-list:dom-navigation-5">navigation</a>.<a href="#dom-navigation-cangoforward" id="dom-navigation-cangoforward-dev">canGoForward</a></code></dt><dd><p>Returns true if the current <a href="#nav-current-history-entry" id="the-history-entry-list:nav-current-history-entry-5">current session
   history entry</a> (i.e., <code id="the-history-entry-list:dom-navigation-currententry-2"><a href="#dom-navigation-currententry">currentEntry</a></code>) is
   not the last one in the navigation history entry list (i.e., in <code id="the-history-entry-list:dom-navigation-entries-2"><a href="#dom-navigation-entries">entries()</a></code>). This means that there is a next <a href="#session-history-entry" id="the-history-entry-list:session-history-entry-3">session
   history entry</a> for this <a href="#navigable" id="the-history-entry-list:navigable-3">navigable</a>, and its <a href="#she-document-state" id="the-history-entry-list:she-document-state-2">document state</a>'s <a href="#document-state-origin" id="the-history-entry-list:document-state-origin-2">origin</a> is <a href="#same-origin" id="the-history-entry-list:same-origin-3">same origin</a> with the current
   <code id="the-history-entry-list:document-2"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-history-entry-list:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>.</p>
  </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-entries" data-dfn-type="method"><code>entries()</code></dfn>
  method steps are:</p>

  <ol><li><p>If <a id="the-history-entry-list:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> <a href="#has-entries-and-events-disabled" id="the-history-entry-list:has-entries-and-events-disabled">has entries and events disabled</a>, then return the empty
   list.</p></li><li>
    <p>Return <a id="the-history-entry-list:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-entry-list" id="the-history-entry-list:navigation-entry-list">entry list</a>.</p>

    <p class="note">Recall that because of Web IDL's sequence type conversion rules, this will
    create a new JavaScript array object on each call. That is, <code><a href="#dom-navigation-entries" id="the-history-entry-list:dom-navigation-entries-3">navigation.entries()</a> !== <a href="#dom-navigation-entries" id="the-history-entry-list:dom-navigation-entries-4">navigation.entries()</a></code>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-currententry" data-dfn-type="attribute"><code>currentEntry</code></dfn> getter steps are to return the
  <a href="#navigation-current-entry" id="the-history-entry-list:navigation-current-entry">current entry</a> of <a id="the-history-entry-list:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-updatecurrententry" data-dfn-type="method"><code>updateCurrentEntry(<var>options</var>)</code></dfn>
  method steps are:</p>

  <ol><li><p>Let <var>current</var> be the <a href="#navigation-current-entry" id="the-history-entry-list:navigation-current-entry-2">current entry</a>
   of <a id="the-history-entry-list:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>If <var>current</var> is null, then throw an <a id="the-history-entry-list:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="the-history-entry-list:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>serializedState</var> be
   <a href="#structuredserializeforstorage" id="the-history-entry-list:structuredserializeforstorage">StructuredSerializeForStorage</a>(<var>options</var>["<code id="the-history-entry-list:dom-navigationupdatecurrententryoptions-state-2"><a href="#dom-navigationupdatecurrententryoptions-state">state</a></code>"]), rethrowing any
   exceptions.</p></li><li><p>Set <var>current</var>'s <a href="#nhe-she" id="the-history-entry-list:nhe-she">session history entry</a>'s <a href="#she-navigation-api-state" id="the-history-entry-list:she-navigation-api-state-2">navigation API state</a> to
   <var>serializedState</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-history-entry-list:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-history-entry-list:event-currententrychange"><a href="#event-currententrychange">currententrychange</a></code> at <a id="the-history-entry-list:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> using
   <code id="the-history-entry-list:navigationcurrententrychangeevent"><a href="#navigationcurrententrychangeevent">NavigationCurrentEntryChangeEvent</a></code>, with its <code id="the-history-entry-list:dom-navigationcurrententrychangeevent-navigationtype"><a href="#dom-navigationcurrententrychangeevent-navigationtype">navigationType</a></code> attribute
   initialized to null and its <code id="the-history-entry-list:dom-navigationcurrententrychangeevent-from"><a href="#dom-navigationcurrententrychangeevent-from">from</a></code>
   initialized to <var>current</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-cangoback" data-dfn-type="attribute"><code>canGoBack</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-history-entry-list:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> <a href="#has-entries-and-events-disabled" id="the-history-entry-list:has-entries-and-events-disabled-2">has entries and events disabled</a>, then return
   false.</p></li><li><p><a id="the-history-entry-list:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <a id="the-history-entry-list:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-current-entry-index" id="the-history-entry-list:navigation-current-entry-index">current entry index</a> is not −1.</p></li><li><p>If <a id="the-history-entry-list:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-current-entry-index" id="the-history-entry-list:navigation-current-entry-index-2">current entry
   index</a> is 0, then return false.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-cangoforward" data-dfn-type="attribute"><code>canGoForward</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-history-entry-list:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> <a href="#has-entries-and-events-disabled" id="the-history-entry-list:has-entries-and-events-disabled-3">has entries and events disabled</a>, then return
   false.</p></li><li><p><a id="the-history-entry-list:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <a id="the-history-entry-list:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-current-entry-index" id="the-history-entry-list:navigation-current-entry-index-3">current entry index</a> is not −1.</p></li><li><p>If <a id="the-history-entry-list:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-current-entry-index" id="the-history-entry-list:navigation-current-entry-index-4">current entry
   index</a> is equal to <a id="the-history-entry-list:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-entry-list" id="the-history-entry-list:navigation-entry-list-2">entry
   list</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="the-history-entry-list:list-size" data-x-internal="list-size">size</a> − 1, then return false.</p></li><li><p>Return true.</p></li></ol>
  </div>

  


  <h5 id="navigation-api-initiating-navigations"><span class="secno">7.2.6.7</span> Initiating navigations<a href="#navigation-api-initiating-navigations" class="self-link"></a></h5>

  <dl class="domintro"><dt><code>{ <a href="#dom-navigationresult-committed" id="navigation-api-initiating-navigations:dom-navigationresult-committed">committed</a>, <a href="#dom-navigationresult-finished" id="navigation-api-initiating-navigations:dom-navigationresult-finished">finished</a> } = <a href="#dom-navigation" id="navigation-api-initiating-navigations:dom-navigation">navigation</a>.<a href="#dom-navigation-navigate" id="dom-navigation-navigate-dev">navigate</a>(<var>url</var>)</code></dt><dt><code>{ <a href="#dom-navigationresult-committed" id="navigation-api-initiating-navigations:dom-navigationresult-committed-2">committed</a>, <a href="#dom-navigationresult-finished" id="navigation-api-initiating-navigations:dom-navigationresult-finished-2">finished</a> } = <a href="#dom-navigation" id="navigation-api-initiating-navigations:dom-navigation-2">navigation</a>.<a href="#dom-navigation-navigate" id="navigation-api-initiating-navigations:dom-navigation-navigate">navigate</a>(<var>url</var>, <var>options</var>)</code></dt><dd>
    <p><a href="#navigate" id="navigation-api-initiating-navigations:navigate">Navigates</a> the current page to the given <var>url</var>.
    <var>options</var> can contain the following values:</p>

    <ul><li><p><code id="dom-navigationnavigateoptions-history-dev"><a href="#dom-navigationnavigateoptions-history">history</a></code> can be set to
     "<code id="navigationhistorybehavior-replace-dev"><a href="#navigationhistorybehavior-replace">replace</a></code>" to replace the current
     session history entry, instead of pushing a new one.</p></li><li><p><code id="dom-navigationoptions-info-dev"><a href="#dom-navigationoptions-info">info</a></code> can be set to any value; it
     will populate the <code id="navigation-api-initiating-navigations:dom-navigateevent-info"><a href="#dom-navigateevent-info">info</a></code> property of the
     corresponding <code id="navigation-api-initiating-navigations:navigateevent"><a href="#navigateevent">NavigateEvent</a></code>.</p></li><li><p><code id="dom-navigationnavigateoptions-state-dev"><a href="#dom-navigationnavigateoptions-state">state</a></code> can be set to any
     <a href="#serializable-objects" id="navigation-api-initiating-navigations:serializable-objects">serializable</a> value; it will populate the state
     retrieved by <code id="navigation-api-initiating-navigations:dom-navigationhistoryentry-getstate"><a href="#dom-navigationhistoryentry-getstate">navigation.currentEntry.getState()</a></code> once the
     navigation completes, for same-document navigations. (It will be ignored for navigations that
     end up cross-document.)</p></li></ul>

    <p>By default this will perform a full navigation (i.e., a cross-document navigation, unless the
    given URL differs only in a <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="navigation-api-initiating-navigations:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> from the current
    one). The <code id="navigation-api-initiating-navigations:dom-navigateevent-intercept"><a href="#dom-navigateevent-intercept">navigateEvent.intercept()</a></code> method can
    be used to convert it into a same-document navigation.</p>

    <p>The returned promises will behave as follows:</p>

    <ul><li><p>For navigations that get aborted, both promises will reject with an
     <a id="navigation-api-initiating-navigations:aborterror" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a> <code id="navigation-api-initiating-navigations:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>For same-document navigations created by using the <code id="navigation-api-initiating-navigations:dom-navigateevent-intercept-2"><a href="#dom-navigateevent-intercept">navigateEvent.intercept()</a></code> method, <code id="navigation-api-initiating-navigations:dom-navigationresult-committed-3"><a href="#dom-navigationresult-committed">committed</a></code> will fulfill after the navigation
     commits, and <code id="navigation-api-initiating-navigations:dom-navigationresult-finished-3"><a href="#dom-navigationresult-finished">finished</a></code> will fulfill or
     reject according to any promsies returned by handlers passed to <code id="navigation-api-initiating-navigations:dom-navigateevent-intercept-3"><a href="#dom-navigateevent-intercept">intercept()</a></code>.</p></li><li><p>For other same-document navigations (e.g., non-intercepted <a href="#navigate-fragid" id="navigation-api-initiating-navigations:navigate-fragid">fragment navigations</a>), both promises will fulfill
     immediately.</p></li><li><p>For cross-document navigations, or navigations that result in 204 or 205 <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="navigation-api-initiating-navigations:concept-response-status" data-x-internal="concept-response-status">statuses</a> or `<code id="navigation-api-initiating-navigations:http-content-disposition"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition: attachment</a></code>` header fields from
     the server (and thus do not actually navigate), both promises will never settle.</p></li></ul>

    <p>In all cases, when the returned promises fulfill, it will be with the
    <code id="navigation-api-initiating-navigations:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> that was navigated to.</p>
   </dd><dt><code>{ <a href="#dom-navigationresult-committed" id="navigation-api-initiating-navigations:dom-navigationresult-committed-4">committed</a>, <a href="#dom-navigationresult-finished" id="navigation-api-initiating-navigations:dom-navigationresult-finished-4">finished</a> } = <a href="#dom-navigation" id="navigation-api-initiating-navigations:dom-navigation-3">navigation</a>.<a href="#dom-navigation-reload" id="dom-navigation-reload-dev">reload</a>(<var>options</var>)</code></dt><dd>
    <p><a href="#reload" id="navigation-api-initiating-navigations:reload">Reloads</a> the current page. <var>options</var> can contain <code id="navigation-api-initiating-navigations:dom-navigationoptions-info"><a href="#dom-navigationoptions-info">info</a></code> and <code id="dom-navigationreloadoptions-state-dev"><a href="#dom-navigationreloadoptions-state">state</a></code>, which behave as described above.</p>

    <p>The default behavior of performing a from-network-or-cache reload of the current page can be
    overriden by the using the <code id="navigation-api-initiating-navigations:dom-navigateevent-intercept-4"><a href="#dom-navigateevent-intercept">navigateEvent.intercept()</a></code> method. Doing so will mean
    this call only updates state or passes along the appropriate <code id="navigation-api-initiating-navigations:dom-navigationoptions-info-2"><a href="#dom-navigationoptions-info">info</a></code>, plus performing whater actions the <code id="navigation-api-initiating-navigations:event-navigate"><a href="#event-navigate">navigate</a></code> event handlers see fit to carry out.</p>

    <p>The returned promises will behave as follows:</p>

    <ul><li><p>If the reload is intercepted by using the <code id="navigation-api-initiating-navigations:dom-navigateevent-intercept-5"><a href="#dom-navigateevent-intercept">navigateEvent.intercept()</a></code> method, <code id="navigation-api-initiating-navigations:dom-navigationresult-committed-5"><a href="#dom-navigationresult-committed">committed</a></code> will fulfill after the navigation
     commits, and <code id="navigation-api-initiating-navigations:dom-navigationresult-finished-5"><a href="#dom-navigationresult-finished">finished</a></code> will fulfill or
     reject according to any promsies returned by handlers passed to <code id="navigation-api-initiating-navigations:dom-navigateevent-intercept-6"><a href="#dom-navigateevent-intercept">intercept()</a></code>.</p></li><li><p>Otherwise, both promises will never settle.</p></li></ul>
   </dd><dt><code>{ <a href="#dom-navigationresult-committed" id="navigation-api-initiating-navigations:dom-navigationresult-committed-6">committed</a>, <a href="#dom-navigationresult-finished" id="navigation-api-initiating-navigations:dom-navigationresult-finished-6">finished</a> } = <a href="#dom-navigation" id="navigation-api-initiating-navigations:dom-navigation-4">navigation</a>.<a href="#dom-navigation-traverseto" id="dom-navigation-traverseto-dev">traverseTo</a>(<var>key</var>)</code></dt><dt><code>{ <a href="#dom-navigationresult-committed" id="navigation-api-initiating-navigations:dom-navigationresult-committed-7">committed</a>, <a href="#dom-navigationresult-finished" id="navigation-api-initiating-navigations:dom-navigationresult-finished-7">finished</a> } = <a href="#dom-navigation" id="navigation-api-initiating-navigations:dom-navigation-5">navigation</a>.<a href="#dom-navigation-traverseto" id="navigation-api-initiating-navigations:dom-navigation-traverseto">traverseTo</a>(<var>key</var>, { <a href="#dom-navigationoptions-info" id="navigation-api-initiating-navigations:dom-navigationoptions-info-3">info</a> })</code></dt><dd>
    <p><a href="#apply-the-traverse-history-step" id="navigation-api-initiating-navigations:apply-the-traverse-history-step">Traverses</a> to the closest <a href="#session-history-entry" id="navigation-api-initiating-navigations:session-history-entry">session
    history entry</a> that matches the <code id="navigation-api-initiating-navigations:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> with the given
    <var>key</var>. <code id="navigation-api-initiating-navigations:dom-navigationoptions-info-4"><a href="#dom-navigationoptions-info">info</a></code> can be set to any value;
    it will populate the <code id="navigation-api-initiating-navigations:dom-navigateevent-info-2"><a href="#dom-navigateevent-info">info</a></code> property of the
    corresponding <code id="navigation-api-initiating-navigations:navigateevent-2"><a href="#navigateevent">NavigateEvent</a></code>.</p>

    <p>If a traversal to that <a href="#session-history-entry" id="navigation-api-initiating-navigations:session-history-entry-2">session history entry</a> is already in progress, then this
    will return the promises for that original traversal, and <code id="navigation-api-initiating-navigations:dom-navigateevent-info-3"><a href="#dom-navigateevent-info">info</a></code> will be ignored.</p>

    <p>The returned promises will behave as follows:</p>

    <ul><li><p>If there is no <code id="navigation-api-initiating-navigations:navigationhistoryentry-3"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> in <code id="navigation-api-initiating-navigations:dom-navigation-entries"><a href="#dom-navigation-entries">navigation.entries()</a></code> whose <code id="navigation-api-initiating-navigations:dom-navigationhistoryentry-key"><a href="#dom-navigationhistoryentry-key">key</a></code> matches <var>key</var>, both promises will
     reject with an <a id="navigation-api-initiating-navigations:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
     <code id="navigation-api-initiating-navigations:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>For same-document traversals intercepted by the <code id="navigation-api-initiating-navigations:dom-navigateevent-intercept-7"><a href="#dom-navigateevent-intercept">navigateEvent.intercept()</a></code> method, <code id="navigation-api-initiating-navigations:dom-navigationresult-committed-8"><a href="#dom-navigationresult-committed">committed</a></code> will fulfill as soon as the traversal
     is processed and <code id="navigation-api-initiating-navigations:dom-navigation-currententry"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> is
     updated, and <code id="navigation-api-initiating-navigations:dom-navigationresult-finished-8"><a href="#dom-navigationresult-finished">finished</a></code> will fulfill or
     reject according to any promsies returned by the handlers passed to <code id="navigation-api-initiating-navigations:dom-navigateevent-intercept-8"><a href="#dom-navigateevent-intercept">intercept()</a></code>.</p></li><li><p>For non-intercepted same-document travesals, both promises will fulfill as soon as the
     traversal is processed and <code id="navigation-api-initiating-navigations:dom-navigation-currententry-2"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> is updated.</p></li><li><p>For cross-document traversals, including attempted cross-document traversals that end up
     resulting in a 204 or 205 <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="navigation-api-initiating-navigations:concept-response-status-2" data-x-internal="concept-response-status">statuses</a> or `<code id="navigation-api-initiating-navigations:http-content-disposition-2"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition: attachment</a></code>` header fields from
     the server (and thus do not actually traverse), both promises will never settle.</p></li></ul>
   </dd><dt><code>{ <a href="#dom-navigationresult-committed" id="navigation-api-initiating-navigations:dom-navigationresult-committed-9">committed</a>, <a href="#dom-navigationresult-finished" id="navigation-api-initiating-navigations:dom-navigationresult-finished-9">finished</a> } = <a href="#dom-navigation" id="navigation-api-initiating-navigations:dom-navigation-6">navigation</a>.<a href="#dom-navigation-back" id="dom-navigation-back-dev">back</a>(<var>key</var>)</code></dt><dt><code>{ <a href="#dom-navigationresult-committed" id="navigation-api-initiating-navigations:dom-navigationresult-committed-10">committed</a>, <a href="#dom-navigationresult-finished" id="navigation-api-initiating-navigations:dom-navigationresult-finished-10">finished</a> } = <a href="#dom-navigation" id="navigation-api-initiating-navigations:dom-navigation-7">navigation</a>.<a href="#dom-navigation-back" id="navigation-api-initiating-navigations:dom-navigation-back">back</a>(<var>key</var>, { <a href="#dom-navigationoptions-info" id="navigation-api-initiating-navigations:dom-navigationoptions-info-5">info</a> })</code></dt><dd>
    <p>Traverses to the closest previous <a href="#session-history-entry" id="navigation-api-initiating-navigations:session-history-entry-3">session history entry</a> which results in this
    <a href="#navigable" id="navigation-api-initiating-navigations:navigable">navigable</a> traversing, i.e., which corresponds to a different
    <code id="navigation-api-initiating-navigations:navigationhistoryentry-4"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> and thus will cause <code id="navigation-api-initiating-navigations:dom-navigation-currententry-3"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> to change. <code id="navigation-api-initiating-navigations:dom-navigationoptions-info-6"><a href="#dom-navigationoptions-info">info</a></code> can be set to any value; it will populate the
    <code id="navigation-api-initiating-navigations:dom-navigateevent-info-4"><a href="#dom-navigateevent-info">info</a></code> property of the corresponding
    <code id="navigation-api-initiating-navigations:navigateevent-3"><a href="#navigateevent">NavigateEvent</a></code>.</p>

    <p>If a traversal to that <a href="#session-history-entry" id="navigation-api-initiating-navigations:session-history-entry-4">session history entry</a> is already in progress, then this
    will return the promises for that original traversal, and <code id="navigation-api-initiating-navigations:dom-navigateevent-info-5"><a href="#dom-navigateevent-info">info</a></code> will be ignored.</p>

    <p>The returned promises behave equivalently to those returned by <code id="navigation-api-initiating-navigations:dom-navigation-traverseto-2"><a href="#dom-navigation-traverseto">traverseTo()</a></code>.</p>
   </dd><dt><code>{ <a href="#dom-navigationresult-committed" id="navigation-api-initiating-navigations:dom-navigationresult-committed-11">committed</a>, <a href="#dom-navigationresult-finished" id="navigation-api-initiating-navigations:dom-navigationresult-finished-11">finished</a> } = <a href="#dom-navigation" id="navigation-api-initiating-navigations:dom-navigation-8">navigation</a>.<a href="#dom-navigation-forward" id="dom-navigation-forward-dev">forward</a>(<var>key</var>)</code></dt><dt><code>{ <a href="#dom-navigationresult-committed" id="navigation-api-initiating-navigations:dom-navigationresult-committed-12">committed</a>, <a href="#dom-navigationresult-finished" id="navigation-api-initiating-navigations:dom-navigationresult-finished-12">finished</a> } = <a href="#dom-navigation" id="navigation-api-initiating-navigations:dom-navigation-9">navigation</a>.<a href="#dom-navigation-forward" id="navigation-api-initiating-navigations:dom-navigation-forward">forward</a>(<var>key</var>, { <a href="#dom-navigationoptions-info" id="navigation-api-initiating-navigations:dom-navigationoptions-info-7">info</a> })</code></dt><dd>
    <p>Traverses to the closest forward <a href="#session-history-entry" id="navigation-api-initiating-navigations:session-history-entry-5">session history entry</a> which results in this
    <a href="#navigable" id="navigation-api-initiating-navigations:navigable-2">navigable</a> traversing, i.e., which corresponds to a different
    <code id="navigation-api-initiating-navigations:navigationhistoryentry-5"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> and thus will cause <code id="navigation-api-initiating-navigations:dom-navigation-currententry-4"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> to change. <code id="navigation-api-initiating-navigations:dom-navigationoptions-info-8"><a href="#dom-navigationoptions-info">info</a></code> can be set to any value; it will populate the
    <code id="navigation-api-initiating-navigations:dom-navigateevent-info-6"><a href="#dom-navigateevent-info">info</a></code> property of the corresponding
    <code id="navigation-api-initiating-navigations:navigateevent-4"><a href="#navigateevent">NavigateEvent</a></code>.</p>

    <p>If a traversal to that <a href="#session-history-entry" id="navigation-api-initiating-navigations:session-history-entry-6">session history entry</a> is already in progress, then this
    will return the promises for that original traversal, and <code id="navigation-api-initiating-navigations:dom-navigateevent-info-7"><a href="#dom-navigateevent-info">info</a></code> will be ignored.</p>

    <p>The returned promises behave equivalently to those returned by <code id="navigation-api-initiating-navigations:dom-navigation-traverseto-3"><a href="#dom-navigation-traverseto">traverseTo()</a></code>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-navigate" data-dfn-type="method"><code>navigate(<var>url</var>, <var>options</var>)</code></dfn> method
  steps are:</p>

  <ol><li><p>Let <var>urlRecord</var> be the result of <a href="#parse-a-url" id="navigation-api-initiating-navigations:parse-a-url">parsing a URL</a>
   given <var>url</var>, relative to <a id="navigation-api-initiating-navigations:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="navigation-api-initiating-navigations:relevant-settings-object">relevant settings
   object</a>.</p></li><li><p>If <var>urlRecord</var> is failure, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result">early error result</a> for a
   <a id="navigation-api-initiating-navigations:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>urlRecord</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="navigation-api-initiating-navigations:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is "<code id="navigation-api-initiating-navigations:the-javascript:-url-special-case"><a href="#the-javascript:-url-special-case">javascript</a></code>", then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-2">early error result</a> for a
   <a id="navigation-api-initiating-navigations:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

   </li><li><p>Let <var>document</var> be <a id="navigation-api-initiating-navigations:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="navigation-api-initiating-navigations:concept-relevant-global">relevant global object</a>'s <a href="#concept-document-window" id="navigation-api-initiating-navigations:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>If <var>options</var>["<code id="navigation-api-initiating-navigations:dom-navigationnavigateoptions-history"><a href="#dom-navigationnavigateoptions-history">history</a></code>"] is "<code id="navigation-api-initiating-navigations:navigationhistorybehavior-push"><a href="#navigationhistorybehavior-push">push</a></code>", and <a href="#the-navigation-must-be-a-replace" id="navigation-api-initiating-navigations:the-navigation-must-be-a-replace">the navigation must be a
   replace</a> given <var>urlRecord</var> and <var>document</var>, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-3">early error result</a> for a
   <a id="navigation-api-initiating-navigations:notsupportederror-2" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

   </li><li><p>Let <var>state</var> be <var>options</var>["<code id="navigation-api-initiating-navigations:dom-navigationnavigateoptions-state"><a href="#dom-navigationnavigateoptions-state">state</a></code>"], if it <a href="https://infra.spec.whatwg.org/#map-exists" id="navigation-api-initiating-navigations:map-exists" data-x-internal="map-exists">exists</a>; otherwise, undefined.</p></li><li>
    <p>Let <var>serializedState</var> be
    <a href="#structuredserializeforstorage" id="navigation-api-initiating-navigations:structuredserializeforstorage">StructuredSerializeForStorage</a>(<var>state</var>). If this throws an exception, then
    return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-4">early error result</a> for that
    exception.</p>

    <p class="note">It is important to perform this step early, since serialization can invoke web
    developer code, which in turn might change various things we check in later steps.</p>
   </li><li><p>If <var>document</var> is not <a href="#fully-active" id="navigation-api-initiating-navigations:fully-active">fully active</a>, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-5">early error result</a> for an
   <a id="navigation-api-initiating-navigations:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

   </li><li><p>If <var>document</var>'s <a href="#unload-counter" id="navigation-api-initiating-navigations:unload-counter">unload counter</a> is greater than 0, then return an
   <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-6">early error result</a> for an
   <a id="navigation-api-initiating-navigations:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>info</var> be <var>options</var>["<code id="navigation-api-initiating-navigations:dom-navigationoptions-info-9"><a href="#dom-navigationoptions-info">info</a></code>"], if it <a href="https://infra.spec.whatwg.org/#map-exists" id="navigation-api-initiating-navigations:map-exists-2" data-x-internal="map-exists">exists</a>;
   otherwise, undefined.</p></li><li><p>Let <var>apiMethodTracker</var> be the result of <a href="#set-up-a-navigate/reload-api-method-tracker" id="navigation-api-initiating-navigations:set-up-a-navigate/reload-api-method-tracker">setting up a navigate/reload API method tracker</a> for <a id="navigation-api-initiating-navigations:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>
   given <var>info</var> and <var>serializedState</var>.</p></li><li>
    <p><a href="#navigate" id="navigation-api-initiating-navigations:navigate-2">Navigate</a> <var>document</var>'s <a href="#node-navigable" id="navigation-api-initiating-navigations:node-navigable">node
    navigable</a> to <var>urlRecord</var> using <var>document</var>, with <i id="navigation-api-initiating-navigations:navigation-hh"><a href="#navigation-hh">historyHandling</a></i> set to <var>options</var>["<code id="navigation-api-initiating-navigations:dom-navigationnavigateoptions-history-2"><a href="#dom-navigationnavigateoptions-history">history</a></code>"], <i id="navigation-api-initiating-navigations:navigation-navigation-api-state"><a href="#navigation-navigation-api-state">navigationAPIState</a></i> set to
    <var>serializedState</var>, and <i id="navigation-api-initiating-navigations:navigation-api-method-tracker-2"><a href="#navigation-api-method-tracker-2">apiMethodTracker</a></i>
    set to <var>apiMethodTracker</var>.</p>

    <p class="note">Unlike <code id="navigation-api-initiating-navigations:dom-location-assign"><a href="#dom-location-assign">location.assign()</a></code> and friends,
    which are exposed across <a href="#same-origin-domain" id="navigation-api-initiating-navigations:same-origin-domain">origin-domain</a> boundaries,
    <code id="navigation-api-initiating-navigations:dom-navigation-navigate-2"><a href="#dom-navigation-navigate">navigation.navigate()</a></code> can only be accessed by code
    with direct synchronous access to the <code id="navigation-api-initiating-navigations:dom-navigation-10"><a href="#dom-navigation">window.navigation</a></code>
    property. Thus, we avoid the complications about attributing the source document of the
    navigation, and we don't need to deal with the <a href="#allowed-to-navigate" id="navigation-api-initiating-navigations:allowed-to-navigate">allowed by sandboxing to navigate</a>
    check and its acccompanying <i id="navigation-api-initiating-navigations:exceptions-enabled"><a href="#exceptions-enabled">exceptionsEnabled</a></i> flag. We just
    treat all navigations as if they come from the <code id="navigation-api-initiating-navigations:document"><a href="#document">Document</a></code> corresponding to this
    <code id="navigation-api-initiating-navigations:navigation"><a href="#navigation">Navigation</a></code> object itself (i.e., <var>document</var>).</p>
   </li><li><p>Return a <a href="#navigation-api-method-tracker-derived-result" id="navigation-api-initiating-navigations:navigation-api-method-tracker-derived-result">navigation API method tracker-derived result</a> for
   <var>apiMethodTracker</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-reload" data-dfn-type="method"><code>reload(<var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>document</var> be <a id="navigation-api-initiating-navigations:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="navigation-api-initiating-navigations:concept-relevant-global-2">relevant global object</a>'s <a href="#concept-document-window" id="navigation-api-initiating-navigations:concept-document-window-2">associated <code>Document</code></a>.</p></li><li><p>Let <var>serializedState</var> be
   <a href="#structuredserializeforstorage" id="navigation-api-initiating-navigations:structuredserializeforstorage-2">StructuredSerializeForStorage</a>(undefined).</p></li><li>
    <p>If <var>options</var>["<code id="navigation-api-initiating-navigations:dom-navigationreloadoptions-state"><a href="#dom-navigationreloadoptions-state">state</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="navigation-api-initiating-navigations:map-exists-3" data-x-internal="map-exists">exists</a>, then set <var>serializedState</var> to
    <a href="#structuredserializeforstorage" id="navigation-api-initiating-navigations:structuredserializeforstorage-3">StructuredSerializeForStorage</a>(<var>options</var>["<code id="navigation-api-initiating-navigations:dom-navigationreloadoptions-state-2"><a href="#dom-navigationreloadoptions-state">state</a></code>"]). If this throws an exception, then
    return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-7">early error result</a> for that
    exception.</p>

    <p class="note">It is important to perform this step early, since serialization can invoke web
    developer code, which in turn might change various things we check in later steps.</p>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>current</var> be the <a href="#navigation-current-entry" id="navigation-api-initiating-navigations:navigation-current-entry">current
     entry</a> of <a id="navigation-api-initiating-navigations:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>If <var>current</var> is not null, then set <var>serializedState</var> to
     <var>current</var>'s <a href="#nhe-she" id="navigation-api-initiating-navigations:nhe-she">session history entry</a>'s <a href="#she-navigation-api-state" id="navigation-api-initiating-navigations:she-navigation-api-state">navigation API state</a>.</p></li></ol>
   </li><li><p>If <var>document</var> is not <a href="#fully-active" id="navigation-api-initiating-navigations:fully-active-2">fully active</a>, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-8">early error result</a> for an
   <a id="navigation-api-initiating-navigations:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

   </li><li><p>If <var>document</var>'s <a href="#unload-counter" id="navigation-api-initiating-navigations:unload-counter-2">unload counter</a> is greater than 0, then return an
   <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-9">early error result</a> for an
   <a id="navigation-api-initiating-navigations:invalidstateerror-5" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>info</var> be <var>options</var>["<code id="navigation-api-initiating-navigations:dom-navigationoptions-info-10"><a href="#dom-navigationoptions-info">info</a></code>"], if it <a href="https://infra.spec.whatwg.org/#map-exists" id="navigation-api-initiating-navigations:map-exists-4" data-x-internal="map-exists">exists</a>;
   otherwise, undefined.</p></li><li><p>Let <var>apiMethodTracker</var> be the result of <a href="#set-up-a-navigate/reload-api-method-tracker" id="navigation-api-initiating-navigations:set-up-a-navigate/reload-api-method-tracker-2">setting up a navigate/reload API method tracker</a> for <a id="navigation-api-initiating-navigations:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>
   given <var>info</var> and <var>serializedState</var>.</p></li><li><p><a href="#reload" id="navigation-api-initiating-navigations:reload-2">Reload</a> <var>document</var>'s <a href="#node-navigable" id="navigation-api-initiating-navigations:node-navigable-2">node navigable</a> with <i id="navigation-api-initiating-navigations:reload-navigation-api-state"><a href="#reload-navigation-api-state">navigationAPIState</a></i> set to <var>serializedState</var> and
   <i id="navigation-api-initiating-navigations:reload-api-method-tracker"><a href="#reload-api-method-tracker">apiMethodTracker</a></i> set to
   <var>apiMethodTracker</var>.</p></li><li><p>Return a <a href="#navigation-api-method-tracker-derived-result" id="navigation-api-initiating-navigations:navigation-api-method-tracker-derived-result-2">navigation API method tracker-derived result</a> for
   <var>apiMethodTracker</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-traverseto" data-dfn-type="method"><code>traverseTo(<var>key</var>, <var>options</var>)</code></dfn>
  method steps are:</p>

  <ol><li><p>If <a id="navigation-api-initiating-navigations:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-current-entry-index" id="navigation-api-initiating-navigations:navigation-current-entry-index">current entry
   index</a> is −1, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-10">early
   error result</a> for an <a id="navigation-api-initiating-navigations:invalidstateerror-6" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="navigation-api-initiating-navigations:domexception-10"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="navigation-api-initiating-navigations:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-entry-list" id="navigation-api-initiating-navigations:navigation-entry-list">entry list</a> does not
   <a href="https://infra.spec.whatwg.org/#list-contain" id="navigation-api-initiating-navigations:list-contains" data-x-internal="list-contains">contain</a> a <code id="navigation-api-initiating-navigations:navigationhistoryentry-6"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> whose <a href="#nhe-she" id="navigation-api-initiating-navigations:nhe-she-2">session history entry</a>'s <a href="#she-navigation-api-key" id="navigation-api-initiating-navigations:she-navigation-api-key">navigation
   API key</a> equals <var>key</var>, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-11">early error result</a> for an
   <a id="navigation-api-initiating-navigations:invalidstateerror-7" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-11"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return the result of <a href="#performing-a-navigation-api-traversal" id="navigation-api-initiating-navigations:performing-a-navigation-api-traversal">performing a navigation API traversal</a> given
   <a id="navigation-api-initiating-navigations:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>key</var>, and <var>options</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-back" data-dfn-type="method"><code>back(<var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="navigation-api-initiating-navigations:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-current-entry-index" id="navigation-api-initiating-navigations:navigation-current-entry-index-2">current entry
   index</a> is −1 or 0, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-12">early error result</a> for an
   <a id="navigation-api-initiating-navigations:invalidstateerror-8" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-12"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>key</var> be <a id="navigation-api-initiating-navigations:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-entry-list" id="navigation-api-initiating-navigations:navigation-entry-list-2">entry
   list</a>[<a id="navigation-api-initiating-navigations:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-current-entry-index" id="navigation-api-initiating-navigations:navigation-current-entry-index-3">current entry
   index</a> − 1]'s <a href="#nhe-she" id="navigation-api-initiating-navigations:nhe-she-3">session history entry</a>'s <a href="#she-navigation-api-key" id="navigation-api-initiating-navigations:she-navigation-api-key-2">navigation API key</a>.</p></li><li><p>Return the result of <a href="#performing-a-navigation-api-traversal" id="navigation-api-initiating-navigations:performing-a-navigation-api-traversal-2">performing a navigation API traversal</a> given
   <a id="navigation-api-initiating-navigations:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>key</var>, and <var>options</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-forward" data-dfn-type="method"><code>forward(<var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="navigation-api-initiating-navigations:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-current-entry-index" id="navigation-api-initiating-navigations:navigation-current-entry-index-4">current entry
   index</a> is −1 or is equal to <a id="navigation-api-initiating-navigations:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-entry-list" id="navigation-api-initiating-navigations:navigation-entry-list-3">entry list</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="navigation-api-initiating-navigations:list-size" data-x-internal="list-size">size</a> −
   1, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-13">early error result</a> for
   an <a id="navigation-api-initiating-navigations:invalidstateerror-9" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-13"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>key</var> be <a id="navigation-api-initiating-navigations:this-16" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-entry-list" id="navigation-api-initiating-navigations:navigation-entry-list-4">entry
   list</a>[<a id="navigation-api-initiating-navigations:this-17" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-current-entry-index" id="navigation-api-initiating-navigations:navigation-current-entry-index-5">current entry
   index</a> + 1]'s <a href="#nhe-she" id="navigation-api-initiating-navigations:nhe-she-4">session history entry</a>'s <a href="#she-navigation-api-key" id="navigation-api-initiating-navigations:she-navigation-api-key-3">navigation API key</a>.</p></li><li><p>Return the result of <a href="#performing-a-navigation-api-traversal" id="navigation-api-initiating-navigations:performing-a-navigation-api-traversal-3">performing a navigation API traversal</a> given
   <a id="navigation-api-initiating-navigations:this-18" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>key</var>, and <var>options</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="performing-a-navigation-api-traversal">perform a navigation API traversal</dfn>
  given a <code id="navigation-api-initiating-navigations:navigation-2"><a href="#navigation">Navigation</a></code> <var>navigation</var>, a string <var>key</var>, and a
  <code id="navigation-api-initiating-navigations:navigationoptions"><a href="#navigationoptions">NavigationOptions</a></code> <var>options</var>:</p>

  <ol><li><p>Let <var>document</var> be <var>navigation</var>'s <a href="#concept-relevant-global" id="navigation-api-initiating-navigations:concept-relevant-global-3">relevant global object</a>'s
   <a href="#concept-document-window" id="navigation-api-initiating-navigations:concept-document-window-3">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var> is not <a href="#fully-active" id="navigation-api-initiating-navigations:fully-active-3">fully active</a>, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-14">early error result</a> for an
   <a id="navigation-api-initiating-navigations:invalidstateerror-10" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-14"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

   </li><li><p>If <var>document</var>'s <a href="#unload-counter" id="navigation-api-initiating-navigations:unload-counter-3">unload counter</a> is greater than 0, then return an
   <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-15">early error result</a> for an
   <a id="navigation-api-initiating-navigations:invalidstateerror-11" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-15"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>current</var> be the <a href="#navigation-current-entry" id="navigation-api-initiating-navigations:navigation-current-entry-2">current entry</a>
   of <var>navigation</var>.</p></li><li><p>If <var>key</var> equals <var>current</var>'s <a href="#nhe-she" id="navigation-api-initiating-navigations:nhe-she-5">session history
   entry</a>'s <a href="#she-navigation-api-key" id="navigation-api-initiating-navigations:she-navigation-api-key-4">navigation API key</a>, then return «[
   "<code id="navigation-api-initiating-navigations:dom-navigationresult-committed-13"><a href="#dom-navigationresult-committed">committed</a></code>" → <a id="navigation-api-initiating-navigations:a-promise-resolved-with" href="https://webidl.spec.whatwg.org/#a-promise-resolved-with" data-x-internal="a-promise-resolved-with">a promise resolved
   with</a> <var>current</var>, "<code id="navigation-api-initiating-navigations:dom-navigationresult-finished-13"><a href="#dom-navigationresult-finished">finished</a></code>"
   → <a id="navigation-api-initiating-navigations:a-promise-resolved-with-2" href="https://webidl.spec.whatwg.org/#a-promise-resolved-with" data-x-internal="a-promise-resolved-with">a promise resolved with</a> <var>current</var> ]».</p></li><li><p>If <var>navigation</var>'s <a href="#upcoming-traverse-api-method-trackers" id="navigation-api-initiating-navigations:upcoming-traverse-api-method-trackers">upcoming traverse API method
   trackers</a>[<var>key</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="navigation-api-initiating-navigations:map-exists-5" data-x-internal="map-exists">exists</a>, then return a
   <a href="#navigation-api-method-tracker-derived-result" id="navigation-api-initiating-navigations:navigation-api-method-tracker-derived-result-3">navigation API method tracker-derived result</a> for <var>navigation</var>'s
   <a href="#upcoming-traverse-api-method-trackers" id="navigation-api-initiating-navigations:upcoming-traverse-api-method-trackers-2">upcoming traverse API method trackers</a>[<var>key</var>].</p></li><li><p>Let <var>info</var> be <var>options</var>["<code id="navigation-api-initiating-navigations:dom-navigationoptions-info-11"><a href="#dom-navigationoptions-info">info</a></code>"], if it <a href="https://infra.spec.whatwg.org/#map-exists" id="navigation-api-initiating-navigations:map-exists-6" data-x-internal="map-exists">exists</a>;
   otherwise, undefined.</p></li><li><p>Let <var>apiMethodTracker</var> be the result of <a href="#add-an-upcoming-traverse-api-method-tracker" id="navigation-api-initiating-navigations:add-an-upcoming-traverse-api-method-tracker">adding an upcoming traverse API method tracker</a> for
   <var>navigation</var> given <var>key</var> and <var>info</var>.</p></li><li><p>Let <var>navigable</var> be <var>document</var>'s <a href="#node-navigable" id="navigation-api-initiating-navigations:node-navigable-3">node navigable</a>.</p></li><li><p>Let <var>traversable</var> be <var>navigable</var>'s <a href="#nav-traversable" id="navigation-api-initiating-navigations:nav-traversable">traversable navigable</a>.</p></li><li><p>Let <var>sourceSnapshotParams</var> be the result of <a href="#snapshotting-source-snapshot-params" id="navigation-api-initiating-navigations:snapshotting-source-snapshot-params">snapshotting source snapshot
   params</a> given <var>document</var>.</p></li><li>
    <p><a href="#tn-append-session-history-traversal-steps" id="navigation-api-initiating-navigations:tn-append-session-history-traversal-steps">Append the following session history
    traversal steps</a> to <var>traversable</var>:</p>

    <ol><li><p>Let <var>navigableSHEs</var> be the result of <a href="#getting-session-history-entries" id="navigation-api-initiating-navigations:getting-session-history-entries">getting session history
     entries</a> given <var>navigable</var>.</p></li><li>
      <p>Let <var>targetSHE</var> be the <a href="#session-history-entry" id="navigation-api-initiating-navigations:session-history-entry-7">session history entry</a> in
      <var>navigableSHEs</var> whose <a href="#she-navigation-api-key" id="navigation-api-initiating-navigations:she-navigation-api-key-5">navigation API key</a>
      is <var>key</var>. If no such entry exists, then:</p>

      <ol><li><p><a href="#queue-a-global-task" id="navigation-api-initiating-navigations:queue-a-global-task">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="navigation-api-initiating-navigations:navigation-and-traversal-task-source">navigation and traversal task
       source</a> given <var>navigation</var>'s <a href="#concept-relevant-global" id="navigation-api-initiating-navigations:concept-relevant-global-4">relevant global object</a> to
       <a href="#reject-the-finished-promise" id="navigation-api-initiating-navigations:reject-the-finished-promise">reject the finished promise</a> for <var>apiMethodTracker</var> with an
       <a id="navigation-api-initiating-navigations:invalidstateerror-12" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-16"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Abort these steps.</p></li></ol>

      <p class="note">This path is taken if <var>navigation</var>'s <a href="#navigation-entry-list" id="navigation-api-initiating-navigations:navigation-entry-list-5">entry list</a> was outdated compared to
      <var>navigableSHEs</var>, which can occur for brief periods while all the relevant threads and
      processes are being synchronized in reaction to a history change.</p>
     </li><li>
      <p>If <var>targetSHE</var> is <var>navigable</var>'s <a href="#nav-active-history-entry" id="navigation-api-initiating-navigations:nav-active-history-entry">active session history entry</a>, then abort these
      steps.</p>

      <p class="note">This can occur if a previously <a href="#tn-append-session-history-traversal-steps" id="navigation-api-initiating-navigations:tn-append-session-history-traversal-steps-2">queued</a> traversal already took us to
      this <a href="#session-history-entry" id="navigation-api-initiating-navigations:session-history-entry-8">session history entry</a>. In that case the previous traversal will have dealt
      with <var>apiMethodTracker</var> already.</p>
     </li><li><p>Let <var>result</var> be the result of <a href="#apply-the-traverse-history-step" id="navigation-api-initiating-navigations:apply-the-traverse-history-step-2">applying the traverse history step</a> given by <var>targetSHE</var>'s <a href="#she-step" id="navigation-api-initiating-navigations:she-step">step</a> to <var>traversable</var>, given <var>sourceSnapshotParams</var>,
     <var>navigable</var>, and "<code id="navigation-api-initiating-navigations:uni-none"><a href="#uni-none">none</a></code>".</p></li><li><p>If <var>result</var> is "<code>canceled-by-beforeunload</code>", then
     <a href="#queue-a-global-task" id="navigation-api-initiating-navigations:queue-a-global-task-2">queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="navigation-api-initiating-navigations:navigation-and-traversal-task-source-2">navigation and traversal task source</a> given
     <var>navigation</var>'s <a href="#concept-relevant-global" id="navigation-api-initiating-navigations:concept-relevant-global-5">relevant global object</a> to <a href="#reject-the-finished-promise" id="navigation-api-initiating-navigations:reject-the-finished-promise-2">reject the finished
     promise</a> for <var>apiMethodTracker</var> with a new
     <a id="navigation-api-initiating-navigations:aborterror-2" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-17"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> created in
     <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigation-api-initiating-navigations:concept-relevant-realm">relevant realm</a>.</p></li><li>
      <p>If <var>result</var> is "<code>initiator-disallowed</code>", then <a href="#queue-a-global-task" id="navigation-api-initiating-navigations:queue-a-global-task-3">queue a
      global task</a> on the <a href="#navigation-and-traversal-task-source" id="navigation-api-initiating-navigations:navigation-and-traversal-task-source-3">navigation and traversal task source</a> given
      <var>navigation</var>'s <a href="#concept-relevant-global" id="navigation-api-initiating-navigations:concept-relevant-global-6">relevant global object</a> to <a href="#reject-the-finished-promise" id="navigation-api-initiating-navigations:reject-the-finished-promise-3">reject the finished
      promise</a> for <var>apiMethodTracker</var> with a new
      <a id="navigation-api-initiating-navigations:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-18"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> created in
      <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigation-api-initiating-navigations:concept-relevant-realm-2">relevant realm</a>.</p>

      <div class="note">
       <p>When <var>result</var> is "<code>canceled-by-beforeunload</code>" or "<code>initiator-disallowed</code>", the <code id="navigation-api-initiating-navigations:event-navigate-2"><a href="#event-navigate">navigate</a></code>
       event was never fired, <a href="#abort-the-ongoing-navigation" id="navigation-api-initiating-navigations:abort-the-ongoing-navigation">aborting the ongoing
       navigation</a> would not be correct; it would result in a <code id="navigation-api-initiating-navigations:event-navigateerror"><a href="#event-navigateerror">navigateerror</a></code> event without a preceding <code id="navigation-api-initiating-navigations:event-navigate-3"><a href="#event-navigate">navigate</a></code> event.</p>

       <p>In the "<code>canceled-by-navigate</code>" case, <code id="navigation-api-initiating-navigations:event-navigate-4"><a href="#event-navigate">navigate</a></code> <em>is</em> fired, but the <a href="#inner-navigate-event-firing-algorithm" id="navigation-api-initiating-navigations:inner-navigate-event-firing-algorithm">inner <code>navigate</code> event firing algorithm</a> will take care of
       <a href="#abort-the-ongoing-navigation" id="navigation-api-initiating-navigations:abort-the-ongoing-navigation-2">aborting the ongoing navigation</a>.</p>
      </div>
     </li></ol>
   </li><li><p>Return a <a href="#navigation-api-method-tracker-derived-result" id="navigation-api-initiating-navigations:navigation-api-method-tracker-derived-result-4">navigation API method tracker-derived result</a> for
   <var>apiMethodTracker</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>An <dfn id="navigation-api-early-error-result">early error result</dfn> for an exception
  <var>e</var> is a <code id="navigation-api-initiating-navigations:navigationresult"><a href="#navigationresult">NavigationResult</a></code> dictionary instance given by «[ "<code id="navigation-api-initiating-navigations:dom-navigationresult-committed-14"><a href="#dom-navigationresult-committed">committed</a></code>" → <a id="navigation-api-initiating-navigations:a-promise-rejected-with" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a>
  <var>e</var>, "<code id="navigation-api-initiating-navigations:dom-navigationresult-finished-14"><a href="#dom-navigationresult-finished">finished</a></code>" → <a id="navigation-api-initiating-navigations:a-promise-rejected-with-2" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise
  rejected with</a> <var>e</var> ]».</p>
  </div>

  <div data-algorithm="">
  <p>To compute the <dfn id="navigation-api-method-tracker-derived-result">navigation API method tracker-derived result</dfn> for a <a href="#navigation-api-method-tracker" id="navigation-api-initiating-navigations:navigation-api-method-tracker">navigation
  API method tracker</a>-or-null <var>apiMethodTracker</var>:</p>

  <ol><li><p>If <var>apiMethodTracker</var> is <a href="#navigation-api-method-tracker-pending" id="navigation-api-initiating-navigations:navigation-api-method-tracker-pending">pending</a>, then return an <a href="#navigation-api-early-error-result" id="navigation-api-initiating-navigations:navigation-api-early-error-result-16">early error result</a> for an
   <a id="navigation-api-initiating-navigations:aborterror-3" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a> <code id="navigation-api-initiating-navigations:domexception-19"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return a <code id="navigation-api-initiating-navigations:navigationresult-2"><a href="#navigationresult">NavigationResult</a></code> dictionary instance given by «[ "<code id="navigation-api-initiating-navigations:dom-navigationresult-committed-15"><a href="#dom-navigationresult-committed">committed</a></code>" → <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-committed" id="navigation-api-initiating-navigations:navigation-api-method-tracker-committed">committed promise</a>, "<code id="navigation-api-initiating-navigations:dom-navigationresult-finished-15"><a href="#dom-navigationresult-finished">finished</a></code>" → <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-finished" id="navigation-api-initiating-navigations:navigation-api-method-tracker-finished">finished promise</a> ]».</p></li></ol>
  </div>

  


  <h5 id="ongoing-navigation-tracking"><span class="secno">7.2.6.8</span> Ongoing navigation tracking<a href="#ongoing-navigation-tracking" class="self-link"></a></h5>

  

  <p>During any given navigation (in the <a href="#navigationtype" id="ongoing-navigation-tracking:navigationtype">broad sense of the
  word</a>), the <code id="ongoing-navigation-tracking:navigation"><a href="#navigation">Navigation</a></code> object needs to keep track of the following:</p>

  <table><caption>For all navigations</caption><thead><tr><th>State
     </th><th>Duration
     </th><th>Explanation
   </th></tr></thead><tbody><tr><td>The <code id="ongoing-navigation-tracking:navigateevent"><a href="#navigateevent">NavigateEvent</a></code>
     </td><td>For the duration of event firing
     </td><td>So that if the navigation is canceled while the event is firing, we can <a href="https://dom.spec.whatwg.org/#canceled-flag" id="ongoing-navigation-tracking:canceled-flag" data-x-internal="canceled-flag">cancel</a> the event
    </td></tr><tr><td>The event's <a href="#concept-navigateevent-abort-controller" id="ongoing-navigation-tracking:concept-navigateevent-abort-controller">abort controller</a>
     </td><td>Until all promises returned from handlers passed to <code id="ongoing-navigation-tracking:dom-navigateevent-intercept"><a href="#dom-navigateevent-intercept">intercept()</a></code> have settled
     </td><td>So that if the navigation is canceled, we can <a id="ongoing-navigation-tracking:signal-abort" href="https://dom.spec.whatwg.org/#abortcontroller-signal-abort" data-x-internal="signal-abort">signal abort</a>
    </td></tr><tr><td>Whether a new element was <a href="#focusing-steps" id="ongoing-navigation-tracking:focusing-steps">focused</a>
     </td><td>Until all promises returned from handlers passed to <code id="ongoing-navigation-tracking:dom-navigateevent-intercept-2"><a href="#dom-navigateevent-intercept">intercept()</a></code> have settled
     </td><td>So that if one was, focus is not <a href="#potentially-reset-the-focus" id="ongoing-navigation-tracking:potentially-reset-the-focus">reset</a>
    </td></tr><tr><td>The <code id="ongoing-navigation-tracking:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> being navigated to
     </td><td>From when it is determined, until all promises returned from handlers passed to <code id="ongoing-navigation-tracking:dom-navigateevent-intercept-3"><a href="#dom-navigateevent-intercept">intercept()</a></code> have settled
     </td><td>So that we know what to resolve any <code id="ongoing-navigation-tracking:dom-navigationresult-committed"><a href="#dom-navigationresult-committed">committed</a></code> and <code id="ongoing-navigation-tracking:dom-navigationresult-finished"><a href="#dom-navigationresult-finished">finished</a></code> promises with
    </td></tr><tr><td>Any <code id="ongoing-navigation-tracking:dom-navigationresult-finished-2"><a href="#dom-navigationresult-finished">finished</a></code> promise that was returned
     </td><td>Until all promises returned from handlers passed to <code id="ongoing-navigation-tracking:dom-navigateevent-intercept-4"><a href="#dom-navigateevent-intercept">intercept()</a></code> have settled
     </td><td>So that we can resolve or reject it appropriately
  </td></tr></tbody></table>

  <table><caption>For non-"<code id="ongoing-navigation-tracking:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigations</caption><thead><tr><th>State
     </th><th>Duration
     </th><th>Explanation
   </th></tr></thead><tbody><tr><td>Any <code id="ongoing-navigation-tracking:dom-navigationnavigateoptions-state"><a href="#dom-navigationnavigateoptions-state">state</a></code>
     </td><td>For the duration of event firing
     </td><td>So that we can update the current entry's <a href="#she-navigation-api-state" id="ongoing-navigation-tracking:she-navigation-api-state">navigation API state</a> if the event finishes firing without being <a href="https://dom.spec.whatwg.org/#canceled-flag" id="ongoing-navigation-tracking:canceled-flag-2" data-x-internal="canceled-flag">canceled</a>
  </td></tr></tbody></table>

  <table><caption>For "<code id="ongoing-navigation-tracking:dom-navigationtype-traverse-2"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigations</caption><thead><tr><th>State
     </th><th>Duration
     </th><th>Explanation
   </th></tr></thead><tbody><tr><td>Any <code id="ongoing-navigation-tracking:dom-navigationoptions-info"><a href="#dom-navigationoptions-info">info</a></code>
     </td><td>Until the task is queued to fire the <code id="ongoing-navigation-tracking:event-navigate"><a href="#event-navigate">navigate</a></code> event
     </td><td>So that we can use it to fire the <code id="ongoing-navigation-tracking:event-navigate-2"><a href="#event-navigate">navigate</a></code> after the trip through the <a href="#tn-session-history-traversal-queue" id="ongoing-navigation-tracking:tn-session-history-traversal-queue">session history traversal queue</a>.
    </td></tr><tr><td>Any <code id="ongoing-navigation-tracking:dom-navigationresult-committed-2"><a href="#dom-navigationresult-committed">committed</a></code> promise that was returned
     </td><td>Until the session history is updated (inside that same task)
     </td><td>So that we can resolve or reject it appropriately
    </td></tr><tr><td>Whether <code id="ongoing-navigation-tracking:dom-navigateevent-intercept-5"><a href="#dom-navigateevent-intercept">intercept()</a></code> was called
     </td><td>Until the session history is updated (inside that same task)
     </td><td>So that we can suppress the normal scroll restoration logic in favor of the behavior given by the <code id="ongoing-navigation-tracking:dom-navigationinterceptoptions-scroll"><a href="#dom-navigationinterceptoptions-scroll">scroll</a></code> option
  </td></tr></tbody></table>

  <p>We also cannot assume there is only a single navigation requested at any given time, due to web
  developer code such as:</p>

  <pre><code class="js"><c- a="">const</c-> p1 <c- o="">=</c-> navigation<c- p="">.</c->navigate<c- p="">(</c->url1<c- p="">).</c->finished<c- p="">;</c->
<c- a="">const</c-> p2 <c- o="">=</c-> navigation<c- p="">.</c->navigate<c- p="">(</c->url2<c- p="">).</c->finished<c- p="">;</c-></code></pre>

  <p>That is, in this scenario, we need to ensure that while navigating to <code>url2</code>, we still have the promise <code>p1</code> around so that we can
  reject it. We can't just get rid of any ongoing navigation promises the moment the second call to
  <code id="ongoing-navigation-tracking:dom-navigation-navigate"><a href="#dom-navigation-navigate">navigate()</a></code> happens.</p>

  <p>We end up accomplishing all this by associating the following with each
  <code id="ongoing-navigation-tracking:navigation-2"><a href="#navigation">Navigation</a></code>:</p>

  <ul><li><p><dfn id="ongoing-navigate-event">Ongoing <code>navigate</code> event</dfn>, a
   <code id="ongoing-navigation-tracking:navigateevent-2"><a href="#navigateevent">NavigateEvent</a></code> or null, initially null.</p></li><li><p><dfn id="focus-changed-during-ongoing-navigation">Focus changed during ongoing navigation</dfn>, a boolean, initially false.</p></li><li><p><dfn id="suppress-normal-scroll-restoration-during-ongoing-navigation">Suppress normal scroll restoration during ongoing navigation</dfn>, a boolean,
   initially false.</p></li><li><p><dfn id="ongoing-api-method-tracker">Ongoing API method tracker</dfn>, a <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker">navigation API method tracker</a> or
   null, initially null.</p></li><li><p><dfn id="upcoming-traverse-api-method-trackers">Upcoming traverse API method trackers</dfn>, an <a id="ongoing-navigation-tracking:ordered-map" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> from strings
   to <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-2">navigation API method trackers</a>, initially
   empty.</p></li></ul>

  <p class="note">The state here that is not stored in <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-3">navigation API method trackers</a> is state which needs to be tracked even for
  navigations that are not initiated via navigation API methods.</p>

  <p>A <dfn id="navigation-api-method-tracker">navigation API method tracker</dfn> is a <a id="ongoing-navigation-tracking:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="ongoing-navigation-tracking:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p>A <dfn id="navigation-api-method-tracker-navigation">navigation object</dfn>, a
   <code id="ongoing-navigation-tracking:navigation-3"><a href="#navigation">Navigation</a></code></p></li><li><p>A <dfn id="navigation-api-method-tracker-key">key</dfn>, a string or null</p></li><li><p>An <dfn id="navigation-api-method-tracker-info">info</dfn>, a JavaScript
   value</p></li><li><p>A <dfn id="navigation-api-method-tracker-state">serialized state</dfn>, a
   <a href="#serialized-state" id="ongoing-navigation-tracking:serialized-state">serialized state</a> or null</p></li><li><p>A <dfn id="navigation-api-method-tracker-committed-to-entry">committed-to entry</dfn>,
   a <code id="ongoing-navigation-tracking:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> or null</p></li><li><p>A <dfn id="navigation-api-method-tracker-committed">committed promise</dfn>, a
   promise</p></li><li><p>A <dfn id="navigation-api-method-tracker-finished">finished promise</dfn>, a
   promise</p></li><li><p>A <dfn id="navigation-api-method-tracker-pending">pending</dfn>, a boolean.</p></li></ul>

  <p>All this state is then managed via the following algorithms.</p>

  <div data-algorithm="">
  <p>To <dfn id="set-up-a-navigate/reload-api-method-tracker">set up a navigate/reload API method tracker</dfn> given a <code id="ongoing-navigation-tracking:navigation-4"><a href="#navigation">Navigation</a></code>
  <var>navigation</var>, a JavaScript value <var>info</var>, and a <a href="#serialized-state" id="ongoing-navigation-tracking:serialized-state-2">serialized
  state</a>-or-null <var>serializedState</var>:</p>

  <ol><li><p>Let <var>committedPromise</var> and <var>finishedPromise</var> be new promises created in
   <var>navigation</var>'s <a href="#concept-relevant-realm" id="ongoing-navigation-tracking:concept-relevant-realm">relevant realm</a>.</p></li><li>
    <p><a id="ongoing-navigation-tracking:mark-as-handled" href="https://webidl.spec.whatwg.org/#mark-a-promise-as-handled" data-x-internal="mark-as-handled">Mark as handled</a> <var>finishedPromise</var>.</p>

    <div id="note-mark-as-handled-navigation-api-finished" class="note"><a href="#note-mark-as-handled-navigation-api-finished" class="self-link"></a>
     <p>The web developer doesn’t necessarily care about <var>finishedPromise</var> being
     rejected:</p>

     <ul><li><p>They might only care about <var>committedPromise</var>.</p></li><li><p>They could be doing multiple synchronous navigations within the same task, in which
      case all but the last will be aborted (causing their <var>finishedPromise</var> to reject).
      This could be an application bug, but also could just be an emergent feature of disparate
      parts of the application overriding each others' actions.</p></li><li><p>They might prefer to listen to other transition-failure signals instead of
      <var>finishedPromise</var>, e.g., the <code id="ongoing-navigation-tracking:event-navigateerror"><a href="#event-navigateerror">navigateerror</a></code>
      event, or the <code id="ongoing-navigation-tracking:dom-navigationtransition-finished"><a href="#dom-navigationtransition-finished">navigation.transition.finished</a></code>
      promise.</p></li></ul>

     <p>As such, we mark it as handled to ensure that it never triggers <code id="ongoing-navigation-tracking:event-unhandledrejection"><a href="#event-unhandledrejection">unhandledrejection</a></code> events.</p>
    </div>
   </li><li>
    <p>Return a new <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-4">navigation API method tracker</a> with:</p>

    <dl class="props"><dt><a href="#navigation-api-method-tracker-navigation" id="ongoing-navigation-tracking:navigation-api-method-tracker-navigation">navigation object</a></dt><dd><var>navigation</var></dd><dt><a href="#navigation-api-method-tracker-key" id="ongoing-navigation-tracking:navigation-api-method-tracker-key">key</a></dt><dd>null</dd><dt><a href="#navigation-api-method-tracker-info" id="ongoing-navigation-tracking:navigation-api-method-tracker-info">info</a></dt><dd><var>info</var></dd><dt><a href="#navigation-api-method-tracker-state" id="ongoing-navigation-tracking:navigation-api-method-tracker-state">serialized state</a></dt><dd><var>serializedState</var></dd><dt><a href="#navigation-api-method-tracker-committed-to-entry" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-to-entry">committed-to entry</a></dt><dd>null</dd><dt><a href="#navigation-api-method-tracker-committed" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed">committed promise</a></dt><dd><var>committedPromise</var></dd><dt><a href="#navigation-api-method-tracker-finished" id="ongoing-navigation-tracking:navigation-api-method-tracker-finished">finished promise</a></dt><dd><var>finishedPromise</var></dd><dt><a href="#navigation-api-method-tracker-pending" id="ongoing-navigation-tracking:navigation-api-method-tracker-pending">pending</a></dt><dd>false if <var>navigation</var> <a href="#has-entries-and-events-disabled" id="ongoing-navigation-tracking:has-entries-and-events-disabled">has entries and events disabled</a>; otherwise
     true</dd></dl>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="add-an-upcoming-traverse-api-method-tracker">add an upcoming traverse API method tracker</dfn> given a <code id="ongoing-navigation-tracking:navigation-5"><a href="#navigation">Navigation</a></code>
  <var>navigation</var>, a string <var>destinationKey</var>, and a JavaScript value
  <var>info</var>:</p>

  <ol><li><p>Let <var>committedPromise</var> and <var>finishedPromise</var> be new promises created in
   <var>navigation</var>'s <a href="#concept-relevant-realm" id="ongoing-navigation-tracking:concept-relevant-realm-2">relevant realm</a>.</p></li><li>
    <p><a id="ongoing-navigation-tracking:mark-as-handled-2" href="https://webidl.spec.whatwg.org/#mark-a-promise-as-handled" data-x-internal="mark-as-handled">Mark as handled</a> <var>finishedPromise</var>.</p>

    <p class="note">See the <a href="#note-mark-as-handled-navigation-api-finished">previous
    discussion</a> about why this is done.</p>
   </li><li>
    <p>Let <var>apiMethodTracker</var> be a new <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-5">navigation API method tracker</a> with:</p>

    <dl class="props"><dt><a href="#navigation-api-method-tracker-navigation" id="ongoing-navigation-tracking:navigation-api-method-tracker-navigation-2">navigation object</a></dt><dd><var>navigation</var></dd><dt><a href="#navigation-api-method-tracker-key" id="ongoing-navigation-tracking:navigation-api-method-tracker-key-2">key</a></dt><dd><var>destinationKey</var></dd><dt><a href="#navigation-api-method-tracker-info" id="ongoing-navigation-tracking:navigation-api-method-tracker-info-2">info</a></dt><dd><var>info</var></dd><dt><a href="#navigation-api-method-tracker-state" id="ongoing-navigation-tracking:navigation-api-method-tracker-state-2">serialized state</a></dt><dd>null</dd><dt><a href="#navigation-api-method-tracker-committed-to-entry" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-to-entry-2">committed-to entry</a></dt><dd>null</dd><dt><a href="#navigation-api-method-tracker-committed" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-2">committed promise</a></dt><dd><var>committedPromise</var></dd><dt><a href="#navigation-api-method-tracker-finished" id="ongoing-navigation-tracking:navigation-api-method-tracker-finished-2">finished promise</a></dt><dd><var>finishedPromise</var></dd><dt><a href="#navigation-api-method-tracker-pending" id="ongoing-navigation-tracking:navigation-api-method-tracker-pending-2">pending</a></dt><dd>false</dd></dl>
   </li><li><p>Set <var>navigation</var>'s <a href="#upcoming-traverse-api-method-trackers" id="ongoing-navigation-tracking:upcoming-traverse-api-method-trackers">upcoming traverse API method
   trackers</a>[<var>destinationKey</var>] to <var>apiMethodTracker</var>.</p></li><li><p>Return <var>apiMethodTracker</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="navigation-api-method-tracker-clean-up">clean up</dfn> a <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-6">navigation API
  method tracker</a> <var>apiMethodTracker</var>:</p>

  <ol><li><p>Let <var>navigation</var> be <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-navigation" id="ongoing-navigation-tracking:navigation-api-method-tracker-navigation-3">navigation object</a>.</p></li><li><p>If <var>navigation</var>'s <a href="#ongoing-api-method-tracker" id="ongoing-navigation-tracking:ongoing-api-method-tracker">ongoing API method tracker</a> is
   <var>apiMethodTracker</var>, then set <var>navigation</var>'s <a href="#ongoing-api-method-tracker" id="ongoing-navigation-tracking:ongoing-api-method-tracker-2">ongoing API method
   tracker</a> to null.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>key</var> be <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-key" id="ongoing-navigation-tracking:navigation-api-method-tracker-key-3">key</a>.</p></li><li><p><a id="ongoing-navigation-tracking:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>key</var> is not null.</p></li><li><p><a id="ongoing-navigation-tracking:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigation</var>'s <a href="#upcoming-traverse-api-method-trackers" id="ongoing-navigation-tracking:upcoming-traverse-api-method-trackers-2">upcoming traverse API method
     trackers</a>[<var>key</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="ongoing-navigation-tracking:map-exists" data-x-internal="map-exists">exists</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="ongoing-navigation-tracking:map-remove" data-x-internal="map-remove">Remove</a> <var>navigation</var>'s <a href="#upcoming-traverse-api-method-trackers" id="ongoing-navigation-tracking:upcoming-traverse-api-method-trackers-3">upcoming traverse
     API method trackers</a>[<var>key</var>].</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="notify-about-the-committed-to-entry">notify about the committed-to entry</dfn> given a <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-7">navigation API method
  tracker</a> <var>apiMethodTracker</var> and a <code id="ongoing-navigation-tracking:navigationhistoryentry-3"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>
  <var>nhe</var>:</p>

  <ol><li><p>Set <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-committed-to-entry" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-to-entry-3">committed-to entry</a> to
   <var>nhe</var>.</p></li><li>
    <p>If <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-state" id="ongoing-navigation-tracking:navigation-api-method-tracker-state-3">serialized state</a> is not null, then set
    <var>nhe</var>'s <a href="#nhe-she" id="ongoing-navigation-tracking:nhe-she">session history entry</a>'s <a href="#she-navigation-api-state" id="ongoing-navigation-tracking:she-navigation-api-state-2">navigation API state</a> to <var>apiMethodTracker</var>'s
    <a href="#navigation-api-method-tracker-state" id="ongoing-navigation-tracking:navigation-api-method-tracker-state-4">serialized state</a>.</p>

    <p class="note">If it's null, then we're traversing to <var>nhe</var> via <code id="ongoing-navigation-tracking:dom-navigation-traverseto"><a href="#dom-navigation-traverseto">navigation.traverseTo()</a></code>, which does not allow changing
    the state.</p>

    <p class="note">At this point, <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-state" id="ongoing-navigation-tracking:navigation-api-method-tracker-state-5">serialized state</a> is no longer needed.
    Implementations might want to clear it out to avoid keeping it alive for the lifetime of the
    <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-8">navigation API method tracker</a>.</p>
   </li><li>
    <p>Resolve <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-committed" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-3">committed promise</a> with
    <var>nhe</var>.</p>

    <p class="note">At this point, <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-committed" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-4">committed promise</a> is only needed in
    cases where it has not yet been returned to author code. Implementations might want to clear it
    out to avoid keeping it alive for the lifetime of the <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-9">navigation API method
    tracker</a>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="resolve-the-finished-promise">resolve the finished promise</dfn> for a <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-10">navigation API method tracker</a>
  <var>apiMethodTracker</var>:</p>

  <ol><li><p><a id="ongoing-navigation-tracking:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-committed-to-entry" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-to-entry-4">committed-to entry</a> is not
   null.</p></li><li><p>Resolve <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-finished" id="ongoing-navigation-tracking:navigation-api-method-tracker-finished-3">finished promise</a> with its <a href="#navigation-api-method-tracker-committed-to-entry" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-to-entry-5">committed-to entry</a>.</p></li><li><p><a href="#navigation-api-method-tracker-clean-up" id="ongoing-navigation-tracking:navigation-api-method-tracker-clean-up">Clean up</a>
   <var>apiMethodTracker</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="reject-the-finished-promise">reject the finished promise</dfn> for a <a href="#navigation-api-method-tracker" id="ongoing-navigation-tracking:navigation-api-method-tracker-11">navigation API method tracker</a>
  <var>apiMethodTracker</var> with a JavaScript value <var>exception</var>:</p>

  <ol><li>
    <p>Reject <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-committed" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-5">committed promise</a> with
    <var>exception</var>.</p>

    <p class="note">This will do nothing if <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-committed" id="ongoing-navigation-tracking:navigation-api-method-tracker-committed-6">committed promise</a> was previously
    resolved via <a href="#notify-about-the-committed-to-entry" id="ongoing-navigation-tracking:notify-about-the-committed-to-entry">notify about the committed-to entry</a>.</p>
   </li><li><p>Reject <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-finished" id="ongoing-navigation-tracking:navigation-api-method-tracker-finished-4">finished promise</a> with
   <var>exception</var>.</p></li><li><p><a href="#navigation-api-method-tracker-clean-up" id="ongoing-navigation-tracking:navigation-api-method-tracker-clean-up-2">Clean up</a>
   <var>apiMethodTracker</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="abort-the-ongoing-navigation">abort the ongoing navigation</dfn> given a <code id="ongoing-navigation-tracking:navigation-6"><a href="#navigation">Navigation</a></code>
  <var>navigation</var> and an optional <code id="ongoing-navigation-tracking:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> <var>error</var>:</p>

  <ol><li><p>Let <var>event</var> be <var>navigation</var>'s <a href="#ongoing-navigate-event" id="ongoing-navigation-tracking:ongoing-navigate-event">ongoing <code>navigate</code> event</a>.</p></li><li><p><a id="ongoing-navigation-tracking:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var> is not null.</p></li><li><p>Set <var>navigation</var>'s <a href="#focus-changed-during-ongoing-navigation" id="ongoing-navigation-tracking:focus-changed-during-ongoing-navigation">focus changed during ongoing navigation</a> to
   false.</p></li><li><p>Set <var>navigation</var>'s <a href="#suppress-normal-scroll-restoration-during-ongoing-navigation" id="ongoing-navigation-tracking:suppress-normal-scroll-restoration-during-ongoing-navigation">suppress normal scroll restoration during ongoing
   navigation</a> to false.</p></li><li><p>If <var>error</var> was not given, then let <var>error</var> be a new
   <a id="ongoing-navigation-tracking:aborterror" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a> <code id="ongoing-navigation-tracking:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> created in
   <var>navigation</var>'s <a href="#concept-relevant-realm" id="ongoing-navigation-tracking:concept-relevant-realm-3">relevant realm</a>.</p></li><li><p>If <var>event</var>'s <a id="ongoing-navigation-tracking:dispatch-flag" href="https://dom.spec.whatwg.org/#dispatch-flag" data-x-internal="dispatch-flag">dispatch flag</a> is set, then set <var>event</var>'s
   <a id="ongoing-navigation-tracking:canceled-flag-3" href="https://dom.spec.whatwg.org/#canceled-flag" data-x-internal="canceled-flag">canceled flag</a> to true.</p></li><li><p><a href="#abort-a-navigateevent" id="ongoing-navigation-tracking:abort-a-navigateevent">Abort</a> <var>event</var> given
   <var>error</var>.</p></li></ol>

  <p>To <dfn id="abort-a-navigateevent">abort a <code>NavigateEvent</code></dfn> <var>event</var> given <var>reason</var>:</p>

  <ol><li><p>Let <var>navigation</var> be <var>event</var>'s <a href="#concept-relevant-global" id="ongoing-navigation-tracking:concept-relevant-global">relevant global object</a>'s
   <a href="#window-navigation-api" id="ongoing-navigation-tracking:window-navigation-api">navigation API</a>.</p></li><li><p><a id="ongoing-navigation-tracking:signal-abort-2" href="https://dom.spec.whatwg.org/#abortcontroller-signal-abort" data-x-internal="signal-abort">Signal abort</a> on <var>event</var>'s <a href="#concept-navigateevent-abort-controller" id="ongoing-navigation-tracking:concept-navigateevent-abort-controller-2">abort controller</a> given
   <var>reason</var>.</p></li><li>
    <p>Let <var>errorInfo</var> be the result of <a href="#extract-error" id="ongoing-navigation-tracking:extract-error">extracting error
    information</a> from <var>reason</var>.</p>

    <p class="note">For example, if this algorithm is reached because of a call to <code id="ongoing-navigation-tracking:dom-window-stop"><a href="#dom-window-stop">window.stop()</a></code>, these properties would probably end up
    initialized based on the line of script that called <code id="ongoing-navigation-tracking:dom-window-stop-2"><a href="#dom-window-stop">window.stop()</a></code>. But if it's because the user clicked the stop
    button, these properties would probably end up with default values like the empty string or
    0.</p>
   </li><li><p>Set <var>navigation</var>'s <a href="#ongoing-navigate-event" id="ongoing-navigation-tracking:ongoing-navigate-event-2">ongoing <code>navigate</code>
   event</a> to null.</p></li><li><p>If <var>navigation</var>'s <a href="#ongoing-api-method-tracker" id="ongoing-navigation-tracking:ongoing-api-method-tracker-3">ongoing API method tracker</a> is non-null, then
   <a href="#reject-the-finished-promise" id="ongoing-navigation-tracking:reject-the-finished-promise">reject the finished promise</a> for <var>apiMethodTracker</var> with
   <var>error</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="ongoing-navigation-tracking:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="ongoing-navigation-tracking:event-navigateerror-2"><a href="#event-navigateerror">navigateerror</a></code> at <var>navigation</var> using
   <code id="ongoing-navigation-tracking:errorevent"><a href="#errorevent">ErrorEvent</a></code>, with additional attributes initialized according to
   <var>errorInfo</var>.</p></li><li><p>If <var>navigation</var>'s <a href="#concept-navigation-transition" id="ongoing-navigation-tracking:concept-navigation-transition">transition</a>
   is null, then return.</p></li><li><p>Reject <var>navigation</var>'s <a href="#concept-navigation-transition" id="ongoing-navigation-tracking:concept-navigation-transition-2">transition</a>'s <a href="#concept-navigationtransition-committed" id="ongoing-navigation-tracking:concept-navigationtransition-committed">committed promise</a> with
   <var>error</var>.</p></li><li><p>Reject <var>navigation</var>'s <a href="#concept-navigation-transition" id="ongoing-navigation-tracking:concept-navigation-transition-3">transition</a>'s <a href="#concept-navigationtransition-finished" id="ongoing-navigation-tracking:concept-navigationtransition-finished">finished promise</a> with
   <var>error</var>.</p></li><li><p>Set <var>navigation</var>'s <a href="#concept-navigation-transition" id="ongoing-navigation-tracking:concept-navigation-transition-4">transition</a>
   to null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="inform-the-navigation-api-about-aborting-navigation">inform the navigation API about aborting navigation</dfn> in a <a href="#navigable" id="ongoing-navigation-tracking:navigable">navigable</a>
  <var>navigable</var>:</p>

  <ol><li><p>If this algorithm is running on <var>navigable</var>'s <a href="#nav-window" id="ongoing-navigation-tracking:nav-window">active
   window</a>'s <a href="#relevant-agent" id="ongoing-navigation-tracking:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="ongoing-navigation-tracking:concept-agent-event-loop">event
   loop</a>, then continue on to the following steps. Otherwise, <a href="#queue-a-global-task" id="ongoing-navigation-tracking:queue-a-global-task">queue a global task</a>
   on the <a href="#navigation-and-traversal-task-source" id="ongoing-navigation-tracking:navigation-and-traversal-task-source">navigation and traversal task source</a> given <var>navigable</var>'s <a href="#nav-window" id="ongoing-navigation-tracking:nav-window-2">active window</a> to run the following steps.</p></li><li><p>Let <var>navigation</var> be <var>navigable</var>'s <a href="#nav-window" id="ongoing-navigation-tracking:nav-window-3">active
   window</a>'s <a href="#window-navigation-api" id="ongoing-navigation-tracking:window-navigation-api-2">navigation API</a>.</p></li><li>
    <p><a id="ongoing-navigation-tracking:while" href="https://infra.spec.whatwg.org/#iteration-while" data-x-internal="while">While</a> <var>navigation</var>'s <a href="#ongoing-navigate-event" id="ongoing-navigation-tracking:ongoing-navigate-event-3">ongoing <code>navigate</code> event</a> is not null:</p>

    <ol><li><p><a href="#abort-the-ongoing-navigation" id="ongoing-navigation-tracking:abort-the-ongoing-navigation">Abort the ongoing navigation</a> given <var>navigation</var>.</p></li></ol>

    <div class="note">
     <p>If there is an ongoing cross-document navigation, this means it will be signaled to the
     navigation API as aborted, e.g., by firing <code id="ongoing-navigation-tracking:event-navigateerror-3"><a href="#event-navigateerror">navigateerror</a></code> events. This is somewhat accurate, since the
     next navigation the <code id="ongoing-navigation-tracking:document"><a href="#document">Document</a></code> experiences will be this same-document navigation, so
     a developer which was expecting the next navigation completion to be that of the cross-document
     navigation gets a useful signal that this did not happen. However, it is also somewhat
     inaccurate, as the browser will continue to process the ongoing cross-document navigation
     (applying it after this same-document one synchronously finishes).</p>

     <p>Ultimately, the navigation API gets a bit messy with overlapping cross- and same-document
     navigations, as the <a href="#ongoing-navigation-tracking">ongoing navigation tracking</a>
     machinery and APIs are built to expose only a single ongoing navigation. Web developers will be
     best-served if they do not create such overlapping situations, e.g., by <code>await</code>ing promises returned from <code id="ongoing-navigation-tracking:dom-navigation-navigate-2"><a href="#dom-navigation-navigate">navigation.navigate()</a></code> before starting new
     navigations.</p>
    </div>

    <p class="note">This is a loop, since <a href="#abort-the-ongoing-navigation" id="ongoing-navigation-tracking:abort-the-ongoing-navigation-2">abort the ongoing navigation</a> can run
    JavaScript (e.g., via the <code id="ongoing-navigation-tracking:event-navigateerror-4"><a href="#event-navigateerror">navigateerror</a></code> event), which
    might start a new navigation. Since such a newly-started navigation will be superseded by the
    completion of this navigation, it gets signaled to the navigation API as aborted.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="inform-the-navigation-api-about-child-navigable-destruction">inform the navigation API about child navigable destruction</dfn> given a
  <a href="#navigable" id="ongoing-navigation-tracking:navigable-2">navigable</a> <var>navigable</var>:</p>

  <ol><li><p><a href="#inform-the-navigation-api-about-aborting-navigation" id="ongoing-navigation-tracking:inform-the-navigation-api-about-aborting-navigation">Inform the navigation API about aborting navigation</a> in
   <var>navigable</var>.</p></li><li><p>Let <var>navigation</var> be <var>navigable</var>'s <a href="#nav-window" id="ongoing-navigation-tracking:nav-window-4">active
   window</a>'s <a href="#window-navigation-api" id="ongoing-navigation-tracking:window-navigation-api-3">navigation API</a>.</p></li><li><p>Let <var>traversalAPIMethodTrackers</var> be a <a href="https://infra.spec.whatwg.org/#list-clone" id="ongoing-navigation-tracking:list-clone" data-x-internal="list-clone">clone</a> of
   <var>navigation</var>'s <a href="#upcoming-traverse-api-method-trackers" id="ongoing-navigation-tracking:upcoming-traverse-api-method-trackers-4">upcoming traverse API method trackers</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="ongoing-navigation-tracking:list-iterate" data-x-internal="list-iterate">For each</a> <var>apiMethodTracker</var> of
   <var>traversalAPIMethodTrackers</var>: <a href="#reject-the-finished-promise" id="ongoing-navigation-tracking:reject-the-finished-promise-2">reject the finished promise</a> for
   <var>apiMethodTracker</var> with a new <a id="ongoing-navigation-tracking:aborterror-2" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a>
   <code id="ongoing-navigation-tracking:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> created in <var>navigation</var>'s <a href="#concept-relevant-realm" id="ongoing-navigation-tracking:concept-relevant-realm-4">relevant realm</a>.</p></li></ol>
  </div>

  <hr>

  <p>The ongoing navigation concept is most-directly exposed to web developers through the <code id="ongoing-navigation-tracking:dom-navigation-transition"><a href="#dom-navigation-transition">navigation.transition</a></code> property, which is an instance of
  the <code id="ongoing-navigation-tracking:navigationtransition"><a href="#navigationtransition">NavigationTransition</a></code> interface:</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="navigationtransition" data-dfn-type="interface"><c- g="">NavigationTransition</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationtype" id="ongoing-navigation-tracking:navigationtype-2"><c- n="">NavigationType</c-></a> <a href="#dom-navigationtransition-navigationtype" id="ongoing-navigation-tracking:dom-navigationtransition-navigationtype"><c- g="">navigationType</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationhistoryentry" id="ongoing-navigation-tracking:navigationhistoryentry-4"><c- n="">NavigationHistoryEntry</c-></a> <a href="#dom-navigationtransition-from" id="ongoing-navigation-tracking:dom-navigationtransition-from"><c- g="">from</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="https://webidl.spec.whatwg.org/#idl-promise" id="ongoing-navigation-tracking:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<c- b="">undefined</c->&gt; <a href="#dom-navigationtransition-committed" id="ongoing-navigation-tracking:dom-navigationtransition-committed"><c- g="">committed</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="https://webidl.spec.whatwg.org/#idl-promise" id="ongoing-navigation-tracking:idl-promise-2" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<c- b="">undefined</c->&gt; <a href="#dom-navigationtransition-finished" id="ongoing-navigation-tracking:dom-navigationtransition-finished-2"><c- g="">finished</c-></a>;
};</code></pre>

  

  <dl class="domintro"><dt><code><a href="#dom-navigation" id="ongoing-navigation-tracking:dom-navigation">navigation</a>.<a href="#dom-navigation-transition" id="dom-navigation-transition-dev">transition</a></code></dt><dd>
    <p>A <code id="ongoing-navigation-tracking:navigationtransition-2"><a href="#navigationtransition">NavigationTransition</a></code> representing any ongoing navigation that hasn't yet
    reached the <code id="ongoing-navigation-tracking:event-navigatesuccess"><a href="#event-navigatesuccess">navigatesuccess</a></code> or <code id="ongoing-navigation-tracking:event-navigateerror-5"><a href="#event-navigateerror">navigateerror</a></code> stage, if one exists; or null, if there is no
    such transition ongoing.</p>

    <p>Since <code id="ongoing-navigation-tracking:dom-navigation-currententry"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> (and other
    properties like <code id="ongoing-navigation-tracking:dom-location-href"><a href="#dom-location-href">location.href</a></code>) are updated immediately
    upon navigation, this <code id="ongoing-navigation-tracking:dom-navigation-transition-2"><a href="#dom-navigation-transition">navigation.transition</a></code>
    property is useful for determining when such navigations are not yet fully settled, according to
    any handlers passed to <code id="ongoing-navigation-tracking:dom-navigateevent-intercept-6"><a href="#dom-navigateevent-intercept">navigateEvent.intercept()</a></code>.</p>
   </dd><dt><code><a href="#dom-navigation" id="ongoing-navigation-tracking:dom-navigation-2">navigation</a>.<a href="#dom-navigation-transition" id="ongoing-navigation-tracking:dom-navigation-transition-3">transition</a>.<a href="#dom-navigationtransition-navigationtype" id="dom-navigationtransition-navigationtype-dev">navigationType</a></code></dt><dd><p>One of "<code id="ongoing-navigation-tracking:dom-navigationtype-push"><a href="#dom-navigationtype-push">push</a></code>", "<code id="ongoing-navigation-tracking:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>", "<code id="ongoing-navigation-tracking:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>", or "<code id="ongoing-navigation-tracking:dom-navigationtype-traverse-3"><a href="#dom-navigationtype-traverse">traverse</a></code>", indicating what type of navigation this
   transition is for.</p></dd><dt><code><a href="#dom-navigation" id="ongoing-navigation-tracking:dom-navigation-3">navigation</a>.<a href="#dom-navigation-transition" id="ongoing-navigation-tracking:dom-navigation-transition-4">transition</a>.<a href="#dom-navigationtransition-from" id="dom-navigationtransition-from-dev">from</a></code></dt><dd><p>The <code id="ongoing-navigation-tracking:navigationhistoryentry-5"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> from which the transition is coming. This can be
   useful to compare against <code id="ongoing-navigation-tracking:dom-navigation-currententry-2"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code>.</p></dd><dt><code><a href="#dom-navigation" id="ongoing-navigation-tracking:dom-navigation-4">navigation</a>.<a href="#dom-navigation-transition" id="ongoing-navigation-tracking:dom-navigation-transition-5">transition</a>.<a href="#dom-navigationtransition-committed" id="dom-navigationtransition-committed-dev">committed</a></code></dt><dd><p>A promise which fulfills once the <code id="ongoing-navigation-tracking:dom-navigation-currententry-3"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> and <a href="https://dom.spec.whatwg.org/#concept-document-url" id="ongoing-navigation-tracking:the-document's-address" data-x-internal="the-document's-address">URL</a> change. This occurs after all of its <a href="#dom-navigationinterceptoptions-precommithandler" id="ongoing-navigation-tracking:dom-navigationinterceptoptions-precommithandler">precommit handlers</a> are fulfilled.
   The promise rejects if one or more of the <a href="#dom-navigationinterceptoptions-precommithandler" id="ongoing-navigation-tracking:dom-navigationinterceptoptions-precommithandler-2">precommit handlers</a>
   rejects.</p></dd><dt><code><a href="#dom-navigation" id="ongoing-navigation-tracking:dom-navigation-5">navigation</a>.<a href="#dom-navigation-transition" id="ongoing-navigation-tracking:dom-navigation-transition-6">transition</a>.<a href="#dom-navigationtransition-finished" id="dom-navigationtransition-finished-dev">finished</a></code></dt><dd><p>A promise which fulfills at the same time as the <code id="ongoing-navigation-tracking:event-navigatesuccess-2"><a href="#event-navigatesuccess">navigatesuccess</a></code> fires, or rejects at the same time the
   <code id="ongoing-navigation-tracking:event-navigateerror-6"><a href="#event-navigateerror">navigateerror</a></code> event fires.</p></dd></dl>

  

  <p>Each <code id="ongoing-navigation-tracking:navigation-7"><a href="#navigation">Navigation</a></code> has a <dfn id="concept-navigation-transition">transition</dfn>, which is a
  <code id="ongoing-navigation-tracking:navigationtransition-3"><a href="#navigationtransition">NavigationTransition</a></code> or null, initially null.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-transition" data-dfn-type="attribute"><code>transition</code></dfn> getter steps are to return
  <a id="ongoing-navigation-tracking:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigation-transition" id="ongoing-navigation-tracking:concept-navigation-transition-5">transition</a>.</p>
  </div>

  <p>Each <code id="ongoing-navigation-tracking:navigationtransition-4"><a href="#navigationtransition">NavigationTransition</a></code> has an associated <dfn id="concept-navigationtransition-navigationtype">navigation type</dfn>, which is a
  <code id="ongoing-navigation-tracking:navigationtype-3"><a href="#navigationtype">NavigationType</a></code>.</p>

  <p>Each <code id="ongoing-navigation-tracking:navigationtransition-5"><a href="#navigationtransition">NavigationTransition</a></code> has an associated <dfn id="concept-navigationtransition-from">from entry</dfn>, which is a
  <code id="ongoing-navigation-tracking:navigationhistoryentry-6"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>.</p>

  <p>Each <code id="ongoing-navigation-tracking:navigationtransition-6"><a href="#navigationtransition">NavigationTransition</a></code> has an associated <dfn id="concept-navigationtransition-committed">committed promise</dfn>, which is a promise.</p>

  <p>Each <code id="ongoing-navigation-tracking:navigationtransition-7"><a href="#navigationtransition">NavigationTransition</a></code> has an associated <dfn id="concept-navigationtransition-finished">finished promise</dfn>, which is a promise.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationTransition" id="dom-navigationtransition-navigationtype" data-dfn-type="attribute"><code>navigationType</code></dfn> getter steps are to
  return <a id="ongoing-navigation-tracking:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationtransition-navigationtype" id="ongoing-navigation-tracking:concept-navigationtransition-navigationtype">navigation
  type</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationTransition" id="dom-navigationtransition-from" data-dfn-type="attribute"><code>from</code></dfn> getter steps are to return
  <a id="ongoing-navigation-tracking:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationtransition-from" id="ongoing-navigation-tracking:concept-navigationtransition-from">from entry</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationTransition" id="dom-navigationtransition-committed" data-dfn-type="attribute"><code>committed</code></dfn> getter steps are to return
  <a id="ongoing-navigation-tracking:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationtransition-committed" id="ongoing-navigation-tracking:concept-navigationtransition-committed-2">committed
  promise</a>.</p>

  <p>The <dfn data-dfn-for="NavigationTransition" id="dom-navigationtransition-finished" data-dfn-type="attribute"><code>finished</code></dfn> getter steps are to return
  <a id="ongoing-navigation-tracking:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationtransition-finished" id="ongoing-navigation-tracking:concept-navigationtransition-finished-2">finished
  promise</a>.</p>
  </div>

  


  <h5 id="navigation-activation-interface"><span class="secno">7.2.6.9</span> The <code id="navigation-activation-interface:navigationactivation"><a href="#navigationactivation">NavigationActivation</a></code> interface<a href="#navigation-activation-interface" class="self-link"></a></h5>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="navigationactivation" data-dfn-type="interface"><c- g="">NavigationActivation</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationhistoryentry" id="navigation-activation-interface:navigationhistoryentry"><c- n="">NavigationHistoryEntry</c-></a>? <a href="#dom-navigationactivation-from" id="navigation-activation-interface:dom-navigationactivation-from"><c- g="">from</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationhistoryentry" id="navigation-activation-interface:navigationhistoryentry-2"><c- n="">NavigationHistoryEntry</c-></a> <a href="#dom-navigationactivation-entry" id="navigation-activation-interface:dom-navigationactivation-entry"><c- g="">entry</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationtype" id="navigation-activation-interface:navigationtype"><c- n="">NavigationType</c-></a> <a href="#dom-navigationactivation-navigationtype" id="navigation-activation-interface:dom-navigationactivation-navigationtype"><c- g="">navigationType</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><a href="#dom-navigation" id="navigation-activation-interface:dom-navigation">navigation</a>.<a href="#dom-navigation-activation" id="dom-navigation-activation-dev">activation</a></code></dt><dd>
    <p>A <code id="navigation-activation-interface:navigationactivation-2"><a href="#navigationactivation">NavigationActivation</a></code> containing information about the most recent
    cross-document navigation, the navigation that "activated" this <code id="navigation-activation-interface:document"><a href="#document">Document</a></code>.</p>

    <p>While <code id="navigation-activation-interface:dom-navigation-currententry"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> and the
    <code id="navigation-activation-interface:document-2"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="navigation-activation-interface:the-document's-address" data-x-internal="the-document's-address">URL</a> can be updated regularly
    due to same-document navigations, <code id="navigation-activation-interface:dom-navigation-activation"><a href="#dom-navigation-activation">navigation.activation</a></code> stays constant, and its properties
    are only updated if the <code id="navigation-activation-interface:document-3"><a href="#document">Document</a></code> is <a href="#reactivate-a-document" id="navigation-activation-interface:reactivate-a-document">reactivated</a> from history.</p>
   </dd><dt><code><a href="#dom-navigation" id="navigation-activation-interface:dom-navigation-2">navigation</a>.<a href="#dom-navigation-activation" id="navigation-activation-interface:dom-navigation-activation-2">activation</a>.<a href="#dom-navigationactivation-entry" id="dom-navigationactivation-entry-dev">entry</a></code></dt><dd><p>A <code id="navigation-activation-interface:navigationhistoryentry-3"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>, equivalent to the value of the <code id="navigation-activation-interface:dom-navigation-currententry-2"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> property at the moment the
   <code id="navigation-activation-interface:document-4"><a href="#document">Document</a></code> was activated.</p></dd><dt><code><a href="#dom-navigation" id="navigation-activation-interface:dom-navigation-3">navigation</a>.<a href="#dom-navigation-activation" id="navigation-activation-interface:dom-navigation-activation-3">activation</a>.<a href="#dom-navigationactivation-from" id="dom-navigationactivation-from-dev">from</a></code></dt><dd>
    <p>A <code id="navigation-activation-interface:navigationhistoryentry-4"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>, representing the <code id="navigation-activation-interface:document-5"><a href="#document">Document</a></code> that was active
    right before the current <code id="navigation-activation-interface:document-6"><a href="#document">Document</a></code>. This will have a value null in case the
    previous <code id="navigation-activation-interface:document-7"><a href="#document">Document</a></code> was not <a href="#same-origin" id="navigation-activation-interface:same-origin">same origin</a> with this one or if it was the
    <a href="#is-initial-about:blank" id="navigation-activation-interface:is-initial-about:blank">initial <code>about:blank</code></a>
    <code id="navigation-activation-interface:document-8"><a href="#document">Document</a></code>.</p>

    <p>There are some cases in which either the <code id="navigation-activation-interface:dom-navigationactivation-from-2"><a href="#dom-navigationactivation-from">from</a></code> or <code id="navigation-activation-interface:dom-navigationactivation-entry-2"><a href="#dom-navigationactivation-entry">entry</a></code> <code id="navigation-activation-interface:navigationhistoryentry-5"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> objects
    would not be viable targets for the <code id="navigation-activation-interface:dom-navigation-traverseto"><a href="#dom-navigation-traverseto">traverseTo()</a></code>
    method, as they might not be retained in history. For example, the <code id="navigation-activation-interface:document-9"><a href="#document">Document</a></code> can be
    activated using <code id="navigation-activation-interface:dom-location-replace"><a href="#dom-location-replace">location.replace()</a></code> or its initial
    entry could be replaced by <code id="navigation-activation-interface:dom-history-replacestate"><a href="#dom-history-replacestate">history.replaceState()</a></code>. However, those entries' <code id="navigation-activation-interface:dom-navigationhistoryentry-url"><a href="#dom-navigationhistoryentry-url">url</a></code> property and <code id="navigation-activation-interface:dom-navigationhistoryentry-getstate"><a href="#dom-navigationhistoryentry-getstate">getState()</a></code> method are still accessible.</p>
   </dd><dt><code><a href="#dom-navigation" id="navigation-activation-interface:dom-navigation-4">navigation</a>.<a href="#dom-navigation-activation" id="navigation-activation-interface:dom-navigation-activation-4">activation</a>.<a href="#dom-navigationactivation-navigationtype" id="dom-navigationactivation-navigationtype-dev">navigationType</a></code></dt><dd><p>One of "<code id="navigation-activation-interface:dom-navigationtype-push"><a href="#dom-navigationtype-push">push</a></code>", "<code id="navigation-activation-interface:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>", "<code id="navigation-activation-interface:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>", or "<code id="navigation-activation-interface:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>", indicating what type of navigation
   activated this <code id="navigation-activation-interface:document-10"><a href="#document">Document</a></code>.</p></dd></dl>

  <p>Each <code id="navigation-activation-interface:navigation"><a href="#navigation">Navigation</a></code> has an associated <dfn id="navigation-activation">activation</dfn>, which is null or a
  <code id="navigation-activation-interface:navigationactivation-3"><a href="#navigationactivation">NavigationActivation</a></code> object, initially null.</p>

  <p>Each <code id="navigation-activation-interface:navigationactivation-4"><a href="#navigationactivation">NavigationActivation</a></code> has:</p>

  <ul><li><p><dfn id="nav-activation-old-entry">old entry</dfn>, null or a
   <code id="navigation-activation-interface:navigationhistoryentry-6"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>.</p></li><li><p><dfn id="nav-activation-new-entry">new entry</dfn>, null or a
   <code id="navigation-activation-interface:navigationhistoryentry-7"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>.</p></li><li><p><dfn id="nav-activation-navigation-type">navigation type</dfn>, a
   <code id="navigation-activation-interface:navigationtype-2"><a href="#navigationtype">NavigationType</a></code>.</p></li></ul>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Navigation" id="dom-navigation-activation" data-dfn-type="attribute"><code>activation</code></dfn> getter steps are to return
  <a id="navigation-activation-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#navigation-activation" id="navigation-activation-interface:navigation-activation">activation</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationActivation" id="dom-navigationactivation-from" data-dfn-type="attribute"><code>from</code></dfn> getter steps are to return
  <a id="navigation-activation-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#nav-activation-old-entry" id="navigation-activation-interface:nav-activation-old-entry">old entry</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationActivation" id="dom-navigationactivation-entry" data-dfn-type="attribute"><code>entry</code></dfn> getter steps are to return
  <a id="navigation-activation-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#nav-activation-new-entry" id="navigation-activation-interface:nav-activation-new-entry">new entry</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationActivation" id="dom-navigationactivation-navigationtype" data-dfn-type="attribute"><code>navigationType</code></dfn> getter steps are to
  return <a id="navigation-activation-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#nav-activation-navigation-type" id="navigation-activation-interface:nav-activation-navigation-type">navigation type</a>.</p>
  </div>


  <h5 id="the-navigate-event"><span class="secno">7.2.6.10</span> The <code id="the-navigate-event:event-navigate"><a href="#event-navigate">navigate</a></code> event<a href="#the-navigate-event" class="self-link"></a></h5>

  <p>A major feature of the navigation API is the <code id="the-navigate-event:event-navigate-2"><a href="#event-navigate">navigate</a></code>
  event. This event is fired on any navigation (in the <a href="#navigationtype" id="the-navigate-event:navigationtype">broad sense of
  the word</a>), allowing web developers to monitor such outgoing navigations. In many cases, the
  event is <code id="the-navigate-event:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code>, which allows preventing the
  navigation from happening. And in others, the navigation can be intercepted and replaced with a
  same-document navigation by using the <code id="the-navigate-event:dom-navigateevent-intercept"><a href="#dom-navigateevent-intercept">intercept()</a></code> method of the <code id="the-navigate-event:navigateevent"><a href="#navigateevent">NavigateEvent</a></code>
  class.</p>

  <h6 id="the-navigateevent-interface"><span class="secno">7.2.6.10.1</span> The <code id="the-navigateevent-interface:navigateevent"><a href="#navigateevent">NavigateEvent</a></code> interface<a href="#the-navigateevent-interface" class="self-link"></a></h6>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="navigateevent" data-dfn-type="interface"><c- g="">NavigateEvent</c-></dfn> : <a id="the-navigateevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <a href="#navigateeventinit" id="the-navigateevent-interface:navigateeventinit"><c- n="">NavigateEventInit</c-></a> <c- g="">eventInitDict</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationtype" id="the-navigateevent-interface:navigationtype"><c- n="">NavigationType</c-></a> <a href="#dom-navigateevent-navigationtype" id="the-navigateevent-interface:dom-navigateevent-navigationtype"><c- g="">navigationType</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationdestination" id="the-navigateevent-interface:navigationdestination"><c- n="">NavigationDestination</c-></a> <a href="#dom-navigateevent-destination" id="the-navigateevent-interface:dom-navigateevent-destination"><c- g="">destination</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigateevent-canintercept" id="the-navigateevent-interface:dom-navigateevent-canintercept"><c- g="">canIntercept</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigateevent-userinitiated" id="the-navigateevent-interface:dom-navigateevent-userinitiated"><c- g="">userInitiated</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigateevent-hashchange" id="the-navigateevent-interface:dom-navigateevent-hashchange"><c- g="">hashChange</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="the-navigateevent-interface:abortsignal" href="https://dom.spec.whatwg.org/#abortsignal" data-x-internal="abortsignal"><c- n="">AbortSignal</c-></a> <a href="#dom-navigateevent-signal" id="the-navigateevent-interface:dom-navigateevent-signal"><c- g="">signal</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <code id="the-navigateevent-interface:formdata"><a data-x-internal="formdata" href="https://xhr.spec.whatwg.org/#formdata"><c- n="">FormData</c-></a></code>? <a href="#dom-navigateevent-formdata" id="the-navigateevent-interface:dom-navigateevent-formdata"><c- g="">formData</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-navigateevent-downloadrequest" id="the-navigateevent-interface:dom-navigateevent-downloadrequest"><c- g="">downloadRequest</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">any</c-> <a href="#dom-navigateevent-info" id="the-navigateevent-interface:dom-navigateevent-info"><c- g="">info</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigateevent-hasuavisualtransition" id="the-navigateevent-interface:dom-navigateevent-hasuavisualtransition"><c- g="">hasUAVisualTransition</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- n="">Element</c->? <a href="#dom-navigateevent-sourceelement" id="the-navigateevent-interface:dom-navigateevent-sourceelement"><c- g="">sourceElement</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-navigateevent-intercept" id="the-navigateevent-interface:dom-navigateevent-intercept"><c- g="">intercept</c-></a>(<c- b="">optional</c-> <a href="#navigationinterceptoptions" id="the-navigateevent-interface:navigationinterceptoptions"><c- n="">NavigationInterceptOptions</c-></a> <c- g="">options</c-> = {});
  <c- b="">undefined</c-> <a href="#dom-navigateevent-scroll" id="the-navigateevent-interface:dom-navigateevent-scroll"><c- g="">scroll</c-></a>();
};

<c- b="">dictionary</c-> <dfn id="navigateeventinit" data-dfn-type="dictionary"><c- g="">NavigateEventInit</c-></dfn> : <a id="the-navigateevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <a href="#navigationtype" id="the-navigateevent-interface:navigationtype-2"><c- n="">NavigationType</c-></a> <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-navigationtype" data-dfn-type="dict-member"><c- g="">navigationType</c-></dfn> = "<a href="#dom-navigationtype-push" id="the-navigateevent-interface:dom-navigationtype-push">push</a>";
  <c- b="">required</c-> <a href="#navigationdestination" id="the-navigateevent-interface:navigationdestination-2"><c- n="">NavigationDestination</c-></a> <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-destination" data-dfn-type="dict-member"><c- g="">destination</c-></dfn>;
  <c- b="">boolean</c-> <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-canintercept" data-dfn-type="dict-member"><c- g="">canIntercept</c-></dfn> = <c- b="">false</c->;
  <c- b="">boolean</c-> <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-userinitiated" data-dfn-type="dict-member"><c- g="">userInitiated</c-></dfn> = <c- b="">false</c->;
  <c- b="">boolean</c-> <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-hashchange" data-dfn-type="dict-member"><c- g="">hashChange</c-></dfn> = <c- b="">false</c->;
  <c- b="">required</c-> <a id="the-navigateevent-interface:abortsignal-2" href="https://dom.spec.whatwg.org/#abortsignal" data-x-internal="abortsignal"><c- n="">AbortSignal</c-></a> <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-signal" data-dfn-type="dict-member"><c- g="">signal</c-></dfn>;
  <a id="the-navigateevent-interface:formdata-2" href="https://xhr.spec.whatwg.org/#formdata" data-x-internal="formdata"><c- n="">FormData</c-></a>? <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-formdata" data-dfn-type="dict-member"><c- g="">formData</c-></dfn> = <c- b="">null</c->;
  <c- b="">DOMString</c->? <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-downloadrequest" data-dfn-type="dict-member"><c- g="">downloadRequest</c-></dfn> = <c- b="">null</c->;
  <c- b="">any</c-> <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-info" data-dfn-type="dict-member"><c- g="">info</c-></dfn>;
  <c- b="">boolean</c-> <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-hasuavisualtransition" data-dfn-type="dict-member"><c- g="">hasUAVisualTransition</c-></dfn> = <c- b="">false</c->;
  <c- n="">Element</c->? <dfn data-dfn-for="NavigateEventInit" id="dom-navigateeventinit-sourceelement" data-dfn-type="dict-member"><c- g="">sourceElement</c-></dfn> = <c- b="">null</c->;
};

<c- b="">dictionary</c-> <dfn id="navigationinterceptoptions" data-dfn-type="dictionary"><c- g="">NavigationInterceptOptions</c-></dfn> {
  <a href="#navigationprecommithandler" id="the-navigateevent-interface:navigationprecommithandler"><c- n="">NavigationPrecommitHandler</c-></a> <dfn data-dfn-for="NavigationInterceptOptions" id="dom-navigationinterceptoptions-precommithandler" data-dfn-type="dict-member"><c- g="">precommitHandler</c-></dfn>;
  <a href="#navigationintercepthandler" id="the-navigateevent-interface:navigationintercepthandler"><c- n="">NavigationInterceptHandler</c-></a> <dfn data-dfn-for="NavigationInterceptOptions" id="dom-navigationinterceptoptions-handler" data-dfn-type="dict-member"><c- g="">handler</c-></dfn>;
  <a href="#navigationfocusreset" id="the-navigateevent-interface:navigationfocusreset"><c- n="">NavigationFocusReset</c-></a> <dfn data-dfn-for="NavigationInterceptOptions" id="dom-navigationinterceptoptions-focusreset" data-dfn-type="dict-member"><c- g="">focusReset</c-></dfn>;
  <a href="#navigationscrollbehavior" id="the-navigateevent-interface:navigationscrollbehavior"><c- n="">NavigationScrollBehavior</c-></a> <dfn data-dfn-for="NavigationInterceptOptions" id="dom-navigationinterceptoptions-scroll" data-dfn-type="dict-member"><c- g="">scroll</c-></dfn>;
};

<c- b="">enum</c-> <dfn id="navigationfocusreset" data-dfn-type="enum"><c- g="">NavigationFocusReset</c-></dfn> {
  <c- s="">"</c-><dfn data-dfn-for="NavigationFocusReset" id="dom-navigationfocusreset-after-transition" data-dfn-type="enum-value"><c- s="">after-transition</c-></dfn><c- s="">"</c->,
  <c- s="">"</c-><dfn data-dfn-for="NavigationFocusReset" id="dom-navigationfocusreset-manual" data-dfn-type="enum-value"><c- s="">manual</c-></dfn><c- s="">"</c->
};

<c- b="">enum</c-> <dfn id="navigationscrollbehavior" data-dfn-type="enum"><c- g="">NavigationScrollBehavior</c-></dfn> {
  <c- s="">"</c-><dfn data-dfn-for="NavigationScrollBehavior" id="dom-navigationscrollbehavior-after-transition" data-dfn-type="enum-value"><c- s="">after-transition</c-></dfn><c- s="">"</c->,
  <c- s="">"</c-><dfn data-dfn-for="NavigationScrollBehavior" id="dom-navigationscrollbehavior-manual" data-dfn-type="enum-value"><c- s="">manual</c-></dfn><c- s="">"</c->
};

<c- b="">callback</c-> <dfn id="navigationintercepthandler" data-dfn-type="callback"><c- g="">NavigationInterceptHandler</c-></dfn> = <a href="https://webidl.spec.whatwg.org/#idl-promise" id="the-navigateevent-interface:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<c- b="">undefined</c->&gt; ();</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-navigateevent-navigationtype" id="dom-navigateevent-navigationtype-dev">navigationType</a></code></dt><dd><p>One of "<code id="the-navigateevent-interface:dom-navigationtype-push-2"><a href="#dom-navigationtype-push">push</a></code>", "<code id="the-navigateevent-interface:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>", "<code id="the-navigateevent-interface:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>", or "<code id="the-navigateevent-interface:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>", indicating what type of navigation this
   is.</p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-destination" id="dom-navigateevent-destination-dev">destination</a></code></dt><dd><p>A <code id="the-navigateevent-interface:navigationdestination-3"><a href="#navigationdestination">NavigationDestination</a></code> representing the destination of the
   navigation.</p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-canintercept" id="dom-navigateevent-canintercept-dev">canIntercept</a></code></dt><dd>
    <p>True if <code id="the-navigateevent-interface:dom-navigateevent-intercept-2"><a href="#dom-navigateevent-intercept">intercept()</a></code> can be called to
    intercept this navigation and convert it into a same-document navigation, replacing its usual
    behavior; false otherwise.</p>

    <p>Generally speaking, this will be true whenever the current <code id="the-navigateevent-interface:document"><a href="#document">Document</a></code> <a href="#can-have-its-url-rewritten" id="the-navigateevent-interface:can-have-its-url-rewritten">can
    have its URL rewritten</a> to the destination URL, except for in the case of cross-document
    "<code id="the-navigateevent-interface:dom-navigationtype-traverse-2"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigations, where it will always
    be false.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-navigateevent-userinitiated" id="dom-navigateevent-userinitiated-dev">userInitiated</a></code></dt><dd><p>True if this navigation was due to a user clicking on an <code id="the-navigateevent-interface:the-a-element"><a href="#the-a-element">a</a></code> element,
   submitting a <code id="the-navigateevent-interface:the-form-element"><a href="#the-form-element">form</a></code> element, or using the <a href="#nav-traversal-ui">browser UI</a>
   to navigate; false otherwise.</p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-hashchange" id="dom-navigateevent-hashchange-dev">hashChange</a></code></dt><dd><p>True for a <a href="#navigate-fragid" id="the-navigateevent-interface:navigate-fragid">fragment navigation</a>; false
   otherwise.</p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-signal" id="dom-navigateevent-signal-dev">signal</a></code></dt><dd>
    <p>An <code id="the-navigateevent-interface:abortsignal-3"><a data-x-internal="abortsignal" href="https://dom.spec.whatwg.org/#abortsignal">AbortSignal</a></code> which will become aborted if the navigation gets canceled, e.g.,
    by the user pressing their browser's "Stop" button, or by another navigation interrupting this
    one.</p>

    <p>The expected pattern is for developers to pass this along to any async operations, such as
    <code id="the-navigateevent-interface:fetch()"><a data-x-internal="fetch()" href="https://fetch.spec.whatwg.org/#dom-global-fetch">fetch()</a></code>, which they perform as part of handling this navigation.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-navigateevent-formdata" id="dom-navigateevent-formdata-dev">formData</a></code></dt><dd>
    <p>The <code id="the-navigateevent-interface:formdata-3"><a data-x-internal="formdata" href="https://xhr.spec.whatwg.org/#formdata">FormData</a></code> representing the submitted form entries for this navigation, if
    this navigation is a "<code id="the-navigateevent-interface:dom-navigationtype-push-3"><a href="#dom-navigationtype-push">push</a></code>" or "<code id="the-navigateevent-interface:dom-navigationtype-replace-2"><a href="#dom-navigationtype-replace">replace</a></code>" navigation representing a POST <a href="#concept-form-submit" id="the-navigateevent-interface:concept-form-submit">form submission</a>; null otherwise.</p>

    <p>(Notably, this will be null even for "<code id="the-navigateevent-interface:dom-navigationtype-reload-2"><a href="#dom-navigationtype-reload">reload</a></code>"
    or "<code id="the-navigateevent-interface:dom-navigationtype-traverse-3"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigations that are revisiting
    a <a href="#session-history-entry" id="the-navigateevent-interface:session-history-entry">session history entry</a> that was originally created from a form submission.)</p>
   </dd><dt><code><var>event</var>.<a href="#dom-navigateevent-downloadrequest" id="dom-navigateevent-downloadrequest-dev">downloadRequest</a></code></dt><dd>
    <p>Represents whether or not this navigation was requested to be a download, by using an
    <code id="the-navigateevent-interface:the-a-element-2"><a href="#the-a-element">a</a></code> or <code id="the-navigateevent-interface:the-area-element"><a href="#the-area-element">area</a></code> element's <code id="the-navigateevent-interface:attr-hyperlink-download"><a href="#attr-hyperlink-download">download</a></code> attribute:</p>

    <ul><li><p>If a download was not requested, then this property is null.</p></li><li><p>If a download was requested, returns the filename that was supplied as the <code id="the-navigateevent-interface:attr-hyperlink-download-2"><a href="#attr-hyperlink-download">download</a></code> attribute's value. (This could be the empty
     string.)</p></li></ul>

    <p>Note that a download being requested does not always mean that a download will happen: for
    example, a download might be blocked by browser security policies, or end up being treated as a
    "<code id="the-navigateevent-interface:navigationhistorybehavior-push"><a href="#navigationhistorybehavior-push">push</a></code>" navigation for <a href="https://github.com/whatwg/html/issues/7718" class="XXX">unspecified reasons</a>.</p>

    <p>Similarly, a navigation might end up being a download even if it was not requested to be one,
    due to the destination server responding with a `<code id="the-navigateevent-interface:http-content-disposition"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition: attachment</a></code>` header.</p>

    <p>Finally, note that the <code id="the-navigateevent-interface:event-navigate"><a href="#event-navigate">navigate</a></code> event will not fire at
    all for downloads initiated using browser UI affordances, e.g., those created by right-clicking
    and choosing to save the target of a link.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-navigateevent-info" id="dom-navigateevent-info-dev">info</a></code></dt><dd><p>An arbitrary JavaScript value passed via one of the <a href="#navigation-api-initiating-navigations">navigation API methods</a> which initiated this
   navigation, or undefined if the navigation was initiated by the user or by a different
   API.</p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-hasuavisualtransition" id="dom-navigateevent-hasuavisualtransition-dev">hasUAVisualTransition</a></code></dt><dd><p>Returns true if the user agent performed a visual transition for this navigation before
   dispatching this event. If true, the best user experience will be given if the author
   synchronously updates the DOM to the post-navigation state.</p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-sourceelement" id="dom-navigateevent-sourceelement-dev">sourceElement</a></code></dt><dd><p>Returns the <code id="the-navigateevent-interface:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> responsible for this navigation. This can be an
   <code id="the-navigateevent-interface:the-a-element-3"><a href="#the-a-element">a</a></code>or <code id="the-navigateevent-interface:the-area-element-2"><a href="#the-area-element">area</a></code> element, a <a href="#concept-submit-button" id="the-navigateevent-interface:concept-submit-button">submit button</a>, or a submitted <code id="the-navigateevent-interface:the-form-element-2"><a href="#the-form-element">form</a></code>
   element.</p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-intercept" id="dom-navigateevent-intercept-dev">intercept</a>({ <a href="#dom-navigationinterceptoptions-precommithandler" id="dom-navigationinterceptoptions-precommithandler-dev">precommitHandler</a>, <a href="#dom-navigationinterceptoptions-handler" id="dom-navigationinterceptoptions-handler-dev">handler</a>, <a href="#dom-navigationinterceptoptions-focusreset" id="dom-navigationinterceptoptions-focusreset-dev">focusReset</a>, <a href="#dom-navigationinterceptoptions-scroll" id="dom-navigationinterceptoptions-scroll-dev">scroll</a> })</code></dt><dd>
    <p>Intercepts this navigation, preventing its normal handling and instead converting it into a
    same-document navigation of the same type to the destination URL.</p>

    <p>The <code id="the-navigateevent-interface:dom-navigationinterceptoptions-precommithandler"><a href="#dom-navigationinterceptoptions-precommithandler">precommitHandler</a></code>
    option can be a function that accepts a <code id="the-navigateevent-interface:navigationprecommitcontroller"><a href="#navigationprecommitcontroller">NavigationPrecommitController</a></code> and returns a
    promise. The precommit handler function will run after the <code id="the-navigateevent-interface:event-navigate-2"><a href="#event-navigate">navigate</a></code> event has finished firing, but before the <code id="the-navigateevent-interface:dom-navigation-currententry"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> property has been updated.
    Returning a rejected promise will abort the navigation and its effect, such as updating the URL
    and session history. After all the precommit handlers are fulfilled, the navigation can proceed
    to commit and call the rest of the handlers. The <code id="the-navigateevent-interface:dom-navigationinterceptoptions-precommithandler-2"><a href="#dom-navigationinterceptoptions-precommithandler">precommitHandler</a></code> option can only
    be passed when the event is <code id="the-navigateevent-interface:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code>: trying to
    pass a <code id="the-navigateevent-interface:dom-navigationinterceptoptions-precommithandler-3"><a href="#dom-navigationinterceptoptions-precommithandler">precommitHandler</a></code> to
    a non-cancelable <code id="the-navigateevent-interface:navigateevent-2"><a href="#navigateevent">NavigateEvent</a></code> will throw a
    <a id="the-navigateevent-interface:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-navigateevent-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p>The <code id="the-navigateevent-interface:dom-navigationinterceptoptions-handler"><a href="#dom-navigationinterceptoptions-handler">handler</a></code> option can be a
    function that returns a promise. The handler function will run after the <code id="the-navigateevent-interface:event-navigate-3"><a href="#event-navigate">navigate</a></code> event has finished firing and the <code id="the-navigateevent-interface:dom-navigation-currententry-2"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> property has been updated.
    This returned promise is used to signal the duration, and success or failure, of the navigation.
    After it settles, the browser signals to the user (e.g., via a loading spinner UI, or assistive
    technology) that the navigation is finished. Additionally, it fires <code id="the-navigateevent-interface:event-navigatesuccess"><a href="#event-navigatesuccess">navigatesuccess</a></code> or <code id="the-navigateevent-interface:event-navigateerror"><a href="#event-navigateerror">navigateerror</a></code> events as appropriate, which other parts of
    the web application can respond to.</p>

    <p>By default, using this method will cause focus to reset when any handlers' returned promises
    settle. Focus will be reset to the first element with the <code id="the-navigateevent-interface:attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code> attribute set, or <a href="#the-body-element-2" id="the-navigateevent-interface:the-body-element-2">the body element</a> if
    the attribute isn't present. The <code id="the-navigateevent-interface:dom-navigationinterceptoptions-focusreset"><a href="#dom-navigationinterceptoptions-focusreset">focusReset</a></code> option can be set to "<code id="the-navigateevent-interface:dom-navigationfocusreset-manual"><a href="#dom-navigationfocusreset-manual">manual</a></code>" to avoid this behavior.</p>

    <p>By default, using this method will delay the browser's scroll restoration logic for "<code id="the-navigateevent-interface:dom-navigationtype-traverse-4"><a href="#dom-navigationtype-traverse">traverse</a></code>" or "<code id="the-navigateevent-interface:dom-navigationtype-reload-3"><a href="#dom-navigationtype-reload">reload</a></code>" navigations, or its
    scroll-reset/scroll-to-a-fragment logic for "<code id="the-navigateevent-interface:dom-navigationtype-push-4"><a href="#dom-navigationtype-push">push</a></code>"
    or "<code id="the-navigateevent-interface:dom-navigationtype-replace-3"><a href="#dom-navigationtype-replace">replace</a></code>" navigations, until any handlers'
    returned promises settle. The <code id="the-navigateevent-interface:dom-navigationinterceptoptions-scroll"><a href="#dom-navigationinterceptoptions-scroll">scroll</a></code>
    option can be set to "<code id="the-navigateevent-interface:dom-navigationscrollbehavior-manual"><a href="#dom-navigationscrollbehavior-manual">manual</a></code>" to turn
    off any browser-driven scroll behavior entirely for this navigation, or <code id="the-navigateevent-interface:dom-navigateevent-scroll-2"><a href="#dom-navigateevent-scroll">scroll()</a></code> can be called before the promise settles to
    trigger this behavior early.</p>

    <p>This method will throw a <a id="the-navigateevent-interface:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-navigateevent-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>
    if <code id="the-navigateevent-interface:dom-navigateevent-canintercept-2"><a href="#dom-navigateevent-canintercept">canIntercept</a></code> is false, or if <code id="the-navigateevent-interface:dom-event-istrusted"><a data-x-internal="dom-event-istrusted" href="https://dom.spec.whatwg.org/#dom-event-istrusted">isTrusted</a></code> is false. It will throw an
    <a id="the-navigateevent-interface:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-navigateevent-interface:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if not called
    synchronously, during event dispatch.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-navigateevent-scroll" id="dom-navigateevent-scroll-dev">scroll</a>()</code></dt><dd>
    <p>For "<code id="the-navigateevent-interface:dom-navigationtype-traverse-5"><a href="#dom-navigationtype-traverse">traverse</a></code>" or "<code id="the-navigateevent-interface:dom-navigationtype-reload-4"><a href="#dom-navigationtype-reload">reload</a></code>" navigations, restores the scroll position
    using the browser's usual scroll restoration logic.</p>

    <p>For "<code id="the-navigateevent-interface:dom-navigationtype-push-5"><a href="#dom-navigationtype-push">push</a></code>" or "<code id="the-navigateevent-interface:dom-navigationtype-replace-4"><a href="#dom-navigationtype-replace">replace</a></code>" navigations, either resets the scroll
    position to the top of the document or scrolls to the <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-navigateevent-interface:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> specified by <code id="the-navigateevent-interface:dom-navigationdestination-url"><a href="#dom-navigationdestination-url">destination.url</a></code> if there is one.</p>

    <p>If called more than once, or called after automatic post-transition scroll processing has
    happened due to the <code id="the-navigateevent-interface:dom-navigationinterceptoptions-scroll-2"><a href="#dom-navigationinterceptoptions-scroll">scroll</a></code> option
    being left as "<code id="the-navigateevent-interface:dom-navigationscrollbehavior-after-transition"><a href="#dom-navigationscrollbehavior-after-transition">after-transition</a></code>", or called
    before the navigation has committed, this method will throw an
    <a id="the-navigateevent-interface:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-navigateevent-interface:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </dd></dl>

  

  <p>Each <code id="the-navigateevent-interface:navigateevent-3"><a href="#navigateevent">NavigateEvent</a></code> has an <dfn id="concept-navigateevent-interception-state">interception state</dfn>, which is either "<code>none</code>", "<code>intercepted</code>", "<code>committed</code>",
  "<code>scrolled</code>", or "<code>finished</code>", initially "<code>none</code>".</p>

  <p>Each <code id="the-navigateevent-interface:navigateevent-4"><a href="#navigateevent">NavigateEvent</a></code> has a <dfn id="concept-navigateevent-navigation-precommit-handler-list">navigation precommit handler
  list</dfn>, a <a id="the-navigateevent-interface:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <code id="the-navigateevent-interface:navigationprecommithandler-2"><a href="#navigationprecommithandler">NavigationPrecommitHandler</a></code> callbacks, initially
  empty.</p>

  <p>Each <code id="the-navigateevent-interface:navigateevent-5"><a href="#navigateevent">NavigateEvent</a></code> has a <dfn id="concept-navigateevent-navigation-handler-list">navigation handler list</dfn>, a
  <a id="the-navigateevent-interface:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <code id="the-navigateevent-interface:navigationintercepthandler-2"><a href="#navigationintercepthandler">NavigationInterceptHandler</a></code> callbacks, initially empty.</p>

  <p>Each <code id="the-navigateevent-interface:navigateevent-6"><a href="#navigateevent">NavigateEvent</a></code> has a <dfn id="concept-navigateevent-focusreset">focus
  reset behavior</dfn>, a <code id="the-navigateevent-interface:navigationfocusreset-2"><a href="#navigationfocusreset">NavigationFocusReset</a></code>-or-null, initially null.</p>

  <p>Each <code id="the-navigateevent-interface:navigateevent-7"><a href="#navigateevent">NavigateEvent</a></code> has a <dfn id="concept-navigateevent-scroll">scroll
  behavior</dfn>, a <code id="the-navigateevent-interface:navigationscrollbehavior-2"><a href="#navigationscrollbehavior">NavigationScrollBehavior</a></code>-or-null, initially null.</p>

  <p>Each <code id="the-navigateevent-interface:navigateevent-8"><a href="#navigateevent">NavigateEvent</a></code> has an <dfn id="concept-navigateevent-abort-controller">abort controller</dfn>, an
  <code id="the-navigateevent-interface:abortcontroller"><a data-x-internal="abortcontroller" href="https://dom.spec.whatwg.org/#abortcontroller">AbortController</a></code>-or-null, initially null.</p>

  <p>Each <code id="the-navigateevent-interface:navigateevent-9"><a href="#navigateevent">NavigateEvent</a></code> has a <dfn id="concept-navigateevent-classic-history-api-state">classic history API state</dfn>, a
  <a href="#serialized-state" id="the-navigateevent-interface:serialized-state">serialized state</a> or null. It is only used in some cases where the event's <code id="the-navigateevent-interface:dom-navigateevent-navigationtype-2"><a href="#dom-navigateevent-navigationtype">navigationType</a></code> is "<code id="the-navigateevent-interface:dom-navigationtype-push-6"><a href="#dom-navigationtype-push">push</a></code>" or "<code id="the-navigateevent-interface:dom-navigationtype-replace-5"><a href="#dom-navigationtype-replace">replace</a></code>", and is set appropriately when the event is
  <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-navigateevent-interface:concept-event-fire" data-x-internal="concept-event-fire">fired</a>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-navigationtype" data-dfn-type="attribute"><code>navigationType</code></dfn>, <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-destination" data-dfn-type="attribute"><code>destination</code></dfn>, <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-canintercept" data-dfn-type="attribute"><code>canIntercept</code></dfn>, <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-userinitiated" data-dfn-type="attribute"><code>userInitiated</code></dfn>,
  <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-hashchange" data-dfn-type="attribute"><code>hashChange</code></dfn>, <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-signal" data-dfn-type="attribute"><code>signal</code></dfn>, <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-formdata" data-dfn-type="attribute"><code>formData</code></dfn>, <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-downloadrequest" data-dfn-type="attribute"><code>downloadRequest</code></dfn>, <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-info" data-dfn-type="attribute"><code>info</code></dfn>, <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-hasuavisualtransition" data-dfn-type="attribute"><code>hasUAVisualTransition</code></dfn>, and
  <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-sourceelement" data-dfn-type="attribute"><code>sourceElement</code></dfn> attributes
  must return the values they are initialized to.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-intercept" data-dfn-type="method"><code>intercept(<var>options</var>)</code></dfn> method steps
  are:</p>

  <ol><li><p><a href="#navigateevent-perform-shared-checks" id="the-navigateevent-interface:navigateevent-perform-shared-checks">Perform shared checks</a> given
   <a id="the-navigateevent-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>If <a id="the-navigateevent-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-navigateevent-interface:dom-navigateevent-canintercept-3"><a href="#dom-navigateevent-canintercept">canIntercept</a></code>
   attribute was initialized to false, then throw a <a id="the-navigateevent-interface:securityerror-3" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
   <code id="the-navigateevent-interface:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="the-navigateevent-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-navigateevent-interface:dispatch-flag" href="https://dom.spec.whatwg.org/#dispatch-flag" data-x-internal="dispatch-flag">dispatch flag</a> is unset, then throw an
   <a id="the-navigateevent-interface:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-navigateevent-interface:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p>If <var>options</var>["<code id="the-navigateevent-interface:dom-navigationinterceptoptions-precommithandler-4"><a href="#dom-navigationinterceptoptions-precommithandler">precommitHandler</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-navigateevent-interface:map-exists" data-x-internal="map-exists">exists</a>, then:</p>

    <ol><li><p> If <a id="the-navigateevent-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <code id="the-navigateevent-interface:dom-event-cancelable-2"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute
     is initialized to false, then throw an <a id="the-navigateevent-interface:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
     <code id="the-navigateevent-interface:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="the-navigateevent-interface:list-append" data-x-internal="list-append">Append</a> <var>options</var>["<code id="the-navigateevent-interface:dom-navigationinterceptoptions-precommithandler-5"><a href="#dom-navigationinterceptoptions-precommithandler">precommitHandler</a></code>"] to
     <a id="the-navigateevent-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigateevent-navigation-precommit-handler-list" id="the-navigateevent-interface:concept-navigateevent-navigation-precommit-handler-list">navigation precommit handler
     list</a>.</p></li></ol>
   </li><li><p><a id="the-navigateevent-interface:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <a id="the-navigateevent-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigateevent-interception-state" id="the-navigateevent-interface:concept-navigateevent-interception-state">interception state</a> is either "<code>none</code>" or "<code>intercepted</code>".</p></li><li><p>Set <a id="the-navigateevent-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigateevent-interception-state" id="the-navigateevent-interface:concept-navigateevent-interception-state-2">interception state</a> to "<code>intercepted</code>".</p></li><li><p>If <var>options</var>["<code id="the-navigateevent-interface:dom-navigationinterceptoptions-handler-2"><a href="#dom-navigationinterceptoptions-handler">handler</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-navigateevent-interface:map-exists-2" data-x-internal="map-exists">exists</a>, then <a href="https://infra.spec.whatwg.org/#list-append" id="the-navigateevent-interface:list-append-2" data-x-internal="list-append">append</a> it to <a id="the-navigateevent-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a href="#concept-navigateevent-navigation-handler-list" id="the-navigateevent-interface:concept-navigateevent-navigation-handler-list">navigation handler
   list</a>.</p></li><li>
    <p>If <var>options</var>["<code id="the-navigateevent-interface:dom-navigationinterceptoptions-focusreset-2"><a href="#dom-navigationinterceptoptions-focusreset">focusReset</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-navigateevent-interface:map-exists-3" data-x-internal="map-exists">exists</a>, then:</p>

    <ol><li><p>If <a id="the-navigateevent-interface:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigateevent-focusreset" id="the-navigateevent-interface:concept-navigateevent-focusreset">focus reset
     behavior</a> is not null, and it is not equal to <var>options</var>["<code id="the-navigateevent-interface:dom-navigationinterceptoptions-focusreset-3"><a href="#dom-navigationinterceptoptions-focusreset">focusReset</a></code>"], then the user agent may
     <a id="the-navigateevent-interface:report-a-warning-to-the-console" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the <code id="the-navigateevent-interface:dom-navigationinterceptoptions-focusreset-4"><a href="#dom-navigationinterceptoptions-focusreset">focusReset</a></code> option for a previous call
     to <code id="the-navigateevent-interface:dom-navigateevent-intercept-3"><a href="#dom-navigateevent-intercept">intercept()</a></code> was overridden by this new
     value, and the previous value will be ignored.</p></li><li><p>Set <a id="the-navigateevent-interface:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigateevent-focusreset" id="the-navigateevent-interface:concept-navigateevent-focusreset-2">focus reset
     behavior</a> to <var>options</var>["<code id="the-navigateevent-interface:dom-navigationinterceptoptions-focusreset-5"><a href="#dom-navigationinterceptoptions-focusreset">focusReset</a></code>"].</p></li></ol>
   </li><li>
    <p>If <var>options</var>["<code id="the-navigateevent-interface:dom-navigationinterceptoptions-scroll-3"><a href="#dom-navigationinterceptoptions-scroll">scroll</a></code>"]
    <a href="https://infra.spec.whatwg.org/#map-exists" id="the-navigateevent-interface:map-exists-4" data-x-internal="map-exists">exists</a>, then:</p>

    <ol><li><p>If <a id="the-navigateevent-interface:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigateevent-scroll" id="the-navigateevent-interface:concept-navigateevent-scroll">scroll
     behavior</a> is not null, and it is not equal to <var>options</var>["<code id="the-navigateevent-interface:dom-navigationinterceptoptions-scroll-4"><a href="#dom-navigationinterceptoptions-scroll">scroll</a></code>"], then the user agent may
     <a id="the-navigateevent-interface:report-a-warning-to-the-console-2" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the <code id="the-navigateevent-interface:dom-navigationinterceptoptions-scroll-5"><a href="#dom-navigationinterceptoptions-scroll">scroll</a></code> option for a previous call to
     <code id="the-navigateevent-interface:dom-navigateevent-intercept-4"><a href="#dom-navigateevent-intercept">intercept()</a></code> was overridden by this new value,
     and the previous value will be ignored.</p></li><li><p>Set <a id="the-navigateevent-interface:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigateevent-scroll" id="the-navigateevent-interface:concept-navigateevent-scroll-2">scroll
     behavior</a> to <var>options</var>["<code id="the-navigateevent-interface:dom-navigationinterceptoptions-scroll-6"><a href="#dom-navigationinterceptoptions-scroll">scroll</a></code>"].</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigateEvent" id="dom-navigateevent-scroll" data-dfn-type="method"><code>scroll()</code></dfn> method steps are:</p>

  <ol><li><p><a href="#navigateevent-perform-shared-checks" id="the-navigateevent-interface:navigateevent-perform-shared-checks-2">Perform shared checks</a> given
   <a id="the-navigateevent-interface:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>If <a id="the-navigateevent-interface:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigateevent-interception-state" id="the-navigateevent-interface:concept-navigateevent-interception-state-3">interception state</a> is not "<code>committed</code>", then throw an <a id="the-navigateevent-interface:invalidstateerror-5" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="the-navigateevent-interface:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#process-scroll-behavior" id="the-navigateevent-interface:process-scroll-behavior">Process scroll behavior</a> given <a id="the-navigateevent-interface:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="navigateevent-perform-shared-checks">perform shared checks</dfn> for a
  <code id="the-navigateevent-interface:navigateevent-10"><a href="#navigateevent">NavigateEvent</a></code> <var>event</var>:</p>

  <ol><li><p>If <var>event</var>'s <a href="#concept-relevant-global" id="the-navigateevent-interface:concept-relevant-global">relevant global object</a>'s <a href="#concept-document-window" id="the-navigateevent-interface:concept-document-window">associated <code>Document</code></a> is not <a href="#fully-active" id="the-navigateevent-interface:fully-active">fully
   active</a>, then throw an <a id="the-navigateevent-interface:invalidstateerror-6" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="the-navigateevent-interface:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>event</var>'s <code id="the-navigateevent-interface:dom-event-istrusted-2"><a data-x-internal="dom-event-istrusted" href="https://dom.spec.whatwg.org/#dom-event-istrusted">isTrusted</a></code> attribute was
   initialized to false, then throw a <a id="the-navigateevent-interface:securityerror-4" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
   <code id="the-navigateevent-interface:domexception-10"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>event</var>'s <a id="the-navigateevent-interface:canceled-flag" href="https://dom.spec.whatwg.org/#canceled-flag" data-x-internal="canceled-flag">canceled flag</a> is set, then throw an
   <a id="the-navigateevent-interface:invalidstateerror-7" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-navigateevent-interface:domexception-11"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
  </div>


  

  <h6 id="the-navigationprecommitcontroller-interface"><span class="secno">7.2.6.10.2</span> The <code id="the-navigationprecommitcontroller-interface:navigationprecommitcontroller"><a href="#navigationprecommitcontroller">NavigationPrecommitController</a></code> interface<a href="#the-navigationprecommitcontroller-interface" class="self-link"></a></h6>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
  <c- b="">interface</c-> <dfn id="navigationprecommitcontroller" data-dfn-type="interface"><c- g="">NavigationPrecommitController</c-></dfn> {
    <c- b="">undefined</c-> <a href="#dom-navigationprecommitcontroller-redirect" id="the-navigationprecommitcontroller-interface:dom-navigationprecommitcontroller-redirect"><c- g="">redirect</c-></a>(<c- b="">USVString</c-> <c- g="">url</c->, <c- b="">optional</c-> <a href="#navigationnavigateoptions" id="the-navigationprecommitcontroller-interface:navigationnavigateoptions"><c- n="">NavigationNavigateOptions</c-></a> <c- g="">options</c-> = {});
  };

  <c- b="">callback</c-> <dfn id="navigationprecommithandler" data-dfn-type="callback"><c- g="">NavigationPrecommitHandler</c-></dfn> = <a href="https://webidl.spec.whatwg.org/#idl-promise" id="the-navigationprecommitcontroller-interface:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<c- b="">undefined</c->&gt; (<a href="#navigationprecommitcontroller" id="the-navigationprecommitcontroller-interface:navigationprecommitcontroller-2"><c- n="">NavigationPrecommitController</c-></a> <c- g="">controller</c->);</code></pre>

  <dl class="domintro"><dt><code><var>precommitController</var>.<a href="#dom-navigationprecommitcontroller-redirect" id="dom-navigationprecommitcontroller-redirect-dev">redirect</a>(USVString <var>url</var>, <a href="#navigationnavigateoptions" id="the-navigationprecommitcontroller-interface:navigationnavigateoptions-2">NavigationNavigateOptions</a> <var>options</var>)</code></dt><dd>
    <p>For "<code id="the-navigationprecommitcontroller-interface:dom-navigationtype-push"><a href="#dom-navigationtype-push">push</a></code>" or "<code id="the-navigationprecommitcontroller-interface:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>" navigations, sets the <code id="the-navigationprecommitcontroller-interface:dom-navigationdestination-url"><a href="#dom-navigationdestination-url">destination.url</a></code> to <var>url</var>.</p>

    <p>If <var>options</var> is given, also sets the <code id="the-navigationprecommitcontroller-interface:dom-navigateevent-info"><a href="#dom-navigateevent-info">info</a></code> and the resulting
    <code id="the-navigationprecommitcontroller-interface:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>'s <a href="#concept-navigationdestination-state" id="the-navigationprecommitcontroller-interface:concept-navigationdestination-state">state</a> to <var>options</var>'s <code id="the-navigationprecommitcontroller-interface:dom-navigationoptions-info"><a href="#dom-navigationoptions-info">info</a></code> and <code id="the-navigationprecommitcontroller-interface:dom-navigationnavigateoptions-state"><a href="#dom-navigationnavigateoptions-state">state</a></code>, if they are present. The <code id="the-navigationprecommitcontroller-interface:dom-navigationnavigateoptions-history"><a href="#dom-navigationnavigateoptions-history">history</a></code> option can also switch between
    "<code id="the-navigationprecommitcontroller-interface:dom-navigationtype-push-2"><a href="#dom-navigationtype-push">push</a></code>" or "<code id="the-navigationprecommitcontroller-interface:dom-navigationtype-replace-2"><a href="#dom-navigationtype-replace">replace</a></code>" navigations types.</p>

    <p>For "<code id="the-navigationprecommitcontroller-interface:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>" or "<code id="the-navigationprecommitcontroller-interface:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigations, an
    <a id="the-navigationprecommitcontroller-interface:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> will be thrown.</p>

    <p>If the current <code id="the-navigationprecommitcontroller-interface:document"><a href="#document">Document</a></code> <a href="#can-have-its-url-rewritten" id="the-navigationprecommitcontroller-interface:can-have-its-url-rewritten">cannot have
    its URL rewritten</a> to <var>url</var>, a <a id="the-navigationprecommitcontroller-interface:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
    <code id="the-navigationprecommitcontroller-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> will be thrown.</p>
  </dd></dl>

  

  <p>Each <code id="the-navigationprecommitcontroller-interface:navigationprecommitcontroller-3"><a href="#navigationprecommitcontroller">NavigationPrecommitController</a></code> has a <code id="the-navigationprecommitcontroller-interface:navigateevent"><a href="#navigateevent">NavigateEvent</a></code> <dfn id="concept-navigationprecommitcontroller-event">event</dfn>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationPrecommitController" id="dom-navigationprecommitcontroller-redirect" data-dfn-type="method"><code>redirect(<var>url</var>,
  <var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p><a id="the-navigationprecommitcontroller-interface:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <a id="the-navigationprecommitcontroller-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationprecommitcontroller-event" id="the-navigationprecommitcontroller-interface:concept-navigationprecommitcontroller-event">event</a>'s <a href="#concept-navigateevent-interception-state" id="the-navigationprecommitcontroller-interface:concept-navigateevent-interception-state">interception state</a> is not "<code>none</code>".</p></li><li><p><a href="#navigateevent-perform-shared-checks" id="the-navigationprecommitcontroller-interface:navigateevent-perform-shared-checks">Perform shared checks</a> given
   <a id="the-navigationprecommitcontroller-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationprecommitcontroller-event" id="the-navigationprecommitcontroller-interface:concept-navigationprecommitcontroller-event-2">event</a>.</p></li><li><p>If <a id="the-navigationprecommitcontroller-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationprecommitcontroller-event" id="the-navigationprecommitcontroller-interface:concept-navigationprecommitcontroller-event-3">event</a>'s <a href="#concept-navigateevent-interception-state" id="the-navigationprecommitcontroller-interface:concept-navigateevent-interception-state-2">interception state</a> is not "<code>intercepted</code>", then throw an <a id="the-navigationprecommitcontroller-interface:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="the-navigationprecommitcontroller-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="the-navigationprecommitcontroller-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationprecommitcontroller-event" id="the-navigationprecommitcontroller-interface:concept-navigationprecommitcontroller-event-4">event</a>'s <code id="the-navigationprecommitcontroller-interface:dom-navigateevent-navigationtype"><a href="#dom-navigateevent-navigationtype">navigationType</a></code> is neither "<code id="the-navigationprecommitcontroller-interface:dom-navigationtype-push-3"><a href="#dom-navigationtype-push">push</a></code>" nor "<code id="the-navigationprecommitcontroller-interface:dom-navigationtype-replace-3"><a href="#dom-navigationtype-replace">replace</a></code>", then throw an
   <a id="the-navigationprecommitcontroller-interface:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-navigationprecommitcontroller-interface:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>document</var> be <a id="the-navigationprecommitcontroller-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-navigationprecommitcontroller-interface:concept-relevant-global">relevant global object</a>'s <a href="#concept-document-window" id="the-navigationprecommitcontroller-interface:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>Let <var>destinationURL</var> be the result of <a href="#parse-a-url" id="the-navigationprecommitcontroller-interface:parse-a-url">parsing</a>
   <var>url</var> given <var>document</var>.</p></li><li><p>If <var>destinationURL</var> is failure, then throw a
   <a id="the-navigationprecommitcontroller-interface:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="the-navigationprecommitcontroller-interface:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>document</var> <a href="#can-have-its-url-rewritten" id="the-navigationprecommitcontroller-interface:can-have-its-url-rewritten-2">cannot have its URL
   rewritten</a> to <var>destinationURL</var>, then throw a
   <a id="the-navigationprecommitcontroller-interface:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-navigationprecommitcontroller-interface:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>options</var>["<code id="the-navigationprecommitcontroller-interface:dom-navigationnavigateoptions-history-2"><a href="#dom-navigationnavigateoptions-history">history</a></code>"] is "<code id="the-navigationprecommitcontroller-interface:navigationhistorybehavior-push"><a href="#navigationhistorybehavior-push">push</a></code>" or "<code id="the-navigationprecommitcontroller-interface:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>", then set <a id="the-navigationprecommitcontroller-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationprecommitcontroller-event" id="the-navigationprecommitcontroller-interface:concept-navigationprecommitcontroller-event-5">event</a>'s <code id="the-navigationprecommitcontroller-interface:dom-navigateevent-navigationtype-2"><a href="#dom-navigateevent-navigationtype">navigationType</a></code> to <var>options</var>["<code id="the-navigationprecommitcontroller-interface:dom-navigationnavigateoptions-history-3"><a href="#dom-navigationnavigateoptions-history">history</a></code>"].</p></li><li>
    <p>If <var>options</var>["<code id="the-navigationprecommitcontroller-interface:dom-navigationnavigateoptions-state-2"><a href="#dom-navigationnavigateoptions-state">state</a></code>"]
    <a href="https://infra.spec.whatwg.org/#map-exists" id="the-navigationprecommitcontroller-interface:map-exists" data-x-internal="map-exists">exists</a>, then:</p>

    <ol><li><p>Let <var>serializedState</var> be the result of calling
     <a href="#structuredserializeforstorage" id="the-navigationprecommitcontroller-interface:structuredserializeforstorage">StructuredSerializeForStorage</a>(<var>options</var>["<code id="the-navigationprecommitcontroller-interface:dom-navigationreloadoptions-state"><a href="#dom-navigationreloadoptions-state">state</a></code>"]). This may throw an
     exception.</p></li><li><p>Set <a id="the-navigationprecommitcontroller-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationprecommitcontroller-event" id="the-navigationprecommitcontroller-interface:concept-navigationprecommitcontroller-event-6">event</a>'s <code id="the-navigationprecommitcontroller-interface:dom-navigateevent-destination"><a href="#dom-navigateevent-destination">destination</a></code>'s <a href="#concept-navigationdestination-state" id="the-navigationprecommitcontroller-interface:concept-navigationdestination-state-2">state</a> to
     <var>serializedState</var>.</p></li><li><p>Set <a id="the-navigationprecommitcontroller-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationprecommitcontroller-event" id="the-navigationprecommitcontroller-interface:concept-navigationprecommitcontroller-event-7">event</a>'s  <a href="https://dom.spec.whatwg.org/#concept-event-target" id="the-navigationprecommitcontroller-interface:concept-event-target" data-x-internal="concept-event-target">target</a>'s <a href="#ongoing-api-method-tracker" id="the-navigationprecommitcontroller-interface:ongoing-api-method-tracker">ongoing API method tracker</a>'s <a href="#navigation-api-method-tracker-state" id="the-navigationprecommitcontroller-interface:navigation-api-method-tracker-state">serialized state</a> to
     <var>serializedState</var>.</p></li></ol>
   </li><li><p>Set <a id="the-navigationprecommitcontroller-interface:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationprecommitcontroller-event" id="the-navigationprecommitcontroller-interface:concept-navigationprecommitcontroller-event-8">event</a>'s <code id="the-navigationprecommitcontroller-interface:dom-navigateevent-destination-2"><a href="#dom-navigateevent-destination">destination</a></code>'s <a href="#concept-navigationdestination-url" id="the-navigationprecommitcontroller-interface:concept-navigationdestination-url">URL</a> to <var>destinationURL</var>.</p></li><li><p>If <var>options</var>["<code id="the-navigationprecommitcontroller-interface:dom-navigationoptions-info-2"><a href="#dom-navigationoptions-info">info</a></code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="the-navigationprecommitcontroller-interface:map-exists-2" data-x-internal="map-exists">exists</a>, then set <a id="the-navigationprecommitcontroller-interface:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s  <a href="#concept-navigationprecommitcontroller-event" id="the-navigationprecommitcontroller-interface:concept-navigationprecommitcontroller-event-9">event</a>'s <code id="the-navigationprecommitcontroller-interface:dom-navigateevent-info-2"><a href="#dom-navigateevent-info">info</a></code> to <var>options</var>["<code id="the-navigationprecommitcontroller-interface:dom-navigationoptions-info-3"><a href="#dom-navigationoptions-info">info</a></code>"].</p></li></ol>
  </div>


  

  <h6 id="the-navigationdestination-interface"><span class="secno">7.2.6.10.3</span> The <code id="the-navigationdestination-interface:navigationdestination"><a href="#navigationdestination">NavigationDestination</a></code> interface<a href="#the-navigationdestination-interface" class="self-link"></a></h6>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="navigationdestination" data-dfn-type="interface"><c- g="">NavigationDestination</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-navigationdestination-url" id="the-navigationdestination-interface:dom-navigationdestination-url"><c- g="">url</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigationdestination-key" id="the-navigationdestination-interface:dom-navigationdestination-key"><c- g="">key</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigationdestination-id" id="the-navigationdestination-interface:dom-navigationdestination-id"><c- g="">id</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">long</c-> <c- b="">long</c-> <a href="#dom-navigationdestination-index" id="the-navigationdestination-interface:dom-navigationdestination-index"><c- g="">index</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigationdestination-samedocument" id="the-navigationdestination-interface:dom-navigationdestination-samedocument"><c- g="">sameDocument</c-></a>;

  <c- b="">any</c-> <a href="#dom-navigationdestination-getstate" id="the-navigationdestination-interface:dom-navigationdestination-getstate"><c- g="">getState</c-></a>();
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-navigateevent-destination" id="the-navigationdestination-interface:dom-navigateevent-destination">destination</a>.<a href="#dom-navigationdestination-url" id="the-navigationdestination-interface:dom-navigationdestination-url-2">url</a></code></dt><dd><p>The URL being navigated to.</p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-destination" id="the-navigationdestination-interface:dom-navigateevent-destination-2">destination</a>.<a href="#dom-navigationdestination-key" id="the-navigationdestination-interface:dom-navigationdestination-key-2">key</a></code></dt><dd><p>The value of the <code id="the-navigationdestination-interface:dom-navigationhistoryentry-key"><a href="#dom-navigationhistoryentry-key">key</a></code> property of the
   destination <code id="the-navigationdestination-interface:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>, if this is a "<code id="the-navigationdestination-interface:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigation, or the empty string otherwise. </p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-destination" id="the-navigationdestination-interface:dom-navigateevent-destination-3">destination</a>.<a href="#dom-navigationdestination-id" id="the-navigationdestination-interface:dom-navigationdestination-id-2">id</a></code></dt><dd><p>The value of the <code id="the-navigationdestination-interface:dom-navigationhistoryentry-id"><a href="#dom-navigationhistoryentry-id">id</a></code> property of the
   destination <code id="the-navigationdestination-interface:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>, if this is a "<code id="the-navigationdestination-interface:dom-navigationtype-traverse-2"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigation, or the empty string otherwise. </p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-destination" id="the-navigationdestination-interface:dom-navigateevent-destination-4">destination</a>.<a href="#dom-navigationdestination-index" id="the-navigationdestination-interface:dom-navigationdestination-index-2">index</a></code></dt><dd><p>The value of the <code id="the-navigationdestination-interface:dom-navigationhistoryentry-index"><a href="#dom-navigationhistoryentry-index">index</a></code> property of
   the destination <code id="the-navigationdestination-interface:navigationhistoryentry-3"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>, if this is a "<code id="the-navigationdestination-interface:dom-navigationtype-traverse-3"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigation, or −1 otherwise.
   </p></dd><dt><code><var>event</var>.<a href="#dom-navigateevent-destination" id="the-navigationdestination-interface:dom-navigateevent-destination-5">destination</a>.<a href="#dom-navigationdestination-samedocument" id="the-navigationdestination-interface:dom-navigationdestination-samedocument-2">sameDocument</a></code></dt><dd>
    <p>Indicates whether or not this navigation is to the same <code id="the-navigationdestination-interface:document"><a href="#document">Document</a></code> as the current
    one, or not. This will be true, for example, in the case of fragment navigations or <code id="the-navigationdestination-interface:dom-history-pushstate"><a href="#dom-history-pushstate">history.pushState()</a></code> navigations.</p>

    <p>Note that this property indicates the original nature of the navigation. If a cross-document
    navigation is converted into a same-document navigation using <code id="the-navigationdestination-interface:dom-navigateevent-intercept"><a href="#dom-navigateevent-intercept">navigateEvent.intercept()</a></code>, that will not change the
    value of this property.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-navigateevent-destination" id="the-navigationdestination-interface:dom-navigateevent-destination-6">destination</a>.<a href="#dom-navigationdestination-getstate" id="the-navigationdestination-interface:dom-navigationdestination-getstate-2">getState</a>()</code></dt><dd>
    <p>For "<code id="the-navigationdestination-interface:dom-navigationtype-traverse-4"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigations, returns the
    <a href="#structureddeserialize" id="the-navigationdestination-interface:structureddeserialize">deserialization</a> of the state stored in the
    destination <a href="#session-history-entry" id="the-navigationdestination-interface:session-history-entry">session history entry</a>.</p>

    <p>For "<code id="the-navigationdestination-interface:dom-navigationtype-push"><a href="#dom-navigationtype-push">push</a></code>" or "<code id="the-navigationdestination-interface:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>" navigations, returns the <a href="#structureddeserialize" id="the-navigationdestination-interface:structureddeserialize-2">deserialization</a> of the state passed to <code id="the-navigationdestination-interface:dom-navigation-navigate"><a href="#dom-navigation-navigate">navigation.navigate()</a></code>, if the navigation was initiated
    by that method, or undefined it if it wasn't.</p>

    <p>For "<code id="the-navigationdestination-interface:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>" navigations, returns the <a href="#structureddeserialize" id="the-navigationdestination-interface:structureddeserialize-3">deserialization</a> of the state passed to <code id="the-navigationdestination-interface:dom-navigation-reload"><a href="#dom-navigation-reload">navigation.reload()</a></code>, if the reload was initiated by that
    method, or undefined it if it wasn't.</p>
   </dd></dl>

  

  <p>Each <code id="the-navigationdestination-interface:navigationdestination-2"><a href="#navigationdestination">NavigationDestination</a></code> has a <dfn id="concept-navigationdestination-url">URL</dfn>, which is a <a id="the-navigationdestination-interface:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p>

  <p>Each <code id="the-navigationdestination-interface:navigationdestination-3"><a href="#navigationdestination">NavigationDestination</a></code> has an <dfn id="concept-navigationdestination-entry">entry</dfn>, which is a
  <code id="the-navigationdestination-interface:navigationhistoryentry-4"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> or null.</p>

  <p class="note">It will be non-null if and only if the <code id="the-navigationdestination-interface:navigationdestination-4"><a href="#navigationdestination">NavigationDestination</a></code>
  corresponds to a "<code id="the-navigationdestination-interface:dom-navigationtype-traverse-5"><a href="#dom-navigationtype-traverse">traverse</a></code>" navigation.</p>

  <p>Each <code id="the-navigationdestination-interface:navigationdestination-5"><a href="#navigationdestination">NavigationDestination</a></code> has a <dfn id="concept-navigationdestination-state">state</dfn>, which is a <a href="#serialized-state" id="the-navigationdestination-interface:serialized-state">serialized
  state</a>.</p>

  <p>Each <code id="the-navigationdestination-interface:navigationdestination-6"><a href="#navigationdestination">NavigationDestination</a></code> has an <dfn id="concept-navigationdestination-samedocument">is same document</dfn>, which is a
  boolean.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationDestination" id="dom-navigationdestination-url" data-dfn-type="attribute"><code>url</code></dfn> getter steps are to return
  <a id="the-navigationdestination-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationdestination-url" id="the-navigationdestination-interface:concept-navigationdestination-url">URL</a>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-navigationdestination-interface:concept-url-serializer" data-x-internal="concept-url-serializer">serialized</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationDestination" id="dom-navigationdestination-key" data-dfn-type="attribute"><code>key</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-navigationdestination-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationdestination-entry" id="the-navigationdestination-interface:concept-navigationdestination-entry">entry</a> is
   null, then return the empty string.</p></li><li><p>Return <a id="the-navigationdestination-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationdestination-entry" id="the-navigationdestination-interface:concept-navigationdestination-entry-2">entry</a>'s <a href="#concept-navigationhistoryentry-key" id="the-navigationdestination-interface:concept-navigationhistoryentry-key">key</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationDestination" id="dom-navigationdestination-id" data-dfn-type="attribute"><code>id</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-navigationdestination-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationdestination-entry" id="the-navigationdestination-interface:concept-navigationdestination-entry-3">entry</a> is
   null, then return the empty string.</p></li><li><p>Return <a id="the-navigationdestination-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationdestination-entry" id="the-navigationdestination-interface:concept-navigationdestination-entry-4">entry</a>'s <a href="#concept-navigationhistoryentry-id" id="the-navigationdestination-interface:concept-navigationhistoryentry-id">ID</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationDestination" id="dom-navigationdestination-index" data-dfn-type="attribute"><code>index</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-navigationdestination-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationdestination-entry" id="the-navigationdestination-interface:concept-navigationdestination-entry-5">entry</a> is
   null, then return −1.</p></li><li><p>Return <a id="the-navigationdestination-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationdestination-entry" id="the-navigationdestination-interface:concept-navigationdestination-entry-6">entry</a>'s <a href="#concept-navigationhistoryentry-index" id="the-navigationdestination-interface:concept-navigationhistoryentry-index">index</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationDestination" id="dom-navigationdestination-samedocument" data-dfn-type="attribute"><code>sameDocument</code></dfn> getter steps are to
  return <a id="the-navigationdestination-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationdestination-samedocument" id="the-navigationdestination-interface:concept-navigationdestination-samedocument">is same
  document</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationDestination" id="dom-navigationdestination-getstate" data-dfn-type="method"><code>getState()</code></dfn> method steps are to return
  <a href="#structureddeserialize" id="the-navigationdestination-interface:structureddeserialize-4">StructuredDeserialize</a>(<a id="the-navigationdestination-interface:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-navigationdestination-state" id="the-navigationdestination-interface:concept-navigationdestination-state">state</a>).</p>
  </div>


  <h6 id="navigate-event-firing"><span class="secno">7.2.6.10.4</span> Firing the event<a href="#navigate-event-firing" class="self-link"></a></h6>

  <p>Other parts of the standard fire the <code id="navigate-event-firing:event-navigate"><a href="#event-navigate">navigate</a></code> event,
  through a series of wrapper algorithms given in this section.</p>

  <div data-algorithm="">
  <p>To <dfn id="fire-a-traverse-navigate-event">fire a traverse <code>navigate</code> event</dfn> at a
  <code id="navigate-event-firing:navigation"><a href="#navigation">Navigation</a></code> <var>navigation</var> given a <a href="#session-history-entry" id="navigate-event-firing:session-history-entry">session history entry</a> <dfn id="fire-navigate-traverse-destinationshe"><var>destinationSHE</var></dfn> and an optional
  <a href="#user-navigation-involvement" id="navigate-event-firing:user-navigation-involvement">user navigation involvement</a> <dfn id="fire-navigate-traverse-userinvolvement"><var>userInvolvement</var></dfn> (default "<code id="navigate-event-firing:uni-none"><a href="#uni-none">none</a></code>"):</p>

  <ol><li><p>Let <var>event</var> be the result of <a id="navigate-event-firing:creating-an-event" href="https://dom.spec.whatwg.org/#concept-event-create" data-x-internal="creating-an-event">creating an event</a> given
   <code id="navigate-event-firing:navigateevent"><a href="#navigateevent">NavigateEvent</a></code>, in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm">relevant realm</a>.</p></li><li><p>Set <var>event</var>'s <a href="#concept-navigateevent-classic-history-api-state" id="navigate-event-firing:concept-navigateevent-classic-history-api-state">classic history API state</a> to
   null.</p></li><li><p>Let <var>destination</var> be a <a id="navigate-event-firing:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigate-event-firing:navigationdestination"><a href="#navigationdestination">NavigationDestination</a></code>
   created in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-2">relevant
   realm</a>.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-url" id="navigate-event-firing:concept-navigationdestination-url">URL</a>
   to <var>destinationSHE</var>'s <a href="#she-url" id="navigate-event-firing:she-url">URL</a>.</p></li><li><p>Let <var>destinationNHE</var> be the <code id="navigate-event-firing:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> in
   <var>navigation</var>'s <a href="#navigation-entry-list" id="navigate-event-firing:navigation-entry-list">entry list</a> whose <a href="#nhe-she" id="navigate-event-firing:nhe-she">session history entry</a> is <var>destinationSHE</var>, or null if no such
   <code id="navigate-event-firing:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> exists.</p></li><li>
    <p>If <var>destinationNHE</var> is non-null, then:</p>

    <ol><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-entry" id="navigate-event-firing:concept-navigationdestination-entry">entry</a> to
     <var>destinationNHE</var>.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-state" id="navigate-event-firing:concept-navigationdestination-state">state</a> to <var>destinationSHE</var>'s <a href="#she-navigation-api-state" id="navigate-event-firing:she-navigation-api-state">navigation API state</a>.</p></li></ol>
   </li><li>
    <p>Otherwise,</p>

    <ol><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-entry" id="navigate-event-firing:concept-navigationdestination-entry-2">entry</a> to null.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-state" id="navigate-event-firing:concept-navigationdestination-state-2">state</a> to
     <a href="#structuredserializeforstorage" id="navigate-event-firing:structuredserializeforstorage">StructuredSerializeForStorage</a>(null).</p></li></ol>
   </li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-samedocument" id="navigate-event-firing:concept-navigationdestination-samedocument">is
   same document</a> to true if <var>destinationSHE</var>'s <a href="#she-document" id="navigate-event-firing:she-document">document</a> is equal to <var>navigation</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global">relevant global
   object</a>'s <a href="#concept-document-window" id="navigate-event-firing:concept-document-window">associated <code>Document</code></a>;
   otherwise false.</p></li><li><p>Return the result of performing the <a href="#inner-navigate-event-firing-algorithm" id="navigate-event-firing:inner-navigate-event-firing-algorithm">inner <code>navigate</code> event firing algorithm</a> given
   <var>navigation</var>, "<code id="navigate-event-firing:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>",
   <var>event</var>, <var>destination</var>, <var>userInvolvement</var>, null, null, and
   null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fire-a-push/replace/reload-navigate-event">fire a push/replace/reload <code>navigate</code> event</dfn> at
  a <code id="navigate-event-firing:navigation-2"><a href="#navigation">Navigation</a></code> <var>navigation</var> given a <code id="navigate-event-firing:navigationtype"><a href="#navigationtype">NavigationType</a></code> <dfn id="fire-navigate-prr-navigationtype"><var>navigationType</var></dfn>, a <a id="navigate-event-firing:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <dfn id="fire-navigate-prr-destinationurl"><var>destinationURL</var></dfn>, a boolean <dfn id="fire-navigate-prr-issamedocument"><var>isSameDocument</var></dfn>, an optional <a href="#user-navigation-involvement" id="navigate-event-firing:user-navigation-involvement-2">user
  navigation involvement</a> <dfn id="fire-navigate-prr-userinvolvement"><var>userInvolvement</var></dfn> (default "<code id="navigate-event-firing:uni-none-2"><a href="#uni-none">none</a></code>"), an optional <code id="navigate-event-firing:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>-or-null <dfn id="fire-navigate-prr-sourceelement"><var>sourceElement</var></dfn> (default null), an
  optional <a href="#entry-list" id="navigate-event-firing:entry-list">entry list</a>-or-null <dfn id="fire-navigate-prr-formdataentrylist"><var>formDataEntryList</var></dfn> (default null), an
  optional <a href="#serialized-state" id="navigate-event-firing:serialized-state">serialized state</a> <dfn id="fire-navigate-prr-navigationapistate"><var>navigationAPIState</var></dfn> (default
  <a href="#structuredserializeforstorage" id="navigate-event-firing:structuredserializeforstorage-2">StructuredSerializeForStorage</a>(null)), an optional <a href="#serialized-state" id="navigate-event-firing:serialized-state-2">serialized
  state</a>-or-null <dfn id="fire-navigate-prr-classichistoryapistate"><var>classicHistoryAPIState</var></dfn> (default
  null), and an optional <a href="#navigation-api-method-tracker" id="navigate-event-firing:navigation-api-method-tracker">navigation API method tracker</a>-or-null <dfn id="fire-navigate-prr-api-method-tracker"><var>apiMethodTracker</var></dfn>:</p>

  <ol><li><p>Let <var>document</var> be <var>navigation</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-2">relevant global object</a>'s <a href="#concept-document-window" id="navigate-event-firing:concept-document-window-2">associated <code>Document</code></a>.</p></li><li><p><a href="#inform-the-navigation-api-about-aborting-navigation" id="navigate-event-firing:inform-the-navigation-api-about-aborting-navigation">Inform the navigation API about aborting navigation</a> in
   <var>document</var>'s <a href="#node-navigable" id="navigate-event-firing:node-navigable">node navigable</a>.</p></li><li>
    <p>If <var>navigation</var> <a href="#has-entries-and-events-disabled" id="navigate-event-firing:has-entries-and-events-disabled">has entries and events disabled</a>, and
    <var>apiMethodTracker</var> is not null:</p>

    <ol><li><p>Set <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-pending" id="navigate-event-firing:navigation-api-method-tracker-pending">pending</a> to false.</p></li><li><p>Set <var>apiMethodTracker</var> to null.</p></li></ol>

    <p class="note">If <var>navigation</var> <a href="#has-entries-and-events-disabled" id="navigate-event-firing:has-entries-and-events-disabled-2">has entries and events disabled</a>, then
    <code id="navigate-event-firing:dom-navigation-navigate"><a href="#dom-navigation-navigate">navigate()</a></code> and <code id="navigate-event-firing:dom-navigation-reload"><a href="#dom-navigation-reload">reload()</a></code> calls return promises that will never fulfill. We
    never create a <code id="navigate-event-firing:navigationhistoryentry-3"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> object for such <code id="navigate-event-firing:document"><a href="#document">Document</a></code>s, there
    is no <code id="navigate-event-firing:navigationhistoryentry-4"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> to apply <var>serializedState</var> to, and there is
    no <code id="navigate-event-firing:event-navigate-2"><a href="#event-navigate">navigate</a></code> event to include <var>info</var> with. So, we
    don't need to track this API method call after all. We need to check this after aborting
    previous navigations, in case the <code id="navigate-event-firing:document-2"><a href="#document">Document</a></code> has became non-<a href="#fully-active" id="navigate-event-firing:fully-active">fully active</a>
    as a result of a <code id="navigate-event-firing:event-navigateerror"><a href="#event-navigateerror">navigateerror</a></code> event.</p>
   </li><li><p>If <var>document</var> is not <a href="#fully-active" id="navigate-event-firing:fully-active-2">fully active</a>, then return false.</p></li><li><p>Let <var>event</var> be the result of <a id="navigate-event-firing:creating-an-event-2" href="https://dom.spec.whatwg.org/#concept-event-create" data-x-internal="creating-an-event">creating an event</a> given
   <code id="navigate-event-firing:navigateevent-2"><a href="#navigateevent">NavigateEvent</a></code>, in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-3">relevant realm</a>.</p></li><li><p>Set <var>event</var>'s <a href="#concept-navigateevent-classic-history-api-state" id="navigate-event-firing:concept-navigateevent-classic-history-api-state-2">classic history API state</a> to
   <var>classicHistoryAPIState</var>.</p></li><li><p>Let <var>destination</var> be a <a id="navigate-event-firing:new-2" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigate-event-firing:navigationdestination-2"><a href="#navigationdestination">NavigationDestination</a></code>
   created in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-4">relevant
   realm</a>.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-url" id="navigate-event-firing:concept-navigationdestination-url-2">URL</a>
   to <var>destinationURL</var>.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-entry" id="navigate-event-firing:concept-navigationdestination-entry-3">entry</a> to null.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-state" id="navigate-event-firing:concept-navigationdestination-state-3">state</a> to
   <var>navigationAPIState</var>.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-samedocument" id="navigate-event-firing:concept-navigationdestination-samedocument-2">is
   same document</a> to <var>isSameDocument</var>.</p></li><li><p>Return the result of performing the <a href="#inner-navigate-event-firing-algorithm" id="navigate-event-firing:inner-navigate-event-firing-algorithm-2">inner <code>navigate</code> event firing algorithm</a> given
   <var>navigation</var>, <var>navigationType</var>, <var>event</var>, <var>destination</var>,
   <var>userInvolvement</var>, <var>sourceElement</var>, <var>formDataEntryList</var>, null, and
   <var>apiMethodTracker</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fire-a-download-request-navigate-event">fire a download request <code>navigate</code> event</dfn> at a
  <code id="navigate-event-firing:navigation-3"><a href="#navigation">Navigation</a></code> <var>navigation</var> given a <a id="navigate-event-firing:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <dfn id="fire-navigate-download-destinationurl"><var>destinationURL</var></dfn>, a <a href="#user-navigation-involvement" id="navigate-event-firing:user-navigation-involvement-3">user
  navigation involvement</a> <dfn id="fire-navigate-download-userinvolvement"><var>userInvolvement</var></dfn>, an
  <code id="navigate-event-firing:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>-or-null <dfn id="fire-navigate-download-sourceelement"><var>sourceElement</var></dfn>, and a string
  <dfn id="fire-navigate-download-filename"><var>filename</var></dfn>:</p>

  <ol><li><p>Let <var>event</var> be the result of <a id="navigate-event-firing:creating-an-event-3" href="https://dom.spec.whatwg.org/#concept-event-create" data-x-internal="creating-an-event">creating an event</a> given
   <code id="navigate-event-firing:navigateevent-3"><a href="#navigateevent">NavigateEvent</a></code>, in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-5">relevant realm</a>.</p></li><li><p>Set <var>event</var>'s <a href="#concept-navigateevent-classic-history-api-state" id="navigate-event-firing:concept-navigateevent-classic-history-api-state-3">classic history API state</a> to
   null.</p></li><li><p>Let <var>destination</var> be a <a id="navigate-event-firing:new-3" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigate-event-firing:navigationdestination-3"><a href="#navigationdestination">NavigationDestination</a></code>
   created in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-6">relevant
   realm</a>.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-url" id="navigate-event-firing:concept-navigationdestination-url-3">URL</a>
   to <var>destinationURL</var>.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-entry" id="navigate-event-firing:concept-navigationdestination-entry-4">entry</a> to null.</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-state" id="navigate-event-firing:concept-navigationdestination-state-4">state</a> to
   <a href="#structuredserializeforstorage" id="navigate-event-firing:structuredserializeforstorage-3">StructuredSerializeForStorage</a>(null).</p></li><li><p>Set <var>destination</var>'s <a href="#concept-navigationdestination-samedocument" id="navigate-event-firing:concept-navigationdestination-samedocument-3">is
   same document</a> to false.</p></li><li><p>Return the result of performing the <a href="#inner-navigate-event-firing-algorithm" id="navigate-event-firing:inner-navigate-event-firing-algorithm-3">inner <code>navigate</code> event firing algorithm</a> given
   <var>navigation</var>, "<code id="navigate-event-firing:dom-navigationtype-push"><a href="#dom-navigationtype-push">push</a></code>", <var>event</var>,
   <var>destination</var>, <var>userInvolvement</var>, <var>sourceElement</var>, null, and
   <var>filename</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="inner-navigate-event-firing-algorithm">inner <code>navigate</code> event firing algorithm</dfn>
  consists of the following steps, given a <code id="navigate-event-firing:navigation-4"><a href="#navigation">Navigation</a></code> <var>navigation</var>, a
  <code id="navigate-event-firing:navigationtype-2"><a href="#navigationtype">NavigationType</a></code> <var>navigationType</var>, a <code id="navigate-event-firing:navigateevent-4"><a href="#navigateevent">NavigateEvent</a></code>
  <var>event</var>, a <code id="navigate-event-firing:navigationdestination-4"><a href="#navigationdestination">NavigationDestination</a></code> <var>destination</var>, a <a href="#user-navigation-involvement" id="navigate-event-firing:user-navigation-involvement-4">user
  navigation involvement</a> <var>userInvolvement</var>, an <code id="navigate-event-firing:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>-or-null
  <var>sourceElement</var>, an <a href="#entry-list" id="navigate-event-firing:entry-list-2">entry list</a>-or-null <var>formDataEntryList</var>, a
  string-or-null <var>downloadRequestFilename</var>, and an optional <a href="#navigation-api-method-tracker" id="navigate-event-firing:navigation-api-method-tracker-2">navigation API method
  tracker</a>-or-null <var>apiMethodTracker</var> (default null):</p>

  <ol><li>
    <p>If <var>navigation</var> <a href="#has-entries-and-events-disabled" id="navigate-event-firing:has-entries-and-events-disabled-3">has entries and events disabled</a>, then:</p>

    <ol><li><p><a id="navigate-event-firing:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigation</var>'s <a href="#ongoing-api-method-tracker" id="navigate-event-firing:ongoing-api-method-tracker">ongoing API method tracker</a> is
     null.</p></li><li><p><a id="navigate-event-firing:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigation</var>'s <a href="#upcoming-traverse-api-method-trackers" id="navigate-event-firing:upcoming-traverse-api-method-trackers">upcoming traverse API method
     trackers</a> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="navigate-event-firing:list-is-empty" data-x-internal="list-is-empty">is empty</a>.</p></li><li><p><a id="navigate-event-firing:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>apiMethodTracker</var> is null.</p></li><li><p>Return true.</p></li></ol>

    <p class="note">These assertions holds because <code id="navigate-event-firing:dom-navigation-traverseto"><a href="#dom-navigation-traverseto">traverseTo()</a></code>, <code id="navigate-event-firing:dom-navigation-back"><a href="#dom-navigation-back">back()</a></code>, and <code id="navigate-event-firing:dom-navigation-forward"><a href="#dom-navigation-forward">forward()</a></code> will immediately fail when entries and events
    are disabled (since there are no entries to traverse to).</p>
   </li><li><p><a id="navigate-event-firing:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigation</var>'s <a href="#ongoing-api-method-tracker" id="navigate-event-firing:ongoing-api-method-tracker-2">ongoing API method tracker</a> is
   null.</p></li><li>
    <p>If <var>destination</var>'s <a href="#concept-navigationdestination-entry" id="navigate-event-firing:concept-navigationdestination-entry-5">entry</a>
    is non-null:</p>

    <ol><li>
      <p><a id="navigate-event-firing:assert-5" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>apiMethodTracker</var> is null.</p>

      <p class="note"><var>apiMethodTracker</var> is passed as an argument only for <code id="navigate-event-firing:dom-navigation-navigate-2"><a href="#dom-navigation-navigate">navigate()</a></code> and <code id="navigate-event-firing:dom-navigation-reload-2"><a href="#dom-navigation-reload">reload()</a></code> calls.
     </p></li><li><p>Let <var>destinationKey</var> be <var>destination</var>'s <a href="#concept-navigationdestination-entry" id="navigate-event-firing:concept-navigationdestination-entry-6">entry</a>'s <a href="#concept-navigationhistoryentry-key" id="navigate-event-firing:concept-navigationhistoryentry-key">key</a>.</p></li><li><p><a id="navigate-event-firing:assert-6" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>destinationKey</var> is not the empty string.</p></li><li>
      <p>If <var>navigation</var>'s <a href="#upcoming-traverse-api-method-trackers" id="navigate-event-firing:upcoming-traverse-api-method-trackers-2">upcoming traverse API method
      trackers</a>[<var>destinationKey</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="navigate-event-firing:map-exists" data-x-internal="map-exists">exists</a>:</p>

      <ol><li><p>Set <var>apiMethodTracker</var> to <var>navigation</var>'s <a href="#upcoming-traverse-api-method-trackers" id="navigate-event-firing:upcoming-traverse-api-method-trackers-3">upcoming traverse API
       method trackers</a>[<var>destinationKey</var>].</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="navigate-event-firing:map-remove" data-x-internal="map-remove">Remove</a> <var>navigation</var>'s <a href="#upcoming-traverse-api-method-trackers" id="navigate-event-firing:upcoming-traverse-api-method-trackers-4">upcoming
       traverse API method trackers</a>[<var>destinationKey</var>].</p></li></ol>
     </li></ol>
   </li><li>
    <p>If <var>apiMethodTracker</var> is not null:</p>

    <ol><li><p>Set <var>navigation</var>'s <a href="#ongoing-api-method-tracker" id="navigate-event-firing:ongoing-api-method-tracker-3">ongoing API method tracker</a> to
     <var>apiMethodTracker</var>.</p></li><li><p>Set <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-pending" id="navigate-event-firing:navigation-api-method-tracker-pending-2">pending</a> to false.</p></li></ol>
   </li><li><p>Let <var>navigable</var> be <var>navigation</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-3">relevant global object</a>'s
   <a href="#window-navigable" id="navigate-event-firing:window-navigable">navigable</a>.</p></li><li><p>Let <var>document</var> be <var>navigation</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-4">relevant global object</a>'s
   <a href="#concept-document-window" id="navigate-event-firing:concept-document-window-3">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var> <a href="#can-have-its-url-rewritten" id="navigate-event-firing:can-have-its-url-rewritten">can have its URL rewritten</a> to <var>destination</var>'s
   <a href="#concept-navigationdestination-url" id="navigate-event-firing:concept-navigationdestination-url-4">URL</a>, and either <var>destination</var>'s
   <a href="#concept-navigationdestination-samedocument" id="navigate-event-firing:concept-navigationdestination-samedocument-4">is same document</a> is true or
   <var>navigationType</var> is not "<code id="navigate-event-firing:dom-navigationtype-traverse-2"><a href="#dom-navigationtype-traverse">traverse</a></code>",
   then initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-canintercept"><a href="#dom-navigateevent-canintercept">canIntercept</a></code> to true. Otherwise, initialize it to
   false.</p></li><li id="navigate-event-traverse-can-be-canceled">
    <p>Let <var>traverseCanBeCanceled</var> be true if all of the following are true:</p>

    <ul><li><p><var>navigable</var> is a <a href="#top-level-traversable" id="navigate-event-firing:top-level-traversable">top-level traversable</a>;</p></li><li><p><var>destination</var>'s <a href="#concept-navigationdestination-samedocument" id="navigate-event-firing:concept-navigationdestination-samedocument-5">is
     same document</a> is true; and</p></li><li><p>either <var>userInvolvement</var> is not "<code id="navigate-event-firing:uni-browser-ui"><a href="#uni-browser-ui">browser
     UI</a></code>", or <var>navigation</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-5">relevant global object</a> has
     <a href="#history-action-activation" id="navigate-event-firing:history-action-activation">history-action activation</a>.</p></li></ul>

    <p>Otherwise, let it be false.</p>
   </li><li>
    <p>If either:</p>

    <ul><li><p><var>navigationType</var> is not "<code id="navigate-event-firing:dom-navigationtype-traverse-3"><a href="#dom-navigationtype-traverse">traverse</a></code>"; or</p></li><li><p><var>traverseCanBeCanceled</var> is true,</p></li></ul>

    <p>then initialize <var>event</var>'s <code id="navigate-event-firing:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> to
    true. Otherwise, initialize it to false.</p>
   </li><li><p>Initialize <var>event</var>'s <code id="navigate-event-firing:dom-event-type"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> to "<code id="navigate-event-firing:event-navigate-3"><a href="#event-navigate">navigate</a></code>".</p></li><li><p>Initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-navigationtype"><a href="#dom-navigateevent-navigationtype">navigationType</a></code> to
   <var>navigationType</var>.</p></li><li><p>Initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-destination"><a href="#dom-navigateevent-destination">destination</a></code> to <var>destination</var>.</p></li><li><p>Initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-downloadrequest"><a href="#dom-navigateevent-downloadrequest">downloadRequest</a></code> to
   <var>downloadRequestFilename</var>.</p></li><li>
    <p>If <var>apiMethodTracker</var> is not null, then initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-info"><a href="#dom-navigateevent-info">info</a></code> to <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-info" id="navigate-event-firing:navigation-api-method-tracker-info">info</a>. Otherwise, initialize it to
    undefined.</p>

    <p class="note">At this point <var>apiMethodTracker</var>'s <a href="#navigation-api-method-tracker-info" id="navigate-event-firing:navigation-api-method-tracker-info-2">info</a> is no longer needed and can be nulled
    out instead of keeping it alive for the lifetime of the <a href="#navigation-api-method-tracker" id="navigate-event-firing:navigation-api-method-tracker-3">navigation API method
    tracker</a>.</p>
   </li><li><p>Initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-hasuavisualtransition"><a href="#dom-navigateevent-hasuavisualtransition">hasUAVisualTransition</a></code> to true if a visual
   transition, to display a cached rendered state of the <var>document</var>'s <a href="#latest-entry" id="navigate-event-firing:latest-entry">latest
   entry</a>, was done by the user agent. Otherwise, initialize it to false.</p></li><li><p>Initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-sourceelement"><a href="#dom-navigateevent-sourceelement">sourceElement</a></code> to
   <var>sourceElement</var>.</p></li><li><p>Set <var>event</var>'s <a href="#concept-navigateevent-abort-controller" id="navigate-event-firing:concept-navigateevent-abort-controller">abort
   controller</a> to a <a id="navigate-event-firing:new-4" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigate-event-firing:abortcontroller"><a data-x-internal="abortcontroller" href="https://dom.spec.whatwg.org/#abortcontroller">AbortController</a></code> created in
   <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-7">relevant realm</a>.</p></li><li><p>Initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-signal"><a href="#dom-navigateevent-signal">signal</a></code> to
   <var>event</var>'s <a href="#concept-navigateevent-abort-controller" id="navigate-event-firing:concept-navigateevent-abort-controller-2">abort
   controller</a>'s <a href="https://dom.spec.whatwg.org/#abortcontroller-signal" id="navigate-event-firing:concept-abortcontroller-signal" data-x-internal="concept-abortcontroller-signal">signal</a>.</p></li><li><p>Let <var>currentURL</var> be <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="navigate-event-firing:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li>
    <p>If all of the following are true:</p>

    <ul><li><p><var>event</var>'s <a href="#concept-navigateevent-classic-history-api-state" id="navigate-event-firing:concept-navigateevent-classic-history-api-state-4">classic history API state</a> is
     null;</p></li><li><p><var>destination</var>'s <a href="#concept-navigationdestination-samedocument" id="navigate-event-firing:concept-navigationdestination-samedocument-6">is
     same document</a> is true;</p></li><li><p><var>destination</var>'s <a href="#concept-navigationdestination-url" id="navigate-event-firing:concept-navigationdestination-url-5">URL</a>
     <a href="https://url.spec.whatwg.org/#concept-url-equals" id="navigate-event-firing:concept-url-equals" data-x-internal="concept-url-equals">equals</a> <var>currentURL</var> with <a href="https://url.spec.whatwg.org/#url-equals-exclude-fragments" id="navigate-event-firing:url-equals-exclude-fragments" data-x-internal="url-equals-exclude-fragments"><i>exclude fragments</i></a> set to true; and</p></li><li><p><var>destination</var>'s <a href="#concept-navigationdestination-url" id="navigate-event-firing:concept-navigationdestination-url-6">URL</a>'s
     <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="navigate-event-firing:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> is not <a id="navigate-event-firing:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a>
     <var>currentURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="navigate-event-firing:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a>,</p></li></ul>

    <p>then initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-hashchange"><a href="#dom-navigateevent-hashchange">hashChange</a></code> to true. Otherwise, initialize it to
    false.</p>

    <p class="note">The first condition here means that <code id="navigate-event-firing:dom-navigateevent-hashchange-2"><a href="#dom-navigateevent-hashchange">hashChange</a></code> will be true for <a href="#navigate-fragid" id="navigate-event-firing:navigate-fragid">fragment navigations</a>, but false for cases like <code>history.pushState(undefined, "", "#fragment")</code>.</p>
   </li><li><p>If <var>userInvolvement</var> is not "<code id="navigate-event-firing:uni-none-3"><a href="#uni-none">none</a></code>", then
   initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-userinitiated"><a href="#dom-navigateevent-userinitiated">userInitiated</a></code>
   to true. Otherwise, initialize it to false.</p></li><li><p>If <var>formDataEntryList</var> is not null, then initialize <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-formdata"><a href="#dom-navigateevent-formdata">formData</a></code> to a <a id="navigate-event-firing:new-5" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigate-event-firing:formdata"><a data-x-internal="formdata" href="https://xhr.spec.whatwg.org/#formdata">FormData</a></code>
   created in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-8">relevant realm</a>,
   associated to <var>formDataEntryList</var>. Otherwise, initialize it to null.</p></li><li><p><a id="navigate-event-firing:assert-7" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigation</var>'s <a href="#ongoing-navigate-event" id="navigate-event-firing:ongoing-navigate-event">ongoing <code>navigate</code> event</a> is null.</p></li><li><p>Set <var>navigation</var>'s <a href="#ongoing-navigate-event" id="navigate-event-firing:ongoing-navigate-event-2">ongoing <code>navigate</code>
   event</a> to <var>event</var>.</p></li><li><p>Set <var>navigation</var>'s <a href="#focus-changed-during-ongoing-navigation" id="navigate-event-firing:focus-changed-during-ongoing-navigation">focus changed during ongoing navigation</a> to
   false.</p></li><li><p>Set <var>navigation</var>'s <a href="#suppress-normal-scroll-restoration-during-ongoing-navigation" id="navigate-event-firing:suppress-normal-scroll-restoration-during-ongoing-navigation">suppress normal scroll restoration during ongoing
   navigation</a> to false.</p></li><li><p>Let <var>dispatchResult</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="navigate-event-firing:concept-event-dispatch" data-x-internal="concept-event-dispatch">dispatching</a> <var>event</var> at
   <var>navigation</var>.</p></li><li>
    <p>If <var>dispatchResult</var> is false:</p>

    <ol><li><p>If <var>navigationType</var> is "<code id="navigate-event-firing:dom-navigationtype-traverse-4"><a href="#dom-navigationtype-traverse">traverse</a></code>", then <a href="#consume-history-action-user-activation" id="navigate-event-firing:consume-history-action-user-activation">consume history-action user
     activation</a> given <var>navigation</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-6">relevant global object</a>.</p></li><li><p>If <var>event</var>'s <a href="#concept-navigateevent-abort-controller" id="navigate-event-firing:concept-navigateevent-abort-controller-3">abort
     controller</a>'s <a href="https://dom.spec.whatwg.org/#abortcontroller-signal" id="navigate-event-firing:concept-abortcontroller-signal-2" data-x-internal="concept-abortcontroller-signal">signal</a> is not <a href="https://dom.spec.whatwg.org/#abortsignal-aborted" id="navigate-event-firing:abortsignal-aborted" data-x-internal="abortsignal-aborted">aborted</a>, then <a href="#abort-the-ongoing-navigation" id="navigate-event-firing:abort-the-ongoing-navigation">abort the ongoing navigation</a>
     given <var>navigation</var>.</p></li><li><p>Return false.</p></li></ol>
   </li><li>
    <p>If <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-firing:concept-navigateevent-interception-state">interception
    state</a> is not "<code>none</code>":</p>

    <ol><li><p>Let <var>fromNHE</var> be the <a href="#navigation-current-entry" id="navigate-event-firing:navigation-current-entry">current
     entry</a> of <var>navigation</var>.</p></li><li><p><a id="navigate-event-firing:assert-8" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>fromNHE</var> is not null.</p></li><li>
      <p>Set <var>navigation</var>'s <a href="#concept-navigation-transition" id="navigate-event-firing:concept-navigation-transition">transition</a>
      to a <a id="navigate-event-firing:new-6" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="navigate-event-firing:navigationtransition"><a href="#navigationtransition">NavigationTransition</a></code> created in <var>navigation</var>'s
      <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-9">relevant realm</a>, with

      </p><dl class="props"><dt><a href="#concept-navigationtransition-navigationtype" id="navigate-event-firing:concept-navigationtransition-navigationtype">navigation type</a></dt><dd><var>navigationType</var></dd><dt><a href="#concept-navigationtransition-from" id="navigate-event-firing:concept-navigationtransition-from">from entry</a></dt><dd><var>fromNHE</var></dd><dt><a href="#concept-navigationtransition-committed" id="navigate-event-firing:concept-navigationtransition-committed">committed promise</a></dt><dd>a new promise created in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-10">relevant realm</a></dd><dt><a href="#concept-navigationtransition-finished" id="navigate-event-firing:concept-navigationtransition-finished">finished promise</a></dt><dd>a new promise created in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-11">relevant realm</a></dd></dl>
     </li><li>
      <p><a id="navigate-event-firing:mark-as-handled" href="https://webidl.spec.whatwg.org/#mark-a-promise-as-handled" data-x-internal="mark-as-handled">Mark as handled</a> <var>navigation</var>'s <a href="#concept-navigation-transition" id="navigate-event-firing:concept-navigation-transition-2">transition</a>'s <a href="#concept-navigationtransition-finished" id="navigate-event-firing:concept-navigationtransition-finished-2">finished promise</a>.</p>

      <p class="note">See the <a href="#note-mark-as-handled-navigation-api-finished">discussion
      about other finished promises</a> to understand why this is done.</p>
     </li><li><p><a id="navigate-event-firing:mark-as-handled-2" href="https://webidl.spec.whatwg.org/#mark-a-promise-as-handled" data-x-internal="mark-as-handled">Mark as handled</a> <var>navigation</var>'s <a href="#concept-navigation-transition" id="navigate-event-firing:concept-navigation-transition-3">transition</a>'s <a href="#concept-navigationtransition-committed" id="navigate-event-firing:concept-navigationtransition-committed-2">committed promise</a>.</p></li></ol>
   </li><li><p>If <var>event</var>'s <a href="#concept-navigateevent-navigation-precommit-handler-list" id="navigate-event-firing:concept-navigateevent-navigation-precommit-handler-list">navigation precommit handler
   list</a> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="navigate-event-firing:list-is-empty-2" data-x-internal="list-is-empty">is empty</a> then <a href="#commit-a-navigate-event" id="navigate-event-firing:commit-a-navigate-event">commit</a> <var>event</var> given <var>apiMethodTracker</var>.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>precommitController</var> be a new <code id="navigate-event-firing:navigationprecommitcontroller"><a href="#navigationprecommitcontroller">NavigationPrecommitController</a></code>
     created in <var>navigation</var>'s <a href="#concept-relevant-realm" id="navigate-event-firing:concept-relevant-realm-12">relevant realm</a>,
     whose <a href="#concept-navigationprecommitcontroller-event" id="navigate-event-firing:concept-navigationprecommitcontroller-event">event</a> is
     <var>event</var>.</p></li><li><p>Let <var>precommitPromisesList</var> be an empty <a id="navigate-event-firing:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigate-event-firing:list-iterate" data-x-internal="list-iterate">For each</a> <var>handler</var> of <var>event</var>'s <a href="#concept-navigateevent-navigation-precommit-handler-list" id="navigate-event-firing:concept-navigateevent-navigation-precommit-handler-list-2">navigation precommit handler
      list</a>:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="navigate-event-firing:list-append" data-x-internal="list-append">Append</a> the result of <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="navigate-event-firing:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">invoking</a> <var>handler</var> with
       « <var>precommitController</var> » to <var>precommitPromisesList</var>.</p></li></ol>
     </li><li><p><a id="navigate-event-firing:wait-for-all" href="https://webidl.spec.whatwg.org/#wait-for-all" data-x-internal="wait-for-all">Wait for all</a> <var>precommitPromisesList</var> with the following success
     steps: <a href="#commit-a-navigate-event" id="navigate-event-firing:commit-a-navigate-event-2">commit</a> <var>event</var> given
     <var>apiMethodTracker</var>, and the following failure step given <var>reason</var>:
     <a href="#process-navigate-event-handler-failure" id="navigate-event-firing:process-navigate-event-handler-failure">process navigate event handler failure</a> given <var>event</var> and
     <var>reason</var>.</p></li></ol>
   </li><li><p>If <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-firing:concept-navigateevent-interception-state-2">interception
   state</a> is "<code>none</code>", then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="commit-a-navigate-event">commit a navigate event</dfn> given a <code id="navigate-event-firing:navigateevent-5"><a href="#navigateevent">NavigateEvent</a></code> object
  <var>event</var> and a <a href="#navigation-api-method-tracker" id="navigate-event-firing:navigation-api-method-tracker-4">navigation API method tracker</a>
  <var>apiMethodTracker</var>:</p>

  <ol><li><p>Let <var>navigation</var> be <var>event</var>'s <a href="https://dom.spec.whatwg.org/#concept-event-target" id="navigate-event-firing:concept-event-target" data-x-internal="concept-event-target">target</a>.</p></li><li><p>Let <var>navigable</var> be <var>event</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-7">relevant global object</a>'s <a href="#window-navigable" id="navigate-event-firing:window-navigable-2">navigable</a>.</p></li><li><p>If <var>event</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-8">relevant global object</a>'s <a href="#concept-document-window" id="navigate-event-firing:concept-document-window-4">associated <code>Document</code></a> is not <a href="#fully-active" id="navigate-event-firing:fully-active-3">fully
   active</a>, then return.</p></li><li><p>If <var>event</var>'s <a href="#concept-navigateevent-abort-controller" id="navigate-event-firing:concept-navigateevent-abort-controller-4">abort
   controller</a>'s <a href="https://dom.spec.whatwg.org/#abortcontroller-signal" id="navigate-event-firing:concept-abortcontroller-signal-3" data-x-internal="concept-abortcontroller-signal">signal</a> is <a href="https://dom.spec.whatwg.org/#abortsignal-aborted" id="navigate-event-firing:abortsignal-aborted-2" data-x-internal="abortsignal-aborted">aborted</a>, then return.</p></li><li><p>Let <var>endResultIsSameDocument</var> be true if <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-firing:concept-navigateevent-interception-state-3">interception state</a> is not "<code>none</code>" or <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-destination-2"><a href="#dom-navigateevent-destination">destination</a></code>'s <a href="#concept-navigationdestination-samedocument" id="navigate-event-firing:concept-navigationdestination-samedocument-7">is same document</a> is true.</p></li><li>
    <p><a href="#prepare-to-run-script" id="navigate-event-firing:prepare-to-run-script">Prepare to run script</a> given <var>navigation</var>'s <a href="#relevant-settings-object" id="navigate-event-firing:relevant-settings-object">relevant settings
    object</a>.</p>

    <div id="note-suppress-microtasks-during-navigation-events" class="note"><a href="#note-suppress-microtasks-during-navigation-events" class="self-link"></a>
     <p>This is done to avoid the <a id="navigate-event-firing:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> becoming empty
     right after any <code id="navigate-event-firing:event-currententrychange"><a href="#event-currententrychange">currententrychange</a></code> event
     handlers run as a result of the <a href="#url-and-history-update-steps" id="navigate-event-firing:url-and-history-update-steps">URL and history update steps</a> that could soon
     happen. If the stack were to become empty at that time, then it would immediately <a href="#perform-a-microtask-checkpoint" id="navigate-event-firing:perform-a-microtask-checkpoint">perform
     a microtask checkpoint</a>, causing various promise fulfillment handlers to run interleaved
     with the event handlers and before any handlers passed to <code id="navigate-event-firing:dom-navigateevent-intercept"><a href="#dom-navigateevent-intercept">navigateEvent.intercept()</a></code>. This is undesirable
     since it means promise handler ordering vs. <code id="navigate-event-firing:event-currententrychange-2"><a href="#event-currententrychange">currententrychange</a></code> event handler ordering vs. <code id="navigate-event-firing:dom-navigateevent-intercept-2"><a href="#dom-navigateevent-intercept">intercept()</a></code> handler ordering would be dependent on
     whether the navigation is happening with an empty <a id="navigate-event-firing:javascript-execution-context-stack-2" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context
     stack</a> (e.g., because the navigation was user-initiated) or with a nonempty one (e.g.,
     because the navigation was caused by a JavaScript API call).</p>

     <p>By inserting an otherwise-unnecessary <a id="navigate-event-firing:javascript-execution-context" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript execution context</a> onto the
     stack in this step, we essentially suppress the <a href="#perform-a-microtask-checkpoint" id="navigate-event-firing:perform-a-microtask-checkpoint-2">perform a microtask checkpoint</a>
     algorithm until later, thus ensuring that the sequence is always: <code id="navigate-event-firing:event-currententrychange-3"><a href="#event-currententrychange">currententrychange</a></code> event handlers, then <code id="navigate-event-firing:dom-navigateevent-intercept-3"><a href="#dom-navigateevent-intercept">intercept()</a></code> handlers, then promise handlers.</p>
    </div>
   </li><li>
    <p>If <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-firing:concept-navigateevent-interception-state-4">interception
    state</a> is not "<code>none</code>":</p>
    <ol><li><p>Set <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-firing:concept-navigateevent-interception-state-5">interception state</a> to "<code>committed</code>".</p></li><li>
      <p>Switch on <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-navigationtype-2"><a href="#dom-navigateevent-navigationtype">navigationType</a></code>:</p>

      <dl class="switch"><dt>"<code id="navigate-event-firing:dom-navigationtype-push-2"><a href="#dom-navigationtype-push">push</a></code>"</dt><dt>"<code id="navigate-event-firing:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>"</dt><dd><p>Run the <a href="#url-and-history-update-steps" id="navigate-event-firing:url-and-history-update-steps-2">URL and history update steps</a> given <var>event</var>'s
       <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-9">relevant global object</a>'s <a href="#concept-document-window" id="navigate-event-firing:concept-document-window-5">associated
       <code>Document</code></a> and <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-destination-3"><a href="#dom-navigateevent-destination">destination</a></code>'s <a href="#dom-navigationdestination-url" id="navigate-event-firing:dom-navigationdestination-url">URL</a>, with <i id="navigate-event-firing:uhus-serializeddata"><a href="#uhus-serializeddata">serializedData</a></i> set to <var>event</var>'s <a href="#concept-navigateevent-classic-history-api-state" id="navigate-event-firing:concept-navigateevent-classic-history-api-state-5">classic history API state</a> and
       <i id="navigate-event-firing:uhus-historyhandling"><a href="#uhus-historyhandling">historyHandling</a></i> set to <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-navigationtype-3"><a href="#dom-navigateevent-navigationtype">navigationType</a></code>.</p></dd><dt>"<code id="navigate-event-firing:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>"</dt><dd><p><a href="#update-the-navigation-api-entries-for-a-same-document-navigation" id="navigate-event-firing:update-the-navigation-api-entries-for-a-same-document-navigation">Update the navigation API entries for a same-document navigation</a> given
       <var>navigation</var>, <var>navigable</var>'s <a href="#nav-active-history-entry" id="navigate-event-firing:nav-active-history-entry">active
       session history entry</a>, and "<code id="navigate-event-firing:dom-navigationtype-reload-2"><a href="#dom-navigationtype-reload">reload</a></code>".</p></dd><dt>"<code id="navigate-event-firing:dom-navigationtype-traverse-5"><a href="#dom-navigationtype-traverse">traverse</a></code>"</dt><dd>
        <ol><li>
          <p>Set <var>navigation</var>'s <a href="#suppress-normal-scroll-restoration-during-ongoing-navigation" id="navigate-event-firing:suppress-normal-scroll-restoration-during-ongoing-navigation-2">suppress normal scroll restoration during ongoing
          navigation</a> to true.</p>

          <p class="note">If <var>event</var>'s <a href="#concept-navigateevent-scroll" id="navigate-event-firing:concept-navigateevent-scroll">scroll
          behavior</a> was set to "<code id="navigate-event-firing:dom-navigationscrollbehavior-after-transition"><a href="#dom-navigationscrollbehavior-after-transition">after-transition</a></code>", then
          scroll restoration will happen as part of <a href="#navigateevent-finish" id="navigate-event-firing:navigateevent-finish">finishing</a> the relevant <code id="navigate-event-firing:navigateevent-6"><a href="#navigateevent">NavigateEvent</a></code>.
          Otherwise, there will be no scroll restoration. That is, no navigation which is
          intercepted by <code id="navigate-event-firing:dom-navigateevent-intercept-4"><a href="#dom-navigateevent-intercept">intercept()</a></code> goes through
          the normal scroll restoration process; scroll restoration for such navigations is either
          done manually, by the web developer, or is done after the transition.</p>
         </li><li><p>Let <var>userInvolvement</var> be "<code id="navigate-event-firing:uni-none-4"><a href="#uni-none">none</a></code>".</p></li><li>
          <p>If <var>event</var>'s <code id="navigate-event-firing:dom-navigateevent-userinitiated-2"><a href="#dom-navigateevent-userinitiated">userInitiated</a></code> is true, then set
          <var>userInvolvement</var> to "<code id="navigate-event-firing:uni-activation"><a href="#uni-activation">activation</a></code>".</p>

          <p class="note">At this point after interception, it is not consequential whether the
          activation was a result of browser UI.</p>
         </li><li>
          <p><a href="#tn-append-session-history-traversal-steps" id="navigate-event-firing:tn-append-session-history-traversal-steps">Append the following session
          history traversal steps</a> to <var>navigable</var>'s <a href="#nav-traversable" id="navigate-event-firing:nav-traversable">traversable navigable</a>:</p>

          <ol><li><p><a href="#resume-applying-the-traverse-history-step" id="navigate-event-firing:resume-applying-the-traverse-history-step">Resume applying the traverse history step</a> given <var>event</var>'s
           <code id="navigate-event-firing:dom-navigateevent-destination-4"><a href="#dom-navigateevent-destination">destination</a></code>'s <a href="#concept-navigationdestination-entry" id="navigate-event-firing:concept-navigationdestination-entry-7">entry</a>'s <a href="#nhe-she" id="navigate-event-firing:nhe-she-2">session history entry</a>'s <a href="#she-step" id="navigate-event-firing:she-step">step</a>,
           <var>navigable</var>'s <a href="#nav-traversable" id="navigate-event-firing:nav-traversable-2">traversable navigable</a>, and
           <var>userInvolvement</var>.</p></li></ol>
         </li></ol>
       </dd></dl>
     </li></ol>
   </li><li><p>If <var>navigation</var>'s <a href="#concept-navigation-transition" id="navigate-event-firing:concept-navigation-transition-4">transition</a>
   is not null, then resolve <var>navigation</var>'s <a href="#concept-navigation-transition" id="navigate-event-firing:concept-navigation-transition-5">transition</a>'s <a href="#concept-navigationtransition-committed" id="navigate-event-firing:concept-navigationtransition-committed-3">committed promise</a> with undefined.</p></li><li>
    <p>If <var>endResultIsSameDocument</var> is true:</p>

    <ol><li><p>Let <var>promisesList</var> be an empty <a id="navigate-event-firing:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigate-event-firing:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>handler</var> of <var>event</var>'s <a href="#concept-navigateevent-navigation-handler-list" id="navigate-event-firing:concept-navigateevent-navigation-handler-list">navigation handler list</a>:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="navigate-event-firing:list-append-2" data-x-internal="list-append">Append</a> the result of <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="navigate-event-firing:es-invoking-callback-functions-2" data-x-internal="es-invoking-callback-functions">invoking</a> <var>handler</var> with an empty
       arguments list to <var>promisesList</var>.</p></li></ol>
     </li><li>
      <p>If <var>promisesList</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="navigate-event-firing:list-size" data-x-internal="list-size">size</a> is 0, then set
      <var>promisesList</var> to « <a id="navigate-event-firing:a-promise-resolved-with" href="https://webidl.spec.whatwg.org/#a-promise-resolved-with" data-x-internal="a-promise-resolved-with">a promise resolved with</a> undefined ».</p>

      <p class="note">There is a subtle timing difference between how <a href="https://webidl.spec.whatwg.org/#wait-for-all" id="navigate-event-firing:wait-for-all-2" data-x-internal="wait-for-all">waiting for all</a> schedules its success and failure steps when given zero promises
      versus ≥1 promises. For most uses of <a href="https://webidl.spec.whatwg.org/#wait-for-all" id="navigate-event-firing:wait-for-all-3" data-x-internal="wait-for-all">waiting for all</a>, this
      does not matter. However, with this API, there are so many events and promise handlers which
      could fire around the same time that the difference is pretty easily observable: it can cause
      the event/promise handler sequence to vary. (Some of the events and promises involved include:
      <code id="navigate-event-firing:event-navigatesuccess"><a href="#event-navigatesuccess">navigatesuccess</a></code> / <code id="navigate-event-firing:event-navigateerror-2"><a href="#event-navigateerror">navigateerror</a></code>, <code id="navigate-event-firing:event-currententrychange-4"><a href="#event-currententrychange">currententrychange</a></code>, <code id="navigate-event-firing:event-dispose"><a href="#event-dispose">dispose</a></code>, <var>apiMethodTracker</var>'s promises, and the <code id="navigate-event-firing:dom-navigationtransition-finished"><a href="#dom-navigationtransition-finished">navigation.transition.finished</a></code> promise.)
     </p></li><li>
      <p><a id="navigate-event-firing:wait-for-all-4" href="https://webidl.spec.whatwg.org/#wait-for-all" data-x-internal="wait-for-all">Wait for all</a> of <var>promisesList</var>, with the following success steps:</p>

      <ol><li><p>If <var>event</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-10">relevant global object</a> is not <a href="#fully-active" id="navigate-event-firing:fully-active-4">fully
       active</a>, then abort these steps.</p></li><li><p>If <var>event</var>'s <a href="#concept-navigateevent-abort-controller" id="navigate-event-firing:concept-navigateevent-abort-controller-5">abort
       controller</a>'s <a href="https://dom.spec.whatwg.org/#abortcontroller-signal" id="navigate-event-firing:concept-abortcontroller-signal-4" data-x-internal="concept-abortcontroller-signal">signal</a> is <a href="https://dom.spec.whatwg.org/#abortsignal-aborted" id="navigate-event-firing:abortsignal-aborted-3" data-x-internal="abortsignal-aborted">aborted</a>, then abort these steps.</p></li><li><p><a id="navigate-event-firing:assert-9" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var> equals <var>navigation</var>'s <a href="#ongoing-navigate-event" id="navigate-event-firing:ongoing-navigate-event-3">ongoing
       <code>navigate</code> event</a>.</p></li><li><p>Set <var>navigation</var>'s <a href="#ongoing-navigate-event" id="navigate-event-firing:ongoing-navigate-event-4">ongoing <code>navigate</code> event</a> to null.</p></li><li><p><a href="#navigateevent-finish" id="navigate-event-firing:navigateevent-finish-2">Finish</a> <var>event</var> given
       true.</p></li><li><p>If <var>apiMethodTracker</var> is non-null, then <a href="#resolve-the-finished-promise" id="navigate-event-firing:resolve-the-finished-promise">resolve the finished
       promise</a> for <var>apiMethodTracker</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="navigate-event-firing:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="navigate-event-firing:event-navigatesuccess-2"><a href="#event-navigatesuccess">navigatesuccess</a></code> at <var>navigation</var>.</p></li><li><p>If <var>navigation</var>'s <a href="#concept-navigation-transition" id="navigate-event-firing:concept-navigation-transition-6">transition</a> is not null, then resolve
       <var>navigation</var>'s <a href="#concept-navigation-transition" id="navigate-event-firing:concept-navigation-transition-7">transition</a>'s
       <a href="#concept-navigationtransition-finished" id="navigate-event-firing:concept-navigationtransition-finished-3">finished promise</a> with
       undefined.</p></li><li><p>Set <var>navigation</var>'s <a href="#concept-navigation-transition" id="navigate-event-firing:concept-navigation-transition-8">transition</a> to null.</p></li></ol>

      <p>and the following failure step given <var>reason</var>: <a href="#process-navigate-event-handler-failure" id="navigate-event-firing:process-navigate-event-handler-failure-2">process navigate event
      handler failure</a> given <var>event</var> and <var>reason</var>.
     </p></li></ol>
   </li><li><p>Otherwise, if <var>apiMethodTracker</var> is non-null, then <a href="#navigation-api-method-tracker-clean-up" id="navigate-event-firing:navigation-api-method-tracker-clean-up">clean up</a>
   <var>apiMethodTracker</var>.</p></li><li>
    <p><a href="#clean-up-after-running-script" id="navigate-event-firing:clean-up-after-running-script">Clean up after running script</a> given <var>navigation</var>'s <a href="#relevant-settings-object" id="navigate-event-firing:relevant-settings-object-2">relevant
    settings object</a>.</p>

    <p class="note">Per the <a href="#note-suppress-microtasks-during-navigation-events">previous
    note</a>, this stops suppressing any potential promise handler microtasks, causing them to run
    at this point or later.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="process-navigate-event-handler-failure">process navigate event handler failure</dfn> given a <code id="navigate-event-firing:navigateevent-7"><a href="#navigateevent">NavigateEvent</a></code> object
  <var>event</var> and a <var>reason</var>:</p>

  <ol><li><p>If <var>event</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-11">relevant global object</a>'s <a href="#concept-document-window" id="navigate-event-firing:concept-document-window-6">associated <code>Document</code></a> is not <a href="#fully-active" id="navigate-event-firing:fully-active-5">fully
   active</a>, then return.</p></li><li><p>If <var>event</var>'s <a href="#concept-navigateevent-abort-controller" id="navigate-event-firing:concept-navigateevent-abort-controller-6">abort
   controller</a>'s <a href="https://dom.spec.whatwg.org/#abortcontroller-signal" id="navigate-event-firing:concept-abortcontroller-signal-5" data-x-internal="concept-abortcontroller-signal">signal</a> is <a href="https://dom.spec.whatwg.org/#abortsignal-aborted" id="navigate-event-firing:abortsignal-aborted-4" data-x-internal="abortsignal-aborted">aborted</a>, then return.</p></li><li><p><a id="navigate-event-firing:assert-10" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var> is <var>event</var>'s <a href="#concept-relevant-global" id="navigate-event-firing:concept-relevant-global-12">relevant global
   object</a>'s <a href="#window-navigation-api" id="navigate-event-firing:window-navigation-api">navigation API</a>'s <a href="#ongoing-navigate-event" id="navigate-event-firing:ongoing-navigate-event-5">ongoing <code>navigate</code> event</a>.</p></li><li><p>If <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-firing:concept-navigateevent-interception-state-6">interception
   state</a> is not "<code>intercepted</code>", then <a href="#navigateevent-finish" id="navigate-event-firing:navigateevent-finish-3">finish</a> <var>event</var> given false.</p></li><li><p><a href="#abort-a-navigateevent" id="navigate-event-firing:abort-a-navigateevent">Abort</a> <var>event</var> given
   <var>reason</var>.</p>
  </li></ol>
  </div>


  <h6 id="navigate-event-scroll-focus"><span class="secno">7.2.6.10.5</span> Scroll and focus behavior<a href="#navigate-event-scroll-focus" class="self-link"></a></h6>

  <p>By calling <code id="navigate-event-scroll-focus:dom-navigateevent-intercept"><a href="#dom-navigateevent-intercept">navigateEvent.intercept()</a></code>, web
  developers can suppress the normal scroll and focus behavior for same-document navigations,
  instead invoking cross-document navigation-like behavior at a later time. The algorithms in this
  section are called at those appropriate later points.</p>

  <div data-algorithm="">
  <p>To <dfn id="navigateevent-finish">finish</dfn> a <code id="navigate-event-scroll-focus:navigateevent"><a href="#navigateevent">NavigateEvent</a></code>
  <var>event</var>, given a boolean <var>didFulfill</var>:</p>

  <ol><li><p><a id="navigate-event-scroll-focus:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state">interception state</a> is not "<code>finished</code>".</p></li><li>
    <p>If <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state-2">interception
    state</a> is "<code>intercepted</code>", then:</p>

    <ol><li><p>Assert: <var>didFulfill</var> is false.</p></li><li>
      <p>Assert: <var>event</var>'s <a href="#concept-navigateevent-navigation-precommit-handler-list" id="navigate-event-scroll-focus:concept-navigateevent-navigation-precommit-handler-list">navigation precommit handler
      list</a> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="navigate-event-scroll-focus:list-is-empty" data-x-internal="list-is-empty">is not empty</a>.</p>

      <p class="note">Only precommit handlers can cancel a navigation before it is committed.</p>
     </li><li><p>Set <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state-3">interception state</a> to "<code>finished</code>".</p></li><li><p>Return.</p></li></ol>

   </li><li><p>If <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state-4">interception
   state</a> is "<code>none</code>", then return.</p></li><li><p><a href="#potentially-reset-the-focus" id="navigate-event-scroll-focus:potentially-reset-the-focus">Potentially reset the focus</a> given <var>event</var>.</p></li><li><p>If <var>didFulfill</var> is true, then <a href="#potentially-process-scroll-behavior" id="navigate-event-scroll-focus:potentially-process-scroll-behavior">potentially process scroll behavior</a>
   given <var>event</var>.</p></li><li><p>Set <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state-5">interception state</a> to "<code>finished</code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="potentially-reset-the-focus">potentially reset the focus</dfn> given a <code id="navigate-event-scroll-focus:navigateevent-2"><a href="#navigateevent">NavigateEvent</a></code>
  <var>event</var>:</p>

  <ol><li><p><a id="navigate-event-scroll-focus:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state-6">interception state</a> is "<code>committed</code>" or "<code>scrolled</code>".</p></li><li><p>Let <var>navigation</var> be <var>event</var>'s <a href="#concept-relevant-global" id="navigate-event-scroll-focus:concept-relevant-global">relevant global object</a>'s
   <a href="#window-navigation-api" id="navigate-event-scroll-focus:window-navigation-api">navigation API</a>.</p></li><li><p>Let <var>focusChanged</var> be <var>navigation</var>'s <a href="#focus-changed-during-ongoing-navigation" id="navigate-event-scroll-focus:focus-changed-during-ongoing-navigation">focus changed during ongoing
   navigation</a>.</p></li><li><p>Set <var>navigation</var>'s <a href="#focus-changed-during-ongoing-navigation" id="navigate-event-scroll-focus:focus-changed-during-ongoing-navigation-2">focus changed during ongoing navigation</a> to
   false.</p></li><li><p>If <var>focusChanged</var> is true, then return.</p></li><li>
    <p>If <var>event</var>'s <a href="#concept-navigateevent-focusreset" id="navigate-event-scroll-focus:concept-navigateevent-focusreset">focus reset
    behavior</a> is "<code id="navigate-event-scroll-focus:dom-navigationfocusreset-manual"><a href="#dom-navigationfocusreset-manual">manual</a></code>", then
    return.</p>

    <p class="note">If it was left as null, then we treat that as "<code id="navigate-event-scroll-focus:dom-navigationfocusreset-after-transition"><a href="#dom-navigationfocusreset-after-transition">after-transition</a></code>", and continue
    onward.</p>
   </li><li><p>Let <var>document</var> be <var>event</var>'s <a href="#concept-relevant-global" id="navigate-event-scroll-focus:concept-relevant-global-2">relevant global object</a>'s <a href="#concept-document-window" id="navigate-event-scroll-focus:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>Let <var>focusTarget</var> be the <a href="#autofocus-delegate" id="navigate-event-scroll-focus:autofocus-delegate">autofocus delegate</a> for
   <var>document</var>.</p></li><li><p>If <var>focusTarget</var> is null, then set <var>focusTarget</var> to
   <var>document</var>'s <a href="#the-body-element-2" id="navigate-event-scroll-focus:the-body-element-2">body element</a>.</p></li><li><p>If <var>focusTarget</var> is null, then set <var>focusTarget</var> to
   <var>document</var>'s <a id="navigate-event-scroll-focus:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>.</p></li><li><p>Run the <a href="#focusing-steps" id="navigate-event-scroll-focus:focusing-steps">focusing steps</a> for <var>focusTarget</var>, with <var>document</var>'s
   <a id="navigate-event-scroll-focus:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> as the <i>fallback target</i>.</p></li><li><p>Move the <a href="#sequential-focus-navigation-starting-point" id="navigate-event-scroll-focus:sequential-focus-navigation-starting-point">sequential focus navigation starting point</a> to
   <var>focusTarget</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="potentially-process-scroll-behavior">potentially process scroll behavior</dfn> given a <code id="navigate-event-scroll-focus:navigateevent-3"><a href="#navigateevent">NavigateEvent</a></code>
  <var>event</var>:</p>

  <ol><li><p><a id="navigate-event-scroll-focus:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state-7">interception state</a> is "<code>committed</code>" or "<code>scrolled</code>".</p></li><li><p>If <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state-8">interception
   state</a> is "<code>scrolled</code>", then return.</p></li><li>
    <p>If <var>event</var>'s <a href="#concept-navigateevent-scroll" id="navigate-event-scroll-focus:concept-navigateevent-scroll">scroll behavior</a> is
    "<code id="navigate-event-scroll-focus:dom-navigationscrollbehavior-manual"><a href="#dom-navigationscrollbehavior-manual">manual</a></code>", then return.</p>

    <p class="note">If it was left as null, then we treat that as "<code id="navigate-event-scroll-focus:dom-navigationscrollbehavior-after-transition"><a href="#dom-navigationscrollbehavior-after-transition">after-transition</a></code>", and continue
    onward.</p>
   </li><li><p><a href="#process-scroll-behavior" id="navigate-event-scroll-focus:process-scroll-behavior">Process scroll behavior</a> given <var>event</var>.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="process-scroll-behavior">process scroll behavior</dfn> given a <code id="navigate-event-scroll-focus:navigateevent-4"><a href="#navigateevent">NavigateEvent</a></code> <var>event</var>:</p>

  <ol><li><p><a id="navigate-event-scroll-focus:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state-9">interception state</a> is "<code>committed</code>".</p></li><li><p>Set <var>event</var>'s <a href="#concept-navigateevent-interception-state" id="navigate-event-scroll-focus:concept-navigateevent-interception-state-10">interception state</a> to "<code>scrolled</code>".</p></li><li><p>If <var>event</var>'s <code id="navigate-event-scroll-focus:dom-navigateevent-navigationtype"><a href="#dom-navigateevent-navigationtype">navigationType</a></code> was initialized to "<code id="navigate-event-scroll-focus:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>" or "<code id="navigate-event-scroll-focus:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>", then <a href="#restore-scroll-position-data" id="navigate-event-scroll-focus:restore-scroll-position-data">restore scroll position data</a>
   given <var>event</var>'s <a href="#concept-relevant-global" id="navigate-event-scroll-focus:concept-relevant-global-3">relevant global object</a>'s <a href="#window-navigable" id="navigate-event-scroll-focus:window-navigable">navigable</a>'s <a href="#nav-active-history-entry" id="navigate-event-scroll-focus:nav-active-history-entry">active session history
   entry</a>.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>document</var> be <var>event</var>'s <a href="#concept-relevant-global" id="navigate-event-scroll-focus:concept-relevant-global-4">relevant global object</a>'s
     <a href="#concept-document-window" id="navigate-event-scroll-focus:concept-document-window-2">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var>'s <a href="#the-indicated-part-of-the-document" id="navigate-event-scroll-focus:the-indicated-part-of-the-document">indicated part</a> is null, then <a id="navigate-event-scroll-focus:scroll-to-the-beginning-of-the-document" href="https://drafts.csswg.org/cssom-view/#scroll-to-the-beginning-of-the-document" data-x-internal="scroll-to-the-beginning-of-the-document">scroll to the
     beginning of the document</a> given <var>document</var>. <a href="#refsCSSOMVIEW">[CSSOMVIEW]</a></p></li><li><p>Otherwise, <a href="#scroll-to-the-fragment-identifier" id="navigate-event-scroll-focus:scroll-to-the-fragment-identifier">scroll to the fragment</a> given <var>document</var>.</p></li></ol>
   </li></ol>
  </div>

  

  <h4 id="nav-traversal-event-interfaces"><span class="secno">7.2.7</span> Event interfaces<a href="#nav-traversal-event-interfaces" class="self-link"></a></h4>

  <p class="note">The <code id="nav-traversal-event-interfaces:navigateevent"><a href="#navigateevent">NavigateEvent</a></code> interface has <a href="#the-navigate-event">its own
  dedicated section</a>, due to its complexity.</p>


  <h5 id="the-navigationcurrententrychangeevent-interface"><span class="secno">7.2.7.1</span> The <code id="the-navigationcurrententrychangeevent-interface:navigationcurrententrychangeevent"><a href="#navigationcurrententrychangeevent">NavigationCurrentEntryChangeEvent</a></code> interface<a href="#the-navigationcurrententrychangeevent-interface" class="self-link"></a></h5>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="navigationcurrententrychangeevent" data-dfn-type="interface"><c- g="">NavigationCurrentEntryChangeEvent</c-></dfn> : <a id="the-navigationcurrententrychangeevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <a href="#navigationcurrententrychangeeventinit" id="the-navigationcurrententrychangeevent-interface:navigationcurrententrychangeeventinit"><c- n="">NavigationCurrentEntryChangeEventInit</c-></a> <c- g="">eventInitDict</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationtype" id="the-navigationcurrententrychangeevent-interface:navigationtype"><c- n="">NavigationType</c-></a>? <a href="#dom-navigationcurrententrychangeevent-navigationtype" id="the-navigationcurrententrychangeevent-interface:dom-navigationcurrententrychangeevent-navigationtype"><c- g="">navigationType</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#navigationhistoryentry" id="the-navigationcurrententrychangeevent-interface:navigationhistoryentry"><c- n="">NavigationHistoryEntry</c-></a> <a href="#dom-navigationcurrententrychangeevent-from" id="the-navigationcurrententrychangeevent-interface:dom-navigationcurrententrychangeevent-from"><c- g="">from</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="navigationcurrententrychangeeventinit" data-dfn-type="dictionary"><c- g="">NavigationCurrentEntryChangeEventInit</c-></dfn> : <a id="the-navigationcurrententrychangeevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <a href="#navigationtype" id="the-navigationcurrententrychangeevent-interface:navigationtype-2"><c- n="">NavigationType</c-></a>? <dfn data-dfn-for="NavigationCurrentEntryChangeEventInit" id="dom-navigationcurrententrychangeeventinit-navigationtype" data-dfn-type="dict-member"><c- g="">navigationType</c-></dfn> = <c- b="">null</c->;
  <c- b="">required</c-> <a href="#navigationhistoryentry" id="the-navigationcurrententrychangeevent-interface:navigationhistoryentry-2"><c- n="">NavigationHistoryEntry</c-></a> <dfn data-dfn-for="NavigationCurrentEntryChangeEventInit" id="dom-navigationcurrententrychangeeventinit-from" data-dfn-type="dict-member"><c- g="">from</c-></dfn>;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-navigationcurrententrychangeevent-navigationtype" id="dom-navigationcurrententrychangeevent-navigationtype-dev">navigationType</a></code></dt><dd><p>Returns the type of navigation which caused the current entry to change, or null if the
   change is due to <code id="the-navigationcurrententrychangeevent-interface:dom-navigation-updatecurrententry"><a href="#dom-navigation-updatecurrententry">navigation.updateCurrentEntry()</a></code>.</p></dd><dt><code><var>event</var>.<a href="#dom-navigationcurrententrychangeevent-from" id="dom-navigationcurrententrychangeevent-from-dev">from</a></code></dt><dd>
    <p>Returns the previous value of <code id="the-navigationcurrententrychangeevent-interface:dom-navigation-currententry"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code>, before the current entry
    changed.</p>

    <p>If <code id="the-navigationcurrententrychangeevent-interface:dom-navigationcurrententrychangeevent-navigationtype-2"><a href="#dom-navigationcurrententrychangeevent-navigationtype">navigationType</a></code>
    is null or "<code id="the-navigationcurrententrychangeevent-interface:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>", then this value will be the
    same as <code id="the-navigationcurrententrychangeevent-interface:dom-navigation-currententry-2"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code>. In that case,
    the event signifies that the contents of the entry changed, even if we did not move to a new
    entry or replace the current one.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigationCurrentEntryChangeEvent" id="dom-navigationcurrententrychangeevent-navigationtype" data-dfn-type="attribute"><code>navigationType</code></dfn> and <dfn data-dfn-for="NavigationCurrentEntryChangeEvent" id="dom-navigationcurrententrychangeevent-from" data-dfn-type="attribute"><code>from</code></dfn> attributes must return the
  values they were initialized to.</p>
  </div>

  


  <h5 id="the-popstateevent-interface"><span class="secno">7.2.7.2</span> The <code id="the-popstateevent-interface:popstateevent"><a href="#popstateevent">PopStateEvent</a></code> interface<a href="#the-popstateevent-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/PopStateEvent/PopStateEvent" title="The PopStateEvent() constructor creates a new PopStateEvent object.">PopStateEvent/PopStateEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>11+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>16+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/PopStateEvent" title="PopStateEvent is an interface for the popstate event.">PopStateEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="popstateevent" data-dfn-type="interface"><c- g="">PopStateEvent</c-></dfn> : <a id="the-popstateevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#popstateeventinit" id="the-popstateevent-interface:popstateeventinit"><c- n="">PopStateEventInit</c-></a> <c- g="">eventInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">any</c-> <a href="#dom-popstateevent-state" id="the-popstateevent-interface:dom-popstateevent-state"><c- g="">state</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-popstateevent-hasuavisualtransition" id="the-popstateevent-interface:dom-popstateevent-hasuavisualtransition"><c- g="">hasUAVisualTransition</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="popstateeventinit" data-dfn-type="dictionary"><c- g="">PopStateEventInit</c-></dfn> : <a id="the-popstateevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- b="">any</c-> <dfn data-dfn-for="PopStateEventInit" id="dom-popstateeventinit-state" data-dfn-type="dict-member"><c- g="">state</c-></dfn> = <c- b="">null</c->;
  <c- b="">boolean</c-> <dfn data-dfn-for="PopStateEventInit" id="dom-popstateeventinit-hasuavisualtransition" data-dfn-type="dict-member"><c- g="">hasUAVisualTransition</c-></dfn> = <c- b="">false</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-popstateevent-state" id="dom-popstateevent-state-dev">state</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/PopStateEvent/state" title="The state read-only property of the PopStateEvent interface represents the state stored when the event was created.">PopStateEvent/state</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns a copy of the information that was provided to <code id="the-popstateevent-interface:dom-history-pushstate"><a href="#dom-history-pushstate">pushState()</a></code> or <code id="the-popstateevent-interface:dom-history-replacestate"><a href="#dom-history-replacestate">replaceState()</a></code>.</p></dd><dt><code><var>event</var>.<a href="#dom-popstateevent-hasuavisualtransition" id="dom-popstateevent-hasuavisualtransition-dev">hasUAVisualTransition</a></code></dt><dd><p>Returns true if the user agent performed a visual transition for this navigation before
   dispatching this event. If true, the best user experience will be given if the author
   synchronously updates the DOM to the post-navigation state.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="PopStateEvent" id="dom-popstateevent-state" data-dfn-type="attribute"><code>state</code></dfn> attribute must return the value it was
  initialized to. It represents the context information for the event, or null, if the state
  represented is the initial state of the <code id="the-popstateevent-interface:document"><a href="#document">Document</a></code>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="PopStateEvent" id="dom-popstateevent-hasuavisualtransition" data-dfn-type="attribute"><code>
  hasUAVisualTransition</code></dfn> attribute must return the value it was initialized to.</p>
  </div>

  


  <h5 id="the-hashchangeevent-interface"><span class="secno">7.2.7.3</span> The <code id="the-hashchangeevent-interface:hashchangeevent"><a href="#hashchangeevent">HashChangeEvent</a></code> interface<a href="#the-hashchangeevent-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HashChangeEvent/HashChangeEvent" title="The HashChangeEvent() constructor creates a new HashChangeEvent object, that is used by the hashchange event fired at the window object when the fragment of the URL changes.">HashChangeEvent/HashChangeEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>11+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>16+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HashChangeEvent" title="The HashChangeEvent interface represents events that fire when the fragment identifier of the URL has changed.">HashChangeEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="hashchangeevent" data-dfn-type="interface"><c- g="">HashChangeEvent</c-></dfn> : <a id="the-hashchangeevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#hashchangeeventinit" id="the-hashchangeevent-interface:hashchangeeventinit"><c- n="">HashChangeEventInit</c-></a> <c- g="">eventInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hashchangeevent-oldurl" id="the-hashchangeevent-interface:dom-hashchangeevent-oldurl"><c- g="">oldURL</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-hashchangeevent-newurl" id="the-hashchangeevent-interface:dom-hashchangeevent-newurl"><c- g="">newURL</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="hashchangeeventinit" data-dfn-type="dictionary"><c- g="">HashChangeEventInit</c-></dfn> : <a id="the-hashchangeevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- b="">USVString</c-> <c- g="">oldURL</c-> = "";
  <c- b="">USVString</c-> <c- g="">newURL</c-> = "";
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-hashchangeevent-oldurl" id="dom-hashchangeevent-oldurl-dev">oldURL</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HashChangeEvent/oldURL" title="The oldURL read-only property of the HashChangeEvent interface returns the previous URL from which the window was navigated.">HashChangeEvent/oldURL</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a id="the-hashchangeevent-interface:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the <a href="#session-history-entry" id="the-hashchangeevent-interface:session-history-entry">session history entry</a> that was previously
    current.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-hashchangeevent-newurl" id="dom-hashchangeevent-newurl-dev">newURL</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HashChangeEvent/newURL" title="The newURL read-only property of the HashChangeEvent interface returns the new URL to which the window is navigating.">HashChangeEvent/newURL</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a id="the-hashchangeevent-interface:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the <a href="#session-history-entry" id="the-hashchangeevent-interface:session-history-entry-2">session history entry</a> that is now
    current.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HashChangeEvent" id="dom-hashchangeevent-oldurl" data-dfn-type="attribute"><code>oldURL</code></dfn> attribute must return the value it was
  initialized to. It represents context information for the event, specifically the URL of the
  <a href="#session-history-entry" id="the-hashchangeevent-interface:session-history-entry-3">session history entry</a> that was traversed from.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HashChangeEvent" id="dom-hashchangeevent-newurl" data-dfn-type="attribute"><code>newURL</code></dfn> attribute must return the value it was
  initialized to. It represents context information for the event, specifically the URL of the
  <a href="#session-history-entry" id="the-hashchangeevent-interface:session-history-entry-4">session history entry</a> that was traversed to.</p>
  </div>

  


  <h5 id="the-pageswapevent-interface"><span class="secno">7.2.7.4</span> The <code id="the-pageswapevent-interface:pageswapevent"><a href="#pageswapevent">PageSwapEvent</a></code> interface<a href="#the-pageswapevent-interface" class="self-link"></a></h5>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="pageswapevent" data-dfn-type="interface"><c- g="">PageSwapEvent</c-></dfn> : <a id="the-pageswapevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#pageswapeventinit" id="the-pageswapevent-interface:pageswapeventinit"><c- n="">PageSwapEventInit</c-></a> <c- g="">eventInitDict</c-> = {});
  <c- b="">readonly</c-> <c- b="">attribute</c-> <code id="the-pageswapevent-interface:navigationactivation"><a href="#navigationactivation"><c- n="">NavigationActivation</c-></a></code>? <a href="#dom-pageswapevent-activation" id="the-pageswapevent-interface:dom-pageswapevent-activation"><c- g="">activation</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <code id="the-pageswapevent-interface:viewtransition"><a data-x-internal="viewtransition" href="https://drafts.csswg.org/css-view-transitions/#viewtransition"><c- n="">ViewTransition</c-></a></code>? <a href="#dom-pageswapevent-viewtransition" id="the-pageswapevent-interface:dom-pageswapevent-viewtransition"><c- g="">viewTransition</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="pageswapeventinit" data-dfn-type="dictionary"><c- g="">PageSwapEventInit</c-></dfn> : <a id="the-pageswapevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <a href="#navigationactivation" id="the-pageswapevent-interface:navigationactivation-2"><c- n="">NavigationActivation</c-></a>? <dfn data-dfn-for="PageSwapEventInit" id="dom-pageswapeventinit-activation" data-dfn-type="dict-member"><c- g="">activation</c-></dfn> = <c- b="">null</c->;
  <code id="the-pageswapevent-interface:viewtransition-2"><a data-x-internal="viewtransition" href="https://drafts.csswg.org/css-view-transitions/#viewtransition"><c- n="">ViewTransition</c-></a></code>? <dfn data-dfn-for="PageSwapEventInit" id="dom-pageswapeventinit-viewtransition" data-dfn-type="dict-member"><c- g="">viewTransition</c-></dfn> = <c- b="">null</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-pageswapevent-activation" id="dom-pageswapevent-activation-dev">activation</a></code></dt><dd><p>A <code id="the-pageswapevent-interface:navigationactivation-3"><a href="#navigationactivation">NavigationActivation</a></code> object representing the destination and type of the
   cross-document navigation. This would be null for cross-origin navigations.</p></dd><dt><code><var>event</var>.<a href="#dom-pageswapevent-activation" id="the-pageswapevent-interface:dom-pageswapevent-activation-2">activation</a>.<a href="#dom-navigationactivation-entry" id="the-pageswapevent-interface:dom-navigationactivation-entry">entry</a></code></dt><dd><p>A <code id="the-pageswapevent-interface:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>, representing the <code id="the-pageswapevent-interface:document"><a href="#document">Document</a></code> that is
   about to become active.</p></dd><dt><code><var>event</var>.<a href="#dom-pageswapevent-activation" id="the-pageswapevent-interface:dom-pageswapevent-activation-3">activation</a>.<a href="#dom-navigationactivation-from" id="the-pageswapevent-interface:dom-navigationactivation-from">from</a></code></dt><dd><p>A <code id="the-pageswapevent-interface:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>, equivalent to the value of the <code id="the-pageswapevent-interface:dom-navigation-currententry"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> property at the moment the
   event is fired.</p></dd><dt><code><var>event</var>.<a href="#dom-pageswapevent-activation" id="the-pageswapevent-interface:dom-pageswapevent-activation-4">activation</a>.<a href="#dom-navigationactivation-navigationtype" id="the-pageswapevent-interface:dom-navigationactivation-navigationtype">navigationType</a></code></dt><dd><p>One of "<code id="the-pageswapevent-interface:dom-navigationtype-push"><a href="#dom-navigationtype-push">push</a></code>", "<code id="the-pageswapevent-interface:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>", "<code id="the-pageswapevent-interface:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>", or "<code id="the-pageswapevent-interface:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>", indicating what type of navigation
   that is about to result in a page swap.</p></dd><dt><code><var>event</var>.<a href="#dom-pageswapevent-viewtransition" id="dom-pageswapevent-viewtransition-dev">viewTransition</a></code></dt><dd>
    <p>Returns the <code id="the-pageswapevent-interface:viewtransition-3"><a data-x-internal="viewtransition" href="https://drafts.csswg.org/css-view-transitions/#viewtransition">ViewTransition</a></code> object that represents an outbound cross-document view
    transition, if such transition is active when the event is fired. Otherwise, returns null.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="PageSwapEvent" id="dom-pageswapevent-activation" data-dfn-type="attribute"><code>activation</code></dfn> and <dfn data-dfn-for="PageSwapEvent" id="dom-pageswapevent-viewtransition" data-dfn-type="attribute"><code>viewTransition</code></dfn> attributes must return
  the values they were initialized to.</p>
  </div>

  


  <h5 id="the-pagerevealevent-interface"><span class="secno">7.2.7.5</span> The <code id="the-pagerevealevent-interface:pagerevealevent"><a href="#pagerevealevent">PageRevealEvent</a></code> interface<a href="#the-pagerevealevent-interface" class="self-link"></a></h5>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="pagerevealevent" data-dfn-type="interface"><c- g="">PageRevealEvent</c-></dfn> : <a id="the-pagerevealevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#pagerevealeventinit" id="the-pagerevealevent-interface:pagerevealeventinit"><c- n="">PageRevealEventInit</c-></a> <c- g="">eventInitDict</c-> = {});
  <c- b="">readonly</c-> <c- b="">attribute</c-> <code id="the-pagerevealevent-interface:viewtransition"><a data-x-internal="viewtransition" href="https://drafts.csswg.org/css-view-transitions/#viewtransition"><c- n="">ViewTransition</c-></a></code>? <a href="#dom-pagerevealevent-viewtransition" id="the-pagerevealevent-interface:dom-pagerevealevent-viewtransition"><c- g="">viewTransition</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="pagerevealeventinit" data-dfn-type="dictionary"><c- g="">PageRevealEventInit</c-></dfn> : <a id="the-pagerevealevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <code id="the-pagerevealevent-interface:viewtransition-2"><a data-x-internal="viewtransition" href="https://drafts.csswg.org/css-view-transitions/#viewtransition"><c- n="">ViewTransition</c-></a></code>? <dfn data-dfn-for="PageRevealEventInit" id="dom-pagerevealeventinit-viewtransition" data-dfn-type="dict-member"><c- g="">viewTransition</c-></dfn> = <c- b="">null</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-pagerevealevent-viewtransition" id="dom-pagerevealevent-viewtransition-dev">viewTransition</a></code></dt><dd>
    <p>Returns the <code id="the-pagerevealevent-interface:viewtransition-3"><a data-x-internal="viewtransition" href="https://drafts.csswg.org/css-view-transitions/#viewtransition">ViewTransition</a></code> object that represents an inbound cross-document view
    transition, if such transition is active when the event is fired. Otherwise, returns null.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="PageRevealEvent" id="dom-pagerevealevent-viewtransition" data-dfn-type="attribute"><code>viewTransition</code></dfn> attribute must return the
  value it was initialized to.</p>
  </div>

  


  <h5 id="the-pagetransitionevent-interface"><span class="secno">7.2.7.6</span> The <code id="the-pagetransitionevent-interface:pagetransitionevent"><a href="#pagetransitionevent">PageTransitionEvent</a></code> interface<a href="#the-pagetransitionevent-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/PageTransitionEvent/PageTransitionEvent" title="The PageTransitionEvent() constructor creates a new PageTransitionEvent object, that is used by the pageshow or pagehide events, fired at the window object when a page is loaded or unloaded.">PageTransitionEvent/PageTransitionEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>11+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>16+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/PageTransitionEvent" title="The PageTransitionEvent event object is available inside handler functions for the pageshow and pagehide events, fired when a document is being loaded or unloaded.">PageTransitionEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="pagetransitionevent" data-dfn-type="interface"><c- g="">PageTransitionEvent</c-></dfn> : <a id="the-pagetransitionevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#pagetransitioneventinit" id="the-pagetransitionevent-interface:pagetransitioneventinit"><c- n="">PageTransitionEventInit</c-></a> <c- g="">eventInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-pagetransitionevent-persisted" id="the-pagetransitionevent-interface:dom-pagetransitionevent-persisted"><c- g="">persisted</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="pagetransitioneventinit" data-dfn-type="dictionary"><c- g="">PageTransitionEventInit</c-></dfn> : <a id="the-pagetransitionevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- b="">boolean</c-> <c- g="">persisted</c-> = <c- b="">false</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-pagetransitionevent-persisted" id="dom-pagetransitionevent-persisted-dev">persisted</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/PageTransitionEvent/persisted" title="The persisted read-only property indicates if a webpage is loading from a cache.">PageTransitionEvent/persisted</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>11+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>For the <code id="the-pagetransitionevent-interface:event-pageshow"><a href="#event-pageshow">pageshow</a></code> event, returns false if the page is
    newly being loaded (and the <code id="the-pagetransitionevent-interface:event-load"><a href="#event-load">load</a></code> event will fire). Otherwise,
    returns true.</p>

    <p>For the <code id="the-pagetransitionevent-interface:event-pagehide"><a href="#event-pagehide">pagehide</a></code> event, returns false if the page is
    going away for the last time. Otherwise, returns true, meaning that the page might be reused if
    the user navigates back to this page (if the <code id="the-pagetransitionevent-interface:document"><a href="#document">Document</a></code>'s <i id="the-pagetransitionevent-interface:concept-document-salvageable"><a href="#concept-document-salvageable">salvageable</a></i> state stays true). </p>

    <p>Things that can cause the page to be unsalvageable include:</p>

    <ul><li><p>The user agent decided to not keep the <code id="the-pagetransitionevent-interface:document-2"><a href="#document">Document</a></code> alive in a <a href="#session-history-entry" id="the-pagetransitionevent-interface:session-history-entry">session
     history entry</a> after <a href="#unload-a-document" id="the-pagetransitionevent-interface:unload-a-document">unload</a></p></li><li><p>Having <code id="the-pagetransitionevent-interface:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s that are not <i id="the-pagetransitionevent-interface:concept-document-salvageable-2"><a href="#concept-document-salvageable">salvageable</a></i></p></li><li><p>Active <code id="the-pagetransitionevent-interface:websocket-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code> objects</p></li><li><p><a href="#abort-a-document" id="the-pagetransitionevent-interface:abort-a-document">Aborting a <code>Document</code></a></p></li></ul>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="PageTransitionEvent" id="dom-pagetransitionevent-persisted" data-dfn-type="attribute"><code>persisted</code></dfn> attribute must return the value
  it was initialized to. It represents the context information for the event.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fire-a-page-transition-event">fire a page transition event</dfn> named <var>eventName</var> at a <code id="the-pagetransitionevent-interface:window"><a href="#window">Window</a></code>
  <var>window</var> with a boolean <var>persisted</var>, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-pagetransitionevent-interface:concept-event-fire" data-x-internal="concept-event-fire">fire
  an event</a> named <var>eventName</var> at <var>window</var>, using
  <code id="the-pagetransitionevent-interface:pagetransitionevent-2"><a href="#pagetransitionevent">PageTransitionEvent</a></code>, with the <code id="the-pagetransitionevent-interface:dom-pagetransitionevent-persisted-2"><a href="#dom-pagetransitionevent-persisted">persisted</a></code> attribute initialized to
  <var>persisted</var>, the <code id="the-pagetransitionevent-interface:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute
  initialized to true, the <code id="the-pagetransitionevent-interface:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to
  true, and <i>legacy target override flag</i> set.</p>
  </div>

  <p class="note">The values for <code id="the-pagetransitionevent-interface:dom-event-cancelable-2"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> and <code id="the-pagetransitionevent-interface:dom-event-bubbles-2"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> don't make any sense, since canceling the event does
  nothing and it's not possible to bubble past the <code id="the-pagetransitionevent-interface:window-2"><a href="#window">Window</a></code> object. They are set to true
  for historical reasons.</p>

  


  <h5 id="the-beforeunloadevent-interface"><span class="secno">7.2.7.7</span> The <code id="the-beforeunloadevent-interface:beforeunloadevent"><a href="#beforeunloadevent">BeforeUnloadEvent</a></code> interface<a href="#the-beforeunloadevent-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BeforeUnloadEvent" title="BeforeUnloadEvent is an interface for the beforeunload event.">BeforeUnloadEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>30+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>3.0+</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="beforeunloadevent" data-dfn-type="interface"><c- g="">BeforeUnloadEvent</c-></dfn> : <a id="the-beforeunloadevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-beforeunloadevent-returnvalue" id="the-beforeunloadevent-interface:dom-beforeunloadevent-returnvalue"><c- g="">returnValue</c-></a>;
};</code></pre>

  <p class="note">There are no <code id="the-beforeunloadevent-interface:beforeunloadevent-2"><a href="#beforeunloadevent">BeforeUnloadEvent</a></code>-specific initialization methods.</p>

  <p>The <code id="the-beforeunloadevent-interface:beforeunloadevent-3"><a href="#beforeunloadevent">BeforeUnloadEvent</a></code> interface is a legacy interface which allows <a href="#checking-if-unloading-is-canceled" id="the-beforeunloadevent-interface:checking-if-unloading-is-canceled">checking
  if unloading is canceled</a> to be controlled not only by canceling the event, but by setting
  the <code id="the-beforeunloadevent-interface:dom-beforeunloadevent-returnvalue-2"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code> attribute to a value
  besides the empty string. Authors should use the <code id="the-beforeunloadevent-interface:dom-event-preventdefault"><a data-x-internal="dom-event-preventdefault" href="https://dom.spec.whatwg.org/#dom-event-preventdefault">preventDefault()</a></code> method, or other means of canceling
  events, instead of using <code id="the-beforeunloadevent-interface:dom-beforeunloadevent-returnvalue-3"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code>.</p>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="BeforeUnloadEvent" id="dom-beforeunloadevent-returnvalue" data-dfn-type="attribute"><code>returnValue</code></dfn> attribute controls the process
  of <a href="#checking-if-unloading-is-canceled" id="the-beforeunloadevent-interface:checking-if-unloading-is-canceled-2">checking if unloading is canceled</a>. When the event is created, the
  attribute must be set to the empty string. On getting, it must return the last value it was set
  to. On setting, the attribute must be set to the new value.</p>
  </div>

  <p class="note">This attribute is a <code>DOMString</code> only for historical reasons.
  Any value besides the empty string will be treated as a request to ask the user for
  confirmation.</p>

  

  <h4 id="the-notrestoredreasons-interface"><span class="secno">7.2.8</span> The <code id="the-notrestoredreasons-interface:notrestoredreasons"><a href="#notrestoredreasons">NotRestoredReasons</a></code> interface<a href="#the-notrestoredreasons-interface" class="self-link"></a></h4>
  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="notrestoredreasondetails" data-dfn-type="interface"><c- g="">NotRestoredReasonDetails</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-not-restored-reason-details-reason" id="the-notrestoredreasons-interface:dom-not-restored-reason-details-reason"><c- g="">reason</c-></a>;
  [<c- g="">Default</c->] <c- b="">object</c-> <c- g="">toJSON</c->();
};

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="notrestoredreasons" data-dfn-type="interface"><c- g="">NotRestoredReasons</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c->? <a href="#dom-not-restored-reasons-src" id="the-notrestoredreasons-interface:dom-not-restored-reasons-src"><c- g="">src</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-not-restored-reasons-id" id="the-notrestoredreasons-interface:dom-not-restored-reasons-id"><c- g="">id</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-not-restored-reasons-name" id="the-notrestoredreasons-interface:dom-not-restored-reasons-name"><c- g="">name</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c->? <a href="#dom-not-restored-reasons-url" id="the-notrestoredreasons-interface:dom-not-restored-reasons-url"><c- g="">url</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">FrozenArray</c->&lt;<a href="#notrestoredreasondetails" id="the-notrestoredreasons-interface:notrestoredreasondetails"><c- n="">NotRestoredReasonDetails</c-></a>&gt;? <a href="#dom-not-restored-reasons-reasons" id="the-notrestoredreasons-interface:dom-not-restored-reasons-reasons"><c- g="">reasons</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">FrozenArray</c->&lt;<a href="#notrestoredreasons" id="the-notrestoredreasons-interface:notrestoredreasons-2"><c- n="">NotRestoredReasons</c-></a>&gt;? <a href="#dom-not-restored-reasons-children" id="the-notrestoredreasons-interface:dom-not-restored-reasons-children"><c- g="">children</c-></a>;
  [<c- g="">Default</c->] <c- b="">object</c-> <c- g="">toJSON</c->();
};</code></pre>

  <dl class="domintro"><dt><code><var>notRestoredReasonDetails</var>.<a href="#dom-not-restored-reason-details-reason" id="dom-not-restored-reason-details-reason-dev">reason</a></code></dt><dd><p>Returns a string that explains the reason that prevented the document from <a href="#note-bfcache">being served from back/forward cache</a>. See the definition of <a href="#concept-document-bfcache-blocking-details" id="the-notrestoredreasons-interface:concept-document-bfcache-blocking-details">bfcache blocking details</a> for the
   possible string values.</p></dd><dt><code><var>notRestoredReasons</var>.<a href="#dom-not-restored-reasons-src" id="dom-not-restored-reasons-src-dev">src</a></code></dt><dd><p>Returns the <code id="the-notrestoredreasons-interface:attr-iframe-src"><a href="#attr-iframe-src">src</a></code> attribute of the document's <a href="#node-navigable" id="the-notrestoredreasons-interface:node-navigable">node
   navigable</a>'s <a href="#nav-container" id="the-notrestoredreasons-interface:nav-container">container</a> if it is an <code id="the-notrestoredreasons-interface:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>
   element. This can be null if not set or if it is not an <code id="the-notrestoredreasons-interface:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> element.</p></dd><dt><code><var>notRestoredReasons</var>.<a href="#dom-not-restored-reasons-id" id="dom-not-restored-reasons-id-dev">id</a></code></dt><dd><p>Returns the <code id="the-notrestoredreasons-interface:the-id-attribute"><a href="#the-id-attribute">id</a></code> attribute of the document's <a href="#node-navigable" id="the-notrestoredreasons-interface:node-navigable-2">node
   navigable</a>'s <a href="#nav-container" id="the-notrestoredreasons-interface:nav-container-2">container</a> if it is an <code id="the-notrestoredreasons-interface:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code>
   element. This can be null if not set or if it is not an <code id="the-notrestoredreasons-interface:the-iframe-element-4"><a href="#the-iframe-element">iframe</a></code> element.</p></dd><dt><code><var>notRestoredReasons</var>.<a href="#dom-not-restored-reasons-name" id="dom-not-restored-reasons-name-dev">name</a></code></dt><dd><p>Returns the <code id="the-notrestoredreasons-interface:attr-iframe-name"><a href="#attr-iframe-name">name</a></code> attribute of the document's
   <a href="#node-navigable" id="the-notrestoredreasons-interface:node-navigable-3">node navigable</a>'s <a href="#nav-container" id="the-notrestoredreasons-interface:nav-container-3">container</a> if it is an
   <code id="the-notrestoredreasons-interface:the-iframe-element-5"><a href="#the-iframe-element">iframe</a></code> element. This can be null if not set or if it is not an <code id="the-notrestoredreasons-interface:the-iframe-element-6"><a href="#the-iframe-element">iframe</a></code>
   element.</p></dd><dt><code><var>notRestoredReasons</var>.<a href="#dom-not-restored-reasons-url" id="dom-not-restored-reasons-url-dev">url</a></code></dt><dd><p>Returns the document's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-notrestoredreasons-interface:the-document's-address" data-x-internal="the-document's-address">URL</a>, or null if the
   document is in a cross-origin <code id="the-notrestoredreasons-interface:the-iframe-element-7"><a href="#the-iframe-element">iframe</a></code>. This is reported in addition to <code id="the-notrestoredreasons-interface:dom-not-restored-reasons-src-2"><a href="#dom-not-restored-reasons-src">src</a></code> because it is possible <code id="the-notrestoredreasons-interface:the-iframe-element-8"><a href="#the-iframe-element">iframe</a></code>
   navigated since the original <code id="the-notrestoredreasons-interface:attr-iframe-src-2"><a href="#attr-iframe-src">src</a></code> was set.</p></dd><dt><code><var>notRestoredReasons</var>.<a href="#dom-not-restored-reasons-reasons" id="dom-not-restored-reasons-reasons-dev">reasons</a></code></dt><dd><p>Returns an array of <code id="the-notrestoredreasons-interface:notrestoredreasondetails-2"><a href="#notrestoredreasondetails">NotRestoredReasonDetails</a></code> for the document. This is null
   if the document is in a cross-origin <code id="the-notrestoredreasons-interface:the-iframe-element-9"><a href="#the-iframe-element">iframe</a></code>.</p></dd><dt><code><var>notRestoredReasons</var>.<a href="#dom-not-restored-reasons-children" id="dom-not-restored-reasons-children-dev">children</a></code></dt><dd><p>Returns an array of <code id="the-notrestoredreasons-interface:notrestoredreasons-3"><a href="#notrestoredreasons">NotRestoredReasons</a></code> that are for the document’s
   children. This is null if the document is in a cross-origin <code id="the-notrestoredreasons-interface:the-iframe-element-10"><a href="#the-iframe-element">iframe</a></code>.</p></dd></dl>

  <p>A <code id="the-notrestoredreasons-interface:notrestoredreasondetails-3"><a href="#notrestoredreasondetails">NotRestoredReasonDetails</a></code> object has a <dfn id="concept-not-restored-reason-details-backing-struct">backing struct</dfn>, a <a href="#nrr-details-struct" id="the-notrestoredreasons-interface:nrr-details-struct">not restored reason details</a> or null, initially null.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NotRestoredReasonDetails" id="dom-not-restored-reason-details-reason" data-dfn-type="attribute"><code>reason</code></dfn> getter steps are to return
  <a id="the-notrestoredreasons-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-not-restored-reason-details-backing-struct" id="the-notrestoredreasons-interface:concept-not-restored-reason-details-backing-struct">backing struct</a>'s <a href="#nrr-details-reason" id="the-notrestoredreasons-interface:nrr-details-reason">reason</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="create-a-notrestoredreasondetails-object">create a <code>NotRestoredReasonDetails</code> object</dfn> given a <a href="#nrr-details-struct" id="the-notrestoredreasons-interface:nrr-details-struct-2">not restored reason details</a> <var>backingStruct</var> and a
  <a id="the-notrestoredreasons-interface:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> <var>realm</var>:</p>

  <ol><li><p>Let <var>notRestoredReasonDetails</var> be a new <code id="the-notrestoredreasons-interface:notrestoredreasondetails-4"><a href="#notrestoredreasondetails">NotRestoredReasonDetails</a></code>
   object created in <var>realm</var>.</p></li><li><p>Set <var>notRestoredReasonDetails</var>'s <a href="#concept-not-restored-reason-details-backing-struct" id="the-notrestoredreasons-interface:concept-not-restored-reason-details-backing-struct-2">backing struct</a> to
   <var>backingStruct</var>.</p></li><li><p>Return <var>notRestoredReasonDetails</var>.</p></li></ol>
  </div>

  <p>A <dfn id="nrr-details-struct" data-export="">not restored reason details</dfn> is a
  <a id="the-notrestoredreasons-interface:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="the-notrestoredreasons-interface:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="nrr-details-reason">reason</dfn>, a string, initially empty.</p></li></ul>

  <p>The <a href="#nrr-details-reason" id="the-notrestoredreasons-interface:nrr-details-reason-2">reason</a> is a string that represents the reason that
  prevented the page from being restored from <a href="#note-bfcache">back/forward cache</a>.
  The string is one of the following:</p>

  <dl><dt>"<dfn id="blocking-fetch"><code>fetch</code></dfn>"</dt><dd>While <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document">unloading</a>, a fetch initiated by this
   <code id="the-notrestoredreasons-interface:document"><a href="#document">Document</a></code> was still ongoing and was canceled, so the page was not in a state that
   could be stored in the <a href="#note-bfcache">back/forward cache</a>.</dd><dt>"<dfn id="blocking-navigation-failure"><code>navigation-failure</code></dfn>"</dt><dd>The original navigation that created this <code id="the-notrestoredreasons-interface:document-2"><a href="#document">Document</a></code> errored, so storing the
   resulting error document in the <a href="#note-bfcache">back/forward cache</a> was
   prevented.</dd><dt>"<dfn id="blocking-parser-aborted"><code>parser-aborted</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-3"><a href="#document">Document</a></code> never finished its initial HTML parsing, so storing the unfinished
   document in the <a href="#note-bfcache">back/forward cache</a> was prevented.</dd><dt>"<dfn id="blocking-websocket"><code>websocket</code></dfn>"</dt><dd>While <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-2">unloading</a>, an open <code id="the-notrestoredreasons-interface:websocket-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code>
   connection was shut down, so the page was not in a state that could be stored in the <a href="#note-bfcache">back/forward cache</a>. <a href="#refsWEBSOCKETS">[WEBSOCKETS]</a></dd><dt>"<dfn id="blocking-weblock" data-export=""><code>lock</code></dfn>"</dt><dd>While <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-3">unloading</a>, held <a id="the-notrestoredreasons-interface:locks" href="https://w3c.github.io/web-locks/#lock-concept" data-x-internal="locks">locks</a> and
   <a id="the-notrestoredreasons-interface:lock-requests" href="https://w3c.github.io/web-locks/#lock-request" data-x-internal="lock-requests">lock requests</a> were terminated, so the page was not in a state that could be stored
   in the <a href="#note-bfcache">back/forward cache</a>. <a href="#refsWEBLOCKS">[WEBLOCKS]</a></dd><dt>"<dfn id="blocking-masked" data-export=""><code>masked</code></dfn>"</dt><dd>This <code id="the-notrestoredreasons-interface:document-4"><a href="#document">Document</a></code> has children that are in a cross-origin <code id="the-notrestoredreasons-interface:the-iframe-element-11"><a href="#the-iframe-element">iframe</a></code>, and
   they prevented <a href="#note-bfcache">back/forward cache</a>; or this <code id="the-notrestoredreasons-interface:document-5"><a href="#document">Document</a></code>
   could not be <a href="#note-bfcache">back/forward cached</a> for user agent-specific reasons, and
   the user agent has chosen not to use one of the more specific reasons from the list of <a href="#ua-specific-blocking-reasons" id="the-notrestoredreasons-interface:ua-specific-blocking-reasons">user-agent specific blocking reasons</a>.
  </dd></dl>

  <p>In addition to the list above, a user agent might choose to expose a reason that prevented the
  page from being restored from <a href="note-bfcache">back/forward cache</a> for <dfn id="ua-specific-blocking-reasons">user-agent specific blocking reasons</dfn>. These are one of
  the following strings:</p>

  <dl><dt>"<dfn id="blocking-audio-capture" data-export=""><code>audio-capture</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-6"><a href="#document">Document</a></code> requested audio capture permission by using <cite>Media Capture and
   Streams</cite>'s <code id="the-notrestoredreasons-interface:getusermedia()"><a data-x-internal="getusermedia()" href="https://w3c.github.io/mediacapture-main/getusermedia.html#dom-mediadevices-getusermedia">getUserMedia()</a></code> with audio. <a href="#refsMEDIASTREAM">[MEDIASTREAM]</a></dd><dt>"<dfn id="blocking-background-work" data-export=""><code>background-work</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-7"><a href="#document">Document</a></code> requested background work by calling <code id="the-notrestoredreasons-interface:syncmanager"><a data-x-internal="syncmanager" href="https://wicg.github.io/background-sync/spec/#syncmanager">SyncManager</a></code>'s
   <code id="the-notrestoredreasons-interface:dom-syncmanager-register"><a data-x-internal="dom-syncmanager-register" href="https://wicg.github.io/background-sync/spec/#dom-syncmanager-register">register()</a></code> method,
   <code id="the-notrestoredreasons-interface:periodicsyncmanager"><a data-x-internal="periodicsyncmanager" href="https://wicg.github.io/periodic-background-sync/#periodicsyncmanager">PeriodicSyncManager</a></code>'s <code id="the-notrestoredreasons-interface:dom-periodicsyncmanager-register"><a data-x-internal="dom-periodicsyncmanager-register" href="https://wicg.github.io/periodic-background-sync/#dom-periodicsyncmanager-register">register()</a></code> method, or
   <code id="the-notrestoredreasons-interface:backgroundfetchmanager"><a data-x-internal="backgroundfetchmanager" href="https://wicg.github.io/background-fetch/#backgroundfetchmanager">BackgroundFetchManager</a></code>'s <code id="the-notrestoredreasons-interface:dom-backgroundfetchmanager-fetch"><a data-x-internal="dom-backgroundfetchmanager-fetch" href="https://wicg.github.io/background-fetch/#dom-backgroundfetchmanager-fetch">fetch()</a></code> method.</dd><dt>"<dfn id="blocking-broadcastchannel-message" data-export=""><code>broadcastchannel-message</code></dfn>"</dt><dd>While the page was stored in <a href="#note-bfcache">back/forward cache</a>, a
   <code id="the-notrestoredreasons-interface:broadcastchannel"><a href="#broadcastchannel">BroadcastChannel</a></code> connection on the page received a message and <code id="the-notrestoredreasons-interface:event-message"><a href="#event-message">message</a></code> event was fired.</dd><dt>"<dfn id="blocking-idb-event" data-export=""><code>idbversionchangeevent</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-8"><a href="#document">Document</a></code> had a pending <code id="the-notrestoredreasons-interface:idbversionchangeevent"><a data-x-internal="idbversionchangeevent" href="https://w3c.github.io/IndexedDB/#idbversionchangeevent">IDBVersionChangeEvent</a></code> while <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-4">unloading</a>. <a href="#refsINDEXEDDB">[INDEXEDDB]</a></dd><dt>"<dfn id="blocking-idledetector" data-export=""><code>idledetector</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-9"><a href="#document">Document</a></code> had an active <code id="the-notrestoredreasons-interface:idledetector"><a data-x-internal="idledetector" href="https://wicg.github.io/idle-detection/#idledetector">IdleDetector</a></code> while <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-5">unloading</a>.</dd><dt>"<dfn id="blocking-keyboard-lock" data-export=""><code>keyboardlock</code></dfn>"</dt><dd>While <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-6">unloading</a>, keyboard lock was still active
   because <code id="the-notrestoredreasons-interface:keyboard"><a data-x-internal="keyboard" href="https://wicg.github.io/keyboard-lock/#keyboard">Keyboard</a></code>'s <code id="the-notrestoredreasons-interface:dom-keyboard-lock"><a data-x-internal="dom-keyboard-lock" href="https://wicg.github.io/keyboard-lock/#dom-keyboard-lock">lock()</a></code> method was
   called.</dd><dt>"<dfn id="blocking-mediastream" data-export=""><code>mediastream</code></dfn>"</dt><dd>A <code id="the-notrestoredreasons-interface:mediastreamtrack"><a data-x-internal="mediastreamtrack" href="https://w3c.github.io/mediacapture-main/getusermedia.html#mediastreamtrack">MediaStreamTrack</a></code> was in the <a id="the-notrestoredreasons-interface:live-state" href="https://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-MediaStreamTrackState.live" data-x-internal="live-state">live state</a> upon <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-7">unloading</a>. <a href="#refsMEDIASTREAM">[MEDIASTREAM]</a></dd><dt>"<dfn id="blocking-midi" data-export=""><code>midi</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-10"><a href="#document">Document</a></code> requested a MIDI permission by calling <code id="the-notrestoredreasons-interface:dom-navigator-requestmidiaccess"><a data-x-internal="dom-navigator-requestmidiaccess" href="https://webaudio.github.io/web-midi-api/#dom-navigator-requestmidiaccess">navigator.requestMIDIAccess()</a></code>.</dd><dt>"<dfn id="blocking-modals" data-export=""><code>modals</code></dfn>"</dt><dd><a href="#user-prompts">User prompts</a> were shown while <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-8">
   unloading</a>.</dd><dt>"<dfn id="blocking-navigating" data-export=""><code>navigating</code></dfn>"</dt><dd>While <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-9">unloading</a>, loading was still ongoing, and so
   the <code id="the-notrestoredreasons-interface:document-11"><a href="#document">Document</a></code> was not in a state that could be stored in <a href="#note-bfcache">back/forward cache</a>.</dd><dt>"<dfn id="blocking-navigation-canceled" data-export=""><code>navigation-canceled</code></dfn>"</dt><dd>The navigation request was canceled by calling <code id="the-notrestoredreasons-interface:dom-window-stop"><a href="#dom-window-stop">window.stop()</a></code> and the page was not in a state to be stored in <a href="note-bfcache">back/forward cache</a>.</dd><dt>"<dfn id="blocking-non-trivial-bcg" data-export=""><code>non-trivial-browsing-context-group</code></dfn>"</dt><dd>The <a href="#browsing-context-group" id="the-notrestoredreasons-interface:browsing-context-group">browsing context group</a> of this <code id="the-notrestoredreasons-interface:document-12"><a href="#document">Document</a></code> had more than one
   <a href="#top-level-browsing-context" id="the-notrestoredreasons-interface:top-level-browsing-context">top-level browsing context</a>.</dd><dt>"<dfn id="blocking-otp" data-export=""><code>otpcredential</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-13"><a href="#document">Document</a></code> created an <code id="the-notrestoredreasons-interface:otpcredential"><a data-x-internal="otpcredential" href="https://wicg.github.io/web-otp/#otpcredential">OTPCredential</a></code>.</dd><dt>"<dfn id="blocking-outstanding-network-request" data-export=""><code>outstanding-network-request</code></dfn>"</dt><dd>While <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-10">unloading</a>, the <code id="the-notrestoredreasons-interface:document-14"><a href="#document">Document</a></code> had
   outstanding network requests and was not in a state that could be stored in <a href="#note-bfcache">back/forward cache</a>.</dd><dt>"<dfn id="blocking-payment" data-export=""><code>paymentrequest</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-15"><a href="#document">Document</a></code> had an active <code id="the-notrestoredreasons-interface:paymentrequest"><a data-x-internal="paymentrequest" href="https://w3c.github.io/payment-request/#dom-paymentrequest">PaymentRequest</a></code> while <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-11">unloading</a>. <a href="#refsPAYMENTREQUEST">[PAYMENTREQUEST]</a></dd><dt>"<dfn id="blocking-picture-in-picture" data-export=""><code>pictureinpicturewindow</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-16"><a href="#document">Document</a></code> had an active <code id="the-notrestoredreasons-interface:pictureinpicturewindow"><a data-x-internal="pictureinpicturewindow" href="https://w3c.github.io/picture-in-picture/#pictureinpicturewindow">PictureInPictureWindow</a></code> while <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-12">unloading</a>. <a href="#refsPICTUREINPICTURE">[PICTUREINPICTURE]</a></dd><dt>"<dfn id="blocking-plugins" data-export=""><code>plugins</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-17"><a href="#document">Document</a></code> contained <a href="#plugin" id="the-notrestoredreasons-interface:plugin">plugins</a>.</dd><dt>"<dfn id="blocking-method-not-get" data-export=""><code>request-method-not-get</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-18"><a href="#document">Document</a></code> was created from an HTTP request whose <a href="https://fetch.spec.whatwg.org/#concept-request-method" id="the-notrestoredreasons-interface:concept-request-method" data-x-internal="concept-request-method">method</a> was not `<code>GET</code>`.
   <a href="#refsFETCH">[FETCH]</a></dd><dt>"<dfn id="blocking-auth-required" data-export=""><code>response-auth-required</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-19"><a href="#document">Document</a></code> was created from an HTTP response that required HTTP
   authentication.</dd><dt>"<dfn id="blocking-ccns" data-export=""><code>response-cache-control-no-store</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-20"><a href="#document">Document</a></code> was created from an HTTP response whose `<code id="the-notrestoredreasons-interface:http-cache-control"><a data-x-internal="http-cache-control" href="https://httpwg.org/specs/rfc7234.html#header.cache-control">Cache-Control</a></code>` header included the "<code>no-store</code>" token. <a href="#refsHTTP">[HTTP]</a></dd><dt>"<dfn id="blocking-ccnc" data-export=""><code>response-cache-control-no-cache</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-21"><a href="#document">Document</a></code> was created from an HTTP response whose `<code id="the-notrestoredreasons-interface:http-cache-control-2"><a data-x-internal="http-cache-control" href="https://httpwg.org/specs/rfc7234.html#header.cache-control">Cache-Control</a></code>` header included the "<code>no-cache</code>" token. <a href="#refsHTTP">[HTTP]</a></dd><dt>"<dfn id="blocking-keepalive" data-export=""><code>response-keep-alive</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-22"><a href="#document">Document</a></code> was created from an HTTP response that contained a `<code>Keep-Alive</code>` header.</dd><dt>"<dfn id="blocking-not-http-https" data-export=""><code>response-scheme-not-http-or-https</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-23"><a href="#document">Document</a></code> was created from a response whose <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="the-notrestoredreasons-interface:concept-response-url" data-x-internal="concept-response-url">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="the-notrestoredreasons-interface:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> was
   not an <a id="the-notrestoredreasons-interface:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>. <a href="#refsFETCH">[FETCH]</a></dd><dt>"<dfn id="blocking-response-not-ok" data-export=""><code>response-status-not-ok</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-24"><a href="#document">Document</a></code> was created from an HTTP response whose <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="the-notrestoredreasons-interface:concept-response-status" data-x-internal="concept-response-status">status</a> was not an <a id="the-notrestoredreasons-interface:ok-status" href="https://fetch.spec.whatwg.org/#ok-status" data-x-internal="ok-status">ok status</a>.
   <a href="#refsFETCH">[FETCH]</a></dd><dt>"<dfn id="blocking-rtc" data-export=""><code>rtc</code></dfn>"</dt><dd>While <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-13">unloading</a>, a <code id="the-notrestoredreasons-interface:rtcpeerconnection"><a data-x-internal="rtcpeerconnection" href="https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection">RTCPeerConnection</a></code> or
   <code id="the-notrestoredreasons-interface:rtcdatachannel"><a data-x-internal="rtcdatachannel" href="https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel">RTCDataChannel</a></code> was shut down, so the page was not in a state that could be stored in
   the <a href="#note-bfcache">back/forward cache</a>. <a href="#refsWEBRTC">[WEBRTC]</a></dd><dt>"<dfn id="blocking-rtc-used-with-ccns" data-export=""><code>rtc-used-with-cache-control-no-store</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-25"><a href="#document">Document</a></code> was created from an HTTP response whose
   `<code id="the-notrestoredreasons-interface:http-cache-control-3"><a data-x-internal="http-cache-control" href="https://httpwg.org/specs/rfc7234.html#header.cache-control">Cache-Control</a></code>` header included the
   "<code>no-store</code>" token, and it has created a <code id="the-notrestoredreasons-interface:rtcpeerconnection-2"><a data-x-internal="rtcpeerconnection" href="https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection">RTCPeerConnection</a></code> or
   <code id="the-notrestoredreasons-interface:rtcdatachannel-2"><a data-x-internal="rtcdatachannel" href="https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel">RTCDataChannel</a></code> which might be used to receive sensitive information, so the page was
   not in a state that could be stored in the <a href="#note-bfcache">back/forward cache</a>.
   <a href="#refsHTTP">[HTTP]</a> <a href="#refsWEBRTC">[WEBRTC]</a></dd><dt>"<dfn id="blocking-sensors" data-export=""><code>sensors</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-26"><a href="#document">Document</a></code> <a href="https://w3c.github.io/sensors/#request-sensor-access" id="the-notrestoredreasons-interface:request-sensor-access" data-x-internal="request-sensor-access">requested sensor
   access</a>.</dd><dt>"<dfn id="sw-added" data-export=""><code>serviceworker-added</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-27"><a href="#document">Document</a></code>'s <a href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client" id="the-notrestoredreasons-interface:serviceworkercontainer-service-worker-client" data-x-internal="serviceworkercontainer-service-worker-client">service worker client</a> started to be
   <a href="https://w3c.github.io/ServiceWorker/#dfn-control" id="the-notrestoredreasons-interface:dfn-control" data-x-internal="dfn-control">controlled</a> by a <code id="the-notrestoredreasons-interface:serviceworker"><a data-x-internal="serviceworker" href="https://w3c.github.io/ServiceWorker/#serviceworker">ServiceWorker</a></code> while the page was
   in <a href="#note-bfcache">back/forward cache</a>. <a href="#refsSW">[SW]</a></dd><dt>"<dfn id="sw-claimed" data-export=""><code>serviceworker-claimed</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-28"><a href="#document">Document</a></code>'s <a href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client" id="the-notrestoredreasons-interface:serviceworkercontainer-service-worker-client-2" data-x-internal="serviceworkercontainer-service-worker-client">service worker client</a>'s <a href="#concept-environment-active-service-worker" id="the-notrestoredreasons-interface:concept-environment-active-service-worker">active service worker</a> was claimed while
   the page was in <a href="#note-bfcache">back/forward cache</a>. <a href="#refsSW">[SW]</a></dd><dt>"<dfn id="blocking-sw-message" data-export=""><code>serviceworker-postmessage</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-29"><a href="#document">Document</a></code>'s <a href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client" id="the-notrestoredreasons-interface:serviceworkercontainer-service-worker-client-3" data-x-internal="serviceworkercontainer-service-worker-client">service worker client</a>'s <a href="#concept-environment-active-service-worker" id="the-notrestoredreasons-interface:concept-environment-active-service-worker-2">active service worker</a> received a
   message while the page was in <a href="#note-bfcache">back/forward cache</a>. <a href="#refsSW">[SW]</a></dd><dt>"<dfn id="blocking-sw-activation" data-export=""><code>serviceworker-version-activated</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-30"><a href="#document">Document</a></code>'s <a href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client" id="the-notrestoredreasons-interface:serviceworkercontainer-service-worker-client-4" data-x-internal="serviceworkercontainer-service-worker-client">service worker client</a>'s <a href="#concept-environment-active-service-worker" id="the-notrestoredreasons-interface:concept-environment-active-service-worker-3">active service worker</a>'s version was
   activated while the page was in <a href="#note-bfcache">back/forward cache</a>.
   <a href="#refsSW">[SW]</a></dd><dt>"<dfn id="blocking-sw-unregistered" data-export=""><code>serviceworker-unregistered</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-31"><a href="#document">Document</a></code>'s <a href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client" id="the-notrestoredreasons-interface:serviceworkercontainer-service-worker-client-5" data-x-internal="serviceworkercontainer-service-worker-client">service worker client</a>'s <a href="#concept-environment-active-service-worker" id="the-notrestoredreasons-interface:concept-environment-active-service-worker-4">active service worker</a>'s <a id="the-notrestoredreasons-interface:service-worker-registration" href="https://w3c.github.io/service-workers/#dfn-service-worker-registration" data-x-internal="service-worker-registration">service
   worker registration</a> was <a href="https://w3c.github.io/service-workers/#navigator-service-worker-unregister" id="the-notrestoredreasons-interface:service-worker-unregister" data-x-internal="service-worker-unregister">unregistered</a> while
   the page was in <a href="#note-bfcache">back/forward cache</a>. <a href="#refsSW">[SW]</a></dd><dt>"<dfn id="blocking-sharedworker" data-export=""><code>sharedworker</code></dfn>"</dt><dd>This <code id="the-notrestoredreasons-interface:document-32"><a href="#document">Document</a></code> was in the <a href="#concept-WorkerGlobalScope-owner-set" id="the-notrestoredreasons-interface:concept-WorkerGlobalScope-owner-set">owner set</a> of a
   <code id="the-notrestoredreasons-interface:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code>.</dd><dt>"<dfn id="blocking-smartcard" data-export=""><code>smartcardconnection</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-33"><a href="#document">Document</a></code> had an active <code id="the-notrestoredreasons-interface:smartcardconnection"><a data-x-internal="smartcardconnection" href="https://wicg.github.io/web-smart-card/#dom-smartcardconnection">SmartCardConnection</a></code> while <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-14">unloading</a>.</dd><dt>"<dfn id="blocking-speech-reco" data-export=""><code>speechrecognition</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-34"><a href="#document">Document</a></code> had an active <code id="the-notrestoredreasons-interface:speechrecognition"><a data-x-internal="speechrecognition" href="https://wicg.github.io/speech-api/#speechrecognition">SpeechRecognition</a></code> while <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-15">unloading</a>.</dd><dt>"<dfn id="blocking-storage" data-export=""><code>storageaccess</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-35"><a href="#document">Document</a></code> requested storage access permission by using the Storage Access
   API.</dd><dt>"<dfn id="blocking-unload" data-export=""><code>unload-listener</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-36"><a href="#document">Document</a></code> registered an <a id="the-notrestoredreasons-interface:event-listener" href="https://dom.spec.whatwg.org/#concept-event-listener" data-x-internal="event-listener">event listener</a> for the <code id="the-notrestoredreasons-interface:event-unload"><a href="#event-unload">unload</a></code> event.</dd><dt>"<dfn id="blocking-video-capture" data-export=""><code>video-capture</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-37"><a href="#document">Document</a></code> requested video capture permission by using <cite>Media Capture and
   Streams</cite>'s <code id="the-notrestoredreasons-interface:getusermedia()-2"><a data-x-internal="getusermedia()" href="https://w3c.github.io/mediacapture-main/getusermedia.html#dom-mediadevices-getusermedia">getUserMedia()</a></code> with video. <a href="#refsMEDIASTREAM">[MEDIASTREAM]</a></dd><dt>"<dfn id="blocking-webhid" data-export=""><code>webhid</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-38"><a href="#document">Document</a></code> called the WebHID API's <code id="the-notrestoredreasons-interface:request-device"><a data-x-internal="request-device" href="https://wicg.github.io/webhid/#requestdevice-method">requestDevice()</a></code> method.</dd><dt>"<dfn id="blocking-webshare" data-export=""><code>webshare</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-39"><a href="#document">Document</a></code> used the Web Share API's <code id="the-notrestoredreasons-interface:dom-navigator-share"><a data-x-internal="dom-navigator-share" href="https://w3c.github.io/web-share/#share-method">navigator.share()</a></code> method.</dd><dt>"<dfn id="blocking-websocket-used-with-ccns" data-export=""><code>websocket-used-with-cache-control-no-store</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-40"><a href="#document">Document</a></code> was created from an HTTP response whose
   `<code id="the-notrestoredreasons-interface:http-cache-control-4"><a data-x-internal="http-cache-control" href="https://httpwg.org/specs/rfc7234.html#header.cache-control">Cache-Control</a></code>` header included the
   "<code>no-store</code>" token, and it has created a <code id="the-notrestoredreasons-interface:websocket-2-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code> connection
   which might be used to receive sensitive information, so the page was not in a state that could be
   stored in the <a href="#note-bfcache">back/forward cache</a>. <a href="#refsHTTP">[HTTP]</a> <a href="#refsWEBSOCKETS">[WEBSOCKETS]</a></dd><dt>"<dfn id="blocking-webtransport" data-export=""><code>webtransport</code></dfn>"</dt><dd>While <a href="#unload-a-document" id="the-notrestoredreasons-interface:unload-a-document-16">unloading</a>, an open <code id="the-notrestoredreasons-interface:webtransport"><a data-x-internal="webtransport" href="https://w3c.github.io/webtransport/#webtransport">WebTransport</a></code>
   connection was shut down, so the page was not in a state that could be stored in the <a href="#note-bfcache">back/forward cache</a>. <a href="#refsWEBTRANSPORT">[WEBTRANSPORT]</a></dd><dt>"<dfn id="blocking-webtransport-used-with-ccns" data-export=""><code>webtransport-used-with-cache-control-no-store</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-41"><a href="#document">Document</a></code> was created from an HTTP response whose
   `<code id="the-notrestoredreasons-interface:http-cache-control-5"><a data-x-internal="http-cache-control" href="https://httpwg.org/specs/rfc7234.html#header.cache-control">Cache-Control</a></code>` header included the
   "<code>no-store</code>" token, and it has created a <code id="the-notrestoredreasons-interface:webtransport-2"><a data-x-internal="webtransport" href="https://w3c.github.io/webtransport/#webtransport">WebTransport</a></code> connection
   which might be used to receive sensitive information, so the page was not in a state that could be
   stored in the <a href="#note-bfcache">back/forward cache</a>. <a href="#refsHTTP">[HTTP]</a> <a href="#refsWEBTRANSPORT">[WEBTRANSPORT]</a></dd><dt>"<dfn id="blocking-webxr" data-export=""><code>webxrdevice</code></dfn>"</dt><dd>The <code id="the-notrestoredreasons-interface:document-42"><a href="#document">Document</a></code> created a <code id="the-notrestoredreasons-interface:xrsystem"><a data-x-internal="xrsystem" href="https://immersive-web.github.io/webxr/#xrsystem">XRSystem</a></code>.</dd></dl>

  <hr>

  <p>A <code id="the-notrestoredreasons-interface:notrestoredreasons-4"><a href="#notrestoredreasons">NotRestoredReasons</a></code> object has a <dfn id="concept-not-restored-reasons-backing-struct">backing struct</dfn>,
  a <a href="#nrr-struct" id="the-notrestoredreasons-interface:nrr-struct">not restored reasons</a> or null, initially null.</p>

  <p>A <code id="the-notrestoredreasons-interface:notrestoredreasons-5"><a href="#notrestoredreasons">NotRestoredReasons</a></code> object has a <dfn id="concept-not-restored-reasons-reasons">reasons array</dfn>, a
  <code>FrozenArray&lt;<code id="the-notrestoredreasons-interface:notrestoredreasondetails-5"><a href="#notrestoredreasondetails">NotRestoredReasonDetails</a></code>&gt;</code> or null,
  initially null.</p>

  <p>A <code id="the-notrestoredreasons-interface:notrestoredreasons-6"><a href="#notrestoredreasons">NotRestoredReasons</a></code> object has a <dfn id="concept-not-restored-reasons-children">children array</dfn>, a
  <code>FrozenArray&lt;<a href="#notrestoredreasons" id="the-notrestoredreasons-interface:notrestoredreasons-7">NotRestoredReasons</a>&gt;</code> or null, initially
  null.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NotRestoredReasons" id="dom-not-restored-reasons-src" data-dfn-type="attribute"><code>src</code></dfn> getter steps are to return
  <a id="the-notrestoredreasons-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-not-restored-reasons-backing-struct" id="the-notrestoredreasons-interface:concept-not-restored-reasons-backing-struct">backing struct</a>'s <a href="#nrr-src" id="the-notrestoredreasons-interface:nrr-src">src</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NotRestoredReasons" id="dom-not-restored-reasons-id" data-dfn-type="attribute"><code>id</code></dfn> getter steps are to return
  <a id="the-notrestoredreasons-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-not-restored-reasons-backing-struct" id="the-notrestoredreasons-interface:concept-not-restored-reasons-backing-struct-2">backing struct</a>'s <a href="#nrr-id" id="the-notrestoredreasons-interface:nrr-id">id</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NotRestoredReasons" id="dom-not-restored-reasons-name" data-dfn-type="attribute"><code>name</code></dfn> getter steps are to return
  <a id="the-notrestoredreasons-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-not-restored-reasons-backing-struct" id="the-notrestoredreasons-interface:concept-not-restored-reasons-backing-struct-3">backing struct</a>'s <a href="#nrr-name" id="the-notrestoredreasons-interface:nrr-name">name</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NotRestoredReasons" id="dom-not-restored-reasons-url" data-dfn-type="attribute"><code>url</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-notrestoredreasons-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-not-restored-reasons-backing-struct" id="the-notrestoredreasons-interface:concept-not-restored-reasons-backing-struct-4">backing struct</a>'s <a href="#nrr-url" id="the-notrestoredreasons-interface:nrr-url">URL</a> is null, then return null.</p></li><li><p>Return <a id="the-notrestoredreasons-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-not-restored-reasons-backing-struct" id="the-notrestoredreasons-interface:concept-not-restored-reasons-backing-struct-5">backing struct</a>'s <a href="#nrr-url" id="the-notrestoredreasons-interface:nrr-url-2">URL</a>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-notrestoredreasons-interface:concept-url-serializer" data-x-internal="concept-url-serializer">serialized</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NotRestoredReasons" id="dom-not-restored-reasons-reasons" data-dfn-type="attribute"><code>reasons</code></dfn> getter steps are to return
  <a id="the-notrestoredreasons-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-not-restored-reasons-reasons" id="the-notrestoredreasons-interface:concept-not-restored-reasons-reasons">reasons array</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NotRestoredReasons" id="dom-not-restored-reasons-children" data-dfn-type="attribute"><code>children</code></dfn> getter steps are to return
  <a id="the-notrestoredreasons-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-not-restored-reasons-children" id="the-notrestoredreasons-interface:concept-not-restored-reasons-children">children array</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="create-a-notrestoredreasons-object" data-export="">create a <code>NotRestoredReasons</code> object</dfn> given a <a href="#nrr-struct" id="the-notrestoredreasons-interface:nrr-struct-2">not restored reasons</a> <var>backingStruct</var> and a
  <a id="the-notrestoredreasons-interface:realm-2" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> <var>realm</var>:</p>

  <ol><li><p>Let <var>notRestoredReasons</var> be a new <code id="the-notrestoredreasons-interface:notrestoredreasons-8"><a href="#notrestoredreasons">NotRestoredReasons</a></code> object created
   in <var>realm</var>.</p></li><li><p>Set <var>notRestoredReasons</var>'s <a href="#concept-not-restored-reasons-backing-struct" id="the-notrestoredreasons-interface:concept-not-restored-reasons-backing-struct-6">backing struct</a> to
   <var>backingStruct</var>.</p></li><li><p>If <var>backingStruct</var>'s <a href="#nrr-reasons" id="the-notrestoredreasons-interface:nrr-reasons">reasons</a> is null, set
   <var>notRestoredReasons</var>'s <a href="#concept-not-restored-reasons-reasons" id="the-notrestoredreasons-interface:concept-not-restored-reasons-reasons-2">reasons array</a> to null.</p></li><li>
    <p>Otherwise:</p>
    <ol><li><p>Let <var>reasonsArray</var> be an empty <a id="the-notrestoredreasons-interface:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-notrestoredreasons-interface:list-iterate" data-x-internal="list-iterate">For each</a> <var>reason</var> of
      <var>backingStruct</var>'s <a href="#nrr-reasons" id="the-notrestoredreasons-interface:nrr-reasons-2">reasons</a>:</p>
      <ol><li><p><a href="#create-a-notrestoredreasondetails-object" id="the-notrestoredreasons-interface:create-a-notrestoredreasondetails-object">Create a <code>NotRestoredReasonDetails</code> object</a> given
       <var>reason</var> and <var>realm</var>, and <a href="https://infra.spec.whatwg.org/#list-append" id="the-notrestoredreasons-interface:list-append" data-x-internal="list-append">append</a>
       it to <var>reasonsArray</var>.</p></li></ol>
     </li><li><p>Set <var>notRestoredReasons</var>'s <a href="#concept-not-restored-reasons-reasons" id="the-notrestoredreasons-interface:concept-not-restored-reasons-reasons-3">reasons array</a> to the result of
     <a id="the-notrestoredreasons-interface:creating-a-frozen-array" href="https://webidl.spec.whatwg.org/#dfn-create-frozen-array" data-x-internal="creating-a-frozen-array">creating a frozen array</a> given <var>reasonsArray</var>.</p></li></ol>
   </li><li><p>If <var>backingStruct</var>'s <a href="#nrr-children" id="the-notrestoredreasons-interface:nrr-children">children</a> is null, set
   <var>notRestoredReasons</var>'s <a href="#concept-not-restored-reasons-children" id="the-notrestoredreasons-interface:concept-not-restored-reasons-children-2">children array</a> to null.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>childrenArray</var> be an empty <a id="the-notrestoredreasons-interface:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-notrestoredreasons-interface:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>child</var> of
      <var>backingStruct</var>'s <a href="#nrr-children" id="the-notrestoredreasons-interface:nrr-children-2">children</a>:</p>

      <ol><li><p><a href="#create-a-notrestoredreasons-object" id="the-notrestoredreasons-interface:create-a-notrestoredreasons-object">Create a <code>NotRestoredReasons</code> object</a> given <var>child</var>
       and <var>realm</var> and <a href="https://infra.spec.whatwg.org/#list-append" id="the-notrestoredreasons-interface:list-append-2" data-x-internal="list-append">append</a> it to
       <var>childrenArray</var>.</p></li></ol>
     </li><li><p>Set <var>notRestoredReasons</var>'s <a href="#concept-not-restored-reasons-children" id="the-notrestoredreasons-interface:concept-not-restored-reasons-children-3">children array</a> to the result of
     <a id="the-notrestoredreasons-interface:creating-a-frozen-array-2" href="https://webidl.spec.whatwg.org/#dfn-create-frozen-array" data-x-internal="creating-a-frozen-array">creating a frozen array</a> given <var>childrenArray</var>.</p></li></ol>
   </li><li><p>Return <var>notRestoredReasons</var>.</p></li></ol>
  </div>

  <p>A <dfn id="nrr-struct" data-export="">not restored reasons</dfn> is a <a id="the-notrestoredreasons-interface:struct-2" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with
  the following <a href="https://infra.spec.whatwg.org/#struct-item" id="the-notrestoredreasons-interface:struct-item-2" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="nrr-src">src</dfn>, a <a id="the-notrestoredreasons-interface:scalar-value-string" href="https://infra.spec.whatwg.org/#scalar-value-string" data-x-internal="scalar-value-string">scalar value string</a> or null, initially
   null.</p></li><li><p><dfn id="nrr-id">id</dfn>, a string or null, initially null.</p></li><li><p><dfn id="nrr-name">name</dfn>, a string or null, initially null.</p></li><li><p><dfn id="nrr-url">url</dfn>, a <a id="the-notrestoredreasons-interface:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> or null, initially null.</p></li><li><p><dfn id="nrr-reasons">reasons</dfn>, null or a <a id="the-notrestoredreasons-interface:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of
   <a href="#nrr-details-struct" id="the-notrestoredreasons-interface:nrr-details-struct-3">not restored reason details</a>, initially null.</p></li><li><p><dfn id="nrr-children">children</dfn>, null or a <a id="the-notrestoredreasons-interface:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#nrr-struct" id="the-notrestoredreasons-interface:nrr-struct-3">not restored reasons</a>, initially null.</p></li></ul>

  <div data-algorithm="">
  <p>A <dfn data-dfn-for="Document" id="concept-document-nrr" data-lt="not restored reasons" data-export=""><code>Document</code>'s not restored reasons</dfn> is its <a href="#node-navigable" id="the-notrestoredreasons-interface:node-navigable-4">node navigable</a>'s
  <a href="#nav-active-history-entry" id="the-notrestoredreasons-interface:nav-active-history-entry">active session history entry</a>'s <a href="#she-document-state" id="the-notrestoredreasons-interface:she-document-state">document state</a>'s <a href="#document-state-not-restored-reasons" id="the-notrestoredreasons-interface:document-state-not-restored-reasons">not restored reasons</a>, if
  <code id="the-notrestoredreasons-interface:document-43"><a href="#document">Document</a></code>'s <a href="#node-navigable" id="the-notrestoredreasons-interface:node-navigable-5">node navigable</a> is a <a href="#top-level-traversable" id="the-notrestoredreasons-interface:top-level-traversable">top-level traversable</a>;
  otherwise null.</p>
  </div>

  <h3 id="infrastructure-for-sequences-of-documents"><span class="secno">7.3</span> Infrastructure for sequences of documents<a href="#infrastructure-for-sequences-of-documents" class="self-link"></a></h3>

  <p>This standard contains several related concepts for grouping sequences of documents. As a
  brief, non-normative summary:</p>

  <ul><li><p><a href="#navigable" id="infrastructure-for-sequences-of-documents:navigable">Navigables</a> are a user-facing representation of a sequence
   of documents, i.e., they represent something that can be navigated between documents. Typical
   examples are tabs or windows in a web browser, or <code id="infrastructure-for-sequences-of-documents:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s, or
   <code id="infrastructure-for-sequences-of-documents:frame"><a href="#frame">frame</a></code>s in a <code id="infrastructure-for-sequences-of-documents:frameset"><a href="#frameset">frameset</a></code>.</p></li><li><p><a href="#traversable-navigable" id="infrastructure-for-sequences-of-documents:traversable-navigable">Traversable navigables</a> are a special type of
   navigable which control the session history of themselves and of their descendant navigables.
   That is, in addition to their own series of documents, they represent a tree of further series
   of documents, plus the ability to linearly traverse back and forward through a flattened view of
   this tree.</p></li><li><p><a href="#browsing-context" id="infrastructure-for-sequences-of-documents:browsing-context">Browsing contexts</a> are a developer-facing
   representation of a series of documents. They correspond 1:1 with <code id="infrastructure-for-sequences-of-documents:windowproxy"><a href="#windowproxy">WindowProxy</a></code>
   objects. Each navigable can present a series of browsing contexts, with <a href="#browsing-context-group-switches-due-to-cross-origin-opener-policy">switches</a> between
   those browsing contexts occuring under certain well-defined circumstances.</p></li></ul>

  <p>Most of this standard works in the language of navigables, but certain APIs expose the
  existence of browsing context switches, and so some parts of the standard need to work in terms
  of browsing contexts.</p>

  <h4 id="navigables"><span class="secno">7.3.1</span> Navigables<a href="#navigables" class="self-link"></a></h4>

  <p>A <dfn id="navigable" data-export="">navigable</dfn> presents a <code id="navigables:document"><a href="#document">Document</a></code> to the user via its <a href="#nav-active-history-entry" id="navigables:nav-active-history-entry">active session history entry</a>. Each navigable has:</p>

  <ul><li><p>An <dfn id="nav-id">id</dfn>, a <a href="#new-unique-internal-value" id="navigables:new-unique-internal-value">new unique internal value</a>.</p></li><li><p id="parent-browsing-context">A <dfn data-dfn-for="navigable" id="nav-parent" data-export="">parent</dfn>,
   a <a href="#navigable" id="navigables:navigable">navigable</a> or null.</p></li><li>
    <p id="current-entry">A <dfn id="nav-current-history-entry">current session history
    entry</dfn>, a <a href="#session-history-entry" id="navigables:session-history-entry">session history entry</a>.</p>

    <p>This can only be modified within the <a href="#tn-session-history-traversal-queue" id="navigables:tn-session-history-traversal-queue">session history traversal queue</a> of the
    parent <a href="#traversable-navigable" id="navigables:traversable-navigable">traversable navigable</a>.</p>
   </li><li>
    <p>An <dfn id="nav-active-history-entry">active session history entry</dfn>, a
    <a href="#session-history-entry" id="navigables:session-history-entry-2">session history entry</a>.</p>

    <p>This can only be modified from the event loop of the <a href="#nav-active-history-entry" id="navigables:nav-active-history-entry-2">active session history entry</a>'s <a href="#she-document" id="navigables:she-document">document</a>.</p>
   </li><li>
    <p>An <dfn id="is-closing">is closing</dfn> boolean, initially false.</p>

    <p class="note">This is only ever set to true for <a href="#top-level-traversable" id="navigables:top-level-traversable">top-level traversable navigables</a>.</p>
   </li><li>
    <p>An <dfn id="delaying-load-events-mode">is delaying <code>load</code>
    events</dfn> boolean, initially false.</p>

    <p class="note">This is only ever set to true in cases where the navigable's <a href="#nav-parent" id="navigables:nav-parent">parent</a> is non-null.</p>
  </li></ul>

  <p>The <a href="#nav-current-history-entry" id="navigables:nav-current-history-entry">current session history entry</a> and the
  <a href="#nav-active-history-entry" id="navigables:nav-active-history-entry-3">active session history entry</a> are usually the same,
  but they get out of sync when:</p>

  <ul><li><p>Synchronous navigations are performed. This causes the <a href="#nav-active-history-entry" id="navigables:nav-active-history-entry-4">active session history entry</a> to temporarily step ahead
   of the <a href="#nav-current-history-entry" id="navigables:nav-current-history-entry-2">current session history entry</a>.</p></li><li><p>A non-displayable, non-error response is received when <a href="#apply-the-history-step" id="navigables:apply-the-history-step">applying the history step</a>. This updates the <a href="#nav-current-history-entry" id="navigables:nav-current-history-entry-3">current session history entry</a> but leaves the <a href="#nav-active-history-entry" id="navigables:nav-active-history-entry-5">active session history entry</a> as-is.</p></li></ul>

  <hr>

  <div data-algorithm="">
  <p>A <a href="#navigable" id="navigables:navigable-2">navigable</a>'s <dfn data-dfn-for="navigable" id="nav-document" data-export="">active
  document</dfn> is its <a href="#nav-active-history-entry" id="navigables:nav-active-history-entry-6">active session history
  entry</a>'s <a href="#she-document" id="navigables:she-document-2">document</a>.</p>
  </div>

  <p class="note">This can be safely read from within the <a href="#tn-session-history-traversal-queue" id="navigables:tn-session-history-traversal-queue-2">session history traversal queue</a> of the
  navigable's <a href="#nav-top" id="navigables:nav-top">top-level traversable</a>. Although a
  <a href="#navigable" id="navigables:navigable-3">navigable</a>'s <a href="#nav-active-history-entry" id="navigables:nav-active-history-entry-7">active history entry</a> can
  change synchronously, the new entry will always have the same <code id="navigables:document-2"><a href="#document">Document</a></code>.</p>

  <div data-algorithm="">
  <p>A <a href="#navigable" id="navigables:navigable-4">navigable</a>'s <dfn data-dfn-for="navigable" id="nav-bc" data-export="">active browsing
  context</dfn> is its <a href="#nav-document" id="navigables:nav-document">active document</a>'s <a href="#concept-document-bc" id="navigables:concept-document-bc">browsing context</a>. If this <a href="#navigable" id="navigables:navigable-5">navigable</a> is a
  <a href="#traversable-navigable" id="navigables:traversable-navigable-2">traversable navigable</a>, then its <a href="#nav-bc" id="navigables:nav-bc">active browsing context</a>
  will be a <a href="#top-level-browsing-context" id="navigables:top-level-browsing-context">top-level browsing context</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#navigable" id="navigables:navigable-6">navigable</a>'s <dfn id="nav-wp">active <code>WindowProxy</code></dfn> is its
  <a href="#nav-bc" id="navigables:nav-bc-2">active browsing context</a>'s associated <code id="navigables:windowproxy"><a href="#windowproxy">WindowProxy</a></code>.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#navigable" id="navigables:navigable-7">navigable</a>'s <dfn data-dfn-for="navigable" id="nav-window" data-export="">active window</dfn>
  is its <a href="#nav-wp" id="navigables:nav-wp">active <code>WindowProxy</code></a>'s <a href="#concept-windowproxy-window" id="navigables:concept-windowproxy-window">[[Window]]</a>.</p>
  </div>

  <p class="note">This will always equal the navigable's <a href="#nav-document" id="navigables:nav-document-2">active
  document</a>'s <a href="#concept-relevant-global" id="navigables:concept-relevant-global">relevant global object</a>; this is kept in sync by the <a href="#make-active" id="navigables:make-active">make
  active</a> algorithm.</p>

  <div data-algorithm="">
  <p id="browsing-context-name">A <a href="#navigable" id="navigables:navigable-8">navigable</a>'s <dfn id="nav-target">target
  name</dfn> is its <a href="#nav-active-history-entry" id="navigables:nav-active-history-entry-8">active session history entry</a>'s
  <a href="#she-document-state" id="navigables:she-document-state">document state</a>'s <a href="#document-state-nav-target-name" id="navigables:document-state-nav-target-name">navigable target name</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To get the <dfn id="node-navigable" data-export="">node navigable</dfn> of a <a id="navigables:node" href="https://dom.spec.whatwg.org/#interface-node" data-x-internal="node">node</a> <var>node</var>, return the
  <a href="#navigable" id="navigables:navigable-9">navigable</a> whose <a href="#nav-document" id="navigables:nav-document-3">active document</a> is
  <var>node</var>'s <a id="navigables:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, or null if there is no such
  <a href="#navigable" id="navigables:navigable-10">navigable</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="initialize-the-navigable">initialize the navigable</dfn> <a href="#navigable" id="navigables:navigable-11">navigable</a> <var>navigable</var>, given a
  <a href="#document-state-2" id="navigables:document-state-2">document state</a> <var>documentState</var> and an optional
  <a href="#navigable" id="navigables:navigable-12">navigable</a>-or-null <var>parent</var> (default null):</p>

  <ol><li><p><a id="navigables:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>documentState</var>'s <a href="#document-state-document" id="navigables:document-state-document">document</a> is non-null.</p></li><li>
    <p>Let <var>entry</var> be a new <a href="#session-history-entry" id="navigables:session-history-entry-3">session history entry</a>, with</p>

    <dl class="props"><dt><a href="#she-url" id="navigables:she-url">URL</a></dt><dd><var>documentState</var>'s <a href="#document-state-document" id="navigables:document-state-document-2">document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="navigables:the-document's-address" data-x-internal="the-document's-address">URL</a></dd><dt><a href="#she-document-state" id="navigables:she-document-state-2">document state</a></dt><dd><var>documentState</var></dd></dl>

    <p class="note">The caller of this algorithm is responsible for initializing <var>entry</var>'s
    <a href="#she-step" id="navigables:she-step">step</a>; it will be left as "<code>pending</code>" until
    that is complete.</p>
   </li><li><p>Set <var>navigable</var>'s <a href="#nav-current-history-entry" id="navigables:nav-current-history-entry-4">current session
   history entry</a> to <var>entry</var>.</p></li><li><p>Set <var>navigable</var>'s <a href="#nav-active-history-entry" id="navigables:nav-active-history-entry-9">active session history
   entry</a> to <var>entry</var>.</p></li><li><p>Set <var>navigable</var>'s <a href="#nav-parent" id="navigables:nav-parent-2">parent</a> to
   <var>parent</var>.</p></li></ol>
  </div>


  <h5 id="traversable-navigables"><span class="secno">7.3.1.1</span> Traversable navigables<a href="#traversable-navigables" class="self-link"></a></h5>

  <p>A <dfn id="traversable-navigable" data-export="">traversable navigable</dfn> is a <a href="#navigable" id="traversable-navigables:navigable">navigable</a> that also controls which
  <a href="#session-history-entry" id="traversable-navigables:session-history-entry">session history entry</a> should be the <a href="#nav-current-history-entry" id="traversable-navigables:nav-current-history-entry">current
  session history entry</a> and <a href="#nav-active-history-entry" id="traversable-navigables:nav-active-history-entry">active session history
  entry</a> for itself and its descendant <a href="#navigable" id="traversable-navigables:navigable-2">navigables</a>.</p>

  <p>In addition to the properties of a <a href="#navigable" id="traversable-navigables:navigable-3">navigable</a>, a <a href="#traversable-navigable" id="traversable-navigables:traversable-navigable">traversable
  navigable</a> has:</p>

  <ul><li><p>A <dfn id="tn-current-session-history-step" data-export="">current session history
   step</dfn>, a number, initially 0.</p></li><li><p id="session-history"><dfn id="tn-session-history-entries">Session history
   entries</dfn>, a <a id="traversable-navigables:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#session-history-entry" id="traversable-navigables:session-history-entry-2">session history
   entries</a>, initially a new <a id="traversable-navigables:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>A <dfn id="tn-session-history-traversal-queue">session history traversal queue</dfn>,
   a <a href="#session-history-traversal-parallel-queue" id="traversable-navigables:session-history-traversal-parallel-queue">session history traversal parallel queue</a>, the result of <a href="#starting-a-new-session-history-traversal-parallel-queue" id="traversable-navigables:starting-a-new-session-history-traversal-parallel-queue">starting a new
   session history traversal parallel queue</a>.</p></li><li><p>A <dfn id="tn-running-nested-apply-history-step">running nested apply history
   step</dfn> boolean, initially false.</p></li><li>
    <p>A <dfn id="system-visibility-state">system visibility state</dfn>, which is either "<code>hidden</code>" or
    "<code>visible</code>".</p>

    <p>See the <a href="#page-visibility">page visibility</a> section for the requirements on this
    item.</p>
   </li><li><p>An <dfn id="is-created-by-web-content">is created by web content</dfn> boolean, initially false.</p></li></ul>

  <div data-algorithm="">
  <p>To get the <dfn data-dfn-for="navigable" id="nav-traversable" data-export="">traversable navigable</dfn> of
  a <a href="#navigable" id="traversable-navigables:navigable-4">navigable</a> <var>inputNavigable</var>:</p>

  <ol><li><p>Let <var>navigable</var> be <var>inputNavigable</var>.</p></li><li><p>While <var>navigable</var> is not a <a href="#traversable-navigable" id="traversable-navigables:traversable-navigable-2">traversable navigable</a>, set
   <var>navigable</var> to <var>navigable</var>'s <a href="#nav-parent" id="traversable-navigables:nav-parent">parent</a>.</p></li><li><p>Return <var>navigable</var>.</p></li></ol>
  </div>

  <h5 id="top-level-traversables"><span class="secno">7.3.1.2</span> Top-level traversables<a href="#top-level-traversables" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A <dfn id="top-level-traversable" data-export="">top-level traversable</dfn> is a <a href="#traversable-navigable" id="top-level-traversables:traversable-navigable">traversable navigable</a> with a null
  <a href="#nav-parent" id="top-level-traversables:nav-parent">parent</a>.</p>
  </div>

  <p class="note">Currently, all <a href="#traversable-navigable" id="top-level-traversables:traversable-navigable-2">traversable navigables</a>
  are <a href="#top-level-traversable" id="top-level-traversables:top-level-traversable">top-level traversables</a>. Future proposals envision
  introducing non-top-level traversables.</p>

  <p>A user agent holds a <dfn data-dfn-for="user agent" id="top-level-traversable-set" data-export="">top-level traversable set</dfn> (a
  <a id="top-level-traversables:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <a href="#top-level-traversable" id="top-level-traversables:top-level-traversable-2">top-level traversables</a>). These are
  typically presented to the user in the form of browser windows or browser tabs.</p>

  <div data-algorithm="">
  <p>To get the <dfn data-dfn-for="navigable" id="nav-top" data-export="">top-level traversable</dfn> of a
  <a href="#navigable" id="top-level-traversables:navigable">navigable</a> <var>inputNavigable</var>:</p>

  <ol><li><p>Let <var>navigable</var> be <var>inputNavigable</var>.</p></li><li><p>While <var>navigable</var>'s <a href="#nav-parent" id="top-level-traversables:nav-parent-2">parent</a> is not null, set
   <var>navigable</var> to <var>navigable</var>'s <a href="#nav-parent" id="top-level-traversables:nav-parent-3">parent</a>.</p></li><li><p>Return <var>navigable</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-new-top-level-traversable">create a new top-level traversable</dfn>
  given a <a href="#browsing-context" id="top-level-traversables:browsing-context">browsing context</a>-or-null <var>opener</var>, a string
  <var>targetName</var>, and an optional <a href="#navigable" id="top-level-traversables:navigable-2">navigable</a>
  <var>openerNavigableForWebDriver</var>:</p>

  <ol><li><p>Let <var>document</var> be null.</p></li><li><p>If <var>opener</var> is null, then set <var>document</var> to the second return value of
   <a href="#creating-a-new-top-level-browsing-context" id="top-level-traversables:creating-a-new-top-level-browsing-context">creating a new top-level browsing context and document</a>.</p></li><li><p>Otherwise, set <var>document</var> to the second return value of <a href="#creating-a-new-auxiliary-browsing-context" id="top-level-traversables:creating-a-new-auxiliary-browsing-context">creating a new
   auxiliary browsing context and document</a> given <var>opener</var>.</p></li><li>
    <p>Let <var>documentState</var> be a new <a href="#document-state-2" id="top-level-traversables:document-state-2">document state</a>, with</p>

    <dl class="props"><dt><a href="#document-state-document" id="top-level-traversables:document-state-document">document</a></dt><dd><var>document</var></dd><dt><a href="#document-state-initiator-origin" id="top-level-traversables:document-state-initiator-origin">initiator origin</a></dt><dd>null if <var>opener</var> is null; otherwise, <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="top-level-traversables:concept-document-origin" data-x-internal="concept-document-origin">origin</a></dd><dt><a href="#document-state-origin" id="top-level-traversables:document-state-origin">origin</a></dt><dd><var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="top-level-traversables:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a></dd><dt><a href="#document-state-nav-target-name" id="top-level-traversables:document-state-nav-target-name">navigable target name</a></dt><dd><var>targetName</var></dd><dt><a href="#document-state-about-base-url" id="top-level-traversables:document-state-about-base-url">about base URL</a></dt><dd><var>document</var>'s <a href="#concept-document-about-base-url" id="top-level-traversables:concept-document-about-base-url">about base
     URL</a></dd></dl>
   </li><li><p>Let <var>traversable</var> be a new <a href="#traversable-navigable" id="top-level-traversables:traversable-navigable-3">traversable navigable</a>.</p></li><li><p><a href="#initialize-the-navigable" id="top-level-traversables:initialize-the-navigable">Initialize the navigable</a> <var>traversable</var> given
   <var>documentState</var>.</p></li><li><p>Let <var>initialHistoryEntry</var> be <var>traversable</var>'s <a href="#nav-active-history-entry" id="top-level-traversables:nav-active-history-entry">active session history entry</a>.</p></li><li><p>Set <var>initialHistoryEntry</var>'s <a href="#she-step" id="top-level-traversables:she-step">step</a> to 0.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="top-level-traversables:list-append" data-x-internal="list-append">Append</a> <var>initialHistoryEntry</var> to
   <var>traversable</var>'s <a href="#tn-session-history-entries" id="top-level-traversables:tn-session-history-entries">session history
   entries</a>.</p></li><li id="copy-session-storage"><p>If <var>opener</var> is non-null, then <a id="top-level-traversables:legacy-clone-a-traversable-storage-shed" href="https://storage.spec.whatwg.org/#legacy-clone-a-traversable-storage-shed" data-x-internal="legacy-clone-a-traversable-storage-shed">legacy-clone a
   traversable storage shed</a> given <var>opener</var>'s <a href="#bc-traversable" id="top-level-traversables:bc-traversable">top-level
   traversable</a> and <var>traversable</var>. <a href="#refsSTORAGE">[STORAGE]</a></p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="top-level-traversables:list-append-2" data-x-internal="list-append">Append</a> <var>traversable</var> to the user agent's
   <a href="#top-level-traversable-set" id="top-level-traversables:top-level-traversable-set">top-level traversable set</a>.</p></li><li><p>Invoke <a id="top-level-traversables:webdriver-bidi-navigable-created" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-created" data-x-internal="webdriver-bidi-navigable-created">WebDriver BiDi navigable created</a> with <var>traversable</var>
   and <var>openerNavigableForWebDriver</var>.</p></li><li><p>Return <var>traversable</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="create-a-fresh-top-level-traversable" data-export="">create a fresh top-level traversable</dfn> given a <a id="top-level-traversables:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>
  <var>initialNavigationURL</var> and an optional <a href="#post-resource" id="top-level-traversables:post-resource">POST resource</a>-or-null
  <var>initialNavigationPostResource</var> (default null):</p>

  <ol><li><p>Let <var>traversable</var> be the result of <a href="#creating-a-new-top-level-traversable" id="top-level-traversables:creating-a-new-top-level-traversable">creating a new top-level
   traversable</a> given null and the empty string.</p></li><li>
    <p><a href="#navigate" id="top-level-traversables:navigate">Navigate</a> <var>traversable</var> to <var>initialNavigationURL</var> using
    <var>traversable</var>'s <a href="#nav-document" id="top-level-traversables:nav-document">active document</a>, with <i id="top-level-traversables:navigation-resource"><a href="#navigation-resource">documentResource</a></i> set to
    <var>initialNavigationPostResource</var>.</p>

    <p class="note">We treat these initial navigations as <var>traversable</var> navigating itself,
    which will ensure all relevant security checks pass.</p>
   </li><li><p>Return <var>traversable</var>.</p></li></ol>
  </div>


  <h5 id="child-navigables"><span class="secno">7.3.1.3</span> Child navigables<a href="#child-navigables" class="self-link"></a></h5>

  <p id="browsing-context-container">Certain elements (for example, <code id="child-navigables:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> elements)
  can present a <a href="#navigable" id="child-navigables:navigable">navigable</a> to the user. These elements are called <dfn id="navigable-container" data-lt="navigable container" data-export="">navigable containers</dfn>.</p>

  <p id="nested-browsing-context">Each <a href="#navigable-container" id="child-navigables:navigable-container">navigable container</a> has a <dfn data-dfn-for="navigable container" id="content-navigable" data-export="">content navigable</dfn>, which is either a <a href="#navigable" id="child-navigables:navigable-2">navigable</a> or
  null. It is initially null.</p>

  <div data-algorithm="">
  <p id="bc-container">The <dfn data-dfn-for="navigable" id="nav-container" data-export="">container</dfn> of a
  <a href="#navigable" id="child-navigables:navigable-3">navigable</a> <var>navigable</var> is the <a href="#navigable-container" id="child-navigables:navigable-container-2">navigable container</a> whose
  <a href="#content-navigable" id="child-navigables:content-navigable">content navigable</a> is <var>navigable</var>, or null if there is no such element.</p>
  </div>

  <div data-algorithm="">
  <p id="bc-container-document">The <dfn data-dfn-for="navigable" id="nav-container-document" data-export="">container document</dfn> of a <a href="#navigable" id="child-navigables:navigable-4">navigable</a>
  <var>navigable</var> is the result of running these steps:</p>

  <ol><li><p>If <var>navigable</var>'s <a href="#nav-container" id="child-navigables:nav-container">container</a> is null, then
   return null.</p></li><li>
    <p>Return <var>navigable</var>'s <a href="#nav-container" id="child-navigables:nav-container-2">container</a>'s <a id="child-navigables:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
    document</a>.</p>

    <p class="note">This is equal to <var>navigable</var>'s <a href="#nav-container" id="child-navigables:nav-container-3">container</a>'s <a id="child-navigables:shadow-including-root" href="https://dom.spec.whatwg.org/#concept-shadow-including-root" data-x-internal="shadow-including-root">shadow-including root</a> as
    <var>navigable</var>'s <a href="#nav-container" id="child-navigables:nav-container-4">container</a> has to be
    <a id="child-navigables:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="doc-container-document">container document</dfn> of a <code id="child-navigables:document"><a href="#document">Document</a></code>
  <var>document</var> is the result of running these steps:</p>

  <ol><li><p>If <var>document</var>'s <a href="#node-navigable" id="child-navigables:node-navigable">node navigable</a> is null, then return null.</p></li><li><p>Return <var>document</var>'s <a href="#node-navigable" id="child-navigables:node-navigable-2">node navigable</a>'s <a href="#nav-container-document" id="child-navigables:nav-container-document">container document</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="child-browsing-context">A <a href="#navigable" id="child-navigables:navigable-5">navigable</a> <var>navigable</var> is a <dfn id="child-navigable" data-export="">child navigable</dfn> of another navigable <var>potentialParent</var> when
  <var>navigable</var>'s <a href="#nav-parent" id="child-navigables:nav-parent">parent</a> is <var>potentialParent</var>. We
  can also just say that a <a href="#navigable" id="child-navigables:navigable-6">navigable</a> "is a <a href="#child-navigable" id="child-navigables:child-navigable">child navigable</a>", which means
  that its <a href="#nav-parent" id="child-navigables:nav-parent-2">parent</a> is non-null.</p>
  </div>

  <p class="note">All <a href="#child-navigable" id="child-navigables:child-navigable-2">child navigables</a> are the <a href="#content-navigable" id="child-navigables:content-navigable-2">content
  navigable</a> of their <a href="#nav-container" id="child-navigables:nav-container-5">container</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="concept-bcc-content-document">content document</dfn> of a <a href="#navigable-container" id="child-navigables:navigable-container-3">navigable
  container</a> <var>container</var> is the result of running these steps:</p>

  <ol><li><p>If <var>container</var>'s <a href="#content-navigable" id="child-navigables:content-navigable-3">content navigable</a> is null, then return
   null.</p></li><li><p>Let <var>document</var> be <var>container</var>'s <a href="#content-navigable" id="child-navigables:content-navigable-4">content navigable</a>'s <a href="#nav-document" id="child-navigables:nav-document">active document</a>.</p></li><li><p>If <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="child-navigables:concept-document-origin" data-x-internal="concept-document-origin">origin</a> and
   <var>container</var>'s <a id="child-navigables:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="child-navigables:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> are not <a href="#same-origin-domain" id="child-navigables:same-origin-domain">same origin-domain</a>, then
   return null.</p></li><li><p>Return <var>document</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="content-window">content window</dfn> of a <a href="#navigable-container" id="child-navigables:navigable-container-4">navigable container</a> <var>container</var> is the
  result of running these steps:</p>

  <ol><li><p>If <var>container</var>'s <a href="#content-navigable" id="child-navigables:content-navigable-5">content navigable</a> is null, then return
   null.</p></li><li><p>Return <var>container</var>'s <a href="#content-navigable" id="child-navigables:content-navigable-6">content navigable</a>'s <a href="#nav-wp" id="child-navigables:nav-wp">active <code>WindowProxy</code></a>'s object.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p id="creating-a-new-nested-browsing-context">To <dfn id="create-a-new-child-navigable">create a new child navigable</dfn>, given
  an element <var>element</var>:</p>

  <ol><li><p>Let <var>parentNavigable</var> be <var>element</var>'s <a href="#node-navigable" id="child-navigables:node-navigable-3">node
   navigable</a>.</p></li><li><p>Let <var>group</var> be <var>element</var>'s <a id="child-navigables:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#concept-document-bc" id="child-navigables:concept-document-bc">browsing context</a>'s <a href="#bc-tlbc" id="child-navigables:bc-tlbc">top-level browsing
   context</a>'s <a href="#tlbc-group" id="child-navigables:tlbc-group">group</a>.</p></li><li><p>Let <var>browsingContext</var> and <var>document</var> be the result of <a href="#creating-a-new-browsing-context" id="child-navigables:creating-a-new-browsing-context">creating a
   new browsing context and document</a> given <var>element</var>'s <a id="child-navigables:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>,
   <var>element</var>, and <var>group</var>.</p></li><li><p>Let <var>targetName</var> be null.</p></li><li><p>If <var>element</var> has a <code>name</code> content attribute, then set
   <var>targetName</var> to the value of that attribute.</p></li><li>
    <p>Let <var>documentState</var> be a new <a href="#document-state-2" id="child-navigables:document-state-2">document state</a>, with</p>

    <dl class="props"><dt><a href="#document-state-document" id="child-navigables:document-state-document">document</a></dt><dd><var>document</var></dd><dt><a href="#document-state-initiator-origin" id="child-navigables:document-state-initiator-origin">initiator origin</a></dt><dd><var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="child-navigables:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a></dd><dt><a href="#document-state-origin" id="child-navigables:document-state-origin">origin</a></dt><dd><var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="child-navigables:concept-document-origin-4" data-x-internal="concept-document-origin">origin</a></dd><dt><a href="#document-state-nav-target-name" id="child-navigables:document-state-nav-target-name">navigable target name</a></dt><dd><var>targetName</var></dd><dt><a href="#document-state-about-base-url" id="child-navigables:document-state-about-base-url">about base URL</a></dt><dd><var>document</var>'s <a href="#concept-document-about-base-url" id="child-navigables:concept-document-about-base-url">about base
     URL</a></dd></dl>
   </li><li><p>Let <var>navigable</var> be a new <a href="#navigable" id="child-navigables:navigable-7">navigable</a>.</p></li><li><p><a href="#initialize-the-navigable" id="child-navigables:initialize-the-navigable">Initialize the navigable</a> <var>navigable</var> given <var>documentState</var>
   and <var>parentNavigable</var>.</p></li><li><p>Set <var>element</var>'s <a href="#content-navigable" id="child-navigables:content-navigable-7">content navigable</a> to <var>navigable</var>.</p></li><li><p>Let <var>historyEntry</var> be <var>navigable</var>'s <a href="#nav-active-history-entry" id="child-navigables:nav-active-history-entry">active session history entry</a>.</p></li><li><p>Let <var>traversable</var> be <var>parentNavigable</var>'s <a href="#nav-traversable" id="child-navigables:nav-traversable">traversable navigable</a>.</p></li><li>
    <p><a href="#tn-append-session-history-traversal-steps" id="child-navigables:tn-append-session-history-traversal-steps">Append the following session
    history traversal steps</a> to <var>traversable</var>:</p>

    <ol><li><p>Let <var>parentDocState</var> be <var>parentNavigable</var>'s <a href="#nav-active-history-entry" id="child-navigables:nav-active-history-entry-2">active session history entry</a>'s <a href="#she-document-state" id="child-navigables:she-document-state">document state</a>.</p></li><li><p>Let <var>parentNavigableEntries</var> be the result of <a href="#getting-session-history-entries" id="child-navigables:getting-session-history-entries">getting session history
     entries</a> for <var>parentNavigable</var>.</p></li><li><p>Let <var>targetStepSHE</var> be the first <a href="#session-history-entry" id="child-navigables:session-history-entry">session history entry</a> in
     <var>parentNavigableEntries</var> whose <a href="#she-document-state" id="child-navigables:she-document-state-2">document
     state</a> equals <var>parentDocState</var>.</p></li><li><p>Set <var>historyEntry</var>'s <a href="#she-step" id="child-navigables:she-step">step</a> to
     <var>targetStepSHE</var>'s <a href="#she-step" id="child-navigables:she-step-2">step</a>.</p></li><li><p>Let <var>nestedHistory</var> be a new <a href="#nested-history" id="child-navigables:nested-history">nested history</a> whose <a href="#nested-history-id" id="child-navigables:nested-history-id">id</a> is <var>navigable</var>'s <a href="#nav-id" id="child-navigables:nav-id">id</a>
     and <a href="#nested-history-entries" id="child-navigables:nested-history-entries">entries list</a> is « <var>historyEntry</var>
     ».</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="child-navigables:list-append" data-x-internal="list-append">Append</a> <var>nestedHistory</var> to
     <var>parentDocState</var>'s <a href="#document-state-nested-histories" id="child-navigables:document-state-nested-histories">nested
     histories</a>.</p></li><li><p><a href="#update-for-navigable-creation/destruction" id="child-navigables:update-for-navigable-creation/destruction">Update for navigable creation/destruction</a> given
     <var>traversable</var>.</p></li></ol>
   </li><li><p>Invoke <a id="child-navigables:webdriver-bidi-navigable-created" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-created" data-x-internal="webdriver-bidi-navigable-created">WebDriver BiDi navigable created</a> with <var>traversable</var>.</p></li></ol>
  </div>


  <h5 id="jake-diagrams"><span class="secno">7.3.1.4</span> Jake diagrams<a href="#jake-diagrams" class="self-link"></a></h5>

  <p>A useful method for visualizing sequences of documents, and in particular <a href="#navigable" id="jake-diagrams:navigable">navigables</a> and their <a href="#session-history-entry" id="jake-diagrams:session-history-entry">session
  history entries</a>, is the <dfn id="jake-diagram">Jake diagram</dfn>. A typical Jake diagram is the
  following:</p>

  
  <table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step current">1</th><th class="step">2</th><th class="step">3</th><th class="step">4</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="3" class="doc-0 current next-is-same-doc">/t-a</td><td colspan="1" class="doc-0 prev-is-same-doc">/t-a#foo</td><td colspan="1" class="doc-1">/t-b</td></tr><tr><th><code>frames[0]</code></th><td colspan="1" class="doc-2">/i-0-a</td><td colspan="3" class="doc-3 current">/i-0-b</td></tr><tr><th><code>frames[1]</code></th><td colspan="2" class="doc-4 current">/i-1-a</td><td colspan="2" class="doc-5">/i-1-b</td></tr></tbody></table>

  <p>Here, each numbered column denotes a possible value for the traversable's <a href="#tn-current-session-history-step" id="jake-diagrams:tn-current-session-history-step">session history step</a>. Each labeled row depicts a
  <a href="#navigable" id="jake-diagrams:navigable-2">navigable</a>, as it transitions between different URLs and documents. The first,
  labeled <code>top</code>, being the <a href="#top-level-traversable" id="jake-diagrams:top-level-traversable">top-level traversable</a>, and the others
  being <a href="#child-navigable" id="jake-diagrams:child-navigable">child navigables</a>. The documents are given by the
  background color of each cell, with a new background color indicating a new document in that
  <a href="#navigable" id="jake-diagrams:navigable-3">navigable</a>. The URLs are given by the text content of the cells; usually they are
  given as <a href="https://url.spec.whatwg.org/#syntax-url-relative" id="jake-diagrams:relative-url" data-x-internal="relative-url">relative URLs</a> for brevity, unless a cross-origin case
  is specifically under investigation. A given navigable might not exist at a given step, in which
  case the corresponding cells are empty. The bold-italic step number depicts the <a href="#tn-current-session-history-step" id="jake-diagrams:tn-current-session-history-step-2">current session history step</a> of the traversable,
  and all cells with bold-italic URLs represent the <a href="#nav-current-history-entry" id="jake-diagrams:nav-current-history-entry">current session history entry</a> for that row's
  navigable.</p>

  <p>Thus, the above Jake diagram depicts the following sequence of events:</p>

  <ol start="0"><li><p>A <a href="#top-level-traversable" id="jake-diagrams:top-level-traversable-2">top-level traversable</a> is created, starting at the URL <code>/t-a</code>, with two <a href="#child-navigable" id="jake-diagrams:child-navigable-2">child navigables</a>
   starting at <code>/i-0-a</code> and <code>/i-1-a</code>
   respectively.</p></li><li><p>The first child navigable is <a href="#navigate" id="jake-diagrams:navigate">navigated</a> to another
   document, with URL <code>/i-0-b</code>.</p></li><li><p>The second child navigable is <a href="#navigate" id="jake-diagrams:navigate-2">navigated</a> to another
   document, with URL <code>/i-1-b</code>.</p></li><li><p>The top-level traversable is <a href="#navigate" id="jake-diagrams:navigate-3">navigated</a> to the
   <em>same</em> document, updating its URL to <code>/t-a#foo</code>.</p></li><li><p>The top-level traversable is <a href="#navigate" id="jake-diagrams:navigate-4">navigated</a> to another
   document, with URL <code>/t-b</code>. (Notice how this document, of course, does not
   carry over the old document's child navigables.)</p></li><li><p>The traversable was <a href="#traverse-the-history-by-a-delta" id="jake-diagrams:traverse-the-history-by-a-delta">traversed by a
   delta</a> of −3, back to step 1.</p></li></ol>

  <p><a href="#jake-diagram" id="jake-diagrams:jake-diagram">Jake diagrams</a> are a powerful tool for visualizing the
  interactions of multiple navigables, navigations, and traversals. They cannot capture every
  possible interaction — for example, they only work with a single level of nesting —
  but we will have ocassion to use them to illustrate several complex situations throughout this
  standard.</p>

  <p class="note"><a href="#jake-diagram" id="jake-diagrams:jake-diagram-2">Jake diagrams</a> are named after their creator,
  the inimitable Jake Archibald.</p>


  <h5 id="related-navigable-collections"><span class="secno">7.3.1.5</span> Related navigable collections<a href="#related-navigable-collections" class="self-link"></a></h5>

  <p>It is often helpful in this standard's algorithms to look at collections of <a href="#navigable" id="related-navigable-collections:navigable">navigables</a> starting at a given <code id="related-navigable-collections:document"><a href="#document">Document</a></code>. This section
  contains a curated set of algorithms for collecting those navigables.</p>

  <p class="note">The return values of these algorithms are ordered so that parents appears before
  their children. Callers rely on this ordering.</p>

  <p class="note">Starting with a <code id="related-navigable-collections:document-2"><a href="#document">Document</a></code>, rather than a <a href="#navigable" id="related-navigable-collections:navigable-2">navigable</a>, is
  generally better because it makes the caller cognizant of whether they are starting with a
  <a href="#fully-active" id="related-navigable-collections:fully-active">fully active</a> <code id="related-navigable-collections:document-3"><a href="#document">Document</a></code> or not. Although non-<a href="#fully-active" id="related-navigable-collections:fully-active-2">fully active</a>
  <code id="related-navigable-collections:document-4"><a href="#document">Document</a></code>s do have ancestor and descendant navigables, they often behave as if they
  don't (e.g., in the <code id="related-navigable-collections:dom-parent"><a href="#dom-parent">window.parent</a></code> getter).</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="ancestor-navigables" data-export="">ancestor navigables</dfn> of a <code id="related-navigable-collections:document-5"><a href="#document">Document</a></code>
  <var>document</var> are given by these steps:</p>

  <ol><li><p>Let <var>navigable</var> be <var>document</var>'s <a href="#node-navigable" id="related-navigable-collections:node-navigable">node navigable</a>'s <a href="#nav-parent" id="related-navigable-collections:nav-parent">parent</a>.</p></li><li><p>Let <var>ancestors</var> be an empty list.</p>

   </li><li>
    <p>While <var>navigable</var> is not null:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-prepend" id="related-navigable-collections:list-prepend" data-x-internal="list-prepend">Prepend</a> <var>navigable</var> to
     <var>ancestors</var>.</p></li><li><p>Set <var>navigable</var> to <var>navigable</var>'s <a href="#nav-parent" id="related-navigable-collections:nav-parent-2">parent</a>.</p></li></ol>
   </li><li><p>Return <var>ancestors</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="inclusive-ancestor-navigables" data-export="">inclusive ancestor navigables</dfn> of a <code id="related-navigable-collections:document-6"><a href="#document">Document</a></code>
  <var>document</var> are given by these steps:</p>

  <ol><li><p>Let <var>navigables</var> be <var>document</var>'s <a href="#ancestor-navigables" id="related-navigable-collections:ancestor-navigables">ancestor
   navigables</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="related-navigable-collections:list-append" data-x-internal="list-append">Append</a> <var>document</var>'s <a href="#node-navigable" id="related-navigable-collections:node-navigable-2">node
   navigable</a> to <var>navigables</var>.</p></li><li><p>Return <var>navigables</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="list-of-the-descendant-browsing-contexts">The <dfn data-dfn-for="Document" id="descendant-navigables" data-export="">descendant
  navigables</dfn> of a <code id="related-navigable-collections:document-7"><a href="#document">Document</a></code> <var>document</var> are given by these steps:</p>

  <ol><li><p>Let <var>navigables</var> be new <a id="related-navigable-collections:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>Let <var>navigableContainers</var> be a <a id="related-navigable-collections:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of all <a href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant" id="related-navigable-collections:shadow-including-descendant" data-x-internal="shadow-including-descendant">shadow-including descendants</a> of <var>document</var>
   that are <a href="#navigable-container" id="related-navigable-collections:navigable-container">navigable containers</a>, in
   <a id="related-navigable-collections:shadow-including-tree-order" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="related-navigable-collections:list-iterate" data-x-internal="list-iterate">For each</a> <var>navigableContainer</var> of
    <var>navigableContainers</var>:</p>

    <ol><li><p>If <var>navigableContainer</var>'s <a href="#content-navigable" id="related-navigable-collections:content-navigable">content navigable</a> is null, then
     continue.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-extend" id="related-navigable-collections:list-extend" data-x-internal="list-extend">Extend</a> <var>navigables</var> with
     <var>navigableContainer</var>'s <a href="#content-navigable" id="related-navigable-collections:content-navigable-2">content navigable</a>'s <a href="#nav-document" id="related-navigable-collections:nav-document">active document</a>'s <a href="#inclusive-descendant-navigables" id="related-navigable-collections:inclusive-descendant-navigables">inclusive descendant
     navigables</a>.</p></li></ol>
   </li><li><p>Return <var>navigables</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="inclusive-descendant-navigables" data-export="">inclusive descendant navigables</dfn> of a
  <code id="related-navigable-collections:document-8"><a href="#document">Document</a></code> <var>document</var> are given by these steps:</p>

  <ol><li><p>Let <var>navigables</var> be « <var>document</var>'s <a href="#node-navigable" id="related-navigable-collections:node-navigable-3">node navigable</a>
   ».</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-extend" id="related-navigable-collections:list-extend-2" data-x-internal="list-extend">Extend</a> <var>navigables</var> with <var>document</var>'s
   <a href="#descendant-navigables" id="related-navigable-collections:descendant-navigables">descendant navigables</a>.</p></li><li><p>Return <var>navigables</var>.</p></li></ol>
  </div>

  <p class="note">These descendant-collecting algorithms are described as looking at the DOM tree
  of descendant <code id="related-navigable-collections:document-9"><a href="#document">Document</a></code> objects. In reality, this is often not feasible since the DOM
  tree can be in another process from the caller of the algorithm. Instead, implementations
  generally replicate the appropriate trees across processes.</p>

  <div data-algorithm="">
  <p id="document-tree-child-browsing-context">The <dfn id="document-tree-child-navigables">document-tree child navigables</dfn> of a
  <code id="related-navigable-collections:document-10"><a href="#document">Document</a></code> <var>document</var> are given by these steps:</p>

  <ol><li><p>If <var>document</var>'s <a href="#node-navigable" id="related-navigable-collections:node-navigable-4">node navigable</a> is null, then return the empty
   list.</p></li><li><p>Let <var>navigables</var> be new <a id="related-navigable-collections:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>Let <var>navigableContainers</var> be a <a id="related-navigable-collections:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of all <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="related-navigable-collections:descendant" data-x-internal="descendant">descendants</a> of <var>document</var> that are <a href="#navigable-container" id="related-navigable-collections:navigable-container-2">navigable containers</a>, in <a id="related-navigable-collections:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="related-navigable-collections:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>navigableContainer</var> of
    <var>navigableContainers</var>:</p>

    <ol><li><p>If <var>navigableContainer</var>'s <a href="#content-navigable" id="related-navigable-collections:content-navigable-3">content navigable</a> is null, then
     <a id="related-navigable-collections:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="related-navigable-collections:list-append-2" data-x-internal="list-append">Append</a> <var>navigableContainer</var>'s <a href="#content-navigable" id="related-navigable-collections:content-navigable-4">content
     navigable</a> to <var>navigables</var>.</p></li></ol>
   </li><li><p>Return <var>navigables</var>.</p></li></ol>
  </div>


  <h5 id="garbage-collection-and-browsing-contexts"><span class="secno">7.3.1.6</span> Navigable destruction<a href="#garbage-collection-and-browsing-contexts" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="destroy-a-child-navigable">destroy a child navigable</dfn> given a <a href="#navigable-container" id="garbage-collection-and-browsing-contexts:navigable-container">navigable container</a>
  <var>container</var>:</p>

  <ol><li><p>Let <var>navigable</var> be <var>container</var>'s <a href="#content-navigable" id="garbage-collection-and-browsing-contexts:content-navigable">content
   navigable</a>.</p></li><li><p>If <var>navigable</var> is null, then return.</p></li><li><p>Set <var>container</var>'s <a href="#content-navigable" id="garbage-collection-and-browsing-contexts:content-navigable-2">content navigable</a> to null.</p></li><li><p><a href="#inform-the-navigation-api-about-child-navigable-destruction" id="garbage-collection-and-browsing-contexts:inform-the-navigation-api-about-child-navigable-destruction">Inform the navigation API about child navigable destruction</a> given
   <var>navigable</var>.</p></li><li><p><a href="#destroy-a-document-and-its-descendants" id="garbage-collection-and-browsing-contexts:destroy-a-document-and-its-descendants">Destroy a document and its descendants</a> given <var>navigable</var>'s <a href="#nav-document" id="garbage-collection-and-browsing-contexts:nav-document">active document</a>.</p></li><li><p>Let <var>parentDocState</var> be <var>container</var>'s <a href="#node-navigable" id="garbage-collection-and-browsing-contexts:node-navigable">node navigable</a>'s
   <a href="#nav-active-history-entry" id="garbage-collection-and-browsing-contexts:nav-active-history-entry">active session history entry</a>'s <a href="#she-document-state" id="garbage-collection-and-browsing-contexts:she-document-state">document state</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="garbage-collection-and-browsing-contexts:list-remove" data-x-internal="list-remove">Remove</a> the <a href="#nested-history" id="garbage-collection-and-browsing-contexts:nested-history">nested history</a> from
   <var>parentDocState</var>'s <a href="#document-state-nested-histories" id="garbage-collection-and-browsing-contexts:document-state-nested-histories">nested
   histories</a> whose <a href="#nested-history-id" id="garbage-collection-and-browsing-contexts:nested-history-id">id</a> equals
   <var>navigable</var>'s <a href="#nav-id" id="garbage-collection-and-browsing-contexts:nav-id">id</a>.</p></li><li><p>Let <var>traversable</var> be <var>container</var>'s <a href="#node-navigable" id="garbage-collection-and-browsing-contexts:node-navigable-2">node navigable</a>'s <a href="#nav-traversable" id="garbage-collection-and-browsing-contexts:nav-traversable">traversable navigable</a>.</p></li><li>
    <p><a href="#tn-append-session-history-traversal-steps" id="garbage-collection-and-browsing-contexts:tn-append-session-history-traversal-steps">Append the following session
    history traversal steps</a> to <var>traversable</var>:</p>

    <ol><li><p><a href="#update-for-navigable-creation/destruction" id="garbage-collection-and-browsing-contexts:update-for-navigable-creation/destruction">Update for navigable creation/destruction</a> given
     <var>traversable</var>.</p></li></ol>
   </li><li><p>Invoke <a id="garbage-collection-and-browsing-contexts:webdriver-bidi-navigable-destroyed" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-destroyed" data-x-internal="webdriver-bidi-navigable-destroyed">WebDriver BiDi navigable destroyed</a> with <var>navigable</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="destroy-a-top-level-traversable">destroy</dfn> a <a href="#top-level-traversable" id="garbage-collection-and-browsing-contexts:top-level-traversable">top-level
  traversable</a> <var>traversable</var>:</p>

  <ol><li><p>Let <var>browsingContext</var> be <var>traversable</var>'s <a href="#nav-bc" id="garbage-collection-and-browsing-contexts:nav-bc">active browsing context</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="garbage-collection-and-browsing-contexts:list-iterate" data-x-internal="list-iterate">For each</a> <var>historyEntry</var> in
    <var>traversable</var>'s <a href="#tn-session-history-entries" id="garbage-collection-and-browsing-contexts:tn-session-history-entries">session history
    entries</a> <span class="XXX">in what order?</span>:</p>

    <ol><li><p>Let <var>document</var> be <var>historyEntry</var>'s <a href="#she-document" id="garbage-collection-and-browsing-contexts:she-document">document</a>.</p></li><li><p>If <var>document</var> is not null, then <a href="#destroy-a-document-and-its-descendants" id="garbage-collection-and-browsing-contexts:destroy-a-document-and-its-descendants-2">destroy a document and its
     descendants</a> given <var>document</var>.</p></li></ol>
   </li><li><p><a href="#bcg-remove" id="garbage-collection-and-browsing-contexts:bcg-remove">Remove</a> <var>browsingContext</var>.</p></li><li><p>Remove <var>traversable</var> from the user interface (e.g., close or hide its tab in
   a tabbed browser).</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="garbage-collection-and-browsing-contexts:list-remove-2" data-x-internal="list-remove">Remove</a> <var>traversable</var> from the user agent's
   <a href="#top-level-traversable-set" id="garbage-collection-and-browsing-contexts:top-level-traversable-set">top-level traversable set</a>.</p></li><li><p>Invoke <a id="garbage-collection-and-browsing-contexts:webdriver-bidi-navigable-destroyed-2" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigable-destroyed" data-x-internal="webdriver-bidi-navigable-destroyed">WebDriver BiDi navigable destroyed</a> with <var>traversable</var>.</p></li></ol>
  </div>

  <p>User agents may <a href="#destroy-a-top-level-traversable" id="garbage-collection-and-browsing-contexts:destroy-a-top-level-traversable">destroy a top-level traversable</a> at any time (typically, <a href="#nav-traversal-ui">in response to user requests</a>).</p>

  <div data-algorithm="">
  <p id="closing-browsing-contexts"><span id="close-a-browsing-context"></span>To <dfn data-dfn-for="top-level traversable" id="close-a-top-level-traversable" data-export="">close</dfn> a <a href="#top-level-traversable" id="garbage-collection-and-browsing-contexts:top-level-traversable-2">top-level traversable</a> <var>traversable</var>:</p>

  <ol><li><p>If <var>traversable</var>'s <a href="#is-closing" id="garbage-collection-and-browsing-contexts:is-closing">is closing</a> is true, then return.</p></li><li><p><a href="#definitely-close-a-top-level-traversable" id="garbage-collection-and-browsing-contexts:definitely-close-a-top-level-traversable">Definitely close</a>
   <var>traversable</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="definitely-close-a-top-level-traversable">definitely close</dfn> a
  <a href="#top-level-traversable" id="garbage-collection-and-browsing-contexts:top-level-traversable-3">top-level traversable</a> <var>traversable</var>:</p>

  <ol><li><p>Let <var>toUnload</var> be <var>traversable</var>'s <a href="#nav-document" id="garbage-collection-and-browsing-contexts:nav-document-2">active
   document</a>'s <a href="#inclusive-descendant-navigables" id="garbage-collection-and-browsing-contexts:inclusive-descendant-navigables">inclusive descendant navigables</a>.</p></li><li><p>If the result of <a href="#checking-if-unloading-is-canceled" id="garbage-collection-and-browsing-contexts:checking-if-unloading-is-canceled">checking if unloading is canceled</a> for <var>toUnload</var> is
   not "<code>continue</code>", then return.</p></li><li>
    <p><a href="#tn-append-session-history-traversal-steps" id="garbage-collection-and-browsing-contexts:tn-append-session-history-traversal-steps-2">Append the following session history
    traversal steps</a> to <var>traversable</var>:</p>

    <ol><li><p>Let <var>afterAllUnloads</var> be an algorithm step which <a href="#destroy-a-top-level-traversable" id="garbage-collection-and-browsing-contexts:destroy-a-top-level-traversable-2">destroys</a> <var>traversable</var>.</p></li><li><p><a href="#unload-a-document-and-its-descendants" id="garbage-collection-and-browsing-contexts:unload-a-document-and-its-descendants">Unload a document and its descendants</a> given <var>traversable</var>'s <a href="#nav-document" id="garbage-collection-and-browsing-contexts:nav-document-3">active document</a>, null, and <var>afterAllUnloads</var>.</p></li></ol>
   </li></ol>
  </div>

  <p class="note">The <a href="#close-a-top-level-traversable" id="garbage-collection-and-browsing-contexts:close-a-top-level-traversable">close</a> vs. <a href="#definitely-close-a-top-level-traversable" id="garbage-collection-and-browsing-contexts:definitely-close-a-top-level-traversable-2">definitely close</a> separation allows other
  specifications to call <a href="#close-a-top-level-traversable" id="garbage-collection-and-browsing-contexts:close-a-top-level-traversable-2">close</a> and have it be a
  no-op if the top-level traversable is already closing due to JavaScript code calling <code id="garbage-collection-and-browsing-contexts:dom-window-close"><a href="#dom-window-close">window.close()</a></code>.</p>


  <h5 id="navigable-target-names"><span class="secno">7.3.1.7</span> <span id="browsing-context-names"></span>Navigable target names<a href="#navigable-target-names" class="self-link"></a></h5>

  <p><a href="#navigable" id="navigable-target-names:navigable">Navigables</a> can be given <a href="#nav-target" id="navigable-target-names:nav-target">target
  names</a>, which are strings allowing certain APIs (such as <code id="navigable-target-names:dom-open"><a href="#dom-open">window.open()</a></code> or the <code id="navigable-target-names:the-a-element"><a href="#the-a-element">a</a></code> element's <code id="navigable-target-names:attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code> attribute) to target <a href="#navigate" id="navigable-target-names:navigate">navigations</a> at that navigable.</p>

  <div data-algorithm="">
  <p id="valid-browsing-context-name">A <dfn id="valid-navigable-target-name">valid navigable target name</dfn> is any string with at
  least one character that does not contain both an <a id="navigable-target-names:ascii-tab-or-newline" href="https://infra.spec.whatwg.org/#ascii-tab-or-newline" data-x-internal="ascii-tab-or-newline">ASCII tab or newline</a> and a U+003C
  (&lt;), and it does not start with a U+005F (_). (Names starting with a U+005F (_) are reserved
  for special keywords.)</p>
  </div>

  <div data-algorithm="">
  <p id="valid-browsing-context-name-or-keyword">A <dfn id="valid-navigable-target-name-or-keyword">valid navigable target name or
  keyword</dfn> is any string that is either a <a href="#valid-navigable-target-name" id="navigable-target-names:valid-navigable-target-name">valid navigable target name</a> or that is
  an <a id="navigable-target-names:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for one of: <code>_blank</code>, <code>_self</code>, <code>_parent</code>, or <code>_top</code>.</p>
  </div>

  <p>These values have different meanings based on whether the page is sandboxed or not, as
  summarized in the following (non-normative) table. In this table, "current" means the
  <a href="#navigable" id="navigable-target-names:navigable-2">navigable</a> that the link or script is in, "parent" means the <a href="#nav-parent" id="navigable-target-names:nav-parent">parent</a> of the <a href="#navigable" id="navigable-target-names:navigable-3">navigable</a> that the link or script is in,
  "top" means the <a href="#nav-top" id="navigable-target-names:nav-top">top-level traversable</a> of the <a href="#navigable" id="navigable-target-names:navigable-4">navigable</a>
  that the link or script is in, "new" means a new <a href="#traversable-navigable" id="navigable-target-names:traversable-navigable">traversable navigable</a> with a null
  <a href="#nav-parent" id="navigable-target-names:nav-parent-2">parent</a> (which may use an <a href="#auxiliary-browsing-context" id="navigable-target-names:auxiliary-browsing-context">auxiliary browsing
  context</a>, subject to various user preferences and user agent policies), "none" means that
  nothing will happen, and "maybe new" means the same as "new" if the "<code id="navigable-target-names:attr-iframe-sandbox-allow-popups"><a href="#attr-iframe-sandbox-allow-popups">allow-popups</a></code>" keyword is also specified on the
  <code id="navigable-target-names:attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute (or if the user overrode the
  sandboxing), and the same as "none" otherwise.</p>

  <table><thead><tr><th rowspan="2">Keyword
     </th><th rowspan="2">Ordinary effect
     </th><th colspan="2">Effect in an <code id="navigable-target-names:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> with...
    </th></tr><tr><th><code>sandbox=""</code>
     </th><th><code>sandbox="allow-top-navigation"</code>

   </th></tr></thead><tbody><tr><td>none specified, for links and form submissions 
     </td><td>current
     </td><td>current
     </td><td>current

    </td></tr><tr><td>empty string
     </td><td>current
     </td><td>current
     </td><td>current

    </td></tr><tr><td><code>_blank</code>
     </td><td>new
     </td><td>maybe new
     </td><td>maybe new

    </td></tr><tr><td><code>_self</code>
     </td><td>current
     </td><td>current
     </td><td>current

    </td></tr><tr><td><code>_parent</code> if there isn't a parent
     </td><td>current
     </td><td>current
     </td><td>current

    </td></tr><tr><td><code>_parent</code> if parent is also top
     </td><td>parent/top
     </td><td>none
     </td><td>parent/top

    </td></tr><tr><td><code>_parent</code> if there is one and it's not top
     </td><td>parent
     </td><td>none
     </td><td>none

    </td></tr><tr><td><code>_top</code> if top is current
     </td><td>current
     </td><td>current
     </td><td>current

    </td></tr><tr><td><code>_top</code> if top is not current
     </td><td>top
     </td><td>none
     </td><td>top

    </td></tr><tr><td>name that doesn't exist
     </td><td>new
     </td><td>maybe new
     </td><td>maybe new

    </td></tr><tr><td>name that exists and is a descendant
     </td><td>specified descendant
     </td><td>specified descendant
     </td><td>specified descendant

    </td></tr><tr><td>name that exists and is current
     </td><td>current
     </td><td>current
     </td><td>current

    </td></tr><tr><td>name that exists and is an ancestor that is top
     </td><td>specified ancestor
     </td><td>none
     </td><td>specified ancestor/top

    </td></tr><tr><td>name that exists and is an ancestor that is not top
     </td><td>specified ancestor
     </td><td>none
     </td><td>none

    </td></tr><tr><td>other name that exists with common top
     </td><td>specified
     </td><td>none
     </td><td>none

    </td></tr><tr><td>name that exists with different top, if <a href="#familiar-with" id="navigable-target-names:familiar-with">familiar</a> and <a href="#one-permitted-sandboxed-navigator" id="navigable-target-names:one-permitted-sandboxed-navigator">one permitted sandboxed navigator</a>
     </td><td>specified
     </td><td>specified
     </td><td>specified

    </td></tr><tr><td>name that exists with different top, if <a href="#familiar-with" id="navigable-target-names:familiar-with-2">familiar</a> but not <a href="#one-permitted-sandboxed-navigator" id="navigable-target-names:one-permitted-sandboxed-navigator-2">one permitted sandboxed navigator</a>
     </td><td>specified
     </td><td>none
     </td><td>none

    </td></tr><tr><td>name that exists with different top, not <a href="#familiar-with" id="navigable-target-names:familiar-with-3">familiar</a>
     </td><td>new
     </td><td>maybe new
     </td><td>maybe new

  </td></tr></tbody></table>

  <p class="tablenote"><small>Most of the restrictions on sandboxed browsing contexts are applied by
  other algorithms, e.g. the <a href="#navigate" id="navigable-target-names:navigate-2">navigation</a> algorithm, not <a href="#the-rules-for-choosing-a-navigable" id="navigable-target-names:the-rules-for-choosing-a-navigable">the
  rules for choosing a navigable</a> given below.</small></p>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="find-a-navigable-by-target-name">find a navigable by target name</dfn> given a string <var>name</var> and a
  <a href="#navigable" id="navigable-target-names:navigable-5">navigable</a> <var>currentNavigable</var>:</p>

  <ol><li><p>Let <var>currentDocument</var> be <var>currentNavigable</var>'s <a href="#nav-document" id="navigable-target-names:nav-document">active document</a>.</p></li><li><p>Let <var>sourceSnapshotParams</var> be the result of <a href="#snapshotting-source-snapshot-params" id="navigable-target-names:snapshotting-source-snapshot-params">snapshotting source snapshot
   params</a> given <var>currentDocument</var>.</p></li><li>
    <p>Let <var>subtreesToSearch</var> be an <a id="navigable-target-names:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> choice of one of
    the following:</p>

    <ul><li><p>« <var>currentNavigable</var>'s <a href="#nav-traversable" id="navigable-target-names:nav-traversable">traversable
     navigable</a>, <var>currentNavigable</var> »</p></li><li><p>the <a href="#inclusive-ancestor-navigables" id="navigable-target-names:inclusive-ancestor-navigables">inclusive ancestor navigables</a> of <var>currentDocument</var></p></li></ul>

    <p class="XXX"><a href="https://github.com/whatwg/html/issues/10848">Issue #10848</a> tracks
    settling on one of these two possibilities, to achieve interoperability.</p>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigable-target-names:list-iterate" data-x-internal="list-iterate">For each</a> <var>subtreeToSearch</var> of
    <var>subtreesToSearch</var>, in reverse order:</p>

    <ol><li><p>Let <var>documentToSearch</var> be <var>subtreeToSearch</var>'s <a href="#nav-document" id="navigable-target-names:nav-document-2">active document</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigable-target-names:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>navigable</var> of the <a href="#inclusive-descendant-navigables" id="navigable-target-names:inclusive-descendant-navigables">inclusive
      descendant navigables</a> of <var>documentToSearch</var>:</p>

      <ol><li>
        <p>If <var>currentNavigable</var> is not <a href="#allowed-to-navigate" id="navigable-target-names:allowed-to-navigate">allowed by sandboxing to navigate</a>
        <var>navigable</var> given <var>sourceSnapshotParams</var>, then optionally
        <a id="navigable-target-names:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p>

        <p class="XXX"><a href="https://github.com/whatwg/html/issues/10849">Issue #10849</a> tracks
        making this check required, to achieve interoperability.</p>
       </li><li><p>If <var>navigable</var>'s <a href="#nav-target" id="navigable-target-names:nav-target-2">target name</a> is
       <var>name</var>, then return <var>navigable</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Let <var>currentTopLevelBrowsingContext</var> be <var>currentNavigable</var>'s <a href="#nav-bc" id="navigable-target-names:nav-bc">active browsing context</a>'s <a href="#bc-tlbc" id="navigable-target-names:bc-tlbc">top-level browsing
   context</a>.</p></li><li><p>Let <var>group</var> be <var>currentTopLevelBrowsingContext</var>'s <a href="#tlbc-group" id="navigable-target-names:tlbc-group">group</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigable-target-names:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>topLevelBrowsingContext</var> of
    <var>group</var>'s <a href="#browsing-context-set" id="navigable-target-names:browsing-context-set">browsing context set</a>, in an <a id="navigable-target-names:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>
    order (the user agent should pick a consistent ordering, such as the most recently opened, most
    recently focused, or more closely related):</p>

    <p class="XXX"><a href="https://github.com/whatwg/html/issues/10850">Issue #10850</a> tracks
    picking a specific ordering, to achieve interoperability.</p>

    <ol><li><p>If <var>currentTopLevelBrowsingContext</var> is <var>topLevelBrowsingContext</var>, then
     <a id="navigable-target-names:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>documentToSearch</var> be <var>topLevelBrowsingContext</var>'s <a href="#active-document" id="navigable-target-names:active-document">active
     document</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="navigable-target-names:list-iterate-4" data-x-internal="list-iterate">For each</a> <var>navigable</var> of the <a href="#inclusive-descendant-navigables" id="navigable-target-names:inclusive-descendant-navigables-2">inclusive
      descendant navigables</a> of <var>documentToSearch</var>:</p>

      <ol><li><p>If <var>currentNavigable</var>'s <a href="#nav-bc" id="navigable-target-names:nav-bc-2">active browsing context</a>
       is not <a href="#familiar-with" id="navigable-target-names:familiar-with-4">familiar with</a> <var>navigable</var>'s <a href="#nav-bc" id="navigable-target-names:nav-bc-3">active
       browsing context</a>, then <a id="navigable-target-names:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li>
        <p>If <var>currentNavigable</var> is not <a href="#allowed-to-navigate" id="navigable-target-names:allowed-to-navigate-2">allowed by sandboxing to navigate</a>
        <var>navigable</var> given <var>sourceSnapshotParams</var>, then optionally
        <a id="navigable-target-names:continue-4" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p>


        <p class="XXX"><a href="https://github.com/whatwg/html/issues/10849">Issue #10849</a> tracks
        making this check required, to achieve interoperability.</p>
       </li><li><p>If <var>navigable</var>'s <a href="#nav-target" id="navigable-target-names:nav-target-3">target name</a> is
       <var>name</var>, then return <var>navigable</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name"><dfn id="the-rules-for-choosing-a-navigable">The rules
  for choosing a navigable</dfn>, given a string <var>name</var>, a <a href="#navigable" id="navigable-target-names:navigable-6">navigable</a>
  <var>currentNavigable</var>, and a boolean <var>noopener</var> are as follows:</p>

  <ol><li><p>Let <var>chosen</var> be null.</p></li><li><p>Let <var>windowType</var> be "<code>existing or none</code>".</p></li><li><p>Let <var>sandboxingFlagSet</var> be <var>currentNavigable</var>'s <a href="#nav-document" id="navigable-target-names:nav-document-3">active document</a>'s <a href="#active-sandboxing-flag-set" id="navigable-target-names:active-sandboxing-flag-set">active sandboxing flag set</a>.</p></li><li><p>If <var>name</var> is the empty string or an <a id="navigable-target-names:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match
   for "<code>_self</code>", then set <var>chosen</var> to
   <var>currentNavigable</var>.</p></li><li><p>Otherwise, if <var>name</var> is an <a id="navigable-target-names:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>_parent</code>", set <var>chosen</var> to <var>currentNavigable</var>'s <a href="#nav-parent" id="navigable-target-names:nav-parent-3">parent</a>, if any, and <var>currentNavigable</var> otherwise.</p></li><li><p>Otherwise, if <var>name</var> is an <a id="navigable-target-names:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>_top</code>", set <var>chosen</var> to <var>currentNavigable</var>'s <a href="#nav-traversable" id="navigable-target-names:nav-traversable-2">traversable navigable</a>.</p></li><li><p>Otherwise, if <var>name</var> is not an <a id="navigable-target-names:ascii-case-insensitive-5" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
   "<code>_blank</code>" and <var>noopener</var> is false, then set <var>chosen</var> to
   the result of <a href="#find-a-navigable-by-target-name" id="navigable-target-names:find-a-navigable-by-target-name">finding a navigable by target
   name</a> given <var>name</var> and <var>currentNavigable</var>.</p></li><li>
    <p>If <var>chosen</var> is null, then a new <a href="#top-level-traversable" id="navigable-target-names:top-level-traversable">top-level traversable</a> is being
    requested, and what happens depends on the user agent's configuration and abilities — it
    is determined by the rules given for the first applicable option from the following list:</p>

    <dl class="switch"><dt id="popup-blocker">If <var>currentNavigable</var>'s <a href="#nav-window" id="navigable-target-names:nav-window">active
     window</a> does not have <a href="#transient-activation" id="navigable-target-names:transient-activation">transient activation</a> and the user agent has been
     configured to not show popups (i.e., the user agent has a "popup blocker" enabled)</dt><dd><p>The user agent may inform the user that a popup has been blocked.</p></dd><dt id="sandboxWindowOpen">If <var>sandboxingFlagSet</var> has the <a href="#sandboxed-auxiliary-navigation-browsing-context-flag" id="navigable-target-names:sandboxed-auxiliary-navigation-browsing-context-flag">sandboxed auxiliary
     navigation browsing context flag</a> set</dt><dd><p>The user agent may report to a developer console that a popup has been blocked.</p></dd><dt>If the user agent has been configured such that in this instance it will create a new <a href="#top-level-traversable" id="navigable-target-names:top-level-traversable-2">top-level traversable</a></dt><dd>
      <ol><li><p><a href="#consume-user-activation" id="navigable-target-names:consume-user-activation">Consume user activation</a> of <var>currentNavigable</var>'s <a href="#nav-window" id="navigable-target-names:nav-window-2">active window</a>.</p></li><li><p>Set <var>windowType</var> to "<code>new and unrestricted</code>".</p></li><li><p>Let <var>currentDocument</var> be <var>currentNavigable</var>'s <a href="#nav-document" id="navigable-target-names:nav-document-4">active document</a>.</p></li><li>
        <p>If <var>currentDocument</var>'s <a href="#concept-document-coop" id="navigable-target-names:concept-document-coop">opener
        policy</a>'s <a href="#coop-struct-value" id="navigable-target-names:coop-struct-value">value</a> is "<code id="navigable-target-names:coop-same-origin"><a href="#coop-same-origin">same-origin</a></code>" or "<code id="navigable-target-names:coop-same-origin-plus-coep"><a href="#coop-same-origin-plus-coep">same-origin-plus-COEP</a></code>", and
        <var>currentDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="navigable-target-names:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is not
        <a href="#same-origin" id="navigable-target-names:same-origin">same origin</a> with <var>currentDocument</var>'s <a href="#relevant-settings-object" id="navigable-target-names:relevant-settings-object">relevant settings
        object</a>'s <a href="#concept-environment-top-level-origin" id="navigable-target-names:concept-environment-top-level-origin">top-level origin</a>, then:</p>

        <ol><li><p>Set <var>noopener</var> to true.</p></li><li><p>Set <var>name</var> to "<code>_blank</code>".</p></li><li><p>Set <var>windowType</var> to "<code>new with no opener</code>".</p>
        </li></ol>

        <p class="note">In the presence of an <a href="#cross-origin-opener-policy" id="navigable-target-names:cross-origin-opener-policy">opener policy</a>, nested documents that are
        cross-origin with their top-level browsing context's active document always set
        <var>noopener</var> to true.</p>
       </li><li><p>Let <var>targetName</var> be the empty string.</p></li><li><p>If <var>name</var> is not an <a id="navigable-target-names:ascii-case-insensitive-6" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>_blank</code>", then set <var>targetName</var> to <var>name</var>.</p></li><li id="noopener"><p>If <var>noopener</var> is true, then set <var>chosen</var> to the
       result of <a href="#creating-a-new-top-level-traversable" id="navigable-target-names:creating-a-new-top-level-traversable">creating a new top-level traversable</a> given null,
       <var>targetName</var>, and <var>currentNavigable</var>.</p></li><li>
        <p>Otherwise:</p>

        <ol><li><p>Set <var>chosen</var> to the result of <a href="#creating-a-new-top-level-traversable" id="navigable-target-names:creating-a-new-top-level-traversable-2">creating a new top-level
         traversable</a> given <var>currentNavigable</var>'s <a href="#nav-bc" id="navigable-target-names:nav-bc-4">active
         browsing context</a>, <var>targetName</var>, and <var>currentNavigable</var>.</p></li><li><p>If <var>sandboxingFlagSet</var>'s <a href="#sandboxed-navigation-browsing-context-flag" id="navigable-target-names:sandboxed-navigation-browsing-context-flag">sandboxed navigation browsing context
         flag</a> is set, then set <var>chosen</var>'s <a href="#nav-bc" id="navigable-target-names:nav-bc-5">active browsing
         context</a>'s <a href="#one-permitted-sandboxed-navigator" id="navigable-target-names:one-permitted-sandboxed-navigator-3">one permitted sandboxed navigator</a> to
         <var>currentNavigable</var>'s <a href="#nav-bc" id="navigable-target-names:nav-bc-6">active browsing
         context</a>.</p></li></ol>
       </li><li><p>If <var>sandboxingFlagSet</var>'s <a href="#sandbox-propagates-to-auxiliary-browsing-contexts-flag" id="navigable-target-names:sandbox-propagates-to-auxiliary-browsing-contexts-flag">sandbox propagates to auxiliary browsing
       contexts flag</a> is set, then all the flags that are set in <var>sandboxingFlagSet</var>
       must be set in <var>chosen</var>'s <a href="#nav-bc" id="navigable-target-names:nav-bc-7">active browsing context</a>'s
       <a href="#popup-sandboxing-flag-set" id="navigable-target-names:popup-sandboxing-flag-set">popup sandboxing flag set</a>.</p></li><li><p>Set <var>chosen</var>'s <a href="#is-created-by-web-content" id="navigable-target-names:is-created-by-web-content">is created by web content</a> to true.</p></li></ol>

      <p class="note">If the newly created <a href="#navigable" id="navigable-target-names:navigable-7">navigable</a> <var>chosen</var> is immediately
      <a href="#navigate" id="navigable-target-names:navigate-3">navigated</a>, then the navigation will be done as a "<code id="navigable-target-names:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>" navigation.</p>
     </dd><dt>If the user agent has been configured such that in this instance it will choose <var>currentNavigable</var></dt><dd><p>Set <var>chosen</var> to <var>currentNavigable</var>.</p></dd><dt>If the user agent has been configured such that in this instance it will not find a navigable</dt><dd><p>Do nothing.</p></dd></dl>

    <p class="note">User agents are encouraged to provide a way for users to configure the user
    agent to always choose <var>currentNavigable</var>.</p>
   </li><li><p>Return <var>chosen</var> and <var>windowType</var>.</p></li></ol>
  </div>


  <h4 id="windows"><span class="secno">7.3.2</span> Browsing contexts<a href="#windows" class="self-link"></a></h4>

  <p>A <dfn id="browsing-context" data-export="">browsing context</dfn> is a programmatic representation of a series of documents,
  multiple of which can live within a single <a href="#navigable" id="windows:navigable">navigable</a>. Each <a href="#browsing-context" id="windows:browsing-context">browsing
  context</a> has a corresponding <code id="windows:windowproxy"><a href="#windowproxy">WindowProxy</a></code> object, as well as the following:</p>

  <ul><li><p>An <dfn id="opener-browsing-context" data-export="">opener browsing context</dfn>, a <a href="#browsing-context" id="windows:browsing-context-2">browsing context</a> or null,
   initially null.</p></li><li><p>An <dfn id="opener-origin-at-creation">opener origin at creation</dfn>, an
   <a href="#concept-origin" id="windows:concept-origin">origin</a> or null, initially null.</p>

   </li><li>
    <p>An <dfn id="is-popup">is popup</dfn> boolean, initially false.</p>

    <p class="note">The only mandatory impact in this specification of <a href="#is-popup" id="windows:is-popup">is popup</a> is on
    the <code id="windows:dom-barprop-visible"><a href="#dom-barprop-visible">visible</a></code> getter of the relevant
    <code id="windows:barprop"><a href="#barprop">BarProp</a></code> objects. However, user agents might also use it for <a href="#nav-traversal-ui">user interface considerations</a>.</p>
   </li><li><p>An <dfn id="is-auxiliary">is auxiliary</dfn> boolean, initially false.</p></li><li><p>An <dfn id="browsing-context-initial-url">initial URL</dfn>, a <a id="windows:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> or
   null, initially null.</p></li><li><p>A <dfn id="virtual-browsing-context-group-id">virtual browsing context group ID</dfn>
   integer, initially 0. This is used by <a href="#coop-struct-report-only-value" id="windows:coop-struct-report-only-value">opener policy
   reporting</a>, to keep track of the browsing context group switches that would have happened
   if the report-only policy had been enforced.</p></li></ul>

  <div data-algorithm="">
  <p>A <a href="#browsing-context" id="windows:browsing-context-3">browsing context</a>'s <dfn id="active-window">active window</dfn> is its <code id="windows:windowproxy-2"><a href="#windowproxy">WindowProxy</a></code>
  object's <a href="#concept-windowproxy-window" id="windows:concept-windowproxy-window">[[Window]]</a> internal slot value. A
  <a href="#browsing-context" id="windows:browsing-context-4">browsing context</a>'s <dfn id="active-document">active document</dfn> is its <a href="#active-window" id="windows:active-window">active window</a>'s
  <a href="#concept-document-window" id="windows:concept-document-window">associated <code>Document</code></a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#browsing-context" id="windows:browsing-context-5">browsing context</a>'s <dfn data-dfn-for="browsing context" id="bc-traversable" data-export="">top-level traversable</dfn> is its <a href="#active-document" id="windows:active-document">active document</a>'s
  <a href="#node-navigable" id="windows:node-navigable">node navigable</a>'s <a href="#nav-top" id="windows:nav-top">top-level traversable</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#browsing-context" id="windows:browsing-context-6">browsing context</a> whose <a href="#is-auxiliary" id="windows:is-auxiliary">is auxiliary</a> is true is known as an <dfn id="auxiliary-browsing-context" data-export="">auxiliary browsing context</dfn>. Auxiliary browsing contexts are always <a href="#top-level-browsing-context" id="windows:top-level-browsing-context">top-level browsing contexts</a>.</p>
  </div>

  <p class="XXX">It's unclear whether a separate <a href="#is-auxiliary" id="windows:is-auxiliary-2">is auxiliary</a> concept is necessary. In
  <a href="https://github.com/whatwg/html/issues/5680">issue #5680</a>, it is indicated that we may
  be able to simplify this by using whether or not the <a href="#opener-browsing-context" id="windows:opener-browsing-context">opener browsing context</a> is
  null.</p>

  <p id="warning-avoid-using-bcs" class="warning">Modern specifications should avoid using the
  <a href="#browsing-context" id="windows:browsing-context-7">browsing context</a> concept in most cases, unless they are dealing with the subtleties
  of <a href="#browsing-context-group-switches-due-to-cross-origin-opener-policy">browsing context
  group switches</a> and <a href="#agent-cluster-map" id="windows:agent-cluster-map">agent cluster allocation</a>. Instead,
  the <code id="windows:document"><a href="#document">Document</a></code> and <a href="#navigable" id="windows:navigable-2">navigable</a> concepts are usually more appropriate.</p>

  <hr>

  <p>A <dfn data-dfn-for="Document" id="concept-document-bc" data-lt="browsing context" data-export=""><code>Document</code>'s browsing context</dfn> is a <a href="#browsing-context" id="windows:browsing-context-8">browsing context</a> or null,
  initially null.</p>

  <p class="note">A <code id="windows:document-2"><a href="#document">Document</a></code> does not necessarily have a non-null <a href="#concept-document-bc" id="windows:concept-document-bc">browsing context</a>. In particular, data mining tools are likely
  to never instantiate browsing contexts. A <code id="windows:document-3"><a href="#document">Document</a></code> created using an API such as <code id="windows:dom-domimplementation-createdocument"><a data-x-internal="dom-domimplementation-createdocument" href="https://dom.spec.whatwg.org/#dom-domimplementation-createdocument">createDocument()</a></code> never has a non-null <a href="#concept-document-bc" id="windows:concept-document-bc-2">browsing context</a>. And the <code id="windows:document-4"><a href="#document">Document</a></code> originally
  created for an <code id="windows:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element, which has since been <a href="#remove-an-element-from-a-document" id="windows:remove-an-element-from-a-document">removed from the document</a>, has no associated browsing context, since that
  browsing context was <a href="#destroy-a-document" id="windows:destroy-a-document">nulled out</a>.</p>

  <p class="note">In general, there is a 1-to-1 mapping from the <code id="windows:window"><a href="#window">Window</a></code> object to the
  <code id="windows:document-5"><a href="#document">Document</a></code> object, as long as the <code id="windows:document-6"><a href="#document">Document</a></code> object has a non-null <a href="#concept-document-bc" id="windows:concept-document-bc-3">browsing context</a>. There is one exception. A
  <code id="windows:window-2"><a href="#window">Window</a></code> can be reused for the presentation of a second <code id="windows:document-7"><a href="#document">Document</a></code> in the
  same <a href="#browsing-context" id="windows:browsing-context-9">browsing context</a>, such that the mapping is then 1-to-2. This occurs when a
  <a href="#browsing-context" id="windows:browsing-context-10">browsing context</a> is <a href="#navigate" id="windows:navigate">navigated</a> from the <a href="#is-initial-about:blank" id="windows:is-initial-about:blank">initial <code>about:blank</code></a> <code id="windows:document-8"><a href="#document">Document</a></code> to
  another, which will be done with <a href="#navigationhistorybehavior-replace" id="windows:navigationhistorybehavior-replace">replacement</a>.</p>

  <h5 id="creating-browsing-contexts"><span class="secno">7.3.2.1</span> Creating browsing contexts<a href="#creating-browsing-contexts" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-new-browsing-context">create a new browsing context and document</dfn>, given null or a <code id="creating-browsing-contexts:document"><a href="#document">Document</a></code>
  object <var>creator</var>, null or an element <var>embedder</var>, and a <a href="#browsing-context-group" id="creating-browsing-contexts:browsing-context-group">browsing context
  group</a> <var>group</var>:</p>

  

  <ol><li><p>Let <var>browsingContext</var> be a new <a href="#browsing-context" id="creating-browsing-contexts:browsing-context">browsing context</a>.</p></li><li><p>Let <var>unsafeContextCreationTime</var> be the
   <a id="creating-browsing-contexts:unsafe-shared-current-time" href="https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time" data-x-internal="unsafe-shared-current-time">unsafe shared current time</a>.</p></li><li><p>Let <var>creatorOrigin</var> be null.</p>

   </li><li><p>Let <var>creatorBaseURL</var> be null.</p></li><li id="creator-browsing-context">
    <p>If <var>creator</var> is non-null, then:</p>

    <ol><li><p>Set <var>creatorOrigin</var> to <var>creator</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="creating-browsing-contexts:concept-document-origin" data-x-internal="concept-document-origin">origin</a>.</p></li><li><p>Set <var>creatorBaseURL</var> to <var>creator</var>'s <a href="#document-base-url" id="creating-browsing-contexts:document-base-url">document base
     URL</a>.</p></li><li><p>Set <var>browsingContext</var>'s <a href="#virtual-browsing-context-group-id" id="creating-browsing-contexts:virtual-browsing-context-group-id">virtual browsing context group ID</a> to
     <var>creator</var>'s <a href="#concept-document-bc" id="creating-browsing-contexts:concept-document-bc">browsing context</a>'s <a href="#bc-tlbc" id="creating-browsing-contexts:bc-tlbc">top-level browsing context</a>'s <a href="#virtual-browsing-context-group-id" id="creating-browsing-contexts:virtual-browsing-context-group-id-2">virtual browsing context group ID</a>.</p></li></ol>
   </li><li><p>Let <var>sandboxFlags</var> be the result of <a href="#determining-the-creation-sandboxing-flags" id="creating-browsing-contexts:determining-the-creation-sandboxing-flags">determining the creation sandboxing
   flags</a> given <var>browsingContext</var> and <var>embedder</var>.</p></li><li id="about-blank-origin"><p>Let <var>origin</var> be the result of <a href="#determining-the-origin" id="creating-browsing-contexts:determining-the-origin">determining the
   origin</a> given <code id="creating-browsing-contexts:about:blank"><a href="#about:blank">about:blank</a></code>, <var>sandboxFlags</var>, and
   <var>creatorOrigin</var>.</p></li><li>
    <p>Let <var>permissionsPolicy</var> be the result of <a id="creating-browsing-contexts:creating-a-permissions-policy" href="https://w3c.github.io/webappsec-feature-policy/#create-for-navigable" data-x-internal="creating-a-permissions-policy">creating a permissions policy</a>
    given <var>embedder</var> and <var>origin</var>. <a href="#refsPERMISSIONSPOLICY">[PERMISSIONSPOLICY]</a></p>
   </li><li><p>Let <var>agent</var> be the result of <a href="#obtain-similar-origin-window-agent" id="creating-browsing-contexts:obtain-similar-origin-window-agent">obtaining a similar-origin window agent</a> given
   <var>origin</var>, <var>group</var>, and false.</p></li><li>
    <p>Let <var>realm execution context</var> be the result of <a href="#creating-a-new-javascript-realm" id="creating-browsing-contexts:creating-a-new-javascript-realm">creating a new realm</a>
    given <var>agent</var> and the following customizations:</p>

    <ul><li><p>For the global object, create a new <code id="creating-browsing-contexts:window"><a href="#window">Window</a></code> object.</p></li><li><p>For the global <b>this</b> binding, use <var>browsingContext</var>'s
     <code id="creating-browsing-contexts:windowproxy"><a href="#windowproxy">WindowProxy</a></code> object.</p></li></ul>
   </li><li><p>Let <var>topLevelCreationURL</var> be <code id="creating-browsing-contexts:about:blank-2"><a href="#about:blank">about:blank</a></code> if <var>embedder</var> is
   null; otherwise <var>embedder</var>'s <a href="#relevant-settings-object" id="creating-browsing-contexts:relevant-settings-object">relevant settings object</a>'s <a href="#concept-environment-top-level-creation-url" id="creating-browsing-contexts:concept-environment-top-level-creation-url">top-level
   creation URL</a>.</p></li><li><p>Let <var>topLevelOrigin</var> be <var>origin</var> if <var>embedder</var> is null;
   otherwise <var>embedder</var>'s <a href="#relevant-settings-object" id="creating-browsing-contexts:relevant-settings-object-2">relevant settings object</a>'s <a href="#concept-environment-top-level-origin" id="creating-browsing-contexts:concept-environment-top-level-origin">top-level
   origin</a>.</p></li><li><p><a href="#set-up-a-window-environment-settings-object" id="creating-browsing-contexts:set-up-a-window-environment-settings-object">Set up a window environment settings object</a> with <code id="creating-browsing-contexts:about:blank-3"><a href="#about:blank">about:blank</a></code>,
   <var>realm execution context</var>, null, <var>topLevelCreationURL</var>, and
   <var>topLevelOrigin</var>.</p></li><li><p>Let <var>loadTimingInfo</var> be a new <a href="#document-load-timing-info" id="creating-browsing-contexts:document-load-timing-info">document load timing info</a> with
   its <a href="#navigation-start-time" id="creating-browsing-contexts:navigation-start-time">navigation start time</a> set to the result of calling <a id="creating-browsing-contexts:coarsen-time" href="https://w3c.github.io/hr-time/#dfn-coarsen-time" data-x-internal="coarsen-time">coarsen time</a>
   with <var>unsafeContextCreationTime</var> and the new <a href="#environment-settings-object" id="creating-browsing-contexts:environment-settings-object">environment settings object</a>'s
   <a href="#concept-settings-object-cross-origin-isolated-capability" id="creating-browsing-contexts:concept-settings-object-cross-origin-isolated-capability">cross-origin isolated
   capability</a>.</p></li><li>
    <p>Let <var>document</var> be a new <code id="creating-browsing-contexts:document-2"><a href="#document">Document</a></code>, with:</p>

    <dl class="props"><dt><a href="https://dom.spec.whatwg.org/#concept-document-type" id="creating-browsing-contexts:concept-document-type" data-x-internal="concept-document-type">type</a></dt><dd>"<code>html</code>"</dd><dt><a href="https://dom.spec.whatwg.org/#concept-document-content-type" id="creating-browsing-contexts:concept-document-content-type" data-x-internal="concept-document-content-type">content type</a></dt><dd>"<code id="creating-browsing-contexts:text/html"><a href="#text/html">text/html</a></code>"</dd><dt><a href="https://dom.spec.whatwg.org/#concept-document-mode" id="creating-browsing-contexts:concept-document-mode" data-x-internal="concept-document-mode">mode</a></dt><dd>"<code>quirks</code>"</dd><dt><a href="https://dom.spec.whatwg.org/#concept-document-origin" id="creating-browsing-contexts:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a></dt><dd><var>origin</var></dd><dt><a href="#concept-document-bc" id="creating-browsing-contexts:concept-document-bc-2">browsing context</a></dt><dd><var>browsingContext</var>

     </dd><dt><a href="#concept-document-permissions-policy" id="creating-browsing-contexts:concept-document-permissions-policy">permissions policy</a></dt><dd><var>permissionsPolicy</var></dd><dt><a href="#active-sandboxing-flag-set" id="creating-browsing-contexts:active-sandboxing-flag-set">active sandboxing flag set</a></dt><dd><var>sandboxFlags</var></dd><dt><a href="#load-timing-info" id="creating-browsing-contexts:load-timing-info">load timing info</a></dt><dd><var>loadTimingInfo</var></dd><dt><a href="#is-initial-about:blank" id="creating-browsing-contexts:is-initial-about:blank">is initial <code>about:blank</code></a></dt><dd>true</dd><dt><a href="#concept-document-about-base-url" id="creating-browsing-contexts:concept-document-about-base-url">about base URL</a></dt><dd><var>creatorBaseURL</var></dd><dt><a href="https://dom.spec.whatwg.org/#concept-document-allow-declarative-shadow-roots" id="creating-browsing-contexts:concept-document-allow-declarative-shadow-roots" data-x-internal="concept-document-allow-declarative-shadow-roots">allow declarative shadow
     roots</a></dt><dd>true</dd><dt><a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="creating-browsing-contexts:document-custom-element-registry" data-x-internal="document-custom-element-registry">custom element registry</a></dt><dd>a new <code id="creating-browsing-contexts:customelementregistry"><a href="#customelementregistry">CustomElementRegistry</a></code> object</dd></dl>
   </li><li>
    <p>If <var>creator</var> is non-null, then:</p>

    <ol><li><p>Set <var>document</var>'s <a href="#the-document's-referrer" id="creating-browsing-contexts:the-document's-referrer">referrer</a> to the
     <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="creating-browsing-contexts:concept-url-serializer" data-x-internal="concept-url-serializer">serialization</a> of <var>creator</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="creating-browsing-contexts:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li><p>Set <var>document</var>'s <a href="#concept-document-policy-container" id="creating-browsing-contexts:concept-document-policy-container">policy
     container</a> to a <a href="#clone-a-policy-container" id="creating-browsing-contexts:clone-a-policy-container">clone</a> of
     <var>creator</var>'s <a href="#concept-document-policy-container" id="creating-browsing-contexts:concept-document-policy-container-2">policy
     container</a>.</p></li><li><p>If <var>creator</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="creating-browsing-contexts:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a> is
     <a href="#same-origin" id="creating-browsing-contexts:same-origin">same origin</a> with <var>creator</var>'s <a href="#relevant-settings-object" id="creating-browsing-contexts:relevant-settings-object-3">relevant settings object</a>'s
     <a href="#concept-environment-top-level-origin" id="creating-browsing-contexts:concept-environment-top-level-origin-2">top-level origin</a>, then set <var>document</var>'s <a href="#concept-document-coop" id="creating-browsing-contexts:concept-document-coop">opener policy</a> to <var>creator</var>'s <a href="#concept-document-bc" id="creating-browsing-contexts:concept-document-bc-3">browsing context</a>'s <a href="#bc-tlbc" id="creating-browsing-contexts:bc-tlbc-2">top-level
     browsing context</a>'s <a href="#active-document" id="creating-browsing-contexts:active-document">active document</a>'s <a href="#concept-document-coop" id="creating-browsing-contexts:concept-document-coop-2">opener policy</a>.</p></li></ol>
   </li><li><p><a id="creating-browsing-contexts:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="creating-browsing-contexts:the-document's-address-2" data-x-internal="the-document's-address">URL</a>
   and <var>document</var>'s <a href="#relevant-settings-object" id="creating-browsing-contexts:relevant-settings-object-4">relevant settings object</a>'s <a href="#concept-environment-creation-url" id="creating-browsing-contexts:concept-environment-creation-url">creation URL</a> are
   <code id="creating-browsing-contexts:about:blank-4"><a href="#about:blank">about:blank</a></code>.</p></li><li><p>Mark <var>document</var> as <a href="#ready-for-post-load-tasks" id="creating-browsing-contexts:ready-for-post-load-tasks">ready for post-load tasks</a>.</p></li><li><p><a href="#populate-with-html/head/body" id="creating-browsing-contexts:populate-with-html/head/body">Populate with <code>html</code>/<code>head</code>/<code>body</code></a> given
   <var>document</var>.</p></li><li><p><a href="#make-active" id="creating-browsing-contexts:make-active">Make active</a> <var>document</var>.</p></li><li><p><a href="#completely-finish-loading" id="creating-browsing-contexts:completely-finish-loading">Completely finish loading</a> <var>document</var>.</p></li><li><p>Return <var>browsingContext</var> and <var>document</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-new-top-level-browsing-context">create a new top-level browsing context and document</dfn>:</p>

  <ol><li><p>Let <var>group</var> and <var>document</var> be the result of <a href="#creating-a-new-browsing-context-group-and-document" id="creating-browsing-contexts:creating-a-new-browsing-context-group-and-document">creating a new
   browsing context group and document</a>.</p></li><li><p>Return <var>group</var>'s <a href="#browsing-context-set" id="creating-browsing-contexts:browsing-context-set">browsing context set</a>[0] and
   <var>document</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-new-auxiliary-browsing-context">create a new auxiliary browsing context and document</dfn>, given
  a <a href="#browsing-context" id="creating-browsing-contexts:browsing-context-2">browsing context</a> <var>opener</var>:</p>

  <ol><li><p>Let <var>openerTopLevelBrowsingContext</var> be <var>opener</var>'s <a href="#bc-traversable" id="creating-browsing-contexts:bc-traversable">top-level traversable</a>'s <a href="#nav-bc" id="creating-browsing-contexts:nav-bc">active browsing
   context</a>.</p></li><li><p>Let <var>group</var> be <var>openerTopLevelBrowsingContext</var>'s <a href="#tlbc-group" id="creating-browsing-contexts:tlbc-group">group</a>.</p></li><li><p><a id="creating-browsing-contexts:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>group</var> is non-null, as <a href="#navigate" id="creating-browsing-contexts:navigate">navigating</a> invokes this directly.</p></li><li><p>Let <var>browsingContext</var> and <var>document</var> be the result of <a href="#creating-a-new-browsing-context" id="creating-browsing-contexts:creating-a-new-browsing-context">creating a
   new browsing context and document</a> with <var>opener</var>'s <a href="#nav-document" id="creating-browsing-contexts:nav-document">active document</a>, null, and <var>group</var>.</p></li><li><p>Set <var>browsingContext</var>'s <a href="#is-auxiliary" id="creating-browsing-contexts:is-auxiliary">is auxiliary</a> to true.</p></li><li><p><a href="#bcg-append" id="creating-browsing-contexts:bcg-append">Append</a> <var>browsingContext</var> to
   <var>group</var>.</p></li><li><p>Set <var>browsingContext</var>'s <a href="#opener-browsing-context" id="creating-browsing-contexts:opener-browsing-context">opener browsing context</a> to
   <var>opener</var>.</p></li><li><p>Set <var>browsingContext</var>'s <a href="#virtual-browsing-context-group-id" id="creating-browsing-contexts:virtual-browsing-context-group-id-3">virtual
   browsing context group ID</a> to <var>openerTopLevelBrowsingContext</var>'s <a href="#virtual-browsing-context-group-id" id="creating-browsing-contexts:virtual-browsing-context-group-id-4">virtual browsing context group ID</a>.</p></li><li><p>Set <var>browsingContext</var>'s <a href="#opener-origin-at-creation" id="creating-browsing-contexts:opener-origin-at-creation">opener origin
   at creation</a> to <var>opener</var>'s <a href="#nav-document" id="creating-browsing-contexts:nav-document-2">active document</a>'s
   <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="creating-browsing-contexts:concept-document-origin-4" data-x-internal="concept-document-origin">origin</a>.</p></li><li><p>Return <var>browsingContext</var> and <var>document</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="determining-the-origin">determine the origin</dfn>, given a <a id="creating-browsing-contexts:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>
  <var>url</var>, a <a href="#sandboxing-flag-set" id="creating-browsing-contexts:sandboxing-flag-set">sandboxing flag set</a> <var>sandboxFlags</var>, and an
  <a href="#concept-origin" id="creating-browsing-contexts:concept-origin">origin</a>-or-null <var>sourceOrigin</var>:</p>

  <ol><li id="sandboxOrigin"><p>If <var>sandboxFlags</var> has its <a href="#sandboxed-origin-browsing-context-flag" id="creating-browsing-contexts:sandboxed-origin-browsing-context-flag">sandboxed origin browsing
   context flag</a> set, then return a new <a href="#concept-origin-opaque" id="creating-browsing-contexts:concept-origin-opaque">opaque
   origin</a>.</p></li><li><p>If <var>url</var> is null, then return a new <a href="#concept-origin-opaque" id="creating-browsing-contexts:concept-origin-opaque-2">opaque
   origin</a>.</p></li><li>
    <p>If <var>url</var> is <code id="creating-browsing-contexts:about:srcdoc"><a href="#about:srcdoc">about:srcdoc</a></code>, then:</p>

    <ol><li><p><a id="creating-browsing-contexts:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>sourceOrigin</var> is non-null.</p></li><li><p>Return <var>sourceOrigin</var>.</p></li></ol>
   </li><li><p>If <var>url</var> <a href="#matches-about:blank" id="creating-browsing-contexts:matches-about:blank">matches <code>about:blank</code></a> and
   <var>sourceOrigin</var> is non-null, then return <var>sourceOrigin</var>.</p></li><li><p>Return <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="creating-browsing-contexts:concept-url-origin" data-x-internal="concept-url-origin">origin</a>.</p></li></ol>

  <p class="note">The cases that return <var>sourceOrigin</var> result in two
  <code id="creating-browsing-contexts:document-3"><a href="#document">Document</a></code>s that end up with the same underlying <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="creating-browsing-contexts:concept-document-origin-5" data-x-internal="concept-document-origin">origin</a>, meaning that <code id="creating-browsing-contexts:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code> affects both.</p>
  </div>


  <h5 id="nested-browsing-contexts"><span class="secno">7.3.2.2</span> Related browsing contexts<a href="#nested-browsing-contexts" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A <a href="#browsing-context" id="nested-browsing-contexts:browsing-context">browsing context</a> <var>potentialDescendant</var> is said to be an <dfn id="ancestor-browsing-context">ancestor</dfn> of a browsing context
  <var>potentialAncestor</var> if the following algorithm returns true:</p>

  <ol><li><p>Let <var>potentialDescendantDocument</var> be <var>potentialDescendant</var>'s
   <a href="#active-document" id="nested-browsing-contexts:active-document">active document</a>.</p></li><li><p>If <var>potentialDescendantDocument</var> is not <a href="#fully-active" id="nested-browsing-contexts:fully-active">fully active</a>, then return
   false.</p></li><li><p>Let <var>ancestorBCs</var> be the list obtained by taking the <a href="#concept-document-bc" id="nested-browsing-contexts:concept-document-bc">browsing context</a> of the <a href="#nav-document" id="nested-browsing-contexts:nav-document">active
   document</a> of each member of <var>potentialDescendantDocument</var>'s <a href="#ancestor-navigables" id="nested-browsing-contexts:ancestor-navigables">ancestor
   navigables</a>.</p></li><li><p>If <var>ancestorBCs</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="nested-browsing-contexts:list-contains" data-x-internal="list-contains">contains</a>
   <var>potentialAncestor</var>, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <dfn id="top-level-browsing-context" data-export="">top-level browsing context</dfn> is a <a href="#browsing-context" id="nested-browsing-contexts:browsing-context-2">browsing context</a> whose
  <a href="#active-document" id="nested-browsing-contexts:active-document-2">active document</a>'s <a href="#node-navigable" id="nested-browsing-contexts:node-navigable">node navigable</a> is a <a href="#traversable-navigable" id="nested-browsing-contexts:traversable-navigable">traversable
  navigable</a>.</p>
  </div>

  <p class="note">It is <em>not</em> required to be a <a href="#top-level-traversable" id="nested-browsing-contexts:top-level-traversable">top-level traversable</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="bc-tlbc">top-level browsing context</dfn> of a <a href="#browsing-context" id="nested-browsing-contexts:browsing-context-3">browsing context</a>
  <var>start</var> is the result of the following algorithm:</p>

  <ol><li><p>If <var>start</var>'s <a href="#active-document" id="nested-browsing-contexts:active-document-3">active document</a> is not <a href="#fully-active" id="nested-browsing-contexts:fully-active-2">fully active</a>, then
   return null.</p></li><li><p>Let <var>navigable</var> be <var>start</var>'s <a href="#active-document" id="nested-browsing-contexts:active-document-4">active document</a>'s <a href="#node-navigable" id="nested-browsing-contexts:node-navigable-2">node
   navigable</a>.</p></li><li><p>While <var>navigable</var>'s <a href="#nav-parent" id="nested-browsing-contexts:nav-parent">parent</a> is not null, set
   <var>navigable</var> to <var>navigable</var>'s <a href="#nav-parent" id="nested-browsing-contexts:nav-parent-2">parent</a>.</p></li><li><p>Return <var>navigable</var>'s <a href="#nav-bc" id="nested-browsing-contexts:nav-bc">active browsing
   context</a>.</p></li></ol>
  </div>

  <div id="warning-avoid-related-bc-terms" class="warning">
   <p>The terms <a href="#ancestor-browsing-context" id="nested-browsing-contexts:ancestor-browsing-context">ancestor browsing context</a> and <a href="#top-level-browsing-context" id="nested-browsing-contexts:top-level-browsing-context">top-level browsing context</a>
   are rarely useful, since <a href="#browsing-context" id="nested-browsing-contexts:browsing-context-4">browsing contexts</a> in general are
   <a href="#warning-avoid-using-bcs">usually the inappropriate specification concept to use</a>.
   Note in particular that when a <a href="#browsing-context" id="nested-browsing-contexts:browsing-context-5">browsing context</a>'s <a href="#active-document" id="nested-browsing-contexts:active-document-5">active document</a> is
   not <a href="#fully-active" id="nested-browsing-contexts:fully-active-3">fully active</a>, it never counts as an ancestor or top-level browsing context, and
   as such these concepts are not useful when <a href="#note-bfcache">bfcache</a> is in play.</p>

   <p>Instead, use concepts such as the <a href="#ancestor-navigables" id="nested-browsing-contexts:ancestor-navigables-2">ancestor navigables</a> collection, the <a href="#nav-parent" id="nested-browsing-contexts:nav-parent-3">parent navigable</a>, or a navigable's <a href="#nav-traversable" id="nested-browsing-contexts:nav-traversable">top-level traversable</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p id="security-1"><span id="security-nav"></span>A <a href="#browsing-context" id="nested-browsing-contexts:browsing-context-6">browsing context</a> <var>A</var> is
  <dfn id="familiar-with">familiar with</dfn> a second <a href="#browsing-context" id="nested-browsing-contexts:browsing-context-7">browsing context</a> <var>B</var> if the following
  algorithm returns true:</p>

  <ol><li><p>If <var>A</var>'s <a href="#active-document" id="nested-browsing-contexts:active-document-6">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="nested-browsing-contexts:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is <a href="#same-origin" id="nested-browsing-contexts:same-origin">same origin</a> with <var>B</var>'s
   <a href="#active-document" id="nested-browsing-contexts:active-document-7">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="nested-browsing-contexts:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>, then return
   true.</p></li><li><p>If <var>A</var>'s <a href="#bc-tlbc" id="nested-browsing-contexts:bc-tlbc">top-level browsing context</a> is
   <var>B</var>, then return true.</p></li><li><p>If <var>B</var> is an <a href="#auxiliary-browsing-context" id="nested-browsing-contexts:auxiliary-browsing-context">auxiliary browsing context</a> and <var>A</var> is
   <a href="#familiar-with" id="nested-browsing-contexts:familiar-with">familiar with</a> <var>B</var>'s <a href="#opener-browsing-context" id="nested-browsing-contexts:opener-browsing-context">opener browsing context</a>, then return
   true.</p></li><li>
    <p>If there exists an <a href="#ancestor-browsing-context" id="nested-browsing-contexts:ancestor-browsing-context-2">ancestor browsing context</a> of <var>B</var> whose <a href="#active-document" id="nested-browsing-contexts:active-document-8">active
    document</a> has the <a href="#same-origin" id="nested-browsing-contexts:same-origin-2">same</a> <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="nested-browsing-contexts:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a> as the <a href="#active-document" id="nested-browsing-contexts:active-document-9">active document</a> of
    <var>A</var>, then return true.</p>

    <p class="note">This includes the case where <var>A</var> is an <a href="#ancestor-browsing-context" id="nested-browsing-contexts:ancestor-browsing-context-3">ancestor browsing
    context</a> of <var>B</var>.</p>
   </li><li><p>Return false.</p></li></ol>
  </div>

  <h5 id="groupings-of-browsing-contexts"><span class="secno">7.3.2.3</span> Groupings of browsing contexts<a href="#groupings-of-browsing-contexts" class="self-link"></a></h5>

  <p>A <a href="#top-level-browsing-context" id="groupings-of-browsing-contexts:top-level-browsing-context">top-level browsing context</a> has an associated <dfn id="tlbc-group">group</dfn> (null or a <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group">browsing context group</a>). It is initially null.</p>

  <p>A user agent holds a <dfn id="browsing-context-group-set">browsing context group set</dfn> (a <a id="groupings-of-browsing-contexts:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-2">browsing context groups</a>).</p>

  <p>A <dfn id="browsing-context-group">browsing context group</dfn> holds a <dfn id="browsing-context-set">browsing context set</dfn> (a <a id="groupings-of-browsing-contexts:set-2" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a>
  of <a href="#top-level-browsing-context" id="groupings-of-browsing-contexts:top-level-browsing-context-2">top-level browsing contexts</a>).</p>

  <p class="note">A <a href="#top-level-browsing-context" id="groupings-of-browsing-contexts:top-level-browsing-context-3">top-level browsing context</a> is added to the <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-3">group</a> when the group is <a href="#creating-a-new-browsing-context-group-and-document" id="groupings-of-browsing-contexts:creating-a-new-browsing-context-group-and-document">created</a>. All subsequent <a href="#top-level-browsing-context" id="groupings-of-browsing-contexts:top-level-browsing-context-4">top-level
  browsing contexts</a> added to the <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-4">group</a> will be
  <a href="#auxiliary-browsing-context" id="groupings-of-browsing-contexts:auxiliary-browsing-context">auxiliary browsing contexts</a>.</p>

  <p>A <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-5">browsing context group</a> has an associated <dfn id="agent-cluster-map">agent cluster map</dfn> (a weak
  <a href="https://infra.spec.whatwg.org/#ordered-map" id="groupings-of-browsing-contexts:ordered-map" data-x-internal="ordered-map">map</a> of <a href="#agent-cluster-key" id="groupings-of-browsing-contexts:agent-cluster-key">agent cluster
  keys</a> to <a href="https://tc39.es/ecma262/#sec-agent-clusters" id="groupings-of-browsing-contexts:agent-cluster" data-x-internal="agent-cluster">agent clusters</a>). User agents are responsible
  for collecting agent clusters when it is deemed that nothing can access them anymore.</p>

  <p>A <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-6">browsing context group</a> has an associated <dfn id="historical-agent-cluster-key-map">historical agent cluster key
  map</dfn>, which is a <a href="https://infra.spec.whatwg.org/#ordered-map" id="groupings-of-browsing-contexts:ordered-map-2" data-x-internal="ordered-map">map</a> of <a href="#concept-origin" id="groupings-of-browsing-contexts:concept-origin">origins</a> to <a href="#agent-cluster-key" id="groupings-of-browsing-contexts:agent-cluster-key-2">agent cluster keys</a>. This
  map is used to ensure the consistency of the <a href="#origin-keyed-agent-clusters">origin-keyed
  agent clusters</a> feature by recording what agent cluster keys were previously used for a given
  origin.</p>

  <p class="note">The <a href="#historical-agent-cluster-key-map" id="groupings-of-browsing-contexts:historical-agent-cluster-key-map">historical agent cluster key map</a> only ever gains entries over the
  lifetime of the browsing context group.</p>

  <p>A <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-7">browsing context group</a> has a <dfn id="bcg-cross-origin-isolation">cross-origin isolation mode</dfn>, which is a
  <a href="#cross-origin-isolation-mode" id="groupings-of-browsing-contexts:cross-origin-isolation-mode">cross-origin isolation mode</a>. It is initially "<code id="groupings-of-browsing-contexts:cross-origin-isolation-none"><a href="#cross-origin-isolation-none">none</a></code>".</p>

  <p>A <dfn id="cross-origin-isolation-mode">cross-origin isolation mode</dfn> is one of three possible values: "<dfn id="cross-origin-isolation-none"><code>none</code></dfn>", "<dfn id="cross-origin-isolation-logical"><code>logical</code></dfn>", or "<dfn id="cross-origin-isolation-concrete"><code>concrete</code></dfn>".</p>

  <div class="note">
   <p>"<code id="groupings-of-browsing-contexts:cross-origin-isolation-logical"><a href="#cross-origin-isolation-logical">logical</a></code>" and "<code id="groupings-of-browsing-contexts:cross-origin-isolation-concrete"><a href="#cross-origin-isolation-concrete">concrete</a></code>" are similar. They are both used for
   <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-8">browsing context groups</a> where:</p>

   <ul><li><p>every top-level <code id="groupings-of-browsing-contexts:document"><a href="#document">Document</a></code> has `<code><a href="#cross-origin-opener-policy-2" id="groupings-of-browsing-contexts:cross-origin-opener-policy-2">Cross-Origin-Opener-Policy</a>: <a href="#coop-same-origin" id="groupings-of-browsing-contexts:coop-same-origin">same-origin</a></code>`, and</p></li><li><p>every <code id="groupings-of-browsing-contexts:document-2"><a href="#document">Document</a></code> has a `<code id="groupings-of-browsing-contexts:cross-origin-embedder-policy"><a href="#cross-origin-embedder-policy">Cross-Origin-Embedder-Policy</a></code>` header
    whose value is <a href="#compatible-with-cross-origin-isolation" id="groupings-of-browsing-contexts:compatible-with-cross-origin-isolation">compatible with cross-origin isolation</a>.</p></li></ul>

   <p>On some platforms, it is difficult to provide the security properties required to grant safe
   access to the APIs gated by the <a href="#concept-settings-object-cross-origin-isolated-capability" id="groupings-of-browsing-contexts:concept-settings-object-cross-origin-isolated-capability">cross-origin isolated
   capability</a>. As a result, only "<code id="groupings-of-browsing-contexts:cross-origin-isolation-concrete-2"><a href="#cross-origin-isolation-concrete">concrete</a></code>" can grant access that capability.
   "<code id="groupings-of-browsing-contexts:cross-origin-isolation-logical-2"><a href="#cross-origin-isolation-logical">logical</a></code>" is used on platform not supporting
   this capability, where various restrictions imposed by cross-origin isolation will still apply,
   but the capability is not granted.</p>
  </div>

  <div data-algorithm="">
  <p id="creating-a-new-browsing-context-group">To <dfn id="creating-a-new-browsing-context-group-and-document">create a new browsing context group and document</dfn>:</p>

  <ol><li><p>Let <var>group</var> be a new <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-9">browsing context group</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="groupings-of-browsing-contexts:set-append" data-x-internal="set-append">Append</a> <var>group</var> to the user agent's
   <a href="#browsing-context-group-set" id="groupings-of-browsing-contexts:browsing-context-group-set">browsing context group set</a>.</p></li><li><p>Let <var>browsingContext</var> and <var>document</var> be the result of <a href="#creating-a-new-browsing-context" id="groupings-of-browsing-contexts:creating-a-new-browsing-context">creating a
   new browsing context and document</a> with null, null, and <var>group</var>.</p></li><li><p><a href="#bcg-append" id="groupings-of-browsing-contexts:bcg-append">Append</a> <var>browsingContext</var> to
   <var>group</var>.</p></li><li><p>Return <var>group</var> and <var>document</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="bcg-append">append</dfn> a <a href="#top-level-browsing-context" id="groupings-of-browsing-contexts:top-level-browsing-context-5">top-level browsing context</a>
  <var>browsingContext</var> to a <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-10">browsing context group</a> <var>group</var>:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="groupings-of-browsing-contexts:set-append-2" data-x-internal="set-append">Append</a> <var>browsingContext</var> to <var>group</var>'s
   <a href="#browsing-context-set" id="groupings-of-browsing-contexts:browsing-context-set">browsing context set</a>.</p></li><li><p>Set <var>browsingContext</var>'s <a href="#tlbc-group" id="groupings-of-browsing-contexts:tlbc-group">group</a> to
   <var>group</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="bcg-remove">remove</dfn> a <a href="#top-level-browsing-context" id="groupings-of-browsing-contexts:top-level-browsing-context-6">top-level browsing context</a>
  <var>browsingContext</var>:</p>

  <ol><li><p><a id="groupings-of-browsing-contexts:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>browsingContext</var>'s <a href="#tlbc-group" id="groupings-of-browsing-contexts:tlbc-group-2">group</a>
   is non-null.</p></li><li><p>Let <var>group</var> be <var>browsingContext</var>'s <a href="#tlbc-group" id="groupings-of-browsing-contexts:tlbc-group-3">group</a>.</p></li><li><p>Set <var>browsingContext</var>'s <a href="#tlbc-group" id="groupings-of-browsing-contexts:tlbc-group-4">group</a> to null.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="groupings-of-browsing-contexts:list-remove" data-x-internal="list-remove">Remove</a> <var>browsingContext</var> from
   <var>group</var>'s <a href="#browsing-context-set" id="groupings-of-browsing-contexts:browsing-context-set-2">browsing context set</a>.</p></li><li><p>If <var>group</var>'s <a href="#browsing-context-set" id="groupings-of-browsing-contexts:browsing-context-set-3">browsing context set</a> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="groupings-of-browsing-contexts:list-is-empty" data-x-internal="list-is-empty">is
   empty</a>, then <a href="https://infra.spec.whatwg.org/#list-remove" id="groupings-of-browsing-contexts:list-remove-2" data-x-internal="list-remove">remove</a> <var>group</var> from the user
   agent's <a href="#browsing-context-group-set" id="groupings-of-browsing-contexts:browsing-context-group-set-2">browsing context group set</a>.</p></li></ol>
  </div>

  <p class="note"><a href="#bcg-append" id="groupings-of-browsing-contexts:bcg-append-2">Append</a> and <a href="#bcg-remove" id="groupings-of-browsing-contexts:bcg-remove">remove</a> are primitive operations that help define the lifetime of a <a href="#browsing-context-group" id="groupings-of-browsing-contexts:browsing-context-group-11">browsing
  context group</a>. They are called by higher-level creation and destruction operations for
  <code id="groupings-of-browsing-contexts:document-3"><a href="#document">Document</a></code>s and <a href="#browsing-context" id="groupings-of-browsing-contexts:browsing-context">browsing contexts</a>.</p>

  <div data-algorithm="">
  <p id="a-browsing-context-is-discarded">When there are no <code id="groupings-of-browsing-contexts:document-4"><a href="#document">Document</a></code> objects whose
  <a href="#concept-document-bc" id="groupings-of-browsing-contexts:concept-document-bc">browsing context</a> equals a given <a href="#browsing-context" id="groupings-of-browsing-contexts:browsing-context-2">browsing
  context</a> (i.e., all such <code id="groupings-of-browsing-contexts:document-5"><a href="#document">Document</a></code>s have been <a href="#destroy-a-document" id="groupings-of-browsing-contexts:destroy-a-document">destroyed</a>), and that <a href="#browsing-context" id="groupings-of-browsing-contexts:browsing-context-3">browsing context</a>'s <code id="groupings-of-browsing-contexts:windowproxy"><a href="#windowproxy">WindowProxy</a></code> is
  eligible for garbage collection, then the <a href="#browsing-context" id="groupings-of-browsing-contexts:browsing-context-4">browsing context</a> will never be accessed
  again. If it is a <a href="#top-level-browsing-context" id="groupings-of-browsing-contexts:top-level-browsing-context-7">top-level browsing context</a>, then at this point the user agent must
  <a href="#bcg-remove" id="groupings-of-browsing-contexts:bcg-remove-2">remove</a> it.</p>
  </div>


  <h4 id="fully-active-documents"><span class="secno">7.3.3</span> Fully active documents<a href="#fully-active-documents" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A <code id="fully-active-documents:document"><a href="#document">Document</a></code> <var>d</var> is said to be <dfn data-dfn-for="Document" id="fully-active" data-export="">fully
  active</dfn> when <var>d</var> is the <a href="#nav-document" id="fully-active-documents:nav-document">active document</a> of a
  <a href="#navigable" id="fully-active-documents:navigable">navigable</a> <var>navigable</var>, and either <var>navigable</var> is a <a href="#top-level-traversable" id="fully-active-documents:top-level-traversable">top-level
  traversable</a> or <var>navigable</var>'s <a href="#nav-container-document" id="fully-active-documents:nav-container-document">container
  document</a> is <a href="#fully-active" id="fully-active-documents:fully-active">fully active</a>.</p>
  </div>

  <p>Because they are associated with an element, <a href="#child-navigable" id="fully-active-documents:child-navigable">child
  navigables</a> are always tied to a specific <code id="fully-active-documents:document-2"><a href="#document">Document</a></code>, their <a href="#nav-container-document" id="fully-active-documents:nav-container-document-2">container document</a>, in their <a href="#nav-parent" id="fully-active-documents:nav-parent">parent navigable</a>. User agents must not allow the user to interact with
  <a href="#child-navigable" id="fully-active-documents:child-navigable-2">child navigables</a> whose <a href="#nav-container-document" id="fully-active-documents:nav-container-document-3">container documents</a> are not themselves <a href="#fully-active" id="fully-active-documents:fully-active-2">fully
  active</a>.</p>

  <div class="example">
   <p>The following example illustrates how a <code id="fully-active-documents:document-3"><a href="#document">Document</a></code> can be the <a href="#nav-document" id="fully-active-documents:nav-document-2">active document</a> of its <a href="#node-navigable" id="fully-active-documents:node-navigable">node navigable</a>, while not being
   <a href="#fully-active" id="fully-active-documents:fully-active-3">fully active</a>. Here <code>a.html</code> is loaded into a browser window,
   <code>b-1.html</code> starts out loaded into an <code id="fully-active-documents:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> as shown, and
   <code>b-2.html</code> and <code>c.html</code> are omitted (they can simply
   be an empty document).</p>

   <pre><code class="html"><c- c="">&lt;!-- a.html --&gt;</c->
<c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Navigable A<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"b-1.html"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"frames[0].location.href = 'b-2.html'"</c-><c- p="">&gt;</c->Click me<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->

<c- c="">&lt;!-- b-1.html --&gt;</c->
<c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Navigable B<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"c.html"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></code></pre>

   <p>At this point, the documents given by <code>a.html</code>, <code>b-1.html</code>, and <code>c.html</code> are all the <a href="#nav-document" id="fully-active-documents:nav-document-3">active documents</a> of their respective <a href="#node-navigable" id="fully-active-documents:node-navigable-2">node navigables</a>. They are also all <a href="#fully-active" id="fully-active-documents:fully-active-4">fully active</a>.</p>

   <p>After clicking on the <code id="fully-active-documents:the-button-element"><a href="#the-button-element">button</a></code>, and thus loading a new <code id="fully-active-documents:document-4"><a href="#document">Document</a></code> from
   <code>b-2.html</code> into navigable B, we have the following results:</p>

   <ul><li><p>The <code>a.html</code> <code id="fully-active-documents:document-5"><a href="#document">Document</a></code> remains both the <a href="#nav-document" id="fully-active-documents:nav-document-4">active document</a> of navigable A, and <a href="#fully-active" id="fully-active-documents:fully-active-5">fully
    active</a>.</p></li><li><p>The <code>b-1.html</code> <code id="fully-active-documents:document-6"><a href="#document">Document</a></code> is now <em>not</em> the <a href="#nav-document" id="fully-active-documents:nav-document-5">active document</a> of navigable B. As such it is also not <a href="#fully-active" id="fully-active-documents:fully-active-6">fully
    active</a>.</p></li><li><p>The new <code>b-2.html</code> <code id="fully-active-documents:document-7"><a href="#document">Document</a></code> is now the <a href="#nav-document" id="fully-active-documents:nav-document-6">active document</a> of navigable B, and is also <a href="#fully-active" id="fully-active-documents:fully-active-7">fully
    active</a>.</p></li><li><p>The <code>c.html</code> <code id="fully-active-documents:document-8"><a href="#document">Document</a></code> is still the <a href="#nav-document" id="fully-active-documents:nav-document-7">active document</a> of navigable C. However, since C's <a href="#nav-container-document" id="fully-active-documents:nav-container-document-4">container document</a> is the <code>b-1.html</code> <code id="fully-active-documents:document-9"><a href="#document">Document</a></code>, which is itself not <a href="#fully-active" id="fully-active-documents:fully-active-8">fully active</a>,
    this means the <code>c.html</code> <code id="fully-active-documents:document-10"><a href="#document">Document</a></code> is now not <a href="#fully-active" id="fully-active-documents:fully-active-9">fully
    active</a>.</p></li></ul>
  </div>


  <h3 id="navigation-and-session-history"><span class="secno">7.4</span> <span id="history"></span>Navigation and session
  history<a href="#navigation-and-session-history" class="self-link"></a></h3>

  <p>Welcome to the dragon's maw. Navigation, session history, and the traversal through that
  session history are some of the most complex parts of this standard.</p>

  <p>The basic concept may not seem so difficult:</p>

  <ul><li><p>The user is looking at a <a href="#navigable" id="navigation-and-session-history:navigable">navigable</a> that is presenting its <a href="#nav-document" id="navigation-and-session-history:nav-document">active document</a>. They <a href="#navigate" id="navigation-and-session-history:navigate">navigate</a> it to another
   <a id="navigation-and-session-history:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p></li><li><p>The browser fetches the given URL from the network, using it to <a href="#attempt-to-populate-the-history-entry's-document" id="navigation-and-session-history:attempt-to-populate-the-history-entry's-document">populate</a> a new <a href="#session-history-entry" id="navigation-and-session-history:session-history-entry">session history entry</a>
   with a newly-<a href="#initialise-the-document-object" id="navigation-and-session-history:initialise-the-document-object">created</a>
   <code id="navigation-and-session-history:document"><a href="#document">Document</a></code>.</p></li><li><p>The browser updates the <a href="#navigable" id="navigation-and-session-history:navigable-2">navigable</a>'s <a href="#nav-active-history-entry" id="navigation-and-session-history:nav-active-history-entry">active session history entry</a> to the newly-populated
   one, and thus updates the <a href="#nav-document" id="navigation-and-session-history:nav-document-2">active document</a> that it is showing
   to the user.</p></li><li><p>At some point later, the user <a href="#traverse-the-history-by-a-delta" id="navigation-and-session-history:traverse-the-history-by-a-delta">presses the
   browser back button</a> to go back to the previous <a href="#session-history-entry" id="navigation-and-session-history:session-history-entry-2">session history
   entry</a>.</p></li><li><p>The browser looks at the <a href="#she-url" id="navigation-and-session-history:she-url">URL</a> stored in that <a href="#session-history-entry" id="navigation-and-session-history:session-history-entry-3">session
   history entry</a>, and uses it to re-fetch and <a href="#attempt-to-populate-the-history-entry's-document" id="navigation-and-session-history:attempt-to-populate-the-history-entry's-document-2">populate</a> that entry's <a href="#she-document" id="navigation-and-session-history:she-document">document</a>.</p></li><li><p>The browser again updates the <a href="#navigable" id="navigation-and-session-history:navigable-3">navigable</a>'s <a href="#nav-active-history-entry" id="navigation-and-session-history:nav-active-history-entry-2">active session history entry</a>.</p></li></ul>

  <p>You can see some of the intertwined complexity peeking through here, in how traversal can
  cause a navigation (i.e., a network fetch to a stored URL), and how a navigation necessarily
  needs to interface with the session history list to ensure that when it finishes the user is
  looking at the right thing. But the real problems come in with the various edge cases and
  interacting web platform features:</p>

  <ul><li><p><a href="#child-navigable" id="navigation-and-session-history:child-navigable">Child navigables</a> (e.g., those contained in
   <code id="navigation-and-session-history:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s) can also navigate and traverse, but those navigations need to be
   linearized into <a href="#tn-session-history-entries" id="navigation-and-session-history:tn-session-history-entries">a single session history list</a>
   since the user only has a single back/forward interface for the entire <a href="#traversable-navigable" id="navigation-and-session-history:traversable-navigable">traversable
   navigable</a> (e.g., browser tab).</p></li><li><p>Since the user can traverse back more than a single step in the session history (e.g., by
   holding down their back button), they can end up traversing multiple <a href="#navigable" id="navigation-and-session-history:navigable-4">navigables</a> at the same time when <a href="#child-navigable" id="navigation-and-session-history:child-navigable-2">child navigables</a> are involved. This needs to be synchronized across all of
   the involved navigables, which might involve multiple <a href="#event-loop" id="navigation-and-session-history:event-loop">event
   loops</a> or even <a href="https://tc39.es/ecma262/#sec-agent-clusters" id="navigation-and-session-history:agent-cluster" data-x-internal="agent-cluster">agent clusters</a>.</p></li><li><p>During navigation, servers can respond with 204 or 205 status codes or with `<code id="navigation-and-session-history:http-content-disposition"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition: attachment</a></code>` headers, which cause
   navigation to abort and the <a href="#navigable" id="navigation-and-session-history:navigable-5">navigable</a> to stay on its original <a href="#active-document" id="navigation-and-session-history:active-document">active document</a>. (This is much worse if it happens during a traversal-initiated
   navigation!)</p></li><li><p>Various other HTTP headers, such as `<code>Location</code>`,
   `<code id="navigation-and-session-history:refresh"><a href="#refresh">Refresh</a></code>`, `<code id="navigation-and-session-history:x-frame-options"><a href="#x-frame-options">X-Frame-Options</a></code>`, and those for Content Security Policy,
   contribute to either the <a href="#create-navigation-params-by-fetching" id="navigation-and-session-history:create-navigation-params-by-fetching">fetching
   process</a>, or the <a href="#initialise-the-document-object" id="navigation-and-session-history:initialise-the-document-object-2"><code>Document</code>-creation
   process</a>, or both. The `<code id="navigation-and-session-history:cross-origin-opener-policy-2"><a href="#cross-origin-opener-policy-2">Cross-Origin-Opener-Policy</a></code>` header even contributes
   to the <a href="#browsing-context-group-switches-due-to-cross-origin-opener-policy">browsing
   context selection and creation</a> process!</p></li><li><p>Some navigations (namely <a href="#scroll-to-fragid">fragment navigations</a> and <a href="#navigate-non-frag-sync">single-page app navigations</a>) are synchronous, meaning that
   JavaScript code expects to observe the navigation's results instantly. This then needs to be
   synchronized with the view of the session history that all other <a href="#navigable" id="navigation-and-session-history:navigable-6">navigables</a> in the tree see, which can be subject to race conditions
   and necessitate resolving conflicting views of the session history.</p></li><li><p>The platform has accumulated various exciting navigation-related features that need
   special-casing, such as <code id="navigation-and-session-history:the-javascript:-url-special-case"><a href="#the-javascript:-url-special-case">javascript:</a></code> URLs, <code id="navigation-and-session-history:attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> <code id="navigation-and-session-history:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>s, and the <code id="navigation-and-session-history:event-beforeunload"><a href="#event-beforeunload">beforeunload</a></code> event.</p></li></ul>

  <p>In what follows, we have attempted to guide the reader through these complexities by
  appropriately cordoning them off into labeled sections and algorithms, and giving appropriate
  words of introduction where possible. Nevertheless, if you wish to truly understand navigation
  and session history, <a href="#how-to-read-this-specification">the usual advice</a> will be
  invaluable.</p>


  <h4 id="session-history-infrastructure"><span class="secno">7.4.1</span> <span id="the-session-history-of-browsing-contexts"></span>Session history<a href="#session-history-infrastructure" class="self-link"></a></h4>

  <h5 id="session-history-entries"><span class="secno">7.4.1.1</span> Session history entries<a href="#session-history-entries" class="self-link"></a></h5>

  <p>A <dfn id="session-history-entry">session history entry</dfn> is a <a id="session-history-entries:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="session-history-entries:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="she-step">step</dfn>, a non-negative integer or "<code>pending</code>", initially "<code>pending</code>".</p></li><li><p><dfn id="she-url">URL</dfn>, a <a id="session-history-entries:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a></p></li><li><p><dfn id="she-document-state">document state</dfn>, a <a href="#document-state-2" id="session-history-entries:document-state-2">document
   state</a>.</p></li><li><p id="she-serialized-state"><dfn id="she-classic-history-api-state">classic history API
   state</dfn>, which is <a href="#serialized-state" id="session-history-entries:serialized-state">serialized state</a>, initially
   <a href="#structuredserializeforstorage" id="session-history-entries:structuredserializeforstorage">StructuredSerializeForStorage</a>(null).</p></li><li><p><dfn id="she-navigation-api-state">navigation API state</dfn>, which is a
   <a href="#serialized-state" id="session-history-entries:serialized-state-2">serialized state</a>, initially
   <a href="#structuredserializeforstorage" id="session-history-entries:structuredserializeforstorage-2">StructuredSerializeForStorage</a>(undefined).</p></li><li><p><dfn id="she-navigation-api-key">navigation API key</dfn>, which is a string,
   initially set to the result of <a id="session-history-entries:generating-a-random-uuid" href="https://w3c.github.io/webcrypto/#dfn-generate-a-random-uuid" data-x-internal="generating-a-random-uuid">generating a random UUID</a>.</p></li><li><p><dfn id="she-navigation-api-id">navigation API ID</dfn>, which is a string, initially
   set to the result of <a id="session-history-entries:generating-a-random-uuid-2" href="https://w3c.github.io/webcrypto/#dfn-generate-a-random-uuid" data-x-internal="generating-a-random-uuid">generating a random UUID</a>.</p></li><li><p><dfn id="she-scroll-restoration-mode">scroll restoration mode</dfn>, a <a href="#scroll-restoration-mode" id="session-history-entries:scroll-restoration-mode">scroll
   restoration mode</a>, initially "<code id="session-history-entries:dom-scrollrestoration-auto"><a href="#dom-scrollrestoration-auto">auto</a></code>".</p></li><li><p><dfn id="she-scroll-position">scroll position data</dfn>, which is scroll position
   data for the <a href="#she-document" id="session-history-entries:she-document">document</a>'s <a href="#restorable-scrollable-regions" id="session-history-entries:restorable-scrollable-regions">restorable scrollable
   regions</a>.</p></li><li>
    <p id="an-entry-with-persisted-user-state"><dfn id="she-other">persisted user state</dfn>,
    which is <a id="session-history-entries:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>, initially null</p>

    <p class="example">For example, some user agents might want to persist the values of form
    controls.</p>

    <p class="note">User agents that persist the value of form controls are encouraged to also
    persist their directionality (the value of the element's <code id="session-history-entries:attr-dir"><a href="#attr-dir">dir</a></code>
    attribute). This prevents values from being displayed incorrectly after a history traversal
    when the user had originally entered the values with an explicit, non-default
    directionality.</p>
   </li></ul>

  <div data-algorithm="">
  <p>To get a <a href="#session-history-entry" id="session-history-entries:session-history-entry">session history entry</a>'s <dfn id="she-document">document</dfn>,
  return its <a href="#she-document-state" id="session-history-entries:she-document-state">document state</a>'s <a href="#document-state-document" id="session-history-entries:document-state-document">document</a>.</p>
  </div>

  <hr>

  <p id="state-object"><dfn id="serialized-state">Serialized state</dfn> is a serialization (via
  <a href="#structuredserializeforstorage" id="session-history-entries:structuredserializeforstorage-3">StructuredSerializeForStorage</a>) of an object representing a user interface state. We
  sometimes informally refer to "state objects", which are the objects representing user interface
  state supplied by the author, or alternately the objects created by deserializing (via
  <a href="#structureddeserialize" id="session-history-entries:structureddeserialize">StructuredDeserialize</a>) serialized state.</p>

  <p>Pages can <a href="#dom-history-pushstate" id="session-history-entries:dom-history-pushstate">add</a> <a href="#serialized-state" id="session-history-entries:serialized-state-3">serialized state</a> to the
  session history. These are then <a href="#structureddeserialize" id="session-history-entries:structureddeserialize-2">deserialized</a> and <a href="#event-popstate" id="session-history-entries:event-popstate">returned to the script</a> when the user (or script) goes back in the
  history, thus enabling authors to use the "navigation" metaphor even in one-page applications.</p>

  <div class="note">
   <p><a href="#serialized-state" id="session-history-entries:serialized-state-4">Serialized state</a> is intended to be used for two main purposes: first, storing a
   preparsed description of the state in the <a id="session-history-entries:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> so that in the simple case an author
   doesn't have to do the parsing (though one would still need the parsing for handling <a href="https://url.spec.whatwg.org/#concept-url" id="session-history-entries:url-3" data-x-internal="url">URLs</a> passed around by users, so it's only a minor optimization). Second, so
   that the author can store state that one wouldn't store in the URL because it only applies to the
   current <code id="session-history-entries:document"><a href="#document">Document</a></code> instance and it would have to be reconstructed if a new
   <code id="session-history-entries:document-2"><a href="#document">Document</a></code> were opened.</p>

   <p>An example of the latter would be something like keeping track of the precise coordinate from
   which a popup <code id="session-history-entries:the-div-element"><a href="#the-div-element">div</a></code> was made to animate, so that if the user goes back, it can be made
   to animate to the same location. Or alternatively, it could be used to keep a pointer into a
   cache of data that would be fetched from the server based on the information in the
   <a id="session-history-entries:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, so that when going back and forward, the information doesn't have to be fetched
   again.</p>
  </div>

  <hr>

  <p>A <dfn id="scroll-restoration-mode">scroll restoration mode</dfn> indicates whether the user agent should restore the
  persisted scroll position (if any) when traversing to an <a href="#session-history-entry" id="session-history-entries:session-history-entry-2">entry</a>. A scroll restoration mode is one of the following:</p>

  <dl><dt>"<dfn data-dfn-for="ScrollRestoration" id="dom-scrollrestoration-auto" data-dfn-type="enum-value"><code>auto</code></dfn>"</dt><dd>The user agent is responsible for restoring the scroll position upon navigation.</dd><dt>"<dfn data-dfn-for="ScrollRestoration" id="dom-scrollrestoration-manual" data-dfn-type="enum-value"><code>manual</code></dfn>"</dt><dd>The page is responsible for restoring the scroll position and the user agent does not
   attempt to do so automatically</dd></dl>


  <h5 id="document-state"><span class="secno">7.4.1.2</span> Document state<a href="#document-state" class="self-link"></a></h5>

  <p><dfn id="document-state-2">Document state</dfn> holds state inside a <a href="#session-history-entry" id="document-state:session-history-entry">session history entry</a> regarding
  how to present and, if necessary, recreate, a <code id="document-state:document"><a href="#document">Document</a></code>. It has:</p>

  <ul><li>
    <p>A <dfn id="document-state-document">document</dfn>, a <code id="document-state:document-2"><a href="#document">Document</a></code> or null,
    initially null.</p>

    <div id="note-bfcache" class="note"><a href="#note-bfcache" class="self-link"></a>
     <p>When a history entry is <a href="#nav-active-history-entry" id="document-state:nav-active-history-entry">active</a>, it has a
     <code id="document-state:document-3"><a href="#document">Document</a></code> in its <a href="#she-document-state" id="document-state:she-document-state">document state</a>. However,
     when a <code id="document-state:document-4"><a href="#document">Document</a></code> is not <a href="#fully-active" id="document-state:fully-active">fully active</a>, it's possible for it to be
     <a href="#destroy-a-document" id="document-state:destroy-a-document">destroyed</a> to free resources. In such cases, this
     <a href="#document-state-document" id="document-state:document-state-document">document</a> item will be nulled out. The <a href="#she-url" id="document-state:she-url">URL</a> and other data in the <a href="#session-history-entry" id="document-state:session-history-entry-2">session history entry</a> and <a href="#she-document-state" id="document-state:she-document-state-2">document state</a> is then used to bring a new
     <code id="document-state:document-5"><a href="#document">Document</a></code> into being to take the place of the original, in the case where the user
     agent finds itself having to traverse to the entry.</p>

     <p>If the <code id="document-state:document-6"><a href="#document">Document</a></code> is <em>not</em> <a href="#destroy-a-document" id="document-state:destroy-a-document-2">destroyed</a>, then during <a href="#traverse-the-history-by-a-delta" id="document-state:traverse-the-history-by-a-delta">history
     traversal</a>, it can be <a href="#reactivate-a-document" id="document-state:reactivate-a-document">reactivated</a>. The cache
     in which browsers store such <code id="document-state:document-7"><a href="#document">Document</a></code>s is often called a <em>back-forward
     cache</em>, or <em>bfcache</em> (or perhaps <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=274784">"blazingly fast"</a> cache).</p>
    </div>
   </li><li><p id="she-policy-container">A <dfn id="document-state-history-policy-container">history
   policy container</dfn>, a <a href="#policy-container" id="document-state:policy-container">policy container</a> or null, initially null.</p></li><li><p>A <dfn id="document-state-request-referrer">request referrer</dfn>, which is "<code>no-referrer</code>", "<code>client</code>", or a <a id="document-state:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, initially
   "<code>client</code>".</p></li><li>
    <p>A <dfn id="document-state-request-referrer-policy">request referrer policy</dfn>, which
    is a <a id="document-state:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>, initially the <a id="document-state:default-referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#default-referrer-policy" data-x-internal="default-referrer-policy">default referrer policy</a>.</p>

    <p class="note">The <a href="#document-state-request-referrer-policy" id="document-state:document-state-request-referrer-policy">request referrer
    policy</a> is distinct from the <a href="#document-state-history-policy-container" id="document-state:document-state-history-policy-container">history policy container</a>'s <a href="#policy-container-referrer-policy" id="document-state:policy-container-referrer-policy">referrer policy</a>. The former is used for
    fetches <em>of</em> this document, whereas the latter controls fetches <em>by</em> this
    document.</p>
   </li><li>
    <p>An <dfn id="document-state-initiator-origin">initiator origin</dfn>, which is an
    <a href="#concept-origin" id="document-state:concept-origin">origin</a> or null, initially null.</p>
   </li><li>
    <p>An <dfn id="document-state-origin">origin</dfn>, which is an <a href="#concept-origin" id="document-state:concept-origin-2">origin</a> or
    null, initially null.</p>

    <p class="note">This is the origin that we set "<code>about:</code>"-schemed
    <code id="document-state:document-8"><a href="#document">Document</a></code>s' <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="document-state:concept-document-origin" data-x-internal="concept-document-origin">origin</a> to. We store it
    here because it is also used when restoring these <code id="document-state:document-9"><a href="#document">Document</a></code>s during traversal,
    since they are reconstructed locally without visiting the network. It is also used to compare
    the origin before and after the <a href="#session-history-entry" id="document-state:session-history-entry-3">session history entry</a> is <a href="#attempt-to-populate-the-history-entry's-document" id="document-state:attempt-to-populate-the-history-entry's-document">repopulated</a>. If the origins change, the <a href="#document-state-nav-target-name" id="document-state:document-state-nav-target-name">navigable target name</a> is cleared.</p>
   </li><li>
    <p>An <dfn id="document-state-about-base-url">about base URL</dfn>, which is a
    <a id="document-state:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> or null, initially null.</p>

    <p class="note">This will be populated only for "<code>about:</code>"-schemed
    <code id="document-state:document-10"><a href="#document">Document</a></code>s and will be the <a href="#fallback-base-url" id="document-state:fallback-base-url">fallback base URL</a> for those
    <code id="document-state:document-11"><a href="#document">Document</a></code>s. It is a snapshot of the initiator <code id="document-state:document-12"><a href="#document">Document</a></code>'s <a href="#document-base-url" id="document-state:document-base-url">document
    base URL</a>.</p>
   </li><li><p><dfn id="document-state-nested-histories">Nested histories</dfn>, a <a id="document-state:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>
   of <a href="#nested-history" id="document-state:nested-history">nested histories</a>, initially an empty
   <a id="document-state:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p>A <dfn id="document-state-resource">resource</dfn>, a string, <a href="#post-resource" id="document-state:post-resource">POST resource</a>
    or null, initially null.</p>

    <p class="note">A string is treated as HTML. It's used to store the source of an <a href="#an-iframe-srcdoc-document" id="document-state:an-iframe-srcdoc-document"><code>iframe</code> <code>srcdoc</code> document</a>.</p>
   </li><li><p>A <dfn id="document-state-reload-pending">reload pending</dfn> boolean, initially
   false.</p></li><li><p>An <dfn id="document-state-ever-populated">ever populated</dfn> boolean, initially
   false.</p></li><li><p id="she-bc-name">A <dfn id="document-state-nav-target-name">navigable target
   name</dfn> string, initially the empty string.</p></li><li><p>A <dfn id="document-state-not-restored-reasons">not restored reasons</dfn>, a
   <a href="#nrr-struct" id="document-state:nrr-struct">not restored reasons</a> or null, initially null.</p></li></ul>

  <p>User agents may <a href="#destroy-a-document-and-its-descendants" id="document-state:destroy-a-document-and-its-descendants">destroy a document and its descendants</a> given the <a href="#document-state-document" id="document-state:document-state-document-2">documents</a> of <a href="#document-state-2" id="document-state:document-state-2">document
  states</a> with non-null <a href="#document-state-document" id="document-state:document-state-document-3">documents</a>, as long as
  the <code id="document-state:document-13"><a href="#document">Document</a></code> is not <a href="#fully-active" id="document-state:fully-active-2">fully active</a>.</p>

  <p>Apart from that restriction, this standard does not specify when user agents should destroy
  the <a href="#document-state-document" id="document-state:document-state-document-4">document</a> stored in a <a href="#document-state-2" id="document-state:document-state-2-2">document
  state</a>, versus keeping it cached.</p>

  <hr>

  <p>A <dfn id="post-resource" data-export="">POST resource</dfn> has:</p>

  <ul><li>
    <p>A <dfn data-dfn-for="POST resource" id="post-resource-request-body" data-export="">request body</dfn>, a
    <a id="document-state:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> or failure.</p>

    <p>This is only ever accessed <a href="#in-parallel" id="document-state:in-parallel">in parallel</a>, so it doesn't need to be stored in
    memory. However, it must return the same <a id="document-state:byte-sequence-2" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> each time. If this isn't
    possible due to resources changing on disk, or if resources can no longer be accessed, then
    this must be set to failure.</p>
   </li><li><p>A <dfn data-dfn-for="POST resource" id="post-resource-request-content-type" data-export="">request
   content-type</dfn>, which is `<code id="document-state:application/x-www-form-urlencoded"><a data-x-internal="application/x-www-form-urlencoded" href="https://url.spec.whatwg.org/#concept-urlencoded">application/x-www-form-urlencoded</a></code>`,
   `<code id="document-state:multipart/form-data"><a href="#multipart/form-data">multipart/form-data</a></code>`, or `<code id="document-state:text/plain"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>`.</p></li></ul>

  <hr>

  <p>A <dfn id="nested-history">nested history</dfn> has:</p>

  <ul><li>
    <p>An <dfn id="nested-history-id">id</dfn>, a <a href="#unique-internal-value" id="document-state:unique-internal-value">unique internal value</a>.</p>

    <p class="note">This is used to associate the <a href="#nested-history" id="document-state:nested-history-2">nested history</a> with a
    <a href="#navigable" id="document-state:navigable">navigable</a>.</p>
   </li><li><p><dfn id="nested-history-entries">Entries</dfn>, a <a id="document-state:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#session-history-entry" id="document-state:session-history-entry-4">session history entries</a>.</p></li></ul>

  <p class="XXX">This will later contain ways to identify a child navigable across reloads.</p>

  <hr>

  <hr>

  <p>Several contiguous entries in a session history can share the same <a href="#she-document-state" id="document-state:she-document-state-3">document state</a>. This can occur when the initial entry is
  reached via normal <a href="#navigate" id="document-state:navigate">navigation</a>, and the following entry is added
  via <code id="document-state:dom-history-pushstate"><a href="#dom-history-pushstate">history.pushState()</a></code>. Or it can occur via <a href="#navigate-fragid" id="document-state:navigate-fragid">navigation to a fragment</a>.</p>

  <p class="note">All entries that share the same <a href="#she-document-state" id="document-state:she-document-state-4">document
  state</a> (and that are therefore merely different states of one particular document) are
  contiguous by construction.</p>

  <hr>

  <p>A <code id="document-state:document-14"><a href="#document">Document</a></code> has a <dfn id="latest-entry">latest entry</dfn>, a <a href="#session-history-entry" id="document-state:session-history-entry-5">session history entry</a> or
  null.</p>

  <p class="note">This is the entry that was most recently represented by a given
  <code id="document-state:document-15"><a href="#document">Document</a></code>. A single <code id="document-state:document-16"><a href="#document">Document</a></code> can represent many <a href="#session-history-entry" id="document-state:session-history-entry-6">session history entries</a> over time, as many contiguous <a href="#session-history-entry" id="document-state:session-history-entry-7">session history entries</a> can share the same <a href="#she-document-state" id="document-state:she-document-state-5">document state</a> as explained above.</p>


  <h5 id="centralized-modifications-of-session-history"><span class="secno">7.4.1.3</span> Centralized modifications of session history<a href="#centralized-modifications-of-session-history" class="self-link"></a></h5>

  <p>To maintain a single source of truth, all modifications to a <a href="#traversable-navigable" id="centralized-modifications-of-session-history:traversable-navigable">traversable
  navigable</a>'s <a href="#tn-session-history-entries" id="centralized-modifications-of-session-history:tn-session-history-entries">session history entries</a> need
  to be synchronized. This is especially important due to how session history is influenced by all
  of the descendant <a href="#navigable" id="centralized-modifications-of-session-history:navigable">navigables</a>, and thus by multiple <a href="#event-loop" id="centralized-modifications-of-session-history:event-loop">event loops</a>. To accomplish this, we use the <a href="#session-history-traversal-parallel-queue" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue">session history
  traversal parallel queue</a> structure.</p>

  <p id="session-history-traversal-queue">A <dfn id="session-history-traversal-parallel-queue">session history traversal parallel queue</dfn> is
  very similar to a <a href="#parallel-queue" id="centralized-modifications-of-session-history:parallel-queue">parallel queue</a>. It has an <dfn id="session-history-traversal-parallel-queue-algorithm-set">algorithm set</dfn>, an <a href="https://infra.spec.whatwg.org/#ordered-set" id="centralized-modifications-of-session-history:set" data-x-internal="set">ordered set</a>.</p>

  <p>The <a href="https://infra.spec.whatwg.org/#list-item" id="centralized-modifications-of-session-history:list-item" data-x-internal="list-item">items</a> in a <a href="#session-history-traversal-parallel-queue" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-2">session history traversal parallel
  queue</a>'s <a href="#session-history-traversal-parallel-queue-algorithm-set" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-algorithm-set">algorithm
  set</a> are either algorithm steps, or <dfn id="session-history-traversal-parallel-queue-sync-nav-steps">synchronous navigation
  steps</dfn>, which are a particular brand of algorithm steps involving a <dfn id="session-history-traversal-parallel-queue-sync-nav-steps-target-nav">target
  navigable</dfn> (a <a href="#navigable" id="centralized-modifications-of-session-history:navigable-2">navigable</a>).</p>

  <div data-algorithm="">
  <p>To <dfn id="tn-append-session-history-traversal-steps">append session history traversal
  steps</dfn> to a <a href="#traversable-navigable" id="centralized-modifications-of-session-history:traversable-navigable-2">traversable navigable</a> <var>traversable</var> given algorithm steps
  <var>steps</var>, <a href="https://infra.spec.whatwg.org/#list-append" id="centralized-modifications-of-session-history:list-append" data-x-internal="list-append">append</a> <var>steps</var> to
  <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="centralized-modifications-of-session-history:tn-session-history-traversal-queue">session history
  traversal queue</a>'s <a href="#session-history-traversal-parallel-queue-algorithm-set" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-algorithm-set-2">algorithm set</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="tn-append-session-history-sync-nav-steps">append session history synchronous
  navigation steps</dfn> involving a <a href="#navigable" id="centralized-modifications-of-session-history:navigable-3">navigable</a> <var>targetNavigable</var> to a
  <a href="#traversable-navigable" id="centralized-modifications-of-session-history:traversable-navigable-3">traversable navigable</a> <var>traversable</var> given algorithm steps <var>steps</var>,
  <a href="https://infra.spec.whatwg.org/#list-append" id="centralized-modifications-of-session-history:list-append-2" data-x-internal="list-append">append</a> <var>steps</var> as <a href="#session-history-traversal-parallel-queue-sync-nav-steps" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-sync-nav-steps">synchronous navigation
  steps</a> targeting <a href="#session-history-traversal-parallel-queue-sync-nav-steps-target-nav" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-sync-nav-steps-target-nav">target
  navigable</a> <var>targetNavigable</var> to <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="centralized-modifications-of-session-history:tn-session-history-traversal-queue-2">session history traversal queue</a>'s <a href="#session-history-traversal-parallel-queue-algorithm-set" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-algorithm-set-3">algorithm set</a>.</p>
  </div>

  <div data-algorithm="">
  <p id="session-history-event-loop">To <dfn id="starting-a-new-session-history-traversal-parallel-queue">start a new session history traversal parallel queue</dfn>:</p>

  <ol><li><p>Let <var>sessionHistoryTraversalQueue</var> be a new <a href="#session-history-traversal-parallel-queue" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-3">session history traversal
   parallel queue</a>.</p></li><li>
    <p>Run the following steps <a href="#in-parallel" id="centralized-modifications-of-session-history:in-parallel">in parallel</a>:</p>

    <ol><li>
      <p>While true:</p>

      <ol><li><p>If <var>sessionHistoryTraversalQueue</var>'s <a href="#session-history-traversal-parallel-queue-algorithm-set" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-algorithm-set-4">algorithm set</a> is
       empty, then <a id="centralized-modifications-of-session-history:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>steps</var> be the result of <a href="https://infra.spec.whatwg.org/#queue-dequeue" id="centralized-modifications-of-session-history:dequeue" data-x-internal="dequeue">dequeuing</a> from
       <var>sessionHistoryTraversalQueue</var>'s <a href="#session-history-traversal-parallel-queue-algorithm-set" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-algorithm-set-5">algorithm
       set</a>.</p></li><li><p>Run <var>steps</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Return <var>sessionHistoryTraversalQueue</var>.</p></li></ol>
  </div>

  <p id="sync-navigation-steps-queue-jumping-examples"><a href="#session-history-traversal-parallel-queue-sync-nav-steps" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-sync-nav-steps-2">Synchronous navigation
  steps</a> are tagged in the <a href="#session-history-traversal-parallel-queue-algorithm-set" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-algorithm-set-6">algorithm set</a> to allow
  them to conditionally "jump the queue". This is handled <a href="#sync-navigations-jump-queue">within apply the history step</a>.</p>

  <div id="example-sync-navigation-steps-queue-jumping-basic" class="example"><a href="#example-sync-navigation-steps-queue-jumping-basic" class="self-link"></a>
   <p>Imagine the joint session history depicted by this <a href="#jake-diagram" id="centralized-modifications-of-session-history:jake-diagram">Jake diagram</a>:</p>

   
   <table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step current">1</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="1" class="doc-0">/a</td><td colspan="1" class="doc-1 current">/b</td></tr></tbody></table>

   <p>And the following code runs at the top level:</p>

   <pre><code class="js">history<c- p="">.</c->back<c- p="">();</c->
location<c- p="">.</c->href <c- o="">=</c-> <c- t="">'#foo'</c-><c- p="">;</c-></code></pre>

   <p>The desired result is:</p>

   
   <table class="jake-diagram"><thead><tr><td></td><th class="step current">0</th><th class="step">1</th><th class="step">2</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="1" class="doc-0 current">/a</td><td colspan="1" class="doc-1 next-is-same-doc">/b</td><td colspan="1" class="doc-1 prev-is-same-doc">/b#foo</td></tr></tbody></table>

   <p>This isn't straightforward, as the sync navigation wins the race in terms of being
   observable, whereas the traversal wins the race in terms of queuing steps on the <a href="#session-history-traversal-parallel-queue" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-4">session
   history traversal parallel queue</a>. To achieve this result, the following happens:</p>

   <ol><li><p><code id="centralized-modifications-of-session-history:dom-history-back"><a href="#dom-history-back">history.back()</a></code> <a href="#tn-append-session-history-traversal-steps" id="centralized-modifications-of-session-history:tn-append-session-history-traversal-steps">appends steps</a> intended to traverse by
    a delta of −1.</p></li><li><p><code id="centralized-modifications-of-session-history:dom-location-href"><a href="#dom-location-href">location.href = '#foo'</a></code> synchronously changes the
    <a href="#nav-active-history-entry" id="centralized-modifications-of-session-history:nav-active-history-entry">active session history entry</a> entry to a
    newly-created one, with the URL <code>/b#foo</code>, and <a href="#tn-append-session-history-sync-nav-steps" id="centralized-modifications-of-session-history:tn-append-session-history-sync-nav-steps">appends synchronous steps</a> to notify
    the central source of truth about that new entry. Note that this does <em>not</em> yet update
    the <a href="#nav-current-history-entry" id="centralized-modifications-of-session-history:nav-current-history-entry">current session history entry</a>, <a href="#tn-current-session-history-step" id="centralized-modifications-of-session-history:tn-current-session-history-step">current session history step</a>, or the <a href="#tn-session-history-entries" id="centralized-modifications-of-session-history:tn-session-history-entries-2">session history entries</a> list; those updates cannot
    be done synchronously, and instead must be done as part of the queued steps.</p></li><li>
     <p>On the <a href="#session-history-traversal-parallel-queue" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-5">session history traversal parallel queue</a>, the steps queued by <code id="centralized-modifications-of-session-history:dom-history-back-2"><a href="#dom-history-back">history.back()</a></code> run:</p>

     <ol><li><p>The target history step is determined to be 0: the <a href="#tn-current-session-history-step" id="centralized-modifications-of-session-history:tn-current-session-history-step-2">current session history step</a> (i.e., 1) plus
      the intended delta of −1.</p></li><li>
       <p>We enter the main <a href="#apply-the-history-step" id="centralized-modifications-of-session-history:apply-the-history-step">apply the history step</a> algorithm.</p>

       <p>The entry at step 0, for the <code>/a</code> URL, has its <a href="#she-document" id="centralized-modifications-of-session-history:she-document">document</a> <a href="#attempt-to-populate-the-history-entry's-document" id="centralized-modifications-of-session-history:attempt-to-populate-the-history-entry's-document">populated</a>.</p>

       <p>Meanwhile, the queue is checked for <a href="#session-history-traversal-parallel-queue-sync-nav-steps" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-sync-nav-steps-3">synchronous navigation
       steps</a>. The steps queued by the <code id="centralized-modifications-of-session-history:dom-location-href-2"><a href="#dom-location-href">location.href</a></code>
       setter now run, and block the traversal from performing effects beyond document population
       (such as, unloading documents and switching active history entries) until they are finished.
       Those steps cause the following to happen:</p>

       <ol><li><p>The entry with URL <code>/b#foo</code> is added, with its <a href="#she-step" id="centralized-modifications-of-session-history:she-step">step</a> determined to be 2: the <a href="#tn-current-session-history-step" id="centralized-modifications-of-session-history:tn-current-session-history-step-3">current session history step</a> (i.e., 1) plus
        1.</p></li><li><p>We fully switch to that newly added entry, including a nested call to <a href="#apply-the-history-step" id="centralized-modifications-of-session-history:apply-the-history-step-2">apply
        the history step</a>. This ultimately results in <a href="#update-document-for-history-step-application" id="centralized-modifications-of-session-history:update-document-for-history-step-application">updating the document</a> by dispatching events like <code id="centralized-modifications-of-session-history:event-hashchange"><a href="#event-hashchange">hashchange</a></code>.</p></li></ol>

       <p>Only once that is all complete, and the <code>/a</code> history entry has been
       fully populated with a <a href="#she-document" id="centralized-modifications-of-session-history:she-document-2">document</a>, do we move on with
       applying the history step given the target step of 0.</p>

       <p>At this point, the <code id="centralized-modifications-of-session-history:document"><a href="#document">Document</a></code> with URL <code>/b#foo</code> <a href="#unload-a-document" id="centralized-modifications-of-session-history:unload-a-document">unloads</a>, and we finish moving to our target history step
       0, which makes the entry with URL <code>/a</code> become the <a href="#nav-active-history-entry" id="centralized-modifications-of-session-history:nav-active-history-entry-2">active session history entry</a> and 0 become the <a href="#tn-current-session-history-step" id="centralized-modifications-of-session-history:tn-current-session-history-step-4">current session history step</a>.</p>
      </li></ol>
    </li></ol>
  </div>

  <div id="example-sync-navigation-steps-queue-jumping-complex" class="example"><a href="#example-sync-navigation-steps-queue-jumping-complex" class="self-link"></a>
   <p>Here is another more complex example, involving races between populating two different
   <code id="centralized-modifications-of-session-history:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s, and a synchronous navigation once one of those iframes loads. We start
   with this setup:</p>

   
   <table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step">1</th><th class="step current">2</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="3" class="doc-0 current">/t</td></tr><tr><th><code>frames[0]</code></th><td colspan="1" class="doc-1">/i-0-a</td><td colspan="2" class="doc-2 current">/i-0-b</td></tr><tr><th><code>frames[1]</code></th><td colspan="2" class="doc-3">/i-1-a</td><td colspan="1" class="doc-4 current">/i-1-b</td></tr></tbody></table>

   <p>and then call <code id="centralized-modifications-of-session-history:dom-history-go"><a href="#dom-history-go">history.go(-2)</a></code>. The following then
   occurs:</p>

   <ol><li>
     <p><code id="centralized-modifications-of-session-history:dom-history-go-2"><a href="#dom-history-go">history.go(-2)</a></code> <a href="#tn-append-session-history-traversal-steps" id="centralized-modifications-of-session-history:tn-append-session-history-traversal-steps-2">appends steps</a> intended to traverse
     by a delta of −2. Once those steps run:</p>

     <ol><li><p>The target step is determined to be 2 + (−2) = 0.</p></li><li>
       <p>In parallel, the fetches are made to <a href="#attempt-to-populate-the-history-entry's-document" id="centralized-modifications-of-session-history:attempt-to-populate-the-history-entry's-document-2">populate</a> the two iframes, fetching <code>/i-0-a</code>
       and <code>/i-1-a</code> respectively.</p>

       <p>Meanwhile, the queue is checked for <a href="#session-history-traversal-parallel-queue-sync-nav-steps" id="centralized-modifications-of-session-history:session-history-traversal-parallel-queue-sync-nav-steps-4">synchronous navigation
       steps</a>. There aren't any right now.</p>
      </li><li><p>In the fetch race, the fetch for <code>/i-0-a</code> wins. We proceed onward
      to finish all of <a href="#apply-the-history-step" id="centralized-modifications-of-session-history:apply-the-history-step-3">apply the history step</a>'s work for how the traversal impacts the
      <code>frames[0]</code> <a href="#navigable" id="centralized-modifications-of-session-history:navigable-4">navigable</a>, including updating its <a href="#nav-active-history-entry" id="centralized-modifications-of-session-history:nav-active-history-entry-3">active session history entry</a> to the entry with URL
      <code>/i-0-a</code>.</p></li><li>
       <p>Before the fetch for <code>/i-1-a</code> finishes, we reach the point where
       <a href="#scripts-may-run-for-the-newly-created-document" id="centralized-modifications-of-session-history:scripts-may-run-for-the-newly-created-document">scripts may run for the newly-created document</a> in the <code>frames[0]</code> <a href="#navigable" id="centralized-modifications-of-session-history:navigable-5">navigable</a>'s <a href="#nav-document" id="centralized-modifications-of-session-history:nav-document">active
       document</a>. Some such script does run:</p>

       <pre><code class="js">location<c- p="">.</c->href <c- o="">=</c-> <c- t="">'#foo'</c-></code></pre>

       <p>This synchronously changes the <code>frames[0]</code> navigable's <a href="#nav-active-history-entry" id="centralized-modifications-of-session-history:nav-active-history-entry-4">active session history entry</a> entry to a
       newly-created one, with the URL <code>/i-0-a#foo</code>, and <a href="#tn-append-session-history-sync-nav-steps" id="centralized-modifications-of-session-history:tn-append-session-history-sync-nav-steps-2">appends synchronous steps</a> to notify
       the central source of truth about that new entry.</p>

       <p>Unlike in the <a href="#example-sync-navigation-steps-queue-jumping-basic">previous
       example</a>, these synchronous steps do <em>not</em> "jump the queue" and update the <a href="#traversable-navigable" id="centralized-modifications-of-session-history:traversable-navigable-4">traversable</a> before we finish the fetch for <code>/i-1-a</code>. This is because the navigable in question, <code>frames[0]</code>, has already been altered as part of the traversal, so we know
       that with the <a href="#tn-current-session-history-step" id="centralized-modifications-of-session-history:tn-current-session-history-step-5">current session history
       step</a> being 2, adding the new entry as a step 3 doesn't make sense.</p>
      </li><li><p>Once the fetch for <code>/i-1-a</code> finally finishes, we proceed to finish
      updating the <code>frames[1]</code> <a href="#navigable" id="centralized-modifications-of-session-history:navigable-6">navigable</a> for the traversal,
      including updating its <a href="#nav-active-history-entry" id="centralized-modifications-of-session-history:nav-active-history-entry-5">active session history
      entry</a> to the entry with URL <code>/i-1-a</code>.</p></li><li><p>Now that both navigables have finished processing the traversal, we update the <a href="#tn-current-session-history-step" id="centralized-modifications-of-session-history:tn-current-session-history-step-6">current session history step</a> to the target
      step of 0.</p></li></ol>
    </li><li>
     <p>Now we can process the steps that were queued for the synchronous navigation:</p>

     <ol><li><p>The <code>/i-0-a#foo</code> entry is added, with its <a href="#she-step" id="centralized-modifications-of-session-history:she-step-2">step</a> determined to be 1: the <a href="#tn-current-session-history-step" id="centralized-modifications-of-session-history:tn-current-session-history-step-7">current session history step</a> (i.e., 0) plus
      1. This also <a href="#clear-the-forward-session-history" id="centralized-modifications-of-session-history:clear-the-forward-session-history">clears existing forward
      history</a>.</p></li><li><p>We fully switch to that newly added entry, including calling <a href="#apply-the-history-step" id="centralized-modifications-of-session-history:apply-the-history-step-4">apply the history
      step</a>. This ultimately results in <a href="#update-document-for-history-step-application" id="centralized-modifications-of-session-history:update-document-for-history-step-application-2">updating the document</a> by dispatching events like <code id="centralized-modifications-of-session-history:event-hashchange-2"><a href="#event-hashchange">hashchange</a></code>, as well as updating the <a href="#tn-current-session-history-step" id="centralized-modifications-of-session-history:tn-current-session-history-step-8">current session history step</a> to the target
      step of 1.</p></li></ol>
    </li></ol>

   <p>The end result is:</p>

   
   <table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step current">1</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="2" class="doc-0 current">/t</td></tr><tr><th><code>frames[0]</code></th><td colspan="1" class="doc-1 next-is-same-doc">/i-0-a</td><td colspan="1" class="doc-1 current prev-is-same-doc">/i-0-a#foo</td></tr><tr><th><code>frames[1]</code></th><td colspan="2" class="doc-3 current">/i-1-a</td></tr></tbody></table>
  </div>


  <h5 id="low-level-operations-on-session-history"><span class="secno">7.4.1.4</span> Low-level operations on session history<a href="#low-level-operations-on-session-history" class="self-link"></a></h5>

  <p>This section contains a miscellaneous grab-bag of operations that we perform throughout the
  standard when manipulating session history. The best way to get a sense of what they do is to
  look at their call sites.</p>

  <div data-algorithm="">
  <p>To <dfn id="getting-session-history-entries">get session history entries</dfn> of a
  <a href="#navigable" id="low-level-operations-on-session-history:navigable">navigable</a> <var>navigable</var>:</p>

  <ol><li><p>Let <var>traversable</var> be <var>navigable</var>'s <a href="#nav-traversable" id="low-level-operations-on-session-history:nav-traversable">traversable navigable</a>.</p></li><li><p><a id="low-level-operations-on-session-history:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running within <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="low-level-operations-on-session-history:tn-session-history-traversal-queue">session history traversal queue</a>.</p></li><li><p>If <var>navigable</var> is <var>traversable</var>, return <var>traversable</var>'s <a href="#tn-session-history-entries" id="low-level-operations-on-session-history:tn-session-history-entries">session history entries</a>.</p></li><li><p>Let <var>docStates</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-set" id="low-level-operations-on-session-history:set" data-x-internal="set">ordered set</a> of <a href="#document-state-2" id="low-level-operations-on-session-history:document-state-2">document states</a>.</p></li><li><p>For each <var>entry</var> of <var>traversable</var>'s <a href="#tn-session-history-entries" id="low-level-operations-on-session-history:tn-session-history-entries-2">session history entries</a>, <a href="https://infra.spec.whatwg.org/#set-append" id="low-level-operations-on-session-history:set-append" data-x-internal="set-append">append</a> <var>entry</var>'s <a href="#she-document-state" id="low-level-operations-on-session-history:she-document-state">document state</a>
   to <var>docStates</var>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="low-level-operations-on-session-history:list-iterate" data-x-internal="list-iterate">For each</a> <var>docState</var> of <var>docStates</var>:</p>

    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="low-level-operations-on-session-history:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>nestedHistory</var> of
      <var>docState</var>'s <a href="#document-state-nested-histories" id="low-level-operations-on-session-history:document-state-nested-histories">nested
      histories</a>:</p>

      <ol><li><p>If <var>nestedHistory</var>'s <a href="#nested-history-id" id="low-level-operations-on-session-history:nested-history-id">id</a> equals
       <var>navigable</var>'s <a href="#nav-id" id="low-level-operations-on-session-history:nav-id">id</a>, return <var>nestedHistory</var>'s
       <a href="#nested-history-entries" id="low-level-operations-on-session-history:nested-history-entries">entries</a>.</p></li><li><p>For each <var>entry</var> of <var>nestedHistory</var>'s <a href="#nested-history-entries" id="low-level-operations-on-session-history:nested-history-entries-2">entries</a>, <a href="https://infra.spec.whatwg.org/#set-append" id="low-level-operations-on-session-history:set-append-2" data-x-internal="set-append">append</a>
       <var>entry</var>'s <a href="#she-document-state" id="low-level-operations-on-session-history:she-document-state-2">document state</a> to
       <var>docStates</var>.</p></li></ol>
     </li></ol>
   </li><li><p><a id="low-level-operations-on-session-history:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this step is not reached.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="getting-session-history-entries-for-the-navigation-api">get session history
  entries for the navigation API</dfn> of a <a href="#navigable" id="low-level-operations-on-session-history:navigable-2">navigable</a> <var>navigable</var> given an
  integer <var>targetStep</var>:</p>

  <ol><li><p>Let <var>rawEntries</var> be the result of <a href="#getting-session-history-entries" id="low-level-operations-on-session-history:getting-session-history-entries">getting session history entries</a>
   for <var>navigable</var>.</p></li><li><p>Let <var>entriesForNavigationAPI</var> be a new empty <a id="low-level-operations-on-session-history:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p>Let <var>startingIndex</var> be the index of the <a href="#session-history-entry" id="low-level-operations-on-session-history:session-history-entry">session history entry</a> in
    <var>rawEntries</var> who has the greatest <a href="#she-step" id="low-level-operations-on-session-history:she-step">step</a> less than or
    equal to <var>targetStep</var>.</p>

    <p class="note">See <a href="#example-getting-the-target-history-entry">this example</a> to
    understand why it's the greatest step less than or equal to <var>targetStep</var>.</p>
   </li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="low-level-operations-on-session-history:list-append" data-x-internal="list-append">Append</a> <var>rawEntries</var>[<var>startingIndex</var>]
   to <var>entriesForNavigationAPI</var>.</p></li><li><p>Let <var>startingOrigin</var> be <var>rawEntries</var>[<var>startingIndex</var>]'s <a href="#she-document-state" id="low-level-operations-on-session-history:she-document-state-3">document state</a>'s <a href="#document-state-origin" id="low-level-operations-on-session-history:document-state-origin">origin</a>.</p></li><li><p>Let <var>i</var> be <var>startingIndex</var> − 1.</p></li><li>
    <p>While <var>i</var> &gt; 0:</p>

    <ol><li><p>If <var>rawEntries</var>[<var>i</var>]'s <a href="#she-document-state" id="low-level-operations-on-session-history:she-document-state-4">document
     state</a>'s <a href="#document-state-origin" id="low-level-operations-on-session-history:document-state-origin-2">origin</a> is not <a href="#same-origin" id="low-level-operations-on-session-history:same-origin">same
     origin</a> with <var>startingOrigin</var>, then <a id="low-level-operations-on-session-history:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-prepend" id="low-level-operations-on-session-history:list-prepend" data-x-internal="list-prepend">Prepend</a> <var>rawEntries</var>[<var>i</var>] to
     <var>entriesForNavigationAPI</var>.</p></li><li><p>Set <var>i</var> to <var>i</var> − 1.</p></li></ol>
   </li><li><p>Set <var>i</var> to <var>startingIndex</var> + 1.</p></li><li>
    <p>While <var>i</var> &lt; <var>rawEntries</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="low-level-operations-on-session-history:list-size" data-x-internal="list-size">size</a>:</p>

    <ol><li><p>If <var>rawEntries</var>[<var>i</var>]'s <a href="#she-document-state" id="low-level-operations-on-session-history:she-document-state-5">document
     state</a>'s <a href="#document-state-origin" id="low-level-operations-on-session-history:document-state-origin-3">origin</a> is not <a href="#same-origin" id="low-level-operations-on-session-history:same-origin-2">same
     origin</a> with <var>startingOrigin</var>, then <a id="low-level-operations-on-session-history:break-2" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="low-level-operations-on-session-history:list-append-2" data-x-internal="list-append">Append</a> <var>rawEntries</var>[<var>i</var>] to
     <var>entriesForNavigationAPI</var>.</p></li><li><p>Set <var>i</var> to <var>i</var> + 1.</p></li></ol>
   </li><li><p>Return <var>entriesForNavigationAPI</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="clear-the-forward-session-history">clear the forward session history</dfn> of a <a href="#traversable-navigable" id="low-level-operations-on-session-history:traversable-navigable">traversable navigable</a>
  <var>navigable</var>:</p>

  <ol><li><p><a id="low-level-operations-on-session-history:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running within <var>navigable</var>'s <a href="#tn-session-history-traversal-queue" id="low-level-operations-on-session-history:tn-session-history-traversal-queue-2">session history traversal queue</a>.</p></li><li><p>Let <var>step</var> be the <var>navigable</var>'s <a href="#tn-current-session-history-step" id="low-level-operations-on-session-history:tn-current-session-history-step">current session history step</a>.</p></li><li><p>Let <var>entryLists</var> be the <a href="https://infra.spec.whatwg.org/#ordered-set" id="low-level-operations-on-session-history:set-2" data-x-internal="set">ordered set</a> «
   <var>navigable</var>'s <a href="#tn-session-history-entries" id="low-level-operations-on-session-history:tn-session-history-entries-3">session history entries</a>
   ».</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="low-level-operations-on-session-history:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>entryList</var> of
    <var>entryLists</var>:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="low-level-operations-on-session-history:list-remove" data-x-internal="list-remove">Remove</a> every <a href="#session-history-entry" id="low-level-operations-on-session-history:session-history-entry-2">session history entry</a> from
     <var>entryList</var> that has a <a href="#she-step" id="low-level-operations-on-session-history:she-step-2">step</a> greater than
     <var>step</var>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="low-level-operations-on-session-history:list-iterate-4" data-x-internal="list-iterate">For each</a> <var>entry</var> of <var>entryList</var>:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="low-level-operations-on-session-history:list-iterate-5" data-x-internal="list-iterate">For each</a> <var>nestedHistory</var> of
       <var>entry</var>'s <a href="#she-document-state" id="low-level-operations-on-session-history:she-document-state-6">document state</a>'s <a href="#document-state-nested-histories" id="low-level-operations-on-session-history:document-state-nested-histories-2">nested histories</a>, <a href="https://infra.spec.whatwg.org/#set-append" id="low-level-operations-on-session-history:set-append-3" data-x-internal="set-append">append</a> <var>nestedHistory</var>'s <a href="#nested-history-entries" id="low-level-operations-on-session-history:nested-history-entries-3">entries list</a> to <var>entryLists</var>.</p></li></ol>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="getting-all-used-history-steps">get all used history steps</dfn> that are part
  of <a href="#traversable-navigable" id="low-level-operations-on-session-history:traversable-navigable-2">traversable navigable</a> <var>traversable</var>:</p>

  <ol><li><p><a id="low-level-operations-on-session-history:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running within <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="low-level-operations-on-session-history:tn-session-history-traversal-queue-3">session history traversal queue</a>.</p></li><li><p>Let <var>steps</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-set" id="low-level-operations-on-session-history:set-3" data-x-internal="set">ordered set</a> of non-negative
   integers.</p></li><li><p>Let <var>entryLists</var> be the <a href="https://infra.spec.whatwg.org/#ordered-set" id="low-level-operations-on-session-history:set-4" data-x-internal="set">ordered set</a> «
   <var>traversable</var>'s <a href="#tn-session-history-entries" id="low-level-operations-on-session-history:tn-session-history-entries-4">session history
   entries</a> ».</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="low-level-operations-on-session-history:list-iterate-6" data-x-internal="list-iterate">For each</a> <var>entryList</var> of
    <var>entryLists</var>:</p>

    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="low-level-operations-on-session-history:list-iterate-7" data-x-internal="list-iterate">For each</a> <var>entry</var> of <var>entryList</var>:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="low-level-operations-on-session-history:set-append-4" data-x-internal="set-append">Append</a> <var>entry</var>'s <a href="#she-step" id="low-level-operations-on-session-history:she-step-3">step</a> to <var>steps</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="low-level-operations-on-session-history:list-iterate-8" data-x-internal="list-iterate">For each</a> <var>nestedHistory</var> of
       <var>entry</var>'s <a href="#she-document-state" id="low-level-operations-on-session-history:she-document-state-7">document state</a>'s <a href="#document-state-nested-histories" id="low-level-operations-on-session-history:document-state-nested-histories-3">nested histories</a>, <a href="https://infra.spec.whatwg.org/#set-append" id="low-level-operations-on-session-history:set-append-5" data-x-internal="set-append">append</a> <var>nestedHistory</var>'s <a href="#nested-history-entries" id="low-level-operations-on-session-history:nested-history-entries-4">entries list</a> to <var>entryLists</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Return <var>steps</var>, <a href="https://infra.spec.whatwg.org/#list-sort-in-ascending-order" id="low-level-operations-on-session-history:list-sort" data-x-internal="list-sort">sorted</a>.</p></li></ol>
  </div>


  <h4 id="navigating-across-documents"><span class="secno">7.4.2</span> <span id="browsing-the-web"></span>Navigation<a href="#navigating-across-documents" class="self-link"></a></h4>

  <p>Certain actions cause a <a href="#navigable" id="navigating-across-documents:navigable">navigable</a> to <i id="navigating-across-documents:navigate"><a href="#navigate">navigate</a></i> to
  a new resource.</p>

  <p class="example">For example, <a href="#following-hyperlinks-2" id="navigating-across-documents:following-hyperlinks-2">following a hyperlink</a>,
  <a href="#concept-form-submit" id="navigating-across-documents:concept-form-submit">form submission</a>, and the <code id="navigating-across-documents:dom-open"><a href="#dom-open">window.open()</a></code> and <code id="navigating-across-documents:dom-location-assign"><a href="#dom-location-assign">location.assign()</a></code> methods can all cause navigation.</p>

  <div id="note-meaning-of-navigate" class="note"><a href="#note-meaning-of-navigate" class="self-link"></a>
   <p>Although in this standard the word "navigation" refers specifically to the
   <a href="#navigate" id="navigating-across-documents:navigate-2">navigate</a> algorithm, this doesn't always line up with web developer or user
   perceptions. For example:</p>

   <ul><li><p>The <a href="#url-and-history-update-steps" id="navigating-across-documents:url-and-history-update-steps">URL and history update steps</a> are often used during so-called
    "single-page app navigations" or "same-document navigations", but they do not trigger the
    <a href="#navigate" id="navigating-across-documents:navigate-3">navigate</a> algorithm.</p></li><li><p><a href="#reload" id="navigating-across-documents:reload">Reloads</a> and <a href="#traverse-the-history-by-a-delta" id="navigating-across-documents:traverse-the-history-by-a-delta">traversals</a> are sometimes talked about as a type of navigation, since all three
    will often <a href="#attempt-to-populate-the-history-entry's-document" id="navigating-across-documents:attempt-to-populate-the-history-entry's-document">attempt to populate the history entry's document</a> and thus could perform
    navigational fetches. See, e.g., the APIs exposed <cite>Navigation Timing</cite>. But they have
    their own entry point algorithms, separate from the <a href="#navigate" id="navigating-across-documents:navigate-4">navigate</a> algorithm.
    <a href="#refsNAVIGATIONTIMING">[NAVIGATIONTIMING]</a></p></li><li><p>Although <a href="#navigate-fragid" id="navigating-across-documents:navigate-fragid">fragment navigations</a> are always done
    through the <a href="#navigate" id="navigating-across-documents:navigate-5">navigate</a> algorithm, a user might perceive them as more like jumping
    around a single page, than as a true navigation.</p></li></ul>
  </div>


  <h5 id="navigation-supporting-concepts"><span class="secno">7.4.2.1</span> Supporting concepts<a href="#navigation-supporting-concepts" class="self-link"></a></h5>

  <p>Before we can jump into the <a href="#navigate" id="navigation-supporting-concepts:navigate">navigation algorithm</a> itself, we
  need to establish several important structures that it uses.</p>

  <p>The <dfn id="source-snapshot-params">source snapshot params</dfn> <a id="navigation-supporting-concepts:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> is used to capture data from a
  <code id="navigation-supporting-concepts:document"><a href="#document">Document</a></code> initiating a navigation. It is snapshotted at the beginning of a navigation
  and used throughout the navigation's lifetime. It has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="navigation-supporting-concepts:struct-item" data-x-internal="struct-item">items</a>:</p>

  <dl><dt><dfn id="source-snapshot-params-activation">has transient activation</dfn></dt><dd>a boolean</dd><dt><dfn id="source-snapshot-params-sandbox">sandboxing flags</dfn></dt><dd>a <a href="#sandboxing-flag-set" id="navigation-supporting-concepts:sandboxing-flag-set">sandboxing flag set</a></dd><dt><dfn id="source-snapshot-params-download">allows downloading</dfn></dt><dd>a boolean</dd><dt><dfn id="source-snapshot-params-client">fetch client</dfn></dt><dd>an <a href="#environment-settings-object" id="navigation-supporting-concepts:environment-settings-object">environment settings object</a> or null, only to be used as a <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="navigation-supporting-concepts:concept-request-client" data-x-internal="concept-request-client">request client</a></dd><dt><dfn id="source-snapshot-params-policy-container">source policy container</dfn></dt><dd>a <a href="#policy-container" id="navigation-supporting-concepts:policy-container">policy container</a></dd></dl>

  <div data-algorithm="">
  <p>To <dfn id="snapshotting-source-snapshot-params">snapshot source snapshot params</dfn>
  given a <code id="navigation-supporting-concepts:document-2"><a href="#document">Document</a></code>-or-null <var>sourceDocument</var>:</p>

  <ol><li>
    <p>If <var>sourceDocument</var> is null, then return a new <a href="#source-snapshot-params" id="navigation-supporting-concepts:source-snapshot-params">source snapshot params</a>
    with</p>

    <dl class="props"><dt><a href="#source-snapshot-params-activation" id="navigation-supporting-concepts:source-snapshot-params-activation">has transient activation</a></dt><dd>true</dd><dt><a href="#source-snapshot-params-sandbox" id="navigation-supporting-concepts:source-snapshot-params-sandbox">sandboxing flags</a></dt><dd>an empty <a href="#sandboxing-flag-set" id="navigation-supporting-concepts:sandboxing-flag-set-2">sandboxing flag set</a></dd><dt><a href="#source-snapshot-params-download" id="navigation-supporting-concepts:source-snapshot-params-download">allows downloading</a></dt><dd>true</dd><dt><a href="#source-snapshot-params-client" id="navigation-supporting-concepts:source-snapshot-params-client">fetch client</a></dt><dd>null</dd><dt><a href="#source-snapshot-params-policy-container" id="navigation-supporting-concepts:source-snapshot-params-policy-container">source policy container</a></dt><dd>a new <a href="#policy-container" id="navigation-supporting-concepts:policy-container-2">policy container</a></dd></dl>

    <p class="note">This <a href="#assert-null-sourcedocument">only occurs</a> in the case of a
    browser UI-initiated navigation.</p>
   </li><li>
    <p>Return a new <a href="#source-snapshot-params" id="navigation-supporting-concepts:source-snapshot-params-2">source snapshot params</a> with

    </p><dl class="props"><dt><a href="#source-snapshot-params-activation" id="navigation-supporting-concepts:source-snapshot-params-activation-2">has transient activation</a></dt><dd>true if <var>sourceDocument</var>'s <a href="#concept-relevant-global" id="navigation-supporting-concepts:concept-relevant-global">relevant global object</a> has <a href="#transient-activation" id="navigation-supporting-concepts:transient-activation">transient
     activation</a>; otherwise false</dd><dt><a href="#source-snapshot-params-sandbox" id="navigation-supporting-concepts:source-snapshot-params-sandbox-2">sandboxing flags</a></dt><dd><var>sourceDocument</var>'s <a href="#active-sandboxing-flag-set" id="navigation-supporting-concepts:active-sandboxing-flag-set">active sandboxing flag set</a></dd><dt><a href="#source-snapshot-params-download" id="navigation-supporting-concepts:source-snapshot-params-download-2">allows downloading</a></dt><dd>false if <var>sourceDocument</var>'s <a href="#active-sandboxing-flag-set" id="navigation-supporting-concepts:active-sandboxing-flag-set-2">active sandboxing flag set</a> has the
     <a href="#sandboxed-downloads-browsing-context-flag" id="navigation-supporting-concepts:sandboxed-downloads-browsing-context-flag">sandboxed downloads browsing context flag</a> set; otherwise true</dd><dt><a href="#source-snapshot-params-client" id="navigation-supporting-concepts:source-snapshot-params-client-2">fetch client</a></dt><dd><var>sourceDocument</var>'s <a href="#relevant-settings-object" id="navigation-supporting-concepts:relevant-settings-object">relevant settings object</a></dd><dt><a href="#source-snapshot-params-policy-container" id="navigation-supporting-concepts:source-snapshot-params-policy-container-2">source policy container</a></dt><dd>a <a href="#clone-a-policy-container" id="navigation-supporting-concepts:clone-a-policy-container">clone</a> of <var>sourceDocument</var>'s <a href="#concept-document-policy-container" id="navigation-supporting-concepts:concept-document-policy-container">policy container</a></dd></dl>
   </li></ol>
  </div>

  <hr>

  <p>The <dfn id="target-snapshot-params">target snapshot params</dfn> <a id="navigation-supporting-concepts:struct-2" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> is used to capture data from a
  <a href="#navigable" id="navigation-supporting-concepts:navigable">navigable</a> being navigated. Like <a href="#source-snapshot-params" id="navigation-supporting-concepts:source-snapshot-params-3">source snapshot params</a>, it is
  snapshotted at the beginning of a navigation and used throughout the navigation's lifetime. It
  has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="navigation-supporting-concepts:struct-item-2" data-x-internal="struct-item">items</a>:</p>

  <dl><dt><dfn id="target-snapshot-params-sandbox">sandboxing flags</dfn></dt><dd>a <a href="#sandboxing-flag-set" id="navigation-supporting-concepts:sandboxing-flag-set-3">sandboxing flag set</a></dd></dl>

  <div data-algorithm="">
  <p>To <dfn id="snapshotting-target-snapshot-params">snapshot target snapshot params</dfn>
  given a <a href="#navigable" id="navigation-supporting-concepts:navigable-2">navigable</a> <var>targetNavigable</var>, return a new <a href="#target-snapshot-params" id="navigation-supporting-concepts:target-snapshot-params">target snapshot
  params</a> with <a href="#target-snapshot-params-sandbox" id="navigation-supporting-concepts:target-snapshot-params-sandbox">sandboxing flags</a> set to
  the result of <a href="#determining-the-creation-sandboxing-flags" id="navigation-supporting-concepts:determining-the-creation-sandboxing-flags">determining the creation sandboxing flags</a> given
  <var>targetNavigable</var>'s <a href="#nav-bc" id="navigation-supporting-concepts:nav-bc">active browsing context</a> and
  <var>targetNavigable</var>'s <a href="#nav-container" id="navigation-supporting-concepts:nav-container">container</a>.</p>
  </div>

  <hr>

  <p>Much of the navigation process is concerned with determining how to create a new
  <code id="navigation-supporting-concepts:document-3"><a href="#document">Document</a></code>, which ultimately happens in the <a href="#initialise-the-document-object" id="navigation-supporting-concepts:initialise-the-document-object">create and initialize a <code>Document</code> object</a>
  algorithm. The parameters to that algorithm are tracked via a <dfn id="navigation-params">navigation params</dfn>
  <a id="navigation-supporting-concepts:struct-3" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a>, which has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="navigation-supporting-concepts:struct-item-3" data-x-internal="struct-item">items</a>:</p>

  
  <dl><dt><dfn id="navigation-params-id">id</dfn></dt><dd>null or a <a href="#navigation-id" id="navigation-supporting-concepts:navigation-id">navigation ID</a></dd><dt><dfn id="navigation-params-navigable">navigable</dfn></dt><dd>the <a href="#navigable" id="navigation-supporting-concepts:navigable-3">navigable</a> to be navigated</dd><dt><dfn id="navigation-params-request">request</dfn></dt><dd>null or a <a href="https://fetch.spec.whatwg.org/#concept-request" id="navigation-supporting-concepts:concept-request" data-x-internal="concept-request">request</a> that started the navigation</dd><dt><dfn id="navigation-params-response">response</dfn></dt><dd>a <a href="https://fetch.spec.whatwg.org/#concept-response" id="navigation-supporting-concepts:concept-response" data-x-internal="concept-response">response</a> that ultimately was navigated to
   (potentially a <a id="navigation-supporting-concepts:network-error" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>)</dd><dt><dfn id="navigation-params-fetch-controller">fetch controller</dfn></dt><dd>null or a <a id="navigation-supporting-concepts:fetch-controller" href="https://fetch.spec.whatwg.org/#fetch-controller" data-x-internal="fetch-controller">fetch controller</a></dd><dt><dfn id="navigation-params-commit-early-hints">commit early hints</dfn></dt><dd>null or an algorithm accepting a <code id="navigation-supporting-concepts:document-4"><a href="#document">Document</a></code>, once it has been created</dd><dt><dfn id="navigation-params-coop-enforcement-result">COOP enforcement result</dfn></dt><dd>an <a href="#coop-enforcement-result" id="navigation-supporting-concepts:coop-enforcement-result">opener policy enforcement result</a>, used for
   reporting and potentially for causing a <a href="#browsing-context-group-switches-due-to-cross-origin-opener-policy">browsing context
   group switch</a></dd><dt><dfn id="navigation-params-reserved-environment">reserved environment</dfn></dt><dd>null or an <a href="#environment" id="navigation-supporting-concepts:environment">environment</a> reserved for the new <code id="navigation-supporting-concepts:document-5"><a href="#document">Document</a></code></dd><dt><dfn id="navigation-params-origin">origin</dfn></dt><dd>an <a href="#concept-origin" id="navigation-supporting-concepts:concept-origin">origin</a> to use for the new <code id="navigation-supporting-concepts:document-6"><a href="#document">Document</a></code></dd><dt><dfn id="navigation-params-policy-container">policy container</dfn></dt><dd>a <a href="#policy-container" id="navigation-supporting-concepts:policy-container-3">policy container</a> to use for the new <code id="navigation-supporting-concepts:document-7"><a href="#document">Document</a></code></dd><dt><dfn id="navigation-params-sandboxing">final sandboxing flag set</dfn></dt><dd>a <a href="#sandboxing-flag-set" id="navigation-supporting-concepts:sandboxing-flag-set-4">sandboxing flag set</a> to impose on the new <code id="navigation-supporting-concepts:document-8"><a href="#document">Document</a></code></dd><dt><dfn id="navigation-params-coop">opener policy</dfn></dt><dd>an <a href="#cross-origin-opener-policy" id="navigation-supporting-concepts:cross-origin-opener-policy">opener policy</a> to use for the new <code id="navigation-supporting-concepts:document-9"><a href="#document">Document</a></code></dd><dt><dfn id="navigation-params-nav-timing-type">navigation timing type</dfn></dt><dd>a <code id="navigation-supporting-concepts:navigationtimingtype"><a data-x-internal="navigationtimingtype" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype">NavigationTimingType</a></code> used for <a href="https://w3c.github.io/navigation-timing/#dfn-create-the-navigation-timing-entry" id="navigation-supporting-concepts:create-the-navigation-timing-entry" data-x-internal="create-the-navigation-timing-entry">creating the navigation timing entry</a> for the new <code id="navigation-supporting-concepts:document-10"><a href="#document">Document</a></code></dd><dt><dfn id="navigation-params-about-base-url">about base URL</dfn></dt><dd>a <a id="navigation-supporting-concepts:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> or null used to populate the new <code id="navigation-supporting-concepts:document-11"><a href="#document">Document</a></code>'s <a href="#concept-document-about-base-url" id="navigation-supporting-concepts:concept-document-about-base-url">about base URL</a></dd><dt><dfn id="navigation-params-user-involvement">user involvement</dfn></dt><dd>a <a href="#user-navigation-involvement" id="navigation-supporting-concepts:user-navigation-involvement">user navigation involvement</a> used when <a href="#obtain-browsing-context-navigation" id="navigation-supporting-concepts:obtain-browsing-context-navigation">obtaining a browsing context</a> for the new
   <code id="navigation-supporting-concepts:document-12"><a href="#document">Document</a></code></dd></dl>

  <p class="note">Once a <a href="#navigation-params" id="navigation-supporting-concepts:navigation-params">navigation params</a> struct is created, this standard does not
  mutate any of its <a href="https://infra.spec.whatwg.org/#struct-item" id="navigation-supporting-concepts:struct-item-4" data-x-internal="struct-item">items</a>. They are only passed onward to other
  algorithms.</p>

  <hr>

  <p>A <dfn id="navigation-id">navigation ID</dfn> is a UUID string generated during navigation. It is used to
  interface with the <cite>WebDriver BiDi</cite> specification as well as to track the <a href="#ongoing-navigation" id="navigation-supporting-concepts:ongoing-navigation">ongoing
  navigation</a>. <a href="#refsWEBDRIVERBIDI">[WEBDRIVERBIDI]</a></p>

  <hr>

  <p>After <code id="navigation-supporting-concepts:document-13"><a href="#document">Document</a></code> creation, the relevant <a href="#traversable-navigable" id="navigation-supporting-concepts:traversable-navigable">traversable navigable</a>'s <a href="#tn-session-history-entries" id="navigation-supporting-concepts:tn-session-history-entries">session history</a> gets updated. The
  <code id="navigation-supporting-concepts:navigationhistorybehavior"><a href="#navigationhistorybehavior">NavigationHistoryBehavior</a></code> enumeration is used to indicate the desired type of session
  history update to the <a href="#navigate" id="navigation-supporting-concepts:navigate-2">navigate</a> algorithm. It is one of the following:</p>

  <dl><dt id="hh-default"><span id="hh-push"></span>"<dfn data-dfn-for="NavigationHistoryBehavior" id="navigationhistorybehavior-push" data-dfn-type="enum-value"><code>push</code></dfn>"</dt><dd>A regular navigation which adds a new <a href="#session-history-entry" id="navigation-supporting-concepts:session-history-entry">session history entry</a>, and will
   <a href="#clear-the-forward-session-history" id="navigation-supporting-concepts:clear-the-forward-session-history">clear the forward session history</a>.</dd><dt id="hh-replace">"<dfn data-dfn-for="NavigationHistoryBehavior" id="navigationhistorybehavior-replace" data-dfn-type="enum-value"><code>replace</code></dfn>"</dt><dd>A navigation that will replace the <a href="#nav-active-history-entry" id="navigation-supporting-concepts:nav-active-history-entry">active session
   history entry</a>.</dd><dt>"<dfn data-dfn-for="NavigationHistoryBehavior" id="navigationhistorybehavior-auto" data-dfn-type="enum-value"><code>auto</code></dfn>"</dt><dd>The default value, which will be converted very early in the <a href="#navigate" id="navigation-supporting-concepts:navigate-3">navigate</a> algorithm
   into "<code id="navigation-supporting-concepts:navigationhistorybehavior-push"><a href="#navigationhistorybehavior-push">push</a></code>" or "<code id="navigation-supporting-concepts:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>". Usually it becomes "<code id="navigation-supporting-concepts:navigationhistorybehavior-push-2"><a href="#navigationhistorybehavior-push">push</a></code>", but under <a href="#navigate-convert-to-replace">certain circumstances</a> it becomes "<code id="navigation-supporting-concepts:navigationhistorybehavior-replace-2"><a href="#navigationhistorybehavior-replace">replace</a></code>" instead.</dd></dl>

  <p>A <dfn id="history-handling-behavior">history handling behavior</dfn> is a <code id="navigation-supporting-concepts:navigationhistorybehavior-2"><a href="#navigationhistorybehavior">NavigationHistoryBehavior</a></code> that is
  either "<code id="navigation-supporting-concepts:navigationhistorybehavior-push-3"><a href="#navigationhistorybehavior-push">push</a></code>" or "<code id="navigation-supporting-concepts:navigationhistorybehavior-replace-3"><a href="#navigationhistorybehavior-replace">replace</a></code>", i.e., that has been resolved away from
  any initial "<code id="navigation-supporting-concepts:navigationhistorybehavior-auto"><a href="#navigationhistorybehavior-auto">auto</a></code>" value.</p>

  <div data-algorithm="">
  <p><dfn id="the-navigation-must-be-a-replace">The navigation must be a replace</dfn>, given a <a id="navigation-supporting-concepts:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var> and a
  <code id="navigation-supporting-concepts:document-14"><a href="#document">Document</a></code> <var>document</var>, if any of the following are true:</p>

  <ul><li><p><var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="navigation-supporting-concepts:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is "<code id="navigation-supporting-concepts:the-javascript:-url-special-case"><a href="#the-javascript:-url-special-case">javascript</a></code>"; or</p></li><li><p><var>document</var>'s <a href="#is-initial-about:blank" id="navigation-supporting-concepts:is-initial-about:blank">is initial <code>about:blank</code></a> is true.</p></li></ul>
  </div>

  <div class="note">
   <p>Other cases that often, but not always, force a "<code id="navigation-supporting-concepts:navigationhistorybehavior-replace-4"><a href="#navigationhistorybehavior-replace">replace</a></code>" navigation are:</p>

   <ul><li><p>if the <code id="navigation-supporting-concepts:document-15"><a href="#document">Document</a></code> is not <a href="#completely-loaded" id="navigation-supporting-concepts:completely-loaded">completely loaded</a>; or</p></li><li><p>if the target <a id="navigation-supporting-concepts:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> equals the <code id="navigation-supporting-concepts:document-16"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="navigation-supporting-concepts:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li></ul>
  </div>

  <hr>

  <p>Various parts of the platform track whether a user is involved in a navigation. A <dfn id="user-navigation-involvement" data-export="">user navigation involvement</dfn> is one of the following:</p>

  <dl><dt>"<dfn data-dfn-for="user navigation involvement" id="uni-browser-ui" data-export=""><code>browser UI</code></dfn>"</dt><dd>The navigation was initiated by the user via browser UI mechanisms.</dd><dt>"<dfn data-dfn-for="user navigation involvement" id="uni-activation" data-export=""><code>activation</code></dfn>"</dt><dd>The navigation was initiated by the user via the <a id="navigation-supporting-concepts:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> of an
   element.</dd><dt>"<dfn data-dfn-for="user navigation involvement" id="uni-none" data-export=""><code>none</code></dfn>"</dt><dd>The navigation was not initiated by the user.</dd></dl>

  <div data-algorithm="">
  <p>For convenience at certain call sites, the <dfn data-dfn-for="Event" id="event-uni">user navigation
  involvement</dfn> for an <code id="navigation-supporting-concepts:event"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code> <var>event</var> is defined as follows:</p>

  <ol><li><p><a id="navigation-supporting-concepts:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this algorithm is being called as part of an <a id="navigation-supporting-concepts:activation-behaviour-2" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation
   behavior</a> definition.</p></li><li><p><a id="navigation-supporting-concepts:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>event</var>'s <code id="navigation-supporting-concepts:dom-event-type"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> is
   "<code id="navigation-supporting-concepts:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code>".</p></li><li><p>If <var>event</var>'s <code id="navigation-supporting-concepts:dom-event-istrusted"><a data-x-internal="dom-event-istrusted" href="https://dom.spec.whatwg.org/#dom-event-istrusted">isTrusted</a></code> is initialized
   to true, then return "<code id="navigation-supporting-concepts:uni-activation"><a href="#uni-activation">activation</a></code>".</p></li><li><p>Return "<code id="navigation-supporting-concepts:uni-none"><a href="#uni-none">none</a></code>".</p></li></ol>
  </div>


  <h5 id="beginning-navigation"><span class="secno">7.4.2.2</span> Beginning navigation<a href="#beginning-navigation" class="self-link"></a></h5>

  
  

  <div data-algorithm="">
  <p>To <dfn id="navigate" data-export="">navigate</dfn> a <a href="#navigable" id="beginning-navigation:navigable">navigable</a> <var>navigable</var> to a
  <a id="beginning-navigation:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var> using an optional <code id="beginning-navigation:document"><a href="#document">Document</a></code>-or-null <var id="source-browsing-context">sourceDocument</var> (default null), with an optional <a href="#post-resource" id="beginning-navigation:post-resource">POST
  resource</a>, string, or null <dfn data-dfn-for="navigate" id="navigation-resource" data-export=""><var>documentResource</var></dfn> (default null), an optional <a href="https://fetch.spec.whatwg.org/#concept-response" id="beginning-navigation:concept-response" data-x-internal="concept-response">response</a>-or-null <dfn data-dfn-for="navigate" id="navigation-response" data-export=""><var>response</var></dfn> (default null), an optional boolean <dfn data-dfn-for="navigate" id="exceptions-enabled" data-export=""><var>exceptionsEnabled</var></dfn> (default false), an optional
  <code id="beginning-navigation:navigationhistorybehavior"><a href="#navigationhistorybehavior">NavigationHistoryBehavior</a></code> <dfn data-dfn-for="navigate" id="navigation-hh" data-export=""><var>historyHandling</var></dfn> (default "<code id="beginning-navigation:navigationhistorybehavior-auto"><a href="#navigationhistorybehavior-auto">auto</a></code>"), an optional <a href="#serialized-state" id="beginning-navigation:serialized-state">serialized
  state</a>-or-null <dfn data-dfn-for="navigate" id="navigation-navigation-api-state" data-export=""><var>navigationAPIState</var></dfn> (default null), an optional <a href="#entry-list" id="beginning-navigation:entry-list">entry list</a> or
  null <dfn data-dfn-for="navigate" id="navigation-form-data-entry-list" data-export=""><var>formDataEntryList</var></dfn> (default null), an optional <a id="beginning-navigation:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>
  <dfn id="navigation-referrer-policy"><var>referrerPolicy</var></dfn> (default the empty
  string), an optional <a href="#user-navigation-involvement" id="beginning-navigation:user-navigation-involvement">user navigation involvement</a> <dfn id="navigation-user-involvement"><var>userInvolvement</var></dfn> (default "<code id="beginning-navigation:uni-none"><a href="#uni-none">none</a></code>"), an optional <code id="beginning-navigation:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> <dfn id="navigation-source-element"><var>sourceElement</var></dfn> (default null), an optional
  boolean <dfn data-dfn-for="navigate" id="navigation-initial-insertion"><var>initialInsertion</var></dfn> (default false), and an
  optional <a href="#navigation-api-method-tracker" id="beginning-navigation:navigation-api-method-tracker">navigation API method tracker</a>-or-null <dfn data-dfn-for="navigate" id="navigation-api-method-tracker-2"><var>apiMethodTracker</var></dfn> (default null):</p>

  <ol><li><p>Let <var>cspNavigationType</var> be "<code>form-submission</code>" if
   <var>formDataEntryList</var> is non-null; otherwise "<code>other</code>".</p></li><li><p>Let <var>sourceSnapshotParams</var> be the result of <a href="#snapshotting-source-snapshot-params" id="beginning-navigation:snapshotting-source-snapshot-params">snapshotting source snapshot
   params</a> given <var>sourceDocument</var>.</p></li><li><p>Let <var>initiatorOriginSnapshot</var> be a new <a href="#concept-origin-opaque" id="beginning-navigation:concept-origin-opaque">opaque origin</a>.</p></li><li><p>Let <var>initiatorBaseURLSnapshot</var> be <code id="beginning-navigation:about:blank"><a href="#about:blank">about:blank</a></code>.</p></li><li>
    <p>If <var>sourceDocument</var> is null:</p>

    <ol><li id="assert-null-sourcedocument"><p><a id="beginning-navigation:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>userInvolvement</var> is
     "<code id="beginning-navigation:uni-browser-ui"><a href="#uni-browser-ui">browser UI</a></code>".</p></li><li><p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="beginning-navigation:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is "<code id="beginning-navigation:the-javascript:-url-special-case"><a href="#the-javascript:-url-special-case">javascript</a></code>", then set <var>initiatorOriginSnapshot</var> to
     <var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="beginning-navigation:concept-document-origin" data-x-internal="concept-document-origin">origin</a>.</p></li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p><a id="beginning-navigation:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>userInvolvement</var> is not "<code id="beginning-navigation:uni-browser-ui-2"><a href="#uni-browser-ui">browser UI</a></code>".</p></li><li id="sandboxLinks">
      <p>If <var>sourceDocument</var>'s <a href="#node-navigable" id="beginning-navigation:node-navigable">node navigable</a> is not <a href="#allowed-to-navigate" id="beginning-navigation:allowed-to-navigate">allowed by
      sandboxing to navigate</a> <var>navigable</var> given <var>sourceSnapshotParams</var>:</p>

      <ol><li><p>If <var>exceptionsEnabled</var> is true, then throw a
       <a id="beginning-navigation:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="beginning-navigation:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return.</p></li></ol>
     </li><li><p>Set <var>initiatorOriginSnapshot</var> to <var>sourceDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="beginning-navigation:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>.</p></li><li><p>Set <var>initiatorBaseURLSnapshot</var> to <var>sourceDocument</var>'s <a href="#document-base-url" id="beginning-navigation:document-base-url">document
     base URL</a>.</p></li></ol>
   </li><li><p>Let <var>navigationId</var> be the result of <a id="beginning-navigation:generating-a-random-uuid" href="https://w3c.github.io/webcrypto/#dfn-generate-a-random-uuid" data-x-internal="generating-a-random-uuid">generating a random UUID</a>.
   <a href="#refsWEBCRYPTO">[WEBCRYPTO]</a></p></li><li>
    <p>If the <a id="beginning-navigation:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a> is equal to <var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document-2">active document</a>'s <a href="#relevant-agent" id="beginning-navigation:relevant-agent">relevant agent</a>, then continue these
    steps. Otherwise, <a href="#queue-a-global-task" id="beginning-navigation:queue-a-global-task">queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="beginning-navigation:navigation-and-traversal-task-source">navigation and traversal task
    source</a> given <var>navigable</var>'s <a href="#nav-window" id="beginning-navigation:nav-window">active window</a> to
    continue these steps.</p>

    <div class="note">
     <p>We do this because we are about to look at a lot of properties of <var>navigable</var>'s
     <a href="#nav-document" id="beginning-navigation:nav-document-3">active document</a>, which are in theory only accessible over
     in the appropriate <a href="#event-loop" id="beginning-navigation:event-loop">event loop</a>. (But, we do not want to unconditionally queue a
     task, since — for example — same-event-loop <a href="#navigate-fragid" id="beginning-navigation:navigate-fragid">fragment navigations</a> need to take effect synchronously.)</p>

     <p>Another implementation strategy would be to replicate the relevant information across event
     loops, or into a canonical "browser process", so that it can be consulted without queueing a
     task. This could give different results than what we specify here in edge cases, where the
     relevant properties have changed over in the target event loop but not yet been replicated.
     Further testing is needed to determine which of these strategies best matches browser
     behavior, in such racy edge cases.</p>
    </div>
   </li><li><p>If <var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document-4">active document</a>'s
   <a href="#unload-counter" id="beginning-navigation:unload-counter">unload counter</a> is greater than 0, then invoke <a id="beginning-navigation:webdriver-bidi-navigation-failed" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-failed" data-x-internal="webdriver-bidi-navigation-failed">WebDriver BiDi navigation
   failed</a> with <var>navigable</var> and a <a id="beginning-navigation:webdriver-bidi-navigation-status" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose
   <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="beginning-navigation:navigation-status-id" data-x-internal="navigation-status-id">id</a> is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="beginning-navigation:navigation-status-status" data-x-internal="navigation-status-status">status</a> is "<code id="beginning-navigation:navigation-status-canceled"><a data-x-internal="navigation-status-canceled" href="https://w3c.github.io/webdriver-bidi/#navigation-status-canceled">canceled</a></code>", and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="beginning-navigation:navigation-status-url" data-x-internal="navigation-status-url">url</a> is <var>url</var>, and return.</p></li><li><p>Let <var>container</var> be <var>navigable</var>'s <a href="#nav-container" id="beginning-navigation:nav-container">container</a>.</p></li><li><p>If <var>container</var> is an <code id="beginning-navigation:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element and <a href="#will-lazy-load-element-steps" id="beginning-navigation:will-lazy-load-element-steps">will lazy load
   element steps</a> given <var>container</var> returns true, then <a href="#stop-intersection-observing-a-lazy-loading-element" id="beginning-navigation:stop-intersection-observing-a-lazy-loading-element">stop
   intersection-observing a lazy loading element</a> <var>container</var> and set
   <var>container</var>'s <a href="#lazy-load-resumption-steps" id="beginning-navigation:lazy-load-resumption-steps">lazy load resumption steps</a> to null.</p></li><li id="navigate-convert-to-replace">
    <p>If <var>historyHandling</var> is "<code id="beginning-navigation:navigationhistorybehavior-auto-2"><a href="#navigationhistorybehavior-auto">auto</a></code>",
    then:</p>

    <ol><li><p>If <var>url</var> <a href="https://url.spec.whatwg.org/#concept-url-equals" id="beginning-navigation:concept-url-equals" data-x-internal="concept-url-equals">equals</a>
     <var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document-5">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="beginning-navigation:the-document's-address" data-x-internal="the-document's-address">URL</a>, and <var>initiatorOriginSnapshot</var> is <a href="#same-origin" id="beginning-navigation:same-origin">same
     origin</a> with <var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document-6">active document</a>'s
     <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="beginning-navigation:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a>, then set <var>historyHandling</var> to
     "<code id="beginning-navigation:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p></li><li><p>Otherwise, set <var>historyHandling</var> to "<code id="beginning-navigation:navigationhistorybehavior-push"><a href="#navigationhistorybehavior-push">push</a></code>".</p></li></ol>
   </li><li><p>If <a href="#the-navigation-must-be-a-replace" id="beginning-navigation:the-navigation-must-be-a-replace">the navigation must be a replace</a> given <var>url</var> and
   <var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document-7">active document</a>, then set
   <var>historyHandling</var> to "<code id="beginning-navigation:navigationhistorybehavior-replace-2"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p></li><li id="navigate-fragid-step">
    <p>If all of the following are true:</p>

    <ul><li><p><var>documentResource</var> is null;</p></li><li><p><var>response</var> is null;</p></li><li><p><var>url</var> <a href="https://url.spec.whatwg.org/#concept-url-equals" id="beginning-navigation:concept-url-equals-2" data-x-internal="concept-url-equals">equals</a> <var>navigable</var>'s
     <a href="#nav-active-history-entry" id="beginning-navigation:nav-active-history-entry">active session history entry</a>'s <a href="#she-url" id="beginning-navigation:she-url">URL</a> with <a href="https://url.spec.whatwg.org/#url-equals-exclude-fragments" id="beginning-navigation:url-equals-exclude-fragments" data-x-internal="url-equals-exclude-fragments"><i>exclude
     fragments</i></a> set to true; and</p></li><li><p><var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="beginning-navigation:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> is
     non-null,</p></li></ul>

    <p>then:</p>

    <ol><li><p><a href="#navigate-fragid" id="beginning-navigation:navigate-fragid-2">Navigate to a fragment</a> given <var>navigable</var>,
     <var>url</var>, <var>historyHandling</var>, <var>userInvolvement</var>,
     <var>sourceElement</var>, <var>navigationAPIState</var>, and <var>navigationId</var>.</p></li><li><p>Return.</p></li></ol>
   </li><li><p>If <var>navigable</var>'s <a href="#nav-parent" id="beginning-navigation:nav-parent">parent</a> is non-null, then set
   <var>navigable</var>'s <a href="#delaying-load-events-mode" id="beginning-navigation:delaying-load-events-mode">is delaying <code>load</code> events</a> to
   true.</p></li><li><p>Let <var>targetSnapshotParams</var> be the result of <a href="#snapshotting-target-snapshot-params" id="beginning-navigation:snapshotting-target-snapshot-params">snapshotting target snapshot
   params</a> given <var>navigable</var>.</p></li><li><p>Invoke <a id="beginning-navigation:webdriver-bidi-navigation-started" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-started" data-x-internal="webdriver-bidi-navigation-started">WebDriver BiDi navigation started</a> with <var>navigable</var> and a new
   <a id="beginning-navigation:webdriver-bidi-navigation-status-2" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="beginning-navigation:navigation-status-id-2" data-x-internal="navigation-status-id">id</a>
   is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="beginning-navigation:navigation-status-status-2" data-x-internal="navigation-status-status">status</a> is "<code id="beginning-navigation:navigation-status-pending"><a data-x-internal="navigation-status-pending" href="https://w3c.github.io/webdriver-bidi/#navigation-status-pending">pending</a></code>", and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="beginning-navigation:navigation-status-url-2" data-x-internal="navigation-status-url">url</a> is <var>url</var>.</p></li><li>
    <p>If <var>navigable</var>'s <a href="#ongoing-navigation" id="beginning-navigation:ongoing-navigation">ongoing navigation</a> is "<code>traversal</code>", then:</p>

    <ol><li><p>Invoke <a id="beginning-navigation:webdriver-bidi-navigation-failed-2" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-failed" data-x-internal="webdriver-bidi-navigation-failed">WebDriver BiDi navigation failed</a> with <var>navigable</var> and a new
     <a id="beginning-navigation:webdriver-bidi-navigation-status-3" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="beginning-navigation:navigation-status-id-3" data-x-internal="navigation-status-id">id</a> is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="beginning-navigation:navigation-status-status-3" data-x-internal="navigation-status-status">status</a> is "<code id="beginning-navigation:navigation-status-canceled-2"><a data-x-internal="navigation-status-canceled" href="https://w3c.github.io/webdriver-bidi/#navigation-status-canceled">canceled</a></code>", and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="beginning-navigation:navigation-status-url-3" data-x-internal="navigation-status-url">url</a> is <var>url</var>.</p></li><li><p>Return.</p></li></ol>

    <p class="note">Any attempts to navigate a <a href="#navigable" id="beginning-navigation:navigable-2">navigable</a> that is currently <a href="#apply-the-traverse-history-step" id="beginning-navigation:apply-the-traverse-history-step">traversing</a> are ignored.</p>
   </li><li>
    <p><a href="#set-the-ongoing-navigation" id="beginning-navigation:set-the-ongoing-navigation">Set the ongoing navigation</a> for <var>navigable</var> to
    <var>navigationId</var>.</p>

    <p class="note">This will have the effect of aborting other ongoing navigations of
    <var>navigable</var>, since at certain points during navigation changes to the <a href="#ongoing-navigation" id="beginning-navigation:ongoing-navigation-2">ongoing
    navigation</a> will cause further work to be abandoned.</p>
   </li><li>
    <p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="beginning-navigation:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a> is "<code id="beginning-navigation:the-javascript:-url-special-case-2"><a href="#the-javascript:-url-special-case">javascript</a></code>", then:</p>

    <ol><li><p><a href="#queue-a-global-task" id="beginning-navigation:queue-a-global-task-2">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="beginning-navigation:navigation-and-traversal-task-source-2">navigation and traversal task
     source</a> given <var>navigable</var>'s <a href="#nav-window" id="beginning-navigation:nav-window-2">active window</a> to
     <a href="#navigate-to-a-javascript:-url" id="beginning-navigation:navigate-to-a-javascript:-url">navigate to a <code>javascript:</code> URL</a> given <var>navigable</var>,
     <var>url</var>, <var>historyHandling</var>, <var>sourceSnapshotParams</var>,
     <var>initiatorOriginSnapshot</var>, <var>userInvolvement</var>,
     <var>cspNavigationType</var>, and <var>initialInsertion</var>.</p></li><li><p>Return.</p></li></ol>
   </li><li>
    <p>If all of the following are true:</p>

    <ul><li><p><var>userInvolvement</var> is not "<code id="beginning-navigation:uni-browser-ui-3"><a href="#uni-browser-ui">browser
     UI</a></code>";</p></li><li><p><var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document-8">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="beginning-navigation:concept-document-origin-4" data-x-internal="concept-document-origin">origin</a> is <a href="#same-origin-domain" id="beginning-navigation:same-origin-domain">same origin-domain</a> with
     <var>sourceDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="beginning-navigation:concept-document-origin-5" data-x-internal="concept-document-origin">origin</a>;</p></li><li><p><var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document-9">active document</a>'s <a href="#is-initial-about:blank" id="beginning-navigation:is-initial-about:blank">is
     initial <code>about:blank</code></a> is false; and</p></li><li><p><var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="beginning-navigation:concept-url-scheme-3" data-x-internal="concept-url-scheme">scheme</a> is a <a id="beginning-navigation:fetch-scheme" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch
     scheme</a>,</p></li></ul>

    <p>then:</p>

    <ol><li><p>Let <var>navigation</var> be <var>navigable</var>'s <a href="#nav-window" id="beginning-navigation:nav-window-3">active
     window</a>'s <a href="#window-navigation-api" id="beginning-navigation:window-navigation-api">navigation API</a>.</p></li><li><p>Let <var>entryListForFiring</var> be <var>formDataEntryList</var> if
     <var>documentResource</var> is a <a href="#post-resource" id="beginning-navigation:post-resource-2">POST resource</a>; otherwise, null.</p></li><li><p>Let <var>navigationAPIStateForFiring</var> be <var>navigationAPIState</var> if
     <var>navigationAPIState</var> is not null; otherwise,
     <a href="#structuredserializeforstorage" id="beginning-navigation:structuredserializeforstorage">StructuredSerializeForStorage</a>(undefined).</p></li><li><p>Let <var>continue</var> be the result of <a href="#fire-a-push/replace/reload-navigate-event" id="beginning-navigation:fire-a-push/replace/reload-navigate-event">firing a push/replace/reload <code>navigate</code>
     event</a> at <var>navigation</var> with <i id="beginning-navigation:fire-navigate-prr-navigationtype"><a href="#fire-navigate-prr-navigationtype">navigationType</a></i> set to <var>historyHandling</var>,
     <i id="beginning-navigation:fire-navigate-prr-issamedocument"><a href="#fire-navigate-prr-issamedocument">isSameDocument</a></i> set to false, <i id="beginning-navigation:fire-navigate-prr-userinvolvement"><a href="#fire-navigate-prr-userinvolvement">userInvolvement</a></i> set to
     <var>userInvolvement</var>, <i id="beginning-navigation:fire-navigate-prr-sourceelement"><a href="#fire-navigate-prr-sourceelement">sourceElement</a></i> set
     to <var>sourceElement</var>, <i id="beginning-navigation:fire-navigate-prr-formdataentrylist"><a href="#fire-navigate-prr-formdataentrylist">formDataEntryList</a></i> set to
     <var>entryListForFiring</var>, <i id="beginning-navigation:fire-navigate-prr-destinationurl"><a href="#fire-navigate-prr-destinationurl">destinationURL</a></i>
     set to <var>url</var>, <i id="beginning-navigation:fire-navigate-prr-navigationapistate"><a href="#fire-navigate-prr-navigationapistate">navigationAPIState</a></i>
     set to <var>navigationAPIStateForFiring</var>, and <i id="beginning-navigation:fire-navigate-prr-api-method-tracker"><a href="#fire-navigate-prr-api-method-tracker">apiMethodTracker</a></i> set to
     <var>apiMethodTracker</var>.</p></li><li><p>If <var>continue</var> is false, then return.</p>
    </li></ol>

    <p class="note">It is possible for navigations with <var>userInvolvement</var> of "<code id="beginning-navigation:uni-browser-ui-4"><a href="#uni-browser-ui">browser UI</a></code>" or initiated by a <a href="#same-origin-domain" id="beginning-navigation:same-origin-domain-2">cross origin-domain</a> <var>sourceDocument</var> to fire <code id="beginning-navigation:event-navigate"><a href="#event-navigate">navigate</a></code> events, if they go through the earlier <a href="#navigate-fragid" id="beginning-navigation:navigate-fragid-3">navigate to a fragment</a> path.</p>
   </li><li><p>If <var>sourceDocument</var> is <var>navigable</var>'s <a href="#nav-container-document" id="beginning-navigation:nav-container-document">container document</a>, then <a id="beginning-navigation:reserve-deferred-fetch-quota" href="https://fetch.spec.whatwg.org/#reserve-deferred-fetch-quota" data-x-internal="reserve-deferred-fetch-quota">reserve deferred fetch
   quota</a> for <var>navigable</var>'s <a href="#nav-container" id="beginning-navigation:nav-container-2">container</a> given
   <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="beginning-navigation:concept-url-origin" data-x-internal="concept-url-origin">origin</a>.</p></li><li>
    <p><a href="#in-parallel" id="beginning-navigation:in-parallel">In parallel</a>, run these steps:</p>

    <ol><li><p>Let <var>unloadPromptCanceled</var> be the result of <a href="#checking-if-unloading-is-canceled" id="beginning-navigation:checking-if-unloading-is-canceled">checking if unloading is
     canceled</a> for <var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document-10">active
     document</a>'s <a href="#inclusive-descendant-navigables" id="beginning-navigation:inclusive-descendant-navigables">inclusive descendant navigables</a>.</p>

     </li><li>
      <p>If <var>unloadPromptCanceled</var> is not "<code>continue</code>", or
      <var>navigable</var>'s <a href="#ongoing-navigation" id="beginning-navigation:ongoing-navigation-3">ongoing navigation</a> is no longer
      <var>navigationId</var>:</p>

      <ol><li><p>Invoke <a id="beginning-navigation:webdriver-bidi-navigation-failed-3" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-failed" data-x-internal="webdriver-bidi-navigation-failed">WebDriver BiDi navigation failed</a> with <var>navigable</var> and a
       new <a id="beginning-navigation:webdriver-bidi-navigation-status-4" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="beginning-navigation:navigation-status-id-4" data-x-internal="navigation-status-id">id</a> is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="beginning-navigation:navigation-status-status-4" data-x-internal="navigation-status-status">status</a> is "<code id="beginning-navigation:navigation-status-canceled-3"><a data-x-internal="navigation-status-canceled" href="https://w3c.github.io/webdriver-bidi/#navigation-status-canceled">canceled</a></code>", and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="beginning-navigation:navigation-status-url-4" data-x-internal="navigation-status-url">url</a> is <var>url</var>.</p></li><li><p>Abort these steps.</p></li></ol>
     </li><li><p><a href="#queue-a-global-task" id="beginning-navigation:queue-a-global-task-3">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="beginning-navigation:navigation-and-traversal-task-source-3">navigation and traversal task
     source</a> given <var>navigable</var>'s <a href="#nav-window" id="beginning-navigation:nav-window-4">active window</a> to
     <a href="#abort-a-document-and-its-descendants" id="beginning-navigation:abort-a-document-and-its-descendants">abort a document and its descendants</a> given <var>navigable</var>'s <a href="#nav-document" id="beginning-navigation:nav-document-11">active document</a>.</p></li><li id="navigation-create-document-state">
      <p>Let <var>documentState</var> be a new <a href="#document-state-2" id="beginning-navigation:document-state-2">document state</a> with</p>

      <dl class="props"><dt><a href="#document-state-request-referrer-policy" id="beginning-navigation:document-state-request-referrer-policy">request referrer policy</a></dt><dd><var>referrerPolicy</var></dd><dt><a href="#document-state-initiator-origin" id="beginning-navigation:document-state-initiator-origin">initiator origin</a></dt><dd><var>initiatorOriginSnapshot</var></dd><dt><a href="#document-state-resource" id="beginning-navigation:document-state-resource">resource</a></dt><dd><var>documentResource</var></dd><dt><a href="#document-state-nav-target-name" id="beginning-navigation:document-state-nav-target-name">navigable target name</a></dt><dd><var>navigable</var>'s <a href="#nav-target" id="beginning-navigation:nav-target">target name</a></dd></dl>

      <p class="note">The <a href="#document-state-nav-target-name" id="beginning-navigation:document-state-nav-target-name-2">navigable target
      name</a> can get cleared under various conditions later in the navigation process, before
      the document state is finalized.</p>
     </li><li>
      <p>If <var>url</var> <a href="#matches-about:blank" id="beginning-navigation:matches-about:blank">matches <code>about:blank</code></a> or
      is <code id="beginning-navigation:about:srcdoc"><a href="#about:srcdoc">about:srcdoc</a></code>, then:</p>

      <ol><li><p>Set <var>documentState</var>'s <a href="#document-state-origin" id="beginning-navigation:document-state-origin">origin</a> to
       <var>initiatorOriginSnapshot</var>.</p></li><li><p>Set <var>documentState</var>'s <a href="#document-state-about-base-url" id="beginning-navigation:document-state-about-base-url">about base
       URL</a> to <var>initiatorBaseURLSnapshot</var>.</p></li></ol>
     </li><li><p>Let <var>historyEntry</var> be a new <a href="#session-history-entry" id="beginning-navigation:session-history-entry">session history entry</a>, with its <a href="#she-url" id="beginning-navigation:she-url-2">URL</a> set to <var>url</var> and its <a href="#she-document-state" id="beginning-navigation:she-document-state">document state</a> set to
     <var>documentState</var>.</p></li><li><p>Let <var>navigationParams</var> be null.</p></li><li>
      <p>If <var>response</var> is non-null:</p>

      <p id="note-navigate-called-with-response" class="note"><a href="#note-navigate-called-with-response" class="self-link"></a>The <a href="#navigate" id="beginning-navigation:navigate">navigate</a> algorithm
      is only supplied with a <a href="https://fetch.spec.whatwg.org/#concept-response" id="beginning-navigation:concept-response-2" data-x-internal="concept-response">response</a> as part of the
      <code id="beginning-navigation:the-object-element"><a href="#the-object-element">object</a></code> and <code id="beginning-navigation:the-embed-element"><a href="#the-embed-element">embed</a></code> processing models, or for processing parts of
      <a href="#navigate-multipart-x-mixed-replace" id="beginning-navigation:navigate-multipart-x-mixed-replace"><code>multipart/x-mixed-replace</code>
      responses</a> after the initial response.</p>

      <ol><li><p>Let <var>sourcePolicyContainer</var> be a <a href="#clone-a-policy-container" id="beginning-navigation:clone-a-policy-container">clone</a> of the <var>sourceDocument</var>'s <a href="#concept-document-policy-container" id="beginning-navigation:concept-document-policy-container">policy container</a>, if
       <var>sourceDocument</var> is not null; otherwise null.</p></li><li><p>Let <var>policyContainer</var> be the result of <a href="#determining-navigation-params-policy-container" id="beginning-navigation:determining-navigation-params-policy-container">determining navigation params policy container</a> given
       <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="beginning-navigation:concept-response-url" data-x-internal="concept-response-url">URL</a>,
       null, <var>sourcePolicyContainer</var>, <var>navigable</var>'s <a href="#nav-container-document" id="beginning-navigation:nav-container-document-2">container document</a>'s <a href="#concept-document-policy-container" id="beginning-navigation:concept-document-policy-container-2">policy container</a>, and null.</p></li><li><p>Let <var>finalSandboxFlags</var> be the <a href="https://infra.spec.whatwg.org/#set-union" id="beginning-navigation:set-union" data-x-internal="set-union">union</a> of
       <var>targetSnapshotParams</var>'s <a href="#target-snapshot-params-sandbox" id="beginning-navigation:target-snapshot-params-sandbox">sandboxing
       flags</a> and <var>policyContainer</var>'s <a href="#policy-container-csp-list" id="beginning-navigation:policy-container-csp-list">CSP
       list</a>'s <a href="#csp-derived-sandboxing-flags" id="beginning-navigation:csp-derived-sandboxing-flags">CSP-derived sandboxing flags</a>.</p></li><li><p>Let <var>responseOrigin</var> be the result of <a href="#determining-the-origin" id="beginning-navigation:determining-the-origin">determining the origin</a>
       given <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="beginning-navigation:concept-response-url-2" data-x-internal="concept-response-url">URL</a>,
       <var>finalSandboxFlags</var>, and <var>documentState</var>'s <a href="#document-state-initiator-origin" id="beginning-navigation:document-state-initiator-origin-2">initiator origin</a>.</p></li><li><p>Let <var>coop</var> be a new <a href="#cross-origin-opener-policy" id="beginning-navigation:cross-origin-opener-policy">opener policy</a>.</p></li><li>
        <p>Let <var>coopEnforcementResult</var> be a new <a href="#coop-enforcement-result" id="beginning-navigation:coop-enforcement-result">opener policy enforcement result</a>
        with</p>

        <dl class="props"><dt><a href="#coop-enforcement-url" id="beginning-navigation:coop-enforcement-url">url</a></dt><dd><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="beginning-navigation:concept-response-url-3" data-x-internal="concept-response-url">URL</a></dd><dt><a href="#coop-enforcement-origin" id="beginning-navigation:coop-enforcement-origin">origin</a></dt><dd><var>responseOrigin</var></dd><dt><a href="#coop-enforcement-coop" id="beginning-navigation:coop-enforcement-coop">opener policy</a></dt><dd><var>coop</var></dd></dl>
       </li><li>
        <p>Set <var>navigationParams</var> to a new <a href="#navigation-params" id="beginning-navigation:navigation-params">navigation params</a>, with</p>

        <dl class="props"><dt><a href="#navigation-params-id" id="beginning-navigation:navigation-params-id">id</a></dt><dd><var>navigationId</var></dd><dt><a href="#navigation-params-navigable" id="beginning-navigation:navigation-params-navigable">navigable</a></dt><dd><var>navigable</var></dd><dt><a href="#navigation-params-request" id="beginning-navigation:navigation-params-request">request</a></dt><dd>null</dd><dt><a href="#navigation-params-response" id="beginning-navigation:navigation-params-response">response</a></dt><dd><var>response</var></dd><dt><a href="#navigation-params-fetch-controller" id="beginning-navigation:navigation-params-fetch-controller">fetch controller</a></dt><dd>null</dd><dt><a href="#navigation-params-commit-early-hints" id="beginning-navigation:navigation-params-commit-early-hints">commit early hints</a></dt><dd>null</dd><dt><a href="#navigation-params-coop-enforcement-result" id="beginning-navigation:navigation-params-coop-enforcement-result">COOP enforcement result</a></dt><dd><var>coopEnforcementResult</var></dd><dt><a href="#navigation-params-reserved-environment" id="beginning-navigation:navigation-params-reserved-environment">reserved environment</a></dt><dd>null</dd><dt><a href="#navigation-params-origin" id="beginning-navigation:navigation-params-origin">origin</a></dt><dd><var>responseOrigin</var></dd><dt><a href="#navigation-params-policy-container" id="beginning-navigation:navigation-params-policy-container">policy container</a></dt><dd><var>policyContainer</var></dd><dt><a href="#navigation-params-sandboxing" id="beginning-navigation:navigation-params-sandboxing">final sandboxing flag set</a></dt><dd><var>finalSandboxFlags</var></dd><dt><a href="#navigation-params-coop" id="beginning-navigation:navigation-params-coop">opener policy</a></dt><dd><var>coop</var></dd><dt><a href="#navigation-params-nav-timing-type" id="beginning-navigation:navigation-params-nav-timing-type">navigation timing type</a></dt><dd>"<code id="beginning-navigation:dom-navigationtimingtype-navigate"><a data-x-internal="dom-navigationtimingtype-navigate" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype-navigate">navigate</a></code>"</dd><dt><a href="#navigation-params-about-base-url" id="beginning-navigation:navigation-params-about-base-url">about base URL</a></dt><dd><var>documentState</var>'s <a href="#document-state-about-base-url" id="beginning-navigation:document-state-about-base-url-2">about base
         URL</a></dd><dt><a href="#navigation-params-user-involvement" id="beginning-navigation:navigation-params-user-involvement">user involvement</a></dt><dd><var>userInvolvement</var></dd></dl>
       </li></ol>
     </li><li>
      <p><a href="#attempt-to-populate-the-history-entry's-document" id="beginning-navigation:attempt-to-populate-the-history-entry's-document">Attempt to populate the history entry's document</a> for <var>historyEntry</var>,
      given <var>navigable</var>, "<code id="beginning-navigation:dom-navigationtimingtype-navigate-2"><a data-x-internal="dom-navigationtimingtype-navigate" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype-navigate">navigate</a></code>", <var>sourceSnapshotParams</var>,
      <var>targetSnapshotParams</var>, <var>userInvolvement</var>, <var>navigationId</var>,
      <var>navigationParams</var>, <var>cspNavigationType</var>, with <i id="beginning-navigation:attempt-to-populate-allow-post"><a href="#attempt-to-populate-allow-post">allowPOST</a></i> set to true and <i id="beginning-navigation:attempt-to-populate-completion-steps"><a href="#attempt-to-populate-completion-steps">completionSteps</a></i> set to the following
      step:</p>

      <ol><li><p><a href="#tn-append-session-history-traversal-steps" id="beginning-navigation:tn-append-session-history-traversal-steps">Append session history
       traversal steps</a> to <var>navigable</var>'s <a href="#nav-traversable" id="beginning-navigation:nav-traversable">traversable</a> to <a href="#finalize-a-cross-document-navigation" id="beginning-navigation:finalize-a-cross-document-navigation">finalize a cross-document
       navigation</a> given <var>navigable</var>, <var>historyHandling</var>,
       <var>userInvolvement</var>, and <var>historyEntry</var>.</p></li></ol>
     </li></ol>
   </li></ol>
  </div>


  <h5 id="ending-navigation"><span class="secno">7.4.2.3</span> Ending navigation<a href="#ending-navigation" class="self-link"></a></h5>

  <p>Although the usual cross-document navigation case will first foray into <a href="#populating-a-session-history-entry">populating a session history entry</a> with a
  <code id="ending-navigation:document"><a href="#document">Document</a></code>, all navigations that don't get aborted will ultimately end up calling into
  one of the below algorithms.</p>


  <h6 id="the-usual-cross-document-navigation-case"><span class="secno">7.4.2.3.1</span> The usual cross-document navigation case<a href="#the-usual-cross-document-navigation-case" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>To <dfn id="finalize-a-cross-document-navigation">finalize a cross-document navigation</dfn> given a <a href="#navigable" id="the-usual-cross-document-navigation-case:navigable">navigable</a>
  <var>navigable</var>, a <a href="#history-handling-behavior" id="the-usual-cross-document-navigation-case:history-handling-behavior">history handling behavior</a> <var>historyHandling</var>, a
  <a href="#user-navigation-involvement" id="the-usual-cross-document-navigation-case:user-navigation-involvement">user navigation involvement</a> <var>userInvolvement</var>, and a <a href="#session-history-entry" id="the-usual-cross-document-navigation-case:session-history-entry">session history
  entry</a> <var>historyEntry</var>:</p>

  <ol><li><p><a id="the-usual-cross-document-navigation-case:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running on <var>navigable</var>'s <a href="#nav-traversable" id="the-usual-cross-document-navigation-case:nav-traversable">traversable navigable's</a> <a href="#tn-session-history-traversal-queue" id="the-usual-cross-document-navigation-case:tn-session-history-traversal-queue">session history traversal queue</a>.</p></li><li><p>Set <var>navigable</var>'s <a href="#delaying-load-events-mode" id="the-usual-cross-document-navigation-case:delaying-load-events-mode">is delaying <code>load</code>
   events</a> to false.</p></li><li>
    <p>If <var>historyEntry</var>'s <a href="#she-document" id="the-usual-cross-document-navigation-case:she-document">document</a> is null, then
    return.</p>

    <p class="note">This means that <a href="#attempt-to-populate-the-history-entry's-document" id="the-usual-cross-document-navigation-case:attempt-to-populate-the-history-entry's-document">attempting to populate the history entry's document</a> ended up not creating a
    document, as a result of e.g., the navigation being canceled by a subsequent navigation, a 204
    No Content response, etc.</p>
   </li><li id="resetBCName">
    <p>If all of the following are true:</p>

    <ul><li><p><var>navigable</var>'s <a href="#nav-parent" id="the-usual-cross-document-navigation-case:nav-parent">parent</a> is null;</p></li><li><p><var>historyEntry</var>'s <a href="#she-document" id="the-usual-cross-document-navigation-case:she-document-2">document</a>'s <a href="#concept-document-bc" id="the-usual-cross-document-navigation-case:concept-document-bc">browsing context</a> is not an <a href="#auxiliary-browsing-context" id="the-usual-cross-document-navigation-case:auxiliary-browsing-context">auxiliary browsing
     context</a> whose <a href="#opener-browsing-context" id="the-usual-cross-document-navigation-case:opener-browsing-context">opener browsing context</a> is non-null; and</p></li><li><p><var>historyEntry</var>'s <a href="#she-document" id="the-usual-cross-document-navigation-case:she-document-3">document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-usual-cross-document-navigation-case:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is not <var>navigable</var>'s <a href="#nav-document" id="the-usual-cross-document-navigation-case:nav-document">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-usual-cross-document-navigation-case:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>,</p></li></ul>

    <p>then set <var>historyEntry</var>'s <a href="#she-document-state" id="the-usual-cross-document-navigation-case:she-document-state">document state</a>'s
    <a href="#document-state-nav-target-name" id="the-usual-cross-document-navigation-case:document-state-nav-target-name">navigable target name</a> to the empty
    string.</p>
   </li><li><p>Let <var>entryToReplace</var> be <var>navigable</var>'s <a href="#nav-active-history-entry" id="the-usual-cross-document-navigation-case:nav-active-history-entry">active session history entry</a> if
   <var>historyHandling</var> is "<code id="the-usual-cross-document-navigation-case:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>",
   otherwise null.</p></li><li><p>Let <var>traversable</var> be <var>navigable</var>'s <a href="#nav-traversable" id="the-usual-cross-document-navigation-case:nav-traversable-2">traversable navigable</a>.</p></li><li><p>Let <var>targetStep</var> be null.</p></li><li><p>Let <var>targetEntries</var> be the result of <a href="#getting-session-history-entries" id="the-usual-cross-document-navigation-case:getting-session-history-entries">getting session history
   entries</a> for <var>navigable</var>.</p></li><li>
    <p>If <var>entryToReplace</var> is null, then:</p>

    <ol><li><p><a href="#clear-the-forward-session-history" id="the-usual-cross-document-navigation-case:clear-the-forward-session-history">Clear the forward session history</a> of <var>traversable</var>.</p></li><li><p>Set <var>targetStep</var> to <var>traversable</var>'s <a href="#tn-current-session-history-step" id="the-usual-cross-document-navigation-case:tn-current-session-history-step">current session history step</a> + 1.</p></li><li><p>Set <var>historyEntry</var>'s <a href="#she-step" id="the-usual-cross-document-navigation-case:she-step">step</a> to
     <var>targetStep</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="the-usual-cross-document-navigation-case:list-append" data-x-internal="list-append">Append</a> <var>historyEntry</var> to
     <var>targetEntries</var>.</p></li></ol>

    <p>Otherwise:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-replace" id="the-usual-cross-document-navigation-case:list-replace" data-x-internal="list-replace">Replace</a> <var>entryToReplace</var> with
     <var>historyEntry</var> in <var>targetEntries</var>.</p></li><li><p>Set <var>historyEntry</var>'s <a href="#she-step" id="the-usual-cross-document-navigation-case:she-step-2">step</a> to
     <var>entryToReplace</var>'s <a href="#she-step" id="the-usual-cross-document-navigation-case:she-step-3">step</a>.</p></li><li><p>If <var>historyEntry</var>'s <a href="#she-document-state" id="the-usual-cross-document-navigation-case:she-document-state-2">document state</a>'s
     <a href="#document-state-origin" id="the-usual-cross-document-navigation-case:document-state-origin">origin</a> is <a href="#same-origin" id="the-usual-cross-document-navigation-case:same-origin">same origin</a> with
     <var>entryToReplace</var>'s <a href="#she-document-state" id="the-usual-cross-document-navigation-case:she-document-state-3">document state</a>'s <a href="#document-state-origin" id="the-usual-cross-document-navigation-case:document-state-origin-2">origin</a>, then set <var>historyEntry</var>'s <a href="#she-navigation-api-key" id="the-usual-cross-document-navigation-case:she-navigation-api-key">navigation API key</a> to <var>entryToReplace</var>'s <a href="#she-navigation-api-key" id="the-usual-cross-document-navigation-case:she-navigation-api-key-2">navigation API key</a>.</p></li><li><p>Set <var>targetStep</var> to <var>traversable</var>'s <a href="#tn-current-session-history-step" id="the-usual-cross-document-navigation-case:tn-current-session-history-step-2">current session history step</a>.</p></li></ol>
   </li><li><p><a href="#apply-the-push/replace-history-step" id="the-usual-cross-document-navigation-case:apply-the-push/replace-history-step">Apply the push/replace history step</a> <var>targetStep</var> to
   <var>traversable</var> given <var>historyHandling</var> and <var>userInvolvement</var>.</p></li></ol>
  </div>


  <h6 id="the-javascript:-url-special-case"><span class="secno">7.4.2.3.2</span> <dfn>The <code>javascript:</code> URL special case</dfn><a href="#the-javascript:-url-special-case" class="self-link"></a></h6>

  <p class="XXX"><code id="the-javascript:-url-special-case:the-javascript:-url-special-case"><a href="#the-javascript:-url-special-case">javascript:</a></code> URLs have a <a href="https://github.com/whatwg/html/labels/topic%3A%20javascript%3A%20URLs">dedicated label</a>
  on the issue tracker documenting various problems with their specification.</p>

  <div data-algorithm="">
  <p>To <dfn id="navigate-to-a-javascript:-url">navigate to a <code>javascript:</code> URL</dfn>, given a <a href="#navigable" id="the-javascript:-url-special-case:navigable">navigable</a>
  <var>targetNavigable</var>, a <a id="the-javascript:-url-special-case:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, a <a href="#history-handling-behavior" id="the-javascript:-url-special-case:history-handling-behavior">history handling
  behavior</a> <var>historyHandling</var>, a <a href="#source-snapshot-params" id="the-javascript:-url-special-case:source-snapshot-params">source snapshot params</a>
  <var>sourceSnapshotParams</var>, an <a href="#concept-origin" id="the-javascript:-url-special-case:concept-origin">origin</a> <var>initiatorOrigin</var>, a <a href="#user-navigation-involvement" id="the-javascript:-url-special-case:user-navigation-involvement">user
  navigation involvement</a> <var>userInvolvement</var>, a string
  <var>cspNavigationType</var>, and a boolean <var>initialInsertion</var>:</p>

  <ol><li><p><a id="the-javascript:-url-special-case:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>historyHandling</var> is "<code id="the-javascript:-url-special-case:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p></li><li><p><a href="#set-the-ongoing-navigation" id="the-javascript:-url-special-case:set-the-ongoing-navigation">Set the ongoing navigation</a> for <var>targetNavigable</var> to null.</p></li><li><p>If <var>initiatorOrigin</var> is not <a href="#same-origin-domain" id="the-javascript:-url-special-case:same-origin-domain">same origin-domain</a> with
   <var>targetNavigable</var>'s <a href="#nav-document" id="the-javascript:-url-special-case:nav-document">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-javascript:-url-special-case:concept-document-origin" data-x-internal="concept-document-origin">origin</a>, then return.</p></li><li>
    <p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="the-javascript:-url-special-case:concept-request" data-x-internal="concept-request">request</a> whose <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="the-javascript:-url-special-case:concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>url</var> and whose <a href="https://fetch.spec.whatwg.org/#concept-request-policy-container" id="the-javascript:-url-special-case:concept-request-policy-container" data-x-internal="concept-request-policy-container">policy container</a> is
    <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-policy-container" id="the-javascript:-url-special-case:source-snapshot-params-policy-container">source
    policy container</a>.</p>

    <p class="note">This is a synthetic <a href="https://fetch.spec.whatwg.org/#concept-request" id="the-javascript:-url-special-case:concept-request-2" data-x-internal="concept-request">request</a> solely for
    plumbing into the next step. It will never hit the network.</p>
   </li><li><p>If the result of <a id="the-javascript:-url-special-case:should-navigation-request-of-type-be-blocked-by-content-security-policy" href="https://w3c.github.io/webappsec-csp/#should-block-navigation-request" data-x-internal="should-navigation-request-of-type-be-blocked-by-content-security-policy">should navigation request of type be blocked by Content Security
   Policy?</a> given <var>request</var> and <var>cspNavigationType</var> is "<code>Blocked</code>", then return. <a href="#refsCSP">[CSP]</a></p></li><li><p>Let <var>newDocument</var> be the result of <a href="#evaluate-a-javascript:-url" id="the-javascript:-url-special-case:evaluate-a-javascript:-url">evaluating a <code>javascript:</code> URL</a> given <var>targetNavigable</var>,
   <var>url</var>, <var>initiatorOrigin</var>, and <var>userInvolvement</var>.</p></li><li>
    <p>If <var>newDocument</var> is null:</p>

    <ol><li><p>If <var>initialInsertion</var> is true and <var>targetNavigable</var>'s <a href="#nav-document" id="the-javascript:-url-special-case:nav-document-2">active document</a>'s <a href="#is-initial-about:blank" id="the-javascript:-url-special-case:is-initial-about:blank">is initial
     <code>about:blank</code></a> is true, then run the <a href="#iframe-load-event-steps" id="the-javascript:-url-special-case:iframe-load-event-steps">iframe load event steps</a>
     given <var>targetNavigable</var>'s <a href="#nav-container" id="the-javascript:-url-special-case:nav-container">container</a>.</p></li><li><p>Return.</p></li></ol>

    <p class="note">In this case, some JavaScript code was executed, but no new
    <code id="the-javascript:-url-special-case:document"><a href="#document">Document</a></code> was created, so we will not perform a navigation.</p>
   </li><li><p><a id="the-javascript:-url-special-case:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>initiatorOrigin</var> is <var>newDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-javascript:-url-special-case:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>.</p></li><li><p>Let <var>entryToReplace</var> be <var>targetNavigable</var>'s <a href="#nav-active-history-entry" id="the-javascript:-url-special-case:nav-active-history-entry">active session history entry</a>.</p></li><li><p>Let <var>oldDocState</var> be <var>entryToReplace</var>'s <a href="#she-document-state" id="the-javascript:-url-special-case:she-document-state">document state</a>.</p></li><li>
    <p>Let <var>documentState</var> be a new <a href="#document-state-2" id="the-javascript:-url-special-case:document-state-2">document state</a> with</p>

    <dl class="props"><dt><a href="#document-state-document" id="the-javascript:-url-special-case:document-state-document">document</a></dt><dd><var>newDocument</var></dd><dt><a href="#document-state-history-policy-container" id="the-javascript:-url-special-case:document-state-history-policy-container">history policy container</a></dt><dd>a <a href="#clone-a-policy-container" id="the-javascript:-url-special-case:clone-a-policy-container">clone</a> of the <var>oldDocState</var>'s
     <a href="#document-state-history-policy-container" id="the-javascript:-url-special-case:document-state-history-policy-container-2">history policy container</a> if it is
     non-null; null otherwise</dd><dt><a href="#document-state-request-referrer" id="the-javascript:-url-special-case:document-state-request-referrer">request referrer</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-request-referrer" id="the-javascript:-url-special-case:document-state-request-referrer-2">request
     referrer</a></dd><dt><a href="#document-state-request-referrer-policy" id="the-javascript:-url-special-case:document-state-request-referrer-policy">request referrer policy</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-request-referrer-policy" id="the-javascript:-url-special-case:document-state-request-referrer-policy-2">request
     referrer policy</a> <span class="XXX">or should this be the <var>referrerPolicy</var> that
     was passed to <a href="#navigate" id="the-javascript:-url-special-case:navigate">navigate</a>?</span></dd><dt><a href="#document-state-initiator-origin" id="the-javascript:-url-special-case:document-state-initiator-origin">initiator origin</a></dt><dd><var>initiatorOrigin</var></dd><dt><a href="#document-state-origin" id="the-javascript:-url-special-case:document-state-origin">origin</a></dt><dd><var>initiatorOrigin</var></dd><dt><a href="#document-state-about-base-url" id="the-javascript:-url-special-case:document-state-about-base-url">about base URL</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-about-base-url" id="the-javascript:-url-special-case:document-state-about-base-url-2">about base
     URL</a></dd><dt><a href="#document-state-resource" id="the-javascript:-url-special-case:document-state-resource">resource</a></dt><dd>null</dd><dt><a href="#document-state-ever-populated" id="the-javascript:-url-special-case:document-state-ever-populated">ever populated</a></dt><dd>true</dd><dt><a href="#document-state-nav-target-name" id="the-javascript:-url-special-case:document-state-nav-target-name">navigable target name</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-nav-target-name" id="the-javascript:-url-special-case:document-state-nav-target-name-2">navigable target
     name</a></dd></dl>
   </li><li>
    <p>Let <var>historyEntry</var> be a new <a href="#session-history-entry" id="the-javascript:-url-special-case:session-history-entry">session history entry</a>, with</p>

    <dl class="props"><dt><a href="#she-url" id="the-javascript:-url-special-case:she-url">URL</a></dt><dd><var>entryToReplace</var>'s <a href="#she-url" id="the-javascript:-url-special-case:she-url-2">URL</a></dd><dt><a href="#she-document-state" id="the-javascript:-url-special-case:she-document-state-2">document state</a></dt><dd><var>documentState</var></dd></dl>

    <p class="note">For the <a href="#she-url" id="the-javascript:-url-special-case:she-url-3">URL</a>, we do <em>not</em> use
    <var>url</var>, i.e. the actual <code id="the-javascript:-url-special-case:the-javascript:-url-special-case-2"><a href="#the-javascript:-url-special-case">javascript:</a></code> URL that
    the <a href="#navigate" id="the-javascript:-url-special-case:navigate-2">navigate</a> algorithm was called with. This means <code id="the-javascript:-url-special-case:the-javascript:-url-special-case-3"><a href="#the-javascript:-url-special-case">javascript:</a></code> URLs are never stored in session history, and so can never be
    traversed to.</p>
   </li><li><p><a href="#tn-append-session-history-traversal-steps" id="the-javascript:-url-special-case:tn-append-session-history-traversal-steps">Append session history traversal
   steps</a> to <var>targetNavigable</var>'s <a href="#nav-traversable" id="the-javascript:-url-special-case:nav-traversable">traversable</a>
   to <a href="#finalize-a-cross-document-navigation" id="the-javascript:-url-special-case:finalize-a-cross-document-navigation">finalize a cross-document navigation</a> with <var>targetNavigable</var>,
   <var>historyHandling</var>, <var>userInvolvement</var>, and <var>historyEntry</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="evaluate-a-javascript:-url">evaluate a <code>javascript:</code> URL</dfn> given a <a href="#navigable" id="the-javascript:-url-special-case:navigable-2">navigable</a>
  <var>targetNavigable</var>, a <a id="the-javascript:-url-special-case:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, an <a href="#concept-origin" id="the-javascript:-url-special-case:concept-origin-2">origin</a>
  <var>newDocumentOrigin</var>, and a <a href="#user-navigation-involvement" id="the-javascript:-url-special-case:user-navigation-involvement-2">user navigation involvement</a>
  <var>userInvolvement</var>:</p>

  <ol><li><p>Let <var>urlString</var> be the result of running the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-javascript:-url-special-case:concept-url-serializer" data-x-internal="concept-url-serializer">URL serializer</a> on <var>url</var>.</p></li><li><p>Let <var>encodedScriptSource</var> be the result of removing the leading "<code>javascript:</code>" from <var>urlString</var>.</p></li><li><p>Let <var>scriptSource</var> be the <a href="https://encoding.spec.whatwg.org/#utf-8-decode" id="the-javascript:-url-special-case:utf-8-decode" data-x-internal="utf-8-decode">UTF-8 decoding</a> of
   the <a href="https://url.spec.whatwg.org/#string-percent-decode" id="the-javascript:-url-special-case:percent-decode" data-x-internal="percent-decode">percent-decoding</a> of
   <var>encodedScriptSource</var>.</p></li><li><p>Let <var>settings</var> be <var>targetNavigable</var>'s <a href="#nav-document" id="the-javascript:-url-special-case:nav-document-3">active document</a>'s <a href="#relevant-settings-object" id="the-javascript:-url-special-case:relevant-settings-object">relevant settings object</a>.</p></li><li><p>Let <var>baseURL</var> be <var>settings</var>'s <a href="#api-base-url" id="the-javascript:-url-special-case:api-base-url">API base URL</a>.</p></li><li><p>Let <var>script</var> be the result of <a href="#creating-a-classic-script" id="the-javascript:-url-special-case:creating-a-classic-script">creating a classic script</a> given
   <var>scriptSource</var>, <var>settings</var>, <var>baseURL</var>, and the <a href="#default-script-fetch-options" id="the-javascript:-url-special-case:default-script-fetch-options">default script
   fetch options</a>.</p></li><li><p>Let <var>evaluationStatus</var> be the result of <a href="#run-a-classic-script" id="the-javascript:-url-special-case:run-a-classic-script">running the classic script</a> <var>script</var>.</p></li><li><p>Let <var>result</var> be null.</p></li><li><p>If <var>evaluationStatus</var> is a normal completion, and
   <var>evaluationStatus</var>.[[Value]] is a String, then set <var>result</var> to
   <var>evaluationStatus</var>.[[Value]].</p></li><li><p>Otherwise, return null.</p></li><li>
    <p>Let <var>response</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-javascript:-url-special-case:concept-response" data-x-internal="concept-response">response</a> with</p>

    <dl class="props"><dt><a href="https://fetch.spec.whatwg.org/#concept-response-url" id="the-javascript:-url-special-case:concept-response-url" data-x-internal="concept-response-url">URL</a></dt><dd><var>targetNavigable</var>'s <a href="#nav-document" id="the-javascript:-url-special-case:nav-document-4">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-javascript:-url-special-case:the-document's-address" data-x-internal="the-document's-address">URL</a></dd><dt><a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="the-javascript:-url-special-case:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a></dt><dd>« (`<code id="the-javascript:-url-special-case:content-type"><a href="#content-type">Content-Type</a></code>`, `<code>text/html;charset=utf-8</code>`) »</dd><dt><a href="https://fetch.spec.whatwg.org/#concept-response-body" id="the-javascript:-url-special-case:concept-response-body" data-x-internal="concept-response-body">body</a></dt><dd>the <a href="https://encoding.spec.whatwg.org/#utf-8-encode" id="the-javascript:-url-special-case:utf-8-encode" data-x-internal="utf-8-encode">UTF-8 encoding</a> of <var>result</var>, <a id="the-javascript:-url-special-case:as-a-body" href="https://fetch.spec.whatwg.org/#byte-sequence-as-a-body" data-x-internal="as-a-body">as a
     body</a></dd></dl>

    <p class="note">The encoding to UTF-8 means that unpaired <a href="https://infra.spec.whatwg.org/#surrogate" id="the-javascript:-url-special-case:surrogate" data-x-internal="surrogate">surrogates</a> will not roundtrip, once the HTML parser decodes the
    response body.</p>
   </li><li><p>Let <var>policyContainer</var> be <var>targetNavigable</var>'s <a href="#nav-document" id="the-javascript:-url-special-case:nav-document-5">active document</a>'s <a href="#concept-document-policy-container" id="the-javascript:-url-special-case:concept-document-policy-container">policy container</a>.</p>

   </li><li><p>Let <var>finalSandboxFlags</var> be <var>policyContainer</var>'s <a href="#policy-container-csp-list" id="the-javascript:-url-special-case:policy-container-csp-list">CSP list</a>'s <a href="#csp-derived-sandboxing-flags" id="the-javascript:-url-special-case:csp-derived-sandboxing-flags">CSP-derived sandboxing
   flags</a>.</p></li><li><p>Let <var>coop</var> be <var>targetNavigable</var>'s <a href="#nav-document" id="the-javascript:-url-special-case:nav-document-6">active
   document</a>'s <a href="#concept-document-coop" id="the-javascript:-url-special-case:concept-document-coop">opener policy</a>.</p></li><li>
    <p>Let <var>coopEnforcementResult</var> be a new <a href="#coop-enforcement-result" id="the-javascript:-url-special-case:coop-enforcement-result">opener
    policy enforcement result</a> with</p>

    <dl class="props"><dt><a href="#coop-enforcement-url" id="the-javascript:-url-special-case:coop-enforcement-url">url</a></dt><dd><var>url</var></dd><dt><a href="#coop-enforcement-origin" id="the-javascript:-url-special-case:coop-enforcement-origin">origin</a></dt><dd><var>newDocumentOrigin</var></dd><dt><a href="#coop-enforcement-coop" id="the-javascript:-url-special-case:coop-enforcement-coop">opener policy</a></dt><dd><var>coop</var></dd></dl>
   </li><li>
    <p>Let <var>navigationParams</var> be a new <a href="#navigation-params" id="the-javascript:-url-special-case:navigation-params">navigation params</a>, with</p>

    <dl class="props"><dt><a href="#navigation-params-id" id="the-javascript:-url-special-case:navigation-params-id">id</a></dt><dd><var>navigationId</var></dd><dt><a href="#navigation-params-navigable" id="the-javascript:-url-special-case:navigation-params-navigable">navigable</a></dt><dd><var>targetNavigable</var></dd><dt><a href="#navigation-params-request" id="the-javascript:-url-special-case:navigation-params-request">request</a></dt><dd>null <span class="XXX">this will cause the referrer of the resulting <code id="the-javascript:-url-special-case:document-2"><a href="#document">Document</a></code>
     to be null; is that correct?</span></dd><dt><a href="#navigation-params-response" id="the-javascript:-url-special-case:navigation-params-response">response</a></dt><dd><var>response</var></dd><dt><a href="#navigation-params-fetch-controller" id="the-javascript:-url-special-case:navigation-params-fetch-controller">fetch controller</a></dt><dd>null</dd><dt><a href="#navigation-params-commit-early-hints" id="the-javascript:-url-special-case:navigation-params-commit-early-hints">commit early hints</a></dt><dd>null</dd><dt><a href="#navigation-params-coop-enforcement-result" id="the-javascript:-url-special-case:navigation-params-coop-enforcement-result">COOP enforcement result</a></dt><dd><var>coopEnforcementResult</var></dd><dt><a href="#navigation-params-reserved-environment" id="the-javascript:-url-special-case:navigation-params-reserved-environment">reserved environment</a></dt><dd>null</dd><dt><a href="#navigation-params-origin" id="the-javascript:-url-special-case:navigation-params-origin">origin</a></dt><dd><var>newDocumentOrigin</var></dd><dt><a href="#navigation-params-policy-container" id="the-javascript:-url-special-case:navigation-params-policy-container">policy container</a></dt><dd><var>policyContainer</var></dd><dt><a href="#navigation-params-sandboxing" id="the-javascript:-url-special-case:navigation-params-sandboxing">final sandboxing flag set</a></dt><dd><var>finalSandboxFlags</var></dd><dt><a href="#navigation-params-coop" id="the-javascript:-url-special-case:navigation-params-coop">opener policy</a></dt><dd><var>coop</var></dd><dt><a href="#navigation-params-nav-timing-type" id="the-javascript:-url-special-case:navigation-params-nav-timing-type">navigation timing type</a></dt><dd>"<code id="the-javascript:-url-special-case:dom-navigationtimingtype-navigate"><a data-x-internal="dom-navigationtimingtype-navigate" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype-navigate">navigate</a></code>"</dd><dt><a href="#navigation-params-about-base-url" id="the-javascript:-url-special-case:navigation-params-about-base-url">about base URL</a></dt><dd><var>targetNavigable</var>'s <a href="#nav-document" id="the-javascript:-url-special-case:nav-document-7">active document</a>'s <a href="#concept-document-about-base-url" id="the-javascript:-url-special-case:concept-document-about-base-url">about base URL</a></dd><dt><a href="#navigation-params-user-involvement" id="the-javascript:-url-special-case:navigation-params-user-involvement">user involvement</a></dt><dd><var>userInvolvement</var></dd></dl>
   </li><li><p>Return the result of <a href="#navigate-html" id="the-javascript:-url-special-case:navigate-html">loading an HTML document</a> given
   <var>navigationParams</var>.</p></li></ol>
  </div>


  <h6 id="scroll-to-fragid"><span class="secno">7.4.2.3.3</span> Fragment navigations<a href="#scroll-to-fragid" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>To <dfn id="navigate-fragid">navigate to a fragment</dfn> given a <a href="#navigable" id="scroll-to-fragid:navigable">navigable</a>
  <var>navigable</var>, a <a id="scroll-to-fragid:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, a <a href="#history-handling-behavior" id="scroll-to-fragid:history-handling-behavior">history handling behavior</a>
  <var>historyHandling</var>, a <a href="#user-navigation-involvement" id="scroll-to-fragid:user-navigation-involvement">user navigation involvement</a> <var>userInvolvement</var>,
  an <code id="scroll-to-fragid:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>-or-null <var>sourceElement</var>, a <a href="#serialized-state" id="scroll-to-fragid:serialized-state">serialized state</a>-or-null
  <var>navigationAPIState</var>, and a <a href="#navigation-id" id="scroll-to-fragid:navigation-id">navigation ID</a> <var>navigationId</var>:</p>

  <ol><li><p>Let <var>navigation</var> be <var>navigable</var>'s <a href="#nav-window" id="scroll-to-fragid:nav-window">active
   window</a>'s <a href="#window-navigation-api" id="scroll-to-fragid:window-navigation-api">navigation API</a>.</p></li><li><p>Let <var>destinationNavigationAPIState</var> be <var>navigable</var>'s <a href="#nav-active-history-entry" id="scroll-to-fragid:nav-active-history-entry">active session history entry</a>'s <a href="#she-navigation-api-state" id="scroll-to-fragid:she-navigation-api-state">navigation API state</a>.</p></li><li><p>If <var>navigationAPIState</var> is not null, then set
   <var>destinationNavigationAPIState</var> to <var>navigationAPIState</var>.</p></li><li><p>Let <var>continue</var> be the result of <a href="#fire-a-push/replace/reload-navigate-event" id="scroll-to-fragid:fire-a-push/replace/reload-navigate-event">firing a push/replace/reload <code>navigate</code> event</a> at
   <var>navigation</var> with <i id="scroll-to-fragid:fire-navigate-prr-navigationtype"><a href="#fire-navigate-prr-navigationtype">navigationType</a></i> set to
   <var>historyHandling</var>, <i id="scroll-to-fragid:fire-navigate-prr-issamedocument"><a href="#fire-navigate-prr-issamedocument">isSameDocument</a></i> set
   to true, <i id="scroll-to-fragid:fire-navigate-prr-userinvolvement"><a href="#fire-navigate-prr-userinvolvement">userInvolvement</a></i> set to
   <var>userInvolvement</var>, <i id="scroll-to-fragid:fire-navigate-prr-sourceelement"><a href="#fire-navigate-prr-sourceelement">sourceElement</a></i> set
   to <var>sourceElement</var>, <i id="scroll-to-fragid:fire-navigate-prr-destinationurl"><a href="#fire-navigate-prr-destinationurl">destinationURL</a></i>
   set to <var>url</var>, and <i id="scroll-to-fragid:fire-navigate-prr-navigationapistate"><a href="#fire-navigate-prr-navigationapistate">navigationAPIState</a></i> set to
   <var>destinationNavigationAPIState</var>.</p></li><li><p>If <var>continue</var> is false, then return.</p>

   </li><li>
    <p>Let <var>historyEntry</var> be a new <a href="#session-history-entry" id="scroll-to-fragid:session-history-entry">session history entry</a>, with</p>

    <dl class="props"><dt><a href="#she-url" id="scroll-to-fragid:she-url">URL</a></dt><dd><var>url</var></dd><dt><a href="#she-document-state" id="scroll-to-fragid:she-document-state">document state</a></dt><dd><var>navigable</var>'s <a href="#nav-active-history-entry" id="scroll-to-fragid:nav-active-history-entry-2">active session history
     entry</a>'s <a href="#she-document-state" id="scroll-to-fragid:she-document-state-2">document state</a></dd><dt><a href="#she-navigation-api-state" id="scroll-to-fragid:she-navigation-api-state-2">navigation API state</a></dt><dd><var>destinationNavigationAPIState</var></dd><dt><a href="#she-scroll-restoration-mode" id="scroll-to-fragid:she-scroll-restoration-mode">scroll restoration mode</a></dt><dd><var>navigable</var>'s <a href="#nav-active-history-entry" id="scroll-to-fragid:nav-active-history-entry-3">active session history
     entry</a>'s <a href="#she-scroll-restoration-mode" id="scroll-to-fragid:she-scroll-restoration-mode-2">scroll restoration mode</a></dd></dl>

    <div class="note">
     <p>For navigations performed with <code id="scroll-to-fragid:dom-navigation-navigate"><a href="#dom-navigation-navigate">navigation.navigate()</a></code>, the value provided by the <code id="scroll-to-fragid:dom-navigationnavigateoptions-state"><a href="#dom-navigationnavigateoptions-state">state</a></code> option is used for the new <a href="#she-navigation-api-state" id="scroll-to-fragid:she-navigation-api-state-3">navigation API state</a>. (This will set it to the
     serialization of undefined, if no value is provided for that option.) For other fragment
     navigations, including user-initiated ones, the <a href="#she-navigation-api-state" id="scroll-to-fragid:she-navigation-api-state-4">navigation API state</a> is carried over from the previous
     entry.</p>

     <p>The <a href="#she-classic-history-api-state" id="scroll-to-fragid:she-classic-history-api-state">classic history API state</a> is never
     carried over.</p>
    </div>
   </li><li><p>Let <var>entryToReplace</var> be <var>navigable</var>'s <a href="#nav-active-history-entry" id="scroll-to-fragid:nav-active-history-entry-4">active session history entry</a> if
   <var>historyHandling</var> is "<code id="scroll-to-fragid:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>",
   otherwise null.</p></li><li><p>Let <var>history</var> be <var>navigable</var>'s <a href="#nav-document" id="scroll-to-fragid:nav-document">active
   document</a>'s <a href="#doc-history" id="scroll-to-fragid:doc-history">history object</a>.</p></li><li><p>Let <var>scriptHistoryIndex</var> be <var>history</var>'s <a href="#concept-history-index" id="scroll-to-fragid:concept-history-index">index</a>.</p></li><li><p>Let <var>scriptHistoryLength</var> be <var>history</var>'s <a href="#concept-history-length" id="scroll-to-fragid:concept-history-length">length</a>.</p></li><li>
    <p>If <var>historyHandling</var> is "<code id="scroll-to-fragid:navigationhistorybehavior-push"><a href="#navigationhistorybehavior-push">push</a></code>",
    then:</p>

    <ol><li><p>Set <var>history</var>'s <a href="#concept-history-state" id="scroll-to-fragid:concept-history-state">state</a> to
     null.</p></li><li><p>Increment <var>scriptHistoryIndex</var>.</p></li><li><p>Set <var>scriptHistoryLength</var> to <var>scriptHistoryIndex</var> + 1.</p></li></ol>
   </li><li><p>Set <var>navigable</var>'s <a href="#nav-document" id="scroll-to-fragid:nav-document-2">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="scroll-to-fragid:the-document's-address" data-x-internal="the-document's-address">URL</a> to <var>url</var>.</p></li><li><p>Set <var>navigable</var>'s <a href="#nav-active-history-entry" id="scroll-to-fragid:nav-active-history-entry-5">active session history
   entry</a> to <var>historyEntry</var>.</p></li><li>
    <p><a href="#update-document-for-history-step-application" id="scroll-to-fragid:update-document-for-history-step-application">Update document for history step application</a> given <var>navigable</var>'s
    <a href="#nav-document" id="scroll-to-fragid:nav-document-3">active document</a>, <var>historyEntry</var>, true,
    <var>scriptHistoryIndex</var>, <var>scriptHistoryLength</var>, and
    <var>historyHandling</var>.</p>

    <p class="note">This algorithm will be called twice as a result of a single fragment
    navigation: once synchronously, where best-guess values <var>scriptHistoryIndex</var> and
    <var>scriptHistoryLength</var> are set, <code id="scroll-to-fragid:dom-history-state"><a href="#dom-history-state">history.state</a></code>
    is nulled out, and various events are fired; and once asynchronously, where the final values for
    index and length are set, <code id="scroll-to-fragid:dom-history-state-2"><a href="#dom-history-state">history.state</a></code> remains
    untouched, and no events are fired.</p>
   </li><li>
    <p><a href="#scroll-to-the-fragment-identifier" id="scroll-to-fragid:scroll-to-the-fragment-identifier">Scroll to the fragment</a> given <var>navigable</var>'s <a href="#nav-document" id="scroll-to-fragid:nav-document-4">active document</a>.</p>

    <p class="note">If the scrolling fails because the <code id="scroll-to-fragid:document"><a href="#document">Document</a></code> is new and the
    relevant <a href="https://dom.spec.whatwg.org/#concept-id" id="scroll-to-fragid:concept-id" data-x-internal="concept-id">ID</a> has not yet been parsed, then the second
    asynchronous call to <a href="#update-document-for-history-step-application" id="scroll-to-fragid:update-document-for-history-step-application-2">update document for history step application</a> will take
    care of scrolling.</p>
   </li><li><p>Let <var>traversable</var> be <var>navigable</var>'s <a href="#nav-traversable" id="scroll-to-fragid:nav-traversable">traversable navigable</a>.</p></li><li>
    <p><a href="#tn-append-session-history-sync-nav-steps" id="scroll-to-fragid:tn-append-session-history-sync-nav-steps">Append the following session history
    synchronous navigation steps</a> involving <var>navigable</var> to
    <var>traversable</var>:</p>

    <ol><li><p><a href="#finalize-a-same-document-navigation" id="scroll-to-fragid:finalize-a-same-document-navigation">Finalize a same-document navigation</a> given <var>traversable</var>,
     <var>navigable</var>, <var>historyEntry</var>, <var>entryToReplace</var>,
     <var>historyHandling</var>, and <var>userInvolvement</var>.</p></li><li><p>Invoke <a id="scroll-to-fragid:webdriver-bidi-fragment-navigated" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-fragment-navigated" data-x-internal="webdriver-bidi-fragment-navigated">WebDriver BiDi fragment navigated</a> with <var>navigable</var> and a
     new <a id="scroll-to-fragid:webdriver-bidi-navigation-status" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="scroll-to-fragid:navigation-status-id" data-x-internal="navigation-status-id">id</a> is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="scroll-to-fragid:navigation-status-url" data-x-internal="navigation-status-url">url</a> is <var>url</var>, and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="scroll-to-fragid:navigation-status-status" data-x-internal="navigation-status-status">status</a> is "<code id="scroll-to-fragid:navigation-status-complete"><a data-x-internal="navigation-status-complete" href="https://w3c.github.io/webdriver-bidi/#navigation-status-complete">complete</a></code>".</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="finalize-a-same-document-navigation">finalize a same-document navigation</dfn> given a <a href="#traversable-navigable" id="scroll-to-fragid:traversable-navigable">traversable navigable</a>
  <var>traversable</var>, a <a href="#navigable" id="scroll-to-fragid:navigable-2">navigable</a> <var>targetNavigable</var>, a <a href="#session-history-entry" id="scroll-to-fragid:session-history-entry-2">session
  history entry</a> <var>targetEntry</var>, a <a href="#session-history-entry" id="scroll-to-fragid:session-history-entry-3">session history entry</a>-or-null
  <var>entryToReplace</var>, a <a href="#history-handling-behavior" id="scroll-to-fragid:history-handling-behavior-2">history handling behavior</a> <var>historyHandling</var>,
  and a <a href="#user-navigation-involvement" id="scroll-to-fragid:user-navigation-involvement-2">user navigation involvement</a> <var>userInvolvement</var>:</p>

  <p class="note">This is used by both <a href="#navigate-fragid" id="scroll-to-fragid:navigate-fragid">fragment navigations</a>
  and by the <a href="#url-and-history-update-steps" id="scroll-to-fragid:url-and-history-update-steps">URL and history update steps</a>, which are the only synchronous updates to
  session history. By virtue of being synchronous, those algorithms are performed outside of the
  <a href="#top-level-traversable" id="scroll-to-fragid:top-level-traversable">top-level traversable</a>'s <a href="#tn-session-history-traversal-queue" id="scroll-to-fragid:tn-session-history-traversal-queue">session
  history traversal queue</a>. This puts them out of sync with the <a href="#top-level-traversable" id="scroll-to-fragid:top-level-traversable-2">top-level
  traversable</a>'s <a href="#tn-current-session-history-step" id="scroll-to-fragid:tn-current-session-history-step">current session history
  step</a>, so this algorithm is used to resolve conflicts due to race conditions.</p>

  <ol><li><p><a id="scroll-to-fragid:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running on <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="scroll-to-fragid:tn-session-history-traversal-queue-2">session history traversal queue</a>.</p></li><li><p>If <var>targetNavigable</var>'s <a href="#nav-active-history-entry" id="scroll-to-fragid:nav-active-history-entry-6">active session
   history entry</a> is not <var>targetEntry</var>, then return.</p></li><li><p>Let <var>targetStep</var> be null.</p></li><li><p>Let <var>targetEntries</var> be the result of <a href="#getting-session-history-entries" id="scroll-to-fragid:getting-session-history-entries">getting session history
   entries</a> for <var>targetNavigable</var>.</p></li><li>
    <p>If <var>entryToReplace</var> is null, then:</p>

    <ol><li><p><a href="#clear-the-forward-session-history" id="scroll-to-fragid:clear-the-forward-session-history">Clear the forward session history</a> of <var>traversable</var>.</p></li><li><p>Set <var>targetStep</var> to <var>traversable</var>'s <a href="#tn-current-session-history-step" id="scroll-to-fragid:tn-current-session-history-step-2">current session history step</a> + 1.</p></li><li><p>Set <var>targetEntry</var>'s <a href="#she-step" id="scroll-to-fragid:she-step">step</a> to
     <var>targetStep</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="scroll-to-fragid:list-append" data-x-internal="list-append">Append</a> <var>targetEntry</var> to
     <var>targetEntries</var>.</p></li></ol>

    <p>Otherwise:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-replace" id="scroll-to-fragid:list-replace" data-x-internal="list-replace">Replace</a> <var>entryToReplace</var> with
     <var>targetEntry</var> in <var>targetEntries</var>.</p></li><li><p>Set <var>targetEntry</var>'s <a href="#she-step" id="scroll-to-fragid:she-step-2">step</a> to
     <var>entryToReplace</var>'s <a href="#she-step" id="scroll-to-fragid:she-step-3">step</a>.</p></li><li><p>Set <var>targetStep</var> to <var>traversable</var>'s <a href="#tn-current-session-history-step" id="scroll-to-fragid:tn-current-session-history-step-3">current session history step</a>.</p></li></ol>
   </li><li>
    <p><a href="#apply-the-push/replace-history-step" id="scroll-to-fragid:apply-the-push/replace-history-step">Apply the push/replace history step</a> <var>targetStep</var> to
    <var>traversable</var> given <var>historyHandling</var> and <var>userInvolvement</var>.</p>

    <p class="note">This is done even for "<code id="scroll-to-fragid:navigationhistorybehavior-replace-2"><a href="#navigationhistorybehavior-replace">replace</a></code>" navigations, as it resolves race
    conditions across multiple synchronous navigations.</p>
   </li></ol>
  </div>


  <h6 id="non-fetch-schemes-and-external-software"><span class="secno">7.4.2.3.4</span> Non-fetch schemes and external software<a href="#non-fetch-schemes-and-external-software" class="self-link"></a></h6>

  <p>The input to <a href="#attempt-to-create-a-non-fetch-scheme-document" id="non-fetch-schemes-and-external-software:attempt-to-create-a-non-fetch-scheme-document">attempt to create a non-fetch scheme document</a> is the <dfn id="non-fetch-scheme-navigation-params">non-fetch
  scheme navigation params</dfn> <a id="non-fetch-schemes-and-external-software:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a>. It is a lightweight version of
  <a href="#navigation-params" id="non-fetch-schemes-and-external-software:navigation-params">navigation params</a> which only carries parameters relevant to the non-<a id="non-fetch-schemes-and-external-software:fetch-scheme" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch
  scheme</a> navigation case. It has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="non-fetch-schemes-and-external-software:struct-item" data-x-internal="struct-item">items</a>:</p>

  
  <dl><dt><dfn id="non-fetch-scheme-params-id">id</dfn></dt><dd>null or a <a href="#navigation-id" id="non-fetch-schemes-and-external-software:navigation-id">navigation ID</a></dd><dt><dfn id="non-fetch-scheme-params-navigable">navigable</dfn></dt><dd>the <a href="#navigable" id="non-fetch-schemes-and-external-software:navigable">navigable</a> experiencing the navigation</dd><dt><dfn id="non-fetch-scheme-params-url">URL</dfn></dt><dd>a <a id="non-fetch-schemes-and-external-software:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a></dd><dt><dfn id="non-fetch-scheme-params-target-sandbox">target snapshot sandboxing flags</dfn></dt><dd>the <a href="#target-snapshot-params" id="non-fetch-schemes-and-external-software:target-snapshot-params">target snapshot params</a>'s <a href="#target-snapshot-params-sandbox" id="non-fetch-schemes-and-external-software:target-snapshot-params-sandbox">sandboxing flags</a> present during navigation</dd><dt><dfn id="non-fetch-scheme-params-source-activation">source snapshot has transient activation</dfn></dt><dd>a copy of the <a href="#source-snapshot-params" id="non-fetch-schemes-and-external-software:source-snapshot-params">source snapshot params</a>'s <a href="#source-snapshot-params-activation" id="non-fetch-schemes-and-external-software:source-snapshot-params-activation">has transient activation</a> boolean present during
   activation</dd><dt><dfn id="non-fetch-scheme-params-initiator-origin">initiator origin</dfn></dt><dd>
    <p>an <a href="#concept-origin" id="non-fetch-schemes-and-external-software:concept-origin">origin</a> possibly for use in a user-facing prompt to confirm the invocation of
    an external software package</p>
    <p class="note">This differs slightly from a <a href="#she-document-state" id="non-fetch-schemes-and-external-software:she-document-state">document
    state</a>'s <a href="#document-state-initiator-origin" id="non-fetch-schemes-and-external-software:document-state-initiator-origin">initiator origin</a> in that a
    <a href="#non-fetch-scheme-navigation-params" id="non-fetch-schemes-and-external-software:non-fetch-scheme-navigation-params">non-fetch scheme navigation params</a>'s <a href="#non-fetch-scheme-params-initiator-origin" id="non-fetch-schemes-and-external-software:non-fetch-scheme-params-initiator-origin">initiator origin</a> follows redirects up
    to the last <a id="non-fetch-schemes-and-external-software:fetch-scheme-2" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a> URL in a redirect chain that ends in a non-<a id="non-fetch-schemes-and-external-software:fetch-scheme-3" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch
    scheme</a> URL.</p>
   </dd><dt><dfn id="non-fetch-scheme-params-nav-timing-type">navigation timing type</dfn></dt><dd>a <code id="non-fetch-schemes-and-external-software:navigationtimingtype"><a data-x-internal="navigationtimingtype" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype">NavigationTimingType</a></code> used for <a href="https://w3c.github.io/navigation-timing/#dfn-create-the-navigation-timing-entry" id="non-fetch-schemes-and-external-software:create-the-navigation-timing-entry" data-x-internal="create-the-navigation-timing-entry">creating the navigation timing entry</a> for the new <code id="non-fetch-schemes-and-external-software:document"><a href="#document">Document</a></code> (if one is
   created)</dd><dt><dfn id="non-fetch-scheme-params-user-involvement">user involvement</dfn></dt><dd>a <a href="#user-navigation-involvement" id="non-fetch-schemes-and-external-software:user-navigation-involvement">user navigation involvement</a> used when <a href="#obtain-browsing-context-navigation" id="non-fetch-schemes-and-external-software:obtain-browsing-context-navigation">obtaining a browsing context</a> for the new
   <code id="non-fetch-schemes-and-external-software:document-2"><a href="#document">Document</a></code> (if one is created)</dd></dl>

  <div data-algorithm="">
  <p id="process-a-navigate-url-scheme">To <dfn id="attempt-to-create-a-non-fetch-scheme-document">attempt to create a non-fetch scheme document</dfn>,
  given a <a href="#non-fetch-scheme-navigation-params" id="non-fetch-schemes-and-external-software:non-fetch-scheme-navigation-params-2">non-fetch scheme navigation params</a> <var>navigationParams</var>:</p>

  <ol><li>Let <var>url</var> be <var>navigationParams</var>'s <a href="#non-fetch-scheme-params-url" id="non-fetch-schemes-and-external-software:non-fetch-scheme-params-url">URL</a>.</li><li>Let <var>navigable</var> be <var>navigationParams</var>'s <a href="#non-fetch-scheme-params-navigable" id="non-fetch-schemes-and-external-software:non-fetch-scheme-params-navigable">navigable</a>.</li><li>
    <p>If <var>url</var> is to be handled using a mechanism that does not affect
    <var>navigable</var>, e.g., because <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="non-fetch-schemes-and-external-software:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is handled externally, then:</p>

    <ol><li><p><a href="#hand-off-to-external-software" id="non-fetch-schemes-and-external-software:hand-off-to-external-software">Hand-off to external software</a> given <var>url</var>, <var>navigable</var>,
     <var>navigationParams</var>'s <a href="#non-fetch-scheme-params-target-sandbox" id="non-fetch-schemes-and-external-software:non-fetch-scheme-params-target-sandbox">target
     snapshot sandboxing flags</a>, <var>navigationParams</var>'s <a href="#non-fetch-scheme-params-source-activation" id="non-fetch-schemes-and-external-software:non-fetch-scheme-params-source-activation">source snapshot has transient
     activation</a>, and <var>navigationParams</var>'s <a href="#non-fetch-scheme-params-initiator-origin" id="non-fetch-schemes-and-external-software:non-fetch-scheme-params-initiator-origin-2">initiator origin</a>.</p></li><li><p>Return null.</p></li></ol>
   </li><li>
    <p>Handle <var>url</var> by displaying some sort of inline content, e.g., an error message
    because the specified scheme is not one of the supported protocols, or an inline prompt to allow
    the user to select <a href="#dom-navigator-registerprotocolhandler" id="non-fetch-schemes-and-external-software:dom-navigator-registerprotocolhandler">a registered
    handler</a> for the given scheme. Return the result of <a href="#navigate-ua-inline" id="non-fetch-schemes-and-external-software:navigate-ua-inline">displaying the inline content</a> given <var>navigable</var>,
    <var>navigationParams</var>'s <a href="#non-fetch-scheme-params-id" id="non-fetch-schemes-and-external-software:non-fetch-scheme-params-id">id</a>,
    <var>navigationParams</var>'s <a href="#non-fetch-scheme-params-nav-timing-type" id="non-fetch-schemes-and-external-software:non-fetch-scheme-params-nav-timing-type">navigation
    timing type</a>, and <var>navigationParams</var>'s <a href="#non-fetch-scheme-params-user-involvement" id="non-fetch-schemes-and-external-software:non-fetch-scheme-params-user-involvement">user involvement</a>.</p>

    <p class="note">In the case of a registered handler being used, <a href="#navigate" id="non-fetch-schemes-and-external-software:navigate">navigate</a> will be
    invoked with a new URL.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="hand-off-to-external-software">hand-off to external software</dfn> given a <a id="non-fetch-schemes-and-external-software:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> or <a href="https://fetch.spec.whatwg.org/#concept-response" id="non-fetch-schemes-and-external-software:concept-response" data-x-internal="concept-response">response</a> <var>resource</var>, a <a href="#navigable" id="non-fetch-schemes-and-external-software:navigable-2">navigable</a>
  <var>navigable</var>, a <a href="#sandboxing-flag-set" id="non-fetch-schemes-and-external-software:sandboxing-flag-set">sandboxing flag set</a> <var>sandboxFlags</var>, a boolean
  <var>hasTransientActivation</var>, and an <a href="#concept-origin" id="non-fetch-schemes-and-external-software:concept-origin-2">origin</a> <var>initiatorOrigin</var>, user
  agents should:</p>

  <ol><li>
    <p>If all of the following are true:</p>

    <ul><li><p><var>navigable</var> is not a <a href="#top-level-traversable" id="non-fetch-schemes-and-external-software:top-level-traversable">top-level traversable</a>;</p></li><li><p><var>sandboxFlags</var> has its <a href="#sandboxed-custom-protocols-navigation-browsing-context-flag" id="non-fetch-schemes-and-external-software:sandboxed-custom-protocols-navigation-browsing-context-flag">sandboxed custom protocols navigation browsing
     context flag</a> set; and</p></li><li><p><var>sandboxFlags</var> has its <a href="#sandboxed-top-level-navigation-with-user-activation-browsing-context-flag" id="non-fetch-schemes-and-external-software:sandboxed-top-level-navigation-with-user-activation-browsing-context-flag">sandboxed top-level navigation with user
     activation browsing context flag</a> set, or <var>hasTransientActivation</var> is
     false,</p></li></ul>

    <p>then return without invoking the external software package.</p>

    <p class="note">Navigation inside an iframe toward external software can be seen by users as a
    new popup or a new top-level navigation. That's why its is allowed in sandboxed
    <code id="non-fetch-schemes-and-external-software:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> only when one of <code id="non-fetch-schemes-and-external-software:attr-iframe-sandbox-allow-popups"><a href="#attr-iframe-sandbox-allow-popups">allow-popups</a></code>, <code id="non-fetch-schemes-and-external-software:attr-iframe-sandbox-allow-top-navigation"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code>, <code id="non-fetch-schemes-and-external-software:attr-iframe-sandbox-allow-top-navigation-by-user-activation"><a href="#attr-iframe-sandbox-allow-top-navigation-by-user-activation">allow-top-navigation-by-user-activation</a></code>,
    or <code id="non-fetch-schemes-and-external-software:attr-iframe-sandbox-allow-top-navigation-to-custom-protocols"><a href="#attr-iframe-sandbox-allow-top-navigation-to-custom-protocols">allow-top-navigation-to-custom-protocols</a></code>
    is specified.</p>
   </li><li>
    <p>Perform the appropriate handoff of <var>resource</var> while attempting to mitigate the risk
    that this is an attempt to exploit the target software. For example, user agents could prompt
    the user to confirm that <var>initiatorOrigin</var> is to be allowed to invoke the external
    software in question. In particular, if <var>hasTransientActivation</var> is false, then the
    user agent should not invoke the external software package without prior user confirmation.</p>

    <p class="example">For example, there could be a vulnerability in the target software's URL
    handler which a hostile page would attempt to exploit by tricking a user into clicking a
    link.</p>
   </li></ol>
  </div>


  <h5 id="preventing-navigation"><span class="secno">7.4.2.4</span> Preventing navigation<a href="#preventing-navigation" class="self-link"></a></h5>

  <p>A couple of scenarios can intervene early in the navigation process and put the whole thing to
  a halt. This can be especially exciting when multiple <a href="#navigable" id="preventing-navigation:navigable">navigables</a>
  are navigating at the same time, due to a session history traversal.</p>

  <div data-algorithm="">
  <p>A <a href="#navigable" id="preventing-navigation:navigable-2">navigable</a> <var>source</var> is <dfn id="allowed-to-navigate">allowed by
  sandboxing to navigate</dfn> a second <a href="#navigable" id="preventing-navigation:navigable-3">navigable</a> <var>target</var>, given a
  <a href="#source-snapshot-params" id="preventing-navigation:source-snapshot-params">source snapshot params</a> <var>sourceSnapshotParams</var>, if the following steps
  return true:</p>

  <ol><li><p>If <var>source</var> is <var>target</var>, then return true.</p></li><li><p>If <var>source</var> is an ancestor of <var>target</var>, then return true.</p></li><li>
    <p>If <var>target</var> is an ancestor of <var>source</var>, then:</p>

    <ol><li><p>If <var>target</var> is not a <a href="#top-level-traversable" id="preventing-navigation:top-level-traversable">top-level traversable</a>, then return
     true.</p></li><li><p>If <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-activation" id="preventing-navigation:source-snapshot-params-activation">has transient activation</a> is true, and
     <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-sandbox" id="preventing-navigation:source-snapshot-params-sandbox">sandboxing
     flags</a>'s <a href="#sandboxed-top-level-navigation-with-user-activation-browsing-context-flag" id="preventing-navigation:sandboxed-top-level-navigation-with-user-activation-browsing-context-flag">sandboxed top-level navigation with user activation browsing context
     flag</a> is set, then return false.</p></li><li><p>If <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-activation" id="preventing-navigation:source-snapshot-params-activation-2">has transient activation</a> is false, and
     <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-sandbox" id="preventing-navigation:source-snapshot-params-sandbox-2">sandboxing
     flags</a>'s <a href="#sandboxed-top-level-navigation-without-user-activation-browsing-context-flag" id="preventing-navigation:sandboxed-top-level-navigation-without-user-activation-browsing-context-flag">sandboxed top-level navigation without user activation browsing context
     flag</a> is set, then return false.</p></li><li><p>Return true.</p></li></ol>
   </li><li>
    <p>If <var>target</var> is a <a href="#top-level-traversable" id="preventing-navigation:top-level-traversable-2">top-level traversable</a>:</p>

    <ol><li><p>If <var>source</var> is the <a href="#one-permitted-sandboxed-navigator" id="preventing-navigation:one-permitted-sandboxed-navigator">one permitted sandboxed navigator</a> of
     <var>target</var>, then return true.</p></li><li><p>If <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-sandbox" id="preventing-navigation:source-snapshot-params-sandbox-3">sandboxing flags</a>'s <a href="#sandboxed-navigation-browsing-context-flag" id="preventing-navigation:sandboxed-navigation-browsing-context-flag">sandboxed navigation
     browsing context flag</a> is set, then return false.</p></li><li><p>Return true.</p></li></ol>
   </li><li><p>If <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-sandbox" id="preventing-navigation:source-snapshot-params-sandbox-4">sandboxing flags</a>'s <a href="#sandboxed-navigation-browsing-context-flag" id="preventing-navigation:sandboxed-navigation-browsing-context-flag-2">sandboxed navigation
   browsing context flag</a> is set, then return false.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="prompt-to-unload-a-document"><span id="prompt-to-unload"></span><span id="checking-if-unloading-is-user-canceled"></span>To <dfn id="checking-if-unloading-is-canceled">check if unloading is canceled</dfn> for a <a id="preventing-navigation:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#navigable" id="preventing-navigation:navigable-4">navigables</a> <var>navigablesThatNeedBeforeUnload</var>, given an optional
  <a href="#traversable-navigable" id="preventing-navigation:traversable-navigable">traversable navigable</a> <var>traversable</var>, an optional integer
  <var>targetStep</var>, and an optional <a href="#user-navigation-involvement" id="preventing-navigation:user-navigation-involvement">user navigation involvement</a>
  <var>userInvolvementForNavigateEvent</var>, run these steps. They return "<code>canceled-by-beforeunload</code>", "<code>canceled-by-navigate</code>", or
  "<code>continue</code>".</p>

  <ol><li><p>Let <var>documentsToFireBeforeunload</var> be the <a href="#nav-document" id="preventing-navigation:nav-document">active
   document</a> of each <a href="https://infra.spec.whatwg.org/#list-item" id="preventing-navigation:list-item" data-x-internal="list-item">item</a> in
   <var>navigablesThatNeedBeforeUnload</var>.</p></li><li><p>Let <var>unloadPromptShown</var> be false.</p></li><li><p>Let <var>finalStatus</var> be "<code>continue</code>".</p></li><li>
    <p>If <var>traversable</var> was given, then:</p>

    <ol><li><p><a id="preventing-navigation:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>targetStep</var> and
     <var>userInvolvementForNavigateEvent</var> were given.</p></li><li><p>Let <var>targetEntry</var> be the result of <a href="#getting-the-target-history-entry" id="preventing-navigation:getting-the-target-history-entry">getting the target history
     entry</a> given <var>traversable</var> and <var>targetStep</var>.</p></li><li>
      <p>If <var>targetEntry</var> is not <var>traversable</var>'s <a href="#nav-current-history-entry" id="preventing-navigation:nav-current-history-entry">current session history entry</a>, and
      <var>targetEntry</var>'s <a href="#she-document-state" id="preventing-navigation:she-document-state">document state</a>'s <a href="#document-state-origin" id="preventing-navigation:document-state-origin">origin</a> is the <a href="#same-origin" id="preventing-navigation:same-origin">same</a> as
      <var>traversable</var>'s <a href="#nav-current-history-entry" id="preventing-navigation:nav-current-history-entry-2">current session history
      entry</a>'s <a href="#she-document-state" id="preventing-navigation:she-document-state-2">document state</a>'s <a href="#document-state-origin" id="preventing-navigation:document-state-origin-2">origin</a>, then:</p>

      <div class="note">
       <p>In this case, we're going to fire the <code id="preventing-navigation:event-navigate"><a href="#event-navigate">navigate</a></code> event
       for <var>traversable</var> here. Because <a href="#navigate-event-traverse-can-be-canceled">under some circumstances</a> it might be
       canceled, we need to do this separately from <a href="#descendant-navigable-traversal-navigate-events">other traversal <code>navigate</code> events</a>, which happen later.</p>

       <p>Additionally, because we want <code id="preventing-navigation:event-beforeunload"><a href="#event-beforeunload">beforeunload</a></code> events
       to fire before <code id="preventing-navigation:event-navigate-2"><a href="#event-navigate">navigate</a></code> events, this means we need to
       fire <code id="preventing-navigation:event-beforeunload-2"><a href="#event-beforeunload">beforeunload</a></code> for <var>traversable</var> here
       (if applicable), instead of doing it as part of the below loop over
       <var>documentsToFireBeforeunload</var>.</p>
      </div>

      <ol><li><p>Let <var>eventsFired</var> be false.</p></li><li><p>Let <var>needsBeforeunload</var> be true if <var>navigablesThatNeedBeforeUnload</var>
       <a href="https://infra.spec.whatwg.org/#list-contain" id="preventing-navigation:list-contains" data-x-internal="list-contains">contains</a> <var>traversable</var>; otherwise
       false.</p></li><li><p>If <var>needsBeforeunload</var> is true, then <a href="https://infra.spec.whatwg.org/#list-remove" id="preventing-navigation:list-remove" data-x-internal="list-remove">remove</a>
       <var>traversable</var>'s <a href="#nav-document" id="preventing-navigation:nav-document-2">active document</a> from
       <var>documentsToFireBeforeunload</var>.</p></li><li>
        <p><a href="#queue-a-global-task" id="preventing-navigation:queue-a-global-task">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="preventing-navigation:navigation-and-traversal-task-source">navigation and traversal task source</a>
        given <var>traversable</var>'s <a href="#nav-window" id="preventing-navigation:nav-window">active window</a> to perform the
        following steps:</p>

        <ol><li>
          <p>If <var>needsBeforeunload</var> is true, then:</p>

          <ol><li><p>Let (<var>unloadPromptShownForThisDocument</var>,
           <var>unloadPromptCanceledByThisDocument</var>) be the result of running the <a href="#steps-to-fire-beforeunload" id="preventing-navigation:steps-to-fire-beforeunload">steps
           to fire <code>beforeunload</code></a> given
           <var>traversable</var>'s <a href="#nav-document" id="preventing-navigation:nav-document-3">active document</a> and
           false.</p></li><li><p>If <var>unloadPromptShownForThisDocument</var> is true, then set
           <var>unloadPromptShown</var> to true.</p></li><li><p>If <var>unloadPromptCanceledByThisDocument</var> is true, then set
           <var>finalStatus</var> to "<code>canceled-by-beforeunload</code>".</p></li></ol>
         </li><li><p>If <var>finalStatus</var> is "<code>canceled-by-beforeunload</code>", then
         abort these steps.</p></li><li><p>Let <var>navigation</var> be <var>traversable</var>'s <a href="#nav-window" id="preventing-navigation:nav-window-2">active window</a>'s <a href="#window-navigation-api" id="preventing-navigation:window-navigation-api">navigation
         API</a>.</p></li><li><p>Let <var>navigateEventResult</var> be the result of <a href="#fire-a-traverse-navigate-event" id="preventing-navigation:fire-a-traverse-navigate-event">firing a traverse <code>navigate</code>
         event</a> at <var>navigation</var> given <var>targetEntry</var> and
         <var>userInvolvementForNavigateEvent</var>.</p></li><li><p>If <var>navigateEventResult</var> is false, then set <var>finalStatus</var> to
         "<code>canceled-by-navigate</code>".</p></li><li><p>Set <var>eventsFired</var> to true.</p></li></ol>
       </li><li><p>Wait until <var>eventsFired</var> is true.</p></li><li><p>If <var>finalStatus</var> is not "<code>continue</code>", then return
       <var>finalStatus</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Let <var>totalTasks</var> be the <a href="https://infra.spec.whatwg.org/#list-size" id="preventing-navigation:list-size" data-x-internal="list-size">size</a> of
   <var>documentsToFireBeforeunload</var>.</p></li><li><p>Let <var>completedTasks</var> be 0.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="preventing-navigation:list-iterate" data-x-internal="list-iterate">For each</a> <var>document</var> of <var>documentsToFireBeforeunload</var>,
    <a href="#queue-a-global-task" id="preventing-navigation:queue-a-global-task-2">queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="preventing-navigation:navigation-and-traversal-task-source-2">navigation and traversal task source</a> given
    <var>document</var>'s <a href="#concept-relevant-global" id="preventing-navigation:concept-relevant-global">relevant global object</a> to run the steps:</p>

    <ol><li><p>Let (<var>unloadPromptShownForThisDocument</var>,
     <var>unloadPromptCanceledByThisDocument</var>) be the result of running the <a href="#steps-to-fire-beforeunload" id="preventing-navigation:steps-to-fire-beforeunload-2">steps to fire
     <code>beforeunload</code></a> given <var>document</var> and
     <var>unloadPromptShown</var>.</p></li><li><p>If <var>unloadPromptShownForThisDocument</var> is true, then set
     <var>unloadPromptShown</var> to true.</p></li><li><p>If <var>unloadPromptCanceledByThisDocument</var> is true, then set
     <var>finalStatus</var> to "<code>canceled-by-beforeunload</code>".</p></li><li><p>Increment <var>completedTasks</var>.</p></li></ol>
   </li><li><p>Wait for <var>completedTasks</var> to be <var>totalTasks</var>.</p></li><li><p>Return <var>finalStatus</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="steps-to-fire-beforeunload">steps to fire <code>beforeunload</code></dfn> given a
  <code id="preventing-navigation:document"><a href="#document">Document</a></code> <var>document</var> and a boolean <var>unloadPromptShown</var> are:</p>

  <ol><li><p>Let <var>unloadPromptCanceled</var> be false.</p></li><li><p>Increase the <var>document</var>'s <a href="#unload-counter" id="preventing-navigation:unload-counter">unload counter</a> by 1.</p></li><li><p>Increase <var>document</var>'s <a href="#relevant-agent" id="preventing-navigation:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="preventing-navigation:concept-agent-event-loop">event loop</a>'s <a href="#termination-nesting-level" id="preventing-navigation:termination-nesting-level">termination nesting level</a> by
   1.</p></li><li><p>Let <var>eventFiringResult</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="preventing-navigation:concept-event-fire" data-x-internal="concept-event-fire">firing
   an event</a> named <code id="preventing-navigation:event-beforeunload-3"><a href="#event-beforeunload">beforeunload</a></code> at
   <var>document</var>'s <a href="#concept-relevant-global" id="preventing-navigation:concept-relevant-global-2">relevant global object</a>, using <code id="preventing-navigation:beforeunloadevent"><a href="#beforeunloadevent">BeforeUnloadEvent</a></code>,
   with the <code id="preventing-navigation:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to
   true.</p></li><li><p>Decrease <var>document</var>'s <a href="#relevant-agent" id="preventing-navigation:relevant-agent-2">relevant agent</a>'s <a href="#concept-agent-event-loop" id="preventing-navigation:concept-agent-event-loop-2">event loop</a>'s <a href="#termination-nesting-level" id="preventing-navigation:termination-nesting-level-2">termination nesting level</a> by
   1.</p></li><li>
    <p>If all of the following are true:</p>

    <ul><li><p><var>unloadPromptShown</var> is false;</p></li><li><p><var>document</var>'s <a href="#active-sandboxing-flag-set" id="preventing-navigation:active-sandboxing-flag-set">active sandboxing flag set</a> does not have its
     <a href="#sandboxed-modals-flag" id="preventing-navigation:sandboxed-modals-flag">sandboxed modals flag</a> set;</p></li><li><p><var>document</var>'s <a href="#concept-relevant-global" id="preventing-navigation:concept-relevant-global-3">relevant global object</a> has <a href="#sticky-activation" id="preventing-navigation:sticky-activation">sticky
     activation</a>;</p></li><li><p><var>eventFiringResult</var> is false, or the <code id="preventing-navigation:dom-beforeunloadevent-returnvalue"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code> attribute of <var>event</var> is
     not the empty string; and</p></li><li><p>showing an unload prompt is unlikely to be annoying, deceptive, or pointless,</p></li></ul>

    <p>then:</p>

    <ol><li><p>Set <var>unloadPromptShown</var> to true.</p></li><li><p>Let <var>userPromptHandler</var> be the result of <a id="preventing-navigation:webdriver-bidi-user-prompt-opened" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-opened" data-x-internal="webdriver-bidi-user-prompt-opened">WebDriver BiDi user prompt
     opened</a> with <var>document</var>'s <a href="#concept-relevant-global" id="preventing-navigation:concept-relevant-global-4">relevant global object</a>,
     "<code>beforeunload</code>", and "".</p></li><li><p>If <var>userPromptHandler</var> is "<code>dismiss</code>", then set
     <var>unloadPromptCanceled</var> to true.</p></li><li>
      <p>If <var>userPromptHandler</var> is "<code>none</code>", then:</p>

      <ol><li>
        <p>Ask the user to confirm that they wish to unload the document, and <a href="#pause" id="preventing-navigation:pause">pause</a>
        while waiting for the user's response.</p>

        <p class="note">The message shown to the user is not customizable, but instead determined by
        the user agent. In particular, the actual value of the <code id="preventing-navigation:dom-beforeunloadevent-returnvalue-2"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code> attribute is ignored.</p>
       </li><li><p>If the user did not confirm the page navigation, then set
       <var>unloadPromptCanceled</var> to true.</p></li></ol>

     </li><li><p>Invoke <a id="preventing-navigation:webdriver-bidi-user-prompt-closed" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-closed" data-x-internal="webdriver-bidi-user-prompt-closed">WebDriver BiDi user prompt closed</a> with <var>document</var>'s
     <a href="#concept-relevant-global" id="preventing-navigation:concept-relevant-global-5">relevant global object</a>, "<code>beforeunload</code>", and true
     if <var>unloadPromptCanceled</var> is false or false otherwise.</p></li></ol>
   </li><li><p>Decrease <var>document</var>'s <a href="#unload-counter" id="preventing-navigation:unload-counter-2">unload counter</a> by 1.</p></li><li><p>Return (<var>unloadPromptShown</var>, <var>unloadPromptCanceled</var>).</p></li></ol>
  </div>


  <h5 id="aborting-navigation"><span class="secno">7.4.2.5</span> Aborting navigation<a href="#aborting-navigation" class="self-link"></a></h5>

  <p id="concept-navigate-mature">Each <a href="#navigable" id="aborting-navigation:navigable">navigable</a> has an <dfn id="ongoing-navigation">ongoing navigation</dfn>,
  which is a <a href="#navigation-id" id="aborting-navigation:navigation-id">navigation ID</a>, "<code>traversal</code>", or null, initially
  null. It is used to track navigation aborting and to prevent any navigations from taking place
  during <a href="#apply-the-traverse-history-step" id="aborting-navigation:apply-the-traverse-history-step">traversal</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="set-the-ongoing-navigation">set the ongoing navigation</dfn> for a <a href="#navigable" id="aborting-navigation:navigable-2">navigable</a> <var>navigable</var> to
  <var>newValue</var>:</p>

  <ol><li><p>If <var>navigable</var>'s <a href="#ongoing-navigation" id="aborting-navigation:ongoing-navigation">ongoing navigation</a> is equal to <var>newValue</var>,
   then return.</p></li><li><p><a href="#inform-the-navigation-api-about-aborting-navigation" id="aborting-navigation:inform-the-navigation-api-about-aborting-navigation">Inform the navigation API about aborting navigation</a> given
   <var>navigable</var>.</p></li><li><p>Set <var>navigable</var>'s <a href="#ongoing-navigation" id="aborting-navigation:ongoing-navigation-2">ongoing navigation</a> to
   <var>newValue</var>.</p></li></ol>
  </div>


  <h4 id="reloading-and-traversing"><span class="secno">7.4.3</span> Reloading and traversing<a href="#reloading-and-traversing" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>To <dfn id="reload">reload</dfn> a <a href="#navigable" id="reloading-and-traversing:navigable">navigable</a> <var>navigable</var> given an optional
  <a href="#serialized-state" id="reloading-and-traversing:serialized-state">serialized state</a>-or-null <dfn id="reload-navigation-api-state"><var>navigationAPIState</var></dfn> (default null), an
  optional <a href="#user-navigation-involvement" id="reloading-and-traversing:user-navigation-involvement">user navigation involvement</a> <dfn id="reload-user-involvement"><var>userInvolvement</var></dfn> (default "<code id="reloading-and-traversing:uni-none"><a href="#uni-none">none</a></code>"), and an optional <a href="#navigation-api-method-tracker" id="reloading-and-traversing:navigation-api-method-tracker">navigation API method
  tracker</a>-or-null <dfn id="reload-api-method-tracker"><var>apiMethodTracker</var></dfn>
  (default null):</p>

  <ol><li>
    <p>If <var>userInvolvement</var> is not "<code id="reloading-and-traversing:uni-browser-ui"><a href="#uni-browser-ui">browser UI</a></code>",
    then:</p>

    <ol><li><p>Let <var>navigation</var> be <var>navigable</var>'s <a href="#nav-window" id="reloading-and-traversing:nav-window">active
     window</a>'s <a href="#window-navigation-api" id="reloading-and-traversing:window-navigation-api">navigation API</a>.</p></li><li><p>Let <var>destinationNavigationAPIState</var> be <var>navigable</var>'s <a href="#nav-active-history-entry" id="reloading-and-traversing:nav-active-history-entry">active session history entry</a>'s <a href="#she-navigation-api-state" id="reloading-and-traversing:she-navigation-api-state">navigation API state</a>.</p></li><li><p>If <var>navigationAPIState</var> is not null, then set
     <var>destinationNavigationAPIState</var> to <var>navigationAPIState</var>.</p></li><li><p>Let <var>continue</var> be the result of <a href="#fire-a-push/replace/reload-navigate-event" id="reloading-and-traversing:fire-a-push/replace/reload-navigate-event">firing a push/replace/reload <code>navigate</code>
     event</a> at <var>navigation</var> with <i id="reloading-and-traversing:fire-navigate-prr-navigationtype"><a href="#fire-navigate-prr-navigationtype">navigationType</a></i> set to "<code id="reloading-and-traversing:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>", <i id="reloading-and-traversing:fire-navigate-prr-issamedocument"><a href="#fire-navigate-prr-issamedocument">isSameDocument</a></i> set to false, <i id="reloading-and-traversing:fire-navigate-prr-userinvolvement"><a href="#fire-navigate-prr-userinvolvement">userInvolvement</a></i> set to
     <var>userInvolvement</var>, <i id="reloading-and-traversing:fire-navigate-prr-destinationurl"><a href="#fire-navigate-prr-destinationurl">destinationURL</a></i>
     set to <var>navigable</var>'s <a href="#nav-active-history-entry" id="reloading-and-traversing:nav-active-history-entry-2">active session history
     entry</a>'s <a href="#she-url" id="reloading-and-traversing:she-url">URL</a>, <i id="reloading-and-traversing:fire-navigate-prr-navigationapistate"><a href="#fire-navigate-prr-navigationapistate">navigationAPIState</a></i> set to
     <var>destinationNavigationAPIState</var>, and <i id="reloading-and-traversing:fire-navigate-prr-api-method-tracker"><a href="#fire-navigate-prr-api-method-tracker">apiMethodTracker</a></i> set to
     <var>apiMethodTracker</var>.</p></li><li><p>If <var>continue</var> is false, then return.</p></li></ol>
   </li><li><p>Set <var>navigable</var>'s <a href="#nav-active-history-entry" id="reloading-and-traversing:nav-active-history-entry-3">active session history
   entry</a>'s <a href="#she-document-state" id="reloading-and-traversing:she-document-state">document state</a>'s <a href="#document-state-reload-pending" id="reloading-and-traversing:document-state-reload-pending">reload pending</a> to true.</p></li><li><p>Let <var>traversable</var> be <var>navigable</var>'s <a href="#nav-traversable" id="reloading-and-traversing:nav-traversable">traversable navigable</a>.</p></li><li>
    <p><a href="#tn-append-session-history-traversal-steps" id="reloading-and-traversing:tn-append-session-history-traversal-steps">Append the following session
    history traversal steps</a> to <var>traversable</var>:</p>

    <ol><li><p><a href="#apply-the-reload-history-step" id="reloading-and-traversing:apply-the-reload-history-step">Apply the reload history step</a> to <var>traversable</var> given
     <var>userInvolvement</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="traverse-the-history-by-a-delta">traverse the history by a delta</dfn> given a <a href="#traversable-navigable" id="reloading-and-traversing:traversable-navigable">traversable navigable</a>
  <var>traversable</var>, an integer <var>delta</var>, and an optional <code id="reloading-and-traversing:document"><a href="#document">Document</a></code> <dfn id="traverse-sourcedocument"><var>sourceDocument</var></dfn>:</p>

  <ol><li><p>Let <var>sourceSnapshotParams</var> and <var>initiatorToCheck</var> be null.</p></li><li><p>Let <var>userInvolvement</var> be "<code id="reloading-and-traversing:uni-browser-ui-2"><a href="#uni-browser-ui">browser
   UI</a></code>".</p></li><li>
    <p>If <var>sourceDocument</var> is given, then:</p>

    <ol><li><p>Set <var>sourceSnapshotParams</var> to the result of <a href="#snapshotting-source-snapshot-params" id="reloading-and-traversing:snapshotting-source-snapshot-params">snapshotting source snapshot
     params</a> given <var>sourceDocument</var>.</p></li><li><p>Set <var>initiatorToCheck</var> to <var>sourceDocument</var>'s <a href="#node-navigable" id="reloading-and-traversing:node-navigable">node
     navigable</a>.</p></li><li><p>Set <var>userInvolvement</var> to "<code id="reloading-and-traversing:uni-none-2"><a href="#uni-none">none</a></code>".</p></li></ol>
   </li><li>
    <p><a href="#tn-append-session-history-traversal-steps" id="reloading-and-traversing:tn-append-session-history-traversal-steps-2">Append the following session
    history traversal steps</a> to <var>traversable</var>:</p>

    <ol><li><p>Let <var>allSteps</var> be the result of <a href="#getting-all-used-history-steps" id="reloading-and-traversing:getting-all-used-history-steps">getting all used history steps</a>
     for <var>traversable</var>.</p></li><li><p>Let <var>currentStepIndex</var> be the index of <var>traversable</var>'s <a href="#tn-current-session-history-step" id="reloading-and-traversing:tn-current-session-history-step">current session history step</a> within
     <var>allSteps</var>.</p></li><li><p>Let <var>targetStepIndex</var> be <var>currentStepIndex</var> plus
     <var>delta</var>.</p></li><li><p>If <var>allSteps</var>[<var>targetStepIndex</var>] does not <a href="https://infra.spec.whatwg.org/#list-contain" id="reloading-and-traversing:list-contains" data-x-internal="list-contains">exist</a>, then abort these steps.</p></li><li><p><a href="#apply-the-traverse-history-step" id="reloading-and-traversing:apply-the-traverse-history-step">Apply the traverse history step</a>
     <var>allSteps</var>[<var>targetStepIndex</var>] to <var>traversable</var>, given
     <var>sourceSnapshotParams</var>, <var>initiatorToCheck</var>, and
     <var>userInvolvement</var>.</p></li></ol>
   </li></ol>
  </div>


  <h4 id="navigate-non-frag-sync"><span class="secno">7.4.4</span> Non-fragment synchronous "navigations"<a href="#navigate-non-frag-sync" class="self-link"></a></h4>

  <p>Apart from the <a href="#navigate" id="navigate-non-frag-sync:navigate">navigate</a> algorithm, <a href="#session-history-entry" id="navigate-non-frag-sync:session-history-entry">session
  history entries</a> can be pushed or replaced via one more mechanism, the <a href="#url-and-history-update-steps" id="navigate-non-frag-sync:url-and-history-update-steps">URL and
  history update steps</a>. The most well-known callers of these steps are the <code id="navigate-non-frag-sync:dom-history-replacestate"><a href="#dom-history-replacestate">history.replaceState()</a></code> and <code id="navigate-non-frag-sync:dom-history-pushstate"><a href="#dom-history-pushstate">history.pushState()</a></code> APIs, but various other parts of the
  standard also need to perform updates to the <a href="#nav-active-history-entry" id="navigate-non-frag-sync:nav-active-history-entry">active
  history entry</a>, and they use these steps to do so.</p>

  <div data-algorithm="">
  <p id="history-1">The <dfn id="url-and-history-update-steps">URL and history update steps</dfn>, given a <code id="navigate-non-frag-sync:document"><a href="#document">Document</a></code>
  <var>document</var>, a <a id="navigate-non-frag-sync:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>newURL</var>, an optional <a href="#serialized-state" id="navigate-non-frag-sync:serialized-state">serialized
  state</a>-or-null <dfn id="uhus-serializeddata"><var>serializedData</var></dfn> (default
  null), and an optional <a href="#history-handling-behavior" id="navigate-non-frag-sync:history-handling-behavior">history handling behavior</a> <dfn id="uhus-historyhandling"><var id="uhus-ispush">historyHandling</var></dfn> (default "<code id="navigate-non-frag-sync:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>"), are:</p>

  <ol><li><p>Let <var>navigable</var> be <var>document</var>'s <a href="#node-navigable" id="navigate-non-frag-sync:node-navigable">node navigable</a>.</p></li><li><p>Let <var>activeEntry</var> be <var>navigable</var>'s <a href="#nav-active-history-entry" id="navigate-non-frag-sync:nav-active-history-entry-2">active session history entry</a>.</p></li><li>
    <p>Let <var>newEntry</var> be a new <a href="#session-history-entry" id="navigate-non-frag-sync:session-history-entry-2">session history entry</a>, with</p>

    <dl class="props"><dt><a href="#she-url" id="navigate-non-frag-sync:she-url">URL</a></dt><dd><var>newURL</var></dd><dt><a href="#she-classic-history-api-state" id="navigate-non-frag-sync:she-classic-history-api-state">serialized state</a></dt><dd>if <var>serializedData</var> is not null, <var>serializedData</var>; otherwise
     <var>activeEntry</var>'s <a href="#she-classic-history-api-state" id="navigate-non-frag-sync:she-classic-history-api-state-2">classic history API
     state</a></dd><dt><a href="#she-document-state" id="navigate-non-frag-sync:she-document-state">document state</a></dt><dd><var>activeEntry</var>'s <a href="#she-document-state" id="navigate-non-frag-sync:she-document-state-2">document state</a></dd><dt><a href="#she-scroll-restoration-mode" id="navigate-non-frag-sync:she-scroll-restoration-mode">scroll restoration mode</a></dt><dd><var>activeEntry</var>'s <a href="#she-scroll-restoration-mode" id="navigate-non-frag-sync:she-scroll-restoration-mode-2">scroll restoration
     mode</a></dd><dt><a href="#she-other" id="navigate-non-frag-sync:she-other">persisted user state</a></dt><dd><var>activeEntry</var>'s <a href="#she-other" id="navigate-non-frag-sync:she-other-2">persisted user state</a></dd></dl>
   </li><li>
    <p>If <var>document</var>'s <a href="#is-initial-about:blank" id="navigate-non-frag-sync:is-initial-about:blank">is initial <code>about:blank</code></a> is true, then set
    <var>historyHandling</var> to "<code id="navigate-non-frag-sync:navigationhistorybehavior-replace-2"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p>

    <p class="note">This means that <code id="navigate-non-frag-sync:dom-history-pushstate-2"><a href="#dom-history-pushstate">pushState()</a></code> on an
    <a href="#is-initial-about:blank" id="navigate-non-frag-sync:is-initial-about:blank-2">initial <code>about:blank</code></a>
    <code id="navigate-non-frag-sync:document-2"><a href="#document">Document</a></code> behaves as a <code id="navigate-non-frag-sync:dom-history-replacestate-2"><a href="#dom-history-replacestate">replaceState()</a></code> call.</p>
   </li><li><p>Let <var>entryToReplace</var> be <var>activeEntry</var> if <var>historyHandling</var> is
   "<code id="navigate-non-frag-sync:navigationhistorybehavior-replace-3"><a href="#navigationhistorybehavior-replace">replace</a></code>", otherwise null.</p></li><li>
    <p>If <var>historyHandling</var> is "<code id="navigate-non-frag-sync:navigationhistorybehavior-push"><a href="#navigationhistorybehavior-push">push</a></code>",
    then:</p>

    <ol><li><p>Increment <var>document</var>'s <a href="#doc-history" id="navigate-non-frag-sync:doc-history">history object</a>'s
     <a href="#concept-history-index" id="navigate-non-frag-sync:concept-history-index">index</a>.</p></li><li><p>Set <var>document</var>'s <a href="#doc-history" id="navigate-non-frag-sync:doc-history-2">history object</a>'s <a href="#concept-history-length" id="navigate-non-frag-sync:concept-history-length">length</a> to its <a href="#concept-history-index" id="navigate-non-frag-sync:concept-history-index-2">index</a> + 1.</p></li></ol>

    <p class="note">These are temporary best-guess values for immediate synchronous access.</p>
   </li><li><p>If <var>serializedData</var> is not null, then <a href="#restore-the-history-object-state" id="navigate-non-frag-sync:restore-the-history-object-state">restore the history object
   state</a> given <var>document</var> and <var>newEntry</var>.</p></li><li>
    <p><a href="#set-the-url" id="navigate-non-frag-sync:set-the-url">Set the URL</a> given <var>document</var> to <var>newURL</var>.</p>

    <p class="note">Since this is neither a <a href="#navigate" id="navigate-non-frag-sync:navigate-2">navigation</a> nor a <a href="#traverse-the-history-by-a-delta" id="navigate-non-frag-sync:traverse-the-history-by-a-delta">history traversal</a>, it does not cause a <code id="navigate-non-frag-sync:event-hashchange"><a href="#event-hashchange">hashchange</a></code> event to be fired.</p>
   </li><li><p>Set <var>document</var>'s <a href="#latest-entry" id="navigate-non-frag-sync:latest-entry">latest entry</a> to <var>newEntry</var>.</p></li><li><p>Set <var>navigable</var>'s <a href="#nav-active-history-entry" id="navigate-non-frag-sync:nav-active-history-entry-3">active session history
   entry</a> to <var>newEntry</var>.</p></li><li><p><a href="#update-the-navigation-api-entries-for-a-same-document-navigation" id="navigate-non-frag-sync:update-the-navigation-api-entries-for-a-same-document-navigation">Update the navigation API entries for a same-document navigation</a> given
   <var>document</var>'s <a href="#concept-relevant-global" id="navigate-non-frag-sync:concept-relevant-global">relevant global object</a>'s <a href="#window-navigation-api" id="navigate-non-frag-sync:window-navigation-api">navigation API</a>, <var>newEntry</var>, and
   <var>historyHandling</var>.</p></li><li><p>Let <var>traversable</var> be <var>navigable</var>'s <a href="#nav-traversable" id="navigate-non-frag-sync:nav-traversable">traversable navigable</a>.</p></li><li>
    <p><a href="#tn-append-session-history-sync-nav-steps" id="navigate-non-frag-sync:tn-append-session-history-sync-nav-steps">Append the following session history
    synchronous navigation steps</a> involving <var>navigable</var> to
    <var>traversable</var>:</p>

    <ol><li><p><a href="#finalize-a-same-document-navigation" id="navigate-non-frag-sync:finalize-a-same-document-navigation">Finalize a same-document navigation</a> given <var>traversable</var>,
     <var>navigable</var>, <var>newEntry</var>, <var>entryToReplace</var>,
     <var>historyHandling</var>, and "<code id="navigate-non-frag-sync:uni-none"><a href="#uni-none">none</a></code>".</p></li><li><p>Invoke <a id="navigate-non-frag-sync:webdriver-bidi-history-updated" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-history-updated" data-x-internal="webdriver-bidi-history-updated">WebDriver BiDi history updated</a> with <var>navigable</var>.</p></li></ol>
   </li></ol>
  </div>

  <p class="note">Although both <a href="#navigate-fragid" id="navigate-non-frag-sync:navigate-fragid">fragment navigation</a> and the
  <a href="#url-and-history-update-steps" id="navigate-non-frag-sync:url-and-history-update-steps-2">URL and history update steps</a> perform synchronous history updates, only fragment
  navigation contains a synchronous call to <a href="#update-document-for-history-step-application" id="navigate-non-frag-sync:update-document-for-history-step-application">update document for history step
  application</a>. The <a href="#url-and-history-update-steps" id="navigate-non-frag-sync:url-and-history-update-steps-3">URL and history update steps</a> instead perform a few select
  updates inside the above algorithm, omitting others. This is somewhat of an unfortunate
  historical accident, and generally leads to <a href="https://github.com/whatwg/html/issues/5562">web-developer sadness</a> about the
  inconsistency. For example, this means that <code id="navigate-non-frag-sync:event-popstate"><a href="#event-popstate">popstate</a></code> events
  fire for fragment navigations, but not for <code id="navigate-non-frag-sync:dom-history-pushstate-3"><a href="#dom-history-pushstate">history.pushState()</a></code> calls.</p>


  <h4 id="populating-a-session-history-entry"><span class="secno">7.4.5</span> <span id="history-traversal"></span><span id="traverse-the-history"></span>Populating a session history entry<a href="#populating-a-session-history-entry" class="self-link"></a></h4>

  <p>As explained in <a href="#history">the overview</a>, both <a href="#navigating-across-documents">navigation</a> and <a href="#reloading-and-traversing">traversal</a> involve creating a <a href="#session-history-entry" id="populating-a-session-history-entry:session-history-entry">session history
  entry</a> and then attempting to populate its <a href="#she-document" id="populating-a-session-history-entry:she-document">document</a>
  member, so that it can be presented inside the <a href="#navigable" id="populating-a-session-history-entry:navigable">navigable</a>.</p>

  <p>This involves either: using <a href="#note-navigate-called-with-response">an already-given
  response</a>; using the <a href="#document-state-resource" id="populating-a-session-history-entry:document-state-resource">srcdoc resource</a> stored in
  the <a href="#session-history-entry" id="populating-a-session-history-entry:session-history-entry-2">session history entry</a>; or <a href="#create-navigation-params-by-fetching" id="populating-a-session-history-entry:create-navigation-params-by-fetching">fetching</a>. The process has several failure modes, which can either result in
  doing nothing (leaving the <a href="#navigable" id="populating-a-session-history-entry:navigable-2">navigable</a> on its currently-<a href="#nav-document" id="populating-a-session-history-entry:nav-document">active</a> <code id="populating-a-session-history-entry:document"><a href="#document">Document</a></code>) or can result in populating the
  <a href="#session-history-entry" id="populating-a-session-history-entry:session-history-entry-3">session history entry</a> with an <a href="#navigate-ua-inline" id="populating-a-session-history-entry:navigate-ua-inline">error
  document</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="attempt-to-populate-the-history-entry's-document">attempt to populate the history entry's document</dfn> for a <a href="#session-history-entry" id="populating-a-session-history-entry:session-history-entry-4">session history
  entry</a> <var>entry</var>, given a <a href="#navigable" id="populating-a-session-history-entry:navigable-3">navigable</a> <var>navigable</var>, a
  <code id="populating-a-session-history-entry:navigationtimingtype"><a data-x-internal="navigationtimingtype" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype">NavigationTimingType</a></code> <var>navTimingType</var>, a <a href="#source-snapshot-params" id="populating-a-session-history-entry:source-snapshot-params">source snapshot params</a>
  <var>sourceSnapshotParams</var>, a <a href="#target-snapshot-params" id="populating-a-session-history-entry:target-snapshot-params">target snapshot params</a>
  <var>targetSnapshotParams</var>, a <a href="#user-navigation-involvement" id="populating-a-session-history-entry:user-navigation-involvement">user navigation involvement</a>
  <var>userInvolvement</var>, an optional <a href="#navigation-id" id="populating-a-session-history-entry:navigation-id">navigation ID</a>-or-null <var>navigationId</var>
  (default null), an optional <a href="#navigation-params" id="populating-a-session-history-entry:navigation-params">navigation params</a>-or-null <var>navigationParams</var>
  (default null), an optional string <var>cspNavigationType</var> (default "<code>other</code>"), an optional boolean <dfn id="attempt-to-populate-allow-post"><var>allowPOST</var></dfn> (default false), and optional
  algorithm steps <dfn id="attempt-to-populate-completion-steps"><var>completionSteps</var></dfn> (default an empty
  algorithm):</p>

  <ol><li><p><a id="populating-a-session-history-entry:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running <a href="#in-parallel" id="populating-a-session-history-entry:in-parallel">in parallel</a>.</p></li><li><p><a id="populating-a-session-history-entry:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: if <var>navigationParams</var> is non-null, then
   <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response">response</a> is
   non-null.</p></li><li><p>Let <var>documentResource</var> be <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state">document state</a>'s <a href="#document-state-resource" id="populating-a-session-history-entry:document-state-resource-2">resource</a>.</p></li><li>
    <p>If <var>navigationParams</var> is null, then:</p>

    <ol><li><p>If <var>documentResource</var> is a string, then set <var>navigationParams</var> to the
     result of <a href="#create-navigation-params-from-a-srcdoc-resource" id="populating-a-session-history-entry:create-navigation-params-from-a-srcdoc-resource">creating navigation
     params from a srcdoc resource</a> given <var>entry</var>, <var>navigable</var>,
     <var>targetSnapshotParams</var>, <var>userInvolvement</var>, <var>navigationId</var>, and
     <var>navTimingType</var>.</p></li><li>
      <p>Otherwise, if all of the following are true:

      </p><ul><li><p><var>entry</var>'s <a href="#she-url" id="populating-a-session-history-entry:she-url">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="populating-a-session-history-entry:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is a <a id="populating-a-session-history-entry:fetch-scheme" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a>; and</p></li><li><p><var>documentResource</var> is null, or <var>allowPOST</var> is true and
       <var>documentResource</var>'s <a href="#post-resource-request-body" id="populating-a-session-history-entry:post-resource-request-body">request body</a>
       is not failure,</p></li></ul>

      <p>then set <var>navigationParams</var> to the result of <a href="#create-navigation-params-by-fetching" id="populating-a-session-history-entry:create-navigation-params-by-fetching-2">creating navigation params by fetching</a> given <var>entry</var>,
      <var>navigable</var>, <var>sourceSnapshotParams</var>, <var>targetSnapshotParams</var>,
      <var>cspNavigationType</var>, <var>userInvolvement</var>, <var>navigationId</var>, and
      <var>navTimingType</var>.</p>
     </li><li>
      <p>Otherwise, if <var>entry</var>'s <a href="#she-url" id="populating-a-session-history-entry:she-url-2">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="populating-a-session-history-entry:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a> is not a <a id="populating-a-session-history-entry:fetch-scheme-2" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a>, then set
      <var>navigationParams</var> to a new <a href="#non-fetch-scheme-navigation-params" id="populating-a-session-history-entry:non-fetch-scheme-navigation-params">non-fetch scheme navigation params</a>,
      with</p>

      <dl class="props"><dt><a href="#non-fetch-scheme-params-id" id="populating-a-session-history-entry:non-fetch-scheme-params-id">id</a></dt><dd><var>navigationId</var></dd><dt><a href="#non-fetch-scheme-params-navigable" id="populating-a-session-history-entry:non-fetch-scheme-params-navigable">navigable</a></dt><dd><var>navigable</var></dd><dt><a href="#non-fetch-scheme-params-url" id="populating-a-session-history-entry:non-fetch-scheme-params-url">URL</a></dt><dd><var>entry</var>'s <a href="#she-url" id="populating-a-session-history-entry:she-url-3">URL</a></dd><dt><a href="#non-fetch-scheme-params-target-sandbox" id="populating-a-session-history-entry:non-fetch-scheme-params-target-sandbox">target snapshot sandboxing flags</a></dt><dd><var>targetSnapshotParams</var>'s <a href="#target-snapshot-params-sandbox" id="populating-a-session-history-entry:target-snapshot-params-sandbox">sandboxing flags</a></dd><dt><a href="#non-fetch-scheme-params-source-activation" id="populating-a-session-history-entry:non-fetch-scheme-params-source-activation">source snapshot has transient activation</a></dt><dd><var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-activation" id="populating-a-session-history-entry:source-snapshot-params-activation">has
       transient activation</a></dd><dt><a href="#non-fetch-scheme-params-initiator-origin" id="populating-a-session-history-entry:non-fetch-scheme-params-initiator-origin">initiator origin</a></dt><dd><var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-2">document state</a>'s <a href="#document-state-initiator-origin" id="populating-a-session-history-entry:document-state-initiator-origin">initiator origin</a></dd><dt><a href="#non-fetch-scheme-params-nav-timing-type" id="populating-a-session-history-entry:non-fetch-scheme-params-nav-timing-type">navigation timing type</a></dt><dd><var>navTimingType</var></dd><dt><a href="#non-fetch-scheme-params-user-involvement" id="populating-a-session-history-entry:non-fetch-scheme-params-user-involvement">user involvement</a></dt><dd><var>userInvolvement</var></dd></dl>
     </li></ol>
   </li><li id="process-a-navigate-response">
    <p><a href="#queue-a-global-task" id="populating-a-session-history-entry:queue-a-global-task">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="populating-a-session-history-entry:navigation-and-traversal-task-source">navigation and traversal task source</a>,
    given <var>navigable</var>'s <a href="#active-window" id="populating-a-session-history-entry:active-window">active window</a>, to run these steps:</p>

    <ol><li><p>If <var>navigable</var>'s <a href="#ongoing-navigation" id="populating-a-session-history-entry:ongoing-navigation">ongoing navigation</a> no longer equals
     <var>navigationId</var>, then run <var>completionSteps</var> and abort these steps.</p></li><li>
      <p>Let <var>saveExtraDocumentState</var> be true.</p>

      <div class="note">
       <p>Usually, in the cases where we end up populating <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-3">document state</a>'s <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document">document</a>, we then want to save some of the state
       from that <code id="populating-a-session-history-entry:document-2"><a href="#document">Document</a></code> into <var>entry</var>. This ensures that if there are future
       traversals to <var>entry</var> where its <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-2">document</a> <a href="#note-bfcache">has been
       destroyed</a>, we can use that state when creating a new <code id="populating-a-session-history-entry:document-3"><a href="#document">Document</a></code>.</p>

       <p>However, in some specific cases, saving the state would be unhelpful. For those, we set
       <var>saveExtraDocumentState</var> to false later in this algorithm.</p>
      </div>
     </li><li>
      <p>If <var>navigationParams</var> is a <a href="#non-fetch-scheme-navigation-params" id="populating-a-session-history-entry:non-fetch-scheme-navigation-params-2">non-fetch scheme navigation params</a>,
      then:</p>

      <ol><li>
        <p>Set <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-4">document state</a>'s <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-3">document</a> to the result of running <a href="#attempt-to-create-a-non-fetch-scheme-document" id="populating-a-session-history-entry:attempt-to-create-a-non-fetch-scheme-document">attempt to
        create a non-fetch scheme document</a> given <var>navigationParams</var>.</p>

        <p class="note">This can result in setting <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-5">document state</a>'s <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-4">document</a> to null, e.g., when <a href="#hand-off-to-external-software" id="populating-a-session-history-entry:hand-off-to-external-software">handing-off to external software</a>.</p>
       </li><li><p>Set <var>saveExtraDocumentState</var> to false.</p></li></ol>
     </li><li>
      <p>Otherwise, if any of the following are true:</p>

      <ul><li><p><var>navigationParams</var> is null;</p></li><li><p>the result of <a id="populating-a-session-history-entry:should-navigation-response-to-navigation-request-of-type-in-target-be-blocked-by-content-security-policy" href="https://w3c.github.io/webappsec-csp/#should-block-navigation-response" data-x-internal="should-navigation-response-to-navigation-request-of-type-in-target-be-blocked-by-content-security-policy">should navigation response to navigation request of type in
       target be blocked by Content Security Policy?</a> given <var>navigationParams</var>'s
       <a href="#navigation-params-request" id="populating-a-session-history-entry:navigation-params-request">request</a>, <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-2">response</a>, <var>navigationParams</var>'s <a href="#navigation-params-policy-container" id="populating-a-session-history-entry:navigation-params-policy-container">policy container</a>'s <a href="#policy-container-csp-list" id="populating-a-session-history-entry:policy-container-csp-list">CSP list</a>, <var>cspNavigationType</var>, and
       <var>navigable</var> is "<code>Blocked</code>";</p></li><li><p><var>navigationParams</var>'s <a href="#navigation-params-reserved-environment" id="populating-a-session-history-entry:navigation-params-reserved-environment">reserved environment</a> is non-null and
       the result of <a href="#check-a-navigation-response's-adherence-to-its-embedder-policy" id="populating-a-session-history-entry:check-a-navigation-response's-adherence-to-its-embedder-policy">checking a navigation response's adherence to its embedder policy</a> given
       <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-3">response</a>,
       <var>navigable</var>, and <var>navigationParams</var>'s <a href="#navigation-params-policy-container" id="populating-a-session-history-entry:navigation-params-policy-container-2">policy container</a>'s <a href="#policy-container-embedder-policy" id="populating-a-session-history-entry:policy-container-embedder-policy">embedder policy</a> is false; or </p></li><li><p>the result of <a href="#check-a-navigation-response's-adherence-to-x-frame-options" id="populating-a-session-history-entry:check-a-navigation-response's-adherence-to-x-frame-options">checking a navigation response's adherence to
       `<code>X-Frame-Options</code>`</a> given <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-4">response</a>, <var>navigable</var>,
       <var>navigationParams</var>'s <a href="#navigation-params-policy-container" id="populating-a-session-history-entry:navigation-params-policy-container-3">policy
       container</a>'s <a href="#policy-container-csp-list" id="populating-a-session-history-entry:policy-container-csp-list-2">CSP list</a>, and
       <var>navigationParams</var>'s <a href="#navigation-params-origin" id="populating-a-session-history-entry:navigation-params-origin">origin</a> is
       false,</p></li></ul>

      <p>then:</p>

      <ol><li><p>Set <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-6">document state</a>'s
       <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-5">document</a> to the result of <a href="#navigate-ua-inline" id="populating-a-session-history-entry:navigate-ua-inline-2">creating a document for inline content that doesn't have a
       DOM</a>, given <var>navigable</var>, null, <var>navTimingType</var>, and
       <var>userInvolvement</var>. The inline content should indicate to the user the sort of error
       that occurred.</p></li><li><p><a href="#make-document-unsalvageable" id="populating-a-session-history-entry:make-document-unsalvageable">Make document unsalvageable</a> given <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-7">document state</a>'s <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-6">document</a> and "<code id="populating-a-session-history-entry:blocking-navigation-failure"><a href="#blocking-navigation-failure">navigation-failure</a></code>".</p></li><li><p>Set <var>saveExtraDocumentState</var> to false.</p></li><li>
        <p>If <var>navigationParams</var> is not null, then:</p>

        <ol><li><p>Run the <a href="#environment-discarding-steps" id="populating-a-session-history-entry:environment-discarding-steps">environment discarding
         steps</a> for <var>navigationParams</var>'s <a href="#navigation-params-reserved-environment" id="populating-a-session-history-entry:navigation-params-reserved-environment-2">reserved environment</a>.</p></li><li><p>Invoke <a id="populating-a-session-history-entry:webdriver-bidi-navigation-failed" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-failed" data-x-internal="webdriver-bidi-navigation-failed">WebDriver BiDi navigation failed</a> with <var>navigable</var> and a
         new <a id="populating-a-session-history-entry:webdriver-bidi-navigation-status" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="populating-a-session-history-entry:navigation-status-id" data-x-internal="navigation-status-id">id</a> is <var>navigationId</var>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="populating-a-session-history-entry:navigation-status-status" data-x-internal="navigation-status-status">status</a> is "<code id="populating-a-session-history-entry:navigation-status-canceled"><a data-x-internal="navigation-status-canceled" href="https://w3c.github.io/webdriver-bidi/#navigation-status-canceled">canceled</a></code>", and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="populating-a-session-history-entry:navigation-status-url" data-x-internal="navigation-status-url">url</a> is <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-5">response</a>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="populating-a-session-history-entry:concept-response-url" data-x-internal="concept-response-url">URL</a>.</p></li></ol>
       </li></ol>
     </li><li id="navigation-as-a-download">
      <p>Otherwise, if <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-6">response</a> has a `<code id="populating-a-session-history-entry:http-content-disposition"><a data-x-internal="http-content-disposition" href="https://httpwg.org/specs/rfc6266.html">Content-Disposition</a></code>` header specifying the <code>attachment</code> disposition type, then:</p>

      <ol><li><p>Let <var>sourceAllowsDownloading</var> be <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-download" id="populating-a-session-history-entry:source-snapshot-params-download">allows downloading</a>.</p></li><li><p>Let <var>targetAllowsDownloading</var> be false if <var>navigationParams</var>'s
       <a href="#navigation-params-sandboxing" id="populating-a-session-history-entry:navigation-params-sandboxing">final sandboxing flag set</a> has the
       <a href="#sandboxed-downloads-browsing-context-flag" id="populating-a-session-history-entry:sandboxed-downloads-browsing-context-flag">sandboxed downloads browsing context flag</a> set; otherwise true.</p></li><li><p>Let <var>uaAllowsDownloading</var> be true.</p></li><li><p>Optionally, the user agent may set <var>uaAllowsDownloading</var> to false, if it
       believes doing so would safeguard the user from a potentially hostile download.</p></li><li>
        <p>If <var>sourceAllowsDownloading</var>, <var>targetAllowsDownloading</var>, and
        <var>uaAllowsDownloading</var> are true, then:</p>

        <ol><li><p><a href="#handle-as-a-download" id="populating-a-session-history-entry:handle-as-a-download">Handle as a download</a>
         <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-7">response</a>
         with <var>navigable</var> and <var>navigationId</var>.</p></li></ol>
       </li></ol>

      <p class="note">This branch leaves <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-8">document state</a>'s <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-7">document</a> as null.</p>
     </li><li>
      <p>Otherwise, if <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-8">response</a>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="populating-a-session-history-entry:concept-response-status" data-x-internal="concept-response-status">status</a> is not 204 and is not 205, then set
      <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-9">document state</a>'s <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-8">document</a> to the result of <a href="#loading-a-document" id="populating-a-session-history-entry:loading-a-document">loading a
      document</a> given <var>navigationParams</var>, <var>sourceSnapshotParams</var>, and
      <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-10">document state</a>'s <a href="#document-state-initiator-origin" id="populating-a-session-history-entry:document-state-initiator-origin-2">initiator origin</a>.</p>

      <p class="note">This can result in setting <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-11">document state</a>'s <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-9">document</a> to null, e.g., when <a href="#hand-off-to-external-software" id="populating-a-session-history-entry:hand-off-to-external-software-2">handing-off to external software</a>.</p>
     </li><li>
      <p>If <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-12">document state</a>'s <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-10">document</a> is not null, then:</p>

      <ol><li><p>Set <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-13">document state</a>'s
       <a href="#document-state-ever-populated" id="populating-a-session-history-entry:document-state-ever-populated">ever populated</a> to true.</p></li><li>
        <p>If <var>saveExtraDocumentState</var> is true:</p>

        <ol><li><p>Let <var>document</var> be <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-14">document state</a>'s <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-11">document</a>.</p></li><li><p>Set <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-15">document state</a>'s
         <a href="#document-state-origin" id="populating-a-session-history-entry:document-state-origin">origin</a> to <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="populating-a-session-history-entry:concept-document-origin" data-x-internal="concept-document-origin">origin</a>.</p></li><li>
          <p>If <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="populating-a-session-history-entry:the-document's-address" data-x-internal="the-document's-address">URL</a>
          <a href="#requires-storing-the-policy-container-in-history" id="populating-a-session-history-entry:requires-storing-the-policy-container-in-history">requires storing the policy container in history</a>, then:</p>

          <ol><li><p><a id="populating-a-session-history-entry:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigationParams</var> is a <a href="#navigation-params" id="populating-a-session-history-entry:navigation-params-2">navigation
           params</a> (i.e., neither null nor a <a href="#non-fetch-scheme-navigation-params" id="populating-a-session-history-entry:non-fetch-scheme-navigation-params-3">non-fetch scheme navigation
           params</a>).</p></li><li><p>Set <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-16">document state</a>'s
           <a href="#document-state-history-policy-container" id="populating-a-session-history-entry:document-state-history-policy-container">history policy container</a>
           to <var>navigationParams</var>'s <a href="#navigation-params-policy-container" id="populating-a-session-history-entry:navigation-params-policy-container-4">policy container</a>.</p></li></ol>
         </li></ol>
       </li><li>
        <p>If <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-17">document state</a>'s <a href="#document-state-request-referrer" id="populating-a-session-history-entry:document-state-request-referrer">request referrer</a> is "<code>client</code>", and <var>navigationParams</var> is a <a href="#navigation-params" id="populating-a-session-history-entry:navigation-params-3">navigation
        params</a> (i.e., neither null nor a <a href="#non-fetch-scheme-navigation-params" id="populating-a-session-history-entry:non-fetch-scheme-navigation-params-4">non-fetch scheme navigation params</a>),
        then:</p>

        <ol><li><p><a id="populating-a-session-history-entry:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigationParams</var>'s <a href="#navigation-params-request" id="populating-a-session-history-entry:navigation-params-request-2">request</a> is not null.</p></li><li><p>Set <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-18">document state</a>'s
         <a href="#document-state-request-referrer" id="populating-a-session-history-entry:document-state-request-referrer-2">request referrer</a> to
         <var>navigationParams</var>'s <a href="#navigation-params-request" id="populating-a-session-history-entry:navigation-params-request-3">request</a>'s
         <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="populating-a-session-history-entry:concept-request-referrer" data-x-internal="concept-request-referrer">referrer</a>.</p></li></ol>
       </li></ol>
     </li><li><p>Run <var>completionSteps</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="create-navigation-params-from-a-srcdoc-resource">create navigation params from a srcdoc resource</dfn> given a <a href="#session-history-entry" id="populating-a-session-history-entry:session-history-entry-5">session history
  entry</a> <var>entry</var>, a <a href="#navigable" id="populating-a-session-history-entry:navigable-4">navigable</a> <var>navigable</var>, a <a href="#target-snapshot-params" id="populating-a-session-history-entry:target-snapshot-params-2">target
  snapshot params</a> <var>targetSnapshotParams</var>, a <a href="#user-navigation-involvement" id="populating-a-session-history-entry:user-navigation-involvement-2">user navigation involvement</a>
  <var>userInvolvement</var>, a <a href="#navigation-id" id="populating-a-session-history-entry:navigation-id-2">navigation ID</a>-or-null <var>navigationId</var>, and a
  <code id="populating-a-session-history-entry:navigationtimingtype-2"><a data-x-internal="navigationtimingtype" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype">NavigationTimingType</a></code> <var>navTimingType</var>:</p>

  <ol><li><p>Let <var>documentResource</var> be <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-19">document state</a>'s <a href="#document-state-resource" id="populating-a-session-history-entry:document-state-resource-3">resource</a>.</p></li><li>
    <p>Let <var>response</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-response" id="populating-a-session-history-entry:concept-response" data-x-internal="concept-response">response</a> with</p>

    <dl class="props"><dt><a href="https://fetch.spec.whatwg.org/#concept-response-url" id="populating-a-session-history-entry:concept-response-url-2" data-x-internal="concept-response-url">URL</a></dt><dd><code id="populating-a-session-history-entry:about:srcdoc"><a href="#about:srcdoc">about:srcdoc</a></code></dd><dt><a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="populating-a-session-history-entry:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a></dt><dd>« (`<code id="populating-a-session-history-entry:content-type"><a href="#content-type">Content-Type</a></code>`, `<code>text/html</code>`) »</dd><dt><a href="https://fetch.spec.whatwg.org/#concept-response-body" id="populating-a-session-history-entry:concept-response-body" data-x-internal="concept-response-body">body</a></dt><dd>the <a href="https://encoding.spec.whatwg.org/#utf-8-encode" id="populating-a-session-history-entry:utf-8-encode" data-x-internal="utf-8-encode">UTF-8 encoding</a> of <var>documentResource</var>,
     <a id="populating-a-session-history-entry:as-a-body" href="https://fetch.spec.whatwg.org/#byte-sequence-as-a-body" data-x-internal="as-a-body">as a body</a></dd></dl>
   </li><li><p>Let <var>responseOrigin</var> be the result of <a href="#determining-the-origin" id="populating-a-session-history-entry:determining-the-origin">determining the origin</a> given
   <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="populating-a-session-history-entry:concept-response-url-3" data-x-internal="concept-response-url">URL</a>,
   <var>targetSnapshotParams</var>'s <a href="#target-snapshot-params-sandbox" id="populating-a-session-history-entry:target-snapshot-params-sandbox-2">sandboxing
   flags</a>, and <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-20">document state</a>'s
   <a href="#document-state-origin" id="populating-a-session-history-entry:document-state-origin-2">origin</a>.</p></li><li><p>Let <var>coop</var> be a new <a href="#cross-origin-opener-policy" id="populating-a-session-history-entry:cross-origin-opener-policy">opener policy</a>.</p></li><li>
    <p>Let <var>coopEnforcementResult</var> be a new <a href="#coop-enforcement-result" id="populating-a-session-history-entry:coop-enforcement-result">opener
    policy enforcement result</a> with</p>

    <dl class="props"><dt><a href="#coop-enforcement-url" id="populating-a-session-history-entry:coop-enforcement-url">url</a></dt><dd><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="populating-a-session-history-entry:concept-response-url-4" data-x-internal="concept-response-url">URL</a></dd><dt><a href="#coop-enforcement-origin" id="populating-a-session-history-entry:coop-enforcement-origin">origin</a></dt><dd><var>responseOrigin</var></dd><dt><a href="#coop-enforcement-coop" id="populating-a-session-history-entry:coop-enforcement-coop">opener policy</a></dt><dd><var>coop</var></dd></dl>
   </li><li><p>Let <var>policyContainer</var> be the result of <a href="#determining-navigation-params-policy-container" id="populating-a-session-history-entry:determining-navigation-params-policy-container">determining navigation params policy container</a> given
   <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="populating-a-session-history-entry:concept-response-url-5" data-x-internal="concept-response-url">URL</a>, <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-21">document state</a>'s <a href="#document-state-history-policy-container" id="populating-a-session-history-entry:document-state-history-policy-container-2">history policy container</a>, null,
   <var>navigable</var>'s <a href="#nav-container-document" id="populating-a-session-history-entry:nav-container-document">container document</a>'s <a href="#concept-document-policy-container" id="populating-a-session-history-entry:concept-document-policy-container">policy container</a>, and null.</p></li><li>
    <p>Return a new <a href="#navigation-params" id="populating-a-session-history-entry:navigation-params-4">navigation params</a>, with</p>

    <dl class="props"><dt><a href="#navigation-params-id" id="populating-a-session-history-entry:navigation-params-id">id</a></dt><dd><var>navigationId</var></dd><dt><a href="#navigation-params-navigable" id="populating-a-session-history-entry:navigation-params-navigable">navigable</a></dt><dd><var>navigable</var></dd><dt><a href="#navigation-params-request" id="populating-a-session-history-entry:navigation-params-request-4">request</a></dt><dd>null</dd><dt><a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-9">response</a></dt><dd><var>response</var></dd><dt><a href="#navigation-params-fetch-controller" id="populating-a-session-history-entry:navigation-params-fetch-controller">fetch controller</a></dt><dd>null</dd><dt><a href="#navigation-params-commit-early-hints" id="populating-a-session-history-entry:navigation-params-commit-early-hints">commit early hints</a></dt><dd>null</dd><dt><a href="#navigation-params-coop-enforcement-result" id="populating-a-session-history-entry:navigation-params-coop-enforcement-result">COOP enforcement result</a></dt><dd><var>coopEnforcementResult</var></dd><dt><a href="#navigation-params-reserved-environment" id="populating-a-session-history-entry:navigation-params-reserved-environment-3">reserved environment</a></dt><dd>null</dd><dt><a href="#navigation-params-origin" id="populating-a-session-history-entry:navigation-params-origin-2">origin</a></dt><dd><var>responseOrigin</var></dd><dt><a href="#navigation-params-policy-container" id="populating-a-session-history-entry:navigation-params-policy-container-5">policy container</a></dt><dd><var>policyContainer</var></dd><dt><a href="#navigation-params-sandboxing" id="populating-a-session-history-entry:navigation-params-sandboxing-2">final sandboxing flag set</a></dt><dd><var>targetSnapshotParams</var>'s <a href="#target-snapshot-params-sandbox" id="populating-a-session-history-entry:target-snapshot-params-sandbox-3">sandboxing
     flags</a></dd><dt><a href="#navigation-params-coop" id="populating-a-session-history-entry:navigation-params-coop">opener policy</a></dt><dd><var>coop</var></dd><dt><a href="#navigation-params-nav-timing-type" id="populating-a-session-history-entry:navigation-params-nav-timing-type">navigation timing type</a></dt><dd><var>navTimingType</var></dd><dt><a href="#navigation-params-about-base-url" id="populating-a-session-history-entry:navigation-params-about-base-url">about base URL</a></dt><dd><var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-22">document state</a>'s <a href="#document-state-about-base-url" id="populating-a-session-history-entry:document-state-about-base-url">about base URL</a></dd><dt><a href="#navigation-params-user-involvement" id="populating-a-session-history-entry:navigation-params-user-involvement">user involvement</a></dt><dd><var>userInvolvement</var></dd></dl>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p id="process-a-navigate-fetch">To <dfn id="create-navigation-params-by-fetching">create navigation params by fetching</dfn> given a
  <a href="#session-history-entry" id="populating-a-session-history-entry:session-history-entry-6">session history entry</a> <var>entry</var>, a <a href="#navigable" id="populating-a-session-history-entry:navigable-5">navigable</a>
  <var>navigable</var>, a <a href="#source-snapshot-params" id="populating-a-session-history-entry:source-snapshot-params-2">source snapshot params</a> <var>sourceSnapshotParams</var>, a
  <a href="#target-snapshot-params" id="populating-a-session-history-entry:target-snapshot-params-3">target snapshot params</a> <var>targetSnapshotParams</var>, a string
  <var>cspNavigationType</var>, a <a href="#user-navigation-involvement" id="populating-a-session-history-entry:user-navigation-involvement-3">user navigation involvement</a>
  <var>userInvolvement</var>, a <a href="#navigation-id" id="populating-a-session-history-entry:navigation-id-3">navigation ID</a>-or-null <var>navigationId</var>, and a
  <code id="populating-a-session-history-entry:navigationtimingtype-3"><a data-x-internal="navigationtimingtype" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype">NavigationTimingType</a></code> <var>navTimingType</var>, perform the following steps. They
  return a <a href="#navigation-params" id="populating-a-session-history-entry:navigation-params-5">navigation params</a>, a <a href="#non-fetch-scheme-navigation-params" id="populating-a-session-history-entry:non-fetch-scheme-navigation-params-5">non-fetch scheme navigation params</a>, or
  null.</p>

  <p class="note">This algorithm mutates <var>entry</var>.</p>

  <ol><li><p><a id="populating-a-session-history-entry:assert-5" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running <a href="#in-parallel" id="populating-a-session-history-entry:in-parallel-2">in parallel</a>.</p></li><li><p>Let <var>documentResource</var> be <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-23">document state</a>'s <a href="#document-state-resource" id="populating-a-session-history-entry:document-state-resource-4">resource</a>.</p></li><li>
    <p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="populating-a-session-history-entry:concept-request" data-x-internal="concept-request">request</a>, with</p>

    <dl class="props"><dt><a href="https://fetch.spec.whatwg.org/#concept-request-url" id="populating-a-session-history-entry:concept-request-url" data-x-internal="concept-request-url">url</a></dt><dd><var>entry</var>'s <a href="#she-url" id="populating-a-session-history-entry:she-url-4">URL</a></dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-client" id="populating-a-session-history-entry:concept-request-client" data-x-internal="concept-request-client">client</a></dt><dd><var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-client" id="populating-a-session-history-entry:source-snapshot-params-client">fetch
     client</a></dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="populating-a-session-history-entry:concept-request-destination" data-x-internal="concept-request-destination">destination</a></dt><dd>"<code>document</code>" <span class="note">The destination is updated below when
     <var>navigable</var> has a <a href="#nav-container" id="populating-a-session-history-entry:nav-container">container</a>.</span></dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="populating-a-session-history-entry:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a></dt><dd>"<code>include</code>"</dd><dt><a id="populating-a-session-history-entry:use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a></dt><dd>set</dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-redirect-mode" id="populating-a-session-history-entry:concept-request-redirect-mode" data-x-internal="concept-request-redirect-mode">redirect mode</a></dt><dd>"<code>manual</code>"</dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-replaces-client-id" id="populating-a-session-history-entry:concept-request-replaces-client-id" data-x-internal="concept-request-replaces-client-id">replaces client id</a></dt><dd><var>navigable</var>'s <a href="#nav-document" id="populating-a-session-history-entry:nav-document-2">active document</a>'s <a href="#relevant-settings-object" id="populating-a-session-history-entry:relevant-settings-object">relevant
     settings object</a>'s <a href="#concept-environment-id" id="populating-a-session-history-entry:concept-environment-id">id</a></dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="populating-a-session-history-entry:concept-request-mode" data-x-internal="concept-request-mode">mode</a></dt><dd>"<code>navigate</code>"</dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="populating-a-session-history-entry:concept-request-referrer-2" data-x-internal="concept-request-referrer">referrer</a></dt><dd><var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-24">document state</a>'s <a href="#document-state-request-referrer" id="populating-a-session-history-entry:document-state-request-referrer-3">request referrer</a></dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-referrer-policy" id="populating-a-session-history-entry:concept-request-referrer-policy" data-x-internal="concept-request-referrer-policy">referrer policy</a></dt><dd><var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-25">document state</a>'s <a href="#document-state-request-referrer-policy" id="populating-a-session-history-entry:document-state-request-referrer-policy">request referrer policy</a></dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-policy-container" id="populating-a-session-history-entry:concept-request-policy-container" data-x-internal="concept-request-policy-container">policy container</a></dt><dd><var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-policy-container" id="populating-a-session-history-entry:source-snapshot-params-policy-container">source policy container</a></dd><dt><a href="https://fetch.spec.whatwg.org/#concept-request-window" id="populating-a-session-history-entry:concept-request-traversable-for-user-prompts" data-x-internal="concept-request-traversable-for-user-prompts">traversable for user prompts</a></dt><dd><var>navigable</var>'s <a href="#nav-top" id="populating-a-session-history-entry:nav-top">top-level traversable</a></dd></dl>
   </li><li><p>If <var>navigable</var> is a <a href="#top-level-traversable" id="populating-a-session-history-entry:top-level-traversable">top-level traversable</a>, then set
   <var>request</var>'s <a id="populating-a-session-history-entry:top-level-navigation-initiator-origin" href="https://fetch.spec.whatwg.org/#request-top-level-navigation-initiator-origin" data-x-internal="top-level-navigation-initiator-origin">top-level navigation initiator origin</a> to <var>entry</var>'s
   <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-26">document state</a>'s <a href="#document-state-initiator-origin" id="populating-a-session-history-entry:document-state-initiator-origin-3">initiator origin</a>.</p></li><li>
    <p>If <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="populating-a-session-history-entry:concept-request-client-2" data-x-internal="concept-request-client">client</a> is null:</p>

    <p class="note">This <a href="#assert-null-sourcedocument">only occurs</a> in the case of a
    browser UI-initiated navigation.</p>

    <ol><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-origin" id="populating-a-session-history-entry:concept-request-origin" data-x-internal="concept-request-origin">origin</a> to a new
     <a href="#concept-origin-opaque" id="populating-a-session-history-entry:concept-origin-opaque">opaque origin</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-service-workers-mode" id="populating-a-session-history-entry:concept-request-service-workers-mode" data-x-internal="concept-request-service-workers-mode">service-workers mode</a> to "<code>all</code>".</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="populating-a-session-history-entry:concept-request-referrer-3" data-x-internal="concept-request-referrer">referrer</a> to
     "<code>no-referrer</code>".</p></li></ol>
   </li><li>
    <p>If <var>documentResource</var> is a <a href="#post-resource" id="populating-a-session-history-entry:post-resource">POST resource</a>:</p>

    <ol><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-method" id="populating-a-session-history-entry:concept-request-method" data-x-internal="concept-request-method">method</a> to `<code>POST</code>`.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-body" id="populating-a-session-history-entry:concept-request-body" data-x-internal="concept-request-body">body</a> to
     <var>documentResource</var>'s <a href="#post-resource-request-body" id="populating-a-session-history-entry:post-resource-request-body-2">request
     body</a>.</p></li><li><p><a href="https://fetch.spec.whatwg.org/#concept-header-list-set" id="populating-a-session-history-entry:concept-header-list-set" data-x-internal="concept-header-list-set">Set</a> `<code>Content-Type</code>`
     to <var>documentResource</var>'s <a href="#post-resource-request-content-type" id="populating-a-session-history-entry:post-resource-request-content-type">request
     content-type</a> in <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-header-list" id="populating-a-session-history-entry:concept-request-header-list" data-x-internal="concept-request-header-list">header
     list</a>.</p></li></ol>
   </li><li><p>If <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-27">document state</a>'s <a href="#document-state-reload-pending" id="populating-a-session-history-entry:document-state-reload-pending">reload pending</a> is true, then set
   <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reload-navigation-flag" id="populating-a-session-history-entry:concept-request-reload-navigation-flag" data-x-internal="concept-request-reload-navigation-flag">reload-navigation
   flag</a>.</p></li><li><p>Otherwise, if <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-28">document
   state</a>'s <a href="#document-state-ever-populated" id="populating-a-session-history-entry:document-state-ever-populated-2">ever populated</a> is true, then
   set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-history-navigation-flag" id="populating-a-session-history-entry:concept-request-history-navigation-flag" data-x-internal="concept-request-history-navigation-flag">history-navigation flag</a>.</p></li><li><p>If <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-activation" id="populating-a-session-history-entry:source-snapshot-params-activation-2">has
   transient activation</a> is true, then set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-user-activation" id="populating-a-session-history-entry:concept-request-user-activation" data-x-internal="concept-request-user-activation">user-activation</a> to true.</p></li><li>
    <p>If <var>navigable</var>'s <a href="#nav-container" id="populating-a-session-history-entry:nav-container-2">container</a> is non-null:</p>

    <ol><li><p>If the <var>navigable</var>'s <a href="#nav-container" id="populating-a-session-history-entry:nav-container-3">container</a> has a
     <a href="#browsing-context-scope-origin" id="populating-a-session-history-entry:browsing-context-scope-origin">browsing context scope origin</a>, then set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-origin" id="populating-a-session-history-entry:concept-request-origin-2" data-x-internal="concept-request-origin">origin</a> to that <a href="#browsing-context-scope-origin" id="populating-a-session-history-entry:browsing-context-scope-origin-2">browsing context scope
     origin</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="populating-a-session-history-entry:concept-request-destination-2" data-x-internal="concept-request-destination">destination</a>
     to <var>navigable</var>'s <a href="#nav-container" id="populating-a-session-history-entry:nav-container-4">container</a>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="populating-a-session-history-entry:concept-element-local-name" data-x-internal="concept-element-local-name">local name</a>.</p></li><li>
      <p>If <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-client" id="populating-a-session-history-entry:source-snapshot-params-client-2">fetch
      client</a> is <var>navigable</var>'s <a href="#nav-container-document" id="populating-a-session-history-entry:nav-container-document-2">container
      document</a>'s <a href="#relevant-settings-object" id="populating-a-session-history-entry:relevant-settings-object-2">relevant settings object</a>, then set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="populating-a-session-history-entry:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator type</a> to <var>navigable</var>'s <a href="#nav-container" id="populating-a-session-history-entry:nav-container-5">container</a>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="populating-a-session-history-entry:concept-element-local-name-2" data-x-internal="concept-element-local-name">local
      name</a>.</p>

      <p class="note">This ensure that only container-initiated navigations are reported to
      resource timing.</p>
     </li></ol>
   </li><li><p>Let <var>response</var> be null.</p></li><li><p>Let <var>responseOrigin</var> be null.</p></li><li><p>Let <var>fetchController</var> be null.</p></li><li>
    <p>Let <var>coopEnforcementResult</var> be a new <a href="#coop-enforcement-result" id="populating-a-session-history-entry:coop-enforcement-result-2">opener
    policy enforcement result</a>, with</p>

    <dl class="props"><dt><a href="#coop-enforcement-url" id="populating-a-session-history-entry:coop-enforcement-url-2">url</a></dt><dd><var>navigable</var>'s <a href="#nav-document" id="populating-a-session-history-entry:nav-document-3">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="populating-a-session-history-entry:the-document's-address-2" data-x-internal="the-document's-address">URL</a></dd><dt><a href="#coop-enforcement-origin" id="populating-a-session-history-entry:coop-enforcement-origin-2">origin</a></dt><dd><var>navigable</var>'s <a href="#nav-document" id="populating-a-session-history-entry:nav-document-4">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="populating-a-session-history-entry:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a></dd><dt><a href="#coop-enforcement-coop" id="populating-a-session-history-entry:coop-enforcement-coop-2">opener policy</a></dt><dd><var>navigable</var>'s <a href="#nav-document" id="populating-a-session-history-entry:nav-document-5">active document</a>'s <a href="#concept-document-coop" id="populating-a-session-history-entry:concept-document-coop">opener policy</a></dd><dt><a href="#coop-enforcement-source" id="populating-a-session-history-entry:coop-enforcement-source">current context is navigation source</a></dt><dd>true if <var>navigable</var>'s <a href="#nav-document" id="populating-a-session-history-entry:nav-document-6">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="populating-a-session-history-entry:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a> is <a href="#same-origin" id="populating-a-session-history-entry:same-origin">same origin</a> with
     <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-29">document state</a>'s <a href="#document-state-initiator-origin" id="populating-a-session-history-entry:document-state-initiator-origin-4">initiator origin</a> otherwise false</dd></dl>
   </li><li><p>Let <var>finalSandboxFlags</var> be an empty <a href="#sandboxing-flag-set" id="populating-a-session-history-entry:sandboxing-flag-set">sandboxing flag set</a>.</p></li><li><p>Let <var>responsePolicyContainer</var> be null.</p></li><li><p>Let <var>responseCOOP</var> be a new <a href="#cross-origin-opener-policy" id="populating-a-session-history-entry:cross-origin-opener-policy-2">opener policy</a>.</p></li><li><p>Let <var>locationURL</var> be null.</p></li><li><p>Let <var>currentURL</var> be <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-current-url" id="populating-a-session-history-entry:concept-request-current-url" data-x-internal="concept-request-current-url">current URL</a>.</p></li><li><p>Let <var>commitEarlyHints</var> be null.</p></li><li>
    <p>While true:</p>

    <ol><li>
      <p>If <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client" data-x-internal="concept-request-reserved-client">reserved
      client</a> is not null and <var>currentURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="populating-a-session-history-entry:concept-url-origin" data-x-internal="concept-url-origin">origin</a> is not the <a href="#same-origin" id="populating-a-session-history-entry:same-origin-2">same</a>
      as <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client-2" data-x-internal="concept-request-reserved-client">reserved
      client</a>'s <a href="#concept-environment-creation-url" id="populating-a-session-history-entry:concept-environment-creation-url">creation URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="populating-a-session-history-entry:concept-url-origin-2" data-x-internal="concept-url-origin">origin</a>, then:</p>

      <ol><li><p>Run the <a href="#environment-discarding-steps" id="populating-a-session-history-entry:environment-discarding-steps-2">environment discarding steps</a> for <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client-3" data-x-internal="concept-request-reserved-client">reserved client</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client-4" data-x-internal="concept-request-reserved-client">reserved
       client</a> to null.</p></li><li>
        <p>Set <var>commitEarlyHints</var> to null.</p>

        <p class="note">Preloaded links from <a href="#early-hints-2" id="populating-a-session-history-entry:early-hints-2">early hint headers</a>
        remain in the preload cache after a <a href="#same-origin" id="populating-a-session-history-entry:same-origin-3">same origin</a> redirect, but get discarded
        when the redirect is cross-origin.</p>
       </li></ol>
     </li><li>
      <p>If <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client-5" data-x-internal="concept-request-reserved-client">reserved
      client</a> is null, then:</p>

      <ol><li><p>Let <var>topLevelCreationURL</var> be <var>currentURL</var>.</p></li><li><p>Let <var>topLevelOrigin</var> be null.</p></li><li>
        <p>If <var>navigable</var> is not a <a href="#top-level-traversable" id="populating-a-session-history-entry:top-level-traversable-2">top-level traversable</a>, then:</p>

        <ol><li><p>Let <var>parentEnvironment</var> be <var>navigable</var>'s <a href="#nav-parent" id="populating-a-session-history-entry:nav-parent">parent</a>'s <a href="#nav-document" id="populating-a-session-history-entry:nav-document-7">active document</a>'s
         <a href="#relevant-settings-object" id="populating-a-session-history-entry:relevant-settings-object-3">relevant settings object</a>.</p></li><li><p>Set <var>topLevelCreationURL</var> to <var>parentEnvironment</var>'s
         <a href="#concept-environment-top-level-creation-url" id="populating-a-session-history-entry:concept-environment-top-level-creation-url">top-level creation URL</a>.</p></li><li><p>Set <var>topLevelOrigin</var> to <var>parentEnvironment</var>'s <a href="#concept-environment-top-level-origin" id="populating-a-session-history-entry:concept-environment-top-level-origin">top-level
         origin</a>.</p></li></ol>
       </li><li>
        <p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client-6" data-x-internal="concept-request-reserved-client">reserved
        client</a> to a new <a href="#environment" id="populating-a-session-history-entry:environment">environment</a> whose <a href="#concept-environment-id" id="populating-a-session-history-entry:concept-environment-id-2">id</a> is a unique opaque string, <a href="#concept-environment-target-browsing-context" id="populating-a-session-history-entry:concept-environment-target-browsing-context">target browsing context</a> is
        <var>navigable</var>'s <a href="#nav-bc" id="populating-a-session-history-entry:nav-bc">active browsing context</a>, <a href="#concept-environment-creation-url" id="populating-a-session-history-entry:concept-environment-creation-url-2">creation URL</a> is <var>currentURL</var>,
        <a href="#concept-environment-top-level-creation-url" id="populating-a-session-history-entry:concept-environment-top-level-creation-url-2">top-level creation URL</a> is <var>topLevelCreationURL</var>, and <a href="#concept-environment-top-level-origin" id="populating-a-session-history-entry:concept-environment-top-level-origin-2">top-level
        origin</a> is <var>topLevelOrigin</var>.</p>

        <p class="note">The created environment's <a href="#concept-environment-active-service-worker" id="populating-a-session-history-entry:concept-environment-active-service-worker">active service worker</a> is set in
        the <a href="https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm" id="populating-a-session-history-entry:on-fetch-request-algorithm" data-x-internal="on-fetch-request-algorithm">Handle Fetch</a> algorithm during the fetch
        if the request URL matches a service worker registration. <a href="#refsSW">[SW]</a></p>
       </li></ol>
     </li><li><p>If the result of <a id="populating-a-session-history-entry:should-navigation-request-of-type-be-blocked-by-content-security-policy" href="https://w3c.github.io/webappsec-csp/#should-block-navigation-request" data-x-internal="should-navigation-request-of-type-be-blocked-by-content-security-policy">should navigation request of type be blocked by Content Security
     Policy?</a> given <var>request</var> and <var>cspNavigationType</var> is "<code>Blocked</code>", then set <var>response</var> to a <a id="populating-a-session-history-entry:network-error" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a> and
     <a id="populating-a-session-history-entry:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>. <a href="#refsCSP">[CSP]</a></p></li><li><p>Set <var>response</var> to null.</p></li><li>
      <p>If <var>fetchController</var> is null, then set <var>fetchController</var> to the result
      of <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="populating-a-session-history-entry:concept-fetch" data-x-internal="concept-fetch">fetching</a> <var>request</var>, with <i id="populating-a-session-history-entry:processearlyhintsresponse"><a data-x-internal="processearlyhintsresponse" href="https://fetch.spec.whatwg.org/#fetch-processearlyhintsresponse">processEarlyHintsResponse</a></i> set to
      <var>processEarlyHintsResponse</var> as defined below, <i id="populating-a-session-history-entry:processresponse"><a data-x-internal="processresponse" href="https://fetch.spec.whatwg.org/#process-response">processResponse</a></i> set to <var>processResponse</var> as defined
      below, and <i id="populating-a-session-history-entry:useparallelqueue"><a data-x-internal="useparallelqueue" href="https://fetch.spec.whatwg.org/#fetch-useparallelqueue">useParallelQueue</a></i> set to true.</p>

      <p>Let <var>processEarlyHintsResponse</var> be the following algorithm given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="populating-a-session-history-entry:concept-response-2" data-x-internal="concept-response">response</a> <var>earlyResponse</var>:</p>

      <ol><li><p>If <var>commitEarlyHints</var> is null, then set <var>commitEarlyHints</var> to the
       result of <a href="#process-early-hint-headers" id="populating-a-session-history-entry:process-early-hint-headers">processing early hint headers</a>
       given <var>earlyResponse</var> and <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client-7" data-x-internal="concept-request-reserved-client">reserved client</a>.</p></li></ol>

      <p>Let <var>processResponse</var> be the following algorithm given a <a href="https://fetch.spec.whatwg.org/#concept-response" id="populating-a-session-history-entry:concept-response-3" data-x-internal="concept-response">response</a> <var>fetchedResponse</var>:</p>

      <ol><li><p>Set <var>response</var> to <var>fetchedResponse</var>.</p></li></ol>
     </li><li>
      <p>Otherwise, <a id="populating-a-session-history-entry:process-the-next-manual-redirect" href="https://fetch.spec.whatwg.org/#fetch-controller-process-the-next-manual-redirect" data-x-internal="process-the-next-manual-redirect">process the next manual redirect</a> for
      <var>fetchController</var>.</p>

      <p class="note">This will result in calling the <i id="populating-a-session-history-entry:processresponse-2"><a data-x-internal="processresponse" href="https://fetch.spec.whatwg.org/#process-response">processResponse</a></i> we supplied above, during our first iteration
      through the loop, and thus setting <var>response</var>.</p>

      <p class="note">Navigation handles redirects manually as navigation is the only place in the
      web platform that cares for redirects to <code id="populating-a-session-history-entry:mailto-protocol"><a data-x-internal="mailto-protocol" href="https://www.rfc-editor.org/rfc/rfc6068#section-2">mailto:</a></code> URLs
      and such.</p>
     </li><li>
      <p>Wait until either <var>response</var> is non-null, or <var>navigable</var>'s <a href="#ongoing-navigation" id="populating-a-session-history-entry:ongoing-navigation-2">ongoing
      navigation</a> changes to no longer equal <var>navigationId</var>.</p>

      <p>If the latter condition occurs, then <a href="https://fetch.spec.whatwg.org/#fetch-controller-abort" id="populating-a-session-history-entry:fetch-controller-abort" data-x-internal="fetch-controller-abort">abort</a>
      <var>fetchController</var>, and return.</p>

      <p>Otherwise, proceed onward.</p>
     </li><li>
      <p>If <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-body" id="populating-a-session-history-entry:concept-request-body-2" data-x-internal="concept-request-body">body</a> is null, then set
      <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-30">document state</a>'s <a href="#document-state-resource" id="populating-a-session-history-entry:document-state-resource-5">resource</a> to null.</p>

      <p class="note">Fetch unsets the <a href="https://fetch.spec.whatwg.org/#concept-request-body" id="populating-a-session-history-entry:concept-request-body-3" data-x-internal="concept-request-body">body</a> for
      particular redirects.</p>
     </li><li><p>Set <var>responsePolicyContainer</var> to the result of <a href="#creating-a-policy-container-from-a-fetch-response" id="populating-a-session-history-entry:creating-a-policy-container-from-a-fetch-response">creating a policy
     container from a fetch response</a> given <var>response</var> and <var>request</var>'s
     <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client-8" data-x-internal="concept-request-reserved-client">reserved client</a>.</p></li><li><p>Set <var>finalSandboxFlags</var> to the <a href="https://infra.spec.whatwg.org/#set-union" id="populating-a-session-history-entry:set-union" data-x-internal="set-union">union</a> of
     <var>targetSnapshotParams</var>'s <a href="#target-snapshot-params-sandbox" id="populating-a-session-history-entry:target-snapshot-params-sandbox-4">sandboxing
     flags</a> and <var>responsePolicyContainer</var>'s <a href="#policy-container-csp-list" id="populating-a-session-history-entry:policy-container-csp-list-3">CSP list</a>'s <a href="#csp-derived-sandboxing-flags" id="populating-a-session-history-entry:csp-derived-sandboxing-flags">CSP-derived sandboxing
     flags</a>.</p></li><li>
      <p>Set <var>responseOrigin</var> to the result of <a href="#determining-the-origin" id="populating-a-session-history-entry:determining-the-origin-2">determining the origin</a> given
      <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="populating-a-session-history-entry:concept-response-url-6" data-x-internal="concept-response-url">URL</a>,
      <var>finalSandboxFlags</var>, and <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-31">document state</a>'s <a href="#document-state-initiator-origin" id="populating-a-session-history-entry:document-state-initiator-origin-5">initiator origin</a>.</p>

      <p class="note">If <var>response</var> is a redirect, then <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="populating-a-session-history-entry:concept-response-url-7" data-x-internal="concept-response-url">URL</a> will be the URL that led to the redirect to
      <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-location-url" id="populating-a-session-history-entry:concept-response-location-url" data-x-internal="concept-response-location-url">location URL</a>; it
      will not be the <a href="https://fetch.spec.whatwg.org/#concept-response-location-url" id="populating-a-session-history-entry:concept-response-location-url-2" data-x-internal="concept-response-location-url">location URL</a> itself.</p>
     </li><li>
      <p>If <var>navigable</var> is a <a href="#top-level-traversable" id="populating-a-session-history-entry:top-level-traversable-3">top-level traversable</a>, then:</p>

      <ol><li><p>Set <var>responseCOOP</var> to the result of <a href="#obtain-coop" id="populating-a-session-history-entry:obtain-coop">obtaining an
       opener policy</a> given <var>response</var> and <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client-9" data-x-internal="concept-request-reserved-client">reserved client</a>.</p></li><li><p>Set <var>coopEnforcementResult</var> to the result of <a href="#coop-enforce" id="populating-a-session-history-entry:coop-enforce">enforcing the response's opener policy</a> given
       <var>navigable</var>'s <a href="#nav-bc" id="populating-a-session-history-entry:nav-bc-2">active browsing context</a>,
       <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="populating-a-session-history-entry:concept-response-url-8" data-x-internal="concept-response-url">URL</a>,
       <var>responseOrigin</var>, <var>responseCOOP</var>, <var>coopEnforcementResult</var>, and
       <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="populating-a-session-history-entry:concept-request-referrer-4" data-x-internal="concept-request-referrer">referrer</a>.</p></li><li>
        <p>If <var>finalSandboxFlags</var> is not empty and <var>responseCOOP</var>'s <a href="#coop-struct-value" id="populating-a-session-history-entry:coop-struct-value">value</a> is not "<code id="populating-a-session-history-entry:coop-unsafe-none"><a href="#coop-unsafe-none">unsafe-none</a></code>", then set <var>response</var> to an
        appropriate <a id="populating-a-session-history-entry:network-error-2" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a> and <a id="populating-a-session-history-entry:break-2" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p>

        <p class="note">This results in a network error as one cannot simultaneously provide a clean
        slate to a response using opener policy and sandbox the result of
        navigating to that response.</p>
       </li></ol>
     </li><li>
      <p>If <var>response</var> is not a <a id="populating-a-session-history-entry:network-error-3" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>, <var>navigable</var> is a
      <a href="#child-navigable" id="populating-a-session-history-entry:child-navigable">child navigable</a>, and the result of performing a <a id="populating-a-session-history-entry:cross-origin-resource-policy-check" href="https://fetch.spec.whatwg.org/#cross-origin-resource-policy-check" data-x-internal="cross-origin-resource-policy-check">cross-origin resource
      policy check</a> with <var>navigable</var>'s <a href="#nav-container-document" id="populating-a-session-history-entry:nav-container-document-3">container document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="populating-a-session-history-entry:concept-document-origin-4" data-x-internal="concept-document-origin">origin</a>, <var>navigable</var>'s <a href="#nav-container-document" id="populating-a-session-history-entry:nav-container-document-4">container document</a>'s <a href="#relevant-settings-object" id="populating-a-session-history-entry:relevant-settings-object-4">relevant settings
      object</a>, <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="populating-a-session-history-entry:concept-request-destination-3" data-x-internal="concept-request-destination">destination</a>, <var>response</var>, and true is
      <b>blocked</b>, then set <var>response</var> to a <a id="populating-a-session-history-entry:network-error-4" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a> and
      <a id="populating-a-session-history-entry:break-3" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p>

      <p class="note">Here we're running the <a id="populating-a-session-history-entry:cross-origin-resource-policy-check-2" href="https://fetch.spec.whatwg.org/#cross-origin-resource-policy-check" data-x-internal="cross-origin-resource-policy-check">cross-origin resource policy check</a>
      against the <a href="#nav-parent" id="populating-a-session-history-entry:nav-parent-2">parent navigable</a> rather than
      <var>navigable</var> itself. This is because we care about the same-originness of the
      embedded content against the parent context, not the navigation source.</p>
     </li><li><p>Set <var>locationURL</var> to <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-location-url" id="populating-a-session-history-entry:concept-response-location-url-3" data-x-internal="concept-response-location-url">location URL</a> given <var>currentURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="populating-a-session-history-entry:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a>.</p></li><li><p>If <var>locationURL</var> is failure or null, then <a id="populating-a-session-history-entry:break-4" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li><li><p><a id="populating-a-session-history-entry:assert-6" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>locationURL</var> is a <a id="populating-a-session-history-entry:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p></li><li><p>Set <var>entry</var>'s <a href="#she-classic-history-api-state" id="populating-a-session-history-entry:she-classic-history-api-state">classic history API
     state</a> to <a href="#structuredserializeforstorage" id="populating-a-session-history-entry:structuredserializeforstorage">StructuredSerializeForStorage</a>(null).</p></li><li><p>Let <var>oldDocState</var> be <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-32">document state</a>.</p></li><li>
      <p>Set <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-33">document state</a> to a new
      <a href="#document-state-2" id="populating-a-session-history-entry:document-state-2">document state</a>, with

      </p><dl class="props"><dt><a href="#document-state-history-policy-container" id="populating-a-session-history-entry:document-state-history-policy-container-3">history policy container</a></dt><dd>a <a href="#clone-a-policy-container" id="populating-a-session-history-entry:clone-a-policy-container">clone</a> of the <var>oldDocState</var>'s
       <a href="#document-state-history-policy-container" id="populating-a-session-history-entry:document-state-history-policy-container-4">history policy container</a> if it
       is non-null; null otherwise</dd><dt><a href="#document-state-request-referrer" id="populating-a-session-history-entry:document-state-request-referrer-4">request referrer</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-request-referrer" id="populating-a-session-history-entry:document-state-request-referrer-5">request
       referrer</a></dd><dt><a href="#document-state-request-referrer-policy" id="populating-a-session-history-entry:document-state-request-referrer-policy-2">request referrer policy</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-request-referrer-policy" id="populating-a-session-history-entry:document-state-request-referrer-policy-3">request
       referrer policy</a></dd><dt><a href="#document-state-initiator-origin" id="populating-a-session-history-entry:document-state-initiator-origin-6">initiator origin</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-initiator-origin" id="populating-a-session-history-entry:document-state-initiator-origin-7">initiator
       origin</a></dd><dt><a href="#document-state-origin" id="populating-a-session-history-entry:document-state-origin-3">origin</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-origin" id="populating-a-session-history-entry:document-state-origin-4">origin</a></dd><dt><a href="#document-state-about-base-url" id="populating-a-session-history-entry:document-state-about-base-url-2">about base URL</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-about-base-url" id="populating-a-session-history-entry:document-state-about-base-url-3">about base URL</a></dd><dt><a href="#document-state-resource" id="populating-a-session-history-entry:document-state-resource-6">resource</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-resource" id="populating-a-session-history-entry:document-state-resource-7">resource</a></dd><dt><a href="#document-state-ever-populated" id="populating-a-session-history-entry:document-state-ever-populated-3">ever populated</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-ever-populated" id="populating-a-session-history-entry:document-state-ever-populated-4">ever
       populated</a></dd><dt><a href="#document-state-nav-target-name" id="populating-a-session-history-entry:document-state-nav-target-name">navigable target name</a></dt><dd><var>oldDocState</var>'s <a href="#document-state-nav-target-name" id="populating-a-session-history-entry:document-state-nav-target-name-2">navigable target
       name</a></dd></dl>

      
      <p class="note">For the navigation case, only <var>entry</var> referenced
      <var>oldDocState</var>, which was created <a href="#navigation-create-document-state">early
      in the navigate algorithm</a>. So for navigations, this is functionally just an update to
      <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-34">document state</a>. For the traversal
      case, it's possible adjacent <a href="#session-history-entry" id="populating-a-session-history-entry:session-history-entry-7">session history
      entries</a> also reference <var>oldDocState</var>, in which case they will continue doing
      so even after we've updated <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-35">document
      state</a>.</p>

      <p class="note"><var>oldDocState</var>'s <a href="#document-state-history-policy-container" id="populating-a-session-history-entry:document-state-history-policy-container-5">history policy container</a> is only ever
      non-null here in the traversal case, after we've populated it during a navigation to a URL
      that <a href="#requires-storing-the-policy-container-in-history" id="populating-a-session-history-entry:requires-storing-the-policy-container-in-history-2">requires storing the policy container in history</a>.</p>

      <div class="example">
       <p>The setup is given by the following <a href="#jake-diagram" id="populating-a-session-history-entry:jake-diagram">Jake diagram</a>:</p>

       
<table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step">1</th><th class="step">2</th><th class="step current">3</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="1" class="doc-0 next-is-same-doc">/a</td><td colspan="1" class="doc-0 prev-is-same-doc next-is-same-doc">/a#foo</td><td colspan="1" class="doc-0 prev-is-same-doc">/a#bar</td><td colspan="1" class="doc-2 current">/b</td></tr></tbody></table>

       <p>Also assume that the <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-36">document state</a> shared by
       the entries in steps 0, 1, and 2 has a null <a href="#document-state-document" id="populating-a-session-history-entry:document-state-document-12">document</a>, i.e., <a href="#note-bfcache">bfcache</a>
       is not in play.</p>

       <p>Now consider the scenario where we traverse back to step 2, but this time when fetching
       <code>/a</code>, the server responds with a `<code>Location</code>`
       header pointing to <code>/c</code>. That is, <var>locationURL</var> points to
       <code>/c</code> and so we have reached this step instead of <a href="https://infra.spec.whatwg.org/#iteration-break" id="populating-a-session-history-entry:break-5" data-x-internal="break">breaking</a> out of the loop.</p>

       <p>In this case, we replace the <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-37">document state</a> of
       the <a href="#session-history-entry" id="populating-a-session-history-entry:session-history-entry-8">session history entry</a> occupying step 2, but we do <em>not</em> replace the
       document state of the entries occupying steps 0 and 1. The resulting <a href="#jake-diagram" id="populating-a-session-history-entry:jake-diagram-2">Jake
       diagram</a> looks like this:</p>

       
<table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step">1</th><th class="step current">2</th><th class="step">3</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="1" class="doc-0 next-is-same-doc">/a</td><td colspan="1" class="doc-0 prev-is-same-doc">/a#foo</td><td colspan="1" class="doc-1 current">/c#bar</td><td colspan="1" class="doc-2">/b</td></tr></tbody></table>

       <p>Note that we perform this replacement even if we end up in a redirect chain back to the
       original URL, for example if <code>/c</code> itself had a `<code>Location</code>` header pointing to <code>/a</code>. Such a case would
       end up like so:</p>

       
<table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step">1</th><th class="step current">2</th><th class="step">3</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="1" class="doc-0 next-is-same-doc">/a</td><td colspan="1" class="doc-0 prev-is-same-doc">/a#foo</td><td colspan="1" class="doc-1 current">/a#bar</td><td colspan="1" class="doc-2">/b</td></tr></tbody></table>
      </div>
     </li><li>
      <p>If <var>locationURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="populating-a-session-history-entry:concept-url-scheme-3" data-x-internal="concept-url-scheme">scheme</a> is not an
      <a id="populating-a-session-history-entry:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>, then:</p>

      <ol><li><p>Set <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-38">document state</a>'s
       <a href="#document-state-resource" id="populating-a-session-history-entry:document-state-resource-8">resource</a> to null.</p></li><li><p><a id="populating-a-session-history-entry:break-6" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">Break</a>.</p></li></ol>
     </li><li><p>Set <var>currentURL</var> to <var>locationURL</var>.</p></li><li><p>Set <var>entry</var>'s <a href="#she-url" id="populating-a-session-history-entry:she-url-5">URL</a> to
     <var>currentURL</var>.</p></li></ol>

    <div class="note">
     <p>By the end of this loop we will be in one of these scenarios:</p>

     <ul><li><p><var>locationURL</var> is failure, because of an unparseable `<code>Location</code>` header.</p></li><li><p><var>locationURL</var> is null, either because <var>response</var> is a <a id="populating-a-session-history-entry:network-error-5" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network
      error</a> or because we successfully fetched a non-<a id="populating-a-session-history-entry:network-error-6" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a> HTTP(S)
      response with no `<code>Location</code>` header.</p></li><li><p><var>locationURL</var> is a <a id="populating-a-session-history-entry:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> with a non-<a href="https://fetch.spec.whatwg.org/#http-scheme" id="populating-a-session-history-entry:http(s)-scheme-2" data-x-internal="http(s)-scheme">HTTP(S)</a> <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="populating-a-session-history-entry:concept-url-scheme-4" data-x-internal="concept-url-scheme">scheme</a>.</p></li></ul>
    </div>
   </li><li>
    <p>If <var>locationURL</var> is a <a id="populating-a-session-history-entry:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> whose <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="populating-a-session-history-entry:concept-url-scheme-5" data-x-internal="concept-url-scheme">scheme</a> is not a <a id="populating-a-session-history-entry:fetch-scheme-3" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a>, then return a new
    <a href="#non-fetch-scheme-navigation-params" id="populating-a-session-history-entry:non-fetch-scheme-navigation-params-6">non-fetch scheme navigation params</a>, with</p>

    <dl class="props"><dt><a href="#non-fetch-scheme-params-id" id="populating-a-session-history-entry:non-fetch-scheme-params-id-2">id</a></dt><dd><var>navigationId</var></dd><dt><a href="#non-fetch-scheme-params-navigable" id="populating-a-session-history-entry:non-fetch-scheme-params-navigable-2">navigable</a></dt><dd><var>navigable</var></dd><dt><a href="#non-fetch-scheme-params-url" id="populating-a-session-history-entry:non-fetch-scheme-params-url-2">URL</a></dt><dd><var>locationURL</var></dd><dt><a href="#non-fetch-scheme-params-target-sandbox" id="populating-a-session-history-entry:non-fetch-scheme-params-target-sandbox-2">target snapshot sandboxing flags</a></dt><dd><var>targetSnapshotParams</var>'s <a href="#target-snapshot-params-sandbox" id="populating-a-session-history-entry:target-snapshot-params-sandbox-5">sandboxing
     flags</a></dd><dt><a href="#non-fetch-scheme-params-source-activation" id="populating-a-session-history-entry:non-fetch-scheme-params-source-activation-2">source snapshot has transient activation</a></dt><dd><var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-activation" id="populating-a-session-history-entry:source-snapshot-params-activation-3">has
     transient activation</a></dd><dt><a href="#non-fetch-scheme-params-initiator-origin" id="populating-a-session-history-entry:non-fetch-scheme-params-initiator-origin-2">initiator origin</a></dt><dd><var>responseOrigin</var></dd><dt><a href="#non-fetch-scheme-params-nav-timing-type" id="populating-a-session-history-entry:non-fetch-scheme-params-nav-timing-type-2">navigation timing type</a></dt><dd><var>navTimingType</var></dd><dt><a href="#non-fetch-scheme-params-user-involvement" id="populating-a-session-history-entry:non-fetch-scheme-params-user-involvement-2">user involvement</a></dt><dd><var>userInvolvement</var></dd></dl>

    <p class="note">At this point, <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-current-url" id="populating-a-session-history-entry:concept-request-current-url-2" data-x-internal="concept-request-current-url">current URL</a> is the last <a id="populating-a-session-history-entry:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> in the
    redirect chain with a <a href="https://fetch.spec.whatwg.org/#fetch-scheme" id="populating-a-session-history-entry:fetch-scheme-4" data-x-internal="fetch-scheme">fetch</a> <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="populating-a-session-history-entry:concept-url-scheme-6" data-x-internal="concept-url-scheme">scheme</a> before redirecting to a non-<a id="populating-a-session-history-entry:fetch-scheme-5" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a>
    <a id="populating-a-session-history-entry:url-5" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>. It is this <a id="populating-a-session-history-entry:url-6" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="populating-a-session-history-entry:concept-url-origin-3" data-x-internal="concept-url-origin">origin</a>
    that will be used as the initiator origin for navigations to non-<a id="populating-a-session-history-entry:fetch-scheme-6" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a>
    <a href="https://url.spec.whatwg.org/#concept-url" id="populating-a-session-history-entry:url-7" data-x-internal="url">URLs</a>.</p>
   </li><li>
    <p>If any of the following are true:</p>

    <ul><li><p><var>response</var> is a <a id="populating-a-session-history-entry:network-error-7" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>;</p></li><li><p><var>locationURL</var> is failure; or</p></li><li><p><var>locationURL</var> is a <a id="populating-a-session-history-entry:url-8" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> whose <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="populating-a-session-history-entry:concept-url-scheme-7" data-x-internal="concept-url-scheme">scheme</a> is a <a id="populating-a-session-history-entry:fetch-scheme-7" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a>,</p></li></ul>

    <p>then return null.</p>

    <p class="note">We allow redirects to non-<a id="populating-a-session-history-entry:fetch-scheme-8" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a> <a href="https://url.spec.whatwg.org/#concept-url" id="populating-a-session-history-entry:url-9" data-x-internal="url">URLs</a>, but redirects to <a id="populating-a-session-history-entry:fetch-scheme-9" href="https://fetch.spec.whatwg.org/#fetch-scheme" data-x-internal="fetch-scheme">fetch scheme</a> <a href="https://url.spec.whatwg.org/#concept-url" id="populating-a-session-history-entry:url-10" data-x-internal="url">URLs</a> that aren't <a href="https://fetch.spec.whatwg.org/#http-scheme" id="populating-a-session-history-entry:http(s)-scheme-3" data-x-internal="http(s)-scheme">HTTP(S)</a> are treated
    like network errors.</p>
   </li><li><p><a id="populating-a-session-history-entry:assert-7" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>locationURL</var> is null and <var>response</var> is not a
   <a id="populating-a-session-history-entry:network-error-8" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>.</p></li><li><p>Let <var>resultPolicyContainer</var> be the result of <a href="#determining-navigation-params-policy-container" id="populating-a-session-history-entry:determining-navigation-params-policy-container-2">determining navigation params
   policy container</a> given <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="populating-a-session-history-entry:concept-response-url-9" data-x-internal="concept-response-url">URL</a>, <var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-39">document state</a>'s <a href="#document-state-history-policy-container" id="populating-a-session-history-entry:document-state-history-policy-container-6">history policy container</a>,
   <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-policy-container" id="populating-a-session-history-entry:source-snapshot-params-policy-container-2">source
   policy container</a>, null, and <var>responsePolicyContainer</var>.</p></li><li>
    <p>If <var>navigable</var>'s <a href="#nav-container" id="populating-a-session-history-entry:nav-container-6">container</a> is an
    <code id="populating-a-session-history-entry:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, and <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-timing-allow-passed" id="populating-a-session-history-entry:concept-response-timing-allow-passed" data-x-internal="concept-response-timing-allow-passed">timing allow passed flag</a> is set, then
    set <var>navigable</var>'s <a href="#nav-container" id="populating-a-session-history-entry:nav-container-7">container</a>'s <a href="#iframe-pending-resource-timing-start-time" id="populating-a-session-history-entry:iframe-pending-resource-timing-start-time">pending resource-timing start time</a> to
    null.</p>

    <p class="note">If the <code id="populating-a-session-history-entry:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> is allowed to report to resource timing,
    we don't need to run its fallback steps as the normal reporting would happen.</p>
   </li><li>
    <p>Return a new <a href="#navigation-params" id="populating-a-session-history-entry:navigation-params-6">navigation params</a>, with</p>

    <dl class="props"><dt><a href="#navigation-params-id" id="populating-a-session-history-entry:navigation-params-id-2">id</a></dt><dd><var>navigationId</var></dd><dt><a href="#navigation-params-navigable" id="populating-a-session-history-entry:navigation-params-navigable-2">navigable</a></dt><dd><var>navigable</var></dd><dt><a href="#navigation-params-request" id="populating-a-session-history-entry:navigation-params-request-5">request</a></dt><dd><var>request</var></dd><dt><a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-10">response</a></dt><dd><var>response</var></dd><dt><a href="#navigation-params-fetch-controller" id="populating-a-session-history-entry:navigation-params-fetch-controller-2">fetch controller</a></dt><dd><var>fetchController</var></dd><dt><a href="#navigation-params-commit-early-hints" id="populating-a-session-history-entry:navigation-params-commit-early-hints-2">commit early hints</a></dt><dd><var>commitEarlyHints</var></dd><dt><a href="#navigation-params-coop" id="populating-a-session-history-entry:navigation-params-coop-2">opener policy</a></dt><dd><var>responseCOOP</var></dd><dt><a href="#navigation-params-reserved-environment" id="populating-a-session-history-entry:navigation-params-reserved-environment-4">reserved environment</a></dt><dd><var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="populating-a-session-history-entry:concept-request-reserved-client-10" data-x-internal="concept-request-reserved-client">reserved client</a></dd><dt><a href="#navigation-params-origin" id="populating-a-session-history-entry:navigation-params-origin-3">origin</a></dt><dd><var>responseOrigin</var></dd><dt><a href="#navigation-params-policy-container" id="populating-a-session-history-entry:navigation-params-policy-container-6">policy container</a></dt><dd><var>resultPolicyContainer</var></dd><dt><a href="#navigation-params-sandboxing" id="populating-a-session-history-entry:navigation-params-sandboxing-3">final sandboxing flag set</a></dt><dd><var>finalSandboxFlags</var></dd><dt><a href="#navigation-params-coop-enforcement-result" id="populating-a-session-history-entry:navigation-params-coop-enforcement-result-2">COOP enforcement result</a></dt><dd><var>coopEnforcementResult</var></dd><dt><a href="#navigation-params-nav-timing-type" id="populating-a-session-history-entry:navigation-params-nav-timing-type-2">navigation timing type</a></dt><dd><var>navTimingType</var></dd><dt><a href="#navigation-params-about-base-url" id="populating-a-session-history-entry:navigation-params-about-base-url-2">about base URL</a></dt><dd><var>entry</var>'s <a href="#she-document-state" id="populating-a-session-history-entry:she-document-state-40">document state</a>'s <a href="#document-state-about-base-url" id="populating-a-session-history-entry:document-state-about-base-url-4">about base URL</a></dd><dt><a href="#navigation-params-user-involvement" id="populating-a-session-history-entry:navigation-params-user-involvement-2">user involvement</a></dt><dd><var>userInvolvement</var></dd></dl>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>An element has a <dfn id="browsing-context-scope-origin">browsing context scope origin</dfn> if its <code id="populating-a-session-history-entry:document-4"><a href="#document">Document</a></code>'s
  <a href="#node-navigable" id="populating-a-session-history-entry:node-navigable">node navigable</a> is a <a href="#top-level-traversable" id="populating-a-session-history-entry:top-level-traversable-4">top-level traversable</a> or if all of its
  <code id="populating-a-session-history-entry:document-5"><a href="#document">Document</a></code>'s <a href="#ancestor-navigables" id="populating-a-session-history-entry:ancestor-navigables">ancestor navigables</a> have <a href="#nav-document" id="populating-a-session-history-entry:nav-document-8">active documents</a> whose <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="populating-a-session-history-entry:concept-document-origin-5" data-x-internal="concept-document-origin">origins</a> are the <a href="#same-origin" id="populating-a-session-history-entry:same-origin-4">same origin</a> as the element's
  <a id="populating-a-session-history-entry:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="populating-a-session-history-entry:concept-document-origin-6" data-x-internal="concept-document-origin">origin</a>. If an element
  has a <a href="#browsing-context-scope-origin" id="populating-a-session-history-entry:browsing-context-scope-origin-3">browsing context scope origin</a>, then its value is the <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="populating-a-session-history-entry:concept-document-origin-7" data-x-internal="concept-document-origin">origin</a> of the element's <a id="populating-a-session-history-entry:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p>
  </div>

  <p class="XXX">This definition is broken and needs investigation to see what it was intended to
  express: see <a href="https://github.com/whatwg/html/issues/4703">issue #4703</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="loading-a-document">load a document</dfn> given <a href="#navigation-params" id="populating-a-session-history-entry:navigation-params-7">navigation params</a>
  <var>navigationParams</var>, <a href="#source-snapshot-params" id="populating-a-session-history-entry:source-snapshot-params-3">source snapshot params</a> <var>sourceSnapshotParams</var>,
  and <a href="#concept-origin" id="populating-a-session-history-entry:concept-origin">origin</a> <var>initiatorOrigin</var>, perform the following steps. They return a
  <code id="populating-a-session-history-entry:document-6"><a href="#document">Document</a></code> or null.</p>

  <ol><li><p>Let <var>type</var> be the <a href="https://mimesniff.spec.whatwg.org/#computed-mime-type" id="populating-a-session-history-entry:content-type-sniffing-2" data-x-internal="content-type-sniffing-2">computed type</a> of
   <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-11">response</a>.</p></li><li>
    <p>If the user agent has been configured to process resources of the given <var>type</var>
    using some mechanism other than rendering the content in a <a href="#navigable" id="populating-a-session-history-entry:navigable-6">navigable</a>, then
    skip this step. Otherwise, if the <var>type</var> is one of the following types:</p>

    <dl class="switch"><dt>an <a id="populating-a-session-history-entry:html-mime-type" href="https://mimesniff.spec.whatwg.org/#html-mime-type" data-x-internal="html-mime-type">HTML MIME type</a></dt><dd>Return the result of <a href="#navigate-html" id="populating-a-session-history-entry:navigate-html">loading an HTML document</a>, given
     <var>navigationParams</var>.</dd><dt>an <a id="populating-a-session-history-entry:xml-mime-type" href="https://mimesniff.spec.whatwg.org/#xml-mime-type" data-x-internal="xml-mime-type">XML MIME type</a> that is not an <a href="#explicitly-supported-xml-mime-type" id="populating-a-session-history-entry:explicitly-supported-xml-mime-type">explicitly supported XML MIME
     type</a></dt><dd>Return the result of <a href="#read-xml" id="populating-a-session-history-entry:read-xml">loading an XML document</a> given
     <var>navigationParams</var> and <var>type</var>.</dd><dt>a <a id="populating-a-session-history-entry:javascript-mime-type" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type" data-x-internal="javascript-mime-type">JavaScript MIME type</a></dt><dt>a <a id="populating-a-session-history-entry:json-mime-type" href="https://mimesniff.spec.whatwg.org/#json-mime-type" data-x-internal="json-mime-type">JSON MIME type</a> that is not an <a href="#explicitly-supported-json-mime-type" id="populating-a-session-history-entry:explicitly-supported-json-mime-type">explicitly supported JSON MIME
     type</a></dt><dt>"<code id="populating-a-session-history-entry:text/css"><a href="#text/css">text/css</a></code>"</dt><dt>"<code id="populating-a-session-history-entry:text/plain"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>"</dt><dt>"<code id="populating-a-session-history-entry:text/vtt"><a href="#text/vtt">text/vtt</a></code>"</dt><dd>Return the result of <a href="#navigate-text" id="populating-a-session-history-entry:navigate-text">loading a text document</a> given
     <var>navigationParams</var> and <var>type</var>.</dd><dt>"<code id="populating-a-session-history-entry:multipart/x-mixed-replace"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code>"</dt><dd>Return the result of <a href="#navigate-multipart-x-mixed-replace" id="populating-a-session-history-entry:navigate-multipart-x-mixed-replace">loading a
     <code>multipart/x-mixed-replace</code> document</a>, given <var>navigationParams</var>,
     <var>sourceSnapshotParams</var>, and <var>initiatorOrigin</var>.</dd><dt>a supported image, video, or audio type</dt><dd>Return the result of <a href="#navigate-media" id="populating-a-session-history-entry:navigate-media">loading a media document</a> given
     <var>navigationParams</var> and <var>type</var>.</dd><dt>"<code>application/pdf</code>"</dt><dt>"<code>text/pdf</code>"</dt><dd>If the user agent's <a href="#pdf-viewer-supported" id="populating-a-session-history-entry:pdf-viewer-supported">PDF viewer supported</a> is true, return the result of <a href="#navigate-ua-inline" id="populating-a-session-history-entry:navigate-ua-inline-3">creating a document for inline content that doesn't have a
     DOM</a> given <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="populating-a-session-history-entry:navigation-params-navigable-3">navigable</a>, <var>navigationParams</var>'s <a href="#navigation-params-id" id="populating-a-session-history-entry:navigation-params-id-3">id</a>, <var>navigationParams</var>'s <a href="#navigation-params-nav-timing-type" id="populating-a-session-history-entry:navigation-params-nav-timing-type-3">navigation timing type</a>, and
     <var>navigationParams</var>'s <a href="#navigation-params-user-involvement" id="populating-a-session-history-entry:navigation-params-user-involvement-3">user
     involvement</a>.</dd></dl>

    <p>Otherwise, proceed onward.</p>

    <p>An <dfn id="explicitly-supported-xml-mime-type">explicitly supported XML MIME type</dfn> is an <a id="populating-a-session-history-entry:xml-mime-type-2" href="https://mimesniff.spec.whatwg.org/#xml-mime-type" data-x-internal="xml-mime-type">XML MIME type</a> for which
    the user agent is configured to use an external application to render the content, or for which
    the user agent has dedicated processing rules. For example, a web browser with a built-in Atom
    feed viewer would be said to explicitly support the <code id="populating-a-session-history-entry:application/atom+xml"><a href="#application/atom+xml">application/atom+xml</a></code> MIME
    type.</p>

    <p>An <dfn id="explicitly-supported-json-mime-type">explicitly supported JSON MIME type</dfn> is a <a id="populating-a-session-history-entry:json-mime-type-2" href="https://mimesniff.spec.whatwg.org/#json-mime-type" data-x-internal="json-mime-type">JSON MIME type</a> for which
    the user agent is configured to use an external application to render the content, or for which
    the user agent has dedicated processing rules.</p>

    <p class="note">In both cases, the external application or user agent will either <a href="#navigate-ua-inline" id="populating-a-session-history-entry:navigate-ua-inline-4">display the content inline</a> directly in
    <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="populating-a-session-history-entry:navigation-params-navigable-4">navigable</a>, or
    <a href="#hand-off-to-external-software" id="populating-a-session-history-entry:hand-off-to-external-software-3">hand it off to external software</a>. Both
    happen in the steps below.</p>
   </li><li id="navigate-non-Document"><p>If, given <var>type</var>, the new resource is to be handled
   by displaying some sort of inline content, e.g., a native rendering of the content or an error
   message because the specified type is not supported, then return the result of <a href="#navigate-ua-inline" id="populating-a-session-history-entry:navigate-ua-inline-5">creating a document for inline content that doesn't have a
   DOM</a> given <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="populating-a-session-history-entry:navigation-params-navigable-5">navigable</a>, <var>navigationParams</var>'s <a href="#navigation-params-id" id="populating-a-session-history-entry:navigation-params-id-4">id</a>, <var>navigationParams</var>'s <a href="#navigation-params-nav-timing-type" id="populating-a-session-history-entry:navigation-params-nav-timing-type-4">navigation timing type</a>, and
   <var>navigationParams</var>'s <a href="#navigation-params-user-involvement" id="populating-a-session-history-entry:navigation-params-user-involvement-4">user
   involvement</a>.</p></li><li><p>Otherwise, the document's <var>type</var> is such that the resource will not affect
   <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="populating-a-session-history-entry:navigation-params-navigable-6">navigable</a>, e.g.,
   because the resource is to be handed to an external application or because it is an unknown type
   that will be processed by <a href="#handle-as-a-download" id="populating-a-session-history-entry:handle-as-a-download-2">handle as a download</a>. <a href="#hand-off-to-external-software" id="populating-a-session-history-entry:hand-off-to-external-software-4">Hand-off to external
   software</a> given <var>navigationParams</var>'s <a href="#navigation-params-response" id="populating-a-session-history-entry:navigation-params-response-12">response</a>, <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="populating-a-session-history-entry:navigation-params-navigable-7">navigable</a>, <var>navigationParams</var>'s <a href="#navigation-params-sandboxing" id="populating-a-session-history-entry:navigation-params-sandboxing-4">final sandboxing flag set</a>,
   <var>sourceSnapshotParams</var>'s <a href="#source-snapshot-params-activation" id="populating-a-session-history-entry:source-snapshot-params-activation-4">has transient
   activation</a>, and <var>initiatorOrigin</var>.</p></li><li><p>Return null.</p></li></ol>
  </div>


  <h4 id="applying-the-history-step"><span class="secno">7.4.6</span> Applying the history step<a href="#applying-the-history-step" class="self-link"></a></h4>

  <p>For both navigation and traversal, once we have an idea of where we want to head to in the
  session history, much of the work comes about in applying that notion to the <a href="#traversable-navigable" id="applying-the-history-step:traversable-navigable">traversable
  navigable</a> and the relevant <code id="applying-the-history-step:document"><a href="#document">Document</a></code>. For navigations, this work generally
  occurs toward the end of the process; for traversals, it is the beginning.</p>

  <h5 id="updating-the-traversable"><span class="secno">7.4.6.1</span> Updating the traversable<a href="#updating-the-traversable" class="self-link"></a></h5>

  <p>Ensuring a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable">traversable</a> ends up at the right
  session history step is particularly complex, as it can involve coordinating across multiple
  <a href="#navigable" id="updating-the-traversable:navigable">navigable</a> descendants of the traversable, <a href="#populating-a-session-history-entry">populating</a> them in parallel, and then
  synchronizing back up to ensure everyone has the same view of the result. This is further
  complicated by the existence of synchronous same-document navigations being mixed together with
  cross-document navigations, and how web pages have come to have certain relative timing
  expectations.</p>

  <p>A <dfn id="changing-navigable-continuation-state">changing navigable continuation state</dfn> is used to store information during the
  <a href="#apply-the-history-step" id="updating-the-traversable:apply-the-history-step">apply the history step</a> algorithm, allowing parts of the algorithm to continue only
  after other parts have finished. It is a <a id="updating-the-traversable:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with:</p>

  <dl><dt><dfn id="changing-nav-continuation-displayed-document">displayed document</dfn></dt><dd>A <code id="updating-the-traversable:document"><a href="#document">Document</a></code></dd><dt><dfn id="changing-nav-continuation-target-entry">target entry</dfn></dt><dd>A <a href="#session-history-entry" id="updating-the-traversable:session-history-entry">session history entry</a></dd><dt><dfn id="changing-nav-continuation-navigable">navigable</dfn></dt><dd>A <a href="#navigable" id="updating-the-traversable:navigable-2">navigable</a></dd><dt><dfn id="changing-nav-continuation-update-only">update only</dfn></dt><dd>A boolean</dd></dl>

  <hr>

  <p>Although all updates to the <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-2">traversable navigable</a> end up in the same <a href="#apply-the-history-step" id="updating-the-traversable:apply-the-history-step-2">apply
  the history step</a> algorithm, each possible entry point comes along with some minor
  customizations:</p>

  <div data-algorithm="">
  <p>To <dfn id="update-for-navigable-creation/destruction">update for navigable creation/destruction</dfn> given a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-3">traversable
  navigable</a> <var>traversable</var>:</p>

  <ol><li><p>Let <var>step</var> be <var>traversable</var>'s <a href="#tn-current-session-history-step" id="updating-the-traversable:tn-current-session-history-step">current session history step</a>.</p></li><li><p>Return the result of <a href="#apply-the-history-step" id="updating-the-traversable:apply-the-history-step-3">applying the history
   step</a> <var>step</var> to <var>traversable</var> given false, null, null, "<code id="updating-the-traversable:uni-none"><a href="#uni-none">none</a></code>", and null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="apply-the-push/replace-history-step">apply the push/replace history step</dfn> given a non-negative integer <var>step</var>
  to a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-4">traversable navigable</a> <var>traversable</var>, given a <a href="#history-handling-behavior" id="updating-the-traversable:history-handling-behavior">history handling
  behavior</a> <var>historyHandling</var> and a <a href="#user-navigation-involvement" id="updating-the-traversable:user-navigation-involvement">user navigation involvement</a>
  <var>userInvolvement</var>:</p>

  <ol><li><p>Return the result of <a href="#apply-the-history-step" id="updating-the-traversable:apply-the-history-step-4">applying the history
   step</a> <var>step</var> to <var>traversable</var> given false, null, null,
   <var>userInvolvement</var>, and <var>historyHandling</var>.</p></li></ol>
  </div>

  <p class="note"><a href="#apply-the-push/replace-history-step" id="updating-the-traversable:apply-the-push/replace-history-step">Apply the push/replace history step</a> never passes <a href="#source-snapshot-params" id="updating-the-traversable:source-snapshot-params">source
  snapshot params</a> or an initiator <a href="#navigable" id="updating-the-traversable:navigable-3">navigable</a> to <a href="#apply-the-history-step" id="updating-the-traversable:apply-the-history-step-5">apply the history
  step</a>. This is because those checks are done earlier in the <a href="#navigate" id="updating-the-traversable:navigate">navigation</a> algorithm.</p>

  <div data-algorithm="">
  <p>To <dfn id="apply-the-reload-history-step">apply the reload history step</dfn> to a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-5">traversable navigable</a>
  <var>traversable</var> given <a href="#user-navigation-involvement" id="updating-the-traversable:user-navigation-involvement-2">user navigation involvement</a>
  <var>userInvolvement</var>:</p>

  <ol><li><p>Let <var>step</var> be <var>traversable</var>'s <a href="#tn-current-session-history-step" id="updating-the-traversable:tn-current-session-history-step-2">current session history step</a>.</p></li><li><p>Return the result of <a href="#apply-the-history-step" id="updating-the-traversable:apply-the-history-step-6">applying the history
   step</a> <var>step</var> to <var>traversable</var> given true, null, null,
   <var>userInvolvement</var>, and "<code id="updating-the-traversable:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>".</p></li></ol>
  </div>

  <p class="note"><a href="#apply-the-reload-history-step" id="updating-the-traversable:apply-the-reload-history-step">Apply the reload history step</a> never passes <a href="#source-snapshot-params" id="updating-the-traversable:source-snapshot-params-2">source snapshot
  params</a> or an initiator <a href="#navigable" id="updating-the-traversable:navigable-4">navigable</a> to <a href="#apply-the-history-step" id="updating-the-traversable:apply-the-history-step-7">apply the history step</a>. This
  is because reloading is always treated as if it were done by the <a href="#navigable" id="updating-the-traversable:navigable-5">navigable</a> itself,
  even in cases like <code>parent.location.reload()</code>.</p>

  <div data-algorithm="">
  <p>To <dfn id="apply-the-traverse-history-step">apply the traverse history step</dfn> given a non-negative integer <var>step</var> to a
  <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-6">traversable navigable</a> <var>traversable</var>, with <a href="#source-snapshot-params" id="updating-the-traversable:source-snapshot-params-3">source snapshot
  params</a> <var>sourceSnapshotParams</var>, <a href="#navigable" id="updating-the-traversable:navigable-6">navigable</a> <var>initiatorToCheck</var>,
  and <a href="#user-navigation-involvement" id="updating-the-traversable:user-navigation-involvement-3">user navigation involvement</a> <var>userInvolvement</var>:</p>

  <ol><li><p>Return the result of <a href="#apply-the-history-step" id="updating-the-traversable:apply-the-history-step-8">applying the history
   step</a> <var>step</var> to <var>traversable</var> given true,
   <var>sourceSnapshotParams</var>, <var>initiatorToCheck</var>,
   <var>userInvolvement</var>, and "<code id="updating-the-traversable:dom-navigationtype-traverse"><a href="#dom-navigationtype-traverse">traverse</a></code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="resume-applying-the-traverse-history-step">resume applying the traverse history step</dfn> given a non-negative integer
  <var>step</var>, a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-7">traversable navigable</a> <var>traversable</var>, and <a href="#user-navigation-involvement" id="updating-the-traversable:user-navigation-involvement-4">user
  navigation involvement</a> <var>userInvolvement</var>, <a href="#apply-the-history-step" id="updating-the-traversable:apply-the-history-step-9">apply</a> <var>step</var> to <var>traversable</var> given false, null, null,
  <var>userInvolvement</var>, and "<code id="updating-the-traversable:dom-navigationtype-traverse-2"><a href="#dom-navigationtype-traverse">traverse</a></code>".</p>
  </div>

  <p class="note">When resuming a traverse, we are already past the cancelation, initiator, and
  source snapshot checks, and this traversal has already been determined to be a same-document
  traversal. Hence, we can pass false and null for those arguments.</p>

  <hr>

  <p>Now for the algorithm itself.</p>

  <div data-algorithm="">
  <p id="update-the-session-history-with-the-new-page">To <dfn id="apply-the-history-step">apply the history step</dfn> given a
  non-negative integer <var>step</var> to a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-8">traversable navigable</a>
  <var>traversable</var>, with boolean <var>checkForCancelation</var>, <a href="#source-snapshot-params" id="updating-the-traversable:source-snapshot-params-4">source snapshot
  params</a>-or-null <var>sourceSnapshotParams</var>, <a href="#navigable" id="updating-the-traversable:navigable-7">navigable</a>-or-null
  <var>initiatorToCheck</var>, <a href="#user-navigation-involvement" id="updating-the-traversable:user-navigation-involvement-5">user navigation involvement</a> <var>userInvolvement</var>,
  and <code id="updating-the-traversable:navigationtype"><a href="#navigationtype">NavigationType</a></code>-or-null <var>navigationType</var>, perform the following steps.
  They return "<code>initiator-disallowed</code>", "<code>canceled-by-beforeunload</code>", "<code>canceled-by-navigate</code>", or
  "<code>applied</code>".</p>

  <ol><li><p><a id="updating-the-traversable:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: This is running within <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="updating-the-traversable:tn-session-history-traversal-queue">session history traversal queue</a>.</p></li><li><p>Let <var>targetStep</var> be the result of <a href="#getting-the-used-step" id="updating-the-traversable:getting-the-used-step">getting the used step</a> given
   <var>traversable</var> and <var>step</var>.</p></li><li>
    <p>If <var>initiatorToCheck</var> is not null, then:</p>

    <ol><li><p><a id="updating-the-traversable:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>sourceSnapshotParams</var> is not null.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-traversable:list-iterate" data-x-internal="list-iterate">For each</a> <var>navigable</var> of <a href="#get-all-navigables-whose-current-session-history-entry-will-change-or-reload" id="updating-the-traversable:get-all-navigables-whose-current-session-history-entry-will-change-or-reload">get all
     navigables whose current session history entry will change or reload</a>: if
     <var>initiatorToCheck</var> is not <a href="#allowed-to-navigate" id="updating-the-traversable:allowed-to-navigate">allowed by sandboxing to navigate</a>
     <var>navigable</var> given <var>sourceSnapshotParams</var>, then return "<code>initiator-disallowed</code>".</p></li></ol>
   </li><li><p>Let <var>navigablesCrossingDocuments</var> be the result of <a href="#getting-all-navigables-that-might-experience-a-cross-document-traversal" id="updating-the-traversable:getting-all-navigables-that-might-experience-a-cross-document-traversal">getting all navigables
   that might experience a cross-document traversal</a> given <var>traversable</var> and
   <var>targetStep</var>.</p></li><li><p>If <var>checkForCancelation</var> is true, and the result of <a href="#checking-if-unloading-is-canceled" id="updating-the-traversable:checking-if-unloading-is-canceled">checking if unloading
   is canceled</a> given <var>navigablesCrossingDocuments</var>, <var>traversable</var>,
   <var>targetStep</var>, and <var>userInvolvement</var> is not "<code>continue</code>",
   then return that result.</p></li><li><p>Let <var>changingNavigables</var> be the result of <a href="#get-all-navigables-whose-current-session-history-entry-will-change-or-reload" id="updating-the-traversable:get-all-navigables-whose-current-session-history-entry-will-change-or-reload-2">get all navigables whose current
   session history entry will change or reload</a> given <var>traversable</var> and
   <var>targetStep</var>.</p></li><li><p>Let <var>nonchangingNavigablesThatStillNeedUpdates</var> be the result of <a href="#getting-all-navigables-that-only-need-history-object-length/index-update" id="updating-the-traversable:getting-all-navigables-that-only-need-history-object-length/index-update">getting
   all navigables that only need history object length/index update</a> given
   <var>traversable</var> and <var>targetStep</var>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-traversable:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>navigable</var> of
    <var>changingNavigables</var>:</p>

    <ol><li><p>Let <var>targetEntry</var> be the result of <a href="#getting-the-target-history-entry" id="updating-the-traversable:getting-the-target-history-entry">getting the target history
     entry</a> given <var>navigable</var> and <var>targetStep</var>.</p></li><li><p>Set <var>navigable</var>'s <a href="#nav-current-history-entry" id="updating-the-traversable:nav-current-history-entry">current session
     history entry</a> to <var>targetEntry</var>.</p></li><li><p><a href="#set-the-ongoing-navigation" id="updating-the-traversable:set-the-ongoing-navigation">Set the ongoing navigation</a> for <var>navigable</var> to "<code>traversal</code>".</p></li></ol>
   </li><li><p>Let <var>totalChangeJobs</var> be the <a href="https://infra.spec.whatwg.org/#list-size" id="updating-the-traversable:list-size" data-x-internal="list-size">size</a> of
   <var>changingNavigables</var>.</p></li><li><p>Let <var>completedChangeJobs</var> be 0.</p></li><li>
    <p>Let <var>changingNavigableContinuations</var> be an empty <a id="updating-the-traversable:queue" href="https://infra.spec.whatwg.org/#queue" data-x-internal="queue">queue</a> of <a href="#changing-navigable-continuation-state" id="updating-the-traversable:changing-navigable-continuation-state">changing navigable continuation
    states</a>.</p>

    <p class="note">This queue is used to split the operations on <var>changingNavigables</var>
    into two parts. Specifically, <var>changingNavigableContinuations</var> holds data for the <a href="#continuations-dequeue">second part</a>.</p>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-traversable:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>navigable</var> of
    <var>changingNavigables</var>, <a href="#queue-a-global-task" id="updating-the-traversable:queue-a-global-task">queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="updating-the-traversable:navigation-and-traversal-task-source">navigation and
    traversal task source</a> of <var>navigable</var>'s <a href="#nav-window" id="updating-the-traversable:nav-window">active
    window</a> to run the steps:</p>

    <p class="note">This set of steps are split into two parts to allow synchronous navigations to
    be processed before documents unload. State is stored in
    <var>changingNavigableContinuations</var> for the <a href="#continuations-dequeue">second
    part</a>.</p>

    <ol><li><p>Let <var>displayedEntry</var> be <var>navigable</var>'s <a href="#nav-active-history-entry" id="updating-the-traversable:nav-active-history-entry">active session history entry</a>.</p></li><li><p>Let <var>targetEntry</var> be <var>navigable</var>'s <a href="#nav-current-history-entry" id="updating-the-traversable:nav-current-history-entry-2">current session history entry</a>.</p></li><li>
      <p>Let <var>changingNavigableContinuation</var> be a <a href="#changing-navigable-continuation-state" id="updating-the-traversable:changing-navigable-continuation-state-2">changing navigable continuation
      state</a> with:</p>

      <dl class="props"><dt><a href="#changing-nav-continuation-displayed-document" id="updating-the-traversable:changing-nav-continuation-displayed-document">displayed document</a></dt><dd><var>displayedEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document">document</a></dd><dt><a href="#changing-nav-continuation-target-entry" id="updating-the-traversable:changing-nav-continuation-target-entry">target entry</a></dt><dd><var>targetEntry</var></dd><dt><a href="#changing-nav-continuation-navigable" id="updating-the-traversable:changing-nav-continuation-navigable">navigable</a></dt><dd><var>navigable</var></dd><dt><a href="#changing-nav-continuation-update-only" id="updating-the-traversable:changing-nav-continuation-update-only">update-only</a></dt><dd>false</dd></dl>
     </li><li>
      <p>If <var>displayedEntry</var> is <var>targetEntry</var> and <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state">document state</a>'s <a href="#document-state-reload-pending" id="updating-the-traversable:document-state-reload-pending">reload pending</a> is false, then:</p>

      <ol><li><p>Set <var>changingNavigableContinuation</var>'s <a href="#changing-nav-continuation-update-only" id="updating-the-traversable:changing-nav-continuation-update-only-2">update-only</a> to true.</p></li><li><p><a id="updating-the-traversable:enqueue" href="https://infra.spec.whatwg.org/#queue-enqueue" data-x-internal="enqueue">Enqueue</a> <var>changingNavigableContinuation</var> on
       <var>changingNavigableContinuations</var>.</p></li><li><p>Abort these steps.</p></li></ol>

      <p class="note">This case occurs due to a <a href="#finalize-a-same-document-navigation" id="updating-the-traversable:finalize-a-same-document-navigation">synchronous navigation</a> which already updated the <a href="#nav-active-history-entry" id="updating-the-traversable:nav-active-history-entry-2">active session history entry</a>.</p>
     </li><li>
      <p>Switch on <var>navigationType</var>:</p>

      <dl class="switch"><dt>"<code id="updating-the-traversable:dom-navigationtype-reload-2"><a href="#dom-navigationtype-reload">reload</a></code>"</dt><dd><p><a id="updating-the-traversable:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-2">document state</a>'s <a href="#document-state-reload-pending" id="updating-the-traversable:document-state-reload-pending-2">reload pending</a> is true.</p></dd><dt>"<code id="updating-the-traversable:dom-navigationtype-traverse-3"><a href="#dom-navigationtype-traverse">traverse</a></code>"</dt><dd><p><a id="updating-the-traversable:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>targetEntry</var>'s
       <a href="#she-document-state" id="updating-the-traversable:she-document-state-3">document state</a>'s <a href="#document-state-ever-populated" id="updating-the-traversable:document-state-ever-populated">ever populated</a> is true.</p></dd><dt>"<code id="updating-the-traversable:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>"</dt><dd><p><a id="updating-the-traversable:assert-5" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>targetEntry</var>'s <a href="#she-step" id="updating-the-traversable:she-step">step</a>
       is <var>displayedEntry</var>'s <a href="#she-step" id="updating-the-traversable:she-step-2">step</a> and
       <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-4">document state</a>'s <a href="#document-state-ever-populated" id="updating-the-traversable:document-state-ever-populated-2">ever populated</a> is false.</p></dd><dt>"<code id="updating-the-traversable:dom-navigationtype-push"><a href="#dom-navigationtype-push">push</a></code>"</dt><dd><p><a id="updating-the-traversable:assert-6" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>targetEntry</var>'s <a href="#she-step" id="updating-the-traversable:she-step-3">step</a> is
       <var>displayedEntry</var>'s <a href="#she-step" id="updating-the-traversable:she-step-4">step</a> + 1 and
       <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-5">document state</a>'s <a href="#document-state-ever-populated" id="updating-the-traversable:document-state-ever-populated-3">ever populated</a> is false.</p></dd></dl>
     </li><li><p>Let <var>oldOrigin</var> be <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-6">document state</a>'s <a href="#document-state-origin" id="updating-the-traversable:document-state-origin">origin</a>.</p></li><li id="descendant-navigable-traversal-navigate-events">
      <p>If all of the following are true:</p>

      <ul><li><p><var>navigable</var> is not <var>traversable</var>;</p></li><li><p><var>targetEntry</var> is not <var>navigable</var>'s <a href="#nav-current-history-entry" id="updating-the-traversable:nav-current-history-entry-3">current session history entry</a>; and</p></li><li><p><var>oldOrigin</var> is the <a href="#same-origin" id="updating-the-traversable:same-origin">same</a> as
       <var>navigable</var>'s <a href="#nav-current-history-entry" id="updating-the-traversable:nav-current-history-entry-4">current session history entry</a>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-7">document state</a>'s <a href="#document-state-origin" id="updating-the-traversable:document-state-origin-2">origin</a>,</p></li></ul>

      <p>then:</p>

      <ol><li><p>Let <var>navigation</var> be <var>navigable</var>'s <a href="#nav-window" id="updating-the-traversable:nav-window-2">active window</a>'s <a href="#window-navigation-api" id="updating-the-traversable:window-navigation-api">navigation API</a>.</p></li><li><p><a href="#fire-a-traverse-navigate-event" id="updating-the-traversable:fire-a-traverse-navigate-event">Fire a traverse <code>navigate</code> event</a> at
       <var>navigation</var> given <var>targetEntry</var> and <var>userInvolvement</var>.</p></li></ol>
     </li><li>
      <p>If <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-2">document</a> is null, or
      <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-8">document state</a>'s <a href="#document-state-reload-pending" id="updating-the-traversable:document-state-reload-pending-3">reload pending</a> is true, then:</p>

      <ol><li><p>Let <var>navTimingType</var> be "<code id="updating-the-traversable:dom-navigationtimingtype-back_forward"><a data-x-internal="dom-navigationtimingtype-back_forward" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype-back_forward">back_forward</a></code>" if
       <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-3">document</a> is null; otherwise
       "<code id="updating-the-traversable:dom-navigationtimingtype-back_forward-2"><a data-x-internal="dom-navigationtimingtype-back_forward" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype-back_forward">reload</a></code>".</p></li><li><p>Let <var>targetSnapshotParams</var> be the result of <a href="#snapshotting-target-snapshot-params" id="updating-the-traversable:snapshotting-target-snapshot-params">snapshotting target
       snapshot params</a> given <var>navigable</var>.</p></li><li><p>Let <var>potentiallyTargetSpecificSourceSnapshotParams</var> be
       <var>sourceSnapshotParams</var>.</p></li><li>
        <p>If <var>potentiallyTargetSpecificSourceSnapshotParams</var> is null, then set it to the
        result of <a href="#snapshotting-source-snapshot-params" id="updating-the-traversable:snapshotting-source-snapshot-params">snapshotting source snapshot params</a> given <var>navigable</var>'s
        <a href="#nav-document" id="updating-the-traversable:nav-document">active document</a>.</p>

        <p class="note">In this case there is no clear source of the traversal/reload. We treat this
        situation as if <var>navigable</var> navigated itself, but note that some properties of
        <var>targetEntry</var>'s original initiator are preserved in <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-9">document state</a>, such as the <a href="#document-state-initiator-origin" id="updating-the-traversable:document-state-initiator-origin">initiator origin</a> and <a href="#document-state-request-referrer" id="updating-the-traversable:document-state-request-referrer">referrer</a>, which will appropriately influence
        the navigation.</p>
       </li><li><p>Set <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-10">document
       state</a>'s <a href="#document-state-reload-pending" id="updating-the-traversable:document-state-reload-pending-4">reload pending</a> to
       false.</p></li><li><p>Let <var>allowPOST</var> be <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-11">document state</a>'s <a href="#document-state-reload-pending" id="updating-the-traversable:document-state-reload-pending-5">reload pending</a>.</p>

       </li><li><p><a href="#in-parallel" id="updating-the-traversable:in-parallel">In parallel</a>, <a href="#attempt-to-populate-the-history-entry's-document" id="updating-the-traversable:attempt-to-populate-the-history-entry's-document">attempt to populate the history entry's
       document</a> for <var>targetEntry</var>, given <var>navigable</var>,
       <var>potentiallyTargetSpecificSourceSnapshotParams</var>, <var>targetSnapshotParams</var>,
       <var>userInvolvement</var>, with <i id="updating-the-traversable:attempt-to-populate-allow-post"><a href="#attempt-to-populate-allow-post">allowPOST</a></i> set
       to <var>allowPOST</var> and <a href="#attempt-to-populate-completion-steps" id="updating-the-traversable:attempt-to-populate-completion-steps"><i>completionSteps</i></a> set to
       <a href="#queue-a-global-task" id="updating-the-traversable:queue-a-global-task-2">queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="updating-the-traversable:navigation-and-traversal-task-source-2">navigation and traversal task source</a>
       given <var>navigable</var>'s <a href="#nav-window" id="updating-the-traversable:nav-window-3">active window</a> to run
       <var>afterDocumentPopulated</var>.</p></li></ol>

      <p>Otherwise, run <var>afterDocumentPopulated</var> <a href="#immediately" id="updating-the-traversable:immediately">immediately</a>.</p>

      <p>In both cases, let <var>afterDocumentPopulated</var> be the following steps:</p>

      <ol><li>
        <p>If <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-4">document</a> is null, then
        set <var>changingNavigableContinuation</var>'s <a href="#changing-nav-continuation-update-only" id="updating-the-traversable:changing-nav-continuation-update-only-3">update-only</a> to true.</p>

        <p class="note">This means we tried to populate the document, but were unable to do so,
        e.g. because of the server returning a 204.</p>

        <div class="note">
         <p>These kinds of failed navigations or traversals will not be signaled to the <a href="#navigation-api">navigation API</a> (e.g., through the promises of any
         <a href="#navigation-api-method-tracker" id="updating-the-traversable:navigation-api-method-tracker">navigation API method tracker</a>, or the <code id="updating-the-traversable:event-navigateerror"><a href="#event-navigateerror">navigateerror</a></code> event). Doing so would leak information
         about the timing of responses from other origins, in the cross-origin case, and providing
         different results in the cross-origin vs. same-origin cases was deemed too confusing.</p>

         <p>However, implementations could use this opportunity to clear any promise handlers for
         the <code id="updating-the-traversable:dom-navigationtransition-finished"><a href="#dom-navigationtransition-finished">navigation.transition.finished</a></code>
         promise, as they are guaranteed at this point to never run. And, they might wish to
         <a id="updating-the-traversable:report-a-warning-to-the-console" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> if any part of the navigation API initiated
         these navigations, to make it clear to the web developer why their promises will never
         settle and events will never fire.</p>
        </div>
       </li><li>
        <p>If <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-5">document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="updating-the-traversable:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is not <var>oldOrigin</var>, then set
        <var>targetEntry</var>'s <a href="#she-classic-history-api-state" id="updating-the-traversable:she-classic-history-api-state">classic history API
        state</a> to <a href="#structuredserializeforstorage" id="updating-the-traversable:structuredserializeforstorage">StructuredSerializeForStorage</a>(null).</p>

        <p class="note">This clears history state when the origin changed vs a previous load of
        <var>targetEntry</var> without a redirect occuring. This can happen due to a change in CSP
        sandbox headers.</p>
       </li><li>
        <p>If all of the following are true:</p>

        <ul><li><p><var>navigable</var>'s <a href="#nav-parent" id="updating-the-traversable:nav-parent">parent</a> is null;</p></li><li><p><var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-6">document</a>'s <a href="#concept-document-bc" id="updating-the-traversable:concept-document-bc">browsing context</a> is not an <a href="#auxiliary-browsing-context" id="updating-the-traversable:auxiliary-browsing-context">auxiliary browsing
         context</a> whose <a href="#opener-browsing-context" id="updating-the-traversable:opener-browsing-context">opener browsing context</a> is non-null; and</p></li><li><p><var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-7">document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="updating-the-traversable:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> is not <var>oldOrigin</var>,</p></li></ul>

        <p>then set <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-12">document
        state</a>'s <a href="#document-state-nav-target-name" id="updating-the-traversable:document-state-nav-target-name">navigable target name</a>
        to the empty string.</p>
       </li><li>
        <p><a id="updating-the-traversable:enqueue-2" href="https://infra.spec.whatwg.org/#queue-enqueue" data-x-internal="enqueue">Enqueue</a> <var>changingNavigableContinuation</var> on
        <var>changingNavigableContinuations</var>.</p>

        <p class="note">The rest of this job <a href="#continuations-dequeue">runs later</a> in
        this algorithm.</p>
       </li></ol>
     </li></ol>
   </li><li><p>Let <var>navigablesThatMustWaitBeforeHandlingSyncNavigation</var> be an empty
   <a id="updating-the-traversable:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a>.</p></li><li>
    <p>While <var>completedChangeJobs</var> does not equal <var>totalChangeJobs</var>:</p>

    <ol><li>
      <p>If <var>traversable</var>'s <a href="#tn-running-nested-apply-history-step" id="updating-the-traversable:tn-running-nested-apply-history-step">running
      nested apply history step</a> is false, then:</p>

      <ol><li id="sync-navigations-jump-queue">
        <p>While <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="updating-the-traversable:tn-session-history-traversal-queue-2">session
        history traversal queue</a>'s <a href="#session-history-traversal-parallel-queue-algorithm-set" id="updating-the-traversable:session-history-traversal-parallel-queue-algorithm-set">algorithm set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="updating-the-traversable:list-contains" data-x-internal="list-contains">contains</a> one or more <a href="#session-history-traversal-parallel-queue-sync-nav-steps" id="updating-the-traversable:session-history-traversal-parallel-queue-sync-nav-steps">synchronous navigation
        steps</a> with a <a href="#session-history-traversal-parallel-queue-sync-nav-steps-target-nav" id="updating-the-traversable:session-history-traversal-parallel-queue-sync-nav-steps-target-nav">target
        navigable</a> not <a href="https://infra.spec.whatwg.org/#list-contain" id="updating-the-traversable:list-contains-2" data-x-internal="list-contains">contained</a> in
        <var>navigablesThatMustWaitBeforeHandlingSyncNavigation</var>:</p>

        <ol><li><p>Let <var>steps</var> be the first <a href="https://infra.spec.whatwg.org/#list-item" id="updating-the-traversable:list-item" data-x-internal="list-item">item</a> in
         <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="updating-the-traversable:tn-session-history-traversal-queue-3">session history
         traversal queue</a>'s <a href="#session-history-traversal-parallel-queue-algorithm-set" id="updating-the-traversable:session-history-traversal-parallel-queue-algorithm-set-2">algorithm set</a> that
         is <a href="#session-history-traversal-parallel-queue-sync-nav-steps" id="updating-the-traversable:session-history-traversal-parallel-queue-sync-nav-steps-2">synchronous
         navigation steps</a> with a <a href="#session-history-traversal-parallel-queue-sync-nav-steps-target-nav" id="updating-the-traversable:session-history-traversal-parallel-queue-sync-nav-steps-target-nav-2">target
         navigable</a> not <a href="https://infra.spec.whatwg.org/#list-contain" id="updating-the-traversable:list-contains-3" data-x-internal="list-contains">contained</a> in
         <var>navigablesThatMustWaitBeforeHandlingSyncNavigation</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="updating-the-traversable:list-remove" data-x-internal="list-remove">Remove</a> <var>steps</var> from
         <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="updating-the-traversable:tn-session-history-traversal-queue-4">session history
         traversal queue</a>'s <a href="#session-history-traversal-parallel-queue-algorithm-set" id="updating-the-traversable:session-history-traversal-parallel-queue-algorithm-set-3">algorithm
         set</a>.</p></li><li><p>Set <var>traversable</var>'s <a href="#tn-running-nested-apply-history-step" id="updating-the-traversable:tn-running-nested-apply-history-step-2">running nested apply history step</a> to
         true.</p></li><li><p>Run <var>steps</var>.</p></li><li><p>Set <var>traversable</var>'s <a href="#tn-running-nested-apply-history-step" id="updating-the-traversable:tn-running-nested-apply-history-step-3">running nested apply history step</a> to
         false.</p></li></ol>

        <p class="note">Synchronous navigations that are intended to take place before this
        traversal jump the queue at this point, so they can be added to the correct place in
        <var>traversable</var>'s <a href="#tn-session-history-entries" id="updating-the-traversable:tn-session-history-entries">session history
        entries</a> before this traversal potentially unloads their document. <a href="#sync-navigation-steps-queue-jumping-examples">More details can be found
        here</a>.</p>
       </li></ol>
     </li><li id="continuations-dequeue"><p>Let <var>changingNavigableContinuation</var> be the result
     of <a href="https://infra.spec.whatwg.org/#queue-dequeue" id="updating-the-traversable:dequeue" data-x-internal="dequeue">dequeuing</a> from
     <var>changingNavigableContinuations</var>.</p></li><li><p>If <var>changingNavigableContinuation</var> is nothing, then
     <a id="updating-the-traversable:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>displayedDocument</var> be <var>changingNavigableContinuation</var>'s <a href="#changing-nav-continuation-displayed-document" id="updating-the-traversable:changing-nav-continuation-displayed-document-2">displayed document</a>.</p></li><li><p>Let <var>targetEntry</var> be <var>changingNavigableContinuation</var>'s <a href="#changing-nav-continuation-target-entry" id="updating-the-traversable:changing-nav-continuation-target-entry-2">target entry</a>.</p></li><li><p>Let <var>navigable</var> be <var>changingNavigableContinuation</var>'s <a href="#changing-nav-continuation-navigable" id="updating-the-traversable:changing-nav-continuation-navigable-2">navigable</a>.</p></li><li>
      <p>Let (<var>scriptHistoryLength</var>, <var>scriptHistoryIndex</var>) be the result of
      <a href="#getting-the-history-object-length-and-index" id="updating-the-traversable:getting-the-history-object-length-and-index">getting the history object length and index</a> given <var>traversable</var> and
      <var>targetStep</var>.</p>

      <p class="note">These values might have changed since they were last calculated.</p>
     </li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-append" id="updating-the-traversable:list-append" data-x-internal="list-append">Append</a> <var>navigable</var> to
      <var>navigablesThatMustWaitBeforeHandlingSyncNavigation</var>.</p>

      <p class="note">Once a navigable has reached this point in traversal, additionally queued
      synchronous navigation steps are likely to be intended to occur after this traversal rather
      than before it, so they no longer jump the queue. <a href="#sync-navigation-steps-queue-jumping-examples">More details can be found here</a>.</p>
     </li><li><p>Let <var>entriesForNavigationAPI</var> be the result of <a href="#getting-session-history-entries-for-the-navigation-api" id="updating-the-traversable:getting-session-history-entries-for-the-navigation-api">getting session history
     entries for the navigation API</a> given <var>navigable</var> and
     <var>targetStep</var>.</p></li><li>
      <p>If <var>changingNavigableContinuation</var>'s <a href="#changing-nav-continuation-update-only" id="updating-the-traversable:changing-nav-continuation-update-only-4">update-only</a> is true, or
      <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-8">document</a> is
      <var>displayedDocument</var>, then:</p>

      <p class="note">This is a same-document navigation: we proceed without unloading.</p>

      <ol><li>
        <p><a href="#set-the-ongoing-navigation" id="updating-the-traversable:set-the-ongoing-navigation-2">Set the ongoing navigation</a> for <var>navigable</var> to null.</p>

        <p class="note">This allows new <a href="#navigate" id="updating-the-traversable:navigate-2">navigations</a> of
        <var>navigable</var> to start, whereas during the traversal they were blocked.</p>
       </li><li><p><a href="#queue-a-global-task" id="updating-the-traversable:queue-a-global-task-3">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="updating-the-traversable:navigation-and-traversal-task-source-3">navigation and traversal task
       source</a> given <var>navigable</var>'s <a href="#nav-window" id="updating-the-traversable:nav-window-4">active window</a> to
       perform <var>afterPotentialUnloads</var>.</p></li></ol>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p><a id="updating-the-traversable:assert-7" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigationType</var> is not null.</p></li><li><p><a href="#deactivate-a-document-for-a-cross-document-navigation" id="updating-the-traversable:deactivate-a-document-for-a-cross-document-navigation">Deactivate</a>
       <var>displayedDocument</var>, given <var>userInvolvement</var>, <var>targetEntry</var>,
       <var>navigationType</var>, and <var>afterPotentialUnloads</var>.</p></li></ol>
     </li><li>
      <p>In both cases, let <var>afterPotentialUnloads</var> be the following steps:</p>

      <ol><li><p>Let <var>previousEntry</var> be <var>navigable</var>'s <a href="#nav-active-history-entry" id="updating-the-traversable:nav-active-history-entry-3">active session history entry</a>.</p></li><li><p>If <var>changingNavigableContinuation</var>'s <a href="#changing-nav-continuation-update-only" id="updating-the-traversable:changing-nav-continuation-update-only-5">update-only</a> is false, then
       <a href="#activate-history-entry" id="updating-the-traversable:activate-history-entry">activate history entry</a> <var>targetEntry</var> for
       <var>navigable</var>.</p></li><li><p>Let <var>updateDocument</var> be an algorithm step which performs <a href="#update-document-for-history-step-application" id="updating-the-traversable:update-document-for-history-step-application">update
       document for history step application</a> given <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-9">document</a>, <var>targetEntry</var>,
       <var>changingNavigableContinuation</var>'s <a href="#changing-nav-continuation-update-only" id="updating-the-traversable:changing-nav-continuation-update-only-6">update-only</a>,
       <var>scriptHistoryLength</var>, <var>scriptHistoryIndex</var>, <var>navigationType</var>,
       <var>entriesForNavigationAPI</var>, and <var>previousEntry</var>.</p></li><li><p>If <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-10">document</a> is equal to
       <var>displayedDocument</var>, then perform <var>updateDocument</var>.</p></li><li><p>Otherwise, <a href="#queue-a-global-task" id="updating-the-traversable:queue-a-global-task-4">queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="updating-the-traversable:navigation-and-traversal-task-source-4">navigation and traversal task
       source</a> given <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-11">document</a>'s
       <a href="#concept-relevant-global" id="updating-the-traversable:concept-relevant-global">relevant global object</a> to perform <var>updateDocument</var>.</p></li><li><p>Increment <var>completedChangeJobs</var>.</p></li></ol>
     </li></ol>
   </li><li>
    <p>Let <var>totalNonchangingJobs</var> be the <a href="https://infra.spec.whatwg.org/#list-size" id="updating-the-traversable:list-size-2" data-x-internal="list-size">size</a> of
    <var>nonchangingNavigablesThatStillNeedUpdates</var>.</p>

    <p class="note">This step onwards deliberately waits for all the previous operations to
    complete, as they include <a href="#sync-navigations-jump-queue">processing synchronous
    navigations</a> which will also post tasks to update history length and index.</p>
   </li><li><p>Let <var>completedNonchangingJobs</var> be 0.</p></li><li><p>Let (<var>scriptHistoryLength</var>, <var>scriptHistoryIndex</var>) be the result of
   <a href="#getting-the-history-object-length-and-index" id="updating-the-traversable:getting-the-history-object-length-and-index-2">getting the history object length and index</a> given <var>traversable</var> and
   <var>targetStep</var>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-traversable:list-iterate-4" data-x-internal="list-iterate">For each</a> <var>navigable</var> of
    <var>nonchangingNavigablesThatStillNeedUpdates</var>, <a href="#queue-a-global-task" id="updating-the-traversable:queue-a-global-task-5">queue a global task</a> on the
    <a href="#navigation-and-traversal-task-source" id="updating-the-traversable:navigation-and-traversal-task-source-5">navigation and traversal task source</a> given <var>navigable</var>'s <a href="#nav-window" id="updating-the-traversable:nav-window-5">active window</a> to run the steps:</p>

    <ol><li><p>Let <var>document</var> be <var>navigable</var>'s <a href="#nav-document" id="updating-the-traversable:nav-document-2">active
     document</a>.</p></li><li><p>Set <var>document</var>'s <a href="#doc-history" id="updating-the-traversable:doc-history">history object</a>'s <a href="#concept-history-index" id="updating-the-traversable:concept-history-index">index</a> to <var>scriptHistoryIndex</var>.</p></li><li><p>Set <var>document</var>'s <a href="#doc-history" id="updating-the-traversable:doc-history-2">history object</a>'s <a href="#concept-history-length" id="updating-the-traversable:concept-history-length">length</a> to <var>scriptHistoryLength</var>.</p></li><li><p>Increment <var>completedNonchangingJobs</var>.</p></li></ol>
   </li><li><p>Wait for <var>completedNonchangingJobs</var> to equal
   <var>totalNonchangingJobs</var>.</p></li><li><p>Set <var>traversable</var>'s <a href="#tn-current-session-history-step" id="updating-the-traversable:tn-current-session-history-step-3">current
   session history step</a> to <var>targetStep</var>.</p></li><li><p>Return "<code>applied</code>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="deactivate-a-document-for-a-cross-document-navigation">deactivate a document for a cross-document navigation</dfn> given a
  <code id="updating-the-traversable:document-2"><a href="#document">Document</a></code> <var>displayedDocument</var>, a <a href="#user-navigation-involvement" id="updating-the-traversable:user-navigation-involvement-6">user navigation involvement</a>
  <var>userNavigationInvolvement</var>, a <a href="#session-history-entry" id="updating-the-traversable:session-history-entry-2">session history entry</a> <var>targetEntry</var>,
  a <code id="updating-the-traversable:navigationtype-2"><a href="#navigationtype">NavigationType</a></code> <var>navigationType</var>, and <var>afterPotentialUnloads</var>,
  which is an algorithm that receives no arguments:</p>

  <ol><li><p>Let <var>navigable</var> be <var>displayedDocument</var>'s
   <a href="#node-navigable" id="updating-the-traversable:node-navigable">node navigable</a>.</p></li><li><p>Let <var>potentiallyTriggerViewTransition</var> be false.</p></li><li><p>Let <var>isBrowserUINavigation</var> be true if
   <var>userNavigationInvolvement</var> is "<code id="updating-the-traversable:uni-browser-ui"><a href="#uni-browser-ui">browser UI</a></code>"; otherwise false.</p></li><li><p>Set <var>potentiallyTriggerViewTransition</var> to the result of calling
   <a id="updating-the-traversable:can-navigation-trigger-a-cross-document-view-transition" href="https://drafts.csswg.org/css-view-transitions-2/#can-navigation-trigger-a-cross-document-view-transition" data-x-internal="can-navigation-trigger-a-cross-document-view-transition">can navigation trigger a cross-document view-transition?</a> given
   <var>displayedDocument</var>, <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-12">document</a>, <var>navigationType</var>, and
   <var>isBrowserUINavigation</var>.</p></li><li>
    <p>If <var>potentiallyTriggerViewTransition</var> is false, then:</p>

    <ol><li>
      <p>Let <var>firePageSwapBeforeUnload</var> be the following step:</p>

      <ol><li><p><a href="#fire-the-pageswap-event" id="updating-the-traversable:fire-the-pageswap-event">Fire the <code>pageswap</code> event</a> given
       <var>displayedDocument</var>, <var>targetEntry</var>, <var>navigationType</var>, and
       null.</p></li></ol>
     </li><li>
      <p><a href="#set-the-ongoing-navigation" id="updating-the-traversable:set-the-ongoing-navigation-3">Set the ongoing navigation</a> for <var>navigable</var> to null.</p>

      <p class="note">This allows new <a href="#navigate" id="updating-the-traversable:navigate-3">navigations</a> of
      <var>navigable</var> to start, whereas during the traversal they were blocked.</p>
     </li><li><p><a href="#unload-a-document-and-its-descendants" id="updating-the-traversable:unload-a-document-and-its-descendants">Unload a document and its descendants</a> given
     <var>displayedDocument</var>, <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-13">document</a>, <var>afterPotentialUnloads</var>, and
     <var>firePageSwapBeforeUnload</var>.</p></li></ol>
   </li><li>
    <p>Otherwise, <a href="#queue-a-global-task" id="updating-the-traversable:queue-a-global-task-6">queue a global task</a> on the
    <a href="#navigation-and-traversal-task-source" id="updating-the-traversable:navigation-and-traversal-task-source-6">navigation and traversal task source</a> given <var>navigable</var>'s <a href="#nav-window" id="updating-the-traversable:nav-window-6">active window</a> to run the steps:</p>

    <ol><li>
      <p>Let <var>proceedWithNavigationAfterViewTransitionCapture</var> be the following
      step:</p>

      <ol><li>
        <p><a href="#tn-append-session-history-traversal-steps" id="updating-the-traversable:tn-append-session-history-traversal-steps">Append the following session
        history traversal steps</a> to <var>navigable</var>'s <a href="#nav-traversable" id="updating-the-traversable:nav-traversable">traversable navigable</a>:</p>

        <ol><li>
          <p><a href="#set-the-ongoing-navigation" id="updating-the-traversable:set-the-ongoing-navigation-4">Set the ongoing navigation</a> for <var>navigable</var> to null.</p>

          <p class="note">This allows new <a href="#navigate" id="updating-the-traversable:navigate-4">navigations</a> of
          <var>navigable</var> to start, whereas during the traversal they were blocked.</p>
         </li><li><p><a href="#unload-a-document-and-its-descendants" id="updating-the-traversable:unload-a-document-and-its-descendants-2">Unload a document and its descendants</a> given
         <var>displayedDocument</var>, <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-14">document</a>, and <var>afterPotentialUnloads</var>.</p></li></ol>
       </li></ol>
     </li><li><p>Let <var>viewTransition</var> be the result of
     <a id="updating-the-traversable:setting-up-a-cross-document-view-transition" href="https://drafts.csswg.org/css-view-transitions-2/#setup-cross-document-view-transition" data-x-internal="setting-up-a-cross-document-view-transition">setting up a cross-document view-transition</a> given
     <var>displayedDocument</var>, <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-15">document</a>, <var>navigationType</var>, and
     <var>proceedWithNavigationAfterViewTransitionCapture</var>.</p></li><li><p><a href="#fire-the-pageswap-event" id="updating-the-traversable:fire-the-pageswap-event-2">Fire the <code>pageswap</code> event</a> given
     <var>displayedDocument</var>, <var>targetEntry</var>, <var>navigationType</var>, and
     <var>viewTransition</var>.</p>

     </li><li>
      <p>If <var>viewTransition</var> is null, then run
      <var>proceedWithNavigationAfterViewTransitionCapture</var>.</p>

      <p class="note">In the case where a view transition started, the view transitions
      algorithms are responsible for calling
      <var>proceedWithNavigationAfterViewTransitionCapture</var>.</p>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fire-the-pageswap-event">fire the <code>pageswap</code> event</dfn> given a
  <code id="updating-the-traversable:document-3"><a href="#document">Document</a></code> <var>displayedDocument</var>, a <a href="#session-history-entry" id="updating-the-traversable:session-history-entry-3">session history entry</a>
  <var>targetEntry</var>, a <code id="updating-the-traversable:navigationtype-3"><a href="#navigationtype">NavigationType</a></code> <var>navigationType</var>, and a
  <code id="updating-the-traversable:viewtransition"><a data-x-internal="viewtransition" href="https://drafts.csswg.org/css-view-transitions/#viewtransition">ViewTransition</a></code>-or-null <var>viewTransition</var>:</p>

  <ol><li><p><a id="updating-the-traversable:assert-8" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running as part of a <a href="#concept-task" id="updating-the-traversable:concept-task">task</a> queued on <var>displayedDocument</var>'s
   <a href="#relevant-agent" id="updating-the-traversable:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="updating-the-traversable:concept-agent-event-loop">event loop</a>.</p></li><li><p>Let <var>navigation</var> be <var>displayedDocument</var>'s
   <a href="#concept-relevant-global" id="updating-the-traversable:concept-relevant-global-2">relevant global object</a>'s <a href="#window-navigation-api" id="updating-the-traversable:window-navigation-api-2">navigation API</a>.</p></li><li><p>Let <var>activation</var> be null.</p></li><li>
    <p>If all of the following are true:</p>

    <ul><li><p><var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-16">document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="updating-the-traversable:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a> is <a href="#same-origin" id="updating-the-traversable:same-origin-2">same origin</a> with
     <var>displayedDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="updating-the-traversable:concept-document-origin-4" data-x-internal="concept-document-origin">origin</a>;
     and</p></li><li><p><var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-17">document</a>'s
     <a href="#was-created-via-cross-origin-redirects" id="updating-the-traversable:was-created-via-cross-origin-redirects">was created via cross-origin redirects</a> is false, or <var>targetEntry</var>'s
     <a href="#she-document" id="updating-the-traversable:she-document-18">document</a>'s <a href="#latest-entry" id="updating-the-traversable:latest-entry">latest entry</a> is not null,</p></li></ul>

    <p>then:</p>

    <ol><li>
      <p>Let <var>destinationEntry</var> be determined by switching on
      <var>navigationType</var>:</p>

      <dl class="switch"><dt>"<code id="updating-the-traversable:dom-navigationtype-reload-3"><a href="#dom-navigationtype-reload">reload</a></code>"</dt><dd><p>The <a href="#navigation-current-entry" id="updating-the-traversable:navigation-current-entry">current entry</a> of
       <var>navigation</var></p></dd><dt>"<code id="updating-the-traversable:dom-navigationtype-traverse-4"><a href="#dom-navigationtype-traverse">traverse</a></code>"</dt><dd><p>The <code id="updating-the-traversable:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> in <var>navigation</var>'s <a href="#navigation-entry-list" id="updating-the-traversable:navigation-entry-list">entry list</a> whose <a href="#nhe-she" id="updating-the-traversable:nhe-she">session history entry</a> is <var>targetEntry</var></p></dd><dt>"<code id="updating-the-traversable:dom-navigationtype-push-2"><a href="#dom-navigationtype-push">push</a></code>"</dt><dt>"<code id="updating-the-traversable:dom-navigationtype-replace-2"><a href="#dom-navigationtype-replace">replace</a></code>"</dt><dd><p>A new <code id="updating-the-traversable:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> in <var>displayedDocument</var>'s <a href="#concept-relevant-realm" id="updating-the-traversable:concept-relevant-realm">relevant realm</a> with its <a href="#nhe-she" id="updating-the-traversable:nhe-she-2">session history entry</a> set to <var>targetEntry</var></p></dd></dl>
     </li><li>
      <p>Set <var>activation</var> to a <a id="updating-the-traversable:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="updating-the-traversable:navigationactivation"><a href="#navigationactivation">NavigationActivation</a></code>
      created in <var>displayedDocument</var>'s <a href="#concept-relevant-realm" id="updating-the-traversable:concept-relevant-realm-2">relevant
      realm</a>, with</p>

      <dl class="props"><dt><a href="#nav-activation-old-entry" id="updating-the-traversable:nav-activation-old-entry">old entry</a></dt><dd>the <a href="#navigation-current-entry" id="updating-the-traversable:navigation-current-entry-2">current entry</a> of
       <var>navigation</var></dd><dt><a href="#nav-activation-new-entry" id="updating-the-traversable:nav-activation-new-entry">new entry</a></dt><dd><var>destinationEntry</var></dd><dt><a href="#nav-activation-navigation-type" id="updating-the-traversable:nav-activation-navigation-type">navigation type</a></dt><dd><var>navigationType</var></dd></dl>
     </li></ol>

    <p class="note">This means that a cross-origin redirect during a navigation would result in a
    null <code id="updating-the-traversable:dom-pageswapevent-activation"><a href="#dom-pageswapevent-activation">activation</a></code> in the old document's
    <code id="updating-the-traversable:pageswapevent"><a href="#pageswapevent">PageSwapEvent</a></code>, unless the new document is being restored from <a href="#note-bfcache">bfcache</a>.</p>
   </li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-traversable:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named
   <code id="updating-the-traversable:event-pageswap"><a href="#event-pageswap">pageswap</a></code> at <var>displayedDocument</var>'s
   <a href="#concept-relevant-global" id="updating-the-traversable:concept-relevant-global-3">relevant global object</a>, using <code id="updating-the-traversable:pageswapevent-2"><a href="#pageswapevent">PageSwapEvent</a></code> with its <code id="updating-the-traversable:dom-pageswapevent-activation-2"><a href="#dom-pageswapevent-activation">activation</a></code> set to <var>activation</var>,
   and its <code id="updating-the-traversable:dom-pageswapevent-viewtransition"><a href="#dom-pageswapevent-viewtransition">viewTransition</a></code> set to
   <var>viewTransition</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="activate-history-entry">activate history entry</dfn> <a href="#session-history-entry" id="updating-the-traversable:session-history-entry-4">session history entry</a> <var>entry</var> for
  <a href="#navigable" id="updating-the-traversable:navigable-8">navigable</a> <var>navigable</var>:</p>

  <ol><li><p><a href="#save-persisted-state" id="updating-the-traversable:save-persisted-state">Save persisted state</a> to the <a href="#navigable" id="updating-the-traversable:navigable-9">navigable</a>'s <a href="#nav-active-history-entry" id="updating-the-traversable:nav-active-history-entry-4">active session history entry</a>.</p></li><li><p>Let <var>newDocument</var> be <var>entry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-19">document</a>.</p></li><li><p><a id="updating-the-traversable:assert-9" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>newDocument</var>'s <a href="#is-initial-about:blank" id="updating-the-traversable:is-initial-about:blank">is initial
   <code>about:blank</code></a> is false, i.e., we never traverse back to the <a href="#is-initial-about:blank" id="updating-the-traversable:is-initial-about:blank-2">initial <code>about:blank</code></a> <code id="updating-the-traversable:document-4"><a href="#document">Document</a></code> because it
   always gets <a href="#navigate-convert-to-replace">replaced</a> when we navigate away from
   it.</p></li><li><p>Set <var>navigable</var>'s <a href="#nav-active-history-entry" id="updating-the-traversable:nav-active-history-entry-5">active session history
   entry</a> to <var>entry</var>.</p></li><li><p><a href="#make-active" id="updating-the-traversable:make-active">Make active</a> <var>newDocument</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="getting-the-used-step">get the used step</dfn> given a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-9">traversable
  navigable</a> <var>traversable</var>, and a non-negative integer <var>step</var>, perform the
  following steps. They return a non-negative integer.</p>

  <ol><li><p>Let <var>steps</var> be the result of <a href="#getting-all-used-history-steps" id="updating-the-traversable:getting-all-used-history-steps">getting all used history steps</a> within
   <var>traversable</var>.</p></li><li>
    <p>Return the greatest <a href="https://infra.spec.whatwg.org/#list-item" id="updating-the-traversable:list-item-2" data-x-internal="list-item">item</a> in <var>steps</var> that is less
    than or equal to <var>step</var>.</p>

    <p class="note">This caters for situations where there's no <a href="#session-history-entry" id="updating-the-traversable:session-history-entry-5">session history entry</a>
    with <a href="#she-step" id="updating-the-traversable:she-step-5">step</a> <var>step</var>, due to the removal of a
    <a href="#navigable" id="updating-the-traversable:navigable-10">navigable</a>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="getting-the-history-object-length-and-index">get the history object length and
  index</dfn> given a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-10">traversable navigable</a> <var>traversable</var>, and a non-negative
  integer <var>step</var>, perform the following steps. They return a <a id="updating-the-traversable:tuple" href="https://infra.spec.whatwg.org/#tuple" data-x-internal="tuple">tuple</a> of two
  non-negative integers.</p>

  <ol><li><p>Let <var>steps</var> be the result of <a href="#getting-all-used-history-steps" id="updating-the-traversable:getting-all-used-history-steps-2">getting all used history steps</a> within
   <var>traversable</var>.</p></li><li><p>Let <var>scriptHistoryLength</var> be the <a href="https://infra.spec.whatwg.org/#list-size" id="updating-the-traversable:list-size-3" data-x-internal="list-size">size</a> of
   <var>steps</var>.</p></li><li>
    <p><a id="updating-the-traversable:assert-10" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>steps</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="updating-the-traversable:list-contains-4" data-x-internal="list-contains">contains</a>
    <var>step</var>.</p>

    <p class="note">It is assumed that <var>step</var> has been adjusted by <a href="#getting-the-used-step" id="updating-the-traversable:getting-the-used-step-2">getting the used
    step</a>.</p>
   </li><li><p>Let <var>scriptHistoryIndex</var> be the index of <var>step</var> in
   <var>steps</var>.</p></li><li><p>Return (<var>scriptHistoryLength</var>, <var>scriptHistoryIndex</var>).</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="get-all-navigables-whose-current-session-history-entry-will-change-or-reload">get all navigables whose current session history entry will change or reload</dfn>
  given a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-11">traversable navigable</a> <var>traversable</var>, and a non-negative integer
  <var>targetStep</var>, perform the following steps. They return a <a id="updating-the-traversable:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#navigable" id="updating-the-traversable:navigable-11">navigables</a>.</p>

  <ol><li><p>Let <var>results</var> be an empty <a id="updating-the-traversable:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p>Let <var>navigablesToCheck</var> be « <var>traversable</var> ».</p>

    <p class="note">This list is extended in the loop below.</p>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-traversable:list-iterate-5" data-x-internal="list-iterate">For each</a> <var>navigable</var> of
    <var>navigablesToCheck</var>:</p>

    <ol><li><p>Let <var>targetEntry</var> be the result of <a href="#getting-the-target-history-entry" id="updating-the-traversable:getting-the-target-history-entry-2">getting the target history
     entry</a> given <var>navigable</var> and <var>targetStep</var>.</p></li><li><p>If <var>targetEntry</var> is not <var>navigable</var>'s <a href="#nav-current-history-entry" id="updating-the-traversable:nav-current-history-entry-5">current session history entry</a> or
     <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-13">document state</a>'s <a href="#document-state-reload-pending" id="updating-the-traversable:document-state-reload-pending-6">reload pending</a> is true, then <a href="https://infra.spec.whatwg.org/#list-append" id="updating-the-traversable:list-append-2" data-x-internal="list-append">append</a> <var>navigable</var> to <var>results</var>.</p></li><li>
      <p>If <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-20">document</a> is
      <var>navigable</var>'s <a href="#nav-document" id="updating-the-traversable:nav-document-3">document</a>, and
      <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-14">document state</a>'s <a href="#document-state-reload-pending" id="updating-the-traversable:document-state-reload-pending-7">reload pending</a> is false, then <a href="https://infra.spec.whatwg.org/#list-extend" id="updating-the-traversable:list-extend" data-x-internal="list-extend">extend</a> <var>navigablesToCheck</var> with the <a href="#child-navigable" id="updating-the-traversable:child-navigable">child navigables</a> of <var>navigable</var>.</p>

      <p class="note">Adding <a href="#child-navigable" id="updating-the-traversable:child-navigable-2">child navigables</a> to
      <var>navigablesToCheck</var> means those navigables will also be checked by this loop. <a href="#child-navigable" id="updating-the-traversable:child-navigable-3">Child navigables</a> are only checked if the
      <var>navigable</var>'s <a href="#nav-document" id="updating-the-traversable:nav-document-4">active document</a> will not change as
      part of this traversal.</p>
     </li></ol>
   </li><li><p>Return <var>results</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="getting-all-navigables-that-only-need-history-object-length/index-update">get
  all navigables that only need history object length/index update</dfn> given a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-12">traversable
  navigable</a> <var>traversable</var>, and a non-negative integer <var>targetStep</var>,
  perform the following steps. They return a <a id="updating-the-traversable:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#navigable" id="updating-the-traversable:navigable-12">navigables</a>.</p>

  <p class="note">Other <a href="#navigable" id="updating-the-traversable:navigable-13">navigables</a> might not be impacted by the
  traversal. For example, if the response is a 204, the currently active document will remain.
  Additionally, going 'back' after a 204 will change the <a href="#nav-current-history-entry" id="updating-the-traversable:nav-current-history-entry-6">current session history entry</a>, but the <a href="#nav-active-history-entry" id="updating-the-traversable:nav-active-history-entry-6">active session history entry</a> will already be
  correct.</p>

  <ol><li><p>Let <var>results</var> be an empty <a id="updating-the-traversable:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p>Let <var>navigablesToCheck</var> be « <var>traversable</var> ».</p>

    <p class="note">This list is extended in the loop below.</p>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-traversable:list-iterate-6" data-x-internal="list-iterate">For each</a> <var>navigable</var> of
    <var>navigablesToCheck</var>:</p>

    <ol><li><p>Let <var>targetEntry</var> be the result of <a href="#getting-the-target-history-entry" id="updating-the-traversable:getting-the-target-history-entry-3">getting the target history
     entry</a> given <var>navigable</var> and <var>targetStep</var>.</p></li><li>
      <p>If <var>targetEntry</var> is <var>navigable</var>'s <a href="#nav-current-history-entry" id="updating-the-traversable:nav-current-history-entry-7">current session history entry</a> and
      <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-15">document state</a>'s <a href="#document-state-reload-pending" id="updating-the-traversable:document-state-reload-pending-8">reload pending</a> is false, then:</p>

      <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="updating-the-traversable:list-append-3" data-x-internal="list-append">Append</a> <var>navigable</var> to
       <var>results</var>.</p></li><li>
        <p><a href="https://infra.spec.whatwg.org/#list-extend" id="updating-the-traversable:list-extend-2" data-x-internal="list-extend">Extend</a> <var>navigablesToCheck</var> with
        <var>navigable</var>'s <a href="#child-navigable" id="updating-the-traversable:child-navigable-4">child navigables</a>.</p>

        <p class="note">Adding <a href="#child-navigable" id="updating-the-traversable:child-navigable-5">child navigables</a> to
        <var>navigablesToCheck</var> means those navigables will also be checked by this loop.
        <a href="#child-navigable" id="updating-the-traversable:child-navigable-6">child navigables</a> are only checked if the
        <var>navigable</var>'s <a href="#nav-document" id="updating-the-traversable:nav-document-5">active document</a> will not change
        as part of this traversal.</p>
       </li></ol>
     </li></ol>
   </li><li><p>Return <var>results</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="getting-the-target-history-entry">get the target history entry</dfn> given a
  <a href="#navigable" id="updating-the-traversable:navigable-14">navigable</a> <var>navigable</var>, and a non-negative integer <var>step</var>, perform
  the following steps. They return a <a href="#session-history-entry" id="updating-the-traversable:session-history-entry-6">session history entry</a>.</p>

  <ol><li><p>Let <var>entries</var> be the result of <a href="#getting-session-history-entries" id="updating-the-traversable:getting-session-history-entries">getting session history entries</a> for
   <var>navigable</var>.</p></li><li><p>Return the <a href="https://infra.spec.whatwg.org/#list-item" id="updating-the-traversable:list-item-3" data-x-internal="list-item">item</a> in <var>entries</var> that has the
   greatest <a href="#she-step" id="updating-the-traversable:she-step-6">step</a> less than or equal to <var>step</var>.</p></li></ol>
  </div>

  <div id="example-getting-the-target-history-entry" class="example"><a href="#example-getting-the-target-history-entry" class="self-link"></a>
   <p>To see why <a href="#getting-the-target-history-entry" id="updating-the-traversable:getting-the-target-history-entry-4">getting the target history entry</a> returns the entry with the greatest
   <a href="#she-step" id="updating-the-traversable:she-step-7">step</a> less than or equal to the input step, consider the following
   <a href="#jake-diagram" id="updating-the-traversable:jake-diagram">Jake diagram</a>:</p>

   
   <table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step">1</th><th class="step">2</th><th class="step">3</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="3" class="doc-0">/t</td><td colspan="1" class="doc-0">/t#foo</td></tr><tr><th><code>frames[0]</code></th><td colspan="1" class="doc-1">/i-0-a</td><td colspan="3" class="doc-2">/i-0-b</td></tr></tbody></table>

   <p>For the input step 1, the target history entry for the <code>top</code> navigable
   is the <code>/t</code> entry, whose <a href="#she-step" id="updating-the-traversable:she-step-8">step</a> is 0, while the target history entry for the <code>frames[0]</code> navigable is the <code>/i-0-b</code> entry, whose <a href="#she-step" id="updating-the-traversable:she-step-9">step</a> is 1:</p>

   
   <table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step current">1</th><th class="step">2</th><th class="step">3</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="3" class="doc-0 current next-is-same-doc">/t</td><td colspan="1" class="doc-0 prev-is-same-doc">/t#foo</td></tr><tr><th><code>frames[0]</code></th><td colspan="1" class="doc-1">/i-0-a</td><td colspan="3" class="doc-2 current">/i-0-b</td></tr></tbody></table>

   <p>Similarly, given the input step 3 we get the <code>top</code> entry whose <a href="#she-step" id="updating-the-traversable:she-step-10">step</a> is 3, and the <code>frames[0]</code> entry whose <a href="#she-step" id="updating-the-traversable:she-step-11">step</a> is 1:</p>

   
   <table class="jake-diagram"><thead><tr><td></td><th class="step">0</th><th class="step">1</th><th class="step">2</th><th class="step current">3</th></tr></thead><tbody><tr><th><code>top</code></th><td colspan="3" class="doc-0 next-is-same-doc">/t</td><td colspan="1" class="doc-0 current prev-is-same-doc">/t#foo</td></tr><tr><th><code>frames[0]</code></th><td colspan="1" class="doc-1">/i-0-a</td><td colspan="3" class="doc-2 current">/i-0-b</td></tr></tbody></table>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="getting-all-navigables-that-might-experience-a-cross-document-traversal">get
  all navigables that might experience a cross-document traversal</dfn> given a <a href="#traversable-navigable" id="updating-the-traversable:traversable-navigable-13">traversable
  navigable</a> <var>traversable</var>, and a non-negative integer <var>targetStep</var>,
  perform the following steps. They return a <a id="updating-the-traversable:list-5" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#navigable" id="updating-the-traversable:navigable-15">navigables</a>.</p>

  <div class="note">
   <p>From <var>traversable</var>'s <a href="#tn-session-history-traversal-queue" id="updating-the-traversable:tn-session-history-traversal-queue-5">session
   history traversal queue</a>'s perspective, these documents are candidates for going
   cross-document during the traversal described by <var>targetStep</var>. They will not experience
   a cross-document traversal if the status code for their target document is HTTP 204 No Content.</p>

   <p>Note that if a given <a href="#navigable" id="updating-the-traversable:navigable-16">navigable</a> might experience a cross-document traversal, this
   algorithm will return <a href="#navigable" id="updating-the-traversable:navigable-17">navigable</a> but not its <a href="#child-navigable" id="updating-the-traversable:child-navigable-7">child
   navigables</a>. Those would end up <a href="#unload-a-document" id="updating-the-traversable:unload-a-document">unloaded</a>, not
   traversed.</p>
  </div>

  <ol><li><p>Let <var>results</var> be an empty <a id="updating-the-traversable:list-6" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p>Let <var>navigablesToCheck</var> be « <var>traversable</var> ».</p>

    <p class="note">This list is extended in the loop below.</p>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-traversable:list-iterate-7" data-x-internal="list-iterate">For each</a> <var>navigable</var> of
    <var>navigablesToCheck</var>:</p>

    <ol><li><p>Let <var>targetEntry</var> be the result of <a href="#getting-the-target-history-entry" id="updating-the-traversable:getting-the-target-history-entry-5">getting the target history
     entry</a> given <var>navigable</var> and <var>targetStep</var>.</p></li><li>
      <p>If <var>targetEntry</var>'s <a href="#she-document" id="updating-the-traversable:she-document-21">document</a> is not
      <var>navigable</var>'s <a href="#nav-document" id="updating-the-traversable:nav-document-6">document</a> or
      <var>targetEntry</var>'s <a href="#she-document-state" id="updating-the-traversable:she-document-state-16">document state</a>'s <a href="#document-state-reload-pending" id="updating-the-traversable:document-state-reload-pending-9">reload pending</a> is true, then <a href="https://infra.spec.whatwg.org/#list-append" id="updating-the-traversable:list-append-4" data-x-internal="list-append">append</a> <var>navigable</var> to <var>results</var>.</p>

      <p class="note">Although <var>navigable</var>'s <a href="#nav-active-history-entry" id="updating-the-traversable:nav-active-history-entry-7">active history entry</a> can change synchronously, the
      new entry will always have the same <code id="updating-the-traversable:document-5"><a href="#document">Document</a></code>, so accessing
      <var>navigable</var>'s <a href="#nav-document" id="updating-the-traversable:nav-document-7">document</a> is reliable.</p>
     </li><li>
      <p>Otherwise, <a href="https://infra.spec.whatwg.org/#list-extend" id="updating-the-traversable:list-extend-3" data-x-internal="list-extend">extend</a> <var>navigablesToCheck</var> with
      <var>navigable</var>'s <a href="#child-navigable" id="updating-the-traversable:child-navigable-8">child navigables</a>.</p>

      <p class="note">Adding <a href="#child-navigable" id="updating-the-traversable:child-navigable-9">child navigables</a> to
      <var>navigablesToCheck</var> means those navigables will also be checked by this loop. <a href="#child-navigable" id="updating-the-traversable:child-navigable-10">Child navigables</a> are only checked if the
      <var>navigable</var>'s <a href="#nav-document" id="updating-the-traversable:nav-document-8">active document</a> will not change as
      part of this traversal.</p>
     </li></ol>
   </li><li><p>Return <var>results</var>.</p></li></ol>
  </div>


  <h5 id="updating-the-document"><span class="secno">7.4.6.2</span> Updating the document<a href="#updating-the-document" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="update-document-for-history-step-application">update document for history step application</dfn> given a <code id="updating-the-document:document"><a href="#document">Document</a></code>
  <var>document</var>, a <a href="#session-history-entry" id="updating-the-document:session-history-entry">session history entry</a> <var>entry</var>, a boolean
  <var>doNotReactivate</var>, integers <var>scriptHistoryLength</var> and
  <var>scriptHistoryIndex</var>, <code id="updating-the-document:navigationtype"><a href="#navigationtype">NavigationType</a></code>-or-null <var>navigationType</var>, an
  optional <a id="updating-the-document:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#session-history-entry" id="updating-the-document:session-history-entry-2">session history entries</a>
  <var>entriesForNavigationAPI</var>, and an optional <a href="#session-history-entry" id="updating-the-document:session-history-entry-3">session history entry</a>
  <var>previousEntryForActivation</var>:</p>

  <ol><li><p>Let <var>documentIsNew</var> be true if <var>document</var>'s <a href="#latest-entry" id="updating-the-document:latest-entry">latest entry</a>
   is null; otherwise false.</p></li><li><p>Let <var>documentsEntryChanged</var> be true if <var>document</var>'s <a href="#latest-entry" id="updating-the-document:latest-entry-2">latest
   entry</a> is not <var>entry</var>; otherwise false.</p></li><li><p>Set <var>document</var>'s <a href="#doc-history" id="updating-the-document:doc-history">history object</a>'s <a href="#concept-history-index" id="updating-the-document:concept-history-index">index</a> to <var>scriptHistoryIndex</var>.</p></li><li><p>Set <var>document</var>'s <a href="#doc-history" id="updating-the-document:doc-history-2">history object</a>'s <a href="#concept-history-length" id="updating-the-document:concept-history-length">length</a> to <var>scriptHistoryLength</var>.</p></li><li><p>Let <var>navigation</var> be <var>history</var>'s <a href="#concept-relevant-global" id="updating-the-document:concept-relevant-global">relevant global object</a>'s
   <a href="#window-navigation-api" id="updating-the-document:window-navigation-api">navigation API</a>.</p></li><li>
    <p>If <var>documentsEntryChanged</var> is true, then:</p>

    <ol><li><p>Let <var>oldURL</var> be <var>document</var>'s <a href="#latest-entry" id="updating-the-document:latest-entry-3">latest entry</a>'s <a href="#she-url" id="updating-the-document:she-url">URL</a>.</p></li><li><p>Set <var>document</var>'s <a href="#latest-entry" id="updating-the-document:latest-entry-4">latest entry</a> to <var>entry</var>.</p></li><li><p><a href="#restore-the-history-object-state" id="updating-the-document:restore-the-history-object-state">Restore the history object state</a> given <var>document</var> and
     <var>entry</var>.</p></li><li>
      <p>If <var>documentIsNew</var> is false, then:</p>

      <ol><li><p><a id="updating-the-document:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>navigationType</var> is not null.</p></li><li><p><a href="#update-the-navigation-api-entries-for-a-same-document-navigation" id="updating-the-document:update-the-navigation-api-entries-for-a-same-document-navigation">Update the navigation API entries for a same-document navigation</a> given
       <var>navigation</var>, <var>entry</var>, and <var>navigationType</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-document:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="updating-the-document:event-popstate"><a href="#event-popstate">popstate</a></code> at <var>document</var>'s <a href="#concept-relevant-global" id="updating-the-document:concept-relevant-global-2">relevant global
       object</a>, using <code id="updating-the-document:popstateevent"><a href="#popstateevent">PopStateEvent</a></code>, with the <code id="updating-the-document:dom-popstateevent-state"><a href="#dom-popstateevent-state">state</a></code> attribute initialized to <var>document</var>'s
       <a href="#doc-history" id="updating-the-document:doc-history-3">history object</a>'s <a href="#concept-history-state" id="updating-the-document:concept-history-state">state</a> and <code id="updating-the-document:dom-popstateevent-hasuavisualtransition"><a href="#dom-popstateevent-hasuavisualtransition">hasUAVisualTransition</a></code> initialized to
       true if a visual transition, to display a cached rendered state of the <a href="#latest-entry" id="updating-the-document:latest-entry-5">latest
       entry</a>, was done by the user agent.</p>

       </li><li><p><a href="#restore-persisted-state" id="updating-the-document:restore-persisted-state">Restore persisted state</a> given <var>entry</var>.</p></li><li><p>If <var>oldURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="updating-the-document:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> is not
       equal to <var>entry</var>'s <a href="#she-url" id="updating-the-document:she-url-2">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="updating-the-document:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a>, then <a href="#queue-a-global-task" id="updating-the-document:queue-a-global-task">queue a global task</a> on the
       <a href="#dom-manipulation-task-source" id="updating-the-document:dom-manipulation-task-source">DOM manipulation task source</a> given <var>document</var>'s <a href="#concept-relevant-global" id="updating-the-document:concept-relevant-global-3">relevant global
       object</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="updating-the-document:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="updating-the-document:event-hashchange"><a href="#event-hashchange">hashchange</a></code> at <var>document</var>'s <a href="#concept-relevant-global" id="updating-the-document:concept-relevant-global-4">relevant global
       object</a>, using <code id="updating-the-document:hashchangeevent"><a href="#hashchangeevent">HashChangeEvent</a></code>, with the <code id="updating-the-document:dom-hashchangeevent-oldurl"><a href="#dom-hashchangeevent-oldurl">oldURL</a></code> attribute initialized to the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="updating-the-document:concept-url-serializer" data-x-internal="concept-url-serializer">serialization</a> of <var>oldURL</var> and the <code id="updating-the-document:dom-hashchangeevent-newurl"><a href="#dom-hashchangeevent-newurl">newURL</a></code> attribute initialized to the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="updating-the-document:concept-url-serializer-2" data-x-internal="concept-url-serializer">serialization</a> of <var>entry</var>'s <a href="#she-url" id="updating-the-document:she-url-3">URL</a>.</p></li></ol>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p><a id="updating-the-document:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>entriesForNavigationAPI</var> is given.</p></li><li><p><a href="#restore-persisted-state" id="updating-the-document:restore-persisted-state-2">Restore persisted state</a> given <var>entry</var>.</p></li><li><p><a href="#initialize-the-navigation-api-entries-for-a-new-document" id="updating-the-document:initialize-the-navigation-api-entries-for-a-new-document">Initialize the navigation API entries for a new document</a> given
       <var>navigation</var>, <var>entriesForNavigationAPI</var>, and <var>entry</var>.</p></li></ol>
     </li></ol>
   </li><li>
    <p>If all the following are true:</p>

    <ul><li><p><var>previousEntryForActivation</var> is given;</p></li><li><p><var>navigationType</var> is non-null; and</p></li><li><p><var>navigationType</var> is "<code id="updating-the-document:dom-navigationtype-reload"><a href="#dom-navigationtype-reload">reload</a></code>" or
     <var>previousEntryForActivation</var>'s <a href="#she-document" id="updating-the-document:she-document">document</a> is not
     <var>document</var>,</p></li></ul>

    <p>then:</p>

    <ol><li><p>If <var>navigation</var>'s <a href="#navigation-activation" id="updating-the-document:navigation-activation">activation</a> is null, then set <var>navigation</var>'s
     <a href="#navigation-activation" id="updating-the-document:navigation-activation-2">activation</a> to a new
     <code id="updating-the-document:navigationactivation"><a href="#navigationactivation">NavigationActivation</a></code> object in <var>navigation</var>'s
     <a href="#concept-relevant-realm" id="updating-the-document:concept-relevant-realm">relevant realm</a>.</p></li><li><p>Let <var>previousEntryIndex</var> be the result of
     <a href="#getting-the-navigation-api-entry-index" id="updating-the-document:getting-the-navigation-api-entry-index">getting the navigation API entry index</a> of <var>previousEntryForActivation</var>
     within <var>navigation</var>.</p></li><li><p>If <var>previousEntryIndex</var> is non-negative, then set <var>activation</var>'s
     <a href="#nav-activation-old-entry" id="updating-the-document:nav-activation-old-entry">old entry</a> to <var>navigation</var>'s <a href="#navigation-entry-list" id="updating-the-document:navigation-entry-list">entry list</a>[<var>previousEntryIndex</var>].</p></li><li>
      <p>Otherwise, if all the following are true:</p>

      <ul><li><p><var>navigationType</var> is "<code id="updating-the-document:dom-navigationtype-replace"><a href="#dom-navigationtype-replace">replace</a></code>";</p></li><li><p><var>previousEntryForActivation</var>'s
       <a href="#she-document-state" id="updating-the-document:she-document-state">document state</a>'s <a href="#document-state-origin" id="updating-the-document:document-state-origin">origin</a> is <a href="#same-origin" id="updating-the-document:same-origin">same origin</a> with
       <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="updating-the-document:concept-document-origin" data-x-internal="concept-document-origin">origin</a>; and</p></li><li><p><var>previousEntryForActivation</var>'s <a href="#she-document" id="updating-the-document:she-document-2">document</a>'s
       <a href="#is-initial-about:blank" id="updating-the-document:is-initial-about:blank">initial <code>about:blank</code></a> is
       false,</p></li></ul>

      <p>then set <var>activation</var>'s <a href="#nav-activation-old-entry" id="updating-the-document:nav-activation-old-entry-2">old entry</a>
      to a new <code id="updating-the-document:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> in <var>navigation</var>'s <a href="#concept-relevant-realm" id="updating-the-document:concept-relevant-realm-2">relevant realm</a>, whose <a href="#nhe-she" id="updating-the-document:nhe-she">session history entry</a> is
      <var>previousEntryForActivation</var>.</p>
     </li><li><p>Set <var>activation</var>'s <a href="#nav-activation-new-entry" id="updating-the-document:nav-activation-new-entry">new entry</a> to
     <var>navigation</var>'s <a href="#navigation-current-entry" id="updating-the-document:navigation-current-entry">current entry</a>.</p></li><li><p>Set <var>activation</var>'s <a href="#nav-activation-navigation-type" id="updating-the-document:nav-activation-navigation-type">navigation type</a> to
     <var>navigationType</var>.</p></li></ol>
   </li><li>
    <p>If <var>documentIsNew</var> is true, then:</p>

    <ol><li><p><a id="updating-the-document:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var>'s <a href="#concept-document-navigation-id" id="updating-the-document:concept-document-navigation-id">during-loading navigation ID for WebDriver BiDi</a>
     is not null.</p></li><li><p>Invoke <a id="updating-the-document:webdriver-bidi-navigation-committed" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-committed" data-x-internal="webdriver-bidi-navigation-committed">WebDriver BiDi navigation committed</a> with <var>navigable</var> and a
     new <a id="updating-the-document:webdriver-bidi-navigation-status" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="updating-the-document:navigation-status-id" data-x-internal="navigation-status-id">id</a> is <var>document</var>'s <a href="#concept-document-navigation-id" id="updating-the-document:concept-document-navigation-id-2">during-loading navigation ID for WebDriver BiDi</a>,
     <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="updating-the-document:navigation-status-status" data-x-internal="navigation-status-status">status</a> is "<code id="updating-the-document:navigation-status-committed"><a data-x-internal="navigation-status-committed" href="https://w3c.github.io/webdriver-bidi/#navigation-status-committed">committed</a></code>", and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="updating-the-document:navigation-status-url" data-x-internal="navigation-status-url">url</a> is <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="updating-the-document:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li><p><a href="#try-to-scroll-to-the-fragment" id="updating-the-document:try-to-scroll-to-the-fragment">Try to scroll to the fragment</a> for <var>document</var>.</p></li><li><p>At this point <dfn id="scripts-may-run-for-the-newly-created-document">scripts may run for the newly-created document</dfn>
     <var>document</var>.</p></li></ol>
   </li><li>
    <p>Otherwise, if <var>documentsEntryChanged</var> is false and <var>doNotReactivate</var> is
    false, then:</p>

    <ol><li><p><a id="updating-the-document:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>entriesForNavigationAPI</var> is given.</p></li><li><p><a href="#reactivate-a-document" id="updating-the-document:reactivate-a-document">Reactivate</a> <var>document</var> given
     <var>entry</var> and <var>entriesForNavigationAPI</var>.</p>
    </li></ol>

    <p class="note"><var>documentsEntryChanged</var> can be false for one of two reasons: either we
    are restoring from <a href="#note-bfcache">bfcache</a>, or we are asynchronously finishing up a
    synchronous navigation which already synchronously set <var>document</var>'s <a href="#latest-entry" id="updating-the-document:latest-entry-6">latest
    entry</a>. The <var>doNotReactivate</var> argument distinguishes between these two
    cases.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="restore-the-history-object-state">restore the history object state</dfn> given <code id="updating-the-document:document-2"><a href="#document">Document</a></code>
  <var>document</var> and <a href="#session-history-entry" id="updating-the-document:session-history-entry-4">session history entry</a> <var>entry</var>:</p>

  <ol><li><p>Let <var>targetRealm</var> be <var>document</var>'s <a href="#concept-relevant-realm" id="updating-the-document:concept-relevant-realm-3">relevant realm</a>.</p></li><li><p>Let <var>state</var> be <a href="#structureddeserialize" id="updating-the-document:structureddeserialize">StructuredDeserialize</a>(<var>entry</var>'s <a href="#she-classic-history-api-state" id="updating-the-document:she-classic-history-api-state">classic history API state</a>, <var>targetRealm</var>).
   If this throws an exception, catch it and let <var>state</var> be null.</p></li><li><p>Set <var>document</var>'s <a href="#doc-history" id="updating-the-document:doc-history-4">history object</a>'s <a href="#concept-history-state" id="updating-the-document:concept-history-state-2">state</a> to <var>state</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="make-active">make active</dfn> a <code id="updating-the-document:document-3"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p>Let <var>window</var> be <var>document</var>'s <a href="#concept-relevant-global" id="updating-the-document:concept-relevant-global-5">relevant global
   object</a>.</p></li><li><p>Set <var>document</var>'s <a href="#concept-document-bc" id="updating-the-document:concept-document-bc">browsing context</a>'s
   <code id="updating-the-document:windowproxy"><a href="#windowproxy">WindowProxy</a></code>'s <a href="#concept-windowproxy-window" id="updating-the-document:concept-windowproxy-window">[[Window]]</a> internal
   slot value to <var>window</var>.</p></li><li><p>Set <var>document</var>'s <a href="#visibility-state" id="updating-the-document:visibility-state">visibility state</a> to <var>document</var>'s
   <a href="#node-navigable" id="updating-the-document:node-navigable">node navigable</a>'s <a href="#nav-traversable" id="updating-the-document:nav-traversable">traversable navigable</a>'s
   <a href="#system-visibility-state" id="updating-the-document:system-visibility-state">system visibility state</a>.</p></li><li><p><a href="https://w3c.github.io/performance-timeline/#queue-a-performanceentry" id="updating-the-document:queue-a-performance-entry" data-x-internal="queue-a-performance-entry">Queue</a> a new
   <code id="updating-the-document:visibilitystateentry"><a href="#visibilitystateentry">VisibilityStateEntry</a></code> whose <a href="#visibilitystateentry-state" id="updating-the-document:visibilitystateentry-state">visibility
   state</a> is <var>document</var>'s <a href="#visibility-state" id="updating-the-document:visibility-state-2">visibility state</a> and whose <a href="#visibilitystateentry-timestamp" id="updating-the-document:visibilitystateentry-timestamp">timestamp</a> is zero.</p></li><li><p>Set <var>window</var>'s <a href="#relevant-settings-object" id="updating-the-document:relevant-settings-object">relevant settings object</a>'s <a href="#concept-environment-execution-ready-flag" id="updating-the-document:concept-environment-execution-ready-flag">execution ready flag</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn data-dfn-for="Document" id="reactivate-a-document" data-export="">reactivate</dfn> a
  <code id="updating-the-document:document-4"><a href="#document">Document</a></code> <var>document</var> given a <a href="#session-history-entry" id="updating-the-document:session-history-entry-5">session history entry</a>
  <var>reactivatedEntry</var> and a <a id="updating-the-document:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#session-history-entry" id="updating-the-document:session-history-entry-6">session history entries</a> <var>entriesForNavigationAPI</var>:</p>

  <p class="note">This algorithm updates <var>document</var> after it has come out of <a href="#note-bfcache">bfcache</a>, i.e., after it has been made <a href="#fully-active" id="updating-the-document:fully-active">fully active</a>
  again. Other specifications that want to watch for this change to the <a href="#fully-active" id="updating-the-document:fully-active-2">fully
  active</a> state are encouraged to add steps into this algorithm, so that the ordering
  of events that happen in effect of the change is clear.</p>

  <ol><li id="history-autocomplete"><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-document:list-iterate" data-x-internal="list-iterate">For each</a>
   <var>formControl</var> of form controls in <var>document</var> with an <a href="#autofill-field-name" id="updating-the-document:autofill-field-name">autofill field
   name</a> of "<code id="updating-the-document:attr-fe-autocomplete-off"><a href="#attr-fe-autocomplete-off">off</a></code>", invoke the <a href="#concept-form-reset-control" id="updating-the-document:concept-form-reset-control">reset algorithm</a> for <var>formControl</var>.</p></li><li>
    <p>If <var>document</var>'s <a href="#suspended-timer-handles" id="updating-the-document:suspended-timer-handles">suspended timer handles</a> is not <a href="https://infra.spec.whatwg.org/#list-is-empty" id="updating-the-document:list-is-empty" data-x-internal="list-is-empty">empty</a>:</p>

    <ol><li><p><a id="updating-the-document:assert-5" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var>'s <a href="#suspension-time" id="updating-the-document:suspension-time">suspension time</a> is not
     zero.</p></li><li><p>Let <var>suspendDuration</var> be the <a id="updating-the-document:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> minus
     <var>document</var>'s <a href="#suspension-time" id="updating-the-document:suspension-time-2">suspension time</a>.</p></li><li><p>Let <var>activeTimers</var> be <var>document</var>'s <a href="#concept-relevant-global" id="updating-the-document:concept-relevant-global-6">relevant global
     object</a>'s <a href="#map-of-active-timers" id="updating-the-document:map-of-active-timers">map of active timers</a>.</p></li><li><p>For each <var>handle</var> in <var>document</var>'s <a href="#suspended-timer-handles" id="updating-the-document:suspended-timer-handles-2">suspended timer
     handles</a>, if <var>activeTimers</var>[<var>handle</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="updating-the-document:map-exists" data-x-internal="map-exists">exists</a>, then increase <var>activeTimers</var>[<var>handle</var>] by
     <var>suspendDuration</var>.</p></li></ol>
   </li><li><p><a href="#update-the-navigation-api-entries-for-reactivation" id="updating-the-document:update-the-navigation-api-entries-for-reactivation">Update the navigation API entries for reactivation</a> given
   <var>document</var>'s <a href="#concept-relevant-global" id="updating-the-document:concept-relevant-global-7">relevant global object</a>'s <a href="#window-navigation-api" id="updating-the-document:window-navigation-api-2">navigation API</a>, <var>entriesForNavigationAPI</var>, and
   <var>reactivatedEntry</var>.</p></li><li>
    <p>If <var>document</var>'s <a href="#current-document-readiness" id="updating-the-document:current-document-readiness">current document readiness</a> is "<code>complete</code>", and <var>document</var>'s <a href="#page-showing" id="updating-the-document:page-showing">page showing</a> is false:</p>

    <ol><li><p>Set <var>document</var>'s <a href="#page-showing" id="updating-the-document:page-showing-2">page showing</a> to true.</p></li><li><p>Set <var>document</var>'s <a href="#has-been-revealed" id="updating-the-document:has-been-revealed">has been revealed</a> to false.</p>

     </li><li><p><a href="#update-the-visibility-state" id="updating-the-document:update-the-visibility-state">Update the visibility state</a> of <var>document</var> to "<code>visible</code>".</p></li><li><p><a href="#fire-a-page-transition-event" id="updating-the-document:fire-a-page-transition-event">Fire a page transition event</a> named <code id="updating-the-document:event-pageshow"><a href="#event-pageshow">pageshow</a></code> at <var>document</var>'s <a href="#concept-relevant-global" id="updating-the-document:concept-relevant-global-8">relevant global
     object</a> with true.</p></li></ol>

    
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="try-to-scroll-to-the-fragment">try to scroll to the fragment</dfn> for a <code id="updating-the-document:document-5"><a href="#document">Document</a></code> <var>document</var>,
  perform the following steps <a href="#in-parallel" id="updating-the-document:in-parallel">in parallel</a>:</p>

  <ol><li><p>Wait for an <a id="updating-the-document:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> amount of time. (This is intended to allow
   the user agent to optimize the user experience in the face of performance concerns.)</p></li><li>
    <p><a href="#queue-a-global-task" id="updating-the-document:queue-a-global-task-2">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="updating-the-document:navigation-and-traversal-task-source">navigation and traversal task source</a>
    given <var>document</var>'s <a href="#concept-relevant-global" id="updating-the-document:concept-relevant-global-9">relevant global object</a> to run these steps:</p>

    <ol><li><p>If <var>document</var> has no parser, or its parser has <a href="#stop-parsing" id="updating-the-document:stop-parsing">stopped parsing</a>, or the user agent has reason to believe the user is no longer
     interested in scrolling to the <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="updating-the-document:concept-url-fragment-3" data-x-internal="concept-url-fragment">fragment</a>, then abort
     these steps.</p></li><li><p><a href="#scroll-to-the-fragment-identifier" id="updating-the-document:scroll-to-the-fragment-identifier">Scroll to the fragment</a> given <var>document</var>.</p></li><li><p>If <var>document</var>'s <a href="#the-indicated-part-of-the-document" id="updating-the-document:the-indicated-part-of-the-document">indicated part</a> is still null, then <a href="#try-to-scroll-to-the-fragment" id="updating-the-document:try-to-scroll-to-the-fragment-2">try to
     scroll to the fragment</a> for <var>document</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="make-document-unsalvageable" data-export="">make document unsalvageable</dfn>, given a <code id="updating-the-document:document-6"><a href="#document">Document</a></code>
  <var>document</var> and a string <var>reason</var>:</p>

  <ol><li><p>Let <var>details</var> be a new <a href="#nrr-details-struct" id="updating-the-document:nrr-details-struct">not restored reason details</a> whose <a href="#nrr-details-reason" id="updating-the-document:nrr-details-reason">reason</a> is <var>reason</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="updating-the-document:set-append" data-x-internal="set-append">Append</a> <var>details</var> to <var>document</var>'s
   <a href="#concept-document-bfcache-blocking-details" id="updating-the-document:concept-document-bfcache-blocking-details">bfcache blocking details</a>.</p></li><li><p>Set <var>document</var>'s <i id="updating-the-document:concept-document-salvageable"><a href="#concept-document-salvageable">salvageable</a></i>
   state to false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="build-not-restored-reasons-for-document-state">build not restored reasons for document state</dfn> given <code id="updating-the-document:document-7"><a href="#document">Document</a></code>
  <var>document</var>:</p>

  <ol><li><p>Let <var>notRestoredReasonsForDocument</var> be a new <a href="#nrr-struct" id="updating-the-document:nrr-struct">not restored reasons</a>.</p></li><li><p>Set <var>notRestoredReasonsForDocument</var>'s <a href="#nrr-url" id="updating-the-document:nrr-url">URL</a> to
   <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="updating-the-document:the-document's-address-2" data-x-internal="the-document's-address">URL</a>.</p></li><li><p>Let <var>container</var> be <var>document</var>'s <a href="#node-navigable" id="updating-the-document:node-navigable-2">node navigable</a>'s <a href="#nav-container" id="updating-the-document:nav-container">container</a>.</p></li><li>
    <p>If <var>container</var> is an <code id="updating-the-document:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element:</p>

    <ol><li><p>Let <var>src</var> be the empty string.</p></li><li>
      <p>If <var>container</var> has a <code id="updating-the-document:dom-iframe-src"><a href="#dom-iframe-src">src</a></code> attribute:</p>

      <ol><li><p>Let <var>src</var> be the result of <a href="#encoding-parsing-and-serializing-a-url" id="updating-the-document:encoding-parsing-and-serializing-a-url">encoding-parsing-and-serializing a
       URL</a> given <var>container</var>'s <code id="updating-the-document:attr-iframe-src"><a href="#attr-iframe-src">src</a></code> attribute's
       value, relative to <var>container</var>'s <a id="updating-the-document:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>src</var> is failure, then set <var>src</var> to <var>container</var>'s <code id="updating-the-document:attr-iframe-src-2"><a href="#attr-iframe-src">src</a></code> attribute's value.</p></li></ol>
     </li><li><p>Set <var>notRestoredReasonsForDocument</var>'s <a href="#nrr-src" id="updating-the-document:nrr-src">src</a> to
     <var>src</var>.</p></li><li><p>Set <var>notRestoredReasonsForDocument</var>'s <a href="#nrr-id" id="updating-the-document:nrr-id">id</a> to
     <var>container</var>'s <code id="updating-the-document:the-id-attribute"><a href="#the-id-attribute">id</a></code> attribute's value, or the empty string
     if it has no such attribute.</p></li><li><p>Set <var>notRestoredReasonsForDocument</var>'s <a href="#nrr-name" id="updating-the-document:nrr-name">name</a> to
     <var>container</var>'s <code id="updating-the-document:attr-iframe-name"><a href="#attr-iframe-name">name</a></code> attribute's value, or the
     empty string if it has no such attribute.</p></li></ol>
   </li><li><p>Set <var>notRestoredReasonsForDocument</var>'s <a href="#nrr-reasons" id="updating-the-document:nrr-reasons">reasons</a>
   to a <a href="https://infra.spec.whatwg.org/#list-clone" id="updating-the-document:list-clone" data-x-internal="list-clone">clone</a> of <var>document</var>'s <a href="#concept-document-bfcache-blocking-details" id="updating-the-document:concept-document-bfcache-blocking-details-2">bfcache blocking details</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-document:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>navigable</var> of <var>document</var>'s
    <a href="#document-tree-child-navigables" id="updating-the-document:document-tree-child-navigables">document-tree child navigables</a>:</p>

    <ol><li><p>Let <var>childDocument</var> be <var>navigable</var>'s <a href="#nav-document" id="updating-the-document:nav-document">active document</a>.</p></li><li><p><a href="#build-not-restored-reasons-for-document-state" id="updating-the-document:build-not-restored-reasons-for-document-state">Build not restored reasons for document state</a> given
     <var>childDocument</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="updating-the-document:list-append" data-x-internal="list-append">Append</a> <var>childDocument</var>'s <a href="#concept-document-nrr" id="updating-the-document:concept-document-nrr">not restored reasons</a> to
     <var>notRestoredReasonsForDocument</var>'s <a href="#nrr-children" id="updating-the-document:nrr-children">children</a>.</p></li></ol>
   </li><li><p>Set <var>document</var>'s <a href="#node-navigable" id="updating-the-document:node-navigable-3">node navigable</a>'s <a href="#nav-active-history-entry" id="updating-the-document:nav-active-history-entry">active session history entry</a>'s <a href="#she-document-state" id="updating-the-document:she-document-state-2">document state</a>'s <a href="#document-state-not-restored-reasons" id="updating-the-document:document-state-not-restored-reasons">not restored reasons</a> to
   <var>notRestoredReasonsForDocument</var>.</p></li></ol>
  </div>

 <div data-algorithm="">
 <p>To <dfn id="build-not-restored-reasons-for-a-top-level-traversable-and-its-descendants">build not restored reasons for a top-level traversable and its descendants</dfn>
 given <a href="#top-level-traversable" id="updating-the-document:top-level-traversable">top-level traversable</a> <var>topLevelTraversable</var>:
 </p><ol><li><p><a href="#build-not-restored-reasons-for-document-state" id="updating-the-document:build-not-restored-reasons-for-document-state-2">Build not restored reasons for document state</a> given
  <var>topLevelTraversable</var>'s <a href="#nav-document" id="updating-the-document:nav-document-2">active document</a>.</p></li><li><p>Let <var>crossOriginDescendants</var> be an empty <a id="updating-the-document:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
   <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-document:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>childNavigable</var> of
   <var>topLevelTraversable</var>'s <a href="#nav-document" id="updating-the-document:nav-document-3">active document</a>'s
   <a href="#descendant-navigables" id="updating-the-document:descendant-navigables">descendant navigables</a>:</p>
   <ol><li><p>If <var>childNavigable</var>'s <a href="#nav-document" id="updating-the-document:nav-document-4">active document</a>'s
    <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="updating-the-document:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> is not <a href="#same-origin" id="updating-the-document:same-origin-2">same origin</a> with
    <var>topLevelTraversable</var>'s <a href="#nav-document" id="updating-the-document:nav-document-5">active document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="updating-the-document:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a>, then <a href="https://infra.spec.whatwg.org/#list-append" id="updating-the-document:list-append-2" data-x-internal="list-append">append</a>
    <var>childNavigable</var> to <var>crossOriginDescendants</var>.</p></li></ol>
  </li><li><p>Let <var>crossOriginDescendantsPreventsBfcache</var> be false.</p></li><li>
   <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="updating-the-document:list-iterate-4" data-x-internal="list-iterate">For each</a> <var>crossOriginNavigable</var> of
   <var>crossOriginDescendants</var>:</p>

   <ol><li><p>Let <var>reasonsForCrossOriginChild</var> be <var>crossOriginNavigable</var>'s <a href="#nav-document" id="updating-the-document:nav-document-6">active document</a>'s <a href="#document-state-2" id="updating-the-document:document-state-2">document state</a>'s <a href="#document-state-not-restored-reasons" id="updating-the-document:document-state-not-restored-reasons-2">not restored reasons</a>.</p></li><li><p>If <var>reasonsForCrossOriginChild</var>'s <a href="#nrr-reasons" id="updating-the-document:nrr-reasons-2">reasons</a>
    is not empty, set <var>crossOriginDescendantsPreventsBfcache</var> to true.</p></li><li><p>Set <var>reasonsForCrossOriginChild</var>'s <a href="#nrr-url" id="updating-the-document:nrr-url-2">URL</a> to
    null.</p></li><li><p>Set <var>reasonsForCrossOriginChild</var>'s <a href="#nrr-reasons" id="updating-the-document:nrr-reasons-3">reasons</a>
    to null.</p></li><li><p>Set <var>reasonsForCrossOriginChild</var>'s <a href="#nrr-children" id="updating-the-document:nrr-children-2">children</a>
    to null.</p></li></ol>
  </li><li><p>If <var>crossOriginDescendantsPreventsBfcache</var> is true, <a href="#make-document-unsalvageable" id="updating-the-document:make-document-unsalvageable">make document
  unsalvageable</a> given <var>topLevelTraversable</var>'s <a href="#nav-document" id="updating-the-document:nav-document-7">active document</a> and "<code id="updating-the-document:blocking-masked"><a href="#blocking-masked">masked</a></code>".</p></li></ol>
 </div>

  <h5 id="revealing-the-document"><span class="secno">7.4.6.3</span> Revealing the document<a href="#revealing-the-document" class="self-link"></a></h5>

  <p>A <code id="revealing-the-document:document"><a href="#document">Document</a></code> has a boolean <dfn id="has-been-revealed">has been revealed</dfn>, initially false. It is used
  to ensure that the <code id="revealing-the-document:event-pagereveal"><a href="#event-pagereveal">pagereveal</a></code> event is fired once for each
  activation of the <code id="revealing-the-document:document-2"><a href="#document">Document</a></code> (once when it's rendered initially, and once for each
  <a href="#reactivate-a-document" id="revealing-the-document:reactivate-a-document">reactivation</a>).</p>

  <div data-algorithm="">
  <p>To <dfn id="reveal">reveal</dfn> a <code id="revealing-the-document:document-3"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p>If <var>document</var>'s <a href="#has-been-revealed" id="revealing-the-document:has-been-revealed">has been revealed</a> is true, then return.</p></li><li><p>Set <var>document</var>'s <a href="#has-been-revealed" id="revealing-the-document:has-been-revealed-2">has been revealed</a> to true.</p></li><li><p>Let <var>transition</var> be the result of
   <a id="revealing-the-document:resolving-inbound-cross-document-view-transition" href="https://drafts.csswg.org/css-view-transitions-2/#resolve-inbound-cross-document-view-transition" data-x-internal="resolving-inbound-cross-document-view-transition">resolving inbound cross-document view-transition</a> for <var>document</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="revealing-the-document:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named
   <code id="revealing-the-document:event-pagereveal-2"><a href="#event-pagereveal">pagereveal</a></code> at <var>document</var>'s
   <a href="#concept-relevant-global" id="revealing-the-document:concept-relevant-global">relevant global object</a>, using <code id="revealing-the-document:pagerevealevent"><a href="#pagerevealevent">PageRevealEvent</a></code> with its <code id="revealing-the-document:dom-pagerevealevent-viewtransition"><a href="#dom-pagerevealevent-viewtransition">viewTransition</a></code> set to
   <var>transition</var>.</p></li><li>
    <p>If <var>transition</var> is not null, then:</p>

    <ol><li><p><a href="#prepare-to-run-script" id="revealing-the-document:prepare-to-run-script">Prepare to run script</a> given <var>document</var>'s
     <a href="#relevant-settings-object" id="revealing-the-document:relevant-settings-object">relevant settings object</a>.</p></li><li><p><a href="https://drafts.csswg.org/css-view-transitions/#activate-view-transition" id="revealing-the-document:activate-view-transition" data-x-internal="activate-view-transition">Activate</a> <var>transition</var>.</p></li><li><p><a href="#clean-up-after-running-script" id="revealing-the-document:clean-up-after-running-script">Clean up after running script</a> given <var>document</var>'s
     <a href="#relevant-settings-object" id="revealing-the-document:relevant-settings-object-2">relevant settings object</a>.</p></li></ol>

    <p class="note">Activating a view transition might resolve/reject promises, so by wrapping the
    activation with prepare/cleanup we ensure those promises are handled before the next rendering
    step.</p>
   </li></ol>
  </div>

  <p class="note">Though <code id="revealing-the-document:event-pagereveal-3"><a href="#event-pagereveal">pagereveal</a></code> is guaranteed to be fired
  during the first <a href="#update-the-rendering" id="revealing-the-document:update-the-rendering">update the rendering</a> step that displays an up-to-date version of the
  page, user agents are free to display a cached frame of the page before firing it. This prevents
  the presence of a <code id="revealing-the-document:event-pagereveal-4"><a href="#event-pagereveal">pagereveal</a></code> handler from delaying the
  presentation of such cached frame.</p>


  <h5 id="scrolling-to-a-fragment"><span class="secno">7.4.6.4</span> Scrolling to a fragment<a href="#scrolling-to-a-fragment" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="scroll-to-the-fragment-identifier">scroll to the fragment</dfn> given a
  <code id="scrolling-to-a-fragment:document"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p>If <var>document</var>'s <a href="#the-indicated-part-of-the-document" id="scrolling-to-a-fragment:the-indicated-part-of-the-document">indicated part</a> is null, then set
   <var>document</var>'s <a href="#target-element" id="scrolling-to-a-fragment:target-element">target element</a> to null.</p></li><li>
    <p>Otherwise, if <var>document</var>'s <a href="#the-indicated-part-of-the-document" id="scrolling-to-a-fragment:the-indicated-part-of-the-document-2">indicated part</a> is <a href="#top-of-the-document" id="scrolling-to-a-fragment:top-of-the-document">top of the
    document</a>, then:</p>

    <ol><li><p>Set <var>document</var>'s <a href="#target-element" id="scrolling-to-a-fragment:target-element-2">target element</a> to null.</p></li><li><p><a id="scrolling-to-a-fragment:scroll-to-the-beginning-of-the-document" href="https://drafts.csswg.org/cssom-view/#scroll-to-the-beginning-of-the-document" data-x-internal="scroll-to-the-beginning-of-the-document">Scroll to the beginning of the document</a> for <var>document</var>.
     <a href="#refsCSSOMVIEW">[CSSOMVIEW]</a></p></li><li><p>Return.</p></li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p><a id="scrolling-to-a-fragment:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var>'s <a href="#the-indicated-part-of-the-document" id="scrolling-to-a-fragment:the-indicated-part-of-the-document-3">indicated part</a> is an
     element.</p></li><li><p>Let <var>target</var> be <var>document</var>'s <a href="#the-indicated-part-of-the-document" id="scrolling-to-a-fragment:the-indicated-part-of-the-document-4">indicated part</a>.</p></li><li><p>Set <var>document</var>'s <a href="#target-element" id="scrolling-to-a-fragment:target-element-3">target element</a> to <var>target</var>.</p></li><li><p>Run the <a href="#ancestor-revealing-algorithm" id="scrolling-to-a-fragment:ancestor-revealing-algorithm">ancestor revealing algorithm</a> on <var>target</var>.</p></li><li><p><a href="https://drafts.csswg.org/cssom-view/#scroll-a-target-into-view" id="scrolling-to-a-fragment:scroll-a-target-into-view" data-x-internal="scroll-a-target-into-view">Scroll <var>target</var> into view</a>,
     with <i>behavior</i> set to "auto", <i>block</i> set to "start", and <i>inline</i>
     set to "nearest". <a href="#refsCSSOMVIEW">[CSSOMVIEW]</a></p></li><li><p>Run the <a href="#focusing-steps" id="scrolling-to-a-fragment:focusing-steps">focusing steps</a> for <var>target</var>, with the
     <code id="scrolling-to-a-fragment:document-2"><a href="#document">Document</a></code>'s <a id="scrolling-to-a-fragment:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> as the <i>fallback target</i>.</p></li><li><p>Move the <a href="#sequential-focus-navigation-starting-point" id="scrolling-to-a-fragment:sequential-focus-navigation-starting-point">sequential focus navigation starting point</a> to
     <var>target</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>A <code id="scrolling-to-a-fragment:document-3"><a href="#document">Document</a></code>'s <dfn id="the-indicated-part-of-the-document">indicated part</dfn> is
  the one that its <a href="https://dom.spec.whatwg.org/#concept-document-url" id="scrolling-to-a-fragment:the-document's-address" data-x-internal="the-document's-address">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="scrolling-to-a-fragment:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> identifies, or null if the fragment does not
  identify anything. The semantics of the <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="scrolling-to-a-fragment:concept-url-fragment-2" data-x-internal="concept-url-fragment">fragment</a> in
  terms of mapping it to a node is defined by the specification that defines the <a id="scrolling-to-a-fragment:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME
  type</a> used by the <code id="scrolling-to-a-fragment:document-4"><a href="#document">Document</a></code> (for example, the processing of <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="scrolling-to-a-fragment:concept-url-fragment-3" data-x-internal="concept-url-fragment">fragments</a> for <a href="https://mimesniff.spec.whatwg.org/#xml-mime-type" id="scrolling-to-a-fragment:xml-mime-type" data-x-internal="xml-mime-type">XML MIME
  types</a> is the responsibility of RFC7303). <a href="#refsRFC7303">[RFC7303]</a></p>
  </div>

  <p>There is also a <dfn id="target-element">target element</dfn> for each <code id="scrolling-to-a-fragment:document-5"><a href="#document">Document</a></code>, which is used in
  defining the <code id="scrolling-to-a-fragment:selector-target"><a href="#selector-target">:target</a></code> pseudo-class and is updated by the
  above algorithm. It is initially null.</p>

  <div data-algorithm="">
  <p>For an <a href="https://dom.spec.whatwg.org/#html-document" id="scrolling-to-a-fragment:html-documents" data-x-internal="html-documents">HTML document</a> <var>document</var>, its
  <a href="#the-indicated-part-of-the-document" id="scrolling-to-a-fragment:the-indicated-part-of-the-document-5">indicated part</a> is the result
  of <a href="#select-the-indicated-part" id="scrolling-to-a-fragment:select-the-indicated-part">selecting the indicated part</a> given
  <var>document</var> and <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="scrolling-to-a-fragment:the-document's-address-2" data-x-internal="the-document's-address">URL</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="select-the-indicated-part">select the indicated part</dfn> given a <code id="scrolling-to-a-fragment:document-6"><a href="#document">Document</a></code> <var>document</var> and a
  <a id="scrolling-to-a-fragment:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>:</p>

  <ol><li><p>If <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="scrolling-to-a-fragment:the-document's-address-3" data-x-internal="the-document's-address">URL</a> does not <a href="https://url.spec.whatwg.org/#concept-url-equals" id="scrolling-to-a-fragment:concept-url-equals" data-x-internal="concept-url-equals">equal</a>
   <var>url</var> with <i id="scrolling-to-a-fragment:url-equals-exclude-fragments"><a data-x-internal="url-equals-exclude-fragments" href="https://url.spec.whatwg.org/#url-equals-exclude-fragments">exclude fragments</a></i> set to
   true, then return null.</p></li><li><p>Let <var>fragment</var> be <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="scrolling-to-a-fragment:concept-url-fragment-4" data-x-internal="concept-url-fragment">fragment</a>.</p></li><li><p>If <var>fragment</var> is the empty string, then return the special value <dfn id="top-of-the-document">top of the
   document</dfn>.</p></li><li><p>Let <var>potentialIndicatedElement</var> be the result of <a href="#find-a-potential-indicated-element" id="scrolling-to-a-fragment:find-a-potential-indicated-element">finding a potential indicated element</a> given <var>document</var> and
   <var>fragment</var>.</p></li><li><p>If <var>potentialIndicatedElement</var> is not null, then return
   <var>potentialIndicatedElement</var>.</p></li><li><p>Let <var>fragmentBytes</var> be the result of <a href="https://url.spec.whatwg.org/#string-percent-decode" id="scrolling-to-a-fragment:percent-decode" data-x-internal="percent-decode">percent-decoding</a> <var>fragment</var>.</p></li><li><p>Let <var>decodedFragment</var> be the result of running <a id="scrolling-to-a-fragment:utf-8-decode-without-bom" href="https://encoding.spec.whatwg.org/#utf-8-decode-without-bom" data-x-internal="utf-8-decode-without-bom">UTF-8 decode without
   BOM</a> on <var>fragmentBytes</var>.</p></li><li><p>Set <var>potentialIndicatedElement</var> to the result of <a href="#find-a-potential-indicated-element" id="scrolling-to-a-fragment:find-a-potential-indicated-element-2">finding a potential indicated element</a> given <var>document</var> and
   <var>decodedFragment</var>.</p></li><li><p>If <var>potentialIndicatedElement</var> is not null, then return
   <var>potentialIndicatedElement</var>.</p></li><li><p>If <var>decodedFragment</var> is an <a id="scrolling-to-a-fragment:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the
   string <code>top</code>, then return the <a href="#top-of-the-document" id="scrolling-to-a-fragment:top-of-the-document-2">top of the document</a>.</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="find-a-potential-indicated-element">find a potential indicated element</dfn> given a <code id="scrolling-to-a-fragment:document-7"><a href="#document">Document</a></code>
  <var>document</var> and a string <var>fragment</var>, run these steps:</p>

  <ol><li><p>If there is an element <a href="https://dom.spec.whatwg.org/#in-a-document-tree" id="scrolling-to-a-fragment:in-a-document-tree" data-x-internal="in-a-document-tree">in the document tree</a>
   whose <a id="scrolling-to-a-fragment:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> is <var>document</var> and that has an <a href="https://dom.spec.whatwg.org/#concept-id" id="scrolling-to-a-fragment:concept-id" data-x-internal="concept-id">ID</a> equal to <var>fragment</var>, then return the first such element
   in <a id="scrolling-to-a-fragment:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li><li><p>If there is an <code id="scrolling-to-a-fragment:the-a-element"><a href="#the-a-element">a</a></code> element <a href="https://dom.spec.whatwg.org/#in-a-document-tree" id="scrolling-to-a-fragment:in-a-document-tree-2" data-x-internal="in-a-document-tree">in the document
   tree</a> whose <a id="scrolling-to-a-fragment:root-2" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> is <var>document</var> that has a <code id="scrolling-to-a-fragment:attr-a-name"><a href="#attr-a-name">name</a></code> attribute whose value is equal to <var>fragment</var>, then
   return the first such element in <a id="scrolling-to-a-fragment:tree-order-2" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li><li><p>Return null.</p></li></ol>
  </div>


  <h5 id="persisted-user-state-restoration"><span class="secno">7.4.6.5</span> Persisted history entry state<a href="#persisted-user-state-restoration" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="save-persisted-state">save persisted state</dfn> to a <a href="#session-history-entry" id="persisted-user-state-restoration:session-history-entry">session history entry</a>
  <var>entry</var>:</p>

  <ol><li><p>Set the <a href="#she-scroll-position" id="persisted-user-state-restoration:she-scroll-position">scroll position data</a> of <var>entry</var>
   to contain the scroll positions for all of <var>entry</var>'s <a href="#she-document" id="persisted-user-state-restoration:she-document">document</a>'s <a href="#restorable-scrollable-regions" id="persisted-user-state-restoration:restorable-scrollable-regions">restorable scrollable regions</a>.</p></li><li><p>Optionally, update <var>entry</var>'s <a href="#she-other" id="persisted-user-state-restoration:she-other">persisted user state</a>
   to reflect any state that the user agent wishes to persist, such as the values of form
   fields.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="restore-persisted-user-state">To <dfn id="restore-persisted-state">restore persisted state</dfn> from a <a href="#session-history-entry" id="persisted-user-state-restoration:session-history-entry-2">session
  history entry</a> <var>entry</var>:</p>

  <ol><li>
    <p>If <var>entry</var>'s <a href="#she-scroll-restoration-mode" id="persisted-user-state-restoration:she-scroll-restoration-mode">scroll restoration
    mode</a> is "<code id="persisted-user-state-restoration:dom-scrollrestoration-auto"><a href="#dom-scrollrestoration-auto">auto</a></code>", and <var>entry</var>'s
    <a href="#she-document" id="persisted-user-state-restoration:she-document-2">document</a>'s <a href="#concept-relevant-global" id="persisted-user-state-restoration:concept-relevant-global">relevant global object</a>'s <a href="#window-navigation-api" id="persisted-user-state-restoration:window-navigation-api">navigation API</a>'s <a href="#suppress-normal-scroll-restoration-during-ongoing-navigation" id="persisted-user-state-restoration:suppress-normal-scroll-restoration-during-ongoing-navigation">suppress normal scroll restoration
    during ongoing navigation</a> is false, then <a href="#restore-scroll-position-data" id="persisted-user-state-restoration:restore-scroll-position-data">restore scroll position data</a> given
    <var>entry</var>.</p>

    <p class="note">The user agent not restoring scroll positions does not imply that scroll
    positions will be left at any particular value (e.g., (0,0)). The actual scroll position depends
    on the navigation type and the user agent's particular caching strategy. So web applications
    cannot assume any particular scroll position but rather are urged to set it to what they want it
    to be.</p>

    <p class="note">If <a href="#suppress-normal-scroll-restoration-during-ongoing-navigation" id="persisted-user-state-restoration:suppress-normal-scroll-restoration-during-ongoing-navigation-2">suppress normal scroll restoration during ongoing navigation</a> is
    true, then <a href="#restore-scroll-position-data" id="persisted-user-state-restoration:restore-scroll-position-data-2">restoring scroll position data</a>
    might still happen at a later point, as part of <a href="#navigateevent-finish" id="persisted-user-state-restoration:navigateevent-finish">finishing</a> the relevant <code id="persisted-user-state-restoration:navigateevent"><a href="#navigateevent">NavigateEvent</a></code>, or via a
    <code id="persisted-user-state-restoration:dom-navigateevent-scroll"><a href="#dom-navigateevent-scroll">navigateEvent.scroll()</a></code> method call.</p>
   </li><li>
    <p>Optionally, update other aspects of <var>entry</var>'s <a href="#she-document" id="persisted-user-state-restoration:she-document-3">document</a> and its rendering, for instance values of form fields,
    that the user agent had previously recorded in <var>entry</var>'s <a href="#she-other" id="persisted-user-state-restoration:she-other-2">persisted user state</a>.</p>

    <p class="note">This can even include updating the <code id="persisted-user-state-restoration:attr-dir"><a href="#attr-dir">dir</a></code> attribute
    of <code id="persisted-user-state-restoration:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements or <code id="persisted-user-state-restoration:the-input-element"><a href="#the-input-element">input</a></code> elements whose <code id="persisted-user-state-restoration:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="persisted-user-state-restoration:text-(type=text)-state-and-search-state-(type=search)">Text</a>, <a href="#text-(type=text)-state-and-search-state-(type=search)" id="persisted-user-state-restoration:text-(type=text)-state-and-search-state-(type=search)-2">Search</a>,
    <a href="#telephone-state-(type=tel)" id="persisted-user-state-restoration:telephone-state-(type=tel)">Telephone</a>, <a href="#url-state-(type=url)" id="persisted-user-state-restoration:url-state-(type=url)">URL</a>, or <a href="#email-state-(type=email)" id="persisted-user-state-restoration:email-state-(type=email)">Email</a>
    state, if the persisted state includes the directionality of user input in such controls.</p>

    <p class="note">Restoring the value of form controls as part of this process does not fire any
    <code id="persisted-user-state-restoration:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> or <code id="persisted-user-state-restoration:event-change"><a href="#event-change">change</a></code> events, but
    can trigger the <code>formStateRestoreCallback</code> of <a href="#form-associated-custom-element" id="persisted-user-state-restoration:form-associated-custom-element">form-associated custom elements</a>.</p>
   </li></ol>
  </div>

  <hr>

  <p>Each <code id="persisted-user-state-restoration:document"><a href="#document">Document</a></code> has a boolean <dfn id="has-been-scrolled-by-the-user">has been scrolled by the user</dfn>, initially
  false. If the user scrolls the document, the user agent must set that document's <a href="#has-been-scrolled-by-the-user" id="persisted-user-state-restoration:has-been-scrolled-by-the-user">has been
  scrolled by the user</a> to true.</p>

  <div data-algorithm="">
  <p>The <dfn id="restorable-scrollable-regions">restorable scrollable regions</dfn> of a <code id="persisted-user-state-restoration:document-2"><a href="#document">Document</a></code> <var>document</var>
  are <var>document</var>'s <a id="persisted-user-state-restoration:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>, and all of <var>document</var>'s scrollable
  regions excepting any <a href="#navigable-container" id="persisted-user-state-restoration:navigable-container">navigable containers</a>.</p>
  </div>

  <p class="note"><a href="#child-navigable" id="persisted-user-state-restoration:child-navigable">Child navigable</a> scroll restoration is handled as part of state
  restoration for the <a href="#session-history-entry" id="persisted-user-state-restoration:session-history-entry-3">session history entry</a> for those <a href="#navigable" id="persisted-user-state-restoration:navigable">navigables</a>' <code id="persisted-user-state-restoration:document-3"><a href="#document">Document</a></code>s.</p>

  <div data-algorithm="">
  <p>To <dfn id="restore-scroll-position-data">restore scroll position data</dfn> given a <a href="#session-history-entry" id="persisted-user-state-restoration:session-history-entry-4">session history entry</a>
  <var>entry</var>:</p>

  <ol><li><p>Let <var>document</var> be <var>entry</var>'s <a href="#she-document" id="persisted-user-state-restoration:she-document-4">document</a>.</p></li><li><p>If <var>document</var>'s <a href="#has-been-scrolled-by-the-user" id="persisted-user-state-restoration:has-been-scrolled-by-the-user-2">has been scrolled by the user</a> is true, then the
   user agent should return.</p></li><li>
    <p>The user agent should attempt to use <var>entry</var>'s <a href="#she-scroll-position" id="persisted-user-state-restoration:she-scroll-position-2">scroll position data</a> to restore the scroll positions of
    <var>entry</var>'s <a href="#she-document" id="persisted-user-state-restoration:she-document-5">document</a>'s <a href="#restorable-scrollable-regions" id="persisted-user-state-restoration:restorable-scrollable-regions-2">restorable scrollable
    regions</a>. The user agent may continue to attempt to do so periodically, until
    <var>document</var>'s <a href="#has-been-scrolled-by-the-user" id="persisted-user-state-restoration:has-been-scrolled-by-the-user-3">has been scrolled by the user</a> becomes true.</p>

    <p class="note">This is formulated as an <em>attempt</em>, which is potentially repeated until
    success or until the user scrolls, due to the fact that relevant content indicated by the <a href="#she-scroll-position" id="persisted-user-state-restoration:she-scroll-position-3">scroll position data</a> might take some time to load from the
    network.</p>

    <p class="note">Scroll restoration might be affected by scroll anchoring.
    <a href="#refsCSSSCROLLANCHORING">[CSSSCROLLANCHORING]</a></p>
   </li></ol>
  </div>


  <h3 id="document-lifecycle"><span class="secno">7.5</span> Document lifecycle<a href="#document-lifecycle" class="self-link"></a></h3>

  <h4 id="shared-document-creation-infrastructure"><span class="secno">7.5.1</span> Shared document creation infrastructure<a href="#shared-document-creation-infrastructure" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When loading a document using one of the below algorithms, we use the
  following steps to <dfn id="initialise-the-document-object">create and initialize a <code>Document</code> object</dfn>,
  given a <a href="https://dom.spec.whatwg.org/#concept-document-type" id="shared-document-creation-infrastructure:concept-document-type" data-x-internal="concept-document-type">type</a> <var>type</var>, <a href="https://dom.spec.whatwg.org/#concept-document-content-type" id="shared-document-creation-infrastructure:concept-document-content-type" data-x-internal="concept-document-content-type">content type</a> <var>contentType</var>, and
  <a href="#navigation-params" id="shared-document-creation-infrastructure:navigation-params">navigation params</a> <var>navigationParams</var>:</p>

  <p class="note"><code id="shared-document-creation-infrastructure:document"><a href="#document">Document</a></code> objects are also created when <a href="#creating-a-new-browsing-context" id="shared-document-creation-infrastructure:creating-a-new-browsing-context">creating a new browsing
  context and document</a>; such <a href="#is-initial-about:blank" id="shared-document-creation-infrastructure:is-initial-about:blank">initial
  <code>about:blank</code></a> <code id="shared-document-creation-infrastructure:document-2"><a href="#document">Document</a></code> are never created by this algorithm. Also,
  <a href="#concept-document-bc" id="shared-document-creation-infrastructure:concept-document-bc">browsing context</a>-less <code id="shared-document-creation-infrastructure:document-3"><a href="#document">Document</a></code> objects can
  be created via various APIs, such as <code id="shared-document-creation-infrastructure:dom-domimplementation-createhtmldocument"><a data-x-internal="dom-domimplementation-createhtmldocument" href="https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument">document.implementation.createHTMLDocument()</a></code>.</p>

  <ol><li>
    <p>Let <var>browsingContext</var> be the result of <a href="#obtain-browsing-context-navigation" id="shared-document-creation-infrastructure:obtain-browsing-context-navigation">obtaining a browsing context to use for a
    navigation response</a> given <var>navigationParams</var>.</p>

    <p class="note">This can result in a <a href="#browsing-context-group-switches-due-to-cross-origin-opener-policy">browsing context
    group switch</a>, in which case <var>browsingContext</var> will be a <a href="#creating-a-new-browsing-context" id="shared-document-creation-infrastructure:creating-a-new-browsing-context-2">newly-created</a> <a href="#browsing-context" id="shared-document-creation-infrastructure:browsing-context">browsing context</a> instead
    of being <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="shared-document-creation-infrastructure:navigation-params-navigable">navigable</a>'s <a href="#nav-bc" id="shared-document-creation-infrastructure:nav-bc">active browsing
    context</a>. In such a case, the created <code id="shared-document-creation-infrastructure:window"><a href="#window">Window</a></code>, <code id="shared-document-creation-infrastructure:document-4"><a href="#document">Document</a></code>, and
    <a id="shared-document-creation-infrastructure:agent" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a> will not end up being used; because the created <code id="shared-document-creation-infrastructure:document-5"><a href="#document">Document</a></code>'s
    <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="shared-document-creation-infrastructure:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is <a href="#concept-origin-opaque" id="shared-document-creation-infrastructure:concept-origin-opaque">opaque</a>, we will end up creating a new <a id="shared-document-creation-infrastructure:agent-2" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a>
    and <code id="shared-document-creation-infrastructure:window-2"><a href="#window">Window</a></code> <a href="#create-new-agent-and-window">later in this algorithm</a> to
    go along with the new <code id="shared-document-creation-infrastructure:document-6"><a href="#document">Document</a></code>.</p>
   </li><li>
    <p>Let <var>permissionsPolicy</var> be the result of <a id="shared-document-creation-infrastructure:creating-a-permissions-policy-from-a-response" href="https://w3c.github.io/webappsec-feature-policy/#create-from-response" data-x-internal="creating-a-permissions-policy-from-a-response">creating a permissions policy from a
    response</a> given <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="shared-document-creation-infrastructure:navigation-params-navigable-2">navigable</a>'s <a href="#nav-container" id="shared-document-creation-infrastructure:nav-container">container</a>, <var>navigationParams</var>'s <a href="#navigation-params-origin" id="shared-document-creation-infrastructure:navigation-params-origin">origin</a>, and <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response">response</a>. <a href="#refsPERMISSIONSPOLICY">[PERMISSIONSPOLICY]</a></p>

    <div class="note">
     <p>The <a id="shared-document-creation-infrastructure:creating-a-permissions-policy-from-a-response-2" href="https://w3c.github.io/webappsec-feature-policy/#create-from-response" data-x-internal="creating-a-permissions-policy-from-a-response">creating a permissions policy from a response</a> algorithm makes use of the
     passed <a href="#concept-origin" id="shared-document-creation-infrastructure:concept-origin">origin</a>. If <code id="shared-document-creation-infrastructure:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code> has
     been used for <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="shared-document-creation-infrastructure:navigation-params-navigable-3">navigable</a>'s <a href="#nav-container-document" id="shared-document-creation-infrastructure:nav-container-document">container document</a>, then its <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="shared-document-creation-infrastructure:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> cannot be <a href="#same-origin-domain" id="shared-document-creation-infrastructure:same-origin-domain">same origin-domain</a> with
     the passed origin, because these steps run before the <var>document</var> is created, so it
     cannot itself yet have used <code id="shared-document-creation-infrastructure:dom-document-domain-2"><a href="#dom-document-domain">document.domain</a></code>. Note
     that this means that Permissions Policy checks are less permissive compared to doing a
     <a href="#same-origin" id="shared-document-creation-infrastructure:same-origin">same origin</a> check instead.</p>

     <p>See below for some examples of this in action.</p>
    </div>
   </li><li><p>Let <var>creationURL</var> be <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-2">response</a>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="shared-document-creation-infrastructure:concept-response-url" data-x-internal="concept-response-url">URL</a>.</p></li><li><p>If <var>navigationParams</var>'s <a href="#navigation-params-request" id="shared-document-creation-infrastructure:navigation-params-request">request</a>
   is non-null, then set <var>creationURL</var> to <var>navigationParams</var>'s <a href="#navigation-params-request" id="shared-document-creation-infrastructure:navigation-params-request-2">request</a>'s <a href="https://fetch.spec.whatwg.org/#concept-request-current-url" id="shared-document-creation-infrastructure:concept-request-current-url" data-x-internal="concept-request-current-url">current URL</a>.</p></li><li><p>Let <var>window</var> be null.</p></li><li>
    <p>If <var>browsingContext</var>'s <a href="#active-document" id="shared-document-creation-infrastructure:active-document">active document</a>'s <a href="#is-initial-about:blank" id="shared-document-creation-infrastructure:is-initial-about:blank-2">is initial
    <code>about:blank</code></a> is true, and <var>browsingContext</var>'s <a href="#active-document" id="shared-document-creation-infrastructure:active-document-2">active
    document</a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="shared-document-creation-infrastructure:concept-document-origin-3" data-x-internal="concept-document-origin">origin</a> is <a href="#same-origin-domain" id="shared-document-creation-infrastructure:same-origin-domain-2">same
    origin-domain</a> with <var>navigationParams</var>'s <a href="#navigation-params-origin" id="shared-document-creation-infrastructure:navigation-params-origin-2">origin</a>, then set <var>window</var> to
    <var>browsingContext</var>'s <a href="#active-window" id="shared-document-creation-infrastructure:active-window">active window</a>.</p>

    <p class="note">This means that both the <a href="#is-initial-about:blank" id="shared-document-creation-infrastructure:is-initial-about:blank-3">initial
    <code>about:blank</code></a> <code id="shared-document-creation-infrastructure:document-7"><a href="#document">Document</a></code>, and the new <code id="shared-document-creation-infrastructure:document-8"><a href="#document">Document</a></code> that
    is about to be created, will share the same <code id="shared-document-creation-infrastructure:window-3"><a href="#window">Window</a></code> object.</p>
  </li><li id="create-new-agent-and-window">
    <p>Otherwise:</p>

    <ol><li><p>Let <var>oacHeader</var> be the result of <a id="shared-document-creation-infrastructure:getting-a-structured-field-value" href="https://fetch.spec.whatwg.org/#concept-header-list-get-structured-header" data-x-internal="getting-a-structured-field-value">getting a structured field value</a>
     given `<code id="shared-document-creation-infrastructure:origin-agent-cluster"><a href="#origin-agent-cluster">Origin-Agent-Cluster</a></code>` and "<code>item</code>" from
     <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-3">response</a>'s
     <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="shared-document-creation-infrastructure:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a>.</p></li><li><p>Let <var>requestsOAC</var> be true if <var>oacHeader</var> is not
     null and <var>oacHeader</var>[0] is the <a href="https://httpwg.org/specs/rfc8941.html#boolean" id="shared-document-creation-infrastructure:http-structured-header-boolean" data-x-internal="http-structured-header-boolean">boolean</a> true; otherwise false.</p></li><li><p>If <var>navigationParams</var>'s <a href="#navigation-params-reserved-environment" id="shared-document-creation-infrastructure:navigation-params-reserved-environment">reserved environment</a> is a
     <a href="#non-secure-context" id="shared-document-creation-infrastructure:non-secure-context">non-secure context</a>, then set <var>requestsOAC</var> to false.</p></li><li><p>Let <var>agent</var> be the result of <a href="#obtain-similar-origin-window-agent" id="shared-document-creation-infrastructure:obtain-similar-origin-window-agent">obtaining a similar-origin window agent</a>
     given <var>navigationParams</var>'s <a href="#navigation-params-origin" id="shared-document-creation-infrastructure:navigation-params-origin-3">origin</a>,
     <var>browsingContext</var>'s <a href="#tlbc-group" id="shared-document-creation-infrastructure:tlbc-group">group</a>, and
     <var>requestsOAC</var>.</p></li><li>
      <p>Let <var>realmExecutionContext</var> be the result of <a href="#creating-a-new-javascript-realm" id="shared-document-creation-infrastructure:creating-a-new-javascript-realm">creating a new realm</a>
      given <var>agent</var> and the following customizations:</p>

      <ul><li><p>For the global object, create a new <code id="shared-document-creation-infrastructure:window-4"><a href="#window">Window</a></code> object.</p></li><li><p>For the global <b>this</b> binding, use <var>browsingContext</var>'s
       <code id="shared-document-creation-infrastructure:windowproxy"><a href="#windowproxy">WindowProxy</a></code> object.</p></li></ul>
     </li><li><p>Set <var>window</var> to the <a href="#concept-realm-global" id="shared-document-creation-infrastructure:concept-realm-global">global
     object</a> of <var>realmExecutionContext</var>'s Realm component.</p></li><li><p>Let <var>topLevelCreationURL</var> be <var>creationURL</var>.</p></li><li><p>Let <var>topLevelOrigin</var> be <var>navigationParams</var>'s <a href="#navigation-params-origin" id="shared-document-creation-infrastructure:navigation-params-origin-4">origin</a>.</p></li><li>
      <p>If <var>navigable</var>'s <a href="#nav-container" id="shared-document-creation-infrastructure:nav-container-2">container</a> is not null,
      then:</p>

      <ol><li><p>Let <var>parentEnvironment</var> be <var>navigable</var>'s <a href="#nav-container" id="shared-document-creation-infrastructure:nav-container-3">container</a>'s <a href="#relevant-settings-object" id="shared-document-creation-infrastructure:relevant-settings-object">relevant settings object</a>.</p></li><li><p>Set <var>topLevelCreationURL</var> to <var>parentEnvironment</var>'s <a href="#concept-environment-top-level-creation-url" id="shared-document-creation-infrastructure:concept-environment-top-level-creation-url">top-level
       creation URL</a>.</p></li><li><p>Set <var>topLevelOrigin</var> to <var>parentEnvironment</var>'s <a href="#concept-environment-top-level-origin" id="shared-document-creation-infrastructure:concept-environment-top-level-origin">top-level
       origin</a>.</p></li></ol>
     </li><li><p><a href="#set-up-a-window-environment-settings-object" id="shared-document-creation-infrastructure:set-up-a-window-environment-settings-object">Set up a window environment settings object</a> with <var>creationURL</var>,
     <var>realmExecutionContext</var>, <var>navigationParams</var>'s <a href="#navigation-params-reserved-environment" id="shared-document-creation-infrastructure:navigation-params-reserved-environment-2">reserved environment</a>,
     <var>topLevelCreationURL</var>, and <var>topLevelOrigin</var>.</p></li></ol>

    <p class="note">This is the usual case, where the new <code id="shared-document-creation-infrastructure:document-9"><a href="#document">Document</a></code> we're about to
    create gets a new <code id="shared-document-creation-infrastructure:window-5"><a href="#window">Window</a></code> to go along with it.</p>
   </li><li><p>Let <var>loadTimingInfo</var> be a new <a href="#document-load-timing-info" id="shared-document-creation-infrastructure:document-load-timing-info">document load timing info</a> with its
   <a href="#navigation-start-time" id="shared-document-creation-infrastructure:navigation-start-time">navigation start time</a> set to <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-4">response</a>'s <a href="https://fetch.spec.whatwg.org/#concept-response-timing-info" id="shared-document-creation-infrastructure:concept-response-timing-info" data-x-internal="concept-response-timing-info">timing info</a>'s <a href="https://fetch.spec.whatwg.org/#fetch-timing-info-start-time" id="shared-document-creation-infrastructure:fetch-timing-info-start-time" data-x-internal="fetch-timing-info-start-time">start time</a>.</p></li><li>
    <p>Let <var>document</var> be a new <code id="shared-document-creation-infrastructure:document-10"><a href="#document">Document</a></code>, with</p>

    <dl class="props"><dt><a href="https://dom.spec.whatwg.org/#concept-document-type" id="shared-document-creation-infrastructure:concept-document-type-2" data-x-internal="concept-document-type">type</a></dt><dd><var>type</var></dd><dt><a href="https://dom.spec.whatwg.org/#concept-document-content-type" id="shared-document-creation-infrastructure:concept-document-content-type-2" data-x-internal="concept-document-content-type">content type</a></dt><dd><var>contentType</var></dd><dt><a href="https://dom.spec.whatwg.org/#concept-document-origin" id="shared-document-creation-infrastructure:concept-document-origin-4" data-x-internal="concept-document-origin">origin</a></dt><dd><var>navigationParams</var>'s <a href="#navigation-params-origin" id="shared-document-creation-infrastructure:navigation-params-origin-5">origin</a></dd><dt><a href="#concept-document-bc" id="shared-document-creation-infrastructure:concept-document-bc-2">browsing context</a></dt><dd><var>browsingContext</var>

     </dd><dt><a href="#concept-document-policy-container" id="shared-document-creation-infrastructure:concept-document-policy-container">policy container</a></dt><dd><var>navigationParams</var>'s <a href="#navigation-params-policy-container" id="shared-document-creation-infrastructure:navigation-params-policy-container">policy
     container</a></dd><dt><a href="#concept-document-permissions-policy" id="shared-document-creation-infrastructure:concept-document-permissions-policy">permissions policy</a></dt><dd><var>permissionsPolicy</var></dd><dt><a href="#active-sandboxing-flag-set" id="shared-document-creation-infrastructure:active-sandboxing-flag-set">active sandboxing flag set</a></dt><dd><var>navigationParams</var>'s <a href="#navigation-params-sandboxing" id="shared-document-creation-infrastructure:navigation-params-sandboxing">final sandboxing
     flag set</a></dd><dt><a href="#concept-document-coop" id="shared-document-creation-infrastructure:concept-document-coop">opener policy</a></dt><dd><var>navigationParams</var>'s <a href="#navigation-params-coop" id="shared-document-creation-infrastructure:navigation-params-coop">cross-origin opener
     policy</a></dd><dt><a href="#load-timing-info" id="shared-document-creation-infrastructure:load-timing-info">load timing info</a></dt><dd><var>loadTimingInfo</var></dd><dt><a href="#was-created-via-cross-origin-redirects" id="shared-document-creation-infrastructure:was-created-via-cross-origin-redirects">was created via cross-origin redirects</a></dt><dd><var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-5">response</a>'s
     <a href="https://fetch.spec.whatwg.org/#response-has-cross-origin-redirects" id="shared-document-creation-infrastructure:concept-response-has-cross-origin-redirects" data-x-internal="concept-response-has-cross-origin-redirects">has cross-origin
     redirects</a></dd><dt><a href="#concept-document-navigation-id" id="shared-document-creation-infrastructure:concept-document-navigation-id">during-loading navigation ID for WebDriver BiDi</a></dt><dd><var>navigationParams</var>'s <a href="#navigation-params-id" id="shared-document-creation-infrastructure:navigation-params-id">id</a></dd><dt><a href="https://dom.spec.whatwg.org/#concept-document-url" id="shared-document-creation-infrastructure:the-document's-address" data-x-internal="the-document's-address">URL</a></dt><dd><var>creationURL</var></dd><dt><a href="#current-document-readiness" id="shared-document-creation-infrastructure:current-document-readiness">current document readiness</a></dt><dd>"<code>loading</code>"</dd><dt><a href="#concept-document-about-base-url" id="shared-document-creation-infrastructure:concept-document-about-base-url">about base URL</a></dt><dd><var>navigationParams</var>'s <a href="#navigation-params-about-base-url" id="shared-document-creation-infrastructure:navigation-params-about-base-url">about base URL</a></dd><dt><a href="https://dom.spec.whatwg.org/#concept-document-allow-declarative-shadow-roots" id="shared-document-creation-infrastructure:concept-document-allow-declarative-shadow-roots" data-x-internal="concept-document-allow-declarative-shadow-roots">allow declarative shadow
     roots</a></dt><dd>true</dd><dt><a href="https://dom.spec.whatwg.org/#document-custom-element-registry" id="shared-document-creation-infrastructure:document-custom-element-registry" data-x-internal="document-custom-element-registry">custom element registry</a></dt><dd>a new <code id="shared-document-creation-infrastructure:customelementregistry"><a href="#customelementregistry">CustomElementRegistry</a></code> object</dd></dl>
   </li><li><p>Set <var>window</var>'s <a href="#concept-document-window" id="shared-document-creation-infrastructure:concept-document-window">associated
   <code>Document</code></a> to <var>document</var>.</p></li><li><p><a id="shared-document-creation-infrastructure:run-csp-initialization-for-a-document" href="https://w3c.github.io/webappsec-csp/#run-document-csp-initialization" data-x-internal="run-csp-initialization-for-a-document">Run CSP initialization for a <code>Document</code></a> given
   <var>document</var>. <a href="#refsCSP">[CSP]</a></p>

   </li><li>
    <p>If <var>navigationParams</var>'s <a href="#navigation-params-request" id="shared-document-creation-infrastructure:navigation-params-request-3">request</a> is
    non-null, then:</p>

    <ol><li><p>Set <var>document</var>'s <a href="#the-document's-referrer" id="shared-document-creation-infrastructure:the-document's-referrer">referrer</a> to the
     empty string.</p></li><li><p>Let <var>referrer</var> be <var>navigationParams</var>'s <a href="#navigation-params-request" id="shared-document-creation-infrastructure:navigation-params-request-4">request</a>'s <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="shared-document-creation-infrastructure:concept-request-referrer" data-x-internal="concept-request-referrer">referrer</a>.</p></li><li>
      <p>If <var>referrer</var> is a <a id="shared-document-creation-infrastructure:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a>, then set <var>document</var>'s <a href="#the-document's-referrer" id="shared-document-creation-infrastructure:the-document's-referrer-2">referrer</a> to the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="shared-document-creation-infrastructure:concept-url-serializer" data-x-internal="concept-url-serializer">serialization</a> of <var>referrer</var>.</p>

      <p class="note">Per <cite>Fetch</cite>, <var>referrer</var> will be either a <a id="shared-document-creation-infrastructure:url-record-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL
      record</a> or "<code>no-referrer</code>" at this point.</p>
     </li></ol>
   </li><li>
    <p>If <var>navigationParams</var>'s <a href="#navigation-params-fetch-controller" id="shared-document-creation-infrastructure:navigation-params-fetch-controller">fetch
    controller</a> is not null, then:</p>

    <ol><li><p>Let <var>fullTimingInfo</var> be the result of <a href="https://fetch.spec.whatwg.org/#extract-full-timing-info" id="shared-document-creation-infrastructure:extract-full-timing-info" data-x-internal="extract-full-timing-info">extracting the full timing info</a> from <var>navigationParams</var>'s <a href="#navigation-params-fetch-controller" id="shared-document-creation-infrastructure:navigation-params-fetch-controller-2">fetch controller</a>.</p></li><li><p>Let <var>redirectCount</var> be 0 if <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-6">response</a>'s <a href="https://fetch.spec.whatwg.org/#response-has-cross-origin-redirects" id="shared-document-creation-infrastructure:concept-response-has-cross-origin-redirects-2" data-x-internal="concept-response-has-cross-origin-redirects">has cross-origin redirects</a> is
     true; otherwise <var>navigationParams</var>'s <a href="#navigation-params-request" id="shared-document-creation-infrastructure:navigation-params-request-5">request</a>'s <a href="https://fetch.spec.whatwg.org/#concept-request-redirect-count" id="shared-document-creation-infrastructure:concept-request-redirect-count" data-x-internal="concept-request-redirect-count">redirect count</a>.</p></li><li><p><a id="shared-document-creation-infrastructure:create-the-navigation-timing-entry" href="https://w3c.github.io/navigation-timing/#dfn-create-the-navigation-timing-entry" data-x-internal="create-the-navigation-timing-entry">Create the navigation timing entry</a> for <var>document</var>, given
     <var>fullTimingInfo</var>, <var>redirectCount</var>, <var>navigationTimingType</var>,
     <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-7">response</a>'s
     <a href="https://fetch.spec.whatwg.org/#response-service-worker-timing-info" id="shared-document-creation-infrastructure:concept-response-service-worker-timing-info" data-x-internal="concept-response-service-worker-timing-info">service worker timing info</a>,
     and <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-8">response</a>'s
     <a href="https://fetch.spec.whatwg.org/#concept-response-body-info" id="shared-document-creation-infrastructure:concept-response-body-info" data-x-internal="concept-response-body-info">body info</a>.</p></li></ol>
   </li><li><p><a id="shared-document-creation-infrastructure:create-the-navigation-timing-entry-2" href="https://w3c.github.io/navigation-timing/#dfn-create-the-navigation-timing-entry" data-x-internal="create-the-navigation-timing-entry">Create the navigation timing entry</a> for <var>document</var>, with
   <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-9">response</a>'s <a href="https://fetch.spec.whatwg.org/#concept-response-timing-info" id="shared-document-creation-infrastructure:concept-response-timing-info-2" data-x-internal="concept-response-timing-info">timing info</a>, <var>redirectCount</var>,
   <var>navigationParams</var>'s <a href="#navigation-params-nav-timing-type" id="shared-document-creation-infrastructure:navigation-params-nav-timing-type">navigation timing
   type</a>, and <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-10">response</a>'s <a href="https://fetch.spec.whatwg.org/#response-service-worker-timing-info" id="shared-document-creation-infrastructure:concept-response-service-worker-timing-info-2" data-x-internal="concept-response-service-worker-timing-info">service worker timing info</a>.</p></li><li>
    <p>If <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-11">response</a>
    has a `<code id="shared-document-creation-infrastructure:refresh"><a href="#refresh">Refresh</a></code>` header, then:</p>

    <ol><li><p>Let <var>value</var> be the <a href="https://infra.spec.whatwg.org/#isomorphic-decode" id="shared-document-creation-infrastructure:isomorphic-decode" data-x-internal="isomorphic-decode">isomorphic decoding</a>
     of the value of the header.</p></li><li><p>Run the <a href="#shared-declarative-refresh-steps" id="shared-document-creation-infrastructure:shared-declarative-refresh-steps">shared declarative refresh steps</a> with <var>document</var> and
     <var>value</var>.</p></li></ol>

    <p class="XXX">We do not currently have a spec for how to handle multiple `<code id="shared-document-creation-infrastructure:refresh-2"><a href="#refresh">Refresh</a></code>`
    headers. This is tracked as <a href="https://github.com/whatwg/html/issues/2900">issue #2900</a>.</p>
   </li><li><p>If <var>navigationParams</var>'s <a href="#navigation-params-commit-early-hints" id="shared-document-creation-infrastructure:navigation-params-commit-early-hints">commit early hints</a> is not null, then call
   <var>navigationParams</var>'s <a href="#navigation-params-commit-early-hints" id="shared-document-creation-infrastructure:navigation-params-commit-early-hints-2">commit early
   hints</a> with <var>document</var>.</p></li><li><p><a href="#process-link-headers" id="shared-document-creation-infrastructure:process-link-headers">Process link headers</a> given <var>document</var>,
   <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-12">response</a>, and
   "<code>pre-media</code>".</p></li><li>
    <p>If <var>navigationParams</var>'s <a href="#navigation-params-navigable" id="shared-document-creation-infrastructure:navigation-params-navigable-4">navigable</a>
    is a <a href="#top-level-traversable" id="shared-document-creation-infrastructure:top-level-traversable">top-level traversable</a>, then <a href="#process-the-speculation-rules-header" id="shared-document-creation-infrastructure:process-the-speculation-rules-header">process the `<code>Speculation-Rules</code>`
    header</a> given <var>document</var> and <var>navigationParams</var>'s <a href="#navigation-params-response" id="shared-document-creation-infrastructure:navigation-params-response-13">response</a>.</p>

    <p class="note">This is conditional because <a href="#step-consider-speculative-loads-top-level-only">speculative loads are only considered for
    top-level traversables</a>, so it would be wasteful to fetch these rules otherwise.</p>
   </li><li><p><a id="shared-document-creation-infrastructure:potentially-free-deferred-fetch-quota" href="https://fetch.spec.whatwg.org/#reserve-deferred-fetch-quota" data-x-internal="potentially-free-deferred-fetch-quota">Potentially free deferred fetch quota</a> for <var>document</var>.</p></li><li><p>Return <var>document</var>.</p></li></ol>
  </div>

  <div class="example">
   <p>In this example, the child document is not allowed to use <code id="shared-document-creation-infrastructure:paymentrequest"><a data-x-internal="paymentrequest" href="https://w3c.github.io/payment-request/#dom-paymentrequest">PaymentRequest</a></code>,
   despite being <a href="#same-origin-domain" id="shared-document-creation-infrastructure:same-origin-domain-3">same origin-domain</a> at the time the child document tries to use
   it. At the time the child document is initialized, only the parent document has set <code id="shared-document-creation-infrastructure:dom-document-domain-3"><a href="#dom-document-domain">document.domain</a></code>, and the child document has not.</p>

   <pre><code class="html"><c- c="">&lt;!-- https://foo.example.com/a.html --&gt;</c->
<c- cp="">&lt;!doctype html&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
document<c- p="">.</c->domain <c- o="">=</c-> <c- t="">'example.com'</c-><c- p="">;</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">b.html</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c-></code></pre>

  <pre><code class="html"><c- c="">&lt;!-- https://bar.example.com/b.html --&gt;</c->
<c- cp="">&lt;!doctype html&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
document<c- p="">.</c->domain <c- o="">=</c-> <c- t="">'example.com'</c-><c- p="">;</c-> <c- c1="">// This happens after the document is initialized</c->
<c- k="">new</c-> PaymentRequest<c- p="">(</c->…<c- p="">);</c-> <c- c1="">// Not allowed to use</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div class="example">
   <p>In this example, the child document <em>is</em> allowed to use
   <code id="shared-document-creation-infrastructure:paymentrequest-2"><a data-x-internal="paymentrequest" href="https://w3c.github.io/payment-request/#dom-paymentrequest">PaymentRequest</a></code>, despite not being <a href="#same-origin-domain" id="shared-document-creation-infrastructure:same-origin-domain-4">same origin-domain</a> at the time
   the child document tries to use it. At the time the child document is initialized, none of
   the documents have set <code id="shared-document-creation-infrastructure:dom-document-domain-4"><a href="#dom-document-domain">document.domain</a></code> yet so
   <a href="#same-origin-domain" id="shared-document-creation-infrastructure:same-origin-domain-5">same origin-domain</a> falls back to a normal <a href="#same-origin" id="shared-document-creation-infrastructure:same-origin-2">same origin</a> check.</p>

   <pre><code class="html"><c- c="">&lt;!-- https://example.com/a.html --&gt;</c->
<c- cp="">&lt;!doctype html&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">b.html</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
<c- c="">&lt;!-- The child document is now initialized, before the script below is run. --&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
document<c- p="">.</c->domain <c- o="">=</c-> <c- t="">'example.com'</c-><c- p="">;</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- c="">&lt;!-- https://example.com/b.html --&gt;</c->
<c- cp="">&lt;!doctype html&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- k="">new</c-> PaymentRequest<c- p="">(</c->…<c- p="">);</c-> <c- c1="">// Allowed to use</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="populate-with-html/head/body">populate with <code>html</code>/<code>head</code>/<code>body</code></dfn> given a
  <code id="shared-document-creation-infrastructure:document-11"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p>Let <var>html</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="shared-document-creation-infrastructure:create-an-element" data-x-internal="create-an-element">creating an
   element</a> given <var>document</var>, "<code>html</code>", and the <a id="shared-document-creation-infrastructure:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
   namespace</a>.</p></li><li><p>Let <var>head</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="shared-document-creation-infrastructure:create-an-element-2" data-x-internal="create-an-element">creating an
   element</a> given <var>document</var>, "<code>head</code>", and the <a id="shared-document-creation-infrastructure:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
   namespace</a>.</p></li><li><p>Let <var>body</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="shared-document-creation-infrastructure:create-an-element-3" data-x-internal="create-an-element">creating an
   element</a> given <var>document</var>, "<code>body</code>", and the <a id="shared-document-creation-infrastructure:html-namespace-2-3" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
   namespace</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="shared-document-creation-infrastructure:concept-node-append" data-x-internal="concept-node-append">Append</a> <var>html</var> to
   <var>document</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="shared-document-creation-infrastructure:concept-node-append-2" data-x-internal="concept-node-append">Append</a> <var>head</var> to
   <var>html</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="shared-document-creation-infrastructure:concept-node-append-3" data-x-internal="concept-node-append">Append</a> <var>body</var> to
   <var>html</var>.</p></li></ol>
  </div>


  <h4 id="read-html"><span class="secno">7.5.2</span> Loading HTML documents<a href="#read-html" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>To <dfn id="navigate-html">load an HTML document</dfn>, given <a href="#navigation-params" id="read-html:navigation-params">navigation
  params</a> <var>navigationParams</var>:</p>

  <ol><li><p>Let <var>document</var> be the result of <a href="#initialise-the-document-object" id="read-html:initialise-the-document-object">creating and initializing a <code>Document</code>
   object</a> given "<code>html</code>", "<code>text/html</code>", and
   <var>navigationParams</var>.</p></li><li>
    <p>If <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="read-html:the-document's-address" data-x-internal="the-document's-address">URL</a> is
    <code id="read-html:about:blank"><a href="#about:blank">about:blank</a></code>, then <a href="#populate-with-html/head/body" id="read-html:populate-with-html/head/body">populate with
    <code>html</code>/<code>head</code>/<code>body</code></a> given <var>document</var>.</p>

    <p class="note">This special case, where even non-<a href="#is-initial-about:blank" id="read-html:is-initial-about:blank">initial
    <code>about:blank</code></a> <code id="read-html:document"><a href="#document">Document</a></code>s are synchronously given their element
    nodes, is necessary for compatible with deployed content. In other words, it is not compatible
    to instead go down the "otherwise" branch and feed the empty <a id="read-html:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> into
    an <a href="#html-parser" id="read-html:html-parser">HTML parser</a> to asynchronously populate <var>document</var>.</p>
   </li><li>
    <p>Otherwise, create an <a href="#html-parser" id="read-html:html-parser-2">HTML parser</a> and associate it with the <var>document</var>.
    Each <a href="#concept-task" id="read-html:concept-task">task</a> that the <a href="#networking-task-source" id="read-html:networking-task-source">networking task source</a>
    places on the <a href="#task-queue" id="read-html:task-queue">task queue</a> while fetching runs must then fill the parser's
    <a href="#the-input-byte-stream" id="read-html:the-input-byte-stream">input byte stream</a> with the fetched bytes and cause the <a href="#html-parser" id="read-html:html-parser-3">HTML parser</a> to
    perform the appropriate processing of the input stream.</p>

    <p>The first <a href="#concept-task" id="read-html:concept-task-2">task</a> that the <a href="#networking-task-source" id="read-html:networking-task-source-2">networking task
    source</a> places on the <a href="#task-queue" id="read-html:task-queue-2">task queue</a> while fetching runs must <a href="#process-link-headers" id="read-html:process-link-headers">process link
    headers</a> given <var>document</var>, <var>navigationParams</var>'s <a href="#navigation-params-response" id="read-html:navigation-params-response">response</a>, and "<code>media</code>", after
    the task has been processed by the <a href="#html-parser" id="read-html:html-parser-4">HTML parser</a>.</p>

    <p>Before any script execution occurs, the user agent must wait for <a href="#scripts-may-run-for-the-newly-created-document" id="read-html:scripts-may-run-for-the-newly-created-document">scripts may run for
    the newly-created document</a> to be true for <var>document</var>.</p>

    <p class="note">The <a href="#the-input-byte-stream" id="read-html:the-input-byte-stream-2">input byte stream</a> converts bytes into characters for use in the
    <a href="#tokenization" id="read-html:tokenization">tokenizer</a>. This process relies, in part, on character encoding
    information found in the real <a href="#content-type" id="read-html:content-type">Content-Type metadata</a> of the
    resource; the computed type is not used for this purpose.</p>

    <p>When no more bytes are available, the user agent must <a href="#queue-a-global-task" id="read-html:queue-a-global-task">queue a global task</a> on
    the <a href="#networking-task-source" id="read-html:networking-task-source-3">networking task source</a> given <var>document</var>'s <a href="#concept-relevant-global" id="read-html:concept-relevant-global">relevant global
    object</a> to have the parser process the implied EOF character, which eventually causes
    a <code id="read-html:event-load"><a href="#event-load">load</a></code> event to be fired.</p>
   </li><li><p>Return <var>document</var>.</p></li></ol>
  </div>


  <h4 id="read-xml"><span class="secno">7.5.3</span> <dfn>Loading XML documents</dfn><a href="#read-xml" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When faced with displaying an XML file inline, provided <a href="#navigation-params" id="read-xml:navigation-params">navigation params</a>
  <var>navigationParams</var> and a string <var>type</var>, user agents must follow the
  requirements defined in <cite>XML</cite> and <cite>Namespaces in XML</cite>, <cite>XML Media
  Types</cite>, <cite>DOM</cite>, and other relevant specifications to <a href="#initialise-the-document-object" id="read-xml:initialise-the-document-object">create and initialize a <code>Document</code> object</a>
  <var>document</var>, given "<code>xml</code>", <var>type</var>, and
  <var>navigationParams</var>, and return that <code id="read-xml:document"><a href="#document">Document</a></code>. They must also create a
  corresponding <a href="#xml-parser" id="read-xml:xml-parser">XML parser</a>. <a href="#refsXML">[XML]</a> <a href="#refsXMLNS">[XMLNS]</a> <a href="#refsRFC7303">[RFC7303]</a>
  <a href="#refsDOM">[DOM]</a></p>

  <p class="note">At the time of writing, the XML specification community had not actually yet
  specified how XML and the DOM interact.</p> 

  <p>The first <a href="#concept-task" id="read-xml:concept-task">task</a> that the <a href="#networking-task-source" id="read-xml:networking-task-source">networking task source</a>
  places on the <a href="#task-queue" id="read-xml:task-queue">task queue</a> while fetching runs must <a href="#process-link-headers" id="read-xml:process-link-headers">process link headers</a>
  given <var>document</var>, <var>navigationParams</var>'s <a href="#navigation-params-response" id="read-xml:navigation-params-response">response</a>, and "<code>media</code>", after
  the task has been processed by the <a href="#xml-parser" id="read-xml:xml-parser-2">XML parser</a>.</p>

  <p>The actual HTTP headers and other metadata, not the headers as mutated or implied by the
  algorithms given in this specification, are the ones that must be used when determining the
  character encoding according to the rules given in the above specifications. Once the character
  encoding is established, the <a id="read-xml:document's-character-encoding" href="https://dom.spec.whatwg.org/#concept-document-encoding" data-x-internal="document's-character-encoding">document's character encoding</a> must be set to that
  character encoding.</p>

  <p>Before any script execution occurs, the user agent must wait for <a href="#scripts-may-run-for-the-newly-created-document" id="read-xml:scripts-may-run-for-the-newly-created-document">scripts may run for the
  newly-created document</a> to be true for the newly-created <code id="read-xml:document-2"><a href="#document">Document</a></code>.</p>

  <p>Once parsing is complete, the user agent must set <var>document</var>'s <a href="#concept-document-navigation-id" id="read-xml:concept-document-navigation-id">during-loading navigation ID for WebDriver BiDi</a> to
  null.</p>
  </div>

  <p class="note">For HTML documents this is reset when parsing is complete, after firing the load
  event.</p>

  <p>Error messages from the parse process (e.g., XML namespace well-formedness errors) may be
  reported inline by mutating the <code id="read-xml:document-3"><a href="#document">Document</a></code>.</p>


  <h4 id="read-text"><span class="secno">7.5.4</span> Loading text documents<a href="#read-text" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>To <dfn id="navigate-text">load a text document</dfn>, given a <a href="#navigation-params" id="read-text:navigation-params">navigation
  params</a> <var>navigationParams</var> and a string <var>type</var>:</p>

  <ol><li><p>Let <var>document</var> be the result of <a href="#initialise-the-document-object" id="read-text:initialise-the-document-object">creating and initializing a <code>Document</code>
   object</a> given "<code>html</code>", <var>type</var>, and
   <var>navigationParams</var>.</p></li><li><p>Set <var>document</var>'s <a href="#parser-cannot-change-the-mode-flag" id="read-text:parser-cannot-change-the-mode-flag">parser cannot change the mode flag</a> to
   true.</p></li><li><p>Set <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-mode" id="read-text:concept-document-mode" data-x-internal="concept-document-mode">mode</a>
   to "<code>no-quirks</code>".</p></li><li>
    <p>Create an <a href="#html-parser" id="read-text:html-parser">HTML parser</a> and associate it with the <var>document</var>. Act as
    if the tokenizer had emitted a start tag token with the tag name "pre" followed by a single
    U+000A LINE FEED (LF) character, and switch the <a href="#html-parser" id="read-text:html-parser-2">HTML parser</a>'s tokenizer to the
    <a href="#plaintext-state" id="read-text:plaintext-state">PLAINTEXT state</a>. Each <a href="#concept-task" id="read-text:concept-task">task</a> that the
    <a href="#networking-task-source" id="read-text:networking-task-source">networking task source</a> places on the <a href="#task-queue" id="read-text:task-queue">task queue</a> while fetching runs
    must then fill the parser's <a href="#the-input-byte-stream" id="read-text:the-input-byte-stream">input byte stream</a> with the fetched bytes and cause the
    <a href="#html-parser" id="read-text:html-parser-3">HTML parser</a> to perform the appropriate processing of the input stream.</p>

    <p><var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="read-text:document's-character-encoding" data-x-internal="document's-character-encoding">encoding</a> must be
    set to the character encoding used to decode the document during parsing.</p>

    <p>The first <a href="#concept-task" id="read-text:concept-task-2">task</a> that the <a href="#networking-task-source" id="read-text:networking-task-source-2">networking task
    source</a> places on the <a href="#task-queue" id="read-text:task-queue-2">task queue</a> while fetching runs must <a href="#process-link-headers" id="read-text:process-link-headers">process link
    headers</a> given <var>document</var>, <var>navigationParams</var>'s <a href="#navigation-params-response" id="read-text:navigation-params-response">response</a>, and "<code>media</code>", after
    the task has been processed by the <a href="#html-parser" id="read-text:html-parser-4">HTML parser</a>.</p>

    <p>Before any script execution occurs, the user agent must wait for <a href="#scripts-may-run-for-the-newly-created-document" id="read-text:scripts-may-run-for-the-newly-created-document">scripts may run for
    the newly-created document</a> to be true for <var>document</var>.</p>

    <p>When no more bytes are available, the user agent must <a href="#queue-a-global-task" id="read-text:queue-a-global-task">queue a global task</a> on
    the <a href="#networking-task-source" id="read-text:networking-task-source-3">networking task source</a> given <var>document</var>'s <a href="#concept-relevant-global" id="read-text:concept-relevant-global">relevant global
    object</a> to have the parser process the implied EOF character, which eventually causes
    a <code id="read-text:event-load"><a href="#event-load">load</a></code> event to be fired.</p>
   </li><li>
    <p>User agents may add content to the <code id="read-text:the-head-element"><a href="#the-head-element">head</a></code> element of <var>document</var>, e.g.,
    linking to a style sheet, providing script, or giving the document a <code id="read-text:the-title-element"><a href="#the-title-element">title</a></code>.</p>

    <p class="note">In particular, if the user agent supports the <code>Format=Flowed</code> feature of RFC 3676 then the user agent would need to apply
    extra styling to cause the text to wrap correctly and to handle the quoting feature. This could
    be performed using, e.g., a CSS extension.</p>
   </li><li><p>Return <var>document</var>.</p></li></ol>

  <p>The rules for how to convert the bytes of the plain text document into actual characters, and
  the rules for actually rendering the text to the user, are defined by the specifications for the
  <a href="https://mimesniff.spec.whatwg.org/#computed-mime-type" id="read-text:content-type-sniffing-2" data-x-internal="content-type-sniffing-2">computed MIME type</a> of the resource (i.e.,
  <var>type</var>).</p>
  </div>

  <h4 id="read-multipart-x-mixed-replace"><span class="secno">7.5.5</span> Loading <code id="read-multipart-x-mixed-replace:multipart/x-mixed-replace"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code>
  documents<a href="#read-multipart-x-mixed-replace" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>To <dfn id="navigate-multipart-x-mixed-replace">load a
  <code>multipart/x-mixed-replace</code> document</dfn>, given <a href="#navigation-params" id="read-multipart-x-mixed-replace:navigation-params">navigation params</a>
  <var>navigationParams</var>, <a href="#source-snapshot-params" id="read-multipart-x-mixed-replace:source-snapshot-params">source snapshot params</a> <var>sourceSnapshotParams</var>,
  and <a href="#concept-origin" id="read-multipart-x-mixed-replace:concept-origin">origin</a> <var>initiatorOrigin</var>:</p>

  <ol><li><p>Parse <var>navigationParams</var>'s <a href="#navigation-params-response" id="read-multipart-x-mixed-replace:navigation-params-response">response</a>'s <a href="https://fetch.spec.whatwg.org/#concept-response-body" id="read-multipart-x-mixed-replace:concept-response-body" data-x-internal="concept-response-body">body</a> using the rules for multipart types.
   <a href="#refsRFC2046">[RFC2046]</a></p></li><li><p>Let <var>firstPartNavigationParams</var> be a copy of
   <var>navigationParams</var>.</p></li><li><p>Set <var>firstPartNavigationParams</var>'s <a href="#navigation-params-response" id="read-multipart-x-mixed-replace:navigation-params-response-2">response</a> to a new <a href="https://fetch.spec.whatwg.org/#concept-response" id="read-multipart-x-mixed-replace:concept-response" data-x-internal="concept-response">response</a> representing the first part of
   <var>navigationParams</var>'s <a href="#navigation-params-response" id="read-multipart-x-mixed-replace:navigation-params-response-3">response</a>'s <a href="https://fetch.spec.whatwg.org/#concept-response-body" id="read-multipart-x-mixed-replace:concept-response-body-2" data-x-internal="concept-response-body">body</a>'s multipart stream.</p></li><li>
    <p>Let <var>document</var> be the result of <a href="#loading-a-document" id="read-multipart-x-mixed-replace:loading-a-document">loading a document</a> given
    <var>firstPartNavigationParams</var>, <var>sourceSnapshotParams</var>, and
    <var>initiatorOrigin</var>.</p>

    <p>For each additional body part obtained from <var>navigationParams</var>'s <a href="#navigation-params-response" id="read-multipart-x-mixed-replace:navigation-params-response-4">response</a>, the user agent must <a href="#navigate" id="read-multipart-x-mixed-replace:navigate">navigate</a>
    <var>document</var>'s <a href="#node-navigable" id="read-multipart-x-mixed-replace:node-navigable">node navigable</a> to <var>navigationParams</var>'s <a href="#navigation-params-request" id="read-multipart-x-mixed-replace:navigation-params-request">request</a>'s <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="read-multipart-x-mixed-replace:concept-request-url" data-x-internal="concept-request-url">URL</a>, using <var>document</var>, with <i id="read-multipart-x-mixed-replace:navigation-response"><a href="#navigation-response">response</a></i> set to <var>navigationParams</var>'s <a href="#navigation-params-response" id="read-multipart-x-mixed-replace:navigation-params-response-5">response</a> and <i id="read-multipart-x-mixed-replace:navigation-hh"><a href="#navigation-hh">historyHandling</a></i> set to "<code id="read-multipart-x-mixed-replace:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>".</p>
   </li><li><p>Return <var>document</var>.</p></li></ol>
  </div>

  <p>For the purposes of algorithms processing these body parts as if they were complete
  stand-alone resources, the user agent must act as if there were no more bytes for those resources
  whenever the boundary following the body part is reached.</p>

  <p class="note">Thus, <code id="read-multipart-x-mixed-replace:event-load"><a href="#event-load">load</a></code> events (and for that matter <code id="read-multipart-x-mixed-replace:event-unload"><a href="#event-unload">unload</a></code> events) do fire for each body part loaded.</p>


  <h4 id="read-media"><span class="secno">7.5.6</span> Loading media documents<a href="#read-media" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>To <dfn id="navigate-media">load a media document</dfn>, given <var>navigationParams</var>
  and a string <var>type</var>:</p>

  <ol><li><p>Let <var>document</var> be the result of <a href="#initialise-the-document-object" id="read-media:initialise-the-document-object">creating and initializing a <code>Document</code>
   object</a> given "<code>html</code>", <var>type</var>, and
   <var>navigationParams</var>.</p></li><li><p>Set <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-mode" id="read-media:concept-document-mode" data-x-internal="concept-document-mode">mode</a>
   to "<code>no-quirks</code>".</p></li><li><p><a href="#populate-with-html/head/body" id="read-media:populate-with-html/head/body">Populate with <code>html</code>/<code>head</code>/<code>body</code></a> given
   <var>document</var>.</p></li><li><p>Append an element <var>host element</var> for the media, as described below, to the
   <code id="read-media:the-body-element"><a href="#the-body-element">body</a></code> element.</p></li><li><p>Set the appropriate attribute of the element <var>host element</var>, as described below,
   to the address of the image, video, or audio resource.</p></li><li><p>User agents may add content to the <code id="read-media:the-head-element"><a href="#the-head-element">head</a></code> element of <var>document</var>, or
   attributes to <var>host element</var>, e.g., to link to a style sheet, to provide a script, to
   give the document a <code id="read-media:the-title-element"><a href="#the-title-element">title</a></code>, or to make the media <a href="#attr-media-autoplay" id="read-media:attr-media-autoplay">autoplay</a>.</p></li><li><p><a href="#process-link-headers" id="read-media:process-link-headers">Process link headers</a> given <var>document</var>,
   <var>navigationParams</var>'s <a href="#navigation-params-response" id="read-media:navigation-params-response">response</a>, and
   "<code>media</code>".</p></li><li><p>Act as if the user agent had <a href="#stop-parsing" id="read-media:stop-parsing">stopped parsing</a>
   <var>document</var>.</p></li><li><p>Return <var>document</var>.</p></li></ol>

  <p>The element <var>host element</var> to create for the media is the element given in
  the table below in the second cell of the row whose first cell describes the media. The
  appropriate attribute to set is the one given by the third cell in that same row.</p>

  <table><thead><tr><th> Type of media
         </th><th> Element for the media
         </th><th> Appropriate attribute
   </th></tr></thead><tbody><tr><td> Image
         </td><td> <code id="read-media:the-img-element"><a href="#the-img-element">img</a></code>
         </td><td> <code id="read-media:attr-img-src"><a href="#attr-img-src">src</a></code>
    </td></tr><tr><td> Video
         </td><td> <code id="read-media:the-video-element"><a href="#the-video-element">video</a></code>
         </td><td> <code id="read-media:attr-media-src"><a href="#attr-media-src">src</a></code>
    </td></tr><tr><td> Audio
         </td><td> <code id="read-media:the-audio-element"><a href="#the-audio-element">audio</a></code>
         </td><td> <code id="read-media:attr-media-src-2"><a href="#attr-media-src">src</a></code>
  </td></tr></tbody></table>
  </div>

  <div data-algorithm="">
  <p>Before any script execution occurs, the user agent must wait for <a href="#scripts-may-run-for-the-newly-created-document" id="read-media:scripts-may-run-for-the-newly-created-document">scripts may run for the
  newly-created document</a> to be true for the <code id="read-media:document"><a href="#document">Document</a></code>.</p>
  </div>


  <h4 id="read-ua-inline"><span class="secno">7.5.7</span> <span id="read-ua-plugin"></span><span id="navigate-plugin"></span>Loading
  a document for inline content that doesn't have a DOM<a href="#read-ua-inline" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When the user agent is to <dfn id="navigate-ua-inline">create a document to display a user
  agent page or PDF viewer inline</dfn>,
  provided a <a href="#navigable" id="read-ua-inline:navigable">navigable</a> <var>navigable</var>, a <a href="#navigation-id" id="read-ua-inline:navigation-id">navigation ID</a>
  <var>navigationId</var>, a <code id="read-ua-inline:navigationtimingtype"><a data-x-internal="navigationtimingtype" href="https://w3c.github.io/navigation-timing/#dom-navigationtimingtype">NavigationTimingType</a></code> <var>navTimingType</var>, and a
  <a href="#user-navigation-involvement" id="read-ua-inline:user-navigation-involvement">user navigation involvement</a> <var>userInvolvement</var>, the user agent should:</p>

  <ol><li><p>Let <var>origin</var> be a new <a href="#concept-origin-opaque" id="read-ua-inline:concept-origin-opaque">opaque
   origin</a>.</p></li><li><p>Let <var>coop</var> be a new <a href="#cross-origin-opener-policy" id="read-ua-inline:cross-origin-opener-policy">opener policy</a>.</p></li><li>
    <p>Let <var>coopEnforcementResult</var> be a new <a href="#coop-enforcement-result" id="read-ua-inline:coop-enforcement-result">opener
    policy enforcement result</a> with</p>

    <dl class="props"><dt><a href="#coop-enforcement-url" id="read-ua-inline:coop-enforcement-url">url</a></dt><dd><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="read-ua-inline:concept-response-url" data-x-internal="concept-response-url">URL</a></dd><dt><a href="#coop-enforcement-origin" id="read-ua-inline:coop-enforcement-origin">origin</a></dt><dd><var>origin</var></dd><dt><a href="#coop-enforcement-coop" id="read-ua-inline:coop-enforcement-coop">opener policy</a></dt><dd><var>coop</var></dd></dl>
   </li><li>
    <p>Let <var>navigationParams</var> be a new <a href="#navigation-params" id="read-ua-inline:navigation-params">navigation params</a> with</p>

    <dl class="props"><dt><a href="#navigation-params-id" id="read-ua-inline:navigation-params-id">id</a></dt><dd><var>navigationId</var></dd><dt><a href="#navigation-params-navigable" id="read-ua-inline:navigation-params-navigable">navigable</a></dt><dd><var>navigable</var></dd><dt><a href="#navigation-params-request" id="read-ua-inline:navigation-params-request">request</a></dt><dd>null</dd><dt><a href="#navigation-params-response" id="read-ua-inline:navigation-params-response">response</a></dt><dd>a new <a href="https://fetch.spec.whatwg.org/#concept-response" id="read-ua-inline:concept-response" data-x-internal="concept-response">response</a></dd><dt><a href="#navigation-params-origin" id="read-ua-inline:navigation-params-origin">origin</a></dt><dd><var>origin</var></dd><dt><a href="#navigation-params-fetch-controller" id="read-ua-inline:navigation-params-fetch-controller">fetch controller</a></dt><dd>null</dd><dt><a href="#navigation-params-commit-early-hints" id="read-ua-inline:navigation-params-commit-early-hints">commit early hints</a></dt><dd>null</dd><dt><a href="#navigation-params-coop-enforcement-result" id="read-ua-inline:navigation-params-coop-enforcement-result">COOP enforcement result</a></dt><dd><var>coopEnforcementResult</var></dd><dt><a href="#navigation-params-reserved-environment" id="read-ua-inline:navigation-params-reserved-environment">reserved environment</a></dt><dd>null</dd><dt><a href="#navigation-params-policy-container" id="read-ua-inline:navigation-params-policy-container">policy container</a></dt><dd>a new <a href="#policy-container" id="read-ua-inline:policy-container">policy container</a></dd><dt><a href="#navigation-params-sandboxing" id="read-ua-inline:navigation-params-sandboxing">final sandboxing flag set</a></dt><dd>an empty set</dd><dt><a href="#navigation-params-coop" id="read-ua-inline:navigation-params-coop">opener policy</a></dt><dd><var>coop</var></dd><dt><a href="#navigation-params-nav-timing-type" id="read-ua-inline:navigation-params-nav-timing-type">navigation timing type</a></dt><dd><var>navTimingType</var></dd><dt><a href="#navigation-params-about-base-url" id="read-ua-inline:navigation-params-about-base-url">about base URL</a></dt><dd>null</dd><dt><a href="#navigation-params-user-involvement" id="read-ua-inline:navigation-params-user-involvement">user involvement</a></dt><dd><var>userInvolvement</var></dd></dl>
   </li><li><p>Let <var>document</var> be the result of <a href="#initialise-the-document-object" id="read-ua-inline:initialise-the-document-object">creating and initializing a <code>Document</code>
   object</a> given "<code>html</code>", "<code>text/html</code>", and
   <var>navigationParams</var>.</p></li><li><p>Either associate <var>document</var> with a custom rendering that is not rendered using
   the normal <code id="read-ua-inline:document"><a href="#document">Document</a></code> rendering rules, or mutate <var>document</var> until it
   represents the content the user agent wants to render.</p></li><li><p>Act as if the user agent had <a href="#stop-parsing" id="read-ua-inline:stop-parsing">stopped parsing</a>
   <var>document</var>.</p></li><li><p>Return <var>document</var>.</p></li></ol>

  <p class="note">Because we ensure the resulting <code id="read-ua-inline:document-2"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="read-ua-inline:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is <a href="#concept-origin-opaque" id="read-ua-inline:concept-origin-opaque-2">opaque</a>, and the resulting <code id="read-ua-inline:document-3"><a href="#document">Document</a></code> cannot run
  script with access to the DOM, the existence and properties of this <code id="read-ua-inline:document-4"><a href="#document">Document</a></code> are not
  observable to web developer code. This means that most of the above values, e.g., the
  <code id="read-ua-inline:text/html"><a href="#text/html">text/html</a></code> <a href="https://dom.spec.whatwg.org/#concept-document-type" id="read-ua-inline:concept-document-type" data-x-internal="concept-document-type">type</a>, do not matter.
  Similarly, most of the items in <var>navigationParams</var> don't have any observable effect,
  besides preventing the <a href="#initialise-the-document-object" id="read-ua-inline:initialise-the-document-object-2"><code>Document</code>-creation
  algorithm</a> from getting confused, and so are set to default values.</p>
  </div>


  <h4 id="loading-documents"><span class="secno">7.5.8</span> Finishing the loading process<a href="#loading-documents" class="self-link"></a></h4>

  <p>A <code id="loading-documents:document"><a href="#document">Document</a></code> has a <dfn id="completely-loaded-time">completely loaded time</dfn> (a time or null), which is
  initially null.</p>

  <div data-algorithm="">
  <p>A <code id="loading-documents:document-2"><a href="#document">Document</a></code> is considered <dfn id="completely-loaded">completely loaded</dfn> if its <a href="#completely-loaded-time" id="loading-documents:completely-loaded-time">completely
  loaded time</a> is non-null.
  </p></div>

  <div data-algorithm="">
  <p>To <dfn id="completely-finish-loading">completely finish loading</dfn> a <code id="loading-documents:document-3"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p><a id="loading-documents:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var>'s <a href="#concept-document-bc" id="loading-documents:concept-document-bc">browsing
   context</a> is non-null.</p></li><li><p>Set <var>document</var>'s <a href="#completely-loaded-time" id="loading-documents:completely-loaded-time-2">completely loaded time</a> to the current
   time.</p></li><li>
    <p>Let <var>container</var> be <var>document</var>'s <a href="#node-navigable" id="loading-documents:node-navigable">node navigable</a>'s <a href="#nav-container" id="loading-documents:nav-container">container</a>.</p>

    <div class="note">
     <p>This will be null in the case where <var>document</var> is the <a href="#is-initial-about:blank" id="loading-documents:is-initial-about:blank">initial <code>about:blank</code></a> <code id="loading-documents:document-4"><a href="#document">Document</a></code> in a
     <code id="loading-documents:frame"><a href="#frame">frame</a></code> or <code id="loading-documents:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, since at the point of <a href="#creating-a-new-browsing-context" id="loading-documents:creating-a-new-browsing-context">browsing context creation</a> which calls this algorithm,
     the container relationship has not yet been established. (That happens in a subsequent step of
     <a href="#create-a-new-child-navigable" id="loading-documents:create-a-new-child-navigable">create a new child navigable</a>.)</p>

     <p>The consequence of this is that the following steps do nothing, i.e., we do not fire an
     asynchronous <code id="loading-documents:event-load"><a href="#event-load">load</a></code> event on the container element for such
     cases. Instead, a synchronous <code id="loading-documents:event-load-2"><a href="#event-load">load</a></code> event is fired in a special
     initial-insertion case when <a href="#process-the-iframe-attributes" id="loading-documents:process-the-iframe-attributes">processing the
     <code>iframe</code> attributes</a>.</p>
    </div>
   </li><li><p>If <var>container</var> is an <code id="loading-documents:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> element, then <a href="#queue-an-element-task" id="loading-documents:queue-an-element-task">queue an element
   task</a> on the <a href="#dom-manipulation-task-source" id="loading-documents:dom-manipulation-task-source">DOM manipulation task source</a> given <var>container</var> to run
   the <a href="#iframe-load-event-steps" id="loading-documents:iframe-load-event-steps">iframe load event steps</a> given <var>container</var>.</p></li><li><p>Otherwise, if <var>container</var> is non-null, then <a href="#queue-an-element-task" id="loading-documents:queue-an-element-task-2">queue an element task</a> on
   the <a href="#dom-manipulation-task-source" id="loading-documents:dom-manipulation-task-source-2">DOM manipulation task source</a> given <var>container</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="loading-documents:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="loading-documents:event-load-3"><a href="#event-load">load</a></code> at
   <var>container</var>.</p>
  </li></ol>
  </div>

  <h4 id="unloading-documents"><span class="secno">7.5.9</span> Unloading documents<a href="#unloading-documents" class="self-link"></a></h4>

  <p>A <code id="unloading-documents:document"><a href="#document">Document</a></code> has a <dfn id="concept-document-salvageable"><i>salvageable</i></dfn> state, which must initially be
  true, and a <dfn id="page-showing">page showing</dfn> boolean, which is initially false. The <a href="#page-showing" id="unloading-documents:page-showing">page
  showing</a> boolean is used to ensure that scripts receive <code id="unloading-documents:event-pageshow"><a href="#event-pageshow">pageshow</a></code> and <code id="unloading-documents:event-pagehide"><a href="#event-pagehide">pagehide</a></code> events
  in a consistent manner (e.g., that they never receive two <code id="unloading-documents:event-pagehide-2"><a href="#event-pagehide">pagehide</a></code> events in a row without an intervening <code id="unloading-documents:event-pageshow-2"><a href="#event-pageshow">pageshow</a></code>, or vice versa).</p>

  <p>A <code id="unloading-documents:document-2"><a href="#document">Document</a></code> has a <code id="unloading-documents:domhighrestimestamp"><a data-x-internal="domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp">DOMHighResTimeStamp</a></code> <dfn id="suspension-time">suspension time</dfn>,
  initially 0.</p>

  <p>A <code id="unloading-documents:document-3"><a href="#document">Document</a></code> has a <a id="unloading-documents:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <dfn id="suspended-timer-handles">suspended timer handles</dfn>,
  initially empty.</p>

  <p><a href="#event-loop" id="unloading-documents:event-loop">Event loops</a> have a <dfn id="termination-nesting-level">termination nesting level</dfn>
  counter, which must initially be 0.</p>

  <p id="ignore-opens-during-unload-counter"><code id="unloading-documents:document-4"><a href="#document">Document</a></code> objects have an <dfn id="unload-counter">unload
  counter</dfn>, which is used to ignore certain operations while the below algorithms run.
  Initially, the counter must be set to zero.</p>

  <div data-algorithm="">
  <p>To <dfn id="unload-a-document">unload</dfn> a <code id="unloading-documents:document-5"><a href="#document">Document</a></code>
  <var>oldDocument</var>, given an optional <code id="unloading-documents:document-6"><a href="#document">Document</a></code> <var>newDocument</var>:</p>

  <ol><li><p><a id="unloading-documents:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running as part of a <a href="#concept-task" id="unloading-documents:concept-task">task</a>
   queued on <var>oldDocument</var>'s <a href="#relevant-agent" id="unloading-documents:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="unloading-documents:concept-agent-event-loop">event loop</a>.</p></li><li><p>Let <var>unloadTimingInfo</var> be a new <a href="#document-unload-timing-info" id="unloading-documents:document-unload-timing-info">document unload timing
   info</a>.</p></li><li>
    <p>If <var>newDocument</var> is not given, then set <var>unloadTimingInfo</var> to null.</p>

    <p class="note">In this case there is no new document that needs to know about how long it took
    <var>oldDocument</var> to unload.</p>
   </li><li>
    <p>Otherwise, if <var>newDocument</var>'s <a href="#event-loop" id="unloading-documents:event-loop-2">event loop</a> is not
    <var>oldDocument</var>'s <a href="#event-loop" id="unloading-documents:event-loop-3">event loop</a>, then the user agent may be <a href="#unload-a-document" id="unloading-documents:unload-a-document">unloading</a> <var>oldDocument</var> <a href="#in-parallel" id="unloading-documents:in-parallel">in parallel</a>. In
    that case, the user agent should set <var>unloadTimingInfo</var> to null.</p>

    <p class="note">In this case <var>newDocument</var>'s loading is not impacted by how long it
    takes to unload <var>oldDocument</var>, so it would be meaningless to communicate that timing
    info.</p>
   </li><li>
    <p>Let <var>intendToKeepInBfcache</var> be true if the user agent intends to keep
    <var>oldDocument</var> alive in a <a href="#session-history-entry" id="unloading-documents:session-history-entry">session history entry</a>, such that it can later be
    <a href="#note-bfcache">used for history traversal</a>.</p>

    <p>This must be false if <var>oldDocument</var> is not <i id="unloading-documents:concept-document-salvageable"><a href="#concept-document-salvageable">salvageable</a></i>, or if there are any descendants of
    <var>oldDocument</var> which the user agent does not intend to keep alive in the same way
    (including due to their lack of <i id="unloading-documents:concept-document-salvageable-2"><a href="#concept-document-salvageable">salvageability</a></i>).</p>
   </li><li><p>Let <var>eventLoop</var> be <var>oldDocument</var>'s <a href="#relevant-agent" id="unloading-documents:relevant-agent-2">relevant agent</a>'s <a href="#concept-agent-event-loop" id="unloading-documents:concept-agent-event-loop-2">event loop</a>.</p></li><li><p>Increase <var>eventLoop</var>'s <a href="#termination-nesting-level" id="unloading-documents:termination-nesting-level">termination nesting level</a> by 1.</p></li><li><p>Increase <var>oldDocument</var>'s <a href="#unload-counter" id="unloading-documents:unload-counter">unload counter</a> by 1.</p></li><li><p>If <var>intendToKeepInBfcache</var> is false, then set <var>oldDocument</var>'s <i id="unloading-documents:concept-document-salvageable-3"><a href="#concept-document-salvageable">salvageable</a></i> state to false.</p></li><li>
    <p>If <var>oldDocument</var>'s <a href="#page-showing" id="unloading-documents:page-showing-2">page showing</a> is true:</p>

    <ol><li><p>Set <var>oldDocument</var>'s <a href="#page-showing" id="unloading-documents:page-showing-3">page showing</a> to false.</p></li><li><p><a href="#fire-a-page-transition-event" id="unloading-documents:fire-a-page-transition-event">Fire a page transition event</a> named <code id="unloading-documents:event-pagehide-3"><a href="#event-pagehide">pagehide</a></code> at <var>oldDocument</var>'s <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global">relevant global
     object</a> with <var>oldDocument</var>'s <i id="unloading-documents:concept-document-salvageable-4"><a href="#concept-document-salvageable">salvageable</a></i> state.</p></li><li><p><a href="#update-the-visibility-state" id="unloading-documents:update-the-visibility-state">Update the visibility state</a> of <var>oldDocument</var> to
     "<code>hidden</code>".</p></li></ol>
   </li><li><p>If <var>unloadTimingInfo</var> is not null, then set <var>unloadTimingInfo</var>'s
   <a href="#unload-event-start-time" id="unloading-documents:unload-event-start-time">unload event start time</a> to the <a id="unloading-documents:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given
   <var>newDocument</var>'s <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global-2">relevant global object</a>, <a href="https://w3c.github.io/hr-time/#dfn-coarsen-time" id="unloading-documents:coarsen-time" data-x-internal="coarsen-time">coarsened</a> given <var>oldDocument</var>'s <a href="#relevant-settings-object" id="unloading-documents:relevant-settings-object">relevant settings object</a>'s
   <a href="#concept-settings-object-cross-origin-isolated-capability" id="unloading-documents:concept-settings-object-cross-origin-isolated-capability">cross-origin isolated
   capability</a>.</p></li><li><p>If <var>oldDocument</var>'s <i id="unloading-documents:concept-document-salvageable-5"><a href="#concept-document-salvageable">salvageable</a></i>
   state is false, then <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="unloading-documents:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="unloading-documents:event-unload"><a href="#event-unload">unload</a></code> at <var>oldDocument</var>'s <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global-3">relevant global
   object</a>, with <i>legacy target override flag</i> set.</p></li><li><p>If <var>unloadTimingInfo</var> is not null, then set <var>unloadTimingInfo</var>'s
   <a href="#unload-event-end-time" id="unloading-documents:unload-event-end-time">unload event end time</a> to the <a id="unloading-documents:current-high-resolution-time-2" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given
   <var>newDocument</var>'s <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global-4">relevant global object</a>, <a href="https://w3c.github.io/hr-time/#dfn-coarsen-time" id="unloading-documents:coarsen-time-2" data-x-internal="coarsen-time">coarsened</a> given <var>oldDocument</var>'s <a href="#relevant-settings-object" id="unloading-documents:relevant-settings-object-2">relevant settings object</a>'s
   <a href="#concept-settings-object-cross-origin-isolated-capability" id="unloading-documents:concept-settings-object-cross-origin-isolated-capability-2">cross-origin isolated
   capability</a>.</p></li><li><p>Decrease <var>eventLoop</var>'s <a href="#termination-nesting-level" id="unloading-documents:termination-nesting-level-2">termination nesting level</a> by 1.</p></li><li><p>Set <var>oldDocument</var>'s <a href="#suspension-time" id="unloading-documents:suspension-time">suspension time</a> to the <a id="unloading-documents:current-high-resolution-time-3" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high
   resolution time</a> given <var>document</var>'s <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global-5">relevant global object</a>.</p></li><li><p>Set <var>oldDocument</var>'s <a href="#suspended-timer-handles" id="unloading-documents:suspended-timer-handles">suspended timer handles</a> to the result of
   <a href="https://infra.spec.whatwg.org/#map-getting-the-keys" id="unloading-documents:map-get-the-keys" data-x-internal="map-get-the-keys">getting the keys</a> for the
   <a href="#map-of-active-timers" id="unloading-documents:map-of-active-timers">map of active timers</a>.</p></li><li><p>Set <var>oldDocument</var>'s <a href="#has-been-scrolled-by-the-user" id="unloading-documents:has-been-scrolled-by-the-user">has been scrolled by the user</a> to false.</p></li><li><p>Run any <a href="#unloading-document-cleanup-steps" id="unloading-documents:unloading-document-cleanup-steps">unloading document cleanup steps</a> for <var>oldDocument</var> that are
   defined by this specification and <a href="#other-applicable-specifications" id="unloading-documents:other-applicable-specifications">other applicable specifications</a>.</p></li><li><p>If <var>oldDocument</var>'s <a href="#node-navigable" id="unloading-documents:node-navigable">node navigable</a> is a <a href="#top-level-traversable" id="unloading-documents:top-level-traversable">top-level
   traversable</a>, <a href="#build-not-restored-reasons-for-a-top-level-traversable-and-its-descendants" id="unloading-documents:build-not-restored-reasons-for-a-top-level-traversable-and-its-descendants">build not restored reasons for a top-level traversable and its
   descendants</a> given <var>oldDocument</var>'s <a href="#node-navigable" id="unloading-documents:node-navigable-2">node navigable</a>.</p></li><li><p>If <var>oldDocument</var>'s <i id="unloading-documents:concept-document-salvageable-6"><a href="#concept-document-salvageable">salvageable</a></i> state
   is false, then <a href="#destroy-a-document" id="unloading-documents:destroy-a-document">destroy</a> <var>oldDocument</var>.</p></li><li><p>Decrease <var>oldDocument</var>'s <a href="#unload-counter" id="unloading-documents:unload-counter-2">unload counter</a> by 1.</p></li><li><p>If <var>newDocument</var> is given, <var>newDocument</var>'s <a href="#was-created-via-cross-origin-redirects" id="unloading-documents:was-created-via-cross-origin-redirects">was created via
   cross-origin redirects</a> is false, and <var>newDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="unloading-documents:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is the <a href="#same-origin" id="unloading-documents:same-origin">same</a> as
   <var>oldDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="unloading-documents:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>, then set
   <var>newDocument</var>'s <a href="#previous-document-unload-timing" id="unloading-documents:previous-document-unload-timing">previous document unload timing</a> to
   <var>unloadTimingInfo</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="unload-a-document-and-its-descendants">unload a document and its descendants</dfn>, given a <code id="unloading-documents:document-7"><a href="#document">Document</a></code>
  <var>document</var>, an optional <code id="unloading-documents:document-8"><a href="#document">Document</a></code>-or-null <var>newDocument</var> (default
  null), an optional set of steps <var>afterAllUnloads</var>, and an optional set of steps
  <var>firePageSwapSteps</var>:</p>

  <ol><li><p><a id="unloading-documents:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running within <var>document</var>'s <a href="#node-navigable" id="unloading-documents:node-navigable-3">node
   navigable</a>'s <a href="#nav-traversable" id="unloading-documents:nav-traversable">traversable navigable</a>'s <a href="#tn-session-history-traversal-queue" id="unloading-documents:tn-session-history-traversal-queue">session history traversal queue</a>.</p></li><li><p>Let <var>childNavigables</var> be <var>document</var>'s <a href="#child-navigable" id="unloading-documents:child-navigable">child navigables</a>.</p></li><li><p>Let <var>numberUnloaded</var> be 0.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="unloading-documents:list-iterate" data-x-internal="list-iterate">For each</a> <var>childNavigable</var> of
    <var>childNavigables</var> <span class="XXX">in what order?</span>, <a href="#queue-a-global-task" id="unloading-documents:queue-a-global-task">queue a
    global task</a> on the <a href="#navigation-and-traversal-task-source" id="unloading-documents:navigation-and-traversal-task-source">navigation and traversal task source</a> given
    <var>childNavigable</var>'s <a href="#nav-window" id="unloading-documents:nav-window">active window</a> to perform the
    following steps:</p>

    <ol><li><p>Let <var>incrementUnloaded</var> be an algorithm step which increments
     <var>numberUnloaded</var>.</p></li><li><p><a href="#unload-a-document-and-its-descendants" id="unloading-documents:unload-a-document-and-its-descendants">Unload a document and its descendants</a> given <var>childNavigable</var>'s
     <a href="#nav-document" id="unloading-documents:nav-document">active document</a>, null, and
     <var>incrementUnloaded</var>.</p></li></ol>
   </li><li><p>Wait until <var>numberUnloaded</var> equals <var>childNavigable</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="unloading-documents:list-size" data-x-internal="list-size">size</a>.</p></li><li>
    <p><a href="#queue-a-global-task" id="unloading-documents:queue-a-global-task-2">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="unloading-documents:navigation-and-traversal-task-source-2">navigation and traversal task source</a>
    given <var>document</var>'s <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global-6">relevant global object</a> to perform the following
    steps:</p>

    <ol><li><p>If <var>firePageSwapSteps</var> is given, then run <var>firePageSwapSteps</var>.</p></li><li><p><a href="#unload-a-document" id="unloading-documents:unload-a-document-2">Unload</a> <var>document</var>, passing along
     <var>newDocument</var> if it is not null.</p></li><li><p>If <var>afterAllUnloads</var> was given, then run it.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>This specification defines the following <dfn id="unloading-document-cleanup-steps" data-export="">unloading document cleanup steps</dfn>.
  Other specifications can define more. Given a <code id="unloading-documents:document-9"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p>Let <var>window</var> be <var>document</var>'s <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global-7">relevant global
   object</a>.</p></li><li>
    <p>For each <code id="unloading-documents:websocket-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code> object <var>webSocket</var> whose <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global-8">relevant global
    object</a> is <var>window</var>, <a id="unloading-documents:make-disappear" href="https://websockets.spec.whatwg.org/#make-disappear" data-x-internal="make-disappear">make disappear</a> <var>webSocket</var>.</p>

    <p>If this affected any <code id="unloading-documents:websocket-2-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code> objects, then <a href="#make-document-unsalvageable" id="unloading-documents:make-document-unsalvageable">make document
    unsalvageable</a> given <var>document</var> and "<code id="unloading-documents:blocking-websocket"><a href="#blocking-websocket">websocket</a></code>".</p>
   </li><li><p>For each <code id="unloading-documents:webtransport"><a data-x-internal="webtransport" href="https://w3c.github.io/webtransport/#webtransport">WebTransport</a></code> object <var>transport</var> whose <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global-9">relevant global
   object</a> is <var>window</var>, run the <a id="unloading-documents:context-cleanup-steps" href="https://w3c.github.io/webtransport/#context-cleanup-steps" data-x-internal="context-cleanup-steps">context cleanup steps</a> given
   <var>transport</var>.</p></li><li>
    <p>If <var>document</var>'s <i id="unloading-documents:concept-document-salvageable-7"><a href="#concept-document-salvageable">salvageable</a></i>
    state is false, then:</p>

    <ol><li><p>For each <code id="unloading-documents:eventsource"><a href="#eventsource">EventSource</a></code> object <var>eventSource</var> whose <a href="#concept-relevant-global" id="unloading-documents:concept-relevant-global-10">relevant
     global object</a> is equal to <var>window</var>, <a href="#concept-eventsource-forcibly-close" id="unloading-documents:concept-eventsource-forcibly-close">forcibly close</a>
     <var>eventSource</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-clear" id="unloading-documents:map-clear" data-x-internal="map-clear">Clear</a> <var>window</var>'s
     <a href="#map-of-active-timers" id="unloading-documents:map-of-active-timers-2">map of active timers</a>.</p></li></ol>
   </li></ol>
  </div>

  <div class="XXX">
   <p>It would be better if specification authors sent a pull request to add calls from here into
   their specifications directly, instead of using the <a href="#unloading-document-cleanup-steps" id="unloading-documents:unloading-document-cleanup-steps-2">unloading document cleanup
   steps</a> hook, to ensure well-defined cross-specification call order. As of the time of this
   writing the following specifications are known to have <a href="#unloading-document-cleanup-steps" id="unloading-documents:unloading-document-cleanup-steps-3">unloading document cleanup
   steps</a>, which will be run in an unspecified order: <cite>Fullscreen API</cite>, <cite>Web
   NFC</cite>, <cite>WebDriver BiDi</cite>, <cite>Compute Pressure</cite>, <cite>File API</cite>,
   <cite>Media Capture and Streams</cite>, <cite>Picture-in-Picture</cite>, <cite>Screen
   Orientation</cite>, <cite>Service Workers</cite>, <cite>WebLocks API</cite>, <cite>WebAudio
   API</cite>, <cite>WebRTC</cite>. <a href="#refsFULLSCREEN">[FULLSCREEN]</a> <a href="#refsWEBNFC">[WEBNFC]</a> <a href="#refsWEBDRIVERBIDI">[WEBDRIVERBIDI]</a>
   <a href="#refsCOMPUTEPRESSURE">[COMPUTEPRESSURE]</a> <a href="#refsFILEAPI">[FILEAPI]</a> <a href="#refsMEDIASTREAM">[MEDIASTREAM]</a> <a href="#refsPICTUREINPICTURE">[PICTUREINPICTURE]</a>
   <a href="#refsSCREENORIENTATION">[SCREENORIENTATION]</a> <a href="#refsSW">[SW]</a> <a href="#refsWEBLOCKS">[WEBLOCKS]</a> <a href="#refsWEBAUDIO">[WEBAUDIO]</a>
   <a href="#refsWEBRTC">[WEBRTC]</a>

   </p><p><a href="https://github.com/whatwg/html/issues/8906">Issue #8906</a> tracks the work to make
   the order of these steps clear.</p>
  </div>

  <h4 id="destroying-documents"><span class="secno">7.5.10</span> Destroying documents<a href="#destroying-documents" class="self-link"></a></h4>

  <div data-algorithm="">
  <p id="discard-a-document">To <dfn id="destroy-a-document">destroy</dfn> a
  <code id="destroying-documents:document"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p><a id="destroying-documents:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running as part of a <a href="#concept-task" id="destroying-documents:concept-task">task</a>
   queued on <var>document</var>'s <a href="#relevant-agent" id="destroying-documents:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="destroying-documents:concept-agent-event-loop">event loop</a>.</p></li><li><p><a href="#abort-a-document" id="destroying-documents:abort-a-document">Abort</a> <var>document</var>.</p></li><li><p>Set <var>document</var>'s <i id="destroying-documents:concept-document-salvageable"><a href="#concept-document-salvageable">salvageable</a></i> state
   to false.</p></li><li><p>Let <var>ports</var> be the list of <code id="destroying-documents:messageport"><a href="#messageport">MessagePort</a></code>s whose <a href="#concept-relevant-global" id="destroying-documents:concept-relevant-global">relevant global
   object</a>'s <a href="#concept-document-window" id="destroying-documents:concept-document-window">associated <code>Document</code></a> is
   <var>document</var>.</p></li><li><p>For each <var>port</var> in <var>ports</var>, <a href="#disentangle" id="destroying-documents:disentangle">disentangle</a>
   <var>port</var>.</p></li><li><p>Run any <a href="#unloading-document-cleanup-steps" id="destroying-documents:unloading-document-cleanup-steps">unloading document cleanup steps</a> for <var>document</var> that
   are defined by this specification and <a href="#other-applicable-specifications" id="destroying-documents:other-applicable-specifications">other applicable specifications</a>.</p></li><li><p>Remove any <a href="#concept-task" id="destroying-documents:concept-task-2">tasks</a> whose <a href="#concept-task-document" id="destroying-documents:concept-task-document">document</a> is <var>document</var> from any <a href="#task-queue" id="destroying-documents:task-queue">task
   queue</a> (without running those tasks).</p></li><li><p>Set <var>document</var>'s <a href="#concept-document-bc" id="destroying-documents:concept-document-bc">browsing context</a> to
   null.</p></li><li><p>Set <var>document</var>'s <a href="#node-navigable" id="destroying-documents:node-navigable">node navigable</a>'s <a href="#nav-active-history-entry" id="destroying-documents:nav-active-history-entry">active session history entry</a>'s <a href="#she-document-state" id="destroying-documents:she-document-state">document state</a>'s <a href="#document-state-document" id="destroying-documents:document-state-document">document</a> to null.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="destroying-documents:list-remove" data-x-internal="list-remove">Remove</a> <var>document</var> from the
   <a href="#concept-WorkerGlobalScope-owner-set" id="destroying-documents:concept-WorkerGlobalScope-owner-set">owner set</a> of each <code id="destroying-documents:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object whose set <a href="https://infra.spec.whatwg.org/#list-contain" id="destroying-documents:list-contains" data-x-internal="list-contains">contains</a> <var>document</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="destroying-documents:list-iterate" data-x-internal="list-iterate">For each</a> <var>workletGlobalScope</var> in
   <var>document</var>'s <a href="#concept-document-worklet-global-scopes" id="destroying-documents:concept-document-worklet-global-scopes">worklet global
   scopes</a>, <a href="#terminate-a-worklet-global-scope" id="destroying-documents:terminate-a-worklet-global-scope">terminate</a>
   <var>workletGlobalScope</var>.</p></li></ol>
  </div>

  <p class="note">Even after destruction, the <code id="destroying-documents:document-2"><a href="#document">Document</a></code> object itself might still be
  accessible to script, in the case where we are <a href="#destroy-a-child-navigable" id="destroying-documents:destroy-a-child-navigable">destroying a child navigable</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="destroy-a-document-and-its-descendants">destroy a document and its descendants</dfn> given a <code id="destroying-documents:document-3"><a href="#document">Document</a></code>
  <var>document</var> and an optional set of steps <var>afterAllDestruction</var>, perform the
  following steps <a href="#in-parallel" id="destroying-documents:in-parallel">in parallel</a>:</p>

  <ol><li>
    <p>If <var>document</var> is not <a href="#fully-active" id="destroying-documents:fully-active">fully active</a>, then:</p>

    <ol><li><p>Let <var>reason</var> be a string from <a href="#ua-specific-blocking-reasons" id="destroying-documents:ua-specific-blocking-reasons">user-agent specific blocking reasons</a>. If none
     apply, then let <var>reason</var> be "<code id="destroying-documents:blocking-masked"><a href="#blocking-masked">masked</a></code>".</p></li><li><p><a href="#make-document-unsalvageable" id="destroying-documents:make-document-unsalvageable">Make document unsalvageable</a> given <var>document</var> and
     <var>reason</var>.</p></li><li><p>If <var>document</var>'s <a href="#node-navigable" id="destroying-documents:node-navigable-2">node navigable</a> is a
     <a href="#top-level-traversable" id="destroying-documents:top-level-traversable">top-level traversable</a>,
     <a href="#build-not-restored-reasons-for-a-top-level-traversable-and-its-descendants" id="destroying-documents:build-not-restored-reasons-for-a-top-level-traversable-and-its-descendants">build not restored reasons for a top-level traversable and its descendants</a>
     given <var>document</var>'s <a href="#node-navigable" id="destroying-documents:node-navigable-3">node navigable</a>.</p></li></ol>
   </li><li><p>Let <var>childNavigables</var> be <var>document</var>'s <a href="#child-navigable" id="destroying-documents:child-navigable">child navigables</a>.</p></li><li><p>Let <var>numberDestroyed</var> be 0.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="destroying-documents:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>childNavigable</var> of
    <var>childNavigables</var> <span class="XXX">in what order?</span>, <a href="#queue-a-global-task" id="destroying-documents:queue-a-global-task">queue a
    global task</a> on the <a href="#navigation-and-traversal-task-source" id="destroying-documents:navigation-and-traversal-task-source">navigation and traversal task source</a> given
    <var>childNavigable</var>'s <a href="#nav-window" id="destroying-documents:nav-window">active window</a> to perform the
    following steps:</p>

    <ol><li><p>Let <var>incrementDestroyed</var> be an algorithm step which increments
     <var>numberDestroyed</var>.</p></li><li><p><a href="#destroy-a-document-and-its-descendants" id="destroying-documents:destroy-a-document-and-its-descendants">Destroy a document and its descendants</a> given <var>childNavigable</var>'s
     <a href="#nav-document" id="destroying-documents:nav-document">active document</a> and <var>incrementDestroyed</var>.</p></li></ol>
   </li><li><p>Wait until <var>numberDestroyed</var> equals <var>childNavigable</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="destroying-documents:list-size" data-x-internal="list-size">size</a>.</p></li><li>
    <p><a href="#queue-a-global-task" id="destroying-documents:queue-a-global-task-2">Queue a global task</a> on the <a href="#navigation-and-traversal-task-source" id="destroying-documents:navigation-and-traversal-task-source-2">navigation and traversal task source</a>
    given <var>document</var>'s <a href="#concept-relevant-global" id="destroying-documents:concept-relevant-global-2">relevant global object</a> to perform the following
    steps:</p>

    <ol><li><p><a href="#destroy-a-document" id="destroying-documents:destroy-a-document">Destroy</a> <var>document</var>.</p></li><li><p>If <var>afterAllDestruction</var> was given, then run it.</p></li></ol>
   </li></ol>
  </div>

  <h4 id="aborting-a-document-load"><span class="secno">7.5.11</span> Aborting a document load<a href="#aborting-a-document-load" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>To <dfn id="abort-a-document">abort</dfn> a <code id="aborting-a-document-load:document"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p><a id="aborting-a-document-load:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running as part of a <a href="#concept-task" id="aborting-a-document-load:concept-task">task</a>
   queued on <var>document</var>'s <a href="#relevant-agent" id="aborting-a-document-load:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="aborting-a-document-load:concept-agent-event-loop">event loop</a>.</p></li><li><p>Cancel any instances of the <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="aborting-a-document-load:concept-fetch" data-x-internal="concept-fetch">fetch</a> algorithm in the
   context of <var>document</var>, discarding any <a href="#concept-task" id="aborting-a-document-load:concept-task-2">tasks</a> <a href="#queue-a-task" id="aborting-a-document-load:queue-a-task">queued</a> for them, and discarding any further data received from the
   network for them. If this resulted in any instances of the <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="aborting-a-document-load:concept-fetch-2" data-x-internal="concept-fetch">fetch</a> algorithm being canceled or any <a href="#queue-a-task" id="aborting-a-document-load:queue-a-task-2">queued</a> <a href="#concept-task" id="aborting-a-document-load:concept-task-3">tasks</a> or any network data getting
   discarded, then <a href="#make-document-unsalvageable" id="aborting-a-document-load:make-document-unsalvageable">make document unsalvageable</a> given <var>document</var> and
   "<code id="aborting-a-document-load:blocking-fetch"><a href="#blocking-fetch">fetch</a></code>".</p></li><li>
    <p>If <var>document</var>'s <a href="#concept-document-navigation-id" id="aborting-a-document-load:concept-document-navigation-id">during-loading
    navigation ID for WebDriver BiDi</a> is non-null, then:</p>

    <ol><li><p>Invoke <a id="aborting-a-document-load:webdriver-bidi-navigation-aborted" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-aborted" data-x-internal="webdriver-bidi-navigation-aborted">WebDriver BiDi navigation aborted</a> with <var>document</var>'s
     <a href="#node-navigable" id="aborting-a-document-load:node-navigable">node navigable</a> and a new <a id="aborting-a-document-load:webdriver-bidi-navigation-status" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="aborting-a-document-load:navigation-status-id" data-x-internal="navigation-status-id">id</a> is <var>document</var>'s <a href="#concept-document-navigation-id" id="aborting-a-document-load:concept-document-navigation-id-2">during-loading navigation ID for WebDriver BiDi</a>,
     <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="aborting-a-document-load:navigation-status-status" data-x-internal="navigation-status-status">status</a> is "<code id="aborting-a-document-load:navigation-status-canceled"><a data-x-internal="navigation-status-canceled" href="https://w3c.github.io/webdriver-bidi/#navigation-status-canceled">canceled</a></code>", and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="aborting-a-document-load:navigation-status-url" data-x-internal="navigation-status-url">url</a> is <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="aborting-a-document-load:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li><p>Set <var>document</var>'s <a href="#concept-document-navigation-id" id="aborting-a-document-load:concept-document-navigation-id-3">during-loading
     navigation ID for WebDriver BiDi</a> to null.</p></li></ol>
   </li><li>
    <p>If <var>document</var> has an <a href="#active-parser" id="aborting-a-document-load:active-parser">active parser</a>, then:</p>

    <ol><li><p>Set <var>document</var>'s <a href="#active-parser-was-aborted" id="aborting-a-document-load:active-parser-was-aborted">active parser was aborted</a> to true.</p></li><li><p><a href="#abort-a-parser" id="aborting-a-document-load:abort-a-parser">Abort that parser</a>.</p></li><li><p><a href="#make-document-unsalvageable" id="aborting-a-document-load:make-document-unsalvageable-2">Make document unsalvageable</a> given <var>document</var> and
     "<code id="aborting-a-document-load:blocking-parser-aborted"><a href="#blocking-parser-aborted">parser-aborted</a></code>".</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="abort-a-document-and-its-descendants">abort a document and its descendants</dfn> given a <code id="aborting-a-document-load:document-2"><a href="#document">Document</a></code>
  <var>document</var>:</p>

  <ol><li><p><a id="aborting-a-document-load:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this is running as part of a <a href="#concept-task" id="aborting-a-document-load:concept-task-4">task</a>
   queued on <var>document</var>'s <a href="#relevant-agent" id="aborting-a-document-load:relevant-agent-2">relevant agent</a>'s <a href="#concept-agent-event-loop" id="aborting-a-document-load:concept-agent-event-loop-2">event loop</a>.</p></li><li><p>Let <var>descendantNavigables</var> be <var>document</var>'s <a href="#descendant-navigables" id="aborting-a-document-load:descendant-navigables">descendant
   navigables</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="aborting-a-document-load:list-iterate" data-x-internal="list-iterate">For each</a> <var>descendantNavigable</var> of
    <var>descendantNavigables</var> <span class="XXX">in what order?</span>, <a href="#queue-a-global-task" id="aborting-a-document-load:queue-a-global-task">queue
    a global task</a> on the <a href="#navigation-and-traversal-task-source" id="aborting-a-document-load:navigation-and-traversal-task-source">navigation and traversal task source</a> given
    <var>descendantNavigable</var>'s <a href="#nav-window" id="aborting-a-document-load:nav-window">active window</a> to perform the
    following steps:</p>

    <ol><li><p><a href="#abort-a-document" id="aborting-a-document-load:abort-a-document">Abort</a> <var>descendantNavigable</var>'s <a href="#nav-document" id="aborting-a-document-load:nav-document">active document</a>.</p></li><li><p>If <var>descendantNavigable</var>'s <a href="#nav-document" id="aborting-a-document-load:nav-document-2">active
     document</a>'s <i id="aborting-a-document-load:concept-document-salvageable"><a href="#concept-document-salvageable">salvageable</a></i> is false, then set
     <var>document</var>'s <i id="aborting-a-document-load:concept-document-salvageable-2"><a href="#concept-document-salvageable">salvageable</a></i> to
     false.</p></li></ol>
   </li><li><p><a href="#abort-a-document" id="aborting-a-document-load:abort-a-document-2">Abort</a> <var>document</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="stop-document-loading">To <dfn id="nav-stop">stop loading</dfn> a
  <a href="#navigable" id="aborting-a-document-load:navigable">navigable</a> <var>navigable</var>:</p>

  <ol><li><p>Let <var>document</var> be <var>navigable</var>'s <a href="#nav-document" id="aborting-a-document-load:nav-document-3">active
   document</a>.</p></li><li>
    <p>If <var>document</var>'s <a href="#unload-counter" id="aborting-a-document-load:unload-counter">unload counter</a> is 0, and <var>navigable</var>'s
    <a href="#ongoing-navigation" id="aborting-a-document-load:ongoing-navigation">ongoing navigation</a> is a <a href="#navigation-id" id="aborting-a-document-load:navigation-id">navigation ID</a>, then <a href="#set-the-ongoing-navigation" id="aborting-a-document-load:set-the-ongoing-navigation">set the ongoing
    navigation</a> for <var>navigable</var> to null.</p>

    <p class="note">This will have the effect of aborting any ongoing navigations of
    <var>navigable</var>, since at certain points during navigation, changes to the <a href="#ongoing-navigation" id="aborting-a-document-load:ongoing-navigation-2">ongoing
    navigation</a> will cause further work to be abandoned.</p>
   </li><li><p><a href="#abort-a-document-and-its-descendants" id="aborting-a-document-load:abort-a-document-and-its-descendants">Abort a document and its descendants</a> given <var>document</var>.</p></li></ol>
  </div>

  <p class="XXX">Through their <a href="#nav-traversal-ui">user interface</a>, user agents also
  allow stopping traversals, i.e. cases where the <a href="#ongoing-navigation" id="aborting-a-document-load:ongoing-navigation-3">ongoing navigation</a> is "<code>traversal</code>". The above algorithm does not account for this. (On the other hand,
  user agents do not allow <code id="aborting-a-document-load:dom-window-stop"><a href="#dom-window-stop">window.stop()</a></code> to stop traversals,
  so the above algorithm is correct for that caller.) See <a href="https://github.com/whatwg/html/issues/6905">issue #6905</a>.</p>


  <h3 id="speculative-loading"><span class="secno">7.6</span> Speculative loading<a href="#speculative-loading" class="self-link"></a></h3>

  <p>Speculative loading is the practice of performing navigation actions, such as prefetching,
  ahead of navigation starting. This makes subsequent navigations faster.</p>

  <p>Developers can initiate speculative loads by using <a href="#speculation-rule-set" id="speculative-loading:speculation-rule-set">speculation rules</a>. User agents might also perform speculative loads in certain
  <a id="speculative-loading:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> scenarios, such as typing into the address bar.</p>

  <h4 id="speculation-rules"><span class="secno">7.6.1</span> Speculation rules<a href="#speculation-rules" class="self-link"></a></h4>

  <p><a href="#speculation-rule-set" id="speculation-rules:speculation-rule-set">Speculation rules</a> are how developers instruct the
  browser about speculative loading operations that the developer believes will be beneficial. They
  are delivered as JSON documents, via either:</p>

  <ul><li><p>inline <code id="speculation-rules:the-script-element"><a href="#the-script-element">script</a></code> elements with their <code id="speculation-rules:attr-script-type"><a href="#attr-script-type">type</a></code>
   attribute set to "<code>speculationrules</code>"; or</p></li><li><p>resources fetched from a URL specified in the `<code id="speculation-rules:speculation-rules-2"><a href="#speculation-rules-2">Speculation-Rules</a></code>` HTTP
   response header.</p></li></ul>

  <div id="example-speculation-rules-simple" class="example"><a href="#example-speculation-rules-simple" class="self-link"></a>
   <p>The following JSON document is parsed into a <a href="#speculation-rule-set" id="speculation-rules:speculation-rule-set-2">speculation rule set</a> specifying a
   number of desired conditions for the user agent to <a id="speculation-rules:start-a-referrer-initiated-navigational-prefetch" href="https://wicg.github.io/nav-speculation/prefetch.html#start-a-referrer-initiated-navigational-prefetch" data-x-internal="start-a-referrer-initiated-navigational-prefetch">start a referrer-initiated navigational
   prefetch</a>:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"prefetch"</c-><c- o="">:</c-> <c- p="">[</c->
    <c- p="">{</c->
      <c- u="">"urls"</c-><c- o="">:</c-> <c- p="">[</c-><c- u="">"/chapters/5"</c-><c- p="">]</c->
    <c- p="">},</c->
    <c- p="">{</c->
      <c- u="">"eagerness"</c-><c- o="">:</c-> <c- u="">"moderate"</c-><c- p="">,</c->
      <c- u="">"where"</c-><c- o="">:</c-> <c- p="">{</c->
        <c- u="">"and"</c-><c- o="">:</c-> <c- p="">[</c->
          <c- p="">{</c-> <c- u="">"href_matches"</c-><c- o="">:</c-> <c- u="">"/*"</c-> <c- p="">},</c->
          <c- p="">{</c-> <c- u="">"not"</c-><c- o="">:</c-> <c- p="">{</c-> <c- u="">"selector_matches"</c-><c- o="">:</c-> <c- u="">".no-prefetch"</c-> <c- p="">}</c-> <c- p="">}</c->
        <c- p="">]</c->
      <c- p="">}</c->
    <c- p="">}</c->
  <c- p="">]</c->
<c- p="">}</c-></code></pre>
  </div>

  <p>A JSON document representing a <a href="#speculation-rule-set" id="speculation-rules:speculation-rule-set-3">speculation rule set</a> must meet the following
  <dfn id="speculation-rule-set-authoring-requirements">speculation rule set authoring requirements</dfn>:</p>

  <ul><li><p>It must be valid JSON. <a href="#refsJSON">[JSON]</a></p></li><li>
    <p>The JSON must represent a JSON object, with at most three keys "<code>tag</code>",
    "<code>prefetch</code>" and "<code>prerender</code>".</p>

    <p class="note">In this standard, "<code>prerender</code>" is optionally converted to
    "<code>prefetch</code>" <a href="#note-speculation-rules-parse-prerender-as-prefetch">at parse time</a>. Some
    implementations might implement different behavior for prerender, as specified in
    <cite>Prerendering Revamped</cite>. <a href="#refsPRERENDERING-REVAMPED">[PRERENDERING-REVAMPED]</a></p>
   </li><li><p>The value corresponding to the "<code>tag</code>" key, if present, must be a
   <a href="#speculation-rule-tag" id="speculation-rules:speculation-rule-tag">speculation rule tag</a>.</p></li><li><p>The values corresponding to the "<code>prefetch</code>" and "<code>prerender</code>" keys, if present, must be arrays of <a href="#valid-speculation-rule" id="speculation-rules:valid-speculation-rule">valid speculation rules</a>.</p></li></ul>

  <p>A <dfn id="valid-speculation-rule">valid speculation rule</dfn> is a JSON object that meets the following requirements:</p>

  <ul><li>
    <p>It must have at most the following keys: "<code>source</code>", "<code>urls</code>", "<code>where</code>", "<code>relative_to</code>",
    "<code>eagerness</code>",  "<code>referrer_policy</code>", "<code>tag</code>", "<code>requires</code>", "<code>expects_no_vary_search</code>", or "<code>target_hint</code>".</p>

    <p class="note">In this standard, <a href="#note-speculation-rules-parse-target-hint">"<code>target_hint</code>" is ignored</a>.</p>
   </li><li><p>The value corresponding to the "<code>source</code>" key, if present, must be
   either "<code>list</code>" or "<code>document</code>".</p></li><li><p>If the value corresponding to the "<code>source</code>" key is "<code>list</code>", then the "<code>urls</code>" key must be present, and the
   "<code>where</code>" key must be absent.</p></li><li><p>If the value corresponding to the "<code>source</code>" key is "<code>document</code>", then the "<code>urls</code>" key must be absent.</p></li><li><p>The "<code>urls</code>" and "<code>where</code>" keys must not both be
   present.</p></li><li><p>If the value corresponding to the "<code>source</code>" key is "<code>document</code>" or the "<code>where</code>" key is present, then the "<code>relative_to</code>" key must be absent.</p></li><li><p>The value corresponding to the "<code>urls</code>" key, if present, must be an
   array of <a href="https://url.spec.whatwg.org/#valid-url-string" id="speculation-rules:valid-url-string" data-x-internal="valid-url-string">valid URL strings</a>.</p></li><li><p>The value corresponding to the "<code>where</code>" key, if present, must be a
   <a href="#valid-document-rule-predicate" id="speculation-rules:valid-document-rule-predicate">valid document rule predicate</a>.</p></li><li><p>The value corresponding to the "<code>relative_to</code>" key, if present, must
   be either "<code>ruleset</code>" or "<code>document</code>".</p></li><li><p>The value corresponding to the "<code>eagerness</code>" key, if present, must be
   a <a href="#speculation-rule-eagerness" id="speculation-rules:speculation-rule-eagerness">speculation rule eagerness</a>.</p></li><li><p>The value corresponding to the "<code>referrer_policy</code>" key, if present,
   must be a <a id="speculation-rules:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>.</p></li><li><p>The value corresponding to the "<code>tag</code>" key, if present, must be a
   <a href="#speculation-rule-tag" id="speculation-rules:speculation-rule-tag-2">speculation rule tag</a>.</p></li><li><p>The value corresponding to the "<code>requires</code>" key, if present, must be
   an array of <a href="#speculation-rule-requirement" id="speculation-rules:speculation-rule-requirement">speculation rule
   requirements</a>.</p></li><li><p>The value corresponding to the "<code>expects_no_vary_search</code>" key, if
   present, must be a <a id="speculation-rules:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> that is <a href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#parse-a-url-search-variance" id="speculation-rules:parse-a-url-search-variance" data-x-internal="parse-a-url-search-variance">parseable</a> as a `<code id="speculation-rules:no-vary-search"><a data-x-internal="no-vary-search" href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-http-header-field-definitio">No-Vary-Search</a></code>` header value.</p></li></ul>

  <p>A <dfn id="valid-document-rule-predicate">valid document rule predicate</dfn> is a JSON object that meets the following
  requirements:</p>

  <ul><li><p>It must contain exactly one of the keys "<code>and</code>", "<code>or</code>", "<code>not</code>", "<code>href_matches</code>", or
   "<code>selector_matches</code>".</p></li><li><p>It must not contain any keys apart from the above or "<code>relative_to</code>".</p></li><li><p>If it contains the key "<code>relative_to</code>", then it must also contain the
   key "<code>href_matches</code>".</p></li><li><p>The value corresponding to the "<code>relative_to</code>" key, if present, must
   be either "<code>ruleset</code>" or "<code>document</code>".</p></li><li><p>The value corresponding to the "<code>and</code>" or "<code>or</code>"
   keys, if present, must be arrays of <a href="#valid-document-rule-predicate" id="speculation-rules:valid-document-rule-predicate-2">valid document
   rule predicates</a>.</p></li><li><p>The value corresponding to the "<code>not</code>" key, if present, must be a
   <a href="#valid-document-rule-predicate" id="speculation-rules:valid-document-rule-predicate-3">valid document rule predicate</a>.</p></li><li><p>The value corresponding to the "<code>href_matches</code>" key, if present, must
   be either a <a href="#valid-url-pattern-input" id="speculation-rules:valid-url-pattern-input">valid URL pattern input</a> or an array of <a href="#valid-url-pattern-input" id="speculation-rules:valid-url-pattern-input-2">valid URL pattern inputs</a>.</p></li><li><p>The value corresponding to the "<code>selector_matches</code>" key, if present,
   must be either a <a id="speculation-rules:string-2" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> matching <code id="speculation-rules:selector-list"><a data-x-internal="selector-list" href="https://drafts.csswg.org/selectors/#typedef-selector-list">&lt;selector-list&gt;</a></code> or an array of
   <a href="https://infra.spec.whatwg.org/#string" id="speculation-rules:string-3" data-x-internal="string">strings</a> that match <code id="speculation-rules:selector-list-2"><a data-x-internal="selector-list" href="https://drafts.csswg.org/selectors/#typedef-selector-list">&lt;selector-list&gt;</a></code>.</p></li></ul>

  <p>A <dfn id="valid-url-pattern-input">valid URL pattern input</dfn> is either:</p>

  <ul><li><p>a <a id="speculation-rules:scalar-value-string" href="https://infra.spec.whatwg.org/#scalar-value-string" data-x-internal="scalar-value-string">scalar value string</a> that can be successfully <a href="https://urlpattern.spec.whatwg.org/#parse-a-constructor-string" id="speculation-rules:parse-a-url-pattern-constructor-string" data-x-internal="parse-a-url-pattern-constructor-string">parsed</a> as a URL pattern constructor string, or;</p></li><li><p>a JSON object whose keys are drawn from the members of the <code id="speculation-rules:urlpatterninit"><a data-x-internal="urlpatterninit" href="https://urlpattern.spec.whatwg.org/#dictdef-urlpatterninit">URLPatternInit</a></code>
   dictionary and whose values are <a href="https://infra.spec.whatwg.org/#scalar-value-string" id="speculation-rules:scalar-value-string-2" data-x-internal="scalar-value-string">scalar value
   strings</a>.</p></li></ul>

  <h5 id="speculation-rules-data-model"><span class="secno">7.6.1.1</span> Data model<a href="#speculation-rules-data-model" class="self-link"></a></h5>

  <p>A <dfn id="speculation-rule-set">speculation rule set</dfn> is a <a id="speculation-rules-data-model:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-data-model:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="sr-set-prefetch">prefetch rules</dfn>, a <a id="speculation-rules-data-model:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#speculation-rule" id="speculation-rules-data-model:speculation-rule">speculation rules</a>, initially empty</p></li></ul>

  <p class="note">In the future, other rules will be possible, e.g., prerender rules. See
  <cite>Prerendering Revamped</cite> for such not-yet-accepted extensions.
  <a href="#refsPRERENDERING-REVAMPED">[PRERENDERING-REVAMPED]</a></p>

  <p>A <dfn id="speculation-rule">speculation rule</dfn> is a <a id="speculation-rules-data-model:struct-2" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-data-model:struct-item-2" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="sr-urls">URLs</dfn>, an <a href="https://infra.spec.whatwg.org/#ordered-set" id="speculation-rules-data-model:set" data-x-internal="set">ordered set</a> of <a href="https://url.spec.whatwg.org/#concept-url" id="speculation-rules-data-model:url" data-x-internal="url">URLs</a></p></li><li><p><dfn id="sr-predicate">predicate</dfn>, a <a href="#document-rule-predicate" id="speculation-rules-data-model:document-rule-predicate">document rule predicate</a> or
   null</p></li><li><p><dfn id="sr-eagerness">eagerness</dfn>, a <a href="#speculation-rule-eagerness" id="speculation-rules-data-model:speculation-rule-eagerness">speculation rule
   eagerness</a></p></li><li><p><dfn id="sr-referrer-policy">referrer policy</dfn>, a <a id="speculation-rules-data-model:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer
   policy</a></p></li><li><p><dfn id="sr-tags">tags</dfn>, an <a href="https://infra.spec.whatwg.org/#ordered-set" id="speculation-rules-data-model:set-2" data-x-internal="set">ordered set</a> of <a href="#speculation-rule-tag" id="speculation-rules-data-model:speculation-rule-tag">speculation rule tags</a></p></li><li><p><dfn id="sr-requirements">requirements</dfn>, an <a href="https://infra.spec.whatwg.org/#ordered-set" id="speculation-rules-data-model:set-3" data-x-internal="set">ordered set</a>
   of <a href="#speculation-rule-requirement" id="speculation-rules-data-model:speculation-rule-requirement">speculation rule requirements</a></p></li><li><p><dfn id="sr-nvs-hint">No-Vary-Search hint</dfn>, a <a id="speculation-rules-data-model:url-search-variance" href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-data-model" data-x-internal="url-search-variance">URL search
   variance</a></p></li></ul>

  <hr>

  <p>A <dfn id="document-rule-predicate">document rule predicate</dfn> is one of the following:</p>

  <ul><li><p>a <a href="#document-rule-conjunction" id="speculation-rules-data-model:document-rule-conjunction">document rule conjunction</a>;</p></li><li><p>a <a href="#document-rule-disjunction" id="speculation-rules-data-model:document-rule-disjunction">document rule disjunction</a>;</p></li><li><p>a <a href="#document-rule-negation" id="speculation-rules-data-model:document-rule-negation">document rule negation</a>;</p></li><li><p>a <a href="#document-rule-url-pattern-predicate" id="speculation-rules-data-model:document-rule-url-pattern-predicate">document rule URL pattern predicate</a>; or</p></li><li><p>a <a href="#document-rule-selector-predicate" id="speculation-rules-data-model:document-rule-selector-predicate">document rule selector predicate</a>.</p></li></ul>

  <p>A <dfn id="document-rule-conjunction">document rule conjunction</dfn> is a <a id="speculation-rules-data-model:struct-3" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-data-model:struct-item-3" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="sr-dr-c-clauses">clauses</dfn>, a <a id="speculation-rules-data-model:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#document-rule-predicate" id="speculation-rules-data-model:document-rule-predicate-2">document rule predicates</a></p></li></ul>

  <p>A <dfn id="document-rule-disjunction">document rule disjunction</dfn> is a <a id="speculation-rules-data-model:struct-4" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-data-model:struct-item-4" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="sr-dr-d-clauses">clauses</dfn>, a <a id="speculation-rules-data-model:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#document-rule-predicate" id="speculation-rules-data-model:document-rule-predicate-3">document rule predicates</a></p></li></ul>

  <p>A <dfn id="document-rule-negation">document rule negation</dfn> is a <a id="speculation-rules-data-model:struct-5" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-data-model:struct-item-5" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="sr-dr-n-clause">clause</dfn>, a <a href="#document-rule-predicate" id="speculation-rules-data-model:document-rule-predicate-4">document rule predicate</a></p></li></ul>

  <p>A <dfn id="document-rule-url-pattern-predicate">document rule URL pattern predicate</dfn> is a <a id="speculation-rules-data-model:struct-6" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following
  <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-data-model:struct-item-6" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="sr-dr-urlpattern-patterns">patterns</dfn>, a <a id="speculation-rules-data-model:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="https://urlpattern.spec.whatwg.org/#url-pattern" id="speculation-rules-data-model:url-pattern" data-x-internal="url-pattern">URL patterns</a></p></li></ul>

  <p>A <dfn id="document-rule-selector-predicate">document rule selector predicate</dfn> is a <a id="speculation-rules-data-model:struct-7" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-data-model:struct-item-7" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="sr-dr-cssselector-selectors">selectors</dfn>, a <a id="speculation-rules-data-model:list-5" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="https://drafts.csswg.org/selectors/#selector" id="speculation-rules-data-model:selector" data-x-internal="selector">selectors</a></p></li></ul>

  <hr>

  <p>A <dfn id="speculation-rule-eagerness">speculation rule eagerness</dfn> is one of the following <a href="https://infra.spec.whatwg.org/#string" id="speculation-rules-data-model:string" data-x-internal="string">strings</a>:</p>

  <dl><dt>"<dfn id="sr-eagerness-immediate"><code>immediate</code></dfn>"</dt><dd><p>The developer believes that performing the associated speculative loads is very likely to
   be worthwhile, and they might also expect that load to require significant lead time to complete.
   User agents should usually enact the speculative load candidate as soon as practical, subject
   only to considerations such as user preferences, device conditions, and resource limits.</p></dd><dt>"<dfn id="sr-eagerness-eager"><code>eager</code></dfn>"</dt><dd><p>User agents should enact the speculative load candidate on even a slight suggestion that
   the user may navigate to this URL in the future. For instance, the user might have moved the
   cursor toward a link or hovered it, even momentarily, or paused scrolling when the link is one of
   the more prominent ones in the viewport. The author is seeking to capture as many navigations as
   possible, as early as possible.</p></dd><dt>"<dfn id="sr-eagerness-moderate"><code>moderate</code></dfn>"</dt><dd><p>User agents should enact the candidate if user behavior suggests the user may navigate to
   this URL in the near future. For instance, the user might have scrolled a link into the viewport
   and shown signs of being likely to click it, e.g., by moving the cursor over it for some time.
   The developer is seeking a balance between "<code id="speculation-rules-data-model:sr-eagerness-eager"><a href="#sr-eagerness-eager">eager</a></code>" and
   "<code id="speculation-rules-data-model:sr-eagerness-conservative"><a href="#sr-eagerness-conservative">conservative</a></code>".</p></dd><dt>"<dfn id="sr-eagerness-conservative"><code>conservative</code></dfn>"</dt><dd><p>User agents should enact the candidate only when the user is very likely to navigate to
   this URL at any moment. For instance, the user might have begun to interact with a link. The
   developer is seeking to capture some of the benefits of speculative loading with a fairly small
   tradeoff of resources.</p></dd></dl>

  <div data-algorithm="">
  <p>A <a href="#speculation-rule-eagerness" id="speculation-rules-data-model:speculation-rule-eagerness-2">speculation rule eagerness</a> <var>A</var> is <dfn id="sr-eagerness-less-eager">less eager</dfn> than another <a href="#speculation-rule-eagerness" id="speculation-rules-data-model:speculation-rule-eagerness-3">speculation rule
  eagerness</a> <var>B</var> if <var>A</var> follows <var>B</var> in the above list.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#speculation-rule-eagerness" id="speculation-rules-data-model:speculation-rule-eagerness-4">speculation rule eagerness</a> <var>A</var> is <dfn id="sr-eagerness-at-least-as-eager">at least as eager</dfn> as another <a href="#speculation-rule-eagerness" id="speculation-rules-data-model:speculation-rule-eagerness-5">speculation rule
  eagerness</a> <var>B</var> if <var>A</var> is not <a href="#sr-eagerness-less-eager" id="speculation-rules-data-model:sr-eagerness-less-eager">less
  eager</a> than <var>B</var>.</p>
  </div>

  <hr>

  <p>A <dfn id="speculation-rule-tag">speculation rule tag</dfn> is either an <a id="speculation-rules-data-model:ascii-string" href="https://infra.spec.whatwg.org/#ascii-string" data-x-internal="ascii-string">ASCII string</a> whose <a href="https://infra.spec.whatwg.org/#code-point" id="speculation-rules-data-model:code-point" data-x-internal="code-point">code points</a> are all in the range U+0020 to U+007E inclusive, or
  null.</p>

  <p class="note">This code point range restriction ensures the value can be sent in an HTTP header
  with no escaping or modification.</p>

  <hr>

  <p>A <dfn id="speculation-rule-requirement">speculation rule requirement</dfn> is the string "<code>anonymous-client-ip-when-cross-origin</code>".</p>

  <p class="note">In the future, more possible requirements might be defined.</p>

  <h5 id="speculation-rules-parsing"><span class="secno">7.6.1.2</span> Parsing<a href="#speculation-rules-parsing" class="self-link"></a></h5>

  <div class="note">
   <p>Since speculative loading is a progressive enhancement, this standard is fairly conservative
   in its parsing behavior. In particular, unknown keys or invalid values usually cause parsing
   failure, since it is safer to do nothing than to possibly misinterpret a speculation rule.</p>

   <p>That said, parsing failure for a single speculation rule still allows other speculation rules
   to be processed. It is only in the case of top-level misconfiguration that the entire speculation
   rule set is discarded.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="parse-a-speculation-rule-set-string">parse a speculation rule set string</dfn> given a <a id="speculation-rules-parsing:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>input</var>,
  a <code id="speculation-rules-parsing:document"><a href="#document">Document</a></code> <var>document</var>, and a <a id="speculation-rules-parsing:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>:</p>

  <ol><li><p>Let <var>parsed</var> be the result of <a href="https://infra.spec.whatwg.org/#parse-a-json-string-to-an-infra-value" id="speculation-rules-parsing:parse-a-json-string-to-an-infra-value" data-x-internal="parse-a-json-string-to-an-infra-value">parsing a JSON string to an Infra value</a> given <var>input</var>.</p></li><li><p>If <var>parsed</var> is not a <a href="https://infra.spec.whatwg.org/#ordered-map" id="speculation-rules-parsing:ordered-map" data-x-internal="ordered-map">map</a>, then throw a
   <code id="speculation-rules-parsing:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that the top-level value needs to be a JSON object.</p>

   </li><li><p>Let <var>result</var> be a new <a href="#speculation-rule-set" id="speculation-rules-parsing:speculation-rule-set">speculation rule set</a>.</p></li><li><p>Let <var>tag</var> be null.</p></li><li>
    <p>If <var>parsed</var>["<code>tag</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists" data-x-internal="map-exists">exists</a>:</p>

    <ol><li><p>If <var>parsed</var>["<code>tag</code>"] is not a <a href="#speculation-rule-tag" id="speculation-rules-parsing:speculation-rule-tag">speculation rule
     tag</a>, then throw a <code id="speculation-rules-parsing:typeerror-2"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that the speculation rule tag is
     invalid.</p>

     </li><li><p>Set <var>tag</var> to <var>parsed</var>["<code>tag</code>"].</p></li></ol>
   </li><li><p>Let <var>typesToTreatAsPrefetch</var> be « "<code>prefetch</code>" ».</p></li><li>
    <p>The user agent may <a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-parsing:list-append" data-x-internal="list-append">append</a> "<code>prerender</code>" to <var>typesToTreatAsPrefetch</var>.</p>

    <p id="note-speculation-rules-parse-prerender-as-prefetch" class="note"><a href="#note-speculation-rules-parse-prerender-as-prefetch" class="self-link"></a>Since this specification
    only includes prefetching, this allows user agents to treat requests for prerendering as
    requests for prefetching. User agents which implement prerendering, per the <cite>Prerendering
    Revamped</cite> specification, will instead interpret these as prerender requests.
    <a href="#refsPRERENDERING-REVAMPED">[PRERENDERING-REVAMPED]</a></p>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-parsing:list-iterate" data-x-internal="list-iterate">For each</a> <var>type</var> of
    <var>typesToTreatAsPrefetch</var>:</p>

    <ol><li>
      <p>If <var>parsed</var>[<var>type</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-2" data-x-internal="map-exists">exists</a>:</p>

      <ol><li>
        <p>If <var>parsed</var>[<var>type</var>] is a <a id="speculation-rules-parsing:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>, then <a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-parsing:list-iterate-2" data-x-internal="list-iterate">for each</a> <var>rule</var> of <var>parsed</var>[<var>type</var>]:</p>

        <ol><li><p>Let <var>rule</var> be the result of <a href="#parse-a-speculation-rule" id="speculation-rules-parsing:parse-a-speculation-rule">parsing
         a speculation rule</a> given <var>rule</var>, <var>tag</var>, <var>document</var>, and
         <var>baseURL</var>.</p></li><li><p>If <var>rule</var> is null, then <a id="speculation-rules-parsing:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-parsing:list-append-2" data-x-internal="list-append">Append</a> <var>rule</var> to <var>result</var>'s
         <a href="#sr-set-prefetch" id="speculation-rules-parsing:sr-set-prefetch">prefetch rules</a>.</p></li></ol>
       </li><li><p>Otherwise, the user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating
       that the rules list for <var>type</var> needs to be a JSON array.</p></li></ol>
     </li></ol>
   </li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="parse-a-speculation-rule">parse a speculation rule</dfn> given a <a href="https://infra.spec.whatwg.org/#ordered-map" id="speculation-rules-parsing:ordered-map-2" data-x-internal="ordered-map">map</a>
  <var>input</var>, a <a href="#speculation-rule-tag" id="speculation-rules-parsing:speculation-rule-tag-2">speculation rule tag</a> <var>rulesetLevelTag</var>, a
  <code id="speculation-rules-parsing:document-2"><a href="#document">Document</a></code> <var>document</var>, and a <a id="speculation-rules-parsing:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>:</p>

  <ol><li>
    <p>If <var>input</var> is not a <a href="https://infra.spec.whatwg.org/#ordered-map" id="speculation-rules-parsing:ordered-map-3" data-x-internal="ordered-map">map</a>:</p>

    <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-2" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the rule
     needs to be a JSON object.</p></li><li><p>Return null.</p></li></ol>
   </li><li>
    <p>If <var>input</var> has any <a href="https://infra.spec.whatwg.org/#map-key" id="speculation-rules-parsing:map-key" data-x-internal="map-key">key</a> other than "<code>source</code>", "<code>urls</code>", "<code>where</code>", "<code>relative_to</code>", "<code>eagerness</code>",  "<code>referrer_policy</code>", "<code>tag</code>", "<code>requires</code>", "<code>expects_no_vary_search</code>", or "<code>target_hint</code>":</p>

    <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-3" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the rule
     has unrecognized keys.</p></li><li><p>Return null.</p></li></ol>

    <p id="note-speculation-rules-parse-target-hint" class="note"><a href="#note-speculation-rules-parse-target-hint" class="self-link"></a>"<code>target_hint</code>" has no impact on the processing model in this standard. However,
    implementations of <cite>Prerendering Revamped</cite> can use it for prerendering rules, and so
    requiring user agents to fail parsing such rules would be counterproductive.
    <a href="#refsPRERENDERING-REVAMPED">[PRERENDERING-REVAMPED]</a>.</p>
   </li><li><p>Let <var>source</var> be null.</p></li><li><p>If <var>input</var>["<code>source</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-3" data-x-internal="map-exists">exists</a>, then set <var>source</var> to <var>input</var>["<code>source</code>"].</p></li><li><p>Otherwise, if <var>input</var>["<code>urls</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-4" data-x-internal="map-exists">exists</a> and <var>input</var>["<code>where</code>"] does not <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-5" data-x-internal="map-exists">exist</a>, then set <var>source</var> to "<code>list</code>".</p></li><li><p>Otherwise, if <var>input</var>["<code>where</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-6" data-x-internal="map-exists">exists</a> and <var>input</var>["<code>urls</code>"] does not <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-7" data-x-internal="map-exists">exist</a>, then set <var>source</var> to "<code>document</code>".</p></li><li>
    <p>If <var>source</var> is neither "<code>list</code>" nor "<code>document</code>":</p>

    <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-4" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that a source
     could not be inferred or an invalid source was specified.</p></li><li><p>Return null.</p></li></ol>
   </li><li><p>Let <var>urls</var> be an empty <a id="speculation-rules-parsing:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>Let <var>predicate</var> be null.</p></li><li>
    <p>If <var>source</var> is "<code>list</code>":</p>

    <ol><li>
      <p>If <var>input</var>["<code>where</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-8" data-x-internal="map-exists">exists</a>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-5" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that there
       were conflicting sources for this rule.</p></li><li><p>Return null.</p></li></ol>
     </li><li>
      <p>If <var>input</var>["<code>relative_to</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-9" data-x-internal="map-exists">exists</a>:</p>

      <ol><li>
        <p>If <var>input</var>["<code>relative_to</code>"] is neither "<code>ruleset</code>" nor "<code>document</code>":</p>

        <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-6" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
         supplied relative-to value was invalid.</p></li><li><p>Return null.</p></li></ol>
       </li><li><p>If <var>input</var>["<code>relative_to</code>"] is "<code>document</code>", then set <var>baseURL</var> to <var>document</var>'s
       <a href="#document-base-url" id="speculation-rules-parsing:document-base-url">document base URL</a>.</p></li></ol>
     </li><li>
      <p>If <var>input</var>["<code>urls</code>"] does not <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-10" data-x-internal="map-exists">exist</a> or is not a <a id="speculation-rules-parsing:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-7" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       supplied URL list was invalid.</p></li><li><p>Return null.</p></li></ol>
     </li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-parsing:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>urlString</var> of <var>input</var>["<code>urls</code>"]:</p>

      <ol><li>
        <p>If <var>urlString</var> is not a string:</p>

        <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-8" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
         supplied URL must be a string.</p></li><li><p>Return null.</p></li></ol>
       </li><li><p>Let <var>parsedURL</var> be the result of <a href="https://url.spec.whatwg.org/#concept-url-parser" id="speculation-rules-parsing:url-parser" data-x-internal="url-parser">URL parsing</a>
       <var>urlString</var> with <var>baseURL</var>.</p></li><li>
        <p>If <var>parsedURL</var> is failure, or <var>parsedURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="speculation-rules-parsing:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is not an <a id="speculation-rules-parsing:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>:</p>

        <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-9" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
         supplied URL string was unparseable.</p></li><li><p><a id="speculation-rules-parsing:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
       </li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-parsing:list-append-3" data-x-internal="list-append">Append</a> <var>parsedURL</var> to
       <var>urls</var>.</p></li></ol>
     </li></ol>
   </li><li>
    <p>If <var>source</var> is "<code>document</code>":</p>

    <ol><li>
      <p>If <var>input</var>["<code>urls</code>"] or <var>input</var>["<code>relative_to</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-11" data-x-internal="map-exists">exists</a>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-10" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that there
       were conflicting sources for this rule.</p></li><li><p>Return null.</p></li></ol>
     </li><li>
      <p>If <var>input</var>["<code>where</code>"] does not <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-12" data-x-internal="map-exists">exist</a>, then set <var>predicate</var> to a <a href="#document-rule-conjunction" id="speculation-rules-parsing:document-rule-conjunction">document rule
      conjunction</a> whose <a href="#sr-dr-c-clauses" id="speculation-rules-parsing:sr-dr-c-clauses">clauses</a> is an empty
      <a id="speculation-rules-parsing:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p>

      <p class="note">Such a predicate will match all links.</p>
     </li><li><p>Otherwise, set <var>predicate</var> to the result of <a href="#parse-a-document-rule-predicate" id="speculation-rules-parsing:parse-a-document-rule-predicate">parsing a document rule predicate</a> given <var>input</var>["<code>where</code>"], <var>document</var>, and <var>baseURL</var>.</p></li><li><p>If <var>predicate</var> is null, then return null.</p></li></ol>
   </li><li><p>Let <var>eagerness</var> be "<code id="speculation-rules-parsing:sr-eagerness-immediate"><a href="#sr-eagerness-immediate">immediate</a></code>" if
   <var>source</var> is "<code>list</code>"; otherwise, "<code id="speculation-rules-parsing:sr-eagerness-conservative"><a href="#sr-eagerness-conservative">conservative</a></code>".</p></li><li>
    <p>If <var>input</var>["<code>eagerness</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-13" data-x-internal="map-exists">exists</a>:</p>

    <ol><li>
      <p>If <var>input</var>["<code>eagerness</code>"] is not a <a href="#speculation-rule-eagerness" id="speculation-rules-parsing:speculation-rule-eagerness">speculation rule
      eagerness</a>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-11" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       eagerness was invalid.</p></li><li><p>Return null.</p></li></ol>
     </li><li><p>Set <var>eagerness</var> to <var>input</var>["<code>eagerness</code>"].</p></li></ol>
   </li><li><p>Let <var>referrerPolicy</var> be the empty string.</p></li><li>
    <p>If <var>input</var>["<code>referrer_policy</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-14" data-x-internal="map-exists">exists</a>:</p>

    <ol><li>
      <p>If <var>input</var>["<code>referrer_policy</code>"] is not a <a id="speculation-rules-parsing:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer
      policy</a>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-12" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       referrer policy was invalid.</p></li><li><p>Return null.</p></li></ol>
     </li><li><p>Set <var>referrerPolicy</var> to <var>input</var>["<code>referrer_policy</code>"].</p></li></ol>
   </li><li><p>Let <var>tags</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-set" id="speculation-rules-parsing:set" data-x-internal="set">ordered set</a>.</p></li><li><p>If <var>rulesetLevelTag</var> is not null, then <a href="https://infra.spec.whatwg.org/#set-append" id="speculation-rules-parsing:set-append" data-x-internal="set-append">append</a>
   <var>rulesetLevelTag</var> to <var>tags</var>.</p></li><li>
    <p>If <var>input</var>["<code>tag</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-15" data-x-internal="map-exists">exists</a>:</p>

    <ol><li>
      <p>If <var>input</var>["<code>tag</code>"] is not a <a href="#speculation-rule-tag" id="speculation-rules-parsing:speculation-rule-tag-3">speculation rule
      tag</a>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-13" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       tag was invalid.</p></li><li><p>Return null.</p></li></ol>
     </li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="speculation-rules-parsing:set-append-2" data-x-internal="set-append">Append</a> <var>input</var>["<code>tag</code>"]
     to <var>tags</var>.</p></li></ol>
   </li><li><p>If <var>tags</var> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="speculation-rules-parsing:list-is-empty" data-x-internal="list-is-empty">is empty</a>, then <a href="https://infra.spec.whatwg.org/#set-append" id="speculation-rules-parsing:set-append-3" data-x-internal="set-append">append</a> null to <var>tags</var>.</p></li><li><p><a id="speculation-rules-parsing:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>tags</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="speculation-rules-parsing:list-size" data-x-internal="list-size">size</a> is either 1 or
   2.</p></li><li><p>Let <var>requirements</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-set" id="speculation-rules-parsing:set-2" data-x-internal="set">ordered set</a>.</p></li><li>
    <p>If <var>input</var>["<code>requires</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-16" data-x-internal="map-exists">exists</a>:</p>

    <ol><li>
      <p>If <var>input</var>["<code>requires</code>"] is not a <a id="speculation-rules-parsing:list-5" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-14" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       requirements were not understood.</p></li><li><p>Return null.</p></li></ol>
     </li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-parsing:list-iterate-4" data-x-internal="list-iterate">For each</a> <var>requirement</var> of
      <var>input</var>["<code>requires</code>"]:</p>

      <ol><li>
        <p>If <var>requirement</var> is not a <a href="#speculation-rule-requirement" id="speculation-rules-parsing:speculation-rule-requirement">speculation rule requirement</a>:</p>

        <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-15" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
         requirement was not understood.</p></li><li><p>Return null.</p></li></ol>
       </li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="speculation-rules-parsing:set-append-4" data-x-internal="set-append">Append</a> <var>requirement</var> to
       <var>requirements</var>.</p></li></ol>
     </li></ol>
   </li><li><p>Let <var>noVarySearchHint</var> be the <a id="speculation-rules-parsing:default-url-search-variance" href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-data-model" data-x-internal="default-url-search-variance">default URL search variance</a>.</p></li><li>
    <p>If <var>input</var>["<code>expects_no_vary_search</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-17" data-x-internal="map-exists">exists</a>:</p>

    <ol><li>
      <p>If <var>input</var>["<code>expects_no_vary_search</code>"] is not a
      <a id="speculation-rules-parsing:string-2" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-16" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       `<code id="speculation-rules-parsing:no-vary-search"><a data-x-internal="no-vary-search" href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-http-header-field-definitio">No-Vary-Search</a></code>` hint was invalid.</p></li><li><p>Return null.</p></li></ol>
     </li><li><p>Set <var>noVarySearchHint</var> to the result of <a href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#parse-a-url-search-variance" id="speculation-rules-parsing:parse-a-url-search-variance" data-x-internal="parse-a-url-search-variance">parsing a URL search variance</a> given <var>input</var>["<code>expects_no_vary_search</code>"].</p></li></ol>
   </li><li>
    <p>Return a <a href="#speculation-rule" id="speculation-rules-parsing:speculation-rule">speculation rule</a> with:</p>

    <dl class="props"><dt><a href="#sr-urls" id="speculation-rules-parsing:sr-urls">URLs</a></dt><dd><var>urls</var></dd><dt><a href="#sr-predicate" id="speculation-rules-parsing:sr-predicate">predicate</a></dt><dd><var>predicate</var></dd><dt><a href="#sr-eagerness" id="speculation-rules-parsing:sr-eagerness">eagerness</a></dt><dd><var>eagerness</var></dd><dt><a href="#sr-referrer-policy" id="speculation-rules-parsing:sr-referrer-policy">referrer policy</a></dt><dd><var>referrerPolicy</var></dd><dt><a href="#sr-tags" id="speculation-rules-parsing:sr-tags">tags</a></dt><dd><var>tags</var></dd><dt><a href="#sr-requirements" id="speculation-rules-parsing:sr-requirements">requirements</a></dt><dd><var>requirements</var></dd><dt><a href="#sr-nvs-hint" id="speculation-rules-parsing:sr-nvs-hint">No-Vary-Search hint</a></dt><dd><var>noVarySearchHint</var></dd></dl>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="parse-a-document-rule-predicate">parse a document rule predicate</dfn> given a value <var>input</var>, a
  <code id="speculation-rules-parsing:document-3"><a href="#document">Document</a></code> <var>document</var>, and a <a id="speculation-rules-parsing:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>:</p>

  <ol><li>
    <p>If <var>input</var> is not a <a href="https://infra.spec.whatwg.org/#ordered-map" id="speculation-rules-parsing:ordered-map-4" data-x-internal="ordered-map">map</a>:</p>

    <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-17" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
     document rule predicate was invalid.</p></li><li><p>Return null.</p></li></ol>
   </li><li>
    <p>If <var>input</var> does not <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-18" data-x-internal="map-exists">contain</a> exactly one of "<code>and</code>", "<code>or</code>", "<code>not</code>", "<code>href_matches</code>", or "<code>selector_matches</code>":</p>

    <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-18" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
     document rule predicate was empty or ambiguous.</p></li><li><p>Return null.</p></li></ol>
   </li><li><p>Let <var>predicateType</var> be the single key found in the previous step.</p></li><li>
    <p>If <var>predicateType</var> is "<code>and</code>" or "<code>or</code>":</p>

    <ol><li>
      <p>If <var>input</var> has any <a href="https://infra.spec.whatwg.org/#map-key" id="speculation-rules-parsing:map-key-2" data-x-internal="map-key">key</a> other than
      <var>predicateType</var>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-19" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       document rule predicate had unexpected extra options.</p></li><li><p>Return null.</p></li></ol>
     </li><li>
      <p>If <var>input</var>[<var>predicateType</var>] is not a <a id="speculation-rules-parsing:list-6" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>:</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-20" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       document rule predicate had an invalid clause list.</p></li><li><p>Return null.</p></li></ol>
     </li><li><p>Let <var>clauses</var> be an empty <a id="speculation-rules-parsing:list-7" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-parsing:list-iterate-5" data-x-internal="list-iterate">For each</a> <var>rawClause</var> of
      <var>input</var>[<var>predicateType</var>]:</p>

      <ol><li><p>Let <var>clause</var> be the result of <a href="#parse-a-document-rule-predicate" id="speculation-rules-parsing:parse-a-document-rule-predicate-2">parsing a document rule predicate</a> given <var>rawClause</var>,
       <var>document</var>, and <var>baseURL</var>.</p></li><li><p>If <var>clause</var> is null, then return null.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-parsing:list-append-4" data-x-internal="list-append">Append</a> <var>clause</var> to
       <var>clauses</var>.</p></li></ol>
     </li><li><p>If <var>predicateType</var> is "<code>and</code>", then return a
     <a href="#document-rule-conjunction" id="speculation-rules-parsing:document-rule-conjunction-2">document rule conjunction</a> whose <a href="#sr-dr-c-clauses" id="speculation-rules-parsing:sr-dr-c-clauses-2">clauses</a> is
     <var>clauses</var>.</p></li><li><p>Return a <a href="#document-rule-disjunction" id="speculation-rules-parsing:document-rule-disjunction">document rule disjunction</a> whose <a href="#sr-dr-d-clauses" id="speculation-rules-parsing:sr-dr-d-clauses">clauses</a> is <var>clauses</var>.</p></li></ol>
   </li><li>
    <p>If <var>predicateType</var> is "<code>not</code>":</p>

    <ol><li>
      <p>If <var>input</var> has any <a href="https://infra.spec.whatwg.org/#map-key" id="speculation-rules-parsing:map-key-3" data-x-internal="map-key">key</a> other than "<code>not</code>":</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-21" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       document rule predicate had unexpected extra options.</p></li><li><p>Return null.</p></li></ol>
     </li><li><p>Let <var>clause</var> be the result of <a href="#parse-a-document-rule-predicate" id="speculation-rules-parsing:parse-a-document-rule-predicate-3">parsing a document rule predicate</a> given
     <var>input</var>[<var>predicateType</var>], <var>document</var>, and
     <var>baseURL</var>.</p></li><li><p>If <var>clause</var> is null, then return null.</p></li><li><p>Return a <a href="#document-rule-negation" id="speculation-rules-parsing:document-rule-negation">document rule negation</a> whose <a href="#sr-dr-n-clause" id="speculation-rules-parsing:sr-dr-n-clause">clause</a> is <var>clause</var>.</p></li></ol>
   </li><li>
    <p>If <var>predicateType</var> is "<code>href_matches</code>":</p>

    <ol><li>
      <p>If <var>input</var> has any <a href="https://infra.spec.whatwg.org/#map-key" id="speculation-rules-parsing:map-key-4" data-x-internal="map-key">key</a> other than "<code>href_matches</code>" or "<code>relative_to</code>":</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-22" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       document rule predicate had unexpected extra options.</p></li><li><p>Return null.</p></li></ol>
     </li><li>
      <p>If <var>input</var>["<code>relative_to</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="speculation-rules-parsing:map-exists-19" data-x-internal="map-exists">exists</a>:</p>

      <ol><li>
        <p>If <var>input</var>["<code>relative_to</code>"] is neither "<code>ruleset</code>" nor "<code>document</code>":</p>

        <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-23" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
         supplied relative-to value was invalid.</p></li><li><p>Return null.</p></li></ol>
       </li><li><p>If <var>input</var>["<code>relative_to</code>"] is "<code>document</code>", then set <var>baseURL</var> to <var>document</var>'s
       <a href="#document-base-url" id="speculation-rules-parsing:document-base-url-2">document base URL</a>.</p></li></ol>
     </li><li><p>Let <var>rawPatterns</var> be <var>input</var>["<code>href_matches</code>"].</p></li><li><p>If <var>rawPatterns</var> is not a <a id="speculation-rules-parsing:list-8" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>, then set <var>rawPatterns</var> to
     « <var>rawPatterns</var> ».</p></li><li><p>Let <var>patterns</var> be an empty <a id="speculation-rules-parsing:list-9" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-parsing:list-iterate-6" data-x-internal="list-iterate">For each</a> <var>rawPattern</var> of
      <var>rawPatterns</var>:</p>

      <ol><li><p>Let <var>pattern</var> be the result of <a href="https://urlpattern.spec.whatwg.org/#build-a-url-pattern-from-an-infra-value" id="speculation-rules-parsing:build-a-url-pattern-from-an-infra-value" data-x-internal="build-a-url-pattern-from-an-infra-value">building a URL pattern from an Infra value</a> given <var>rawPattern</var>
       and <var>baseURL</var>. If this step throws an exception, catch the exception and set
       <var>pattern</var> to null.</p></li><li>
        <p>If <var>pattern</var> is null:</p>

        <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-24" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
         supplied URL pattern was invalid.</p></li><li><p>Return null.</p></li></ol>
       </li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-parsing:list-append-5" data-x-internal="list-append">Append</a> <var>pattern</var> to
       <var>patterns</var>.</p></li></ol>
     </li><li><p>Return a <a href="#document-rule-url-pattern-predicate" id="speculation-rules-parsing:document-rule-url-pattern-predicate">document rule URL pattern predicate</a> whose <a href="#sr-dr-urlpattern-patterns" id="speculation-rules-parsing:sr-dr-urlpattern-patterns">patterns</a> is <var>patterns</var>.</p></li></ol>
   </li><li>
    <p>If <var>predicateType</var> is "<code>selector_matches</code>":</p>

    <ol><li>
      <p>If <var>input</var> has any <a href="https://infra.spec.whatwg.org/#map-key" id="speculation-rules-parsing:map-key-5" data-x-internal="map-key">key</a> other than "<code>selector_matches</code>":</p>

      <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-25" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       document rule predicate had unexpected extra options.</p></li><li><p>Return null.</p></li></ol>
     </li><li><p>Let <var>rawSelectors</var> be <var>input</var>["<code>selector_matches</code>"].</p></li><li><p>If <var>rawSelectors</var> is not a <a id="speculation-rules-parsing:list-10" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>, then set <var>rawSelectors</var>
     to « <var>rawSelectors</var> ».</p></li><li><p>Let <var>selectors</var> be an empty <a id="speculation-rules-parsing:list-11" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-parsing:list-iterate-7" data-x-internal="list-iterate">For each</a> <var>rawSelector</var> of
      <var>rawSelectors</var>:</p>

      <ol><li><p>Let <var>parsedSelectorList</var> be failure.</p></li><li><p>If <var>rawSelector</var> is a string, then set <var>parsedSelectorList</var> to the
       result of <a href="https://drafts.csswg.org/selectors/#parse-a-selector" id="speculation-rules-parsing:parse-a-selector" data-x-internal="parse-a-selector">parsing a selector</a> given
       <var>rawSelector</var>.</p></li><li>
        <p>If <var>parsedSelectorList</var> is failure:</p>

        <ol><li><p>The user agent may <a id="speculation-rules-parsing:report-a-warning-to-the-console-26" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
         supplied selector list was invalid.</p></li><li><p>Return null.</p></li></ol>
       </li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-parsing:list-iterate-8" data-x-internal="list-iterate">For each</a> <var>selector</var> of
       <var>parsedSelectorList</var>, <a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-parsing:list-append-6" data-x-internal="list-append">append</a> <var>selector</var>
       to <var>selectors</var>.</p></li></ol>
     </li><li><p>Return a <a href="#document-rule-selector-predicate" id="speculation-rules-parsing:document-rule-selector-predicate">document rule selector predicate</a> whose <a href="#sr-dr-cssselector-selectors" id="speculation-rules-parsing:sr-dr-cssselector-selectors">selectors</a> is <var>selectors</var>.</p></li></ol>
   </li><li><p><a id="speculation-rules-parsing:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this step is never reached, as one of the previous branches was
   taken.</p></li></ol>
  </div>


  <h5 id="speculation-rules-processing-model"><span class="secno">7.6.1.3</span> Processing model<a href="#speculation-rules-processing-model" class="self-link"></a></h5>

  <p>A <dfn id="speculative-load-candidate">speculative load candidate</dfn> is a <a id="speculation-rules-processing-model:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-processing-model:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="sl-candidate-url">URL</dfn>, a <a id="speculation-rules-processing-model:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a></p></li><li><p><dfn id="sl-candidate-nvs-hint">No-Vary-Search hint</dfn>, a <a id="speculation-rules-processing-model:url-search-variance" href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-data-model" data-x-internal="url-search-variance">URL search
   variance</a></p></li><li><p><dfn id="sl-candidate-eagerness">eagerness</dfn>, a <a href="#speculation-rule-eagerness" id="speculation-rules-processing-model:speculation-rule-eagerness">speculation rule
   eagerness</a></p></li><li><p><dfn id="sl-candidate-referrer-policy">referrer policy</dfn>, a <a id="speculation-rules-processing-model:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer
   policy</a></p></li><li><p><dfn id="sl-candidate-tags">tags</dfn>, an <a href="https://infra.spec.whatwg.org/#ordered-set" id="speculation-rules-processing-model:set" data-x-internal="set">ordered set</a> of
   <a href="#speculation-rule-tag" id="speculation-rules-processing-model:speculation-rule-tag">speculation rule tags</a></p></li></ul>

  <p>A <dfn id="prefetch-candidate">prefetch candidate</dfn> is a <a href="#speculative-load-candidate" id="speculation-rules-processing-model:speculative-load-candidate">speculative load candidate</a> with the following
  additional <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-processing-model:struct-item-2" data-x-internal="struct-item">item</a>:</p>

  <ul><li><p><dfn id="sl-candidate-anonymization-policy">anonymization policy</dfn>, a
   <a href="#prefetch-ip-anonymization-policy" id="speculation-rules-processing-model:prefetch-ip-anonymization-policy">prefetch IP anonymization policy</a></p></li></ul>

  <p>A <dfn id="prefetch-ip-anonymization-policy">prefetch IP anonymization policy</dfn> is either null or a <a href="#cross-origin-prefetch-ip-anonymization-policy" id="speculation-rules-processing-model:cross-origin-prefetch-ip-anonymization-policy">cross-origin prefetch
  IP anonymization policy</a>.</p>

  <p>A <dfn id="cross-origin-prefetch-ip-anonymization-policy">cross-origin prefetch IP anonymization policy</dfn> is a <a id="speculation-rules-processing-model:struct-2" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> whose
  single <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-processing-model:struct-item-3" data-x-internal="struct-item">item</a> is its <dfn id="copiap-origin">origin</dfn>, an
  <a href="#concept-origin" id="speculation-rules-processing-model:concept-origin">origin</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>A <a href="#speculative-load-candidate" id="speculation-rules-processing-model:speculative-load-candidate-2">speculative load candidate</a> <var>candidateA</var> is <dfn id="sl-candidate-redundant-with">redundant with</dfn> another <a href="#speculative-load-candidate" id="speculation-rules-processing-model:speculative-load-candidate-3">speculative load
  candidate</a> <var>candidateB</var> if the following steps return true:</p>

  <ol><li><p>If <var>candidateA</var>'s <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint">No-Vary-Search hint</a>
   is not equal to <var>candidateB</var>'s <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-2">No-Vary-Search
   hint</a>, then return false.</p></li><li><p>If <var>candidateA</var>'s <a href="#sl-candidate-url" id="speculation-rules-processing-model:sl-candidate-url">URL</a> is not
   <a id="speculation-rules-processing-model:equivalent-modulo-search-variance" href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-comparing" data-x-internal="equivalent-modulo-search-variance">equivalent modulo search variance</a> to <var>candidateB</var>'s <a href="#sl-candidate-url" id="speculation-rules-processing-model:sl-candidate-url-2">URL</a> given <var>candidateA</var>'s <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-3">No-Vary-Search hint</a>, then return false.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div id="note-sl-candidate-redundant-with-nvs-strictness" class="note"><a href="#note-sl-candidate-redundant-with-nvs-strictness" class="self-link"></a>
   <p>The requirement that the <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-4">No-Vary-Search hints</a> be
   equivalent is somewhat strict. It means that some cases which could theoretically be treated as
   matching, are not treated as such. Thus, redundant speculative loads could happen.</p>

   <p>However, allowing more lenient matching makes the check no longer an equivalence relation, and
   producing such matches would require an implementation strategy that does a full comparison,
   instead of a simpler one using normalized URL keys. This is in line with the best practices for
   server operators, and attendant HTTP cache implementation notes, in <a href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#section-6"><cite>No
   Vary Search</cite> §&nbsp;6 Comparing</a>.</p>

   <p>In practice, we do not expect this to cause redundant speculative loads, since server
   operators and the corresponding speculation rules-writing web developers will follow best
   practices and use static `<code id="speculation-rules-processing-model:no-vary-search"><a data-x-internal="no-vary-search" href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-http-header-field-definitio">No-Vary-Search</a></code>` header values/speculation rule hints.</p>
  </div>

  <div id="example-sl-candidate-reundant-with-nvs-strictness" class="example" data-var-scope=""><a href="#example-sl-candidate-reundant-with-nvs-strictness" class="self-link"></a>
   <p>Consider three <a href="#speculative-load-candidate" id="speculation-rules-processing-model:speculative-load-candidate-4">speculative load
   candidates</a>:</p>

   <ol><li><p><var>A</var> has a <a href="#sl-candidate-url" id="speculation-rules-processing-model:sl-candidate-url-3">URL</a> of <code>https://example.com?a=1&amp;b=1</code> and a <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-5">No-Vary-Search hint</a> parsed from <code>params=("a")</code>.</p></li><li><p><var>B</var> has a <a href="#sl-candidate-url" id="speculation-rules-processing-model:sl-candidate-url-4">URL</a> of <code>https://example.com?a=2&amp;b=1</code> and a <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-6">No-Vary-Search hint</a> parsed from <code>params=("b")</code>.</p></li><li><p><var>C</var> has a <a href="#sl-candidate-url" id="speculation-rules-processing-model:sl-candidate-url-5">URL</a> of <code>https://example.com?a=2&amp;b=2</code> and a <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-7">No-Vary-Search hint</a> parsed from <code>params=("a")</code>.</p></li></ol>

   <p>With the current definition of <a href="#sl-candidate-redundant-with" id="speculation-rules-processing-model:sl-candidate-redundant-with">redundant
   with</a>, none of these candidates are redundant with each other. A <a href="#speculation-rule-set" id="speculation-rules-processing-model:speculation-rule-set">speculation rule
   set</a> which contained all three could cause three separate speculative loads.</p>

   <p>A definition which did not require equivalent <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-8">No-Vary-Search hints</a> could consider <var>A</var> and
   <var>B</var> to match (using <var>A</var>'s <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-9">No-Vary-Search
   hint</a>), and <var>B</var> and <var>C</var> to match (using <var>B</var>'s <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-10">No-Vary-Search hint</a>). But it could not consider
   <var>A</var> and <var>C</var> to match, so it would not be transitive, and thus not an
   equivalence relation.</p>
  </div>

  <hr>

  <p>Every <code id="speculation-rules-processing-model:document"><a href="#document">Document</a></code> has <dfn id="document-sr-sets">speculation rule sets</dfn>, a
  <a id="speculation-rules-processing-model:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#speculation-rule-set" id="speculation-rules-processing-model:speculation-rule-set-2">speculation rule sets</a>, initially
  empty.</p>

  <p>Every <code id="speculation-rules-processing-model:document-2"><a href="#document">Document</a></code> has a <dfn id="consider-speculative-loads-microtask-queued">consider speculative loads microtask queued</dfn>, a
  boolean, initially false.</p>

  <div data-algorithm="">
  <p>To <dfn id="consider-speculative-loads">consider speculative loads</dfn> for a <code id="speculation-rules-processing-model:document-3"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li id="step-consider-speculative-loads-top-level-only">
    <p>If <var>document</var>'s <a href="#node-navigable" id="speculation-rules-processing-model:node-navigable">node navigable</a> is not a <a href="#top-level-traversable" id="speculation-rules-processing-model:top-level-traversable">top-level
    traversable</a>, then return.</p>

    <p class="note">Supporting speculative loads into <a href="#child-navigable" id="speculation-rules-processing-model:child-navigable">child
    navigables</a> has some complexities and is not currently defined. It might be possible to
    define it in the future.</p>
   </li><li><p>If <var>document</var>'s <a href="#consider-speculative-loads-microtask-queued" id="speculation-rules-processing-model:consider-speculative-loads-microtask-queued">consider speculative loads microtask queued</a> is true,
   then return.</p></li><li><p>Set <var>document</var>'s <a href="#consider-speculative-loads-microtask-queued" id="speculation-rules-processing-model:consider-speculative-loads-microtask-queued-2">consider speculative loads microtask queued</a> to
   true.</p></li><li>
    <p><a href="#queue-a-microtask" id="speculation-rules-processing-model:queue-a-microtask">Queue a microtask</a> given <var>document</var> to run the following steps:</p>

    <ol><li><p>Set <var>document</var>'s <a href="#consider-speculative-loads-microtask-queued" id="speculation-rules-processing-model:consider-speculative-loads-microtask-queued-3">consider speculative loads microtask queued</a> to
     false.</p></li><li><p>Run the <a href="#inner-consider-speculative-loads-steps" id="speculation-rules-processing-model:inner-consider-speculative-loads-steps">inner consider speculative loads steps</a> for
     <var>document</var>.</p></li></ol>
   </li></ol>
  </div>

  <p>In addition to the call sites explicitly given in this standard:</p>

  <ul><li><p>When style recalculation would cause selector matching results to change, the user agent
   must <a href="#consider-speculative-loads" id="speculation-rules-processing-model:consider-speculative-loads">consider speculative loads</a> for the relevant <code id="speculation-rules-processing-model:document-4"><a href="#document">Document</a></code>.</p></li><li>
    <p>When the user indicates interest in <a href="#hyperlink" id="speculation-rules-processing-model:hyperlink">hyperlinks</a>, in one of the
    <a id="speculation-rules-processing-model:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> ways that the user agent uses to implement the
    <a href="#speculation-rule-eagerness" id="speculation-rules-processing-model:speculation-rule-eagerness-2">speculation rule eagerness</a> heuristics, the user agent may <a href="#consider-speculative-loads" id="speculation-rules-processing-model:consider-speculative-loads-2">consider
    speculative loads</a> for the hyperlink's <a id="speculation-rules-processing-model:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p>

    <p class="example">For example, a user agent which implements "<code id="speculation-rules-processing-model:sr-eagerness-conservative"><a href="#sr-eagerness-conservative">conservative</a></code>" eagerness by watching for <code id="speculation-rules-processing-model:event-pointerdown"><a data-x-internal="event-pointerdown" href="https://w3c.github.io/pointerevents/#the-pointerdown-event">pointerdown</a></code> events would want to <a href="#consider-speculative-loads" id="speculation-rules-processing-model:consider-speculative-loads-3">consider speculative
    loads</a> as part of reacting to such events.</p>
   </li></ul>

  <div id="note-consider-speculative-loads-stateless" class="note"><a href="#note-consider-speculative-loads-stateless" class="self-link"></a>
   <p>In this standard, every call to <a href="#consider-speculative-loads" id="speculation-rules-processing-model:consider-speculative-loads-4">consider speculative loads</a> is given just a
   <code id="speculation-rules-processing-model:document-5"><a href="#document">Document</a></code>, and the algorithm re-computes all possible candidates in a stateless way.
   A real implementation would likely cache previous computations, and pass along information from
   the call site to make updates more efficient. For example, if an <code id="speculation-rules-processing-model:the-a-element"><a href="#the-a-element">a</a></code> element's <code id="speculation-rules-processing-model:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute is changed, that specific element could be
   passed along in order to update only the related <a href="#speculative-load-candidate" id="speculation-rules-processing-model:speculative-load-candidate-5">speculative load candidate</a>.</p>

   <p>Note that because of how <a href="#consider-speculative-loads" id="speculation-rules-processing-model:consider-speculative-loads-5">consider speculative loads</a> queues a microtask, by the
   time the <a href="#inner-consider-speculative-loads-steps" id="speculation-rules-processing-model:inner-consider-speculative-loads-steps-2">inner consider speculative loads steps</a> are run, multiple updates (or <a href="#step-prefetch-record-cancel-and-discard">cancelations</a>) might be processed
   together.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="inner-consider-speculative-loads-steps">inner consider speculative loads steps</dfn> for a <code id="speculation-rules-processing-model:document-6"><a href="#document">Document</a></code>
  <var>document</var> are:</p>

  <ol><li><p>If <var>document</var> is not <a href="#fully-active" id="speculation-rules-processing-model:fully-active">fully active</a>, then return.</p></li><li><p>Let <var>prefetchCandidates</var> be an empty <a id="speculation-rules-processing-model:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate" data-x-internal="list-iterate">For each</a> <var>ruleSet</var> of <var>document</var>'s <a href="#document-sr-sets" id="speculation-rules-processing-model:document-sr-sets">speculation rule sets</a>:</p>

    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>rule</var> of <var>ruleSet</var>'s <a href="#sr-set-prefetch" id="speculation-rules-processing-model:sr-set-prefetch">prefetch rules</a>:</p>

      <ol><li><p>Let <var>anonymizationPolicy</var> be null.</p></li><li><p>If <var>rule</var>'s <a href="#sr-requirements" id="speculation-rules-processing-model:sr-requirements">requirements</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="speculation-rules-processing-model:list-contains" data-x-internal="list-contains">contains</a> "<code>anonymous-client-ip-when-cross-origin</code>", then set
       <var>anonymizationPolicy</var> to a <a href="#cross-origin-prefetch-ip-anonymization-policy" id="speculation-rules-processing-model:cross-origin-prefetch-ip-anonymization-policy-2">cross-origin prefetch IP anonymization
       policy</a> whose <a href="#copiap-origin" id="speculation-rules-processing-model:copiap-origin">origin</a> is <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="speculation-rules-processing-model:concept-document-origin" data-x-internal="concept-document-origin">origin</a>.</p></li><li>
        <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>url</var> of <var>rule</var>'s <a href="#sr-urls" id="speculation-rules-processing-model:sr-urls">URLs</a>:</p>

        <ol><li><p>Let <var>referrerPolicy</var> be the result of <a href="#compute-a-speculative-load-referrer-policy" id="speculation-rules-processing-model:compute-a-speculative-load-referrer-policy">computing a speculative load referrer policy</a> given
         <var>rule</var> and null.</p></li><li>
          <p><a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-processing-model:list-append" data-x-internal="list-append">Append</a> a new <a href="#prefetch-candidate" id="speculation-rules-processing-model:prefetch-candidate">prefetch candidate</a> with</p>

          <dl class="props"><dt><a href="#sl-candidate-url" id="speculation-rules-processing-model:sl-candidate-url-6">URL</a></dt><dd><var>url</var></dd><dt><a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-11">No-Vary-Search hint</a></dt><dd><var>rule</var>'s <a href="#sr-nvs-hint" id="speculation-rules-processing-model:sr-nvs-hint">No-Vary-Search hint</a></dd><dt><a href="#sl-candidate-eagerness" id="speculation-rules-processing-model:sl-candidate-eagerness">eagerness</a></dt><dd><var>rule</var>'s <a href="#sr-eagerness" id="speculation-rules-processing-model:sr-eagerness">eagerness</a></dd><dt><a href="#sl-candidate-referrer-policy" id="speculation-rules-processing-model:sl-candidate-referrer-policy">referrer policy</a></dt><dd><var>referrerPolicy</var></dd><dt><a href="#sl-candidate-tags" id="speculation-rules-processing-model:sl-candidate-tags">tags</a></dt><dd><var>rule</var>'s <a href="#sr-tags" id="speculation-rules-processing-model:sr-tags">tags</a></dd><dt><a href="#sl-candidate-anonymization-policy" id="speculation-rules-processing-model:sl-candidate-anonymization-policy">anonymization policy</a></dt><dd><var>anonymizationPolicy</var></dd></dl>

          <p>to <var>prefetchCandidates</var>.</p>
         </li></ol>
       </li><li>
        <p>If <var>rule</var>'s <a href="#sr-predicate" id="speculation-rules-processing-model:sr-predicate">predicate</a> is not null:</p>

        <ol><li><p>Let <var>links</var> be the result of <a href="#find-matching-links" id="speculation-rules-processing-model:find-matching-links">finding
         matching links</a> given <var>document</var> and <var>rule</var>'s <a href="#sr-predicate" id="speculation-rules-processing-model:sr-predicate-2">predicate</a>.</p></li><li>
          <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-4" data-x-internal="list-iterate">For each</a> <var>link</var> of <var>links</var>:</p>

          <ol><li><p>Let <var>referrerPolicy</var> be the result of <a href="#compute-a-speculative-load-referrer-policy" id="speculation-rules-processing-model:compute-a-speculative-load-referrer-policy-2">computing a speculative load referrer policy</a> given
           <var>rule</var> and <var>link</var>.</p></li><li>
            <p><a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-processing-model:list-append-2" data-x-internal="list-append">Append</a> a new <a href="#prefetch-candidate" id="speculation-rules-processing-model:prefetch-candidate-2">prefetch candidate</a>
            with</p>

            <dl class="props"><dt><a href="#sl-candidate-url" id="speculation-rules-processing-model:sl-candidate-url-7">URL</a></dt><dd><var>link</var>'s <a href="#concept-hyperlink-url" id="speculation-rules-processing-model:concept-hyperlink-url">url</a></dd><dt><a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-12">No-Vary-Search hint</a></dt><dd><var>rule</var>'s <a href="#sr-nvs-hint" id="speculation-rules-processing-model:sr-nvs-hint-2">No-Vary-Search hint</a></dd><dt><a href="#sl-candidate-eagerness" id="speculation-rules-processing-model:sl-candidate-eagerness-2">eagerness</a></dt><dd><var>rule</var>'s <a href="#sr-eagerness" id="speculation-rules-processing-model:sr-eagerness-2">eagerness</a></dd><dt><a href="#sl-candidate-referrer-policy" id="speculation-rules-processing-model:sl-candidate-referrer-policy-2">referrer policy</a></dt><dd><var>referrerPolicy</var></dd><dt><a href="#sl-candidate-tags" id="speculation-rules-processing-model:sl-candidate-tags-2">tags</a></dt><dd><var>rule</var>'s <a href="#sr-tags" id="speculation-rules-processing-model:sr-tags-2">tags</a></dd><dt><a href="#sl-candidate-anonymization-policy" id="speculation-rules-processing-model:sl-candidate-anonymization-policy-2">anonymization policy</a></dt><dd><var>anonymizationPolicy</var></dd></dl>

            <p>to <var>prefetchCandidates</var>.</p>
           </li></ol>
         </li></ol>
       </li></ol>
     </li></ol>
   </li><li id="step-prefetch-record-cancel-and-discard">
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-5" data-x-internal="list-iterate">For each</a> <var>prefetchRecord</var> of
    <var>document</var>'s <a href="https://wicg.github.io/nav-speculation/prefetch.html#document-prefetch-records" id="speculation-rules-processing-model:document-prefetch-records" data-x-internal="document-prefetch-records">prefetch records</a>:</p>

    <ol><li><p>If <var>prefetchRecord</var>'s <a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-source" id="speculation-rules-processing-model:prefetch-record-source" data-x-internal="prefetch-record-source">source</a> is
     not "<code>speculation rules</code>", then <a id="speculation-rules-processing-model:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p><a id="speculation-rules-processing-model:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>prefetchRecord</var>'s <a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-state" id="speculation-rules-processing-model:prefetch-record-state" data-x-internal="prefetch-record-state">state</a> is not "<code>canceled</code>".</p></li><li><p>If <var>prefetchRecord</var> is not <a id="speculation-rules-processing-model:still-being-speculated" href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-still-being-speculated" data-x-internal="still-being-speculated">still being speculated</a> given
     <var>prefetchCandidates</var>, then <a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-cancel-and-discard" id="speculation-rules-processing-model:prefetch-record-cancel-and-discard" data-x-internal="prefetch-record-cancel-and-discard">cancel
     and discard</a> <var>prefetchRecord</var> given <var>document</var>.</p></li></ol>
   </li><li><p>Let <var>prefetchCandidateGroups</var> be an empty <a id="speculation-rules-processing-model:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-6" data-x-internal="list-iterate">For each</a> <var>candidate</var> of
    <var>prefetchCandidates</var>:</p>

    <ol><li><p>Let <var>group</var> be « <var>candidate</var> ».</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-extend" id="speculation-rules-processing-model:list-extend" data-x-internal="list-extend">Extend</a> <var>group</var> with all <a href="https://infra.spec.whatwg.org/#list-item" id="speculation-rules-processing-model:list-item" data-x-internal="list-item">items</a> in <var>prefetchCandidates</var>, apart from <var>candidate</var> itself,
     which are <a href="#sl-candidate-redundant-with" id="speculation-rules-processing-model:sl-candidate-redundant-with-2">redundant with</a> <var>candidate</var>
     and whose <a href="#sl-candidate-eagerness" id="speculation-rules-processing-model:sl-candidate-eagerness-3">eagerness</a> is <a href="#sr-eagerness-at-least-as-eager" id="speculation-rules-processing-model:sr-eagerness-at-least-as-eager">at least as eager</a> as <var>candidate</var>'s
     <a href="#sl-candidate-eagerness" id="speculation-rules-processing-model:sl-candidate-eagerness-4">eagerness</a>.</p></li><li><p>If <var>prefetchCandidateGroups</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="speculation-rules-processing-model:list-contains-2" data-x-internal="list-contains">contains</a>
     another group whose <a href="https://infra.spec.whatwg.org/#list-item" id="speculation-rules-processing-model:list-item-2" data-x-internal="list-item">items</a> are the same as <var>group</var>,
     ignoring order, then <a id="speculation-rules-processing-model:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-processing-model:list-append-3" data-x-internal="list-append">Append</a> <var>group</var> to
     <var>prefetchCandidateGroups</var>.</p></li></ol>

    <div id="example-redundant-speculation-rules" class="example"><a href="#example-redundant-speculation-rules" class="self-link"></a>
     <p>The following speculation rules generate two <a href="#sl-candidate-redundant-with" id="speculation-rules-processing-model:sl-candidate-redundant-with-3">redundant</a> <a href="#prefetch-candidate" id="speculation-rules-processing-model:prefetch-candidate-3">prefetch candidates</a>:</p>

     <pre><code class="json"><c- p="">{</c->
  <c- u="">"prefetch"</c-><c- o="">:</c-> <c- p="">[</c->
    <c- p="">{</c->
      <c- u="">"tag"</c-><c- o="">:</c-> <c- u="">"a"</c-><c- p="">,</c->
      <c- u="">"urls"</c-><c- o="">:</c-> <c- p="">[</c-><c- u="">"next.html"</c-><c- p="">]</c->
    <c- p="">},</c->
    <c- p="">{</c->
      <c- u="">"tag"</c-><c- o="">:</c-> <c- u="">"b"</c-><c- p="">,</c->
      <c- u="">"urls"</c-><c- o="">:</c-> <c- p="">[</c-><c- u="">"next.html"</c-><c- p="">],</c->
      <c- u="">"referrer_policy"</c-><c- o="">:</c-> <c- u="">"no-referrer"</c->
    <c- p="">}</c->
  <c- p="">]</c->
<c- p="">}</c-></code></pre>

     <p>This step will create a single group containing them both, in the given order. (The second
     pass through will not create a group, since its contents would be the same as the first group,
     just in a different order.) This means that if the user agent chooses to execute the "may" step
     below to enact the group, it will enact the first candidate, and ignore the second. Thus, the
     request will be made with the <a id="speculation-rules-processing-model:default-referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#default-referrer-policy" data-x-internal="default-referrer-policy">default referrer policy</a>, instead of using "<code id="speculation-rules-processing-model:referrer-policy-no-referrer"><a data-x-internal="referrer-policy-no-referrer" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer">no-referrer</a></code>".</p>

     <p>However, the <a href="#collect-tags-from-speculative-load-candidates" id="speculation-rules-processing-model:collect-tags-from-speculative-load-candidates">collect tags from speculative load candidates</a> algorithm will
     collect tags from both candidates in the group, so the `<code id="speculation-rules-processing-model:sec-speculation-tags"><a href="#sec-speculation-tags">Sec-Speculation-Tags</a></code>`
     header value will be `<code>"a", "b"</code>`. This indicates to server operators that
     either rule could have caused the speculative load.</p>
    </div>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-7" data-x-internal="list-iterate">For each</a> <var>group</var> of
    <var>prefetchCandidateGroups</var>:</p>

    <ol><li>
      <p>The user agent may run the following steps:</p>

      <ol><li><p>Let <var>prefetchCandidate</var> be <var>group</var>[0].</p></li><li><p>Let <var>tagsToSend</var> be the result of <a href="#collect-tags-from-speculative-load-candidates" id="speculation-rules-processing-model:collect-tags-from-speculative-load-candidates-2">collecting tags from speculative load candidates</a> given
       <var>group</var>.</p></li><li>
        <p>Let <var>prefetchRecord</var> be a new <a id="speculation-rules-processing-model:prefetch-record" href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record" data-x-internal="prefetch-record">prefetch record</a> with</p>

        <dl class="props"><dt><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-source" id="speculation-rules-processing-model:prefetch-record-source-2" data-x-internal="prefetch-record-source">source</a></dt><dd>"<code>speculation rules</code>"</dd><dt><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-url" id="speculation-rules-processing-model:prefetch-record-url" data-x-internal="prefetch-record-url">URL</a></dt><dd><var>prefetchCandidate</var>'s <a href="#sl-candidate-url" id="speculation-rules-processing-model:sl-candidate-url-8">URL</a></dd><dt><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-no-vary-search-hint" id="speculation-rules-processing-model:prefetch-record-nvs-hint" data-x-internal="prefetch-record-nvs-hint">No-Vary-Search hint</a></dt><dd><var>prefetchCandidate</var>'s <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-13">No-Vary-Search
         hint</a></dd><dt><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-referrer-policy" id="speculation-rules-processing-model:prefetch-record-referrer-policy" data-x-internal="prefetch-record-referrer-policy">referrer policy</a></dt><dd><var>prefetchCandidate</var>'s <a href="#sl-candidate-referrer-policy" id="speculation-rules-processing-model:sl-candidate-referrer-policy-3">referrer
         policy</a></dd><dt><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-anonymization-policy" id="speculation-rules-processing-model:prefetch-record-anonymization-policy" data-x-internal="prefetch-record-anonymization-policy">anonymization policy</a></dt><dd><var>prefetchCandidate</var>'s <a href="#sl-candidate-anonymization-policy" id="speculation-rules-processing-model:sl-candidate-anonymization-policy-3">anonymization policy</a></dd><dt><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-tags" id="speculation-rules-processing-model:prefetch-record-tags" data-x-internal="prefetch-record-tags">tags</a> </dt><dd><var>tagsToSend</var></dd></dl>
       </li><li><p><a id="speculation-rules-processing-model:start-a-referrer-initiated-navigational-prefetch" href="https://wicg.github.io/nav-speculation/prefetch.html#start-a-referrer-initiated-navigational-prefetch" data-x-internal="start-a-referrer-initiated-navigational-prefetch">Start a referrer-initiated navigational prefetch</a> given
       <var>prefetchRecord</var> and <var>document</var>.</p></li></ol>

      <p>When deciding whether to execute this "may" step, user agents should consider
      <var>prefetchCandidate</var>'s <a href="#sl-candidate-eagerness" id="speculation-rules-processing-model:sl-candidate-eagerness-5">eagerness</a>, in
      accordance to the current behavior of the user and the definitions of <a href="#speculation-rule-eagerness" id="speculation-rules-processing-model:speculation-rule-eagerness-3">speculation rule
      eagerness</a>.</p>

      <p><var>prefetchCandidate</var>'s <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-14">No-Vary-Search
      hint</a> can also be useful in implementing the heuristics defined for the
      <a href="#speculation-rule-eagerness" id="speculation-rules-processing-model:speculation-rule-eagerness-4">speculation rule eagerness</a> values. For example, a user hovering of a link whose
      <a href="#concept-hyperlink-url" id="speculation-rules-processing-model:concept-hyperlink-url-2">URL</a> is <a id="speculation-rules-processing-model:equivalent-modulo-search-variance-2" href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html#name-comparing" data-x-internal="equivalent-modulo-search-variance">equivalent modulo search
      variance</a> to <var>prefetchCandidate</var>'s <a href="#sl-candidate-url" id="speculation-rules-processing-model:sl-candidate-url-9">URL</a>
      given <var>prefetchCandidate</var>'s <a href="#sl-candidate-nvs-hint" id="speculation-rules-processing-model:sl-candidate-nvs-hint-15">No-Vary-Search
      hint</a> could indicate to the user agent that performing this step would be useful.</p>

      <p>When deciding whether to execute this "may" step, user agents should prioritize user
      preferences (express or implied, such as data-saver or battery-saver modes) over the eagerness
      supplied by the web developer.</p>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="compute-a-speculative-load-referrer-policy">compute a speculative load referrer policy</dfn> given a <a href="#speculation-rule" id="speculation-rules-processing-model:speculation-rule">speculation rule</a>
  <var>rule</var> and an <code id="speculation-rules-processing-model:the-a-element-2"><a href="#the-a-element">a</a></code> element, <code id="speculation-rules-processing-model:the-area-element"><a href="#the-area-element">area</a></code> element, or null
  <var>link</var>:</p>

  <ol><li><p>If <var>rule</var>'s <a href="#sr-referrer-policy" id="speculation-rules-processing-model:sr-referrer-policy">referrer policy</a> is not the
   empty string, then return <var>rule</var>'s <a href="#sr-referrer-policy" id="speculation-rules-processing-model:sr-referrer-policy-2">referrer
   policy</a>.</p></li><li><p>If <var>link</var> is null, then return the empty string.</p></li><li><p>Return <var>link</var>'s <a href="#hyperlink-referrer-policy" id="speculation-rules-processing-model:hyperlink-referrer-policy">hyperlink referrer policy</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="collect-tags-from-speculative-load-candidates">collect tags from speculative load candidates</dfn> given a <a id="speculation-rules-processing-model:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="#speculative-load-candidate" id="speculation-rules-processing-model:speculative-load-candidate-6">speculative load candidates</a> <var>candidates</var>:</p>

  <ol><li><p>Let <var>tags</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-set" id="speculation-rules-processing-model:set-2" data-x-internal="set">ordered set</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-8" data-x-internal="list-iterate">For each</a> <var>candidate</var> of
    <var>candidates</var>:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-9" data-x-internal="list-iterate">For each</a> <var>tag</var> of <var>candidate</var>'s
     <a href="#sl-candidate-tags" id="speculation-rules-processing-model:sl-candidate-tags-3">tags</a>: <a href="https://infra.spec.whatwg.org/#set-append" id="speculation-rules-processing-model:set-append" data-x-internal="set-append">append</a>
     <var>tag</var> to <var>tags</var>.</p></li></ol>
   </li><li><p><a href="https://infra.spec.whatwg.org/#list-sort-in-ascending-order" id="speculation-rules-processing-model:list-sort" data-x-internal="list-sort">Sort in ascending order</a> <var>tags</var>, with
   <var>tagA</var> being less than <var>tagB</var> if <var>tagA</var> is null, or if <var>tagA</var>
   is <a id="speculation-rules-processing-model:code-unit-less-than" href="https://infra.spec.whatwg.org/#code-unit-less-than" data-x-internal="code-unit-less-than">code unit less than</a> <var>tagB</var>.</p></li><li><p>Return <var>tags</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="find-matching-links">find matching links</dfn> given a <code id="speculation-rules-processing-model:document-7"><a href="#document">Document</a></code> <var>document</var> and a
  <a href="#document-rule-predicate" id="speculation-rules-processing-model:document-rule-predicate">document rule predicate</a> <var>predicate</var>:</p>

  <ol><li><p>Let <var>links</var> be an empty <a id="speculation-rules-processing-model:list-5" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-10" data-x-internal="list-iterate">For each</a> <a id="speculation-rules-processing-model:shadow-including-descendant" href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant" data-x-internal="shadow-including-descendant">shadow-including descendant</a>
    <var>descendant</var> of <var>document</var>, in <a id="speculation-rules-processing-model:shadow-including-tree-order" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including tree order</a>:</p>

    <ol><li><p>If <var>descendant</var> is not an <code id="speculation-rules-processing-model:the-a-element-3"><a href="#the-a-element">a</a></code> or <code id="speculation-rules-processing-model:the-area-element-2"><a href="#the-area-element">area</a></code> element with an
     <code id="speculation-rules-processing-model:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code> attribute, then <a id="speculation-rules-processing-model:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li>
      <p>If <var>descendant</var> is not <a href="#being-rendered" id="speculation-rules-processing-model:being-rendered">being rendered</a> or is part of <a href="https://drafts.csswg.org/css-contain/#skips-its-contents" id="speculation-rules-processing-model:skips-its-contents" data-x-internal="skips-its-contents">skipped contents</a>, then <a id="speculation-rules-processing-model:continue-4" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p>

      <p class="note">Such links, though present in <var>document</var>, aren't available for the
      user to interact with, and thus are unlikely to be good candidates. In addition, they might
      not have their style or layout computed, which might make selector matching less efficient in
      user agents which skip some or all of that work for these elements.</p>
     </li><li><p>If <var>descendant</var>'s <a href="#concept-hyperlink-url" id="speculation-rules-processing-model:concept-hyperlink-url-3">url</a> is null, or
     its <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="speculation-rules-processing-model:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is not an <a id="speculation-rules-processing-model:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>, then
     <a id="speculation-rules-processing-model:continue-5" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>predicate</var> <a href="#dr-predicate-matches" id="speculation-rules-processing-model:dr-predicate-matches">matches</a>
     <var>descendant</var>, then <a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-processing-model:list-append-4" data-x-internal="list-append">append</a> <var>descendant</var> to
     <var>links</var>.</p></li></ol>
   </li><li><p>Return <var>links</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <a href="#document-rule-predicate" id="speculation-rules-processing-model:document-rule-predicate-2">document rule predicate</a> <var>predicate</var> <dfn id="dr-predicate-matches">matches</dfn> an <code id="speculation-rules-processing-model:the-a-element-4"><a href="#the-a-element">a</a></code> or <code id="speculation-rules-processing-model:the-area-element-3"><a href="#the-area-element">area</a></code> element
  <var>el</var> if the following steps return true, switching on <var>predicate</var>'s type:</p>

  <dl class="switch"><dt><a href="#document-rule-conjunction" id="speculation-rules-processing-model:document-rule-conjunction">document rule conjunction</a></dt><dd>
    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-11" data-x-internal="list-iterate">For each</a> <var>clause</var> of <var>predicate</var>'s
      <a href="#sr-dr-c-clauses" id="speculation-rules-processing-model:sr-dr-c-clauses">clauses</a>:</p>

      <ol><li><p>If <var>clause</var> does not <a href="#dr-predicate-matches" id="speculation-rules-processing-model:dr-predicate-matches-2">match</a>
       <var>el</var>, then return false.</p></li></ol>
     </li><li><p>Return true.</p></li></ol>
   </dd><dt><a href="#document-rule-disjunction" id="speculation-rules-processing-model:document-rule-disjunction">document rule disjunction</a></dt><dd>
    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-12" data-x-internal="list-iterate">For each</a> <var>clause</var> of <var>predicate</var>'s
      <a href="#sr-dr-d-clauses" id="speculation-rules-processing-model:sr-dr-d-clauses">clauses</a>:</p>

      <ol><li><p>If <var>clause</var> <a href="#dr-predicate-matches" id="speculation-rules-processing-model:dr-predicate-matches-3">matches</a> <var>el</var>,
       then return true.</p></li></ol>
     </li><li><p>Return false.</p></li></ol>
   </dd><dt><a href="#document-rule-negation" id="speculation-rules-processing-model:document-rule-negation">document rule negation</a></dt><dd>
    <ol><li><p>If <var>predicate</var>'s <a href="#sr-dr-n-clause" id="speculation-rules-processing-model:sr-dr-n-clause">clause</a> <a href="#dr-predicate-matches" id="speculation-rules-processing-model:dr-predicate-matches-4">matches</a> <var>el</var>, then return false.</p></li><li><p>Return true.</p></li></ol>
   </dd><dt><a href="#document-rule-url-pattern-predicate" id="speculation-rules-processing-model:document-rule-url-pattern-predicate">document rule URL pattern predicate</a></dt><dd>
    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-13" data-x-internal="list-iterate">For each</a> <var>pattern</var> of <var>predicate</var>'s
      <a href="#sr-dr-urlpattern-patterns" id="speculation-rules-processing-model:sr-dr-urlpattern-patterns">patterns</a>:</p>

      <ol><li><p>If performing a <a href="https://urlpattern.spec.whatwg.org/#url-pattern-match" id="speculation-rules-processing-model:url-pattern-match" data-x-internal="url-pattern-match">match</a> given <var>pattern</var>
       and <var>el</var>'s <a href="#concept-hyperlink-url" id="speculation-rules-processing-model:concept-hyperlink-url-4">url</a> gives a non-null value,
       then return true.</p></li></ol>
     </li><li><p>Return false.</p></li></ol>
   </dd><dt><a href="#document-rule-selector-predicate" id="speculation-rules-processing-model:document-rule-selector-predicate">document rule selector predicate</a></dt><dd>
    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="speculation-rules-processing-model:list-iterate-14" data-x-internal="list-iterate">For each</a> <var>selector</var> of <var>predicate</var>'s
      <a href="#sr-dr-cssselector-selectors" id="speculation-rules-processing-model:sr-dr-cssselector-selectors">selectors</a>:</p>

      <ol><li><p>If performing a <a href="https://drafts.csswg.org/selectors/#match-a-selector-against-an-element" id="speculation-rules-processing-model:match-a-selector-against-an-element" data-x-internal="match-a-selector-against-an-element">match</a> given
       <var>selector</var> and <var>el</var> with the <a id="speculation-rules-processing-model:scoping-root" href="https://drafts.csswg.org/selectors/#scoping-root" data-x-internal="scoping-root">scoping root</a> set to
       <var>el</var>'s <a id="speculation-rules-processing-model:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a> returns success, then return true.</p></li></ol>
     </li><li><p>Return false.</p></li></ol>
   </dd></dl>
  </div>

  <hr>

  <p>Speculation rules features use the <dfn id="speculation-rules-task-source">speculation rules task source</dfn>, which is a
  <a href="#task-source" id="speculation-rules-processing-model:task-source">task source</a>.</p>

  <p class="note">Because speculative loading is generally less important than processing tasks for
  the purpose of the current document, implementations might give <a href="#concept-task" id="speculation-rules-processing-model:concept-task">tasks</a> enqueued here an especially low priority.</p>

  <h4 id="navigational-prefetching"><span class="secno">7.6.2</span> Navigational prefetching<a href="#navigational-prefetching" class="self-link"></a></h4>

  <p>For now, the navigational prefetching process is defined in the <cite>Prefetch</cite>
  specification. Moving it into this standard is tracked in <a href="https://github.com/whatwg/html/issues/11123">issue #11123</a>. <a href="#refsPREFETCH">[PREFETCH]</a></p>

  <p>This standard refers to the following concepts defined there:</p>

  <ul class="brief"><li><dfn id="prefetch-record"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record">prefetch
   record</a></dfn>, and its items <dfn id="prefetch-record-source"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-source">source</a></dfn>,
   <dfn id="prefetch-record-url"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-url">URL</a></dfn>,
   <dfn id="prefetch-record-nvs-hint"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-no-vary-search-hint">No-Vary-Search
   hint</a></dfn>, <dfn id="prefetch-record-referrer-policy"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-referrer-policy">referrer
   policy</a></dfn>, <dfn id="prefetch-record-anonymization-policy"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-anonymization-policy">anonymization
   policy</a></dfn>, <dfn id="prefetch-record-tags"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-tags">tags</a></dfn>,
   and <dfn id="prefetch-record-state"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-state">state</a></dfn></li><li><dfn id="prefetch-record-cancel-and-discard"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-cancel-and-discard">cancel
   and discard</a></dfn></li><li><dfn id="still-being-speculated"><a href="https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record-still-being-speculated">still
   being speculated</a></dfn></li><li><dfn id="document-prefetch-records"><a href="https://wicg.github.io/nav-speculation/prefetch.html#document-prefetch-records">prefetch
   records</a></dfn></li><li><dfn id="start-a-referrer-initiated-navigational-prefetch"><a href="https://wicg.github.io/nav-speculation/prefetch.html#start-a-referrer-initiated-navigational-prefetch">start
   a referrer-initiated navigational prefetch</a></dfn></li></ul>

  <h4 id="the-speculation-rules-header"><span class="secno">7.6.3</span> The `<code id="the-speculation-rules-header:speculation-rules-2"><a href="#speculation-rules-2">Speculation-Rules</a></code>` header<a href="#the-speculation-rules-header" class="self-link"></a></h4>

  <p>The `<dfn id="speculation-rules-2" data-dfn-type="http-header"><code>Speculation-Rules</code></dfn>` HTTP response header allows the
  developer to request that the user agent fetch and apply a given <a href="#speculation-rule-set" id="the-speculation-rules-header:speculation-rule-set">speculation rule set</a>
  to the current <code id="the-speculation-rules-header:document"><a href="#document">Document</a></code>. It is a <a href="https://httpwg.org/specs/rfc8941.html" id="the-speculation-rules-header:http-structured-header" data-x-internal="http-structured-header">structured
  header</a> whose value must be a <a href="https://httpwg.org/specs/rfc8941.html#list" id="the-speculation-rules-header:http-structured-header-list" data-x-internal="http-structured-header-list">list</a> of
  <a href="https://httpwg.org/specs/rfc8941.html#string" id="the-speculation-rules-header:http-structured-header-string" data-x-internal="http-structured-header-string">strings</a> that are all <a href="https://url.spec.whatwg.org/#valid-url-string" id="the-speculation-rules-header:valid-url-string" data-x-internal="valid-url-string">valid URL strings</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="process-the-speculation-rules-header">process the `<code>Speculation-Rules</code>` header</dfn> given a <code id="the-speculation-rules-header:document-2"><a href="#document">Document</a></code>
  <var>document</var> and a <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-speculation-rules-header:concept-response" data-x-internal="concept-response">response</a> <var>response</var>:</p>

  <ol><li><p>Let <var>parsedList</var> be the result of <a id="the-speculation-rules-header:getting-a-structured-field-value" href="https://fetch.spec.whatwg.org/#concept-header-list-get-structured-header" data-x-internal="getting-a-structured-field-value">getting a structured field value</a>
   given `<code id="the-speculation-rules-header:speculation-rules-2-2"><a href="#speculation-rules-2">Speculation-Rules</a></code>` and "<code>list</code>" from
   <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="the-speculation-rules-header:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a>.</p></li><li><p>If <var>parsedList</var> is null, then return.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-speculation-rules-header:list-iterate" data-x-internal="list-iterate">For each</a> <var>item</var> of <var>parsedList</var>:</p>

    <ol><li><p>If <var>item</var> is not a <a id="the-speculation-rules-header:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a>, then <a id="the-speculation-rules-header:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>url</var> be the result of <a href="https://url.spec.whatwg.org/#concept-url-parser" id="the-speculation-rules-header:url-parser" data-x-internal="url-parser">URL parsing</a>
     <var>item</var> with <var>document</var>'s <a href="#document-base-url" id="the-speculation-rules-header:document-base-url">document base URL</a>.</p></li><li><p>If <var>url</var> is failure, then <a id="the-speculation-rules-header:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li>
      <p><a href="#in-parallel" id="the-speculation-rules-header:in-parallel">In parallel</a>:</p>

      <ol><li>
        <p>Optionally, wait for an <a id="the-speculation-rules-header:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> amount of time.</p>

        <p class="note">This allows the implementation to prioritize other work ahead of loading
        speculation rules, as especially during <code id="the-speculation-rules-header:document-3"><a href="#document">Document</a></code> creation and header
        processing, there are often many more important things going on.</p>
       </li><li>
        <p><a href="#queue-a-global-task" id="the-speculation-rules-header:queue-a-global-task">Queue a global task</a> on the <a href="#speculation-rules-task-source" id="the-speculation-rules-header:speculation-rules-task-source">speculation rules task source</a> given
        <var>document</var>'s <a href="#concept-relevant-global" id="the-speculation-rules-header:concept-relevant-global">relevant global object</a> to perform the following
        steps:</p>

        <ol><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="the-speculation-rules-header:concept-request" data-x-internal="concept-request">request</a> whose
         <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="the-speculation-rules-header:concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>url</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="the-speculation-rules-header:concept-request-destination" data-x-internal="concept-request-destination">destination</a> is "<code>speculationrules</code>", and <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="the-speculation-rules-header:concept-request-mode" data-x-internal="concept-request-mode">mode</a> is
         "<code>cors</code>".</p></li><li>
          <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-speculation-rules-header:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var> with the following <i id="the-speculation-rules-header:processresponseconsumebody"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> steps given <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-speculation-rules-header:concept-response-2" data-x-internal="concept-response">response</a> <var>response</var> and null, failure, or a
          <a id="the-speculation-rules-header:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bodyBytes</var>:</p>

          <ol><li><p>If <var>bodyBytes</var> is null or failure, then abort these steps.</p></li><li><p>If <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="the-speculation-rules-header:concept-response-status" data-x-internal="concept-response-status">status</a> is
           not an <a id="the-speculation-rules-header:ok-status" href="https://fetch.spec.whatwg.org/#ok-status" data-x-internal="ok-status">ok status</a>, then abort these steps.</p></li><li><p>If the result of <a href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type" id="the-speculation-rules-header:extract-a-mime-type" data-x-internal="extract-a-mime-type">extracting a MIME type</a>
           from <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="the-speculation-rules-header:concept-response-header-list-2" data-x-internal="concept-response-header-list">header list</a>
           does not have an <a href="https://mimesniff.spec.whatwg.org/#mime-type-essence" id="the-speculation-rules-header:mime-type-essence" data-x-internal="mime-type-essence">essence</a> of
           "<code id="the-speculation-rules-header:application/speculationrules+json"><a href="#application/speculationrules+json">application/speculationrules+json</a></code>", then abort these steps.</p></li><li><p>Let <var>bodyText</var> be the result of <a href="https://encoding.spec.whatwg.org/#utf-8-decode" id="the-speculation-rules-header:utf-8-decode" data-x-internal="utf-8-decode">UTF-8
           decoding</a> <var>bodyBytes</var>.</p></li><li><p>Let <var>ruleSet</var> be the result of <a href="#parse-a-speculation-rule-set-string" id="the-speculation-rules-header:parse-a-speculation-rule-set-string">parsing a speculation rule set string</a> given <var>bodyText</var>,
           <var>document</var>, and <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="the-speculation-rules-header:concept-response-url" data-x-internal="concept-response-url">URL</a>. If this throws an exception, then abort these
           steps.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="the-speculation-rules-header:list-append" data-x-internal="list-append">Append</a> <var>ruleSet</var> to
           <var>document</var>'s <a href="#document-sr-sets" id="the-speculation-rules-header:document-sr-sets">speculation rule
           sets</a>.</p></li><li><p><a href="#consider-speculative-loads" id="the-speculation-rules-header:consider-speculative-loads">Consider speculative loads</a> for <var>document</var>.</p></li></ol>
         </li></ol>
       </li></ol>
     </li></ol>
   </li></ol>
  </div>


  <h4 id="the-sec-speculation-tags-header"><span class="secno">7.6.4</span> The `<code id="the-sec-speculation-tags-header:sec-speculation-tags"><a href="#sec-speculation-tags">Sec-Speculation-Tags</a></code>` header<a href="#the-sec-speculation-tags-header" class="self-link"></a></h4>

  <p>The `<dfn id="sec-speculation-tags" data-dfn-type="http-header"><code>Sec-Speculation-Tags</code></dfn>` HTTP request header specifies
  the web developer-provided tags associated with the speculative navigation request. It can also be
  used to distinguish speculative navigation requests from speculative subresource requests, since
  `<code id="the-sec-speculation-tags-header:sec-purpose"><a data-x-internal="sec-purpose" href="https://fetch.spec.whatwg.org/#sec-purpose-header">Sec-Purpose</a></code>` can be sent by both categories of requests.</p>

  <p>The header is a <a href="https://httpwg.org/specs/rfc8941.html" id="the-sec-speculation-tags-header:http-structured-header" data-x-internal="http-structured-header">structured header</a> whose value must
  be a <a href="https://httpwg.org/specs/rfc8941.html#list" id="the-sec-speculation-tags-header:http-structured-header-list" data-x-internal="http-structured-header-list">list</a>. The list can contain either <a href="https://httpwg.org/specs/rfc8941.html#token" id="the-sec-speculation-tags-header:http-structured-header-token" data-x-internal="http-structured-header-token">token</a> or <a href="https://httpwg.org/specs/rfc8941.html#string" id="the-sec-speculation-tags-header:http-structured-header-string" data-x-internal="http-structured-header-string">string</a> values. String values represent
  developer-provided tags, whereas token values represent predefined tags. As of now, the only
  predefined tag is <code>null</code>, which indicates a speculative navigation request
  with no developer-defined tag.</p>


  <h4 id="speculative-loading-security"><span class="secno">7.6.5</span> Security considerations<a href="#speculative-loading-security" class="self-link"></a></h4>


  <h5 id="speculative-loading-cross-site-requests"><span class="secno">7.6.5.1</span> Cross-site requests<a href="#speculative-loading-cross-site-requests" class="self-link"></a></h5>

  <p>Speculative loads can be initiated by web pages to cross-site destinations. However, because
  such cross-site speculative loads are always done without <a id="speculative-loading-cross-site-requests:credentials" href="https://fetch.spec.whatwg.org/#credentials" data-x-internal="credentials">credentials</a>, as explained
  <a href="speculative-loading-state-partitioning">below</a>, ambient authority is limited to
  requests that are already possible via other mechanisms on the platform.</p>

  <p>The `<code id="speculative-loading-cross-site-requests:speculation-rules-2"><a href="#speculation-rules-2">Speculation-Rules</a></code>` header can also be used to issue requests, for JSON
  documents whose body will be <a href="#parse-a-speculation-rule-set-string" id="speculative-loading-cross-site-requests:parse-a-speculation-rule-set-string">parsed as a
  speculation rule set string</a>. However, they use the "<code>same-origin</code>"
  <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="speculative-loading-cross-site-requests:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a>, the "<code>cors</code>" <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="speculative-loading-cross-site-requests:concept-request-mode" data-x-internal="concept-request-mode">mode</a>, and responses which do not
  use the <code id="speculative-loading-cross-site-requests:application/speculationrules+json"><a href="#application/speculationrules+json">application/speculationrules+json</a></code> <a id="speculative-loading-cross-site-requests:mime-type-essence" href="https://mimesniff.spec.whatwg.org/#mime-type-essence" data-x-internal="mime-type-essence">MIME type essence</a> are ignored,
  so they are not useful in mounting attacks.</p>


  <h5 id="speculative-loading-injected-content"><span class="secno">7.6.5.2</span> Injected content<a href="#speculative-loading-injected-content" class="self-link"></a></h5>

  <p>Because links in a document can be selected for speculative loading via <a href="#document-rule-predicate" id="speculative-loading-injected-content:document-rule-predicate">document rule predicates</a>, developers need to be cautious if such links
  might contain user-generated markup. For example, if the <code id="speculative-loading-injected-content:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> of a link can be entered by one user and displayed to all
  other users, a malicious user might choose a value like "<code>/logout</code>", causing
  other users' browsers to automatically log out of the site when that link is speculatively loaded.
  Using a <a href="#document-rule-selector-predicate" id="speculative-loading-injected-content:document-rule-selector-predicate">document rule selector predicate</a> to exclude such potentially-dangerous links,
  or using a <a href="#document-rule-url-pattern-predicate" id="speculative-loading-injected-content:document-rule-url-pattern-predicate">document rule URL pattern predicate</a> to allowlist known-safe links, are
  useful techniques in this regard.</p>

  <p>As with all uses of the <code id="speculative-loading-injected-content:the-script-element"><a href="#the-script-element">script</a></code> element, developers need to be cautious about
  inserting user-provided content into <code>&lt;script type=speculationrules&gt;</code>'s
  <a id="speculative-loading-injected-content:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a>. In particular, the insertion of an unescaped closing <code>&lt;/script&gt;</code> tag could be used to break out of the <code id="speculative-loading-injected-content:the-script-element-2"><a href="#the-script-element">script</a></code> element
  context and inject attacker-controlled markup.</p>

  <p>The <code>&lt;script type=speculationrules&gt;</code> feature causes activity in
  response to content found in the document, so it is worth considering the options open to an
  attacker able to inject unescaped HTML. Such an attacker is already able to inject JavaScript or
  <code id="speculative-loading-injected-content:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> elements. Speculative loads are generally less dangerous than arbitrary script
  execution. However, the use of <a href="#document-rule-predicate" id="speculative-loading-injected-content:document-rule-predicate-2">document rule
  predicates</a> could be used to speculatively load links in the document, and the existence of
  those loads could provide a vector for exfiltrating information about those links.
  Defense-in-depth against this possibility is provided by Content Security Policy. In particular,
  the <code>script-src</code> directive can be used to restrict the parsing of speculation
  rules <code id="speculative-loading-injected-content:the-script-element-3"><a href="#the-script-element">script</a></code> elements, and the <code>default-src</code> directive applies
  to navigational prefetch requests arising from such speculation rules. Additional defense is
  provided by the requirement that speculative loads are only performed to <a href="https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url" id="speculative-loading-injected-content:is-url-potentially-trustworthy" data-x-internal="is-url-potentially-trustworthy">potentially-trustworthy URLs</a>, so an on-path attacker would only
  have access to metadata and traffic analysis, and could not see the URLs directly.
  <a href="#refsCSP">[CSP]</a></p>

  <p>It's generally not expected that user-generated content will be added as arbitrary response
  headers: server operators are already going to encounter significant trouble if this is possible.
  It is therefore unlikely that the `<code id="speculative-loading-injected-content:speculation-rules-2"><a href="#speculation-rules-2">Speculation-Rules</a></code>` header meaningfully expands the
  XSS attack surface. For this reason, Content Security Policy does not apply to the loading of rule
  sets via that header.</p>


  <h5 id="speculative-loading-ip-anonymization"><span class="secno">7.6.5.3</span> IP anonymization<a href="#speculative-loading-ip-anonymization" class="self-link"></a></h5>

  <p>This standard allows developers to request that navigational prefetches are performed using IP
  anonymization technology provided by the user agent. The details of this anonymization are not
  specified, but some general security principles apply.</p>

  <p>To the extent IP anonymization is implemented using a proxy service, it is advisable to
  minimize the information available to the service operator and other entities on the network path.
  This likely involves, at a minimum, the use of TLS for the connection.</p>

  <p>Site operators need to be aware that, similar to virtual private network (VPN) technology, the
  client IP address seen by the HTTP server might not exactly correspond to the user's actual
  network provider or location, and a traffic for multiple distinct subscribers could originate from
  a single client IP address. This can affect site operators' security and abuse prevention
  measures. IP anonymization measures might make an effort to use an egress IP address which has a
  similar geolocation or is located in the same jurisdiction as the user, but any such behavior is
  particular to the user agent and not guaranteed.</p>


  <h4 id="speculative-loading-privacy"><span class="secno">7.6.6</span> Privacy considerations<a href="#speculative-loading-privacy" class="self-link"></a></h4>


  <h5 id="speculative-loading-heuristics"><span class="secno">7.6.6.1</span> Heuristics and optionality<a href="#speculative-loading-heuristics" class="self-link"></a></h5>

  <p>The <a href="#consider-speculative-loads" id="speculative-loading-heuristics:consider-speculative-loads">consider speculative loads</a> algorithm contains a crucial "may" step, which
  encourages user agents to <a href="https://wicg.github.io/nav-speculation/prefetch.html#start-a-referrer-initiated-navigational-prefetch" id="speculative-loading-heuristics:start-a-referrer-initiated-navigational-prefetch" data-x-internal="start-a-referrer-initiated-navigational-prefetch">start
  referrer-initiated navigational prefetches</a> based on a combination of the <a href="#speculation-rule-eagerness" id="speculative-loading-heuristics:speculation-rule-eagerness">speculation
  rule eagerness</a> and other features of the user's environment. Because it can be observable
  to the document whether speculative loads are performed, user agents must take care to protect
  privacy when making such decisions—for instance by only using information which is already
  available to the origin. If these heuristics depend on any persistent state, that state must be
  erased whenever the user erases other site data. If the user agent automatically clears other site
  data from time to time, it must erase such persistent state at the same time.</p>

  <p class="note">The use of <a href="#concept-origin" id="speculative-loading-heuristics:concept-origin">origin</a> instead of <a href="#site" id="speculative-loading-heuristics:site">site</a> here is intentional.
  Although same-site origins are generally allowed to coordinate if they wish, the web's security
  model is premised on preventing origins from accessing the data of other origins, even same-site
  ones. Thus, the user agent needs to be sure not to leak such data unintentionally across origins,
  not just across sites.</p>

  <p>Examples of inputs which would be already known to the document:</p>

  <ul><li><p>author-supplied <a href="#speculation-rule-eagerness" id="speculative-loading-heuristics:speculation-rule-eagerness-2">eagerness</a></p></li><li><p>order of appearance in the document</p></li><li><p>whether a link is in the viewport</p></li><li><p>whether the cursor is near a link</p></li><li><p>rendered size of a link</p></li></ul>

  <p>Examples of persistent data related to the origin (which the origin could have gathered itself)
  but which must be erased according to user intent:</p>

  <ul><li><p>whether the user has clicked this or similar links on this document or other documents on
   the same origin</p></li></ul>

  <p>Examples of device information which might be valuable in deciding whether speculative loading
  is appropriate, but which needs to be considered as part of the user agent's overall privacy
  posture because it can make the user more identifiable across origins:</p>

  <ul><li><p>coarse device class (CPU, memory)</p></li><li><p>coarse battery level</p></li><li><p>whether the network connection is known to be metered</p></li><li><p>any user-toggleable settings, such as a speculative loading toggle, a battery-saver
   toggle, or a data-saver toggle</p></li></ul>


  <h5 id="speculative-loading-state-partitioning"><span class="secno">7.6.6.2</span> State partitioning<a href="#speculative-loading-state-partitioning" class="self-link"></a></h5>

  <p>The <a id="speculative-loading-state-partitioning:start-a-referrer-initiated-navigational-prefetch" href="https://wicg.github.io/nav-speculation/prefetch.html#start-a-referrer-initiated-navigational-prefetch" data-x-internal="start-a-referrer-initiated-navigational-prefetch">start a referrer-initiated navigational prefetch</a> algorithm is designed to
  ensure that the HTTP requests that it issues behave consistently with how user agents partition
  <a id="speculative-loading-state-partitioning:credentials" href="https://fetch.spec.whatwg.org/#credentials" data-x-internal="credentials">credentials</a> according to <a href="https://storage.spec.whatwg.org/#storage-key" id="speculative-loading-state-partitioning:storage-key" data-x-internal="storage-key">storage keys</a>. This
  property is maintained even for cross-partition prefetches, as follows.</p>

  <p>If a future navigation using a prefetched response would load a document in the same partition,
  then at prefetch time, the partitioned credentials can be sent, as they can with subresource
  requests and scripted fetches. If such a future navigation would instead load a document in
  another partition, it would be inconsistent with the partitioning scheme to use partitioned
  credentials for the destination partition (since this would cross the boundary between partitions
  without a top-level navigation) and also inconsistent to use partitioned credentials within the
  originating partition (since this would result in the user seeing a document with different state
  than a non-prefetched navigation). Instead, a third, initially empty, partition is used for such
  requests. These requests therefore send along no credentials from either partition. However, the
  resulting prefetched response body constructed using this initially-empty partition can only be
  used if, at activation time, the destination partition contains no credentials.</p>

  <p>This is somewhat similar to the behavior of only sending such prefetch requests if the
  destination partition is known ahead of time to not contain credentials. However, to avoid such
  behavior being used a way of probing for the presence of credentials, instead such prefetch
  requests are always completed, and in the case of conflicting credentials, their results are not
  used.</p>

  <p>Redirects are possible between these two types of requests. A redirect from a same- to
  cross-partition URL could contain information derived from partitioned credentials in the
  originating partition; however, this is equivalent to the originating document fetching the
  same-partition URL itself and then issuing a request for the cross-partition URL. A redirect from
  a cross- to same-origin URL could carry credentials from the isolated partition, but since this
  partition has no prior state this does not enable tracking based on the user's prior browsing
  activity on that site, and the document could construct the same state by issuing uncredentialed
  requests itself.</p>


  <h5 id="speculative-loading-identity-joining"><span class="secno">7.6.6.3</span> Identity joining<a href="#speculative-loading-identity-joining" class="self-link"></a></h5>

  <p>Speculative loads provide a mechanism through which HTTP requests for later top-level
  navigation can be made without a user gesture. It is natural to ask whether it is possible for two
  coordinating sites to connect user identities.</p>

  <p>Since existing <a id="speculative-loading-identity-joining:credentials" href="https://fetch.spec.whatwg.org/#credentials" data-x-internal="credentials">credentials</a> for the destination site are not sent (as explained in
  the previous section), that site is limited in its ability to identify the user before navigation
  in a similar way to if the referrer site had simply used <code id="speculative-loading-identity-joining:fetch()"><a data-x-internal="fetch()" href="https://fetch.spec.whatwg.org/#dom-global-fetch">fetch()</a></code> to make an
  uncredentialed request. Upon navigation, this becomes similar to ordinary navigation (e.g., by
  clicking a link that was not speculatively loaded).</p>

  <p>To the extent that user agents attempt to mitigate identity joining for ordinary fetches and
  navigations, they can apply similar mitigations to speculatively-loaded navigations.</p>


  <h3 id="the-x-frame-options-header"><span class="secno">7.7</span> The `<code id="the-x-frame-options-header:x-frame-options"><a href="#x-frame-options">X-Frame-Options</a></code>` header<a href="#the-x-frame-options-header" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options" title="The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <frame>, <iframe>, <embed> or <object>. Sites can use this to avoid click-jacking attacks, by ensuring that their content is not embedded into other sites.">Headers/X-Frame-Options</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>Yes</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>Yes</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>Yes</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The `<dfn id="x-frame-options" data-dfn-type="http-header"><code>X-Frame-Options</code></dfn>` HTTP response header is a way
  of controlling whether and how a <code id="the-x-frame-options-header:document"><a href="#document">Document</a></code> may be loaded inside of a <a href="#child-navigable" id="the-x-frame-options-header:child-navigable">child
  navigable</a>. For sites using CSP, the <code id="the-x-frame-options-header:frame-ancestors-directive"><a data-x-internal="frame-ancestors-directive" href="https://w3c.github.io/webappsec-csp/#frame-ancestors">frame-ancestors</a></code> directive provides more granular control over the
  same situations. It was originally defined in <cite>HTTP Header Field X-Frame-Options</cite>, but
  the definition and processing model here supersedes that document.
  <a href="#refsCSP">[CSP]</a> <a href="#refsRFC7034">[RFC7034]</a>

  </p><p class="note">In particular, <cite>HTTP Header Field X-Frame-Options</cite> specified an `<code>ALLOW-FROM</code>` variant of the header, but that is not to be implemented.</p>

  <p class="note">Per the below processing model, if both
  a CSP <code id="the-x-frame-options-header:frame-ancestors-directive-2"><a data-x-internal="frame-ancestors-directive" href="https://w3c.github.io/webappsec-csp/#frame-ancestors">frame-ancestors</a></code> directive and an
  `<code id="the-x-frame-options-header:x-frame-options-2"><a href="#x-frame-options">X-Frame-Options</a></code>` header are used in the same <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-x-frame-options-header:concept-response" data-x-internal="concept-response">response</a>, then `<code id="the-x-frame-options-header:x-frame-options-3"><a href="#x-frame-options">X-Frame-Options</a></code>` is ignored.</p>

  <p>For web developers and conformance checkers, its value <a href="https://fetch.spec.whatwg.org/#abnf" id="the-x-frame-options-header:header-abnf" data-x-internal="header-abnf">ABNF</a>
  is:</p>

  <pre><code class="abnf"><c- nc="">X-Frame-Options</c-> <c- o="">=</c-> <c- l="">"DENY"</c-> <c- o="">/</c-> <c- l="">"SAMEORIGIN"</c-></code></pre>

  

  <div data-algorithm="">
  <p>To <dfn id="check-a-navigation-response's-adherence-to-x-frame-options">check a navigation response's adherence to `<code>X-Frame-Options</code>`</dfn>, given
  a <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-x-frame-options-header:concept-response-2" data-x-internal="concept-response">response</a> <var>response</var>, a <a href="#navigable" id="the-x-frame-options-header:navigable">navigable</a>
  <var>navigable</var>, a <a href="https://w3c.github.io/webappsec-csp/#csp-list" id="the-x-frame-options-header:concept-csp-list" data-x-internal="concept-csp-list">CSP list</a> <var>cspList</var>, and
  an <a href="#concept-origin" id="the-x-frame-options-header:concept-origin">origin</a> <var>destinationOrigin</var>:</p>

  <ol><li><p>If <var>navigable</var> is not a <a href="#child-navigable" id="the-x-frame-options-header:child-navigable-2">child navigable</a>, then return true.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-x-frame-options-header:list-iterate" data-x-internal="list-iterate">For each</a> <var>policy</var> of <var>cspList</var>:</p>

    <ol><li><p>If <var>policy</var>'s <a href="https://w3c.github.io/webappsec-csp/#policy-disposition" id="the-x-frame-options-header:csp-disposition" data-x-internal="csp-disposition">disposition</a> is not "<code>enforce</code>", then <a id="the-x-frame-options-header:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>policy</var>'s <a href="https://w3c.github.io/webappsec-csp/#policy-directive-set" id="the-x-frame-options-header:csp-directive-set" data-x-internal="csp-directive-set">directive set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="the-x-frame-options-header:list-contains" data-x-internal="list-contains">contains</a> a <code id="the-x-frame-options-header:frame-ancestors-directive-3"><a data-x-internal="frame-ancestors-directive" href="https://w3c.github.io/webappsec-csp/#frame-ancestors">frame-ancestors</a></code> directive, then return true.</p></li></ol>
   </li><li><p>Let <var>rawXFrameOptions</var> be the result of <a href="https://fetch.spec.whatwg.org/#concept-header-list-get-decode-split" id="the-x-frame-options-header:concept-header-list-get-decode-split" data-x-internal="concept-header-list-get-decode-split">getting, decoding, and splitting</a>
   `<code id="the-x-frame-options-header:x-frame-options-4"><a href="#x-frame-options">X-Frame-Options</a></code>` from <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="the-x-frame-options-header:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a>.</p></li><li><p>Let <var>xFrameOptions</var> be a new <a id="the-x-frame-options-header:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-x-frame-options-header:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>value</var> of
   <var>rawXFrameOptions</var>, <a href="https://infra.spec.whatwg.org/#set-append" id="the-x-frame-options-header:set-append" data-x-internal="set-append">append</a> <var>value</var>,
   <a id="the-x-frame-options-header:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>, to <var>xFrameOptions</var>.</p></li><li>
    <p>If <var>xFrameOptions</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="the-x-frame-options-header:list-size" data-x-internal="list-size">size</a> is greater than 1, and
    <var>xFrameOptions</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="the-x-frame-options-header:list-contains-2" data-x-internal="list-contains">contains</a> any of "<code>deny</code>", "<code>allowall</code>", or "<code>sameorigin</code>", then return false.</p>

    <p class="note">The intention here is to block any attempts at applying
    `<code id="the-x-frame-options-header:x-frame-options-5"><a href="#x-frame-options">X-Frame-Options</a></code>` which were trying to do something valid, but appear confused.</p>

    <p class="note">This is the only impact of the legacy `<code>ALLOWALL</code>` value
    on the processing model.</p>
   </li><li>
    <p>If <var>xFrameOptions</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="the-x-frame-options-header:list-size-2" data-x-internal="list-size">size</a> is greater than 1, then
    return true.</p>

    <p class="note">This means it contains multiple invalid values, which we treat the same way as
    if the header was omitted entirely.</p>
   </li><li><p>If <var>xFrameOptions</var>[0] is "<code>deny</code>", then return
   false.</p></li><li>
    <p>If <var>xFrameOptions</var>[0] is "<code>sameorigin</code>", then:</p>

    <ol><li><p>Let <var>containerDocument</var> be <var>navigable</var>'s <a href="#nav-container-document" id="the-x-frame-options-header:nav-container-document">container document</a>.</p></li><li>
      <p><a id="the-x-frame-options-header:while" href="https://infra.spec.whatwg.org/#iteration-while" data-x-internal="while">While</a> <var>containerDocument</var> is not null:</p>

      <ol><li><p>If <var>containerDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-x-frame-options-header:concept-document-origin" data-x-internal="concept-document-origin">origin</a>
       is not <a href="#same-origin" id="the-x-frame-options-header:same-origin">same origin</a> with <var>destinationOrigin</var>, then return
       false.</p></li><li><p>Set <var>containerDocument</var> to <var>containerDocument</var>'s <a href="#doc-container-document" id="the-x-frame-options-header:doc-container-document">container document</a>.</p></li></ol>
     </li></ol>
   </li><li>
    <p>Return true.</p>

    <p class="note">If we've reached this point then we have a lone invalid value (which could
    potentially be one the legacy `<code>ALLOWALL</code>` or `<code>ALLOW-FROM</code>` forms). These are treated as if the header were omitted
    entirely.</p>
   </li></ol>
  </div>

  <hr>

  

  <div class="example">
   <p>The following table illustrates the processing of various values for the header, including
   non-conformant ones:</p>

   <table class="data"><thead><tr><th>`<code id="the-x-frame-options-header:x-frame-options-6"><a href="#x-frame-options">X-Frame-Options</a></code>`</th><th>Valid</th><th>Result</th></tr></thead><tbody><tr><td>`<code>DENY</code>`</td><td>✅</td><td>embedding disallowed</td></tr><tr><td>`<code>SAMEORIGIN</code>`</td><td>✅</td><td>same-origin embedding allowed</td></tr><tr><td>`<code>INVALID</code>`</td><td>❌</td><td>embedding allowed</td></tr><tr><td>`<code>ALLOWALL</code>`</td><td>❌</td><td>embedding allowed</td></tr><tr><td>`<code>ALLOW-FROM=https://example.com/</code>`</td><td>❌</td><td>embedding allowed (from anywhere)</td></tr></tbody></table>
  </div>

  <div class="example">
   <p>The following table illustrates how various non-conformant cases involving multiple values are
   processed:</p>

   <table class="data"><thead><tr><th>`<code id="the-x-frame-options-header:x-frame-options-7"><a href="#x-frame-options">X-Frame-Options</a></code>`</th><th>Result</th></tr></thead><tbody><tr><td>`<code>SAMEORIGIN, SAMEORIGIN</code>`</td><td>same-origin embedding allowed</td></tr><tr><td>`<code>SAMEORIGIN, DENY</code>`</td><td>embedding disallowed</td></tr><tr><td>`<code>SAMEORIGIN,</code>`</td><td>embedding disallowed</td></tr><tr><td>`<code>SAMEORIGIN, ALLOWALL</code>`</td><td>embedding disallowed</td></tr><tr><td>`<code>SAMEORIGIN, INVALID</code>`</td><td>embedding disallowed</td></tr><tr><td>`<code>ALLOWALL, INVALID</code>`</td><td>embedding disallowed</td></tr><tr><td>`<code>ALLOWALL,</code>`</td><td>embedding disallowed</td></tr><tr><td>`<code>INVALID, INVALID</code>`</td><td>embedding allowed</td></tr></tbody></table>

   <p>The same results are obtained whether the values are delivered in a single header whose value is comma-delimited,
   or in multiple headers.</p>
  </div>


  <h3 id="the-refresh-header"><span class="secno">7.8</span> The `<code id="the-refresh-header:refresh"><a href="#refresh">Refresh</a></code>` header<a href="#the-refresh-header" class="self-link"></a></h3>

  <p>The `<dfn id="refresh" data-dfn-type="http-header"><code>Refresh</code></dfn>` HTTP response header is the HTTP-equivalent
  to a <code id="the-refresh-header:the-meta-element"><a href="#the-meta-element">meta</a></code> element with an <code id="the-refresh-header:attr-meta-http-equiv"><a href="#attr-meta-http-equiv">http-equiv</a></code>
  attribute in the <a href="#attr-meta-http-equiv-refresh" id="the-refresh-header:attr-meta-http-equiv-refresh">Refresh state</a>. It takes <a href="#conformance-attr-meta-http-equiv-refresh">the same value</a> and works largely the
  same. Its processing model is detailed in <a href="#initialise-the-document-object" id="the-refresh-header:initialise-the-document-object">create and initialize a <code>Document</code>
  object</a>.</p>
  


  <h3 id="nav-traversal-ui"><span class="secno">7.9</span> <span id="history-notes"></span>Browser user interface
  considerations<a href="#nav-traversal-ui" class="self-link"></a></h3>

  <p>Browser user agents should provide the ability to <a href="#navigate" id="nav-traversal-ui:navigate">navigate</a>, <a href="#reload" id="nav-traversal-ui:reload">reload</a>, and <a href="#nav-stop" id="nav-traversal-ui:nav-stop">stop loading</a>
  any <a href="#top-level-traversable" id="nav-traversal-ui:top-level-traversable">top-level traversable</a> in their <a href="#top-level-traversable-set" id="nav-traversal-ui:top-level-traversable-set">top-level traversable set</a>.</p>

  <p class="example">For example, via a location bar and reload/stop button UI.</p>

  <p>Browser user agents should provide the ability to <a href="#traverse-the-history-by-a-delta" id="nav-traversal-ui:traverse-the-history-by-a-delta">traverse by a delta</a> any <a href="#top-level-traversable" id="nav-traversal-ui:top-level-traversable-2">top-level traversable</a> in their <a href="#top-level-traversable-set" id="nav-traversal-ui:top-level-traversable-set-2">top-level
  traversable set</a>.</p>

  <p class="example">For example, via back and forward buttons, possibly including long-press
  abilities to change the delta.</p>

  <p>It is suggested that such user agents allow traversal by deltas greater than one, to avoid
  letting a page "trap" the user by stuffing the session history with spurious entries. (For
  example, via repeated calls to <code id="nav-traversal-ui:dom-history-pushstate"><a href="#dom-history-pushstate">history.pushState()</a></code> or
  <a href="#navigate-fragid" id="nav-traversal-ui:navigate-fragid">fragment navigations</a>.)</p>

  <p class="note">Some user agents have heuristics for translating a single "back" or "forward"
  button press into a larger delta, specifically to overcome such abuses. We are contemplating
  specifying these heuristics in <a href="https://github.com/whatwg/html/issues/7832">issue
  #7832</a>.</p>

  <p>Browser user agents should offer users the ability to <a href="#create-a-fresh-top-level-traversable" id="nav-traversal-ui:create-a-fresh-top-level-traversable">create a fresh top-level
  traversable</a>, given a user-provided or user agent-determined initial <a id="nav-traversal-ui:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p>

  <p class="example">For example, via a "new tab" or "new window" button.</p>

  <p>Browser user agents should offer users the ability to arbitrarily <a href="#close-a-top-level-traversable" id="nav-traversal-ui:close-a-top-level-traversable">close</a> any <a href="#top-level-traversable" id="nav-traversal-ui:top-level-traversable-3">top-level traversable</a> in their
  <a href="#top-level-traversable-set" id="nav-traversal-ui:top-level-traversable-set-3">top-level traversable set</a>.</p>

  <p class="example">For example, by clicking a "close tab" button.</p>

  <hr>

  <p>Browser user agents may provide ways for the user to explicitly cause any
  <a href="#navigable" id="nav-traversal-ui:navigable">navigable</a> (not just a <a href="#top-level-traversable" id="nav-traversal-ui:top-level-traversable-4">top-level traversable</a>) to <a href="#navigate" id="nav-traversal-ui:navigate-2">navigate</a>, <a href="#reload" id="nav-traversal-ui:reload-2">reload</a>, or <a href="#nav-stop" id="nav-traversal-ui:nav-stop-2">stop
  loading</a>.</p>

  <p class="example">For example, via a context menu.</p>

  <p>Browser user agents may provide the ability for users to <a href="#destroy-a-top-level-traversable" id="nav-traversal-ui:destroy-a-top-level-traversable">destroy a top-level
  traversable</a>.</p>

  <p class="example">For example, by force-closing a window containing one or more such <a href="#top-level-traversable" id="nav-traversal-ui:top-level-traversable-5">top-level traversables</a>.</p>

  <hr>

  <p>When a user requests a <a href="#reload" id="nav-traversal-ui:reload-3">reload</a> of a <a href="#navigable" id="nav-traversal-ui:navigable-2">navigable</a> whose <a href="#nav-active-history-entry" id="nav-traversal-ui:nav-active-history-entry">active session history entry</a>'s <a href="#she-document-state" id="nav-traversal-ui:she-document-state">document state</a>'s <a href="#document-state-resource" id="nav-traversal-ui:document-state-resource">resource</a> is a <a href="#post-resource" id="nav-traversal-ui:post-resource">POST resource</a>, the user agent
  should prompt the user to confirm the operation first, since otherwise transactions (e.g.,
  purchases or database modifications) could be repeated.</p>

  <p>When a user requests a <a href="#reload" id="nav-traversal-ui:reload-4">reload</a> of a <a href="#navigable" id="nav-traversal-ui:navigable-3">navigable</a>, user agents may provide
  a mechanism for ignoring any caches when reloading.</p>

  <hr>

  <p>All calls to <a href="#navigate" id="nav-traversal-ui:navigate-3">navigate</a> initiated by the mechanisms mentioned above must have the <i id="nav-traversal-ui:navigation-user-involvement"><a href="#navigation-user-involvement">userInvolvement</a></i> argument set to "<code id="nav-traversal-ui:uni-browser-ui"><a href="#uni-browser-ui">browser UI</a></code>".</p>

  <p>All calls to <a href="#reload" id="nav-traversal-ui:reload-5">reload</a> initiated by the mechanisms mentioned above must have the <i id="nav-traversal-ui:reload-user-involvement"><a href="#reload-user-involvement">userInvolvement</a></i> argument set to "<code id="nav-traversal-ui:uni-browser-ui-2"><a href="#uni-browser-ui">browser UI</a></code>".</p>

  <p>All calls to <a href="#traverse-the-history-by-a-delta" id="nav-traversal-ui:traverse-the-history-by-a-delta-2">traverse the history by a delta</a> initiated by the mechanisms mentioned
  above must not pass a value for the <i id="nav-traversal-ui:traverse-sourcedocument"><a href="#traverse-sourcedocument">sourceDocument</a></i>
  argument.</p>

  <hr>

  <p>The above recommendations, and the data structures in this specification, are not meant to
  place restrictions on how user agents represent the session history to the user.</p>

  <p>For example, although a <a href="#top-level-traversable" id="nav-traversal-ui:top-level-traversable-6">top-level traversable</a>'s <a href="#tn-session-history-entries" id="nav-traversal-ui:tn-session-history-entries">session history entries</a> are stored and maintained as a
  list, and the user agent is recommended to give an interface for <a href="#traverse-the-history-by-a-delta" id="nav-traversal-ui:traverse-the-history-by-a-delta-3">traversing that list by a delta</a>, a novel user agent could instead or
  in addition present a tree-like view, with each page having multiple "forward" pages that the user
  can choose between.</p>

  <p>Similarly, although session history for all descendant <a href="#navigable" id="nav-traversal-ui:navigable-4">navigables</a> is stored in their <a href="#traversable-navigable" id="nav-traversal-ui:traversable-navigable">traversable navigable</a>, user
  agents could present the user with a more nuanced per-<a href="#navigable" id="nav-traversal-ui:navigable-5">navigable</a> view of the session
  history.</p>

  <hr>

  <p>Browser user agents may use a <a href="#top-level-browsing-context" id="nav-traversal-ui:top-level-browsing-context">top-level browsing context</a>'s <a href="#is-popup" id="nav-traversal-ui:is-popup">is
  popup</a> boolean for the following purposes:

  </p><ul><li><p>Deciding whether or not to provide a minimal web browser user interface for the
   corresponding <a href="#top-level-traversable" id="nav-traversal-ui:top-level-traversable-7">top-level traversable</a>.</p></li><li><p>Performing the optional steps in <a id="nav-traversal-ui:set-up-browsing-context-features" href="https://drafts.csswg.org/cssom-view/#set-up-browsing-context-features" data-x-internal="set-up-browsing-context-features">set up browsing context features</a>.</p></li></ul>

  <p>In both cases user agents might additionally incorporate user preferences, or present a choice
  as to whether to go down the popup route.</p>

  <p>User agents that provide a minimal user interface for such popups are encouraged to not hide
  the browser's location bar.</p>


  <h2 id="webappapis"><span class="secno">8</span> Web application APIs<a href="#webappapis" class="self-link"></a></h2>

  <h3 id="scripting"><span class="secno">8.1</span> Scripting<a href="#scripting" class="self-link"></a></h3>

  <h4 id="introduction-11"><span class="secno">8.1.1</span> Introduction<a href="#introduction-11" class="self-link"></a></h4>

  <p>Various mechanisms can cause author-provided executable code to run in the context of a
  document. These mechanisms include, but are probably not limited to:</p>

  <ul><li>Processing of <code id="introduction-11:the-script-element"><a href="#the-script-element">script</a></code> elements.</li><li>Navigating to <a href="#the-javascript:-url-special-case" id="introduction-11:the-javascript:-url-special-case"><code>javascript:</code> URLs</a>.</li><li>Event handlers, whether registered through the DOM using <code>addEventListener()</code>, by explicit <a href="#event-handler-content-attributes" id="introduction-11:event-handler-content-attributes">event handler content attributes</a>, by
   <a href="#event-handler-idl-attributes" id="introduction-11:event-handler-idl-attributes">event handler IDL attributes</a>, or otherwise.</li><li>Processing of technologies like SVG that have their own scripting features.</li></ul>

  <h4 id="agents-and-agent-clusters"><span class="secno">8.1.2</span> Agents and agent clusters<a href="#agents-and-agent-clusters" class="self-link"></a></h4>

  <h5 id="integration-with-the-javascript-agent-formalism"><span class="secno">8.1.2.1</span> Integration with the JavaScript agent formalism<a href="#integration-with-the-javascript-agent-formalism" class="self-link"></a></h5>

  <p>JavaScript defines the concept of an <a id="integration-with-the-javascript-agent-formalism:agent" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a>. This section gives the mapping of that
  language-level concept on to the web platform.</p>

  <div class="note">
   <p>Conceptually, the <a id="integration-with-the-javascript-agent-formalism:agent-2" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a> concept is an architecture-independent, idealized
   "thread" in which JavaScript code runs. Such code can involve multiple globals/<a href="#concept-global-object-realm" id="integration-with-the-javascript-agent-formalism:concept-global-object-realm">realms</a> that can synchronously access each other, and
   thus needs to run in a single execution thread.</p>

   <p>Two <code id="integration-with-the-javascript-agent-formalism:window"><a href="#window">Window</a></code> objects having the same <a id="integration-with-the-javascript-agent-formalism:agent-3" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a> does not indicate
   they can directly access all objects created in each other's realms. They would have to be
   <a href="#same-origin-domain" id="integration-with-the-javascript-agent-formalism:same-origin-domain">same origin-domain</a>; see <a href="#isplatformobjectsameorigin-(-o-)" id="integration-with-the-javascript-agent-formalism:isplatformobjectsameorigin-(-o-)">IsPlatformObjectSameOrigin</a>.</p>
  </div>

  <p>The following types of agents exist on the web platform:</p>

  <dl><dt><dfn id="similar-origin-window-agent" data-export="">Similar-origin window agent</dfn></dt><dd>
    <p>Contains various <code id="integration-with-the-javascript-agent-formalism:window-2"><a href="#window">Window</a></code> objects which can potentially reach each other, either
    directly or by using <code id="integration-with-the-javascript-agent-formalism:dom-document-domain"><a href="#dom-document-domain">document.domain</a></code>.</p>

    <p>If the encompassing <a id="integration-with-the-javascript-agent-formalism:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>'s <a href="#is-origin-keyed" id="integration-with-the-javascript-agent-formalism:is-origin-keyed">is origin-keyed</a> is true, then
    all the <code id="integration-with-the-javascript-agent-formalism:window-3"><a href="#window">Window</a></code> objects will be <a href="#same-origin" id="integration-with-the-javascript-agent-formalism:same-origin">same origin</a>, can reach each other
    directly, and <code id="integration-with-the-javascript-agent-formalism:dom-document-domain-2"><a href="#dom-document-domain">document.domain</a></code> will no-op.</p>

    <p class="note">Two <code id="integration-with-the-javascript-agent-formalism:window-4"><a href="#window">Window</a></code> objects that are <a href="#same-origin" id="integration-with-the-javascript-agent-formalism:same-origin-2">same origin</a> can be in
    different <a href="#similar-origin-window-agent" id="integration-with-the-javascript-agent-formalism:similar-origin-window-agent">similar-origin window agents</a>, for
    instance if they are each in their own <a href="#browsing-context-group" id="integration-with-the-javascript-agent-formalism:browsing-context-group">browsing context group</a>.</p>
   </dd><dt><dfn id="dedicated-worker-agent" data-export="">Dedicated worker agent</dfn></dt><dd><p>Contains a single <code id="integration-with-the-javascript-agent-formalism:dedicatedworkerglobalscope"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code>.</p></dd><dt><dfn id="shared-worker-agent" data-export="">Shared worker agent</dfn></dt><dd><p>Contains a single <code id="integration-with-the-javascript-agent-formalism:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code>.</p></dd><dt><dfn id="service-worker-agent" data-export="">Service worker agent</dfn></dt><dd><p>Contains a single <code id="integration-with-the-javascript-agent-formalism:serviceworkerglobalscope"><a data-x-internal="serviceworkerglobalscope" href="https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope">ServiceWorkerGlobalScope</a></code>.</p></dd><dt><dfn id="worklet-agent" data-export="">Worklet agent</dfn></dt><dd>
    <p>Contains a single <code id="integration-with-the-javascript-agent-formalism:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code> object.</p>

    <p class="note">Although a given worklet can have multiple realms, each such realm needs its own
    agent, as each realm can be executing code independently and at the same time as the others.</p>
   </dd></dl>

  <p>Only <a href="#shared-worker-agent" id="integration-with-the-javascript-agent-formalism:shared-worker-agent">shared</a> and <a href="#dedicated-worker-agent" id="integration-with-the-javascript-agent-formalism:dedicated-worker-agent">dedicated worker agents</a> allow the use of JavaScript <code id="integration-with-the-javascript-agent-formalism:atomics"><a data-x-internal="atomics" href="https://tc39.es/ecma262/#sec-atomics-object">Atomics</a></code> APIs to
  potentially <a href="https://tc39.es/ecma262/#sec-forward-progress" id="integration-with-the-javascript-agent-formalism:forward-progress" data-x-internal="forward-progress">block</a>.</p>

  

  <div data-algorithm="">
  <p>To <dfn id="create-an-agent">create an agent</dfn>, given a boolean <var>canBlock</var>:</p>

  <ol><li><p>Let <var>signifier</var> be a new unique internal value.</p></li><li><p>Let <var>candidateExecution</var> be a new <a id="integration-with-the-javascript-agent-formalism:candidate-execution" href="https://tc39.es/ecma262/#sec-candidate-executions" data-x-internal="candidate-execution">candidate execution</a>.</p></li><li><p>Let <var>agent</var> be a new <a id="integration-with-the-javascript-agent-formalism:agent-4" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a> whose [[CanBlock]] is
   <var>canBlock</var>, [[Signifier]] is <var>signifier</var>, [[CandidateExecution]] is
   <var>candidateExecution</var>, and [[IsLockFree1]], [[IsLockFree2]], and [[LittleEndian]] are set
   at the implementation's discretion.</p></li><li><p>Set <var>agent</var>'s <a href="#concept-agent-event-loop" id="integration-with-the-javascript-agent-formalism:concept-agent-event-loop">event loop</a> to a new
   <a href="#event-loop" id="integration-with-the-javascript-agent-formalism:event-loop">event loop</a>.</p></li><li><p>Return <var>agent</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>For a <a id="integration-with-the-javascript-agent-formalism:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> <var>realm</var>, the <a id="integration-with-the-javascript-agent-formalism:agent-5" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a> whose [[Signifier]] is
  <var>realm</var>.[[AgentSignifier]] is <dfn data-dfn-for="realm" id="realm's-agent" data-lt="agent" data-export="">the realm's agent</dfn>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="relevant-agent" data-export="">relevant agent</dfn> for a <a id="integration-with-the-javascript-agent-formalism:platform-object" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a>
  <var>platformObject</var> is <var>platformObject</var>'s <a href="#concept-relevant-realm" id="integration-with-the-javascript-agent-formalism:concept-relevant-realm">relevant realm</a>'s <a href="#realm's-agent" id="integration-with-the-javascript-agent-formalism:realm's-agent">agent</a>.</p>
  </div>

  <p class="note">The agent equivalent of the <a id="integration-with-the-javascript-agent-formalism:current-realm" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a> is the <a id="integration-with-the-javascript-agent-formalism:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding
  agent</a>.</p>

  

  <h5 id="integration-with-the-javascript-agent-cluster-formalism"><span class="secno">8.1.2.2</span> Integration with the JavaScript agent cluster formalism<a href="#integration-with-the-javascript-agent-cluster-formalism" class="self-link"></a></h5>

  <p>JavaScript also defines the concept of an <a id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>, which this standard maps
  to the web platform by placing agents appropriately when they are created using the
  <a href="#obtain-similar-origin-window-agent" id="integration-with-the-javascript-agent-cluster-formalism:obtain-similar-origin-window-agent">obtain a similar-origin window agent</a> or
  <a href="#obtaining-a-worker/worklet-agent" id="integration-with-the-javascript-agent-cluster-formalism:obtaining-a-worker/worklet-agent">obtain a worker/worklet agent</a>
  algorithms.</p>

  <p>The <a id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-2" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a> concept is crucial for defining the JavaScript memory model, and
  in particular among which <a href="https://tc39.es/ecma262/#sec-agents" id="integration-with-the-javascript-agent-cluster-formalism:agent" data-x-internal="agent">agents</a> the backing data of
  <code id="integration-with-the-javascript-agent-cluster-formalism:sharedarraybuffer"><a data-x-internal="sharedarraybuffer" href="https://tc39.es/ecma262/#sec-sharedarraybuffer-objects">SharedArrayBuffer</a></code> objects can be shared.</p>

  <p class="note">Conceptually, the <a id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-3" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a> concept is an
  architecture-independent, idealized "process boundary" that groups together multiple "threads"
  (<a href="https://tc39.es/ecma262/#sec-agents" id="integration-with-the-javascript-agent-cluster-formalism:agent-2" data-x-internal="agent">agents</a>). The <a href="https://tc39.es/ecma262/#sec-agent-clusters" id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-4" data-x-internal="agent-cluster">agent clusters</a>
  defined by the specification are generally more restrictive than the actual process boundaries
  implemented in user agents. By enforcing these idealized divisions at the specification level, we
  ensure that web developers see interoperable behavior with regard to shared memory, even in the
  face of varying and changing user agent process models.</p>

  

  <p>An <a id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-5" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a> has an associated <dfn id="agent-cluster-cross-origin-isolation">cross-origin isolation mode</dfn>, which is a
  <a href="#cross-origin-isolation-mode" id="integration-with-the-javascript-agent-cluster-formalism:cross-origin-isolation-mode">cross-origin isolation mode</a>. It is initially "<code id="integration-with-the-javascript-agent-cluster-formalism:cross-origin-isolation-none"><a href="#cross-origin-isolation-none">none</a></code>".</p>

  <p>An <a id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-6" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a> has an associated <dfn id="is-origin-keyed">is origin-keyed</dfn> (a boolean), which
  is initially false.</p>

  <hr>

  <p>The following defines the allocation of the <a href="https://tc39.es/ecma262/#sec-agent-clusters" id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-7" data-x-internal="agent-cluster">agent clusters</a>
  of <a href="#similar-origin-window-agent" id="integration-with-the-javascript-agent-cluster-formalism:similar-origin-window-agent">similar-origin window agents</a>.</p>

  <p>An <dfn id="agent-cluster-key">agent cluster key</dfn> is a <a href="#site" id="integration-with-the-javascript-agent-cluster-formalism:site">site</a> or <a href="#concept-origin-tuple" id="integration-with-the-javascript-agent-cluster-formalism:concept-origin-tuple">tuple origin</a>. Without web developer action to achieve <a href="#origin-keyed-agent-clusters">origin-keyed agent clusters</a>, it will be a
  <a href="#site" id="integration-with-the-javascript-agent-cluster-formalism:site-2">site</a>.</p>

  <p class="note">An equivalent formulation is that an <a href="#agent-cluster-key" id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-key">agent cluster key</a> can be a
  <a href="#scheme-and-host" id="integration-with-the-javascript-agent-cluster-formalism:scheme-and-host">scheme-and-host</a> or an <a href="#concept-origin" id="integration-with-the-javascript-agent-cluster-formalism:concept-origin">origin</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="obtain-similar-origin-window-agent">obtain a similar-origin window agent</dfn>,
  given an <a href="#concept-origin" id="integration-with-the-javascript-agent-cluster-formalism:concept-origin-2">origin</a> <var>origin</var>, a <a href="#browsing-context-group" id="integration-with-the-javascript-agent-cluster-formalism:browsing-context-group">browsing context group</a>
  <var>group</var>, and a boolean <var>requestsOAC</var>, run these steps:</p>

  <ol><li><p>Let <var>site</var> be the result of <a href="#obtain-a-site" id="integration-with-the-javascript-agent-cluster-formalism:obtain-a-site">obtaining a site</a>
   with <var>origin</var>.</p></li><li><p>Let <var>key</var> be <var>site</var>.</p></li><li><p>If <var>group</var>'s <a href="#bcg-cross-origin-isolation" id="integration-with-the-javascript-agent-cluster-formalism:bcg-cross-origin-isolation">cross-origin isolation
   mode</a> is not "<code id="integration-with-the-javascript-agent-cluster-formalism:cross-origin-isolation-none-2"><a href="#cross-origin-isolation-none">none</a></code>", then set
   <var>key</var> to <var>origin</var>.</p></li><li><p>Otherwise, if <var>group</var>'s <a href="#historical-agent-cluster-key-map" id="integration-with-the-javascript-agent-cluster-formalism:historical-agent-cluster-key-map">historical agent cluster key
   map</a>[<var>origin</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="integration-with-the-javascript-agent-cluster-formalism:map-exists" data-x-internal="map-exists">exists</a>, then set <var>key</var> to
   <var>group</var>'s <a href="#historical-agent-cluster-key-map" id="integration-with-the-javascript-agent-cluster-formalism:historical-agent-cluster-key-map-2">historical agent cluster key map</a>[<var>origin</var>].</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>If <var>requestsOAC</var> is true, then set <var>key</var> to
     <var>origin</var>.</p></li><li><p>Set <var>group</var>'s <a href="#historical-agent-cluster-key-map" id="integration-with-the-javascript-agent-cluster-formalism:historical-agent-cluster-key-map-3">historical agent cluster key map</a>[<var>origin</var>]
     to <var>key</var>.</p></li></ol>
   </li><li>
    <p>If <var>group</var>'s <a href="#agent-cluster-map" id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-map">agent cluster map</a>[<var>key</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="integration-with-the-javascript-agent-cluster-formalism:map-exists-2" data-x-internal="map-exists">does not exist</a>, then:</p>

    <ol><li><p>Let <var>agentCluster</var> be a new <a id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-8" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>.</p></li><li><p>Set <var>agentCluster</var>'s <a href="#agent-cluster-cross-origin-isolation" id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-cross-origin-isolation">cross-origin isolation mode</a> to
     <var>group</var>'s <a href="#bcg-cross-origin-isolation" id="integration-with-the-javascript-agent-cluster-formalism:bcg-cross-origin-isolation-2">cross-origin isolation
     mode</a>.</p></li><li>
      <p>If <var>key</var> is an <a href="#concept-origin" id="integration-with-the-javascript-agent-cluster-formalism:concept-origin-3">origin</a>:</p>

      <ol><li><p><a id="integration-with-the-javascript-agent-cluster-formalism:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>key</var> is <var>origin</var>.</p></li><li><p>Set <var>agentCluster</var>'s <a href="#is-origin-keyed" id="integration-with-the-javascript-agent-cluster-formalism:is-origin-keyed">is origin-keyed</a> to true.</p></li></ol>
     </li><li><p>Add the result of <a href="#create-an-agent" id="integration-with-the-javascript-agent-cluster-formalism:create-an-agent">creating an agent</a>, given false,
     to <var>agentCluster</var>.</p></li><li><p>Set <var>group</var>'s <a href="#agent-cluster-map" id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-map-2">agent cluster map</a>[<var>key</var>] to
     <var>agentCluster</var>.</p></li></ol>
   </li><li><p>Return the single <a href="#similar-origin-window-agent" id="integration-with-the-javascript-agent-cluster-formalism:similar-origin-window-agent-2">similar-origin window agent</a> contained in <var>group</var>'s
   <a href="#agent-cluster-map" id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-map-3">agent cluster map</a>[<var>key</var>].</p></li></ol>
  </div>

  <p class="note">This means that there is only one <a href="#similar-origin-window-agent" id="integration-with-the-javascript-agent-cluster-formalism:similar-origin-window-agent-3">similar-origin window agent</a> per
  browsing context agent cluster. (However, <a href="#dedicated-worker-agent" id="integration-with-the-javascript-agent-cluster-formalism:dedicated-worker-agent">dedicated
  worker</a> and <a href="#worklet-agent" id="integration-with-the-javascript-agent-cluster-formalism:worklet-agent">worklet agents</a> might be in the same
  cluster.)</p>

  <hr>

  <p>The following defines the allocation of the <a href="https://tc39.es/ecma262/#sec-agent-clusters" id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-9" data-x-internal="agent-cluster">agent clusters</a>
  of all other types of agents.</p>

  <div data-algorithm="">
  <p>To <dfn id="obtaining-a-worker/worklet-agent">obtain a worker/worklet agent</dfn>, given an
  <a href="#environment-settings-object" id="integration-with-the-javascript-agent-cluster-formalism:environment-settings-object">environment settings object</a> or null <var>outside settings</var>, a boolean
  <var>isTopLevel</var>, and a boolean <var>canBlock</var>, run these steps:</p>

  <ol><li><p>Let <var>agentCluster</var> be null.

   </p></li><li>
    <p>If <var>isTopLevel</var> is true, then:</p>

    <ol><li><p>Set <var>agentCluster</var> to a new <a id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-10" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>.</p></li><li>
      <p>Set <var>agentCluster</var>'s <a href="#is-origin-keyed" id="integration-with-the-javascript-agent-cluster-formalism:is-origin-keyed-2">is origin-keyed</a> to true.</p>

      <p class="note">These workers can be considered to be origin-keyed. However, this is not
      exposed through any APIs (in the way that <code id="integration-with-the-javascript-agent-cluster-formalism:dom-originagentcluster"><a href="#dom-originagentcluster">originAgentCluster</a></code> exposes the origin-keyedness for
      windows).</p>
     </li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p><a id="integration-with-the-javascript-agent-cluster-formalism:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>outside settings</var> is not null.</p></li><li><p>Let <var>ownerAgent</var> be <var>outside settings</var>'s <a href="#environment-settings-object's-realm" id="integration-with-the-javascript-agent-cluster-formalism:environment-settings-object's-realm">realm</a>'s <a href="#realm's-agent" id="integration-with-the-javascript-agent-cluster-formalism:realm's-agent">agent</a>.</p></li><li><p>Set <var>agentCluster</var> to the agent cluster which contains
     <var>ownerAgent</var>.</p></li></ol>
   </li><li><p>Let <var>agent</var> be the result of <a href="#create-an-agent" id="integration-with-the-javascript-agent-cluster-formalism:create-an-agent-2">creating an
   agent</a> given <var>canBlock</var>.</p></li><li><p>Add <var>agent</var> to <var>agentCluster</var>.</p></li><li><p>Return <var>agent</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="obtain-a-dedicated/shared-worker-agent">obtain a dedicated/shared worker agent</dfn>, given an <a href="#environment-settings-object" id="integration-with-the-javascript-agent-cluster-formalism:environment-settings-object-2">environment settings
  object</a> <var>outside settings</var> and a boolean <var>isShared</var>, return the result of
  <a href="#obtaining-a-worker/worklet-agent" id="integration-with-the-javascript-agent-cluster-formalism:obtaining-a-worker/worklet-agent-2">obtaining a worker/worklet agent</a> given <var>outside settings</var>,
  <var>isShared</var>, and true.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="obtain-a-worklet-agent">obtain a worklet agent</dfn>, given an <a href="#environment-settings-object" id="integration-with-the-javascript-agent-cluster-formalism:environment-settings-object-3">environment settings object</a>
  <var>outside settings</var>, return the result of <a href="#obtaining-a-worker/worklet-agent" id="integration-with-the-javascript-agent-cluster-formalism:obtaining-a-worker/worklet-agent-3">obtaining a worker/worklet agent</a>
  given <var>outside settings</var>, false, and false.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="obtain-a-service-worker-agent" data-export="">obtain a service worker agent</dfn>, return the result of <a href="#obtaining-a-worker/worklet-agent" id="integration-with-the-javascript-agent-cluster-formalism:obtaining-a-worker/worklet-agent-4">obtaining a
  worker/worklet agent</a> given null, true, and false.</p>
  </div>

  <hr>

  

  <div id="can-share-memory-with" class="example"><a href="#can-share-memory-with" class="self-link"></a>
   <p>The following pairs of global objects are each within the same <a id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-11" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>, and
   thus can use <code id="integration-with-the-javascript-agent-cluster-formalism:sharedarraybuffer-2"><a data-x-internal="sharedarraybuffer" href="https://tc39.es/ecma262/#sec-sharedarraybuffer-objects">SharedArrayBuffer</a></code> instances to share memory with each other:</p>

   <ul><li><p>A <code id="integration-with-the-javascript-agent-cluster-formalism:window"><a href="#window">Window</a></code> object and a dedicated worker that it created.</p></li><li><p>A worker (of any type) and a dedicated worker it created.</p></li><li><p data-var-scope="">A <code id="integration-with-the-javascript-agent-cluster-formalism:window-2"><a href="#window">Window</a></code> object <var>A</var> and the <code id="integration-with-the-javascript-agent-cluster-formalism:window-3"><a href="#window">Window</a></code> object of an
    <code id="integration-with-the-javascript-agent-cluster-formalism:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element that <var>A</var> created that could be <a href="#same-origin-domain" id="integration-with-the-javascript-agent-cluster-formalism:same-origin-domain">same
    origin-domain</a> with <var>A</var>.</p></li><li><p>A <code id="integration-with-the-javascript-agent-cluster-formalism:window-4"><a href="#window">Window</a></code> object and a <a href="#same-origin-domain" id="integration-with-the-javascript-agent-cluster-formalism:same-origin-domain-2">same origin-domain</a> <code id="integration-with-the-javascript-agent-cluster-formalism:window-5"><a href="#window">Window</a></code>
    object that opened it.</p></li><li><p>A <code id="integration-with-the-javascript-agent-cluster-formalism:window-6"><a href="#window">Window</a></code> object and a worklet that it created.</p></li></ul>

   <p>The following pairs of global objects are <em>not</em> within the same <a id="integration-with-the-javascript-agent-cluster-formalism:agent-cluster-12" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent
   cluster</a>, and thus cannot share memory:</p>

   <ul><li><p>A <code id="integration-with-the-javascript-agent-cluster-formalism:window-7"><a href="#window">Window</a></code> object and a shared worker it created.</p></li><li><p>A worker (of any type) and a shared worker it created.</p></li><li><p>A <code id="integration-with-the-javascript-agent-cluster-formalism:window-8"><a href="#window">Window</a></code> object and a service worker it created.</p></li><li><p data-var-scope="">A <code id="integration-with-the-javascript-agent-cluster-formalism:window-9"><a href="#window">Window</a></code> object <var>A</var> and the <code id="integration-with-the-javascript-agent-cluster-formalism:window-10"><a href="#window">Window</a></code> object of an
    <code id="integration-with-the-javascript-agent-cluster-formalism:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> element that <var>A</var> created that cannot be <a href="#same-origin-domain" id="integration-with-the-javascript-agent-cluster-formalism:same-origin-domain-3">same
    origin-domain</a> with <var>A</var>.</p></li><li><p>Any two <code id="integration-with-the-javascript-agent-cluster-formalism:window-11"><a href="#window">Window</a></code> objects with no opener or ancestor relationship. This holds
    even if the two <code id="integration-with-the-javascript-agent-cluster-formalism:window-12"><a href="#window">Window</a></code> objects are <a href="#same-origin" id="integration-with-the-javascript-agent-cluster-formalism:same-origin">same origin</a>.</p></li></ul>
  </div>

  

  <h4 id="realms-and-their-counterparts"><span class="secno">8.1.3</span> Realms and their counterparts<a href="#realms-and-their-counterparts" class="self-link"></a></h4>

  <p>The JavaScript specification introduces the <a id="realms-and-their-counterparts:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> concept, representing a global
  environment in which script is run. Each realm comes with an <a id="realms-and-their-counterparts:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>
  <a href="#global-object" id="realms-and-their-counterparts:global-object">global object</a>; much of this specification is devoted to defining that global object
  and its properties.</p>

  <p>For web specifications, it is often useful to associate values or algorithms with a
  realm/global object pair. When the values are specific to a particular type of realm, they are
  associated directly with the global object in question, e.g., in the definition of the
  <code id="realms-and-their-counterparts:window"><a href="#window">Window</a></code> or <code id="realms-and-their-counterparts:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> interfaces. When the values have utility
  across multiple realms, we use the <a href="#environment-settings-object" id="realms-and-their-counterparts:environment-settings-object">environment settings object</a> concept.</p>

  <p>Finally, in some cases it is necessary to track associated values before a
  realm/global object/environment settings object even comes into existence (for example, during
  <a href="#navigate" id="realms-and-their-counterparts:navigate">navigation</a>). These values are tracked in the
  <a href="#environment" id="realms-and-their-counterparts:environment">environment</a> concept.</p>

  <h5 id="environments"><span class="secno">8.1.3.1</span> Environments<a href="#environments" class="self-link"></a></h5>

  <p>An <dfn id="environment" data-export="">environment</dfn> is an object that identifies the settings of a current or
  potential execution environment (i.e., a <a href="#navigation-params" id="environments:navigation-params">navigation
  params</a>'s <a href="#navigation-params-reserved-environment" id="environments:navigation-params-reserved-environment">reserved environment</a>
  or a <a href="https://fetch.spec.whatwg.org/#concept-request" id="environments:concept-request" data-x-internal="concept-request">request</a>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="environments:concept-request-reserved-client" data-x-internal="concept-request-reserved-client">reserved client</a>). An <a href="#environment" id="environments:environment">environment</a> has
  the following fields:</p>

  <dl><dt>An <dfn data-dfn-for="environment" id="concept-environment-id" data-export="">id</dfn></dt><dd><p>An opaque string that uniquely identifies this <a href="#environment" id="environments:environment-2">environment</a>.</p></dd><dt>A <dfn data-dfn-for="environment" id="concept-environment-creation-url" data-export="">creation URL</dfn></dt><dd>
    <p>A <a id="environments:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> that represents the location of the resource with which this
    <a href="#environment" id="environments:environment-3">environment</a> is associated.</p>

    <p class="note">In the case of a <code id="environments:window"><a href="#window">Window</a></code> <a href="#environment-settings-object" id="environments:environment-settings-object">environment settings object</a>,
    this URL might be distinct from its <a href="#concept-settings-object-global" id="environments:concept-settings-object-global">global
    object</a>'s <a href="#concept-document-window" id="environments:concept-document-window">associated
    <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="environments:the-document's-address" data-x-internal="the-document's-address">URL</a>, due to
    mechanisms such as <code id="environments:dom-history-pushstate"><a href="#dom-history-pushstate">history.pushState()</a></code> which modify
    the latter.</p>
   </dd><dt>A <dfn data-dfn-for="environment" id="concept-environment-top-level-creation-url" data-export="">top-level creation URL</dfn></dt><dd><p>Null or a <a id="environments:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> that represents the <a href="#concept-environment-creation-url" id="environments:concept-environment-creation-url">creation URL</a> of the "top-level"
   <a href="#environment" id="environments:environment-4">environment</a>. It is null for workers and worklets.</p></dd><dt>A <dfn data-dfn-for="environment" id="concept-environment-top-level-origin" data-export="">top-level origin</dfn></dt><dd>
    <p>A <span class="XXX">for now</span> <a id="environments:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> value, null,
    or an <a href="#concept-origin" id="environments:concept-origin">origin</a>. For a "top-level" potential execution environment it is null (i.e.,
    when there is no response yet); otherwise it is the "top-level" <a href="#environment" id="environments:environment-5">environment</a>'s <a href="#concept-settings-object-origin" id="environments:concept-settings-object-origin">origin</a>. For a dedicated worker or worklet it is
    the <a href="#concept-environment-top-level-origin" id="environments:concept-environment-top-level-origin">top-level origin</a> of its creator. For a shared or service worker it is an
    <a id="environments:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> value.</p>

    <p class="note">This is distinct from the <a href="#concept-environment-top-level-creation-url" id="environments:concept-environment-top-level-creation-url">top-level creation URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="environments:concept-url-origin" data-x-internal="concept-url-origin">origin</a> when sandboxing, workers, and worklets are
    involved.</p>
   </dd><dt>A <dfn data-dfn-for="environment" id="concept-environment-target-browsing-context" data-export="">target browsing context</dfn></dt><dd><p>Null or a target <a href="#browsing-context" id="environments:browsing-context">browsing context</a> for a <a href="https://fetch.spec.whatwg.org/#navigation-request" id="environments:navigation-request" data-x-internal="navigation-request">navigation request</a>.</p></dd><dt>An <dfn data-dfn-for="environment" id="concept-environment-active-service-worker" data-export="">active service worker</dfn></dt><dd><p>Null or a <a href="https://w3c.github.io/ServiceWorker/#dfn-service-worker" id="environments:dfn-service-worker" data-x-internal="dfn-service-worker">service worker</a> that <a href="https://w3c.github.io/ServiceWorker/#dfn-control" id="environments:dfn-control" data-x-internal="dfn-control">controls</a> the <a href="#environment" id="environments:environment-6">environment</a>.</p></dd><dt>An <dfn data-dfn-for="environment" id="concept-environment-execution-ready-flag" data-export="">execution ready flag</dfn></dt><dd><p>A flag that indicates whether the environment setup is done. It is initially
   unset.</p></dd></dl>

  <p>Specifications may define <dfn id="environment-discarding-steps" data-export="">environment discarding steps</dfn> for environments. The
  steps take an <a href="#environment" id="environments:environment-7">environment</a> as input.</p>

  <p class="note">The <a href="#environment-discarding-steps" id="environments:environment-discarding-steps">environment discarding
  steps</a> are run for only a select few environments: the ones that will
  never become execution ready because, for example, they failed to load.</p>

  <h5 id="environment-settings-objects"><span class="secno">8.1.3.2</span> Environment settings objects<a href="#environment-settings-objects" class="self-link"></a></h5>

  <p>An <dfn id="environment-settings-object" data-export="">environment settings object</dfn> is an <a href="#environment" id="environment-settings-objects:environment">environment</a> that
  additionally specifies algorithms for:</p>

  <dl><dt>A <dfn data-dfn-for="environment settings object" id="realm-execution-context" data-export="">realm execution
   context</dfn></dt><dd>
    <p>A <a id="environment-settings-objects:javascript-execution-context" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript execution context</a> shared by all
    <a href="#the-script-element" id="environment-settings-objects:the-script-element">scripts</a> that use this settings object, i.e., all scripts in a given
    <a id="environment-settings-objects:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>. When we <a href="#run-a-classic-script" id="environment-settings-objects:run-a-classic-script">run a classic script</a> or <a href="#run-a-module-script" id="environment-settings-objects:run-a-module-script">run a module
    script</a>, this execution context becomes the top of the <a id="environment-settings-objects:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context
    stack</a>, on top of which another execution context specific to the script in question is
    pushed. (This setup ensures <a id="environment-settings-objects:source-text-module-record" href="https://tc39.es/ecma262/#sec-source-text-module-records" data-x-internal="source-text-module-record">Source Text Module Record</a>'s
    <a href="https://tc39.es/ecma262/#sec-moduleevaluation" id="environment-settings-objects:js-evaluate" data-x-internal="js-evaluate">Evaluate</a> knows which realm to use.)</p>
   </dd><dt>A <dfn data-dfn-for="environment
   settings object" id="concept-settings-object-module-map" data-export="">module map</dfn></dt><dd>
    <p>A <a href="#module-map" id="environment-settings-objects:module-map">module map</a> that is used when importing JavaScript modules.</p>
   </dd><dt>An <dfn data-dfn-for="environment settings object" id="api-base-url" data-export="">API base URL</dfn></dt><dd>
    <p>A <a id="environment-settings-objects:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> used by APIs called by scripts that use this <a href="#environment-settings-object" id="environment-settings-objects:environment-settings-object">environment settings
    object</a> to <a href="#parse-a-url" id="environment-settings-objects:parse-a-url">parse URLs</a>.</p>
   </dd><dt>An <dfn data-dfn-for="environment
   settings object" id="concept-settings-object-origin" data-export="">origin</dfn></dt><dd>
    <p>An <a href="#concept-origin" id="environment-settings-objects:concept-origin">origin</a> used in security checks.</p>
   </dd><dt>A <dfn data-dfn-for="environment settings object" id="concept-settings-object-has-cross-site-ancestor" data-export="">has cross-site ancestor</dfn></dt><dd><p>A boolean used in security checks.</p></dd><dt>A <dfn data-dfn-for="environment settings object" id="concept-settings-object-policy-container" data-export="">policy container</dfn></dt><dd>
    <p>A <a href="#policy-container" id="environment-settings-objects:policy-container">policy container</a> containing policies used for security checks.</p>
   </dd><dt>A <dfn data-dfn-for="environment settings object" id="concept-settings-object-cross-origin-isolated-capability" data-export="">cross-origin isolated capability</dfn></dt><dd><p>A boolean representing whether scripts that use this <a href="#environment-settings-object" id="environment-settings-objects:environment-settings-object-2">environment settings
   object</a> are allowed to use APIs that require cross-origin isolation.</p></dd><dt>A <dfn data-dfn-for="environment settings object" id="concept-settings-object-time-origin" data-export="">time origin</dfn></dt><dd>A number used as the baseline for performance-related timestamps. <a href="#refsHRT">[HRT]</a></dd></dl>

  <div data-algorithm="">
  <p>An <a href="#environment-settings-object" id="environment-settings-objects:environment-settings-object-3">environment settings object</a>'s <dfn data-dfn-for="environment settings
  object" id="responsible-event-loop" data-export="">responsible event loop</dfn> is its <a href="#concept-settings-object-global" id="environment-settings-objects:concept-settings-object-global">global
  object</a>'s <a href="#relevant-agent" id="environment-settings-objects:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="environment-settings-objects:concept-agent-event-loop">event
  loop</a>.</p>
  </div>

  <h5 id="realms-settings-objects-global-objects"><span class="secno">8.1.3.3</span> Realms, settings objects, and global objects<a href="#realms-settings-objects-global-objects" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>A <dfn id="global-object" data-export="">global object</dfn> is a JavaScript object that is the [[GlobalObject]] field of
  a <a id="realms-settings-objects-global-objects:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>.</p>
  </div>

  <p class="note">In this specification, all <a href="https://tc39.es/ecma262/#sec-code-realms" id="realms-settings-objects-global-objects:realm-2" data-x-internal="realm">realms</a> are <a href="#creating-a-new-javascript-realm" id="realms-settings-objects-global-objects:creating-a-new-javascript-realm">created</a> with <a href="#global-object" id="realms-settings-objects-global-objects:global-object">global
  objects</a> that are either <code id="realms-settings-objects-global-objects:window"><a href="#window">Window</a></code>, <code id="realms-settings-objects-global-objects:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code>, or
  <code id="realms-settings-objects-global-objects:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code> objects.</p>

  <p>A <a href="#global-object" id="realms-settings-objects-global-objects:global-object-2">global object</a> has an <dfn data-dfn-for="global object" id="in-error-reporting-mode">in error reporting mode</dfn>
  boolean, which is initially false.</p>

  <p>A <a href="#global-object" id="realms-settings-objects-global-objects:global-object-3">global object</a> has an <dfn id="outstanding-rejected-promises-weak-set">outstanding rejected promises weak set</dfn>, a
  <a id="realms-settings-objects-global-objects:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <code id="realms-settings-objects-global-objects:idl-promise"><a data-x-internal="idl-promise" href="https://webidl.spec.whatwg.org/#idl-promise">Promise</a></code> objects, initially empty. This set
  must not create strong references to any of its members, and implementations are free to limit
  its size in an <a id="realms-settings-objects-global-objects:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner, e.g., by removing old entries from it
  when new ones are added.</p>

  <p>A <a href="#global-object" id="realms-settings-objects-global-objects:global-object-4">global object</a> has an <dfn id="about-to-be-notified-rejected-promises-list">about-to-be-notified rejected promises list</dfn>, a
  <a id="realms-settings-objects-global-objects:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <code id="realms-settings-objects-global-objects:idl-promise-2"><a data-x-internal="idl-promise" href="https://webidl.spec.whatwg.org/#idl-promise">Promise</a></code> objects, initially empty.</p>

  <p>A <a href="#global-object" id="realms-settings-objects-global-objects:global-object-5">global object</a> has an <dfn id="concept-global-import-map">import map</dfn>,
  initially an <a href="#empty-import-map" id="realms-settings-objects-global-objects:empty-import-map">empty import map</a>.</p>

  <p class="note">For now, only <code id="realms-settings-objects-global-objects:window-2"><a href="#window">Window</a></code> <a href="#global-object" id="realms-settings-objects-global-objects:global-object-6">global
  objects</a> have their <a href="#concept-global-import-map" id="realms-settings-objects-global-objects:concept-global-import-map">import map</a> modified
  from the initial empty one. The <a href="#concept-global-import-map" id="realms-settings-objects-global-objects:concept-global-import-map-2">import map</a> is
  only accessed for the resolution of a root <a href="#module-script" id="realms-settings-objects-global-objects:module-script">module script</a>.</p>

  <p>A <a href="#global-object" id="realms-settings-objects-global-objects:global-object-7">global object</a> has a <dfn id="resolved-module-set">resolved module set</dfn>, a <a id="realms-settings-objects-global-objects:set-2" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a>
  of <a href="#specifier-resolution-record" id="realms-settings-objects-global-objects:specifier-resolution-record">specifier resolution records</a>, initially
  empty.</p>

  <p class="note">The <a href="#resolved-module-set" id="realms-settings-objects-global-objects:resolved-module-set">resolved module set</a> ensures that module specifier resolution
  returns the same result when called multiple times with the same (referrer, specifier) pair. It
  does that by ensuring that <a href="#import-map" id="realms-settings-objects-global-objects:import-map">import map</a> rules that impact the specifier in its
  referrer's scope cannot be defined after its initial resolution. For now, only <code id="realms-settings-objects-global-objects:window-3"><a href="#window">Window</a></code>
  <a href="#global-object" id="realms-settings-objects-global-objects:global-object-8">global objects</a> have their module set data structures modified
  from the initial empty one.</p>

  <hr>

  <p>There is always a 1-to-1-to-1 mapping between <a href="https://tc39.es/ecma262/#sec-code-realms" id="realms-settings-objects-global-objects:realm-3" data-x-internal="realm">realms</a>, <a href="#global-object" id="realms-settings-objects-global-objects:global-object-9">global objects</a>, and <a href="#environment-settings-object" id="realms-settings-objects-global-objects:environment-settings-object">environment settings objects</a>:</p>

  <ul><li>
    <div data-algorithm="">
    <p>A <a id="realms-settings-objects-global-objects:realm-4" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> has a [[HostDefined]] field, which contains <dfn data-dfn-for="realm" id="concept-realm-settings-object" data-lt="settings object" data-export="">the realm's
    settings object</dfn>.</p>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>A <a id="realms-settings-objects-global-objects:realm-5" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> has a [[GlobalObject]] field, which contains <dfn data-dfn-for="realm" id="concept-realm-global" data-lt="global object" data-export="">the realm's global
    object</dfn>.</p>
    </div>
   </li><li><p>Each <a href="#global-object" id="realms-settings-objects-global-objects:global-object-10">global object</a> in this specification is created during the <a href="#creating-a-new-javascript-realm" id="realms-settings-objects-global-objects:creating-a-new-javascript-realm-2">creation</a> of a corresponding <a id="realms-settings-objects-global-objects:realm-6" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>, known as
   <dfn data-dfn-for="global object" id="concept-global-object-realm" data-lt="realm" data-export="">the global
   object's realm</dfn>.</p></li><li id="relevant-settings-object-for-a-global-object"><p>Each <a href="#global-object" id="realms-settings-objects-global-objects:global-object-11">global object</a> in this
   specification is created alongside a corresponding <a href="#environment-settings-object" id="realms-settings-objects-global-objects:environment-settings-object-2">environment settings object</a>,
   known as its <a href="#relevant-settings-object" id="realms-settings-objects-global-objects:relevant-settings-object">relevant settings object</a>.</p>

   </li><li>
    <div data-algorithm="">
    <p>An <a href="#environment-settings-object" id="realms-settings-objects-global-objects:environment-settings-object-3">environment settings object</a>'s <a href="#realm-execution-context" id="realms-settings-objects-global-objects:realm-execution-context">realm execution context</a>'s
    Realm component is <dfn data-dfn-for="environment settings object" id="environment-settings-object's-realm" data-lt="realm" data-export="">the environment settings object's realm</dfn>.</p>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>An <a href="#environment-settings-object" id="realms-settings-objects-global-objects:environment-settings-object-4">environment settings object</a>'s <a href="#environment-settings-object's-realm" id="realms-settings-objects-global-objects:environment-settings-object's-realm">realm</a> then has a [[GlobalObject]] field, which contains <dfn data-dfn-for="environment settings
    object" id="concept-settings-object-global" data-lt="global object" data-export="">the environment settings object's global object</dfn>.</p>
    </div>
   </li></ul>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-new-javascript-realm" data-export="">create a new
  realm</dfn> in an <a id="realms-settings-objects-global-objects:agent" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a> <var>agent</var>, optionally with instructions to create a
  global object or a global <b>this</b> binding (or both), the following steps are taken:</p>

  <ol><li><p>Perform <a href="https://tc39.es/ecma262/#sec-initializehostdefinedrealm" id="realms-settings-objects-global-objects:js-initializehostdefinedrealm" data-x-internal="js-initializehostdefinedrealm">InitializeHostDefinedRealm</a>()
   with the provided customizations for creating the global object and the global <b>this</b>
   binding.</p></li><li>
    <p>Let <var>realm execution context</var> be the <a id="realms-settings-objects-global-objects:running-javascript-execution-context" href="https://tc39.es/ecma262/#running-execution-context" data-x-internal="running-javascript-execution-context">running JavaScript execution
    context</a>.</p>

    <p class="note">This is the <a id="realms-settings-objects-global-objects:javascript-execution-context" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript execution context</a> created in the previous
    step.</p>
   </li><li><p>Remove <var>realm execution context</var> from the <a id="realms-settings-objects-global-objects:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context
   stack</a>.</p></li><li><p>Let <var>realm</var> be <var>realm execution context</var>'s Realm component.</p></li><li>
    <p>If <var>agent</var>'s <a id="realms-settings-objects-global-objects:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>'s <a href="#agent-cluster-cross-origin-isolation" id="realms-settings-objects-global-objects:agent-cluster-cross-origin-isolation">cross-origin isolation mode</a> is "<code id="realms-settings-objects-global-objects:cross-origin-isolation-none"><a href="#cross-origin-isolation-none">none</a></code>", then:</p>

    <ol><li><p>Let <var>global</var> be <var>realm</var>'s <a href="#concept-realm-global" id="realms-settings-objects-global-objects:concept-realm-global">global
     object</a>.</p></li><li><p>Let <var>status</var> be ! <var>global</var>.[[Delete]]("<code>SharedArrayBuffer</code>").</p></li><li><p><a id="realms-settings-objects-global-objects:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>status</var> is true.</p></li></ol>

    <p class="note">This is done for compatibility with web content and there is some hope that this
    can be removed in the future. Web developers can still get at the constructor through
    <code class="js">new WebAssembly.Memory({ shared:true, initial:0, maximum:0
    }).buffer.constructor</code>.</p>
   </li><li><p>Return <var>realm execution context</var>.</p></li></ol>
  </div>

  <hr>

  <p>When defining algorithm steps throughout this specification, it is often important to indicate
  what <a id="realms-settings-objects-global-objects:realm-7" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> is to be used—or, equivalently, what <a href="#global-object" id="realms-settings-objects-global-objects:global-object-12">global object</a> or
  <a href="#environment-settings-object" id="realms-settings-objects-global-objects:environment-settings-object-5">environment settings object</a> is to be used. In general, there are at least four
  possibilities:</p>

  <dl><dt><dfn id="concept-entry-everything">Entry</dfn></dt><dd>This corresponds to the script that initiated the currently running script action: i.e.,
    the function or script that the user agent called into when it called into author code.</dd><dt><dfn id="concept-incumbent-everything">Incumbent</dfn></dt><dd>This corresponds to the most-recently-entered author function or script on the stack, or the
    author function or script that originally scheduled the currently-running callback.</dd><dt><dfn id="concept-current-everything">Current</dfn></dt><dd>This corresponds to the currently-running function object, including built-in user-agent
    functions which might not be implemented as JavaScript. (It is derived from the <a id="realms-settings-objects-global-objects:current-realm" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current
    realm</a>.)</dd><dt><dfn id="concept-relevant-everything">Relevant</dfn></dt><dd>Every <a id="realms-settings-objects-global-objects:platform-object" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> has a <a href="#concept-relevant-realm" id="realms-settings-objects-global-objects:concept-relevant-realm">relevant
    realm</a>, which is roughly the <a id="realms-settings-objects-global-objects:realm-8" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> in which it was created. When writing
    algorithms, the most prominent <a id="realms-settings-objects-global-objects:platform-object-2" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> whose <a href="#concept-relevant-realm" id="realms-settings-objects-global-objects:concept-relevant-realm-2">relevant realm</a> might be important is the <b>this</b>
    value of the currently-running function object. In some cases, there can be other important
    <a href="#concept-relevant-realm" id="realms-settings-objects-global-objects:concept-relevant-realm-3">relevant realms</a>, such as those of any
    arguments.</dd></dl>

  <p>Note how the <a href="#concept-entry-everything" id="realms-settings-objects-global-objects:concept-entry-everything">entry</a>, <a href="#concept-incumbent-everything" id="realms-settings-objects-global-objects:concept-incumbent-everything">incumbent</a>, and <a href="#concept-current-everything" id="realms-settings-objects-global-objects:concept-current-everything">current</a> concepts are usable without qualification,
  whereas the <a href="#concept-relevant-everything" id="realms-settings-objects-global-objects:concept-relevant-everything">relevant</a> concept must be applied to
  a particular <a id="realms-settings-objects-global-objects:platform-object-3" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a>.</p>

  <p class="warning">The <a href="#concept-incumbent-everything" id="realms-settings-objects-global-objects:concept-incumbent-everything-2">incumbent</a> and <a href="#concept-entry-everything" id="realms-settings-objects-global-objects:concept-entry-everything-2">entry</a> concepts should not be used by new specifications,
  as they are excessively complicated and unintuitive to work with. We are working to remove almost
  all existing uses from the platform: see <a href="https://github.com/whatwg/html/issues/1430">issue #1430</a> for <a href="#concept-incumbent-everything" id="realms-settings-objects-global-objects:concept-incumbent-everything-3">incumbent</a>, and <a href="https://github.com/whatwg/html/issues/1431">issue #1431</a> for <a href="#concept-entry-everything" id="realms-settings-objects-global-objects:concept-entry-everything-3">entry</a>.</p>

  <p>In general, web platform specifications should use the <a href="#concept-relevant-everything" id="realms-settings-objects-global-objects:concept-relevant-everything-2">relevant</a> concept, applied to the object being operated
  on (usually the <b>this</b> value of the current method). This mismatches the JavaScript
  specification, where <a href="#concept-current-everything" id="realms-settings-objects-global-objects:concept-current-everything-2">current</a> is generally used as
  the default (e.g., in determining the <a id="realms-settings-objects-global-objects:realm-9" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> whose <code>Array</code>
  constructor should be used to construct the result in <code>Array.prototype.map</code>).
  But this inconsistency is so embedded in the platform that we have to accept it going forward.</p>

  <div class="example">

   <p>Consider the following pages, with <code>a.html</code> being loaded in a browser
   window, <code>b.html</code> being loaded in an <code id="realms-settings-objects-global-objects:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> as shown, and <code>c.html</code> and <code>d.html</code> omitted (they can simply be empty
   documents):</p>

   <pre><code class="html"><c- c="">&lt;!-- a.html --&gt;</c->
<c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Entry page<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"b.html"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"frames[0].hello()"</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->

<c- c="">&lt;!--b.html --&gt;</c->
<c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Incumbent page<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"c.html"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"c"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"d.html"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"d"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">const</c-> c <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"#c"</c-><c- p="">).</c->contentWindow<c- p="">;</c->
  <c- a="">const</c-> d <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"#d"</c-><c- p="">).</c->contentWindow<c- p="">;</c->

  window<c- p="">.</c->hello <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
    c<c- p="">.</c->print<c- p="">.</c->call<c- p="">(</c->d<c- p="">);</c->
  <c- p="">};</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>Each page has its own <a href="#browsing-context" id="realms-settings-objects-global-objects:browsing-context">browsing context</a>, and thus its own <a id="realms-settings-objects-global-objects:realm-10" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>,
   <a href="#global-object" id="realms-settings-objects-global-objects:global-object-13">global object</a>, and <a href="#environment-settings-object" id="realms-settings-objects-global-objects:environment-settings-object-6">environment settings object</a>.</p>

   <p>When the <code id="realms-settings-objects-global-objects:dom-print"><a href="#dom-print">print()</a></code> method is called in response to pressing the
   button in <code>a.html</code>, then:</p>

   <ul><li><p>The <a href="#concept-entry-realm" id="realms-settings-objects-global-objects:concept-entry-realm">entry realm</a> is that of <code>a.html</code>.</p></li><li><p>The <a href="#concept-incumbent-realm" id="realms-settings-objects-global-objects:concept-incumbent-realm">incumbent realm</a> is that of <code>b.html</code>.</p></li><li><p>The <a id="realms-settings-objects-global-objects:current-realm-2" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a> is that of <code>c.html</code> (since it is the
    <code id="realms-settings-objects-global-objects:dom-print-2"><a href="#dom-print">print()</a></code> method from <code>c.html</code> whose code is
    running).</p></li><li><p>The <a href="#concept-relevant-realm" id="realms-settings-objects-global-objects:concept-relevant-realm-4">relevant realm</a> of the object on which
    the <code id="realms-settings-objects-global-objects:dom-print-3"><a href="#dom-print">print()</a></code> method is being called is that of <code>d.html</code>.</p></li></ul>
  </div>

  <div class="example">
   <p>One reason why the <a href="#concept-relevant-everything" id="realms-settings-objects-global-objects:concept-relevant-everything-3">relevant</a> concept is
   generally a better default choice than the <a href="#concept-current-everything" id="realms-settings-objects-global-objects:concept-current-everything-3">current</a> concept is that it is more suitable for
   creating an object that is to be persisted and returned multiple times. For example, the <code id="realms-settings-objects-global-objects:dom-navigator-getbattery"><a data-x-internal="dom-navigator-getbattery" href="https://w3c.github.io/battery/#widl-Navigator-getBattery-Promise-BatteryManager">navigator.getBattery()</a></code> method creates promises in the
   <a href="#concept-relevant-realm" id="realms-settings-objects-global-objects:concept-relevant-realm-5">relevant realm</a> for the <code id="realms-settings-objects-global-objects:navigator"><a href="#navigator">Navigator</a></code> object
   on which it is invoked. This has the following impact: <a href="#refsBATTERY">[BATTERY]</a>

   </p><pre><code class="html"><c- c="">&lt;!-- outer.html --&gt;</c->
<c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Relevant realm demo: outer page<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">function</c-> doTest<c- p="">()</c-> <c- p="">{</c->
    <c- a="">const</c-> promise <c- o="">=</c-> navigator<c- p="">.</c->getBattery<c- p="">.</c->call<c- p="">(</c->frames<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->navigator<c- p="">);</c->

    console<c- p="">.</c->log<c- p="">(</c->promise <c- k="">instanceof</c-> Promise<c- p="">);</c->           <c- c1="">// logs false</c->
    console<c- p="">.</c->log<c- p="">(</c->promise <c- k="">instanceof</c-> frames<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->Promise<c- p="">);</c-> <c- c1="">// logs true</c->

    frames<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->hello<c- p="">();</c->
  <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"inner.html"</c-> <c- e="">onload</c-><c- o="">=</c-><c- s="">"doTest()"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->

<c- c="">&lt;!-- inner.html --&gt;</c->
<c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Relevant realm demo: inner page<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">function</c-> hello<c- p="">()</c-> <c- p="">{</c->
    <c- a="">const</c-> promise <c- o="">=</c-> navigator<c- p="">.</c->getBattery<c- p="">();</c->

    console<c- p="">.</c->log<c- p="">(</c->promise <c- k="">instanceof</c-> Promise<c- p="">);</c->        <c- c1="">// logs true</c->
    console<c- p="">.</c->log<c- p="">(</c->promise <c- k="">instanceof</c-> parent<c- p="">.</c->Promise<c- p="">);</c-> <c- c1="">// logs false</c->
  <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>If the algorithm for the <code id="realms-settings-objects-global-objects:dom-navigator-getbattery-2"><a data-x-internal="dom-navigator-getbattery" href="https://w3c.github.io/battery/#widl-Navigator-getBattery-Promise-BatteryManager">getBattery()</a></code> method
   had instead used the <a id="realms-settings-objects-global-objects:current-realm-3" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a>, all the results would be reversed. That is,
   after the first call to <code id="realms-settings-objects-global-objects:dom-navigator-getbattery-3"><a data-x-internal="dom-navigator-getbattery" href="https://w3c.github.io/battery/#widl-Navigator-getBattery-Promise-BatteryManager">getBattery()</a></code> in <code>outer.html</code>, the <code id="realms-settings-objects-global-objects:navigator-2"><a href="#navigator">Navigator</a></code> object in <code>inner.html</code> would be permanently storing a <code>Promise</code> object
   created in <code>outer.html</code>'s <a id="realms-settings-objects-global-objects:realm-11" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>, and calls like that inside the
   <code>hello()</code> function would thus return a promise from the "wrong" realm. Since
   this is undesirable, the algorithm instead uses the <a href="#concept-relevant-realm" id="realms-settings-objects-global-objects:concept-relevant-realm-6">relevant realm</a>, giving the sensible results indicated in
   the comments above.</p>
  </div>

  <hr>

  <p>The rest of this section deals with formally defining the <a href="#concept-entry-everything" id="realms-settings-objects-global-objects:concept-entry-everything-4">entry</a>, <a href="#concept-incumbent-everything" id="realms-settings-objects-global-objects:concept-incumbent-everything-4">incumbent</a>, <a href="#concept-current-everything" id="realms-settings-objects-global-objects:concept-current-everything-4">current</a>, and <a href="#concept-relevant-everything" id="realms-settings-objects-global-objects:concept-relevant-everything-4">relevant</a> concepts.</p>

  <h6 id="entry"><span class="secno">8.1.3.3.1</span> Entry<a href="#entry" class="self-link"></a></h6>

  <p>The process of <a href="#calling-scripts">calling scripts</a> will push or pop <a href="#realm-execution-context" id="entry:realm-execution-context">realm execution contexts</a> onto the <a id="entry:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript
  execution context stack</a>, interspersed with other <a href="https://tc39.es/ecma262/#sec-execution-contexts" id="entry:javascript-execution-context" data-x-internal="javascript-execution-context">execution contexts</a>.</p>

  <div data-algorithm="">
  <p>With this in hand, we define the <dfn id="entry-execution-context">entry execution context</dfn> to be the most recently
  pushed item in the <a id="entry:javascript-execution-context-stack-2" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> that is a <a href="#realm-execution-context" id="entry:realm-execution-context-2">realm execution context</a>. The <dfn id="concept-entry-realm">entry
  realm</dfn> is the <a href="#entry-execution-context" id="entry:entry-execution-context">entry execution context</a>'s Realm component.</p>
  </div>

  <div data-algorithm="">
  <p>Then, the <dfn id="entry-settings-object">entry settings object</dfn> is the <a href="#concept-realm-settings-object" id="entry:concept-realm-settings-object">environment settings object</a> of the <a href="#concept-entry-realm" id="entry:concept-entry-realm">entry realm</a>.</p>
  </div>

  <div data-algorithm="">
  <p>Similarly, the <dfn id="entry-global-object">entry global object</dfn> is the <a href="#concept-realm-global" id="entry:concept-realm-global">global object</a> of the <a href="#concept-entry-realm" id="entry:concept-entry-realm-2">entry
  realm</a>.</p>
  </div>

  <h6 id="incumbent"><span class="secno">8.1.3.3.2</span> Incumbent<a href="#incumbent" class="self-link"></a></h6>

  <p>All <a href="https://tc39.es/ecma262/#sec-execution-contexts" id="incumbent:javascript-execution-context" data-x-internal="javascript-execution-context">JavaScript execution contexts</a> must
  contain, as part of their code evaluation state, a <dfn id="skip-when-determining-incumbent-counter">skip-when-determining-incumbent
  counter</dfn> value, which is initially zero. In the process of <a href="#prepare-to-run-a-callback" id="incumbent:prepare-to-run-a-callback">preparing to run a callback</a> and <a href="#clean-up-after-running-a-callback" id="incumbent:clean-up-after-running-a-callback">cleaning up after running a callback</a>, this value will be incremented and
  decremented.</p>

  <p>Every <a href="#event-loop" id="incumbent:event-loop">event loop</a> has an associated <dfn id="backup-incumbent-settings-object-stack">backup incumbent settings object
  stack</dfn>, initially empty. Roughly speaking, it is used to determine the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object">incumbent
  settings object</a> when no author code is on the stack, but author code is responsible for the
  current algorithm having been run in some way. The process of <a href="#prepare-to-run-a-callback" id="incumbent:prepare-to-run-a-callback-2">preparing to run a callback</a> and <a href="#clean-up-after-running-a-callback" id="incumbent:clean-up-after-running-a-callback-2">cleaning up after running a callback</a> manipulate this stack. <a href="#refsWEBIDL">[WEBIDL]</a></p>

  <p>When Web IDL is used to <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="incumbent:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">invoke</a> author
  code, or when <a href="#hostenqueuepromisejob" id="incumbent:hostenqueuepromisejob">HostEnqueuePromiseJob</a> invokes a promise job, they use the following
  algorithms to track relevant data for determining the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-2">incumbent settings object</a>:</p>

  <div data-algorithm="">
  <p>To <dfn id="prepare-to-run-a-callback" data-export="">prepare to run a callback</dfn> with an <a href="#environment-settings-object" id="incumbent:environment-settings-object">environment settings object</a>
  <var>settings</var>:</p>

  <ol><li><p>Push <var>settings</var> onto the <a href="#backup-incumbent-settings-object-stack" id="incumbent:backup-incumbent-settings-object-stack">backup incumbent settings object
   stack</a>.</p></li><li><p>Let <var>context</var> be the <a href="#topmost-script-having-execution-context" id="incumbent:topmost-script-having-execution-context">topmost script-having execution
   context</a>.</p></li><li><p>If <var>context</var> is not null, increment <var>context</var>'s
   <a href="#skip-when-determining-incumbent-counter" id="incumbent:skip-when-determining-incumbent-counter">skip-when-determining-incumbent counter</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="clean-up-after-running-a-callback" data-export="">clean up after running a callback</dfn> with an <a href="#environment-settings-object" id="incumbent:environment-settings-object-2">environment settings
  object</a> <var>settings</var>:</p>

  <ol><li>
    <p>Let <var>context</var> be the <a href="#topmost-script-having-execution-context" id="incumbent:topmost-script-having-execution-context-2">topmost script-having execution context</a>.</p>

    <p class="note">This will be the same as the <a href="#topmost-script-having-execution-context" id="incumbent:topmost-script-having-execution-context-3">topmost script-having execution
    context</a> inside the corresponding invocation of <a href="#prepare-to-run-a-callback" id="incumbent:prepare-to-run-a-callback-3">prepare to run a
    callback</a>.</p>
   </li><li><p>If <var>context</var> is not null, decrement <var>context</var>'s
   <a href="#skip-when-determining-incumbent-counter" id="incumbent:skip-when-determining-incumbent-counter-2">skip-when-determining-incumbent counter</a>.</p></li><li><p><a id="incumbent:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: the topmost entry of the <a href="#backup-incumbent-settings-object-stack" id="incumbent:backup-incumbent-settings-object-stack-2">backup incumbent settings object
   stack</a> is <var>settings</var>.</p></li><li><p>Remove <var>settings</var> from the <a href="#backup-incumbent-settings-object-stack" id="incumbent:backup-incumbent-settings-object-stack-3">backup incumbent settings object
   stack</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Here, the <dfn id="topmost-script-having-execution-context">topmost script-having execution context</dfn> is the topmost entry of the
  <a id="incumbent:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> that has a non-null ScriptOrModule component, or
  null if there is no such entry in the <a id="incumbent:javascript-execution-context-stack-2" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a>.</p>
  </div>

  <div data-algorithm="">
  <p>With all this in place, the <dfn id="incumbent-settings-object" data-export="">incumbent settings object</dfn> is determined as
  follows:</p>

  <ol><li><p>Let <var>context</var> be the <a href="#topmost-script-having-execution-context" id="incumbent:topmost-script-having-execution-context-4">topmost script-having execution
   context</a>.</p></li><li>
    <p>If <var>context</var> is null, or if <var>context</var>'s
    <a href="#skip-when-determining-incumbent-counter" id="incumbent:skip-when-determining-incumbent-counter-3">skip-when-determining-incumbent counter</a> is greater than zero, then:</p>

    <ol><li>
      <p><a id="incumbent:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: the <a href="#backup-incumbent-settings-object-stack" id="incumbent:backup-incumbent-settings-object-stack-4">backup incumbent settings object stack</a> is not
      empty.</p>

      <p class="note">This assert would fail if you try to obtain the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-3">incumbent settings
      object</a> from inside an algorithm that was triggered neither by <a href="#calling-scripts">calling scripts</a> nor by Web IDL <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="incumbent:es-invoking-callback-functions-2" data-x-internal="es-invoking-callback-functions">invoking</a> a callback. For example, it would
      trigger if you tried to obtain the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-4">incumbent settings object</a> inside an algorithm
      that ran periodically as part of the <a href="#event-loop" id="incumbent:event-loop-2">event loop</a>, with no involvement of author
      code. In such cases the <a href="#concept-incumbent-everything" id="incumbent:concept-incumbent-everything">incumbent</a> concept
      cannot be used.</p>
     </li><li><p>Return the topmost entry of the <a href="#backup-incumbent-settings-object-stack" id="incumbent:backup-incumbent-settings-object-stack-5">backup incumbent settings object
     stack</a>.</p></li></ol>
   </li><li><p>Return <var>context</var>'s Realm component's <a href="#concept-realm-settings-object" id="incumbent:concept-realm-settings-object">settings object</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Then, the <dfn id="concept-incumbent-realm" data-export="">incumbent realm</dfn> is the <a href="#environment-settings-object's-realm" id="incumbent:environment-settings-object's-realm">realm</a> of the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-5">incumbent settings
  object</a>.</p>
  </div>

  <div data-algorithm="">
  <p>Similarly, the <dfn id="concept-incumbent-global" data-export="">incumbent global object</dfn> is
  the <a href="#concept-settings-object-global" id="incumbent:concept-settings-object-global">global object</a> of the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-6">incumbent
  settings object</a>.</p>
  </div>

  <hr>

  <p>The following series of examples is intended to make it clear how all of the different
  mechanisms contribute to the definition of the <a href="#incumbent">incumbent</a> concept:</p>

  <div id="example-incumbent-1" class="example"><a href="#example-incumbent-1" class="self-link"></a>
   <p>Consider the following starter example:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  frames<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->postMessage<c- p="">(</c-><c- u="">"some data"</c-><c- p="">,</c-> <c- u="">"*"</c-><c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>There are two interesting <a href="#environment-settings-object" id="incumbent:environment-settings-object-3">environment settings
   objects</a> here: that of <code>window</code>, and that of <code>frames[0]</code>. Our concern is: what is the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-7">incumbent settings object</a> at
   the time that the algorithm for <code id="incumbent:dom-window-postmessage"><a href="#dom-window-postmessage">postMessage()</a></code>
   executes?</p>

   <p>It should be that of <code>window</code>, to capture the intuitive notion that the
   author script responsible for causing the algorithm to happen is executing in <code>window</code>, not <code>frames[0]</code>. This makes sense: the <a href="#window-post-message-steps" id="incumbent:window-post-message-steps">window
   post message steps</a> use the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-8">incumbent settings object</a> to determine the <code id="incumbent:dom-messageevent-source"><a href="#dom-messageevent-source">source</a></code> property of the resulting
   <code id="incumbent:messageevent"><a href="#messageevent">MessageEvent</a></code>, and in this case <code>window</code> is definitely the
   source of the message.</p>

   <p>Let us now explain how the steps given above give us our intuitively-desired result of <code>window</code>'s <a href="#relevant-settings-object" id="incumbent:relevant-settings-object">relevant settings object</a>.</p>

   <p>When the <a href="#window-post-message-steps" id="incumbent:window-post-message-steps-2">window post message steps</a> look up the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-9">incumbent settings
   object</a>, the <a href="#topmost-script-having-execution-context" id="incumbent:topmost-script-having-execution-context-5">topmost script-having execution context</a> will be that
   corresponding to the <code id="incumbent:the-script-element"><a href="#the-script-element">script</a></code> element: it was pushed onto the <a id="incumbent:javascript-execution-context-stack-3" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript
   execution context stack</a> as part of <a href="https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation" id="incumbent:js-scriptevaluation" data-x-internal="js-scriptevaluation">ScriptEvaluation</a> during the <a href="#run-a-classic-script" id="incumbent:run-a-classic-script">run a classic script</a>
   algorithm. Since there are no Web IDL callback invocations involved, the context's
   <a href="#skip-when-determining-incumbent-counter" id="incumbent:skip-when-determining-incumbent-counter-4">skip-when-determining-incumbent counter</a> is zero, so it is used to determine the
   <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-10">incumbent settings object</a>; the result is the <a href="#environment-settings-object" id="incumbent:environment-settings-object-4">environment settings
   object</a> of <code>window</code>.</p>

   <p>(Note how the <a href="#environment-settings-object" id="incumbent:environment-settings-object-5">environment settings object</a> of <code>frames[0]</code> is
   the <a href="#relevant-settings-object" id="incumbent:relevant-settings-object-2">relevant settings object</a> of <a id="incumbent:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> at the time the <code id="incumbent:dom-window-postmessage-2"><a href="#dom-window-postmessage">postMessage()</a></code> method is called, and thus is involved in
   determining the <em>target</em> of the message. Whereas the incumbent is used to determine the
   <em>source</em>.)
  </p></div>

  <div id="example-incumbent-2" class="example"><a href="#example-incumbent-2" class="self-link"></a>
   <p>Consider the following more complicated example:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">const</c-> bound <c- o="">=</c-> frames<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->postMessage<c- p="">.</c->bind<c- p="">(</c->frames<c- p="">[</c-><c- mf="">0</c-><c- p="">],</c-> <c- u="">"some data"</c-><c- p="">,</c-> <c- u="">"*"</c-><c- p="">);</c->
  window<c- p="">.</c->setTimeout<c- p="">(</c->bound<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>This example is very similar to the previous one, but with an extra indirection through <code>Function.prototype.bind</code> as well as <code id="incumbent:dom-settimeout"><a href="#dom-settimeout">setTimeout()</a></code>. But, the answer should be the same: invoking
   algorithms asynchronously should not change the <a href="#concept-incumbent-everything" id="incumbent:concept-incumbent-everything-2">incumbent</a> concept.</p>

   <p>This time, the result involves more complicated mechanisms:</p>

   <p>When <code>bound</code> is <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="incumbent:concept-idl-convert" data-x-internal="concept-idl-convert">converted</a> to a
   Web IDL callback type, the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-11">incumbent settings object</a> is that corresponding to <code>window</code> (in the same manner as in our starter example above). Web IDL stores this
   as the resulting callback value's <a id="incumbent:callback-context" href="https://webidl.spec.whatwg.org/#dfn-callback-context" data-x-internal="callback-context">callback context</a>.</p>

   <p>When the <a href="#concept-task" id="incumbent:concept-task">task</a> posted by <code id="incumbent:dom-settimeout-2"><a href="#dom-settimeout">setTimeout()</a></code> executes, the algorithm for that task uses Web IDL to
   <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="incumbent:es-invoking-callback-functions-3" data-x-internal="es-invoking-callback-functions">invoke</a> the stored callback value. Web IDL in
   turn calls the above <a href="#prepare-to-run-a-callback" id="incumbent:prepare-to-run-a-callback-4">prepare to run a callback</a> algorithm. This pushes the stored
   <a id="incumbent:callback-context-2" href="https://webidl.spec.whatwg.org/#dfn-callback-context" data-x-internal="callback-context">callback context</a> onto the <a href="#backup-incumbent-settings-object-stack" id="incumbent:backup-incumbent-settings-object-stack-6">backup incumbent settings object stack</a>. At
   this time (inside the timer task) there is no author code on the stack, so the <a href="#topmost-script-having-execution-context" id="incumbent:topmost-script-having-execution-context-6">topmost
   script-having execution context</a> is null, and nothing gets its
   <a href="#skip-when-determining-incumbent-counter" id="incumbent:skip-when-determining-incumbent-counter-5">skip-when-determining-incumbent counter</a> incremented.</p>

   <p>Invoking the callback then calls <code>bound</code>, which in turn calls
   the <code id="incumbent:dom-window-postmessage-3"><a href="#dom-window-postmessage">postMessage()</a></code> method of <code>frames[0]</code>. When the <code id="incumbent:dom-window-postmessage-4"><a href="#dom-window-postmessage">postMessage()</a></code>
   algorithm looks up the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-12">incumbent settings object</a>, there is still no author code on
   the stack, since the bound function just directly calls the built-in method. So the
   <a href="#topmost-script-having-execution-context" id="incumbent:topmost-script-having-execution-context-7">topmost script-having execution context</a> will be null: the <a id="incumbent:javascript-execution-context-2" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript execution
   context</a> stack only contains an execution context corresponding to <code id="incumbent:dom-window-postmessage-5"><a href="#dom-window-postmessage">postMessage()</a></code>, with no <a href="https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation" id="incumbent:js-scriptevaluation-2" data-x-internal="js-scriptevaluation">ScriptEvaluation</a> context or similar below it.</p>

   <p>This is where we fall back to the <a href="#backup-incumbent-settings-object-stack" id="incumbent:backup-incumbent-settings-object-stack-7">backup incumbent settings object stack</a>. As
   noted above, it will contain as its topmost entry the <a href="#relevant-settings-object" id="incumbent:relevant-settings-object-3">relevant settings object</a> of
   <code>window</code>. So that is what is used as the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-13">incumbent settings
   object</a> while executing the <code id="incumbent:dom-window-postmessage-6"><a href="#dom-window-postmessage">postMessage()</a></code>
   algorithm.</p>
  </div>

  <div id="example-incumbent-3" class="example"><a href="#example-incumbent-3" class="self-link"></a>
   <p>Consider this final, even more convoluted example:</p>

   <pre><code class="html"><c- c="">&lt;!-- a.html --&gt;</c->
<c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->click me<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- a="">const</c-> bound <c- o="">=</c-> frames<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->location<c- p="">.</c->assign<c- p="">.</c->bind<c- p="">(</c->frames<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->location<c- p="">,</c-> <c- u="">"https://example.com/"</c-><c- p="">);</c->
document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"button"</c-><c- p="">).</c->addEventListener<c- p="">(</c-><c- u="">"click"</c-><c- p="">,</c-> bound<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <pre><code class="html"><c- c="">&lt;!-- b.html --&gt;</c->
<c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"a.html"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">const</c-> iframe <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"iframe"</c-><c- p="">);</c->
  iframe<c- p="">.</c->onload <c- o="">=</c-> <c- a="">function</c-> onLoad<c- p="">()</c-> <c- p="">{</c->
    iframe<c- p="">.</c->contentWindow<c- p="">.</c->document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"button"</c-><c- p="">).</c->click<c- p="">();</c->
  <c- p="">};</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>Again there are two interesting <a href="#environment-settings-object" id="incumbent:environment-settings-object-6">environment
   settings objects</a> in play: that of <code>a.html</code>, and that of <code>b.html</code>. When the <code id="incumbent:dom-location-assign"><a href="#dom-location-assign">location.assign()</a></code>
   method triggers the <a href="#location-object-navigate" id="incumbent:location-object-navigate"><code>Location</code>-object navigate</a> algorithm, what will be
   the <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-14">incumbent settings object</a>? As before, it should intuitively be that of <code>a.html</code>: the <code id="incumbent:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> listener was originally
   scheduled by <code>a.html</code>, so even if something involving <code>b.html</code> causes the listener to fire, the <a href="#concept-incumbent-everything" id="incumbent:concept-incumbent-everything-3">incumbent</a> responsible is that of <code>a.html</code>.</p>

   <p>The callback setup is similar to the previous example: when <code>bound</code> is
   <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="incumbent:concept-idl-convert-2" data-x-internal="concept-idl-convert">converted</a> to a Web IDL callback type, the
   <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-15">incumbent settings object</a> is that corresponding to <code>a.html</code>,
   which is stored as the callback's <a id="incumbent:callback-context-3" href="https://webidl.spec.whatwg.org/#dfn-callback-context" data-x-internal="callback-context">callback context</a>.</p>

   <p>When the <code id="incumbent:dom-click"><a href="#dom-click">click()</a></code> method is called inside <code>b.html</code>, it <a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="incumbent:concept-event-dispatch" data-x-internal="concept-event-dispatch">dispatches</a> a <code id="incumbent:event-click-2"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event on the button that is inside <code>a.html</code>. This time, when the <a href="#prepare-to-run-a-callback" id="incumbent:prepare-to-run-a-callback-5">prepare to run a callback</a> algorithm
   executes as part of event dispatch, there <em>is</em> author code on the stack; the <a href="#topmost-script-having-execution-context" id="incumbent:topmost-script-having-execution-context-8">topmost
   script-having execution context</a> is that of the <code>onLoad</code> function,
   whose <a href="#skip-when-determining-incumbent-counter" id="incumbent:skip-when-determining-incumbent-counter-6">skip-when-determining-incumbent counter</a> gets incremented. Additionally, <code>a.html</code>'s <a href="#environment-settings-object" id="incumbent:environment-settings-object-7">environment settings object</a> (stored as the
   <code id="incumbent:eventhandler"><a href="#eventhandler">EventHandler</a></code>'s <a id="incumbent:callback-context-4" href="https://webidl.spec.whatwg.org/#dfn-callback-context" data-x-internal="callback-context">callback context</a>) is pushed onto the
   <a href="#backup-incumbent-settings-object-stack" id="incumbent:backup-incumbent-settings-object-stack-8">backup incumbent settings object stack</a>.</p>

   <p>Now, when the <a href="#location-object-navigate" id="incumbent:location-object-navigate-2"><code>Location</code>-object navigate</a> algorithm looks up the
   <a href="#incumbent-settings-object" id="incumbent:incumbent-settings-object-16">incumbent settings object</a>, the <a href="#topmost-script-having-execution-context" id="incumbent:topmost-script-having-execution-context-9">topmost script-having execution
   context</a> is still that of the <code>onLoad</code> function (due to the fact we
   are using a bound function as the callback). Its <a href="#skip-when-determining-incumbent-counter" id="incumbent:skip-when-determining-incumbent-counter-7">skip-when-determining-incumbent
   counter</a> value is one, however, so we fall back to the <a href="#backup-incumbent-settings-object-stack" id="incumbent:backup-incumbent-settings-object-stack-9">backup incumbent settings
   object stack</a>. This gives us the <a href="#environment-settings-object" id="incumbent:environment-settings-object-8">environment settings object</a> of <code>a.html</code>, as expected.</p>

   <p>Note that this means that even though it is the <code id="incumbent:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> inside <code>a.html</code> that navigates, it is <code>a.html</code> itself that is used
   as the source <code id="incumbent:document"><a href="#document">Document</a></code>, which determines among other things the <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="incumbent:concept-request-client" data-x-internal="concept-request-client">request client</a>. This is <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=26603#c36">perhaps the only justifiable use
   of the incumbent concept on the web platform</a>; in all other cases the consequences of using it
   are simply confusing and we hope to one day switch them to use <a href="#concept-current-everything" id="incumbent:concept-current-everything">current</a> or <a href="#concept-relevant-everything" id="incumbent:concept-relevant-everything">relevant</a> as appropriate.</p>
  </div>

  <h6 id="current"><span class="secno">8.1.3.3.3</span> Current<a href="#current" class="self-link"></a></h6>

  <p>The JavaScript specification defines the <a id="current:current-realm" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a>, also known as the "current
  Realm Record". <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <div data-algorithm="">
  <p>Then, the <dfn id="current-settings-object" data-export="">current settings object</dfn> is the <a href="#concept-realm-settings-object" id="current:concept-realm-settings-object">environment settings object</a> of the <a id="current:current-realm-2" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current
  realm</a>.</p>
  </div>

  <div data-algorithm="">
  <p>Similarly, the <dfn id="current-global-object" data-export="">current global object</dfn> is the <a href="#concept-realm-global" id="current:concept-realm-global">global object</a> of the <a id="current:current-realm-3" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a>.</p>
  </div>

  <h6 id="relevant"><span class="secno">8.1.3.3.4</span> Relevant<a href="#relevant" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>The <dfn id="concept-relevant-realm" data-export="">relevant realm</dfn> for a <a id="relevant:platform-object" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform
  object</a> is the value of <a href="https://webidl.spec.whatwg.org/#es-platform-objects" id="relevant:realm-field-of-a-platform-object" data-x-internal="realm-field-of-a-platform-object">its [[Realm]]
  field</a>.</p>
  </div>

  <div data-algorithm="">
  <p>Then, the <dfn id="relevant-settings-object" data-export="">relevant settings object</dfn> for a <a id="relevant:platform-object-2" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a>
  <var>o</var> is the <a href="#concept-realm-settings-object" id="relevant:concept-realm-settings-object">environment settings
  object</a> of the <a href="#concept-relevant-realm" id="relevant:concept-relevant-realm">relevant realm</a> for
  <var>o</var>.</p>
  </div>

  <div data-algorithm="">
  <p>Similarly, the <dfn id="concept-relevant-global" data-export="">relevant global object</dfn> for a
  <a id="relevant:platform-object-3" href="https://webidl.spec.whatwg.org/#dfn-platform-object" data-x-internal="platform-object">platform object</a> <var>o</var> is the <a href="#concept-realm-global" id="relevant:concept-realm-global">global
  object</a> of the <a href="#concept-relevant-realm" id="relevant:concept-relevant-realm-2">relevant realm</a> for
  <var>o</var>.</p>
  </div>

  <h5 id="enabling-and-disabling-scripting"><span class="secno">8.1.3.4</span> Enabling and disabling scripting<a href="#enabling-and-disabling-scripting" class="self-link"></a></h5>

  <div data-algorithm="">
  <p id="concept-bc-script"><dfn id="concept-environment-script">Scripting is enabled</dfn> for
  an <a href="#environment-settings-object" id="enabling-and-disabling-scripting:environment-settings-object">environment settings object</a> <var>settings</var> when all of the following
  conditions are true:</p>

  <ul><li>The user agent supports scripting.</li><li>
   <a id="enabling-and-disabling-scripting:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
   The user has not disabled scripting for <var>settings</var> at this time. (User agents may
   provide users with the option to disable scripting globally, or in a finer-grained manner, e.g.,
   on a per-origin basis, down to the level of individual <a href="#environment-settings-object" id="enabling-and-disabling-scripting:environment-settings-object-2">environment settings objects</a>.)</li><li id="sandboxScriptBlocked">Either <var>settings</var>'s <a href="#concept-settings-object-global" id="enabling-and-disabling-scripting:concept-settings-object-global">global object</a> is not a <code id="enabling-and-disabling-scripting:window"><a href="#window">Window</a></code> object,
   or <var>settings</var>'s <a href="#concept-settings-object-global" id="enabling-and-disabling-scripting:concept-settings-object-global-2">global object</a>'s
   <a href="#concept-document-window" id="enabling-and-disabling-scripting:concept-document-window">associated <code>Document</code></a>'s <a href="#active-sandboxing-flag-set" id="enabling-and-disabling-scripting:active-sandboxing-flag-set">active
   sandboxing flag set</a> does not have its <a href="#sandboxed-scripts-browsing-context-flag" id="enabling-and-disabling-scripting:sandboxed-scripts-browsing-context-flag">sandboxed scripts browsing context flag</a>
   set.</li></ul>
  </div>

  <div data-algorithm="">
  <p id="concept-bc-noscript"><dfn id="concept-environment-noscript">Scripting is disabled</dfn>
  for an <a href="#environment-settings-object" id="enabling-and-disabling-scripting:environment-settings-object-3">environment settings object</a> when scripting is not <a href="#concept-environment-script" id="enabling-and-disabling-scripting:concept-environment-script">enabled</a> for it, i.e., when any of the above conditions
  are false.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p><dfn id="concept-n-script">Scripting is enabled</dfn> for a node <var>node</var> if
  <var>node</var>'s <a id="enabling-and-disabling-scripting:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#concept-document-bc" id="enabling-and-disabling-scripting:concept-document-bc">browsing
  context</a> is non-null, and <a href="#concept-environment-script" id="enabling-and-disabling-scripting:concept-environment-script-2">scripting is
  enabled</a> for <var>node</var>'s <a href="#relevant-settings-object" id="enabling-and-disabling-scripting:relevant-settings-object">relevant settings object</a>.</p>
  </div>

  <p><dfn id="concept-n-noscript">Scripting is disabled</dfn> for a node when scripting is not
  <a href="#concept-n-script" id="enabling-and-disabling-scripting:concept-n-script">enabled</a>, i.e., when its <a id="enabling-and-disabling-scripting:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#concept-document-bc" id="enabling-and-disabling-scripting:concept-document-bc-2">browsing context</a> is null or when <a href="#concept-environment-noscript" id="enabling-and-disabling-scripting:concept-environment-noscript">scripting is disabled</a> for its <a href="#relevant-settings-object" id="enabling-and-disabling-scripting:relevant-settings-object-2">relevant settings
  object</a>.</p>

  <h5 id="secure-contexts"><span class="secno">8.1.3.5</span> Secure contexts<a href="#secure-contexts" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>An <a href="#environment" id="secure-contexts:environment">environment</a> <var>environment</var> is a <dfn id="secure-context" data-lt="secure context|Is
  an environment settings object contextually secure?" data-export="">secure context</dfn> if the following
  algorithm returns true:</p>

  <ol><li>
    <p>If <var>environment</var> is an <a href="#environment-settings-object" id="secure-contexts:environment-settings-object">environment settings object</a>, then:</p>

    <ol><li><p>Let <var>global</var> be <var>environment</var>'s <a href="#concept-settings-object-global" id="secure-contexts:concept-settings-object-global">global object</a>.</p></li><li>
      <p>If <var>global</var> is a <code id="secure-contexts:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code>, then:

      </p><ol><li>
        <p>If <var>global</var>'s <a href="#concept-WorkerGlobalScope-owner-set" id="secure-contexts:concept-WorkerGlobalScope-owner-set">owner set</a>[0]'s <a href="#relevant-settings-object" id="secure-contexts:relevant-settings-object">relevant settings object</a>
        is a <a href="#secure-context" id="secure-contexts:secure-context">secure context</a>, then return true.</p>

        <p class="note">We only need to check the 0th item since they will necessarily all be
        consistent.</p>
       </li><li><p>Return false.</p></li></ol>
     </li><li>
      <p>If <var>global</var> is a <code id="secure-contexts:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>, then return true.</p>

      <p class="note">Worklets can only be created in secure contexts.</p>
     </li></ol>
   </li><li><p>If the result of <a id="secure-contexts:is-url-potentially-trustworthy" href="https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url" data-x-internal="is-url-potentially-trustworthy">Is url potentially trustworthy?</a> given
   <var>environment</var>'s <a href="#concept-environment-top-level-creation-url" id="secure-contexts:concept-environment-top-level-creation-url">top-level creation URL</a> is "<code>Potentially
   Trustworthy</code>", then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>An <a href="#environment" id="secure-contexts:environment-2">environment</a> is a <dfn id="non-secure-context" data-export="">non-secure context</dfn> if it is not a
  <a href="#secure-context" id="secure-contexts:secure-context-2">secure context</a>.</p>
  </div>

  

  <h4 id="scripting-processing-model"><span class="secno">8.1.4</span> <span id="processing-model-7"></span>Script processing
  model<a href="#scripting-processing-model" class="self-link"></a></h4>

  

  <h5 id="script-structs"><span class="secno">8.1.4.1</span> <span id="definitions-2"></span>Scripts<a href="#script-structs" class="self-link"></a></h5>

  <p>A <dfn id="concept-script" data-export="">script</dfn> is one of two possible <a href="https://infra.spec.whatwg.org/#struct" id="script-structs:struct" data-x-internal="struct">structs</a> (namely, a <a href="#classic-script" id="script-structs:classic-script">classic script</a> or a
  <a href="#module-script" id="script-structs:module-script">module script</a>). All scripts have:</p>

  <dl><dt>A <dfn data-dfn-for="script" id="settings-object" data-export="">settings object</dfn></dt><dd><p>An <a href="#environment-settings-object" id="script-structs:environment-settings-object">environment settings object</a>, containing various settings that are shared
   with other <a href="#concept-script" id="script-structs:concept-script">scripts</a> in the same context.</p></dd><dt>A <dfn data-dfn-for="script" id="concept-script-record" data-export="">record</dfn></dt><dd>
    <p>One of the following:</p>

    <ul><li><p>a <a id="script-structs:script-record" href="https://tc39.es/ecma262/#sec-script-records" data-x-internal="script-record">script record</a>, for <a href="#classic-script" id="script-structs:classic-script-2">classic
     scripts</a>;</p></li><li><p>a <a id="script-structs:source-text-module-record" href="https://tc39.es/ecma262/#sec-source-text-module-records" data-x-internal="source-text-module-record">Source Text Module Record</a>, for <a href="#javascript-module-script" id="script-structs:javascript-module-script">JavaScript module scripts</a>;</p></li><li><p>a <a id="script-structs:synthetic-module-record" href="https://tc39.es/ecma262/#sec-synthetic-module-records" data-x-internal="synthetic-module-record">Synthetic Module Record</a>, for <a href="#css-module-script" id="script-structs:css-module-script">CSS module
     scripts</a> and <a href="#json-module-script" id="script-structs:json-module-script">JSON module scripts</a>;</p></li><li><p>a <a id="script-structs:webassembly-module-record" href="https://webassembly.github.io/esm-integration/js-api/index.html#webassembly-module-record" data-x-internal="webassembly-module-record">WebAssembly Module Record</a>, for <a href="#webassembly-module-script" id="script-structs:webassembly-module-script">WebAssembly module scripts</a>; or</p></li><li><p>null, representing a parsing failure.</p></li></ul>
   </dd><dt>A <dfn data-dfn-for="script" id="concept-script-parse-error">parse error</dfn></dt><dd>
    <p>A JavaScript value, which has meaning only if the <a href="#concept-script-record" id="script-structs:concept-script-record">record</a> is null, indicating that the corresponding script
    source text could not be parsed.</p>

    <p class="note">This value is used for internal tracking of immediate parse errors when <a href="#creating-scripts">creating scripts</a>, and is not to be used directly. Instead, consult
    the <a href="#concept-script-error-to-rethrow" id="script-structs:concept-script-error-to-rethrow">error to rethrow</a> when determining
    "what went wrong" for this script.</p>
  </dd><dt>An <dfn data-dfn-for="script" id="concept-script-error-to-rethrow" data-export="">error
   to rethrow</dfn></dt><dd>
    <p>A JavaScript value representing an error that will prevent evaluation from succeeding. It
    will be re-thrown by any attempts to <a href="#calling-scripts">run</a> the script.</p>

    <p class="note">This could be the script's <a href="#concept-script-parse-error" id="script-structs:concept-script-parse-error">parse
    error</a>, but in the case of a <a href="#module-script" id="script-structs:module-script-2">module script</a> it could instead be the
    <a href="#concept-script-parse-error" id="script-structs:concept-script-parse-error-2">parse error</a> from one of its dependencies, or
    an error from <a href="#resolve-a-module-specifier" id="script-structs:resolve-a-module-specifier">resolve a module specifier</a>.</p>

    <p class="note">Since this exception value is provided by the JavaScript specification, we know
    that it is never null, so we use null to signal that no error has occurred.</p>
   </dd><dt><dfn data-dfn-for="script" id="concept-script-script-fetch-options" data-export="">Fetch options</dfn></dt><dd>Null or a <a href="#script-fetch-options" id="script-structs:script-fetch-options">script fetch options</a>, containing various options related to fetching
   this script or <a href="#module-script" id="script-structs:module-script-3">module scripts</a> that it imports.</dd><dt>A <dfn data-dfn-for="script" id="concept-script-base-url" data-export="">base
   URL</dfn></dt><dd><p>Null or a base <a id="script-structs:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> used for <a href="#resolve-a-module-specifier" id="script-structs:resolve-a-module-specifier-2">resolving module specifiers</a>. When non-null, this will either be the URL from
   which the script was obtained, for external scripts, or the <a href="#document-base-url" id="script-structs:document-base-url">document base URL</a> of the
   containing document, for inline scripts.</p></dd></dl>


  <p>A <dfn id="classic-script" data-export="">classic script</dfn> is a type of <a href="#concept-script" id="script-structs:concept-script-2">script</a>
  that has the following additional <a href="https://infra.spec.whatwg.org/#struct-item" id="script-structs:struct-item" data-x-internal="struct-item">item</a>:</p>

  <dl><dt>A <dfn id="muted-errors">muted errors</dfn> boolean</dt><dd><p>A boolean which, if true, means that error information will not be provided for errors in
   this script. This is used to mute errors for cross-origin scripts, since that can leak private
   information.</p></dd></dl>

  <p>A <dfn id="module-script" data-export="">module script</dfn> is another type of <a href="#concept-script" id="script-structs:concept-script-3">script</a>. It has no additional <a href="https://infra.spec.whatwg.org/#struct-item" id="script-structs:struct-item-2" data-x-internal="struct-item">items</a>.</p>

  <p><a href="#module-script" id="script-structs:module-script-4">Module scripts</a> can be classified into four types:</p>

  <ul><li>
    <div data-algorithm="">
    <p>A <a href="#module-script" id="script-structs:module-script-5">module script</a> is a <dfn id="javascript-module-script" data-export="">JavaScript module script</dfn> if
    its <a href="#concept-script-record" id="script-structs:concept-script-record-2">record</a> is a <a id="script-structs:source-text-module-record-2" href="https://tc39.es/ecma262/#sec-source-text-module-records" data-x-internal="source-text-module-record">Source Text Module
    Record</a>.</p>
    </div>
   </li><li>
    <div data-algorithm="">
    <p>A <a href="#module-script" id="script-structs:module-script-6">module script</a> is a <dfn id="css-module-script" data-export="">CSS module script</dfn> if its <a href="#concept-script-record" id="script-structs:concept-script-record-3">record</a> is a <a id="script-structs:synthetic-module-record-2" href="https://tc39.es/ecma262/#sec-synthetic-module-records" data-x-internal="synthetic-module-record">Synthetic Module Record</a>, and it
    was created via the <a href="#creating-a-css-module-script" id="script-structs:creating-a-css-module-script">create a CSS module
    script</a> algorithm. CSS module scripts represent a parsed CSS style sheet.</p>
    </div>

    
   </li><li>
    <div data-algorithm="">
    <p>A <a href="#module-script" id="script-structs:module-script-7">module script</a> is a <dfn id="json-module-script" data-export="">JSON module script</dfn> if its <a href="#concept-script-record" id="script-structs:concept-script-record-4">record</a> is a <a id="script-structs:synthetic-module-record-3" href="https://tc39.es/ecma262/#sec-synthetic-module-records" data-x-internal="synthetic-module-record">Synthetic Module Record</a>, and it
    was created via the <a href="#creating-a-json-module-script" id="script-structs:creating-a-json-module-script">create a JSON module
    script</a> algorithm. JSON module scripts represent a parsed JSON document.</p>
    </div>

    
   </li><li>
    <div data-algorithm="">
    <p>A <a href="#module-script" id="script-structs:module-script-8">module script</a> is a <dfn id="webassembly-module-script" data-export="">WebAssembly module script</dfn> if
    its <a href="#concept-script-record" id="script-structs:concept-script-record-5">record</a> is a <a id="script-structs:webassembly-module-record-2" href="https://webassembly.github.io/esm-integration/js-api/index.html#webassembly-module-record" data-x-internal="webassembly-module-record">WebAssembly Module
    Record</a>.</p>
    </div>
   </li></ul>

  <p class="note">As CSS style sheets and JSON documents do not import dependent modules, and do not
  throw exceptions on evaluation, the <a href="#concept-script-script-fetch-options" id="script-structs:concept-script-script-fetch-options">fetch
  options</a> and <a href="#concept-script-base-url" id="script-structs:concept-script-base-url">base URL</a> of <a href="#css-module-script" id="script-structs:css-module-script-2">CSS module scripts</a> and <a href="#json-module-script" id="script-structs:json-module-script-2">JSON module
  scripts</a> and are always null.</p>

  <div data-algorithm="">
  <p>The <dfn id="active-script">active script</dfn> is determined by the following algorithm:</p>

  <ol><li><p>Let <var>record</var> be <a id="script-structs:getactivescriptormodule" href="https://tc39.es/ecma262/#sec-getactivescriptormodule" data-x-internal="getactivescriptormodule">GetActiveScriptOrModule</a>().</p></li><li><p>If <var>record</var> is null, return null.</p></li><li><p>Return <var>record</var>.[[HostDefined]].</p></li></ol>
  </div>

  <p class="note">The <a href="#active-script" id="script-structs:active-script">active script</a> concept is so far only used by the
  <code id="script-structs:import()"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> feature, to determine the <a href="#concept-script-base-url" id="script-structs:concept-script-base-url-2">base
  URL</a> to use for resolving relative module specifiers.</p>

  <h5 id="fetching-scripts"><span class="secno">8.1.4.2</span> Fetching scripts<a href="#fetching-scripts" class="self-link"></a></h5>

  <p>This section introduces a number of algorithms for fetching scripts, taking various necessary
  inputs and resulting in <a href="#classic-script" id="fetching-scripts:classic-script">classic</a> or <a href="#module-script" id="fetching-scripts:module-script">module scripts</a>.</p>

  <hr>

  <p><dfn id="script-fetch-options">Script fetch options</dfn> is a <a id="fetching-scripts:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="fetching-scripts:struct-item" data-x-internal="struct-item">items</a>:</p>

  <dl><dt><dfn id="concept-script-fetch-options-nonce">cryptographic nonce</dfn></dt><dd><p>The <a href="https://fetch.spec.whatwg.org/#concept-request-nonce-metadata" id="fetching-scripts:concept-request-nonce-metadata" data-x-internal="concept-request-nonce-metadata">cryptographic nonce metadata</a> used
   for the initial fetch and for fetching any imported modules</p></dd><dt><dfn id="concept-script-fetch-options-integrity">integrity metadata</dfn></dt><dd><p>The <a href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata" id="fetching-scripts:concept-request-integrity-metadata" data-x-internal="concept-request-integrity-metadata">integrity metadata</a> used for
   the initial fetch</p></dd><dt><dfn id="concept-script-fetch-options-parser">parser metadata</dfn></dt><dd><p>The <a href="https://fetch.spec.whatwg.org/#concept-request-parser-metadata" id="fetching-scripts:concept-request-parser-metadata" data-x-internal="concept-request-parser-metadata">parser metadata</a> used for the
   initial fetch and for fetching any imported modules</p></dd><dt><dfn id="concept-script-fetch-options-credentials">credentials mode</dfn></dt><dd><p>The <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="fetching-scripts:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> used for the
   initial fetch (for <a href="#module-script" id="fetching-scripts:module-script-2">module scripts</a>) and for fetching any
   imported modules (for both <a href="#module-script" id="fetching-scripts:module-script-3">module scripts</a> and <a href="#classic-script" id="fetching-scripts:classic-script-2">classic scripts</a>)</p></dd><dt><dfn id="concept-script-fetch-options-referrer-policy">referrer policy</dfn></dt><dd>
    <p>The <a href="https://fetch.spec.whatwg.org/#concept-request-referrer-policy" id="fetching-scripts:concept-request-referrer-policy" data-x-internal="concept-request-referrer-policy">referrer policy</a> used for the
    initial fetch and for fetching any imported modules</p>

    <p class="note">This policy can mutate after a <a href="#module-script" id="fetching-scripts:module-script-4">module script</a>'s <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response" data-x-internal="concept-response">response</a> is received, to be the <a id="fetching-scripts:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">referrer policy</a>
    <a href="https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header" id="fetching-scripts:parse-referrer-policy-header" data-x-internal="parse-referrer-policy-header">parsed</a> from the <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-2" data-x-internal="concept-response">response</a>, and used when fetching any module dependencies.</p>
   </dd><dt><dfn id="concept-script-fetch-options-render-blocking">render-blocking</dfn></dt><dd><p>The boolean value of <a href="https://fetch.spec.whatwg.org/#request-render-blocking" id="fetching-scripts:concept-request-render-blocking" data-x-internal="concept-request-render-blocking">render-blocking</a>
   used for the initial fetch and for fetching any imported modules. Unless otherwise stated, its
   value is false.</p></dd><dt><dfn id="concept-script-fetch-options-fetch-priority">fetch priority</dfn></dt><dd><p>The <a href="https://fetch.spec.whatwg.org/#request-priority" id="fetching-scripts:concept-request-priority" data-x-internal="concept-request-priority">priority</a> used for the
   initial fetch</p></dd></dl>

  <p class="note">Recall that via the <code id="fetching-scripts:import()"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> feature, <a href="#classic-script" id="fetching-scripts:classic-script-3">classic scripts</a> can import <a href="#module-script" id="fetching-scripts:module-script-5">module scripts</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="default-script-fetch-options">default script fetch options</dfn> are a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options">script fetch options</a> whose <a href="#concept-script-fetch-options-nonce" id="fetching-scripts:concept-script-fetch-options-nonce">cryptographic nonce</a> is the empty string, <a href="#concept-script-fetch-options-integrity" id="fetching-scripts:concept-script-fetch-options-integrity">integrity metadata</a> is the empty string,
  <a href="#concept-script-fetch-options-parser" id="fetching-scripts:concept-script-fetch-options-parser">parser metadata</a> is "<code>not-parser-inserted</code>", <a href="#concept-script-fetch-options-credentials" id="fetching-scripts:concept-script-fetch-options-credentials">credentials mode</a> is "<code>same-origin</code>", <a href="#concept-script-fetch-options-referrer-policy" id="fetching-scripts:concept-script-fetch-options-referrer-policy">referrer policy</a> is the empty
  string, and <a href="#concept-script-fetch-options-fetch-priority" id="fetching-scripts:concept-script-fetch-options-fetch-priority">fetch priority</a>
  is "<code>auto</code>".</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="set-up-the-classic-script-request">set up the classic script request</dfn>,
  given a <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-scripts:concept-request" data-x-internal="concept-request">request</a> <var>request</var> and
  a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-2">script fetch options</a> <var>options</var>,
  set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-nonce-metadata" id="fetching-scripts:concept-request-nonce-metadata-2" data-x-internal="concept-request-nonce-metadata">cryptographic nonce
  metadata</a> to <var>options</var>'s <a href="#concept-script-fetch-options-nonce" id="fetching-scripts:concept-script-fetch-options-nonce-2">cryptographic nonce</a>, its <a href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata" id="fetching-scripts:concept-request-integrity-metadata-2" data-x-internal="concept-request-integrity-metadata">integrity metadata</a> to <var>options</var>'s
  <a href="#concept-script-fetch-options-integrity" id="fetching-scripts:concept-script-fetch-options-integrity-2">integrity metadata</a>, its <a href="https://fetch.spec.whatwg.org/#concept-request-parser-metadata" id="fetching-scripts:concept-request-parser-metadata-2" data-x-internal="concept-request-parser-metadata">parser metadata</a> to <var>options</var>'s <a href="#concept-script-fetch-options-parser" id="fetching-scripts:concept-script-fetch-options-parser-2">parser metadata</a>, its <a href="https://fetch.spec.whatwg.org/#concept-request-referrer-policy" id="fetching-scripts:concept-request-referrer-policy-2" data-x-internal="concept-request-referrer-policy">referrer policy</a> to <var>options</var>'s <a href="#concept-script-fetch-options-referrer-policy" id="fetching-scripts:concept-script-fetch-options-referrer-policy-2">referrer policy</a>, its
  <a href="https://fetch.spec.whatwg.org/#request-render-blocking" id="fetching-scripts:concept-request-render-blocking-2" data-x-internal="concept-request-render-blocking">render-blocking</a> to <var>options</var>'s
  <a href="#concept-script-fetch-options-render-blocking" id="fetching-scripts:concept-script-fetch-options-render-blocking">render-blocking</a>, and its
  <a href="https://fetch.spec.whatwg.org/#request-priority" id="fetching-scripts:concept-request-priority-2" data-x-internal="concept-request-priority">priority</a> to <var>options</var>'s
  <a href="#concept-script-fetch-options-fetch-priority" id="fetching-scripts:concept-script-fetch-options-fetch-priority-2">fetch priority</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="set-up-the-module-script-request">set up the module script request</dfn>,
  given a <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-scripts:concept-request-2" data-x-internal="concept-request">request</a> <var>request</var> and
  a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-3">script fetch options</a> <var>options</var>,
  set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-nonce-metadata" id="fetching-scripts:concept-request-nonce-metadata-3" data-x-internal="concept-request-nonce-metadata">cryptographic nonce
  metadata</a> to <var>options</var>'s <a href="#concept-script-fetch-options-nonce" id="fetching-scripts:concept-script-fetch-options-nonce-3">cryptographic nonce</a>, its <a href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata" id="fetching-scripts:concept-request-integrity-metadata-3" data-x-internal="concept-request-integrity-metadata">integrity metadata</a> to <var>options</var>'s
  <a href="#concept-script-fetch-options-integrity" id="fetching-scripts:concept-script-fetch-options-integrity-3">integrity metadata</a>, its <a href="https://fetch.spec.whatwg.org/#concept-request-parser-metadata" id="fetching-scripts:concept-request-parser-metadata-3" data-x-internal="concept-request-parser-metadata">parser metadata</a> to <var>options</var>'s <a href="#concept-script-fetch-options-parser" id="fetching-scripts:concept-script-fetch-options-parser-3">parser metadata</a>, its <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="fetching-scripts:concept-request-credentials-mode-2" data-x-internal="concept-request-credentials-mode">credentials mode</a> to <var>options</var>'s <a href="#concept-script-fetch-options-credentials" id="fetching-scripts:concept-script-fetch-options-credentials-2">credentials mode</a>, its <a href="https://fetch.spec.whatwg.org/#concept-request-referrer-policy" id="fetching-scripts:concept-request-referrer-policy-3" data-x-internal="concept-request-referrer-policy">referrer policy</a> to <var>options</var>'s <a href="#concept-script-fetch-options-referrer-policy" id="fetching-scripts:concept-script-fetch-options-referrer-policy-3">referrer policy</a>, its
  <a href="https://fetch.spec.whatwg.org/#request-render-blocking" id="fetching-scripts:concept-request-render-blocking-3" data-x-internal="concept-request-render-blocking">render-blocking</a> to <var>options</var>'s
  <a href="#concept-script-fetch-options-render-blocking" id="fetching-scripts:concept-script-fetch-options-render-blocking-2">render-blocking</a>, and its
  <a href="https://fetch.spec.whatwg.org/#request-priority" id="fetching-scripts:concept-request-priority-3" data-x-internal="concept-request-priority">priority</a> to <var>options</var>'s
  <a href="#concept-script-fetch-options-fetch-priority" id="fetching-scripts:concept-script-fetch-options-fetch-priority-3">fetch priority</a>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="get-the-descendant-script-fetch-options">get the descendant script fetch options</dfn> given a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-4">script fetch options</a>
  <var>originalOptions</var>, a <a id="fetching-scripts:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, and an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object">environment settings
  object</a> <var>settingsObject</var>:</p>

  <ol><li><p>Let <var>newOptions</var> be a copy of <var>originalOptions</var>.</p></li><li><p>Let <var>integrity</var> be the result of <a href="#resolving-a-module-integrity-metadata" id="fetching-scripts:resolving-a-module-integrity-metadata">resolving a module integrity
   metadata</a> with <var>url</var> and <var>settingsObject</var>.</p></li><li><p>Set <var>newOptions</var>'s <a href="#concept-script-fetch-options-integrity" id="fetching-scripts:concept-script-fetch-options-integrity-4">integrity metadata</a> to
   <var>integrity</var>.</p></li><li><p>Set <var>newOptions</var>'s <a href="#concept-script-fetch-options-fetch-priority" id="fetching-scripts:concept-script-fetch-options-fetch-priority-4">fetch priority</a> to "<code>auto</code>".</p></li><li><p>Return <var>newOptions</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="resolving-a-module-integrity-metadata">resolve a module integrity
  metadata</dfn>, given a <a id="fetching-scripts:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var> and an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-2">environment settings
  object</a> <var>settingsObject</var>:</p>

  <ol><li><p>Let <var>map</var> be <var>settingsObject</var>'s <a href="#concept-settings-object-global" id="fetching-scripts:concept-settings-object-global">global object</a>'s <a href="#concept-global-import-map" id="fetching-scripts:concept-global-import-map">import map</a>.</p></li><li><p>If <var>map</var>'s <a href="#concept-import-map-integrity" id="fetching-scripts:concept-import-map-integrity">integrity</a>[<var>url</var>] does not <a href="https://infra.spec.whatwg.org/#map-exists" id="fetching-scripts:map-exists" data-x-internal="map-exists">exist</a>, then return the empty string.</p></li><li><p>Return <var>map</var>'s <a href="#concept-import-map-integrity" id="fetching-scripts:concept-import-map-integrity-2">integrity</a>[<var>url</var>].</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>Several of the below algorithms can be customized with a <dfn data-dfn-for="fetching scripts" id="fetching-scripts-perform-fetch" data-export="">perform the fetch
  hook</dfn> algorithm, which takes a <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-scripts:concept-request-3" data-x-internal="concept-request">request</a>, a boolean <var id="fetching-scripts:fetching-scripts-is-top-level"><a href="#fetching-scripts-is-top-level">isTopLevel</a></var>, and a <dfn data-dfn-for="fetching
  scripts" id="fetching-scripts-processcustomfetchresponse" data-export=""><var>processCustomFetchResponse</var></dfn>
  algorithm. It runs <var id="fetching-scripts:fetching-scripts-processcustomfetchresponse"><a href="#fetching-scripts-processcustomfetchresponse">processCustomFetchResponse</a></var> with a <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-3" data-x-internal="concept-response">response</a> and either null (on failure) or a <a id="fetching-scripts:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte
  sequence</a> containing the response body. <dfn data-dfn-for="fetching scripts" id="fetching-scripts-is-top-level" data-export=""><var>isTopLevel</var></dfn> will be true for all <a href="#classic-script" id="fetching-scripts:classic-script-4">classic
  script</a> fetches, and for the initial fetch when <a href="#fetch-a-module-script-tree" id="fetching-scripts:fetch-a-module-script-tree">fetching an external module script graph</a> or <a href="#fetch-a-module-worker-script-tree" id="fetching-scripts:fetch-a-module-worker-script-tree">fetching a module worker script graph</a>, but false for the fetches
  resulting from <code>import</code> statements encountered throughout the graph or from
  <code>import()</code> expressions.</p>
  </div>

  <p>By default, not supplying a <a href="#fetching-scripts-perform-fetch" id="fetching-scripts:fetching-scripts-perform-fetch">perform the fetch
  hook</a> will cause the below algorithms to simply <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetching-scripts:concept-fetch" data-x-internal="concept-fetch">fetch</a>
  the given <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-scripts:concept-request-4" data-x-internal="concept-request">request</a>, with algorithm-specific customizations
  to the <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-scripts:concept-request-5" data-x-internal="concept-request">request</a> and validations of the resulting <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-4" data-x-internal="concept-response">response</a>.</p>

  <p>To layer your own customizations on top of these algorithm-specific ones, supply a <a href="#fetching-scripts-perform-fetch" id="fetching-scripts:fetching-scripts-perform-fetch-2">perform the fetch hook</a> that modifies the given
  <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-scripts:concept-request-6" data-x-internal="concept-request">request</a>, <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetching-scripts:concept-fetch-2" data-x-internal="concept-fetch">fetches</a> it,
  and then performs specific validations of the resulting <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-5" data-x-internal="concept-response">response</a> (completing with a <a id="fetching-scripts:network-error" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a> if the
  validations fail).</p>

  <p>The hook can also be used to perform more subtle customizations, such as keeping a cache of
  <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-6" data-x-internal="concept-response">responses</a> and avoiding performing a <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetching-scripts:concept-fetch-3" data-x-internal="concept-fetch">fetch</a> at all.</p>

  <p class="note"><cite>Service Workers</cite> is an example of a specification that runs these
  algorithms with its own options for the hook. <a href="#refsSW">[SW]</a></p>

  <hr>

  <p>Now for the algorithms themselves.</p>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-classic-script" data-export="">fetch a classic script</dfn> given a <a id="fetching-scripts:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, an
  <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-3">environment settings object</a> <var>settingsObject</var>, a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-5">script fetch
  options</a> <var>options</var>, a <a href="#cors-settings-attribute" id="fetching-scripts:cors-settings-attribute">CORS settings
  attribute state</a> <var>corsSetting</var>, an <a id="fetching-scripts:encoding" href="https://encoding.spec.whatwg.org/#encoding" data-x-internal="encoding">encoding</a> <var>encoding</var>, and
  an algorithm <var>onComplete</var>, run these steps. <var>onComplete</var> must be an algorithm
  accepting null (on failure) or a <a href="#classic-script" id="fetching-scripts:classic-script-5">classic script</a> (on success).</p>

  <ol><li><p>Let <var>request</var> be the result of <a href="#create-a-potential-cors-request" id="fetching-scripts:create-a-potential-cors-request">creating a potential-CORS request</a> given <var>url</var>, "<code>script</code>", and <var>corsSetting</var>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="fetching-scripts:concept-request-client" data-x-internal="concept-request-client">client</a> to
   <var>settingsObject</var>.</p>

   </li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="fetching-scripts:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator
   type</a> to "<code>script</code>".</p>

   </li><li><p><a href="#set-up-the-classic-script-request" id="fetching-scripts:set-up-the-classic-script-request">Set up the classic script request</a> given <var>request</var> and
   <var>options</var>.</p></li><li>
    <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetching-scripts:concept-fetch-4" data-x-internal="concept-fetch">Fetch</a> <var>request</var> with
    the following <i id="fetching-scripts:processresponseconsumebody"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> steps given
    <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-7" data-x-internal="concept-response">response</a> <var>response</var> and null, failure, or a
    <a id="fetching-scripts:byte-sequence-2" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bodyBytes</var>:</p>

    <p class="note"><var>response</var> can be either <a href="#cors-same-origin" id="fetching-scripts:cors-same-origin">CORS-same-origin</a> or
    <a href="#cors-cross-origin" id="fetching-scripts:cors-cross-origin">CORS-cross-origin</a>. This only affects how error reporting happens.</p>

    <ol><li><p>Set <var>response</var> to <var>response</var>'s <a href="#unsafe-response" id="fetching-scripts:unsafe-response">unsafe response</a>.</p></li><li>
      <p>If any of the following are true:</p>

      <ul><li><p><var>bodyBytes</var> is null or failure; or</p></li><li><p><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="fetching-scripts:concept-response-status" data-x-internal="concept-response-status">status</a> is not an
       <a id="fetching-scripts:ok-status" href="https://fetch.spec.whatwg.org/#ok-status" data-x-internal="ok-status">ok status</a>,</p></li></ul>

      <p>then run <var>onComplete</var> given null, and abort these steps.</p>

      <p class="note">For historical reasons, this algorithm does not include MIME type checking,
      unlike the other script-fetching algorithms in this section.</p>
     </li><li><p>Let <var>potentialMIMETypeForEncoding</var> be the result of <a href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type" id="fetching-scripts:extract-a-mime-type" data-x-internal="extract-a-mime-type">extracting a MIME type</a> given <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="fetching-scripts:concept-response-header-list" data-x-internal="concept-response-header-list">header list</a>.</p></li><li>
      <p>Set <var>encoding</var> to the result of <a href="https://fetch.spec.whatwg.org/#legacy-extract-an-encoding" id="fetching-scripts:legacy-extract-an-encoding" data-x-internal="legacy-extract-an-encoding">legacy
      extracting an encoding</a> given <var>potentialMIMETypeForEncoding</var> and
      <var>encoding</var>.</p>

      <p class="note">This intentionally ignores the <a id="fetching-scripts:mime-type-essence" href="https://mimesniff.spec.whatwg.org/#mime-type-essence" data-x-internal="mime-type-essence">MIME type essence</a>.</p>
     </li><li>
      <p>Let <var>sourceText</var> be the result of <a href="https://encoding.spec.whatwg.org/#decode" id="fetching-scripts:decode" data-x-internal="decode">decoding</a>
      <var>bodyBytes</var> to Unicode, using <var>encoding</var> as the fallback encoding.</p>

      <p class="note">The <a id="fetching-scripts:decode-2" href="https://encoding.spec.whatwg.org/#decode" data-x-internal="decode">decode</a> algorithm overrides <var>encoding</var> if the file
      contains a BOM.</p>
     </li><li><p>Let <var>mutedErrors</var> be true if <var>response</var> was
     <a href="#cors-cross-origin" id="fetching-scripts:cors-cross-origin-2">CORS-cross-origin</a>, and false otherwise.</p></li><li><p>Let <var>script</var> be the result of <a href="#creating-a-classic-script" id="fetching-scripts:creating-a-classic-script">creating a classic script</a> given
     <var>sourceText</var>, <var>settingsObject</var>, <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="fetching-scripts:concept-response-url" data-x-internal="concept-response-url">URL</a>, <var>options</var>,
     <var>mutedErrors</var>, and <var>url</var>.</p></li><li>Run <var>onComplete</var> given <var>script</var>.</li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-classic-worker-script" data-export="">fetch a classic worker script</dfn> given a <a id="fetching-scripts:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, an
  <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-4">environment settings object</a> <var>fetchClient</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination" data-x-internal="concept-request-destination">destination</a> <var>destination</var>, an
  <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-5">environment settings object</a> <var>settingsObject</var>, an algorithm
  <var>onComplete</var>, and an optional <a href="#fetching-scripts-perform-fetch" id="fetching-scripts:fetching-scripts-perform-fetch-3">perform the
  fetch hook</a> <var>performFetch</var>, run these steps. <var>onComplete</var> must be an
  algorithm accepting null (on failure) or a <a href="#classic-script" id="fetching-scripts:classic-script-6">classic script</a> (on success).</p>

  <ol><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-scripts:concept-request-7" data-x-internal="concept-request">request</a> whose <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="fetching-scripts:concept-request-url" data-x-internal="concept-request-url">URL</a> is <var>url</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="fetching-scripts:concept-request-client-2" data-x-internal="concept-request-client">client</a> is <var>fetchClient</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-2" data-x-internal="concept-request-destination">destination</a> is <var>destination</var>, <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="fetching-scripts:concept-request-initiator-type-2" data-x-internal="concept-request-initiator-type">initiator type</a> is "<code>other</code>",
   <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="fetching-scripts:concept-request-mode" data-x-internal="concept-request-mode">mode</a> is "<code>same-origin</code>", <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="fetching-scripts:concept-request-credentials-mode-3" data-x-internal="concept-request-credentials-mode">credentials mode</a> is "<code>same-origin</code>", <a href="https://fetch.spec.whatwg.org/#concept-request-parser-metadata" id="fetching-scripts:concept-request-parser-metadata-4" data-x-internal="concept-request-parser-metadata">parser
   metadata</a> is "<code>not parser-inserted</code>", and whose
   <a id="fetching-scripts:use-url-credentials-flag" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a> is set.</p></li><li>
    <p>If <var>performFetch</var> was given, run <var>performFetch</var> with <var>request</var>,
    true, and with <var>processResponseConsumeBody</var> as defined below.</p>

    <p>Otherwise, <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetching-scripts:concept-fetch-5" data-x-internal="concept-fetch">fetch</a> <var>request</var> with <i id="fetching-scripts:processresponseconsumebody-2"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> set to
    <var>processResponseConsumeBody</var> as defined below.</p>

    <p>In both cases, let <var>processResponseConsumeBody</var> given <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-8" data-x-internal="concept-response">response</a> <var>response</var> and null, failure, or a <a id="fetching-scripts:byte-sequence-3" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte
    sequence</a> <var>bodyBytes</var> be the following algorithm:</p>

    <ol><li><p>Set <var>response</var> to <var>response</var>'s <a href="#unsafe-response" id="fetching-scripts:unsafe-response-2">unsafe response</a>.</p></li><li>
      <p>If any of the following are true:</p>

      <ul><li><p><var>bodyBytes</var> is null or failure; or</p></li><li><p><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="fetching-scripts:concept-response-status-2" data-x-internal="concept-response-status">status</a> is not an
       <a id="fetching-scripts:ok-status-2" href="https://fetch.spec.whatwg.org/#ok-status" data-x-internal="ok-status">ok status</a>,</p></li></ul>

      <p>then run <var>onComplete</var> given null, and abort these steps.</p>
     </li><li>
      <p>If all of the following are true:</p>

      <ul><li><p><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="fetching-scripts:concept-response-url-2" data-x-internal="concept-response-url">URL</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="fetching-scripts:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is an <a id="fetching-scripts:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>; and</p></li><li><p>the result of <a href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type" id="fetching-scripts:extract-a-mime-type-2" data-x-internal="extract-a-mime-type">extracting a MIME type</a> from
       <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="fetching-scripts:concept-response-header-list-2" data-x-internal="concept-response-header-list">header list</a> is not
       a <a id="fetching-scripts:javascript-mime-type" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type" data-x-internal="javascript-mime-type">JavaScript MIME type</a>,</p>
      </li></ul>

      <p>then run <var>onComplete</var> given null, and abort these steps.</p>

      <p class="note">Other <a href="https://fetch.spec.whatwg.org/#fetch-scheme" id="fetching-scripts:fetch-scheme" data-x-internal="fetch-scheme">fetch schemes</a> are exempted from MIME
      type checking for historical web-compatibility reasons. We might be able to tighten this in
      the future; see <a href="https://github.com/whatwg/html/issues/3255">issue #3255</a>.</p>
     </li><li><p>Let <var>sourceText</var> be the result of <a href="https://encoding.spec.whatwg.org/#utf-8-decode" id="fetching-scripts:utf-8-decode" data-x-internal="utf-8-decode">UTF-8
     decoding</a> <var>bodyBytes</var>.</p></li><li><p>Let <var>script</var> be the result of <a href="#creating-a-classic-script" id="fetching-scripts:creating-a-classic-script-2">creating a classic script</a> using
     <var>sourceText</var>, <var>settingsObject</var>, <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="fetching-scripts:concept-response-url-3" data-x-internal="concept-response-url">URL</a>, and the <a href="#default-script-fetch-options" id="fetching-scripts:default-script-fetch-options">default script fetch
     options</a>.</p></li><li><p>Run <var>onComplete</var> given <var>script</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-classic-worker-imported-script" data-export="">fetch a classic worker-imported script</dfn> given a <a id="fetching-scripts:url-5" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>
  <var>url</var>, an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-6">environment settings object</a> <var>settingsObject</var>, and an
  optional <a href="#fetching-scripts-perform-fetch" id="fetching-scripts:fetching-scripts-perform-fetch-4">perform the fetch hook</a>
  <var>performFetch</var>, run these steps. The algorithm will return a <a href="#classic-script" id="fetching-scripts:classic-script-7">classic script</a>
  on success, or throw an exception on failure.</p>

  <ol><li><p>Let <var>response</var> be null.</p></li><li><p>Let <var>bodyBytes</var> be null.</p></li><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-scripts:concept-request-8" data-x-internal="concept-request">request</a> whose <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="fetching-scripts:concept-request-url-2" data-x-internal="concept-request-url">URL</a> is <var>url</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="fetching-scripts:concept-request-client-3" data-x-internal="concept-request-client">client</a> is <var>settingsObject</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-3" data-x-internal="concept-request-destination">destination</a> is "<code>script</code>",
   <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="fetching-scripts:concept-request-initiator-type-3" data-x-internal="concept-request-initiator-type">initiator type</a> is "<code>other</code>", <a href="https://fetch.spec.whatwg.org/#concept-request-parser-metadata" id="fetching-scripts:concept-request-parser-metadata-5" data-x-internal="concept-request-parser-metadata">parser metadata</a>
   is "<code>not parser-inserted</code>", and whose <a id="fetching-scripts:use-url-credentials-flag-2" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag" data-x-internal="use-url-credentials-flag">use-URL-credentials flag</a>
   is set.</p></li><li>
    <p>If <var>performFetch</var> was given, run <var>performFetch</var> with <var>request</var>,
    <var>isTopLevel</var>, and with <var>processResponseConsumeBody</var> as defined below.</p>

    <p>Otherwise, <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetching-scripts:concept-fetch-6" data-x-internal="concept-fetch">fetch</a> <var>request</var> with <i id="fetching-scripts:processresponseconsumebody-3"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> set to
    <var>processResponseConsumeBody</var> as defined below.</p>

    <p>In both cases, let <var>processResponseConsumeBody</var> given <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-9" data-x-internal="concept-response">response</a> <var>res</var> and null, failure, or a
    <a id="fetching-scripts:byte-sequence-4" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bb</var> be the following algorithm:</p>

    <ol><li><p>Set <var>bodyBytes</var> to <var>bb</var>.</p></li><li><p>Set <var>response</var> to <var>res</var>.</p></li></ol>
   </li><li>
    <p><a href="#pause" id="fetching-scripts:pause">Pause</a> until <var>response</var> is not null.</p>

    <p class="note">Unlike other algorithms in this section, the fetching process is synchronous
    here.</p>
   </li><li><p>Set <var>response</var> to <var>response</var>'s <a href="#unsafe-response" id="fetching-scripts:unsafe-response-3">unsafe response</a>.</p></li><li>
    <p>If any of the following are true:</p>

    <ul><li><p><var>bodyBytes</var> is null or failure;</p></li><li><p><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="fetching-scripts:concept-response-status-3" data-x-internal="concept-response-status">status</a> is not an
     <a id="fetching-scripts:ok-status-3" href="https://fetch.spec.whatwg.org/#ok-status" data-x-internal="ok-status">ok status</a>; or</p></li><li><p>the result of <a href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type" id="fetching-scripts:extract-a-mime-type-3" data-x-internal="extract-a-mime-type">extracting a MIME type</a> from
     <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="fetching-scripts:concept-response-header-list-3" data-x-internal="concept-response-header-list">header list</a> is not a
     <a id="fetching-scripts:javascript-mime-type-2" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type" data-x-internal="javascript-mime-type">JavaScript MIME type</a>,</p>
    </li></ul>

    <p>then throw a <a id="fetching-scripts:networkerror" href="https://webidl.spec.whatwg.org/#networkerror" data-x-internal="networkerror">"<code>NetworkError</code>"</a> <code id="fetching-scripts:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>
   </li><li><p>Let <var>sourceText</var> be the result of <a href="https://encoding.spec.whatwg.org/#utf-8-decode" id="fetching-scripts:utf-8-decode-2" data-x-internal="utf-8-decode">UTF-8
   decoding</a> <var>bodyBytes</var>.</p></li><li><p>Let <var>mutedErrors</var> be true if <var>response</var> was
   <a href="#cors-cross-origin" id="fetching-scripts:cors-cross-origin-3">CORS-cross-origin</a>, and false otherwise.</p></li><li><p>Let <var>script</var> be the result of <a href="#creating-a-classic-script" id="fetching-scripts:creating-a-classic-script-3">creating a classic script</a> given
   <var>sourceText</var>, <var>settingsObject</var>, <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="fetching-scripts:concept-response-url-4" data-x-internal="concept-response-url">URL</a>, the <a href="#default-script-fetch-options" id="fetching-scripts:default-script-fetch-options-2">default script fetch options</a>, and
   <var>mutedErrors</var>.</p></li><li><p>Return <var>script</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-module-script-tree" data-export="">fetch an external module script graph</dfn>
  given a <a id="fetching-scripts:url-6" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-7">environment settings object</a>
  <var>settingsObject</var>, a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-6">script fetch options</a> <var>options</var>, and an
  algorithm <var>onComplete</var>, run these steps. <var>onComplete</var> must be an algorithm
  accepting null (on failure) or a <a href="#module-script" id="fetching-scripts:module-script-6">module script</a> (on success).</p>

  <ol><li>
    <p><a href="#fetch-a-single-module-script" id="fetching-scripts:fetch-a-single-module-script">Fetch a single module script</a> given <var>url</var>, <var>settingsObject</var>,
    "<code>script</code>", <var>options</var>, <var>settingsObject</var>, "<code>client</code>", true, and with the following steps given <var>result</var>:</p>

    <ol><li><p>If <var>result</var> is null, run <var>onComplete</var> given null, and abort these
     steps.</p></li><li><p><a href="#fetch-the-descendants-of-and-link-a-module-script" id="fetching-scripts:fetch-the-descendants-of-and-link-a-module-script">Fetch the descendants of
     and link</a> <var>result</var> given <var>settingsObject</var>, "<code>script</code>", and <var>onComplete</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-modulepreload-module-script-graph">fetch a modulepreload module script graph</dfn> given a <a id="fetching-scripts:url-7" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>,
  a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-4" data-x-internal="concept-request-destination">destination</a> <var>destination</var>, an
  <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-8">environment settings object</a> <var>settingsObject</var>, a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-7">script fetch
  options</a> <var>options</var>, and an algorithm <var>onComplete</var>, run these steps.
  <var>onComplete</var> must be an algorithm accepting null (on failure) or a <a href="#module-script" id="fetching-scripts:module-script-7">module
  script</a> (on success).</p>

  <ol><li>
    <p><a href="#fetch-a-single-module-script" id="fetching-scripts:fetch-a-single-module-script-2">Fetch a single module script</a> given <var>url</var>, <var>settingsObject</var>,
    <var>destination</var>, <var>options</var>, <var>settingsObject</var>, "<code>client</code>", true, and with the following steps given <var>result</var>:</p>

    <ol><li><p>Run <var>onComplete</var> given <var>result</var>.</p></li><li><p><a id="fetching-scripts:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>settingsObject</var>'s <a href="#concept-settings-object-global" id="fetching-scripts:concept-settings-object-global-2">global object</a> implements
     <code id="fetching-scripts:window"><a href="#window">Window</a></code>.</p></li><li>
      <p>If <var>result</var> is not null, optionally <a href="#fetch-the-descendants-of-and-link-a-module-script" id="fetching-scripts:fetch-the-descendants-of-and-link-a-module-script-2">fetch the descendants of and link</a> <var>result</var> given
      <var>settingsObject</var>, <var>destination</var>, and an empty algorithm.</p>

      <p class="note">Generally, performing this step will be beneficial for performance, as it
      allows pre-loading the modules that will invariably be requested later, via algorithms such as
      <a href="#fetch-a-module-script-tree" id="fetching-scripts:fetch-a-module-script-tree-2">fetch an external module script graph</a> that fetch the entire graph. However, user
      agents might wish to skip them in bandwidth-constrained situations, or situations where the
      relevant fetches are already in flight.</p>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-an-inline-module-script-graph">fetch an inline module script graph</dfn> given a <a id="fetching-scripts:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a>
  <var>sourceText</var>, a <a id="fetching-scripts:url-8" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>, an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-9">environment settings
  object</a> <var>settingsObject</var>, a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-8">script fetch options</a> <var>options</var>,
  and an algorithm <var>onComplete</var>, run these steps. <var>onComplete</var> must be an
  algorithm accepting null (on failure) or a <a href="#module-script" id="fetching-scripts:module-script-8">module script</a> (on success).</p>

  <ol><li><p>Let <var>script</var> be the result of <a href="#creating-a-javascript-module-script" id="fetching-scripts:creating-a-javascript-module-script">creating a JavaScript module script</a>
   using <var>sourceText</var>, <var>settingsObject</var>, <var>baseURL</var>, and
   <var>options</var>.</p></li><li><p><a href="#fetch-the-descendants-of-and-link-a-module-script" id="fetching-scripts:fetch-the-descendants-of-and-link-a-module-script-3">Fetch the descendants of
   and link</a> <var>script</var>, given <var>settingsObject</var>, "<code>script</code>", and <var>onComplete</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-module-worker-script-tree" data-export="">fetch a module worker script graph</dfn>
  given a <a id="fetching-scripts:url-9" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-10">environment settings object</a>
  <var>fetchClient</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-5" data-x-internal="concept-request-destination">destination</a>
  <var>destination</var>, a <a href="#concept-script-fetch-options-credentials" id="fetching-scripts:concept-script-fetch-options-credentials-3">credentials
  mode</a> <var>credentialsMode</var>, an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-11">environment settings object</a>
  <var>settingsObject</var>, and an algorithm <var>onComplete</var>, <a href="#fetch-a-worklet/module-worker-script-graph" id="fetching-scripts:fetch-a-worklet/module-worker-script-graph">fetch a worklet/module
  worker script graph</a> given <var>url</var>, <var>fetchClient</var>, <var>destination</var>,
  <var>credentialsMode</var>, <var>settingsObject</var>, and <var>onComplete</var>.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-worklet-script-graph">fetch a worklet script graph</dfn> given a <a id="fetching-scripts:url-10" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, an
  <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-12">environment settings object</a> <var>fetchClient</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-6" data-x-internal="concept-request-destination">destination</a> <var>destination</var>, a
  <a href="#concept-script-fetch-options-credentials" id="fetching-scripts:concept-script-fetch-options-credentials-4">credentials mode</a>
  <var>credentialsMode</var>, an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-13">environment settings object</a>
  <var>settingsObject</var>, a <a href="#concept-worklet-module-responses-map" id="fetching-scripts:concept-worklet-module-responses-map">module responses
  map</a> <var>moduleResponsesMap</var>, and an algorithm <var>onComplete</var>, <a href="#fetch-a-worklet/module-worker-script-graph" id="fetching-scripts:fetch-a-worklet/module-worker-script-graph-2">fetch a
  worklet/module worker script graph</a> given <var>url</var>, <var>fetchClient</var>,
  <var>destination</var>, <var>credentialsMode</var>, <var>settingsObject</var>,
  <var>onComplete</var>, and the following <a href="#fetching-scripts-perform-fetch" id="fetching-scripts:fetching-scripts-perform-fetch-5">perform the
  fetch hook</a> given <var>request</var> and <var id="fetching-scripts:fetching-scripts-processcustomfetchresponse-2"><a href="#fetching-scripts-processcustomfetchresponse">processCustomFetchResponse</a></var>:</p>

  <ol><li><p>Let <var>requestURL</var> be <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="fetching-scripts:concept-request-url-3" data-x-internal="concept-request-url">URL</a>.</p></li><li><p>If <var>moduleResponsesMap</var>[<var>requestURL</var>] is "<code>fetching</code>", wait <a href="#in-parallel" id="fetching-scripts:in-parallel">in parallel</a> until that entry's value changes, then
   <a href="#queue-a-task" id="fetching-scripts:queue-a-task">queue a task</a> on the <a href="#networking-task-source" id="fetching-scripts:networking-task-source">networking task source</a> to proceed with running the
   following steps.</p></li><li>
    <p>If <var>moduleResponsesMap</var>[<var>requestURL</var>] <a href="https://infra.spec.whatwg.org/#map-exists" id="fetching-scripts:map-exists-2" data-x-internal="map-exists">exists</a>, then:</p>

    <ol><li><p>Let <var>cached</var> be <var>moduleResponsesMap</var>[<var>requestURL</var>].</p></li><li><p>Run <var>processCustomFetchResponse</var> with <var>cached</var>[0] and
     <var>cached</var>[1].</p></li><li><p>Return.</p></li></ol>
   </li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="fetching-scripts:map-set" data-x-internal="map-set">Set</a> <var>moduleResponsesMap</var>[<var>requestURL</var>] to
   "<code>fetching</code>".</p></li><li>
    <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetching-scripts:concept-fetch-7" data-x-internal="concept-fetch">Fetch</a> <var>request</var>, with <i id="fetching-scripts:processresponseconsumebody-4"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> set to the following steps
    given <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-10" data-x-internal="concept-response">response</a> <var>response</var> and null, failure, or a
    <a id="fetching-scripts:byte-sequence-5" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bodyBytes</var>:</p>

    <ol><li><p>Set <var>moduleResponsesMap</var>[<var>requestURL</var>] to (<var>response</var>,
     <var>bodyBytes</var>).</p></li><li><p>Run <var>processCustomFetchResponse</var> with <var>response</var> and
     <var>bodyBytes</var>.</p></li></ol>
   </li></ol>
  </div>

  <hr>

  <p>The following algorithms are meant for internal use by this specification only as part of <a href="#fetch-a-module-script-tree" id="fetching-scripts:fetch-a-module-script-tree-3">fetching an external module script graph</a> or
  other similar concepts above, and should not be used directly by other specifications.</p>

  <p>This diagram illustrates how these algorithms relate to the ones above, as well as to each
  other:</p>

  <svg viewBox="0 0 941 166" id="module-script-fetching-diagram" aria-label="Fetch an external module script, fetch a modulepreload module script graph, fetch an inline module script graph, and fetch a module worker script graph all call fetch the descendants of and link a module script." role="img">
   <defs>
    <marker markerHeight="6" id="module-script-fetching-diagram-arrow" orient="auto" markerWidth="6" refX="5" refY="3">
     <path d="M0,0 V6 L5,3 Z" style="fill: var(--text, CanvasText)"></path>
    </marker>
   </defs>

   <g transform="translate(0.5,0.5)" class="caller">
    <rect width="180" height="50"></rect>
    <foreignObject width="180" height="50">
     <a href="#fetch-a-module-script-tree" id="fetching-scripts:fetch-a-module-script-tree-4" xmlns="http://www.w3.org/1999/xhtml">fetch an external module script graph</a>
    </foreignObject>
   </g>
   <path d="M90.5,50.5 L470.5,140.5" marker-end="url(#module-script-fetching-diagram-arrow)"></path>

   <g transform="translate(190.5,0.5)" class="caller">
    <rect width="180" height="50"></rect>
    <foreignObject width="180" height="50">
     <a href="#fetch-a-modulepreload-module-script-graph" id="fetching-scripts:fetch-a-modulepreload-module-script-graph" xmlns="http://www.w3.org/1999/xhtml">fetch a modulepreload module script graph</a>
    </foreignObject>
   </g>
   <path d="M280.5,50.5 L470.5,140.5" marker-end="url(#module-script-fetching-diagram-arrow)"></path>

   <g transform="translate(380.5,0.5)" class="caller">
    <rect width="180" height="50"></rect>
    <foreignObject width="180" height="50">
     <a href="#fetch-an-inline-module-script-graph" id="fetching-scripts:fetch-an-inline-module-script-graph" xmlns="http://www.w3.org/1999/xhtml">fetch an inline module script graph</a>
    </foreignObject>
   </g>
   <path d="M470.5,50.5 L470.5,140.5" marker-end="url(#module-script-fetching-diagram-arrow)"></path>

   <g transform="translate(570.5,0.5)" class="caller">
    <rect width="180" height="50"></rect>
    <foreignObject width="180" height="50">
     <a href="#fetch-a-module-worker-script-tree" id="fetching-scripts:fetch-a-module-worker-script-tree-2" xmlns="http://www.w3.org/1999/xhtml">fetch a module worker script graph</a>
    </foreignObject>
   </g>
   <path d="M660.5,50.5 L755.5,70.5" marker-end="url(#module-script-fetching-diagram-arrow)"></path>

   <g transform="translate(760.5,0.5)" class="caller">
    <rect width="180" height="50"></rect>
    <foreignObject width="180" height="50">
     <a href="#fetch-a-worklet-script-graph" id="fetching-scripts:fetch-a-worklet-script-graph" xmlns="http://www.w3.org/1999/xhtml">fetch a worklet script graph</a>
    </foreignObject>
   </g>
   <path d="M850.5,50.5 L755.5,70.5" marker-end="url(#module-script-fetching-diagram-arrow)"></path>

   <g transform="translate(665.5,70.5)" class="caller">
    <rect width="180" height="50"></rect>
    <foreignObject width="180" height="50">
     <a href="#fetch-a-worklet/module-worker-script-graph" id="fetching-scripts:fetch-a-worklet/module-worker-script-graph-3" xmlns="http://www.w3.org/1999/xhtml">fetch a worklet/module worker script graph</a>
    </foreignObject>
   </g>
   <path d="M755.5,120.5 L470.5,140.5" marker-end="url(#module-script-fetching-diagram-arrow)"></path>

   <g transform="translate(260.5,140.5)" class="subalgorithm">
    <rect width="420" height="25"></rect>
    <foreignObject width="420" height="25">
     <a href="#fetch-the-descendants-of-and-link-a-module-script" id="fetching-scripts:fetch-the-descendants-of-and-link-a-module-script-4" xmlns="http://www.w3.org/1999/xhtml">fetch the descendants of and link a module script</a>
    </foreignObject>
   </g>
  </svg>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-worklet/module-worker-script-graph">fetch a worklet/module worker script graph</dfn> given a <a id="fetching-scripts:url-11" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>
  <var>url</var>, an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-14">environment settings object</a> <var>fetchClient</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-7" data-x-internal="concept-request-destination">destination</a> <var>destination</var>, a <a href="#concept-script-fetch-options-credentials" id="fetching-scripts:concept-script-fetch-options-credentials-5">credentials mode</a>
  <var>credentialsMode</var>, an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-15">environment settings object</a> <var>settingsObject</var>,
  an algorithm <var>onComplete</var>, and an optional <a href="#fetching-scripts-perform-fetch" id="fetching-scripts:fetching-scripts-perform-fetch-6">perform the fetch hook</a> <var>performFetch</var>, run
  these steps. <var>onComplete</var> must be an algorithm accepting null (on failure) or a
  <a href="#module-script" id="fetching-scripts:module-script-9">module script</a> (on success).</p>

  <ol><li><p>Let <var>options</var> be a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-9">script fetch options</a> whose <a href="#concept-script-fetch-options-nonce" id="fetching-scripts:concept-script-fetch-options-nonce-4">cryptographic nonce</a> is the empty string, <a href="#concept-script-fetch-options-integrity" id="fetching-scripts:concept-script-fetch-options-integrity-5">integrity metadata</a> is the empty string,
   <a href="#concept-script-fetch-options-parser" id="fetching-scripts:concept-script-fetch-options-parser-4">parser metadata</a> is "<code>not-parser-inserted</code>", <a href="#concept-script-fetch-options-credentials" id="fetching-scripts:concept-script-fetch-options-credentials-6">credentials mode</a> is
   <var>credentialsMode</var>, <a href="#concept-script-fetch-options-referrer-policy" id="fetching-scripts:concept-script-fetch-options-referrer-policy-4">referrer
   policy</a> is the empty string, and <a href="#concept-script-fetch-options-fetch-priority" id="fetching-scripts:concept-script-fetch-options-fetch-priority-5">fetch priority</a> is "<code>auto</code>".</p>

   </li><li>
    <p><a href="#fetch-a-single-module-script" id="fetching-scripts:fetch-a-single-module-script-3">Fetch a single module script</a> given <var>url</var>,
    <var>fetchClient</var>, <var>destination</var>, <var>options</var>, <var>settingsObject</var>,
    "<code>client</code>", true, and <var>onSingleFetchComplete</var> as defined below. If
    <var>performFetch</var> was given, pass it along as well.</p>

    <p><var>onSingleFetchComplete</var> given <var>result</var> is the following algorithm:</p>

    <ol><li><p>If <var>result</var> is null, run <var>onComplete</var> given null, and abort these
     steps.</p></li><li><p><a href="#fetch-the-descendants-of-and-link-a-module-script" id="fetching-scripts:fetch-the-descendants-of-and-link-a-module-script-5">Fetch the descendants
     of and link</a> <var>result</var> given <var>fetchClient</var>,
     <var>destination</var>, and <var>onComplete</var>. If <var>performFetch</var> was given, pass
     it along as well.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-the-descendants-of-and-link-a-module-script">fetch the descendants of and
  link</dfn> a <a href="#module-script" id="fetching-scripts:module-script-10">module script</a> <var>moduleScript</var>, given an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-16">environment
  settings object</a> <var>fetchClient</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-8" data-x-internal="concept-request-destination">destination</a> <var>destination</var>, an algorithm
  <var>onComplete</var>, and an optional <a href="#fetching-scripts-perform-fetch" id="fetching-scripts:fetching-scripts-perform-fetch-7">perform the
  fetch hook</a> <var>performFetch</var>, run these steps. <var>onComplete</var> must be an
  algorithm accepting null (on failure) or a <a href="#module-script" id="fetching-scripts:module-script-11">module script</a> (on success).</p>

  <ol><li><p>Let <var>record</var> be <var>moduleScript</var>'s <a href="#concept-script-record" id="fetching-scripts:concept-script-record">record</a>.</p></li><li>
    <p>If <var>record</var> is null, then:</p>

    <ol><li><p>Set <var>moduleScript</var>'s <a href="#concept-script-error-to-rethrow" id="fetching-scripts:concept-script-error-to-rethrow">error to
     rethrow</a> to <var>moduleScript</var>'s <a href="#parse-errors" id="fetching-scripts:parse-errors">parse error</a>.</p></li><li><p>Run <var>onComplete</var> given <var>moduleScript</var>.</p></li><li><p>Return.</p></li></ol>
   </li><li><p>Let <var>state</var> be <a id="fetching-scripts:record" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> { [[ErrorToRethrow]]: null, [[Destination]]:
   <var>destination</var>, [[PerformFetch]]: null, [[FetchClient]]: <var>fetchClient</var>
   }.</p></li><li><p>If <var>performFetch</var> was given, set <var>state</var>.[[PerformFetch]] to
   <var>performFetch</var>.</p></li><li>
    <p>Let <var>loadingPromise</var> be <var>record</var>.<a href="https://tc39.es/ecma262/#sec-LoadRequestedModules" id="fetching-scripts:js-loadrequestedmodules" data-x-internal="js-loadrequestedmodules">LoadRequestedModules</a>(<var>state</var>).</p>

    <p class="note">This step will recursively load all the module transitive dependencies.</p>
   </li><li>
    <p><a id="fetching-scripts:upon-fulfillment" href="https://webidl.spec.whatwg.org/#upon-fulfillment" data-x-internal="upon-fulfillment">Upon fulfillment</a> of <var>loadingPromise</var>, run the following steps:</p>

    <ol><li>
      <p>Perform <var>record</var>.<a href="https://tc39.es/ecma262/#sec-moduledeclarationlinking" id="fetching-scripts:js-link" data-x-internal="js-link">Link</a>().</p>

      <p class="note">This step will recursively call <a href="https://tc39.es/ecma262/#sec-moduledeclarationlinking" id="fetching-scripts:js-link-2" data-x-internal="js-link">Link</a> on all of
      the module's unlinked dependencies.</p>

      <p>If this throws an exception, catch it, and set <var>moduleScript</var>'s <a href="#concept-script-error-to-rethrow" id="fetching-scripts:concept-script-error-to-rethrow-2">error to rethrow</a> to that exception.</p>
     </li><li><p>Run <var>onComplete</var> given <var>moduleScript</var>.</p></li></ol>
   </li><li>
    <p><a id="fetching-scripts:upon-rejection" href="https://webidl.spec.whatwg.org/#upon-rejection" data-x-internal="upon-rejection">Upon rejection</a> of <var>loadingPromise</var>, run the
    following steps:</p>

    <ol><li><p>If <var>state</var>.[[ErrorToRethrow]] is not null, set <var>moduleScript</var>'s <a href="#concept-script-error-to-rethrow" id="fetching-scripts:concept-script-error-to-rethrow-3">error to rethrow</a> to
     <var>state</var>.[[ErrorToRethrow]] and run <var>onComplete</var> given
     <var>moduleScript</var>.</p></li><li>
      <p>Otherwise, run <var>onComplete</var> given null.</p>

      <p class="note"><var>state</var>.[[ErrorToRethrow]] is null when <var>loadingPromise</var> is
      rejected due to a loading error.</p>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-single-module-script">fetch a single module script</dfn>, given a <a id="fetching-scripts:url-12" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>, an
  <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-17">environment settings object</a> <var>fetchClient</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-9" data-x-internal="concept-request-destination">destination</a> <var>destination</var>, a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-10">script
  fetch options</a> <var>options</var>, an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-18">environment settings object</a>
  <var>settingsObject</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="fetching-scripts:concept-request-referrer" data-x-internal="concept-request-referrer">referrer</a>
  <var>referrer</var>, an optional <a id="fetching-scripts:modulerequest-record" href="https://tc39.es/ecma262/#modulerequest-record" data-x-internal="modulerequest-record">ModuleRequest Record</a> <var>moduleRequest</var>, a
  boolean <var id="fetching-scripts:fetching-scripts-is-top-level-2"><a href="#fetching-scripts-is-top-level">isTopLevel</a></var>, an algorithm
  <var>onComplete</var>, and an optional <a href="#fetching-scripts-perform-fetch" id="fetching-scripts:fetching-scripts-perform-fetch-8">perform the
  fetch hook</a> <var>performFetch</var>, run these steps. <var>onComplete</var> must be an
  algorithm accepting null (on failure) or a <a href="#module-script" id="fetching-scripts:module-script-12">module script</a> (on success).</p>

  <ol><li><p>Let <var>moduleType</var> be "<code>javascript-or-wasm</code>".</p></li><li><p>If <var>moduleRequest</var> was given, then set <var>moduleType</var> to the result of
   running the <a href="#module-type-from-module-request" id="fetching-scripts:module-type-from-module-request">module type from module request</a> steps given
   <var>moduleRequest</var>.</p></li><li><p><a id="fetching-scripts:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: the result of running the <a href="#module-type-allowed" id="fetching-scripts:module-type-allowed">module type allowed</a> steps
   given <var>moduleType</var> and <var>settingsObject</var> is true. Otherwise, we would not have
   reached this point because a failure would have been raised when inspecting
   <var>moduleRequest</var>.[[Attributes]] in <a href="#validate-requested-module-specifiers">
   HostLoadImportedModule</a> or <a href="#fetch-a-single-imported-module-script" id="fetching-scripts:fetch-a-single-imported-module-script">fetch a single imported module script</a>.</p></li><li><p>Let <var>moduleMap</var> be <var>settingsObject</var>'s <a href="#concept-settings-object-module-map" id="fetching-scripts:concept-settings-object-module-map">module map</a>.</p></li><li><p>If <var>moduleMap</var>[(<var>url</var>, <var>moduleType</var>)] is
   "<code>fetching</code>", wait <a href="#in-parallel" id="fetching-scripts:in-parallel-2">in parallel</a> until that entry's value
   changes, then <a href="#queue-a-task" id="fetching-scripts:queue-a-task-2">queue a task</a> on the <a href="#networking-task-source" id="fetching-scripts:networking-task-source-2">networking task source</a> to proceed
   with running the following steps.</p></li><li><p>If <var>moduleMap</var>[(<var>url</var>, <var>moduleType</var>)] <a href="https://infra.spec.whatwg.org/#map-exists" id="fetching-scripts:map-exists-3" data-x-internal="map-exists">exists</a>, run <var>onComplete</var> given
   <var>moduleMap</var>[(<var>url</var>, <var>moduleType</var>)], and return.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="fetching-scripts:map-set-2" data-x-internal="map-set">Set</a> <var>moduleMap</var>[(<var>url</var>,
   <var>moduleType</var>)] to "<code>fetching</code>".</p></li><li><p>Let <var>request</var> be a new <a href="https://fetch.spec.whatwg.org/#concept-request" id="fetching-scripts:concept-request-9" data-x-internal="concept-request">request</a> whose
   <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="fetching-scripts:concept-request-url-4" data-x-internal="concept-request-url">URL</a> is <var>url</var>, <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="fetching-scripts:concept-request-mode-2" data-x-internal="concept-request-mode">mode</a> is "<code>cors</code>", <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="fetching-scripts:concept-request-referrer-2" data-x-internal="concept-request-referrer">referrer</a> is <var>referrer</var>, and <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="fetching-scripts:concept-request-client-4" data-x-internal="concept-request-client">client</a> is <var>fetchClient</var>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-10" data-x-internal="concept-request-destination">destination</a> to
   the result of running the <a href="#fetch-destination-from-module-type" id="fetching-scripts:fetch-destination-from-module-type">fetch destination from module type</a> steps given
   <var>destination</var> and <var>moduleType</var>.</p></li><li><p>If <var>destination</var> is "<code>worker</code>", "<code>sharedworker</code>", or "<code>serviceworker</code>", and
   <var>isTopLevel</var> is true, then set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-mode" id="fetching-scripts:concept-request-mode-3" data-x-internal="concept-request-mode">mode</a> to "<code>same-origin</code>".</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="fetching-scripts:concept-request-initiator-type-4" data-x-internal="concept-request-initiator-type">initiator
   type</a> to "<code>script</code>".</p>

   </li><li><p><a href="#set-up-the-module-script-request" id="fetching-scripts:set-up-the-module-script-request">Set up the module script request</a> given <var>request</var> and
   <var>options</var>.</p></li><li>
    <p>If <var>performFetch</var> was given, run <var>performFetch</var> with <var>request</var>,
    <var>isTopLevel</var>, and with <var>processResponseConsumeBody</var> as defined below.</p>

    <p>Otherwise, <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="fetching-scripts:concept-fetch-8" data-x-internal="concept-fetch">fetch</a> <var>request</var> with <i id="fetching-scripts:processresponseconsumebody-5"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> set to
    <var>processResponseConsumeBody</var> as defined below.</p>

    <p>In both cases, let <var>processResponseConsumeBody</var> given <a href="https://fetch.spec.whatwg.org/#concept-response" id="fetching-scripts:concept-response-11" data-x-internal="concept-response">response</a> <var>response</var> and null, failure, or a
    <a id="fetching-scripts:byte-sequence-6" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bodyBytes</var> be the following algorithm:</p>

    <p class="note"><var>response</var> is always <a href="#cors-same-origin" id="fetching-scripts:cors-same-origin-2">CORS-same-origin</a>.</p>

    <ol><li>
      <p>If any of the following are true:</p>

      <ul><li><p><var>bodyBytes</var> is null or failure; or</p></li><li><p><var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="fetching-scripts:concept-response-status-4" data-x-internal="concept-response-status">status</a> is not an
       <a id="fetching-scripts:ok-status-4" href="https://fetch.spec.whatwg.org/#ok-status" data-x-internal="ok-status">ok status</a>,</p></li></ul>

      <p>then <a href="https://infra.spec.whatwg.org/#map-set" id="fetching-scripts:map-set-3" data-x-internal="map-set">set</a> <var>moduleMap</var>[(<var>url</var>,
      <var>moduleType</var>)] to null, run <var>onComplete</var> given null, and abort these
      steps.</p>
     </li><li><p>Let <var>mimeType</var> be the result of <a href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type" id="fetching-scripts:extract-a-mime-type-4" data-x-internal="extract-a-mime-type">extracting
     a MIME type</a> from <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-header-list" id="fetching-scripts:concept-response-header-list-4" data-x-internal="concept-response-header-list">header list</a>.</p></li><li><p>Let <var>moduleScript</var> be null.</p></li><li><p>Let <var>referrerPolicy</var> be the result of <a href="https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header" id="fetching-scripts:parse-referrer-policy-header-2" data-x-internal="parse-referrer-policy-header">parsing the `<code>Referrer-Policy</code>` header</a>
     given <var>response</var>. <a href="#refsREFERRERPOLICY">[REFERRERPOLICY]</a></p></li><li><p>If <var>referrerPolicy</var> is not the empty string, set <var>options</var>'s <a href="#concept-script-fetch-options-referrer-policy" id="fetching-scripts:concept-script-fetch-options-referrer-policy-5">referrer policy</a> to
     <var>referrerPolicy</var>.</p></li><li><p>If <var>mimeType</var>'s <a href="https://mimesniff.spec.whatwg.org/#mime-type-essence" id="fetching-scripts:mime-type-essence-2" data-x-internal="mime-type-essence">essence</a> is
     "<code id="fetching-scripts:application/wasm"><a href="#application/wasm">application/wasm</a></code>" and <var>moduleType</var> is "<code>javascript-or-wasm</code>", then set <var>moduleScript</var> to the result of
     <a href="#creating-a-webassembly-module-script" id="fetching-scripts:creating-a-webassembly-module-script">creating a WebAssembly module script</a> given <var>bodyBytes</var>,
     <var>settingsObject</var>, <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="fetching-scripts:concept-response-url-5" data-x-internal="concept-response-url">URL</a>, and <var>options</var>.</p></li><li>
      <p>Otherwise:</p>
      <ol><li><p>Let <var>sourceText</var> be the result of <a href="https://encoding.spec.whatwg.org/#utf-8-decode" id="fetching-scripts:utf-8-decode-3" data-x-internal="utf-8-decode">UTF-8
       decoding</a> <var>bodyBytes</var>.</p></li><li><p>If <var>mimeType</var> is a <a id="fetching-scripts:javascript-mime-type-3" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type" data-x-internal="javascript-mime-type">JavaScript MIME type</a> and <var>moduleType</var>
       is "<code>javascript-or-wasm</code>", then set <var>moduleScript</var> to the result of
       <a href="#creating-a-javascript-module-script" id="fetching-scripts:creating-a-javascript-module-script-2">creating a JavaScript module script</a> given <var>sourceText</var>,
       <var>settingsObject</var>, <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="fetching-scripts:concept-response-url-6" data-x-internal="concept-response-url">URL</a>, and <var>options</var>.</p></li><li><p>If the <a id="fetching-scripts:mime-type-essence-3" href="https://mimesniff.spec.whatwg.org/#mime-type-essence" data-x-internal="mime-type-essence">MIME type essence</a> of <var>mimeType</var> is "<code id="fetching-scripts:text/css"><a href="#text/css">text/css</a></code>"
       and <var>moduleType</var> is "<code>css</code>", then set <var>moduleScript</var> to
       the result of <a href="#creating-a-css-module-script" id="fetching-scripts:creating-a-css-module-script">creating a CSS module script</a> given <var>sourceText</var> and
       <var>settingsObject</var>.</p></li><li><p>If <var>mimeType</var> is a <a id="fetching-scripts:json-mime-type" href="https://mimesniff.spec.whatwg.org/#json-mime-type" data-x-internal="json-mime-type">JSON MIME type</a> and
       <var>moduleType</var> is "<code>json</code>", then set <var>moduleScript</var> to
       the result of <a href="#creating-a-json-module-script" id="fetching-scripts:creating-a-json-module-script">creating a JSON module script</a> given <var>sourceText</var> and
       <var>settingsObject</var>.</p></li></ol>
     </li><li>
      <p><a href="https://infra.spec.whatwg.org/#map-set" id="fetching-scripts:map-set-4" data-x-internal="map-set">Set</a> <var>moduleMap</var>[(<var>url</var>,
      <var>moduleType</var>)] to <var>moduleScript</var>, and run <var>onComplete</var> given
      <var>moduleScript</var>.</p>

      <p class="note">It is intentional that the <a href="#module-map" id="fetching-scripts:module-map">module map</a> is keyed by the <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="fetching-scripts:concept-request-url-5" data-x-internal="concept-request-url">request URL</a>, whereas the <a href="#concept-script-base-url" id="fetching-scripts:concept-script-base-url">base URL</a> for the <a href="#module-script" id="fetching-scripts:module-script-13">module script</a> is
      set to the <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="fetching-scripts:concept-response-url-7" data-x-internal="concept-response-url">response URL</a>. The former is used to
      deduplicate fetches, while the latter is used for URL resolution.</p>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="fetch-a-single-imported-module-script">fetch a single imported module script</dfn>, given a <a id="fetching-scripts:url-13" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>,
  an <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-19">environment settings object</a> <var>fetchClient</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="fetching-scripts:concept-request-destination-11" data-x-internal="concept-request-destination">destination</a> <var>destination</var>, a <a href="#script-fetch-options" id="fetching-scripts:script-fetch-options-11">script
  fetch options</a> <var>options</var>, <a href="#environment-settings-object" id="fetching-scripts:environment-settings-object-20">environment settings object</a>
  <var>settingsObject</var>, a <a href="https://fetch.spec.whatwg.org/#concept-request-referrer" id="fetching-scripts:concept-request-referrer-3" data-x-internal="concept-request-referrer">referrer</a>
  <var>referrer</var>, a <a id="fetching-scripts:modulerequest-record-2" href="https://tc39.es/ecma262/#modulerequest-record" data-x-internal="modulerequest-record">ModuleRequest Record</a> <var>moduleRequest</var>, an
  algorithm <var>onComplete</var>, and an optional <a href="#fetching-scripts-perform-fetch" id="fetching-scripts:fetching-scripts-perform-fetch-9">perform the fetch hook</a> <var>performFetch</var>, run
  these steps. <var>onComplete</var> must be an algorithm accepting null (on failure) or a
  <a href="#module-script" id="fetching-scripts:module-script-14">module script</a> (on success).</p>

  <ol><li><p><a id="fetching-scripts:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>moduleRequest</var>.[[Attributes]] does not contain any
   <a id="fetching-scripts:record-2" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> <var>entry</var> such that <var>entry</var>.[[Key]] is not "<code>type</code>", because we only asked for "<code>type</code>" attributes in
   <a href="#hostgetsupportedimportattributes" id="fetching-scripts:hostgetsupportedimportattributes">HostGetSupportedImportAttributes</a>.</p></li><li><p>Let <var>moduleType</var> be the result of running the <a href="#module-type-from-module-request" id="fetching-scripts:module-type-from-module-request-2">module type from module
   request</a> steps given <var>moduleRequest</var>.</p></li><li><p>If the result of running the <a href="#module-type-allowed" id="fetching-scripts:module-type-allowed-2">module type allowed</a> steps given
   <var>moduleType</var> and <var>settingsObject</var> is false, then run <var>onComplete</var>
   given null, and return.</p></li><li><p><a href="#fetch-a-single-module-script" id="fetching-scripts:fetch-a-single-module-script-4">Fetch a single module script</a> given <var>url</var>, <var>fetchClient</var>,
   <var>destination</var>, <var>options</var>, <var>settingsObject</var>, <var>referrer</var>,
   <var>moduleRequest</var>, false, and <var>onComplete</var>. If <var>performFetch</var> was given,
   pass it along as well.</p></li></ol>
  </div>

  <h5 id="creating-scripts"><span class="secno">8.1.4.3</span> Creating scripts<a href="#creating-scripts" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-classic-script">create a classic script</dfn>, given a
  <a id="creating-scripts:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>source</var>, an <a href="#environment-settings-object" id="creating-scripts:environment-settings-object">environment settings object</a>
  <var>settings</var>, a <a id="creating-scripts:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>, a <a href="#script-fetch-options" id="creating-scripts:script-fetch-options">script fetch options</a>
  <var>options</var>, an optional boolean <var>mutedErrors</var> (default false), and an optional
  <a id="creating-scripts:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>-or-null <var>sourceURLForWindowScripts</var> (default null):</p>

  <ol><li>
    <p>If <var>mutedErrors</var> is true, then set <var>baseURL</var> to
    <code id="creating-scripts:about:blank"><a href="#about:blank">about:blank</a></code>.</p>

    <p class="note">When <var>mutedErrors</var> is true, <var>baseURL</var> is the script's
    <a href="#cors-cross-origin" id="creating-scripts:cors-cross-origin">CORS-cross-origin</a> <a href="https://fetch.spec.whatwg.org/#concept-response" id="creating-scripts:concept-response" data-x-internal="concept-response">response</a>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="creating-scripts:concept-response-url" data-x-internal="concept-response-url">url</a>, which shouldn't be exposed to JavaScript. Therefore,
    <var>baseURL</var> is sanitized here.</p>
   </li><li><p>If <a href="#concept-environment-noscript" id="creating-scripts:concept-environment-noscript">scripting is disabled</a> for
   <var>settings</var>, then set <var>source</var> to the empty string.</p></li><li><p>Let <var>script</var> be a new <a href="#classic-script" id="creating-scripts:classic-script">classic script</a> that this algorithm will
   subsequently initialize.</p></li><li><p>Set <var>script</var>'s <a href="#settings-object" id="creating-scripts:settings-object">settings
   object</a> to <var>settings</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-base-url" id="creating-scripts:concept-script-base-url">base URL</a> to
   <var>baseURL</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-script-fetch-options" id="creating-scripts:concept-script-script-fetch-options">fetch
   options</a> to <var>options</var>.</p></li><li><p>Set <var>script</var>'s <a href="#muted-errors" id="creating-scripts:muted-errors">muted errors</a> to <var>mutedErrors</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error">parse error</a> and
   <a href="#concept-script-error-to-rethrow" id="creating-scripts:concept-script-error-to-rethrow">error to rethrow</a> to null.</p></li><li><p><a id="creating-scripts:record-classic-script-creation-time" href="https://w3c.github.io/long-animation-frames/#record-classic-script-creation-time" data-x-internal="record-classic-script-creation-time">Record classic script creation time</a> given <var>script</var> and
   <var>sourceURLForWindowScripts</var>.</p></li><li>
    <p>Let <var>result</var> be <a href="https://tc39.es/ecma262/#sec-parse-script" id="creating-scripts:js-parsescript" data-x-internal="js-parsescript">ParseScript</a>(<var>source</var>,
    <var>settings</var>'s <a href="#environment-settings-object's-realm" id="creating-scripts:environment-settings-object's-realm">realm</a>,
    <var>script</var>).</p>

    <p class="note">Passing <var>script</var> as the last parameter here ensures
    <var>result</var>.[[HostDefined]] will be <var>script</var>.</p>
   </li><li>
    <p>If <var>result</var> is a <a id="creating-scripts:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of errors, then:

    </p><ol><li><p>Set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error-2">parse error</a> and
     its <a href="#concept-script-error-to-rethrow" id="creating-scripts:concept-script-error-to-rethrow-2">error to rethrow</a> to
     <var>result</var>[0].</p></li><li><p>Return <var>script</var>.</p></li></ol>
   </li><li><p>Set <var>script</var>'s <a href="#concept-script-record" id="creating-scripts:concept-script-record">record</a> to
   <var>result</var>.</p></li><li><p>Return <var>script</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-javascript-module-script">create a JavaScript module script</dfn>,
  given a <a id="creating-scripts:string-2" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>source</var>, an <a href="#environment-settings-object" id="creating-scripts:environment-settings-object-2">environment settings
  object</a> <var>settings</var>, a <a id="creating-scripts:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>, and a <a href="#script-fetch-options" id="creating-scripts:script-fetch-options-2">script fetch
  options</a> <var>options</var>:</p>

  <ol><li><p>If <a href="#concept-environment-noscript" id="creating-scripts:concept-environment-noscript-2">scripting is disabled</a> for
   <var>settings</var>, then set <var>source</var> to the empty string.</p></li><li><p>Let <var>script</var> be a new <a href="#module-script" id="creating-scripts:module-script">module script</a> that this algorithm will
   subsequently initialize.</p></li><li><p>Set <var>script</var>'s <a href="#settings-object" id="creating-scripts:settings-object-2">settings
   object</a> to <var>settings</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-base-url" id="creating-scripts:concept-script-base-url-2">base URL</a> to
   <var>baseURL</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-script-fetch-options" id="creating-scripts:concept-script-script-fetch-options-2">fetch
   options</a> to <var>options</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error-3">parse error</a> and
   <a href="#concept-script-error-to-rethrow" id="creating-scripts:concept-script-error-to-rethrow-3">error to rethrow</a> to null.</p></li><li>
    <p>Let <var>result</var> be <a href="https://tc39.es/ecma262/#sec-parsemodule" id="creating-scripts:js-parsemodule" data-x-internal="js-parsemodule">ParseModule</a>(<var>source</var>,
    <var>settings</var>'s <a href="#environment-settings-object's-realm" id="creating-scripts:environment-settings-object's-realm-2">realm</a>,
    <var>script</var>).</p>

    <p class="note">Passing <var>script</var> as the last parameter here ensures
    <var>result</var>.[[HostDefined]] will be <var>script</var>.</p>
   </li><li>
    <p>If <var>result</var> is a <a id="creating-scripts:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of errors, then:</p>

    <ol><li><p>Set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error-4">parse error</a> to
     <var>result</var>[0].</p></li><li><p>Return <var>script</var>.</p></li></ol>
   </li><li><p>Set <var>script</var>'s <a href="#concept-script-record" id="creating-scripts:concept-script-record-2">record</a> to
   <var>result</var>.</p></li><li><p>Return <var>script</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-webassembly-module-script">create a WebAssembly module script</dfn>,
  given a <a id="creating-scripts:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bodyBytes</var>, an <a href="#environment-settings-object" id="creating-scripts:environment-settings-object-3">environment settings
  object</a> <var>settings</var>, a <a id="creating-scripts:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>, and a <a href="#script-fetch-options" id="creating-scripts:script-fetch-options-3">script fetch
  options</a> <var>options</var>:</p>

  <ol><li>
    <p>If <a href="#concept-environment-noscript" id="creating-scripts:concept-environment-noscript-3">scripting is disabled</a> for
    <var>settings</var>, then set <var>bodyBytes</var> to the byte sequence 0x00 0x61 0x73 0x6D 0x01
    0x00 0x00 0x00.</p>

    <p class="note">This byte sequence corresponds to an empty WebAssembly module with only the magic
    bytes and version number provided.</p>
   </li><li><p>Let <var>script</var> be a new <a href="#module-script" id="creating-scripts:module-script-2">module script</a> that this algorithm will
   subsequently initialize.</p></li><li><p>Set <var>script</var>'s <a href="#settings-object" id="creating-scripts:settings-object-3">settings
   object</a> to <var>settings</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-base-url" id="creating-scripts:concept-script-base-url-3">base URL</a> to
   <var>baseURL</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-script-fetch-options" id="creating-scripts:concept-script-script-fetch-options-3">fetch
   options</a> to <var>options</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error-5">parse error</a> and
   <a href="#concept-script-error-to-rethrow" id="creating-scripts:concept-script-error-to-rethrow-4">error to rethrow</a> to null.</p></li><li>
    <p>Let <var>result</var> be the result of <a href="https://webassembly.github.io/esm-integration/js-api/index.html#parse-a-webassembly-module" id="creating-scripts:parse-a-webassembly-module" data-x-internal="parse-a-webassembly-module">parsing a
    WebAssembly module</a> given <var>bodyBytes</var>,
    <var>settings</var>'s <a href="#environment-settings-object's-realm" id="creating-scripts:environment-settings-object's-realm-3">realm</a>, and
    <var>script</var>.</p>

    <p class="note">Passing <var>script</var> as the last parameter here ensures
    <var>result</var>.[[HostDefined]] will be <var>script</var>.</p>
   </li><li>
    <p>If the previous step threw an error <var>error</var>, then:</p>

    <ol><li><p>Set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error-6">parse error</a> to
     <var>error</var>.</p></li><li><p>Return <var>script</var>.</p></li></ol>
   </li><li><p>Set <var>script</var>'s <a href="#concept-script-record" id="creating-scripts:concept-script-record-3">record</a> to
   <var>result</var>.</p></li><li><p>Return <var>script</var>.</p></li></ol>
  </div>

  <p class="note"><cite>WebAssembly JavaScript Interface: ESM Integration</cite> specifies the
  hooks for the WebAssembly integration with ECMA-262 module loading. This includes support both
  for direct dependency imports, as well as for source phase imports, which support virtualization
  and multi-instantiation. <a href="#refsWASMESM">[WASMESM]</a></p>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-css-module-script">create a CSS module script</dfn>, given a
  string <var>source</var> and an <a href="#environment-settings-object" id="creating-scripts:environment-settings-object-4">environment settings object</a> <var>settings</var>:</p>

  <ol><li><p>Let <var>script</var> be a new <a href="#module-script" id="creating-scripts:module-script-3">module script</a> that this algorithm will
   subsequently initialize.</p></li><li><p>Set <var>script</var>'s <a href="#settings-object" id="creating-scripts:settings-object-4">settings
   object</a> to <var>settings</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-base-url" id="creating-scripts:concept-script-base-url-4">base URL</a> and
   <a href="#concept-script-script-fetch-options" id="creating-scripts:concept-script-script-fetch-options-4">fetch options</a> to null.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error-7">parse error</a> and
   <a href="#concept-script-error-to-rethrow" id="creating-scripts:concept-script-error-to-rethrow-5">error to rethrow</a> to null.</p></li><li><p>Let <var>sheet</var> be the result of running the steps to <a id="creating-scripts:create-a-constructed-cssstylesheet" href="https://drafts.csswg.org/cssom/#create-a-constructed-cssstylesheet" data-x-internal="create-a-constructed-cssstylesheet">create a constructed
   <code>CSSStyleSheet</code></a> with an empty dictionary as the argument.</p></li><li>
    <p>Run the steps to <a id="creating-scripts:synchronously-replace-the-rules-of-a-cssstylesheet" href="https://drafts.csswg.org/cssom/#synchronously-replace-the-rules-of-a-cssstylesheet" data-x-internal="synchronously-replace-the-rules-of-a-cssstylesheet">synchronously replace the rules of a <code>CSSStyleSheet</code></a>
    on <var>sheet</var> given <var>source</var>.</p>

    <p>If this throws an exception, catch it, and set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error-8">parse error</a> to that exception, and return
    <var>script</var>.</p>

    <p class="note">The steps to <a id="creating-scripts:synchronously-replace-the-rules-of-a-cssstylesheet-2" href="https://drafts.csswg.org/cssom/#synchronously-replace-the-rules-of-a-cssstylesheet" data-x-internal="synchronously-replace-the-rules-of-a-cssstylesheet">synchronously replace the rules of a
    <code>CSSStyleSheet</code></a> will throw if <var>source</var> contains any <code>@import</code> rules.  This is by-design for now because there is not yet an
    agreement on how to handle these for CSS module scripts; therefore they are blocked altogether
    until a consensus is reached.</p>
   </li><li><p>Set <var>script</var>'s <a href="#concept-script-record" id="creating-scripts:concept-script-record-4">record</a> to the result
   of <a id="creating-scripts:createdefaultexportsyntheticmodule" href="https://tc39.es/ecma262/#sec-create-default-export-synthetic-module" data-x-internal="createdefaultexportsyntheticmodule">CreateDefaultExportSyntheticModule</a>(<var>sheet</var>).</p></li><li><p>Return <var>script</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="creating-a-json-module-script">create a JSON module script</dfn>, given a
  string <var>source</var> and an <a href="#environment-settings-object" id="creating-scripts:environment-settings-object-5">environment settings object</a> <var>settings</var>:</p>

  <ol><li><p>Let <var>script</var> be a new <a href="#module-script" id="creating-scripts:module-script-4">module script</a> that this algorithm will
   subsequently initialize.</p></li><li><p>Set <var>script</var>'s <a href="#settings-object" id="creating-scripts:settings-object-5">settings
   object</a> to <var>settings</var>.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-base-url" id="creating-scripts:concept-script-base-url-5">base URL</a> and
   <a href="#concept-script-script-fetch-options" id="creating-scripts:concept-script-script-fetch-options-5">fetch options</a> to null.</p></li><li><p>Set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error-9">parse error</a> and
   <a href="#concept-script-error-to-rethrow" id="creating-scripts:concept-script-error-to-rethrow-6">error to rethrow</a> to null.</p></li><li>
    <p>Let <var>result</var> be <a id="creating-scripts:parsejsonmodule" href="https://tc39.es/ecma262/#sec-parse-json-module" data-x-internal="parsejsonmodule">ParseJSONModule</a>(<var>source</var>).</p>

    <p>If this throws an exception, catch it, and set <var>script</var>'s <a href="#concept-script-parse-error" id="creating-scripts:concept-script-parse-error-10">parse error</a> to that exception, and return
    <var>script</var>.</p>
   </li><li><p>Set <var>script</var>'s <a href="#concept-script-record" id="creating-scripts:concept-script-record-5">record</a> to
   <var>result</var>.</p></li><li><p>Return <var>script</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="module-type-from-module-request">module type from module request</dfn> steps, given a <a id="creating-scripts:modulerequest-record" href="https://tc39.es/ecma262/#modulerequest-record" data-x-internal="modulerequest-record">ModuleRequest
  Record</a> <var>moduleRequest</var>, are as follows:</p>

  <ol><li><p>Let <var>moduleType</var> be "<code>javascript-or-wasm</code>".</p></li><li>
    <p>If <var>moduleRequest</var>.[[Attributes]] has a <a id="creating-scripts:record" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> <var>entry</var> such
    that <var>entry</var>.[[Key]] is "<code>type</code>", then:</p>

    <ol><li>
      <p>If <var>entry</var>.[[Value]] is "<code>javascript-or-wasm</code>", then set
      <var>moduleType</var> to null.</p>

      <p class="note">This specification uses the "<code>javascript-or-wasm</code>" module
      type internally for <a href="#javascript-module-script" id="creating-scripts:javascript-module-script">JavaScript module scripts</a> or
      <a href="#webassembly-module-script" id="creating-scripts:webassembly-module-script">WebAssembly module scripts</a>, so this step is
      needed to prevent modules from being imported using a
      "<code>javascript-or-wasm</code>" type attribute (a null <var>moduleType</var> will
      cause the <a href="#module-type-allowed" id="creating-scripts:module-type-allowed">module type allowed</a> check to fail).</p>
     </li><li><p>Otherwise, set <var>moduleType</var> to <var>entry</var>.[[Value]].</p></li></ol>
   </li><li><p>Return <var>moduleType</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="module-type-allowed">module type allowed</dfn> steps, given a <a id="creating-scripts:string-3" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>moduleType</var>
  and an <a href="#environment-settings-object" id="creating-scripts:environment-settings-object-6">environment settings object</a> <var>settings</var>, are as follows:</p>

  <ol><li><p>If <var>moduleType</var> is not "<code>javascript-or-wasm</code>", "<code>css</code>", or "<code>json</code>", then return false.</p></li><li><p>If <var>moduleType</var> is "<code>css</code>" and the
   <code id="creating-scripts:cssstylesheet"><a data-x-internal="cssstylesheet" href="https://drafts.csswg.org/cssom/#the-cssstylesheet-interface">CSSStyleSheet</a></code> interface is not <a href="https://webidl.spec.whatwg.org/#dfn-exposed" id="creating-scripts:idl-exposed" data-x-internal="idl-exposed">exposed</a> in
   <var>settings</var>'s <a href="#environment-settings-object's-realm" id="creating-scripts:environment-settings-object's-realm-4">realm</a>, then
   return false.</p></li><li><p>Return true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="fetch-destination-from-module-type">fetch destination from module type</dfn> steps, given a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="creating-scripts:concept-request-destination" data-x-internal="concept-request-destination">destination</a> <var>defaultDestination</var> and a
  <a id="creating-scripts:string-4" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>moduleType</var>, are as follows:</p>

  <ol><li>If <var>moduleType</var> is "<code>json</code>", then return "<code>json</code>".</li><li>If <var>moduleType</var> is "<code>css</code>", then return "<code>style</code>".</li><li>Return <var>defaultDestination</var>.</li></ol>
  </div>

  <h5 id="calling-scripts"><span class="secno">8.1.4.4</span> Calling scripts<a href="#calling-scripts" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="run-a-classic-script" data-export="">run a classic script</dfn> given a <a href="#classic-script" id="calling-scripts:classic-script">classic script</a> <var>script</var>
  and an optional boolean <var>rethrow errors</var> (default false):</p>

  <ol><li><p>Let <var>settings</var> be the <a href="#settings-object" id="calling-scripts:settings-object">settings
   object</a> of <var>script</var>.</p></li><li><p><a href="#check-if-we-can-run-script" id="calling-scripts:check-if-we-can-run-script">Check if we can run script</a> with <var>settings</var>. If this returns "do
   not run", then return <a id="calling-scripts:normalcompletion" href="https://tc39.es/ecma262/#sec-normalcompletion" data-x-internal="normalcompletion">NormalCompletion</a>(empty).</p></li><li><p><a id="calling-scripts:record-classic-script-execution-start-time" href="https://w3c.github.io/long-animation-frames/#record-classic-script-execution-start-time" data-x-internal="record-classic-script-execution-start-time">Record classic script execution start time</a> given <var>script</var>.</p></li><li><p><a href="#prepare-to-run-script" id="calling-scripts:prepare-to-run-script">Prepare to run script</a> given <var>settings</var>.</p></li><li><p>Let <var>evaluationStatus</var> be null.</p></li><li><p>If <var>script</var>'s <a href="#concept-script-error-to-rethrow" id="calling-scripts:concept-script-error-to-rethrow">error to
   rethrow</a> is not null, then set <var>evaluationStatus</var> to
   <a id="calling-scripts:throwcompletion" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(<var>script</var>'s <a href="#concept-script-error-to-rethrow" id="calling-scripts:concept-script-error-to-rethrow-2">error to rethrow</a>).</p></li><li>
    <p>Otherwise, set <var>evaluationStatus</var> to <a href="https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation" id="calling-scripts:js-scriptevaluation" data-x-internal="js-scriptevaluation">ScriptEvaluation</a>(<var>script</var>'s <a href="#concept-script-record" id="calling-scripts:concept-script-record">record</a>).</p>

    <p>If <a href="https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation" id="calling-scripts:js-scriptevaluation-2" data-x-internal="js-scriptevaluation">ScriptEvaluation</a> does not complete because the
    user agent has <a href="#abort-a-running-script" id="calling-scripts:abort-a-running-script">aborted the running script</a>, leave
    <var>evaluationStatus</var> as null.</p>
   </li><li>
    <p>If <var>evaluationStatus</var> is an <a href="https://tc39.es/ecma262/#sec-completion-record-specification-type" id="calling-scripts:completion-record" data-x-internal="completion-record">abrupt
    completion</a>, then:</p>

    <ol><li>
      <p>If <var>rethrow errors</var> is true and <var>script</var>'s <a href="#muted-errors" id="calling-scripts:muted-errors">muted
      errors</a> is false, then:</p>

      <ol><li><p><a href="#clean-up-after-running-script" id="calling-scripts:clean-up-after-running-script">Clean up after running script</a> with <var>settings</var>.</p></li><li><p>Rethrow <var>evaluationStatus</var>.[[Value]].</p></li></ol>

     </li><li>
      <p>If <var>rethrow errors</var> is true and <var>script</var>'s <a href="#muted-errors" id="calling-scripts:muted-errors-2">muted
      errors</a> is true, then:</p>

      <ol><li><p><a href="#clean-up-after-running-script" id="calling-scripts:clean-up-after-running-script-2">Clean up after running script</a> with <var>settings</var>.</p></li><li><p>Throw a <a id="calling-scripts:networkerror" href="https://webidl.spec.whatwg.org/#networkerror" data-x-internal="networkerror">"<code>NetworkError</code>"</a> <code id="calling-scripts:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
     </li><li>
      <p>Otherwise, <var>rethrow errors</var> is false. Perform the following steps:</p>

      <ol><li><p><a href="#report-an-exception" id="calling-scripts:report-an-exception">Report an exception</a> given by <var>evaluationStatus</var>.[[Value]] for
       <var>script</var>'s <a href="#settings-object" id="calling-scripts:settings-object-2">settings object</a>'s
       <a href="#concept-settings-object-global" id="calling-scripts:concept-settings-object-global">global object</a>.</p></li><li><p><a href="#clean-up-after-running-script" id="calling-scripts:clean-up-after-running-script-3">Clean up after running script</a> with <var>settings</var>.</p></li><li><p>Return <var>evaluationStatus</var>.</p></li></ol>
     </li></ol>
   </li><li><p><a href="#clean-up-after-running-script" id="calling-scripts:clean-up-after-running-script-4">Clean up after running script</a> with <var>settings</var>.</p></li><li><p>If <var>evaluationStatus</var> is a normal completion, then return
   <var>evaluationStatus</var>.</p></li><li><p>If we've reached this point, <var>evaluationStatus</var> was left as null because the
   script was <a href="#abort-a-running-script" id="calling-scripts:abort-a-running-script-2">aborted prematurely</a> during evaluation.
   Return <a id="calling-scripts:throwcompletion-2" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(a new <code id="calling-scripts:quotaexceedederror"><a data-x-internal="quotaexceedederror" href="https://webidl.spec.whatwg.org/#quotaexceedederror">QuotaExceededError</a></code>).
   </p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="run-a-module-script" data-export="">run a module script</dfn> given a <a href="#module-script" id="calling-scripts:module-script">module script</a> <var>script</var>
  and an optional boolean <var>preventErrorReporting</var> (default false):</p>

  <ol><li><p>Let <var>settings</var> be the <a href="#settings-object" id="calling-scripts:settings-object-3">settings
   object</a> of <var>script</var>.</p></li><li><p><a href="#check-if-we-can-run-script" id="calling-scripts:check-if-we-can-run-script-2">Check if we can run script</a> with <var>settings</var>. If this returns "do not
   run", then return <a id="calling-scripts:a-promise-resolved-with" href="https://webidl.spec.whatwg.org/#a-promise-resolved-with" data-x-internal="a-promise-resolved-with">a promise resolved with</a> undefined.</p></li><li><p><a id="calling-scripts:record-module-script-execution-start-time" href="https://w3c.github.io/long-animation-frames/#record-module-script-execution-start-time" data-x-internal="record-module-script-execution-start-time">Record module script execution start time</a> given <var>script</var>.</p></li><li><p><a href="#prepare-to-run-script" id="calling-scripts:prepare-to-run-script-2">Prepare to run script</a> given <var>settings</var>.</p></li><li><p>Let <var>evaluationPromise</var> be null.</p></li><li><p>If <var>script</var>'s <a href="#concept-script-error-to-rethrow" id="calling-scripts:concept-script-error-to-rethrow-3">error to
   rethrow</a> is not null, then set <var>evaluationPromise</var> to <a id="calling-scripts:a-promise-rejected-with" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected
   with</a> <var>script</var>'s <a href="#concept-script-error-to-rethrow" id="calling-scripts:concept-script-error-to-rethrow-4">error to
   rethrow</a>.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>record</var> be <var>script</var>'s <a href="#concept-script-record" id="calling-scripts:concept-script-record-2">record</a>.</p>

     </li><li>
      <p>Set <var>evaluationPromise</var> to <var>record</var>.<a href="https://tc39.es/ecma262/#sec-moduleevaluation" id="calling-scripts:js-evaluate" data-x-internal="js-evaluate">Evaluate</a>().</p>

      <p class="note">This step will recursively evaluate all of the module's dependencies.</p>

      <p>If <a href="https://tc39.es/ecma262/#sec-moduleevaluation" id="calling-scripts:js-evaluate-2" data-x-internal="js-evaluate">Evaluate</a> fails to complete as a result of the user agent
      <a href="#abort-a-running-script" id="calling-scripts:abort-a-running-script-3">aborting the running script</a>, then set
      <var>evaluationPromise</var> to <a id="calling-scripts:a-promise-rejected-with-2" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> a new
      <code id="calling-scripts:quotaexceedederror-2"><a data-x-internal="quotaexceedederror" href="https://webidl.spec.whatwg.org/#quotaexceedederror">QuotaExceededError</a></code>.</p>
      </li></ol>
   </li><li><p>If <var>preventErrorReporting</var> is false, then <a id="calling-scripts:upon-rejection" href="https://webidl.spec.whatwg.org/#upon-rejection" data-x-internal="upon-rejection">upon rejection</a> of
   <var>evaluationPromise</var> with <var>reason</var>, <a href="#report-an-exception" id="calling-scripts:report-an-exception-2">report an exception</a> given by
   <var>reason</var> for <var>script</var>'s <a href="#settings-object" id="calling-scripts:settings-object-4">settings
   object</a>'s <a href="#concept-settings-object-global" id="calling-scripts:concept-settings-object-global-2">global object</a>.</p></li><li><p><a href="#clean-up-after-running-script" id="calling-scripts:clean-up-after-running-script-5">Clean up after running script</a> with <var>settings</var>.</p></li><li><p>Return <var>evaluationPromise</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The steps to <dfn id="check-if-we-can-run-script">check if we can run script</dfn> with an <a href="#environment-settings-object" id="calling-scripts:environment-settings-object">environment settings
  object</a> <var>settings</var> are as follows. They return either "run" or "do not run".</p>

  <ol><li><p>If the <a href="#concept-settings-object-global" id="calling-scripts:concept-settings-object-global-3">global object</a> specified by
   <var>settings</var> is a <code id="calling-scripts:window"><a href="#window">Window</a></code> object whose <code id="calling-scripts:document"><a href="#document">Document</a></code> object is not
   <a href="#fully-active" id="calling-scripts:fully-active">fully active</a>, then return "do not run".</p>

   </li><li><p>If <a href="#concept-environment-noscript" id="calling-scripts:concept-environment-noscript">scripting is disabled</a> for
   <var>settings</var>, then return "do not run".</p>

   </li><li><p>Return "run".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The steps to <dfn id="prepare-to-run-script" data-export="">prepare to run script</dfn> with an <a href="#environment-settings-object" id="calling-scripts:environment-settings-object-2">environment settings
  object</a> <var>settings</var> are as follows:</p>

  <ol><li><p>Push <var>settings</var>'s <a href="#realm-execution-context" id="calling-scripts:realm-execution-context">realm execution context</a> onto the <a id="calling-scripts:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript
   execution context stack</a>; it is now the <a id="calling-scripts:running-javascript-execution-context" href="https://tc39.es/ecma262/#running-execution-context" data-x-internal="running-javascript-execution-context">running JavaScript execution
   context</a>.</p></li><li><p>Add <var>settings</var> to the <a id="calling-scripts:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s <a href="#concept-agent-event-loop" id="calling-scripts:concept-agent-event-loop">event loop</a>'s <a href="#currently-running-task" id="calling-scripts:currently-running-task">currently running task</a>'s
   <a href="#script-evaluation-environment-settings-object-set" id="calling-scripts:script-evaluation-environment-settings-object-set">script evaluation environment settings object set</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The steps to <dfn id="clean-up-after-running-script" data-export="">clean up after running script</dfn> with an <a href="#environment-settings-object" id="calling-scripts:environment-settings-object-3">environment settings
  object</a> <var>settings</var> are as follows:</p>

  <ol><li><p><a id="calling-scripts:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>settings</var>'s <a href="#realm-execution-context" id="calling-scripts:realm-execution-context-2">realm execution context</a> is the
   <a id="calling-scripts:running-javascript-execution-context-2" href="https://tc39.es/ecma262/#running-execution-context" data-x-internal="running-javascript-execution-context">running JavaScript execution context</a>.</p></li><li><p>Remove <var>settings</var>'s <a href="#realm-execution-context" id="calling-scripts:realm-execution-context-3">realm execution context</a> from the
   <a id="calling-scripts:javascript-execution-context-stack-2" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a>.</p></li><li><p>If the <a id="calling-scripts:javascript-execution-context-stack-3" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> is now empty, <a href="#perform-a-microtask-checkpoint" id="calling-scripts:perform-a-microtask-checkpoint">perform a
   microtask checkpoint</a>. (If this runs scripts, these algorithms will be invoked
   reentrantly.)</p></li></ol>
  </div>

  <p class="note">These algorithms are not invoked by one script directly calling another, but they
  can be invoked reentrantly in an indirect manner, e.g. if a script dispatches an event which has
  event listeners registered.</p>

  <div data-algorithm="">
  <p>The <dfn id="running-script">running script</dfn> is the <a href="#concept-script" id="calling-scripts:concept-script">script</a> in the
  [[HostDefined]] field in the ScriptOrModule component of the <a id="calling-scripts:running-javascript-execution-context-3" href="https://tc39.es/ecma262/#running-execution-context" data-x-internal="running-javascript-execution-context">running JavaScript execution
  context</a>.</p>
  </div>


  <h5 id="killing-scripts"><span class="secno">8.1.4.5</span> Killing scripts<a href="#killing-scripts" class="self-link"></a></h5>

  <p>Although the JavaScript specification does not account for this possibility, it's sometimes
  necessary to <dfn id="abort-a-running-script" data-lt="abort a running script|abort the running script" data-export="">abort a
  running script</dfn>. This causes any <a href="https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation" id="killing-scripts:js-scriptevaluation" data-x-internal="js-scriptevaluation">ScriptEvaluation</a>
  or <a id="killing-scripts:source-text-module-record" href="https://tc39.es/ecma262/#sec-source-text-module-records" data-x-internal="source-text-module-record">Source Text Module Record</a> <a href="https://tc39.es/ecma262/#sec-moduleevaluation" id="killing-scripts:js-evaluate" data-x-internal="js-evaluate">Evaluate</a> invocations
  to cease immediately, emptying the <a id="killing-scripts:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> without
  triggering any of the normal mechanisms like <code>finally</code> blocks.
  <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <p>User agents may impose resource limitations on scripts, for example CPU quotas, memory limits,
  total execution time limits, or bandwidth limitations. When a script exceeds a limit, the user
  agent may either throw a <code id="killing-scripts:quotaexceedederror"><a data-x-internal="quotaexceedederror" href="https://webidl.spec.whatwg.org/#quotaexceedederror">QuotaExceededError</a></code>, <a href="#abort-a-running-script" id="killing-scripts:abort-a-running-script">abort the script</a> without an exception, prompt the user, or throttle script
  execution.</p>

  <div class="example">

   <p>For example, the following script never terminates. A user agent could, after waiting for a
   few seconds, prompt the user to either terminate the script or let it continue.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- k="">while</c-> <c- p="">(</c-><c- kc="">true</c-><c- p="">)</c-> <c- p="">{</c-> <c- d="">/* loop */</c-> <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <p>User agents are encouraged to allow users to disable scripting whenever the user is prompted
  either by a script (e.g. using the <code id="killing-scripts:dom-alert"><a href="#dom-alert">window.alert()</a></code> API) or because
  of a script's actions (e.g. because it has exceeded a time limit).</p>

  <p>If scripting is disabled while a script is executing, the script should be terminated
  immediately.</p>

  <p>User agents may allow users to specifically disable scripts just for the purposes of closing a
  <a href="#browsing-context" id="killing-scripts:browsing-context">browsing context</a>.</p>

  <p class="example">For example, the prompt mentioned in the example above could also offer the
  user with a mechanism to just close the page entirely, without running any <code id="killing-scripts:event-unload"><a href="#event-unload">unload</a></code> event handlers.</p>

  

  <h5 id="runtime-script-errors"><span class="secno">8.1.4.6</span> Runtime script errors<a href="#runtime-script-errors" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/reportError" title="The reportError() global method may be used to report errors to the console or global event handlers, emulating an uncaught JavaScript exception.">reportError</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>93+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>95+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>95+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="domintro"><dt><code>self.<a href="#dom-reporterror" id="dom-reporterror-dev">reportError</a>(<var>e</var>)</code></dt><dd><p>Dispatches an <code id="runtime-script-errors:event-error"><a href="#event-error">error</a></code> event at the global object for the
   given value <var>e</var>, in the same fashion as an unhandled exception.</p></dd></dl>

  

  

  <div data-algorithm="">
  <p>To <dfn id="extract-error">extract error information</dfn> from a JavaScript value
  <var>exception</var>:</p>

  <ol><li><p>Let <var>attributes</var> be an empty <a href="https://infra.spec.whatwg.org/#ordered-map" id="runtime-script-errors:ordered-map" data-x-internal="ordered-map">map</a> keyed by IDL
   attributes.</p></li><li><p>Set <var>attributes</var>[<code id="runtime-script-errors:dom-errorevent-error"><a href="#dom-errorevent-error">error</a></code>] to
   <var>exception</var>.</p></li><li>
    <p>
     <a id="runtime-script-errors:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
     Set <var>attributes</var>[<code id="runtime-script-errors:dom-errorevent-message"><a href="#dom-errorevent-message">message</a></code>],
     <var>attributes</var>[<code id="runtime-script-errors:dom-errorevent-filename"><a href="#dom-errorevent-filename">filename</a></code>],
     <var>attributes</var>[<code id="runtime-script-errors:dom-errorevent-lineno"><a href="#dom-errorevent-lineno">lineno</a></code>], and
     <var>attributes</var>[<code id="runtime-script-errors:dom-errorevent-colno"><a href="#dom-errorevent-colno">colno</a></code>] to
     <a id="runtime-script-errors:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> values derived from <var>exception</var>.
    </p>

    <p class="note">Browsers implement behavior not specified here or in the JavaScript
    specification to gather values which are helpful, including in unusual cases (e.g., <code>eval</code>). In the future, this might be specified in greater detail.</p>
   </li><li><p>Return <var>attributes</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p id="runtime-script-errors-in-documents"><span id="report-the-error"></span>To <dfn id="report-an-exception" data-export="">report an exception</dfn> <var>exception</var> which is a JavaScript value, for a
  particular <a href="#global-object" id="runtime-script-errors:global-object">global object</a> <var>global</var> and optional boolean <dfn id="report-exception-omiterror"><var>omitError</var></dfn> (default false):</p>

  <ol><li><p>Let <var>notHandled</var> be true.</p></li><li><p>Let <var>errorInfo</var> be the result of <a href="#extract-error" id="runtime-script-errors:extract-error">extracting error
   information</a> from <var>exception</var>.</p></li><li>
    <p>Let <var>script</var> be a <a href="#concept-script" id="runtime-script-errors:concept-script">script</a> found in an
    <a id="runtime-script-errors:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> way, or null. This should usually be the <a href="#running-script" id="runtime-script-errors:running-script">running
    script</a> (most notably during <a href="#run-a-classic-script" id="runtime-script-errors:run-a-classic-script">run a classic script</a>).</p>

    <p class="note">Implementations have not yet settled on interoperable behavior for which script
    is used to determine whether errors are muted in less common cases.</p>
   </li><li><p>If <var>script</var> is a <a href="#classic-script" id="runtime-script-errors:classic-script">classic script</a> and <var>script</var>'s <a href="#muted-errors" id="runtime-script-errors:muted-errors">muted
   errors</a> is true, then set <var>errorInfo</var>[<code id="runtime-script-errors:dom-errorevent-error-2"><a href="#dom-errorevent-error">error</a></code>] to null, <var>errorInfo</var>[<code id="runtime-script-errors:dom-errorevent-message-2"><a href="#dom-errorevent-message">message</a></code>] to "<code>Script error.</code>",
   <var>errorInfo</var>[<code id="runtime-script-errors:dom-errorevent-filename-2"><a href="#dom-errorevent-filename">filename</a></code>] to the empty
   string, <var>errorInfo</var>[<code id="runtime-script-errors:dom-errorevent-lineno-2"><a href="#dom-errorevent-lineno">lineno</a></code>] to 0, and
   <var>errorInfo</var>[<code id="runtime-script-errors:dom-errorevent-colno-2"><a href="#dom-errorevent-colno">colno</a></code>] to 0.</p></li><li><p>If <var>omitError</var> is true, then set <var>errorInfo</var>[<code id="runtime-script-errors:dom-errorevent-error-3"><a href="#dom-errorevent-error">error</a></code>] to null.</p></li><li>
    <p>If <var>global</var> is not <a href="#in-error-reporting-mode" id="runtime-script-errors:in-error-reporting-mode">in error reporting mode</a>, then:</p>

    <ol><li>Set <var>global</var>'s <a href="#in-error-reporting-mode" id="runtime-script-errors:in-error-reporting-mode-2">in error reporting mode</a> to true.</li><li>
      <p>If <var>global</var> implements <code id="runtime-script-errors:eventtarget"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code>, then set <var>notHandled</var> to
      the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="runtime-script-errors:concept-event-fire" data-x-internal="concept-event-fire">firing an event</a> named <code id="runtime-script-errors:event-error-2"><a href="#event-error">error</a></code> at <var>global</var>, using <code id="runtime-script-errors:errorevent"><a href="#errorevent">ErrorEvent</a></code>, with
      the <code id="runtime-script-errors:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true,
      and additional attributes initialized according to <var>errorInfo</var>.</p>

      <p class="note">Returning true in an event handler cancels the event per <a href="#the-event-handler-processing-algorithm" id="runtime-script-errors:the-event-handler-processing-algorithm">the event
      handler processing algorithm</a>.</p>
     </li><li><p>Set <var>global</var>'s <a href="#in-error-reporting-mode" id="runtime-script-errors:in-error-reporting-mode-3">in error reporting mode</a> to false.</p></li></ol>
   </li><li>
    <p>If <var>notHandled</var> is true, then:</p>

    <ol><li><p>Set <var>errorInfo</var>[<code id="runtime-script-errors:dom-errorevent-error-4"><a href="#dom-errorevent-error">error</a></code>] to
     null.</p></li><li>
      <p>If <var>global</var> implements <code id="runtime-script-errors:dedicatedworkerglobalscope"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code>, <a href="#queue-a-global-task" id="runtime-script-errors:queue-a-global-task">queue a
      global task</a> on the <a href="#dom-manipulation-task-source" id="runtime-script-errors:dom-manipulation-task-source">DOM manipulation task source</a> with the
      <var>global</var>'s associated <code id="runtime-script-errors:worker"><a href="#worker">Worker</a></code>'s <a href="#concept-relevant-global" id="runtime-script-errors:concept-relevant-global">relevant global object</a> to
      run these steps:</p>

      <ol><li><p>Let <var>workerObject</var> be the <code id="runtime-script-errors:worker-2"><a href="#worker">Worker</a></code> object associated with
       <var>global</var>.</p></li><li><p>Set <var>notHandled</var> to the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="runtime-script-errors:concept-event-fire-2" data-x-internal="concept-event-fire">firing
       an event</a> named <code id="runtime-script-errors:event-error-3"><a href="#event-error">error</a></code> at <var>workerObject</var>,
       using <code id="runtime-script-errors:errorevent-2"><a href="#errorevent">ErrorEvent</a></code>, with the <code id="runtime-script-errors:dom-event-cancelable-2"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true,
       and additional attributes initialized according to <var>errorInfo</var>.</p></li><li>
        <p>If <var>notHandled</var> is true, then <a href="#report-an-exception" id="runtime-script-errors:report-an-exception">report</a>
        <var>exception</var> for <var>workerObject</var>'s <a href="#concept-relevant-global" id="runtime-script-errors:concept-relevant-global-2">relevant global object</a> with
        <a href="#report-exception-omiterror" id="runtime-script-errors:report-exception-omiterror"><var>omitError</var></a> set to true.</p>

        <p class="note">The actual <var>exception</var> value will not be available in the owner
        realm, but the user agent still carries through enough information to set the message,
        filename, and other attributes, as well as potentially report to a developer console.</p>
       </li></ol>
     </li><li><p>Otherwise, the user agent may report <var>exception</var> to a developer
     console.</p></li></ol>
   </li></ol>
  </div>

  <p>If the implicit port connecting a worker to its <code id="runtime-script-errors:worker-3"><a href="#worker">Worker</a></code> object has been
  disentangled (i.e. if the parent worker has been terminated), then the user agent must act as if
  the <code id="runtime-script-errors:worker-4"><a href="#worker">Worker</a></code> object had no <code id="runtime-script-errors:event-error-4"><a href="#event-error">error</a></code> event handler and as
  if that worker's <code id="runtime-script-errors:handler-workerglobalscope-onerror"><a href="#handler-workerglobalscope-onerror">onerror</a></code> attribute was
  null, but must otherwise act as described above.</p>

  <p class="note">Thus, error reports propagate up to the chain of dedicated workers up to the
  original <code id="runtime-script-errors:document"><a href="#document">Document</a></code>, even if some of the workers along this chain have been terminated
  and garbage collected.</p>

  <p>Previous revisions of this standard defined an algorithm to <dfn id="report-the-exception" data-lt="report the exception" data-export="">report the exception</dfn>. As part of <a href="https://github.com/whatwg/html">issue #958</a>, this has been superseded by <a href="#report-an-exception" id="runtime-script-errors:report-an-exception-2">report an
  exception</a> which behaves differently and takes different inputs. <a href="https://github.com/whatwg/html/issues/10516">Issue #10516</a> tracks updating the
  specification ecosystem.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-reporterror" data-dfn-type="method"><code>reportError(<var>e</var>)</code></dfn> method steps are to
  <a href="#report-an-exception" id="runtime-script-errors:report-an-exception-3">report an exception</a> <var>e</var> for <a id="runtime-script-errors:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
  </div>

  <p class="XXX">It is unclear whether <a href="#muted-errors" id="runtime-script-errors:muted-errors-2">muting</a> is
  applicable here. In Chrome and Safari it is muted, but in Firefox it is not. See also <a href="https://github.com/whatwg/html/issues/958">issue #958</a>.</p>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent" title="The ErrorEvent interface represents events providing information related to errors in scripts or in files.">ErrorEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>27+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div><p id="the-errorevent-interface">The <code id="runtime-script-errors:errorevent-3"><a href="#errorevent">ErrorEvent</a></code> interface is defined as follows:</p>

  <pre><code class="idl">[Exposed=*]
<c- b="">interface</c-> <dfn id="errorevent" data-dfn-type="interface"><c- g="">ErrorEvent</c-></dfn> : <a id="runtime-script-errors:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <a href="https://dom.spec.whatwg.org/#concept-event-constructor" id="runtime-script-errors:dom-event-constructor" data-x-internal="dom-event-constructor"><c- g="">constructor</c-></a>(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#erroreventinit" id="runtime-script-errors:erroreventinit"><c- n="">ErrorEventInit</c-></a> <c- g="">eventInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-errorevent-message" id="runtime-script-errors:dom-errorevent-message-3"><c- g="">message</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-errorevent-filename" id="runtime-script-errors:dom-errorevent-filename-3"><c- g="">filename</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-errorevent-lineno" id="runtime-script-errors:dom-errorevent-lineno-3"><c- g="">lineno</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-errorevent-colno" id="runtime-script-errors:dom-errorevent-colno-3"><c- g="">colno</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">any</c-> <a href="#dom-errorevent-error" id="runtime-script-errors:dom-errorevent-error-5"><c- g="">error</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="erroreventinit" data-dfn-type="dictionary"><c- g="">ErrorEventInit</c-></dfn> : <a id="runtime-script-errors:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- b="">DOMString</c-> <c- g="">message</c-> = "";
  <c- b="">USVString</c-> <c- g="">filename</c-> = "";
  <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">lineno</c-> = 0;
  <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">colno</c-> = 0;
  <c- b="">any</c-> <c- g="">error</c->;
};</code></pre>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ErrorEvent" id="dom-errorevent-message" data-dfn-type="attribute"><code>message</code></dfn>
  attribute must return the value it was initialized to. It represents the error message.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ErrorEvent" id="dom-errorevent-filename" data-dfn-type="attribute"><code>filename</code></dfn> attribute must return the value it was
  initialized to. It represents the <a id="runtime-script-errors:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> of the script in which the error originally
  occurred.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ErrorEvent" id="dom-errorevent-lineno" data-dfn-type="attribute"><code>lineno</code></dfn>
  attribute must return the value it was initialized to. It represents the line number where the
  error occurred in the script.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ErrorEvent" id="dom-errorevent-colno" data-dfn-type="attribute"><code>colno</code></dfn>
  attribute must return the value it was initialized to. It represents the column number where the
  error occurred in the script.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ErrorEvent" id="dom-errorevent-error" data-dfn-type="attribute"><code>error</code></dfn>
  attribute must return the value it was initialized to. It must initially be initialized to
  undefined. Where appropriate, it is set to the object representing the error (e.g., the exception
  object in the case of an uncaught exception).</p>
  </div>

  

  <h5 id="unhandled-promise-rejections"><span class="secno">8.1.4.7</span> Unhandled promise rejections<a href="#unhandled-promise-rejections" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/rejectionhandled_event" title="The rejectionhandled event is sent to the script's global scope (usually window but also Worker) whenever a rejected JavaScript Promise is handled late, i.e. when a handler is attached to the promise after its rejection had caused an unhandledrejection event.">Window/rejectionhandled_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>69+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>11.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>In addition to synchronous <a href="#runtime-script-errors">runtime script errors</a>, scripts
  may experience asynchronous promise rejections, tracked via the <code id="unhandled-promise-rejections:event-unhandledrejection"><a href="#event-unhandledrejection">unhandledrejection</a></code> and <code id="unhandled-promise-rejections:event-rejectionhandled"><a href="#event-rejectionhandled">rejectionhandled</a></code> events. Tracking these
  rejections is done via the <a href="#the-hostpromiserejectiontracker-implementation" id="unhandled-promise-rejections:the-hostpromiserejectiontracker-implementation">HostPromiseRejectionTracker</a> abstract operation, but
  reporting them is defined here.</p>

  

  <div data-algorithm="">
  <p>To <dfn id="notify-about-rejected-promises">notify about rejected promises</dfn> given a <a href="#global-object" id="unhandled-promise-rejections:global-object">global object</a>
  <var>global</var>:</p>

  <ol><li><p>Let <var>list</var> be a <a href="https://infra.spec.whatwg.org/#list-clone" id="unhandled-promise-rejections:list-clone" data-x-internal="list-clone">clone</a> of <var>global</var>'s
   <a href="#about-to-be-notified-rejected-promises-list" id="unhandled-promise-rejections:about-to-be-notified-rejected-promises-list">about-to-be-notified rejected promises list</a>.</p></li><li><p>If <var>list</var> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="unhandled-promise-rejections:list-is-empty" data-x-internal="list-is-empty">is empty</a>, then return.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-empty" id="unhandled-promise-rejections:list-empty" data-x-internal="list-empty">Empty</a> <var>global</var>'s <a href="#about-to-be-notified-rejected-promises-list" id="unhandled-promise-rejections:about-to-be-notified-rejected-promises-list-2">about-to-be-notified
   rejected promises list</a>.</p></li><li>
    <p><a href="#queue-a-global-task" id="unhandled-promise-rejections:queue-a-global-task">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="unhandled-promise-rejections:dom-manipulation-task-source">DOM manipulation task source</a> given
    <var>global</var> to run the following step:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="unhandled-promise-rejections:list-iterate" data-x-internal="list-iterate">For each</a> promise <var>p</var> of <var>list</var>:</p>

      <ol><li><p>If <var>p</var>.[[PromiseIsHandled]] is true, then <a id="unhandled-promise-rejections:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>notCanceled</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="unhandled-promise-rejections:concept-event-fire" data-x-internal="concept-event-fire">firing
       an event</a> named <code id="unhandled-promise-rejections:event-unhandledrejection-2"><a href="#event-unhandledrejection">unhandledrejection</a></code> at
       <var>global</var>, using <code id="unhandled-promise-rejections:promiserejectionevent"><a href="#promiserejectionevent">PromiseRejectionEvent</a></code>, with the <code id="unhandled-promise-rejections:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true, the <code id="unhandled-promise-rejections:dom-promiserejectionevent-promise"><a href="#dom-promiserejectionevent-promise">promise</a></code> attribute initialized to
       <var>p</var>, and the <code id="unhandled-promise-rejections:dom-promiserejectionevent-reason"><a href="#dom-promiserejectionevent-reason">reason</a></code>
       attribute initialized to <var>p</var>.[[PromiseResult]].</p></li><li id="concept-promise-rejection-handled"><p id="concept-promise-rejection-nothandled">If
       <var>notCanceled</var> is true, then the user agent may report
       <var>p</var>.[[PromiseResult]] to a developer console.</p></li><li><p>If <var>p</var>.[[PromiseIsHandled]] is false, then <a href="https://infra.spec.whatwg.org/#set-append" id="unhandled-promise-rejections:set-append" data-x-internal="set-append">append</a> <var>p</var> to <var>global</var>'s <a href="#outstanding-rejected-promises-weak-set" id="unhandled-promise-rejections:outstanding-rejected-promises-weak-set">outstanding rejected
       promises weak set</a>.</p></li></ol>
     </li></ol>
   </li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent" title="The PromiseRejectionEvent interface represents events which are sent to the global script context when JavaScript Promises are rejected. These events are particularly useful for telemetry and debugging purposes.">PromiseRejectionEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>69+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>11.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p id="the-promiserejectionevent-interface">The <code id="unhandled-promise-rejections:promiserejectionevent-2"><a href="#promiserejectionevent">PromiseRejectionEvent</a></code> interface is
  defined as follows:</p>

  <pre><code class="idl">[Exposed=*]
<c- b="">interface</c-> <dfn id="promiserejectionevent" data-dfn-type="interface"><c- g="">PromiseRejectionEvent</c-></dfn> : <a id="unhandled-promise-rejections:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <a href="https://dom.spec.whatwg.org/#concept-event-constructor" id="unhandled-promise-rejections:dom-event-constructor" data-x-internal="dom-event-constructor"><c- g="">constructor</c-></a>(<c- b="">DOMString</c-> <c- g="">type</c->, <a href="#promiserejectioneventinit" id="unhandled-promise-rejections:promiserejectioneventinit"><c- n="">PromiseRejectionEventInit</c-></a> <c- g="">eventInitDict</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="https://webidl.spec.whatwg.org/#idl-object" id="unhandled-promise-rejections:idl-object" data-x-internal="idl-object"><c- b="">object</c-></a> <a href="#dom-promiserejectionevent-promise" id="unhandled-promise-rejections:dom-promiserejectionevent-promise-2"><c- g="">promise</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">any</c-> <a href="#dom-promiserejectionevent-reason" id="unhandled-promise-rejections:dom-promiserejectionevent-reason-2"><c- g="">reason</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="promiserejectioneventinit" data-dfn-type="dictionary"><c- g="">PromiseRejectionEventInit</c-></dfn> : <a id="unhandled-promise-rejections:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- b="">required</c-> <a href="https://webidl.spec.whatwg.org/#idl-object" id="unhandled-promise-rejections:idl-object-2" data-x-internal="idl-object"><c- b="">object</c-></a> <c- g="">promise</c->;
  <c- b="">any</c-> <c- g="">reason</c->;
};</code></pre>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent/promise" title="The PromiseRejectionEvent interface's promise read-only property indicates the JavaScript Promise which was rejected. You can examine the event's PromiseRejectionEvent.reason property to learn why the promise was rejected.">PromiseRejectionEvent/promise</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>69+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>11.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="PromiseRejectionEvent" id="dom-promiserejectionevent-promise" data-dfn-type="attribute"><code>promise</code></dfn> attribute must return the value it
  was initialized to. It represents the promise which this notification is about.</p>
  </div>

  <p class="note">Because of how Web IDL conversion rules for <code><a href="https://webidl.spec.whatwg.org/#idl-promise" id="unhandled-promise-rejections:idl-promise" data-x-internal="idl-promise">Promise</a>&lt;<var>T</var>&gt;</code> types always wrap the input into a new promise, the
  <code id="unhandled-promise-rejections:dom-promiserejectionevent-promise-3"><a href="#dom-promiserejectionevent-promise">promise</a></code> attribute is of type <code id="unhandled-promise-rejections:idl-object-3"><a data-x-internal="idl-object" href="https://webidl.spec.whatwg.org/#idl-object">object</a></code> instead, which is more appropriate for representing an opaque
  handle to the original promise object.</p>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent/reason" title="The PromiseRejectionEvent reason read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject(). This in theory provides information about why the promise was rejected.">PromiseRejectionEvent/reason</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>69+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>11.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="PromiseRejectionEvent" id="dom-promiserejectionevent-reason" data-dfn-type="attribute"><code>reason</code></dfn> attribute must return the value it
  was initialized to. It represents the rejection reason for the promise.</p>
  </div>


  <h5 id="import-map-parse-results"><span class="secno">8.1.4.8</span> Import map parse results<a href="#import-map-parse-results" class="self-link"></a></h5>

  <p>An <dfn id="import-map-parse-result">import map parse result</dfn> is a <a id="import-map-parse-results:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> that is similar to a <a href="#concept-script" id="import-map-parse-results:concept-script">script</a>, and also can be stored in a <code id="import-map-parse-results:the-script-element"><a href="#the-script-element">script</a></code> element's
  <a href="#concept-script-result" id="import-map-parse-results:concept-script-result">result</a>, but is not counted as a <a href="#concept-script" id="import-map-parse-results:concept-script-2">script</a> for other purposes. It has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="import-map-parse-results:struct-item" data-x-internal="struct-item">items</a>:</p>

  <dl><dt>An <dfn id="impr-import-map">import map</dfn></dt><dd>An <a href="#import-map" id="import-map-parse-results:import-map">import map</a> or null.</dd><dt>An <dfn id="impr-error-to-rethrow">error to rethrow</dfn></dt><dd>A JavaScript value representing an error that will prevent using this import map, when
   non-null.</dd></dl>

  <div data-algorithm="">
  <p>To <dfn id="create-an-import-map-parse-result">create an import map parse result</dfn> given a <a id="import-map-parse-results:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>input</var>
  and a <a id="import-map-parse-results:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>:</p>

  <ol><li><p>Let <var>result</var> be an <a href="#import-map-parse-result" id="import-map-parse-results:import-map-parse-result">import map parse result</a> whose <a href="#impr-import-map" id="import-map-parse-results:impr-import-map">import map</a> is null and whose <a href="#impr-error-to-rethrow" id="import-map-parse-results:impr-error-to-rethrow">error to rethrow</a> is null.</p></li><li><p><a href="#parse-an-import-map-string" id="import-map-parse-results:parse-an-import-map-string">Parse an import map string</a> given <var>input</var> and <var>baseURL</var>,
   catching any exceptions. If this threw an exception, then set <var>result</var>'s <a href="#impr-error-to-rethrow" id="import-map-parse-results:impr-error-to-rethrow-2">error to rethrow</a> to that exception. Otherwise, set
   <var>result</var>'s <a href="#impr-import-map" id="import-map-parse-results:impr-import-map-2">import map</a> to the return
   value.</p></li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="register-an-import-map">register an import map</dfn> given a <code id="import-map-parse-results:window"><a href="#window">Window</a></code> <var>global</var> and an
  <a href="#import-map-parse-result" id="import-map-parse-results:import-map-parse-result-2">import map parse result</a> <var>result</var>:</p>

  <ol><li><p>If <var>result</var>'s <a href="#impr-error-to-rethrow" id="import-map-parse-results:impr-error-to-rethrow-3">error to rethrow</a> is
   not null, then <a href="#report-an-exception" id="import-map-parse-results:report-an-exception">report an exception</a> given by <var>result</var>'s <a href="#impr-error-to-rethrow" id="import-map-parse-results:impr-error-to-rethrow-4">error to rethrow</a> for <var>global</var> and
   return.</p></li><li><p><a href="#merge-existing-and-new-import-maps" id="import-map-parse-results:merge-existing-and-new-import-maps">Merge existing and new import
   maps</a>, given <var>global</var> and <var>result</var>'s <a href="#impr-import-map" id="import-map-parse-results:impr-import-map-3">import map</a>.</p></li></ol>
  </div>


  <h5 id="speculation-rules-parse-results"><span class="secno">8.1.4.9</span> Speculation rules parse results<a href="#speculation-rules-parse-results" class="self-link"></a></h5>

  <p>A <dfn id="speculation-rules-parse-result">speculation rules parse result</dfn> is a <a id="speculation-rules-parse-results:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> that is similar to a <a href="#concept-script" id="speculation-rules-parse-results:concept-script">script</a>, and also can be stored in a <code id="speculation-rules-parse-results:the-script-element"><a href="#the-script-element">script</a></code> element's
  <a href="#concept-script-result" id="speculation-rules-parse-results:concept-script-result">result</a>, but is not counted as a <a href="#concept-script" id="speculation-rules-parse-results:concept-script-2">script</a> for other purposes. It has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="speculation-rules-parse-results:struct-item" data-x-internal="struct-item">items</a>:</p>

  <dl><dt>A <dfn id="srpr-sr-set">speculation rule set</dfn></dt><dd>A <a href="#speculation-rule-set" id="speculation-rules-parse-results:speculation-rule-set">speculation rule set</a> or null.</dd><dt>An <dfn id="srpr-error-to-rethrow">error to rethrow</dfn></dt><dd>A JavaScript value representing an error that will prevent using these speculation rules,
   when non-null.</dd></dl>

  <div data-algorithm="">
  <p>To <dfn id="create-a-speculation-rules-parse-result">create a speculation rules parse result</dfn> given a <a id="speculation-rules-parse-results:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a>
  <var>input</var> and a <code id="speculation-rules-parse-results:document"><a href="#document">Document</a></code> <var>document</var>:</p>

  <ol><li><p>Let <var>result</var> be a <a href="#speculation-rules-parse-result" id="speculation-rules-parse-results:speculation-rules-parse-result">speculation rules parse result</a> whose <a href="#srpr-sr-set" id="speculation-rules-parse-results:srpr-sr-set">import map</a> is null and whose <a href="#srpr-error-to-rethrow" id="speculation-rules-parse-results:srpr-error-to-rethrow">error to rethrow</a> is null.</p></li><li><p><a href="#parse-a-speculation-rule-set-string" id="speculation-rules-parse-results:parse-a-speculation-rule-set-string">Parse a speculation rule set string</a> given <var>input</var>,
   <var>document</var>, and <var>document</var>'s <a href="#document-base-url" id="speculation-rules-parse-results:document-base-url">document base URL</a>, catching any
   exceptions. If this threw an exception, then set <var>result</var>'s <a href="#srpr-error-to-rethrow" id="speculation-rules-parse-results:srpr-error-to-rethrow-2">error to rethrow</a> to that exception. Otherwise, set
   <var>result</var>'s <a href="#srpr-sr-set" id="speculation-rules-parse-results:srpr-sr-set-2">speculation rule set</a> to the return
   value.</p></li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="register-speculation-rules">register speculation rules</dfn> given a <code id="speculation-rules-parse-results:window"><a href="#window">Window</a></code> <var>global</var>, a
  <a href="#speculation-rules-parse-result" id="speculation-rules-parse-results:speculation-rules-parse-result-2">speculation rules parse result</a> <var>result</var>, and an optional boolean
  <var>queueErrors</var> (default false):</p>

  <ol><li>
    <p>If <var>result</var>'s <a href="#srpr-error-to-rethrow" id="speculation-rules-parse-results:srpr-error-to-rethrow-3">error to rethrow</a> is not
    null, then:</p>

    <ol><li>
      <p>If <var>queueErrors</var> is true, then <a href="#queue-a-global-task" id="speculation-rules-parse-results:queue-a-global-task">queue a global task</a> on the <a href="#dom-manipulation-task-source" id="speculation-rules-parse-results:dom-manipulation-task-source">DOM
      manipulation task source</a> given <var>global</var> to perform the following step:</p>

      <ol><li><p><a href="#report-an-exception" id="speculation-rules-parse-results:report-an-exception">Report an exception</a> given by <var>result</var>'s <a href="#srpr-error-to-rethrow" id="speculation-rules-parse-results:srpr-error-to-rethrow-4">error to rethrow</a> for <var>global</var>.</p></li></ol>
     </li><li><p>Otherwise, <a href="#report-an-exception" id="speculation-rules-parse-results:report-an-exception-2">report an exception</a> given by <var>result</var>'s <a href="#srpr-error-to-rethrow" id="speculation-rules-parse-results:srpr-error-to-rethrow-5">error to rethrow</a> for <var>global</var>.</p></li><li><p>Return.</p></li></ol>
   </li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="speculation-rules-parse-results:list-append" data-x-internal="list-append">Append</a> <var>result</var>'s <a href="#srpr-sr-set" id="speculation-rules-parse-results:srpr-sr-set-3">speculation rule set</a> to <var>global</var>'s <a href="#concept-document-window" id="speculation-rules-parse-results:concept-document-window">associated <code>Document</code></a>'s <a href="#document-sr-sets" id="speculation-rules-parse-results:document-sr-sets">speculation rule sets</a>.</p></li><li><p><a href="#consider-speculative-loads" id="speculation-rules-parse-results:consider-speculative-loads">Consider speculative loads</a> for <var>global</var>'s <a href="#concept-document-window" id="speculation-rules-parse-results:concept-document-window-2">associated <code>Document</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="unregister-speculation-rules">unregister speculation rules</dfn> given a <code id="speculation-rules-parse-results:window-2"><a href="#window">Window</a></code> <var>global</var> and a
  <a href="#speculation-rules-parse-result" id="speculation-rules-parse-results:speculation-rules-parse-result-3">speculation rules parse result</a> <var>result</var>:</p>

  <ol><li><p>If <var>result</var>'s <a href="#srpr-error-to-rethrow" id="speculation-rules-parse-results:srpr-error-to-rethrow-6">error to rethrow</a> is not
   null, then return.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="speculation-rules-parse-results:list-remove" data-x-internal="list-remove">Remove</a> <var>result</var>'s <a href="#srpr-sr-set" id="speculation-rules-parse-results:srpr-sr-set-4">speculation rule set</a> from <var>global</var>'s <a href="#concept-document-window" id="speculation-rules-parse-results:concept-document-window-3">associated <code>Document</code></a>'s <a href="#document-sr-sets" id="speculation-rules-parse-results:document-sr-sets-2">speculation rule sets</a>.</p></li><li><p><a href="#consider-speculative-loads" id="speculation-rules-parse-results:consider-speculative-loads-2">Consider speculative loads</a> for <var>global</var>'s <a href="#concept-document-window" id="speculation-rules-parse-results:concept-document-window-4">associated <code>Document</code></a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="update-speculation-rules">update speculation rules</dfn> given a <code id="speculation-rules-parse-results:window-3"><a href="#window">Window</a></code> <var>global</var>, a
  <a href="#speculation-rules-parse-result" id="speculation-rules-parse-results:speculation-rules-parse-result-4">speculation rules parse result</a> <var>oldResult</var>, and a <a href="#speculation-rules-parse-result" id="speculation-rules-parse-results:speculation-rules-parse-result-5">speculation rules
  parse result</a> <var>newResult</var>:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="speculation-rules-parse-results:list-remove-2" data-x-internal="list-remove">Remove</a> <var>oldResult</var>'s <a href="#srpr-sr-set" id="speculation-rules-parse-results:srpr-sr-set-5">speculation rule set</a> from <var>global</var>'s <a href="#concept-document-window" id="speculation-rules-parse-results:concept-document-window-5">associated <code>Document</code></a>'s <a href="#document-sr-sets" id="speculation-rules-parse-results:document-sr-sets-3">speculation rule sets</a>.</p></li><li>
    <p><a href="#register-speculation-rules" id="speculation-rules-parse-results:register-speculation-rules">Register speculation rules</a> given <var>global</var>, <var>newResult</var>, and
    true.</p>

    <p id="note-update-speculation-rules-queue-errors" class="note"><a href="#note-update-speculation-rules-queue-errors" class="self-link"></a>When updating speculation rules,
    as opposed to registering them for the first time, we ensure that any <code id="speculation-rules-parse-results:event-error"><a href="#event-error">error</a></code> events are queued as tasks, instead of synchronously fired.
    Although synchronously executing <code id="speculation-rules-parse-results:event-error-2"><a href="#event-error">error</a></code> event handlers is OK
    when inserting <code id="speculation-rules-parse-results:the-script-element-2"><a href="#the-script-element">script</a></code> elements, it's best if other modifications do not cause such
    synchronous script execution.</p>
   </li></ol>
  </div>

  


  <h4 id="module-specifier-resolution"><span class="secno">8.1.5</span> Module specifier resolution<a href="#module-specifier-resolution" class="self-link"></a></h4>

  <h5 id="the-resolution-algorithm"><span class="secno">8.1.5.1</span> The resolution algorithm<a href="#the-resolution-algorithm" class="self-link"></a></h5>

  <p>The <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier">resolve a module specifier</a> algorithm is the primary entry point for
  converting module specifier strings into <a href="https://url.spec.whatwg.org/#concept-url" id="the-resolution-algorithm:url" data-x-internal="url">URLs</a>. When no <a href="#import-map" id="the-resolution-algorithm:import-map">import maps</a> are involved, it is relatively straightforward, and
  reduces to <a href="#resolving-a-url-like-module-specifier" id="the-resolution-algorithm:resolving-a-url-like-module-specifier">resolving a URL-like module specifier</a>.</p>

  <p>When there is a non-empty <a href="#import-map" id="the-resolution-algorithm:import-map-2">import map</a> present, the behavior is more complex. It
  checks candidate entries from all applicable <a href="#module-specifier-map" id="the-resolution-algorithm:module-specifier-map">module specifier
  maps</a>, from most-specific to least-specific <a href="#concept-import-map-scopes" id="the-resolution-algorithm:concept-import-map-scopes">scopes</a> (falling back to the top-level unscoped <a href="#concept-import-map-imports" id="the-resolution-algorithm:concept-import-map-imports">imports</a>), and from most-specific to least-specific
  prefixes. For each candidate, the <a href="#resolving-an-imports-match" id="the-resolution-algorithm:resolving-an-imports-match">resolve
  an imports match</a> algorithm will give one of the following results:</p>

  <ul><li><p>Successful resolution of the specifier to a <a id="the-resolution-algorithm:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>. Then the
  <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier-2">resolve a module specifier</a> algorithm will return that URL.</p></li><li><p>Throwing an exception. Then the <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier-3">resolve a module specifier</a> algorithm will
   rethrow that exception, without any further fallbacks.</p></li><li><p>Failing to resolve, without an error. In this case the outer <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier-4">resolve a module
   specifier</a> algorithm will move on to the next candidate.</p></li></ul>

  <p>In the end, if no successful resolution is found via any of the candidate <a href="#module-specifier-map" id="the-resolution-algorithm:module-specifier-map-2">module specifier maps</a>, <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier-5">resolve a module specifier</a> will throw
  an exception. Thus the result is always either a <a id="the-resolution-algorithm:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> or a thrown exception.</p>

  

  <div data-algorithm="">
  <p>To <dfn id="resolve-a-module-specifier">resolve a module specifier</dfn> given a <a href="#the-script-element" id="the-resolution-algorithm:the-script-element">script</a>-or-null
  <var>referringScript</var> and a <a id="the-resolution-algorithm:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>specifier</var>:</p>

  <ol><li><p>Let <var>settingsObject</var> and <var>baseURL</var> be null.</p></li><li>
    <p>If <var>referringScript</var> is not null, then:</p>

    <ol><li><p>Set <var>settingsObject</var> to <var>referringScript</var>'s
     <a href="#settings-object" id="the-resolution-algorithm:settings-object">settings object</a>.</p></li><li><p>Set <var>baseURL</var> to <var>referringScript</var>'s <a href="#concept-script-base-url" id="the-resolution-algorithm:concept-script-base-url">base URL</a>.</p></li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p><a id="the-resolution-algorithm:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: there is a <a href="#current-settings-object" id="the-resolution-algorithm:current-settings-object">current settings object</a>.</p></li><li><p>Set <var>settingsObject</var> to the <a href="#current-settings-object" id="the-resolution-algorithm:current-settings-object-2">current settings object</a>.</p></li><li><p>Set <var>baseURL</var> to <var>settingsObject</var>'s <a href="#api-base-url" id="the-resolution-algorithm:api-base-url">API base
     URL</a>.</p></li></ol>
   </li><li><p>Let <var>importMap</var> be an <a href="#empty-import-map" id="the-resolution-algorithm:empty-import-map">empty import map</a>.</p></li><li><p>If <var>settingsObject</var>'s <a href="#concept-settings-object-global" id="the-resolution-algorithm:concept-settings-object-global">global
   object</a> implements <code id="the-resolution-algorithm:window"><a href="#window">Window</a></code>, then set <var>importMap</var> to
   <var>settingsObject</var>'s <a href="#concept-settings-object-global" id="the-resolution-algorithm:concept-settings-object-global-2">global object</a>'s
   <a href="#concept-global-import-map" id="the-resolution-algorithm:concept-global-import-map">import map</a>.</p></li><li><p>Let <var>serializedBaseURL</var> be <var>baseURL</var>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-resolution-algorithm:concept-url-serializer" data-x-internal="concept-url-serializer">serialized</a>.</p></li><li><p>Let <var>asURL</var> be the result of <a href="#resolving-a-url-like-module-specifier" id="the-resolution-algorithm:resolving-a-url-like-module-specifier-2">resolving a URL-like module specifier</a>
   given <var>specifier</var> and <var>baseURL</var>.</p></li><li><p>Let <var>normalizedSpecifier</var> be the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-resolution-algorithm:concept-url-serializer-2" data-x-internal="concept-url-serializer">serialization</a> of <var>asURL</var>, if <var>asURL</var> is
   non-null; otherwise, <var>specifier</var>.</p></li><li><p>Let <var>result</var> be a <a id="the-resolution-algorithm:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>-or-null, initially null.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-resolution-algorithm:list-iterate" data-x-internal="list-iterate">For each</a> <var>scopePrefix</var> → <var>scopeImports</var>
    of <var>importMap</var>'s <a href="#concept-import-map-scopes" id="the-resolution-algorithm:concept-import-map-scopes-2">scopes</a>:</p>

    <ol><li>
      <p>If <var>scopePrefix</var> is <var>serializedBaseURL</var>, or if <var>scopePrefix</var> ends
      with U+002F (/) and <var>scopePrefix</var> is a <a id="the-resolution-algorithm:code-unit-prefix" href="https://infra.spec.whatwg.org/#code-unit-prefix" data-x-internal="code-unit-prefix">code unit prefix</a> of
      <var>serializedBaseURL</var>, then:</p>

      <ol><li><p>Let <var>scopeImportsMatch</var> be the result of <a href="#resolving-an-imports-match" id="the-resolution-algorithm:resolving-an-imports-match-2">resolving an imports
       match</a> given <var>normalizedSpecifier</var>, <var>asURL</var>, and
       <var>scopeImports</var>.</p></li><li><p>If <var>scopeImportsMatch</var> is not null, then set <var>result</var> to
       <var>scopeImportsMatch</var>, and <a id="the-resolution-algorithm:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li></ol>
     </li></ol>
   </li><li><p>If <var>result</var> is null, set <var>result</var> to the result of <a href="#resolving-an-imports-match" id="the-resolution-algorithm:resolving-an-imports-match-3">resolving an
   imports match</a> given <var>normalizedSpecifier</var>, <var>asURL</var>, and
   <var>importMap</var>'s <a href="#concept-import-map-imports" id="the-resolution-algorithm:concept-import-map-imports-2">imports</a>.</p></li><li>
    <p>If <var>result</var> is null, set it to <var>asURL</var>.</p>

    <p class="note">By this point, if <var>result</var> was null, <var>specifier</var> wasn't
    remapped to anything by <var>importMap</var>, but it might have been able to be turned into a
    URL.</p>
   </li><li>
    <p>If <var>result</var> is not null, then:</p>

    <ol><li><p><a href="#add-module-to-resolved-module-set" id="the-resolution-algorithm:add-module-to-resolved-module-set">Add module to resolved module set</a> given <var>settingsObject</var>,
     <var>serializedBaseURL</var>, <var>normalizedSpecifier</var>, and <var>asURL</var>.</p></li><li><p>Return <var>result</var>.</p></li></ol>
   </li><li><p>Throw a <code id="the-resolution-algorithm:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that <var>specifier</var> was a bare specifier,
   but was not remapped to anything by <var>importMap</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="resolving-an-imports-match">resolve an imports match</dfn>, given a
  <a id="the-resolution-algorithm:string-2" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>normalizedSpecifier</var>, a <a id="the-resolution-algorithm:url-5" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>-or-null <var>asURL</var>,
  and a <a href="#module-specifier-map" id="the-resolution-algorithm:module-specifier-map-3">module specifier map</a> <var>specifierMap</var>:</p>

  <ol><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-resolution-algorithm:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>specifierKey</var> →
    <var>resolutionResult</var> of <var>specifierMap</var>:</p>

    <ol><li>
      <p>If <var>specifierKey</var> is <var>normalizedSpecifier</var>, then:</p>

      <ol><li>
        <p>If <var>resolutionResult</var> is null, then throw a <code id="the-resolution-algorithm:typeerror-2"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating
        that resolution of <var>specifierKey</var> was blocked by a null entry.</p>

        <p class="note">This will terminate the entire <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier-6">resolve a module specifier</a>
        algorithm, without any further fallbacks.</p>
       </li><li><p><a id="the-resolution-algorithm:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>resolutionResult</var> is a <a id="the-resolution-algorithm:url-6" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p></li><li><p>Return <var>resolutionResult</var>.</p></li></ol>
     </li><li>
      <p>If all of the following are true:</p>

      <ul><li><p><var>specifierKey</var> ends with U+002F (/);</p></li><li><p><var>specifierKey</var> is a <a id="the-resolution-algorithm:code-unit-prefix-2" href="https://infra.spec.whatwg.org/#code-unit-prefix" data-x-internal="code-unit-prefix">code unit prefix</a> of
       <var>normalizedSpecifier</var>; and</p></li><li><p>either <var>asURL</var> is null, or <var>asURL</var> <a id="the-resolution-algorithm:is-special" href="https://url.spec.whatwg.org/#is-special" data-x-internal="is-special">is special</a>,</p></li></ul>

      <p>then:</p>

      <ol><li>
        <p>If <var>resolutionResult</var> is null, then throw a <code id="the-resolution-algorithm:typeerror-3"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating
        that the resolution of <var>specifierKey</var> was blocked by a null entry.</p>

        <p class="note">This will terminate the entire <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier-7">resolve a module specifier</a>
        algorithm, without any further fallbacks.</p>
       </li><li><p><a id="the-resolution-algorithm:assert-3" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>resolutionResult</var> is a <a id="the-resolution-algorithm:url-7" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p></li><li><p>Let <var>afterPrefix</var> be the portion of <var>normalizedSpecifier</var> after the
       initial <var>specifierKey</var> prefix.</p></li><li><p><a id="the-resolution-algorithm:assert-4" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>resolutionResult</var>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-resolution-algorithm:concept-url-serializer-3" data-x-internal="concept-url-serializer">serialized</a>, ends with U+002F (/), as enforced during
       <a href="#parse-an-import-map-string" id="the-resolution-algorithm:parse-an-import-map-string">parsing</a>.</p></li><li><p>Let <var>url</var> be the result of <a href="https://url.spec.whatwg.org/#concept-url-parser" id="the-resolution-algorithm:url-parser" data-x-internal="url-parser">URL parsing</a>
       <var>afterPrefix</var> with <var>resolutionResult</var>.</p></li><li>
        <p>If <var>url</var> is failure, then throw a <code id="the-resolution-algorithm:typeerror-4"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that
        resolution of <var>normalizedSpecifier</var> was blocked since the <var>afterPrefix</var>
        portion could not be URL-parsed relative to the <var>resolutionResult</var> mapped to by
        the <var>specifierKey</var> prefix.</p>

        <p class="note">This will terminate the entire <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier-8">resolve a module specifier</a>
        algorithm, without any further fallbacks.</p>
       </li><li><p><a id="the-resolution-algorithm:assert-5" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>url</var> is a <a id="the-resolution-algorithm:url-8" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>.</p></li><li>
        <p>If the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-resolution-algorithm:concept-url-serializer-4" data-x-internal="concept-url-serializer">serialization</a> of
        <var>resolutionResult</var> is not a <a id="the-resolution-algorithm:code-unit-prefix-3" href="https://infra.spec.whatwg.org/#code-unit-prefix" data-x-internal="code-unit-prefix">code unit prefix</a> of the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-resolution-algorithm:concept-url-serializer-5" data-x-internal="concept-url-serializer">serialization</a> of <var>url</var>, then throw a
        <code id="the-resolution-algorithm:typeerror-5"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that the resolution of <var>normalizedSpecifier</var> was
        blocked due to it backtracking above its prefix <var>specifierKey</var>.</p>

        <p class="note">This will terminate the entire <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier-9">resolve a module specifier</a>
        algorithm, without any further fallbacks.</p>
       </li><li><p>Return <var>url</var>.</p></li></ol>
     </li></ol>
   </li><li>
    <p>Return null.</p>

    <p class="note">The <a href="#resolve-a-module-specifier" id="the-resolution-algorithm:resolve-a-module-specifier-10">resolve a module specifier</a> algorithm will fall back to a
    less-specific scope, or to "<code>imports</code>", if possible.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="resolving-a-url-like-module-specifier">resolve a URL-like module
  specifier</dfn>, given a <a id="the-resolution-algorithm:string-3" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>specifier</var> and a <a id="the-resolution-algorithm:url-9" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>
  <var>baseURL</var>:</p>

  <ol><li>
    <p>If <var>specifier</var> <a id="the-resolution-algorithm:starts-with" href="https://infra.spec.whatwg.org/#string-starts-with" data-x-internal="starts-with">starts with</a> "<code>/</code>", "<code>./</code>", or "<code>../</code>", then:</p>

    <ol><li><p>Let <var>url</var> be the result of <a href="https://url.spec.whatwg.org/#concept-url-parser" id="the-resolution-algorithm:url-parser-2" data-x-internal="url-parser">URL parsing</a>
     <var>specifier</var> with <var>baseURL</var>.</p></li><li>
      <p>If <var>url</var> is failure, then return null.</p>

      <p class="example">One way this could happen is if <var>specifier</var> is "<code>../foo</code>" and <var>baseURL</var> is a <code id="the-resolution-algorithm:data-protocol"><a data-x-internal="data-protocol" href="https://www.rfc-editor.org/rfc/rfc2397#section-2">data:</a></code> URL.</p>
     </li><li><p>Return <var>url</var>.</p></li></ol>

    <p class="note">This includes cases where <var>specifier</var> <a id="the-resolution-algorithm:starts-with-2" href="https://infra.spec.whatwg.org/#string-starts-with" data-x-internal="starts-with">starts with</a> "<code>//</code>", i.e., scheme-relative URLs. Thus, <var>url</var> might end up with a
    different <a href="https://url.spec.whatwg.org/#concept-url-host" id="the-resolution-algorithm:concept-url-host" data-x-internal="concept-url-host">host</a> than <var>baseURL</var>.</p>
   </li><li><p>Let <var>url</var> be the result of <a href="https://url.spec.whatwg.org/#concept-url-parser" id="the-resolution-algorithm:url-parser-3" data-x-internal="url-parser">URL parsing</a>
   <var>specifier</var> (with no base URL).</p></li><li><p>If <var>url</var> is failure, then return null.</p></li><li><p>Return <var>url</var>.</p>
  </li></ol>
  </div>

  


  <h5 id="import-maps"><span class="secno">8.1.5.2</span> Import maps<a href="#import-maps" class="self-link"></a></h5>

  <p>An <a href="#import-map" id="import-map-dev">import map</a> allows control over module specifier resolution. Import maps
  are delivered via inline <code id="import-maps:the-script-element"><a href="#the-script-element">script</a></code> elements with their <code id="import-maps:attr-script-type"><a href="#attr-script-type">type</a></code> attribute set to "<code>importmap</code>", and
  with their <a id="import-maps:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> containing a JSON representation of the import
  map.</p>

  <p>A <code id="import-maps:document"><a href="#document">Document</a></code> can have multiple import maps processed, which can happen either
  before or after any modules have been imported, e.g., via <code id="import-maps:import()"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> expressions or
  <code id="import-maps:the-script-element-2"><a href="#the-script-element">script</a></code> elements with their <code id="import-maps:attr-script-type-2"><a href="#attr-script-type">type</a></code> attribute set
  to "<code>module</code>". The <a href="#merge-existing-and-new-import-maps" id="import-maps:merge-existing-and-new-import-maps">merge existing and new import maps</a> algorithm
  ensures that new import maps cannot define the module resolution for modules that were already
  defined by past import maps, or for ones that were already resolved.</p>

  <div id="example-import-map-bare-specifier" class="example"><a href="#example-import-map-bare-specifier" class="self-link"></a>
   <p>The simplest use of import maps is to globally remap a bare module specifier:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"moment"</c-><c- o="">:</c-> <c- u="">"/node_modules/moment/src/moment.js"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>This enables statements like <code class="js">import moment from "moment";</code>
   to work, fetching and evaluating the JavaScript module at the <code>/node_modules/moment/src/moment.js</code> URL.</p>
  </div>

  <div id="example-import-map-trailing-slashes" class="example"><a href="#example-import-map-trailing-slashes" class="self-link"></a>
   <p>An import map can remap a class of module specifiers into a class of URLs by using trailing
   slashes, like so:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"moment/"</c-><c- o="">:</c-> <c- u="">"/node_modules/moment/src/"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>This enables statements like <code class="js">import localeData from
   "moment/locale/zh-cn.js";</code> to work, fetching and evaluating the JavaScript module at the
   <code>/node_modules/moment/src/locale/zh-cn.js</code> URL. Such trailing-slash
   mappings are often combined with bare-specifier mappings, e.g.</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"moment"</c-><c- o="">:</c-> <c- u="">"/node_modules/moment/src/moment.js"</c-><c- p="">,</c->
    <c- u="">"moment/"</c-><c- o="">:</c-> <c- u="">"/node_modules/moment/src/"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>so that both the "main module" specified by "<code>moment</code>" and the
   "submodules" specified by paths such as "<code>moment/locale/zh-cn.js</code>" are
   available.</p>
  </div>

  <div id="example-import-map-url-like-specifier" class="example"><a href="#example-import-map-url-like-specifier" class="self-link"></a>
   <p>Bare specifiers are not the only type of module specifiers which import maps can remap.
   "URL-like" specifiers, i.e., those that are either parseable as absolute URLs or start with
   "<code>/</code>", "<code>./</code>", or "<code>../</code>", can be
   remapped as well:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"https://cdn.example.com/vue/dist/vue.runtime.esm.js"</c-><c- o="">:</c-> <c- u="">"/node_modules/vue/dist/vue.runtime.esm.js"</c-><c- p="">,</c->
    <c- u="">"/js/app.mjs"</c-><c- o="">:</c-> <c- u="">"/js/app-8e0d62a03.mjs"</c-><c- p="">,</c->
    <c- u="">"../helpers/"</c-><c- o="">:</c-> <c- u="">"https://cdn.example/helpers/"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>Note how the URL to be remapped, as well as the URL being mapped to, can be specified either
   as absolute URLs, or as relative URLs starting with "<code>/</code>", "<code>./</code>", or "<code>../</code>". (They cannot be specified as relative
   URLs without those starting sigils, as those help distinguish from bare module specifiers.) Also
   note how the <a href="#example-import-map-trailing-slashes">trailing slash mapping</a> works in
   this context as well.</p>

   <p>Such remappings operate on the post-canonicalization URL, and do not require a match between
   the literal strings supplied in the import map key and the imported module specifier. So for
   example, if this import map was included on <code>https://example.com/app.html</code>,
   then not only would <code class="js">import "/js/app.mjs"</code> be remapped, but so
   would <code class="js">import "./js/app.mjs"</code> and <code class="js">import "./foo/../js/app.mjs"</code>.</p>
  </div>

  <div id="example-import-map-scopes" class="example"><a href="#example-import-map-scopes" class="self-link"></a>
   <p>All previous examples have globally remapped module specifiers, by using the top-level "<code>imports</code>" key in the import map. The top-level "<code>scopes</code>"
   key can be used to provide localized remappings, which only apply when the referring module
   matches a specific URL prefix. For example:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"scopes"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/a/"</c-> <c- o="">:</c-> <c- p="">{</c->
      <c- u="">"moment"</c-><c- o="">:</c-> <c- u="">"/node_modules/moment/src/moment.js"</c->
    <c- p="">},</c->
    <c- u="">"/b/"</c-> <c- o="">:</c-> <c- p="">{</c->
      <c- u="">"moment"</c-><c- o="">:</c-> <c- u="">"https://cdn.example.com/moment/src/moment.js"</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>With this import map, the statement <code>import "moment"</code> will have
   different meanings depending on which referrer script contains the statement:</p>

   <ul><li><p>Inside scripts located under <code>/a/</code>, this will import <code>/node_modules/moment/src/moment.js</code>.</p></li><li><p>Inside scripts located under <code>/b/</code>, this will import <code>https://cdn.example.com/moment/src/moment.js</code>.</p></li><li><p>Inside scripts located under <code>/c/</code>, this will fail to resolve and
    thus throw an exception.</p></li></ul>

   <p>A typical usage of scopes is to allow multiple versions of the "same" module to exist in a
   web application, with some parts of the module graph importing one version, and other parts
   importing another version.
  </p></div>

  <div id="example-import-map-scopes-overlapping" class="example"><a href="#example-import-map-scopes-overlapping" class="self-link"></a>
   <p>Scopes can overlap each other, and overlap the global "<code>imports</code>"
   specifier map. At resolution time, scopes are consulted in order of most- to least-specific,
   where specificity is measured by sorting the scopes using the <a id="import-maps:code-unit-less-than" href="https://infra.spec.whatwg.org/#code-unit-less-than" data-x-internal="code-unit-less-than">code unit less than</a>
   operation. So, for example, "<code>/scope2/scope3/</code>" is treated as more specific
   than "<code>/scope2/</code>", which is treated as more specific than the top-level
   (unscoped) mappings.</p>

   <p>The following import map illustrates this:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"a"</c-><c- o="">:</c-> <c- u="">"/a-1.mjs"</c-><c- p="">,</c->
    <c- u="">"b"</c-><c- o="">:</c-> <c- u="">"/b-1.mjs"</c-><c- p="">,</c->
    <c- u="">"c"</c-><c- o="">:</c-> <c- u="">"/c-1.mjs"</c->
  <c- p="">},</c->
  <c- u="">"scopes"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/scope2/"</c-><c- o="">:</c-> <c- p="">{</c->
      <c- u="">"a"</c-><c- o="">:</c-> <c- u="">"/a-2.mjs"</c->
    <c- p="">},</c->
    <c- u="">"/scope2/scope3/"</c-><c- o="">:</c-> <c- p="">{</c->
      <c- u="">"b"</c-><c- o="">:</c-> <c- u="">"/b-3.mjs"</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>This results in the following resolutions (using relative URLs for brevity):</p>

   <table id="table-import-map-scopes-example"><thead><tr><td colspan="2" rowspan="2">
      </td><th colspan="3">Specifier
     </th></tr><tr><th>"<code>a</code>"
      </th><th>"<code>b</code>"
      </th><th>"<code>c</code>"
    </th></tr></thead><tbody><tr><th rowspan="3">Referrer
      </th><th><code>/scope1/r.mjs</code>
      </th><td><code>/a-1.mjs</code>
      </td><td><code>/b-1.mjs</code>
      </td><td><code>/c-1.mjs</code>
     </td></tr><tr><th><code>/scope2/r.mjs</code>
      </th><td><code>/a-2.mjs</code>
      </td><td><code>/b-1.mjs</code>
      </td><td><code>/c-1.mjs</code>
     </td></tr><tr><th><code>/scope2/scope3/r.mjs</code>
      </th><td><code>/a-2.mjs</code>
      </td><td><code>/b-3.mjs</code>
      </td><td><code>/c-1.mjs</code>
   </td></tr></tbody></table>
  </div>

  <div id="example-import-map-integrity" class="example"><a href="#example-import-map-integrity" class="self-link"></a>
   <p>Import maps can also be used to provide modules with integrity metadata to be used in
   <cite>Subresource Integrity</cite> checks. <a href="#refsSRI">[SRI]</a>
   </p>

   <p>The following import map illustrates this:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"a"</c-><c- o="">:</c-> <c- u="">"/a-1.mjs"</c-><c- p="">,</c->
    <c- u="">"b"</c-><c- o="">:</c-> <c- u="">"/b-1.mjs"</c-><c- p="">,</c->
    <c- u="">"c"</c-><c- o="">:</c-> <c- u="">"/c-1.mjs"</c->
  <c- p="">},</c->
  <c- u="">"integrity"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/a-1.mjs"</c-><c- o="">:</c-> <c- u="">"sha384-Li9vy3DqF8tnTXuiaAJuML3ky+er10rcgNR/VqsVpcw+ThHmYcwiB1pbOxEbzJr7"</c-><c- p="">,</c->
    <c- u="">"/d-1.mjs"</c-><c- o="">:</c-> <c- u="">"sha384-MBO5IDfYaE6c6Aao94oZrIOiC6CGiSN2n4QUbHNPhzk5Xhm0djZLQqTpL0HzTUxk"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>The above example provides integrity metadata to be enforced on the modules <code>/a-1.mjs</code> and <code>/d-1.mjs</code>, even if the latter is not defined
   as an import in the map.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <a id="import-maps:child-text-content-2" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> of a <code id="import-maps:the-script-element-3"><a href="#the-script-element">script</a></code> element representing an
  <a href="#import-map" id="import-maps:import-map">import map</a> must match the following <dfn id="import-map-authoring-requirements">import map authoring
  requirements</dfn>:</p>

  <ul><li><p>It must be valid JSON. <a href="#refsJSON">[JSON]</a></p></li><li><p>The JSON must represent a JSON object, with at most the three keys "<code>imports</code>", "<code>scopes</code>", and "<code>integrity</code>".</p></li><li><p>The values corresponding to the "<code>imports</code>", "<code>scopes</code>", and "<code>integrity</code>" keys, if present,
   must themselves be JSON objects.</p></li><li><p>The value corresponding to the "<code>imports</code>" key, if present, must be
   a <a href="#valid-module-specifier-map" id="import-maps:valid-module-specifier-map">valid module specifier map</a>.</p></li><li><p>The value corresponding to the "<code>scopes</code>" key, if present, must be a
   JSON object, whose keys are <a href="https://url.spec.whatwg.org/#valid-url-string" id="import-maps:valid-url-string" data-x-internal="valid-url-string">valid URL strings</a> and whose
   values are <a href="#valid-module-specifier-map" id="import-maps:valid-module-specifier-map-2">valid module specifier
   maps</a>.</p></li><li><p>The value corresponding to the "<code>integrity</code>" key, if present, must
   be a JSON object, whose keys are <a href="https://url.spec.whatwg.org/#valid-url-string" id="import-maps:valid-url-string-2" data-x-internal="valid-url-string">valid URL strings</a> and
   whose values fit <a id="import-maps:the-requirements-of-the-integrity-attribute" href="https://w3c.github.io/webappsec-subresource-integrity/#the-integrity-attribute" data-x-internal="the-requirements-of-the-integrity-attribute">the requirements of the integrity attribute</a>.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>A <dfn id="valid-module-specifier-map">valid module specifier map</dfn> is a JSON object that meets the following
  requirements:</p>

  <ul><li><p>All of its keys must be nonempty.</p></li><li><p>All of its values must be strings.</p></li><li><p>Each value must be either a <a href="https://url.spec.whatwg.org/#syntax-url-absolute" id="import-maps:absolute-url" data-x-internal="absolute-url">valid absolute URL</a> or a
   <a id="import-maps:valid-url-string-3" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL string</a> that <a id="import-maps:starts-with" href="https://infra.spec.whatwg.org/#string-starts-with" data-x-internal="starts-with">starts with</a> "<code>/</code>", "<code>./</code>", or "<code>../</code>".</p></li><li><p>If a given key <a id="import-maps:ends-with" href="https://infra.spec.whatwg.org/#string-ends-with" data-x-internal="ends-with">ends with</a> "<code>/</code>", then the corresponding
   value must also.</p></li></ul>
  </div>


  

  <h5 id="import-map-processing-model"><span class="secno">8.1.5.3</span> Import map processing model<a href="#import-map-processing-model" class="self-link"></a></h5>

  <p>Formally, an <dfn id="import-map">import map</dfn> is a <a id="import-map-processing-model:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with three <a href="https://infra.spec.whatwg.org/#struct-item" id="import-map-processing-model:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p><dfn id="concept-import-map-imports">imports</dfn>, a <a href="#module-specifier-map" id="import-map-processing-model:module-specifier-map">module specifier
   map</a>;</p></li><li><p><dfn id="concept-import-map-scopes">scopes</dfn>, an <a id="import-map-processing-model:ordered-map" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> of
   <a href="https://url.spec.whatwg.org/#concept-url" id="import-map-processing-model:url" data-x-internal="url">URLs</a> to <a href="#module-specifier-map" id="import-map-processing-model:module-specifier-map-2">module specifier
   maps</a>; and</p></li><li><p><dfn id="concept-import-map-integrity">integrity</dfn>, a <a href="#module-integrity-map" id="import-map-processing-model:module-integrity-map">module integrity
   map</a>.</p></li></ul>

  <p>A <dfn id="module-specifier-map">module specifier map</dfn> is an <a id="import-map-processing-model:ordered-map-2" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> whose <a href="https://infra.spec.whatwg.org/#map-key" id="import-map-processing-model:map-key" data-x-internal="map-key">keys</a> are <a href="https://infra.spec.whatwg.org/#string" id="import-map-processing-model:string" data-x-internal="string">strings</a> and whose <a href="https://infra.spec.whatwg.org/#map-value" id="import-map-processing-model:map-value" data-x-internal="map-value">values</a> are either <a href="https://url.spec.whatwg.org/#concept-url" id="import-map-processing-model:url-2" data-x-internal="url">URLs</a> or nulls.</p>

  <p>A <dfn id="module-integrity-map">module integrity map</dfn> is an <a id="import-map-processing-model:ordered-map-3" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> whose <a href="https://infra.spec.whatwg.org/#map-key" id="import-map-processing-model:map-key-2" data-x-internal="map-key">keys</a> are <a href="https://url.spec.whatwg.org/#concept-url" id="import-map-processing-model:url-3" data-x-internal="url">URLs</a> and whose <a href="https://infra.spec.whatwg.org/#map-value" id="import-map-processing-model:map-value-2" data-x-internal="map-value">values</a> are <a href="https://infra.spec.whatwg.org/#string" id="import-map-processing-model:string-2" data-x-internal="string">strings</a> that will be used as <a href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata" id="import-map-processing-model:concept-request-integrity-metadata" data-x-internal="concept-request-integrity-metadata">integrity metadata</a>.</p>

  <p>An <dfn id="empty-import-map">empty import map</dfn> is an <a href="#import-map" id="import-map-processing-model:import-map">import map</a> with its <a href="#concept-import-map-imports" id="import-map-processing-model:concept-import-map-imports">imports</a> and <a href="#concept-import-map-scopes" id="import-map-processing-model:concept-import-map-scopes">scopes</a> both being empty maps.</p>

  <hr>

  <p>A <dfn id="specifier-resolution-record">specifier resolution record</dfn> is a <a id="import-map-processing-model:struct-2" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a>. It has the following <a href="https://infra.spec.whatwg.org/#struct-item" id="import-map-processing-model:struct-item-2" data-x-internal="struct-item">items</a>:</p>
  <dl><dt>A <dfn id="specifier-resolution-record-serialized-base-url">serialized base
   URL</dfn></dt><dd>A <a id="import-map-processing-model:string-3" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a>-or-null that represents the base URL of the specifier, when one
   exists.</dd><dt>A <dfn id="specifier-resolution-record-specifier">specifier</dfn></dt><dd>A <a id="import-map-processing-model:string-4" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> representing the specifier.</dd><dt>A <dfn id="specifier-resolution-record-as-url">specifier as a URL</dfn></dt><dd>A <a id="import-map-processing-model:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>-or-null that represents the URL in case of a URL-like module
   specifier.</dd></dl>

  <p class="note">Implementations can replace
  <a href="#specifier-resolution-record-as-url" id="import-map-processing-model:specifier-resolution-record-as-url">specifier as a URL</a> with a boolean that
  indicates that the specifier is either bare or URL-like that <a id="import-map-processing-model:is-special" href="https://url.spec.whatwg.org/#is-special" data-x-internal="is-special">is special</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="add-module-to-resolved-module-set">add module to resolved module set</dfn> given an <a href="#environment-settings-object" id="import-map-processing-model:environment-settings-object">environment settings
  object</a> <var>settingsObject</var>, a <a id="import-map-processing-model:string-5" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>serializedBaseURL</var>, a
  <a id="import-map-processing-model:string-6" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>normalizedSpecifier</var>, and a <a id="import-map-processing-model:url-5" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>-or-null
  <var>asURL</var>:</p>

  <ol><li><p>Let <var>global</var> be <var>settingsObject</var>'s <a href="#concept-settings-object-global" id="import-map-processing-model:concept-settings-object-global">global object</a>.</p></li><li><p>If <var>global</var> does not implement <code id="import-map-processing-model:window"><a href="#window">Window</a></code>, then return.</p></li><li><p>Let <var>record</var> be a new <a href="#specifier-resolution-record" id="import-map-processing-model:specifier-resolution-record">specifier resolution record</a>, with <a href="#specifier-resolution-record-serialized-base-url" id="import-map-processing-model:specifier-resolution-record-serialized-base-url">serialized base URL</a> set to
   <var>serializedBaseURL</var>, <a href="#specifier-resolution-record-specifier" id="import-map-processing-model:specifier-resolution-record-specifier">specifier</a> set to
   <var>normalizedSpecifier</var>, and <a href="#specifier-resolution-record-as-url" id="import-map-processing-model:specifier-resolution-record-as-url-2">specifier as a URL</a> set to
   <var>asURL</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="import-map-processing-model:set-append" data-x-internal="set-append">Append</a> <var>record</var> to <var>global</var>'s
   <a href="#resolved-module-set" id="import-map-processing-model:resolved-module-set">resolved module set</a>.</p></li></ol>
  </div>
  <hr>

  <div data-algorithm="">
  <p>To <dfn id="parse-an-import-map-string">parse an import map string</dfn>, given a <a id="import-map-processing-model:string-7" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>input</var> and a
  <a id="import-map-processing-model:url-6" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>:</p>

  <ol><li><p>Let <var>parsed</var> be the result of <a href="https://infra.spec.whatwg.org/#parse-a-json-string-to-an-infra-value" id="import-map-processing-model:parse-a-json-string-to-an-infra-value" data-x-internal="parse-a-json-string-to-an-infra-value">parsing a JSON string to an Infra value</a> given <var>input</var>.</p></li><li><p>If <var>parsed</var> is not an <a id="import-map-processing-model:ordered-map-4" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>, then throw a
   <code id="import-map-processing-model:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that the top-level value needs to be a JSON object.</p></li><li><p>Let <var>sortedAndNormalizedImports</var> be an empty <a id="import-map-processing-model:ordered-map-5" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>.</p></li><li>
    <p>If <var>parsed</var>["<code>imports</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="import-map-processing-model:map-exists" data-x-internal="map-exists">exists</a>, then:</p>

    <ol><li><p>If <var>parsed</var>["<code>imports</code>"] is not an <a id="import-map-processing-model:ordered-map-6" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered
     map</a>, then throw a <code id="import-map-processing-model:typeerror-2"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that the value for the "<code>imports</code>" top-level key needs to be a JSON object.</p></li><li><p>Set <var>sortedAndNormalizedImports</var> to the result of <a href="#sorting-and-normalizing-a-module-specifier-map" id="import-map-processing-model:sorting-and-normalizing-a-module-specifier-map">sorting and
     normalizing a module specifier map</a> given <var>parsed</var>["<code>imports</code>"] and <var>baseURL</var>.</p></li></ol>
   </li><li><p>Let <var>sortedAndNormalizedScopes</var> be an empty <a id="import-map-processing-model:ordered-map-7" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>.</p></li><li>
    <p>If <var>parsed</var>["<code>scopes</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="import-map-processing-model:map-exists-2" data-x-internal="map-exists">exists</a>, then:</p>

    <ol><li><p>If <var>parsed</var>["<code>scopes</code>"] is not an <a id="import-map-processing-model:ordered-map-8" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered
     map</a>, then throw a <code id="import-map-processing-model:typeerror-3"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that the value for the "<code>scopes</code>" top-level key needs to be a JSON object.</p></li><li><p>Set <var>sortedAndNormalizedScopes</var> to the result of <a href="#sorting-and-normalizing-scopes" id="import-map-processing-model:sorting-and-normalizing-scopes">sorting and normalizing
     scopes</a> given <var>parsed</var>["<code>scopes</code>"] and
     <var>baseURL</var>.</p></li></ol>
   </li><li><p>Let <var>normalizedIntegrity</var> be an empty <a id="import-map-processing-model:ordered-map-9" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>.</p></li><li>
    <p>If <var>parsed</var>["<code>integrity</code>"] <a href="https://infra.spec.whatwg.org/#map-exists" id="import-map-processing-model:map-exists-3" data-x-internal="map-exists">exists</a>, then:</p>

    <ol><li><p>If <var>parsed</var>["<code>integrity</code>"] is not an <a id="import-map-processing-model:ordered-map-10" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered
     map</a>, then throw a <code id="import-map-processing-model:typeerror-4"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that the value for the "<code>integrity</code>" top-level key needs to be a JSON object.</p></li><li><p>Set <var>normalizedIntegrity</var> to the result of <a href="#normalizing-a-module-integrity-map" id="import-map-processing-model:normalizing-a-module-integrity-map">normalizing a module
     integrity map</a> given <var>parsed</var>["<code>integrity</code>"] and
     <var>baseURL</var>.</p></li></ol>
   </li><li>
    <p>If <var>parsed</var>'s <a href="https://infra.spec.whatwg.org/#map-key" id="import-map-processing-model:map-key-3" data-x-internal="map-key">keys</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="import-map-processing-model:list-contains" data-x-internal="list-contains">contains</a> any items besides "<code>imports</code>", "<code>scopes</code>", or "<code>integrity</code>", then the user agent should
    <a id="import-map-processing-model:report-a-warning-to-the-console" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that an invalid top-level key was
    present in the import map.</p>

    <p class="note">This can help detect typos. It is not an error, because that would prevent any
    future extensions from being added backward-compatibly.</p>
   </li><li><p>Return an <a href="#import-map" id="import-map-processing-model:import-map-2">import map</a> whose <a href="#concept-import-map-imports" id="import-map-processing-model:concept-import-map-imports-2">imports</a> are <var>sortedAndNormalizedImports</var>,
   whose <a href="#concept-import-map-scopes" id="import-map-processing-model:concept-import-map-scopes-2">scopes</a> are
   <var>sortedAndNormalizedScopes</var>, and whose <a href="#concept-import-map-integrity" id="import-map-processing-model:concept-import-map-integrity">integrity</a> are
   <var>normalizedIntegrity</var>.</p></li></ol>
  </div>

  <div id="example-import-map-normalization" class="example"><a href="#example-import-map-normalization" class="self-link"></a>
   <p>The <a href="#import-map" id="import-map-processing-model:import-map-3">import map</a> that results from this parsing algorithm is highly normalized.
   For example, given a base URL of <code>https://example.com/base/page.html</code>, the
   input</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"node_modules/helper/index.mjs"</c-><c- p="">,</c->
    <c- u="">"lodash"</c-><c- o="">:</c-> <c- u="">"/node_modules/lodash-es/lodash.js"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>will generate an <a href="#import-map" id="import-map-processing-model:import-map-4">import map</a> with <a href="#concept-import-map-imports" id="import-map-processing-model:concept-import-map-imports-3">imports</a> of</p>

   <pre><code>«[
  "https://example.com/app/helper" → https://example.com/base/node_modules/helper/index.mjs
  "lodash" → https://example.com/node_modules/lodash-es/lodash.js
]»</code></pre>

   <p>and (despite nothing being present in the input string) an empty <a id="import-map-processing-model:ordered-map-11" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> for
   its <a href="#concept-import-map-scopes" id="import-map-processing-model:concept-import-map-scopes-3">scopes</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="merge-module-specifier-maps">merge module specifier maps</dfn>, given a <a href="#module-specifier-map" id="import-map-processing-model:module-specifier-map-3">module specifier map</a>
  <var>newMap</var> and a <a href="#module-specifier-map" id="import-map-processing-model:module-specifier-map-4">module specifier map</a> <var>oldMap</var>:</p>

  <ol><li><p>Let <var>mergedMap</var> be a deep copy of <var>oldMap</var>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#map-iterate" id="import-map-processing-model:map-iterate" data-x-internal="map-iterate">For each</a> <var>specifier</var> →
    <var>url</var> of <var>newMap</var>:</p>

    <ol><li>
      <p>If <var>specifier</var> <a href="https://infra.spec.whatwg.org/#map-exists" id="import-map-processing-model:map-exists-4" data-x-internal="map-exists">exists</a> in
      <var>oldMap</var>, then:</p>

      <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-2" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating the
       ignored rule. They may choose to avoid reporting if the rule is identical to an existing
       one.</p></li><li><p><a id="import-map-processing-model:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
     </li><li><p>Set <var>mergedMap</var>[<var>specifier</var>] to <var>url</var>.</p></li></ol>
   </li><li><p>Return <var>mergedMap</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="merge-existing-and-new-import-maps">merge existing and new import maps</dfn>,
  given a <a href="#concept-settings-object-global" id="import-map-processing-model:concept-settings-object-global-2">global object</a> <var>global</var> and
  an <a href="#import-map" id="import-map-processing-model:import-map-5">import map</a> <var>newImportMap</var>:</p>

  <ol><li>
    <p>Let <var>newImportMapScopes</var> be a deep copy of <var>newImportMap</var>'s <a href="#concept-import-map-scopes" id="import-map-processing-model:concept-import-map-scopes-4">scopes</a>.</p>

    <p class="note">We're mutating these copies and removing items from them when they are used to
    ignore scope-specific rules. This is true for <var>newImportMapScopes</var>, as well as to
    <var>newImportMapImports</var> below.</p>
   </li><li><p>Let <var>oldImportMap</var> be <var>global</var>'s <a href="#concept-global-import-map" id="import-map-processing-model:concept-global-import-map">import map</a>.</p></li><li><p>Let <var>newImportMapImports</var> be a deep copy of <var>newImportMap</var>'s <a href="#concept-import-map-imports" id="import-map-processing-model:concept-import-map-imports-4">imports</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#map-iterate" id="import-map-processing-model:map-iterate-2" data-x-internal="map-iterate">For each</a> <var>scopePrefix</var> →
    <var>scopeImports</var> of <var>newImportMapScopes</var>:</p>

    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="import-map-processing-model:list-iterate" data-x-internal="list-iterate">For each</a> <var>record</var> of <var>global</var>'s
      <a href="#resolved-module-set" id="import-map-processing-model:resolved-module-set-2">resolved module set</a>:</p>

      <ol><li>
        <p>If <var>scopePrefix</var> is <var>record</var>'s <a href="#specifier-resolution-record-serialized-base-url" id="import-map-processing-model:specifier-resolution-record-serialized-base-url-2">serialized base URL</a>, or if
        <var>scopePrefix</var> ends with U+002F (/) and <var>scopePrefix</var> is a <a id="import-map-processing-model:code-unit-prefix" href="https://infra.spec.whatwg.org/#code-unit-prefix" data-x-internal="code-unit-prefix">code unit
        prefix</a> of <var>record</var>'s <a href="#specifier-resolution-record-serialized-base-url" id="import-map-processing-model:specifier-resolution-record-serialized-base-url-3">serialized base URL</a>,
        then:</p>

        <ol><li>
          <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="import-map-processing-model:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>specifierKey</var> →
          <var>resolutionResult</var> of <var>scopeImports</var>:</p>

          <ol><li>
            <p>If <var>specifierKey</var> is <var>record</var>'s <a href="#specifier-resolution-record-specifier" id="import-map-processing-model:specifier-resolution-record-specifier-2">specifier</a>, or if all of the
            following conditions are true:</p>

            <ul><li><p><var>specifierKey</var> ends with U+002F (/);</p></li><li><p><var>specifierKey</var> is a <a id="import-map-processing-model:code-unit-prefix-2" href="https://infra.spec.whatwg.org/#code-unit-prefix" data-x-internal="code-unit-prefix">code unit prefix</a> of
             <var>record</var>'s <a href="#specifier-resolution-record-specifier" id="import-map-processing-model:specifier-resolution-record-specifier-3">specifier</a>;</p></li><li><p>either <var>record</var>'s <a href="#specifier-resolution-record-as-url" id="import-map-processing-model:specifier-resolution-record-as-url-3">specifier as a URL</a> is null or
             <a id="import-map-processing-model:is-special-2" href="https://url.spec.whatwg.org/#is-special" data-x-internal="is-special">is special</a>,</p></li></ul>

            <p>then:</p>

            <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-3" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating the
             ignored rule. They may choose to avoid reporting if the rule is identical to an existing
             one.</p></li><li><p>Remove <var>scopeImports</var>[<var>specifierKey</var>].</p></li></ol>
           </li></ol>
         </li></ol>
       </li></ol>

      <p class="note">Implementers are encouraged to implement a more efficient matching
      algorithm when working with the <a href="#resolved-module-set" id="import-map-processing-model:resolved-module-set-3">resolved module set</a>. As guidance, the number of
      resolved/mapped modules in a large application can be on the order of thousands.</p>
     </li><li><p>If <var>scopePrefix</var> <a href="https://infra.spec.whatwg.org/#map-exists" id="import-map-processing-model:map-exists-5" data-x-internal="map-exists">exists</a> in
     <var>oldImportMap</var>'s <a href="#concept-import-map-scopes" id="import-map-processing-model:concept-import-map-scopes-5">scopes</a>, then
     set <var>oldImportMap</var>'s <a href="#concept-import-map-scopes" id="import-map-processing-model:concept-import-map-scopes-6">scopes</a>[<var>scopePrefix</var>] to the result of
     <a href="#merge-module-specifier-maps" id="import-map-processing-model:merge-module-specifier-maps">merging module specifier maps</a>, given
     <var>scopeImports</var> and <var>oldImportMap</var>'s <a href="#concept-import-map-scopes" id="import-map-processing-model:concept-import-map-scopes-7">scopes</a>[<var>scopePrefix</var>].</p></li><li><p>Otherwise, set <var>oldImportMap</var>'s <a href="#concept-import-map-scopes" id="import-map-processing-model:concept-import-map-scopes-8">scopes</a>[<var>scopePrefix</var>] to
     <var>scopeImports</var>.</p></li></ol>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#map-iterate" id="import-map-processing-model:map-iterate-3" data-x-internal="map-iterate">For each</a> <var>url</var> →
    <var>integrity</var> of <var>newImportMap</var>'s <a href="#concept-import-map-integrity" id="import-map-processing-model:concept-import-map-integrity-2">integrity</a>:</p>

    <ol><li>
      <p>If <var>url</var> <a href="https://infra.spec.whatwg.org/#map-exists" id="import-map-processing-model:map-exists-6" data-x-internal="map-exists">exists</a> in <var>oldImportMap</var>'s
      <a href="#concept-import-map-integrity" id="import-map-processing-model:concept-import-map-integrity-3">integrity</a>, then:</p>

      <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-4" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating the
       ignored rule. They may choose to avoid reporting if the rule is identical to an existing
       one.</p></li><li><p><a id="import-map-processing-model:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
     </li><li><p>Set <var>oldImportMap</var>'s <a href="#concept-import-map-integrity" id="import-map-processing-model:concept-import-map-integrity-4">integrity</a>[<var>url</var>] to
     <var>integrity</var>.</p></li></ol>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="import-map-processing-model:list-iterate-3" data-x-internal="list-iterate">For each</a> <var>record</var> of <var>global</var>'s
    <a href="#resolved-module-set" id="import-map-processing-model:resolved-module-set-4">resolved module set</a>:</p>

    <ol><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="import-map-processing-model:list-iterate-4" data-x-internal="list-iterate">For each</a> <var>specifier</var> → <var>url</var> of
      <var>newImportMapImports</var>:</p>

      <ol><li>
        <p>If <var>specifier</var> <a id="import-map-processing-model:starts-with" href="https://infra.spec.whatwg.org/#string-starts-with" data-x-internal="starts-with">starts with</a> <var>record</var>'s <a href="#specifier-resolution-record-specifier" id="import-map-processing-model:specifier-resolution-record-specifier-4">specifier</a>, then:</p>

        <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-5" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating the
         ignored rule. They may choose to avoid reporting if the rule is identical to an existing
         one.</p></li><li><p>Remove <var>newImportMapImports</var>[<var>specifier</var>].</p></li></ol>
       </li></ol>
     </li></ol>
   </li><li><p>Set <var>oldImportMap</var>'s <a href="#concept-import-map-imports" id="import-map-processing-model:concept-import-map-imports-5">imports</a> to
   the result of <a href="#merge-module-specifier-maps" id="import-map-processing-model:merge-module-specifier-maps-2">merge module specifier maps</a>,
   given <var>newImportMapImports</var> and <var>oldImportMap</var>'s <a href="#concept-import-map-imports" id="import-map-processing-model:concept-import-map-imports-6">imports</a>.</p></li></ol>
  </div>

  <p>The above algorithm merges a new import map into the given <a href="#environment-settings-object" id="import-map-processing-model:environment-settings-object-2">environment settings
  object</a>'s <a href="#global-object" id="import-map-processing-model:global-object">global object</a>'s <a href="#import-map" id="import-map-processing-model:import-map-6">import map</a>. Let's examine a few
  examples:</p>

  <div id="example-import-map-merge-unrelated" class="example"><a href="#example-import-map-merge-unrelated" class="self-link"></a>
   <p>There are two cases when rules of the new import map don't get merged into the existing
   one.</p>

   <ol><li><p>The new import map rule has the exact same scope and specifier as a rule in the existing
    import map. We'll call that "conflicting rule".</p></li><li><p>The new import map rule may impact the resolution of an already resolved module. We'll
    call that "impacted already resolved module".</p></li></ol>

   <p>When the new import map has no conflicting rules, and there are no impacted resolved modules,
   the resulting map would be a combination of the new and existing maps. Rules that would have
   individually impacted similar modules (e.g. "/app/" and "/app/helper") but are not an exact
   match are not conflicting, and all make it to the merged map.</p>

   <p>So, the following existing and new import maps:</p>

   <pre><code class="json"><c- p="">{</c->
   <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/"</c-><c- o="">:</c-> <c- u="">"./original-app/"</c-><c- p="">,</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./helper/index.mjs"</c->
  <c- p="">},</c->
  <c- u="">"scopes"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/js"</c-><c- o="">:</c-> <c- p="">{</c->
      <c- u="">"/app/"</c-><c- o="">:</c-> <c- u="">"./js-app/"</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>Would be equivalent to the following single import map:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/"</c-><c- o="">:</c-> <c- u="">"./original-app/"</c-><c- p="">,</c->
    <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./helper/index.mjs"</c->
  <c- p="">},</c->
  <c- u="">"scopes"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/js"</c-><c- o="">:</c-> <c- p="">{</c->
      <c- u="">"/app/"</c-><c- o="">:</c-> <c- u="">"./js-app/"</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>
  </div>

  <div id="example-import-map-merge-conflict-imports" class="example"><a href="#example-import-map-merge-conflict-imports" class="self-link"></a>
   <p>When the new import map impacts an already resolved module, that rule gets dropped from the
   import map.</p>

   <p>So, if the <a href="#resolved-module-set" id="import-map-processing-model:resolved-module-set-5">resolved module set</a> already contains the "<code>/app/helper</code>", the following new import map:</p>

   <pre><code class="json"><c- p="">{</c->
   <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./helper/index.mjs"</c-><c- p="">,</c->
    <c- u="">"lodash"</c-><c- o="">:</c-> <c- u="">"/node_modules/lodash-es/lodash.js"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>Would be equivalent to the following one:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"lodash"</c-><c- o="">:</c-> <c- u="">"/node_modules/lodash-es/lodash.js"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>
  </div>

  <div id="example-import-map-merge-conflict-scopes" class="example"><a href="#example-import-map-merge-conflict-scopes" class="self-link"></a>
   <p>The same is true for rules that impact already resolved modules defined in specific scopes.
   If we already resolved "<code>/app/helper</code>" from "<code>/app/main.mjs</code>" the following new import map:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"scopes"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/"</c-><c- o="">:</c-> <c- p="">{</c->
      <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./helper/index.mjs"</c->
    <c- p="">}</c->
  <c- p="">},</c->
   <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"lodash"</c-><c- o="">:</c-> <c- u="">"/node_modules/lodash-es/lodash.js"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>Would similarly be equivalent to:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"lodash"</c-><c- o="">:</c-> <c- u="">"/node_modules/lodash-es/lodash.js"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>
  </div>

  <div id="example-import-map-merge-conflict-imports-and-scopes" class="example"><a href="#example-import-map-merge-conflict-imports-and-scopes" class="self-link"></a>
   <p>We could also have cases where a single already-resolved module specifier has multiple rules
   for its resolution, depending on the referring script. In such cases, only the relevant rules
   would not be added to the map.</p>
   <p>For example, if we already resolved "<code>/app/helper</code>" from "<code>/app/vendor/main.mjs</code>", the following new import map:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"scopes"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/"</c-><c- o="">:</c-> <c- p="">{</c->
      <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./helper/index.mjs"</c->
    <c- p="">},</c->
    <c- u="">"/app/vendor/"</c-><c- o="">:</c-> <c- p="">{</c->
      <c- u="">"/app/"</c-><c- o="">:</c-> <c- u="">"./vendor_helper/"</c->
    <c- p="">},</c->
    <c- u="">"/vendor/"</c-><c- o="">:</c-> <c- p="">{</c->
      <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./helper/vendor_index.mjs"</c->
    <c- p="">}</c->
  <c- p="">},</c->
   <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"lodash"</c-><c- o="">:</c-> <c- u="">"/node_modules/lodash-es/lodash.js"</c->
    <c- u="">"/app/"</c-><c- o="">:</c-> <c- u="">"./general_app_path/"</c->
    <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./other_path/helper/index.mjs"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>Would be equivalent to:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"scopes"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/vendor/"</c-><c- o="">:</c-> <c- p="">{</c->
      <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./helper/vendor_index.mjs"</c->
    <c- p="">}</c->
  <c- p="">},</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"lodash"</c-><c- o="">:</c-> <c- u="">"/node_modules/lodash-es/lodash.js"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

  <p>This is achieved by the fact that the merge algorithm tracks already resolved modules
  and removes rules affecting them from new import maps before they are merged into the existing
  one.</p>
  </div>

  <div id="example-import-map-merge-two-map-conflict" class="example"><a href="#example-import-map-merge-two-map-conflict" class="self-link"></a>
   <p>When the new import map has conflicting rules to the existing import map, with no impacted
   already resolved modules, the existing import map rules persist.</p>

   <p>For example, the following existing and new import maps:</p>

   <pre><code class="json"><c- p="">{</c->
   <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./helper/index.mjs"</c-><c- p="">,</c->
    <c- u="">"lodash"</c-><c- o="">:</c-> <c- u="">"/node_modules/lodash-es/lodash.js"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./main/helper/index.mjs"</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>Would be equivalent to the following single import map:</p>

   <pre><code class="json"><c- p="">{</c->
  <c- u="">"imports"</c-><c- o="">:</c-> <c- p="">{</c->
    <c- u="">"/app/helper"</c-><c- o="">:</c-> <c- u="">"./helper/index.mjs"</c-><c- p="">,</c->
    <c- u="">"lodash"</c-><c- o="">:</c-> <c- u="">"/node_modules/lodash-es/lodash.js"</c-><c- p="">,</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="sorting-and-normalizing-a-module-specifier-map">sort and normalize a module
  specifier map</dfn>, given an <a id="import-map-processing-model:ordered-map-12" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> <var>originalMap</var> and a
  <a id="import-map-processing-model:url-7" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>:</p>

  <ol><li><p>Let <var>normalized</var> be an empty <a id="import-map-processing-model:ordered-map-13" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="import-map-processing-model:list-iterate-5" data-x-internal="list-iterate">For each</a> <var>specifierKey</var> → <var>value</var> of
    <var>originalMap</var>:</p>

    <ol><li><p>Let <var>normalizedSpecifierKey</var> be the result of <a href="#normalizing-a-specifier-key" id="import-map-processing-model:normalizing-a-specifier-key">normalizing a specifier
     key</a> given <var>specifierKey</var> and <var>baseURL</var>.</p></li><li><p>If <var>normalizedSpecifierKey</var> is null, then <a id="import-map-processing-model:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li>
      <p>If <var>value</var> is not a <a id="import-map-processing-model:string-8" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a>, then:</p>

      <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-6" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that
       addresses need to be strings.</p></li><li><p>Set <var>normalized</var>[<var>normalizedSpecifierKey</var>] to null.</p></li><li><p><a id="import-map-processing-model:continue-4" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
     </li><li><p>Let <var>addressURL</var> be the result of <a href="#resolving-a-url-like-module-specifier" id="import-map-processing-model:resolving-a-url-like-module-specifier">resolving a URL-like module
     specifier</a> given <var>value</var> and <var>baseURL</var>.</p></li><li>
      <p>If <var>addressURL</var> is null, then:</p>

      <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-7" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that the
       address was invalid.</p></li><li><p>Set <var>normalized</var>[<var>normalizedSpecifierKey</var>] to null.</p></li><li><p><a id="import-map-processing-model:continue-5" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
     </li><li>
      <p>If <var>specifierKey</var> ends with U+002F (/), and the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="import-map-processing-model:concept-url-serializer" data-x-internal="concept-url-serializer">serialization</a> of <var>addressURL</var> does not end
      with U+002F (/), then:</p>

      <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-8" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that an
       invalid address was given for the specifier key <var>specifierKey</var>; since
       <var>specifierKey</var> ends with a slash, the address needs to as well.</p></li><li><p>Set <var>normalized</var>[<var>normalizedSpecifierKey</var>] to null.</p></li><li><p><a id="import-map-processing-model:continue-6" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
     </li><li><p>Set <var>normalized</var>[<var>normalizedSpecifierKey</var>] to
     <var>addressURL</var>.</p></li></ol>
   </li><li><p>Return the result of <a href="https://infra.spec.whatwg.org/#map-sort-in-descending-order" id="import-map-processing-model:map-sort-descending" data-x-internal="map-sort-descending">sorting in descending order</a>
   <var>normalized</var>, with an entry <var>a</var> being less than an entry <var>b</var> if
   <var>a</var>'s <a href="https://infra.spec.whatwg.org/#map-key" id="import-map-processing-model:map-key-4" data-x-internal="map-key">key</a> is <a id="import-map-processing-model:code-unit-less-than" href="https://infra.spec.whatwg.org/#code-unit-less-than" data-x-internal="code-unit-less-than">code unit less than</a>
   <var>b</var>'s <a href="https://infra.spec.whatwg.org/#map-key" id="import-map-processing-model:map-key-5" data-x-internal="map-key">key</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="sorting-and-normalizing-scopes">sort and normalize scopes</dfn>, given an
  <a id="import-map-processing-model:ordered-map-14" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> <var>originalMap</var> and a <a id="import-map-processing-model:url-8" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>:</p>

  <ol><li><p>Let <var>normalized</var> be an empty <a id="import-map-processing-model:ordered-map-15" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="import-map-processing-model:list-iterate-6" data-x-internal="list-iterate">For each</a> <var>scopePrefix</var> →
    <var>potentialSpecifierMap</var> of <var>originalMap</var>:</p>

    <ol><li><p>If <var>potentialSpecifierMap</var> is not an <a id="import-map-processing-model:ordered-map-16" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>, then throw a
     <code id="import-map-processing-model:typeerror-5"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> indicating that the value of the scope with prefix
     <var>scopePrefix</var> needs to be a JSON object.</p></li><li><p>Let <var>scopePrefixURL</var> be the result of <a href="https://url.spec.whatwg.org/#concept-url-parser" id="import-map-processing-model:url-parser" data-x-internal="url-parser">URL
     parsing</a> <var>scopePrefix</var> with <var>baseURL</var>.</p></li><li>
      <p>If <var>scopePrefixURL</var> is failure, then:</p>

      <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-9" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> that the scope prefix
       URL was not parseable.</p></li><li><p><a id="import-map-processing-model:continue-7" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
     </li><li><p>Let <var>normalizedScopePrefix</var> be the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="import-map-processing-model:concept-url-serializer-2" data-x-internal="concept-url-serializer">serialization</a> of <var>scopePrefixURL</var>.</p></li><li><p>Set <var>normalized</var>[<var>normalizedScopePrefix</var>] to the result of
     <a href="#sorting-and-normalizing-a-module-specifier-map" id="import-map-processing-model:sorting-and-normalizing-a-module-specifier-map-2">sorting and normalizing a module specifier map</a> given
     <var>potentialSpecifierMap</var> and <var>baseURL</var>.</p></li></ol>
   </li><li><p>Return the result of <a href="https://infra.spec.whatwg.org/#map-sort-in-descending-order" id="import-map-processing-model:map-sort-descending-2" data-x-internal="map-sort-descending">sorting in descending
   order</a> <var>normalized</var>, with an entry <var>a</var> being less than an entry
   <var>b</var> if <var>a</var>'s <a href="https://infra.spec.whatwg.org/#map-key" id="import-map-processing-model:map-key-6" data-x-internal="map-key">key</a> is <a id="import-map-processing-model:code-unit-less-than-2" href="https://infra.spec.whatwg.org/#code-unit-less-than" data-x-internal="code-unit-less-than">code unit less
   than</a> <var>b</var>'s <a href="https://infra.spec.whatwg.org/#map-key" id="import-map-processing-model:map-key-7" data-x-internal="map-key">key</a>.</p></li></ol>
  </div>

  <p class="note">In the above two algorithms, sorting keys and scopes in descending order has the
  effect of putting "<code>foo/bar/</code>" before "<code>foo/</code>". This in
  turn gives "<code>foo/bar/</code>" a higher priority than "<code>foo/</code>"
  during <a href="#resolve-a-module-specifier" id="import-map-processing-model:resolve-a-module-specifier">module specifier resolution</a>.</p>

  <div data-algorithm="">
  <p>To <dfn id="normalizing-a-module-integrity-map">normalize a module integrity map</dfn>,
  given an <a id="import-map-processing-model:ordered-map-17" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> <var>originalMap</var>:</p>

  <ol><li><p>Let <var>normalized</var> be an empty <a id="import-map-processing-model:ordered-map-18" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="import-map-processing-model:list-iterate-7" data-x-internal="list-iterate">For each</a> <var>key</var> → <var>value</var> of
    <var>originalMap</var>:</p>

    <ol><li>
      <p>Let <var>resolvedURL</var> be the result of <a href="#resolving-a-url-like-module-specifier" id="import-map-processing-model:resolving-a-url-like-module-specifier-2">resolving a URL-like module
      specifier</a> given <var>key</var> and <var>baseURL</var>.</p>

      <p class="note">Unlike "<code>imports</code>", keys of the integrity map are treated
      as URLs, not module specifiers. However, we use the <a href="#resolving-a-url-like-module-specifier" id="import-map-processing-model:resolving-a-url-like-module-specifier-3">resolve a URL-like module specifier</a> algorithm to prohibit "bare" relative
      URLs like <code>foo</code>, which could be mistaken for module specifiers.</p>
     </li><li>
      <p>If <var>resolvedURL</var> is null, then:</p>

      <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-10" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that
       the key failed to resolve.</p></li><li><p><a id="import-map-processing-model:continue-8" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
     </li><li>
      <p>If <var>value</var> is not a <a id="import-map-processing-model:string-9" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a>, then:</p>

      <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-11" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that
       <a href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata" id="import-map-processing-model:concept-request-integrity-metadata-2" data-x-internal="concept-request-integrity-metadata">integrity metadata</a> values need to
       be <a href="https://infra.spec.whatwg.org/#string" id="import-map-processing-model:string-10" data-x-internal="string">strings</a>.</p></li><li><p><a id="import-map-processing-model:continue-9" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</p></li></ol>
     </li><li><p>Set <var>normalized</var>[<var>resolvedURL</var>] to <var>value</var>.</p></li></ol>
   </li><li><p>Return <var>normalized</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="normalizing-a-specifier-key">normalize a specifier key</dfn>, given a <a id="import-map-processing-model:string-11" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>specifierKey</var> and a <a id="import-map-processing-model:url-9" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>baseURL</var>:</p>

  <ol><li>
    <p>If <var>specifierKey</var> is the empty string, then:</p>

    <ol><li><p>The user agent may <a id="import-map-processing-model:report-a-warning-to-the-console-12" href="https://console.spec.whatwg.org/#report-a-warning-to-the-console" data-x-internal="report-a-warning-to-the-console">report a warning to the console</a> indicating that specifier keys may not be the empty string.</p></li><li><p>Return null.</p></li></ol>
   </li><li><p>Let <var>url</var> be the result of <a href="#resolving-a-url-like-module-specifier" id="import-map-processing-model:resolving-a-url-like-module-specifier-4">resolving a URL-like module specifier</a>, given <var>specifierKey</var> and <var>baseURL</var>.</p></li><li><p>If <var>url</var> is not null, then return the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="import-map-processing-model:concept-url-serializer-3" data-x-internal="concept-url-serializer">serialization</a> of <var>url</var>.</p></li><li><p>Return <var>specifierKey</var>.</p></li></ol>
  </div>


  <h4 id="javascript-specification-host-hooks"><span class="secno">8.1.6</span> JavaScript specification host hooks<a href="#javascript-specification-host-hooks" class="self-link"></a></h4>

  <p>The JavaScript specification contains a number of <a id="javascript-specification-host-hooks:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> abstract
  operations, that vary depending on the host environment. This section defines them for user
  agent hosts.</p>

  <div data-algorithm="">
  <h5 id="the-hostensurecanaddprivateelement-implementation"><span class="secno">8.1.6.1</span> <dfn>HostEnsureCanAddPrivateElement</dfn>(<var>O</var>)<a href="#the-hostensurecanaddprivateelement-implementation" class="self-link"></a></h5>

  <p>JavaScript contains an <a id="the-hostensurecanaddprivateelement-implementation:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-hostensurecanaddprivateelement" id="the-hostensurecanaddprivateelement-implementation:js-hostensurecanaddprivateelement" data-x-internal="js-hostensurecanaddprivateelement">HostEnsureCanAddPrivateElement</a>(<var>O</var>)
  abstract operation. User agents must use the following implementation: <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a>

  </p><ol><li><p>If <var>O</var> is a <code id="the-hostensurecanaddprivateelement-implementation:windowproxy"><a href="#windowproxy">WindowProxy</a></code> object, or <a id="the-hostensurecanaddprivateelement-implementation:implements" href="https://webidl.spec.whatwg.org/#implements" data-x-internal="implements">implements</a>
   <code id="the-hostensurecanaddprivateelement-implementation:location"><a href="#location">Location</a></code>, then return <a id="the-hostensurecanaddprivateelement-implementation:throwcompletion" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(a new
   <code id="the-hostensurecanaddprivateelement-implementation:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>).</p></li><li><p>Return <a id="the-hostensurecanaddprivateelement-implementation:normalcompletion" href="https://tc39.es/ecma262/#sec-normalcompletion" data-x-internal="normalcompletion">NormalCompletion</a>(unused).</p></li></ol>
  </div>

  <p class="note">JavaScript private fields can be applied to arbitrary objects. Since this can
  dramatically complicate implementation for particularly-exotic host objects, the JavaScript
  language specification provides this hook to allow hosts to reject private fields on objects
  meeting a host-defined criteria. In the case of HTML, <code id="the-hostensurecanaddprivateelement-implementation:windowproxy-2"><a href="#windowproxy">WindowProxy</a></code> and
  <code id="the-hostensurecanaddprivateelement-implementation:location-2"><a href="#location">Location</a></code> have complicated semantics — particularly around navigation and
  security — that make implementation of private field semantics challenging, so our
  implementation simply rejects those objects.</p>

  <div data-algorithm="">
  <h5 id="hostensurecancompilestrings(realm,-parameterstrings,-bodystring,-codestring,-compilationtype,-parameterargs,-bodyarg)"><span class="secno">8.1.6.2</span> <dfn>HostEnsureCanCompileStrings</dfn>(<var>realm</var>,
  <var>parameterStrings</var>, <var>bodyString</var>, <var>codeString</var>, <var>compilationType</var>,
  <var>parameterArgs</var>, <var>bodyArg</var>)<a href="#hostensurecancompilestrings(realm,-parameterstrings,-bodystring,-codestring,-compilationtype,-parameterargs,-bodyarg)" class="self-link"></a></h5>

  <p>JavaScript contains an <a id="hostensurecancompilestrings(realm,-parameterstrings,-bodystring,-codestring,-compilationtype,-parameterargs,-bodyarg):implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/proposal-dynamic-code-brand-checks/#sec-hostensurecancompilestrings" id="hostensurecancompilestrings(realm,-parameterstrings,-bodystring,-codestring,-compilationtype,-parameterargs,-bodyarg):js-hostensurecancompilestrings" data-x-internal="js-hostensurecancompilestrings">HostEnsureCanCompileStrings</a> abstract operation,
  redefined by the <cite>Dynamic Code Brand Checks</cite> proposal. User agents must use
  the following implementation: <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a> <a href="#refsJSDYNAMICCODEBRANDCHECKS">[JSDYNAMICCODEBRANDCHECKS]</a>

  </p><ol><li><p>Perform ? <a href="https://w3c.github.io/webappsec-csp/#can-compile-strings" id="hostensurecancompilestrings(realm,-parameterstrings,-bodystring,-codestring,-compilationtype,-parameterargs,-bodyarg):csp-ensurecspdoesnotblockstringcompilation" data-x-internal="csp-ensurecspdoesnotblockstringcompilation">EnsureCSPDoesNotBlockStringCompilation</a>(<var>realm</var>,
   <var>parameterStrings</var>, <var>bodyString</var>, <var>codeString</var>,
   <var>compilationType</var>, <var>parameterArgs</var>, <var>bodyArg</var>).
   <a href="#refsCSP">[CSP]</a></p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="hostgetcodeforeval(argument)"><span class="secno">8.1.6.3</span> <dfn>HostGetCodeForEval</dfn>(<var>argument</var>)<a href="#hostgetcodeforeval(argument)" class="self-link"></a></h5>

  <p>The <cite>Dynamic Code Brand Checks</cite> proposal contains an
  <a id="hostgetcodeforeval(argument):implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/proposal-dynamic-code-brand-checks/#sec-hostgetcodeforeval" id="hostgetcodeforeval(argument):js-hostgetcodeforeval" data-x-internal="js-hostgetcodeforeval">HostGetCodeForEval</a>(<var>argument</var>) abstract operation.
  User agents must use the following implementation: <a href="#refsJSDYNAMICCODEBRANDCHECKS">[JSDYNAMICCODEBRANDCHECKS]</a>

  </p><ol><li><p>If <var>argument</var> is a <code id="hostgetcodeforeval(argument):tt-trustedscript"><a data-x-internal="tt-trustedscript" href="https://w3c.github.io/trusted-types/dist/spec/#trusted-script">TrustedScript</a></code> object,
   then return <var>argument</var>'s <a href="https://w3c.github.io/trusted-types/dist/spec/#trustedscript-data" id="hostgetcodeforeval(argument):tt-trustedscript-data" data-x-internal="tt-trustedscript-data">data</a>.</p></li><li><p>Otherwise, return no-code.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="the-hostpromiserejectiontracker-implementation"><span class="secno">8.1.6.4</span> <dfn>HostPromiseRejectionTracker</dfn>(<var>promise</var>, <var>operation</var>)<a href="#the-hostpromiserejectiontracker-implementation" class="self-link"></a></h5>

  <p>JavaScript contains an <a id="the-hostpromiserejectiontracker-implementation:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-host-promise-rejection-tracker" id="the-hostpromiserejectiontracker-implementation:js-hostpromiserejectiontracker" data-x-internal="js-hostpromiserejectiontracker">HostPromiseRejectionTracker</a>(<var>promise</var>,
  <var>operation</var>) abstract operation. User agents must use the following implementation:
  <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li><p>Let <var>script</var> be the <a href="#running-script" id="the-hostpromiserejectiontracker-implementation:running-script">running script</a>.</p></li><li><p>If <var>script</var> is a <a href="#classic-script" id="the-hostpromiserejectiontracker-implementation:classic-script">classic script</a> and <var>script</var>'s <a href="#muted-errors" id="the-hostpromiserejectiontracker-implementation:muted-errors">muted
   errors</a> is true, then return.</p></li><li><p>Let <var>settingsObject</var> be the <a href="#current-settings-object" id="the-hostpromiserejectiontracker-implementation:current-settings-object">current settings object</a>.</p></li><li><p>If <var>script</var> is not null, then set <var>settingsObject</var> to
   <var>script</var>'s <a href="#settings-object" id="the-hostpromiserejectiontracker-implementation:settings-object">settings
   object</a>.</p></li><li><p>Let <var>global</var> be <var>settingsObject</var>'s <a href="#concept-settings-object-global" id="the-hostpromiserejectiontracker-implementation:concept-settings-object-global">global object</a>.</p></li><li>
    <p>If <var>operation</var> is "<code>reject</code>", then:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="the-hostpromiserejectiontracker-implementation:list-append" data-x-internal="list-append">Append</a> <var>promise</var> to <var>global</var>'s
     <a href="#about-to-be-notified-rejected-promises-list" id="the-hostpromiserejectiontracker-implementation:about-to-be-notified-rejected-promises-list">about-to-be-notified rejected promises list</a>.</p></li></ol>
   </li><li>
    <p>If <var>operation</var> is "<code>handle</code>", then:</p>

    <ol><li><p>If <var>global</var>'s <a href="#about-to-be-notified-rejected-promises-list" id="the-hostpromiserejectiontracker-implementation:about-to-be-notified-rejected-promises-list-2">about-to-be-notified rejected promises list</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="the-hostpromiserejectiontracker-implementation:list-contains" data-x-internal="list-contains">contains</a> <var>promise</var>, then <a href="https://infra.spec.whatwg.org/#list-remove" id="the-hostpromiserejectiontracker-implementation:list-remove" data-x-internal="list-remove">remove</a> <var>promise</var> from that list and return.</p></li><li><p>If <var>global</var>'s <a href="#outstanding-rejected-promises-weak-set" id="the-hostpromiserejectiontracker-implementation:outstanding-rejected-promises-weak-set">outstanding rejected promises weak set</a> does not
     <a href="https://infra.spec.whatwg.org/#list-contain" id="the-hostpromiserejectiontracker-implementation:list-contains-2" data-x-internal="list-contains">contain</a> <var>promise</var>, then return.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="the-hostpromiserejectiontracker-implementation:list-remove-2" data-x-internal="list-remove">Remove</a> <var>promise</var> from <var>global</var>'s
     <a href="#outstanding-rejected-promises-weak-set" id="the-hostpromiserejectiontracker-implementation:outstanding-rejected-promises-weak-set-2">outstanding rejected promises weak set</a>.</p></li><li><p><a href="#queue-a-global-task" id="the-hostpromiserejectiontracker-implementation:queue-a-global-task">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="the-hostpromiserejectiontracker-implementation:dom-manipulation-task-source">DOM manipulation task source</a> given
     <var>global</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-hostpromiserejectiontracker-implementation:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-hostpromiserejectiontracker-implementation:event-rejectionhandled"><a href="#event-rejectionhandled">rejectionhandled</a></code> at <var>global</var>, using
     <code id="the-hostpromiserejectiontracker-implementation:promiserejectionevent"><a href="#promiserejectionevent">PromiseRejectionEvent</a></code>, with the <code id="the-hostpromiserejectiontracker-implementation:dom-promiserejectionevent-promise"><a href="#dom-promiserejectionevent-promise">promise</a></code> attribute initialized to
     <var>promise</var>, and the <code id="the-hostpromiserejectiontracker-implementation:dom-promiserejectionevent-reason"><a href="#dom-promiserejectionevent-reason">reason</a></code>
     attribute initialized to <var>promise</var>.[[PromiseResult]].</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <h5 id="hostsystemutcepochnanoseconds"><span class="secno">8.1.6.5</span> <dfn>HostSystemUTCEpochNanoseconds</dfn>(<var>global</var>)<a href="#hostsystemutcepochnanoseconds" class="self-link"></a></h5>

  <p>The Temporal proposal contains an <a id="hostsystemutcepochnanoseconds:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/proposal-temporal/#sec-hostsystemutcepochnanoseconds" id="hostsystemutcepochnanoseconds:js-hostsystemutcepochnanoseconds" data-x-internal="js-hostsystemutcepochnanoseconds">HostSystemUTCEpochNanoseconds</a> abstract operation.
  User agents must use the following implementation: <a href="#refsJSTEMPORAL">[JSTEMPORAL]</a></p>

  <ol><li><p>Let <var>settingsObject</var> be <var>global</var>'s <a href="#relevant-settings-object" id="hostsystemutcepochnanoseconds:relevant-settings-object">relevant settings
   object</a>.</p></li><li><p>Let <var>time</var> be <var>settingsObject</var>'s <a id="hostsystemutcepochnanoseconds:current-wall-time" href="https://w3c.github.io/hr-time/#dfn-current-wall-time" data-x-internal="current-wall-time">current wall
   time</a>.</p></li><li><p>Let <var>ns</var> be the number of nanoseconds from the <a id="hostsystemutcepochnanoseconds:unix-epoch" href="https://w3c.github.io/hr-time/#dfn-unix-epoch" data-x-internal="unix-epoch">Unix epoch</a> to
   <var>time</var>, rounded to the nearest integer.</p></li><li><p>Return the result of <a id="hostsystemutcepochnanoseconds:clamping" href="https://tc39.es/ecma262/#clamping" data-x-internal="clamping">clamping</a> <var>ns</var> between
   <a id="hostsystemutcepochnanoseconds:nsmininstant" href="https://tc39.es/proposal-temporal/#eqn-nsMinInstant" data-x-internal="nsmininstant">nsMinInstant</a> and <a id="hostsystemutcepochnanoseconds:nsmaxinstant" href="https://tc39.es/proposal-temporal/#eqn-nsMaxInstant" data-x-internal="nsmaxinstant">nsMaxInstant</a>.</p></li></ol>
  </div>

  <h5 id="integration-with-javascript-jobs"><span class="secno">8.1.6.6</span> Job-related host hooks<a href="#integration-with-javascript-jobs" class="self-link"></a></h5>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Incumbent_settings_object_tracking" title="The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.">Reference/Global_Objects/Promise#Incumbent_settings_object_tracking</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>50+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><p>The JavaScript specification defines Jobs to be scheduled and run later by the host, as well as
  <a href="https://tc39.es/ecma262/#sec-jobcallback-records" id="integration-with-javascript-jobs:jobcallback-record" data-x-internal="jobcallback-record">JobCallback Records</a> which encapsulate JavaScript
  functions that are called as part of jobs. The JavaScript specification contains a number of
  <a id="integration-with-javascript-jobs:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> abstract operations that lets the host define how jobs are
  scheduled and how JobCallbacks are handled. HTML uses these abstract operations to <span id="incumbent-settings-object-tracking-in-promises">track the <a href="#incumbent-settings-object" id="integration-with-javascript-jobs:incumbent-settings-object">incumbent settings
  object</a> in promises and <code id="integration-with-javascript-jobs:finalizationregistry"><a data-x-internal="finalizationregistry" href="https://tc39.es/ecma262/#sec-finalization-registry-objects">FinalizationRegistry</a></code> callbacks</span> by saving and
  restoring the <a href="#incumbent-settings-object" id="integration-with-javascript-jobs:incumbent-settings-object-2">incumbent settings object</a> and a <a id="integration-with-javascript-jobs:javascript-execution-context" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript execution
  context</a> for the <a href="#active-script" id="integration-with-javascript-jobs:active-script">active script</a> in JobCallbacks. This section defines them for
  user agent hosts.</p>

  <div data-algorithm="">
  <h6 id="hostcalljobcallback"><span class="secno">8.1.6.6.1</span> <dfn>HostCallJobCallback</dfn>(<var>callback</var>, <var>V</var>,
  <var>argumentsList</var>)<a href="#hostcalljobcallback" class="self-link"></a></h6>

  <p>JavaScript contains an <a id="hostcalljobcallback:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-hostcalljobcallback" id="hostcalljobcallback:js-hostcalljobcallback" data-x-internal="js-hostcalljobcallback">HostCallJobCallback</a>(<var>callback</var>, <var>V</var>,
  <var>argumentsList</var>) abstract operation to let hosts restore state when invoking JavaScript
  callbacks from inside tasks. User agents must use the following implementation:
  <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li><p>Let <var>incumbent settings</var> be
   <var>callback</var>.[[HostDefined]].[[IncumbentSettings]].</p></li><li><p>Let <var>script execution context</var> be
   <var>callback</var>.[[HostDefined]].[[ActiveScriptContext]].</p></li><li>
    <p><a href="#prepare-to-run-a-callback" id="hostcalljobcallback:prepare-to-run-a-callback">Prepare to run a callback</a> with <var>incumbent settings</var>.</p>

    <p class="note">This affects the <a href="#concept-incumbent-everything" id="hostcalljobcallback:concept-incumbent-everything">incumbent</a>
    concept while the callback runs.</p>
   </li><li>
    <p>If <var>script execution context</var> is not null, then <a href="https://infra.spec.whatwg.org/#stack-push" id="hostcalljobcallback:stack-push" data-x-internal="stack-push">push</a> <var>script execution context</var> onto the <a id="hostcalljobcallback:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution
    context stack</a>.</p>

    <p class="note">This affects the <a href="#active-script" id="hostcalljobcallback:active-script">active script</a> while the callback runs.</p>
   </li><li><p>Let <var>result</var> be <a id="hostcalljobcallback:call" href="https://tc39.es/ecma262/#sec-call" data-x-internal="call">Call</a>(<var>callback</var>.[[Callback]], <var>V</var>,
   <var>argumentsList</var>).</p></li><li><p>If <var>script execution context</var> is not null, then <a href="https://infra.spec.whatwg.org/#stack-pop" id="hostcalljobcallback:stack-pop" data-x-internal="stack-pop">pop</a> <var>script execution context</var> from the <a id="hostcalljobcallback:javascript-execution-context-stack-2" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context
   stack</a>.</p></li><li><p><a href="#clean-up-after-running-a-callback" id="hostcalljobcallback:clean-up-after-running-a-callback">Clean up after running a callback</a> with <var>incumbent
   settings</var>.</p></li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="hostenqueuefinalizationregistrycleanupjob"><span class="secno">8.1.6.6.2</span> <dfn>HostEnqueueFinalizationRegistryCleanupJob</dfn>(<var>finalizationRegistry</var>)<a href="#hostenqueuefinalizationregistrycleanupjob" class="self-link"></a></h6>

  <p>JavaScript has the ability to register objects with <code id="hostenqueuefinalizationregistrycleanupjob:finalizationregistry"><a data-x-internal="finalizationregistry" href="https://tc39.es/ecma262/#sec-finalization-registry-objects">FinalizationRegistry</a></code> objects,
  in order to schedule a cleanup action if they are found to be garbage collected. The JavaScript
  specification contains an <a id="hostenqueuefinalizationregistrycleanupjob:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-host-cleanup-finalization-registry" id="hostenqueuefinalizationregistrycleanupjob:js-hostenqueuefinalizationregistrycleanupjob" data-x-internal="js-hostenqueuefinalizationregistrycleanupjob">HostEnqueueFinalizationRegistryCleanupJob</a>(<var>finalizationRegistry</var>)
  abstract operation to schedule the cleanup action.</p>

  <p class="note">The timing and occurrence of cleanup work is <a id="hostenqueuefinalizationregistrycleanupjob:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>
  in the JavaScript specification. User agents might differ in when and whether an object is garbage
  collected, affecting both whether the return value of the <code id="hostenqueuefinalizationregistrycleanupjob:weakref.prototype.deref()"><a data-x-internal="weakref.prototype.deref()" href="https://tc39.es/ecma262/#sec-weak-ref.prototype.deref">WeakRef.prototype.deref()</a></code>
  method is undefined, and whether <code id="hostenqueuefinalizationregistrycleanupjob:finalizationregistry-2"><a data-x-internal="finalizationregistry" href="https://tc39.es/ecma262/#sec-finalization-registry-objects">FinalizationRegistry</a></code> cleanup callbacks occur. There
  are well-known cases in popular web browsers where objects are not accessible to JavaScript, but
  they remain retained by the garbage collector indefinitely. HTML clears kept-alive
  <code id="hostenqueuefinalizationregistrycleanupjob:weakref"><a data-x-internal="weakref" href="https://tc39.es/ecma262/#sec-weak-ref-objects">WeakRef</a></code> objects in the <a href="#perform-a-microtask-checkpoint" id="hostenqueuefinalizationregistrycleanupjob:perform-a-microtask-checkpoint">perform a microtask checkpoint</a> algorithm. Authors
  would be best off not depending on the timing details of garbage collection implementations.</p>

  <p>Cleanup actions do not take place interspersed with synchronous JavaScript execution, but
  rather happen in queued <a href="#concept-task" id="hostenqueuefinalizationregistrycleanupjob:concept-task">tasks</a>. User agents must use the
  following implementation: <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li><p>Let <var>global</var> be <var>finalizationRegistry</var>.[[Realm]]'s <a href="#global-object" id="hostenqueuefinalizationregistrycleanupjob:global-object">global
   object</a>.</p></li><li>
    <p><a href="#queue-a-global-task" id="hostenqueuefinalizationregistrycleanupjob:queue-a-global-task">Queue a global task</a> on the <dfn id="javascript-engine-task-source">JavaScript engine task source</dfn> given
    <var>global</var> to perform the following steps:</p>

    <ol><li><p>Let <var>entry</var> be
     <var>finalizationRegistry</var>.[[CleanupCallback]].[[Callback]].[[Realm]]'s <a href="#concept-realm-settings-object" id="hostenqueuefinalizationregistrycleanupjob:concept-realm-settings-object">environment settings object</a>.</p></li><li><p><a href="#check-if-we-can-run-script" id="hostenqueuefinalizationregistrycleanupjob:check-if-we-can-run-script">Check if we can run script</a> with <var>entry</var>. If this returns "do not
     run", then return.</p></li><li>
      <p><a href="#prepare-to-run-script" id="hostenqueuefinalizationregistrycleanupjob:prepare-to-run-script">Prepare to run script</a> with <var>entry</var>.</p>

      <p class="note">This affects the <a href="#concept-entry-everything" id="hostenqueuefinalizationregistrycleanupjob:concept-entry-everything">entry</a> concept
      while the cleanup callback runs.</p>
     </li><li><p>Let <var>result</var> be the result of performing
     <a id="hostenqueuefinalizationregistrycleanupjob:cleanupfinalizationregistry" href="https://tc39.es/ecma262/#sec-cleanup-finalization-registry" data-x-internal="cleanupfinalizationregistry">CleanupFinalizationRegistry</a>(<var>finalizationRegistry</var>).</p></li><li><p><a href="#clean-up-after-running-script" id="hostenqueuefinalizationregistrycleanupjob:clean-up-after-running-script">Clean up after running script</a> with <var>entry</var>.</p></li><li><p>If <var>result</var> is an <a href="https://tc39.es/ecma262/#sec-completion-record-specification-type" id="hostenqueuefinalizationregistrycleanupjob:completion-record" data-x-internal="completion-record">abrupt completion</a>,
     then <a href="#report-an-exception" id="hostenqueuefinalizationregistrycleanupjob:report-an-exception">report an exception</a> given by <var>result</var>.[[Value]] for
     <var>global</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="hostenqueuegenericjob"><span class="secno">8.1.6.6.3</span> <dfn>HostEnqueueGenericJob</dfn>(<var>job</var>,
  <var>realm</var>)<a href="#hostenqueuegenericjob" class="self-link"></a></h6>

  <p>JavaScript contains an <a id="hostenqueuegenericjob:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-hostenqueuegenericjob" id="hostenqueuegenericjob:js-hostenqueuegenericjob" data-x-internal="js-hostenqueuegenericjob">HostEnqueueGenericJob</a>(<var>job</var>, <var>realm</var>)
  abstract operation to perform generic jobs in a particular realm (e.g., resolve promises resulting
  from <code id="hostenqueuegenericjob:atomics.waitasync"><a data-x-internal="atomics.waitasync" href="https://tc39.es/ecma262/#sec-atomics.waitasync">Atomics.waitAsync</a></code>). User agents must use the following implementation:
  <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li><p>Let <var>global</var> be <var>realm</var>'s <a href="#concept-realm-global" id="hostenqueuegenericjob:concept-realm-global">global
   object</a>.</p></li><li><p><a href="#queue-a-global-task" id="hostenqueuegenericjob:queue-a-global-task">Queue a global task</a> on the <a href="#javascript-engine-task-source" id="hostenqueuegenericjob:javascript-engine-task-source">JavaScript engine task source</a> given
   <var>global</var> to perform <var>job</var>().</p></li></ol>
  </div>

  <span id="integration-with-the-javascript-job-queue"></span>
  <span id="enqueuejob(queuename,-job,-arguments)"></span>
  <div data-algorithm="">
  <h6 id="hostenqueuepromisejob"><span class="secno">8.1.6.6.4</span> <dfn>HostEnqueuePromiseJob</dfn>(<var>job</var>,
  <var>realm</var>)<a href="#hostenqueuepromisejob" class="self-link"></a></h6>

  <p>JavaScript contains an <a id="hostenqueuepromisejob:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-hostenqueuepromisejob" id="hostenqueuepromisejob:js-hostenqueuepromisejob" data-x-internal="js-hostenqueuepromisejob">HostEnqueuePromiseJob</a>(<var>job</var>, <var>realm</var>)
  abstract operation to schedule Promise-related operations. HTML schedules these operations in the
  microtask queue. User agents must use the following implementation: <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li>
    <p>If <var>realm</var> is not null, then let <var>job settings</var> be the <a href="#concept-realm-settings-object" id="hostenqueuepromisejob:concept-realm-settings-object">settings object</a> for <var>realm</var>. Otherwise,
    let <var>job settings</var> be null.</p>

     <div class="note">
      <p>If <var>realm</var> is not null, it is the <a id="hostenqueuepromisejob:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a> of the author code that will
      run. When <var>job</var> is returned by <a id="hostenqueuepromisejob:newpromisereactionjob" href="https://tc39.es/ecma262/#sec-newpromisereactionjob" data-x-internal="newpromisereactionjob">NewPromiseReactionJob</a>, it is the realm of
      the promise's handler function. When <var>job</var> is returned by
      <a id="hostenqueuepromisejob:newpromiseresolvethenablejob" href="https://tc39.es/ecma262/#sec-newpromiseresolvethenablejob" data-x-internal="newpromiseresolvethenablejob">NewPromiseResolveThenableJob</a>, it is the realm of the <code>then</code>
      function.

      </p><p>If <var>realm</var> is null, either no author code will run or author code is guaranteed to
      throw. For the former, the author may not have passed in code to run, such as in <code>promise.then(null, null)</code>. For the latter, it is because a revoked Proxy was
      passed. In both cases, all the steps below that would otherwise use <var>job settings</var>
      get skipped.</p>

      <p class="XXX"><a href="https://tc39.es/ecma262/#sec-newpromiseresolvethenablejob">NewPromiseResolveThenableJob</a>
      and <a href="https://tc39.es/ecma262/#sec-newpromisereactionjob">NewPromiseReactionJob</a>
      both seem to provide non-null realms (the current Realm Record) in the case of a revoked
      proxy. The previous text could be updated to reflect that.</p>
     </div>
   </li><li>
    <p><a href="#queue-a-microtask" id="hostenqueuepromisejob:queue-a-microtask">Queue a microtask</a> to perform the following steps:</p>

    <ol><li><p>If <var>job settings</var> is not null, then <a href="#check-if-we-can-run-script" id="hostenqueuepromisejob:check-if-we-can-run-script">check if we can run script</a>
     with <var>job settings</var>. If this returns "do not run" then return.</p></li><li>
      <p>If <var>job settings</var> is not null, then <a href="#prepare-to-run-script" id="hostenqueuepromisejob:prepare-to-run-script">prepare to run script</a> with
      <var>job settings</var>.</p>

      <p class="note">This affects the <a href="#concept-entry-everything" id="hostenqueuepromisejob:concept-entry-everything">entry</a> concept
      while the job runs.</p>
     </li><li>
      <p>Let <var>result</var> be <var>job</var>().</p>

      <p class="note"><var>job</var> is an <a id="hostenqueuepromisejob:abstract-closure" href="https://tc39.es/ecma262/#sec-abstract-closure" data-x-internal="abstract-closure">abstract closure</a> returned by
      <a id="hostenqueuepromisejob:newpromisereactionjob-2" href="https://tc39.es/ecma262/#sec-newpromisereactionjob" data-x-internal="newpromisereactionjob">NewPromiseReactionJob</a> or <a id="hostenqueuepromisejob:newpromiseresolvethenablejob-2" href="https://tc39.es/ecma262/#sec-newpromiseresolvethenablejob" data-x-internal="newpromiseresolvethenablejob">NewPromiseResolveThenableJob</a>. The promise's
      handler function when <var>job</var> is returned by <a id="hostenqueuepromisejob:newpromisereactionjob-3" href="https://tc39.es/ecma262/#sec-newpromisereactionjob" data-x-internal="newpromisereactionjob">NewPromiseReactionJob</a>, and
      the <code>then</code> function when <var>job</var> is returned by
      <a id="hostenqueuepromisejob:newpromiseresolvethenablejob-3" href="https://tc39.es/ecma262/#sec-newpromiseresolvethenablejob" data-x-internal="newpromiseresolvethenablejob">NewPromiseResolveThenableJob</a>, are wrapped in <a href="https://tc39.es/ecma262/#sec-jobcallback-records" id="hostenqueuepromisejob:jobcallback-record" data-x-internal="jobcallback-record">JobCallback Records</a>. HTML saves the <a href="#incumbent-settings-object" id="hostenqueuepromisejob:incumbent-settings-object">incumbent settings object</a> and
      a <a id="hostenqueuepromisejob:javascript-execution-context" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript execution context</a> for to the <a href="#active-script" id="hostenqueuepromisejob:active-script">active script</a> in
      <a href="#hostmakejobcallback" id="hostenqueuepromisejob:hostmakejobcallback">HostMakeJobCallback</a> and restores them in <a href="#hostcalljobcallback" id="hostenqueuepromisejob:hostcalljobcallback">HostCallJobCallback</a>.</p>
     </li><li><p>If <var>job settings</var> is not null, then <a href="#clean-up-after-running-script" id="hostenqueuepromisejob:clean-up-after-running-script">clean up after running script</a>
     with <var>job settings</var>.</p></li><li>
      <p>If <var>result</var> is an <a href="https://tc39.es/ecma262/#sec-completion-record-specification-type" id="hostenqueuepromisejob:completion-record" data-x-internal="completion-record">abrupt completion</a>, then
      <a href="#report-an-exception" id="hostenqueuepromisejob:report-an-exception">report an exception</a> given by <var>result</var>.[[Value]] for <var>realm</var>'s
      <a href="#concept-realm-global" id="hostenqueuepromisejob:concept-realm-global">global object</a>.</p>

      <p class="XXX">There is a very gnarly case where HostEnqueuePromiseJob is called with a null
      realm (e.g., because Promise.prototype.then was called with null handlers) but also the job
      returns abruptly (because the promise capability's resolve or reject handler threw, possibly
      because this is a subclass of Promise that takes the supplied functions and wraps them in
      throwing functions before passing them on to the function passed to the Promise superclass
      constructor. Which global is to be used then, considering that the current realm could be
      different at each of those steps, by using a Promise constructor or Promise.prototype.then
      from another realm? See <a href="https://github.com/whatwg/html/issues/10526">issue
      #10526</a>.</p>
     </li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="hostenqueuetimeoutjob"><span class="secno">8.1.6.6.5</span> <dfn>HostEnqueueTimeoutJob</dfn>(<var>job</var>, <var>realm</var>,
  <var>milliseconds</var>)<a href="#hostenqueuetimeoutjob" class="self-link"></a></h6>

  <p>JavaScript contains an <a id="hostenqueuetimeoutjob:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-hostenqueuetimeoutjob" id="hostenqueuetimeoutjob:js-hostenqueuetimeoutjob" data-x-internal="js-hostenqueuetimeoutjob">HostEnqueueTimeoutJob</a>(<var>job</var>,
  <var>milliseconds</var>) abstract operation to schedule an operation to be performed after a
  timeout. HTML schedules these operations using <a href="#run-steps-after-a-timeout" id="hostenqueuetimeoutjob:run-steps-after-a-timeout">run steps after a timeout</a>. User agents
  must use the following implementation: <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li><p>Let <var>global</var> be <var>realm</var>'s <a href="#concept-realm-global" id="hostenqueuetimeoutjob:concept-realm-global">global
   object</a>.</p></li><li><p>Let <var>timeoutStep</var> be an algorithm step which <a href="#queue-a-global-task" id="hostenqueuetimeoutjob:queue-a-global-task">queues a global task</a> on the <a href="#javascript-engine-task-source" id="hostenqueuetimeoutjob:javascript-engine-task-source">JavaScript engine task source</a> given
   <var>global</var> to perform <var>job</var>().</p></li><li><p><a href="#run-steps-after-a-timeout" id="hostenqueuetimeoutjob:run-steps-after-a-timeout-2">Run steps after a timeout</a> given <var>global</var>, "<code>JavaScript</code>", <var>milliseconds</var>, and <var>timeoutStep</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="hostmakejobcallback"><span class="secno">8.1.6.6.6</span> <dfn>HostMakeJobCallback</dfn>(<var>callable</var>)<a href="#hostmakejobcallback" class="self-link"></a></h6>

  <p>JavaScript contains an <a id="hostmakejobcallback:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-hostmakejobcallback" id="hostmakejobcallback:js-hostmakejobcallback" data-x-internal="js-hostmakejobcallback">HostMakeJobCallback</a>(<var>callable</var>) abstract operation
  to let hosts attach state to JavaScript callbacks that are called from inside <a href="#concept-task" id="hostmakejobcallback:concept-task">task</a>s. User agents must use the following implementation:
  <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li><p>Let <var>incumbent settings</var> be the <a href="#incumbent-settings-object" id="hostmakejobcallback:incumbent-settings-object">incumbent settings object</a>.</p></li><li><p>Let <var>active script</var> be the <a href="#active-script" id="hostmakejobcallback:active-script">active script</a>.</p></li><li><p>Let <var>script execution context</var> be null.</p></li><li>
    <p>If <var>active script</var> is not null, set <var>script execution context</var> to a new
    <a id="hostmakejobcallback:javascript-execution-context" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript execution context</a>, with its Function field set to null, its Realm field
    set to <var>active script</var>'s <a href="#settings-object" id="hostmakejobcallback:settings-object">settings
    object</a>'s <a href="#environment-settings-object's-realm" id="hostmakejobcallback:environment-settings-object's-realm">realm</a>, and its
    ScriptOrModule set to <var>active script</var>'s
    <a href="#concept-script-record" id="hostmakejobcallback:concept-script-record">record</a>.</p>

    <p class="note">As seen below, this is used in order to propagate the current <a href="#active-script" id="hostmakejobcallback:active-script-2">active
    script</a> forward to the time when the job callback is invoked.</p>

    <div class="example">
     <p>A case where <var>active script</var> is non-null, and saving it in this way is useful, is
     the following:</p>

     <pre><code class="js">Promise<c- p="">.</c->resolve<c- p="">(</c-><c- t="">'import(`./example.mjs`)'</c-><c- p="">).</c->then<c- p="">(</c->eval<c- p="">);</c-></code></pre>

     <p>Without this step (and the steps that use it in <a href="#hostcalljobcallback" id="hostmakejobcallback:hostcalljobcallback">HostCallJobCallback</a>), there
     would be no <a href="#active-script" id="hostmakejobcallback:active-script-3">active script</a> when the <code id="hostmakejobcallback:import()"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> expression is evaluated,
     since <code id="hostmakejobcallback:eval()"><a data-x-internal="eval()" href="https://tc39.es/ecma262/#sec-eval-x">eval()</a></code> is a built-in function that does not originate from any particular
     <a href="#concept-script" id="hostmakejobcallback:concept-script">script</a>.</p>

     <p>With this step in place, the active script is propagated from the above code into the job,
     allowing <code id="hostmakejobcallback:import()-2"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> to use the original script's <a href="#concept-script-base-url" id="hostmakejobcallback:concept-script-base-url">base URL</a> appropriately.</p>
    </div>

    <div class="example">
     <p><var>active script</var> can be null if the user clicks on the following button:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"Promise.resolve('import(`./example.mjs`)').then(eval)"</c-><c- p="">&gt;</c->Click me<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-></code></pre>

     <p>In this case, the JavaScript function for the <a href="#event-handlers" id="hostmakejobcallback:event-handlers">event
     handler</a> will be created by the <a href="#getting-the-current-value-of-the-event-handler" id="hostmakejobcallback:getting-the-current-value-of-the-event-handler">get the current value of the event handler</a> algorithm, which creates a function
     with null [[ScriptOrModule]] value. Thus, when the promise machinery calls
     <a href="#hostmakejobcallback" id="hostmakejobcallback:hostmakejobcallback">HostMakeJobCallback</a>, there will be no <a href="#active-script" id="hostmakejobcallback:active-script-4">active script</a> to pass
     along.</p>

     <p>As a consequence, this means that when the <code id="hostmakejobcallback:import()-3"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> expression is evaluated,
     there will still be no <a href="#active-script" id="hostmakejobcallback:active-script-5">active script</a>. Fortunately that is handled by our
     implementation of <a href="#hostloadimportedmodule" id="hostmakejobcallback:hostloadimportedmodule">HostLoadImportedModule</a> by falling back to using the
     <a href="#current-settings-object" id="hostmakejobcallback:current-settings-object">current settings object</a>'s <a href="#api-base-url" id="hostmakejobcallback:api-base-url">API base URL</a>.</p>
    </div>
   </li><li><p>Return the <a id="hostmakejobcallback:jobcallback-record" href="https://tc39.es/ecma262/#sec-jobcallback-records" data-x-internal="jobcallback-record">JobCallback Record</a> { [[Callback]]: <var>callable</var>,
   [[HostDefined]]: { [[IncumbentSettings]]: <var>incumbent settings</var>, [[ActiveScriptContext]]:
   <var>script execution context</var> } }.</p></li></ol>
  </div>

  


  <h5 id="integration-with-the-javascript-module-system"><span class="secno">8.1.6.7</span> Module-related host hooks<a href="#integration-with-the-javascript-module-system" class="self-link"></a></h5>

  <p>The JavaScript specification defines a syntax for modules, as well as some host-agnostic parts
  of their processing model. This specification defines the rest of their processing model: how the
  module system is bootstrapped, via the <code id="integration-with-the-javascript-module-system:the-script-element"><a href="#the-script-element">script</a></code> element with <code id="integration-with-the-javascript-module-system:attr-script-type"><a href="#attr-script-type">type</a></code> attribute set to "<code>module</code>", and how
  modules are fetched, resolved, and executed. <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <p class="note">Although the JavaScript specification speaks in terms of "scripts" versus
  "modules", in general this specification speaks in terms of <a href="#classic-script" id="integration-with-the-javascript-module-system:classic-script">classic
  scripts</a> versus <a href="#module-script" id="integration-with-the-javascript-module-system:module-script">module scripts</a>, since both of them use
  the <code id="integration-with-the-javascript-module-system:the-script-element-2"><a href="#the-script-element">script</a></code> element.</p>

  <dl class="domintro"><dt><code><var>modulePromise</var> = <a href="https://tc39.es/ecma262/#sec-import-calls" id="integration-with-the-javascript-module-system:import()" data-x-internal="import()">import(<var>specifier</var>)</a></code></dt><dd>
    <p>Returns a promise for the module namespace object for the <a href="#module-script" id="integration-with-the-javascript-module-system:module-script-2">module script</a>
    identified by <var>specifier</var>. This allows dynamic importing of module scripts at runtime,
    instead of statically using the <code>import</code> statement form. The specifier will
    be <a href="#resolve-a-module-specifier" id="integration-with-the-javascript-module-system:resolve-a-module-specifier">resolved</a> relative to the <a href="#active-script" id="integration-with-the-javascript-module-system:active-script">active
    script</a>.</p>

    <p>The returned promise will be rejected if an invalid specifier is given, or if a failure is
    encountered while <a href="#hostloadimportedmodule" id="integration-with-the-javascript-module-system:hostloadimportedmodule">fetching</a> or evaluating the
    resulting module graph.</p>

    <p>This syntax can be used inside both <a href="#classic-script" id="integration-with-the-javascript-module-system:classic-script-2">classic</a> and <a href="#module-script" id="integration-with-the-javascript-module-system:module-script-3">module scripts</a>. It thus provides a bridge into the module-script
    world, from the classic-script world.</p>
   </dd><dt><code><var>url</var> = <a href="https://tc39.es/ecma262/#sec-meta-properties" id="integration-with-the-javascript-module-system:import.meta" data-x-internal="import.meta">import.meta</a>.<a href="#import-meta-url" id="integration-with-the-javascript-module-system:import-meta-url">url</a></code></dt><dd>
    <p>Returns the <a href="#active-script" id="integration-with-the-javascript-module-system:active-script-2">active module script</a>'s <a href="#concept-script-base-url" id="integration-with-the-javascript-module-system:concept-script-base-url">base URL</a>.</p>

    <p>This syntax can only be used inside <a href="#module-script" id="integration-with-the-javascript-module-system:module-script-4">module scripts</a>.</p>
   </dd><dt><code><var>url</var> = <a href="https://tc39.es/ecma262/#sec-meta-properties" id="integration-with-the-javascript-module-system:import.meta-2" data-x-internal="import.meta">import.meta</a>.<a href="#import-meta-resolve" id="integration-with-the-javascript-module-system:import-meta-resolve">resolve</a>(<var>specifier</var>)</code></dt><dd>
    <p>Returns <var>specifier</var>, <a href="#resolve-a-module-specifier" id="integration-with-the-javascript-module-system:resolve-a-module-specifier-2">resolved</a>
    relative to the <a href="#active-script" id="integration-with-the-javascript-module-system:active-script-3">active script</a>. That is, this returns the URL that would be imported
    by using <code id="integration-with-the-javascript-module-system:import()-2"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import(<var>specifier</var>)</a></code>.</p>

    <p>Throws a <code id="integration-with-the-javascript-module-system:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> exception if an invalid specifier is given.</p>

    <p>This syntax can only be used inside <a href="#module-script" id="integration-with-the-javascript-module-system:module-script-5">module scripts</a>.</p>
   </dd></dl>

  <p>A <dfn id="module-map">module map</dfn> is a <a href="https://infra.spec.whatwg.org/#ordered-map" id="integration-with-the-javascript-module-system:ordered-map" data-x-internal="ordered-map">map</a> keyed by <a href="https://infra.spec.whatwg.org/#tuple" id="integration-with-the-javascript-module-system:tuple" data-x-internal="tuple">tuples</a> consisting of a <a id="integration-with-the-javascript-module-system:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> and a <a id="integration-with-the-javascript-module-system:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a>.
  The <a id="integration-with-the-javascript-module-system:url-record-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a> is the <a href="https://fetch.spec.whatwg.org/#concept-request-url" id="integration-with-the-javascript-module-system:concept-request-url" data-x-internal="concept-request-url">request URL</a> at which
  the module was fetched, and the <a id="integration-with-the-javascript-module-system:string-2" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> indicates the type of the module (e.g. "<code>javascript-or-wasm</code>"). The <a href="#module-map" id="integration-with-the-javascript-module-system:module-map">module map</a>'s values are either a
  <a href="#module-script" id="integration-with-the-javascript-module-system:module-script-6">module script</a>, null (used to represent failed fetches), or a placeholder value "<code>fetching</code>". <a href="#module-map" id="integration-with-the-javascript-module-system:module-map-2">Module maps</a> are used to ensure
  that imported module scripts are only fetched, parsed, and evaluated once per
  <code id="integration-with-the-javascript-module-system:document"><a href="#document">Document</a></code> or <a href="#workers">worker</a>.</p>

  <div class="example">
   <p>Since <a href="#module-map" id="integration-with-the-javascript-module-system:module-map-3">module maps</a> are keyed by (URL, module type), the
   following code will create three separate entries in the <a href="#module-map" id="integration-with-the-javascript-module-system:module-map-4">module map</a>, since it
   results in three different (URL, module type) <a href="https://infra.spec.whatwg.org/#tuple" id="integration-with-the-javascript-module-system:tuple-2" data-x-internal="tuple">tuples</a> (all with "<code>javascript-or-wasm</code>" type):</p>

   <pre><code class="js"><c- k="">import</c-> <c- u="">"https://example.com/module.mjs"</c-><c- p="">;</c->
<c- k="">import</c-> <c- u="">"https://example.com/module.mjs#map-buster"</c-><c- p="">;</c->
<c- k="">import</c-> <c- u="">"https://example.com/module.mjs?debug=true"</c-><c- p="">;</c-></code></pre>

   <p>That is, URL <a href="https://url.spec.whatwg.org/#concept-url-query" id="integration-with-the-javascript-module-system:concept-url-query" data-x-internal="concept-url-query">queries</a> and <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="integration-with-the-javascript-module-system:concept-url-fragment" data-x-internal="concept-url-fragment">fragments</a> can be varied to create distinct entries in the
   <a href="#module-map" id="integration-with-the-javascript-module-system:module-map-5">module map</a>; they are not ignored. Thus, three separate fetches and three separate
   module evaluations will be performed.</p>

   <p>In contrast, the following code would only create a single entry in the <a href="#module-map" id="integration-with-the-javascript-module-system:module-map-6">module
   map</a>, since after applying the <a id="integration-with-the-javascript-module-system:url-parser" href="https://url.spec.whatwg.org/#concept-url-parser" data-x-internal="url-parser">URL parser</a> to these inputs, the resulting <a href="https://url.spec.whatwg.org/#concept-url" id="integration-with-the-javascript-module-system:url-record-3" data-x-internal="url-record">URL records</a> are equal:</p>

   <pre><code class="js"><c- k="">import</c-> <c- u="">"https://example.com/module2.mjs"</c-><c- p="">;</c->
<c- k="">import</c-> <c- u="">"https:example.com/module2.mjs"</c-><c- p="">;</c->
<c- k="">import</c-> <c- u="">"https://///example.com\\module2.mjs"</c-><c- p="">;</c->
<c- k="">import</c-> <c- u="">"https://example.com/foo/../module2.mjs"</c-><c- p="">;</c-></code></pre>

   <p>So in this second example, only one fetch and one module evaluation will occur.</p>

   <p>Note that this behavior is the same as how <a href="#sharedworker" id="integration-with-the-javascript-module-system:sharedworker">shared workers</a> are keyed by their parsed <a href="#concept-sharedworkerglobalscope-constructor-url" id="integration-with-the-javascript-module-system:concept-sharedworkerglobalscope-constructor-url">constructor URL</a>.</p>
  </div>

  <div class="example">
   <p>Since module type is also part of the <a href="#module-map" id="integration-with-the-javascript-module-system:module-map-7">module map</a> key, the following code will
   create two separate entries in the <a href="#module-map" id="integration-with-the-javascript-module-system:module-map-8">module map</a> (the type is "<code>javascript-or-wasm</code>" for the first, and "<code>css</code>" for the
   second):</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">module</c-><c- p="">&gt;</c->
  <c- k="">import</c-> <c- u="">"https://example.com/module"</c-><c- p="">;</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">module</c-><c- p="">&gt;</c->
  <c- k="">import</c-> <c- u="">"https://example.com/module"</c-> <c- a="">with</c-> <c- p="">{</c-> type<c- o="">:</c-> <c- u="">"css"</c-> <c- p="">};</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>This can result in two separate fetches and two separate module evaluations being performed.</p>

   <p class="XXX">In practice, due to the as-yet-unspecified memory cache (see issue <a href="https://github.com/whatwg/html/issues/6110">#6110</a>) the resource may only be fetched
   once in WebKit and Blink-based browsers. Additionally, as long as all module types are mutually
   exclusive, the module type check in <a href="#fetch-a-single-module-script" id="integration-with-the-javascript-module-system:fetch-a-single-module-script">fetch a single module script</a> will fail for at
   least one of the imports, so at most one module evaluation will occur.</p>

   <p>The purpose of including the type in the <a href="#module-map" id="integration-with-the-javascript-module-system:module-map-9">module map</a> key is so that an import
   with the wrong type attribute does not prevent a different import of the same specifier but with
   the correct type from succeeding.</p>
  </div>

  <div class="example">
   <p>JavaScript module scripts are the default import type when importing from another JavaScript
    module; that is, when an <code>import</code> statement lacks a <code>type</code> import attribute the imported module script's type will be JavaScript.
    Attempting to import a JavaScript resource using an <code>import</code> statement with
    a <code>type</code> import attribute will fail:</p>

    <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"module"</c-><c- p="">&gt;</c->
    <c- c1="">// All of the following will fail, assuming that the imported .mjs files are served with a</c->
    <c- c1="">// JavaScript MIME type. JavaScript module scripts are the default and cannot be imported with</c->
    <c- c1="">// any import type attribute.</c->
    <c- k="">import</c-> foo <c- k="">from</c-> <c- u="">"./foo.mjs"</c-> <c- a="">with</c-> <c- p="">{</c-> type<c- o="">:</c-> <c- u="">"javascript"</c-> <c- p="">};</c->
    <c- k="">import</c-> foo2 <c- k="">from</c-> <c- u="">"./foo2.mjs"</c-> <c- a="">with</c-> <c- p="">{</c-> type<c- o="">:</c-> <c- u="">"js"</c-> <c- p="">};</c->
    <c- k="">import</c-> foo3 <c- k="">from</c-> <c- u="">"./foo3.mjs"</c-> <c- a="">with</c-> <c- p="">{</c-> type<c- o="">:</c-> <c- u="">""</c-> <c- p="">};</c->
    <c- k="">await</c-> <c- k="">import</c-><c- p="">(</c-><c- u="">"./foo4.mjs"</c-><c- p="">,</c-> <c- p="">{</c-> <c- a="">with</c-><c- o="">:</c-> <c- p="">{</c-> type<c- o="">:</c-> <c- kc="">null</c-> <c- p="">}</c-> <c- p="">});</c->
    <c- k="">await</c-> <c- k="">import</c-><c- p="">(</c-><c- u="">"./foo5.mjs"</c-><c- p="">,</c-> <c- p="">{</c-> <c- a="">with</c-><c- o="">:</c-> <c- p="">{</c-> type<c- o="">:</c-> <c- kc="">undefined</c-> <c- p="">}</c-> <c- p="">});</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>

  


  <div data-algorithm="">
  <h6 id="hostgetimportmetaproperties"><span class="secno">8.1.6.7.1</span> <dfn>HostGetImportMetaProperties</dfn>(<var>moduleRecord</var>)<a href="#hostgetimportmetaproperties" class="self-link"></a></h6><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve" title="import.meta.resolve() is a built-in function defined on the import.meta object of a JavaScript module that resolves a module specifier to a URL using the current module's URL as base.">Reference/Operators/import.meta/resolve</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>106+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>105+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>105+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta" title="The import.meta meta-property exposes context-specific metadata to a JavaScript module. It contains information about the module, such as the module's URL.">Reference/Operators/import.meta</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>62+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>12+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>JavaScript contains an <a id="hostgetimportmetaproperties:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-hostgetimportmetaproperties" id="hostgetimportmetaproperties:js-hostgetimportmetaproperties" data-x-internal="js-hostgetimportmetaproperties">HostGetImportMetaProperties</a> abstract operation.
  User agents must use the following implementation: <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li><p>Let <var>moduleScript</var> be <var>moduleRecord</var>.[[HostDefined]].</p></li><li><p><a id="hostgetimportmetaproperties:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>moduleScript</var>'s <a href="#concept-script-base-url" id="hostgetimportmetaproperties:concept-script-base-url">base
   URL</a> is not null, as <var>moduleScript</var> is a <a href="#javascript-module-script" id="hostgetimportmetaproperties:javascript-module-script">JavaScript module
   script</a>.</p></li><li><p>Let <var>urlString</var> be <var>moduleScript</var>'s <a href="#concept-script-base-url" id="hostgetimportmetaproperties:concept-script-base-url-2">base URL</a>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="hostgetimportmetaproperties:concept-url-serializer" data-x-internal="concept-url-serializer">serialized</a>.</p></li><li>
    <p>Let <var>steps</var> be the following steps, given the argument <var>specifier</var>:</p>

    <ol><li><p>Set <var>specifier</var> to ? <a id="hostgetimportmetaproperties:tostring" href="https://tc39.es/ecma262/#sec-tostring" data-x-internal="tostring">ToString</a>(<var>specifier</var>).</p></li><li><p>Let <var>url</var> be the result of <a href="#resolve-a-module-specifier" id="hostgetimportmetaproperties:resolve-a-module-specifier">resolving
     a module specifier</a> given <var>moduleScript</var> and <var>specifier</var>.</p></li><li><p>Return the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="hostgetimportmetaproperties:concept-url-serializer-2" data-x-internal="concept-url-serializer">serialization</a> of
     <var>url</var>.</p></li></ol>
   </li><li><p>Let <var>resolveFunction</var> be ! <a id="hostgetimportmetaproperties:createbuiltinfunction" href="https://tc39.es/ecma262/#sec-createbuiltinfunction" data-x-internal="createbuiltinfunction">CreateBuiltinFunction</a>(<var>steps</var>,
   1, "<code>resolve</code>", « »).</p></li><li><p>Return « <a id="hostgetimportmetaproperties:record" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> { [[Key]]: "<dfn id="import-meta-url"><code>url</code></dfn>", [[Value]]: <var>urlString</var> },
   <a id="hostgetimportmetaproperties:record-2" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> { [[Key]]: "<dfn id="import-meta-resolve"><code>resolve</code></dfn>",
   [[Value]]: <var>resolveFunction</var> } ».</p></li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="hostgetsupportedimportattributes"><span class="secno">8.1.6.7.2</span> <span id="hostgetsupportedimportassertions"></span><dfn>HostGetSupportedImportAttributes</dfn>()<a href="#hostgetsupportedimportattributes" class="self-link"></a></h6>

  <p>JavaScript contains an <a id="hostgetsupportedimportattributes:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-hostgetsupportedimportattributes" id="hostgetsupportedimportattributes:js-hostgetsupportedimportattributes" data-x-internal="js-hostgetsupportedimportattributes">HostGetSupportedImportAttributes</a> abstract
  operation. User agents must use the following implementation: <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li><p>Return « "<code>type</code>" ».</p></li></ol>
  </div>

  <div data-algorithm="">
  <h6 id="hostloadimportedmodule"><span class="secno">8.1.6.7.3</span> <dfn>HostLoadImportedModule</dfn>(<var>referrer</var>,
  <var>moduleRequest</var>, <var>loadState</var>, <var>payload</var>)<a href="#hostloadimportedmodule" class="self-link"></a></h6>

  <p>JavaScript contains an <a id="hostloadimportedmodule:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> <a href="https://tc39.es/ecma262/#sec-HostLoadImportedModule" id="hostloadimportedmodule:js-hostloadimportedmodule" data-x-internal="js-hostloadimportedmodule">HostLoadImportedModule</a> abstract operation. User agents
  must use the following implementation: <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

  <ol><li><p>Let <var>settingsObject</var> be the <a href="#current-settings-object" id="hostloadimportedmodule:current-settings-object">current settings object</a>.</p></li><li>
    <p>If <var>settingsObject</var>'s <a href="#concept-settings-object-global" id="hostloadimportedmodule:concept-settings-object-global">global
    object</a> implements <code id="hostloadimportedmodule:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code> or <code id="hostloadimportedmodule:serviceworkerglobalscope"><a data-x-internal="serviceworkerglobalscope" href="https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope">ServiceWorkerGlobalScope</a></code>
    and <var>loadState</var> is undefined, then:</p>

    <p class="note"><var>loadState</var> is undefined when the current fetching process has been
    initiated by a dynamic <code id="hostloadimportedmodule:import()"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> call, either directly or when loading the
    transitive dependencies of the dynamically imported module.</p>

    <ol><li><p>Perform <a id="hostloadimportedmodule:finishloadingimportedmodule" href="https://tc39.es/ecma262/#sec-FinishLoadingImportedModule" data-x-internal="finishloadingimportedmodule">FinishLoadingImportedModule</a>(<var>referrer</var>,
     <var>moduleRequest</var>, <var>payload</var>, <a id="hostloadimportedmodule:throwcompletion" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(a new
     <code id="hostloadimportedmodule:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>)).</p></li><li><p>Return.</p></li></ol>
   </li><li><p>Let <var>referencingScript</var> be null.</p></li><li><p>Let <var>originalFetchOptions</var> be the <a href="#default-script-fetch-options" id="hostloadimportedmodule:default-script-fetch-options">default script fetch
   options</a>.</p></li><li><p>Let <var>fetchReferrer</var> be "<code>client</code>".</p></li><li>
    <p>If <var>referrer</var> is a <a id="hostloadimportedmodule:script-record" href="https://tc39.es/ecma262/#sec-script-records" data-x-internal="script-record">Script Record</a> or a <a id="hostloadimportedmodule:cyclic-module-record" href="https://tc39.es/ecma262/#sec-cyclic-module-records" data-x-internal="cyclic-module-record">Cyclic Module
    Record</a>, then:</p>

    <ol><li><p>Set <var>referencingScript</var> to <var>referrer</var>.[[HostDefined]].</p>

     </li><li><p>Set <var>settingsObject</var> to <var>referencingScript</var>'s <a href="#settings-object" id="hostloadimportedmodule:settings-object">settings object</a>.</p></li><li><p>Set <var>fetchReferrer</var> to <var>referencingScript</var>'s <a href="#concept-script-base-url" id="hostloadimportedmodule:concept-script-base-url">base URL</a>.</p></li><li><p>Set <var>originalFetchOptions</var> to <var>referencingScript</var>'s <a href="#concept-script-script-fetch-options" id="hostloadimportedmodule:concept-script-script-fetch-options">fetch options</a>.</p></li></ol>

    <div class="example">
     <p><var>referrer</var> is usually a <a id="hostloadimportedmodule:script-record-2" href="https://tc39.es/ecma262/#sec-script-records" data-x-internal="script-record">Script Record</a> or a <a id="hostloadimportedmodule:cyclic-module-record-2" href="https://tc39.es/ecma262/#sec-cyclic-module-records" data-x-internal="cyclic-module-record">Cyclic Module
     Record</a>, but it will not be so for event handlers per the <a href="#getting-the-current-value-of-the-event-handler" id="hostloadimportedmodule:getting-the-current-value-of-the-event-handler">get the current value of the event handler</a>
     algorithm. For example, given:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"import('./foo.mjs')"</c-><c- p="">&gt;</c->Click me<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-></code></pre>

     <p>If a <code id="hostloadimportedmodule:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event occurs, then at the time the
     <code id="hostloadimportedmodule:import()-2"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code> expression runs, <a id="hostloadimportedmodule:getactivescriptormodule" href="https://tc39.es/ecma262/#sec-getactivescriptormodule" data-x-internal="getactivescriptormodule">GetActiveScriptOrModule</a> will return null,
     and this operation will receive the <a id="hostloadimportedmodule:current-realm" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a> as a fallback
     <var>referrer</var>.</p>
    </div>
   </li><li>
    <p>If <var>referrer</var> is a <a id="hostloadimportedmodule:cyclic-module-record-3" href="https://tc39.es/ecma262/#sec-cyclic-module-records" data-x-internal="cyclic-module-record">Cyclic Module Record</a> and <var>moduleRequest</var>
    is equal to the first element of <var>referrer</var>.[[RequestedModules]], then:</p>

    <ol><li id="validate-requested-module-specifiers">
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="hostloadimportedmodule:list-iterate" data-x-internal="list-iterate">For each</a> <a id="hostloadimportedmodule:modulerequest-record" href="https://tc39.es/ecma262/#modulerequest-record" data-x-internal="modulerequest-record">ModuleRequest record</a>
      <var>requested</var> of <var>referrer</var>.[[RequestedModules]]:</p>

      <ol><li>
        <p>If <var>moduleRequest</var>.[[Attributes]] contains a <a id="hostloadimportedmodule:record" href="https://tc39.es/ecma262/#sec-list-and-record-specification-type" data-x-internal="record">Record</a> <var>entry</var>
        such that <var>entry</var>.[[Key]] is not "<code>type</code>", then:</p>

        <ol><li><p>Let <var>error</var> be a new <code id="hostloadimportedmodule:syntaxerror-2"><a data-x-internal="syntaxerror-2" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-syntaxerror">SyntaxError</a></code> exception.</p></li><li><p>If <var>loadState</var> is not undefined and <var>loadState</var>.[[ErrorToRethrow]]
         is null, set <var>loadState</var>.[[ErrorToRethrow]] to <var>error</var>.</p></li><li><p>Perform <a id="hostloadimportedmodule:finishloadingimportedmodule-2" href="https://tc39.es/ecma262/#sec-FinishLoadingImportedModule" data-x-internal="finishloadingimportedmodule">FinishLoadingImportedModule</a>(<var>referrer</var>,
         <var>moduleRequest</var>, <var>payload</var>,
         <a id="hostloadimportedmodule:throwcompletion-2" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(<var>error</var>)).</p></li><li><p>Return.</p></li></ol>

        <p class="note">The JavaScript specification re-performs this validation but it is duplicated
        here to avoid unnecessarily loading any of the dependencies on validation failure.</p>
       </li><li><p><a href="#resolve-a-module-specifier" id="hostloadimportedmodule:resolve-a-module-specifier">Resolve a module specifier</a> given <var>referencingScript</var> and
       <var>moduleRequest</var>.[[Specifier]], catching any exceptions. If they throw an exception, let
       <var>resolutionError</var> be the thrown exception.</p></li><li>
        <p>If the previous step threw an exception, then:</p>

        <ol><li><p>If <var>loadState</var> is not undefined and <var>loadState</var>.[[ErrorToRethrow]]
         is null, set <var>loadState</var>.[[ErrorToRethrow]] to
         <var>resolutionError</var>.</p></li><li><p>Perform <a id="hostloadimportedmodule:finishloadingimportedmodule-3" href="https://tc39.es/ecma262/#sec-FinishLoadingImportedModule" data-x-internal="finishloadingimportedmodule">FinishLoadingImportedModule</a>(<var>referrer</var>,
         <var>moduleRequest</var>, <var>payload</var>,
         <a id="hostloadimportedmodule:throwcompletion-3" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(<var>resolutionError</var>)).</p></li><li><p>Return.</p></li></ol>
       </li><li><p>Let <var>moduleType</var> be the result of running the <a href="#module-type-from-module-request" id="hostloadimportedmodule:module-type-from-module-request">module type from module
       request</a> steps given <var>moduleRequest</var>.</p></li><li>
        <p>If the result of running the <a href="#module-type-allowed" id="hostloadimportedmodule:module-type-allowed">module type allowed</a> steps given
        <var>moduleType</var> and <var>settingsObject</var> is false, then:</p>

        <ol><li><p>Let <var>error</var> be a new <code id="hostloadimportedmodule:typeerror-2"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> exception.</p></li><li><p>If <var>loadState</var> is not undefined and <var>loadState</var>.[[ErrorToRethrow]]
         is null, set <var>loadState</var>.[[ErrorToRethrow]] to <var>error</var>.</p></li><li><p>Perform <a id="hostloadimportedmodule:finishloadingimportedmodule-4" href="https://tc39.es/ecma262/#sec-FinishLoadingImportedModule" data-x-internal="finishloadingimportedmodule">FinishLoadingImportedModule</a>(<var>referrer</var>,
         <var>moduleRequest</var>, <var>payload</var>,
         <a id="hostloadimportedmodule:throwcompletion-4" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(<var>error</var>)).</p></li><li><p>Return.</p></li></ol>
       </li></ol>

      <p class="note">This step is essentially validating all of the requested module specifiers and
      type attributes when the first call to <a href="#hostloadimportedmodule" id="hostloadimportedmodule:hostloadimportedmodule">HostLoadImportedModule</a> for a static module
      dependency list is made, to avoid further loading operations in the case any one of the
      dependencies has a static error. We treat a module with unresolvable module specifiers or
      unsupported type attributes the same as one that cannot be parsed; in both cases, a syntactic
      issue makes it impossible to ever contemplate linking the module later.</p>
     </li></ol>
   </li><li><p>Let <var>url</var> be the result of <a href="#resolve-a-module-specifier" id="hostloadimportedmodule:resolve-a-module-specifier-2">resolving a
   module specifier</a> given <var>referencingScript</var> and
   <var>moduleRequest</var>.[[Specifier]], catching any exceptions. If they throw an exception, let
   <var>resolutionError</var> be the thrown exception.</p></li><li>
    <p>If the previous step threw an exception, then:</p>

    <ol><li><p>If <var>loadState</var> is not undefined and <var>loadState</var>.[[ErrorToRethrow]] is
     null, set <var>loadState</var>.[[ErrorToRethrow]] to <var>resolutionError</var>.</p></li><li><p>Perform <a id="hostloadimportedmodule:finishloadingimportedmodule-5" href="https://tc39.es/ecma262/#sec-FinishLoadingImportedModule" data-x-internal="finishloadingimportedmodule">FinishLoadingImportedModule</a>(<var>referrer</var>,
     <var>moduleRequest</var>, <var>payload</var>,
     <a id="hostloadimportedmodule:throwcompletion-5" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(<var>resolutionError</var>)).</p></li><li><p>Return.</p></li></ol>
   </li><li><p>Let <var>fetchOptions</var> be the result of <a href="#get-the-descendant-script-fetch-options" id="hostloadimportedmodule:get-the-descendant-script-fetch-options">getting the descendant script fetch options</a> given
   <var>originalFetchOptions</var>, <var>url</var>, and <var>settingsObject</var>.</p></li><li><p>Let <var>destination</var> be <code>"script"</code>.</p></li><li><p>Let <var>fetchClient</var> be <var>settingsObject</var>.</p></li><li>
    <p>If <var>loadState</var> is not undefined, then:</p>

    <ol><li><p>Set <var>destination</var> to <var>loadState</var>.[[Destination]].</p></li><li><p>Set <var>fetchClient</var> to <var>loadState</var>.[[FetchClient]].</p></li></ol>
   </li><li>
    <p><a href="#fetch-a-single-imported-module-script" id="hostloadimportedmodule:fetch-a-single-imported-module-script">Fetch a single imported module script</a> given <var>url</var>,
    <var>fetchClient</var>, <var>destination</var>, <var>fetchOptions</var>,
    <var>settingsObject</var>, <var>fetchReferrer</var>, <var>moduleRequest</var>, and
    <var>onSingleFetchComplete</var> as defined below. If <var>loadState</var> is not undefined and
    <var>loadState</var>.[[PerformFetch]] is not null, pass <var>loadState</var>.[[PerformFetch]]
    along as well.</p>

    <p><var>onSingleFetchComplete</var> given <var>moduleScript</var> is the following
    algorithm:</p>

    <ol><li><p>Let <var>completion</var> be null.</p></li><li><p>If <var>moduleScript</var> is null, then set <var>completion</var> to
     <a id="hostloadimportedmodule:throwcompletion-6" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(a new <code id="hostloadimportedmodule:typeerror-3"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>).</p></li><li>
      <p>Otherwise, if <var>moduleScript</var>'s <a href="#concept-script-parse-error" id="hostloadimportedmodule:concept-script-parse-error">parse
      error</a> is not null, then:</p>

      <ol><li><p>Let <var>parseError</var> be <var>moduleScript</var>'s <a href="#concept-script-parse-error" id="hostloadimportedmodule:concept-script-parse-error-2">parse error</a>.</p></li><li><p>Set <var>completion</var> to
       <a id="hostloadimportedmodule:throwcompletion-7" href="https://tc39.es/ecma262/#sec-throwcompletion" data-x-internal="throwcompletion">ThrowCompletion</a>(<var>parseError</var>).</p></li><li><p>If <var>loadState</var> is not undefined and <var>loadState</var>.[[ErrorToRethrow]] is
       null, set <var>loadState</var>.[[ErrorToRethrow]] to <var>parseError</var>.</p></li></ol>
     </li><li><p>Otherwise, set <var>completion</var> to
     <a id="hostloadimportedmodule:normalcompletion" href="https://tc39.es/ecma262/#sec-normalcompletion" data-x-internal="normalcompletion">NormalCompletion</a>(<var>moduleScript</var>'s <a href="#concept-script-record" id="hostloadimportedmodule:concept-script-record">record</a>).</p></li><li><p>Perform <a id="hostloadimportedmodule:finishloadingimportedmodule-6" href="https://tc39.es/ecma262/#sec-FinishLoadingImportedModule" data-x-internal="finishloadingimportedmodule">FinishLoadingImportedModule</a>(<var>referrer</var>,
     <var>moduleRequest</var>, <var>payload</var>, <var>completion</var>).</p></li></ol>
   </li></ol>
  </div>

  

  <h4 id="event-loops"><span class="secno">8.1.7</span> Event loops<a href="#event-loops" class="self-link"></a></h4>

  <h5 id="definitions-3"><span class="secno">8.1.7.1</span> Definitions<a href="#definitions-3" class="self-link"></a></h5>

  <p>To coordinate events, user interaction, scripts, rendering, networking, and so forth, user
  agents must use <dfn id="event-loop" data-lt="event loop" data-export="">event loops</dfn> as
  described in this section. Each <a id="definitions-3:agent" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a> has an associated <dfn data-dfn-for="agent" id="concept-agent-event-loop" data-export="">event loop</dfn>, which is unique to that agent.</p>

  <div data-algorithm="">
  <p>The <a href="#concept-agent-event-loop" id="definitions-3:concept-agent-event-loop">event loop</a> of a <a href="#similar-origin-window-agent" id="definitions-3:similar-origin-window-agent">similar-origin window
  agent</a> is known as a <dfn id="window-event-loop">window event loop</dfn>. The <a href="#concept-agent-event-loop" id="definitions-3:concept-agent-event-loop-2">event loop</a> of a <a href="#dedicated-worker-agent" id="definitions-3:dedicated-worker-agent">dedicated worker agent</a>,
  <a href="#shared-worker-agent" id="definitions-3:shared-worker-agent">shared worker agent</a>, or <a href="#service-worker-agent" id="definitions-3:service-worker-agent">service worker agent</a> is known as a <dfn id="worker-event-loop-2">worker
  event loop</dfn>. And the <a href="#concept-agent-event-loop" id="definitions-3:concept-agent-event-loop-3">event loop</a> of a
  <a href="#worklet-agent" id="definitions-3:worklet-agent">worklet agent</a> is known as a <dfn id="worklet-event-loop">worklet event loop</dfn>.</p>
  </div>

  <div class="note">
   <p><a href="#event-loop" id="definitions-3:event-loop">Event loops</a> do not necessarily correspond to implementation
   threads. For example, multiple <a href="#window-event-loop" id="definitions-3:window-event-loop">window event loops</a> could
   be cooperatively scheduled in a single thread.</p>

   <p>However, for the various worker <a href="https://tc39.es/ecma262/#sec-agents" id="definitions-3:agent-2" data-x-internal="agent">agents</a> that are allocated with
   [[CanBlock]] set to true, the JavaScript specification does place requirements on them regarding
   <a id="definitions-3:forward-progress" href="https://tc39.es/ecma262/#sec-forward-progress" data-x-internal="forward-progress">forward progress</a>, which effectively amount to requiring dedicated per-agent threads
   in those cases.</p>
  </div>

  

  <hr>

  <p>An <a href="#event-loop" id="definitions-3:event-loop-2">event loop</a> has one or more <dfn id="task-queue">task queues</dfn>. A
  <a href="#task-queue" id="definitions-3:task-queue">task queue</a> is a <a id="definitions-3:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <a href="#concept-task" id="definitions-3:concept-task">tasks</a>.</p>

  <p class="note"><a href="#task-queue" id="definitions-3:task-queue-2">Task queues</a> are <a href="https://infra.spec.whatwg.org/#ordered-set" id="definitions-3:set-2" data-x-internal="set">sets</a>,
  not <a href="https://infra.spec.whatwg.org/#queue" id="definitions-3:queue" data-x-internal="queue">queues</a>, because the <a href="#event-loop-processing-model">event
  loop processing model</a> grabs the first <a href="#concept-task-runnable" id="definitions-3:concept-task-runnable"><em>runnable</em></a> <a href="#concept-task" id="definitions-3:concept-task-2">task</a>
  from the chosen queue, instead of <a href="https://infra.spec.whatwg.org/#queue-dequeue" id="definitions-3:dequeue" data-x-internal="dequeue">dequeuing</a> the first task.</p>

  <p class="note">The <a href="#microtask-queue" id="definitions-3:microtask-queue">microtask queue</a> is not a <a href="#task-queue" id="definitions-3:task-queue-3">task queue</a>.</p>

  <p>Tasks encapsulate algorithms that are responsible for such work as:</p>

  <dl><dt>Events</dt><dd>
    <p>Dispatching an <code id="definitions-3:event"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code> object at a particular
    <code id="definitions-3:eventtarget"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code> object is often done by a dedicated task.</p>

    <p class="note">Not all events are dispatched using the <a href="#task-queue" id="definitions-3:task-queue-4">task queue</a>; many are
    dispatched during other tasks.</p>
   </dd><dt>Parsing</dt><dd><p>The <a href="#html-parser" id="definitions-3:html-parser">HTML parser</a> tokenizing one or more bytes, and then processing any
   resulting tokens, is typically a task.</p></dd><dt>Callbacks</dt><dd><p>Calling a callback is often done by a dedicated task.</p></dd><dt>Using a resource</dt><dd><p>When an algorithm <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="definitions-3:concept-fetch" data-x-internal="concept-fetch">fetches</a> a resource, if the fetching
   occurs in a non-blocking fashion then the processing of the resource once some or all of the
   resource is available is performed by a task.</p></dd><dt>Reacting to DOM manipulation</dt><dd><p>Some elements have tasks that trigger in response to DOM manipulation, e.g. when that
   element is <a href="#insert-an-element-into-a-document" id="definitions-3:insert-an-element-into-a-document">inserted into the document</a>.</p>
  </dd></dl>

  <p>Formally, a <dfn id="concept-task" data-lt="task" data-export="">task</dfn> is a
  <a id="definitions-3:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> which has:</p>

  <dl><dt><dfn id="concept-task-steps">Steps</dfn></dt><dd>A series of steps specifying the work to be done by the task.</dd><dt>A <dfn id="concept-task-source">source</dfn></dt><dd>One of the <a href="#task-source" id="definitions-3:task-source">task sources</a>, used to group and serialize
   related tasks.</dd><dt>A <dfn id="concept-task-document">document</dfn></dt><dd>A <code id="definitions-3:document"><a href="#document">Document</a></code> associated with the task, or null for tasks that are not in a
   <a href="#window-event-loop" id="definitions-3:window-event-loop-2">window event loop</a>.</dd><dt>A <dfn id="script-evaluation-environment-settings-object-set" data-export="">script evaluation environment settings object set</dfn></dt><dd>A <a id="definitions-3:set-3" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <a href="#environment-settings-object" id="definitions-3:environment-settings-object">environment settings
   objects</a> used for tracking script evaluation during the task.</dd></dl>

  <div data-algorithm="">
  <p>A <a href="#concept-task" id="definitions-3:concept-task-3">task</a> is <dfn id="concept-task-runnable">runnable</dfn>
  if its <a href="#concept-task-document" id="definitions-3:concept-task-document">document</a> is either null or <a href="#fully-active" id="definitions-3:fully-active">fully
  active</a>.</p>
  </div>

  <p>Per its <a href="#concept-task-source" id="definitions-3:concept-task-source">source</a> field, each <a href="#concept-task" id="definitions-3:concept-task-4">task</a> is defined as coming from a specific <dfn id="task-source" data-export="">task
  source</dfn>. For each <a href="#event-loop" id="definitions-3:event-loop-3">event loop</a>, every <a href="#task-source" id="definitions-3:task-source-2">task source</a> must be associated
  with a specific <a href="#task-queue" id="definitions-3:task-queue-5">task queue</a>.</p>

  <p class="note">Essentially, <a href="#task-source" id="definitions-3:task-source-3">task sources</a> are used within
  standards to separate logically-different types of tasks, which a user agent might wish to
  distinguish between. <a href="#task-queue" id="definitions-3:task-queue-6">Task queues</a> are used by user agents to
  coalesce task sources within a given <a href="#event-loop" id="definitions-3:event-loop-4">event loop</a>.</p>

  <p class="example">For example, a user agent could have one <a href="#task-queue" id="definitions-3:task-queue-7">task queue</a> for mouse and
  key events (to which the <a href="#user-interaction-task-source" id="definitions-3:user-interaction-task-source">user interaction task source</a> is associated), and another to
  which all other <a href="#task-source" id="definitions-3:task-source-4">task sources</a> are associated. Then, using the
  freedom granted in the initial step of the <a href="#event-loop-processing-model">event loop
  processing model</a>, it could give keyboard and mouse events preference over other tasks
  three-quarters of the time, keeping the interface responsive but not starving other task queues.
  Note that in this setup, the processing model still enforces that the user agent would never
  process events from any one <a href="#task-source" id="definitions-3:task-source-5">task source</a> out of order.</p>

  <hr>

  <p>Each <a href="#event-loop" id="definitions-3:event-loop-5">event loop</a> has a <dfn id="currently-running-task">currently running task</dfn>, which is either a <a href="#concept-task" id="definitions-3:concept-task-5">task</a> or null. Initially, this is null. It is used to handle
  reentrancy.</p>

  <p>Each <a href="#event-loop" id="definitions-3:event-loop-6">event loop</a> has a <dfn id="microtask-queue">microtask queue</dfn>, which is a <a id="definitions-3:queue-2" href="https://infra.spec.whatwg.org/#queue" data-x-internal="queue">queue</a> of
  <a href="#microtask" id="definitions-3:microtask">microtasks</a>, initially empty. A <dfn id="microtask" data-export="">microtask</dfn> is a
  colloquial way of referring to a <a href="#concept-task" id="definitions-3:concept-task-6">task</a> that was created via the
  <a href="#queue-a-microtask" id="definitions-3:queue-a-microtask">queue a microtask</a> algorithm.</p>

  <p>Each <a href="#event-loop" id="definitions-3:event-loop-7">event loop</a> has a <dfn id="performing-a-microtask-checkpoint">performing a microtask checkpoint</dfn> boolean,
  which is initially false. It is used to prevent reentrant invocation of the <a href="#perform-a-microtask-checkpoint" id="definitions-3:perform-a-microtask-checkpoint">perform a
  microtask checkpoint</a> algorithm.</p>

  <p>Each <a href="#window-event-loop" id="definitions-3:window-event-loop-3">window event loop</a> has a <code id="definitions-3:domhighrestimestamp"><a data-x-internal="domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp">DOMHighResTimeStamp</a></code>
  <dfn id="last-render-opportunity-time">last render opportunity time</dfn>, initially set to zero.</p>

  <p>Each <a href="#window-event-loop" id="definitions-3:window-event-loop-4">window event loop</a> has a <code id="definitions-3:domhighrestimestamp-2"><a data-x-internal="domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp">DOMHighResTimeStamp</a></code>
  <dfn id="last-idle-period-start-time">last idle period start time</dfn>, initially set to zero.</p>

  <div data-algorithm="">
  <p>To get the <dfn id="same-loop-windows">same-loop windows</dfn> for a <a href="#window-event-loop" id="definitions-3:window-event-loop-5">window event loop</a> <var>loop</var>,
  return all <code id="definitions-3:window"><a href="#window">Window</a></code> objects whose <a href="#relevant-agent" id="definitions-3:relevant-agent">relevant agent</a>'s
  <a href="#concept-agent-event-loop" id="definitions-3:concept-agent-event-loop-4">event loop</a> is <var>loop</var>.</p>
  </div>


  <h5 id="queuing-tasks"><span class="secno">8.1.7.2</span> Queuing tasks<a href="#queuing-tasks" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="queue-a-task" data-export="">queue a task</dfn> on a <a href="#task-source" id="queuing-tasks:task-source">task source</a> <var>source</var>, which
  performs a series of steps <var>steps</var>, optionally given an event loop <var>event loop</var>
  and a document <var>document</var>:</p>

  <ol><li><p>If <var>event loop</var> was not given, set <var>event loop</var> to the <a href="#implied-event-loop" id="queuing-tasks:implied-event-loop">implied
   event loop</a>.</p></li><li><p>If <var>document</var> was not given, set <var>document</var> to the <a href="#implied-document" id="queuing-tasks:implied-document">implied
   document</a>.</p></li><li><p>Let <var>task</var> be a new <a href="#concept-task" id="queuing-tasks:concept-task">task</a>.</p></li><li><p>Set <var>task</var>'s <a href="#concept-task-steps" id="queuing-tasks:concept-task-steps">steps</a> to
   <var>steps</var>.</p></li><li><p>Set <var>task</var>'s <a href="#concept-task-source" id="queuing-tasks:concept-task-source">source</a> to
   <var>source</var>.</p></li><li><p>Set <var>task</var>'s <a href="#concept-task-document" id="queuing-tasks:concept-task-document">document</a> to the
   <var>document</var>.</p></li><li><p>Set <var>task</var>'s <a href="#script-evaluation-environment-settings-object-set" id="queuing-tasks:script-evaluation-environment-settings-object-set">script evaluation environment settings object set</a> to an
   empty <a id="queuing-tasks:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a>.</p></li><li><p>Let <var>queue</var> be the <a href="#task-queue" id="queuing-tasks:task-queue">task queue</a> to which <var>source</var> is
   associated on <var>event loop</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="queuing-tasks:list-append" data-x-internal="list-append">Append</a> <var>task</var> to <var>queue</var>.</p></li></ol>
  </div>

  <p class="warning">Failing to pass an event loop and document to <a href="#queue-a-task" id="queuing-tasks:queue-a-task">queue a task</a> means
  relying on the ambiguous and poorly-specified <a href="#implied-event-loop" id="queuing-tasks:implied-event-loop-2">implied event loop</a> and <a href="#implied-document" id="queuing-tasks:implied-document-2">implied
  document</a> concepts. Specification authors should either always pass these values, or use the
  wrapper algorithms <a href="#queue-a-global-task" id="queuing-tasks:queue-a-global-task">queue a global task</a> or <a href="#queue-an-element-task" id="queuing-tasks:queue-an-element-task">queue an element task</a>
  instead. Using the wrapper algorithms is recommended.</p>

  <div data-algorithm="">
  <p>To <dfn id="queue-a-global-task" data-export="">queue a global task</dfn> on a <a href="#task-source" id="queuing-tasks:task-source-2">task source</a> <var>source</var>, with
  a <a href="#global-object" id="queuing-tasks:global-object">global object</a> <var>global</var> and a series of steps <var>steps</var>:</p>

  <ol><li><p>Let <var>event loop</var> be <var>global</var>'s <a href="#relevant-agent" id="queuing-tasks:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="queuing-tasks:concept-agent-event-loop">event loop</a>.</p></li><li><p>Let <var>document</var> be <var>global</var>'s <a href="#concept-document-window" id="queuing-tasks:concept-document-window">associated <code>Document</code></a>, if <var>global</var> is
   a <code id="queuing-tasks:window"><a href="#window">Window</a></code> object; otherwise null.</p>

   </li><li><p><a href="#queue-a-task" id="queuing-tasks:queue-a-task-2">Queue a task</a> given <var>source</var>, <var>event loop</var>,
   <var>document</var>, and <var>steps</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="queue-an-element-task" data-export="">queue an element task</dfn> on a <a href="#task-source" id="queuing-tasks:task-source-3">task source</a> <var>source</var>,
  with an element <var>element</var> and a series of steps <var>steps</var>:</p>

  <ol><li><p>Let <var>global</var> be <var>element</var>'s <a href="#concept-relevant-global" id="queuing-tasks:concept-relevant-global">relevant global
   object</a>.</p></li><li><p><a href="#queue-a-global-task" id="queuing-tasks:queue-a-global-task-2">Queue a global task</a> given <var>source</var>, <var>global</var>, and
   <var>steps</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="queue-a-microtask" data-export="">queue a microtask</dfn> which performs a series of steps <var>steps</var>,
  optionally given a document <var>document</var>:</p>

  <ol><li><p><a id="queuing-tasks:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: there is a <a id="queuing-tasks:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>. I.e., this algorithm is
   not called while <a href="#in-parallel" id="queuing-tasks:in-parallel">in parallel</a>.</p></li><li><p>Let <var>eventLoop</var> be the <a id="queuing-tasks:surrounding-agent-2" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s <a href="#concept-agent-event-loop" id="queuing-tasks:concept-agent-event-loop-2">event loop</a>.</p></li><li><p>If <var>document</var> was not given, set <var>document</var> to the <a href="#implied-document" id="queuing-tasks:implied-document-3">implied
   document</a>.</p></li><li><p>Let <var>microtask</var> be a new <a href="#concept-task" id="queuing-tasks:concept-task-2">task</a>.</p></li><li><p>Set <var>microtask</var>'s <a href="#concept-task-steps" id="queuing-tasks:concept-task-steps-2">steps</a> to
   <var>steps</var>.</p></li><li><p>Set <var>microtask</var>'s <a href="#concept-task-source" id="queuing-tasks:concept-task-source-2">source</a> to the
   <dfn id="microtask-task-source">microtask task source</dfn>.</p></li><li><p>Set <var>microtask</var>'s <a href="#concept-task-document" id="queuing-tasks:concept-task-document-2">document</a> to
   <var>document</var>.</p></li><li><p>Set <var>microtask</var>'s <a href="#script-evaluation-environment-settings-object-set" id="queuing-tasks:script-evaluation-environment-settings-object-set-2">script evaluation environment settings object set</a>
   to an empty <a id="queuing-tasks:set-2" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a>.</p></li><li><p><a id="queuing-tasks:enqueue" href="https://infra.spec.whatwg.org/#queue-enqueue" data-x-internal="enqueue">Enqueue</a> <var>microtask</var> on <var>eventLoop</var>'s <a href="#microtask-queue" id="queuing-tasks:microtask-queue">microtask
   queue</a>.</p></li></ol>
  </div>

  <p class="note">It is possible for a <a href="#microtask" id="queuing-tasks:microtask">microtask</a> to be moved to a regular <a href="#task-queue" id="queuing-tasks:task-queue-2">task
  queue</a>, if, during its initial execution, it <a href="#spin-the-event-loop" id="queuing-tasks:spin-the-event-loop">spins the
  event loop</a>. This is the only case in which the <a href="#concept-task-source" id="queuing-tasks:concept-task-source-3">source</a>, <a href="#concept-task-document" id="queuing-tasks:concept-task-document-3">document</a>,
  and <a href="#script-evaluation-environment-settings-object-set" id="queuing-tasks:script-evaluation-environment-settings-object-set-3">script evaluation environment settings object set</a> of the microtask are consulted;
  they are ignored by the <a href="#perform-a-microtask-checkpoint" id="queuing-tasks:perform-a-microtask-checkpoint">perform a microtask checkpoint</a> algorithm.</p>

  <p>The <dfn id="implied-event-loop">implied event loop</dfn> when queuing a task is the one that can deduced from the
  context of the calling algorithm. This is generally unambiguous, as most specification algorithms
  only ever involve a single <a id="queuing-tasks:agent" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a> (and thus a single <a href="#event-loop" id="queuing-tasks:event-loop">event loop</a>). The
  exception is algorithms involving or specifying cross-agent communication (e.g., between a window
  and a worker); for those cases, the <a href="#implied-event-loop" id="queuing-tasks:implied-event-loop-3">implied event loop</a> concept must not be relied
  upon and specifications must explicitly provide an <a href="#event-loop" id="queuing-tasks:event-loop-2">event loop</a> when <a href="#queue-a-task" id="queuing-tasks:queue-a-task-3">queuing a task</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="implied-document">implied document</dfn> when queuing a task on an <a href="#event-loop" id="queuing-tasks:event-loop-3">event loop</a> <var>event
  loop</var> is determined as follows:</p>

  <ol><li><p>If <var>event loop</var> is not a <a href="#window-event-loop" id="queuing-tasks:window-event-loop">window event loop</a>, then return
   null.</p></li><li><p>If the task is being queued in the context of an element, then return the element's
   <a id="queuing-tasks:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If the task is being queued in the context of a <a href="#browsing-context" id="queuing-tasks:browsing-context">browsing context</a>, then return
   the browsing context's <a href="#active-document" id="queuing-tasks:active-document">active document</a>.</p></li><li><p>If the task is being queued by or for a <a href="#concept-script" id="queuing-tasks:concept-script">script</a>, then
   return the script's <a href="#settings-object" id="queuing-tasks:settings-object">settings object</a>'s <a href="#concept-settings-object-global" id="queuing-tasks:concept-settings-object-global">global object</a>'s <a href="#concept-document-window" id="queuing-tasks:concept-document-window-2">associated <code>Document</code></a>.</p></li><li><p><a id="queuing-tasks:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this step is never reached, because one of the previous conditions is
   true. <span class="XXX">Really?</span></p></li></ol>
  </div>

  <p class="XXX">Both <a href="#implied-event-loop" id="queuing-tasks:implied-event-loop-4">implied event loop</a> and <a href="#implied-document" id="queuing-tasks:implied-document-4">implied
  document</a> are vaguely-defined and have a lot of action-at-a-distance. The hope is to remove
  these, especially <a href="#implied-document" id="queuing-tasks:implied-document-5">implied document</a>. See <a href="https://github.com/whatwg/html/issues/4980">issue #4980</a>.</p>


  <h5 id="event-loop-processing-model" data-dfn-type="dfn" data-lt="event loop processing model"><span class="secno">8.1.7.3</span> <span id="processing-model-8"></span>Processing model<a href="#event-loop-processing-model" class="self-link"></a></h5>
  

  <div data-algorithm="">
  <p>An <a href="#event-loop" id="event-loop-processing-model:event-loop">event loop</a> must continually run through the following steps for as long as it
  exists:</p>

  
  <ol id="step1"><li><p>Let <var>oldestTask</var> and <var>taskStartTime</var> be null.</p></li><li>
    <p>If the <a href="#event-loop" id="event-loop-processing-model:event-loop-2">event loop</a> has a <a href="#task-queue" id="event-loop-processing-model:task-queue">task queue</a> with at least one <a href="#concept-task-runnable" id="event-loop-processing-model:concept-task-runnable">runnable</a> <a href="#concept-task" id="event-loop-processing-model:concept-task">task</a>,
    then:</p>

    <ol><li>
      <p>Let <var>taskQueue</var> be one such <a href="#task-queue" id="event-loop-processing-model:task-queue-2">task queue</a>, chosen in an
      <a id="event-loop-processing-model:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner.</p>

      <p class="note">Remember that the <a href="#microtask-queue" id="event-loop-processing-model:microtask-queue">microtask queue</a> is not a <a href="#task-queue" id="event-loop-processing-model:task-queue-3">task
      queue</a>, so it will not be chosen in this step. However, a <a href="#task-queue" id="event-loop-processing-model:task-queue-4">task queue</a> to
      which the <a href="#microtask-task-source" id="event-loop-processing-model:microtask-task-source">microtask task source</a> is associated might be chosen in this step. In
      that case, the <a href="#concept-task" id="event-loop-processing-model:concept-task-2">task</a> chosen in the next step was originally
      a <a href="#microtask" id="event-loop-processing-model:microtask">microtask</a>, but it got moved as part of <a href="#spin-the-event-loop" id="event-loop-processing-model:spin-the-event-loop">spinning the event loop</a>.</p>
     </li><li><p>Set <var>taskStartTime</var> to the <a id="event-loop-processing-model:unsafe-shared-current-time" href="https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time" data-x-internal="unsafe-shared-current-time">unsafe shared current time</a>.</p></li><li><p>Set <var>oldestTask</var> to the first <a href="#concept-task-runnable" id="event-loop-processing-model:concept-task-runnable-2">runnable</a> <a href="#concept-task" id="event-loop-processing-model:concept-task-3">task</a> in
     <var>taskQueue</var>, and <a href="https://infra.spec.whatwg.org/#list-remove" id="event-loop-processing-model:list-remove" data-x-internal="list-remove">remove</a> it from
     <var>taskQueue</var>.</p></li><li><p>If <var>oldestTask</var>'s <a href="#concept-task-document" id="event-loop-processing-model:concept-task-document">document</a> is not
     null, then <a id="event-loop-processing-model:record-task-start-time" href="https://w3c.github.io/long-animation-frames/#record-task-start-time" data-x-internal="record-task-start-time">record task start time</a> given <var>taskStartTime</var> and
     <var>oldestTask</var>'s <a href="#concept-task-document" id="event-loop-processing-model:concept-task-document-2">document</a>.</p></li><li><p>Set the <a href="#event-loop" id="event-loop-processing-model:event-loop-3">event loop</a>'s <a href="#currently-running-task" id="event-loop-processing-model:currently-running-task">currently running task</a> to
     <var>oldestTask</var>.</p></li><li><p>Perform <var>oldestTask</var>'s <a href="#concept-task-steps" id="event-loop-processing-model:concept-task-steps">steps</a>.</p></li><li><p>Set the <a href="#event-loop" id="event-loop-processing-model:event-loop-4">event loop</a>'s <a href="#currently-running-task" id="event-loop-processing-model:currently-running-task-2">currently running task</a> back to
     null.</p></li><li><p><a href="#perform-a-microtask-checkpoint" id="event-loop-processing-model:perform-a-microtask-checkpoint">Perform a microtask checkpoint</a>.</p></li></ol>
   </li><li><p>Let <var>taskEndTime</var> be the <a id="event-loop-processing-model:unsafe-shared-current-time-2" href="https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time" data-x-internal="unsafe-shared-current-time">unsafe shared current time</a>.
   <a href="#refsHRT">[HRT]</a></p></li><li>
    <p>If <var>oldestTask</var> is not null, then:</p>

    <ol><li><p>Let <var>top-level browsing contexts</var> be an empty <a id="event-loop-processing-model:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a>.</p></li><li>
      <p>For each <a href="#environment-settings-object" id="event-loop-processing-model:environment-settings-object">environment settings object</a> <var>settings</var> of
      <var>oldestTask</var>'s <a href="#script-evaluation-environment-settings-object-set" id="event-loop-processing-model:script-evaluation-environment-settings-object-set">script evaluation environment settings object set</a>:</p>

      <ol><li><p>Let <var>global</var> be <var>settings</var>'s <a href="#concept-settings-object-global" id="event-loop-processing-model:concept-settings-object-global">global object</a>.</p></li><li><p>If <var>global</var> is not a <code id="event-loop-processing-model:window"><a href="#window">Window</a></code> object, then
       <a id="event-loop-processing-model:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>If <var>global</var>'s <a href="#window-bc" id="event-loop-processing-model:window-bc">browsing context</a> is null, then
       <a id="event-loop-processing-model:continue-2" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p>Let <var>tlbc</var> be <var>global</var>'s <a href="#window-bc" id="event-loop-processing-model:window-bc-2">browsing
       context</a>'s <a href="#bc-tlbc" id="event-loop-processing-model:bc-tlbc">top-level browsing context</a>.</p></li><li><p>If <var>tlbc</var> is not null, then <a href="https://infra.spec.whatwg.org/#set-append" id="event-loop-processing-model:set-append" data-x-internal="set-append">append</a> it to
       <var>top-level browsing contexts</var>.</p></li></ol>
     </li><li><p><a id="event-loop-processing-model:report-long-tasks" href="https://w3c.github.io/longtasks/#report-long-tasks" data-x-internal="report-long-tasks">Report long tasks</a>, passing in <var>taskStartTime</var>,
     <var>taskEndTime</var>, <var>top-level browsing contexts</var>, and
     <var>oldestTask</var>.</p></li><li><p>If <var>oldestTask</var>'s <a href="#concept-task-document" id="event-loop-processing-model:concept-task-document-3">document</a> is not
     null, then <a id="event-loop-processing-model:record-task-end-time" href="https://w3c.github.io/long-animation-frames/#record-task-end-time" data-x-internal="record-task-end-time">record task end time</a> given <var>taskEndTime</var> and
     <var>oldestTask</var>'s <a href="#concept-task-document" id="event-loop-processing-model:concept-task-document-4">document</a>.</p></li></ol>
   </li><li id="idle-deadline-computation">
    <p>If this is a <a href="#window-event-loop" id="event-loop-processing-model:window-event-loop">window event loop</a> that has no <a href="#concept-task-runnable" id="event-loop-processing-model:concept-task-runnable-3"><em>runnable</em></a> <a href="#concept-task" id="event-loop-processing-model:concept-task-4">task</a>
    in this <a href="#event-loop" id="event-loop-processing-model:event-loop-5">event loop</a>'s <a href="#task-queue" id="event-loop-processing-model:task-queue-5">task queues</a>, then:</p>

    <ol><li><p>Set this <a href="#event-loop" id="event-loop-processing-model:event-loop-6">event loop</a>'s <a href="#last-idle-period-start-time" id="event-loop-processing-model:last-idle-period-start-time">last idle period start time</a> to the
     <a id="event-loop-processing-model:unsafe-shared-current-time-3" href="https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time" data-x-internal="unsafe-shared-current-time">unsafe shared current time</a>.</p></li><li>
      <p>Let <var>computeDeadline</var> be the following steps:</p>

      <ol><li>
        <p>Let <var>deadline</var> be this <a href="#event-loop" id="event-loop-processing-model:event-loop-7">event loop</a>'s <a href="#last-idle-period-start-time" id="event-loop-processing-model:last-idle-period-start-time-2">last idle period start
        time</a> plus 50.</p>

        <p class="note">The cap of 50ms in the future is to ensure responsiveness to new user input
        within the threshold of human perception.</p>
       </li><li><p>Let <var>hasPendingRenders</var> be false.</p></li><li>
        <p>For each <var>windowInSameLoop</var> of the <a href="#same-loop-windows" id="event-loop-processing-model:same-loop-windows">same-loop windows</a> for this
        <a href="#event-loop" id="event-loop-processing-model:event-loop-8">event loop</a>:</p>

        <ol><li><p>If <var>windowInSameLoop</var>'s <a href="#list-of-animation-frame-callbacks" id="event-loop-processing-model:list-of-animation-frame-callbacks">map of animation frame callbacks</a> is
         not <a href="https://infra.spec.whatwg.org/#map-is-empty" id="event-loop-processing-model:map-empty" data-x-internal="map-empty">empty</a>, or if the user agent believes that the
         <var>windowInSameLoop</var> might have pending rendering updates, set
         <var>hasPendingRenders</var> to true.</p></li><li><p>Let <var>timerCallbackEstimates</var> be the result of <a href="https://infra.spec.whatwg.org/#map-getting-the-values" id="event-loop-processing-model:map-get-the-values" data-x-internal="map-get-the-values">getting the values</a> of <var>windowInSameLoop</var>'s <a href="#map-of-active-timers" id="event-loop-processing-model:map-of-active-timers">map of active
         timers</a>.</p></li><li><p>For each <var>timeoutDeadline</var> of <var>timerCallbackEstimates</var>, if
         <var>timeoutDeadline</var> is less than <var>deadline</var>, set <var>deadline</var> to
         <var>timeoutDeadline</var>.</p></li></ol>
       </li><li>
        <p>If <var>hasPendingRenders</var> is true, then:</p>

        <ol><li>
          <p>Let <var>nextRenderDeadline</var> be this <a href="#event-loop" id="event-loop-processing-model:event-loop-9">event loop</a>'s <a href="#last-render-opportunity-time" id="event-loop-processing-model:last-render-opportunity-time">last render
          opportunity time</a> plus (1000 divided by the current refresh rate).</p>

          <p>The refresh rate can be hardware- or implementation-specific. For a refresh rate of
          60Hz, the <var>nextRenderDeadline</var> would be about 16.67ms after the <a href="#last-render-opportunity-time" id="event-loop-processing-model:last-render-opportunity-time-2">last
          render opportunity time</a>.</p>
         </li><li><p>If <var>nextRenderDeadline</var> is less than <var>deadline</var>, then return
         <var>nextRenderDeadline</var>.</p></li></ol>
       </li><li><p>Return <var>deadline</var>.</p></li></ol>
     </li><li><p>For each <var>win</var> of the <a href="#same-loop-windows" id="event-loop-processing-model:same-loop-windows-2">same-loop windows</a> for this <a href="#event-loop" id="event-loop-processing-model:event-loop-10">event
     loop</a>, perform the <a id="event-loop-processing-model:start-an-idle-period-algorithm" href="https://w3c.github.io/requestidlecallback/#start-an-idle-period-algorithm" data-x-internal="start-an-idle-period-algorithm">start an idle period algorithm</a> for <var>win</var> with
     the following step: return the result of calling <var>computeDeadline</var>, <a href="https://w3c.github.io/hr-time/#dfn-coarsen-time" id="event-loop-processing-model:coarsen-time" data-x-internal="coarsen-time">coarsened</a> given <var>win</var>'s <a href="#relevant-settings-object" id="event-loop-processing-model:relevant-settings-object">relevant settings
     object</a>'s <a href="#concept-settings-object-cross-origin-isolated-capability" id="event-loop-processing-model:concept-settings-object-cross-origin-isolated-capability">cross-origin isolated
     capability</a>. <a href="#refsREQUESTIDLECALLBACK">[REQUESTIDLECALLBACK]</a></p></li></ol>
   </li><li>
    <p>If this is a <a href="#worker-event-loop-2" id="event-loop-processing-model:worker-event-loop-2">worker event loop</a>, then:</p>

    <ol><li>
      <p>If this <a href="#event-loop" id="event-loop-processing-model:event-loop-11">event loop</a>'s <a id="event-loop-processing-model:agent" href="https://tc39.es/ecma262/#sec-agents" data-x-internal="agent">agent</a>'s single <a id="event-loop-processing-model:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>'s <a href="#concept-realm-global" id="event-loop-processing-model:concept-realm-global">global object</a> is a <a href="#concept-animationframeprovider-supported" id="event-loop-processing-model:concept-animationframeprovider-supported">supported</a>
      <code id="event-loop-processing-model:dedicatedworkerglobalscope"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> and the user agent believes that it would benefit
      from having its rendering updated at this time, then:</p>
      

      <ol><li><p>Let <var>now</var> be the <a id="event-loop-processing-model:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given the
       <code id="event-loop-processing-model:dedicatedworkerglobalscope-2"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code>. <a href="#refsHRT">[HRT]</a></p></li><li><p><a href="#run-the-animation-frame-callbacks" id="event-loop-processing-model:run-the-animation-frame-callbacks">Run the animation frame callbacks</a> for that
       <code id="event-loop-processing-model:dedicatedworkerglobalscope-3"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code>, passing in <var>now</var> as the
       timestamp.</p></li><li><p>Update the rendering of that dedicated worker to reflect the current state.</p></li></ol>

      <p class="note">Similar to the notes for <a href="#update-the-rendering" id="event-loop-processing-model:update-the-rendering">updating the
      rendering</a> in a <a href="#window-event-loop" id="event-loop-processing-model:window-event-loop-2">window event loop</a>, a user agent can determine the rate of
      rendering in the dedicated worker.</p>
     </li><li><p>If there are no <a href="#concept-task" id="event-loop-processing-model:concept-task-5">tasks</a> in the <a href="#event-loop" id="event-loop-processing-model:event-loop-12">event
     loop</a>'s <a href="#task-queue" id="event-loop-processing-model:task-queue-6">task queues</a> and the
     <code id="event-loop-processing-model:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object's <a href="#dom-workerglobalscope-closing" id="event-loop-processing-model:dom-workerglobalscope-closing">closing</a> flag is true, then destroy the
     <a href="#event-loop" id="event-loop-processing-model:event-loop-13">event loop</a>, aborting these steps, resuming the <a href="#run-a-worker" id="event-loop-processing-model:run-a-worker">run a worker</a> steps
     described in the <a href="#workers">Web workers</a> section below.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>A <a href="#window-event-loop" id="event-loop-processing-model:window-event-loop-3">window event loop</a> <var>eventLoop</var> must also run the following <a href="#in-parallel" id="event-loop-processing-model:in-parallel">in
  parallel</a>, as long as it exists:</p>

  <ol><li><p>Wait until at least one <a href="#navigable" id="event-loop-processing-model:navigable">navigable</a> whose <a href="#nav-document" id="event-loop-processing-model:nav-document">active
   document</a>'s <a href="#relevant-agent" id="event-loop-processing-model:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="event-loop-processing-model:concept-agent-event-loop">event
   loop</a> is <var>eventLoop</var> might have a <a href="#rendering-opportunity" id="event-loop-processing-model:rendering-opportunity">rendering opportunity</a>.</p></li><li><p>Set <var>eventLoop</var>'s <a href="#last-render-opportunity-time" id="event-loop-processing-model:last-render-opportunity-time-3">last render opportunity time</a> to the <a id="event-loop-processing-model:unsafe-shared-current-time-4" href="https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time" data-x-internal="unsafe-shared-current-time">unsafe
   shared current time</a>.</p></li><li>
    <p>For each <var>navigable</var> that has a <a href="#rendering-opportunity" id="event-loop-processing-model:rendering-opportunity-2">rendering opportunity</a>, <a href="#queue-a-global-task" id="event-loop-processing-model:queue-a-global-task">queue a
    global task</a> on the <a href="#rendering-task-source" id="event-loop-processing-model:rendering-task-source">rendering task source</a> given <var>navigable</var>'s <a href="#nav-window" id="event-loop-processing-model:nav-window">active window</a> to <dfn id="update-the-rendering" data-export="">update the rendering</dfn>:</p>

    <p class="note">This might cause redundant calls to <a href="#update-the-rendering" id="event-loop-processing-model:update-the-rendering-2">update the rendering</a>. However,
    these calls would have no observable effect because there will be no rendering necessary, as
    per the <i>Unnecessary rendering</i> step. Implementations can introduce further optimizations
    such as only queuing this task when it is not already queued. However, note that the document
    associated with the task might become inactive before the task is processed.</p>

    <ol><li><p>Let <var>frameTimestamp</var> be <var>eventLoop</var>'s <a href="#last-render-opportunity-time" id="event-loop-processing-model:last-render-opportunity-time-4">last render opportunity
     time</a>.</p></li><li>
      <p>Let <var>docs</var> be all <a href="#fully-active" id="event-loop-processing-model:fully-active">fully active</a> <code id="event-loop-processing-model:document"><a href="#document">Document</a></code> objects whose
      <a href="#relevant-agent" id="event-loop-processing-model:relevant-agent-2">relevant agent</a>'s <a href="#concept-agent-event-loop" id="event-loop-processing-model:concept-agent-event-loop-2">event loop</a> is
      <var>eventLoop</var>, sorted arbitrarily except that the following conditions must be
      met:</p>

      <ul><li><p>Any <code id="event-loop-processing-model:document-2"><a href="#document">Document</a></code> <var>B</var> whose <a href="#doc-container-document" id="event-loop-processing-model:doc-container-document">container document</a> is <var>A</var> must be listed
       after <var>A</var> in the list.</p></li><li><p>If there are two documents <var>A</var> and <var>B</var> that both have the same
       non-null <a href="#doc-container-document" id="event-loop-processing-model:doc-container-document-2">container document</a> <var>C</var>, then
       the order of <var>A</var> and <var>B</var> in the list must match the <a id="event-loop-processing-model:shadow-including-tree-order" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" data-x-internal="shadow-including-tree-order">shadow-including
       tree order</a> of their respective <a href="#navigable-container" id="event-loop-processing-model:navigable-container">navigable
       containers</a> in <var>C</var>'s <a id="event-loop-processing-model:node-tree" href="https://dom.spec.whatwg.org/#concept-node-tree" data-x-internal="node-tree">node tree</a>.</p></li></ul>

      <p>In the steps below that iterate over <var>docs</var>, each <code id="event-loop-processing-model:document-3"><a href="#document">Document</a></code> must be
      processed in the order it is found in the list.</p>
     </li><li>
      <p><i>Filter non-renderable documents</i>: Remove from <var>docs</var> any
      <code id="event-loop-processing-model:document-4"><a href="#document">Document</a></code> object <var>doc</var> for which any of the following are true:

      </p><ul><li><p><var>doc</var> is <a href="#render-blocked" id="event-loop-processing-model:render-blocked">render-blocked</a>;</p></li><li><p><var>doc</var>'s <a href="#visibility-state" id="event-loop-processing-model:visibility-state">visibility state</a> is "<code>hidden</code>";</p></li><li><p><var>doc</var>'s rendering is <a href="https://drafts.csswg.org/css-view-transitions/#document-rendering-suppression-for-view-transitions" id="event-loop-processing-model:rendering-suppression-for-view-transitions" data-x-internal="rendering-suppression-for-view-transitions">suppressed for view transitions</a>; or</p></li><li><p><var>doc</var>'s <a href="#node-navigable" id="event-loop-processing-model:node-navigable">node navigable</a> doesn't currently have a <a href="#rendering-opportunity" id="event-loop-processing-model:rendering-opportunity-3">rendering
       opportunity</a>.</p></li></ul>

      <p class="note">We have to check for rendering opportunities here, in addition to checking
      that in the <a href="#in-parallel" id="event-loop-processing-model:in-parallel-2">in parallel</a> steps, as some documents that share the same <a href="#event-loop" id="event-loop-processing-model:event-loop-14">event
      loop</a> might not have a <a href="#rendering-opportunity" id="event-loop-processing-model:rendering-opportunity-4">rendering opportunity</a> at the same time.</p>
     </li><li>
      <p><i>Unnecessary rendering</i>: Remove from <var>docs</var> any <code id="event-loop-processing-model:document-5"><a href="#document">Document</a></code> object
      <var>doc</var> for which all of the following are true:</p>

      <ul><li><p>the user agent believes that updating the rendering of <var>doc</var>'s <a href="#node-navigable" id="event-loop-processing-model:node-navigable-2">node
       navigable</a> would have no visible effect; and</p></li><li><p><var>doc</var>'s <a href="#list-of-animation-frame-callbacks" id="event-loop-processing-model:list-of-animation-frame-callbacks-2">map of animation frame callbacks</a> is empty.</p></li></ul>
     </li><li>
      <p>Remove from <var>docs</var> all <code id="event-loop-processing-model:document-6"><a href="#document">Document</a></code> objects for which the user agent
      believes that it's preferable to skip updating the rendering for other reasons.</p>

      <div class="note">
       <p>The step labeled <i>Filter non-renderable documents</i> prevents the user agent from
       updating the rendering when it is unable to present new content to the user.</p>

       <p>The step labeled <i>Unnecessary rendering</i> prevents the user agent from updating the
       rendering when there's no new content to draw.</p>

       <p>This step enables the user agent to prevent the steps below from running for other
       reasons, for example, to ensure certain <a href="#concept-task" id="event-loop-processing-model:concept-task-6">tasks</a> are
       executed immediately after each other, with only <a href="#perform-a-microtask-checkpoint" id="event-loop-processing-model:perform-a-microtask-checkpoint-2">microtask checkpoints</a> interleaved (and without, e.g., <a href="#run-the-animation-frame-callbacks" id="event-loop-processing-model:run-the-animation-frame-callbacks-2">animation frame callbacks</a> interleaved). Concretely, a
       user agent might wish to coalesce timer callbacks together, with no intermediate rendering
       updates.</p>
      </div>
     </li><li><p>For each <var>doc</var> of <var>docs</var>, <a href="#reveal" id="event-loop-processing-model:reveal">reveal</a> <var>doc</var>.</p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a href="#flush-autofocus-candidates" id="event-loop-processing-model:flush-autofocus-candidates">flush autofocus candidates</a> for
     <var>doc</var> if its <a href="#node-navigable" id="event-loop-processing-model:node-navigable-3">node navigable</a> is a <a href="#top-level-traversable" id="event-loop-processing-model:top-level-traversable">top-level
     traversable</a>.</p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:run-the-resize-steps" href="https://drafts.csswg.org/cssom-view/#document-run-the-resize-steps" data-x-internal="run-the-resize-steps">run the resize steps</a> for
     <var>doc</var>. <a href="#refsCSSOMVIEW">[CSSOMVIEW]</a></p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:run-the-scroll-steps" href="https://drafts.csswg.org/cssom-view/#document-run-the-scroll-steps" data-x-internal="run-the-scroll-steps">run the scroll steps</a> for
     <var>doc</var>. <a href="#refsCSSOMVIEW">[CSSOMVIEW]</a></p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:evaluate-media-queries-and-report-changes" href="https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes" data-x-internal="evaluate-media-queries-and-report-changes">evaluate media queries and report
     changes</a> for <var>doc</var>. <a href="#refsCSSOMVIEW">[CSSOMVIEW]</a></p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:update-animations-and-send-events" href="https://drafts.csswg.org/web-animations-1/#update-animations-and-send-events" data-x-internal="update-animations-and-send-events">update animations and send
     events</a> for <var>doc</var>, passing in <a id="event-loop-processing-model:relative-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-relative-high-resolution-time" data-x-internal="relative-high-resolution-time">relative high resolution time</a> given
     <var>frameTimestamp</var> and <var>doc</var>'s <a href="#concept-relevant-global" id="event-loop-processing-model:concept-relevant-global">relevant global object</a> as the
     timestamp. <a href="#refsWEBANIMATIONS">[WEBANIMATIONS]</a></p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:run-the-fullscreen-steps" href="https://fullscreen.spec.whatwg.org/#run-the-fullscreen-steps" data-x-internal="run-the-fullscreen-steps">run the fullscreen steps</a> for
     <var>doc</var>. <a href="#refsFULLSCREEN">[FULLSCREEN]</a></p></li><li>
      <p>For each <var>doc</var> of <var>docs</var>, if the user agent detects that the backing
      storage associated with a <code id="event-loop-processing-model:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> or an
      <code id="event-loop-processing-model:offscreencanvasrenderingcontext2d"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code>, <var>context</var>, has been lost, then it
      must run the <dfn id="context-lost-steps">context lost steps</dfn> for each such <var>context</var>:</p>

      <ol><li><p>Let <var>canvas</var> be the value of <var>context</var>'s <code id="event-loop-processing-model:dom-context-2d-canvas"><a href="#dom-context-2d-canvas">canvas</a></code> attribute, if <var>context</var> is a
       <code id="event-loop-processing-model:canvasrenderingcontext2d-2"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code>, or the <a href="#associated-offscreencanvas-object" id="event-loop-processing-model:associated-offscreencanvas-object">associated <code>OffscreenCanvas</code>
       object</a> for <var>context</var> otherwise.</p></li><li><p>Set <var>context</var>'s <a href="#concept-canvas-context-lost" id="event-loop-processing-model:concept-canvas-context-lost">context
       lost</a> to true.</p></li><li><p><a href="#reset-the-rendering-context-to-its-default-state" id="event-loop-processing-model:reset-the-rendering-context-to-its-default-state">Reset the rendering context to its default state</a> given
       <var>context</var>.</p></li><li><p>Let <var>shouldRestore</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="event-loop-processing-model:concept-event-fire" data-x-internal="concept-event-fire">firing an event</a> named <code id="event-loop-processing-model:event-contextlost"><a href="#event-contextlost">contextlost</a></code> at <var>canvas</var>, with the <code id="event-loop-processing-model:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attribute initialized to true.</p></li><li><p>If <var>shouldRestore</var> is false, then abort these steps.</p></li><li><p>Attempt to restore <var>context</var> by creating a backing storage using
       <var>context</var>'s attributes and associating them with <var>context</var>. If this fails,
       then abort these steps.</p></li><li><p>Set <var>context</var>'s <a href="#concept-canvas-context-lost" id="event-loop-processing-model:concept-canvas-context-lost-2">context
       lost</a> to false.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="event-loop-processing-model:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="event-loop-processing-model:event-contextrestored"><a href="#event-contextrestored">contextrestored</a></code> at <var>canvas</var>.</p></li></ol>
     </li><li><p>For each <var>doc</var> of <var>docs</var>, <a href="#run-the-animation-frame-callbacks" id="event-loop-processing-model:run-the-animation-frame-callbacks-3">run the animation frame
     callbacks</a> for <var>doc</var>, passing in the <a id="event-loop-processing-model:relative-high-resolution-time-2" href="https://w3c.github.io/hr-time/#dfn-relative-high-resolution-time" data-x-internal="relative-high-resolution-time">relative high resolution time</a>
     given <var>frameTimestamp</var> and <var>doc</var>'s <a href="#concept-relevant-global" id="event-loop-processing-model:concept-relevant-global-2">relevant global object</a> as
     the timestamp.</p></li><li><p>Let <var>unsafeStyleAndLayoutStartTime</var> be the <a id="event-loop-processing-model:unsafe-shared-current-time-5" href="https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time" data-x-internal="unsafe-shared-current-time">unsafe shared current
     time</a>.</p>

     </li><li>
      <p>For each <var>doc</var> of <var>docs</var>:</p>

      <ol><li><p>Let <var>resizeObserverDepth</var> be 0.</p></li><li>
        <p>While true:</p>

        <ol><li><p>Recalculate styles and update layout for <var>doc</var>.</p></li><li><p>Let <var>hadInitialVisibleContentVisibilityDetermination</var> be false.</p></li><li>
          <p>For each element <var>element</var> with <a href="https://drafts.csswg.org/css-contain/#propdef-content-visibility" id="event-loop-processing-model:content-visibility-auto" data-x-internal="content-visibility-auto">'auto'</a> used value of
          <a id="event-loop-processing-model:'content-visibility'" href="https://drafts.csswg.org/css-contain/#content-visibility" data-x-internal="'content-visibility'">'content-visibility'</a>:</p>

          <ol><li><p>Let <var>checkForInitialDetermination</var> be true if <var>element</var>'s
           <a id="event-loop-processing-model:proximity-to-the-viewport" href="https://drafts.csswg.org/css-contain/#proximity-to-the-viewport" data-x-internal="proximity-to-the-viewport">proximity to the viewport</a> is not determined and it is not <a id="event-loop-processing-model:relevant-to-the-user" href="https://drafts.csswg.org/css-contain/#relevant-to-the-user" data-x-internal="relevant-to-the-user">relevant to
           the user</a>. Otherwise, let <var>checkForInitialDetermination</var> be
           false.</p></li><li><p>Determine <a id="event-loop-processing-model:proximity-to-the-viewport-2" href="https://drafts.csswg.org/css-contain/#proximity-to-the-viewport" data-x-internal="proximity-to-the-viewport">proximity to the viewport</a> for <var>element</var>.</p></li><li><p>If <var>checkForInitialDetermination</var> is true and <var>element</var> is now
           <a id="event-loop-processing-model:relevant-to-the-user-2" href="https://drafts.csswg.org/css-contain/#relevant-to-the-user" data-x-internal="relevant-to-the-user">relevant to the user</a>, then set
           <var>hadInitialVisibleContentVisibilityDetermination</var> to true.</p></li></ol>
         </li><li>
          <p>If <var>hadInitialVisibleContentVisibilityDetermination</var> is true, then
          <a id="event-loop-processing-model:continue-3" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p>

          <p class="note">The intent of this step is for the initial viewport proximity
          determination, which takes effect immediately, to be reflected in the style and layout
          calculation which is carried out in a previous step of this loop. Proximity
          determinations other than the initial one take effect at the next <a href="#rendering-opportunity" id="event-loop-processing-model:rendering-opportunity-5">rendering
          opportunity</a>. <a href="#refsCSSCONTAIN">[CSSCONTAIN]</a></p>
         </li><li><p><a id="event-loop-processing-model:gather-active-resize-observations-at-depth" href="https://drafts.csswg.org/resize-observer-1/#gather-active-observations-h" data-x-internal="gather-active-resize-observations-at-depth">Gather active resize observations at depth</a>
         <var>resizeObserverDepth</var> for <var>doc</var>.</p></li><li><p>If <var>doc</var> <a id="event-loop-processing-model:has-active-resize-observations" href="https://drafts.csswg.org/resize-observer-1/#has-active-observations-h" data-x-internal="has-active-resize-observations">has active resize observations</a>:</p>

          <ol><li><p>Set <var>resizeObserverDepth</var> to the result of <a href="https://drafts.csswg.org/resize-observer-1/#broadcast-resize-notifications-h" id="event-loop-processing-model:broadcast-active-resize-observations" data-x-internal="broadcast-active-resize-observations">broadcasting active resize observations</a> given
           <var>doc</var>.</p></li><li><a id="event-loop-processing-model:continue-4" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">Continue</a>.</li></ol>
         </li><li>Otherwise, <a id="event-loop-processing-model:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</li></ol>
       </li><li><p>If <var>doc</var> <a id="event-loop-processing-model:has-skipped-resize-observations" href="https://drafts.csswg.org/resize-observer-1/#has-skipped-observations-h" data-x-internal="has-skipped-resize-observations">has skipped resize observations</a>, then <a id="event-loop-processing-model:deliver-resize-loop-error" href="https://drafts.csswg.org/resize-observer-1/#deliver-resize-error" data-x-internal="deliver-resize-loop-error">deliver
       resize loop error</a> given <var>doc</var>.</p></li></ol>
     </li><li id="focus-fixup-rule">
      <p>For each <var>doc</var> of <var>docs</var>, if the <a href="#focused-area-of-the-document" id="event-loop-processing-model:focused-area-of-the-document">focused area</a> of <var>doc</var> is not a <a href="#focusable-area" id="event-loop-processing-model:focusable-area">focusable area</a>, then
      run the <a href="#focusing-steps" id="event-loop-processing-model:focusing-steps">focusing steps</a> for <var>doc</var>'s <a id="event-loop-processing-model:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>, and set
      <var>doc</var>'s <a href="#concept-relevant-global" id="event-loop-processing-model:concept-relevant-global-3">relevant global object</a>'s <a href="#window-navigation-api" id="event-loop-processing-model:window-navigation-api">navigation API</a>'s <a href="#focus-changed-during-ongoing-navigation" id="event-loop-processing-model:focus-changed-during-ongoing-navigation">focus changed during ongoing
      navigation</a> to false.</p>

      <p class="example">For example, this might happen because an element has the <code id="event-loop-processing-model:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute added, causing it to stop <a href="#being-rendered" id="event-loop-processing-model:being-rendered">being
      rendered</a>. It might also happen to an <code id="event-loop-processing-model:the-input-element"><a href="#the-input-element">input</a></code> element when the element gets
      <a href="#concept-fe-disabled" id="event-loop-processing-model:concept-fe-disabled">disabled</a>.</p>

      <p class="note">This will <a href="#note-sometimes-no-blur-event">usually</a> fire <code id="event-loop-processing-model:event-blur"><a href="#event-blur">blur</a></code> events, and possibly <code id="event-loop-processing-model:event-change"><a href="#event-change">change</a></code> events.</p>

      <p class="note">In addition to this asynchronous fixup, if the <a href="#focused-area-of-the-document" id="event-loop-processing-model:focused-area-of-the-document-2">focused area of the
      document</a> is removed, there is a <a href="#node-remove-focus-fixup">synchronous
      fixup</a>. That one will <em>not</em> fire <code id="event-loop-processing-model:event-blur-2"><a href="#event-blur">blur</a></code> or <code id="event-loop-processing-model:event-change-2"><a href="#event-change">change</a></code> events.</p>
     </li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:perform-pending-transition-operations" href="https://drafts.csswg.org/css-view-transitions/#perform-pending-transition-operations" data-x-internal="perform-pending-transition-operations">perform pending transition
     operations</a> for <var>doc</var>. <a href="#refsCSSVIEWTRANSITIONS">[CSSVIEWTRANSITIONS]</a></p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:run-the-update-intersection-observations-steps" href="https://w3c.github.io/IntersectionObserver/#run-the-update-intersection-observations-steps" data-x-internal="run-the-update-intersection-observations-steps">run the update intersection
     observations steps</a> for <var>doc</var>, passing in the <a id="event-loop-processing-model:relative-high-resolution-time-3" href="https://w3c.github.io/hr-time/#dfn-relative-high-resolution-time" data-x-internal="relative-high-resolution-time">relative high resolution
     time</a> given <var>now</var> and <var>doc</var>'s <a href="#concept-relevant-global" id="event-loop-processing-model:concept-relevant-global-4">relevant global object</a> as
     the timestamp. <a href="#refsINTERSECTIONOBSERVER">[INTERSECTIONOBSERVER]</a></p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:record-rendering-time" href="https://w3c.github.io/long-animation-frames/#record-rendering-time" data-x-internal="record-rendering-time">record rendering time</a> for
     <var>doc</var> given <var>unsafeStyleAndLayoutStartTime</var>.</p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:mark-paint-timing" href="https://w3c.github.io/paint-timing/#mark-paint-timing" data-x-internal="mark-paint-timing">mark paint timing</a> for
     <var>doc</var>.</p></li><li><p>For each <var>doc</var> of <var>docs</var>, update the rendering or user interface of
     <var>doc</var> and its <a href="#node-navigable" id="event-loop-processing-model:node-navigable-4">node navigable</a> to reflect the current state.</p></li><li><p>For each <var>doc</var> of <var>docs</var>, <a id="event-loop-processing-model:process-top-layer-removals" href="https://drafts.csswg.org/css-position-4/#process-top-layer-removals" data-x-internal="process-top-layer-removals">process top layer removals</a>
     given <var>doc</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>A <a href="#navigable" id="event-loop-processing-model:navigable-2">navigable</a> has a <dfn id="rendering-opportunity" data-export="">rendering opportunity</dfn> if the user agent is
  currently able to present the contents of the <a href="#navigable" id="event-loop-processing-model:navigable-3">navigable</a> to the user, accounting for
  hardware refresh rate constraints and user agent throttling for performance reasons, but
  considering content presentable even if it's outside the viewport.</p>
  </div>

  <p>A <a href="#navigable" id="event-loop-processing-model:navigable-4">navigable</a>'s <a href="#rendering-opportunity" id="event-loop-processing-model:rendering-opportunity-6">rendering opportunities</a>
  are determined based on hardware constraints such as display refresh rates and other factors such
  as page performance or whether its <a href="#nav-document" id="event-loop-processing-model:nav-document-2">active document</a>'s
  <a href="#visibility-state" id="event-loop-processing-model:visibility-state-2">visibility state</a> is "<code>visible</code>". Rendering opportunities
  typically occur at regular intervals.</p>

  <p class="note">This specification does not mandate any particular model for selecting rendering
  opportunities. But for example, if the browser is attempting to achieve a 60Hz refresh rate, then
  rendering opportunities occur at a maximum of every 60th of a second (about 16.7ms). If the
  browser finds that a <a href="#navigable" id="event-loop-processing-model:navigable-5">navigable</a> is not able to sustain this rate, it might drop to a
  more sustainable 30 rendering opportunities per second for that <a href="#navigable" id="event-loop-processing-model:navigable-6">navigable</a>, rather
  than occasionally dropping frames. Similarly, if a <a href="#navigable" id="event-loop-processing-model:navigable-7">navigable</a> is not visible, the
  user agent might decide to drop that page to a much slower 4 rendering opportunities per second,
  or even less.</p>


  <hr>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="perform-a-microtask-checkpoint" data-export="">perform a microtask checkpoint</dfn>:</p>

  <ol><li><p>If the <a href="#event-loop" id="event-loop-processing-model:event-loop-15">event loop</a>'s <a href="#performing-a-microtask-checkpoint" id="event-loop-processing-model:performing-a-microtask-checkpoint">performing a microtask checkpoint</a> is true,
   then return.</p></li><li><p>Set the <a href="#event-loop" id="event-loop-processing-model:event-loop-16">event loop</a>'s <a href="#performing-a-microtask-checkpoint" id="event-loop-processing-model:performing-a-microtask-checkpoint-2">performing a microtask checkpoint</a> to
   true.</p></li><li>
    <p>While the <a href="#event-loop" id="event-loop-processing-model:event-loop-17">event loop</a>'s <a href="#microtask-queue" id="event-loop-processing-model:microtask-queue-2">microtask queue</a> is not <a href="https://infra.spec.whatwg.org/#list-is-empty" id="event-loop-processing-model:list-is-empty" data-x-internal="list-is-empty">empty</a>:</p>

    <ol><li><p>Let <var>oldestMicrotask</var> be the result of <a href="https://infra.spec.whatwg.org/#queue-dequeue" id="event-loop-processing-model:dequeue" data-x-internal="dequeue">dequeuing</a>
     from the <a href="#event-loop" id="event-loop-processing-model:event-loop-18">event loop</a>'s <a href="#microtask-queue" id="event-loop-processing-model:microtask-queue-3">microtask queue</a>.</p></li><li><p>Set the <a href="#event-loop" id="event-loop-processing-model:event-loop-19">event loop</a>'s <a href="#currently-running-task" id="event-loop-processing-model:currently-running-task-3">currently running task</a> to
     <var>oldestMicrotask</var>.</p></li><li>
      <p>Run <var>oldestMicrotask</var>.</p>

      <p class="note">This might involve invoking scripted callbacks, which eventually calls the
      <a href="#clean-up-after-running-script" id="event-loop-processing-model:clean-up-after-running-script">clean up after running script</a> steps, which call this <a href="#perform-a-microtask-checkpoint" id="event-loop-processing-model:perform-a-microtask-checkpoint-3">perform a microtask
      checkpoint</a> algorithm again, which is why we use the <a href="#performing-a-microtask-checkpoint" id="event-loop-processing-model:performing-a-microtask-checkpoint-3">performing a microtask
      checkpoint</a> flag to avoid reentrancy.</p>
     </li><li><p>Set the <a href="#event-loop" id="event-loop-processing-model:event-loop-20">event loop</a>'s <a href="#currently-running-task" id="event-loop-processing-model:currently-running-task-4">currently running task</a> back to
     null.</p></li></ol>
   </li><li><p>For each <a href="#environment-settings-object" id="event-loop-processing-model:environment-settings-object-2">environment settings object</a> <var>settingsObject</var> whose
   <a href="#responsible-event-loop" id="event-loop-processing-model:responsible-event-loop">responsible event loop</a> is this <a href="#event-loop" id="event-loop-processing-model:event-loop-21">event loop</a>, <a href="#notify-about-rejected-promises" id="event-loop-processing-model:notify-about-rejected-promises">notify about rejected
   promises</a> given <var>settingsObject</var>'s <a href="#concept-settings-object-global" id="event-loop-processing-model:concept-settings-object-global-2">global object</a>.</p></li><li><p><a id="event-loop-processing-model:cleanup-indexed-database-transactions" href="https://w3c.github.io/IndexedDB/#cleanup-indexed-database-transactions" data-x-internal="cleanup-indexed-database-transactions">Cleanup Indexed Database transactions</a>.</p></li><li>
    <p>Perform <a id="event-loop-processing-model:clearkeptobjects" href="https://tc39.es/ecma262/#sec-clear-kept-objects" data-x-internal="clearkeptobjects">ClearKeptObjects</a>().</p>

    <p class="note">When <code id="event-loop-processing-model:weakref.prototype.deref()"><a data-x-internal="weakref.prototype.deref()" href="https://tc39.es/ecma262/#sec-weak-ref.prototype.deref">WeakRef.prototype.deref()</a></code> returns an object, that object is
    kept alive until the next invocation of <a id="event-loop-processing-model:clearkeptobjects-2" href="https://tc39.es/ecma262/#sec-clear-kept-objects" data-x-internal="clearkeptobjects">ClearKeptObjects</a>(), after which it is again
    subject to garbage collection.</p>
   </li><li><p>Set the <a href="#event-loop" id="event-loop-processing-model:event-loop-22">event loop</a>'s <a href="#performing-a-microtask-checkpoint" id="event-loop-processing-model:performing-a-microtask-checkpoint-4">performing a microtask checkpoint</a> to
   false.</p></li><li><p><a id="event-loop-processing-model:record-timing-info-for-microtask-checkpoint" href="https://w3c.github.io/long-animation-frames/#record-timing-info-for-microtask-checkpoint" data-x-internal="record-timing-info-for-microtask-checkpoint">Record timing info for microtask checkpoint</a>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>When an algorithm running <a href="#in-parallel" id="event-loop-processing-model:in-parallel-3">in parallel</a> is to <dfn id="await-a-stable-state">await a stable state</dfn>, the
  user agent must <a href="#queue-a-microtask" id="event-loop-processing-model:queue-a-microtask">queue a microtask</a> that runs the following steps, and must then stop
  executing (execution of the algorithm resumes when the microtask is run, as described in the
  following steps):</p>

  <ol><li><p>Run the algorithm's <dfn id="synchronous-section">synchronous section</dfn>.</p></li><li><p>Resume execution of the algorithm <a href="#in-parallel" id="event-loop-processing-model:in-parallel-4">in parallel</a>, if appropriate, as described
   in the algorithm's steps.</p></li></ol>
  </div>

  <p class="note">Steps in <a href="#synchronous-section" id="event-loop-processing-model:synchronous-section">synchronous sections</a> are marked
  with ⌛.</p>

  <hr>

  <div data-algorithm="">
  <p>Algorithm steps that say to <dfn id="spin-the-event-loop">spin the event loop</dfn> until a condition <var>goal</var> is
  met are equivalent to substituting in the following algorithm steps:</p>

  <ol><li>
    <p>Let <var>task</var> be the <a href="#event-loop" id="event-loop-processing-model:event-loop-23">event loop</a>'s <a href="#currently-running-task" id="event-loop-processing-model:currently-running-task-5">currently running
    task</a>.</p>

    <p class="note"><var>task</var> could be a <a href="#microtask" id="event-loop-processing-model:microtask-2">microtask</a>.</p>
   </li><li><p>Let <var>task source</var> be <var>task</var>'s <a href="#concept-task-source" id="event-loop-processing-model:concept-task-source">source</a>.</p></li><li><p>Let <var>old stack</var> be a copy of the <a id="event-loop-processing-model:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context
   stack</a>.</p></li><li><p>Empty the <a id="event-loop-processing-model:javascript-execution-context-stack-2" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a>.</p></li><li>
    <p><a href="#perform-a-microtask-checkpoint" id="event-loop-processing-model:perform-a-microtask-checkpoint-4">Perform a microtask checkpoint</a>.</p>

    <p class="note">If <var>task</var> is a <a href="#microtask" id="event-loop-processing-model:microtask-3">microtask</a> this step will be a no-op due to
    <a href="#performing-a-microtask-checkpoint" id="event-loop-processing-model:performing-a-microtask-checkpoint-5">performing a microtask checkpoint</a> being true.</p>
   </li><li>
    <p><a href="#in-parallel" id="event-loop-processing-model:in-parallel-5">In parallel</a>:</p>

    <ol><li><p>Wait until the condition <var>goal</var> is met.</p></li><li>
      <p><a href="#queue-a-task" id="event-loop-processing-model:queue-a-task">Queue a task</a> on <var>task source</var> to:</p>

      <ol><li><p>Replace the <a id="event-loop-processing-model:javascript-execution-context-stack-3" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> with <var>old
       stack</var>.</p></li><li>
        <p>Perform any steps that appear after this <a href="#spin-the-event-loop" id="event-loop-processing-model:spin-the-event-loop-2">spin the event loop</a> instance in the
        original algorithm.</p>

        <p class="note">This resumes <var>task</var>.</p>
       </li></ol>
     </li></ol>
   </li><li>
    <p>Stop <var>task</var>, allowing whatever algorithm that invoked it to resume.</p>

    <p class="note">This causes the <a href="#event-loop" id="event-loop-processing-model:event-loop-24">event loop</a>'s main set of steps or the <a href="#perform-a-microtask-checkpoint" id="event-loop-processing-model:perform-a-microtask-checkpoint-5">perform
    a microtask checkpoint</a> algorithm to continue.</p>
   </li></ol>
  </div>

  <p class="note">Unlike other algorithms in this and other specifications, which behave similar to
  programming-language function calls, <a href="#spin-the-event-loop" id="event-loop-processing-model:spin-the-event-loop-3">spin the event loop</a> is more like a macro, which
  saves typing and indentation at the usage site by expanding into a series of steps and
  operations.</p>

  <div class="example">
   <p>An algorithm whose steps are:</p>

   <div data-algorithm="">
   <ol><li><p>Do something.</p></li><li><p><a href="#spin-the-event-loop" id="event-loop-processing-model:spin-the-event-loop-4">Spin the event loop</a> until awesomeness happens.</p></li><li><p>Do something else.</p></li></ol>
   </div>

   <p>is a shorthand which, after "macro expansion", becomes</p>

   <div data-algorithm="">
   <ol><li><p>Do something.</p></li><li><p>Let <var>old stack</var> be a copy of the <a id="event-loop-processing-model:javascript-execution-context-stack-4" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context
    stack</a>.</p></li><li><p>Empty the <a id="event-loop-processing-model:javascript-execution-context-stack-5" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a>.</p></li><li><p><a href="#perform-a-microtask-checkpoint" id="event-loop-processing-model:perform-a-microtask-checkpoint-6">Perform a microtask checkpoint</a>.</p></li><li>
     <p><a href="#in-parallel" id="event-loop-processing-model:in-parallel-6">In parallel</a>:</p>

     <ol><li><p>Wait until awesomeness happens.</p></li><li>
       <p><a href="#queue-a-task" id="event-loop-processing-model:queue-a-task-2">Queue a task</a> on the task source in which "do something" was done to:</p>

       <ol><li><p>Replace the <a id="event-loop-processing-model:javascript-execution-context-stack-6" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> with <var>old
        stack</var>.</p></li><li><p>Do something else.</p></li></ol>
      </li></ol>
    </li></ol>
   </div>
  </div>

  <div class="example">
   <p>Here is a more full example of the substitution, where the event loop is spun from inside a
   task that is queued from work in parallel. The version using <a href="#spin-the-event-loop" id="event-loop-processing-model:spin-the-event-loop-5">spin the event loop</a>:</p>

   <div data-algorithm="">
   <ol><li>
     <p><a href="#in-parallel" id="event-loop-processing-model:in-parallel-7">In parallel</a>:</p>

     <ol><li><p>Do parallel thing 1.</p></li><li>
       <p><a href="#queue-a-task" id="event-loop-processing-model:queue-a-task-3">Queue a task</a> on the <a href="#dom-manipulation-task-source" id="event-loop-processing-model:dom-manipulation-task-source">DOM manipulation task source</a> to:</p>

       <ol><li><p>Do task thing 1.</p></li><li><p><a href="#spin-the-event-loop" id="event-loop-processing-model:spin-the-event-loop-6">Spin the event loop</a> until awesomeness happens.</p></li><li><p>Do task thing 2.</p></li></ol>
      </li><li><p>Do parallel thing 2.</p></li></ol>
    </li></ol>
   </div>

   <p>The fully expanded version:</p>

   <div data-algorithm="">
   <ol><li>
     <p><a href="#in-parallel" id="event-loop-processing-model:in-parallel-8">In parallel</a>:</p>

     <ol><li><p>Do parallel thing 1.</p></li><li><p>Let <var>old stack</var> be null.</p></li><li>
       <p><a href="#queue-a-task" id="event-loop-processing-model:queue-a-task-4">Queue a task</a> on the <a href="#dom-manipulation-task-source" id="event-loop-processing-model:dom-manipulation-task-source-2">DOM manipulation task source</a> to:</p>

       <ol><li><p>Do task thing 1.</p></li><li><p>Set <var>old stack</var> to a copy of the <a id="event-loop-processing-model:javascript-execution-context-stack-7" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context
        stack</a>.</p></li><li><p>Empty the <a id="event-loop-processing-model:javascript-execution-context-stack-8" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a>.</p></li><li><p><a href="#perform-a-microtask-checkpoint" id="event-loop-processing-model:perform-a-microtask-checkpoint-7">Perform a microtask checkpoint</a>.</p></li></ol>
      </li><li><p>Wait until awesomeness happens.</p></li><li>
       <p><a href="#queue-a-task" id="event-loop-processing-model:queue-a-task-5">Queue a task</a> on the <a href="#dom-manipulation-task-source" id="event-loop-processing-model:dom-manipulation-task-source-3">DOM manipulation task source</a> to:</p>

       <ol><li><p>Replace the <a id="event-loop-processing-model:javascript-execution-context-stack-9" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> with <var>old
        stack</var>.</p></li><li><p>Do task thing 2.</p></li></ol>
      </li><li><p>Do parallel thing 2.</p></li></ol>
    </li></ol>
   </div>
  </div>

  <hr>

  <div data-algorithm="">
  <p>Some of the algorithms in this specification, for historical reasons, require the user agent to
  <dfn id="pause" data-export="">pause</dfn> while running a <a href="#concept-task" id="event-loop-processing-model:concept-task-7">task</a> until a condition
  <var>goal</var> is met. This means running the following steps:</p>

  <ol><li><p>Let <var>global</var> be the <a href="#current-global-object" id="event-loop-processing-model:current-global-object">current global object</a>.</p></li><li><p>Let <var>timeBeforePause</var> be the <a id="event-loop-processing-model:current-high-resolution-time-2" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given
   <var>global</var>.</p></li><li><p>If necessary, update the rendering or user interface of any <code id="event-loop-processing-model:document-7"><a href="#document">Document</a></code> or
   <a href="#navigable" id="event-loop-processing-model:navigable-8">navigable</a> to reflect the current state.</p></li><li><p>Wait until the condition <var>goal</var> is met. While a user agent has a paused
   <a href="#concept-task" id="event-loop-processing-model:concept-task-8">task</a>, the corresponding <a href="#event-loop" id="event-loop-processing-model:event-loop-25">event loop</a> must not run
   further <a href="#concept-task" id="event-loop-processing-model:concept-task-9">tasks</a>, and any script in the currently running <a href="#concept-task" id="event-loop-processing-model:concept-task-10">task</a> must block. User agents should remain responsive to user input
   while paused, however, albeit in a reduced capacity since the <a href="#event-loop" id="event-loop-processing-model:event-loop-26">event loop</a> will not be
   doing anything.</p></li><li><p><a id="event-loop-processing-model:record-pause-duration" href="https://w3c.github.io/long-animation-frames/#record-pause-duration" data-x-internal="record-pause-duration">Record pause duration</a> given the <a id="event-loop-processing-model:duration-from" href="https://w3c.github.io/hr-time/#dfn-duration-from" data-x-internal="duration-from">duration from</a>
   <var>timeBeforePause</var> to the <a id="event-loop-processing-model:current-high-resolution-time-3" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given
   <var>global</var>.</p></li></ol>
  </div>

  <div class="warning">
   <p><a href="#pause" id="event-loop-processing-model:pause">Pausing</a> is highly detrimental to the user experience, especially
   in scenarios where a single <a href="#event-loop" id="event-loop-processing-model:event-loop-27">event loop</a> is shared among multiple documents. User
   agents are encouraged to experiment with alternatives to <a href="#pause" id="event-loop-processing-model:pause-2">pausing</a>,
   such as <a href="#spin-the-event-loop" id="event-loop-processing-model:spin-the-event-loop-7">spinning the event loop</a> or even simply
   proceeding without any kind of suspended execution at all, insofar as it is possible to do so
   while preserving compatibility with existing content. This specification will happily change if
   a less-drastic alternative is discovered to be web-compatible.</p>

   <p>In the interim, implementers should be aware that the variety of alternatives that user agents
   might experiment with can change subtle aspects of <a href="#event-loop" id="event-loop-processing-model:event-loop-28">event loop</a> behavior, including
   <a href="#concept-task" id="event-loop-processing-model:concept-task-11">task</a> and <a href="#microtask" id="event-loop-processing-model:microtask-4">microtask</a> timing. Implementations should
   continue experimenting even if doing so causes them to violate the exact semantics implied by the
   <a href="#pause" id="event-loop-processing-model:pause-3">pause</a> operation.</p>
  </div>

  <h5 id="generic-task-sources"><span class="secno">8.1.7.4</span> Generic task sources<a href="#generic-task-sources" class="self-link"></a></h5>

  <p>The following <a href="#task-source" id="generic-task-sources:task-source">task sources</a> are used by a number of mostly
  unrelated features in this and other specifications.</p>

  <dl><dt>The <dfn id="dom-manipulation-task-source" data-export="">DOM manipulation task source</dfn></dt><dd>
    <p>This <a href="#task-source" id="generic-task-sources:task-source-2">task source</a> is used for features that react to DOM manipulations, such as
    things that happen in a non-blocking fashion when an element is <a href="#insert-an-element-into-a-document" id="generic-task-sources:insert-an-element-into-a-document">inserted into the document</a>.</p>
   </dd><dt>The <dfn id="user-interaction-task-source" data-export="">user interaction task source</dfn></dt><dd>
    <p>This <a href="#task-source" id="generic-task-sources:task-source-3">task source</a> is used for features that react to user interaction, for
    example keyboard or mouse input.</p>

    <p>Events sent in response to user input (e.g., <code id="generic-task-sources:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> events)
    must be fired using <a href="#concept-task" id="generic-task-sources:concept-task">tasks</a> <a href="#queue-a-task" id="generic-task-sources:queue-a-task">queued</a> with the <a href="#user-interaction-task-source" id="generic-task-sources:user-interaction-task-source">user interaction task source</a>. <a href="#refsUIEVENTS">[UIEVENTS]</a></p>
    
   </dd><dt>The <dfn id="networking-task-source" data-export="">networking task source</dfn></dt><dd>
    <p>This <a href="#task-source" id="generic-task-sources:task-source-4">task source</a> is used for features that trigger in response to network
    activity.</p>
   </dd><dt id="history-traversal-task-source">The <dfn id="navigation-and-traversal-task-source">navigation and traversal task source</dfn></dt><dd>
    <p>This <a href="#task-source" id="generic-task-sources:task-source-5">task source</a> is used to queue tasks involved in <a href="#navigate" id="generic-task-sources:navigate">navigation</a> and <a href="#apply-the-traverse-history-step" id="generic-task-sources:apply-the-traverse-history-step">history
    traversal</a>.</p>
   </dd><dt>The <dfn id="rendering-task-source">rendering task source</dfn></dt><dd>
    <p>This <a href="#task-source" id="generic-task-sources:task-source-6">task source</a> is used solely to <a href="#update-the-rendering" id="generic-task-sources:update-the-rendering">update the rendering</a>.</p>
   </dd></dl>

  <h5 id="event-loop-for-spec-authors"><span class="secno">8.1.7.5</span> Dealing with the event loop from other specifications<a href="#event-loop-for-spec-authors" class="self-link"></a></h5>

  <p>Writing specifications that correctly interact with the <a href="#event-loop" id="event-loop-for-spec-authors:event-loop">event loop</a> can be tricky.
  This is compounded by how this specification uses concurrency-model-independent terminology, so we
  say things like "<a href="#event-loop" id="event-loop-for-spec-authors:event-loop-2">event loop</a>" and "<a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel">in parallel</a>" instead of using more
  familiar model-specific terms like "main thread" or "on a background thread".</p>

  <p>By default, specification text generally runs on the <a href="#event-loop" id="event-loop-for-spec-authors:event-loop-3">event loop</a>. This falls out
  from the formal <a href="#event-loop-processing-model">event loop processing model</a>, in that
  you can eventually trace most algorithms back to a <a href="#concept-task" id="event-loop-for-spec-authors:concept-task">task</a> <a href="#queue-a-task" id="event-loop-for-spec-authors:queue-a-task">queued</a> there.</p>

  <p class="example">The algorithm steps for any JavaScript method will be invoked by author code
  calling that method. And author code can only be run via queued tasks, usually originating
  somewhere in the <a href="#script-processing-model"><code>script</code> processing model</a>.</p>

  <p>From this starting point, the overriding guideline is that any work a specification needs to
  perform that would otherwise block the <a href="#event-loop" id="event-loop-for-spec-authors:event-loop-4">event loop</a> must instead be performed <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-2">in
  parallel</a> with it. This includes (but is not limited to):</p>

  <ul><li><p>performing heavy computation;</p></li><li><p>displaying a user-facing prompt;</p></li><li><p>performing operations which could require involving outside systems (i.e. "going out of
   process").</p></li></ul>

  <p>The next complication is that, in algorithm sections that are <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-3">in parallel</a>, you
  must not create or manipulate objects associated to a specific <a id="event-loop-for-spec-authors:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>, <a href="#global-object" id="event-loop-for-spec-authors:global-object">global</a>, or <a href="#environment-settings-object" id="event-loop-for-spec-authors:environment-settings-object">environment settings object</a>. (Stated in more
  familiar terms, you must not directly access main-thread artifacts from a background thread.)
  Doing so would create data races observable to JavaScript code, since after all, your algorithm
  steps are running <em><a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-4">in parallel</a></em> to the JavaScript code.</p>

  <p>By extension, you cannot access Web IDL's <a id="event-loop-for-spec-authors:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> value from steps running <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-5">in
  parallel</a>, even if those steps were activated by an algorithm that <em>does</em> have access
  to the <a id="event-loop-for-spec-authors:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> value.</p>

  <p>You can, however, manipulate specification-level data structures and values from
  <cite>Infra</cite>, as those are realm-agnostic. They are never directly exposed to JavaScript without
  a specific conversion taking place (often <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="event-loop-for-spec-authors:concept-idl-convert" data-x-internal="concept-idl-convert">via Web IDL</a>).
  <a href="#refsINFRA">[INFRA]</a> <a href="#refsWEBIDL">[WEBIDL]</a></p>

  <p>To affect the world of observable JavaScript objects, then, you must <a href="#queue-a-global-task" id="event-loop-for-spec-authors:queue-a-global-task">queue a global
  task</a> to perform any such manipulations. This ensures your steps are properly interleaved
  with respect to other things happening on the <a href="#event-loop" id="event-loop-for-spec-authors:event-loop-5">event loop</a>. Furthermore, you must
  choose a <a href="#task-source" id="event-loop-for-spec-authors:task-source">task source</a> when <a href="#queue-a-global-task" id="event-loop-for-spec-authors:queue-a-global-task-2">queuing a global
  task</a>; this governs the relative order of your steps versus others. If you are unsure which
  <a href="#task-source" id="event-loop-for-spec-authors:task-source-2">task source</a> to use, pick one of the <a href="#generic-task-sources">generic task
  sources</a> that sounds most applicable. Finally, you must indicate which <a href="#global-object" id="event-loop-for-spec-authors:global-object-2">global
  object</a> your queued task is associated with; this ensures that if that global object is
  inactive, the task does not run.</p>

  <p class="note">The base primitive, on which <a href="#queue-a-global-task" id="event-loop-for-spec-authors:queue-a-global-task-3">queue a global task</a> builds, is the
  <a href="#queue-a-task" id="event-loop-for-spec-authors:queue-a-task-2">queue a task</a> algorithm. In general, <a href="#queue-a-global-task" id="event-loop-for-spec-authors:queue-a-global-task-4">queue a global task</a> is better
  because it automatically picks the right <a href="#event-loop" id="event-loop-for-spec-authors:event-loop-6">event loop</a> and, where appropriate, <a href="#concept-task-document" id="event-loop-for-spec-authors:concept-task-document">document</a>. Older specifications often use <a href="#queue-a-task" id="event-loop-for-spec-authors:queue-a-task-3">queue a
  task</a> combined with the <a href="#implied-event-loop" id="event-loop-for-spec-authors:implied-event-loop">implied event loop</a> and <a href="#implied-document" id="event-loop-for-spec-authors:implied-document">implied document</a>
  concepts, but this is discouraged.</p>

  <div data-algorithm="">
  <p>Putting this all together, we can provide a template for a typical algorithm that needs to do
  work asynchronously:</p>

  <ol><li><p>Do any synchronous setup work, while still on the <a href="#event-loop" id="event-loop-for-spec-authors:event-loop-7">event loop</a>. This may
   include converting <a id="event-loop-for-spec-authors:realm-2" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>-specific JavaScript values into realm-agnostic
   specification-level values.</p></li><li><p>Perform a set of potentially-expensive steps <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-6">in parallel</a>, operating entirely
   on realm-agnostic values, and producing a realm-agnostic result.</p></li><li><p><a href="#queue-a-global-task" id="event-loop-for-spec-authors:queue-a-global-task-5">Queue a global task</a>, on a specified <a href="#task-source" id="event-loop-for-spec-authors:task-source-3">task source</a> and given an
   appropriate <a href="#global-object" id="event-loop-for-spec-authors:global-object-3">global object</a>, to convert the realm-agnostic result back into observable
   effects on the observable world of JavaScript objects on the <a href="#event-loop" id="event-loop-for-spec-authors:event-loop-8">event loop</a>.</p></li></ol>
  </div>

  <div id="example-event-loop-using-algorithm" class="example"><a href="#example-event-loop-using-algorithm" class="self-link"></a>

   <div data-algorithm="">
   <p>The following is an algorithm that "encrypts" a passed-in <a id="event-loop-for-spec-authors:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="https://infra.spec.whatwg.org/#scalar-value-string" id="event-loop-for-spec-authors:scalar-value-string" data-x-internal="scalar-value-string">scalar value strings</a> <var>input</var>, after parsing them as
   URLs:</p>

   <ol><li><p>Let <var>urls</var> be an empty <a id="event-loop-for-spec-authors:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
     <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="event-loop-for-spec-authors:list-iterate" data-x-internal="list-iterate">For each</a> <var>string</var> of <var>input</var>:</p>

     <ol><li><p>Let <var>parsed</var> be the result of <a href="#encoding-parsing-a-url" id="event-loop-for-spec-authors:encoding-parsing-a-url">encoding-parsing a URL</a> given
      <var>string</var>, relative to the <a href="#current-settings-object" id="event-loop-for-spec-authors:current-settings-object">current settings object</a>.</p></li><li><p>If <var>parsed</var> is failure, then return <a id="event-loop-for-spec-authors:a-promise-rejected-with" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> a
      <a id="event-loop-for-spec-authors:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="event-loop-for-spec-authors:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>serialized</var> be the result of applying the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="event-loop-for-spec-authors:concept-url-serializer" data-x-internal="concept-url-serializer">URL serializer</a> to <var>parsed</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="event-loop-for-spec-authors:list-append" data-x-internal="list-append">Append</a> <var>serialized</var> to <var>urls</var>.</p></li></ol>
    </li><li><p>Let <var>realm</var> be the <a id="event-loop-for-spec-authors:current-realm" href="https://tc39.es/ecma262/#current-realm" data-x-internal="current-realm">current realm</a>.</p></li><li><p>Let <var>p</var> be a new promise.</p></li><li>
     <p>Run the following steps <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-7">in parallel</a>:</p>

     <ol><li><p>Let <var>encryptedURLs</var> be an empty <a id="event-loop-for-spec-authors:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li>
       <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="event-loop-for-spec-authors:list-iterate-2" data-x-internal="list-iterate">For each</a> <var>url</var> of <var>urls</var>:</p>

       <ol><li><p>Wait 100 milliseconds, so that people think we're doing heavy-duty encryption.</p></li><li><p>Let <var>encrypted</var> be a new <a id="event-loop-for-spec-authors:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> derived from <var>url</var>,
        whose <var>n</var>th <a id="event-loop-for-spec-authors:code-unit" href="https://infra.spec.whatwg.org/#code-unit" data-x-internal="code-unit">code unit</a> is equal to <var>url</var>'s <var>n</var>th
        <a id="event-loop-for-spec-authors:code-unit-2" href="https://infra.spec.whatwg.org/#code-unit" data-x-internal="code-unit">code unit</a> plus 13.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="event-loop-for-spec-authors:list-append-2" data-x-internal="list-append">Append</a> <var>encrypted</var> to
        <var>encryptedURLs</var>.</p>
       </li></ol>
      </li><li>
       <p><a href="#queue-a-global-task" id="event-loop-for-spec-authors:queue-a-global-task-6">Queue a global task</a> on the <a href="#networking-task-source" id="event-loop-for-spec-authors:networking-task-source">networking task source</a>, given
       <var>realm</var>'s <a href="#concept-realm-global" id="event-loop-for-spec-authors:concept-realm-global">global object</a>, to perform the
       following steps:</p>

       <ol><li><p>Let <var>array</var> be the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="event-loop-for-spec-authors:concept-idl-convert-2" data-x-internal="concept-idl-convert">converting</a> <var>encryptedURLs</var> to a JavaScript
        array, in <var>realm</var>.</p></li><li><p>Resolve <var>p</var> with <var>array</var>.</p></li></ol>
      </li></ol>
    </li><li><p>Return <var>p</var>.</p></li></ol>
   </div>

   <p>Here are several things to notice about this algorithm:</p>

   <ul><li><p>It does its URL parsing up front, on the <a href="#event-loop" id="event-loop-for-spec-authors:event-loop-9">event loop</a>, before going to the
    <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-8">in parallel</a> steps. This is necessary, since parsing depends on the <a href="#current-settings-object" id="event-loop-for-spec-authors:current-settings-object-2">current
    settings object</a>, which would no longer be current after going <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-9">in
    parallel</a>.</p></li><li><p>Alternately, it could have saved a reference to the <a href="#current-settings-object" id="event-loop-for-spec-authors:current-settings-object-3">current settings
    object</a>'s <a href="#api-base-url" id="event-loop-for-spec-authors:api-base-url">API base URL</a> and used it during the <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-10">in parallel</a> steps;
    that would have been equivalent. However, we recommend instead doing as much work as possible up
    front, as this example does. Attempting to save the correct values can be error prone; for
    example, if we'd saved just the <a href="#current-settings-object" id="event-loop-for-spec-authors:current-settings-object-4">current settings object</a>, instead of its <a href="#api-base-url" id="event-loop-for-spec-authors:api-base-url-2">API
    base URL</a>, there would have been a potential race.</p></li><li><p>It implicitly passes a <a id="event-loop-for-spec-authors:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="https://infra.spec.whatwg.org/#string" id="event-loop-for-spec-authors:string-2" data-x-internal="string">strings</a> from the
    initial steps to the <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-11">in parallel</a> steps. This is OK, as both <a href="https://infra.spec.whatwg.org/#list" id="event-loop-for-spec-authors:list-5" data-x-internal="list">lists</a> and <a href="https://infra.spec.whatwg.org/#string" id="event-loop-for-spec-authors:string-3" data-x-internal="string">strings</a> are
    <a id="event-loop-for-spec-authors:realm-3" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>-agnostic.</p></li><li><p>It performs "expensive computation" (waiting for 100 milliseconds per input URL) during
    the <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-12">in parallel</a> steps, thus not blocking the main <a href="#event-loop" id="event-loop-for-spec-authors:event-loop-10">event loop</a>.</p></li><li><p>Promises, as observable JavaScript objects, are never created and manipulated during the
    <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-13">in parallel</a> steps. <var>p</var> is created before entering those steps, and then is
    manipulated during a <a href="#concept-task" id="event-loop-for-spec-authors:concept-task-2">task</a> that is <a href="#queue-a-global-task" id="event-loop-for-spec-authors:queue-a-global-task-7">queued</a> specifically for that purpose.</p></li><li><p>The creation of a JavaScript array object also happens during the queued task, and is
    careful to specify which realm it creates the array in since that is no longer obvious from
    context.</p></li></ul>

   <p>(On these last two points, see also <a href="https://github.com/whatwg/webidl/issues/135">whatwg/webidl issue #135</a> and <a href="https://github.com/whatwg/webidl/issues/371">whatwg/webidl issue #371</a>, where we are
   still mulling over the subtleties of the above promise-resolution pattern.)</p>

   <p>Another thing to note is that, in the event this algorithm was called from a Web IDL-specified
   operation taking a <code>sequence</code>&lt;<code id="event-loop-for-spec-authors:idl-usvstring"><a data-x-internal="idl-usvstring" href="https://webidl.spec.whatwg.org/#idl-USVString">USVString</a></code>&gt;, there was an automatic conversion from
   <a id="event-loop-for-spec-authors:realm-4" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>-specific JavaScript objects provided by the author as input, into the
   realm-agnostic <code>sequence</code>&lt;<code id="event-loop-for-spec-authors:idl-usvstring-2"><a data-x-internal="idl-usvstring" href="https://webidl.spec.whatwg.org/#idl-USVString">USVString</a></code>&gt;
   Web IDL type, which we then treat as a <a id="event-loop-for-spec-authors:list-6" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="https://infra.spec.whatwg.org/#scalar-value-string" id="event-loop-for-spec-authors:scalar-value-string-2" data-x-internal="scalar-value-string">scalar value strings</a>. So depending on how your specification is structured, there
   may be other implicit steps happening on the main <a href="#event-loop" id="event-loop-for-spec-authors:event-loop-11">event loop</a> that play a part in
   this whole process of getting you ready to go <a href="#in-parallel" id="event-loop-for-spec-authors:in-parallel-14">in parallel</a>.</p>

  </div>


  

  <h4 id="events"><span class="secno">8.1.8</span> Events<a href="#events" class="self-link"></a></h4>

  <h5 id="event-handler-attributes"><span class="secno">8.1.8.1</span> Event handlers<a href="#event-handler-attributes" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers" title="Events are signals fired inside the browser window that notify of changes in the browser or operating system environment. Programmers can create event handler code that will run when an event fires, allowing web pages to respond appropriately to change.">Events/Event_handlers</a></p></div></div>

  <p>Many objects can have <dfn id="event-handlers" data-lt="event handler" data-export="">event handlers</dfn> specified. These
  act as non-capture <a href="https://dom.spec.whatwg.org/#concept-event-listener" id="event-handler-attributes:event-listener" data-x-internal="event-listener">event listeners</a> for the object on which
  they are specified. <a href="#refsDOM">[DOM]</a></p>

  

  <p>An <a href="#event-handlers" id="event-handler-attributes:event-handlers">event handler</a> is a <a id="event-handler-attributes:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with two <a href="https://infra.spec.whatwg.org/#struct-item" id="event-handler-attributes:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p>a <dfn data-dfn-for="event handler" id="event-handler-value" data-export="">value</dfn>, which is
   either null, a callback object, or an
   <a href="#internal-raw-uncompiled-handler" id="event-handler-attributes:internal-raw-uncompiled-handler">internal raw uncompiled handler</a>. The <code id="event-handler-attributes:eventhandler"><a href="#eventhandler">EventHandler</a></code> callback
   function type describes how this is exposed to scripts. Initially, an <a href="#event-handlers" id="event-handler-attributes:event-handlers-2">event handler</a>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value">value</a>
   must be set to null.</p></li><li><p>a <dfn data-dfn-for="event handler" id="event-handler-listener" data-export="">listener</dfn>, which
   is either null or an <a id="event-handler-attributes:event-listener-2" href="https://dom.spec.whatwg.org/#concept-event-listener" data-x-internal="event-listener">event listener</a> responsible for running <a href="#the-event-handler-processing-algorithm" id="event-handler-attributes:the-event-handler-processing-algorithm">the
   event handler processing algorithm</a>. Initially, an <a href="#event-handlers" id="event-handler-attributes:event-handlers-3">event handler</a>'s <a href="#event-handler-listener" id="event-handler-attributes:event-handler-listener">listener</a> must be set to null.</p></li></ul>

  

  <p>Event handlers are exposed in two ways.</p>

  <p>The first way, common to all event handlers, is as an <a href="#event-handler-idl-attributes" id="event-handler-attributes:event-handler-idl-attributes">event handler IDL attribute</a>.</p>

  <p>The second way is as an <a href="#event-handler-content-attributes" id="event-handler-attributes:event-handler-content-attributes">event handler content
  attribute</a>. Event handlers on <a href="#html-elements" id="event-handler-attributes:html-elements">HTML elements</a> and some of the event handlers on
  <code id="event-handler-attributes:window"><a href="#window">Window</a></code> objects are exposed in this way.</p>

  <p>For both of these two ways, the <a href="#event-handlers" id="event-handler-attributes:event-handlers-4">event handler</a> is exposed
  through a <dfn id="event-handler-name">name</dfn>, which is a string that always starts with
  "<code>on</code>" and is followed by the name of the event for which the handler is
  intended.</p>

  <hr>

  <p>Most of the time, the object that exposes an <a href="#event-handlers" id="event-handler-attributes:event-handlers-5">event handler</a>
  is the same as the object on which the corresponding <a id="event-handler-attributes:event-listener-3" href="https://dom.spec.whatwg.org/#concept-event-listener" data-x-internal="event-listener">event listener</a> is added.
  However, the <code id="event-handler-attributes:the-body-element"><a href="#the-body-element">body</a></code> and <code id="event-handler-attributes:frameset"><a href="#frameset">frameset</a></code> elements expose several <a href="#event-handlers" id="event-handler-attributes:event-handlers-6">event
  handlers</a> that act upon the element's <code id="event-handler-attributes:window-2"><a href="#window">Window</a></code> object, if one exists. In either
  case, we call the object an <a href="#event-handlers" id="event-handler-attributes:event-handlers-7">event handler</a> acts upon the <dfn id="event-handler-target">target</dfn> of that <a href="#event-handlers" id="event-handler-attributes:event-handlers-8">event
  handler</a>.</p>

  

  <div data-algorithm="">
  <p>To <dfn id="determining-the-target-of-an-event-handler">determine the target of an event
  handler</dfn>, given an <code id="event-handler-attributes:eventtarget"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code> object <var>eventTarget</var> on which the <a href="#event-handlers" id="event-handler-attributes:event-handlers-9">event handler</a> is exposed, and an <a href="#event-handler-name" id="event-handler-attributes:event-handler-name">event handler name</a>
  <var>name</var>, the following steps are taken:</p>

  <ol><li><p>If <var>eventTarget</var> is not a <code id="event-handler-attributes:the-body-element-2"><a href="#the-body-element">body</a></code> element or a <code id="event-handler-attributes:frameset-2"><a href="#frameset">frameset</a></code>
   element, then return <var>eventTarget</var>.</p></li><li><p>If <var>name</var> is not the name of an attribute member of the
   <code id="event-handler-attributes:windoweventhandlers"><a href="#windoweventhandlers">WindowEventHandlers</a></code> interface mixin and the <a href="#window-reflecting-body-element-event-handler-set" id="event-handler-attributes:window-reflecting-body-element-event-handler-set"><code>Window</code>-reflecting
   body element event handler set</a> does not <a href="https://infra.spec.whatwg.org/#list-contain" id="event-handler-attributes:list-contains" data-x-internal="list-contains">contain</a>
   <var>name</var>, then return <var>eventTarget</var>.</p></li><li>
    <p>If <var>eventTarget</var>'s <a id="event-handler-attributes:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is not an <a href="#active-document" id="event-handler-attributes:active-document">active
    document</a>, then return null.</p>

    <p class="note">This could happen if this object is a <code id="event-handler-attributes:the-body-element-3"><a href="#the-body-element">body</a></code> element without
    a corresponding <code id="event-handler-attributes:window-3"><a href="#window">Window</a></code> object, for example.</p>

    <p class="note">This check does not necessarily prevent <code id="event-handler-attributes:the-body-element-4"><a href="#the-body-element">body</a></code> and
    <code id="event-handler-attributes:frameset-3"><a href="#frameset">frameset</a></code> elements that are not <a href="#the-body-element-2" id="event-handler-attributes:the-body-element-2-2">the body element</a> of their <a id="event-handler-attributes:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
    document</a> from reaching the next step. In particular, a <code id="event-handler-attributes:the-body-element-5"><a href="#the-body-element">body</a></code> element created
    in an <a href="#active-document" id="event-handler-attributes:active-document-2">active document</a> (perhaps with <code id="event-handler-attributes:dom-document-createelement"><a data-x-internal="dom-document-createelement" href="https://dom.spec.whatwg.org/#dom-document-createelement">document.createElement()</a></code>) but not
    <a id="event-handler-attributes:connected" href="https://dom.spec.whatwg.org/#connected" data-x-internal="connected">connected</a> will also have its corresponding <code id="event-handler-attributes:window-4"><a href="#window">Window</a></code> object as the <a href="#event-handler-target" id="event-handler-attributes:event-handler-target">target</a> of several <a href="#event-handlers" id="event-handler-attributes:event-handlers-10">event handlers</a> exposed
    through it.</p>
   </li><li><p>Return <var>eventTarget</var>'s <a id="event-handler-attributes:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#concept-relevant-global" id="event-handler-attributes:concept-relevant-global">relevant global
   object</a>.</p></li></ol>
  </div>

  <hr>

  <p>Each <code id="event-handler-attributes:eventtarget-2"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code> object that has one or more <a href="#event-handlers" id="event-handler-attributes:event-handlers-11">event handlers</a> specified
  has an associated <dfn data-dfn-for="EventTarget" id="event-handler-map" data-export="">event handler map</dfn>, which is a <a href="https://infra.spec.whatwg.org/#ordered-map" id="event-handler-attributes:ordered-map" data-x-internal="ordered-map">map</a> of strings representing <a href="#event-handler-name" id="event-handler-attributes:event-handler-name-2">names</a> of <a href="#event-handlers" id="event-handler-attributes:event-handlers-12">event handlers</a> to <a href="#event-handlers" id="event-handler-attributes:event-handlers-13">event handlers</a>.</p>

  <div data-algorithm="">
  <p>When an <code id="event-handler-attributes:eventtarget-3"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code> object that has one or more <a href="#event-handlers" id="event-handler-attributes:event-handlers-14">event handlers</a>
  specified is created, its <a href="#event-handler-map" id="event-handler-attributes:event-handler-map">event handler map</a> must be initialized such that it contains
  an <a href="https://infra.spec.whatwg.org/#map-entry" id="event-handler-attributes:map-entry" data-x-internal="map-entry">entry</a> for each <a href="#event-handlers" id="event-handler-attributes:event-handlers-15">event
  handler</a> that has that object as <a href="#event-handler-target" id="event-handler-attributes:event-handler-target-2">target</a>, with
  <a href="https://infra.spec.whatwg.org/#struct-item" id="event-handler-attributes:struct-item-2" data-x-internal="struct-item">items</a> in those <a href="#event-handlers" id="event-handler-attributes:event-handlers-16">event handlers</a> set to their initial
  values.</p>
  </div>

  <p class="note">The order of the <a href="https://infra.spec.whatwg.org/#map-entry" id="event-handler-attributes:map-entry-2" data-x-internal="map-entry">entries</a> of <a href="#event-handler-map" id="event-handler-attributes:event-handler-map-2">event handler
  map</a> could be arbitrary. It is not observable through any algorithms that operate on the
  map.</p>

  <p class="note"><a href="https://infra.spec.whatwg.org/#map-entry" id="event-handler-attributes:map-entry-3" data-x-internal="map-entry">Entries</a> are not created in the <a href="#event-handler-map" id="event-handler-attributes:event-handler-map-3">event handler
  map</a> of an object for <a href="#event-handlers" id="event-handler-attributes:event-handlers-17">event handlers</a> that are merely exposed on that object,
  but have some other object as their <a href="#event-handler-target" id="event-handler-attributes:event-handler-target-3">targets</a>.</p>

  

  <hr>

  <p>An <dfn id="event-handler-idl-attributes" data-export="">event handler IDL attribute</dfn> is an
  IDL attribute for a specific <a href="#event-handlers" id="event-handler-attributes:event-handlers-18">event handler</a>. The name of the
  IDL attribute is the same as the <a href="#event-handler-name" id="event-handler-attributes:event-handler-name-3">name</a> of the <a href="#event-handlers" id="event-handler-attributes:event-handlers-19">event handler</a>.</p>

  

  <div data-algorithm="">
  <p>The getter of an <a href="#event-handler-idl-attributes" id="event-handler-attributes:event-handler-idl-attributes-2">event handler IDL attribute</a>
  with name <var>name</var>, when called, must run these steps:</p>

  <ol><li><p>Let <var>eventTarget</var> be the result of <a href="#determining-the-target-of-an-event-handler" id="event-handler-attributes:determining-the-target-of-an-event-handler">determining the target of an event
   handler</a> given this object and <var>name</var>.</p></li><li><p>If <var>eventTarget</var> is null, then return null.</p></li><li><p>Return the result of <a href="#getting-the-current-value-of-the-event-handler" id="event-handler-attributes:getting-the-current-value-of-the-event-handler">getting the current value of the event handler</a> given
   <var>eventTarget</var> and <var>name</var>.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>The setter of an <a href="#event-handler-idl-attributes" id="event-handler-attributes:event-handler-idl-attributes-3">event handler IDL attribute</a>
  with name <var>name</var>, when called, must run these steps:</p>

  <ol><li><p>Let <var>eventTarget</var> be the result of <a href="#determining-the-target-of-an-event-handler" id="event-handler-attributes:determining-the-target-of-an-event-handler-2">determining the target of an event
   handler</a> given this object and <var>name</var>.</p></li><li><p>If <var>eventTarget</var> is null, then return.</p></li><li><p>If the given value is null, then <a href="#deactivate-an-event-handler" id="event-handler-attributes:deactivate-an-event-handler">deactivate an event handler</a> given
   <var>eventTarget</var> and <var>name</var>.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>handlerMap</var> be <var>eventTarget</var>'s <a href="#event-handler-map" id="event-handler-attributes:event-handler-map-4">event handler
     map</a>.</p></li><li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>name</var>].</p></li><li><p>Set <var>eventHandler</var>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-2">value</a> to the
     given value.</p></li><li><p><a href="#activate-an-event-handler" id="event-handler-attributes:activate-an-event-handler">Activate an event handler</a> given <var>eventTarget</var> and
     <var>name</var>.</p></li></ol>
   </li></ol>
  </div>

  <p class="note">Certain <a href="#event-handler-idl-attributes" id="event-handler-attributes:event-handler-idl-attributes-4">event handler IDL attributes</a> have additional requirements, in
  particular the <code id="event-handler-attributes:handler-messageeventtarget-onmessage"><a href="#handler-messageeventtarget-onmessage">onmessage</a></code> attribute of
  <code id="event-handler-attributes:messageport"><a href="#messageport">MessagePort</a></code> objects.</p>

  

  <hr>

  <p>An <dfn id="event-handler-content-attributes" data-export="">event handler content attribute</dfn>
  is a content attribute for a specific <a href="#event-handlers" id="event-handler-attributes:event-handlers-20">event handler</a>. The name
  of the content attribute is the same as the <a href="#event-handler-name" id="event-handler-attributes:event-handler-name-4">name</a> of the
  <a href="#event-handlers" id="event-handler-attributes:event-handlers-21">event handler</a>.</p>

  <p><a href="#event-handler-content-attributes" id="event-handler-attributes:event-handler-content-attributes-2">Event handler content attributes</a>, when specified, must contain valid JavaScript
  code which, when parsed, would match the <i id="event-handler-attributes:js-prod-functionbody"><a data-x-internal="js-prod-functionbody" href="https://tc39.es/ecma262/#prod-FunctionBody">FunctionBody</a></i>
  production after <a id="event-handler-attributes:automatic-semicolon-insertion" href="https://tc39.es/ecma262/#sec-automatic-semicolon-insertion" data-x-internal="automatic-semicolon-insertion">automatic semicolon insertion</a>.</p>

  

  <div data-algorithm="">
  <p>The following <a href="https://dom.spec.whatwg.org/#concept-element-attributes-change-ext" id="event-handler-attributes:concept-element-attributes-change-ext" data-x-internal="concept-element-attributes-change-ext">attribute change
  steps</a> are used to synchronize between <a href="#event-handler-content-attributes" id="event-handler-attributes:event-handler-content-attributes-3">event handler content attributes</a> and
  <a href="#event-handlers" id="event-handler-attributes:event-handlers-22">event handlers</a>: <a href="#refsDOM">[DOM]</a></p>

  <ol><li><p>If <var>namespace</var> is not null, or <var>localName</var> is not the name of an <a href="#event-handler-content-attributes" id="event-handler-attributes:event-handler-content-attributes-4">event handler content attribute</a> on
   <var>element</var>, then return.</p></li><li><p>Let <var>eventTarget</var> be the result of <a href="#determining-the-target-of-an-event-handler" id="event-handler-attributes:determining-the-target-of-an-event-handler-3">determining the target of an event
   handler</a> given <var>element</var> and <var>localName</var>.</p></li><li><p>If <var>eventTarget</var> is null, then return.</p></li><li><p>If <var>value</var> is null, then <a href="#deactivate-an-event-handler" id="event-handler-attributes:deactivate-an-event-handler-2">deactivate an event handler</a> given
   <var>eventTarget</var> and <var>localName</var>.</p></li><li>
    <p>Otherwise:</p>

    <ol><li><p>If the <a id="event-handler-attributes:should-element's-inline-behavior-be-blocked-by-content-security-policy" href="https://w3c.github.io/webappsec-csp/#should-block-inline" data-x-internal="should-element's-inline-behavior-be-blocked-by-content-security-policy">Should element's inline behavior be blocked by Content Security
     Policy?</a> algorithm returns "<code>Blocked</code>" when executed upon
     <var>element</var>, "<code>script attribute</code>", and <var>value</var>, then
     return. <a href="#refsCSP">[CSP]</a></p></li><li><p>Let <var>handlerMap</var> be <var>eventTarget</var>'s <a href="#event-handler-map" id="event-handler-attributes:event-handler-map-5">event handler
     map</a>.</p></li><li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>localName</var>].</p></li><li><p>Let <var>location</var> be the script location that triggered the execution of these
     steps.</p></li><li><p>Set <var>eventHandler</var>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-3">value</a> to the
     <a href="#internal-raw-uncompiled-handler" id="event-handler-attributes:internal-raw-uncompiled-handler-2">internal raw uncompiled handler</a> <var>value</var>/<var>location</var>.</p></li><li><p><a href="#activate-an-event-handler" id="event-handler-attributes:activate-an-event-handler-2">Activate an event handler</a> given <var>eventTarget</var> and
     <var>localName</var>.</p></li></ol>
   </li></ol>

  <p class="note">Per the DOM Standard, these steps are run even if <var>oldValue</var> and
  <var>value</var> are identical (setting an attribute to its current value), but <em>not</em> if
  <var>oldValue</var> and <var>value</var> are both null (removing an attribute that doesn't
  currently exist). <a href="#refsDOM">[DOM]</a></p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="deactivate-an-event-handler">deactivate an event handler</dfn> given an <code id="event-handler-attributes:eventtarget-4"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code> object
  <var>eventTarget</var> and a string <var>name</var> that is the <a href="#event-handler-name" id="event-handler-attributes:event-handler-name-5">name</a> of an <a href="#event-handlers" id="event-handler-attributes:event-handlers-23">event handler</a>, run these steps:</p>

  <ol><li><p>Let <var>handlerMap</var> be <var>eventTarget</var>'s <a href="#event-handler-map" id="event-handler-attributes:event-handler-map-6">event handler
   map</a>.</p></li><li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>name</var>].</p></li><li><p>Set <var>eventHandler</var>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-4">value</a> to
   null.</p></li><li><p>Let <var>listener</var> be <var>eventHandler</var>'s <a href="#event-handler-listener" id="event-handler-attributes:event-handler-listener-2">listener</a>.</p></li><li><p>If <var>listener</var> is not null, then <a id="event-handler-attributes:remove-an-event-listener" href="https://dom.spec.whatwg.org/#remove-an-event-listener" data-x-internal="remove-an-event-listener">remove an event listener</a> with
   <var>eventTarget</var> and <var>listener</var>.</p></li><li><p>Set <var>eventHandler</var>'s <a href="#event-handler-listener" id="event-handler-attributes:event-handler-listener-3">listener</a> to
   null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="erase-all-event-listeners-and-handlers">erase all event listeners and handlers</dfn> given an <code id="event-handler-attributes:eventtarget-5"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code> object
  <var>eventTarget</var>, run these steps:</p>

  <ol><li><p>If <var>eventTarget</var> has an associated <a href="#event-handler-map" id="event-handler-attributes:event-handler-map-7">event handler map</a>, then for each
   <var>name</var> → <var>eventHandler</var> of <var>eventTarget</var>'s associated <a href="#event-handler-map" id="event-handler-attributes:event-handler-map-8">event
   handler map</a>, <a href="#deactivate-an-event-handler" id="event-handler-attributes:deactivate-an-event-handler-3">deactivate an event handler</a> given <var>eventTarget</var> and
   <var>name</var>.</p></li><li><p><a id="event-handler-attributes:remove-all-event-listeners" href="https://dom.spec.whatwg.org/#remove-all-event-listeners" data-x-internal="remove-all-event-listeners">Remove all event listeners</a> given <var>eventTarget</var>.</p></li></ol>
  </div>

  <p class="note">This algorithm is used to define <code id="event-handler-attributes:dom-document-open"><a href="#dom-document-open">document.open()</a></code>.</p>

  <div data-algorithm="">
  <p>To <dfn id="activate-an-event-handler">activate an event handler</dfn> given an <code id="event-handler-attributes:eventtarget-6"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code> object
  <var>eventTarget</var> and a string <var>name</var> that is the <a href="#event-handler-name" id="event-handler-attributes:event-handler-name-6">name</a> of an <a href="#event-handlers" id="event-handler-attributes:event-handlers-24">event handler</a>, run these steps:</p>

  <ol><li><p>Let <var>handlerMap</var> be <var>eventTarget</var>'s <a href="#event-handler-map" id="event-handler-attributes:event-handler-map-9">event handler
   map</a>.</p></li><li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>name</var>].</p></li><li><p>If <var>eventHandler</var>'s <a href="#event-handler-listener" id="event-handler-attributes:event-handler-listener-4">listener</a> is not
   null, then return.</p></li><li>
    <p>Let <var>callback</var> be the result of creating a Web IDL <code id="event-handler-attributes:dom-eventlistener"><a data-x-internal="dom-eventlistener" href="https://dom.spec.whatwg.org/#callbackdef-eventlistener">EventListener</a></code> instance representing a reference to a function
    of one argument that executes the steps of <a href="#the-event-handler-processing-algorithm" id="event-handler-attributes:the-event-handler-processing-algorithm-2">the event handler processing algorithm</a>,
    given <var>eventTarget</var>, <var>name</var>, and its argument.</p>

    <p>The <code id="event-handler-attributes:dom-eventlistener-2"><a data-x-internal="dom-eventlistener" href="https://dom.spec.whatwg.org/#callbackdef-eventlistener">EventListener</a></code>'s <a id="event-handler-attributes:callback-context" href="https://webidl.spec.whatwg.org/#dfn-callback-context" data-x-internal="callback-context">callback context</a> can
    be arbitrary; it does not impact the steps of <a href="#the-event-handler-processing-algorithm" id="event-handler-attributes:the-event-handler-processing-algorithm-3">the event handler processing
    algorithm</a>. <a href="#refsDOM">[DOM]</a></p>

    <p class="note">The callback is emphatically <em>not</em> the <a href="#event-handlers" id="event-handler-attributes:event-handlers-25">event handler</a> itself. Every event handler ends up registering the same
    callback, the algorithm defined below, which takes care of invoking the right code, and
    processing the code's return value.</p>
   </li><li>
    <p>Let <var>listener</var> be a new <a id="event-handler-attributes:event-listener-4" href="https://dom.spec.whatwg.org/#concept-event-listener" data-x-internal="event-listener">event listener</a> whose <a href="https://dom.spec.whatwg.org/#event-listener-type" id="event-handler-attributes:event-listener-type" data-x-internal="event-listener-type">type</a> is the <dfn id="event-handler-event-type" data-export="">event handler event type</dfn> corresponding to
    <var>eventHandler</var> and <a href="https://dom.spec.whatwg.org/#event-listener-callback" id="event-handler-attributes:event-listener-callback" data-x-internal="event-listener-callback">callback</a> is
    <var>callback</var>.</p>

    <p class="note">To be clear, an <a id="event-handler-attributes:event-listener-5" href="https://dom.spec.whatwg.org/#concept-event-listener" data-x-internal="event-listener">event listener</a> is different from an <code id="event-handler-attributes:dom-eventlistener-3"><a data-x-internal="dom-eventlistener" href="https://dom.spec.whatwg.org/#callbackdef-eventlistener">EventListener</a></code>.</p>
   </li><li><p><a id="event-handler-attributes:add-an-event-listener" href="https://dom.spec.whatwg.org/#add-an-event-listener" data-x-internal="add-an-event-listener">Add an event listener</a> with <var>eventTarget</var> and
   <var>listener</var>.</p></li><li><p>Set <var>eventHandler</var>'s <a href="#event-handler-listener" id="event-handler-attributes:event-handler-listener-5">listener</a> to
   <var>listener</var>.</p></li></ol>
  </div>

  <div class="note">
   <p>The event listener registration happens only if the <a href="#event-handlers" id="event-handler-attributes:event-handlers-26">event
   handler</a>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-5">value</a> is being set to non-null, and
   the <a href="#event-handlers" id="event-handler-attributes:event-handlers-27">event handler</a> is not already activated. Since listeners
   are called in the order they were registered, assuming no <a href="#deactivate-an-event-handler" id="event-handler-attributes:deactivate-an-event-handler-4">deactivation</a> occurred, the order of event listeners for a particular event type
   will always be:</p>

   <ol><li><p>the event listeners registered with <code id="event-handler-attributes:dom-eventtarget-addeventlistener"><a data-x-internal="dom-eventtarget-addeventlistener" href="https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener">addEventListener()</a></code> before the first time the
    <a href="#event-handlers" id="event-handler-attributes:event-handlers-28">event handler</a>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-6">value</a> was set to non-null</p></li><li><p>then the callback to which it is currently set, if any</p></li><li><p>and finally the event listeners registered with <code id="event-handler-attributes:dom-eventtarget-addeventlistener-2"><a data-x-internal="dom-eventtarget-addeventlistener" href="https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener">addEventListener()</a></code> <em>after</em> the first
    time the <a href="#event-handlers" id="event-handler-attributes:event-handlers-29">event handler</a>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-7">value</a> was set to non-null.</p></li></ol>
  </div>

  

  <div class="example">

   <p>This example demonstrates the order in which event listeners are invoked. If the button in
   this example is clicked by the user, the page will show four alerts, with the text "ONE", "TWO",
   "THREE", and "FOUR" respectively.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"test"</c-><c- p="">&gt;</c->Start Demo<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> button <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'test'</c-><c- p="">);</c->
 button<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> alert<c- p="">(</c-><c- t="">'ONE'</c-><c- p="">)</c-> <c- p="">},</c-> <c- kc="">false</c-><c- p="">);</c->
 button<c- p="">.</c->setAttribute<c- p="">(</c-><c- t="">'onclick'</c-><c- p="">,</c-> <c- u="">"alert('NOT CALLED')"</c-><c- p="">);</c-> <c- c1="">// event handler listener is registered here</c->
 button<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> alert<c- p="">(</c-><c- t="">'THREE'</c-><c- p="">)</c-> <c- p="">},</c-> <c- kc="">false</c-><c- p="">);</c->
 button<c- p="">.</c->onclick <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> alert<c- p="">(</c-><c- t="">'TWO'</c-><c- p="">);</c-> <c- p="">};</c->
 button<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> alert<c- p="">(</c-><c- t="">'FOUR'</c-><c- p="">)</c-> <c- p="">},</c-> <c- kc="">false</c-><c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>However, in the following example, the event handler is <a href="#deactivate-an-event-handler" id="event-handler-attributes:deactivate-an-event-handler-5">deactivated</a> after its initial activation (and its event listener is removed),
   before being reactivated at a later time. The page will show five alerts with "ONE", "TWO",
   "THREE", "FOUR", and "FIVE" respectively, in order.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">button</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"test"</c-><c- p="">&gt;</c->Start Demo<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> button <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'test'</c-><c- p="">);</c->
 button<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> alert<c- p="">(</c-><c- t="">'ONE'</c-><c- p="">)</c-> <c- p="">},</c-> <c- kc="">false</c-><c- p="">);</c->
 button<c- p="">.</c->setAttribute<c- p="">(</c-><c- t="">'onclick'</c-><c- p="">,</c-> <c- u="">"alert('NOT CALLED')"</c-><c- p="">);</c-> <c- c1="">// event handler is activated here</c->
 button<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> alert<c- p="">(</c-><c- t="">'TWO'</c-><c- p="">)</c-> <c- p="">},</c-> <c- kc="">false</c-><c- p="">);</c->
 button<c- p="">.</c->onclick <c- o="">=</c-> <c- kc="">null</c-><c- p="">;</c->                                 <c- c1="">// but deactivated here</c->
 button<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> alert<c- p="">(</c-><c- t="">'THREE'</c-><c- p="">)</c-> <c- p="">},</c-> <c- kc="">false</c-><c- p="">);</c->
 button<c- p="">.</c->onclick <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> alert<c- p="">(</c-><c- t="">'FOUR'</c-><c- p="">);</c-> <c- p="">};</c->       <c- c1="">// and re-activated here</c->
 button<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'click'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> alert<c- p="">(</c-><c- t="">'FIVE'</c-><c- p="">)</c-> <c- p="">},</c-> <c- kc="">false</c-><c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  </div>

  

  <p class="note">The interfaces implemented by the event object do not influence whether an <a href="#event-handlers" id="event-handler-attributes:event-handlers-30">event handler</a> is triggered or not.</p>

  <div data-algorithm="">
  <p><dfn id="the-event-handler-processing-algorithm">The event handler processing algorithm</dfn> for an <code id="event-handler-attributes:eventtarget-7"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code> object
  <var>eventTarget</var>, a string <var>name</var> representing the <a href="#event-handler-name" id="event-handler-attributes:event-handler-name-7">name</a> of an <a href="#event-handlers" id="event-handler-attributes:event-handlers-31">event handler</a>, and an
  <code id="event-handler-attributes:event"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code> object <var>event</var> is as follows:</p>

  <ol><li><p>Let <var>callback</var> be the result of <a href="#getting-the-current-value-of-the-event-handler" id="event-handler-attributes:getting-the-current-value-of-the-event-handler-2">getting the current value of the event
   handler</a> given <var>eventTarget</var> and <var>name</var>.</p></li><li><p>If <var>callback</var> is null, then return.</p></li><li><p>Let <var>special error event handling</var> be true if <var>event</var> is an
   <code id="event-handler-attributes:errorevent"><a href="#errorevent">ErrorEvent</a></code> object, <var>event</var>'s <code id="event-handler-attributes:dom-event-type"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> is
   "<code id="event-handler-attributes:event-error"><a href="#event-error">error</a></code>", and <var>event</var>'s <code id="event-handler-attributes:dom-event-currenttarget"><a data-x-internal="dom-event-currenttarget" href="https://dom.spec.whatwg.org/#dom-event-currenttarget">currentTarget</a></code> implements the
   <code id="event-handler-attributes:windoworworkerglobalscope"><a href="#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a></code> mixin. Otherwise, let <var>special error event
   handling</var> be false.</p></li><li>
    <p>Process the <code id="event-handler-attributes:event-2"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code> object <var>event</var> as follows:</p>

    <dl class="switch"><dt>If <var>special error event handling</var> is true</dt><dd>
      <p>Let <var>return value</var> be the result of <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="event-handler-attributes:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">invoking</a> <var>callback</var> with «
      <var>event</var>'s <code id="event-handler-attributes:dom-errorevent-message"><a href="#dom-errorevent-message">message</a></code>, <var>event</var>'s
      <code id="event-handler-attributes:dom-errorevent-filename"><a href="#dom-errorevent-filename">filename</a></code>, <var>event</var>'s <code id="event-handler-attributes:dom-errorevent-lineno"><a href="#dom-errorevent-lineno">lineno</a></code>, <var>event</var>'s <code id="event-handler-attributes:dom-errorevent-colno"><a href="#dom-errorevent-colno">colno</a></code>, <var>event</var>'s <code id="event-handler-attributes:dom-errorevent-error"><a href="#dom-errorevent-error">error</a></code> », "<code>rethrow</code>", and with <i id="event-handler-attributes:dfn-callback-this-value"><a data-x-internal="dfn-callback-this-value" href="https://webidl.spec.whatwg.org/#dfn-callback-this-value">callback this value</a></i> set to <var>event</var>'s <code id="event-handler-attributes:dom-event-currenttarget-2"><a data-x-internal="dom-event-currenttarget" href="https://dom.spec.whatwg.org/#dom-event-currenttarget">currentTarget</a></code>.</p>
     </dd><dt>Otherwise</dt><dd>
      <p>Let <var>return value</var> be the result of <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="event-handler-attributes:es-invoking-callback-functions-2" data-x-internal="es-invoking-callback-functions">invoking</a> <var>callback</var> with «
      <var>event</var> », "<code>rethrow</code>", and with <i id="event-handler-attributes:dfn-callback-this-value-2"><a data-x-internal="dfn-callback-this-value" href="https://webidl.spec.whatwg.org/#dfn-callback-this-value">callback this value</a></i> set to <var>event</var>'s <code id="event-handler-attributes:dom-event-currenttarget-3"><a data-x-internal="dom-event-currenttarget" href="https://dom.spec.whatwg.org/#dom-event-currenttarget">currentTarget</a></code>.</p>
     </dd></dl>

    <p class="note">If an exception gets thrown by the callback, it will be rethrown, ending these
    steps. The exception will propagate to the <a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="event-handler-attributes:concept-event-dispatch" data-x-internal="concept-event-dispatch">DOM event
    dispatch logic</a>, which will then <a href="#report-an-exception" id="event-handler-attributes:report-an-exception">report</a> it.</p>
   </li><li>
    <p>Process <var>return value</var> as follows:</p>

    <dl class="switch"><dt>If <var>event</var> is a <code id="event-handler-attributes:beforeunloadevent"><a href="#beforeunloadevent">BeforeUnloadEvent</a></code> object and <var>event</var>'s <code id="event-handler-attributes:dom-event-type-2"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> is "<code id="event-handler-attributes:event-beforeunload"><a href="#event-beforeunload">beforeunload</a></code>"</dt><dd>
      <p class="note">In this case, the <a href="#event-handler-idl-attributes" id="event-handler-attributes:event-handler-idl-attributes-5">event handler
      IDL attribute</a>'s type will be <code id="event-handler-attributes:onbeforeunloadeventhandler"><a href="#onbeforeunloadeventhandler">OnBeforeUnloadEventHandler</a></code>, so <var>return
      value</var> will have been coerced into either null or a <code id="event-handler-attributes:idl-domstring"><a data-x-internal="idl-domstring" href="https://webidl.spec.whatwg.org/#idl-DOMString">DOMString</a></code>.</p>

      <p>If <var>return value</var> is not null, then:</p>

      <ol><li><p>Set <var>event</var>'s <a id="event-handler-attributes:canceled-flag" href="https://dom.spec.whatwg.org/#canceled-flag" data-x-internal="canceled-flag">canceled flag</a>.</p></li><li><p>If <var>event</var>'s <code id="event-handler-attributes:dom-beforeunloadevent-returnvalue"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code> attribute's value is the empty
       string, then set <var>event</var>'s <code id="event-handler-attributes:dom-beforeunloadevent-returnvalue-2"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code> attribute's value to
       <var>return value</var>.</p></li></ol>
     </dd><dt>If <var>special error event handling</var> is true</dt><dd><p>If <var>return value</var> is true, then set <var>event</var>'s <a id="event-handler-attributes:canceled-flag-2" href="https://dom.spec.whatwg.org/#canceled-flag" data-x-internal="canceled-flag">canceled
     flag</a>.</p></dd><dt>Otherwise</dt><dd>
      <p>If <var>return value</var> is false, then set <var>event</var>'s <a id="event-handler-attributes:canceled-flag-3" href="https://dom.spec.whatwg.org/#canceled-flag" data-x-internal="canceled-flag">canceled
      flag</a>.</p>

      <p class="note">If we've gotten to this "Otherwise" clause because <var>event</var>'s <code id="event-handler-attributes:dom-event-type-3"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> is "<code id="event-handler-attributes:event-beforeunload-2"><a href="#event-beforeunload">beforeunload</a></code>" but <var>event</var> is <em>not</em> a
      <code id="event-handler-attributes:beforeunloadevent-2"><a href="#beforeunloadevent">BeforeUnloadEvent</a></code> object, then <var>return value</var> will never be false, since
      in such cases <var>return value</var> will have been coerced into either null or a <code id="event-handler-attributes:idl-domstring-2"><a data-x-internal="idl-domstring" href="https://webidl.spec.whatwg.org/#idl-DOMString">DOMString</a></code>.</p>
     </dd></dl>
   </li></ol>
  </div>

  

  <hr>

  <p>The <code id="event-handler-attributes:eventhandler-2"><a href="#eventhandler">EventHandler</a></code> callback function type represents a callback used for event
  handlers. It is represented in Web IDL as follows:</p>

  <pre><code class="idl">[<a id="event-handler-attributes:legacytreatnonobjectasnull" href="https://webidl.spec.whatwg.org/#LegacyTreatNonObjectAsNull" data-x-internal="legacytreatnonobjectasnull"><c- g="">LegacyTreatNonObjectAsNull</c-></a>]
<c- b="">callback</c-> <dfn id="eventhandlernonnull" data-dfn-type="callback"><c- g="">EventHandlerNonNull</c-></dfn> = <c- b="">any</c-> (<a id="event-handler-attributes:event-3" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> <c- g="">event</c->);
<c- b="">typedef</c-> <a href="#eventhandlernonnull" id="event-handler-attributes:eventhandlernonnull"><c- n="">EventHandlerNonNull</c-></a>? <dfn id="eventhandler" data-dfn-type="typedef"><c- g="">EventHandler</c-></dfn>;</code></pre>

  <p class="note">In JavaScript, any <code id="event-handler-attributes:idl-function"><a data-x-internal="idl-function" href="https://webidl.spec.whatwg.org/#common-Function">Function</a></code> object implements
  this interface.</p>

  <div class="example">

   <p>For example, the following document fragment:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">body</c-> <c- e="">onload</c-><c- o="">=</c-><c- s="">"alert(this)"</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"alert(this)"</c-><c- p="">&gt;</c-></code></pre>

   <p>...leads to an alert saying "<code>[object&nbsp;Window]</code>" when the document is
   loaded, and an alert saying "<code>[object&nbsp;HTMLBodyElement]</code>" whenever the
   user clicks something in the page.</p>

  </div>

  <div class="note">
   <p>The return value of the function affects whether the event is canceled or not: as described above, if the return value is false, the event is canceled.</p>

   <p>There are two exceptions in the platform, for historical reasons:</p>

   <ul><li><p>The <code id="event-handler-attributes:handler-onerror"><a href="#handler-onerror">onerror</a></code> handlers on global objects, where
    returning <em>true</em> cancels the event.</p></li><li><p>The <code id="event-handler-attributes:handler-window-onbeforeunload"><a href="#handler-window-onbeforeunload">onbeforeunload</a></code> handler, where
    returning any non-null and non-undefined value will cancel the event.</p></li></ul>
  </div>

  <p>For historical reasons, the <code id="event-handler-attributes:handler-onerror-2"><a href="#handler-onerror">onerror</a></code> handler has different
  arguments:</p>

  <pre><code class="idl">[<a id="event-handler-attributes:legacytreatnonobjectasnull-2" href="https://webidl.spec.whatwg.org/#LegacyTreatNonObjectAsNull" data-x-internal="legacytreatnonobjectasnull"><c- g="">LegacyTreatNonObjectAsNull</c-></a>]
<c- b="">callback</c-> <dfn id="onerroreventhandlernonnull" data-dfn-type="callback"><c- g="">OnErrorEventHandlerNonNull</c-></dfn> = <c- b="">any</c-> ((<a id="event-handler-attributes:event-4" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> <c- b="">or</c-> <c- b="">DOMString</c->) <c- g="">event</c->, <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">source</c->, <c- b="">optional</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">lineno</c->, <c- b="">optional</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">colno</c->, <c- b="">optional</c-> <c- b="">any</c-> <c- g="">error</c->);
<c- b="">typedef</c-> <a href="#onerroreventhandlernonnull" id="event-handler-attributes:onerroreventhandlernonnull"><c- n="">OnErrorEventHandlerNonNull</c-></a>? <dfn id="onerroreventhandler" data-dfn-type="typedef"><c- g="">OnErrorEventHandler</c-></dfn>;</code></pre>

  <div class="example">
   <pre><code class="js">window<c- p="">.</c->onerror <c- o="">=</c-> <c- p="">(</c->message<c- p="">,</c-> source<c- p="">,</c-> lineno<c- p="">,</c-> colno<c- p="">,</c-> error<c- p="">)</c-> <c- p="">=&gt;</c-> <c- p="">{</c-> … <c- p="">};</c-></code></pre>
  </div>

  <p>Similarly, the <code id="event-handler-attributes:handler-window-onbeforeunload-2"><a href="#handler-window-onbeforeunload">onbeforeunload</a></code> handler has a
  different return value:</p>

  <pre><code class="idl">[<a id="event-handler-attributes:legacytreatnonobjectasnull-3" href="https://webidl.spec.whatwg.org/#LegacyTreatNonObjectAsNull" data-x-internal="legacytreatnonobjectasnull"><c- g="">LegacyTreatNonObjectAsNull</c-></a>]
<c- b="">callback</c-> <dfn id="onbeforeunloadeventhandlernonnull" data-dfn-type="callback"><c- g="">OnBeforeUnloadEventHandlerNonNull</c-></dfn> = <c- b="">DOMString</c->? (<a id="event-handler-attributes:event-5" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> <c- g="">event</c->);
<c- b="">typedef</c-> <a href="#onbeforeunloadeventhandlernonnull" id="event-handler-attributes:onbeforeunloadeventhandlernonnull"><c- n="">OnBeforeUnloadEventHandlerNonNull</c-></a>? <dfn id="onbeforeunloadeventhandler" data-dfn-type="typedef"><c- g="">OnBeforeUnloadEventHandler</c-></dfn>;</code></pre>

  

  

  <hr>

  <p>An <dfn id="internal-raw-uncompiled-handler">internal raw uncompiled handler</dfn> is a tuple with the following information:</p>

  <ul><li><p>An uncompiled script body</p></li><li><p>A location where the script body originated, in case an error needs to be
   reported</p></li></ul>

  <div data-algorithm="">
  <p>When the user agent is to <dfn id="getting-the-current-value-of-the-event-handler">get the
  current value of the event handler</dfn> given an <code id="event-handler-attributes:eventtarget-8"><a data-x-internal="eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a></code> object
  <var>eventTarget</var> and a string <var>name</var> that is the <a href="#event-handler-name" id="event-handler-attributes:event-handler-name-8">name</a> of an <a href="#event-handlers" id="event-handler-attributes:event-handlers-32">event handler</a>, it must run these
  steps:</p>

  <ol><li><p>Let <var>handlerMap</var> be <var>eventTarget</var>'s <a href="#event-handler-map" id="event-handler-attributes:event-handler-map-10">event handler
   map</a>.</p></li><li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>name</var>].</p></li><li>
    <p>If <var>eventHandler</var>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-8">value</a> is an
    <a href="#internal-raw-uncompiled-handler" id="event-handler-attributes:internal-raw-uncompiled-handler-3">internal raw uncompiled handler</a>, then:</p>

    <ol><li><p>If <var>eventTarget</var> is an element, then let <var>element</var> be
     <var>eventTarget</var>, and <var>document</var> be <var>element</var>'s <a id="event-handler-attributes:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
     document</a>. Otherwise, <var>eventTarget</var> is a <code id="event-handler-attributes:window-5"><a href="#window">Window</a></code> object, let
     <var>element</var> be null, and <var>document</var> be <var>eventTarget</var>'s <a href="#concept-document-window" id="event-handler-attributes:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>If <a href="#concept-n-noscript" id="event-handler-attributes:concept-n-noscript">scripting is disabled</a> for
     <var>document</var>, then return null.</p></li><li><p>Let <var>body</var> be the uncompiled script body in <var>eventHandler</var>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-9">value</a>.</p></li><li><p>Let <var>location</var> be the location where the script body originated, as
     given by <var>eventHandler</var>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-10">value</a>.</p></li><li><p>If <var>element</var> is not null and <var>element</var> has a
     <a href="#form-owner" id="event-handler-attributes:form-owner">form owner</a>, let <var>form owner</var> be that <a href="#form-owner" id="event-handler-attributes:form-owner-2">form owner</a>.
     Otherwise, let <var>form owner</var> be null.</p></li><li><p>Let <var>settings object</var> be the <a href="#relevant-settings-object" id="event-handler-attributes:relevant-settings-object">relevant settings object</a> of
     <var>document</var>.</p></li><li>
      <p>If <var>body</var> is not parsable as <i id="event-handler-attributes:js-prod-functionbody-2"><a data-x-internal="js-prod-functionbody" href="https://tc39.es/ecma262/#prod-FunctionBody">FunctionBody</a></i>
      or if parsing detects an <a id="event-handler-attributes:early-error" href="https://tc39.es/ecma262/#early-error-rule" data-x-internal="early-error">early error</a>, then follow these substeps:</p>

      <ol><li>
        <p>Set <var>eventHandler</var>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-11">value</a> to
        null.</p>

        <p class="note">This does not <a href="#deactivate-an-event-handler" id="event-handler-attributes:deactivate-an-event-handler-6">deactivate</a>
        the event handler, which additionally <a href="https://dom.spec.whatwg.org/#remove-an-event-listener" id="event-handler-attributes:remove-an-event-listener-2" data-x-internal="remove-an-event-listener">removes</a>
        the event handler's <a href="#event-handler-listener" id="event-handler-attributes:event-handler-listener-6">listener</a> (if present).</p>
       </li><li><p>Let <var>syntaxError</var> be a new <code id="event-handler-attributes:syntaxerror-2"><a data-x-internal="syntaxerror-2" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-syntaxerror">SyntaxError</a></code> exception associated
       with <var>settings object</var>'s <a href="#environment-settings-object's-realm" id="event-handler-attributes:environment-settings-object's-realm">realm</a> which describes the error while parsing. It should be based on
       <var>location</var>, where the script body originated.</p></li><li><p><a href="#report-an-exception" id="event-handler-attributes:report-an-exception-2">Report an exception</a> with <var>syntaxError</var>
       for <var>settings object</var>'s <a href="#concept-settings-object-global" id="event-handler-attributes:concept-settings-object-global">global
       object</a>.</p></li><li><p>Return null.</p></li></ol>
     </li><li>
      <p>Push <var>settings object</var>'s <a href="#realm-execution-context" id="event-handler-attributes:realm-execution-context">realm execution context</a> onto the
      <a id="event-handler-attributes:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a>; it is now the <a id="event-handler-attributes:running-javascript-execution-context" href="https://tc39.es/ecma262/#running-execution-context" data-x-internal="running-javascript-execution-context">running JavaScript
      execution context</a>.</p>

      <p class="note">This is necessary so the subsequent invocation of <a href="https://tc39.es/ecma262/#sec-ordinaryfunctioncreate" id="event-handler-attributes:js-ordinaryfunctioncreate" data-x-internal="js-ordinaryfunctioncreate">OrdinaryFunctionCreate</a> takes place in the correct
      <a id="event-handler-attributes:realm" href="https://tc39.es/ecma262/#sec-code-realms" data-x-internal="realm">realm</a>.</p>
     </li><li>
      <p>Let <var>function</var> be the result of calling <a href="https://tc39.es/ecma262/#sec-ordinaryfunctioncreate" id="event-handler-attributes:js-ordinaryfunctioncreate-2" data-x-internal="js-ordinaryfunctioncreate">OrdinaryFunctionCreate</a>, with arguments:</p>

      <dl><dt><i>functionPrototype</i></dt><dd><a id="event-handler-attributes:function.prototype" href="https://tc39.es/ecma262/#sec-properties-of-the-function-prototype-object" data-x-internal="function.prototype">%Function.prototype%</a></dd><dt><i>sourceText</i></dt><dd>
        <dl class="switch"><dt>If <var>name</var> is <code id="event-handler-attributes:handler-onerror-3"><a href="#handler-onerror">onerror</a></code> and
         <var>eventTarget</var> is a <code id="event-handler-attributes:window-6"><a href="#window">Window</a></code> object</dt><dd>The string formed by concatenating "<code>function </code>", <var>name</var>,
         "<code>(event, source, lineno, colno, error) {</code>", U+000A LF,
         <var>body</var>, U+000A LF, and "<code>}</code>".</dd><dt>Otherwise</dt><dd>The string formed by concatenating "<code>function </code>", <var>name</var>,
         "<code>(event) {</code>", U+000A LF, <var>body</var>, U+000A LF, and "<code>}</code>".</dd></dl>
       </dd><dt><i>ParameterList</i></dt><dd>
        <dl class="switch"><dt>If <var>name</var> is <code id="event-handler-attributes:handler-onerror-4"><a href="#handler-onerror">onerror</a></code> and
         <var>eventTarget</var> is a <code id="event-handler-attributes:window-7"><a href="#window">Window</a></code> object</dt><dd>Let the function have five arguments, named <code>event</code>, <code>source</code>, <code>lineno</code>, <code>colno</code>, and
         <code>error</code>.</dd><dt>Otherwise</dt><dd>Let the function have a single argument called <code>event</code>.</dd></dl>
       </dd><dt><i>body</i></dt><dd>The result of parsing <var>body</var> above.</dd><dt><i>thisMode</i></dt><dd>non-lexical-this</dd><dt><i>scope</i></dt><dd>
        <ol><li><p>Let <var>realm</var> be <var>settings object</var>'s <a href="#environment-settings-object's-realm" id="event-handler-attributes:environment-settings-object's-realm-2">realm</a>.</p></li><li><p>Let <var>scope</var> be <var>realm</var>.[[GlobalEnv]].</p></li><li>
          <p>If <var>eventHandler</var> is an element's <a href="#event-handlers" id="event-handler-attributes:event-handlers-33">event
          handler</a>, then set <var>scope</var> to <a href="https://tc39.es/ecma262/#sec-newobjectenvironment" id="event-handler-attributes:js-newobjectenvironment" data-x-internal="js-newobjectenvironment">NewObjectEnvironment</a>(<var>document</var>, true,
          <var>scope</var>).</p>

          <p>(Otherwise, <var>eventHandler</var> is a <code id="event-handler-attributes:window-8"><a href="#window">Window</a></code> object's <a href="#event-handlers" id="event-handler-attributes:event-handlers-34">event handler</a>.)</p>
         </li><li><p>If <var>form owner</var> is not null, then set <var>scope</var> to <a href="https://tc39.es/ecma262/#sec-newobjectenvironment" id="event-handler-attributes:js-newobjectenvironment-2" data-x-internal="js-newobjectenvironment">NewObjectEnvironment</a>(<var>form owner</var>, true,
         <var>scope</var>).</p></li><li><p>If <var>element</var> is not null, then set <var>scope</var> to <a href="https://tc39.es/ecma262/#sec-newobjectenvironment" id="event-handler-attributes:js-newobjectenvironment-3" data-x-internal="js-newobjectenvironment">NewObjectEnvironment</a>(<var>element</var>, true,
         <var>scope</var>).</p></li><li><p>Return <var>scope</var>.</p></li></ol>
       </dd></dl>
     </li><li><p>Remove <var>settings object</var>'s <a href="#realm-execution-context" id="event-handler-attributes:realm-execution-context-2">realm execution context</a> from the
     <a id="event-handler-attributes:javascript-execution-context-stack-2" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a>.</p></li><li>
      <p>Set <var>function</var>.[[ScriptOrModule]] to null.</p>

      <div class="note">
       <p>This is done because the default behavior, of associating the created function
       with the nearest <a href="#concept-script" id="event-handler-attributes:concept-script">script</a> on the stack, can lead to
       path-dependent results. For example, an event handler which is first invoked by user
       interaction would end up with null [[ScriptOrModule]] (since then this algorithm would be
       first invoked when the <a href="#active-script" id="event-handler-attributes:active-script">active script</a> is null), whereas one that is first invoked
       by dispatching an event from script would have its [[ScriptOrModule]] set to that script.</p>

       <p>Instead, we just always set [[ScriptOrModule]] to null. This is more intuitive anyway; the
       idea that the first script which dispatches an event is somehow responsible for the event
       handler code is dubious.</p>

       <p>In practice, this only affects the resolution of relative URLs via <code id="event-handler-attributes:import()"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code>,
       which consult the <a href="#concept-script-base-url" id="event-handler-attributes:concept-script-base-url">base URL</a> of the associated
       script. Nulling out [[ScriptOrModule]] means that <a href="#hostloadimportedmodule" id="event-handler-attributes:hostloadimportedmodule">HostLoadImportedModule</a> will
       fall back to the <a href="#current-settings-object" id="event-handler-attributes:current-settings-object">current settings object</a>'s <a href="#api-base-url" id="event-handler-attributes:api-base-url">API base URL</a>.</p>
      </div>
     </li><li><p>Set <var>eventHandler</var>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-12">value</a> to the
     result of creating a Web IDL <code id="event-handler-attributes:eventhandler-3"><a href="#eventhandler">EventHandler</a></code> callback function object whose object
     reference is <var>function</var> and whose <a id="event-handler-attributes:callback-context-2" href="https://webidl.spec.whatwg.org/#dfn-callback-context" data-x-internal="callback-context">callback context</a> is <var>settings
     object</var>.</p></li></ol>
   </li><li><p>Return <var>eventHandler</var>'s <a href="#event-handler-value" id="event-handler-attributes:event-handler-value-13">value</a>.</p></li></ol>
  </div>

  



  <h5 id="event-handlers-on-elements,-document-objects,-and-window-objects"><span class="secno">8.1.8.2</span> Event handlers on elements, <code id="event-handlers-on-elements,-document-objects,-and-window-objects:document"><a href="#document">Document</a></code> objects, and <code id="event-handlers-on-elements,-document-objects,-and-window-objects:window"><a href="#window">Window</a></code> objects<a href="#event-handlers-on-elements,-document-objects,-and-window-objects" class="self-link"></a></h5>

  <p>The following are the <a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-event-type">event handler event types</a>) that must be
  supported by all <a href="#html-elements" id="event-handlers-on-elements,-document-objects,-and-window-objects:html-elements">HTML elements</a>, as both <a href="#event-handler-content-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-content-attributes">event handler content attributes</a>
  and <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes">event handler IDL attributes</a>; and that must be
  supported by all <code id="event-handlers-on-elements,-document-objects,-and-window-objects:document-2"><a href="#document">Document</a></code> and <code id="event-handlers-on-elements,-document-objects,-and-window-objects:window-2"><a href="#window">Window</a></code> objects, as <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes-2">event handler IDL
  attributes</a>:</p>

  <table><thead><tr><th><a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onabort" data-dfn-type="attribute"><code>onabort</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/abort_event" title="The abort event is fired when the resource was not fully loaded, but not as the result of an error.">HTMLMediaElement/abort_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code>abort</code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onauxclick" data-dfn-type="attribute"><code>onauxclick</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/auxclick_event" title="The auxclick event is fired at an Element when a non-primary pointing device button (any mouse button other than the primary—usually leftmost—button) has been pressed and released both within the same element.">Element/auxclick_event</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>53+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>55+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>53+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-auxclick"><a data-x-internal="event-auxclick" href="https://w3c.github.io/uievents/#event-type-auxclick">auxclick</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onbeforeinput" data-dfn-type="attribute"><code>onbeforeinput</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-beforeinput"><a data-x-internal="event-beforeinput" href="https://w3c.github.io/uievents/#event-type-beforeinput">beforeinput</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onbeforematch" data-dfn-type="attribute"><code>onbeforematch</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-beforematch"><a href="#event-beforematch">beforematch</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onbeforetoggle" data-dfn-type="attribute"><code>onbeforetoggle</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-beforetoggle"><a href="#event-beforetoggle">beforetoggle</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncancel" data-dfn-type="attribute"><code>oncancel</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/cancel_event" title="The cancel event fires on a <dialog> when the user instructs the browser that they wish to dismiss the current open dialog. The browser fires this event when the user presses the Esc key.">HTMLDialogElement/cancel_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-cancel"><a href="#event-cancel">cancel</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncanplay" data-dfn-type="attribute"><code>oncanplay</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canplay_event" title="The canplay event is fired when the user agent can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content.">HTMLMediaElement/canplay_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-canplay"><a href="#event-media-canplay">canplay</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncanplaythrough" data-dfn-type="attribute"><code>oncanplaythrough</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canplaythrough_event" title="The canplaythrough event is fired when the user agent can play the media, and estimates that enough data has been loaded to play the media up to its end without having to stop for further buffering of content.">HTMLMediaElement/canplaythrough_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-canplaythrough"><a href="#event-media-canplaythrough">canplaythrough</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onchange" data-dfn-type="attribute"><code>onchange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event" title="The change event is fired for <input>, <select>, and <textarea> elements when the user modifies the element's value. Unlike the input event, the change event is not necessarily fired for each alteration to an element's value.">HTMLElement/change_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-change"><a href="#event-change">change</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onclick" data-dfn-type="attribute"><code>onclick</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event" title="An element receives a click event when a pointing device button (such as a mouse's primary mouse button) is both pressed and released while the pointer is located inside the element.">Element/click_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onclose" data-dfn-type="attribute"><code>onclose</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-close"><a href="#event-close">close</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncommand" data-dfn-type="attribute"><code>oncommand</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-command"><a href="#event-command">command</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncontextlost" data-dfn-type="attribute"><code>oncontextlost</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-contextlost"><a href="#event-contextlost">contextlost</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncontextmenu" data-dfn-type="attribute"><code>oncontextmenu</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-contextmenu"><a data-x-internal="event-contextmenu" href="https://w3c.github.io/uievents/#event-type-contextmenu">contextmenu</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncontextrestored" data-dfn-type="attribute"><code>oncontextrestored</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-contextrestored"><a href="#event-contextrestored">contextrestored</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncopy" data-dfn-type="attribute"><code>oncopy</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/copy_event" title="The copy event fires when the user initiates a copy action through the browser's user interface.">Element/copy_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-copy"><a data-x-internal="event-copy" href="https://w3c.github.io/clipboard-apis/#clipboard-event-copy">copy</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncuechange" data-dfn-type="attribute"><code>oncuechange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement/cuechange_event" title="The cuechange event fires when a TextTrack has changed the currently displaying cues. The event is fired on both the TextTrack and the HTMLTrackElement in which it's being presented, if any.">HTMLTrackElement/cuechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>32+</span></span><hr><span class="opera yes"><span>Opera</span><span>19+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4.3+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>19+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-cuechange"><a href="#event-media-cuechange">cuechange</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oncut" data-dfn-type="attribute"><code>oncut</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/cut_event" title="The cut event is fired when the user has initiated a &quot;cut&quot; action through the browser's user interface.">Element/cut_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-cut"><a data-x-internal="event-cut" href="https://w3c.github.io/clipboard-apis/#clipboard-event-cut">cut</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ondblclick" data-dfn-type="attribute"><code>ondblclick</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/dblclick_event" title="The dblclick event fires when a pointing device button (such as a mouse's primary button) is double-clicked; that is, when it's rapidly clicked twice on a single element within a very short span of time.">Element/dblclick_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-dblclick"><a data-x-internal="event-dblclick" href="https://w3c.github.io/uievents/#event-type-dblclick">dblclick</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ondrag" data-dfn-type="attribute"><code>ondrag</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-drag"><a href="#event-dnd-drag">drag</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ondragend" data-dfn-type="attribute"><code>ondragend</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragend"><a href="#event-dnd-dragend">dragend</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ondragenter" data-dfn-type="attribute"><code>ondragenter</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragenter"><a href="#event-dnd-dragenter">dragenter</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ondragleave" data-dfn-type="attribute"><code>ondragleave</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragleave"><a href="#event-dnd-dragleave">dragleave</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ondragover" data-dfn-type="attribute"><code>ondragover</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragover"><a href="#event-dnd-dragover">dragover</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ondragstart" data-dfn-type="attribute"><code>ondragstart</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragstart"><a href="#event-dnd-dragstart">dragstart</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ondrop" data-dfn-type="attribute"><code>ondrop</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-drop"><a href="#event-dnd-drop">drop</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ondurationchange" data-dfn-type="attribute"><code>ondurationchange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/durationchange_event" title="The durationchange event is fired when the duration attribute has been updated.">HTMLMediaElement/durationchange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-durationchange"><a href="#event-media-durationchange">durationchange</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onemptied" data-dfn-type="attribute"><code>onemptied</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/emptied_event" title="The emptied event is fired when the media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the load() method is called to reload it.">HTMLMediaElement/emptied_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-emptied"><a href="#event-media-emptied">emptied</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onended" data-dfn-type="attribute"><code>onended</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ended_event" title="The ended event is fired when playback or streaming has stopped because the end of the media was reached or because no further data is available.">HTMLMediaElement/ended_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-ended"><a href="#event-media-ended">ended</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onformdata" data-dfn-type="attribute"><code>onformdata</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-formdata"><a href="#event-formdata">formdata</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oninput" data-dfn-type="attribute"><code>oninput</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event" title="The input event fires when the value of an <input>, <select>, or <textarea> element has been changed.">HTMLElement/input_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Partial implementation.">🔰 9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-oninvalid" data-dfn-type="attribute"><code>oninvalid</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-invalid"><a href="#event-invalid">invalid</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onkeydown" data-dfn-type="attribute"><code>onkeydown</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event" title="The keydown event is fired when a key is pressed.">Element/keydown_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>1.2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-keydown"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onkeypress" data-dfn-type="attribute"><code>onkeypress</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-keypress"><a data-x-internal="event-keypress" href="https://w3c.github.io/uievents/#event-type-keypress">keypress</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onkeyup" data-dfn-type="attribute"><code>onkeyup</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/keyup_event" title="The keyup event is fired when a key is released.">Element/keyup_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>1.2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-keyup"><a data-x-internal="event-keyup" href="https://w3c.github.io/uievents/#event-type-keyup">keyup</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onloadeddata" data-dfn-type="attribute"><code>onloadeddata</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadeddata_event" title="The loadeddata event is fired when the frame at the current playback position of the media has finished loading; often the first frame.">HTMLMediaElement/loadeddata_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-loadeddata"><a href="#event-media-loadeddata">loadeddata</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onloadedmetadata" data-dfn-type="attribute"><code>onloadedmetadata</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadedmetadata_event" title="The loadedmetadata event is fired when the metadata has been loaded.">HTMLMediaElement/loadedmetadata_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-loadedmetadata"><a href="#event-media-loadedmetadata">loadedmetadata</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onloadstart" data-dfn-type="attribute"><code>onloadstart</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadstart_event" title="The loadstart event is fired when the browser has started to load a resource.">HTMLMediaElement/loadstart_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-loadstart"><a href="#event-media-loadstart">loadstart</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onmousedown" data-dfn-type="attribute"><code>onmousedown</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mousedown_event" title="The mousedown event is fired at an Element when a pointing device button is pressed while the pointer is inside the element.">Element/mousedown_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-mousedown"><a data-x-internal="event-mousedown" href="https://w3c.github.io/uievents/#event-type-mousedown">mousedown</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onmouseenter" data-dfn-type="attribute"><code>onmouseenter</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseenter_event" title="The mouseenter event is fired at an Element when a pointing device (usually a mouse) is initially moved so that its hotspot is within the element at which the event was fired.">Element/mouseenter_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>10+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>30+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-mouseenter"><a data-x-internal="event-mouseenter" href="https://w3c.github.io/uievents/#event-type-mouseenter">mouseenter</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onmouseleave" data-dfn-type="attribute"><code>onmouseleave</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseleave_event" title="The mouseleave event is fired at an Element when the cursor of a pointing device (usually a mouse) is moved out of it.">Element/mouseleave_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>10+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>30+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5.5+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-mouseleave"><a data-x-internal="event-mouseleave" href="https://w3c.github.io/uievents/#event-type-mouseleave">mouseleave</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onmousemove" data-dfn-type="attribute"><code>onmousemove</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mousemove_event" title="The mousemove event is fired at an element when a pointing device (usually a mouse) is moved while the cursor's hotspot is inside it.">Element/mousemove_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-mousemove"><a data-x-internal="event-mousemove" href="https://w3c.github.io/uievents/#event-type-mousemove">mousemove</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onmouseout" data-dfn-type="attribute"><code>onmouseout</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseout_event" title="The mouseout event is fired at an Element when a pointing device (usually a mouse) is used to move the cursor so that it is no longer contained within the element or one of its children.">Element/mouseout_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-mouseout"><a data-x-internal="event-mouseout" href="https://w3c.github.io/uievents/#event-type-mouseout">mouseout</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onmouseover" data-dfn-type="attribute"><code>onmouseover</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseover_event" title="The mouseover event is fired at an Element when a pointing device (such as a mouse or trackpad) is used to move the cursor onto the element or one of its child elements.">Element/mouseover_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>9.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-mouseover"><a data-x-internal="event-mouseover" href="https://w3c.github.io/uievents/#event-type-mouseover">mouseover</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onmouseup" data-dfn-type="attribute"><code>onmouseup</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseup_event" title="The mouseup event is fired at an Element when a button on a pointing device (such as a mouse or trackpad) is released while the pointer is located inside it.">Element/mouseup_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-mouseup"><a data-x-internal="event-mouseup" href="https://w3c.github.io/uievents/#event-type-mouseup">mouseup</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onpaste" data-dfn-type="attribute"><code>onpaste</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event" title="The paste event is fired when the user has initiated a &quot;paste&quot; action through the browser's user interface.">Element/paste_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>22+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-paste"><a data-x-internal="event-paste" href="https://w3c.github.io/clipboard-apis/#clipboard-event-paste">paste</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onpause" data-dfn-type="attribute"><code>onpause</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/pause_event" title="The pause event is sent when a request to pause an activity is handled and the activity has entered its paused state, most commonly after the media has been paused through a call to the element's pause() method.">HTMLMediaElement/pause_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-pause"><a href="#event-media-pause">pause</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onplay" data-dfn-type="attribute"><code>onplay</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play_event" title="The play event is fired when the paused property is changed from true to false, as a result of the play method, or the autoplay attribute.">HTMLMediaElement/play_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-play"><a href="#event-media-play">play</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onplaying" data-dfn-type="attribute"><code>onplaying</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event" title="The playing event is fired after playback is first started, and whenever it is restarted. For example it is fired when playback resumes after having been paused or delayed due to lack of data.">HTMLMediaElement/playing_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-playing"><a href="#event-media-playing">playing</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onprogress" data-dfn-type="attribute"><code>onprogress</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/progress_event" title="The progress event is fired periodically as the browser loads a resource.">HTMLMediaElement/progress_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-progress"><a href="#event-media-progress">progress</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onratechange" data-dfn-type="attribute"><code>onratechange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ratechange_event" title="The ratechange event is fired when the playback rate has changed.">HTMLMediaElement/ratechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-ratechange"><a href="#event-media-ratechange">ratechange</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onreset" data-dfn-type="attribute"><code>onreset</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-reset"><a href="#event-reset">reset</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onscrollend" data-dfn-type="attribute"><code>onscrollend</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/scrollend_event" title="The scrollend event fires when the document view has completed scrolling. Scrolling is considered completed when the scroll position has no more pending updates and the user has completed their gesture.">Document/scrollend_event</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>109+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollend_event" title="The scrollend event fires when element scrolling has completed. Scrolling is considered completed when the scroll position has no more pending updates and the user has completed their gesture.">Element/scrollend_event</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>109+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-scrollend"><a data-x-internal="event-scrollend" href="https://drafts.csswg.org/cssom-view/#eventdef-document-scrollend">scrollend</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onsecuritypolicyviolation" data-dfn-type="attribute"><code>onsecuritypolicyviolation</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/securitypolicyviolation_event" title="The securitypolicyviolation event is fired when a Content Security Policy is violated.">Element/securitypolicyviolation_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>41+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>15+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-securitypolicyviolation"><a data-x-internal="event-securitypolicyviolation" href="https://w3c.github.io/webappsec-csp/#eventdef-globaleventhandlers-securitypolicyviolation">securitypolicyviolation</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onseeked" data-dfn-type="attribute"><code>onseeked</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seeked_event" title="The seeked event is fired when a seek operation completed, the current playback position has changed, and the Boolean seeking attribute is changed to false.">HTMLMediaElement/seeked_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-seeked"><a href="#event-media-seeked">seeked</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onseeking" data-dfn-type="attribute"><code>onseeking</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seeking_event" title="The seeking event is fired when a seek operation starts, meaning the Boolean seeking attribute has changed to true and the media is seeking a new position.">HTMLMediaElement/seeking_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-seeking"><a href="#event-media-seeking">seeking</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onselect" data-dfn-type="attribute"><code>onselect</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select_event" title="The select event fires when some text has been selected.">HTMLInputElement/select_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/select_event" title="The select event fires when some text has been selected.">HTMLTextAreaElement/select_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-select"><a href="#event-select">select</a></code>  
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onslotchange" data-dfn-type="attribute"><code>onslotchange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/slotchange_event" title="The slotchange event is fired on an HTMLSlotElement instance (<slot> element) when the node(s) contained in that slot change.">HTMLSlotElement/slotchange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>63+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>53+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-slotchange"><a data-x-internal="event-slotchange" href="https://dom.spec.whatwg.org/#eventdef-htmlslotelement-slotchange">slotchange</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onstalled" data-dfn-type="attribute"><code>onstalled</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/stalled_event" title="The stalled event is fired when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.">HTMLMediaElement/stalled_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-stalled"><a href="#event-media-stalled">stalled</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onsubmit" data-dfn-type="attribute"><code>onsubmit</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event" title="The submit event fires when a <form> is submitted.">HTMLFormElement/submit_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-submit"><a href="#event-submit">submit</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onsuspend" data-dfn-type="attribute"><code>onsuspend</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/suspend_event" title="The suspend event is fired when media data loading has been suspended.">HTMLMediaElement/suspend_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-suspend"><a href="#event-media-suspend">suspend</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ontimeupdate" data-dfn-type="attribute"><code>ontimeupdate</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/timeupdate_event" title="The timeupdate event is fired when the time indicated by the currentTime attribute has been updated.">HTMLMediaElement/timeupdate_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-timeupdate"><a href="#event-media-timeupdate">timeupdate</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-ontoggle" data-dfn-type="attribute"><code>ontoggle</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-toggle"><a href="#event-toggle">toggle</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onvolumechange" data-dfn-type="attribute"><code>onvolumechange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/volumechange_event" title="The volumechange event is fired when either the volume attribute or the muted attribute has changed.">HTMLMediaElement/volumechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-volumechange"><a href="#event-media-volumechange">volumechange</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onwaiting" data-dfn-type="attribute"><code>onwaiting</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/waiting_event" title="The waiting event is fired when playback has stopped because of a temporary lack of data.">HTMLMediaElement/waiting_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-media-waiting"><a href="#event-media-waiting">waiting</a></code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onwebkitanimationend" data-dfn-type="attribute"><code>onwebkitanimationend</code></dfn> </td><td> <code>webkitAnimationEnd</code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onwebkitanimationiteration" data-dfn-type="attribute"><code>onwebkitanimationiteration</code></dfn> </td><td> <code>webkitAnimationIteration</code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onwebkitanimationstart" data-dfn-type="attribute"><code>onwebkitanimationstart</code></dfn> </td><td> <code>webkitAnimationStart</code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onwebkittransitionend" data-dfn-type="attribute"><code>onwebkittransitionend</code></dfn> </td><td> <code>webkitTransitionEnd</code>
    </td></tr><tr><td><dfn data-dfn-for="HTMLElement,Document,Window,GlobalEventHandlers" id="handler-onwheel" data-dfn-type="attribute"><code>onwheel</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event" title="The wheel event fires when the user rotates a wheel button on a pointing device (typically a mouse).">Element/wheel_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>17+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>31+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios no"><span>Safari iOS</span><span>No</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-wheel"><a data-x-internal="event-wheel" href="https://w3c.github.io/uievents/#event-type-wheel">wheel</a></code> 


 

 
  </td></tr></tbody></table>

  <hr>

  <p>The following are the <a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-3">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-event-type-3">event handler event types</a>) that must be
  supported by all <a href="#html-elements" id="event-handlers-on-elements,-document-objects,-and-window-objects:html-elements-2">HTML elements</a> other than <code id="event-handlers-on-elements,-document-objects,-and-window-objects:the-body-element"><a href="#the-body-element">body</a></code> and <code id="event-handlers-on-elements,-document-objects,-and-window-objects:frameset"><a href="#frameset">frameset</a></code>
  elements, as both <a href="#event-handler-content-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-content-attributes-2">event handler content attributes</a> and <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes-3">event handler IDL
  attributes</a>; that must be supported by all <code id="event-handlers-on-elements,-document-objects,-and-window-objects:document-3"><a href="#document">Document</a></code>
  objects, as <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes-4">event handler IDL attributes</a>; and that must be
  supported by all <code id="event-handlers-on-elements,-document-objects,-and-window-objects:window-3"><a href="#window">Window</a></code> objects, as <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes-5">event handler IDL attributes</a> on the
  <code id="event-handlers-on-elements,-document-objects,-and-window-objects:window-4"><a href="#window">Window</a></code> objects themselves, and with corresponding <a href="#event-handler-content-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-content-attributes-3">event handler content
  attributes</a> and <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes-6">event handler IDL attributes</a> exposed on all <code id="event-handlers-on-elements,-document-objects,-and-window-objects:the-body-element-2"><a href="#the-body-element">body</a></code>
  and <code id="event-handlers-on-elements,-document-objects,-and-window-objects:frameset-2"><a href="#frameset">frameset</a></code> elements that are owned by that <code id="event-handlers-on-elements,-document-objects,-and-window-objects:window-5"><a href="#window">Window</a></code> object's <a href="#concept-document-window" id="event-handlers-on-elements,-document-objects,-and-window-objects:concept-document-window">associated <code>Document</code></a>:</p>

  <table><thead><tr><th><a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-4">Event handler</a> </th><th><a href="#event-handler-event-type" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-event-type-4">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="handler-onblur" data-dfn-type="attribute"><code>onblur</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event" title="The blur event fires when an element has lost focus. The event does not bubble, but the related focusout event that follows does bubble.">Element/blur_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>24+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/blur_event" title="The blur event fires when an element has lost focus.">Window/blur_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-blur"><a href="#event-blur">blur</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="handler-onerror" data-dfn-type="attribute"><code>onerror</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event" title="The error event is fired on a Window object when a resource failed to load or couldn't be used — for example if a script has an execution error.">Window/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-error"><a href="#event-error">error</a></code>
    </td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="handler-onfocus" data-dfn-type="attribute"><code>onfocus</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/focus_event" title="The focus event fires when an element has received focus. The event does not bubble, but the related focusin event that follows does bubble.">Element/focus_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>24+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/focus_event" title="The focus event fires when an element has received focus.">Window/focus_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-focus"><a href="#event-focus">focus</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="handler-onload" data-dfn-type="attribute"><code>onload</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-load"><a href="#event-load">load</a></code>
    </td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="handler-onresize" data-dfn-type="attribute"><code>onresize</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-resize"><a data-x-internal="event-resize" href="https://drafts.csswg.org/cssom-view/#eventdef-window-resize">resize</a></code>
    </td></tr><tr><td><dfn data-dfn-for="GlobalEventHandlers" id="handler-onscroll" data-dfn-type="attribute"><code>onscroll</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/scroll_event" title="The scroll event fires when the document view has been scrolled. To detect when scrolling has completed, see the Document: scrollend event. For element scrolling, see Element: scroll event.">Document/scroll_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>2+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll_event" title="The scroll event fires when an element has been scrolled. To detect when scrolling has completed, see the Element: scrollend event.">Element/scroll_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>1.3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-scroll"><a data-x-internal="event-scroll" href="https://drafts.csswg.org/cssom-view/#eventdef-document-scroll">scroll</a></code>
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>We call the <a id="event-handlers-on-elements,-document-objects,-and-window-objects:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of the <a href="#event-handler-name" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-name">names</a> of the
  <a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-5">event handlers</a> listed in the first column of this table the
  <dfn id="window-reflecting-body-element-event-handler-set"><code>Window</code>-reflecting body element event handler set</dfn>.</p>
  </div>

  <hr>

  <p>The following are the <a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-6">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-event-type-5">event handler event types</a>) that must be
  supported by <code id="event-handlers-on-elements,-document-objects,-and-window-objects:window-6"><a href="#window">Window</a></code> objects, as <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes-7">event handler IDL attributes</a> on the
  <code id="event-handlers-on-elements,-document-objects,-and-window-objects:window-7"><a href="#window">Window</a></code> objects themselves, and with corresponding <a href="#event-handler-content-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-content-attributes-4">event handler content
  attributes</a> and <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes-8">event handler IDL attributes</a> exposed on all <code id="event-handlers-on-elements,-document-objects,-and-window-objects:the-body-element-3"><a href="#the-body-element">body</a></code>
  and <code id="event-handlers-on-elements,-document-objects,-and-window-objects:frameset-3"><a href="#frameset">frameset</a></code> elements that are owned by that <code id="event-handlers-on-elements,-document-objects,-and-window-objects:window-8"><a href="#window">Window</a></code> object's <a href="#concept-document-window" id="event-handlers-on-elements,-document-objects,-and-window-objects:concept-document-window-2">associated <code>Document</code></a>:</p>

  <table><thead><tr><th><a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-7">Event handler</a> </th><th><a href="#event-handler-event-type" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-event-type-6">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onafterprint" data-dfn-type="attribute"><code>onafterprint</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/afterprint_event" title="The afterprint event is fired after the associated document has started printing or the print preview has been closed.">Window/afterprint_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>13+</span></span><span class="chrome yes"><span>Chrome</span><span>63+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-afterprint"><a href="#event-afterprint">afterprint</a></code>
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onbeforeprint" data-dfn-type="attribute"><code>onbeforeprint</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeprint_event" title="The beforeprint event is fired when the associated document is about to be printed or previewed for printing.">Window/beforeprint_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>13+</span></span><span class="chrome yes"><span>Chrome</span><span>63+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-beforeprint"><a href="#event-beforeprint">beforeprint</a></code>
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onbeforeunload" data-dfn-type="attribute"><code>onbeforeunload</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event" title="The beforeunload event is fired when the window, the document and its resources are about to be unloaded. The document is still visible and the event is still cancelable at this point.">Window/beforeunload_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-beforeunload"><a href="#event-beforeunload">beforeunload</a></code>
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onhashchange" data-dfn-type="attribute"><code>onhashchange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/hashchange_event" title="The hashchange event is fired when the fragment identifier of the URL has changed (the part of the URL beginning with and following the # symbol).">Window/hashchange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-hashchange"><a href="#event-hashchange">hashchange</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onlanguagechange" data-dfn-type="attribute"><code>onlanguagechange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/languagechange_event" title="The languagechange event is fired at the global scope object when the user's preferred language changes.">Window/languagechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>32+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>4.0+</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-languagechange"><a href="#event-languagechange">languagechange</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onmessage" data-dfn-type="attribute"><code>onmessage</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/message_event" title="The message event is fired on a Window object when the window receives a message, for example from a call to Window.postMessage() from another browsing context.">Window/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-message"><a href="#event-message">message</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onmessageerror" data-dfn-type="attribute"><code>onmessageerror</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/error_event" title="The error event is fired when the resource could not be loaded due to an error (for example, a network connectivity problem).">HTMLMediaElement/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/messageerror_event" title="The messageerror event is fired on a Window object when it receives a message that can't be deserialized.">Window/messageerror_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-messageerror"><a href="#event-messageerror">messageerror</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onoffline" data-dfn-type="attribute"><code>onoffline</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/offline_event" title="The offline event of the Window interface is fired when the browser has lost access to the network and the value of Navigator.onLine switches to false.">Window/offline_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-offline"><a href="#event-offline">offline</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-ononline" data-dfn-type="attribute"><code>ononline</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/online_event" title="The online event of the Window interface is fired when the browser has gained access to the network and the value of Navigator.onLine switches to true.">Window/online_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-online"><a href="#event-online">online</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onpageswap" data-dfn-type="attribute"><code>onpageswap</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-pageswap"><a href="#event-pageswap">pageswap</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onpagehide" data-dfn-type="attribute"><code>onpagehide</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-pagehide"><a href="#event-pagehide">pagehide</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onpagereveal" data-dfn-type="attribute"><code>onpagereveal</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-pagereveal"><a href="#event-pagereveal">pagereveal</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onpageshow" data-dfn-type="attribute"><code>onpageshow</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-pageshow"><a href="#event-pageshow">pageshow</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onpopstate" data-dfn-type="attribute"><code>onpopstate</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event" title="The popstate event of the Window interface is fired when the active history entry changes while the user navigates the session history. It changes the current history entry to that of the last page the user visited or, if history.pushState() has been used to add a history entry to the history stack, that history entry is used instead.">Window/popstate_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.5+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-popstate"><a href="#event-popstate">popstate</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onrejectionhandled" data-dfn-type="attribute"><code>onrejectionhandled</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/rejectionhandled_event" title="The rejectionhandled event is sent to the script's global scope (usually window but also Worker) whenever a rejected JavaScript Promise is handled late, i.e. when a handler is attached to the promise after its rejection had caused an unhandledrejection event.">Window/rejectionhandled_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>69+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>11.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-rejectionhandled"><a href="#event-rejectionhandled">rejectionhandled</a></code>
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onstorage" data-dfn-type="attribute"><code>onstorage</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event" title="The storage event of the Window interface fires when a storage area (localStorage) has been modified in the context of another document.">Window/storage_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>45+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>15+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-storage"><a href="#event-storage">storage</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onunhandledrejection" data-dfn-type="attribute"><code>onunhandledrejection</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event" title="The unhandledrejection event is sent to the global scope of a script when a JavaScript Promise that has no rejection handler is rejected; typically, this is the window, but may also be a Worker.">Window/unhandledrejection_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>69+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>11.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-unhandledrejection"><a href="#event-unhandledrejection">unhandledrejection</a></code>
    </td></tr><tr><td><dfn data-dfn-for="WindowEventHandlers" id="handler-window-onunload" data-dfn-type="attribute"><code>onunload</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event" title="The unload event is fired when the document or a child resource is being unloaded.">Window/unload_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-unload"><a href="#event-unload">unload</a></code> 
  </td></tr></tbody></table>

  <p>This list of <a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-8">event handlers</a> is reified as <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes-9">event handler IDL
  attributes</a> through the <code id="event-handlers-on-elements,-document-objects,-and-window-objects:windoweventhandlers"><a href="#windoweventhandlers">WindowEventHandlers</a></code> interface mixin.</p>

  <hr>

  <p>The following are the <a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-9">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-event-type-7">event handler event types</a>) that must be
  supported on <code id="event-handlers-on-elements,-document-objects,-and-window-objects:document-4"><a href="#document">Document</a></code> objects as <a href="#event-handler-idl-attributes" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-idl-attributes-10">event handler IDL attributes</a>:</p>

  

  <table><thead><tr><th><a href="#event-handlers" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-10">Event handler</a> </th><th><a href="#event-handler-event-type" id="event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-event-type-8">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="Document" id="handler-onreadystatechange" data-dfn-type="attribute"><code>onreadystatechange</code></dfn> </td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code>
    </td></tr><tr><td><dfn data-dfn-for="Document" id="handler-onvisibilitychange" data-dfn-type="attribute"><code>onvisibilitychange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event" title="The visibilitychange event is fired at the document when the contents of its tab have become visible or have been hidden.">Document/visibilitychange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>62+</span></span><hr><span class="opera yes"><span>Opera</span><span>49+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Partial implementation.">🔰 10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>62+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>46+</span></span></div></div></div></td><td> <code id="event-handlers-on-elements,-document-objects,-and-window-objects:event-visibilitychange"><a href="#event-visibilitychange">visibilitychange</a></code>
  </td></tr></tbody></table>


  

  <h6 id="idl-definitions"><span class="secno">8.1.8.2.1</span> IDL definitions<a href="#idl-definitions" class="self-link"></a></h6>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="globaleventhandlers" data-dfn-type="interface"><c- g="">GlobalEventHandlers</c-></dfn> {
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-onabort" id="idl-definitions:handler-onabort"><c- g="">onabort</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-onauxclick" id="idl-definitions:handler-onauxclick"><c- g="">onauxclick</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-3"><c- n="">EventHandler</c-></a> <a href="#handler-onbeforeinput" id="idl-definitions:handler-onbeforeinput"><c- g="">onbeforeinput</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-4"><c- n="">EventHandler</c-></a> <a href="#handler-onbeforematch" id="idl-definitions:handler-onbeforematch"><c- g="">onbeforematch</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-5"><c- n="">EventHandler</c-></a> <a href="#handler-onbeforetoggle" id="idl-definitions:handler-onbeforetoggle"><c- g="">onbeforetoggle</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-6"><c- n="">EventHandler</c-></a> <a href="#handler-onblur" id="idl-definitions:handler-onblur"><c- g="">onblur</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-7"><c- n="">EventHandler</c-></a> <a href="#handler-oncancel" id="idl-definitions:handler-oncancel"><c- g="">oncancel</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-8"><c- n="">EventHandler</c-></a> <a href="#handler-oncanplay" id="idl-definitions:handler-oncanplay"><c- g="">oncanplay</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-9"><c- n="">EventHandler</c-></a> <a href="#handler-oncanplaythrough" id="idl-definitions:handler-oncanplaythrough"><c- g="">oncanplaythrough</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-10"><c- n="">EventHandler</c-></a> <a href="#handler-onchange" id="idl-definitions:handler-onchange"><c- g="">onchange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-11"><c- n="">EventHandler</c-></a> <a href="#handler-onclick" id="idl-definitions:handler-onclick"><c- g="">onclick</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-12"><c- n="">EventHandler</c-></a> <a href="#handler-onclose" id="idl-definitions:handler-onclose"><c- g="">onclose</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-13"><c- n="">EventHandler</c-></a> <a href="#handler-oncommand" id="idl-definitions:handler-oncommand"><c- g="">oncommand</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-14"><c- n="">EventHandler</c-></a> <a href="#handler-oncontextlost" id="idl-definitions:handler-oncontextlost"><c- g="">oncontextlost</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-15"><c- n="">EventHandler</c-></a> <a href="#handler-oncontextmenu" id="idl-definitions:handler-oncontextmenu"><c- g="">oncontextmenu</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-16"><c- n="">EventHandler</c-></a> <a href="#handler-oncontextrestored" id="idl-definitions:handler-oncontextrestored"><c- g="">oncontextrestored</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-17"><c- n="">EventHandler</c-></a> <a href="#handler-oncopy" id="idl-definitions:handler-oncopy"><c- g="">oncopy</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-18"><c- n="">EventHandler</c-></a> <a href="#handler-oncuechange" id="idl-definitions:handler-oncuechange"><c- g="">oncuechange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-19"><c- n="">EventHandler</c-></a> <a href="#handler-oncut" id="idl-definitions:handler-oncut"><c- g="">oncut</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-20"><c- n="">EventHandler</c-></a> <a href="#handler-ondblclick" id="idl-definitions:handler-ondblclick"><c- g="">ondblclick</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-21"><c- n="">EventHandler</c-></a> <a href="#handler-ondrag" id="idl-definitions:handler-ondrag"><c- g="">ondrag</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-22"><c- n="">EventHandler</c-></a> <a href="#handler-ondragend" id="idl-definitions:handler-ondragend"><c- g="">ondragend</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-23"><c- n="">EventHandler</c-></a> <a href="#handler-ondragenter" id="idl-definitions:handler-ondragenter"><c- g="">ondragenter</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-24"><c- n="">EventHandler</c-></a> <a href="#handler-ondragleave" id="idl-definitions:handler-ondragleave"><c- g="">ondragleave</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-25"><c- n="">EventHandler</c-></a> <a href="#handler-ondragover" id="idl-definitions:handler-ondragover"><c- g="">ondragover</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-26"><c- n="">EventHandler</c-></a> <a href="#handler-ondragstart" id="idl-definitions:handler-ondragstart"><c- g="">ondragstart</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-27"><c- n="">EventHandler</c-></a> <a href="#handler-ondrop" id="idl-definitions:handler-ondrop"><c- g="">ondrop</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-28"><c- n="">EventHandler</c-></a> <a href="#handler-ondurationchange" id="idl-definitions:handler-ondurationchange"><c- g="">ondurationchange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-29"><c- n="">EventHandler</c-></a> <a href="#handler-onemptied" id="idl-definitions:handler-onemptied"><c- g="">onemptied</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-30"><c- n="">EventHandler</c-></a> <a href="#handler-onended" id="idl-definitions:handler-onended"><c- g="">onended</c-></a>;
  <c- b="">attribute</c-> <a href="#onerroreventhandler" id="idl-definitions:onerroreventhandler"><c- n="">OnErrorEventHandler</c-></a> <a href="#handler-onerror" id="idl-definitions:handler-onerror"><c- g="">onerror</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-31"><c- n="">EventHandler</c-></a> <a href="#handler-onfocus" id="idl-definitions:handler-onfocus"><c- g="">onfocus</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-32"><c- n="">EventHandler</c-></a> <a href="#handler-onformdata" id="idl-definitions:handler-onformdata"><c- g="">onformdata</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-33"><c- n="">EventHandler</c-></a> <a href="#handler-oninput" id="idl-definitions:handler-oninput"><c- g="">oninput</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-34"><c- n="">EventHandler</c-></a> <a href="#handler-oninvalid" id="idl-definitions:handler-oninvalid"><c- g="">oninvalid</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-35"><c- n="">EventHandler</c-></a> <a href="#handler-onkeydown" id="idl-definitions:handler-onkeydown"><c- g="">onkeydown</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-36"><c- n="">EventHandler</c-></a> <a href="#handler-onkeypress" id="idl-definitions:handler-onkeypress"><c- g="">onkeypress</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-37"><c- n="">EventHandler</c-></a> <a href="#handler-onkeyup" id="idl-definitions:handler-onkeyup"><c- g="">onkeyup</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-38"><c- n="">EventHandler</c-></a> <a href="#handler-onload" id="idl-definitions:handler-onload"><c- g="">onload</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-39"><c- n="">EventHandler</c-></a> <a href="#handler-onloadeddata" id="idl-definitions:handler-onloadeddata"><c- g="">onloadeddata</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-40"><c- n="">EventHandler</c-></a> <a href="#handler-onloadedmetadata" id="idl-definitions:handler-onloadedmetadata"><c- g="">onloadedmetadata</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-41"><c- n="">EventHandler</c-></a> <a href="#handler-onloadstart" id="idl-definitions:handler-onloadstart"><c- g="">onloadstart</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-42"><c- n="">EventHandler</c-></a> <a href="#handler-onmousedown" id="idl-definitions:handler-onmousedown"><c- g="">onmousedown</c-></a>;
  [<a id="idl-definitions:legacylenientthis" href="https://webidl.spec.whatwg.org/#LegacyLenientThis" data-x-internal="legacylenientthis"><c- g="">LegacyLenientThis</c-></a>] <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-43"><c- n="">EventHandler</c-></a> <a href="#handler-onmouseenter" id="idl-definitions:handler-onmouseenter"><c- g="">onmouseenter</c-></a>;
  [<a id="idl-definitions:legacylenientthis-2" href="https://webidl.spec.whatwg.org/#LegacyLenientThis" data-x-internal="legacylenientthis"><c- g="">LegacyLenientThis</c-></a>] <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-44"><c- n="">EventHandler</c-></a> <a href="#handler-onmouseleave" id="idl-definitions:handler-onmouseleave"><c- g="">onmouseleave</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-45"><c- n="">EventHandler</c-></a> <a href="#handler-onmousemove" id="idl-definitions:handler-onmousemove"><c- g="">onmousemove</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-46"><c- n="">EventHandler</c-></a> <a href="#handler-onmouseout" id="idl-definitions:handler-onmouseout"><c- g="">onmouseout</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-47"><c- n="">EventHandler</c-></a> <a href="#handler-onmouseover" id="idl-definitions:handler-onmouseover"><c- g="">onmouseover</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-48"><c- n="">EventHandler</c-></a> <a href="#handler-onmouseup" id="idl-definitions:handler-onmouseup"><c- g="">onmouseup</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-49"><c- n="">EventHandler</c-></a> <a href="#handler-onpaste" id="idl-definitions:handler-onpaste"><c- g="">onpaste</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-50"><c- n="">EventHandler</c-></a> <a href="#handler-onpause" id="idl-definitions:handler-onpause"><c- g="">onpause</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-51"><c- n="">EventHandler</c-></a> <a href="#handler-onplay" id="idl-definitions:handler-onplay"><c- g="">onplay</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-52"><c- n="">EventHandler</c-></a> <a href="#handler-onplaying" id="idl-definitions:handler-onplaying"><c- g="">onplaying</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-53"><c- n="">EventHandler</c-></a> <a href="#handler-onprogress" id="idl-definitions:handler-onprogress"><c- g="">onprogress</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-54"><c- n="">EventHandler</c-></a> <a href="#handler-onratechange" id="idl-definitions:handler-onratechange"><c- g="">onratechange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-55"><c- n="">EventHandler</c-></a> <a href="#handler-onreset" id="idl-definitions:handler-onreset"><c- g="">onreset</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-56"><c- n="">EventHandler</c-></a> <a href="#handler-onresize" id="idl-definitions:handler-onresize"><c- g="">onresize</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-57"><c- n="">EventHandler</c-></a> <a href="#handler-onscroll" id="idl-definitions:handler-onscroll"><c- g="">onscroll</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-58"><c- n="">EventHandler</c-></a> <a href="#handler-onscrollend" id="idl-definitions:handler-onscrollend"><c- g="">onscrollend</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-59"><c- n="">EventHandler</c-></a> <a href="#handler-onsecuritypolicyviolation" id="idl-definitions:handler-onsecuritypolicyviolation"><c- g="">onsecuritypolicyviolation</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-60"><c- n="">EventHandler</c-></a> <a href="#handler-onseeked" id="idl-definitions:handler-onseeked"><c- g="">onseeked</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-61"><c- n="">EventHandler</c-></a> <a href="#handler-onseeking" id="idl-definitions:handler-onseeking"><c- g="">onseeking</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-62"><c- n="">EventHandler</c-></a> <a href="#handler-onselect" id="idl-definitions:handler-onselect"><c- g="">onselect</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-63"><c- n="">EventHandler</c-></a> <a href="#handler-onslotchange" id="idl-definitions:handler-onslotchange"><c- g="">onslotchange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-64"><c- n="">EventHandler</c-></a> <a href="#handler-onstalled" id="idl-definitions:handler-onstalled"><c- g="">onstalled</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-65"><c- n="">EventHandler</c-></a> <a href="#handler-onsubmit" id="idl-definitions:handler-onsubmit"><c- g="">onsubmit</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-66"><c- n="">EventHandler</c-></a> <a href="#handler-onsuspend" id="idl-definitions:handler-onsuspend"><c- g="">onsuspend</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-67"><c- n="">EventHandler</c-></a> <a href="#handler-ontimeupdate" id="idl-definitions:handler-ontimeupdate"><c- g="">ontimeupdate</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-68"><c- n="">EventHandler</c-></a> <a href="#handler-ontoggle" id="idl-definitions:handler-ontoggle"><c- g="">ontoggle</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-69"><c- n="">EventHandler</c-></a> <a href="#handler-onvolumechange" id="idl-definitions:handler-onvolumechange"><c- g="">onvolumechange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-70"><c- n="">EventHandler</c-></a> <a href="#handler-onwaiting" id="idl-definitions:handler-onwaiting"><c- g="">onwaiting</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-71"><c- n="">EventHandler</c-></a> <a href="#handler-onwebkitanimationend" id="idl-definitions:handler-onwebkitanimationend"><c- g="">onwebkitanimationend</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-72"><c- n="">EventHandler</c-></a> <a href="#handler-onwebkitanimationiteration" id="idl-definitions:handler-onwebkitanimationiteration"><c- g="">onwebkitanimationiteration</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-73"><c- n="">EventHandler</c-></a> <a href="#handler-onwebkitanimationstart" id="idl-definitions:handler-onwebkitanimationstart"><c- g="">onwebkitanimationstart</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-74"><c- n="">EventHandler</c-></a> <a href="#handler-onwebkittransitionend" id="idl-definitions:handler-onwebkittransitionend"><c- g="">onwebkittransitionend</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-75"><c- n="">EventHandler</c-></a> <a href="#handler-onwheel" id="idl-definitions:handler-onwheel"><c- g="">onwheel</c-></a>;
};

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="windoweventhandlers" data-dfn-type="interface"><c- g="">WindowEventHandlers</c-></dfn> {
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-76"><c- n="">EventHandler</c-></a> <a href="#handler-window-onafterprint" id="idl-definitions:handler-window-onafterprint"><c- g="">onafterprint</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-77"><c- n="">EventHandler</c-></a> <a href="#handler-window-onbeforeprint" id="idl-definitions:handler-window-onbeforeprint"><c- g="">onbeforeprint</c-></a>;
  <c- b="">attribute</c-> <a href="#onbeforeunloadeventhandler" id="idl-definitions:onbeforeunloadeventhandler"><c- n="">OnBeforeUnloadEventHandler</c-></a> <a href="#handler-window-onbeforeunload" id="idl-definitions:handler-window-onbeforeunload"><c- g="">onbeforeunload</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-78"><c- n="">EventHandler</c-></a> <a href="#handler-window-onhashchange" id="idl-definitions:handler-window-onhashchange"><c- g="">onhashchange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-79"><c- n="">EventHandler</c-></a> <a href="#handler-window-onlanguagechange" id="idl-definitions:handler-window-onlanguagechange"><c- g="">onlanguagechange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-80"><c- n="">EventHandler</c-></a> <a href="#handler-window-onmessage" id="idl-definitions:handler-window-onmessage"><c- g="">onmessage</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-81"><c- n="">EventHandler</c-></a> <a href="#handler-window-onmessageerror" id="idl-definitions:handler-window-onmessageerror"><c- g="">onmessageerror</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-82"><c- n="">EventHandler</c-></a> <a href="#handler-window-onoffline" id="idl-definitions:handler-window-onoffline"><c- g="">onoffline</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-83"><c- n="">EventHandler</c-></a> <a href="#handler-window-ononline" id="idl-definitions:handler-window-ononline"><c- g="">ononline</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-84"><c- n="">EventHandler</c-></a> <a href="#handler-window-onpagehide" id="idl-definitions:handler-window-onpagehide"><c- g="">onpagehide</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-85"><c- n="">EventHandler</c-></a> <a href="#handler-window-onpagereveal" id="idl-definitions:handler-window-onpagereveal"><c- g="">onpagereveal</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-86"><c- n="">EventHandler</c-></a> <a href="#handler-window-onpageshow" id="idl-definitions:handler-window-onpageshow"><c- g="">onpageshow</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-87"><c- n="">EventHandler</c-></a> <a href="#handler-window-onpageswap" id="idl-definitions:handler-window-onpageswap"><c- g="">onpageswap</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-88"><c- n="">EventHandler</c-></a> <a href="#handler-window-onpopstate" id="idl-definitions:handler-window-onpopstate"><c- g="">onpopstate</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-89"><c- n="">EventHandler</c-></a> <a href="#handler-window-onrejectionhandled" id="idl-definitions:handler-window-onrejectionhandled"><c- g="">onrejectionhandled</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-90"><c- n="">EventHandler</c-></a> <a href="#handler-window-onstorage" id="idl-definitions:handler-window-onstorage"><c- g="">onstorage</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-91"><c- n="">EventHandler</c-></a> <a href="#handler-window-onunhandledrejection" id="idl-definitions:handler-window-onunhandledrejection"><c- g="">onunhandledrejection</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="idl-definitions:eventhandler-92"><c- n="">EventHandler</c-></a> <a href="#handler-window-onunload" id="idl-definitions:handler-window-onunload"><c- g="">onunload</c-></a>;
};</code></pre>

  <h5 id="event-firing"><span class="secno">8.1.8.3</span> Event firing<a href="#event-firing" class="self-link"></a></h5>

  <p>Certain operations and methods are defined as firing events on elements. For example, the <code id="event-firing:dom-click"><a href="#dom-click">click()</a></code> method on the <code id="event-firing:htmlelement"><a href="#htmlelement">HTMLElement</a></code> interface is defined as
  firing a <code id="event-firing:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event on the element. <a href="#refsUIEVENTS">[UIEVENTS]</a></p>

  <div data-algorithm="">
  <p><dfn id="fire-a-synthetic-pointer-event">Firing a synthetic pointer event named
  <var>e</var></dfn> at <var>target</var>, with an optional <var>not trusted flag</var>, means
  running these steps:</p>

  <ol><li><p>Let <var>event</var> be the result of <a id="event-firing:creating-an-event" href="https://dom.spec.whatwg.org/#concept-event-create" data-x-internal="creating-an-event">creating an event</a> using
   <code id="event-firing:pointerevent"><a data-x-internal="pointerevent" href="https://w3c.github.io/pointerevents/#pointerevent-interface">PointerEvent</a></code>.</p></li><li><p>Initialize <var>event</var>'s <code id="event-firing:dom-event-type"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute to
   <var>e</var>.</p></li><li><p>Initialize <var>event</var>'s <code id="event-firing:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> and <code id="event-firing:dom-event-cancelable"><a data-x-internal="dom-event-cancelable" href="https://dom.spec.whatwg.org/#dom-event-cancelable">cancelable</a></code> attributes to true.</p></li><li><p>Set <var>event</var>'s <a id="event-firing:composed-flag" href="https://dom.spec.whatwg.org/#composed-flag" data-x-internal="composed-flag">composed flag</a>.</p></li><li><p>If the <var>not trusted flag</var> is set, initialize <var>event</var>'s <code id="event-firing:dom-event-istrusted"><a data-x-internal="dom-event-istrusted" href="https://dom.spec.whatwg.org/#dom-event-istrusted">isTrusted</a></code> attribute to false.</p></li><li><p>Initialize <var>event</var>'s <code>ctrlKey</code>, <code>shiftKey</code>, <code>altKey</code>, and <code>metaKey</code>
   attributes according to the current state of the key input device, if any (false for any keys
   that are not available).</p></li><li><p>Initialize <var>event</var>'s <code id="event-firing:dom-uievent-view"><a data-x-internal="dom-uievent-view" href="https://w3c.github.io/uievents/#dom-uievent-view">view</a></code> attribute to
   <var>target</var>'s <a id="event-firing:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <code id="event-firing:window"><a href="#window">Window</a></code> object, if any, and null
   otherwise.</p></li><li><p><var>event</var>'s <code>getModifierState()</code> method is to return values
   appropriately describing the current state of the key input device.</p></li><li><p>Return the result of <a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="event-firing:concept-event-dispatch" data-x-internal="concept-event-dispatch">dispatching</a>
   <var>event</var> at <var>target</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p><dfn id="fire-a-click-event">Firing a <code>click</code> event</dfn>
  at <var>target</var> means <a href="#fire-a-synthetic-pointer-event" id="event-firing:fire-a-synthetic-pointer-event">firing a synthetic
  pointer event named <code>click</code></a> at <var>target</var>.</p>
  </div>

  


  <h3 id="windoworworkerglobalscope-mixin"><span class="secno">8.2</span> The <code id="windoworworkerglobalscope-mixin:windoworworkerglobalscope"><a href="#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a></code> mixin<a href="#windoworworkerglobalscope-mixin" class="self-link"></a></h3>

  <p>The <code id="windoworworkerglobalscope-mixin:windoworworkerglobalscope-2"><a href="#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a></code> mixin is for use of APIs that are to be exposed on
  <code id="windoworworkerglobalscope-mixin:window"><a href="#window">Window</a></code> and <code id="windoworworkerglobalscope-mixin:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> objects.</p>

  <p class="note">Other standards are encouraged to further extend it using <code>partial
  interface mixin <a href="#windoworworkerglobalscope" id="windoworworkerglobalscope-mixin:windoworworkerglobalscope-3">WindowOrWorkerGlobalScope</a> { … };</code> along with an
  appropriate reference.</p>

  <pre><code class="idl"><c- b="">typedef</c-> (<c- b="">DOMString</c-> <c- b="">or</c-> <a href="https://webidl.spec.whatwg.org/#common-Function" id="windoworworkerglobalscope-mixin:idl-function" data-x-internal="idl-function"><c- n="">Function</c-></a> <c- b="">or</c-> <a href="https://w3c.github.io/trusted-types/dist/spec/#trusted-script" id="windoworworkerglobalscope-mixin:tt-trustedscript" data-x-internal="tt-trustedscript"><c- n="">TrustedScript</c-></a>) <dfn id="timerhandler" data-dfn-type="typedef"><c- g="">TimerHandler</c-></dfn>;

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="windoworworkerglobalscope" data-dfn-type="interface"><c- g="">WindowOrWorkerGlobalScope</c-></dfn> {
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-origin" id="windoworworkerglobalscope-mixin:dom-origin"><c- g="">origin</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-issecurecontext" id="windoworworkerglobalscope-mixin:dom-issecurecontext"><c- g="">isSecureContext</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-crossoriginisolated" id="windoworworkerglobalscope-mixin:dom-crossoriginisolated"><c- g="">crossOriginIsolated</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-reporterror" id="windoworworkerglobalscope-mixin:dom-reporterror"><c- g="">reportError</c-></a>(<c- b="">any</c-> <c- g="">e</c->);

  // base64 utility methods
  <c- b="">DOMString</c-> <a href="#dom-btoa" id="windoworworkerglobalscope-mixin:dom-btoa"><c- g="">btoa</c-></a>(<c- b="">DOMString</c-> <c- g="">data</c->);
  <c- b="">ByteString</c-> <a href="#dom-atob" id="windoworworkerglobalscope-mixin:dom-atob"><c- g="">atob</c-></a>(<c- b="">DOMString</c-> <c- g="">data</c->);

  // timers
  <c- b="">long</c-> <a href="#dom-settimeout" id="windoworworkerglobalscope-mixin:dom-settimeout"><c- g="">setTimeout</c-></a>(<a href="#timerhandler" id="windoworworkerglobalscope-mixin:timerhandler"><c- n="">TimerHandler</c-></a> <c- g="">handler</c->, <c- b="">optional</c-> <c- b="">long</c-> <c- g="">timeout</c-> = 0, <c- b="">any</c->... <c- g="">arguments</c->);
  <c- b="">undefined</c-> <a href="#dom-cleartimeout" id="windoworworkerglobalscope-mixin:dom-cleartimeout"><c- g="">clearTimeout</c-></a>(<c- b="">optional</c-> <c- b="">long</c-> <c- g="">id</c-> = 0);
  <c- b="">long</c-> <a href="#dom-setinterval" id="windoworworkerglobalscope-mixin:dom-setinterval"><c- g="">setInterval</c-></a>(<a href="#timerhandler" id="windoworworkerglobalscope-mixin:timerhandler-2"><c- n="">TimerHandler</c-></a> <c- g="">handler</c->, <c- b="">optional</c-> <c- b="">long</c-> <c- g="">timeout</c-> = 0, <c- b="">any</c->... <c- g="">arguments</c->);
  <c- b="">undefined</c-> <a href="#dom-clearinterval" id="windoworworkerglobalscope-mixin:dom-clearinterval"><c- g="">clearInterval</c-></a>(<c- b="">optional</c-> <c- b="">long</c-> <c- g="">id</c-> = 0);

  // microtask queuing
  <c- b="">undefined</c-> <a href="#dom-queuemicrotask" id="windoworworkerglobalscope-mixin:dom-queuemicrotask"><c- g="">queueMicrotask</c-></a>(<a href="https://webidl.spec.whatwg.org/#VoidFunction" id="windoworworkerglobalscope-mixin:idl-voidfunction" data-x-internal="idl-voidfunction"><c- n="">VoidFunction</c-></a> <c- g="">callback</c->);

  // ImageBitmap
  <a href="https://webidl.spec.whatwg.org/#idl-promise" id="windoworworkerglobalscope-mixin:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<a href="#imagebitmap" id="windoworworkerglobalscope-mixin:imagebitmap"><c- n="">ImageBitmap</c-></a>&gt; <a href="#dom-createimagebitmap" id="windoworworkerglobalscope-mixin:dom-createimagebitmap"><c- g="">createImageBitmap</c-></a>(<a href="#imagebitmapsource" id="windoworworkerglobalscope-mixin:imagebitmapsource"><c- n="">ImageBitmapSource</c-></a> <c- g="">image</c->, <c- b="">optional</c-> <a href="#imagebitmapoptions" id="windoworworkerglobalscope-mixin:imagebitmapoptions"><c- n="">ImageBitmapOptions</c-></a> <c- g="">options</c-> = {});
  <a href="https://webidl.spec.whatwg.org/#idl-promise" id="windoworworkerglobalscope-mixin:idl-promise-2" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<a href="#imagebitmap" id="windoworworkerglobalscope-mixin:imagebitmap-2"><c- n="">ImageBitmap</c-></a>&gt; <a href="#dom-createimagebitmap" id="windoworworkerglobalscope-mixin:dom-createimagebitmap-2"><c- g="">createImageBitmap</c-></a>(<a href="#imagebitmapsource" id="windoworworkerglobalscope-mixin:imagebitmapsource-2"><c- n="">ImageBitmapSource</c-></a> <c- g="">image</c->, <c- b="">long</c-> <c- g="">sx</c->, <c- b="">long</c-> <c- g="">sy</c->, <c- b="">long</c-> <c- g="">sw</c->, <c- b="">long</c-> <c- g="">sh</c->, <c- b="">optional</c-> <a href="#imagebitmapoptions" id="windoworworkerglobalscope-mixin:imagebitmapoptions-2"><c- n="">ImageBitmapOptions</c-></a> <c- g="">options</c-> = {});

  // structured cloning
  <c- b="">any</c-> <a href="#dom-structuredclone" id="windoworworkerglobalscope-mixin:dom-structuredclone"><c- g="">structuredClone</c-></a>(<c- b="">any</c-> <c- g="">value</c->, <c- b="">optional</c-> <a href="#structuredserializeoptions" id="windoworworkerglobalscope-mixin:structuredserializeoptions"><c- n="">StructuredSerializeOptions</c-></a> <c- g="">options</c-> = {});
};
<a href="#window" id="windoworworkerglobalscope-mixin:window-2"><c- n="">Window</c-></a> <c- b="">includes</c-> <a href="#windoworworkerglobalscope" id="windoworworkerglobalscope-mixin:windoworworkerglobalscope-4"><c- n="">WindowOrWorkerGlobalScope</c-></a>;
<a href="#workerglobalscope" id="windoworworkerglobalscope-mixin:workerglobalscope-2"><c- n="">WorkerGlobalScope</c-></a> <c- b="">includes</c-> <a href="#windoworworkerglobalscope" id="windoworworkerglobalscope-mixin:windoworworkerglobalscope-5"><c- n="">WindowOrWorkerGlobalScope</c-></a>;</code></pre>

  <dl class="domintro"><dt><code>self.<a href="#dom-issecurecontext" id="dom-issecurecontext-dev">isSecureContext</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/isSecureContext" title="The global isSecureContext read-only property returns a boolean indicating whether the current context is secure (true) or not (false).">isSecureContext</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>47+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>15+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns whether or not this global object represents a <a href="#secure-context" id="windoworworkerglobalscope-mixin:secure-context">secure context</a>.
   <a href="#refsSECURE-CONTEXTS">[SECURE-CONTEXTS]</a></p></dd><dt><code>self.<a href="#dom-origin" id="dom-origin-dev">origin</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/origin" title="The global origin read-only property returns the origin of the global scope, serialized as a string.">origin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>54+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>59+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the global object's <a href="#concept-origin" id="windoworworkerglobalscope-mixin:concept-origin">origin</a>, serialized as string.</p></dd><dt><code>self.<a href="#dom-crossoriginisolated" id="dom-crossoriginisolated-dev">crossOriginIsolated</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/crossOriginIsolated" title="The global crossOriginIsolated read-only property returns a boolean value that indicates whether the website is in a cross-origin isolation state. That state mitigates the risk of side-channel attacks and unlocks a few capabilities:">crossOriginIsolated</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>72+</span></span><span class="safari yes"><span>Safari</span><span>15.2+</span></span><span class="chrome yes"><span>Chrome</span><span>87+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>87+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns whether scripts running in this global are allowed to use APIs that require
   cross-origin isolation. This depends on the `<code id="windoworworkerglobalscope-mixin:cross-origin-opener-policy-2"><a href="#cross-origin-opener-policy-2">Cross-Origin-Opener-Policy</a></code>` and
   `<code id="windoworworkerglobalscope-mixin:cross-origin-embedder-policy"><a href="#cross-origin-embedder-policy">Cross-Origin-Embedder-Policy</a></code>` HTTP response headers and the "<code id="windoworworkerglobalscope-mixin:cross-origin-isolated-feature"><a href="#cross-origin-isolated-feature">cross-origin-isolated</a></code>" feature.</p></dd></dl>

  <div class="example">
   <p>Developers are strongly encouraged to use <code>self.origin</code> over <code>location.origin</code>. The former returns the <a href="#concept-origin" id="windoworworkerglobalscope-mixin:concept-origin-2">origin</a> of the environment,
   the latter of the URL of the environment. Imagine the following script executing in a document on
   <code>https://stargate.example/</code>:</p>

   <pre><code class="js"><c- a="">var</c-> frame <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"iframe"</c-><c- p="">)</c->
frame<c- p="">.</c->onload <c- o="">=</c-> <c- a="">function</c-><c- p="">()</c-> <c- p="">{</c->
  <c- a="">var</c-> frameWin <c- o="">=</c-> frame<c- p="">.</c->contentWindow
  console<c- p="">.</c->log<c- p="">(</c->frameWin<c- p="">.</c->location<c- p="">.</c->origin<c- p="">)</c-> <c- c1="">// "null"</c->
  console<c- p="">.</c->log<c- p="">(</c->frameWin<c- p="">.</c->origin<c- p="">)</c-> <c- c1="">// "https://stargate.example"</c->
<c- p="">}</c->
document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->frame<c- p="">)</c-></code></pre>

   <p><code>self.origin</code> is a more reliable security indicator.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-issecurecontext" data-dfn-type="attribute"><code>isSecureContext</code></dfn> getter steps are to return true if
  <a id="windoworworkerglobalscope-mixin:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="windoworworkerglobalscope-mixin:relevant-settings-object">relevant settings object</a> is a <a href="#secure-context" id="windoworworkerglobalscope-mixin:secure-context-2">secure context</a>, or
  false otherwise.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-origin" data-dfn-type="attribute"><code>origin</code></dfn> getter steps are to return <a id="windoworworkerglobalscope-mixin:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#relevant-settings-object" id="windoworworkerglobalscope-mixin:relevant-settings-object-2">relevant settings object</a>'s <a href="#concept-settings-object-origin" id="windoworworkerglobalscope-mixin:concept-settings-object-origin">origin</a>, <a href="#ascii-serialisation-of-an-origin" id="windoworworkerglobalscope-mixin:ascii-serialisation-of-an-origin">serialized</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-crossoriginisolated" data-dfn-type="attribute"><code>crossOriginIsolated</code></dfn> getter steps are to return
  <a id="windoworworkerglobalscope-mixin:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="windoworworkerglobalscope-mixin:relevant-settings-object-3">relevant settings object</a>'s <a href="#concept-settings-object-cross-origin-isolated-capability" id="windoworworkerglobalscope-mixin:concept-settings-object-cross-origin-isolated-capability">cross-origin isolated
  capability</a>.</p>
  </div>

  


  <h3 id="atob"><span class="secno">8.3</span> Base64 utility methods<a href="#atob" class="self-link"></a></h3>

  <p>The <code id="atob:dom-atob"><a href="#dom-atob">atob()</a></code> and <code id="atob:dom-btoa"><a href="#dom-btoa">btoa()</a></code> methods
  allow developers to transform content to and from the base64 encoding.</p>

  <p class="note">In these APIs, for mnemonic purposes, the "b" can be considered to stand for
  "binary", and the "a" for "ASCII". In practice, though, for primarily historical reasons, both the
  input and output of these functions are Unicode strings.</p>

  <dl class="domintro"><dt><code><var>result</var> = self.<a href="#dom-btoa" id="dom-btoa-dev">btoa</a>(<var>data</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/btoa" title="The btoa() method creates a Base64-encoded ASCII string from a binary string (i.e., a string in which each character in the string is treated as a byte of binary data).">btoa</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>Takes the input data, in the form of a Unicode string containing only characters in the range
    U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF respectively, and
    converts it to its base64 representation, which it returns.</p>

    <p>Throws an <a id="atob:invalidcharactererror" href="https://webidl.spec.whatwg.org/#invalidcharactererror" data-x-internal="invalidcharactererror">"<code>InvalidCharacterError</code>"</a> <code id="atob:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>
    if the input string contains any out-of-range characters.</p>
   </dd><dt><code><var>result</var> = self.<a href="#dom-atob" id="dom-atob-dev">atob</a>(<var>data</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/atob" title="The atob() function decodes a string of data which has been encoded using Base64 encoding. You can use the btoa() method to encode and transmit data which may otherwise cause communication problems, then transmit it and use the atob() method to decode the data again. For example, you can encode, transmit, and decode control characters such as ASCII values 0 through 31.">atob</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>Takes the input data, in the form of a Unicode string containing base64-encoded binary data,
    decodes it, and returns a string consisting of characters in the range U+0000 to U+00FF, each
    representing a binary byte with values 0x00 to 0xFF respectively, corresponding to that binary
    data.</p>

    <p>Throws an <a id="atob:invalidcharactererror-2" href="https://webidl.spec.whatwg.org/#invalidcharactererror" data-x-internal="invalidcharactererror">"<code>InvalidCharacterError</code>"</a> <code id="atob:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    input string is not valid base64 data.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-btoa" data-dfn-type="method"><code id="dom-windowbase64-btoa">btoa(<var>data</var>)</code></dfn> method must throw an
  <a id="atob:invalidcharactererror-3" href="https://webidl.spec.whatwg.org/#invalidcharactererror" data-x-internal="invalidcharactererror">"<code>InvalidCharacterError</code>"</a> <code id="atob:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if <var>data</var>
  contains any character whose code point is greater than U+00FF. Otherwise, the user agent must
  convert <var>data</var> to a byte sequence whose <var>n</var>th byte is the eight-bit
  representation of the <var>n</var>th code point of <var>data</var>, and then must apply
  <a id="atob:forgiving-base64-encode" href="https://infra.spec.whatwg.org/#forgiving-base64-encode" data-x-internal="forgiving-base64-encode">forgiving-base64 encode</a> to that byte sequence and return the result.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-atob" data-dfn-type="method"><code id="dom-windowbase64-atob">atob(<var>data</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>decodedData</var> be the result of running <a id="atob:forgiving-base64-decode" href="https://infra.spec.whatwg.org/#forgiving-base64-decode" data-x-internal="forgiving-base64-decode">forgiving-base64 decode</a>
   on <var>data</var>.</p></li><li><p>If <var>decodedData</var> is failure, then throw an
   <a id="atob:invalidcharactererror-4" href="https://webidl.spec.whatwg.org/#invalidcharactererror" data-x-internal="invalidcharactererror">"<code>InvalidCharacterError</code>"</a> <code id="atob:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return <var>decodedData</var>.</p></li></ol>
  </div>

  


  <h3 id="dynamic-markup-insertion"><span class="secno">8.4</span> <dfn>Dynamic markup insertion</dfn><a href="#dynamic-markup-insertion" class="self-link"></a></h3>

  <p class="note">APIs for dynamically inserting markup into the document interact with the parser,
  and thus their behavior varies depending on whether they are used with <a id="dynamic-markup-insertion:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML
  documents</a> (and the <a href="#html-parser" id="dynamic-markup-insertion:html-parser">HTML parser</a>) or <a id="dynamic-markup-insertion:xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a> (and the
  <a href="#xml-parser" id="dynamic-markup-insertion:xml-parser">XML parser</a>).</p>

  

  <p><code id="dynamic-markup-insertion:document"><a href="#document">Document</a></code> objects have a <dfn id="throw-on-dynamic-markup-insertion-counter">throw-on-dynamic-markup-insertion counter</dfn>,
  which is used in conjunction with the <a href="#create-an-element-for-the-token" id="dynamic-markup-insertion:create-an-element-for-the-token">create an element for the token</a> algorithm to
  prevent <a href="#custom-element-constructor" id="dynamic-markup-insertion:custom-element-constructor">custom element constructors</a> from being
  able to use <code id="dynamic-markup-insertion:dom-document-open"><a href="#dom-document-open">document.open()</a></code>, <code id="dynamic-markup-insertion:dom-document-close"><a href="#dom-document-close">document.close()</a></code>, and <code id="dynamic-markup-insertion:dom-document-write"><a href="#dom-document-write">document.write()</a></code> when they are invoked by the parser.
  Initially, the counter must be set to zero.</p>

  



  <h4 id="opening-the-input-stream"><span class="secno">8.4.1</span> Opening the input stream<a href="#opening-the-input-stream" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>document</var> = <var>document</var>.<a href="#dom-document-open" id="dom-document-open-dev">open</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/open" title="The Document.open() method opens a document for writing.">Document/open</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera yes"><span>Opera</span><span>51+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></dt><dd>
    <p>Causes the <code id="opening-the-input-stream:document"><a href="#document">Document</a></code> to be replaced in-place, as if it was a new
    <code id="opening-the-input-stream:document-2"><a href="#document">Document</a></code> object, but reusing the previous object, which is then returned.</p>

    <p>The resulting <code id="opening-the-input-stream:document-3"><a href="#document">Document</a></code> has an HTML parser associated with it, which can be given
    data to parse using <code id="opening-the-input-stream:dom-document-write"><a href="#dom-document-write">document.write()</a></code>.</p>

    <p>The method has no effect if the <code id="opening-the-input-stream:document-4"><a href="#document">Document</a></code> is still being parsed.</p>

    <p>Throws an <a id="opening-the-input-stream:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="opening-the-input-stream:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    <code id="opening-the-input-stream:document-5"><a href="#document">Document</a></code> is an <a href="https://dom.spec.whatwg.org/#xml-document" id="opening-the-input-stream:xml-documents" data-x-internal="xml-documents">XML document</a>.</p>

    <p>Throws an <a id="opening-the-input-stream:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="opening-the-input-stream:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    parser is currently executing a <a href="#custom-element-constructor" id="opening-the-input-stream:custom-element-constructor">custom element constructor</a>.</p>
   </dd><dt><code><var>window</var> = <var>document</var>.<a href="#dom-document-open-window" id="opening-the-input-stream:dom-document-open-window">open</a>(<var>url</var>, <var>name</var>, <var>features</var>)</code></dt><dd><p>Works like the <code id="opening-the-input-stream:dom-open"><a href="#dom-open">window.open()</a></code> method.</p></dd></dl>

  

  <p><code id="opening-the-input-stream:document-6"><a href="#document">Document</a></code> objects have an <dfn id="active-parser-was-aborted">active parser was aborted</dfn> boolean, which is
  used to prevent scripts from invoking the <code id="opening-the-input-stream:dom-document-open"><a href="#dom-document-open">document.open()</a></code>
  and <code id="opening-the-input-stream:dom-document-write-2"><a href="#dom-document-write">document.write()</a></code> methods (directly or indirectly)
  after the document's <a href="#active-parser" id="opening-the-input-stream:active-parser">active parser</a> has been aborted. It is initially false.</p>

  <div data-algorithm="">
  <p>The <dfn id="document-open-steps">document open steps</dfn>, given a <var>document</var>, are as follows:</p>

  <ol><li><p>If <var>document</var> is an <a href="https://dom.spec.whatwg.org/#xml-document" id="opening-the-input-stream:xml-documents-2" data-x-internal="xml-documents">XML document</a>, then throw
   an <a id="opening-the-input-stream:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="opening-the-input-stream:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>document</var>'s <a href="#throw-on-dynamic-markup-insertion-counter" id="opening-the-input-stream:throw-on-dynamic-markup-insertion-counter">throw-on-dynamic-markup-insertion counter</a> is greater
   than 0, then throw an <a id="opening-the-input-stream:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="opening-the-input-stream:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>entryDocument</var> be the <a href="#entry-global-object" id="opening-the-input-stream:entry-global-object">entry global object</a>'s <a href="#concept-document-window" id="opening-the-input-stream:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="opening-the-input-stream:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is not
   <a href="#same-origin" id="opening-the-input-stream:same-origin">same origin</a> to <var>entryDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="opening-the-input-stream:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a>, then throw a
   <a id="opening-the-input-stream:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="opening-the-input-stream:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p>If <var>document</var> has an <a href="#active-parser" id="opening-the-input-stream:active-parser-2">active parser</a> whose <a href="#script-nesting-level" id="opening-the-input-stream:script-nesting-level">script nesting
    level</a> is greater than 0, then return <var>document</var>.</p>

    <p class="note">This basically causes <code id="opening-the-input-stream:dom-document-open-2"><a href="#dom-document-open">document.open()</a></code> to
    be ignored when it's called in an inline script found during parsing, while still letting it
    have an effect when called from a non-parser task such as a timer callback or event handler.</p>
   </li><li>
    <p>Similarly, if <var>document</var>'s <a href="#unload-counter" id="opening-the-input-stream:unload-counter">unload counter</a> is greater than 0, then
    return <var>document</var>.</p>

    <p class="note">This basically causes <code id="opening-the-input-stream:dom-document-open-3"><a href="#dom-document-open">document.open()</a></code> to
    be ignored when it's called from a <code id="opening-the-input-stream:event-beforeunload"><a href="#event-beforeunload">beforeunload</a></code>, <code id="opening-the-input-stream:event-pagehide"><a href="#event-pagehide">pagehide</a></code>, or <code id="opening-the-input-stream:event-unload"><a href="#event-unload">unload</a></code> event
    handler while the <code id="opening-the-input-stream:document-7"><a href="#document">Document</a></code> is being unloaded.</p>
   </li><li>
    <p>If <var>document</var>'s <a href="#active-parser-was-aborted" id="opening-the-input-stream:active-parser-was-aborted">active parser was aborted</a> is true, then return
    <var>document</var>.</p>

    <p class="note">This notably causes <code id="opening-the-input-stream:dom-document-open-4"><a href="#dom-document-open">document.open()</a></code> to
    be ignored if it is called after a <a href="#navigate" id="opening-the-input-stream:navigate">navigation</a> has started, but
    only during the initial parse. See <a href="https://github.com/whatwg/html/issues/4723">issue
    #4723</a> for more background.</p>
   </li><li><p>If <var>document</var>'s <a href="#node-navigable" id="opening-the-input-stream:node-navigable">node navigable</a> is non-null and
   <var>document</var>'s <a href="#node-navigable" id="opening-the-input-stream:node-navigable-2">node navigable</a>'s <a href="#ongoing-navigation" id="opening-the-input-stream:ongoing-navigation">ongoing navigation</a> is a
   <a href="#navigation-id" id="opening-the-input-stream:navigation-id">navigation ID</a>, then <a href="#nav-stop" id="opening-the-input-stream:nav-stop">stop loading</a>
   <var>document</var>'s <a href="#node-navigable" id="opening-the-input-stream:node-navigable-3">node navigable</a>.</p></li><li><p>For each <a id="opening-the-input-stream:shadow-including-inclusive-descendant" href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant" data-x-internal="shadow-including-inclusive-descendant">shadow-including inclusive descendant</a> <var>node</var> of
   <var>document</var>, <a href="#erase-all-event-listeners-and-handlers" id="opening-the-input-stream:erase-all-event-listeners-and-handlers">erase all event listeners and handlers</a> given
   <var>node</var>.</p></li><li><p>If <var>document</var> is the <a href="#concept-document-window" id="opening-the-input-stream:concept-document-window-2">associated
   <code>Document</code></a> of <var>document</var>'s <a href="#concept-relevant-global" id="opening-the-input-stream:concept-relevant-global">relevant global object</a>, then
   <a href="#erase-all-event-listeners-and-handlers" id="opening-the-input-stream:erase-all-event-listeners-and-handlers-2">erase all event listeners and handlers</a> given <var>document</var>'s <a href="#concept-relevant-global" id="opening-the-input-stream:concept-relevant-global-2">relevant
   global object</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-replace-all" id="opening-the-input-stream:concept-node-replace-all" data-x-internal="concept-node-replace-all">Replace all</a> with null within
   <var>document</var>.</p></li><li>
    <p>If <var>document</var> is <a href="#fully-active" id="opening-the-input-stream:fully-active">fully active</a>, then:</p>

    <ol><li><p>Let <var>newURL</var> be a copy of <var>entryDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="opening-the-input-stream:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li><p>If <var>entryDocument</var> is not <var>document</var>, then set <var>newURL</var>'s
     <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="opening-the-input-stream:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> to null.</p></li><li><p>Run the <a href="#url-and-history-update-steps" id="opening-the-input-stream:url-and-history-update-steps">URL and history update steps</a> with <var>document</var> and
     <var>newURL</var>.</p></li></ol>
   </li><li><p>Set <var>document</var>'s <a href="#is-initial-about:blank" id="opening-the-input-stream:is-initial-about:blank">is initial <code>about:blank</code></a> to
   false.</p></li><li><p>If <var>document</var>'s <a href="#iframe-load-in-progress" id="opening-the-input-stream:iframe-load-in-progress">iframe load in progress</a> flag is set, then set
   <var>document</var>'s <a href="#mute-iframe-load" id="opening-the-input-stream:mute-iframe-load">mute iframe load</a> flag.</p></li><li><p>Set <var>document</var> to <a id="opening-the-input-stream:no-quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-no-quirks" data-x-internal="no-quirks-mode">no-quirks mode</a>.</p></li><li><p>Create a new <a href="#html-parser" id="opening-the-input-stream:html-parser">HTML parser</a> and associate it with <var>document</var>. This is a
   <dfn id="script-created-parser">script-created parser</dfn> (meaning that it can be closed by the <code id="opening-the-input-stream:dom-document-open-5"><a href="#dom-document-open">document.open()</a></code> and <code id="opening-the-input-stream:dom-document-close"><a href="#dom-document-close">document.close()</a></code> methods, and that the tokenizer will wait for
   an explicit call to <code id="opening-the-input-stream:dom-document-close-2"><a href="#dom-document-close">document.close()</a></code> before emitting an
   end-of-file token). The encoding <a href="#concept-encoding-confidence" id="opening-the-input-stream:concept-encoding-confidence">confidence</a> is
   <i>irrelevant</i>.</p></li><li><p>Set the <a href="#insertion-point" id="opening-the-input-stream:insertion-point">insertion point</a> to point at just before the end of the <a href="#input-stream" id="opening-the-input-stream:input-stream">input
   stream</a> (which at this point will be empty).</p></li><li>
    <p><a href="#update-the-current-document-readiness" id="opening-the-input-stream:update-the-current-document-readiness">Update the current document readiness</a> of <var>document</var> to "<code>loading</code>".</p>

    <p class="note">This causes a <code id="opening-the-input-stream:event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code>
    event to fire, but the event is actually unobservable to author code, because of the previous
    step which <a href="#erase-all-event-listeners-and-handlers" id="opening-the-input-stream:erase-all-event-listeners-and-handlers-3">erased all event listeners and
    handlers</a> that could observe it.</p>
   </li><li><p>Return <var>document</var>.</p></li></ol>
  </div>

  <p class="note">The <a href="#document-open-steps" id="opening-the-input-stream:document-open-steps">document open steps</a> do not affect whether a <code id="opening-the-input-stream:document-8"><a href="#document">Document</a></code>
  is <a href="#ready-for-post-load-tasks" id="opening-the-input-stream:ready-for-post-load-tasks">ready for post-load tasks</a> or <a href="#completely-loaded" id="opening-the-input-stream:completely-loaded">completely loaded</a>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-open" data-dfn-type="method"><code>open(<var>unused1</var>,
  <var>unused2</var>)</code></dfn> method must return the result of running the <a href="#document-open-steps" id="opening-the-input-stream:document-open-steps-2">document open
  steps</a> with <a id="opening-the-input-stream:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>

  <p id="dom-document-open-unused-arguments" class="note"><a href="#dom-document-open-unused-arguments" class="self-link"></a>The <var>unused1</var> and
  <var>unused2</var> arguments are ignored, but kept in the IDL to allow code that calls the
  function with one or two arguments to continue working. They are necessary due to Web IDL
  <a id="opening-the-input-stream:overload-resolution-algorithm" href="https://webidl.spec.whatwg.org/#dfn-overload-resolution-algorithm" data-x-internal="overload-resolution-algorithm">overload resolution algorithm</a> rules, which would throw a <code id="opening-the-input-stream:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code>
  exception for such calls had the arguments not been there. <a href="https://github.com/whatwg/webidl/issues/581">whatwg/webidl issue #581</a> investigates
  changing the algorithm to allow for their removal. <a href="#refsWEBIDL">[WEBIDL]</a></p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-open-window" data-dfn-type="method"><code>open(<var>url</var>,
  <var>name</var>, <var>features</var>)</code></dfn> method must run these steps:</p>

  <ol><li><p>If <a id="opening-the-input-stream:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is not <a href="#fully-active" id="opening-the-input-stream:fully-active-2">fully active</a>, then throw an
   <a id="opening-the-input-stream:invalidaccesserror" href="https://webidl.spec.whatwg.org/#invalidaccesserror" data-x-internal="invalidaccesserror">"<code>InvalidAccessError</code>"</a> <code id="opening-the-input-stream:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return the result of running the <a href="#window-open-steps" id="opening-the-input-stream:window-open-steps">window open steps</a> with <var>url</var>,
   <var>name</var>, and <var>features</var>.</p></li></ol>
  </div>

  



  <h4 id="closing-the-input-stream"><span class="secno">8.4.2</span> Closing the input stream<a href="#closing-the-input-stream" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-close" id="dom-document-close-dev">close</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/close" title="The Document.close() method finishes writing to a document, opened with Document.open().">Document/close</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera yes"><span>Opera</span><span>51+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></dt><dd>
    <p>Closes the input stream that was opened by the <code id="closing-the-input-stream:dom-document-open"><a href="#dom-document-open">document.open()</a></code> method.</p>

    <p>Throws an <a id="closing-the-input-stream:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="closing-the-input-stream:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    <code id="closing-the-input-stream:document"><a href="#document">Document</a></code> is an <a href="https://dom.spec.whatwg.org/#xml-document" id="closing-the-input-stream:xml-documents" data-x-internal="xml-documents">XML document</a>.</p>

    <p>Throws an <a id="closing-the-input-stream:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="closing-the-input-stream:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    parser is currently executing a <a href="#custom-element-constructor" id="closing-the-input-stream:custom-element-constructor">custom element constructor</a>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-close" data-dfn-type="method"><code>close()</code></dfn> method must run the following
  steps:</p>

  <ol><li><p>If <a id="closing-the-input-stream:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is an <a href="https://dom.spec.whatwg.org/#xml-document" id="closing-the-input-stream:xml-documents-2" data-x-internal="xml-documents">XML document</a>, then throw
   an <a id="closing-the-input-stream:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="closing-the-input-stream:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <a id="closing-the-input-stream:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#throw-on-dynamic-markup-insertion-counter" id="closing-the-input-stream:throw-on-dynamic-markup-insertion-counter">throw-on-dynamic-markup-insertion counter</a> is greater
   than zero, then throw an <a id="closing-the-input-stream:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="closing-the-input-stream:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If there is no <a href="#script-created-parser" id="closing-the-input-stream:script-created-parser">script-created parser</a> associated with <a id="closing-the-input-stream:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, then
   return.</p></li><li><p>Insert an <a href="#explicit-eof-character" id="closing-the-input-stream:explicit-eof-character">explicit "EOF" character</a> at the end of the parser's <a href="#input-stream" id="closing-the-input-stream:input-stream">input
   stream</a>.</p></li><li><p>If <a id="closing-the-input-stream:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#pending-parsing-blocking-script" id="closing-the-input-stream:pending-parsing-blocking-script">pending parsing-blocking script</a> is not null, then
   return.</p></li><li><p>Run the tokenizer, processing resulting tokens as they are emitted, and stopping when the
   tokenizer reaches the <a href="#explicit-eof-character" id="closing-the-input-stream:explicit-eof-character-2">explicit "EOF" character</a> or <a href="#spin-the-event-loop" id="closing-the-input-stream:spin-the-event-loop">spins the event loop</a>.</p></li></ol>
  </div>

  



  <h4 id="document.write()"><span class="secno">8.4.3</span> <code id="document.write():dom-document-write"><a href="#dom-document-write">document.write()</a></code><a href="#document.write()" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-write" id="dom-document-write-dev">write</a>(...<var>text</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/write" title="The document.write() method writes a string of text to a document stream opened by document.open().">Document/write</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>In general, adds the given string(s) to the <code id="document.write():document"><a href="#document">Document</a></code>'s input stream.</p>

    <p class="warning">This method has very idiosyncratic behavior. In some cases, this method can
    affect the state of the <a href="#html-parser" id="document.write():html-parser">HTML parser</a> while the parser is running, resulting in a DOM
    that does not correspond to the source of the document (e.g. if the string written is the string
    "<code>&lt;plaintext&gt;</code>" or "<code>&lt;!--</code>"). In other cases,
    the call can clear the current page first, as if <code id="document.write():dom-document-open"><a href="#dom-document-open">document.open()</a></code> had been called. In yet more cases, the method
    is simply ignored, or throws an exception. User agents are <a href="#document-written-scripts-intervention">explicitly allowed to avoid executing
    <code>script</code> elements inserted via this method</a>. And to make matters even worse, the
    exact behavior of this method can in some cases be dependent on network latency, which can lead to failures that are very hard to debug. <strong>For all these reasons, use
    of this method is strongly discouraged.</strong></p>

    <p>Throws an <a id="document.write():invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="document.write():domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> when
    invoked on <a id="document.write():xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a>.</p>

    <p>Throws an <a id="document.write():invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="document.write():domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    parser is currently executing a <a href="#custom-element-constructor" id="document.write():custom-element-constructor">custom element constructor</a>.</p>
   </dd></dl>

  <p class="warning">This method performs no sanitization to remove potentially-dangerous elements
  and attributes like <code id="document.write():the-script-element"><a href="#the-script-element">script</a></code> or <a href="#event-handler-content-attributes" id="document.write():event-handler-content-attributes">event handler content attributes</a>.</p>

  

  <p><code id="document.write():document-2"><a href="#document">Document</a></code> objects have an <dfn id="ignore-destructive-writes-counter">ignore-destructive-writes counter</dfn>, which is
  used in conjunction with the processing of <code id="document.write():the-script-element-2"><a href="#the-script-element">script</a></code> elements to prevent external
  scripts from being able to use <code id="document.write():dom-document-write-2"><a href="#dom-document-write">document.write()</a></code> to blow
  away the document by implicitly calling <code id="document.write():dom-document-open-2"><a href="#dom-document-open">document.open()</a></code>.
  Initially, the counter must be set to zero.</p>

  <div data-algorithm="">
  <p>The <dfn id="document-write-steps">document write steps</dfn>, given a <code id="document.write():document-3"><a href="#document">Document</a></code> object <var>document</var>,
  a list <var>text</var>, a boolean <var>lineFeed</var>, and a string <var>sink</var>, are as
  follows:</p>

  <ol><li><p>Let <var>string</var> be the empty string.</p></li><li><p>Let <var>isTrusted</var> be false if <var>text</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="document.write():list-contains" data-x-internal="list-contains">contains</a> a string; otherwise true.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="document.write():list-iterate" data-x-internal="list-iterate">For each</a> <var>value</var> of <var>text</var>:</p>

    <ol><li><p>If <var>value</var> is a <code id="document.write():tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code> object, then
     append <var>value</var>'s associated <a href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml-data" id="document.write():tt-trustedhtml-data" data-x-internal="tt-trustedhtml-data">data</a> to
     <var>string</var>.</p></li><li><p>Otherwise, append <var>value</var> to <var>string</var>.</p></li></ol>
   </li><li><p>If <var>isTrusted</var> is false, set <var>string</var> to the result of invoking the
   <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="document.write():tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with
   <code id="document.write():tt-trustedhtml-2"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="document.write():this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="document.write():concept-relevant-global">relevant global
   object</a>, <var>string</var>, <var>sink</var>, and "<code>script</code>".</p></li><li><p>If <var>lineFeed</var> is true, append U+000A LINE FEED to <var>string</var>.</p></li><li><p>If <var>document</var> is an <a href="https://dom.spec.whatwg.org/#xml-document" id="document.write():xml-documents-2" data-x-internal="xml-documents">XML document</a>, then throw
   an <a id="document.write():invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="document.write():domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>document</var>'s <a href="#throw-on-dynamic-markup-insertion-counter" id="document.write():throw-on-dynamic-markup-insertion-counter">throw-on-dynamic-markup-insertion counter</a> is greater
   than 0, then throw an <a id="document.write():invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="document.write():domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>document</var>'s <a href="#active-parser-was-aborted" id="document.write():active-parser-was-aborted">active parser was aborted</a> is true, then
   return.</p></li><li>
    <p>If the <a href="#insertion-point" id="document.write():insertion-point">insertion point</a> is undefined, then:

    </p><ol><li><p>If <var>document</var>'s <a href="#unload-counter" id="document.write():unload-counter">unload counter</a> is greater than 0 or
     <var>document</var>'s <a href="#ignore-destructive-writes-counter" id="document.write():ignore-destructive-writes-counter">ignore-destructive-writes counter</a> is greater than 0, then
     return.</p></li><li><p>Run the <a href="#document-open-steps" id="document.write():document-open-steps">document open steps</a> with <var>document</var>.</p></li></ol>
   </li><li><p>Insert <var>string</var> into the <a href="#input-stream" id="document.write():input-stream">input stream</a> just before the <a href="#insertion-point" id="document.write():insertion-point-2">insertion
   point</a>.</p></li><li>
    <p>If <var>document</var>'s <a href="#pending-parsing-blocking-script" id="document.write():pending-parsing-blocking-script">pending parsing-blocking script</a> is null, then have the
    <a href="#html-parser" id="document.write():html-parser-2">HTML parser</a> process <var>string</var>, one code point at a time, processing
    resulting tokens as they are emitted, and stopping when the tokenizer reaches the insertion
    point or when the processing of the tokenizer is aborted by the tree construction stage (this
    can happen if a <code id="document.write():the-script-element-3"><a href="#the-script-element">script</a></code> end tag token is emitted by the tokenizer).

    </p><p class="note">If the <code id="document.write():dom-document-write-3"><a href="#dom-document-write">document.write()</a></code> method was
    called from script executing inline (i.e. executing because the parser parsed a set of
    <code id="document.write():the-script-element-4"><a href="#the-script-element">script</a></code> tags), then this is a <a href="#nestedParsing">reentrant invocation of the
    parser</a>. If the <a href="#parser-pause-flag" id="document.write():parser-pause-flag">parser pause flag</a> is set, the tokenizer will abort immediately
    and no HTML will be parsed, per the tokenizer's <a href="#check-parser-pause-flag">parser pause
    flag check</a>.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-write" data-dfn-type="method"><code>document.write(...<var>text</var>)</code></dfn> method steps are
  to run the <a href="#document-write-steps" id="document.write():document-write-steps">document write steps</a> with <a id="document.write():this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>text</var>, false, and
  "<code>Document write</code>".</p>
  </div>

  


  <h4 id="document.writeln()"><span class="secno">8.4.4</span> <code id="document.writeln():dom-document-writeln"><a href="#dom-document-writeln">document.writeln()</a></code><a href="#document.writeln()" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>document</var>.<a href="#dom-document-writeln" id="dom-document-writeln-dev">writeln</a>(...<var>text</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/writeln" title="Writes a string of text followed by a newline character to a document.">Document/writeln</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>64+</span></span><hr><span class="opera yes"><span>Opera</span><span>51+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></dt><dd>
    <p>Adds the given string(s) to the <code id="document.writeln():document"><a href="#document">Document</a></code>'s input stream, followed by a newline
    character. If necessary, calls the <code id="document.writeln():dom-document-open"><a href="#dom-document-open">open()</a></code> method
    implicitly first.</p>

    <p class="warning">This method has very idiosyncratic behavior. <strong>Use of this
    method is strongly discouraged, for the same reasons as <code id="document.writeln():dom-document-write"><a href="#dom-document-write">document.write()</a></code>.</strong></p>

    <p>Throws an <a id="document.writeln():invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="document.writeln():domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> when
    invoked on <a id="document.writeln():xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a>.</p>

    <p>Throws an <a id="document.writeln():invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="document.writeln():domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    parser is currently executing a <a href="#custom-element-constructor" id="document.writeln():custom-element-constructor">custom element constructor</a>.</p>
   </dd></dl>

  <p class="warning">This method performs no sanitization to remove potentially-dangerous elements
  and attributes like <code id="document.writeln():the-script-element"><a href="#the-script-element">script</a></code> or <a href="#event-handler-content-attributes" id="document.writeln():event-handler-content-attributes">event handler content attributes</a>.</p>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-writeln" data-dfn-type="method"><code>document.writeln(...<var>text</var>)</code></dfn> method steps are
  to run the <a href="#document-write-steps" id="document.writeln():document-write-steps">document write steps</a> with <a id="document.writeln():this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>text</var>, true, and
  "<code>Document writeln</code>".</p>
  </div>

  


  <h3 id="dom-parsing-and-serialization"><span class="secno">8.5</span> DOM parsing and serialization APIs<a href="#dom-parsing-and-serialization" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMParser" title="The DOMParser interface provides the ability to parse XML or HTML source code from a string into a DOM Document.">DOMParser</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a id="Element-partial" href="https://dom.spec.whatwg.org/#interface-element" data-x-internal="element"><c- g="">Element</c-></a> {
  [<a href="#cereactions" id="dom-parsing-and-serialization:cereactions"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-element-sethtmlunsafe" id="dom-parsing-and-serialization:dom-element-sethtmlunsafe"><c- g="">setHTMLUnsafe</c-></a>((<code id="dom-parsing-and-serialization:tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> <c- b="">DOMString</c->) <c- g="">html</c->);
  <c- b="">DOMString</c-> <a href="#dom-element-gethtml" id="dom-parsing-and-serialization:dom-element-gethtml"><c- g="">getHTML</c-></a>(<c- b="">optional</c-> <a href="#gethtmloptions" id="dom-parsing-and-serialization:gethtmloptions"><c- n="">GetHTMLOptions</c-></a> <c- g="">options</c-> = {});

  [<a href="#cereactions" id="dom-parsing-and-serialization:cereactions-2"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> (<code id="dom-parsing-and-serialization:tt-trustedhtml-2"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> [<a id="dom-parsing-and-serialization:legacynulltoemptystring" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c->) <a href="#dom-element-innerhtml" id="dom-parsing-and-serialization:dom-element-innerhtml"><c- g="">innerHTML</c-></a>;
  [<a href="#cereactions" id="dom-parsing-and-serialization:cereactions-3"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> (<code id="dom-parsing-and-serialization:tt-trustedhtml-3"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> [<a id="dom-parsing-and-serialization:legacynulltoemptystring-2" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c->) <a href="#dom-element-outerhtml" id="dom-parsing-and-serialization:dom-element-outerhtml"><c- g="">outerHTML</c-></a>;
  [<a href="#cereactions" id="dom-parsing-and-serialization:cereactions-4"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-element-insertadjacenthtml" id="dom-parsing-and-serialization:dom-element-insertadjacenthtml"><c- g="">insertAdjacentHTML</c-></a>(<c- b="">DOMString</c-> <c- g="">position</c->, (<code id="dom-parsing-and-serialization:tt-trustedhtml-4"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> <c- b="">DOMString</c->) <c- g="">string</c->);
};

<c- b="">partial</c-> <c- b="">interface</c-> <a id="ShadowRoot-partial" href="https://dom.spec.whatwg.org/#interface-shadowroot" data-x-internal="shadowroot"><c- g="">ShadowRoot</c-></a> {
  [<a href="#cereactions" id="dom-parsing-and-serialization:cereactions-5"><c- g="">CEReactions</c-></a>] <c- b="">undefined</c-> <a href="#dom-shadowroot-sethtmlunsafe" id="dom-parsing-and-serialization:dom-shadowroot-sethtmlunsafe"><c- g="">setHTMLUnsafe</c-></a>((<code id="dom-parsing-and-serialization:tt-trustedhtml-5"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> <c- b="">DOMString</c->) <c- g="">html</c->);
  <c- b="">DOMString</c-> <a href="#dom-shadowroot-gethtml" id="dom-parsing-and-serialization:dom-shadowroot-gethtml"><c- g="">getHTML</c-></a>(<c- b="">optional</c-> <a href="#gethtmloptions" id="dom-parsing-and-serialization:gethtmloptions-2"><c- n="">GetHTMLOptions</c-></a> <c- g="">options</c-> = {});

  [<a href="#cereactions" id="dom-parsing-and-serialization:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> (<code id="dom-parsing-and-serialization:tt-trustedhtml-6"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> [<a id="dom-parsing-and-serialization:legacynulltoemptystring-3" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c->) <a href="#dom-shadowroot-innerhtml" id="dom-parsing-and-serialization:dom-shadowroot-innerhtml"><c- g="">innerHTML</c-></a>;
};

<c- b="">dictionary</c-> <dfn id="gethtmloptions" data-dfn-type="dictionary"><c- g="">GetHTMLOptions</c-></dfn> {
  <c- b="">boolean</c-> <dfn data-dfn-for="GetHTMLOptions" id="dom-gethtmloptions-serializableshadowroots" data-dfn-type="dict-member"><c- g="">serializableShadowRoots</c-></dfn> = <c- b="">false</c->;
  <c- b="">sequence</c->&lt;<c- n="">ShadowRoot</c->&gt; <dfn data-dfn-for="GetHTMLOptions" id="dom-gethtmloptions-shadowroots" data-dfn-type="dict-member"><c- g="">shadowRoots</c-></dfn> = [];
};</code></pre>

  <h4 id="the-domparser-interface"><span class="secno">8.5.1</span> The <code id="the-domparser-interface:domparser"><a href="#domparser">DOMParser</a></code> interface<a href="#the-domparser-interface" class="self-link"></a></h4>

  <p>The <code id="the-domparser-interface:domparser-2"><a href="#domparser">DOMParser</a></code> interface allows authors to create new <code id="the-domparser-interface:document"><a href="#document">Document</a></code> objects
  by parsing strings, as either HTML or XML.</p>

  <dl class="domintro"><dt><code><var>parser</var> = new <a href="#dom-domparser-constructor" id="dom-domparser-constructor-dev">DOMParser</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/DOMParser" title="The DOMParser() constructor creates a new DOMParser object. This object can be used to parse the text of a document using the parseFromString() method.">DOMParser/DOMParser</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Constructs a new <code id="the-domparser-interface:domparser-3"><a href="#domparser">DOMParser</a></code> object.</p></dd><dt><code><var>document</var> = <var>parser</var>.<a href="#dom-domparser-parsefromstring" id="dom-domparser-parsefromstring-dev">parseFromString</a>(<var>string</var>, <var>type</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString" title="The parseFromString() method of the DOMParser interface parses a string containing either HTML or XML, returning an HTMLDocument or an XMLDocument.">DOMParser/parseFromString</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Parses <var>string</var> using either the HTML or XML parser, according to <var>type</var>,
    and returns the resulting <code id="the-domparser-interface:document-2"><a href="#document">Document</a></code>. <var>type</var> can be "<code id="the-domparser-interface:text/html"><a href="#text/html">text/html</a></code>"
    (which will invoke the HTML parser), or any of "<code id="the-domparser-interface:text/xml"><a href="#text/xml">text/xml</a></code>",
    "<code id="the-domparser-interface:application/xml"><a href="#application/xml">application/xml</a></code>", "<code id="the-domparser-interface:application/xhtml+xml"><a href="#application/xhtml+xml">application/xhtml+xml</a></code>", or
    "<code id="the-domparser-interface:image/svg+xml"><a href="#image/svg+xml">image/svg+xml</a></code>" (which will invoke the XML parser).</p>

    <p>For the XML parser, if <var>string</var> cannot be parsed, then the returned
    <code id="the-domparser-interface:document-3"><a href="#document">Document</a></code> will contain elements describing the resulting error.</p>

    <p>Note that <code id="the-domparser-interface:the-script-element"><a href="#the-script-element">script</a></code> elements are not evaluated during parsing, and the resulting
    document's <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="the-domparser-interface:document's-character-encoding" data-x-internal="document's-character-encoding">encoding</a> will always be
    <a id="the-domparser-interface:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>. The document's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-domparser-interface:the-document's-address" data-x-internal="the-document's-address">URL</a> will be
    inherited from <var>parser</var>'s <a href="#concept-relevant-global" id="the-domparser-interface:concept-relevant-global">relevant global object</a>.</p>

    <p>Values other than the above for <var>type</var> will cause a <code id="the-domparser-interface:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> exception
    to be thrown.</p>
   </dd></dl>

  <p class="note">The design of <code id="the-domparser-interface:domparser-4"><a href="#domparser">DOMParser</a></code>, as a class that needs to be constructed and
  then have its <code id="the-domparser-interface:dom-domparser-parsefromstring"><a href="#dom-domparser-parsefromstring">parseFromString()</a></code> method
  called, is an unfortunate historical artifact. If we were designing this functionality today it
  would be a standalone function. For parsing HTML, the modern alternative is <code id="the-domparser-interface:dom-parsehtmlunsafe"><a href="#dom-parsehtmlunsafe">Document.parseHTMLUnsafe()</a></code>.</p>

  <p class="warning">This method performs no sanitization to remove potentially-dangerous elements
  and attributes like <code id="the-domparser-interface:the-script-element-2"><a href="#the-script-element">script</a></code> or <a href="#event-handler-content-attributes" id="the-domparser-interface:event-handler-content-attributes">event handler content attributes</a>.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="domparser" data-dfn-type="interface"><c- g="">DOMParser</c-></dfn> {
  <a href="#dom-domparser-constructor" id="the-domparser-interface:dom-domparser-constructor"><c- g="">constructor</c-></a>();

  [<c- g="">NewObject</c->] <code id="the-domparser-interface:document-4"><a href="#document"><c- n="">Document</c-></a></code> <a href="#dom-domparser-parsefromstring" id="the-domparser-interface:dom-domparser-parsefromstring-2"><c- g="">parseFromString</c-></a>((<code id="the-domparser-interface:tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> <c- b="">DOMString</c->) <c- g="">string</c->, <a href="#domparsersupportedtype" id="the-domparser-interface:domparsersupportedtype"><c- n="">DOMParserSupportedType</c-></a> <c- g="">type</c->);
};

<c- b="">enum</c-> <dfn id="domparsersupportedtype" data-dfn-type="enum"><c- g="">DOMParserSupportedType</c-></dfn> {
  <c- s="">"</c-><a href="#dom-domparsersupportedtype-texthtml" id="the-domparser-interface:dom-domparsersupportedtype-texthtml"><c- s="">text/html</c-></a><c- s="">"</c->,
  <c- s="">"</c-><a href="#dom-domparsersupportedtype-otherwise" id="the-domparser-interface:dom-domparsersupportedtype-otherwise"><c- s="">text/xml</c-></a><c- s="">"</c->,
  <c- s="">"</c-><a href="#dom-domparsersupportedtype-otherwise" id="the-domparser-interface:dom-domparsersupportedtype-otherwise-2"><c- s="">application/xml</c-></a><c- s="">"</c->,
  <c- s="">"</c-><a href="#dom-domparsersupportedtype-otherwise" id="the-domparser-interface:dom-domparsersupportedtype-otherwise-3"><c- s="">application/xhtml+xml</c-></a><c- s="">"</c->,
  <c- s="">"</c-><a href="#dom-domparsersupportedtype-otherwise" id="the-domparser-interface:dom-domparsersupportedtype-otherwise-4"><c- s="">image/svg+xml</c-></a><c- s="">"</c->
};</code></pre>

  

  <div data-algorithm="">
  <p>The <dfn id="dom-domparser-constructor"><code>new DOMParser()</code></dfn> constructor
  steps are to do nothing.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DOMParser" id="dom-domparser-parsefromstring" data-dfn-type="method"><code>parseFromString(<var>string</var>,
  <var>type</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>compliantString</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="the-domparser-interface:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="the-domparser-interface:tt-trustedhtml-2"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="the-domparser-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-domparser-interface:concept-relevant-global-2">relevant global
   object</a>, <var>string</var>, "<code>DOMParser parseFromString</code>", and "<code>script</code>".</p></li><li>
    <p>Let <var>document</var> be a new <code id="the-domparser-interface:document-5"><a href="#document">Document</a></code>, whose <a href="https://dom.spec.whatwg.org/#concept-document-content-type" id="the-domparser-interface:concept-document-content-type" data-x-internal="concept-document-content-type">content type</a> is <var>type</var> and <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-domparser-interface:the-document's-address-2" data-x-internal="the-document's-address">URL</a> is <a id="the-domparser-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-domparser-interface:concept-relevant-global-3">relevant global object</a>'s <a href="#concept-document-window" id="the-domparser-interface:concept-document-window">associated <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-domparser-interface:the-document's-address-3" data-x-internal="the-document's-address">URL</a>.</p>
    

    <p class="note">The document's <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="the-domparser-interface:document's-character-encoding-2" data-x-internal="document's-character-encoding">encoding</a> will
    be left as its default, of <a id="the-domparser-interface:utf-8-2" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>. In particular, any XML declarations or
    <code id="the-domparser-interface:the-meta-element"><a href="#the-meta-element">meta</a></code> elements found while parsing <var>compliantString</var> will have no effect.</p>
   </li><li>
    <p>Switch on <var>type</var>:</p>

    <dl class="switch"><dt>"<dfn data-dfn-for="DOMParserSupportedType" id="dom-domparsersupportedtype-texthtml" data-dfn-type="enum-value"><code>text/html</code></dfn>"</dt><dd>
      <ol><li><p><a href="#parse-html-from-a-string" id="the-domparser-interface:parse-html-from-a-string">Parse HTML from a string</a> given <var>document</var> and
       <var>compliantString</var>.</p></li></ol>

      <p class="note">Since <var>document</var> does not have a <a href="#concept-document-bc" id="the-domparser-interface:concept-document-bc">browsing context</a>, <a href="#concept-n-script" id="the-domparser-interface:concept-n-script">scripting is disabled</a>.</p>
     </dd><dt><dfn id="dom-domparsersupportedtype-otherwise">Otherwise</dfn></dt><dd>
      <ol><li><p>Create an <a href="#xml-parser" id="the-domparser-interface:xml-parser">XML parser</a> <var>parser</var>, associated with
       <var>document</var>, and with <a href="#xml-scripting-support-disabled" id="the-domparser-interface:xml-scripting-support-disabled">XML scripting support disabled</a>.</p></li><li><p>Parse <var>compliantString</var> using <var>parser</var>.</p>

       </li><li>
        <p>If the previous step resulted in an XML well-formedness or XML namespace well-formedness
        error, then:</p>

        <ol><li><p><a id="the-domparser-interface:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>document</var> has no child nodes.</p></li><li><p>Let <var>root</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-domparser-interface:create-an-element" data-x-internal="create-an-element">creating an
         element</a> given <var>document</var>, "<code>parsererror</code>", and "<code>http://www.mozilla.org/newlayout/xml/parsererror.xml</code>".</p></li><li><p>Optionally, add attributes or children to <var>root</var> to describe the nature of
         the parsing error.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-domparser-interface:concept-node-append" data-x-internal="concept-node-append">Append</a> <var>root</var> to
         <var>document</var>.</p></li></ol>
       </li></ol>
     </dd></dl>
   </li><li><p>Return <var>document</var>.</p>
  </li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="parse-html-from-a-string">parse HTML from a string</dfn>, given a <code id="the-domparser-interface:document-6"><a href="#document">Document</a></code> <var>document</var> and a
  <a id="the-domparser-interface:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <var>html</var>:</p>

  <ol><li><p>Set <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-type" id="the-domparser-interface:concept-document-type" data-x-internal="concept-document-type">type</a> to "<code>html</code>".</p></li><li><p>Create an <a href="#html-parser" id="the-domparser-interface:html-parser">HTML parser</a> <var>parser</var>, associated with
   <var>document</var>.</p></li><li><p>Place <var>html</var> into the <a href="#input-stream" id="the-domparser-interface:input-stream">input stream</a> for <var>parser</var>. The
   encoding <a href="#concept-encoding-confidence" id="the-domparser-interface:concept-encoding-confidence">confidence</a> is
   <i>irrelevant</i>.</p></li><li>
    <p>Start <var>parser</var> and let it run until it has consumed all the characters just
    inserted into the input stream.</p>

    <p class="note">This might mutate the document's <a href="https://dom.spec.whatwg.org/#concept-document-mode" id="the-domparser-interface:concept-document-mode" data-x-internal="concept-document-mode">mode</a>.</p>
   </li></ol>
  </div>

  

  <h4 id="unsafe-html-parsing-methods"><span class="secno">8.5.2</span> Unsafe HTML parsing methods<a href="#unsafe-html-parsing-methods" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-element-sethtmlunsafe" id="dom-element-sethtmlunsafe-dev">setHTMLUnsafe</a>(<var>html</var>)</code></dt><dd>
    <p>Parses <var>html</var> using the HTML parser, and replaces the children of <var>element</var>
    with the result. <var>element</var> provides context for the HTML parser.</p>
   </dd><dt><code><var>shadowRoot</var>.<a href="#dom-shadowroot-sethtmlunsafe" id="dom-shadowroot-sethtmlunsafe-dev">setHTMLUnsafe</a>(<var>html</var>)</code></dt><dd>
    <p>Parses <var>html</var> using the HTML parser, and replaces the children of
    <var>shadowRoot</var> with the result. <var>shadowRoot</var>'s <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="unsafe-html-parsing-methods:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">host</a> provides context for the HTML parser.</p>
   </dd><dt><code><var>doc</var> = Document.<a href="#dom-parsehtmlunsafe" id="unsafe-html-parsing-methods:dom-parsehtmlunsafe">parseHTMLUnsafe</a>(<var>html</var>)</code></dt><dd>
    <p>Parses <var>html</var> using the HTML parser, and returns the resulting
    <code id="unsafe-html-parsing-methods:document"><a href="#document">Document</a></code>.</p>

    <p>Note that <code id="unsafe-html-parsing-methods:the-script-element"><a href="#the-script-element">script</a></code> elements are not evaluated during parsing, and the resulting
    document's <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="unsafe-html-parsing-methods:document's-character-encoding" data-x-internal="document's-character-encoding">encoding</a> will always be
    <a id="unsafe-html-parsing-methods:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>. The document's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="unsafe-html-parsing-methods:the-document's-address" data-x-internal="the-document's-address">URL</a> will be
    <code id="unsafe-html-parsing-methods:about:blank"><a href="#about:blank">about:blank</a></code>.</p>
   </dd></dl>

  <p class="warning">These methods perform no sanitization to remove potentially-dangerous elements
  and attributes like <code id="unsafe-html-parsing-methods:the-script-element-2"><a href="#the-script-element">script</a></code> or <a href="#event-handler-content-attributes" id="unsafe-html-parsing-methods:event-handler-content-attributes">event handler content attributes</a>.</p>

  

  <div data-algorithm="">
  <p><code id="unsafe-html-parsing-methods:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>'s <dfn data-dfn-for="Element" id="dom-element-sethtmlunsafe" data-dfn-type="method"><code>setHTMLUnsafe(<var>html</var>)</code></dfn> method steps
  are:</p>

  <ol><li><p>Let <var>compliantHTML</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="unsafe-html-parsing-methods:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="unsafe-html-parsing-methods:tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="unsafe-html-parsing-methods:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="unsafe-html-parsing-methods:concept-relevant-global">relevant global
   object</a>, <var>html</var>, "<code>Element setHTMLUnsafe</code>", and "<code>script</code>".</p></li><li><p>Let <var>target</var> be <a id="unsafe-html-parsing-methods:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#template-contents" id="unsafe-html-parsing-methods:template-contents">template contents</a> if
   <a id="unsafe-html-parsing-methods:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is a <code id="unsafe-html-parsing-methods:the-template-element"><a href="#the-template-element">template</a></code> element; otherwise <a id="unsafe-html-parsing-methods:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p><a href="#unsafely-set-html" id="unsafe-html-parsing-methods:unsafely-set-html">Unsafely set HTML</a> given <var>target</var>, <a id="unsafe-html-parsing-methods:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, and
   <var>compliantHTML</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p><code id="unsafe-html-parsing-methods:shadowroot"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code>'s <dfn data-dfn-for="ShadowRoot" id="dom-shadowroot-sethtmlunsafe" data-dfn-type="method"><code>setHTMLUnsafe(<var>html</var>)</code></dfn> method steps
  are:</p>

  <ol><li><p>Let <var>compliantHTML</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="unsafe-html-parsing-methods:tt-getcompliantstring-2" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="unsafe-html-parsing-methods:tt-trustedhtml-2"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="unsafe-html-parsing-methods:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="unsafe-html-parsing-methods:concept-relevant-global-2">relevant global
   object</a>, <var>html</var>, "<code>ShadowRoot setHTMLUnsafe</code>", and "<code>script</code>".</p></li><li><p><a href="#unsafely-set-html" id="unsafe-html-parsing-methods:unsafely-set-html-2">Unsafely set HTML</a> given <a id="unsafe-html-parsing-methods:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <a id="unsafe-html-parsing-methods:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="unsafe-html-parsing-methods:concept-documentfragment-host-2" data-x-internal="concept-documentfragment-host">shadow host</a>, and <var>compliantHTML</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="unsafely-set-html">unsafely set HTML</dfn>, given an <code id="unsafe-html-parsing-methods:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or <code id="unsafe-html-parsing-methods:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code>
  <var>target</var>, an <code id="unsafe-html-parsing-methods:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> <var>contextElement</var>, and a <a id="unsafe-html-parsing-methods:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a>
  <var>html</var>:</p>

  <ol><li><p>Let <var>newChildren</var> be the result of the <a href="#html-fragment-parsing-algorithm" id="unsafe-html-parsing-methods:html-fragment-parsing-algorithm">HTML fragment parsing
   algorithm</a> given <var>contextElement</var>, <var>html</var>, and true.</p></li><li><p>Let <var>fragment</var> be a new <code id="unsafe-html-parsing-methods:documentfragment-2"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> whose <a id="unsafe-html-parsing-methods:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a> is <var>contextElement</var>'s <a id="unsafe-html-parsing-methods:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>For each <var>node</var> in <var>newChildren</var>, <a href="https://dom.spec.whatwg.org/#concept-node-append" id="unsafe-html-parsing-methods:concept-node-append" data-x-internal="concept-node-append">append</a> <var>node</var> to <var>fragment</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-replace-all" id="unsafe-html-parsing-methods:concept-node-replace-all" data-x-internal="concept-node-replace-all">Replace all</a> with <var>fragment</var> within
   <var>target</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The static <dfn data-dfn-for="Document" id="dom-parsehtmlunsafe" data-dfn-type="method"><code>parseHTMLUnsafe(<var>html</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>compliantHTML</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="unsafe-html-parsing-methods:tt-getcompliantstring-3" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="unsafe-html-parsing-methods:tt-trustedhtml-3"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="unsafe-html-parsing-methods:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="unsafe-html-parsing-methods:concept-relevant-global-3">relevant global
   object</a>, <var>html</var>, "<code>Document parseHTMLUnsafe</code>", and "<code>script</code>".</p></li><li>
    <p>Let <var>document</var> be a new <code id="unsafe-html-parsing-methods:document-2"><a href="#document">Document</a></code>, whose <a href="https://dom.spec.whatwg.org/#concept-document-content-type" id="unsafe-html-parsing-methods:concept-document-content-type" data-x-internal="concept-document-content-type">content type</a> is "<code>text/html</code>".</p>

    <p class="note">Since <var>document</var> does not have a <a href="#concept-document-bc" id="unsafe-html-parsing-methods:concept-document-bc">browsing context</a>, <a href="#concept-n-script" id="unsafe-html-parsing-methods:concept-n-script">scripting
    is disabled</a>.</p>
   </li><li><p>Set <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-allow-declarative-shadow-roots" id="unsafe-html-parsing-methods:concept-document-allow-declarative-shadow-roots" data-x-internal="concept-document-allow-declarative-shadow-roots">allow declarative shadow roots</a> to
   true.</p></li><li><p><a href="#parse-html-from-a-string" id="unsafe-html-parsing-methods:parse-html-from-a-string">Parse HTML from a string</a> given <var>document</var> and
   <var>compliantHTML</var>.</p></li><li><p>Return <var>document</var>.</p></li></ol>
  </div>

  

  <h4 id="html-serialization-methods"><span class="secno">8.5.3</span> HTML serialization methods<a href="#html-serialization-methods" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>html</var> = <var>element</var>.<a href="#dom-element-gethtml" id="dom-element-gethtml-dev">getHTML</a>({ <a href="#dom-gethtmloptions-serializableshadowroots" id="html-serialization-methods:dom-gethtmloptions-serializableshadowroots">serializableShadowRoots</a>, <a href="#dom-gethtmloptions-shadowroots" id="html-serialization-methods:dom-gethtmloptions-shadowroots">shadowRoots</a> })</code></dt><dd>
    <p>Returns the result of serializing <var>element</var> to HTML. <a href="https://dom.spec.whatwg.org/#concept-shadow-root" id="html-serialization-methods:shadow-root" data-x-internal="shadow-root">Shadow roots</a> within <var>element</var> are serialized according to the provided options:</p>

    <ul><li><p>If <code id="html-serialization-methods:dom-gethtmloptions-serializableshadowroots-2"><a href="#dom-gethtmloptions-serializableshadowroots">serializableShadowRoots</a></code> is true, then all shadow roots marked as <a href="https://dom.spec.whatwg.org/#shadowroot-serializable" id="html-serialization-methods:shadow-serializable" data-x-internal="shadow-serializable">serializable</a> are serialized.</p></li><li><p>If the <code id="html-serialization-methods:dom-gethtmloptions-shadowroots-2"><a href="#dom-gethtmloptions-shadowroots">shadowRoots</a></code> array is provided, then all shadow roots specified in the array are serialized, regardless of whether or not they are marked as serializable.</p></li></ul>

    <p>If neither option is provided, then no shadow roots are serialized.</p>
   </dd><dt><code><var>html</var> = <var>shadowRoot</var>.<a href="#dom-shadowroot-gethtml" id="dom-shadowroot-gethtml-dev">getHTML</a>({ <a href="#dom-gethtmloptions-serializableshadowroots" id="html-serialization-methods:dom-gethtmloptions-serializableshadowroots-3">serializableShadowRoots</a>, <a href="#dom-gethtmloptions-shadowroots" id="html-serialization-methods:dom-gethtmloptions-shadowroots-3">shadowRoots</a> })</code></dt><dd>
    <p>Returns the result of serializing <var>shadowRoot</var> to HTML, using its <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="html-serialization-methods:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">shadow host</a> as the context element. <a href="https://dom.spec.whatwg.org/#concept-shadow-root" id="html-serialization-methods:shadow-root-2" data-x-internal="shadow-root">Shadow roots</a> within <var>shadowRoot</var> are serialized according to the provided options, as above.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p><code id="html-serialization-methods:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>'s <dfn data-dfn-for="Element" id="dom-element-gethtml" data-dfn-type="method"><code>getHTML(<var>options</var>)</code></dfn> method steps
  are to return the result of <a href="#html-fragment-serialisation-algorithm" id="html-serialization-methods:html-fragment-serialisation-algorithm">HTML fragment serialization algorithm</a> with
  <a id="html-serialization-methods:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>options</var>["<code id="html-serialization-methods:dom-gethtmloptions-serializableshadowroots-4"><a href="#dom-gethtmloptions-serializableshadowroots">serializableShadowRoots</a></code>"],
  and <var>options</var>["<code id="html-serialization-methods:dom-gethtmloptions-shadowroots-4"><a href="#dom-gethtmloptions-shadowroots">shadowRoots</a></code>"].</p>
  </div>

  <div data-algorithm="">
  <p><code id="html-serialization-methods:shadowroot"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code>'s <dfn data-dfn-for="ShadowRoot" id="dom-shadowroot-gethtml" data-dfn-type="method"><code>getHTML(<var>options</var>)</code></dfn> method steps
  are to return the result of <a href="#html-fragment-serialisation-algorithm" id="html-serialization-methods:html-fragment-serialisation-algorithm-2">HTML fragment serialization algorithm</a> with
  <a id="html-serialization-methods:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>options</var>["<code id="html-serialization-methods:dom-gethtmloptions-serializableshadowroots-5"><a href="#dom-gethtmloptions-serializableshadowroots">serializableShadowRoots</a></code>"],
  and <var>options</var>["<code id="html-serialization-methods:dom-gethtmloptions-shadowroots-5"><a href="#dom-gethtmloptions-shadowroots">shadowRoots</a></code>"].</p>
  </div>

  

  <h4 id="the-innerhtml-property"><span class="secno">8.5.4</span> The <code id="the-innerhtml-property:dom-element-innerhtml"><a href="#dom-element-innerhtml">innerHTML</a></code> property<a href="#the-innerhtml-property" class="self-link"></a></h4>

  <p class="XXX">The <code id="the-innerhtml-property:dom-element-innerhtml-2"><a href="#dom-element-innerhtml">innerHTML</a></code> property has a number of outstanding issues
  in the <cite>DOM Parsing and Serialization</cite> <a href="https://github.com/w3c/DOM-Parsing/issues">issue
  tracker</a>, documenting various problems with its specification.</p>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-element-innerhtml" id="dom-element-innerhtml-dev">innerHTML</a></code></dt><dd>
    <p>Returns a fragment of HTML or XML that represents the element's contents.</p>

    <p>In the case of an XML document, throws an <a id="the-innerhtml-property:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
    <code id="the-innerhtml-property:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the element cannot be serialized to XML.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-element-innerhtml" id="the-innerhtml-property:dom-element-innerhtml-3">innerHTML</a> = <var>value</var></code></dt><dd>
    <p>Replaces the contents of the element with nodes parsed from the given string.</p>

    <p>In the case of an XML document, throws a <a id="the-innerhtml-property:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
    <code id="the-innerhtml-property:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the given string is not well-formed.</p>
   </dd><dt><code><var>shadowRoot</var>.<a href="#dom-shadowroot-innerhtml" id="dom-shadowroot-innerhtml-dev">innerHTML</a></code></dt><dd>
    <p>Returns a fragment of HTML that represents the shadow roots's contents.</p>
   </dd><dt><code><var>shadowRoot</var>.<a href="#dom-shadowroot-innerhtml" id="the-innerhtml-property:dom-shadowroot-innerhtml">innerHTML</a> = <var>value</var></code></dt><dd>
    <p>Replaces the contents of the shadow root with nodes parsed from the given string.</p>
   </dd></dl>

  <p class="warning">These properties' setters perform no sanitization to remove
  potentially-dangerous elements and attributes like <code id="the-innerhtml-property:the-script-element"><a href="#the-script-element">script</a></code> or <a href="#event-handler-content-attributes" id="the-innerhtml-property:event-handler-content-attributes">event handler
  content attributes</a>.</p>

  

  <div data-algorithm="">
  <p>The <dfn id="fragment-serializing-algorithm-steps" data-export="">fragment serializing algorithm steps</dfn>, given an <code id="the-innerhtml-property:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>,
  <code id="the-innerhtml-property:document"><a href="#document">Document</a></code>, or <code id="the-innerhtml-property:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> <var>node</var> and a boolean <var>require
  well-formed</var>, are:</p>

  <ol><li><p>Let <var>context document</var> be <var>node</var>'s <a id="the-innerhtml-property:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>If <var>context document</var> is an <a href="https://dom.spec.whatwg.org/#html-document" id="the-innerhtml-property:html-documents" data-x-internal="html-documents">HTML document</a>,
    return the result of <a href="#html-fragment-serialisation-algorithm" id="the-innerhtml-property:html-fragment-serialisation-algorithm">HTML fragment serialization algorithm</a> with <var>node</var>,
    false, and « ».</p></li><li><p>Return the <a href="https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization" id="the-innerhtml-property:xml-serialization" data-x-internal="xml-serialization">XML serialization</a> of <var>node</var>
    given <var>require well-formed</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="fragment-parsing-algorithm-steps" data-export="">fragment parsing algorithm steps</dfn>, given an <code id="the-innerhtml-property:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>
  <var>context</var> and a string <var>markup</var>, are:</p>

  <ol><li><p>Let <var>algorithm</var> be the <a href="#html-fragment-parsing-algorithm" id="the-innerhtml-property:html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>.</p></li><li><p>If <var>context</var>'s <a id="the-innerhtml-property:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is an <a href="https://dom.spec.whatwg.org/#xml-document" id="the-innerhtml-property:xml-documents" data-x-internal="xml-documents">XML
   document</a>, then set <var>algorithm</var> to the <a href="#xml-fragment-parsing-algorithm" id="the-innerhtml-property:xml-fragment-parsing-algorithm">XML fragment parsing
   algorithm</a>.</p></li><li><p>Let <var>newChildren</var> be the result of invoking <var>algorithm</var> given
   <var>context</var> and <var>markup</var>.</p></li><li><p>Let <var>fragment</var> be a new <code id="the-innerhtml-property:documentfragment-2"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> whose <a id="the-innerhtml-property:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a> is <var>context</var>'s <a id="the-innerhtml-property:node-document-4" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li>
    <p>For each <var>node</var> of <var>newChildren</var>, in <a id="the-innerhtml-property:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>: <a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-innerhtml-property:concept-node-append" data-x-internal="concept-node-append">append</a> <var>node</var> to <var>fragment</var>.</p>

    <p class="note">This ensures the <a id="the-innerhtml-property:node-document-5" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> for the new <a href="https://dom.spec.whatwg.org/#interface-node" id="the-innerhtml-property:node" data-x-internal="node">nodes</a> is correct.</p>
   </li><li><p>Return <var>fragment</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p><code id="the-innerhtml-property:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>'s <dfn data-dfn-for="Element" id="dom-element-innerhtml" data-dfn-type="attribute"><code>innerHTML</code></dfn> getter steps are to return the result of
  running <a href="#fragment-serializing-algorithm-steps" id="the-innerhtml-property:fragment-serializing-algorithm-steps">fragment serializing algorithm steps</a> with <a id="the-innerhtml-property:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and true.</p>
  </div>

  <div data-algorithm="">
  <p><code id="the-innerhtml-property:shadowroot"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code>'s <dfn data-dfn-for="ShadowRoot" id="dom-shadowroot-innerhtml" data-dfn-type="attribute"><code>innerHTML</code></dfn> getter steps are to return the result of
  running <a href="#fragment-serializing-algorithm-steps" id="the-innerhtml-property:fragment-serializing-algorithm-steps-2">fragment serializing algorithm steps</a> with <a id="the-innerhtml-property:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and true.</p>
  </div>

  <div data-algorithm="">
  <p><code id="the-innerhtml-property:element-4"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>'s <code id="the-innerhtml-property:dom-element-innerhtml-4"><a href="#dom-element-innerhtml">innerHTML</a></code> setter steps
  are:</p>

  <ol><li><p>Let <var>compliantString</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="the-innerhtml-property:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="the-innerhtml-property:tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="the-innerhtml-property:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-innerhtml-property:concept-relevant-global">relevant global
    object</a>, the given value, "<code>Element innerHTML</code>", and "<code>script</code>".</p></li><li><p>Let <var>context</var> be <a id="the-innerhtml-property:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>Let <var>fragment</var> be the result of invoking the <a href="#fragment-parsing-algorithm-steps" id="the-innerhtml-property:fragment-parsing-algorithm-steps">fragment parsing algorithm
    steps</a> with <var>context</var> and <var>compliantString</var>.</p></li><li>
     <p>If <var>context</var> is a <code id="the-innerhtml-property:the-template-element"><a href="#the-template-element">template</a></code> element, then set <var>context</var> to
     the <code id="the-innerhtml-property:the-template-element-2"><a href="#the-template-element">template</a></code> element's <a href="#template-contents" id="the-innerhtml-property:template-contents">template contents</a> (a
     <code id="the-innerhtml-property:documentfragment-3"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code>).</p>

     <p class="note">Setting <code id="the-innerhtml-property:dom-element-innerhtml-5"><a href="#dom-element-innerhtml">innerHTML</a></code> on a
     <code id="the-innerhtml-property:the-template-element-3"><a href="#the-template-element">template</a></code> element will replace all the nodes in its <a href="#template-contents" id="the-innerhtml-property:template-contents-2">template contents</a>
     rather than its <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="the-innerhtml-property:concept-tree-child" data-x-internal="concept-tree-child">children</a>.</p>
    </li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-replace-all" id="the-innerhtml-property:concept-node-replace-all" data-x-internal="concept-node-replace-all">Replace all</a> with <var>fragment</var>
    within <var>context</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p><code id="the-innerhtml-property:shadowroot-2"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code>'s <code id="the-innerhtml-property:dom-shadowroot-innerhtml-2"><a href="#dom-shadowroot-innerhtml">innerHTML</a></code> setter
  steps are:</p>

  <ol><li><p>Let <var>compliantString</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="the-innerhtml-property:tt-getcompliantstring-2" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="the-innerhtml-property:tt-trustedhtml-2"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="the-innerhtml-property:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-innerhtml-property:concept-relevant-global-2">relevant global
    object</a>, the given value, "<code>ShadowRoot innerHTML</code>", and "<code>script</code>".</p></li><li><p>Let <var>context</var> be <a id="the-innerhtml-property:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="https://dom.spec.whatwg.org/#concept-documentfragment-host" id="the-innerhtml-property:concept-documentfragment-host" data-x-internal="concept-documentfragment-host">host</a>.</p></li><li><p>Let <var>fragment</var> be the result of invoking the <a href="#fragment-parsing-algorithm-steps" id="the-innerhtml-property:fragment-parsing-algorithm-steps-2">fragment parsing algorithm
    steps</a> with <var>context</var> and <var>compliantString</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-replace-all" id="the-innerhtml-property:concept-node-replace-all-2" data-x-internal="concept-node-replace-all">Replace all</a> with <var>fragment</var>
    within <a id="the-innerhtml-property:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li></ol>
  </div>

  

  <h4 id="the-outerhtml-property"><span class="secno">8.5.5</span> The <code id="the-outerhtml-property:dom-element-outerhtml"><a href="#dom-element-outerhtml">outerHTML</a></code> property<a href="#the-outerhtml-property" class="self-link"></a></h4>

  <p class="XXX">The <code id="the-outerhtml-property:dom-element-outerhtml-2"><a href="#dom-element-outerhtml">outerHTML</a></code> property has a number of outstanding issues
  in the <cite>DOM Parsing and Serialization</cite> <a href="https://github.com/w3c/DOM-Parsing/issues">issue
  tracker</a>, documenting various problems with its specification.</p>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-element-outerhtml" id="dom-element-outerhtml-dev">outerHTML</a></code></dt><dd>
    <p>Returns a fragment of HTML or XML that represents the element and its contents.</p>

    <p>In the case of an XML document, throws an <a id="the-outerhtml-property:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
    <code id="the-outerhtml-property:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the element cannot be serialized to XML.</p>
   </dd><dt><code><var>element</var>.<a href="#dom-element-outerhtml" id="the-outerhtml-property:dom-element-outerhtml-3">outerHTML</a> = <var>value</var></code></dt><dd>
    <p>Replaces the element with nodes parsed from the given string.</p>

    <p>In the case of an XML document, throws a <a id="the-outerhtml-property:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
    <code id="the-outerhtml-property:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the given string is not well-formed.</p>

    <p>Throws a <a id="the-outerhtml-property:nomodificationallowederror" href="https://webidl.spec.whatwg.org/#nomodificationallowederror" data-x-internal="nomodificationallowederror">"<code>NoModificationAllowedError</code>"</a> <code id="the-outerhtml-property:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    the parent of the element is a <a href="#document" id="the-outerhtml-property:document"><code>Document</code></a>.</p>
   </dd></dl>

  <p class="warning">This property's setter performs no sanitization to remove potentially-dangerous
  elements and attributes like <code id="the-outerhtml-property:the-script-element"><a href="#the-script-element">script</a></code> or <a href="#event-handler-content-attributes" id="the-outerhtml-property:event-handler-content-attributes">event handler content
  attributes</a>.</p>

  

  <div data-algorithm="">
  <p><code id="the-outerhtml-property:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>'s <dfn data-dfn-for="Element" id="dom-element-outerhtml" data-dfn-type="attribute"><code>outerHTML</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>element</var> be a fictional node whose only child is <a id="the-outerhtml-property:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>Return the result of running <a href="#fragment-serializing-algorithm-steps" id="the-outerhtml-property:fragment-serializing-algorithm-steps">fragment serializing algorithm steps</a> with
   <var>element</var> and true.
  </p></li></ol>
  </div>

  <div data-algorithm="">
  <p><code id="the-outerhtml-property:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>'s <code id="the-outerhtml-property:dom-element-outerhtml-4"><a href="#dom-element-outerhtml">outerHTML</a></code> setter steps
  are:</p>

  <ol><li><p>Let <var>compliantString</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="the-outerhtml-property:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="the-outerhtml-property:tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="the-outerhtml-property:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-outerhtml-property:concept-relevant-global">relevant global
    object</a>, the given value, "<code>Element outerHTML</code>", and "<code>script</code>".</p></li><li><p>Let <var>parent</var> be <a id="the-outerhtml-property:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-outerhtml-property:parent" href="https://dom.spec.whatwg.org/#concept-tree-parent" data-x-internal="parent">parent</a>.</p></li><li><p>If <var>parent</var> is null, return. There would be no way to obtain a
    reference to the nodes created even if the remaining steps were run.</p></li><li><p>If <var>parent</var> is a <code id="the-outerhtml-property:document-2"><a href="#document">Document</a></code>, throw a
    <a id="the-outerhtml-property:nomodificationallowederror-2" href="https://webidl.spec.whatwg.org/#nomodificationallowederror" data-x-internal="nomodificationallowederror">"<code>NoModificationAllowedError</code>"</a> <code id="the-outerhtml-property:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>parent</var> is a <code id="the-outerhtml-property:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code>, set <var>parent</var> to the
    result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-outerhtml-property:create-an-element" data-x-internal="create-an-element">creating an element</a> given <a id="the-outerhtml-property:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
    <a id="the-outerhtml-property:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, "<code>body</code>", and the <a id="the-outerhtml-property:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
    namespace</a>.</p></li><li><p>Let <var>fragment</var> be the result of invoking the <a href="#fragment-parsing-algorithm-steps" id="the-outerhtml-property:fragment-parsing-algorithm-steps">fragment parsing algorithm
    steps</a> given <var>parent</var> and <var>compliantString</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-replace" id="the-outerhtml-property:concept-node-replace" data-x-internal="concept-node-replace">Replace</a> <a id="the-outerhtml-property:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> with
    <var>fragment</var> within <a id="the-outerhtml-property:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-outerhtml-property:parent-2" href="https://dom.spec.whatwg.org/#concept-tree-parent" data-x-internal="parent">parent</a>.</p></li></ol>
  </div>

  

  <h4 id="the-insertadjacenthtml()-method"><span class="secno">8.5.6</span> The <code id="the-insertadjacenthtml()-method:dom-element-insertadjacenthtml"><a href="#dom-element-insertadjacenthtml">insertAdjacentHTML()</a></code> method<a href="#the-insertadjacenthtml()-method" class="self-link"></a></h4>

  <p class="XXX">The <code id="the-insertadjacenthtml()-method:dom-element-insertadjacenthtml-2"><a href="#dom-element-insertadjacenthtml">insertAdjacentHTML()</a></code>
  method has a number of outstanding issues in the <cite>DOM Parsing and Serialization</cite> <a href="https://github.com/w3c/DOM-Parsing/issues">issue tracker</a>, documenting various problems
  with its specification.</p>

  <dl class="domintro"><dt><code><var>element</var>.<a href="#dom-element-insertadjacenthtml" id="dom-element-insertadjacenthtml-dev">insertAdjacentHTML</a>(<var>position</var>, <var>string</var>)</code></dt><dd>
    <p>Parses <var>string</var> as HTML or XML and inserts the resulting nodes into the tree in
    the position given by the <var>position</var> argument, as follows:</p>

    <dl><dt>"<code>beforebegin</code>"</dt><dd>Before the element itself (i.e., after <var>element</var>'s previous sibling)</dd><dt>"<code>afterbegin</code>"</dt><dd>Just inside the element, before its first child.</dd><dt>"<code>beforeend</code>"</dt><dd>Just inside the element, after its last child.</dd><dt>"<code>afterend</code>"</dt><dd>After the element itself (i.e., before <var>element</var>'s next sibling)</dd></dl>

    <p>Throws a <a id="the-insertadjacenthtml()-method:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="the-insertadjacenthtml()-method:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the arguments
    have invalid values (e.g., in the case of an <a href="https://dom.spec.whatwg.org/#xml-document" id="the-insertadjacenthtml()-method:xml-documents" data-x-internal="xml-documents">XML document</a>,
    if the given string is not well-formed).</p>

    <p>Throws a <a id="the-insertadjacenthtml()-method:nomodificationallowederror" href="https://webidl.spec.whatwg.org/#nomodificationallowederror" data-x-internal="nomodificationallowederror">"<code>NoModificationAllowedError</code>"</a> <code id="the-insertadjacenthtml()-method:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>
    if the given position isn't possible (e.g. inserting elements after the root element of a
    <code id="the-insertadjacenthtml()-method:document"><a href="#document">Document</a></code>).</p>
   </dd></dl>

  <p class="warning">This method performs no sanitization to remove potentially-dangerous elements
  and attributes like <code id="the-insertadjacenthtml()-method:the-script-element"><a href="#the-script-element">script</a></code> or <a href="#event-handler-content-attributes" id="the-insertadjacenthtml()-method:event-handler-content-attributes">event handler content attributes</a>.</p>

  

  <div data-algorithm="">
  <p><code id="the-insertadjacenthtml()-method:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>'s <dfn data-dfn-for="Element" id="dom-element-insertadjacenthtml" data-dfn-type="method"><code>insertAdjacentHTML(<var>position</var>,
  <var>string</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>compliantString</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="the-insertadjacenthtml()-method:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="the-insertadjacenthtml()-method:tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="the-insertadjacenthtml()-method:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-insertadjacenthtml()-method:concept-relevant-global">relevant global
   object</a>, <var>string</var>, "<code>Element insertAdjacentHTML</code>", and "<code>script</code>".</p></li><li><p>Let <var>context</var> be null.</p></li><li><p>Use the first matching item from this list:</p>
    <dl class="switch"><dt>If <var>position</var> is an <a id="the-insertadjacenthtml()-method:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>beforebegin</code>"</dt><dt>If <var>position</var> is an <a id="the-insertadjacenthtml()-method:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>afterend</code>"</dt><dd>
      <ol><li><p>Set <var>context</var> to <a id="the-insertadjacenthtml()-method:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#dom-parent" id="the-insertadjacenthtml()-method:dom-parent">parent</a>.</p></li><li><p>If <var>context</var> is null or a <code id="the-insertadjacenthtml()-method:document-2"><a href="#document">Document</a></code>, throw a
       <a id="the-insertadjacenthtml()-method:nomodificationallowederror-2" href="https://webidl.spec.whatwg.org/#nomodificationallowederror" data-x-internal="nomodificationallowederror">"<code>NoModificationAllowedError</code>"</a> <code id="the-insertadjacenthtml()-method:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
     </dd><dt>If <var>position</var> is an <a id="the-insertadjacenthtml()-method:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>afterbegin</code>"</dt><dt>If <var>position</var> is an <a id="the-insertadjacenthtml()-method:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>beforeend</code>"</dt><dd>Set <var>context</var> to <a id="the-insertadjacenthtml()-method:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</dd><dt>Otherwise</dt><dd><p>Throw a <a id="the-insertadjacenthtml()-method:syntaxerror-2" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="the-insertadjacenthtml()-method:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></dd></dl>
   </li><li>
    <p>If <var>context</var> is not an <code id="the-insertadjacenthtml()-method:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> or all of the following are true:</p>

    <ul><li><p><var>context</var>'s <a id="the-insertadjacenthtml()-method:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is an HTML document;</p></li><li><p><var>context</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="the-insertadjacenthtml()-method:concept-element-local-name" data-x-internal="concept-element-local-name">local name</a> is
     "<code id="the-insertadjacenthtml()-method:the-html-element"><a href="#the-html-element">html</a></code>"; and</p></li><li><p><var>context</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="the-insertadjacenthtml()-method:concept-element-namespace" data-x-internal="concept-element-namespace">namespace</a> is the
     <a id="the-insertadjacenthtml()-method:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>,</p></li></ul>

    <p>then set <var>context</var> to the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-insertadjacenthtml()-method:create-an-element" data-x-internal="create-an-element">creating an
    element</a> given <a id="the-insertadjacenthtml()-method:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-insertadjacenthtml()-method:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, "<code>body</code>", and the <a id="the-insertadjacenthtml()-method:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>.</p>
   </li><li>
    <p>Let <var>fragment</var> be the result of invoking the <a href="#fragment-parsing-algorithm-steps" id="the-insertadjacenthtml()-method:fragment-parsing-algorithm-steps">fragment parsing algorithm
    steps</a> with <var>context</var> and <var>compliantString</var>.</p>
   </li><li>Use the first matching item from this list:
    <dl class="switch"><dt>If <var>position</var> is an <a id="the-insertadjacenthtml()-method:ascii-case-insensitive-5" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>beforebegin</code>"</dt><dd>
      <p><a href="https://dom.spec.whatwg.org/#concept-node-insert" id="the-insertadjacenthtml()-method:concept-node-insert" data-x-internal="concept-node-insert">Insert</a> <var>fragment</var> into
      <a id="the-insertadjacenthtml()-method:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#dom-parent" id="the-insertadjacenthtml()-method:dom-parent-2">parent</a> before <a id="the-insertadjacenthtml()-method:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
     </dd><dt>If <var>position</var> is an <a id="the-insertadjacenthtml()-method:ascii-case-insensitive-6" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>afterbegin</code>"</dt><dd>
      <p><a href="https://dom.spec.whatwg.org/#concept-node-insert" id="the-insertadjacenthtml()-method:concept-node-insert-2" data-x-internal="concept-node-insert">Insert</a> <var>fragment</var> into
      <a id="the-insertadjacenthtml()-method:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> before its <a id="the-insertadjacenthtml()-method:first-child" href="https://dom.spec.whatwg.org/#concept-tree-first-child" data-x-internal="first-child">first child</a>.</p>
     </dd><dt>If <var>position</var> is an <a id="the-insertadjacenthtml()-method:ascii-case-insensitive-7" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>beforeend</code>"</dt><dd>
      <p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="the-insertadjacenthtml()-method:concept-node-append" data-x-internal="concept-node-append">Append</a> <var>fragment</var> to
      <a id="the-insertadjacenthtml()-method:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
     </dd><dt>If <var>position</var> is an <a id="the-insertadjacenthtml()-method:ascii-case-insensitive-8" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>afterend</code>"</dt><dd>
      <p><a href="https://dom.spec.whatwg.org/#concept-node-insert" id="the-insertadjacenthtml()-method:concept-node-insert-3" data-x-internal="concept-node-insert">Insert</a> <var>fragment</var> into
      <a id="the-insertadjacenthtml()-method:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#dom-parent" id="the-insertadjacenthtml()-method:dom-parent-3">parent</a> before <a id="the-insertadjacenthtml()-method:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
      <a id="the-insertadjacenthtml()-method:next-sibling" href="https://dom.spec.whatwg.org/#concept-tree-next-sibling" data-x-internal="next-sibling">next sibling</a>.</p>
     </dd></dl>
   </li></ol>
  </div>

  <p class="note">As with other direct <code id="the-insertadjacenthtml()-method:node"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code>-manipulation APIs (and unlike <code id="the-insertadjacenthtml()-method:dom-element-innerhtml"><a href="#dom-element-innerhtml">innerHTML</a></code>), <code id="the-insertadjacenthtml()-method:dom-element-insertadjacenthtml-3"><a href="#dom-element-insertadjacenthtml">insertAdjacentHTML()</a></code> does not include any special
  handling for <code id="the-insertadjacenthtml()-method:the-template-element"><a href="#the-template-element">template</a></code> elements. In most cases you will want to use <code>templateEl.<a href="#dom-template-content" id="the-insertadjacenthtml()-method:dom-template-content">content</a>.<a href="#dom-element-insertadjacenthtml" id="the-insertadjacenthtml()-method:dom-element-insertadjacenthtml-4">insertAdjacentHTML()</a></code> instead of directly
  manipulating the child nodes of a <code id="the-insertadjacenthtml()-method:the-template-element-2"><a href="#the-template-element">template</a></code> element.</p>

  

  <h4 id="the-createcontextualfragment()-method"><span class="secno">8.5.7</span> The <code id="the-createcontextualfragment()-method:dom-range-createcontextualfragment"><a href="#dom-range-createcontextualfragment">createContextualFragment()</a></code>
  method<a href="#the-createcontextualfragment()-method" class="self-link"></a></h4>

  <p class="XXX">The <code id="the-createcontextualfragment()-method:dom-range-createcontextualfragment-2"><a href="#dom-range-createcontextualfragment">createContextualFragment()</a></code> method has a number
  of outstanding issues in the <cite>DOM Parsing and Serialization</cite> <a href="https://github.com/w3c/DOM-Parsing/issues">issue tracker</a>, documenting various problems
  with its specification.</p>

  <dl class="domintro"><dt><code><var>docFragment</var> = <var>range</var>.<a href="#dom-range-createcontextualfragment" id="dom-range-createcontextualfragment-dev">createContextualFragment</a>(<var>string</var>)</code></dt><dd>
    <p>Returns a <code id="the-createcontextualfragment()-method:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> created from the markup string <var>string</var> using
    <var>range</var>'s <a href="https://dom.spec.whatwg.org/#concept-range-start-node" id="the-createcontextualfragment()-method:concept-range-start-node" data-x-internal="concept-range-start-node">start node</a> as the context in
    which <var>fragment</var> is parsed.</p>
   </dd></dl>

  <p class="warning">This method performs no sanitization to remove potentially-dangerous elements
  and attributes like <code id="the-createcontextualfragment()-method:the-script-element"><a href="#the-script-element">script</a></code> or <a href="#event-handler-content-attributes" id="the-createcontextualfragment()-method:event-handler-content-attributes">event handler content attributes</a>.</p>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a id="Range-partial" href="https://dom.spec.whatwg.org/#interface-range" data-x-internal="range"><c- g="">Range</c-></a> {
  [<a href="#cereactions" id="the-createcontextualfragment()-method:cereactions"><c- g="">CEReactions</c-></a>, <c- g="">NewObject</c->] <code id="the-createcontextualfragment()-method:documentfragment-2"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment"><c- n="">DocumentFragment</c-></a></code> <a href="#dom-range-createcontextualfragment" id="the-createcontextualfragment()-method:dom-range-createcontextualfragment-3"><c- g="">createContextualFragment</c-></a>((<code id="the-createcontextualfragment()-method:tt-trustedhtml"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml"><c- n="">TrustedHTML</c-></a></code> <c- b="">or</c-> <c- b="">DOMString</c->) <c- g="">string</c->);
};</code></pre>

  

  <div data-algorithm="">
  <p><code id="the-createcontextualfragment()-method:range"><a data-x-internal="range" href="https://dom.spec.whatwg.org/#interface-range">Range</a></code>'s <dfn data-dfn-for="Range" id="dom-range-createcontextualfragment" data-dfn-type="method"><code>createContextualFragment(<var>string</var>)</code></dfn>
  method steps are:</p>

  <ol><li><p>Let <var>compliantString</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="the-createcontextualfragment()-method:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get
   Trusted Type compliant string</a> algorithm with <code id="the-createcontextualfragment()-method:tt-trustedhtml-2"><a data-x-internal="tt-trustedhtml" href="https://w3c.github.io/trusted-types/dist/spec/#trustedhtml">TrustedHTML</a></code>, <a id="the-createcontextualfragment()-method:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="the-createcontextualfragment()-method:concept-relevant-global">relevant global
   object</a>, <var>string</var>, "<code>Range createContextualFragment</code>", and
   "<code>script</code>".</p></li><li><p>Let <var>node</var> be <a id="the-createcontextualfragment()-method:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="https://dom.spec.whatwg.org/#concept-range-start-node" id="the-createcontextualfragment()-method:concept-range-start-node-2" data-x-internal="concept-range-start-node">start
   node</a>.</p></li><li><p>Let <var>element</var> be null.</p></li><li><p>If <var>node</var> <a id="the-createcontextualfragment()-method:implements" href="https://webidl.spec.whatwg.org/#implements" data-x-internal="implements">implements</a> <code id="the-createcontextualfragment()-method:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>, set <var>element</var>
   to <var>node</var>.</p></li><li><p>Otherwise, if <var>node</var> <a id="the-createcontextualfragment()-method:implements-2" href="https://webidl.spec.whatwg.org/#implements" data-x-internal="implements">implements</a> <code id="the-createcontextualfragment()-method:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> or
   <code id="the-createcontextualfragment()-method:comment-2"><a data-x-internal="comment-2" href="https://dom.spec.whatwg.org/#interface-comment">Comment</a></code>, set <var>element</var> to <var>node</var>'s <a id="the-createcontextualfragment()-method:parent-element" href="https://dom.spec.whatwg.org/#parent-element" data-x-internal="parent-element">parent
   element</a>.</p></li><li>
    <p>If <var>element</var> is null or all of the following are true:</p>

    <ul><li><p><var>element</var>'s <a id="the-createcontextualfragment()-method:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is an HTML document;</p></li><li><p><var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="the-createcontextualfragment()-method:concept-element-local-name" data-x-internal="concept-element-local-name">local name</a> is
     "<code id="the-createcontextualfragment()-method:the-html-element"><a href="#the-html-element">html</a></code>"; and</p></li><li><p><var>element</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="the-createcontextualfragment()-method:concept-element-namespace" data-x-internal="concept-element-namespace">namespace</a> is the
     <a id="the-createcontextualfragment()-method:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>,</p></li></ul>

    <p>then set <var>element</var> to the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="the-createcontextualfragment()-method:create-an-element" data-x-internal="create-an-element">creating an
    element</a> given <a id="the-createcontextualfragment()-method:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a id="the-createcontextualfragment()-method:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, "<code>body</code>", and the <a id="the-createcontextualfragment()-method:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>.</p>
   </li><li><p>Let <var>fragment node</var> be the result of invoking the <a href="#fragment-parsing-algorithm-steps" id="the-createcontextualfragment()-method:fragment-parsing-algorithm-steps">fragment parsing
   algorithm steps</a> with <var>element</var> and <var>compliantString</var>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-createcontextualfragment()-method:list-iterate" data-x-internal="list-iterate">For each</a> <var>script</var> of <var>fragment node</var>'s
    <code id="the-createcontextualfragment()-method:the-script-element-2"><a href="#the-script-element">script</a></code> element <a href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="the-createcontextualfragment()-method:concept-tree-descendant" data-x-internal="concept-tree-descendant">descendants</a>:</p>

    <ol><li><p>Set <var>script</var>'s <a href="#already-started" id="the-createcontextualfragment()-method:already-started">already started</a> to false.</p></li><li><p>Set <var>script</var>'s <a href="#parser-document" id="the-createcontextualfragment()-method:parser-document">parser document</a> to null.</p></li></ol>
   </li><li><p>Return <var>fragment node</var>.</p></li></ol>
  </div>

  

  <h4 id="the-xmlserializer-interface"><span class="secno">8.5.8</span> The <code id="the-xmlserializer-interface:xmlserializer"><a href="#xmlserializer">XMLSerializer</a></code> interface<a href="#the-xmlserializer-interface" class="self-link"></a></h4>

  <p class="XXX">The <code id="the-xmlserializer-interface:xmlserializer-2"><a href="#xmlserializer">XMLSerializer</a></code> interface has a number of outstanding issues in the
  <cite>DOM Parsing and Serialization</cite> <a href="https://github.com/w3c/DOM-Parsing/issues">issue tracker</a>, documenting various problems
  with its specification. The remainder of <cite>DOM Parsing and Serialization</cite> will be
  gradually upstreamed to this specification.</p>

  <dl class="domintro"><dt><code><var>xmlSerializer</var> = new <a href="#dom-xmlserializer-constructor" id="dom-xmlserializer-constructor-dev">XMLSerializer</a>()</code></dt><dd><p>Constructs a new <code id="the-xmlserializer-interface:xmlserializer-3"><a href="#xmlserializer">XMLSerializer</a></code> object.</p></dd><dt><code><var>string</var> = <var>xmlSerializer</var>.<a href="#dom-xmlserializer-serializetostring" id="dom-xmlserializer-serializetostring-dev">serializeToString</a>(<var>root</var>)</code></dt><dd>
    <p>Returns the result of serializing <var>root</var> to XML.</p>

    <p>Throws an <a id="the-xmlserializer-interface:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-xmlserializer-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    <var>root</var> cannot be serialized to XML.</p>
   </dd></dl>

  <p class="note">The design of <code id="the-xmlserializer-interface:xmlserializer-4"><a href="#xmlserializer">XMLSerializer</a></code>, as a class that needs to be constructed
  and then have its <code id="the-xmlserializer-interface:dom-xmlserializer-serializetostring"><a href="#dom-xmlserializer-serializetostring">serializeToString()</a></code>
  method called, is an unfortunate historical artifact. If we were designing this functionality
  today it would be a standalone function.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="xmlserializer" data-dfn-type="interface"><c- g="">XMLSerializer</c-></dfn> {
  <a href="#dom-xmlserializer-constructor" id="the-xmlserializer-interface:dom-xmlserializer-constructor"><c- g="">constructor</c-></a>();

  <c- b="">DOMString</c-> <a href="#dom-xmlserializer-serializetostring" id="the-xmlserializer-interface:dom-xmlserializer-serializetostring-2"><c- g="">serializeToString</c-></a>(<code id="the-xmlserializer-interface:node"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node"><c- n="">Node</c-></a></code> <c- g="">root</c->);
};</code></pre>

  

  <div data-algorithm="">
  <p>The <dfn id="dom-xmlserializer-constructor"><code>new XMLSerializer()</code></dfn>
  constructor steps are to do nothing.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="XMLSerializer" id="dom-xmlserializer-serializetostring" data-dfn-type="method"><code>serializeToString(<var>root</var>)</code></dfn>
  method steps are:</p>

  <ol><li><p>Return the <a href="https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization" id="the-xmlserializer-interface:xml-serialization" data-x-internal="xml-serialization">XML serialization</a> of <var>root</var>
   given false.</p></li></ol>
  </div>

  

  <h3 id="timers"><span class="secno">8.6</span> Timers<a href="#timers" class="self-link"></a></h3>

  <p>The <code id="timers:dom-settimeout"><a href="#dom-settimeout">setTimeout()</a></code> and <code id="timers:dom-setinterval"><a href="#dom-setinterval">setInterval()</a></code> methods allow authors to schedule timer-based
  callbacks.</p>

  <dl class="domintro"><dt><code><var>id</var> = self.<a href="#dom-settimeout" id="dom-settimeout-dev">setTimeout</a>(<var>handler</var> [, <var>timeout</var> [, ...<var>arguments</var> ] ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/setTimeout" title="The global setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires.">setTimeout</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Schedules a timeout to run <var>handler</var> after <var>timeout</var> milliseconds. Any
    <var>arguments</var> are passed straight through to the <var>handler</var>.</p>
   </dd><dt><code><var>id</var> = self.<a href="#dom-settimeout" id="timers:dom-settimeout-2">setTimeout</a>(<var>code</var> [, <var>timeout</var> ])</code></dt><dd>
    <p>Schedules a timeout to compile and run <var>code</var> after <var>timeout</var>
    milliseconds.</p>
   </dd><dt><code>self.<a href="#dom-cleartimeout" id="dom-cleartimeout-dev">clearTimeout</a>(<var>id</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/clearTimeout" title="The global clearTimeout() method cancels a timeout previously established by calling setTimeout().">clearTimeout</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Cancels the timeout set with <code id="timers:dom-settimeout-3"><a href="#dom-settimeout">setTimeout()</a></code> or <code id="timers:dom-setinterval-2"><a href="#dom-setinterval">setInterval()</a></code> identified by <var>id</var>.</p></dd><dt><code><var>id</var> = self.<a href="#dom-setinterval" id="dom-setinterval-dev">setInterval</a>(<var>handler</var> [, <var>timeout</var> [, ...<var>arguments</var> ] ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/setInterval" title="The setInterval() method, offered on the Window and Worker interfaces, repeatedly calls a function or executes a code snippet, with a fixed time delay between each call.">setInterval</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Schedules a timeout to run <var>handler</var> every <var>timeout</var> milliseconds. Any
    <var>arguments</var> are passed straight through to the <var>handler</var>.</p>
   </dd><dt><code><var>id</var> = self.<a href="#dom-setinterval" id="timers:dom-setinterval-3">setInterval</a>(<var>code</var> [, <var>timeout</var> ])</code></dt><dd>
    <p>Schedules a timeout to compile and run <var>code</var> every <var>timeout</var>
    milliseconds.</p>
   </dd><dt><code>self.<a href="#dom-clearinterval" id="dom-clearinterval-dev">clearInterval</a>(<var>id</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/clearInterval" title="The global clearInterval() method cancels a timed, repeating action which was previously established by a call to setInterval(). If the parameter provided does not identify a previously established action, this method does nothing.">clearInterval</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Cancels the timeout set with <code id="timers:dom-setinterval-4"><a href="#dom-setinterval">setInterval()</a></code> or <code id="timers:dom-settimeout-4"><a href="#dom-settimeout">setTimeout()</a></code> identified by <var>id</var>.</p></dd></dl>

  <p class="note">Timers can be nested; after five such nested timers, however, the interval is
  forced to be at least four milliseconds.</p>

  <p class="note">This API does not guarantee that timers will run exactly on schedule. Delays due
  to CPU load, other tasks, etc, are to be expected.</p>

  

  <p>Objects that implement the <code id="timers:windoworworkerglobalscope"><a href="#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a></code> mixin have a
  <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="map-of-settimeout-and-setinterval-ids" data-export="">map of setTimeout and setInterval IDs</dfn>, which is
  an <a id="timers:ordered-map" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>, initially empty. Each <a href="https://infra.spec.whatwg.org/#map-key" id="timers:map-key" data-x-internal="map-key">key</a> in this map
  is a positive integer, corresponding to the return value of a <code id="timers:dom-settimeout-5"><a href="#dom-settimeout">setTimeout()</a></code> or <code id="timers:dom-setinterval-5"><a href="#dom-setinterval">setInterval()</a></code> call.
  Each <a href="https://infra.spec.whatwg.org/#map-value" id="timers:map-value" data-x-internal="map-value">value</a> is a <a href="#unique-internal-value" id="timers:unique-internal-value">unique internal value</a>, corresponding
  to a key in the object's <a href="#map-of-active-timers" id="timers:map-of-active-timers">map of active timers</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-settimeout" data-dfn-type="method"><code id="dom-windowtimers-setTimeout">setTimeout(<var>handler</var>, <var>timeout</var>,
  ...<var>arguments</var>)</code></dfn> method steps are to return the result of running the
  <a href="#timer-initialisation-steps" id="timers:timer-initialisation-steps">timer initialization steps</a> given <a id="timers:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>handler</var>,
  <var>timeout</var>, <var>arguments</var>, and false.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-setinterval" data-dfn-type="method"><code id="dom-windowtimers-setInterval">setInterval(<var>handler</var>, <var>timeout</var>,
  ...<var>arguments</var>)</code></dfn> method steps are to return the result of running the
  <a href="#timer-initialisation-steps" id="timers:timer-initialisation-steps-2">timer initialization steps</a> given <a id="timers:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>handler</var>,
  <var>timeout</var>, <var>arguments</var>, and true.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-cleartimeout" data-dfn-type="method"><code id="dom-windowtimers-clearTimeout">clearTimeout(<var>id</var>)</code></dfn> and <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-clearinterval" data-dfn-type="method"><code id="dom-windowtimers-clearInterval">clearInterval(<var>id</var>)</code></dfn> method steps
  are to <a href="https://infra.spec.whatwg.org/#map-remove" id="timers:map-remove" data-x-internal="map-remove">remove</a> <a id="timers:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#map-of-settimeout-and-setinterval-ids" id="timers:map-of-settimeout-and-setinterval-ids">map of setTimeout and
  setInterval IDs</a>[<var>id</var>].</p>
  </div>

  <p class="note">Because <code id="timers:dom-cleartimeout"><a href="#dom-cleartimeout">clearTimeout()</a></code> and <code id="timers:dom-clearinterval"><a href="#dom-clearinterval">clearInterval()</a></code> clear entries from the same map, either method
  can be used to clear timers created by <code id="timers:dom-settimeout-6"><a href="#dom-settimeout">setTimeout()</a></code> or <code id="timers:dom-setinterval-6"><a href="#dom-setinterval">setInterval()</a></code>.</p>

  <hr>

  <div data-algorithm="">
  <p>To perform the <dfn id="timer-initialisation-steps">timer initialization
  steps</dfn>, given a <code id="timers:windoworworkerglobalscope-2"><a href="#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a></code> <var>global</var>, a string or <code id="timers:idl-function"><a data-x-internal="idl-function" href="https://webidl.spec.whatwg.org/#common-Function">Function</a></code> or <code id="timers:tt-trustedscript"><a data-x-internal="tt-trustedscript" href="https://w3c.github.io/trusted-types/dist/spec/#trusted-script">TrustedScript</a></code>
  <var>handler</var>, a number <var>timeout</var>, a list <var>arguments</var>, a boolean
  <var>repeat</var>, and optionally (and only if <var>repeat</var> is true) a number
  <var>previousId</var>, perform the following steps. They return a number.</p>

  <ol><li><p>Let <var>thisArg</var> be <var>global</var> if that is a <code id="timers:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code>
   object; otherwise let <var>thisArg</var> be the <code id="timers:windowproxy"><a href="#windowproxy">WindowProxy</a></code> that corresponds to
   <var>global</var>.</p></li><li><p>If <var>previousId</var> was given, let <var>id</var> be <var>previousId</var>;
   otherwise, let <var>id</var> be an <a id="timers:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> integer that is greater
   than zero and does not already <a href="https://infra.spec.whatwg.org/#map-exists" id="timers:map-exists" data-x-internal="map-exists">exist</a> in <var>global</var>'s
   <a href="#map-of-settimeout-and-setinterval-ids" id="timers:map-of-settimeout-and-setinterval-ids-2">map of setTimeout and setInterval IDs</a>.</p></li><li>
    <p>If the <a id="timers:surrounding-agent" href="https://tc39.es/ecma262/#surrounding-agent" data-x-internal="surrounding-agent">surrounding agent</a>'s <a href="#concept-agent-event-loop" id="timers:concept-agent-event-loop">event
    loop</a>'s <a href="#currently-running-task" id="timers:currently-running-task">currently running task</a> is a task that was created by this algorithm,
    then let <var>nesting level</var> be the <a href="#concept-task" id="timers:concept-task">task</a>'s <a href="#timer-nesting-level" id="timers:timer-nesting-level">timer
    nesting level</a>. Otherwise, let <var>nesting level</var> be 0.</p>

    <p class="note">The task's <a href="#timer-nesting-level" id="timers:timer-nesting-level-2">timer nesting level</a> is used both for nested calls to
    <code id="timers:dom-settimeout-7"><a href="#dom-settimeout">setTimeout()</a></code>, and for the repeating timers created by
    <code id="timers:dom-setinterval-7"><a href="#dom-setinterval">setInterval()</a></code>. (Or, indeed, for any combination of the
    two.) In other words, it represents nested invocations of this algorithm, not of a particular
    method.</p>
   </li><li><p>If <var>timeout</var> is less than 0, then set <var>timeout</var> to 0.</p></li><li><p>If <var>nesting level</var> is greater than 5, and <var>timeout</var> is less than 4,
   then set <var>timeout</var> to 4.</p></li><li><p>Let <var>realm</var> be <var>global</var>'s <a href="#concept-relevant-realm" id="timers:concept-relevant-realm">relevant
   realm</a>.</p></li><li><p>Let <var>initiating script</var> be the <a href="#active-script" id="timers:active-script">active script</a>.</p></li><li><p>Let <var>uniqueHandle</var> be null.</p></li><li>
    <p>Let <var>task</var> be a <a href="#concept-task" id="timers:concept-task-2">task</a> that runs the following
    substeps:</p>

    <ol><li><p><a id="timers:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>uniqueHandle</var> is a <a href="#unique-internal-value" id="timers:unique-internal-value-2">unique internal value</a>,
     not null.</p></li><li><p>If <var>id</var> does not <a href="https://infra.spec.whatwg.org/#map-exists" id="timers:map-exists-2" data-x-internal="map-exists">exist</a> in <var>global</var>'s
     <a href="#map-of-settimeout-and-setinterval-ids" id="timers:map-of-settimeout-and-setinterval-ids-3">map of setTimeout and setInterval IDs</a>, then abort these steps.</p></li><li>
      <p>If <var>global</var>'s <a href="#map-of-settimeout-and-setinterval-ids" id="timers:map-of-settimeout-and-setinterval-ids-4">map of setTimeout and setInterval IDs</a>[<var>id</var>]
      does not equal <var>uniqueHandle</var>, then abort these steps.</p>

      <p class="note">This accommodates for the ID having been cleared by a <code id="timers:dom-cleartimeout-2"><a href="#dom-cleartimeout">clearTimeout()</a></code> or <code id="timers:dom-clearinterval-2"><a href="#dom-clearinterval">clearInterval()</a></code> call, and being reused by a subsequent
      <code id="timers:dom-settimeout-8"><a href="#dom-settimeout">setTimeout()</a></code> or <code id="timers:dom-setinterval-8"><a href="#dom-setinterval">setInterval()</a></code> call.</p>
     </li><li><p><a id="timers:record-timing-info-for-timer-handler" href="https://w3c.github.io/long-animation-frames/#record-timing-info-for-timer-handler" data-x-internal="record-timing-info-for-timer-handler">Record timing info for timer handler</a> given <var>handler</var>,
     <var>global</var>'s <a href="#relevant-settings-object" id="timers:relevant-settings-object">relevant settings object</a>, and <var>repeat</var>.</p></li><li><p>If <var>handler</var> is a <code id="timers:idl-function-2"><a data-x-internal="idl-function" href="https://webidl.spec.whatwg.org/#common-Function">Function</a></code>, then <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="timers:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">invoke</a> <var>handler</var> given
     <var>arguments</var> and "<code>report</code>", and with <i id="timers:dfn-callback-this-value"><a data-x-internal="dfn-callback-this-value" href="https://webidl.spec.whatwg.org/#dfn-callback-this-value">callback this value</a></i> set to <var>thisArg</var>.</p>
     </li><li>
      <p>Otherwise:</p>

      <ol><li>
        <p>If <var>previousId</var> was not given:</p>

        <ol><li><p>Let <var>globalName</var> be "<code>Window</code>" if <var>global</var> is
         a <code id="timers:window"><a href="#window">Window</a></code> object; "<code>WorkerGlobalScope</code>"
         otherwise.</p></li><li><p>Let <var>methodName</var> be "<code>setInterval</code>" if
         <var>repeat</var> is true; "<code>setTimeout</code>" otherwise.</p></li><li><p>Let <var>sink</var> be a concatenation of <var>globalName</var>, U+0020 SPACE, and
         <var>methodName</var>.</p></li><li><p>Set <var>handler</var> to the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="timers:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with
         <code id="timers:tt-trustedscript-2"><a data-x-internal="tt-trustedscript" href="https://w3c.github.io/trusted-types/dist/spec/#trusted-script">TrustedScript</a></code>, <var>global</var>,
         <var>handler</var>, <var>sink</var>, and "<code>script</code>".</p></li></ol>
       </li><li><p><a id="timers:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>handler</var> is a string.</p></li><li><p>Perform <a href="https://w3c.github.io/webappsec-csp/#can-compile-strings" id="timers:csp-ensurecspdoesnotblockstringcompilation" data-x-internal="csp-ensurecspdoesnotblockstringcompilation">EnsureCSPDoesNotBlockStringCompilation</a>(<var>realm</var>,
       « », <var>handler</var>, <var>handler</var>, timer, « », <var>handler</var>). If this throws
       an exception, catch it, <a href="#report-an-exception" id="timers:report-an-exception">report</a> it for
       <var>global</var>, and abort these steps.</p></li><li><p>Let <var>settings object</var> be <var>global</var>'s <a href="#relevant-settings-object" id="timers:relevant-settings-object-2">relevant settings
       object</a>.</p></li><li><p>Let <var>fetch options</var> be the <a href="#default-script-fetch-options" id="timers:default-script-fetch-options">default script fetch
       options</a>.</p></li><li><p>Let <var>base URL</var> be <var>settings object</var>'s <a href="#api-base-url" id="timers:api-base-url">API base
       URL</a>.</p></li><li>
        <p>If <var>initiating script</var> is not null, then:</p>

        <ol><li><p>Set <var>fetch options</var> to a <a href="#script-fetch-options" id="timers:script-fetch-options">script fetch options</a> whose <a href="#concept-script-fetch-options-nonce" id="timers:concept-script-fetch-options-nonce">cryptographic nonce</a> is <var>initiating
         script</var>'s <a href="#concept-script-script-fetch-options" id="timers:concept-script-script-fetch-options">fetch options</a>'s
         <a href="#concept-script-fetch-options-nonce" id="timers:concept-script-fetch-options-nonce-2">cryptographic nonce</a>, <a href="#concept-script-fetch-options-integrity" id="timers:concept-script-fetch-options-integrity">integrity metadata</a> is the empty
         string, <a href="#concept-script-fetch-options-parser" id="timers:concept-script-fetch-options-parser">parser metadata</a> is
         "<code>not-parser-inserted</code>", <a href="#concept-script-fetch-options-credentials" id="timers:concept-script-fetch-options-credentials">credentials mode</a> is
         <var>initiating script</var>'s <a href="#concept-script-script-fetch-options" id="timers:concept-script-script-fetch-options-2">fetch
         options</a>'s <a href="#concept-script-fetch-options-credentials" id="timers:concept-script-fetch-options-credentials-2">credentials
         mode</a>, <a href="#concept-script-fetch-options-referrer-policy" id="timers:concept-script-fetch-options-referrer-policy">referrer
         policy</a> is <var>initiating script</var>'s <a href="#concept-script-script-fetch-options" id="timers:concept-script-script-fetch-options-3">fetch options</a>'s <a href="#concept-script-fetch-options-referrer-policy" id="timers:concept-script-fetch-options-referrer-policy-2">referrer policy</a>, and <a href="#concept-script-fetch-options-fetch-priority" id="timers:concept-script-fetch-options-fetch-priority">fetch priority</a> is "<code>auto</code>".</p></li><li><p>Set <var>base URL</var> to <var>initiating script</var>'s <a href="#concept-script-base-url" id="timers:concept-script-base-url">base URL</a>.</p></li></ol>

        <p class="note">The effect of these steps ensures that the string compilation done by <code id="timers:dom-settimeout-9"><a href="#dom-settimeout">setTimeout()</a></code> and <code id="timers:dom-setinterval-9"><a href="#dom-setinterval">setInterval()</a></code> behaves equivalently to that done by
        <code id="timers:eval()"><a data-x-internal="eval()" href="https://tc39.es/ecma262/#sec-eval-x">eval()</a></code>. That is, <a href="#module-script" id="timers:module-script">module script</a> fetches via <code id="timers:import()"><a data-x-internal="import()" href="https://tc39.es/ecma262/#sec-import-calls">import()</a></code>
        will behave the same in both contexts.</p>
       </li><li><p>Let <var>script</var> be the result of <a href="#creating-a-classic-script" id="timers:creating-a-classic-script">creating a classic script</a> given
       <var>handler</var>, <var>settings object</var>, <var>base URL</var>, and <var>fetch
       options</var>.</p></li><li><p><a href="#run-a-classic-script" id="timers:run-a-classic-script">Run the classic script</a>
       <var>script</var>.</p></li></ol>
     </li><li><p>If <var>id</var> does not <a href="https://infra.spec.whatwg.org/#map-exists" id="timers:map-exists-3" data-x-internal="map-exists">exist</a> in <var>global</var>'s
     <a href="#map-of-settimeout-and-setinterval-ids" id="timers:map-of-settimeout-and-setinterval-ids-5">map of setTimeout and setInterval IDs</a>, then abort these steps.</p></li><li>
      <p>If <var>global</var>'s <a href="#map-of-settimeout-and-setinterval-ids" id="timers:map-of-settimeout-and-setinterval-ids-6">map of setTimeout and setInterval IDs</a>[<var>id</var>]
      does not equal <var>uniqueHandle</var>, then abort these steps.</p>

      <p class="note">The ID might have been removed via the author code in <var>handler</var>
      calling <code id="timers:dom-cleartimeout-3"><a href="#dom-cleartimeout">clearTimeout()</a></code> or <code id="timers:dom-clearinterval-3"><a href="#dom-clearinterval">clearInterval()</a></code>. Checking that uniqueHandle isn't different
      accounts for the possibility of the ID, after having been cleared, being reused by a
      subsequent <code id="timers:dom-settimeout-10"><a href="#dom-settimeout">setTimeout()</a></code> or <code id="timers:dom-setinterval-10"><a href="#dom-setinterval">setInterval()</a></code> call.</p>
     </li><li><p>If <var>repeat</var> is true, then perform the <a href="#timer-initialisation-steps" id="timers:timer-initialisation-steps-3">timer initialization
     steps</a> again, given <var>global</var>, <var>handler</var>, <var>timeout</var>,
     <var>arguments</var>, true, and <var>id</var>.</p></li><li><p>Otherwise, <a href="https://infra.spec.whatwg.org/#map-remove" id="timers:map-remove-2" data-x-internal="map-remove">remove</a> <var>global</var>'s <a href="#map-of-settimeout-and-setinterval-ids" id="timers:map-of-settimeout-and-setinterval-ids-7">map of
     setTimeout and setInterval IDs</a>[<var>id</var>].</p></li></ol>
   </li><li><p>Increment <var>nesting level</var> by one.</p></li><li><p>Set <var>task</var>'s <dfn id="timer-nesting-level">timer nesting level</dfn> to <var>nesting level</var>.</p></li><li><p>Let <var>completionStep</var> be an algorithm step which <a href="#queue-a-global-task" id="timers:queue-a-global-task">queues a global task</a> on the <dfn id="timer-task-source" data-export="">timer task source</dfn> given
   <var>global</var> to run <var>task</var>.</p></li><li><p>Set <var>uniqueHandle</var> to the result of <a href="#run-steps-after-a-timeout" id="timers:run-steps-after-a-timeout">running steps after a timeout</a> given <var>global</var>, "<code>setTimeout/setInterval</code>", <var>timeout</var>, and
   <var>completionStep</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="timers:map-set" data-x-internal="map-set">Set</a> <var>global</var>'s <a href="#map-of-settimeout-and-setinterval-ids" id="timers:map-of-settimeout-and-setinterval-ids-8">map of setTimeout and
   setInterval IDs</a>[<var>id</var>] to <var>uniqueHandle</var>.</p></li><li><p>Return <var>id</var>.</p></li></ol>
  </div>

  <p class="note">Argument conversion as defined by Web IDL (for example, invoking <code>toString()</code> methods on objects passed as the first argument) happens in the
  algorithms defined in Web IDL, before this algorithm is invoked.</p>

  <div class="example">
   <p>So for example, the following rather silly code will result in the log containing "<code>ONE&nbsp;TWO&nbsp;</code>":</p>

   <pre><code class="js"><c- a="">var</c-> log <c- o="">=</c-> <c- t="">''</c-><c- p="">;</c->
<c- a="">function</c-> logger<c- p="">(</c->s<c- p="">)</c-> <c- p="">{</c-> log <c- o="">+=</c-> s <c- o="">+</c-> <c- t="">' '</c-><c- p="">;</c-> <c- p="">}</c->

setTimeout<c- p="">({</c-> toString<c- o="">:</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
  setTimeout<c- p="">(</c-><c- u="">"logger('ONE')"</c-><c- p="">,</c-> <c- mf="">100</c-><c- p="">);</c->
  <c- k="">return</c-> <c- u="">"logger('TWO')"</c-><c- p="">;</c->
<c- p="">}</c-> <c- p="">},</c-> <c- mf="">100</c-><c- p="">);</c-></code></pre>
  </div>

  

  <div class="example">
   <p>To run tasks of several milliseconds back to back without any delay, while still yielding back
   to the browser to avoid starving the user interface (and to avoid the browser killing the script
   for hogging the CPU), simply queue the next timer before performing work:</p>

   <pre><code class="js"><c- a="">function</c-> doExpensiveWork<c- p="">()</c-> <c- p="">{</c->
  <c- a="">var</c-> done <c- o="">=</c-> <c- kc="">false</c-><c- p="">;</c->
  <c- c1="">// ...</c->
  <c- c1="">// this part of the function takes up to five milliseconds</c->
  <c- c1="">// set done to true if we're done</c->
  <c- c1="">// ...</c->
  <c- k="">return</c-> done<c- p="">;</c->
<c- p="">}</c->

<c- a="">function</c-> rescheduleWork<c- p="">()</c-> <c- p="">{</c->
  <c- a="">var</c-> id <c- o="">=</c-> setTimeout<c- p="">(</c->rescheduleWork<c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c-> <c- c1="">// preschedule next iteration</c->
  <c- k="">if</c-> <c- p="">(</c->doExpensiveWork<c- p="">())</c->
    clearTimeout<c- p="">(</c->id<c- p="">);</c-> <c- c1="">// clear the timeout if we don't need it</c->
<c- p="">}</c->

<c- a="">function</c-> scheduleWork<c- p="">()</c-> <c- p="">{</c->
  setTimeout<c- p="">(</c->rescheduleWork<c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->
<c- p="">}</c->

scheduleWork<c- p="">();</c-> <c- c1="">// queues a task to do lots of work</c-></code></pre>
  </div>

  

  <p>Objects that implement the <code id="timers:windoworworkerglobalscope-3"><a href="#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a></code> mixin have a <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="map-of-active-timers" data-export="">map of active timers</dfn>, which is an <a id="timers:ordered-map-2" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>,
  initially empty. Each <a href="https://infra.spec.whatwg.org/#map-key" id="timers:map-key-2" data-x-internal="map-key">key</a> in this map is a <a href="#unique-internal-value" id="timers:unique-internal-value-3">unique internal
  value</a> that represents a timer, and each <a href="https://infra.spec.whatwg.org/#map-value" id="timers:map-value-2" data-x-internal="map-value">value</a> is a
  <code id="timers:domhighrestimestamp"><a data-x-internal="domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp">DOMHighResTimeStamp</a></code>, representing the expiry time for that timer.</p>

  <div data-algorithm="">
  <p>To <dfn id="run-steps-after-a-timeout" data-export="">run steps after a timeout</dfn>, given a <code id="timers:windoworworkerglobalscope-4"><a href="#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a></code>
  <var>global</var>, a string <var>orderingIdentifier</var>, a number <var>milliseconds</var>, and a
  set of steps <var>completionSteps</var>, perform the following steps. They return a <a href="#unique-internal-value" id="timers:unique-internal-value-4">unique
  internal value</a>.</p>

  <ol><li><p>Let <var>timerKey</var> be a new <a href="#unique-internal-value" id="timers:unique-internal-value-5">unique internal value</a>.</p></li><li><p>Let <var>startTime</var> be the <a id="timers:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given
   <var>global</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="timers:map-set-2" data-x-internal="map-set">Set</a> <var>global</var>'s <a href="#map-of-active-timers" id="timers:map-of-active-timers-2">map of active
   timers</a>[<var>timerKey</var>] to <var>startTime</var> plus
   <var>milliseconds</var>.</p></li><li>
    <p>Run the following steps <a href="#in-parallel" id="timers:in-parallel">in parallel</a>:</p>

    <ol><li>
      <p>If <var>global</var> is a <code id="timers:window-2"><a href="#window">Window</a></code> object, wait until <var>global</var>'s <a href="#concept-document-window" id="timers:concept-document-window">associated <code>Document</code></a> has been <a href="#fully-active" id="timers:fully-active">fully
      active</a> for a further <var>milliseconds</var> milliseconds (not necessarily
      consecutively).</p>

      <p>Otherwise, <var>global</var> is a <code id="timers:workerglobalscope-2"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object; wait until
      <var>milliseconds</var> milliseconds have passed with the worker not suspended (not
      necessarily consecutively).</p>
     </li><li><p>Wait until any invocations of this algorithm that had the same <var>global</var> and
     <var>orderingIdentifier</var>, that started before this one, and whose <var>milliseconds</var>
     is less than or equal to this one's, have completed.</p></li><li>
      <p>Optionally, wait a further <a id="timers:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> length of time.</p>

      <p class="note">This is intended to allow user agents to pad timeouts as needed to optimize
      the power usage of the device. For example, some processors have a low-power mode where the
      granularity of timers is reduced; on such platforms, user agents can slow timers down to fit
      this schedule instead of requiring the processor to use the more accurate mode with its
      associated higher power usage.</p>
     </li><li><p>Perform <var>completionSteps</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="timers:map-remove-3" data-x-internal="map-remove">Remove</a> <var>global</var>'s
     <a href="#map-of-active-timers" id="timers:map-of-active-timers-3">map of active timers</a>[<var>timerKey</var>].</p></li></ol>
   </li><li><p>Return <var>timerKey</var>.</p></li></ol>

  <p class="note"><a href="#run-steps-after-a-timeout" id="timers:run-steps-after-a-timeout-2">Run steps after a timeout</a> is meant to be used by other
  specifications that want to execute developer-supplied code after a developer-supplied timeout,
  in a similar manner to <code id="timers:dom-settimeout-11"><a href="#dom-settimeout">setTimeout()</a></code>. (Note, however, it does
  not have the nesting and clamping behavior of <code id="timers:dom-settimeout-12"><a href="#dom-settimeout">setTimeout()</a></code>.)
  Such specifications can choose an <var>orderingIdentifier</var> to ensure ordering within their
  specification's timeouts, while not constraining ordering with respect to other specification's
  timeouts.</p>
  </div>

  

  <h3 id="microtask-queuing"><span class="secno">8.7</span> Microtask queuing<a href="#microtask-queuing" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask" title="The queueMicrotask() method, which is exposed on the Window or Worker interface, queues a microtask to be executed at a safe time prior to control returning to the browser's event loop.">queueMicrotask</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>69+</span></span><span class="safari yes"><span>Safari</span><span>12.1+</span></span><span class="chrome yes"><span>Chrome</span><span>71+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <dl class="domintro"><dt><code><var>self</var>.<a href="#dom-queuemicrotask" id="dom-queuemicrotask-dev">queueMicrotask</a>(<var>callback</var>)</code></dt><dd><p><a href="#queue-a-microtask" id="microtask-queuing:queue-a-microtask">Queues</a> a <a href="#microtask" id="microtask-queuing:microtask">microtask</a> to run the given
   <var>callback</var>.</p></dd></dl>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-queuemicrotask" data-dfn-type="method"><code>queueMicrotask(<var>callback</var>)</code></dfn> method must
  <a href="#queue-a-microtask" id="microtask-queuing:queue-a-microtask-2">queue a microtask</a> to <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="microtask-queuing:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">invoke</a>
  <var>callback</var> with « » and "<code>report</code>".</p>
  </div>

  <p>The <code id="microtask-queuing:dom-queuemicrotask"><a href="#dom-queuemicrotask">queueMicrotask()</a></code> method allows authors to schedule
  a callback on the <a href="#microtask-queue" id="microtask-queuing:microtask-queue">microtask queue</a>. This allows their code to run once the
  <a id="microtask-queuing:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> is next empty, which happens once all currently
  executing synchronous JavaScript has run to completion. This doesn't yield control back to the
  <a href="#event-loop" id="microtask-queuing:event-loop">event loop</a>, as would be the case when using, for example, <code id="microtask-queuing:dom-settimeout"><a href="#dom-settimeout">setTimeout(<var>f</var>,&nbsp;0)</a></code>.</p>

  <p>Authors ought to be aware that scheduling a lot of microtasks has the same performance
  downsides as running a lot of synchronous code. Both will prevent the browser from doing its own
  work, such as rendering. In many cases, <code id="microtask-queuing:dom-animationframeprovider-requestanimationframe"><a href="#dom-animationframeprovider-requestanimationframe">requestAnimationFrame()</a></code> or
  <code id="microtask-queuing:requestidlecallback()"><a data-x-internal="requestidlecallback()" href="https://w3c.github.io/requestidlecallback/#the-requestidlecallback-method">requestIdleCallback()</a></code> is a better choice. In particular, if the goal is to run code
  before the next rendering cycle, that is the purpose of <code id="microtask-queuing:dom-animationframeprovider-requestanimationframe-2"><a href="#dom-animationframeprovider-requestanimationframe">requestAnimationFrame()</a></code>.</p>

  <p>As can be seen from the following examples, the best way of thinking about <code id="microtask-queuing:dom-queuemicrotask-2"><a href="#dom-queuemicrotask">queueMicrotask()</a></code> is as a mechanism for rearranging synchronous
  code, effectively placing the queued code immediately after the currently executing synchronous
  JavaScript has run to completion.</p>

  <div class="example">
   <p>The most common reason for using <code id="microtask-queuing:dom-queuemicrotask-3"><a href="#dom-queuemicrotask">queueMicrotask()</a></code> is
   to create consistent ordering, even in the cases where information is available synchronously,
   without introducing undue delay.</p>

   <p>For example, consider a custom element firing a <code>load</code> event, that also
   maintains an internal cache of previously-loaded data. A naïve implementation might look
   like:</p>

   <pre><code class="js">MyElement<c- p="">.</c->prototype<c- p="">.</c->loadData <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->url<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->_cache<c- p="">[</c->url<c- p="">])</c-> <c- p="">{</c->
    <c- k="">this</c-><c- p="">.</c->_setData<c- p="">(</c-><c- k="">this</c-><c- p="">.</c->_cache<c- p="">[</c->url<c- p="">]);</c->
    <c- k="">this</c-><c- p="">.</c->dispatchEvent<c- p="">(</c-><c- k="">new</c-> Event<c- p="">(</c-><c- u="">"load"</c-><c- p="">));</c->
  <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
    fetch<c- p="">(</c->url<c- p="">).</c->then<c- p="">(</c->res <c- p="">=&gt;</c-> res<c- p="">.</c->arrayBuffer<c- p="">()).</c->then<c- p="">(</c->data <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- k="">this</c-><c- p="">.</c->_cache<c- p="">[</c->url<c- p="">]</c-> <c- o="">=</c-> data<c- p="">;</c->
      <c- k="">this</c-><c- p="">.</c->_setData<c- p="">(</c->data<c- p="">);</c->
      <c- k="">this</c-><c- p="">.</c->dispatchEvent<c- p="">(</c-><c- k="">new</c-> Event<c- p="">(</c-><c- u="">"load"</c-><c- p="">));</c->
    <c- p="">});</c->
  <c- p="">}</c->
<c- p="">};</c-></code></pre>

   <p>This naïve implementation is problematic, however, in that it causes its users to
   experience inconsistent behavior. For example, code such as</p>

   <pre><code class="js">element<c- p="">.</c->addEventListener<c- p="">(</c-><c- u="">"load"</c-><c- p="">,</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> console<c- p="">.</c->log<c- p="">(</c-><c- u="">"loaded"</c-><c- p="">));</c->
console<c- p="">.</c->log<c- p="">(</c-><c- u="">"1"</c-><c- p="">);</c->
element<c- p="">.</c->loadData<c- p="">();</c->
console<c- p="">.</c->log<c- p="">(</c-><c- u="">"2"</c-><c- p="">);</c-></code></pre>

   <p>will sometimes log "1, 2, loaded" (if the data needs to be fetched), and sometimes log "1,
   loaded, 2" (if the data is already cached). Similarly, after the call to <code>loadData()</code>, it will be inconsistent whether or not the data is set on the
   element.</p>

   <p>To get a consistent ordering, <code id="microtask-queuing:dom-queuemicrotask-4"><a href="#dom-queuemicrotask">queueMicrotask()</a></code> can be
   used:</p>

   <pre><code class="js">MyElement<c- p="">.</c->prototype<c- p="">.</c->loadData <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->url<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c-><c- k="">this</c-><c- p="">.</c->_cache<c- p="">[</c->url<c- p="">])</c-> <c- p="">{</c-><strong>
    queueMicrotask<c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- k="">this</c-><c- p="">.</c->_setData<c- p="">(</c-><c- k="">this</c-><c- p="">.</c->_cache<c- p="">[</c->url<c- p="">]);</c->
      <c- k="">this</c-><c- p="">.</c->dispatchEvent<c- p="">(</c-><c- k="">new</c-> Event<c- p="">(</c-><c- u="">"load"</c-><c- p="">));</c->
    <c- p="">});</c-></strong>
  <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
    fetch<c- p="">(</c->url<c- p="">).</c->then<c- p="">(</c->res <c- p="">=&gt;</c-> res<c- p="">.</c->arrayBuffer<c- p="">()).</c->then<c- p="">(</c->data <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- k="">this</c-><c- p="">.</c->_cache<c- p="">[</c->url<c- p="">]</c-> <c- o="">=</c-> data<c- p="">;</c->
      <c- k="">this</c-><c- p="">.</c->_setData<c- p="">(</c->data<c- p="">);</c->
      <c- k="">this</c-><c- p="">.</c->dispatchEvent<c- p="">(</c-><c- k="">new</c-> Event<c- p="">(</c-><c- u="">"load"</c-><c- p="">));</c->
    <c- p="">});</c->
  <c- p="">}</c->
<c- p="">};</c-></code></pre>

   <p>By essentially rearranging the queued code to be after the <a id="microtask-queuing:javascript-execution-context-stack-2" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context
   stack</a> empties, this ensures a consistent ordering and update of the element's state.</p>
  </div>

  <div class="example">
   <p>Another interesting use of <code id="microtask-queuing:dom-queuemicrotask-5"><a href="#dom-queuemicrotask">queueMicrotask()</a></code> is to
   allow uncoordinated "batching" of work by multiple callers. For example, consider a library
   function that wants to send data somewhere as soon as possible, but doesn't want to make multiple
   network requests if doing so is easily avoidable. One way to balance this would be like so:</p>

   <pre><code class="js"><c- a="">const</c-> queuedToSend <c- o="">=</c-> <c- p="">[];</c->

<c- a="">function</c-> sendData<c- p="">(</c->data<c- p="">)</c-> <c- p="">{</c->
  queuedToSend<c- p="">.</c->push<c- p="">(</c->data<c- p="">);</c->

  <c- k="">if</c-> <c- p="">(</c->queuedToSend<c- p="">.</c->length <c- o="">===</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
    queueMicrotask<c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- a="">const</c-> stringToSend <c- o="">=</c-> JSON<c- p="">.</c->stringify<c- p="">(</c->queuedToSend<c- p="">);</c->
      queuedToSend<c- p="">.</c->length <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->

      fetch<c- p="">(</c-><c- u="">"/endpoint"</c-><c- p="">,</c-> stringToSend<c- p="">);</c->
    <c- p="">});</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>With this architecture, multiple subsequent calls to <code>sendData()</code> within
   the currently executing synchronous JavaScript will be batched together into one
   <code id="microtask-queuing:fetch()"><a data-x-internal="fetch()" href="https://fetch.spec.whatwg.org/#dom-global-fetch">fetch()</a></code> call, but with no intervening event loop tasks preempting the fetch (as
   would have happened with similar code that instead used <code id="microtask-queuing:dom-settimeout-2"><a href="#dom-settimeout">setTimeout()</a></code>).</p>
  </div>


  <h3 id="user-prompts"><span class="secno">8.8</span> User prompts<a href="#user-prompts" class="self-link"></a></h3>

  

  <h4 id="simple-dialogs"><span class="secno">8.8.1</span> Simple dialogs<a href="#simple-dialogs" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-alert" id="dom-alert-dev">alert</a>(<var>message</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/alert" title="window.alert() instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.">Window/alert</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Displays a modal alert with the given message, and waits for the user to dismiss
   it.</p></dd><dt><code><var>result</var> = <var>window</var>.<a href="#dom-confirm" id="dom-confirm-dev">confirm</a>(<var>message</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm" title="window.confirm() instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels the dialog.">Window/confirm</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>1+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Displays a modal OK/Cancel prompt with the given message, waits for the user to dismiss it,
    and returns true if the user clicks OK and false if the user clicks Cancel.</p>
   </dd><dt><code><var>result</var> = <var>window</var>.<a href="#dom-prompt" id="dom-prompt-dev">prompt</a>(<var>message</var> [, <var>default</var>])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt" title="window.prompt() instructs the browser to display a dialog with an optional message prompting the user to input some text, and to wait until the user either submits the text or cancels the dialog.">Window/prompt</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Displays a modal text control prompt with the given message, waits for the user to dismiss
    it, and returns the value that the user entered. If the user cancels the prompt, then returns
    null instead. If the second argument is present, then the given value is used as a default.</p>
   </dd></dl>

  <p class="note">Logic that depends on <a href="#concept-task" id="simple-dialogs:concept-task">tasks</a> or <a href="#microtask" id="simple-dialogs:microtask">microtasks</a>, such as <a href="#media-element" id="simple-dialogs:media-element">media elements</a>
  loading their <a href="#media-data" id="simple-dialogs:media-data">media data</a>, are stalled when these methods are invoked.</p>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-alert-noargs" data-dfn-type="method"><code>alert()</code></dfn> and <dfn data-dfn-for="Window" id="dom-alert" data-dfn-type="method"><code>alert(<var>message</var>)</code></dfn> method steps
  are:</p>

  <ol><li><p>If we <a href="#cannot-show-simple-dialogs" id="simple-dialogs:cannot-show-simple-dialogs">cannot show simple dialogs</a> for <a id="simple-dialogs:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, then return.</p></li><li><p>If the method was invoked with no arguments, then let <var>message</var> be the
   empty string; otherwise, let <var>message</var> be the method's first
   argument.</p></li><li><p>Set <var>message</var> to the result of <a href="https://infra.spec.whatwg.org/#normalize-newlines" id="simple-dialogs:normalize-newlines" data-x-internal="normalize-newlines">normalizing
   newlines</a> given <var>message</var>.</p></li><li><p>Set <var>message</var> to the result of <a href="#optionally-truncate-a-simple-dialog-string" id="simple-dialogs:optionally-truncate-a-simple-dialog-string">optionally truncating</a> <var>message</var>.</p></li><li><p>Let <var>userPromptHandler</var> be <a id="simple-dialogs:webdriver-bidi-user-prompt-opened" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-opened" data-x-internal="webdriver-bidi-user-prompt-opened">WebDriver BiDi user prompt opened</a> with
   <a id="simple-dialogs:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, "<code>alert</code>", and <var>message</var>.</p></li><li>
    <p>If <var>userPromptHandler</var> is "<code>none</code>", then:</p>

    <ol><li><p>Show <var>message</var> to the user, treating U+000A LF as a line break.</p></li><li><p>Optionally, <a href="#pause" id="simple-dialogs:pause">pause</a> while waiting for the user to acknowledge the
     message.</p></li></ol>
   </li><li><p>Invoke <a id="simple-dialogs:webdriver-bidi-user-prompt-closed" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-closed" data-x-internal="webdriver-bidi-user-prompt-closed">WebDriver BiDi user prompt closed</a> with <a id="simple-dialogs:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>,
   "<code>alert</code>", and true.</p></li></ol>
  </div>

  <p class="note">This method is defined using two overloads, instead of using an
  optional argument, for historical reasons. The practical impact of this is
  that <code class="js">alert(undefined)</code> is treated as <code class="js">alert("undefined")</code>, but <code class="js">alert()</code> is treated as
  <code class="js">alert("")</code>.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-confirm" data-dfn-type="method"><code>confirm(<var>message</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If we <a href="#cannot-show-simple-dialogs" id="simple-dialogs:cannot-show-simple-dialogs-2">cannot show simple dialogs</a> for <a id="simple-dialogs:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, then return
   false.</p></li><li><p>Set <var>message</var> to the result of <a href="https://infra.spec.whatwg.org/#normalize-newlines" id="simple-dialogs:normalize-newlines-2" data-x-internal="normalize-newlines">normalizing
   newlines</a> given <var>message</var>.</p></li><li><p>Set <var>message</var> to the result of <a href="#optionally-truncate-a-simple-dialog-string" id="simple-dialogs:optionally-truncate-a-simple-dialog-string-2">optionally truncating</a> <var>message</var>.</p></li><li><p>Show <var>message</var> to the user, treating U+000A LF as a line break, and ask the user
   to respond with a positive or negative response.</p></li><li><p>Let <var>userPromptHandler</var> be <a id="simple-dialogs:webdriver-bidi-user-prompt-opened-2" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-opened" data-x-internal="webdriver-bidi-user-prompt-opened">WebDriver BiDi user prompt opened</a> with
   <a id="simple-dialogs:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, "<code>confirm</code>", and <var>message</var>.</p></li><li><p>Let <var>accepted</var> be false.</p></li><li>
    <p>If <var>userPromptHandler</var> is "<code>none</code>", then:</p>

    <ol><li><p><a href="#pause" id="simple-dialogs:pause-2">Pause</a> until the user responds either positively or negatively.</p></li><li><p>If the user responded positively, then set <var>accepted</var> to true.</p></li></ol>
   </li><li><p>If <var>userPromptHandler</var> is "<code>accept</code>", then set
   <var>accepted</var> to true.</p></li><li><p>Invoke <a id="simple-dialogs:webdriver-bidi-user-prompt-closed-2" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-closed" data-x-internal="webdriver-bidi-user-prompt-closed">WebDriver BiDi user prompt closed</a> with <a id="simple-dialogs:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>,
   "<code>confirm</code>", and <var>accepted</var>.</p></li><li><p>Return <var>accepted</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-prompt" data-dfn-type="method"><code>prompt(<var>message</var>,
  <var>default</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If we <a href="#cannot-show-simple-dialogs" id="simple-dialogs:cannot-show-simple-dialogs-3">cannot show simple dialogs</a> for <a id="simple-dialogs:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, then return
   null.</p></li><li><p>Set <var>message</var> to the result of <a href="https://infra.spec.whatwg.org/#normalize-newlines" id="simple-dialogs:normalize-newlines-3" data-x-internal="normalize-newlines">normalizing
   newlines</a> given <var>message</var>.</p></li><li><p>Set <var>message</var> to the result of <a href="#optionally-truncate-a-simple-dialog-string" id="simple-dialogs:optionally-truncate-a-simple-dialog-string-3">optionally truncating</a> <var>message</var>.</p></li><li><p>Set <var>default</var> to the result of <a href="#optionally-truncate-a-simple-dialog-string" id="simple-dialogs:optionally-truncate-a-simple-dialog-string-4">optionally truncating</a> <var>default</var>.</p></li><li><p>Show <var>message</var> to the user, treating U+000A LF as a line break, and ask the user
   to either respond with a string value or abort. The response must be defaulted to the value given
   by <var>default</var>.</p></li><li><p>Let <var>userPromptHandler</var> be <a id="simple-dialogs:webdriver-bidi-user-prompt-opened-3" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-opened" data-x-internal="webdriver-bidi-user-prompt-opened">WebDriver BiDi user prompt opened</a> with
   <a id="simple-dialogs:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, "<code>prompt</code>", and <var>message</var>.</p></li><li><p>Let <var>result</var> be null.</p></li><li>
    <p>If <var>userPromptHandler</var> is "<code>none</code>", then:</p>

    <ol><li><p><a href="#pause" id="simple-dialogs:pause-3">Pause</a> while waiting for the user's response.</p></li><li><p>If the user did not abort, then set <var>result</var> to the string that the user
     responded with.</p></li></ol>
   </li><li><p>Otherwise, if <var>userPromptHandler</var> is "<code>accept</code>", then set
   <var>result</var> to the empty string.</p></li><li><p>Invoke <a id="simple-dialogs:webdriver-bidi-user-prompt-closed-3" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-closed" data-x-internal="webdriver-bidi-user-prompt-closed">WebDriver BiDi user prompt closed</a> with <a id="simple-dialogs:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>,
   "<code>prompt</code>", false if <var>result</var> is null or true otherwise,
   and <var>result</var>.</p></li><li><p>Return <var>result</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="optionally-truncate-a-simple-dialog-string">optionally truncate a simple dialog string</dfn> <var>s</var>, return either
  <var>s</var> itself or some string derived from <var>s</var> that is shorter. User agents should
  not provide UI for displaying the elided portion of <var>s</var>, as this makes it too easy for
  abusers to create dialogs of the form "Important security alert! Click 'Show More' for full
  details!".</p>
  </div>

  <p class="note">For example, a user agent might want to only display the first 100 characters of a
  message. Or, a user agent might replace the middle of the string with "…". These types of
  modifications can be useful in limiting the abuse potential of unnaturally large,
  trustworthy-looking system dialogs.</p>

  <div data-algorithm="">
  <p>We <dfn id="cannot-show-simple-dialogs">cannot show simple dialogs</dfn> for a <code id="simple-dialogs:window"><a href="#window">Window</a></code> <var>window</var> when the
  following algorithm returns true:</p>

  <ol><li><p>If the <a href="#active-sandboxing-flag-set" id="simple-dialogs:active-sandboxing-flag-set">active sandboxing flag set</a> of <var>window</var>'s <a href="#concept-document-window" id="simple-dialogs:concept-document-window">associated <code>Document</code></a> has the <a href="#sandboxed-modals-flag" id="simple-dialogs:sandboxed-modals-flag">sandboxed
   modals flag</a> set, then return true.</p></li><li><p>If <var>window</var>'s <a href="#relevant-settings-object" id="simple-dialogs:relevant-settings-object">relevant settings object</a>'s <a href="#concept-settings-object-origin" id="simple-dialogs:concept-settings-object-origin">origin</a> and <var>window</var>'s <a href="#relevant-settings-object" id="simple-dialogs:relevant-settings-object-2">relevant
   settings object</a>'s <a href="#concept-environment-top-level-origin" id="simple-dialogs:concept-environment-top-level-origin">top-level origin</a> are not <a href="#same-origin-domain" id="simple-dialogs:same-origin-domain">same origin-domain</a>,
   then return true.</p></li><li>If <var>window</var>'s <a href="#relevant-agent" id="simple-dialogs:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="simple-dialogs:concept-agent-event-loop">event loop</a>'s <a href="#termination-nesting-level" id="simple-dialogs:termination-nesting-level">termination nesting level</a> is
   nonzero, then optionally return true.</li><li><p>Optionally, return true. (For example, the user agent might give the
   user the option to ignore all modal dialogs, and would thus abort at this step whenever the method was
   invoked.)</p></li><li><p>Return false.</p></li></ol>
  </div>

  


  <h4 id="printing"><span class="secno">8.8.2</span> Printing<a href="#printing" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/print" title="Opens the print dialog to print the current document.">Window/print</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>5+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>114+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-print" id="dom-print-dev">print</a>()</code></dt><dd><p>Prompts the user to print the page.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-print" data-dfn-type="method"><code>print()</code></dfn> method steps
  are:</p>

  <ol><li><p>Let <var>document</var> be <a id="printing:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="printing:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>If <var>document</var> is not <a href="#fully-active" id="printing:fully-active">fully active</a>, then return.</p></li><li><p>If <var>document</var>'s <a href="#unload-counter" id="printing:unload-counter">unload counter</a> is greater than 0, then
   return.</p></li><li><p>If <var>document</var> is <a href="#ready-for-post-load-tasks" id="printing:ready-for-post-load-tasks">ready for post-load tasks</a>, then run the
   <a href="#printing-steps" id="printing:printing-steps">printing steps</a> for <var>document</var>.</p></li><li><p>Otherwise, set <var>document</var>'s <dfn id="print-when-loaded">print when loaded</dfn> flag.</p></li></ol>
  </div>

  <p>User agents should also run the <a href="#printing-steps" id="printing:printing-steps-2">printing steps</a> whenever the user asks for the
  opportunity to <a href="#obtain-a-physical-form" id="printing:obtain-a-physical-form">obtain a physical form</a> (e.g. printed copy), or the representation of a
  physical form (e.g. PDF copy), of a document.</p>

  <div data-algorithm="">
  <p>The <dfn id="printing-steps">printing steps</dfn> for a <code id="printing:document"><a href="#document">Document</a></code> <var>document</var> are:</p>

  <ol><li>
    <p>The user agent may display a message to the user or return (or both).</p>

    <p class="example">For instance, a kiosk browser could silently ignore any invocations of the
    <code id="printing:dom-print"><a href="#dom-print">print()</a></code> method.</p>

    <p class="example">For instance, a browser on a mobile device could detect that there are no
    printers in the vicinity and display a message saying so before continuing to offer a "save to
    PDF" option.</p>
   </li><li>
    <p>If the <a href="#active-sandboxing-flag-set" id="printing:active-sandboxing-flag-set">active sandboxing flag set</a> of <var>document</var> has the <a href="#sandboxed-modals-flag" id="printing:sandboxed-modals-flag">sandboxed
    modals flag</a> set, then return.</p>

    <p class="note">If the printing dialog is blocked by a <code id="printing:document-2"><a href="#document">Document</a></code>'s sandbox,
    then neither the <code id="printing:event-beforeprint"><a href="#event-beforeprint">beforeprint</a></code> nor <code id="printing:event-afterprint"><a href="#event-afterprint">afterprint</a></code> events will be fired.</p>
   </li><li>
    <p>The user agent must <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="printing:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="printing:event-beforeprint-2"><a href="#event-beforeprint">beforeprint</a></code> at the <a href="#concept-relevant-global" id="printing:concept-relevant-global">relevant global object</a> of
    <var>document</var>, as well as any <a href="#child-navigable" id="printing:child-navigable">child navigable</a> in
    it.</p>

    <p class="XXX">Firing in children only doesn't seem right here, and some tasks likely need to
    be queued. See <a href="https://github.com/whatwg/html/issues/5096">issue #5096</a>.</p>

    <p class="example">The <code id="printing:event-beforeprint-3"><a href="#event-beforeprint">beforeprint</a></code> event can be used to
    annotate the printed copy, for instance adding the time at which the document was printed.</p>
   </li><li><p>The user agent should offer the user the opportunity to <a href="#obtain-a-physical-form" id="printing:obtain-a-physical-form-2">obtain a physical
   form</a> (or the representation of a physical form) of <var>document</var>. The user agent may
   wait for the user to either accept or decline before returning; if so, the user agent must
   <a href="#pause" id="printing:pause">pause</a> while the method is waiting. Even if the user agent doesn't wait at this
   point, the user agent must use the state of the relevant documents as they are at this point in
   the algorithm if and when it eventually creates the alternate form.</p></li><li>
    <p>The user agent must <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="printing:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="printing:event-afterprint-2"><a href="#event-afterprint">afterprint</a></code> at the <a href="#concept-relevant-global" id="printing:concept-relevant-global-2">relevant global object</a> of
    <var>document</var>, as well as any <a href="#child-navigable" id="printing:child-navigable-2">child navigables</a> in
    it.</p>

    <p class="XXX">Firing in children only doesn't seem right here, and some tasks likely need to
    be queued. See <a href="https://github.com/whatwg/html/issues/5096">issue #5096</a>.</p>

    <p class="example">The <code id="printing:event-afterprint-3"><a href="#event-afterprint">afterprint</a></code> event can be used to
    revert annotations added in the earlier event, as well as showing post-printing UI. For
    instance, if a page is walking the user through the steps of applying for a home loan, the
    script could automatically advance to the next step after having printed a form or other.</p>
   </li></ol>
  </div>

  


  <h3 id="system-state-and-capabilities"><span class="secno">8.9</span> System state and capabilities<a href="#system-state-and-capabilities" class="self-link"></a></h3>

  <h4 id="the-navigator-object"><span class="secno">8.9.1</span> The <code id="the-navigator-object:navigator"><a href="#navigator">Navigator</a></code> object<a href="#the-navigator-object" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator" title="The Navigator interface represents the state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities.">Navigator</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <p>Instances of <code id="the-navigator-object:navigator-2"><a href="#navigator">Navigator</a></code> represent the identity and state of the user agent (the
  client). It has also been used as a generic global under which various APIs are located, but this
  is not precedent to build upon. Instead use the <code id="the-navigator-object:windoworworkerglobalscope"><a href="#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a></code> mixin or
  equivalent.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="navigator" data-dfn-type="interface"><c- g="">Navigator</c-></dfn> {
  // objects implementing this interface also implement the interfaces given below
};
<a href="#navigator" id="the-navigator-object:navigator-3"><c- n="">Navigator</c-></a> <c- b="">includes</c-> <a href="#navigatorid" id="the-navigator-object:navigatorid"><c- n="">NavigatorID</c-></a>;
<a href="#navigator" id="the-navigator-object:navigator-4"><c- n="">Navigator</c-></a> <c- b="">includes</c-> <a href="#navigatorlanguage" id="the-navigator-object:navigatorlanguage"><c- n="">NavigatorLanguage</c-></a>;
<a href="#navigator" id="the-navigator-object:navigator-5"><c- n="">Navigator</c-></a> <c- b="">includes</c-> <a href="#navigatoronline" id="the-navigator-object:navigatoronline"><c- n="">NavigatorOnLine</c-></a>;
<a href="#navigator" id="the-navigator-object:navigator-6"><c- n="">Navigator</c-></a> <c- b="">includes</c-> <a href="#navigatorcontentutils" id="the-navigator-object:navigatorcontentutils"><c- n="">NavigatorContentUtils</c-></a>;
<a href="#navigator" id="the-navigator-object:navigator-7"><c- n="">Navigator</c-></a> <c- b="">includes</c-> <a href="#navigatorcookies" id="the-navigator-object:navigatorcookies"><c- n="">NavigatorCookies</c-></a>;
<a href="#navigator" id="the-navigator-object:navigator-8"><c- n="">Navigator</c-></a> <c- b="">includes</c-> <a href="#navigatorplugins" id="the-navigator-object:navigatorplugins"><c- n="">NavigatorPlugins</c-></a>;
<a href="#navigator" id="the-navigator-object:navigator-9"><c- n="">Navigator</c-></a> <c- b="">includes</c-> <a href="#navigatorconcurrenthardware" id="the-navigator-object:navigatorconcurrenthardware"><c- n="">NavigatorConcurrentHardware</c-></a>;</code></pre>

  

  <p class="note">These interface mixins are defined separately so that <code id="the-navigator-object:workernavigator"><a href="#workernavigator">WorkerNavigator</a></code> can reuse parts of
  the <code id="the-navigator-object:navigator-10"><a href="#navigator">Navigator</a></code> interface.</p>

  <div data-algorithm="">
  <p>Each <code id="the-navigator-object:window"><a href="#window">Window</a></code> has an <dfn id="associated-navigator">associated <code>Navigator</code></dfn>, which is a <code id="the-navigator-object:navigator-11"><a href="#navigator">Navigator</a></code>
  object. Upon creation of the <code id="the-navigator-object:window-2"><a href="#window">Window</a></code> object, its <a href="#associated-navigator" id="the-navigator-object:associated-navigator">associated <code>Navigator</code></a> must be
  set to a <a id="the-navigator-object:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="the-navigator-object:navigator-12"><a href="#navigator">Navigator</a></code> object created in the <code id="the-navigator-object:window-3"><a href="#window">Window</a></code> object's <a href="#concept-relevant-realm" id="the-navigator-object:concept-relevant-realm">relevant realm</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/navigator" title="The Window.navigator read-only property returns a reference to the Navigator object, which has methods and properties about the application running the script.">Window/navigator</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-navigator" data-dfn-type="attribute"><code>navigator</code></dfn> and <dfn data-dfn-for="Window" id="dom-clientinformation" data-dfn-type="attribute"><code>clientInformation</code></dfn> getter steps are to return
  <a id="the-navigator-object:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#associated-navigator" id="the-navigator-object:associated-navigator-2">associated <code>Navigator</code></a>.
  </p></div>

  


  <h5 id="client-identification"><span class="secno">8.9.1.1</span> Client identification<a href="#client-identification" class="self-link"></a></h5>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="navigatorid" data-dfn-type="interface"><c- g="">NavigatorID</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-appcodename" id="client-identification:dom-navigator-appcodename"><c- g="">appCodeName</c-></a>; // constant "Mozilla"
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-appname" id="client-identification:dom-navigator-appname"><c- g="">appName</c-></a>; // constant "Netscape"
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-appversion" id="client-identification:dom-navigator-appversion"><c- g="">appVersion</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-platform" id="client-identification:dom-navigator-platform"><c- g="">platform</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-product" id="client-identification:dom-navigator-product"><c- g="">product</c-></a>; // constant "Gecko"
  [<c- g="">Exposed</c->=<c- n="">Window</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-productsub" id="client-identification:dom-navigator-productsub"><c- g="">productSub</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-useragent" id="client-identification:dom-navigator-useragent"><c- g="">userAgent</c-></a>;
  [<c- g="">Exposed</c->=<c- n="">Window</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-vendor" id="client-identification:dom-navigator-vendor"><c- g="">vendor</c-></a>;
  [<c- g="">Exposed</c->=<c- n="">Window</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-vendorsub" id="client-identification:dom-navigator-vendorsub"><c- g="">vendorSub</c-></a>; // constant ""
};</code></pre>

  <p>In certain cases, despite the best efforts of the entire industry, web browsers have bugs and
  limitations that web authors are forced to work around.</p>

  <p>This section defines a collection of attributes that can be used to determine, from script, the
  kind of user agent in use, in order to work around these issues.</p>

  

  <p>The user agent has a <dfn id="concept-navigator-compatibility-mode">navigator compatibility
  mode</dfn>, which is either <i>Chrome</i>, <i>Gecko</i>, or <i>WebKit</i>.</p>

  <p class="note">The <a href="#concept-navigator-compatibility-mode" id="client-identification:concept-navigator-compatibility-mode">navigator compatibility
  mode</a> constrains the <code id="client-identification:navigatorid"><a href="#navigatorid">NavigatorID</a></code> mixin to the combinations of attribute
  values and presence of <code id="client-identification:dom-navigator-taintenabled"><a href="#dom-navigator-taintenabled">taintEnabled()</a></code> and <code id="client-identification:dom-navigator-oscpu"><a href="#dom-navigator-oscpu">oscpu</a></code> that are known to be compatible with existing web
  content.</p>

  

  <p>Client detection should always be limited to detecting known current versions; future versions
  and unknown versions should always be assumed to be fully compliant.</p>

  <dl class="domintro"><dt><code><var>self</var>.<a href="#dom-navigator" id="client-identification:dom-navigator">navigator</a>.<a href="#dom-navigator-appcodename" id="dom-navigator-appcodename-dev">appCodeName</a></code></dt><dd><p>Returns the string "<code>Mozilla</code>".</p></dd><dt><code><var>self</var>.<a href="#dom-navigator" id="client-identification:dom-navigator-2">navigator</a>.<a href="#dom-navigator-appname" id="dom-navigator-appname-dev">appName</a></code></dt><dd><p>Returns the string "<code>Netscape</code>".</p></dd><dt><code><var>self</var>.<a href="#dom-navigator" id="client-identification:dom-navigator-3">navigator</a>.<a href="#dom-navigator-appversion" id="dom-navigator-appversion-dev">appVersion</a></code></dt><dd><p>Returns the version of the browser.</p></dd><dt><code><var>self</var>.<a href="#dom-navigator" id="client-identification:dom-navigator-4">navigator</a>.<a href="#dom-navigator-platform" id="dom-navigator-platform-dev">platform</a></code></dt><dd><p>Returns the name of the platform.</p></dd><dt><code><var>self</var>.<a href="#dom-navigator" id="client-identification:dom-navigator-5">navigator</a>.<a href="#dom-navigator-product" id="dom-navigator-product-dev">product</a></code></dt><dd><p>Returns the string "<code>Gecko</code>".</p></dd><dt><code><var>window</var>.<a href="#dom-navigator" id="client-identification:dom-navigator-6">navigator</a>.<a href="#dom-navigator-productsub" id="dom-navigator-productsub-dev">productSub</a></code></dt><dd><p>Returns either the string "<code>20030107</code>", or the string "<code>20100101</code>".</p></dd><dt><code><var>self</var>.<a href="#dom-navigator" id="client-identification:dom-navigator-7">navigator</a>.<a href="#dom-navigator-useragent" id="dom-navigator-useragent-dev">userAgent</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent" title="The Navigator.userAgent read-only property returns the user agent string for the current browser.">Navigator/userAgent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator/userAgent" title="The WorkerNavigator.userAgent read-only property returns the user agent string for the current browser.">WorkerNavigator/userAgent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the complete `<code>User-Agent</code>` header.</p></dd><dt><code><var>window</var>.<a href="#dom-navigator" id="client-identification:dom-navigator-8">navigator</a>.<a href="#dom-navigator-vendor" id="dom-navigator-vendor-dev">vendor</a></code></dt><dd><p>Returns either the empty string, the string "<code>Apple Computer, Inc.</code>",
   or the string "<code>Google Inc.</code>".</p></dd><dt><code><var>window</var>.<a href="#dom-navigator" id="client-identification:dom-navigator-9">navigator</a>.<a href="#dom-navigator-vendorsub" id="dom-navigator-vendorsub-dev">vendorSub</a></code></dt><dd><p>Returns the empty string.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-appcodename" data-dfn-type="attribute"><code>appCodeName</code></dfn> getter steps are to return
  "<code>Mozilla</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-appname" data-dfn-type="attribute"><code>appName</code></dfn>
  getter steps are to return "<code>Netscape</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-appversion" data-dfn-type="attribute"><code>appVersion</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>userAgent</var> be <a id="client-identification:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="client-identification:relevant-settings-object">relevant settings object</a>'s
   <a href="https://fetch.spec.whatwg.org/#environment-default-user-agent-value" id="client-identification:environment-default-user-agent-value" data-x-internal="environment-default-user-agent-value">environment default `<code>User-Agent</code>`
   value</a>.</p></li><li><p>If <var>userAgent</var> does not start with `<code>Mozilla/5.0 (</code>`, then
   return the empty string.</p></li><li><p>Let <var>trail</var> be the substring of <var>userAgent</var>, <a href="https://infra.spec.whatwg.org/#isomorphic-decode" id="client-identification:isomorphic-decode" data-x-internal="isomorphic-decode">isomorphic decoded</a>, that follows the "<code>Mozilla/</code>" prefix.</p></li><li>
    <dl class="switch"><dt>If the <a href="#concept-navigator-compatibility-mode" id="client-identification:concept-navigator-compatibility-mode-2">navigator compatibility
     mode</a> is <i>Chrome</i> or <i>WebKit</i></dt><dd><p>Return <var>trail</var>.</p></dd><dt>If the <a href="#concept-navigator-compatibility-mode" id="client-identification:concept-navigator-compatibility-mode-3">navigator compatibility
     mode</a> is <i>Gecko</i></dt><dd>
      <p>If <var>trail</var> starts with "<code>5.0 (Windows</code>", then return "<code>5.0 (Windows)</code>".</p>

      <p>Otherwise, return the prefix of <var>trail</var> up to but not including the first U+003B
      (;), concatenated with the character U+0029 RIGHT PARENTHESIS. For example, "<code>5.0 (Macintosh)</code>", "<code>5.0 (Android 10)</code>", or "<code>5.0 (X11)</code>".</p> 
     </dd></dl>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-platform" data-dfn-type="attribute"><code>platform</code></dfn>
  getter steps are to return a string representing the platform on which the
  browser is executing (e.g. "<code>MacIntel</code>", "<code>Win32</code>",
  "<code>Linux x86_64</code>", "<code>Linux armv81</code>") or, for privacy and
  compatibility, a string that is commonly returned on another platform.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-product" data-dfn-type="attribute"><code>product</code></dfn>
  getter steps are to return "<code>Gecko</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-productsub" data-dfn-type="attribute"><code>productSub</code></dfn>
  getter steps are to return the appropriate string from the following list:</p>

   <dl class="switch"><dt>If the <a href="#concept-navigator-compatibility-mode" id="client-identification:concept-navigator-compatibility-mode-4">navigator compatibility
     mode</a> is <i>Chrome</i> or <i>WebKit</i></dt><dd><p>The string "<code>20030107</code>".</p></dd><dt>If the <a href="#concept-navigator-compatibility-mode" id="client-identification:concept-navigator-compatibility-mode-5">navigator compatibility
     mode</a> is <i>Gecko</i></dt><dd><p>The string "<code>20100101</code>".</p></dd></dl>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-useragent" data-dfn-type="attribute"><code>userAgent</code></dfn>
  getter steps are to return <a id="client-identification:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="client-identification:relevant-settings-object-2">relevant settings object</a>'s <a href="https://fetch.spec.whatwg.org/#environment-default-user-agent-value" id="client-identification:environment-default-user-agent-value-2" data-x-internal="environment-default-user-agent-value">environment default `<code>User-Agent</code>` value</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-vendor" data-dfn-type="attribute"><code>vendor</code></dfn>
  getter steps are to return the appropriate string from the following list:</p>

   <dl class="switch"><dt>If the <a href="#concept-navigator-compatibility-mode" id="client-identification:concept-navigator-compatibility-mode-6">navigator compatibility
     mode</a> is <i>Chrome</i></dt><dd><p>The string "<code>Google Inc.</code>".</p></dd><dt>If the <a href="#concept-navigator-compatibility-mode" id="client-identification:concept-navigator-compatibility-mode-7">navigator compatibility
     mode</a> is <i>Gecko</i></dt><dd><p>The empty string.</p></dd><dt>If the <a href="#concept-navigator-compatibility-mode" id="client-identification:concept-navigator-compatibility-mode-8">navigator compatibility
     mode</a> is <i>WebKit</i></dt><dd><p>The string "<code>Apple Computer, Inc.</code>".</p></dd></dl>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-vendorsub" data-dfn-type="attribute"><code>vendorSub</code></dfn>
  getter steps are to return the empty string.</p>
  </div>

  <p>If the <a href="#concept-navigator-compatibility-mode" id="client-identification:concept-navigator-compatibility-mode-9">navigator compatibility mode</a>
  is <i>Gecko</i>, then the user agent must also support the following partial interface:</p>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <c- b="">mixin</c-> <a href="#navigatorid" id="NavigatorID-partial"><c- g="">NavigatorID</c-></a> {
  [<c- g="">Exposed</c->=<c- n="">Window</c->] <c- b="">boolean</c-> <a href="#dom-navigator-taintenabled" id="client-identification:dom-navigator-taintenabled-2"><c- g="">taintEnabled</c-></a>(); // constant false
  [<c- g="">Exposed</c->=<c- n="">Window</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-oscpu" id="client-identification:dom-navigator-oscpu-2"><c- g="">oscpu</c-></a>;
};</code></pre>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-taintenabled" data-dfn-type="method"><code>taintEnabled()</code></dfn> method must return false.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorID" id="dom-navigator-oscpu" data-dfn-type="attribute"><code>oscpu</code></dfn> attribute's getter must return
  either the empty string or a string representing the platform on which the browser is executing,
  e.g. "<code>Windows NT 10.0; Win64; x64</code>", "<code>Linux
  x86_64</code>".</p>
  </div>

  
  <p class="warning">
  <a id="client-identification:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  Any information in this API that varies from user to user can be used to profile the user. In
  fact, if enough such information is available, a user can actually be uniquely identified. For
  this reason, user agent implementers are strongly urged to include as little information in this
  API as possible.</p>

  

  

  <h5 id="language-preferences"><span class="secno">8.9.1.2</span> Language preferences<a href="#language-preferences" class="self-link"></a></h5>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="navigatorlanguage" data-dfn-type="interface"><c- g="">NavigatorLanguage</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-navigator-language" id="language-preferences:dom-navigator-language"><c- g="">language</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">FrozenArray</c->&lt;<c- b="">DOMString</c->&gt; <a href="#dom-navigator-languages" id="language-preferences:dom-navigator-languages"><c- g="">languages</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>self</var>.<a href="#dom-navigator" id="language-preferences:dom-navigator">navigator</a>.<a href="#dom-navigator-language" id="dom-navigator-language-dev">language</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language" title="The Navigator.language read-only property returns a string representing the preferred language of the user, usually the language of the browser UI.">Navigator/language</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator/language" title="The WorkerNavigator.language read-only property returns a string representing the preferred language of the user, usually the language of the browser UI.">WorkerNavigator/language</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Returns a language tag representing the user's preferred language.</p></dd><dt><code><var>self</var>.<a href="#dom-navigator" id="language-preferences:dom-navigator-2">navigator</a>.<a href="#dom-navigator-languages" id="dom-navigator-languages-dev">languages</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages" title="The Navigator.languages read-only property returns an array of strings representing the user's preferred languages. The language is described using language tags according to RFC 5646: Tags for Identifying Languages (also known as BCP 47). In the returned array they are ordered by preference with the most preferred language first.">Navigator/languages</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>32+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera yes"><span>Opera</span><span>24+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>16+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>3.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>24+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator/languages" title="The WorkerNavigator.languages read-only property returns an array of strings representing the user's preferred languages. The language is described using language tags according to RFC 5646: Tags for Identifying Languages (also known as BCP 47). In the returned array they are ordered by preference with the most preferred language first.">WorkerNavigator/languages</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>32+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera yes"><span>Opera</span><span>24+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>16+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>3.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>24+</span></span></div></div></div></dt><dd>
    <p>Returns an array of language tags representing the user's preferred languages, with the most
    preferred language first.</p>

    <p>The most preferred language is the one returned by <code id="language-preferences:dom-navigator-language-2"><a href="#dom-navigator-language">navigator.language</a></code>.</p>
   </dd></dl>

  <p class="note">A <code id="language-preferences:event-languagechange"><a href="#event-languagechange">languagechange</a></code> event is fired at the
  <code id="language-preferences:window"><a href="#window">Window</a></code> or <code id="language-preferences:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object when the user agent's understanding
  of what the user's preferred languages are changes.</p>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorLanguage" id="dom-navigator-language" data-dfn-type="attribute"><code>language</code></dfn> getter steps are to return a valid BCP 47
  language tag representing either <a href="#a-plausible-language" id="language-preferences:a-plausible-language">a plausible language</a> or the user's most preferred
  language. <a href="#refsBCP47">[BCP47]</a></p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorLanguage" id="dom-navigator-languages" data-dfn-type="attribute"><code>languages</code></dfn> getter steps are to
  return a <a id="language-preferences:frozen-array" href="https://webidl.spec.whatwg.org/#dfn-frozen-array-type" data-x-internal="frozen-array">frozen array</a> of valid BCP 47 language tags representing either one
  or more <a href="#a-plausible-language" id="language-preferences:a-plausible-language-2">plausible languages</a>, or the user's preferred
  languages, ordered by preference with the most preferred language first. The same object must be
  returned until the user agent needs to return different values, or values in a different order.
  <a href="#refsBCP47">[BCP47]</a></p>
  </div>

  <div data-algorithm="">
  <p>Whenever the user agent needs to make the <code id="language-preferences:dom-navigator-languages-2"><a href="#dom-navigator-languages">navigator.languages</a></code> attribute of a <code id="language-preferences:window-2"><a href="#window">Window</a></code>
  or <code id="language-preferences:workerglobalscope-2"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object <var>global</var> return a new set of language tags,
  the user agent must <a href="#queue-a-global-task" id="language-preferences:queue-a-global-task">queue a global task</a> on the <a href="#dom-manipulation-task-source" id="language-preferences:dom-manipulation-task-source">DOM manipulation task
  source</a> given <var>global</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="language-preferences:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a>
  named <code id="language-preferences:event-languagechange-2"><a href="#event-languagechange">languagechange</a></code> at <var>global</var>, and wait
  until that task begins to be executed before actually returning a new value.</p>
  </div>

  <p>To determine <dfn id="a-plausible-language">a plausible language</dfn>, the user agent should bear in mind the following:</p>

  <ul><li>
   <a id="language-preferences:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
   Any information in this API that varies from user to user can be used to profile or identify the
   user.</li><li>If the user is not using a service that obfuscates the user's point of origin (e.g. the Tor
   anonymity network), then the value that is least likely to distinguish the user from other users
   with similar origins (e.g. from the same IP address block) is the language used by the majority
   of such users. <a href="#refsTOR">[TOR]</a></li><li>If the user is using an anonymizing service, then the value "<code>en-US</code>" is
   suggested; if all users of the service use that same value, that reduces the possibility of
   distinguishing the users from each other.</li></ul>

  <p>
  <a id="language-preferences:tracking-vector-2" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  To avoid introducing any more fingerprinting vectors, user agents should use the same list for the
  APIs defined in this function as for the HTTP `<code id="language-preferences:http-accept-language"><a data-x-internal="http-accept-language" href="https://httpwg.org/specs/rfc7231.html#header.accept-language">Accept-Language</a></code>` header.</p>

  


  <h5 id="navigator.online"><span class="secno">8.9.1.3</span> <span id="browser-state"></span>Browser state<a href="#navigator.online" class="self-link"></a></h5>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="navigatoronline" data-dfn-type="interface"><c- g="">NavigatorOnLine</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigator-online" id="navigator.online:dom-navigator-online"><c- g="">onLine</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>self</var>.<a href="#dom-navigator" id="navigator.online:dom-navigator">navigator</a>.<a href="#dom-navigator-online" id="dom-navigator-online-dev">onLine</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine" title="Returns the online status of the browser. The property returns a boolean value, with true meaning online and false meaning offline. The property sends updates whenever the browser's ability to connect to the network changes. The update occurs when the user follows links or when a script requests a remote page. For example, the property should return false when users click links soon after they lose internet connection.">Navigator/onLine</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>3+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android yes"><span>WebView Android</span><span title="Partial implementation.">🔰 37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator/onLine" title="Returns the online status of the browser. The property returns a boolean value, with true meaning online and false meaning offline. The property sends updates whenever the browser's ability to connect to the network changes. The update occurs when the user follows links or when a script requests a remote page.">WorkerNavigator/onLine</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span title="Partial implementation.">🔰 4.4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>Returns false if the user agent is definitely offline (disconnected from the network).
    Returns true if the user agent might be online.</p>

    <p>The events <code id="navigator.online:event-online"><a href="#event-online">online</a></code> and <code id="navigator.online:event-offline"><a href="#event-offline">offline</a></code> are fired when the value of this attribute changes.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorOnLine" id="dom-navigator-online" data-dfn-type="attribute"><code>onLine</code></dfn> getter steps are to return true if
  <a id="navigator.online:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="navigator.online:relevant-settings-object">relevant settings object</a> <a id="navigator.online:is-offline" href="https://fetch.spec.whatwg.org/#is-offline" data-x-internal="is-offline">is offline</a> is false;
  otherwise false.</p>
  </div>

  <div data-algorithm="">
  <p>When the value that would be returned by the <code id="navigator.online:dom-navigator-online-2"><a href="#dom-navigator-online">navigator.onLine</a></code> attribute of a <code id="navigator.online:window"><a href="#window">Window</a></code> or
  <code id="navigator.online:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> <var>global</var> changes from true to false, the user agent must
  <a href="#queue-a-global-task" id="navigator.online:queue-a-global-task">queue a global task</a> on the <a href="#networking-task-source" id="navigator.online:networking-task-source">networking task source</a> given
  <var>global</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="navigator.online:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="navigator.online:event-offline-2"><a href="#event-offline">offline</a></code> at <var>global</var>.</p>
  </div>

  <div data-algorithm="">
  <p>On the other hand, when the value that would be returned by the <code id="navigator.online:dom-navigator-online-3"><a href="#dom-navigator-online">navigator.onLine</a></code> attribute of a <code id="navigator.online:window-2"><a href="#window">Window</a></code> or
  <code id="navigator.online:workerglobalscope-2"><a href="#workerglobalscope">WorkerGlobalScope</a></code> <var>global</var> changes from false to true, the user agent must
  <a href="#queue-a-global-task" id="navigator.online:queue-a-global-task-2">queue a global task</a> on the <a href="#networking-task-source" id="navigator.online:networking-task-source-2">networking task source</a> given
  <var>global</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="navigator.online:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="navigator.online:event-online-2"><a href="#event-online">online</a></code> at the <code id="navigator.online:window-3"><a href="#window">Window</a></code> or <code id="navigator.online:workerglobalscope-3"><a href="#workerglobalscope">WorkerGlobalScope</a></code>
  object.</p>
  </div>

  

  <p class="note">This attribute is inherently unreliable. A computer can be connected to a network
  without having Internet access.</p>

  <div class="example">
   <p>In this example, an indicator is updated as the browser goes online and offline.</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Online status<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">function</c-> updateIndicator<c- p="">()</c-> <c- p="">{</c->
     document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'indicator'</c-><c- p="">).</c->textContent <c- o="">=</c-> navigator<c- p="">.</c->onLine <c- o="">?</c-> <c- t="">'online'</c-> <c- o="">:</c-> <c- t="">'offline'</c-><c- p="">;</c->
   <c- p="">}</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-> <c- e="">onload</c-><c- o="">=</c-><c- s="">"updateIndicator()"</c-> <c- e="">ononline</c-><c- o="">=</c-><c- s="">"updateIndicator()"</c-> <c- e="">onoffline</c-><c- o="">=</c-><c- s="">"updateIndicator()"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The network is: <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"indicator"</c-><c- p="">&gt;</c->(state unknown)<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h5 id="custom-handlers"><span class="secno">8.9.1.4</span> Custom scheme handlers: the <code id="custom-handlers:dom-navigator-registerprotocolhandler"><a href="#dom-navigator-registerprotocolhandler">registerProtocolHandler()</a></code> method<a href="#custom-handlers" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler" title="The Navigator method registerProtocolHandler() lets websites register their ability to open or handle particular URL schemes (aka protocols).">Navigator/registerProtocolHandler</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>13+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge no"><span>Edge (Legacy)</span><span>No</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="navigatorcontentutils" data-dfn-type="interface"><c- g="">NavigatorContentUtils</c-></dfn> {
  [<c- g="">SecureContext</c->] <c- b="">undefined</c-> <a href="#dom-navigator-registerprotocolhandler" id="custom-handlers:dom-navigator-registerprotocolhandler-2"><c- g="">registerProtocolHandler</c-></a>(<c- b="">DOMString</c-> <c- g="">scheme</c->, <c- b="">USVString</c-> <c- g="">url</c->);
  [<c- g="">SecureContext</c->] <c- b="">undefined</c-> <a href="#dom-navigator-unregisterprotocolhandler" id="custom-handlers:dom-navigator-unregisterprotocolhandler"><c- g="">unregisterProtocolHandler</c-></a>(<c- b="">DOMString</c-> <c- g="">scheme</c->, <c- b="">USVString</c-> <c- g="">url</c->);
};</code></pre>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-navigator" id="custom-handlers:dom-navigator">navigator</a>.<a href="#dom-navigator-registerprotocolhandler" id="dom-navigator-registerprotocolhandler-dev">registerProtocolHandler</a>(<var>scheme</var>, <var>url</var>)</code></dt><dd>
    <p>Registers a handler for <var>scheme</var> at <var>url</var>. For example, an online telephone
    messaging service could register itself as a handler of the <code id="custom-handlers:sms-protocol"><a data-x-internal="sms-protocol" href="https://www.rfc-editor.org/rfc/rfc5724#section-2">sms:</a></code> scheme, so that if the user clicks on such a link, they are given the
    opportunity to use that web site. <a href="#refsSMS">[SMS]</a></p>

    <p>The string "<code>%s</code>" in <var>url</var> is used as a placeholder for where
    to put the URL of the content to be handled.</p>

    <p>Throws a <a id="custom-handlers:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="custom-handlers:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the user
    agent blocks the registration (this might happen if trying to register as a handler for "<code>http</code>", for instance).</p>

    <p>Throws a <a id="custom-handlers:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="custom-handlers:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the "<code>%s</code>" string is missing in <var>url</var>.</p>
   </dd><dt><code><var>window</var>.<a href="#dom-navigator" id="custom-handlers:dom-navigator-2">navigator</a>.<a href="#dom-navigator-unregisterprotocolhandler" id="dom-navigator-unregisterprotocolhandler-dev">unregisterProtocolHandler</a>(<var>scheme</var>, <var>url</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/unregisterProtocolHandler" title="The Navigator method unregisterProtocolHandler() removes a protocol handler for a given URL scheme.">Navigator/unregisterProtocolHandler</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>38+</span></span><hr><span class="opera yes"><span>Opera</span><span>25+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Unregisters the handler given by the arguments.</p>

    <p>Throws a <a id="custom-handlers:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="custom-handlers:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the user
    agent blocks the deregistration (this might happen if with invalid schemes, for instance).</p>

    <p>Throws a <a id="custom-handlers:syntaxerror-2" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="custom-handlers:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the "<code>%s</code>" string is missing in <var>url</var>.</p>
   </dd></dl>


  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorContentUtils" id="dom-navigator-registerprotocolhandler" data-dfn-type="method"><code>registerProtocolHandler(<var>scheme</var>,
  <var>url</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let (<var>normalizedScheme</var>, <var>normalizedURLString</var>) be the result of running
   <a href="#normalize-protocol-handler-parameters" id="custom-handlers:normalize-protocol-handler-parameters">normalize protocol handler parameters</a> with <var>scheme</var>, <var>url</var>, and
   <a id="custom-handlers:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="custom-handlers:relevant-settings-object">relevant settings object</a>.</p></li><li>
    <p><a href="#in-parallel" id="custom-handlers:in-parallel">In parallel</a>: <dfn id="protocol-handler-registration" data-export="">register a
    protocol handler</dfn> for <var>normalizedScheme</var> and <var>normalizedURLString</var>. User
    agents may, within the constraints described, do whatever they like. A user agent could, for
    instance, prompt the user and offer the user the opportunity to add the site to a shortlist of
    handlers, or make the handlers their default, or cancel the request. User agents could also
    silently collect the information, providing it only when relevant to the user.</p>

    <p>User agents should keep track of which sites have registered handlers (even if the user has
    declined such registrations) so that the user is not repeatedly prompted with the same
    request.</p>

    <p>If the <a href="#registerprotocolhandler()-automation-mode" id="custom-handlers:registerprotocolhandler()-automation-mode"><code>registerProtocolHandler()</code> automation
    mode</a> of <a id="custom-handlers:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="custom-handlers:concept-relevant-global">relevant global object</a>'s <a href="#concept-document-window" id="custom-handlers:concept-document-window">associated <code>Document</code></a> is not "<dfn id="rph-automation-mode-none"><code>none</code></dfn>", the user agent should first verify that it
    is in an automation context (see <a id="custom-handlers:webdriver's-security-considerations" href="https://w3c.github.io/webdriver/#security" data-x-internal="webdriver's-security-considerations">WebDriver's security considerations</a>). The user
    agent should then bypass the above communication of information and gathering of user consent,
    and instead do the following based on the value of the <a href="#registerprotocolhandler()-automation-mode" id="custom-handlers:registerprotocolhandler()-automation-mode-2"><code>registerProtocolHandler()</code> automation
    mode</a>:</p>

    <dl><dt>"<dfn id="rph-automation-mode-auto-accept"><code>autoAccept</code></dfn>"</dt><dd><p>Act as if the user has seen the registration details and accepted the request.</p></dd><dt>"<dfn id="rph-automation-mode-auto-reject"><code>autoReject</code></dfn>"</dt><dd><p>Act as if the user has seen the registration details and rejected the request.</p></dd></dl>

    <p>When the <dfn id="protocol-handler-invocation" data-lt="invoke a protocol
    handler" data-export="">user agent uses this handler</dfn> for a <a id="custom-handlers:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>inputURL</var>:</p>

    <ol><li><p><a id="custom-handlers:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>inputURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="custom-handlers:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is <var>normalizedScheme</var>.</p></li><li><p><a href="https://url.spec.whatwg.org/#set-the-username" id="custom-handlers:set-the-username" data-x-internal="set-the-username">Set the username</a> given <var>inputURL</var> and
     the empty string.</p></li><li><p><a href="https://url.spec.whatwg.org/#set-the-password" id="custom-handlers:set-the-password" data-x-internal="set-the-password">Set the password</a> given <var>inputURL</var> and
     the empty string.</p></li><li><p>Let <var>inputURLString</var> be the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="custom-handlers:concept-url-serializer" data-x-internal="concept-url-serializer">serialization</a> of <var>inputURL</var>.</p></li><li><p>Let <var>encodedURL</var> be the result of running <a id="custom-handlers:utf-8-percent-encode" href="https://url.spec.whatwg.org/#string-utf-8-percent-encode" data-x-internal="utf-8-percent-encode">UTF-8 percent-encode</a> on
     <var>inputURLString</var> using the <a id="custom-handlers:component-percent-encode-set" href="https://url.spec.whatwg.org/#component-percent-encode-set" data-x-internal="component-percent-encode-set">component percent-encode set</a>.</p></li><li><p>Let <var>handlerURLString</var> be <var>normalizedURLString</var>.</p></li><li><p>Replace the first instance of "<code>%s</code>" in <var>handlerURLString</var>
     with <var>encodedURL</var>.</p></li><li><p>Let <var>resultURL</var> be the result of <a href="https://url.spec.whatwg.org/#concept-url-parser" id="custom-handlers:url-parser" data-x-internal="url-parser">parsing</a>
     <var>handlerURLString</var>.</p></li><li><p><a href="#navigate" id="custom-handlers:navigate">Navigate</a> an appropriate <a href="#navigable" id="custom-handlers:navigable">navigable</a> to
     <var>resultURL</var>.</p></li></ol>

    <div class="example">
     <p>If the user had visited a site at <code>https://example.com/</code> that made the
     following call:</p>

     <pre><code class="js">navigator<c- p="">.</c->registerProtocolHandler<c- p="">(</c-><c- t="">'web+soup'</c-><c- p="">,</c-> <c- t="">'soup?url=%s'</c-><c- p="">)</c-></code></pre>

     <p>...and then, much later, while visiting <code>https://www.example.net/</code>,
     clicked on a link such as:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-> <c- e="">href</c-><c- o="">=</c-><c- s="">"web+soup:chicken-kïwi"</c-><c- p="">&gt;</c->Download our Chicken Kïwi soup!<c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>

     <p>...then the UA might navigate to the following URL:</p>

     <pre>https://example.com/soup?url=web+soup:chicken-k%C3%AFwi</pre>

     <p>This site could then do whatever it is that it does with soup (synthesize it and ship it to
     the user, or whatever).</p>
    </div>

    <p>This does not define when the handler is used. To some extent, the <a href="#navigate" id="custom-handlers:navigate-2">processing model for navigating across documents</a> defines some cases
    where it is relevant, but in general user agents may use this information wherever they would
    otherwise consider handing schemes to native plugins or helper applications.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="NavigatorContentUtils" id="dom-navigator-unregisterprotocolhandler" data-dfn-type="method"><code>unregisterProtocolHandler(<var>scheme</var>,
  <var>url</var>)</code></dfn> method steps are:

  </p><ol><li><p>Let (<var>normalizedScheme</var>, <var>normalizedURLString</var>) be the result of running
   <a href="#normalize-protocol-handler-parameters" id="custom-handlers:normalize-protocol-handler-parameters-2">normalize protocol handler parameters</a> with <var>scheme</var>, <var>url</var>, and
   <a id="custom-handlers:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="custom-handlers:relevant-settings-object-2">relevant settings object</a>.</p></li><li><p><a href="#in-parallel" id="custom-handlers:in-parallel-2">In parallel</a>: unregister the handler described by <var>normalizedScheme</var>
   and <var>normalizedURLString</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="normalize-protocol-handler-parameters" data-export="">normalize protocol handler parameters</dfn>, given a string <var>scheme</var>, a
  string <var>url</var>, and an <a href="#environment-settings-object" id="custom-handlers:environment-settings-object">environment settings object</a> <var>environment</var>, run
  these steps:</p>

  <ol><li><p>Set <var>scheme</var> to <var>scheme</var>, <a id="custom-handlers:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII
   lowercase</a>.</p></li><li>
    <p>If <var>scheme</var> is neither a <a href="#safelisted-scheme" id="custom-handlers:safelisted-scheme">safelisted scheme</a> nor a string starting with
    "<code>web+</code>" followed by one or more <a href="https://infra.spec.whatwg.org/#ascii-lower-alpha" id="custom-handlers:lowercase-ascii-letters" data-x-internal="lowercase-ascii-letters">ASCII
    lower alphas</a>, then throw a <a id="custom-handlers:securityerror-3" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
    <code id="custom-handlers:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p class="note">This means that including a colon in <var>scheme</var> (as in "<code>mailto:</code>") will throw.</p>

    <p>The following schemes are the <dfn id="safelisted-scheme" data-export="">safelisted
    schemes</dfn>:</p>

    <ul class="brief"><li><code>bitcoin</code></li><li><code>ftp</code></li><li><code>ftps</code></li><li><code>geo</code></li><li><code>im</code></li><li><code>irc</code></li><li><code>ircs</code></li><li><code>magnet</code></li><li><code>mailto</code></li><li><code>matrix</code></li><li><code>mms</code></li><li><code>news</code></li><li><code>nntp</code></li><li><code>openpgp4fpr</code></li><li><code>sftp</code></li><li><code>sip</code></li><li><code>sms</code></li><li><code>smsto</code></li><li><code>ssh</code></li><li><code>tel</code></li><li><code>urn</code></li><li><code>webcal</code></li><li><code>wtai</code></li><li><code>xmpp</code></li></ul>

    <p class="note">This list can be changed. If there are schemes that ought to be added, please
    send feedback.</p>
   </li><li><p>If <var>url</var> does not contain "<code>%s</code>", then throw a
   <a id="custom-handlers:syntaxerror-3" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="custom-handlers:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>urlRecord</var> be the result of <a href="#encoding-parsing-a-url" id="custom-handlers:encoding-parsing-a-url">encoding-parsing a URL</a> given
   <var>url</var>, relative to <var>environment</var>.</p></li><li>
    <p>If <var>urlRecord</var> is failure, then throw a <a id="custom-handlers:syntaxerror-4" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
    <code id="custom-handlers:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p class="note">This is forcibly the case if the <code>%s</code> placeholder is in the
    host or port of the URL.</p>
   </li><li><p>If <var>urlRecord</var>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="custom-handlers:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a> is not an
   <a id="custom-handlers:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a> or <var>urlRecord</var>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="custom-handlers:concept-url-origin" data-x-internal="concept-url-origin">origin</a> is not <a href="#same-origin" id="custom-handlers:same-origin">same origin</a> with
   <var>environment</var>'s <a href="#concept-settings-object-origin" id="custom-handlers:concept-settings-object-origin">origin</a>, then throw
   a <a id="custom-handlers:securityerror-4" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="custom-handlers:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p><a id="custom-handlers:assert-2" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: the result of <a id="custom-handlers:is-url-potentially-trustworthy" href="https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url" data-x-internal="is-url-potentially-trustworthy">Is url potentially trustworthy?</a> given
    <var>urlRecord</var> is "<code>Potentially Trustworthy</code>".</p>

    <p class="note">Because <a href="#normalize-protocol-handler-parameters" id="custom-handlers:normalize-protocol-handler-parameters-3">normalize protocol handler parameters</a> is run within a
    <a href="#secure-context" id="custom-handlers:secure-context">secure context</a>, this is implied by the <a href="#same-origin" id="custom-handlers:same-origin-2">same origin</a> condition.</p>
   </li><li>
    <p>Return (<var>scheme</var>, <var>urlRecord</var>).</p>

    <p class="note">The <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="custom-handlers:concept-url-serializer-2" data-x-internal="concept-url-serializer">serialization</a> of
    <var>urlRecord</var> will by definition not be a <a id="custom-handlers:valid-url-string" href="https://url.spec.whatwg.org/#valid-url-string" data-x-internal="valid-url-string">valid URL string</a> as it includes
    the string "<code>%s</code>" which is not a valid component in a URL.</p>
   </li></ol>
  </div>



  <h6 id="security-and-privacy"><span class="secno">8.9.1.4.1</span> Security and privacy<a href="#security-and-privacy" class="self-link"></a></h6>

  <p>Custom scheme handlers can introduce a number of concerns, in particular privacy concerns.</p>

  <p><strong>Hijacking all web usage.</strong> User agents should not allow schemes that are key to
  its normal operation, such as an <a id="security-and-privacy:http(s)-scheme" href="https://fetch.spec.whatwg.org/#http-scheme" data-x-internal="http(s)-scheme">HTTP(S) scheme</a>, to be rerouted through third-party
  sites. This would allow a user's activities to be trivially tracked, and would allow user
  information, even in secure connections, to be collected.</p>

  <p><strong>Hijacking defaults.</strong> User agents are strongly urged to not automatically change
  any defaults, as this could lead the user to send data to remote hosts that the user is not
  expecting. New handlers registering themselves should never automatically cause those sites to be
  used.</p>

  <p><strong>Registration spamming.</strong> User agents should consider the possibility that a site
  will attempt to register a large number of handlers, possibly from multiple domains (e.g., by
  redirecting through a series of pages each on a different domain, and each registering a handler
  for <code>web+spam:</code> — analogous practices abusing other web browser
  features have been used by pornography web sites for many years). User agents should gracefully
  handle such hostile attempts, protecting the user.</p>

  <p><strong>Hostile handler metadata.</strong> User agents should protect against typical attacks
  against strings embedded in their interface, for example ensuring that markup or escape characters
  in such strings are not executed, that null bytes are properly handled, that over-long strings do
  not cause crashes or buffer overruns, and so forth.</p>

  <p><strong>Leaking private data.</strong> Web page authors may reference a custom scheme
  handler using URL data considered private. They might do so with the expectation that the user's
  choice of handler points to a page inside the organization, ensuring that sensitive data will not
  be exposed to third parties. However, a user may have registered a handler pointing to an
  external site, resulting in a data leak to that third party. Implementers might wish to consider
  allowing administrators to disable custom handlers on certain subdomains, content types, or
  schemes.</p>

  <p><strong>Interface interference.</strong> User agents should be prepared to handle intentionally
  long arguments to the methods. For example, if the user interface exposed consists of an "accept"
  button and a "deny" button, with the "accept" binding containing the name of the handler, it's
  important that a long name not cause the "deny" button to be pushed off the screen.</p>

  <h6 id="user-agent-automation"><span class="secno">8.9.1.4.2</span> <dfn id="rph-user-agent-automation">User agent automation</dfn><a href="#user-agent-automation" class="self-link"></a></h6>

  <p>Each <code id="user-agent-automation:document"><a href="#document">Document</a></code> has a <dfn id="registerprotocolhandler()-automation-mode"><code>registerProtocolHandler()</code> automation
  mode</dfn>. It defaults to "<code id="user-agent-automation:rph-automation-mode-none"><a href="#rph-automation-mode-none">none</a></code>", but it also can
  be either "<code id="user-agent-automation:rph-automation-mode-auto-accept"><a href="#rph-automation-mode-auto-accept">autoAccept</a></code>" or "<code id="user-agent-automation:rph-automation-mode-auto-reject"><a href="#rph-automation-mode-auto-reject">autoReject</a></code>".</p>

  <p>For the purposes of user agent automation and website testing, this standard defines <dfn id="set-rph-registration-mode">Set RPH Registration Mode</dfn> WebDriver <a id="user-agent-automation:extension-command" href="https://w3c.github.io/webdriver/#dfn-extension-commands" data-x-internal="extension-command">extension
  command</a>. It instructs the user agent to place a <code id="user-agent-automation:document-2"><a href="#document">Document</a></code> into a mode where it
  will automatically simulate a user either accepting or rejecting and registration confirmation
  prompt dialog.</p>

  <table class="data"><thead><tr><th>HTTP Method
     </th><th>URI Template
   </th></tr></thead><tbody><tr><td>`<code>POST</code>`
     </td><td><code>/session/{session id}/custom-handlers/set-mode</code>
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The <a id="user-agent-automation:remote-end-steps" href="https://w3c.github.io/webdriver/#dfn-remote-end-steps" data-x-internal="remote-end-steps">remote end steps</a> are:</p>

  <ol><li><p>If <var>parameters</var> is not a JSON Object, return a <a id="user-agent-automation:webdriver-error" href="https://w3c.github.io/webdriver/#dfn-errors" data-x-internal="webdriver-error">WebDriver error</a> with
   <a id="user-agent-automation:webdriver-error-code" href="https://w3c.github.io/webdriver/#dfn-error-code" data-x-internal="webdriver-error-code">WebDriver error code</a> <a id="user-agent-automation:invalid-argument" href="https://w3c.github.io/webdriver/#dfn-invalid-argument" data-x-internal="invalid-argument">invalid argument</a>.</p></li><li><p>Let <var>mode</var> be the result of <a id="user-agent-automation:getting-a-property" href="https://w3c.github.io/webdriver/#dfn-getting-properties" data-x-internal="getting-a-property">getting a property</a> named "<code>mode</code>" from <var>parameters</var>.</p></li><li><p>If <var>mode</var> is not "<code id="user-agent-automation:rph-automation-mode-auto-accept-2"><a href="#rph-automation-mode-auto-accept">autoAccept</a></code>", "<code id="user-agent-automation:rph-automation-mode-auto-reject-2"><a href="#rph-automation-mode-auto-reject">autoReject</a></code>", or "<code id="user-agent-automation:rph-automation-mode-none-2"><a href="#rph-automation-mode-none">none</a></code>", return a <a id="user-agent-automation:webdriver-error-2" href="https://w3c.github.io/webdriver/#dfn-errors" data-x-internal="webdriver-error">WebDriver error</a> with
   <a id="user-agent-automation:webdriver-error-code-2" href="https://w3c.github.io/webdriver/#dfn-error-code" data-x-internal="webdriver-error-code">WebDriver error code</a> <a id="user-agent-automation:invalid-argument-2" href="https://w3c.github.io/webdriver/#dfn-invalid-argument" data-x-internal="invalid-argument">invalid argument</a>.</p></li><li><p>Let <var>document</var> be the <a href="https://w3c.github.io/webdriver/#dfn-current-browsing-context" id="user-agent-automation:webdriver-current-browsing-context" data-x-internal="webdriver-current-browsing-context">current
   browsing context</a>'s <a href="#active-document" id="user-agent-automation:active-document">active document</a>.</p></li><li><p>Set <var>document</var>'s <a href="#registerprotocolhandler()-automation-mode" id="user-agent-automation:registerprotocolhandler()-automation-mode"><code>registerProtocolHandler()</code> automation
   mode</a> to <var>mode</var>.</p></li><li><p>Return <a href="https://w3c.github.io/webdriver/#dfn-success" id="user-agent-automation:success-value" data-x-internal="success-value">success</a> with data null.</p></li></ol>
  </div>

  

  <h5 id="cookies"><span class="secno">8.9.1.5</span> Cookies<a href="#cookies" class="self-link"></a></h5>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="navigatorcookies" data-dfn-type="interface"><c- g="">NavigatorCookies</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigator-cookieenabled" id="cookies:dom-navigator-cookieenabled"><c- g="">cookieEnabled</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-navigator" id="cookies:dom-navigator">navigator</a>.<a href="#dom-navigator-cookieenabled" id="dom-navigator-cookieenabled-dev">cookieEnabled</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/cookieEnabled" title="navigator.cookieEnabled returns a Boolean value that indicates whether cookies are enabled or not.">Navigator/cookieEnabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns false if setting a cookie will be ignored, and true otherwise.</p></dd></dl>

  

   <div data-algorithm="">
   <p>The <dfn data-dfn-for="NavigatorCookies" id="dom-navigator-cookieenabled" data-dfn-type="attribute"><code>cookieEnabled</code></dfn> attribute must return true if the
   user agent attempts to handle cookies according to <cite>HTTP State Management Mechanism</cite>,
   and false if it ignores cookie change requests. <a href="#refsCOOKIES">[COOKIES]</a></p>
   </div>

  

  <h5 id="pdf-viewing-support"><span class="secno">8.9.1.6</span> PDF viewing support<a href="#pdf-viewing-support" class="self-link"></a></h5>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-navigator" id="pdf-viewing-support:dom-navigator">navigator</a>.<a href="#dom-navigator-pdfviewerenabled" id="dom-navigator-pdfviewerenabled-dev">pdfViewerEnabled</a></code></dt><dd><p>Returns true if the user agent supports inline viewing of PDF files when <a href="#navigate" id="pdf-viewing-support:navigate">navigating</a> to them, or false otherwise. In the latter case, PDF files
   will be handled by <a href="#hand-off-to-external-software" id="pdf-viewing-support:hand-off-to-external-software">external
   software</a>.</p></dd></dl>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="navigatorplugins" data-dfn-type="interface"><c- g="">NavigatorPlugins</c-></dfn> {
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#pluginarray" id="pdf-viewing-support:pluginarray"><c- n="">PluginArray</c-></a> <a href="#dom-navigator-plugins" id="pdf-viewing-support:dom-navigator-plugins"><c- g="">plugins</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#mimetypearray" id="pdf-viewing-support:mimetypearray"><c- n="">MimeTypeArray</c-></a> <a href="#dom-navigator-mimetypes" id="pdf-viewing-support:dom-navigator-mimetypes"><c- g="">mimeTypes</c-></a>;
  <c- b="">boolean</c-> <a href="#dom-navigator-javaenabled" id="pdf-viewing-support:dom-navigator-javaenabled"><c- g="">javaEnabled</c-></a>();
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-navigator-pdfviewerenabled" id="pdf-viewing-support:dom-navigator-pdfviewerenabled"><c- g="">pdfViewerEnabled</c-></a>;
};

[<c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="pdf-viewing-support:legacyunenumerablenamedproperties" href="https://webidl.spec.whatwg.org/#LegacyUnenumerableNamedProperties" data-x-internal="legacyunenumerablenamedproperties"><c- g="">LegacyUnenumerableNamedProperties</c-></a>]
<c- b="">interface</c-> <dfn id="pluginarray" data-dfn-type="interface"><c- g="">PluginArray</c-></dfn> {
  <c- b="">undefined</c-> <a href="#dom-pluginarray-refresh" id="pdf-viewing-support:dom-pluginarray-refresh"><c- g="">refresh</c-></a>();
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-pluginarray-length" id="pdf-viewing-support:dom-pluginarray-length"><c- g="">length</c-></a>;
  <c- b="">getter</c-> <a href="#plugin" id="pdf-viewing-support:plugin"><c- n="">Plugin</c-></a>? <a href="#dom-pluginarray-item" id="pdf-viewing-support:dom-pluginarray-item"><c- g="">item</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <c- b="">getter</c-> <a href="#plugin" id="pdf-viewing-support:plugin-2"><c- n="">Plugin</c-></a>? <a href="#dom-pluginarray-nameditem" id="pdf-viewing-support:dom-pluginarray-nameditem"><c- g="">namedItem</c-></a>(<c- b="">DOMString</c-> <c- g="">name</c->);
};

[<c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="pdf-viewing-support:legacyunenumerablenamedproperties-2" href="https://webidl.spec.whatwg.org/#LegacyUnenumerableNamedProperties" data-x-internal="legacyunenumerablenamedproperties"><c- g="">LegacyUnenumerableNamedProperties</c-></a>]
<c- b="">interface</c-> <dfn id="mimetypearray" data-dfn-type="interface"><c- g="">MimeTypeArray</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-mimetypearray-length" id="pdf-viewing-support:dom-mimetypearray-length"><c- g="">length</c-></a>;
  <c- b="">getter</c-> <a href="#mimetype" id="pdf-viewing-support:mimetype"><c- n="">MimeType</c-></a>? <a href="#dom-mimetypearray-item" id="pdf-viewing-support:dom-mimetypearray-item"><c- g="">item</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <c- b="">getter</c-> <a href="#mimetype" id="pdf-viewing-support:mimetype-2"><c- n="">MimeType</c-></a>? <a href="#dom-mimetypearray-nameditem" id="pdf-viewing-support:dom-mimetypearray-nameditem"><c- g="">namedItem</c-></a>(<c- b="">DOMString</c-> <c- g="">name</c->);
};

[<c- g="">Exposed</c->=<c- n="">Window</c->,
 <a id="pdf-viewing-support:legacyunenumerablenamedproperties-3" href="https://webidl.spec.whatwg.org/#LegacyUnenumerableNamedProperties" data-x-internal="legacyunenumerablenamedproperties"><c- g="">LegacyUnenumerableNamedProperties</c-></a>]
<c- b="">interface</c-> <dfn id="dom-plugin" data-dfn-type="interface"><c- g="">Plugin</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-plugin-name" id="pdf-viewing-support:dom-plugin-name"><c- g="">name</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-plugin-description" id="pdf-viewing-support:dom-plugin-description"><c- g="">description</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-plugin-filename" id="pdf-viewing-support:dom-plugin-filename"><c- g="">filename</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-plugin-length" id="pdf-viewing-support:dom-plugin-length"><c- g="">length</c-></a>;
  <c- b="">getter</c-> <a href="#mimetype" id="pdf-viewing-support:mimetype-3"><c- n="">MimeType</c-></a>? <a href="#dom-plugin-item" id="pdf-viewing-support:dom-plugin-item"><c- g="">item</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <c- b="">getter</c-> <a href="#mimetype" id="pdf-viewing-support:mimetype-4"><c- n="">MimeType</c-></a>? <a href="#dom-plugin-nameditem" id="pdf-viewing-support:dom-plugin-nameditem"><c- g="">namedItem</c-></a>(<c- b="">DOMString</c-> <c- g="">name</c->);
};

[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="mimetype" data-dfn-type="interface"><c- g="">MimeType</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-mimetype-type" id="pdf-viewing-support:dom-mimetype-type"><c- g="">type</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-mimetype-description" id="pdf-viewing-support:dom-mimetype-description"><c- g="">description</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-mimetype-suffixes" id="pdf-viewing-support:dom-mimetype-suffixes"><c- g="">suffixes</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#plugin" id="pdf-viewing-support:plugin-3"><c- n="">Plugin</c-></a> <a href="#dom-mimetype-enabledplugin" id="pdf-viewing-support:dom-mimetype-enabledplugin"><c- g="">enabledPlugin</c-></a>;
};</code></pre>

  

  <p>Although these days detecting PDF viewer support can be done via <code id="pdf-viewing-support:dom-navigator-pdfviewerenabled-2"><a href="#dom-navigator-pdfviewerenabled">navigator.pdfViewerEnabled</a></code>, for historical reasons,
  there are a number of complex and intertwined interfaces that provide the same capability, which
  legacy code relies on. This section specifies both the simple modern variant and the complicated
  historical one.</p>

  <p id="fingerprint-pdfViewerEnabled">
  <a id="pdf-viewing-support:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  Each user agent has a <dfn id="pdf-viewer-supported">PDF viewer supported</dfn> boolean, whose value is
  <a id="pdf-viewing-support:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> (and might vary according to user preferences).</p>

  <p class="note">This value also impacts the <a href="#navigate" id="pdf-viewing-support:navigate-2">navigation</a> processing
  model.</p>

  <hr>

  <p>Each <code id="pdf-viewing-support:window"><a href="#window">Window</a></code> object has a <dfn id="pdf-viewer-plugin-objects">PDF viewer plugin objects</dfn> list. If the user
  agent's <a href="#pdf-viewer-supported" id="pdf-viewing-support:pdf-viewer-supported">PDF viewer supported</a> is false, then it is the empty list. Otherwise, it is a
  list containing five <code id="pdf-viewing-support:dom-plugin"><a href="#dom-plugin">Plugin</a></code> objects, whose <a href="#concept-plugin-name" id="pdf-viewing-support:concept-plugin-name">names</a> are, respectively:</p>

  <ol start="0" class="brief"><li>"<code>PDF Viewer</code>"</li><li>"<code>Chrome PDF Viewer</code>"</li><li>"<code>Chromium PDF Viewer</code>"</li><li>"<code>Microsoft Edge PDF Viewer</code>"</li><li>"<code>WebKit built-in PDF</code>"</li></ol>

  <p>The values of the above list form the <dfn id="pdf-viewer-plugin-names">PDF viewer plugin names</dfn> list.</p>

  <p class="note">These names were chosen based on evidence of what websites historically search
  for, and thus what is necessary for user agents to expose in order to maintain compatibility with
  existing content. They are ordered alphabetically. The "<code>PDF Viewer</code>" name
  was then inserted in the 0th position so that the <code id="pdf-viewing-support:dom-mimetype-enabledplugin-2"><a href="#dom-mimetype-enabledplugin">enabledPlugin</a></code> getter could point to a generic plugin
  name.</p>

  <p>Each <code id="pdf-viewing-support:window-2"><a href="#window">Window</a></code> object has a <dfn id="pdf-viewer-mime-type-objects">PDF viewer mime type objects</dfn> list. If the user
  agent's <a href="#pdf-viewer-supported" id="pdf-viewing-support:pdf-viewer-supported-2">PDF viewer supported</a> is false, then it is the empty list. Otherwise, it is a
  list containing two <code id="pdf-viewing-support:mimetype-5"><a href="#mimetype">MimeType</a></code> objects, whose <a href="#concept-mimetype-type" id="pdf-viewing-support:concept-mimetype-type">types</a> are, respectively:</p>

  <ol start="0" class="brief"><li>"<code>application/pdf</code>"</li><li>"<code>text/pdf</code>"</li></ol>

  <p>The values of the above list form the <dfn id="pdf-viewer-mime-types">PDF viewer mime types</dfn> list.</p>

  <hr>

  <p>Each <code id="pdf-viewing-support:navigatorplugins"><a href="#navigatorplugins">NavigatorPlugins</a></code> object has a <dfn id="plugins-array">plugins array</dfn>, which is a new
  <code id="pdf-viewing-support:pluginarray-2"><a href="#pluginarray">PluginArray</a></code>, and a <dfn id="mime-types-array">mime types array</dfn>, which is a new
  <code id="pdf-viewing-support:mimetypearray-2"><a href="#mimetypearray">MimeTypeArray</a></code>.</p>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:navigatorplugins-2"><a href="#navigatorplugins">NavigatorPlugins</a></code> mixin's <dfn data-dfn-for="NavigatorPlugins" id="dom-navigator-plugins" data-dfn-type="attribute"><code>plugins</code></dfn> getter steps are to return <a id="pdf-viewing-support:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#plugins-array" id="pdf-viewing-support:plugins-array">plugins array</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:navigatorplugins-3"><a href="#navigatorplugins">NavigatorPlugins</a></code> mixin's <dfn data-dfn-for="NavigatorPlugins" id="dom-navigator-mimetypes" data-dfn-type="attribute"><code>mimeTypes</code></dfn> getter steps are to return
  <a id="pdf-viewing-support:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#mime-types-array" id="pdf-viewing-support:mime-types-array">mime types array</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:navigatorplugins-4"><a href="#navigatorplugins">NavigatorPlugins</a></code> mixin's <dfn data-dfn-for="NavigatorPlugins" id="dom-navigator-javaenabled" data-dfn-type="method"><code>javaEnabled()</code></dfn> method steps are to return false.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/pdfViewerEnabled" title="The pdfViewerEnabled property of the Navigator interface indicates whether the browser supports inline display of PDF files when navigating to them.">Navigator/pdfViewerEnabled</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>99+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>94+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>94+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <code id="pdf-viewing-support:navigatorplugins-5"><a href="#navigatorplugins">NavigatorPlugins</a></code> mixin's <dfn data-dfn-for="NavigatorPlugins" id="dom-navigator-pdfviewerenabled" data-dfn-type="attribute"><code>pdfViewerEnabled</code></dfn> getter steps are to return
  the user agent's <a href="#pdf-viewer-supported" id="pdf-viewing-support:pdf-viewer-supported-3">PDF viewer supported</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:pluginarray-3"><a href="#pluginarray">PluginArray</a></code> interface <a href="https://webidl.spec.whatwg.org/#dfn-support-named-properties" id="pdf-viewing-support:support-named-properties" data-x-internal="support-named-properties">supports named
  properties</a>. If the user agent's <a href="#pdf-viewer-supported" id="pdf-viewing-support:pdf-viewer-supported-4">PDF viewer supported</a> is true, then they are
  the <a href="#pdf-viewer-plugin-names" id="pdf-viewing-support:pdf-viewer-plugin-names">PDF viewer plugin names</a>. Otherwise, they are the empty list.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:pluginarray-4"><a href="#pluginarray">PluginArray</a></code> interface's <dfn data-dfn-for="PluginArray" id="dom-pluginarray-nameditem" data-dfn-type="method"><code>namedItem(<var>name</var>)</code></dfn> method steps are:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="pdf-viewing-support:list-iterate" data-x-internal="list-iterate">For each</a> <code id="pdf-viewing-support:dom-plugin-2"><a href="#dom-plugin">Plugin</a></code>
   <var>plugin</var> of <a id="pdf-viewing-support:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global">relevant global object</a>'s <a href="#pdf-viewer-plugin-objects" id="pdf-viewing-support:pdf-viewer-plugin-objects">PDF viewer
   plugin objects</a>: if <var>plugin</var>'s <a href="#concept-plugin-name" id="pdf-viewing-support:concept-plugin-name-2">name</a> is
   <var>name</var>, then return <var>plugin</var>.</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:pluginarray-5"><a href="#pluginarray">PluginArray</a></code> interface <a id="pdf-viewing-support:supports-indexed-properties" href="https://webidl.spec.whatwg.org/#dfn-support-indexed-properties" data-x-internal="supports-indexed-properties">supports indexed properties</a>. The
  <a id="pdf-viewing-support:supported-property-indices" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> are the <a id="pdf-viewing-support:indices" href="https://infra.spec.whatwg.org/#list-get-the-indices" data-x-internal="indices">indices</a> of <a id="pdf-viewing-support:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-2">relevant global object</a>'s <a href="#pdf-viewer-plugin-objects" id="pdf-viewing-support:pdf-viewer-plugin-objects-2">PDF viewer plugin objects</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:pluginarray-6"><a href="#pluginarray">PluginArray</a></code> interface's <dfn data-dfn-for="PluginArray" id="dom-pluginarray-item" data-dfn-type="method"><code>item(<var>index</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>plugins</var> be <a id="pdf-viewing-support:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-3">relevant global object</a>'s
   <a href="#pdf-viewer-plugin-objects" id="pdf-viewing-support:pdf-viewer-plugin-objects-3">PDF viewer plugin objects</a>.</p></li><li><p>If <var>index</var> &lt; <var>plugins</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="pdf-viewing-support:list-size" data-x-internal="list-size">size</a>, then
   return <var>plugins</var>[<var>index</var>].</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:pluginarray-7"><a href="#pluginarray">PluginArray</a></code> interface's <dfn data-dfn-for="PluginArray" id="dom-pluginarray-length" data-dfn-type="attribute"><code>length</code></dfn> getter steps are to return <a id="pdf-viewing-support:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-4">relevant global object</a>'s <a href="#pdf-viewer-plugin-objects" id="pdf-viewing-support:pdf-viewer-plugin-objects-4">PDF viewer plugin objects</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="pdf-viewing-support:list-size-2" data-x-internal="list-size">size</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:pluginarray-8"><a href="#pluginarray">PluginArray</a></code> interface's <dfn data-dfn-for="PluginArray" id="dom-pluginarray-refresh" data-dfn-type="method"><code>refresh()</code></dfn> method steps are to do nothing.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:mimetypearray-3"><a href="#mimetypearray">MimeTypeArray</a></code> interface <a href="https://webidl.spec.whatwg.org/#dfn-support-named-properties" id="pdf-viewing-support:support-named-properties-2" data-x-internal="support-named-properties">supports named
  properties</a>. If the user agent's <a href="#pdf-viewer-supported" id="pdf-viewing-support:pdf-viewer-supported-5">PDF viewer supported</a> is true, then they are
  the <a href="#pdf-viewer-mime-types" id="pdf-viewing-support:pdf-viewer-mime-types">PDF viewer mime types</a>. Otherwise, they are the empty list.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:mimetypearray-4"><a href="#mimetypearray">MimeTypeArray</a></code> interface's <dfn data-dfn-for="MimeTypeArray" id="dom-mimetypearray-nameditem" data-dfn-type="method"><code>namedItem(<var>name</var>)</code></dfn> method steps are:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="pdf-viewing-support:list-iterate-2" data-x-internal="list-iterate">For each</a> <code id="pdf-viewing-support:mimetype-6"><a href="#mimetype">MimeType</a></code> <var>mimeType</var> of
   <a id="pdf-viewing-support:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-5">relevant global object</a>'s <a href="#pdf-viewer-mime-type-objects" id="pdf-viewing-support:pdf-viewer-mime-type-objects">PDF viewer mime type
   objects</a>: if <var>mimeType</var>'s <a href="#concept-mimetype-type" id="pdf-viewing-support:concept-mimetype-type-2">type</a> is
   <var>name</var>, then return <var>mimeType</var>.</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:mimetypearray-5"><a href="#mimetypearray">MimeTypeArray</a></code> interface <a id="pdf-viewing-support:supports-indexed-properties-2" href="https://webidl.spec.whatwg.org/#dfn-support-indexed-properties" data-x-internal="supports-indexed-properties">supports indexed properties</a>. The
  <a id="pdf-viewing-support:supported-property-indices-2" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> are the <a id="pdf-viewing-support:indices-2" href="https://infra.spec.whatwg.org/#list-get-the-indices" data-x-internal="indices">indices</a> of <a id="pdf-viewing-support:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-6">relevant global object</a>'s <a href="#pdf-viewer-mime-type-objects" id="pdf-viewing-support:pdf-viewer-mime-type-objects-2">PDF viewer mime type objects</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:mimetypearray-6"><a href="#mimetypearray">MimeTypeArray</a></code> interface's <dfn data-dfn-for="MimeTypeArray" id="dom-mimetypearray-item" data-dfn-type="method"><code>item(<var>index</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>mimeTypes</var> be <a id="pdf-viewing-support:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-7">relevant global object</a>'s
   <a href="#pdf-viewer-mime-type-objects" id="pdf-viewing-support:pdf-viewer-mime-type-objects-3">PDF viewer mime type objects</a>.</p></li><li><p>If <var>index</var> &lt; <var>mimeTypes</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="pdf-viewing-support:list-size-3" data-x-internal="list-size">size</a>, then
   return <var>mimeTypes</var>[<var>index</var>].</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:mimetypearray-7"><a href="#mimetypearray">MimeTypeArray</a></code> interface's <dfn data-dfn-for="MimeTypeArray" id="dom-mimetypearray-length" data-dfn-type="attribute"><code>length</code></dfn> getter steps are to return
  <a id="pdf-viewing-support:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-8">relevant global object</a>'s <a href="#pdf-viewer-mime-type-objects" id="pdf-viewing-support:pdf-viewer-mime-type-objects-4">PDF viewer mime type
  objects</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="pdf-viewing-support:list-size-4" data-x-internal="list-size">size</a>.</p>
  </div>

  <hr>

  <p>Each <code id="pdf-viewing-support:dom-plugin-3"><a href="#dom-plugin">Plugin</a></code> object has a <dfn id="concept-plugin-name">name</dfn>, which is set when the object is created.</p>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:dom-plugin-4"><a href="#dom-plugin">Plugin</a></code> interface's <dfn data-dfn-for="Plugin" id="dom-plugin-name" data-dfn-type="attribute"><code>name</code></dfn> getter steps are to return <a id="pdf-viewing-support:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-plugin-name" id="pdf-viewing-support:concept-plugin-name-3">name</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:dom-plugin-5"><a href="#dom-plugin">Plugin</a></code> interface's <dfn data-dfn-for="Plugin" id="dom-plugin-description" data-dfn-type="attribute"><code>description</code></dfn> getter steps are to return "<code>Portable Document Format</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:dom-plugin-6"><a href="#dom-plugin">Plugin</a></code> interface's <dfn data-dfn-for="Plugin" id="dom-plugin-filename" data-dfn-type="attribute"><code>filename</code></dfn> getter steps are to return "<code>internal-pdf-viewer</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:dom-plugin-7"><a href="#dom-plugin">Plugin</a></code> interface <a href="https://webidl.spec.whatwg.org/#dfn-support-named-properties" id="pdf-viewing-support:support-named-properties-3" data-x-internal="support-named-properties">supports named properties</a>. If the user agent's <a href="#pdf-viewer-supported" id="pdf-viewing-support:pdf-viewer-supported-6">PDF viewer
  supported</a> is true, then they are the <a href="#pdf-viewer-mime-types" id="pdf-viewing-support:pdf-viewer-mime-types-2">PDF viewer mime types</a>. Otherwise, they
  are the empty list.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:dom-plugin-8"><a href="#dom-plugin">Plugin</a></code> interface's <dfn data-dfn-for="Plugin" id="dom-plugin-nameditem" data-dfn-type="method"><code>namedItem(<var>name</var>)</code></dfn> method steps are:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#list-iterate" id="pdf-viewing-support:list-iterate-3" data-x-internal="list-iterate">For each</a> <code id="pdf-viewing-support:mimetype-7"><a href="#mimetype">MimeType</a></code> <var>mimeType</var> of
   <a id="pdf-viewing-support:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-9">relevant global object</a>'s <a href="#pdf-viewer-mime-type-objects" id="pdf-viewing-support:pdf-viewer-mime-type-objects-5">PDF viewer mime type
   objects</a>: if <var>mimeType</var>'s <a href="#concept-mimetype-type" id="pdf-viewing-support:concept-mimetype-type-3">type</a> is
   <var>name</var>, then return <var>mimeType</var>.</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:dom-plugin-9"><a href="#dom-plugin">Plugin</a></code> interface <a id="pdf-viewing-support:supports-indexed-properties-3" href="https://webidl.spec.whatwg.org/#dfn-support-indexed-properties" data-x-internal="supports-indexed-properties">supports indexed properties</a>.
  The <a id="pdf-viewing-support:supported-property-indices-3" href="https://webidl.spec.whatwg.org/#dfn-supported-property-indices" data-x-internal="supported-property-indices">supported property indices</a> are the <a id="pdf-viewing-support:indices-3" href="https://infra.spec.whatwg.org/#list-get-the-indices" data-x-internal="indices">indices</a> of <a id="pdf-viewing-support:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-10">relevant global object</a>'s <a href="#pdf-viewer-mime-type-objects" id="pdf-viewing-support:pdf-viewer-mime-type-objects-6">PDF viewer mime type objects</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:dom-plugin-10"><a href="#dom-plugin">Plugin</a></code> interface's <dfn data-dfn-for="Plugin" id="dom-plugin-item" data-dfn-type="method"><code>item(<var>index</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>mimeTypes</var> be <a id="pdf-viewing-support:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-11">relevant global object</a>'s
   <a href="#pdf-viewer-mime-type-objects" id="pdf-viewing-support:pdf-viewer-mime-type-objects-7">PDF viewer mime type objects</a>.</p></li><li><p>If <var>index</var> &lt; <var>mimeTypes</var>'s <a href="https://infra.spec.whatwg.org/#list-size" id="pdf-viewing-support:list-size-5" data-x-internal="list-size">size</a>, then
   return <var>mimeTypes</var>[<var>index</var>].</p></li><li><p>Return null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:dom-plugin-11"><a href="#dom-plugin">Plugin</a></code> interface's <dfn data-dfn-for="Plugin" id="dom-plugin-length" data-dfn-type="attribute"><code>length</code></dfn> getter steps are to return
  <a id="pdf-viewing-support:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-12">relevant global object</a>'s <a href="#pdf-viewer-mime-type-objects" id="pdf-viewing-support:pdf-viewer-mime-type-objects-8">PDF viewer mime type
  objects</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="pdf-viewing-support:list-size-6" data-x-internal="list-size">size</a>.</p>
  </div>

  <hr>

  <p>Each <code id="pdf-viewing-support:mimetype-8"><a href="#mimetype">MimeType</a></code> object has a <dfn id="concept-mimetype-type">type</dfn>, which
  is set when the object is created.</p>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:mimetype-9"><a href="#mimetype">MimeType</a></code> interface's <dfn data-dfn-for="MimeType" id="dom-mimetype-type" data-dfn-type="attribute"><code>type</code></dfn> getter steps are to return <a id="pdf-viewing-support:this-16" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-mimetype-type" id="pdf-viewing-support:concept-mimetype-type-4">type</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:mimetype-10"><a href="#mimetype">MimeType</a></code> interface's <dfn data-dfn-for="MimeType" id="dom-mimetype-description" data-dfn-type="attribute"><code>description</code></dfn> getter steps are to return "<code>Portable Document Format</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:mimetype-11"><a href="#mimetype">MimeType</a></code> interface's <dfn data-dfn-for="MimeType" id="dom-mimetype-suffixes" data-dfn-type="attribute"><code>suffixes</code></dfn> getter steps are to return "<code>pdf</code>".</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="pdf-viewing-support:mimetype-12"><a href="#mimetype">MimeType</a></code> interface's <dfn data-dfn-for="MimeType" id="dom-mimetype-enabledplugin" data-dfn-type="attribute"><code>enabledPlugin</code></dfn> getter steps are to return
  <a id="pdf-viewing-support:this-17" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="pdf-viewing-support:concept-relevant-global-13">relevant global object</a>'s <a href="#pdf-viewer-plugin-objects" id="pdf-viewing-support:pdf-viewer-plugin-objects-5">PDF viewer plugin
  objects</a>[0] (i.e., the generic "<code>PDF Viewer</code>" one).</p>
  </div>

  


  <h3 id="images-2"><span class="secno">8.10</span> Images<a href="#images-2" class="self-link"></a></h3>

  <h4 id="the-imagedata-interface"><span class="secno">8.10.1</span> The <code id="the-imagedata-interface:imagedata"><a href="#imagedata">ImageData</a></code> interface<a href="#the-imagedata-interface" class="self-link"></a></h4>

<div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageData" title="The ImageData interface represents the underlying pixel data of an area of a <canvas> element.">ImageData</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><pre><code class="idl">
<c- b="">typedef</c-> (<a href="https://webidl.spec.whatwg.org/#idl-Uint8ClampedArray" id="the-imagedata-interface:idl-uint8clampedarray" data-x-internal="idl-uint8clampedarray"><c- b="">Uint8ClampedArray</c-></a> <c- b="">or</c-> <a href="https://webidl.spec.whatwg.org/#idl-Float16Array" id="the-imagedata-interface:idl-float16array" data-x-internal="idl-float16array"><c- n="">Float16Array</c-></a>) <dfn id="imagedataarray" data-dfn-type="typedef"><c- g="">ImageDataArray</c-></dfn>;

<c- b="">enum</c-> <dfn id="imagedatapixelformat" data-dfn-type="enum"><c- g="">ImageDataPixelFormat</c-></dfn> { <c- s="">"</c-><a href="#dom-imagedatapixelformat-rgba-unorm8" id="the-imagedata-interface:dom-imagedatapixelformat-rgba-unorm8"><c- s="">rgba-unorm8</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-imagedatapixelformat-rgba-float16" id="the-imagedata-interface:dom-imagedatapixelformat-rgba-float16"><c- s="">rgba-float16</c-></a><c- s="">"</c-> };

<c- b="">dictionary</c-> <dfn id="imagedatasettings" data-dfn-type="dictionary"><c- g="">ImageDataSettings</c-></dfn> {
  <a href="#predefinedcolorspace" id="the-imagedata-interface:predefinedcolorspace"><c- n="">PredefinedColorSpace</c-></a> <a href="#dom-predefinedcolorspace-srgb" id="the-imagedata-interface:dom-predefinedcolorspace-srgb"><c- g="">colorSpace</c-></a>;
  <a href="#imagedatapixelformat" id="the-imagedata-interface:imagedatapixelformat"><c- n="">ImageDataPixelFormat</c-></a> <a href="#dom-imagedatasettings-pixelformat" id="the-imagedata-interface:dom-imagedatasettings-pixelformat"><c- g="">pixelFormat</c-></a> = "<a href="#dom-imagedatapixelformat-rgba-unorm8" id="the-imagedata-interface:dom-imagedatapixelformat-rgba-unorm8-2">rgba-unorm8</a>";
};

[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->),
 <a href="#serializable" id="the-imagedata-interface:serializable"><c- g="">Serializable</c-></a>]
<c- b="">interface</c-> <dfn id="imagedata" data-dfn-type="interface"><c- g="">ImageData</c-></dfn> {
  <a href="#dom-imagedata" id="the-imagedata-interface:dom-imagedata"><c- g="">constructor</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">sw</c->, <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">sh</c->, <c- b="">optional</c-> <a href="#imagedatasettings" id="the-imagedata-interface:imagedatasettings"><c- n="">ImageDataSettings</c-></a> <c- g="">settings</c-> = {});
  <a href="#dom-imagedata-with-data" id="the-imagedata-interface:dom-imagedata-with-data"><c- g="">constructor</c-></a>(<a href="#imagedataarray" id="the-imagedata-interface:imagedataarray"><c- n="">ImageDataArray</c-></a> <c- g="">data</c->, <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">sw</c->, <c- b="">optional</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">sh</c->, <c- b="">optional</c-> <a href="#imagedatasettings" id="the-imagedata-interface:imagedatasettings-2"><c- n="">ImageDataSettings</c-></a> <c- g="">settings</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-imagedata-width" id="the-imagedata-interface:dom-imagedata-width"><c- g="">width</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-imagedata-height" id="the-imagedata-interface:dom-imagedata-height"><c- g="">height</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#imagedataarray" id="the-imagedata-interface:imagedataarray-2"><c- n="">ImageDataArray</c-></a> <a href="#dom-imagedata-data" id="the-imagedata-interface:dom-imagedata-data"><c- g="">data</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#imagedatapixelformat" id="the-imagedata-interface:imagedatapixelformat-2"><c- n="">ImageDataPixelFormat</c-></a> <a href="#dom-imagedata-pixelformat" id="the-imagedata-interface:dom-imagedata-pixelformat"><c- g="">pixelFormat</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#predefinedcolorspace" id="the-imagedata-interface:predefinedcolorspace-2"><c- n="">PredefinedColorSpace</c-></a> <a href="#dom-imagedata-colorspace" id="the-imagedata-interface:dom-imagedata-colorspace"><c- g="">colorSpace</c-></a>;
};
</code></pre>

  <p>An <code id="the-imagedata-interface:imagedata-2"><a href="#imagedata">ImageData</a></code> object <dfn id="concept-imagedata-bitmap-representation">
  represents a rectanglar bitmap</dfn> with width equal to the <code id="the-imagedata-interface:dom-imagedata-width-2"><a href="#dom-imagedata-width">
  width</a></code> attribute and height equal to the <code id="the-imagedata-interface:dom-imagedata-height-2"><a href="#dom-imagedata-height">height</a></code>
  attribute. The pixel values of this bitmap are stored in the <code id="the-imagedata-interface:dom-imagedata-data-2"><a href="#dom-imagedata-data">
  data</a></code> attribute in left-to-right order, row by row from top to bottom, starting with 0 for
  the top left pixel, with the order and numerical representation of the color components of each
  pixel determined by the <code id="the-imagedata-interface:dom-imagedata-pixelformat-2"><a href="#dom-imagedata-pixelformat">pixelFormat</a></code> attribute.
  The color space of the pixel values of the bitmap is determined by the <code id="the-imagedata-interface:dom-imagedata-colorspace-2"><a href="#dom-imagedata-colorspace">colorSpace</a></code> attribute.</p>


  <dl class="domintro"><dt><code><var>imageData</var> = new <a href="#dom-imagedata" id="dom-imagedata-dev">ImageData</a>(<var>sw</var>, <var>sh</var> [, <var>settings</var>])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageData/ImageData" title="The ImageData() constructor returns a newly instantiated ImageData object built from the typed array given and having the specified width and height.">ImageData/ImageData</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome yes"><span>Chrome</span><span>36+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns an <code id="the-imagedata-interface:imagedata-3"><a href="#imagedata">ImageData</a></code> object with the given dimensions and the color space
    indicated by <var>settings</var>. All the pixels in the returned object are <a id="the-imagedata-interface:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent
    black</a>.</p>

    <p>Throws an <a id="the-imagedata-interface:indexsizeerror" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-imagedata-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if either of
    the width or height arguments are zero.</p>
   </dd><dt><code><var>imageData</var> = new <a href="#dom-imagedata-with-data" id="dom-imagedata-with-data-dev">ImageData</a>(<var>data</var>, <var>sw</var> [, <var>sh</var> [, <var>settings</var> ] ])</code></dt><dd>
    <p>Returns an <code id="the-imagedata-interface:imagedata-4"><a href="#imagedata">ImageData</a></code> object using the data provided in the <code id="the-imagedata-interface:imagedataarray-3"><a href="#imagedataarray">ImageDataArray</a></code>
    argument, interpreted using the given dimensions and the color space indicated by <var>settings</var>.</p>

    <p>The byte length of the data needs to be a multiple of the number of bytes per pixel times the
    given width. If the height is provided as well, then the length needs to be exactly the number of
    bytes per pixel times the width times the height.</p>

    <p>Throws an <a id="the-imagedata-interface:indexsizeerror-2" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-imagedata-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the given
    data and dimensions can't be interpreted consistently, or if either dimension is zero.</p>
   </dd><dt><code><var>imageData</var>.<a href="#dom-imagedata-width" id="dom-imagedata-width-dev">width</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageData/width" title="The readonly ImageData.width property returns the number of pixels per row in the ImageData object.">ImageData/width</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dt><code><var>imageData</var>.<a href="#dom-imagedata-height" id="dom-imagedata-height-dev">height</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageData/height" title="The readonly ImageData.height property returns the number of rows in the ImageData object.">ImageData/height</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Returns the actual dimensions of the data in the <code id="the-imagedata-interface:imagedata-5"><a href="#imagedata">ImageData</a></code> object, in
   pixels.</p></dd><dt><code><var>imageData</var>.<a href="#dom-imagedata-data" id="dom-imagedata-data-dev">data</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageData/data" title="The readonly ImageData.data property returns a Uint8ClampedArray that contains the ImageData object's pixel data. Data is stored as a one-dimensional array in the RGBA order, with integer values between 0 and 255 (inclusive).">ImageData/data</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd><p>Returns the one-dimensional array containing the data in RGBA order, as integers in the
   range 0 to 255.</p></dd><dt><code><var>imageData</var>.<a href="#dom-imagedata-colorspace" id="dom-imagedata-colorspace-dev">colorSpace</a></code></dt><dd><p>Returns the color space of the pixels.</p></dd></dl>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ImageData" id="dom-imagedata" data-dfn-type="constructor"><code>new ImageData(<var>sw</var>,
  <var>sh</var>, <var>settings</var>)</code></dfn> constructor steps are:</p>

  <ol><li><p>If one or both of <var>sw</var> and <var>sh</var> are zero, then throw an
   <a id="the-imagedata-interface:indexsizeerror-3" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-imagedata-interface:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#initialize-an-imagedata-object" id="the-imagedata-interface:initialize-an-imagedata-object">Initialize</a> <a id="the-imagedata-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> given
   <var>sw</var>, <var>sh</var>, and <var>settings</var>.</p></li><li><p>Initialize the image data of <a id="the-imagedata-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> to <a id="the-imagedata-interface:transparent-black-2" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ImageData" id="dom-imagedata-with-data" data-dfn-type="constructor"><code>new
  ImageData(<var>data</var>, <var>sw</var>, <var>sh</var>, <var>settings</var>)</code></dfn>
  constructor steps are:</p>

  <ol><li><p>Let <var>bytesPerPixel</var> be 4 if
   <var>settings</var>["<code id="the-imagedata-interface:dom-imagedatasettings-pixelformat-2"><a href="#dom-imagedatasettings-pixelformat">pixelFormat</a></code>"] is
   "<a href="#dom-imagedatapixelformat-rgba-unorm8" id="the-imagedata-interface:dom-imagedatapixelformat-rgba-unorm8-3">rgba-unorm8</a>"; otherwise 8.</p></li><li><p>Let <var>length</var> be the <a id="the-imagedata-interface:buffer-source-byte-length" href="https://webidl.spec.whatwg.org/#buffersource-byte-length" data-x-internal="buffer-source-byte-length">buffer source byte length</a> of <var>data</var>.</p></li><li><p>If <var>length</var> is not a nonzero integral multiple of <var>bytesPerPixel</var>, then throw an
   <a id="the-imagedata-interface:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-imagedata-interface:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>length</var> be <var>length</var> divided by <var>bytesPerPixel</var>.</p>

   </li><li>
    <p>If <var>length</var> is not an integral multiple of <var>sw</var>, then throw an
    <a id="the-imagedata-interface:indexsizeerror-4" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-imagedata-interface:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>

    <p class="note">At this step, the length is guaranteed to be greater than zero (otherwise the
    second step above would have aborted the steps), so if <var>sw</var> is zero, this
    step will throw the exception and return.</p>
   </li><li><p>Let <var>height</var> be <var>length</var> divided by <var>sw</var>.</p></li><li><p>If <var>sh</var> was given and its value is not equal to <var>height</var>, then throw an
   <a id="the-imagedata-interface:indexsizeerror-5" href="https://webidl.spec.whatwg.org/#indexsizeerror" data-x-internal="indexsizeerror">"<code>IndexSizeError</code>"</a> <code id="the-imagedata-interface:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li>
    <p><a href="#initialize-an-imagedata-object" id="the-imagedata-interface:initialize-an-imagedata-object-2">Initialize</a> <a id="the-imagedata-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> given
    <var>sw</var>, <var>sh</var>, <var>settings</var>, and
    <i><a href="#initialize-imagedata-source" id="the-imagedata-interface:initialize-imagedata-source">source</a></i> set to <var>data</var>.</p>

    <p class="note">This step does not set <a id="the-imagedata-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s data to a copy of <var>data</var>.
    It sets it to the actual <code id="the-imagedata-interface:imagedataarray-4"><a href="#imagedataarray">ImageDataArray</a></code> object passed as <var>data</var>.</p>
   </li></ol>
  </div>


  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageData/colorSpace" title="The read-only ImageData.colorSpace property is a string indicating the color space of the image data.">ImageData/colorSpace</a></p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari yes"><span>Safari</span><span>15.2+</span></span><span class="chrome yes"><span>Chrome</span><span>92+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>92+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>To <dfn id="initialize-an-imagedata-object">initialize an <code>ImageData</code> object</dfn> <var>imageData</var>, given a
  positive integer number of pixels per row <var>pixelsPerRow</var>, a positive integer number
  of rows <var>rows</var>, an <code id="the-imagedata-interface:imagedatasettings-3"><a href="#imagedatasettings">ImageDataSettings</a></code> <var>settings</var>, an optional
  <code id="the-imagedata-interface:imagedataarray-5"><a href="#imagedataarray">ImageDataArray</a></code> <dfn id="initialize-imagedata-source"><var>source</var></dfn>,
  and an optional <code id="the-imagedata-interface:predefinedcolorspace-3"><a href="#predefinedcolorspace">PredefinedColorSpace</a></code> <dfn id="initialize-imagedata-defaultcolorspace"><var>defaultColorSpace</var></dfn>:</p>

  <ol><li>
    <p>If <var>source</var> was given:</p>

    <ol><li><p>If <var>settings</var>["<code id="the-imagedata-interface:dom-imagedatasettings-pixelformat-3"><a href="#dom-imagedatasettings-pixelformat">pixelFormat</a></code>"]
     equals "<a href="#dom-imagedatapixelformat-rgba-unorm8" id="the-imagedata-interface:dom-imagedatapixelformat-rgba-unorm8-4">rgba-unorm8</a>" and
     <var>source</var> is not a <code id="the-imagedata-interface:idl-uint8clampedarray-2"><a data-x-internal="idl-uint8clampedarray" href="https://webidl.spec.whatwg.org/#idl-Uint8ClampedArray">Uint8ClampedArray</a></code>,
     then throw an <a id="the-imagedata-interface:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-imagedata-interface:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>settings</var>["<code id="the-imagedata-interface:dom-imagedatasettings-pixelformat-4"><a href="#dom-imagedatasettings-pixelformat">pixelFormat</a></code>"]
     is "<a href="#dom-imagedatapixelformat-rgba-float16" id="the-imagedata-interface:dom-imagedatapixelformat-rgba-float16-2">rgba-float16</a>" and
     <var>source</var> is not a <code id="the-imagedata-interface:idl-float16array-2"><a data-x-internal="idl-float16array" href="https://webidl.spec.whatwg.org/#idl-Float16Array">Float16Array</a></code>,
     then throw an <a id="the-imagedata-interface:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-imagedata-interface:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Initialize the <dfn data-dfn-for="ImageData" id="dom-imagedata-data" data-dfn-type="attribute"><code>data</code></dfn> attribute of <var>imageData</var> to
     <var>source</var>.</p></li></ol>
   </li><li>
    <p>Otherwise (<var>source</var> was not given):</p>

    <ol><li><p>If <var>settings</var>["<code id="the-imagedata-interface:dom-imagedatasettings-pixelformat-5"><a href="#dom-imagedatasettings-pixelformat">pixelFormat</a></code>"] is "<a href="#dom-imagedatapixelformat-rgba-unorm8" id="the-imagedata-interface:dom-imagedatapixelformat-rgba-unorm8-5">rgba-unorm8</a>", then initialize the <code id="the-imagedata-interface:dom-imagedata-data-3"><a href="#dom-imagedata-data">data</a></code> attribute of <var>imageData</var> to a new <code id="the-imagedata-interface:idl-uint8clampedarray-3"><a data-x-internal="idl-uint8clampedarray" href="https://webidl.spec.whatwg.org/#idl-Uint8ClampedArray">Uint8ClampedArray</a></code> object. The <code id="the-imagedata-interface:idl-uint8clampedarray-4"><a data-x-internal="idl-uint8clampedarray" href="https://webidl.spec.whatwg.org/#idl-Uint8ClampedArray">Uint8ClampedArray</a></code> object must use a new
     <code id="the-imagedata-interface:idl-arraybuffer"><a data-x-internal="idl-arraybuffer" href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer">ArrayBuffer</a></code> for its storage, and must have
     a zero byte offset and byte length equal to the length of its storage, in bytes.
     The storage <code id="the-imagedata-interface:idl-arraybuffer-2"><a data-x-internal="idl-arraybuffer" href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer">ArrayBuffer</a></code> must have a length
     of 4 × <var>rows</var> × <var>pixelsPerRow</var> bytes.</p></li><li><p>Otherwise, if <var>settings</var>["<code id="the-imagedata-interface:dom-imagedatasettings-pixelformat-6"><a href="#dom-imagedatasettings-pixelformat">pixelFormat</a></code>"] is "<a href="#dom-imagedatapixelformat-rgba-unorm8" id="the-imagedata-interface:dom-imagedatapixelformat-rgba-unorm8-6">rgba-float16</a>", then initialize the <code id="the-imagedata-interface:dom-imagedata-data-4"><a href="#dom-imagedata-data">data</a></code> attribute of <var>imageData</var> to a new <code id="the-imagedata-interface:idl-float16array-3"><a data-x-internal="idl-float16array" href="https://webidl.spec.whatwg.org/#idl-Float16Array">Float16Array</a></code> object. The <code id="the-imagedata-interface:idl-float16array-4"><a data-x-internal="idl-float16array" href="https://webidl.spec.whatwg.org/#idl-Float16Array">Float16Array</a></code> object must use a new
     <code id="the-imagedata-interface:idl-arraybuffer-3"><a data-x-internal="idl-arraybuffer" href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer">ArrayBuffer</a></code> for its storage, and must have
     a zero byte offset and byte length equal to the length of its storage, in bytes.
     The storage <code id="the-imagedata-interface:idl-arraybuffer-4"><a data-x-internal="idl-arraybuffer" href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer">ArrayBuffer</a></code> must have a length
     of 8 × <var>rows</var> × <var>pixelsPerRow</var> bytes.</p></li><li><p>If the storage <code id="the-imagedata-interface:idl-arraybuffer-5"><a data-x-internal="idl-arraybuffer" href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer">ArrayBuffer</a></code> could not be
     allocated, then rethrow the <code id="the-imagedata-interface:js-rangeerror"><a data-x-internal="js-rangeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror">RangeError</a></code> thrown by JavaScript,
     and return.</p></li></ol>
   </li><li><p>Initialize the <dfn data-dfn-for="ImageData" id="dom-imagedata-width" data-dfn-type="attribute"><code>width</code></dfn> attribute of <var>imageData</var> to
   <var>pixelsPerRow</var>.</p></li><li><p>Initialize the <dfn data-dfn-for="ImageData" id="dom-imagedata-height" data-dfn-type="attribute"><code>height</code></dfn> attribute of <var>imageData</var> to
   <var>rows</var>.</p></li><li><p>Initialize the
   <dfn data-dfn-for="ImageData" id="dom-imagedata-pixelformat" data-dfn-type="attribute"><code>pixelFormat</code></dfn>
   attribute of <var>imageData</var> to
   <var>settings</var>["<dfn data-dfn-for="ImageDataSettings" id="dom-imagedatasettings-pixelformat" data-dfn-type="dict-member"><code>pixelFormat</code></dfn>"].</p></li><li><p>If <var>settings</var>["<code id="the-imagedata-interface:dom-imagedatasettings-colorspace"><a href="#dom-imagedatasettings-colorspace">colorSpace</a></code>"]
   <a href="https://infra.spec.whatwg.org/#map-exists" id="the-imagedata-interface:map-exists" data-x-internal="map-exists">exists</a>, then initialize the <dfn data-dfn-for="ImageData" id="dom-imagedata-colorspace" data-dfn-type="attribute"><code>colorSpace</code></dfn> attribute of <var>imageData</var> to
   <var>settings</var>["<dfn data-dfn-for="ImageDataSettings" id="dom-imagedatasettings-colorspace" data-dfn-type="dict-member"><code>colorSpace</code></dfn>"].</p></li><li><p>Otherwise, if <var>defaultColorSpace</var> was given, then initialize the <code id="the-imagedata-interface:dom-imagedata-colorspace-3"><a href="#dom-imagedata-colorspace">colorSpace</a></code> attribute of <var>imageData</var> to
   <var>defaultColorSpace</var>.</p></li><li><p>Otherwise, initialize the <code id="the-imagedata-interface:dom-imagedata-colorspace-4"><a href="#dom-imagedata-colorspace">colorSpace</a></code>
   attribute of <var>imageData</var> to "<a href="#dom-predefinedcolorspace-srgb" id="the-imagedata-interface:dom-predefinedcolorspace-srgb-2">srgb</a>".</p></li></ol>
  </div>

  <div data-algorithm="">
  <p><code id="the-imagedata-interface:imagedata-6"><a href="#imagedata">ImageData</a></code> objects are <a href="#serializable-objects" id="the-imagedata-interface:serializable-objects">serializable objects</a>. Their <a href="#serialization-steps" id="the-imagedata-interface:serialization-steps">serialization
  steps</a>, given <var>value</var> and <var>serialized</var>, are:</p>

  <ol><li><p>Set <var>serialized</var>.[[Data]] to the <a href="#sub-serialization" id="the-imagedata-interface:sub-serialization">sub-serialization</a> of the value of
   <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-data-5"><a href="#dom-imagedata-data">data</a></code> attribute.</p></li><li><p>Set <var>serialized</var>.[[Width]] to the value of <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-width-3"><a href="#dom-imagedata-width">width</a></code> attribute.</p></li><li><p>Set <var>serialized</var>.[[Height]] to the value of <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-height-3"><a href="#dom-imagedata-height">height</a></code> attribute.</p></li><li><p>Set <var>serialized</var>.[[ColorSpace]] to the value of <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-colorspace-5"><a href="#dom-imagedata-colorspace">colorSpace</a></code> attribute.</p></li><li><p>Set <var>serialized</var>.[[PixelFormat]] to the value of <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-pixelformat-3"><a href="#dom-imagedata-pixelformat">pixelFormat</a></code> attribute.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Their <a href="#deserialization-steps" id="the-imagedata-interface:deserialization-steps">deserialization steps</a>, given <var>serialized</var>, <var>value</var>,
  and <var>targetRealm</var>, are:</p>

  <ol><li><p>Initialize <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-data-6"><a href="#dom-imagedata-data">data</a></code> attribute
   to the <a href="#sub-deserialization" id="the-imagedata-interface:sub-deserialization">sub-deserialization</a> of <var>serialized</var>.[[Data]].</p></li><li><p>Initialize <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-width-4"><a href="#dom-imagedata-width">width</a></code> attribute
   to <var>serialized</var>.[[Width]].</p></li><li><p>Initialize <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-height-4"><a href="#dom-imagedata-height">height</a></code> attribute
   to <var>serialized</var>.[[Height]].</p></li><li><p>Initialize <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-colorspace-6"><a href="#dom-imagedata-colorspace">colorSpace</a></code>
   attribute to <var>serialized</var>.[[ColorSpace]].</p></li><li><p>Initialize <var>value</var>'s <code id="the-imagedata-interface:dom-imagedata-pixelformat-4"><a href="#dom-imagedata-pixelformat">pixelFormat</a></code>
   attribute to <var>serialized</var>.[[PixelFormat]].</p></li></ol>
  </div>

  <p>The <code id="the-imagedata-interface:imagedatapixelformat-3"><a href="#imagedatapixelformat">ImageDataPixelFormat</a></code> enumeration is used to specify type of the
  <code id="the-imagedata-interface:dom-imagedata-data-7"><a href="#dom-imagedata-data">data</a></code> attribute of an <code id="the-imagedata-interface:imagedata-7"><a href="#imagedata">ImageData</a></code>
  and the arrangement and numerical representation of the color components for each pixel.</p>

  <p>The "<dfn data-dfn-for="ImageDataPixelFormat" id="dom-imagedatapixelformat-rgba-unorm8" data-dfn-type="enum-value"><code>rgba-unorm8</code></dfn>" value indicates that the
  <code id="the-imagedata-interface:dom-imagedata-data-8"><a href="#dom-imagedata-data">data</a></code> attribute of an <code id="the-imagedata-interface:imagedata-8"><a href="#imagedata">ImageData</a></code> must be of
  type <a href="https://webidl.spec.whatwg.org/#idl-Uint8ClampedArray" id="the-imagedata-interface:idl-uint8clampedarray-5" data-x-internal="idl-uint8clampedarray">Uint8ClampedArray</a>. The color components of each
  pixel must be stored in four sequential elements in the order of red, green, blue, and then alpha.
  Each element represents the 8-bit unsigned normalized value for that component.</p>

  <p>The "<dfn data-dfn-for="ImageDataPixelFormat" id="dom-imagedatapixelformat-rgba-float16" data-dfn-type="enum-value"><code>rgba-float16</code></dfn>" value indicates that the
  <code id="the-imagedata-interface:dom-imagedata-data-9"><a href="#dom-imagedata-data">data</a></code> attribute of an <code id="the-imagedata-interface:imagedata-9"><a href="#imagedata">ImageData</a></code> must be of
  type <a href="https://webidl.spec.whatwg.org/#idl-Float16Array" id="the-imagedata-interface:idl-float16array-5" data-x-internal="idl-float16array">Float16Array</a>. The color components of each pixel must
  be stored in four sequential elements in the order of red, green, blue, and then alpha. Each
  element represents the value for that component.</p>

  <h4 id="the-imagebitmap-interface"><span class="secno">8.10.2</span> The <code id="the-imagebitmap-interface:imagebitmap"><a href="#imagebitmap">ImageBitmap</a></code> interface<a href="#the-imagebitmap-interface" class="self-link"></a></h4>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap" title="The ImageBitmap interface represents a bitmap image which can be drawn to a <canvas> without undue latency. It can be created from a variety of source objects using the createImageBitmap() factory method. ImageBitmap provides an asynchronous and resource efficient pathway to prepare textures for rendering in WebGL.">ImageBitmap</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>42+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>50+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->), <a href="#serializable" id="the-imagebitmap-interface:serializable"><c- g="">Serializable</c-></a>, <a href="#transferable" id="the-imagebitmap-interface:transferable"><c- g="">Transferable</c-></a>]
<c- b="">interface</c-> <dfn id="imagebitmap" data-dfn-type="interface"><c- g="">ImageBitmap</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-imagebitmap-width" id="the-imagebitmap-interface:dom-imagebitmap-width"><c- g="">width</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-imagebitmap-height" id="the-imagebitmap-interface:dom-imagebitmap-height"><c- g="">height</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-imagebitmap-close" id="the-imagebitmap-interface:dom-imagebitmap-close"><c- g="">close</c-></a>();
};

<c- b="">typedef</c-> (<a href="#canvasimagesource" id="the-imagebitmap-interface:canvasimagesource"><c- n="">CanvasImageSource</c-></a> <c- b="">or</c->
         <a id="the-imagebitmap-interface:blob" href="https://w3c.github.io/FileAPI/#dfn-Blob" data-x-internal="blob"><c- n="">Blob</c-></a> <c- b="">or</c->
         <a href="#imagedata" id="the-imagebitmap-interface:imagedata"><c- n="">ImageData</c-></a>) <dfn id="imagebitmapsource" data-dfn-type="typedef"><c- g="">ImageBitmapSource</c-></dfn>;

<c- b="">enum</c-> <dfn id="imageorientation" data-dfn-type="enum"><c- g="">ImageOrientation</c-></dfn> { <c- s="">"</c-><a href="#dom-imageorientation-from-image" id="the-imagebitmap-interface:dom-imageorientation-from-image"><c- s="">from-image</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-imageorientation-flipy" id="the-imagebitmap-interface:dom-imageorientation-flipy"><c- s="">flipY</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="premultiplyalpha" data-dfn-type="enum"><c- g="">PremultiplyAlpha</c-></dfn> { <c- s="">"</c-><a href="#dom-premultiplyalpha-none" id="the-imagebitmap-interface:dom-premultiplyalpha-none"><c- s="">none</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-premultiplyalpha-premultiply" id="the-imagebitmap-interface:dom-premultiplyalpha-premultiply"><c- s="">premultiply</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-premultiplyalpha-default" id="the-imagebitmap-interface:dom-premultiplyalpha-default"><c- s="">default</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="colorspaceconversion" data-dfn-type="enum"><c- g="">ColorSpaceConversion</c-></dfn> { <c- s="">"</c-><a href="#dom-colorspaceconversion-none" id="the-imagebitmap-interface:dom-colorspaceconversion-none"><c- s="">none</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-colorspaceconversion-default" id="the-imagebitmap-interface:dom-colorspaceconversion-default"><c- s="">default</c-></a><c- s="">"</c-> };
<c- b="">enum</c-> <dfn id="resizequality" data-dfn-type="enum"><c- g="">ResizeQuality</c-></dfn> { <c- s="">"</c-><a href="#dom-resizequality-pixelated" id="the-imagebitmap-interface:dom-resizequality-pixelated"><c- s="">pixelated</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-resizequality-low" id="the-imagebitmap-interface:dom-resizequality-low"><c- s="">low</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-resizequality-medium" id="the-imagebitmap-interface:dom-resizequality-medium"><c- s="">medium</c-></a><c- s="">"</c->, <c- s="">"</c-><a href="#dom-resizequality-high" id="the-imagebitmap-interface:dom-resizequality-high"><c- s="">high</c-></a><c- s="">"</c-> };

<c- b="">dictionary</c-> <dfn id="imagebitmapoptions" data-dfn-type="dictionary"><c- g="">ImageBitmapOptions</c-></dfn> {
  <a href="#imageorientation" id="the-imagebitmap-interface:imageorientation"><c- n="">ImageOrientation</c-></a> <a href="#dom-imagebitmapoptions-imageorientation" id="the-imagebitmap-interface:dom-imagebitmapoptions-imageorientation"><c- g="">imageOrientation</c-></a> = "<a href="#dom-imageorientation-from-image" id="the-imagebitmap-interface:dom-imageorientation-from-image-2">from-image</a>";
  <a href="#premultiplyalpha" id="the-imagebitmap-interface:premultiplyalpha"><c- n="">PremultiplyAlpha</c-></a> <a href="#dom-imagebitmapoptions-premultiplyalpha" id="the-imagebitmap-interface:dom-imagebitmapoptions-premultiplyalpha"><c- g="">premultiplyAlpha</c-></a> = "<a href="#dom-premultiplyalpha-default" id="the-imagebitmap-interface:dom-premultiplyalpha-default-2">default</a>";
  <a href="#colorspaceconversion" id="the-imagebitmap-interface:colorspaceconversion"><c- n="">ColorSpaceConversion</c-></a> <a href="#dom-imagebitmapoptions-colorspaceconversion" id="the-imagebitmap-interface:dom-imagebitmapoptions-colorspaceconversion"><c- g="">colorSpaceConversion</c-></a> = "<a href="#dom-colorspaceconversion-default" id="the-imagebitmap-interface:dom-colorspaceconversion-default-2">default</a>";
  [<c- g="">EnforceRange</c->] <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-imagebitmapoptions-resizewidth" id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth"><c- g="">resizeWidth</c-></a>;
  [<c- g="">EnforceRange</c->] <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-imagebitmapoptions-resizeheight" id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight"><c- g="">resizeHeight</c-></a>;
  <a href="#resizequality" id="the-imagebitmap-interface:resizequality"><c- n="">ResizeQuality</c-></a> <a href="#dom-imagebitmapoptions-resizequality" id="the-imagebitmap-interface:dom-imagebitmapoptions-resizequality"><c- g="">resizeQuality</c-></a> = "<a href="#dom-resizequality-low" id="the-imagebitmap-interface:dom-resizequality-low-2">low</a>";
};</code></pre>

  <p>An <code id="the-imagebitmap-interface:imagebitmap-2"><a href="#imagebitmap">ImageBitmap</a></code> object represents a bitmap image that can be painted to a canvas
  without undue latency.</p>

  <p class="note">The exact judgement of what is undue latency of this is left up to the
  implementer, but in general if making use of the bitmap requires network I/O, or even local disk
  I/O, then the latency is probably undue; whereas if it only requires a blocking read from a GPU or
  system RAM, the latency is probably acceptable.</p>

  <dl class="domintro"><dt><code><var>promise</var> = self.<a href="#dom-createimagebitmap" id="dom-createimagebitmap-dev">createImageBitmap</a>(<var>image</var> [, <var>options</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/createImageBitmap" title="The createImageBitmap() method creates a bitmap from a given source, optionally cropped to contain only a portion of that source. The method exists on the global scope in both windows and workers. It accepts a variety of different image sources, and returns a Promise which resolves to an ImageBitmap.">createImageBitmap</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>42+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>50+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dt><code><var>promise</var> = self.<a href="#dom-createimagebitmap" id="the-imagebitmap-interface:dom-createimagebitmap">createImageBitmap</a>(<var>image</var>, <var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var> [, <var>options</var> ])</code></dt><dd>
    <p>Takes <var>image</var>, which can be an <code id="the-imagebitmap-interface:the-img-element"><a href="#the-img-element">img</a></code> element, an <a id="the-imagebitmap-interface:svg-image" href="https://svgwg.org/svg2-draft/embedded.html#ImageElement" data-x-internal="svg-image">SVG
    <code>image</code></a> element, a <code id="the-imagebitmap-interface:the-video-element"><a href="#the-video-element">video</a></code> element, a <code id="the-imagebitmap-interface:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element,
    a <code id="the-imagebitmap-interface:blob-2"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> object, an <code id="the-imagebitmap-interface:imagedata-2"><a href="#imagedata">ImageData</a></code> object, or another
    <code id="the-imagebitmap-interface:imagebitmap-3"><a href="#imagebitmap">ImageBitmap</a></code> object, and returns a promise that is resolved when a new
    <code id="the-imagebitmap-interface:imagebitmap-4"><a href="#imagebitmap">ImageBitmap</a></code> is created.</p>

    <p>If no <code id="the-imagebitmap-interface:imagebitmap-5"><a href="#imagebitmap">ImageBitmap</a></code> object can be constructed, for example because the provided
    <var>image</var> data is not actually an image, then the promise is rejected instead.</p>

    <p>If <var>sx</var>, <var>sy</var>, <var>sw</var>, and <var>sh</var> arguments are provided, the
    source image is cropped to the given pixels, with any pixels missing in the original replaced by
    <a id="the-imagebitmap-interface:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>. These coordinates are in the source image's pixel coordinate
    space, <em>not</em> in <a href="https://drafts.csswg.org/css-values/#px" id="the-imagebitmap-interface:'px'" data-x-internal="'px'">CSS pixels</a>.</p>

    <p>If <var>options</var> is provided, the <code id="the-imagebitmap-interface:imagebitmap-6"><a href="#imagebitmap">ImageBitmap</a></code> object's bitmap data is
    modified according to <var>options</var>. For example, if the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-premultiplyalpha-2"><a href="#dom-imagebitmapoptions-premultiplyalpha">premultiplyAlpha</a></code> option is set to "<code id="the-imagebitmap-interface:dom-premultiplyalpha-premultiply-2"><a href="#dom-premultiplyalpha-premultiply">premultiply</a></code>", the <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data">bitmap data</a>'s non-alpha color components are
    <a href="#concept-premultiplied-alpha" id="the-imagebitmap-interface:concept-premultiplied-alpha">premultiplied by the alpha component</a>.</p>

    <p>Rejects the promise with an <a id="the-imagebitmap-interface:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
    <code id="the-imagebitmap-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the source image is not in a valid state (e.g., an <code id="the-imagebitmap-interface:the-img-element-2"><a href="#the-img-element">img</a></code>
    element that hasn't loaded successfully, an <code id="the-imagebitmap-interface:imagebitmap-7"><a href="#imagebitmap">ImageBitmap</a></code> object whose
    <a href="#detached" id="the-imagebitmap-interface:detached">[[Detached]]</a> internal slot value is true, an <code id="the-imagebitmap-interface:imagedata-3"><a href="#imagedata">ImageData</a></code> object whose
    <code id="the-imagebitmap-interface:dom-imagedata-data"><a href="#dom-imagedata-data">data</a></code> attribute value's [[ViewedArrayBuffer]] internal
    slot is detached, or a <code id="the-imagebitmap-interface:blob-3"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> whose data cannot be interpreted as a bitmap
    image).</p>

    <p>Rejects the promise with a <a id="the-imagebitmap-interface:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
    <code id="the-imagebitmap-interface:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the script is not allowed to access the image data of the source
    image (e.g. a <code id="the-imagebitmap-interface:the-video-element-2"><a href="#the-video-element">video</a></code> that is <a href="#cors-cross-origin" id="the-imagebitmap-interface:cors-cross-origin">CORS-cross-origin</a>, or a
    <code id="the-imagebitmap-interface:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> being drawn on by a script in a worker from another
    <a href="#concept-origin" id="the-imagebitmap-interface:concept-origin">origin</a>).</p>
   </dd><dt><code><var>imageBitmap</var>.<a href="#dom-imagebitmap-close" id="dom-imagebitmap-close-dev">close</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap/close" title="The ImageBitmap.close() method disposes of all graphical resources associated with an ImageBitmap.">ImageBitmap/close</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>46+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>52+</span></span><hr><span class="opera yes"><span>Opera</span><span>37+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>37+</span></span></div></div></div></dt><dd><p>Releases <var>imageBitmap</var>'s underlying <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-2">bitmap data</a>.</p></dd><dt><code><var>imageBitmap</var>.<a href="#dom-imagebitmap-width" id="dom-imagebitmap-width-dev">width</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap/width" title="The read-only ImageBitmap.width property returns the ImageBitmap object's width in CSS pixels.">ImageBitmap/width</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>42+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>50+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the <a id="the-imagebitmap-interface:natural-width" href="https://drafts.csswg.org/css-images/#natural-width" data-x-internal="natural-width">natural width</a> of the image, in <a href="https://drafts.csswg.org/css-values/#px" id="the-imagebitmap-interface:'px'-2" data-x-internal="'px'">CSS
    pixels</a>.</p>
   </dd><dt><code><var>imageBitmap</var>.<a href="#dom-imagebitmap-height" id="dom-imagebitmap-height-dev">height</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap/height" title="The read-only ImageBitmap.height property returns the ImageBitmap object's height in CSS pixels.">ImageBitmap/height</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>42+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>50+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns the <a id="the-imagebitmap-interface:natural-height" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a> of the image, in <a href="https://drafts.csswg.org/css-values/#px" id="the-imagebitmap-interface:'px'-3" data-x-internal="'px'">CSS
    pixels</a>.</p>
   </dd></dl>

  

  <p>An <code id="the-imagebitmap-interface:imagebitmap-8"><a href="#imagebitmap">ImageBitmap</a></code> object whose <a href="#detached" id="the-imagebitmap-interface:detached-2">[[Detached]]</a> internal slot value
  is false always has associated <dfn id="concept-imagebitmap-bitmap-data">bitmap data</dfn>,
  with a width and a height. However, it is possible for this data to be corrupted. If an
  <code id="the-imagebitmap-interface:imagebitmap-9"><a href="#imagebitmap">ImageBitmap</a></code> object's media data can be decoded without errors, it is said to be <dfn id="concept-imagebitmap-good">fully decodable</dfn>.</p>

  <p>An <code id="the-imagebitmap-interface:imagebitmap-10"><a href="#imagebitmap">ImageBitmap</a></code> object's bitmap has an <a href="#concept-canvas-origin-clean" id="the-imagebitmap-interface:concept-canvas-origin-clean">origin-clean</a> flag, which indicates whether the
  bitmap is tainted by content from a different <a href="#concept-origin" id="the-imagebitmap-interface:concept-origin-2">origin</a>. The flag is initially set to
  true and may be changed to false by the steps of <code id="the-imagebitmap-interface:dom-createimagebitmap-2"><a href="#dom-createimagebitmap">createImageBitmap()</a></code>.</p>

  <hr>

  <p><code id="the-imagebitmap-interface:imagebitmap-11"><a href="#imagebitmap">ImageBitmap</a></code> objects are <a href="#serializable-objects" id="the-imagebitmap-interface:serializable-objects">serializable objects</a> and <a href="#transferable-objects" id="the-imagebitmap-interface:transferable-objects">transferable
  objects</a>.</p>

  <div data-algorithm="">
  <p>Their <a href="#serialization-steps" id="the-imagebitmap-interface:serialization-steps">serialization steps</a>, given <var>value</var> and <var>serialized</var>,
  are:</p>

  <ol><li><p>If <var>value</var>'s <a href="#concept-canvas-origin-clean" id="the-imagebitmap-interface:concept-canvas-origin-clean-2">origin-clean</a>
   flag is not set, then throw a <a id="the-imagebitmap-interface:datacloneerror" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a>
   <code id="the-imagebitmap-interface:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.

   </p></li><li><p>Set <var>serialized</var>.[[BitmapData]] to a copy of <var>value</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-3">bitmap data</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Their <a href="#deserialization-steps" id="the-imagebitmap-interface:deserialization-steps">deserialization steps</a>, given <var>serialized</var>, <var>value</var>,
  and <var>targetRealm</var>, are:</p>

  <ol><li><p>Set <var>value</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-4">bitmap data</a>
   to <var>serialized</var>.[[BitmapData]].</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Their <a href="#transfer-steps" id="the-imagebitmap-interface:transfer-steps">transfer steps</a>, given <var>value</var> and <var>dataHolder</var>, are:</p>

  <ol><li><p>If <var>value</var>'s <a href="#concept-canvas-origin-clean" id="the-imagebitmap-interface:concept-canvas-origin-clean-3">origin-clean</a>
   flag is not set, then throw a <a id="the-imagebitmap-interface:datacloneerror-2" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a>
   <code id="the-imagebitmap-interface:domexception-4"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.

   </p></li><li><p>Set <var>dataHolder</var>.[[BitmapData]] to <var>value</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-5">bitmap data</a>.</p></li><li><p>Unset <var>value</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-6">bitmap
   data</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Their <a href="#transfer-receiving-steps" id="the-imagebitmap-interface:transfer-receiving-steps">transfer-receiving steps</a>, given <var>dataHolder</var> and <var>value</var>,
  are:</p>

  <ol><li><p>Set <var>value</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-7">bitmap data</a>
   to <var>dataHolder</var>.[[BitmapData]].</p></li></ol>
  </div>

  <hr>

  <p>The <a href="#dom-createimagebitmap" id="the-imagebitmap-interface:dom-createimagebitmap-3">createImageBitmap</a> method uses the <dfn id="bitmap-task-source">bitmap
  task source</dfn> to settle its returned Promise.</p>

  <div data-var-scope="">
  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WindowOrWorkerGlobalScope" id="dom-createimagebitmap" data-dfn-type="method"><code>createImageBitmap(<var>image</var>,
  <var>options</var>)</code></dfn> and <code>createImageBitmap(<var>image</var>,
  <var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var>, <var>options</var>)</code> methods,
  when invoked, must run these steps:</p>

  <ol><li><p>If either <var>sw</var> or <var>sh</var> is given and is 0, then return <a id="the-imagebitmap-interface:a-promise-rejected-with" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise
   rejected with</a> a <code id="the-imagebitmap-interface:js-rangeerror"><a data-x-internal="js-rangeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror">RangeError</a></code>.</p></li><li><p>If either <var>options</var>'s <dfn data-dfn-for="ImageBitmapOptions" id="dom-imagebitmapoptions-resizewidth" data-dfn-type="dict-member"><code>resizeWidth</code></dfn> or <var>options</var>'s
   <dfn data-dfn-for="ImageBitmapOptions" id="dom-imagebitmapoptions-resizeheight" data-dfn-type="dict-member"><code>resizeHeight</code></dfn> is present and is 0, then
   return <a id="the-imagebitmap-interface:a-promise-rejected-with-2" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> an <a id="the-imagebitmap-interface:invalidstateerror-2" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="the-imagebitmap-interface:domexception-5"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="#check-the-usability-of-the-image-argument" id="the-imagebitmap-interface:check-the-usability-of-the-image-argument">Check the usability of the <var>image</var> argument</a>. If this throws an
   exception or returns <i>bad</i>, then return <a id="the-imagebitmap-interface:a-promise-rejected-with-3" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> an
   <a id="the-imagebitmap-interface:invalidstateerror-3" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-imagebitmap-interface:domexception-6"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.

   </p></li><li><p>Let <var>promise</var> be a new promise.</p></li><li><p>Let <var>imageBitmap</var> be a new <code id="the-imagebitmap-interface:imagebitmap-12"><a href="#imagebitmap">ImageBitmap</a></code> object.</p></li><li>
    <p>Switch on <var>image</var>:</p>

    <dl class="switch"><dt><code id="the-imagebitmap-interface:the-img-element-3"><a href="#the-img-element">img</a></code>
     </dt><dt><a id="the-imagebitmap-interface:svg-image-2" href="https://svgwg.org/svg2-draft/embedded.html#ImageElement" data-x-internal="svg-image">SVG <code>image</code></a>
     </dt><dd>
      <ol><li><p>If <var>image</var>'s media data has no <a id="the-imagebitmap-interface:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> (e.g., it's
       a vector graphic with no specified content size) and either <var>options</var>'s <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth-2"><a href="#dom-imagebitmapoptions-resizewidth">resizeWidth</a></code> or <var>options</var>'s <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight-2"><a href="#dom-imagebitmapoptions-resizeheight">resizeHeight</a></code> is not present, then return
       <a id="the-imagebitmap-interface:a-promise-rejected-with-4" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> an <a id="the-imagebitmap-interface:invalidstateerror-4" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
       <code id="the-imagebitmap-interface:domexception-7"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If <var>image</var>'s media data has no <a id="the-imagebitmap-interface:natural-dimensions-2" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> (e.g., it's
       a vector graphic with no specified content size), it should be rendered to a bitmap of the
       size specified by the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth-3"><a href="#dom-imagebitmapoptions-resizewidth">resizeWidth</a></code>
       and the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight-3"><a href="#dom-imagebitmapoptions-resizeheight">resizeHeight</a></code>
       options.</p></li><li><p>Set <var>imageBitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-8">bitmap
       data</a> to a copy of <var>image</var>'s media data, <a href="#cropped-to-the-source-rectangle-with-formatting" id="the-imagebitmap-interface:cropped-to-the-source-rectangle-with-formatting">cropped to the source rectangle
       with formatting</a>. If this is an animated image, <var>imageBitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-9">bitmap data</a> must only be taken from the
       default image of the animation (the one that the format defines is to be used when animation
       is not supported or is disabled), or, if there is no such image, the first frame of the
       animation.</p></li><li><p>If <var>image</var> <a href="#the-image-argument-is-not-origin-clean" id="the-imagebitmap-interface:the-image-argument-is-not-origin-clean">is not origin-clean</a>, then set the <a href="#concept-canvas-origin-clean" id="the-imagebitmap-interface:concept-canvas-origin-clean-4">origin-clean</a> flag of <var>imageBitmap</var>'s
       bitmap to false.</p></li><li><p><a href="#queue-a-global-task" id="the-imagebitmap-interface:queue-a-global-task">Queue a global task</a>, using the <a href="#bitmap-task-source" id="the-imagebitmap-interface:bitmap-task-source">bitmap task source</a>, to
       resolve <var>promise</var> with <var>imageBitmap</var>.</p></li></ol>
     </dd><dt><code id="the-imagebitmap-interface:the-video-element-3"><a href="#the-video-element">video</a></code>
     </dt><dd>
      <ol><li><p>If <var>image</var>'s <code id="the-imagebitmap-interface:dom-media-networkstate"><a href="#dom-media-networkstate">networkState</a></code>
       attribute is <code id="the-imagebitmap-interface:dom-media-network_empty"><a href="#dom-media-network_empty">NETWORK_EMPTY</a></code>, then return
       <a id="the-imagebitmap-interface:a-promise-rejected-with-5" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a> an <a id="the-imagebitmap-interface:invalidstateerror-5" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
       <code id="the-imagebitmap-interface:domexception-8"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>imageBitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-10">bitmap
       data</a> to a copy of the frame at the <a href="#current-playback-position" id="the-imagebitmap-interface:current-playback-position">current playback position</a>, at the
       <a href="#media-resource" id="the-imagebitmap-interface:media-resource">media resource</a>'s <a href="#concept-video-intrinsic-width" id="the-imagebitmap-interface:concept-video-intrinsic-width">natural
       width</a> and <a href="#concept-video-intrinsic-height" id="the-imagebitmap-interface:concept-video-intrinsic-height">natural height</a> (i.e.,
       after any aspect-ratio correction has been applied), <a href="#cropped-to-the-source-rectangle-with-formatting" id="the-imagebitmap-interface:cropped-to-the-source-rectangle-with-formatting-2">cropped to the source rectangle
       with formatting</a>.</p>

       </li><li><p>If <var>image</var> <a href="#the-image-argument-is-not-origin-clean" id="the-imagebitmap-interface:the-image-argument-is-not-origin-clean-2">is not origin-clean</a>, then set the <a href="#concept-canvas-origin-clean" id="the-imagebitmap-interface:concept-canvas-origin-clean-5">origin-clean</a> flag of <var>imageBitmap</var>'s
       bitmap to false.</p></li><li><p><a href="#queue-a-global-task" id="the-imagebitmap-interface:queue-a-global-task-2">Queue a global task</a>, using the <a href="#bitmap-task-source" id="the-imagebitmap-interface:bitmap-task-source-2">bitmap task source</a>, to
       resolve <var>promise</var> with <var>imageBitmap</var>.</p></li></ol>
     </dd><dt><code id="the-imagebitmap-interface:the-canvas-element-3"><a href="#the-canvas-element">canvas</a></code>
     </dt><dd>
      <ol><li><p>Set <var>imageBitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-11">bitmap
       data</a> to a copy of <var>image</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-12">bitmap data</a>, <a href="#cropped-to-the-source-rectangle-with-formatting" id="the-imagebitmap-interface:cropped-to-the-source-rectangle-with-formatting-3">cropped to the source
       rectangle with formatting</a>.</p></li><li><p>Set the <a href="#concept-canvas-origin-clean" id="the-imagebitmap-interface:concept-canvas-origin-clean-6">origin-clean</a> flag of the
       <var>imageBitmap</var>'s bitmap to the same value as the <a href="#concept-canvas-origin-clean" id="the-imagebitmap-interface:concept-canvas-origin-clean-7">origin-clean</a> flag of <var>image</var>'s
       bitmap.</p></li><li><p><a href="#queue-a-global-task" id="the-imagebitmap-interface:queue-a-global-task-3">Queue a global task</a>, using the <a href="#bitmap-task-source" id="the-imagebitmap-interface:bitmap-task-source-3">bitmap task source</a>, to
       resolve <var>promise</var> with <var>imageBitmap</var>.</p></li></ol>
     </dd><dt><code id="the-imagebitmap-interface:blob-4"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code>
     </dt><dd>
      <p>Run these steps <a href="#in-parallel" id="the-imagebitmap-interface:in-parallel">in parallel</a>:</p>

      <ol><li><p>Let <var>imageData</var> be the result of reading <var>image</var>'s data. If an <a href="#file-error-read" id="the-imagebitmap-interface:file-error-read">error occurs during reading of the object</a>, then <a href="#queue-a-global-task" id="the-imagebitmap-interface:queue-a-global-task-4">queue a
       global task</a>, using the <a href="#bitmap-task-source" id="the-imagebitmap-interface:bitmap-task-source-4">bitmap task source</a>, to reject <var>promise</var>
       with an <a id="the-imagebitmap-interface:invalidstateerror-6" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-imagebitmap-interface:domexception-9"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> and abort
       these steps.</p></li><li><p>Apply the <a href="https://mimesniff.spec.whatwg.org/#rules-for-sniffing-images-specifically" id="the-imagebitmap-interface:content-type-sniffing:-image" data-x-internal="content-type-sniffing:-image">image sniffing rules</a> to
       determine the file format of <var>imageData</var>, with MIME type of <var>image</var> (as
       given by <var>image</var>'s <code id="the-imagebitmap-interface:dom-blob-type"><a data-x-internal="dom-blob-type" href="https://w3c.github.io/FileAPI/#dfn-type">type</a></code> attribute) giving the
       official type.</p></li><li><p>If <var>imageData</var> is not in a supported image file format (e.g., it's not an
       image at all), or if <var>imageData</var> is corrupted in some fatal way such that the image
       dimensions cannot be obtained (e.g., a vector graphic with no natural size), then <a href="#queue-a-global-task" id="the-imagebitmap-interface:queue-a-global-task-5">queue
       a global task</a>, using the <a href="#bitmap-task-source" id="the-imagebitmap-interface:bitmap-task-source-5">bitmap task source</a>, to reject <var>promise</var>
       with an <a id="the-imagebitmap-interface:invalidstateerror-7" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="the-imagebitmap-interface:domexception-10"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> and abort
       these steps.</p></li><li><p>Set <var>imageBitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-13">bitmap
       data</a> to <var>imageData</var>, <a href="#cropped-to-the-source-rectangle-with-formatting" id="the-imagebitmap-interface:cropped-to-the-source-rectangle-with-formatting-4">cropped to the source rectangle with
       formatting</a>. If this is an animated image, <var>imageBitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-14">bitmap data</a> must only be taken from the
       default image of the animation (the one that the format defines is to be used when animation
       is not supported or is disabled), or, if there is no such image, the first frame of the
       animation.</p></li><li><p><a href="#queue-a-global-task" id="the-imagebitmap-interface:queue-a-global-task-6">Queue a global task</a>, using the <a href="#bitmap-task-source" id="the-imagebitmap-interface:bitmap-task-source-6">bitmap task source</a>, to
       resolve <var>promise</var> with <var>imageBitmap</var>.</p></li></ol>
     </dd><dt><code id="the-imagebitmap-interface:imagedata-4"><a href="#imagedata">ImageData</a></code>
     </dt><dd>
      <ol><li><p>Let <var>buffer</var> be <var>image</var>'s <code id="the-imagebitmap-interface:dom-imagedata-data-2"><a href="#dom-imagedata-data">data</a></code> attribute value's [[ViewedArrayBuffer]] internal
       slot.</p></li><li><p>If <a id="the-imagebitmap-interface:isdetachedbuffer" href="https://tc39.es/ecma262/#sec-isdetachedbuffer" data-x-internal="isdetachedbuffer">IsDetachedBuffer</a>(<var>buffer</var>) is true, then return <a id="the-imagebitmap-interface:a-promise-rejected-with-6" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a
       promise rejected with</a> an <a id="the-imagebitmap-interface:invalidstateerror-8" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
       <code id="the-imagebitmap-interface:domexception-11"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>imageBitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-15">bitmap
       data</a> to <var>image</var>'s image data, <a href="#cropped-to-the-source-rectangle-with-formatting" id="the-imagebitmap-interface:cropped-to-the-source-rectangle-with-formatting-5">cropped to the source rectangle with
       formatting</a>.</p></li><li><p><a href="#queue-a-global-task" id="the-imagebitmap-interface:queue-a-global-task-7">Queue a global task</a>, using the <a href="#bitmap-task-source" id="the-imagebitmap-interface:bitmap-task-source-7">bitmap task source</a>, to
       resolve <var>promise</var> with <var>imageBitmap</var>.</p></li></ol>
     </dd><dt><code id="the-imagebitmap-interface:imagebitmap-13"><a href="#imagebitmap">ImageBitmap</a></code>
     </dt><dd>
      <ol><li><p>Set <var>imageBitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-16">bitmap
       data</a> to a copy of <var>image</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-17">bitmap data</a>, <a href="#cropped-to-the-source-rectangle-with-formatting" id="the-imagebitmap-interface:cropped-to-the-source-rectangle-with-formatting-6">cropped to the source
       rectangle with formatting</a>.</p></li><li><p>Set the <a href="#concept-canvas-origin-clean" id="the-imagebitmap-interface:concept-canvas-origin-clean-8">origin-clean</a> flag of
       <var>imageBitmap</var>'s bitmap to the same value as the <a href="#concept-canvas-origin-clean" id="the-imagebitmap-interface:concept-canvas-origin-clean-9">origin-clean</a> flag of <var>image</var>'s
       bitmap.</p></li><li><p><a href="#queue-a-global-task" id="the-imagebitmap-interface:queue-a-global-task-8">Queue a global task</a>, using the <a href="#bitmap-task-source" id="the-imagebitmap-interface:bitmap-task-source-8">bitmap task source</a>, to
       resolve <var>promise</var> with <var>imageBitmap</var>.</p></li></ol>
     </dd><dt><code id="the-imagebitmap-interface:videoframe"><a data-x-internal="videoframe" href="https://w3c.github.io/webcodecs/#videoframe-interface">VideoFrame</a></code>
     </dt><dd>
      <ol><li><p>Set <var>imageBitmap</var>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-18">bitmap
       data</a> to a copy of <var>image</var>'s visible pixel data, <a href="#cropped-to-the-source-rectangle-with-formatting" id="the-imagebitmap-interface:cropped-to-the-source-rectangle-with-formatting-7">cropped to the source
       rectangle with formatting</a>.</p></li><li><p><a href="#queue-a-global-task" id="the-imagebitmap-interface:queue-a-global-task-9">Queue a global task</a>, using the <a href="#bitmap-task-source" id="the-imagebitmap-interface:bitmap-task-source-9">bitmap task source</a>, to
       resolve <var>promise</var> with <var>imageBitmap</var>.</p></li></ol>
     </dd></dl>
   </li><li><p>Return <var>promise</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the steps above require that the user agent <dfn id="cropped-to-the-source-rectangle-with-formatting">crop bitmap data to the source rectangle with formatting</dfn>,
  the user agent must run the following steps:</p>

  <ol><li><p>Let <var>input</var> be the <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-19">bitmap
   data</a> being transformed.</p></li><li>
    <p>If <var>sx</var>, <var>sy</var>, <var>sw</var> and <var>sh</var> are specified, let
    <var>sourceRectangle</var> be a rectangle whose corners are the four points (<var>sx</var>,
    <var>sy</var>), (<var>sx</var>+<var>sw</var>, <var>sy</var>), (<var>sx</var>+<var>sw</var>,
    <var>sy</var>+<var>sh</var>), (<var>sx</var>, <var>sy</var>+<var>sh</var>). Otherwise, let
    <var>sourceRectangle</var> be a rectangle whose corners are the four points (0, 0), (width of
    <var>input</var>, 0), (width of <var>input</var>, height of <var>input</var>), (0, height of
    <var>input</var>).</p>

    <p class="note">If either <var>sw</var> or <var>sh</var> are negative, then
    the top-left corner of this rectangle will be to the left or above the (<var>sx</var>,
    <var>sy</var>) point.</p>
   </li><li>
    <p>Let <var>outputWidth</var> be determined as follows:</p>

    <dl class="switch"><dt>If the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth-4"><a href="#dom-imagebitmapoptions-resizewidth">resizeWidth</a></code> member of
     <var>options</var> is specified</dt><dd>the value of the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth-5"><a href="#dom-imagebitmapoptions-resizewidth">resizeWidth</a></code>
     member of <var>options</var></dd><dt>If the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth-6"><a href="#dom-imagebitmapoptions-resizewidth">resizeWidth</a></code> member of
     <var>options</var> is not specified, but the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight-4"><a href="#dom-imagebitmapoptions-resizeheight">resizeHeight</a></code> member is specified</dt><dd>the width of <var>sourceRectangle</var>, times the value of the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight-5"><a href="#dom-imagebitmapoptions-resizeheight">resizeHeight</a></code> member of <var>options</var>,
     divided by the height of <var>sourceRectangle</var>, rounded up to the nearest integer</dd><dt>If neither <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth-7"><a href="#dom-imagebitmapoptions-resizewidth">resizeWidth</a></code> nor <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight-6"><a href="#dom-imagebitmapoptions-resizeheight">resizeHeight</a></code> are specified</dt><dd>the width of <var>sourceRectangle</var></dd></dl>
   </li><li>
    <p>Let <var>outputHeight</var> be determined as follows:</p>

    <dl class="switch"><dt>If the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight-7"><a href="#dom-imagebitmapoptions-resizeheight">resizeHeight</a></code> member of
     <var>options</var> is specified</dt><dd>the value of the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight-8"><a href="#dom-imagebitmapoptions-resizeheight">resizeHeight</a></code>
     member of <var>options</var></dd><dt>If the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight-9"><a href="#dom-imagebitmapoptions-resizeheight">resizeHeight</a></code> member of
     <var>options</var> is not specified, but the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth-8"><a href="#dom-imagebitmapoptions-resizewidth">resizeWidth</a></code> member is specified</dt><dd>the height of <var>sourceRectangle</var>, times the value of the <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth-9"><a href="#dom-imagebitmapoptions-resizewidth">resizeWidth</a></code> member of <var>options</var>,
     divided by the width of <var>sourceRectangle</var>, rounded up to the nearest integer</dd><dt>If neither <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizewidth-10"><a href="#dom-imagebitmapoptions-resizewidth">resizeWidth</a></code> nor <code id="the-imagebitmap-interface:dom-imagebitmapoptions-resizeheight-10"><a href="#dom-imagebitmapoptions-resizeheight">resizeHeight</a></code> are specified</dt><dd>the height of <var>sourceRectangle</var></dd></dl>
   </li><li><p>Place <var>input</var> on an infinite <a id="the-imagebitmap-interface:transparent-black-2" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> grid plane,
   positioned so that its top left corner is at the origin of the plane, with the
   <var>x</var>-coordinate increasing to the right, and the <var>y</var>-coordinate increasing down,
   and with each pixel in the <var>input</var> image data occupying a cell on the plane's
   grid.</p></li><li><p>Let <var>output</var> be the rectangle on the plane denoted by
   <var>sourceRectangle</var>.</p></li><li><p>Scale <var>output</var> to the size specified by <var>outputWidth</var> and
   <var>outputHeight</var>. The user agent should use the value of the <dfn data-dfn-for="ImageBitmapOptions" id="dom-imagebitmapoptions-resizequality" data-dfn-type="dict-member"><code>resizeQuality</code></dfn> option to guide the
   choice of scaling algorithm.</p></li><li>
    <p>If the value of the <dfn data-dfn-for="ImageBitmapOptions" id="dom-imagebitmapoptions-imageorientation" data-dfn-type="dict-member"><code>imageOrientation</code></dfn> member of
    <var>options</var> is "<dfn data-dfn-for="ImageOrientation" id="dom-imageorientation-flipy" data-dfn-type="enum-value"><code>flipY</code></dfn>", <var>output</var> must be flipped
    vertically, disregarding any image orientation metadata of the source (such as EXIF metadata),
    if any. <a href="#refsEXIF">[EXIF]</a></p>

    <p class="note">If the value is "<dfn data-dfn-for="ImageOrientation" id="dom-imageorientation-from-image" data-dfn-type="enum-value"><code>from-image</code></dfn>", no extra step is needed.</p>

    <p class="note">There used to be a "<dfn id="dom-imagebitmapoptions-imageorientation-none"><code>none</code></dfn>" enum value. It was
    renamed to "<code id="the-imagebitmap-interface:dom-imageorientation-from-image-3"><a href="#dom-imageorientation-from-image">from-image</a></code>". In the future,
    "<code id="the-imagebitmap-interface:dom-imagebitmapoptions-imageorientation-none"><a href="#dom-imagebitmapoptions-imageorientation-none">none</a></code>" will be added back
    with a different meaning.</p>
   </li><li>
    <p>If <var>image</var> is an <code id="the-imagebitmap-interface:the-img-element-4"><a href="#the-img-element">img</a></code> element or a <code id="the-imagebitmap-interface:blob-5"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code> object, let
    <var>val</var> be the value of the <dfn data-dfn-for="ImageBitmapOptions" id="dom-imagebitmapoptions-colorspaceconversion" data-dfn-type="dict-member"><code>colorSpaceConversion</code></dfn> member
    of <var>options</var>, and then run these substeps:</p>

    <ol><li><p>If <var>val</var> is "<dfn data-dfn-for="ColorSpaceConversion" id="dom-colorspaceconversion-default" data-dfn-type="enum-value"><code>default</code></dfn>",
     the color space conversion behavior is implementation-specific, and should be chosen according
     to the default color space that the implementation uses for drawing images onto the canvas.</p>
     </li><li><p>If <var>val</var> is "<dfn data-dfn-for="ColorSpaceConversion" id="dom-colorspaceconversion-none" data-dfn-type="enum-value"><code>none</code></dfn>", <var>output</var> must be decoded
     without performing any color space conversions. This means that the image decoding algorithm
     must ignore color profile metadata embedded in the source data as well as the display device
     color profile.</p></li></ol>
   </li><li>
    <p>Let <var>val</var> be the value of <dfn data-dfn-for="ImageBitmapOptions" id="dom-imagebitmapoptions-premultiplyalpha" data-dfn-type="dict-member"><code>premultiplyAlpha</code></dfn> member of
    <var>options</var>, and then run these substeps:</p>

    <ol><li><p>If <var>val</var> is "<dfn data-dfn-for="PremultiplyAlpha" id="dom-premultiplyalpha-default" data-dfn-type="enum-value"><code>default</code></dfn>", the alpha premultiplication
     behavior is implementation-specific, and should be chosen according to implementation deems
     optimal for drawing images onto the canvas.</p></li><li><p>If <var>val</var> is "<dfn data-dfn-for="PremultiplyAlpha" id="dom-premultiplyalpha-premultiply" data-dfn-type="enum-value"><code>premultiply</code></dfn>", the <var>output</var> that
     is not premultiplied by alpha must have its color components <a href="#convert-to-premultiplied" id="the-imagebitmap-interface:convert-to-premultiplied">multiplied by alpha</a> and that is premultiplied by alpha
     must be left untouched.</p></li><li><p>If <var>val</var> is "<dfn data-dfn-for="PremultiplyAlpha" id="dom-premultiplyalpha-none" data-dfn-type="enum-value"><code>none</code></dfn>", the <var>output</var> that is not
     premultiplied by alpha must be left untouched and that is premultiplied by alpha must have its
     color components <a href="#convert-from-premultiplied" id="the-imagebitmap-interface:convert-from-premultiplied">divided by alpha</a>.</p></li></ol>
   </li><li><p>Return <var>output</var>.</p></li></ol>
  </div>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ImageBitmap" id="dom-imagebitmap-close" data-dfn-type="method"><code>close()</code></dfn>
  method steps are:</p>

  <ol><li><p>Set <a id="the-imagebitmap-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#detached" id="the-imagebitmap-interface:detached-3">[[Detached]]</a> internal slot value to true.</p></li><li><p>Unset <a id="the-imagebitmap-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-imagebitmap-bitmap-data" id="the-imagebitmap-interface:concept-imagebitmap-bitmap-data-20">bitmap
   data</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ImageBitmap" id="dom-imagebitmap-width" data-dfn-type="attribute"><code>width</code></dfn>
  getter steps are:</p>

  <ol><li><p>If <a id="the-imagebitmap-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#detached" id="the-imagebitmap-interface:detached-4">[[Detached]]</a> internal slot's value is true, then
   return 0.</p></li><li><p>Return <a id="the-imagebitmap-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s width, in <a href="https://drafts.csswg.org/css-values/#px" id="the-imagebitmap-interface:'px'-4" data-x-internal="'px'">CSS pixels</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="ImageBitmap" id="dom-imagebitmap-height" data-dfn-type="attribute"><code>height</code></dfn>
  getter steps are:</p>

  <ol><li><p>If <a id="the-imagebitmap-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#detached" id="the-imagebitmap-interface:detached-5">[[Detached]]</a> internal slot's value is true, then
   return 0.</p></li><li><p>Return <a id="the-imagebitmap-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s height, in <a href="https://drafts.csswg.org/css-values/#px" id="the-imagebitmap-interface:'px'-5" data-x-internal="'px'">CSS pixels</a>.</p></li></ol>
  </div>

  <p>The <code id="the-imagebitmap-interface:resizequality-2"><a href="#resizequality">ResizeQuality</a></code> enumeration is used to express a preference for the
  interpolation quality to use when scaling images.</p>

  <p>The "<dfn data-dfn-for="ResizeQuality" id="dom-resizequality-pixelated" data-dfn-type="enum-value"><code>pixelated</code></dfn>" value indicates a preference for
  scaling the image to preserve the pixelation of the original as much as possible, with minor
  smoothing as necessary to avoid distorting the image when the target size is not a clean multiple
  of the original.</p>

  <p>To implement "<code id="the-imagebitmap-interface:dom-resizequality-pixelated-2"><a href="#dom-resizequality-pixelated">pixelated</a></code>", for each axis
  independently, first determine the integer multiple of its natural size that puts it closest to
  the target size and is greater than zero. Scale it to this integer-multiple-size using nearest
  neighbor, then scale it the rest of the way to the target size using bilinear interpolation.</p>

  <p>The "<dfn data-dfn-for="ResizeQuality" id="dom-resizequality-low" data-dfn-type="enum-value"><code>low</code></dfn>"
  value indicates a preference for a low level of image interpolation quality. Low-quality image
  interpolation may be more computationally efficient than higher settings.</p>

  <p>The "<dfn data-dfn-for="ResizeQuality" id="dom-resizequality-medium" data-dfn-type="enum-value"><code>medium</code></dfn>" value indicates a preference for a medium
  level of image interpolation quality.</p>

  <p>The "<dfn data-dfn-for="ResizeQuality" id="dom-resizequality-high" data-dfn-type="enum-value"><code>high</code></dfn>" value indicates a preference for a high level
  of image interpolation quality. High-quality image interpolation may be more computationally
  expensive than lower settings.</p>

  <p class="note">Bilinear scaling is an example of a relatively fast, lower-quality image-smoothing
  algorithm. Bicubic or Lanczos scaling are examples of image-scaling algorithms that produce
  higher-quality output. This specification does not mandate that specific interpolation algorithms
  be used, except for "<code id="the-imagebitmap-interface:dom-resizequality-pixelated-3"><a href="#dom-resizequality-pixelated">pixelated</a></code>" as described
  above.</p>

  

  <div class="example">

   <p>Using this API, a sprite sheet can be precut and prepared:</p>

   <pre><code class="js"><c- a="">var</c-> sprites <c- o="">=</c-> <c- p="">{};</c->
<c- a="">function</c-> loadMySprites<c- p="">()</c-> <c- p="">{</c->
  <c- a="">var</c-> image <c- o="">=</c-> <c- k="">new</c-> Image<c- p="">();</c->
  image<c- p="">.</c->src <c- o="">=</c-> <c- t="">'mysprites.png'</c-><c- p="">;</c->
  <c- a="">var</c-> resolver<c- p="">;</c->
  <c- a="">var</c-> promise <c- o="">=</c-> <c- k="">new</c-> Promise<c- p="">(</c-><c- a="">function</c-> <c- p="">(</c->arg<c- p="">)</c-> <c- p="">{</c-> resolver <c- o="">=</c-> arg <c- p="">});</c->
  image<c- p="">.</c->onload <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
    resolver<c- p="">(</c->Promise<c- p="">.</c->all<c- p="">([</c->
      createImageBitmap<c- p="">(</c->image<c- p="">,</c->  <c- mf="">0</c-><c- p="">,</c->  <c- mf="">0</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">).</c->then<c- p="">(</c-><c- a="">function</c-> <c- p="">(</c->image<c- p="">)</c-> <c- p="">{</c-> sprites<c- p="">.</c->person <c- o="">=</c-> image <c- p="">}),</c->
      createImageBitmap<c- p="">(</c->image<c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c->  <c- mf="">0</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">).</c->then<c- p="">(</c-><c- a="">function</c-> <c- p="">(</c->image<c- p="">)</c-> <c- p="">{</c-> sprites<c- p="">.</c->grass  <c- o="">=</c-> image <c- p="">}),</c->
      createImageBitmap<c- p="">(</c->image<c- p="">,</c-> <c- mf="">80</c-><c- p="">,</c->  <c- mf="">0</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">).</c->then<c- p="">(</c-><c- a="">function</c-> <c- p="">(</c->image<c- p="">)</c-> <c- p="">{</c-> sprites<c- p="">.</c->tree   <c- o="">=</c-> image <c- p="">}),</c->
      createImageBitmap<c- p="">(</c->image<c- p="">,</c->  <c- mf="">0</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">).</c->then<c- p="">(</c-><c- a="">function</c-> <c- p="">(</c->image<c- p="">)</c-> <c- p="">{</c-> sprites<c- p="">.</c->hut    <c- o="">=</c-> image <c- p="">}),</c->
      createImageBitmap<c- p="">(</c->image<c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">).</c->then<c- p="">(</c-><c- a="">function</c-> <c- p="">(</c->image<c- p="">)</c-> <c- p="">{</c-> sprites<c- p="">.</c->apple  <c- o="">=</c-> image <c- p="">}),</c->
      createImageBitmap<c- p="">(</c->image<c- p="">,</c-> <c- mf="">80</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">,</c-> <c- mf="">40</c-><c- p="">).</c->then<c- p="">(</c-><c- a="">function</c-> <c- p="">(</c->image<c- p="">)</c-> <c- p="">{</c-> sprites<c- p="">.</c->snake  <c- o="">=</c-> image <c- p="">})</c->
    <c- p="">]));</c->
  <c- p="">};</c->
  <c- k="">return</c-> promise<c- p="">;</c->
<c- p="">}</c->

<c- a="">function</c-> runDemo<c- p="">()</c-> <c- p="">{</c->
  <c- a="">var</c-> canvas <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- t="">'canvas#demo'</c-><c- p="">);</c->
  <c- a="">var</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">);</c->
  context<c- p="">.</c->drawImage<c- p="">(</c->sprites<c- p="">.</c->tree<c- p="">,</c-> <c- mf="">30</c-><c- p="">,</c-> <c- mf="">10</c-><c- p="">);</c->
  context<c- p="">.</c->drawImage<c- p="">(</c->sprites<c- p="">.</c->snake<c- p="">,</c-> <c- mf="">70</c-><c- p="">,</c-> <c- mf="">10</c-><c- p="">);</c->
<c- p="">}</c->

loadMySprites<c- p="">().</c->then<c- p="">(</c->runDemo<c- p="">);</c-></code></pre>

  </div>



  <h3 id="animation-frames"><span class="secno">8.11</span> Animation frames<a href="#animation-frames" class="self-link"></a></h3>

  <p>Some objects include the <code id="animation-frames:animationframeprovider"><a href="#animationframeprovider">AnimationFrameProvider</a></code> interface mixin.</p>

  <pre><code class="idl"><c- b="">callback</c-> <dfn id="framerequestcallback" data-dfn-type="callback"><c- g="">FrameRequestCallback</c-></dfn> = <c- b="">undefined</c-> (<a id="animation-frames:domhighrestimestamp" href="https://w3c.github.io/hr-time/#dom-domhighrestimestamp" data-x-internal="domhighrestimestamp"><c- n="">DOMHighResTimeStamp</c-></a> <c- g="">time</c->);

<c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="animationframeprovider" data-dfn-type="interface"><c- g="">AnimationFrameProvider</c-></dfn> {
  <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-animationframeprovider-requestanimationframe" id="animation-frames:dom-animationframeprovider-requestanimationframe"><c- g="">requestAnimationFrame</c-></a>(<a href="#framerequestcallback" id="animation-frames:framerequestcallback"><c- n="">FrameRequestCallback</c-></a> <c- g="">callback</c->);
  <c- b="">undefined</c-> <a href="#animationframeprovider-cancelanimationframe" id="animation-frames:animationframeprovider-cancelanimationframe"><c- g="">cancelAnimationFrame</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">handle</c->);
};
<a href="#window" id="animation-frames:window"><c- n="">Window</c-></a> <c- b="">includes</c-> <a href="#animationframeprovider" id="animation-frames:animationframeprovider-2"><c- n="">AnimationFrameProvider</c-></a>;
<a href="#dedicatedworkerglobalscope" id="animation-frames:dedicatedworkerglobalscope"><c- n="">DedicatedWorkerGlobalScope</c-></a> <c- b="">includes</c-> <a href="#animationframeprovider" id="animation-frames:animationframeprovider-3"><c- n="">AnimationFrameProvider</c-></a>;</code></pre>

  <div data-algorithm="">
  <p>Each <code id="animation-frames:animationframeprovider-4"><a href="#animationframeprovider">AnimationFrameProvider</a></code> object also has a <dfn id="concept-animationframeprovider-target-object">target object</dfn> that stores the
  provider's internal state. It is defined as follows:</p>

  <dl><dt>If the <code id="animation-frames:animationframeprovider-5"><a href="#animationframeprovider">AnimationFrameProvider</a></code> is a <code id="animation-frames:window-2"><a href="#window">Window</a></code></dt><dd>The <code id="animation-frames:window-3"><a href="#window">Window</a></code>'s <a href="#concept-document-window" id="animation-frames:concept-document-window">associated
   <code>Document</code></a></dd><dt>If the <code id="animation-frames:animationframeprovider-6"><a href="#animationframeprovider">AnimationFrameProvider</a></code> is a <code id="animation-frames:dedicatedworkerglobalscope-2"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code></dt><dd>The <code id="animation-frames:dedicatedworkerglobalscope-3"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code></dd></dl>
  </div>

  <p>Each <a href="#concept-animationframeprovider-target-object" id="animation-frames:concept-animationframeprovider-target-object">target object</a> has a
  <dfn id="list-of-animation-frame-callbacks">map of animation frame callbacks</dfn>, which is an
  <a id="animation-frames:ordered-map" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> that must be initially empty, and an <dfn id="animation-frame-callback-identifier">animation frame callback
  identifier</dfn>, which is a number that must initially be zero.</p>

  <div data-algorithm="">
  <p>An <code id="animation-frames:animationframeprovider-7"><a href="#animationframeprovider">AnimationFrameProvider</a></code> <var>provider</var> is considered <dfn id="concept-animationframeprovider-supported">supported</dfn> if any of the following are
  true:</p>

  <ul><li><p><var>provider</var> is a <code id="animation-frames:window-4"><a href="#window">Window</a></code>.</p></li><li><p><var>provider</var>'s <a href="#concept-WorkerGlobalScope-owner-set" id="animation-frames:concept-WorkerGlobalScope-owner-set">owner set</a> <a href="https://infra.spec.whatwg.org/#list-contain" id="animation-frames:list-contains" data-x-internal="list-contains">contains</a>
   a <code id="animation-frames:document"><a href="#document">Document</a></code> object.</p></li><li><p>Any of the <code id="animation-frames:dedicatedworkerglobalscope-4"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> objects in <var>provider</var>'s
   <a href="#concept-WorkerGlobalScope-owner-set" id="animation-frames:concept-WorkerGlobalScope-owner-set-2">owner set</a> are <a href="#concept-animationframeprovider-supported" id="animation-frames:concept-animationframeprovider-supported">supported</a>.</p></li></ul>
  </div>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame" title="The window.requestAnimationFrame() method tells the browser that you wish to perform an animation and requests that the browser calls a specified function to update an animation right before the next repaint. The method takes a callback as an argument to be invoked before the repaint.">Window/requestAnimationFrame</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>23+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>24+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>23+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4.4+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="AnimationFrameProvider" id="dom-animationframeprovider-requestanimationframe" data-dfn-type="method"><code>requestAnimationFrame(<var>callback</var>)</code></dfn>
  method steps are:</p>

  <ol><li><p>If <a id="animation-frames:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is not <a href="#concept-animationframeprovider-supported" id="animation-frames:concept-animationframeprovider-supported-2">supported</a>, then throw a
   <a id="animation-frames:notsupportederror" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="animation-frames:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>target</var> be <a id="animation-frames:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-animationframeprovider-target-object" id="animation-frames:concept-animationframeprovider-target-object-2">target object</a>.</p></li><li><p>Increment <var>target</var>'s <a href="#animation-frame-callback-identifier" id="animation-frames:animation-frame-callback-identifier">animation frame callback identifier</a> by one,
   and let <var>handle</var> be the result.</p></li><li><p>Let <var>callbacks</var> be <var>target</var>'s <a href="#list-of-animation-frame-callbacks" id="animation-frames:list-of-animation-frame-callbacks">map of animation frame
   callbacks</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="animation-frames:map-set" data-x-internal="map-set">Set</a> <var>callbacks</var>[<var>handle</var>] to
   <var>callback</var>.</p></li><li><p>Return <var>handle</var>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/cancelAnimationFrame" title="The window.cancelAnimationFrame() method cancels an animation frame request previously scheduled through a call to window.requestAnimationFrame().">Window/cancelAnimationFrame</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>23+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>24+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="AnimationFrameProvider" id="animationframeprovider-cancelanimationframe" data-dfn-type="method"><code>cancelAnimationFrame(<var>handle</var>)</code></dfn>
  method steps are:</p>

  <ol><li><p>If <a id="animation-frames:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is not <a href="#concept-animationframeprovider-supported" id="animation-frames:concept-animationframeprovider-supported-3">supported</a>, then throw a
   <a id="animation-frames:notsupportederror-2" href="https://webidl.spec.whatwg.org/#notsupportederror" data-x-internal="notsupportederror">"<code>NotSupportedError</code>"</a> <code id="animation-frames:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>callbacks</var> be <a id="animation-frames:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-animationframeprovider-target-object" id="animation-frames:concept-animationframeprovider-target-object-3">target object</a>'s <a href="#list-of-animation-frame-callbacks" id="animation-frames:list-of-animation-frame-callbacks-2">map of
   animation frame callbacks</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="animation-frames:map-remove" data-x-internal="map-remove">Remove</a> <var>callbacks</var>[<var>handle</var>].</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="run-the-animation-frame-callbacks">run the animation frame callbacks</dfn> for a <a href="#concept-animationframeprovider-target-object" id="animation-frames:concept-animationframeprovider-target-object-4">target object</a> <var>target</var> with
  a timestamp <var>now</var>:</p>

  <ol><li><p>Let <var>callbacks</var> be <var>target</var>'s <a href="#list-of-animation-frame-callbacks" id="animation-frames:list-of-animation-frame-callbacks-3">map of animation frame
   callbacks</a>.</p></li><li><p>Let <var>callbackHandles</var> be the result of <a href="https://infra.spec.whatwg.org/#map-getting-the-keys" id="animation-frames:map-get-the-keys" data-x-internal="map-get-the-keys">getting
   the keys</a> of <var>callbacks</var>.</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="animation-frames:list-iterate" data-x-internal="list-iterate">For each</a> <var>handle</var> in
    <var>callbackHandles</var>, if <var>handle</var> <a href="https://infra.spec.whatwg.org/#map-exists" id="animation-frames:map-exists" data-x-internal="map-exists">exists</a> in
    <var>callbacks</var>:</p>

    <ol><li><p>Let <var>callback</var> be <var>callbacks</var>[<var>handle</var>].</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="animation-frames:map-remove-2" data-x-internal="map-remove">Remove</a>
     <var>callbacks</var>[<var>handle</var>].</p></li><li><p><a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="animation-frames:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">Invoke</a> <var>callback</var> with «
     <var>now</var> » and "<code>report</code>".</p></li></ol>
   </li></ol>
  </div>

  <div class="example">
   <p>Inside workers, <code id="animation-frames:dom-animationframeprovider-requestanimationframe-2"><a href="#dom-animationframeprovider-requestanimationframe">requestAnimationFrame()</a></code> can be
   used together with an <code id="animation-frames:offscreencanvas"><a href="#offscreencanvas">OffscreenCanvas</a></code> transferred from a <code id="animation-frames:the-canvas-element"><a href="#the-canvas-element">canvas</a></code>
   element. First, in the document, transfer control to the worker:</p>

   <pre><code class="js"><c- a="">const</c-> offscreenCanvas <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- u="">"c"</c-><c- p="">).</c->transferControlToOffscreen<c- p="">();</c->
worker<c- p="">.</c->postMessage<c- p="">(</c->offscreenCanvas<c- p="">,</c-> <c- p="">[</c->offscreenCanvas<c- p="">]);</c-></code></pre>

   <p>Then, in the worker, the following code will draw a rectangle moving from left to right:</p>

   <pre><code class="js"><c- a="">let</c-> ctx<c- p="">,</c-> pos <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
<c- a="">function</c-> draw<c- p="">(</c->dt<c- p="">)</c-> <c- p="">{</c->
  ctx<c- p="">.</c->clearRect<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">100</c-><c- p="">,</c-> <c- mf="">100</c-><c- p="">);</c->
  ctx<c- p="">.</c->fillRect<c- p="">(</c->pos<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">10</c-><c- p="">,</c-> <c- mf="">10</c-><c- p="">);</c->
  pos <c- o="">+=</c-> <c- mf="">10</c-> <c- o="">*</c-> dt<c- p="">;</c->
  requestAnimationFrame<c- p="">(</c->draw<c- p="">);</c->
<c- p="">}</c->

self<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->ev<c- p="">)</c-> <c- p="">{</c->
  <c- a="">const</c-> transferredCanvas <c- o="">=</c-> ev<c- p="">.</c->data<c- p="">;</c->
  ctx <c- o="">=</c-> transferredCanvas<c- p="">.</c->getContext<c- p="">(</c-><c- u="">"2d"</c-><c- p="">);</c->
  draw<c- p="">();</c->
<c- p="">};</c-></code></pre>
  </div>

  <h2 id="comms"><span class="secno">9</span> Communication<a href="#comms" class="self-link"></a></h2>

  <p id="network" class="note"><a href="#network" class="self-link"></a><span id="network-intro"></span><span id="the-websocket-interface"></span><span id="feedback-from-the-protocol"></span><span id="ping-and-pong-frames"></span><span id="the-closeevent-interface"></span><span id="garbage-collection-2"></span><span id="websocket"></span><span id="binarytype"></span><span id="closeevent"></span><span id="closeeventinit"></span>The <code id="comms:websocket-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code> interface used
  to be defined here. It is now defined in <cite>WebSockets</cite>. <a href="#refsWEBSOCKETS">[WEBSOCKETS]</a></p>

  <h3 id="the-messageevent-interface"><span class="secno">9.1</span> The <code id="the-messageevent-interface:messageevent"><a href="#messageevent">MessageEvent</a></code> interface<a href="#the-messageevent-interface" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent" title="The MessageEvent interface represents a message received by a target object.">MessageEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <p>Messages in <a href="#server-sent-events" id="the-messageevent-interface:server-sent-events">server-sent events</a>, <a href="#web-messaging" id="the-messageevent-interface:web-messaging">cross-document messaging</a>,
  <a href="#channel-messaging" id="the-messageevent-interface:channel-messaging">channel messaging</a>, <a href="#broadcasting-to-other-browsing-contexts" id="the-messageevent-interface:broadcasting-to-other-browsing-contexts">broadcast channels</a>, and <cite>WebSockets</cite> use
  the <code id="the-messageevent-interface:messageevent-2"><a href="#messageevent">MessageEvent</a></code> interface for their <code id="the-messageevent-interface:event-message"><a href="#event-message">message</a></code>
  events: <a href="#refsWEBSOCKETS">[WEBSOCKETS]</a></p>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->,<c- n="">AudioWorklet</c->)]
<c- b="">interface</c-> <dfn id="messageevent" data-dfn-type="interface"><c- g="">MessageEvent</c-></dfn> : <a id="the-messageevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <a href="https://dom.spec.whatwg.org/#concept-event-constructor" id="the-messageevent-interface:dom-event-constructor" data-x-internal="dom-event-constructor"><c- g="">constructor</c-></a>(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#messageeventinit" id="the-messageevent-interface:messageeventinit"><c- n="">MessageEventInit</c-></a> <c- g="">eventInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">any</c-> <a href="#dom-messageevent-data" id="the-messageevent-interface:dom-messageevent-data"><c- g="">data</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-messageevent-origin" id="the-messageevent-interface:dom-messageevent-origin"><c- g="">origin</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-messageevent-lasteventid" id="the-messageevent-interface:dom-messageevent-lasteventid"><c- g="">lastEventId</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#messageeventsource" id="the-messageevent-interface:messageeventsource"><c- n="">MessageEventSource</c-></a>? <a href="#dom-messageevent-source" id="the-messageevent-interface:dom-messageevent-source"><c- g="">source</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">FrozenArray</c->&lt;<a href="#messageport" id="the-messageevent-interface:messageport"><c- n="">MessagePort</c-></a>&gt; <a href="#dom-messageevent-ports" id="the-messageevent-interface:dom-messageevent-ports"><c- g="">ports</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-messageevent-initmessageevent" id="the-messageevent-interface:dom-messageevent-initmessageevent"><c- g="">initMessageEvent</c-></a>(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <c- b="">boolean</c-> <c- g="">bubbles</c-> = <c- b="">false</c->, <c- b="">optional</c-> <c- b="">boolean</c-> <c- g="">cancelable</c-> = <c- b="">false</c->, <c- b="">optional</c-> <c- b="">any</c-> <c- g="">data</c-> = <c- b="">null</c->, <c- b="">optional</c-> <c- b="">USVString</c-> <c- g="">origin</c-> = "", <c- b="">optional</c-> <c- b="">DOMString</c-> <c- g="">lastEventId</c-> = "", <c- b="">optional</c-> <a href="#messageeventsource" id="the-messageevent-interface:messageeventsource-2"><c- n="">MessageEventSource</c-></a>? <c- g="">source</c-> = <c- b="">null</c->, <c- b="">optional</c-> <c- b="">sequence</c->&lt;<a href="#messageport" id="the-messageevent-interface:messageport-2"><c- n="">MessagePort</c-></a>&gt; <c- g="">ports</c-> = []);
};

<c- b="">dictionary</c-> <dfn id="messageeventinit" data-dfn-type="dictionary"><c- g="">MessageEventInit</c-></dfn> : <a id="the-messageevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- b="">any</c-> <dfn data-dfn-for="MessageEventInit" id="dom-messageeventinit-data" data-dfn-type="dict-member"><c- g="">data</c-></dfn> = <c- b="">null</c->;
  <c- b="">USVString</c-> <dfn data-dfn-for="MessageEventInit" id="dom-messageeventinit-origin" data-dfn-type="dict-member"><c- g="">origin</c-></dfn> = "";
  <c- b="">DOMString</c-> <dfn data-dfn-for="MessageEventInit" id="dom-messageeventinit-lasteventid" data-dfn-type="dict-member"><c- g="">lastEventId</c-></dfn> = "";
  <a href="#messageeventsource" id="the-messageevent-interface:messageeventsource-3"><c- n="">MessageEventSource</c-></a>? <dfn data-dfn-for="MessageEventInit" id="dom-messageeventinit-source" data-dfn-type="dict-member"><c- g="">source</c-></dfn> = <c- b="">null</c->;
  <c- b="">sequence</c->&lt;<a href="#messageport" id="the-messageevent-interface:messageport-3"><c- n="">MessagePort</c-></a>&gt; <dfn data-dfn-for="MessageEventInit" id="dom-messageeventinit-ports" data-dfn-type="dict-member"><c- g="">ports</c-></dfn> = [];
};

<c- b="">typedef</c-> (<a href="#windowproxy" id="the-messageevent-interface:windowproxy"><c- n="">WindowProxy</c-></a> <c- b="">or</c-> <a href="#messageport" id="the-messageevent-interface:messageport-4"><c- n="">MessagePort</c-></a> <c- b="">or</c-> <a id="the-messageevent-interface:serviceworker" href="https://w3c.github.io/ServiceWorker/#serviceworker" data-x-internal="serviceworker"><c- n="">ServiceWorker</c-></a>) <dfn id="messageeventsource" data-dfn-type="typedef"><c- g="">MessageEventSource</c-></dfn>;</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-messageevent-data" id="dom-messageevent-data-dev">data</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data" title="The data read-only property of the MessageEvent interface represents the data sent by the message emitter.">MessageEvent/data</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd><p>Returns the data of the message.</p></dd><dt><code><var>event</var>.<a href="#dom-messageevent-origin" id="dom-messageevent-origin-dev">origin</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/origin" title="The origin read-only property of the MessageEvent interface is a string representing the origin of the message emitter.">MessageEvent/origin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the origin of the message, for <a href="#server-sent-events" id="the-messageevent-interface:server-sent-events-2">server-sent events</a> and
    <a href="#web-messaging" id="the-messageevent-interface:web-messaging-2">cross-document messaging</a>.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-messageevent-lasteventid" id="dom-messageevent-lasteventid-dev">lastEventId</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/lastEventId" title="The lastEventId read-only property of the MessageEvent interface is a string representing a unique ID for the event.">MessageEvent/lastEventId</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <a href="#concept-event-stream-last-event-id" id="the-messageevent-interface:concept-event-stream-last-event-id">last event ID string</a>,
    for <a href="#server-sent-events" id="the-messageevent-interface:server-sent-events-3">server-sent events</a>.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-messageevent-source" id="dom-messageevent-source-dev">source</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/source" title="The source read-only property of the MessageEvent interface is a MessageEventSource (which can be a WindowProxy, MessagePort, or ServiceWorker object) representing the message emitter.">MessageEvent/source</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-messageevent-interface:windowproxy-2"><a href="#windowproxy">WindowProxy</a></code> of the source window, for <a href="#web-messaging" id="the-messageevent-interface:web-messaging-3">cross-document
    messaging</a>, and the <code id="the-messageevent-interface:messageport-5"><a href="#messageport">MessagePort</a></code> being attached, in the <code id="the-messageevent-interface:event-workerglobalscope-connect"><a href="#event-workerglobalscope-connect">connect</a></code> event fired at
    <code id="the-messageevent-interface:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> objects.</p>
   </dd><dt><code><var>event</var>.<a href="#dom-messageevent-ports" id="dom-messageevent-ports-dev">ports</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/ports" title="The ports read-only property of the MessageEvent interface is an array of MessagePort objects representing the ports associated with the channel the message is being sent through (where appropriate, e.g. in channel messaging or when sending a message to a shared worker).">MessageEvent/ports</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-messageevent-interface:messageport-6"><a href="#messageport">MessagePort</a></code> array sent with the message, for <a href="#web-messaging" id="the-messageevent-interface:web-messaging-4">cross-document
    messaging</a> and <a href="#channel-messaging" id="the-messageevent-interface:channel-messaging-2">channel messaging</a>.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessageEvent" id="dom-messageevent-data" data-dfn-type="attribute"><code>data</code></dfn>
  attribute must return the value it was initialized to. It represents the message being sent.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessageEvent" id="dom-messageevent-origin" data-dfn-type="attribute"><code>origin</code></dfn> attribute must return the value it was
  initialized to. It represents, in <a href="#server-sent-events" id="the-messageevent-interface:server-sent-events-4">server-sent events</a> and <a href="#web-messaging" id="the-messageevent-interface:web-messaging-5">cross-document
  messaging</a>, the <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-messageevent-interface:concept-document-origin" data-x-internal="concept-document-origin">origin</a> of the document that
  sent the message (typically the scheme, hostname, and port of the document, but not its path or
  <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="the-messageevent-interface:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a>).</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessageEvent" id="dom-messageevent-lasteventid" data-dfn-type="attribute"><code>lastEventId</code></dfn> attribute must return the value it
  was initialized to. It represents, in <a href="#server-sent-events" id="the-messageevent-interface:server-sent-events-5">server-sent events</a>, the <a href="#concept-event-stream-last-event-id" id="the-messageevent-interface:concept-event-stream-last-event-id-2">last event ID string</a> of the event source.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessageEvent" id="dom-messageevent-source" data-dfn-type="attribute"><code>source</code></dfn> attribute must return the value it was
  initialized to. It represents, in <a href="#web-messaging" id="the-messageevent-interface:web-messaging-6">cross-document messaging</a>, the
  <code id="the-messageevent-interface:windowproxy-3"><a href="#windowproxy">WindowProxy</a></code> of the <a href="#browsing-context" id="the-messageevent-interface:browsing-context">browsing context</a> of the <code id="the-messageevent-interface:window"><a href="#window">Window</a></code> object
  from which the message came; and in the <code id="the-messageevent-interface:event-workerglobalscope-connect-2"><a href="#event-workerglobalscope-connect">connect</a></code> events used by <a href="#sharedworkerglobalscope" id="the-messageevent-interface:sharedworkerglobalscope-2">shared workers</a>, the newly connecting
  <code id="the-messageevent-interface:messageport-7"><a href="#messageport">MessagePort</a></code>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessageEvent" id="dom-messageevent-ports" data-dfn-type="attribute"><code>ports</code></dfn>
  attribute must return the value it was initialized to. It represents, in <a href="#web-messaging" id="the-messageevent-interface:web-messaging-7">cross-document
  messaging</a> and <a href="#channel-messaging" id="the-messageevent-interface:channel-messaging-3">channel messaging</a>, the <code id="the-messageevent-interface:messageport-8"><a href="#messageport">MessagePort</a></code> array being
  sent.</p>
  </div>

  
  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessageEvent" id="dom-messageevent-initmessageevent" data-dfn-type="method"><code>initMessageEvent(<var>type</var>, <var>bubbles</var>,
  <var>cancelable</var>, <var>data</var>, <var>origin</var>, <var>lastEventId</var>,
  <var>source</var>, <var>ports</var>)</code></dfn> method must initialize the event in a manner
  analogous to the similarly-named <code id="the-messageevent-interface:dom-event-initevent"><a data-x-internal="dom-event-initevent" href="https://dom.spec.whatwg.org/#dom-event-initevent">initEvent()</a></code> method.
  <a href="#refsDOM">[DOM]</a></p>
  </div>

  

  <p class="note">Various APIs (e.g., <code id="the-messageevent-interface:websocket-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code>, <code id="the-messageevent-interface:eventsource"><a href="#eventsource">EventSource</a></code>) use the
  <code id="the-messageevent-interface:messageevent-3"><a href="#messageevent">MessageEvent</a></code> interface for their <code id="the-messageevent-interface:event-message-2"><a href="#event-message">message</a></code> event
  without using the <code id="the-messageevent-interface:messageport-9"><a href="#messageport">MessagePort</a></code> API.</p>


  <h3 id="server-sent-events"><span class="secno">9.2</span> <dfn>Server-sent events</dfn><a href="#server-sent-events" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events" title="Traditionally, a web page has to send a request to the server to receive new data; that is, the page requests data from the server. With server-sent events, it's possible for a server to send new data to a web page at any time, by pushing messages to the web page. These incoming messages can be treated as Events + data inside the web page.">Server-sent_events</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <h4 id="server-sent-events-intro"><span class="secno">9.2.1</span> Introduction<a href="#server-sent-events-intro" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>To enable servers to push data to web pages over HTTP or using dedicated server-push protocols,
  this specification introduces the <code id="server-sent-events-intro:eventsource"><a href="#eventsource">EventSource</a></code> interface.</p>

  <p>Using this API consists of creating an <code id="server-sent-events-intro:eventsource-2"><a href="#eventsource">EventSource</a></code> object and registering an event
  listener.</p>

  <pre><code class="js"><c- a="">var</c-> source <c- o="">=</c-> <c- k="">new</c-> EventSource<c- p="">(</c-><c- t="">'updates.cgi'</c-><c- p="">);</c->
source<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  alert<c- p="">(</c->event<c- p="">.</c->data<c- p="">);</c->
<c- p="">};</c-></code></pre>

  <p>On the server-side, the script ("<code>updates.cgi</code>" in this case) sends
  messages in the following form, with the <code id="server-sent-events-intro:text/event-stream"><a href="#text/event-stream">text/event-stream</a></code> MIME type:</p>

  <pre>data: This is the first message.

data: This is the second message, it
data: has two lines.

data: This is the third message.</pre>

  <hr>

  <p>Authors can separate events by using different event types. Here is a stream that has two event
  types, "add" and "remove":</p>

  <pre>event: add
data: 73857293

event: remove
data: 2153

event: add
data: 113411</pre>

  <p>The script to handle such a stream would look like this (where <code>addHandler</code>
  and <code>removeHandler</code> are functions that take one argument, the event):</p>

  <pre><code class="js"><c- a="">var</c-> source <c- o="">=</c-> <c- k="">new</c-> EventSource<c- p="">(</c-><c- t="">'updates.cgi'</c-><c- p="">);</c->
source<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'add'</c-><c- p="">,</c-> addHandler<c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->
source<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'remove'</c-><c- p="">,</c-> removeHandler<c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c-></code></pre>

  <p>The default event type is "message".</p>

  <p>Event streams are always decoded as UTF-8. There is no way to specify another character
  encoding.</p>

  <hr>

  <p>Event stream requests can be redirected using HTTP 301 and 307 redirects as with normal HTTP
  requests. Clients will reconnect if the connection is closed; a client can be told to stop
  reconnecting using the HTTP 204 No Content response code.</p>

  <p>Using this API rather than emulating it using <code id="server-sent-events-intro:xmlhttprequest"><a data-x-internal="xmlhttprequest" href="https://xhr.spec.whatwg.org/#xmlhttprequest">XMLHttpRequest</a></code> or an
  <code id="server-sent-events-intro:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> allows the user agent to make better use of network resources in cases where
  the user agent implementer and the network operator are able to coordinate in advance. Amongst
  other benefits, this can result in significant savings in battery life on portable devices. This
  is discussed further in the section below on <a href="#eventsource-push">connectionless
  push</a>.</p>


  <h4 id="the-eventsource-interface"><span class="secno">9.2.2</span> The <code id="the-eventsource-interface:eventsource"><a href="#eventsource">EventSource</a></code> interface<a href="#the-eventsource-interface" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource" title="The EventSource interface is web content's interface to server-sent events.">EventSource</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="eventsource" data-dfn-type="interface"><c- g="">EventSource</c-></dfn> : <a id="the-eventsource-interface:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <a href="#dom-eventsource" id="the-eventsource-interface:dom-eventsource"><c- g="">constructor</c-></a>(<c- b="">USVString</c-> <c- g="">url</c->, <c- b="">optional</c-> <a href="#eventsourceinit" id="the-eventsource-interface:eventsourceinit"><c- n="">EventSourceInit</c-></a> <c- g="">eventSourceInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-eventsource-url" id="the-eventsource-interface:dom-eventsource-url"><c- g="">url</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">boolean</c-> <a href="#dom-eventsource-withcredentials" id="the-eventsource-interface:dom-eventsource-withcredentials"><c- g="">withCredentials</c-></a>;

  // ready state
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-eventsource-connecting" id="the-eventsource-interface:dom-eventsource-connecting"><c- g="">CONNECTING</c-></a> = 0;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-eventsource-open" id="the-eventsource-interface:dom-eventsource-open"><c- g="">OPEN</c-></a> = 1;
  <c- b="">const</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-eventsource-closed" id="the-eventsource-interface:dom-eventsource-closed"><c- g="">CLOSED</c-></a> = 2;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">short</c-> <a href="#dom-eventsource-readystate" id="the-eventsource-interface:dom-eventsource-readystate"><c- g="">readyState</c-></a>;

  // networking
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-eventsource-interface:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-eventsource-onopen" id="the-eventsource-interface:handler-eventsource-onopen"><c- g="">onopen</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-eventsource-interface:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-eventsource-onmessage" id="the-eventsource-interface:handler-eventsource-onmessage"><c- g="">onmessage</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-eventsource-interface:eventhandler-3"><c- n="">EventHandler</c-></a> <a href="#handler-eventsource-onerror" id="the-eventsource-interface:handler-eventsource-onerror"><c- g="">onerror</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-eventsource-close" id="the-eventsource-interface:dom-eventsource-close"><c- g="">close</c-></a>();
};

<c- b="">dictionary</c-> <dfn id="eventsourceinit" data-dfn-type="dictionary"><c- g="">EventSourceInit</c-></dfn> {
  <c- b="">boolean</c-> <dfn data-dfn-for="EventSourceInit" id="dom-eventsourceinit-withcredentials" data-dfn-type="dict-member"><c- g="">withCredentials</c-></dfn> = <c- b="">false</c->;
};</code></pre>

  

  <p>Each <code id="the-eventsource-interface:eventsource-2"><a href="#eventsource">EventSource</a></code> object has the following associated with it:</p>

  <ul><li><p>A <dfn data-dfn-for="EventSource" id="concept-eventsource-url">url</dfn> (a <a id="the-eventsource-interface:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL
   record</a>). Set during construction.</p></li><li><p>A <dfn id="concept-event-stream-request">request</dfn>. This must initially be
   null.</p></li><li><p>A <dfn id="concept-event-stream-reconnection-time">reconnection time</dfn>, in
   milliseconds. This must initially be an <a id="the-eventsource-interface:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> value, probably in
   the region of a few seconds.</p></li><li><p>A <dfn id="concept-event-stream-last-event-id">last event ID string</dfn>. This must
   initially be the empty string.</p></li></ul>

  <p>Apart from <a href="#concept-eventsource-url" id="the-eventsource-interface:concept-eventsource-url">url</a> these are not currently exposed on
  the <code id="the-eventsource-interface:eventsource-3"><a href="#eventsource">EventSource</a></code> object.</p>

  

  <dl class="domintro"><dt><code><var>source</var> = new <a href="#dom-eventsource" id="dom-eventsource-dev">EventSource</a>(
   <var>url</var> [, { <a href="#dom-eventsourceinit-withcredentials" id="the-eventsource-interface:dom-eventsourceinit-withcredentials">withCredentials</a>:
   true } ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/EventSource" title="The EventSource() constructor returns a newly-created EventSource, which represents a remote resource.">EventSource/EventSource</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>11+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dd>
    <p>Creates a new <code id="the-eventsource-interface:eventsource-4"><a href="#eventsource">EventSource</a></code> object.</p>

    <p><var>url</var> is a string giving the <a id="the-eventsource-interface:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> that will provide the event
    stream.</p>

    <p>Setting <code id="the-eventsource-interface:dom-eventsourceinit-withcredentials-2"><a href="#dom-eventsourceinit-withcredentials">withCredentials</a></code> to true
    will set the <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="the-eventsource-interface:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> for
    connection requests to <var>url</var> to "<code>include</code>".</p>
   </dd><dt><code><var>source</var>.<a href="#dom-eventsource-close" id="dom-eventsource-close-dev">close</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close" title="The close() method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).">EventSource/close</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dd>
    <p>Aborts any instances of the <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-eventsource-interface:concept-fetch" data-x-internal="concept-fetch">fetch</a> algorithm started for
    this <code id="the-eventsource-interface:eventsource-5"><a href="#eventsource">EventSource</a></code> object, and sets the <code id="the-eventsource-interface:dom-eventsource-readystate-2"><a href="#dom-eventsource-readystate">readyState</a></code> attribute to <code id="the-eventsource-interface:dom-eventsource-closed-2"><a href="#dom-eventsource-closed">CLOSED</a></code>.</p>
   </dd><dt><code><var>source</var>.<a href="#dom-eventsource-url" id="dom-eventsource-url-dev">url</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/url" title="The url read-only property of the EventSource interface returns a string representing the URL of the source.">EventSource/url</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>6+</span></span><span class="chrome yes"><span>Chrome</span><span>18+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dd><p>Returns the <a href="#concept-eventsource-url" id="the-eventsource-interface:concept-eventsource-url-2">URL providing the event
   stream</a>.</p></dd><dt><code><var>source</var>.<a href="#dom-eventsource-withcredentials" id="dom-eventsource-withcredentials-dev">withCredentials</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/withCredentials" title="The withCredentials read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.">EventSource/withCredentials</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>7+</span></span><span class="chrome yes"><span>Chrome</span><span>26+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dd>
    <p>Returns true if the <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="the-eventsource-interface:concept-request-credentials-mode-2" data-x-internal="concept-request-credentials-mode">credentials mode</a>
    for connection requests to the <a href="#concept-eventsource-url" id="the-eventsource-interface:concept-eventsource-url-3">URL providing the event
    stream</a> is set to "<code>include</code>", and false otherwise.</p>
   </dd><dt><code><var>source</var>.<a href="#dom-eventsource-readystate" id="dom-eventsource-readystate-dev">readyState</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/readyState" title="The readyState read-only property of the EventSource interface returns a number representing the state of the connection.">EventSource/readyState</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></dt><dd>
    <p>Returns the state of this <code id="the-eventsource-interface:eventsource-6"><a href="#eventsource">EventSource</a></code> object's connection. It can have the
    values described below.</p>
   </dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="EventSource" id="dom-eventsource" data-dfn-type="constructor"><code>EventSource(<var>url</var>, <var>eventSourceInitDict</var>)</code></dfn>
  constructor, when invoked, must run these steps:</p>

  <ol><li><p>Let <var>ev</var> be a new <code id="the-eventsource-interface:eventsource-7"><a href="#eventsource">EventSource</a></code> object.</p></li><li><p>Let <var>settings</var> be <var>ev</var>'s <a href="#relevant-settings-object" id="the-eventsource-interface:relevant-settings-object">relevant settings object</a>.

   </p></li><li><p>Let <var>urlRecord</var> be the result of <a href="#encoding-parsing-a-url" id="the-eventsource-interface:encoding-parsing-a-url">encoding-parsing a URL</a> given
   <var>url</var>, relative to <var>settings</var>.</p></li><li><p>If <var>urlRecord</var> is failure, then throw a <a id="the-eventsource-interface:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="the-eventsource-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>ev</var>'s <a href="#concept-eventsource-url" id="the-eventsource-interface:concept-eventsource-url-4">url</a> to
   <var>urlRecord</var>.</p>

   </li><li><p>Let <var>corsAttributeState</var> be <a href="#attr-crossorigin-anonymous" id="the-eventsource-interface:attr-crossorigin-anonymous">Anonymous</a>.</p></li><li><p>If the value of <var>eventSourceInitDict</var>'s <code id="the-eventsource-interface:dom-eventsourceinit-withcredentials-3"><a href="#dom-eventsourceinit-withcredentials">withCredentials</a></code> member is true, then set
   <var>corsAttributeState</var> to <a href="#attr-crossorigin-use-credentials" id="the-eventsource-interface:attr-crossorigin-use-credentials">Use
   Credentials</a> and set <var>ev</var>'s <code id="the-eventsource-interface:dom-eventsource-withcredentials-2"><a href="#dom-eventsource-withcredentials">withCredentials</a></code> attribute to true.</p></li><li><p>Let <var>request</var> be the result of <a href="#create-a-potential-cors-request" id="the-eventsource-interface:create-a-potential-cors-request">creating a potential-CORS request</a> given
   <var>urlRecord</var>, the empty string, and <var>corsAttributeState</var>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-client" id="the-eventsource-interface:concept-request-client" data-x-internal="concept-request-client">client</a> to
   <var>settings</var>.</p></li><li><p>User agents may <a href="https://fetch.spec.whatwg.org/#concept-header-list-set" id="the-eventsource-interface:concept-header-list-set" data-x-internal="concept-header-list-set">set</a> (`<code id="the-eventsource-interface:http-accept"><a data-x-internal="http-accept" href="https://httpwg.org/specs/rfc7231.html#header.accept">Accept</a></code>`, `<code id="the-eventsource-interface:text/event-stream"><a href="#text/event-stream">text/event-stream</a></code>`) in <var>request</var>'s
   <a href="https://fetch.spec.whatwg.org/#concept-request-header-list" id="the-eventsource-interface:concept-request-header-list" data-x-internal="concept-request-header-list">header list</a>.</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-cache-mode" id="the-eventsource-interface:concept-request-cache-mode" data-x-internal="concept-request-cache-mode">cache mode</a> to
   "<code>no-store</code>".</p></li><li><p>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#request-initiator-type" id="the-eventsource-interface:concept-request-initiator-type" data-x-internal="concept-request-initiator-type">initiator
   type</a> to "<code>other</code>".</p></li><li><p>Set <var>ev</var>'s <a href="#concept-event-stream-request" id="the-eventsource-interface:concept-event-stream-request">request</a> to
   <var>request</var>.</p></li><li><p>Let <var>processEventSourceEndOfBody</var> given <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-eventsource-interface:concept-response" data-x-internal="concept-response">response</a> <var>res</var> be the following step: if
   <var>res</var> is not a <a id="the-eventsource-interface:network-error" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>, then <a href="#reestablish-the-connection" id="the-eventsource-interface:reestablish-the-connection">reestablish the
   connection</a>.</p></li><li>
    <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-eventsource-interface:concept-fetch-2" data-x-internal="concept-fetch">Fetch</a> <var>request</var>, with <i id="the-eventsource-interface:processresponseendofbody"><a data-x-internal="processresponseendofbody" href="https://fetch.spec.whatwg.org/#fetch-processresponseendofbody">processResponseEndOfBody</a></i> set to
    <var>processEventSourceEndOfBody</var> and <i id="the-eventsource-interface:processresponse"><a data-x-internal="processresponse" href="https://fetch.spec.whatwg.org/#process-response">processResponse</a></i> set
    to the following steps given <a href="https://fetch.spec.whatwg.org/#concept-response" id="the-eventsource-interface:concept-response-2" data-x-internal="concept-response">response</a>
    <var>res</var>:</p>

    <ol><li><p>If <var>res</var> is an <a id="the-eventsource-interface:aborted-network-error" href="https://fetch.spec.whatwg.org/#concept-aborted-network-error" data-x-internal="aborted-network-error">aborted network error</a>, then <a href="#fail-the-connection" id="the-eventsource-interface:fail-the-connection">fail the
     connection</a>.</p></li><li><p>Otherwise, if <var>res</var> is a <a id="the-eventsource-interface:network-error-2" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>, then <a href="#reestablish-the-connection" id="the-eventsource-interface:reestablish-the-connection-2">reestablish
     the connection</a>, unless the user agent knows that to be futile, in which case the user
     agent may <a href="#fail-the-connection" id="the-eventsource-interface:fail-the-connection-2">fail the connection</a>.</p></li><li><p>Otherwise, if <var>res</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-status" id="the-eventsource-interface:concept-response-status" data-x-internal="concept-response-status">status</a> is
     not 200, or if <var>res</var>'s `<code id="the-eventsource-interface:content-type"><a href="#content-type">Content-Type</a></code>` is not
     `<code id="the-eventsource-interface:text/event-stream-2"><a href="#text/event-stream">text/event-stream</a></code>`, then <a href="#fail-the-connection" id="the-eventsource-interface:fail-the-connection-3">fail the connection</a>.</p>

     </li><li><p>Otherwise, <a href="#announce-the-connection" id="the-eventsource-interface:announce-the-connection">announce the connection</a> and <a href="#event-stream-interpretation">interpret</a> <var>res</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-body" id="the-eventsource-interface:concept-response-body" data-x-internal="concept-response-body">body</a> line by line.</p></li></ol>
   </li><li><p>Return <var>ev</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="EventSource" id="dom-eventsource-url" data-dfn-type="attribute"><code>url</code></dfn>
  attribute's getter must return the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-eventsource-interface:concept-url-serializer" data-x-internal="concept-url-serializer">serialization</a> of
  this <code id="the-eventsource-interface:eventsource-8"><a href="#eventsource">EventSource</a></code> object's <a href="#concept-eventsource-url" id="the-eventsource-interface:concept-eventsource-url-5">url</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="EventSource" id="dom-eventsource-withcredentials" data-dfn-type="attribute"><code>withCredentials</code></dfn> attribute must return the
  value to which it was last initialized. When the object is created, it must be initialized to
  false.</p>
  </div>

  <p>The <dfn data-dfn-for="EventSource" id="dom-eventsource-readystate" data-dfn-type="attribute"><code>readyState</code></dfn> attribute represents the state of the
  connection. It can have the following values:</p>

  

  <dl><dt><dfn data-dfn-for="EventSource" id="dom-eventsource-connecting" data-dfn-type="const"><code>CONNECTING</code></dfn> (numeric value 0)</dt><dd>The connection has not yet been established, or it was closed and the user agent is
   reconnecting.</dd><dt><dfn data-dfn-for="EventSource" id="dom-eventsource-open" data-dfn-type="const"><code>OPEN</code></dfn> (numeric value 1)</dt><dd>The user agent has an open connection and is dispatching events as it receives them.</dd><dt><dfn data-dfn-for="EventSource" id="dom-eventsource-closed" data-dfn-type="const"><code>CLOSED</code></dfn> (numeric value 2)</dt><dd>The connection is not open, and the user agent is not trying to reconnect. Either there was a
   fatal error or the <code id="the-eventsource-interface:dom-eventsource-close-2"><a href="#dom-eventsource-close">close()</a></code> method was invoked.</dd></dl>

  

  <div data-algorithm="">
  <p>When the object is created, its <code id="the-eventsource-interface:dom-eventsource-readystate-3"><a href="#dom-eventsource-readystate">readyState</a></code> must
  be set to <code id="the-eventsource-interface:dom-eventsource-connecting-2"><a href="#dom-eventsource-connecting">CONNECTING</a></code> (0). The rules given below
  for handling the connection define when the value changes.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="EventSource" id="dom-eventsource-close" data-dfn-type="method"><code>close()</code></dfn>
  method must abort any instances of the <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="the-eventsource-interface:concept-fetch-3" data-x-internal="concept-fetch">fetch</a> algorithm started
  for this <code id="the-eventsource-interface:eventsource-9"><a href="#eventsource">EventSource</a></code> object, and must set the <code id="the-eventsource-interface:dom-eventsource-readystate-4"><a href="#dom-eventsource-readystate">readyState</a></code> attribute to <code id="the-eventsource-interface:dom-eventsource-closed-3"><a href="#dom-eventsource-closed">CLOSED</a></code>.</p> 
  </div>

  

  <p>The following are the <a href="#event-handlers" id="the-eventsource-interface:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="the-eventsource-interface:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="the-eventsource-interface:event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the
  <code id="the-eventsource-interface:eventsource-10"><a href="#eventsource">EventSource</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="the-eventsource-interface:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="the-eventsource-interface:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="EventSource" id="handler-eventsource-onopen" data-dfn-type="attribute"><code>onopen</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/open_event" title="The open event of the EventSource API is fired when a connection with an event source is opened.">EventSource/open_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td> <code id="the-eventsource-interface:event-open"><a href="#event-open">open</a></code>
    </td></tr><tr><td><dfn data-dfn-for="EventSource" id="handler-eventsource-onmessage" data-dfn-type="attribute"><code>onmessage</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/message_event" title="The message event of the EventSource API is fired when data is received through an event source.">EventSource/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td> <code id="the-eventsource-interface:event-message"><a href="#event-message">message</a></code>
    </td></tr><tr><td><dfn data-dfn-for="EventSource" id="handler-eventsource-onerror" data-dfn-type="attribute"><code>onerror</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/error_event" title="The error event of the EventSource API is fired when a connection with an event source fails to be opened.">EventSource/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td> <code id="the-eventsource-interface:event-error"><a href="#event-error">error</a></code>
  </td></tr></tbody></table>

  <hr>

  

  <h4 id="sse-processing-model"><span class="secno">9.2.3</span> <span id="processing-model-9"></span>Processing model<a href="#sse-processing-model" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="announce-the-connection">announce the connection</dfn>, the user agent must <a href="#queue-a-task" id="sse-processing-model:queue-a-task">queue a
  task</a> which, if the <code id="sse-processing-model:dom-eventsource-readystate"><a href="#dom-eventsource-readystate">readyState</a></code> attribute is
  set to a value other than <code id="sse-processing-model:dom-eventsource-closed"><a href="#dom-eventsource-closed">CLOSED</a></code>, sets the <code id="sse-processing-model:dom-eventsource-readystate-2"><a href="#dom-eventsource-readystate">readyState</a></code> attribute to <code id="sse-processing-model:dom-eventsource-open"><a href="#dom-eventsource-open">OPEN</a></code> and <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sse-processing-model:concept-event-fire" data-x-internal="concept-event-fire">fires an
  event</a> named <code id="sse-processing-model:event-open"><a href="#event-open">open</a></code> at the <code id="sse-processing-model:eventsource"><a href="#eventsource">EventSource</a></code>
  object.</p>
  </div>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="reestablish-the-connection">reestablish the connection</dfn>, the user agent must run the
  following steps. These steps are run <a href="#in-parallel" id="sse-processing-model:in-parallel">in parallel</a>, not as part of a <a href="#concept-task" id="sse-processing-model:concept-task">task</a>. (The tasks that it queues, of course, are run like normal tasks
  and not themselves <a href="#in-parallel" id="sse-processing-model:in-parallel-2">in parallel</a>.)</p>

  <ol><li>
    <p><a href="#queue-a-task" id="sse-processing-model:queue-a-task-2">Queue a task</a> to run the following steps:</p>

    <ol><li><p>If the <code id="sse-processing-model:dom-eventsource-readystate-3"><a href="#dom-eventsource-readystate">readyState</a></code> attribute is set to
     <code id="sse-processing-model:dom-eventsource-closed-2"><a href="#dom-eventsource-closed">CLOSED</a></code>, abort the task.</p></li><li><p>Set the <code id="sse-processing-model:dom-eventsource-readystate-4"><a href="#dom-eventsource-readystate">readyState</a></code> attribute to <code id="sse-processing-model:dom-eventsource-connecting"><a href="#dom-eventsource-connecting">CONNECTING</a></code>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sse-processing-model:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="sse-processing-model:event-error"><a href="#event-error">error</a></code> at the <code id="sse-processing-model:eventsource-2"><a href="#eventsource">EventSource</a></code> object.</p></li></ol>
   </li><li><p>Wait a delay equal to the reconnection time of the event source.</p></li><li><p>Optionally, wait some more. In particular, if the previous attempt failed, then user
   agents might introduce an exponential backoff delay to avoid overloading a potentially already
   overloaded server. Alternatively, if the operating system has reported that there is no network
   connectivity, user agents might wait for the operating system to announce that the network
   connection has returned before retrying.</p></li><li><p>Wait until the aforementioned task has run, if it has not yet run.</p></li><li>
    <p><a href="#queue-a-task" id="sse-processing-model:queue-a-task-3">Queue a task</a> to run the following steps:</p>

    <ol><li><p>If the <code id="sse-processing-model:eventsource-3"><a href="#eventsource">EventSource</a></code> object's <code id="sse-processing-model:dom-eventsource-readystate-5"><a href="#dom-eventsource-readystate">readyState</a></code> attribute is not set to <code id="sse-processing-model:dom-eventsource-connecting-2"><a href="#dom-eventsource-connecting">CONNECTING</a></code>, then return.</p></li><li><p>Let <var>request</var> be the <code id="sse-processing-model:eventsource-4"><a href="#eventsource">EventSource</a></code> object's <a href="#concept-event-stream-request" id="sse-processing-model:concept-event-stream-request">request</a>.

     </p></li><li>
      <p>If the <code id="sse-processing-model:eventsource-5"><a href="#eventsource">EventSource</a></code> object's <a href="#concept-event-stream-last-event-id" id="sse-processing-model:concept-event-stream-last-event-id">last event ID string</a> is not the empty
      string, then:</p>

      <ol><li><p>Let <var>lastEventIDValue</var> be the <code id="sse-processing-model:eventsource-6"><a href="#eventsource">EventSource</a></code> object's <a href="#concept-event-stream-last-event-id" id="sse-processing-model:concept-event-stream-last-event-id-2">last event ID string</a>, <a href="https://encoding.spec.whatwg.org/#utf-8-encode" id="sse-processing-model:utf-8-encode" data-x-internal="utf-8-encode">encoded as UTF-8</a>.</p></li><li><p><a href="https://fetch.spec.whatwg.org/#concept-header-list-set" id="sse-processing-model:concept-header-list-set" data-x-internal="concept-header-list-set">Set</a> (`<code id="sse-processing-model:last-event-id"><a href="#last-event-id">Last-Event-ID</a></code>`,
       <var>lastEventIDValue</var>) in <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-header-list" id="sse-processing-model:concept-request-header-list" data-x-internal="concept-request-header-list">header list</a>.</p></li></ol>
     </li><li><p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="sse-processing-model:concept-fetch" data-x-internal="concept-fetch">Fetch</a> <var>request</var> and process the
     response obtained in this fashion, if any, as described earlier in this section.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="fail-the-connection">fail the connection</dfn>, the user agent must <a href="#queue-a-task" id="sse-processing-model:queue-a-task-4">queue a
  task</a> which, if the <code id="sse-processing-model:dom-eventsource-readystate-6"><a href="#dom-eventsource-readystate">readyState</a></code> attribute is
  set to a value other than <code id="sse-processing-model:dom-eventsource-closed-3"><a href="#dom-eventsource-closed">CLOSED</a></code>, sets the <code id="sse-processing-model:dom-eventsource-readystate-7"><a href="#dom-eventsource-readystate">readyState</a></code> attribute to <code id="sse-processing-model:dom-eventsource-closed-4"><a href="#dom-eventsource-closed">CLOSED</a></code> and <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="sse-processing-model:concept-event-fire-3" data-x-internal="concept-event-fire">fires an
  event</a> named <code id="sse-processing-model:event-error-2"><a href="#event-error">error</a></code> at the <code id="sse-processing-model:eventsource-7"><a href="#eventsource">EventSource</a></code> object.
  <strong>Once the user agent has <a href="#fail-the-connection" id="sse-processing-model:fail-the-connection">failed the connection</a>,
  it does <em>not</em> attempt to reconnect.</strong></p>
  </div>

  <hr>

  <p>The <a href="#task-source" id="sse-processing-model:task-source">task source</a> for any <a href="#concept-task" id="sse-processing-model:concept-task-2">tasks</a> that are <a href="#queue-a-task" id="sse-processing-model:queue-a-task-5">queued</a> by <code id="sse-processing-model:eventsource-8"><a href="#eventsource">EventSource</a></code> objects is the <dfn id="remote-event-task-source">remote event
  task source</dfn>.</p>

  


  <h4 id="the-last-event-id-header"><span class="secno">9.2.4</span> The `<code id="the-last-event-id-header:last-event-id"><a href="#last-event-id">Last-Event-ID</a></code>` header<a href="#the-last-event-id-header" class="self-link"></a></h4>

  <p>The <dfn id="last-event-id" data-dfn-type="http-header"><code>Last-Event-ID</code></dfn>` HTTP request header reports an
  <code id="the-last-event-id-header:eventsource"><a href="#eventsource">EventSource</a></code> object's <a href="#concept-event-stream-last-event-id" id="the-last-event-id-header:concept-event-stream-last-event-id">last event ID
  string</a> to the server when the user agent is to <a href="#reestablish-the-connection" id="the-last-event-id-header:reestablish-the-connection">reestablish the connection</a>.

  </p><p class="XXX">See <a href="https://github.com/whatwg/html/issues/7363">whatwg/html issue
  #7363</a> to define the value space better. It is essentially any UTF-8 encoded string, that does
  not contain U+0000 NULL, U+000A LF, or U+000D CR.</p>


  <h4 id="parsing-an-event-stream"><span class="secno">9.2.5</span> Parsing an event stream<a href="#parsing-an-event-stream" class="self-link"></a></h4>

  

  <p>This event stream format's <a id="parsing-an-event-stream:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> is <code id="parsing-an-event-stream:text/event-stream"><a href="#text/event-stream">text/event-stream</a></code>.</p>

  <p>The event stream format is as described by the <code>stream</code> production of the
  following ABNF, the character set for which is Unicode. <a href="#refsABNF">[ABNF]</a></p>

  <pre><code class="abnf"><c- nc="">stream</c->        <c- o="">=</c-> <c- p="">[</c-> <c- nc="">bom</c-> <c- p="">]</c-> <c- o="">*</c-><c- nc="">event</c->
<c- nc="">event</c->         <c- o="">=</c-> <c- o="">*</c-><c- p="">(</c-> <c- nc="">comment</c-> <c- o="">/</c-> <c- nc="">field</c-> <c- p="">)</c-> <c- nc="">end-of-line</c->
<c- nc="">comment</c->       <c- o="">=</c-> <c- nc="">colon</c-> <c- o="">*</c-><c- nc="">any-char</c-> <c- nc="">end-of-line</c->
<c- nc="">field</c->         <c- o="">=</c-> <c- o="">1*</c-><c- nc="">name-char</c-> <c- p="">[</c-> <c- nc="">colon</c-> <c- p="">[</c-> <c- nc="">space</c-> <c- p="">]</c-> <c- o="">*</c-><c- nc="">any-char</c-> <c- p="">]</c-> <c- nc="">end-of-line</c->
<c- nc="">end-of-line</c->   <c- o="">=</c-> <c- p="">(</c-> <c- nc="">cr</c-> <c- nc="">lf</c-> <c- o="">/</c-> <c- nc="">cr</c-> <c- o="">/</c-> <c- nc="">lf</c-> <c- p="">)</c->

<c- c1="">; characters</c->
<c- nc="">lf</c->            <c- o="">=</c-> <c- l="">%x000A</c-> <c- c1="">; U+000A LINE FEED (LF)</c->
<c- nc="">cr</c->            <c- o="">=</c-> <c- l="">%x000D</c-> <c- c1="">; U+000D CARRIAGE RETURN (CR)</c->
<c- nc="">space</c->         <c- o="">=</c-> <c- l="">%x0020</c-> <c- c1="">; U+0020 SPACE</c->
<c- nc="">colon</c->         <c- o="">=</c-> <c- l="">%x003A</c-> <c- c1="">; U+003A COLON (:)</c->
<c- nc="">bom</c->           <c- o="">=</c-> <c- l="">%xFEFF</c-> <c- c1="">; U+FEFF BYTE ORDER MARK</c->
<c- nc="">name-char</c->     <c- o="">=</c-> <c- l="">%x0000-0009</c-> <c- o="">/</c-> <c- l="">%x000B-000C</c-> <c- o="">/</c-> <c- l="">%x000E-0039</c-> <c- o="">/</c-> <c- l="">%x003B-10FFFF</c->
                <c- c1="">; a </c-><a id="parsing-an-event-stream:scalar-value" href="https://infra.spec.whatwg.org/#scalar-value" data-x-internal="scalar-value"><c- c1="">scalar value</c-></a><c- c1=""> other than U+000A LINE FEED (LF), U+000D CARRIAGE RETURN (CR), or U+003A COLON (:)</c->
<c- nc="">any-char</c->      <c- o="">=</c-> <c- l="">%x0000-0009</c-> <c- o="">/</c-> <c- l="">%x000B-000C</c-> <c- o="">/</c-> <c- l="">%x000E-10FFFF</c->
                <c- c1="">; a </c-><a id="parsing-an-event-stream:scalar-value-2" href="https://infra.spec.whatwg.org/#scalar-value" data-x-internal="scalar-value"><c- c1="">scalar value</c-></a><c- c1=""> other than U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)</c-></code></pre>

  <p>Event streams in this format must always be encoded as UTF-8. <a href="#refsENCODING">[ENCODING]</a></p>

  <p>Lines must be separated by either a U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character
  pair, a single U+000A LINE FEED (LF) character, or a single U+000D CARRIAGE RETURN (CR)
  character.</p>

  <p>Since connections established to remote servers for such resources are expected to be
  long-lived, UAs should ensure that appropriate buffering is used. In particular, while line
  buffering with lines are defined to end with a single U+000A LINE FEED (LF) character is safe,
  block buffering or line buffering with different expected line endings can cause delays in event
  dispatch.</p>


  

  <h4 id="event-stream-interpretation"><span class="secno">9.2.6</span> Interpreting an event stream<a href="#event-stream-interpretation" class="self-link"></a></h4>

  <p>Streams must be decoded using the <a id="event-stream-interpretation:utf-8-decode" href="https://encoding.spec.whatwg.org/#utf-8-decode" data-x-internal="utf-8-decode">UTF-8 decode</a> algorithm.</p>

  <p class="note">The <a id="event-stream-interpretation:utf-8-decode-2" href="https://encoding.spec.whatwg.org/#utf-8-decode" data-x-internal="utf-8-decode">UTF-8 decode</a> algorithm strips one leading UTF-8 Byte Order Mark
  (BOM), if any.</p>

  <p>The stream must then be parsed by reading everything line by line, with a U+000D CARRIAGE
  RETURN U+000A LINE FEED (CRLF) character pair, a single U+000A LINE FEED (LF) character not
  preceded by a U+000D CARRIAGE RETURN (CR) character, and a single U+000D CARRIAGE RETURN (CR)
  character not followed by a U+000A LINE FEED (LF) character being the ways in which a line can
  end.</p>

  <div data-var-scope="">
  <p>When a stream is parsed, a <var>data</var> buffer, an <var>event type</var>
  buffer, and a <var>last event ID</var> buffer must be associated with it. They must be
  initialized to the empty string.</p>

  <div data-algorithm="">
  <p>Lines must be processed, in the order they are received, as follows:</p>

  <dl class="switch"><dt>If the line is empty (a blank line)</dt><dd><p><a href="#dispatchMessage" id="event-stream-interpretation:dispatchMessage">Dispatch the event</a>, as defined below.</p></dd><dt>If the line starts with a U+003A COLON character (:)</dt><dd><p>Ignore the line.</p></dd><dt>If the line contains a U+003A COLON character (:)</dt><dd>
    <p>Collect the characters on the line before the first U+003A COLON character (:), and let <var>field</var> be that string.</p>

    <p>Collect the characters on the line after the first U+003A COLON character (:), and let <var>value</var> be that string. If <var>value</var> starts with a U+0020 SPACE
    character, remove it from <var>value</var>.</p>

    <p><a href="#processField">Process the field</a> using the steps described below, using <var>field</var> as the field name and <var>value</var> as the field value.</p>
   </dd><dt>Otherwise, the string is not empty but does not contain a U+003A COLON character (:)</dt><dd>
    <p><a href="#processField">Process the field</a> using the steps described below, using the
    whole line as the field name, and the empty string as the field value.</p>
   </dd></dl>
  </div>

  <p>Once the end of the file is reached, any pending data must be discarded. (If the file ends in
  the middle of an event, before the final empty line, the incomplete event is not dispatched.)</p>

  <hr>

  <div data-algorithm="">
  <p id="processField">The steps to <dfn>process the field</dfn> given a field name and a
  field value depend on the field name, as given in the following list. Field names must be compared
  literally, with no case folding performed.</p>

  <dl class="switch"><dt>If the field name is "event"</dt><dd><p>Set the <var>event type</var> buffer to the field value.</p></dd><dt>If the field name is "data"</dt><dd><p>Append the field value to the <var>data</var> buffer, then append a single U+000A
   LINE FEED (LF) character to the <var>data</var> buffer.</p></dd><dt>If the field name is "id"</dt><dd><p>If the field value does not contain U+0000 NULL, then set the <var>last event ID</var>
   buffer to the field value. Otherwise, ignore the field.</p></dd><dt>If the field name is "retry"</dt><dd><p>If the field value consists of only <a id="event-stream-interpretation:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, then interpret the field
   value as an integer in base ten, and set the event stream's <a href="#concept-event-stream-reconnection-time" id="event-stream-interpretation:concept-event-stream-reconnection-time">reconnection time</a> to that integer.
   Otherwise, ignore the field.</p></dd><dt>Otherwise</dt><dd><p>The field is ignored.</p></dd></dl>
  </div>


  <div data-algorithm="">
  <p>When the user agent is required to <dfn id="dispatchMessage">dispatch the
  event</dfn>, the user agent must process the <var>data</var> buffer, the <var>event type</var> buffer, and the <var>last event ID</var> buffer using steps
  appropriate for the user agent.</p>
  </div>

  <div data-algorithm="">
  <p>For web browsers, the appropriate steps to <a href="#dispatchMessage" id="event-stream-interpretation:dispatchMessage-2">dispatch the event</a> are as follows:</p>

  <ol><li><p>Set the <a href="#concept-event-stream-last-event-id" id="event-stream-interpretation:concept-event-stream-last-event-id">last event ID string</a> of
   the event source to the value of the <var>last event ID</var> buffer. The buffer does
   not get reset, so the <a href="#concept-event-stream-last-event-id" id="event-stream-interpretation:concept-event-stream-last-event-id-2">last event ID
   string</a> of the event source remains set to this value until the next time it is set by the
   server.</p></li><li><p>If the <var>data</var> buffer is an empty string, set the <var>data</var> buffer and the <var>event type</var> buffer to the empty string and
   return.</p></li><li><p>If the <var>data</var> buffer's last character is a U+000A LINE FEED (LF)
   character, then remove the last character from the <var>data</var> buffer.</p></li><li><p>Let <var>event</var> be the result of <a id="event-stream-interpretation:creating-an-event" href="https://dom.spec.whatwg.org/#concept-event-create" data-x-internal="creating-an-event">creating an event</a> using
   <code id="event-stream-interpretation:messageevent"><a href="#messageevent">MessageEvent</a></code>, in the <a href="#concept-relevant-realm" id="event-stream-interpretation:concept-relevant-realm">relevant realm</a> of
   the <code id="event-stream-interpretation:eventsource"><a href="#eventsource">EventSource</a></code> object.</p></li><li><p>Initialize <var>event</var>'s <code id="event-stream-interpretation:dom-event-type"><a data-x-internal="dom-event-type" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute to
   "<code id="event-stream-interpretation:event-message"><a href="#event-message">message</a></code>", its <code id="event-stream-interpretation:dom-messageevent-data"><a href="#dom-messageevent-data">data</a></code> attribute to <var>data</var>, its <code id="event-stream-interpretation:dom-messageevent-origin"><a href="#dom-messageevent-origin">origin</a></code> attribute to the <a href="#ascii-serialisation-of-an-origin" id="event-stream-interpretation:ascii-serialisation-of-an-origin">serialization</a> of the <a href="https://url.spec.whatwg.org/#concept-url-origin" id="event-stream-interpretation:concept-url-origin" data-x-internal="concept-url-origin">origin</a> of the
   event stream's final URL (i.e., the URL after redirects), and its <code id="event-stream-interpretation:dom-messageevent-lasteventid"><a href="#dom-messageevent-lasteventid">lastEventId</a></code> attribute to the <a href="#concept-event-stream-last-event-id" id="event-stream-interpretation:concept-event-stream-last-event-id-3">last event ID string</a> of the event
   source.</p></li><li><p>If the <var>event type</var> buffer has a value other than the empty string, change the
   <a href="https://dom.spec.whatwg.org/#dom-event-type" id="event-stream-interpretation:concept-event-type" data-x-internal="concept-event-type">type</a> of the newly created event to equal the value of
   the <var>event type</var> buffer.</p></li><li><p>Set the <var>data</var> buffer and the <var>event type</var> buffer to
   the empty string.</p></li><li><p><a href="#queue-a-task" id="event-stream-interpretation:queue-a-task">Queue a task</a> which, if the <code id="event-stream-interpretation:dom-eventsource-readystate"><a href="#dom-eventsource-readystate">readyState</a></code> attribute is set to a value other than <code id="event-stream-interpretation:dom-eventsource-closed"><a href="#dom-eventsource-closed">CLOSED</a></code>, <a href="https://dom.spec.whatwg.org/#concept-event-dispatch" id="event-stream-interpretation:concept-event-dispatch" data-x-internal="concept-event-dispatch">dispatches</a> the newly created event at the
   <code id="event-stream-interpretation:eventsource-2"><a href="#eventsource">EventSource</a></code> object.</p></li></ol>

  <p class="note">If an event doesn't have an "id" field, but an earlier event did set the event
  source's <a href="#concept-event-stream-last-event-id" id="event-stream-interpretation:concept-event-stream-last-event-id-4">last event ID string</a>, then the
  event's <code id="event-stream-interpretation:dom-messageevent-lasteventid-2"><a href="#dom-messageevent-lasteventid">lastEventId</a></code> field will be set to the
  value of whatever the last seen "id" field was.</p>
  </div>

  <div data-algorithm="">
  <p>For other user agents, the appropriate steps to <a href="#dispatchMessage" id="event-stream-interpretation:dispatchMessage-3">dispatch the event</a> are
  implementation dependent, but at a minimum they must set the <var>data</var> and <var>event type</var> buffers to the empty string before returning.</p>
  </div>

  </div>
  

  <div class="example">
   <p>The following event stream, once followed by a blank line:</p>
   <pre>data: YHOO
data: +2
data: 10</pre>

   <p>...would cause an event <code id="event-stream-interpretation:event-message-2"><a href="#event-message">message</a></code> with the interface
   <code id="event-stream-interpretation:messageevent-2"><a href="#messageevent">MessageEvent</a></code> to be dispatched on the <code id="event-stream-interpretation:eventsource-3"><a href="#eventsource">EventSource</a></code> object. The event's
   <code id="event-stream-interpretation:dom-messageevent-data-2"><a href="#dom-messageevent-data">data</a></code> attribute would contain the string "<code>YHOO\n+2\n10</code>" (where "<code>\n</code>" represents a newline).</p>

   <p>This could be used as follows:
   </p><pre><code class="js"><c- a="">var</c-> stocks <c- o="">=</c-> <c- k="">new</c-> EventSource<c- p="">(</c-><c- u="">"https://stocks.example.com/ticker.php"</c-><c- p="">);</c->
stocks<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> data <c- o="">=</c-> event<c- p="">.</c->data<c- p="">.</c->split<c- p="">(</c-><c- t="">'\n'</c-><c- p="">);</c->
  updateStocks<c- p="">(</c->data<c- p="">[</c-><c- mf="">0</c-><c- p="">],</c-> data<c- p="">[</c-><c- mf="">1</c-><c- p="">],</c-> data<c- p="">[</c-><c- mf="">2</c-><c- p="">]);</c->
<c- p="">};</c-></code></pre>

   <p>...where <code>updateStocks()</code> is a function defined as:</p>

   <pre><code class="js"><c- a="">function</c-> updateStocks<c- p="">(</c->symbol<c- p="">,</c-> delta<c- p="">,</c-> value<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c-></code></pre>

   <p>...or some such.</p>
  </div>

  <div class="example">
   <p>The following stream contains four blocks. The first block has just a comment, and will fire
   nothing. The second block has two fields with names "data" and "id" respectively; an event will
   be fired for this block, with the data "first event", and will then set the last event ID to "1"
   so that if the connection died between this block and the next, the server would be sent a
   `<code id="event-stream-interpretation:last-event-id"><a href="#last-event-id">Last-Event-ID</a></code>` header with the value `<code>1</code>`. The third block
   fires an event with data "second event", and also has an "id" field, this time with no value,
   which resets the last event ID to the empty string (meaning no `<code id="event-stream-interpretation:last-event-id-2"><a href="#last-event-id">Last-Event-ID</a></code>`
   header will now be sent in the event of a reconnection being attempted). Finally, the last block
   just fires an event with the data "&nbsp;third&nbsp;event" (with a single leading space
   character). Note that the last still has to end with a blank line, the end of the stream is not
   enough to trigger the dispatch of the last event.</p>

   <pre>: test stream

data: first event
id: 1

data:second event
id

data:&nbsp;&nbsp;third event
</pre>
  </div>

  <div class="example">
   <p>The following stream fires two events:</p>

   <pre>data

data
data

data:</pre>

   <p>The first block fires events with the data set to the empty string, as would the last block if
   it was followed by a blank line. The middle block fires an event with the data set to a single
   newline character. The last block is discarded because it is not followed by a blank line.</p>
  </div>

  <div class="example">
   <p>The following stream fires two identical events:</p>

   <pre>data:test

data:&nbsp;test
</pre>

   <p>This is because the space after the colon is ignored if present.</p>
  </div>


  <h4 id="authoring-notes"><span class="secno">9.2.7</span> Authoring notes<a href="#authoring-notes" class="self-link"></a></h4>

  <p>Legacy proxy servers are known to, in certain cases, drop HTTP connections after a short
  timeout. To protect against such proxy servers, authors can include a comment line (one starting
  with a ':' character) every 15 seconds or so.</p>

  <p>Authors wishing to relate event source connections to each other or to specific documents
  previously served might find that relying on IP addresses doesn't work, as individual clients can
  have multiple IP addresses (due to having multiple proxy servers) and individual IP addresses can
  have multiple clients (due to sharing a proxy server). It is better to include a unique identifier
  in the document when it is served and then pass that identifier as part of the URL when the
  connection is established.</p>

  <p>Authors are also cautioned that HTTP chunking can have unexpected negative effects on the
  reliability of this protocol, in particular if the chunking is done by a different layer unaware
  of the timing requirements. If this is a problem, chunking can be disabled for serving event
  streams.</p> 

  <p>Clients that support HTTP's per-server connection limitation might run into trouble when
  opening multiple pages from a site if each page has an <code id="authoring-notes:eventsource"><a href="#eventsource">EventSource</a></code> to the same
  domain. Authors can avoid this using the relatively complex mechanism of using unique domain names
  per connection, or by allowing the user to enable or disable the <code id="authoring-notes:eventsource-2"><a href="#eventsource">EventSource</a></code>
  functionality on a per-page basis, or by sharing a single <code id="authoring-notes:eventsource-3"><a href="#eventsource">EventSource</a></code> object using a
  <a href="#sharedworkerglobalscope" id="authoring-notes:sharedworkerglobalscope">shared worker</a>.</p>

  

  <h4 id="eventsource-push"><span class="secno">9.2.8</span> Connectionless push and other features<a href="#eventsource-push" class="self-link"></a></h4>

  <p>User agents running in controlled environments, e.g. browsers on mobile handsets tied to
  specific carriers, may offload the management of the connection to a proxy on the network. In such
  a situation, the user agent for the purposes of conformance is considered to include both the
  handset software and the network proxy.</p>

  <div class="example">

   <p>For example, a browser on a mobile device, after having established a connection, might detect
   that it is on a supporting network and request that a proxy server on the network take over the
   management of the connection. The timeline for such a situation might be as follows:</p>

   <ol><li>Browser connects to a remote HTTP server and requests the resource specified by the author
    in the <code id="eventsource-push:dom-eventsource"><a href="#dom-eventsource">EventSource</a></code> constructor.</li><li>The server sends occasional messages.</li><li>In between two messages, the browser detects that it is idle except for the network activity
    involved in keeping the TCP connection alive, and decides to switch to sleep mode to save
    power.</li><li>The browser disconnects from the server.</li><li>The browser contacts a service on the network, and requests that the service, a "push
    proxy", maintain the connection instead.</li><li>The "push proxy" service contacts the remote HTTP server and requests the resource specified
    by the author in the <code id="eventsource-push:dom-eventsource-2"><a href="#dom-eventsource">EventSource</a></code> constructor (possibly
    including a `<code id="eventsource-push:last-event-id"><a href="#last-event-id">Last-Event-ID</a></code>` HTTP header, etc.).</li><li>The browser allows the mobile device to go to sleep.</li><li>The server sends another message.</li><li>The "push proxy" service uses a technology such as OMA push to convey the event to the
    mobile device, which wakes only enough to process the event and then returns to sleep.</li></ol>

  </div>

  <p>This can reduce the total data usage, and can therefore result in considerable power
  savings.</p>

  <p>As well as implementing the existing API and <code id="eventsource-push:text/event-stream"><a href="#text/event-stream">text/event-stream</a></code> wire format as
  defined by this specification and in more distributed ways as described above, formats of event
  framing defined by <a href="#other-applicable-specifications" id="eventsource-push:other-applicable-specifications">other applicable specifications</a> may be supported. This
  specification does not define how they are to be parsed or processed.</p>


  <h4 id="garbage-collection"><span class="secno">9.2.9</span> Garbage collection<a href="#garbage-collection" class="self-link"></a></h4>

  <p>While an <code id="garbage-collection:eventsource"><a href="#eventsource">EventSource</a></code> object's <code id="garbage-collection:dom-eventsource-readystate"><a href="#dom-eventsource-readystate">readyState</a></code> is <code id="garbage-collection:dom-eventsource-connecting"><a href="#dom-eventsource-connecting">CONNECTING</a></code>, and the object has one or more event
  listeners registered for <code id="garbage-collection:event-open"><a href="#event-open">open</a></code>, <code id="garbage-collection:event-message"><a href="#event-message">message</a></code>, or <code id="garbage-collection:event-error"><a href="#event-error">error</a></code> events, there must
  be a strong reference from the <code id="garbage-collection:window"><a href="#window">Window</a></code> or <code id="garbage-collection:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object that
  the <code id="garbage-collection:eventsource-2"><a href="#eventsource">EventSource</a></code> object's constructor was invoked from to the <code id="garbage-collection:eventsource-3"><a href="#eventsource">EventSource</a></code>
  object itself.</p>

  <p>While an <code id="garbage-collection:eventsource-4"><a href="#eventsource">EventSource</a></code> object's <code id="garbage-collection:dom-eventsource-readystate-2"><a href="#dom-eventsource-readystate">readyState</a></code> is <code id="garbage-collection:dom-eventsource-open"><a href="#dom-eventsource-open">OPEN</a></code>, and the object has one or more event listeners
  registered for <code id="garbage-collection:event-message-2"><a href="#event-message">message</a></code> or <code id="garbage-collection:event-error-2"><a href="#event-error">error</a></code> events, there must be a strong reference from the
  <code id="garbage-collection:window-2"><a href="#window">Window</a></code> or <code id="garbage-collection:workerglobalscope-2"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object that the <code id="garbage-collection:eventsource-5"><a href="#eventsource">EventSource</a></code>
  object's constructor was invoked from to the <code id="garbage-collection:eventsource-6"><a href="#eventsource">EventSource</a></code> object itself.</p>

  <p>While there is a task queued by an <code id="garbage-collection:eventsource-7"><a href="#eventsource">EventSource</a></code> object on the <a href="#remote-event-task-source" id="garbage-collection:remote-event-task-source">remote event
  task source</a>, there must be a strong reference from the <code id="garbage-collection:window-3"><a href="#window">Window</a></code> or
  <code id="garbage-collection:workerglobalscope-3"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object that the <code id="garbage-collection:eventsource-8"><a href="#eventsource">EventSource</a></code> object's constructor was
  invoked from to that <code id="garbage-collection:eventsource-9"><a href="#eventsource">EventSource</a></code> object.</p>

  <div data-algorithm="">
  <p>If a user agent is to <dfn id="concept-eventsource-forcibly-close">forcibly close</dfn> an
  <code id="garbage-collection:eventsource-10"><a href="#eventsource">EventSource</a></code> object (this happens when a <code id="garbage-collection:document"><a href="#document">Document</a></code> object goes away
  permanently), the user agent must abort any instances of the <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="garbage-collection:concept-fetch" data-x-internal="concept-fetch">fetch</a> algorithm started for this <code id="garbage-collection:eventsource-11"><a href="#eventsource">EventSource</a></code> object,
  and must set the <code id="garbage-collection:dom-eventsource-readystate-3"><a href="#dom-eventsource-readystate">readyState</a></code> attribute to <code id="garbage-collection:dom-eventsource-closed"><a href="#dom-eventsource-closed">CLOSED</a></code>.</p> 
  </div>

  <div data-algorithm="">
  <p>If an <code id="garbage-collection:eventsource-12"><a href="#eventsource">EventSource</a></code> object is garbage collected while its connection is still open,
  the user agent must abort any instance of the <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="garbage-collection:concept-fetch-2" data-x-internal="concept-fetch">fetch</a> algorithm
  opened by this <code id="garbage-collection:eventsource-13"><a href="#eventsource">EventSource</a></code>.</p> 
  </div>


  <h4 id="implementation-advice"><span class="secno">9.2.10</span> Implementation advice<a href="#implementation-advice" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>User agents are strongly urged to provide detailed diagnostic information about
  <code id="implementation-advice:eventsource"><a href="#eventsource">EventSource</a></code> objects and their related network connections in their development
  consoles, to aid authors in debugging code using this API.</p>

  <p>For example, a user agent could have a panel displaying all the <code id="implementation-advice:eventsource-2"><a href="#eventsource">EventSource</a></code>
  objects a page has created, each listing the constructor's arguments, whether there was a network
  error, what the CORS status of the connection is and what headers were sent by the client and
  received from the server to lead to that status, the messages that were received and how they were
  parsed, and so forth.</p>

  <p>Implementations are especially encouraged to report detailed information to their development
  consoles whenever an <code id="implementation-advice:event-error"><a href="#event-error">error</a></code> event is fired, since little to no
  information can be made available in the events themselves.</p>

  


  <h3 id="web-messaging"><span class="secno">9.3</span> <dfn id="crossDocumentMessages">Cross-document messaging</dfn><a href="#web-messaging" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage" title="The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.">Window/postMessage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>9.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>≤37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <p>Web browsers, for security and privacy reasons, prevent documents in different domains from
  affecting each other; that is, cross-site scripting is disallowed.</p>

  <p>While this is an important security feature, it prevents pages from different domains from
  communicating even when those pages are not hostile. This section introduces a messaging system
  that allows documents to communicate with each other regardless of their source domain, in a way
  designed to not enable cross-site scripting attacks.</p>

  <p id="fingerprint-postMessage" class="note"><a href="#fingerprint-postMessage" class="self-link"></a>
  <a id="web-messaging:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  The <code id="web-messaging:dom-window-postmessage"><a href="#dom-window-postmessage">postMessage()</a></code> API can be used as a <a id="web-messaging:tracking-vector-2" href="https://infra.spec.whatwg.org/#tracking-vector" data-x-internal="tracking-vector">tracking
  vector</a>.</p>


  <h4 id="introduction-12"><span class="secno">9.3.1</span> Introduction<a href="#introduction-12" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <div class="example">

   <p>For example, if document A contains an <code id="introduction-12:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element that contains document B,
   and script in document A calls <code id="introduction-12:dom-window-postmessage"><a href="#dom-window-postmessage">postMessage()</a></code> on the
   <code id="introduction-12:window"><a href="#window">Window</a></code> object of document B, then a message event will be fired on that object,
   marked as originating from the <code id="introduction-12:window-2"><a href="#window">Window</a></code> of document A. The script in document A might
   look like:</p>

   <pre><code class="js"><c- a="">var</c-> o <c- o="">=</c-> document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'iframe'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
o<c- p="">.</c->contentWindow<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'Hello world'</c-><c- p="">,</c-> <c- t="">'https://b.example.org/'</c-><c- p="">);</c-></code></pre>

   <p>To register an event handler for incoming events, the script would use <code>addEventListener()</code> (or similar mechanisms). For example, the script in document B
   might look like:</p>

   <pre><code class="js">window<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> receiver<c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->
<c- a="">function</c-> receiver<c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->origin <c- o="">==</c-> <c- t="">'https://example.com'</c-><c- p="">)</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->data <c- o="">==</c-> <c- t="">'Hello world'</c-><c- p="">)</c-> <c- p="">{</c->
      e<c- p="">.</c->source<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'Hello'</c-><c- p="">,</c-> e<c- p="">.</c->origin<c- p="">);</c->
    <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
      alert<c- p="">(</c->e<c- p="">.</c->data<c- p="">);</c->
    <c- p="">}</c->
  <c- p="">}</c->
<c- p="">}</c-></code></pre>

   <p>This script first checks the domain is the expected domain, and then looks at the message,
   which it either displays to the user, or responds to by sending a message back to the document
   which sent the message in the first place.</p>

  </div>


  <h4 id="security-postmsg"><span class="secno">9.3.2</span> Security<a href="#security-postmsg" class="self-link"></a></h4>

  

  <h5 id="authors"><span class="secno">9.3.2.1</span> Authors<a href="#authors" class="self-link"></a></h5>

  

  <p id="security-4" class="warning">Use of this API requires extra care to protect users from
  hostile entities abusing a site for their own purposes.</p>

  <p>Authors should check the <code id="authors:dom-messageevent-origin"><a href="#dom-messageevent-origin">origin</a></code> attribute to
  ensure that messages are only accepted from domains that they expect to receive messages from.
  Otherwise, bugs in the author's message handling code could be exploited by hostile sites.</p>

  <p>Furthermore, even after checking the <code id="authors:dom-messageevent-origin-2"><a href="#dom-messageevent-origin">origin</a></code>
  attribute, authors should also check that the data in question is of the expected format.
  Otherwise, if the source of the event has been attacked using a cross-site scripting flaw, further
  unchecked processing of information sent using the <code id="authors:dom-window-postmessage"><a href="#dom-window-postmessage">postMessage()</a></code> method could result in the attack being
  propagated into the receiver.</p>

  <p>Authors should not use the wildcard keyword (*) in the <var>targetOrigin</var>
  argument in messages that contain any confidential information, as otherwise there is no way to
  guarantee that the message is only delivered to the recipient to which it was intended.</p>

  <hr>

  <p>Authors who accept messages from any origin are encouraged to consider the risks of a
  denial-of-service attack. An attacker could send a high volume of messages; if the receiving page
  performs expensive computation or causes network traffic to be sent for each such message, the
  attacker's message could be multiplied into a denial-of-service attack. Authors are encouraged to
  employ rate limiting (only accepting a certain number of messages per minute) to make such attacks
  impractical.</p>


  

  <h5 id="user-agents"><span class="secno">9.3.2.2</span> User agents<a href="#user-agents" class="self-link"></a></h5>

  <p>The integrity of this API is based on the inability for scripts of one <a href="#concept-origin" id="user-agents:concept-origin">origin</a> to
  post arbitrary events (using <code>dispatchEvent()</code> or otherwise) to objects in
  other origins (those that are not the <a href="#same-origin" id="user-agents:same-origin">same</a>).</p>

  <p class="note">Implementers are urged to take extra care in the implementation of this feature.
  It allows authors to transmit information from one domain to another domain, which is normally
  disallowed for security reasons. It also requires that UAs be careful to allow access to certain
  properties but not others.</p>

  <hr>

  <p>User agents are also encouraged to consider rate-limiting message traffic between different
  <a href="#concept-origin" id="user-agents:concept-origin-2">origins</a>, to protect naïve sites from denial-of-service
  attacks.</p>

  



  <h4 id="posting-messages"><span class="secno">9.3.3</span> Posting messages<a href="#posting-messages" class="self-link"></a></h4>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-window-postmessage-options" id="dom-window-postmessage-options-dev">postMessage</a>(<var>message</var> [, <var>options</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage" title="The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.">Window/postMessage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>9.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></dt><dd>
    <p>Posts a message to the given window. Messages can be structured objects, e.g. nested objects
    and arrays, can contain JavaScript values (strings, numbers, <code id="posting-messages:date"><a data-x-internal="date" href="https://tc39.es/ecma262/#sec-date-objects">Date</a></code> objects, etc.),
    and can contain certain data objects such as <code id="posting-messages:file"><a data-x-internal="file" href="https://w3c.github.io/FileAPI/#dfn-file">File</a></code> <code id="posting-messages:blob"><a data-x-internal="blob" href="https://w3c.github.io/FileAPI/#dfn-Blob">Blob</a></code>,
    <code id="posting-messages:filelist"><a data-x-internal="filelist" href="https://w3c.github.io/FileAPI/#filelist-section">FileList</a></code>, and <code id="posting-messages:idl-arraybuffer"><a data-x-internal="idl-arraybuffer" href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer">ArrayBuffer</a></code> objects.</p>

    <p>Objects listed in the <code id="posting-messages:dom-structuredserializeoptions-transfer"><a href="#dom-structuredserializeoptions-transfer">transfer</a></code> member
    of <var>options</var> are transferred, not just cloned, meaning that they are no longer usable
    on the sending side.</p>

    <p>A target origin can be specified using the <code id="posting-messages:dom-windowpostmessageoptions-targetorigin"><a href="#dom-windowpostmessageoptions-targetorigin">targetOrigin</a></code> member of
    <var>options</var>. If not provided, it defaults to "<code>/</code>". This default
    restricts the message to same-origin targets only.</p>

    <p>If the origin of the target window doesn't match the given target origin, the message is
    discarded, to avoid information leakage. To send the message to the target regardless of origin,
    set the target origin to "<code>*</code>".</p>

    <p>Throws a <a id="posting-messages:datacloneerror" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="posting-messages:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    <var>transfer</var> array contains duplicate objects or if <var>message</var> could not be
    cloned.</p>
   </dd><dt><code><var>window</var>.<a href="#dom-window-postmessage" id="posting-messages:dom-window-postmessage">postMessage</a>(<var>message</var>, <var>targetOrigin</var> [, <var>transfer</var> ])</code></dt><dd><p>This is an alternate version of <code id="posting-messages:dom-window-postmessage-options"><a href="#dom-window-postmessage-options">postMessage()</a></code> where the target origin is specified
   as a parameter. Calling <code>window.postMessage(message, target, transfer)</code> is
   equivalent to <code>window.postMessage(message, {targetOrigin,
   transfer})</code>.</p></dd></dl>

  <p class="note">When posting a message to a <code id="posting-messages:window"><a href="#window">Window</a></code> of a <a href="#browsing-context" id="posting-messages:browsing-context">browsing context</a>
  that has just been navigated to a new <code id="posting-messages:document"><a href="#document">Document</a></code> is likely to result in the message not
  receiving its intended recipient: the scripts in the target <a href="#browsing-context" id="posting-messages:browsing-context-2">browsing context</a> have to
  have had time to set up listeners for the messages. Thus, for instance, in situations where a
  message is to be sent to the <code id="posting-messages:window-2"><a href="#window">Window</a></code> of newly created child <code id="posting-messages:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>,
  authors are advised to have the child <code id="posting-messages:document-2"><a href="#document">Document</a></code> post a message to their parent
  announcing their readiness to receive messages, and for the parent to wait for this message before
  beginning posting messages.</p>

  

  <div data-algorithm="">
  <p>The <dfn id="window-post-message-steps">window post message steps</dfn>, given a <var>targetWindow</var>, <var>message</var>,
  and <var>options</var>, are as follows:</p>

  <ol><li><p>Let <var>targetRealm</var> be <var>targetWindow</var>'s <a href="#concept-global-object-realm" id="posting-messages:concept-global-object-realm">realm</a>.</p></li><li><p>Let <var>incumbentSettings</var> be the <a href="#incumbent-settings-object" id="posting-messages:incumbent-settings-object">incumbent settings object</a>.</p></li><li><p>Let <var>targetOrigin</var> be <var>options</var>["<code id="posting-messages:dom-windowpostmessageoptions-targetorigin-2"><a href="#dom-windowpostmessageoptions-targetorigin">targetOrigin</a></code>"].</p></li><li><p>If <var>targetOrigin</var> is a single U+002F SOLIDUS character (/), then set
   <var>targetOrigin</var> to <var>incumbentSettings</var>'s <a href="#concept-settings-object-origin" id="posting-messages:concept-settings-object-origin">origin</a>.</p>

   </li><li>
    <p>Otherwise, if <var>targetOrigin</var> is not a single U+002A ASTERISK character (*),
    then:</p>

    <ol><li><p>Let <var>parsedURL</var> be the result of running the <a id="posting-messages:url-parser" href="https://url.spec.whatwg.org/#concept-url-parser" data-x-internal="url-parser">URL parser</a> on
     <var>targetOrigin</var>.</p></li><li><p>If <var>parsedURL</var> is failure, then throw a <a id="posting-messages:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
     <code id="posting-messages:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Set <var>targetOrigin</var> to <var>parsedURL</var>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="posting-messages:concept-url-origin" data-x-internal="concept-url-origin">origin</a>.</p></li></ol>
   </li><li><p>Let <var>transfer</var> be <var>options</var>["<code id="posting-messages:dom-structuredserializeoptions-transfer-2"><a href="#dom-structuredserializeoptions-transfer">transfer</a></code>"].</p></li><li><p>Let <var>serializeWithTransferResult</var> be
   <a href="#structuredserializewithtransfer" id="posting-messages:structuredserializewithtransfer">StructuredSerializeWithTransfer</a>(<var>message</var>, <var>transfer</var>). Rethrow
   any exceptions.</p></li><li>
    <p><a href="#queue-a-global-task" id="posting-messages:queue-a-global-task">Queue a global task</a> on the <dfn id="posted-message-task-source">posted message task source</dfn> given
    <var>targetWindow</var> to run the following steps:</p>

    <ol><li><p>If the <var>targetOrigin</var> argument is not a single literal U+002A ASTERISK character
     (*) and <var>targetWindow</var>'s <a href="#concept-document-window" id="posting-messages:concept-document-window">associated
     <code>Document</code></a>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="posting-messages:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is not
     <a href="#same-origin" id="posting-messages:same-origin">same origin</a> with <var>targetOrigin</var>, then return.</p></li><li><p>Let <var>origin</var> be the <a href="#ascii-serialisation-of-an-origin" id="posting-messages:ascii-serialisation-of-an-origin">serialization</a> of <var>incumbentSettings</var>'s <a href="#concept-settings-object-origin" id="posting-messages:concept-settings-object-origin-2">origin</a>.</p></li><li><p>Let <var>source</var> be the <code id="posting-messages:windowproxy"><a href="#windowproxy">WindowProxy</a></code> object corresponding to
     <var>incumbentSettings</var>'s <a href="#concept-settings-object-global" id="posting-messages:concept-settings-object-global">global
     object</a> (a <code id="posting-messages:window-3"><a href="#window">Window</a></code> object).</p></li><li>
      <p>Let <var>deserializeRecord</var> be
      <a href="#structureddeserializewithtransfer" id="posting-messages:structureddeserializewithtransfer">StructuredDeserializeWithTransfer</a>(<var>serializeWithTransferResult</var>,
      <var>targetRealm</var>).</p>

      <p>If this throws an exception, catch it, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="posting-messages:concept-event-fire" data-x-internal="concept-event-fire">fire an
      event</a> named <code id="posting-messages:event-messageerror"><a href="#event-messageerror">messageerror</a></code> at
      <var>targetWindow</var>, using <code id="posting-messages:messageevent"><a href="#messageevent">MessageEvent</a></code>, with the <code id="posting-messages:dom-messageevent-origin"><a href="#dom-messageevent-origin">origin</a></code> attribute initialized to <var>origin</var> and
      the <code id="posting-messages:dom-messageevent-source"><a href="#dom-messageevent-source">source</a></code> attribute initialized to
      <var>source</var>, and then return.</p>
     </li><li><p>Let <var>messageClone</var> be <var>deserializeRecord</var>.[[Deserialized]].</p></li><li><p>Let <var>newPorts</var> be a new <a id="posting-messages:frozen-array" href="https://webidl.spec.whatwg.org/#dfn-frozen-array-type" data-x-internal="frozen-array">frozen array</a> consisting of all
     <code id="posting-messages:messageport"><a href="#messageport">MessagePort</a></code> objects in <var>deserializeRecord</var>.[[TransferredValues]], if any,
     maintaining their relative order.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="posting-messages:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="posting-messages:event-message"><a href="#event-message">message</a></code> at <var>targetWindow</var>, using
     <code id="posting-messages:messageevent-2"><a href="#messageevent">MessageEvent</a></code>, with the <code id="posting-messages:dom-messageevent-origin-2"><a href="#dom-messageevent-origin">origin</a></code>
     attribute initialized to <var>origin</var>, the <code id="posting-messages:dom-messageevent-source-2"><a href="#dom-messageevent-source">source</a></code> attribute initialized to <var>source</var>, the
     <code id="posting-messages:dom-messageevent-data"><a href="#dom-messageevent-data">data</a></code> attribute initialized to
     <var>messageClone</var>, and the <code id="posting-messages:dom-messageevent-ports"><a href="#dom-messageevent-ports">ports</a></code> attribute
     initialized to <var>newPorts</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="posting-messages:window-4"><a href="#window">Window</a></code> interface's <dfn data-dfn-for="Window" id="dom-window-postmessage-options" data-dfn-type="method"><code>postMessage(<var>message</var>,
  <var>options</var>)</code></dfn> method steps are to run the <a href="#window-post-message-steps" id="posting-messages:window-post-message-steps">window post message
  steps</a> given <a id="posting-messages:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>message</var>, and <var>options</var>.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="posting-messages:window-5"><a href="#window">Window</a></code> interface's <dfn data-dfn-for="Window" id="dom-window-postmessage" data-dfn-type="method"><code>postMessage(<var>message</var>, <var>targetOrigin</var>,
  <var>transfer</var>)</code></dfn> method steps are to run the <a href="#window-post-message-steps" id="posting-messages:window-post-message-steps-2">window post message
  steps</a> given <a id="posting-messages:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>, <var>message</var>, and «[ "<code id="posting-messages:dom-windowpostmessageoptions-targetorigin-3"><a href="#dom-windowpostmessageoptions-targetorigin">targetOrigin</a></code>" →
  <var>targetOrigin</var>, "<code id="posting-messages:dom-structuredserializeoptions-transfer-3"><a href="#dom-structuredserializeoptions-transfer">transfer</a></code>"
  → <var>transfer</var> ]».</p>
  </div>

  




  <h3 id="channel-messaging"><span class="secno">9.4</span> <dfn>Channel messaging</dfn><a href="#channel-messaging" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API" title="The Channel Messaging API allows two separate scripts running in different browsing contexts attached to the same document (e.g., two IFrames, or the main document and an IFrame, two documents via a SharedWorker, or two workers) to communicate directly, passing messages between one another through two-way channels (or pipes) with a port at each end.">Channel_Messaging_API</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API/Using_channel_messaging" title="The Channel Messaging API allows two separate scripts running in different browsing contexts attached to the same document (e.g., two <iframe> elements, the main document and a single <iframe>, or two documents via a SharedWorker) to communicate directly, passing messages between each other through two-way channels (or pipes) with a port at each end.">Channel_Messaging_API/Using_channel_messaging</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <h4 id="introduction-13"><span class="secno">9.4.1</span> Introduction<a href="#introduction-13" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>To enable independent pieces of code (e.g. running in different <a href="#browsing-context" id="introduction-13:browsing-context">browsing contexts</a>) to communicate directly, authors can use <a href="#channel-messaging" id="introduction-13:channel-messaging">channel
  messaging</a>.</p>

  <p>Communication channels in this mechanism are implemented as two-ways pipes, with a port at each
  end. Messages sent in one port are delivered at the other port, and vice-versa. Messages are
  delivered as DOM events, without interrupting or blocking running <a href="#concept-task" id="introduction-13:concept-task">tasks</a>.</p>

  <p>To create a connection (two "entangled" ports), the <code>MessageChannel()</code>
  constructor is called:</p>

  <pre><code class="js"><c- a="">var</c-> channel <c- o="">=</c-> <c- k="">new</c-> MessageChannel<c- p="">();</c-></code></pre>

  <p>One of the ports is kept as the local port, and the other port is sent to the remote code, e.g.
  using <code id="introduction-13:dom-window-postmessage"><a href="#dom-window-postmessage">postMessage()</a></code>:</p>

  <pre><code class="js">otherWindow<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'hello'</c-><c- p="">,</c-> <c- t="">'https://example.com'</c-><c- p="">,</c-> <c- p="">[</c->channel<c- p="">.</c->port2<c- p="">]);</c-></code></pre>

  <p>To send messages, the <code id="introduction-13:dom-messageport-postmessage"><a href="#dom-messageport-postmessage">postMessage()</a></code> method on
  the port is used:</p>

  <pre><code class="js">channel<c- p="">.</c->port1<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'hello'</c-><c- p="">);</c-></code></pre>

  <p>To receive messages, one listens to <code id="introduction-13:event-message"><a href="#event-message">message</a></code> events:</p>

  <pre><code class="js">channel<c- p="">.</c->port1<c- p="">.</c->onmessage <c- o="">=</c-> handleMessage<c- p="">;</c->
<c- a="">function</c-> handleMessage<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  <c- c1="">// message is in event.data</c->
  <c- c1="">// ...</c->
<c- p="">}</c-></code></pre>

  <p>Data sent on a port can be structured data; for example here an array of strings is passed on a
  <code id="introduction-13:messageport"><a href="#messageport">MessagePort</a></code>:</p>

  <pre><code class="js">port1<c- p="">.</c->postMessage<c- p="">([</c-><c- t="">'hello'</c-><c- p="">,</c-> <c- t="">'world'</c-><c- p="">]);</c-></code></pre>


  <h5 id="examples-5"><span class="secno">9.4.1.1</span> Examples<a href="#examples-5" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <div class="example">

   <p>In this example, two JavaScript libraries are connected to each other using
   <code id="examples-5:messageport"><a href="#messageport">MessagePort</a></code>s. This allows the libraries to later be hosted in different frames, or
   in <code id="examples-5:worker"><a href="#worker">Worker</a></code> objects, without any change to the APIs.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"contacts.js"</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- exposes a contacts object --&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"compose-mail.js"</c-><c- p="">&gt;&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-> <c- c="">&lt;!-- exposes a composer object --&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- a="">var</c-> channel <c- o="">=</c-> <c- k="">new</c-> MessageChannel<c- p="">();</c->
 composer<c- p="">.</c->addContactsProvider<c- p="">(</c->channel<c- p="">.</c->port1<c- p="">);</c->
 contacts<c- p="">.</c->registerConsumer<c- p="">(</c->channel<c- p="">.</c->port2<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>Here's what the "addContactsProvider()" function's implementation could look like:</p>

   <pre><code class="js"><c- a="">function</c-> addContactsProvider<c- p="">(</c->port<c- p="">)</c-> <c- p="">{</c->
  port<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- k="">switch</c-> <c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->messageType<c- p="">)</c-> <c- p="">{</c->
      <c- k="">case</c-> <c- t="">'search-result'</c-><c- o="">:</c-> handleSearchResult<c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->results<c- p="">);</c-> <c- k="">break</c-><c- p="">;</c->
      <c- k="">case</c-> <c- t="">'search-done'</c-><c- o="">:</c-> handleSearchDone<c- p="">();</c-> <c- k="">break</c-><c- p="">;</c->
      <c- k="">case</c-> <c- t="">'search-error'</c-><c- o="">:</c-> handleSearchError<c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->message<c- p="">);</c-> <c- k="">break</c-><c- p="">;</c->
      <c- c1="">// ...</c->
    <c- p="">}</c->
  <c- p="">};</c->
<c- p="">};</c-></code></pre>

   <p>Alternatively, it could be implemented as follows:</p>

   <pre><code class="js"><c- a="">function</c-> addContactsProvider<c- p="">(</c->port<c- p="">)</c-> <c- p="">{</c->
  port<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->messageType <c- o="">==</c-> <c- t="">'search-result'</c-><c- p="">)</c->
      handleSearchResult<c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->results<c- p="">);</c->
  <c- p="">});</c->
  port<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->messageType <c- o="">==</c-> <c- t="">'search-done'</c-><c- p="">)</c->
      handleSearchDone<c- p="">();</c->
  <c- p="">});</c->
  port<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->messageType <c- o="">==</c-> <c- t="">'search-error'</c-><c- p="">)</c->
      handleSearchError<c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->message<c- p="">);</c->
  <c- p="">});</c->
  <c- c1="">// ...</c->
  port<c- p="">.</c->start<c- p="">();</c->
<c- p="">};</c-></code></pre>

   <p>The key difference is that when using <code id="examples-5:dom-eventtarget-addeventlistener"><a data-x-internal="dom-eventtarget-addeventlistener" href="https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener">addEventListener()</a></code>, the <code id="examples-5:dom-messageport-start"><a href="#dom-messageport-start">start()</a></code> method must also be invoked. When using <code id="examples-5:handler-messageeventtarget-onmessage"><a href="#handler-messageeventtarget-onmessage">onmessage</a></code>, the call to <code id="examples-5:dom-messageport-start-2"><a href="#dom-messageport-start">start()</a></code> is implied.</p>

   <p>The <code id="examples-5:dom-messageport-start-3"><a href="#dom-messageport-start">start()</a></code> method, whether called explicitly or
   implicitly (by setting <code id="examples-5:handler-messageeventtarget-onmessage-2"><a href="#handler-messageeventtarget-onmessage">onmessage</a></code>),
   starts the flow of messages: messages posted on message ports are initially paused, so that they
   don't get dropped on the floor before the script has had a chance to set up its handlers.</p>

  </div>


  <h5 id="ports-as-the-basis-of-an-object-capability-model-on-the-web"><span class="secno">9.4.1.2</span> Ports as the basis of an object-capability model on the web<a href="#ports-as-the-basis-of-an-object-capability-model-on-the-web" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <div data-var-scope="">
  <p>Ports can be viewed as a way to expose limited capabilities (in the object-capability model
  sense) to other actors in the system. This can either be a weak capability system, where the ports
  are merely used as a convenient model within a particular origin, or as a strong capability model,
  where they are provided by one origin <var>provider</var> as the only mechanism by which
  another origin <var>consumer</var> can effect change in or obtain information from <var>provider</var>.</p>
  </div>

  <p>For example, consider a situation in which a social web site embeds in one <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>
  the user's email contacts provider (an address book site, from a second origin), and in a second
  <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> a game (from a third origin). The outer social site and the game in the second
  <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code> cannot access anything inside the first <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:the-iframe-element-4"><a href="#the-iframe-element">iframe</a></code>; together they can
  only:</p>

  <ul><li><p><a href="#navigate" id="ports-as-the-basis-of-an-object-capability-model-on-the-web:navigate">Navigate</a> the <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:the-iframe-element-5"><a href="#the-iframe-element">iframe</a></code> to a new <a id="ports-as-the-basis-of-an-object-capability-model-on-the-web:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>, such as the same
   <a id="ports-as-the-basis-of-an-object-capability-model-on-the-web:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> but with a different <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="ports-as-the-basis-of-an-object-capability-model-on-the-web:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a>,
   causing the <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:window"><a href="#window">Window</a></code> in the <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:the-iframe-element-6"><a href="#the-iframe-element">iframe</a></code> to receive a <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:event-hashchange"><a href="#event-hashchange">hashchange</a></code> event.</p></li><li><p>Resize the <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:the-iframe-element-7"><a href="#the-iframe-element">iframe</a></code>, causing the <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:window-2"><a href="#window">Window</a></code> in the <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:the-iframe-element-8"><a href="#the-iframe-element">iframe</a></code>
   to receive a <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:event-resize"><a data-x-internal="event-resize" href="https://drafts.csswg.org/cssom-view/#eventdef-window-resize">resize</a></code> event.</p></li><li><p>Send a <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:event-message"><a href="#event-message">message</a></code> event to the <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:window-3"><a href="#window">Window</a></code> in the
   <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:the-iframe-element-9"><a href="#the-iframe-element">iframe</a></code> using the <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:dom-window-postmessage"><a href="#dom-window-postmessage">window.postMessage()</a></code>
   API.</p></li></ul>

  <p>The contacts provider can use these methods, most particularly the third one, to provide an API
  that can be accessed by other origins to manipulate the user's address book. For example, it could
  respond to a message "<code>add-contact Guillaume Tell
  &lt;tell@pomme.example.net&gt;</code>" by adding the given person and email address to the user's
  address book.</p>

  <p>To avoid any site on the web being able to manipulate the user's contacts, the contacts
  provider might only allow certain trusted sites, such as the social site, to do this.</p>

  <p>Now suppose the game wanted to add a contact to the user's address book, and that the social
  site was willing to allow it to do so on its behalf, essentially "sharing" the trust that the
  contacts provider had with the social site. There are several ways it could do this; most simply,
  it could just proxy messages between the game site and the contacts site. However, this solution
  has a number of difficulties: it requires the social site to either completely trust the game site
  not to abuse the privilege, or it requires that the social site verify each request to make sure
  it's not a request that it doesn't want to allow (such as adding multiple contacts, reading the
  contacts, or deleting them); it also requires some additional complexity if there's ever the
  possibility of multiple games simultaneously trying to interact with the contacts provider.</p>

  <p>Using message channels and <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:messageport"><a href="#messageport">MessagePort</a></code> objects, however, all of these problems can
  go away. When the game tells the social site that it wants to add a contact, the social site can
  ask the contacts provider not for it to add a contact, but for the <em>capability</em> to add a
  single contact. The contacts provider then creates a pair of <code id="ports-as-the-basis-of-an-object-capability-model-on-the-web:messageport-2"><a href="#messageport">MessagePort</a></code> objects, and
  sends one of them back to the social site, who forwards it on to the game. The game and the
  contacts provider then have a direct connection, and the contacts provider knows to only honor a
  single "add contact" request, nothing else. In other words, the game has been granted the
  capability to add a single contact.</p>


  <h5 id="ports-as-the-basis-of-abstracting-out-service-implementations"><span class="secno">9.4.1.3</span> Ports as the basis of abstracting out service implementations<a href="#ports-as-the-basis-of-abstracting-out-service-implementations" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Continuing the example from the previous section, consider the contacts provider in particular.
  While an initial implementation might have simply used <code id="ports-as-the-basis-of-abstracting-out-service-implementations:xmlhttprequest"><a data-x-internal="xmlhttprequest" href="https://xhr.spec.whatwg.org/#xmlhttprequest">XMLHttpRequest</a></code> objects in the
  service's <code id="ports-as-the-basis-of-abstracting-out-service-implementations:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, an evolution of the service might instead want to use a <a href="#sharedworker" id="ports-as-the-basis-of-abstracting-out-service-implementations:sharedworker">shared worker</a> with a single <code id="ports-as-the-basis-of-abstracting-out-service-implementations:websocket-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code> connection.</p>

  <p>If the initial design used <code id="ports-as-the-basis-of-abstracting-out-service-implementations:messageport"><a href="#messageport">MessagePort</a></code> objects to grant capabilities, or even just
  to allow multiple simultaneous independent sessions, the service implementation can switch from
  the <code id="ports-as-the-basis-of-abstracting-out-service-implementations:xmlhttprequest-2"><a data-x-internal="xmlhttprequest" href="https://xhr.spec.whatwg.org/#xmlhttprequest">XMLHttpRequest</a></code>s-in-each-<code id="ports-as-the-basis-of-abstracting-out-service-implementations:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> model to the
  shared-<code id="ports-as-the-basis-of-abstracting-out-service-implementations:websocket-2-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code> model without changing the API at all: the ports on the service
  provider side can all be forwarded to the shared worker without it affecting the users of the API
  in the slightest.</p>



  <h4 id="message-channels"><span class="secno">9.4.2</span> Message channels<a href="#message-channels" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel" title="The MessageChannel interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.">MessageChannel</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="messagechannel" data-dfn-type="interface"><c- g="">MessageChannel</c-></dfn> {
  <a href="#dom-messagechannel" id="message-channels:dom-messagechannel"><c- g="">constructor</c-></a>();

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#messageport" id="message-channels:messageport"><c- n="">MessagePort</c-></a> <a href="#dom-messagechannel-port1" id="message-channels:dom-messagechannel-port1"><c- g="">port1</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#messageport" id="message-channels:messageport-2"><c- n="">MessagePort</c-></a> <a href="#dom-messagechannel-port2" id="message-channels:dom-messagechannel-port2"><c- g="">port2</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>channel</var> = new <a href="#dom-messagechannel" id="dom-messagechannel-dev">MessageChannel</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel/MessageChannel" title="The MessageChannel() constructor of the MessageChannel interface returns a new MessageChannel object with two new MessagePort objects.">MessageChannel/MessageChannel</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>Returns a new <code id="message-channels:messagechannel"><a href="#messagechannel">MessageChannel</a></code> object with two new <code id="message-channels:messageport-3"><a href="#messageport">MessagePort</a></code>
    objects.</p>
   </dd><dt><code><var>channel</var>.<a href="#dom-messagechannel-port1" id="dom-messagechannel-port1-dev">port1</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel/port1" title="The port1 read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.">MessageChannel/port1</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Returns the first <code id="message-channels:messageport-4"><a href="#messageport">MessagePort</a></code> object.</p></dd><dt><code><var>channel</var>.<a href="#dom-messagechannel-port2" id="dom-messagechannel-port2-dev">port2</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel/port2" title="The port2 read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.">MessageChannel/port2</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Returns the second <code id="message-channels:messageport-5"><a href="#messageport">MessagePort</a></code> object.</p></dd></dl>

  

  <p>A <code id="message-channels:messagechannel-2"><a href="#messagechannel">MessageChannel</a></code> object has an associated <dfn id="port-1">port 1</dfn> and an associated
  <dfn id="port-2">port 2</dfn>, both <code id="message-channels:messageport-6"><a href="#messageport">MessagePort</a></code> objects.</p>

  <div data-algorithm="">
  <p>The <dfn id="dom-messagechannel"><code>new MessageChannel()</code></dfn> constructor steps
  are:</p>

  <ol><li><p>Set <a id="message-channels:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#port-1" id="message-channels:port-1">port 1</a> to a <a id="message-channels:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a>
   <code id="message-channels:messageport-7"><a href="#messageport">MessagePort</a></code> in <a id="message-channels:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-realm" id="message-channels:concept-relevant-realm">relevant
   realm</a>.</p></li><li><p>Set <a id="message-channels:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#port-2" id="message-channels:port-2">port 2</a> to a <a id="message-channels:new-2" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a>
   <code id="message-channels:messageport-8"><a href="#messageport">MessagePort</a></code> in <a id="message-channels:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-realm" id="message-channels:concept-relevant-realm-2">relevant
   realm</a>.</p></li><li><p><a href="#entangle" id="message-channels:entangle">Entangle</a> <a id="message-channels:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#port-1" id="message-channels:port-1-2">port 1</a> and <a id="message-channels:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
   <a href="#port-2" id="message-channels:port-2-2">port 2</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessageChannel" id="dom-messagechannel-port1" data-dfn-type="attribute"><code>port1</code></dfn> getter steps are to return
  <a id="message-channels:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#port-1" id="message-channels:port-1-3">port 1</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessageChannel" id="dom-messagechannel-port2" data-dfn-type="attribute"><code>port2</code></dfn> getter steps are to return
  <a id="message-channels:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#port-2" id="message-channels:port-2-3">port 2</a>.</p>
  </div>

  

  <h4 id="the-messageeventtarget-mixin"><span class="secno">9.4.3</span> <span id="the-messageeventtarget-abstract-interface"></span>The
  <code id="the-messageeventtarget-mixin:messageeventtarget"><a href="#messageeventtarget">MessageEventTarget</a></code> mixin<a href="#the-messageeventtarget-mixin" class="self-link"></a></h4>
  

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="messageeventtarget" data-dfn-type="interface"><c- g="">MessageEventTarget</c-></dfn> {
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-messageeventtarget-mixin:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-messageeventtarget-onmessage" id="the-messageeventtarget-mixin:handler-messageeventtarget-onmessage"><c- g="">onmessage</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-messageeventtarget-mixin:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-messageeventtarget-onmessageerror" id="the-messageeventtarget-mixin:handler-messageeventtarget-onmessageerror"><c- g="">onmessageerror</c-></a>;
};</code></pre>

   <p>The following are the <a href="#event-handlers" id="the-messageeventtarget-mixin:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="the-messageeventtarget-mixin:event-handler-event-type">event handler event types</a>) that must be supported,
   as <a href="#event-handler-idl-attributes" id="the-messageeventtarget-mixin:event-handler-idl-attributes">event handler IDL attributes</a>, by objects implementing the
   <code id="the-messageeventtarget-mixin:messageeventtarget-2"><a href="#messageeventtarget">MessageEventTarget</a></code> interface:</p>

   <table><thead><tr><th><a href="#event-handlers" id="the-messageeventtarget-mixin:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="the-messageeventtarget-mixin:event-handler-event-type-2">Event handler event type</a>
    </th></tr></thead><tbody><tr><td><span id="handler-messageport-onmessage"></span><span id="handler-worker-onmessage"></span><span id="handler-dedicatedworkerglobalscope-onmessage"></span><dfn data-dfn-for="MessageEventTarget" id="handler-messageeventtarget-onmessage" data-dfn-type="attribute"><code>onmessage</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/message_event" title="The message event is fired on a MessagePort object when a message arrives on that channel.">MessagePort/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.5+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/message_event" title="The message event is fired on a DedicatedWorkerGlobalScope object when the worker receives a message from its parent (i.e. when the parent sends a message using Worker.postMessage()).">DedicatedWorkerGlobalScope/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.5+</span></span></div></div></div></td><td> <code id="the-messageeventtarget-mixin:event-message"><a href="#event-message">message</a></code>
     </td></tr><tr><td><span id="handler-messageport-onmessageerror"></span><span id="handler-worker-onmessageerror"></span><span id="handler-dedicatedworkerglobalscope-onmessageerror"></span><dfn data-dfn-for="MessageEventTarget" id="handler-messageeventtarget-onmessageerror" data-dfn-type="attribute"><code>onmessageerror</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/messageerror_event" title="The messageerror event is fired on a MessagePort object when it receives a message that can't be deserialized.">MessagePort/messageerror_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event" title="The messageerror event is fired on a DedicatedWorkerGlobalScope object when it receives a message that can't be deserialized.">DedicatedWorkerGlobalScope/messageerror_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></td><td> <code id="the-messageeventtarget-mixin:event-messageerror"><a href="#event-messageerror">messageerror</a></code>
   </td></tr></tbody></table>

  <h4 id="message-ports"><span class="secno">9.4.4</span> Message ports<a href="#message-ports" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort" title="The MessagePort interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.">MessagePort</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <p>Each channel has two message ports. Data sent through one port is received by the other port,
  and vice versa.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->,<c- n="">AudioWorklet</c->), <a href="#transferable" id="message-ports:transferable"><c- g="">Transferable</c-></a>]
<c- b="">interface</c-> <dfn id="messageport" data-dfn-type="interface"><c- g="">MessagePort</c-></dfn> : <a id="message-ports:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <c- b="">undefined</c-> <a href="#dom-messageport-postmessage" id="message-ports:dom-messageport-postmessage"><c- g="">postMessage</c-></a>(<c- b="">any</c-> <c- g="">message</c->, <c- b="">sequence</c->&lt;<a href="https://webidl.spec.whatwg.org/#idl-object" id="message-ports:idl-object" data-x-internal="idl-object"><c- b="">object</c-></a>&gt; <c- g="">transfer</c->);
  <c- b="">undefined</c-> <a href="#dom-messageport-postmessage-options" id="message-ports:dom-messageport-postmessage-options"><c- g="">postMessage</c-></a>(<c- b="">any</c-> <c- g="">message</c->, <c- b="">optional</c-> <a href="#structuredserializeoptions" id="message-ports:structuredserializeoptions"><c- n="">StructuredSerializeOptions</c-></a> <c- g="">options</c-> = {});
  <c- b="">undefined</c-> <a href="#dom-messageport-start" id="message-ports:dom-messageport-start"><c- g="">start</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-messageport-close" id="message-ports:dom-messageport-close"><c- g="">close</c-></a>();

  // event handlers
  <c- b="">attribute</c-> <a href="#eventhandler" id="message-ports:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-messageport-onclose" id="message-ports:handler-messageport-onclose"><c- g="">onclose</c-></a>;
};

<a href="#messageport" id="message-ports:messageport"><c- n="">MessagePort</c-></a> <c- b="">includes</c-> <a href="#messageeventtarget" id="message-ports:messageeventtarget"><c- n="">MessageEventTarget</c-></a>;

<c- b="">dictionary</c-> <dfn id="structuredserializeoptions" data-dfn-type="dictionary"><c- g="">StructuredSerializeOptions</c-></dfn> {
  <c- b="">sequence</c->&lt;<a href="https://webidl.spec.whatwg.org/#idl-object" id="message-ports:idl-object-2" data-x-internal="idl-object"><c- b="">object</c-></a>&gt; <dfn data-dfn-for="StructuredSerializeOptions" id="dom-structuredserializeoptions-transfer" data-dfn-type="dict-member"><c- g="">transfer</c-></dfn> = [];
};</code></pre>

  <dl class="domintro"><dt><code><var>port</var>.<a href="#dom-messageport-postmessage" id="dom-messageport-postmessage-dev">postMessage</a>(<var>message</var> [, <var>transfer</var>])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage" title="The postMessage() method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.">MessagePort/postMessage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dt><code><var>port</var>.<a href="#dom-messageport-postmessage-options" id="dom-messageport-postmessage-options-dev">postMessage</a>(<var>message</var> [, { <span>transfer</span> }])</code></dt><dd>
    <p>Posts a message through the channel. Objects listed in <var>transfer</var> are transferred,
    not just cloned, meaning that they are no longer usable on the sending side.</p>

    <p>Throws a <a id="message-ports:datacloneerror" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a> <code id="message-ports:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if
    <var>transfer</var> contains duplicate objects or <var>port</var>, or if <var>message</var>
    could not be cloned.</p>
   </dd><dt><code><var>port</var>.<a href="#dom-messageport-start" id="dom-messageport-start-dev">start</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/start" title="The start() method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.">MessagePort/start</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Begins dispatching messages received on the port.</p></dd><dt><code><var>port</var>.<a href="#dom-messageport-close" id="dom-messageport-close-dev">close</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/close" title="The close() method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.">MessagePort/close</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Disconnects the port, so that it is no longer active.</p></dd></dl>

  

  <p>Each <code id="message-ports:messageport-2"><a href="#messageport">MessagePort</a></code> object has a <dfn id="message-event-target">message event target</dfn> (a
  <code id="message-ports:messageeventtarget-2"><a href="#messageeventtarget">MessageEventTarget</a></code>), to which the <code id="message-ports:event-message"><a href="#event-message">message</a></code> and <code id="message-ports:event-messageerror"><a href="#event-messageerror">messageerror</a></code> events are dispatched. Unless otherwise
  specified, it defaults to the <code id="message-ports:messageport-3"><a href="#messageport">MessagePort</a></code> object itself.</p>

  <p>Each <code id="message-ports:messageport-4"><a href="#messageport">MessagePort</a></code> object can be entangled with another (a symmetric relationship).
  Each <code id="message-ports:messageport-5"><a href="#messageport">MessagePort</a></code> object also has a <a href="#task-source" id="message-ports:task-source">task source</a> called the <dfn id="port-message-queue">port
  message queue</dfn>, initially empty. A <a href="#port-message-queue" id="message-ports:port-message-queue">port message queue</a> can be enabled or
  disabled, and is initially disabled. Once enabled, a port can never be disabled again (though
  messages in the queue can get moved to another queue or removed altogether, which has much the
  same effect). A <code id="message-ports:messageport-6"><a href="#messageport">MessagePort</a></code> also has a <dfn id="has-been-shipped">has been shipped</dfn> flag, which must
  initially be false.</p>

  <div data-algorithm="">
  <p>When a port's <a href="#port-message-queue" id="message-ports:port-message-queue-2">port message queue</a> is enabled, the <a href="#event-loop" id="message-ports:event-loop">event loop</a> must use
  it as one of its <a href="#task-source" id="message-ports:task-source-2">task sources</a>. When a port's <a href="#concept-relevant-global" id="message-ports:concept-relevant-global">relevant
  global object</a> is a <code id="message-ports:window"><a href="#window">Window</a></code>, all <a href="#concept-task" id="message-ports:concept-task">tasks</a> <a href="#queue-a-task" id="message-ports:queue-a-task">queued</a> on its <a href="#port-message-queue" id="message-ports:port-message-queue-3">port message queue</a> must be associated with
  the port's <a href="#concept-relevant-global" id="message-ports:concept-relevant-global-2">relevant global object</a>'s <a href="#concept-document-window" id="message-ports:concept-document-window">associated
  <code>Document</code></a>.</p>
  </div>

  <p class="note">If the document is <a href="#fully-active" id="message-ports:fully-active">fully active</a>, but the event listeners were all
  created in the context of documents that are <em>not</em> <a href="#fully-active" id="message-ports:fully-active-2">fully active</a>, then the
  messages will not be received unless and until the documents become <a href="#fully-active" id="message-ports:fully-active-3">fully active</a>
  again.</p>

  <div data-algorithm="">
  <p>Each <a href="#event-loop" id="message-ports:event-loop-2">event loop</a> has a <a href="#task-source" id="message-ports:task-source-3">task source</a> called the <dfn id="unshipped-port-message-queue">unshipped port
  message queue</dfn>. This is a virtual <a href="#task-source" id="message-ports:task-source-4">task source</a>: it must act as if it contained
  the <a href="#concept-task" id="message-ports:concept-task-2">tasks</a> of each <a href="#port-message-queue" id="message-ports:port-message-queue-4">port message queue</a> of each
  <code id="message-ports:messageport-7"><a href="#messageport">MessagePort</a></code> whose <a href="#has-been-shipped" id="message-ports:has-been-shipped">has been shipped</a> flag is false, whose <a href="#port-message-queue" id="message-ports:port-message-queue-5">port
  message queue</a> is enabled, and whose <a href="#relevant-agent" id="message-ports:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="message-ports:concept-agent-event-loop">event loop</a> is that <a href="#event-loop" id="message-ports:event-loop-3">event loop</a>, in the order
  in which they were added to their respective <a href="#task-source" id="message-ports:task-source-5">task source</a>. When a <a href="#concept-task" id="message-ports:concept-task-3">task</a> would be removed from the <a href="#unshipped-port-message-queue" id="message-ports:unshipped-port-message-queue">unshipped port message
  queue</a>, it must instead be removed from its <a href="#port-message-queue" id="message-ports:port-message-queue-6">port message queue</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="message-ports:messageport-8"><a href="#messageport">MessagePort</a></code>'s <a href="#has-been-shipped" id="message-ports:has-been-shipped-2">has been shipped</a> flag is false, its <a href="#port-message-queue" id="message-ports:port-message-queue-7">port
  message queue</a> must be ignored for the purposes of the <a href="#event-loop" id="message-ports:event-loop-4">event loop</a>. (The
  <a href="#unshipped-port-message-queue" id="message-ports:unshipped-port-message-queue-2">unshipped port message queue</a> is used instead.)</p>
  </div>

  <p class="note">The <a href="#has-been-shipped" id="message-ports:has-been-shipped-3">has been shipped</a> flag is set to true when a port, its twin, or
  the object it was cloned from, is or has been transferred. When a <code id="message-ports:messageport-9"><a href="#messageport">MessagePort</a></code>'s
  <a href="#has-been-shipped" id="message-ports:has-been-shipped-4">has been shipped</a> flag is true, its <a href="#port-message-queue" id="message-ports:port-message-queue-8">port message queue</a> acts as a
  first-class <a href="#task-source" id="message-ports:task-source-6">task source</a>, unaffected to any <a href="#unshipped-port-message-queue" id="message-ports:unshipped-port-message-queue-3">unshipped port message
  queue</a>.</p>

  <div data-algorithm="">
  <p>When the user agent is to <dfn id="entangle">entangle</dfn> two <code id="message-ports:messageport-10"><a href="#messageport">MessagePort</a></code> objects, it must run
  the following steps:</p>

  <ol><li>
    <p>If one of the ports is already entangled, then disentangle it and the port that it was
    entangled with.</p>

    <p class="note">If those two previously entangled ports were the two ports of a
    <code id="message-ports:messagechannel"><a href="#messagechannel">MessageChannel</a></code> object, then that <code id="message-ports:messagechannel-2"><a href="#messagechannel">MessageChannel</a></code> object no longer
    represents an actual channel: the two ports in that object are no longer entangled.</p>
   </li><li>
    <p>Associate the two ports to be entangled, so that they form the two parts of a new channel.
    (There is no <code id="message-ports:messagechannel-3"><a href="#messagechannel">MessageChannel</a></code> object that represents this channel.)</p>

    <p>Two ports <var>A</var> and <var>B</var> that have gone through this step
    are now said to be entangled; one is entangled to the other, and vice versa.</p>

    <p class="note">While this specification describes this process as instantaneous,
    implementations are more likely to implement it via message passing. As with all algorithms, the
    key is "merely" that the end result be indistinguishable, in a black-box sense, from the
    specification.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="disentangle">disentangle</dfn> steps, given a <code id="message-ports:messageport-11"><a href="#messageport">MessagePort</a></code> <var>initiatorPort</var>
  which initiates disentangling, are as follows:</p>

  <ol><li><p>Let <var>otherPort</var> be the <code id="message-ports:messageport-12"><a href="#messageport">MessagePort</a></code> which <var>initiatorPort</var>
   was entangled with.</p></li><li><p><a id="message-ports:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>otherPort</var> exists.</p></li><li><p>Disentangle <var>initiatorPort</var> and <var>otherPort</var>, so that they are no longer
   entangled or associated with each other.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="message-ports:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="message-ports:event-close"><a href="#event-close">close</a></code> at <var>otherPort</var>.</p></li></ol>

  <div class="note">
   <p>The <code id="message-ports:event-close-2"><a href="#event-close">close</a></code> event will be fired even if the port is not
   explicitly closed. The cases where this event is dispatched are:</p>

   <ul><li>the <code id="message-ports:dom-messageport-close-2"><a href="#dom-messageport-close">close()</a></code> method was called;</li><li>the <code id="message-ports:document"><a href="#document">Document</a></code> was <a href="#destroy-a-document" id="message-ports:destroy-a-document">destroyed</a>; or</li><li>the <code id="message-ports:messageport-13"><a href="#messageport">MessagePort</a></code> was <a href="#ports-and-garbage-collection">garbage
    collected</a>.</li></ul>

   <p>We only dispatch the event on <var>otherPort</var> because <var>initiatorPort</var> explicitly
   triggered the close, its <code id="message-ports:document-2"><a href="#document">Document</a></code> no longer exists, or it was already garbage
   collected, as described above.</p>
  </div>
  </div>

  <hr>

  <div data-algorithm="">
  <p id="transferMessagePort"><code id="message-ports:messageport-14"><a href="#messageport">MessagePort</a></code> objects are <a href="#transferable-objects" id="message-ports:transferable-objects">transferable
  objects</a>. Their <a href="#transfer-steps" id="message-ports:transfer-steps">transfer steps</a>, given <var>value</var> and
  <var>dataHolder</var>, are:</p>

  <ol><li><p>Set <var>value</var>'s <a href="#has-been-shipped" id="message-ports:has-been-shipped-5">has been shipped</a> flag to true.</p></li><li><p>Set <var>dataHolder</var>.[[PortMessageQueue]] to <var>value</var>'s <a href="#port-message-queue" id="message-ports:port-message-queue-9">port message
   queue</a>.</p></li><li>
    <p>If <var>value</var> is entangled with another port <var>remotePort</var>, then:</p>

    <ol><li><p>Set <var>remotePort</var>'s <a href="#has-been-shipped" id="message-ports:has-been-shipped-6">has been shipped</a> flag to true.</p></li><li><p>Set <var>dataHolder</var>.[[RemotePort]] to <var>remotePort</var>.</p></li></ol>
   </li><li><p>Otherwise, set <var>dataHolder</var>.[[RemotePort]] to null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>Their <a href="#transfer-receiving-steps" id="message-ports:transfer-receiving-steps">transfer-receiving steps</a>, given <var>dataHolder</var> and <var>value</var>,
  are:</p>

  <ol><li><p>Set <var>value</var>'s <a href="#has-been-shipped" id="message-ports:has-been-shipped-7">has been shipped</a> flag to true.</p></li><li><p>Move all the <a href="#concept-task" id="message-ports:concept-task-4">tasks</a> that are to fire <code id="message-ports:event-message-2"><a href="#event-message">message</a></code> events in <var>dataHolder</var>.[[PortMessageQueue]] to the
   <a href="#port-message-queue" id="message-ports:port-message-queue-10">port message queue</a> of <var>value</var>, if any, leaving <var>value</var>'s
   <a href="#port-message-queue" id="message-ports:port-message-queue-11">port message queue</a> in its initial disabled state, and, if <var>value</var>'s
   <a href="#concept-relevant-global" id="message-ports:concept-relevant-global-3">relevant global object</a> is a <code id="message-ports:window-2"><a href="#window">Window</a></code>, associating the moved <a href="#concept-task" id="message-ports:concept-task-5">tasks</a> with <var>value</var>'s <a href="#concept-relevant-global" id="message-ports:concept-relevant-global-4">relevant global object</a>'s
   <a href="#concept-document-window" id="message-ports:concept-document-window-2">associated <code>Document</code></a>.</p></li><li><p>If <var>dataHolder</var>.[[RemotePort]] is not null, then <a href="#entangle" id="message-ports:entangle">entangle</a>
   <var>dataHolder</var>.[[RemotePort]] and <var>value</var>. (This will disentangle
   <var>dataHolder</var>.[[RemotePort]] from the original port that was transferred.)</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn id="message-port-post-message-steps">message port post message steps</dfn>, given <var>sourcePort</var>,
  <var>targetPort</var>, <var>message</var>, and <var>options</var> are as follows:</p>

  <ol><li><p>Let <var>transfer</var> be <var>options</var>["<code id="message-ports:dom-structuredserializeoptions-transfer"><a href="#dom-structuredserializeoptions-transfer">transfer</a></code>"].</p></li><li><p>If <var>transfer</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="message-ports:list-contains" data-x-internal="list-contains">contains</a>
   <var>sourcePort</var>, then throw a <a id="message-ports:datacloneerror-2" href="https://webidl.spec.whatwg.org/#datacloneerror" data-x-internal="datacloneerror">"<code>DataCloneError</code>"</a>
   <code id="message-ports:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>doomed</var> be false.</p></li><li><p>If <var>targetPort</var> is not null and <var>transfer</var> <a href="https://infra.spec.whatwg.org/#list-contain" id="message-ports:list-contains-2" data-x-internal="list-contains">contains</a> <var>targetPort</var>, then set <var>doomed</var> to true and
   optionally report to a developer console that the target port was posted to itself, causing the
   communication channel to be lost.</p></li><li><p>Let <var>serializeWithTransferResult</var> be
   <a href="#structuredserializewithtransfer" id="message-ports:structuredserializewithtransfer">StructuredSerializeWithTransfer</a>(<var>message</var>, <var>transfer</var>). Rethrow
   any exceptions.</p></li><li><p>If <var>targetPort</var> is null, or if <var>doomed</var> is true, then return.</p></li><li>
    <p>Add a <a href="#concept-task" id="message-ports:concept-task-6">task</a> that runs the following steps to the <a href="#port-message-queue" id="message-ports:port-message-queue-12">port
    message queue</a> of <var>targetPort</var>:</p>

    <ol><li>
      <p>Let <var>finalTargetPort</var> be the <code id="message-ports:messageport-15"><a href="#messageport">MessagePort</a></code> in whose <a href="#port-message-queue" id="message-ports:port-message-queue-13">port message
      queue</a> the task now finds itself.</p>

      <p class="note">This can be different from <var>targetPort</var>, if <var>targetPort</var>
      itself was transferred and thus all its tasks moved along with it.</p>
     </li><li><p>Let <var>messageEventTarget</var> be <var>finalTargetPort</var>'s <a href="#message-event-target" id="message-ports:message-event-target">message event
     target</a>.</p></li><li><p>Let <var>targetRealm</var> be <var>finalTargetPort</var>'s <a href="#concept-relevant-realm" id="message-ports:concept-relevant-realm">relevant realm</a>.</p></li><li>
      <p>Let <var>deserializeRecord</var> be
      <a href="#structureddeserializewithtransfer" id="message-ports:structureddeserializewithtransfer">StructuredDeserializeWithTransfer</a>(<var>serializeWithTransferResult</var>,
      <var>targetRealm</var>).</p>

      <p>If this throws an exception, catch it, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="message-ports:concept-event-fire-2" data-x-internal="concept-event-fire">fire an
      event</a> named <code id="message-ports:event-messageerror-2"><a href="#event-messageerror">messageerror</a></code> at
      <var>messageEventTarget</var>, using <code id="message-ports:messageevent"><a href="#messageevent">MessageEvent</a></code>, and then return.
     </p></li><li><p>Let <var>messageClone</var> be <var>deserializeRecord</var>.[[Deserialized]].</p></li><li><p>Let <var>newPorts</var> be a new <a id="message-ports:frozen-array" href="https://webidl.spec.whatwg.org/#dfn-frozen-array-type" data-x-internal="frozen-array">frozen array</a> consisting of all
     <code id="message-ports:messageport-16"><a href="#messageport">MessagePort</a></code> objects in <var>deserializeRecord</var>.[[TransferredValues]], if any,
     maintaining their relative order.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="message-ports:concept-event-fire-3" data-x-internal="concept-event-fire">Fire an event</a> named <code id="message-ports:event-message-3"><a href="#event-message">message</a></code> at <var>messageEventTarget</var>, using
     <code id="message-ports:messageevent-2"><a href="#messageevent">MessageEvent</a></code>, with the <code id="message-ports:dom-messageevent-data"><a href="#dom-messageevent-data">data</a></code> attribute
     initialized to <var>messageClone</var> and the <code id="message-ports:dom-messageevent-ports"><a href="#dom-messageevent-ports">ports</a></code> attribute initialized to
     <var>newPorts</var>.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessagePort" id="dom-messageport-postmessage-options" data-dfn-type="method"><code>postMessage(<var>message</var>,
  <var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>targetPort</var> be the port with which <a id="message-ports:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is entangled, if any;
   otherwise let it be null.</p></li><li><p>Run the <a href="#message-port-post-message-steps" id="message-ports:message-port-post-message-steps">message port post message steps</a> providing <a id="message-ports:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>,
   <var>targetPort</var>, <var>message</var> and <var>options</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessagePort" id="dom-messageport-postmessage" data-dfn-type="method"><code>postMessage(<var>message</var>,
  <var>transfer</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>targetPort</var> be the port with which <a id="message-ports:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is entangled, if any;
   otherwise let it be null.</p></li><li><p>Let <var>options</var> be «[ "<code id="message-ports:dom-structuredserializeoptions-transfer-2"><a href="#dom-structuredserializeoptions-transfer">transfer</a></code>" → <var>transfer</var>
   ]».</p></li><li><p>Run the <a href="#message-port-post-message-steps" id="message-ports:message-port-post-message-steps-2">message port post message steps</a> providing <a id="message-ports:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>,
   <var>targetPort</var>, <var>message</var> and <var>options</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessagePort" id="dom-messageport-start" data-dfn-type="method"><code>start()</code></dfn>
  method steps are to enable <a id="message-ports:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#port-message-queue" id="message-ports:port-message-queue-14">port message queue</a>, if it is not
  already enabled.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="MessagePort" id="dom-messageport-close" data-dfn-type="method"><code>close()</code></dfn>
  method steps are:</p>

  <ol><li><p>Set <a id="message-ports:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#detached" id="message-ports:detached">[[Detached]]</a> internal slot value to true.</p></li><li><p>If <a id="message-ports:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is entangled, <a href="#disentangle" id="message-ports:disentangle">disentangle</a> it.</p></li></ol>
  </div>

  <hr>

  <p>The following are the <a href="#event-handlers" id="message-ports:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="message-ports:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="message-ports:event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the
  <code id="message-ports:messageport-17"><a href="#messageport">MessagePort</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="message-ports:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="message-ports:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="MessagePort" id="handler-messageport-onclose" data-dfn-type="attribute"><code>onclose</code></dfn> </td><td> <code id="message-ports:event-close-3"><a href="#event-close">close</a></code>
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The first time a <code id="message-ports:messageport-18"><a href="#messageport">MessagePort</a></code> object's <code id="message-ports:handler-messageeventtarget-onmessage"><a href="#handler-messageeventtarget-onmessage">onmessage</a></code> IDL attribute is set, the port's
  <a href="#port-message-queue" id="message-ports:port-message-queue-15">port message queue</a> must be enabled, as if the <code id="message-ports:dom-messageport-start-2"><a href="#dom-messageport-start">start()</a></code> method had been called.</p>
  </div>

  


  <h4 id="ports-and-garbage-collection"><span class="secno">9.4.5</span> Ports and garbage collection<a href="#ports-and-garbage-collection" class="self-link"></a></h4>

  
  <div data-algorithm="">
  <p>When a <code id="ports-and-garbage-collection:messageport"><a href="#messageport">MessagePort</a></code> object <var>o</var> is garbage collected, if <var>o</var> is
  entangled, then the user agent must <a href="#disentangle" id="ports-and-garbage-collection:disentangle">disentangle</a>
  <var>o</var>.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="ports-and-garbage-collection:messageport-2"><a href="#messageport">MessagePort</a></code> object <var>o</var> is entangled and <code id="ports-and-garbage-collection:event-message"><a href="#event-message">message</a></code> or <code id="ports-and-garbage-collection:event-messageerror"><a href="#event-messageerror">messageerror</a></code>
  event listener is registered, user agents must act as if <var>o</var>'s entangled
  <code id="ports-and-garbage-collection:messageport-3"><a href="#messageport">MessagePort</a></code> object has a strong reference to <var>o</var>.</p>
  </div>

  <p>Furthermore, a <code id="ports-and-garbage-collection:messageport-4"><a href="#messageport">MessagePort</a></code> object must not be garbage collected while there
  exists an event referenced by a <a href="#concept-task" id="ports-and-garbage-collection:concept-task">task</a> in a <a href="#task-queue" id="ports-and-garbage-collection:task-queue">task
  queue</a> that is to be dispatched on that <code id="ports-and-garbage-collection:messageport-5"><a href="#messageport">MessagePort</a></code> object, or while the
  <code id="ports-and-garbage-collection:messageport-6"><a href="#messageport">MessagePort</a></code> object's <a href="#port-message-queue" id="ports-and-garbage-collection:port-message-queue">port message queue</a> is enabled and not empty.</p>
  

  

  <div class="note">

   <p>Thus, a message port can be received, given an event listener, and then forgotten, and so long
   as that event listener could receive a message, the channel will be maintained.</p>

   <p>Of course, if this was to occur on both sides of the channel, then both ports could be garbage
   collected, since they would not be reachable from live code, despite having a strong reference to
   each other. However, if a message port has a pending message, it is not garbage collected.</p>

  </div>

  

  <p class="note">Authors are strongly encouraged to explicitly close <code id="ports-and-garbage-collection:messageport-7"><a href="#messageport">MessagePort</a></code>
  objects to disentangle them, so that their resources can be recollected. Creating many
  <code id="ports-and-garbage-collection:messageport-8"><a href="#messageport">MessagePort</a></code> objects and discarding them without closing them can lead to high
  transient memory usage since garbage collection is not necessarily performed promptly, especially
  for <code id="ports-and-garbage-collection:messageport-9"><a href="#messageport">MessagePort</a></code>s where garbage collection can involve cross-process coordination.</p>



  <h3 id="broadcasting-to-other-browsing-contexts"><span class="secno">9.5</span> <dfn>Broadcasting to other browsing contexts</dfn><a href="#broadcasting-to-other-browsing-contexts" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel" title="The BroadcastChannel interface represents a named channel that any browsing context of a given origin can subscribe to. It allows communication between different documents (in different windows, tabs, frames or iframes) of the same origin. Messages are broadcasted via a message event fired at all BroadcastChannel objects listening to the channel, except the object that sent the message.">BroadcastChannel</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API" title="The Broadcast Channel API allows basic communication between browsing contexts (that is, windows, tabs, frames, or iframes) and workers on the same origin.">Broadcast_Channel_API</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>Pages on a single <a href="#concept-origin" id="broadcasting-to-other-browsing-contexts:concept-origin">origin</a> opened by the same user in the same user agent but in
  different unrelated <a href="#browsing-context" id="broadcasting-to-other-browsing-contexts:browsing-context">browsing contexts</a> sometimes need to
  send notifications to each other, for example "hey, the user logged in over here, check your
  credentials again".</p>

  <p>For elaborate cases, e.g. to manage locking of shared state, to manage synchronization of
  resources between a server and multiple local clients, to share a <code id="broadcasting-to-other-browsing-contexts:websocket-2"><a data-x-internal="websocket-2" href="https://websockets.spec.whatwg.org/#websocket">WebSocket</a></code>
  connection with a remote host, and so forth, <a href="#sharedworker" id="broadcasting-to-other-browsing-contexts:sharedworker">shared workers</a> are
  the most appropriate solution.</p>

  <p>For simple cases, though, where a shared worker would be an unreasonable overhead, authors can
  use the simple channel-based broadcast mechanism described in this section.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">Worker</c->)]
<c- b="">interface</c-> <dfn id="broadcastchannel" data-dfn-type="interface"><c- g="">BroadcastChannel</c-></dfn> : <a id="broadcasting-to-other-browsing-contexts:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <a href="#dom-broadcastchannel" id="broadcasting-to-other-browsing-contexts:dom-broadcastchannel"><c- g="">constructor</c-></a>(<c- b="">DOMString</c-> <c- g="">name</c->);

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-broadcastchannel-name" id="broadcasting-to-other-browsing-contexts:dom-broadcastchannel-name"><c- g="">name</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-broadcastchannel-postmessage" id="broadcasting-to-other-browsing-contexts:dom-broadcastchannel-postmessage"><c- g="">postMessage</c-></a>(<c- b="">any</c-> <c- g="">message</c->);
  <c- b="">undefined</c-> <a href="#dom-broadcastchannel-close" id="broadcasting-to-other-browsing-contexts:dom-broadcastchannel-close"><c- g="">close</c-></a>();
  <c- b="">attribute</c-> <a href="#eventhandler" id="broadcasting-to-other-browsing-contexts:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-broadcastchannel-onmessage" id="broadcasting-to-other-browsing-contexts:handler-broadcastchannel-onmessage"><c- g="">onmessage</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="broadcasting-to-other-browsing-contexts:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-broadcastchannel-onmessageerror" id="broadcasting-to-other-browsing-contexts:handler-broadcastchannel-onmessageerror"><c- g="">onmessageerror</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>broadcastChannel</var> = new <a href="#dom-broadcastchannel" id="dom-broadcastchannel-dev">BroadcastChannel</a>(<var>name</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/BroadcastChannel" title="The BroadcastChannel() constructor creates a new BroadcastChannel and connects it to the underlying channel.">BroadcastChannel/BroadcastChannel</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Returns a new <code id="broadcasting-to-other-browsing-contexts:broadcastchannel"><a href="#broadcastchannel">BroadcastChannel</a></code> object via which messages for the given channel
    name can be sent and received.</p>
   </dd><dt><code><var>broadcastChannel</var>.<a href="#dom-broadcastchannel-name" id="dom-broadcastchannel-name-dev">name</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/name" title="The read-only BroadcastChannel.name property returns a string, which uniquely identifies the given channel with its name. This name is passed to the BroadcastChannel() constructor at creation time and is therefore read-only.">BroadcastChannel/name</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the channel name (as passed to the constructor).</p></dd><dt><code><var>broadcastChannel</var>.<a href="#dom-broadcastchannel-postmessage" id="dom-broadcastchannel-postmessage-dev">postMessage</a>(<var>message</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/postMessage" title="The BroadcastChannel.postMessage() sends a message, which can be of any kind of Object, to each listener in any browsing context with the same origin. The message is transmitted as a 'message' event targeted at each BroadcastChannel bound to the channel.">BroadcastChannel/postMessage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Sends the given message to other <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-2"><a href="#broadcastchannel">BroadcastChannel</a></code> objects set up for this
    channel. Messages can be structured objects, e.g. nested objects and arrays.</p>
   </dd><dt><code><var>broadcastChannel</var>.<a href="#dom-broadcastchannel-close" id="dom-broadcastchannel-close-dev">close</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/close" title="The BroadcastChannel.close() terminates the connection to the underlying channel, allowing the object to be garbage collected. This is a necessary step to perform as there is no other way for a browser to know that this channel is not needed anymore.">BroadcastChannel/close</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Closes the <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-3"><a href="#broadcastchannel">BroadcastChannel</a></code> object, opening it up to garbage
   collection.</p></dd></dl>

  

  <p>A <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-4"><a href="#broadcastchannel">BroadcastChannel</a></code> object has a <dfn id="channel-name">channel name</dfn> and a <dfn id="concept-broadcastchannel-closed">closed flag</dfn>.</p>

  <div data-algorithm="">
  <p>The <dfn id="dom-broadcastchannel"><code>new BroadcastChannel(<var>name</var>)</code></dfn>
  constructor steps are:</p>

  <ol><li><p>Set <a id="broadcasting-to-other-browsing-contexts:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#channel-name" id="broadcasting-to-other-browsing-contexts:channel-name">channel name</a> to <var>name</var>.</p></li><li><p>Set <a id="broadcasting-to-other-browsing-contexts:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-broadcastchannel-closed" id="broadcasting-to-other-browsing-contexts:concept-broadcastchannel-closed">closed flag</a>
   to false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="BroadcastChannel" id="dom-broadcastchannel-name" data-dfn-type="attribute"><code>name</code></dfn> getter steps are to return
  <a id="broadcasting-to-other-browsing-contexts:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#channel-name" id="broadcasting-to-other-browsing-contexts:channel-name-2">channel name</a>.</p>
  </div>

  <div data-algorithm="">
  <p>A <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-5"><a href="#broadcastchannel">BroadcastChannel</a></code> object is said to be <dfn id="eligible-for-messaging">eligible for messaging</dfn> when
  its <a href="#concept-relevant-global" id="broadcasting-to-other-browsing-contexts:concept-relevant-global">relevant global object</a> is either:</p>

  <ul><li><p>a <code id="broadcasting-to-other-browsing-contexts:window"><a href="#window">Window</a></code> object whose <a href="#concept-document-window" id="broadcasting-to-other-browsing-contexts:concept-document-window">associated
   <code>Document</code></a> is <a href="#fully-active" id="broadcasting-to-other-browsing-contexts:fully-active">fully active</a>, or</p></li><li><p>a <code id="broadcasting-to-other-browsing-contexts:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object whose <a href="#dom-workerglobalscope-closing" id="broadcasting-to-other-browsing-contexts:dom-workerglobalscope-closing">closing</a> flag is false and is not <a href="#suspendable-worker" id="broadcasting-to-other-browsing-contexts:suspendable-worker">suspendable</a>.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="BroadcastChannel" id="dom-broadcastchannel-postmessage" data-dfn-type="method"><code>postMessage(<var>message</var>)</code></dfn> method
  steps are:</p>

  <ol><li><p>If <a id="broadcasting-to-other-browsing-contexts:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> is not <a href="#eligible-for-messaging" id="broadcasting-to-other-browsing-contexts:eligible-for-messaging">eligible for messaging</a>, then return.</p></li><li><p>If <a id="broadcasting-to-other-browsing-contexts:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-broadcastchannel-closed" id="broadcasting-to-other-browsing-contexts:concept-broadcastchannel-closed-2">closed flag</a>
   is true, then throw an <a id="broadcasting-to-other-browsing-contexts:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a>
   <code id="broadcasting-to-other-browsing-contexts:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>serialized</var> be <a href="#structuredserialize" id="broadcasting-to-other-browsing-contexts:structuredserialize">StructuredSerialize</a>(<var>message</var>). Rethrow
   any exceptions.</p></li><li><p>Let <var>sourceOrigin</var> be <a id="broadcasting-to-other-browsing-contexts:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="broadcasting-to-other-browsing-contexts:relevant-settings-object">relevant settings object</a>'s
   <a href="#concept-settings-object-origin" id="broadcasting-to-other-browsing-contexts:concept-settings-object-origin">origin</a>.</p></li><li><p>Let <var>sourceStorageKey</var> be the result of running <a id="broadcasting-to-other-browsing-contexts:obtain-a-storage-key-for-non-storage-purposes" href="https://storage.spec.whatwg.org/#obtain-a-storage-key-for-non-storage-purposes" data-x-internal="obtain-a-storage-key-for-non-storage-purposes">obtain a storage key for
   non-storage purposes</a> with <a id="broadcasting-to-other-browsing-contexts:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="broadcasting-to-other-browsing-contexts:relevant-settings-object-2">relevant settings
   object</a>.</p></li><li>
    <p>Let <var>destinations</var> be a list of <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-6"><a href="#broadcastchannel">BroadcastChannel</a></code> objects that
    match the following criteria:</p>

    <ul><li><p>They are <a href="#eligible-for-messaging" id="broadcasting-to-other-browsing-contexts:eligible-for-messaging-2">eligible for messaging</a>.</p></li><li><p>The result of running <a id="broadcasting-to-other-browsing-contexts:obtain-a-storage-key-for-non-storage-purposes-2" href="https://storage.spec.whatwg.org/#obtain-a-storage-key-for-non-storage-purposes" data-x-internal="obtain-a-storage-key-for-non-storage-purposes">obtain a storage key for non-storage purposes</a> with
     their <a href="#relevant-settings-object" id="broadcasting-to-other-browsing-contexts:relevant-settings-object-3">relevant settings object</a> <a href="https://storage.spec.whatwg.org/#storage-key-equal" id="broadcasting-to-other-browsing-contexts:storage-key-equal" data-x-internal="storage-key-equal">equals</a>
     <var>sourceStorageKey</var>.</p></li><li><p>Their <a href="#channel-name" id="broadcasting-to-other-browsing-contexts:channel-name-3">channel name</a> <a id="broadcasting-to-other-browsing-contexts:is" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="is">is</a> <a id="broadcasting-to-other-browsing-contexts:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#channel-name" id="broadcasting-to-other-browsing-contexts:channel-name-4">channel
     name</a>.</p></li></ul>
   </li><li><p>Remove <var>source</var> from <var>destinations</var>.</p></li><li><p>Sort <var>destinations</var> such that all <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-7"><a href="#broadcastchannel">BroadcastChannel</a></code> objects whose
   <a href="#relevant-agent" id="broadcasting-to-other-browsing-contexts:relevant-agent">relevant agents</a> are the same are sorted in creation order,
   oldest first. (This does not define a complete ordering. Within this constraint, user agents may
   sort the list in any <a id="broadcasting-to-other-browsing-contexts:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner.)</p></li><li>
    <p>For each <var>destination</var> in <var>destinations</var>, <a href="#queue-a-global-task" id="broadcasting-to-other-browsing-contexts:queue-a-global-task">queue a global task</a>
    on the <a href="#dom-manipulation-task-source" id="broadcasting-to-other-browsing-contexts:dom-manipulation-task-source">DOM manipulation task source</a> given <var>destination</var>'s <a href="#concept-relevant-global" id="broadcasting-to-other-browsing-contexts:concept-relevant-global-2">relevant
    global object</a> to perform the following steps:</p>

    <ol><li><p>If <var>destination</var>'s <a href="#concept-broadcastchannel-closed" id="broadcasting-to-other-browsing-contexts:concept-broadcastchannel-closed-3">closed
     flag</a> is true, then abort these steps.</p></li><li><p>Let <var>targetRealm</var> be <var>destination</var>'s <a href="#concept-relevant-realm" id="broadcasting-to-other-browsing-contexts:concept-relevant-realm">relevant realm</a>.</p></li><li>
      <p>Let <var>data</var> be <a href="#structureddeserialize" id="broadcasting-to-other-browsing-contexts:structureddeserialize">StructuredDeserialize</a>(<var>serialized</var>,
      <var>targetRealm</var>).</p>

      <p>If this throws an exception, catch it, <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="broadcasting-to-other-browsing-contexts:concept-event-fire" data-x-internal="concept-event-fire">fire an
      event</a> named <code id="broadcasting-to-other-browsing-contexts:event-messageerror"><a href="#event-messageerror">messageerror</a></code> at
      <var>destination</var>, using <code id="broadcasting-to-other-browsing-contexts:messageevent"><a href="#messageevent">MessageEvent</a></code>, with the <code id="broadcasting-to-other-browsing-contexts:dom-messageevent-origin"><a href="#dom-messageevent-origin">origin</a></code> attribute initialized to the <a href="#ascii-serialisation-of-an-origin" id="broadcasting-to-other-browsing-contexts:ascii-serialisation-of-an-origin">serialization</a> of <var>sourceOrigin</var>, and then
      abort these steps.</p>
     </li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="broadcasting-to-other-browsing-contexts:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="broadcasting-to-other-browsing-contexts:event-message"><a href="#event-message">message</a></code> at <var>destination</var>, using
     <code id="broadcasting-to-other-browsing-contexts:messageevent-2"><a href="#messageevent">MessageEvent</a></code>, with the <code id="broadcasting-to-other-browsing-contexts:dom-messageevent-data"><a href="#dom-messageevent-data">data</a></code> attribute
     initialized to <var>data</var> and the <code id="broadcasting-to-other-browsing-contexts:dom-messageevent-origin-2"><a href="#dom-messageevent-origin">origin</a></code>
     attribute initialized to the <a href="#ascii-serialisation-of-an-origin" id="broadcasting-to-other-browsing-contexts:ascii-serialisation-of-an-origin-2">serialization</a> of
     <var>sourceOrigin</var>.</p></li></ol>
   </li></ol>
  </div>

  <p>While a <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-8"><a href="#broadcastchannel">BroadcastChannel</a></code> object whose <a href="#concept-broadcastchannel-closed" id="broadcasting-to-other-browsing-contexts:concept-broadcastchannel-closed-4">closed flag</a> is false has an event listener
  registered for <code id="broadcasting-to-other-browsing-contexts:event-message-2"><a href="#event-message">message</a></code> or <code id="broadcasting-to-other-browsing-contexts:event-messageerror-2"><a href="#event-messageerror">messageerror</a></code> events, there must be a strong reference from the
  <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-9"><a href="#broadcastchannel">BroadcastChannel</a></code> object's <a href="#concept-relevant-global" id="broadcasting-to-other-browsing-contexts:concept-relevant-global-3">relevant global object</a> to the
  <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-10"><a href="#broadcastchannel">BroadcastChannel</a></code> object itself.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="BroadcastChannel" id="dom-broadcastchannel-close" data-dfn-type="method"><code>close()</code></dfn> method steps are to set
  <a id="broadcasting-to-other-browsing-contexts:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-broadcastchannel-closed" id="broadcasting-to-other-browsing-contexts:concept-broadcastchannel-closed-5">closed flag</a> to true.</p>
  </div>

  

  <p class="note">Authors are strongly encouraged to explicitly close <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-11"><a href="#broadcastchannel">BroadcastChannel</a></code>
  objects when they are no longer needed, so that they can be garbage collected. Creating many
  <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-12"><a href="#broadcastchannel">BroadcastChannel</a></code> objects and discarding them while leaving them with an event
  listener and without closing them can lead to an apparent memory leak, since the objects will
  continue to live for as long as they have an event listener (or until their page or worker is
  closed).</p>

  

  <hr>

  <p>The following are the <a href="#event-handlers" id="broadcasting-to-other-browsing-contexts:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="broadcasting-to-other-browsing-contexts:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="broadcasting-to-other-browsing-contexts:event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the
  <code id="broadcasting-to-other-browsing-contexts:broadcastchannel-13"><a href="#broadcastchannel">BroadcastChannel</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="broadcasting-to-other-browsing-contexts:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="broadcasting-to-other-browsing-contexts:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="BroadcastChannel" id="handler-broadcastchannel-onmessage" data-dfn-type="attribute"><code>onmessage</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/message_event" title="The message event is fired on a BroadcastChannel object when a message arrives on that channel.">BroadcastChannel/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="broadcasting-to-other-browsing-contexts:event-message-3"><a href="#event-message">message</a></code>
    </td></tr><tr><td><dfn data-dfn-for="BroadcastChannel" id="handler-broadcastchannel-onmessageerror" data-dfn-type="attribute"><code>onmessageerror</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/messageerror_event" title="The messageerror event is fired on a BroadcastChannel object when a message that can't be deserialized arrives on the channel.">BroadcastChannel/messageerror_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></td><td> <code id="broadcasting-to-other-browsing-contexts:event-messageerror-3"><a href="#event-messageerror">messageerror</a></code>
  </td></tr></tbody></table>

  

  <div class="example">

   <p>Suppose a page wants to know when the user logs out, even when the user does so from another
   tab at the same site:</p>

   <pre><code class="js"><c- a="">var</c-> authChannel <c- o="">=</c-> <c- k="">new</c-> BroadcastChannel<c- p="">(</c-><c- t="">'auth'</c-><c- p="">);</c->
authChannel<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->data <c- o="">==</c-> <c- t="">'logout'</c-><c- p="">)</c->
    showLogout<c- p="">();</c->
<c- p="">}</c->

<c- a="">function</c-> logoutRequested<c- p="">()</c-> <c- p="">{</c->
  <c- c1="">// called when the user asks us to log them out</c->
  doLogout<c- p="">();</c->
  showLogout<c- p="">();</c->
  authChannel<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'logout'</c-><c- p="">);</c->
<c- p="">}</c->

<c- a="">function</c-> doLogout<c- p="">()</c-> <c- p="">{</c->
  <c- c1="">// actually log the user out (e.g. clearing cookies)</c->
  <c- c1="">// ...</c->
<c- p="">}</c->

<c- a="">function</c-> showLogout<c- p="">()</c-> <c- p="">{</c->
  <c- c1="">// update the UI to indicate we're logged out</c->
  <c- c1="">// ...</c->
<c- p="">}</c-></code></pre>

  </div>



  <h2 id="workers" data-dfn-type="dfn" data-lt="web worker" data-export=""><span class="secno">10</span> Web workers<a href="#workers" class="self-link"></a></h2><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API" title="Web Workers makes it possible to run a script operation in a background thread separate from the main execution thread of a web application. The advantage of this is that laborious processing can be performed in a separate thread, allowing the main (usually the UI) thread to run without being blocked/slowed down.">Web_Workers_API</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers" title="Web Workers are a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering with the user interface. In addition, they can perform I/O using XMLHttpRequest (although the responseXML and channel attributes are always null) or fetch (with no such restrictions). Once created, a worker can send messages to the JavaScript code that created it by posting messages to an event handler specified by that code (and vice versa).">Web_Workers_API/Using_web_workers</a></p></div></div>

  <h3 id="introduction-14"><span class="secno">10.1</span> Introduction<a href="#introduction-14" class="self-link"></a></h3>

  <h4 id="scope-2"><span class="secno">10.1.1</span> Scope<a href="#scope-2" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>This specification defines an API for running scripts in the background independently of any
  user interface scripts.</p>

  <p>This allows for long-running scripts that are not interrupted by scripts that respond to clicks
  or other user interactions, and allows long tasks to be executed without yielding to keep the page
  responsive.</p>

  <p>Workers (as these background scripts are called herein) are relatively heavy-weight, and are
  not intended to be used in large numbers. For example, it would be inappropriate to launch one
  worker for each pixel of a four megapixel image. The examples below show some appropriate uses of
  workers.</p>

  <p>Generally, workers are expected to be long-lived, have a high start-up performance cost, and a
  high per-instance memory cost.</p>


  <h4 id="examples-6"><span class="secno">10.1.2</span> Examples<a href="#examples-6" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>There are a variety of uses that workers can be put to. The following subsections show various
  examples of this use.</p>


  <h5 id="a-background-number-crunching-worker"><span class="secno">10.1.2.1</span> A background number-crunching worker<a href="#a-background-number-crunching-worker" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>The simplest use of workers is for performing a computationally
  expensive task without interrupting the user interface.</p>

  <p>In this example, the main document spawns a worker to (naïvely) compute prime numbers, and
  progressively displays the most recently found prime number.</p>

  <p>The main page is as follows:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Worker example: One-core computation<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->The highest prime number discovered so far is: <c- p="">&lt;</c-><c- f="">output</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"result"</c-><c- p="">&gt;&lt;/</c-><c- f="">output</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- t="">'worker.js'</c-><c- p="">);</c->
   worker<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
     document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'result'</c-><c- p="">).</c->textContent <c- o="">=</c-> event<c- p="">.</c->data<c- p="">;</c->
   <c- p="">};</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c->
</code></pre>

  <p>The <code id="a-background-number-crunching-worker:dom-worker"><a href="#dom-worker">Worker()</a></code> constructor call creates a worker and returns a
  <code id="a-background-number-crunching-worker:worker"><a href="#worker">Worker</a></code> object representing that worker, which is used to communicate with the worker.
  That object's <code id="a-background-number-crunching-worker:handler-messageeventtarget-onmessage"><a href="#handler-messageeventtarget-onmessage">onmessage</a></code> event handler
  allows the code to receive messages from the worker.</p>

  <p>The worker itself is as follows:</p>

  <pre><code class="js"><c- a="">var</c-> n <c- o="">=</c-> <c- mf="">1</c-><c- p="">;</c->
search<c- o="">:</c-> <c- k="">while</c-> <c- p="">(</c-><c- kc="">true</c-><c- p="">)</c-> <c- p="">{</c->
  n <c- o="">+=</c-> <c- mf="">1</c-><c- p="">;</c->
  <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> i <c- o="">=</c-> <c- mf="">2</c-><c- p="">;</c-> i <c- o="">&lt;=</c-> Math<c- p="">.</c->sqrt<c- p="">(</c->n<c- p="">);</c-> i <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c->
    <c- k="">if</c-> <c- p="">(</c->n <c- o="">%</c-> i <c- o="">==</c-> <c- mf="">0</c-><c- p="">)</c->
     <c- k="">continue</c-> search<c- p="">;</c->
  <c- c1="">// found a prime!</c->
  postMessage<c- p="">(</c->n<c- p="">);</c->
<c- p="">}</c->
</code></pre>

  <p>The bulk of this code is simply an unoptimized search for a prime number. The <code id="a-background-number-crunching-worker:dom-dedicatedworkerglobalscope-postmessage"><a href="#dom-dedicatedworkerglobalscope-postmessage">postMessage()</a></code> method is used to send a
  message back to the page when a prime is found.</p>

  <p><a href="/demos/workers/primes/page.html">View this example online</a>.</p>


  <h5 id="module-worker-example"><span class="secno">10.1.2.2</span> Using a JavaScript module as a worker<a href="#module-worker-example" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>All of our examples so far show workers that run <a href="#classic-script" id="module-worker-example:classic-script">classic
  scripts</a>. Workers can instead be instantiated using <a href="#module-script" id="module-worker-example:module-script">module
  scripts</a>, which have the usual benefits: the ability to use the JavaScript
  <code>import</code> statement to import other modules; strict mode by default; and
  top-level declarations not polluting the worker's global scope.</p>

  <p>As the <code>import</code> statement is available, the <code id="module-worker-example:dom-workerglobalscope-importscripts"><a href="#dom-workerglobalscope-importscripts">importScripts()</a></code> method will automatically fail
  inside module workers.</p>

  <p>In this example, the main document uses a worker to do off-main-thread image manipulation.
  It imports the filters used from another module.</p>

  <p>The main page is as follows:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Worker example: image decoding<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
    Type an image URL to decode
    <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"url"</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"image-url"</c-> <c- e="">list</c-><c- o="">=</c-><c- s="">"image-list"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">datalist</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"image-list"</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://html.spec.whatwg.org/images/drawImage.png"</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://html.spec.whatwg.org/images/robots.jpeg"</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"https://html.spec.whatwg.org/images/arcTo2.png"</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">datalist</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
    Choose a filter to apply
    <c- p="">&lt;</c-><c- f="">select</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"filter"</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"none"</c-><c- p="">&gt;</c->none<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"grayscale"</c-><c- p="">&gt;</c->grayscale<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
      <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">value</c-><c- o="">=</c-><c- s="">"brighten"</c-><c- p="">&gt;</c->brighten by 20%<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
    <c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"output"</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"module"</c-><c- p="">&gt;</c->
  <c- a="">const</c-> worker <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- u="">"worker.js"</c-><c- p="">,</c-> <c- p="">{</c-> type<c- o="">:</c-> <c- u="">"module"</c-> <c- p="">});</c->
  worker<c- p="">.</c->onmessage <c- o="">=</c-> receiveFromWorker<c- p="">;</c->

  <c- a="">const</c-> url <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"#image-url"</c-><c- p="">);</c->
  <c- a="">const</c-> filter <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"#filter"</c-><c- p="">);</c->
  <c- a="">const</c-> output <c- o="">=</c-> document<c- p="">.</c->querySelector<c- p="">(</c-><c- u="">"#output"</c-><c- p="">);</c->

  url<c- p="">.</c->oninput <c- o="">=</c-> updateImage<c- p="">;</c->
  filter<c- p="">.</c->oninput <c- o="">=</c-> sendToWorker<c- p="">;</c->

  <c- a="">let</c-> imageData<c- p="">,</c-> context<c- p="">;</c->

  <c- a="">function</c-> updateImage<c- p="">()</c-> <c- p="">{</c->
    <c- a="">const</c-> img <c- o="">=</c-> <c- k="">new</c-> Image<c- p="">();</c->
    img<c- p="">.</c->src <c- o="">=</c-> url<c- p="">.</c->value<c- p="">;</c->

    img<c- p="">.</c->onload <c- o="">=</c-> <c- p="">()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
      <c- a="">const</c-> canvas <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"canvas"</c-><c- p="">);</c->
      canvas<c- p="">.</c->width <c- o="">=</c-> img<c- p="">.</c->width<c- p="">;</c->
      canvas<c- p="">.</c->height <c- o="">=</c-> img<c- p="">.</c->height<c- p="">;</c->

      context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- u="">"2d"</c-><c- p="">);</c->
      context<c- p="">.</c->drawImage<c- p="">(</c->img<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->
      imageData <c- o="">=</c-> context<c- p="">.</c->getImageData<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> canvas<c- p="">.</c->width<c- p="">,</c-> canvas<c- p="">.</c->height<c- p="">);</c->

      sendToWorker<c- p="">();</c->
      output<c- p="">.</c->replaceChildren<c- p="">(</c->canvas<c- p="">);</c->
    <c- p="">};</c->
  <c- p="">}</c->

  <c- a="">function</c-> sendToWorker<c- p="">()</c-> <c- p="">{</c->
    worker<c- p="">.</c->postMessage<c- p="">({</c-> imageData<c- p="">,</c-> filter<c- o="">:</c-> filter<c- p="">.</c->value <c- p="">});</c->
  <c- p="">}</c->

  <c- a="">function</c-> receiveFromWorker<c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    context<c- p="">.</c->putImageData<c- p="">(</c->e<c- p="">.</c->data<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">);</c->
  <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
</code></pre>

  <p>The worker file is then:</p>

  <pre><code class="js"><c- k="">import</c-> <c- o="">*</c-> <c- k="">as</c-> filters <c- k="">from</c-> <c- u="">"./filters.js"</c-><c- p="">;</c->

self<c- p="">.</c->onmessage <c- o="">=</c-> e <c- p="">=&gt;</c-> <c- p="">{</c->
  <c- a="">const</c-> <c- p="">{</c-> imageData<c- p="">,</c-> filter <c- p="">}</c-> <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
  filters<c- p="">[</c->filter<c- p="">](</c->imageData<c- p="">);</c->
  self<c- p="">.</c->postMessage<c- p="">(</c->imageData<c- p="">,</c-> <c- p="">[</c->imageData<c- p="">.</c->data<c- p="">.</c->buffer<c- p="">]);</c->
<c- p="">};</c->
</code></pre>

  <p>Which imports the file <code>filters.js</code>:</p>

  <pre><code class="js"><c- k="">export</c-> <c- a="">function</c-> none<c- p="">()</c-> <c- p="">{}</c->

<c- k="">export</c-> <c- a="">function</c-> grayscale<c- p="">({</c-> data<c- o="">:</c-> d <c- p="">})</c-> <c- p="">{</c->
  <c- k="">for</c-> <c- p="">(</c-><c- a="">let</c-> i <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> i <c- o="">&lt;</c-> d<c- p="">.</c->length<c- p="">;</c-> i <c- o="">+=</c-> <c- mf="">4</c-><c- p="">)</c-> <c- p="">{</c->
    <c- a="">const</c-> <c- p="">[</c->r<c- p="">,</c-> g<c- p="">,</c-> b<c- p="">]</c-> <c- o="">=</c-> <c- p="">[</c->d<c- p="">[</c->i<c- p="">],</c-> d<c- p="">[</c->i <c- o="">+</c-> <c- mf="">1</c-><c- p="">],</c-> d<c- p="">[</c->i <c- o="">+</c-> <c- mf="">2</c-><c- p="">]];</c->

    <c- c1="">// CIE luminance for the RGB</c->
    <c- c1="">// The human eye is bad at seeing red and blue, so we de-emphasize them.</c->
    d<c- p="">[</c->i<c- p="">]</c-> <c- o="">=</c-> d<c- p="">[</c->i <c- o="">+</c-> <c- mf="">1</c-><c- p="">]</c-> <c- o="">=</c-> d<c- p="">[</c->i <c- o="">+</c-> <c- mf="">2</c-><c- p="">]</c-> <c- o="">=</c-> <c- mf="">0.2126</c-> <c- o="">*</c-> r <c- o="">+</c-> <c- mf="">0.7152</c-> <c- o="">*</c-> g <c- o="">+</c-> <c- mf="">0.0722</c-> <c- o="">*</c-> b<c- p="">;</c->
  <c- p="">}</c->
<c- p="">};</c->

<c- k="">export</c-> <c- a="">function</c-> brighten<c- p="">({</c-> data<c- o="">:</c-> d <c- p="">})</c-> <c- p="">{</c->
  <c- k="">for</c-> <c- p="">(</c-><c- a="">let</c-> i <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> i <c- o="">&lt;</c-> d<c- p="">.</c->length<c- p="">;</c-> <c- o="">++</c->i<c- p="">)</c-> <c- p="">{</c->
    d<c- p="">[</c->i<c- p="">]</c-> <c- o="">*=</c-> <c- mf="">1.2</c-><c- p="">;</c->
  <c- p="">}</c->
<c- p="">};</c->
</code></pre>

  <p><a href="/demos/workers/modules/page.html">View this example online</a>.</p>


  <h5 id="shared-workers-introduction"><span class="secno">10.1.2.3</span> Shared workers introduction<a href="#shared-workers-introduction" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker" title="The SharedWorker interface represents a specific kind of worker that can be accessed from several browsing contexts, such as several windows, iframes or even workers. They implement an interface different than dedicated workers and have a different global scope, SharedWorkerGlobalScope.">SharedWorker</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>33+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>4.0–5.0</span></span><span class="opera_android no"><span>Opera Android</span><span>11–14</span></span></div></div></div>

  <p><i>This section is non-normative.</i></p>

  <p>This section introduces shared workers using a Hello World example. Shared workers use slightly
  different APIs, since each worker can have multiple connections.</p>

  <p>This first example shows how you connect to a worker and how a worker can send a message back
  to the page when it connects to it. Received messages are displayed in a log.</p>

  <p>Here is the HTML page:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Shared workers: demo 1<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">pre</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"log"</c-><c- p="">&gt;</c->Log:<c- p="">&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> SharedWorker<c- p="">(</c-><c- t="">'test.js'</c-><c- p="">);</c->
  <c- a="">var</c-> log <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'log'</c-><c- p="">);</c->
  worker<c- p="">.</c->port<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c-> <c- c1="">// note: not worker.onmessage!</c->
    log<c- p="">.</c->textContent <c- o="">+=</c-> <c- t="">'\n'</c-> <c- o="">+</c-> e<c- p="">.</c->data<c- p="">;</c->
  <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
</code></pre>

  <p>Here is the JavaScript worker:</p>

  <pre><code class="js">onconnect <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> port <c- o="">=</c-> e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">];</c->
  port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'Hello World!'</c-><c- p="">);</c->
<c- p="">}</c->
</code></pre>

  <p><a href="/demos/workers/shared/001/test.html">View this example online</a>.</p>

  <hr>

  <p>This second example extends the first one by changing two things: first, messages are received
  using <code>addEventListener()</code> instead of an <a href="#event-handler-idl-attributes" id="shared-workers-introduction:event-handler-idl-attributes">event handler IDL attribute</a>, and second, a message is sent <em>to</em> the
  worker, causing the worker to send another message in return. Received messages are again
  displayed in a log.</p>

  <p>Here is the HTML page:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Shared workers: demo 2<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">pre</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"log"</c-><c- p="">&gt;</c->Log:<c- p="">&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> SharedWorker<c- p="">(</c-><c- t="">'test.js'</c-><c- p="">);</c->
  <c- a="">var</c-> log <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'log'</c-><c- p="">);</c->
  worker<c- p="">.</c->port<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> <c- a="">function</c-><c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    log<c- p="">.</c->textContent <c- o="">+=</c-> <c- t="">'\n'</c-> <c- o="">+</c-> e<c- p="">.</c->data<c- p="">;</c->
  <c- p="">},</c-> <c- kc="">false</c-><c- p="">);</c->
  worker<c- p="">.</c->port<c- p="">.</c->start<c- p="">();</c-> <c- c1="">// note: need this when using addEventListener</c->
  worker<c- p="">.</c->port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'ping'</c-><c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
</code></pre>

  <p>Here is the JavaScript worker:</p>

  <pre><code class="js">onconnect <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> port <c- o="">=</c-> e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">];</c->
  port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'Hello World!'</c-><c- p="">);</c->
  port<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'pong'</c-><c- p="">);</c-> <c- c1="">// not e.ports[0].postMessage!</c->
    <c- c1="">// e.target.postMessage('pong'); would work also</c->
  <c- p="">}</c->
<c- p="">}</c->
</code></pre>

  <p><a href="/demos/workers/shared/002/test.html">View this example online</a>.</p>

  <hr>

  <p>Finally, the example is extended to show how two pages can connect to the same worker; in this
  case, the second page is merely in an <code id="shared-workers-introduction:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> on the first page, but the same
  principle would apply to an entirely separate page in a separate <a href="#top-level-traversable" id="shared-workers-introduction:top-level-traversable">top-level
  traversable</a>.</p>

  <p>Here is the outer HTML page:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Shared workers: demo 3<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">pre</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"log"</c-><c- p="">&gt;</c->Log:<c- p="">&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> SharedWorker<c- p="">(</c-><c- t="">'test.js'</c-><c- p="">);</c->
  <c- a="">var</c-> log <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'log'</c-><c- p="">);</c->
  worker<c- p="">.</c->port<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> <c- a="">function</c-><c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    log<c- p="">.</c->textContent <c- o="">+=</c-> <c- t="">'\n'</c-> <c- o="">+</c-> e<c- p="">.</c->data<c- p="">;</c->
  <c- p="">},</c-> <c- kc="">false</c-><c- p="">);</c->
  worker<c- p="">.</c->port<c- p="">.</c->start<c- p="">();</c->
  worker<c- p="">.</c->port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'ping'</c-><c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">iframe</c-> <c- e="">src</c-><c- o="">=</c-><c- s="">"inner.html"</c-><c- p="">&gt;&lt;/</c-><c- f="">iframe</c-><c- p="">&gt;</c->
</code></pre>

  <p>Here is the inner HTML page:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Shared workers: demo 3 inner frame<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">pre</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">log</c-><c- p="">&gt;</c->Inner log:<c- p="">&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> SharedWorker<c- p="">(</c-><c- t="">'test.js'</c-><c- p="">);</c->
  <c- a="">var</c-> log <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'log'</c-><c- p="">);</c->
  worker<c- p="">.</c->port<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
   log<c- p="">.</c->textContent <c- o="">+=</c-> <c- t="">'\n'</c-> <c- o="">+</c-> e<c- p="">.</c->data<c- p="">;</c->
  <c- p="">}</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
</code></pre>

  <p>Here is the JavaScript worker:</p>

  <pre><code class="js"><c- a="">var</c-> count <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
onconnect <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  count <c- o="">+=</c-> <c- mf="">1</c-><c- p="">;</c->
  <c- a="">var</c-> port <c- o="">=</c-> e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">];</c->
  port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'Hello World! You are connection #'</c-> <c- o="">+</c-> count<c- p="">);</c->
  port<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'pong'</c-><c- p="">);</c->
  <c- p="">}</c->
<c- p="">}</c->
</code></pre>

  <p><a href="/demos/workers/shared/003/test.html">View this example online</a>.</p>


  <h5 id="shared-state-using-a-shared-worker"><span class="secno">10.1.2.4</span> Shared state using a shared worker<a href="#shared-state-using-a-shared-worker" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>In this example, multiple windows (viewers) can be opened that are all viewing the same map.
  All the windows share the same map information, with a single worker coordinating all the viewers.
  Each viewer can move around independently, but if they set any data on the map, all the viewers
  are updated.</p>

  <p>The main page isn't interesting, it merely provides a way to open the viewers:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Workers example: Multiviewer<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">function</c-> openViewer<c- p="">()</c-> <c- p="">{</c->
     window<c- p="">.</c->open<c- p="">(</c-><c- t="">'viewer.html'</c-><c- p="">);</c->
   <c- p="">}</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"openViewer()"</c-><c- p="">&gt;</c->Open a new
  viewer<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Each viewer opens in a new window. You can have as many viewers
  as you like, they all view the same data.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c->
</code></pre>

  <p>The viewer is more involved:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Workers example: Multiviewer viewer<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> SharedWorker<c- p="">(</c-><c- t="">'worker.js'</c-><c- p="">,</c-> <c- t="">'core'</c-><c- p="">);</c->

   <c- c1="">// CONFIGURATION</c->
   <c- a="">function</c-> configure<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
     <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">4</c-><c- p="">)</c-> <c- o="">!=</c-> <c- t="">'cfg '</c-><c- p="">)</c-> <c- k="">return</c-><c- p="">;</c->
     <c- a="">var</c-> name <c- o="">=</c-> event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">4</c-><c- p="">).</c->split<c- p="">(</c-><c- t="">' '</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
     <c- c1="">// update display to mention our name is name</c->
     document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'h1'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">].</c->textContent <c- o="">+=</c-> <c- t="">' '</c-> <c- o="">+</c-> name<c- p="">;</c->
     <c- c1="">// no longer need this listener</c->
     worker<c- p="">.</c->port<c- p="">.</c->removeEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> configure<c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->
   <c- p="">}</c->
   worker<c- p="">.</c->port<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> configure<c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->

   <c- c1="">// MAP</c->
   <c- a="">function</c-> paintMap<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
     <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">4</c-><c- p="">)</c-> <c- o="">!=</c-> <c- t="">'map '</c-><c- p="">)</c-> <c- k="">return</c-><c- p="">;</c->
     <c- a="">var</c-> data <c- o="">=</c-> event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">4</c-><c- p="">).</c->split<c- p="">(</c-><c- t="">','</c-><c- p="">);</c->
     <c- c1="">// display tiles data[0] .. data[8]</c->
     <c- a="">var</c-> canvas <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'map'</c-><c- p="">);</c->
     <c- a="">var</c-> context <c- o="">=</c-> canvas<c- p="">.</c->getContext<c- p="">(</c-><c- t="">'2d'</c-><c- p="">);</c->
     <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> y <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> y <c- o="">&lt;</c-> <c- mf="">3</c-><c- p="">;</c-> y <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
       <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> x <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> x <c- o="">&lt;</c-> <c- mf="">3</c-><c- p="">;</c-> x <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
         <c- a="">var</c-> tile <c- o="">=</c-> data<c- p="">[</c->y <c- o="">*</c-> <c- mf="">3</c-> <c- o="">+</c-> x<c- p="">];</c->
         <c- k="">if</c-> <c- p="">(</c->tile <c- o="">==</c-> <c- t="">'0'</c-><c- p="">)</c->
           context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- t="">'green'</c-><c- p="">;</c->
         <c- k="">else</c->
           context<c- p="">.</c->fillStyle <c- o="">=</c-> <c- t="">'maroon'</c-><c- p="">;</c->
         context<c- p="">.</c->fillRect<c- p="">(</c->x <c- o="">*</c-> <c- mf="">50</c-><c- p="">,</c-> y <c- o="">*</c-> <c- mf="">50</c-><c- p="">,</c-> <c- mf="">50</c-><c- p="">,</c-> <c- mf="">50</c-><c- p="">);</c->
       <c- p="">}</c->
     <c- p="">}</c->
   <c- p="">}</c->
   worker<c- p="">.</c->port<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> paintMap<c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->

   <c- c1="">// PUBLIC CHAT</c->
   <c- a="">function</c-> updatePublicChat<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
     <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">4</c-><c- p="">)</c-> <c- o="">!=</c-> <c- t="">'txt '</c-><c- p="">)</c-> <c- k="">return</c-><c- p="">;</c->
     <c- a="">var</c-> name <c- o="">=</c-> event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">4</c-><c- p="">).</c->split<c- p="">(</c-><c- t="">' '</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
     <c- a="">var</c-> message <c- o="">=</c-> event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">4</c-> <c- o="">+</c-> name<c- p="">.</c->length <c- o="">+</c-> <c- mf="">1</c-><c- p="">);</c->
     <c- c1="">// display "&lt;name&gt; message" in public chat</c->
     <c- a="">var</c-> public <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'public'</c-><c- p="">);</c->
     <c- a="">var</c-> p <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'p'</c-><c- p="">);</c->
     <c- a="">var</c-> n <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'button'</c-><c- p="">);</c->
     n<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'&lt;'</c-> <c- o="">+</c-> name <c- o="">+</c-> <c- t="">'&gt; '</c-><c- p="">;</c->
     n<c- p="">.</c->onclick <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c-> worker<c- p="">.</c->port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'msg '</c-> <c- o="">+</c-> name<c- p="">);</c-> <c- p="">};</c->
     p<c- p="">.</c->appendChild<c- p="">(</c->n<c- p="">);</c->
     <c- a="">var</c-> m <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'span'</c-><c- p="">);</c->
     m<c- p="">.</c->textContent <c- o="">=</c-> message<c- p="">;</c->
     p<c- p="">.</c->appendChild<c- p="">(</c->m<c- p="">);</c->
     public<c- p="">.</c->appendChild<c- p="">(</c->p<c- p="">);</c->
   <c- p="">}</c->
   worker<c- p="">.</c->port<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> updatePublicChat<c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->

   <c- c1="">// PRIVATE CHAT</c->
   <c- a="">function</c-> startPrivateChat<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
     <c- k="">if</c-> <c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">4</c-><c- p="">)</c-> <c- o="">!=</c-> <c- t="">'msg '</c-><c- p="">)</c-> <c- k="">return</c-><c- p="">;</c->
     <c- a="">var</c-> name <c- o="">=</c-> event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">4</c-><c- p="">).</c->split<c- p="">(</c-><c- t="">' '</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
     <c- a="">var</c-> port <c- o="">=</c-> event<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">];</c->
     <c- c1="">// display a private chat UI</c->
     <c- a="">var</c-> ul <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'private'</c-><c- p="">);</c->
     <c- a="">var</c-> li <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'li'</c-><c- p="">);</c->
     <c- a="">var</c-> h3 <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'h3'</c-><c- p="">);</c->
     h3<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'Private chat with '</c-> <c- o="">+</c-> name<c- p="">;</c->
     li<c- p="">.</c->appendChild<c- p="">(</c->h3<c- p="">);</c->
     <c- a="">var</c-> div <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'div'</c-><c- p="">);</c->
     <c- a="">var</c-> addMessage <c- o="">=</c-> <c- a="">function</c-><c- p="">(</c->name<c- p="">,</c-> message<c- p="">)</c-> <c- p="">{</c->
       <c- a="">var</c-> p <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'p'</c-><c- p="">);</c->
       <c- a="">var</c-> n <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'strong'</c-><c- p="">);</c->
       n<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'&lt;'</c-> <c- o="">+</c-> name <c- o="">+</c-> <c- t="">'&gt; '</c-><c- p="">;</c->
       p<c- p="">.</c->appendChild<c- p="">(</c->n<c- p="">);</c->
       <c- a="">var</c-> t <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'span'</c-><c- p="">);</c->
       t<c- p="">.</c->textContent <c- o="">=</c-> message<c- p="">;</c->
       p<c- p="">.</c->appendChild<c- p="">(</c->t<c- p="">);</c->
       div<c- p="">.</c->appendChild<c- p="">(</c->p<c- p="">);</c->
     <c- p="">};</c->
     port<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
       addMessage<c- p="">(</c->name<c- p="">,</c-> event<c- p="">.</c->data<c- p="">);</c->
     <c- p="">};</c->
     li<c- p="">.</c->appendChild<c- p="">(</c->div<c- p="">);</c->
     <c- a="">var</c-> form <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'form'</c-><c- p="">);</c->
     <c- a="">var</c-> p <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'p'</c-><c- p="">);</c->
     <c- a="">var</c-> input <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'input'</c-><c- p="">);</c->
     input<c- p="">.</c->size <c- o="">=</c-> <c- mf="">50</c-><c- p="">;</c->
     p<c- p="">.</c->appendChild<c- p="">(</c->input<c- p="">);</c->
     p<c- p="">.</c->appendChild<c- p="">(</c->document<c- p="">.</c->createTextNode<c- p="">(</c-><c- t="">' '</c-><c- p="">));</c->
     <c- a="">var</c-> button <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- t="">'button'</c-><c- p="">);</c->
     button<c- p="">.</c->textContent <c- o="">=</c-> <c- t="">'Post'</c-><c- p="">;</c->
     p<c- p="">.</c->appendChild<c- p="">(</c->button<c- p="">);</c->
     form<c- p="">.</c->onsubmit <c- o="">=</c-> <c- a="">function</c-> <c- p="">()</c-> <c- p="">{</c->
       port<c- p="">.</c->postMessage<c- p="">(</c->input<c- p="">.</c->value<c- p="">);</c->
       addMessage<c- p="">(</c-><c- t="">'me'</c-><c- p="">,</c-> input<c- p="">.</c->value<c- p="">);</c->
       input<c- p="">.</c->value <c- o="">=</c-> <c- t="">''</c-><c- p="">;</c->
       <c- k="">return</c-> <c- kc="">false</c-><c- p="">;</c->
     <c- p="">};</c->
     form<c- p="">.</c->appendChild<c- p="">(</c->p<c- p="">);</c->
     li<c- p="">.</c->appendChild<c- p="">(</c->form<c- p="">);</c->
     ul<c- p="">.</c->appendChild<c- p="">(</c->li<c- p="">);</c->
   <c- p="">}</c->
   worker<c- p="">.</c->port<c- p="">.</c->addEventListener<c- p="">(</c-><c- t="">'message'</c-><c- p="">,</c-> startPrivateChat<c- p="">,</c-> <c- kc="">false</c-><c- p="">);</c->

   worker<c- p="">.</c->port<c- p="">.</c->start<c- p="">();</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h1</c-><c- p="">&gt;</c->Viewer<c- p="">&lt;/</c-><c- f="">h1</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Map<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">canvas</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"map"</c-> <c- e="">height</c-><c- o="">=</c-><c- s="">150</c-> <c- e="">width</c-><c- o="">=</c-><c- s="">150</c-><c- p="">&gt;&lt;/</c-><c- f="">canvas</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"worker.port.postMessage('mov left')"</c-><c- p="">&gt;</c->Left<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"worker.port.postMessage('mov up')"</c-><c- p="">&gt;</c->Up<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"worker.port.postMessage('mov down')"</c-><c- p="">&gt;</c->Down<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"worker.port.postMessage('mov right')"</c-><c- p="">&gt;</c->Right<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"worker.port.postMessage('set 0')"</c-><c- p="">&gt;</c->Set 0<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"worker.port.postMessage('set 1')"</c-><c- p="">&gt;</c->Set 1<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Public Chat<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"public"</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">form</c-> <c- e="">onsubmit</c-><c- o="">=</c-><c- s="">"worker.port.postMessage('txt ' + message.value); message.value = ''; return false;"</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"text"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"message"</c-> <c- e="">size</c-><c- o="">=</c-><c- s="">"50"</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">button</c-><c- p="">&gt;</c->Post<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c->
   <c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">form</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">h2</c-><c- p="">&gt;</c->Private Chat<c- p="">&lt;/</c-><c- f="">h2</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">ul</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"private"</c-><c- p="">&gt;&lt;/</c-><c- f="">ul</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c->
</code></pre>

  <p>There are several key things worth noting about the way the viewer is written.</p>

  <p><strong>Multiple listeners</strong>. Instead of a single message processing function, the code
  here attaches multiple event listeners, each one performing a quick check to see if it is relevant
  for the message. In this example it doesn't make much difference, but if multiple authors wanted
  to collaborate using a single port to communicate with a worker, it would allow for independent
  code instead of changes having to all be made to a single event handling function.</p>

  <p>Registering event listeners in this way also allows you to unregister specific listeners when
  you are done with them, as is done with the <code>configure()</code> method in this
  example.</p>

  <p>Finally, the worker:</p>

  <pre><code class="js"><c- a="">var</c-> nextName <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
<c- a="">function</c-> getNextName<c- p="">()</c-> <c- p="">{</c->
  <c- c1="">// this could use more friendly names</c->
  <c- c1="">// but for now just return a number</c->
  <c- k="">return</c-> nextName<c- o="">++</c-><c- p="">;</c->
<c- p="">}</c->

<c- a="">var</c-> map <c- o="">=</c-> <c- p="">[</c->
 <c- p="">[</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">],</c->
 <c- p="">[</c-><c- mf="">1</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">],</c->
 <c- p="">[</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">],</c->
 <c- p="">[</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">],</c->
 <c- p="">[</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">],</c->
 <c- p="">[</c-><c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">],</c->
 <c- p="">[</c-><c- mf="">1</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">],</c->
<c- p="">];</c->

<c- a="">function</c-> wrapX<c- p="">(</c->x<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->x <c- o="">&lt;</c-> <c- mf="">0</c-><c- p="">)</c-> <c- k="">return</c-> wrapX<c- p="">(</c->x <c- o="">+</c-> map<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->length<c- p="">);</c->
  <c- k="">if</c-> <c- p="">(</c->x <c- o="">&gt;=</c-> map<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->length<c- p="">)</c-> <c- k="">return</c-> wrapX<c- p="">(</c->x <c- o="">-</c-> map<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->length<c- p="">);</c->
  <c- k="">return</c-> x<c- p="">;</c->
<c- p="">}</c->

<c- a="">function</c-> wrapY<c- p="">(</c->y<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->y <c- o="">&lt;</c-> <c- mf="">0</c-><c- p="">)</c-> <c- k="">return</c-> wrapY<c- p="">(</c->y <c- o="">+</c-> map<c- p="">.</c->length<c- p="">);</c->
  <c- k="">if</c-> <c- p="">(</c->y <c- o="">&gt;=</c-> map<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->length<c- p="">)</c-> <c- k="">return</c-> wrapY<c- p="">(</c->y <c- o="">-</c-> map<c- p="">.</c->length<c- p="">);</c->
  <c- k="">return</c-> y<c- p="">;</c->
<c- p="">}</c->

<c- a="">function</c-> wrap<c- p="">(</c->val<c- p="">,</c-> min<c- p="">,</c-> max<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->val <c- o="">&lt;</c-> min<c- p="">)</c->
    <c- k="">return</c-> val <c- o="">+</c-> <c- p="">(</c->max<c- o="">-</c->min<c- p="">)</c-><c- o="">+</c-><c- mf="">1</c-><c- p="">;</c->
  <c- k="">if</c-> <c- p="">(</c->val <c- o="">&gt;</c-> max<c- p="">)</c->
    <c- k="">return</c-> val <c- o="">-</c-> <c- p="">(</c->max<c- o="">-</c->min<c- p="">)</c-><c- o="">-</c-><c- mf="">1</c-><c- p="">;</c->
  <c- k="">return</c-> val<c- p="">;</c->
<c- p="">}</c->

<c- a="">function</c-> sendMapData<c- p="">(</c->viewer<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> data <c- o="">=</c-> <c- t="">''</c-><c- p="">;</c->
  <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> y <c- o="">=</c-> viewer<c- p="">.</c->y<c- o="">-</c-><c- mf="">1</c-><c- p="">;</c-> y <c- o="">&lt;=</c-> viewer<c- p="">.</c->y<c- o="">+</c-><c- mf="">1</c-><c- p="">;</c-> y <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
    <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> x <c- o="">=</c-> viewer<c- p="">.</c->x<c- o="">-</c-><c- mf="">1</c-><c- p="">;</c-> x <c- o="">&lt;=</c-> viewer<c- p="">.</c->x<c- o="">+</c-><c- mf="">1</c-><c- p="">;</c-> x <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
      <c- k="">if</c-> <c- p="">(</c->data <c- o="">!=</c-> <c- t="">''</c-><c- p="">)</c->
        data <c- o="">+=</c-> <c- t="">','</c-><c- p="">;</c->
      data <c- o="">+=</c-> map<c- p="">[</c->wrap<c- p="">(</c->y<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> map<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->length<c- o="">-</c-><c- mf="">1</c-><c- p="">)][</c->wrap<c- p="">(</c->x<c- p="">,</c-> <c- mf="">0</c-><c- p="">,</c-> map<c- p="">.</c->length<c- o="">-</c-><c- mf="">1</c-><c- p="">)];</c->
    <c- p="">}</c->
  <c- p="">}</c->
  viewer<c- p="">.</c->port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'map '</c-> <c- o="">+</c-> data<c- p="">);</c->
<c- p="">}</c->

<c- a="">var</c-> viewers <c- o="">=</c-> <c- p="">{};</c->
onconnect <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> name <c- o="">=</c-> getNextName<c- p="">();</c->
  event<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->_data <c- o="">=</c-> <c- p="">{</c-> port<c- o="">:</c-> event<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">],</c-> name<c- o="">:</c-> name<c- p="">,</c-> x<c- o="">:</c-> <c- mf="">0</c-><c- p="">,</c-> y<c- o="">:</c-> <c- mf="">0</c-><c- p="">,</c-> <c- p="">};</c->
  viewers<c- p="">[</c->name<c- p="">]</c-> <c- o="">=</c-> event<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->_data<c- p="">;</c->
  event<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->postMessage<c- p="">(</c-><c- t="">'cfg '</c-> <c- o="">+</c-> name<c- p="">);</c->
  event<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->onmessage <c- o="">=</c-> getMessage<c- p="">;</c->
  sendMapData<c- p="">(</c->event<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->_data<c- p="">);</c->
<c- p="">};</c->

<c- a="">function</c-> getMessage<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  <c- k="">switch</c-> <c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">0</c-><c- p="">,</c-> <c- mf="">4</c-><c- p="">))</c-> <c- p="">{</c->
    <c- k="">case</c-> <c- t="">'mov '</c-><c- o="">:</c->
      <c- a="">var</c-> direction <c- o="">=</c-> event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">4</c-><c- p="">);</c->
      <c- a="">var</c-> dx <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
      <c- a="">var</c-> dy <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
      <c- k="">switch</c-> <c- p="">(</c->direction<c- p="">)</c-> <c- p="">{</c->
        <c- k="">case</c-> <c- t="">'up'</c-><c- o="">:</c-> dy <c- o="">=</c-> <c- o="">-</c-><c- mf="">1</c-><c- p="">;</c-> <c- k="">break</c-><c- p="">;</c->
        <c- k="">case</c-> <c- t="">'down'</c-><c- o="">:</c-> dy <c- o="">=</c-> <c- mf="">1</c-><c- p="">;</c-> <c- k="">break</c-><c- p="">;</c->
        <c- k="">case</c-> <c- t="">'left'</c-><c- o="">:</c-> dx <c- o="">=</c-> <c- o="">-</c-><c- mf="">1</c-><c- p="">;</c-> <c- k="">break</c-><c- p="">;</c->
        <c- k="">case</c-> <c- t="">'right'</c-><c- o="">:</c-> dx <c- o="">=</c-> <c- mf="">1</c-><c- p="">;</c-> <c- k="">break</c-><c- p="">;</c->
      <c- p="">}</c->
      event<c- p="">.</c->target<c- p="">.</c->_data<c- p="">.</c->x <c- o="">=</c-> wrapX<c- p="">(</c->event<c- p="">.</c->target<c- p="">.</c->_data<c- p="">.</c->x <c- o="">+</c-> dx<c- p="">);</c->
      event<c- p="">.</c->target<c- p="">.</c->_data<c- p="">.</c->y <c- o="">=</c-> wrapY<c- p="">(</c->event<c- p="">.</c->target<c- p="">.</c->_data<c- p="">.</c->y <c- o="">+</c-> dy<c- p="">);</c->
      sendMapData<c- p="">(</c->event<c- p="">.</c->target<c- p="">.</c->_data<c- p="">);</c->
      <c- k="">break</c-><c- p="">;</c->
    <c- k="">case</c-> <c- t="">'set '</c-><c- o="">:</c->
      <c- a="">var</c-> value <c- o="">=</c-> event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">4</c-><c- p="">);</c->
      map<c- p="">[</c->event<c- p="">.</c->target<c- p="">.</c->_data<c- p="">.</c->y<c- p="">][</c->event<c- p="">.</c->target<c- p="">.</c->_data<c- p="">.</c->x<c- p="">]</c-> <c- o="">=</c-> value<c- p="">;</c->
      <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> viewer <c- k="">in</c-> viewers<c- p="">)</c->
        sendMapData<c- p="">(</c->viewers<c- p="">[</c->viewer<c- p="">]);</c->
      <c- k="">break</c-><c- p="">;</c->
    <c- k="">case</c-> <c- t="">'txt '</c-><c- o="">:</c->
      <c- a="">var</c-> name <c- o="">=</c-> event<c- p="">.</c->target<c- p="">.</c->_data<c- p="">.</c->name<c- p="">;</c->
      <c- a="">var</c-> message <c- o="">=</c-> event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">4</c-><c- p="">);</c->
      <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> viewer <c- k="">in</c-> viewers<c- p="">)</c->
        viewers<c- p="">[</c->viewer<c- p="">].</c->port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'txt '</c-> <c- o="">+</c-> name <c- o="">+</c-> <c- t="">' '</c-> <c- o="">+</c-> message<c- p="">);</c->
      <c- k="">break</c-><c- p="">;</c->
    <c- k="">case</c-> <c- t="">'msg '</c-><c- o="">:</c->
      <c- a="">var</c-> party1 <c- o="">=</c-> event<c- p="">.</c->target<c- p="">.</c->_data<c- p="">;</c->
      <c- a="">var</c-> party2 <c- o="">=</c-> viewers<c- p="">[</c->event<c- p="">.</c->data<c- p="">.</c->substr<c- p="">(</c-><c- mf="">4</c-><c- p="">).</c->split<c- p="">(</c-><c- t="">' '</c-><c- p="">,</c-> <c- mf="">1</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">]];</c->
      <c- k="">if</c-> <c- p="">(</c->party2<c- p="">)</c-> <c- p="">{</c->
        <c- a="">var</c-> channel <c- o="">=</c-> <c- k="">new</c-> MessageChannel<c- p="">();</c->
        party1<c- p="">.</c->port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'msg '</c-> <c- o="">+</c-> party2<c- p="">.</c->name<c- p="">,</c-> <c- p="">[</c->channel<c- p="">.</c->port1<c- p="">]);</c->
        party2<c- p="">.</c->port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'msg '</c-> <c- o="">+</c-> party1<c- p="">.</c->name<c- p="">,</c-> <c- p="">[</c->channel<c- p="">.</c->port2<c- p="">]);</c->
      <c- p="">}</c->
      <c- k="">break</c-><c- p="">;</c->
  <c- p="">}</c->
<c- p="">}</c->
</code></pre>

  <p><strong>Connecting to multiple pages</strong>. The script uses the <code id="shared-state-using-a-shared-worker:handler-sharedworkerglobalscope-onconnect"><a href="#handler-sharedworkerglobalscope-onconnect">onconnect</a></code> event listener to listen for
  multiple connections.</p>

  <p><strong>Direct channels</strong>. When the worker receives a "msg" message from one viewer
  naming another viewer, it sets up a direct connection between the two, so that the two viewers can
  communicate directly without the worker having to proxy all the messages.</p>

  <p><a href="/demos/workers/multiviewer/page.html">View this example online</a>.</p>


  <h5 id="delegation"><span class="secno">10.1.2.5</span> Delegation<a href="#delegation" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>With multicore CPUs becoming prevalent, one way to obtain better performance is to split
  computationally expensive tasks amongst multiple workers. In this example, a computationally
  expensive task that is to be performed for every number from 1 to 10,000,000 is farmed out to ten
  subworkers.</p>

  <p>The main page is as follows, it just reports the result:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Worker example: Multicore computation<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Result: <c- p="">&lt;</c-><c- f="">output</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"result"</c-><c- p="">&gt;&lt;/</c-><c- f="">output</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- t="">'worker.js'</c-><c- p="">);</c->
   worker<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
     document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'result'</c-><c- p="">).</c->textContent <c- o="">=</c-> event<c- p="">.</c->data<c- p="">;</c->
   <c- p="">};</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c->
</code></pre>

  <p>The worker itself is as follows:</p>

  <pre><code class="js"><c- c1="">// settings</c->
<c- a="">var</c-> num_workers <c- o="">=</c-> <c- mf="">10</c-><c- p="">;</c->
<c- a="">var</c-> items_per_worker <c- o="">=</c-> <c- mf="">1000000</c-><c- p="">;</c->

<c- c1="">// start the workers</c->
<c- a="">var</c-> result <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
<c- a="">var</c-> pending_workers <c- o="">=</c-> num_workers<c- p="">;</c->
<c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> i <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c-> i <c- o="">&lt;</c-> num_workers<c- p="">;</c-> i <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- t="">'core.js'</c-><c- p="">);</c->
  worker<c- p="">.</c->postMessage<c- p="">(</c->i <c- o="">*</c-> items_per_worker<c- p="">);</c->
  worker<c- p="">.</c->postMessage<c- p="">((</c->i<c- o="">+</c-><c- mf="">1</c-><c- p="">)</c-> <c- o="">*</c-> items_per_worker<c- p="">);</c->
  worker<c- p="">.</c->onmessage <c- o="">=</c-> storeResult<c- p="">;</c->
<c- p="">}</c->

<c- c1="">// handle the results</c->
<c- a="">function</c-> storeResult<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  result <c- o="">+=</c-> <c- mf="">1</c-><c- o="">*</c->event<c- p="">.</c->data<c- p="">;</c->
  pending_workers <c- o="">-=</c-> <c- mf="">1</c-><c- p="">;</c->
  <c- k="">if</c-> <c- p="">(</c->pending_workers <c- o="">&lt;=</c-> <c- mf="">0</c-><c- p="">)</c->
    postMessage<c- p="">(</c->result<c- p="">);</c-> <c- c1="">// finished!</c->
<c- p="">}</c->
</code></pre>

  <p>It consists of a loop to start the subworkers, and then a handler
  that waits for all the subworkers to respond.</p>

  <p>The subworkers are implemented as follows:</p>

  <pre><code class="js"><c- a="">var</c-> start<c- p="">;</c->
onmessage <c- o="">=</c-> getStart<c- p="">;</c->
<c- a="">function</c-> getStart<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  start <c- o="">=</c-> <c- mf="">1</c-><c- o="">*</c->event<c- p="">.</c->data<c- p="">;</c->
  onmessage <c- o="">=</c-> getEnd<c- p="">;</c->
<c- p="">}</c->

<c- a="">var</c-> end<c- p="">;</c->
<c- a="">function</c-> getEnd<c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  end <c- o="">=</c-> <c- mf="">1</c-><c- o="">*</c->event<c- p="">.</c->data<c- p="">;</c->
  onmessage <c- o="">=</c-> <c- kc="">null</c-><c- p="">;</c->
  work<c- p="">();</c->
<c- p="">}</c->

<c- a="">function</c-> work<c- p="">()</c-> <c- p="">{</c->
  <c- a="">var</c-> result <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
  <c- k="">for</c-> <c- p="">(</c-><c- a="">var</c-> i <c- o="">=</c-> start<c- p="">;</c-> i <c- o="">&lt;</c-> end<c- p="">;</c-> i <c- o="">+=</c-> <c- mf="">1</c-><c- p="">)</c-> <c- p="">{</c->
    <c- c1="">// perform some complex calculation here</c->
    result <c- o="">+=</c-> <c- mf="">1</c-><c- p="">;</c->
  <c- p="">}</c->
  postMessage<c- p="">(</c->result<c- p="">);</c->
  close<c- p="">();</c->
<c- p="">}</c->
</code></pre>

  <p>They receive two numbers in two events, perform the computation for the range of numbers thus
  specified, and then report the result back to the parent.</p>

  <p><a href="/demos/workers/multicore/page.html">View this example online</a>.</p>


  <h5 id="providing-libraries"><span class="secno">10.1.2.6</span> Providing libraries<a href="#providing-libraries" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Suppose that a cryptography library is made available that provides three tasks:</p>

  <dl><dt>Generate a public/private key pair</dt><dd>Takes a port, on which it will send two messages, first the public key and then the private
   key.</dd><dt>Given a plaintext and a public key, return the corresponding ciphertext</dt><dd>Takes a port, to which any number of messages can be sent, the first giving the public key,
   and the remainder giving the plaintext, each of which is encrypted and then sent on that same
   channel as the ciphertext. The user can close the port when it is done encrypting content.</dd><dt>Given a ciphertext and a private key, return the corresponding plaintext</dt><dd>Takes a port, to which any number of messages can be sent, the first giving the private key,
   and the remainder giving the ciphertext, each of which is decrypted and then sent on that same
   channel as the plaintext. The user can close the port when it is done decrypting content.</dd></dl>

  <p>The library itself is as follows:</p>

  <pre><code class="js"><c- a="">function</c-> handleMessage<c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->data <c- o="">==</c-> <c- u="">"genkeys"</c-><c- p="">)</c->
    genkeys<c- p="">(</c->e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">]);</c->
  <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->data <c- o="">==</c-> <c- u="">"encrypt"</c-><c- p="">)</c->
    encrypt<c- p="">(</c->e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">]);</c->
  <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->data <c- o="">==</c-> <c- u="">"decrypt"</c-><c- p="">)</c->
    decrypt<c- p="">(</c->e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">]);</c->
<c- p="">}</c->

<c- a="">function</c-> genkeys<c- p="">(</c->p<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> keys <c- o="">=</c-> _generateKeyPair<c- p="">();</c->
  p<c- p="">.</c->postMessage<c- p="">(</c->keys<c- p="">[</c-><c- mf="">0</c-><c- p="">]);</c->
  p<c- p="">.</c->postMessage<c- p="">(</c->keys<c- p="">[</c-><c- mf="">1</c-><c- p="">]);</c->
<c- p="">}</c->

<c- a="">function</c-> encrypt<c- p="">(</c->p<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> key<c- p="">,</c-> state <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
  p<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->state <c- o="">==</c-> <c- mf="">0</c-><c- p="">)</c-> <c- p="">{</c->
      key <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
      state <c- o="">=</c-> <c- mf="">1</c-><c- p="">;</c->
    <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
      p<c- p="">.</c->postMessage<c- p="">(</c->_encrypt<c- p="">(</c->key<c- p="">,</c-> e<c- p="">.</c->data<c- p="">));</c->
    <c- p="">}</c->
  <c- p="">};</c->
<c- p="">}</c->

<c- a="">function</c-> decrypt<c- p="">(</c->p<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> key<c- p="">,</c-> state <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
  p<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    <c- k="">if</c-> <c- p="">(</c->state <c- o="">==</c-> <c- mf="">0</c-><c- p="">)</c-> <c- p="">{</c->
      key <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
      state <c- o="">=</c-> <c- mf="">1</c-><c- p="">;</c->
    <c- p="">}</c-> <c- k="">else</c-> <c- p="">{</c->
      p<c- p="">.</c->postMessage<c- p="">(</c->_decrypt<c- p="">(</c->key<c- p="">,</c-> e<c- p="">.</c->data<c- p="">));</c->
    <c- p="">}</c->
  <c- p="">};</c->
<c- p="">}</c->

<c- c1="">// support being used as a shared worker as well as a dedicated worker</c->
<c- k="">if</c-> <c- p="">(</c-><c- t="">'onmessage'</c-> <c- k="">in</c-> <c- k="">this</c-><c- p="">)</c-> <c- c1="">// dedicated worker</c->
  onmessage <c- o="">=</c-> handleMessage<c- p="">;</c->
<c- k="">else</c-> <c- c1="">// shared worker</c->
  onconnect <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c-> e<c- p="">.</c->port<c- p="">.</c->onmessage <c- o="">=</c-> handleMessage<c- p="">;</c-> <c- p="">}</c->


<c- c1="">// the "crypto" functions:</c->

<c- a="">function</c-> _generateKeyPair<c- p="">()</c-> <c- p="">{</c->
  <c- k="">return</c-> <c- p="">[</c->Math<c- p="">.</c->random<c- p="">(),</c-> Math<c- p="">.</c->random<c- p="">()];</c->
<c- p="">}</c->

<c- a="">function</c-> _encrypt<c- p="">(</c->k<c- p="">,</c-> s<c- p="">)</c-> <c- p="">{</c->
  <c- k="">return</c-> <c- t="">'encrypted-'</c-> <c- o="">+</c-> k <c- o="">+</c-> <c- t="">' '</c-> <c- o="">+</c-> s<c- p="">;</c->
<c- p="">}</c->

<c- a="">function</c-> _decrypt<c- p="">(</c->k<c- p="">,</c-> s<c- p="">)</c-> <c- p="">{</c->
  <c- k="">return</c-> s<c- p="">.</c->substr<c- p="">(</c->s<c- p="">.</c->indexOf<c- p="">(</c-><c- t="">' '</c-><c- p="">)</c-><c- o="">+</c-><c- mf="">1</c-><c- p="">);</c->
<c- p="">}</c->
</code></pre>

  <p>Note that the crypto functions here are just stubs and don't do real cryptography.</p>

  <p>This library could be used as follows:</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">charset</c-><c- o="">=</c-><c- s="">"utf-8"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Worker example: Crypto library<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
   <c- a="">const</c-> cryptoLib <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- t="">'libcrypto-v1.js'</c-><c- p="">);</c-> <c- c1="">// or could use 'libcrypto-v2.js'</c->
   <c- a="">function</c-> startConversation<c- p="">(</c->source<c- p="">,</c-> message<c- p="">)</c-> <c- p="">{</c->
     <c- a="">const</c-> messageChannel <c- o="">=</c-> <c- k="">new</c-> MessageChannel<c- p="">();</c->
     source<c- p="">.</c->postMessage<c- p="">(</c->message<c- p="">,</c-> <c- p="">[</c->messageChannel<c- p="">.</c->port2<c- p="">]);</c->
     <c- k="">return</c-> messageChannel<c- p="">.</c->port1<c- p="">;</c->
   <c- p="">}</c->
   <c- a="">function</c-> getKeys<c- p="">()</c-> <c- p="">{</c->
     <c- a="">let</c-> state <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
     startConversation<c- p="">(</c->cryptoLib<c- p="">,</c-> <c- u="">"genkeys"</c-><c- p="">).</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
       <c- k="">if</c-> <c- p="">(</c->state <c- o="">===</c-> <c- mf="">0</c-><c- p="">)</c->
         document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'public'</c-><c- p="">).</c->value <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
       <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c->state <c- o="">===</c-> <c- mf="">1</c-><c- p="">)</c->
         document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'private'</c-><c- p="">).</c->value <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
       state <c- o="">+=</c-> <c- mf="">1</c-><c- p="">;</c->
     <c- p="">};</c->
   <c- p="">}</c->
   <c- a="">function</c-> enc<c- p="">()</c-> <c- p="">{</c->
     <c- a="">const</c-> port <c- o="">=</c-> startConversation<c- p="">(</c->cryptoLib<c- p="">,</c-> <c- u="">"encrypt"</c-><c- p="">);</c->
     port<c- p="">.</c->postMessage<c- p="">(</c->document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'public'</c-><c- p="">).</c->value<c- p="">);</c->
     port<c- p="">.</c->postMessage<c- p="">(</c->document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'input'</c-><c- p="">).</c->value<c- p="">);</c->
     port<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
       document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'input'</c-><c- p="">).</c->value <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
       port<c- p="">.</c->close<c- p="">();</c->
     <c- p="">};</c->
   <c- p="">}</c->
   <c- a="">function</c-> dec<c- p="">()</c-> <c- p="">{</c->
     <c- a="">const</c-> port <c- o="">=</c-> startConversation<c- p="">(</c->cryptoLib<c- p="">,</c-> <c- u="">"decrypt"</c-><c- p="">);</c->
     port<c- p="">.</c->postMessage<c- p="">(</c->document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'private'</c-><c- p="">).</c->value<c- p="">);</c->
     port<c- p="">.</c->postMessage<c- p="">(</c->document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'input'</c-><c- p="">).</c->value<c- p="">);</c->
     port<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
       document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'input'</c-><c- p="">).</c->value <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
       port<c- p="">.</c->close<c- p="">();</c->
     <c- p="">};</c->
   <c- p="">}</c->
  <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">style</c-><c- p="">&gt;</c->
   <c- f="">textarea</c-> <c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> <c- kc="">block</c-><c- p="">;</c-> <c- p="">}</c->
  <c- p="">&lt;/</c-><c- f="">style</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">body</c-> <c- e="">onload</c-><c- o="">=</c-><c- s="">"getKeys()"</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">legend</c-><c- p="">&gt;</c->Keys<c- p="">&lt;/</c-><c- f="">legend</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Public Key: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"public"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Private Key: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"private"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">fieldset</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->Input: <c- p="">&lt;</c-><c- f="">textarea</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"input"</c-><c- p="">&gt;&lt;/</c-><c- f="">textarea</c-><c- p="">&gt;&lt;/</c-><c- f="">label</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"enc()"</c-><c- p="">&gt;</c->Encrypt<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">button</c-> <c- e="">onclick</c-><c- o="">=</c-><c- s="">"dec()"</c-><c- p="">&gt;</c->Decrypt<c- p="">&lt;/</c-><c- f="">button</c-><c- p="">&gt;&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c->
</code></pre>

  <p>A later version of the API, though, might want to offload all the crypto work onto subworkers.
  This could be done as follows:</p>

  <pre><code class="js"><c- a="">function</c-> handleMessage<c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->data <c- o="">==</c-> <c- u="">"genkeys"</c-><c- p="">)</c->
    genkeys<c- p="">(</c->e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">]);</c->
  <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->data <c- o="">==</c-> <c- u="">"encrypt"</c-><c- p="">)</c->
    encrypt<c- p="">(</c->e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">]);</c->
  <c- k="">else</c-> <c- k="">if</c-> <c- p="">(</c->e<c- p="">.</c->data <c- o="">==</c-> <c- u="">"decrypt"</c-><c- p="">)</c->
    decrypt<c- p="">(</c->e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">]);</c->
<c- p="">}</c->

<c- a="">function</c-> genkeys<c- p="">(</c->p<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> generator <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- t="">'libcrypto-v2-generator.js'</c-><c- p="">);</c->
  generator<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">''</c-><c- p="">,</c-> <c- p="">[</c->p<c- p="">]);</c->
<c- p="">}</c->

<c- a="">function</c-> encrypt<c- p="">(</c->p<c- p="">)</c-> <c- p="">{</c->
  p<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    <c- a="">var</c-> key <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
    <c- a="">var</c-> encryptor <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- t="">'libcrypto-v2-encryptor.js'</c-><c- p="">);</c->
    encryptor<c- p="">.</c->postMessage<c- p="">(</c->key<c- p="">,</c-> <c- p="">[</c->p<c- p="">]);</c->
  <c- p="">};</c->
<c- p="">}</c->

<c- a="">function</c-> encrypt<c- p="">(</c->p<c- p="">)</c-> <c- p="">{</c->
  p<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    <c- a="">var</c-> key <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
    <c- a="">var</c-> decryptor <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- t="">'libcrypto-v2-decryptor.js'</c-><c- p="">);</c->
    decryptor<c- p="">.</c->postMessage<c- p="">(</c->key<c- p="">,</c-> <c- p="">[</c->p<c- p="">]);</c->
  <c- p="">};</c->
<c- p="">}</c->

<c- c1="">// support being used as a shared worker as well as a dedicated worker</c->
<c- k="">if</c-> <c- p="">(</c-><c- t="">'onmessage'</c-> <c- k="">in</c-> <c- k="">this</c-><c- p="">)</c-> <c- c1="">// dedicated worker</c->
  onmessage <c- o="">=</c-> handleMessage<c- p="">;</c->
<c- k="">else</c-> <c- c1="">// shared worker</c->
  onconnect <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c-> e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->onmessage <c- o="">=</c-> handleMessage <c- p="">};</c->
</code></pre>

  <p>The little subworkers would then be as follows.</p>

  <p>For generating key pairs:</p>

  <pre><code class="js">onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> k <c- o="">=</c-> _generateKeyPair<c- p="">();</c->
  e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->postMessage<c- p="">(</c->k<c- p="">[</c-><c- mf="">0</c-><c- p="">]);</c->
  e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->postMessage<c- p="">(</c->k<c- p="">[</c-><c- mf="">1</c-><c- p="">]);</c->
  close<c- p="">();</c->
<c- p="">}</c->

<c- a="">function</c-> _generateKeyPair<c- p="">()</c-> <c- p="">{</c->
  <c- k="">return</c-> <c- p="">[</c->Math<c- p="">.</c->random<c- p="">(),</c-> Math<c- p="">.</c->random<c- p="">()];</c->
<c- p="">}</c->
</code></pre>

  <p>For encrypting:</p>

  <pre><code class="js">onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> key <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
  e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    <c- a="">var</c-> s <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
    postMessage<c- p="">(</c->_encrypt<c- p="">(</c->key<c- p="">,</c-> s<c- p="">));</c->
  <c- p="">}</c->
<c- p="">}</c->

<c- a="">function</c-> _encrypt<c- p="">(</c->k<c- p="">,</c-> s<c- p="">)</c-> <c- p="">{</c->
  <c- k="">return</c-> <c- t="">'encrypted-'</c-> <c- o="">+</c-> k <c- o="">+</c-> <c- t="">' '</c-> <c- o="">+</c-> s<c- p="">;</c->
<c- p="">}</c->
</code></pre>

  <p>For decrypting:</p>

  <pre><code class="js">onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> key <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
  e<c- p="">.</c->ports<c- p="">[</c-><c- mf="">0</c-><c- p="">].</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->e<c- p="">)</c-> <c- p="">{</c->
    <c- a="">var</c-> s <c- o="">=</c-> e<c- p="">.</c->data<c- p="">;</c->
    postMessage<c- p="">(</c->_decrypt<c- p="">(</c->key<c- p="">,</c-> s<c- p="">));</c->
  <c- p="">}</c->
<c- p="">}</c->

<c- a="">function</c-> _decrypt<c- p="">(</c->k<c- p="">,</c-> s<c- p="">)</c-> <c- p="">{</c->
  <c- k="">return</c-> s<c- p="">.</c->substr<c- p="">(</c->s<c- p="">.</c->indexOf<c- p="">(</c-><c- t="">' '</c-><c- p="">)</c-><c- o="">+</c-><c- mf="">1</c-><c- p="">);</c->
<c- p="">}</c->
</code></pre>

  <p>Notice how the users of the API don't have to even know that this is happening — the API
  hasn't changed; the library can delegate to subworkers without changing its API, even though it is
  accepting data using message channels.</p>

  <p><a href="/demos/workers/crypto/page.html">View this example online</a>.</p>


  <h4 id="tutorials"><span class="secno">10.1.3</span> Tutorials<a href="#tutorials" class="self-link"></a></h4>

  <h5 id="creating-a-dedicated-worker"><span class="secno">10.1.3.1</span> Creating a dedicated worker<a href="#creating-a-dedicated-worker" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Creating a worker requires a URL to a JavaScript file. The <code id="creating-a-dedicated-worker:dom-worker"><a href="#dom-worker">Worker()</a></code> constructor is invoked with the URL to that file as its only
  argument; a worker is then created and returned:</p>

  <pre><code class="js"><c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- t="">'helper.js'</c-><c- p="">);</c-></code></pre>

  <p>If you want your worker script to be interpreted as a <a href="#module-script" id="creating-a-dedicated-worker:module-script">module script</a> instead of
  the default <a href="#classic-script" id="creating-a-dedicated-worker:classic-script">classic script</a>, you need to use a slightly different signature:</p>

  <pre><code class="js"><c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> Worker<c- p="">(</c-><c- t="">'helper.mjs'</c-><c- p="">,</c-> <c- p="">{</c-> type<c- o="">:</c-> <c- u="">"module"</c-> <c- p="">});</c-></code></pre>


  <h5 id="communicating-with-a-dedicated-worker"><span class="secno">10.1.3.2</span> Communicating with a dedicated worker<a href="#communicating-with-a-dedicated-worker" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Dedicated workers use <code id="communicating-with-a-dedicated-worker:messageport"><a href="#messageport">MessagePort</a></code> objects behind the scenes, and thus support all
  the same features, such as sending structured data, transferring binary data, and transferring
  other ports.</p>

  <p>To receive messages from a dedicated worker, use the <code id="communicating-with-a-dedicated-worker:handler-messageeventtarget-onmessage"><a href="#handler-messageeventtarget-onmessage">onmessage</a></code> <a href="#event-handler-idl-attributes" id="communicating-with-a-dedicated-worker:event-handler-idl-attributes">event handler IDL attribute</a> on the <code id="communicating-with-a-dedicated-worker:worker"><a href="#worker">Worker</a></code> object:</p>

  <pre><code class="js">worker<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">};</c-></code></pre>

  <p>You can also use the <code id="communicating-with-a-dedicated-worker:dom-eventtarget-addeventlistener"><a data-x-internal="dom-eventtarget-addeventlistener" href="https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener">addEventListener()</a></code>
  method.</p>

  <p class="note">The implicit <code id="communicating-with-a-dedicated-worker:messageport-2"><a href="#messageport">MessagePort</a></code> used by dedicated workers has its <a href="#port-message-queue" id="communicating-with-a-dedicated-worker:port-message-queue">port
  message queue</a> implicitly enabled when it is created, so there is no equivalent to the
  <code id="communicating-with-a-dedicated-worker:messageport-3"><a href="#messageport">MessagePort</a></code> interface's <code id="communicating-with-a-dedicated-worker:dom-messageport-start"><a href="#dom-messageport-start">start()</a></code> method on
  the <code id="communicating-with-a-dedicated-worker:worker-2"><a href="#worker">Worker</a></code> interface.</p>

  <p>To <em>send</em> data to a worker, use the <code id="communicating-with-a-dedicated-worker:dom-worker-postmessage"><a href="#dom-worker-postmessage">postMessage()</a></code> method. Structured data can be sent over this
  communication channel. To send <code id="communicating-with-a-dedicated-worker:idl-arraybuffer"><a data-x-internal="idl-arraybuffer" href="https://webidl.spec.whatwg.org/#idl-ArrayBuffer">ArrayBuffer</a></code> objects
  efficiently (by transferring them rather than cloning them), list them in an array in the second
  argument.</p>

  <pre><code class="js">worker<c- p="">.</c->postMessage<c- p="">({</c->
  operation<c- o="">:</c-> <c- t="">'find-edges'</c-><c- p="">,</c->
  input<c- o="">:</c-> buffer<c- p="">,</c-> <c- c1="">// an ArrayBuffer object</c->
  threshold<c- o="">:</c-> <c- mf="">0.6</c-><c- p="">,</c->
<c- p="">},</c-> <c- p="">[</c->buffer<c- p="">]);</c-></code></pre>

  <p>To receive a message inside the worker, the <code id="communicating-with-a-dedicated-worker:handler-messageeventtarget-onmessage-2"><a href="#handler-messageeventtarget-onmessage">onmessage</a></code> <a href="#event-handler-idl-attributes" id="communicating-with-a-dedicated-worker:event-handler-idl-attributes-2">event handler IDL attribute</a> is used.</p>

  <pre><code class="js">onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">};</c-></code></pre>

  <p>You can again also use the <code id="communicating-with-a-dedicated-worker:dom-eventtarget-addeventlistener-2"><a data-x-internal="dom-eventtarget-addeventlistener" href="https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener">addEventListener()</a></code> method.</p>

  <p>In either case, the data is provided in the event object's <code id="communicating-with-a-dedicated-worker:dom-messageevent-data"><a href="#dom-messageevent-data">data</a></code> attribute.</p>

  <p>To send messages back, you again use <code id="communicating-with-a-dedicated-worker:dom-dedicatedworkerglobalscope-postmessage"><a href="#dom-dedicatedworkerglobalscope-postmessage">postMessage()</a></code>. It supports the
  structured data in the same manner.</p>

  <pre><code class="js">postMessage<c- p="">(</c->event<c- p="">.</c->data<c- p="">.</c->input<c- p="">,</c-> <c- p="">[</c->event<c- p="">.</c->data<c- p="">.</c->input<c- p="">]);</c-> <c- c1="">// transfer the buffer back</c-></code></pre>


  <h5 id="shared-workers" data-dfn-type="dfn" data-lt="shared worker"><span class="secno">10.1.3.3</span> Shared workers<a href="#shared-workers" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker" title="The SharedWorker interface represents a specific kind of worker that can be accessed from several browsing contexts, such as several windows, iframes or even workers. They implement an interface different than dedicated workers and have a different global scope, SharedWorkerGlobalScope.">SharedWorker</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>33+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>4.0–5.0</span></span><span class="opera_android no"><span>Opera Android</span><span>11–14</span></span></div></div></div>

  <p><i>This section is non-normative.</i></p>

  <p>Shared workers are identified by the URL of the script used to create it, optionally with an
  explicit name. The name allows multiple instances of a particular shared worker to be started.</p>

  <p>Shared workers are scoped by <a href="#concept-origin" id="shared-workers:concept-origin">origin</a>. Two different sites using the same names will
  not collide. However, if a page tries to use the same shared worker name as another page on the
  same site, but with a different script URL, it will fail.</p>

  <p>Creating shared workers is done using the <code id="shared-workers:dom-sharedworker"><a href="#dom-sharedworker">SharedWorker()</a></code>
  constructor. This constructor takes the URL to the script to use for its first argument, and the
  name of the worker, if any, as the second argument.</p>

  <pre><code class="js"><c- a="">var</c-> worker <c- o="">=</c-> <c- k="">new</c-> SharedWorker<c- p="">(</c-><c- t="">'service.js'</c-><c- p="">);</c-></code></pre>

  <p>Communicating with shared workers is done with explicit <code id="shared-workers:messageport"><a href="#messageport">MessagePort</a></code> objects. The
  object returned by the <code id="shared-workers:dom-sharedworker-2"><a href="#dom-sharedworker">SharedWorker()</a></code> constructor holds a
  reference to the port on its <code id="shared-workers:dom-sharedworker-port"><a href="#dom-sharedworker-port">port</a></code> attribute.</p>

  <pre><code class="js">worker<c- p="">.</c->port<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">};</c->
worker<c- p="">.</c->port<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'some message'</c-><c- p="">);</c->
worker<c- p="">.</c->port<c- p="">.</c->postMessage<c- p="">({</c-> foo<c- o="">:</c-> <c- t="">'structured'</c-><c- p="">,</c-> bar<c- o="">:</c-> <c- p="">[</c-><c- t="">'data'</c-><c- p="">,</c-> <c- t="">'also'</c-><c- p="">,</c-> <c- t="">'possible'</c-><c- p="">]});</c-></code></pre>

  <p>Inside the shared worker, new clients of the worker are announced using the <code id="shared-workers:event-workerglobalscope-connect"><a href="#event-workerglobalscope-connect">connect</a></code> event. The port for the new client is
  given by the event object's <code id="shared-workers:dom-messageevent-source"><a href="#dom-messageevent-source">source</a></code> attribute.</p>

  <pre><code class="js">onconnect <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c->
  <c- a="">var</c-> newPort <c- o="">=</c-> event<c- p="">.</c->source<c- p="">;</c->
  <c- c1="">// set up a listener</c->
  newPort<c- p="">.</c->onmessage <c- o="">=</c-> <c- a="">function</c-> <c- p="">(</c->event<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">};</c->
  <c- c1="">// send a message back to the port</c->
  newPort<c- p="">.</c->postMessage<c- p="">(</c-><c- t="">'ready!'</c-><c- p="">);</c-> <c- c1="">// can also send structured data, of course</c->
<c- p="">};</c-></code></pre>




  <h3 id="infrastructure-2"><span class="secno">10.2</span> Infrastructure<a href="#infrastructure-2" class="self-link"></a></h3>

  <p>This standard defines two kinds of workers: dedicated workers, and shared workers. Dedicated
  workers, once created, are linked to their creator, but message ports can be used to communicate
  from a dedicated worker to multiple other browsing contexts or workers. Shared workers, on the
  other hand, are named, and once created any script running in the same <a href="#concept-origin" id="infrastructure-2:concept-origin">origin</a> can
  obtain a reference to that worker and communicate with it. <cite>Service Workers</cite> defines a
  third kind. <a href="#refsSW">[SW]</a></p>


  <h4 id="the-global-scope"><span class="secno">10.2.1</span> The global scope<a href="#the-global-scope" class="self-link"></a></h4>

  <p>The global scope is the "inside" of a worker.</p>

  <h5 id="the-workerglobalscope-common-interface"><span class="secno">10.2.1.1</span> The <code id="workerglobalscope-dev"><a href="#workerglobalscope">WorkerGlobalScope</a></code> common interface<a href="#the-workerglobalscope-common-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope" title="The WorkerGlobalScope interface of the Web Workers API is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by Window objects — in this case event handlers, the console or the associated WorkerNavigator object. Each WorkerGlobalScope has its own event loop.">WorkerGlobalScope</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Worker</c->]
<c- b="">interface</c-> <dfn id="workerglobalscope" data-dfn-type="interface"><c- g="">WorkerGlobalScope</c-></dfn> : <a id="the-workerglobalscope-common-interface:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#workerglobalscope" id="the-workerglobalscope-common-interface:workerglobalscope"><c- n="">WorkerGlobalScope</c-></a> <a href="#dom-workerglobalscope-self" id="the-workerglobalscope-common-interface:dom-workerglobalscope-self"><c- g="">self</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#workerlocation" id="the-workerglobalscope-common-interface:workerlocation"><c- n="">WorkerLocation</c-></a> <a href="#dom-workerglobalscope-location" id="the-workerglobalscope-common-interface:dom-workerglobalscope-location"><c- g="">location</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#workernavigator" id="the-workerglobalscope-common-interface:workernavigator"><c- n="">WorkerNavigator</c-></a> <a href="#dom-worker-navigator" id="the-workerglobalscope-common-interface:dom-worker-navigator"><c- g="">navigator</c-></a>;
  <c- b="">undefined</c-> <a href="#dom-workerglobalscope-importscripts" id="the-workerglobalscope-common-interface:dom-workerglobalscope-importscripts"><c- g="">importScripts</c-></a>((<code id="the-workerglobalscope-common-interface:tt-trustedscripturl"><a data-x-internal="tt-trustedscripturl" href="https://w3c.github.io/trusted-types/dist/spec/#trustedscripturl"><c- n="">TrustedScriptURL</c-></a></code> <c- b="">or</c-> <c- b="">USVString</c->)... <c- g="">urls</c->);

  <c- b="">attribute</c-> <a href="#onerroreventhandler" id="the-workerglobalscope-common-interface:onerroreventhandler"><c- n="">OnErrorEventHandler</c-></a> <a href="#handler-workerglobalscope-onerror" id="the-workerglobalscope-common-interface:handler-workerglobalscope-onerror"><c- g="">onerror</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-workerglobalscope-common-interface:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-workerglobalscope-onlanguagechange" id="the-workerglobalscope-common-interface:handler-workerglobalscope-onlanguagechange"><c- g="">onlanguagechange</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-workerglobalscope-common-interface:eventhandler-2"><c- n="">EventHandler</c-></a> <a href="#handler-workerglobalscope-onoffline" id="the-workerglobalscope-common-interface:handler-workerglobalscope-onoffline"><c- g="">onoffline</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-workerglobalscope-common-interface:eventhandler-3"><c- n="">EventHandler</c-></a> <a href="#handler-workerglobalscope-ononline" id="the-workerglobalscope-common-interface:handler-workerglobalscope-ononline"><c- g="">ononline</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-workerglobalscope-common-interface:eventhandler-4"><c- n="">EventHandler</c-></a> <a href="#handler-workerglobalscope-onrejectionhandled" id="the-workerglobalscope-common-interface:handler-workerglobalscope-onrejectionhandled"><c- g="">onrejectionhandled</c-></a>;
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-workerglobalscope-common-interface:eventhandler-5"><c- n="">EventHandler</c-></a> <a href="#handler-workerglobalscope-onunhandledrejection" id="the-workerglobalscope-common-interface:handler-workerglobalscope-onunhandledrejection"><c- g="">onunhandledrejection</c-></a>;
};</code></pre>

  <p><code id="the-workerglobalscope-common-interface:workerglobalscope-2"><a href="#workerglobalscope">WorkerGlobalScope</a></code> serves as the base class for specific types of worker global
  scope objects, including <code id="the-workerglobalscope-common-interface:dedicatedworkerglobalscope"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code>,
  <code id="the-workerglobalscope-common-interface:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code>, and <code id="the-workerglobalscope-common-interface:serviceworkerglobalscope"><a data-x-internal="serviceworkerglobalscope" href="https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope">ServiceWorkerGlobalScope</a></code>.</p>

  

  <p id="the-worker's-documents">A <code id="the-workerglobalscope-common-interface:workerglobalscope-3"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for="WorkerGlobalScope" id="concept-WorkerGlobalScope-owner-set" data-export="">owner set</dfn> (a
  <a id="the-workerglobalscope-common-interface:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <code id="the-workerglobalscope-common-interface:document"><a href="#document">Document</a></code> and <code id="the-workerglobalscope-common-interface:workerglobalscope-4"><a href="#workerglobalscope">WorkerGlobalScope</a></code> objects). It is
  initially empty and populated when the worker is created or obtained.</p>

  <p class="note">It is a <a id="the-workerglobalscope-common-interface:set-2" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a>, instead of a single owner, to accommodate
  <code id="the-workerglobalscope-common-interface:sharedworkerglobalscope-2"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> objects.</p>

  <p>A <code id="the-workerglobalscope-common-interface:workerglobalscope-5"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for="WorkerGlobalScope" id="concept-workerglobalscope-type" data-export="">type</dfn> ("<code>classic</code>" or "<code>module</code>"). It is set during creation.</p>

  <p>A <code id="the-workerglobalscope-common-interface:workerglobalscope-6"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for="WorkerGlobalScope" id="concept-workerglobalscope-url" data-export="">url</dfn> (null or a <a id="the-workerglobalscope-common-interface:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a>). It is initially
  null.</p>

  <p>A <code id="the-workerglobalscope-common-interface:workerglobalscope-7"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for="WorkerGlobalScope" id="concept-workerglobalscope-name" data-export="">name</dfn> (a string). It is set during creation.</p>

  <p class="note">The <a href="#concept-workerglobalscope-name" id="the-workerglobalscope-common-interface:concept-workerglobalscope-name">name</a> can have different
  semantics for each subclass of <code id="the-workerglobalscope-common-interface:workerglobalscope-8"><a href="#workerglobalscope">WorkerGlobalScope</a></code>. For
  <code id="the-workerglobalscope-common-interface:dedicatedworkerglobalscope-2"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> instances, it is simply a developer-supplied name, useful
  mostly for debugging purposes. For <code id="the-workerglobalscope-common-interface:sharedworkerglobalscope-3"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> instances, it allows
  obtaining a reference to a common shared worker via the <code id="the-workerglobalscope-common-interface:dom-sharedworker"><a href="#dom-sharedworker">SharedWorker()</a></code> constructor. For
  <code id="the-workerglobalscope-common-interface:serviceworkerglobalscope-2"><a data-x-internal="serviceworkerglobalscope" href="https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope">ServiceWorkerGlobalScope</a></code> objects, it doesn't make sense (and as such isn't exposed
  through the JavaScript API at all).</p>

  <p>A <code id="the-workerglobalscope-common-interface:workerglobalscope-9"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for="WorkerGlobalScope" id="concept-workerglobalscope-policy-container" data-export="">policy container</dfn> (a <a href="#policy-container" id="the-workerglobalscope-common-interface:policy-container">policy
  container</a>). It is initially a new <a href="#policy-container" id="the-workerglobalscope-common-interface:policy-container-2">policy container</a>.</p>

  <p>A <code id="the-workerglobalscope-common-interface:workerglobalscope-10"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for="WorkerGlobalScope" id="concept-workerglobalscope-embedder-policy" data-export="">embedder policy</dfn> (an <a href="#embedder-policy" id="the-workerglobalscope-common-interface:embedder-policy">embedder
  policy</a>).</p>

  <p>A <code id="the-workerglobalscope-common-interface:workerglobalscope-11"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for="WorkerGlobalScope" id="concept-workerglobalscope-module-map" data-export="">module map</dfn>.  It is a <a href="#module-map" id="the-workerglobalscope-common-interface:module-map">module map</a>,
  initially empty.</p>

  <p>A <code id="the-workerglobalscope-common-interface:workerglobalscope-12"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for="WorkerGlobalScope" id="concept-workerglobalscope-cross-origin-isolated-capability" data-export="">cross-origin isolated
  capability</dfn> boolean. It is initially false.</p>

  

  <dl class="domintro"><dt><code><var>workerGlobal</var>.<a href="#dom-workerglobalscope-self" id="dom-workerglobalscope-self-dev">self</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/self" title="The self read-only property of the WorkerGlobalScope interface returns a reference to the WorkerGlobalScope itself. Most of the time it is a specific scope like DedicatedWorkerGlobalScope, SharedWorkerGlobalScope, or ServiceWorkerGlobalScope.">WorkerGlobalScope/self</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>34+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>Returns <var>workerGlobal</var>.</dd><dt><code><var>workerGlobal</var>.<a href="#dom-workerglobalscope-location" id="dom-workerglobalscope-location-dev">location</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/location" title="The location read-only property of the WorkerGlobalScope interface returns the WorkerLocation associated with the worker. It is a specific location object, mostly a subset of the Location for browsing scopes, but adapted to workers.">WorkerGlobalScope/location</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>Returns <var>workerGlobal</var>'s <code id="the-workerglobalscope-common-interface:workerlocation-2"><a href="#workerlocation">WorkerLocation</a></code> object.</dd><dt><code><var>workerGlobal</var>.<a href="#dom-worker-navigator" id="dom-worker-navigator-dev">navigator</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/navigator" title="The navigator read-only property of the WorkerGlobalScope interface returns the WorkerNavigator associated with the worker. It is a specific navigator object, mostly a subset of the Navigator for browsing scopes, but adapted to workers.">WorkerGlobalScope/navigator</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>Returns <var>workerGlobal</var>'s <code id="the-workerglobalscope-common-interface:workernavigator-2"><a href="#workernavigator">WorkerNavigator</a></code> object.</dd><dt><code><var>workerGlobal</var>.<a href="#dom-workerglobalscope-importscripts" id="dom-workerglobalscope-importscripts-dev">importScripts</a>(...<var>urls</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts" title="The importScripts() method of the WorkerGlobalScope interface synchronously imports one or more scripts into the worker's scope.">WorkerGlobalScope/importScripts</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>Fetches each <a id="the-workerglobalscope-common-interface:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> in <var>urls</var>, executes them one-by-one in the order they
   are passed, and then returns (or throws if something went amiss).</dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerGlobalScope" id="dom-workerglobalscope-self" data-dfn-type="attribute"><code>self</code></dfn> attribute must return the
  <code id="the-workerglobalscope-common-interface:workerglobalscope-13"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object itself.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerGlobalScope" id="dom-workerglobalscope-location" data-dfn-type="attribute"><code>location</code></dfn> attribute must return the
  <code id="the-workerglobalscope-common-interface:workerlocation-3"><a href="#workerlocation">WorkerLocation</a></code> object whose associated <a href="#concept-workerlocation-workerglobalscope" id="the-workerglobalscope-common-interface:concept-workerlocation-workerglobalscope"><code>WorkerGlobalScope</code> object</a> is
  the <code id="the-workerglobalscope-common-interface:workerglobalscope-14"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object.</p>
  </div>

  <p class="note">While the <code id="the-workerglobalscope-common-interface:workerlocation-4"><a href="#workerlocation">WorkerLocation</a></code> object is created after the
  <code id="the-workerglobalscope-common-interface:workerglobalscope-15"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object, this is not problematic as it cannot be observed from
  script.</p>

  <hr>

  

  <p>The following are the <a href="#event-handlers" id="the-workerglobalscope-common-interface:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="the-workerglobalscope-common-interface:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="the-workerglobalscope-common-interface:event-handler-idl-attributes">event handler IDL attributes</a>, by objects implementing the
  <code id="the-workerglobalscope-common-interface:workerglobalscope-16"><a href="#workerglobalscope">WorkerGlobalScope</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="the-workerglobalscope-common-interface:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="the-workerglobalscope-common-interface:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="WorkerGlobalScope" id="handler-workerglobalscope-onerror" data-dfn-type="attribute"><code>onerror</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/error_event" title="The error event of the WorkerGlobalScope interface fires when an error occurs in the worker.">WorkerGlobalScope/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="the-workerglobalscope-common-interface:event-error"><a href="#event-error">error</a></code>
    </td></tr><tr><td><dfn data-dfn-for="WorkerGlobalScope" id="handler-workerglobalscope-onlanguagechange" data-dfn-type="attribute"><code>onlanguagechange</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/languagechange_event" title="The languagechange event is fired at the global scope object when the user's preferred language changes.">WorkerGlobalScope/languagechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>74+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="the-workerglobalscope-common-interface:event-languagechange"><a href="#event-languagechange">languagechange</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WorkerGlobalScope" id="handler-workerglobalscope-onoffline" data-dfn-type="attribute"><code>onoffline</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/offline_event" title="The offline event of the WorkerGlobalScope fires when the device loses connection to the internet.">WorkerGlobalScope/offline_event</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="the-workerglobalscope-common-interface:event-offline"><a href="#event-offline">offline</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WorkerGlobalScope" id="handler-workerglobalscope-ononline" data-dfn-type="attribute"><code>ononline</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/online_event" title="The online event of the WorkerGlobalScope fires when the device reconnects to the internet.">WorkerGlobalScope/online_event</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>8+</span></span><span class="chrome no"><span>Chrome</span><span>No</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink no"><span>Edge</span><span>No</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="the-workerglobalscope-common-interface:event-online"><a href="#event-online">online</a></code> 
    </td></tr><tr><td><dfn data-dfn-for="WorkerGlobalScope" id="handler-workerglobalscope-onrejectionhandled" data-dfn-type="attribute"><code>onrejectionhandled</code></dfn> </td><td> <code id="the-workerglobalscope-common-interface:event-rejectionhandled"><a href="#event-rejectionhandled">rejectionhandled</a></code>
    </td></tr><tr><td><dfn data-dfn-for="WorkerGlobalScope" id="handler-workerglobalscope-onunhandledrejection" data-dfn-type="attribute"><code>onunhandledrejection</code></dfn> </td><td> <code id="the-workerglobalscope-common-interface:event-unhandledrejection"><a href="#event-unhandledrejection">unhandledrejection</a></code>
  </td></tr></tbody></table>


  <h5 id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface"><span class="secno">10.2.1.2</span> Dedicated workers and the <code id="dedicatedworkerglobalscope-dev"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> interface<a href="#dedicated-workers-and-the-dedicatedworkerglobalscope-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope" title="The DedicatedWorkerGlobalScope object (the Worker global scope) is accessible through the self keyword. Some additional global functions, namespaces objects, and constructors, not typically associated with the worker global scope, but available on it, are listed in the JavaScript Reference. See also: Functions available to workers.">DedicatedWorkerGlobalScope</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Global</c->=(<c- n="">Worker</c->,<c- n="">DedicatedWorker</c->),<c- g="">Exposed</c->=<c- n="">DedicatedWorker</c->]
<c- b="">interface</c-> <dfn id="dedicatedworkerglobalscope" data-dfn-type="interface"><c- g="">DedicatedWorkerGlobalScope</c-></dfn> : <a href="#workerglobalscope" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:workerglobalscope"><c- n="">WorkerGlobalScope</c-></a> {
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-dedicatedworkerglobalscope-name" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-dedicatedworkerglobalscope-name"><c- g="">name</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-dedicatedworkerglobalscope-postmessage" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-dedicatedworkerglobalscope-postmessage"><c- g="">postMessage</c-></a>(<c- b="">any</c-> <c- g="">message</c->, <c- b="">sequence</c->&lt;<a href="https://webidl.spec.whatwg.org/#idl-object" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:idl-object" data-x-internal="idl-object"><c- b="">object</c-></a>&gt; <c- g="">transfer</c->);
  <c- b="">undefined</c-> <a href="#dom-dedicatedworkerglobalscope-postmessage-options" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-dedicatedworkerglobalscope-postmessage-options"><c- g="">postMessage</c-></a>(<c- b="">any</c-> <c- g="">message</c->, <c- b="">optional</c-> <a href="#structuredserializeoptions" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:structuredserializeoptions"><c- n="">StructuredSerializeOptions</c-></a> <c- g="">options</c-> = {});

  <c- b="">undefined</c-> <a href="#dom-dedicatedworkerglobalscope-close" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-dedicatedworkerglobalscope-close"><c- g="">close</c-></a>();
};

<a href="#dedicatedworkerglobalscope" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope"><c- n="">DedicatedWorkerGlobalScope</c-></a> <c- b="">includes</c-> <a href="#messageeventtarget" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:messageeventtarget"><c- n="">MessageEventTarget</c-></a>;</code></pre>

  <p><code id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope-2"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> objects have an associated <dfn id="inside-port">inside port</dfn> (a
  <code id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:messageport"><a href="#messageport">MessagePort</a></code>). This port is part of a channel that is set up when the worker is
  created, but it is not exposed. This object must never be garbage collected before
  the <code id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope-3"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> object.</p>

  <dl class="domintro"><dt><code><var>dedicatedWorkerGlobal</var>.<a href="#dom-dedicatedworkerglobalscope-name" id="dom-dedicatedworkerglobalscope-name-dev">name</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/name" title="The name read-only property of the DedicatedWorkerGlobalScope interface returns the name that the Worker was (optionally) given when it was created. This is the name that the Worker() constructor can pass to get a reference to the DedicatedWorkerGlobalScope.">DedicatedWorkerGlobalScope/name</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>55+</span></span><span class="safari yes"><span>Safari</span><span>12.1+</span></span><span class="chrome yes"><span>Chrome</span><span>70+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns <var>dedicatedWorkerGlobal</var>'s <a href="#concept-workerglobalscope-name" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:concept-workerglobalscope-name">name</a>, i.e. the value given to the
   <code id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:worker"><a href="#worker">Worker</a></code> constructor. Primarily useful for debugging.</p></dd><dt><code><var>dedicatedWorkerGlobal</var>.<a href="#dom-dedicatedworkerglobalscope-postmessage" id="dom-dedicatedworkerglobalscope-postmessage-dev">postMessage</a>(<var>message</var> [, <var>transfer</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/postMessage" title="The postMessage() method of the DedicatedWorkerGlobalScope interface sends a message to the main thread that spawned it.">DedicatedWorkerGlobalScope/postMessage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dt><code><var>dedicatedWorkerGlobal</var>.<a href="#dom-dedicatedworkerglobalscope-postmessage-options" id="dom-dedicatedworkerglobalscope-postmessage-options-dev">postMessage</a>(<var>message</var> [, { <a href="#dom-structuredserializeoptions-transfer" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-structuredserializeoptions-transfer">transfer</a> } ])</code></dt><dd><p>Clones <var>message</var> and transmits it to the <code id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:worker-2"><a href="#worker">Worker</a></code> object associated
   with <var>dedicatedWorkerGlobal</var>. <var>transfer</var> can be passed as a list of objects
   that are to be transferred rather than cloned.</p></dd><dt><code><var>dedicatedWorkerGlobal</var>.<a href="#dom-dedicatedworkerglobalscope-close" id="dom-dedicatedworkerglobalscope-close-dev">close</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/close" title="The close() method of the DedicatedWorkerGlobalScope interface discards any tasks queued in the DedicatedWorkerGlobalScope's event loop, effectively closing this particular scope.">DedicatedWorkerGlobalScope/close</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Aborts <var>dedicatedWorkerGlobal</var>.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DedicatedWorkerGlobalScope" id="dom-dedicatedworkerglobalscope-name" data-dfn-type="attribute"><code>name</code></dfn> getter steps are to return
  <a id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerglobalscope-name" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:concept-workerglobalscope-name-2">name</a>. Its value
  represents the name given to the worker using the <code id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:worker-3"><a href="#worker">Worker</a></code> constructor, used primarily
  for debugging purposes.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DedicatedWorkerGlobalScope" id="dom-dedicatedworkerglobalscope-postmessage" data-dfn-type="method"><code>postMessage(<var>message</var>,
  <var>transfer</var>)</code></dfn> and <dfn data-dfn-for="DedicatedWorkerGlobalScope" id="dom-dedicatedworkerglobalscope-postmessage-options" data-dfn-type="method"><code>postMessage(<var>message</var>,
  <var>options</var>)</code></dfn> methods on <code id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope-4"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> objects act as
  if, when invoked, it immediately invoked the respective <code id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-messageport-postmessage"><a href="#dom-messageport-postmessage">postMessage(<var>message</var>, <var>transfer</var>)</a></code>
  and <code id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-messageport-postmessage-options"><a href="#dom-messageport-postmessage-options">postMessage(<var>message</var>,
  <var>options</var>)</a></code> on the port, with the same arguments, and returned the same return
  value.</p>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="close-a-worker" data-export="">close a worker</dfn>, given a <var>workerGlobal</var>, run these steps:</p>

  <ol><li><p>Discard any <a href="#concept-task" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:concept-task">tasks</a> that have been added to
   <var>workerGlobal</var>'s <a href="#relevant-agent" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:concept-agent-event-loop">event loop</a>'s <a href="#task-queue" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:task-queue">task
   queues</a>.</p>

   </li><li><p>Set <var>workerGlobal</var>'s <a href="#dom-workerglobalscope-closing" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-workerglobalscope-closing">closing</a>
   flag to true. (This prevents any further tasks from being queued.)</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="DedicatedWorkerGlobalScope" id="dom-dedicatedworkerglobalscope-close" data-dfn-type="method"><code>close()</code></dfn> method steps are to
  <a href="#close-a-worker" id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:close-a-worker">close a worker</a> given <a id="dedicated-workers-and-the-dedicatedworkerglobalscope-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
  </div>

  <hr>

  

  <h5 id="shared-workers-and-the-sharedworkerglobalscope-interface"><span class="secno">10.2.1.3</span> Shared workers and the <code id="sharedworkerglobalscope-dev"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> interface<a href="#shared-workers-and-the-sharedworkerglobalscope-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorkerGlobalScope" title="The SharedWorkerGlobalScope object (the SharedWorker global scope) is accessible through the self keyword. Some additional global functions, namespaces objects, and constructors, not typically associated with the worker global scope, but available on it, are listed in the JavaScript Reference. See the complete list of functions available to workers.">SharedWorkerGlobalScope</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Global</c->=(<c- n="">Worker</c->,<c- n="">SharedWorker</c->),<c- g="">Exposed</c->=<c- n="">SharedWorker</c->]
<c- b="">interface</c-> <dfn id="sharedworkerglobalscope" data-dfn-type="interface"><c- g="">SharedWorkerGlobalScope</c-></dfn> : <a href="#workerglobalscope" id="shared-workers-and-the-sharedworkerglobalscope-interface:workerglobalscope"><c- n="">WorkerGlobalScope</c-></a> {
  [<c- g="">Replaceable</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c-> <a href="#dom-sharedworkerglobalscope-name" id="shared-workers-and-the-sharedworkerglobalscope-interface:dom-sharedworkerglobalscope-name"><c- g="">name</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-sharedworkerglobalscope-close" id="shared-workers-and-the-sharedworkerglobalscope-interface:dom-sharedworkerglobalscope-close"><c- g="">close</c-></a>();

  <c- b="">attribute</c-> <a href="#eventhandler" id="shared-workers-and-the-sharedworkerglobalscope-interface:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-sharedworkerglobalscope-onconnect" id="shared-workers-and-the-sharedworkerglobalscope-interface:handler-sharedworkerglobalscope-onconnect"><c- g="">onconnect</c-></a>;
};</code></pre>

  

  <p>A <code id="shared-workers-and-the-sharedworkerglobalscope-interface:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> object has associated <dfn id="concept-sharedworkerglobalscope-constructor-origin">constructor origin</dfn> (an
  <a href="#concept-origin" id="shared-workers-and-the-sharedworkerglobalscope-interface:concept-origin">origin</a>), <dfn id="concept-sharedworkerglobalscope-constructor-url">constructor
  URL</dfn> (a <a id="shared-workers-and-the-sharedworkerglobalscope-interface:url-record" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url-record">URL record</a>), and <dfn id="concept-sharedworkerglobalscope-credentials">credentials</dfn> (a <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="shared-workers-and-the-sharedworkerglobalscope-interface:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a>). They are initialized when the
  <code id="shared-workers-and-the-sharedworkerglobalscope-interface:sharedworkerglobalscope-2"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> object is created, in the <a href="#run-a-worker" id="shared-workers-and-the-sharedworkerglobalscope-interface:run-a-worker">run a worker</a>
  algorithm.</p>

  

  <p>Shared workers receive message ports through <code id="shared-workers-and-the-sharedworkerglobalscope-interface:event-workerglobalscope-connect"><a href="#event-workerglobalscope-connect">connect</a></code> events on their <code id="shared-workers-and-the-sharedworkerglobalscope-interface:sharedworkerglobalscope-3"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> object for each
  connection.</p>

  <dl class="domintro"><dt><code><var>sharedWorkerGlobal</var>.<a href="#dom-sharedworkerglobalscope-name" id="dom-sharedworkerglobalscope-name-dev">name</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorkerGlobalScope/name" title="The name read-only property of the SharedWorkerGlobalScope interface returns the name that the SharedWorker was (optionally) given when it was created. This is the name that the SharedWorker() constructor can pass to get a reference to the SharedWorkerGlobalScope.">SharedWorkerGlobalScope/name</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Returns <var>sharedWorkerGlobal</var>'s <a href="#concept-workerglobalscope-name" id="shared-workers-and-the-sharedworkerglobalscope-interface:concept-workerglobalscope-name">name</a>, i.e. the value given to the
   <code id="shared-workers-and-the-sharedworkerglobalscope-interface:sharedworker"><a href="#sharedworker">SharedWorker</a></code> constructor. Multiple <code id="shared-workers-and-the-sharedworkerglobalscope-interface:sharedworker-2"><a href="#sharedworker">SharedWorker</a></code> objects can correspond
   to the same shared worker (and <code id="shared-workers-and-the-sharedworkerglobalscope-interface:sharedworkerglobalscope-4"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code>), by reusing the same
   name.</p></dd><dt><code><var>sharedWorkerGlobal</var>.<a href="#dom-sharedworkerglobalscope-close" id="dom-sharedworkerglobalscope-close-dev">close</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorkerGlobalScope/close" title="The close() method of the SharedWorkerGlobalScope interface discards any tasks queued in the SharedWorkerGlobalScope's event loop, effectively closing this particular scope.">SharedWorkerGlobalScope/close</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Aborts <var>sharedWorkerGlobal</var>.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="SharedWorkerGlobalScope" id="dom-sharedworkerglobalscope-name" data-dfn-type="attribute"><code>name</code></dfn> getter steps are to return
  <a id="shared-workers-and-the-sharedworkerglobalscope-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerglobalscope-name" id="shared-workers-and-the-sharedworkerglobalscope-interface:concept-workerglobalscope-name-2">name</a>. Its value
  represents the name that can be used to obtain a reference to the worker using the
  <code id="shared-workers-and-the-sharedworkerglobalscope-interface:sharedworker-3"><a href="#sharedworker">SharedWorker</a></code> constructor.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="SharedWorkerGlobalScope" id="dom-sharedworkerglobalscope-close" data-dfn-type="method"><code>close()</code></dfn> method steps are to <a href="#close-a-worker" id="shared-workers-and-the-sharedworkerglobalscope-interface:close-a-worker">close a
  worker</a> given <a id="shared-workers-and-the-sharedworkerglobalscope-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p>
  </div>

  <hr>

  

  <p>The following are the <a href="#event-handlers" id="shared-workers-and-the-sharedworkerglobalscope-interface:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="shared-workers-and-the-sharedworkerglobalscope-interface:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="shared-workers-and-the-sharedworkerglobalscope-interface:event-handler-idl-attributes">event handler IDL attributes</a>, by objects implementing the
  <code id="shared-workers-and-the-sharedworkerglobalscope-interface:sharedworkerglobalscope-5"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="shared-workers-and-the-sharedworkerglobalscope-interface:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="shared-workers-and-the-sharedworkerglobalscope-interface:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="SharedWorkerGlobalScope" id="handler-sharedworkerglobalscope-onconnect" data-dfn-type="attribute"><code>onconnect</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorkerGlobalScope/connect_event" title="The connect event is fired in shared workers at their SharedWorkerGlobalScope when a new client connects.">SharedWorkerGlobalScope/connect_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="shared-workers-and-the-sharedworkerglobalscope-interface:event-workerglobalscope-connect-2"><a href="#event-workerglobalscope-connect">connect</a></code>
  </td></tr></tbody></table>



  <h4 id="worker-event-loop"><span class="secno">10.2.2</span> The event loop<a href="#worker-event-loop" class="self-link"></a></h4>

  <p>A <a href="#worker-event-loop-2" id="worker-event-loop:worker-event-loop-2">worker event loop</a>'s <a href="#task-queue" id="worker-event-loop:task-queue">task queues</a> only have
  events, callbacks, and networking activity as <a href="#concept-task" id="worker-event-loop:concept-task">tasks</a>. These <a href="#worker-event-loop-2" id="worker-event-loop:worker-event-loop-2-2">worker event loops</a> are created by the
  <a href="#run-a-worker" id="worker-event-loop:run-a-worker">run a worker</a> algorithm.</p>

  <p>Each <code id="worker-event-loop:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object has a <dfn data-dfn-for="WorkerGlobalScope" id="dom-workerglobalscope-closing" data-export="">closing</dfn> flag, which must be initially
  false, but which can get set to true by the algorithms in the processing model
  section below.</p>

  <div data-algorithm="">
  <p>Once the <code id="worker-event-loop:workerglobalscope-2"><a href="#workerglobalscope">WorkerGlobalScope</a></code>'s <a href="#dom-workerglobalscope-closing" id="worker-event-loop:dom-workerglobalscope-closing">closing</a> flag is set to true, the <a href="#event-loop" id="worker-event-loop:event-loop">event
  loop</a>'s <a href="#task-queue" id="worker-event-loop:task-queue-2">task queues</a> must discard any
  further <a href="#concept-task" id="worker-event-loop:concept-task-2">tasks</a> that would be added to them (tasks already on the
  queue are unaffected except where otherwise specified). Effectively, once the <a href="#dom-workerglobalscope-closing" id="worker-event-loop:dom-workerglobalscope-closing-2">closing</a> flag is true, timers stop firing,
  notifications for all pending background operations are dropped, etc.</p>
  </div>



  

  <h4 id="the-worker's-lifetime"><span class="secno">10.2.3</span> The worker's lifetime<a href="#the-worker's-lifetime" class="self-link"></a></h4>

  <p>Workers communicate with other workers and with <code id="the-worker's-lifetime:window"><a href="#window">Window</a></code>s through <a href="#channel-messaging" id="the-worker's-lifetime:channel-messaging">message channels</a> and their <code id="the-worker's-lifetime:messageport"><a href="#messageport">MessagePort</a></code>
  objects.</p>

  <div data-algorithm="">
  <p>Each <code id="the-worker's-lifetime:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object <var>worker global scope</var> has a list of
  <dfn id="the-worker's-ports" data-export="">the worker's ports</dfn>, which consists of all the <code id="the-worker's-lifetime:messageport-2"><a href="#messageport">MessagePort</a></code> objects
  that are entangled with another port and that have one (but only one) port owned by <var>worker
  global scope</var>. This list includes the implicit <code id="the-worker's-lifetime:messageport-3"><a href="#messageport">MessagePort</a></code> in the case of <a href="#dedicatedworkerglobalscope" id="the-worker's-lifetime:dedicatedworkerglobalscope">dedicated workers</a>.</p>
  </div>

  <div data-algorithm="">
  <p id="list-of-relevant-document-objects-to-add">Given an <a href="#environment-settings-object" id="the-worker's-lifetime:environment-settings-object">environment settings
  object</a> <var>o</var> when creating or obtaining a worker, the <dfn id="relevant-owner-to-add">relevant owner to
  add</dfn> depends on the type of <a href="#concept-settings-object-global" id="the-worker's-lifetime:concept-settings-object-global">global
  object</a> specified by <var>o</var>. If <var>o</var>'s <a href="#concept-settings-object-global" id="the-worker's-lifetime:concept-settings-object-global-2">global object</a> is a <code id="the-worker's-lifetime:workerglobalscope-2"><a href="#workerglobalscope">WorkerGlobalScope</a></code>
  object (i.e., if we are creating a nested dedicated worker), then the relevant owner is that
  global object. Otherwise, <var>o</var>'s <a href="#concept-settings-object-global" id="the-worker's-lifetime:concept-settings-object-global-3">global
  object</a> is a <code id="the-worker's-lifetime:window-2"><a href="#window">Window</a></code> object, and the relevant owner is that
  <code id="the-worker's-lifetime:window-3"><a href="#window">Window</a></code>'s <a href="#concept-document-window" id="the-worker's-lifetime:concept-document-window">associated
  <code>Document</code></a>.</p>
  </div>

  <hr>

  <p>A user agent has an <a id="the-worker's-lifetime:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> value, the <dfn id="between-loads-shared-worker-timeout">between-loads shared
  worker timeout</dfn>, which is some small amount of time. This represents how long the user agent
  allows shared workers to survive while a page is loading, in case that page is going to contact
  the shared worker again. Setting this value to greater than zero lets user agents avoid the cost
  of restarting a shared worker used by a site when the user is navigating from page to page within
  that site.</p>

  <p class="note">A typical value for the <a href="#between-loads-shared-worker-timeout" id="the-worker's-lifetime:between-loads-shared-worker-timeout">between-loads shared worker timeout</a> might be
  5 seconds.</p>

  <hr>

  <div data-algorithm="">
  <p>A <code id="the-worker's-lifetime:workerglobalscope-3"><a href="#workerglobalscope">WorkerGlobalScope</a></code> <var>global</var> is <dfn id="active-needed-worker">actively needed</dfn> if the following algorithm returns true:</p>

  <ol><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-worker's-lifetime:list-iterate" data-x-internal="list-iterate">For each</a> <var>owner</var> of <var>global</var>'s
    <a href="#concept-WorkerGlobalScope-owner-set" id="the-worker's-lifetime:concept-WorkerGlobalScope-owner-set">owner set</a>:</p>

    <ol><li><p>If <var>owner</var> is a <code id="the-worker's-lifetime:document"><a href="#document">Document</a></code>, and <var>owner</var> is <a href="#fully-active" id="the-worker's-lifetime:fully-active">fully
     active</a>, then return true.</p></li><li><p>If <var>owner</var> is a <code id="the-worker's-lifetime:workerglobalscope-4"><a href="#workerglobalscope">WorkerGlobalScope</a></code> that is <a href="#active-needed-worker" id="the-worker's-lifetime:active-needed-worker">actively needed</a>, then return true.</p></li></ol>
   </li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-worker's-lifetime:workerglobalscope-5"><a href="#workerglobalscope">WorkerGlobalScope</a></code> <var>global</var> is <dfn id="protected-worker">protected</dfn> if the following algorithm returns true:</p>

  <ol><li><p>If <var>global</var> is not <a href="#active-needed-worker" id="the-worker's-lifetime:active-needed-worker-2">actively needed</a>,
   then return false.</p></li><li><p>If <var>global</var> is a <code id="the-worker's-lifetime:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code>, then return true.</p></li><li><p>If <var>global</var>'s <a href="#the-worker's-ports" id="the-worker's-lifetime:the-worker's-ports">the worker's ports</a> is not <a href="https://infra.spec.whatwg.org/#list-is-empty" id="the-worker's-lifetime:list-is-empty" data-x-internal="list-is-empty">empty</a>, then return true.</p></li><li><p>If <var>global</var> has outstanding timers, database transactions, or network
   connections, then return true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-worker's-lifetime:workerglobalscope-6"><a href="#workerglobalscope">WorkerGlobalScope</a></code> <var>global</var> is <dfn id="permissible-worker">permissible</dfn> if the following algorithm returns true:</p>

  <ol><li><p>If <var>global</var>'s <a href="#concept-WorkerGlobalScope-owner-set" id="the-worker's-lifetime:concept-WorkerGlobalScope-owner-set-2">owner set</a> is not <a href="https://infra.spec.whatwg.org/#list-is-empty" id="the-worker's-lifetime:list-is-empty-2" data-x-internal="list-is-empty">empty</a>, then return true.</p></li><li>
    <p>If all of the following are true:</p>

    <ul><li><p><var>global</var> is a <code id="the-worker's-lifetime:sharedworkerglobalscope-2"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code>;</p></li><li><p><var>global</var>'s <a href="#concept-WorkerGlobalScope-owner-set" id="the-worker's-lifetime:concept-WorkerGlobalScope-owner-set-3">owner set</a> has been <a href="https://infra.spec.whatwg.org/#list-is-empty" id="the-worker's-lifetime:list-is-empty-3" data-x-internal="list-is-empty">empty</a> for no more than the user agent's <a href="#between-loads-shared-worker-timeout" id="the-worker's-lifetime:between-loads-shared-worker-timeout-2">between-loads shared worker
     timeout</a>; and</p>

     </li><li><p>the user agent has a <a href="#navigable" id="the-worker's-lifetime:navigable">navigable</a> whose <a href="#nav-document" id="the-worker's-lifetime:nav-document">active
     document</a> is not <a href="#completely-loaded" id="the-worker's-lifetime:completely-loaded">completely loaded</a>,</p></li></ul>

    <p>then return true.</p>
   </li><li><p>Return false.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-worker's-lifetime:workerglobalscope-7"><a href="#workerglobalscope">WorkerGlobalScope</a></code> <var>global</var> is <dfn id="suspendable-worker">suspendable</dfn> if the following algorithm returns true:</p>

  <ol><li><p>If <var>global</var> is <a href="#active-needed-worker" id="the-worker's-lifetime:active-needed-worker-3">actively needed</a>, then
   return false.</p></li><li><p>If <var>global</var> is <a href="#permissible-worker" id="the-worker's-lifetime:permissible-worker">permissible</a>, then return
   true.</p></li><li><p>Return false.</p></li></ol>
  </div>

  <div id="note-worker-lifetime-terminology" class="note"><a href="#note-worker-lifetime-terminology" class="self-link"></a>
   <p>These concepts are used elsewhere in the specification's normative requirements as
   follows:</p>

   <ul><li><p>Workers get <a href="#step-closing-orphan-workers">closed as orphans</a> between when
    they stop being <a href="#protected-worker" id="the-worker's-lifetime:protected-worker">protected</a> and when they stop being <a href="#permissible-worker" id="the-worker's-lifetime:permissible-worker-2">permissible</a>.</p></li><li><p>Workers get <a href="#step-suspending-workers">suspended or un-suspended</a> based on
    whether they are <a href="#suspendable-worker" id="the-worker's-lifetime:suspendable-worker">suspendable</a>.</p></li><li><p>Workers that have been closed, but keep executing, <a href="#terminate-rampant-workers">can be terminated</a> at the user agent's discretion, once
    they stop being <a href="#active-needed-worker" id="the-worker's-lifetime:active-needed-worker-4">actively needed</a>.</p></li></ul>

   <p>Note that every <code id="the-worker's-lifetime:workerglobalscope-8"><a href="#workerglobalscope">WorkerGlobalScope</a></code> that is <a href="#active-needed-worker" id="the-worker's-lifetime:active-needed-worker-5">actively needed</a> is <a href="#protected-worker" id="the-worker's-lifetime:protected-worker-2">protected</a>, and every
   <code id="the-worker's-lifetime:workerglobalscope-9"><a href="#workerglobalscope">WorkerGlobalScope</a></code> that is <a href="#protected-worker" id="the-worker's-lifetime:protected-worker-3">protected</a> is <a href="#permissible-worker" id="the-worker's-lifetime:permissible-worker-3">permissible</a>. (But the converses do not hold.)</p>

   <p>An important difference between <a href="#protected-worker" id="the-worker's-lifetime:protected-worker-4">protected</a> and <a href="#permissible-worker" id="the-worker's-lifetime:permissible-worker-4">permissible</a> is that a <code id="the-worker's-lifetime:workerglobalscope-10"><a href="#workerglobalscope">WorkerGlobalScope</a></code> is <a href="#protected-worker" id="the-worker's-lifetime:protected-worker-5">protected</a> only if its transitive set of owners contains at least
   one <a href="#fully-active" id="the-worker's-lifetime:fully-active-2">fully active</a> <code id="the-worker's-lifetime:document-2"><a href="#document">Document</a></code>, whereas a <code id="the-worker's-lifetime:workerglobalscope-11"><a href="#workerglobalscope">WorkerGlobalScope</a></code> can
   be <a href="#permissible-worker" id="the-worker's-lifetime:permissible-worker-5">permissible</a> even if all the <code id="the-worker's-lifetime:document-3"><a href="#document">Document</a></code>s in
   its transitive set of owners are in <a href="#note-bfcache">bfcache</a>.</p>
  </div>

  <p id="note-between-loads-shared-worker-timeout-lifetime" class="note"><a href="#note-between-loads-shared-worker-timeout-lifetime" class="self-link"></a>The <a href="#between-loads-shared-worker-timeout" id="the-worker's-lifetime:between-loads-shared-worker-timeout-3">between-loads
  shared worker timeout</a> only influences the definition of <a href="#permissible-worker" id="the-worker's-lifetime:permissible-worker-6">permissible</a>, not <a href="#protected-worker" id="the-worker's-lifetime:protected-worker-6">protected</a>, and so
  implementations are not required to keep shared workers alive for that duration. Rather, they are
  required to close shared workers after the timeout is reached.</p>


  <h4 id="worker-processing-model"><span class="secno">10.2.4</span> <span id="processing-model-10"></span>Processing model<a href="#worker-processing-model" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="run-a-worker" data-export="">run a worker</dfn> for a script with <code id="worker-processing-model:worker"><a href="#worker">Worker</a></code> or
  <code id="worker-processing-model:sharedworker"><a href="#sharedworker">SharedWorker</a></code> object <var>worker</var>, <a id="worker-processing-model:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <var>url</var>,
  <a href="#environment-settings-object" id="worker-processing-model:environment-settings-object">environment settings object</a> <var>outside settings</var>, <code id="worker-processing-model:messageport"><a href="#messageport">MessagePort</a></code>
  <var>outside port</var>, and a <code id="worker-processing-model:workeroptions"><a href="#workeroptions">WorkerOptions</a></code> dictionary <var>options</var>, it must
  run the following steps.</p>

  <ol><li><p>Let <var>is shared</var> be true if <var>worker</var> is a <code id="worker-processing-model:sharedworker-2"><a href="#sharedworker">SharedWorker</a></code>
   object, and false otherwise.</p></li><li><p>Let <var>owner</var> be the <a href="#relevant-owner-to-add" id="worker-processing-model:relevant-owner-to-add">relevant owner to add</a> given <var>outside
   settings</var>.</p></li><li><p>Let <var>unsafeWorkerCreationTime</var> be the <a id="worker-processing-model:unsafe-shared-current-time" href="https://w3c.github.io/hr-time/#dfn-unsafe-shared-current-time" data-x-internal="unsafe-shared-current-time">unsafe shared current
   time</a>.</p></li><li><p>Let <var>agent</var> be the result of <a href="#obtain-a-dedicated/shared-worker-agent" id="worker-processing-model:obtain-a-dedicated/shared-worker-agent">obtaining a dedicated/shared worker agent</a> given <var>outside settings</var> and
   <var>is shared</var>. Run the rest of these steps in that agent.</p></li><li>
    <p>Let <var>realm execution context</var> be the result of <a href="#creating-a-new-javascript-realm" id="worker-processing-model:creating-a-new-javascript-realm">creating a new realm</a>
    given <var>agent</var> and the following customizations:</p>

    <ul><li><p>For the global object, if <var>is shared</var> is true, create a new
     <code id="worker-processing-model:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> object. Otherwise, create a new
     <code id="worker-processing-model:dedicatedworkerglobalscope"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> object.</p></li></ul>
   </li><li>
    <p>Let <var>worker global scope</var> be the <a href="#concept-realm-global" id="worker-processing-model:concept-realm-global">global
    object</a> of <var>realm execution context</var>'s Realm component.

    </p><p class="note">This is the <code id="worker-processing-model:dedicatedworkerglobalscope-2"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> or
    <code id="worker-processing-model:sharedworkerglobalscope-2"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> object created in the previous step.</p>
   </li><li><p><a href="#set-up-a-worker-environment-settings-object" id="worker-processing-model:set-up-a-worker-environment-settings-object">Set up a worker environment settings object</a> with <var>realm execution
   context</var>, <var>outside settings</var>, and <var>unsafeWorkerCreationTime</var>, and let
   <var>inside settings</var> be the result.</p></li><li><p>Set <var>worker global scope</var>'s <a href="#concept-workerglobalscope-name" id="worker-processing-model:concept-workerglobalscope-name">name</a> to <var>options</var>["<code id="worker-processing-model:dom-workeroptions-name"><a href="#dom-workeroptions-name">name</a></code>"].</p></li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="worker-processing-model:set-append" data-x-internal="set-append">Append</a> <var>owner</var> to <var>worker global
   scope</var>'s <a href="#concept-WorkerGlobalScope-owner-set" id="worker-processing-model:concept-WorkerGlobalScope-owner-set">owner set</a>.</p></li><li>
    <p>If <var>is shared</var> is true, then:</p>

    <ol><li><p>Set <var>worker global scope</var>'s <a href="#concept-sharedworkerglobalscope-constructor-origin" id="worker-processing-model:concept-sharedworkerglobalscope-constructor-origin">constructor origin</a> to
     <var>outside settings</var>'s <a href="#concept-settings-object-origin" id="worker-processing-model:concept-settings-object-origin">origin</a>.</p></li><li><p>Set <var>worker global scope</var>'s <a href="#concept-sharedworkerglobalscope-constructor-url" id="worker-processing-model:concept-sharedworkerglobalscope-constructor-url">constructor URL</a> to
     <var>url</var>.</p></li><li><p>Set <var>worker global scope</var>'s <a href="#concept-workerglobalscope-type" id="worker-processing-model:concept-workerglobalscope-type">type</a> to <var>options</var>["<code id="worker-processing-model:dom-workeroptions-type"><a href="#dom-workeroptions-type">type</a></code>"].</p></li><li><p>Set <var>worker global scope</var>'s <a href="#concept-sharedworkerglobalscope-credentials" id="worker-processing-model:concept-sharedworkerglobalscope-credentials">credentials</a> to
     <var>options</var>["<code id="worker-processing-model:dom-workeroptions-credentials"><a href="#dom-workeroptions-credentials">credentials</a></code>"].</p></li></ol>
   </li><li><p>Let <var>destination</var> be "<code>sharedworker</code>" if <var>is
   shared</var> is true, and "<code>worker</code>" otherwise.</p></li><li>
    <p>Obtain <var>script</var> by switching on <var>options</var>["<code id="worker-processing-model:dom-workeroptions-type-2"><a href="#dom-workeroptions-type">type</a></code>"]:</p>

    <dl class="switch"><dt>"<code>classic</code>"</dt><dd><a href="#fetch-a-classic-worker-script" id="worker-processing-model:fetch-a-classic-worker-script">Fetch a classic worker script</a> given <var>url</var>, <var>outside
     settings</var>, <var>destination</var>, <var>inside settings</var>, and with
     <var>onComplete</var> and <var>performFetch</var> as defined below.</dd><dt>"<code>module</code>"</dt><dd><a href="#fetch-a-module-worker-script-tree" id="worker-processing-model:fetch-a-module-worker-script-tree">Fetch a module worker script graph</a> given <var>url</var>, <var>outside
     settings</var>, <var>destination</var>, the value of the <code>credentials</code>
     member of <var>options</var>, <var>inside settings</var>, and with <var>onComplete</var> and
     <var>performFetch</var> as defined below.</dd></dl>

    <p>In both cases, let <var>performFetch</var> be the following <a href="#fetching-scripts-perform-fetch" id="worker-processing-model:fetching-scripts-perform-fetch">perform the fetch hook</a> given <var>request</var>,
    <var id="worker-processing-model:fetching-scripts-is-top-level"><a href="#fetching-scripts-is-top-level">isTopLevel</a></var>, and <var id="worker-processing-model:fetching-scripts-processcustomfetchresponse"><a href="#fetching-scripts-processcustomfetchresponse">processCustomFetchResponse</a></var>:</p>

    <ol><li><p>If <var>isTopLevel</var> is false, <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="worker-processing-model:concept-fetch" data-x-internal="concept-fetch">fetch</a>
     <var>request</var> with <i id="worker-processing-model:processresponseconsumebody"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i>
     set to <var>processCustomFetchResponse</var>, and abort these steps.</p></li><li>Set <var>request</var>'s <a href="https://fetch.spec.whatwg.org/#concept-request-reserved-client" id="worker-processing-model:concept-request-reserved-client" data-x-internal="concept-request-reserved-client">reserved
     client</a> to <var>inside settings</var>.</li><li>
      <p><a href="https://fetch.spec.whatwg.org/#concept-fetch" id="worker-processing-model:concept-fetch-2" data-x-internal="concept-fetch">Fetch</a> <var>request</var> with <i id="worker-processing-model:processresponseconsumebody-2"><a data-x-internal="processresponseconsumebody" href="https://fetch.spec.whatwg.org/#process-response-end-of-body">processResponseConsumeBody</a></i> set to the following steps
      given <a href="https://fetch.spec.whatwg.org/#concept-response" id="worker-processing-model:concept-response" data-x-internal="concept-response">response</a> <var>response</var> and null, failure,
      or a <a id="worker-processing-model:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte sequence</a> <var>bodyBytes</var>:</p>

      <ol><li><p>Set <var>worker global scope</var>'s <a href="#concept-workerglobalscope-url" id="worker-processing-model:concept-workerglobalscope-url">url</a> to <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="worker-processing-model:concept-response-url" data-x-internal="concept-response-url">url</a>.</p></li><li><p><a href="#initialize-worker-policy-container" id="worker-processing-model:initialize-worker-policy-container">Initialize worker global scope's
       policy container</a> given <var>worker global scope</var>, <var>response</var>, and
       <var>inside settings</var>.</p></li><li><p>If the <a id="worker-processing-model:run-csp-initialization-for-a-global-object" href="https://w3c.github.io/webappsec-csp/#run-global-object-csp-initialization" data-x-internal="run-csp-initialization-for-a-global-object">Run CSP initialization for a global object</a> algorithm returns
       "<code>Blocked</code>" when executed upon <var>worker global scope</var>, set
       <var>response</var> to a <a id="worker-processing-model:network-error" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>. <a href="#refsCSP">[CSP]</a></p></li><li>
        <p>If <var>worker global scope</var>'s <a href="#concept-workerglobalscope-embedder-policy" id="worker-processing-model:concept-workerglobalscope-embedder-policy">embedder policy</a>'s <a href="#embedder-policy-value-2" id="worker-processing-model:embedder-policy-value-2">value</a> is <a href="#compatible-with-cross-origin-isolation" id="worker-processing-model:compatible-with-cross-origin-isolation">compatible with cross-origin
        isolation</a> and <var>is shared</var> is true, then set <var>agent</var>'s <a id="worker-processing-model:agent-cluster" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent
        cluster</a>'s <a href="#agent-cluster-cross-origin-isolation" id="worker-processing-model:agent-cluster-cross-origin-isolation">cross-origin isolation
        mode</a> to "<code id="worker-processing-model:cross-origin-isolation-logical"><a href="#cross-origin-isolation-logical">logical</a></code>" or "<code id="worker-processing-model:cross-origin-isolation-concrete"><a href="#cross-origin-isolation-concrete">concrete</a></code>". The one chosen is
        <a id="worker-processing-model:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>.</p>

        <p class="XXX">This really ought to be set when the agent cluster is created, which requires
        a redesign of this section.</p>
       </li><li><p>If the result of <a href="#check-a-global-object's-embedder-policy" id="worker-processing-model:check-a-global-object's-embedder-policy">checking a
       global object's embedder policy</a> with <var>worker global scope</var>, <var>outside
       settings</var>, and <var>response</var> is false, then set <var>response</var> to a
       <a id="worker-processing-model:network-error-2" href="https://fetch.spec.whatwg.org/#concept-network-error" data-x-internal="network-error">network error</a>.</p></li><li><p>Set <var>worker global scope</var>'s <a href="#concept-workerglobalscope-cross-origin-isolated-capability" id="worker-processing-model:concept-workerglobalscope-cross-origin-isolated-capability">cross-origin isolated
       capability</a> to true if <var>agent</var>'s <a id="worker-processing-model:agent-cluster-2" href="https://tc39.es/ecma262/#sec-agent-clusters" data-x-internal="agent-cluster">agent cluster</a>'s <a href="#agent-cluster-cross-origin-isolation" id="worker-processing-model:agent-cluster-cross-origin-isolation-2">cross-origin isolation mode</a> is "<code id="worker-processing-model:cross-origin-isolation-concrete-2"><a href="#cross-origin-isolation-concrete">concrete</a></code>".</p></li><li><p>If <var>is shared</var> is false and <var>owner</var>'s <a href="#concept-settings-object-cross-origin-isolated-capability" id="worker-processing-model:concept-settings-object-cross-origin-isolated-capability">cross-origin isolated
       capability</a> is false, then set <var>worker global scope</var>'s <a href="#concept-workerglobalscope-cross-origin-isolated-capability" id="worker-processing-model:concept-workerglobalscope-cross-origin-isolated-capability-2">cross-origin isolated
       capability</a> to false.</p></li><li>
        <p>If <var>is shared</var> is false and <var>response</var>'s
        <a href="https://fetch.spec.whatwg.org/#concept-response-url" id="worker-processing-model:concept-response-url-2" data-x-internal="concept-response-url">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="worker-processing-model:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is "<code>data</code>", then set
        <var>worker global scope</var>'s <a href="#concept-workerglobalscope-cross-origin-isolated-capability" id="worker-processing-model:concept-workerglobalscope-cross-origin-isolated-capability-3">cross-origin isolated
        capability</a> to false.</p>

        <p class="note">This is a conservative default for now, while we figure out how workers in
        general, and <code id="worker-processing-model:data-protocol"><a data-x-internal="data-protocol" href="https://www.rfc-editor.org/rfc/rfc2397#section-2">data:</a></code> URL workers in particular (which are
        cross-origin from their owner), will be treated in the context of permissions policies. See
        <a href="https://github.com/w3c/webappsec-permissions-policy/issues/207">w3c/webappsec-permissions-policy
        issue #207</a> for more details.</p>
       </li><li><p>Run <var>processCustomFetchResponse</var> with <var>response</var> and
       <var>bodyBytes</var>.</p></li></ol>
     </li></ol>

    <p>In both cases, let <var>onComplete</var> given <var>script</var> be the following steps:</p>

    <ol><li><p>If <var>script</var> is null or if <var>script</var>'s <a href="#concept-script-error-to-rethrow" id="worker-processing-model:concept-script-error-to-rethrow">error to rethrow</a> is non-null, then:</p>

     <ol><li><p><a href="#queue-a-global-task" id="worker-processing-model:queue-a-global-task">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="worker-processing-model:dom-manipulation-task-source">DOM manipulation task source</a> given
      <var>worker</var>'s <a href="#concept-relevant-global" id="worker-processing-model:concept-relevant-global">relevant global object</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="worker-processing-model:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="worker-processing-model:event-error"><a href="#event-error">error</a></code>
      at <var>worker</var>.</p></li><li><p>Run the <a href="#environment-discarding-steps" id="worker-processing-model:environment-discarding-steps">environment discarding steps</a>
      for <var>inside settings</var>.</p></li><li><p>Abort these steps.</p></li></ol>

     </li><li><p>Associate <var>worker</var> with <var>worker global scope</var>.</p></li><li><p>Let <var>inside port</var> be a <a id="worker-processing-model:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="worker-processing-model:messageport-2"><a href="#messageport">MessagePort</a></code> object in
     <var>inside settings</var>'s <a href="#environment-settings-object's-realm" id="worker-processing-model:environment-settings-object's-realm">realm</a>.</p></li><li>
      <p>If <var>is shared</var> is false, then:</p>

      <ol><li><p>Set <var>inside port</var>'s <a href="#message-event-target" id="worker-processing-model:message-event-target">message event target</a> to <var>worker global
       scope</var>.</p></li><li><p>Set <var>worker global scope</var>'s <a href="#inside-port" id="worker-processing-model:inside-port">inside port</a> to <var>inside
       port</var>.</p></li></ol>
     </li><li><p><a href="#entangle" id="worker-processing-model:entangle">Entangle</a> <var>outside port</var> and <var>inside port</var>.</p></li><li><p>Create a new <code id="worker-processing-model:workerlocation"><a href="#workerlocation">WorkerLocation</a></code> object and associate it with <var>worker global
     scope</var>.</p>

     </li><li id="step-closing-orphan-workers"><p><i>Closing orphan workers</i>: Start monitoring
     <var>worker global scope</var> such that no sooner than it stops being <a href="#protected-worker" id="worker-processing-model:protected-worker">protected</a>, and no later than it stops being <a href="#permissible-worker" id="worker-processing-model:permissible-worker">permissible</a>, <var>worker global scope</var>'s <a href="#dom-workerglobalscope-closing" id="worker-processing-model:dom-workerglobalscope-closing">closing</a> flag is set to true.</p></li><li id="step-suspending-workers"><p><i>Suspending workers</i>: Start monitoring <var>worker
     global scope</var>, such that whenever <var>worker global scope</var>'s <a href="#dom-workerglobalscope-closing" id="worker-processing-model:dom-workerglobalscope-closing-2">closing</a> flag is false and it is <a href="#suspendable-worker" id="worker-processing-model:suspendable-worker">suspendable</a>, the user agent suspends execution of script in
     <var>worker global scope</var> until such time as either the <a href="#dom-workerglobalscope-closing" id="worker-processing-model:dom-workerglobalscope-closing-3">closing</a> flag switches to true or <var>worker
     global scope</var> stops being <a href="#suspendable-worker" id="worker-processing-model:suspendable-worker-2">suspendable</a>.</p></li><li><p>Set <var>inside settings</var>'s <a href="#concept-environment-execution-ready-flag" id="worker-processing-model:concept-environment-execution-ready-flag">execution ready flag</a>.</p></li><li>
      <p>If <var>script</var> is a <a href="#classic-script" id="worker-processing-model:classic-script">classic script</a>, then <a href="#run-a-classic-script" id="worker-processing-model:run-a-classic-script">run the classic script</a> <var>script</var>. Otherwise, it is a <a href="#module-script" id="worker-processing-model:module-script">module
      script</a>; <a href="#run-a-module-script" id="worker-processing-model:run-a-module-script">run the module script</a>
      <var>script</var>.</p>

      <p class="note">In addition to the usual possibilities of returning a value or failing due to
      an exception, this could be <a href="#abort-a-running-script" id="worker-processing-model:abort-a-running-script">prematurely aborted</a> by
      the <a href="#terminate-a-worker" id="worker-processing-model:terminate-a-worker">terminate a worker</a> algorithm defined below.</p>
     </li><li><p>Enable <var>outside port</var>'s <a href="#port-message-queue" id="worker-processing-model:port-message-queue">port message queue</a>.</p></li><li><p>If <var>is shared</var> is false, enable the <a href="#port-message-queue" id="worker-processing-model:port-message-queue-2">port message queue</a>
     of the worker's implicit port.</p></li><li><p>If <var>is shared</var> is true, then <a href="#queue-a-global-task" id="worker-processing-model:queue-a-global-task-2">queue a global task</a> on the <a href="#dom-manipulation-task-source" id="worker-processing-model:dom-manipulation-task-source-2">DOM
     manipulation task source</a> given <var>worker global scope</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="worker-processing-model:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="worker-processing-model:event-workerglobalscope-connect"><a href="#event-workerglobalscope-connect">connect</a></code> at <var>worker global scope</var>, using
     <code id="worker-processing-model:messageevent"><a href="#messageevent">MessageEvent</a></code>, with the <code id="worker-processing-model:dom-messageevent-data"><a href="#dom-messageevent-data">data</a></code> attribute
     initialized to the empty string, the <code id="worker-processing-model:dom-messageevent-ports"><a href="#dom-messageevent-ports">ports</a></code> attribute
     initialized to a new <a id="worker-processing-model:frozen-array" href="https://webidl.spec.whatwg.org/#dfn-frozen-array-type" data-x-internal="frozen-array">frozen array</a> containing <var>inside port</var>, and the <code id="worker-processing-model:dom-messageevent-source"><a href="#dom-messageevent-source">source</a></code> attribute initialized to <var>inside
     port</var>.</p></li><li><p>Enable the <a href="https://w3c.github.io/ServiceWorker/#dfn-client-message-queue" id="worker-processing-model:dfn-client-message-queue" data-x-internal="dfn-client-message-queue">client message queue</a> of the
     <code id="worker-processing-model:serviceworkercontainer"><a data-x-internal="serviceworkercontainer" href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer">ServiceWorkerContainer</a></code> object whose associated <a href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client" id="worker-processing-model:serviceworkercontainer-service-worker-client" data-x-internal="serviceworkercontainer-service-worker-client">service worker client</a> is
     <var>worker global scope</var>'s <a href="#relevant-settings-object" id="worker-processing-model:relevant-settings-object">relevant settings object</a>.</p></li><li>
      <p><i>Event loop</i>: Run the <a href="#responsible-event-loop" id="worker-processing-model:responsible-event-loop">responsible
      event loop</a> specified by <var>inside settings</var> until it is destroyed.</p>

      <p class="note">The handling of events or the execution of callbacks by <a href="#concept-task" id="worker-processing-model:concept-task">tasks</a> run by the <a href="#event-loop" id="worker-processing-model:event-loop">event loop</a> might get <a href="#abort-a-running-script" id="worker-processing-model:abort-a-running-script-2">prematurely aborted</a> by the <a href="#terminate-a-worker" id="worker-processing-model:terminate-a-worker-2">terminate a
      worker</a> algorithm defined below.</p>

      <p class="note">The worker processing model remains on this step until the event loop is
      destroyed, which happens after the <a href="#dom-workerglobalscope-closing" id="worker-processing-model:dom-workerglobalscope-closing-4">closing</a>
      flag is set to true, as described in the <a href="#event-loop" id="worker-processing-model:event-loop-2">event loop</a> processing model.</p>
     </li><li>
      <p><a href="https://infra.spec.whatwg.org/#map-clear" id="worker-processing-model:map-clear" data-x-internal="map-clear">Clear</a> the <var>worker global scope</var>'s
      <a href="#map-of-active-timers" id="worker-processing-model:map-of-active-timers">map of active timers</a>.</p>
     </li><li>
      <p>Disentangle all the ports in the list of <a href="#the-worker's-ports" id="worker-processing-model:the-worker's-ports">the worker's ports</a>.</p>
     </li><li>
       <p><a href="https://infra.spec.whatwg.org/#list-empty" id="worker-processing-model:list-empty" data-x-internal="list-empty">Empty</a> <var>worker global scope</var>'s <a href="#concept-WorkerGlobalScope-owner-set" id="worker-processing-model:concept-WorkerGlobalScope-owner-set-2">owner set</a>.</p>
     </li></ol>
   </li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="terminate-a-worker" data-export="">terminate a worker</dfn>, it must run the following steps
  <a href="#in-parallel" id="worker-processing-model:in-parallel">in parallel</a> with the worker's main loop (the "<a href="#run-a-worker" id="worker-processing-model:run-a-worker">run a worker</a>" processing
  model defined above):</p>

  <ol><li><p>Set the worker's <code id="worker-processing-model:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object's <a href="#dom-workerglobalscope-closing" id="worker-processing-model:dom-workerglobalscope-closing-5">closing</a> flag to true.</p></li><li><p>If there are any <a href="#concept-task" id="worker-processing-model:concept-task-2">tasks</a> queued in the
   <code id="worker-processing-model:workerglobalscope-2"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object's <a href="#relevant-agent" id="worker-processing-model:relevant-agent">relevant agent</a>'s <a href="#concept-agent-event-loop" id="worker-processing-model:concept-agent-event-loop">event loop</a>'s <a href="#task-queue" id="worker-processing-model:task-queue">task
   queues</a>, discard them without processing them.</p></li><li><p><a href="#abort-a-running-script" id="worker-processing-model:abort-a-running-script-3">Abort the script</a> currently running in the
   worker.</p></li><li><p>If the worker's <code id="worker-processing-model:workerglobalscope-3"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object is actually a
   <code id="worker-processing-model:dedicatedworkerglobalscope-3"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> object (i.e. the worker is a dedicated worker), then
   empty the <a href="#port-message-queue" id="worker-processing-model:port-message-queue-3">port message queue</a> of the port that the worker's implicit port is
   entangled with.</p></li></ol>
  </div>

  <p id="terminate-rampant-workers">User agents may invoke the <a href="#terminate-a-worker" id="worker-processing-model:terminate-a-worker-3">terminate a worker</a>
  algorithm when a worker stops being <a href="#active-needed-worker" id="worker-processing-model:active-needed-worker">actively needed</a> and
  the worker continues executing even after its <a href="#dom-workerglobalscope-closing" id="worker-processing-model:dom-workerglobalscope-closing-6">closing</a> flag was set to true.</p>

  


  <h4 id="runtime-script-errors-2"><span class="secno">10.2.5</span> Runtime script errors<a href="#runtime-script-errors-2" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>Whenever an uncaught runtime script error occurs in one of the worker's scripts, if the error
  did not occur while handling a previous script error, the user agent will <a href="#report-an-exception" id="runtime-script-errors-2:report-an-exception">report</a> it for the worker's <code id="runtime-script-errors-2:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object.</p>
  </div>


  <h4 id="creating-workers"><span class="secno">10.2.6</span> Creating workers<a href="#creating-workers" class="self-link"></a></h4>

  <h5 id="the-abstractworker-mixin"><span class="secno">10.2.6.1</span> <span id="the-abstractworker-abstract-interface"></span>The
  <code id="the-abstractworker-mixin:abstractworker"><a href="#abstractworker">AbstractWorker</a></code> mixin<a href="#the-abstractworker-mixin" class="self-link"></a></h5>
  

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="abstractworker" data-dfn-type="interface"><c- g="">AbstractWorker</c-></dfn> {
  <c- b="">attribute</c-> <a href="#eventhandler" id="the-abstractworker-mixin:eventhandler"><c- n="">EventHandler</c-></a> <a href="#handler-abstractworker-onerror" id="the-abstractworker-mixin:handler-abstractworker-onerror"><c- g="">onerror</c-></a>;
};</code></pre>

  <p>The following are the <a href="#event-handlers" id="the-abstractworker-mixin:event-handlers">event handlers</a> (and their corresponding <a href="#event-handler-event-type" id="the-abstractworker-mixin:event-handler-event-type">event handler event types</a>) that must be supported,
  as <a href="#event-handler-idl-attributes" id="the-abstractworker-mixin:event-handler-idl-attributes">event handler IDL attributes</a>, by objects implementing the
  <code id="the-abstractworker-mixin:abstractworker-2"><a href="#abstractworker">AbstractWorker</a></code> interface:</p>

  <table><thead><tr><th><a href="#event-handlers" id="the-abstractworker-mixin:event-handlers-2">Event handler</a> </th><th><a href="#event-handler-event-type" id="the-abstractworker-mixin:event-handler-event-type-2">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="AbstractWorker" id="handler-abstractworker-onerror" data-dfn-type="attribute"><code>onerror</code></dfn> <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/error_event" title="The error event fires whenever an error occurs in the service worker.">ServiceWorker/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>44+</span></span><span class="safari yes"><span>Safari</span><span>11.1+</span></span><span class="chrome yes"><span>Chrome</span><span>40+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/error_event" title="The error event of the SharedWorker interface fires when an error occurs in the worker.">SharedWorker/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>33+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>4.0–5.0</span></span><span class="opera_android no"><span>Opera Android</span><span>11–14</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker/error_event" title="The error event of the Worker interface fires when an error occurs in the worker.">Worker/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="the-abstractworker-mixin:event-error"><a href="#event-error">error</a></code>
  </td></tr></tbody></table>


  
  <h5 id="script-settings-for-workers"><span class="secno">10.2.6.2</span> Script settings for workers<a href="#script-settings-for-workers" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="set-up-a-worker-environment-settings-object">set up a worker environment settings object</dfn>, given a <a id="script-settings-for-workers:javascript-execution-context" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript execution
  context</a> <var>execution context</var>, an <a href="#environment-settings-object" id="script-settings-for-workers:environment-settings-object">environment settings object</a>
  <var>outside settings</var>, and a number <var>unsafeWorkerCreationTime</var>:</p>

  <ol><li><p>Let <var>inherited origin</var> be <var>outside settings</var>'s <a href="#concept-settings-object-origin" id="script-settings-for-workers:concept-settings-object-origin">origin</a>.</p></li><li><p>Let <var>realm</var> be the value of <var>execution context</var>'s Realm
   component.</p></li><li><p>Let <var>worker global scope</var> be <var>realm</var>'s <a href="#concept-realm-global" id="script-settings-for-workers:concept-realm-global">global object</a>.</p></li><li>
    <p>Let <var>settings object</var> be a new <a href="#environment-settings-object" id="script-settings-for-workers:environment-settings-object-2">environment settings object</a> whose algorithms
    are defined as follows:</p>

    <dl><dt>The <a href="#realm-execution-context" id="script-settings-for-workers:realm-execution-context">realm execution context</a></dt><dd>
      <p>Return <var>execution context</var>.
     </p></dd><dt>The <a href="#concept-settings-object-module-map" id="script-settings-for-workers:concept-settings-object-module-map">module map</a></dt><dd>
      <p>Return <var>worker global scope</var>'s <a href="#concept-workerglobalscope-module-map" id="script-settings-for-workers:concept-workerglobalscope-module-map">module map</a>.</p>
     </dd><dt>The <a href="#api-base-url" id="script-settings-for-workers:api-base-url">API base URL</a></dt><dd>
      <p>Return <var>worker global scope</var>'s <a href="#concept-workerglobalscope-url" id="script-settings-for-workers:concept-workerglobalscope-url">url</a>.</p>
     </dd><dt>The <a href="#concept-settings-object-origin" id="script-settings-for-workers:concept-settings-object-origin-2">origin</a></dt><dd>
      <p>Return a unique <a href="#concept-origin-opaque" id="script-settings-for-workers:concept-origin-opaque">opaque origin</a> if <var>worker
      global scope</var>'s <a href="#concept-workerglobalscope-url" id="script-settings-for-workers:concept-workerglobalscope-url-2">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="script-settings-for-workers:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a> is "<code>data</code>", and <var>inherited
      origin</var> otherwise.</p>
     </dd><dt>The <a href="#concept-settings-object-has-cross-site-ancestor" id="script-settings-for-workers:concept-settings-object-has-cross-site-ancestor">has cross-site
     ancestry</a></dt><dd>
      <ol><li><p>If <var>outside settings</var>'s <a href="#concept-settings-object-has-cross-site-ancestor" id="script-settings-for-workers:concept-settings-object-has-cross-site-ancestor-2">has cross-site ancestor</a> is
       true, then return true.</p></li><li><p>If <var>worker global scope</var>'s <a href="#concept-workerglobalscope-url" id="script-settings-for-workers:concept-workerglobalscope-url-3">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="script-settings-for-workers:concept-url-scheme-2" data-x-internal="concept-url-scheme">scheme</a> is "<code>data</code>", then return
       true.</p></li><li><p>Return false.</p></li></ol>
     </dd><dt>The <a href="#concept-settings-object-policy-container" id="script-settings-for-workers:concept-settings-object-policy-container">policy container</a></dt><dd>
      <p>Return <var>worker global scope</var>'s <a href="#concept-workerglobalscope-policy-container" id="script-settings-for-workers:concept-workerglobalscope-policy-container">policy container</a>.</p>
     </dd><dt>The <a href="#concept-settings-object-cross-origin-isolated-capability" id="script-settings-for-workers:concept-settings-object-cross-origin-isolated-capability">cross-origin
     isolated capability</a></dt><dd><p>Return <var>worker global scope</var>'s <a href="#concept-workerglobalscope-cross-origin-isolated-capability" id="script-settings-for-workers:concept-workerglobalscope-cross-origin-isolated-capability">cross-origin isolated
     capability</a>.</p></dd><dt>The <a href="#concept-settings-object-time-origin" id="script-settings-for-workers:concept-settings-object-time-origin">time origin</a></dt><dd><p>Return the result of <a href="https://w3c.github.io/hr-time/#dfn-coarsen-time" id="script-settings-for-workers:coarsen-time" data-x-internal="coarsen-time">coarsening</a>
     <var>unsafeWorkerCreationTime</var> with <var>worker global scope</var>'s <a href="#concept-workerglobalscope-cross-origin-isolated-capability" id="script-settings-for-workers:concept-workerglobalscope-cross-origin-isolated-capability-2">cross-origin isolated
     capability</a>.</p></dd></dl>
   </li><li><p>Set <var>settings object</var>'s <a href="#concept-environment-id" id="script-settings-for-workers:concept-environment-id">id</a> to a new
   unique opaque string, <a href="#concept-environment-creation-url" id="script-settings-for-workers:concept-environment-creation-url">creation URL</a> to
   <var>worker global scope</var>'s <a id="script-settings-for-workers:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">url</a>, <a href="#concept-environment-top-level-creation-url" id="script-settings-for-workers:concept-environment-top-level-creation-url">top-level creation URL</a> to null,
   <a href="#concept-environment-target-browsing-context" id="script-settings-for-workers:concept-environment-target-browsing-context">target browsing context</a> to
   null, and <a href="#concept-environment-active-service-worker" id="script-settings-for-workers:concept-environment-active-service-worker">active service worker</a>
   to null.</p></li><li><p>If <var>worker global scope</var> is a <code id="script-settings-for-workers:dedicatedworkerglobalscope"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> object,
   then set <var>settings object</var>'s <a href="#concept-environment-top-level-origin" id="script-settings-for-workers:concept-environment-top-level-origin">top-level origin</a> to <var>outside
   settings</var>'s <a href="#concept-environment-top-level-origin" id="script-settings-for-workers:concept-environment-top-level-origin-2">top-level origin</a>.</p></li><li>
    <p>Otherwise, set <var>settings object</var>'s <a href="#concept-environment-top-level-origin" id="script-settings-for-workers:concept-environment-top-level-origin-3">top-level origin</a> to an
    <a id="script-settings-for-workers:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> value.</p>

    <p class="XXX">See <a href="https://privacycg.github.io/storage-partitioning/">Client-Side
    Storage Partitioning</a> for the latest on properly defining this.</p>
   </li><li><p>Set <var>realm</var>'s [[HostDefined]] field to <var>settings object</var>.</p></li><li><p>Return <var>settings object</var>.</p></li></ol>
  </div>
  


  <h5 id="dedicated-workers-and-the-worker-interface"><span class="secno">10.2.6.3</span> Dedicated workers and the <code id="worker-dev"><a href="#worker">Worker</a></code> interface<a href="#dedicated-workers-and-the-worker-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker" title="The Worker interface of the Web Workers API represents a background task that can be created via script, which can send messages back to its creator.">Worker</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=(<c- n="">Window</c->,<c- n="">DedicatedWorker</c->,<c- n="">SharedWorker</c->)]
<c- b="">interface</c-> <dfn id="worker" data-dfn-type="interface"><c- g="">Worker</c-></dfn> : <a id="dedicated-workers-and-the-worker-interface:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <a href="#dom-worker" id="dedicated-workers-and-the-worker-interface:dom-worker"><c- g="">constructor</c-></a>((<code id="dedicated-workers-and-the-worker-interface:tt-trustedscripturl"><a data-x-internal="tt-trustedscripturl" href="https://w3c.github.io/trusted-types/dist/spec/#trustedscripturl"><c- n="">TrustedScriptURL</c-></a></code> <c- b="">or</c-> <c- b="">USVString</c->) <c- g="">scriptURL</c->, <c- b="">optional</c-> <a href="#workeroptions" id="dedicated-workers-and-the-worker-interface:workeroptions"><c- n="">WorkerOptions</c-></a> <c- g="">options</c-> = {});

  <c- b="">undefined</c-> <a href="#dom-worker-terminate" id="dedicated-workers-and-the-worker-interface:dom-worker-terminate"><c- g="">terminate</c-></a>();

  <c- b="">undefined</c-> <a href="#dom-worker-postmessage" id="dedicated-workers-and-the-worker-interface:dom-worker-postmessage"><c- g="">postMessage</c-></a>(<c- b="">any</c-> <c- g="">message</c->, <c- b="">sequence</c->&lt;<a href="https://webidl.spec.whatwg.org/#idl-object" id="dedicated-workers-and-the-worker-interface:idl-object" data-x-internal="idl-object"><c- b="">object</c-></a>&gt; <c- g="">transfer</c->);
  <c- b="">undefined</c-> <a href="#dom-worker-postmessage-options" id="dedicated-workers-and-the-worker-interface:dom-worker-postmessage-options"><c- g="">postMessage</c-></a>(<c- b="">any</c-> <c- g="">message</c->, <c- b="">optional</c-> <a href="#structuredserializeoptions" id="dedicated-workers-and-the-worker-interface:structuredserializeoptions"><c- n="">StructuredSerializeOptions</c-></a> <c- g="">options</c-> = {});
};

<c- b="">dictionary</c-> <dfn id="workeroptions" data-dfn-type="dictionary"><c- g="">WorkerOptions</c-></dfn> {
  <c- b="">DOMString</c-> <dfn data-dfn-for="WorkerOptions" id="dom-workeroptions-name" data-dfn-type="dict-member"><c- g="">name</c-></dfn> = "";
  <a href="#workertype" id="dedicated-workers-and-the-worker-interface:workertype"><c- n="">WorkerType</c-></a> <dfn data-dfn-for="WorkerOptions" id="dom-workeroptions-type" data-dfn-type="dict-member"><c- g="">type</c-></dfn> = "classic";
  <a id="dedicated-workers-and-the-worker-interface:requestcredentials" href="https://fetch.spec.whatwg.org/#requestcredentials" data-x-internal="requestcredentials"><c- n="">RequestCredentials</c-></a> <dfn data-dfn-for="WorkerOptions" id="dom-workeroptions-credentials" data-dfn-type="dict-member"><c- g="">credentials</c-></dfn> = "same-origin"; // credentials is only used if type is "module"
};

<c- b="">enum</c-> <dfn id="workertype" data-dfn-type="enum"><c- g="">WorkerType</c-></dfn> { <c- s="">"classic"</c->, <c- s="">"module"</c-> };

<a href="#worker" id="dedicated-workers-and-the-worker-interface:worker"><c- n="">Worker</c-></a> <c- b="">includes</c-> <a href="#abstractworker" id="dedicated-workers-and-the-worker-interface:abstractworker"><c- n="">AbstractWorker</c-></a>;
<a href="#worker" id="dedicated-workers-and-the-worker-interface:worker-2"><c- n="">Worker</c-></a> <c- b="">includes</c-> <a href="#messageeventtarget" id="dedicated-workers-and-the-worker-interface:messageeventtarget"><c- n="">MessageEventTarget</c-></a>;</code></pre>

  <dl class="domintro"><dt><code><var>worker</var> = new <a href="#dom-worker" id="dom-worker-dev">Worker</a>(<var>scriptURL</var> [, <var>options</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker" title="The Worker() constructor creates a Worker object that executes the script at the specified URL. This script must obey the same-origin policy.">Worker/Worker</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>Returns a new <code id="dedicated-workers-and-the-worker-interface:worker-3"><a href="#worker">Worker</a></code> object. <var>scriptURL</var> will be fetched and executed
    in the background, creating a new global environment for which <var>worker</var> represents the
    communication channel.</p>

    <p><var>options</var> can contain the following values:</p>

    <ul><li><p><code id="dom-workeroptions-name-dev"><a href="#dom-workeroptions-name">name</a></code> can be used to define the <a href="#concept-workerglobalscope-name" id="dedicated-workers-and-the-worker-interface:concept-workerglobalscope-name">name</a> of that global environment, primarily for
     debugging purposes.</p></li><li><p><code id="dom-workeroptions-type-dev"><a href="#dom-workeroptions-type">type</a></code> can be used to load the new
     global environment from <var>scriptURL</var> as a JavaScript module, by setting it to the value
     "<code>module</code>".</p></li><li><p><code id="dom-workeroptions-credentials-dev"><a href="#dom-workeroptions-credentials">credentials</a></code> can be used to
     specify how <var>scriptURL</var> is fetched, but only if <code id="dedicated-workers-and-the-worker-interface:dom-workeroptions-type"><a href="#dom-workeroptions-type">type</a></code> is set to "<code>module</code>".</p></li></ul>
   </dd><dt><code><var>worker</var>.<a href="#dom-worker-terminate" id="dom-worker-terminate-dev">terminate</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker/terminate" title="The terminate() method of the Worker interface immediately terminates the Worker. This does not offer the worker an opportunity to finish its operations; it is stopped at once.">Worker/terminate</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>Aborts <var>worker</var>'s associated global environment.</dd><dt><code><var>worker</var>.<a href="#dom-worker-postmessage" id="dom-worker-postmessage-dev">postMessage</a>(<var>message</var> [, <var>transfer</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage" title="The postMessage() method of the Worker interface sends a message to the worker. The first parameter is the data to send to the worker. The data may be any JavaScript object that can be handled by the structured clone algorithm.">Worker/postMessage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dt><code><var>worker</var>.<a href="#dom-worker-postmessage-options" id="dom-worker-postmessage-options-dev">postMessage</a>(<var>message</var> [, { <a href="#dom-structuredserializeoptions-transfer" id="dedicated-workers-and-the-worker-interface:dom-structuredserializeoptions-transfer">transfer</a> } ])</code></dt><dd><p>Clones <var>message</var> and transmits it to <var>worker</var>'s global environment.
   <var>transfer</var> can be passed as a list of objects that are to be transferred rather than
   cloned.</p></dd></dl>

  

  <p>Each <code id="dedicated-workers-and-the-worker-interface:worker-4"><a href="#worker">Worker</a></code> object has an associated <dfn data-dfn-for="Worker" id="outside-port">outside port</dfn> (a
  <code id="dedicated-workers-and-the-worker-interface:messageport"><a href="#messageport">MessagePort</a></code>). This port is part of a channel that is set up when the worker is
  created, but it is not exposed. This object must never be garbage collected before the
  <code id="dedicated-workers-and-the-worker-interface:worker-5"><a href="#worker">Worker</a></code> object.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Worker" id="dom-worker-terminate" data-dfn-type="method"><code>terminate()</code></dfn>
  method steps are to <a href="#terminate-a-worker" id="dedicated-workers-and-the-worker-interface:terminate-a-worker">terminate a worker</a> given <a id="dedicated-workers-and-the-worker-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s worker.</p>
  </div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Worker" id="dom-worker-postmessage" data-dfn-type="method"><code>postMessage(<var>message</var>, <var>transfer</var>)</code></dfn>
  and <dfn data-dfn-for="Worker" id="dom-worker-postmessage-options" data-dfn-type="method"><code>postMessage(<var>message</var>,
  <var>options</var>)</code></dfn> methods on <code id="dedicated-workers-and-the-worker-interface:worker-6"><a href="#worker">Worker</a></code> objects act as if, when invoked,
  they immediately invoked the respective <code id="dedicated-workers-and-the-worker-interface:dom-messageport-postmessage"><a href="#dom-messageport-postmessage">postMessage(<var>message</var>, <var>transfer</var>)</a></code>
  and <code id="dedicated-workers-and-the-worker-interface:dom-messageport-postmessage-options"><a href="#dom-messageport-postmessage-options">postMessage(<var>message</var>,
  <var>options</var>)</a></code> on <a id="dedicated-workers-and-the-worker-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#outside-port" id="dedicated-workers-and-the-worker-interface:outside-port">outside port</a>, with the same
  arguments, and returned the same return value.</p>
  </div>

  

  <div class="example">

   <p>The <code id="dedicated-workers-and-the-worker-interface:dom-worker-postmessage-2"><a href="#dom-worker-postmessage">postMessage()</a></code>
   method's first argument can be structured data:</p>

   <pre><code class="js">worker<c- p="">.</c->postMessage<c- p="">({</c->opcode<c- o="">:</c-> <c- t="">'activate'</c-><c- p="">,</c-> device<c- o="">:</c-> <c- mf="">1938</c-><c- p="">,</c-> parameters<c- o="">:</c-> <c- p="">[</c-><c- mf="">23</c-><c- p="">,</c-> <c- mf="">102</c-><c- p="">]});</c-></code></pre>

  </div>

  

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Worker" id="dom-worker" data-dfn-type="constructor"><code>new Worker(<var>scriptURL</var>,
  <var>options</var>)</code></dfn> constructor steps are:</p>

  <ol><li><p>Let <var>compliantScriptURL</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="dedicated-workers-and-the-worker-interface:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="dedicated-workers-and-the-worker-interface:tt-trustedscripturl-2"><a data-x-internal="tt-trustedscripturl" href="https://w3c.github.io/trusted-types/dist/spec/#trustedscripturl">TrustedScriptURL</a></code>, <a id="dedicated-workers-and-the-worker-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="dedicated-workers-and-the-worker-interface:concept-relevant-global">relevant global
   object</a>, <var>scriptURL</var>, "<code>Worker constructor</code>", and "<code>script</code>".</p></li><li><p>Let <var>outsideSettings</var> be <a id="dedicated-workers-and-the-worker-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="dedicated-workers-and-the-worker-interface:relevant-settings-object">relevant settings
   object</a>.</p>

   </li><li>
    <p>Let <var>workerURL</var> be the result of <a href="#encoding-parsing-a-url" id="dedicated-workers-and-the-worker-interface:encoding-parsing-a-url">encoding-parsing a URL</a> given
    <var>compliantScriptURL</var>, relative to <var>outsideSettings</var>.</p>

    <p class="note">Any <a href="#same-origin" id="dedicated-workers-and-the-worker-interface:same-origin">same-origin</a> URL (including <code id="dedicated-workers-and-the-worker-interface:blob-protocol"><a data-x-internal="blob-protocol" href="https://w3c.github.io/FileAPI/#DefinitionOfScheme">blob:</a></code> URLs) can be used. <code id="dedicated-workers-and-the-worker-interface:data-protocol"><a data-x-internal="data-protocol" href="https://www.rfc-editor.org/rfc/rfc2397#section-2">data:</a></code>
    URLs can also be used, but they create a worker with an <a href="#concept-origin-opaque" id="dedicated-workers-and-the-worker-interface:concept-origin-opaque">opaque origin</a>.</p>
   </li><li><p>If <var>workerURL</var> is failure, then throw a <a id="dedicated-workers-and-the-worker-interface:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="dedicated-workers-and-the-worker-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>outsidePort</var> be a <a id="dedicated-workers-and-the-worker-interface:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="dedicated-workers-and-the-worker-interface:messageport-2"><a href="#messageport">MessagePort</a></code> in
   <var>outsideSettings</var>'s <a href="#environment-settings-object's-realm" id="dedicated-workers-and-the-worker-interface:environment-settings-object's-realm">realm</a>.</p></li><li><p>Set <var>outsidePort</var>'s <a href="#message-event-target" id="dedicated-workers-and-the-worker-interface:message-event-target">message event target</a> to
   <a id="dedicated-workers-and-the-worker-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>Set <a id="dedicated-workers-and-the-worker-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#outside-port" id="dedicated-workers-and-the-worker-interface:outside-port-2">outside port</a> to <var>outsidePort</var>.</p></li><li><p>Let <var>worker</var> be <a id="dedicated-workers-and-the-worker-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li>
    <p>Run this step <a href="#in-parallel" id="dedicated-workers-and-the-worker-interface:in-parallel">in parallel</a>:</p>

    <ol><li><p><a href="#run-a-worker" id="dedicated-workers-and-the-worker-interface:run-a-worker">Run a worker</a> given <var>worker</var>, <var>workerURL</var>,
     <var>outsideSettings</var>, <var>outsidePort</var>, and <var>options</var>.</p></li></ol>
   </li></ol>
  </div>

  


  <h5 id="shared-workers-and-the-sharedworker-interface"><span class="secno">10.2.6.4</span> Shared workers and the <code id="sharedworker-dev"><a href="#sharedworker">SharedWorker</a></code> interface<a href="#shared-workers-and-the-sharedworker-interface" class="self-link"></a></h5><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker" title="The SharedWorker interface represents a specific kind of worker that can be accessed from several browsing contexts, such as several windows, iframes or even workers. They implement an interface different than dedicated workers and have a different global scope, SharedWorkerGlobalScope.">SharedWorker</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>33+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>4.0–5.0</span></span><span class="opera_android no"><span>Opera Android</span><span>11–14</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="sharedworker" data-dfn-type="interface"><c- g="">SharedWorker</c-></dfn> : <a id="shared-workers-and-the-sharedworker-interface:eventtarget" href="https://dom.spec.whatwg.org/#interface-eventtarget" data-x-internal="eventtarget"><c- n="">EventTarget</c-></a> {
  <a href="#dom-sharedworker" id="shared-workers-and-the-sharedworker-interface:dom-sharedworker"><c- g="">constructor</c-></a>((<code id="shared-workers-and-the-sharedworker-interface:tt-trustedscripturl"><a data-x-internal="tt-trustedscripturl" href="https://w3c.github.io/trusted-types/dist/spec/#trustedscripturl"><c- n="">TrustedScriptURL</c-></a></code> <c- b="">or</c-> <c- b="">USVString</c->) <c- g="">scriptURL</c->, <c- b="">optional</c-> (<c- b="">DOMString</c-> <c- b="">or</c-> <a href="#workeroptions" id="shared-workers-and-the-sharedworker-interface:workeroptions"><c- n="">WorkerOptions</c-></a>) <c- g="">options</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#messageport" id="shared-workers-and-the-sharedworker-interface:messageport"><c- n="">MessagePort</c-></a> <a href="#dom-sharedworker-port" id="shared-workers-and-the-sharedworker-interface:dom-sharedworker-port"><c- g="">port</c-></a>;
};
<a href="#sharedworker" id="shared-workers-and-the-sharedworker-interface:sharedworker"><c- n="">SharedWorker</c-></a> <c- b="">includes</c-> <a href="#abstractworker" id="shared-workers-and-the-sharedworker-interface:abstractworker"><c- n="">AbstractWorker</c-></a>;</code></pre>

  <dl class="domintro"><dt><code><var>sharedWorker</var> = new <a href="#dom-sharedworker" id="dom-sharedworker-dev">SharedWorker</a>(<var>scriptURL</var> [, <var>name</var> ])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/SharedWorker" title="The SharedWorker() constructor creates a SharedWorker object that executes the script at the specified URL. This script must obey the same-origin policy.">SharedWorker/SharedWorker</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>33+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>4.0–5.0</span></span><span class="opera_android no"><span>Opera Android</span><span>11–14</span></span></div></div></div></dt><dd><p>Returns a new <code id="shared-workers-and-the-sharedworker-interface:sharedworker-2"><a href="#sharedworker">SharedWorker</a></code> object. <var>scriptURL</var> will be fetched and
   executed in the background, creating a new global environment for which <var>sharedWorker</var>
   represents the communication channel. <var>name</var> can be used to define the <a href="#concept-workerglobalscope-name" id="shared-workers-and-the-sharedworker-interface:concept-workerglobalscope-name">name</a> of that global environment.</p></dd><dt><code><var>sharedWorker</var> = new <a href="#dom-sharedworker" id="shared-workers-and-the-sharedworker-interface:dom-sharedworker-2">SharedWorker</a>(<var>scriptURL</var> [, <var>options</var> ])</code></dt><dd>
    <p>Returns a new <code id="shared-workers-and-the-sharedworker-interface:sharedworker-3"><a href="#sharedworker">SharedWorker</a></code> object. <var>scriptURL</var> will be fetched and
    executed in the background, creating a new global environment for which <var>sharedWorker</var>
    represents the communication channel.</p>

    <p><var>options</var> can contain the following values:</p>

    <ul><li><p><code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-name"><a href="#dom-workeroptions-name">name</a></code> can be used to define the <a href="#concept-workerglobalscope-name" id="shared-workers-and-the-sharedworker-interface:concept-workerglobalscope-name-2">name</a> of that global environment.</p></li><li><p><code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-type"><a href="#dom-workeroptions-type">type</a></code> can be used to load the new global
     environment from <var>scriptURL</var> as a JavaScript module, by setting it to the value "<code>module</code>".</p></li><li><p><code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-credentials"><a href="#dom-workeroptions-credentials">credentials</a></code> can be used to specify
     how <var>scriptURL</var> is fetched, but only if <code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-type-2"><a href="#dom-workeroptions-type">type</a></code> is set to "<code>module</code>".</p></li></ul>

    <p>Note that attempting to construct a shared worker with <var>options</var> whose <code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-type-3"><a href="#dom-workeroptions-type">type</a></code>, or <code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-credentials-2"><a href="#dom-workeroptions-credentials">credentials</a></code> values mismatch those
    of an existing shared worker with the same <a href="#concept-sharedworkerglobalscope-constructor-url" id="shared-workers-and-the-sharedworker-interface:concept-sharedworkerglobalscope-constructor-url">constructor URL</a> and <a href="#concept-workerglobalscope-name" id="shared-workers-and-the-sharedworker-interface:concept-workerglobalscope-name-3">name</a>, will cause the returned
    <var>sharedWorker</var> to fire an <code id="shared-workers-and-the-sharedworker-interface:event-error"><a href="#event-error">error</a></code> event and not connect
    to the existing shared worker.</p>
   </dd><dt><code><var>sharedWorker</var>.<a href="#dom-sharedworker-port" id="dom-sharedworker-port-dev">port</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/port" title="The port property of the SharedWorker interface returns a MessagePort object used to communicate and control the shared worker.">SharedWorker/port</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>33+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>4.0–5.0</span></span><span class="opera_android no"><span>Opera Android</span><span>11–14</span></span></div></div></div></dt><dd><p>Returns <var>sharedWorker</var>'s <code id="shared-workers-and-the-sharedworker-interface:messageport-2"><a href="#messageport">MessagePort</a></code> object which can be used to
   communicate with the global environment.</p></dd></dl>

  

  <p>A user agent has an associated <dfn id="shared-worker-manager">shared worker manager</dfn> which is the result of
  <a href="#starting-a-new-parallel-queue" id="shared-workers-and-the-sharedworker-interface:starting-a-new-parallel-queue">starting a new parallel queue</a>.</p>

  <p class="note">Each user agent has a single <a href="#shared-worker-manager" id="shared-workers-and-the-sharedworker-interface:shared-worker-manager">shared worker manager</a> for simplicity.
  Implementations could use one per <a href="#concept-origin" id="shared-workers-and-the-sharedworker-interface:concept-origin">origin</a>; that would not be observably different and
  enables more concurrency.</p>

  <hr>

  <p>Each <code id="shared-workers-and-the-sharedworker-interface:sharedworker-4"><a href="#sharedworker">SharedWorker</a></code> has a <dfn id="concept-sharedworker-port">port</dfn>, a
  <code id="shared-workers-and-the-sharedworker-interface:messageport-3"><a href="#messageport">MessagePort</a></code> set when the object is created.</p>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="SharedWorker" id="dom-sharedworker-port" data-dfn-type="attribute"><code>port</code></dfn>
  getter steps are to return <a id="shared-workers-and-the-sharedworker-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-sharedworker-port" id="shared-workers-and-the-sharedworker-interface:concept-sharedworker-port">port</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="SharedWorker" id="dom-sharedworker" data-dfn-type="constructor"><code>new
  SharedWorker(<var>scriptURL</var>, <var>options</var>)</code></dfn> constructor steps are:</p>

  <ol><li><p>Let <var>compliantScriptURL</var> be the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="shared-workers-and-the-sharedworker-interface:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="shared-workers-and-the-sharedworker-interface:tt-trustedscripturl-2"><a data-x-internal="tt-trustedscripturl" href="https://w3c.github.io/trusted-types/dist/spec/#trustedscripturl">TrustedScriptURL</a></code>, <a id="shared-workers-and-the-sharedworker-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="shared-workers-and-the-sharedworker-interface:concept-relevant-global">relevant global
   object</a>, <var>scriptURL</var>, "<code>SharedWorker constructor</code>", and
   "<code>script</code>".</p></li><li><p>If <var>options</var> is a <code id="shared-workers-and-the-sharedworker-interface:idl-domstring"><a data-x-internal="idl-domstring" href="https://webidl.spec.whatwg.org/#idl-DOMString">DOMString</a></code>, set
   <var>options</var> to a new <code id="shared-workers-and-the-sharedworker-interface:workeroptions-2"><a href="#workeroptions">WorkerOptions</a></code> dictionary whose <code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-name-2"><a href="#dom-workeroptions-name">name</a></code> member is set to the value of <var>options</var> and
   whose other members are set to their default values.</p></li><li><p>Let <var>outsideSettings</var> be <a id="shared-workers-and-the-sharedworker-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="shared-workers-and-the-sharedworker-interface:relevant-settings-object">relevant settings
   object</a>.</p></li><li>
    <p>Let <var>urlRecord</var> be the result of <a href="#encoding-parsing-a-url" id="shared-workers-and-the-sharedworker-interface:encoding-parsing-a-url">encoding-parsing a URL</a> given
    <var>compliantScriptURL</var>, relative to <var>outsideSettings</var>.</p>

    <p class="note">Any <a href="#same-origin" id="shared-workers-and-the-sharedworker-interface:same-origin">same-origin</a> URL (including <code id="shared-workers-and-the-sharedworker-interface:blob-protocol"><a data-x-internal="blob-protocol" href="https://w3c.github.io/FileAPI/#DefinitionOfScheme">blob:</a></code> URLs) can be used. <code id="shared-workers-and-the-sharedworker-interface:data-protocol"><a data-x-internal="data-protocol" href="https://www.rfc-editor.org/rfc/rfc2397#section-2">data:</a></code>
    URLs can also be used, but they create a worker with an <a href="#concept-origin-opaque" id="shared-workers-and-the-sharedworker-interface:concept-origin-opaque">opaque origin</a>.</p>
   </li><li><p>If <var>urlRecord</var> is failure, then throw a <a id="shared-workers-and-the-sharedworker-interface:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="shared-workers-and-the-sharedworker-interface:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>outsidePort</var> be a <a id="shared-workers-and-the-sharedworker-interface:new" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="shared-workers-and-the-sharedworker-interface:messageport-4"><a href="#messageport">MessagePort</a></code> in
   <var>outsideSettings</var>'s <a href="#environment-settings-object's-realm" id="shared-workers-and-the-sharedworker-interface:environment-settings-object's-realm">realm</a>.</p></li><li><p>Set <a id="shared-workers-and-the-sharedworker-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-sharedworker-port" id="shared-workers-and-the-sharedworker-interface:concept-sharedworker-port-2">port</a> to
   <var>outsidePort</var>.</p></li><li><p>Let <var>callerIsSecureContext</var> be true if <var>outsideSettings</var> is a
   <a href="#secure-context" id="shared-workers-and-the-sharedworker-interface:secure-context">secure context</a>; otherwise, false.</p></li><li><p>Let <var>outsideStorageKey</var> be the result of running <a id="shared-workers-and-the-sharedworker-interface:obtain-a-storage-key-for-non-storage-purposes" href="https://storage.spec.whatwg.org/#obtain-a-storage-key-for-non-storage-purposes" data-x-internal="obtain-a-storage-key-for-non-storage-purposes">obtain a storage key for
   non-storage purposes</a> given <var>outsideSettings</var>.</p></li><li><p>Let <var>worker</var> be <a id="shared-workers-and-the-sharedworker-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li>
    <p><a href="#enqueue-the-following-steps" id="shared-workers-and-the-sharedworker-interface:enqueue-the-following-steps">Enqueue the following steps</a> to the <a href="#shared-worker-manager" id="shared-workers-and-the-sharedworker-interface:shared-worker-manager-2">shared worker manager</a>:</p>

    <ol><li><p>Let <var>workerGlobalScope</var> be null.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="shared-workers-and-the-sharedworker-interface:list-iterate" data-x-internal="list-iterate">For each</a> <var>scope</var> in the list of all
      <code id="shared-workers-and-the-sharedworker-interface:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> objects:</p>

      <ol><li><p>Let <var>workerStorageKey</var> be the result of running <a id="shared-workers-and-the-sharedworker-interface:obtain-a-storage-key-for-non-storage-purposes-2" href="https://storage.spec.whatwg.org/#obtain-a-storage-key-for-non-storage-purposes" data-x-internal="obtain-a-storage-key-for-non-storage-purposes">obtain a storage key
        for non-storage purposes</a> given <var>scope</var>'s <a href="#relevant-settings-object" id="shared-workers-and-the-sharedworker-interface:relevant-settings-object-2">relevant settings
        object</a>.</p></li><li>
         <p>If all of the following are true:</p>

         <ul><li><var>workerStorageKey</var> <a href="https://storage.spec.whatwg.org/#storage-key-equal" id="shared-workers-and-the-sharedworker-interface:storage-key-equal" data-x-internal="storage-key-equal">equals</a>
          <var>outsideStorageKey</var>;</li><li><var>scope</var>'s <a href="#dom-workerglobalscope-closing" id="shared-workers-and-the-sharedworker-interface:dom-workerglobalscope-closing">closing</a> flag is
          false;</li><li><var>scope</var>'s <a href="#concept-sharedworkerglobalscope-constructor-url" id="shared-workers-and-the-sharedworker-interface:concept-sharedworkerglobalscope-constructor-url-2">
          constructor URL</a> <a href="https://url.spec.whatwg.org/#concept-url-equals" id="shared-workers-and-the-sharedworker-interface:concept-url-equals" data-x-internal="concept-url-equals">equals</a>
          <var>urlRecord</var>; and</li><li><var>scope</var>'s <a href="#concept-workerglobalscope-name" id="shared-workers-and-the-sharedworker-interface:concept-workerglobalscope-name-4">name</a> equals
          <var>options</var>["<code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-name-3"><a href="#dom-workeroptions-name">name</a></code>"],</li></ul>

         <p>then:</p>

         <ol><li><p>Set <var>workerGlobalScope</var> to <var>scope</var>.</p></li><li><p><a id="shared-workers-and-the-sharedworker-interface:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">Break</a>.</p></li></ol>
        </li></ol>

      <p class="note"><code id="shared-workers-and-the-sharedworker-interface:data-protocol-2"><a data-x-internal="data-protocol" href="https://www.rfc-editor.org/rfc/rfc2397#section-2">data:</a></code> URLs create a worker with an <a href="#concept-origin-opaque" id="shared-workers-and-the-sharedworker-interface:concept-origin-opaque-2">opaque origin</a>. Both the <a href="#concept-sharedworkerglobalscope-constructor-origin" id="shared-workers-and-the-sharedworker-interface:concept-sharedworkerglobalscope-constructor-origin">constructor origin</a> and
      <a href="#concept-sharedworkerglobalscope-constructor-url" id="shared-workers-and-the-sharedworker-interface:concept-sharedworkerglobalscope-constructor-url-3">constructor URL</a> are
      compared so the same <code id="shared-workers-and-the-sharedworker-interface:data-protocol-3"><a data-x-internal="data-protocol" href="https://www.rfc-editor.org/rfc/rfc2397#section-2">data:</a></code> URL can be used within an
      <a href="#concept-origin" id="shared-workers-and-the-sharedworker-interface:concept-origin-2">origin</a> to get to the same <code id="shared-workers-and-the-sharedworker-interface:sharedworkerglobalscope-2"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> object, but cannot
      be used to bypass the <a href="#same-origin" id="shared-workers-and-the-sharedworker-interface:same-origin-2">same origin</a> restriction.</p>
     </li><li>
      <p>If <var>workerGlobalScope</var> is not null, but the user agent has been configured to
      disallow communication between the worker represented by the <var>workerGlobalScope</var> and
      the <a href="#concept-script" id="shared-workers-and-the-sharedworker-interface:concept-script">scripts</a> whose <a href="#settings-object" id="shared-workers-and-the-sharedworker-interface:settings-object">settings object</a> is <var>outsideSettings</var>,
      then set <var>workerGlobalScope</var> to null.</p>

      <p class="note">For example, a user agent could have a development mode that isolates a
      particular <a href="#top-level-traversable" id="shared-workers-and-the-sharedworker-interface:top-level-traversable">top-level traversable</a> from all other pages, and scripts in that
      development mode could be blocked from connecting to shared workers running in the normal
      browser mode.</p>
     </li><li>
      <p>If <var>workerGlobalScope</var> is not null, and any of the following are true:</p>

      <ul><li><p><var>workerGlobalScope</var>'s <a href="#concept-workerglobalscope-type" id="shared-workers-and-the-sharedworker-interface:concept-workerglobalscope-type">type</a> is not equal to <var>options</var>["<code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-type-4"><a href="#dom-workeroptions-type">type</a></code>"]; or</p></li><li><p><var>workerGlobalScope</var>'s <a href="#concept-sharedworkerglobalscope-credentials" id="shared-workers-and-the-sharedworker-interface:concept-sharedworkerglobalscope-credentials">credentials</a> is not equal to
       <var>options</var>["<code id="shared-workers-and-the-sharedworker-interface:dom-workeroptions-credentials-3"><a href="#dom-workeroptions-credentials">credentials</a></code>"]</p></li></ul>

      <p>then:</p>

      <ol><li><p><a href="#queue-a-global-task" id="shared-workers-and-the-sharedworker-interface:queue-a-global-task">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="shared-workers-and-the-sharedworker-interface:dom-manipulation-task-source">DOM manipulation task source</a>
       given <var>worker</var>'s <a href="#concept-relevant-global" id="shared-workers-and-the-sharedworker-interface:concept-relevant-global-2">relevant global object</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="shared-workers-and-the-sharedworker-interface:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="shared-workers-and-the-sharedworker-interface:event-error-2"><a href="#event-error">error</a></code> at <var>worker</var>.</p></li><li><p>Abort these steps.</p></li></ol>
     </li><li>
      <p>If <var>workerGlobalScope</var> is not null:</p>

      <ol><li><p>Let <var>insideSettings</var> be <var>workerGlobalScope</var>'s <a href="#relevant-settings-object" id="shared-workers-and-the-sharedworker-interface:relevant-settings-object-3">relevant
       settings object</a>.</p></li><li><p>Let <var>workerIsSecureContext</var> be true if <var>insideSettings</var> is a
       <a href="#secure-context" id="shared-workers-and-the-sharedworker-interface:secure-context-2">secure context</a>; otherwise, false.</p></li><li>
        <p>If <var>workerIsSecureContext</var> is not <var>callerIsSecureContext</var>:</p>

        <ol><li><p><a href="#queue-a-global-task" id="shared-workers-and-the-sharedworker-interface:queue-a-global-task-2">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="shared-workers-and-the-sharedworker-interface:dom-manipulation-task-source-2">DOM manipulation task source</a>
         given <var>worker</var>'s <a href="#concept-relevant-global" id="shared-workers-and-the-sharedworker-interface:concept-relevant-global-3">relevant global object</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="shared-workers-and-the-sharedworker-interface:concept-event-fire-2" data-x-internal="concept-event-fire">fire an event</a> named <code id="shared-workers-and-the-sharedworker-interface:event-error-3"><a href="#event-error">error</a></code> at <var>worker</var>.</p></li><li><p>Abort these steps.</p></li></ol>
       </li><li><p>Associate <var>worker</var> with <var>workerGlobalScope</var>.</p></li><li><p>Let <var>insidePort</var> be a <a id="shared-workers-and-the-sharedworker-interface:new-2" href="https://webidl.spec.whatwg.org/#new" data-x-internal="new">new</a> <code id="shared-workers-and-the-sharedworker-interface:messageport-5"><a href="#messageport">MessagePort</a></code> in
       <var>insideSettings</var>'s <a href="#environment-settings-object's-realm" id="shared-workers-and-the-sharedworker-interface:environment-settings-object's-realm-2">realm</a>.</p></li><li><p><a href="#entangle" id="shared-workers-and-the-sharedworker-interface:entangle">Entangle</a> <var>outsidePort</var> and <var>insidePort</var>.</p></li><li><p><a href="#queue-a-global-task" id="shared-workers-and-the-sharedworker-interface:queue-a-global-task-3">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="shared-workers-and-the-sharedworker-interface:dom-manipulation-task-source-3">DOM manipulation task source</a>
       given <var>workerGlobalScope</var> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="shared-workers-and-the-sharedworker-interface:concept-event-fire-3" data-x-internal="concept-event-fire">fire an event</a>
       named <code id="shared-workers-and-the-sharedworker-interface:event-workerglobalscope-connect"><a href="#event-workerglobalscope-connect">connect</a></code> at
       <var>workerGlobalScope</var>, using <code id="shared-workers-and-the-sharedworker-interface:messageevent"><a href="#messageevent">MessageEvent</a></code>, with the <code id="shared-workers-and-the-sharedworker-interface:dom-messageevent-data"><a href="#dom-messageevent-data">data</a></code> attribute initialized to the empty string, the
       <code id="shared-workers-and-the-sharedworker-interface:dom-messageevent-ports"><a href="#dom-messageevent-ports">ports</a></code> attribute initialized to a new
       <a id="shared-workers-and-the-sharedworker-interface:frozen-array" href="https://webidl.spec.whatwg.org/#dfn-frozen-array-type" data-x-internal="frozen-array">frozen array</a> containing only <var>insidePort</var>, and the <code id="shared-workers-and-the-sharedworker-interface:dom-messageevent-source"><a href="#dom-messageevent-source">source</a></code> attribute initialized to
       <var>insidePort</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#set-append" id="shared-workers-and-the-sharedworker-interface:set-append" data-x-internal="set-append">Append</a> the <a href="#relevant-owner-to-add" id="shared-workers-and-the-sharedworker-interface:relevant-owner-to-add">relevant owner to add</a> given
       <var>outsideSettings</var> to <var>workerGlobalScope</var>'s <a href="#concept-WorkerGlobalScope-owner-set" id="shared-workers-and-the-sharedworker-interface:concept-WorkerGlobalScope-owner-set">owner set</a>.</p></li></ol>
     </li><li><p>Otherwise, <a href="#in-parallel" id="shared-workers-and-the-sharedworker-interface:in-parallel">in parallel</a>, <a href="#run-a-worker" id="shared-workers-and-the-sharedworker-interface:run-a-worker">run a worker</a> given <var>worker</var>,
     <var>urlRecord</var>, <var>outsideSettings</var>, <var>outsidePort</var>, and
     <var>options</var>.</p></li></ol>
   </li></ol>
  </div>

  


  <h4 id="navigator.hardwareconcurrency"><span class="secno">10.2.7</span> Concurrent hardware capabilities<a href="#navigator.hardwareconcurrency" class="self-link"></a></h4>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="navigatorconcurrenthardware" data-dfn-type="interface"><c- g="">NavigatorConcurrentHardware</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <c- b="">long</c-> <a href="#dom-navigator-hardwareconcurrency" id="navigator.hardwareconcurrency:dom-navigator-hardwareconcurrency"><c- g="">hardwareConcurrency</c-></a>;
};</code></pre>

  <dl class="domintro"><dt><code><var>self</var>.<a href="#dom-navigator" id="navigator.hardwareconcurrency:dom-navigator">navigator</a>.<a href="#dom-navigator-hardwareconcurrency" id="dom-navigator-hardwareconcurrency-dev">hardwareConcurrency</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/hardwareConcurrency" title="The navigator.hardwareConcurrency read-only property returns the number of logical processors available to run threads on the user's computer.">Navigator/hardwareConcurrency</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>48+</span></span><span class="safari no"><span>Safari</span><span>10.1–11</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>15+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/hardwareConcurrency" title="The navigator.hardwareConcurrency read-only property returns the number of logical processors available to run threads on the user's computer.">Navigator/hardwareConcurrency</a></p><div class="support"><span class="firefox yes"><span>Firefox</span><span>48+</span></span><span class="safari no"><span>Safari</span><span>10.1–11</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>15+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd><p>Returns the number of logical processors potentially available to the user agent.</p></dd></dl>

  

  <div data-algorithm="">
  <p>
  <a id="navigator.hardwareconcurrency:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  The <dfn data-dfn-for="NavigatorConcurrentHardware" id="dom-navigator-hardwareconcurrency" data-dfn-type="attribute"><code>navigator.hardwareConcurrency</code></dfn> attribute's
  getter must return a number between 1 and the number of logical processors potentially available
  to the user agent. If this cannot be determined, the getter must return 1.</p>
  </div>

  <p>User agents should err toward exposing the number of logical processors available, using lower
  values only in cases where there are user-agent specific limits in place (such as a limitation
  on the number of <a href="#worker" id="navigator.hardwareconcurrency:worker">workers</a> that can be created) or when the user agent
  desires to limit fingerprinting possibilities.</p>

  

  <h3 id="apis-available-to-workers"><span class="secno">10.3</span> APIs available to workers<a href="#apis-available-to-workers" class="self-link"></a></h3>

  

  <h4 id="importing-scripts-and-libraries"><span class="secno">10.3.1</span> Importing scripts and libraries<a href="#importing-scripts-and-libraries" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerGlobalScope" id="dom-workerglobalscope-importscripts" data-dfn-type="method"><code>importScripts(...<var>urls</var>)</code></dfn>
  method steps are:</p>

  <ol><li><p>Let <var>urlStrings</var> be « ».</p></li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="importing-scripts-and-libraries:list-iterate" data-x-internal="list-iterate">For each</a> <var>url</var> of <var>urls</var>:</p>

    <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="importing-scripts-and-libraries:list-append" data-x-internal="list-append">Append</a> the result of invoking the <a href="https://w3c.github.io/trusted-types/dist/spec/#get-trusted-type-compliant-string-algorithm" id="importing-scripts-and-libraries:tt-getcompliantstring" data-x-internal="tt-getcompliantstring">Get Trusted Type compliant string</a> algorithm with <code id="importing-scripts-and-libraries:tt-trustedscripturl"><a data-x-internal="tt-trustedscripturl" href="https://w3c.github.io/trusted-types/dist/spec/#trustedscripturl">TrustedScriptURL</a></code>, <a id="importing-scripts-and-libraries:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-relevant-global" id="importing-scripts-and-libraries:concept-relevant-global">relevant global
     object</a>, <var>url</var>, "<code>WorkerGlobalScope importScripts</code>", and
     "<code>script</code>" to <var>urlStrings</var>.</p></li></ol>
   </li><li><p><a href="#import-scripts-into-worker-global-scope" id="importing-scripts-and-libraries:import-scripts-into-worker-global-scope">Import scripts into worker global scope</a> given <a id="importing-scripts-and-libraries:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> and
   <var>urlStrings</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="import-scripts-into-worker-global-scope" data-export="">import scripts into worker global scope</dfn>, given a
  <code id="importing-scripts-and-libraries:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object <var>worker global scope</var>, a <a id="importing-scripts-and-libraries:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of
  <a href="https://infra.spec.whatwg.org/#scalar-value-string" id="importing-scripts-and-libraries:scalar-value-string" data-x-internal="scalar-value-string">scalar value strings</a> <var>urls</var>, and an optional
  <a href="#fetching-scripts-perform-fetch" id="importing-scripts-and-libraries:fetching-scripts-perform-fetch">perform the fetch hook</a>
  <var>performFetch</var>:</p>

  <ol><li><p>If <var>worker global scope</var>'s <a href="#concept-workerglobalscope-type" id="importing-scripts-and-libraries:concept-workerglobalscope-type">type</a> is "<code>module</code>", throw a
   <code id="importing-scripts-and-libraries:typeerror"><a data-x-internal="typeerror" href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> exception.</p></li><li><p>Let <var>settings object</var> be the <a href="#current-settings-object" id="importing-scripts-and-libraries:current-settings-object">current settings object</a>.</p></li><li><p>If <var>urls</var> is empty, return.</p></li><li><p>Let <var>urlRecords</var> be « ».</p></li><li>
    <p>For each <var>url</var> of <var>urls</var>:</p>

    <ol><li><p>Let <var>urlRecord</var> be the result of <a href="#encoding-parsing-a-url" id="importing-scripts-and-libraries:encoding-parsing-a-url">encoding-parsing a URL</a> given
     <var>url</var>, relative to <var>settings object</var>.</p></li><li><p>If <var>urlRecord</var> is failure, then throw a <a id="importing-scripts-and-libraries:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
     <code id="importing-scripts-and-libraries:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="importing-scripts-and-libraries:list-append-2" data-x-internal="list-append">Append</a> <var>urlRecord</var> to
     <var>urlRecords</var>.</p></li></ol>
   </li><li>
    <p>For each <var>urlRecord</var> of <var>urlRecords</var>:</p>

    <ol><li><p><a href="#fetch-a-classic-worker-imported-script" id="importing-scripts-and-libraries:fetch-a-classic-worker-imported-script">Fetch a classic worker-imported script</a> given <var>urlRecord</var> and
     <var>settings object</var>, passing along <var>performFetch</var> if provided. If this
     succeeds, let <var>script</var> be the result. Otherwise, rethrow the exception.</p></li><li>
      <p><a href="#run-a-classic-script" id="importing-scripts-and-libraries:run-a-classic-script">Run the classic script</a> <var>script</var>, with
      <i>rethrow errors</i> set to true.</p>

      <p class="note"><var>script</var> will run until it either returns, fails to parse, fails to
      catch an exception, or gets <a href="#abort-a-running-script" id="importing-scripts-and-libraries:abort-a-running-script">prematurely aborted</a>
      by the <a href="#terminate-a-worker" id="importing-scripts-and-libraries:terminate-a-worker">terminate a worker</a> algorithm defined above.</p>

      <p>If an exception was thrown or if the script was <a href="#abort-a-running-script" id="importing-scripts-and-libraries:abort-a-running-script-2">prematurely aborted</a>, then abort all these steps, letting the exception or
      aborting continue to be processed by the calling <a href="#concept-script" id="importing-scripts-and-libraries:concept-script">script</a>.</p>
     </li></ol>
   </li></ol>
  </div>

  <p class="note"><cite>Service Workers</cite> is an example of a specification that runs this
  algorithm with its own <a href="#fetching-scripts-perform-fetch" id="importing-scripts-and-libraries:fetching-scripts-perform-fetch-2">perform the fetch
  hook</a>. <a href="#refsSW">[SW]</a></p>

  


  <h4 id="the-workernavigator-object"><span class="secno">10.3.2</span> The <code id="workernavigator-dev"><a href="#workernavigator">WorkerNavigator</a></code> interface<a href="#the-workernavigator-object" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator" title="The WorkerNavigator interface represents a subset of the Navigator interface allowed to be accessed from a Worker. Such an object is initialized for each worker and is available via the self.navigator property.">WorkerNavigator</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerGlobalScope" id="dom-worker-navigator" data-dfn-type="attribute"><code>navigator</code></dfn> attribute of the
  <code id="the-workernavigator-object:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> interface must return an instance of the
  <code id="the-workernavigator-object:workernavigator"><a href="#workernavigator">WorkerNavigator</a></code> interface, which represents the identity and state of the user agent
  (the client):</p>
  </div>

  

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Worker</c->]
<c- b="">interface</c-> <dfn id="workernavigator" data-dfn-type="interface"><c- g="">WorkerNavigator</c-></dfn> {};
<a href="#workernavigator" id="the-workernavigator-object:workernavigator-2"><c- n="">WorkerNavigator</c-></a> <c- b="">includes</c-> <a href="#navigatorid" id="the-workernavigator-object:navigatorid"><c- n="">NavigatorID</c-></a>;
<a href="#workernavigator" id="the-workernavigator-object:workernavigator-3"><c- n="">WorkerNavigator</c-></a> <c- b="">includes</c-> <a href="#navigatorlanguage" id="the-workernavigator-object:navigatorlanguage"><c- n="">NavigatorLanguage</c-></a>;
<a href="#workernavigator" id="the-workernavigator-object:workernavigator-4"><c- n="">WorkerNavigator</c-></a> <c- b="">includes</c-> <a href="#navigatoronline" id="the-workernavigator-object:navigatoronline"><c- n="">NavigatorOnLine</c-></a>;
<a href="#workernavigator" id="the-workernavigator-object:workernavigator-5"><c- n="">WorkerNavigator</c-></a> <c- b="">includes</c-> <a href="#navigatorconcurrenthardware" id="the-workernavigator-object:navigatorconcurrenthardware"><c- n="">NavigatorConcurrentHardware</c-></a>;</code></pre>

  

  <h4 id="worker-locations"><span class="secno">10.3.3</span> The <code id="workerlocation-dev"><a href="#workerlocation">WorkerLocation</a></code> interface<a href="#worker-locations" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation" title="The WorkerLocation interface defines the absolute location of the script executed by the Worker. Such an object is initialized for each worker and is available via the WorkerGlobalScope.location property obtained by calling self.location.">WorkerLocation</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/toString" title="The toString() stringifier method of a WorkerLocation object returns a string containing the serialized URL for the worker's location. It is a synonym for WorkerLocation.href.">WorkerLocation/toString</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>15+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>14+</span></span></div></div></div><pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Worker</c->]
<c- b="">interface</c-> <dfn id="workerlocation" data-dfn-type="interface"><c- g="">WorkerLocation</c-></dfn> {
  <c- b="">stringifier</c-> <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-workerlocation-href" id="worker-locations:dom-workerlocation-href"><c- g="">href</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-workerlocation-origin" id="worker-locations:dom-workerlocation-origin"><c- g="">origin</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-workerlocation-protocol" id="worker-locations:dom-workerlocation-protocol"><c- g="">protocol</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-workerlocation-host" id="worker-locations:dom-workerlocation-host"><c- g="">host</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-workerlocation-hostname" id="worker-locations:dom-workerlocation-hostname"><c- g="">hostname</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-workerlocation-port" id="worker-locations:dom-workerlocation-port"><c- g="">port</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-workerlocation-pathname" id="worker-locations:dom-workerlocation-pathname"><c- g="">pathname</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-workerlocation-search" id="worker-locations:dom-workerlocation-search"><c- g="">search</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-workerlocation-hash" id="worker-locations:dom-workerlocation-hash"><c- g="">hash</c-></a>;
};</code></pre>

  

  

  <p>A <code id="worker-locations:workerlocation"><a href="#workerlocation">WorkerLocation</a></code> object has an associated <dfn id="concept-workerlocation-workerglobalscope"><code>WorkerGlobalScope</code> object</dfn> (a
  <code id="worker-locations:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code> object).

  </p><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/href" title="The href property of a WorkerLocation object returns a string containing the serialized URL for the worker's location.">WorkerLocation/href</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerLocation" id="dom-workerlocation-href" data-dfn-type="attribute"><code>href</code></dfn> getter steps are to return <a id="worker-locations:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s
  <a href="#concept-workerlocation-workerglobalscope" id="worker-locations:concept-workerlocation-workerglobalscope"><code>WorkerGlobalScope</code>
  object</a>'s <a href="#concept-workerglobalscope-url" id="worker-locations:concept-workerglobalscope-url">url</a>, <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="worker-locations:concept-url-serializer" data-x-internal="concept-url-serializer">serialized</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/origin" title="The origin property of a WorkerLocation object returns the worker's origin.">WorkerLocation/origin</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>10+</span></span><span class="chrome yes"><span>Chrome</span><span>38+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>14+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerLocation" id="dom-workerlocation-origin" data-dfn-type="attribute"><code>origin</code></dfn> getter steps are to return the <a href="#ascii-serialisation-of-an-origin" id="worker-locations:ascii-serialisation-of-an-origin">serialization</a> of <a id="worker-locations:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerlocation-workerglobalscope" id="worker-locations:concept-workerlocation-workerglobalscope-2"><code>WorkerGlobalScope</code> object</a>'s
  <a href="#concept-workerglobalscope-url" id="worker-locations:concept-workerglobalscope-url-2">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-origin" id="worker-locations:concept-url-origin" data-x-internal="concept-url-origin">origin</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/protocol" title="The protocol property of a WorkerLocation object returns the protocol part of the worker's location.">WorkerLocation/protocol</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerLocation" id="dom-workerlocation-protocol" data-dfn-type="attribute"><code>protocol</code></dfn> getter steps are to return
  <a id="worker-locations:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerlocation-workerglobalscope" id="worker-locations:concept-workerlocation-workerglobalscope-3"><code>WorkerGlobalScope</code> object</a>'s
  <a href="#concept-workerglobalscope-url" id="worker-locations:concept-workerglobalscope-url-3">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-scheme" id="worker-locations:concept-url-scheme" data-x-internal="concept-url-scheme">scheme</a>, followed by "<code>:</code>".</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/host" title="The host property of a WorkerLocation object returns the host part of the worker's location.">WorkerLocation/host</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerLocation" id="dom-workerlocation-host" data-dfn-type="attribute"><code>host</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>url</var> be <a id="worker-locations:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerlocation-workerglobalscope" id="worker-locations:concept-workerlocation-workerglobalscope-4"><code>WorkerGlobalScope</code> object</a>'s
   <a href="#concept-workerglobalscope-url" id="worker-locations:concept-workerglobalscope-url-4">url</a>.</p></li><li><p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="worker-locations:concept-url-host" data-x-internal="concept-url-host">host</a> is null, return the empty
   string.</p></li><li><p>If <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="worker-locations:concept-url-port" data-x-internal="concept-url-port">port</a> is null, return
   <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="worker-locations:concept-url-host-2" data-x-internal="concept-url-host">host</a>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="worker-locations:host-serializer" data-x-internal="host-serializer">serialized</a>.</p></li><li><p>Return <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="worker-locations:concept-url-host-3" data-x-internal="concept-url-host">host</a>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="worker-locations:host-serializer-2" data-x-internal="host-serializer">serialized</a>, followed by "<code>:</code>" and <var>url</var>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="worker-locations:concept-url-port-2" data-x-internal="concept-url-port">port</a>, <a href="https://url.spec.whatwg.org/#serialize-an-integer" id="worker-locations:serialize-an-integer" data-x-internal="serialize-an-integer">serialized</a>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/hostname" title="The hostname property of a WorkerLocation object returns the hostname part of the worker's location.">WorkerLocation/hostname</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerLocation" id="dom-workerlocation-hostname" data-dfn-type="attribute"><code>hostname</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>host</var> be <a id="worker-locations:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerlocation-workerglobalscope" id="worker-locations:concept-workerlocation-workerglobalscope-5"><code>WorkerGlobalScope</code> object</a>'s
   <a href="#concept-workerglobalscope-url" id="worker-locations:concept-workerglobalscope-url-5">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-host" id="worker-locations:concept-url-host-4" data-x-internal="concept-url-host">host</a>.</p></li><li><p>If <var>host</var> is null, return the empty string.</p></li><li><p>Return <var>host</var>, <a href="https://url.spec.whatwg.org/#concept-host-serializer" id="worker-locations:host-serializer-3" data-x-internal="host-serializer">serialized</a>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/port" title="The port property of a WorkerLocation object returns the port part of the worker's location.">WorkerLocation/port</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerLocation" id="dom-workerlocation-port" data-dfn-type="attribute"><code>port</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>port</var> be <a id="worker-locations:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerlocation-workerglobalscope" id="worker-locations:concept-workerlocation-workerglobalscope-6"><code>WorkerGlobalScope</code> object</a>'s
   <a href="#concept-workerglobalscope-url" id="worker-locations:concept-workerglobalscope-url-6">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-port" id="worker-locations:concept-url-port-3" data-x-internal="concept-url-port">port</a>.</p></li><li><p>If <var>port</var> is null, return the empty string.</p></li><li><p>Return <var>port</var>, <a href="https://url.spec.whatwg.org/#serialize-an-integer" id="worker-locations:serialize-an-integer-2" data-x-internal="serialize-an-integer">serialized</a>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/pathname" title="The pathname property of a WorkerLocation object returns the pathname part of the worker's location.">WorkerLocation/pathname</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerLocation" id="dom-workerlocation-pathname" data-dfn-type="attribute"><code>pathname</code></dfn> getter steps are to return the result
  of <a href="https://url.spec.whatwg.org/#url-path-serializer" id="worker-locations:url-path-serializer" data-x-internal="url-path-serializer">URL path serializing</a> <a id="worker-locations:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerlocation-workerglobalscope" id="worker-locations:concept-workerlocation-workerglobalscope-7"><code>WorkerGlobalScope</code> object</a>'s
  <a href="#concept-workerglobalscope-url" id="worker-locations:concept-workerglobalscope-url-7">url</a>.</p>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/search" title="The search property of a WorkerLocation object returns the search part of the worker's location.">WorkerLocation/search</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerLocation" id="dom-workerlocation-search" data-dfn-type="attribute"><code>search</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>query</var> be <a id="worker-locations:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerlocation-workerglobalscope" id="worker-locations:concept-workerlocation-workerglobalscope-8"><code>WorkerGlobalScope</code> object</a>'s
   <a href="#concept-workerglobalscope-url" id="worker-locations:concept-workerglobalscope-url-8">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-query" id="worker-locations:concept-url-query" data-x-internal="concept-url-query">query</a>.</p></li><li><p>If <var>query</var> is either null or the empty string, return the empty string.</p></li><li><p>Return "<code>?</code>", followed by <var>query</var>.</p></li></ol>
  </div>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation/hash" title="The hash property of a WorkerLocation object returns the hash part of the worker's location.">WorkerLocation/hash</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><div data-algorithm="">
  <p>The <dfn data-dfn-for="WorkerLocation" id="dom-workerlocation-hash" data-dfn-type="attribute"><code>hash</code></dfn> getter steps are:</p>

  <ol><li><p>Let <var>fragment</var> be <a id="worker-locations:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-workerlocation-workerglobalscope" id="worker-locations:concept-workerlocation-workerglobalscope-9"><code>WorkerGlobalScope</code> object</a>'s
   <a href="#concept-workerglobalscope-url" id="worker-locations:concept-workerglobalscope-url-9">url</a>'s <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="worker-locations:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a>.</p></li><li><p>If <var>fragment</var> is either null or the empty string, return the empty string.</p></li><li><p>Return "<code>#</code>", followed by <var>fragment</var>.</p></li></ol>
  </div>

  


  <h2 id="worklets"><span class="secno">11</span> Worklets<a href="#worklets" class="self-link"></a></h2>

  <h3 id="worklets-intro"><span class="secno">11.1</span> Introduction<a href="#worklets-intro" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>Worklets are a piece of specification infrastructure which can be used for running scripts
  independent of the main JavaScript execution environment, while not requiring any particular
  implementation model.</p>

  <p>The worklet infrastructure specified here cannot be used directly by web developers. Instead,
  other specifications build upon it to create directly-usable worklet types, specialized for
  running in particular parts of the browser implementation pipeline.</p>

  <h4 id="worklets-motivations"><span class="secno">11.1.1</span> Motivations<a href="#worklets-motivations" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Allowing extension points to rendering, or other sensitive parts of the implementation pipeline
  such as audio output, is difficult. If extension points were done with full access to the APIs
  available on <code id="worklets-motivations:window"><a href="#window">Window</a></code>, engines would need to abandon previously-held assumptions for
  what could happen in the middle of those phases. For example, during the layout phase, rendering
  engines assume that no DOM will be modified.</p>

  <p>Additionally, defining extension points in the <code id="worklets-motivations:window-2"><a href="#window">Window</a></code> environment would restrict
  user agents to performing work in the same thread as the <code id="worklets-motivations:window-3"><a href="#window">Window</a></code> object. (Unless
  implementations added complex, high-overhead infrastructure to allow thread-safe APIs, as well
  as thread-joining guarantees.)</p>

  <p>Worklets are designed to allow extension points, while keeping guarantees that user agents
  currently rely on. This is done through new global environments, based on subclasses of
  <code id="worklets-motivations:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>.</p>

  <p>Worklets are similar to web workers. However, they:</p>

  <ul><li><p>Are thread-agnostic. That is, they are not designed to run on a dedicated separate thread,
   like each worker is. Implementations can run worklets wherever they choose (including on the main
   thread).</p></li><li><p>Are able to have multiple duplicate instances of the global scope created, for the purpose
   of parallelism.</p></li><li><p>Do not use an event-based API. Instead, classes are registered on the global scope, whose
   methods are invoked by the user agent.</p></li><li><p>Have a reduced API surface on the global scope.</p></li><li><p>Have a lifetime for their <a href="#global-object" id="worklets-motivations:global-object">global object</a> which is defined by other
   specifications, often in an <a id="worklets-motivations:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner.</p></li></ul>

  <p>As worklets have relatively high overhead, they are best used sparingly. Due to this, a given
  <code id="worklets-motivations:workletglobalscope-2"><a href="#workletglobalscope">WorkletGlobalScope</a></code> is expected to be shared between multiple separate scripts. (This
  is similar to how a single <code id="worklets-motivations:window-4"><a href="#window">Window</a></code> is shared between multiple separate scripts.)</p>

  <p>Worklets are a general technology that serve different use cases. Some worklets, such as those
  defined in <cite>CSS Painting API</cite>, provide extension points intended for stateless,
  idempotent, and short-running computations, which have special considerations as described in the
  next couple of sections. Others, such as those defined in <cite>Web Audio API</cite>, are used for
  stateful, long-running operations. <a href="#refsCSSPAINT">[CSSPAINT]</a> <a href="#refsWEBAUDIO">[WEBAUDIO]</a></p>

  <h4 id="worklets-idempotent"><span class="secno">11.1.2</span> Code idempotence<a href="#worklets-idempotent" class="self-link"></a></h4>

  <p>Some specifications which use worklets are intended to allow user agents to parallelize work
  over multiple threads, or to move work between threads as required. In these specifications, user
  agents might invoke methods on a web-developer-provided class in an
  <a id="worklets-idempotent:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> order.</p>

  <p>As a result of this, to prevent interoperability issues, authors who register classes on such
  <code id="worklets-idempotent:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s should make their code idempotent. That is, a method or set of
  methods on the class should produce the same output given a particular input.</p>

  <p>This specification uses the following techniques in order to encourage authors to write code in
  an idempotent way:</p>

  <ul><li>
    <p>No reference to the global object is available (i.e., there is no counterpart to <code id="worklets-idempotent:dom-workerglobalscope-self"><a href="#dom-workerglobalscope-self">self</a></code> on <code id="worklets-idempotent:workletglobalscope-2"><a href="#workletglobalscope">WorkletGlobalScope</a></code>).</p>

    <p class="XXX">Although this was the intention when worklets were first specified, the
    introduction of <code>globalThis</code> has made it no longer true. See <a href="https://github.com/whatwg/html/issues/6059">issue #6059</a> for more discussion.</p>
   </li><li><p>Code is loaded as a <a href="#module-script" id="worklets-idempotent:module-script">module script</a>, which results in the code being executed
   in strict mode and with no shared <code>this</code> referencing the global
   proxy.</p></li></ul>

  <p>Together, these restrictions help prevent two different scripts from sharing state using
  properties of the <a href="#global-object" id="worklets-idempotent:global-object">global object</a>.</p>

  <p>Additionally, specifications which use worklets and intend to allow
  <a id="worklets-idempotent:implementation-defined-2" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> behavior must obey the following:</p>

  <ul><li><p>They must require user agents to always have at least two <code id="worklets-idempotent:workletglobalscope-3"><a href="#workletglobalscope">WorkletGlobalScope</a></code>
   instances per <code id="worklets-idempotent:worklet"><a href="#worklet">Worklet</a></code>, and randomly assign a method or set of methods on a class to
   a particular <code id="worklets-idempotent:workletglobalscope-4"><a href="#workletglobalscope">WorkletGlobalScope</a></code> instance. These specifications may provide an
   opt-out under memory constraints.</p></li><li><p>These specifications must allow user agents to create and destroy instances of their
   <code id="worklets-idempotent:workletglobalscope-5"><a href="#workletglobalscope">WorkletGlobalScope</a></code> subclasses at any time.</p></li></ul>

  <h4 id="worklets-speculative"><span class="secno">11.1.3</span> Speculative evaluation<a href="#worklets-speculative" class="self-link"></a></h4>

  <p>Some specifications which use worklets can invoke methods on a web-developer-provided class
  based on the state of the user agent. To increase concurrency between threads, a user agent may
  invoke a method speculatively, based on potential future states.</p>

  <p>In these specifications, user agents might invoke such methods at any time, and with any
  arguments, not just ones corresponding to the current state of the user agent. The results of such
  speculative evaluations are not displayed immediately, but can be cached for use if the user agent
  state matches the speculated state. This can increase the concurrency between the user agent and
  worklet threads.</p>

  <p>As a result of this, to prevent interoperability risks between user agents, authors who
  register classes on such <code id="worklets-speculative:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s should make their code stateless. That
  is, the only effect of invoking a method should be its result, and not any side effects such as
  updating mutable state.</p>

  <p>The same techniques which encourage <a href="#worklets-idempotent">code idempotence</a> also
  encourage authors to write stateless code.</p>

  <div class="non-normative">

  <h3 id="worklets-examples"><span class="secno">11.2</span> Examples<a href="#worklets-examples" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>For these examples, we'll use a fake worklet. The <code id="worklets-examples:window"><a href="#window">Window</a></code> object provides two
  <code id="worklets-examples:worklet"><a href="#worklet">Worklet</a></code> instances, which each run code in their own collection of
  <code id="worklets-examples:fakeworkletglobalscope"><a href="#fakeworkletglobalscope">FakeWorkletGlobalScope</a></code>s:

  </p><pre class="extract"><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#window" id="worklets-examples:window-2"><c- g="">Window</c-></a> {
  [<c- g="">SameObject</c->, <c- g="">SecureContext</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#worklet" id="worklets-examples:worklet-2"><c- n="">Worklet</c-></a> <a href="#fakeworklet1" id="worklets-examples:fakeworklet1"><c- g="">fakeWorklet1</c-></a>;
  [<c- g="">SameObject</c->, <c- g="">SecureContext</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#worklet" id="worklets-examples:worklet-3"><c- n="">Worklet</c-></a> <a href="#fakeworklet2" id="worklets-examples:fakeworklet2"><c- g="">fakeWorklet2</c-></a>;
};</code></pre>

  

  <p>Each <code id="worklets-examples:window-3"><a href="#window">Window</a></code> has two <code id="worklets-examples:worklet-4"><a href="#worklet">Worklet</a></code> instances, <dfn id="fake-worklet-1">fake
  worklet 1</dfn> and <dfn id="fake-worklet-2">fake worklet 2</dfn>. Both of these have their <a href="#worklet-global-scope-type" id="worklets-examples:worklet-global-scope-type">worklet
  global scope type</a> set to <code id="worklets-examples:fakeworkletglobalscope-2"><a href="#fakeworkletglobalscope">FakeWorkletGlobalScope</a></code>, and their <a href="#worklet-destination-type" id="worklets-examples:worklet-destination-type">worklet
  destination type</a> set to "<code>fakeworklet</code>". User agents should create at
  least two <code id="worklets-examples:fakeworkletglobalscope-3"><a href="#fakeworkletglobalscope">FakeWorkletGlobalScope</a></code> instances per worklet.</p>

  <p class="note">"<code>fakeworklet</code>" is not actually a valid <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="worklets-examples:concept-request-destination" data-x-internal="concept-request-destination">destination</a> per <cite>Fetch</cite>. But this
  illustrates how real worklets would generally have their own worklet-type-specific destination.
  <a href="#refsFETCH">[FETCH]</a></p>

  

  <div data-algorithm="">
  <p>The <dfn id="fakeworklet1" data-noexport=""><code>fakeWorklet1</code></dfn> getter steps are to return
  <a id="worklets-examples:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#fake-worklet-1" id="worklets-examples:fake-worklet-1">fake worklet 1</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="fakeworklet2" data-noexport=""><code>fakeWorklet2</code></dfn> getter steps are to return
  <a id="worklets-examples:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#fake-worklet-2" id="worklets-examples:fake-worklet-2">fake worklet 2</a>.</p>
  </div>

  

  <hr>

  <pre class="extract"><code class="idl">[<c- g="">Global</c->=(<c- n="">Worklet</c->,<c- n="">FakeWorklet</c->),
 <c- g="">Exposed</c->=<c- n="">FakeWorklet</c->,
 <c- g="">SecureContext</c->]
<c- b="">interface</c-> <dfn id="fakeworkletglobalscope" data-dfn-type="interface" data-noexport=""><c- g="">FakeWorkletGlobalScope</c-></dfn> : <a href="#workletglobalscope" id="worklets-examples:workletglobalscope"><c- n="">WorkletGlobalScope</c-></a> {
  <c- b="">undefined</c-> <a href="#dom-fakeworkletglobalscope-registerfake" id="worklets-examples:dom-fakeworkletglobalscope-registerfake"><c- g="">registerFake</c-></a>(<c- b="">DOMString</c-> <c- g="">type</c->, <a href="https://webidl.spec.whatwg.org/#common-Function" id="worklets-examples:idl-function" data-x-internal="idl-function"><c- n="">Function</c-></a> <c- g="">classConstructor</c->);
};</code></pre>

  

  

  

  <p>Each <code id="worklets-examples:fakeworkletglobalscope-4"><a href="#fakeworkletglobalscope">FakeWorkletGlobalScope</a></code> has a <dfn id="registered-class-constructors-map">registered class constructors map</dfn>,
  which is an <a id="worklets-examples:ordered-map" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a>, initially empty.</p>

  <div data-algorithm="">
  <p>The <dfn id="dom-fakeworkletglobalscope-registerfake" data-noexport=""><code>registerFake(<var>type</var>, <var>classConstructor</var>)</code></dfn> method
  steps are to set <a id="worklets-examples:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#registered-class-constructors-map" id="worklets-examples:registered-class-constructors-map">registered class constructors
  map</a>[<var>type</var>] to <var>classConstructor</var>.</p>
  </div>

  

  <h4 id="worklets-examples-loading"><span class="secno">11.2.1</span> Loading scripts<a href="#worklets-examples-loading" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>To load scripts into <a href="#fake-worklet-1" id="worklets-examples-loading:fake-worklet-1">fake worklet 1</a>, a web developer would write:</p>

  <pre><code class="js">window<c- p="">.</c->fakeWorklet1<c- p="">.</c->addModule<c- p="">(</c-><c- t="">'script1.mjs'</c-><c- p="">);</c->
window<c- p="">.</c->fakeWorklet1<c- p="">.</c->addModule<c- p="">(</c-><c- t="">'script2.mjs'</c-><c- p="">);</c-></code></pre>

  <p>Note that which script finishes fetching and runs first is dependent on network timing: it
  could be either <code>script1.mjs</code> or <code>script2.mjs</code>. This
  generally won't matter for well-written scripts intended to be loaded in worklets, if they follow
  the suggestions about preparing for <a href="#worklets-speculative">speculative
  evaluation</a>.</p>

  <p>If a web developer wants to perform a task only after the scripts have successfully run and
  loaded into some worklets, they could write:</p>

  <pre><code class="js">Promise<c- p="">.</c->all<c- p="">([</c->
    window<c- p="">.</c->fakeWorklet1<c- p="">.</c->addModule<c- p="">(</c-><c- t="">'script1.mjs'</c-><c- p="">),</c->
    window<c- p="">.</c->fakeWorklet2<c- p="">.</c->addModule<c- p="">(</c-><c- t="">'script2.mjs'</c-><c- p="">)</c->
<c- p="">]).</c->then<c- p="">(()</c-> <c- p="">=&gt;</c-> <c- p="">{</c->
    <c- c1="">// Do something which relies on those scripts being loaded.</c->
<c- p="">});</c-></code></pre>

  <hr>

  <p>Another important point about script-loading is that loaded scripts can be run in multiple
  <code id="worklets-examples-loading:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s per <code id="worklets-examples-loading:worklet"><a href="#worklet">Worklet</a></code>, as discussed in the section on <a href="#worklets-idempotent">code idempotence</a>. In particular, the specification above
  for <a href="#fake-worklet-1" id="worklets-examples-loading:fake-worklet-1-2">fake worklet 1</a> and <a href="#fake-worklet-2" id="worklets-examples-loading:fake-worklet-2">fake worklet 2</a> require this. So, consider a
  scenario such as the following:</p>

  <pre><code class="js"><c- c1="">// script.mjs</c->
console<c- p="">.</c->log<c- p="">(</c-><c- u="">"Hello from a FakeWorkletGlobalScope!"</c-><c- p="">);</c-></code></pre>

  <pre><code class="js"><c- c1="">// app.mjs</c->
window<c- p="">.</c->fakeWorklet1<c- p="">.</c->addModule<c- p="">(</c-><c- u="">"script.mjs"</c-><c- p="">);</c-></code></pre>

  <p>This could result in output such as the following from a user agent's console:</p>

  <pre><code>[fakeWorklet1#1] Hello from a FakeWorkletGlobalScope!
[fakeWorklet1#4] Hello from a FakeWorkletGlobalScope!
[fakeWorklet1#2] Hello from a FakeWorkletGlobalScope!
[fakeWorklet1#3] Hello from a FakeWorkletGlobalScope!</code></pre>

  <p>If the user agent at some point decided to kill and restart the third instance of
  <code id="worklets-examples-loading:fakeworkletglobalscope"><a href="#fakeworkletglobalscope">FakeWorkletGlobalScope</a></code>, the console would again print <code>[fakeWorklet1#3] Hello from a FakeWorkletGlobalScope!</code> when this occurs.</p>

  <h4 id="worklets-example-registering"><span class="secno">11.2.2</span> Registering a class and invoking its methods<a href="#worklets-example-registering" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>Let's say that one of the intended usages of our fake worklet by web developers is to allow
  them to customize the highly-complex process of boolean negation. They might register their
  customization as follows:</p>

  <pre><code class="js"><c- c1="">// script.mjs</c->
registerFake<c- p="">(</c-><c- t="">'negation-processor'</c-><c- p="">,</c-> <c- a="">class</c-> <c- p="">{</c->
  process<c- p="">(</c->arg<c- p="">)</c-> <c- p="">{</c->
    <c- k="">return</c-> <c- o="">!</c->arg<c- p="">;</c->
  <c- p="">}</c->
<c- p="">});</c-></code></pre>

  <pre><code class="js"><c- c1="">// app.mjs</c->
window<c- p="">.</c->fakeWorklet1<c- p="">.</c->addModule<c- p="">(</c-><c- u="">"script.mjs"</c-><c- p="">);</c-></code></pre>

  <div data-algorithm="">
  <p>To make use of such registered classes, the specification for fake worklets could define a <dfn id="fakeworkletglobalscope-process">find the opposite of true</dfn> algorithm, given a
  <code id="worklets-example-registering:worklet"><a href="#worklet">Worklet</a></code> <var>worklet</var>:</p>

  <ol><li><p>Optionally, <a href="#create-a-worklet-global-scope" id="worklets-example-registering:create-a-worklet-global-scope">create a worklet global scope</a> for <var>worklet</var>.</p></li><li><p>Let <var>workletGlobalScope</var> be one of <var>worklet</var>'s <a href="#concept-worklet-global-scopes" id="worklets-example-registering:concept-worklet-global-scopes">global scopes</a>, chosen in an
   <a id="worklets-example-registering:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner.</p></li><li><p>Let <var>classConstructor</var> be <var>workletGlobalScope</var>'s <a href="#registered-class-constructors-map" id="worklets-example-registering:registered-class-constructors-map">registered class
   constructors map</a>["<code>negation-processor</code>"].</p></li><li><p>Let <var>classInstance</var> be the result of <a href="https://webidl.spec.whatwg.org/#construct-a-callback-function" id="worklets-example-registering:es-constructing-callback-functions" data-x-internal="es-constructing-callback-functions">constructing</a> <var>classConstructor</var>, with
   no arguments.</p></li><li><p>Let <var>function</var> be <a href="https://tc39.es/ecma262/#sec-get-o-p" id="worklets-example-registering:js-get" data-x-internal="js-get">Get</a>(<var>classInstance</var>,
   "<code>process</code>"). Rethrow any exceptions.</p>

   </li><li><p>Let <var>callback</var> be the result of <a href="https://webidl.spec.whatwg.org/#es-type-mapping" id="worklets-example-registering:concept-idl-convert" data-x-internal="concept-idl-convert">converting</a> <var>function</var> to a Web IDL <code id="worklets-example-registering:idl-function"><a data-x-internal="idl-function" href="https://webidl.spec.whatwg.org/#common-Function">Function</a></code> instance.</p></li><li><p>Return the result of <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="worklets-example-registering:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">invoking</a>
   <var>callback</var> with « true » and "<code>rethrow</code>", and with <i id="worklets-example-registering:dfn-callback-this-value"><a data-x-internal="dfn-callback-this-value" href="https://webidl.spec.whatwg.org/#dfn-callback-this-value">callback this value</a></i> set to
   <var>classInstance</var>.</p></li></ol>
  </div>

  <p class="note">Another, perhaps better, specification architecture would be to extract the "<code>process</code>" property and convert it into a <code id="worklets-example-registering:idl-function-2"><a data-x-internal="idl-function" href="https://webidl.spec.whatwg.org/#common-Function">Function</a></code> at registration time, as part of the <code id="worklets-example-registering:dom-fakeworkletglobalscope-registerfake"><a href="#dom-fakeworkletglobalscope-registerfake">registerFake()</a></code> method steps.</p>

  </div>

  <h3 id="worklets-infrastructure"><span class="secno">11.3</span> Infrastructure<a href="#worklets-infrastructure" class="self-link"></a></h3>

  <h4 id="worklets-global"><span class="secno">11.3.1</span> The global scope<a href="#worklets-global" class="self-link"></a></h4>

  <p>Subclasses of <code id="workletglobalscope-dev"><a href="#workletglobalscope">WorkletGlobalScope</a></code> are used to create <a href="#global-object" id="worklets-global:global-object">global objects</a> wherein code loaded into a particular <code id="worklets-global:worklet"><a href="#worklet">Worklet</a></code> can
  execute.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Worklet</c->, <c- g="">SecureContext</c->]
<c- b="">interface</c-> <dfn id="workletglobalscope" data-dfn-type="interface"><c- g="">WorkletGlobalScope</c-></dfn> {};</code></pre>

  <p class="note">Other specifications are intended to subclass <code id="worklets-global:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>,
  adding APIs to register a class, as well as other APIs specific for their worklet type.</p>

  

  <p>Each <code id="worklets-global:workletglobalscope-2"><a href="#workletglobalscope">WorkletGlobalScope</a></code> has an associated <dfn id="concept-workletglobalscope-module-map">module map</dfn>. It is a <a href="#module-map" id="worklets-global:module-map">module map</a>,
  initially empty.</p>

  

  <h5 id="worklet-agents-and-event-loops"><span class="secno">11.3.1.1</span> Agents and event loops<a href="#worklet-agents-and-event-loops" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Each <code id="worklet-agents-and-event-loops:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code> is contained in its own <a href="#worklet-agent" id="worklet-agents-and-event-loops:worklet-agent">worklet agent</a>, which
  has its corresponding <a href="#concept-agent-event-loop" id="worklet-agents-and-event-loops:concept-agent-event-loop">event loop</a>. However, in
  practice, implementation of these agents and event loops is expected to be different from most
  others.</p>

  <p>A <a href="#worklet-agent" id="worklet-agents-and-event-loops:worklet-agent-2">worklet agent</a> exists for each <code id="worklet-agents-and-event-loops:workletglobalscope-2"><a href="#workletglobalscope">WorkletGlobalScope</a></code> since, in theory,
  an implementation could use a separate thread for each <code id="worklet-agents-and-event-loops:workletglobalscope-3"><a href="#workletglobalscope">WorkletGlobalScope</a></code> instance,
  and allowing this level of parallelism is best done using agents. However, because their
  [[CanBlock]] value is false, there is no requirement that agents and threads are one-to-one. This
  allows implementations the freedom to execute scripts loaded into a worklet on any thread,
  including one running code from other agents with [[CanBlock]] of false, such as the thread of a
  <a href="#similar-origin-window-agent" id="worklet-agents-and-event-loops:similar-origin-window-agent">similar-origin window agent</a> ("the main thread"). Contrast this with <a href="#dedicated-worker-agent" id="worklet-agents-and-event-loops:dedicated-worker-agent">dedicated worker agents</a>, whose true value for [[CanBlock]]
  effectively requires them to get a dedicated operating system thread.</p>

  <p>Worklet <a href="#event-loop" id="worklet-agents-and-event-loops:event-loop">event loops</a> are also somewhat special. They are only
  used for <a href="#concept-task" id="worklet-agents-and-event-loops:concept-task">tasks</a> associated with <code id="worklet-agents-and-event-loops:dom-worklet-addmodule"><a href="#dom-worklet-addmodule">addModule()</a></code>, tasks wherein the user agent invokes
  author-defined methods, and <a href="#microtask" id="worklet-agents-and-event-loops:microtask">microtasks</a>. Thus, even though the <a href="#event-loop-processing-model">event loop processing model</a> specifies that all event loops
  run continuously, implementations can achieve observably-equivalent results using a simpler
  strategy, which just <a href="https://webidl.spec.whatwg.org/#invoke-a-callback-function" id="worklet-agents-and-event-loops:es-invoking-callback-functions" data-x-internal="es-invoking-callback-functions">invokes</a> author-provided
  methods and then relies on that process to <a href="#perform-a-microtask-checkpoint" id="worklet-agents-and-event-loops:perform-a-microtask-checkpoint">perform a microtask checkpoint</a>.</p>

  

  <h5 id="worklets-creation-termination"><span class="secno">11.3.1.2</span> Creation and termination<a href="#worklets-creation-termination" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="create-a-worklet-global-scope" data-export="">create a worklet global scope</dfn> for a <code id="worklets-creation-termination:worklet"><a href="#worklet">Worklet</a></code>
  <var>worklet</var>:</p>

  <ol><li><p>Let <var>outsideSettings</var> be <var>worklet</var>'s <a href="#relevant-settings-object" id="worklets-creation-termination:relevant-settings-object">relevant settings
   object</a>.</p></li><li><p>Let <var>agent</var> be the result of <a href="#obtain-a-worklet-agent" id="worklets-creation-termination:obtain-a-worklet-agent">obtaining a
   worklet agent</a> given <var>outsideSettings</var>. Run the rest of these steps in that
   agent.</p></li><li>
    <p>Let <var>realmExecutionContext</var> be the result of <a href="#creating-a-new-javascript-realm" id="worklets-creation-termination:creating-a-new-javascript-realm">creating a new realm</a> given
    <var>agent</var> and the following customizations:</p>

    <ul><li><p>For the global object, create a new object of the type given by <var>worklet</var>'s
     <a href="#worklet-global-scope-type" id="worklets-creation-termination:worklet-global-scope-type">worklet global scope type</a>.</p></li></ul>
   </li><li><p>Let <var>workletGlobalScope</var> be the <a href="#concept-realm-global" id="worklets-creation-termination:concept-realm-global">global
   object</a> of <var>realmExecutionContext</var>'s Realm component.</p></li><li><p>Let <var>insideSettings</var> be the result of <a href="#set-up-a-worklet-environment-settings-object" id="worklets-creation-termination:set-up-a-worklet-environment-settings-object">setting up a worklet environment settings object</a> given
   <var>realmExecutionContext</var> and <var>outsideSettings</var>.</p></li><li><p>Let <var>pendingAddedModules</var> be a <a href="https://infra.spec.whatwg.org/#list-clone" id="worklets-creation-termination:list-clone" data-x-internal="list-clone">clone</a> of
   <var>worklet</var>'s <a href="#concept-worklet-added-modules-list" id="worklets-creation-termination:concept-worklet-added-modules-list">added modules
   list</a>.</p></li><li>
    <p>Let <var>runNextAddedModule</var> be the following steps:</p>

    <ol><li>
      <p>If <var>pendingAddedModules</var> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="worklets-creation-termination:list-is-empty" data-x-internal="list-is-empty">is not empty</a>, then:</p>

      <ol><li><p>Let <var>moduleURL</var> be the result of <a href="https://infra.spec.whatwg.org/#queue-dequeue" id="worklets-creation-termination:dequeue" data-x-internal="dequeue">dequeuing</a>
       from <var>pendingAddedModules</var>.</p></li><li>
        <p><a href="#fetch-a-worklet-script-graph" id="worklets-creation-termination:fetch-a-worklet-script-graph">Fetch a worklet script graph</a> given <var>moduleURL</var>,
        <var>insideSettings</var>, <var>worklet</var>'s <a href="#worklet-destination-type" id="worklets-creation-termination:worklet-destination-type">worklet destination type</a>, <span class="XXX">what credentials mode?</span>, <var>insideSettings</var>, <var>worklet</var>'s
        <a href="#concept-worklet-module-responses-map" id="worklets-creation-termination:concept-worklet-module-responses-map">module responses map</a>, and with
        the following steps given <var>script</var>:</p>

        <p class="note">This will not actually perform a network request, as it will just reuse
        <a href="https://fetch.spec.whatwg.org/#concept-response" id="worklets-creation-termination:concept-response" data-x-internal="concept-response">responses</a> from <var>worklet</var>'s <a href="#concept-worklet-module-responses-map" id="worklets-creation-termination:concept-worklet-module-responses-map-2">module responses map</a>. The main
        purpose of this step is to create a new <var>workletGlobalScope</var>-specific <a href="#module-script" id="worklets-creation-termination:module-script">module
        script</a> from the <a href="https://fetch.spec.whatwg.org/#concept-response" id="worklets-creation-termination:concept-response-2" data-x-internal="concept-response">response</a>.</p>

        <ol><li><p><a id="worklets-creation-termination:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <var>script</var> is not null, since the fetch succeeded and
         the source text was successfully parsed when <var>worklet</var>'s <a href="#concept-worklet-module-responses-map" id="worklets-creation-termination:concept-worklet-module-responses-map-3">module responses map</a> was initially
         populated with <var>moduleURL</var>.</p></li><li><p><a href="#run-a-module-script" id="worklets-creation-termination:run-a-module-script">Run a module script</a> given <var>script</var>.</p></li><li><p>Run <var>runNextAddedModule</var>.</p></li></ol>
       </li><li>Abort these steps.</li></ol>
     </li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="worklets-creation-termination:list-append" data-x-internal="list-append">Append</a> <var>workletGlobalScope</var> to
     <var>outsideSettings</var>'s <a href="#concept-settings-object-global" id="worklets-creation-termination:concept-settings-object-global">global
     object</a>'s <a href="#concept-document-window" id="worklets-creation-termination:concept-document-window">associated
     <code>Document</code></a>'s <a href="#concept-document-worklet-global-scopes" id="worklets-creation-termination:concept-document-worklet-global-scopes">worklet
     global scopes</a>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="worklets-creation-termination:list-append-2" data-x-internal="list-append">Append</a> <var>workletGlobalScope</var> to
     <var>worklet</var>'s <a href="#concept-worklet-global-scopes" id="worklets-creation-termination:concept-worklet-global-scopes">global
     scopes</a>.</p></li><li><p>Run the <a href="#responsible-event-loop" id="worklets-creation-termination:responsible-event-loop">responsible event loop</a> specified by
     <var>insideSettings</var>.</p></li></ol>
   </li><li><p>Run <var>runNextAddedModule</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="terminate-a-worklet-global-scope" data-export="">terminate a worklet global scope</dfn> given a <code id="worklets-creation-termination:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>
  <var>workletGlobalScope</var>:</p>

  <ol><li><p>Let <var>eventLoop</var> be <var>workletGlobalScope</var>'s <a href="#relevant-agent" id="worklets-creation-termination:relevant-agent">relevant agent</a>'s
   <a href="#concept-agent-event-loop" id="worklets-creation-termination:concept-agent-event-loop">event loop</a>.</p></li><li><p>If there are any <a href="#concept-task" id="worklets-creation-termination:concept-task">tasks</a> queued in <var>eventLoop</var>'s
   <a href="#task-queue" id="worklets-creation-termination:task-queue">task queues</a>, discard them without processing them.</p></li><li><p>Wait for <var>eventLoop</var> to complete the <a href="#currently-running-task" id="worklets-creation-termination:currently-running-task">currently running
   task</a>.</p></li><li><p>If the previous step doesn't complete within an <a id="worklets-creation-termination:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> period
   of time, then <a href="#abort-a-running-script" id="worklets-creation-termination:abort-a-running-script">abort the script</a> currently running in
   the worklet.</p></li><li><p>Destroy <var>eventLoop</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="worklets-creation-termination:list-remove" data-x-internal="list-remove">Remove</a> <var>workletGlobalScope</var> from the <a href="#concept-worklet-global-scopes" id="worklets-creation-termination:concept-worklet-global-scopes-2">global scopes</a> of the <code id="worklets-creation-termination:worklet-2"><a href="#worklet">Worklet</a></code> whose
   <a href="#concept-worklet-global-scopes" id="worklets-creation-termination:concept-worklet-global-scopes-3">global scopes</a> contains
   <var>workletGlobalScope</var>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#list-remove" id="worklets-creation-termination:list-remove-2" data-x-internal="list-remove">Remove</a> <var>workletGlobalScope</var> from the <a href="#concept-document-worklet-global-scopes" id="worklets-creation-termination:concept-document-worklet-global-scopes-2">worklet global scopes</a> of the
   <code id="worklets-creation-termination:document"><a href="#document">Document</a></code> whose <a href="#concept-document-worklet-global-scopes" id="worklets-creation-termination:concept-document-worklet-global-scopes-3">worklet global
   scopes</a> contains <var>workletGlobalScope</var>.</p></li></ol>
  </div>

  <h5 id="script-settings-for-worklets"><span class="secno">11.3.1.3</span> Script settings for worklets<a href="#script-settings-for-worklets" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>To <dfn id="set-up-a-worklet-environment-settings-object">set up a worklet environment settings object</dfn>, given a <a id="script-settings-for-worklets:javascript-execution-context" href="https://tc39.es/ecma262/#sec-execution-contexts" data-x-internal="javascript-execution-context">JavaScript
  execution context</a> <var>executionContext</var> and an <a href="#environment-settings-object" id="script-settings-for-worklets:environment-settings-object">environment settings
  object</a> <var>outsideSettings</var>:</p>

  <ol><li><p>Let <var>origin</var> be a unique <a href="#concept-origin-opaque" id="script-settings-for-worklets:concept-origin-opaque">opaque
   origin</a>.</p></li><li><p>Let <var>inheritedAPIBaseURL</var> be <var>outsideSettings</var>'s <a href="#api-base-url" id="script-settings-for-worklets:api-base-url">API base
   URL</a>.</p></li><li><p>Let <var>inheritedPolicyContainer</var> be a <a href="#clone-a-policy-container" id="script-settings-for-worklets:clone-a-policy-container">clone</a> of <var>outsideSettings</var>'s <a href="#concept-settings-object-policy-container" id="script-settings-for-worklets:concept-settings-object-policy-container">policy container</a>.</p></li><li><p>Let <var>realm</var> be the value of <var>executionContext</var>'s Realm
   component.</p></li><li><p>Let <var>workletGlobalScope</var> be <var>realm</var>'s <a href="#concept-realm-global" id="script-settings-for-worklets:concept-realm-global">global object</a>.</p></li><li>
    <p>Let <var>settingsObject</var> be a new <a href="#environment-settings-object" id="script-settings-for-worklets:environment-settings-object-2">environment settings object</a> whose
    algorithms are defined as follows:</p>

    <dl><dt>The <a href="#realm-execution-context" id="script-settings-for-worklets:realm-execution-context">realm execution context</a></dt><dd>
      <p>Return <var>executionContext</var>.</p>
     </dd><dt>The <a href="#concept-settings-object-module-map" id="script-settings-for-worklets:concept-settings-object-module-map">module map</a></dt><dd>
      <p>Return <var>workletGlobalScope</var>'s <a href="#concept-workletglobalscope-module-map" id="script-settings-for-worklets:concept-workletglobalscope-module-map">module map</a>.</p>
     </dd><dt>The <a href="#api-base-url" id="script-settings-for-worklets:api-base-url-2">API base URL</a></dt><dd>
      <p>Return <var>inheritedAPIBaseURL</var>.</p>

      <p class="note">Unlike workers or other globals derived from a single resource, worklets have
      no primary resource; instead, multiple scripts, each with their own URL, are loaded into the
      global scope via <code id="script-settings-for-worklets:dom-worklet-addmodule"><a href="#dom-worklet-addmodule">worklet.addModule()</a></code>. So this <a href="#api-base-url" id="script-settings-for-worklets:api-base-url-3">API base URL</a>
      is rather unlike that of other globals. However, so far this doesn't matter, as no APIs
      available to worklet code make use of the <a href="#api-base-url" id="script-settings-for-worklets:api-base-url-4">API base URL</a>.</p>
     </dd><dt>The <a href="#concept-settings-object-origin" id="script-settings-for-worklets:concept-settings-object-origin">origin</a></dt><dd>
      <p>Return <var>origin</var>.</p>
     </dd><dt>The <a href="#concept-settings-object-has-cross-site-ancestor" id="script-settings-for-worklets:concept-settings-object-has-cross-site-ancestor">has cross-site
     ancestor</a></dt><dd><p>Return true.</p></dd><dt>The <a href="#concept-settings-object-policy-container" id="script-settings-for-worklets:concept-settings-object-policy-container-2">policy container</a></dt><dd>
      <p>Return <var>inheritedPolicyContainer</var>.</p>
     </dd><dt>The <a href="#concept-settings-object-cross-origin-isolated-capability" id="script-settings-for-worklets:concept-settings-object-cross-origin-isolated-capability">cross-origin
     isolated capability</a></dt><dd><p>Return <span class="XXX">TODO</span>.</p></dd><dt>The <a href="#concept-settings-object-time-origin" id="script-settings-for-worklets:concept-settings-object-time-origin">time origin</a></dt><dd><p><a id="script-settings-for-worklets:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: this algorithm is never called, because the <a href="#concept-settings-object-time-origin" id="script-settings-for-worklets:concept-settings-object-time-origin-2">time origin</a> is not available in a worklet
     context.</p></dd></dl>
   </li><li><p>Set <var>settingsObject</var>'s <a href="#concept-environment-id" id="script-settings-for-worklets:concept-environment-id">id</a> to a new
   unique opaque string, <a href="#concept-environment-creation-url" id="script-settings-for-worklets:concept-environment-creation-url">creation URL</a> to
   <var>inheritedAPIBaseURL</var>, <a href="#concept-environment-top-level-creation-url" id="script-settings-for-worklets:concept-environment-top-level-creation-url">top-level creation URL</a> to null, <a href="#concept-environment-top-level-origin" id="script-settings-for-worklets:concept-environment-top-level-origin">top-level
   origin</a> to <var>outsideSettings</var>'s <a href="#concept-environment-top-level-origin" id="script-settings-for-worklets:concept-environment-top-level-origin-2">top-level origin</a>, <a href="#concept-environment-target-browsing-context" id="script-settings-for-worklets:concept-environment-target-browsing-context">target browsing context</a> to null, and
   <a href="#concept-environment-active-service-worker" id="script-settings-for-worklets:concept-environment-active-service-worker">active service worker</a> to
   null.</p></li><li><p>Set <var>realm</var>'s [[HostDefined]] field to <var>settingsObject</var>.</p></li><li><p>Return <var>settingsObject</var>.</p></li></ol>
  </div>

  

  <h4 id="worklets-worklet"><span class="secno">11.3.2</span> The <code id="worklets-worklet:worklet"><a href="#worklet">Worklet</a></code> class<a href="#worklets-worklet" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Worklet" title="The Worklet interface is a lightweight version of Web Workers and gives developers access to low-level parts of the rendering pipeline.">Worklet</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>76+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>65+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div>

  <p>The <code id="worklet-dev"><a href="#worklet">Worklet</a></code> class provides the capability to add module scripts into its
  associated <code id="worklets-worklet:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s. The user agent can then create classes registered on
  the <code id="worklets-worklet:workletglobalscope-2"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s and invoke their methods.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->, <c- g="">SecureContext</c->]
<c- b="">interface</c-> <dfn id="worklet" data-dfn-type="interface"><c- g="">Worklet</c-></dfn> {
  [<c- g="">NewObject</c->] <a href="https://webidl.spec.whatwg.org/#idl-promise" id="worklets-worklet:idl-promise" data-x-internal="idl-promise"><c- b="">Promise</c-></a>&lt;<c- b="">undefined</c->&gt; <a href="#dom-worklet-addmodule" id="worklets-worklet:dom-worklet-addmodule"><c- g="">addModule</c-></a>(<c- b="">USVString</c-> <c- g="">moduleURL</c->, <c- b="">optional</c-> <a href="#workletoptions" id="worklets-worklet:workletoptions"><c- n="">WorkletOptions</c-></a> <c- g="">options</c-> = {});
};

<c- b="">dictionary</c-> <dfn id="workletoptions" data-dfn-type="dictionary"><c- g="">WorkletOptions</c-></dfn> {
  <a id="worklets-worklet:requestcredentials" href="https://fetch.spec.whatwg.org/#requestcredentials" data-x-internal="requestcredentials"><c- n="">RequestCredentials</c-></a> <dfn data-dfn-for="WorkletOptions" id="dom-workletoptions-credentials" data-dfn-type="dict-member"><c- g="">credentials</c-></dfn> = "same-origin";
};</code></pre>

  <p>Specifications that create <code id="worklets-worklet:worklet-2"><a href="#worklet">Worklet</a></code> instances must specify the following for a
  given instance:</p>

  <ul><li><p>its <dfn id="worklet-global-scope-type" data-export="">worklet global scope type</dfn>, which must be a Web IDL type that <a href="https://webidl.spec.whatwg.org/#dfn-inherit" id="worklets-worklet:inherit" data-x-internal="inherit">inherits</a> from <code id="worklets-worklet:workletglobalscope-3"><a href="#workletglobalscope">WorkletGlobalScope</a></code>; and</p></li><li><p>its <dfn id="worklet-destination-type" data-export="">worklet destination type</dfn>, which must be a <a href="https://fetch.spec.whatwg.org/#concept-request-destination" id="worklets-worklet:concept-request-destination" data-x-internal="concept-request-destination">destination</a>, and is used when fetching
   scripts.</p></li></ul>

  <dl class="domintro"><dt><code>await <var>worklet</var>.<a href="#dom-worklet-addmodule" id="dom-worklet-addmodule-dev">addModule</a>(<var>moduleURL</var>[, { <a href="#dom-workletoptions-credentials" id="worklets-worklet:dom-workletoptions-credentials">credentials</a> }])</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Worklet/addModule" title="The addModule() method of the Worklet interface loads the module in the given JavaScript file and adds it to the current Worklet.">Worklet/addModule</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>76+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>65+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></dt><dd>
    <p>Loads and executes the <a href="#module-script" id="worklets-worklet:module-script">module script</a> given by <var>moduleURL</var> into all of
    <var>worklet</var>'s <a href="#concept-worklet-global-scopes" id="worklets-worklet:concept-worklet-global-scopes">global scopes</a>. It can
    also create additional global scopes as part of this process, depending on the worklet type. The
    returned promise will fulfill once the script has been successfully loaded and run in all global
    scopes.</p>

    <p>The <code id="worklets-worklet:dom-workletoptions-credentials-2"><a href="#dom-workletoptions-credentials">credentials</a></code> option can be set to a
    <a href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode" id="worklets-worklet:concept-request-credentials-mode" data-x-internal="concept-request-credentials-mode">credentials mode</a> to modify the
    script-fetching process. It defaults to "<code>same-origin</code>".</p>

    <p>Any failures in <a href="#fetch-a-worklet-script-graph" id="worklets-worklet:fetch-a-worklet-script-graph">fetching</a> the script or its
    dependencies will cause the returned promise to be rejected with an
    <a id="worklets-worklet:aborterror" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a> <code id="worklets-worklet:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>. Any errors in parsing the
    script or its dependencies will cause the returned promise to be rejected with the exception
    generated during parsing.</p>
   </dd></dl>

  

  <p>A <code id="worklets-worklet:worklet-3"><a href="#worklet">Worklet</a></code> has a <a id="worklets-worklet:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <dfn data-dfn-for="Worklet" id="concept-worklet-global-scopes" data-export="">global scopes</dfn>, which contains
  instances of the <code id="worklets-worklet:worklet-4"><a href="#worklet">Worklet</a></code>'s <a href="#worklet-global-scope-type" id="worklets-worklet:worklet-global-scope-type">worklet global scope type</a>. It is initially
  empty.</p>

  <p>A <code id="worklets-worklet:worklet-5"><a href="#worklet">Worklet</a></code> has an <dfn id="concept-worklet-added-modules-list">added modules
  list</dfn>, which is a <a id="worklets-worklet:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="https://url.spec.whatwg.org/#concept-url" id="worklets-worklet:url" data-x-internal="url">URLs</a>, initially empty.
  Access to this list should be thread-safe.</p>

  <p>A <code id="worklets-worklet:worklet-6"><a href="#worklet">Worklet</a></code> has a <dfn id="concept-worklet-module-responses-map">module
  responses map</dfn>, which is an <a id="worklets-worklet:ordered-map" href="https://infra.spec.whatwg.org/#ordered-map" data-x-internal="ordered-map">ordered map</a> from <a href="https://url.spec.whatwg.org/#concept-url" id="worklets-worklet:url-2" data-x-internal="url">URLs</a> to
  either "<code>fetching</code>" or <a href="https://infra.spec.whatwg.org/#tuple" id="worklets-worklet:tuple" data-x-internal="tuple">tuples</a> consisting of a
  <a href="https://fetch.spec.whatwg.org/#concept-response" id="worklets-worklet:concept-response" data-x-internal="concept-response">response</a> and either null, failure, or a <a id="worklets-worklet:byte-sequence" href="https://infra.spec.whatwg.org/#byte-sequence" data-x-internal="byte-sequence">byte
  sequence</a> representing the response body. This map is initially empty, and access to it
  should be thread-safe.</p>

  <div class="note">
   <p>The <a href="#concept-worklet-added-modules-list" id="worklets-worklet:concept-worklet-added-modules-list">added modules list</a> and <a href="#concept-worklet-module-responses-map" id="worklets-worklet:concept-worklet-module-responses-map">module responses map</a> exist to ensure that
   <code id="worklets-worklet:workletglobalscope-4"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s created at different times get equivalent <a href="#module-script" id="worklets-worklet:module-script-2">module scripts</a> run in them, based on the same source text. This allows the
   creation of additional <code id="worklets-worklet:workletglobalscope-5"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s to be transparent to the author.</p>

   <p>In practice, user agents are not expected to implement these data structures, and the
   algorithms that consult them, using thread-safe programming techniques. Instead, when <code id="worklets-worklet:dom-worklet-addmodule-2"><a href="#dom-worklet-addmodule">addModule()</a></code> is called, user agents can fetch the module
   graph on the main thread, and send the fetched source text (i.e., the important data contained in
   the <a href="#concept-worklet-module-responses-map" id="worklets-worklet:concept-worklet-module-responses-map-2">module responses map</a>) to each
   thread which has a <code id="worklets-worklet:workletglobalscope-6"><a href="#workletglobalscope">WorkletGlobalScope</a></code>.</p>

   <p>Then, when a user agent <a href="#create-a-worklet-global-scope" id="worklets-worklet:create-a-worklet-global-scope">creates</a> a new
   <code id="worklets-worklet:workletglobalscope-7"><a href="#workletglobalscope">WorkletGlobalScope</a></code> for a given <code id="worklets-worklet:worklet-7"><a href="#worklet">Worklet</a></code>, it can simply send the map of
   fetched source text and the list of entry points from the main thread to the thread containing
   the new <code id="worklets-worklet:workletglobalscope-8"><a href="#workletglobalscope">WorkletGlobalScope</a></code>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Worklet" id="dom-worklet-addmodule" data-dfn-type="method"><code>addModule(<var>moduleURL</var>,
  <var>options</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>outsideSettings</var> be the <a href="#relevant-settings-object" id="worklets-worklet:relevant-settings-object">relevant settings object</a> of
   <a id="worklets-worklet:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p>Let <var>moduleURLRecord</var> be the result of <a href="#encoding-parsing-a-url" id="worklets-worklet:encoding-parsing-a-url">encoding-parsing a URL</a> given
   <var>moduleURL</var>, relative to <var>outsideSettings</var>.</p></li><li><p>If <var>moduleURLRecord</var> is failure, then return <a id="worklets-worklet:a-promise-rejected-with" href="https://webidl.spec.whatwg.org/#a-promise-rejected-with" data-x-internal="a-promise-rejected-with">a promise rejected with</a>
   a <a id="worklets-worklet:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="worklets-worklet:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>promise</var> be a new promise.</p></li><li><p>Let <var>workletInstance</var> be <a id="worklets-worklet:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li>
    <p>Run the following steps <a href="#in-parallel" id="worklets-worklet:in-parallel">in parallel</a>:</p>

    <ol><li>
      <p>If <var>workletInstance</var>'s <a href="#concept-worklet-global-scopes" id="worklets-worklet:concept-worklet-global-scopes-2">global
      scopes</a> <a href="https://infra.spec.whatwg.org/#list-is-empty" id="worklets-worklet:list-is-empty" data-x-internal="list-is-empty">is empty</a>, then:</p>

      <ol><li><p><a href="#create-a-worklet-global-scope" id="worklets-worklet:create-a-worklet-global-scope-2">Create a worklet global scope</a> given <var>workletInstance</var>.</p></li><li><p>Optionally, <a href="#create-a-worklet-global-scope" id="worklets-worklet:create-a-worklet-global-scope-3">create</a> additional
       global scope instances given <var>workletInstance</var>, depending on the specific worklet in
       question and its specification.</p></li><li><p>Wait for all steps of the <a href="#create-a-worklet-global-scope" id="worklets-worklet:create-a-worklet-global-scope-4">creation</a>
       process(es) — including those taking place within the <a href="#worklet-agent" id="worklets-worklet:worklet-agent">worklet
       agents</a> — to complete, before moving on.</p></li></ol>
     </li><li><p>Let <var>pendingTasks</var> be <var>workletInstance</var>'s <a href="#concept-worklet-global-scopes" id="worklets-worklet:concept-worklet-global-scopes-3">global scopes</a>'s <a href="https://infra.spec.whatwg.org/#list-size" id="worklets-worklet:list-size" data-x-internal="list-size">size</a>.</p></li><li><p>Let <var>addedSuccessfully</var> be false.</p></li><li>
      <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="worklets-worklet:list-iterate" data-x-internal="list-iterate">For each</a> <var>workletGlobalScope</var> of
      <var>workletInstance</var>'s <a href="#concept-worklet-global-scopes" id="worklets-worklet:concept-worklet-global-scopes-4">global
      scopes</a>, <a href="#queue-a-global-task" id="worklets-worklet:queue-a-global-task">queue a global task</a> on the <a href="#networking-task-source" id="worklets-worklet:networking-task-source">networking task source</a>
      given <var>workletGlobalScope</var> to <a href="#fetch-a-worklet-script-graph" id="worklets-worklet:fetch-a-worklet-script-graph-2">fetch a worklet script graph</a> given
      <var>moduleURLRecord</var>, <var>outsideSettings</var>, <var>workletInstance</var>'s
      <a href="#worklet-destination-type" id="worklets-worklet:worklet-destination-type">worklet destination type</a>, <var>options</var>["<code id="worklets-worklet:dom-workletoptions-credentials-3"><a href="#dom-workletoptions-credentials">credentials</a></code>"], <var>workletGlobalScope</var>'s
      <a href="#relevant-settings-object" id="worklets-worklet:relevant-settings-object-2">relevant settings object</a>, <var>workletInstance</var>'s <a href="#concept-worklet-module-responses-map" id="worklets-worklet:concept-worklet-module-responses-map-3">module responses map</a>, and the following
      steps given <var>script</var>:</p>

      <p class="note">Only the first of these fetches will actually perform a network request; the
      ones for other <code id="worklets-worklet:workletglobalscope-9"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s will reuse <a href="https://fetch.spec.whatwg.org/#concept-response" id="worklets-worklet:concept-response-2" data-x-internal="concept-response">responses</a> from <var>workletInstance</var>'s <a href="#concept-worklet-module-responses-map" id="worklets-worklet:concept-worklet-module-responses-map-4">module responses map</a>.</p>

      <ol><li>
        <p>If <var>script</var> is null, then:</p>

        <ol><li>
          <p><a href="#queue-a-global-task" id="worklets-worklet:queue-a-global-task-2">Queue a global task</a> on the <a href="#networking-task-source" id="worklets-worklet:networking-task-source-2">networking task source</a> given
          <var>workletInstance</var>'s <a href="#concept-relevant-global" id="worklets-worklet:concept-relevant-global">relevant global object</a> to perform the following
          steps:</p>

          <ol><li>
            <p>If <var>pendingTasks</var> is not −1, then:</p>

            <ol><li><p>Set <var>pendingTasks</var> to −1.</p></li><li><p>Reject <var>promise</var> with an <a id="worklets-worklet:aborterror-2" href="https://webidl.spec.whatwg.org/#aborterror" data-x-internal="aborterror">"<code>AbortError</code>"</a>
             <code id="worklets-worklet:domexception-3"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li></ol>
           </li></ol>
         </li><li><p>Abort these steps.</p></li></ol>
       </li><li>
        <p>If <var>script</var>'s <a href="#concept-script-error-to-rethrow" id="worklets-worklet:concept-script-error-to-rethrow">error to
        rethrow</a> is not null, then:</p>

        <ol><li>
          <p><a href="#queue-a-global-task" id="worklets-worklet:queue-a-global-task-3">Queue a global task</a> on the <a href="#networking-task-source" id="worklets-worklet:networking-task-source-3">networking task source</a> given
          <var>workletInstance</var>'s <a href="#concept-relevant-global" id="worklets-worklet:concept-relevant-global-2">relevant global object</a> to perform the following
          steps:</p>

          <ol><li>
            <p>If <var>pendingTasks</var> is not −1, then:</p>

            <ol><li><p>Set <var>pendingTasks</var> to −1.</p></li><li><p>Reject <var>promise</var> with <var>script</var>'s <a href="#concept-script-error-to-rethrow" id="worklets-worklet:concept-script-error-to-rethrow-2">error to rethrow</a>.</p></li></ol>
           </li></ol>
         </li><li><p>Abort these steps.</p></li></ol>
       </li><li>
        <p>If <var>addedSuccessfully</var> is false, then:</p>

        <ol><li><p><a href="https://infra.spec.whatwg.org/#list-append" id="worklets-worklet:list-append" data-x-internal="list-append">Append</a> <var>moduleURLRecord</var> to
         <var>workletInstance</var>'s <a href="#concept-worklet-added-modules-list" id="worklets-worklet:concept-worklet-added-modules-list-2">added
         modules list</a>.</p></li><li><p>Set <var>addedSuccessfully</var> to true.</p></li></ol>
       </li><li><p><a href="#run-a-module-script" id="worklets-worklet:run-a-module-script">Run a module script</a> given <var>script</var>.</p></li><li>
        <p><a href="#queue-a-global-task" id="worklets-worklet:queue-a-global-task-4">Queue a global task</a> on the <a href="#networking-task-source" id="worklets-worklet:networking-task-source-4">networking task source</a> given
        <var>workletInstance</var>'s <a href="#concept-relevant-global" id="worklets-worklet:concept-relevant-global-3">relevant global object</a> to perform the following
        steps:</p>

        <ol><li>
          <p>If <var>pendingTasks</var> is not −1, then:</p>

          <ol><li><p>Set <var>pendingTasks</var> to <var>pendingTasks</var> − 1.</p></li><li><p>If <var>pendingTasks</var> is 0, then resolve <var>promise</var>.</p></li></ol>
         </li></ol>
       </li></ol>
     </li></ol>
   </li><li><p>Return <var>promise</var>.</p></li></ol>
  </div>

  

  <h4 id="worklets-lifetime"><span class="secno">11.3.3</span> The worklet's lifetime<a href="#worklets-lifetime" class="self-link"></a></h4>

  <p>The lifetime of a <code id="worklets-lifetime:worklet"><a href="#worklet">Worklet</a></code> has no special considerations; it is tied to the object
  it belongs to, such as the <code id="worklets-lifetime:window"><a href="#window">Window</a></code>.</p>

  

  <p>Each <code id="worklets-lifetime:document"><a href="#document">Document</a></code> has a <dfn id="concept-document-worklet-global-scopes">worklet
  global scopes</dfn>, which is a <a id="worklets-lifetime:set" href="https://infra.spec.whatwg.org/#ordered-set" data-x-internal="set">set</a> of <code id="worklets-lifetime:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s, initially
  empty.</p>

  

  <p>The lifetime of a <code id="worklets-lifetime:workletglobalscope-2"><a href="#workletglobalscope">WorkletGlobalScope</a></code> is, at a minimum, tied to the
  <code id="worklets-lifetime:document-2"><a href="#document">Document</a></code> whose <a href="#concept-document-worklet-global-scopes" id="worklets-lifetime:concept-document-worklet-global-scopes">worklet global
  scopes</a> contain it. In particular, <a href="#destroy-a-document" id="worklets-lifetime:destroy-a-document">destroying</a> the
  <code id="worklets-lifetime:document-3"><a href="#document">Document</a></code> will <a href="#terminate-a-worklet-global-scope" id="worklets-lifetime:terminate-a-worklet-global-scope">terminate</a> the
  corresponding <code id="worklets-lifetime:workletglobalscope-3"><a href="#workletglobalscope">WorkletGlobalScope</a></code> and allow it to be garbage-collected.</p>

  <p>Additionally, user agents may, at any time, <a href="#terminate-a-worklet-global-scope" id="worklets-lifetime:terminate-a-worklet-global-scope-2">terminate</a> a given <code id="worklets-lifetime:workletglobalscope-4"><a href="#workletglobalscope">WorkletGlobalScope</a></code>, unless the specification defining
  the corresponding worklet type says otherwise. For example, they might terminate them if the
  <a href="#worklet-agent" id="worklets-lifetime:worklet-agent">worklet agent</a>'s <a href="#concept-agent-event-loop" id="worklets-lifetime:concept-agent-event-loop">event loop</a> has no
  <a href="#concept-task" id="worklets-lifetime:concept-task">tasks</a> queued, or if the user agent has no pending operations
  planning to make use of the worklet, or if the user agent detects abnormal operations such as
  infinite loops or callbacks exceeding imposed time limits.</p>

  <p>Finally, specifications for specific worklet types can give more specific details on when to
  <a href="#create-a-worklet-global-scope" id="worklets-lifetime:create-a-worklet-global-scope">create</a> <code id="worklets-lifetime:workletglobalscope-5"><a href="#workletglobalscope">WorkletGlobalScope</a></code>s for a
  given worklet type. For example, they might create them during specific processes that call upon
  worklet code, as in the <a href="#worklets-example-registering">example</a>.</p>

  <h2 id="webstorage"><span class="secno">12</span> Web storage<a href="#webstorage" class="self-link"></a></h2><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API" title="The Web Storage API provides mechanisms by which browsers can store key/value pairs, in a much more intuitive fashion than using cookies.">Web_Storage_API</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API" title="The Web Storage API provides mechanisms by which browsers can securely store key/value pairs.">Web_Storage_API/Using_the_Web_Storage_API</a></p></div></div>

  <h3 id="introduction-15"><span class="secno">12.1</span> Introduction<a href="#introduction-15" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>This specification introduces two related mechanisms, similar to HTTP session cookies, for
  storing name-value pairs on the client side. <a href="#refsCOOKIES">[COOKIES]</a></p>

  <p>The first is designed for scenarios where the user is carrying out a single transaction, but
  could be carrying out multiple transactions in different windows at the same time.</p>

  <p>Cookies don't really handle this case well. For example, a user could be buying plane tickets
  in two different windows, using the same site. If the site used cookies to keep track of which
  ticket the user was buying, then as the user clicked from page to page in both windows, the ticket
  currently being purchased would "leak" from one window to the other, potentially causing the user
  to buy two tickets for the same flight without noticing.</p>

  <p>To address this, this specification introduces the <code id="introduction-15:dom-sessionstorage"><a href="#dom-sessionstorage">sessionStorage</a></code> getter. Sites can add data to the session
  storage, and it will be accessible to any page from the same site opened in that window.</p>

  <div class="example">
   <p>For example, a page could have a checkbox that the user ticks to
   indicate that they want insurance:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">input</c-> <c- e="">type</c-><c- o="">=</c-><c- s="">"checkbox"</c-> <c- e="">onchange</c-><c- o="">=</c-><c- s="">"sessionStorage.insurance = checked ? 'true' : ''"</c-><c- p="">&gt;</c->
  I want insurance on this trip.
<c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c-></code></pre>

   <p>A later page could then check, from script, whether the user had checked the checkbox or
   not:</p>

   <pre><code class="js"><c- k="">if</c-> <c- p="">(</c->sessionStorage<c- p="">.</c->insurance<c- p="">)</c-> <c- p="">{</c-> <c- p="">...</c-> <c- p="">}</c-></code></pre>

   <p>If the user had multiple windows opened on the site, each one would have its own individual
   copy of the session storage object.</p>
  </div>

  

  <p>The second storage mechanism is designed for storage that spans multiple windows, and lasts
  beyond the current session. In particular, web applications might wish to store megabytes of user
  data, such as entire user-authored documents or a user's mailbox, on the client side for
  performance reasons.</p>

  <p>Again, cookies do not handle this case well, because they are transmitted with every
  request.</p>

  <p>The <code id="introduction-15:dom-localstorage"><a href="#dom-localstorage">localStorage</a></code> getter is used to access a page's local
  storage area.</p>

  <div class="example">
   <p>The site at example.com can display a count of how many times the user has loaded its page by
   putting the following at the bottom of its page:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
  You have viewed this page
  <c- p="">&lt;</c-><c- f="">span</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"count"</c-><c- p="">&gt;</c->an untold number of<c- p="">&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c->
  time(s).
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- k="">if</c-> <c- p="">(</c-><c- o="">!</c->localStorage<c- p="">.</c->pageLoadCount<c- p="">)</c->
    localStorage<c- p="">.</c->pageLoadCount <c- o="">=</c-> <c- mf="">0</c-><c- p="">;</c->
  localStorage<c- p="">.</c->pageLoadCount <c- o="">=</c-> parseInt<c- p="">(</c->localStorage<c- p="">.</c->pageLoadCount<c- p="">)</c-> <c- o="">+</c-> <c- mf="">1</c-><c- p="">;</c->
  document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'count'</c-><c- p="">).</c->textContent <c- o="">=</c-> localStorage<c- p="">.</c->pageLoadCount<c- p="">;</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <p>Each site has its own separate storage area.</p>

  <p class="warning">The <code id="introduction-15:dom-localstorage-2"><a href="#dom-localstorage">localStorage</a></code> getter provides access
  to shared state. This specification does not define the interaction with other agent clusters
  in a multiprocess user agent, and authors are encouraged to assume that there is no locking
  mechanism. A site could, for instance, try to read the value of a key, increment its value, then
  write it back out, using the new value as a unique identifier for the session; if the site does
  this twice in two different browser windows at the same time, it might end up using the same
  "unique" identifier for both sessions, with potentially disastrous effects.</p>




  <h3 id="storage"><span class="secno">12.2</span> The API<a href="#storage" class="self-link"></a></h3><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage" title="The Storage interface of the Web Storage API provides access to a particular domain's session or local storage. It allows, for example, the addition, modification, or deletion of stored data items.">Storage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <h4 id="the-storage-interface"><span class="secno">12.2.1</span> The <code id="the-storage-interface:storage-2"><a href="#storage-2">Storage</a></code> interface<a href="#the-storage-interface" class="self-link"></a></h4>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="storage-2" data-dfn-type="interface"><c- g="">Storage</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <a href="#dom-storage-length" id="the-storage-interface:dom-storage-length"><c- g="">length</c-></a>;
  <c- b="">DOMString</c->? <a href="#dom-storage-key" id="the-storage-interface:dom-storage-key"><c- g="">key</c-></a>(<c- b="">unsigned</c-> <c- b="">long</c-> <c- g="">index</c->);
  <c- b="">getter</c-> <c- b="">DOMString</c->? <a href="#dom-storage-getitem" id="the-storage-interface:dom-storage-getitem"><c- g="">getItem</c-></a>(<c- b="">DOMString</c-> <c- g="">key</c->);
  <c- b="">setter</c-> <c- b="">undefined</c-> <a href="#dom-storage-setitem" id="the-storage-interface:dom-storage-setitem"><c- g="">setItem</c-></a>(<c- b="">DOMString</c-> <c- g="">key</c->, <c- b="">DOMString</c-> <c- g="">value</c->);
  <c- b="">deleter</c-> <c- b="">undefined</c-> <a href="#dom-storage-removeitem" id="the-storage-interface:dom-storage-removeitem"><c- g="">removeItem</c-></a>(<c- b="">DOMString</c-> <c- g="">key</c->);
  <c- b="">undefined</c-> <a href="#dom-storage-clear" id="the-storage-interface:dom-storage-clear"><c- g="">clear</c-></a>();
};</code></pre>

  <dl class="domintro"><dt><code><var>storage</var>.<a href="#dom-storage-length" id="dom-storage-length-dev">length</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage/length" title="The length read-only property of the Storage interface returns the number of data items stored in a given Storage object.">Storage/length</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Returns the number of key/value pairs.</p></dd><dt><code><var>storage</var>.<a href="#dom-storage-key" id="dom-storage-key-dev">key</a> (<var>n</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage/key" title="The key() method of the Storage interface, when passed a number n, returns the name of the nth key in a given Storage object. The order of keys is user-agent defined, so you should not rely on it.">Storage/key</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd><p>Returns the name of the <var>n</var>th key, or null if <var>n</var> is greater than or
   equal to the number of key/value pairs.</p></dd><dt><code><var>value</var> = <var>storage</var>.<a href="#dom-storage-getitem" id="dom-storage-getitem-dev">getItem</a> (<var>key</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage/getItem" title="The getItem() method of the Storage interface, when passed a key name, will return that key's value, or null if the key does not exist, in the given Storage object.">Storage/getItem</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dt><code><var>value</var> = <var>storage</var>[<var>key</var>]</code></dt><dd><p>Returns the current value associated with the given <var>key</var>, or null if the given
   <var>key</var> does not exist.</p></dd><dt><code><var>storage</var>.<a href="#dom-storage-setitem" id="dom-storage-setitem-dev">setItem</a> (<var>key</var>, <var>value</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem" title="The setItem() method of the Storage interface, when passed a key name and value, will add that key to the given Storage object, or update that key's value if it already exists.">Storage/setItem</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dt><code><var>storage</var>[<var>key</var>] = <var>value</var></code></dt><dd>
    <p>Sets the value of the pair identified by <var>key</var> to <var>value</var>, creating a new
    key/value pair if none existed for <var>key</var> previously.</p>

    <p>Throws a <code id="the-storage-interface:quotaexceedederror"><a data-x-internal="quotaexceedederror" href="https://webidl.spec.whatwg.org/#quotaexceedederror">QuotaExceededError</a></code> if the new value couldn't be set. (Setting could
    fail if, e.g., the user has disabled storage for the site, or if the quota has been
    exceeded.)</p>

    <p>Dispatches a <code id="the-storage-interface:event-storage"><a href="#event-storage">storage</a></code> event on <code id="the-storage-interface:window"><a href="#window">Window</a></code> objects
    holding an equivalent <code id="the-storage-interface:storage-2-2"><a href="#storage-2">Storage</a></code> object.</p>
   </dd><dt><code><var>storage</var>.<a href="#dom-storage-removeitem" id="dom-storage-removeitem-dev">removeItem</a> (<var>key</var>)</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage/removeItem" title="The removeItem() method of the Storage interface, when passed a key name, will remove that key from the given Storage object if it exists. The Storage interface of the Web Storage API provides access to a particular domain's session or local storage.">Storage/removeItem</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dt><code id="the-storage-interface:delete"><a data-x-internal="delete" href="https://tc39.es/ecma262/#sec-delete-operator">delete</a></code> <var>storage</var>[<var>key</var>]</dt><dd>
    <p>Removes the key/value pair with the given <var>key</var>, if a key/value pair with the given
    <var>key</var> exists.</p>

    <p>Dispatches a <code id="the-storage-interface:event-storage-2"><a href="#event-storage">storage</a></code> event on <code id="the-storage-interface:window-2"><a href="#window">Window</a></code> objects
    holding an equivalent <code id="the-storage-interface:storage-2-3"><a href="#storage-2">Storage</a></code> object.</p>
   </dd><dt><code><var>storage</var>.<a href="#dom-storage-clear" id="dom-storage-clear-dev">clear</a>()</code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage/clear" title="The clear() method of the Storage interface clears all keys stored in a given Storage object.">Storage/clear</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>6+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>Removes all key/value pairs, if there are any.</p>

    <p>Dispatches a <code id="the-storage-interface:event-storage-3"><a href="#event-storage">storage</a></code> event on <code id="the-storage-interface:window-3"><a href="#window">Window</a></code> objects
    holding an equivalent <code id="the-storage-interface:storage-2-4"><a href="#storage-2">Storage</a></code> object.</p>
   </dd></dl>

  

  <p>A <code id="the-storage-interface:storage-2-5"><a href="#storage-2">Storage</a></code> object has an associated:</p>

  <dl><dt><dfn id="concept-storage-map">map</dfn>
   </dt><dd>A <a id="the-storage-interface:storage-proxy-map" href="https://storage.spec.whatwg.org/#storage-proxy-map" data-x-internal="storage-proxy-map">storage proxy map</a>.</dd><dt><dfn id="concept-storage-type">type</dfn>
   </dt><dd>"<code>local</code>" or "<code>session</code>".
  </dd></dl>

  <div data-algorithm="">
  <p>To <dfn id="concept-storage-reorder">reorder</dfn> a <code id="the-storage-interface:storage-2-6"><a href="#storage-2">Storage</a></code> object
  <var>storage</var>, reorder <var>storage</var>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map">map</a>'s
  <a href="https://infra.spec.whatwg.org/#map-entry" id="the-storage-interface:map-entry" data-x-internal="map-entry">entries</a> in an <a id="the-storage-interface:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> manner.</p>
  </div>

  <p class="note">Unfortunate as it is, iteration order is not defined and can change upon most
  mutations.</p>

  <div data-algorithm="">
  <p>To <dfn id="concept-storage-broadcast">broadcast</dfn> a <code id="the-storage-interface:storage-2-7"><a href="#storage-2">Storage</a></code> object
  <var>storage</var>, given a <var>key</var>, <var>oldValue</var>, and <var>newValue</var>, run
  these steps:</p>

  <ol><li><p>Let <var>thisDocument</var> be <var>storage</var>'s <a href="#concept-relevant-global" id="the-storage-interface:concept-relevant-global">relevant global object</a>'s <a href="#concept-document-window" id="the-storage-interface:concept-document-window">associated <code>Document</code></a>.</p></li><li><p>Let <var>url</var> be the <a href="https://url.spec.whatwg.org/#concept-url-serializer" id="the-storage-interface:concept-url-serializer" data-x-internal="concept-url-serializer">serialization</a> of
   <var>thisDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-storage-interface:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li><li>
    <p>Let <var>remoteStorages</var> be all <code id="the-storage-interface:storage-2-8"><a href="#storage-2">Storage</a></code> objects excluding
    <var>storage</var> whose:</p>

    <ul><li><a href="#concept-storage-type" id="the-storage-interface:concept-storage-type">type</a> is <var>storage</var>'s <a href="#concept-storage-type" id="the-storage-interface:concept-storage-type-2">type</a></li><li><a href="#relevant-settings-object" id="the-storage-interface:relevant-settings-object">relevant settings object</a>'s <a href="#concept-origin" id="the-storage-interface:concept-origin">origin</a> is <a href="#same-origin" id="the-storage-interface:same-origin">same origin</a>
     with <var>storage</var>'s <a href="#relevant-settings-object" id="the-storage-interface:relevant-settings-object-2">relevant settings object</a>'s <a href="#concept-origin" id="the-storage-interface:concept-origin-2">origin</a></li></ul>

    <p>and, if <a href="#concept-storage-type" id="the-storage-interface:concept-storage-type-3">type</a> is "<code>session</code>",
    whose <a href="#relevant-settings-object" id="the-storage-interface:relevant-settings-object-3">relevant settings object</a>'s <a href="#concept-document-window" id="the-storage-interface:concept-document-window-2">associated
    <code>Document</code></a>'s <a href="#node-navigable" id="the-storage-interface:node-navigable">node navigable</a>'s <a href="#nav-traversable" id="the-storage-interface:nav-traversable">traversable navigable</a> is <var>thisDocument</var>'s <a href="#node-navigable" id="the-storage-interface:node-navigable-2">node
    navigable</a>'s <a href="#nav-traversable" id="the-storage-interface:nav-traversable-2">traversable navigable</a>.</p>
   </li><li>
    <p><a href="https://infra.spec.whatwg.org/#list-iterate" id="the-storage-interface:list-iterate" data-x-internal="list-iterate">For each</a> <var>remoteStorage</var> of
    <var>remoteStorages</var>: <a href="#queue-a-global-task" id="the-storage-interface:queue-a-global-task">queue a global task</a> on the <a href="#dom-manipulation-task-source" id="the-storage-interface:dom-manipulation-task-source">DOM manipulation task
    source</a> given <var>remoteStorage</var>'s <a href="#concept-relevant-global" id="the-storage-interface:concept-relevant-global-2">relevant global object</a> to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-storage-interface:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-storage-interface:event-storage-4"><a href="#event-storage">storage</a></code> at <var>remoteStorage</var>'s <a href="#concept-relevant-global" id="the-storage-interface:concept-relevant-global-3">relevant global
    object</a>, using <code id="the-storage-interface:storageevent"><a href="#storageevent">StorageEvent</a></code>, with <code id="the-storage-interface:dom-storageevent-key"><a href="#dom-storageevent-key">key</a></code> initialized to <var>key</var>, <code id="the-storage-interface:dom-storageevent-oldvalue"><a href="#dom-storageevent-oldvalue">oldValue</a></code> initialized to <var>oldValue</var>, <code id="the-storage-interface:dom-storageevent-newvalue"><a href="#dom-storageevent-newvalue">newValue</a></code> initialized to <var>newValue</var>, <code id="the-storage-interface:dom-storageevent-url"><a href="#dom-storageevent-url">url</a></code> initialized to <var>url</var>, and <code id="the-storage-interface:dom-storageevent-storagearea"><a href="#dom-storageevent-storagearea">storageArea</a></code> initialized to
    <var>remoteStorage</var>.</p>
    

    <p class="note">The <code id="the-storage-interface:document"><a href="#document">Document</a></code> object associated with the resulting <a href="#concept-task" id="the-storage-interface:concept-task">task</a> is not necessarily <a href="#fully-active" id="the-storage-interface:fully-active">fully active</a>, but events fired
    on such objects are ignored by the <a href="#event-loop" id="the-storage-interface:event-loop">event loop</a> until the <code id="the-storage-interface:document-2"><a href="#document">Document</a></code>
    becomes <a href="#fully-active" id="the-storage-interface:fully-active-2">fully active</a> again.</p>
   </li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Storage" id="dom-storage-length" data-dfn-type="attribute"><code>length</code></dfn> getter
  steps are to return <a id="the-storage-interface:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-2">map</a>'s <a href="https://infra.spec.whatwg.org/#map-size" id="the-storage-interface:map-size" data-x-internal="map-size">size</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Storage" id="dom-storage-key" data-dfn-type="method"><code>key(<var>index</var>)</code></dfn>
  method steps are:</p>

  <ol><li><p>If <var>index</var> is greater than or equal to <a id="the-storage-interface:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-3">map</a>'s <a href="https://infra.spec.whatwg.org/#map-size" id="the-storage-interface:map-size-2" data-x-internal="map-size">size</a>, then return
   null.</p></li><li><p>Let <var>keys</var> be the result of running <a href="https://infra.spec.whatwg.org/#map-getting-the-keys" id="the-storage-interface:map-get-the-keys" data-x-internal="map-get-the-keys">get the
   keys</a> on <a id="the-storage-interface:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-4">map</a>.

   </p></li><li><p>Return <var>keys</var>[<var>index</var>].</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a id="the-storage-interface:supported-property-names" href="https://webidl.spec.whatwg.org/#dfn-supported-property-names" data-x-internal="supported-property-names">supported property names</a> on a <code id="the-storage-interface:storage-2-9"><a href="#storage-2">Storage</a></code> object <var>storage</var>
  are the result of running <a href="https://infra.spec.whatwg.org/#map-getting-the-keys" id="the-storage-interface:map-get-the-keys-2" data-x-internal="map-get-the-keys">get the keys</a> on
  <var>storage</var>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-5">map</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Storage" id="dom-storage-getitem" data-dfn-type="method"><code>getItem(<var>key</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="the-storage-interface:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-6">map</a>[<var>key</var>] does
   not <a href="https://infra.spec.whatwg.org/#map-exists" id="the-storage-interface:map-exists" data-x-internal="map-exists">exist</a>, then return null.</p></li><li><p>Return <a id="the-storage-interface:this-5" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-7">map</a>[<var>key</var>].</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Storage" id="dom-storage-setitem" data-dfn-type="method"><code>setItem(<var>key</var>,
  <var>value</var>)</code></dfn> method steps are:</p>

  <ol><li><p>Let <var>oldValue</var> be null.</p></li><li><p>Let <var>reorder</var> be true.</p></li><li>
    <p>If <a id="the-storage-interface:this-6" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-8">map</a>[<var>key</var>]
    <a href="https://infra.spec.whatwg.org/#map-exists" id="the-storage-interface:map-exists-2" data-x-internal="map-exists">exists</a>:</p>

    <ol><li><p>Set <var>oldValue</var> to <a id="the-storage-interface:this-7" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-9">map</a>[<var>key</var>].</p></li><li><p>If <var>oldValue</var> <a id="the-storage-interface:is" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="is">is</a> <var>value</var>, then return.</p></li><li><p>Set <var>reorder</var> to false.</p></li></ol>
   </li><li><p>If <var>value</var> cannot be stored, then throw a
   <code id="the-storage-interface:quotaexceedederror-2"><a data-x-internal="quotaexceedederror" href="https://webidl.spec.whatwg.org/#quotaexceedederror">QuotaExceededError</a></code>.</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-set" id="the-storage-interface:map-set" data-x-internal="map-set">Set</a> <a id="the-storage-interface:this-8" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-10">map</a>[<var>key</var>] to <var>value</var>.</p></li><li><p>If <var>reorder</var> is true, then <a href="#concept-storage-reorder" id="the-storage-interface:concept-storage-reorder">reorder</a>
   <a id="the-storage-interface:this-9" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p><a href="#concept-storage-broadcast" id="the-storage-interface:concept-storage-broadcast">Broadcast</a> <a id="the-storage-interface:this-10" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> with
   <var>key</var>, <var>oldValue</var>, and <var>value</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Storage" id="dom-storage-removeitem" data-dfn-type="method"><code>removeItem(<var>key</var>)</code></dfn> method steps are:</p>

  <ol><li><p>If <a id="the-storage-interface:this-11" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-11">map</a>[<var>key</var>] does
   not <a href="https://infra.spec.whatwg.org/#map-exists" id="the-storage-interface:map-exists-3" data-x-internal="map-exists">exist</a>, then return.</p></li><li><p>Set <var>oldValue</var> to <a id="the-storage-interface:this-12" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-12">map</a>[<var>key</var>].</p></li><li><p><a href="https://infra.spec.whatwg.org/#map-remove" id="the-storage-interface:map-remove" data-x-internal="map-remove">Remove</a> <a id="the-storage-interface:this-13" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-13">map</a>[<var>key</var>].</p></li><li><p><a href="#concept-storage-reorder" id="the-storage-interface:concept-storage-reorder-2">Reorder</a> <a id="the-storage-interface:this-14" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>.</p></li><li><p><a href="#concept-storage-broadcast" id="the-storage-interface:concept-storage-broadcast-2">Broadcast</a> <a id="the-storage-interface:this-15" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> with
   <var>key</var>, <var>oldValue</var>, and null.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Storage" id="dom-storage-clear" data-dfn-type="method"><code>clear()</code></dfn> method
  steps are:</p>

  <ol><li><p><a href="https://infra.spec.whatwg.org/#map-clear" id="the-storage-interface:map-clear" data-x-internal="map-clear">Clear</a> <a id="the-storage-interface:this-16" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-storage-map" id="the-storage-interface:concept-storage-map-14">map</a>.</p></li><li><p><a href="#concept-storage-broadcast" id="the-storage-interface:concept-storage-broadcast-3">Broadcast</a> <a id="the-storage-interface:this-17" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a> with null,
   null, and null.</p></li></ol>
  </div>

  


  <h4 id="the-sessionstorage-attribute"><span class="secno">12.2.2</span> The <code id="the-sessionstorage-attribute:dom-sessionstorage"><a href="#dom-sessionstorage">sessionStorage</a></code> getter<a href="#the-sessionstorage-attribute" class="self-link"></a></h4>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="windowsessionstorage" data-dfn-type="interface"><c- g="">WindowSessionStorage</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#storage-2" id="the-sessionstorage-attribute:storage-2"><c- n="">Storage</c-></a> <a href="#dom-sessionstorage" id="the-sessionstorage-attribute:dom-sessionstorage-2"><c- g="">sessionStorage</c-></a>;
};
<a href="#window" id="the-sessionstorage-attribute:window"><c- n="">Window</c-></a> <c- b="">includes</c-> <a href="#windowsessionstorage" id="the-sessionstorage-attribute:windowsessionstorage"><c- n="">WindowSessionStorage</c-></a>;</code></pre>

  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-sessionstorage" id="dom-sessionstorage-dev">sessionStorage</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage" title="The read-only sessionStorage property accesses a session Storage object for the current origin. sessionStorage is similar to localStorage; the difference is that while data in localStorage doesn't expire, data in sessionStorage is cleared when the page session ends.">Window/sessionStorage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-sessionstorage-attribute:storage-2-2"><a href="#storage-2">Storage</a></code> object associated with that <var>window</var>'s origin's
    session storage area.</p>

    <p>Throws a <a id="the-sessionstorage-attribute:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-sessionstorage-attribute:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    <code id="the-sessionstorage-attribute:document"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-sessionstorage-attribute:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is an <a href="#concept-origin-opaque" id="the-sessionstorage-attribute:concept-origin-opaque">opaque origin</a> or if the request violates a policy decision
    (e.g., if the user agent is configured to not allow the page to persist data).</p>
   </dd></dl>

  

  <p>A <code id="the-sessionstorage-attribute:document-2"><a href="#document">Document</a></code> object has an associated <dfn id="session-storage-holder">session storage holder</dfn>, which is
  null or a <code id="the-sessionstorage-attribute:storage-2-3"><a href="#storage-2">Storage</a></code> object. It is initially null.</p>

  <div data-algorithm="">
  <p>
  <a id="the-sessionstorage-attribute:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  The <dfn data-dfn-for="WindowSessionStorage" id="dom-sessionstorage" data-dfn-type="attribute"><code>sessionStorage</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-sessionstorage-attribute:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="the-sessionstorage-attribute:concept-document-window">associated
   <code>Document</code></a>'s <a href="#session-storage-holder" id="the-sessionstorage-attribute:session-storage-holder">session storage holder</a> is non-null, then return
   <a id="the-sessionstorage-attribute:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="the-sessionstorage-attribute:concept-document-window-2">associated
   <code>Document</code></a>'s <a href="#session-storage-holder" id="the-sessionstorage-attribute:session-storage-holder-2">session storage holder</a>.</p></li><li><p>Let <var>map</var> be the result of running <a id="the-sessionstorage-attribute:obtain-a-session-storage-bottle-map" href="https://storage.spec.whatwg.org/#obtain-a-session-storage-bottle-map" data-x-internal="obtain-a-session-storage-bottle-map">obtain a session storage bottle
   map</a> with <a id="the-sessionstorage-attribute:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="the-sessionstorage-attribute:relevant-settings-object">relevant settings object</a> and "<code>sessionStorage</code>".</p></li><li><p>If <var>map</var> is failure, then throw a <a id="the-sessionstorage-attribute:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
   <code id="the-sessionstorage-attribute:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>storage</var> be a new <code id="the-sessionstorage-attribute:storage-2-4"><a href="#storage-2">Storage</a></code> object whose <a href="#concept-storage-map" id="the-sessionstorage-attribute:concept-storage-map">map</a> is <var>map</var>.

   </p></li><li><p>Set <a id="the-sessionstorage-attribute:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="the-sessionstorage-attribute:concept-document-window-3">associated
   <code>Document</code></a>'s <a href="#session-storage-holder" id="the-sessionstorage-attribute:session-storage-holder-3">session storage holder</a> to
   <var>storage</var>.</p></li><li><p>Return <var>storage</var>.</p></li></ol>
  </div>

  <p class="note">After <a href="#creating-a-new-auxiliary-browsing-context" id="the-sessionstorage-attribute:creating-a-new-auxiliary-browsing-context">creating a new auxiliary browsing context and document</a>, the
  session storage <a href="#copy-session-storage">is copied</a> over.</p>

  


  <h4 id="the-localstorage-attribute"><span class="secno">12.2.3</span> The <code id="the-localstorage-attribute:dom-localstorage"><a href="#dom-localstorage">localStorage</a></code> getter<a href="#the-localstorage-attribute" class="self-link"></a></h4>

  <pre><code class="idl"><c- b="">interface</c-> <c- b="">mixin</c-> <dfn id="windowlocalstorage" data-dfn-type="interface"><c- g="">WindowLocalStorage</c-></dfn> {
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#storage-2" id="the-localstorage-attribute:storage-2"><c- n="">Storage</c-></a> <a href="#dom-localstorage" id="the-localstorage-attribute:dom-localstorage-2"><c- g="">localStorage</c-></a>;
};
<a href="#window" id="the-localstorage-attribute:window"><c- n="">Window</c-></a> <c- b="">includes</c-> <a href="#windowlocalstorage" id="the-localstorage-attribute:windowlocalstorage"><c- n="">WindowLocalStorage</c-></a>;</code></pre>


  <dl class="domintro"><dt><code><var>window</var>.<a href="#dom-localstorage" id="dom-localstorage-dev">localStorage</a></code><div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" title="The localStorage read-only property of the window interface allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions.">Window/localStorage</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></dt><dd>
    <p>Returns the <code id="the-localstorage-attribute:storage-2-2"><a href="#storage-2">Storage</a></code> object associated with <var>window</var>'s origin's local
    storage area.</p>

    <p>Throws a <a id="the-localstorage-attribute:securityerror" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a> <code id="the-localstorage-attribute:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code> if the
    <code id="the-localstorage-attribute:document"><a href="#document">Document</a></code>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="the-localstorage-attribute:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is an <a href="#concept-origin-opaque" id="the-localstorage-attribute:concept-origin-opaque">opaque origin</a> or if the request violates a policy decision
    (e.g., if the user agent is configured to not allow the page to persist data).</p>
   </dd></dl>

  

  <p>A <code id="the-localstorage-attribute:document-2"><a href="#document">Document</a></code> object has an associated <dfn id="local-storage-holder">local storage holder</dfn>, which is null
  or a <code id="the-localstorage-attribute:storage-2-3"><a href="#storage-2">Storage</a></code> object. It is initially null.</p>

  <div data-algorithm="">
  <p>
  <a id="the-localstorage-attribute:tracking-vector" title="There is a tracking vector here." href="https://infra.spec.whatwg.org/#tracking-vector" class="tracking-vector" data-x-internal="tracking-vector"><img width="46" alt="(This is a tracking vector.)" crossorigin="" class="darkmode-aware" src="https://resources.whatwg.org/tracking-vector.svg" height="64"></a>
  The <dfn data-dfn-for="WindowLocalStorage" id="dom-localstorage" data-dfn-type="attribute"><code>localStorage</code></dfn> getter steps are:</p>

  <ol><li><p>If <a id="the-localstorage-attribute:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="the-localstorage-attribute:concept-document-window">associated
   <code>Document</code></a>'s <a href="#local-storage-holder" id="the-localstorage-attribute:local-storage-holder">local storage holder</a> is non-null, then return
   <a id="the-localstorage-attribute:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="the-localstorage-attribute:concept-document-window-2">associated
   <code>Document</code></a>'s <a href="#local-storage-holder" id="the-localstorage-attribute:local-storage-holder-2">local storage holder</a>.</p></li><li><p>Let <var>map</var> be the result of running <a id="the-localstorage-attribute:obtain-a-local-storage-bottle-map" href="https://storage.spec.whatwg.org/#obtain-a-local-storage-bottle-map" data-x-internal="obtain-a-local-storage-bottle-map">obtain a local storage bottle map</a>
   with <a id="the-localstorage-attribute:this-3" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#relevant-settings-object" id="the-localstorage-attribute:relevant-settings-object">relevant settings object</a> and "<code>localStorage</code>".</p></li><li><p>If <var>map</var> is failure, then throw a <a id="the-localstorage-attribute:securityerror-2" href="https://webidl.spec.whatwg.org/#securityerror" data-x-internal="securityerror">"<code>SecurityError</code>"</a>
   <code id="the-localstorage-attribute:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Let <var>storage</var> be a new <code id="the-localstorage-attribute:storage-2-4"><a href="#storage-2">Storage</a></code> object whose <a href="#concept-storage-map" id="the-localstorage-attribute:concept-storage-map">map</a> is <var>map</var>.

   </p></li><li><p>Set <a id="the-localstorage-attribute:this-4" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-document-window" id="the-localstorage-attribute:concept-document-window-3">associated
   <code>Document</code></a>'s <a href="#local-storage-holder" id="the-localstorage-attribute:local-storage-holder-3">local storage holder</a> to <var>storage</var>.</p></li><li><p>Return <var>storage</var>.</p></li></ol>
  </div>

  


  <h4 id="the-storageevent-interface"><span class="secno">12.2.4</span> The <code id="the-storageevent-interface:storageevent"><a href="#storageevent">StorageEvent</a></code> interface<a href="#the-storageevent-interface" class="self-link"></a></h4><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent" title="The StorageEvent interface is implemented by the storage event, which is sent to a window when a storage area the window has access to is changed within the context of another document.">StorageEvent</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>13+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="storageevent" data-dfn-type="interface"><c- g="">StorageEvent</c-></dfn> : <a id="the-storageevent-interface:event" href="https://dom.spec.whatwg.org/#interface-event" data-x-internal="event"><c- n="">Event</c-></a> {
  <c- g="">constructor</c->(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <a href="#storageeventinit" id="the-storageevent-interface:storageeventinit"><c- n="">StorageEventInit</c-></a> <c- g="">eventInitDict</c-> = {});

  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-storageevent-key" id="the-storageevent-interface:dom-storageevent-key"><c- g="">key</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-storageevent-oldvalue" id="the-storageevent-interface:dom-storageevent-oldvalue"><c- g="">oldValue</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">DOMString</c->? <a href="#dom-storageevent-newvalue" id="the-storageevent-interface:dom-storageevent-newvalue"><c- g="">newValue</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <c- b="">USVString</c-> <a href="#dom-storageevent-url" id="the-storageevent-interface:dom-storageevent-url"><c- g="">url</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#storage-2" id="the-storageevent-interface:storage-2"><c- n="">Storage</c-></a>? <a href="#dom-storageevent-storagearea" id="the-storageevent-interface:dom-storageevent-storagearea"><c- g="">storageArea</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-storageevent-initstorageevent" id="the-storageevent-interface:dom-storageevent-initstorageevent"><c- g="">initStorageEvent</c-></a>(<c- b="">DOMString</c-> <c- g="">type</c->, <c- b="">optional</c-> <c- b="">boolean</c-> <c- g="">bubbles</c-> = <c- b="">false</c->, <c- b="">optional</c-> <c- b="">boolean</c-> <c- g="">cancelable</c-> = <c- b="">false</c->, <c- b="">optional</c-> <c- b="">DOMString</c->? <c- g="">key</c-> = <c- b="">null</c->, <c- b="">optional</c-> <c- b="">DOMString</c->? <c- g="">oldValue</c-> = <c- b="">null</c->, <c- b="">optional</c-> <c- b="">DOMString</c->? <c- g="">newValue</c-> = <c- b="">null</c->, <c- b="">optional</c-> <c- b="">USVString</c-> <c- g="">url</c-> = "", <c- b="">optional</c-> <c- n="">Storage</c->? <c- g="">storageArea</c-> = <c- b="">null</c->);
};

<c- b="">dictionary</c-> <dfn id="storageeventinit" data-dfn-type="dictionary"><c- g="">StorageEventInit</c-></dfn> : <a id="the-storageevent-interface:eventinit" href="https://dom.spec.whatwg.org/#dictdef-eventinit" data-x-internal="eventinit"><c- n="">EventInit</c-></a> {
  <c- b="">DOMString</c->? <c- g="">key</c-> = <c- b="">null</c->;
  <c- b="">DOMString</c->? <c- g="">oldValue</c-> = <c- b="">null</c->;
  <c- b="">DOMString</c->? <c- g="">newValue</c-> = <c- b="">null</c->;
  <c- b="">USVString</c-> <c- g="">url</c-> = "";
  <a href="#storage-2" id="the-storageevent-interface:storage-2-2"><c- n="">Storage</c-></a>? <c- g="">storageArea</c-> = <c- b="">null</c->;
};</code></pre>

  <dl class="domintro"><dt><code><var>event</var>.<a href="#dom-storageevent-key" id="dom-storageevent-key-dev">key</a></code></dt><dd><p>Returns the key of the storage item being changed.</p></dd><dt><code><var>event</var>.<a href="#dom-storageevent-oldvalue" id="dom-storageevent-oldvalue-dev">oldValue</a></code></dt><dd><p>Returns the old value of the key of the storage item whose value is being
   changed.</p></dd><dt><code><var>event</var>.<a href="#dom-storageevent-newvalue" id="dom-storageevent-newvalue-dev">newValue</a></code></dt><dd><p>Returns the new value of the key of the storage item whose value is being
   changed.</p></dd><dt><code><var>event</var>.<a href="#dom-storageevent-url" id="dom-storageevent-url-dev">url</a></code></dt><dd><p>Returns the <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-storageevent-interface:the-document's-address" data-x-internal="the-document's-address">URL</a> of the document whose storage
   item changed.</p></dd><dt><code><var>event</var>.<a href="#dom-storageevent-storagearea" id="dom-storageevent-storagearea-dev">storageArea</a></code></dt><dd><p>Returns the <code id="the-storageevent-interface:storage-2-3"><a href="#storage-2">Storage</a></code> object that was affected.</p></dd></dl>

  

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="StorageEvent" id="dom-storageevent-key" data-dfn-type="attribute"><code>key</code></dfn>,
  <dfn data-dfn-for="StorageEvent" id="dom-storageevent-oldvalue" data-dfn-type="attribute"><code>oldValue</code></dfn>,
  <dfn data-dfn-for="StorageEvent" id="dom-storageevent-newvalue" data-dfn-type="attribute"><code>newValue</code></dfn>,
  <dfn data-dfn-for="StorageEvent" id="dom-storageevent-url" data-dfn-type="attribute"><code>url</code></dfn>, and <dfn data-dfn-for="StorageEvent" id="dom-storageevent-storagearea" data-dfn-type="attribute"><code>storageArea</code></dfn>
  attributes must return the values they were initialized to.</p>
  </div>

  
  <div data-algorithm="">
  <p>The <dfn data-dfn-for="StorageEvent" id="dom-storageevent-initstorageevent" data-dfn-type="method"><code>initStorageEvent(<var>type</var>, <var>bubbles</var>,
  <var>cancelable</var>, <var>key</var>, <var>oldValue</var>, <var>newValue</var>, <var>url</var>,
  <var>storageArea</var>)</code></dfn> method must initialize the event in a manner analogous to the
  similarly-named <code id="the-storageevent-interface:dom-event-initevent"><a data-x-internal="dom-event-initevent" href="https://dom.spec.whatwg.org/#dom-event-initevent">initEvent()</a></code> method. <a href="#refsDOM">[DOM]</a></p>
  </div>

  


  <h3 id="privacy"><span class="secno">12.3</span> Privacy<a href="#privacy" class="self-link"></a></h3>

  <h4 id="user-tracking"><span class="secno">12.3.1</span> User tracking<a href="#user-tracking" class="self-link"></a></h4>

  <p>A third-party advertiser (or any entity capable of getting content distributed to multiple
  sites) could use a unique identifier stored in its local storage area to track a user across
  multiple sessions, building a profile of the user's interests to allow for highly targeted
  advertising. In conjunction with a site that is aware of the user's real identity (for example an
  e-commerce site that requires authenticated credentials), this could allow oppressive groups to
  target individuals with greater accuracy than in a world with purely anonymous web usage.</p>

  <p>There are a number of techniques that can be used to mitigate the risk of user tracking:</p>

  <dl><dt>Blocking third-party storage</dt><dd>
    <p>User agents may restrict access to the <code id="user-tracking:dom-localstorage"><a href="#dom-localstorage">localStorage</a></code>
    objects to scripts originating at the domain of the <a href="#nav-document" id="user-tracking:nav-document">active
    document</a> of the <a href="#top-level-traversable" id="user-tracking:top-level-traversable">top-level traversable</a>, for instance denying access to the
    API for pages from other domains running in <code id="user-tracking:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s.</p>
   </dd><dt>Expiring stored data</dt><dd>
    <p>User agents may, possibly in a manner configured by the user, automatically delete stored
    data after a period of time.</p>

    <p>For example, a user agent could be configured to treat third-party local storage areas as
    session-only storage, deleting the data once the user had closed all the <a href="#navigable" id="user-tracking:navigable">navigables</a> that could access it.</p>

    <p>This can restrict the ability of a site to track a user, as the site would then only be able
    to track the user across multiple sessions when they authenticate with the site itself (e.g. by
    making a purchase or logging in to a service).</p>

    <p>However, this also reduces the usefulness of the API as a long-term storage mechanism. It can
    also put the user's data at risk, if the user does not fully understand the implications of data
    expiration.</p>
   </dd><dt>Treating persistent storage as cookies</dt><dd>
    <p>If users attempt to protect their privacy by clearing cookies without also clearing data
    stored in the local storage area, sites can defeat those attempts by using the two features as
    redundant backup for each other. User agents should present the interfaces for clearing these in
    a way that helps users to understand this possibility and enables them to delete data in all
    persistent storage features simultaneously. <a href="#refsCOOKIES">[COOKIES]</a></p>
   </dd><dt>Site-specific safelisting of access to local storage areas</dt><dd>
    <p>User agents may allow sites to access session storage areas in
    an unrestricted manner, but require the user to authorize access
    to local storage areas.</p>
   </dd><dt>Origin-tracking of stored data</dt><dd>
    <p>User agents may record the <a href="#concept-origin" id="user-tracking:concept-origin">origins</a> of sites that contained
    content from third-party origins that caused data to be stored.</p>

    <p>If this information is then used to present the view of data currently in persistent storage,
    it would allow the user to make informed decisions about which parts of the persistent storage
    to prune. Combined with a blocklist ("delete this data and prevent this domain from ever storing
    data again"), the user can restrict the use of persistent storage to sites that they trust.</p>
   </dd><dt>Shared blocklists</dt><dd>
    <p>User agents may allow users to share their persistent storage domain blocklists.</p>

    <p>This would allow communities to act together to protect their privacy.</p>
   </dd></dl>

  <p>While these suggestions prevent trivial use of this API for user tracking, they do not block it
  altogether. Within a single domain, a site can continue to track the user during a session, and
  can then pass all this information to the third party along with any identifying information
  (names, credit card numbers, addresses) obtained by the site. If a third party cooperates with
  multiple sites to obtain such information, a profile can still be created.</p>

  <p>However, user tracking is to some extent possible even with no cooperation from the user agent
  whatsoever, for instance by using session identifiers in URLs, a technique already commonly used
  for innocuous purposes but easily repurposed for user tracking (even retroactively). This
  information can then be shared with other sites, using visitors' IP addresses and other
  user-specific data (e.g. user-agent headers and configuration settings) to combine separate
  sessions into coherent user profiles.</p>

  

  <h4 id="sensitivity-of-data"><span class="secno">12.3.2</span> Sensitivity of data<a href="#sensitivity-of-data" class="self-link"></a></h4>

  <p>User agents should treat persistently stored data as potentially sensitive; it's quite possible
  for emails, calendar appointments, health records, or other confidential documents to be stored
  in this mechanism.</p>

  <p>To this end, user agents should ensure that when deleting data, it is promptly deleted from the
  underlying storage.</p>

  


  <h3 id="security-storage"><span class="secno">12.4</span> Security<a href="#security-storage" class="self-link"></a></h3>

  <h4 id="dns-spoofing-attacks"><span class="secno">12.4.1</span> DNS spoofing attacks<a href="#dns-spoofing-attacks" class="self-link"></a></h4>

  <p>Because of the potential for DNS spoofing attacks, one cannot guarantee that a host claiming to
  be in a certain domain really is from that domain. To mitigate this, pages can use TLS. Pages
  using TLS can be sure that only the user, software working on behalf of the user, and other pages
  using TLS that have certificates identifying them as being from the same domain, can access their
  storage areas.</p>


  <h4 id="cross-directory-attacks"><span class="secno">12.4.2</span> Cross-directory attacks<a href="#cross-directory-attacks" class="self-link"></a></h4>

  <p>Different authors sharing one host name, for example users hosting content on the now defunct
  <code>geocities.com</code>, all share one local storage object. There is no feature to
  restrict the access by pathname. Authors on shared hosts are therefore urged to avoid using these
  features, as it would be trivial for other authors to read the data and overwrite it.</p>

  <p class="note">Even if a path-restriction feature was made available, the usual DOM scripting
  security model would make it trivial to bypass this protection and access the data from any
  path.</p>


  

  <h4 id="implementation-risks"><span class="secno">12.4.3</span> Implementation risks<a href="#implementation-risks" class="self-link"></a></h4>

  <p>The two primary risks when implementing these persistent storage features are letting hostile
  sites read information from other domains, and letting hostile sites write information that is
  then read from other domains.</p>

  <p>Letting third-party sites read data that is not supposed to be read from their domain causes
  <em>information leakage</em>. For example, a user's shopping wishlist on one domain could be used
  by another domain for targeted advertising; or a user's work-in-progress confidential documents
  stored by a word-processing site could be examined by the site of a competing company.</p>

  <p>Letting third-party sites write data to the persistent storage of other domains can result in
  <em>information spoofing</em>, which is equally dangerous. For example, a hostile site could add
  items to a user's wishlist; or a hostile site could set a user's session identifier to a known ID
  that the hostile site can then use to track the user's actions on the victim site.</p>

  <p>Thus, strictly following the <a href="#concept-origin" id="implementation-risks:concept-origin">origin</a> model described in this specification is
  important for user security.</p>

  



  <h2 id="syntax"><span class="secno">13</span> <dfn>The HTML syntax</dfn><a href="#syntax" class="self-link"></a></h2>

  <p class="note">This section only describes the rules for resources labeled with an <a id="syntax:html-mime-type" href="https://mimesniff.spec.whatwg.org/#html-mime-type" data-x-internal="html-mime-type">HTML
  MIME type</a>. Rules for XML resources are discussed in the section below entitled "<a href="#the-xhtml-syntax" id="syntax:the-xhtml-syntax">The
  XML syntax</a>".</p>


  <h3 id="writing"><span class="secno">13.1</span> Writing HTML documents<a href="#writing" class="self-link"></a></h3>

  

  <p><i>This section only applies to documents, authoring tools, and markup generators. In
  particular, it does not apply to conformance checkers; conformance checkers must use the
  requirements given in the next section ("parsing HTML documents").</i></p>

  

  <div data-algorithm="">
  <p>Documents must consist of the following parts, in the given
  order:</p>

  <ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li><li>Any number of <a href="#syntax-comments" id="writing:syntax-comments">comments</a> and <a id="writing:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
   whitespace</a>.</li><li>A <a href="#syntax-doctype" id="writing:syntax-doctype">DOCTYPE</a>.

   </li><li>Any number of <a href="#syntax-comments" id="writing:syntax-comments-2">comments</a> and <a id="writing:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
   whitespace</a>.</li><li>The <a id="writing:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>, in the form of an <code id="writing:the-html-element"><a href="#the-html-element">html</a></code> <a href="#syntax-elements" id="writing:syntax-elements">element</a>.</li><li>Any number of <a href="#syntax-comments" id="writing:syntax-comments-3">comments</a> and <a id="writing:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
   whitespace</a>.</li></ol>
  </div>

  <p>The various types of content mentioned above are described in the next few sections.</p>

  <p>In addition, there are some restrictions on how <a href="#character-encoding-declaration" id="writing:character-encoding-declaration">character encoding declarations</a> are to be serialized, as discussed in the
  section on that topic.</p>

  <div class="note">

   <p><a id="writing:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> before the <code id="writing:the-html-element-2"><a href="#the-html-element">html</a></code> element, at the start of the
   <code id="writing:the-html-element-3"><a href="#the-html-element">html</a></code> element and before the <code id="writing:the-head-element"><a href="#the-head-element">head</a></code> element, will be dropped when the
   document is parsed; <a id="writing:space-characters-5" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> <em>after</em> the <code id="writing:the-html-element-4"><a href="#the-html-element">html</a></code> element
   will be parsed as if it were at the end of the <code id="writing:the-body-element"><a href="#the-body-element">body</a></code> element. Thus, <a id="writing:space-characters-6" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
   whitespace</a> around the <a id="writing:document-element-2" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> does not round-trip.</p>

   <p>It is suggested that newlines be inserted after the DOCTYPE, after any comments that are
   before the document element, after the <code id="writing:the-html-element-5"><a href="#the-html-element">html</a></code> element's start tag (if it is not <a href="#syntax-tag-omission" id="writing:syntax-tag-omission">omitted</a>), and after any comments that are inside the
   <code id="writing:the-html-element-6"><a href="#the-html-element">html</a></code> element but before the <code id="writing:the-head-element-2"><a href="#the-head-element">head</a></code> element.</p>

  </div>

  <p>Many strings in the HTML syntax (e.g. the names of elements and their attributes) are
  case-insensitive, but only for <a href="https://infra.spec.whatwg.org/#ascii-upper-alpha" id="writing:uppercase-ascii-letters" data-x-internal="uppercase-ascii-letters">ASCII upper alphas</a> and
  <a href="https://infra.spec.whatwg.org/#ascii-lower-alpha" id="writing:lowercase-ascii-letters" data-x-internal="lowercase-ascii-letters">ASCII lower alphas</a>. For convenience, in this section this
  is just referred to as "case-insensitive".</p>


  <h4 id="the-doctype"><span class="secno">13.1.1</span> The DOCTYPE<a href="#the-doctype" class="self-link"></a></h4>

  <p>A <dfn id="syntax-doctype">DOCTYPE</dfn> is a 
  required preamble.</p>

  <p class="note">DOCTYPEs are required for legacy reasons. When omitted, browsers tend to use a
  different rendering mode that is incompatible with some specifications. Including the DOCTYPE in a
  document ensures that the browser makes a best-effort attempt at following the relevant
  specifications.</p>

  <div data-algorithm="">
  <p>A DOCTYPE must consist of the following components, in this order:</p>

  <ol class="brief"><li>A string that is an <a id="the-doctype:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>&lt;!DOCTYPE</code>".</li><li>One or more <a id="the-doctype:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</li><li>A string that is an <a id="the-doctype:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>html</code>".</li><li>Optionally, a <a href="#doctype-legacy-string" id="the-doctype:doctype-legacy-string">DOCTYPE legacy string</a>.</li><li>Zero or more <a id="the-doctype:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</li><li>A U+003E GREATER-THAN SIGN character (&gt;).</li></ol>
  </div>

  <p class="note">In other words, <code>&lt;!DOCTYPE html&gt;</code>, case-insensitively.</p>

  <hr>

  <div data-algorithm="">
  <p>For the purposes of HTML generators that cannot output HTML markup with the short DOCTYPE
  "<code>&lt;!DOCTYPE html&gt;</code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
  into the DOCTYPE (in the position defined above). This string must consist of:</p>

  <ol class="brief"><li>One or more <a id="the-doctype:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</li><li>A string that is an <a id="the-doctype:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>SYSTEM</code>".</li><li>One or more <a id="the-doctype:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</li><li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li><li>The literal string "<code id="the-doctype:about:legacy-compat"><a href="#about:legacy-compat">about:legacy-compat</a></code>".</li><li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>quote mark</i>).</li></ol>
  </div>

  <p class="note">In other words, <code>&lt;!DOCTYPE html SYSTEM "about:legacy-compat"&gt;</code> or
  <code>&lt;!DOCTYPE html SYSTEM 'about:legacy-compat'&gt;</code>, case-insensitively except for the
  part in single or double quotes.</p>

  <p>The <a href="#doctype-legacy-string" id="the-doctype:doctype-legacy-string-2">DOCTYPE legacy string</a> should not be used unless the document is generated from
  a system that cannot output the shorter string.</p>



  <h4 id="elements-2"><span class="secno">13.1.2</span> Elements<a href="#elements-2" class="self-link"></a></h4>

  <p>There are six different kinds of <dfn id="syntax-elements">elements</dfn>: <a href="#void-elements" id="elements-2:void-elements">void
  elements</a>, <a href="#the-template-element-2" id="elements-2:the-template-element-2">the <code>template</code> element</a>, <a href="#raw-text-elements" id="elements-2:raw-text-elements">raw text
  elements</a>, <a href="#escapable-raw-text-elements" id="elements-2:escapable-raw-text-elements">escapable raw text elements</a>, <a href="#foreign-elements" id="elements-2:foreign-elements">foreign elements</a>, and
  <a href="#normal-elements" id="elements-2:normal-elements">normal elements</a>.</p>

  <dl><dt><dfn id="void-elements">Void elements</dfn></dt><dd><code id="elements-2:the-area-element"><a href="#the-area-element">area</a></code>, <code id="elements-2:the-base-element"><a href="#the-base-element">base</a></code>, <code id="elements-2:the-br-element"><a href="#the-br-element">br</a></code>, <code id="elements-2:the-col-element"><a href="#the-col-element">col</a></code>, <code id="elements-2:the-embed-element"><a href="#the-embed-element">embed</a></code>,
   <code id="elements-2:the-hr-element"><a href="#the-hr-element">hr</a></code>, <code id="elements-2:the-img-element"><a href="#the-img-element">img</a></code>, <code id="elements-2:the-input-element"><a href="#the-input-element">input</a></code>, <code id="elements-2:the-link-element"><a href="#the-link-element">link</a></code>, <code id="elements-2:the-meta-element"><a href="#the-meta-element">meta</a></code>,
   <code id="elements-2:the-source-element"><a href="#the-source-element">source</a></code>, <code id="elements-2:the-track-element"><a href="#the-track-element">track</a></code>, <code id="elements-2:the-wbr-element"><a href="#the-wbr-element">wbr</a></code></dd><dt><dfn id="the-template-element-2">The <code>template</code> element</dfn></dt><dd><code id="elements-2:the-template-element"><a href="#the-template-element">template</a></code></dd><dt><dfn id="raw-text-elements">Raw text elements</dfn></dt><dd><code id="elements-2:the-script-element"><a href="#the-script-element">script</a></code>, <code id="elements-2:the-style-element"><a href="#the-style-element">style</a></code></dd><dt><dfn id="escapable-raw-text-elements">Escapable raw text elements</dfn></dt><dd><code id="elements-2:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>, <code id="elements-2:the-title-element"><a href="#the-title-element">title</a></code></dd><dt><dfn id="foreign-elements">Foreign elements</dfn></dt><dd>Elements from the <a id="elements-2:mathml-namespace" href="https://infra.spec.whatwg.org/#mathml-namespace" data-x-internal="mathml-namespace">MathML namespace</a> and the <a id="elements-2:svg-namespace" href="https://infra.spec.whatwg.org/#svg-namespace" data-x-internal="svg-namespace">SVG namespace</a>.</dd><dt><dfn id="normal-elements">Normal elements</dfn></dt><dd>All other allowed <a href="#html-elements" id="elements-2:html-elements">HTML elements</a> are normal elements.</dd></dl>

  <p><dfn id="syntax-tags">Tags</dfn> are used to delimit the start and end of elements in the
  markup. <a href="#raw-text-elements" id="elements-2:raw-text-elements-2">Raw text</a>, <a href="#escapable-raw-text-elements" id="elements-2:escapable-raw-text-elements-2">escapable raw text</a>, and <a href="#normal-elements" id="elements-2:normal-elements-2">normal</a> elements have
  a <a href="#syntax-start-tag" id="elements-2:syntax-start-tag">start tag</a> to indicate where they begin, and an <a href="#syntax-end-tag" id="elements-2:syntax-end-tag">end tag</a> to indicate where they end. The start and end tags of
  certain <a href="#normal-elements" id="elements-2:normal-elements-3">normal elements</a> can be <a href="#syntax-tag-omission" id="elements-2:syntax-tag-omission">omitted</a>, as
  described below in the section on <a href="#syntax-tag-omission" id="elements-2:syntax-tag-omission-2">optional tags</a>. Those
  that cannot be omitted must not be omitted. <a href="#void-elements" id="elements-2:void-elements-2">Void elements</a> only have a start tag; end
  tags must not be specified for <a href="#void-elements" id="elements-2:void-elements-3">void elements</a>. <a href="#foreign-elements" id="elements-2:foreign-elements-2">Foreign elements</a> must
  either have a start tag and an end tag, or a start tag that is marked as self-closing, in which
  case they must not have an end tag.</p>

  <p>The <a href="#concept-html-contents" id="elements-2:concept-html-contents">contents</a> of the element must be placed between
  just after the start tag (which <a href="#syntax-tag-omission" id="elements-2:syntax-tag-omission-3">might be implied, in certain
  cases</a>) and just before the end tag (which again, <a href="#syntax-tag-omission" id="elements-2:syntax-tag-omission-4">might be
  implied in certain cases</a>). The exact allowed contents of each individual element depend on
  the <a href="#content-models" id="elements-2:content-models">content model</a> of that element, as described earlier in
  this specification. Elements must not contain content that their content model disallows. In
  addition to the restrictions placed on the contents by those content models, however, the five
  types of elements have additional <em>syntactic</em> requirements.</p>

  <p><a href="#void-elements" id="elements-2:void-elements-4">Void elements</a> can't have any contents (since there's no end tag, no content can be
  put between the start tag and the end tag).</p>

  <p id="template-syntax"><a href="#the-template-element-2" id="elements-2:the-template-element-2-2">The <code>template</code> element</a> can have
  <a href="#template-contents" id="elements-2:template-contents">template contents</a>, but such <a href="#template-contents" id="elements-2:template-contents-2">template contents</a> are not children of the
  <code id="elements-2:the-template-element-3"><a href="#the-template-element">template</a></code> element itself. Instead, they are stored in a <code id="elements-2:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code>
  associated with a different <code id="elements-2:document"><a href="#document">Document</a></code> — without a <a href="#browsing-context" id="elements-2:browsing-context">browsing context</a> — so
  as to avoid the <code id="elements-2:the-template-element-4"><a href="#the-template-element">template</a></code> contents interfering with the main <code id="elements-2:document-2"><a href="#document">Document</a></code>.
  The markup for the <a href="#template-contents" id="elements-2:template-contents-3">template contents</a> of a <code id="elements-2:the-template-element-5"><a href="#the-template-element">template</a></code> element is placed
  just after the <code id="elements-2:the-template-element-6"><a href="#the-template-element">template</a></code> element's start tag and just before <code id="elements-2:the-template-element-7"><a href="#the-template-element">template</a></code>
  element's end tag (as with other elements), and may consist of any <a href="#syntax-text" id="elements-2:syntax-text">text</a>, <a href="#syntax-charref" id="elements-2:syntax-charref">character references</a>, <a href="#syntax-elements" id="elements-2:syntax-elements">elements</a>, and <a href="#syntax-comments" id="elements-2:syntax-comments">comments</a>, but
  the text must not contain the character U+003C LESS-THAN SIGN (&lt;) or an <a href="#syntax-ambiguous-ampersand" id="elements-2:syntax-ambiguous-ampersand">ambiguous ampersand</a>.</p>

  <p><a href="#raw-text-elements" id="elements-2:raw-text-elements-3">Raw text elements</a> can have <a href="#syntax-text" id="elements-2:syntax-text-2">text</a>, though it has <a href="#cdata-rcdata-restrictions">restrictions</a> described below.</p>

  <p><a href="#escapable-raw-text-elements" id="elements-2:escapable-raw-text-elements-3">Escapable raw text elements</a> can have <a href="#syntax-text" id="elements-2:syntax-text-3">text</a> and
  <a href="#syntax-charref" id="elements-2:syntax-charref-2">character references</a>, but the text must not contain an <a href="#syntax-ambiguous-ampersand" id="elements-2:syntax-ambiguous-ampersand-2">ambiguous ampersand</a>. There are also <a href="#cdata-rcdata-restrictions">further restrictions</a> described below.</p>

  <p><a href="#foreign-elements" id="elements-2:foreign-elements-3">Foreign elements</a> whose start tag is marked as self-closing can't have any contents
  (since, again, as there's no end tag, no content can be put between the start tag and the end
  tag). <a href="#foreign-elements" id="elements-2:foreign-elements-4">Foreign elements</a> whose start tag is <em>not</em> marked as self-closing can
  have <a href="#syntax-text" id="elements-2:syntax-text-4">text</a>, <a href="#syntax-charref" id="elements-2:syntax-charref-3">character
  references</a>, <a href="#syntax-cdata" id="elements-2:syntax-cdata">CDATA sections</a>, other <a href="#syntax-elements" id="elements-2:syntax-elements-2">elements</a>, and <a href="#syntax-comments" id="elements-2:syntax-comments-2">comments</a>, but
  the text must not contain the character U+003C LESS-THAN SIGN (&lt;) or an <a href="#syntax-ambiguous-ampersand" id="elements-2:syntax-ambiguous-ampersand-3">ambiguous ampersand</a>.</p>

  <div class="note">

   <p>The HTML syntax does not support namespace declarations, even in <a href="#foreign-elements" id="elements-2:foreign-elements-5">foreign
   elements</a>.</p>

   <p>For instance, consider the following HTML fragment:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">svg</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">metadata</c-><c- p="">&gt;</c->
   <c- c="">&lt;!-- this is invalid --&gt;</c->
   <c- p="">&lt;</c-><c- f="">cdr:license</c-> <c- e="">xmlns:cdr</c-><c- o="">=</c-><c- s="">"https://www.example.com/cdr/metadata"</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"MIT"</c-><c- p="">/&gt;</c->
  <c- p="">&lt;/</c-><c- f="">metadata</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">svg</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>The innermost element, <code>cdr:license</code>, is actually in the SVG namespace, as
   the "<code>xmlns:cdr</code>" attribute has no effect (unlike in XML). In fact, as the
   comment in the fragment above says, the fragment is actually non-conforming. This is because
   <cite>SVG 2</cite> does not define any elements called "<code>cdr:license</code>" in
   the SVG namespace.</p>

  </div>

  <p><a href="#normal-elements" id="elements-2:normal-elements-4">Normal elements</a> can have <a href="#syntax-text" id="elements-2:syntax-text-5">text</a>, <a href="#syntax-charref" id="elements-2:syntax-charref-4">character references</a>, other <a href="#syntax-elements" id="elements-2:syntax-elements-3">elements</a>, and <a href="#syntax-comments" id="elements-2:syntax-comments-3">comments</a>, but
  the text must not contain the character U+003C LESS-THAN SIGN (&lt;) or an <a href="#syntax-ambiguous-ampersand" id="elements-2:syntax-ambiguous-ampersand-4">ambiguous ampersand</a>. Some <a href="#normal-elements" id="elements-2:normal-elements-5">normal elements</a>
  also have <a href="#element-restrictions">yet more restrictions</a> on what content they are
  allowed to hold, beyond the restrictions imposed by the content model and those described in this
  paragraph. Those restrictions are described below.</p>

  <p>Tags contain a <dfn id="syntax-tag-name">tag name</dfn>, giving the element's name. HTML
  elements all have names that only use <a href="https://infra.spec.whatwg.org/#ascii-alphanumeric" id="elements-2:alphanumeric-ascii-characters" data-x-internal="alphanumeric-ascii-characters">ASCII
  alphanumerics</a>. In the HTML syntax, tag names, even those for <a href="#foreign-elements" id="elements-2:foreign-elements-6">foreign elements</a>,
  may be written with any mix of lower- and uppercase letters that, when converted to all-lowercase,
  matches the element's tag name; tag names are case-insensitive.</p>


  <h5 id="start-tags"><span class="secno">13.1.2.1</span> Start tags<a href="#start-tags" class="self-link"></a></h5>

  <div data-algorithm="">
  <p><dfn id="syntax-start-tag">Start tags</dfn> must have the following format:</p>

  <ol><li>The first character of a start tag must be a U+003C LESS-THAN SIGN character (&lt;).</li><li>The next few characters of a start tag must be the element's <a href="#syntax-tag-name" id="start-tags:syntax-tag-name">tag name</a>.</li><li>If there are to be any attributes in the next step, there must first be one or more
   <a id="start-tags:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</li><li>Then, the start tag may have a number of attributes, the <a href="#syntax-attributes" id="start-tags:syntax-attributes">syntax for which</a> is described below. Attributes must be
   separated from each other by one or more <a id="start-tags:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</li><li>After the attributes, or after the <a href="#syntax-tag-name" id="start-tags:syntax-tag-name-2">tag name</a> if there
   are no attributes, there may be one or more <a id="start-tags:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>. (Some attributes are
   required to be followed by a space. See the <a href="#syntax-attributes" id="start-tags:syntax-attributes-2">attributes
   section</a> below.)</li><li>Then, if the element is one of the <a href="#void-elements" id="start-tags:void-elements">void elements</a>, or if the element is a <a href="#foreign-elements" id="start-tags:foreign-elements">foreign element</a>, then there may be a single U+002F SOLIDUS
   character (/), which on <a href="#foreign-elements" id="start-tags:foreign-elements-2">foreign elements</a> marks the start tag as self-closing. On
   <a href="#void-elements" id="start-tags:void-elements-2">void elements</a>, it does not mark the start tag as self-closing but instead is
   unnecessary and has no effect of any kind. For such void elements, it should be used only with
   caution — especially since, if directly preceded by an <a href="#unquoted">unquoted attribute
   value</a>, it becomes part of the attribute value rather than being discarded by the
   parser.</li><li>Finally, start tags must be closed by a U+003E GREATER-THAN SIGN character (&gt;).</li></ol>
  </div>


  <h5 id="end-tags"><span class="secno">13.1.2.2</span> End tags<a href="#end-tags" class="self-link"></a></h5>

  <div data-algorithm="">
  <p><dfn id="syntax-end-tag">End tags</dfn> must have the following format:</p>

  <ol><li>The first character of an end tag must be a U+003C LESS-THAN SIGN character (&lt;).</li><li>The second character of an end tag must be a U+002F SOLIDUS character (/).</li><li>The next few characters of an end tag must be the element's <a href="#syntax-tag-name" id="end-tags:syntax-tag-name">tag
   name</a>.</li><li>After the tag name, there may be one or more <a id="end-tags:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</li><li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN character (&gt;).</li></ol>
  </div>


  <h5 id="attributes-2"><span class="secno">13.1.2.3</span> Attributes<a href="#attributes-2" class="self-link"></a></h5>

  <p><dfn id="syntax-attributes">Attributes</dfn> for an element are expressed inside the
  element's start tag.</p>

  <p>Attributes have a name and a value. <dfn id="syntax-attribute-name">Attribute names</dfn>
  must consist of one or more characters other than <a href="https://infra.spec.whatwg.org/#control" id="attributes-2:control" data-x-internal="control">controls</a>,
  U+0020 SPACE, U+0022 ("), U+0027 ('), U+003E (&gt;), U+002F (/), U+003D (=), and <a href="https://infra.spec.whatwg.org/#noncharacter" id="attributes-2:noncharacter" data-x-internal="noncharacter">noncharacters</a>. In the HTML syntax, attribute names, even those for
  <a href="#foreign-elements" id="attributes-2:foreign-elements">foreign elements</a>, may be written with any mix of <a href="https://infra.spec.whatwg.org/#ascii-lower-alpha" id="attributes-2:lowercase-ascii-letters" data-x-internal="lowercase-ascii-letters">ASCII lower</a> and <a href="https://infra.spec.whatwg.org/#ascii-upper-alpha" id="attributes-2:uppercase-ascii-letters" data-x-internal="uppercase-ascii-letters">ASCII upper alphas</a>.</p>

  <p><dfn id="syntax-attribute-value">Attribute values</dfn> are a mixture of <a href="#syntax-text" id="attributes-2:syntax-text">text</a> and <a href="#syntax-charref" id="attributes-2:syntax-charref">character references</a>,
  except with the additional restriction that the text cannot contain an <a href="#syntax-ambiguous-ampersand" id="attributes-2:syntax-ambiguous-ampersand">ambiguous ampersand</a>.</p>

  <p>Attributes can be specified in four different ways:</p>

  <dl><dt>Empty attribute syntax</dt><dd>
    <p>Just the <a href="#syntax-attribute-name" id="attributes-2:syntax-attribute-name">attribute name</a>. The value is implicitly
    the empty string.</p>

    <div class="example">

     <p>In the following example, the <code id="attributes-2:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code> attribute is
     given with the empty attribute syntax:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <em><c- e="">disabled</c-></em><c- p="">&gt;</c-></code></pre>

    </div>

    <p>If an attribute using the empty attribute syntax is to be followed by another attribute, then
    there must be <a id="attributes-2:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> separating the two.</p>
   </dd><dt id="unquoted">Unquoted attribute value syntax</dt><dd>
    <p>The <a href="#syntax-attribute-name" id="attributes-2:syntax-attribute-name-2">attribute name</a>, followed by zero or more
    <a id="attributes-2:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, followed by a single U+003D EQUALS SIGN character, followed by
    zero or more <a id="attributes-2:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, followed by the <a href="#syntax-attribute-value" id="attributes-2:syntax-attribute-value">attribute value</a>, which, in addition to the requirements
    given above for attribute values, must not contain any literal <a id="attributes-2:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>,
    any U+0022 QUOTATION MARK characters ("), U+0027 APOSTROPHE characters ('), U+003D
    EQUALS SIGN characters (=), U+003C LESS-THAN SIGN characters (&lt;), U+003E GREATER-THAN SIGN
    characters (&gt;), or U+0060 GRAVE ACCENT characters (`), and must not be the empty string.</p>

    


    <div class="example">

     <p>In the following example, the <code id="attributes-2:attr-input-value"><a href="#attr-input-value">value</a></code> attribute is given
     with the unquoted attribute value syntax:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <em><c- e="">value</c-><c- o="">=</c-><c- s="">yes</c-></em><c- p="">&gt;</c-></code></pre>

    </div>

    <p>If an attribute using the unquoted attribute syntax is to be followed by another attribute or
    by the optional U+002F SOLIDUS character (/) allowed in step 6 of the <a href="#syntax-start-tag" id="attributes-2:syntax-start-tag">start tag</a> syntax above, then there must be <a id="attributes-2:space-characters-5" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
    whitespace</a> separating the two.</p>
   </dd><dt>Single-quoted attribute value syntax</dt><dd>
    <p>The <a href="#syntax-attribute-name" id="attributes-2:syntax-attribute-name-3">attribute name</a>, followed by zero or more
    <a id="attributes-2:space-characters-6" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, followed by a single U+003D EQUALS SIGN character, followed by
    zero or more <a id="attributes-2:space-characters-7" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, followed by a single U+0027 APOSTROPHE character
    ('), followed by the <a href="#syntax-attribute-value" id="attributes-2:syntax-attribute-value-2">attribute value</a>, which, in
    addition to the requirements given above for attribute values, must not contain any literal
    U+0027 APOSTROPHE characters ('), and finally followed by a second single U+0027 APOSTROPHE
    character (').</p>

    <div class="example">

     <p>In the following example, the <code id="attributes-2:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is given
     with the single-quoted attribute value syntax:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <em><c- e="">type</c-><c- o="">=</c-><c- s="">'checkbox'</c-></em><c- p="">&gt;</c-></code></pre>

    </div>

    <p>If an attribute using the single-quoted attribute syntax is to be followed by another
    attribute, then there must be <a id="attributes-2:space-characters-8" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> separating the two.</p>
   </dd><dt>Double-quoted attribute value syntax</dt><dd>
    <p>The <a href="#syntax-attribute-name" id="attributes-2:syntax-attribute-name-4">attribute name</a>, followed by zero or more
    <a id="attributes-2:space-characters-9" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, followed by a single U+003D EQUALS SIGN character, followed by
    zero or more <a id="attributes-2:space-characters-10" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, followed by a single U+0022 QUOTATION MARK character
    ("), followed by the <a href="#syntax-attribute-value" id="attributes-2:syntax-attribute-value-3">attribute value</a>, which, in
    addition to the requirements given above for attribute values, must not contain any literal
    U+0022 QUOTATION MARK characters ("), and finally followed by a second single U+0022 QUOTATION
    MARK character (").</p>

    <div class="example">

     <p>In the following example, the <code id="attributes-2:attr-fe-name"><a href="#attr-fe-name">name</a></code> attribute is given with
     the double-quoted attribute value syntax:</p>

     <pre><code class="html"><c- p="">&lt;</c-><c- f="">input</c-> <em><c- e="">name</c-><c- o="">=</c-><c- s="">"be evil"</c-></em><c- p="">&gt;</c-></code></pre>

    </div>

    <p>If an attribute using the double-quoted attribute syntax is to be followed by another
    attribute, then there must be <a id="attributes-2:space-characters-11" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> separating the two.</p>
   </dd></dl>

  <p>There must never be two or more attributes on the same start tag whose names are an <a id="attributes-2:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for each other.</p>

  <hr>

  <p>When a <a href="#foreign-elements" id="attributes-2:foreign-elements-2">foreign element</a> has one of the namespaced
  attributes given by the local name and namespace of the first and second cells of a row from the
  following table, it must be written using the name given by the third cell from the same row.</p>

  <table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
   </th></tr></thead><tbody><tr><td> <code>actuate</code> </td><td> <a id="attributes-2:xlink-namespace" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a> </td><td> <code>xlink:actuate</code>
    </td></tr><tr><td> <code>arcrole</code> </td><td> <a id="attributes-2:xlink-namespace-2" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a> </td><td> <code>xlink:arcrole</code>
    </td></tr><tr><td> <code>href</code> </td><td> <a id="attributes-2:xlink-namespace-3" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a> </td><td> <code>xlink:href</code>
    </td></tr><tr><td> <code>role</code> </td><td> <a id="attributes-2:xlink-namespace-4" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a> </td><td> <code>xlink:role</code>
    </td></tr><tr><td> <code>show</code> </td><td> <a id="attributes-2:xlink-namespace-5" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a> </td><td> <code>xlink:show</code>
    </td></tr><tr><td> <code>title</code> </td><td> <a id="attributes-2:xlink-namespace-6" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a> </td><td> <code>xlink:title</code>
    </td></tr><tr><td> <code>type</code> </td><td> <a id="attributes-2:xlink-namespace-7" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a> </td><td> <code>xlink:type</code>
    </td></tr><tr><td> <code>lang</code> </td><td> <a id="attributes-2:xml-namespace" href="https://infra.spec.whatwg.org/#xml-namespace" data-x-internal="xml-namespace">XML namespace</a> </td><td> <code>xml:lang</code>
    </td></tr><tr><td> <code>space</code> </td><td> <a id="attributes-2:xml-namespace-2" href="https://infra.spec.whatwg.org/#xml-namespace" data-x-internal="xml-namespace">XML namespace</a> </td><td> <code>xml:space</code>
    </td></tr><tr><td> <code>xmlns</code> </td><td> <a id="attributes-2:xmlns-namespace" href="https://infra.spec.whatwg.org/#xmlns-namespace" data-x-internal="xmlns-namespace">XMLNS namespace</a> </td><td> <code>xmlns</code>
    </td></tr><tr><td> <code>xlink</code> </td><td> <a id="attributes-2:xmlns-namespace-2" href="https://infra.spec.whatwg.org/#xmlns-namespace" data-x-internal="xmlns-namespace">XMLNS namespace</a> </td><td> <code>xmlns:xlink</code>
  </td></tr></tbody></table>

  <p>No other namespaced attribute can be expressed in <a href="#syntax" id="attributes-2:syntax">the HTML syntax</a>.</p>

  <p class="note">Whether the attributes in the table above are conforming or not is defined by
  other specifications (e.g. <cite>SVG 2</cite> and <cite>MathML</cite>); this section only
  describes the syntax rules if the attributes are serialized using the HTML syntax.</p>


  <h5 id="optional-tags"><span class="secno">13.1.2.4</span> Optional tags<a href="#optional-tags" class="self-link"></a></h5>

  <p>Certain tags can be <dfn id="syntax-tag-omission">omitted</dfn>.</p>

  <p class="note">Omitting an element's <a href="#syntax-start-tag" id="optional-tags:syntax-start-tag">start tag</a> in the
  situations described below does not mean the element is not present; it is implied, but it is
  still there. For example, an HTML document always has a root <code id="optional-tags:the-html-element"><a href="#the-html-element">html</a></code> element, even if
  the string <code>&lt;html&gt;</code> doesn't appear anywhere in the markup.</p>

  
  <p>An <code id="optional-tags:the-html-element-2"><a href="#the-html-element">html</a></code> element's <a href="#syntax-start-tag" id="optional-tags:syntax-start-tag-2">start tag</a> may be omitted
  if the first thing inside the <code id="optional-tags:the-html-element-3"><a href="#the-html-element">html</a></code> element is not a <a href="#syntax-comments" id="optional-tags:syntax-comments">comment</a>.</p>

  <div class="example">

   <p>For example, in the following case it's ok to remove the "<code>&lt;html&gt;</code>"
   tag:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<strong><c- p="">&lt;</c-><c- f="">html</c-><c- p="">&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>Doing so would make the document look like this:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->

  <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>This has the exact same DOM. In particular, note that whitespace around the <a id="optional-tags:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document
   element</a> is ignored by the parser. The following example would also have the exact same
   DOM:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c-><c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>However, in the following example, removing the start tag moves the comment to before the
   <code id="optional-tags:the-html-element-4"><a href="#the-html-element">html</a></code> element:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-><c- p="">&gt;</c->
  <strong><c- c="">&lt;!-- where is this comment in the DOM? --&gt;</c-></strong>
  <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>With the tag removed, the document actually turns into the same as this:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- c="">&lt;!-- where is this comment in the DOM? --&gt;</c->
<small><c- p="">&lt;</c-><c- f="">html</c-><c- p="">&gt;</c-></small>
  <c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c->
    <c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>This is why the tag can only be removed if it is not followed by a comment: removing the tag
   when there is a comment there changes the document's resulting parse tree. Of course, if the
   position of the comment does not matter, then the tag can be omitted, as if the comment had been
   moved to before the start tag in the first place.</p>

  </div>

  
  <p>An <code id="optional-tags:the-html-element-5"><a href="#the-html-element">html</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag">end tag</a> may be omitted if
  the <code id="optional-tags:the-html-element-6"><a href="#the-html-element">html</a></code> element is not immediately followed by a <a href="#syntax-comments" id="optional-tags:syntax-comments-2">comment</a>.</p>

  
  <p>A <code id="optional-tags:the-head-element"><a href="#the-head-element">head</a></code> element's <a href="#syntax-start-tag" id="optional-tags:syntax-start-tag-3">start tag</a> may be omitted if
  the element is empty, or if the first thing inside the <code id="optional-tags:the-head-element-2"><a href="#the-head-element">head</a></code> element is an
  element.</p>

  
  <p>A <code id="optional-tags:the-head-element-3"><a href="#the-head-element">head</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-2">end tag</a> may be omitted if
  the <code id="optional-tags:the-head-element-4"><a href="#the-head-element">head</a></code> element is not immediately followed by <a id="optional-tags:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> or a
  <a href="#syntax-comments" id="optional-tags:syntax-comments-3">comment</a>.</p>

  
  <p>A <code id="optional-tags:the-body-element"><a href="#the-body-element">body</a></code> element's <a href="#syntax-start-tag" id="optional-tags:syntax-start-tag-4">start tag</a> may be omitted
  if the element is empty, or if the first thing inside the <code id="optional-tags:the-body-element-2"><a href="#the-body-element">body</a></code> element is not
  <a id="optional-tags:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> or a <a href="#syntax-comments" id="optional-tags:syntax-comments-4">comment</a>, except if the
  first thing inside the <code id="optional-tags:the-body-element-3"><a href="#the-body-element">body</a></code> element is a <code id="optional-tags:the-meta-element"><a href="#the-meta-element">meta</a></code>, <code id="optional-tags:the-noscript-element"><a href="#the-noscript-element">noscript</a></code>,
  <code id="optional-tags:the-link-element"><a href="#the-link-element">link</a></code>, <code id="optional-tags:the-script-element"><a href="#the-script-element">script</a></code>, <code id="optional-tags:the-style-element"><a href="#the-style-element">style</a></code>, or <code id="optional-tags:the-template-element"><a href="#the-template-element">template</a></code> element.
  </p>

  
  <p>A <code id="optional-tags:the-body-element-4"><a href="#the-body-element">body</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-3">end tag</a> may be omitted if the
  <code id="optional-tags:the-body-element-5"><a href="#the-body-element">body</a></code> element is not immediately followed by a <a href="#syntax-comments" id="optional-tags:syntax-comments-5">comment</a>.</p>

  <div class="example">

   <p>Note that in the example above, the <code id="optional-tags:the-head-element-5"><a href="#the-head-element">head</a></code> element start and end tags, and the
   <code id="optional-tags:the-body-element-6"><a href="#the-body-element">body</a></code> element start tag, can't be omitted, because they are surrounded by
   whitespace:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">html</c-><c- p="">&gt;</c-><strong>
  </strong><c- p="">&lt;</c-><c- f="">head</c-><c- p="">&gt;</c-><strong>
    </strong><c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c-><strong>
  </strong><c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;</c-><strong>
  </strong><c- p="">&lt;</c-><c- f="">body</c-><c- p="">&gt;</c-><strong>
    </strong><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>(The <code id="optional-tags:the-body-element-7"><a href="#the-body-element">body</a></code> and <code id="optional-tags:the-html-element-7"><a href="#the-html-element">html</a></code> element end tags could be omitted without
   trouble; any spaces after those get parsed into the <code id="optional-tags:the-body-element-8"><a href="#the-body-element">body</a></code> element anyway.)</p>

   <p>Usually, however, whitespace isn't an issue. If we first remove the whitespace we don't care
   about:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c-><c- p="">&lt;</c-><c- f="">html</c-><c- p="">&gt;&lt;</c-><c- f="">head</c-><c- p="">&gt;&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;&lt;/</c-><c- f="">head</c-><c- p="">&gt;&lt;</c-><c- f="">body</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">body</c-><c- p="">&gt;&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <p>Then we can omit a number of tags without affecting the DOM:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c-><c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>At that point, we can also add some whitespace back:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>This would be equivalent to this document, with the omitted tags shown in their
   parser-implied positions; the only whitespace text node that results from this is the newline at
   the end of the <code id="optional-tags:the-head-element-6"><a href="#the-head-element">head</a></code> element:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c->
<small><c- p="">&lt;</c-><c- f="">html</c-><c- p="">&gt;&lt;</c-><c- f="">head</c-><c- p="">&gt;</c-></small><c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;</c->
<small><c- p="">&lt;/</c-><c- f="">head</c-><c- p="">&gt;&lt;</c-><c- f="">body</c-><c- p="">&gt;</c-></small><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-><small><c- p="">&lt;/</c-><c- f="">body</c-><c- p="">&gt;&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></small></code></pre>

  </div>

  
  <p>An <code id="optional-tags:the-li-element"><a href="#the-li-element">li</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-4">end tag</a> may be omitted if the
  <code id="optional-tags:the-li-element-2"><a href="#the-li-element">li</a></code> element is immediately followed by another <code id="optional-tags:the-li-element-3"><a href="#the-li-element">li</a></code> element or if there is
  no more content in the parent element.</p>

  
  <p>A <code id="optional-tags:the-dt-element"><a href="#the-dt-element">dt</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-5">end tag</a> may be omitted if the
  <code id="optional-tags:the-dt-element-2"><a href="#the-dt-element">dt</a></code> element is immediately followed by another <code id="optional-tags:the-dt-element-3"><a href="#the-dt-element">dt</a></code> element or a
  <code id="optional-tags:the-dd-element"><a href="#the-dd-element">dd</a></code> element.</p>

  
  <p>A <code id="optional-tags:the-dd-element-2"><a href="#the-dd-element">dd</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-6">end tag</a> may be omitted if the
  <code id="optional-tags:the-dd-element-3"><a href="#the-dd-element">dd</a></code> element is immediately followed by another <code id="optional-tags:the-dd-element-4"><a href="#the-dd-element">dd</a></code> element or a
  <code id="optional-tags:the-dt-element-4"><a href="#the-dt-element">dt</a></code> element, or if there is no more content in the parent element.</p>

  
  <p>A <code id="optional-tags:the-p-element"><a href="#the-p-element">p</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-7">end tag</a> may be omitted if the
  <code id="optional-tags:the-p-element-2"><a href="#the-p-element">p</a></code> element is immediately followed by an <code id="optional-tags:the-address-element"><a href="#the-address-element">address</a></code>, <code id="optional-tags:the-article-element"><a href="#the-article-element">article</a></code>,
  <code id="optional-tags:the-aside-element"><a href="#the-aside-element">aside</a></code>, <code id="optional-tags:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code>, <code id="optional-tags:the-details-element"><a href="#the-details-element">details</a></code>, <code id="optional-tags:the-dialog-element"><a href="#the-dialog-element">dialog</a></code>,
  <code id="optional-tags:the-div-element"><a href="#the-div-element">div</a></code>, <code id="optional-tags:the-dl-element"><a href="#the-dl-element">dl</a></code>, <code id="optional-tags:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code>, <code id="optional-tags:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code>,
  <code id="optional-tags:the-figure-element"><a href="#the-figure-element">figure</a></code>, <code id="optional-tags:the-footer-element"><a href="#the-footer-element">footer</a></code>, <code id="optional-tags:the-form-element"><a href="#the-form-element">form</a></code>, <code id="optional-tags:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, <code id="optional-tags:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>,
  <code id="optional-tags:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, <code id="optional-tags:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>, <code id="optional-tags:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>, <code id="optional-tags:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>, <code id="optional-tags:the-header-element"><a href="#the-header-element">header</a></code>,
  <code id="optional-tags:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code>, <code id="optional-tags:the-hr-element"><a href="#the-hr-element">hr</a></code>, <code id="optional-tags:the-main-element"><a href="#the-main-element">main</a></code>, <code id="optional-tags:the-menu-element"><a href="#the-menu-element">menu</a></code>, <code id="optional-tags:the-nav-element"><a href="#the-nav-element">nav</a></code>,
  <code id="optional-tags:the-ol-element"><a href="#the-ol-element">ol</a></code>, <code id="optional-tags:the-p-element-3"><a href="#the-p-element">p</a></code>, <code id="optional-tags:the-pre-element"><a href="#the-pre-element">pre</a></code>, <code id="optional-tags:the-search-element"><a href="#the-search-element">search</a></code>, <code id="optional-tags:the-section-element"><a href="#the-section-element">section</a></code>,
  <code id="optional-tags:the-table-element"><a href="#the-table-element">table</a></code>, or <code id="optional-tags:the-ul-element"><a href="#the-ul-element">ul</a></code> element, or if there is no more content in the parent
  element and the parent element is an <a href="#html-elements" id="optional-tags:html-elements">HTML element</a> that is not
  an <code id="optional-tags:the-a-element"><a href="#the-a-element">a</a></code>, <code id="optional-tags:the-audio-element"><a href="#the-audio-element">audio</a></code>, <code id="optional-tags:the-del-element"><a href="#the-del-element">del</a></code>, <code id="optional-tags:the-ins-element"><a href="#the-ins-element">ins</a></code>, <code id="optional-tags:the-map-element"><a href="#the-map-element">map</a></code>,
  <code id="optional-tags:the-noscript-element-2"><a href="#the-noscript-element">noscript</a></code>, or <code id="optional-tags:the-video-element"><a href="#the-video-element">video</a></code> element, or an <a href="#autonomous-custom-element" id="optional-tags:autonomous-custom-element">autonomous custom
  element</a>.</p>

  <div class="example">

   <p>We can thus simplify the earlier example further:

   </p><pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c-><c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.</code></pre>

  </div>

  
  <p>An <code id="optional-tags:the-rt-element"><a href="#the-rt-element">rt</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-8">end tag</a> may be omitted if the
  <code id="optional-tags:the-rt-element-2"><a href="#the-rt-element">rt</a></code> element is immediately followed by an <code id="optional-tags:the-rt-element-3"><a href="#the-rt-element">rt</a></code> or <code id="optional-tags:the-rp-element"><a href="#the-rp-element">rp</a></code> element,
  or if there is no more content in the parent element.</p>

  
  <p>An <code id="optional-tags:the-rp-element-2"><a href="#the-rp-element">rp</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-9">end tag</a> may be omitted if the
  <code id="optional-tags:the-rp-element-3"><a href="#the-rp-element">rp</a></code> element is immediately followed by an <code id="optional-tags:the-rt-element-4"><a href="#the-rt-element">rt</a></code> or <code id="optional-tags:the-rp-element-4"><a href="#the-rp-element">rp</a></code> element,
  or if there is no more content in the parent element.</p>

  
  <p>An <code id="optional-tags:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-10">end tag</a> may be omitted
  if the <code id="optional-tags:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> element  is
  immediately followed by another <code id="optional-tags:the-optgroup-element-3"><a href="#the-optgroup-element">optgroup</a></code> element, if it is immediately followed by an
  <code id="optional-tags:the-hr-element-2"><a href="#the-hr-element">hr</a></code> element, or if  there is no more content in the parent
  element.</p>
  

  
  <p>An <code id="optional-tags:the-option-element"><a href="#the-option-element">option</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-11">end tag</a> may be omitted if
  the <code id="optional-tags:the-option-element-2"><a href="#the-option-element">option</a></code> element is immediately followed by another <code id="optional-tags:the-option-element-3"><a href="#the-option-element">option</a></code> element, if
  it is immediately followed by an <code id="optional-tags:the-optgroup-element-4"><a href="#the-optgroup-element">optgroup</a></code> element, if it is immediately followed by
  an <code id="optional-tags:the-hr-element-3"><a href="#the-hr-element">hr</a></code> element, or if there is no more content in the parent element.</p>

  
  <p>A <code id="optional-tags:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> element's <a href="#syntax-start-tag" id="optional-tags:syntax-start-tag-5">start tag</a> may be
  omitted if the first thing inside the <code id="optional-tags:the-colgroup-element-2"><a href="#the-colgroup-element">colgroup</a></code> element is a <code id="optional-tags:the-col-element"><a href="#the-col-element">col</a></code> element,
  and if the element is not immediately preceded by another <code id="optional-tags:the-colgroup-element-3"><a href="#the-colgroup-element">colgroup</a></code> element whose
  <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-12">end tag</a> has been omitted. (It can't be omitted if the element
  is empty.)</p>

  
  <p>A <code id="optional-tags:the-colgroup-element-4"><a href="#the-colgroup-element">colgroup</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-13">end tag</a> may be omitted
  if the <code id="optional-tags:the-colgroup-element-5"><a href="#the-colgroup-element">colgroup</a></code> element is not immediately followed by <a id="optional-tags:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>
  or a <a href="#syntax-comments" id="optional-tags:syntax-comments-6">comment</a>.</p>

  
  <p>A <code id="optional-tags:the-caption-element"><a href="#the-caption-element">caption</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-14">end tag</a> may be omitted if
  the <code id="optional-tags:the-caption-element-2"><a href="#the-caption-element">caption</a></code> element is not immediately followed by <a id="optional-tags:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> or a
  <a href="#syntax-comments" id="optional-tags:syntax-comments-7">comment</a>.</p>

  
  <p>A <code id="optional-tags:the-thead-element"><a href="#the-thead-element">thead</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-15">end tag</a> may be omitted if
  the <code id="optional-tags:the-thead-element-2"><a href="#the-thead-element">thead</a></code> element is immediately followed by a <code id="optional-tags:the-tbody-element"><a href="#the-tbody-element">tbody</a></code> or
  <code id="optional-tags:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> element.</p>

  
  <p>A <code id="optional-tags:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code> element's <a href="#syntax-start-tag" id="optional-tags:syntax-start-tag-6">start tag</a> may be omitted
  if the first thing inside the <code id="optional-tags:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code> element is a <code id="optional-tags:the-tr-element"><a href="#the-tr-element">tr</a></code> element, and if the
  element is not immediately preceded by a <code id="optional-tags:the-tbody-element-4"><a href="#the-tbody-element">tbody</a></code>, <code id="optional-tags:the-thead-element-3"><a href="#the-thead-element">thead</a></code>, or
  <code id="optional-tags:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-16">end tag</a> has been omitted. (It
  can't be omitted if the element is empty.)</p>

  
  <p>A <code id="optional-tags:the-tbody-element-5"><a href="#the-tbody-element">tbody</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-17">end tag</a> may be omitted if
  the <code id="optional-tags:the-tbody-element-6"><a href="#the-tbody-element">tbody</a></code> element is immediately followed by a <code id="optional-tags:the-tbody-element-7"><a href="#the-tbody-element">tbody</a></code> or
  <code id="optional-tags:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code> element, or if there is no more content in the parent element.</p>

  
  <p>A <code id="optional-tags:the-tfoot-element-4"><a href="#the-tfoot-element">tfoot</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-18">end tag</a> may be omitted if
  there is no more content in the parent element.</p>

  
  <p>A <code id="optional-tags:the-tr-element-2"><a href="#the-tr-element">tr</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-19">end tag</a> may be omitted if the
  <code id="optional-tags:the-tr-element-3"><a href="#the-tr-element">tr</a></code> element is immediately followed by another <code id="optional-tags:the-tr-element-4"><a href="#the-tr-element">tr</a></code> element, or if there is
  no more content in the parent element.</p>

  
  <p>A <code id="optional-tags:the-td-element"><a href="#the-td-element">td</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-20">end tag</a> may be omitted if the
  <code id="optional-tags:the-td-element-2"><a href="#the-td-element">td</a></code> element is immediately followed by a <code id="optional-tags:the-td-element-3"><a href="#the-td-element">td</a></code> or <code id="optional-tags:the-th-element"><a href="#the-th-element">th</a></code> element,
  or if there is no more content in the parent element.</p>

  
  <p>A <code id="optional-tags:the-th-element-2"><a href="#the-th-element">th</a></code> element's <a href="#syntax-end-tag" id="optional-tags:syntax-end-tag-21">end tag</a> may be omitted if the
  <code id="optional-tags:the-th-element-3"><a href="#the-th-element">th</a></code> element is immediately followed by a <code id="optional-tags:the-td-element-4"><a href="#the-td-element">td</a></code> or <code id="optional-tags:the-th-element-4"><a href="#the-th-element">th</a></code> element,
  or if there is no more content in the parent element.</p>

  <div class="example">

   <p>The ability to omit all these table-related tags makes table markup much terser.</p>

   <p>Take this example:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->37547 TEE Electric Powered Rail Car Train Functions (Abbreviated)<c- p="">&lt;/</c-><c- f="">caption</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">colgroup</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;/</c-><c- f="">colgroup</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Function<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Control Unit<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Central Station<c- p="">&lt;/</c-><c- f="">th</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">thead</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Headlights<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Interior Lights<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Electric locomotive operating sounds<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Engineer's cab lighting<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Station Announcements - Swiss<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">tbody</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

   <p>The exact same table, modulo some whitespace differences, could be marked up as follows:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->37547 TEE Electric Powered Rail Car Train Functions (Abbreviated)
 <c- p="">&lt;</c-><c- f="">colgroup</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Function
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Control Unit
   <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Central Station
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Headlights
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Interior Lights
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Electric locomotive operating sounds
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Engineer's cab lighting
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Station Announcements - Swiss
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

   <p>Since the cells take up much less room this way, this can be made even terser by having each
   row on one line:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">caption</c-><c- p="">&gt;</c->37547 TEE Electric Powered Rail Car Train Functions (Abbreviated)
 <c- p="">&lt;</c-><c- f="">colgroup</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;&lt;</c-><c- f="">col</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">thead</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Function                              <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Control Unit     <c- p="">&lt;</c-><c- f="">th</c-><c- p="">&gt;</c->Central Station
 <c- p="">&lt;</c-><c- f="">tbody</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Headlights                            <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔                <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Interior Lights                       <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔                <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Electric locomotive operating sounds  <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔                <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Engineer's cab lighting               <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->                 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
  <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c-> <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->Station Announcements - Swiss         <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->                 <c- p="">&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->✔
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>

   <p>The only differences between these tables, at the DOM level, is with the precise position of
   the (in any case semantically-neutral) whitespace.</p>

  </div>

  <p><strong>However</strong>, a <a href="#syntax-start-tag" id="optional-tags:syntax-start-tag-7">start tag</a> must never be
  omitted if it has any attributes.</p>

  <div class="example">

   <p>Returning to the earlier example with all the whitespace removed and then all the optional
   tags removed:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c-><c- p="">&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.</code></pre>

   <p>If the <code id="optional-tags:the-body-element-9"><a href="#the-body-element">body</a></code> element in this example had to have a <code id="optional-tags:classes"><a href="#classes">class</a></code> attribute and the <code id="optional-tags:the-html-element-8"><a href="#the-html-element">html</a></code> element had to have a <code id="optional-tags:attr-lang"><a href="#attr-lang">lang</a></code> attribute, the markup would have to become:</p>

   <pre><code class="html"><c- cp="">&lt;!DOCTYPE HTML&gt;</c-><c- p="">&lt;</c-><c- f="">html</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"en"</c-><c- p="">&gt;&lt;</c-><c- f="">title</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">title</c-><c- p="">&gt;&lt;</c-><c- f="">body</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">"demo"</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->Welcome to this example.</code></pre>

  </div>

  <p class="note">This section assumes that the document is conforming, in particular, that there
  are no <a href="#content-models" id="optional-tags:content-models">content model</a> violations. Omitting tags in the fashion
  described in this section in a document that does not conform to the <a href="#content-models" id="optional-tags:content-models-2">content models</a>
  described in this specification is likely to result in unexpected DOM differences (this is, in
  part, what the content models are designed to avoid).</p>


  <h5 id="element-restrictions"><span class="secno">13.1.2.5</span> Restrictions on content models<a href="#element-restrictions" class="self-link"></a></h5>

  <p>For historical reasons, certain elements have extra restrictions beyond even the restrictions
  given by their content model.</p>

  <p>A <code id="element-restrictions:the-table-element"><a href="#the-table-element">table</a></code> element must not contain <code id="element-restrictions:the-tr-element"><a href="#the-tr-element">tr</a></code> elements, even though these
  elements are technically allowed inside <code id="element-restrictions:the-table-element-2"><a href="#the-table-element">table</a></code> elements according to the content
  models described in this specification. (If a <code id="element-restrictions:the-tr-element-2"><a href="#the-tr-element">tr</a></code> element is put inside a
  <code id="element-restrictions:the-table-element-3"><a href="#the-table-element">table</a></code> in the markup, it will in fact imply a <code id="element-restrictions:the-tbody-element"><a href="#the-tbody-element">tbody</a></code> start tag before
  it.)</p>

  <p>A single <a href="#syntax-newlines" id="element-restrictions:syntax-newlines">newline</a> may be placed immediately after the <a href="#syntax-start-tag" id="element-restrictions:syntax-start-tag">start tag</a> of <code id="element-restrictions:the-pre-element"><a href="#the-pre-element">pre</a></code> and <code id="element-restrictions:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements.
  This does not affect the processing of the element. The otherwise optional <a href="#syntax-newlines" id="element-restrictions:syntax-newlines-2">newline</a> <em>must</em> be included if the element's contents
  themselves start with a <a href="#syntax-newlines" id="element-restrictions:syntax-newlines-3">newline</a> (because otherwise the
  leading newline in the contents would be treated like the optional newline, and ignored).</p>

  <div class="example">
   <p>The following two <code id="element-restrictions:the-pre-element-2"><a href="#the-pre-element">pre</a></code> blocks are equivalent:</p>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;</c->Hello<c- p="">&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>
   <pre><code class="html"><c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;</c-><br>Hello<c- p="">&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>
  </div>


  <h5 id="cdata-rcdata-restrictions"><span class="secno">13.1.2.6</span> Restrictions on the contents of raw text and escapable raw text elements<a href="#cdata-rcdata-restrictions" class="self-link"></a></h5>

  <p>The text in <a href="#raw-text-elements" id="cdata-rcdata-restrictions:raw-text-elements">raw text</a> and <a href="#escapable-raw-text-elements" id="cdata-rcdata-restrictions:escapable-raw-text-elements">escapable raw text
  elements</a> must not contain any occurrences of the string "<code>&lt;/</code>"
  (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the
  tag name of the element followed by one of U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED
  (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, U+003E GREATER-THAN SIGN
  (&gt;), or U+002F SOLIDUS (/).</p>


  <h4 id="text-2"><span class="secno">13.1.3</span> Text<a href="#text-2" class="self-link"></a></h4>

  <p><dfn id="syntax-text">Text</dfn> is allowed inside elements, attribute values, and comments.
  Extra constraints are placed on what is and what is not allowed in text based on where the text is
  to be put, as described in the other sections.</p>


  <h5 id="newlines"><span class="secno">13.1.3.1</span> Newlines<a href="#newlines" class="self-link"></a></h5>

  <p><dfn id="syntax-newlines">Newlines</dfn> in HTML may be represented either as U+000D
  CARRIAGE RETURN (CR) characters, U+000A LINE FEED (LF) characters, or pairs of U+000D CARRIAGE
  RETURN (CR), U+000A LINE FEED (LF) characters in that order.</p>

  <p>Where <a href="#syntax-charref" id="newlines:syntax-charref">character references</a> are allowed, a character
  reference of a U+000A LINE FEED (LF) character (but not a U+000D CARRIAGE RETURN (CR) character)
  also represents a <a href="#syntax-newlines" id="newlines:syntax-newlines">newline</a>.</p>


  <h4 id="character-references"><span class="secno">13.1.4</span> Character references<a href="#character-references" class="self-link"></a></h4>

  <p>In certain cases described in other sections, <a href="#syntax-text" id="character-references:syntax-text">text</a> may be
  mixed with <dfn id="syntax-charref">character references</dfn>. These can be used to escape
  characters that couldn't otherwise legally be included in <a href="#syntax-text" id="character-references:syntax-text-2">text</a>.</p>

  <div data-algorithm="">
  <p>Character references must start with a U+0026 AMPERSAND character (&amp;). Following this,
  there are three possible kinds of character references:</p>

  <dl><dt>Named character references</dt><dd>The ampersand must be followed by one of the names given in the <a href="#named-character-references" id="character-references:named-character-references">named character
   references</a> section, using the same case. The name must be one that is
   terminated by a U+003B SEMICOLON character (;).</dd><dt>Decimal numeric character reference</dt><dd>The ampersand must be followed by a U+0023 NUMBER SIGN character (#), followed by one or more
   <a id="character-references:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>, representing a base-ten integer that corresponds to a code point that
   is allowed according to the definition below. The digits must then be followed by a U+003B
   SEMICOLON character (;).</dd><dt>Hexadecimal numeric character reference</dt><dd>The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which must be followed
   by either a U+0078 LATIN SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
   character (X), which must then be followed by one or more <a id="character-references:ascii-hex-digits" href="https://infra.spec.whatwg.org/#ascii-hex-digit" data-x-internal="ascii-hex-digits">ASCII hex digits</a>,
   representing a hexadecimal integer that corresponds to a code point that is allowed according to
   the definition below. The digits must then be followed by a U+003B SEMICOLON character (;).</dd></dl>

  <p>The numeric character reference forms described above are allowed to reference any code point
  excluding U+000D CR, <a href="https://infra.spec.whatwg.org/#noncharacter" id="character-references:noncharacter" data-x-internal="noncharacter">noncharacters</a>, and <a href="https://infra.spec.whatwg.org/#control" id="character-references:control" data-x-internal="control">controls</a> other than <a id="character-references:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>.</p>
  </div>

  <div data-algorithm="">
  <p>An <dfn id="syntax-ambiguous-ampersand">ambiguous ampersand</dfn> is a U+0026 AMPERSAND
  character (&amp;) that is followed by one or more <a href="https://infra.spec.whatwg.org/#ascii-alphanumeric" id="character-references:alphanumeric-ascii-characters" data-x-internal="alphanumeric-ascii-characters">ASCII
  alphanumerics</a>, followed by a U+003B SEMICOLON character (;), where these characters do not
  match any of the names given in the <a href="#named-character-references" id="character-references:named-character-references-2">named character references</a> section.</p>
  </div>


  <h4 id="cdata-sections"><span class="secno">13.1.5</span> CDATA sections<a href="#cdata-sections" class="self-link"></a></h4>

  <div data-algorithm="">
  <p><dfn id="syntax-cdata">CDATA sections</dfn> must consist of the following components, in
  this order:</p>

  <ol><li>The string "<code>&lt;![CDATA[</code>".</li><li>Optionally, <a href="#syntax-text" id="cdata-sections:syntax-text">text</a>, with the additional restriction that the
   text must not contain the string "<code>]]&gt;</code>".</li><li>The string "<code>]]&gt;</code>".</li></ol>
  </div>

  <div class="example">

   <p>CDATA sections can only be used in foreign content (MathML or SVG). In this example, a CDATA
   section is used to escape the contents of a <a id="cdata-sections:mathml-ms" href="https://w3c.github.io/mathml-core/#string-literal-ms" data-x-internal="mathml-ms">MathML <code>ms</code></a> element:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->You can add a string to a number, but this stringifies the number:<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">math</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ms</c-><c- p="">&gt;</c-><c- cp="">&lt;![CDATA[x&lt;y]]&gt;</c-><c- p="">&lt;/</c-><c- f="">ms</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">mo</c-><c- p="">&gt;</c->+<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">mn</c-><c- p="">&gt;</c->3<c- p="">&lt;/</c-><c- f="">mn</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">mo</c-><c- p="">&gt;</c->=<c- p="">&lt;/</c-><c- f="">mo</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">ms</c-><c- p="">&gt;</c-><c- cp="">&lt;![CDATA[x&lt;y3]]&gt;</c-><c- p="">&lt;/</c-><c- f="">ms</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">math</c-><c- p="">&gt;</c-></code></pre>

  </div>


  <h4 id="comments"><span class="secno">13.1.6</span> Comments<a href="#comments" class="self-link"></a></h4>

  <div data-algorithm="">
  <p><dfn id="syntax-comments">Comments</dfn> must have the following format:</p>

  <ol><li>The string "<code>&lt;!--</code>".</li><li>Optionally, <a href="#syntax-text" id="comments:syntax-text">text</a>, with the additional restriction that the
   text must not start with the string "<code>&gt;</code>", nor start with the string
   "<code>-&gt;</code>", nor contain the strings "<code>&lt;!--</code>", "<code>--&gt;</code>", or "<code>--!&gt;</code>", nor end with the string "<code>&lt;!-</code>".</li><li>The string "<code>--&gt;</code>".</li></ol>
  </div>

  <p class="note">The <a href="#syntax-text" id="comments:syntax-text-2">text</a> is allowed to end with the string
  "<code>&lt;!</code>", as in <code>&lt;!--My favorite operators are &gt; and
  &lt;!--&gt;</code>.</p>




  

  <h3 id="parsing"><span class="secno">13.2</span> Parsing HTML documents<a href="#parsing" class="self-link"></a></h3>

  <p><i>This section only applies to user agents, data mining tools, and conformance
  checkers.</i></p>

  <p class="note">The rules for parsing XML documents into DOM trees are covered by the next
  section, entitled "<a href="#the-xhtml-syntax" id="parsing:the-xhtml-syntax">The XML syntax</a>".</p>

  <p>User agents must use the parsing rules described in this section to generate the DOM trees from
  <code id="parsing:text/html"><a href="#text/html">text/html</a></code> resources. Together, these rules define what is referred to as the
  <dfn id="html-parser" data-export="">HTML parser</dfn>.</p>

  <div class="note">
   <p>While the HTML syntax described in this specification bears a close resemblance to SGML and
   XML, it is a separate language with its own parsing rules.</p>

   <p>Some earlier versions of HTML (in particular from HTML2 to HTML4) were based on SGML and used
   SGML parsing rules. However, few (if any) web browsers ever implemented true SGML parsing for
   HTML documents; the only user agents to strictly handle HTML as an SGML application have
   historically been validators. The resulting confusion — with validators claiming documents
   to have one representation while widely deployed web browsers interoperably implemented a
   different representation — has wasted decades of productivity. This version of HTML thus
   returns to a non-SGML basis.</p>
  </div>

  <p>For the purposes of conformance checkers, if a resource is determined to be in <a href="#syntax" id="parsing:syntax">the HTML
  syntax</a>, then it is an <a href="https://dom.spec.whatwg.org/#html-document" id="parsing:html-documents" data-x-internal="html-documents">HTML document</a>.</p>

  <p class="note">As stated <a href="#html-elements" id="parsing:html-elements">in the terminology section</a>,
  references to <a href="#element-type" id="parsing:element-type">element types</a> that do not explicitly specify a
  namespace always refer to elements in the <a id="parsing:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>. For example, if the spec
  talks about "a <code id="parsing:the-menu-element"><a href="#the-menu-element">menu</a></code> element", then that is an element with the local name "<code>menu</code>", the namespace "<code>http://www.w3.org/1999/xhtml</code>", and
  the interface <code id="parsing:htmlmenuelement"><a href="#htmlmenuelement">HTMLMenuElement</a></code>. Where possible, references to such elements are
  hyperlinked to their definition.</p>

  


  

  <h4 id="overview-of-the-parsing-model"><span class="secno">13.2.1</span> Overview of the parsing model<a href="#overview-of-the-parsing-model" class="self-link"></a></h4>

  <p class="overview"><img class="darkmode-aware" src="/images/parsing-model-overview.svg" width="345" alt="" height="535"></p>

  <p>The input to the HTML parsing process consists of a stream of <a href="https://infra.spec.whatwg.org/#code-point" id="overview-of-the-parsing-model:code-point" data-x-internal="code-point">code
  points</a>, which is passed through a <a href="#tokenization" id="overview-of-the-parsing-model:tokenization">tokenization</a> stage followed by a <a href="#tree-construction" id="overview-of-the-parsing-model:tree-construction">tree
  construction</a> stage. The output is a <code id="overview-of-the-parsing-model:document"><a href="#document">Document</a></code> object.</p>

  <p class="note">Implementations that <a href="#non-scripted">do not support scripting</a> do not
  have to actually create a DOM <code id="overview-of-the-parsing-model:document-2"><a href="#document">Document</a></code> object, but the DOM tree in such cases is
  still used as the model for the rest of the specification.</p>

  <p>In the common case, the data handled by the tokenization stage comes from the network, but
  <a href="#dynamic-markup-insertion" id="overview-of-the-parsing-model:dynamic-markup-insertion">it can also come from script</a> running in the user
  agent, e.g. using the <code id="overview-of-the-parsing-model:dom-document-write"><a href="#dom-document-write">document.write()</a></code> API.</p>

  <p id="nestedParsing">There is only one set of states for the tokenizer stage and the tree
  construction stage, but the tree construction stage is reentrant, meaning that while the tree
  construction stage is handling one token, the tokenizer might be resumed, causing further tokens
  to be emitted and processed before the first token's processing is complete.</p>

  <div class="example">

   <p>In the following example, the tree construction stage will be called upon to handle a "p"
   start tag token while handling the "script" end tag token:</p>

   <pre><code class="html">...
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 document<c- p="">.</c->write<c- p="">(</c-><c- t="">'&lt;p&gt;'</c-><c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
...</code></pre>

  </div>

  <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting level</dfn>, which must be initially
  set to zero, and a <dfn id="parser-pause-flag">parser pause flag</dfn>, which must be initially set to false.</p>

  



  

  <h4 id="parse-errors"><span class="secno">13.2.2</span> <dfn>Parse errors</dfn><a href="#parse-errors" class="self-link"></a></h4>

  <p>This specification defines the parsing rules for HTML documents, whether they are syntactically
  correct or not. Certain points in the parsing algorithm are said to be <a href="#parse-errors" id="parse-errors:parse-errors">parse errors</a>. The error handling for parse errors is well-defined (that's the
  processing rules described throughout this specification), but user agents, while parsing an HTML
  document, may <a href="#abort-a-parser" id="parse-errors:abort-a-parser">abort the parser</a> at the first <a href="#parse-errors" id="parse-errors:parse-errors-2">parse
  error</a> that they encounter for which they do not wish to apply the rules described in this
  specification.</p>

  <p>Conformance checkers must report at least one parse error condition to the user if one or more
  parse error conditions exist in the document and must not report parse error conditions if none
  exist in the document. Conformance checkers may report more than one parse error condition if more
  than one parse error condition exists in the document.</p>

  <p class="note">Parse errors are only errors with the <em>syntax</em> of HTML. In addition to
  checking for parse errors, conformance checkers will also verify that the document obeys all the
  other conformance requirements described in this specification.</p>

  <p>Some parse errors have dedicated codes outlined in the table below that should be used by
  conformance checkers in reports.</p>

  <p><i>Error descriptions in the table below are non-normative.</i></p>

  <table class="parse-error-table"><thead><tr><th>Code
     </th><th>Description
    </th></tr></thead><tbody><tr><td><dfn id="parse-error-abrupt-closing-of-empty-comment">abrupt-closing-of-empty-comment</dfn>
     </td><td><p>This error occurs if the parser encounters an empty <a href="#syntax-comments" id="parse-errors:syntax-comments">comment</a> that is abruptly closed by a U+003E (&gt;) <a id="parse-errors:code-point" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
     point</a> (i.e., <code>&lt;!--&gt;</code> or <code>&lt;!---&gt;</code>). The
     parser behaves as if the comment is closed correctly.</p>

    </td></tr><tr><td><dfn id="parse-error-abrupt-doctype-public-identifier">abrupt-doctype-public-identifier</dfn>
     </td><td><p>This error occurs if the parser encounters a U+003E (&gt;) <a id="parse-errors:code-point-2" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in the
     <a href="#syntax-doctype" id="parse-errors:syntax-doctype">DOCTYPE</a> public identifier (e.g., <code>&lt;!DOCTYPE html PUBLIC "foo&gt;</code>). In such a case, if the DOCTYPE is correctly
     placed as a document preamble, the parser sets the <code id="parse-errors:document"><a href="#document">Document</a></code> to <a id="parse-errors:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks
     mode</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-abrupt-doctype-system-identifier">abrupt-doctype-system-identifier</dfn>
     </td><td><p>This error occurs if the parser encounters a U+003E (&gt;) <a id="parse-errors:code-point-3" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in the
     <a href="#syntax-doctype" id="parse-errors:syntax-doctype-2">DOCTYPE</a> system identifier (e.g., <code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "foo&gt;</code>). In such a case,
     if the DOCTYPE is correctly placed as a document preamble, the parser sets the
     <code id="parse-errors:document-2"><a href="#document">Document</a></code> to <a id="parse-errors:quirks-mode-2" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-absence-of-digits-in-numeric-character-reference">absence-of-digits-in-numeric-character-reference</dfn>
     </td><td><p>This error occurs if the parser encounters a numeric <a href="#syntax-charref" id="parse-errors:syntax-charref">character reference</a> that doesn't contain any digits (e.g., <code>&amp;#qux;</code>). In this case the parser doesn't resolve the character
     reference.</p>

    </td></tr><tr><td><dfn id="parse-error-cdata-in-html-content">cdata-in-html-content</dfn>
     </td><td><p>This error occurs if the parser encounters a <a href="#syntax-cdata" id="parse-errors:syntax-cdata">CDATA
     section</a> outside of foreign content (SVG or MathML). The parser treats such CDATA
     sections (including leading "<code>[CDATA[</code>" and trailing "<code>]]</code>" strings) as comments.</p>

    </td></tr><tr><td><dfn id="parse-error-character-reference-outside-unicode-range">character-reference-outside-unicode-range</dfn>
     </td><td><p>This error occurs if the parser encounters a numeric <a href="#syntax-charref" id="parse-errors:syntax-charref-2">character reference</a> that references a <a id="parse-errors:code-point-4" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a>
     that is greater than the valid Unicode range. The parser resolves such a character reference to
     a U+FFFD REPLACEMENT CHARACTER.</p>

    </td></tr><tr><td><dfn id="parse-error-control-character-in-input-stream">control-character-in-input-stream</dfn>
     </td><td><p>This error occurs if the <a href="#input-stream" id="parse-errors:input-stream">input stream</a> contains a <a href="https://infra.spec.whatwg.org/#control" id="parse-errors:control" data-x-internal="control">control</a> <a id="parse-errors:code-point-5" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> that is not <a id="parse-errors:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
     whitespace</a> or U+0000 NULL. Such code points are parsed as-is and usually, where parsing
     rules don't apply any additional restrictions, make their way into the DOM.</p>

    </td></tr><tr><td><dfn id="parse-error-control-character-reference">control-character-reference</dfn>
     </td><td><p>This error occurs if the parser encounters a numeric <a href="#syntax-charref" id="parse-errors:syntax-charref-3">character reference</a> that references a <a href="https://infra.spec.whatwg.org/#control" id="parse-errors:control-2" data-x-internal="control">control</a> <a id="parse-errors:code-point-6" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> that is not <a id="parse-errors:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
     whitespace</a> or is a U+000D CARRIAGE RETURN. The parser resolves such character references
     as-is except C1 control references that are replaced according to the <a href="#numeric-character-reference-end-state" id="parse-errors:numeric-character-reference-end-state">numeric character
     reference end state</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-duplicate-attribute">duplicate-attribute</dfn>
     </td><td><p>This error occurs if the parser encounters an <a href="#syntax-attributes" id="parse-errors:syntax-attributes">attribute</a> in a tag that already has an attribute with the
     same name. The parser ignores all such duplicate occurrences of the attribute.

    </p></td></tr><tr><td><dfn id="parse-error-end-tag-with-attributes">end-tag-with-attributes</dfn>
     </td><td><p>This error occurs if the parser encounters an <a href="#syntax-end-tag" id="parse-errors:syntax-end-tag">end
     tag</a> with <a href="#syntax-attributes" id="parse-errors:syntax-attributes-2">attributes</a>. Attributes in end tags are
     ignored and do not make their way into the DOM.</p>

    </td></tr><tr><td><dfn id="parse-error-end-tag-with-trailing-solidus">end-tag-with-trailing-solidus</dfn>
     </td><td><p>This error occurs if the parser encounters an <a href="#syntax-end-tag" id="parse-errors:syntax-end-tag-2">end
     tag</a> that has a U+002F (/) <a id="parse-errors:code-point-7" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> right before the closing U+003E (&gt;)
     code point (e.g., <code>&lt;/div/&gt;</code>). Such a tag is treated as a regular end
     tag.</p>

    </td></tr><tr><td><dfn id="parse-error-eof-before-tag-name">eof-before-tag-name</dfn>
     </td><td><p>This error occurs if the parser encounters the end of the <a href="#input-stream" id="parse-errors:input-stream-2">input stream</a>
     where a tag name is expected. In this case the parser treats the beginning of a <a href="#syntax-start-tag" id="parse-errors:syntax-start-tag">start tag</a> (i.e., <code>&lt;</code>) or an <a href="#syntax-end-tag" id="parse-errors:syntax-end-tag-3">end tag</a> (i.e., <code>&lt;/</code>) as text
     content.</p>

    </td></tr><tr><td><dfn id="parse-error-eof-in-cdata">eof-in-cdata</dfn>
     </td><td><p>This error occurs if the parser encounters the end of the <a href="#input-stream" id="parse-errors:input-stream-3">input stream</a> in a
     <a href="#syntax-cdata" id="parse-errors:syntax-cdata-2">CDATA section</a>. The parser treats such CDATA sections as if
     they are closed immediately before the end of the input stream.</p>

    </td></tr><tr><td><dfn id="parse-error-eof-in-comment">eof-in-comment</dfn>
     </td><td><p>This error occurs if the parser encounters the end of the <a href="#input-stream" id="parse-errors:input-stream-4">input stream</a> in a
     <a href="#syntax-comments" id="parse-errors:syntax-comments-2">comment</a>. The parser treats such comments as if they are
     closed immediately before the end of the input stream.</p>

    </td></tr><tr><td><dfn id="parse-error-eof-in-doctype">eof-in-doctype</dfn>
     </td><td><p>This error occurs if the parser encounters the end of the input stream in a <a href="#syntax-doctype" id="parse-errors:syntax-doctype-3">DOCTYPE</a>. In such a case, if the DOCTYPE is correctly placed as a
     document preamble, the parser sets the <code id="parse-errors:document-3"><a href="#document">Document</a></code> to <a id="parse-errors:quirks-mode-3" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-eof-in-script-html-comment-like-text">eof-in-script-html-comment-like-text</dfn>
     </td><td>
      <p>This error occurs if the parser encounters the end of the <a href="#input-stream" id="parse-errors:input-stream-5">input stream</a> in text
      that resembles an <a href="#syntax-comments" id="parse-errors:syntax-comments-3">HTML comment</a> inside
      <code id="parse-errors:the-script-element"><a href="#the-script-element">script</a></code> element content (e.g., <code>&lt;script&gt;&lt;!-- foo</code>).</p>

      <p class="note">Syntactic structures that resemble HTML comments in <code id="parse-errors:the-script-element-2"><a href="#the-script-element">script</a></code>
      elements are parsed as text content. They can be a part of a scripting language-specific
      syntactic structure or be treated as an HTML-like comment, if the scripting language supports
      them (e.g., parsing rules for HTML-like comments can be found in Annex B of the JavaScript
      specification). The common reason for this error is a violation of the <a href="#restrictions-for-contents-of-script-elements" id="parse-errors:restrictions-for-contents-of-script-elements">restrictions for contents of <code>script</code> elements</a>. <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a></p>

    </td></tr><tr><td><dfn id="parse-error-eof-in-tag">eof-in-tag</dfn>
     </td><td><p>This error occurs if the parser encounters the end of the <a href="#input-stream" id="parse-errors:input-stream-6">input stream</a> in a
     <a href="#syntax-start-tag" id="parse-errors:syntax-start-tag-2">start tag</a> or an <a href="#syntax-end-tag" id="parse-errors:syntax-end-tag-4">end
     tag</a> (e.g., <code>&lt;div id=</code>). Such a tag is ignored.</p>

    </td></tr><tr><td><dfn id="parse-error-incorrectly-closed-comment">incorrectly-closed-comment</dfn>
     </td><td><p>This error occurs if the parser encounters a <a href="#syntax-comments" id="parse-errors:syntax-comments-4">comment</a> that is closed by the "<code>--!&gt;</code>"
     <a id="parse-errors:code-point-8" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> sequence. The parser treats such comments as if they are correctly
     closed by the "<code>--&gt;</code>" code point sequence.</p>

    </td></tr><tr><td><dfn id="parse-error-incorrectly-opened-comment">incorrectly-opened-comment</dfn>
     </td><td>
      <p>This error occurs if the parser encounters the "<code>&lt;!</code>" <a id="parse-errors:code-point-9" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
      point</a> sequence that is not immediately followed by two U+002D (-) code points and that
      is not the start of a <a href="#syntax-doctype" id="parse-errors:syntax-doctype-4">DOCTYPE</a> or a <a href="#syntax-cdata" id="parse-errors:syntax-cdata-3">CDATA section</a>. All content that follows the "<code>&lt;!</code>" code point sequence up to a U+003E (&gt;) code point (if present) or to
      the end of the <a href="#input-stream" id="parse-errors:input-stream-7">input stream</a> is treated as a comment.</p>

      <p class="note">One possible cause of this error is using an XML markup declaration (e.g.,
      <code>&lt;!ELEMENT br EMPTY&gt;</code>) in HTML.</p>

    </td></tr><tr><td><dfn id="parse-error-invalid-character-sequence-after-doctype-name">invalid-character-sequence-after-doctype-name</dfn>
     </td><td><p>This error occurs if the parser encounters any <a id="parse-errors:code-point-10" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> sequence other
     than "<code>PUBLIC</code>" and "<code>SYSTEM</code>" keywords after a <a href="#syntax-doctype" id="parse-errors:syntax-doctype-5">DOCTYPE</a> name. In such a case, the parser ignores any following
     public or system identifiers, and if the DOCTYPE is correctly placed as a document preamble,
     and if the <a href="#parser-cannot-change-the-mode-flag" id="parse-errors:parser-cannot-change-the-mode-flag">parser cannot change the mode flag</a> is false, sets the <code id="parse-errors:document-4"><a href="#document">Document</a></code>
     to <a id="parse-errors:quirks-mode-4" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-invalid-first-character-of-tag-name">invalid-first-character-of-tag-name</dfn>
     </td><td>
      <p>This error occurs if the parser encounters a <a id="parse-errors:code-point-11" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> that is not an
      <a id="parse-errors:ascii-letters" href="https://infra.spec.whatwg.org/#ascii-alpha" data-x-internal="ascii-letters">ASCII alpha</a> where first code point of a <a href="#syntax-start-tag" id="parse-errors:syntax-start-tag-3">start
      tag</a> name or an <a href="#syntax-end-tag" id="parse-errors:syntax-end-tag-5">end tag</a> name is expected. If a
      start tag was expected such code point and a preceding U+003C (&lt;) is treated as text
      content, and all content that follows is treated as markup. Whereas, if an end tag was
      expected, such code point and all content that follows up to a U+003E (&gt;) code point (if
      present) or to the end of the <a href="#input-stream" id="parse-errors:input-stream-8">input stream</a> is treated as a comment.</p>

      <div class="example">
       <p>For example, consider the following markup:</p>

       <pre><code class="html"><c- p="">&lt;</c-><c- f="">42</c-><c- p="">&gt;&lt;/</c-><c- f="">42</c-><c- p="">&gt;</c-></code></pre>

       <p>This will be parsed into:</p>

       <ul class="domTree"><li class="t1"><code id="parse-errors:the-html-element"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="parse-errors:the-head-element"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="parse-errors:the-body-element"><a href="#the-body-element">body</a></code><ul><li class="t3"><code id="parse-errors:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>&lt;42&gt;</span></li><li class="t8"><code id="parse-errors:comment-2"><a data-x-internal="comment-2" href="https://dom.spec.whatwg.org/#interface-comment">#comment</a></code>: <span>42</span></li></ul></li></ul></li></ul>
      </div>

      <p class="note">While the first code point of a tag name is limited to an <a id="parse-errors:ascii-letters-2" href="https://infra.spec.whatwg.org/#ascii-alpha" data-x-internal="ascii-letters">ASCII
      alpha</a>, a wide range of code points (including <a id="parse-errors:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a>) is allowed in
      subsequent positions.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-attribute-value">missing-attribute-value</dfn>
     </td><td><p>This error occurs if the parser encounters a U+003E (&gt;) <a id="parse-errors:code-point-12" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> where an
     <a href="#syntax-attributes" id="parse-errors:syntax-attributes-3">attribute</a> value is expected (e.g., <code>&lt;div id=&gt;</code>). The parser treats the attribute as having an empty value.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-doctype-name">missing-doctype-name</dfn>
     </td><td><p>This error occurs if the parser encounters a <a href="#syntax-doctype" id="parse-errors:syntax-doctype-6">DOCTYPE</a> that is missing a name (e.g., <code>&lt;!DOCTYPE&gt;</code>). In such a case, if the DOCTYPE is correctly placed as a
     document preamble, the parser sets the <code id="parse-errors:document-5"><a href="#document">Document</a></code> to <a id="parse-errors:quirks-mode-5" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-doctype-public-identifier">missing-doctype-public-identifier</dfn>
     </td><td><p>This error occurs if the parser encounters a U+003E (&gt;) <a id="parse-errors:code-point-13" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> where
     start of the <a href="#syntax-doctype" id="parse-errors:syntax-doctype-7">DOCTYPE</a> public identifier is expected (e.g.,
     <code>&lt;!DOCTYPE html PUBLIC &gt;</code>). In such a case, if the DOCTYPE is correctly
     placed as a document preamble, the parser sets the <code id="parse-errors:document-6"><a href="#document">Document</a></code> to <a id="parse-errors:quirks-mode-6" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks
     mode</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-doctype-system-identifier">missing-doctype-system-identifier</dfn>
     </td><td><p>This error occurs if the parser encounters a U+003E (&gt;) <a id="parse-errors:code-point-14" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> where
     start of the <a href="#syntax-doctype" id="parse-errors:syntax-doctype-8">DOCTYPE</a> system identifier is expected (e.g.,
     <code>&lt;!DOCTYPE html SYSTEM &gt;</code>). In such a case, if the DOCTYPE is correctly
     placed as a document preamble, the parser sets the <code id="parse-errors:document-7"><a href="#document">Document</a></code> to <a id="parse-errors:quirks-mode-7" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks
     mode</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-end-tag-name">missing-end-tag-name</dfn>
     </td><td><p>This error occurs if the parser encounters a U+003E (&gt;) <a id="parse-errors:code-point-15" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> where an
     <a href="#syntax-end-tag" id="parse-errors:syntax-end-tag-6">end tag</a> name is expected, i.e., <code>&lt;/&gt;</code>. The parser ignores the whole "<code>&lt;/&gt;</code>" code
     point sequence.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-quote-before-doctype-public-identifier">missing-quote-before-doctype-public-identifier</dfn>
     </td><td><p>This error occurs if the parser encounters the <a href="#syntax-doctype" id="parse-errors:syntax-doctype-9">DOCTYPE</a> public identifier that is not preceded by a quote (e.g.,
     <code>&lt;!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01//EN"&gt;</code>). In such a case,
     the parser ignores the public identifier, and if the DOCTYPE is correctly placed as a document
     preamble, sets the <code id="parse-errors:document-8"><a href="#document">Document</a></code> to <a id="parse-errors:quirks-mode-8" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-quote-before-doctype-system-identifier">missing-quote-before-doctype-system-identifier</dfn>
     </td><td><p>This error occurs if the parser encounters the <a href="#syntax-doctype" id="parse-errors:syntax-doctype-10">DOCTYPE</a> system identifier that is not preceded by a quote (e.g.,
     <code>&lt;!DOCTYPE html SYSTEM
     http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</code>). In such a case, the parser
     ignores the system identifier, and if the DOCTYPE is correctly placed as a document preamble,
     sets the <code id="parse-errors:document-9"><a href="#document">Document</a></code> to <a id="parse-errors:quirks-mode-9" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-semicolon-after-character-reference">missing-semicolon-after-character-reference</dfn>
     </td><td>
      <p>This error occurs if the parser encounters a <a href="#syntax-charref" id="parse-errors:syntax-charref-4">character
      reference</a> that is not terminated by a U+003B (;) <a id="parse-errors:code-point-16" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a>.
      The parser behaves the same as if the character reference is terminated by the U+003B
      (;) code point.</p>

      <p class="note">Most <a href="#named-character-references" id="parse-errors:named-character-references">named character references</a> require a terminating U+003B
      (;) <a id="parse-errors:code-point-17" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a>. Those that don't might get resolved as a longer named <a href="#syntax-charref" id="parse-errors:syntax-charref-5">character reference</a> in certain ambiguous scenarios.</p>

      <p class="example">For example, <code>&amp;notin</code> will be parsed as "<code>¬in</code>", i.e., the same as if the input were <code>&amp;not;in</code>, whereas <code>&amp;notin;</code> will be parsed as
      "<code>∉</code>".</p>

    </td></tr><tr><td><dfn id="parse-error-missing-whitespace-after-doctype-public-keyword">missing-whitespace-after-doctype-public-keyword</dfn>
     </td><td><p>This error occurs if the parser encounters a <a href="#syntax-doctype" id="parse-errors:syntax-doctype-11">DOCTYPE</a> whose "<code>PUBLIC</code>" keyword and public
     identifier are not separated by <a id="parse-errors:space-characters-3" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>. In this case the parser behaves
     as if ASCII whitespace is present.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-whitespace-after-doctype-system-keyword">missing-whitespace-after-doctype-system-keyword</dfn>
     </td><td><p>This error occurs if the parser encounters a <a href="#syntax-doctype" id="parse-errors:syntax-doctype-12">DOCTYPE</a> whose "<code>SYSTEM</code>" keyword and system
     identifier are not separated by <a id="parse-errors:space-characters-4" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>. In this case the parser behaves
     as if ASCII whitespace is present.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-whitespace-before-doctype-name">missing-whitespace-before-doctype-name</dfn>
     </td><td><p>This error occurs if the parser encounters a <a href="#syntax-doctype" id="parse-errors:syntax-doctype-13">DOCTYPE</a> whose "<code>DOCTYPE</code>" keyword and name
     are not separated by <a id="parse-errors:space-characters-5" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>. In this case the parser behaves as if ASCII
     whitespace is present.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-whitespace-between-attributes">missing-whitespace-between-attributes</dfn>
     </td><td><p>This error occurs if the parser encounters <a href="#syntax-attributes" id="parse-errors:syntax-attributes-4">attributes</a> that are not separated by <a id="parse-errors:space-characters-6" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
     whitespace</a> (e.g., <code>&lt;div id="foo"class="bar"&gt;</code>). In this case the
     parser behaves as if ASCII whitespace is present.</p>

    </td></tr><tr><td><dfn id="parse-error-missing-whitespace-between-doctype-public-and-system-identifiers">missing-whitespace-between-doctype-public-and-system-identifiers</dfn>
     </td><td><p>This error occurs if the parser encounters a <a href="#syntax-doctype" id="parse-errors:syntax-doctype-14">DOCTYPE</a> whose public and system identifiers are not separated by
     <a id="parse-errors:space-characters-7" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>. In this case the parser behaves as if ASCII whitespace is
     present.</p>

    </td></tr><tr><td><dfn id="parse-error-nested-comment">nested-comment</dfn>
     </td><td><p>This error occurs if the parser encounters a nested <a href="#syntax-comments" id="parse-errors:syntax-comments-5">comment</a> (e.g., <code>&lt;!-- &lt;!-- nested --&gt;
     --&gt;</code>). Such a comment will be closed by the first occurring "<code>--&gt;</code>"
     <a id="parse-errors:code-point-18" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> sequence and everything that follows will be treated as markup.</p>

    </td></tr><tr><td><dfn id="parse-error-noncharacter-character-reference">noncharacter-character-reference</dfn>
     </td><td><p>This error occurs if the parser encounters a numeric <a href="#syntax-charref" id="parse-errors:syntax-charref-6">character reference</a> that references a <a id="parse-errors:noncharacter" href="https://infra.spec.whatwg.org/#noncharacter" data-x-internal="noncharacter">noncharacter</a>.
     The parser resolves such character references as-is.</p>

    </td></tr><tr><td><dfn id="parse-error-noncharacter-in-input-stream">noncharacter-in-input-stream</dfn>
     </td><td><p>This error occurs if the <a href="#input-stream" id="parse-errors:input-stream-9">input stream</a> contains a <a id="parse-errors:noncharacter-2" href="https://infra.spec.whatwg.org/#noncharacter" data-x-internal="noncharacter">noncharacter</a>.
     Such <a href="https://infra.spec.whatwg.org/#code-point" id="parse-errors:code-point-19" data-x-internal="code-point">code points</a> are parsed as-is and usually, where parsing
     rules don't apply any additional restrictions, make their way into the DOM.</p>

    </td></tr><tr><td><dfn id="parse-error-non-void-html-element-start-tag-with-trailing-solidus">non-void-html-element-start-tag-with-trailing-solidus</dfn>
     </td><td>
      <p>This error occurs if the parser encounters a <a href="#syntax-start-tag" id="parse-errors:syntax-start-tag-4">start
      tag</a> for an element that is not in the list of <a href="#void-elements" id="parse-errors:void-elements">void elements</a> or is not a
      part of foreign content (i.e., not an SVG or MathML element) that has a U+002F (/) <a id="parse-errors:code-point-20" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
      point</a> right before the closing U+003E (&gt;) code point. The parser behaves as if the
      U+002F (/) is not present.</p>

      <div class="example">
       <p>For example, consider the following markup:</p>

       <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-><c- p="">/&gt;&lt;</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;&lt;</c-><c- f="">span</c-><c- p="">&gt;&lt;/</c-><c- f="">span</c-><c- p="">&gt;</c-></code></pre>

       <p>This will be parsed into:</p>

       <ul class="domTree"><li class="t1"><code id="parse-errors:the-html-element-2"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="parse-errors:the-head-element-2"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="parse-errors:the-body-element-2"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="parse-errors:the-div-element"><a href="#the-div-element">div</a></code><ul><li class="t1"><code id="parse-errors:the-span-element"><a href="#the-span-element">span</a></code></li><li class="t1"><code id="parse-errors:the-span-element-2"><a href="#the-span-element">span</a></code></li></ul></li></ul></li></ul></li></ul>
      </div>

      <p class="note">The trailing U+002F (/) in a start tag name can be used only in foreign
      content to specify self-closing tags. (Self-closing tags don't exist in HTML.) It is also
      allowed for void elements, but doesn't have any effect in this case.</p>

    </td></tr><tr><td><dfn id="parse-error-null-character-reference">null-character-reference</dfn>
     </td><td><p>This error occurs if the parser encounters a numeric <a href="#syntax-charref" id="parse-errors:syntax-charref-7">character reference</a> that references a U+0000 NULL <a id="parse-errors:code-point-21" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code
     point</a>. The parser resolves such character references to a U+FFFD REPLACEMENT
     CHARACTER.</p>

    </td></tr><tr><td><dfn id="parse-error-surrogate-character-reference">surrogate-character-reference</dfn>
     </td><td><p>This error occurs if the parser encounters a numeric <a href="#syntax-charref" id="parse-errors:syntax-charref-8">character reference</a> that references a <a id="parse-errors:surrogate" href="https://infra.spec.whatwg.org/#surrogate" data-x-internal="surrogate">surrogate</a>.
     The parser resolves such character references to a U+FFFD REPLACEMENT CHARACTER.</p>

    </td></tr><tr><td><dfn id="parse-error-surrogate-in-input-stream">surrogate-in-input-stream</dfn>
     </td><td>
      <p>This error occurs if the <a href="#input-stream" id="parse-errors:input-stream-10">input stream</a> contains a <a href="https://infra.spec.whatwg.org/#surrogate" id="parse-errors:surrogate-2" data-x-internal="surrogate">surrogate</a>. Such <a href="https://infra.spec.whatwg.org/#code-point" id="parse-errors:code-point-22" data-x-internal="code-point">code points</a> are
      parsed as-is and usually, where parsing rules don't apply any additional restrictions, make
      their way into the DOM.</p>

      <p class="note">Surrogates can only find their way into the input stream via script APIs such
      as <code id="parse-errors:dom-document-write"><a href="#dom-document-write">document.write()</a></code>.</p>

    </td></tr><tr><td><dfn id="parse-error-unexpected-character-after-doctype-system-identifier">unexpected-character-after-doctype-system-identifier</dfn>
     </td><td><p>This error occurs if the parser encounters any <a href="https://infra.spec.whatwg.org/#code-point" id="parse-errors:code-point-23" data-x-internal="code-point">code
     points</a> other than <a id="parse-errors:space-characters-8" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> or closing U+003E (&gt;) after the <a href="#syntax-doctype" id="parse-errors:syntax-doctype-15">DOCTYPE</a> system identifier. The parser ignores these code
     points.</p>

    </td></tr><tr><td><dfn id="parse-error-unexpected-character-in-attribute-name">unexpected-character-in-attribute-name</dfn>
     </td><td>
      <p>This error occurs if the parser encounters a U+0022 ("), U+0027 ('), or U+003C (&lt;)
      <a id="parse-errors:code-point-24" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in an <a href="#syntax-attribute-name" id="parse-errors:syntax-attribute-name">attribute name</a>. The
      parser includes such code points in the attribute name.</p>

      <p class="note">Code points that trigger this error are usually a part of another syntactic
      construct and can be a sign of a typo around the attribute name.</p>

      <div class="example">
       <p>For example, consider the following markup:</p>

       <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">foo</c->&lt;<c- e="">div</c-><c- p="">&gt;</c-></code></pre>

       <p>Due to a forgotten U+003E (&gt;) code point after <code>foo</code> the parser
       treats this markup as a single <code id="parse-errors:the-div-element-2"><a href="#the-div-element">div</a></code> element with a "<code>foo&lt;div</code>" attribute.</p>

       <p>As another example of this error, consider the following markup:</p>

       <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c->'<c- e="">bar</c->'<c- p="">&gt;</c-></code></pre>

       <p>Due to a forgotten U+003D (=) code point between an attribute name and value the parser
       treats this markup as a <code id="parse-errors:the-div-element-3"><a href="#the-div-element">div</a></code> element with the attribute "<code>id'bar'</code>" that has an empty value.</p>
     </div>

    </td></tr><tr><td><dfn id="parse-error-unexpected-character-in-unquoted-attribute-value">unexpected-character-in-unquoted-attribute-value</dfn>
     </td><td>
      <p>This error occurs if the parser encounters a U+0022 ("), U+0027 ('), U+003C (&lt;), U+003D
      (=), or U+0060 (`) <a id="parse-errors:code-point-25" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in an unquoted <a href="#syntax-attribute-value" id="parse-errors:syntax-attribute-value">attribute value</a>. The parser includes such code points
      in the attribute value.</p>

      <p class="note">Code points that trigger this error are usually a part of another syntactic
      construct and can be a sign of a typo around the attribute value.</p>

      <p class="note">U+0060 (`) is in the list of code points that trigger this error because
      certain legacy user agents treat it as a quote.</p>

      <div class="example">
       <p>For example, consider the following markup:</p>

       <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">foo</c-><c- o="">=</c-><c- s="">b'ar'</c-><c- p="">&gt;</c-></code></pre>

       <p>Due to a misplaced U+0027 (') code point the parser sets the value of the "<code>foo</code>" attribute to "<code>b'ar'</code>".</p>
     </div>

    </td></tr><tr><td><dfn id="parse-error-unexpected-equals-sign-before-attribute-name">unexpected-equals-sign-before-attribute-name</dfn>
     </td><td>
      <p>This error occurs if the parser encounters a U+003D (=) <a id="parse-errors:code-point-26" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> before an
      attribute name. In this case the parser treats U+003D (=) as the first code point of the
      attribute name.</p>

      <p class="note">The common reason for this error is a forgotten attribute name.</p>

      <div class="example">
       <p>For example, consider the following markup:</p>

       <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">foo</c-><c- o="">=</c-><c- s="">"bar"</c-> ="<c- e="">baz</c->"<c- p="">&gt;</c-></code></pre>

       <p>Due to a forgotten attribute name the parser treats this markup as a <code id="parse-errors:the-div-element-4"><a href="#the-div-element">div</a></code>
       element with two attributes: a "<code>foo</code>" attribute with a "<code>bar</code>" value and a "<code>="baz"</code>" attribute with an empty
       value.</p>
      </div>

    </td></tr><tr><td><dfn id="parse-error-unexpected-null-character">unexpected-null-character</dfn>
     </td><td><p>This error occurs if the parser encounters a U+0000 NULL <a id="parse-errors:code-point-27" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in the
     <a href="#input-stream" id="parse-errors:input-stream-11">input stream</a> in certain positions. In general, such code points are either
     ignored or, for security reasons, replaced with a U+FFFD REPLACEMENT CHARACTER.</p>

    </td></tr><tr><td><dfn id="parse-error-unexpected-question-mark-instead-of-tag-name">unexpected-question-mark-instead-of-tag-name</dfn>
     </td><td>
      <p>This error occurs if the parser encounters a U+003F (?) <a id="parse-errors:code-point-28" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> where first
      code point of a <a href="#syntax-start-tag" id="parse-errors:syntax-start-tag-5">start tag</a> name is expected. The U+003F
      (?) and all content that follows up to a U+003E (&gt;) code point (if present) or to the end of
      the <a href="#input-stream" id="parse-errors:input-stream-12">input stream</a> is treated as a comment.</p>

      <div class="example">
       <p>For example, consider the following markup:</p>

       <pre><code class="html"><c- cp="">&lt;?xml-stylesheet type="text/css" href="style.css"?&gt;</c-></code></pre>

       <p>This will be parsed into:</p>

       <ul class="domTree"><li class="t8"><code id="parse-errors:comment-2-2"><a data-x-internal="comment-2" href="https://dom.spec.whatwg.org/#interface-comment">#comment</a></code>: <span>?xml-stylesheet type="text/css" href="style.css"?</span></li><li class="t1"><code id="parse-errors:the-html-element-3"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="parse-errors:the-head-element-3"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="parse-errors:the-body-element-3"><a href="#the-body-element">body</a></code></li></ul></li></ul>
      </div>

      <p class="note">The common reason for this error is an XML processing instruction (e.g., <code>&lt;?xml-stylesheet type="text/css" href="style.css"?&gt;</code>) or an XML declaration
      (e.g., <code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</code>) being used in
      HTML.</p>

    </td></tr><tr><td><dfn id="parse-error-unexpected-solidus-in-tag">unexpected-solidus-in-tag</dfn>
     </td><td><p>This error occurs if the parser encounters a U+002F (/) <a id="parse-errors:code-point-29" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> that is
     not a part of a quoted <a href="#syntax-attributes" id="parse-errors:syntax-attributes-5">attribute</a> value and not
     immediately followed by a U+003E (&gt;) code point in a tag (e.g., <code>&lt;div /
     id="foo"&gt;</code>). In this case the parser behaves as if it encountered <a id="parse-errors:space-characters-9" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII
     whitespace</a>.</p>

    </td></tr><tr><td><dfn id="parse-error-unknown-named-character-reference">unknown-named-character-reference</dfn>
     </td><td><p>This error occurs if the parser encounters an <a href="#syntax-ambiguous-ampersand" id="parse-errors:syntax-ambiguous-ampersand">ambiguous ampersand</a>. In this case the parser doesn't
     resolve the <a href="#syntax-charref" id="parse-errors:syntax-charref-9">character reference</a>.</p>

  </td></tr></tbody></table>

  


  

  <h4 id="the-input-byte-stream"><span class="secno">13.2.3</span> The <dfn>input byte stream</dfn><a href="#the-input-byte-stream" class="self-link"></a></h4>

  <p>The stream of code points that comprises the input to the tokenization stage will be initially
  seen by the user agent as a stream of bytes (typically coming over the network or from the local
  file system). The bytes encode the actual characters according to a particular <i>character
  encoding</i>, which the user agent uses to decode the bytes into characters.</p>

  <p class="note">For XML documents, the algorithm user agents are required to use to determine the
  character encoding is given by <cite>XML</cite>. This section does not apply to XML documents.
  <a href="#refsXML">[XML]</a></p>

  <p>Usually, the <a href="#encoding-sniffing-algorithm" id="the-input-byte-stream:encoding-sniffing-algorithm">encoding sniffing algorithm</a> defined below is used to determine the
  character encoding.</p>

  <div data-algorithm="">
  <p>Given a character encoding, the bytes in the <a href="#the-input-byte-stream" id="the-input-byte-stream:the-input-byte-stream">input byte stream</a> must be converted
  to characters for the tokenizer's <a href="#input-stream" id="the-input-byte-stream:input-stream">input stream</a>, by passing the <a href="#the-input-byte-stream" id="the-input-byte-stream:the-input-byte-stream-2">input byte
  stream</a> and character encoding to <a id="the-input-byte-stream:decode" href="https://encoding.spec.whatwg.org/#decode" data-x-internal="decode">decode</a>.</p>
  </div>

  <p class="note">A leading Byte Order Mark (BOM) causes the character encoding argument to be
  ignored and will itself be skipped.</p>

  <p class="note">Bytes or sequences of bytes in the original byte stream that did not conform to
  the Encoding standard (e.g. invalid UTF-8 byte sequences in a UTF-8 input byte stream) are errors
  that conformance checkers are expected to report. <a href="#refsENCODING">[ENCODING]</a></p>

  <p class="warning">The decoder algorithms describe how to handle invalid input; for security
  reasons, it is imperative that those rules be followed precisely. Differences in how invalid byte
  sequences are handled can result in, amongst other problems, script injection vulnerabilities
  ("XSS").</p>

  <p>When the HTML parser is decoding an input byte stream, it uses a character encoding and a <dfn id="concept-encoding-confidence">confidence</dfn>. The confidence is either <i>tentative</i>,
  <i>certain</i>, or <i>irrelevant</i>. The encoding used, and whether the confidence in that
  encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used
  during the parsing</a> to determine whether to <a href="#change-the-encoding" id="the-input-byte-stream:change-the-encoding">change the encoding</a>. If no encoding is
  necessary, e.g. because the parser is operating on a Unicode stream and doesn't have to use a
  character encoding at all, then the <a href="#concept-encoding-confidence" id="the-input-byte-stream:concept-encoding-confidence">confidence</a> is
  <i>irrelevant</i>.</p>

  <p class="note">Some algorithms feed the parser by directly adding characters to the <a href="#input-stream" id="the-input-byte-stream:input-stream-2">input
  stream</a> rather than adding bytes to the <a href="#the-input-byte-stream" id="the-input-byte-stream:the-input-byte-stream-3">input byte stream</a>.</p>



  <h5 id="parsing-with-a-known-character-encoding"><span class="secno">13.2.3.1</span> Parsing with a known character encoding<a href="#parsing-with-a-known-character-encoding" class="self-link"></a></h5>

  <p>When the HTML parser is to operate on an input byte stream that has <dfn id="a-known-definite-encoding" data-export="">a known
  definite encoding</dfn>, then the character encoding is that encoding and the <a href="#concept-encoding-confidence" id="parsing-with-a-known-character-encoding:concept-encoding-confidence">confidence</a> is <i>certain</i>.</p>


  <h5 id="determining-the-character-encoding"><span class="secno">13.2.3.2</span> Determining the character encoding<a href="#determining-the-character-encoding" class="self-link"></a></h5>

  <p>In some cases, it might be impractical to unambiguously determine the encoding before parsing
  the document. Because of this, this specification provides for a two-pass mechanism with an
  optional pre-scan. Implementations are allowed, as described below, to apply a simplified parsing
  algorithm to whatever bytes they have available before beginning to parse the document. Then, the
  real parser is started, using a tentative encoding derived from this pre-parse and other
  out-of-band metadata. If, while the document is being loaded, the user agent discovers a character
  encoding declaration that conflicts with this information, then the parser can get reinvoked to
  perform a parse of the document with the real encoding.</p>

  <div data-algorithm="">
  <p id="documentEncoding">User agents must use the following algorithm, called the <dfn id="encoding-sniffing-algorithm">encoding
  sniffing algorithm</dfn>, to determine the character encoding to use when decoding a document in
  the first pass. This algorithm takes as input any out-of-band metadata available to the user agent
  (e.g. the <a href="#content-type" id="determining-the-character-encoding:content-type">Content-Type metadata</a> of the document) and all the
  bytes available so far, and returns a character encoding and a <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence">confidence</a> that is either <i>tentative</i> or
  <i>certain</i>.</p>

  <ol><li>
    <p>If the result of <a href="https://encoding.spec.whatwg.org/#bom-sniff" id="determining-the-character-encoding:bom-sniff" data-x-internal="bom-sniff">BOM sniffing</a> is an encoding, return that
    encoding with <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence-2">confidence</a> <i>certain</i>.</p>

    <p class="note">Although the <a id="determining-the-character-encoding:decode" href="https://encoding.spec.whatwg.org/#decode" data-x-internal="decode">decode</a> algorithm will itself change the encoding to
    use based on the presence of a byte order mark, this algorithm sniffs the BOM as well in order
    to set the correct <a id="determining-the-character-encoding:document's-character-encoding" href="https://dom.spec.whatwg.org/#concept-document-encoding" data-x-internal="document's-character-encoding">document's character encoding</a> and <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence-3">confidence</a>.</p>
   </li><li>
    <p>If the user has explicitly instructed the user agent to override the document's character
    encoding with a specific encoding, optionally return that encoding with the <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence-4">confidence</a> <i>certain</i>.</p>

    <p class="note">Typically, user agents remember such user requests across sessions, and in some
    cases apply them to documents in <code id="determining-the-character-encoding:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>s as well.</p>
   </li><li>
    <p>The user agent may wait for more bytes of the resource to be available, either in this step
    or at any later step in this algorithm. For instance, a user agent might wait 500ms or 1024
    bytes, whichever came first. In general preparsing the source to find the encoding improves
    performance, as it reduces the need to throw away the data structures used when parsing upon
    finding the encoding information. However, if the user agent delays too long to obtain data to
    determine the encoding, then the cost of the delay could outweigh any performance improvements
    from the preparse.</p>

    <p class="note">The authoring conformance requirements for character encoding declarations limit
    them to only appearing <a href="#charset1024">in the first 1024 bytes</a>. User agents are
    therefore encouraged to use the prescan algorithm below (as invoked by these steps) on the first
    1024 bytes, but not to stall beyond that.</p>
   </li><li><p>If the transport layer specifies a character encoding, and it is supported, return that
   encoding with the <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence-5">confidence</a> <i>certain</i>.</p></li><li>
    <p>Optionally, <a href="#prescan-a-byte-stream-to-determine-its-encoding" id="determining-the-character-encoding:prescan-a-byte-stream-to-determine-its-encoding">prescan the byte
    stream to determine its encoding</a>, with the <i><a href="#prescan-end-condition" id="determining-the-character-encoding:prescan-end-condition">end
    condition</a></i> being when the user agent decides that scanning further bytes would not be
    efficient. User agents are encouraged to only prescan the first 1024 bytes. User agents may
    decide that scanning <em>any</em> bytes is not efficient, in which case these substeps are
    entirely skipped.</p>

    <p>The aforementioned algorithm returns either a character encoding or failure. If it returns a
    character encoding, then return the same encoding, with <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence-6">confidence</a> <i>tentative</i>.</p>
   </li><li>
    <p>If the <a href="#html-parser" id="determining-the-character-encoding:html-parser">HTML parser</a> for which this algorithm is being run is associated with a
    <code id="determining-the-character-encoding:document"><a href="#document">Document</a></code> <var>d</var> whose <a href="#doc-container-document" id="determining-the-character-encoding:doc-container-document">container
    document</a> is non-null, then:</p>

    <ol><li><p>Let <var>parentDocument</var> be <var>d</var>'s <a href="#doc-container-document" id="determining-the-character-encoding:doc-container-document-2">container document</a>.</p></li><li><p>If <var>parentDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="determining-the-character-encoding:concept-document-origin" data-x-internal="concept-document-origin">origin</a> is
     <a href="#same-origin" id="determining-the-character-encoding:same-origin">same origin</a> with <var>d</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-origin" id="determining-the-character-encoding:concept-document-origin-2" data-x-internal="concept-document-origin">origin</a> and <var>parentDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="determining-the-character-encoding:document's-character-encoding-2" data-x-internal="document's-character-encoding">character encoding</a> is not
     <a id="determining-the-character-encoding:utf-16-encoding" href="https://encoding.spec.whatwg.org/#utf-16be-le" data-x-internal="utf-16-encoding">UTF-16BE/LE</a>, then return <var>parentDocument</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-encoding" id="determining-the-character-encoding:document's-character-encoding-3" data-x-internal="document's-character-encoding">character encoding</a>, with the <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence-7">confidence</a> <i>tentative</i>.</p></li></ol>
   </li><li><p>Otherwise, if the user agent has information on the likely encoding for this page, e.g.
   based on the encoding of the page when it was last visited, then return that encoding, with the
   <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence-8">confidence</a> <i>tentative</i>.</p></li><li>
    <p>The user agent may attempt to autodetect the character encoding from applying frequency
    analysis or other algorithms to the data stream. Such algorithms may use information about the
    resource other than the resource's contents, including the address of the resource. If
    autodetection succeeds in determining a character encoding, and that encoding is a supported
    encoding, then return that encoding, with the <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence-9">confidence</a> <i>tentative</i>.
    <a href="#refsUNIVCHARDET">[UNIVCHARDET]</a></p>

    <p class="note">User agents are generally discouraged from attempting to autodetect encodings
    for resources obtained over the network, since doing so involves inherently non-interoperable
    heuristics. Attempting to detect encodings based on an HTML document's preamble is especially
    tricky since HTML markup typically uses only ASCII characters, and HTML documents tend to begin
    with a lot of markup rather than with text content.</p>

    <p class="note">The UTF-8 encoding has a highly detectable bit pattern. Files from the local
    file system that contain bytes with values greater than 0x7F which match the UTF-8 pattern are
    very likely to be UTF-8, while documents with byte sequences that do not match it are very
    likely not. When a user agent can examine the whole file, rather than just the preamble,
    detecting for UTF-8 specifically can be especially effective. <a href="#refsPPUTF8">[PPUTF8]</a>
    <a href="#refsUTF8DET">[UTF8DET]</a></p>
   </li><li>
    <p>Otherwise, return an <a id="determining-the-character-encoding:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> or user-specified default character
    encoding, with the <a href="#concept-encoding-confidence" id="determining-the-character-encoding:concept-encoding-confidence-10">confidence</a>
    <i>tentative</i>.</p>

    <p>In controlled environments or in environments where the encoding of documents can be
    prescribed (for example, for user agents intended for dedicated use in new networks), the
    comprehensive <code>UTF-8</code> encoding is suggested.</p>

    <p>In other environments, the default encoding is typically dependent on the user's locale (an
    approximation of the languages, and thus often encodings, of the pages that the user is likely
    to frequent). The following table gives suggested defaults based on the user's locale, for
    compatibility with legacy content. Locales are identified by BCP 47 language tags.
    <a href="#refsBCP47">[BCP47]</a> <a href="#refsENCODING">[ENCODING]</a></p>

    

    <table><thead><tr><th colspan="2">Locale language
       </th><th>Suggested default encoding
     </th></tr></thead><tbody><tr><td>ar
       </td><td>Arabic
       </td><td><a id="determining-the-character-encoding:windows-1256" href="https://encoding.spec.whatwg.org/#windows-1256" data-x-internal="windows-1256">windows-1256</a> 

      

      
      
      </td></tr><tr><td>az
       </td><td>Azeri
       </td><td><a id="determining-the-character-encoding:windows-1254" href="https://encoding.spec.whatwg.org/#windows-1254" data-x-internal="windows-1254">windows-1254</a>

      

      
      
      </td></tr><tr><td>ba
       </td><td>Bashkir
       </td><td><a id="determining-the-character-encoding:windows-1251" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      
      
      </td></tr><tr><td>be
       </td><td>Belarusian
       </td><td><a id="determining-the-character-encoding:windows-1251-2" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      </td></tr><tr><td>bg
       </td><td>Bulgarian
       </td><td><a id="determining-the-character-encoding:windows-1251-3" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      

      

      

      

      

      </td></tr><tr><td>cs
       </td><td>Czech
       </td><td><a id="determining-the-character-encoding:windows-1250" href="https://encoding.spec.whatwg.org/#windows-1250" data-x-internal="windows-1250">windows-1250</a> 

      

      

      

      
      
      
      </td></tr><tr><td>el
       </td><td>Greek
       </td><td><a id="determining-the-character-encoding:iso-8859-7" href="https://encoding.spec.whatwg.org/#iso-8859-7" data-x-internal="iso-8859-7">ISO-8859-7</a> 

      

      

      </td></tr><tr><td>et
       </td><td>Estonian
       </td><td><a id="determining-the-character-encoding:windows-1257" href="https://encoding.spec.whatwg.org/#windows-1257" data-x-internal="windows-1257">windows-1257</a> 

      

      </td></tr><tr><td>fa
       </td><td>Persian
       </td><td><a id="determining-the-character-encoding:windows-1256-2" href="https://encoding.spec.whatwg.org/#windows-1256" data-x-internal="windows-1256">windows-1256</a> 

      

      

      

      

      

      

      

      

      

      

      </td></tr><tr><td>he
       </td><td>Hebrew
       </td><td><a id="determining-the-character-encoding:windows-1255" href="https://encoding.spec.whatwg.org/#windows-1255" data-x-internal="windows-1255">windows-1255</a> 

      

      </td></tr><tr><td>hr
       </td><td>Croatian
       </td><td><a id="determining-the-character-encoding:windows-1250-2" href="https://encoding.spec.whatwg.org/#windows-1250" data-x-internal="windows-1250">windows-1250</a> 

      </td></tr><tr><td>hu
       </td><td>Hungarian
       </td><td><a id="determining-the-character-encoding:iso-8859-2" href="https://encoding.spec.whatwg.org/#iso-8859-2" data-x-internal="iso-8859-2">ISO-8859-2</a> 

      

      

      

      

      

      

      </td></tr><tr><td>ja
       </td><td>Japanese
       </td><td><a id="determining-the-character-encoding:shift_jis" href="https://encoding.spec.whatwg.org/#shift_jis" data-x-internal="shift_jis">Shift_JIS</a> 

      
      
      </td></tr><tr><td>kk
       </td><td>Kazakh
       </td><td><a id="determining-the-character-encoding:windows-1251-4" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      

      </td></tr><tr><td>ko
       </td><td>Korean
       </td><td><a id="determining-the-character-encoding:euc-kr" href="https://encoding.spec.whatwg.org/#euc-kr" data-x-internal="euc-kr">EUC-KR</a> 

      </td></tr><tr><td>ku
       </td><td>Kurdish
       </td><td><a id="determining-the-character-encoding:windows-1254-2" href="https://encoding.spec.whatwg.org/#windows-1254" data-x-internal="windows-1254">windows-1254</a> 

      
      
      </td></tr><tr><td>ky
       </td><td>Kyrgyz
       </td><td><a id="determining-the-character-encoding:windows-1251-5" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      </td></tr><tr><td>lt
       </td><td>Lithuanian
       </td><td><a id="determining-the-character-encoding:windows-1257-2" href="https://encoding.spec.whatwg.org/#windows-1257" data-x-internal="windows-1257">windows-1257</a> 

      </td></tr><tr><td>lv
       </td><td>Latvian
       </td><td><a id="determining-the-character-encoding:windows-1257-3" href="https://encoding.spec.whatwg.org/#windows-1257" data-x-internal="windows-1257">windows-1257</a> 

      
      
      </td></tr><tr><td>mk
       </td><td>Macedonian
       </td><td><a id="determining-the-character-encoding:windows-1251-6" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      

      

      

      

      

      

      

      

      

      

      </td></tr><tr><td>pl
       </td><td>Polish
       </td><td><a id="determining-the-character-encoding:iso-8859-2-2" href="https://encoding.spec.whatwg.org/#iso-8859-2" data-x-internal="iso-8859-2">ISO-8859-2</a> 

      

      

      

      

      

      

      

      

      

      

      </td></tr><tr><td>ru
       </td><td>Russian
       </td><td><a id="determining-the-character-encoding:windows-1251-7" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      
      
      </td></tr><tr><td>sah
       </td><td>Yakut
       </td><td><a id="determining-the-character-encoding:windows-1251-8" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      

      

      </td></tr><tr><td>sk
       </td><td>Slovak
       </td><td><a id="determining-the-character-encoding:windows-1250-3" href="https://encoding.spec.whatwg.org/#windows-1250" data-x-internal="windows-1250">windows-1250</a> 

      </td></tr><tr><td>sl
       </td><td>Slovenian
       </td><td><a id="determining-the-character-encoding:iso-8859-2-3" href="https://encoding.spec.whatwg.org/#iso-8859-2" data-x-internal="iso-8859-2">ISO-8859-2</a> 

      

      

      

      

      

      

      

      

      </td></tr><tr><td>sr
       </td><td>Serbian
       </td><td><a id="determining-the-character-encoding:windows-1251-9" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      

      

      

      

      

      
      
      </td></tr><tr><td>tg
       </td><td>Tajik
       </td><td><a id="determining-the-character-encoding:windows-1251-10" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      </td></tr><tr><td>th
       </td><td>Thai
       </td><td><a id="determining-the-character-encoding:windows-874" href="https://encoding.spec.whatwg.org/#windows-874" data-x-internal="windows-874">windows-874</a> 

      

      

      </td></tr><tr><td>tr
       </td><td>Turkish
       </td><td><a id="determining-the-character-encoding:windows-1254-3" href="https://encoding.spec.whatwg.org/#windows-1254" data-x-internal="windows-1254">windows-1254</a> 

      
      
      </td></tr><tr><td>tt
       </td><td>Tatar
       </td><td><a id="determining-the-character-encoding:windows-1251-11" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      

      </td></tr><tr><td>uk
       </td><td>Ukrainian
       </td><td><a id="determining-the-character-encoding:windows-1251-12" href="https://encoding.spec.whatwg.org/#windows-1251" data-x-internal="windows-1251">windows-1251</a> 

      

      

      

      </td></tr><tr><td>vi
       </td><td>Vietnamese
       </td><td><a id="determining-the-character-encoding:windows-1258" href="https://encoding.spec.whatwg.org/#windows-1258" data-x-internal="windows-1258">windows-1258</a> 

      

      

      

      

      

      </td></tr><tr><td>zh-Hans, zh-CN, zh-SG
       </td><td>Chinese, Simplified
       </td><td><a id="determining-the-character-encoding:gbk" href="https://encoding.spec.whatwg.org/#gbk" data-x-internal="gbk">GBK</a> 

      </td></tr><tr><td>zh-Hant, zh-HK, zh-MO, zh-TW
       </td><td>Chinese, Traditional
       </td><td><a id="determining-the-character-encoding:big5" href="https://encoding.spec.whatwg.org/#big5" data-x-internal="big5">Big5</a> 

      

      </td></tr><tr><td colspan="2">All other locales
       </td><td><a id="determining-the-character-encoding:windows-1252" href="https://encoding.spec.whatwg.org/#windows-1252" data-x-internal="windows-1252">windows-1252</a>

    </td></tr></tbody></table>

    <p class="tablenote"><small>The contents of this table are derived from the intersection of
    Windows, Chrome, and Firefox defaults.</small></p>
   </li></ol>
  </div>

  <p>The <a id="determining-the-character-encoding:document's-character-encoding-4" href="https://dom.spec.whatwg.org/#concept-document-encoding" data-x-internal="document's-character-encoding">document's character encoding</a> must immediately be set to the value returned
  from this algorithm, at the same time as the user agent uses the returned value to select the
  decoder to use for the input byte stream.</p>

  <hr>

  <div data-algorithm="">
  <p>When an algorithm requires a user agent to <dfn id="prescan-a-byte-stream-to-determine-its-encoding" data-export="">prescan a byte stream to determine its
  encoding</dfn>, given some defined <dfn data-dfn-for="prescan a byte
  stream to determine its encoding" id="prescan-end-condition" data-export=""><var>end condition</var></dfn>, then it must run the following
  steps. If at any point during these steps (including during instances of the <a href="#concept-get-attributes-when-sniffing" id="determining-the-character-encoding:concept-get-attributes-when-sniffing">get an attribute</a> algorithm invoked by this
  one) the user agent either runs out of bytes (meaning the <var>position</var> pointer created in
  the first step below goes beyond the end of the byte stream obtained so far) or reaches its
  <var>end condition</var>, then abort the <a href="#prescan-a-byte-stream-to-determine-its-encoding" id="determining-the-character-encoding:prescan-a-byte-stream-to-determine-its-encoding-2">prescan a byte stream to determine its
  encoding</a> algorithm and return the result <a href="#concept-get-xml-encoding-when-sniffing" id="determining-the-character-encoding:concept-get-xml-encoding-when-sniffing">get an XML encoding</a> applied to the same
  bytes that the <a href="#prescan-a-byte-stream-to-determine-its-encoding" id="determining-the-character-encoding:prescan-a-byte-stream-to-determine-its-encoding-3">prescan a byte stream to determine its encoding</a> algorithm was applied
  to. Otherwise, these steps will return a character encoding.</p>

  <ol><li><p>Let <var>position</var> be a pointer to a byte in the input byte stream, initially
   pointing at the first byte.</p></li><li>
    <p>Prescan for UTF-16 XML declarations: If <var>position</var> points to:</p>

    <dl class="switch"><dt>A sequence of bytes starting with: 0x3C, 0x0, 0x3F, 0x0, 0x78, 0x0 (case-sensitive UTF-16
     little-endian '&lt;?x')</dt><dd><p>Return <a id="determining-the-character-encoding:utf-16le" href="https://encoding.spec.whatwg.org/#utf-16le" data-x-internal="utf-16le">UTF-16LE</a>.</p></dd><dt>A sequence of bytes starting with: 0x0, 0x3C, 0x0, 0x3F, 0x0, 0x78 (case-sensitive UTF-16
     big-endian '&lt;?x')</dt><dd><p>Return <a id="determining-the-character-encoding:utf-16be" href="https://encoding.spec.whatwg.org/#utf-16be" data-x-internal="utf-16be">UTF-16BE</a>.</p></dd></dl>

    <p class="note">For historical reasons, the prefix is two bytes longer than in <a href="https://www.w3.org/TR/REC-xml/#sec-guessing">Appendix F</a> of <cite>XML</cite> and the
    encoding name is not checked.</p>
   </li><li>
    <p><i>Loop</i>: If <var>position</var> points to:</p>

    <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (`<code>&lt;!--</code>`)</dt><dd>
      <p>Advance the <var>position</var> pointer so that it points at the first 0x3E byte
      which is preceded by two 0x2D bytes (i.e. at the end of an ASCII '--&gt;' sequence) and comes
      after the 0x3C byte that was found. (The two 0x2D bytes can be the same as those in the
      '&lt;!--' sequence.)</p>
     </dd><dt>A sequence of bytes starting with: 0x3C, 0x4D or 0x6D, 0x45 or 0x65, 0x54 or 0x74, 0x41 or 0x61, and one of 0x09, 0x0A, 0x0C, 0x0D, 0x20, 0x2F (case-insensitive ASCII '&lt;meta' followed by a space or slash)</dt><dd>
      <ol><li><p>Advance the <var>position</var> pointer so that it points at the next 0x09,
       0x0A, 0x0C, 0x0D, 0x20, or 0x2F byte (the one in sequence of characters matched
       above).</p></li><li><p>Let <var>attribute list</var> be an empty list of strings.</p></li><li><p>Let <var>got pragma</var> be false.</p></li><li><p>Let <var>need pragma</var> be null.</p></li><li><p>Let <var>charset</var> be the null value (which, for the purposes of this
       algorithm, is distinct from an unrecognized encoding or the empty string).</p></li><li><p><i>Attributes</i>: <a href="#concept-get-attributes-when-sniffing" id="determining-the-character-encoding:concept-get-attributes-when-sniffing-2">Get an
       attribute</a> and its value. If no attribute was sniffed, then jump to the
       <i>processing</i> step below.</p></li><li><p>If the attribute's name is already in <var>attribute list</var>, then return
       to the step labeled <i>attributes</i>.</p>

       </li><li><p>Add the attribute's name to <var>attribute list</var>.</p>

       </li><li>
        <p>Run the appropriate step from the following list, if one applies:</p>

        <dl class="switch"><dt>If the attribute's name is "<code>http-equiv</code>"</dt><dd><p>If the attribute's value is "<code>content-type</code>", then set <var>got pragma</var> to true.</p></dd><dt>If the attribute's name is "<code>content</code>"</dt><dd><p>Apply the <a href="#algorithm-for-extracting-a-character-encoding-from-a-meta-element" id="determining-the-character-encoding:algorithm-for-extracting-a-character-encoding-from-a-meta-element">algorithm for extracting a character encoding from a
         <code>meta</code> element</a>, giving the attribute's value as the string to parse. If a
         character encoding is returned, and if <var>charset</var> is still set to null,
         let <var>charset</var> be the encoding returned, and set <var>need
         pragma</var> to true.</p></dd><dt>If the attribute's name is "<code>charset</code>"</dt><dd><p>Let <var>charset</var> be the result of <a id="determining-the-character-encoding:getting-an-encoding" href="https://encoding.spec.whatwg.org/#concept-encoding-get" data-x-internal="getting-an-encoding">getting an encoding</a>
         from the attribute's value, and set <var>need pragma</var> to false.</p></dd></dl>
       </li><li><p>Return to the step labeled <i>attributes</i>.</p></li><li><p><i>Processing</i>: If <var>need pragma</var> is null, then jump to the step
       below labeled <i>next byte</i>.</p></li><li><p>If <var>need pragma</var> is true but <var>got pragma</var> is
       false, then jump to the step below labeled <i>next byte</i>.</p></li><li><p>If <var>charset</var> is failure, then jump to the step below labeled <i>next
       byte</i>.</p></li><li><p>If <var>charset</var> is <a id="determining-the-character-encoding:utf-16-encoding-2" href="https://encoding.spec.whatwg.org/#utf-16be-le" data-x-internal="utf-16-encoding">UTF-16BE/LE</a>, then set <var>charset</var> to
       <a id="determining-the-character-encoding:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>.

       </p></li><li><p>If <var>charset</var> is <a id="determining-the-character-encoding:x-user-defined" href="https://encoding.spec.whatwg.org/#x-user-defined" data-x-internal="x-user-defined">x-user-defined</a>, then set <var>charset</var> to
       <a id="determining-the-character-encoding:windows-1252-2" href="https://encoding.spec.whatwg.org/#windows-1252" data-x-internal="windows-1252">windows-1252</a>.</p></li><li><p>Return <var>charset</var>.</p></li></ol>
     </dd><dt>A sequence of bytes starting with a 0x3C byte (&lt;), optionally a 0x2F byte (/), and
     finally a byte in the range 0x41-0x5A or 0x61-0x7A (A-Z or a-z)</dt><dd>
      <ol><li><p>Advance the <var>position</var> pointer so that it points at the next 0x09 (HT),
       0x0A (LF), 0x0C (FF), 0x0D (CR), 0x20 (SP), or 0x3E (&gt;) byte.</p></li><li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" id="determining-the-character-encoding:concept-get-attributes-when-sniffing-3">get an attribute</a>
       until no further attributes can be found, then jump to the step below labeled <i>next
       byte</i>.</p></li></ol>
     </dd><dt>A sequence of bytes starting with: 0x3C 0x21 (`<code>&lt;!</code>`)</dt><dt>A sequence of bytes starting with: 0x3C 0x2F (`<code>&lt;/</code>`)</dt><dt>A sequence of bytes starting with: 0x3C 0x3F (`<code>&lt;?</code>`)</dt><dd>
      <p>Advance the <var>position</var> pointer so that it points at the first 0x3E byte (&gt;) that
      comes after the 0x3C byte that was found.</p>
     </dd><dt>Any other byte</dt><dd>
      <p>Do nothing with that byte.</p>
     </dd></dl>
   </li><li><i>Next byte</i>: Move <var>position</var> so it points at the next byte in the
   input byte stream, and return to the step above labeled <i>loop</i>.</li></ol>
  </div>

  <div data-algorithm="">
  <p>When the <a href="#prescan-a-byte-stream-to-determine-its-encoding" id="determining-the-character-encoding:prescan-a-byte-stream-to-determine-its-encoding-4">prescan a byte stream to determine its encoding</a> algorithm says to <dfn id="concept-get-attributes-when-sniffing">get an attribute</dfn>, it means doing this:</p>

  <ol><li><p>If the byte at <var>position</var> is one of 0x09 (HT), 0x0A (LF), 0x0C (FF), 0x0D (CR),
   0x20 (SP), or 0x2F (/), then advance <var>position</var> to the next byte and redo this
   step.</p></li><li><p>If the byte at <var>position</var> is 0x3E (&gt;), then abort the <a href="#concept-get-attributes-when-sniffing" id="determining-the-character-encoding:concept-get-attributes-when-sniffing-4">get an attribute</a> algorithm. There isn't
   one.</p></li><li><p>Otherwise, the byte at <var>position</var> is the start of the attribute name.
   Let <var>attribute name</var> and <var>attribute value</var> be the empty
   string.</p></li><li><p>Process the byte at <var>position</var> as follows:</p>

    <dl class="switch"><dt>If it is 0x3D (=), and the <var>attribute name</var> is longer than the empty string</dt><dd>Advance <var>position</var> to the next byte and jump to the step below labeled
     <i>value</i>.</dd><dt>If it is 0x09 (HT), 0x0A (LF), 0x0C (FF), 0x0D (CR), or 0x20 (SP)</dt><dd>Jump to the step below labeled <i>spaces</i>.</dd><dt>If it is 0x2F (/) or 0x3E (&gt;)</dt><dd>Abort the <a href="#concept-get-attributes-when-sniffing" id="determining-the-character-encoding:concept-get-attributes-when-sniffing-5">get an attribute</a>
     algorithm. The attribute's name is the value of <var>attribute name</var>, its value
     is the empty string.</dd><dt>If it is in the range 0x41 (A) to 0x5A (Z)</dt><dd>Append the code point <var>b</var>+0x20 to <var>attribute name</var>
     (where <var>b</var> is the value of the byte at <var>position</var>). (This converts the input
     to lowercase.)</dd><dt>Anything else</dt><dd>Append the code point with the same value as the byte at <var>position</var> to
     <var>attribute name</var>. (It doesn't actually matter how bytes outside the ASCII range are
     handled here, since only ASCII bytes can contribute to the detection of a character
     encoding.)</dd></dl>
   </li><li><p>Advance <var>position</var> to the next byte and return to the previous
   step.</p></li><li><p><i>Spaces</i>: If the byte at <var>position</var> is one of 0x09 (HT), 0x0A (LF), 0x0C
   (FF), 0x0D (CR), or 0x20 (SP), then advance <var>position</var> to the next byte, then, repeat
   this step.</p></li><li><p>If the byte at <var>position</var> is <em>not</em> 0x3D (=), abort the <a href="#concept-get-attributes-when-sniffing" id="determining-the-character-encoding:concept-get-attributes-when-sniffing-6">get an attribute</a> algorithm. The attribute's
   name is the value of <var>attribute name</var>, its value is the empty string.</p></li><li><p>Advance <var>position</var> past the 0x3D (=) byte.</p></li><li><p><i>Value</i>: If the byte at <var>position</var> is one of 0x09 (HT), 0x0A (LF), 0x0C
   (FF), 0x0D (CR), or 0x20 (SP), then advance <var>position</var> to the next byte, then, repeat
   this step.</p></li><li><p>Process the byte at <var>position</var> as follows:</p>

    <dl class="switch"><dt>If it is 0x22 (") or 0x27 (')</dt><dd>
      <ol><li>Let <var>b</var> be the value of the byte at <var>position</var>.</li><li><i>Quote loop</i>: Advance <var>position</var> to the next byte.</li><li>If the value of the byte at <var>position</var> is the value of <var>b</var>, then advance <var>position</var> to the next byte and abort the
       "get an attribute" algorithm. The attribute's name is the value of <var>attribute
       name</var>, and its value is the value of <var>attribute value</var>.</li><li>Otherwise, if the value of the byte at <var>position</var> is in the range 0x41 (A) to
       0x5A (Z), then append a code point to <var>attribute value</var> whose value is 0x20 more
       than the value of the byte at <var>position</var>.</li><li>Otherwise, append a code point to <var>attribute value</var> whose value is the same as
       the value of the byte at <var>position</var>.</li><li>Return to the step above labeled <i>quote loop</i>.</li></ol>
     </dd><dt>If it is 0x3E (&gt;)</dt><dd>Abort the <a href="#concept-get-attributes-when-sniffing" id="determining-the-character-encoding:concept-get-attributes-when-sniffing-7">get an attribute</a>
     algorithm. The attribute's name is the value of <var>attribute name</var>, its value
     is the empty string.</dd><dt>If it is in the range 0x41 (A) to 0x5A (Z)</dt><dd>Append a code point <var>b</var>+0x20 to <var>attribute value</var>
     (where <var>b</var> is the value of the byte at <var>position</var>). Advance
     <var>position</var> to the next byte.</dd><dt>Anything else</dt><dd>Append a code point with the same value as the byte at <var>position</var> to
     <var>attribute value</var>. Advance <var>position</var> to the next byte.</dd></dl>
   </li><li><p>Process the byte at <var>position</var> as
   follows:</p>

    <dl class="switch"><dt>If it is 0x09 (HT), 0x0A (LF), 0x0C (FF), 0x0D (CR), 0x20 (SP), or 0x3E (&gt;)</dt><dd>Abort the <a href="#concept-get-attributes-when-sniffing" id="determining-the-character-encoding:concept-get-attributes-when-sniffing-8">get an attribute</a>
     algorithm. The attribute's name is the value of <var>attribute name</var> and its
     value is the value of <var>attribute value</var>.</dd><dt>If it is in the range 0x41 (A) to 0x5A (Z)</dt><dd>Append a code point <var>b</var>+0x20 to <var>attribute value</var>
     (where <var>b</var> is the value of the byte at <var>position</var>).</dd><dt>Anything else</dt><dd>Append a code point with the same value as the byte at <var>position</var> to
     <var>attribute value</var>.</dd></dl>
   </li><li><p>Advance <var>position</var> to the next byte and return to the previous
   step.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the <a href="#prescan-a-byte-stream-to-determine-its-encoding" id="determining-the-character-encoding:prescan-a-byte-stream-to-determine-its-encoding-5">prescan a byte stream to determine its encoding</a> algorithm is aborted
  without returning an encoding, <dfn id="concept-get-xml-encoding-when-sniffing">get an XML
  encoding</dfn> means doing this.</p>

  <p class="note">Looking for syntax resembling an XML declaration, even in <code id="determining-the-character-encoding:text/html"><a href="#text/html">text/html</a></code>,
  is necessary for compatibility with existing content.</p>

  <ol><li><p>Let <var>encodingPosition</var> be a pointer to the start of the stream.</p></li><li><p>If <var>encodingPosition</var> does not point to the start of a byte sequence 0x3C, 0x3F,
   0x78, 0x6D, 0x6C (`<code>&lt;?xml</code>`), then return failure.</p></li><li><p>Let <var>xmlDeclarationEnd</var> be a pointer to the next byte in the input byte stream
   which is 0x3E (&gt;). If there is no such byte, then return failure.</p></li><li><p>Set <var>encodingPosition</var> to the position of the first occurrence of the subsequence
   of bytes 0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67 (`<code>encoding</code>`) at or
   after the current <var>encodingPosition</var>. If there is no such sequence, then return
   failure.</p></li><li><p>Advance <var>encodingPosition</var> past the 0x67 (g) byte.</p></li><li><p>While the byte at <var>encodingPosition</var> is less than or equal to 0x20 (i.e., it is
   either an ASCII space or control character), advance <var>encodingPosition</var> to the next
   byte.</p></li><li><p>If the byte at <var>encodingPosition</var> is not 0x3D (=), then return failure.</p></li><li><p>Advance <var>encodingPosition</var> to the next byte.</p></li><li><p>While the byte at <var>encodingPosition</var> is less than or equal to 0x20 (i.e., it is
   either an ASCII space or control character), advance <var>encodingPosition</var> to the next
   byte.</p></li><li><p>Let <var>quoteMark</var> be the byte at <var>encodingPosition</var>.</p></li><li><p>If <var>quoteMark</var> is not either 0x22 (") or 0x27 ('), then return failure.</p></li><li><p>Advance <var>encodingPosition</var> to the next byte.</p></li><li><p>Let <var>encodingEndPosition</var> be the position of the next occurrence of
   <var>quoteMark</var> at or after <var>encodingPosition</var>. If <var>quoteMark</var> does not
   occur again, then return failure.</p></li><li><p>Let <var>potentialEncoding</var> be the sequence of the bytes between
   <var>encodingPosition</var> (inclusive) and <var>encodingEndPosition</var> (exclusive).</p></li><li><p>If <var>potentialEncoding</var> contains one or more bytes whose byte value is 0x20 or
   below, then return failure.</p></li><li><p>Let <var>encoding</var> be the result of <a id="determining-the-character-encoding:getting-an-encoding-2" href="https://encoding.spec.whatwg.org/#concept-encoding-get" data-x-internal="getting-an-encoding">getting an encoding</a> given
   <var>potentialEncoding</var> <a href="https://infra.spec.whatwg.org/#isomorphic-decode" id="determining-the-character-encoding:isomorphic-decode" data-x-internal="isomorphic-decode">isomorphic decoded</a>.</p></li><li><p>If the <var>encoding</var> is <a id="determining-the-character-encoding:utf-16-encoding-3" href="https://encoding.spec.whatwg.org/#utf-16be-le" data-x-internal="utf-16-encoding">UTF-16BE/LE</a>, then change it to
   <a id="determining-the-character-encoding:utf-8-2" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>.</p></li><li><p>Return <var>encoding</var>.</p></li></ol>
  </div>

  <p>For the sake of interoperability, user agents should not use a pre-scan algorithm that returns
  different results than the one described above. (But, if you do, please at least let us know, so
  that we can improve this algorithm and benefit everyone...)</p>



  <h5 id="character-encodings"><span class="secno">13.2.3.3</span> Character encodings<a href="#character-encodings" class="self-link"></a></h5>

  <p>User agents must support the encodings defined in <cite>Encoding</cite>, including, but
  not limited to,
  <dfn id="utf-8"><a href="https://encoding.spec.whatwg.org/#utf-8">UTF-8</a></dfn>,
  <dfn id="iso-8859-2"><a href="https://encoding.spec.whatwg.org/#iso-8859-2">ISO-8859-2</a></dfn>,
  <dfn id="iso-8859-7"><a href="https://encoding.spec.whatwg.org/#iso-8859-7">ISO-8859-7</a></dfn>,
  <dfn id="iso-8859-8"><a href="https://encoding.spec.whatwg.org/#iso-8859-8">ISO-8859-8</a></dfn>,
  <dfn id="windows-874"><a href="https://encoding.spec.whatwg.org/#windows-874">windows-874</a></dfn>,
  <dfn id="windows-1250"><a href="https://encoding.spec.whatwg.org/#windows-1250">windows-1250</a></dfn>,
  <dfn id="windows-1251"><a href="https://encoding.spec.whatwg.org/#windows-1251">windows-1251</a></dfn>,
  <dfn id="windows-1252"><a href="https://encoding.spec.whatwg.org/#windows-1252">windows-1252</a></dfn>,
  <dfn id="windows-1254"><a href="https://encoding.spec.whatwg.org/#windows-1254">windows-1254</a></dfn>,
  <dfn id="windows-1255"><a href="https://encoding.spec.whatwg.org/#windows-1255">windows-1255</a></dfn>,
  <dfn id="windows-1256"><a href="https://encoding.spec.whatwg.org/#windows-1256">windows-1256</a></dfn>,
  <dfn id="windows-1257"><a href="https://encoding.spec.whatwg.org/#windows-1257">windows-1257</a></dfn>,
  <dfn id="windows-1258"><a href="https://encoding.spec.whatwg.org/#windows-1258">windows-1258</a></dfn>,
  <dfn id="gbk"><a href="https://encoding.spec.whatwg.org/#gbk">GBK</a></dfn>,
  <dfn id="big5"><a href="https://encoding.spec.whatwg.org/#big5">Big5</a></dfn>,
  <dfn id="iso-2022-jp"><a href="https://encoding.spec.whatwg.org/#iso-2022-jp">ISO-2022-JP</a></dfn>,
  <dfn id="shift_jis"><a href="https://encoding.spec.whatwg.org/#shift_jis">Shift_JIS</a></dfn>,
  <dfn id="euc-kr"><a href="https://encoding.spec.whatwg.org/#euc-kr">EUC-KR</a></dfn>,
  <dfn id="utf-16be"><a href="https://encoding.spec.whatwg.org/#utf-16be">UTF-16BE</a></dfn>,
  <dfn id="utf-16le"><a href="https://encoding.spec.whatwg.org/#utf-16le">UTF-16LE</a></dfn>,
  <dfn id="utf-16-encoding"><a href="https://encoding.spec.whatwg.org/#utf-16be-le">UTF-16BE/LE</a></dfn>, and
  <dfn id="x-user-defined"><a href="https://encoding.spec.whatwg.org/#x-user-defined">x-user-defined</a></dfn>.
  User agents must not support other encodings.</p>

  <p class="note">The above prohibits supporting, for example, CESU-8, UTF-7, BOCU-1, SCSU, EBCDIC,
  and UTF-32. This specification does not make any attempt to support prohibited encodings in its
  algorithms; support and use of prohibited encodings would thus lead to unexpected behavior.
  <a href="#refsCESU8">[CESU8]</a> <a href="#refsUTF7">[UTF7]</a> <a href="#refsBOCU1">[BOCU1]</a> <a href="#refsSCSU">[SCSU]</a></p>


  <h5 id="changing-the-encoding-while-parsing"><span class="secno">13.2.3.4</span> Changing the encoding while parsing<a href="#changing-the-encoding-while-parsing" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the encoding</dfn>, it must run the
  following steps. This might happen if the <a href="#encoding-sniffing-algorithm" id="changing-the-encoding-while-parsing:encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
  failed to find a character encoding, or if it found a character encoding that was not the actual
  encoding of the file.</p>

  <ol><li><p>If the encoding that is already being used to interpret the input stream is
   <a id="changing-the-encoding-while-parsing:utf-16-encoding" href="https://encoding.spec.whatwg.org/#utf-16be-le" data-x-internal="utf-16-encoding">UTF-16BE/LE</a>, then set the <a href="#concept-encoding-confidence" id="changing-the-encoding-while-parsing:concept-encoding-confidence">confidence</a> to <i>certain</i> and return. The new
   encoding is ignored; if it was anything but the same encoding, then it would be clearly
   incorrect.</p></li><li><p>If the new encoding is <a id="changing-the-encoding-while-parsing:utf-16-encoding-2" href="https://encoding.spec.whatwg.org/#utf-16be-le" data-x-internal="utf-16-encoding">UTF-16BE/LE</a>, then change it to
   <a id="changing-the-encoding-while-parsing:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>.</p></li><li><p>If the new encoding is <a id="changing-the-encoding-while-parsing:x-user-defined" href="https://encoding.spec.whatwg.org/#x-user-defined" data-x-internal="x-user-defined">x-user-defined</a>, then change it to
   <a id="changing-the-encoding-while-parsing:windows-1252" href="https://encoding.spec.whatwg.org/#windows-1252" data-x-internal="windows-1252">windows-1252</a>.</p></li><li><p>If the new encoding is identical or equivalent to the encoding that is already being used
   to interpret the input stream, then set the <a href="#concept-encoding-confidence" id="changing-the-encoding-while-parsing:concept-encoding-confidence-2">confidence</a> to <i>certain</i> and return.
   This happens when the encoding information found in the file matches what the <a href="#encoding-sniffing-algorithm" id="changing-the-encoding-while-parsing:encoding-sniffing-algorithm-2">encoding
   sniffing algorithm</a> determined to be the encoding, and in the second pass through the
   parser if the first pass found that the encoding sniffing algorithm described in the earlier
   section failed to find the right encoding.</p></li><li><p>If all the bytes up to the last byte converted by the current decoder have the same
   Unicode interpretations in both the current encoding and the new encoding, and if the user agent
   supports changing the converter on the fly, then the user agent may change to the new converter
   for the encoding on the fly. Set the <a id="changing-the-encoding-while-parsing:document's-character-encoding" href="https://dom.spec.whatwg.org/#concept-document-encoding" data-x-internal="document's-character-encoding">document's character encoding</a> and the encoding
   used to convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" id="changing-the-encoding-while-parsing:concept-encoding-confidence-3">confidence</a> to <i>certain</i>, and return.</p></li><li><p>Otherwise, restart the <a href="#navigate" id="changing-the-encoding-while-parsing:navigate">navigate</a> algorithm, with <i id="changing-the-encoding-while-parsing:navigation-hh"><a href="#navigation-hh">historyHandling</a></i> set to "<code id="changing-the-encoding-while-parsing:navigationhistorybehavior-replace"><a href="#navigationhistorybehavior-replace">replace</a></code>" and other inputs kept the same, but
   this time skip the <a href="#encoding-sniffing-algorithm" id="changing-the-encoding-while-parsing:encoding-sniffing-algorithm-3">encoding sniffing algorithm</a> and instead just set the encoding to
   the new encoding and the <a href="#concept-encoding-confidence" id="changing-the-encoding-while-parsing:concept-encoding-confidence-4">confidence</a> to
   <i>certain</i>. Whenever possible, this should be done without actually contacting the network
   layer (the bytes should be re-parsed from memory), even if, e.g., the document is marked as not
   being cacheable. If this is not possible and contacting the network layer would involve repeating
   a request that uses a method other than `<code>GET</code>`, then instead set the <a href="#concept-encoding-confidence" id="changing-the-encoding-while-parsing:concept-encoding-confidence-5">confidence</a> to <i>certain</i> and ignore the new
   encoding. The resource will be misinterpreted. User agents may notify the user of the situation,
   to aid in application development.</p></li></ol>
  </div>

  <p class="note">This algorithm is only invoked when a new encoding is found declared on a
  <code id="changing-the-encoding-while-parsing:the-meta-element"><a href="#the-meta-element">meta</a></code> element.</p> 


  <h5 id="preprocessing-the-input-stream"><span class="secno">13.2.3.5</span> Preprocessing the input stream<a href="#preprocessing-the-input-stream" class="self-link"></a></h5>

  <p>The <dfn id="input-stream">input stream</dfn> consists of the characters pushed into it as the <a href="#the-input-byte-stream" id="preprocessing-the-input-stream:the-input-byte-stream">input byte
  stream</a> is decoded or from the various APIs that directly manipulate the input stream.</p>

  <p>Any occurrences of <a href="https://infra.spec.whatwg.org/#surrogate" id="preprocessing-the-input-stream:surrogate" data-x-internal="surrogate">surrogates</a> are <a href="#parse-error-surrogate-in-input-stream" id="preprocessing-the-input-stream:parse-error-surrogate-in-input-stream">surrogate-in-input-stream</a>
  <a href="#parse-errors" id="preprocessing-the-input-stream:parse-errors">parse errors</a>. Any occurrences of <a href="https://infra.spec.whatwg.org/#noncharacter" id="preprocessing-the-input-stream:noncharacter" data-x-internal="noncharacter">noncharacters</a> are <a href="#parse-error-noncharacter-in-input-stream" id="preprocessing-the-input-stream:parse-error-noncharacter-in-input-stream">noncharacter-in-input-stream</a>
  <a href="#parse-errors" id="preprocessing-the-input-stream:parse-errors-2">parse errors</a> and any occurrences of <a href="https://infra.spec.whatwg.org/#control" id="preprocessing-the-input-stream:control" data-x-internal="control">controls</a> other than <a id="preprocessing-the-input-stream:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> and U+0000 NULL
  characters are <a href="#parse-error-control-character-in-input-stream" id="preprocessing-the-input-stream:parse-error-control-character-in-input-stream">control-character-in-input-stream</a>
  <a href="#parse-errors" id="preprocessing-the-input-stream:parse-errors-3">parse errors</a>.</p>

  <p class="note">The handling of U+0000 NULL characters varies based on where the characters are
  found and happens at the later stages of the parsing. They are either ignored or, for security
  reasons, replaced with a U+FFFD REPLACEMENT CHARACTER. This handling is, by necessity, spread
  across both the tokenization stage and the tree construction stage.</p>

  <div data-algorithm="">
  <p>Before the <a href="#tokenization" id="preprocessing-the-input-stream:tokenization">tokenization</a> stage, the input stream must be preprocessed by <a href="https://infra.spec.whatwg.org/#normalize-newlines" id="preprocessing-the-input-stream:normalize-newlines" data-x-internal="normalize-newlines">normalizing newlines</a>. Thus, newlines in HTML DOMs are
  represented by U+000A LF characters, and there are never any U+000D CR characters in the input to
  the <a href="#tokenization" id="preprocessing-the-input-stream:tokenization-2">tokenization</a> stage.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the <a href="#input-stream" id="preprocessing-the-input-stream:input-stream">input stream</a>
  that has not yet been <dfn>consumed</dfn> or explicitly ignored by the requirements in
  this section. Initially, the <i id="preprocessing-the-input-stream:next-input-character"><a href="#next-input-character">next input character</a></i> is the
  first character in the input. The <dfn id="current-input-character">current input character</dfn> is the last character to have
  been <i>consumed</i>.</p>
  </div>

  <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a character or just before the end
  of the input stream) where content inserted using <code id="preprocessing-the-input-stream:dom-document-write"><a href="#dom-document-write">document.write()</a></code> is actually inserted. The insertion point is
  relative to the position of the character immediately after it, it is not an absolute offset into
  the input stream. Initially, the insertion point is undefined.</p>

  <p>The "EOF" character in the tables below is a conceptual character representing the end of the
  <a href="#input-stream" id="preprocessing-the-input-stream:input-stream-2">input stream</a>. If the parser is a <a href="#script-created-parser" id="preprocessing-the-input-stream:script-created-parser">script-created parser</a>, then the end of
  the <a href="#input-stream" id="preprocessing-the-input-stream:input-stream-3">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF" character</dfn> (inserted by
  the <code id="preprocessing-the-input-stream:dom-document-close"><a href="#dom-document-close">document.close()</a></code> method) is consumed. Otherwise, the
  "EOF" character is not a real character in the stream, but rather the lack of any further
  characters.</p>

  


  

  <h4 id="parse-state"><span class="secno">13.2.4</span> Parse state<a href="#parse-state" class="self-link"></a></h4>

  <h5 id="the-insertion-mode"><span class="secno">13.2.4.1</span> The insertion mode<a href="#the-insertion-mode" class="self-link"></a></h5>

  <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls the primary operation of the
  tree construction stage.</p>

  <p>Initially, the <a href="#insertion-mode" id="the-insertion-mode:insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" id="the-insertion-mode:the-initial-insertion-mode">initial</a>". It can change to "<a href="#the-before-html-insertion-mode" id="the-insertion-mode:the-before-html-insertion-mode">before
  html</a>", "<a href="#the-before-head-insertion-mode" id="the-insertion-mode:the-before-head-insertion-mode">before head</a>", "<a href="#parsing-main-inhead" id="the-insertion-mode:parsing-main-inhead">in head</a>", "<a href="#parsing-main-inheadnoscript" id="the-insertion-mode:parsing-main-inheadnoscript">in head noscript</a>", "<a href="#the-after-head-insertion-mode" id="the-insertion-mode:the-after-head-insertion-mode">after head</a>",
  "<a href="#parsing-main-inbody" id="the-insertion-mode:parsing-main-inbody">in body</a>", "<a href="#parsing-main-incdata" id="the-insertion-mode:parsing-main-incdata">text</a>", "<a href="#parsing-main-intable" id="the-insertion-mode:parsing-main-intable">in table</a>", "<a href="#parsing-main-intabletext" id="the-insertion-mode:parsing-main-intabletext">in table text</a>", "<a href="#parsing-main-incaption" id="the-insertion-mode:parsing-main-incaption">in caption</a>", "<a href="#parsing-main-incolgroup" id="the-insertion-mode:parsing-main-incolgroup">in column
  group</a>", "<a href="#parsing-main-intbody" id="the-insertion-mode:parsing-main-intbody">in table body</a>", "<a href="#parsing-main-intr" id="the-insertion-mode:parsing-main-intr">in row</a>", "<a href="#parsing-main-intd" id="the-insertion-mode:parsing-main-intd">in
  cell</a>", "<a href="#parsing-main-intemplate" id="the-insertion-mode:parsing-main-intemplate">in template</a>", "<a href="#parsing-main-afterbody" id="the-insertion-mode:parsing-main-afterbody">after body</a>", "<a href="#parsing-main-inframeset" id="the-insertion-mode:parsing-main-inframeset">in frameset</a>", "<a href="#parsing-main-afterframeset" id="the-insertion-mode:parsing-main-afterframeset">after
  frameset</a>", "<a href="#the-after-after-body-insertion-mode" id="the-insertion-mode:the-after-after-body-insertion-mode">after after body</a>", and
  "<a href="#the-after-after-frameset-insertion-mode" id="the-insertion-mode:the-after-after-frameset-insertion-mode">after after frameset</a>" during the
  course of the parsing, as described in the <a href="#tree-construction" id="the-insertion-mode:tree-construction">tree construction</a> stage. The insertion
  mode affects how tokens are processed and whether CDATA sections are supported.</p>

  <div data-algorithm="">
  <p>Several of these modes, namely "<a href="#parsing-main-inhead" id="the-insertion-mode:parsing-main-inhead-2">in head</a>", "<a href="#parsing-main-inbody" id="the-insertion-mode:parsing-main-inbody-2">in body</a>", and "<a href="#parsing-main-intable" id="the-insertion-mode:parsing-main-intable-2">in
  table</a>", are special, in that the other modes defer to them at various times. When the
  algorithm below says that the user agent is to do something "<dfn id="using-the-rules-for">using the rules for</dfn> the
  <var>m</var> insertion mode", where <var>m</var> is one of these modes, the user agent must use
  the rules described under the <var>m</var> <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-2">insertion mode</a>'s section, but must leave
  the <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-3">insertion mode</a> unchanged unless the rules in <var>m</var> themselves switch the
  <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-4">insertion mode</a> to a new value.</p>
  </div>

  <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" id="the-insertion-mode:parsing-main-incdata-2">text</a>" or
  "<a href="#parsing-main-intabletext" id="the-insertion-mode:parsing-main-intabletext-2">in table text</a>", the <dfn id="original-insertion-mode">original insertion
  mode</dfn> is also set. This is the insertion mode to which the tree construction stage will
  return.</p>

  <p>Similarly, to parse nested <code id="the-insertion-mode:the-template-element"><a href="#the-template-element">template</a></code> elements, a <dfn id="stack-of-template-insertion-modes">stack of template insertion
  modes</dfn> is used. It is initially empty. The <dfn id="current-template-insertion-mode">current template insertion mode</dfn> is the
  insertion mode that was most recently added to the <a href="#stack-of-template-insertion-modes" id="the-insertion-mode:stack-of-template-insertion-modes">stack of template insertion modes</a>.
  The algorithms in the sections below will <i>push</i> insertion modes onto this stack, meaning
  that the specified insertion mode is to be added to the stack, and <i>pop</i> insertion modes from
  the stack, which means that the most recently added insertion mode must be removed from the
  stack.</p>

  <hr>

  <div data-algorithm="">
  <p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion mode appropriately</dfn>, it
  means the UA must follow these steps:</p>

  <ol><li><p>Let <var>last</var> be false.</p></li><li><p>Let <var>node</var> be the last node in the <a href="#stack-of-open-elements" id="the-insertion-mode:stack-of-open-elements">stack of open
   elements</a>.</p></li><li><p><i>Loop</i>: If <var>node</var> is the first node in the stack of open elements, then set
   <var>last</var> to true, and, if the parser was created as part of the <a href="#html-fragment-parsing-algorithm" id="the-insertion-mode:html-fragment-parsing-algorithm">HTML fragment
   parsing algorithm</a> (<a href="#fragment-case" id="the-insertion-mode:fragment-case">fragment case</a>), set <var>node</var> to the <var id="the-insertion-mode:concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element passed to that algorithm.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:the-td-element"><a href="#the-td-element">td</a></code> or <code id="the-insertion-mode:the-th-element"><a href="#the-th-element">th</a></code> element and <var>last</var> is
   false, then switch the <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-5">insertion mode</a> to "<a href="#parsing-main-intd" id="the-insertion-mode:parsing-main-intd-2">in
   cell</a>" and return.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:the-tr-element"><a href="#the-tr-element">tr</a></code> element, then switch the <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-6">insertion
   mode</a> to "<a href="#parsing-main-intr" id="the-insertion-mode:parsing-main-intr-2">in row</a>" and return.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>, <code id="the-insertion-mode:the-thead-element"><a href="#the-thead-element">thead</a></code>, or
   <code id="the-insertion-mode:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> element, then switch the <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-7">insertion mode</a> to "<a href="#parsing-main-intbody" id="the-insertion-mode:parsing-main-intbody-2">in table body</a>" and return.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:the-caption-element"><a href="#the-caption-element">caption</a></code> element, then switch the
   <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-8">insertion mode</a> to "<a href="#parsing-main-incaption" id="the-insertion-mode:parsing-main-incaption-2">in caption</a>" and
   return.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> element, then switch the
   <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-9">insertion mode</a> to "<a href="#parsing-main-incolgroup" id="the-insertion-mode:parsing-main-incolgroup-2">in column
   group</a>" and return.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:the-table-element"><a href="#the-table-element">table</a></code> element, then switch the
   <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-10">insertion mode</a> to "<a href="#parsing-main-intable" id="the-insertion-mode:parsing-main-intable-3">in table</a>" and
   return.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:the-template-element-2"><a href="#the-template-element">template</a></code> element, then switch the
   <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-11">insertion mode</a> to the <a href="#current-template-insertion-mode" id="the-insertion-mode:current-template-insertion-mode">current template insertion mode</a> and
   return.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:the-head-element"><a href="#the-head-element">head</a></code> element and <var>last</var> is
   false, then switch the <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-12">insertion mode</a> to "<a href="#parsing-main-inhead" id="the-insertion-mode:parsing-main-inhead-3">in
   head</a>" and return.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:the-body-element"><a href="#the-body-element">body</a></code> element, then switch the
   <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-13">insertion mode</a> to "<a href="#parsing-main-inbody" id="the-insertion-mode:parsing-main-inbody-3">in body</a>" and
   return.</p></li><li><p>If <var>node</var> is a <code id="the-insertion-mode:frameset"><a href="#frameset">frameset</a></code> element, then switch the
   <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-14">insertion mode</a> to "<a href="#parsing-main-inframeset" id="the-insertion-mode:parsing-main-inframeset-2">in frameset</a>" and
   return. (<a href="#fragment-case" id="the-insertion-mode:fragment-case-2">fragment case</a>)</p></li><li>
    <p>If <var>node</var> is an <code id="the-insertion-mode:the-html-element"><a href="#the-html-element">html</a></code> element, run these substeps:</p>

    <ol><li><p>If the <a href="#head-element-pointer" id="the-insertion-mode:head-element-pointer"><code>head</code> element pointer</a> is null, switch the
     <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-15">insertion mode</a> to "<a href="#the-before-head-insertion-mode" id="the-insertion-mode:the-before-head-insertion-mode-2">before head</a>"
     and return. (<a href="#fragment-case" id="the-insertion-mode:fragment-case-3">fragment case</a>)</p></li><li><p>Otherwise, the <a href="#head-element-pointer" id="the-insertion-mode:head-element-pointer-2"><code>head</code> element pointer</a> is not null, switch the
     <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-16">insertion mode</a> to "<a href="#the-after-head-insertion-mode" id="the-insertion-mode:the-after-head-insertion-mode-2">after head</a>" and
     return.</p></li></ol>
   </li><li><p>If <var>last</var> is true, then switch the <a href="#insertion-mode" id="the-insertion-mode:insertion-mode-17">insertion mode</a> to "<a href="#parsing-main-inbody" id="the-insertion-mode:parsing-main-inbody-4">in body</a>" and return. (<a href="#fragment-case" id="the-insertion-mode:fragment-case-4">fragment
   case</a>)</p></li><li><p>Let <var>node</var> now be the node before <var>node</var> in the
   <a href="#stack-of-open-elements" id="the-insertion-mode:stack-of-open-elements-2">stack of open elements</a>.</p></li><li><p>Return to the step labeled <i>loop</i>.</p></li></ol>
  </div>


  <h5 id="the-stack-of-open-elements"><span class="secno">13.2.4.2</span> The stack of open elements<a href="#the-stack-of-open-elements" class="self-link"></a></h5>

  <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The stack grows downwards; the
  topmost node on the stack is the first one added to the stack, and the bottommost node of the
  stack is the most recently added node in the stack (notwithstanding when the stack is manipulated
  in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested
  tags</a>).</p>

  <p class="note">The "<a href="#the-before-html-insertion-mode" id="the-stack-of-open-elements:the-before-html-insertion-mode">before html</a>"
  <a href="#insertion-mode" id="the-stack-of-open-elements:insertion-mode">insertion mode</a> creates the <code id="the-stack-of-open-elements:the-html-element"><a href="#the-html-element">html</a></code> <a id="the-stack-of-open-elements:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>, which is
  then added to the stack.</p>

  <p class="note">In the <a href="#fragment-case" id="the-stack-of-open-elements:fragment-case">fragment case</a>, the <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements">stack of open elements</a> is
  initialized to contain an <code id="the-stack-of-open-elements:the-html-element-2"><a href="#the-html-element">html</a></code> element that is created as part of <a href="#html-fragment-parsing-algorithm" id="the-stack-of-open-elements:html-fragment-parsing-algorithm">that algorithm</a>. (The <a href="#fragment-case" id="the-stack-of-open-elements:fragment-case-2">fragment case</a> skips the
  "<a href="#the-before-html-insertion-mode" id="the-stack-of-open-elements:the-before-html-insertion-mode-2">before html</a>" <a href="#insertion-mode" id="the-stack-of-open-elements:insertion-mode-2">insertion mode</a>.)</p>

  <p>The <code id="the-stack-of-open-elements:the-html-element-3"><a href="#the-html-element">html</a></code> node, however it is created, is the topmost node of the stack. It only
  gets popped off the stack when the parser <a href="#stop-parsing" id="the-stack-of-open-elements:stop-parsing">finishes</a>.</p>

  <div data-algorithm="">
  <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-2">stack of open
  elements</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="adjusted-current-node">adjusted current node</dfn> is the <i id="the-stack-of-open-elements:concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></i>
  element if the parser was created as part of the <a href="#html-fragment-parsing-algorithm" id="the-stack-of-open-elements:html-fragment-parsing-algorithm-2">HTML fragment parsing algorithm</a> and
  the <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-3">stack of open elements</a> has only one element in it (<a href="#fragment-case" id="the-stack-of-open-elements:fragment-case-3">fragment case</a>);
  otherwise, the <a href="#adjusted-current-node" id="the-stack-of-open-elements:adjusted-current-node">adjusted current node</a> is the <a href="#current-node" id="the-stack-of-open-elements:current-node">current node</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When the <a href="#current-node" id="the-stack-of-open-elements:current-node-2">current node</a> is removed from the <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-4">stack of open elements</a>,
  <a href="#process-internal-resource-links" id="the-stack-of-open-elements:process-internal-resource-links">process internal resource links</a> given the <a href="#current-node" id="the-stack-of-open-elements:current-node-3">current node</a>'s
  <a id="the-stack-of-open-elements:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p>
  </div>

  <p>Elements in the <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-5">stack of open elements</a> fall into the following categories:</p>

  <dl><dt><dfn id="special">Special</dfn></dt><dd>
    <p>The following elements have varying levels of special parsing rules: HTML's
    <code id="the-stack-of-open-elements:the-address-element"><a href="#the-address-element">address</a></code>, <code id="the-stack-of-open-elements:applet"><a href="#applet">applet</a></code>, <code id="the-stack-of-open-elements:the-area-element"><a href="#the-area-element">area</a></code>, <code id="the-stack-of-open-elements:the-article-element"><a href="#the-article-element">article</a></code>,
    <code id="the-stack-of-open-elements:the-aside-element"><a href="#the-aside-element">aside</a></code>, <code id="the-stack-of-open-elements:the-base-element"><a href="#the-base-element">base</a></code>, <code id="the-stack-of-open-elements:basefont"><a href="#basefont">basefont</a></code>, <code id="the-stack-of-open-elements:bgsound"><a href="#bgsound">bgsound</a></code>,
    <code id="the-stack-of-open-elements:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code>, <code id="the-stack-of-open-elements:the-body-element"><a href="#the-body-element">body</a></code>, <code id="the-stack-of-open-elements:the-br-element"><a href="#the-br-element">br</a></code>, <code id="the-stack-of-open-elements:the-button-element"><a href="#the-button-element">button</a></code>,
    <code id="the-stack-of-open-elements:the-caption-element"><a href="#the-caption-element">caption</a></code>, <code id="the-stack-of-open-elements:center"><a href="#center">center</a></code>, <code id="the-stack-of-open-elements:the-col-element"><a href="#the-col-element">col</a></code>, <code id="the-stack-of-open-elements:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code>,
    <code id="the-stack-of-open-elements:the-dd-element"><a href="#the-dd-element">dd</a></code>, <code id="the-stack-of-open-elements:the-details-element"><a href="#the-details-element">details</a></code>, <code id="the-stack-of-open-elements:dir"><a href="#dir">dir</a></code>, <code id="the-stack-of-open-elements:the-div-element"><a href="#the-div-element">div</a></code>, <code id="the-stack-of-open-elements:the-dl-element"><a href="#the-dl-element">dl</a></code>,
    <code id="the-stack-of-open-elements:the-dt-element"><a href="#the-dt-element">dt</a></code>, <code id="the-stack-of-open-elements:the-embed-element"><a href="#the-embed-element">embed</a></code>, <code id="the-stack-of-open-elements:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code>, <code id="the-stack-of-open-elements:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code>,
    <code id="the-stack-of-open-elements:the-figure-element"><a href="#the-figure-element">figure</a></code>, <code id="the-stack-of-open-elements:the-footer-element"><a href="#the-footer-element">footer</a></code>, <code id="the-stack-of-open-elements:the-form-element"><a href="#the-form-element">form</a></code>, <code id="the-stack-of-open-elements:frame"><a href="#frame">frame</a></code>,
    <code id="the-stack-of-open-elements:frameset"><a href="#frameset">frameset</a></code>, <code id="the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, <code id="the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>, <code id="the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, <code id="the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>,
    <code id="the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>, <code id="the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>, <code id="the-stack-of-open-elements:the-head-element"><a href="#the-head-element">head</a></code>, <code id="the-stack-of-open-elements:the-header-element"><a href="#the-header-element">header</a></code>, <code id="the-stack-of-open-elements:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code>,
    <code id="the-stack-of-open-elements:the-hr-element"><a href="#the-hr-element">hr</a></code>, <code id="the-stack-of-open-elements:the-html-element-4"><a href="#the-html-element">html</a></code>, <code id="the-stack-of-open-elements:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, 
    <code id="the-stack-of-open-elements:the-img-element"><a href="#the-img-element">img</a></code>, <code id="the-stack-of-open-elements:the-input-element"><a href="#the-input-element">input</a></code>, <code id="the-stack-of-open-elements:keygen"><a href="#keygen">keygen</a></code>, <code id="the-stack-of-open-elements:the-li-element"><a href="#the-li-element">li</a></code>, <code id="the-stack-of-open-elements:the-link-element"><a href="#the-link-element">link</a></code>,
    <code id="the-stack-of-open-elements:listing"><a href="#listing">listing</a></code>, <code id="the-stack-of-open-elements:the-main-element"><a href="#the-main-element">main</a></code>, <code id="the-stack-of-open-elements:the-marquee-element"><a href="#the-marquee-element">marquee</a></code>, <code id="the-stack-of-open-elements:the-menu-element"><a href="#the-menu-element">menu</a></code>,
    <code id="the-stack-of-open-elements:the-meta-element"><a href="#the-meta-element">meta</a></code>, <code id="the-stack-of-open-elements:the-nav-element"><a href="#the-nav-element">nav</a></code>, <code id="the-stack-of-open-elements:noembed"><a href="#noembed">noembed</a></code>, <code id="the-stack-of-open-elements:noframes"><a href="#noframes">noframes</a></code>,
    <code id="the-stack-of-open-elements:the-noscript-element"><a href="#the-noscript-element">noscript</a></code>, <code id="the-stack-of-open-elements:the-object-element"><a href="#the-object-element">object</a></code>, <code id="the-stack-of-open-elements:the-ol-element"><a href="#the-ol-element">ol</a></code>, <code id="the-stack-of-open-elements:the-p-element"><a href="#the-p-element">p</a></code>,
    <code id="the-stack-of-open-elements:param"><a href="#param">param</a></code>, <code id="the-stack-of-open-elements:plaintext"><a href="#plaintext">plaintext</a></code>, <code id="the-stack-of-open-elements:the-pre-element"><a href="#the-pre-element">pre</a></code>, <code id="the-stack-of-open-elements:the-script-element"><a href="#the-script-element">script</a></code>,
    <code id="the-stack-of-open-elements:the-search-element"><a href="#the-search-element">search</a></code>, <code id="the-stack-of-open-elements:the-section-element"><a href="#the-section-element">section</a></code>, <code id="the-stack-of-open-elements:the-select-element"><a href="#the-select-element">select</a></code>, <code id="the-stack-of-open-elements:the-source-element"><a href="#the-source-element">source</a></code>,
    <code id="the-stack-of-open-elements:the-style-element"><a href="#the-style-element">style</a></code>, <code id="the-stack-of-open-elements:the-summary-element"><a href="#the-summary-element">summary</a></code>, <code id="the-stack-of-open-elements:the-table-element"><a href="#the-table-element">table</a></code>, <code id="the-stack-of-open-elements:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>,
    <code id="the-stack-of-open-elements:the-td-element"><a href="#the-td-element">td</a></code>, <code id="the-stack-of-open-elements:the-template-element"><a href="#the-template-element">template</a></code>, <code id="the-stack-of-open-elements:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>, <code id="the-stack-of-open-elements:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code>,
    <code id="the-stack-of-open-elements:the-th-element"><a href="#the-th-element">th</a></code>, <code id="the-stack-of-open-elements:the-thead-element"><a href="#the-thead-element">thead</a></code>, <code id="the-stack-of-open-elements:the-title-element"><a href="#the-title-element">title</a></code>, <code id="the-stack-of-open-elements:the-tr-element"><a href="#the-tr-element">tr</a></code>, <code id="the-stack-of-open-elements:the-track-element"><a href="#the-track-element">track</a></code>,
    <code id="the-stack-of-open-elements:the-ul-element"><a href="#the-ul-element">ul</a></code>, <code id="the-stack-of-open-elements:the-wbr-element"><a href="#the-wbr-element">wbr</a></code>, <code id="the-stack-of-open-elements:xmp"><a href="#xmp">xmp</a></code>; <a id="the-stack-of-open-elements:mathml-mi" href="https://w3c.github.io/mathml-core/#the-mi-element" data-x-internal="mathml-mi">MathML <code>mi</code></a>,
    <a id="the-stack-of-open-elements:mathml-mo" href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo" data-x-internal="mathml-mo">MathML <code>mo</code></a>, <a id="the-stack-of-open-elements:mathml-mn" href="https://w3c.github.io/mathml-core/#number-mn" data-x-internal="mathml-mn">MathML <code>mn</code></a>, <a id="the-stack-of-open-elements:mathml-ms" href="https://w3c.github.io/mathml-core/#string-literal-ms" data-x-internal="mathml-ms">MathML
    <code>ms</code></a>, <a id="the-stack-of-open-elements:mathml-mtext" href="https://w3c.github.io/mathml-core/#text-mtext" data-x-internal="mathml-mtext">MathML <code>mtext</code></a>, and <a id="the-stack-of-open-elements:mathml-annotation-xml" href="https://w3c.github.io/mathml-core/#dfn-annotation-xml" data-x-internal="mathml-annotation-xml">MathML
    <code>annotation-xml</code></a>; and <a id="the-stack-of-open-elements:svg-foreignobject" href="https://svgwg.org/svg2-draft/embedded.html#ForeignObjectElement" data-x-internal="svg-foreignobject">SVG <code>foreignObject</code></a>, <a id="the-stack-of-open-elements:svg-desc" href="https://svgwg.org/svg2-draft/struct.html#DescElement" data-x-internal="svg-desc">SVG
    <code>desc</code></a>, and <a id="the-stack-of-open-elements:svg-title" href="https://svgwg.org/svg2-draft/struct.html#TitleElement" data-x-internal="svg-title">SVG <code>title</code></a>.</p> 

    <p class="note">An <code>image</code> start tag token is handled by the tree builder,
    but it is not in this list because it is not an element; it gets turned into an <code id="the-stack-of-open-elements:the-img-element-2"><a href="#the-img-element">img</a></code>
    element.</p>
   </dd><dt><dfn id="formatting">Formatting</dfn></dt><dd><p>The following HTML elements are those that end up in the <a href="#list-of-active-formatting-elements" id="the-stack-of-open-elements:list-of-active-formatting-elements">list of active formatting
   elements</a>: <code id="the-stack-of-open-elements:the-a-element"><a href="#the-a-element">a</a></code>, <code id="the-stack-of-open-elements:the-b-element"><a href="#the-b-element">b</a></code>, <code id="the-stack-of-open-elements:big"><a href="#big">big</a></code>, <code id="the-stack-of-open-elements:the-code-element"><a href="#the-code-element">code</a></code>,
   <code id="the-stack-of-open-elements:the-em-element"><a href="#the-em-element">em</a></code>, <code id="the-stack-of-open-elements:font"><a href="#font">font</a></code>, <code id="the-stack-of-open-elements:the-i-element"><a href="#the-i-element">i</a></code>, <code id="the-stack-of-open-elements:nobr"><a href="#nobr">nobr</a></code>, <code id="the-stack-of-open-elements:the-s-element"><a href="#the-s-element">s</a></code>,
   <code id="the-stack-of-open-elements:the-small-element"><a href="#the-small-element">small</a></code>, <code id="the-stack-of-open-elements:strike"><a href="#strike">strike</a></code>, <code id="the-stack-of-open-elements:the-strong-element"><a href="#the-strong-element">strong</a></code>, <code id="the-stack-of-open-elements:tt"><a href="#tt">tt</a></code>, and
   <code id="the-stack-of-open-elements:the-u-element"><a href="#the-u-element">u</a></code>.</p></dd><dt><dfn id="ordinary">Ordinary</dfn></dt><dd><p>All other elements found while parsing an HTML document.</p></dd></dl>

  <p class="note">Typically, the <a href="#special" id="the-stack-of-open-elements:special">special</a> elements have the start and end tag tokens
  handled specifically, while <a href="#ordinary" id="the-stack-of-open-elements:ordinary">ordinary</a> elements' tokens fall into "any other start tag"
  and "any other end tag" clauses, and some parts of the tree builder check if a particular element
  in the <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-6">stack of open elements</a> is in the <a href="#special" id="the-stack-of-open-elements:special-2">special</a> category. However, some
  elements (e.g., the <code id="the-stack-of-open-elements:the-option-element"><a href="#the-option-element">option</a></code> element) have their start or end tag tokens handled
  specifically, but are still not in the <a href="#special" id="the-stack-of-open-elements:special-3">special</a> category, so that they get the
  <a href="#ordinary" id="the-stack-of-open-elements:ordinary-2">ordinary</a> handling elsewhere.</p>

  <div data-algorithm="">
  <p>The <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-7">stack of open elements</a> is said to <dfn id="has-an-element-in-the-specific-scope">have an element <var>target node</var> in a specific scope</dfn> consisting of a
  list of element types <var>list</var> when the following algorithm terminates in a match
  state:</p>

  <ol><li><p>Initialize <var>node</var> to be the <a href="#current-node" id="the-stack-of-open-elements:current-node-4">current node</a> (the bottommost
   node of the stack).</p></li><li><p>If <var>node</var> is <var>target node</var>, terminate in a match state.</p></li><li><p>Otherwise, if <var>node</var> is one of the element types in <var>list</var>, terminate in a failure state.</p></li><li><p>Otherwise, set <var>node</var> to the previous entry in the <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-8">stack of open
   elements</a> and return to step 2. (This will never fail, since the loop will always terminate
   in the previous step if the top of the stack — an <code id="the-stack-of-open-elements:the-html-element-5"><a href="#the-html-element">html</a></code> element — is
   reached.)</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-9">stack of open elements</a> is said to <dfn id="has-an-element-in-scope">have a
  particular element in scope</dfn> when it <a href="#has-an-element-in-the-specific-scope" id="the-stack-of-open-elements:has-an-element-in-the-specific-scope">has
  that element in the specific scope</a> consisting of the following element types:</p>

  <ul class="brief"><li><code id="the-stack-of-open-elements:applet-2"><a href="#applet">applet</a></code></li><li><code id="the-stack-of-open-elements:the-caption-element-2"><a href="#the-caption-element">caption</a></code></li><li><code id="the-stack-of-open-elements:the-html-element-6"><a href="#the-html-element">html</a></code></li><li><code id="the-stack-of-open-elements:the-table-element-2"><a href="#the-table-element">table</a></code></li><li><code id="the-stack-of-open-elements:the-td-element-2"><a href="#the-td-element">td</a></code></li><li><code id="the-stack-of-open-elements:the-th-element-2"><a href="#the-th-element">th</a></code></li><li><code id="the-stack-of-open-elements:the-marquee-element-2"><a href="#the-marquee-element">marquee</a></code></li><li><code id="the-stack-of-open-elements:the-object-element-2"><a href="#the-object-element">object</a></code></li><li><code id="the-stack-of-open-elements:the-select-element-2"><a href="#the-select-element">select</a></code></li><li><code id="the-stack-of-open-elements:the-template-element-2"><a href="#the-template-element">template</a></code></li><li><a id="the-stack-of-open-elements:mathml-mi-2" href="https://w3c.github.io/mathml-core/#the-mi-element" data-x-internal="mathml-mi">MathML <code>mi</code></a></li><li><a id="the-stack-of-open-elements:mathml-mo-2" href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo" data-x-internal="mathml-mo">MathML <code>mo</code></a></li><li><a id="the-stack-of-open-elements:mathml-mn-2" href="https://w3c.github.io/mathml-core/#number-mn" data-x-internal="mathml-mn">MathML <code>mn</code></a></li><li><a id="the-stack-of-open-elements:mathml-ms-2" href="https://w3c.github.io/mathml-core/#string-literal-ms" data-x-internal="mathml-ms">MathML <code>ms</code></a></li><li><a id="the-stack-of-open-elements:mathml-mtext-2" href="https://w3c.github.io/mathml-core/#text-mtext" data-x-internal="mathml-mtext">MathML <code>mtext</code></a></li><li><a id="the-stack-of-open-elements:mathml-annotation-xml-2" href="https://w3c.github.io/mathml-core/#dfn-annotation-xml" data-x-internal="mathml-annotation-xml">MathML <code>annotation-xml</code></a></li><li><a id="the-stack-of-open-elements:svg-foreignobject-2" href="https://svgwg.org/svg2-draft/embedded.html#ForeignObjectElement" data-x-internal="svg-foreignobject">SVG <code>foreignObject</code></a></li><li><a id="the-stack-of-open-elements:svg-desc-2" href="https://svgwg.org/svg2-draft/struct.html#DescElement" data-x-internal="svg-desc">SVG <code>desc</code></a></li><li><a id="the-stack-of-open-elements:svg-title-2" href="https://svgwg.org/svg2-draft/struct.html#TitleElement" data-x-internal="svg-title">SVG <code>title</code></a></li></ul>
  </div>

  <div data-algorithm="">
  <p>The <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-10">stack of open elements</a> is said to <dfn id="has-an-element-in-list-item-scope">have a particular element in list item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope" id="the-stack-of-open-elements:has-an-element-in-the-specific-scope-2">has that element in the specific scope</a> consisting of the following
  element types:</p>

  <ul class="brief"><li>All the element types listed above for the <i id="the-stack-of-open-elements:has-an-element-in-scope"><a href="#has-an-element-in-scope">has an element in scope</a></i> algorithm.</li><li><code id="the-stack-of-open-elements:the-ol-element-2"><a href="#the-ol-element">ol</a></code> in the <a id="the-stack-of-open-elements:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></li><li><code id="the-stack-of-open-elements:the-ul-element-2"><a href="#the-ul-element">ul</a></code> in the <a id="the-stack-of-open-elements:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></li></ul>
  </div>

  <div data-algorithm="">
  <p>The <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-11">stack of open elements</a> is said to <dfn id="has-an-element-in-button-scope">have a particular element in button scope</dfn> when it <a href="#has-an-element-in-the-specific-scope" id="the-stack-of-open-elements:has-an-element-in-the-specific-scope-3">has that element in the specific scope</a> consisting of the following element
  types:</p>

  <ul class="brief"><li>All the element types listed above for the <i id="the-stack-of-open-elements:has-an-element-in-scope-2"><a href="#has-an-element-in-scope">has an element in scope</a></i> algorithm.</li><li><code id="the-stack-of-open-elements:the-button-element-2"><a href="#the-button-element">button</a></code> in the <a id="the-stack-of-open-elements:html-namespace-2-3" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></li></ul>
  </div>

  <div data-algorithm="">
  <p>The <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-12">stack of open elements</a> is said to <dfn id="has-an-element-in-table-scope">have a particular element in table scope</dfn> when it <a href="#has-an-element-in-the-specific-scope" id="the-stack-of-open-elements:has-an-element-in-the-specific-scope-4">has that element in the specific scope</a> consisting of the following element
  types:</p>

  <ul class="brief"><li><code id="the-stack-of-open-elements:the-html-element-7"><a href="#the-html-element">html</a></code> in the <a id="the-stack-of-open-elements:html-namespace-2-4" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></li><li><code id="the-stack-of-open-elements:the-table-element-3"><a href="#the-table-element">table</a></code> in the <a id="the-stack-of-open-elements:html-namespace-2-5" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></li><li><code id="the-stack-of-open-elements:the-template-element-3"><a href="#the-template-element">template</a></code> in the <a id="the-stack-of-open-elements:html-namespace-2-6" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></li></ul>
  </div>

  <p>Nothing happens if at any time any of the elements in the <a href="#stack-of-open-elements" id="the-stack-of-open-elements:stack-of-open-elements-13">stack of open elements</a>
  are moved to a new location in, or removed from, the <code id="the-stack-of-open-elements:document"><a href="#document">Document</a></code> tree. In particular,
  the stack is not changed in this situation. This can cause, amongst other strange effects, content
  to be appended to nodes that are no longer in the DOM.</p>

  <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting
  elements</a>), the stack is manipulated in a random-access fashion.</p>


  <h5 id="the-list-of-active-formatting-elements"><span class="secno">13.2.4.3</span> The list of active formatting elements<a href="#the-list-of-active-formatting-elements" class="self-link"></a></h5>

  <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is empty. It is used to handle
  mis-nested <a href="#formatting" id="the-list-of-active-formatting-elements:formatting">formatting element tags</a>.</p>

  <p>The list contains elements in the <a href="#formatting" id="the-list-of-active-formatting-elements:formatting-2">formatting</a> category, and <a href="#concept-parser-marker" id="the-list-of-active-formatting-elements:concept-parser-marker">markers</a>. The <dfn id="concept-parser-marker">markers</dfn> are inserted when entering <code id="the-list-of-active-formatting-elements:applet"><a href="#applet">applet</a></code>,
  <code id="the-list-of-active-formatting-elements:the-object-element"><a href="#the-object-element">object</a></code>, <code id="the-list-of-active-formatting-elements:the-marquee-element"><a href="#the-marquee-element">marquee</a></code>, <code id="the-list-of-active-formatting-elements:the-template-element"><a href="#the-template-element">template</a></code>, <code id="the-list-of-active-formatting-elements:the-td-element"><a href="#the-td-element">td</a></code>,
  <code id="the-list-of-active-formatting-elements:the-th-element"><a href="#the-th-element">th</a></code>, and <code id="the-list-of-active-formatting-elements:the-caption-element"><a href="#the-caption-element">caption</a></code> elements, and are used to prevent formatting from
  "leaking" <em>into</em> <code id="the-list-of-active-formatting-elements:applet-2"><a href="#applet">applet</a></code>, <code id="the-list-of-active-formatting-elements:the-object-element-2"><a href="#the-object-element">object</a></code>, <code id="the-list-of-active-formatting-elements:the-marquee-element-2"><a href="#the-marquee-element">marquee</a></code>,
  <code id="the-list-of-active-formatting-elements:the-template-element-2"><a href="#the-template-element">template</a></code>, <code id="the-list-of-active-formatting-elements:the-td-element-2"><a href="#the-td-element">td</a></code>, <code id="the-list-of-active-formatting-elements:the-th-element-2"><a href="#the-th-element">th</a></code>, and <code id="the-list-of-active-formatting-elements:the-caption-element-2"><a href="#the-caption-element">caption</a></code> elements.</p>

  <p>In addition, each element in the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements">list of active formatting elements</a> is associated
  with the token for which it was created, so that further elements can be created for that token if
  necessary.</p>

  <div data-algorithm="">
  <p>When the steps below require the UA to <dfn id="push-onto-the-list-of-active-formatting-elements">push onto the list of active formatting
  elements</dfn> an element <var>element</var>, the UA must perform the following
  steps:</p>

  <ol id="noah"><li><p>If there are already three elements in the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-2">list of active formatting elements</a>
   after the last <a href="#concept-parser-marker" id="the-list-of-active-formatting-elements:concept-parser-marker-2">marker</a>, if any, or anywhere in the
   list if there are no <a href="#concept-parser-marker" id="the-list-of-active-formatting-elements:concept-parser-marker-3">markers</a>, that have the same tag
   name, namespace, and attributes as <var>element</var>, then remove the earliest such
   element from the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-3">list of active formatting elements</a>. For these purposes, the
   attributes must be compared as they were when the elements were created by the parser; two
   elements have the same attributes if all their parsed attributes can be paired such that the two
   attributes in each pair have identical names, namespaces, and values (the order of the attributes
   does not matter).</p>

   <p class="note">This is the Noah's Ark clause. But with three per family instead of two.</p></li><li><p>Add <var>element</var> to the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-4">list of active formatting
   elements</a>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</dfn>,
  the UA must perform the following steps:</p>

  <ol><li><p>If there are no entries in the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-5">list of active formatting elements</a>, then there
   is nothing to reconstruct; stop this algorithm.</p></li><li><p>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-6">list of active formatting
   elements</a> is a <a href="#concept-parser-marker" id="the-list-of-active-formatting-elements:concept-parser-marker-4">marker</a>, or if it is an element
   that is in the <a href="#stack-of-open-elements" id="the-list-of-active-formatting-elements:stack-of-open-elements">stack of open elements</a>, then there is nothing to reconstruct; stop
   this algorithm.</p></li><li><p>Let <var>entry</var> be the last (most recently added) element in the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-7">list
   of active formatting elements</a>.</p></li><li><p><i>Rewind</i>: If there are no entries before <var>entry</var> in the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-8">list
   of active formatting elements</a>, then jump to the step labeled <i>create</i>.</p></li><li><p>Let <var>entry</var> be the entry one earlier than <var>entry</var> in
   the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-9">list of active formatting elements</a>.</p></li><li><p>If <var>entry</var> is neither a <a href="#concept-parser-marker" id="the-list-of-active-formatting-elements:concept-parser-marker-5">marker</a> nor an element that is also in the <a href="#stack-of-open-elements" id="the-list-of-active-formatting-elements:stack-of-open-elements-2">stack of
   open elements</a>, go to the step labeled <i>rewind</i>.</p></li><li><p><i>Advance</i>: Let <var>entry</var> be the element one later than <var>entry</var> in the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-10">list of active formatting elements</a>.</p></li><li><p><i>Create</i>: <a href="#insert-an-html-element" id="the-list-of-active-formatting-elements:insert-an-html-element">Insert an HTML element</a> for the token for which the element
   <var>entry</var> was created, to obtain <var>new element</var>.</p></li><li><p>Replace the entry for <var>entry</var> in the list with an entry for <var>new element</var>.</p></li><li><p>If the entry for <var>new element</var> in the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-11">list of active formatting
   elements</a> is not the last entry in the list, return to the step labeled
   <i>advance</i>.</p></li></ol>
  </div>

  <p>This has the effect of reopening all the formatting elements that were opened in the current
  body, cell, or caption (whichever is youngest) that haven't been explicitly closed.</p>

  <p class="note">The way this specification is written, the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-12">list of active formatting
  elements</a> always consists of elements in chronological order with the least recently added
  element first and the most recently added element last (except for while steps 7 to 10 of the
  above algorithm are being executed, of course).</p>

  <div data-algorithm="">
  <p>When the steps below require the UA to <dfn id="clear-the-list-of-active-formatting-elements-up-to-the-last-marker">clear the list of active formatting elements up to
  the last marker</dfn>, the UA must perform the following steps:</p>

  <ol><li><p>Let <var>entry</var> be the last (most recently added) entry in the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-13">list of
   active formatting elements</a>.</p></li><li><p>Remove <var>entry</var> from the <a href="#list-of-active-formatting-elements" id="the-list-of-active-formatting-elements:list-of-active-formatting-elements-14">list of active formatting
   elements</a>.</p></li><li><p>If <var>entry</var> was a <a href="#concept-parser-marker" id="the-list-of-active-formatting-elements:concept-parser-marker-6">marker</a>,
   then stop the algorithm at this point. The list has been cleared up to the last <a href="#concept-parser-marker" id="the-list-of-active-formatting-elements:concept-parser-marker-7">marker</a>.</p></li><li><p>Go to step 1.</p></li></ol>
  </div>


  <h5 id="the-element-pointers"><span class="secno">13.2.4.4</span> The element pointers<a href="#the-element-pointers" class="self-link"></a></h5>

  <p>Initially, the <dfn id="head-element-pointer"><code>head</code> element pointer</dfn> and the <dfn id="form-element-pointer"><code>form</code> element pointer</dfn> are both null.</p>

  <p>Once a <code id="the-element-pointers:the-head-element"><a href="#the-head-element">head</a></code> element has been parsed (whether implicitly or explicitly) the
  <a href="#head-element-pointer" id="the-element-pointers:head-element-pointer"><code>head</code> element pointer</a> gets set to point to this node.</p>

  <p>The <a href="#form-element-pointer" id="the-element-pointers:form-element-pointer"><code>form</code> element pointer</a> points to the last
  <code id="the-element-pointers:the-form-element"><a href="#the-form-element">form</a></code> element that was opened and whose end tag has not yet been seen. It is used to
  make form controls associate with forms in the face of dramatically bad markup, for historical
  reasons. It is ignored inside <code id="the-element-pointers:the-template-element"><a href="#the-template-element">template</a></code> elements.</p>


  <h5 id="other-parsing-state-flags"><span class="secno">13.2.4.5</span> Other parsing state flags<a href="#other-parsing-state-flags" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>The <dfn id="scripting-flag">scripting flag</dfn> is set to "enabled" if <a href="#concept-n-script" id="other-parsing-state-flags:concept-n-script">scripting
  was enabled</a> for the <code id="other-parsing-state-flags:document"><a href="#document">Document</a></code> with which the parser is associated when the
  parser was created, and "disabled" otherwise.</p>
  </div>

  <p class="note">The <a href="#scripting-flag" id="other-parsing-state-flags:scripting-flag">scripting flag</a> can be enabled even when the parser was created as
  part of the <a href="#html-fragment-parsing-algorithm" id="other-parsing-state-flags:html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>, even though <code id="other-parsing-state-flags:the-script-element"><a href="#the-script-element">script</a></code> elements
  don't execute in that case.</p>

  <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is created. It is set to "not
  ok" after certain tokens are seen.</p>

  


  

  <h4 id="tokenization"><span class="secno">13.2.5</span> <dfn>Tokenization</dfn><a href="#tokenization" class="self-link"></a></h4>

  <p>Implementations must act as if they used the following state machine to tokenize HTML. The
  state machine must start in the <a href="#data-state" id="tokenization:data-state">data state</a>. Most states consume a single character,
  which may have various side-effects, and either switches the state machine to a new state to
  <a href="#reconsume" id="tokenization:reconsume">reconsume</a> the <a href="#current-input-character" id="tokenization:current-input-character">current input character</a>, or switches it to a new state to
  consume the <a href="#next-input-character" id="tokenization:next-input-character">next character</a>, or stays in the same state
  to consume the next character. Some states have more complicated behavior and can consume several
  characters before switching to another state. In some cases, the tokenizer state is also changed
  by the tree construction stage.</p>

  <p>When a state says to <dfn id="reconsume">reconsume</dfn> a matched character in a specified state, that means
  to switch to that state, but when it attempts to consume the <a href="#next-input-character" id="tokenization:next-input-character-2">next input character</a>,
  provide it with the <a href="#current-input-character" id="tokenization:current-input-character-2">current input character</a> instead.</p>

  <p data-var-scope="">The exact behavior of certain states depends on the <a href="#insertion-mode" id="tokenization:insertion-mode">insertion mode</a> and the
  <a href="#stack-of-open-elements" id="tokenization:stack-of-open-elements">stack of open elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary buffer</var></dfn> to track progress, and the <a href="#character-reference-state" id="tokenization:character-reference-state">character reference
  state</a> uses a <dfn id="return-state"><var>return state</var></dfn> to return to the
  state it was invoked from.</p>

  <p>The output of the tokenization step is a series of zero or more of the following tokens:
  DOCTYPE, start tag, end tag, comment, character, end-of-file. DOCTYPE tokens have a name, a public
  identifier, a system identifier, and a <dfn id="force-quirks-flag"><i>force-quirks flag</i></dfn>. When a DOCTYPE token
  is created, its name, public identifier, and system identifier must be marked as missing (which is
  a distinct state from the empty string), and the <i id="tokenization:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> must be set to
  <i>off</i> (its other state is <i>on</i>). Start and end tag tokens have a tag name, a <dfn id="self-closing-flag">self-closing flag</dfn>, and a list of attributes, each of which has a
  name and a value. When a start or end tag token is created, its <i id="tokenization:self-closing-flag"><a href="#self-closing-flag">self-closing flag</a></i> must be unset (its other state is that it be set), and its attributes
  list must be empty. Comment and character tokens have data.</p>

  <p>When a token is emitted, it must immediately be handled by the <a href="#tree-construction" id="tokenization:tree-construction">tree construction</a>
  stage. The tree construction stage can affect the state of the tokenization stage, and can insert
  additional characters into the stream. (For example, the <code id="tokenization:the-script-element"><a href="#the-script-element">script</a></code> element can result in
  scripts executing and using the <a href="#dynamic-markup-insertion" id="tokenization:dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert characters
  into the stream being tokenized.)</p>

  <p class="note">Creating a token and emitting it are distinct actions. It is possible for a token
  to be created but implicitly abandoned (never emitted), e.g. if the file ends unexpectedly while
  processing the characters that are being parsed into a start tag token.</p>

  <div data-algorithm="">
  <p>When a start tag token is emitted with its <i id="tokenization:self-closing-flag-2"><a href="#self-closing-flag">self-closing flag</a></i> set, if the flag is not
  <dfn id="acknowledge-self-closing-flag">acknowledged</dfn> when it is processed by the tree
  construction stage, that is a <a href="#parse-error-non-void-html-element-start-tag-with-trailing-solidus" id="tokenization:parse-error-non-void-html-element-start-tag-with-trailing-solidus">non-void-html-element-start-tag-with-trailing-solidus</a>
  <a href="#parse-errors" id="tokenization:parse-errors">parse error</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When an end tag token is emitted with attributes, that is an <a href="#parse-error-end-tag-with-attributes" id="tokenization:parse-error-end-tag-with-attributes">end-tag-with-attributes</a> <a href="#parse-errors" id="tokenization:parse-errors-2">parse
  error</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When an end tag token is emitted with its <i id="tokenization:self-closing-flag-3"><a href="#self-closing-flag">self-closing flag</a></i>
  set, that is an <a href="#parse-error-end-tag-with-trailing-solidus" id="tokenization:parse-error-end-tag-with-trailing-solidus">end-tag-with-trailing-solidus</a>
  <a href="#parse-errors" id="tokenization:parse-errors-3">parse error</a>.</p>
  </div>

  <div data-algorithm="">
  <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose tag name matches the tag name
  of the last start tag to have been emitted from this tokenizer, if any. If no start tag has been
  emitted from this tokenizer, then no end tag token is appropriate.</p>
  </div>

  <div data-algorithm="">
  <p>A <a href="#syntax-charref" id="tokenization:syntax-charref">character reference</a> is said to be <dfn id="charref-in-attribute">consumed as part of an attribute</dfn> if the <var id="tokenization:return-state"><a href="#return-state">return state</a></var> is either <a href="#attribute-value-(double-quoted)-state" id="tokenization:attribute-value-(double-quoted)-state">attribute value (double-quoted) state</a>,
  <a href="#attribute-value-(single-quoted)-state" id="tokenization:attribute-value-(single-quoted)-state">attribute value (single-quoted) state</a>, or <a href="#attribute-value-(unquoted)-state" id="tokenization:attribute-value-(unquoted)-state">attribute value (unquoted)
  state</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When a state says to <dfn id="flush-code-points-consumed-as-a-character-reference">flush code points consumed as a character reference</dfn>, it means
  that for each <a id="tokenization:code-point" href="https://infra.spec.whatwg.org/#code-point" data-x-internal="code-point">code point</a> in the <var id="tokenization:temporary-buffer"><a href="#temporary-buffer">temporary
  buffer</a></var> (in the order they were added to the buffer), the user agent must append the code point
  from the buffer to the current attribute's value if the character reference was <a href="#charref-in-attribute" id="tokenization:charref-in-attribute">consumed as part of an attribute</a>, or emit the code point as a
  character token otherwise.</p>
  </div>

  <div data-algorithm="">
  <p id="check-parser-pause-flag">Before each step of the tokenizer, the user agent must first check
  the <a href="#parser-pause-flag" id="tokenization:parser-pause-flag">parser pause flag</a>. If it is true, then the tokenizer must abort the processing of
  any nested invocations of the tokenizer, yielding control back to the caller.</p>
  </div>

  <p>The tokenizer state machine consists of the states defined in the following subsections.</p>


  


  <h5 id="data-state"><span class="secno">13.2.5.1</span> <dfn>Data state</dfn><a href="#data-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="data-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt><dd>Set the <var id="data-state:return-state"><a href="#return-state">return state</a></var> to the <a href="#data-state" id="data-state:data-state">data state</a>.
   Switch to the <a href="#character-reference-state" id="data-state:character-reference-state">character reference state</a>.</dd><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#tag-open-state" id="data-state:tag-open-state">tag open state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="data-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="data-state:parse-errors">parse
   error</a>. Emit the <a href="#current-input-character" id="data-state:current-input-character">current input character</a> as a character token.</dd><dt>EOF</dt><dd>Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Emit the <a href="#current-input-character" id="data-state:current-input-character-2">current input character</a> as a character token.</dd></dl>
  </div>


  <h5 id="rcdata-state"><span class="secno">13.2.5.2</span> <dfn>RCDATA state</dfn><a href="#rcdata-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="rcdata-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt><dd>Set the <var id="rcdata-state:return-state"><a href="#return-state">return state</a></var> to the <a href="#rcdata-state" id="rcdata-state:rcdata-state">RCDATA state</a>.
   Switch to the <a href="#character-reference-state" id="rcdata-state:character-reference-state">character reference state</a>.</dd><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#rcdata-less-than-sign-state" id="rcdata-state:rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="rcdata-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="rcdata-state:parse-errors">parse
   error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd><dt>EOF</dt><dd>Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Emit the <a href="#current-input-character" id="rcdata-state:current-input-character">current input character</a> as a character token.</dd></dl>
  </div>


  <h5 id="rawtext-state"><span class="secno">13.2.5.3</span> <dfn>RAWTEXT state</dfn><a href="#rawtext-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="rawtext-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#rawtext-less-than-sign-state" id="rawtext-state:rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="rawtext-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="rawtext-state:parse-errors">parse
   error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd><dt>EOF</dt><dd>Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Emit the <a href="#current-input-character" id="rawtext-state:current-input-character">current input character</a> as a character token.</dd></dl>
  </div>


  <h5 id="script-data-state"><span class="secno">13.2.5.4</span> <dfn>Script data state</dfn><a href="#script-data-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#script-data-less-than-sign-state" id="script-data-state:script-data-less-than-sign-state">script data less-than sign state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="script-data-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="script-data-state:parse-errors">parse
   error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd><dt>EOF</dt><dd>Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Emit the <a href="#current-input-character" id="script-data-state:current-input-character">current input character</a> as a character token.</dd></dl>
  </div>


  <h5 id="plaintext-state"><span class="secno">13.2.5.5</span> <dfn>PLAINTEXT state</dfn><a href="#plaintext-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="plaintext-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="plaintext-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="plaintext-state:parse-errors">parse
   error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd><dt>EOF</dt><dd>Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Emit the <a href="#current-input-character" id="plaintext-state:current-input-character">current input character</a> as a character token.</dd></dl>
  </div>


  <h5 id="tag-open-state"><span class="secno">13.2.5.6</span> <dfn>Tag open state</dfn><a href="#tag-open-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="tag-open-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt><dd>Switch to the <a href="#markup-declaration-open-state" id="tag-open-state:markup-declaration-open-state">markup declaration open state</a>.</dd><dt>U+002F SOLIDUS (/)</dt><dd>Switch to the <a href="#end-tag-open-state" id="tag-open-state:end-tag-open-state">end tag open state</a>.</dd><dt><a id="tag-open-state:ascii-letters" href="https://infra.spec.whatwg.org/#ascii-alpha" data-x-internal="ascii-letters">ASCII alpha</a></dt><dd>Create a new start tag token, set its tag name to the empty string. <a href="#reconsume" id="tag-open-state:reconsume">Reconsume</a> in
   the <a href="#tag-name-state" id="tag-open-state:tag-name-state">tag name state</a>.

   </dd><dt>U+003F QUESTION MARK (?)</dt><dd>This is an <a href="#parse-error-unexpected-question-mark-instead-of-tag-name" id="tag-open-state:parse-error-unexpected-question-mark-instead-of-tag-name">unexpected-question-mark-instead-of-tag-name</a>
   <a href="#parse-errors" id="tag-open-state:parse-errors">parse error</a>. Create a comment token whose data is the empty string.
   <a href="#reconsume" id="tag-open-state:reconsume-2">Reconsume</a> in the <a href="#bogus-comment-state" id="tag-open-state:bogus-comment-state">bogus comment state</a>.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-before-tag-name" id="tag-open-state:parse-error-eof-before-tag-name">eof-before-tag-name</a>
   <a href="#parse-errors" id="tag-open-state:parse-errors-2">parse error</a>. Emit a U+003C LESS-THAN SIGN character token and an end-of-file
   token.</dd><dt>Anything else</dt><dd>This is an <a href="#parse-error-invalid-first-character-of-tag-name" id="tag-open-state:parse-error-invalid-first-character-of-tag-name">invalid-first-character-of-tag-name</a>
   <a href="#parse-errors" id="tag-open-state:parse-errors-3">parse error</a>. Emit a U+003C LESS-THAN SIGN character token. <a href="#reconsume" id="tag-open-state:reconsume-3">Reconsume</a> in
   the <a href="#data-state" id="tag-open-state:data-state">data state</a>.</dd></dl>
  </div>

  <h5 id="end-tag-open-state"><span class="secno">13.2.5.7</span> <dfn>End tag open state</dfn><a href="#end-tag-open-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="end-tag-open-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a id="end-tag-open-state:ascii-letters" href="https://infra.spec.whatwg.org/#ascii-alpha" data-x-internal="ascii-letters">ASCII alpha</a></dt><dd>Create a new end tag token, set its tag name to the empty string. <a href="#reconsume" id="end-tag-open-state:reconsume">Reconsume</a> in
   the <a href="#tag-name-state" id="end-tag-open-state:tag-name-state">tag name state</a>.

   </dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is a <a href="#parse-error-missing-end-tag-name" id="end-tag-open-state:parse-error-missing-end-tag-name">missing-end-tag-name</a>
   <a href="#parse-errors" id="end-tag-open-state:parse-errors">parse error</a>. Switch to the <a href="#data-state" id="end-tag-open-state:data-state">data state</a>.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-before-tag-name" id="end-tag-open-state:parse-error-eof-before-tag-name">eof-before-tag-name</a>
   <a href="#parse-errors" id="end-tag-open-state:parse-errors-2">parse error</a>. Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
   character token and an end-of-file token.

   </dd><dt>Anything else</dt><dd>This is an <a href="#parse-error-invalid-first-character-of-tag-name" id="end-tag-open-state:parse-error-invalid-first-character-of-tag-name">invalid-first-character-of-tag-name</a>
   <a href="#parse-errors" id="end-tag-open-state:parse-errors-3">parse error</a>. Create a comment token whose data is the empty string.
   <a href="#reconsume" id="end-tag-open-state:reconsume-2">Reconsume</a> in the <a href="#bogus-comment-state" id="end-tag-open-state:bogus-comment-state">bogus comment state</a>.</dd></dl>
  </div>


  <h5 id="tag-name-state"><span class="secno">13.2.5.8</span> <dfn>Tag name state</dfn><a href="#tag-name-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="tag-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Switch to the <a href="#before-attribute-name-state" id="tag-name-state:before-attribute-name-state">before attribute name state</a>.</dd><dt>U+002F SOLIDUS (/)</dt><dd>Switch to the <a href="#self-closing-start-tag-state" id="tag-name-state:self-closing-start-tag-state">self-closing start tag state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="tag-name-state:data-state">data state</a>. Emit the current tag token.</dd><dt><a id="tag-name-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Append the lowercase version of the <a href="#current-input-character" id="tag-name-state:current-input-character">current input character</a> (add 0x0020 to the
   character's code point) to the current tag token's tag name.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="tag-name-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="tag-name-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current tag token's tag
   name.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-tag" id="tag-name-state:parse-error-eof-in-tag">eof-in-tag</a> <a href="#parse-errors" id="tag-name-state:parse-errors-2">parse error</a>.
   Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="tag-name-state:current-input-character-2">current input character</a> to the current tag token's tag name.</dd></dl>
  </div>


  <h5 id="rcdata-less-than-sign-state"><span class="secno">13.2.5.9</span> <dfn>RCDATA less-than sign state</dfn><a href="#rcdata-less-than-sign-state" class="self-link"></a></h5>
  

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="rcdata-less-than-sign-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002F SOLIDUS (/)</dt><dd>Set the <var id="rcdata-less-than-sign-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch to
   the <a href="#rcdata-end-tag-open-state" id="rcdata-less-than-sign-state:rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token. <a href="#reconsume" id="rcdata-less-than-sign-state:reconsume">Reconsume</a> in the <a href="#rcdata-state" id="rcdata-less-than-sign-state:rcdata-state">RCDATA
   state</a>.</dd></dl>
  </div>


  <h5 id="rcdata-end-tag-open-state"><span class="secno">13.2.5.10</span> <dfn>RCDATA end tag open state</dfn><a href="#rcdata-end-tag-open-state" class="self-link"></a></h5>
  

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="rcdata-end-tag-open-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a id="rcdata-end-tag-open-state:ascii-letters" href="https://infra.spec.whatwg.org/#ascii-alpha" data-x-internal="ascii-letters">ASCII alpha</a></dt><dd>Create a new end tag token, set its tag name to the empty string. <a href="#reconsume" id="rcdata-end-tag-open-state:reconsume">Reconsume</a> in
   the <a href="#rcdata-end-tag-name-state" id="rcdata-end-tag-open-state:rcdata-end-tag-name-state">RCDATA end tag name state</a>.

   </dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token.
   <a href="#reconsume" id="rcdata-end-tag-open-state:reconsume-2">Reconsume</a> in the <a href="#rcdata-state" id="rcdata-end-tag-open-state:rcdata-state">RCDATA state</a>.</dd></dl>
  </div>


  <h5 id="rcdata-end-tag-name-state"><span class="secno">13.2.5.11</span> <dfn>RCDATA end tag name state</dfn><a href="#rcdata-end-tag-name-state" class="self-link"></a></h5>
  

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="rcdata-end-tag-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="rcdata-end-tag-name-state:appropriate-end-tag-token">appropriate end tag token</a>, then switch to the
   <a href="#before-attribute-name-state" id="rcdata-end-tag-name-state:before-attribute-name-state">before attribute name state</a>. Otherwise, treat it as per the "anything else" entry
   below.</dd><dt>U+002F SOLIDUS (/)</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="rcdata-end-tag-name-state:appropriate-end-tag-token-2">appropriate end tag token</a>, then switch to the
   <a href="#self-closing-start-tag-state" id="rcdata-end-tag-name-state:self-closing-start-tag-state">self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry
   below.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="rcdata-end-tag-name-state:appropriate-end-tag-token-3">appropriate end tag token</a>, then switch to the
   <a href="#data-state" id="rcdata-end-tag-name-state:data-state">data state</a> and emit the current tag token. Otherwise, treat it as per the "anything
   else" entry below.</dd><dt><a id="rcdata-end-tag-name-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Append the lowercase version of the <a href="#current-input-character" id="rcdata-end-tag-name-state:current-input-character">current input character</a> (add 0x0020 to the
   character's code point) to the current tag token's tag name. Append the <a href="#current-input-character" id="rcdata-end-tag-name-state:current-input-character-2">current input
   character</a> to the <var id="rcdata-end-tag-name-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var>.</dd><dt><a id="rcdata-end-tag-name-state:lowercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-lower-alpha" data-x-internal="lowercase-ascii-letters">ASCII lower alpha</a></dt><dd>Append the <a href="#current-input-character" id="rcdata-end-tag-name-state:current-input-character-3">current input character</a> to the current tag token's tag name. Append
   the <a href="#current-input-character" id="rcdata-end-tag-name-state:current-input-character-4">current input character</a> to the <var id="rcdata-end-tag-name-state:temporary-buffer-2"><a href="#temporary-buffer">temporary
   buffer</a></var>.</dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and a
   character token for each of the characters in the <var id="rcdata-end-tag-name-state:temporary-buffer-3"><a href="#temporary-buffer">temporary
   buffer</a></var> (in the order they were added to the buffer). <a href="#reconsume" id="rcdata-end-tag-name-state:reconsume">Reconsume</a> in the
   <a href="#rcdata-state" id="rcdata-end-tag-name-state:rcdata-state">RCDATA state</a>.</dd></dl>
  </div>


  <h5 id="rawtext-less-than-sign-state"><span class="secno">13.2.5.12</span> <dfn>RAWTEXT less-than sign state</dfn><a href="#rawtext-less-than-sign-state" class="self-link"></a></h5>
  

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="rawtext-less-than-sign-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002F SOLIDUS (/)</dt><dd>Set the <var id="rawtext-less-than-sign-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch to
   the <a href="#rawtext-end-tag-open-state" id="rawtext-less-than-sign-state:rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token. <a href="#reconsume" id="rawtext-less-than-sign-state:reconsume">Reconsume</a> in the <a href="#rawtext-state" id="rawtext-less-than-sign-state:rawtext-state">RAWTEXT
   state</a>.</dd></dl>
  </div>


  <h5 id="rawtext-end-tag-open-state"><span class="secno">13.2.5.13</span> <dfn>RAWTEXT end tag open state</dfn><a href="#rawtext-end-tag-open-state" class="self-link"></a></h5>
  

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="rawtext-end-tag-open-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a id="rawtext-end-tag-open-state:ascii-letters" href="https://infra.spec.whatwg.org/#ascii-alpha" data-x-internal="ascii-letters">ASCII alpha</a></dt><dd>Create a new end tag token, set its tag name to the empty string. <a href="#reconsume" id="rawtext-end-tag-open-state:reconsume">Reconsume</a> in
   the <a href="#rawtext-end-tag-name-state" id="rawtext-end-tag-open-state:rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.

   </dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token.
   <a href="#reconsume" id="rawtext-end-tag-open-state:reconsume-2">Reconsume</a> in the <a href="#rawtext-state" id="rawtext-end-tag-open-state:rawtext-state">RAWTEXT state</a>.</dd></dl>
  </div>


  <h5 id="rawtext-end-tag-name-state"><span class="secno">13.2.5.14</span> <dfn>RAWTEXT end tag name state</dfn><a href="#rawtext-end-tag-name-state" class="self-link"></a></h5>
  

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="rawtext-end-tag-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="rawtext-end-tag-name-state:appropriate-end-tag-token">appropriate end tag token</a>, then switch to the
   <a href="#before-attribute-name-state" id="rawtext-end-tag-name-state:before-attribute-name-state">before attribute name state</a>. Otherwise, treat it as per the "anything else" entry
   below.</dd><dt>U+002F SOLIDUS (/)</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="rawtext-end-tag-name-state:appropriate-end-tag-token-2">appropriate end tag token</a>, then switch to the
   <a href="#self-closing-start-tag-state" id="rawtext-end-tag-name-state:self-closing-start-tag-state">self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry
   below.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="rawtext-end-tag-name-state:appropriate-end-tag-token-3">appropriate end tag token</a>, then switch to the
   <a href="#data-state" id="rawtext-end-tag-name-state:data-state">data state</a> and emit the current tag token. Otherwise, treat it as per the "anything
   else" entry below.</dd><dt><a id="rawtext-end-tag-name-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Append the lowercase version of the <a href="#current-input-character" id="rawtext-end-tag-name-state:current-input-character">current input character</a> (add 0x0020 to the
   character's code point) to the current tag token's tag name. Append the <a href="#current-input-character" id="rawtext-end-tag-name-state:current-input-character-2">current input
   character</a> to the <var id="rawtext-end-tag-name-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var>.</dd><dt><a id="rawtext-end-tag-name-state:lowercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-lower-alpha" data-x-internal="lowercase-ascii-letters">ASCII lower alpha</a></dt><dd>Append the <a href="#current-input-character" id="rawtext-end-tag-name-state:current-input-character-3">current input character</a> to the current tag token's tag name. Append
   the <a href="#current-input-character" id="rawtext-end-tag-name-state:current-input-character-4">current input character</a> to the <var id="rawtext-end-tag-name-state:temporary-buffer-2"><a href="#temporary-buffer">temporary
   buffer</a></var>.</dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and a
   character token for each of the characters in the <var id="rawtext-end-tag-name-state:temporary-buffer-3"><a href="#temporary-buffer">temporary
   buffer</a></var> (in the order they were added to the buffer). <a href="#reconsume" id="rawtext-end-tag-name-state:reconsume">Reconsume</a> in the
   <a href="#rawtext-state" id="rawtext-end-tag-name-state:rawtext-state">RAWTEXT state</a>.</dd></dl>
  </div>


  <h5 id="script-data-less-than-sign-state"><span class="secno">13.2.5.15</span> <dfn>Script data less-than sign state</dfn><a href="#script-data-less-than-sign-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-less-than-sign-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002F SOLIDUS (/)</dt><dd>Set the <var id="script-data-less-than-sign-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch to
   the <a href="#script-data-end-tag-open-state" id="script-data-less-than-sign-state:script-data-end-tag-open-state">script data end tag open state</a>.</dd><dt>U+0021 EXCLAMATION MARK (!)</dt><dd>Switch to the <a href="#script-data-escape-start-state" id="script-data-less-than-sign-state:script-data-escape-start-state">script data escape start state</a>. Emit a U+003C LESS-THAN SIGN
   character token and a U+0021 EXCLAMATION MARK character token.</dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token. <a href="#reconsume" id="script-data-less-than-sign-state:reconsume">Reconsume</a> in the <a href="#script-data-state" id="script-data-less-than-sign-state:script-data-state">script data
   state</a>.</dd></dl>
  </div>


  <h5 id="script-data-end-tag-open-state"><span class="secno">13.2.5.16</span> <dfn>Script data end tag open state</dfn><a href="#script-data-end-tag-open-state" class="self-link"></a></h5>
  

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-end-tag-open-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a id="script-data-end-tag-open-state:ascii-letters" href="https://infra.spec.whatwg.org/#ascii-alpha" data-x-internal="ascii-letters">ASCII alpha</a></dt><dd>Create a new end tag token, set its tag name to the empty string. <a href="#reconsume" id="script-data-end-tag-open-state:reconsume">Reconsume</a> in
   the <a href="#script-data-end-tag-name-state" id="script-data-end-tag-open-state:script-data-end-tag-name-state">script data end tag name state</a>.

   </dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token.
   <a href="#reconsume" id="script-data-end-tag-open-state:reconsume-2">Reconsume</a> in the <a href="#script-data-state" id="script-data-end-tag-open-state:script-data-state">script data state</a>.</dd></dl>
  </div>


  <h5 id="script-data-end-tag-name-state"><span class="secno">13.2.5.17</span> <dfn>Script data end tag name state</dfn><a href="#script-data-end-tag-name-state" class="self-link"></a></h5>
  

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-end-tag-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="script-data-end-tag-name-state:appropriate-end-tag-token">appropriate end tag token</a>, then switch to the
   <a href="#before-attribute-name-state" id="script-data-end-tag-name-state:before-attribute-name-state">before attribute name state</a>. Otherwise, treat it as per the "anything else" entry
   below.</dd><dt>U+002F SOLIDUS (/)</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="script-data-end-tag-name-state:appropriate-end-tag-token-2">appropriate end tag token</a>, then switch to the
   <a href="#self-closing-start-tag-state" id="script-data-end-tag-name-state:self-closing-start-tag-state">self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry
   below.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="script-data-end-tag-name-state:appropriate-end-tag-token-3">appropriate end tag token</a>, then switch to the
   <a href="#data-state" id="script-data-end-tag-name-state:data-state">data state</a> and emit the current tag token. Otherwise, treat it as per the "anything
   else" entry below.</dd><dt><a id="script-data-end-tag-name-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Append the lowercase version of the <a href="#current-input-character" id="script-data-end-tag-name-state:current-input-character">current input character</a> (add 0x0020 to the
   character's code point) to the current tag token's tag name. Append the <a href="#current-input-character" id="script-data-end-tag-name-state:current-input-character-2">current input
   character</a> to the <var id="script-data-end-tag-name-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var>.</dd><dt><a id="script-data-end-tag-name-state:lowercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-lower-alpha" data-x-internal="lowercase-ascii-letters">ASCII lower alpha</a></dt><dd>Append the <a href="#current-input-character" id="script-data-end-tag-name-state:current-input-character-3">current input character</a> to the current tag token's tag name. Append
   the <a href="#current-input-character" id="script-data-end-tag-name-state:current-input-character-4">current input character</a> to the <var id="script-data-end-tag-name-state:temporary-buffer-2"><a href="#temporary-buffer">temporary
   buffer</a></var>.</dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and a
   character token for each of the characters in the <var id="script-data-end-tag-name-state:temporary-buffer-3"><a href="#temporary-buffer">temporary
   buffer</a></var> (in the order they were added to the buffer). <a href="#reconsume" id="script-data-end-tag-name-state:reconsume">Reconsume</a> in the
   <a href="#script-data-state" id="script-data-end-tag-name-state:script-data-state">script data state</a>.</dd></dl>
  </div>


  <h5 id="script-data-escape-start-state"><span class="secno">13.2.5.18</span> <dfn>Script data escape start state</dfn><a href="#script-data-escape-start-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-escape-start-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#script-data-escape-start-dash-state" id="script-data-escape-start-state:script-data-escape-start-dash-state">script data escape start dash state</a>. Emit a U+002D HYPHEN-MINUS
   character token.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="script-data-escape-start-state:reconsume">Reconsume</a> in the <a href="#script-data-state" id="script-data-escape-start-state:script-data-state">script data state</a>.</dd></dl>
  </div>


  <h5 id="script-data-escape-start-dash-state"><span class="secno">13.2.5.19</span> <dfn>Script data escape start dash state</dfn><a href="#script-data-escape-start-dash-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-escape-start-dash-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#script-data-escaped-dash-dash-state" id="script-data-escape-start-dash-state:script-data-escaped-dash-dash-state">script data escaped dash dash state</a>. Emit a U+002D HYPHEN-MINUS
   character token.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="script-data-escape-start-dash-state:reconsume">Reconsume</a> in the <a href="#script-data-state" id="script-data-escape-start-dash-state:script-data-state">script data state</a>.</dd></dl>
  </div>


  <h5 id="script-data-escaped-state"><span class="secno">13.2.5.20</span> <dfn>Script data escaped state</dfn><a href="#script-data-escaped-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-escaped-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#script-data-escaped-dash-state" id="script-data-escaped-state:script-data-escaped-dash-state">script data escaped dash state</a>. Emit a U+002D HYPHEN-MINUS
   character token.</dd><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#script-data-escaped-less-than-sign-state" id="script-data-escaped-state:script-data-escaped-less-than-sign-state">script data escaped less-than sign state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="script-data-escaped-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="script-data-escaped-state:parse-errors">parse
   error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-script-html-comment-like-text" id="script-data-escaped-state:parse-error-eof-in-script-html-comment-like-text">eof-in-script-html-comment-like-text</a>
   <a href="#parse-errors" id="script-data-escaped-state:parse-errors-2">parse error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Emit the <a href="#current-input-character" id="script-data-escaped-state:current-input-character">current input character</a> as a character token.</dd></dl>
  </div>


  <h5 id="script-data-escaped-dash-state"><span class="secno">13.2.5.21</span> <dfn>Script data escaped dash state</dfn><a href="#script-data-escaped-dash-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-escaped-dash-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#script-data-escaped-dash-dash-state" id="script-data-escaped-dash-state:script-data-escaped-dash-dash-state">script data escaped dash dash state</a>. Emit a U+002D HYPHEN-MINUS
   character token.</dd><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#script-data-escaped-less-than-sign-state" id="script-data-escaped-dash-state:script-data-escaped-less-than-sign-state">script data escaped less-than sign state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="script-data-escaped-dash-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="script-data-escaped-dash-state:parse-errors">parse
   error</a>. Switch to the <a href="#script-data-escaped-state" id="script-data-escaped-dash-state:script-data-escaped-state">script data escaped state</a>. Emit a U+FFFD REPLACEMENT
   CHARACTER character token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-script-html-comment-like-text" id="script-data-escaped-dash-state:parse-error-eof-in-script-html-comment-like-text">eof-in-script-html-comment-like-text</a>
   <a href="#parse-errors" id="script-data-escaped-dash-state:parse-errors-2">parse error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Switch to the <a href="#script-data-escaped-state" id="script-data-escaped-dash-state:script-data-escaped-state-2">script data escaped state</a>. Emit the <a href="#current-input-character" id="script-data-escaped-dash-state:current-input-character">current input
   character</a> as a character token.</dd></dl>
  </div>


  <h5 id="script-data-escaped-dash-dash-state"><span class="secno">13.2.5.22</span> <dfn>Script data escaped dash dash state</dfn><a href="#script-data-escaped-dash-dash-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-escaped-dash-dash-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Emit a U+002D HYPHEN-MINUS character token.</dd><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#script-data-escaped-less-than-sign-state" id="script-data-escaped-dash-dash-state:script-data-escaped-less-than-sign-state">script data escaped less-than sign state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#script-data-state" id="script-data-escaped-dash-dash-state:script-data-state">script data state</a>. Emit a U+003E GREATER-THAN SIGN character
   token.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="script-data-escaped-dash-dash-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="script-data-escaped-dash-dash-state:parse-errors">parse
   error</a>. Switch to the <a href="#script-data-escaped-state" id="script-data-escaped-dash-dash-state:script-data-escaped-state">script data escaped state</a>. Emit a U+FFFD REPLACEMENT
   CHARACTER character token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-script-html-comment-like-text" id="script-data-escaped-dash-dash-state:parse-error-eof-in-script-html-comment-like-text">eof-in-script-html-comment-like-text</a>
   <a href="#parse-errors" id="script-data-escaped-dash-dash-state:parse-errors-2">parse error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Switch to the <a href="#script-data-escaped-state" id="script-data-escaped-dash-dash-state:script-data-escaped-state-2">script data escaped state</a>. Emit the <a href="#current-input-character" id="script-data-escaped-dash-dash-state:current-input-character">current input
   character</a> as a character token.</dd></dl>
  </div>


  <h5 id="script-data-escaped-less-than-sign-state"><span class="secno">13.2.5.23</span> <dfn>Script data escaped less-than sign state</dfn><a href="#script-data-escaped-less-than-sign-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-escaped-less-than-sign-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002F SOLIDUS (/)</dt><dd>Set the <var id="script-data-escaped-less-than-sign-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch to
   the <a href="#script-data-escaped-end-tag-open-state" id="script-data-escaped-less-than-sign-state:script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd><dt><a id="script-data-escaped-less-than-sign-state:ascii-letters" href="https://infra.spec.whatwg.org/#ascii-alpha" data-x-internal="ascii-letters">ASCII alpha</a></dt><dd>Set the <var id="script-data-escaped-less-than-sign-state:temporary-buffer-2"><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Emit a
   U+003C LESS-THAN SIGN character token. <a href="#reconsume" id="script-data-escaped-less-than-sign-state:reconsume">Reconsume</a> in the <a href="#script-data-double-escape-start-state" id="script-data-escaped-less-than-sign-state:script-data-double-escape-start-state">script data double
   escape start state</a>.</dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token. <a href="#reconsume" id="script-data-escaped-less-than-sign-state:reconsume-2">Reconsume</a> in the <a href="#script-data-escaped-state" id="script-data-escaped-less-than-sign-state:script-data-escaped-state">script data
   escaped state</a>.</dd></dl>
  </div>


  <h5 id="script-data-escaped-end-tag-open-state"><span class="secno">13.2.5.24</span> <dfn>Script data escaped end tag open state</dfn><a href="#script-data-escaped-end-tag-open-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-escaped-end-tag-open-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a id="script-data-escaped-end-tag-open-state:ascii-letters" href="https://infra.spec.whatwg.org/#ascii-alpha" data-x-internal="ascii-letters">ASCII alpha</a></dt><dd>Create a new end tag token, set its tag name to the empty string. <a href="#reconsume" id="script-data-escaped-end-tag-open-state:reconsume">Reconsume</a> in
   the <a href="#script-data-escaped-end-tag-name-state" id="script-data-escaped-end-tag-open-state:script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token.
   <a href="#reconsume" id="script-data-escaped-end-tag-open-state:reconsume-2">Reconsume</a> in the <a href="#script-data-escaped-state" id="script-data-escaped-end-tag-open-state:script-data-escaped-state">script data escaped state</a>.</dd></dl>
  </div>


  <h5 id="script-data-escaped-end-tag-name-state"><span class="secno">13.2.5.25</span> <dfn>Script data escaped end tag name state</dfn><a href="#script-data-escaped-end-tag-name-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-escaped-end-tag-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="script-data-escaped-end-tag-name-state:appropriate-end-tag-token">appropriate end tag token</a>, then switch to the
   <a href="#before-attribute-name-state" id="script-data-escaped-end-tag-name-state:before-attribute-name-state">before attribute name state</a>. Otherwise, treat it as per the "anything else" entry
   below.</dd><dt>U+002F SOLIDUS (/)</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="script-data-escaped-end-tag-name-state:appropriate-end-tag-token-2">appropriate end tag token</a>, then switch to the
   <a href="#self-closing-start-tag-state" id="script-data-escaped-end-tag-name-state:self-closing-start-tag-state">self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry
   below.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>If the current end tag token is an <a href="#appropriate-end-tag-token" id="script-data-escaped-end-tag-name-state:appropriate-end-tag-token-3">appropriate end tag token</a>, then switch to the
   <a href="#data-state" id="script-data-escaped-end-tag-name-state:data-state">data state</a> and emit the current tag token. Otherwise, treat it as per the "anything
   else" entry below.</dd><dt><a id="script-data-escaped-end-tag-name-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Append the lowercase version of the <a href="#current-input-character" id="script-data-escaped-end-tag-name-state:current-input-character">current input character</a> (add 0x0020 to the
   character's code point) to the current tag token's tag name. Append the <a href="#current-input-character" id="script-data-escaped-end-tag-name-state:current-input-character-2">current input
   character</a> to the <var id="script-data-escaped-end-tag-name-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var>.</dd><dt><a id="script-data-escaped-end-tag-name-state:lowercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-lower-alpha" data-x-internal="lowercase-ascii-letters">ASCII lower alpha</a></dt><dd>Append the <a href="#current-input-character" id="script-data-escaped-end-tag-name-state:current-input-character-3">current input character</a> to the current tag token's tag name. Append
   the <a href="#current-input-character" id="script-data-escaped-end-tag-name-state:current-input-character-4">current input character</a> to the <var id="script-data-escaped-end-tag-name-state:temporary-buffer-2"><a href="#temporary-buffer">temporary
   buffer</a></var>.</dd><dt>Anything else</dt><dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and a
   character token for each of the characters in the <var id="script-data-escaped-end-tag-name-state:temporary-buffer-3"><a href="#temporary-buffer">temporary buffer
   </a></var> (in the order they were added to the buffer). <a href="#reconsume" id="script-data-escaped-end-tag-name-state:reconsume">Reconsume</a> in the <a href="#script-data-escaped-state" id="script-data-escaped-end-tag-name-state:script-data-escaped-state">script
   data escaped state</a>.</dd></dl>
  </div>


  <h5 id="script-data-double-escape-start-state"><span class="secno">13.2.5.26</span> <dfn>Script data double escape start state</dfn><a href="#script-data-double-escape-start-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-double-escape-start-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dt>U+002F SOLIDUS (/)</dt><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>If the <var id="script-data-double-escape-start-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> is the string "<code>script</code>", then switch to the <a href="#script-data-double-escaped-state" id="script-data-double-escape-start-state:script-data-double-escaped-state">script data double escaped state</a>.
   Otherwise, switch to the <a href="#script-data-escaped-state" id="script-data-double-escape-start-state:script-data-escaped-state">script data escaped state</a>. Emit the <a href="#current-input-character" id="script-data-double-escape-start-state:current-input-character">current input
   character</a> as a character token.</dd><dt><a id="script-data-double-escape-start-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Append the lowercase version of the <a href="#current-input-character" id="script-data-double-escape-start-state:current-input-character-2">current input character</a> (add 0x0020 to the
   character's code point) to the <var id="script-data-double-escape-start-state:temporary-buffer-2"><a href="#temporary-buffer">temporary buffer</a></var>. Emit the
   <a href="#current-input-character" id="script-data-double-escape-start-state:current-input-character-3">current input character</a> as a character token.</dd><dt><a id="script-data-double-escape-start-state:lowercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-lower-alpha" data-x-internal="lowercase-ascii-letters">ASCII lower alpha</a></dt><dd>Append the <a href="#current-input-character" id="script-data-double-escape-start-state:current-input-character-4">current input character</a> to the <var id="script-data-double-escape-start-state:temporary-buffer-3"><a href="#temporary-buffer">temporary buffer</a></var>. Emit the <a href="#current-input-character" id="script-data-double-escape-start-state:current-input-character-5">current input character</a> as a character
   token.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="script-data-double-escape-start-state:reconsume">Reconsume</a> in the <a href="#script-data-escaped-state" id="script-data-double-escape-start-state:script-data-escaped-state-2">script data escaped state</a>.</dd></dl>
  </div>


  <h5 id="script-data-double-escaped-state"><span class="secno">13.2.5.27</span> <dfn>Script data double escaped state</dfn><a href="#script-data-double-escaped-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-double-escaped-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#script-data-double-escaped-dash-state" id="script-data-double-escaped-state:script-data-double-escaped-dash-state">script data double escaped dash state</a>. Emit a U+002D HYPHEN-MINUS
   character token.</dd><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#script-data-double-escaped-less-than-sign-state" id="script-data-double-escaped-state:script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign state</a>. Emit a U+003C
   LESS-THAN SIGN character token.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="script-data-double-escaped-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="script-data-double-escaped-state:parse-errors">parse
   error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-script-html-comment-like-text" id="script-data-double-escaped-state:parse-error-eof-in-script-html-comment-like-text">eof-in-script-html-comment-like-text</a>
   <a href="#parse-errors" id="script-data-double-escaped-state:parse-errors-2">parse error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Emit the <a href="#current-input-character" id="script-data-double-escaped-state:current-input-character">current input character</a> as a character token.</dd></dl>
  </div>


  <h5 id="script-data-double-escaped-dash-state"><span class="secno">13.2.5.28</span> <dfn>Script data double escaped dash state</dfn><a href="#script-data-double-escaped-dash-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-double-escaped-dash-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#script-data-double-escaped-dash-dash-state" id="script-data-double-escaped-dash-state:script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>. Emit a U+002D
   HYPHEN-MINUS character token.</dd><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#script-data-double-escaped-less-than-sign-state" id="script-data-double-escaped-dash-state:script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign state</a>. Emit a U+003C
   LESS-THAN SIGN character token.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="script-data-double-escaped-dash-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="script-data-double-escaped-dash-state:parse-errors">parse
   error</a>. Switch to the <a href="#script-data-double-escaped-state" id="script-data-double-escaped-dash-state:script-data-double-escaped-state">script data double escaped state</a>. Emit a U+FFFD
   REPLACEMENT CHARACTER character token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-script-html-comment-like-text" id="script-data-double-escaped-dash-state:parse-error-eof-in-script-html-comment-like-text">eof-in-script-html-comment-like-text</a>
   <a href="#parse-errors" id="script-data-double-escaped-dash-state:parse-errors-2">parse error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Switch to the <a href="#script-data-double-escaped-state" id="script-data-double-escaped-dash-state:script-data-double-escaped-state-2">script data double escaped state</a>. Emit the <a href="#current-input-character" id="script-data-double-escaped-dash-state:current-input-character">current input
   character</a> as a character token.</dd></dl>
  </div>


  <h5 id="script-data-double-escaped-dash-dash-state"><span class="secno">13.2.5.29</span> <dfn>Script data double escaped dash dash state</dfn><a href="#script-data-double-escaped-dash-dash-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-double-escaped-dash-dash-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Emit a U+002D HYPHEN-MINUS character token.</dd><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Switch to the <a href="#script-data-double-escaped-less-than-sign-state" id="script-data-double-escaped-dash-dash-state:script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign state</a>. Emit a U+003C
   LESS-THAN SIGN character token.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#script-data-state" id="script-data-double-escaped-dash-dash-state:script-data-state">script data state</a>. Emit a U+003E GREATER-THAN SIGN character
   token.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="script-data-double-escaped-dash-dash-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="script-data-double-escaped-dash-dash-state:parse-errors">parse
   error</a>. Switch to the <a href="#script-data-double-escaped-state" id="script-data-double-escaped-dash-dash-state:script-data-double-escaped-state">script data double escaped state</a>. Emit a U+FFFD
   REPLACEMENT CHARACTER character token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-script-html-comment-like-text" id="script-data-double-escaped-dash-dash-state:parse-error-eof-in-script-html-comment-like-text">eof-in-script-html-comment-like-text</a>
   <a href="#parse-errors" id="script-data-double-escaped-dash-dash-state:parse-errors-2">parse error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Switch to the <a href="#script-data-double-escaped-state" id="script-data-double-escaped-dash-dash-state:script-data-double-escaped-state-2">script data double escaped state</a>. Emit the <a href="#current-input-character" id="script-data-double-escaped-dash-dash-state:current-input-character">current input
   character</a> as a character token.</dd></dl>
  </div>


  <h5 id="script-data-double-escaped-less-than-sign-state"><span class="secno">13.2.5.30</span> <dfn>Script data double escaped less-than sign state</dfn><a href="#script-data-double-escaped-less-than-sign-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-double-escaped-less-than-sign-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002F SOLIDUS (/)</dt><dd>Set the <var id="script-data-double-escaped-less-than-sign-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch to
   the <a href="#script-data-double-escape-end-state" id="script-data-double-escaped-less-than-sign-state:script-data-double-escape-end-state">script data double escape end state</a>. Emit a U+002F SOLIDUS character token.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="script-data-double-escaped-less-than-sign-state:reconsume">Reconsume</a> in the <a href="#script-data-double-escaped-state" id="script-data-double-escaped-less-than-sign-state:script-data-double-escaped-state">script data double escaped state</a>.</dd></dl>
  </div>


  <h5 id="script-data-double-escape-end-state"><span class="secno">13.2.5.31</span> <dfn>Script data double escape end state</dfn><a href="#script-data-double-escape-end-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="script-data-double-escape-end-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dt>U+002F SOLIDUS (/)</dt><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>If the <var id="script-data-double-escape-end-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> is the string "<code>script</code>", then switch to the <a href="#script-data-escaped-state" id="script-data-double-escape-end-state:script-data-escaped-state">script data escaped state</a>. Otherwise,
   switch to the <a href="#script-data-double-escaped-state" id="script-data-double-escape-end-state:script-data-double-escaped-state">script data double escaped state</a>. Emit the <a href="#current-input-character" id="script-data-double-escape-end-state:current-input-character">current input
   character</a> as a character token.</dd><dt><a id="script-data-double-escape-end-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Append the lowercase version of the <a href="#current-input-character" id="script-data-double-escape-end-state:current-input-character-2">current input character</a> (add 0x0020 to the
   character's code point) to the <var id="script-data-double-escape-end-state:temporary-buffer-2"><a href="#temporary-buffer">temporary buffer</a></var>. Emit the
   <a href="#current-input-character" id="script-data-double-escape-end-state:current-input-character-3">current input character</a> as a character token.</dd><dt><a id="script-data-double-escape-end-state:lowercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-lower-alpha" data-x-internal="lowercase-ascii-letters">ASCII lower alpha</a></dt><dd>Append the <a href="#current-input-character" id="script-data-double-escape-end-state:current-input-character-4">current input character</a> to the <var id="script-data-double-escape-end-state:temporary-buffer-3"><a href="#temporary-buffer">temporary buffer</a></var>. Emit the <a href="#current-input-character" id="script-data-double-escape-end-state:current-input-character-5">current input character</a> as a character
   token.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="script-data-double-escape-end-state:reconsume">Reconsume</a> in the <a href="#script-data-double-escaped-state" id="script-data-double-escape-end-state:script-data-double-escaped-state-2">script data double escaped state</a>.</dd></dl>
  </div>


  <h5 id="before-attribute-name-state"><span class="secno">13.2.5.32</span> <dfn>Before attribute name state</dfn><a href="#before-attribute-name-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="before-attribute-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Ignore the character.</dd><dt>U+002F SOLIDUS (/)</dt><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dt>EOF</dt><dd><a href="#reconsume" id="before-attribute-name-state:reconsume">Reconsume</a> in the <a href="#after-attribute-name-state" id="before-attribute-name-state:after-attribute-name-state">after attribute name state</a>.</dd><dt>U+003D EQUALS SIGN (=)</dt><dd>This is an <a href="#parse-error-unexpected-equals-sign-before-attribute-name" id="before-attribute-name-state:parse-error-unexpected-equals-sign-before-attribute-name">unexpected-equals-sign-before-attribute-name</a>
   <a href="#parse-errors" id="before-attribute-name-state:parse-errors">parse error</a>. Start a new attribute in the current tag token. Set that attribute's
   name to the <a href="#current-input-character" id="before-attribute-name-state:current-input-character">current input character</a>, and its value to the empty string. Switch to
   the <a href="#attribute-name-state" id="before-attribute-name-state:attribute-name-state">attribute name state</a>.</dd><dt>Anything else</dt><dd>Start a new attribute in the current tag token. Set that attribute name and value to the
   empty string. <a href="#reconsume" id="before-attribute-name-state:reconsume-2">Reconsume</a> in the <a href="#attribute-name-state" id="before-attribute-name-state:attribute-name-state-2">attribute name state</a>.</dd></dl>
  </div>


  <h5 id="attribute-name-state"><span class="secno">13.2.5.33</span> <dfn>Attribute name state</dfn><a href="#attribute-name-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="attribute-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dt>U+002F SOLIDUS (/)</dt><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dt>EOF</dt><dd><a href="#reconsume" id="attribute-name-state:reconsume">Reconsume</a> in the <a href="#after-attribute-name-state" id="attribute-name-state:after-attribute-name-state">after attribute name state</a>.</dd><dt>U+003D EQUALS SIGN (=)</dt><dd>Switch to the <a href="#before-attribute-value-state" id="attribute-name-state:before-attribute-value-state">before attribute value state</a>.</dd><dt><a id="attribute-name-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Append the lowercase version of the <a href="#current-input-character" id="attribute-name-state:current-input-character">current input character</a> (add 0x0020 to the
   character's code point) to the current attribute's name.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="attribute-name-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="attribute-name-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's
   name.</dd><dt>U+0022 QUOTATION MARK (")</dt><dt>U+0027 APOSTROPHE (')</dt><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>This is an <a href="#parse-error-unexpected-character-in-attribute-name" id="attribute-name-state:parse-error-unexpected-character-in-attribute-name">unexpected-character-in-attribute-name</a>
   <a href="#parse-errors" id="attribute-name-state:parse-errors-2">parse error</a>. Treat it as per the "anything else" entry below.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="attribute-name-state:current-input-character-2">current input character</a> to the current attribute's name.</dd></dl>

  <p>When the user agent leaves the attribute name state (and before emitting the tag token, if
  appropriate), the complete attribute's name must be compared to the other attributes on the same
  token; if there is already an attribute on the token with the exact same name, then this is a
  <a href="#parse-error-duplicate-attribute" id="attribute-name-state:parse-error-duplicate-attribute">duplicate-attribute</a> <a href="#parse-errors" id="attribute-name-state:parse-errors-3">parse error</a>
  and the new attribute must be removed from the token.</p>
  </div>

  <p class="note">If an attribute is so removed from a token, it, and the value that gets associated
  with it, if any, are never subsequently used by the parser, and are therefore effectively
  discarded. Removing the attribute in this way does not change its status as the "current
  attribute" for the purposes of the tokenizer, however.</p>


  <h5 id="after-attribute-name-state"><span class="secno">13.2.5.34</span> <dfn>After attribute name state</dfn><a href="#after-attribute-name-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="after-attribute-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Ignore the character.</dd><dt>U+002F SOLIDUS (/)</dt><dd>Switch to the <a href="#self-closing-start-tag-state" id="after-attribute-name-state:self-closing-start-tag-state">self-closing start tag state</a>.</dd><dt>U+003D EQUALS SIGN (=)</dt><dd>Switch to the <a href="#before-attribute-value-state" id="after-attribute-name-state:before-attribute-value-state">before attribute value state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="after-attribute-name-state:data-state">data state</a>. Emit the current tag token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-tag" id="after-attribute-name-state:parse-error-eof-in-tag">eof-in-tag</a>
   <a href="#parse-errors" id="after-attribute-name-state:parse-errors">parse error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Start a new attribute in the current tag token. Set that attribute name and value to the
   empty string. <a href="#reconsume" id="after-attribute-name-state:reconsume">Reconsume</a> in the <a href="#attribute-name-state" id="after-attribute-name-state:attribute-name-state">attribute name state</a>.</dd></dl>
  </div>


  <h5 id="before-attribute-value-state"><span class="secno">13.2.5.35</span> <dfn>Before attribute value state</dfn><a href="#before-attribute-value-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="before-attribute-value-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Ignore the character.</dd><dt>U+0022 QUOTATION MARK (")</dt><dd>Switch to the <a href="#attribute-value-(double-quoted)-state" id="before-attribute-value-state:attribute-value-(double-quoted)-state">attribute value (double-quoted) state</a>.</dd><dt>U+0027 APOSTROPHE (')</dt><dd>Switch to the <a href="#attribute-value-(single-quoted)-state" id="before-attribute-value-state:attribute-value-(single-quoted)-state">attribute value (single-quoted) state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is a <a href="#parse-error-missing-attribute-value" id="before-attribute-value-state:parse-error-missing-attribute-value">missing-attribute-value</a>
   <a href="#parse-errors" id="before-attribute-value-state:parse-errors">parse error</a>. Switch to the <a href="#data-state" id="before-attribute-value-state:data-state">data state</a>. Emit the current tag token.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="before-attribute-value-state:reconsume">Reconsume</a> in the <a href="#attribute-value-(unquoted)-state" id="before-attribute-value-state:attribute-value-(unquoted)-state">attribute value (unquoted) state</a>.</dd></dl>
  </div>


  <h5 id="attribute-value-(double-quoted)-state"><span class="secno">13.2.5.36</span> <dfn>Attribute value (double-quoted) state</dfn><a href="#attribute-value-(double-quoted)-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="attribute-value-(double-quoted)-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt><dd>Switch to the <a href="#after-attribute-value-(quoted)-state" id="attribute-value-(double-quoted)-state:after-attribute-value-(quoted)-state">after attribute value (quoted) state</a>.</dd><dt>U+0026 AMPERSAND (&amp;)</dt><dd>Set the <var id="attribute-value-(double-quoted)-state:return-state"><a href="#return-state">return state</a></var> to the <a href="#attribute-value-(double-quoted)-state" id="attribute-value-(double-quoted)-state:attribute-value-(double-quoted)-state">attribute value
   (double-quoted) state</a>. Switch to the <a href="#character-reference-state" id="attribute-value-(double-quoted)-state:character-reference-state">character reference state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="attribute-value-(double-quoted)-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="attribute-value-(double-quoted)-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's
   value.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-tag" id="attribute-value-(double-quoted)-state:parse-error-eof-in-tag">eof-in-tag</a> <a href="#parse-errors" id="attribute-value-(double-quoted)-state:parse-errors-2">parse error</a>.
   Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="attribute-value-(double-quoted)-state:current-input-character">current input character</a> to the current attribute's value.</dd></dl>
  </div>


  <h5 id="attribute-value-(single-quoted)-state"><span class="secno">13.2.5.37</span> <dfn>Attribute value (single-quoted) state</dfn><a href="#attribute-value-(single-quoted)-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="attribute-value-(single-quoted)-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt><dd>Switch to the <a href="#after-attribute-value-(quoted)-state" id="attribute-value-(single-quoted)-state:after-attribute-value-(quoted)-state">after attribute value (quoted) state</a>.</dd><dt>U+0026 AMPERSAND (&amp;)</dt><dd>Set the <var id="attribute-value-(single-quoted)-state:return-state"><a href="#return-state">return state</a></var> to the <a href="#attribute-value-(single-quoted)-state" id="attribute-value-(single-quoted)-state:attribute-value-(single-quoted)-state">attribute value
   (single-quoted) state</a>. Switch to the <a href="#character-reference-state" id="attribute-value-(single-quoted)-state:character-reference-state">character reference state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="attribute-value-(single-quoted)-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="attribute-value-(single-quoted)-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's
   value.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-tag" id="attribute-value-(single-quoted)-state:parse-error-eof-in-tag">eof-in-tag</a> <a href="#parse-errors" id="attribute-value-(single-quoted)-state:parse-errors-2">parse error</a>.
   Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="attribute-value-(single-quoted)-state:current-input-character">current input character</a> to the current attribute's value.</dd></dl>
  </div>


  <h5 id="attribute-value-(unquoted)-state"><span class="secno">13.2.5.38</span> <dfn>Attribute value (unquoted) state</dfn><a href="#attribute-value-(unquoted)-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="attribute-value-(unquoted)-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Switch to the <a href="#before-attribute-name-state" id="attribute-value-(unquoted)-state:before-attribute-name-state">before attribute name state</a>.</dd><dt>U+0026 AMPERSAND (&amp;)</dt><dd>Set the <var id="attribute-value-(unquoted)-state:return-state"><a href="#return-state">return state</a></var> to the <a href="#attribute-value-(unquoted)-state" id="attribute-value-(unquoted)-state:attribute-value-(unquoted)-state">attribute value
   (unquoted) state</a>. Switch to the <a href="#character-reference-state" id="attribute-value-(unquoted)-state:character-reference-state">character reference state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="attribute-value-(unquoted)-state:data-state">data state</a>. Emit the current tag token.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="attribute-value-(unquoted)-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="attribute-value-(unquoted)-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's
   value.</dd><dt>U+0022 QUOTATION MARK (")</dt><dt>U+0027 APOSTROPHE (')</dt><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dt>U+003D EQUALS SIGN (=)</dt><dt>U+0060 GRAVE ACCENT (`)</dt><dd>This is an <a href="#parse-error-unexpected-character-in-unquoted-attribute-value" id="attribute-value-(unquoted)-state:parse-error-unexpected-character-in-unquoted-attribute-value">unexpected-character-in-unquoted-attribute-value</a>
   <a href="#parse-errors" id="attribute-value-(unquoted)-state:parse-errors-2">parse error</a>. Treat it as per the "anything else" entry below.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-tag" id="attribute-value-(unquoted)-state:parse-error-eof-in-tag">eof-in-tag</a>
   <a href="#parse-errors" id="attribute-value-(unquoted)-state:parse-errors-3">parse error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="attribute-value-(unquoted)-state:current-input-character">current input character</a> to the current attribute's value.</dd></dl>
  </div>


  <h5 id="after-attribute-value-(quoted)-state"><span class="secno">13.2.5.39</span> <dfn>After attribute value (quoted) state</dfn><a href="#after-attribute-value-(quoted)-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="after-attribute-value-(quoted)-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Switch to the <a href="#before-attribute-name-state" id="after-attribute-value-(quoted)-state:before-attribute-name-state">before attribute name state</a>.</dd><dt>U+002F SOLIDUS (/)</dt><dd>Switch to the <a href="#self-closing-start-tag-state" id="after-attribute-value-(quoted)-state:self-closing-start-tag-state">self-closing start tag state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="after-attribute-value-(quoted)-state:data-state">data state</a>. Emit the current tag token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-tag" id="after-attribute-value-(quoted)-state:parse-error-eof-in-tag">eof-in-tag</a> <a href="#parse-errors" id="after-attribute-value-(quoted)-state:parse-errors">parse error</a>.
   Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-whitespace-between-attributes" id="after-attribute-value-(quoted)-state:parse-error-missing-whitespace-between-attributes">missing-whitespace-between-attributes</a>
   <a href="#parse-errors" id="after-attribute-value-(quoted)-state:parse-errors-2">parse error</a>. <a href="#reconsume" id="after-attribute-value-(quoted)-state:reconsume">Reconsume</a> in the <a href="#before-attribute-name-state" id="after-attribute-value-(quoted)-state:before-attribute-name-state-2">before attribute name state</a>.
   </dd></dl>
  </div>


  <h5 id="self-closing-start-tag-state"><span class="secno">13.2.5.40</span> <dfn>Self-closing start tag state</dfn><a href="#self-closing-start-tag-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="self-closing-start-tag-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Set the <i id="self-closing-start-tag-state:self-closing-flag"><a href="#self-closing-flag">self-closing flag</a></i> of the current tag token. Switch
   to the <a href="#data-state" id="self-closing-start-tag-state:data-state">data state</a>. Emit the current tag token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-tag" id="self-closing-start-tag-state:parse-error-eof-in-tag">eof-in-tag</a>
   <a href="#parse-errors" id="self-closing-start-tag-state:parse-errors">parse error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is an <a href="#parse-error-unexpected-solidus-in-tag" id="self-closing-start-tag-state:parse-error-unexpected-solidus-in-tag">unexpected-solidus-in-tag</a> <a href="#parse-errors" id="self-closing-start-tag-state:parse-errors-2">parse
   error</a>. <a href="#reconsume" id="self-closing-start-tag-state:reconsume">Reconsume</a> in the <a href="#before-attribute-name-state" id="self-closing-start-tag-state:before-attribute-name-state">before attribute name state</a>.</dd></dl>
  </div>


  <h5 id="bogus-comment-state"><span class="secno">13.2.5.41</span> <dfn>Bogus comment state</dfn><a href="#bogus-comment-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="bogus-comment-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="bogus-comment-state:data-state">data state</a>. Emit the current comment token.</dd><dt>EOF</dt><dd>Emit the comment. Emit an end-of-file token.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="bogus-comment-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="bogus-comment-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the comment token's data.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="bogus-comment-state:current-input-character">current input character</a> to the comment token's data.</dd></dl>
  </div>


  <h5 id="markup-declaration-open-state"><span class="secno">13.2.5.42</span> <dfn>Markup declaration open state</dfn><a href="#markup-declaration-open-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>If the next few characters are:</p>

  <dl class="switch"><dt>Two U+002D HYPHEN-MINUS characters (-)</dt><dd>Consume those two characters, create a comment token whose data is the empty string, and
   switch to the <a href="#comment-start-state" id="markup-declaration-open-state:comment-start-state">comment start state</a>.</dd><dt><a id="markup-declaration-open-state:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the word "DOCTYPE"</dt><dd>Consume those characters and switch to the <a href="#doctype-state" id="markup-declaration-open-state:doctype-state">DOCTYPE state</a>.</dd><dt>The string "[CDATA[" (the five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
   character before and after)</dt><dd>Consume those characters. If there is an <a href="#adjusted-current-node" id="markup-declaration-open-state:adjusted-current-node">adjusted current node</a> and it is not
   an element in the <a id="markup-declaration-open-state:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, then switch to the <a href="#cdata-section-state" id="markup-declaration-open-state:cdata-section-state">CDATA section
   state</a>. Otherwise, this is a <a href="#parse-error-cdata-in-html-content" id="markup-declaration-open-state:parse-error-cdata-in-html-content">cdata-in-html-content</a> <a href="#parse-errors" id="markup-declaration-open-state:parse-errors">parse
   error</a>. Create a comment token whose data is the "[CDATA[" string. Switch to the
   <a href="#bogus-comment-state" id="markup-declaration-open-state:bogus-comment-state">bogus comment state</a>.</dd><dt>Anything else</dt><dd>This is an <a href="#parse-error-incorrectly-opened-comment" id="markup-declaration-open-state:parse-error-incorrectly-opened-comment">incorrectly-opened-comment</a>
   <a href="#parse-errors" id="markup-declaration-open-state:parse-errors-2">parse error</a>. Create a comment token whose data is the empty string. Switch to the
   <a href="#bogus-comment-state" id="markup-declaration-open-state:bogus-comment-state-2">bogus comment state</a> (don't consume anything in the current state).</dd></dl>
  </div>


  <h5 id="comment-start-state"><span class="secno">13.2.5.43</span> <dfn>Comment start state</dfn><a href="#comment-start-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-start-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#comment-start-dash-state" id="comment-start-state:comment-start-dash-state">comment start dash state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is an <a href="#parse-error-abrupt-closing-of-empty-comment" id="comment-start-state:parse-error-abrupt-closing-of-empty-comment">abrupt-closing-of-empty-comment</a> <a href="#parse-errors" id="comment-start-state:parse-errors">parse
   error</a>. Switch to the <a href="#data-state" id="comment-start-state:data-state">data state</a>. Emit the current comment token.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="comment-start-state:reconsume">Reconsume</a> in the <a href="#comment-state" id="comment-start-state:comment-state">comment state</a>.</dd></dl>
  </div>


  <h5 id="comment-start-dash-state"><span class="secno">13.2.5.44</span> <dfn>Comment start dash state</dfn><a href="#comment-start-dash-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-start-dash-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#comment-end-state" id="comment-start-dash-state:comment-end-state">comment end state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is an <a href="#parse-error-abrupt-closing-of-empty-comment" id="comment-start-dash-state:parse-error-abrupt-closing-of-empty-comment">abrupt-closing-of-empty-comment</a> <a href="#parse-errors" id="comment-start-dash-state:parse-errors">parse
   error</a>. Switch to the <a href="#data-state" id="comment-start-dash-state:data-state">data state</a>. Emit the current comment token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-comment" id="comment-start-dash-state:parse-error-eof-in-comment">eof-in-comment</a> <a href="#parse-errors" id="comment-start-dash-state:parse-errors-2">parse
   error</a>. Emit the current comment token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.
   <a href="#reconsume" id="comment-start-dash-state:reconsume">Reconsume</a> in the <a href="#comment-state" id="comment-start-dash-state:comment-state">comment state</a>.</dd></dl>
  </div>


  <h5 id="comment-state"><span class="secno">13.2.5.45</span> <dfn id="comment">Comment state</dfn><a href="#comment-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Append the <a href="#current-input-character" id="comment-state:current-input-character">current input character</a> to the comment token's data. Switch to the
   <a href="#comment-less-than-sign-state" id="comment-state:comment-less-than-sign-state">comment less-than sign state</a>.</dd><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#comment-end-dash-state" id="comment-state:comment-end-dash-state">comment end dash state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="comment-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="comment-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the comment token's data.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-comment" id="comment-state:parse-error-eof-in-comment">eof-in-comment</a> <a href="#parse-errors" id="comment-state:parse-errors-2">parse
   error</a>. Emit the current comment token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="comment-state:current-input-character-2">current input character</a> to the comment token's data.</dd></dl>
  </div>


  <h5 id="comment-less-than-sign-state"><span class="secno">13.2.5.46</span> <dfn>Comment less-than sign state</dfn><a href="#comment-less-than-sign-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-less-than-sign-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt><dd>Append the <a href="#current-input-character" id="comment-less-than-sign-state:current-input-character">current input character</a> to the comment token's data. Switch to the
   <a href="#comment-less-than-sign-bang-state" id="comment-less-than-sign-state:comment-less-than-sign-bang-state">comment less-than sign bang state</a>.</dd><dt>U+003C LESS-THAN SIGN (&lt;)</dt><dd>Append the <a href="#current-input-character" id="comment-less-than-sign-state:current-input-character-2">current input character</a> to the comment token's data.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="comment-less-than-sign-state:reconsume">Reconsume</a> in the <a href="#comment-state" id="comment-less-than-sign-state:comment-state">comment state</a>.</dd></dl>
  </div>


  <h5 id="comment-less-than-sign-bang-state"><span class="secno">13.2.5.47</span> <dfn>Comment less-than sign bang state</dfn><a href="#comment-less-than-sign-bang-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-less-than-sign-bang-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#comment-less-than-sign-bang-dash-state" id="comment-less-than-sign-bang-state:comment-less-than-sign-bang-dash-state">comment less-than sign bang dash state</a>.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="comment-less-than-sign-bang-state:reconsume">Reconsume</a> in the <a href="#comment-state" id="comment-less-than-sign-bang-state:comment-state">comment state</a>.</dd></dl>
  </div>


  <h5 id="comment-less-than-sign-bang-dash-state"><span class="secno">13.2.5.48</span> <dfn>Comment less-than sign bang dash state</dfn><a href="#comment-less-than-sign-bang-dash-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-less-than-sign-bang-dash-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#comment-less-than-sign-bang-dash-dash-state" id="comment-less-than-sign-bang-dash-state:comment-less-than-sign-bang-dash-dash-state">comment less-than sign bang dash dash state</a>.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="comment-less-than-sign-bang-dash-state:reconsume">Reconsume</a> in the <a href="#comment-end-dash-state" id="comment-less-than-sign-bang-dash-state:comment-end-dash-state">comment end dash state</a>.</dd></dl>
  </div>


  <h5 id="comment-less-than-sign-bang-dash-dash-state"><span class="secno">13.2.5.49</span> <dfn>Comment less-than sign bang dash dash state</dfn><a href="#comment-less-than-sign-bang-dash-dash-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-less-than-sign-bang-dash-dash-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dt>EOF</dt><dd><a href="#reconsume" id="comment-less-than-sign-bang-dash-dash-state:reconsume">Reconsume</a> in the <a href="#comment-end-state" id="comment-less-than-sign-bang-dash-dash-state:comment-end-state">comment end state</a>.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-nested-comment" id="comment-less-than-sign-bang-dash-dash-state:parse-error-nested-comment">nested-comment</a> <a href="#parse-errors" id="comment-less-than-sign-bang-dash-dash-state:parse-errors">parse
   error</a>. <a href="#reconsume" id="comment-less-than-sign-bang-dash-dash-state:reconsume-2">Reconsume</a> in the <a href="#comment-end-state" id="comment-less-than-sign-bang-dash-dash-state:comment-end-state-2">comment end state</a>.</dd></dl>
  </div>


  <h5 id="comment-end-dash-state"><span class="secno">13.2.5.50</span> <dfn>Comment end dash state</dfn><a href="#comment-end-dash-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-end-dash-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Switch to the <a href="#comment-end-state" id="comment-end-dash-state:comment-end-state">comment end state</a>.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-comment" id="comment-end-dash-state:parse-error-eof-in-comment">eof-in-comment</a> <a href="#parse-errors" id="comment-end-dash-state:parse-errors">parse
   error</a>. Emit the current comment token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.
   <a href="#reconsume" id="comment-end-dash-state:reconsume">Reconsume</a> in the <a href="#comment-state" id="comment-end-dash-state:comment-state">comment state</a>.</dd></dl>
  </div>


  <h5 id="comment-end-state"><span class="secno">13.2.5.51</span> <dfn>Comment end state</dfn><a href="#comment-end-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-end-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="comment-end-state:data-state">data state</a>. Emit the current comment token.</dd><dt>U+0021 EXCLAMATION MARK (!)</dt><dd>Switch to the <a href="#comment-end-bang-state" id="comment-end-state:comment-end-bang-state">comment end bang state</a>.</dd><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-comment" id="comment-end-state:parse-error-eof-in-comment">eof-in-comment</a> <a href="#parse-errors" id="comment-end-state:parse-errors">parse
   error</a>. Emit the current comment token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append two U+002D HYPHEN-MINUS characters (-) to the comment token's data.
   <a href="#reconsume" id="comment-end-state:reconsume">Reconsume</a> in the <a href="#comment-state" id="comment-end-state:comment-state">comment state</a>.</dd></dl>
  </div>


  <h5 id="comment-end-bang-state"><span class="secno">13.2.5.52</span> <dfn>Comment end bang state</dfn><a href="#comment-end-bang-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="comment-end-bang-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt><dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021 EXCLAMATION MARK character (!) to
   the comment token's data. Switch to the <a href="#comment-end-dash-state" id="comment-end-bang-state:comment-end-dash-state">comment end dash state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is an <a href="#parse-error-incorrectly-closed-comment" id="comment-end-bang-state:parse-error-incorrectly-closed-comment">incorrectly-closed-comment</a> <a href="#parse-errors" id="comment-end-bang-state:parse-errors">parse
   error</a>. Switch to the <a href="#data-state" id="comment-end-bang-state:data-state">data state</a>. Emit the current comment token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-comment" id="comment-end-bang-state:parse-error-eof-in-comment">eof-in-comment</a> <a href="#parse-errors" id="comment-end-bang-state:parse-errors-2">parse
   error</a>. Emit the current comment token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021 EXCLAMATION MARK character (!) to
   the comment token's data. <a href="#reconsume" id="comment-end-bang-state:reconsume">Reconsume</a> in the <a href="#comment-state" id="comment-end-bang-state:comment-state">comment state</a>.</dd></dl>
  </div>


  <h5 id="doctype-state"><span class="secno">13.2.5.53</span> <dfn>DOCTYPE state</dfn><a href="#doctype-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="doctype-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Switch to the <a href="#before-doctype-name-state" id="doctype-state:before-doctype-name-state">before DOCTYPE name state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd><a href="#reconsume" id="doctype-state:reconsume">Reconsume</a> in the <a href="#before-doctype-name-state" id="doctype-state:before-doctype-name-state-2">before DOCTYPE name state</a>.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="doctype-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="doctype-state:parse-errors">parse
   error</a>. Create a new DOCTYPE token. Set its <i id="doctype-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. Emit the current token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-whitespace-before-doctype-name" id="doctype-state:parse-error-missing-whitespace-before-doctype-name">missing-whitespace-before-doctype-name</a>
   <a href="#parse-errors" id="doctype-state:parse-errors-2">parse error</a>. <a href="#reconsume" id="doctype-state:reconsume-2">Reconsume</a> in the <a href="#before-doctype-name-state" id="doctype-state:before-doctype-name-state-3">before DOCTYPE name state</a>.
   </dd></dl>
  </div>


  <h5 id="before-doctype-name-state"><span class="secno">13.2.5.54</span> <dfn>Before DOCTYPE name state</dfn><a href="#before-doctype-name-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="before-doctype-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Ignore the character.</dd><dt><a id="before-doctype-name-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Create a new DOCTYPE token. Set the token's name to the lowercase version of the
   <a href="#current-input-character" id="before-doctype-name-state:current-input-character">current input character</a> (add 0x0020 to the character's code point). Switch to the
   <a href="#doctype-name-state" id="before-doctype-name-state:doctype-name-state">DOCTYPE name state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="before-doctype-name-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="before-doctype-name-state:parse-errors">parse
   error</a>. Create a new DOCTYPE token. Set the token's name to a U+FFFD REPLACEMENT CHARACTER
   character. Switch to the <a href="#doctype-name-state" id="before-doctype-name-state:doctype-name-state-2">DOCTYPE name state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is a <a href="#parse-error-missing-doctype-name" id="before-doctype-name-state:parse-error-missing-doctype-name">missing-doctype-name</a>
   <a href="#parse-errors" id="before-doctype-name-state:parse-errors-2">parse error</a>. Create a new DOCTYPE token. Set its <i id="before-doctype-name-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> to <i>on</i>. Switch to the <a href="#data-state" id="before-doctype-name-state:data-state">data
   state</a>. Emit the current token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="before-doctype-name-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="before-doctype-name-state:parse-errors-3">parse
   error</a>. Create a new DOCTYPE token. Set its <i id="before-doctype-name-state:force-quirks-flag-2"><a href="#force-quirks-flag"> force-quirks
   flag</a></i> to <i>on</i>. Emit the current token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Create a new DOCTYPE token. Set the token's name to the <a href="#current-input-character" id="before-doctype-name-state:current-input-character-2">current input character</a>.
   Switch to the <a href="#doctype-name-state" id="before-doctype-name-state:doctype-name-state-3">DOCTYPE name state</a>.</dd></dl>
  </div>


  <h5 id="doctype-name-state"><span class="secno">13.2.5.55</span> <dfn>DOCTYPE name state</dfn><a href="#doctype-name-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="doctype-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Switch to the <a href="#after-doctype-name-state" id="doctype-name-state:after-doctype-name-state">after DOCTYPE name state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="doctype-name-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt><a id="doctype-name-state:uppercase-ascii-letters" href="https://infra.spec.whatwg.org/#ascii-upper-alpha" data-x-internal="uppercase-ascii-letters">ASCII upper alpha</a></dt><dd>Append the lowercase version of the <a href="#current-input-character" id="doctype-name-state:current-input-character">current input character</a> (add 0x0020 to the
   character's code point) to the current DOCTYPE token's name.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="doctype-name-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="doctype-name-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
   name.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="doctype-name-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="doctype-name-state:parse-errors-2">parse
   error</a>. Set the current DOCTYPE token's <i id="doctype-name-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="doctype-name-state:current-input-character-2">current input character</a> to the current DOCTYPE token's name.</dd></dl>
  </div>


  <h5 id="after-doctype-name-state"><span class="secno">13.2.5.56</span> <dfn>After DOCTYPE name state</dfn><a href="#after-doctype-name-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="after-doctype-name-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Ignore the character.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="after-doctype-name-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="after-doctype-name-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="after-doctype-name-state:parse-errors">parse
   error</a>. Set the current DOCTYPE token's <i id="after-doctype-name-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>
    <p>If the six characters starting from the <a href="#current-input-character" id="after-doctype-name-state:current-input-character">current input character</a> are an
    <a id="after-doctype-name-state:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the word "PUBLIC", then consume those characters
    and switch to the <a href="#after-doctype-public-keyword-state" id="after-doctype-name-state:after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>

    <p>Otherwise, if the six characters starting from the <a href="#current-input-character" id="after-doctype-name-state:current-input-character-2">current input character</a> are
    an <a id="after-doctype-name-state:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the word "SYSTEM", then consume those
    characters and switch to the <a href="#after-doctype-system-keyword-state" id="after-doctype-name-state:after-doctype-system-keyword-state">after DOCTYPE system keyword state</a>.</p>

    <p>Otherwise, this is an <a href="#parse-error-invalid-character-sequence-after-doctype-name" id="after-doctype-name-state:parse-error-invalid-character-sequence-after-doctype-name">invalid-character-sequence-after-doctype-name</a>
    <a href="#parse-errors" id="after-doctype-name-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's <i id="after-doctype-name-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks
    flag</a></i> to <i>on</i>. <a href="#reconsume" id="after-doctype-name-state:reconsume">Reconsume</a> in the <a href="#bogus-doctype-state" id="after-doctype-name-state:bogus-doctype-state">bogus DOCTYPE state</a>.</p>
   </dd></dl>
  </div>


  <h5 id="after-doctype-public-keyword-state"><span class="secno">13.2.5.57</span> <dfn>After DOCTYPE public keyword state</dfn><a href="#after-doctype-public-keyword-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="after-doctype-public-keyword-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Switch to the <a href="#before-doctype-public-identifier-state" id="after-doctype-public-keyword-state:before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd><dt>U+0022 QUOTATION MARK (")</dt><dd>This is a <a href="#parse-error-missing-whitespace-after-doctype-public-keyword" id="after-doctype-public-keyword-state:parse-error-missing-whitespace-after-doctype-public-keyword">missing-whitespace-after-doctype-public-keyword</a>
   <a href="#parse-errors" id="after-doctype-public-keyword-state:parse-errors">parse error</a>. Set the current DOCTYPE token's public identifier to the empty string (not
   missing), then switch to the <a href="#doctype-public-identifier-(double-quoted)-state" id="after-doctype-public-keyword-state:doctype-public-identifier-(double-quoted)-state">DOCTYPE public identifier (double-quoted) state</a>.</dd><dt>U+0027 APOSTROPHE (')</dt><dd>This is a <a href="#parse-error-missing-whitespace-after-doctype-public-keyword" id="after-doctype-public-keyword-state:parse-error-missing-whitespace-after-doctype-public-keyword-2">missing-whitespace-after-doctype-public-keyword</a>
   <a href="#parse-errors" id="after-doctype-public-keyword-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's public identifier to the empty string (not
   missing), then switch to the <a href="#doctype-public-identifier-(single-quoted)-state" id="after-doctype-public-keyword-state:doctype-public-identifier-(single-quoted)-state">DOCTYPE public identifier (single-quoted) state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is a <a href="#parse-error-missing-doctype-public-identifier" id="after-doctype-public-keyword-state:parse-error-missing-doctype-public-identifier">missing-doctype-public-identifier</a> <a href="#parse-errors" id="after-doctype-public-keyword-state:parse-errors-3">parse
   error</a>. Set the current DOCTYPE token's <i id="after-doctype-public-keyword-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Switch to the <a href="#data-state" id="after-doctype-public-keyword-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="after-doctype-public-keyword-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="after-doctype-public-keyword-state:parse-errors-4">parse
   error</a>. Set the current DOCTYPE token's <i id="after-doctype-public-keyword-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-quote-before-doctype-public-identifier" id="after-doctype-public-keyword-state:parse-error-missing-quote-before-doctype-public-identifier">missing-quote-before-doctype-public-identifier</a>
   <a href="#parse-errors" id="after-doctype-public-keyword-state:parse-errors-5">parse error</a>. Set the current DOCTYPE token's <i id="after-doctype-public-keyword-state:force-quirks-flag-3"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. <a href="#reconsume" id="after-doctype-public-keyword-state:reconsume">Reconsume</a> in the <a href="#bogus-doctype-state" id="after-doctype-public-keyword-state:bogus-doctype-state">bogus DOCTYPE state</a>.</dd></dl>
  </div>


  <h5 id="before-doctype-public-identifier-state"><span class="secno">13.2.5.58</span> <dfn>Before DOCTYPE public identifier state</dfn><a href="#before-doctype-public-identifier-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="before-doctype-public-identifier-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Ignore the character.</dd><dt>U+0022 QUOTATION MARK (")</dt><dd>Set the current DOCTYPE token's public identifier to the empty string (not missing), then switch to
   the <a href="#doctype-public-identifier-(double-quoted)-state" id="before-doctype-public-identifier-state:doctype-public-identifier-(double-quoted)-state">DOCTYPE public identifier (double-quoted) state</a>.</dd><dt>U+0027 APOSTROPHE (')</dt><dd>Set the current DOCTYPE token's public identifier to the empty string (not missing), then switch to
   the <a href="#doctype-public-identifier-(single-quoted)-state" id="before-doctype-public-identifier-state:doctype-public-identifier-(single-quoted)-state">DOCTYPE public identifier (single-quoted) state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is a <a href="#parse-error-missing-doctype-public-identifier" id="before-doctype-public-identifier-state:parse-error-missing-doctype-public-identifier">missing-doctype-public-identifier</a>
   <a href="#parse-errors" id="before-doctype-public-identifier-state:parse-errors">parse error</a>. Set the current DOCTYPE token's <i id="before-doctype-public-identifier-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. Switch to the <a href="#data-state" id="before-doctype-public-identifier-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="before-doctype-public-identifier-state:parse-error-eof-in-doctype">eof-in-doctype</a>
   <a href="#parse-errors" id="before-doctype-public-identifier-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's <i id="before-doctype-public-identifier-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-quote-before-doctype-public-identifier" id="before-doctype-public-identifier-state:parse-error-missing-quote-before-doctype-public-identifier">missing-quote-before-doctype-public-identifier</a>
   <a href="#parse-errors" id="before-doctype-public-identifier-state:parse-errors-3">parse error</a>. Set the current DOCTYPE token's <i id="before-doctype-public-identifier-state:force-quirks-flag-3"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. <a href="#reconsume" id="before-doctype-public-identifier-state:reconsume">Reconsume</a> in the <a href="#bogus-doctype-state" id="before-doctype-public-identifier-state:bogus-doctype-state">bogus DOCTYPE state</a>.</dd></dl>
  </div>


  <h5 id="doctype-public-identifier-(double-quoted)-state"><span class="secno">13.2.5.59</span> <dfn>DOCTYPE public identifier (double-quoted) state</dfn><a href="#doctype-public-identifier-(double-quoted)-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="doctype-public-identifier-(double-quoted)-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt><dd>Switch to the <a href="#after-doctype-public-identifier-state" id="doctype-public-identifier-(double-quoted)-state:after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="doctype-public-identifier-(double-quoted)-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="doctype-public-identifier-(double-quoted)-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
   public identifier.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is an <a href="#parse-error-abrupt-doctype-public-identifier" id="doctype-public-identifier-(double-quoted)-state:parse-error-abrupt-doctype-public-identifier">abrupt-doctype-public-identifier</a>
   <a href="#parse-errors" id="doctype-public-identifier-(double-quoted)-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's <i id="doctype-public-identifier-(double-quoted)-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. Switch to the <a href="#data-state" id="doctype-public-identifier-(double-quoted)-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="doctype-public-identifier-(double-quoted)-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="doctype-public-identifier-(double-quoted)-state:parse-errors-3">parse
   error</a>. Set the current DOCTYPE token's <i id="doctype-public-identifier-(double-quoted)-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="doctype-public-identifier-(double-quoted)-state:current-input-character">current input character</a> to the current DOCTYPE token's public
   identifier.</dd></dl>
  </div>


  <h5 id="doctype-public-identifier-(single-quoted)-state"><span class="secno">13.2.5.60</span> <dfn>DOCTYPE public identifier (single-quoted) state</dfn><a href="#doctype-public-identifier-(single-quoted)-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="doctype-public-identifier-(single-quoted)-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt><dd>Switch to the <a href="#after-doctype-public-identifier-state" id="doctype-public-identifier-(single-quoted)-state:after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="doctype-public-identifier-(single-quoted)-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="doctype-public-identifier-(single-quoted)-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
   public identifier.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is an <a href="#parse-error-abrupt-doctype-public-identifier" id="doctype-public-identifier-(single-quoted)-state:parse-error-abrupt-doctype-public-identifier">abrupt-doctype-public-identifier</a>
   <a href="#parse-errors" id="doctype-public-identifier-(single-quoted)-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's <i id="doctype-public-identifier-(single-quoted)-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. Switch to the <a href="#data-state" id="doctype-public-identifier-(single-quoted)-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="doctype-public-identifier-(single-quoted)-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="doctype-public-identifier-(single-quoted)-state:parse-errors-3">parse
   error</a>. Set the current DOCTYPE token's <i id="doctype-public-identifier-(single-quoted)-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="doctype-public-identifier-(single-quoted)-state:current-input-character">current input character</a> to the current DOCTYPE token's public
   identifier.</dd></dl>
  </div>


  <h5 id="after-doctype-public-identifier-state"><span class="secno">13.2.5.61</span> <dfn>After DOCTYPE public identifier state</dfn><a href="#after-doctype-public-identifier-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="after-doctype-public-identifier-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state" id="after-doctype-public-identifier-state:between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="after-doctype-public-identifier-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>U+0022 QUOTATION MARK (")</dt><dd>This is a <a href="#parse-error-missing-whitespace-between-doctype-public-and-system-identifiers" id="after-doctype-public-identifier-state:parse-error-missing-whitespace-between-doctype-public-and-system-identifiers">missing-whitespace-between-doctype-public-and-system-identifiers</a>
   <a href="#parse-errors" id="after-doctype-public-identifier-state:parse-errors">parse error</a>. Set the current DOCTYPE token's system identifier to the empty string (not
   missing), then switch to the <a href="#doctype-system-identifier-(double-quoted)-state" id="after-doctype-public-identifier-state:doctype-system-identifier-(double-quoted)-state">DOCTYPE system identifier (double-quoted) state</a>.</dd><dt>U+0027 APOSTROPHE (')</dt><dd>This is a <a href="#parse-error-missing-whitespace-between-doctype-public-and-system-identifiers" id="after-doctype-public-identifier-state:parse-error-missing-whitespace-between-doctype-public-and-system-identifiers-2">missing-whitespace-between-doctype-public-and-system-identifiers</a>
   <a href="#parse-errors" id="after-doctype-public-identifier-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's system identifier to the empty string (not
   missing), then switch to the <a href="#doctype-system-identifier-(single-quoted)-state" id="after-doctype-public-identifier-state:doctype-system-identifier-(single-quoted)-state">DOCTYPE system identifier (single-quoted) state</a>.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="after-doctype-public-identifier-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="after-doctype-public-identifier-state:parse-errors-3">parse
   error</a>. Set the current DOCTYPE token's <i id="after-doctype-public-identifier-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-quote-before-doctype-system-identifier" id="after-doctype-public-identifier-state:parse-error-missing-quote-before-doctype-system-identifier">missing-quote-before-doctype-system-identifier</a>
   <a href="#parse-errors" id="after-doctype-public-identifier-state:parse-errors-4">parse error</a>. Set the current DOCTYPE token's <i id="after-doctype-public-identifier-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. <a href="#reconsume" id="after-doctype-public-identifier-state:reconsume">Reconsume</a> in the <a href="#bogus-doctype-state" id="after-doctype-public-identifier-state:bogus-doctype-state">bogus DOCTYPE state</a>.</dd></dl>
  </div>


  <h5 id="between-doctype-public-and-system-identifiers-state"><span class="secno">13.2.5.62</span> <dfn>Between DOCTYPE public and system identifiers state</dfn><a href="#between-doctype-public-and-system-identifiers-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="between-doctype-public-and-system-identifiers-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Ignore the character.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="between-doctype-public-and-system-identifiers-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>U+0022 QUOTATION MARK (")</dt><dd>Set the current DOCTYPE token's system identifier to the empty string (not missing), then switch to
   the <a href="#doctype-system-identifier-(double-quoted)-state" id="between-doctype-public-and-system-identifiers-state:doctype-system-identifier-(double-quoted)-state">DOCTYPE system identifier (double-quoted) state</a>.</dd><dt>U+0027 APOSTROPHE (')</dt><dd>Set the current DOCTYPE token's system identifier to the empty string (not missing), then switch to
   the <a href="#doctype-system-identifier-(single-quoted)-state" id="between-doctype-public-and-system-identifiers-state:doctype-system-identifier-(single-quoted)-state">DOCTYPE system identifier (single-quoted) state</a>.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="between-doctype-public-and-system-identifiers-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="between-doctype-public-and-system-identifiers-state:parse-errors">parse
   error</a>. Set the current DOCTYPE token's <i id="between-doctype-public-and-system-identifiers-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-quote-before-doctype-system-identifier" id="between-doctype-public-and-system-identifiers-state:parse-error-missing-quote-before-doctype-system-identifier">missing-quote-before-doctype-system-identifier</a>
   <a href="#parse-errors" id="between-doctype-public-and-system-identifiers-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's <i id="between-doctype-public-and-system-identifiers-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. <a href="#reconsume" id="between-doctype-public-and-system-identifiers-state:reconsume">Reconsume</a> in the <a href="#bogus-doctype-state" id="between-doctype-public-and-system-identifiers-state:bogus-doctype-state">bogus DOCTYPE state</a>.</dd></dl>
  </div>


  <h5 id="after-doctype-system-keyword-state"><span class="secno">13.2.5.63</span> <dfn>After DOCTYPE system keyword state</dfn><a href="#after-doctype-system-keyword-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="after-doctype-system-keyword-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Switch to the <a href="#before-doctype-system-identifier-state" id="after-doctype-system-keyword-state:before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd><dt>U+0022 QUOTATION MARK (")</dt><dd>This is a <a href="#parse-error-missing-whitespace-after-doctype-system-keyword" id="after-doctype-system-keyword-state:parse-error-missing-whitespace-after-doctype-system-keyword">missing-whitespace-after-doctype-system-keyword</a>
   <a href="#parse-errors" id="after-doctype-system-keyword-state:parse-errors">parse error</a>. Set the current DOCTYPE token's system identifier to the empty string (not
   missing), then switch to the <a href="#doctype-system-identifier-(double-quoted)-state" id="after-doctype-system-keyword-state:doctype-system-identifier-(double-quoted)-state">DOCTYPE system identifier (double-quoted) state</a>.</dd><dt>U+0027 APOSTROPHE (')</dt><dd>This is a <a href="#parse-error-missing-whitespace-after-doctype-system-keyword" id="after-doctype-system-keyword-state:parse-error-missing-whitespace-after-doctype-system-keyword-2">missing-whitespace-after-doctype-system-keyword</a>
   <a href="#parse-errors" id="after-doctype-system-keyword-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's system identifier to the empty string (not
   missing), then switch to the <a href="#doctype-system-identifier-(single-quoted)-state" id="after-doctype-system-keyword-state:doctype-system-identifier-(single-quoted)-state">DOCTYPE system identifier (single-quoted) state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is a <a href="#parse-error-missing-doctype-system-identifier" id="after-doctype-system-keyword-state:parse-error-missing-doctype-system-identifier">missing-doctype-system-identifier</a>
   <a href="#parse-errors" id="after-doctype-system-keyword-state:parse-errors-3">parse error</a>. Set the current DOCTYPE token's <i id="after-doctype-system-keyword-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. Switch to the <a href="#data-state" id="after-doctype-system-keyword-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="after-doctype-system-keyword-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="after-doctype-system-keyword-state:parse-errors-4">parse
   error</a>. Set the current DOCTYPE token's <i id="after-doctype-system-keyword-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-quote-before-doctype-system-identifier" id="after-doctype-system-keyword-state:parse-error-missing-quote-before-doctype-system-identifier">missing-quote-before-doctype-system-identifier</a>
   <a href="#parse-errors" id="after-doctype-system-keyword-state:parse-errors-5">parse error</a>. Set the current DOCTYPE token's <i id="after-doctype-system-keyword-state:force-quirks-flag-3"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. <a href="#reconsume" id="after-doctype-system-keyword-state:reconsume">Reconsume</a> in the <a href="#bogus-doctype-state" id="after-doctype-system-keyword-state:bogus-doctype-state">bogus DOCTYPE state</a>.</dd></dl>
  </div>


  <h5 id="before-doctype-system-identifier-state"><span class="secno">13.2.5.64</span> <dfn>Before DOCTYPE system identifier state</dfn><a href="#before-doctype-system-identifier-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="before-doctype-system-identifier-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Ignore the character.</dd><dt>U+0022 QUOTATION MARK (")</dt><dd>Set the current DOCTYPE token's system identifier to the empty string (not missing), then switch to
   the <a href="#doctype-system-identifier-(double-quoted)-state" id="before-doctype-system-identifier-state:doctype-system-identifier-(double-quoted)-state">DOCTYPE system identifier (double-quoted) state</a>.</dd><dt>U+0027 APOSTROPHE (')</dt><dd>Set the current DOCTYPE token's system identifier to the empty string (not missing), then switch to
   the <a href="#doctype-system-identifier-(single-quoted)-state" id="before-doctype-system-identifier-state:doctype-system-identifier-(single-quoted)-state">DOCTYPE system identifier (single-quoted) state</a>.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is a <a href="#parse-error-missing-doctype-system-identifier" id="before-doctype-system-identifier-state:parse-error-missing-doctype-system-identifier">missing-doctype-system-identifier</a> <a href="#parse-errors" id="before-doctype-system-identifier-state:parse-errors">parse
   error</a>. Set the current DOCTYPE token's <i id="before-doctype-system-identifier-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Switch to the <a href="#data-state" id="before-doctype-system-identifier-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="before-doctype-system-identifier-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="before-doctype-system-identifier-state:parse-errors-2">parse
   error</a>. Set the current DOCTYPE token's <i id="before-doctype-system-identifier-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-quote-before-doctype-system-identifier" id="before-doctype-system-identifier-state:parse-error-missing-quote-before-doctype-system-identifier">missing-quote-before-doctype-system-identifier</a>
   <a href="#parse-errors" id="before-doctype-system-identifier-state:parse-errors-3">parse error</a>. Set the current DOCTYPE token's <i id="before-doctype-system-identifier-state:force-quirks-flag-3"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. <a href="#reconsume" id="before-doctype-system-identifier-state:reconsume">Reconsume</a> in the <a href="#bogus-doctype-state" id="before-doctype-system-identifier-state:bogus-doctype-state">bogus DOCTYPE state</a>.</dd></dl>
  </div>


  <h5 id="doctype-system-identifier-(double-quoted)-state"><span class="secno">13.2.5.65</span> <dfn>DOCTYPE system identifier (double-quoted) state</dfn><a href="#doctype-system-identifier-(double-quoted)-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="doctype-system-identifier-(double-quoted)-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt><dd>Switch to the <a href="#after-doctype-system-identifier-state" id="doctype-system-identifier-(double-quoted)-state:after-doctype-system-identifier-state">after DOCTYPE system identifier state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="doctype-system-identifier-(double-quoted)-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="doctype-system-identifier-(double-quoted)-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
   system identifier.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is an <a href="#parse-error-abrupt-doctype-system-identifier" id="doctype-system-identifier-(double-quoted)-state:parse-error-abrupt-doctype-system-identifier">abrupt-doctype-system-identifier</a>
   <a href="#parse-errors" id="doctype-system-identifier-(double-quoted)-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's <i id="doctype-system-identifier-(double-quoted)-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. Switch to the <a href="#data-state" id="doctype-system-identifier-(double-quoted)-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="doctype-system-identifier-(double-quoted)-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="doctype-system-identifier-(double-quoted)-state:parse-errors-3">parse
   error</a>. Set the current DOCTYPE token's <i id="doctype-system-identifier-(double-quoted)-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="doctype-system-identifier-(double-quoted)-state:current-input-character">current input character</a> to the current DOCTYPE token's system
   identifier.</dd></dl>
  </div>


  <h5 id="doctype-system-identifier-(single-quoted)-state"><span class="secno">13.2.5.66</span> <dfn>DOCTYPE system identifier (single-quoted) state</dfn><a href="#doctype-system-identifier-(single-quoted)-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="doctype-system-identifier-(single-quoted)-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt><dd>Switch to the <a href="#after-doctype-system-identifier-state" id="doctype-system-identifier-(single-quoted)-state:after-doctype-system-identifier-state">after DOCTYPE system identifier state</a>.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="doctype-system-identifier-(single-quoted)-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="doctype-system-identifier-(single-quoted)-state:parse-errors">parse
   error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
   system identifier.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>This is an <a href="#parse-error-abrupt-doctype-system-identifier" id="doctype-system-identifier-(single-quoted)-state:parse-error-abrupt-doctype-system-identifier">abrupt-doctype-system-identifier</a>
   <a href="#parse-errors" id="doctype-system-identifier-(single-quoted)-state:parse-errors-2">parse error</a>. Set the current DOCTYPE token's <i id="doctype-system-identifier-(single-quoted)-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks
   flag</a></i> to <i>on</i>. Switch to the <a href="#data-state" id="doctype-system-identifier-(single-quoted)-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="doctype-system-identifier-(single-quoted)-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="doctype-system-identifier-(single-quoted)-state:parse-errors-3">parse
   error</a>. Set the current DOCTYPE token's <i id="doctype-system-identifier-(single-quoted)-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Append the <a href="#current-input-character" id="doctype-system-identifier-(single-quoted)-state:current-input-character">current input character</a> to the current DOCTYPE token's system
   identifier.</dd></dl>
  </div>


  <h5 id="after-doctype-system-identifier-state"><span class="secno">13.2.5.67</span> <dfn>After DOCTYPE system identifier state</dfn><a href="#after-doctype-system-identifier-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="after-doctype-system-identifier-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0009 CHARACTER TABULATION (tab)</dt><dt>U+000A LINE FEED (LF)</dt><dt>U+000C FORM FEED (FF)</dt><dt>U+0020 SPACE</dt><dd>Ignore the character.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="after-doctype-system-identifier-state:data-state">data state</a>. Emit the current DOCTYPE token.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-doctype" id="after-doctype-system-identifier-state:parse-error-eof-in-doctype">eof-in-doctype</a> <a href="#parse-errors" id="after-doctype-system-identifier-state:parse-errors">parse
   error</a>. Set the current DOCTYPE token's <i id="after-doctype-system-identifier-state:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>. Emit the current DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>This is an <a href="#parse-error-unexpected-character-after-doctype-system-identifier" id="after-doctype-system-identifier-state:parse-error-unexpected-character-after-doctype-system-identifier">unexpected-character-after-doctype-system-identifier</a>
   <a href="#parse-errors" id="after-doctype-system-identifier-state:parse-errors-2">parse error</a>. <a href="#reconsume" id="after-doctype-system-identifier-state:reconsume">Reconsume</a> in the <a href="#bogus-doctype-state" id="after-doctype-system-identifier-state:bogus-doctype-state">bogus DOCTYPE state</a>. (This
   does <em>not</em> set the current DOCTYPE token's <i id="after-doctype-system-identifier-state:force-quirks-flag-2"><a href="#force-quirks-flag">force-quirks flag</a></i> to
   <i>on</i>.)</dd></dl>
  </div>


  <h5 id="bogus-doctype-state"><span class="secno">13.2.5.68</span> <dfn>Bogus DOCTYPE state</dfn><a href="#bogus-doctype-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="bogus-doctype-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="bogus-doctype-state:data-state">data state</a>. Emit the DOCTYPE token.</dd><dt>U+0000 NULL</dt><dd>This is an <a href="#parse-error-unexpected-null-character" id="bogus-doctype-state:parse-error-unexpected-null-character">unexpected-null-character</a> <a href="#parse-errors" id="bogus-doctype-state:parse-errors">parse
   error</a>. Ignore the character.</dd><dt>EOF</dt><dd>Emit the DOCTYPE token. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Ignore the character.</dd></dl>
  </div>


  <h5 id="cdata-section-state"><span class="secno">13.2.5.69</span> <dfn>CDATA section state</dfn><a href="#cdata-section-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="cdata-section-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+005D RIGHT SQUARE BRACKET (])</dt><dd>Switch to the <a href="#cdata-section-bracket-state" id="cdata-section-state:cdata-section-bracket-state">CDATA section bracket state</a>.</dd><dt>EOF</dt><dd>This is an <a href="#parse-error-eof-in-cdata" id="cdata-section-state:parse-error-eof-in-cdata">eof-in-cdata</a> <a href="#parse-errors" id="cdata-section-state:parse-errors">parse
    error</a>. Emit an end-of-file token.</dd><dt>Anything else</dt><dd>Emit the <a href="#current-input-character" id="cdata-section-state:current-input-character">current input character</a> as a character token.</dd></dl>
  </div>

  <p class="note">U+0000 NULL characters are handled in the tree construction stage, as part of the
  <a href="#parsing-main-inforeign" id="cdata-section-state:parsing-main-inforeign">in foreign content</a> insertion mode, which
  is the only place where CDATA sections can appear.</p>

  <h5 id="cdata-section-bracket-state"><span class="secno">13.2.5.70</span> <dfn>CDATA section bracket state</dfn><a href="#cdata-section-bracket-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="cdata-section-bracket-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+005D RIGHT SQUARE BRACKET (])</dt><dd>Switch to the <a href="#cdata-section-end-state" id="cdata-section-bracket-state:cdata-section-end-state">CDATA section end state</a>.</dd><dt>Anything else</dt><dd>Emit a U+005D RIGHT SQUARE BRACKET character token. <a href="#reconsume" id="cdata-section-bracket-state:reconsume">Reconsume</a> in the
    <a href="#cdata-section-state" id="cdata-section-bracket-state:cdata-section-state">CDATA section state</a>.</dd></dl>
  </div>


  <h5 id="cdata-section-end-state"><span class="secno">13.2.5.71</span> <dfn>CDATA section end state</dfn><a href="#cdata-section-end-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="cdata-section-end-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+005D RIGHT SQUARE BRACKET (])</dt><dd>Emit a U+005D RIGHT SQUARE BRACKET character token.</dd><dt>U+003E GREATER-THAN SIGN (&gt;)</dt><dd>Switch to the <a href="#data-state" id="cdata-section-end-state:data-state">data state</a>.</dd><dt>Anything else</dt><dd>Emit two U+005D RIGHT SQUARE BRACKET character tokens. <a href="#reconsume" id="cdata-section-end-state:reconsume">Reconsume</a> in the
    <a href="#cdata-section-state" id="cdata-section-end-state:cdata-section-state">CDATA section state</a>.</dd></dl>
  </div>



  <h5 id="character-reference-state"><span class="secno">13.2.5.72</span> <dfn>Character reference state</dfn><a href="#character-reference-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Set the <var id="character-reference-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append
   a U+0026 AMPERSAND (&amp;) character to the <var id="character-reference-state:temporary-buffer-2"><a href="#temporary-buffer">temporary
   buffer</a></var>. Consume the <a href="#next-input-character" id="character-reference-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a href="https://infra.spec.whatwg.org/#ascii-alphanumeric" id="character-reference-state:alphanumeric-ascii-characters" data-x-internal="alphanumeric-ascii-characters">ASCII alphanumeric</a></dt><dd><a href="#reconsume" id="character-reference-state:reconsume">Reconsume</a> in the <a href="#named-character-reference-state" id="character-reference-state:named-character-reference-state">named character reference state</a>.</dd><dt>U+0023 NUMBER SIGN (#)</dt><dd>Append the <a href="#current-input-character" id="character-reference-state:current-input-character">current input character</a> to the
   <var id="character-reference-state:temporary-buffer-3"><a href="#temporary-buffer">temporary buffer</a></var>. Switch to the <a href="#numeric-character-reference-state" id="character-reference-state:numeric-character-reference-state">numeric character
   reference state</a>.</dd><dt>Anything else</dt><dd><a href="#flush-code-points-consumed-as-a-character-reference" id="character-reference-state:flush-code-points-consumed-as-a-character-reference">Flush code points consumed as a character reference</a>. <a href="#reconsume" id="character-reference-state:reconsume-2">Reconsume</a> in
   the <var id="character-reference-state:return-state"><a href="#return-state">return state</a></var>.</dd></dl>
  </div>


  <h5 id="named-character-reference-state"><span class="secno">13.2.5.73</span> <dfn>Named character reference state</dfn><a href="#named-character-reference-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the maximum number of characters possible, where the consumed characters are one of the
  identifiers in the first column of the <a href="#named-character-references" id="named-character-reference-state:named-character-references">named character references</a> table. Append each
  character to the <var id="named-character-reference-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> when it's consumed.</p>

  <dl class="switch"><dt>If there is a match</dt><dd>
    <p>If the character reference was <a href="#charref-in-attribute" id="named-character-reference-state:charref-in-attribute">consumed as part of an
    attribute</a>, and the last character matched is not a U+003B SEMICOLON character (;), and
    the <a href="#next-input-character" id="named-character-reference-state:next-input-character">next input character</a> is either a U+003D EQUALS SIGN character (=) or an
    <a id="named-character-reference-state:alphanumeric-ascii-characters" href="https://infra.spec.whatwg.org/#ascii-alphanumeric" data-x-internal="alphanumeric-ascii-characters">ASCII alphanumeric</a>, then, for historical reasons, <a href="#flush-code-points-consumed-as-a-character-reference" id="named-character-reference-state:flush-code-points-consumed-as-a-character-reference">flush code points consumed
    as a character reference</a> and switch to the <var id="named-character-reference-state:return-state"><a href="#return-state">return state</a></var>.
    </p>
    

    <p>Otherwise:</p>

    <ol><li><p>If the last character matched is not a U+003B SEMICOLON character (;), then this is a
     <a href="#parse-error-missing-semicolon-after-character-reference" id="named-character-reference-state:parse-error-missing-semicolon-after-character-reference">missing-semicolon-after-character-reference</a>
     <a href="#parse-errors" id="named-character-reference-state:parse-errors">parse error</a>.</p></li><li><p>Set the <var id="named-character-reference-state:temporary-buffer-2"><a href="#temporary-buffer">temporary buffer</a></var> to the empty string.
     Append one or two characters corresponding to the character reference name (as given by the
     second column of the <a href="#named-character-references" id="named-character-reference-state:named-character-references-2">named character references</a> table) to the <var id="named-character-reference-state:temporary-buffer-3"><a href="#temporary-buffer">temporary buffer</a></var>.</p></li><li><a href="#flush-code-points-consumed-as-a-character-reference" id="named-character-reference-state:flush-code-points-consumed-as-a-character-reference-2">Flush code points consumed as a character reference</a>. Switch to the <var id="named-character-reference-state:return-state-2"><a href="#return-state">return state</a></var>.</li></ol>
   </dd><dt>Otherwise</dt><dd><a href="#flush-code-points-consumed-as-a-character-reference" id="named-character-reference-state:flush-code-points-consumed-as-a-character-reference-3">Flush code points consumed as a character reference</a>. Switch to the
   <a href="#ambiguous-ampersand-state" id="named-character-reference-state:ambiguous-ampersand-state">ambiguous ampersand state</a>.</dd></dl>
  </div>

  <div class="example">

    <p>If the markup contains (not in an attribute) the string <code>I'm &amp;notit; I
    tell you</code>, the character reference is parsed as "not", as in, <code>I'm ¬it;
    I tell you</code> (and this is a parse error). But if the markup was <code>I'm
    &amp;notin; I tell you</code>, the character reference would be parsed as "notin;", resulting
    in <code>I'm ∉ I tell you</code> (and no parse error).</p>

    <p>However, if the markup contains the string <code>I'm &amp;notit; I tell you</code>
    in an attribute, no character reference is parsed and string remains intact (and there is no
    parse error).</p>

  </div>


  <h5 id="ambiguous-ampersand-state"><span class="secno">13.2.5.74</span> <dfn>Ambiguous ampersand state</dfn><a href="#ambiguous-ampersand-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="ambiguous-ampersand-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a href="https://infra.spec.whatwg.org/#ascii-alphanumeric" id="ambiguous-ampersand-state:alphanumeric-ascii-characters" data-x-internal="alphanumeric-ascii-characters">ASCII alphanumeric</a></dt><dd>If the character reference was <a href="#charref-in-attribute" id="ambiguous-ampersand-state:charref-in-attribute">consumed as part of an
    attribute</a>, then append the <a href="#current-input-character" id="ambiguous-ampersand-state:current-input-character">current input character</a> to the current
    attribute's value. Otherwise, emit the <a href="#current-input-character" id="ambiguous-ampersand-state:current-input-character-2">current input character</a> as a character
    token.</dd><dt>U+003B SEMICOLON (;)</dt><dd>This is an <a href="#parse-error-unknown-named-character-reference" id="ambiguous-ampersand-state:parse-error-unknown-named-character-reference">unknown-named-character-reference</a>
    <a href="#parse-errors" id="ambiguous-ampersand-state:parse-errors">parse error</a>. <a href="#reconsume" id="ambiguous-ampersand-state:reconsume">Reconsume</a> in the <var id="ambiguous-ampersand-state:return-state"><a href="#return-state">return
    state</a></var>.

    </dd><dt>Anything else</dt><dd><a href="#reconsume" id="ambiguous-ampersand-state:reconsume-2">Reconsume</a> in the <var id="ambiguous-ampersand-state:return-state-2"><a href="#return-state">return state</a></var>.</dd></dl>
  </div>

  <h5 id="numeric-character-reference-state"><span class="secno">13.2.5.75</span> <dfn>Numeric character reference state</dfn><a href="#numeric-character-reference-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Set the <dfn id="character-reference-code"><var>character reference code</var></dfn> to
  zero (0).</p>

  <p>Consume the <a href="#next-input-character" id="numeric-character-reference-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt><dt>U+0058 LATIN CAPITAL LETTER X</dt><dd>Append the <a href="#current-input-character" id="numeric-character-reference-state:current-input-character">current input character</a> to the <var id="numeric-character-reference-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var>. Switch to the <a href="#hexadecimal-character-reference-start-state" id="numeric-character-reference-state:hexadecimal-character-reference-start-state">hexadecimal character reference start
    state</a>.</dd><dt>Anything else</dt><dd><a href="#reconsume" id="numeric-character-reference-state:reconsume">Reconsume</a> in the <a href="#decimal-character-reference-start-state" id="numeric-character-reference-state:decimal-character-reference-start-state">decimal character reference start state</a>.</dd></dl>
  </div>


  <h5 id="hexadecimal-character-reference-start-state"><span class="secno">13.2.5.76</span> <dfn>Hexadecimal character reference start state</dfn><a href="#hexadecimal-character-reference-start-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="hexadecimal-character-reference-start-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a href="https://infra.spec.whatwg.org/#ascii-hex-digit" id="hexadecimal-character-reference-start-state:ascii-hex-digits" data-x-internal="ascii-hex-digits">ASCII hex digit</a></dt><dd><a href="#reconsume" id="hexadecimal-character-reference-start-state:reconsume">Reconsume</a> in the <a href="#hexadecimal-character-reference-state" id="hexadecimal-character-reference-start-state:hexadecimal-character-reference-state">hexadecimal character reference state</a>.</dd><dt>Anything else</dt><dd>This is an <a href="#parse-error-absence-of-digits-in-numeric-character-reference" id="hexadecimal-character-reference-start-state:parse-error-absence-of-digits-in-numeric-character-reference">absence-of-digits-in-numeric-character-reference</a>
    <a href="#parse-errors" id="hexadecimal-character-reference-start-state:parse-errors">parse error</a>. <a href="#flush-code-points-consumed-as-a-character-reference" id="hexadecimal-character-reference-start-state:flush-code-points-consumed-as-a-character-reference">Flush code points consumed as a character reference</a>.
    <a href="#reconsume" id="hexadecimal-character-reference-start-state:reconsume-2">Reconsume</a> in the <var id="hexadecimal-character-reference-start-state:return-state"><a href="#return-state">return state</a></var>.</dd></dl>
  </div>


  <h5 id="decimal-character-reference-start-state"><span class="secno">13.2.5.77</span> <dfn>Decimal character reference start state</dfn><a href="#decimal-character-reference-start-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="decimal-character-reference-start-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a href="https://infra.spec.whatwg.org/#ascii-digit" id="decimal-character-reference-start-state:ascii-digits" data-x-internal="ascii-digits">ASCII digit</a></dt><dd><a href="#reconsume" id="decimal-character-reference-start-state:reconsume">Reconsume</a> in the <a href="#decimal-character-reference-state" id="decimal-character-reference-start-state:decimal-character-reference-state">decimal character reference state</a>.</dd><dt>Anything else</dt><dd>This is an <a href="#parse-error-absence-of-digits-in-numeric-character-reference" id="decimal-character-reference-start-state:parse-error-absence-of-digits-in-numeric-character-reference">absence-of-digits-in-numeric-character-reference</a>
    <a href="#parse-errors" id="decimal-character-reference-start-state:parse-errors">parse error</a>. <a href="#flush-code-points-consumed-as-a-character-reference" id="decimal-character-reference-start-state:flush-code-points-consumed-as-a-character-reference">Flush code points consumed as a character reference</a>.
    <a href="#reconsume" id="decimal-character-reference-start-state:reconsume-2">Reconsume</a> in the <var id="decimal-character-reference-start-state:return-state"><a href="#return-state">return state</a></var>.</dd></dl>
  </div>


  <h5 id="hexadecimal-character-reference-state"><span class="secno">13.2.5.78</span> <dfn>Hexadecimal character reference state</dfn><a href="#hexadecimal-character-reference-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="hexadecimal-character-reference-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a href="https://infra.spec.whatwg.org/#ascii-digit" id="hexadecimal-character-reference-state:ascii-digits" data-x-internal="ascii-digits">ASCII digit</a></dt><dd>Multiply the <var id="hexadecimal-character-reference-state:character-reference-code"><a href="#character-reference-code">character reference code</a></var> by 16.
    Add a numeric version of the <a href="#current-input-character" id="hexadecimal-character-reference-state:current-input-character">current input character</a> (subtract 0x0030 from the
    character's code point) to the <var id="hexadecimal-character-reference-state:character-reference-code-2"><a href="#character-reference-code">character reference
    code</a></var>.</dd><dt><a id="hexadecimal-character-reference-state:uppercase-ascii-hex-digits" href="https://infra.spec.whatwg.org/#ascii-upper-hex-digit" data-x-internal="uppercase-ascii-hex-digits">ASCII upper hex digit</a></dt><dd>Multiply the <var id="hexadecimal-character-reference-state:character-reference-code-3"><a href="#character-reference-code">character reference code</a></var> by 16.
    Add a numeric version of the <a href="#current-input-character" id="hexadecimal-character-reference-state:current-input-character-2">current input character</a> as a hexadecimal digit
    (subtract 0x0037 from the character's code point) to the <var id="hexadecimal-character-reference-state:character-reference-code-4"><a href="#character-reference-code">character reference code</a></var>.</dd><dt><a id="hexadecimal-character-reference-state:lowercase-ascii-hex-digits" href="https://infra.spec.whatwg.org/#ascii-lower-hex-digit" data-x-internal="lowercase-ascii-hex-digits">ASCII lower hex digit</a></dt><dd>Multiply the <var id="hexadecimal-character-reference-state:character-reference-code-5"><a href="#character-reference-code">character reference code</a></var> by 16.
    Add a numeric version of the <a href="#current-input-character" id="hexadecimal-character-reference-state:current-input-character-3">current input character</a> as a hexadecimal digit
    (subtract 0x0057 from the character's code point) to the <var id="hexadecimal-character-reference-state:character-reference-code-6"><a href="#character-reference-code">character reference code</a></var>.</dd><dt>U+003B SEMICOLON (;)</dt><dd>Switch to the <a href="#numeric-character-reference-end-state" id="hexadecimal-character-reference-state:numeric-character-reference-end-state">numeric character reference end state</a>.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-semicolon-after-character-reference" id="hexadecimal-character-reference-state:parse-error-missing-semicolon-after-character-reference">missing-semicolon-after-character-reference</a>
    <a href="#parse-errors" id="hexadecimal-character-reference-state:parse-errors">parse error</a>. <a href="#reconsume" id="hexadecimal-character-reference-state:reconsume">Reconsume</a> in the <a href="#numeric-character-reference-end-state" id="hexadecimal-character-reference-state:numeric-character-reference-end-state-2">numeric character reference end
    state</a>.</dd></dl>
  </div>


  <h5 id="decimal-character-reference-state"><span class="secno">13.2.5.79</span> <dfn>Decimal character reference state</dfn><a href="#decimal-character-reference-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Consume the <a href="#next-input-character" id="decimal-character-reference-state:next-input-character">next input character</a>:</p>

  <dl class="switch"><dt><a href="https://infra.spec.whatwg.org/#ascii-digit" id="decimal-character-reference-state:ascii-digits" data-x-internal="ascii-digits">ASCII digit</a></dt><dd>Multiply the <var id="decimal-character-reference-state:character-reference-code"><a href="#character-reference-code">character reference code</a></var> by 10.
    Add a numeric version of the <a href="#current-input-character" id="decimal-character-reference-state:current-input-character">current input character</a> (subtract 0x0030 from the
    character's code point) to the <var id="decimal-character-reference-state:character-reference-code-2"><a href="#character-reference-code">character reference
    code</a></var>.</dd><dt>U+003B SEMICOLON (;)</dt><dd>Switch to the <a href="#numeric-character-reference-end-state" id="decimal-character-reference-state:numeric-character-reference-end-state">numeric character reference end state</a>.</dd><dt>Anything else</dt><dd>This is a <a href="#parse-error-missing-semicolon-after-character-reference" id="decimal-character-reference-state:parse-error-missing-semicolon-after-character-reference">missing-semicolon-after-character-reference</a>
    <a href="#parse-errors" id="decimal-character-reference-state:parse-errors">parse error</a>. <a href="#reconsume" id="decimal-character-reference-state:reconsume">Reconsume</a> in the <a href="#numeric-character-reference-end-state" id="decimal-character-reference-state:numeric-character-reference-end-state-2">numeric character reference end
    state</a>.</dd></dl>
  </div>


  <h5 id="numeric-character-reference-end-state"><span class="secno">13.2.5.80</span> <dfn>Numeric character reference end state</dfn><a href="#numeric-character-reference-end-state" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>Check the <var id="numeric-character-reference-end-state:character-reference-code"><a href="#character-reference-code">character reference code</a></var>:</p>

  <ul><li><p>If the number is 0x00, then this is a <a href="#parse-error-null-character-reference" id="numeric-character-reference-end-state:parse-error-null-character-reference">null-character-reference</a> <a href="#parse-errors" id="numeric-character-reference-end-state:parse-errors">parse
    error</a>. Set the <var id="numeric-character-reference-end-state:character-reference-code-2"><a href="#character-reference-code">character reference code</a></var> to
    0xFFFD.</p></li><li><p>If the number is greater than 0x10FFFF, then this is a <a href="#parse-error-character-reference-outside-unicode-range" id="numeric-character-reference-end-state:parse-error-character-reference-outside-unicode-range">character-reference-outside-unicode-range</a>
    <a href="#parse-errors" id="numeric-character-reference-end-state:parse-errors-2">parse error</a>. Set the <var id="numeric-character-reference-end-state:character-reference-code-3"><a href="#character-reference-code">character reference
    code</a></var> to 0xFFFD.</p></li><li><p>If the number is a <a href="https://infra.spec.whatwg.org/#surrogate" id="numeric-character-reference-end-state:surrogate" data-x-internal="surrogate">surrogate</a>, then this is a <a href="#parse-error-surrogate-character-reference" id="numeric-character-reference-end-state:parse-error-surrogate-character-reference">surrogate-character-reference</a>
    <a href="#parse-errors" id="numeric-character-reference-end-state:parse-errors-3">parse error</a>. Set the <var id="numeric-character-reference-end-state:character-reference-code-4"><a href="#character-reference-code">character reference
    code</a></var> to 0xFFFD.</p></li><li><p>If the number is a <a href="https://infra.spec.whatwg.org/#noncharacter" id="numeric-character-reference-end-state:noncharacter" data-x-internal="noncharacter">noncharacter</a>, then this is a
    <a href="#parse-error-noncharacter-character-reference" id="numeric-character-reference-end-state:parse-error-noncharacter-character-reference">noncharacter-character-reference</a>
    <a href="#parse-errors" id="numeric-character-reference-end-state:parse-errors-4">parse error</a>.</p></li><li><p>If the number is 0x0D, or a
    <a href="https://infra.spec.whatwg.org/#control" id="numeric-character-reference-end-state:control" data-x-internal="control">control</a> that's not <a id="numeric-character-reference-end-state:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>, then this is a
    <a href="#parse-error-control-character-reference" id="numeric-character-reference-end-state:parse-error-control-character-reference">control-character-reference</a>
    <a href="#parse-errors" id="numeric-character-reference-end-state:parse-errors-5">parse error</a>. If the number is one of the numbers in the first column of the
    following table, then find the row with that number in the first column, and set the <var id="numeric-character-reference-end-state:character-reference-code-5"><a href="#character-reference-code">character reference code</a></var> to the number in the second
    column of that row.</p>
    

    <table id="table-charref-overrides"><thead><tr><th>Number </th><th colspan="2">Code point
      </th></tr></thead><tbody><tr><td>0x80 </td><td>0x20AC </td><td>EURO SIGN (€)
      
      </td></tr><tr><td>0x82 </td><td>0x201A </td><td>SINGLE LOW-9 QUOTATION MARK (‚)
      </td></tr><tr><td>0x83 </td><td>0x0192 </td><td>LATIN SMALL LETTER F WITH HOOK (ƒ)
      </td></tr><tr><td>0x84 </td><td>0x201E </td><td>DOUBLE LOW-9 QUOTATION MARK („)
      </td></tr><tr><td>0x85 </td><td>0x2026 </td><td>HORIZONTAL ELLIPSIS (…)
      </td></tr><tr><td>0x86 </td><td>0x2020 </td><td>DAGGER (†)
      </td></tr><tr><td>0x87 </td><td>0x2021 </td><td>DOUBLE DAGGER (‡)
      </td></tr><tr><td>0x88 </td><td>0x02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ)
      </td></tr><tr><td>0x89 </td><td>0x2030 </td><td>PER MILLE SIGN (‰)
      </td></tr><tr><td>0x8A </td><td>0x0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (Š)
      </td></tr><tr><td>0x8B </td><td>0x2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹)
      </td></tr><tr><td>0x8C </td><td>0x0152 </td><td>LATIN CAPITAL LIGATURE OE (Œ)
      
      </td></tr><tr><td>0x8E </td><td>0x017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (Ž)
      
      
      </td></tr><tr><td>0x91 </td><td>0x2018 </td><td>LEFT SINGLE QUOTATION MARK (‘)
      </td></tr><tr><td>0x92 </td><td>0x2019 </td><td>RIGHT SINGLE QUOTATION MARK (’)
      </td></tr><tr><td>0x93 </td><td>0x201C </td><td>LEFT DOUBLE QUOTATION MARK (“)
      </td></tr><tr><td>0x94 </td><td>0x201D </td><td>RIGHT DOUBLE QUOTATION MARK (”)
      </td></tr><tr><td>0x95 </td><td>0x2022 </td><td>BULLET (•)
      </td></tr><tr><td>0x96 </td><td>0x2013 </td><td>EN DASH (–)
      </td></tr><tr><td>0x97 </td><td>0x2014 </td><td>EM DASH (—)
      </td></tr><tr><td>0x98 </td><td>0x02DC </td><td>SMALL TILDE (˜)
      </td></tr><tr><td>0x99 </td><td>0x2122 </td><td>TRADE MARK SIGN (™)
      </td></tr><tr><td>0x9A </td><td>0x0161 </td><td>LATIN SMALL LETTER S WITH CARON (š)
      </td></tr><tr><td>0x9B </td><td>0x203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›)
      </td></tr><tr><td>0x9C </td><td>0x0153 </td><td>LATIN SMALL LIGATURE OE (œ)
      
      </td></tr><tr><td>0x9E </td><td>0x017E </td><td>LATIN SMALL LETTER Z WITH CARON (ž)
      </td></tr><tr><td>0x9F </td><td>0x0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ)
    </td></tr></tbody></table></li></ul>

  <p>Set the <var id="numeric-character-reference-end-state:temporary-buffer"><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append a
  code point equal to the <var id="numeric-character-reference-end-state:character-reference-code-6"><a href="#character-reference-code">character reference code</a></var> to
  the <var id="numeric-character-reference-end-state:temporary-buffer-2"><a href="#temporary-buffer">temporary buffer</a></var>. <a href="#flush-code-points-consumed-as-a-character-reference" id="numeric-character-reference-end-state:flush-code-points-consumed-as-a-character-reference">Flush code points consumed as a
  character reference</a>. Switch to the <var id="numeric-character-reference-end-state:return-state"><a href="#return-state">return state</a></var>.</p>
  </div>

  


  

  

  <h4 id="tree-construction"><span class="secno">13.2.6</span> <dfn>Tree construction</dfn><a href="#tree-construction" class="self-link"></a></h4>

  <p>The input to the tree construction stage is a sequence of tokens from the
  <a href="#tokenization" id="tree-construction:tokenization">tokenization</a> stage. The tree construction stage is associated with a DOM
  <code id="tree-construction:document"><a href="#document">Document</a></code> object when a parser is created. The "output" of this stage consists of
  dynamically modifying or extending that document's DOM tree.</p>

  <p>This specification does not define when an interactive user agent has to render the
  <code id="tree-construction:document-2"><a href="#document">Document</a></code> so that it is available to the user, or when it has to begin accepting user
  input.</p>

  <hr>

  <div data-algorithm="">
  <p>As each token is emitted from the tokenizer, the user agent must follow the appropriate steps
  from the following list, known as the <dfn id="tree-construction-dispatcher">tree construction dispatcher</dfn>:</p>

  <dl class="switch"><dt>If the <a href="#stack-of-open-elements" id="tree-construction:stack-of-open-elements">stack of open elements</a> is empty</dt><dt>If the <a href="#adjusted-current-node" id="tree-construction:adjusted-current-node">adjusted current node</a> is an element in the <a id="tree-construction:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a></dt><dt>If the <a href="#adjusted-current-node" id="tree-construction:adjusted-current-node-2">adjusted current node</a> is a <a href="#mathml-text-integration-point" id="tree-construction:mathml-text-integration-point">MathML text integration point</a> and the token is a start tag whose tag name is neither "mglyph" nor "malignmark"</dt><dt>If the <a href="#adjusted-current-node" id="tree-construction:adjusted-current-node-3">adjusted current node</a> is a <a href="#mathml-text-integration-point" id="tree-construction:mathml-text-integration-point-2">MathML text integration point</a> and the token is a character token</dt><dt>If the <a href="#adjusted-current-node" id="tree-construction:adjusted-current-node-4">adjusted current node</a> is a <a id="tree-construction:mathml-annotation-xml" href="https://w3c.github.io/mathml-core/#dfn-annotation-xml" data-x-internal="mathml-annotation-xml">MathML <code>annotation-xml</code></a> element and the token is a start tag whose tag name is "svg"</dt><dt>If the <a href="#adjusted-current-node" id="tree-construction:adjusted-current-node-5">adjusted current node</a> is an <a href="#html-integration-point" id="tree-construction:html-integration-point">HTML integration point</a> and the token is a start tag</dt><dt>If the <a href="#adjusted-current-node" id="tree-construction:adjusted-current-node-6">adjusted current node</a> is an <a href="#html-integration-point" id="tree-construction:html-integration-point-2">HTML integration point</a> and the token is a character token</dt><dt>If the token is an end-of-file token</dt><dd>Process the token according to the rules given in the section corresponding to the current
   <a href="#insertion-mode" id="tree-construction:insertion-mode">insertion mode</a> in HTML content.</dd><dt>Otherwise</dt><dd>Process the token according to the rules given in the section for parsing tokens <a href="#parsing-main-inforeign" id="tree-construction:parsing-main-inforeign">in foreign content</a>.</dd></dl>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="next-token">next token</dfn> is the token that is about to be processed by the <a href="#tree-construction-dispatcher" id="tree-construction:tree-construction-dispatcher">tree
  construction dispatcher</a> (even if the token is subsequently just ignored).</p>
  </div>

  <div data-algorithm="">
  <p>A node is a <dfn id="mathml-text-integration-point">MathML text integration point</dfn> if it is one of the following
  elements:</p>

  <ul class="brief"><li>A <a id="tree-construction:mathml-mi" href="https://w3c.github.io/mathml-core/#the-mi-element" data-x-internal="mathml-mi">MathML <code>mi</code></a> element</li><li>A <a id="tree-construction:mathml-mo" href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo" data-x-internal="mathml-mo">MathML <code>mo</code></a> element</li><li>A <a id="tree-construction:mathml-mn" href="https://w3c.github.io/mathml-core/#number-mn" data-x-internal="mathml-mn">MathML <code>mn</code></a> element</li><li>A <a id="tree-construction:mathml-ms" href="https://w3c.github.io/mathml-core/#string-literal-ms" data-x-internal="mathml-ms">MathML <code>ms</code></a> element</li><li>A <a id="tree-construction:mathml-mtext" href="https://w3c.github.io/mathml-core/#text-mtext" data-x-internal="mathml-mtext">MathML <code>mtext</code></a> element</li></ul>
  </div>

  <div data-algorithm="">
  <p>A node is an <dfn id="html-integration-point">HTML integration point</dfn> if it is one of the following elements:</p>

  <ul class="brief"><li>A <a id="tree-construction:mathml-annotation-xml-2" href="https://w3c.github.io/mathml-core/#dfn-annotation-xml" data-x-internal="mathml-annotation-xml">MathML <code>annotation-xml</code></a> element whose start tag token had an
   attribute with the name "encoding" whose value was an <a id="tree-construction:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match
   for the string "<code>text/html</code>"</li><li>A <a id="tree-construction:mathml-annotation-xml-3" href="https://w3c.github.io/mathml-core/#dfn-annotation-xml" data-x-internal="mathml-annotation-xml">MathML <code>annotation-xml</code></a> element whose start tag token had an
   attribute with the name "encoding" whose value was an <a id="tree-construction:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match
   for the string "<code>application/xhtml+xml</code>"</li><li>An <a id="tree-construction:svg-foreignobject" href="https://svgwg.org/svg2-draft/embedded.html#ForeignObjectElement" data-x-internal="svg-foreignobject">SVG <code>foreignObject</code></a> element</li><li>An <a id="tree-construction:svg-desc" href="https://svgwg.org/svg2-draft/struct.html#DescElement" data-x-internal="svg-desc">SVG <code>desc</code></a> element</li><li>An <a id="tree-construction:svg-title" href="https://svgwg.org/svg2-draft/struct.html#TitleElement" data-x-internal="svg-title">SVG <code>title</code></a> element</li></ul>
  </div>

  <p class="note">If the node in question is the <var id="tree-construction:concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element passed to the <a href="#html-fragment-parsing-algorithm" id="tree-construction:html-fragment-parsing-algorithm">HTML fragment
  parsing algorithm</a>, then the start tag token for that element is the "fake" token created
  during by that <a href="#html-fragment-parsing-algorithm" id="tree-construction:html-fragment-parsing-algorithm-2">HTML fragment parsing algorithm</a>.</p>

  <hr>

  <p class="note">Not all of the tag names mentioned below are conformant tag names in this
  specification; many are included to handle legacy content. They still form part of the algorithm
  that implementations are required to implement to claim conformance.</p>

  <p class="note">The algorithm described below places no limit on the depth of the DOM tree
  generated, or on the length of tag names, attribute names, attribute values, <code id="tree-construction:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code>
  nodes, etc. While implementers are encouraged to <a href="https://infra.spec.whatwg.org/#algorithm-limits">avoid arbitrary limits</a>, it is
  recognized that practical concerns will likely force user agents to impose nesting depth
  constraints.</p>


  <h5 id="creating-and-inserting-nodes"><span class="secno">13.2.6.1</span> Creating and inserting nodes<a href="#creating-and-inserting-nodes" class="self-link"></a></h5>

  <p>While the parser is processing a token, it can enable or disable <dfn id="foster-parent">foster parenting</dfn>. This affects the following algorithm.</p>

  <div data-algorithm="">
  <p>The <dfn id="appropriate-place-for-inserting-a-node">appropriate place for inserting a node</dfn>, optionally using a particular
  <i>override target</i>, is the position in an element returned by running the following steps:</p>

  <ol><li>
    <p>If there was an <i>override target</i> specified, then let <var>target</var> be the
    <i>override target</i>.</p>

    <p>Otherwise, let <var>target</var> be the <a href="#current-node" id="creating-and-inserting-nodes:current-node">current node</a>.</p>
   </li><li>
    <p>Determine the <var>adjusted insertion location</var> using the first matching steps
    from the following list:</p>

    <dl class="switch"><dt>If <a href="#foster-parent" id="creating-and-inserting-nodes:foster-parent">foster parenting</a> is enabled and <var>target</var> is a <code id="creating-and-inserting-nodes:the-table-element"><a href="#the-table-element">table</a></code>, <code id="creating-and-inserting-nodes:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>, <code id="creating-and-inserting-nodes:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code>,
     <code id="creating-and-inserting-nodes:the-thead-element"><a href="#the-thead-element">thead</a></code>, or <code id="creating-and-inserting-nodes:the-tr-element"><a href="#the-tr-element">tr</a></code> element</dt><dd>
      <p class="note">Foster parenting happens when content is misnested in tables.</p>

      <p>Run these substeps:</p>

      <ol><li><p>Let <var>last template</var> be the last <code id="creating-and-inserting-nodes:the-template-element"><a href="#the-template-element">template</a></code> element in the
       <a href="#stack-of-open-elements" id="creating-and-inserting-nodes:stack-of-open-elements">stack of open elements</a>, if any.</p>

       </li><li><p>Let <var>last table</var> be the last <code id="creating-and-inserting-nodes:the-table-element-2"><a href="#the-table-element">table</a></code> element in the
       <a href="#stack-of-open-elements" id="creating-and-inserting-nodes:stack-of-open-elements-2">stack of open elements</a>, if any.</p>

       </li><li><p>If there is a <var>last template</var> and either there is no <var>last table</var>, or there is one, but <var>last template</var> is lower
       (more recently added) than <var>last table</var> in the <a href="#stack-of-open-elements" id="creating-and-inserting-nodes:stack-of-open-elements-3">stack of open
       elements</a>, then: let <var>adjusted insertion location</var> be inside <var>last template</var>'s <a href="#template-contents" id="creating-and-inserting-nodes:template-contents">template contents</a>, after its last child (if any),
       and abort these steps.</p></li><li><p>If there is no <var>last table</var>,  then let <var>adjusted insertion
       location</var> be inside the first element in the <a href="#stack-of-open-elements" id="creating-and-inserting-nodes:stack-of-open-elements-4">stack of open elements</a> (the
       <code id="creating-and-inserting-nodes:the-html-element"><a href="#the-html-element">html</a></code> element), after its last child (if any), and abort these steps.
       (<a href="#fragment-case" id="creating-and-inserting-nodes:fragment-case">fragment case</a>)</p>

       

       </li><li><p>If <var>last table</var> has a parent node, then let <var>adjusted insertion location</var> be inside <var>last table</var>'s parent
       node, immediately before <var>last table</var>, and abort these steps.</p></li><li><p>Let <var>previous element</var> be the element immediately above <var>last table</var> in the <a href="#stack-of-open-elements" id="creating-and-inserting-nodes:stack-of-open-elements-5">stack of open elements</a>.</p></li><li><p>Let <var>adjusted insertion location</var> be inside <var>previous
       element</var>, after its last child (if any).</p></li></ol>

      <p class="note">These steps are involved in part because it's possible for elements, the
      <code id="creating-and-inserting-nodes:the-table-element-3"><a href="#the-table-element">table</a></code> element in this case in particular, to have been moved by a script around
      in the DOM, or indeed removed from the DOM entirely, after the element was inserted by the
      parser.</p>
     </dd><dt>Otherwise</dt><dd>
      <p>Let <var>adjusted insertion location</var> be inside <var>target</var>,
      after its last child (if any).</p>
     </dd></dl>
   </li><li>
    <p>If the <var>adjusted insertion location</var> is inside a <code id="creating-and-inserting-nodes:the-template-element-2"><a href="#the-template-element">template</a></code>
    element, let it instead be inside the <code id="creating-and-inserting-nodes:the-template-element-3"><a href="#the-template-element">template</a></code> element's <a href="#template-contents" id="creating-and-inserting-nodes:template-contents-2">template
    contents</a>, after its last child (if any).</p>
   </li><li>
    <p>Return the <var>adjusted insertion location</var>.</p>
   </li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="create-an-element-for-the-token">create an element for a token</dfn>, given a
  token <var>token</var>, a string <var>namespace</var>, and a <code id="creating-and-inserting-nodes:node"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code> object
  <var>intendedParent</var>:</p>

  <ol><li><p>If the <a href="#active-speculative-html-parser" id="creating-and-inserting-nodes:active-speculative-html-parser">active speculative HTML parser</a> is not null, then return the result of
   <a href="#create-a-speculative-mock-element" id="creating-and-inserting-nodes:create-a-speculative-mock-element">creating a speculative mock element</a>
   given <var>namespace</var>, <var>token</var>'s tag name, and <var>token</var>'s
   attributes.</p></li><li>
    <p>Otherwise, optionally <a href="#create-a-speculative-mock-element" id="creating-and-inserting-nodes:create-a-speculative-mock-element-2">create a speculative mock element</a> given
    <var>namespace</var>, <var>token</var>'s tag name, and <var>token</var>'s attributes.</p>

    <p class="note">The result is not used. This step allows for a <a href="#speculative-fetch" id="creating-and-inserting-nodes:speculative-fetch">speculative fetch</a> to
    be initiated from non-speculative parsing. The fetch is still speculative at this point,
    because, for example, by the time the element is inserted, <var>intended parent</var> might
    have been removed from the document.</p>
   </li><li><p>Let <var>document</var> be <var>intendedParent</var>'s <a id="creating-and-inserting-nodes:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>.</p></li><li><p>Let <var>localName</var> be <var>token</var>'s tag name.</p></li><li><p>Let <var>is</var> be the value of the "<code id="creating-and-inserting-nodes:attr-is"><a href="#attr-is">is</a></code>" attribute in
   <var>token</var>, if such an attribute exists; otherwise null.</p></li><li><p>Let <var>registry</var> be the result of <a href="#look-up-a-custom-element-registry" id="creating-and-inserting-nodes:look-up-a-custom-element-registry">looking up a custom element registry</a> given <var>intendedParent</var>.</p></li><li><p>Let <var>definition</var> be the result of <a href="#look-up-a-custom-element-definition" id="creating-and-inserting-nodes:look-up-a-custom-element-definition">looking up a custom element definition</a> given <var>registry</var>,
   <var>namespace</var>, <var>localName</var>, and <var>is</var>.</p></li><li><p>Let <var>willExecuteScript</var> be true if <var>definition</var> is non-null and the
   parser was not created as part of the <a href="#html-fragment-parsing-algorithm" id="creating-and-inserting-nodes:html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>; otherwise
   false.</p></li><li>
    <p>If <var>willExecuteScript</var> is true:</p>

    <ol><li><p>Increment <var>document</var>'s <a href="#throw-on-dynamic-markup-insertion-counter" id="creating-and-inserting-nodes:throw-on-dynamic-markup-insertion-counter">throw-on-dynamic-markup-insertion
     counter</a>.</p></li><li><p>If the <a id="creating-and-inserting-nodes:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution context stack</a> is empty, then <a href="#perform-a-microtask-checkpoint" id="creating-and-inserting-nodes:perform-a-microtask-checkpoint">perform a
     microtask checkpoint</a>.</p></li><li><p>Push a new <a href="#element-queue" id="creating-and-inserting-nodes:element-queue">element queue</a> onto <var>document</var>'s <a href="#relevant-agent" id="creating-and-inserting-nodes:relevant-agent">relevant
     agent</a>'s <a href="#custom-element-reactions-stack" id="creating-and-inserting-nodes:custom-element-reactions-stack">custom element reactions stack</a>.</p></li></ol>
   </li><li>
    <p>Let <var>element</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="creating-and-inserting-nodes:create-an-element" data-x-internal="create-an-element">creating an
    element</a> given <var>document</var>, <var>localName</var>, <var>namespace</var>, null,
    <var>is</var>, <var>willExecuteScript</var>, and <var>registry</var>.</p>

    <p class="note">This will cause <a href="#custom-element-constructor" id="creating-and-inserting-nodes:custom-element-constructor">custom element
    constructors</a> to run, if <var>willExecuteScript</var> is true. However, since we
    incremented the <a href="#throw-on-dynamic-markup-insertion-counter" id="creating-and-inserting-nodes:throw-on-dynamic-markup-insertion-counter-2">throw-on-dynamic-markup-insertion counter</a>, this cannot cause <a href="#dom-document-write" id="creating-and-inserting-nodes:dom-document-write">new characters to be inserted into the tokenizer</a>, or <a href="#dom-document-open" id="creating-and-inserting-nodes:dom-document-open">the document to be blown away</a>.</p>
   </li><li>
    <p><a href="https://dom.spec.whatwg.org/#concept-element-attributes-append" id="creating-and-inserting-nodes:concept-element-attributes-append" data-x-internal="concept-element-attributes-append">Append</a> each attribute in the given
    token to <var>element</var>.</p>

    <p class="note">This can <a href="#enqueue-a-custom-element-callback-reaction" id="creating-and-inserting-nodes:enqueue-a-custom-element-callback-reaction">enqueue a custom element callback reaction</a> for the
    <code>attributeChangedCallback</code>, which might run immediately (in the next
    step).</p>

    <p class="note">Even though the <code id="creating-and-inserting-nodes:attr-is-2"><a href="#attr-is">is</a></code> attribute governs the <a href="https://dom.spec.whatwg.org/#concept-create-element" id="creating-and-inserting-nodes:create-an-element-2" data-x-internal="create-an-element">creation</a> of a <a href="#customized-built-in-element" id="creating-and-inserting-nodes:customized-built-in-element">customized built-in element</a>, it is
    not present during the execution of the relevant <a href="#custom-element-constructor" id="creating-and-inserting-nodes:custom-element-constructor-2">custom element constructor</a>; it is
    appended in this step, along with all other attributes.</p>
   </li><li>
    <p>If <var>willExecuteScript</var> is true:</p>

    <ol><li><p>Let <var>queue</var> be the result of popping from <var>document</var>'s <a href="#relevant-agent" id="creating-and-inserting-nodes:relevant-agent-2">relevant
     agent</a>'s <a href="#custom-element-reactions-stack" id="creating-and-inserting-nodes:custom-element-reactions-stack-2">custom element reactions stack</a>. (This will be the same
     <a href="#element-queue" id="creating-and-inserting-nodes:element-queue-2">element queue</a> as was pushed above.)</p></li><li><p><a href="#invoke-custom-element-reactions" id="creating-and-inserting-nodes:invoke-custom-element-reactions">Invoke custom element reactions</a> in <var>queue</var>.</p></li><li><p>Decrement <var>document</var>'s <a href="#throw-on-dynamic-markup-insertion-counter" id="creating-and-inserting-nodes:throw-on-dynamic-markup-insertion-counter-3">throw-on-dynamic-markup-insertion
     counter</a>.</p></li></ol>
   </li><li><p>If <var>element</var> has an <code>xmlns</code> attribute <em>in the <a id="creating-and-inserting-nodes:xmlns-namespace" href="https://infra.spec.whatwg.org/#xmlns-namespace" data-x-internal="xmlns-namespace">XMLNS
   namespace</a></em> whose value is not exactly the same as the element's namespace, that is a
   <a href="#parse-errors" id="creating-and-inserting-nodes:parse-errors">parse error</a>. Similarly, if <var>element</var> has an <code>xmlns:xlink</code> attribute in the <a id="creating-and-inserting-nodes:xmlns-namespace-2" href="https://infra.spec.whatwg.org/#xmlns-namespace" data-x-internal="xmlns-namespace">XMLNS namespace</a> whose value is not the
   <a id="creating-and-inserting-nodes:xlink-namespace" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink Namespace</a>, that is a <a href="#parse-errors" id="creating-and-inserting-nodes:parse-errors-2">parse error</a>.</p></li><li><p>If <var>element</var> is a <a href="#category-reset" id="creating-and-inserting-nodes:category-reset">resettable element</a> and not
   a <a href="#form-associated-custom-element" id="creating-and-inserting-nodes:form-associated-custom-element">form-associated custom element</a>, then invoke its <a href="#concept-form-reset-control" id="creating-and-inserting-nodes:concept-form-reset-control">reset algorithm</a>. (This initializes the element's <a href="#concept-fe-value" id="creating-and-inserting-nodes:concept-fe-value">value</a> and <a href="#concept-fe-checked" id="creating-and-inserting-nodes:concept-fe-checked">checkedness</a>
   based on the element's attributes.)</p></li><li><p>If <var>element</var> is a <a href="#form-associated-element" id="creating-and-inserting-nodes:form-associated-element">form-associated element</a> and not a
   <a href="#form-associated-custom-element" id="creating-and-inserting-nodes:form-associated-custom-element-2">form-associated custom element</a>, the
   <a href="#form-element-pointer" id="creating-and-inserting-nodes:form-element-pointer"><code>form</code> element pointer</a> is not null, there is no
   <code id="creating-and-inserting-nodes:the-template-element-4"><a href="#the-template-element">template</a></code> element on the <a href="#stack-of-open-elements" id="creating-and-inserting-nodes:stack-of-open-elements-6">stack of open elements</a>, <var>element</var> is
   either not <a href="#category-listed" id="creating-and-inserting-nodes:category-listed">listed</a> or doesn't have a <code id="creating-and-inserting-nodes:attr-fae-form"><a href="#attr-fae-form">form</a></code> attribute, and the <var>intendedParent</var> is in the same
   <a id="creating-and-inserting-nodes:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> as the element pointed to by the <a href="#form-element-pointer" id="creating-and-inserting-nodes:form-element-pointer-2"><code>form</code> element
   pointer</a>, then <a href="#concept-form-association" id="creating-and-inserting-nodes:concept-form-association">associate</a> <var>element</var>
   with the <code id="creating-and-inserting-nodes:the-form-element"><a href="#the-form-element">form</a></code> element pointed to by the <a href="#form-element-pointer" id="creating-and-inserting-nodes:form-element-pointer-3"><code>form</code> element
   pointer</a> and set <var>element</var>'s <a href="#parser-inserted-flag" id="creating-and-inserting-nodes:parser-inserted-flag">parser inserted flag</a>.</p></li><li><p>Return <var>element</var>.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>To <dfn id="insert-an-element-at-the-adjusted-insertion-location">insert an element at the adjusted insertion location</dfn> with an element
  <var>element</var>:</p>

  <ol><li><p>Let the <var>adjusted insertion location</var> be the <a href="#appropriate-place-for-inserting-a-node" id="creating-and-inserting-nodes:appropriate-place-for-inserting-a-node">appropriate place for
   inserting a node</a>.</p></li><li><p>If it is not possible to insert <var>element</var> at the <var>adjusted insertion
   location</var>, abort these steps.</p></li><li><p>If the parser was not created as part of the <a href="#html-fragment-parsing-algorithm" id="creating-and-inserting-nodes:html-fragment-parsing-algorithm-2">HTML fragment parsing
   algorithm</a>, then push a new <a href="#element-queue" id="creating-and-inserting-nodes:element-queue-3">element queue</a> onto <var>element</var>'s
   <a href="#relevant-agent" id="creating-and-inserting-nodes:relevant-agent-3">relevant agent</a>'s <a href="#custom-element-reactions-stack" id="creating-and-inserting-nodes:custom-element-reactions-stack-3">custom element reactions stack</a>.</p></li><li><p>Insert <var>element</var> at the <var>adjusted insertion location</var>.</p></li><li><p>If the parser was not created as part of the <a href="#html-fragment-parsing-algorithm" id="creating-and-inserting-nodes:html-fragment-parsing-algorithm-3">HTML fragment parsing
   algorithm</a>, then pop the <a href="#element-queue" id="creating-and-inserting-nodes:element-queue-4">element queue</a> from <var>element</var>'s
   <a href="#relevant-agent" id="creating-and-inserting-nodes:relevant-agent-4">relevant agent</a>'s <a href="#custom-element-reactions-stack" id="creating-and-inserting-nodes:custom-element-reactions-stack-4">custom element reactions stack</a>, and <a href="#invoke-custom-element-reactions" id="creating-and-inserting-nodes:invoke-custom-element-reactions-2">invoke
   custom element reactions</a> in that queue.</p></li></ol>

  <p class="note">If the <var>adjusted insertion location</var> cannot accept more elements, e.g.,
  because it's a <code id="creating-and-inserting-nodes:document"><a href="#document">Document</a></code> that already has an element child, then <var>element</var> is
  dropped on the floor.</p>
  </div>

  

  <div data-algorithm="">
  <p>To <dfn id="insert-a-foreign-element">insert a foreign element</dfn>, given a token <var>token</var>, a string
  <var>namespace</var>, and a boolean <var>onlyAddToElementStack</var>:</p>

  <ol><li><p>Let the <var>adjustedInsertionLocation</var> be the <a href="#appropriate-place-for-inserting-a-node" id="creating-and-inserting-nodes:appropriate-place-for-inserting-a-node-2">appropriate place for inserting
   a node</a>.</p></li><li><p>Let <var>element</var> be the result of <a href="#create-an-element-for-the-token" id="creating-and-inserting-nodes:create-an-element-for-the-token">creating an element for the token</a> given <var>token</var>, <var>namespace</var>,
   and the element in which the <var>adjustedInsertionLocation</var> finds itself.</p></li><li><p>If <var>onlyAddToElementStack</var> is false, then run <a href="#insert-an-element-at-the-adjusted-insertion-location" id="creating-and-inserting-nodes:insert-an-element-at-the-adjusted-insertion-location">insert an element at the
   adjusted insertion location</a> with <var>element</var>.</p></li><li><p>Push <var>element</var> onto the <a href="#stack-of-open-elements" id="creating-and-inserting-nodes:stack-of-open-elements-7">stack of open elements</a> so that it is the new
   <a href="#current-node" id="creating-and-inserting-nodes:current-node-2">current node</a>.</p></li><li><p>Return <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>To <dfn id="insert-an-html-element">insert an HTML element</dfn> given a token <var>token</var>: <a href="#insert-a-foreign-element" id="creating-and-inserting-nodes:insert-a-foreign-element">insert a foreign
  element</a> given <var>token</var>, the <a id="creating-and-inserting-nodes:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, and false.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML attributes</dfn> for a token,
  then, if the token has an attribute named <code>definitionurl</code>, change its name to
  <code>definitionURL</code> (note the case difference).</p>
  </div>

  <div data-algorithm="">
  <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG attributes</dfn> for a token,
  then, for each attribute on the token whose attribute name is one of the ones in the first column
  of the following table, change the attribute's name to the name given in the corresponding cell in
  the second column. (This fixes the case of SVG attributes that are not all lowercase.)</p>

  <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
   </th></tr></thead><tbody><tr><td> <code>attributename</code> </td><td> <code>attributeName</code>
    </td></tr><tr><td> <code>attributetype</code> </td><td> <code>attributeType</code>
    </td></tr><tr><td> <code>basefrequency</code> </td><td> <code>baseFrequency</code>
    </td></tr><tr><td> <code>baseprofile</code> </td><td> <code>baseProfile</code>
    </td></tr><tr><td> <code>calcmode</code> </td><td> <code>calcMode</code>
    </td></tr><tr><td> <code>clippathunits</code> </td><td> <code>clipPathUnits</code>
    </td></tr><tr><td> <code>diffuseconstant</code> </td><td> <code>diffuseConstant</code>
    </td></tr><tr><td> <code>edgemode</code> </td><td> <code>edgeMode</code>
    </td></tr><tr><td> <code>filterunits</code> </td><td> <code>filterUnits</code>
    </td></tr><tr><td> <code>glyphref</code> </td><td> <code>glyphRef</code>
    </td></tr><tr><td> <code>gradienttransform</code> </td><td> <code>gradientTransform</code>
    </td></tr><tr><td> <code>gradientunits</code> </td><td> <code>gradientUnits</code>
    </td></tr><tr><td> <code>kernelmatrix</code> </td><td> <code>kernelMatrix</code>
    </td></tr><tr><td> <code>kernelunitlength</code> </td><td> <code>kernelUnitLength</code>
    </td></tr><tr><td> <code>keypoints</code> </td><td> <code>keyPoints</code>
    </td></tr><tr><td> <code>keysplines</code> </td><td> <code>keySplines</code>
    </td></tr><tr><td> <code>keytimes</code> </td><td> <code>keyTimes</code>
    </td></tr><tr><td> <code>lengthadjust</code> </td><td> <code>lengthAdjust</code>
    </td></tr><tr><td> <code>limitingconeangle</code> </td><td> <code>limitingConeAngle</code>
    </td></tr><tr><td> <code>markerheight</code> </td><td> <code>markerHeight</code>
    </td></tr><tr><td> <code>markerunits</code> </td><td> <code>markerUnits</code>
    </td></tr><tr><td> <code>markerwidth</code> </td><td> <code>markerWidth</code>
    </td></tr><tr><td> <code>maskcontentunits</code> </td><td> <code>maskContentUnits</code>
    </td></tr><tr><td> <code>maskunits</code> </td><td> <code>maskUnits</code>
    </td></tr><tr><td> <code>numoctaves</code> </td><td> <code>numOctaves</code>
    </td></tr><tr><td> <code>pathlength</code> </td><td> <code>pathLength</code>
    </td></tr><tr><td> <code>patterncontentunits</code> </td><td> <code>patternContentUnits</code>
    </td></tr><tr><td> <code>patterntransform</code> </td><td> <code>patternTransform</code>
    </td></tr><tr><td> <code>patternunits</code> </td><td> <code>patternUnits</code>
    </td></tr><tr><td> <code>pointsatx</code> </td><td> <code>pointsAtX</code>
    </td></tr><tr><td> <code>pointsaty</code> </td><td> <code>pointsAtY</code>
    </td></tr><tr><td> <code>pointsatz</code> </td><td> <code>pointsAtZ</code>
    </td></tr><tr><td> <code>preservealpha</code> </td><td> <code>preserveAlpha</code>
    </td></tr><tr><td> <code>preserveaspectratio</code> </td><td> <code>preserveAspectRatio</code>
    </td></tr><tr><td> <code>primitiveunits</code> </td><td> <code>primitiveUnits</code>
    </td></tr><tr><td> <code>refx</code> </td><td> <code>refX</code>
    </td></tr><tr><td> <code>refy</code> </td><td> <code>refY</code>
    </td></tr><tr><td> <code>repeatcount</code> </td><td> <code>repeatCount</code>
    </td></tr><tr><td> <code>repeatdur</code> </td><td> <code>repeatDur</code>
    </td></tr><tr><td> <code>requiredextensions</code> </td><td> <code>requiredExtensions</code>
    </td></tr><tr><td> <code>requiredfeatures</code> </td><td> <code>requiredFeatures</code>
    </td></tr><tr><td> <code>specularconstant</code> </td><td> <code>specularConstant</code>
    </td></tr><tr><td> <code>specularexponent</code> </td><td> <code>specularExponent</code>
    </td></tr><tr><td> <code>spreadmethod</code> </td><td> <code>spreadMethod</code>
    </td></tr><tr><td> <code>startoffset</code> </td><td> <code>startOffset</code>
    </td></tr><tr><td> <code>stddeviation</code> </td><td> <code>stdDeviation</code>
    </td></tr><tr><td> <code>stitchtiles</code> </td><td> <code>stitchTiles</code>
    </td></tr><tr><td> <code>surfacescale</code> </td><td> <code>surfaceScale</code>
    </td></tr><tr><td> <code>systemlanguage</code> </td><td> <code>systemLanguage</code>
    </td></tr><tr><td> <code>tablevalues</code> </td><td> <code>tableValues</code>
    </td></tr><tr><td> <code>targetx</code> </td><td> <code>targetX</code>
    </td></tr><tr><td> <code>targety</code> </td><td> <code>targetY</code>
    </td></tr><tr><td> <code>textlength</code> </td><td> <code>textLength</code>
    </td></tr><tr><td> <code>viewbox</code> </td><td> <code>viewBox</code>
    </td></tr><tr><td> <code>viewtarget</code> </td><td> <code>viewTarget</code>
    </td></tr><tr><td> <code>xchannelselector</code> </td><td> <code>xChannelSelector</code>
    </td></tr><tr><td> <code>ychannelselector</code> </td><td> <code>yChannelSelector</code>
    </td></tr><tr><td> <code>zoomandpan</code> </td><td> <code>zoomAndPan</code>
  </td></tr></tbody></table>
  </div>

  <div data-algorithm="">
  <p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust foreign attributes</dfn> for a
  token, then, if any of the attributes on the token match the strings given in the first column of
  the following table, let the attribute be a namespaced attribute, with the prefix being the string
  given in the corresponding cell in the second column, the local name being the string given in the
  corresponding cell in the third column, and the namespace being the namespace given in the
  corresponding cell in the fourth column. (This fixes the use of namespaced attributes, in
  particular <a href="https://www.w3.org/TR/xml/#sec-lang-tag" id="creating-and-inserting-nodes:attr-xml-lang" data-x-internal="attr-xml-lang"><code>lang</code> attributes in the <span>XML
  namespace</span></a>.)</p>

  <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
   </th></tr></thead><tbody><tr><td> <code>xlink:actuate</code> </td><td> <code>xlink</code> </td><td> <code>actuate</code> </td><td> <a id="creating-and-inserting-nodes:xlink-namespace-2" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a>
    </td></tr><tr><td> <code>xlink:arcrole</code> </td><td> <code>xlink</code> </td><td> <code>arcrole</code> </td><td> <a id="creating-and-inserting-nodes:xlink-namespace-3" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a>
    </td></tr><tr><td> <code>xlink:href</code> </td><td> <code>xlink</code> </td><td> <code>href</code> </td><td> <a id="creating-and-inserting-nodes:xlink-namespace-4" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a>
    </td></tr><tr><td> <code>xlink:role</code> </td><td> <code>xlink</code> </td><td> <code>role</code> </td><td> <a id="creating-and-inserting-nodes:xlink-namespace-5" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a>
    </td></tr><tr><td> <code>xlink:show</code> </td><td> <code>xlink</code> </td><td> <code>show</code> </td><td> <a id="creating-and-inserting-nodes:xlink-namespace-6" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a>
    </td></tr><tr><td> <code>xlink:title</code> </td><td> <code>xlink</code> </td><td> <code>title</code> </td><td> <a id="creating-and-inserting-nodes:xlink-namespace-7" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a>
    </td></tr><tr><td> <code>xlink:type</code> </td><td> <code>xlink</code> </td><td> <code>type</code> </td><td> <a id="creating-and-inserting-nodes:xlink-namespace-8" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a>
    </td></tr><tr><td> <code>xml:lang</code> </td><td> <code>xml</code> </td><td> <code>lang</code> </td><td> <a id="creating-and-inserting-nodes:xml-namespace" href="https://infra.spec.whatwg.org/#xml-namespace" data-x-internal="xml-namespace">XML namespace</a>
    </td></tr><tr><td> <code>xml:space</code> </td><td> <code>xml</code> </td><td> <code>space</code> </td><td> <a id="creating-and-inserting-nodes:xml-namespace-2" href="https://infra.spec.whatwg.org/#xml-namespace" data-x-internal="xml-namespace">XML namespace</a>
    </td></tr><tr><td> <code>xmlns</code> </td><td> (none) </td><td> <code>xmlns</code> </td><td> <a id="creating-and-inserting-nodes:xmlns-namespace-3" href="https://infra.spec.whatwg.org/#xmlns-namespace" data-x-internal="xmlns-namespace">XMLNS namespace</a>
    </td></tr><tr><td> <code>xmlns:xlink</code> </td><td> <code>xmlns</code> </td><td> <code>xlink</code> </td><td> <a id="creating-and-inserting-nodes:xmlns-namespace-4" href="https://infra.spec.whatwg.org/#xmlns-namespace" data-x-internal="xmlns-namespace">XMLNS namespace</a>
  </td></tr></tbody></table>
  </div>

  <hr>

  <div data-algorithm="">
  <p>When the steps below require the user agent to <dfn id="insert-a-character">insert a character</dfn> while processing a
  token, the user agent must run the following steps:</p>

  <ol><li><p>Let <var>data</var> be the characters passed to the algorithm, or, if no
   characters were explicitly specified, the character of the character token being
   processed.</p></li><li><p>Let the <var>adjusted insertion location</var> be the <a href="#appropriate-place-for-inserting-a-node" id="creating-and-inserting-nodes:appropriate-place-for-inserting-a-node-3">appropriate
   place for inserting a node</a>.</p></li><li>
    <p>If the <var>adjusted insertion location</var> is in a <code id="creating-and-inserting-nodes:document-2"><a href="#document">Document</a></code> node,
    then return.

    </p><p class="note">The DOM will not let <code id="creating-and-inserting-nodes:document-3"><a href="#document">Document</a></code> nodes have <code id="creating-and-inserting-nodes:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node
    children, so they are dropped on the floor.</p>
   </li><li>
    <p>If there is a <code id="creating-and-inserting-nodes:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node immediately before the <var>adjusted insertion
    location</var>, then append <var>data</var> to that <code id="creating-and-inserting-nodes:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node's <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="creating-and-inserting-nodes:concept-cd-data" data-x-internal="concept-cd-data">data</a>.</p>

    <p>Otherwise, create a new <code id="creating-and-inserting-nodes:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node whose <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="creating-and-inserting-nodes:concept-cd-data-2" data-x-internal="concept-cd-data">data</a> is <var>data</var> and
    whose <a id="creating-and-inserting-nodes:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is the same as that of the
    element in which the <var>adjusted insertion location</var> finds itself, and insert
    the newly created node at the <var>adjusted insertion location</var>.</p>
   </li></ol>
  </div>

  <div class="example">

   <p>Here are some sample inputs to the parser and the corresponding number of <code id="creating-and-inserting-nodes:text-5"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code>
   nodes that they result in, assuming a user agent that executes scripts.</p>

   <table><thead><tr><th>Input </th><th>Number of <code id="creating-and-inserting-nodes:text-6"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes
    </th></tr></thead><tbody><tr><td><pre><code class="html">A<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- a="">var</c->&nbsp;script&nbsp;<c- o="">=</c->&nbsp;document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'script'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">];</c->
document<c- p="">.</c->body<c- p="">.</c->removeChild<c- p="">(</c->script<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->B</code></pre>
      </td><td>One <code id="creating-and-inserting-nodes:text-7"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node in the document, containing "AB".
     </td></tr><tr><td><pre><code class="html">A<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- a="">var</c->&nbsp;text&nbsp;<c- o="">=</c->&nbsp;document<c- p="">.</c->createTextNode<c- p="">(</c-><c- t="">'B'</c-><c- p="">);</c->
document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->text<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->C</code></pre>
      </td><td>Three <code id="creating-and-inserting-nodes:text-8"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes; "A" before the script, the script's contents, and "BC" after the script (the parser appends to the <code id="creating-and-inserting-nodes:text-9"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node created by the script).
     </td></tr><tr><td><pre><code class="html">A<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- a="">var</c->&nbsp;text&nbsp;<c- o="">=</c->&nbsp;document<c- p="">.</c->getElementsByTagName<c- p="">(</c-><c- t="">'script'</c-><c- p="">)[</c-><c- mf="">0</c-><c- p="">].</c->firstChild<c- p="">;</c->
text<c- p="">.</c->data&nbsp;<c- o="">=</c->&nbsp;<c- t="">'B'</c-><c- p="">;</c->
document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->text<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->C</code></pre>
      </td><td>Two adjacent <code id="creating-and-inserting-nodes:text-10"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes in the document, containing "A" and "BC".
     </td></tr><tr><td><pre><code class="html">A<c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->B<c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->C<c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->D<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>
      </td><td>One <code id="creating-and-inserting-nodes:text-11"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node before the table, containing "ABCD". (This is caused by <a href="#foster-parent" id="creating-and-inserting-nodes:foster-parent-2">foster parenting</a>.)
     </td></tr><tr><td><pre><code class="html">A<c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->&nbsp;B<c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->&nbsp;C<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>
      </td><td>One <code id="creating-and-inserting-nodes:text-12"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node before the table, containing "A&nbsp;B&nbsp;C" (A-space-B-space-C). (This is caused by <a href="#foster-parent" id="creating-and-inserting-nodes:foster-parent-3">foster parenting</a>.)
     </td></tr><tr><td><pre><code class="html">A<c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->&nbsp;B<c- p="">&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c->&nbsp;<c- p="">&lt;/</c-><c- f="">em</c-><c- p="">&gt;</c->C<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></code></pre>
      </td><td>One <code id="creating-and-inserting-nodes:text-13"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node before the table, containing "A&nbsp;BC" (A-space-B-C), and one <code id="creating-and-inserting-nodes:text-14"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node inside the table (as a child of a <code id="creating-and-inserting-nodes:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code>) with a single space character. (Space characters separated from non-space characters by non-character tokens are not affected by <a href="#foster-parent" id="creating-and-inserting-nodes:foster-parent-4">foster parenting</a>, even if those other tokens then get ignored.)
   </td></tr></tbody></table>

  </div>

  <hr>

  <div data-algorithm="">
  <p>When the steps below require the user agent to <dfn id="insert-a-comment">insert a comment</dfn> while processing a
  comment token, optionally with an explicit insertion position <var>position</var>, the
  user agent must run the following steps:</p>

  <ol><li><p>Let <var>data</var> be the data given in the comment token being
   processed.</p></li><li><p>If <var>position</var> was specified, then let the <var>adjusted
   insertion location</var> be <var>position</var>. Otherwise, let <var>adjusted
   insertion location</var> be the <a href="#appropriate-place-for-inserting-a-node" id="creating-and-inserting-nodes:appropriate-place-for-inserting-a-node-4">appropriate place for inserting a node</a>.</p></li><li><p>Create a <code id="creating-and-inserting-nodes:comment-2"><a data-x-internal="comment-2" href="https://dom.spec.whatwg.org/#interface-comment">Comment</a></code> node whose <code>data</code> attribute is set to
   <var>data</var> and whose <a id="creating-and-inserting-nodes:node-document-3" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is
   the same as that of the node in which the <var>adjusted insertion location</var> finds
   itself.</p>

   </li><li><p>Insert the newly created node at the <var>adjusted insertion
   location</var>.</p></li></ol>
  </div>

  <h5 id="parsing-elements-that-contain-only-text"><span class="secno">13.2.6.2</span> Parsing elements that contain only text<a href="#parsing-elements-that-contain-only-text" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>The <dfn id="generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</dfn> and the <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element
  parsing algorithm</dfn> consist of the following steps. These algorithms are always invoked in
  response to a start tag token.</p>

  <ol><li><p><a href="#insert-an-html-element" id="parsing-elements-that-contain-only-text:insert-an-html-element">Insert an HTML element</a> for the token.</p></li><li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm" id="parsing-elements-that-contain-only-text:generic-raw-text-element-parsing-algorithm">generic raw text element parsing
   algorithm</a>, switch the tokenizer to the <a href="#rawtext-state" id="parsing-elements-that-contain-only-text:rawtext-state">RAWTEXT state</a>; otherwise the algorithm
   invoked was the <a href="#generic-rcdata-element-parsing-algorithm" id="parsing-elements-that-contain-only-text:generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>, switch the tokenizer to
   the <a href="#rcdata-state" id="parsing-elements-that-contain-only-text:rcdata-state">RCDATA state</a>.</p></li><li><p>Set the <a href="#original-insertion-mode" id="parsing-elements-that-contain-only-text:original-insertion-mode">original insertion mode</a> to the current <a href="#insertion-mode" id="parsing-elements-that-contain-only-text:insertion-mode">insertion
   mode</a>.</p>

   </li><li><p>Then, switch the <a href="#insertion-mode" id="parsing-elements-that-contain-only-text:insertion-mode-2">insertion mode</a> to "<a href="#parsing-main-incdata" id="parsing-elements-that-contain-only-text:parsing-main-incdata">text</a>".</p></li></ol>
  </div>


  <h5 id="closing-elements-that-have-implied-end-tags"><span class="secno">13.2.6.3</span> Closing elements that have implied end tags<a href="#closing-elements-that-have-implied-end-tags" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end tags</dfn>, then, while the
  <a href="#current-node" id="closing-elements-that-have-implied-end-tags:current-node">current node</a> is a <code id="closing-elements-that-have-implied-end-tags:the-dd-element"><a href="#the-dd-element">dd</a></code> element, a <code id="closing-elements-that-have-implied-end-tags:the-dt-element"><a href="#the-dt-element">dt</a></code> element, an
  <code id="closing-elements-that-have-implied-end-tags:the-li-element"><a href="#the-li-element">li</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:the-option-element"><a href="#the-option-element">option</a></code> element, a
  <code id="closing-elements-that-have-implied-end-tags:the-p-element"><a href="#the-p-element">p</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:rb"><a href="#rb">rb</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:the-rp-element"><a href="#the-rp-element">rp</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:the-rt-element"><a href="#the-rt-element">rt</a></code>
  element, or an <code id="closing-elements-that-have-implied-end-tags:rtc"><a href="#rtc">rtc</a></code> element, the UA must pop the <a href="#current-node" id="closing-elements-that-have-implied-end-tags:current-node-2">current node</a> off the
  <a href="#stack-of-open-elements" id="closing-elements-that-have-implied-end-tags:stack-of-open-elements">stack of open elements</a>.</p>

  <p>If a step requires the UA to generate implied end tags but lists an element to exclude from the
  process, then the UA must perform the above steps as if that element was not in the above
  list.</p>
  </div>

  <div data-algorithm="">
  <p>When the steps below require the UA to <dfn id="generate-all-implied-end-tags-thoroughly">generate all implied end tags thoroughly</dfn>,
  then, while the <a href="#current-node" id="closing-elements-that-have-implied-end-tags:current-node-3">current node</a> is a <code id="closing-elements-that-have-implied-end-tags:the-caption-element"><a href="#the-caption-element">caption</a></code> element, a
  <code id="closing-elements-that-have-implied-end-tags:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> element, a <code id="closing-elements-that-have-implied-end-tags:the-dd-element-2"><a href="#the-dd-element">dd</a></code> element, a <code id="closing-elements-that-have-implied-end-tags:the-dt-element-2"><a href="#the-dt-element">dt</a></code> element, an
  <code id="closing-elements-that-have-implied-end-tags:the-li-element-2"><a href="#the-li-element">li</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:the-option-element-2"><a href="#the-option-element">option</a></code> element, a
  <code id="closing-elements-that-have-implied-end-tags:the-p-element-2"><a href="#the-p-element">p</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:rb-2"><a href="#rb">rb</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:the-rp-element-2"><a href="#the-rp-element">rp</a></code> element, an <code id="closing-elements-that-have-implied-end-tags:the-rt-element-2"><a href="#the-rt-element">rt</a></code>
  element, an <code id="closing-elements-that-have-implied-end-tags:rtc-2"><a href="#rtc">rtc</a></code> element, a <code id="closing-elements-that-have-implied-end-tags:the-tbody-element"><a href="#the-tbody-element">tbody</a></code> element, a <code id="closing-elements-that-have-implied-end-tags:the-td-element"><a href="#the-td-element">td</a></code> element, a
  <code id="closing-elements-that-have-implied-end-tags:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> element, a <code id="closing-elements-that-have-implied-end-tags:the-th-element"><a href="#the-th-element">th</a></code> element, a <code id="closing-elements-that-have-implied-end-tags:the-thead-element"><a href="#the-thead-element">thead</a></code> element, or a
  <code id="closing-elements-that-have-implied-end-tags:the-tr-element"><a href="#the-tr-element">tr</a></code> element, the UA must pop the <a href="#current-node" id="closing-elements-that-have-implied-end-tags:current-node-4">current node</a> off the
  <a href="#stack-of-open-elements" id="closing-elements-that-have-implied-end-tags:stack-of-open-elements-2">stack of open elements</a>.</p>
  </div>



  <h5 id="parsing-main-inhtml"><span class="secno">13.2.6.4</span> The rules for parsing tokens in HTML content<a href="#parsing-main-inhtml" class="self-link"></a></h5>


  <h6 id="the-initial-insertion-mode"><span class="secno">13.2.6.4.1</span> The "<dfn>initial</dfn>" insertion mode<a href="#the-initial-insertion-mode" class="self-link"></a></h6>

  <p>A <code id="the-initial-insertion-mode:document"><a href="#document">Document</a></code> object has an associated <dfn id="parser-cannot-change-the-mode-flag">parser cannot change the mode flag</dfn>
  (a boolean). It is initially false.</p>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#the-initial-insertion-mode" id="the-initial-insertion-mode:the-initial-insertion-mode">initial</a>" <a href="#insertion-mode" id="the-initial-insertion-mode:insertion-mode">insertion mode</a>, the user agent must handle the token as
  follows:</p>

  <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
   TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
   U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p>Ignore the token.</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="the-initial-insertion-mode:insert-a-comment">Insert a comment</a> as the last child of the <code id="the-initial-insertion-mode:document-2"><a href="#document">Document</a></code> object.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p>If the DOCTYPE token's name is not "<code>html</code>", or the token's public
    identifier is not missing, or the token's system identifier is neither missing nor
    "<code id="the-initial-insertion-mode:about:legacy-compat"><a href="#about:legacy-compat">about:legacy-compat</a></code>", then there is a <a href="#parse-errors" id="the-initial-insertion-mode:parse-errors">parse error</a>.</p>

    <p>Append a <code id="the-initial-insertion-mode:documenttype"><a data-x-internal="documenttype" href="https://dom.spec.whatwg.org/#interface-documenttype">DocumentType</a></code> node to the <code id="the-initial-insertion-mode:document-3"><a href="#document">Document</a></code> node, with its <a href="https://dom.spec.whatwg.org/#concept-doctype-name" id="the-initial-insertion-mode:concept-doctype-name" data-x-internal="concept-doctype-name">name</a> set to the name given in the DOCTYPE token, or the
    empty string if the name was missing; its <a href="https://dom.spec.whatwg.org/#concept-doctype-publicid" id="the-initial-insertion-mode:concept-doctype-publicid" data-x-internal="concept-doctype-publicid">public
    ID</a> set to the public identifier given in the DOCTYPE token, or the empty string if the
    public identifier was missing; and its <a href="https://dom.spec.whatwg.org/#concept-doctype-systemid" id="the-initial-insertion-mode:concept-doctype-systemid" data-x-internal="concept-doctype-systemid">system ID</a>
    set to the system identifier given in the DOCTYPE token, or the empty string if the system
    identifier was missing.</p>

    <p class="note">This also ensures that the <code id="the-initial-insertion-mode:documenttype-2"><a data-x-internal="documenttype" href="https://dom.spec.whatwg.org/#interface-documenttype">DocumentType</a></code> node is returned as the
    value of the <code id="the-initial-insertion-mode:dom-document-doctype"><a data-x-internal="dom-document-doctype" href="https://dom.spec.whatwg.org/#dom-document-doctype">doctype</a></code> attribute of the
    <code id="the-initial-insertion-mode:document-4"><a href="#document">Document</a></code> object.</p>

    <p id="quirks-mode-doctypes">Then, if the document is <em>not</em> <a href="#an-iframe-srcdoc-document" id="the-initial-insertion-mode:an-iframe-srcdoc-document">an <code>iframe</code>
    <code>srcdoc</code> document</a>, and the <a href="#parser-cannot-change-the-mode-flag" id="the-initial-insertion-mode:parser-cannot-change-the-mode-flag">parser cannot
    change the mode flag</a> is false, and the DOCTYPE token matches one of the conditions in the
    following list, then set the <code id="the-initial-insertion-mode:document-5"><a href="#document">Document</a></code> to <a id="the-initial-insertion-mode:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>:</p>

    <ul class="brief"><li> The <i id="the-initial-insertion-mode:force-quirks-flag"><a href="#force-quirks-flag">force-quirks flag</a></i> is set to <i>on</i>. </li><li> The name is not "<code>html</code>". </li><li> The public identifier is set to: "<code>-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li><li> The public identifier is set to: "<code>-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li><li> The public identifier is set to: "<code>HTML</code>" </li><li> The system identifier is set to: "<code>http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li><li> The public identifier starts with: "<code>+//Silmaril//dtd html Pro v0r11 19970101//</code>" </li><li> The public identifier starts with: "<code>-//AS//DTD HTML 3.0 asWedit + extensions//</code>" </li><li> The public identifier starts with: "<code>-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Level 1//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Level 2//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Strict Level 1//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Strict Level 2//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Strict//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.1E//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 3.0//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 3.2 Final//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 3.2//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML 3//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 0//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 1//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 2//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 3//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 0//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 1//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 2//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 3//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict//</code>" </li><li> The public identifier starts with: "<code>-//IETF//DTD HTML//</code>" </li><li> The public identifier starts with: "<code>-//Metrius//DTD Metrius Presentational//</code>" </li><li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//</code>" </li><li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 2.0 HTML//</code>" </li><li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 2.0 Tables//</code>" </li><li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//</code>" </li><li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 3.0 HTML//</code>" </li><li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 3.0 Tables//</code>" </li><li> The public identifier starts with: "<code>-//Netscape Comm. Corp.//DTD HTML//</code>" </li><li> The public identifier starts with: "<code>-//Netscape Comm. Corp.//DTD Strict HTML//</code>" </li><li> The public identifier starts with: "<code>-//O'Reilly and Associates//DTD HTML 2.0//</code>" </li><li> The public identifier starts with: "<code>-//O'Reilly and Associates//DTD HTML Extended 1.0//</code>" </li><li> The public identifier starts with: "<code>-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//</code>" </li><li> The public identifier starts with: "<code>-//SQ//DTD HTML 2.0 HoTMetaL + extensions//</code>" </li><li> The public identifier starts with: "<code>-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//</code>" </li><li> The public identifier starts with: "<code>-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//</code>" </li><li> The public identifier starts with: "<code>-//Spyglass//DTD HTML 2.0 Extended//</code>" </li><li> The public identifier starts with: "<code>-//Sun Microsystems Corp.//DTD HotJava HTML//</code>" </li><li> The public identifier starts with: "<code>-//Sun Microsystems Corp.//DTD HotJava Strict HTML//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD HTML 3 1995-03-24//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2 Draft//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2 Final//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2S Draft//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD HTML 4.0 Frameset//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD HTML 4.0 Transitional//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD HTML Experimental 19960712//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD HTML Experimental 970421//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD W3 HTML//</code>" </li><li> The public identifier starts with: "<code>-//W3O//DTD W3 HTML 3.0//</code>" </li><li> The public identifier starts with: "<code>-//WebTechs//DTD Mozilla HTML 2.0//</code>" </li><li> The public identifier starts with: "<code>-//WebTechs//DTD Mozilla HTML//</code>" </li><li> The system identifier is missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Frameset//</code>" </li><li> The system identifier is missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Transitional//</code>" </li></ul>

    <p>Otherwise, if the document is <em>not</em> <a href="#an-iframe-srcdoc-document" id="the-initial-insertion-mode:an-iframe-srcdoc-document-2">an <code>iframe</code> <code>srcdoc</code> document</a>, and the <a href="#parser-cannot-change-the-mode-flag" id="the-initial-insertion-mode:parser-cannot-change-the-mode-flag-2">parser cannot change
    the mode flag</a> is false, and the DOCTYPE token matches one of the conditions in the
    following list, then set the <code id="the-initial-insertion-mode:document-6"><a href="#document">Document</a></code> to <a id="the-initial-insertion-mode:limited-quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-limited-quirks" data-x-internal="limited-quirks-mode">limited-quirks mode</a>:</p>

    <ul class="brief"><li> The public identifier starts with: "<code>-//W3C//DTD XHTML 1.0 Frameset//</code>" </li><li> The public identifier starts with: "<code>-//W3C//DTD XHTML 1.0 Transitional//</code>" </li><li> The system identifier is not missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Frameset//</code>" </li><li> The system identifier is not missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Transitional//</code>" </li></ul>

    <p>The system identifier and public identifier strings must be compared to the values given in
    the lists above in an <a id="the-initial-insertion-mode:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> manner. A system identifier whose
    value is the empty string is not considered missing for the purposes of the conditions
    above.</p>

    <p>Then, switch the <a href="#insertion-mode" id="the-initial-insertion-mode:insertion-mode-2">insertion mode</a> to "<a href="#the-before-html-insertion-mode" id="the-initial-insertion-mode:the-before-html-insertion-mode">before html</a>".</p>
   </dd><dt>Anything else</dt><dd>
    <p>If the document is <em>not</em> <a href="#an-iframe-srcdoc-document" id="the-initial-insertion-mode:an-iframe-srcdoc-document-3">an <code>iframe</code> <code>srcdoc</code> document</a>, then this is a <a href="#parse-errors" id="the-initial-insertion-mode:parse-errors-2">parse
    error</a>; if the <a href="#parser-cannot-change-the-mode-flag" id="the-initial-insertion-mode:parser-cannot-change-the-mode-flag-3">parser cannot change the mode flag</a> is false, set the
    <code id="the-initial-insertion-mode:document-7"><a href="#document">Document</a></code> to <a id="the-initial-insertion-mode:quirks-mode-2" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>.</p>

    <p>In any case, switch the <a href="#insertion-mode" id="the-initial-insertion-mode:insertion-mode-3">insertion mode</a> to "<a href="#the-before-html-insertion-mode" id="the-initial-insertion-mode:the-before-html-insertion-mode-2">before html</a>", then reprocess the token.</p>
   </dd></dl>
  </div>


  <h6 id="the-before-html-insertion-mode"><span class="secno">13.2.6.4.2</span> The "<dfn>before html</dfn>" insertion mode<a href="#the-before-html-insertion-mode" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#the-before-html-insertion-mode" id="the-before-html-insertion-mode:the-before-html-insertion-mode">before html</a>" <a href="#insertion-mode" id="the-before-html-insertion-mode:insertion-mode">insertion mode</a>, the user agent must handle the token as
  follows:</p>

  <dl class="switch"><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="the-before-html-insertion-mode:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="the-before-html-insertion-mode:insert-a-comment">Insert a comment</a> as the last child of the <code id="the-before-html-insertion-mode:document"><a href="#document">Document</a></code> object.</p>
   </dd><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
   FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p>Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p><a href="#create-an-element-for-the-token" id="the-before-html-insertion-mode:create-an-element-for-the-token">Create an element for the token</a> in the <a id="the-before-html-insertion-mode:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, with the
    <code id="the-before-html-insertion-mode:document-2"><a href="#document">Document</a></code> as the intended parent. Append it to the <code id="the-before-html-insertion-mode:document-3"><a href="#document">Document</a></code> object. Put
    this element in the <a href="#stack-of-open-elements" id="the-before-html-insertion-mode:stack-of-open-elements">stack of open elements</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="the-before-html-insertion-mode:insertion-mode-2">insertion mode</a> to "<a href="#the-before-head-insertion-mode" id="the-before-html-insertion-mode:the-before-head-insertion-mode">before
    head</a>".</p>
   </dd><dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt><dd>
    <p>Act as described in the "anything else" entry below.</p>
   </dd><dt>Any other end tag</dt><dd>
    <p><a href="#parse-errors" id="the-before-html-insertion-mode:parse-errors-2">Parse error</a>. Ignore the token.</p>
   </dd><dt>Anything else</dt><dd>
    <p>Create an <code id="the-before-html-insertion-mode:the-html-element"><a href="#the-html-element">html</a></code> element whose <a id="the-before-html-insertion-mode:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is the <code id="the-before-html-insertion-mode:document-4"><a href="#document">Document</a></code> object. Append
    it to the <code id="the-before-html-insertion-mode:document-5"><a href="#document">Document</a></code> object. Put this element in the <a href="#stack-of-open-elements" id="the-before-html-insertion-mode:stack-of-open-elements-2">stack of open
    elements</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="the-before-html-insertion-mode:insertion-mode-3">insertion mode</a> to "<a href="#the-before-head-insertion-mode" id="the-before-html-insertion-mode:the-before-head-insertion-mode-2">before
    head</a>", then reprocess the token.</p>
   </dd></dl>
  </div>

  <p>The <a id="the-before-html-insertion-mode:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> can end up being removed from the <code id="the-before-html-insertion-mode:document-6"><a href="#document">Document</a></code>
  object, e.g. by scripts; nothing in particular happens in such cases, content continues being
  appended to the nodes as described in the next section.</p>


  <h6 id="the-before-head-insertion-mode"><span class="secno">13.2.6.4.3</span> The "<dfn>before head</dfn>" insertion mode<a href="#the-before-head-insertion-mode" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#the-before-head-insertion-mode" id="the-before-head-insertion-mode:the-before-head-insertion-mode">before head</a>" <a href="#insertion-mode" id="the-before-head-insertion-mode:insertion-mode">insertion mode</a>, the user agent must handle the token as
  follows:</p>

  <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
   TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
   U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p>Ignore the token.</p> 
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="the-before-head-insertion-mode:insert-a-comment">Insert a comment</a>.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="the-before-head-insertion-mode:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="the-before-head-insertion-mode:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="the-before-head-insertion-mode:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="the-before-head-insertion-mode:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>A start tag whose tag name is "head"</dt><dd>
    <p><a href="#insert-an-html-element" id="the-before-head-insertion-mode:insert-an-html-element">Insert an HTML element</a> for the token.</p>

    <p>Set the <a href="#head-element-pointer" id="the-before-head-insertion-mode:head-element-pointer"><code>head</code> element pointer</a> to the newly created
    <code id="the-before-head-insertion-mode:the-head-element"><a href="#the-head-element">head</a></code> element.</p>

    <p>Switch the <a href="#insertion-mode" id="the-before-head-insertion-mode:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-inhead" id="the-before-head-insertion-mode:parsing-main-inhead">in
    head</a>".</p>
   </dd><dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt><dd>
    <p>Act as described in the "anything else" entry below.</p>
   </dd><dt>Any other end tag</dt><dd>
    <p><a href="#parse-errors" id="the-before-head-insertion-mode:parse-errors-2">Parse error</a>. Ignore the token.</p>
   </dd><dt>Anything else</dt><dd>
    

    <p><a href="#insert-an-html-element" id="the-before-head-insertion-mode:insert-an-html-element-2">Insert an HTML element</a> for a "head" start tag token with no attributes.</p>

    <p>Set the <a href="#head-element-pointer" id="the-before-head-insertion-mode:head-element-pointer-2"><code>head</code> element pointer</a> to the newly created
    <code id="the-before-head-insertion-mode:the-head-element-2"><a href="#the-head-element">head</a></code> element.</p>

    <p>Switch the <a href="#insertion-mode" id="the-before-head-insertion-mode:insertion-mode-4">insertion mode</a> to "<a href="#parsing-main-inhead" id="the-before-head-insertion-mode:parsing-main-inhead-2">in
    head</a>".</p>

    

    <p>Reprocess the current token.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-inhead"><span class="secno">13.2.6.4.4</span> The "<dfn>in head</dfn>" insertion mode<a href="#parsing-main-inhead" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-inhead" id="parsing-main-inhead:parsing-main-inhead">in
  head</a>" <a href="#insertion-mode" id="parsing-main-inhead:insertion-mode">insertion mode</a>, the user agent must handle the token as follows:</p>

  <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
   TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
   U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p><a href="#insert-a-character" id="parsing-main-inhead:insert-a-character">Insert the character</a>.</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="parsing-main-inhead:insert-a-comment">Insert a comment</a>.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inhead:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-inhead:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-inhead:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-inhead:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>A start tag whose tag name is one of: "base", "basefont",
   "bgsound", "link"</dt><dd>
    <p><a href="#insert-an-html-element" id="parsing-main-inhead:insert-an-html-element">Insert an HTML element</a> for the token. Immediately pop the <a href="#current-node" id="parsing-main-inhead:current-node">current
    node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inhead:stack-of-open-elements">stack of open elements</a>.</p>

    <p><a href="#acknowledge-self-closing-flag" id="parsing-main-inhead:acknowledge-self-closing-flag">Acknowledge the token's <i>self-closing
    flag</i></a>, if it is set.</p>
   </dd><dt>A start tag whose tag name is "meta"</dt><dd>
    <p><a href="#insert-an-html-element" id="parsing-main-inhead:insert-an-html-element-2">Insert an HTML element</a> for the token. Immediately pop the <a href="#current-node" id="parsing-main-inhead:current-node-2">current
    node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inhead:stack-of-open-elements-2">stack of open elements</a>.</p>

    <p><a href="#acknowledge-self-closing-flag" id="parsing-main-inhead:acknowledge-self-closing-flag-2">Acknowledge the token's <i>self-closing
    flag</i></a>, if it is set.</p>

    <p>If the <a href="#active-speculative-html-parser" id="parsing-main-inhead:active-speculative-html-parser">active speculative HTML parser</a> is null, then:</p>

    <ol><li><p id="meta-charset-during-parse">If the element has a <code id="parsing-main-inhead:attr-meta-charset"><a href="#attr-meta-charset">charset</a></code> attribute, and <a id="parsing-main-inhead:getting-an-encoding" href="https://encoding.spec.whatwg.org/#concept-encoding-get" data-x-internal="getting-an-encoding">getting an encoding</a> from
     its value results in an <a id="parsing-main-inhead:encoding" href="https://encoding.spec.whatwg.org/#encoding" data-x-internal="encoding">encoding</a>, and the
     <a href="#concept-encoding-confidence" id="parsing-main-inhead:concept-encoding-confidence">confidence</a> is currently <i>tentative</i>,
     then <a href="#change-the-encoding" id="parsing-main-inhead:change-the-encoding">change the encoding</a> to the resulting encoding.</p></li><li><p>Otherwise, if the element has an <code id="parsing-main-inhead:attr-meta-http-equiv"><a href="#attr-meta-http-equiv">http-equiv</a></code>
     attribute whose value is an <a id="parsing-main-inhead:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>Content-Type</code>", and the element has a <code id="parsing-main-inhead:attr-meta-content"><a href="#attr-meta-content">content</a></code> attribute, and applying the <a href="#algorithm-for-extracting-a-character-encoding-from-a-meta-element" id="parsing-main-inhead:algorithm-for-extracting-a-character-encoding-from-a-meta-element">algorithm for
     extracting a character encoding from a <code>meta</code> element</a> to that attribute's
     value returns an <a id="parsing-main-inhead:encoding-2" href="https://encoding.spec.whatwg.org/#encoding" data-x-internal="encoding">encoding</a>, and the
     <a href="#concept-encoding-confidence" id="parsing-main-inhead:concept-encoding-confidence-2">confidence</a> is currently <i>tentative</i>,
     then <a href="#change-the-encoding" id="parsing-main-inhead:change-the-encoding-2">change the encoding</a> to the extracted encoding.</p></li></ol>

    <p class="note">The <a href="#speculative-html-parser" id="parsing-main-inhead:speculative-html-parser">speculative HTML parser</a> doesn't speculatively apply character
    encoding declarations in order to reduce implementation complexity.</p>
   </dd><dt>A start tag whose tag name is "title"</dt><dd>
    <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm" id="parsing-main-inhead:generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
   </dd><dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag" id="parsing-main-inhead:scripting-flag">scripting flag</a> is enabled</dt><dt>A start tag whose tag name is one of: "noframes", "style"</dt><dd>
    <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm" id="parsing-main-inhead:generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
   </dd><dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag" id="parsing-main-inhead:scripting-flag-2">scripting flag</a> is disabled</dt><dd>
    <p><a href="#insert-an-html-element" id="parsing-main-inhead:insert-an-html-element-3">Insert an HTML element</a> for the token.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-inhead:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" id="parsing-main-inhead:parsing-main-inheadnoscript">in
    head noscript</a>".</p>
   </dd><dt id="scriptTag">A start tag whose tag name is "script"</dt><dd>
    <p>Run these steps:</p>

    <ol><li><p>Let the <var>adjusted insertion location</var> be the <a href="#appropriate-place-for-inserting-a-node" id="parsing-main-inhead:appropriate-place-for-inserting-a-node">appropriate place
     for inserting a node</a>.</p></li><li><p><a href="#create-an-element-for-the-token" id="parsing-main-inhead:create-an-element-for-the-token">Create an element for the token</a> in the <a id="parsing-main-inhead:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, with
     the intended parent being the element in which the <var>adjusted insertion
     location</var> finds itself.</p></li><li>
      <p>Set the element's <a href="#parser-document" id="parsing-main-inhead:parser-document">parser document</a> to the <code id="parsing-main-inhead:document"><a href="#document">Document</a></code>, and set the
      element's <a href="#script-force-async" id="parsing-main-inhead:script-force-async">force async</a> to false.</p>

      <p class="note">This ensures that, if the script is external, any <code id="parsing-main-inhead:dom-document-write"><a href="#dom-document-write">document.write()</a></code> calls in the script will execute in-line,
      instead of blowing the document away, as would happen in most other cases. It also prevents
      the script from executing until the end tag is seen.</p>
     </li><li><p>If the parser was created as part of the <a href="#html-fragment-parsing-algorithm" id="parsing-main-inhead:html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>,
     then set the <code id="parsing-main-inhead:the-script-element"><a href="#the-script-element">script</a></code> element's <a href="#already-started" id="parsing-main-inhead:already-started">already started</a> to true.
     (<a href="#fragment-case" id="parsing-main-inhead:fragment-case">fragment case</a>)</p></li><li id="document-written-scripts-intervention"><p>If the parser was invoked via the <code id="parsing-main-inhead:dom-document-write-2"><a href="#dom-document-write">document.write()</a></code> or <code id="parsing-main-inhead:dom-document-writeln"><a href="#dom-document-writeln">document.writeln()</a></code> methods, then optionally set the
     <code id="parsing-main-inhead:the-script-element-2"><a href="#the-script-element">script</a></code> element's <a href="#already-started" id="parsing-main-inhead:already-started-2">already started</a> to true. (For example, the user
     agent might use this clause to prevent execution of <a href="#concept-origin" id="parsing-main-inhead:concept-origin">cross-origin</a>
     scripts inserted via <code id="parsing-main-inhead:dom-document-write-3"><a href="#dom-document-write">document.write()</a></code> under slow
     network conditions, or when the page has already taken a long time to load.)</p></li><li><p>Insert the newly created element at the <var>adjusted insertion
     location</var>.</p></li><li><p>Push the element onto the <a href="#stack-of-open-elements" id="parsing-main-inhead:stack-of-open-elements-3">stack of open elements</a> so that it is the new
     <a href="#current-node" id="parsing-main-inhead:current-node-3">current node</a>.</p></li><li><p>Switch the tokenizer to the <a href="#script-data-state" id="parsing-main-inhead:script-data-state">script data state</a>.</p></li><li><p>Set the <a href="#original-insertion-mode" id="parsing-main-inhead:original-insertion-mode">original insertion mode</a> to the current <a href="#insertion-mode" id="parsing-main-inhead:insertion-mode-4">insertion
     mode</a>.</p>

     </li><li><p>Switch the <a href="#insertion-mode" id="parsing-main-inhead:insertion-mode-5">insertion mode</a> to "<a href="#parsing-main-incdata" id="parsing-main-inhead:parsing-main-incdata">text</a>".</p></li></ol>
   </dd><dt>An end tag whose tag name is "head"</dt><dd>
    <p>Pop the <a href="#current-node" id="parsing-main-inhead:current-node-4">current node</a> (which will be the <code id="parsing-main-inhead:the-head-element"><a href="#the-head-element">head</a></code> element) off the
    <a href="#stack-of-open-elements" id="parsing-main-inhead:stack-of-open-elements-4">stack of open elements</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-inhead:insertion-mode-6">insertion mode</a> to "<a href="#the-after-head-insertion-mode" id="parsing-main-inhead:the-after-head-insertion-mode">after
    head</a>".</p>
   </dd><dt>An end tag whose tag name is one of: "body", "html", "br"</dt><dd>
    <p>Act as described in the "anything else" entry below.</p>
   </dd><dt>A start tag whose tag name is "template"</dt><dd>
    <p>Run these steps:</p>

    <ol><li><p>Let <var>templateStartTag</var> be the start tag.</p></li><li><p>Insert a <a href="#concept-parser-marker" id="parsing-main-inhead:concept-parser-marker">marker</a> at the end of the <a href="#list-of-active-formatting-elements" id="parsing-main-inhead:list-of-active-formatting-elements">list
     of active formatting elements</a>.</p></li><li><p>Set the <a href="#frameset-ok-flag" id="parsing-main-inhead:frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li><li><p>Switch the <a href="#insertion-mode" id="parsing-main-inhead:insertion-mode-7">insertion mode</a> to "<a href="#parsing-main-intemplate" id="parsing-main-inhead:parsing-main-intemplate">in
     template</a>".</p></li><li><p>Push "<a href="#parsing-main-intemplate" id="parsing-main-inhead:parsing-main-intemplate-2">in template</a>" onto the
     <a href="#stack-of-template-insertion-modes" id="parsing-main-inhead:stack-of-template-insertion-modes">stack of template insertion modes</a> so that it is the new <a href="#current-template-insertion-mode" id="parsing-main-inhead:current-template-insertion-mode">current template
     insertion mode</a>.</p></li><li><p>Let the <var>adjustedInsertionLocation</var> be the <a href="#appropriate-place-for-inserting-a-node" id="parsing-main-inhead:appropriate-place-for-inserting-a-node-2">appropriate place for
     inserting a node</a>.</p></li><li><p>Let <var>intendedParent</var> be the element in which the
     <var>adjustedInsertionLocation</var> finds itself.</p></li><li><p>Let <var>document</var> be <var>intendedParent</var>'s <a id="parsing-main-inhead:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
     document</a>.</p></li><li>
      <p>If any of the following are false:</p>

      <ul><li><var>templateStartTag</var>'s <code id="parsing-main-inhead:attr-template-shadowrootmode"><a href="#attr-template-shadowrootmode">shadowrootmode</a></code> is not in the <a href="#attr-shadowrootmode-none-state" id="parsing-main-inhead:attr-shadowrootmode-none-state">None</a> state;</li><li><var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-allow-declarative-shadow-roots" id="parsing-main-inhead:concept-document-allow-declarative-shadow-roots" data-x-internal="concept-document-allow-declarative-shadow-roots">allow declarative shadow
       roots</a> is true; or</li><li>the <a href="#adjusted-current-node" id="parsing-main-inhead:adjusted-current-node">adjusted current node</a> is not the topmost element in the <a href="#stack-of-open-elements" id="parsing-main-inhead:stack-of-open-elements-5">stack of
       open elements</a>,</li></ul>

      <p>then <a href="#insert-an-html-element" id="parsing-main-inhead:insert-an-html-element-4">insert an HTML element</a> for the token.</p>
     </li><li>
      <p>Otherwise:</p>

      <ol><li><p>Let <var>declarativeShadowHostElement</var> be <a href="#adjusted-current-node" id="parsing-main-inhead:adjusted-current-node-2">adjusted current
       node</a>.</p></li><li><p>Let <var>template</var> be the result of <a href="#insert-a-foreign-element" id="parsing-main-inhead:insert-a-foreign-element">insert a foreign element</a> for
       <var>templateStartTag</var>, with <a id="parsing-main-inhead:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a> and true.</p></li><li><p>Let <var>mode</var> be <var>templateStartTag</var>'s <code id="parsing-main-inhead:attr-template-shadowrootmode-2"><a href="#attr-template-shadowrootmode">shadowrootmode</a></code> attribute's value.</p></li><li><p>Let <var>clonable</var> be true if <var>templateStartTag</var> has a <code id="parsing-main-inhead:attr-template-shadowrootclonable"><a href="#attr-template-shadowrootclonable">shadowrootclonable</a></code> attribute; otherwise
       false.</p></li><li><p>Let <var>serializable</var> be true if <var>templateStartTag</var> has a <code id="parsing-main-inhead:attr-template-shadowrootserializable"><a href="#attr-template-shadowrootserializable">shadowrootserializable</a></code> attribute;
       otherwise false.</p></li><li><p>Let <var>delegatesFocus</var> be true if <var>templateStartTag</var> has a <code id="parsing-main-inhead:attr-template-shadowrootdelegatesfocus"><a href="#attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus</a></code> attribute;
       otherwise false.</p></li><li><p>If <var>declarativeShadowHostElement</var> is a <a id="parsing-main-inhead:shadow-host" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a>, then
       <a href="#insert-an-element-at-the-adjusted-insertion-location" id="parsing-main-inhead:insert-an-element-at-the-adjusted-insertion-location">insert an element at the adjusted insertion location</a> with
       <var>template</var>.</p></li><li>
        <p>Otherwise:</p>

        <ol><li><p>Let <var>registry</var> be <var>declarativeShadowHostElement</var>'s <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="parsing-main-inhead:element-custom-element-registry" data-x-internal="element-custom-element-registry">custom element registry</a>.</p></li><li><p>If <var>templateStartTag</var> has a <code id="parsing-main-inhead:attr-template-shadowrootcustomelementregistry"><a href="#attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</a></code>
         attribute, then set <var>registry</var> to null.</p></li><li>
          <p><a href="https://dom.spec.whatwg.org/#concept-attach-a-shadow-root" id="parsing-main-inhead:concept-attach-a-shadow-root" data-x-internal="concept-attach-a-shadow-root">Attach a shadow root</a> with
          <var>declarativeShadowHostElement</var>, <var>mode</var>, <var>clonable</var>,
          <var>serializable</var>, <var>delegatesFocus</var>, "<code>named</code>", and
          <var>registry</var>.</p>

          <p>If an exception is thrown, then catch it and:</p>

          <ol><li><p><a href="#insert-an-element-at-the-adjusted-insertion-location" id="parsing-main-inhead:insert-an-element-at-the-adjusted-insertion-location-2">Insert an element at the adjusted insertion location</a> with
           <var>template</var>.</p></li><li><p>The user agent may report an error to the developer console.</p></li><li><p>Return.</p></li></ol>
         </li><li><p>Let <var>shadow</var> be <var>declarativeShadowHostElement</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="parsing-main-inhead:concept-element-shadow-root" data-x-internal="concept-element-shadow-root">shadow root</a>.</p></li><li><p>Set <var>shadow</var>'s <a href="https://dom.spec.whatwg.org/#shadowroot-declarative" id="parsing-main-inhead:concept-shadow-root-declarative" data-x-internal="concept-shadow-root-declarative">declarative</a> to true.</p></li><li><p>Set <var>template</var>'s <a href="#template-contents" id="parsing-main-inhead:template-contents">template contents</a> property to
         <var>shadow</var>.</p></li><li><p>Set <var>shadow</var>'s <a id="parsing-main-inhead:available-to-element-internals" href="https://dom.spec.whatwg.org/#shadowroot-available-to-element-internals" data-x-internal="available-to-element-internals">available to element internals</a> to
         true.</p></li><li><p>If <var>templateStartTag</var> has a <code id="parsing-main-inhead:attr-template-shadowrootcustomelementregistry-2"><a href="#attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</a></code>
         attribute, then set <var>shadow</var>'s <a id="parsing-main-inhead:keep-custom-element-registry-null" href="https://dom.spec.whatwg.org/#shadowroot-keep-custom-element-registry-null" data-x-internal="keep-custom-element-registry-null">keep custom element registry null</a> to
         true.</p></li></ol>
       </li></ol>
     </li></ol>
   </dd><dt>An end tag whose tag name is "template"</dt><dd>
    <p>If there is no <code id="parsing-main-inhead:the-template-element"><a href="#the-template-element">template</a></code> element on the <a href="#stack-of-open-elements" id="parsing-main-inhead:stack-of-open-elements-6">stack of open elements</a>, then
    this is a <a href="#parse-errors" id="parsing-main-inhead:parse-errors-2">parse error</a>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol><li><p><a href="#generate-all-implied-end-tags-thoroughly" id="parsing-main-inhead:generate-all-implied-end-tags-thoroughly">Generate all implied end tags thoroughly</a>.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inhead:current-node-5">current node</a> is not a <code id="parsing-main-inhead:the-template-element-2"><a href="#the-template-element">template</a></code> element, then this is a
     <a href="#parse-errors" id="parsing-main-inhead:parse-errors-3">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inhead:stack-of-open-elements-7">stack of open elements</a> until a <code id="parsing-main-inhead:the-template-element-3"><a href="#the-template-element">template</a></code>
     element has been popped from the stack.</p></li><li><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker" id="parsing-main-inhead:clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to the last marker</a>.</li><li><p>Pop the <a href="#current-template-insertion-mode" id="parsing-main-inhead:current-template-insertion-mode-2">current template insertion mode</a> off the <a href="#stack-of-template-insertion-modes" id="parsing-main-inhead:stack-of-template-insertion-modes-2">stack of template
     insertion modes</a>.</p>

     </li><li><p><a href="#reset-the-insertion-mode-appropriately" id="parsing-main-inhead:reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p></li></ol>
   </dd><dt>A start tag whose tag name is "head"</dt><dt>Any other end tag</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inhead:parse-errors-4">Parse error</a>. Ignore the token.</p>
   </dd><dt>Anything else</dt><dd>
    

    
    <p>Pop the <a href="#current-node" id="parsing-main-inhead:current-node-6">current node</a> (which will be the <code id="parsing-main-inhead:the-head-element-2"><a href="#the-head-element">head</a></code> element) off the
    <a href="#stack-of-open-elements" id="parsing-main-inhead:stack-of-open-elements-8">stack of open elements</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-inhead:insertion-mode-8">insertion mode</a> to "<a href="#the-after-head-insertion-mode" id="parsing-main-inhead:the-after-head-insertion-mode-2">after
    head</a>".</p>
    

    <p>Reprocess the token.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-inheadnoscript"><span class="secno">13.2.6.4.5</span> The "<dfn>in head noscript</dfn>" insertion mode<a href="#parsing-main-inheadnoscript" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-inheadnoscript" id="parsing-main-inheadnoscript:parsing-main-inheadnoscript">in head noscript</a>" <a href="#insertion-mode" id="parsing-main-inheadnoscript:insertion-mode">insertion mode</a>, the user agent must handle the
  token as follows:</p>

  <dl class="switch"><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inheadnoscript:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-inheadnoscript:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-inheadnoscript:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-inheadnoscript:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>An end tag whose tag name is "noscript"</dt><dd>
    <p>Pop the <a href="#current-node" id="parsing-main-inheadnoscript:current-node">current node</a> (which will be a <code id="parsing-main-inheadnoscript:the-noscript-element"><a href="#the-noscript-element">noscript</a></code> element) from the
    <a href="#stack-of-open-elements" id="parsing-main-inheadnoscript:stack-of-open-elements">stack of open elements</a>; the new <a href="#current-node" id="parsing-main-inheadnoscript:current-node-2">current node</a> will be a
    <code id="parsing-main-inheadnoscript:the-head-element"><a href="#the-head-element">head</a></code> element.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-inheadnoscript:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-inhead" id="parsing-main-inheadnoscript:parsing-main-inhead">in
    head</a>".</p>
   </dd><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
   FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dt>A comment token</dt><dt>A start tag whose tag name is one of: "basefont", "bgsound", "link", "meta", "noframes",
   "style"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-inheadnoscript:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-inhead" id="parsing-main-inheadnoscript:parsing-main-inhead-2">in head</a>" <a href="#insertion-mode" id="parsing-main-inheadnoscript:insertion-mode-4">insertion mode</a>.</p>
   </dd><dt>An end tag whose tag name is "br"</dt><dd>
    <p>Act as described in the "anything else" entry below.</p>
   </dd><dt>A start tag whose tag name is one of: "head", "noscript"</dt><dt>Any other end tag</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inheadnoscript:parse-errors-2">Parse error</a>. Ignore the token.</p>
   </dd><dt>Anything else</dt><dd>
    

    <p><a href="#parse-errors" id="parsing-main-inheadnoscript:parse-errors-3">Parse error</a>.</p>

    
    <p>Pop the <a href="#current-node" id="parsing-main-inheadnoscript:current-node-3">current node</a> (which will be a <code id="parsing-main-inheadnoscript:the-noscript-element-2"><a href="#the-noscript-element">noscript</a></code> element) from the
    <a href="#stack-of-open-elements" id="parsing-main-inheadnoscript:stack-of-open-elements-2">stack of open elements</a>; the new <a href="#current-node" id="parsing-main-inheadnoscript:current-node-4">current node</a> will be a
    <code id="parsing-main-inheadnoscript:the-head-element-2"><a href="#the-head-element">head</a></code> element.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-inheadnoscript:insertion-mode-5">insertion mode</a> to "<a href="#parsing-main-inhead" id="parsing-main-inheadnoscript:parsing-main-inhead-3">in
    head</a>".</p>
    

    <p>Reprocess the token.</p>
   </dd></dl>
  </div>


  <h6 id="the-after-head-insertion-mode"><span class="secno">13.2.6.4.6</span> The "<dfn>after head</dfn>" insertion mode<a href="#the-after-head-insertion-mode" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#the-after-head-insertion-mode" id="the-after-head-insertion-mode:the-after-head-insertion-mode">after head</a>" <a href="#insertion-mode" id="the-after-head-insertion-mode:insertion-mode">insertion mode</a>, the user agent must handle the token as
  follows:</p>

  <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
   TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
   U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p><a href="#insert-a-character" id="the-after-head-insertion-mode:insert-a-character">Insert the character</a>.</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="the-after-head-insertion-mode:insert-a-comment">Insert a comment</a>.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="the-after-head-insertion-mode:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="the-after-head-insertion-mode:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="the-after-head-insertion-mode:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="the-after-head-insertion-mode:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>A start tag whose tag name is "body"</dt><dd>
    <p><a href="#insert-an-html-element" id="the-after-head-insertion-mode:insert-an-html-element">Insert an HTML element</a> for the token.</p>

    <p>Set the <a href="#frameset-ok-flag" id="the-after-head-insertion-mode:frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>

    <p>Switch the <a href="#insertion-mode" id="the-after-head-insertion-mode:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-inbody" id="the-after-head-insertion-mode:parsing-main-inbody-2">in
    body</a>".</p>
   </dd><dt>A start tag whose tag name is "frameset"</dt><dd>
    <p><a href="#insert-an-html-element" id="the-after-head-insertion-mode:insert-an-html-element-2">Insert an HTML element</a> for the token.</p>

    <p>Switch the <a href="#insertion-mode" id="the-after-head-insertion-mode:insertion-mode-4">insertion mode</a> to "<a href="#parsing-main-inframeset" id="the-after-head-insertion-mode:parsing-main-inframeset">in
    frameset</a>".</p>
   </dd><dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta",
   "noframes", "script", "style", "template", "title"</dt><dd>
    <p><a href="#parse-errors" id="the-after-head-insertion-mode:parse-errors-2">Parse error</a>.</p>

    <p>Push the node pointed to by the <a href="#head-element-pointer" id="the-after-head-insertion-mode:head-element-pointer"><code>head</code> element pointer</a> onto
    the <a href="#stack-of-open-elements" id="the-after-head-insertion-mode:stack-of-open-elements">stack of open elements</a>.</p>

    <p>Process the token <a href="#using-the-rules-for" id="the-after-head-insertion-mode:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-inhead" id="the-after-head-insertion-mode:parsing-main-inhead">in head</a>" <a href="#insertion-mode" id="the-after-head-insertion-mode:insertion-mode-5">insertion mode</a>.</p>

    <p>Remove the node pointed to by the <a href="#head-element-pointer" id="the-after-head-insertion-mode:head-element-pointer-2"><code>head</code> element pointer</a>
    from the <a href="#stack-of-open-elements" id="the-after-head-insertion-mode:stack-of-open-elements-2">stack of open elements</a>. (It might not be the <a href="#current-node" id="the-after-head-insertion-mode:current-node">current node</a> at
    this point.)</p>

    <p class="note">The <a href="#head-element-pointer" id="the-after-head-insertion-mode:head-element-pointer-3"><code>head</code> element pointer</a> cannot be null at
    this point.</p>
   </dd><dt>An end tag whose tag name is "template"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="the-after-head-insertion-mode:using-the-rules-for-3">using the rules for</a> the "<a href="#parsing-main-inhead" id="the-after-head-insertion-mode:parsing-main-inhead-2">in head</a>" <a href="#insertion-mode" id="the-after-head-insertion-mode:insertion-mode-6">insertion mode</a>.</p>
   </dd><dt>An end tag whose tag name is one of: "body", "html", "br"</dt><dd>
    <p>Act as described in the "anything else" entry below.</p>
   </dd><dt>A start tag whose tag name is "head"</dt><dt>Any other end tag</dt><dd>
    <p><a href="#parse-errors" id="the-after-head-insertion-mode:parse-errors-3">Parse error</a>. Ignore the token.</p>
   </dd><dt>Anything else</dt><dd>
    
    <p><a href="#insert-an-html-element" id="the-after-head-insertion-mode:insert-an-html-element-3">Insert an HTML element</a> for a "body" start tag token with no attributes.</p>

    <p>Switch the <a href="#insertion-mode" id="the-after-head-insertion-mode:insertion-mode-7">insertion mode</a> to "<a href="#parsing-main-inbody" id="the-after-head-insertion-mode:parsing-main-inbody-3">in
    body</a>".</p>
    

    <p>Reprocess the current token.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-inbody"><span class="secno">13.2.6.4.7</span> The "<dfn>in body</dfn>" insertion mode<a href="#parsing-main-inbody" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-inbody" id="parsing-main-inbody:parsing-main-inbody">in
  body</a>" <a href="#insertion-mode" id="parsing-main-inbody:insertion-mode">insertion mode</a>, the user agent must handle the token as follows:</p>

  <dl class="switch"><dt>A character token that is U+0000 NULL</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inbody:parse-errors">Parse error</a>. Ignore the token.</p>

    
   </dd><dt>A character token that is one of U+0009 CHARACTER TABULATION,
   U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE
   RETURN (CR), or U+0020 SPACE</dt><dd>
    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-a-character" id="parsing-main-inbody:insert-a-character">Insert the token's character</a>.</p>
   </dd><dt>Any other character token</dt><dd>
    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-2">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-a-character" id="parsing-main-inbody:insert-a-character-2">Insert the token's character</a>.</p>

    <p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="parsing-main-inbody:insert-a-comment">Insert a comment</a>.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-2">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-3">Parse error</a>.</p>

    <p>If there is a <code id="parsing-main-inbody:the-template-element"><a href="#the-template-element">template</a></code> element on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements">stack of open elements</a>, then
    ignore the token.</p>

    <p>Otherwise, for each attribute on the token, check to see if the attribute is already present
    on the top element of the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-2">stack of open elements</a>. If it is not, add the attribute
    and its corresponding value to that element.</p>
   </dd><dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta",
   "noframes", "script", "style", "template", "title"</dt><dt>An end tag whose tag name is "template"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-inbody:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" id="parsing-main-inbody:parsing-main-inhead">in head</a>" <a href="#insertion-mode" id="parsing-main-inbody:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>A start tag whose tag name is "body"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-4">Parse error</a>.</p>

    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-3">stack of open elements</a> has only one node on it, or if the second element
    on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-4">stack of open elements</a> is not a <code id="parsing-main-inbody:the-body-element"><a href="#the-body-element">body</a></code> element, or if there is a
    <code id="parsing-main-inbody:the-template-element-2"><a href="#the-template-element">template</a></code> element on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-5">stack of open elements</a>, then ignore the token.
    (<a href="#fragment-case" id="parsing-main-inbody:fragment-case">fragment case</a> or there is a <code id="parsing-main-inbody:the-template-element-3"><a href="#the-template-element">template</a></code> element on the stack)</p>

    <p>Otherwise, set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-2">frameset-ok flag</a> to "not ok"; then, for each attribute on the
    token, check to see if the attribute is already present on the <code id="parsing-main-inbody:the-body-element-2"><a href="#the-body-element">body</a></code> element (the
    second element) on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-6">stack of open elements</a>, and if it is not, add the attribute
    and its corresponding value to that element.</p>
   </dd><dt>A start tag whose tag name is "frameset"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-5">Parse error</a>.</p>

    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-7">stack of open elements</a> has only one node on it, or if the second element
    on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-8">stack of open elements</a> is not a <code id="parsing-main-inbody:the-body-element-3"><a href="#the-body-element">body</a></code> element, then ignore the
    token. (<a href="#fragment-case" id="parsing-main-inbody:fragment-case-2">fragment case</a> or there is a <code id="parsing-main-inbody:the-template-element-4"><a href="#the-template-element">template</a></code> element on the
    stack)</p>

    <p>If the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-3">frameset-ok flag</a> is set to "not ok", ignore the token.</p>

    <p>Otherwise, run the following steps:</p>

    <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-9">stack of open elements</a> from its parent
     node, if it has one.</p></li><li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-10">stack of open elements</a>, from the
     <a href="#current-node" id="parsing-main-inbody:current-node">current node</a> up to, but not including, the root <code id="parsing-main-inbody:the-html-element"><a href="#the-html-element">html</a></code> element.</p>

     </li><li><p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element">Insert an HTML element</a> for the token.</p></li><li><p>Switch the <a href="#insertion-mode" id="parsing-main-inbody:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-inframeset" id="parsing-main-inbody:parsing-main-inframeset">in
     frameset</a>".</p>
    </li></ol>
   </dd><dt>An end-of-file token</dt><dd>
    <p>If the <a href="#stack-of-template-insertion-modes" id="parsing-main-inbody:stack-of-template-insertion-modes">stack of template insertion modes</a> is not empty, then process the token
    <a href="#using-the-rules-for" id="parsing-main-inbody:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-intemplate" id="parsing-main-inbody:parsing-main-intemplate">in
    template</a>" <a href="#insertion-mode" id="parsing-main-inbody:insertion-mode-4">insertion mode</a>.</p>
    

    <p>Otherwise, follow these steps:</p>

    <ol><li><p>If there is a node in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-11">stack of open elements</a> that is not either a
     <code id="parsing-main-inbody:the-dd-element"><a href="#the-dd-element">dd</a></code> element, a <code id="parsing-main-inbody:the-dt-element"><a href="#the-dt-element">dt</a></code> element, an <code id="parsing-main-inbody:the-li-element"><a href="#the-li-element">li</a></code> element, an
     <code id="parsing-main-inbody:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element, an <code id="parsing-main-inbody:the-option-element"><a href="#the-option-element">option</a></code> element, a <code id="parsing-main-inbody:the-p-element"><a href="#the-p-element">p</a></code> element, an
     <code id="parsing-main-inbody:rb"><a href="#rb">rb</a></code> element, an <code id="parsing-main-inbody:the-rp-element"><a href="#the-rp-element">rp</a></code> element, an <code id="parsing-main-inbody:the-rt-element"><a href="#the-rt-element">rt</a></code> element, an
     <code id="parsing-main-inbody:rtc"><a href="#rtc">rtc</a></code> element, a <code id="parsing-main-inbody:the-tbody-element"><a href="#the-tbody-element">tbody</a></code> element, a <code id="parsing-main-inbody:the-td-element"><a href="#the-td-element">td</a></code> element, a
     <code id="parsing-main-inbody:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> element, a <code id="parsing-main-inbody:the-th-element"><a href="#the-th-element">th</a></code> element, a <code id="parsing-main-inbody:the-thead-element"><a href="#the-thead-element">thead</a></code> element, a
     <code id="parsing-main-inbody:the-tr-element"><a href="#the-tr-element">tr</a></code> element, the <code id="parsing-main-inbody:the-body-element-4"><a href="#the-body-element">body</a></code> element, or the <code id="parsing-main-inbody:the-html-element-2"><a href="#the-html-element">html</a></code> element, then
     this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-6">parse error</a>.</p></li><li><p><a href="#stop-parsing" id="parsing-main-inbody:stop-parsing">Stop parsing</a>.</p></li></ol>
   </dd><dt>An end tag whose tag name is "body"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-12">stack of open elements</a> does not <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope">have a <code>body</code> element in scope</a>, this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-7">parse error</a>;
    ignore the token.</p>

    

    <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-13">stack of open elements</a> that is not either a
    <code id="parsing-main-inbody:the-dd-element-2"><a href="#the-dd-element">dd</a></code> element, a <code id="parsing-main-inbody:the-dt-element-2"><a href="#the-dt-element">dt</a></code> element, an <code id="parsing-main-inbody:the-li-element-2"><a href="#the-li-element">li</a></code> element, an
    <code id="parsing-main-inbody:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> element, an <code id="parsing-main-inbody:the-option-element-2"><a href="#the-option-element">option</a></code> element, a <code id="parsing-main-inbody:the-p-element-2"><a href="#the-p-element">p</a></code> element, an
    <code id="parsing-main-inbody:rb-2"><a href="#rb">rb</a></code> element, an <code id="parsing-main-inbody:the-rp-element-2"><a href="#the-rp-element">rp</a></code> element, an <code id="parsing-main-inbody:the-rt-element-2"><a href="#the-rt-element">rt</a></code> element, an
    <code id="parsing-main-inbody:rtc-2"><a href="#rtc">rtc</a></code> element, a <code id="parsing-main-inbody:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code> element, a <code id="parsing-main-inbody:the-td-element-2"><a href="#the-td-element">td</a></code> element, a
    <code id="parsing-main-inbody:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code> element, a <code id="parsing-main-inbody:the-th-element-2"><a href="#the-th-element">th</a></code> element, a <code id="parsing-main-inbody:the-thead-element-2"><a href="#the-thead-element">thead</a></code> element, a
    <code id="parsing-main-inbody:the-tr-element-2"><a href="#the-tr-element">tr</a></code> element, the <code id="parsing-main-inbody:the-body-element-5"><a href="#the-body-element">body</a></code> element, or the <code id="parsing-main-inbody:the-html-element-3"><a href="#the-html-element">html</a></code> element, then
    this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-8">parse error</a>.</p> 

    

    <p>Switch the <a href="#insertion-mode" id="parsing-main-inbody:insertion-mode-5">insertion mode</a> to "<a href="#parsing-main-afterbody" id="parsing-main-inbody:parsing-main-afterbody">after
    body</a>".</p>
   </dd><dt>An end tag whose tag name is "html"</dt><dd>
    
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-14">stack of open elements</a> does not <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-2">have a <code>body</code> element in scope</a>, this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-9">parse error</a>;
    ignore the token.</p>

    

    <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-15">stack of open elements</a> that is not either a
    <code id="parsing-main-inbody:the-dd-element-3"><a href="#the-dd-element">dd</a></code> element, a <code id="parsing-main-inbody:the-dt-element-3"><a href="#the-dt-element">dt</a></code> element, an <code id="parsing-main-inbody:the-li-element-3"><a href="#the-li-element">li</a></code> element, an
    <code id="parsing-main-inbody:the-optgroup-element-3"><a href="#the-optgroup-element">optgroup</a></code> element, an <code id="parsing-main-inbody:the-option-element-3"><a href="#the-option-element">option</a></code> element, a <code id="parsing-main-inbody:the-p-element-3"><a href="#the-p-element">p</a></code> element, an
    <code id="parsing-main-inbody:rb-3"><a href="#rb">rb</a></code> element, an <code id="parsing-main-inbody:the-rp-element-3"><a href="#the-rp-element">rp</a></code> element, an <code id="parsing-main-inbody:the-rt-element-3"><a href="#the-rt-element">rt</a></code> element, an
    <code id="parsing-main-inbody:rtc-3"><a href="#rtc">rtc</a></code> element, a <code id="parsing-main-inbody:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code> element, a <code id="parsing-main-inbody:the-td-element-3"><a href="#the-td-element">td</a></code> element, a
    <code id="parsing-main-inbody:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code> element, a <code id="parsing-main-inbody:the-th-element-3"><a href="#the-th-element">th</a></code> element, a <code id="parsing-main-inbody:the-thead-element-3"><a href="#the-thead-element">thead</a></code> element, a
    <code id="parsing-main-inbody:the-tr-element-3"><a href="#the-tr-element">tr</a></code> element, the <code id="parsing-main-inbody:the-body-element-6"><a href="#the-body-element">body</a></code> element, or the <code id="parsing-main-inbody:the-html-element-4"><a href="#the-html-element">html</a></code> element, then
    this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-10">parse error</a>.</p> 

    

    <p>Switch the <a href="#insertion-mode" id="parsing-main-inbody:insertion-mode-6">insertion mode</a> to "<a href="#parsing-main-afterbody" id="parsing-main-inbody:parsing-main-afterbody-2">after
    body</a>".</p>
    

    <p>Reprocess the token.</p>
   </dd><dt>A start tag whose tag name is one of: "address", "article", "aside", "blockquote", "center",
   "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header",
   "hgroup", "main", "menu", "nav", "ol", "p", "search", "section", "summary", "ul"</dt><dd>
    

    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-16">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope">has a
    <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element">close a <code>p</code>
    element</a>.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-2">Insert an HTML element</a> for the token.</p>
   </dd><dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
   "h5", "h6"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-17">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-2">has a
    <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-2">close a <code>p</code>
    element</a>.</p>

    <p>If the <a href="#current-node" id="parsing-main-inbody:current-node-2">current node</a> is an <a href="#html-elements" id="parsing-main-inbody:html-elements">HTML element</a> whose
    tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-11">parse
    error</a>; pop the <a href="#current-node" id="parsing-main-inbody:current-node-3">current node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-18">stack of open elements</a>.</p>
    

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-3">Insert an HTML element</a> for the token.</p>
   </dd><dt>A start tag whose tag name is one of: "pre", "listing"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-19">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-3">has
    a <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-3">close a <code>p</code>
    element</a>.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-4">Insert an HTML element</a> for the token.</p>

    <p>If the <a href="#next-token" id="parsing-main-inbody:next-token">next token</a> is a U+000A LINE FEED (LF) character token, then ignore that
    token and move on to the next one. (Newlines at the start of <code id="parsing-main-inbody:the-pre-element"><a href="#the-pre-element">pre</a></code> blocks are ignored
    as an authoring convenience.)</p>

    

    <p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-4">frameset-ok flag</a> to "not ok".</p>
   </dd><dt>A start tag whose tag name is "form"</dt><dd>
    <p>If the <a href="#form-element-pointer" id="parsing-main-inbody:form-element-pointer"><code>form</code> element pointer</a> is not null, and there is
    no <code id="parsing-main-inbody:the-template-element-5"><a href="#the-template-element">template</a></code> element on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-20">stack of open elements</a>, then this is a
    <a href="#parse-errors" id="parsing-main-inbody:parse-errors-12">parse error</a>; ignore the token.</p>

    <p>Otherwise:</p>

    <ol><li><p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-21">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-4">has
     a <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-4">close a <code>p</code>
     element</a>.</p></li><li><p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-5">Insert an HTML element</a> for the token, and, if there is no <code id="parsing-main-inbody:the-template-element-6"><a href="#the-template-element">template</a></code>
     element on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-22">stack of open elements</a>, set the <a href="#form-element-pointer" id="parsing-main-inbody:form-element-pointer-2"><code>form</code> element pointer</a> to point to the element created.</p></li></ol>
   </dd><dt>A start tag whose tag name is "li"</dt><dd>
    <p>Run these steps:</p>

    <ol><li><p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-5">frameset-ok flag</a> to "not ok".</p></li><li><p>Initialize <var>node</var> to be the <a href="#current-node" id="parsing-main-inbody:current-node-4">current
     node</a> (the bottommost node of the stack).</p></li><li>
      <p><i>Loop</i>: If <var>node</var> is an <code id="parsing-main-inbody:the-li-element-4"><a href="#the-li-element">li</a></code> element, then run these
      substeps:</p>

      <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags">Generate implied end tags</a>, except for <code id="parsing-main-inbody:the-li-element-5"><a href="#the-li-element">li</a></code> elements.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-5">current node</a> is not an <code id="parsing-main-inbody:the-li-element-6"><a href="#the-li-element">li</a></code> element, then this is a
       <a href="#parse-errors" id="parsing-main-inbody:parse-errors-13">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-23">stack of open elements</a> until an <code id="parsing-main-inbody:the-li-element-7"><a href="#the-li-element">li</a></code>
       element has been popped from the stack.</p></li><li><p>Jump to the step labeled <i>done</i> below.</p></li></ol>
     </li><li><p>If <var>node</var> is in the <a href="#special" id="parsing-main-inbody:special">special</a> category, but is not an
     <code id="parsing-main-inbody:the-address-element"><a href="#the-address-element">address</a></code>, <code id="parsing-main-inbody:the-div-element"><a href="#the-div-element">div</a></code>, or <code id="parsing-main-inbody:the-p-element-4"><a href="#the-p-element">p</a></code> element, then jump to the step
     labeled <i>done</i> below.</p></li><li><p>Otherwise, set <var>node</var> to the previous entry in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-24">stack of open
     elements</a> and return to the step labeled <i>loop</i>.</p></li><li><p><i>Done</i>: If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-25">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-5">has a <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-5">close a
     <code>p</code> element</a>.</p></li><li><p>Finally, <a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-6">insert an HTML element</a> for the token.</p></li></ol>
   </dd><dt>A start tag whose tag name is one of: "dd", "dt"</dt><dd>
    <p>Run these steps:</p>

    <ol><li><p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-6">frameset-ok flag</a> to "not ok".</p></li><li><p>Initialize <var>node</var> to be the <a href="#current-node" id="parsing-main-inbody:current-node-6">current
     node</a> (the bottommost node of the stack).</p></li><li>
      <p><i>Loop</i>: If <var>node</var> is a <code id="parsing-main-inbody:the-dd-element-4"><a href="#the-dd-element">dd</a></code> element, then run these
      substeps:</p>

      <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-2">Generate implied end tags</a>, except for <code id="parsing-main-inbody:the-dd-element-5"><a href="#the-dd-element">dd</a></code> elements.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-7">current node</a> is not a <code id="parsing-main-inbody:the-dd-element-6"><a href="#the-dd-element">dd</a></code> element, then this is a
       <a href="#parse-errors" id="parsing-main-inbody:parse-errors-14">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-26">stack of open elements</a> until a <code id="parsing-main-inbody:the-dd-element-7"><a href="#the-dd-element">dd</a></code>
       element has been popped from the stack.</p></li><li><p>Jump to the step labeled <i>done</i> below.</p></li></ol>
     </li><li>
      <p>If <var>node</var> is a <code id="parsing-main-inbody:the-dt-element-4"><a href="#the-dt-element">dt</a></code> element, then run these substeps:</p>

      <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-3">Generate implied end tags</a>, except for <code id="parsing-main-inbody:the-dt-element-5"><a href="#the-dt-element">dt</a></code> elements.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-8">current node</a> is not a <code id="parsing-main-inbody:the-dt-element-6"><a href="#the-dt-element">dt</a></code> element, then this is a
       <a href="#parse-errors" id="parsing-main-inbody:parse-errors-15">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-27">stack of open elements</a> until a <code id="parsing-main-inbody:the-dt-element-7"><a href="#the-dt-element">dt</a></code>
       element has been popped from the stack.</p></li><li><p>Jump to the step labeled <i>done</i> below.</p></li></ol>
     </li><li><p>If <var>node</var> is in the <a href="#special" id="parsing-main-inbody:special-2">special</a> category, but is not an
     <code id="parsing-main-inbody:the-address-element-2"><a href="#the-address-element">address</a></code>, <code id="parsing-main-inbody:the-div-element-2"><a href="#the-div-element">div</a></code>, or <code id="parsing-main-inbody:the-p-element-5"><a href="#the-p-element">p</a></code> element, then jump to the step
     labeled <i>done</i> below.</p></li><li><p>Otherwise, set <var>node</var> to the previous entry in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-28">stack of open
     elements</a> and return to the step labeled <i>loop</i>.</p></li><li><p><i>Done</i>: If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-29">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-6">has a <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-6">close a
     <code>p</code> element</a>.</p></li><li><p>Finally, <a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-7">insert an HTML element</a> for the token.</p></li></ol>
   </dd><dt>A start tag whose tag name is "plaintext"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-30">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-7">has a
    <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-7">close a <code>p</code>
    element</a>.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-8">Insert an HTML element</a> for the token.</p>

    <p>Switch the tokenizer to the <a href="#plaintext-state" id="parsing-main-inbody:plaintext-state">PLAINTEXT state</a>.</p>

    <p class="note">Once a start tag with the tag name "plaintext" has been seen, all remaining
    tokens will be character tokens (and a final end-of-file token) because there is no way to
    switch the tokenizer out of the <a href="#plaintext-state" id="parsing-main-inbody:plaintext-state-2">PLAINTEXT state</a>. However, as the tree builder
    remains in its existing insertion mode, it might <a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-3">reconstruct the active formatting
    elements</a> while processing those character tokens. This means that the parser can
    insert other elements into the <code id="parsing-main-inbody:plaintext"><a href="#plaintext">plaintext</a></code> element.</p>
   </dd><dt>A start tag whose tag name is "button"</dt><dd>
    <ol><li>
      <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-31">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-3">has a
      <code>button</code> element in scope</a>, then run these substeps:</p>

      <ol><li><p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-16">Parse error</a>.</p></li><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-4">Generate implied end tags</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-32">stack of open elements</a> until a <code id="parsing-main-inbody:the-button-element"><a href="#the-button-element">button</a></code>
       element has been popped from the stack.</p></li></ol>
     </li><li><p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-4">Reconstruct the active formatting elements</a>, if any.</p></li><li><p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-9">Insert an HTML element</a> for the token.</p></li><li><p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-7">frameset-ok flag</a> to "not ok".</p></li></ol>
   </dd><dt>An end tag whose tag name is one of: "address", "article", "aside", "blockquote", "button",
   "center", "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer",
   "header", "hgroup", "listing", "main", "menu", "nav", "ol", "pre", "search", "section", "select",
   "summary", "ul"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-33">stack of open elements</a> does not <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-4">have an element in scope</a> that is an <a href="#html-elements" id="parsing-main-inbody:html-elements-2">HTML
    element</a> with the same tag name as that of the token, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-17">parse
    error</a>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-5">Generate implied end tags</a>.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-9">current node</a> is not an <a href="#html-elements" id="parsing-main-inbody:html-elements-3">HTML element</a> with
     the same tag name as that of the token, then this is a
     <a href="#parse-errors" id="parsing-main-inbody:parse-errors-18">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-34">stack of open elements</a> until an <a href="#html-elements" id="parsing-main-inbody:html-elements-4">HTML element</a> with the same tag name as the token has been popped from the
     stack.</p></li></ol>
   </dd><dt>An end tag whose tag name is "form"</dt><dd>
    <p>If there is no <code id="parsing-main-inbody:the-template-element-7"><a href="#the-template-element">template</a></code> element on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-35">stack of open elements</a>, then
    run these substeps:</p>

    <ol><li><p>Let <var>node</var> be the element that the <a href="#form-element-pointer" id="parsing-main-inbody:form-element-pointer-3"><code>form</code>
     element pointer</a> is set to, or null if it is not set to an element.</p></li><li><p>Set the <a href="#form-element-pointer" id="parsing-main-inbody:form-element-pointer-4"><code>form</code> element pointer</a> to null.</p></li><li><p>If <var>node</var> is null or if the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-36">stack of open elements</a> does
     not <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-5">have <var>node</var> in scope</a>, then
     this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-19">parse error</a>; return and ignore the token.</p></li><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-6">Generate implied end tags</a>.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-10">current node</a> is not <var>node</var>, then this is a
     <a href="#parse-errors" id="parsing-main-inbody:parse-errors-20">parse error</a>.</p></li><li><p>Remove <var>node</var> from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-37">stack of open elements</a>.</p></li></ol>

    <p>If there <em>is</em> a <code id="parsing-main-inbody:the-template-element-8"><a href="#the-template-element">template</a></code> element on the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-38">stack of open
    elements</a>, then run these substeps instead:</p>

    <ol><li><p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-39">stack of open elements</a> does not <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-6">have a <code>form</code> element in scope</a>, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-21">parse
     error</a>; return and ignore the token.</p></li><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-7">Generate implied end tags</a>.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-11">current node</a> is not a <code id="parsing-main-inbody:the-form-element"><a href="#the-form-element">form</a></code> element, then this is a
     <a href="#parse-errors" id="parsing-main-inbody:parse-errors-22">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-40">stack of open elements</a> until a <code id="parsing-main-inbody:the-form-element-2"><a href="#the-form-element">form</a></code>
     element has been popped from the stack.</p></li></ol>
   </dd><dt>An end tag whose tag name is "p"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-41">stack of open elements</a> does not <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-8">have a <code>p</code> element in button scope</a>, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-23">parse
    error</a>; <a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-10">insert an HTML element</a> for a "p" start tag token with no
    attributes.</p>

    <p><a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-8">Close a <code>p</code> element</a>.</p>
   </dd><dt>An end tag whose tag name is "li"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-42">stack of open elements</a> does not <a href="#has-an-element-in-list-item-scope" id="parsing-main-inbody:has-an-element-in-list-item-scope">have an <code>li</code> element in list item scope</a>, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-24">parse
    error</a>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-8">Generate implied end tags</a>, except for <code id="parsing-main-inbody:the-li-element-8"><a href="#the-li-element">li</a></code> elements.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-12">current node</a> is not an <code id="parsing-main-inbody:the-li-element-9"><a href="#the-li-element">li</a></code> element, then this is a
     <a href="#parse-errors" id="parsing-main-inbody:parse-errors-25">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-43">stack of open elements</a> until an <code id="parsing-main-inbody:the-li-element-10"><a href="#the-li-element">li</a></code>
     element has been popped from the stack.</p></li></ol>
   </dd><dt>An end tag whose tag name is one of: "dd", "dt"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-44">stack of open elements</a> does not <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-7">have an element in scope</a> that is an <a href="#html-elements" id="parsing-main-inbody:html-elements-5">HTML
    element</a> with the same tag name as that of the token, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-26">parse
    error</a>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-9">Generate implied end tags</a>, except for <a href="#html-elements" id="parsing-main-inbody:html-elements-6">HTML elements</a> with the
     same tag name as the token.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-13">current node</a> is not an <a href="#html-elements" id="parsing-main-inbody:html-elements-7">HTML
     element</a> with the same tag name as that of the token, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-27">parse
     error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-45">stack of open elements</a> until an <a href="#html-elements" id="parsing-main-inbody:html-elements-8">HTML element</a> with the same tag name as the token has been popped from the
     stack.</p></li></ol>
   </dd><dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-46">stack of open elements</a> does not <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-8">have an element in scope</a> that is an <a href="#html-elements" id="parsing-main-inbody:html-elements-9">HTML
    element</a> and whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is
    a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-28">parse error</a>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-10">Generate implied end tags</a>.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-14">current node</a> is not an <a href="#html-elements" id="parsing-main-inbody:html-elements-10">HTML
     element</a> with the same tag name as that of the token, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-29">parse
     error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-47">stack of open elements</a> until an <a href="#html-elements" id="parsing-main-inbody:html-elements-11">HTML element</a> whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6"
     has been popped from the stack.</p></li></ol>
   </dd><dt>An end tag whose tag name is "sarcasm"</dt><dd>
    <p>Take a deep breath, then act as described in the "any other end
    tag" entry below.</p>
   </dd><dt>A start tag whose tag name is "a"</dt><dd>
    <p>If the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements">list of active formatting elements</a> contains an <code id="parsing-main-inbody:the-a-element"><a href="#the-a-element">a</a></code> element
    between the end of the list and the last <a href="#concept-parser-marker" id="parsing-main-inbody:concept-parser-marker">marker</a> on
    the list (or the start of the list if there is no <a href="#concept-parser-marker" id="parsing-main-inbody:concept-parser-marker-2">marker</a> on the list), then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-30">parse
    error</a>; run the <a href="#adoption-agency-algorithm" id="parsing-main-inbody:adoption-agency-algorithm">adoption agency algorithm</a> for the token, then remove that
    element from the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-2">list of active formatting elements</a> and the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-48">stack of open
    elements</a> if the <a href="#adoption-agency-algorithm" id="parsing-main-inbody:adoption-agency-algorithm-2">adoption agency algorithm</a> didn't already remove it (it might
    not have if the element is not <a href="#has-an-element-in-table-scope" id="parsing-main-inbody:has-an-element-in-table-scope">in table
    scope</a>).</p>

    <p class="example">In the non-conforming stream
    <code>&lt;a&nbsp;href="a"&gt;a&lt;table&gt;&lt;a&nbsp;href="b"&gt;b&lt;/table&gt;x</code>, the first
    <code id="parsing-main-inbody:the-a-element-2"><a href="#the-a-element">a</a></code> element would be closed upon seeing the second one, and the "x" character would
    be inside a link to "b", not to "a". This is despite the fact that the outer <code id="parsing-main-inbody:the-a-element-3"><a href="#the-a-element">a</a></code>
    element is not in table scope (meaning that a regular <code>&lt;/a&gt;</code> end tag at the start
    of the table wouldn't close the outer <code id="parsing-main-inbody:the-a-element-4"><a href="#the-a-element">a</a></code> element). The result is that the two
    <code id="parsing-main-inbody:the-a-element-5"><a href="#the-a-element">a</a></code> elements are indirectly nested inside each other — non-conforming markup
    will often result in non-conforming DOMs when parsed.</p>

    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-5">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-11">Insert an HTML element</a> for the token. <a href="#push-onto-the-list-of-active-formatting-elements" id="parsing-main-inbody:push-onto-the-list-of-active-formatting-elements">Push onto the list of active
    formatting elements</a> that element.</p>
   </dd><dt>A start tag whose tag name is one of: "b", "big", "code", "em",
   "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt><dd>
    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-6">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-12">Insert an HTML element</a> for the token. <a href="#push-onto-the-list-of-active-formatting-elements" id="parsing-main-inbody:push-onto-the-list-of-active-formatting-elements-2">Push onto the list of active
    formatting elements</a> that element.</p>
   </dd><dt>A start tag whose tag name is "nobr"</dt><dd>
    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-7">Reconstruct the active formatting elements</a>, if any.</p>

    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-49">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-9">has a
    <code>nobr</code> element in scope</a>, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-31">parse error</a>; run the
    <a href="#adoption-agency-algorithm" id="parsing-main-inbody:adoption-agency-algorithm-3">adoption agency algorithm</a> for the token, then once again <a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-8">reconstruct the
    active formatting elements</a>, if any.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-13">Insert an HTML element</a> for the token. <a href="#push-onto-the-list-of-active-formatting-elements" id="parsing-main-inbody:push-onto-the-list-of-active-formatting-elements-3">Push onto the list of active
    formatting elements</a> that element.</p>
   </dd><dt>An end tag whose tag name is one of: "a",
   "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
   "strike", "strong", "tt", "u"</dt><dd>
    <p>Run the <a href="#adoption-agency-algorithm" id="parsing-main-inbody:adoption-agency-algorithm-4">adoption agency algorithm</a> for the token.</p>
   </dd><dt>A start tag whose tag name is one of: "applet", "marquee", "object"</dt><dd>
    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-9">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-14">Insert an HTML element</a> for the token.</p>

    <p>Insert a <a href="#concept-parser-marker" id="parsing-main-inbody:concept-parser-marker-3">marker</a> at the end of the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-3">list of
    active formatting elements</a>.</p>

    <p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-8">frameset-ok flag</a> to "not ok".</p>
   </dd><dt>An end tag token whose tag name is one of: "applet", "marquee", "object"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-50">stack of open elements</a> does not <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-10">have an element in scope</a> that is an <a href="#html-elements" id="parsing-main-inbody:html-elements-12">HTML
    element</a> with the same tag name as that of the token, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-32">parse
    error</a>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-11">Generate implied end tags</a>.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-15">current node</a> is not an <a href="#html-elements" id="parsing-main-inbody:html-elements-13">HTML
     element</a> with the same tag name as that of the token, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-33">parse
     error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-51">stack of open elements</a> until an <a href="#html-elements" id="parsing-main-inbody:html-elements-14">HTML element</a> with the same tag name as the token has been popped from the
     stack.</p></li><li><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker" id="parsing-main-inbody:clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to the last marker</a>.</li></ol>
   </dd><dt>A start tag whose tag name is "table"</dt><dd>
    <p>If the <code id="parsing-main-inbody:document"><a href="#document">Document</a></code> is <em>not</em> set to <a id="parsing-main-inbody:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, and the
    <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-52">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-9">has a
    <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-9">close a <code>p</code>
    element</a>.</p> 

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-15">Insert an HTML element</a> for the token.</p>

    <p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-9">frameset-ok flag</a> to "not ok".</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-inbody:insertion-mode-7">insertion mode</a> to "<a href="#parsing-main-intable" id="parsing-main-inbody:parsing-main-intable">in
    table</a>".</p>
   </dd><dt>An end tag whose tag name is "br"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-34">Parse error</a>. Drop the attributes from the token, and act as described in the
    next entry; i.e. act as if this was a "br" start tag token with no attributes, rather than the
    end tag token that it actually is.</p>
   </dd><dt>A start tag whose tag name is one of: "area", "br", "embed",
   "img", "keygen", "wbr"</dt><dd>
    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-10">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-16">Insert an HTML element</a> for the token. Immediately pop the <a href="#current-node" id="parsing-main-inbody:current-node-16">current
    node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-53">stack of open elements</a>.</p>

    <p><a href="#acknowledge-self-closing-flag" id="parsing-main-inbody:acknowledge-self-closing-flag">Acknowledge the token's <i>self-closing
    flag</i></a>, if it is set.</p>

    <p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-10">frameset-ok flag</a> to "not ok".</p>
    
   </dd><dt>A start tag whose tag name is "input"</dt><dd>
    <p>If the parser was created as part of the <a href="#html-fragment-parsing-algorithm" id="parsing-main-inbody:html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
    (<a href="#fragment-case" id="parsing-main-inbody:fragment-case-3">fragment case</a>) and the <a href="#concept-frag-parse-context" id="parsing-main-inbody:concept-frag-parse-context">context</a>
    element passed to that algorithm is a <code id="parsing-main-inbody:the-select-element"><a href="#the-select-element">select</a></code> element:</p>

    <ol><li><p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-35">Parse error</a>.</p></li><li><p>Ignore the token.</p></li><li><p>Return.</p></li></ol>

    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-54">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-11">has a
    <code>select</code> element in scope</a>:</p>

    <ol><li><p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-36">Parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-55">stack of open elements</a> until a <code id="parsing-main-inbody:the-select-element-2"><a href="#the-select-element">select</a></code>
     element has been popped from the stack.</p></li></ol>

    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-11">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-17">Insert an HTML element</a> for the token. Immediately pop the <a href="#current-node" id="parsing-main-inbody:current-node-17">current
    node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-56">stack of open elements</a>.</p>

    <p><a href="#acknowledge-self-closing-flag" id="parsing-main-inbody:acknowledge-self-closing-flag-2">Acknowledge the token's <i>self-closing
    flag</i></a>, if it is set.</p>

    <p>If the token does not have an attribute with the name "type", or if it does, but that
    attribute's value is not an <a id="parsing-main-inbody:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>hidden</code>", then: set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-11">frameset-ok flag</a> to "not ok".</p>
   </dd><dt>A start tag whose tag name is one of: "param", "source", "track"</dt><dd>
    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-18">Insert an HTML element</a> for the token. Immediately pop the <a href="#current-node" id="parsing-main-inbody:current-node-18">current
    node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-57">stack of open elements</a>.</p>

    <p><a href="#acknowledge-self-closing-flag" id="parsing-main-inbody:acknowledge-self-closing-flag-3">Acknowledge the token's <i>self-closing
    flag</i></a>, if it is set.</p>
   </dd><dt>A start tag whose tag name is "hr"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-58">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-10">has a
    <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-10">close a <code>p</code>
    element</a>.</p>

    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-59">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-12">has a
    <code>select</code> element in scope</a>:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-12">Generate implied end tags</a>.</p></li><li><p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-60">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-13">has an
     <code>option</code> element in scope</a> or <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-14">has an
     <code>optgroup</code> element in scope</a>, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-37">parse
     error</a>.</p></li></ol>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-19">Insert an HTML element</a> for the token. Immediately pop the <a href="#current-node" id="parsing-main-inbody:current-node-19">current
    node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-61">stack of open elements</a>.</p>

    <p><a href="#acknowledge-self-closing-flag" id="parsing-main-inbody:acknowledge-self-closing-flag-4">Acknowledge the token's <i>self-closing
    flag</i></a>, if it is set.</p>

    <p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-12">frameset-ok flag</a> to "not ok".</p>
   </dd><dt>A start tag whose tag name is "image"</dt><dd>
    
    <p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-38">Parse error</a>. Change the token's tag name to "img" and reprocess it. (Don't
    ask.)</p>
   </dd><dt>A start tag whose tag name is "textarea"</dt><dd>
    <p>Run these steps:</p>

    <ol><li><p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-20">Insert an HTML element</a> for the token.</p></li><li><p>If the <a href="#next-token" id="parsing-main-inbody:next-token-2">next token</a> is a U+000A LINE FEED (LF) character token, then ignore
     that token and move on to the next one. (Newlines at the start of <code id="parsing-main-inbody:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>
     elements are ignored as an authoring convenience.)</p></li><li><p>Switch the tokenizer to the <a href="#rcdata-state" id="parsing-main-inbody:rcdata-state">RCDATA state</a>.</p></li><li><p>Set the <a href="#original-insertion-mode" id="parsing-main-inbody:original-insertion-mode">original insertion mode</a> to the current <a href="#insertion-mode" id="parsing-main-inbody:insertion-mode-8">insertion
     mode</a>.</p>

     </li><li><p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-13">frameset-ok flag</a> to "not ok".</p></li><li><p>Switch the <a href="#insertion-mode" id="parsing-main-inbody:insertion-mode-9">insertion mode</a> to "<a href="#parsing-main-incdata" id="parsing-main-inbody:parsing-main-incdata">text</a>".</p></li></ol>
   </dd><dt>A start tag whose tag name is "xmp"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-62">stack of open elements</a> <a href="#has-an-element-in-button-scope" id="parsing-main-inbody:has-an-element-in-button-scope-11">has a
    <code>p</code> element in button scope</a>, then <a href="#close-a-p-element" id="parsing-main-inbody:close-a-p-element-11">close a <code>p</code>
    element</a>.</p>

    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-12">Reconstruct the active formatting elements</a>, if any.</p>

    <p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-14">frameset-ok flag</a> to "not ok".</p>

    <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm" id="parsing-main-inbody:generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
   </dd><dt>A start tag whose tag name is "iframe"</dt><dd>
    <p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-15">frameset-ok flag</a> to "not ok".</p>

    <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm" id="parsing-main-inbody:generic-raw-text-element-parsing-algorithm-2">generic raw text element parsing algorithm</a>.</p>
   </dd><dt>A start tag whose tag name is "noembed"</dt><dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag" id="parsing-main-inbody:scripting-flag">scripting flag</a> is enabled</dt><dd>
    <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm" id="parsing-main-inbody:generic-raw-text-element-parsing-algorithm-3">generic raw text element parsing algorithm</a>.</p>
   </dd><dt>A start tag whose tag name is "select"</dt><dd>
    <p>If the parser was created as part of the <a href="#html-fragment-parsing-algorithm" id="parsing-main-inbody:html-fragment-parsing-algorithm-2">HTML fragment parsing algorithm</a>
    (<a href="#fragment-case" id="parsing-main-inbody:fragment-case-4">fragment case</a>) and the <a href="#concept-frag-parse-context" id="parsing-main-inbody:concept-frag-parse-context-2">context</a>
    element passed to that algorithm is a <code id="parsing-main-inbody:the-select-element-3"><a href="#the-select-element">select</a></code> element:</p>

    <ol><li><p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-39">Parse error</a>.</p></li><li><p>Ignore the token.</p></li></ol>

    <p>Otherwise, if the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-63">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-15">has a <code>select</code> element in scope</a>:</p>

    <ol><li><p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-40">Parse error</a>.</p></li><li><p>Ignore the token.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-64">stack of open elements</a> until a <code id="parsing-main-inbody:the-select-element-4"><a href="#the-select-element">select</a></code>
     element has been popped from the stack.</p></li></ol>

    <p>Otherwise:</p>

    <ol><li><p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-13">Reconstruct the active formatting elements</a>, if any.</p></li><li><p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-21">Insert an HTML element</a> for the token.</p></li><li><p>Set the <a href="#frameset-ok-flag" id="parsing-main-inbody:frameset-ok-flag-16">frameset-ok flag</a> to "not ok".</p></li></ol>
   </dd><dt>A start tag whose tag name is "option"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-65">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-16">has a
    <code>select</code> element in scope</a>:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-13">Generate implied end tags</a> except for <code id="parsing-main-inbody:the-optgroup-element-4"><a href="#the-optgroup-element">optgroup</a></code>
     elements.</p></li><li><p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-66">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-17">has an
     <code>option</code> element in scope</a>, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-41">parse error</a>.</p></li></ol>

    <p>Otherwise:</p>

    <ol><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-20">current node</a> is an <code id="parsing-main-inbody:the-option-element-4"><a href="#the-option-element">option</a></code> element, then pop the
     <a href="#current-node" id="parsing-main-inbody:current-node-21">current node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-67">stack of open elements</a>.</p></li></ol>

    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-14">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-22">Insert an HTML element</a> for the token.</p>
   </dd><dt>A start tag whose tag name is "optgroup"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-68">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-18">has a
    <code>select</code> element in scope</a>:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-14">Generate implied end tags</a>.</p></li><li><p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-69">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-19">has an
     <code>option</code> element in scope</a> or <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-20">has an
     <code>optgroup</code> element in scope</a>, then this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-42">parse
     error</a>.</p></li></ol>

    <p>Otherwise, if the <a href="#current-node" id="parsing-main-inbody:current-node-22">current node</a> is an <code id="parsing-main-inbody:the-option-element-5"><a href="#the-option-element">option</a></code> element, then pop the
    <a href="#current-node" id="parsing-main-inbody:current-node-23">current node</a> from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-70">stack of open elements</a>.</p>

    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-15">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-23">Insert an HTML element</a> for the token.</p>
   </dd><dt>A start tag whose tag name is one of: "rb", "rtc"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-71">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-21">has a
    <code>ruby</code> element in scope</a>, then <a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-15">generate implied end tags</a>. If the
    <a href="#current-node" id="parsing-main-inbody:current-node-24">current node</a> is not now a <code id="parsing-main-inbody:the-ruby-element"><a href="#the-ruby-element">ruby</a></code> element, this is a
    <a href="#parse-errors" id="parsing-main-inbody:parse-errors-43">parse error</a>.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-24">Insert an HTML element</a> for the token.</p>
   </dd><dt>A start tag whose tag name is one of: "rp", "rt"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-72">stack of open elements</a> <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-22">has a
    <code>ruby</code> element in scope</a>, then <a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-16">generate implied end tags</a>, except
    for <code id="parsing-main-inbody:rtc-4"><a href="#rtc">rtc</a></code> elements. If the <a href="#current-node" id="parsing-main-inbody:current-node-25">current node</a> is not now a <code id="parsing-main-inbody:rtc-5"><a href="#rtc">rtc</a></code>
    element or a <code id="parsing-main-inbody:the-ruby-element-2"><a href="#the-ruby-element">ruby</a></code> element, this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-44">parse error</a>.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-25">Insert an HTML element</a> for the token.</p>
   </dd><dt>A start tag whose tag name is "math"</dt><dd>
    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-16">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#adjust-mathml-attributes" id="parsing-main-inbody:adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This fixes the case of MathML
    attributes that are not all lowercase.)</p>

    <p><a href="#adjust-foreign-attributes" id="parsing-main-inbody:adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This fixes the use of namespaced
    attributes, in particular XLink.)</p>

    <p><a href="#insert-a-foreign-element" id="parsing-main-inbody:insert-a-foreign-element">Insert a foreign element</a> for the token, with <a id="parsing-main-inbody:mathml-namespace" href="https://infra.spec.whatwg.org/#mathml-namespace" data-x-internal="mathml-namespace">MathML namespace</a>
    and false.</p>

    

    <p>If the token has its <i id="parsing-main-inbody:self-closing-flag"><a href="#self-closing-flag">self-closing flag</a></i> set, pop the <a href="#current-node" id="parsing-main-inbody:current-node-26">current node</a> off the
    <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-73">stack of open elements</a> and <a href="#acknowledge-self-closing-flag" id="parsing-main-inbody:acknowledge-self-closing-flag-5">acknowledge
    the token's <i>self-closing flag</i></a>.</p>
   </dd><dt>A start tag whose tag name is "svg"</dt><dd>
    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-17">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#adjust-svg-attributes" id="parsing-main-inbody:adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes the case of SVG attributes that
    are not all lowercase.)</p>

    <p><a href="#adjust-foreign-attributes" id="parsing-main-inbody:adjust-foreign-attributes-2">Adjust foreign attributes</a> for the token. (This fixes the use of namespaced
    attributes, in particular XLink in SVG.)</p>

    <p><a href="#insert-a-foreign-element" id="parsing-main-inbody:insert-a-foreign-element-2">Insert a foreign element</a> for the token, with <a id="parsing-main-inbody:svg-namespace" href="https://infra.spec.whatwg.org/#svg-namespace" data-x-internal="svg-namespace">SVG namespace</a>
    and false.</p>

    

    <p>If the token has its <i id="parsing-main-inbody:self-closing-flag-2"><a href="#self-closing-flag">self-closing flag</a></i> set, pop the <a href="#current-node" id="parsing-main-inbody:current-node-27">current node</a> off the
    <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-74">stack of open elements</a> and <a href="#acknowledge-self-closing-flag" id="parsing-main-inbody:acknowledge-self-closing-flag-6">acknowledge
    the token's <i>self-closing flag</i></a>.</p>
   </dd><dt>A start  tag whose tag name is one of: "caption", "col", "colgroup", "frame",
   "head", "tbody", "td", "tfoot", "th", "thead", "tr"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inbody:parse-errors-45">Parse error</a>. Ignore the token.</p>

    
   </dd><dt>Any other start tag</dt><dd>
    <p><a href="#reconstruct-the-active-formatting-elements" id="parsing-main-inbody:reconstruct-the-active-formatting-elements-18">Reconstruct the active formatting elements</a>, if any.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-inbody:insert-an-html-element-26">Insert an HTML element</a> for the token.</p>

    <p class="note">This element will be an <a href="#ordinary" id="parsing-main-inbody:ordinary">ordinary</a> element. With one exception: if
    the <a href="#scripting-flag" id="parsing-main-inbody:scripting-flag-2">scripting flag</a> is disabled, it can also be a <code id="parsing-main-inbody:the-noscript-element"><a href="#the-noscript-element">noscript</a></code> element.</p>
   </dd><dt>Any other end tag</dt><dd>
    <p>Run these steps:</p>

    <ol><li><p>Initialize <var>node</var> to be the <a href="#current-node" id="parsing-main-inbody:current-node-28">current node</a> (the bottommost
     node of the stack).</p></li><li><p><i>Loop</i>: If <var>node</var> is an <a href="#html-elements" id="parsing-main-inbody:html-elements-15">HTML
     element</a> with the same tag name as the token, then:</p>

      <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-17">Generate implied end tags</a>, except for <a href="#html-elements" id="parsing-main-inbody:html-elements-16">HTML elements</a> with the
       same tag name as the token.</p></li><li><p>If <var>node</var> is not the <a href="#current-node" id="parsing-main-inbody:current-node-29">current node</a>, then this is a
       <a href="#parse-errors" id="parsing-main-inbody:parse-errors-46">parse error</a>.</p></li><li><p>Pop all the nodes from the <a href="#current-node" id="parsing-main-inbody:current-node-30">current node</a> up to <var>node</var>,
       including <var>node</var>, then stop these steps.</p></li></ol>
     </li><li><p>Otherwise, if <var>node</var> is in the <a href="#special" id="parsing-main-inbody:special-3">special</a> category, then
     this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-47">parse error</a>; ignore the token, and return.</p></li><li><p>Set <var>node</var> to the previous entry in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-75">stack of open
     elements</a>.</p></li><li><p>Return to the step labeled <i>loop</i>.</p></li></ol>
   </dd></dl>
  </div>

  <div data-algorithm="">
  <p>When the steps above say the user agent is to <dfn id="close-a-p-element">close a <code>p</code> element</dfn>, it
  means that the user agent must run the following steps:</p>

  <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-inbody:generate-implied-end-tags-18">Generate implied end tags</a>, except for <code id="parsing-main-inbody:the-p-element-6"><a href="#the-p-element">p</a></code> elements.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-31">current node</a> is not a <code id="parsing-main-inbody:the-p-element-7"><a href="#the-p-element">p</a></code> element, then this is a
   <a href="#parse-errors" id="parsing-main-inbody:parse-errors-48">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-76">stack of open elements</a> until a <code id="parsing-main-inbody:the-p-element-8"><a href="#the-p-element">p</a></code> element
   has been popped from the stack.</p></li></ol>
  </div>

  
  <div data-algorithm="">
  <p id="adoptionAgency">The <dfn id="adoption-agency-algorithm">adoption agency algorithm</dfn>, which takes as its only argument
  a token <var>token</var> for which the algorithm is being run, consists of the following
  steps:</p>

  <ol><li><p>Let <var>subject</var> be <var>token</var>'s tag name.</p></li><li><p>If the <a href="#current-node" id="parsing-main-inbody:current-node-32">current node</a> is an <a href="#html-elements" id="parsing-main-inbody:html-elements-17">HTML element</a>
   whose tag name is <var>subject</var>, and the <a href="#current-node" id="parsing-main-inbody:current-node-33">current node</a> is not in the
   <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-4">list of active formatting elements</a>, then pop the <a href="#current-node" id="parsing-main-inbody:current-node-34">current node</a> off the
   <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-77">stack of open elements</a> and return.</p></li><li><p>Let <var>outerLoopCounter</var> be 0.</p></li><li>
    <p>While true:</p>

    <ol><li><p>If <var>outerLoopCounter</var> is greater than or equal to 8, then return.</p></li><li><p>Increment <var>outerLoopCounter</var> by 1.</p></li><li>
      <p>Let <var>formattingElement</var> be the last element in the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-5">list of active
      formatting elements</a> that:</p>

      <ul><li>is between the end of the list and the last <a href="#concept-parser-marker" id="parsing-main-inbody:concept-parser-marker-4">marker</a> in the list, if any, or the start of the list
       otherwise, and</li><li>has the tag name <var>subject</var>.</li></ul>

      <p>If there is no such element, then return and instead act as described in the "any other end
      tag" entry above.</p>
     </li><li><p>If <var>formattingElement</var> is not in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-78">stack of open elements</a>, then
     this is a <a href="#parse-errors" id="parsing-main-inbody:parse-errors-49">parse error</a>; remove the element from the list, and return.</p></li><li><p>If <var>formattingElement</var> is in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-79">stack of open elements</a>, but the
     element is not <a href="#has-an-element-in-scope" id="parsing-main-inbody:has-an-element-in-scope-23">in scope</a>, then this is a
     <a href="#parse-errors" id="parsing-main-inbody:parse-errors-50">parse error</a>; return.</p></li><li><p>If <var>formattingElement</var> is not the <a href="#current-node" id="parsing-main-inbody:current-node-35">current node</a>, this is a
     <a href="#parse-errors" id="parsing-main-inbody:parse-errors-51">parse error</a>. (But do not return.)</p></li><li><p>Let <var>furthestBlock</var> be the topmost node in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-80">stack of open
     elements</a> that is lower in the stack than <var>formattingElement</var>, and is an
     element in the <a href="#special" id="parsing-main-inbody:special-4">special</a> category. There might not be one.</p></li><li><p>If there is no <var>furthestBlock</var>, then the UA must first pop all the nodes from
     the bottom of the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-81">stack of open elements</a>, from the <a href="#current-node" id="parsing-main-inbody:current-node-36">current node</a> up to
     and including <var>formattingElement</var>, then remove <var>formattingElement</var> from the
     <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-6">list of active formatting elements</a>, and finally return.</p></li><li><p>Let <var>commonAncestor</var> be the element immediately above
     <var>formattingElement</var> in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-82">stack of open elements</a>.</p></li><li><p>Let a bookmark note the position of <var>formattingElement</var> in the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-7">list of
     active formatting elements</a> relative to the elements on either side of it in the
     list.</p></li><li><p>Let <var>node</var> and <var>lastNode</var> be <var>furthestBlock</var>.</p></li><li><p>Let <var>innerLoopCounter</var> be 0.</p></li><li>
      <p>While true:</p>

      <ol><li><p>Increment <var>innerLoopCounter</var> by 1.</p></li><li><p>Let <var>node</var> be the element immediately above <var>node</var> in the
       <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-83">stack of open elements</a>, or if <var>node</var> is no longer in the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-84">stack of
       open elements</a> (e.g. because it got removed by this algorithm), the element that was immediately above <var>node</var> in
       the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-85">stack of open elements</a> before <var>node</var> was removed.</p></li><li><p>If <var>node</var> is <var>formattingElement</var>, then <a id="parsing-main-inbody:break" href="https://infra.spec.whatwg.org/#iteration-break" data-x-internal="break">break</a>.</p></li><li><p>If <var>innerLoopCounter</var> is greater than 3 and <var>node</var> is in the
       <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-8">list of active formatting elements</a>, then remove <var>node</var> from the
       <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-9">list of active formatting elements</a>.</p></li><li><p>If <var>node</var> is not in the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-10">list of active
       formatting elements</a>, then remove <var>node</var> from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-86">stack of open
       elements</a> and <a id="parsing-main-inbody:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a>.</p></li><li><p><a href="#create-an-element-for-the-token" id="parsing-main-inbody:create-an-element-for-the-token">Create an element for the token</a> for which the element <var>node</var> was
       created, in the <a id="parsing-main-inbody:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, with <var>commonAncestor</var> as the intended
       parent; replace the entry for <var>node</var> in the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-11">list of active formatting
       elements</a> with an entry for the new element, replace the entry for <var>node</var> in
       the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-87">stack of open elements</a> with an entry for the new element, and let
       <var>node</var> be the new element.</p></li><li><p>If <var>lastNode</var> is <var>furthestBlock</var>, then move the aforementioned
       bookmark to be immediately after the new <var>node</var> in the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-12">list of active
       formatting elements</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="parsing-main-inbody:concept-node-append" data-x-internal="concept-node-append">Append</a> <var>lastNode</var> to
       <var>node</var>.</p></li><li><p>Set <var>lastNode</var> to <var>node</var>.</p></li></ol>
     </li><li><p>Insert whatever <var>lastNode</var> ended up being in the previous step at the
     <a href="#appropriate-place-for-inserting-a-node" id="parsing-main-inbody:appropriate-place-for-inserting-a-node">appropriate place for inserting a node</a>, but using <var>commonAncestor</var>
     as the <i>override target</i>.</p></li><li><p><a href="#create-an-element-for-the-token" id="parsing-main-inbody:create-an-element-for-the-token-2">Create an element for the token</a> for which <var>formattingElement</var> was created,
     in the <a id="parsing-main-inbody:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, with <var>furthestBlock</var> as the intended parent.</p></li><li><p>Take all of the child nodes of <var>furthestBlock</var> and append them to the
     element created in the last step.</p></li><li><p>Append that new element to <var>furthestBlock</var>.</p></li><li><p>Remove <var>formattingElement</var> from the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-13">list of active formatting
     elements</a>, and insert the new element into the <a href="#list-of-active-formatting-elements" id="parsing-main-inbody:list-of-active-formatting-elements-14">list of active formatting
     elements</a> at the position of the aforementioned bookmark.</p></li><li><p>Remove <var>formattingElement</var> from the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-88">stack of open
     elements</a>, and insert the new element into the <a href="#stack-of-open-elements" id="parsing-main-inbody:stack-of-open-elements-89">stack of open elements</a>
     immediately below the position of <var>furthestBlock</var> in that stack.</p></li></ol>
   </li></ol>
  </div>

  <p class="note">This algorithm's name, the "adoption agency algorithm", comes from the way it
  causes elements to change parents, and is in contrast with <a href="https://ln.hixie.ch/?start=1037910467&amp;count=1">other possible algorithms</a> for dealing
  with misnested content.</p>





  <h6 id="parsing-main-incdata"><span class="secno">13.2.6.4.8</span> The "<dfn>text</dfn>" insertion mode<a href="#parsing-main-incdata" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-incdata" id="parsing-main-incdata:parsing-main-incdata">text</a>" <a href="#insertion-mode" id="parsing-main-incdata:insertion-mode">insertion mode</a>, the user agent must handle the token as
  follows:</p>

  <dl class="switch"><dt>A character token</dt><dd>
    <p><a href="#insert-a-character" id="parsing-main-incdata:insert-a-character">Insert the token's character</a>.</p>

    <p class="note">This can never be a U+0000 NULL character; the tokenizer converts those to
    U+FFFD REPLACEMENT CHARACTER characters.</p>
   </dd><dt>An end-of-file token</dt><dd>
    
    <p><a href="#parse-errors" id="parsing-main-incdata:parse-errors">Parse error</a>.</p>

    <p>If the <a href="#current-node" id="parsing-main-incdata:current-node">current node</a> is a <code id="parsing-main-incdata:the-script-element"><a href="#the-script-element">script</a></code> element, then set its <a href="#already-started" id="parsing-main-incdata:already-started">already
    started</a> to true.</p>

    <p>Pop the <a href="#current-node" id="parsing-main-incdata:current-node-2">current node</a> off the <a href="#stack-of-open-elements" id="parsing-main-incdata:stack-of-open-elements">stack of open elements</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-incdata:insertion-mode-2">insertion mode</a> to the <a href="#original-insertion-mode" id="parsing-main-incdata:original-insertion-mode">original insertion mode</a> and
    reprocess the token.</p>
   </dd><dt id="scriptEndTag">An end tag whose tag name is "script"</dt><dd>
    <p>If the <a href="#active-speculative-html-parser" id="parsing-main-incdata:active-speculative-html-parser">active speculative HTML parser</a> is null and the <a id="parsing-main-incdata:javascript-execution-context-stack" href="https://tc39.es/ecma262/#execution-context-stack" data-x-internal="javascript-execution-context-stack">JavaScript execution
    context stack</a> is empty, then <a href="#perform-a-microtask-checkpoint" id="parsing-main-incdata:perform-a-microtask-checkpoint">perform a microtask checkpoint</a>.</p>

    <p>Let <var>script</var> be the <a href="#current-node" id="parsing-main-incdata:current-node-3">current node</a> (which will be a
    <code id="parsing-main-incdata:the-script-element-2"><a href="#the-script-element">script</a></code> element).</p>

    <p>Pop the <a href="#current-node" id="parsing-main-incdata:current-node-4">current node</a> off the <a href="#stack-of-open-elements" id="parsing-main-incdata:stack-of-open-elements-2">stack of open elements</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-incdata:insertion-mode-3">insertion mode</a> to the <a href="#original-insertion-mode" id="parsing-main-incdata:original-insertion-mode-2">original insertion mode</a>.</p>

    <p>Let the <var>old insertion point</var> have the same value as the current
    <a href="#insertion-point" id="parsing-main-incdata:insertion-point">insertion point</a>. Let the <a href="#insertion-point" id="parsing-main-incdata:insertion-point-2">insertion point</a> be just before the <a href="#next-input-character" id="parsing-main-incdata:next-input-character">next
    input character</a>.</p>

    <p>Increment the parser's <a href="#script-nesting-level" id="parsing-main-incdata:script-nesting-level">script nesting level</a> by one.</p>

    <p>If the <a href="#active-speculative-html-parser" id="parsing-main-incdata:active-speculative-html-parser-2">active speculative HTML parser</a> is null, then <a href="#prepare-the-script-element" id="parsing-main-incdata:prepare-the-script-element">prepare the script
    element</a> <var>script</var>. This might cause some script to execute, which might cause
    <a href="#dom-document-write" id="parsing-main-incdata:dom-document-write">new characters to be inserted into the tokenizer</a>, and
    might cause the tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>

    <p>Decrement the parser's <a href="#script-nesting-level" id="parsing-main-incdata:script-nesting-level-2">script nesting level</a> by one. If the parser's <a href="#script-nesting-level" id="parsing-main-incdata:script-nesting-level-3">script
    nesting level</a> is zero, then set the <a href="#parser-pause-flag" id="parsing-main-incdata:parser-pause-flag">parser pause flag</a> to false.</p>

    <p>Let the <a href="#insertion-point" id="parsing-main-incdata:insertion-point-3">insertion point</a> have the value of the <var>old insertion
    point</var>. (In other words, restore the <a href="#insertion-point" id="parsing-main-incdata:insertion-point-4">insertion point</a> to its previous value.
    This value might be the "undefined" value.)</p>

    <p id="scriptTagParserResumes">At this stage, if the <a href="#pending-parsing-blocking-script" id="parsing-main-incdata:pending-parsing-blocking-script">pending parsing-blocking
    script</a> is not null, then:</p>

    <dl class="switch"><dt>If the <a href="#script-nesting-level" id="parsing-main-incdata:script-nesting-level-4">script nesting level</a> is not zero:</dt><dd>
      <p>Set the <a href="#parser-pause-flag" id="parsing-main-incdata:parser-pause-flag-2">parser pause flag</a> to true, and abort the processing of any nested
      invocations of the tokenizer, yielding control back to the caller. (Tokenization will resume
      when the caller returns to the "outer" tree construction stage.)</p>

      <p class="note">The tree construction stage of this particular parser is <a href="#nestedParsing">being called reentrantly</a>, say from a call to <code id="parsing-main-incdata:dom-document-write-2"><a href="#dom-document-write">document.write()</a></code>.</p>
     </dd><dt>Otherwise:</dt><dd>
      <p>While the <a href="#pending-parsing-blocking-script" id="parsing-main-incdata:pending-parsing-blocking-script-2">pending parsing-blocking script</a> is not null:</p>

      <ol><li><p>Let <var>the script</var> be the <a href="#pending-parsing-blocking-script" id="parsing-main-incdata:pending-parsing-blocking-script-3">pending parsing-blocking
       script</a>.</p></li><li><p>Set the <a href="#pending-parsing-blocking-script" id="parsing-main-incdata:pending-parsing-blocking-script-4">pending parsing-blocking script</a> to null.</p></li><li><p><a href="#start-the-speculative-html-parser" id="parsing-main-incdata:start-the-speculative-html-parser">Start the speculative HTML parser</a> for this instance of the HTML
       parser.</p></li><li><p>Block the <a href="#tokenization" id="parsing-main-incdata:tokenization">tokenizer</a> for this instance of the
       <a href="#html-parser" id="parsing-main-incdata:html-parser">HTML parser</a>, such that the <a href="#event-loop" id="parsing-main-incdata:event-loop">event loop</a> will not run <a href="#concept-task" id="parsing-main-incdata:concept-task">tasks</a> that invoke the <a href="#tokenization" id="parsing-main-incdata:tokenization-2">tokenizer</a>.</p></li><li><p>If the parser's <code id="parsing-main-incdata:document"><a href="#document">Document</a></code> <a href="#has-a-style-sheet-that-is-blocking-scripts" id="parsing-main-incdata:has-a-style-sheet-that-is-blocking-scripts">has a style sheet that is blocking
       scripts</a> or <var>the script</var>'s <a href="#ready-to-be-parser-executed" id="parsing-main-incdata:ready-to-be-parser-executed">ready to be parser-executed</a> is false:
       <a href="#spin-the-event-loop" id="parsing-main-incdata:spin-the-event-loop">spin the event loop</a> until the parser's <code id="parsing-main-incdata:document-2"><a href="#document">Document</a></code> <a href="#has-no-style-sheet-that-is-blocking-scripts" id="parsing-main-incdata:has-no-style-sheet-that-is-blocking-scripts">has no style
       sheet that is blocking scripts</a> and <var>the script</var>'s <a href="#ready-to-be-parser-executed" id="parsing-main-incdata:ready-to-be-parser-executed-2">ready to be
       parser-executed</a> becomes true.</p></li><li>
        <p>If this <a href="#abort-a-parser" id="parsing-main-incdata:abort-a-parser">parser has been aborted</a> in the meantime,
        return.</p>

        <p class="note">This could happen if, e.g., while the <a href="#spin-the-event-loop" id="parsing-main-incdata:spin-the-event-loop-2">spin the event loop</a>
        algorithm is running, the <code id="parsing-main-incdata:document-3"><a href="#document">Document</a></code> gets <a href="#destroy-a-document" id="parsing-main-incdata:destroy-a-document">destroyed</a>, or the <code id="parsing-main-incdata:dom-document-open"><a href="#dom-document-open">document.open()</a></code>
        method gets invoked on the <code id="parsing-main-incdata:document-4"><a href="#document">Document</a></code>.</p>
       </li><li><p><a href="#stop-the-speculative-html-parser" id="parsing-main-incdata:stop-the-speculative-html-parser">Stop the speculative HTML parser</a> for this instance of the HTML
       parser.</p></li><li><p>Unblock the <a href="#tokenization" id="parsing-main-incdata:tokenization-3">tokenizer</a> for this instance of the
       <a href="#html-parser" id="parsing-main-incdata:html-parser-2">HTML parser</a>, such that <a href="#concept-task" id="parsing-main-incdata:concept-task-2">tasks</a> that invoke the
       <a href="#tokenization" id="parsing-main-incdata:tokenization-4">tokenizer</a> can again be run.</p></li><li><p>Let the <a href="#insertion-point" id="parsing-main-incdata:insertion-point-5">insertion point</a> be just before the <a href="#next-input-character" id="parsing-main-incdata:next-input-character-2">next input
       character</a>.</p></li><li><p>Increment the parser's <a href="#script-nesting-level" id="parsing-main-incdata:script-nesting-level-5">script nesting level</a> by one (it should be zero
       before this step, so this sets it to one).</p></li><li><p><a href="#execute-the-script-element" id="parsing-main-incdata:execute-the-script-element">Execute the script element</a> <var>the script</var>.</p></li><li><p>Decrement the parser's <a href="#script-nesting-level" id="parsing-main-incdata:script-nesting-level-6">script nesting level</a> by one. If the parser's
       <a href="#script-nesting-level" id="parsing-main-incdata:script-nesting-level-7">script nesting level</a> is zero (which it always should be at this point), then set
       the <a href="#parser-pause-flag" id="parsing-main-incdata:parser-pause-flag-3">parser pause flag</a> to false.</p>

       </li><li><p>Let the <a href="#insertion-point" id="parsing-main-incdata:insertion-point-6">insertion point</a> be undefined again.</p></li></ol>
     </dd></dl>
   </dd><dt>Any other end tag</dt><dd>
    <p>Pop the <a href="#current-node" id="parsing-main-incdata:current-node-5">current node</a> off the <a href="#stack-of-open-elements" id="parsing-main-incdata:stack-of-open-elements-3">stack of open elements</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-incdata:insertion-mode-4">insertion mode</a> to the <a href="#original-insertion-mode" id="parsing-main-incdata:original-insertion-mode-3">original insertion mode</a>.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-intable"><span class="secno">13.2.6.4.9</span> The "<dfn>in table</dfn>" insertion mode<a href="#parsing-main-intable" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-intable" id="parsing-main-intable:parsing-main-intable">in
  table</a>" <a href="#insertion-mode" id="parsing-main-intable:insertion-mode">insertion mode</a>, the user agent must handle the token as follows:</p>

  <dl class="switch"><dt>A character token, if the <a href="#current-node" id="parsing-main-intable:current-node">current node</a> is <code id="parsing-main-intable:the-table-element"><a href="#the-table-element">table</a></code>, <code id="parsing-main-intable:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>, <code id="parsing-main-intable:the-template-element"><a href="#the-template-element">template</a></code>, <code id="parsing-main-intable:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code>, <code id="parsing-main-intable:the-thead-element"><a href="#the-thead-element">thead</a></code>, or <code id="parsing-main-intable:the-tr-element"><a href="#the-tr-element">tr</a></code> element</dt><dd>
     <p>Let the <dfn id="concept-pending-table-char-tokens"><var>pending table character
     tokens</var></dfn> be an empty list of tokens.</p>

     <p>Set the <a href="#original-insertion-mode" id="parsing-main-intable:original-insertion-mode">original insertion mode</a> to the current <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-2">insertion mode</a>.</p>

     <p>Switch the <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-intabletext" id="parsing-main-intable:parsing-main-intabletext">in
     table text</a>" and reprocess the token.</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="parsing-main-intable:insert-a-comment">Insert a comment</a>.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intable:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "caption"</dt><dd>
    <p><a href="#clear-the-stack-back-to-a-table-context" id="parsing-main-intable:clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See below.)</p>

    <p>Insert a <a href="#concept-parser-marker" id="parsing-main-intable:concept-parser-marker">marker</a> at the end of the <a href="#list-of-active-formatting-elements" id="parsing-main-intable:list-of-active-formatting-elements">list of
    active formatting elements</a>.</p>

    <p><a href="#insert-an-html-element" id="parsing-main-intable:insert-an-html-element">Insert an HTML element</a> for the token, then switch the <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-4">insertion
    mode</a> to "<a href="#parsing-main-incaption" id="parsing-main-intable:parsing-main-incaption">in caption</a>".</p>
   </dd><dt>A start tag whose tag name is "colgroup"</dt><dd>
    <p><a href="#clear-the-stack-back-to-a-table-context" id="parsing-main-intable:clear-the-stack-back-to-a-table-context-2">Clear the stack back to a table context</a>. (See below.)</p>

    <p><a href="#insert-an-html-element" id="parsing-main-intable:insert-an-html-element-2">Insert an HTML element</a> for the token, then switch the <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-5">insertion
    mode</a> to "<a href="#parsing-main-incolgroup" id="parsing-main-intable:parsing-main-incolgroup">in column group</a>".</p>
   </dd><dt>A start tag whose tag name is "col"</dt><dd>
    
    <p><a href="#clear-the-stack-back-to-a-table-context" id="parsing-main-intable:clear-the-stack-back-to-a-table-context-3">Clear the stack back to a table context</a>. (See below.)</p>

    <p><a href="#insert-an-html-element" id="parsing-main-intable:insert-an-html-element-3">Insert an HTML element</a> for a "colgroup" start tag token with no attributes, then
    switch the <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-6">insertion mode</a> to "<a href="#parsing-main-incolgroup" id="parsing-main-intable:parsing-main-incolgroup-2">in
    column group</a>".</p>
    

    <p>Reprocess the current token.</p>
   </dd><dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt><dd>
    <p><a href="#clear-the-stack-back-to-a-table-context" id="parsing-main-intable:clear-the-stack-back-to-a-table-context-4">Clear the stack back to a table context</a>. (See below.)</p>

    <p><a href="#insert-an-html-element" id="parsing-main-intable:insert-an-html-element-4">Insert an HTML element</a> for the token, then switch the <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-7">insertion
    mode</a> to "<a href="#parsing-main-intbody" id="parsing-main-intable:parsing-main-intbody">in table body</a>".</p>
   </dd><dt>A start tag whose tag name is one of: "td", "th", "tr"</dt><dd>
    
    <p><a href="#clear-the-stack-back-to-a-table-context" id="parsing-main-intable:clear-the-stack-back-to-a-table-context-5">Clear the stack back to a table context</a>. (See below.)</p>

    <p><a href="#insert-an-html-element" id="parsing-main-intable:insert-an-html-element-5">Insert an HTML element</a> for a "tbody" start tag token with no attributes, then
    switch the <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-8">insertion mode</a> to "<a href="#parsing-main-intbody" id="parsing-main-intable:parsing-main-intbody-2">in table
    body</a>".</p>
    

    <p>Reprocess the current token.</p>
   </dd><dt>A start tag whose tag name is "table"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intable:parse-errors-2">Parse error</a>.</p>

    
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intable:stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intable:has-an-element-in-table-scope">have a <code>table</code> element in table scope</a>, ignore the token.</p>

    <p>Otherwise:</p>

    <ol><li><p>Pop elements from this stack until a <code id="parsing-main-intable:the-table-element-2"><a href="#the-table-element">table</a></code> element has been popped from the
     stack.</p></li><li><p><a href="#reset-the-insertion-mode-appropriately" id="parsing-main-intable:reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p></li><li><p>Reprocess the token.</p></li></ol>
   </dd><dt>An end tag whose tag name is "table"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intable:stack-of-open-elements-2">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intable:has-an-element-in-table-scope-2">have a <code>table</code> element in table scope</a>, this is a <a href="#parse-errors" id="parsing-main-intable:parse-errors-3">parse
    error</a>; ignore the token.</p>

    <p>Otherwise:</p>

    <ol><li><p>Pop elements from this stack until a <code id="parsing-main-intable:the-table-element-3"><a href="#the-table-element">table</a></code> element has been popped from the
     stack.</p></li><li><p><a href="#reset-the-insertion-mode-appropriately" id="parsing-main-intable:reset-the-insertion-mode-appropriately-2">Reset the insertion mode appropriately</a>.</p></li></ol>
   </dd><dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "tbody",
   "td", "tfoot", "th", "thead", "tr"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intable:parse-errors-4">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is one of: "style", "script", "template"</dt><dt>An end tag whose tag name is "template"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-intable:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" id="parsing-main-intable:parsing-main-inhead">in head</a>" <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-9">insertion
    mode</a>.</p>
   </dd><dt>A start tag whose tag name is "input"</dt><dd>
    <p>If the token does not have an attribute with the name "type", or if it does, but that
    attribute's value is not an <a id="parsing-main-intable:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>hidden</code>", then: act as described in the "anything else" entry below.</p>

    <p>Otherwise:</p>

    <ol><li><p><a href="#parse-errors" id="parsing-main-intable:parse-errors-5">Parse error</a>.</p></li><li><p><a href="#insert-an-html-element" id="parsing-main-intable:insert-an-html-element-6">Insert an HTML element</a> for the token.</p></li><li><p>Pop that <code id="parsing-main-intable:the-input-element"><a href="#the-input-element">input</a></code> element off the <a href="#stack-of-open-elements" id="parsing-main-intable:stack-of-open-elements-3">stack of open elements</a>.</p></li><li><p><a href="#acknowledge-self-closing-flag" id="parsing-main-intable:acknowledge-self-closing-flag">Acknowledge the token's <i>self-closing
     flag</i></a>, if it is set.</p></li></ol>
   </dd><dt>A start tag whose tag name is "form"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intable:parse-errors-6">Parse error</a>.</p>

    <p>If there is a <code id="parsing-main-intable:the-template-element-2"><a href="#the-template-element">template</a></code> element on the <a href="#stack-of-open-elements" id="parsing-main-intable:stack-of-open-elements-4">stack of open elements</a>, or if
    the <a href="#form-element-pointer" id="parsing-main-intable:form-element-pointer"><code>form</code> element pointer</a> is not null, ignore the
    token.</p> 

    <p>Otherwise:</p>

    <ol><li><p><a href="#insert-an-html-element" id="parsing-main-intable:insert-an-html-element-7">Insert an HTML element</a> for the token, and set the <a href="#form-element-pointer" id="parsing-main-intable:form-element-pointer-2"><code>form</code> element pointer</a> to point to the element created.</p></li><li><p>Pop that <code id="parsing-main-intable:the-form-element"><a href="#the-form-element">form</a></code> element off the <a href="#stack-of-open-elements" id="parsing-main-intable:stack-of-open-elements-5">stack of open elements</a>.</p></li></ol>
   </dd><dt>An end-of-file token</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-intable:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-intable:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-10">insertion mode</a>.</p>
   </dd><dt>Anything else</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intable:parse-errors-7">Parse error</a>. Enable <a href="#foster-parent" id="parsing-main-intable:foster-parent">foster parenting</a>, process
    the token <a href="#using-the-rules-for" id="parsing-main-intable:using-the-rules-for-3">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-intable:parsing-main-inbody-2">in
    body</a>" <a href="#insertion-mode" id="parsing-main-intable:insertion-mode-11">insertion mode</a>, and then disable <a href="#foster-parent" id="parsing-main-intable:foster-parent-2">foster
    parenting</a>.</p>
   </dd></dl>
  </div>

  <div data-algorithm="">
  <p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack back to a table context</dfn>, it
  means that the UA must, while the <a href="#current-node" id="parsing-main-intable:current-node-2">current node</a> is not a <code id="parsing-main-intable:the-table-element-4"><a href="#the-table-element">table</a></code>,
  <code id="parsing-main-intable:the-template-element-3"><a href="#the-template-element">template</a></code>, or <code id="parsing-main-intable:the-html-element"><a href="#the-html-element">html</a></code> element, pop elements from the <a href="#stack-of-open-elements" id="parsing-main-intable:stack-of-open-elements-6">stack of open
  elements</a>.</p>
  </div>

  <p class="note">This is the same list of elements as used in the <i id="parsing-main-intable:has-an-element-in-table-scope-3"><a href="#has-an-element-in-table-scope">has an element in table scope</a></i> steps.</p>

  <p class="note">The <a href="#current-node" id="parsing-main-intable:current-node-3">current node</a> being an <code id="parsing-main-intable:the-html-element-2"><a href="#the-html-element">html</a></code> element after this
  process is a <a href="#fragment-case" id="parsing-main-intable:fragment-case">fragment case</a>.</p>



  <h6 id="parsing-main-intabletext"><span class="secno">13.2.6.4.10</span> The "<dfn>in table text</dfn>" insertion mode<a href="#parsing-main-intabletext" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-intabletext" id="parsing-main-intabletext:parsing-main-intabletext">in table text</a>" <a href="#insertion-mode" id="parsing-main-intabletext:insertion-mode">insertion mode</a>, the user agent must handle the token as
  follows:</p>

  <dl class="switch"><dt>A character token that is U+0000 NULL</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intabletext:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>Any other character token</dt><dd>
    <p>Append the character token to the <var id="parsing-main-intabletext:concept-pending-table-char-tokens"><a href="#concept-pending-table-char-tokens">pending
    table character tokens</a></var> list.</p>
   </dd><dt>Anything else</dt><dd>
    

    <p>If any of the tokens in the <var id="parsing-main-intabletext:concept-pending-table-char-tokens-2"><a href="#concept-pending-table-char-tokens">pending table
    character tokens</a></var> list are character tokens that are not <a id="parsing-main-intabletext:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a>,
    then this is a <a href="#parse-errors" id="parsing-main-intabletext:parse-errors-2">parse error</a>: reprocess the character tokens in the <var id="parsing-main-intabletext:concept-pending-table-char-tokens-3"><a href="#concept-pending-table-char-tokens">pending table character tokens</a></var> list using the
    rules given in the "anything else" entry in the "<a href="#parsing-main-intable" id="parsing-main-intabletext:parsing-main-intable">in
    table</a>" insertion mode.</p>

    

    <p>Otherwise, <a href="#insert-a-character" id="parsing-main-intabletext:insert-a-character">insert the characters</a> given by the <var id="parsing-main-intabletext:concept-pending-table-char-tokens-4"><a href="#concept-pending-table-char-tokens">pending table character tokens</a></var> list.</p> 

    

    <p>Switch the <a href="#insertion-mode" id="parsing-main-intabletext:insertion-mode-2">insertion mode</a> to the <a href="#original-insertion-mode" id="parsing-main-intabletext:original-insertion-mode">original insertion mode</a> and
    reprocess the token.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-incaption"><span class="secno">13.2.6.4.11</span> The "<dfn>in caption</dfn>" insertion mode<a href="#parsing-main-incaption" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-incaption" id="parsing-main-incaption:parsing-main-incaption">in
  caption</a>" <a href="#insertion-mode" id="parsing-main-incaption:insertion-mode">insertion mode</a>, the user agent must handle the token as follows:</p>

  <dl class="switch"><dt>An end tag whose tag name is "caption"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-incaption:stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-incaption:has-an-element-in-table-scope">have a <code>caption</code> element in table scope</a>, this is a <a href="#parse-errors" id="parsing-main-incaption:parse-errors">parse
    error</a>; ignore the token. (<a href="#fragment-case" id="parsing-main-incaption:fragment-case">fragment case</a>)</p>

    <p>Otherwise:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-incaption:generate-implied-end-tags">Generate implied end tags</a>.</p></li><li><p>Now, if the <a href="#current-node" id="parsing-main-incaption:current-node">current node</a> is not a <code id="parsing-main-incaption:the-caption-element"><a href="#the-caption-element">caption</a></code> element, then this is a
     <a href="#parse-errors" id="parsing-main-incaption:parse-errors-2">parse error</a>.</p></li><li><p>Pop elements from this stack until a <code id="parsing-main-incaption:the-caption-element-2"><a href="#the-caption-element">caption</a></code> element has been popped from the
     stack.</p></li><li><p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker" id="parsing-main-incaption:clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to the last marker</a>.</p></li><li><p>Switch the <a href="#insertion-mode" id="parsing-main-incaption:insertion-mode-2">insertion mode</a> to "<a href="#parsing-main-intable" id="parsing-main-incaption:parsing-main-intable">in
     table</a>".</p></li></ol>
   </dd><dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "td", "tfoot",
   "th", "thead", "tr"</dt><dt>An end tag whose tag name is "table"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-incaption:stack-of-open-elements-2">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-incaption:has-an-element-in-table-scope-2">have a <code>caption</code> element in table scope</a>, this is a <a href="#parse-errors" id="parsing-main-incaption:parse-errors-3">parse
    error</a>; ignore the token. (<a href="#fragment-case" id="parsing-main-incaption:fragment-case-2">fragment case</a>)</p>

    <p>Otherwise:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-incaption:generate-implied-end-tags-2">Generate implied end tags</a>.</p></li><li><p>Now, if the <a href="#current-node" id="parsing-main-incaption:current-node-2">current node</a> is not a <code id="parsing-main-incaption:the-caption-element-3"><a href="#the-caption-element">caption</a></code> element, then this is a
     <a href="#parse-errors" id="parsing-main-incaption:parse-errors-4">parse error</a>.</p></li><li><p>Pop elements from this stack until a <code id="parsing-main-incaption:the-caption-element-4"><a href="#the-caption-element">caption</a></code> element has been popped from the
     stack.</p></li><li><p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker" id="parsing-main-incaption:clear-the-list-of-active-formatting-elements-up-to-the-last-marker-2">Clear the list of active formatting elements up to the last marker</a>.</p></li><li><p>Switch the <a href="#insertion-mode" id="parsing-main-incaption:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-intable" id="parsing-main-incaption:parsing-main-intable-2">in
     table</a>".</p></li><li><p>Reprocess the token.</p></li></ol>
   </dd><dt>An end tag whose tag name is one of: "body", "col", "colgroup", "html", "tbody", "td",
   "tfoot", "th", "thead", "tr"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-incaption:parse-errors-5">Parse error</a>. Ignore the token.</p>
   </dd><dt>Anything else</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-incaption:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-incaption:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-incaption:insertion-mode-4">insertion mode</a>.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-incolgroup"><span class="secno">13.2.6.4.12</span> The "<dfn>in column group</dfn>" insertion mode<a href="#parsing-main-incolgroup" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-incolgroup" id="parsing-main-incolgroup:parsing-main-incolgroup">in column group</a>" <a href="#insertion-mode" id="parsing-main-incolgroup:insertion-mode">insertion mode</a>, the user agent must handle the token
  as follows:</p>

  <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
   FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p><a href="#insert-a-character" id="parsing-main-incolgroup:insert-a-character">Insert the character</a>.</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="parsing-main-incolgroup:insert-a-comment">Insert a comment</a>.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-incolgroup:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-incolgroup:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-incolgroup:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-incolgroup:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>A start tag whose tag name is "col"</dt><dd>
    <p><a href="#insert-an-html-element" id="parsing-main-incolgroup:insert-an-html-element">Insert an HTML element</a> for the token. Immediately pop the <a href="#current-node" id="parsing-main-incolgroup:current-node">current
    node</a> off the <a href="#stack-of-open-elements" id="parsing-main-incolgroup:stack-of-open-elements">stack of open elements</a>.</p>

    <p><a href="#acknowledge-self-closing-flag" id="parsing-main-incolgroup:acknowledge-self-closing-flag">Acknowledge the token's <i>self-closing
    flag</i></a>, if it is set.</p>
   </dd><dt>An end tag whose tag name is "colgroup"</dt><dd>
    <p>If the <a href="#current-node" id="parsing-main-incolgroup:current-node-2">current node</a> is not a <code id="parsing-main-incolgroup:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> element, then this is a
    <a href="#parse-errors" id="parsing-main-incolgroup:parse-errors-2">parse error</a>; ignore the token.</p> 

    <p>Otherwise, pop the <a href="#current-node" id="parsing-main-incolgroup:current-node-3">current node</a> from the <a href="#stack-of-open-elements" id="parsing-main-incolgroup:stack-of-open-elements-2">stack of open elements</a>.
    Switch the <a href="#insertion-mode" id="parsing-main-incolgroup:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-intable" id="parsing-main-incolgroup:parsing-main-intable">in
    table</a>".</p>
   </dd><dt>An end tag whose tag name is "col"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-incolgroup:parse-errors-3">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "template"</dt><dt>An end tag whose tag name is "template"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-incolgroup:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-inhead" id="parsing-main-incolgroup:parsing-main-inhead">in head</a>" <a href="#insertion-mode" id="parsing-main-incolgroup:insertion-mode-4">insertion mode</a>.</p>
   </dd><dt>An end-of-file token</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-incolgroup:using-the-rules-for-3">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-incolgroup:parsing-main-inbody-2">in body</a>" <a href="#insertion-mode" id="parsing-main-incolgroup:insertion-mode-5">insertion mode</a>.</p>
   </dd><dt>Anything else</dt><dd>
    
    <p>If the <a href="#current-node" id="parsing-main-incolgroup:current-node-4">current node</a> is not a <code id="parsing-main-incolgroup:the-colgroup-element-2"><a href="#the-colgroup-element">colgroup</a></code> element, then this is a
    <a href="#parse-errors" id="parsing-main-incolgroup:parse-errors-4">parse error</a>; ignore the token.</p> 

    <p>Otherwise, pop the <a href="#current-node" id="parsing-main-incolgroup:current-node-5">current node</a> from the <a href="#stack-of-open-elements" id="parsing-main-incolgroup:stack-of-open-elements-3">stack of open
    elements</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-incolgroup:insertion-mode-6">insertion mode</a> to "<a href="#parsing-main-intable" id="parsing-main-incolgroup:parsing-main-intable-2">in
    table</a>".</p>
    

    <p>Reprocess the token.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-intbody"><span class="secno">13.2.6.4.13</span> The "<dfn>in table body</dfn>" insertion mode<a href="#parsing-main-intbody" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-intbody" id="parsing-main-intbody:parsing-main-intbody">in table body</a>" <a href="#insertion-mode" id="parsing-main-intbody:insertion-mode">insertion mode</a>, the user agent must handle the token as
  follows:</p>

  <dl class="switch"><dt>A start tag whose tag name is "tr"</dt><dd>
    <p><a href="#clear-the-stack-back-to-a-table-body-context" id="parsing-main-intbody:clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body context</a>. (See below.)</p>

    <p><a href="#insert-an-html-element" id="parsing-main-intbody:insert-an-html-element">Insert an HTML element</a> for the token, then switch the <a href="#insertion-mode" id="parsing-main-intbody:insertion-mode-2">insertion
    mode</a> to "<a href="#parsing-main-intr" id="parsing-main-intbody:parsing-main-intr">in row</a>".</p>
   </dd><dt>A start tag whose tag name is one of: "th", "td"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intbody:parse-errors">Parse error</a>.</p>

    
    <p><a href="#clear-the-stack-back-to-a-table-body-context" id="parsing-main-intbody:clear-the-stack-back-to-a-table-body-context-2">Clear the stack back to a table body context</a>. (See below.)</p>

    <p><a href="#insert-an-html-element" id="parsing-main-intbody:insert-an-html-element-2">Insert an HTML element</a> for a "tr" start tag token with no attributes, then
    switch the <a href="#insertion-mode" id="parsing-main-intbody:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-intr" id="parsing-main-intbody:parsing-main-intr-2">in
    row</a>".</p>
    

    <p>Reprocess the current token.</p>
   </dd><dt>An end tag whose tag name is one of: "tbody", "tfoot",
   "thead"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intbody:stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intbody:has-an-element-in-table-scope">have an element in table scope</a> that is an <a href="#html-elements" id="parsing-main-intbody:html-elements">HTML
    element</a> with the same tag name as the token, this is a <a href="#parse-errors" id="parsing-main-intbody:parse-errors-2">parse error</a>;
    ignore the token.</p>

    <p>Otherwise:</p>

    <ol><li><p><a href="#clear-the-stack-back-to-a-table-body-context" id="parsing-main-intbody:clear-the-stack-back-to-a-table-body-context-3">Clear the stack back to a table body context</a>. (See below.)</p></li><li><p>Pop the <a href="#current-node" id="parsing-main-intbody:current-node">current node</a> from the <a href="#stack-of-open-elements" id="parsing-main-intbody:stack-of-open-elements-2">stack of open elements</a>. Switch the
     <a href="#insertion-mode" id="parsing-main-intbody:insertion-mode-4">insertion mode</a> to "<a href="#parsing-main-intable" id="parsing-main-intbody:parsing-main-intable">in table</a>".</p></li></ol>
   </dd><dt>A start tag whose tag name is one of: "caption", "col",
   "colgroup", "tbody", "tfoot", "thead"</dt><dt>An end tag whose tag name is "table"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intbody:stack-of-open-elements-3">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intbody:has-an-element-in-table-scope-2">have a <code>tbody</code>, <code>thead</code>, or <code>tfoot</code> element in table
    scope</a>, this is a <a href="#parse-errors" id="parsing-main-intbody:parse-errors-3">parse error</a>; ignore the token.</p>

    <p>Otherwise:</p>

    <ol><li><p><a href="#clear-the-stack-back-to-a-table-body-context" id="parsing-main-intbody:clear-the-stack-back-to-a-table-body-context-4">Clear the stack back to a table body context</a>. (See below.)</p></li><li><p>Pop the <a href="#current-node" id="parsing-main-intbody:current-node-2">current node</a> from the <a href="#stack-of-open-elements" id="parsing-main-intbody:stack-of-open-elements-4">stack of open elements</a>. Switch the
     <a href="#insertion-mode" id="parsing-main-intbody:insertion-mode-5">insertion mode</a> to "<a href="#parsing-main-intable" id="parsing-main-intbody:parsing-main-intable-2">in table</a>".</p></li><li><p>Reprocess the token.</p></li></ol>
   </dd><dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "td",
   "th", "tr"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intbody:parse-errors-4">Parse error</a>. Ignore the token.</p>
   </dd><dt>Anything else</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-intbody:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-intable" id="parsing-main-intbody:parsing-main-intable-3">in table</a>" <a href="#insertion-mode" id="parsing-main-intbody:insertion-mode-6">insertion mode</a>.</p>
   </dd></dl>
  </div>

  <div data-algorithm="">
  <p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack back to a table body context</dfn>,
  it means that the UA must, while the <a href="#current-node" id="parsing-main-intbody:current-node-3">current node</a> is not a <code id="parsing-main-intbody:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>,
  <code id="parsing-main-intbody:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code>, <code id="parsing-main-intbody:the-thead-element"><a href="#the-thead-element">thead</a></code>, <code id="parsing-main-intbody:the-template-element"><a href="#the-template-element">template</a></code>, or <code id="parsing-main-intbody:the-html-element"><a href="#the-html-element">html</a></code> element, pop
  elements from the <a href="#stack-of-open-elements" id="parsing-main-intbody:stack-of-open-elements-5">stack of open elements</a>.</p>
  </div>

  <p class="note">The <a href="#current-node" id="parsing-main-intbody:current-node-4">current node</a> being an <code id="parsing-main-intbody:the-html-element-2"><a href="#the-html-element">html</a></code> element after this
  process is a <a href="#fragment-case" id="parsing-main-intbody:fragment-case">fragment case</a>.</p>


  <h6 id="parsing-main-intr"><span class="secno">13.2.6.4.14</span> The "<dfn>in row</dfn>" insertion mode<a href="#parsing-main-intr" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-intr" id="parsing-main-intr:parsing-main-intr">in
  row</a>" <a href="#insertion-mode" id="parsing-main-intr:insertion-mode">insertion mode</a>, the user agent must handle the token as follows:</p>

  <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt><dd>
    <p><a href="#clear-the-stack-back-to-a-table-row-context" id="parsing-main-intr:clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row context</a>. (See below.)</p>

    <p><a href="#insert-an-html-element" id="parsing-main-intr:insert-an-html-element">Insert an HTML element</a> for the token, then switch the <a href="#insertion-mode" id="parsing-main-intr:insertion-mode-2">insertion
    mode</a> to "<a href="#parsing-main-intd" id="parsing-main-intr:parsing-main-intd">in cell</a>".</p>

    <p>Insert a <a href="#concept-parser-marker" id="parsing-main-intr:concept-parser-marker">marker</a> at the end of the <a href="#list-of-active-formatting-elements" id="parsing-main-intr:list-of-active-formatting-elements">list of
    active formatting elements</a>.</p>
   </dd><dt>An end tag whose tag name is "tr"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intr:stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intr:has-an-element-in-table-scope">have a <code>tr</code> element in table scope</a>, this is a <a href="#parse-errors" id="parsing-main-intr:parse-errors">parse error</a>;
    ignore the token.</p>

    <p>Otherwise:</p>

    <ol><li><p><a href="#clear-the-stack-back-to-a-table-row-context" id="parsing-main-intr:clear-the-stack-back-to-a-table-row-context-2">Clear the stack back to a table row context</a>. (See below.)</p></li><li><p>Pop the <a href="#current-node" id="parsing-main-intr:current-node">current node</a> (which will be a <code id="parsing-main-intr:the-tr-element"><a href="#the-tr-element">tr</a></code> element) from the
     <a href="#stack-of-open-elements" id="parsing-main-intr:stack-of-open-elements-2">stack of open elements</a>. Switch the <a href="#insertion-mode" id="parsing-main-intr:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-intbody" id="parsing-main-intr:parsing-main-intbody">in table body</a>".</p></li></ol>
   </dd><dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "tfoot",
   "thead", "tr"</dt><dt>An end tag whose tag name is "table"</dt><dd>
    
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intr:stack-of-open-elements-3">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intr:has-an-element-in-table-scope-2">have a <code>tr</code> element in table scope</a>, this is a <a href="#parse-errors" id="parsing-main-intr:parse-errors-2">parse error</a>;
    ignore the token.</p>

    <p>Otherwise:</p>

    <ol><li><p><a href="#clear-the-stack-back-to-a-table-row-context" id="parsing-main-intr:clear-the-stack-back-to-a-table-row-context-3">Clear the stack back to a table row context</a>. (See below.)</p></li><li><p>Pop the <a href="#current-node" id="parsing-main-intr:current-node-2">current node</a> (which will be a <code id="parsing-main-intr:the-tr-element-2"><a href="#the-tr-element">tr</a></code> element) from the
     <a href="#stack-of-open-elements" id="parsing-main-intr:stack-of-open-elements-4">stack of open elements</a>. Switch the <a href="#insertion-mode" id="parsing-main-intr:insertion-mode-4">insertion mode</a> to "<a href="#parsing-main-intbody" id="parsing-main-intr:parsing-main-intbody-2">in table body</a>".</p></li><li><p>Reprocess the token.</p></li></ol>
   </dd><dt>An end tag whose tag name is one of: "tbody", "tfoot", "thead"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intr:stack-of-open-elements-5">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intr:has-an-element-in-table-scope-3">have an element in table scope</a> that is an <a href="#html-elements" id="parsing-main-intr:html-elements">HTML
    element</a> with the same tag name as the token, this is a <a href="#parse-errors" id="parsing-main-intr:parse-errors-3">parse error</a>;
    ignore the token.</p>

    
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intr:stack-of-open-elements-6">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intr:has-an-element-in-table-scope-4">have a <code>tr</code> element in table scope</a>, ignore the token.</p>

    <p>Otherwise:</p>

    <ol><li><p><a href="#clear-the-stack-back-to-a-table-row-context" id="parsing-main-intr:clear-the-stack-back-to-a-table-row-context-4">Clear the stack back to a table row context</a>. (See below.)</p></li><li><p>Pop the <a href="#current-node" id="parsing-main-intr:current-node-3">current node</a> (which will be a <code id="parsing-main-intr:the-tr-element-3"><a href="#the-tr-element">tr</a></code> element) from the
     <a href="#stack-of-open-elements" id="parsing-main-intr:stack-of-open-elements-7">stack of open elements</a>. Switch the <a href="#insertion-mode" id="parsing-main-intr:insertion-mode-5">insertion mode</a> to "<a href="#parsing-main-intbody" id="parsing-main-intr:parsing-main-intbody-3">in table body</a>".</p></li><li><p>Reprocess the token.</p></li></ol>
   </dd><dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "td",
   "th"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intr:parse-errors-4">Parse error</a>. Ignore the token.</p>
   </dd><dt>Anything else</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-intr:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-intable" id="parsing-main-intr:parsing-main-intable">in table</a>" <a href="#insertion-mode" id="parsing-main-intr:insertion-mode-6">insertion mode</a>.</p>
   </dd></dl>
  </div>

  <div data-algorithm="">
  <p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack back to a table row context</dfn>,
  it means that the UA must, while the <a href="#current-node" id="parsing-main-intr:current-node-4">current node</a> is not a <code id="parsing-main-intr:the-tr-element-4"><a href="#the-tr-element">tr</a></code>,
  <code id="parsing-main-intr:the-template-element"><a href="#the-template-element">template</a></code>, or <code id="parsing-main-intr:the-html-element"><a href="#the-html-element">html</a></code> element, pop elements from the <a href="#stack-of-open-elements" id="parsing-main-intr:stack-of-open-elements-8">stack of open
  elements</a>.</p>
  </div>

  <p class="note">The <a href="#current-node" id="parsing-main-intr:current-node-5">current node</a> being an <code id="parsing-main-intr:the-html-element-2"><a href="#the-html-element">html</a></code> element after this
  process is a <a href="#fragment-case" id="parsing-main-intr:fragment-case">fragment case</a>.</p>


  <h6 id="parsing-main-intd"><span class="secno">13.2.6.4.15</span> The "<dfn>in cell</dfn>" insertion mode<a href="#parsing-main-intd" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-intd" id="parsing-main-intd:parsing-main-intd">in cell</a>" <a href="#insertion-mode" id="parsing-main-intd:insertion-mode">insertion mode</a>, the user agent must handle the token as follows:</p>

  <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intd:stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intd:has-an-element-in-table-scope">have an element in table scope</a> that is an <a href="#html-elements" id="parsing-main-intd:html-elements">HTML
    element</a> with the same tag name as that of the token, then this is a <a href="#parse-errors" id="parsing-main-intd:parse-errors">parse
    error</a>; ignore the token.</p>

    <p>Otherwise:</p>

    <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-intd:generate-implied-end-tags">Generate implied end tags</a>.</p></li><li><p>Now, if the <a href="#current-node" id="parsing-main-intd:current-node">current node</a> is not an <a href="#html-elements" id="parsing-main-intd:html-elements-2">HTML
     element</a> with the same tag name as the token, then this is a <a href="#parse-errors" id="parsing-main-intd:parse-errors-2">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-intd:stack-of-open-elements-2">stack of open elements</a> until an <a href="#html-elements" id="parsing-main-intd:html-elements-3">HTML element</a> with the same tag name as the token has been popped from the
     stack.</p></li><li><p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker" id="parsing-main-intd:clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to the last marker</a>.</p></li><li><p>Switch the <a href="#insertion-mode" id="parsing-main-intd:insertion-mode-2">insertion mode</a> to "<a href="#parsing-main-intr" id="parsing-main-intd:parsing-main-intr">in
     row</a>".</p></li></ol>
   </dd><dt>A start tag whose tag name is one of: "caption", "col",
   "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt><dd>
    <p><a id="parsing-main-intd:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: The <a href="#stack-of-open-elements" id="parsing-main-intd:stack-of-open-elements-3">stack of open elements</a> <a href="#has-an-element-in-table-scope" id="parsing-main-intd:has-an-element-in-table-scope-2">has a <code>td</code> or <code>th</code> element in table scope</a>.</p>
    

    <p><a href="#close-the-cell" id="parsing-main-intd:close-the-cell">Close the cell</a> (see below) and reprocess the token.</p>
   </dd><dt>An end tag whose tag name is one of: "body", "caption",
   "col", "colgroup", "html"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intd:parse-errors-3">Parse error</a>. Ignore the token.</p>
   </dd><dt>An end tag whose tag name is one of: "table", "tbody",
   "tfoot", "thead", "tr"</dt><dd>
    <p>If the <a href="#stack-of-open-elements" id="parsing-main-intd:stack-of-open-elements-4">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" id="parsing-main-intd:has-an-element-in-table-scope-3">have an element in table scope</a> that is an <a href="#html-elements" id="parsing-main-intd:html-elements-4">HTML
    element</a> with the same tag name as that of the token, then this is a <a href="#parse-errors" id="parsing-main-intd:parse-errors-4">parse
    error</a>; ignore the token.</p>

    <p>Otherwise, <a href="#close-the-cell" id="parsing-main-intd:close-the-cell-2">close the cell</a> (see below) and reprocess the token.</p>
   </dd><dt>Anything else</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-intd:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-intd:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-intd:insertion-mode-3">insertion mode</a>.</p>
   </dd></dl>
  </div>

  <div data-algorithm="">
  <p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they mean to run the following
  algorithm:</p>

  <ol><li><p><a href="#generate-implied-end-tags" id="parsing-main-intd:generate-implied-end-tags-2">Generate implied end tags</a>.</p></li><li><p>If the <a href="#current-node" id="parsing-main-intd:current-node-2">current node</a> is not now a <code id="parsing-main-intd:the-td-element"><a href="#the-td-element">td</a></code> element or a <code id="parsing-main-intd:the-th-element"><a href="#the-th-element">th</a></code>
   element, then this is a <a href="#parse-errors" id="parsing-main-intd:parse-errors-5">parse error</a>.</p></li><li><p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-intd:stack-of-open-elements-5">stack of open elements</a> until a <code id="parsing-main-intd:the-td-element-2"><a href="#the-td-element">td</a></code>
   element or a <code id="parsing-main-intd:the-th-element-2"><a href="#the-th-element">th</a></code> element has been popped from the stack.</p></li><li><p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker" id="parsing-main-intd:clear-the-list-of-active-formatting-elements-up-to-the-last-marker-2">Clear the list of active formatting elements up to the last marker</a>.</p></li><li><p>Switch the <a href="#insertion-mode" id="parsing-main-intd:insertion-mode-4">insertion mode</a> to "<a href="#parsing-main-intr" id="parsing-main-intd:parsing-main-intr-2">in
   row</a>".</p></li></ol>
  </div>

  <p class="note">The <a href="#stack-of-open-elements" id="parsing-main-intd:stack-of-open-elements-6">stack of open elements</a> cannot have both a <code id="parsing-main-intd:the-td-element-3"><a href="#the-td-element">td</a></code> and a
  <code id="parsing-main-intd:the-th-element-3"><a href="#the-th-element">th</a></code> element <a href="#has-an-element-in-table-scope" id="parsing-main-intd:has-an-element-in-table-scope-4">in table scope</a> at the
  same time, nor can it have neither when the <a href="#close-the-cell" id="parsing-main-intd:close-the-cell-3">close the cell</a> algorithm is invoked.</p>


  <h6 id="parsing-main-intemplate"><span class="secno">13.2.6.4.16</span> The "<dfn>in template</dfn>" insertion mode<a href="#parsing-main-intemplate" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-intemplate" id="parsing-main-intemplate:parsing-main-intemplate">in
  template</a>" <a href="#insertion-mode" id="parsing-main-intemplate:insertion-mode">insertion mode</a>, the user agent must handle the token as follows:</p>

  <dl class="switch"><dt>A character token</dt><dt>A comment token</dt><dt>A DOCTYPE token</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-intemplate:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-intemplate:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-intemplate:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "template", "title"</dt><dt>An end tag whose tag name is "template"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-intemplate:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-inhead" id="parsing-main-intemplate:parsing-main-inhead">in head</a>" <a href="#insertion-mode" id="parsing-main-intemplate:insertion-mode-3">insertion mode</a>.</p>
   </dd><dt>A start tag whose tag name is one of: "caption", "colgroup", "tbody", "tfoot", "thead"</dt><dd>
    <p>Pop the <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode">current template insertion mode</a> off the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes">stack of template
    insertion modes</a>.</p>

    <p>Push "<a href="#parsing-main-intable" id="parsing-main-intemplate:parsing-main-intable">in table</a>" onto the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-2">stack of
    template insertion modes</a> so that it is the new <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-2">current template insertion
    mode</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-intemplate:insertion-mode-4">insertion mode</a> to "<a href="#parsing-main-intable" id="parsing-main-intemplate:parsing-main-intable-2">in
    table</a>", and reprocess the token.</p>
   </dd><dt>A start tag whose tag name is "col"</dt><dd>
    <p>Pop the <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-3">current template insertion mode</a> off the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-3">stack of template
    insertion modes</a>.</p>

    <p>Push "<a href="#parsing-main-incolgroup" id="parsing-main-intemplate:parsing-main-incolgroup">in column group</a>" onto the
    <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-4">stack of template insertion modes</a> so that it is the new <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-4">current template
    insertion mode</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-intemplate:insertion-mode-5">insertion mode</a> to "<a href="#parsing-main-incolgroup" id="parsing-main-intemplate:parsing-main-incolgroup-2">in
    column group</a>", and reprocess the token.</p>
   </dd><dt>A start tag whose tag name is "tr"</dt><dd>
    <p>Pop the <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-5">current template insertion mode</a> off the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-5">stack of template
    insertion modes</a>.</p>

    <p>Push "<a href="#parsing-main-intbody" id="parsing-main-intemplate:parsing-main-intbody">in table body</a>" onto the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-6">stack
    of template insertion modes</a> so that it is the new <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-6">current template insertion
    mode</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-intemplate:insertion-mode-6">insertion mode</a> to "<a href="#parsing-main-intbody" id="parsing-main-intemplate:parsing-main-intbody-2">in
    table body</a>", and reprocess the token.</p>
   </dd><dt>A start tag whose tag name is one of: "td", "th"</dt><dd>
    <p>Pop the <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-7">current template insertion mode</a> off the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-7">stack of template
    insertion modes</a>.</p>

    <p>Push "<a href="#parsing-main-intr" id="parsing-main-intemplate:parsing-main-intr">in row</a>" onto the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-8">stack of template
    insertion modes</a> so that it is the new <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-8">current template insertion mode</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-intemplate:insertion-mode-7">insertion mode</a> to "<a href="#parsing-main-intr" id="parsing-main-intemplate:parsing-main-intr-2">in
    row</a>", and reprocess the token.</p>
   </dd><dt>Any other start tag</dt><dd>
    <p>Pop the <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-9">current template insertion mode</a> off the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-9">stack of template
    insertion modes</a>.</p>

    <p>Push "<a href="#parsing-main-inbody" id="parsing-main-intemplate:parsing-main-inbody-2">in body</a>" onto the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-10">stack of template
    insertion modes</a> so that it is the new <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-10">current template insertion mode</a>.</p>

    <p>Switch the <a href="#insertion-mode" id="parsing-main-intemplate:insertion-mode-8">insertion mode</a> to "<a href="#parsing-main-inbody" id="parsing-main-intemplate:parsing-main-inbody-3">in
    body</a>", and reprocess the token.</p>
   </dd><dt>Any other end tag</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-intemplate:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>An end-of-file token</dt><dd>
    <p>If there is no <code id="parsing-main-intemplate:the-template-element"><a href="#the-template-element">template</a></code> element on the <a href="#stack-of-open-elements" id="parsing-main-intemplate:stack-of-open-elements">stack of open elements</a>, then
    <a href="#stop-parsing" id="parsing-main-intemplate:stop-parsing">stop parsing</a>. (<a href="#fragment-case" id="parsing-main-intemplate:fragment-case">fragment case</a>)</p>

    <p>Otherwise, this is a <a href="#parse-errors" id="parsing-main-intemplate:parse-errors-2">parse error</a>.</p>

    
    <p>Pop elements from the <a href="#stack-of-open-elements" id="parsing-main-intemplate:stack-of-open-elements-2">stack of open elements</a> until a <code id="parsing-main-intemplate:the-template-element-2"><a href="#the-template-element">template</a></code>
    element has been popped from the stack.</p>

    <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker" id="parsing-main-intemplate:clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to the last marker</a>.</p>

    <p>Pop the <a href="#current-template-insertion-mode" id="parsing-main-intemplate:current-template-insertion-mode-11">current template insertion mode</a> off the <a href="#stack-of-template-insertion-modes" id="parsing-main-intemplate:stack-of-template-insertion-modes-11">stack of template
    insertion modes</a>.</p>

    <p><a href="#reset-the-insertion-mode-appropriately" id="parsing-main-intemplate:reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
    

    <p>Reprocess the token.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-afterbody"><span class="secno">13.2.6.4.17</span> The "<dfn>after body</dfn>" insertion mode<a href="#parsing-main-afterbody" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-afterbody" id="parsing-main-afterbody:parsing-main-afterbody">after body</a>" <a href="#insertion-mode" id="parsing-main-afterbody:insertion-mode">insertion mode</a>, the user agent must handle the token as follows:</p>

  <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
   FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-afterbody:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-afterbody:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-afterbody:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="parsing-main-afterbody:insert-a-comment">Insert a comment</a> as the last child of the first element in the <a href="#stack-of-open-elements" id="parsing-main-afterbody:stack-of-open-elements">stack of
    open elements</a> (the <code id="parsing-main-afterbody:the-html-element"><a href="#the-html-element">html</a></code> element).</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-afterbody:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-afterbody:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-afterbody:parsing-main-inbody-2">in body</a>" <a href="#insertion-mode" id="parsing-main-afterbody:insertion-mode-3">insertion mode</a>.</p>
   </dd><dt>An end tag whose tag name is "html"</dt><dd>
    <p>If the parser was created as part of the <a href="#html-fragment-parsing-algorithm" id="parsing-main-afterbody:html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>, this
    is a <a href="#parse-errors" id="parsing-main-afterbody:parse-errors-2">parse error</a>; ignore the token. (<a href="#fragment-case" id="parsing-main-afterbody:fragment-case">fragment case</a>)</p>

    <p>Otherwise, switch the <a href="#insertion-mode" id="parsing-main-afterbody:insertion-mode-4">insertion mode</a> to "<a href="#the-after-after-body-insertion-mode" id="parsing-main-afterbody:the-after-after-body-insertion-mode">after after body</a>".</p>
   </dd><dt>An end-of-file token</dt><dd>
    <p><a href="#stop-parsing" id="parsing-main-afterbody:stop-parsing">Stop parsing</a>.</p>
   </dd><dt>Anything else</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-afterbody:parse-errors-3">Parse error</a>. Switch the <a href="#insertion-mode" id="parsing-main-afterbody:insertion-mode-5">insertion mode</a> to "<a href="#parsing-main-inbody" id="parsing-main-afterbody:parsing-main-inbody-3">in body</a>" and reprocess the token.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-inframeset"><span class="secno">13.2.6.4.18</span> The "<dfn>in frameset</dfn>" insertion mode<a href="#parsing-main-inframeset" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-inframeset" id="parsing-main-inframeset:parsing-main-inframeset">in
  frameset</a>" <a href="#insertion-mode" id="parsing-main-inframeset:insertion-mode">insertion mode</a>, the user agent must handle the token as follows:</p>

  <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
   FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p><a href="#insert-a-character" id="parsing-main-inframeset:insert-a-character">Insert the character</a>.</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="parsing-main-inframeset:insert-a-comment">Insert a comment</a>.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inframeset:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-inframeset:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-inframeset:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-inframeset:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>A start tag whose tag name is "frameset"</dt><dd>
    <p><a href="#insert-an-html-element" id="parsing-main-inframeset:insert-an-html-element">Insert an HTML element</a> for the token.</p>
   </dd><dt>An end tag whose tag name is "frameset"</dt><dd>
    <p>If the <a href="#current-node" id="parsing-main-inframeset:current-node">current node</a> is the root <code id="parsing-main-inframeset:the-html-element"><a href="#the-html-element">html</a></code> element, then this is a
    <a href="#parse-errors" id="parsing-main-inframeset:parse-errors-2">parse error</a>; ignore the token. (<a href="#fragment-case" id="parsing-main-inframeset:fragment-case">fragment case</a>)</p>

    <p>Otherwise, pop the <a href="#current-node" id="parsing-main-inframeset:current-node-2">current node</a> from the <a href="#stack-of-open-elements" id="parsing-main-inframeset:stack-of-open-elements">stack of open
    elements</a>.</p>

    <p>If the parser was not created as part of the <a href="#html-fragment-parsing-algorithm" id="parsing-main-inframeset:html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
    (<a href="#fragment-case" id="parsing-main-inframeset:fragment-case-2">fragment case</a>), and the <a href="#current-node" id="parsing-main-inframeset:current-node-3">current node</a> is no longer a
    <code id="parsing-main-inframeset:frameset"><a href="#frameset">frameset</a></code> element, then switch the <a href="#insertion-mode" id="parsing-main-inframeset:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-afterframeset" id="parsing-main-inframeset:parsing-main-afterframeset">after frameset</a>".</p>
   </dd><dt>A start tag whose tag name is "frame"</dt><dd>
    <p><a href="#insert-an-html-element" id="parsing-main-inframeset:insert-an-html-element-2">Insert an HTML element</a> for the token. Immediately pop the <a href="#current-node" id="parsing-main-inframeset:current-node-4">current
    node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inframeset:stack-of-open-elements-2">stack of open elements</a>.</p>

    <p><a href="#acknowledge-self-closing-flag" id="parsing-main-inframeset:acknowledge-self-closing-flag">Acknowledge the token's <i>self-closing
    flag</i></a>, if it is set.</p>
   </dd><dt>A start tag whose tag name is "noframes"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-inframeset:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-inhead" id="parsing-main-inframeset:parsing-main-inhead">in head</a>" <a href="#insertion-mode" id="parsing-main-inframeset:insertion-mode-4">insertion mode</a>.</p>
   </dd><dt>An end-of-file token</dt><dd>
    <p>If the <a href="#current-node" id="parsing-main-inframeset:current-node-5">current node</a> is not the root <code id="parsing-main-inframeset:the-html-element-2"><a href="#the-html-element">html</a></code> element, then this is a
    <a href="#parse-errors" id="parsing-main-inframeset:parse-errors-3">parse error</a>.</p>

    <p class="note">The <a href="#current-node" id="parsing-main-inframeset:current-node-6">current node</a> can only be the root
    <code id="parsing-main-inframeset:the-html-element-3"><a href="#the-html-element">html</a></code> element in the <a href="#fragment-case" id="parsing-main-inframeset:fragment-case-3">fragment case</a>.</p>

    <p><a href="#stop-parsing" id="parsing-main-inframeset:stop-parsing">Stop parsing</a>.</p>
   </dd><dt>Anything else</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inframeset:parse-errors-4">Parse error</a>. Ignore the token.</p>
   </dd></dl>
  </div>


  <h6 id="parsing-main-afterframeset"><span class="secno">13.2.6.4.19</span> The "<dfn>after frameset</dfn>" insertion mode<a href="#parsing-main-afterframeset" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#parsing-main-afterframeset" id="parsing-main-afterframeset:parsing-main-afterframeset">after frameset</a>" <a href="#insertion-mode" id="parsing-main-afterframeset:insertion-mode">insertion mode</a>, the user agent must handle the token
  as follows:</p>

  
  <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
   FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p><a href="#insert-a-character" id="parsing-main-afterframeset:insert-a-character">Insert the character</a>.</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="parsing-main-afterframeset:insert-a-comment">Insert a comment</a>.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-afterframeset:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-afterframeset:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="parsing-main-afterframeset:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="parsing-main-afterframeset:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>An end tag whose tag name is "html"</dt><dd>
    <p>Switch the <a href="#insertion-mode" id="parsing-main-afterframeset:insertion-mode-3">insertion mode</a> to "<a href="#the-after-after-frameset-insertion-mode" id="parsing-main-afterframeset:the-after-after-frameset-insertion-mode">after after frameset</a>".</p>
   </dd><dt>A start tag whose tag name is "noframes"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="parsing-main-afterframeset:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-inhead" id="parsing-main-afterframeset:parsing-main-inhead">in head</a>" <a href="#insertion-mode" id="parsing-main-afterframeset:insertion-mode-4">insertion mode</a>.</p>
   </dd><dt>An end-of-file token</dt><dd>
    <p><a href="#stop-parsing" id="parsing-main-afterframeset:stop-parsing">Stop parsing</a>.</p>
   </dd><dt>Anything else</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-afterframeset:parse-errors-2">Parse error</a>. Ignore the token.</p>
   </dd></dl>
  </div>


  <h6 id="the-after-after-body-insertion-mode"><span class="secno">13.2.6.4.20</span> The "<dfn>after after body</dfn>" insertion mode<a href="#the-after-after-body-insertion-mode" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#the-after-after-body-insertion-mode" id="the-after-after-body-insertion-mode:the-after-after-body-insertion-mode">after after body</a>" <a href="#insertion-mode" id="the-after-after-body-insertion-mode:insertion-mode">insertion mode</a>, the user agent must handle the token
  as follows:</p>

  <dl class="switch"><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="the-after-after-body-insertion-mode:insert-a-comment">Insert a comment</a> as the last child of the <code id="the-after-after-body-insertion-mode:document"><a href="#document">Document</a></code> object.</p>
   </dd><dt>A DOCTYPE token</dt><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
   FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="the-after-after-body-insertion-mode:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="the-after-after-body-insertion-mode:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="the-after-after-body-insertion-mode:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>An end-of-file token</dt><dd>
    <p><a href="#stop-parsing" id="the-after-after-body-insertion-mode:stop-parsing">Stop parsing</a>.</p>
   </dd><dt>Anything else</dt><dd>
    <p><a href="#parse-errors" id="the-after-after-body-insertion-mode:parse-errors">Parse error</a>. Switch the <a href="#insertion-mode" id="the-after-after-body-insertion-mode:insertion-mode-3">insertion mode</a> to "<a href="#parsing-main-inbody" id="the-after-after-body-insertion-mode:parsing-main-inbody-2">in body</a>" and reprocess the token.</p>
   </dd></dl>
  </div>


  <h6 id="the-after-after-frameset-insertion-mode"><span class="secno">13.2.6.4.21</span> The "<dfn>after after frameset</dfn>" insertion mode<a href="#the-after-after-frameset-insertion-mode" class="self-link"></a></h6>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for the "<a href="#the-after-after-frameset-insertion-mode" id="the-after-after-frameset-insertion-mode:the-after-after-frameset-insertion-mode">after after frameset</a>" <a href="#insertion-mode" id="the-after-after-frameset-insertion-mode:insertion-mode">insertion mode</a>, the user agent must handle the
  token as follows:</p>

  <dl class="switch"><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="the-after-after-frameset-insertion-mode:insert-a-comment">Insert a comment</a> as the last child of the <code id="the-after-after-frameset-insertion-mode:document"><a href="#document">Document</a></code> object.</p>
   </dd><dt>A DOCTYPE token</dt><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
   FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dt>A start tag whose tag name is "html"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="the-after-after-frameset-insertion-mode:using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" id="the-after-after-frameset-insertion-mode:parsing-main-inbody">in body</a>" <a href="#insertion-mode" id="the-after-after-frameset-insertion-mode:insertion-mode-2">insertion mode</a>.</p>
   </dd><dt>An end-of-file token</dt><dd>
    <p><a href="#stop-parsing" id="the-after-after-frameset-insertion-mode:stop-parsing">Stop parsing</a>.</p>
   </dd><dt>A start tag whose tag name is "noframes"</dt><dd>
    <p>Process the token <a href="#using-the-rules-for" id="the-after-after-frameset-insertion-mode:using-the-rules-for-2">using the rules for</a> the "<a href="#parsing-main-inhead" id="the-after-after-frameset-insertion-mode:parsing-main-inhead">in head</a>" <a href="#insertion-mode" id="the-after-after-frameset-insertion-mode:insertion-mode-3">insertion mode</a>.</p>
   </dd><dt>Anything else</dt><dd>
    <p><a href="#parse-errors" id="the-after-after-frameset-insertion-mode:parse-errors">Parse error</a>. Ignore the token.</p>
   </dd></dl>
  </div>



  <h5 id="parsing-main-inforeign"><span class="secno">13.2.6.5</span> The rules for parsing tokens <dfn>in foreign content</dfn><a href="#parsing-main-inforeign" class="self-link"></a></h5>

  <div data-algorithm="">
  <p>When the user agent is to apply the rules for parsing tokens in foreign content, the user agent
  must handle the token as follows:</p>

  <dl class="switch"><dt>A character token that is U+0000 NULL</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inforeign:parse-errors">Parse error</a>. <a href="#insert-a-character" id="parsing-main-inforeign:insert-a-character">Insert a U+FFFD REPLACEMENT
    CHARACTER character</a>.</p>
   </dd><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
   FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt><dd>
    <p><a href="#insert-a-character" id="parsing-main-inforeign:insert-a-character-2">Insert the token's character</a>.</p>
   </dd><dt>Any other character token</dt><dd>
    <p><a href="#insert-a-character" id="parsing-main-inforeign:insert-a-character-3">Insert the token's character</a>.</p>

    <p>Set the <a href="#frameset-ok-flag" id="parsing-main-inforeign:frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
   </dd><dt>A comment token</dt><dd>
    <p><a href="#insert-a-comment" id="parsing-main-inforeign:insert-a-comment">Insert a comment</a>.</p>
   </dd><dt>A DOCTYPE token</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inforeign:parse-errors-2">Parse error</a>. Ignore the token.</p>
   </dd><dt>A start tag whose tag name is one of:  "b", "big", "blockquote", "body", "br", "center", "code", "dd", "div", "dl", "dt", "em", "embed", "h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "i", "img",
   "li", "listing",
   "menu", "meta", "nobr", "ol", "p", "pre", "ruby", "s",  "small", "span", "strong", "strike",  "sub",
   "sup", "table", "tt", "u", "ul", "var"</dt><dt>A start tag whose tag name is "font", if the token has any attributes named "color", "face",
   or "size"</dt><dt>An end tag whose tag name is "br", "p"</dt><dd>
    <p><a href="#parse-errors" id="parsing-main-inforeign:parse-errors-3">Parse error</a>.</p>

    <p>While the <a href="#current-node" id="parsing-main-inforeign:current-node">current node</a> is not a <a href="#mathml-text-integration-point" id="parsing-main-inforeign:mathml-text-integration-point">MathML text integration point</a>, an
    <a href="#html-integration-point" id="parsing-main-inforeign:html-integration-point">HTML integration point</a>, or an element in the <a id="parsing-main-inforeign:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, pop
    elements from the <a href="#stack-of-open-elements" id="parsing-main-inforeign:stack-of-open-elements">stack of open elements</a>.</p>

    <p>Reprocess the token according to the rules given in the section corresponding to the current
    <a href="#insertion-mode" id="parsing-main-inforeign:insertion-mode">insertion mode</a> in HTML content.</p>
   </dd><dt>Any other start tag</dt><dd>
    <p>If the <a href="#adjusted-current-node" id="parsing-main-inforeign:adjusted-current-node">adjusted current node</a> is an element in the <a id="parsing-main-inforeign:mathml-namespace" href="https://infra.spec.whatwg.org/#mathml-namespace" data-x-internal="mathml-namespace">MathML namespace</a>,
    <a href="#adjust-mathml-attributes" id="parsing-main-inforeign:adjust-mathml-attributes">adjust MathML attributes</a> for the token. (This fixes the case of MathML attributes
    that are not all lowercase.)</p>

    <p>If the <a href="#adjusted-current-node" id="parsing-main-inforeign:adjusted-current-node-2">adjusted current node</a> is an element in the <a id="parsing-main-inforeign:svg-namespace" href="https://infra.spec.whatwg.org/#svg-namespace" data-x-internal="svg-namespace">SVG namespace</a>, and the
    token's tag name is one of the ones in the first column of the following table, change the tag
    name to the name given in the corresponding cell in the second column. (This fixes the case of
    SVG elements that are not all lowercase.)</p>

    <table><thead><tr><th> Tag name </th><th> Element name
     </th></tr></thead><tbody><tr><td> <code>altglyph</code> </td><td> <code>altGlyph</code>
      </td></tr><tr><td> <code>altglyphdef</code> </td><td> <code>altGlyphDef</code>
      </td></tr><tr><td> <code>altglyphitem</code> </td><td> <code>altGlyphItem</code>
      </td></tr><tr><td> <code>animatecolor</code> </td><td> <code>animateColor</code>
      </td></tr><tr><td> <code>animatemotion</code> </td><td> <code>animateMotion</code>
      </td></tr><tr><td> <code>animatetransform</code> </td><td> <code>animateTransform</code>
      </td></tr><tr><td> <code>clippath</code> </td><td> <code>clipPath</code>
      </td></tr><tr><td> <code>feblend</code> </td><td> <code>feBlend</code>
      </td></tr><tr><td> <code>fecolormatrix</code> </td><td> <code>feColorMatrix</code>
      </td></tr><tr><td> <code>fecomponenttransfer</code> </td><td> <code>feComponentTransfer</code>
      </td></tr><tr><td> <code>fecomposite</code> </td><td> <code>feComposite</code>
      </td></tr><tr><td> <code>feconvolvematrix</code> </td><td> <code>feConvolveMatrix</code>
      </td></tr><tr><td> <code>fediffuselighting</code> </td><td> <code>feDiffuseLighting</code>
      </td></tr><tr><td> <code>fedisplacementmap</code> </td><td> <code>feDisplacementMap</code>
      </td></tr><tr><td> <code>fedistantlight</code> </td><td> <code>feDistantLight</code>
      </td></tr><tr><td> <code>fedropshadow</code> </td><td> <code>feDropShadow</code>
      </td></tr><tr><td> <code>feflood</code> </td><td> <code>feFlood</code>
      </td></tr><tr><td> <code>fefunca</code> </td><td> <code>feFuncA</code>
      </td></tr><tr><td> <code>fefuncb</code> </td><td> <code>feFuncB</code>
      </td></tr><tr><td> <code>fefuncg</code> </td><td> <code>feFuncG</code>
      </td></tr><tr><td> <code>fefuncr</code> </td><td> <code>feFuncR</code>
      </td></tr><tr><td> <code>fegaussianblur</code> </td><td> <code>feGaussianBlur</code>
      </td></tr><tr><td> <code>feimage</code> </td><td> <code>feImage</code>
      </td></tr><tr><td> <code>femerge</code> </td><td> <code>feMerge</code>
      </td></tr><tr><td> <code>femergenode</code> </td><td> <code>feMergeNode</code>
      </td></tr><tr><td> <code>femorphology</code> </td><td> <code>feMorphology</code>
      </td></tr><tr><td> <code>feoffset</code> </td><td> <code>feOffset</code>
      </td></tr><tr><td> <code>fepointlight</code> </td><td> <code>fePointLight</code>
      </td></tr><tr><td> <code>fespecularlighting</code> </td><td> <code>feSpecularLighting</code>
      </td></tr><tr><td> <code>fespotlight</code> </td><td> <code>feSpotLight</code>
      </td></tr><tr><td> <code>fetile</code> </td><td> <code>feTile</code>
      </td></tr><tr><td> <code>feturbulence</code> </td><td> <code>feTurbulence</code>
      </td></tr><tr><td> <code>foreignobject</code> </td><td> <code>foreignObject</code>
      </td></tr><tr><td> <code>glyphref</code> </td><td> <code>glyphRef</code>
      </td></tr><tr><td> <code>lineargradient</code> </td><td> <code>linearGradient</code>
      </td></tr><tr><td> <code>radialgradient</code> </td><td> <code>radialGradient</code>
      
      </td></tr><tr><td> <code>textpath</code> </td><td> <code>textPath</code>
    </td></tr></tbody></table>

    <p>If the <a href="#adjusted-current-node" id="parsing-main-inforeign:adjusted-current-node-3">adjusted current node</a> is an element in the <a id="parsing-main-inforeign:svg-namespace-2" href="https://infra.spec.whatwg.org/#svg-namespace" data-x-internal="svg-namespace">SVG namespace</a>,
    <a href="#adjust-svg-attributes" id="parsing-main-inforeign:adjust-svg-attributes">adjust SVG attributes</a> for the token. (This fixes the case of SVG attributes that
    are not all lowercase.)</p>

    <p><a href="#adjust-foreign-attributes" id="parsing-main-inforeign:adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This fixes the use of namespaced
    attributes, in particular XLink in SVG.)</p>

    <p><a href="#insert-a-foreign-element" id="parsing-main-inforeign:insert-a-foreign-element">Insert a foreign element</a> for the token, with the <a href="#adjusted-current-node" id="parsing-main-inforeign:adjusted-current-node-4">adjusted current
    node</a>'s namespace and false.</p>

    <p>If the token has its <i id="parsing-main-inforeign:self-closing-flag"><a href="#self-closing-flag">self-closing flag</a></i> set, then run the appropriate steps from the
    following list:</p>

    <dl class="switch"><dt>If the token's tag name is "script", and the new <a href="#current-node" id="parsing-main-inforeign:current-node-2">current node</a> is in the <a id="parsing-main-inforeign:svg-namespace-3" href="https://infra.spec.whatwg.org/#svg-namespace" data-x-internal="svg-namespace">SVG namespace</a></dt><dd>
      <p><a href="#acknowledge-self-closing-flag" id="parsing-main-inforeign:acknowledge-self-closing-flag">Acknowledge the token's <i>self-closing
      flag</i></a>, and then act as described in the steps for a "script" end tag below.</p>
     </dd><dt>Otherwise</dt><dd>
      <p>Pop the <a href="#current-node" id="parsing-main-inforeign:current-node-3">current node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inforeign:stack-of-open-elements-2">stack of open elements</a> and <a href="#acknowledge-self-closing-flag" id="parsing-main-inforeign:acknowledge-self-closing-flag-2">acknowledge the token's <i>self-closing
      flag</i></a>.</p>
     </dd></dl>
   </dd><dt id="scriptForeignEndTag">An end tag whose tag name is "script", if the <a href="#current-node" id="parsing-main-inforeign:current-node-4">current
   node</a> is an <a id="parsing-main-inforeign:svg-script" href="https://svgwg.org/svg2-draft/interact.html#ScriptElement" data-x-internal="svg-script">SVG <code>script</code></a> element</dt><dd>
    <p>Pop the <a href="#current-node" id="parsing-main-inforeign:current-node-5">current node</a> off the <a href="#stack-of-open-elements" id="parsing-main-inforeign:stack-of-open-elements-3">stack of open elements</a>.</p>

    <p>Let the <var>old insertion point</var> have the same value as the current
    <a href="#insertion-point" id="parsing-main-inforeign:insertion-point">insertion point</a>. Let the <a href="#insertion-point" id="parsing-main-inforeign:insertion-point-2">insertion point</a> be just before the <a href="#next-input-character" id="parsing-main-inforeign:next-input-character">next
    input character</a>.</p>

    <p>Increment the parser's <a href="#script-nesting-level" id="parsing-main-inforeign:script-nesting-level">script nesting level</a> by one. Set the <a href="#parser-pause-flag" id="parsing-main-inforeign:parser-pause-flag">parser pause
    flag</a> to true.</p>

    <p>If the <a href="#active-speculative-html-parser" id="parsing-main-inforeign:active-speculative-html-parser">active speculative HTML parser</a> is null and the user agent supports SVG,
    then <a href="https://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process the
    SVG <code>script</code> element</a> according to the SVG rules. <a href="#refsSVG">[SVG]</a></p>

    <p class="note">Even if this causes <a href="#dom-document-write" id="parsing-main-inforeign:dom-document-write">new characters to be
    inserted into the tokenizer</a>, the parser will not be executed reentrantly, since the
    <a href="#parser-pause-flag" id="parsing-main-inforeign:parser-pause-flag-2">parser pause flag</a> is true.</p>

    <p>Decrement the parser's <a href="#script-nesting-level" id="parsing-main-inforeign:script-nesting-level-2">script nesting level</a> by one. If the parser's <a href="#script-nesting-level" id="parsing-main-inforeign:script-nesting-level-3">script
    nesting level</a> is zero, then set the <a href="#parser-pause-flag" id="parsing-main-inforeign:parser-pause-flag-3">parser pause flag</a> to false.</p>

    <p>Let the <a href="#insertion-point" id="parsing-main-inforeign:insertion-point-3">insertion point</a> have the value of the <var>old insertion
    point</var>. (In other words, restore the <a href="#insertion-point" id="parsing-main-inforeign:insertion-point-4">insertion point</a> to its previous value.
    This value might be the "undefined" value.)</p>
   </dd><dt>Any other end tag</dt><dd>
    <p>Run these steps:</p>

    <ol><li><p>Initialize <var>node</var> to be the <a href="#current-node" id="parsing-main-inforeign:current-node-6">current node</a> (the bottommost
     node of the stack).</p></li><li><p>If <var>node</var>'s tag name, <a id="parsing-main-inforeign:converted-to-ascii-lowercase" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>, is
     not the same as the tag name of the token, then this is a <a href="#parse-errors" id="parsing-main-inforeign:parse-errors-4">parse error</a>.</p></li><li><p><i>Loop</i>: If <var>node</var> is the topmost element in the <a href="#stack-of-open-elements" id="parsing-main-inforeign:stack-of-open-elements-4">stack of
     open elements</a>, then return. (<a href="#fragment-case" id="parsing-main-inforeign:fragment-case">fragment case</a>)</p></li><li><p>If <var>node</var>'s tag name, <a id="parsing-main-inforeign:converted-to-ascii-lowercase-2" href="https://infra.spec.whatwg.org/#ascii-lowercase" data-x-internal="converted-to-ascii-lowercase">converted to ASCII lowercase</a>, is
     the same as the tag name of the token, pop elements from the <a href="#stack-of-open-elements" id="parsing-main-inforeign:stack-of-open-elements-5">stack of open
     elements</a> until <var>node</var> has been popped from the stack, and then return.</p></li><li><p>Set <var>node</var> to the previous entry in the <a href="#stack-of-open-elements" id="parsing-main-inforeign:stack-of-open-elements-6">stack of open
     elements</a>.</p></li><li><p>If <var>node</var> is not an element in the <a id="parsing-main-inforeign:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, return
     to the step labeled <i>loop</i>.</p></li><li><p>Otherwise, process the token according to the rules given in the section corresponding
     to the current <a href="#insertion-mode" id="parsing-main-inforeign:insertion-mode-2">insertion mode</a> in HTML content.</p></li></ol>
   </dd></dl>
  </div>

  


  

  <h4 id="the-end"><span class="secno">13.2.7</span> The end<a href="#the-end" class="self-link"></a></h4>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event" title="The DOMContentLoaded event fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.">Document/DOMContentLoaded_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event" title="The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets, scripts, iframes, and images. This is in contrast to DOMContentLoaded, which is fired as soon as the page DOM has been loaded, without waiting for resources to finish loading.">Window/load_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>1.3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div><div data-algorithm="">
  <p>Once the user agent <dfn id="stop-parsing">stops parsing</dfn> the document, the user agent
  must run the following steps:</p>

  <ol><li><p>If the <a href="#active-speculative-html-parser" id="the-end:active-speculative-html-parser">active speculative HTML parser</a> is not null, then <a href="#stop-the-speculative-html-parser" id="the-end:stop-the-speculative-html-parser">stop the
   speculative HTML parser</a> and return.</p></li><li><p>Set the <a href="#insertion-point" id="the-end:insertion-point">insertion point</a> to undefined.</p></li><li><p><a href="#update-the-current-document-readiness" id="the-end:update-the-current-document-readiness">Update the current document readiness</a> to "<code>interactive</code>".</p></li><li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements" id="the-end:stack-of-open-elements">stack of open elements</a>.</p></li><li><p>While the <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing" id="the-end:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the document has finished
   parsing</a> is not empty:</p>

    <ol><li><p><a href="#spin-the-event-loop" id="the-end:spin-the-event-loop">Spin the event loop</a> until the first <code id="the-end:the-script-element"><a href="#the-script-element">script</a></code> in the <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing" id="the-end:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing-2">list
     of scripts that will execute when the document has finished parsing</a> has its <a href="#ready-to-be-parser-executed" id="the-end:ready-to-be-parser-executed">ready
     to be parser-executed</a> set to true <em>and</em> the parser's <code id="the-end:document"><a href="#document">Document</a></code>
     <a href="#has-no-style-sheet-that-is-blocking-scripts" id="the-end:has-no-style-sheet-that-is-blocking-scripts">has no style sheet that is blocking scripts</a>.</p></li><li><p><a href="#execute-the-script-element" id="the-end:execute-the-script-element">Execute the script element</a> given by the first <code id="the-end:the-script-element-2"><a href="#the-script-element">script</a></code> in
     the <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing" id="the-end:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing-3">list of scripts that will execute when the document has finished
     parsing</a>.</p></li><li><p>Remove the first <code id="the-end:the-script-element-3"><a href="#the-script-element">script</a></code> element from the <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing" id="the-end:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing-4">list of scripts that will
     execute when the document has finished parsing</a> (i.e. shift out the first entry in the
     list).</p></li></ol>
   </li><li>
    <p><a href="#queue-a-global-task" id="the-end:queue-a-global-task">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="the-end:dom-manipulation-task-source">DOM manipulation task source</a> given the
    <code id="the-end:document-2"><a href="#document">Document</a></code>'s <a href="#concept-relevant-global" id="the-end:concept-relevant-global">relevant global object</a> to run the following substeps:</p>

    <ol><li><p>Set the <code id="the-end:document-3"><a href="#document">Document</a></code>'s <a href="#load-timing-info" id="the-end:load-timing-info">load timing info</a>'s <a href="#dom-content-loaded-event-start-time" id="the-end:dom-content-loaded-event-start-time">DOM content loaded
     event start time</a> to the <a id="the-end:current-high-resolution-time" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given the
     <code id="the-end:document-4"><a href="#document">Document</a></code>'s <a href="#concept-relevant-global" id="the-end:concept-relevant-global-2">relevant global object</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-end:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-end:event-domcontentloaded"><a href="#event-domcontentloaded">DOMContentLoaded</a></code> at the <code id="the-end:document-5"><a href="#document">Document</a></code>
     object, with its <code id="the-end:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to
     true.</p></li><li><p>Set the <code id="the-end:document-6"><a href="#document">Document</a></code>'s <a href="#load-timing-info" id="the-end:load-timing-info-2">load timing info</a>'s <a href="#dom-content-loaded-event-end-time" id="the-end:dom-content-loaded-event-end-time">DOM content loaded
     event end time</a> to the <a id="the-end:current-high-resolution-time-2" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given the
     <code id="the-end:document-7"><a href="#document">Document</a></code>'s <a href="#concept-relevant-global" id="the-end:concept-relevant-global-3">relevant global object</a>.</p></li><li><p>Enable the <a href="https://w3c.github.io/ServiceWorker/#dfn-client-message-queue" id="the-end:dfn-client-message-queue" data-x-internal="dfn-client-message-queue">client message queue</a> of the
     <code id="the-end:serviceworkercontainer"><a data-x-internal="serviceworkercontainer" href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer">ServiceWorkerContainer</a></code> object whose associated <a href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client" id="the-end:serviceworkercontainer-service-worker-client" data-x-internal="serviceworkercontainer-service-worker-client">service worker client</a> is the
     <code id="the-end:document-8"><a href="#document">Document</a></code> object's <a href="#relevant-settings-object" id="the-end:relevant-settings-object">relevant settings object</a>.</p></li><li><p>Invoke <a id="the-end:webdriver-bidi-dom-content-loaded" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-dom-content-loaded" data-x-internal="webdriver-bidi-dom-content-loaded">WebDriver BiDi DOM content loaded</a> with the <code id="the-end:document-9"><a href="#document">Document</a></code>'s
     <a href="#concept-document-bc" id="the-end:concept-document-bc">browsing context</a>, and a new <a id="the-end:webdriver-bidi-navigation-status" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi
     navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="the-end:navigation-status-id" data-x-internal="navigation-status-id">id</a> is the
     <code id="the-end:document-10"><a href="#document">Document</a></code> object's <a href="#concept-document-navigation-id" id="the-end:concept-document-navigation-id">during-loading
     navigation ID for WebDriver BiDi</a>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="the-end:navigation-status-status" data-x-internal="navigation-status-status">status</a>
     is "<code id="the-end:navigation-status-pending"><a data-x-internal="navigation-status-pending" href="https://w3c.github.io/webdriver-bidi/#navigation-status-pending">pending</a></code>", and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="the-end:navigation-status-url" data-x-internal="navigation-status-url">url</a> is the <code id="the-end:document-11"><a href="#document">Document</a></code> object's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-end:the-document's-address" data-x-internal="the-document's-address">URL</a>.</p></li></ol>
   </li><li><p><a href="#spin-the-event-loop" id="the-end:spin-the-event-loop-2">Spin the event loop</a> until the <a href="#set-of-scripts-that-will-execute-as-soon-as-possible" id="the-end:set-of-scripts-that-will-execute-as-soon-as-possible">set of scripts that will execute as soon
   as possible</a> and the <a href="#list-of-scripts-that-will-execute-in-order-as-soon-as-possible" id="the-end:list-of-scripts-that-will-execute-in-order-as-soon-as-possible">list of scripts that will execute in order as soon as
   possible</a> are empty.</p></li><li><p><a href="#spin-the-event-loop" id="the-end:spin-the-event-loop-3">Spin the event loop</a> until there is nothing that <dfn id="delay-the-load-event">delays the load event</dfn> in the <code id="the-end:document-12"><a href="#document">Document</a></code>.</p></li><li>
    <p><a href="#queue-a-global-task" id="the-end:queue-a-global-task-2">Queue a global task</a> on the <a href="#dom-manipulation-task-source" id="the-end:dom-manipulation-task-source-2">DOM manipulation task source</a> given the
    <code id="the-end:document-13"><a href="#document">Document</a></code>'s <a href="#concept-relevant-global" id="the-end:concept-relevant-global-4">relevant global object</a> to run the following steps:</p>

    <ol><li><p><a href="#update-the-current-document-readiness" id="the-end:update-the-current-document-readiness-2">Update the current document readiness</a> to "<code>complete</code>".</p></li><li><p>If the <code id="the-end:document-14"><a href="#document">Document</a></code> object's <a href="#concept-document-bc" id="the-end:concept-document-bc-2">browsing
     context</a> is null, then abort these steps.</p></li><li><p>Let <var>window</var> be the <code id="the-end:document-15"><a href="#document">Document</a></code>'s <a href="#concept-relevant-global" id="the-end:concept-relevant-global-5">relevant global
     object</a>.</p></li><li><p>Set the <code id="the-end:document-16"><a href="#document">Document</a></code>'s <a href="#load-timing-info" id="the-end:load-timing-info-3">load timing info</a>'s <a href="#load-event-start-time" id="the-end:load-event-start-time">load event start
     time</a> to the <a id="the-end:current-high-resolution-time-3" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given <var>window</var>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-end:concept-event-fire-2" data-x-internal="concept-event-fire">Fire an event</a> named <code id="the-end:event-load"><a href="#event-load">load</a></code> at <var>window</var>, with <i>legacy target override
     flag</i> set.</p></li><li><p>Invoke <a id="the-end:webdriver-bidi-load-complete" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-load-complete" data-x-internal="webdriver-bidi-load-complete">WebDriver BiDi load complete</a> with the <code id="the-end:document-17"><a href="#document">Document</a></code>'s <a href="#concept-document-bc" id="the-end:concept-document-bc-3">browsing context</a>, and a new <a id="the-end:webdriver-bidi-navigation-status-2" href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-status" data-x-internal="webdriver-bidi-navigation-status">WebDriver BiDi
     navigation status</a> whose <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-id" id="the-end:navigation-status-id-2" data-x-internal="navigation-status-id">id</a> is the
     <code id="the-end:document-18"><a href="#document">Document</a></code> object's <a href="#concept-document-navigation-id" id="the-end:concept-document-navigation-id-2">during-loading
     navigation ID for WebDriver BiDi</a>, <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-status" id="the-end:navigation-status-status-2" data-x-internal="navigation-status-status">status</a>
     is "<code id="the-end:navigation-status-complete"><a data-x-internal="navigation-status-complete" href="https://w3c.github.io/webdriver-bidi/#navigation-status-complete">complete</a></code>", and <a href="https://w3c.github.io/webdriver-bidi/#navigation-status-url" id="the-end:navigation-status-url-2" data-x-internal="navigation-status-url">url</a> is the <code id="the-end:document-19"><a href="#document">Document</a></code> object's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="the-end:the-document's-address-2" data-x-internal="the-document's-address">URL</a>.</p></li><li><p>Set the <code id="the-end:document-20"><a href="#document">Document</a></code> object's <a href="#concept-document-navigation-id" id="the-end:concept-document-navigation-id-3">during-loading navigation ID for WebDriver BiDi</a>
     to null.</p></li><li><p>Set the <code id="the-end:document-21"><a href="#document">Document</a></code>'s <a href="#load-timing-info" id="the-end:load-timing-info-4">load timing info</a>'s <a href="#load-event-end-time" id="the-end:load-event-end-time">load event end
     time</a> to the <a id="the-end:current-high-resolution-time-4" href="https://w3c.github.io/hr-time/#dfn-current-high-resolution-time" data-x-internal="current-high-resolution-time">current high resolution time</a> given <var>window</var>.</p></li><li><p><a id="the-end:assert" href="https://infra.spec.whatwg.org/#assert" data-x-internal="assert">Assert</a>: <code id="the-end:document-22"><a href="#document">Document</a></code>'s <a href="#page-showing" id="the-end:page-showing">page showing</a> is
     false.</p></li><li><p>Set the <code id="the-end:document-23"><a href="#document">Document</a></code>'s <a href="#page-showing" id="the-end:page-showing-2">page showing</a> to true.</p></li><li><p><a href="#fire-a-page-transition-event" id="the-end:fire-a-page-transition-event">Fire a page transition event</a> named <code id="the-end:event-pageshow"><a href="#event-pageshow">pageshow</a></code> at <var>window</var> with false.</p></li><li><p><a href="#completely-finish-loading" id="the-end:completely-finish-loading">Completely finish loading</a> the <code id="the-end:document-24"><a href="#document">Document</a></code>.</p></li><li><p><a id="the-end:queue-the-navigation-timing-entry" href="https://w3c.github.io/navigation-timing/#dfn-queue-the-navigation-timing-entry" data-x-internal="queue-the-navigation-timing-entry">Queue the navigation timing entry</a> for the <code id="the-end:document-25"><a href="#document">Document</a></code>.</p></li></ol>
   </li><li><p>If the <code id="the-end:document-26"><a href="#document">Document</a></code>'s <a href="#print-when-loaded" id="the-end:print-when-loaded">print when loaded</a> flag is set, then run the
   <a href="#printing-steps" id="the-end:printing-steps">printing steps</a>.</p></li><li><p>The <code id="the-end:document-27"><a href="#document">Document</a></code> is now <dfn id="ready-for-post-load-tasks">ready for post-load tasks</dfn>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the user agent is to <dfn id="abort-a-parser">abort a parser</dfn>, it must run the following steps:</p>

  <ol><li><p>Throw away any pending content in the <a href="#input-stream" id="the-end:input-stream">input stream</a>, and discard any future
   content that would have been added to it.</p></li><li><p><a href="#stop-the-speculative-html-parser" id="the-end:stop-the-speculative-html-parser-2">Stop the speculative HTML parser</a> for this HTML parser.</p></li><li><p><a href="#update-the-current-document-readiness" id="the-end:update-the-current-document-readiness-3">Update the current document readiness</a> to "<code>interactive</code>".</p></li><li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements" id="the-end:stack-of-open-elements-2">stack of open elements</a>.</p></li><li><p><a href="#update-the-current-document-readiness" id="the-end:update-the-current-document-readiness-4">Update the current document readiness</a> to "<code>complete</code>".</p></li></ol>
  </div>

  


  

  <h4 id="speculative-html-parsing"><span class="secno">13.2.8</span> Speculative HTML parsing<a href="#speculative-html-parsing" class="self-link"></a></h4>

  <p>User agents may implement an optimization, as described in this section, to speculatively fetch
  resources that are declared in the HTML markup while the HTML parser is waiting for a
  <a href="#pending-parsing-blocking-script" id="speculative-html-parsing:pending-parsing-blocking-script">pending parsing-blocking script</a> to be fetched and executed, or during normal parsing,
  at the time <a href="#create-an-element-for-the-token" id="speculative-html-parsing:create-an-element-for-the-token">an element is created for a token</a>.
  While this optimization is not defined in precise detail, there are some rules to consider for
  interoperability.</p>

  <p>Each <a href="#html-parser" id="speculative-html-parsing:html-parser">HTML parser</a> can have an <dfn id="active-speculative-html-parser" data-export="">active speculative HTML parser</dfn>. It
  is initially null.</p>

  <p>The <dfn id="speculative-html-parser" data-export="">speculative HTML parser</dfn> must act like the normal HTML parser (e.g., the
  tree builder rules apply), with some exceptions:</p>

  <ul><li>
    <p>The state of the normal HTML parser and the document itself must not be affected.</p>

    <p class="example">For example, the <a href="#next-input-character" id="speculative-html-parsing:next-input-character">next input character</a> or the <a href="#stack-of-open-elements" id="speculative-html-parsing:stack-of-open-elements">stack of open
    elements</a> for the normal HTML parser is not affected by the <a href="#speculative-html-parser" id="speculative-html-parsing:speculative-html-parser">speculative HTML
    parser</a>.</p>
   </li><li>
    <p>Bytes pushed into the HTML parser's <a href="#the-input-byte-stream" id="speculative-html-parsing:the-input-byte-stream">input byte stream</a> must also be pushed into
    the speculative HTML parser's <a href="#the-input-byte-stream" id="speculative-html-parsing:the-input-byte-stream-2">input byte stream</a>. Bytes read from the streams must
    be independent.</p>
   </li><li>
    <p>The result of the speculative parsing is primarily a series of <a href="#speculative-fetch" id="speculative-html-parsing:speculative-fetch">speculative fetches</a>. Which kinds of resources to speculatively fetch is
    <a id="speculative-html-parsing:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>, but user agents must not speculatively fetch resources that
    would not be fetched with the normal HTML parser, under the assumption that the script that is
    blocking the HTML parser does nothing.</p>

    <p class="note">It is possible that the same markup is seen multiple times from the
    <a href="#speculative-html-parser" id="speculative-html-parsing:speculative-html-parser-2">speculative HTML parser</a> and then the normal HTML parser. It is expected that
    duplicated fetches will be prevented by caching rules, which are not yet fully specified.</p>
   </li></ul>

  <div data-algorithm="">
  <p>A <dfn id="speculative-fetch">speculative fetch</dfn> for a <a href="#speculative-mock-element" id="speculative-html-parsing:speculative-mock-element">speculative mock element</a> <var>element</var>
  must follow these rules:</p>

  <p class="XXX">Should some of these things be applied to the document "for real", even
  though they are found speculatively?</p>

  <ul><li>
    <p>If the <a href="#speculative-html-parser" id="speculative-html-parsing:speculative-html-parser-3">speculative HTML parser</a> encounters one of the following elements, then
    act as if that element is processed for the purpose of its effect of subsequent speculative
    fetches.</p>

    <ul class="brief"><li>A <code id="speculative-html-parsing:the-base-element"><a href="#the-base-element">base</a></code> element.</li><li>A <code id="speculative-html-parsing:the-meta-element"><a href="#the-meta-element">meta</a></code> element whose <code id="speculative-html-parsing:attr-meta-http-equiv"><a href="#attr-meta-http-equiv">http-equiv</a></code>
     attribute is in the <a href="#attr-meta-http-equiv-content-security-policy" id="speculative-html-parsing:attr-meta-http-equiv-content-security-policy">Content
     security policy</a> state.</li><li>A <code id="speculative-html-parsing:the-meta-element-2"><a href="#the-meta-element">meta</a></code> element whose <code id="speculative-html-parsing:attr-meta-name"><a href="#attr-meta-name">name</a></code> attribute is an
     <a id="speculative-html-parsing:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code id="speculative-html-parsing:meta-referrer"><a href="#meta-referrer">referrer</a></code>".</li><li>A <code id="speculative-html-parsing:the-meta-element-3"><a href="#the-meta-element">meta</a></code> element whose <code id="speculative-html-parsing:attr-meta-name-2"><a href="#attr-meta-name">name</a></code> attribute is an
     <a id="speculative-html-parsing:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>viewport</code>". (This can
     affect whether a media query list <a href="#matches-the-environment" id="speculative-html-parsing:matches-the-environment">matches the environment</a>.) <a href="#refsCSSDEVICEADAPT">[CSSDEVICEADAPT]</a></li></ul>
   </li><li><p>Let <var>url</var> be the <a id="speculative-html-parsing:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> that <var>element</var> would fetch if it was
   processed normally. If there is no such <a id="speculative-html-parsing:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> or if it is the empty string, then do
   nothing. Otherwise, if <a id="speculative-html-parsing:url-3" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">url</a> is already in the <a href="#list-of-speculative-fetch-urls" id="speculative-html-parsing:list-of-speculative-fetch-urls">list of speculative fetch
   URLs</a>, then do nothing. Otherwise, fetch <a id="speculative-html-parsing:url-4" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">url</a> as if the element was processed
   normally, and add <var>url</var> to the <a href="#list-of-speculative-fetch-urls" id="speculative-html-parsing:list-of-speculative-fetch-urls-2">list of speculative fetch URLs</a>.</p></li></ul>
  </div>

  <p>Each <code id="speculative-html-parsing:document"><a href="#document">Document</a></code> has a <dfn id="list-of-speculative-fetch-urls">list of speculative fetch URLs</dfn>, which is a
  <a id="speculative-html-parsing:list" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> of <a href="https://url.spec.whatwg.org/#concept-url" id="speculative-html-parsing:url-5" data-x-internal="url">URLs</a>, initially empty.</p>

  <div data-algorithm="">
  <p>To <dfn id="start-the-speculative-html-parser">start the speculative HTML parser</dfn> for an instance of an HTML parser
  <var>parser</var>:</p>

  <ol><li>
    <p>Optionally, return.</p>

    <p class="note">This step allows user agents to opt out of speculative HTML parsing.</p>
   </li><li>
    <p>If <var>parser</var>'s <a href="#active-speculative-html-parser" id="speculative-html-parsing:active-speculative-html-parser">active speculative HTML parser</a> is not null, then
    <a href="#stop-the-speculative-html-parser" id="speculative-html-parsing:stop-the-speculative-html-parser">stop the speculative HTML parser</a> for <var>parser</var>.</p>

    <p class="note">This can happen when <code id="speculative-html-parsing:dom-document-write"><a href="#dom-document-write">document.write()</a></code>
    writes another parser-blocking script. For simplicity, this specification always restarts
    speculative parsing, but user agents can implement a more efficient strategy, so long as the end
    result is equivalent.</p>
   </li><li><p>Let <var>speculativeParser</var> be a new <a href="#speculative-html-parser" id="speculative-html-parsing:speculative-html-parser-4">speculative HTML parser</a>, with the
   same state as <var>parser</var>.</p></li><li><p>Let <var>speculativeDoc</var> be a new isomorphic representation of <var>parser</var>'s
   <code id="speculative-html-parsing:document-2"><a href="#document">Document</a></code>, where all elements are instead <a href="#speculative-mock-element" id="speculative-html-parsing:speculative-mock-element-2">speculative mock elements</a>. Let <var>speculativeParser</var> parse into
   <var>speculativeDoc</var>.</p></li><li><p>Set <var>parser</var>'s <a href="#active-speculative-html-parser" id="speculative-html-parsing:active-speculative-html-parser-2">active speculative HTML parser</a> to
   <var>speculativeParser</var>.</p></li><li><p><a href="#in-parallel" id="speculative-html-parsing:in-parallel">In parallel</a>, run <var>speculativeParser</var> until it is stopped or until it
   reaches the end of its <a href="#input-stream" id="speculative-html-parsing:input-stream">input stream</a>.</p></li></ol>
  </div>


  <div data-algorithm="">
  <p>To <dfn id="stop-the-speculative-html-parser">stop the speculative HTML parser</dfn> for an instance of an HTML parser
  <var>parser</var>:</p>

  <ol><li><p>Let <var>speculativeParser</var> be <var>parser</var>'s <a href="#active-speculative-html-parser" id="speculative-html-parsing:active-speculative-html-parser-3">active speculative HTML
   parser</a>.</p></li><li><p>If <var>speculativeParser</var> is null, then return.</p></li><li><p>Throw away any pending content in <var>speculativeParser</var>'s <a href="#input-stream" id="speculative-html-parsing:input-stream-2">input
   stream</a>, and discard any future content that would have been added to it.</p></li><li><p>Set <var>parser</var>'s <a href="#active-speculative-html-parser" id="speculative-html-parsing:active-speculative-html-parser-4">active speculative HTML parser</a> to null.</p></li></ol>
  </div>

  <p>The <a href="#speculative-html-parser" id="speculative-html-parsing:speculative-html-parser-5">speculative HTML parser</a> will create <a href="#speculative-mock-element" id="speculative-html-parsing:speculative-mock-element-3">speculative mock elements</a> instead of normal elements. DOM
  operations that the tree builder normally does on elements are expected to work appropriately on
  speculative mock elements.</p>

  <p>A <dfn id="speculative-mock-element">speculative mock element</dfn> is a <a id="speculative-html-parsing:struct" href="https://infra.spec.whatwg.org/#struct" data-x-internal="struct">struct</a> with the following <a href="https://infra.spec.whatwg.org/#struct-item" id="speculative-html-parsing:struct-item" data-x-internal="struct-item">items</a>:</p>

  <ul><li><p>A <a id="speculative-html-parsing:string" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <dfn id="concept-mock-namespace">namespace</dfn>, corresponding
   to an element's <a href="https://dom.spec.whatwg.org/#concept-element-namespace" id="speculative-html-parsing:concept-element-namespace" data-x-internal="concept-element-namespace">namespace</a>.</p></li><li><p>A <a id="speculative-html-parsing:string-2" href="https://infra.spec.whatwg.org/#string" data-x-internal="string">string</a> <dfn id="concept-mock-local-name">local name</dfn>,
   corresponding to an element's <a href="https://dom.spec.whatwg.org/#concept-element-local-name" id="speculative-html-parsing:concept-element-local-name" data-x-internal="concept-element-local-name">local
   name</a>.</p></li><li><p>A <a id="speculative-html-parsing:list-2" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> <dfn id="concept-mock-attribute-list">attribute list</dfn>,
   corresponding to an element's <a id="speculative-html-parsing:attribute-list" href="https://dom.spec.whatwg.org/#concept-element-attribute" data-x-internal="attribute-list">attribute list</a>.</p></li><li><p>A <a id="speculative-html-parsing:list-3" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a> <dfn id="concept-mock-children">children</dfn>, corresponding to
   an element's <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="speculative-html-parsing:concept-tree-child" data-x-internal="concept-tree-child">children</a>.</p></li></ul>

  <div data-algorithm="">
  <p>To <dfn id="create-a-speculative-mock-element">create a speculative mock element</dfn> given a <var>namespace</var>,
  <var>tagName</var>, and <var>attributes</var>:</p>

  <ol><li><p>Let <var>element</var> be a new <a href="#speculative-mock-element" id="speculative-html-parsing:speculative-mock-element-4">speculative mock element</a>.</p></li><li><p>Set <var>element</var>'s <a href="#concept-mock-namespace" id="speculative-html-parsing:concept-mock-namespace">namespace</a> to
   <var>namespace</var>.</p></li><li><p>Set <var>element</var>'s <a href="#concept-mock-local-name" id="speculative-html-parsing:concept-mock-local-name">local name</a> to
   <var>tagName</var>.</p></li><li><p>Set <var>element</var>'s <a href="#concept-mock-attribute-list" id="speculative-html-parsing:concept-mock-attribute-list">attribute list</a>
   to <var>attributes</var>.</p></li><li><p>Set <var>element</var>'s <a href="#concept-mock-children" id="speculative-html-parsing:concept-mock-children">children</a> to a new
   empty <a id="speculative-html-parsing:list-4" href="https://infra.spec.whatwg.org/#list" data-x-internal="list">list</a>.</p></li><li><p>Optionally, perform a <a href="#speculative-fetch" id="speculative-html-parsing:speculative-fetch-2">speculative fetch</a> for <var>element</var>.</p></li><li><p>Return <var>element</var>.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>When the tree builder says to insert an element into a <code id="speculative-html-parsing:the-template-element"><a href="#the-template-element">template</a></code> element's
  <a href="#template-contents" id="speculative-html-parsing:template-contents">template contents</a>, if that is a <a href="#speculative-mock-element" id="speculative-html-parsing:speculative-mock-element-5">speculative mock element</a>, and the
  <code id="speculative-html-parsing:the-template-element-2"><a href="#the-template-element">template</a></code> element's <a href="#template-contents" id="speculative-html-parsing:template-contents-2">template contents</a> is not a
  <code id="speculative-html-parsing:shadowroot"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code> node, instead do nothing. URLs found speculatively inside
  non-declarative-shadow-root <code id="speculative-html-parsing:the-template-element-3"><a href="#the-template-element">template</a></code> elements might themselves be templates, and must
  not be speculatively fetched.</p>
  </div>

  


  

  <h4 id="coercing-an-html-dom-into-an-infoset"><span class="secno">13.2.9</span> Coercing an HTML DOM into an infoset<a href="#coercing-an-html-dom-into-an-infoset" class="self-link"></a></h4>

  <p>When an application uses an <a href="#html-parser" id="coercing-an-html-dom-into-an-infoset:html-parser">HTML parser</a> in conjunction with an XML pipeline, it is
  possible that the constructed DOM is not compatible with the XML tool chain in certain subtle
  ways. For example, an XML toolchain might not be able to represent attributes with the name <code>xmlns</code>, since they conflict with the Namespaces in XML syntax. There is also some
  data that the <a href="#html-parser" id="coercing-an-html-dom-into-an-infoset:html-parser-2">HTML parser</a> generates that isn't included in the DOM itself. This
  section specifies some rules for handling these issues.</p>

  <p>If the XML API being used doesn't support DOCTYPEs, the tool may drop DOCTYPEs altogether.</p>

  <p>If the XML API doesn't support attributes in no namespace that are named "<code>xmlns</code>", attributes whose names start with "<code>xmlns:</code>", or
  attributes in the <a id="coercing-an-html-dom-into-an-infoset:xmlns-namespace" href="https://infra.spec.whatwg.org/#xmlns-namespace" data-x-internal="xmlns-namespace">XMLNS namespace</a>, then the tool may drop such attributes.</p>

  <p>The tool may annotate the output with any namespace declarations required for proper
  operation.</p>

  <p>If the XML API being used restricts the allowable characters in the local names of elements and
  attributes, then the tool may map all element and attribute local names that the API wouldn't
  support to a set of names that <em>are</em> allowed, by replacing any character that isn't
  supported with the uppercase letter U and the six digits of the character's code point when
  expressed in hexadecimal, using digits 0-9 and capital letters A-F as the symbols, in increasing
  numeric order.</p>

  <p class="example">For example, the element name <code>foo&lt;bar</code>, which can be
  output by the <a href="#html-parser" id="coercing-an-html-dom-into-an-infoset:html-parser-3">HTML parser</a>, though it is neither a legal HTML element name nor a
  well-formed XML element name, would be converted into <code>fooU00003Cbar</code>, which
  <em>is</em> a well-formed XML element name (though it's still not legal in HTML by any means).</p>

  <p class="example">As another example, consider the attribute <code>xlink:href</code>.
  Used on a MathML element, it becomes, after being <a href="#adjust-foreign-attributes" id="coercing-an-html-dom-into-an-infoset:adjust-foreign-attributes">adjusted</a>, an attribute with a prefix "<code>xlink</code>" and a local
  name "<code>href</code>". However, used on an HTML element, it becomes an attribute with
  no prefix and the local name "<code>xlink:href</code>", which is not a valid NCName, and
  thus might not be accepted by an XML API. It could thus get converted, becoming "<code>xlinkU00003Ahref</code>".</p>

  <p class="note">The resulting names from this conversion conveniently can't clash with any
  attribute generated by the <a href="#html-parser" id="coercing-an-html-dom-into-an-infoset:html-parser-4">HTML parser</a>, since those are all either lowercase or those
  listed in the <a href="#adjust-foreign-attributes" id="coercing-an-html-dom-into-an-infoset:adjust-foreign-attributes-2">adjust foreign attributes</a> algorithm's table.</p>

  <p>If the XML API restricts comments from having two consecutive U+002D HYPHEN-MINUS characters
  (--), the tool may insert a single U+0020 SPACE character between any such offending
  characters.</p>

  <p>If the XML API restricts comments from ending in a U+002D HYPHEN-MINUS character (-), the tool
  may insert a single U+0020 SPACE character at the end of such comments.</p>

  <p>If the XML API restricts allowed characters in character data, attribute values, or comments,
  the tool may replace any U+000C FORM FEED (FF) character with a U+0020 SPACE character, and any
  other literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>

  <p>If the tool has no way to convey out-of-band information, then the tool may drop the following
  information:</p>

  <ul><li>Whether the document is set to <i id="coercing-an-html-dom-into-an-infoset:no-quirks-mode"><a data-x-internal="no-quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-no-quirks">no-quirks mode</a></i>, <i id="coercing-an-html-dom-into-an-infoset:limited-quirks-mode"><a data-x-internal="limited-quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-limited-quirks">limited-quirks mode</a></i>, or
   <i id="coercing-an-html-dom-into-an-infoset:quirks-mode"><a data-x-internal="quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks">quirks mode</a></i></li><li>The association between form controls and forms that aren't their nearest <code id="coercing-an-html-dom-into-an-infoset:the-form-element"><a href="#the-form-element">form</a></code>
   element ancestor (use of the <a href="#form-element-pointer" id="coercing-an-html-dom-into-an-infoset:form-element-pointer"><code>form</code> element pointer</a> in the parser)</li><li>The <a href="#template-contents" id="coercing-an-html-dom-into-an-infoset:template-contents">template contents</a> of any <code id="coercing-an-html-dom-into-an-infoset:the-template-element"><a href="#the-template-element">template</a></code> elements.</li></ul>

  <p class="note">The mutations allowed by this section apply <em>after</em> the <a href="#html-parser" id="coercing-an-html-dom-into-an-infoset:html-parser-5">HTML
  parser</a>'s rules have been applied. For example, a <code>&lt;a::&gt;</code> start tag
  will be closed by a <code>&lt;/a::&gt;</code> end tag, and never by a <code>&lt;/aU00003AU00003A&gt;</code> end tag, even if the user agent is using the rules above to
  then generate an actual element in the DOM with the name <code>aU00003AU00003A</code> for
  that start tag.</p>

  


  

  <h4 id="an-introduction-to-error-handling-and-strange-cases-in-the-parser"><span class="secno">13.2.10</span> An introduction to error handling and strange cases in the parser<a href="#an-introduction-to-error-handling-and-strange-cases-in-the-parser" class="self-link"></a></h4>

  <p><i>This section is non-normative.</i></p>

  <p>This section examines some erroneous markup and discusses how the <a href="#html-parser" id="an-introduction-to-error-handling-and-strange-cases-in-the-parser:html-parser">HTML parser</a>
  handles these cases.</p>


  <h5 id="misnested-tags:-b-i-/b-/i"><span class="secno">13.2.10.1</span> Misnested tags: &lt;b&gt;&lt;i&gt;&lt;/b&gt;&lt;/i&gt;<a href="#misnested-tags:-b-i-/b-/i" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>The most-often discussed example of erroneous markup is as follows:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->1<c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->2<c- p="">&lt;</c-><c- f="">i</c-><c- p="">&gt;</c->3<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->4<c- p="">&lt;/</c-><c- f="">i</c-><c- p="">&gt;</c->5<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  <p>The parsing of this markup is straightforward up to the "3". At this point, the DOM looks like
  this:</p>

  <ul class="domTree"><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-html-element"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-head-element"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-body-element"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-p-element"><a href="#the-p-element">p</a></code><ul><li class="t3"><code id="misnested-tags:-b-i-/b-/i:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>1</span></li><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-b-element"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-i-/b-/i:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>2</span></li><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-i-element"><a href="#the-i-element">i</a></code><ul><li class="t3"><code id="misnested-tags:-b-i-/b-/i:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>3</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>Here, the <a href="#stack-of-open-elements" id="misnested-tags:-b-i-/b-/i:stack-of-open-elements">stack of open elements</a> has five elements on it: <code id="misnested-tags:-b-i-/b-/i:the-html-element-2"><a href="#the-html-element">html</a></code>,
  <code id="misnested-tags:-b-i-/b-/i:the-body-element-2"><a href="#the-body-element">body</a></code>, <code id="misnested-tags:-b-i-/b-/i:the-p-element-2"><a href="#the-p-element">p</a></code>, <code id="misnested-tags:-b-i-/b-/i:the-b-element-2"><a href="#the-b-element">b</a></code>, and <code id="misnested-tags:-b-i-/b-/i:the-i-element-2"><a href="#the-i-element">i</a></code>. The <a href="#list-of-active-formatting-elements" id="misnested-tags:-b-i-/b-/i:list-of-active-formatting-elements">list of active
  formatting elements</a> just has two: <code id="misnested-tags:-b-i-/b-/i:the-b-element-3"><a href="#the-b-element">b</a></code> and <code id="misnested-tags:-b-i-/b-/i:the-i-element-3"><a href="#the-i-element">i</a></code>. The <a href="#insertion-mode" id="misnested-tags:-b-i-/b-/i:insertion-mode">insertion
  mode</a> is "<a href="#parsing-main-inbody" id="misnested-tags:-b-i-/b-/i:parsing-main-inbody">in body</a>".</p>

  <p data-var-scope="">Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption
  agency algorithm</a>" is invoked. This is a simple case, in that the <var>formattingElement</var>
  is the <code id="misnested-tags:-b-i-/b-/i:the-b-element-4"><a href="#the-b-element">b</a></code> element, and there is no <var>furthest block</var>.
  Thus, the <a href="#stack-of-open-elements" id="misnested-tags:-b-i-/b-/i:stack-of-open-elements-2">stack of open elements</a> ends up with just three elements: <code id="misnested-tags:-b-i-/b-/i:the-html-element-3"><a href="#the-html-element">html</a></code>,
  <code id="misnested-tags:-b-i-/b-/i:the-body-element-3"><a href="#the-body-element">body</a></code>, and <code id="misnested-tags:-b-i-/b-/i:the-p-element-3"><a href="#the-p-element">p</a></code>, while the <a href="#list-of-active-formatting-elements" id="misnested-tags:-b-i-/b-/i:list-of-active-formatting-elements-2">list of active formatting elements</a>
  has just one: <code id="misnested-tags:-b-i-/b-/i:the-i-element-4"><a href="#the-i-element">i</a></code>. The DOM tree is unmodified at this point.</p>

  <p>The next token is a character ("4"), triggers the <a href="#reconstruct-the-active-formatting-elements" id="misnested-tags:-b-i-/b-/i:reconstruct-the-active-formatting-elements">reconstruction of the active formatting elements</a>, in this case just
  the <code id="misnested-tags:-b-i-/b-/i:the-i-element-5"><a href="#the-i-element">i</a></code> element. A new <code id="misnested-tags:-b-i-/b-/i:the-i-element-6"><a href="#the-i-element">i</a></code> element is thus created for the "4"
  <code id="misnested-tags:-b-i-/b-/i:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node. After the end tag token for the "i" is also received, and the "5"
  <code id="misnested-tags:-b-i-/b-/i:text-5"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node is inserted, the DOM looks as follows:</p>

  <ul class="domTree"><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-html-element-4"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-head-element-2"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-body-element-4"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-p-element-4"><a href="#the-p-element">p</a></code><ul><li class="t3"><code id="misnested-tags:-b-i-/b-/i:text-6"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>1</span></li><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-b-element-5"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-i-/b-/i:text-7"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>2</span></li><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-i-element-7"><a href="#the-i-element">i</a></code><ul><li class="t3"><code id="misnested-tags:-b-i-/b-/i:text-8"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>3</span></li></ul></li></ul></li><li class="t1"><code id="misnested-tags:-b-i-/b-/i:the-i-element-8"><a href="#the-i-element">i</a></code><ul><li class="t3"><code id="misnested-tags:-b-i-/b-/i:text-9"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>4</span></li></ul></li><li class="t3"><code id="misnested-tags:-b-i-/b-/i:text-10"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>5</span></li></ul></li></ul></li></ul></li></ul>


  <h5 id="misnested-tags:-b-p-/b-/p"><span class="secno">13.2.10.2</span> Misnested tags: &lt;b&gt;&lt;p&gt;&lt;/b&gt;&lt;/p&gt;<a href="#misnested-tags:-b-p-/b-/p" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>A case similar to the previous one is the following:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->1<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->2<c- p="">&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->3<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

  <p>Up to the "2" the parsing here is straightforward:</p>

  <ul class="domTree"><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-html-element"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-head-element"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-body-element"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-b-element"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>1</span></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-p-element"><a href="#the-p-element">p</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>2</span></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The interesting part is when the end tag token with the tag name "b" is parsed.</p>

  <p>Before that token is seen, the <a href="#stack-of-open-elements" id="misnested-tags:-b-p-/b-/p:stack-of-open-elements">stack of open elements</a> has four elements on it:
  <code id="misnested-tags:-b-p-/b-/p:the-html-element-2"><a href="#the-html-element">html</a></code>, <code id="misnested-tags:-b-p-/b-/p:the-body-element-2"><a href="#the-body-element">body</a></code>, <code id="misnested-tags:-b-p-/b-/p:the-b-element-2"><a href="#the-b-element">b</a></code>, and <code id="misnested-tags:-b-p-/b-/p:the-p-element-2"><a href="#the-p-element">p</a></code>. The <a href="#list-of-active-formatting-elements" id="misnested-tags:-b-p-/b-/p:list-of-active-formatting-elements">list of active
  formatting elements</a> just has the one: <code id="misnested-tags:-b-p-/b-/p:the-b-element-3"><a href="#the-b-element">b</a></code>. The <a href="#insertion-mode" id="misnested-tags:-b-p-/b-/p:insertion-mode">insertion mode</a> is
  "<a href="#parsing-main-inbody" id="misnested-tags:-b-p-/b-/p:parsing-main-inbody">in body</a>".</p>

  <p data-var-scope="">Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption
  agency algorithm</a>" is invoked, as in the previous example. However, in this case, there
  <em>is</em> a <var>furthest block</var>, namely the <code id="misnested-tags:-b-p-/b-/p:the-p-element-3"><a href="#the-p-element">p</a></code> element. Thus, this
  time the adoption agency algorithm isn't skipped over.</p>

  <p data-var-scope="">The <var>common ancestor</var> is the <code id="misnested-tags:-b-p-/b-/p:the-body-element-3"><a href="#the-body-element">body</a></code> element. A conceptual
  "bookmark" marks the position of the <code id="misnested-tags:-b-p-/b-/p:the-b-element-4"><a href="#the-b-element">b</a></code> in the <a href="#list-of-active-formatting-elements" id="misnested-tags:-b-p-/b-/p:list-of-active-formatting-elements-2">list of active formatting
  elements</a>, but since that list has only one element in it, the bookmark won't have much
  effect.</p>

  <p data-var-scope="">As the algorithm progresses, <var>node</var> ends up set to the formatting element
  (<code id="misnested-tags:-b-p-/b-/p:the-b-element-5"><a href="#the-b-element">b</a></code>), and <var>last node</var> ends up set to the <var>furthest
  block</var> (<code id="misnested-tags:-b-p-/b-/p:the-p-element-4"><a href="#the-p-element">p</a></code>).</p>

  <p data-var-scope="">The <var>last node</var> gets appended (moved) to the <var>common
  ancestor</var>, so that the DOM looks like:</p>

  <ul class="domTree"><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-html-element-3"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-head-element-2"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-body-element-4"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-b-element-6"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>1</span></li></ul></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-p-element-5"><a href="#the-p-element">p</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>2</span></li></ul></li></ul></li></ul></li></ul>

  <p>A new <code id="misnested-tags:-b-p-/b-/p:the-b-element-7"><a href="#the-b-element">b</a></code> element is created, and the children of the <code id="misnested-tags:-b-p-/b-/p:the-p-element-6"><a href="#the-p-element">p</a></code> element are
  moved to it:</p>

  <ul class="domTree"><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-html-element-4"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-head-element-3"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-body-element-5"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-b-element-8"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-5"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>1</span></li></ul></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-p-element-7"><a href="#the-p-element">p</a></code></li></ul></li></ul></li></ul>
  <ul class="domTree"><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-b-element-9"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-6"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>2</span></li></ul></li></ul>

  <p>Finally, the new <code id="misnested-tags:-b-p-/b-/p:the-b-element-10"><a href="#the-b-element">b</a></code> element is appended to the <code id="misnested-tags:-b-p-/b-/p:the-p-element-8"><a href="#the-p-element">p</a></code> element, so that the
  DOM looks like:</p>

  <ul class="domTree"><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-html-element-5"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-head-element-4"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-body-element-6"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-b-element-11"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-7"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>1</span></li></ul></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-p-element-9"><a href="#the-p-element">p</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-b-element-12"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-8"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>2</span></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The <code id="misnested-tags:-b-p-/b-/p:the-b-element-13"><a href="#the-b-element">b</a></code> element is removed from the <a href="#list-of-active-formatting-elements" id="misnested-tags:-b-p-/b-/p:list-of-active-formatting-elements-3">list of active formatting elements</a>
  and the <a href="#stack-of-open-elements" id="misnested-tags:-b-p-/b-/p:stack-of-open-elements-2">stack of open elements</a>, so that when the "3" is parsed, it is appended to the
  <code id="misnested-tags:-b-p-/b-/p:the-p-element-10"><a href="#the-p-element">p</a></code> element:</p>

  <ul class="domTree"><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-html-element-6"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-head-element-5"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-body-element-7"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-b-element-14"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-9"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>1</span></li></ul></li><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-p-element-11"><a href="#the-p-element">p</a></code><ul><li class="t1"><code id="misnested-tags:-b-p-/b-/p:the-b-element-15"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-10"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>2</span></li></ul></li><li class="t3"><code id="misnested-tags:-b-p-/b-/p:text-11"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>3</span></li></ul></li></ul></li></ul></li></ul>


  <h5 id="unexpected-markup-in-tables"><span class="secno">13.2.10.3</span> Unexpected markup in tables<a href="#unexpected-markup-in-tables" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Error handling in tables is, for historical reasons, especially strange. For example, consider
  the following markup:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c-><strong><c- p="">&lt;</c-><c- f="">b</c-><c- p="">&gt;</c-></strong><c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;&lt;</c-><c- f="">td</c-><c- p="">&gt;</c->aaa<c- p="">&lt;/</c-><c- f="">td</c-><c- p="">&gt;&lt;/</c-><c- f="">tr</c-><c- p="">&gt;</c-><strong>bbb</strong><c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c->ccc</code></pre>

  <p>The highlighted <code id="unexpected-markup-in-tables:the-b-element"><a href="#the-b-element">b</a></code> element start tag is not allowed directly inside a table like
  that, and the parser handles this case by placing the element <em>before</em> the table. (This is
  called <i id="unexpected-markup-in-tables:foster-parent"><a href="#foster-parent">foster parenting</a></i>.) This can be seen by examining the DOM tree
  as it stands just after the <code id="unexpected-markup-in-tables:the-table-element"><a href="#the-table-element">table</a></code> element's start tag has been seen:</p>

  <ul class="domTree"><li class="t1"><code id="unexpected-markup-in-tables:the-html-element"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-head-element"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-body-element"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-table-element-2"><a href="#the-table-element">table</a></code></li></ul></li></ul></li></ul>

  <p>...and then immediately after the <code id="unexpected-markup-in-tables:the-b-element-2"><a href="#the-b-element">b</a></code> element start tag has been seen:</p>

  <ul class="domTree"><li class="t1"><code id="unexpected-markup-in-tables:the-html-element-2"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-head-element-2"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-body-element-2"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-b-element-3"><a href="#the-b-element">b</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-table-element-3"><a href="#the-table-element">table</a></code></li></ul></li></ul></li></ul>

  <p>At this point, the <a href="#stack-of-open-elements" id="unexpected-markup-in-tables:stack-of-open-elements">stack of open elements</a> has on it the elements
  <code id="unexpected-markup-in-tables:the-html-element-3"><a href="#the-html-element">html</a></code>, <code id="unexpected-markup-in-tables:the-body-element-3"><a href="#the-body-element">body</a></code>, <code id="unexpected-markup-in-tables:the-table-element-4"><a href="#the-table-element">table</a></code>, and <code id="unexpected-markup-in-tables:the-b-element-4"><a href="#the-b-element">b</a></code> (in that order,
  despite the resulting DOM tree); the <a href="#list-of-active-formatting-elements" id="unexpected-markup-in-tables:list-of-active-formatting-elements">list of active formatting elements</a> just has the
  <code id="unexpected-markup-in-tables:the-b-element-5"><a href="#the-b-element">b</a></code> element in it; and the <a href="#insertion-mode" id="unexpected-markup-in-tables:insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" id="unexpected-markup-in-tables:parsing-main-intable">in table</a>".</p>

  <p>The <code id="unexpected-markup-in-tables:the-tr-element"><a href="#the-tr-element">tr</a></code> start tag causes the <code id="unexpected-markup-in-tables:the-b-element-6"><a href="#the-b-element">b</a></code> element to be popped off the stack and
  a <code id="unexpected-markup-in-tables:the-tbody-element"><a href="#the-tbody-element">tbody</a></code> start tag to be implied; the <code id="unexpected-markup-in-tables:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code> and <code id="unexpected-markup-in-tables:the-tr-element-2"><a href="#the-tr-element">tr</a></code> elements
  are then handled in a rather straight-forward manner, taking the parser through the "<a href="#parsing-main-intbody" id="unexpected-markup-in-tables:parsing-main-intbody">in table body</a>" and "<a href="#parsing-main-intr" id="unexpected-markup-in-tables:parsing-main-intr">in row</a>" insertion modes, after which the DOM looks as follows:</p>

  <ul class="domTree"><li class="t1"><code id="unexpected-markup-in-tables:the-html-element-4"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-head-element-3"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-body-element-4"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-b-element-7"><a href="#the-b-element">b</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-table-element-5"><a href="#the-table-element">table</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tr-element-3"><a href="#the-tr-element">tr</a></code></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>Here, the <a href="#stack-of-open-elements" id="unexpected-markup-in-tables:stack-of-open-elements-2">stack of open elements</a> has on it the elements <code id="unexpected-markup-in-tables:the-html-element-5"><a href="#the-html-element">html</a></code>,
  <code id="unexpected-markup-in-tables:the-body-element-5"><a href="#the-body-element">body</a></code>, <code id="unexpected-markup-in-tables:the-table-element-6"><a href="#the-table-element">table</a></code>, <code id="unexpected-markup-in-tables:the-tbody-element-4"><a href="#the-tbody-element">tbody</a></code>, and <code id="unexpected-markup-in-tables:the-tr-element-4"><a href="#the-tr-element">tr</a></code>; the <a href="#list-of-active-formatting-elements" id="unexpected-markup-in-tables:list-of-active-formatting-elements-2">list of
  active formatting elements</a> still has the <code id="unexpected-markup-in-tables:the-b-element-8"><a href="#the-b-element">b</a></code> element in it; and the
  <a href="#insertion-mode" id="unexpected-markup-in-tables:insertion-mode-2">insertion mode</a> is "<a href="#parsing-main-intr" id="unexpected-markup-in-tables:parsing-main-intr-2">in row</a>".</p>

  <p>The <code id="unexpected-markup-in-tables:the-td-element"><a href="#the-td-element">td</a></code> element start tag token, after putting a <code id="unexpected-markup-in-tables:the-td-element-2"><a href="#the-td-element">td</a></code> element on the
  tree, puts a <a href="#concept-parser-marker" id="unexpected-markup-in-tables:concept-parser-marker">marker</a> on the <a href="#list-of-active-formatting-elements" id="unexpected-markup-in-tables:list-of-active-formatting-elements-3">list of active
  formatting elements</a> (it also switches to the "<a href="#parsing-main-intd" id="unexpected-markup-in-tables:parsing-main-intd">in
  cell</a>" <a href="#insertion-mode" id="unexpected-markup-in-tables:insertion-mode-3">insertion mode</a>).</p>

  <ul class="domTree"><li class="t1"><code id="unexpected-markup-in-tables:the-html-element-6"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-head-element-4"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-body-element-6"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-b-element-9"><a href="#the-b-element">b</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-table-element-7"><a href="#the-table-element">table</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tbody-element-5"><a href="#the-tbody-element">tbody</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tr-element-5"><a href="#the-tr-element">tr</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-td-element-3"><a href="#the-td-element">td</a></code></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The <a href="#concept-parser-marker" id="unexpected-markup-in-tables:concept-parser-marker-2">marker</a> means that when the "aaa" character
  tokens are seen, no <code id="unexpected-markup-in-tables:the-b-element-10"><a href="#the-b-element">b</a></code> element is created to hold the resulting <code id="unexpected-markup-in-tables:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code>
  node:</p>

  <ul class="domTree"><li class="t1"><code id="unexpected-markup-in-tables:the-html-element-7"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-head-element-5"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-body-element-7"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-b-element-11"><a href="#the-b-element">b</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-table-element-8"><a href="#the-table-element">table</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tbody-element-6"><a href="#the-tbody-element">tbody</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tr-element-6"><a href="#the-tr-element">tr</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-td-element-4"><a href="#the-td-element">td</a></code><ul><li class="t3"><code id="unexpected-markup-in-tables:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>aaa</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The end tags are handled in a straight-forward manner; after handling them, the <a href="#stack-of-open-elements" id="unexpected-markup-in-tables:stack-of-open-elements-3">stack of
  open elements</a> has on it the elements <code id="unexpected-markup-in-tables:the-html-element-8"><a href="#the-html-element">html</a></code>, <code id="unexpected-markup-in-tables:the-body-element-8"><a href="#the-body-element">body</a></code>,
  <code id="unexpected-markup-in-tables:the-table-element-9"><a href="#the-table-element">table</a></code>, and <code id="unexpected-markup-in-tables:the-tbody-element-7"><a href="#the-tbody-element">tbody</a></code>; the <a href="#list-of-active-formatting-elements" id="unexpected-markup-in-tables:list-of-active-formatting-elements-4">list of active formatting elements</a>
  still has the <code id="unexpected-markup-in-tables:the-b-element-12"><a href="#the-b-element">b</a></code> element in it (the <a href="#concept-parser-marker" id="unexpected-markup-in-tables:concept-parser-marker-3">marker</a>
  having been removed by the "td" end tag token); and the <a href="#insertion-mode" id="unexpected-markup-in-tables:insertion-mode-4">insertion mode</a> is "<a href="#parsing-main-intbody" id="unexpected-markup-in-tables:parsing-main-intbody-2">in table body</a>".</p>

  <p>Thus it is that the "bbb" character tokens are found. These trigger the "<a href="#parsing-main-intabletext" id="unexpected-markup-in-tables:parsing-main-intabletext">in table text</a>" insertion mode to be used (with the <a href="#original-insertion-mode" id="unexpected-markup-in-tables:original-insertion-mode">original
  insertion mode</a> set to "<a href="#parsing-main-intbody" id="unexpected-markup-in-tables:parsing-main-intbody-3">in table body</a>").
  The character tokens are collected, and when the next token (the <code id="unexpected-markup-in-tables:the-table-element-10"><a href="#the-table-element">table</a></code> element end
  tag) is seen, they are processed as a group. Since they are not all spaces, they are handled as
  per the "anything else" rules in the "<a href="#parsing-main-intable" id="unexpected-markup-in-tables:parsing-main-intable-2">in table</a>"
  insertion mode, which defer to the "<a href="#parsing-main-inbody" id="unexpected-markup-in-tables:parsing-main-inbody">in body</a>"
  insertion mode but with <a href="#foster-parent" id="unexpected-markup-in-tables:foster-parent-2">foster parenting</a>.</p>

  <p>When <a href="#reconstruct-the-active-formatting-elements" id="unexpected-markup-in-tables:reconstruct-the-active-formatting-elements">the active formatting elements
  are reconstructed</a>, a <code id="unexpected-markup-in-tables:the-b-element-13"><a href="#the-b-element">b</a></code> element is created and <a href="#foster-parent" id="unexpected-markup-in-tables:foster-parent-3">foster parented</a>, and then the "bbb" <code id="unexpected-markup-in-tables:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node is appended to it:</p>

  <ul class="domTree"><li class="t1"><code id="unexpected-markup-in-tables:the-html-element-9"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-head-element-6"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-body-element-9"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-b-element-14"><a href="#the-b-element">b</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-b-element-15"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="unexpected-markup-in-tables:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>bbb</span></li></ul></li><li class="t1"><code id="unexpected-markup-in-tables:the-table-element-11"><a href="#the-table-element">table</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tbody-element-8"><a href="#the-tbody-element">tbody</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tr-element-7"><a href="#the-tr-element">tr</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-td-element-5"><a href="#the-td-element">td</a></code><ul><li class="t3"><code id="unexpected-markup-in-tables:text-5"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>aaa</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The <a href="#stack-of-open-elements" id="unexpected-markup-in-tables:stack-of-open-elements-4">stack of open elements</a> has on it the elements <code id="unexpected-markup-in-tables:the-html-element-10"><a href="#the-html-element">html</a></code>,
  <code id="unexpected-markup-in-tables:the-body-element-10"><a href="#the-body-element">body</a></code>, <code id="unexpected-markup-in-tables:the-table-element-12"><a href="#the-table-element">table</a></code>, <code id="unexpected-markup-in-tables:the-tbody-element-9"><a href="#the-tbody-element">tbody</a></code>, and the new <code id="unexpected-markup-in-tables:the-b-element-16"><a href="#the-b-element">b</a></code> (again, note
  that this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements" id="unexpected-markup-in-tables:list-of-active-formatting-elements-5">list of active formatting elements</a>
  has the new <code id="unexpected-markup-in-tables:the-b-element-17"><a href="#the-b-element">b</a></code> element in it; and the <a href="#insertion-mode" id="unexpected-markup-in-tables:insertion-mode-5">insertion mode</a> is still "<a href="#parsing-main-intbody" id="unexpected-markup-in-tables:parsing-main-intbody-4">in table body</a>".</p>

  <p>Had the character tokens been only <a id="unexpected-markup-in-tables:space-characters" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> instead of "bbb", then that
  <a id="unexpected-markup-in-tables:space-characters-2" href="https://infra.spec.whatwg.org/#ascii-whitespace" data-x-internal="space-characters">ASCII whitespace</a> would just be appended to the <code id="unexpected-markup-in-tables:the-tbody-element-10"><a href="#the-tbody-element">tbody</a></code> element.</p>

  <p>Finally, the <code id="unexpected-markup-in-tables:the-table-element-13"><a href="#the-table-element">table</a></code> is closed by a "table" end tag. This pops all the nodes from
  the <a href="#stack-of-open-elements" id="unexpected-markup-in-tables:stack-of-open-elements-5">stack of open elements</a> up to and including the <code id="unexpected-markup-in-tables:the-table-element-14"><a href="#the-table-element">table</a></code> element, but it
  doesn't affect the <a href="#list-of-active-formatting-elements" id="unexpected-markup-in-tables:list-of-active-formatting-elements-6">list of active formatting elements</a>, so the "ccc" character tokens
  after the table result in yet another <code id="unexpected-markup-in-tables:the-b-element-18"><a href="#the-b-element">b</a></code> element being created, this time after the
  table:</p>

  <ul class="domTree"><li class="t1"><code id="unexpected-markup-in-tables:the-html-element-11"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-head-element-7"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-body-element-11"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-b-element-19"><a href="#the-b-element">b</a></code></li><li class="t1"><code id="unexpected-markup-in-tables:the-b-element-20"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="unexpected-markup-in-tables:text-6"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>bbb</span></li></ul></li><li class="t1"><code id="unexpected-markup-in-tables:the-table-element-15"><a href="#the-table-element">table</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tbody-element-11"><a href="#the-tbody-element">tbody</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-tr-element-8"><a href="#the-tr-element">tr</a></code><ul><li class="t1"><code id="unexpected-markup-in-tables:the-td-element-6"><a href="#the-td-element">td</a></code><ul><li class="t3"><code id="unexpected-markup-in-tables:text-7"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>aaa</span></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code id="unexpected-markup-in-tables:the-b-element-21"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="unexpected-markup-in-tables:text-8"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>ccc</span></li></ul></li></ul></li></ul></li></ul>


  <h5 id="scripts-that-modify-the-page-as-it-is-being-parsed"><span class="secno">13.2.10.4</span> Scripts that modify the page as it is being parsed<a href="#scripts-that-modify-the-page-as-it-is-being-parsed" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Consider the following markup, which for this example we will assume is the document with
  <a id="scripts-that-modify-the-page-as-it-is-being-parsed:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <code>https://example.com/inner</code>, being rendered as the content of
  an <code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> in another document with the <a id="scripts-that-modify-the-page-as-it-is-being-parsed:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> <code>https://example.com/outer</code>:</p>

  <pre><code class="html"><c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">a</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  <c- a="">var</c-> div <c- o="">=</c-> document<c- p="">.</c->getElementById<c- p="">(</c-><c- t="">'a'</c-><c- p="">);</c->
  parent<c- p="">.</c->document<c- p="">.</c->body<c- p="">.</c->appendChild<c- p="">(</c->div<c- p="">);</c->
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
  alert<c- p="">(</c->document<c- p="">.</c->URL<c- p="">);</c->
 <c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
 alert<c- p="">(</c->document<c- p="">.</c->URL<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

  <p>Up to the first "script" end tag, before the script is parsed, the result is relatively
  straightforward:</p>

  <ul class="domTree"><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-html-element"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-head-element"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-body-element"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element"><a href="#the-div-element">div</a></code> <span class="t2"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-id-attribute" class="attribute name"><a href="#the-id-attribute">id</a></code>="<code class="attribute value">a</code>"</span><ul><li class="t3"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>
 </span></li><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element"><a href="#the-script-element">script</a></code><ul><li class="t3"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>var div = document.getElementById('a'); ⏎ parent.document.body.appendChild(div);</span></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>After the script is parsed, though, the <code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element-2"><a href="#the-div-element">div</a></code> element and its child
  <code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element-2"><a href="#the-script-element">script</a></code> element are gone:</p>

  <ul class="domTree"><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-html-element-2"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-head-element-2"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-body-element-2"><a href="#the-body-element">body</a></code></li></ul></li></ul>

  <p>They are, at this point, in the <code id="scripts-that-modify-the-page-as-it-is-being-parsed:document"><a href="#document">Document</a></code> of the aforementioned outer
  <a href="#browsing-context" id="scripts-that-modify-the-page-as-it-is-being-parsed:browsing-context">browsing context</a>. However, the <a href="#stack-of-open-elements" id="scripts-that-modify-the-page-as-it-is-being-parsed:stack-of-open-elements">stack of open elements</a> <em>still contains
  the <code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element-3"><a href="#the-div-element">div</a></code> element</em>.</p>

  <p>Thus, when the second <code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element-3"><a href="#the-script-element">script</a></code> element is parsed, it is inserted <em>into the outer
  <code id="scripts-that-modify-the-page-as-it-is-being-parsed:document-2"><a href="#document">Document</a></code> object</em>.</p>

  <p>Those parsed into different <code id="scripts-that-modify-the-page-as-it-is-being-parsed:document-3"><a href="#document">Document</a></code>s than the one the parser was created for do
  not execute, so the first alert does not show.</p>

  <p>Once the <code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element-4"><a href="#the-div-element">div</a></code> element's end tag is parsed, the <code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element-5"><a href="#the-div-element">div</a></code> element is popped
  off the stack, and so the next <code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element-4"><a href="#the-script-element">script</a></code> element is in the inner
  <code id="scripts-that-modify-the-page-as-it-is-being-parsed:document-4"><a href="#document">Document</a></code>:</p>

  <ul class="domTree"><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-html-element-3"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-head-element-3"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-body-element-3"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element-5"><a href="#the-script-element">script</a></code><ul><li class="t3"><code id="scripts-that-modify-the-page-as-it-is-being-parsed:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>alert(document.URL);</span></li></ul></li></ul></li></ul></li></ul>

  <p>This script does execute, resulting in an alert that says "https://example.com/inner".</p>


  <h5 id="the-execution-of-scripts-that-are-moving-across-multiple-documents"><span class="secno">13.2.10.5</span> The execution of scripts that are moving across multiple documents<a href="#the-execution-of-scripts-that-are-moving-across-multiple-documents" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>Elaborating on the example in the previous section, consider the case where the second
  <code id="the-execution-of-scripts-that-are-moving-across-multiple-documents:the-script-element"><a href="#the-script-element">script</a></code> element is an external script (i.e. one with a <code id="the-execution-of-scripts-that-are-moving-across-multiple-documents:attr-script-src"><a href="#attr-script-src">src</a></code> attribute). Since the element was not in the parser's
  <code id="the-execution-of-scripts-that-are-moving-across-multiple-documents:document"><a href="#document">Document</a></code> when it was created, that external script is not even downloaded.</p>

  <p>In a case where a <code id="the-execution-of-scripts-that-are-moving-across-multiple-documents:the-script-element-2"><a href="#the-script-element">script</a></code> element with a <code id="the-execution-of-scripts-that-are-moving-across-multiple-documents:attr-script-src-2"><a href="#attr-script-src">src</a></code>
  attribute is parsed normally into its parser's <code id="the-execution-of-scripts-that-are-moving-across-multiple-documents:document-2"><a href="#document">Document</a></code>, but while the external
  script is being downloaded, the element is moved to another document, the script continues to
  download, but does not execute.</p>

  <p class="note">In general, moving <code id="the-execution-of-scripts-that-are-moving-across-multiple-documents:the-script-element-3"><a href="#the-script-element">script</a></code> elements between <code id="the-execution-of-scripts-that-are-moving-across-multiple-documents:document-3"><a href="#document">Document</a></code>s is
  considered a bad practice.</p>



  <h5 id="unclosed-formatting-elements"><span class="secno">13.2.10.6</span> Unclosed formatting elements<a href="#unclosed-formatting-elements" class="self-link"></a></h5>

  <p><i>This section is non-normative.</i></p>

  <p>The following markup shows how nested formatting elements (such as <code id="unclosed-formatting-elements:the-b-element"><a href="#the-b-element">b</a></code>) get
  collected and continue to be applied even as the elements they are contained in are closed, but
  that excessive duplicates are thrown away.</p>

  <pre><code class="html"><c- cp="">&lt;!DOCTYPE html&gt;</c->
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">x</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">x</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">x</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">x</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->X
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;</c->X
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-> <c- e="">class</c-><c- o="">=</c-><c- s="">x</c-><c- p="">&gt;&lt;</c-><c- f="">b</c-><c- p="">&gt;</c->X
<c- p="">&lt;</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">b</c-><c- p="">&gt;&lt;/</c-><c- f="">b</c-><c- p="">&gt;&lt;/</c-><c- f="">b</c-><c- p="">&gt;&lt;/</c-><c- f="">b</c-><c- p="">&gt;&lt;/</c-><c- f="">b</c-><c- p="">&gt;&lt;/</c-><c- f="">b</c-><c- p="">&gt;</c->X</code></pre>

  <p>The resulting DOM tree is as follows:</p>

  <ul class="domTree"><li class="t10">DOCTYPE: <code>html</code></li><li class="t1"><code id="unclosed-formatting-elements:the-html-element"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-head-element"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="unclosed-formatting-elements:the-body-element"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-p-element"><a href="#the-p-element">p</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-2"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-3"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-2" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-4"><a href="#the-b-element">b</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-5"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-3" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-6"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-4" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-7"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="unclosed-formatting-elements:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>X⏎</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code id="unclosed-formatting-elements:the-p-element-2"><a href="#the-p-element">p</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-8"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-5" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-9"><a href="#the-b-element">b</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-10"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-6" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-11"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-7" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-12"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="unclosed-formatting-elements:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>X⏎</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code id="unclosed-formatting-elements:the-p-element-3"><a href="#the-p-element">p</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-13"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-8" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-14"><a href="#the-b-element">b</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-15"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-9" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-16"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-10" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-17"><a href="#the-b-element">b</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-18"><a href="#the-b-element">b</a></code><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-19"><a href="#the-b-element">b</a></code> <span class="t2"><code id="unclosed-formatting-elements:classes-11" class="attribute name"><a href="#classes">class</a></code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code id="unclosed-formatting-elements:the-b-element-20"><a href="#the-b-element">b</a></code><ul><li class="t3"><code id="unclosed-formatting-elements:text-3"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>X⏎</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code id="unclosed-formatting-elements:the-p-element-4"><a href="#the-p-element">p</a></code><ul><li class="t3"><code id="unclosed-formatting-elements:text-4"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">#text</a></code>: <span>X⏎</span></li></ul></li></ul></li></ul></li></ul>

  <p>Note how the second <code id="unclosed-formatting-elements:the-p-element-5"><a href="#the-p-element">p</a></code> element in the markup has no explicit <code id="unclosed-formatting-elements:the-b-element-21"><a href="#the-b-element">b</a></code>
  elements, but in the resulting DOM, up to three of each kind of formatting element (in this case
  three <code id="unclosed-formatting-elements:the-b-element-22"><a href="#the-b-element">b</a></code> elements with the class attribute, and two unadorned <code id="unclosed-formatting-elements:the-b-element-23"><a href="#the-b-element">b</a></code> elements)
  get reconstructed before the element's "X".</p>

  <p>Also note how this means that in the final paragraph only six <code id="unclosed-formatting-elements:the-b-element-24"><a href="#the-b-element">b</a></code> end tags are
  needed to completely clear the <a href="#list-of-active-formatting-elements" id="unclosed-formatting-elements:list-of-active-formatting-elements">list of active formatting elements</a>, even though nine
  <code id="unclosed-formatting-elements:the-b-element-25"><a href="#the-b-element">b</a></code> start tags have been seen up to this point.</p>





  <h3 id="serialising-html-fragments"><span class="secno">13.3</span> Serializing HTML fragments<a href="#serialising-html-fragments" class="self-link"></a></h3>

  <div data-algorithm="">
  <p>For the purposes of the following algorithm, an element <dfn id="serializes-as-void">serializes as void</dfn> if its
  element type is one of the <a href="#void-elements" id="serialising-html-fragments:void-elements">void elements</a>, or is <code id="serialising-html-fragments:basefont"><a href="#basefont">basefont</a></code>,
  <code id="serialising-html-fragments:bgsound"><a href="#bgsound">bgsound</a></code>, <code id="serialising-html-fragments:frame"><a href="#frame">frame</a></code>, <code id="serialising-html-fragments:keygen"><a href="#keygen">keygen</a></code>, or <code id="serialising-html-fragments:param"><a href="#param">param</a></code>.</p>
  </div>

  <div data-algorithm="">
  <p>The following steps form the <dfn id="html-fragment-serialisation-algorithm" data-export="">HTML fragment serialization algorithm</dfn>. The algorithm takes as input a DOM
  <code id="serialising-html-fragments:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>, <code id="serialising-html-fragments:document"><a href="#document">Document</a></code>, or <code id="serialising-html-fragments:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> referred to as
  <var>the node</var>, a boolean <var>serializableShadowRoots</var>, and a
  <code>sequence&lt;ShadowRoot&gt;</code> <var>shadowRoots</var>, and returns a string.</p>

  <p class="note">This algorithm serializes the <em>children</em> of the node being serialized, not
  the node itself.</p>

  <ol><li><p>If <var>the node</var> <a href="#serializes-as-void" id="serialising-html-fragments:serializes-as-void">serializes as void</a>, then return the empty
   string.</p></li><li><p>Let <var>s</var> be a string, and initialize it to the empty string.</p></li><li><p>If <var>the node</var> is a <code id="serialising-html-fragments:the-template-element"><a href="#the-template-element">template</a></code> element, then let <var>the node</var> instead be the <code id="serialising-html-fragments:the-template-element-2"><a href="#the-template-element">template</a></code> element's <a href="#template-contents" id="serialising-html-fragments:template-contents">template
   contents</a> (a <code id="serialising-html-fragments:documentfragment-2"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> node).</p></li><li>
    <p>If <var>current node</var> is a <a id="serialising-html-fragments:shadow-host" href="https://dom.spec.whatwg.org/#element-shadow-host" data-x-internal="shadow-host">shadow host</a>, then:</p>

    <ol><li><p>Let <var>shadow</var> be <var>current node</var>'s
     <a href="https://dom.spec.whatwg.org/#concept-element-shadow-root" id="serialising-html-fragments:concept-element-shadow-root" data-x-internal="concept-element-shadow-root">shadow root</a>.</p></li><li>
      <p>If one of the following is true:</p>

      <ul><li><p><var>serializableShadowRoots</var> is true and <var>shadow</var>'s
       <a href="https://dom.spec.whatwg.org/#shadowroot-serializable" id="serialising-html-fragments:shadow-serializable" data-x-internal="shadow-serializable">serializable</a> is true; or</p></li><li><p><var>shadowRoots</var> contains <var>shadow</var>,</p></li></ul>

      <p>then:</p>

      <ol><li><p>Append "<code>&lt;template shadowrootmode="</code>".</p></li><li><p>If <var>shadow</var>'s <a href="https://dom.spec.whatwg.org/#shadowroot-mode" id="serialising-html-fragments:concept-shadow-root-mode" data-x-internal="concept-shadow-root-mode">mode</a>
       is "<code>open</code>", then append "<code>open</code>".
       Otherwise, append "<code>closed</code>".</p></li><li><p>Append "<code>"</code>".</p></li><li><p>If <var>shadow</var>'s <a id="serialising-html-fragments:delegates-focus" href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus" data-x-internal="delegates-focus">delegates focus</a> is set, then append
       "<code> shadowrootdelegatesfocus=""</code>".</p></li><li><p>If <var>shadow</var>'s <a href="https://dom.spec.whatwg.org/#shadowroot-serializable" id="serialising-html-fragments:shadow-serializable-2" data-x-internal="shadow-serializable">serializable</a> is set, then append
       "<code> shadowrootserializable=""</code>".</p></li><li><p>If <var>shadow</var>'s <a id="serialising-html-fragments:clonable" href="https://dom.spec.whatwg.org/#shadowroot-clonable" data-x-internal="clonable">clonable</a> is set, then append
       "<code> shadowrootclonable=""</code>".</p></li><li><p>If <var>current node</var>'s <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="serialising-html-fragments:element-custom-element-registry" data-x-internal="element-custom-element-registry">custom
       element registry</a> is not <var>shadow</var>'s <a href="https://dom.spec.whatwg.org/#shadowroot-custom-element-registry" id="serialising-html-fragments:shadow-root-custom-element-registry" data-x-internal="shadow-root-custom-element-registry">custom element registry</a>, then append
       "<code> shadowrootcustomelementregistry=""</code>".</p></li><li><p>Append "<code>&gt;</code>".</p></li><li><p>Append the value of running the <a href="#html-fragment-serialisation-algorithm" id="serialising-html-fragments:html-fragment-serialisation-algorithm">HTML fragment serialization algorithm</a> with
       <var>shadow</var>, <var>serializableShadowRoots</var>, and <var>shadowRoots</var> (thus recursing
       into this algorithm for that element).</p></li><li><p>Append "<code>&lt;/template&gt;</code>".</p></li></ol>
     </li></ol>
   </li><li>
    <p>For each child node of <var>the node</var>, in <a id="serialising-html-fragments:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>, run the
    following steps:</p>

    <ol><li><p>Let <var>current node</var> be the child node being processed.</p></li><li>
      <p>Append the appropriate string from the following list to <var>s</var>:</p>

      <dl class="switch"><dt>If <var>current node</var> is an <code id="serialising-html-fragments:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code></dt><dd>
        <p>If <var>current node</var> is an element in the <a id="serialising-html-fragments:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, the
        <a id="serialising-html-fragments:mathml-namespace" href="https://infra.spec.whatwg.org/#mathml-namespace" data-x-internal="mathml-namespace">MathML namespace</a>, or the <a id="serialising-html-fragments:svg-namespace" href="https://infra.spec.whatwg.org/#svg-namespace" data-x-internal="svg-namespace">SVG namespace</a>, then let <var>tagname</var> be <var>current node</var>'s local name. Otherwise, let <var>tagname</var> be <var>current node</var>'s qualified name.</p>

        <p>Append a U+003C LESS-THAN SIGN character (&lt;), followed by <var>tagname</var>.</p>

        <p class="note">For <a href="#html-elements" id="serialising-html-fragments:html-elements">HTML elements</a> created by the <a href="#html-parser" id="serialising-html-fragments:html-parser">HTML parser</a> or
        <code id="serialising-html-fragments:dom-document-createelement"><a data-x-internal="dom-document-createelement" href="https://dom.spec.whatwg.org/#dom-document-createelement">createElement()</a></code>, <var>tagname</var> will be
        lowercase.</p>

        <p>If <var>current node</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="serialising-html-fragments:concept-element-is-value" data-x-internal="concept-element-is-value"><code>is</code> value</a> is not null, and the element does not have an <code id="serialising-html-fragments:attr-is"><a href="#attr-is">is</a></code> attribute in its attribute list, then append the string "<code> is="</code>", followed by <var>current node</var>'s <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="serialising-html-fragments:concept-element-is-value-2" data-x-internal="concept-element-is-value"><code>is</code> value</a> <a href="#escapingString" id="serialising-html-fragments:escapingString">escaped as described below</a> in <i>attribute mode</i>,
        followed by a U+0022 QUOTATION MARK character (").</p>

        <p>For each attribute that the element has, append a U+0020 SPACE character, the <a href="#attribute's-serialised-name" id="serialising-html-fragments:attribute's-serialised-name">attribute's serialized name as described below</a>, a
        U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK character ("), the
        attribute's value, <a href="#escapingString" id="serialising-html-fragments:escapingString-2">escaped as described below</a> in
        <i>attribute mode</i>, and a second U+0022 QUOTATION MARK character (").</p>

        <p>An <dfn id="attribute's-serialised-name">attribute's serialized name</dfn>
        for the purposes of the previous paragraph must be determined as follows:</p>

        <dl class="switch"><dt>If the attribute has no namespace</dt><dd>
          <p>The attribute's serialized name is the attribute's local name.</p>

          <p class="note">For attributes on <a href="#html-elements" id="serialising-html-fragments:html-elements-2">HTML elements</a> set by the <a href="#html-parser" id="serialising-html-fragments:html-parser-2">HTML
          parser</a> or by <code id="serialising-html-fragments:dom-element-setattribute"><a data-x-internal="dom-element-setattribute" href="https://dom.spec.whatwg.org/#dom-element-setattribute">setAttribute()</a></code>, the
          local name will be lowercase.</p>
         </dd><dt>If the attribute is in the <a id="serialising-html-fragments:xml-namespace" href="https://infra.spec.whatwg.org/#xml-namespace" data-x-internal="xml-namespace">XML namespace</a></dt><dd><p>The attribute's serialized name is the string "<code>xml:</code>" followed
         by the attribute's local name.</p></dd><dt>If the attribute is in the <a id="serialising-html-fragments:xmlns-namespace" href="https://infra.spec.whatwg.org/#xmlns-namespace" data-x-internal="xmlns-namespace">XMLNS namespace</a> and the attribute's local name
         is <code>xmlns</code></dt><dd><p>The attribute's serialized name is the string "<code>xmlns</code>".</p></dd><dt>If the attribute is in the <a id="serialising-html-fragments:xmlns-namespace-2" href="https://infra.spec.whatwg.org/#xmlns-namespace" data-x-internal="xmlns-namespace">XMLNS namespace</a> and the attribute's local name
         is not <code>xmlns</code></dt><dd><p>The attribute's serialized name is the string "<code>xmlns:</code>"
         followed by the attribute's local name.</p></dd><dt>If the attribute is in the <a id="serialising-html-fragments:xlink-namespace" href="https://infra.spec.whatwg.org/#xlink-namespace" data-x-internal="xlink-namespace">XLink namespace</a></dt><dd><p>The attribute's serialized name is the string "<code>xlink:</code>"
         followed by the attribute's local name.</p></dd><dt>If the attribute is in some other namespace</dt><dd><p>The attribute's serialized name is the attribute's qualified name.</p></dd></dl>

        <p>While the exact order of attributes is <a id="serialising-html-fragments:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a>, and may
        depend on factors such as the order that the attributes were given in the original markup,
        the sort order must be stable, such that consecutive invocations of this algorithm serialize
        an element's attributes in the same order.</p>

        <p>Append a U+003E GREATER-THAN SIGN character (&gt;).</p>

        <p>If <var>current node</var> <a href="#serializes-as-void" id="serialising-html-fragments:serializes-as-void-2">serializes as void</a>, then <a id="serialising-html-fragments:continue" href="https://infra.spec.whatwg.org/#iteration-continue" data-x-internal="continue">continue</a> on to the next
        child node at this point.</p>

        <p>Append the value of running the <a href="#html-fragment-serialisation-algorithm" id="serialising-html-fragments:html-fragment-serialisation-algorithm-2">HTML fragment serialization algorithm</a> with
        <var>current node</var>, <var>serializableShadowRoots</var>, and <var>shadowRoots</var> (thus
        recursing into this algorithm for that node), followed by a U+003C LESS-THAN SIGN character (&lt;), a
        U+002F SOLIDUS character (/), <var>tagname</var> again, and finally a U+003E GREATER-THAN SIGN
        character (&gt;).</p>
       </dd><dt>If <var>current node</var> is a <code id="serialising-html-fragments:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node</dt><dd>
        <p>If the parent of <var>current node</var> is a <code id="serialising-html-fragments:the-style-element"><a href="#the-style-element">style</a></code>,
        <code id="serialising-html-fragments:the-script-element"><a href="#the-script-element">script</a></code>, <code id="serialising-html-fragments:xmp"><a href="#xmp">xmp</a></code>, <code id="serialising-html-fragments:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, <code id="serialising-html-fragments:noembed"><a href="#noembed">noembed</a></code>,
        <code id="serialising-html-fragments:noframes"><a href="#noframes">noframes</a></code>, or <code id="serialising-html-fragments:plaintext"><a href="#plaintext">plaintext</a></code> element, or if the parent of <var>current node</var> is a <code id="serialising-html-fragments:the-noscript-element"><a href="#the-noscript-element">noscript</a></code> element and <a href="#concept-n-script" id="serialising-html-fragments:concept-n-script">scripting is enabled</a> for the node, then append the value of
        <var>current node</var>'s <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="serialising-html-fragments:concept-cd-data" data-x-internal="concept-cd-data">data</a> literally.</p>

        <p>Otherwise, append the value of <var>current node</var>'s <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="serialising-html-fragments:concept-cd-data-2" data-x-internal="concept-cd-data">data</a>, <a href="#escapingString" id="serialising-html-fragments:escapingString-3">escaped as described
        below</a>.</p>
       </dd><dt>If <var>current node</var> is a <code id="serialising-html-fragments:comment-2"><a data-x-internal="comment-2" href="https://dom.spec.whatwg.org/#interface-comment">Comment</a></code></dt><dd>
        <p>Append "<code>&lt;!--</code>" (U+003C LESS-THAN SIGN, U+0021
        EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS), followed by the value of
        <var>current node</var>'s <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="serialising-html-fragments:concept-cd-data-3" data-x-internal="concept-cd-data">data</a>, followed by the
        literal string "<code>--&gt;</code>" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS,
        U+003E GREATER-THAN SIGN).</p>
       </dd><dt>If <var>current node</var> is a <code id="serialising-html-fragments:processinginstruction"><a data-x-internal="processinginstruction" href="https://dom.spec.whatwg.org/#interface-processinginstruction">ProcessingInstruction</a></code></dt><dd>
        <p>Append "<code>&lt;?</code>" (U+003C LESS-THAN SIGN, U+003F
        QUESTION MARK), followed by the value of <var>current node</var>'s <code>target</code> IDL attribute, followed by a single U+0020 SPACE character, followed
        by the value of <var>current node</var>'s <a href="https://dom.spec.whatwg.org/#concept-cd-data" id="serialising-html-fragments:concept-cd-data-4" data-x-internal="concept-cd-data">data</a>,
        followed by a single U+003E GREATER-THAN SIGN character (&gt;).</p>
       </dd><dt>If <var>current node</var> is a <code id="serialising-html-fragments:documenttype"><a data-x-internal="documenttype" href="https://dom.spec.whatwg.org/#interface-documenttype">DocumentType</a></code></dt><dd>
        <p>Append "<code>&lt;!DOCTYPE</code>" (U+003C LESS-THAN SIGN, U+0021
        EXCLAMATION MARK, U+0044 LATIN CAPITAL LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN
        CAPITAL LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL LETTER Y, U+0050 LATIN
        CAPITAL LETTER P, U+0045 LATIN CAPITAL LETTER E), followed by a space (U+0020 SPACE),
        followed by the value of <var>current node</var>'s <a href="https://dom.spec.whatwg.org/#concept-doctype-name" id="serialising-html-fragments:concept-doctype-name" data-x-internal="concept-doctype-name">name</a>, followed by "<code>&gt;</code>"
        (U+003E GREATER-THAN SIGN).</p>
       </dd></dl>
     </li></ol>
   </li><li><p>Return <var>s</var>.</p></li></ol>
  </div>

  <p id="warning-html-serializer-roundtrip" class="warning">It is possible that the output of this
  algorithm, if parsed with an <a href="#html-parser" id="serialising-html-fragments:html-parser-3">HTML parser</a>, will not return the original tree
  structure. Tree structures that do not roundtrip a serialize and reparse step can also be produced
  by the <a href="#html-parser" id="serialising-html-fragments:html-parser-4">HTML parser</a> itself, although such cases are typically non-conforming.</p>

  <div id="example-html-serializer-roundtrip-comments-and-script" class="example"><a href="#example-html-serializer-roundtrip-comments-and-script" class="self-link"></a>
   <p>For instance, if a <code id="serialising-html-fragments:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element to which a <code>Comment</code>
   node has been appended is serialized and the output is then reparsed, the comment will end up
   being displayed in the text control. Similarly, if, as a result of DOM manipulation, an element
   contains a comment that contains "<code>--&gt;</code>", then when the result of
   serializing the element is parsed, the comment will be truncated at that point and the rest of
   the comment will be interpreted as markup. More examples would be making a <code id="serialising-html-fragments:the-script-element-2"><a href="#the-script-element">script</a></code>
   element contain a <code id="serialising-html-fragments:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node with the text string "<code>&lt;/script&gt;</code>", or having a <code id="serialising-html-fragments:the-p-element"><a href="#the-p-element">p</a></code> element that contains a
   <code id="serialising-html-fragments:the-ul-element"><a href="#the-ul-element">ul</a></code> element (as the <code id="serialising-html-fragments:the-ul-element-2"><a href="#the-ul-element">ul</a></code> element's <a href="#syntax-start-tag" id="serialising-html-fragments:syntax-start-tag">start
   tag</a> would imply the end tag for the <code id="serialising-html-fragments:the-p-element-2"><a href="#the-p-element">p</a></code>).</p>

   <p>This can enable cross-site scripting attacks. An example of this would be a page that lets the
   user enter some font family names that are then inserted into a CSS <code id="serialising-html-fragments:the-style-element-2"><a href="#the-style-element">style</a></code> block via
   the DOM and which then uses the <code id="serialising-html-fragments:dom-element-innerhtml"><a href="#dom-element-innerhtml">innerHTML</a></code> IDL
   attribute to get the HTML serialization of that <code id="serialising-html-fragments:the-style-element-3"><a href="#the-style-element">style</a></code> element: if the user enters
   "<code>&lt;/style&gt;&lt;script&gt;attack&lt;/script&gt;</code>" as a font family name, <code id="serialising-html-fragments:dom-element-innerhtml-2"><a href="#dom-element-innerhtml">innerHTML</a></code> will return markup that, if parsed in a different
   context, would contain a <code id="serialising-html-fragments:the-script-element-3"><a href="#the-script-element">script</a></code> node, even though no <code id="serialising-html-fragments:the-script-element-4"><a href="#the-script-element">script</a></code> node
   existed in the original DOM.</p>
  </div>

  <div id="example-html-serializer-roundtrip-nested-form" class="example"><a href="#example-html-serializer-roundtrip-nested-form" class="self-link"></a>
   <p>For example, consider the following markup:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"outer"</c-><c- p="">&gt;&lt;</c-><c- f="">div</c-><c- p="">&gt;&lt;/</c-><c- f="">form</c-><c- p="">&gt;&lt;</c-><c- f="">form</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"inner"</c-><c- p="">&gt;&lt;</c-><c- f="">input</c-><c- p="">&gt;</c-></code></pre>

   <p>This will be parsed into:</p>

   <ul class="domTree"><li class="t1"><code id="serialising-html-fragments:the-html-element"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-head-element"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="serialising-html-fragments:the-body-element"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-form-element"><a href="#the-form-element">form</a></code> <span class="t2"><code id="serialising-html-fragments:the-id-attribute" class="attribute name"><a href="#the-id-attribute">id</a></code>="<code class="attribute value">outer</code>"</span><ul><li class="t1"><code id="serialising-html-fragments:the-div-element"><a href="#the-div-element">div</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-form-element-2"><a href="#the-form-element">form</a></code> <span class="t2"><code id="serialising-html-fragments:the-id-attribute-2" class="attribute name"><a href="#the-id-attribute">id</a></code>="<code class="attribute value">inner</code>"</span><ul><li class="t1"><code id="serialising-html-fragments:the-input-element"><a href="#the-input-element">input</a></code></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

   <p>The <code id="serialising-html-fragments:the-input-element-2"><a href="#the-input-element">input</a></code> element will be associated with the inner <code id="serialising-html-fragments:the-form-element-3"><a href="#the-form-element">form</a></code> element.
   Now, if this tree structure is serialized and reparsed, the <code>&lt;form
   id="inner"&gt;</code> start tag will be ignored, and so the <code id="serialising-html-fragments:the-input-element-3"><a href="#the-input-element">input</a></code> element will be
   associated with the outer <code id="serialising-html-fragments:the-form-element-4"><a href="#the-form-element">form</a></code> element instead.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">html</c-><c- p="">&gt;&lt;</c-><c- f="">head</c-><c- p="">&gt;&lt;/</c-><c- f="">head</c-><c- p="">&gt;&lt;</c-><c- f="">body</c-><c- p="">&gt;&lt;</c-><c- f="">form</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"outer"</c-><c- p="">&gt;&lt;</c-><c- f="">div</c-><c- p="">&gt;</c-><mark><c- p="">&lt;</c-><c- f="">form</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"inner"</c-><c- p="">&gt;</c-></mark><c- p="">&lt;</c-><c- f="">input</c-><c- p="">&gt;&lt;/</c-><c- f="">form</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;&lt;/</c-><c- f="">form</c-><c- p="">&gt;&lt;/</c-><c- f="">body</c-><c- p="">&gt;&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <ul class="domTree"><li class="t1"><code id="serialising-html-fragments:the-html-element-2"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-head-element-2"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="serialising-html-fragments:the-body-element-2"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-form-element-5"><a href="#the-form-element">form</a></code> <span class="t2"><code id="serialising-html-fragments:the-id-attribute-3" class="attribute name"><a href="#the-id-attribute">id</a></code>="<code class="attribute value">outer</code>"</span><ul><li class="t1"><code id="serialising-html-fragments:the-div-element-2"><a href="#the-div-element">div</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-input-element-4"><a href="#the-input-element">input</a></code></li></ul></li></ul></li></ul></li></ul></li></ul>
  </div>

  <div id="example-html-serializer-roundtrip-foster-parenting" class="example"><a href="#example-html-serializer-roundtrip-foster-parenting" class="self-link"></a>
   <p>As another example, consider the following markup:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">a</c-><c- p="">&gt;&lt;</c-><c- f="">table</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-><c- p="">&gt;</c-></code></pre>

   <p>This will be parsed into:</p>

   <ul class="domTree"><li class="t1"><code id="serialising-html-fragments:the-html-element-3"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-head-element-3"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="serialising-html-fragments:the-body-element-3"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-a-element"><a href="#the-a-element">a</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-a-element-2"><a href="#the-a-element">a</a></code></li><li class="t1"><code id="serialising-html-fragments:the-table-element"><a href="#the-table-element">table</a></code></li></ul></li></ul></li></ul></li></ul>

   <p>That is, the <code id="serialising-html-fragments:the-a-element-3"><a href="#the-a-element">a</a></code> elements are nested, because the second <code id="serialising-html-fragments:the-a-element-4"><a href="#the-a-element">a</a></code> element is
   <a href="#foster-parent" id="serialising-html-fragments:foster-parent">foster parented</a>. After a serialize-reparse roundtrip, the
   <code id="serialising-html-fragments:the-a-element-5"><a href="#the-a-element">a</a></code> elements and the <code id="serialising-html-fragments:the-table-element-2"><a href="#the-table-element">table</a></code> element would all be siblings, because the
   second <code>&lt;a&gt;</code> start tag implicitly closes the first <code id="serialising-html-fragments:the-a-element-6"><a href="#the-a-element">a</a></code>
   element.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">html</c-><c- p="">&gt;&lt;</c-><c- f="">head</c-><c- p="">&gt;&lt;/</c-><c- f="">head</c-><c- p="">&gt;&lt;</c-><c- f="">body</c-><c- p="">&gt;&lt;</c-><c- f="">a</c-><c- p="">&gt;</c-><mark><c- p="">&lt;</c-><c- f="">a</c-><c- p="">&gt;</c-></mark><c- p="">&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;</c-><c- f="">table</c-><c- p="">&gt;&lt;/</c-><c- f="">table</c-><c- p="">&gt;&lt;/</c-><c- f="">a</c-><c- p="">&gt;&lt;/</c-><c- f="">body</c-><c- p="">&gt;&lt;/</c-><c- f="">html</c-><c- p="">&gt;</c-></code></pre>

   <ul class="domTree"><li class="t1"><code id="serialising-html-fragments:the-html-element-4"><a href="#the-html-element">html</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-head-element-4"><a href="#the-head-element">head</a></code></li><li class="t1"><code id="serialising-html-fragments:the-body-element-4"><a href="#the-body-element">body</a></code><ul><li class="t1"><code id="serialising-html-fragments:the-a-element-7"><a href="#the-a-element">a</a></code></li><li class="t1"><code id="serialising-html-fragments:the-a-element-8"><a href="#the-a-element">a</a></code></li><li class="t1"><code id="serialising-html-fragments:the-table-element-3"><a href="#the-table-element">table</a></code></li></ul></li></ul></li></ul>
  </div>

  <p>For historical reasons, this algorithm does not round-trip an initial U+000A (LF) character in
  <code id="serialising-html-fragments:the-pre-element"><a href="#the-pre-element">pre</a></code>, <code id="serialising-html-fragments:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code>, or <code id="serialising-html-fragments:listing"><a href="#listing">listing</a></code> elements, even though (in the
  first two cases) the markup being round-tripped can be conforming. The <a href="#html-parser" id="serialising-html-fragments:html-parser-5">HTML parser</a>
  will drop such a character during parsing, but this algorithm does <em>not</em> serialize an extra
  U+000A (LF) character.</p>
  

  <div id="example-html-serializer-roundtrip-linefeed" class="example"><a href="#example-html-serializer-roundtrip-linefeed" class="self-link"></a>
   <p>For example, consider the following markup:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">pre</c-><c- p="">&gt;</c->

Hello.<c- p="">&lt;/</c-><c- f="">pre</c-><c- p="">&gt;</c-></code></pre>

   <p>When this document is first parsed, the <code id="serialising-html-fragments:the-pre-element-2"><a href="#the-pre-element">pre</a></code> element's <a id="serialising-html-fragments:child-text-content" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text
   content</a> starts with a single newline character. After a serialize-reparse roundtrip, the
   <code id="serialising-html-fragments:the-pre-element-3"><a href="#the-pre-element">pre</a></code> element's <a id="serialising-html-fragments:child-text-content-2" href="https://dom.spec.whatwg.org/#concept-child-text-content" data-x-internal="child-text-content">child text content</a> is simply "<code>Hello.</code>".</p>
  </div>

  <p id="attr-is-during-serialization">Because of the special role of the <code id="serialising-html-fragments:attr-is-2"><a href="#attr-is">is</a></code> attribute in signaling the creation of <a href="#customized-built-in-element" id="serialising-html-fragments:customized-built-in-element">customized built-in elements</a>, in that it provides a mechanism for parsed
  HTML to set the element's <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="serialising-html-fragments:concept-element-is-value-3" data-x-internal="concept-element-is-value"><code>is</code>
  value</a>, we special-case its handling during serialization. This ensures that an element's
  <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="serialising-html-fragments:concept-element-is-value-4" data-x-internal="concept-element-is-value"><code>is</code> value</a> is preserved
  through serialize-parse roundtrips.</p>

  <div id="example-html-serializer-roundtrip-is-attribute" class="example"><a href="#example-html-serializer-roundtrip-is-attribute" class="self-link"></a>
   <p>When creating a <a href="#customized-built-in-element" id="serialising-html-fragments:customized-built-in-element-2">customized built-in element</a> via the parser, a developer uses the
   <code id="serialising-html-fragments:attr-is-3"><a href="#attr-is">is</a></code> attribute directly; in such cases serialize-parse roundtrips
   work fine.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
window<c- p="">.</c->SuperP <c- o="">=</c-> <c- a="">class</c-> <c- k="">extends</c-> HTMLParagraphElement <c- p="">{};</c->
customElements<c- p="">.</c->define<c- p="">(</c-><c- u="">"super-p"</c-><c- p="">,</c-> SuperP<c- p="">,</c-> <c- p="">{</c-> <c- k="">extends</c-><c- o="">:</c-> <c- u="">"p"</c-> <c- p="">});</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">div</c-> <c- e="">id</c-><c- o="">=</c-><c- s="">"container"</c-><c- p="">&gt;&lt;</c-><c- f="">p</c-> <c- e="">is</c-><c- o="">=</c-><c- s="">"super-p"</c-><c- p="">&gt;</c->Superb!<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;&lt;/</c-><c- f="">div</c-><c- p="">&gt;</c->

<c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
console<c- p="">.</c->log<c- p="">(</c->container<c- p="">.</c->innerHTML<c- p="">);</c-> <c- c1="">// &lt;p is="super-p"&gt;</c->
container<c- p="">.</c->innerHTML <c- o="">=</c-> container<c- p="">.</c->innerHTML<c- p="">;</c->
console<c- p="">.</c->log<c- p="">(</c->container<c- p="">.</c->innerHTML<c- p="">);</c-> <c- c1="">// &lt;p is="super-p"&gt;</c->
console<c- p="">.</c->assert<c- p="">(</c->container<c- p="">.</c->firstChild <c- k="">instanceof</c-> SuperP<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>But when creating a customized built-in element via its <a href="#custom-element-constructor" id="serialising-html-fragments:custom-element-constructor">constructor</a> or via <code id="serialising-html-fragments:dom-document-createelement-2"><a data-x-internal="dom-document-createelement" href="https://dom.spec.whatwg.org/#dom-document-createelement">createElement()</a></code>, the <code id="serialising-html-fragments:attr-is-4"><a href="#attr-is">is</a></code>
   attribute is not added. Instead, the <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="serialising-html-fragments:concept-element-is-value-5" data-x-internal="concept-element-is-value"><code>is</code> value</a> (which is what the custom elements machinery uses) is set
   without intermediating through an attribute.</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
container<c- p="">.</c->innerHTML <c- o="">=</c-> <c- u="">""</c-><c- p="">;</c->
<c- a="">const</c-> p <c- o="">=</c-> document<c- p="">.</c->createElement<c- p="">(</c-><c- u="">"p"</c-><c- p="">,</c-> <c- p="">{</c-> is<c- o="">:</c-> <c- u="">"super-p"</c-> <c- p="">});</c->
container<c- p="">.</c->appendChild<c- p="">(</c->p<c- p="">);</c->

<c- c1="">// The is attribute is not present in the DOM:</c->
console<c- p="">.</c->assert<c- p="">(</c-><c- o="">!</c->p<c- p="">.</c->hasAttribute<c- p="">(</c-><c- u="">"is"</c-><c- p="">));</c->

<c- c1="">// But the element is still a super-p:</c->
console<c- p="">.</c->assert<c- p="">(</c->p <c- k="">instanceof</c-> SuperP<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>

   <p>To ensure that serialize-parse roundtrips still work, the serialization process explicitly
   writes out the element's <a href="https://dom.spec.whatwg.org/#concept-element-is-value" id="serialising-html-fragments:concept-element-is-value-6" data-x-internal="concept-element-is-value"><code>is</code>
   value</a> as an <code id="serialising-html-fragments:attr-is-5"><a href="#attr-is">is</a></code> attribute:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">script</c-><c- p="">&gt;</c->
console<c- p="">.</c->log<c- p="">(</c->container<c- p="">.</c->innerHTML<c- p="">);</c-> <c- c1="">// &lt;p is="super-p"&gt;</c->
container<c- p="">.</c->innerHTML <c- o="">=</c-> container<c- p="">.</c->innerHTML<c- p="">;</c->
console<c- p="">.</c->log<c- p="">(</c->container<c- p="">.</c->innerHTML<c- p="">);</c-> <c- c1="">// &lt;p is="super-p"&gt;</c->
console<c- p="">.</c->assert<c- p="">(</c->container<c- p="">.</c->firstChild <c- k="">instanceof</c-> SuperP<c- p="">);</c->
<c- p="">&lt;/</c-><c- f="">script</c-><c- p="">&gt;</c-></code></pre>
  </div>

  <div data-algorithm="">
  <p><dfn id="escapingString">Escaping a string</dfn> (for the purposes of the algorithm above)
  consists of running the following steps:</p>

  <ol><li><p>Replace any occurrence of the "<code>&amp;</code>" character by the string "<code>&amp;amp;</code>".</p></li><li><p>Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the string "<code>&amp;nbsp;</code>".</p></li><li><p>Replace any occurrences of the "<code>&lt;</code>" character by the string
   "<code>&amp;lt;</code>".</p></li><li><p>Replace any occurrences of the "<code>&gt;</code>" character by the string
   "<code>&amp;gt;</code>".</p></li><li><p>If the algorithm was invoked in the <i>attribute mode</i>, then replace any occurrences of
   the "<code>"</code>" character by the string "<code>&amp;quot;</code>".</p></li></ol>
  </div>


  <h3 id="parsing-html-fragments"><span class="secno">13.4</span> Parsing HTML fragments<a href="#parsing-html-fragments" class="self-link"></a></h3>

  <div data-algorithm="">
  <p>The <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing algorithm</dfn>, given an <code id="parsing-html-fragments:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> node <dfn id="concept-frag-parse-context"><var>context</var></dfn>, string <var>input</var>, and an
  optional boolean <var>allowDeclarativeShadowRoots</var> (default false) is the following steps.
  They return a list of zero or more nodes.</p>

  <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms in the <a href="#html-parser" id="parsing-html-fragments:html-parser">HTML
  parser</a> section are parts that only occur if the parser was created for the purposes of this
  algorithm. The algorithms have been annotated with such markings for informational purposes only;
  such markings have no normative weight. If it is possible for a condition described as a
  <a href="#fragment-case" id="parsing-html-fragments:fragment-case">fragment case</a> to occur even when the parser wasn't created for the purposes of
  handling this algorithm, then that is an error in the specification.</p>

  <ol><li><p>Let <var>document</var> be a <code id="parsing-html-fragments:document"><a href="#document">Document</a></code> node whose <a href="https://dom.spec.whatwg.org/#concept-document-type" id="parsing-html-fragments:concept-document-type" data-x-internal="concept-document-type">type</a> is "<code>html</code>".</p></li><li><p>If <var id="parsing-html-fragments:concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var>'s <a id="parsing-html-fragments:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> is
   in <a id="parsing-html-fragments:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, then set <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-mode" id="parsing-html-fragments:concept-document-mode" data-x-internal="concept-document-mode">mode</a> to "<code>quirks</code>".</p></li><li><p>Otherwise, if <var id="parsing-html-fragments:concept-frag-parse-context-2"><a href="#concept-frag-parse-context">context</a></var>'s <a id="parsing-html-fragments:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node
   document</a> is in <a id="parsing-html-fragments:limited-quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-limited-quirks" data-x-internal="limited-quirks-mode">limited-quirks mode</a>, then set <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-mode" id="parsing-html-fragments:concept-document-mode-2" data-x-internal="concept-document-mode">mode</a> to "<code>limited-quirks</code>".</p></li><li><p>If <var>allowDeclarativeShadowRoots</var> is true, then set <var>document</var>'s <a href="https://dom.spec.whatwg.org/#concept-document-allow-declarative-shadow-roots" id="parsing-html-fragments:concept-document-allow-declarative-shadow-roots" data-x-internal="concept-document-allow-declarative-shadow-roots">allow declarative shadow roots</a> to
   true.</p></li><li><p>Create a new <a href="#html-parser" id="parsing-html-fragments:html-parser-2">HTML parser</a>, and associate it with <var>document</var>.</p></li><li>
    <p>Set the state of the <a href="#html-parser" id="parsing-html-fragments:html-parser-3">HTML parser</a>'s <a href="#tokenization" id="parsing-html-fragments:tokenization">tokenization</a> stage as
    follows, switching on the <var id="parsing-html-fragments:concept-frag-parse-context-3"><a href="#concept-frag-parse-context">context</a></var> element:</p>

    <dl class="switch"><dt><code id="parsing-html-fragments:the-title-element"><a href="#the-title-element">title</a></code></dt><dt><code id="parsing-html-fragments:the-textarea-element"><a href="#the-textarea-element">textarea</a></code></dt><dd>Switch the tokenizer to the <a href="#rcdata-state" id="parsing-html-fragments:rcdata-state">RCDATA state</a>.</dd><dt><code id="parsing-html-fragments:the-style-element"><a href="#the-style-element">style</a></code></dt><dt><code id="parsing-html-fragments:xmp"><a href="#xmp">xmp</a></code></dt><dt><code id="parsing-html-fragments:the-iframe-element"><a href="#the-iframe-element">iframe</a></code></dt><dt><code id="parsing-html-fragments:noembed"><a href="#noembed">noembed</a></code></dt><dt><code id="parsing-html-fragments:noframes"><a href="#noframes">noframes</a></code></dt><dd>Switch the tokenizer to the <a href="#rawtext-state" id="parsing-html-fragments:rawtext-state">RAWTEXT state</a>.</dd><dt><code id="parsing-html-fragments:the-script-element"><a href="#the-script-element">script</a></code></dt><dd>Switch the tokenizer to the <a href="#script-data-state" id="parsing-html-fragments:script-data-state">script data state</a>.</dd><dt><code id="parsing-html-fragments:the-noscript-element"><a href="#the-noscript-element">noscript</a></code></dt><dd>If the <a href="#scripting-flag" id="parsing-html-fragments:scripting-flag">scripting flag</a> is enabled, switch the tokenizer to the <a href="#rawtext-state" id="parsing-html-fragments:rawtext-state-2">RAWTEXT
     state</a>. Otherwise, leave the tokenizer in the <a href="#data-state" id="parsing-html-fragments:data-state">data state</a>.</dd><dt><code id="parsing-html-fragments:plaintext"><a href="#plaintext">plaintext</a></code></dt><dd>Switch the tokenizer to the <a href="#plaintext-state" id="parsing-html-fragments:plaintext-state">PLAINTEXT state</a>.</dd><dt>Any other element</dt><dd>Leave the tokenizer in the <a href="#data-state" id="parsing-html-fragments:data-state-2">data state</a>.</dd></dl>

    <p class="note">For performance reasons, an implementation that does not report errors and
    that uses the actual state machine described in this specification directly could use the
    PLAINTEXT state instead of the RAWTEXT and script data states where those are mentioned in the
    list above. Except for rules regarding parse errors, they are equivalent, since there is no
    <a href="#appropriate-end-tag-token" id="parsing-html-fragments:appropriate-end-tag-token">appropriate end tag token</a> in the fragment case, yet they involve far fewer state
    transitions.</p>
   </li><li><p>Let <var>root</var> be the result of <a href="https://dom.spec.whatwg.org/#concept-create-element" id="parsing-html-fragments:create-an-element" data-x-internal="create-an-element">creating an
   element</a> given <var>document</var>, "<code>html</code>", the <a id="parsing-html-fragments:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
   namespace</a>, null, null, false, and <var>context</var>'s <a href="https://dom.spec.whatwg.org/#element-custom-element-registry" id="parsing-html-fragments:element-custom-element-registry" data-x-internal="element-custom-element-registry">custom element registry</a>.</p></li><li><p><a href="https://dom.spec.whatwg.org/#concept-node-append" id="parsing-html-fragments:concept-node-append" data-x-internal="concept-node-append">Append</a> <var>root</var> to
   <var>document</var>.</p></li><li><p>Set up the <a href="#html-parser" id="parsing-html-fragments:html-parser-4">HTML parser</a>'s <a href="#stack-of-open-elements" id="parsing-html-fragments:stack-of-open-elements">stack of open elements</a> so that it
   contains just the single element <var>root</var>.</p></li><li><p>If <var id="parsing-html-fragments:concept-frag-parse-context-4"><a href="#concept-frag-parse-context">context</a></var> is a <code id="parsing-html-fragments:the-template-element"><a href="#the-template-element">template</a></code>
   element, then push "<a href="#parsing-main-intemplate" id="parsing-html-fragments:parsing-main-intemplate">in template</a>" onto the
   <a href="#stack-of-template-insertion-modes" id="parsing-html-fragments:stack-of-template-insertion-modes">stack of template insertion modes</a> so that it is the new <a href="#current-template-insertion-mode" id="parsing-html-fragments:current-template-insertion-mode">current template
   insertion mode</a>.</p></li><li>
    <p>Create a start tag token whose name is the local name of <var id="parsing-html-fragments:concept-frag-parse-context-5"><a href="#concept-frag-parse-context">context</a></var> and whose attributes are the attributes of
    <var id="parsing-html-fragments:concept-frag-parse-context-6"><a href="#concept-frag-parse-context">context</a></var>.</p>

    <p>Let this start tag token be the start tag token of <var id="parsing-html-fragments:concept-frag-parse-context-7"><a href="#concept-frag-parse-context">context</a></var>; e.g. for the purposes of determining if it is
    an <a href="#html-integration-point" id="parsing-html-fragments:html-integration-point">HTML integration point</a>.</p>
   </li><li>
    <p><a href="#reset-the-insertion-mode-appropriately" id="parsing-html-fragments:reset-the-insertion-mode-appropriately">Reset the parser's insertion mode
    appropriately</a>.</p>

    <p class="note">The parser will reference the <var id="parsing-html-fragments:concept-frag-parse-context-8"><a href="#concept-frag-parse-context">context</a></var> element as part of that algorithm.</p>
   </li><li><p>Set the <a href="#html-parser" id="parsing-html-fragments:html-parser-5">HTML parser</a>'s <a href="#form-element-pointer" id="parsing-html-fragments:form-element-pointer"><code>form</code> element pointer</a> to the
   nearest node to <var id="parsing-html-fragments:concept-frag-parse-context-9"><a href="#concept-frag-parse-context">context</a></var> that is a
   <code id="parsing-html-fragments:the-form-element"><a href="#the-form-element">form</a></code> element (going straight up the ancestor chain, and including the element
   itself, if it is a <code id="parsing-html-fragments:the-form-element-2"><a href="#the-form-element">form</a></code> element), if any. (If there is no such <code id="parsing-html-fragments:the-form-element-3"><a href="#the-form-element">form</a></code>
   element, the <a href="#form-element-pointer" id="parsing-html-fragments:form-element-pointer-2"><code>form</code> element pointer</a> keeps its initial value,
   null.)</p></li><li><p>Place the <var>input</var> into the <a href="#input-stream" id="parsing-html-fragments:input-stream">input stream</a> for the <a href="#html-parser" id="parsing-html-fragments:html-parser-6">HTML
   parser</a> just created. The encoding <a href="#concept-encoding-confidence" id="parsing-html-fragments:concept-encoding-confidence">confidence</a> is <i>irrelevant</i>.</p></li><li><p>Start the <a href="#html-parser" id="parsing-html-fragments:html-parser-7">HTML parser</a> and let it run until it has consumed all the characters
   just inserted into the input stream.</p></li><li><p>Return <var>root</var>'s <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="parsing-html-fragments:concept-tree-child" data-x-internal="concept-tree-child">children</a>, in <a id="parsing-html-fragments:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree
   order</a>.</p></li></ol>
  </div>

  



  <h3 id="named-character-references"><span class="secno">13.5</span> <dfn>Named character references</dfn><a href="#named-character-references" class="self-link"></a></h3>

  <p>This table lists the <a href="#syntax-charref" id="named-character-references:syntax-charref">character reference</a> names that are
  supported by HTML, and the code points to which they refer. It is referenced by the previous
  sections.</p>

  <p class="note">It is intentional, for legacy compatibility, that many code points have multiple
  character reference names. For example, some appear both with and without the trailing semicolon,
  or with different capitalizations.</p>

  <div id="named-character-references-table">
   <table><thead><tr><th> Name </th><th> Character(s) </th><th> Glyph </th></tr></thead><tbody><tr id="entity-Aacute"><td> <code>Aacute;</code> </td><td> U+000C1 </td><td> <span class="glyph">Á</span> </td></tr><tr id="entity-Aacute-legacy" class="impl"><td> <code>Aacute</code> </td><td> U+000C1 </td><td> <span>Á</span> </td></tr><tr id="entity-aacute"><td> <code>aacute;</code> </td><td> U+000E1 </td><td> <span class="glyph">á</span> </td></tr><tr id="entity-aacute-legacy" class="impl"><td> <code>aacute</code> </td><td> U+000E1 </td><td> <span>á</span> </td></tr><tr id="entity-Abreve"><td> <code>Abreve;</code> </td><td> U+00102 </td><td> <span class="glyph">Ă</span> </td></tr><tr id="entity-abreve"><td> <code>abreve;</code> </td><td> U+00103 </td><td> <span class="glyph">ă</span> </td></tr><tr id="entity-ac"><td> <code>ac;</code> </td><td> U+0223E </td><td> <span class="glyph">∾</span> </td></tr><tr id="entity-acd"><td> <code>acd;</code> </td><td> U+0223F </td><td> <span class="glyph">∿</span> </td></tr><tr id="entity-acE"><td> <code>acE;</code> </td><td> U+0223E U+00333 </td><td> <span class="glyph compound">∾̳</span> </td></tr><tr id="entity-Acirc"><td> <code>Acirc;</code> </td><td> U+000C2 </td><td> <span class="glyph">Â</span> </td></tr><tr id="entity-Acirc-legacy" class="impl"><td> <code>Acirc</code> </td><td> U+000C2 </td><td> <span>Â</span> </td></tr><tr id="entity-acirc"><td> <code>acirc;</code> </td><td> U+000E2 </td><td> <span class="glyph">â</span> </td></tr><tr id="entity-acirc-legacy" class="impl"><td> <code>acirc</code> </td><td> U+000E2 </td><td> <span>â</span> </td></tr><tr id="entity-acute"><td> <code>acute;</code> </td><td> U+000B4 </td><td> <span class="glyph">´</span> </td></tr><tr id="entity-acute-legacy" class="impl"><td> <code>acute</code> </td><td> U+000B4 </td><td> <span>´</span> </td></tr><tr id="entity-Acy"><td> <code>Acy;</code> </td><td> U+00410 </td><td> <span class="glyph">А</span> </td></tr><tr id="entity-acy"><td> <code>acy;</code> </td><td> U+00430 </td><td> <span class="glyph">а</span> </td></tr><tr id="entity-AElig"><td> <code>AElig;</code> </td><td> U+000C6 </td><td> <span class="glyph">Æ</span> </td></tr><tr id="entity-AElig-legacy" class="impl"><td> <code>AElig</code> </td><td> U+000C6 </td><td> <span>Æ</span> </td></tr><tr id="entity-aelig"><td> <code>aelig;</code> </td><td> U+000E6 </td><td> <span class="glyph">æ</span> </td></tr><tr id="entity-aelig-legacy" class="impl"><td> <code>aelig</code> </td><td> U+000E6 </td><td> <span>æ</span> </td></tr><tr id="entity-af"><td> <code>af;</code> </td><td> U+02061 </td><td> <span class="glyph">⁡</span> </td></tr><tr id="entity-Afr"><td> <code>Afr;</code> </td><td> U+1D504 </td><td> <span class="glyph">𝔄</span> </td></tr><tr id="entity-afr"><td> <code>afr;</code> </td><td> U+1D51E </td><td> <span class="glyph">𝔞</span> </td></tr><tr id="entity-Agrave"><td> <code>Agrave;</code> </td><td> U+000C0 </td><td> <span class="glyph">À</span> </td></tr><tr id="entity-Agrave-legacy" class="impl"><td> <code>Agrave</code> </td><td> U+000C0 </td><td> <span>À</span> </td></tr><tr id="entity-agrave"><td> <code>agrave;</code> </td><td> U+000E0 </td><td> <span class="glyph">à</span> </td></tr><tr id="entity-agrave-legacy" class="impl"><td> <code>agrave</code> </td><td> U+000E0 </td><td> <span>à</span> </td></tr><tr id="entity-alefsym"><td> <code>alefsym;</code> </td><td> U+02135 </td><td> <span class="glyph">ℵ</span> </td></tr><tr id="entity-aleph"><td> <code>aleph;</code> </td><td> U+02135 </td><td> <span class="glyph">ℵ</span> </td></tr><tr id="entity-Alpha"><td> <code>Alpha;</code> </td><td> U+00391 </td><td> <span class="glyph">Α</span> </td></tr><tr id="entity-alpha"><td> <code>alpha;</code> </td><td> U+003B1 </td><td> <span class="glyph">α</span> </td></tr><tr id="entity-Amacr"><td> <code>Amacr;</code> </td><td> U+00100 </td><td> <span class="glyph">Ā</span> </td></tr><tr id="entity-amacr"><td> <code>amacr;</code> </td><td> U+00101 </td><td> <span class="glyph">ā</span> </td></tr><tr id="entity-amalg"><td> <code>amalg;</code> </td><td> U+02A3F </td><td> <span class="glyph">⨿</span> </td></tr><tr id="entity-AMP"><td> <code>AMP;</code> </td><td> U+00026 </td><td> <span class="glyph">&amp;</span> </td></tr><tr id="entity-AMP-legacy" class="impl"><td> <code>AMP</code> </td><td> U+00026 </td><td> <span>&amp;</span> </td></tr><tr id="entity-amp"><td> <code>amp;</code> </td><td> U+00026 </td><td> <span class="glyph">&amp;</span> </td></tr><tr id="entity-amp-legacy" class="impl"><td> <code>amp</code> </td><td> U+00026 </td><td> <span>&amp;</span> </td></tr><tr id="entity-And"><td> <code>And;</code> </td><td> U+02A53 </td><td> <span class="glyph">⩓</span> </td></tr><tr id="entity-and"><td> <code>and;</code> </td><td> U+02227 </td><td> <span class="glyph">∧</span> </td></tr><tr id="entity-andand"><td> <code>andand;</code> </td><td> U+02A55 </td><td> <span class="glyph">⩕</span> </td></tr><tr id="entity-andd"><td> <code>andd;</code> </td><td> U+02A5C </td><td> <span class="glyph">⩜</span> </td></tr><tr id="entity-andslope"><td> <code>andslope;</code> </td><td> U+02A58 </td><td> <span class="glyph">⩘</span> </td></tr><tr id="entity-andv"><td> <code>andv;</code> </td><td> U+02A5A </td><td> <span class="glyph">⩚</span> </td></tr><tr id="entity-ang"><td> <code>ang;</code> </td><td> U+02220 </td><td> <span class="glyph">∠</span> </td></tr><tr id="entity-ange"><td> <code>ange;</code> </td><td> U+029A4 </td><td> <span class="glyph">⦤</span> </td></tr><tr id="entity-angle"><td> <code>angle;</code> </td><td> U+02220 </td><td> <span class="glyph">∠</span> </td></tr><tr id="entity-angmsd"><td> <code>angmsd;</code> </td><td> U+02221 </td><td> <span class="glyph">∡</span> </td></tr><tr id="entity-angmsdaa"><td> <code>angmsdaa;</code> </td><td> U+029A8 </td><td> <span class="glyph">⦨</span> </td></tr><tr id="entity-angmsdab"><td> <code>angmsdab;</code> </td><td> U+029A9 </td><td> <span class="glyph">⦩</span> </td></tr><tr id="entity-angmsdac"><td> <code>angmsdac;</code> </td><td> U+029AA </td><td> <span class="glyph">⦪</span> </td></tr><tr id="entity-angmsdad"><td> <code>angmsdad;</code> </td><td> U+029AB </td><td> <span class="glyph">⦫</span> </td></tr><tr id="entity-angmsdae"><td> <code>angmsdae;</code> </td><td> U+029AC </td><td> <span class="glyph">⦬</span> </td></tr><tr id="entity-angmsdaf"><td> <code>angmsdaf;</code> </td><td> U+029AD </td><td> <span class="glyph">⦭</span> </td></tr><tr id="entity-angmsdag"><td> <code>angmsdag;</code> </td><td> U+029AE </td><td> <span class="glyph">⦮</span> </td></tr><tr id="entity-angmsdah"><td> <code>angmsdah;</code> </td><td> U+029AF </td><td> <span class="glyph">⦯</span> </td></tr><tr id="entity-angrt"><td> <code>angrt;</code> </td><td> U+0221F </td><td> <span class="glyph">∟</span> </td></tr><tr id="entity-angrtvb"><td> <code>angrtvb;</code> </td><td> U+022BE </td><td> <span class="glyph">⊾</span> </td></tr><tr id="entity-angrtvbd"><td> <code>angrtvbd;</code> </td><td> U+0299D </td><td> <span class="glyph">⦝</span> </td></tr><tr id="entity-angsph"><td> <code>angsph;</code> </td><td> U+02222 </td><td> <span class="glyph">∢</span> </td></tr><tr id="entity-angst"><td> <code>angst;</code> </td><td> U+000C5 </td><td> <span class="glyph">Å</span> </td></tr><tr id="entity-angzarr"><td> <code>angzarr;</code> </td><td> U+0237C </td><td> <span class="glyph">⍼</span> </td></tr><tr id="entity-Aogon"><td> <code>Aogon;</code> </td><td> U+00104 </td><td> <span class="glyph">Ą</span> </td></tr><tr id="entity-aogon"><td> <code>aogon;</code> </td><td> U+00105 </td><td> <span class="glyph">ą</span> </td></tr><tr id="entity-Aopf"><td> <code>Aopf;</code> </td><td> U+1D538 </td><td> <span class="glyph">𝔸</span> </td></tr><tr id="entity-aopf"><td> <code>aopf;</code> </td><td> U+1D552 </td><td> <span class="glyph">𝕒</span> </td></tr><tr id="entity-ap"><td> <code>ap;</code> </td><td> U+02248 </td><td> <span class="glyph">≈</span> </td></tr><tr id="entity-apacir"><td> <code>apacir;</code> </td><td> U+02A6F </td><td> <span class="glyph">⩯</span> </td></tr><tr id="entity-apE"><td> <code>apE;</code> </td><td> U+02A70 </td><td> <span class="glyph">⩰</span> </td></tr><tr id="entity-ape"><td> <code>ape;</code> </td><td> U+0224A </td><td> <span class="glyph">≊</span> </td></tr><tr id="entity-apid"><td> <code>apid;</code> </td><td> U+0224B </td><td> <span class="glyph">≋</span> </td></tr><tr id="entity-apos"><td> <code>apos;</code> </td><td> U+00027 </td><td> <span class="glyph">'</span> </td></tr><tr id="entity-ApplyFunction"><td> <code>ApplyFunction;</code> </td><td> U+02061 </td><td> <span class="glyph">⁡</span> </td></tr><tr id="entity-approx"><td> <code>approx;</code> </td><td> U+02248 </td><td> <span class="glyph">≈</span> </td></tr><tr id="entity-approxeq"><td> <code>approxeq;</code> </td><td> U+0224A </td><td> <span class="glyph">≊</span> </td></tr><tr id="entity-Aring"><td> <code>Aring;</code> </td><td> U+000C5 </td><td> <span class="glyph">Å</span> </td></tr><tr id="entity-Aring-legacy" class="impl"><td> <code>Aring</code> </td><td> U+000C5 </td><td> <span>Å</span> </td></tr><tr id="entity-aring"><td> <code>aring;</code> </td><td> U+000E5 </td><td> <span class="glyph">å</span> </td></tr><tr id="entity-aring-legacy" class="impl"><td> <code>aring</code> </td><td> U+000E5 </td><td> <span>å</span> </td></tr><tr id="entity-Ascr"><td> <code>Ascr;</code> </td><td> U+1D49C </td><td> <span class="glyph">𝒜</span> </td></tr><tr id="entity-ascr"><td> <code>ascr;</code> </td><td> U+1D4B6 </td><td> <span class="glyph">𝒶</span> </td></tr><tr id="entity-Assign"><td> <code>Assign;</code> </td><td> U+02254 </td><td> <span class="glyph">≔</span> </td></tr><tr id="entity-ast"><td> <code>ast;</code> </td><td> U+0002A </td><td> <span class="glyph">*</span> </td></tr><tr id="entity-asymp"><td> <code>asymp;</code> </td><td> U+02248 </td><td> <span class="glyph">≈</span> </td></tr><tr id="entity-asympeq"><td> <code>asympeq;</code> </td><td> U+0224D </td><td> <span class="glyph">≍</span> </td></tr><tr id="entity-Atilde"><td> <code>Atilde;</code> </td><td> U+000C3 </td><td> <span class="glyph">Ã</span> </td></tr><tr id="entity-Atilde-legacy" class="impl"><td> <code>Atilde</code> </td><td> U+000C3 </td><td> <span>Ã</span> </td></tr><tr id="entity-atilde"><td> <code>atilde;</code> </td><td> U+000E3 </td><td> <span class="glyph">ã</span> </td></tr><tr id="entity-atilde-legacy" class="impl"><td> <code>atilde</code> </td><td> U+000E3 </td><td> <span>ã</span> </td></tr><tr id="entity-Auml"><td> <code>Auml;</code> </td><td> U+000C4 </td><td> <span class="glyph">Ä</span> </td></tr><tr id="entity-Auml-legacy" class="impl"><td> <code>Auml</code> </td><td> U+000C4 </td><td> <span>Ä</span> </td></tr><tr id="entity-auml"><td> <code>auml;</code> </td><td> U+000E4 </td><td> <span class="glyph">ä</span> </td></tr><tr id="entity-auml-legacy" class="impl"><td> <code>auml</code> </td><td> U+000E4 </td><td> <span>ä</span> </td></tr><tr id="entity-awconint"><td> <code>awconint;</code> </td><td> U+02233 </td><td> <span class="glyph">∳</span> </td></tr><tr id="entity-awint"><td> <code>awint;</code> </td><td> U+02A11 </td><td> <span class="glyph">⨑</span> </td></tr><tr id="entity-backcong"><td> <code>backcong;</code> </td><td> U+0224C </td><td> <span class="glyph">≌</span> </td></tr><tr id="entity-backepsilon"><td> <code>backepsilon;</code> </td><td> U+003F6 </td><td> <span class="glyph">϶</span> </td></tr><tr id="entity-backprime"><td> <code>backprime;</code> </td><td> U+02035 </td><td> <span class="glyph">‵</span> </td></tr><tr id="entity-backsim"><td> <code>backsim;</code> </td><td> U+0223D </td><td> <span class="glyph">∽</span> </td></tr><tr id="entity-backsimeq"><td> <code>backsimeq;</code> </td><td> U+022CD </td><td> <span class="glyph">⋍</span> </td></tr><tr id="entity-Backslash"><td> <code>Backslash;</code> </td><td> U+02216 </td><td> <span class="glyph">∖</span> </td></tr><tr id="entity-Barv"><td> <code>Barv;</code> </td><td> U+02AE7 </td><td> <span class="glyph">⫧</span> </td></tr><tr id="entity-barvee"><td> <code>barvee;</code> </td><td> U+022BD </td><td> <span class="glyph">⊽</span> </td></tr><tr id="entity-Barwed"><td> <code>Barwed;</code> </td><td> U+02306 </td><td> <span class="glyph">⌆</span> </td></tr><tr id="entity-barwed"><td> <code>barwed;</code> </td><td> U+02305 </td><td> <span class="glyph">⌅</span> </td></tr><tr id="entity-barwedge"><td> <code>barwedge;</code> </td><td> U+02305 </td><td> <span class="glyph">⌅</span> </td></tr><tr id="entity-bbrk"><td> <code>bbrk;</code> </td><td> U+023B5 </td><td> <span class="glyph">⎵</span> </td></tr><tr id="entity-bbrktbrk"><td> <code>bbrktbrk;</code> </td><td> U+023B6 </td><td> <span class="glyph">⎶</span> </td></tr><tr id="entity-bcong"><td> <code>bcong;</code> </td><td> U+0224C </td><td> <span class="glyph">≌</span> </td></tr><tr id="entity-Bcy"><td> <code>Bcy;</code> </td><td> U+00411 </td><td> <span class="glyph">Б</span> </td></tr><tr id="entity-bcy"><td> <code>bcy;</code> </td><td> U+00431 </td><td> <span class="glyph">б</span> </td></tr><tr id="entity-bdquo"><td> <code>bdquo;</code> </td><td> U+0201E </td><td> <span class="glyph">„</span> </td></tr><tr id="entity-becaus"><td> <code>becaus;</code> </td><td> U+02235 </td><td> <span class="glyph">∵</span> </td></tr><tr id="entity-Because"><td> <code>Because;</code> </td><td> U+02235 </td><td> <span class="glyph">∵</span> </td></tr><tr id="entity-because"><td> <code>because;</code> </td><td> U+02235 </td><td> <span class="glyph">∵</span> </td></tr><tr id="entity-bemptyv"><td> <code>bemptyv;</code> </td><td> U+029B0 </td><td> <span class="glyph">⦰</span> </td></tr><tr id="entity-bepsi"><td> <code>bepsi;</code> </td><td> U+003F6 </td><td> <span class="glyph">϶</span> </td></tr><tr id="entity-bernou"><td> <code>bernou;</code> </td><td> U+0212C </td><td> <span class="glyph">ℬ</span> </td></tr><tr id="entity-Bernoullis"><td> <code>Bernoullis;</code> </td><td> U+0212C </td><td> <span class="glyph">ℬ</span> </td></tr><tr id="entity-Beta"><td> <code>Beta;</code> </td><td> U+00392 </td><td> <span class="glyph">Β</span> </td></tr><tr id="entity-beta"><td> <code>beta;</code> </td><td> U+003B2 </td><td> <span class="glyph">β</span> </td></tr><tr id="entity-beth"><td> <code>beth;</code> </td><td> U+02136 </td><td> <span class="glyph">ℶ</span> </td></tr><tr id="entity-between"><td> <code>between;</code> </td><td> U+0226C </td><td> <span class="glyph">≬</span> </td></tr><tr id="entity-Bfr"><td> <code>Bfr;</code> </td><td> U+1D505 </td><td> <span class="glyph">𝔅</span> </td></tr><tr id="entity-bfr"><td> <code>bfr;</code> </td><td> U+1D51F </td><td> <span class="glyph">𝔟</span> </td></tr><tr id="entity-bigcap"><td> <code>bigcap;</code> </td><td> U+022C2 </td><td> <span class="glyph">⋂</span> </td></tr><tr id="entity-bigcirc"><td> <code>bigcirc;</code> </td><td> U+025EF </td><td> <span class="glyph">◯</span> </td></tr><tr id="entity-bigcup"><td> <code>bigcup;</code> </td><td> U+022C3 </td><td> <span class="glyph">⋃</span> </td></tr><tr id="entity-bigodot"><td> <code>bigodot;</code> </td><td> U+02A00 </td><td> <span class="glyph">⨀</span> </td></tr><tr id="entity-bigoplus"><td> <code>bigoplus;</code> </td><td> U+02A01 </td><td> <span class="glyph">⨁</span> </td></tr><tr id="entity-bigotimes"><td> <code>bigotimes;</code> </td><td> U+02A02 </td><td> <span class="glyph">⨂</span> </td></tr><tr id="entity-bigsqcup"><td> <code>bigsqcup;</code> </td><td> U+02A06 </td><td> <span class="glyph">⨆</span> </td></tr><tr id="entity-bigstar"><td> <code>bigstar;</code> </td><td> U+02605 </td><td> <span class="glyph">★</span> </td></tr><tr id="entity-bigtriangledown"><td> <code>bigtriangledown;</code> </td><td> U+025BD </td><td> <span class="glyph">▽</span> </td></tr><tr id="entity-bigtriangleup"><td> <code>bigtriangleup;</code> </td><td> U+025B3 </td><td> <span class="glyph">△</span> </td></tr><tr id="entity-biguplus"><td> <code>biguplus;</code> </td><td> U+02A04 </td><td> <span class="glyph">⨄</span> </td></tr><tr id="entity-bigvee"><td> <code>bigvee;</code> </td><td> U+022C1 </td><td> <span class="glyph">⋁</span> </td></tr><tr id="entity-bigwedge"><td> <code>bigwedge;</code> </td><td> U+022C0 </td><td> <span class="glyph">⋀</span> </td></tr><tr id="entity-bkarow"><td> <code>bkarow;</code> </td><td> U+0290D </td><td> <span class="glyph">⤍</span> </td></tr><tr id="entity-blacklozenge"><td> <code>blacklozenge;</code> </td><td> U+029EB </td><td> <span class="glyph">⧫</span> </td></tr><tr id="entity-blacksquare"><td> <code>blacksquare;</code> </td><td> U+025AA </td><td> <span class="glyph">▪</span> </td></tr><tr id="entity-blacktriangle"><td> <code>blacktriangle;</code> </td><td> U+025B4 </td><td> <span class="glyph">▴</span> </td></tr><tr id="entity-blacktriangledown"><td> <code>blacktriangledown;</code> </td><td> U+025BE </td><td> <span class="glyph">▾</span> </td></tr><tr id="entity-blacktriangleleft"><td> <code>blacktriangleleft;</code> </td><td> U+025C2 </td><td> <span class="glyph">◂</span> </td></tr><tr id="entity-blacktriangleright"><td> <code>blacktriangleright;</code> </td><td> U+025B8 </td><td> <span class="glyph">▸</span> </td></tr><tr id="entity-blank"><td> <code>blank;</code> </td><td> U+02423 </td><td> <span class="glyph">␣</span> </td></tr><tr id="entity-blk12"><td> <code>blk12;</code> </td><td> U+02592 </td><td> <span class="glyph">▒</span> </td></tr><tr id="entity-blk14"><td> <code>blk14;</code> </td><td> U+02591 </td><td> <span class="glyph">░</span> </td></tr><tr id="entity-blk34"><td> <code>blk34;</code> </td><td> U+02593 </td><td> <span class="glyph">▓</span> </td></tr><tr id="entity-block"><td> <code>block;</code> </td><td> U+02588 </td><td> <span class="glyph">█</span> </td></tr><tr id="entity-bne"><td> <code>bne;</code> </td><td> U+0003D U+020E5 </td><td> <span class="glyph compound">=⃥</span> </td></tr><tr id="entity-bnequiv"><td> <code>bnequiv;</code> </td><td> U+02261 U+020E5 </td><td> <span class="glyph compound">≡⃥</span> </td></tr><tr id="entity-bNot"><td> <code>bNot;</code> </td><td> U+02AED </td><td> <span class="glyph">⫭</span> </td></tr><tr id="entity-bnot"><td> <code>bnot;</code> </td><td> U+02310 </td><td> <span class="glyph">⌐</span> </td></tr><tr id="entity-Bopf"><td> <code>Bopf;</code> </td><td> U+1D539 </td><td> <span class="glyph">𝔹</span> </td></tr><tr id="entity-bopf"><td> <code>bopf;</code> </td><td> U+1D553 </td><td> <span class="glyph">𝕓</span> </td></tr><tr id="entity-bot"><td> <code>bot;</code> </td><td> U+022A5 </td><td> <span class="glyph">⊥</span> </td></tr><tr id="entity-bottom"><td> <code>bottom;</code> </td><td> U+022A5 </td><td> <span class="glyph">⊥</span> </td></tr><tr id="entity-bowtie"><td> <code>bowtie;</code> </td><td> U+022C8 </td><td> <span class="glyph">⋈</span> </td></tr><tr id="entity-boxbox"><td> <code>boxbox;</code> </td><td> U+029C9 </td><td> <span class="glyph">⧉</span> </td></tr><tr id="entity-boxDL"><td> <code>boxDL;</code> </td><td> U+02557 </td><td> <span class="glyph">╗</span> </td></tr><tr id="entity-boxDl"><td> <code>boxDl;</code> </td><td> U+02556 </td><td> <span class="glyph">╖</span> </td></tr><tr id="entity-boxdL"><td> <code>boxdL;</code> </td><td> U+02555 </td><td> <span class="glyph">╕</span> </td></tr><tr id="entity-boxdl"><td> <code>boxdl;</code> </td><td> U+02510 </td><td> <span class="glyph">┐</span> </td></tr><tr id="entity-boxDR"><td> <code>boxDR;</code> </td><td> U+02554 </td><td> <span class="glyph">╔</span> </td></tr><tr id="entity-boxDr"><td> <code>boxDr;</code> </td><td> U+02553 </td><td> <span class="glyph">╓</span> </td></tr><tr id="entity-boxdR"><td> <code>boxdR;</code> </td><td> U+02552 </td><td> <span class="glyph">╒</span> </td></tr><tr id="entity-boxdr"><td> <code>boxdr;</code> </td><td> U+0250C </td><td> <span class="glyph">┌</span> </td></tr><tr id="entity-boxH"><td> <code>boxH;</code> </td><td> U+02550 </td><td> <span class="glyph">═</span> </td></tr><tr id="entity-boxh"><td> <code>boxh;</code> </td><td> U+02500 </td><td> <span class="glyph">─</span> </td></tr><tr id="entity-boxHD"><td> <code>boxHD;</code> </td><td> U+02566 </td><td> <span class="glyph">╦</span> </td></tr><tr id="entity-boxHd"><td> <code>boxHd;</code> </td><td> U+02564 </td><td> <span class="glyph">╤</span> </td></tr><tr id="entity-boxhD"><td> <code>boxhD;</code> </td><td> U+02565 </td><td> <span class="glyph">╥</span> </td></tr><tr id="entity-boxhd"><td> <code>boxhd;</code> </td><td> U+0252C </td><td> <span class="glyph">┬</span> </td></tr><tr id="entity-boxHU"><td> <code>boxHU;</code> </td><td> U+02569 </td><td> <span class="glyph">╩</span> </td></tr><tr id="entity-boxHu"><td> <code>boxHu;</code> </td><td> U+02567 </td><td> <span class="glyph">╧</span> </td></tr><tr id="entity-boxhU"><td> <code>boxhU;</code> </td><td> U+02568 </td><td> <span class="glyph">╨</span> </td></tr><tr id="entity-boxhu"><td> <code>boxhu;</code> </td><td> U+02534 </td><td> <span class="glyph">┴</span> </td></tr><tr id="entity-boxminus"><td> <code>boxminus;</code> </td><td> U+0229F </td><td> <span class="glyph">⊟</span> </td></tr><tr id="entity-boxplus"><td> <code>boxplus;</code> </td><td> U+0229E </td><td> <span class="glyph">⊞</span> </td></tr><tr id="entity-boxtimes"><td> <code>boxtimes;</code> </td><td> U+022A0 </td><td> <span class="glyph">⊠</span> </td></tr><tr id="entity-boxUL"><td> <code>boxUL;</code> </td><td> U+0255D </td><td> <span class="glyph">╝</span> </td></tr><tr id="entity-boxUl"><td> <code>boxUl;</code> </td><td> U+0255C </td><td> <span class="glyph">╜</span> </td></tr><tr id="entity-boxuL"><td> <code>boxuL;</code> </td><td> U+0255B </td><td> <span class="glyph">╛</span> </td></tr><tr id="entity-boxul"><td> <code>boxul;</code> </td><td> U+02518 </td><td> <span class="glyph">┘</span> </td></tr><tr id="entity-boxUR"><td> <code>boxUR;</code> </td><td> U+0255A </td><td> <span class="glyph">╚</span> </td></tr><tr id="entity-boxUr"><td> <code>boxUr;</code> </td><td> U+02559 </td><td> <span class="glyph">╙</span> </td></tr><tr id="entity-boxuR"><td> <code>boxuR;</code> </td><td> U+02558 </td><td> <span class="glyph">╘</span> </td></tr><tr id="entity-boxur"><td> <code>boxur;</code> </td><td> U+02514 </td><td> <span class="glyph">└</span> </td></tr><tr id="entity-boxV"><td> <code>boxV;</code> </td><td> U+02551 </td><td> <span class="glyph">║</span> </td></tr><tr id="entity-boxv"><td> <code>boxv;</code> </td><td> U+02502 </td><td> <span class="glyph">│</span> </td></tr><tr id="entity-boxVH"><td> <code>boxVH;</code> </td><td> U+0256C </td><td> <span class="glyph">╬</span> </td></tr><tr id="entity-boxVh"><td> <code>boxVh;</code> </td><td> U+0256B </td><td> <span class="glyph">╫</span> </td></tr><tr id="entity-boxvH"><td> <code>boxvH;</code> </td><td> U+0256A </td><td> <span class="glyph">╪</span> </td></tr><tr id="entity-boxvh"><td> <code>boxvh;</code> </td><td> U+0253C </td><td> <span class="glyph">┼</span> </td></tr><tr id="entity-boxVL"><td> <code>boxVL;</code> </td><td> U+02563 </td><td> <span class="glyph">╣</span> </td></tr><tr id="entity-boxVl"><td> <code>boxVl;</code> </td><td> U+02562 </td><td> <span class="glyph">╢</span> </td></tr><tr id="entity-boxvL"><td> <code>boxvL;</code> </td><td> U+02561 </td><td> <span class="glyph">╡</span> </td></tr><tr id="entity-boxvl"><td> <code>boxvl;</code> </td><td> U+02524 </td><td> <span class="glyph">┤</span> </td></tr><tr id="entity-boxVR"><td> <code>boxVR;</code> </td><td> U+02560 </td><td> <span class="glyph">╠</span> </td></tr><tr id="entity-boxVr"><td> <code>boxVr;</code> </td><td> U+0255F </td><td> <span class="glyph">╟</span> </td></tr><tr id="entity-boxvR"><td> <code>boxvR;</code> </td><td> U+0255E </td><td> <span class="glyph">╞</span> </td></tr><tr id="entity-boxvr"><td> <code>boxvr;</code> </td><td> U+0251C </td><td> <span class="glyph">├</span> </td></tr><tr id="entity-bprime"><td> <code>bprime;</code> </td><td> U+02035 </td><td> <span class="glyph">‵</span> </td></tr><tr id="entity-Breve"><td> <code>Breve;</code> </td><td> U+002D8 </td><td> <span class="glyph">˘</span> </td></tr><tr id="entity-breve"><td> <code>breve;</code> </td><td> U+002D8 </td><td> <span class="glyph">˘</span> </td></tr><tr id="entity-brvbar"><td> <code>brvbar;</code> </td><td> U+000A6 </td><td> <span class="glyph">¦</span> </td></tr><tr id="entity-brvbar-legacy" class="impl"><td> <code>brvbar</code> </td><td> U+000A6 </td><td> <span>¦</span> </td></tr><tr id="entity-Bscr"><td> <code>Bscr;</code> </td><td> U+0212C </td><td> <span class="glyph">ℬ</span> </td></tr><tr id="entity-bscr"><td> <code>bscr;</code> </td><td> U+1D4B7 </td><td> <span class="glyph">𝒷</span> </td></tr><tr id="entity-bsemi"><td> <code>bsemi;</code> </td><td> U+0204F </td><td> <span class="glyph">⁏</span> </td></tr><tr id="entity-bsim"><td> <code>bsim;</code> </td><td> U+0223D </td><td> <span class="glyph">∽</span> </td></tr><tr id="entity-bsime"><td> <code>bsime;</code> </td><td> U+022CD </td><td> <span class="glyph">⋍</span> </td></tr><tr id="entity-bsol"><td> <code>bsol;</code> </td><td> U+0005C </td><td> <span class="glyph">\</span> </td></tr><tr id="entity-bsolb"><td> <code>bsolb;</code> </td><td> U+029C5 </td><td> <span class="glyph">⧅</span> </td></tr><tr id="entity-bsolhsub"><td> <code>bsolhsub;</code> </td><td> U+027C8 </td><td> <span class="glyph">⟈</span> </td></tr><tr id="entity-bull"><td> <code>bull;</code> </td><td> U+02022 </td><td> <span class="glyph">•</span> </td></tr><tr id="entity-bullet"><td> <code>bullet;</code> </td><td> U+02022 </td><td> <span class="glyph">•</span> </td></tr><tr id="entity-bump"><td> <code>bump;</code> </td><td> U+0224E </td><td> <span class="glyph">≎</span> </td></tr><tr id="entity-bumpE"><td> <code>bumpE;</code> </td><td> U+02AAE </td><td> <span class="glyph">⪮</span> </td></tr><tr id="entity-bumpe"><td> <code>bumpe;</code> </td><td> U+0224F </td><td> <span class="glyph">≏</span> </td></tr><tr id="entity-Bumpeq"><td> <code>Bumpeq;</code> </td><td> U+0224E </td><td> <span class="glyph">≎</span> </td></tr><tr id="entity-bumpeq"><td> <code>bumpeq;</code> </td><td> U+0224F </td><td> <span class="glyph">≏</span> </td></tr><tr id="entity-Cacute"><td> <code>Cacute;</code> </td><td> U+00106 </td><td> <span class="glyph">Ć</span> </td></tr><tr id="entity-cacute"><td> <code>cacute;</code> </td><td> U+00107 </td><td> <span class="glyph">ć</span> </td></tr><tr id="entity-Cap"><td> <code>Cap;</code> </td><td> U+022D2 </td><td> <span class="glyph">⋒</span> </td></tr><tr id="entity-cap"><td> <code>cap;</code> </td><td> U+02229 </td><td> <span class="glyph">∩</span> </td></tr><tr id="entity-capand"><td> <code>capand;</code> </td><td> U+02A44 </td><td> <span class="glyph">⩄</span> </td></tr><tr id="entity-capbrcup"><td> <code>capbrcup;</code> </td><td> U+02A49 </td><td> <span class="glyph">⩉</span> </td></tr><tr id="entity-capcap"><td> <code>capcap;</code> </td><td> U+02A4B </td><td> <span class="glyph">⩋</span> </td></tr><tr id="entity-capcup"><td> <code>capcup;</code> </td><td> U+02A47 </td><td> <span class="glyph">⩇</span> </td></tr><tr id="entity-capdot"><td> <code>capdot;</code> </td><td> U+02A40 </td><td> <span class="glyph">⩀</span> </td></tr><tr id="entity-CapitalDifferentialD"><td> <code>CapitalDifferentialD;</code> </td><td> U+02145 </td><td> <span class="glyph">ⅅ</span> </td></tr><tr id="entity-caps"><td> <code>caps;</code> </td><td> U+02229 U+0FE00 </td><td> <span class="glyph compound">∩︀</span> </td></tr><tr id="entity-caret"><td> <code>caret;</code> </td><td> U+02041 </td><td> <span class="glyph">⁁</span> </td></tr><tr id="entity-caron"><td> <code>caron;</code> </td><td> U+002C7 </td><td> <span class="glyph">ˇ</span> </td></tr><tr id="entity-Cayleys"><td> <code>Cayleys;</code> </td><td> U+0212D </td><td> <span class="glyph">ℭ</span> </td></tr><tr id="entity-ccaps"><td> <code>ccaps;</code> </td><td> U+02A4D </td><td> <span class="glyph">⩍</span> </td></tr><tr id="entity-Ccaron"><td> <code>Ccaron;</code> </td><td> U+0010C </td><td> <span class="glyph">Č</span> </td></tr><tr id="entity-ccaron"><td> <code>ccaron;</code> </td><td> U+0010D </td><td> <span class="glyph">č</span> </td></tr><tr id="entity-Ccedil"><td> <code>Ccedil;</code> </td><td> U+000C7 </td><td> <span class="glyph">Ç</span> </td></tr><tr id="entity-Ccedil-legacy" class="impl"><td> <code>Ccedil</code> </td><td> U+000C7 </td><td> <span>Ç</span> </td></tr><tr id="entity-ccedil"><td> <code>ccedil;</code> </td><td> U+000E7 </td><td> <span class="glyph">ç</span> </td></tr><tr id="entity-ccedil-legacy" class="impl"><td> <code>ccedil</code> </td><td> U+000E7 </td><td> <span>ç</span> </td></tr><tr id="entity-Ccirc"><td> <code>Ccirc;</code> </td><td> U+00108 </td><td> <span class="glyph">Ĉ</span> </td></tr><tr id="entity-ccirc"><td> <code>ccirc;</code> </td><td> U+00109 </td><td> <span class="glyph">ĉ</span> </td></tr><tr id="entity-Cconint"><td> <code>Cconint;</code> </td><td> U+02230 </td><td> <span class="glyph">∰</span> </td></tr><tr id="entity-ccups"><td> <code>ccups;</code> </td><td> U+02A4C </td><td> <span class="glyph">⩌</span> </td></tr><tr id="entity-ccupssm"><td> <code>ccupssm;</code> </td><td> U+02A50 </td><td> <span class="glyph">⩐</span> </td></tr><tr id="entity-Cdot"><td> <code>Cdot;</code> </td><td> U+0010A </td><td> <span class="glyph">Ċ</span> </td></tr><tr id="entity-cdot"><td> <code>cdot;</code> </td><td> U+0010B </td><td> <span class="glyph">ċ</span> </td></tr><tr id="entity-cedil"><td> <code>cedil;</code> </td><td> U+000B8 </td><td> <span class="glyph">¸</span> </td></tr><tr id="entity-cedil-legacy" class="impl"><td> <code>cedil</code> </td><td> U+000B8 </td><td> <span>¸</span> </td></tr><tr id="entity-Cedilla"><td> <code>Cedilla;</code> </td><td> U+000B8 </td><td> <span class="glyph">¸</span> </td></tr><tr id="entity-cemptyv"><td> <code>cemptyv;</code> </td><td> U+029B2 </td><td> <span class="glyph">⦲</span> </td></tr><tr id="entity-cent"><td> <code>cent;</code> </td><td> U+000A2 </td><td> <span class="glyph">¢</span> </td></tr><tr id="entity-cent-legacy" class="impl"><td> <code>cent</code> </td><td> U+000A2 </td><td> <span>¢</span> </td></tr><tr id="entity-CenterDot"><td> <code>CenterDot;</code> </td><td> U+000B7 </td><td> <span class="glyph">·</span> </td></tr><tr id="entity-centerdot"><td> <code>centerdot;</code> </td><td> U+000B7 </td><td> <span class="glyph">·</span> </td></tr><tr id="entity-Cfr"><td> <code>Cfr;</code> </td><td> U+0212D </td><td> <span class="glyph">ℭ</span> </td></tr><tr id="entity-cfr"><td> <code>cfr;</code> </td><td> U+1D520 </td><td> <span class="glyph">𝔠</span> </td></tr><tr id="entity-CHcy"><td> <code>CHcy;</code> </td><td> U+00427 </td><td> <span class="glyph">Ч</span> </td></tr><tr id="entity-chcy"><td> <code>chcy;</code> </td><td> U+00447 </td><td> <span class="glyph">ч</span> </td></tr><tr id="entity-check"><td> <code>check;</code> </td><td> U+02713 </td><td> <span class="glyph">✓</span> </td></tr><tr id="entity-checkmark"><td> <code>checkmark;</code> </td><td> U+02713 </td><td> <span class="glyph">✓</span> </td></tr><tr id="entity-Chi"><td> <code>Chi;</code> </td><td> U+003A7 </td><td> <span class="glyph">Χ</span> </td></tr><tr id="entity-chi"><td> <code>chi;</code> </td><td> U+003C7 </td><td> <span class="glyph">χ</span> </td></tr><tr id="entity-cir"><td> <code>cir;</code> </td><td> U+025CB </td><td> <span class="glyph">○</span> </td></tr><tr id="entity-circ"><td> <code>circ;</code> </td><td> U+002C6 </td><td> <span class="glyph">ˆ</span> </td></tr><tr id="entity-circeq"><td> <code>circeq;</code> </td><td> U+02257 </td><td> <span class="glyph">≗</span> </td></tr><tr id="entity-circlearrowleft"><td> <code>circlearrowleft;</code> </td><td> U+021BA </td><td> <span class="glyph">↺</span> </td></tr><tr id="entity-circlearrowright"><td> <code>circlearrowright;</code> </td><td> U+021BB </td><td> <span class="glyph">↻</span> </td></tr><tr id="entity-circledast"><td> <code>circledast;</code> </td><td> U+0229B </td><td> <span class="glyph">⊛</span> </td></tr><tr id="entity-circledcirc"><td> <code>circledcirc;</code> </td><td> U+0229A </td><td> <span class="glyph">⊚</span> </td></tr><tr id="entity-circleddash"><td> <code>circleddash;</code> </td><td> U+0229D </td><td> <span class="glyph">⊝</span> </td></tr><tr id="entity-CircleDot"><td> <code>CircleDot;</code> </td><td> U+02299 </td><td> <span class="glyph">⊙</span> </td></tr><tr id="entity-circledR"><td> <code>circledR;</code> </td><td> U+000AE </td><td> <span class="glyph">®</span> </td></tr><tr id="entity-circledS"><td> <code>circledS;</code> </td><td> U+024C8 </td><td> <span class="glyph">Ⓢ</span> </td></tr><tr id="entity-CircleMinus"><td> <code>CircleMinus;</code> </td><td> U+02296 </td><td> <span class="glyph">⊖</span> </td></tr><tr id="entity-CirclePlus"><td> <code>CirclePlus;</code> </td><td> U+02295 </td><td> <span class="glyph">⊕</span> </td></tr><tr id="entity-CircleTimes"><td> <code>CircleTimes;</code> </td><td> U+02297 </td><td> <span class="glyph">⊗</span> </td></tr><tr id="entity-cirE"><td> <code>cirE;</code> </td><td> U+029C3 </td><td> <span class="glyph">⧃</span> </td></tr><tr id="entity-cire"><td> <code>cire;</code> </td><td> U+02257 </td><td> <span class="glyph">≗</span> </td></tr><tr id="entity-cirfnint"><td> <code>cirfnint;</code> </td><td> U+02A10 </td><td> <span class="glyph">⨐</span> </td></tr><tr id="entity-cirmid"><td> <code>cirmid;</code> </td><td> U+02AEF </td><td> <span class="glyph">⫯</span> </td></tr><tr id="entity-cirscir"><td> <code>cirscir;</code> </td><td> U+029C2 </td><td> <span class="glyph">⧂</span> </td></tr><tr id="entity-ClockwiseContourIntegral"><td> <code>ClockwiseContourIntegral;</code> </td><td> U+02232 </td><td> <span class="glyph">∲</span> </td></tr><tr id="entity-CloseCurlyDoubleQuote"><td> <code>CloseCurlyDoubleQuote;</code> </td><td> U+0201D </td><td> <span class="glyph">”</span> </td></tr><tr id="entity-CloseCurlyQuote"><td> <code>CloseCurlyQuote;</code> </td><td> U+02019 </td><td> <span class="glyph">’</span> </td></tr><tr id="entity-clubs"><td> <code>clubs;</code> </td><td> U+02663 </td><td> <span class="glyph">♣</span> </td></tr><tr id="entity-clubsuit"><td> <code>clubsuit;</code> </td><td> U+02663 </td><td> <span class="glyph">♣</span> </td></tr><tr id="entity-Colon"><td> <code>Colon;</code> </td><td> U+02237 </td><td> <span class="glyph">∷</span> </td></tr><tr id="entity-colon"><td> <code>colon;</code> </td><td> U+0003A </td><td> <span class="glyph">:</span> </td></tr><tr id="entity-Colone"><td> <code>Colone;</code> </td><td> U+02A74 </td><td> <span class="glyph">⩴</span> </td></tr><tr id="entity-colone"><td> <code>colone;</code> </td><td> U+02254 </td><td> <span class="glyph">≔</span> </td></tr><tr id="entity-coloneq"><td> <code>coloneq;</code> </td><td> U+02254 </td><td> <span class="glyph">≔</span> </td></tr><tr id="entity-comma"><td> <code>comma;</code> </td><td> U+0002C </td><td> <span class="glyph">,</span> </td></tr><tr id="entity-commat"><td> <code>commat;</code> </td><td> U+00040 </td><td> <span class="glyph">@</span> </td></tr><tr id="entity-comp"><td> <code>comp;</code> </td><td> U+02201 </td><td> <span class="glyph">∁</span> </td></tr><tr id="entity-compfn"><td> <code>compfn;</code> </td><td> U+02218 </td><td> <span class="glyph">∘</span> </td></tr><tr id="entity-complement"><td> <code>complement;</code> </td><td> U+02201 </td><td> <span class="glyph">∁</span> </td></tr><tr id="entity-complexes"><td> <code>complexes;</code> </td><td> U+02102 </td><td> <span class="glyph">ℂ</span> </td></tr><tr id="entity-cong"><td> <code>cong;</code> </td><td> U+02245 </td><td> <span class="glyph">≅</span> </td></tr><tr id="entity-congdot"><td> <code>congdot;</code> </td><td> U+02A6D </td><td> <span class="glyph">⩭</span> </td></tr><tr id="entity-Congruent"><td> <code>Congruent;</code> </td><td> U+02261 </td><td> <span class="glyph">≡</span> </td></tr><tr id="entity-Conint"><td> <code>Conint;</code> </td><td> U+0222F </td><td> <span class="glyph">∯</span> </td></tr><tr id="entity-conint"><td> <code>conint;</code> </td><td> U+0222E </td><td> <span class="glyph">∮</span> </td></tr><tr id="entity-ContourIntegral"><td> <code>ContourIntegral;</code> </td><td> U+0222E </td><td> <span class="glyph">∮</span> </td></tr><tr id="entity-Copf"><td> <code>Copf;</code> </td><td> U+02102 </td><td> <span class="glyph">ℂ</span> </td></tr><tr id="entity-copf"><td> <code>copf;</code> </td><td> U+1D554 </td><td> <span class="glyph">𝕔</span> </td></tr><tr id="entity-coprod"><td> <code>coprod;</code> </td><td> U+02210 </td><td> <span class="glyph">∐</span> </td></tr><tr id="entity-Coproduct"><td> <code>Coproduct;</code> </td><td> U+02210 </td><td> <span class="glyph">∐</span> </td></tr><tr id="entity-COPY"><td> <code>COPY;</code> </td><td> U+000A9 </td><td> <span class="glyph">©</span> </td></tr><tr id="entity-COPY-legacy" class="impl"><td> <code>COPY</code> </td><td> U+000A9 </td><td> <span>©</span> </td></tr><tr id="entity-copy"><td> <code>copy;</code> </td><td> U+000A9 </td><td> <span class="glyph">©</span> </td></tr><tr id="entity-copy-legacy" class="impl"><td> <code>copy</code> </td><td> U+000A9 </td><td> <span>©</span> </td></tr><tr id="entity-copysr"><td> <code>copysr;</code> </td><td> U+02117 </td><td> <span class="glyph">℗</span> </td></tr><tr id="entity-CounterClockwiseContourIntegral"><td> <code>CounterClockwiseContourIntegral;</code> </td><td> U+02233 </td><td> <span class="glyph">∳</span> </td></tr><tr id="entity-crarr"><td> <code>crarr;</code> </td><td> U+021B5 </td><td> <span class="glyph">↵</span> </td></tr><tr id="entity-Cross"><td> <code>Cross;</code> </td><td> U+02A2F </td><td> <span class="glyph">⨯</span> </td></tr><tr id="entity-cross"><td> <code>cross;</code> </td><td> U+02717 </td><td> <span class="glyph">✗</span> </td></tr><tr id="entity-Cscr"><td> <code>Cscr;</code> </td><td> U+1D49E </td><td> <span class="glyph">𝒞</span> </td></tr><tr id="entity-cscr"><td> <code>cscr;</code> </td><td> U+1D4B8 </td><td> <span class="glyph">𝒸</span> </td></tr><tr id="entity-csub"><td> <code>csub;</code> </td><td> U+02ACF </td><td> <span class="glyph">⫏</span> </td></tr><tr id="entity-csube"><td> <code>csube;</code> </td><td> U+02AD1 </td><td> <span class="glyph">⫑</span> </td></tr><tr id="entity-csup"><td> <code>csup;</code> </td><td> U+02AD0 </td><td> <span class="glyph">⫐</span> </td></tr><tr id="entity-csupe"><td> <code>csupe;</code> </td><td> U+02AD2 </td><td> <span class="glyph">⫒</span> </td></tr><tr id="entity-ctdot"><td> <code>ctdot;</code> </td><td> U+022EF </td><td> <span class="glyph">⋯</span> </td></tr><tr id="entity-cudarrl"><td> <code>cudarrl;</code> </td><td> U+02938 </td><td> <span class="glyph">⤸</span> </td></tr><tr id="entity-cudarrr"><td> <code>cudarrr;</code> </td><td> U+02935 </td><td> <span class="glyph">⤵</span> </td></tr><tr id="entity-cuepr"><td> <code>cuepr;</code> </td><td> U+022DE </td><td> <span class="glyph">⋞</span> </td></tr><tr id="entity-cuesc"><td> <code>cuesc;</code> </td><td> U+022DF </td><td> <span class="glyph">⋟</span> </td></tr><tr id="entity-cularr"><td> <code>cularr;</code> </td><td> U+021B6 </td><td> <span class="glyph">↶</span> </td></tr><tr id="entity-cularrp"><td> <code>cularrp;</code> </td><td> U+0293D </td><td> <span class="glyph">⤽</span> </td></tr><tr id="entity-Cup"><td> <code>Cup;</code> </td><td> U+022D3 </td><td> <span class="glyph">⋓</span> </td></tr><tr id="entity-cup"><td> <code>cup;</code> </td><td> U+0222A </td><td> <span class="glyph">∪</span> </td></tr><tr id="entity-cupbrcap"><td> <code>cupbrcap;</code> </td><td> U+02A48 </td><td> <span class="glyph">⩈</span> </td></tr><tr id="entity-CupCap"><td> <code>CupCap;</code> </td><td> U+0224D </td><td> <span class="glyph">≍</span> </td></tr><tr id="entity-cupcap"><td> <code>cupcap;</code> </td><td> U+02A46 </td><td> <span class="glyph">⩆</span> </td></tr><tr id="entity-cupcup"><td> <code>cupcup;</code> </td><td> U+02A4A </td><td> <span class="glyph">⩊</span> </td></tr><tr id="entity-cupdot"><td> <code>cupdot;</code> </td><td> U+0228D </td><td> <span class="glyph">⊍</span> </td></tr><tr id="entity-cupor"><td> <code>cupor;</code> </td><td> U+02A45 </td><td> <span class="glyph">⩅</span> </td></tr><tr id="entity-cups"><td> <code>cups;</code> </td><td> U+0222A U+0FE00 </td><td> <span class="glyph compound">∪︀</span> </td></tr><tr id="entity-curarr"><td> <code>curarr;</code> </td><td> U+021B7 </td><td> <span class="glyph">↷</span> </td></tr><tr id="entity-curarrm"><td> <code>curarrm;</code> </td><td> U+0293C </td><td> <span class="glyph">⤼</span> </td></tr><tr id="entity-curlyeqprec"><td> <code>curlyeqprec;</code> </td><td> U+022DE </td><td> <span class="glyph">⋞</span> </td></tr><tr id="entity-curlyeqsucc"><td> <code>curlyeqsucc;</code> </td><td> U+022DF </td><td> <span class="glyph">⋟</span> </td></tr><tr id="entity-curlyvee"><td> <code>curlyvee;</code> </td><td> U+022CE </td><td> <span class="glyph">⋎</span> </td></tr><tr id="entity-curlywedge"><td> <code>curlywedge;</code> </td><td> U+022CF </td><td> <span class="glyph">⋏</span> </td></tr><tr id="entity-curren"><td> <code>curren;</code> </td><td> U+000A4 </td><td> <span class="glyph">¤</span> </td></tr><tr id="entity-curren-legacy" class="impl"><td> <code>curren</code> </td><td> U+000A4 </td><td> <span>¤</span> </td></tr><tr id="entity-curvearrowleft"><td> <code>curvearrowleft;</code> </td><td> U+021B6 </td><td> <span class="glyph">↶</span> </td></tr><tr id="entity-curvearrowright"><td> <code>curvearrowright;</code> </td><td> U+021B7 </td><td> <span class="glyph">↷</span> </td></tr><tr id="entity-cuvee"><td> <code>cuvee;</code> </td><td> U+022CE </td><td> <span class="glyph">⋎</span> </td></tr><tr id="entity-cuwed"><td> <code>cuwed;</code> </td><td> U+022CF </td><td> <span class="glyph">⋏</span> </td></tr><tr id="entity-cwconint"><td> <code>cwconint;</code> </td><td> U+02232 </td><td> <span class="glyph">∲</span> </td></tr><tr id="entity-cwint"><td> <code>cwint;</code> </td><td> U+02231 </td><td> <span class="glyph">∱</span> </td></tr><tr id="entity-cylcty"><td> <code>cylcty;</code> </td><td> U+0232D </td><td> <span class="glyph">⌭</span> </td></tr><tr id="entity-Dagger"><td> <code>Dagger;</code> </td><td> U+02021 </td><td> <span class="glyph">‡</span> </td></tr><tr id="entity-dagger"><td> <code>dagger;</code> </td><td> U+02020 </td><td> <span class="glyph">†</span> </td></tr><tr id="entity-daleth"><td> <code>daleth;</code> </td><td> U+02138 </td><td> <span class="glyph">ℸ</span> </td></tr><tr id="entity-Darr"><td> <code>Darr;</code> </td><td> U+021A1 </td><td> <span class="glyph">↡</span> </td></tr><tr id="entity-dArr"><td> <code>dArr;</code> </td><td> U+021D3 </td><td> <span class="glyph">⇓</span> </td></tr><tr id="entity-darr"><td> <code>darr;</code> </td><td> U+02193 </td><td> <span class="glyph">↓</span> </td></tr><tr id="entity-dash"><td> <code>dash;</code> </td><td> U+02010 </td><td> <span class="glyph">‐</span> </td></tr><tr id="entity-Dashv"><td> <code>Dashv;</code> </td><td> U+02AE4 </td><td> <span class="glyph">⫤</span> </td></tr><tr id="entity-dashv"><td> <code>dashv;</code> </td><td> U+022A3 </td><td> <span class="glyph">⊣</span> </td></tr><tr id="entity-dbkarow"><td> <code>dbkarow;</code> </td><td> U+0290F </td><td> <span class="glyph">⤏</span> </td></tr><tr id="entity-dblac"><td> <code>dblac;</code> </td><td> U+002DD </td><td> <span class="glyph">˝</span> </td></tr><tr id="entity-Dcaron"><td> <code>Dcaron;</code> </td><td> U+0010E </td><td> <span class="glyph">Ď</span> </td></tr><tr id="entity-dcaron"><td> <code>dcaron;</code> </td><td> U+0010F </td><td> <span class="glyph">ď</span> </td></tr><tr id="entity-Dcy"><td> <code>Dcy;</code> </td><td> U+00414 </td><td> <span class="glyph">Д</span> </td></tr><tr id="entity-dcy"><td> <code>dcy;</code> </td><td> U+00434 </td><td> <span class="glyph">д</span> </td></tr><tr id="entity-DD"><td> <code>DD;</code> </td><td> U+02145 </td><td> <span class="glyph">ⅅ</span> </td></tr><tr id="entity-dd"><td> <code>dd;</code> </td><td> U+02146 </td><td> <span class="glyph">ⅆ</span> </td></tr><tr id="entity-ddagger"><td> <code>ddagger;</code> </td><td> U+02021 </td><td> <span class="glyph">‡</span> </td></tr><tr id="entity-ddarr"><td> <code>ddarr;</code> </td><td> U+021CA </td><td> <span class="glyph">⇊</span> </td></tr><tr id="entity-DDotrahd"><td> <code>DDotrahd;</code> </td><td> U+02911 </td><td> <span class="glyph">⤑</span> </td></tr><tr id="entity-ddotseq"><td> <code>ddotseq;</code> </td><td> U+02A77 </td><td> <span class="glyph">⩷</span> </td></tr><tr id="entity-deg"><td> <code>deg;</code> </td><td> U+000B0 </td><td> <span class="glyph">°</span> </td></tr><tr id="entity-deg-legacy" class="impl"><td> <code>deg</code> </td><td> U+000B0 </td><td> <span>°</span> </td></tr><tr id="entity-Del"><td> <code>Del;</code> </td><td> U+02207 </td><td> <span class="glyph">∇</span> </td></tr><tr id="entity-Delta"><td> <code>Delta;</code> </td><td> U+00394 </td><td> <span class="glyph">Δ</span> </td></tr><tr id="entity-delta"><td> <code>delta;</code> </td><td> U+003B4 </td><td> <span class="glyph">δ</span> </td></tr><tr id="entity-demptyv"><td> <code>demptyv;</code> </td><td> U+029B1 </td><td> <span class="glyph">⦱</span> </td></tr><tr id="entity-dfisht"><td> <code>dfisht;</code> </td><td> U+0297F </td><td> <span class="glyph">⥿</span> </td></tr><tr id="entity-Dfr"><td> <code>Dfr;</code> </td><td> U+1D507 </td><td> <span class="glyph">𝔇</span> </td></tr><tr id="entity-dfr"><td> <code>dfr;</code> </td><td> U+1D521 </td><td> <span class="glyph">𝔡</span> </td></tr><tr id="entity-dHar"><td> <code>dHar;</code> </td><td> U+02965 </td><td> <span class="glyph">⥥</span> </td></tr><tr id="entity-dharl"><td> <code>dharl;</code> </td><td> U+021C3 </td><td> <span class="glyph">⇃</span> </td></tr><tr id="entity-dharr"><td> <code>dharr;</code> </td><td> U+021C2 </td><td> <span class="glyph">⇂</span> </td></tr><tr id="entity-DiacriticalAcute"><td> <code>DiacriticalAcute;</code> </td><td> U+000B4 </td><td> <span class="glyph">´</span> </td></tr><tr id="entity-DiacriticalDot"><td> <code>DiacriticalDot;</code> </td><td> U+002D9 </td><td> <span class="glyph">˙</span> </td></tr><tr id="entity-DiacriticalDoubleAcute"><td> <code>DiacriticalDoubleAcute;</code> </td><td> U+002DD </td><td> <span class="glyph">˝</span> </td></tr><tr id="entity-DiacriticalGrave"><td> <code>DiacriticalGrave;</code> </td><td> U+00060 </td><td> <span class="glyph">`</span> </td></tr><tr id="entity-DiacriticalTilde"><td> <code>DiacriticalTilde;</code> </td><td> U+002DC </td><td> <span class="glyph">˜</span> </td></tr><tr id="entity-diam"><td> <code>diam;</code> </td><td> U+022C4 </td><td> <span class="glyph">⋄</span> </td></tr><tr id="entity-Diamond"><td> <code>Diamond;</code> </td><td> U+022C4 </td><td> <span class="glyph">⋄</span> </td></tr><tr id="entity-diamond"><td> <code>diamond;</code> </td><td> U+022C4 </td><td> <span class="glyph">⋄</span> </td></tr><tr id="entity-diamondsuit"><td> <code>diamondsuit;</code> </td><td> U+02666 </td><td> <span class="glyph">♦</span> </td></tr><tr id="entity-diams"><td> <code>diams;</code> </td><td> U+02666 </td><td> <span class="glyph">♦</span> </td></tr><tr id="entity-die"><td> <code>die;</code> </td><td> U+000A8 </td><td> <span class="glyph">¨</span> </td></tr><tr id="entity-DifferentialD"><td> <code>DifferentialD;</code> </td><td> U+02146 </td><td> <span class="glyph">ⅆ</span> </td></tr><tr id="entity-digamma"><td> <code>digamma;</code> </td><td> U+003DD </td><td> <span class="glyph">ϝ</span> </td></tr><tr id="entity-disin"><td> <code>disin;</code> </td><td> U+022F2 </td><td> <span class="glyph">⋲</span> </td></tr><tr id="entity-div"><td> <code>div;</code> </td><td> U+000F7 </td><td> <span class="glyph">÷</span> </td></tr><tr id="entity-divide"><td> <code>divide;</code> </td><td> U+000F7 </td><td> <span class="glyph">÷</span> </td></tr><tr id="entity-divide-legacy" class="impl"><td> <code>divide</code> </td><td> U+000F7 </td><td> <span>÷</span> </td></tr><tr id="entity-divideontimes"><td> <code>divideontimes;</code> </td><td> U+022C7 </td><td> <span class="glyph">⋇</span> </td></tr><tr id="entity-divonx"><td> <code>divonx;</code> </td><td> U+022C7 </td><td> <span class="glyph">⋇</span> </td></tr><tr id="entity-DJcy"><td> <code>DJcy;</code> </td><td> U+00402 </td><td> <span class="glyph">Ђ</span> </td></tr><tr id="entity-djcy"><td> <code>djcy;</code> </td><td> U+00452 </td><td> <span class="glyph">ђ</span> </td></tr><tr id="entity-dlcorn"><td> <code>dlcorn;</code> </td><td> U+0231E </td><td> <span class="glyph">⌞</span> </td></tr><tr id="entity-dlcrop"><td> <code>dlcrop;</code> </td><td> U+0230D </td><td> <span class="glyph">⌍</span> </td></tr><tr id="entity-dollar"><td> <code>dollar;</code> </td><td> U+00024 </td><td> <span class="glyph">$</span> </td></tr><tr id="entity-Dopf"><td> <code>Dopf;</code> </td><td> U+1D53B </td><td> <span class="glyph">𝔻</span> </td></tr><tr id="entity-dopf"><td> <code>dopf;</code> </td><td> U+1D555 </td><td> <span class="glyph">𝕕</span> </td></tr><tr id="entity-Dot"><td> <code>Dot;</code> </td><td> U+000A8 </td><td> <span class="glyph">¨</span> </td></tr><tr id="entity-dot"><td> <code>dot;</code> </td><td> U+002D9 </td><td> <span class="glyph">˙</span> </td></tr><tr id="entity-DotDot"><td> <code>DotDot;</code> </td><td> U+020DC </td><td> <span class="glyph composition">◌⃜</span> </td></tr><tr id="entity-doteq"><td> <code>doteq;</code> </td><td> U+02250 </td><td> <span class="glyph">≐</span> </td></tr><tr id="entity-doteqdot"><td> <code>doteqdot;</code> </td><td> U+02251 </td><td> <span class="glyph">≑</span> </td></tr><tr id="entity-DotEqual"><td> <code>DotEqual;</code> </td><td> U+02250 </td><td> <span class="glyph">≐</span> </td></tr><tr id="entity-dotminus"><td> <code>dotminus;</code> </td><td> U+02238 </td><td> <span class="glyph">∸</span> </td></tr><tr id="entity-dotplus"><td> <code>dotplus;</code> </td><td> U+02214 </td><td> <span class="glyph">∔</span> </td></tr><tr id="entity-dotsquare"><td> <code>dotsquare;</code> </td><td> U+022A1 </td><td> <span class="glyph">⊡</span> </td></tr><tr id="entity-doublebarwedge"><td> <code>doublebarwedge;</code> </td><td> U+02306 </td><td> <span class="glyph">⌆</span> </td></tr><tr id="entity-DoubleContourIntegral"><td> <code>DoubleContourIntegral;</code> </td><td> U+0222F </td><td> <span class="glyph">∯</span> </td></tr><tr id="entity-DoubleDot"><td> <code>DoubleDot;</code> </td><td> U+000A8 </td><td> <span class="glyph">¨</span> </td></tr><tr id="entity-DoubleDownArrow"><td> <code>DoubleDownArrow;</code> </td><td> U+021D3 </td><td> <span class="glyph">⇓</span> </td></tr><tr id="entity-DoubleLeftArrow"><td> <code>DoubleLeftArrow;</code> </td><td> U+021D0 </td><td> <span class="glyph">⇐</span> </td></tr><tr id="entity-DoubleLeftRightArrow"><td> <code>DoubleLeftRightArrow;</code> </td><td> U+021D4 </td><td> <span class="glyph">⇔</span> </td></tr><tr id="entity-DoubleLeftTee"><td> <code>DoubleLeftTee;</code> </td><td> U+02AE4 </td><td> <span class="glyph">⫤</span> </td></tr><tr id="entity-DoubleLongLeftArrow"><td> <code>DoubleLongLeftArrow;</code> </td><td> U+027F8 </td><td> <span class="glyph">⟸</span> </td></tr><tr id="entity-DoubleLongLeftRightArrow"><td> <code>DoubleLongLeftRightArrow;</code> </td><td> U+027FA </td><td> <span class="glyph">⟺</span> </td></tr><tr id="entity-DoubleLongRightArrow"><td> <code>DoubleLongRightArrow;</code> </td><td> U+027F9 </td><td> <span class="glyph">⟹</span> </td></tr><tr id="entity-DoubleRightArrow"><td> <code>DoubleRightArrow;</code> </td><td> U+021D2 </td><td> <span class="glyph">⇒</span> </td></tr><tr id="entity-DoubleRightTee"><td> <code>DoubleRightTee;</code> </td><td> U+022A8 </td><td> <span class="glyph">⊨</span> </td></tr><tr id="entity-DoubleUpArrow"><td> <code>DoubleUpArrow;</code> </td><td> U+021D1 </td><td> <span class="glyph">⇑</span> </td></tr><tr id="entity-DoubleUpDownArrow"><td> <code>DoubleUpDownArrow;</code> </td><td> U+021D5 </td><td> <span class="glyph">⇕</span> </td></tr><tr id="entity-DoubleVerticalBar"><td> <code>DoubleVerticalBar;</code> </td><td> U+02225 </td><td> <span class="glyph">∥</span> </td></tr><tr id="entity-DownArrow"><td> <code>DownArrow;</code> </td><td> U+02193 </td><td> <span class="glyph">↓</span> </td></tr><tr id="entity-Downarrow"><td> <code>Downarrow;</code> </td><td> U+021D3 </td><td> <span class="glyph">⇓</span> </td></tr><tr id="entity-downarrow"><td> <code>downarrow;</code> </td><td> U+02193 </td><td> <span class="glyph">↓</span> </td></tr><tr id="entity-DownArrowBar"><td> <code>DownArrowBar;</code> </td><td> U+02913 </td><td> <span class="glyph">⤓</span> </td></tr><tr id="entity-DownArrowUpArrow"><td> <code>DownArrowUpArrow;</code> </td><td> U+021F5 </td><td> <span class="glyph">⇵</span> </td></tr><tr id="entity-DownBreve"><td> <code>DownBreve;</code> </td><td> U+00311 </td><td> <span class="glyph composition">◌̑</span> </td></tr><tr id="entity-downdownarrows"><td> <code>downdownarrows;</code> </td><td> U+021CA </td><td> <span class="glyph">⇊</span> </td></tr><tr id="entity-downharpoonleft"><td> <code>downharpoonleft;</code> </td><td> U+021C3 </td><td> <span class="glyph">⇃</span> </td></tr><tr id="entity-downharpoonright"><td> <code>downharpoonright;</code> </td><td> U+021C2 </td><td> <span class="glyph">⇂</span> </td></tr><tr id="entity-DownLeftRightVector"><td> <code>DownLeftRightVector;</code> </td><td> U+02950 </td><td> <span class="glyph">⥐</span> </td></tr><tr id="entity-DownLeftTeeVector"><td> <code>DownLeftTeeVector;</code> </td><td> U+0295E </td><td> <span class="glyph">⥞</span> </td></tr><tr id="entity-DownLeftVector"><td> <code>DownLeftVector;</code> </td><td> U+021BD </td><td> <span class="glyph">↽</span> </td></tr><tr id="entity-DownLeftVectorBar"><td> <code>DownLeftVectorBar;</code> </td><td> U+02956 </td><td> <span class="glyph">⥖</span> </td></tr><tr id="entity-DownRightTeeVector"><td> <code>DownRightTeeVector;</code> </td><td> U+0295F </td><td> <span class="glyph">⥟</span> </td></tr><tr id="entity-DownRightVector"><td> <code>DownRightVector;</code> </td><td> U+021C1 </td><td> <span class="glyph">⇁</span> </td></tr><tr id="entity-DownRightVectorBar"><td> <code>DownRightVectorBar;</code> </td><td> U+02957 </td><td> <span class="glyph">⥗</span> </td></tr><tr id="entity-DownTee"><td> <code>DownTee;</code> </td><td> U+022A4 </td><td> <span class="glyph">⊤</span> </td></tr><tr id="entity-DownTeeArrow"><td> <code>DownTeeArrow;</code> </td><td> U+021A7 </td><td> <span class="glyph">↧</span> </td></tr><tr id="entity-drbkarow"><td> <code>drbkarow;</code> </td><td> U+02910 </td><td> <span class="glyph">⤐</span> </td></tr><tr id="entity-drcorn"><td> <code>drcorn;</code> </td><td> U+0231F </td><td> <span class="glyph">⌟</span> </td></tr><tr id="entity-drcrop"><td> <code>drcrop;</code> </td><td> U+0230C </td><td> <span class="glyph">⌌</span> </td></tr><tr id="entity-Dscr"><td> <code>Dscr;</code> </td><td> U+1D49F </td><td> <span class="glyph">𝒟</span> </td></tr><tr id="entity-dscr"><td> <code>dscr;</code> </td><td> U+1D4B9 </td><td> <span class="glyph">𝒹</span> </td></tr><tr id="entity-DScy"><td> <code>DScy;</code> </td><td> U+00405 </td><td> <span class="glyph">Ѕ</span> </td></tr><tr id="entity-dscy"><td> <code>dscy;</code> </td><td> U+00455 </td><td> <span class="glyph">ѕ</span> </td></tr><tr id="entity-dsol"><td> <code>dsol;</code> </td><td> U+029F6 </td><td> <span class="glyph">⧶</span> </td></tr><tr id="entity-Dstrok"><td> <code>Dstrok;</code> </td><td> U+00110 </td><td> <span class="glyph">Đ</span> </td></tr><tr id="entity-dstrok"><td> <code>dstrok;</code> </td><td> U+00111 </td><td> <span class="glyph">đ</span> </td></tr><tr id="entity-dtdot"><td> <code>dtdot;</code> </td><td> U+022F1 </td><td> <span class="glyph">⋱</span> </td></tr><tr id="entity-dtri"><td> <code>dtri;</code> </td><td> U+025BF </td><td> <span class="glyph">▿</span> </td></tr><tr id="entity-dtrif"><td> <code>dtrif;</code> </td><td> U+025BE </td><td> <span class="glyph">▾</span> </td></tr><tr id="entity-duarr"><td> <code>duarr;</code> </td><td> U+021F5 </td><td> <span class="glyph">⇵</span> </td></tr><tr id="entity-duhar"><td> <code>duhar;</code> </td><td> U+0296F </td><td> <span class="glyph">⥯</span> </td></tr><tr id="entity-dwangle"><td> <code>dwangle;</code> </td><td> U+029A6 </td><td> <span class="glyph">⦦</span> </td></tr><tr id="entity-DZcy"><td> <code>DZcy;</code> </td><td> U+0040F </td><td> <span class="glyph">Џ</span> </td></tr><tr id="entity-dzcy"><td> <code>dzcy;</code> </td><td> U+0045F </td><td> <span class="glyph">џ</span> </td></tr><tr id="entity-dzigrarr"><td> <code>dzigrarr;</code> </td><td> U+027FF </td><td> <span class="glyph">⟿</span> </td></tr><tr id="entity-Eacute"><td> <code>Eacute;</code> </td><td> U+000C9 </td><td> <span class="glyph">É</span> </td></tr><tr id="entity-Eacute-legacy" class="impl"><td> <code>Eacute</code> </td><td> U+000C9 </td><td> <span>É</span> </td></tr><tr id="entity-eacute"><td> <code>eacute;</code> </td><td> U+000E9 </td><td> <span class="glyph">é</span> </td></tr><tr id="entity-eacute-legacy" class="impl"><td> <code>eacute</code> </td><td> U+000E9 </td><td> <span>é</span> </td></tr><tr id="entity-easter"><td> <code>easter;</code> </td><td> U+02A6E </td><td> <span class="glyph">⩮</span> </td></tr><tr id="entity-Ecaron"><td> <code>Ecaron;</code> </td><td> U+0011A </td><td> <span class="glyph">Ě</span> </td></tr><tr id="entity-ecaron"><td> <code>ecaron;</code> </td><td> U+0011B </td><td> <span class="glyph">ě</span> </td></tr><tr id="entity-ecir"><td> <code>ecir;</code> </td><td> U+02256 </td><td> <span class="glyph">≖</span> </td></tr><tr id="entity-Ecirc"><td> <code>Ecirc;</code> </td><td> U+000CA </td><td> <span class="glyph">Ê</span> </td></tr><tr id="entity-Ecirc-legacy" class="impl"><td> <code>Ecirc</code> </td><td> U+000CA </td><td> <span>Ê</span> </td></tr><tr id="entity-ecirc"><td> <code>ecirc;</code> </td><td> U+000EA </td><td> <span class="glyph">ê</span> </td></tr><tr id="entity-ecirc-legacy" class="impl"><td> <code>ecirc</code> </td><td> U+000EA </td><td> <span>ê</span> </td></tr><tr id="entity-ecolon"><td> <code>ecolon;</code> </td><td> U+02255 </td><td> <span class="glyph">≕</span> </td></tr><tr id="entity-Ecy"><td> <code>Ecy;</code> </td><td> U+0042D </td><td> <span class="glyph">Э</span> </td></tr><tr id="entity-ecy"><td> <code>ecy;</code> </td><td> U+0044D </td><td> <span class="glyph">э</span> </td></tr><tr id="entity-eDDot"><td> <code>eDDot;</code> </td><td> U+02A77 </td><td> <span class="glyph">⩷</span> </td></tr><tr id="entity-Edot"><td> <code>Edot;</code> </td><td> U+00116 </td><td> <span class="glyph">Ė</span> </td></tr><tr id="entity-eDot"><td> <code>eDot;</code> </td><td> U+02251 </td><td> <span class="glyph">≑</span> </td></tr><tr id="entity-edot"><td> <code>edot;</code> </td><td> U+00117 </td><td> <span class="glyph">ė</span> </td></tr><tr id="entity-ee"><td> <code>ee;</code> </td><td> U+02147 </td><td> <span class="glyph">ⅇ</span> </td></tr><tr id="entity-efDot"><td> <code>efDot;</code> </td><td> U+02252 </td><td> <span class="glyph">≒</span> </td></tr><tr id="entity-Efr"><td> <code>Efr;</code> </td><td> U+1D508 </td><td> <span class="glyph">𝔈</span> </td></tr><tr id="entity-efr"><td> <code>efr;</code> </td><td> U+1D522 </td><td> <span class="glyph">𝔢</span> </td></tr><tr id="entity-eg"><td> <code>eg;</code> </td><td> U+02A9A </td><td> <span class="glyph">⪚</span> </td></tr><tr id="entity-Egrave"><td> <code>Egrave;</code> </td><td> U+000C8 </td><td> <span class="glyph">È</span> </td></tr><tr id="entity-Egrave-legacy" class="impl"><td> <code>Egrave</code> </td><td> U+000C8 </td><td> <span>È</span> </td></tr><tr id="entity-egrave"><td> <code>egrave;</code> </td><td> U+000E8 </td><td> <span class="glyph">è</span> </td></tr><tr id="entity-egrave-legacy" class="impl"><td> <code>egrave</code> </td><td> U+000E8 </td><td> <span>è</span> </td></tr><tr id="entity-egs"><td> <code>egs;</code> </td><td> U+02A96 </td><td> <span class="glyph">⪖</span> </td></tr><tr id="entity-egsdot"><td> <code>egsdot;</code> </td><td> U+02A98 </td><td> <span class="glyph">⪘</span> </td></tr><tr id="entity-el"><td> <code>el;</code> </td><td> U+02A99 </td><td> <span class="glyph">⪙</span> </td></tr><tr id="entity-Element"><td> <code>Element;</code> </td><td> U+02208 </td><td> <span class="glyph">∈</span> </td></tr><tr id="entity-elinters"><td> <code>elinters;</code> </td><td> U+023E7 </td><td> <span class="glyph">⏧</span> </td></tr><tr id="entity-ell"><td> <code>ell;</code> </td><td> U+02113 </td><td> <span class="glyph">ℓ</span> </td></tr><tr id="entity-els"><td> <code>els;</code> </td><td> U+02A95 </td><td> <span class="glyph">⪕</span> </td></tr><tr id="entity-elsdot"><td> <code>elsdot;</code> </td><td> U+02A97 </td><td> <span class="glyph">⪗</span> </td></tr><tr id="entity-Emacr"><td> <code>Emacr;</code> </td><td> U+00112 </td><td> <span class="glyph">Ē</span> </td></tr><tr id="entity-emacr"><td> <code>emacr;</code> </td><td> U+00113 </td><td> <span class="glyph">ē</span> </td></tr><tr id="entity-empty"><td> <code>empty;</code> </td><td> U+02205 </td><td> <span class="glyph">∅</span> </td></tr><tr id="entity-emptyset"><td> <code>emptyset;</code> </td><td> U+02205 </td><td> <span class="glyph">∅</span> </td></tr><tr id="entity-EmptySmallSquare"><td> <code>EmptySmallSquare;</code> </td><td> U+025FB </td><td> <span class="glyph">◻</span> </td></tr><tr id="entity-emptyv"><td> <code>emptyv;</code> </td><td> U+02205 </td><td> <span class="glyph">∅</span> </td></tr><tr id="entity-EmptyVerySmallSquare"><td> <code>EmptyVerySmallSquare;</code> </td><td> U+025AB </td><td> <span class="glyph">▫</span> </td></tr><tr id="entity-emsp"><td> <code>emsp;</code> </td><td> U+02003 </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-emsp13"><td> <code>emsp13;</code> </td><td> U+02004 </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-emsp14"><td> <code>emsp14;</code> </td><td> U+02005 </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-ENG"><td> <code>ENG;</code> </td><td> U+0014A </td><td> <span class="glyph">Ŋ</span> </td></tr><tr id="entity-eng"><td> <code>eng;</code> </td><td> U+0014B </td><td> <span class="glyph">ŋ</span> </td></tr><tr id="entity-ensp"><td> <code>ensp;</code> </td><td> U+02002 </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-Eogon"><td> <code>Eogon;</code> </td><td> U+00118 </td><td> <span class="glyph">Ę</span> </td></tr><tr id="entity-eogon"><td> <code>eogon;</code> </td><td> U+00119 </td><td> <span class="glyph">ę</span> </td></tr><tr id="entity-Eopf"><td> <code>Eopf;</code> </td><td> U+1D53C </td><td> <span class="glyph">𝔼</span> </td></tr><tr id="entity-eopf"><td> <code>eopf;</code> </td><td> U+1D556 </td><td> <span class="glyph">𝕖</span> </td></tr><tr id="entity-epar"><td> <code>epar;</code> </td><td> U+022D5 </td><td> <span class="glyph">⋕</span> </td></tr><tr id="entity-eparsl"><td> <code>eparsl;</code> </td><td> U+029E3 </td><td> <span class="glyph">⧣</span> </td></tr><tr id="entity-eplus"><td> <code>eplus;</code> </td><td> U+02A71 </td><td> <span class="glyph">⩱</span> </td></tr><tr id="entity-epsi"><td> <code>epsi;</code> </td><td> U+003B5 </td><td> <span class="glyph">ε</span> </td></tr><tr id="entity-Epsilon"><td> <code>Epsilon;</code> </td><td> U+00395 </td><td> <span class="glyph">Ε</span> </td></tr><tr id="entity-epsilon"><td> <code>epsilon;</code> </td><td> U+003B5 </td><td> <span class="glyph">ε</span> </td></tr><tr id="entity-epsiv"><td> <code>epsiv;</code> </td><td> U+003F5 </td><td> <span class="glyph">ϵ</span> </td></tr><tr id="entity-eqcirc"><td> <code>eqcirc;</code> </td><td> U+02256 </td><td> <span class="glyph">≖</span> </td></tr><tr id="entity-eqcolon"><td> <code>eqcolon;</code> </td><td> U+02255 </td><td> <span class="glyph">≕</span> </td></tr><tr id="entity-eqsim"><td> <code>eqsim;</code> </td><td> U+02242 </td><td> <span class="glyph">≂</span> </td></tr><tr id="entity-eqslantgtr"><td> <code>eqslantgtr;</code> </td><td> U+02A96 </td><td> <span class="glyph">⪖</span> </td></tr><tr id="entity-eqslantless"><td> <code>eqslantless;</code> </td><td> U+02A95 </td><td> <span class="glyph">⪕</span> </td></tr><tr id="entity-Equal"><td> <code>Equal;</code> </td><td> U+02A75 </td><td> <span class="glyph">⩵</span> </td></tr><tr id="entity-equals"><td> <code>equals;</code> </td><td> U+0003D </td><td> <span class="glyph">=</span> </td></tr><tr id="entity-EqualTilde"><td> <code>EqualTilde;</code> </td><td> U+02242 </td><td> <span class="glyph">≂</span> </td></tr><tr id="entity-equest"><td> <code>equest;</code> </td><td> U+0225F </td><td> <span class="glyph">≟</span> </td></tr><tr id="entity-Equilibrium"><td> <code>Equilibrium;</code> </td><td> U+021CC </td><td> <span class="glyph">⇌</span> </td></tr><tr id="entity-equiv"><td> <code>equiv;</code> </td><td> U+02261 </td><td> <span class="glyph">≡</span> </td></tr><tr id="entity-equivDD"><td> <code>equivDD;</code> </td><td> U+02A78 </td><td> <span class="glyph">⩸</span> </td></tr><tr id="entity-eqvparsl"><td> <code>eqvparsl;</code> </td><td> U+029E5 </td><td> <span class="glyph">⧥</span> </td></tr><tr id="entity-erarr"><td> <code>erarr;</code> </td><td> U+02971 </td><td> <span class="glyph">⥱</span> </td></tr><tr id="entity-erDot"><td> <code>erDot;</code> </td><td> U+02253 </td><td> <span class="glyph">≓</span> </td></tr><tr id="entity-Escr"><td> <code>Escr;</code> </td><td> U+02130 </td><td> <span class="glyph">ℰ</span> </td></tr><tr id="entity-escr"><td> <code>escr;</code> </td><td> U+0212F </td><td> <span class="glyph">ℯ</span> </td></tr><tr id="entity-esdot"><td> <code>esdot;</code> </td><td> U+02250 </td><td> <span class="glyph">≐</span> </td></tr><tr id="entity-Esim"><td> <code>Esim;</code> </td><td> U+02A73 </td><td> <span class="glyph">⩳</span> </td></tr><tr id="entity-esim"><td> <code>esim;</code> </td><td> U+02242 </td><td> <span class="glyph">≂</span> </td></tr><tr id="entity-Eta"><td> <code>Eta;</code> </td><td> U+00397 </td><td> <span class="glyph">Η</span> </td></tr><tr id="entity-eta"><td> <code>eta;</code> </td><td> U+003B7 </td><td> <span class="glyph">η</span> </td></tr><tr id="entity-ETH"><td> <code>ETH;</code> </td><td> U+000D0 </td><td> <span class="glyph">Ð</span> </td></tr><tr id="entity-ETH-legacy" class="impl"><td> <code>ETH</code> </td><td> U+000D0 </td><td> <span>Ð</span> </td></tr><tr id="entity-eth"><td> <code>eth;</code> </td><td> U+000F0 </td><td> <span class="glyph">ð</span> </td></tr><tr id="entity-eth-legacy" class="impl"><td> <code>eth</code> </td><td> U+000F0 </td><td> <span>ð</span> </td></tr><tr id="entity-Euml"><td> <code>Euml;</code> </td><td> U+000CB </td><td> <span class="glyph">Ë</span> </td></tr><tr id="entity-Euml-legacy" class="impl"><td> <code>Euml</code> </td><td> U+000CB </td><td> <span>Ë</span> </td></tr><tr id="entity-euml"><td> <code>euml;</code> </td><td> U+000EB </td><td> <span class="glyph">ë</span> </td></tr><tr id="entity-euml-legacy" class="impl"><td> <code>euml</code> </td><td> U+000EB </td><td> <span>ë</span> </td></tr><tr id="entity-euro"><td> <code>euro;</code> </td><td> U+020AC </td><td> <span class="glyph">€</span> </td></tr><tr id="entity-excl"><td> <code>excl;</code> </td><td> U+00021 </td><td> <span class="glyph">!</span> </td></tr><tr id="entity-exist"><td> <code>exist;</code> </td><td> U+02203 </td><td> <span class="glyph">∃</span> </td></tr><tr id="entity-Exists"><td> <code>Exists;</code> </td><td> U+02203 </td><td> <span class="glyph">∃</span> </td></tr><tr id="entity-expectation"><td> <code>expectation;</code> </td><td> U+02130 </td><td> <span class="glyph">ℰ</span> </td></tr><tr id="entity-ExponentialE"><td> <code>ExponentialE;</code> </td><td> U+02147 </td><td> <span class="glyph">ⅇ</span> </td></tr><tr id="entity-exponentiale"><td> <code>exponentiale;</code> </td><td> U+02147 </td><td> <span class="glyph">ⅇ</span> </td></tr><tr id="entity-fallingdotseq"><td> <code>fallingdotseq;</code> </td><td> U+02252 </td><td> <span class="glyph">≒</span> </td></tr><tr id="entity-Fcy"><td> <code>Fcy;</code> </td><td> U+00424 </td><td> <span class="glyph">Ф</span> </td></tr><tr id="entity-fcy"><td> <code>fcy;</code> </td><td> U+00444 </td><td> <span class="glyph">ф</span> </td></tr><tr id="entity-female"><td> <code>female;</code> </td><td> U+02640 </td><td> <span class="glyph">♀</span> </td></tr><tr id="entity-ffilig"><td> <code>ffilig;</code> </td><td> U+0FB03 </td><td> <span class="glyph">ﬃ</span> </td></tr><tr id="entity-fflig"><td> <code>fflig;</code> </td><td> U+0FB00 </td><td> <span class="glyph">ﬀ</span> </td></tr><tr id="entity-ffllig"><td> <code>ffllig;</code> </td><td> U+0FB04 </td><td> <span class="glyph">ﬄ</span> </td></tr><tr id="entity-Ffr"><td> <code>Ffr;</code> </td><td> U+1D509 </td><td> <span class="glyph">𝔉</span> </td></tr><tr id="entity-ffr"><td> <code>ffr;</code> </td><td> U+1D523 </td><td> <span class="glyph">𝔣</span> </td></tr><tr id="entity-filig"><td> <code>filig;</code> </td><td> U+0FB01 </td><td> <span class="glyph">ﬁ</span> </td></tr><tr id="entity-FilledSmallSquare"><td> <code>FilledSmallSquare;</code> </td><td> U+025FC </td><td> <span class="glyph">◼</span> </td></tr><tr id="entity-FilledVerySmallSquare"><td> <code>FilledVerySmallSquare;</code> </td><td> U+025AA </td><td> <span class="glyph">▪</span> </td></tr><tr id="entity-fjlig"><td> <code>fjlig;</code> </td><td> U+00066 U+0006A </td><td> <span class="glyph compound">fj</span> </td></tr><tr id="entity-flat"><td> <code>flat;</code> </td><td> U+0266D </td><td> <span class="glyph">♭</span> </td></tr><tr id="entity-fllig"><td> <code>fllig;</code> </td><td> U+0FB02 </td><td> <span class="glyph">ﬂ</span> </td></tr><tr id="entity-fltns"><td> <code>fltns;</code> </td><td> U+025B1 </td><td> <span class="glyph">▱</span> </td></tr><tr id="entity-fnof"><td> <code>fnof;</code> </td><td> U+00192 </td><td> <span class="glyph">ƒ</span> </td></tr><tr id="entity-Fopf"><td> <code>Fopf;</code> </td><td> U+1D53D </td><td> <span class="glyph">𝔽</span> </td></tr><tr id="entity-fopf"><td> <code>fopf;</code> </td><td> U+1D557 </td><td> <span class="glyph">𝕗</span> </td></tr><tr id="entity-ForAll"><td> <code>ForAll;</code> </td><td> U+02200 </td><td> <span class="glyph">∀</span> </td></tr><tr id="entity-forall"><td> <code>forall;</code> </td><td> U+02200 </td><td> <span class="glyph">∀</span> </td></tr><tr id="entity-fork"><td> <code>fork;</code> </td><td> U+022D4 </td><td> <span class="glyph">⋔</span> </td></tr><tr id="entity-forkv"><td> <code>forkv;</code> </td><td> U+02AD9 </td><td> <span class="glyph">⫙</span> </td></tr><tr id="entity-Fouriertrf"><td> <code>Fouriertrf;</code> </td><td> U+02131 </td><td> <span class="glyph">ℱ</span> </td></tr><tr id="entity-fpartint"><td> <code>fpartint;</code> </td><td> U+02A0D </td><td> <span class="glyph">⨍</span> </td></tr><tr id="entity-frac12"><td> <code>frac12;</code> </td><td> U+000BD </td><td> <span class="glyph">½</span> </td></tr><tr id="entity-frac12-legacy" class="impl"><td> <code>frac12</code> </td><td> U+000BD </td><td> <span>½</span> </td></tr><tr id="entity-frac13"><td> <code>frac13;</code> </td><td> U+02153 </td><td> <span class="glyph">⅓</span> </td></tr><tr id="entity-frac14"><td> <code>frac14;</code> </td><td> U+000BC </td><td> <span class="glyph">¼</span> </td></tr><tr id="entity-frac14-legacy" class="impl"><td> <code>frac14</code> </td><td> U+000BC </td><td> <span>¼</span> </td></tr><tr id="entity-frac15"><td> <code>frac15;</code> </td><td> U+02155 </td><td> <span class="glyph">⅕</span> </td></tr><tr id="entity-frac16"><td> <code>frac16;</code> </td><td> U+02159 </td><td> <span class="glyph">⅙</span> </td></tr><tr id="entity-frac18"><td> <code>frac18;</code> </td><td> U+0215B </td><td> <span class="glyph">⅛</span> </td></tr><tr id="entity-frac23"><td> <code>frac23;</code> </td><td> U+02154 </td><td> <span class="glyph">⅔</span> </td></tr><tr id="entity-frac25"><td> <code>frac25;</code> </td><td> U+02156 </td><td> <span class="glyph">⅖</span> </td></tr><tr id="entity-frac34"><td> <code>frac34;</code> </td><td> U+000BE </td><td> <span class="glyph">¾</span> </td></tr><tr id="entity-frac34-legacy" class="impl"><td> <code>frac34</code> </td><td> U+000BE </td><td> <span>¾</span> </td></tr><tr id="entity-frac35"><td> <code>frac35;</code> </td><td> U+02157 </td><td> <span class="glyph">⅗</span> </td></tr><tr id="entity-frac38"><td> <code>frac38;</code> </td><td> U+0215C </td><td> <span class="glyph">⅜</span> </td></tr><tr id="entity-frac45"><td> <code>frac45;</code> </td><td> U+02158 </td><td> <span class="glyph">⅘</span> </td></tr><tr id="entity-frac56"><td> <code>frac56;</code> </td><td> U+0215A </td><td> <span class="glyph">⅚</span> </td></tr><tr id="entity-frac58"><td> <code>frac58;</code> </td><td> U+0215D </td><td> <span class="glyph">⅝</span> </td></tr><tr id="entity-frac78"><td> <code>frac78;</code> </td><td> U+0215E </td><td> <span class="glyph">⅞</span> </td></tr><tr id="entity-frasl"><td> <code>frasl;</code> </td><td> U+02044 </td><td> <span class="glyph">⁄</span> </td></tr><tr id="entity-frown"><td> <code>frown;</code> </td><td> U+02322 </td><td> <span class="glyph">⌢</span> </td></tr><tr id="entity-Fscr"><td> <code>Fscr;</code> </td><td> U+02131 </td><td> <span class="glyph">ℱ</span> </td></tr><tr id="entity-fscr"><td> <code>fscr;</code> </td><td> U+1D4BB </td><td> <span class="glyph">𝒻</span> </td></tr><tr id="entity-gacute"><td> <code>gacute;</code> </td><td> U+001F5 </td><td> <span class="glyph">ǵ</span> </td></tr><tr id="entity-Gamma"><td> <code>Gamma;</code> </td><td> U+00393 </td><td> <span class="glyph">Γ</span> </td></tr><tr id="entity-gamma"><td> <code>gamma;</code> </td><td> U+003B3 </td><td> <span class="glyph">γ</span> </td></tr><tr id="entity-Gammad"><td> <code>Gammad;</code> </td><td> U+003DC </td><td> <span class="glyph">Ϝ</span> </td></tr><tr id="entity-gammad"><td> <code>gammad;</code> </td><td> U+003DD </td><td> <span class="glyph">ϝ</span> </td></tr><tr id="entity-gap"><td> <code>gap;</code> </td><td> U+02A86 </td><td> <span class="glyph">⪆</span> </td></tr><tr id="entity-Gbreve"><td> <code>Gbreve;</code> </td><td> U+0011E </td><td> <span class="glyph">Ğ</span> </td></tr><tr id="entity-gbreve"><td> <code>gbreve;</code> </td><td> U+0011F </td><td> <span class="glyph">ğ</span> </td></tr><tr id="entity-Gcedil"><td> <code>Gcedil;</code> </td><td> U+00122 </td><td> <span class="glyph">Ģ</span> </td></tr><tr id="entity-Gcirc"><td> <code>Gcirc;</code> </td><td> U+0011C </td><td> <span class="glyph">Ĝ</span> </td></tr><tr id="entity-gcirc"><td> <code>gcirc;</code> </td><td> U+0011D </td><td> <span class="glyph">ĝ</span> </td></tr><tr id="entity-Gcy"><td> <code>Gcy;</code> </td><td> U+00413 </td><td> <span class="glyph">Г</span> </td></tr><tr id="entity-gcy"><td> <code>gcy;</code> </td><td> U+00433 </td><td> <span class="glyph">г</span> </td></tr><tr id="entity-Gdot"><td> <code>Gdot;</code> </td><td> U+00120 </td><td> <span class="glyph">Ġ</span> </td></tr><tr id="entity-gdot"><td> <code>gdot;</code> </td><td> U+00121 </td><td> <span class="glyph">ġ</span> </td></tr><tr id="entity-gE"><td> <code>gE;</code> </td><td> U+02267 </td><td> <span class="glyph">≧</span> </td></tr><tr id="entity-ge"><td> <code>ge;</code> </td><td> U+02265 </td><td> <span class="glyph">≥</span> </td></tr><tr id="entity-gEl"><td> <code>gEl;</code> </td><td> U+02A8C </td><td> <span class="glyph">⪌</span> </td></tr><tr id="entity-gel"><td> <code>gel;</code> </td><td> U+022DB </td><td> <span class="glyph">⋛</span> </td></tr><tr id="entity-geq"><td> <code>geq;</code> </td><td> U+02265 </td><td> <span class="glyph">≥</span> </td></tr><tr id="entity-geqq"><td> <code>geqq;</code> </td><td> U+02267 </td><td> <span class="glyph">≧</span> </td></tr><tr id="entity-geqslant"><td> <code>geqslant;</code> </td><td> U+02A7E </td><td> <span class="glyph">⩾</span> </td></tr><tr id="entity-ges"><td> <code>ges;</code> </td><td> U+02A7E </td><td> <span class="glyph">⩾</span> </td></tr><tr id="entity-gescc"><td> <code>gescc;</code> </td><td> U+02AA9 </td><td> <span class="glyph">⪩</span> </td></tr><tr id="entity-gesdot"><td> <code>gesdot;</code> </td><td> U+02A80 </td><td> <span class="glyph">⪀</span> </td></tr><tr id="entity-gesdoto"><td> <code>gesdoto;</code> </td><td> U+02A82 </td><td> <span class="glyph">⪂</span> </td></tr><tr id="entity-gesdotol"><td> <code>gesdotol;</code> </td><td> U+02A84 </td><td> <span class="glyph">⪄</span> </td></tr><tr id="entity-gesl"><td> <code>gesl;</code> </td><td> U+022DB U+0FE00 </td><td> <span class="glyph compound">⋛︀</span> </td></tr><tr id="entity-gesles"><td> <code>gesles;</code> </td><td> U+02A94 </td><td> <span class="glyph">⪔</span> </td></tr><tr id="entity-Gfr"><td> <code>Gfr;</code> </td><td> U+1D50A </td><td> <span class="glyph">𝔊</span> </td></tr><tr id="entity-gfr"><td> <code>gfr;</code> </td><td> U+1D524 </td><td> <span class="glyph">𝔤</span> </td></tr><tr id="entity-Gg"><td> <code>Gg;</code> </td><td> U+022D9 </td><td> <span class="glyph">⋙</span> </td></tr><tr id="entity-gg"><td> <code>gg;</code> </td><td> U+0226B </td><td> <span class="glyph">≫</span> </td></tr><tr id="entity-ggg"><td> <code>ggg;</code> </td><td> U+022D9 </td><td> <span class="glyph">⋙</span> </td></tr><tr id="entity-gimel"><td> <code>gimel;</code> </td><td> U+02137 </td><td> <span class="glyph">ℷ</span> </td></tr><tr id="entity-GJcy"><td> <code>GJcy;</code> </td><td> U+00403 </td><td> <span class="glyph">Ѓ</span> </td></tr><tr id="entity-gjcy"><td> <code>gjcy;</code> </td><td> U+00453 </td><td> <span class="glyph">ѓ</span> </td></tr><tr id="entity-gl"><td> <code>gl;</code> </td><td> U+02277 </td><td> <span class="glyph">≷</span> </td></tr><tr id="entity-gla"><td> <code>gla;</code> </td><td> U+02AA5 </td><td> <span class="glyph">⪥</span> </td></tr><tr id="entity-glE"><td> <code>glE;</code> </td><td> U+02A92 </td><td> <span class="glyph">⪒</span> </td></tr><tr id="entity-glj"><td> <code>glj;</code> </td><td> U+02AA4 </td><td> <span class="glyph">⪤</span> </td></tr><tr id="entity-gnap"><td> <code>gnap;</code> </td><td> U+02A8A </td><td> <span class="glyph">⪊</span> </td></tr><tr id="entity-gnapprox"><td> <code>gnapprox;</code> </td><td> U+02A8A </td><td> <span class="glyph">⪊</span> </td></tr><tr id="entity-gnE"><td> <code>gnE;</code> </td><td> U+02269 </td><td> <span class="glyph">≩</span> </td></tr><tr id="entity-gne"><td> <code>gne;</code> </td><td> U+02A88 </td><td> <span class="glyph">⪈</span> </td></tr><tr id="entity-gneq"><td> <code>gneq;</code> </td><td> U+02A88 </td><td> <span class="glyph">⪈</span> </td></tr><tr id="entity-gneqq"><td> <code>gneqq;</code> </td><td> U+02269 </td><td> <span class="glyph">≩</span> </td></tr><tr id="entity-gnsim"><td> <code>gnsim;</code> </td><td> U+022E7 </td><td> <span class="glyph">⋧</span> </td></tr><tr id="entity-Gopf"><td> <code>Gopf;</code> </td><td> U+1D53E </td><td> <span class="glyph">𝔾</span> </td></tr><tr id="entity-gopf"><td> <code>gopf;</code> </td><td> U+1D558 </td><td> <span class="glyph">𝕘</span> </td></tr><tr id="entity-grave"><td> <code>grave;</code> </td><td> U+00060 </td><td> <span class="glyph">`</span> </td></tr><tr id="entity-GreaterEqual"><td> <code>GreaterEqual;</code> </td><td> U+02265 </td><td> <span class="glyph">≥</span> </td></tr><tr id="entity-GreaterEqualLess"><td> <code>GreaterEqualLess;</code> </td><td> U+022DB </td><td> <span class="glyph">⋛</span> </td></tr><tr id="entity-GreaterFullEqual"><td> <code>GreaterFullEqual;</code> </td><td> U+02267 </td><td> <span class="glyph">≧</span> </td></tr><tr id="entity-GreaterGreater"><td> <code>GreaterGreater;</code> </td><td> U+02AA2 </td><td> <span class="glyph">⪢</span> </td></tr><tr id="entity-GreaterLess"><td> <code>GreaterLess;</code> </td><td> U+02277 </td><td> <span class="glyph">≷</span> </td></tr><tr id="entity-GreaterSlantEqual"><td> <code>GreaterSlantEqual;</code> </td><td> U+02A7E </td><td> <span class="glyph">⩾</span> </td></tr><tr id="entity-GreaterTilde"><td> <code>GreaterTilde;</code> </td><td> U+02273 </td><td> <span class="glyph">≳</span> </td></tr><tr id="entity-Gscr"><td> <code>Gscr;</code> </td><td> U+1D4A2 </td><td> <span class="glyph">𝒢</span> </td></tr><tr id="entity-gscr"><td> <code>gscr;</code> </td><td> U+0210A </td><td> <span class="glyph">ℊ</span> </td></tr><tr id="entity-gsim"><td> <code>gsim;</code> </td><td> U+02273 </td><td> <span class="glyph">≳</span> </td></tr><tr id="entity-gsime"><td> <code>gsime;</code> </td><td> U+02A8E </td><td> <span class="glyph">⪎</span> </td></tr><tr id="entity-gsiml"><td> <code>gsiml;</code> </td><td> U+02A90 </td><td> <span class="glyph">⪐</span> </td></tr><tr id="entity-GT"><td> <code>GT;</code> </td><td> U+0003E </td><td> <span class="glyph">&gt;</span> </td></tr><tr id="entity-GT-legacy" class="impl"><td> <code>GT</code> </td><td> U+0003E </td><td> <span>&gt;</span> </td></tr><tr id="entity-Gt"><td> <code>Gt;</code> </td><td> U+0226B </td><td> <span class="glyph">≫</span> </td></tr><tr id="entity-gt"><td> <code>gt;</code> </td><td> U+0003E </td><td> <span class="glyph">&gt;</span> </td></tr><tr id="entity-gt-legacy" class="impl"><td> <code>gt</code> </td><td> U+0003E </td><td> <span>&gt;</span> </td></tr><tr id="entity-gtcc"><td> <code>gtcc;</code> </td><td> U+02AA7 </td><td> <span class="glyph">⪧</span> </td></tr><tr id="entity-gtcir"><td> <code>gtcir;</code> </td><td> U+02A7A </td><td> <span class="glyph">⩺</span> </td></tr><tr id="entity-gtdot"><td> <code>gtdot;</code> </td><td> U+022D7 </td><td> <span class="glyph">⋗</span> </td></tr><tr id="entity-gtlPar"><td> <code>gtlPar;</code> </td><td> U+02995 </td><td> <span class="glyph">⦕</span> </td></tr><tr id="entity-gtquest"><td> <code>gtquest;</code> </td><td> U+02A7C </td><td> <span class="glyph">⩼</span> </td></tr><tr id="entity-gtrapprox"><td> <code>gtrapprox;</code> </td><td> U+02A86 </td><td> <span class="glyph">⪆</span> </td></tr><tr id="entity-gtrarr"><td> <code>gtrarr;</code> </td><td> U+02978 </td><td> <span class="glyph">⥸</span> </td></tr><tr id="entity-gtrdot"><td> <code>gtrdot;</code> </td><td> U+022D7 </td><td> <span class="glyph">⋗</span> </td></tr><tr id="entity-gtreqless"><td> <code>gtreqless;</code> </td><td> U+022DB </td><td> <span class="glyph">⋛</span> </td></tr><tr id="entity-gtreqqless"><td> <code>gtreqqless;</code> </td><td> U+02A8C </td><td> <span class="glyph">⪌</span> </td></tr><tr id="entity-gtrless"><td> <code>gtrless;</code> </td><td> U+02277 </td><td> <span class="glyph">≷</span> </td></tr><tr id="entity-gtrsim"><td> <code>gtrsim;</code> </td><td> U+02273 </td><td> <span class="glyph">≳</span> </td></tr><tr id="entity-gvertneqq"><td> <code>gvertneqq;</code> </td><td> U+02269 U+0FE00 </td><td> <span class="glyph compound">≩︀</span> </td></tr><tr id="entity-gvnE"><td> <code>gvnE;</code> </td><td> U+02269 U+0FE00 </td><td> <span class="glyph compound">≩︀</span> </td></tr><tr id="entity-Hacek"><td> <code>Hacek;</code> </td><td> U+002C7 </td><td> <span class="glyph">ˇ</span> </td></tr><tr id="entity-hairsp"><td> <code>hairsp;</code> </td><td> U+0200A </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-half"><td> <code>half;</code> </td><td> U+000BD </td><td> <span class="glyph">½</span> </td></tr><tr id="entity-hamilt"><td> <code>hamilt;</code> </td><td> U+0210B </td><td> <span class="glyph">ℋ</span> </td></tr><tr id="entity-HARDcy"><td> <code>HARDcy;</code> </td><td> U+0042A </td><td> <span class="glyph">Ъ</span> </td></tr><tr id="entity-hardcy"><td> <code>hardcy;</code> </td><td> U+0044A </td><td> <span class="glyph">ъ</span> </td></tr><tr id="entity-hArr"><td> <code>hArr;</code> </td><td> U+021D4 </td><td> <span class="glyph">⇔</span> </td></tr><tr id="entity-harr"><td> <code>harr;</code> </td><td> U+02194 </td><td> <span class="glyph">↔</span> </td></tr><tr id="entity-harrcir"><td> <code>harrcir;</code> </td><td> U+02948 </td><td> <span class="glyph">⥈</span> </td></tr><tr id="entity-harrw"><td> <code>harrw;</code> </td><td> U+021AD </td><td> <span class="glyph">↭</span> </td></tr><tr id="entity-Hat"><td> <code>Hat;</code> </td><td> U+0005E </td><td> <span class="glyph">^</span> </td></tr><tr id="entity-hbar"><td> <code>hbar;</code> </td><td> U+0210F </td><td> <span class="glyph">ℏ</span> </td></tr><tr id="entity-Hcirc"><td> <code>Hcirc;</code> </td><td> U+00124 </td><td> <span class="glyph">Ĥ</span> </td></tr><tr id="entity-hcirc"><td> <code>hcirc;</code> </td><td> U+00125 </td><td> <span class="glyph">ĥ</span> </td></tr><tr id="entity-hearts"><td> <code>hearts;</code> </td><td> U+02665 </td><td> <span class="glyph">♥</span> </td></tr><tr id="entity-heartsuit"><td> <code>heartsuit;</code> </td><td> U+02665 </td><td> <span class="glyph">♥</span> </td></tr><tr id="entity-hellip"><td> <code>hellip;</code> </td><td> U+02026 </td><td> <span class="glyph">…</span> </td></tr><tr id="entity-hercon"><td> <code>hercon;</code> </td><td> U+022B9 </td><td> <span class="glyph">⊹</span> </td></tr><tr id="entity-Hfr"><td> <code>Hfr;</code> </td><td> U+0210C </td><td> <span class="glyph">ℌ</span> </td></tr><tr id="entity-hfr"><td> <code>hfr;</code> </td><td> U+1D525 </td><td> <span class="glyph">𝔥</span> </td></tr><tr id="entity-HilbertSpace"><td> <code>HilbertSpace;</code> </td><td> U+0210B </td><td> <span class="glyph">ℋ</span> </td></tr><tr id="entity-hksearow"><td> <code>hksearow;</code> </td><td> U+02925 </td><td> <span class="glyph">⤥</span> </td></tr><tr id="entity-hkswarow"><td> <code>hkswarow;</code> </td><td> U+02926 </td><td> <span class="glyph">⤦</span> </td></tr><tr id="entity-hoarr"><td> <code>hoarr;</code> </td><td> U+021FF </td><td> <span class="glyph">⇿</span> </td></tr><tr id="entity-homtht"><td> <code>homtht;</code> </td><td> U+0223B </td><td> <span class="glyph">∻</span> </td></tr><tr id="entity-hookleftarrow"><td> <code>hookleftarrow;</code> </td><td> U+021A9 </td><td> <span class="glyph">↩</span> </td></tr><tr id="entity-hookrightarrow"><td> <code>hookrightarrow;</code> </td><td> U+021AA </td><td> <span class="glyph">↪</span> </td></tr><tr id="entity-Hopf"><td> <code>Hopf;</code> </td><td> U+0210D </td><td> <span class="glyph">ℍ</span> </td></tr><tr id="entity-hopf"><td> <code>hopf;</code> </td><td> U+1D559 </td><td> <span class="glyph">𝕙</span> </td></tr><tr id="entity-horbar"><td> <code>horbar;</code> </td><td> U+02015 </td><td> <span class="glyph">―</span> </td></tr><tr id="entity-HorizontalLine"><td> <code>HorizontalLine;</code> </td><td> U+02500 </td><td> <span class="glyph">─</span> </td></tr><tr id="entity-Hscr"><td> <code>Hscr;</code> </td><td> U+0210B </td><td> <span class="glyph">ℋ</span> </td></tr><tr id="entity-hscr"><td> <code>hscr;</code> </td><td> U+1D4BD </td><td> <span class="glyph">𝒽</span> </td></tr><tr id="entity-hslash"><td> <code>hslash;</code> </td><td> U+0210F </td><td> <span class="glyph">ℏ</span> </td></tr><tr id="entity-Hstrok"><td> <code>Hstrok;</code> </td><td> U+00126 </td><td> <span class="glyph">Ħ</span> </td></tr><tr id="entity-hstrok"><td> <code>hstrok;</code> </td><td> U+00127 </td><td> <span class="glyph">ħ</span> </td></tr><tr id="entity-HumpDownHump"><td> <code>HumpDownHump;</code> </td><td> U+0224E </td><td> <span class="glyph">≎</span> </td></tr><tr id="entity-HumpEqual"><td> <code>HumpEqual;</code> </td><td> U+0224F </td><td> <span class="glyph">≏</span> </td></tr><tr id="entity-hybull"><td> <code>hybull;</code> </td><td> U+02043 </td><td> <span class="glyph">⁃</span> </td></tr><tr id="entity-hyphen"><td> <code>hyphen;</code> </td><td> U+02010 </td><td> <span class="glyph">‐</span> </td></tr><tr id="entity-Iacute"><td> <code>Iacute;</code> </td><td> U+000CD </td><td> <span class="glyph">Í</span> </td></tr><tr id="entity-Iacute-legacy" class="impl"><td> <code>Iacute</code> </td><td> U+000CD </td><td> <span>Í</span> </td></tr><tr id="entity-iacute"><td> <code>iacute;</code> </td><td> U+000ED </td><td> <span class="glyph">í</span> </td></tr><tr id="entity-iacute-legacy" class="impl"><td> <code>iacute</code> </td><td> U+000ED </td><td> <span>í</span> </td></tr><tr id="entity-ic"><td> <code>ic;</code> </td><td> U+02063 </td><td> <span class="glyph">⁣</span> </td></tr><tr id="entity-Icirc"><td> <code>Icirc;</code> </td><td> U+000CE </td><td> <span class="glyph">Î</span> </td></tr><tr id="entity-Icirc-legacy" class="impl"><td> <code>Icirc</code> </td><td> U+000CE </td><td> <span>Î</span> </td></tr><tr id="entity-icirc"><td> <code>icirc;</code> </td><td> U+000EE </td><td> <span class="glyph">î</span> </td></tr><tr id="entity-icirc-legacy" class="impl"><td> <code>icirc</code> </td><td> U+000EE </td><td> <span>î</span> </td></tr><tr id="entity-Icy"><td> <code>Icy;</code> </td><td> U+00418 </td><td> <span class="glyph">И</span> </td></tr><tr id="entity-icy"><td> <code>icy;</code> </td><td> U+00438 </td><td> <span class="glyph">и</span> </td></tr><tr id="entity-Idot"><td> <code>Idot;</code> </td><td> U+00130 </td><td> <span class="glyph">İ</span> </td></tr><tr id="entity-IEcy"><td> <code>IEcy;</code> </td><td> U+00415 </td><td> <span class="glyph">Е</span> </td></tr><tr id="entity-iecy"><td> <code>iecy;</code> </td><td> U+00435 </td><td> <span class="glyph">е</span> </td></tr><tr id="entity-iexcl"><td> <code>iexcl;</code> </td><td> U+000A1 </td><td> <span class="glyph">¡</span> </td></tr><tr id="entity-iexcl-legacy" class="impl"><td> <code>iexcl</code> </td><td> U+000A1 </td><td> <span>¡</span> </td></tr><tr id="entity-iff"><td> <code>iff;</code> </td><td> U+021D4 </td><td> <span class="glyph">⇔</span> </td></tr><tr id="entity-Ifr"><td> <code>Ifr;</code> </td><td> U+02111 </td><td> <span class="glyph">ℑ</span> </td></tr><tr id="entity-ifr"><td> <code>ifr;</code> </td><td> U+1D526 </td><td> <span class="glyph">𝔦</span> </td></tr><tr id="entity-Igrave"><td> <code>Igrave;</code> </td><td> U+000CC </td><td> <span class="glyph">Ì</span> </td></tr><tr id="entity-Igrave-legacy" class="impl"><td> <code>Igrave</code> </td><td> U+000CC </td><td> <span>Ì</span> </td></tr><tr id="entity-igrave"><td> <code>igrave;</code> </td><td> U+000EC </td><td> <span class="glyph">ì</span> </td></tr><tr id="entity-igrave-legacy" class="impl"><td> <code>igrave</code> </td><td> U+000EC </td><td> <span>ì</span> </td></tr><tr id="entity-ii"><td> <code>ii;</code> </td><td> U+02148 </td><td> <span class="glyph">ⅈ</span> </td></tr><tr id="entity-iiiint"><td> <code>iiiint;</code> </td><td> U+02A0C </td><td> <span class="glyph">⨌</span> </td></tr><tr id="entity-iiint"><td> <code>iiint;</code> </td><td> U+0222D </td><td> <span class="glyph">∭</span> </td></tr><tr id="entity-iinfin"><td> <code>iinfin;</code> </td><td> U+029DC </td><td> <span class="glyph">⧜</span> </td></tr><tr id="entity-iiota"><td> <code>iiota;</code> </td><td> U+02129 </td><td> <span class="glyph">℩</span> </td></tr><tr id="entity-IJlig"><td> <code>IJlig;</code> </td><td> U+00132 </td><td> <span class="glyph">Ĳ</span> </td></tr><tr id="entity-ijlig"><td> <code>ijlig;</code> </td><td> U+00133 </td><td> <span class="glyph">ĳ</span> </td></tr><tr id="entity-Im"><td> <code>Im;</code> </td><td> U+02111 </td><td> <span class="glyph">ℑ</span> </td></tr><tr id="entity-Imacr"><td> <code>Imacr;</code> </td><td> U+0012A </td><td> <span class="glyph">Ī</span> </td></tr><tr id="entity-imacr"><td> <code>imacr;</code> </td><td> U+0012B </td><td> <span class="glyph">ī</span> </td></tr><tr id="entity-image"><td> <code>image;</code> </td><td> U+02111 </td><td> <span class="glyph">ℑ</span> </td></tr><tr id="entity-ImaginaryI"><td> <code>ImaginaryI;</code> </td><td> U+02148 </td><td> <span class="glyph">ⅈ</span> </td></tr><tr id="entity-imagline"><td> <code>imagline;</code> </td><td> U+02110 </td><td> <span class="glyph">ℐ</span> </td></tr><tr id="entity-imagpart"><td> <code>imagpart;</code> </td><td> U+02111 </td><td> <span class="glyph">ℑ</span> </td></tr><tr id="entity-imath"><td> <code>imath;</code> </td><td> U+00131 </td><td> <span class="glyph">ı</span> </td></tr><tr id="entity-imof"><td> <code>imof;</code> </td><td> U+022B7 </td><td> <span class="glyph">⊷</span> </td></tr><tr id="entity-imped"><td> <code>imped;</code> </td><td> U+001B5 </td><td> <span class="glyph">Ƶ</span> </td></tr><tr id="entity-Implies"><td> <code>Implies;</code> </td><td> U+021D2 </td><td> <span class="glyph">⇒</span> </td></tr><tr id="entity-in"><td> <code>in;</code> </td><td> U+02208 </td><td> <span class="glyph">∈</span> </td></tr><tr id="entity-incare"><td> <code>incare;</code> </td><td> U+02105 </td><td> <span class="glyph">℅</span> </td></tr><tr id="entity-infin"><td> <code>infin;</code> </td><td> U+0221E </td><td> <span class="glyph">∞</span> </td></tr><tr id="entity-infintie"><td> <code>infintie;</code> </td><td> U+029DD </td><td> <span class="glyph">⧝</span> </td></tr><tr id="entity-inodot"><td> <code>inodot;</code> </td><td> U+00131 </td><td> <span class="glyph">ı</span> </td></tr><tr id="entity-Int"><td> <code>Int;</code> </td><td> U+0222C </td><td> <span class="glyph">∬</span> </td></tr><tr id="entity-int"><td> <code>int;</code> </td><td> U+0222B </td><td> <span class="glyph">∫</span> </td></tr><tr id="entity-intcal"><td> <code>intcal;</code> </td><td> U+022BA </td><td> <span class="glyph">⊺</span> </td></tr><tr id="entity-integers"><td> <code>integers;</code> </td><td> U+02124 </td><td> <span class="glyph">ℤ</span> </td></tr><tr id="entity-Integral"><td> <code>Integral;</code> </td><td> U+0222B </td><td> <span class="glyph">∫</span> </td></tr><tr id="entity-intercal"><td> <code>intercal;</code> </td><td> U+022BA </td><td> <span class="glyph">⊺</span> </td></tr><tr id="entity-Intersection"><td> <code>Intersection;</code> </td><td> U+022C2 </td><td> <span class="glyph">⋂</span> </td></tr><tr id="entity-intlarhk"><td> <code>intlarhk;</code> </td><td> U+02A17 </td><td> <span class="glyph">⨗</span> </td></tr><tr id="entity-intprod"><td> <code>intprod;</code> </td><td> U+02A3C </td><td> <span class="glyph">⨼</span> </td></tr><tr id="entity-InvisibleComma"><td> <code>InvisibleComma;</code> </td><td> U+02063 </td><td> <span class="glyph">⁣</span> </td></tr><tr id="entity-InvisibleTimes"><td> <code>InvisibleTimes;</code> </td><td> U+02062 </td><td> <span class="glyph">⁢</span> </td></tr><tr id="entity-IOcy"><td> <code>IOcy;</code> </td><td> U+00401 </td><td> <span class="glyph">Ё</span> </td></tr><tr id="entity-iocy"><td> <code>iocy;</code> </td><td> U+00451 </td><td> <span class="glyph">ё</span> </td></tr><tr id="entity-Iogon"><td> <code>Iogon;</code> </td><td> U+0012E </td><td> <span class="glyph">Į</span> </td></tr><tr id="entity-iogon"><td> <code>iogon;</code> </td><td> U+0012F </td><td> <span class="glyph">į</span> </td></tr><tr id="entity-Iopf"><td> <code>Iopf;</code> </td><td> U+1D540 </td><td> <span class="glyph">𝕀</span> </td></tr><tr id="entity-iopf"><td> <code>iopf;</code> </td><td> U+1D55A </td><td> <span class="glyph">𝕚</span> </td></tr><tr id="entity-Iota"><td> <code>Iota;</code> </td><td> U+00399 </td><td> <span class="glyph">Ι</span> </td></tr><tr id="entity-iota"><td> <code>iota;</code> </td><td> U+003B9 </td><td> <span class="glyph">ι</span> </td></tr><tr id="entity-iprod"><td> <code>iprod;</code> </td><td> U+02A3C </td><td> <span class="glyph">⨼</span> </td></tr><tr id="entity-iquest"><td> <code>iquest;</code> </td><td> U+000BF </td><td> <span class="glyph">¿</span> </td></tr><tr id="entity-iquest-legacy" class="impl"><td> <code>iquest</code> </td><td> U+000BF </td><td> <span>¿</span> </td></tr><tr id="entity-Iscr"><td> <code>Iscr;</code> </td><td> U+02110 </td><td> <span class="glyph">ℐ</span> </td></tr><tr id="entity-iscr"><td> <code>iscr;</code> </td><td> U+1D4BE </td><td> <span class="glyph">𝒾</span> </td></tr><tr id="entity-isin"><td> <code>isin;</code> </td><td> U+02208 </td><td> <span class="glyph">∈</span> </td></tr><tr id="entity-isindot"><td> <code>isindot;</code> </td><td> U+022F5 </td><td> <span class="glyph">⋵</span> </td></tr><tr id="entity-isinE"><td> <code>isinE;</code> </td><td> U+022F9 </td><td> <span class="glyph">⋹</span> </td></tr><tr id="entity-isins"><td> <code>isins;</code> </td><td> U+022F4 </td><td> <span class="glyph">⋴</span> </td></tr><tr id="entity-isinsv"><td> <code>isinsv;</code> </td><td> U+022F3 </td><td> <span class="glyph">⋳</span> </td></tr><tr id="entity-isinv"><td> <code>isinv;</code> </td><td> U+02208 </td><td> <span class="glyph">∈</span> </td></tr><tr id="entity-it"><td> <code>it;</code> </td><td> U+02062 </td><td> <span class="glyph">⁢</span> </td></tr><tr id="entity-Itilde"><td> <code>Itilde;</code> </td><td> U+00128 </td><td> <span class="glyph">Ĩ</span> </td></tr><tr id="entity-itilde"><td> <code>itilde;</code> </td><td> U+00129 </td><td> <span class="glyph">ĩ</span> </td></tr><tr id="entity-Iukcy"><td> <code>Iukcy;</code> </td><td> U+00406 </td><td> <span class="glyph">І</span> </td></tr><tr id="entity-iukcy"><td> <code>iukcy;</code> </td><td> U+00456 </td><td> <span class="glyph">і</span> </td></tr><tr id="entity-Iuml"><td> <code>Iuml;</code> </td><td> U+000CF </td><td> <span class="glyph">Ï</span> </td></tr><tr id="entity-Iuml-legacy" class="impl"><td> <code>Iuml</code> </td><td> U+000CF </td><td> <span>Ï</span> </td></tr><tr id="entity-iuml"><td> <code>iuml;</code> </td><td> U+000EF </td><td> <span class="glyph">ï</span> </td></tr><tr id="entity-iuml-legacy" class="impl"><td> <code>iuml</code> </td><td> U+000EF </td><td> <span>ï</span> </td></tr><tr id="entity-Jcirc"><td> <code>Jcirc;</code> </td><td> U+00134 </td><td> <span class="glyph">Ĵ</span> </td></tr><tr id="entity-jcirc"><td> <code>jcirc;</code> </td><td> U+00135 </td><td> <span class="glyph">ĵ</span> </td></tr><tr id="entity-Jcy"><td> <code>Jcy;</code> </td><td> U+00419 </td><td> <span class="glyph">Й</span> </td></tr><tr id="entity-jcy"><td> <code>jcy;</code> </td><td> U+00439 </td><td> <span class="glyph">й</span> </td></tr><tr id="entity-Jfr"><td> <code>Jfr;</code> </td><td> U+1D50D </td><td> <span class="glyph">𝔍</span> </td></tr><tr id="entity-jfr"><td> <code>jfr;</code> </td><td> U+1D527 </td><td> <span class="glyph">𝔧</span> </td></tr><tr id="entity-jmath"><td> <code>jmath;</code> </td><td> U+00237 </td><td> <span class="glyph">ȷ</span> </td></tr><tr id="entity-Jopf"><td> <code>Jopf;</code> </td><td> U+1D541 </td><td> <span class="glyph">𝕁</span> </td></tr><tr id="entity-jopf"><td> <code>jopf;</code> </td><td> U+1D55B </td><td> <span class="glyph">𝕛</span> </td></tr><tr id="entity-Jscr"><td> <code>Jscr;</code> </td><td> U+1D4A5 </td><td> <span class="glyph">𝒥</span> </td></tr><tr id="entity-jscr"><td> <code>jscr;</code> </td><td> U+1D4BF </td><td> <span class="glyph">𝒿</span> </td></tr><tr id="entity-Jsercy"><td> <code>Jsercy;</code> </td><td> U+00408 </td><td> <span class="glyph">Ј</span> </td></tr><tr id="entity-jsercy"><td> <code>jsercy;</code> </td><td> U+00458 </td><td> <span class="glyph">ј</span> </td></tr><tr id="entity-Jukcy"><td> <code>Jukcy;</code> </td><td> U+00404 </td><td> <span class="glyph">Є</span> </td></tr><tr id="entity-jukcy"><td> <code>jukcy;</code> </td><td> U+00454 </td><td> <span class="glyph">є</span> </td></tr><tr id="entity-Kappa"><td> <code>Kappa;</code> </td><td> U+0039A </td><td> <span class="glyph">Κ</span> </td></tr><tr id="entity-kappa"><td> <code>kappa;</code> </td><td> U+003BA </td><td> <span class="glyph">κ</span> </td></tr><tr id="entity-kappav"><td> <code>kappav;</code> </td><td> U+003F0 </td><td> <span class="glyph">ϰ</span> </td></tr><tr id="entity-Kcedil"><td> <code>Kcedil;</code> </td><td> U+00136 </td><td> <span class="glyph">Ķ</span> </td></tr><tr id="entity-kcedil"><td> <code>kcedil;</code> </td><td> U+00137 </td><td> <span class="glyph">ķ</span> </td></tr><tr id="entity-Kcy"><td> <code>Kcy;</code> </td><td> U+0041A </td><td> <span class="glyph">К</span> </td></tr><tr id="entity-kcy"><td> <code>kcy;</code> </td><td> U+0043A </td><td> <span class="glyph">к</span> </td></tr><tr id="entity-Kfr"><td> <code>Kfr;</code> </td><td> U+1D50E </td><td> <span class="glyph">𝔎</span> </td></tr><tr id="entity-kfr"><td> <code>kfr;</code> </td><td> U+1D528 </td><td> <span class="glyph">𝔨</span> </td></tr><tr id="entity-kgreen"><td> <code>kgreen;</code> </td><td> U+00138 </td><td> <span class="glyph">ĸ</span> </td></tr><tr id="entity-KHcy"><td> <code>KHcy;</code> </td><td> U+00425 </td><td> <span class="glyph">Х</span> </td></tr><tr id="entity-khcy"><td> <code>khcy;</code> </td><td> U+00445 </td><td> <span class="glyph">х</span> </td></tr><tr id="entity-KJcy"><td> <code>KJcy;</code> </td><td> U+0040C </td><td> <span class="glyph">Ќ</span> </td></tr><tr id="entity-kjcy"><td> <code>kjcy;</code> </td><td> U+0045C </td><td> <span class="glyph">ќ</span> </td></tr><tr id="entity-Kopf"><td> <code>Kopf;</code> </td><td> U+1D542 </td><td> <span class="glyph">𝕂</span> </td></tr><tr id="entity-kopf"><td> <code>kopf;</code> </td><td> U+1D55C </td><td> <span class="glyph">𝕜</span> </td></tr><tr id="entity-Kscr"><td> <code>Kscr;</code> </td><td> U+1D4A6 </td><td> <span class="glyph">𝒦</span> </td></tr><tr id="entity-kscr"><td> <code>kscr;</code> </td><td> U+1D4C0 </td><td> <span class="glyph">𝓀</span> </td></tr><tr id="entity-lAarr"><td> <code>lAarr;</code> </td><td> U+021DA </td><td> <span class="glyph">⇚</span> </td></tr><tr id="entity-Lacute"><td> <code>Lacute;</code> </td><td> U+00139 </td><td> <span class="glyph">Ĺ</span> </td></tr><tr id="entity-lacute"><td> <code>lacute;</code> </td><td> U+0013A </td><td> <span class="glyph">ĺ</span> </td></tr><tr id="entity-laemptyv"><td> <code>laemptyv;</code> </td><td> U+029B4 </td><td> <span class="glyph">⦴</span> </td></tr><tr id="entity-lagran"><td> <code>lagran;</code> </td><td> U+02112 </td><td> <span class="glyph">ℒ</span> </td></tr><tr id="entity-Lambda"><td> <code>Lambda;</code> </td><td> U+0039B </td><td> <span class="glyph">Λ</span> </td></tr><tr id="entity-lambda"><td> <code>lambda;</code> </td><td> U+003BB </td><td> <span class="glyph">λ</span> </td></tr><tr id="entity-Lang"><td> <code>Lang;</code> </td><td> U+027EA </td><td> <span class="glyph">⟪</span> </td></tr><tr id="entity-lang"><td> <code>lang;</code> </td><td> U+027E8 </td><td> <span class="glyph">⟨</span> </td></tr><tr id="entity-langd"><td> <code>langd;</code> </td><td> U+02991 </td><td> <span class="glyph">⦑</span> </td></tr><tr id="entity-langle"><td> <code>langle;</code> </td><td> U+027E8 </td><td> <span class="glyph">⟨</span> </td></tr><tr id="entity-lap"><td> <code>lap;</code> </td><td> U+02A85 </td><td> <span class="glyph">⪅</span> </td></tr><tr id="entity-Laplacetrf"><td> <code>Laplacetrf;</code> </td><td> U+02112 </td><td> <span class="glyph">ℒ</span> </td></tr><tr id="entity-laquo"><td> <code>laquo;</code> </td><td> U+000AB </td><td> <span class="glyph">«</span> </td></tr><tr id="entity-laquo-legacy" class="impl"><td> <code>laquo</code> </td><td> U+000AB </td><td> <span>«</span> </td></tr><tr id="entity-Larr"><td> <code>Larr;</code> </td><td> U+0219E </td><td> <span class="glyph">↞</span> </td></tr><tr id="entity-lArr"><td> <code>lArr;</code> </td><td> U+021D0 </td><td> <span class="glyph">⇐</span> </td></tr><tr id="entity-larr"><td> <code>larr;</code> </td><td> U+02190 </td><td> <span class="glyph">←</span> </td></tr><tr id="entity-larrb"><td> <code>larrb;</code> </td><td> U+021E4 </td><td> <span class="glyph">⇤</span> </td></tr><tr id="entity-larrbfs"><td> <code>larrbfs;</code> </td><td> U+0291F </td><td> <span class="glyph">⤟</span> </td></tr><tr id="entity-larrfs"><td> <code>larrfs;</code> </td><td> U+0291D </td><td> <span class="glyph">⤝</span> </td></tr><tr id="entity-larrhk"><td> <code>larrhk;</code> </td><td> U+021A9 </td><td> <span class="glyph">↩</span> </td></tr><tr id="entity-larrlp"><td> <code>larrlp;</code> </td><td> U+021AB </td><td> <span class="glyph">↫</span> </td></tr><tr id="entity-larrpl"><td> <code>larrpl;</code> </td><td> U+02939 </td><td> <span class="glyph">⤹</span> </td></tr><tr id="entity-larrsim"><td> <code>larrsim;</code> </td><td> U+02973 </td><td> <span class="glyph">⥳</span> </td></tr><tr id="entity-larrtl"><td> <code>larrtl;</code> </td><td> U+021A2 </td><td> <span class="glyph">↢</span> </td></tr><tr id="entity-lat"><td> <code>lat;</code> </td><td> U+02AAB </td><td> <span class="glyph">⪫</span> </td></tr><tr id="entity-lAtail"><td> <code>lAtail;</code> </td><td> U+0291B </td><td> <span class="glyph">⤛</span> </td></tr><tr id="entity-latail"><td> <code>latail;</code> </td><td> U+02919 </td><td> <span class="glyph">⤙</span> </td></tr><tr id="entity-late"><td> <code>late;</code> </td><td> U+02AAD </td><td> <span class="glyph">⪭</span> </td></tr><tr id="entity-lates"><td> <code>lates;</code> </td><td> U+02AAD U+0FE00 </td><td> <span class="glyph compound">⪭︀</span> </td></tr><tr id="entity-lBarr"><td> <code>lBarr;</code> </td><td> U+0290E </td><td> <span class="glyph">⤎</span> </td></tr><tr id="entity-lbarr"><td> <code>lbarr;</code> </td><td> U+0290C </td><td> <span class="glyph">⤌</span> </td></tr><tr id="entity-lbbrk"><td> <code>lbbrk;</code> </td><td> U+02772 </td><td> <span class="glyph">❲</span> </td></tr><tr id="entity-lbrace"><td> <code>lbrace;</code> </td><td> U+0007B </td><td> <span class="glyph">{</span> </td></tr><tr id="entity-lbrack"><td> <code>lbrack;</code> </td><td> U+0005B </td><td> <span class="glyph">[</span> </td></tr><tr id="entity-lbrke"><td> <code>lbrke;</code> </td><td> U+0298B </td><td> <span class="glyph">⦋</span> </td></tr><tr id="entity-lbrksld"><td> <code>lbrksld;</code> </td><td> U+0298F </td><td> <span class="glyph">⦏</span> </td></tr><tr id="entity-lbrkslu"><td> <code>lbrkslu;</code> </td><td> U+0298D </td><td> <span class="glyph">⦍</span> </td></tr><tr id="entity-Lcaron"><td> <code>Lcaron;</code> </td><td> U+0013D </td><td> <span class="glyph">Ľ</span> </td></tr><tr id="entity-lcaron"><td> <code>lcaron;</code> </td><td> U+0013E </td><td> <span class="glyph">ľ</span> </td></tr><tr id="entity-Lcedil"><td> <code>Lcedil;</code> </td><td> U+0013B </td><td> <span class="glyph">Ļ</span> </td></tr><tr id="entity-lcedil"><td> <code>lcedil;</code> </td><td> U+0013C </td><td> <span class="glyph">ļ</span> </td></tr><tr id="entity-lceil"><td> <code>lceil;</code> </td><td> U+02308 </td><td> <span class="glyph">⌈</span> </td></tr><tr id="entity-lcub"><td> <code>lcub;</code> </td><td> U+0007B </td><td> <span class="glyph">{</span> </td></tr><tr id="entity-Lcy"><td> <code>Lcy;</code> </td><td> U+0041B </td><td> <span class="glyph">Л</span> </td></tr><tr id="entity-lcy"><td> <code>lcy;</code> </td><td> U+0043B </td><td> <span class="glyph">л</span> </td></tr><tr id="entity-ldca"><td> <code>ldca;</code> </td><td> U+02936 </td><td> <span class="glyph">⤶</span> </td></tr><tr id="entity-ldquo"><td> <code>ldquo;</code> </td><td> U+0201C </td><td> <span class="glyph">“</span> </td></tr><tr id="entity-ldquor"><td> <code>ldquor;</code> </td><td> U+0201E </td><td> <span class="glyph">„</span> </td></tr><tr id="entity-ldrdhar"><td> <code>ldrdhar;</code> </td><td> U+02967 </td><td> <span class="glyph">⥧</span> </td></tr><tr id="entity-ldrushar"><td> <code>ldrushar;</code> </td><td> U+0294B </td><td> <span class="glyph">⥋</span> </td></tr><tr id="entity-ldsh"><td> <code>ldsh;</code> </td><td> U+021B2 </td><td> <span class="glyph">↲</span> </td></tr><tr id="entity-lE"><td> <code>lE;</code> </td><td> U+02266 </td><td> <span class="glyph">≦</span> </td></tr><tr id="entity-le"><td> <code>le;</code> </td><td> U+02264 </td><td> <span class="glyph">≤</span> </td></tr><tr id="entity-LeftAngleBracket"><td> <code>LeftAngleBracket;</code> </td><td> U+027E8 </td><td> <span class="glyph">⟨</span> </td></tr><tr id="entity-LeftArrow"><td> <code>LeftArrow;</code> </td><td> U+02190 </td><td> <span class="glyph">←</span> </td></tr><tr id="entity-Leftarrow"><td> <code>Leftarrow;</code> </td><td> U+021D0 </td><td> <span class="glyph">⇐</span> </td></tr><tr id="entity-leftarrow"><td> <code>leftarrow;</code> </td><td> U+02190 </td><td> <span class="glyph">←</span> </td></tr><tr id="entity-LeftArrowBar"><td> <code>LeftArrowBar;</code> </td><td> U+021E4 </td><td> <span class="glyph">⇤</span> </td></tr><tr id="entity-LeftArrowRightArrow"><td> <code>LeftArrowRightArrow;</code> </td><td> U+021C6 </td><td> <span class="glyph">⇆</span> </td></tr><tr id="entity-leftarrowtail"><td> <code>leftarrowtail;</code> </td><td> U+021A2 </td><td> <span class="glyph">↢</span> </td></tr><tr id="entity-LeftCeiling"><td> <code>LeftCeiling;</code> </td><td> U+02308 </td><td> <span class="glyph">⌈</span> </td></tr><tr id="entity-LeftDoubleBracket"><td> <code>LeftDoubleBracket;</code> </td><td> U+027E6 </td><td> <span class="glyph">⟦</span> </td></tr><tr id="entity-LeftDownTeeVector"><td> <code>LeftDownTeeVector;</code> </td><td> U+02961 </td><td> <span class="glyph">⥡</span> </td></tr><tr id="entity-LeftDownVector"><td> <code>LeftDownVector;</code> </td><td> U+021C3 </td><td> <span class="glyph">⇃</span> </td></tr><tr id="entity-LeftDownVectorBar"><td> <code>LeftDownVectorBar;</code> </td><td> U+02959 </td><td> <span class="glyph">⥙</span> </td></tr><tr id="entity-LeftFloor"><td> <code>LeftFloor;</code> </td><td> U+0230A </td><td> <span class="glyph">⌊</span> </td></tr><tr id="entity-leftharpoondown"><td> <code>leftharpoondown;</code> </td><td> U+021BD </td><td> <span class="glyph">↽</span> </td></tr><tr id="entity-leftharpoonup"><td> <code>leftharpoonup;</code> </td><td> U+021BC </td><td> <span class="glyph">↼</span> </td></tr><tr id="entity-leftleftarrows"><td> <code>leftleftarrows;</code> </td><td> U+021C7 </td><td> <span class="glyph">⇇</span> </td></tr><tr id="entity-LeftRightArrow"><td> <code>LeftRightArrow;</code> </td><td> U+02194 </td><td> <span class="glyph">↔</span> </td></tr><tr id="entity-Leftrightarrow"><td> <code>Leftrightarrow;</code> </td><td> U+021D4 </td><td> <span class="glyph">⇔</span> </td></tr><tr id="entity-leftrightarrow"><td> <code>leftrightarrow;</code> </td><td> U+02194 </td><td> <span class="glyph">↔</span> </td></tr><tr id="entity-leftrightarrows"><td> <code>leftrightarrows;</code> </td><td> U+021C6 </td><td> <span class="glyph">⇆</span> </td></tr><tr id="entity-leftrightharpoons"><td> <code>leftrightharpoons;</code> </td><td> U+021CB </td><td> <span class="glyph">⇋</span> </td></tr><tr id="entity-leftrightsquigarrow"><td> <code>leftrightsquigarrow;</code> </td><td> U+021AD </td><td> <span class="glyph">↭</span> </td></tr><tr id="entity-LeftRightVector"><td> <code>LeftRightVector;</code> </td><td> U+0294E </td><td> <span class="glyph">⥎</span> </td></tr><tr id="entity-LeftTee"><td> <code>LeftTee;</code> </td><td> U+022A3 </td><td> <span class="glyph">⊣</span> </td></tr><tr id="entity-LeftTeeArrow"><td> <code>LeftTeeArrow;</code> </td><td> U+021A4 </td><td> <span class="glyph">↤</span> </td></tr><tr id="entity-LeftTeeVector"><td> <code>LeftTeeVector;</code> </td><td> U+0295A </td><td> <span class="glyph">⥚</span> </td></tr><tr id="entity-leftthreetimes"><td> <code>leftthreetimes;</code> </td><td> U+022CB </td><td> <span class="glyph">⋋</span> </td></tr><tr id="entity-LeftTriangle"><td> <code>LeftTriangle;</code> </td><td> U+022B2 </td><td> <span class="glyph">⊲</span> </td></tr><tr id="entity-LeftTriangleBar"><td> <code>LeftTriangleBar;</code> </td><td> U+029CF </td><td> <span class="glyph">⧏</span> </td></tr><tr id="entity-LeftTriangleEqual"><td> <code>LeftTriangleEqual;</code> </td><td> U+022B4 </td><td> <span class="glyph">⊴</span> </td></tr><tr id="entity-LeftUpDownVector"><td> <code>LeftUpDownVector;</code> </td><td> U+02951 </td><td> <span class="glyph">⥑</span> </td></tr><tr id="entity-LeftUpTeeVector"><td> <code>LeftUpTeeVector;</code> </td><td> U+02960 </td><td> <span class="glyph">⥠</span> </td></tr><tr id="entity-LeftUpVector"><td> <code>LeftUpVector;</code> </td><td> U+021BF </td><td> <span class="glyph">↿</span> </td></tr><tr id="entity-LeftUpVectorBar"><td> <code>LeftUpVectorBar;</code> </td><td> U+02958 </td><td> <span class="glyph">⥘</span> </td></tr><tr id="entity-LeftVector"><td> <code>LeftVector;</code> </td><td> U+021BC </td><td> <span class="glyph">↼</span> </td></tr><tr id="entity-LeftVectorBar"><td> <code>LeftVectorBar;</code> </td><td> U+02952 </td><td> <span class="glyph">⥒</span> </td></tr><tr id="entity-lEg"><td> <code>lEg;</code> </td><td> U+02A8B </td><td> <span class="glyph">⪋</span> </td></tr><tr id="entity-leg"><td> <code>leg;</code> </td><td> U+022DA </td><td> <span class="glyph">⋚</span> </td></tr><tr id="entity-leq"><td> <code>leq;</code> </td><td> U+02264 </td><td> <span class="glyph">≤</span> </td></tr><tr id="entity-leqq"><td> <code>leqq;</code> </td><td> U+02266 </td><td> <span class="glyph">≦</span> </td></tr><tr id="entity-leqslant"><td> <code>leqslant;</code> </td><td> U+02A7D </td><td> <span class="glyph">⩽</span> </td></tr><tr id="entity-les"><td> <code>les;</code> </td><td> U+02A7D </td><td> <span class="glyph">⩽</span> </td></tr><tr id="entity-lescc"><td> <code>lescc;</code> </td><td> U+02AA8 </td><td> <span class="glyph">⪨</span> </td></tr><tr id="entity-lesdot"><td> <code>lesdot;</code> </td><td> U+02A7F </td><td> <span class="glyph">⩿</span> </td></tr><tr id="entity-lesdoto"><td> <code>lesdoto;</code> </td><td> U+02A81 </td><td> <span class="glyph">⪁</span> </td></tr><tr id="entity-lesdotor"><td> <code>lesdotor;</code> </td><td> U+02A83 </td><td> <span class="glyph">⪃</span> </td></tr><tr id="entity-lesg"><td> <code>lesg;</code> </td><td> U+022DA U+0FE00 </td><td> <span class="glyph compound">⋚︀</span> </td></tr><tr id="entity-lesges"><td> <code>lesges;</code> </td><td> U+02A93 </td><td> <span class="glyph">⪓</span> </td></tr><tr id="entity-lessapprox"><td> <code>lessapprox;</code> </td><td> U+02A85 </td><td> <span class="glyph">⪅</span> </td></tr><tr id="entity-lessdot"><td> <code>lessdot;</code> </td><td> U+022D6 </td><td> <span class="glyph">⋖</span> </td></tr><tr id="entity-lesseqgtr"><td> <code>lesseqgtr;</code> </td><td> U+022DA </td><td> <span class="glyph">⋚</span> </td></tr><tr id="entity-lesseqqgtr"><td> <code>lesseqqgtr;</code> </td><td> U+02A8B </td><td> <span class="glyph">⪋</span> </td></tr><tr id="entity-LessEqualGreater"><td> <code>LessEqualGreater;</code> </td><td> U+022DA </td><td> <span class="glyph">⋚</span> </td></tr><tr id="entity-LessFullEqual"><td> <code>LessFullEqual;</code> </td><td> U+02266 </td><td> <span class="glyph">≦</span> </td></tr><tr id="entity-LessGreater"><td> <code>LessGreater;</code> </td><td> U+02276 </td><td> <span class="glyph">≶</span> </td></tr><tr id="entity-lessgtr"><td> <code>lessgtr;</code> </td><td> U+02276 </td><td> <span class="glyph">≶</span> </td></tr><tr id="entity-LessLess"><td> <code>LessLess;</code> </td><td> U+02AA1 </td><td> <span class="glyph">⪡</span> </td></tr><tr id="entity-lesssim"><td> <code>lesssim;</code> </td><td> U+02272 </td><td> <span class="glyph">≲</span> </td></tr><tr id="entity-LessSlantEqual"><td> <code>LessSlantEqual;</code> </td><td> U+02A7D </td><td> <span class="glyph">⩽</span> </td></tr><tr id="entity-LessTilde"><td> <code>LessTilde;</code> </td><td> U+02272 </td><td> <span class="glyph">≲</span> </td></tr><tr id="entity-lfisht"><td> <code>lfisht;</code> </td><td> U+0297C </td><td> <span class="glyph">⥼</span> </td></tr><tr id="entity-lfloor"><td> <code>lfloor;</code> </td><td> U+0230A </td><td> <span class="glyph">⌊</span> </td></tr><tr id="entity-Lfr"><td> <code>Lfr;</code> </td><td> U+1D50F </td><td> <span class="glyph">𝔏</span> </td></tr><tr id="entity-lfr"><td> <code>lfr;</code> </td><td> U+1D529 </td><td> <span class="glyph">𝔩</span> </td></tr><tr id="entity-lg"><td> <code>lg;</code> </td><td> U+02276 </td><td> <span class="glyph">≶</span> </td></tr><tr id="entity-lgE"><td> <code>lgE;</code> </td><td> U+02A91 </td><td> <span class="glyph">⪑</span> </td></tr><tr id="entity-lHar"><td> <code>lHar;</code> </td><td> U+02962 </td><td> <span class="glyph">⥢</span> </td></tr><tr id="entity-lhard"><td> <code>lhard;</code> </td><td> U+021BD </td><td> <span class="glyph">↽</span> </td></tr><tr id="entity-lharu"><td> <code>lharu;</code> </td><td> U+021BC </td><td> <span class="glyph">↼</span> </td></tr><tr id="entity-lharul"><td> <code>lharul;</code> </td><td> U+0296A </td><td> <span class="glyph">⥪</span> </td></tr><tr id="entity-lhblk"><td> <code>lhblk;</code> </td><td> U+02584 </td><td> <span class="glyph">▄</span> </td></tr><tr id="entity-LJcy"><td> <code>LJcy;</code> </td><td> U+00409 </td><td> <span class="glyph">Љ</span> </td></tr><tr id="entity-ljcy"><td> <code>ljcy;</code> </td><td> U+00459 </td><td> <span class="glyph">љ</span> </td></tr><tr id="entity-Ll"><td> <code>Ll;</code> </td><td> U+022D8 </td><td> <span class="glyph">⋘</span> </td></tr><tr id="entity-ll"><td> <code>ll;</code> </td><td> U+0226A </td><td> <span class="glyph">≪</span> </td></tr><tr id="entity-llarr"><td> <code>llarr;</code> </td><td> U+021C7 </td><td> <span class="glyph">⇇</span> </td></tr><tr id="entity-llcorner"><td> <code>llcorner;</code> </td><td> U+0231E </td><td> <span class="glyph">⌞</span> </td></tr><tr id="entity-Lleftarrow"><td> <code>Lleftarrow;</code> </td><td> U+021DA </td><td> <span class="glyph">⇚</span> </td></tr><tr id="entity-llhard"><td> <code>llhard;</code> </td><td> U+0296B </td><td> <span class="glyph">⥫</span> </td></tr><tr id="entity-lltri"><td> <code>lltri;</code> </td><td> U+025FA </td><td> <span class="glyph">◺</span> </td></tr><tr id="entity-Lmidot"><td> <code>Lmidot;</code> </td><td> U+0013F </td><td> <span class="glyph">Ŀ</span> </td></tr><tr id="entity-lmidot"><td> <code>lmidot;</code> </td><td> U+00140 </td><td> <span class="glyph">ŀ</span> </td></tr><tr id="entity-lmoust"><td> <code>lmoust;</code> </td><td> U+023B0 </td><td> <span class="glyph">⎰</span> </td></tr><tr id="entity-lmoustache"><td> <code>lmoustache;</code> </td><td> U+023B0 </td><td> <span class="glyph">⎰</span> </td></tr><tr id="entity-lnap"><td> <code>lnap;</code> </td><td> U+02A89 </td><td> <span class="glyph">⪉</span> </td></tr><tr id="entity-lnapprox"><td> <code>lnapprox;</code> </td><td> U+02A89 </td><td> <span class="glyph">⪉</span> </td></tr><tr id="entity-lnE"><td> <code>lnE;</code> </td><td> U+02268 </td><td> <span class="glyph">≨</span> </td></tr><tr id="entity-lne"><td> <code>lne;</code> </td><td> U+02A87 </td><td> <span class="glyph">⪇</span> </td></tr><tr id="entity-lneq"><td> <code>lneq;</code> </td><td> U+02A87 </td><td> <span class="glyph">⪇</span> </td></tr><tr id="entity-lneqq"><td> <code>lneqq;</code> </td><td> U+02268 </td><td> <span class="glyph">≨</span> </td></tr><tr id="entity-lnsim"><td> <code>lnsim;</code> </td><td> U+022E6 </td><td> <span class="glyph">⋦</span> </td></tr><tr id="entity-loang"><td> <code>loang;</code> </td><td> U+027EC </td><td> <span class="glyph">⟬</span> </td></tr><tr id="entity-loarr"><td> <code>loarr;</code> </td><td> U+021FD </td><td> <span class="glyph">⇽</span> </td></tr><tr id="entity-lobrk"><td> <code>lobrk;</code> </td><td> U+027E6 </td><td> <span class="glyph">⟦</span> </td></tr><tr id="entity-LongLeftArrow"><td> <code>LongLeftArrow;</code> </td><td> U+027F5 </td><td> <span class="glyph">⟵</span> </td></tr><tr id="entity-Longleftarrow"><td> <code>Longleftarrow;</code> </td><td> U+027F8 </td><td> <span class="glyph">⟸</span> </td></tr><tr id="entity-longleftarrow"><td> <code>longleftarrow;</code> </td><td> U+027F5 </td><td> <span class="glyph">⟵</span> </td></tr><tr id="entity-LongLeftRightArrow"><td> <code>LongLeftRightArrow;</code> </td><td> U+027F7 </td><td> <span class="glyph">⟷</span> </td></tr><tr id="entity-Longleftrightarrow"><td> <code>Longleftrightarrow;</code> </td><td> U+027FA </td><td> <span class="glyph">⟺</span> </td></tr><tr id="entity-longleftrightarrow"><td> <code>longleftrightarrow;</code> </td><td> U+027F7 </td><td> <span class="glyph">⟷</span> </td></tr><tr id="entity-longmapsto"><td> <code>longmapsto;</code> </td><td> U+027FC </td><td> <span class="glyph">⟼</span> </td></tr><tr id="entity-LongRightArrow"><td> <code>LongRightArrow;</code> </td><td> U+027F6 </td><td> <span class="glyph">⟶</span> </td></tr><tr id="entity-Longrightarrow"><td> <code>Longrightarrow;</code> </td><td> U+027F9 </td><td> <span class="glyph">⟹</span> </td></tr><tr id="entity-longrightarrow"><td> <code>longrightarrow;</code> </td><td> U+027F6 </td><td> <span class="glyph">⟶</span> </td></tr><tr id="entity-looparrowleft"><td> <code>looparrowleft;</code> </td><td> U+021AB </td><td> <span class="glyph">↫</span> </td></tr><tr id="entity-looparrowright"><td> <code>looparrowright;</code> </td><td> U+021AC </td><td> <span class="glyph">↬</span> </td></tr><tr id="entity-lopar"><td> <code>lopar;</code> </td><td> U+02985 </td><td> <span class="glyph">⦅</span> </td></tr><tr id="entity-Lopf"><td> <code>Lopf;</code> </td><td> U+1D543 </td><td> <span class="glyph">𝕃</span> </td></tr><tr id="entity-lopf"><td> <code>lopf;</code> </td><td> U+1D55D </td><td> <span class="glyph">𝕝</span> </td></tr><tr id="entity-loplus"><td> <code>loplus;</code> </td><td> U+02A2D </td><td> <span class="glyph">⨭</span> </td></tr><tr id="entity-lotimes"><td> <code>lotimes;</code> </td><td> U+02A34 </td><td> <span class="glyph">⨴</span> </td></tr><tr id="entity-lowast"><td> <code>lowast;</code> </td><td> U+02217 </td><td> <span class="glyph">∗</span> </td></tr><tr id="entity-lowbar"><td> <code>lowbar;</code> </td><td> U+0005F </td><td> <span class="glyph">_</span> </td></tr><tr id="entity-LowerLeftArrow"><td> <code>LowerLeftArrow;</code> </td><td> U+02199 </td><td> <span class="glyph">↙</span> </td></tr><tr id="entity-LowerRightArrow"><td> <code>LowerRightArrow;</code> </td><td> U+02198 </td><td> <span class="glyph">↘</span> </td></tr><tr id="entity-loz"><td> <code>loz;</code> </td><td> U+025CA </td><td> <span class="glyph">◊</span> </td></tr><tr id="entity-lozenge"><td> <code>lozenge;</code> </td><td> U+025CA </td><td> <span class="glyph">◊</span> </td></tr><tr id="entity-lozf"><td> <code>lozf;</code> </td><td> U+029EB </td><td> <span class="glyph">⧫</span> </td></tr><tr id="entity-lpar"><td> <code>lpar;</code> </td><td> U+00028 </td><td> <span class="glyph">(</span> </td></tr><tr id="entity-lparlt"><td> <code>lparlt;</code> </td><td> U+02993 </td><td> <span class="glyph">⦓</span> </td></tr><tr id="entity-lrarr"><td> <code>lrarr;</code> </td><td> U+021C6 </td><td> <span class="glyph">⇆</span> </td></tr><tr id="entity-lrcorner"><td> <code>lrcorner;</code> </td><td> U+0231F </td><td> <span class="glyph">⌟</span> </td></tr><tr id="entity-lrhar"><td> <code>lrhar;</code> </td><td> U+021CB </td><td> <span class="glyph">⇋</span> </td></tr><tr id="entity-lrhard"><td> <code>lrhard;</code> </td><td> U+0296D </td><td> <span class="glyph">⥭</span> </td></tr><tr id="entity-lrm"><td> <code>lrm;</code> </td><td> U+0200E </td><td> <span class="glyph">‎</span> </td></tr><tr id="entity-lrtri"><td> <code>lrtri;</code> </td><td> U+022BF </td><td> <span class="glyph">⊿</span> </td></tr><tr id="entity-lsaquo"><td> <code>lsaquo;</code> </td><td> U+02039 </td><td> <span class="glyph">‹</span> </td></tr><tr id="entity-Lscr"><td> <code>Lscr;</code> </td><td> U+02112 </td><td> <span class="glyph">ℒ</span> </td></tr><tr id="entity-lscr"><td> <code>lscr;</code> </td><td> U+1D4C1 </td><td> <span class="glyph">𝓁</span> </td></tr><tr id="entity-Lsh"><td> <code>Lsh;</code> </td><td> U+021B0 </td><td> <span class="glyph">↰</span> </td></tr><tr id="entity-lsh"><td> <code>lsh;</code> </td><td> U+021B0 </td><td> <span class="glyph">↰</span> </td></tr><tr id="entity-lsim"><td> <code>lsim;</code> </td><td> U+02272 </td><td> <span class="glyph">≲</span> </td></tr><tr id="entity-lsime"><td> <code>lsime;</code> </td><td> U+02A8D </td><td> <span class="glyph">⪍</span> </td></tr><tr id="entity-lsimg"><td> <code>lsimg;</code> </td><td> U+02A8F </td><td> <span class="glyph">⪏</span> </td></tr><tr id="entity-lsqb"><td> <code>lsqb;</code> </td><td> U+0005B </td><td> <span class="glyph">[</span> </td></tr><tr id="entity-lsquo"><td> <code>lsquo;</code> </td><td> U+02018 </td><td> <span class="glyph">‘</span> </td></tr><tr id="entity-lsquor"><td> <code>lsquor;</code> </td><td> U+0201A </td><td> <span class="glyph">‚</span> </td></tr><tr id="entity-Lstrok"><td> <code>Lstrok;</code> </td><td> U+00141 </td><td> <span class="glyph">Ł</span> </td></tr><tr id="entity-lstrok"><td> <code>lstrok;</code> </td><td> U+00142 </td><td> <span class="glyph">ł</span> </td></tr><tr id="entity-LT"><td> <code>LT;</code> </td><td> U+0003C </td><td> <span class="glyph">&lt;</span> </td></tr><tr id="entity-LT-legacy" class="impl"><td> <code>LT</code> </td><td> U+0003C </td><td> <span>&lt;</span> </td></tr><tr id="entity-Lt"><td> <code>Lt;</code> </td><td> U+0226A </td><td> <span class="glyph">≪</span> </td></tr><tr id="entity-lt"><td> <code>lt;</code> </td><td> U+0003C </td><td> <span class="glyph">&lt;</span> </td></tr><tr id="entity-lt-legacy" class="impl"><td> <code>lt</code> </td><td> U+0003C </td><td> <span>&lt;</span> </td></tr><tr id="entity-ltcc"><td> <code>ltcc;</code> </td><td> U+02AA6 </td><td> <span class="glyph">⪦</span> </td></tr><tr id="entity-ltcir"><td> <code>ltcir;</code> </td><td> U+02A79 </td><td> <span class="glyph">⩹</span> </td></tr><tr id="entity-ltdot"><td> <code>ltdot;</code> </td><td> U+022D6 </td><td> <span class="glyph">⋖</span> </td></tr><tr id="entity-lthree"><td> <code>lthree;</code> </td><td> U+022CB </td><td> <span class="glyph">⋋</span> </td></tr><tr id="entity-ltimes"><td> <code>ltimes;</code> </td><td> U+022C9 </td><td> <span class="glyph">⋉</span> </td></tr><tr id="entity-ltlarr"><td> <code>ltlarr;</code> </td><td> U+02976 </td><td> <span class="glyph">⥶</span> </td></tr><tr id="entity-ltquest"><td> <code>ltquest;</code> </td><td> U+02A7B </td><td> <span class="glyph">⩻</span> </td></tr><tr id="entity-ltri"><td> <code>ltri;</code> </td><td> U+025C3 </td><td> <span class="glyph">◃</span> </td></tr><tr id="entity-ltrie"><td> <code>ltrie;</code> </td><td> U+022B4 </td><td> <span class="glyph">⊴</span> </td></tr><tr id="entity-ltrif"><td> <code>ltrif;</code> </td><td> U+025C2 </td><td> <span class="glyph">◂</span> </td></tr><tr id="entity-ltrPar"><td> <code>ltrPar;</code> </td><td> U+02996 </td><td> <span class="glyph">⦖</span> </td></tr><tr id="entity-lurdshar"><td> <code>lurdshar;</code> </td><td> U+0294A </td><td> <span class="glyph">⥊</span> </td></tr><tr id="entity-luruhar"><td> <code>luruhar;</code> </td><td> U+02966 </td><td> <span class="glyph">⥦</span> </td></tr><tr id="entity-lvertneqq"><td> <code>lvertneqq;</code> </td><td> U+02268 U+0FE00 </td><td> <span class="glyph compound">≨︀</span> </td></tr><tr id="entity-lvnE"><td> <code>lvnE;</code> </td><td> U+02268 U+0FE00 </td><td> <span class="glyph compound">≨︀</span> </td></tr><tr id="entity-macr"><td> <code>macr;</code> </td><td> U+000AF </td><td> <span class="glyph">¯</span> </td></tr><tr id="entity-macr-legacy" class="impl"><td> <code>macr</code> </td><td> U+000AF </td><td> <span>¯</span> </td></tr><tr id="entity-male"><td> <code>male;</code> </td><td> U+02642 </td><td> <span class="glyph">♂</span> </td></tr><tr id="entity-malt"><td> <code>malt;</code> </td><td> U+02720 </td><td> <span class="glyph">✠</span> </td></tr><tr id="entity-maltese"><td> <code>maltese;</code> </td><td> U+02720 </td><td> <span class="glyph">✠</span> </td></tr><tr id="entity-Map"><td> <code>Map;</code> </td><td> U+02905 </td><td> <span class="glyph">⤅</span> </td></tr><tr id="entity-map"><td> <code>map;</code> </td><td> U+021A6 </td><td> <span class="glyph">↦</span> </td></tr><tr id="entity-mapsto"><td> <code>mapsto;</code> </td><td> U+021A6 </td><td> <span class="glyph">↦</span> </td></tr><tr id="entity-mapstodown"><td> <code>mapstodown;</code> </td><td> U+021A7 </td><td> <span class="glyph">↧</span> </td></tr><tr id="entity-mapstoleft"><td> <code>mapstoleft;</code> </td><td> U+021A4 </td><td> <span class="glyph">↤</span> </td></tr><tr id="entity-mapstoup"><td> <code>mapstoup;</code> </td><td> U+021A5 </td><td> <span class="glyph">↥</span> </td></tr><tr id="entity-marker"><td> <code>marker;</code> </td><td> U+025AE </td><td> <span class="glyph">▮</span> </td></tr><tr id="entity-mcomma"><td> <code>mcomma;</code> </td><td> U+02A29 </td><td> <span class="glyph">⨩</span> </td></tr><tr id="entity-Mcy"><td> <code>Mcy;</code> </td><td> U+0041C </td><td> <span class="glyph">М</span> </td></tr><tr id="entity-mcy"><td> <code>mcy;</code> </td><td> U+0043C </td><td> <span class="glyph">м</span> </td></tr><tr id="entity-mdash"><td> <code>mdash;</code> </td><td> U+02014 </td><td> <span class="glyph">—</span> </td></tr><tr id="entity-mDDot"><td> <code>mDDot;</code> </td><td> U+0223A </td><td> <span class="glyph">∺</span> </td></tr><tr id="entity-measuredangle"><td> <code>measuredangle;</code> </td><td> U+02221 </td><td> <span class="glyph">∡</span> </td></tr><tr id="entity-MediumSpace"><td> <code>MediumSpace;</code> </td><td> U+0205F </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-Mellintrf"><td> <code>Mellintrf;</code> </td><td> U+02133 </td><td> <span class="glyph">ℳ</span> </td></tr><tr id="entity-Mfr"><td> <code>Mfr;</code> </td><td> U+1D510 </td><td> <span class="glyph">𝔐</span> </td></tr><tr id="entity-mfr"><td> <code>mfr;</code> </td><td> U+1D52A </td><td> <span class="glyph">𝔪</span> </td></tr><tr id="entity-mho"><td> <code>mho;</code> </td><td> U+02127 </td><td> <span class="glyph">℧</span> </td></tr><tr id="entity-micro"><td> <code>micro;</code> </td><td> U+000B5 </td><td> <span class="glyph">µ</span> </td></tr><tr id="entity-micro-legacy" class="impl"><td> <code>micro</code> </td><td> U+000B5 </td><td> <span>µ</span> </td></tr><tr id="entity-mid"><td> <code>mid;</code> </td><td> U+02223 </td><td> <span class="glyph">∣</span> </td></tr><tr id="entity-midast"><td> <code>midast;</code> </td><td> U+0002A </td><td> <span class="glyph">*</span> </td></tr><tr id="entity-midcir"><td> <code>midcir;</code> </td><td> U+02AF0 </td><td> <span class="glyph">⫰</span> </td></tr><tr id="entity-middot"><td> <code>middot;</code> </td><td> U+000B7 </td><td> <span class="glyph">·</span> </td></tr><tr id="entity-middot-legacy" class="impl"><td> <code>middot</code> </td><td> U+000B7 </td><td> <span>·</span> </td></tr><tr id="entity-minus"><td> <code>minus;</code> </td><td> U+02212 </td><td> <span class="glyph">−</span> </td></tr><tr id="entity-minusb"><td> <code>minusb;</code> </td><td> U+0229F </td><td> <span class="glyph">⊟</span> </td></tr><tr id="entity-minusd"><td> <code>minusd;</code> </td><td> U+02238 </td><td> <span class="glyph">∸</span> </td></tr><tr id="entity-minusdu"><td> <code>minusdu;</code> </td><td> U+02A2A </td><td> <span class="glyph">⨪</span> </td></tr><tr id="entity-MinusPlus"><td> <code>MinusPlus;</code> </td><td> U+02213 </td><td> <span class="glyph">∓</span> </td></tr><tr id="entity-mlcp"><td> <code>mlcp;</code> </td><td> U+02ADB </td><td> <span class="glyph">⫛</span> </td></tr><tr id="entity-mldr"><td> <code>mldr;</code> </td><td> U+02026 </td><td> <span class="glyph">…</span> </td></tr><tr id="entity-mnplus"><td> <code>mnplus;</code> </td><td> U+02213 </td><td> <span class="glyph">∓</span> </td></tr><tr id="entity-models"><td> <code>models;</code> </td><td> U+022A7 </td><td> <span class="glyph">⊧</span> </td></tr><tr id="entity-Mopf"><td> <code>Mopf;</code> </td><td> U+1D544 </td><td> <span class="glyph">𝕄</span> </td></tr><tr id="entity-mopf"><td> <code>mopf;</code> </td><td> U+1D55E </td><td> <span class="glyph">𝕞</span> </td></tr><tr id="entity-mp"><td> <code>mp;</code> </td><td> U+02213 </td><td> <span class="glyph">∓</span> </td></tr><tr id="entity-Mscr"><td> <code>Mscr;</code> </td><td> U+02133 </td><td> <span class="glyph">ℳ</span> </td></tr><tr id="entity-mscr"><td> <code>mscr;</code> </td><td> U+1D4C2 </td><td> <span class="glyph">𝓂</span> </td></tr><tr id="entity-mstpos"><td> <code>mstpos;</code> </td><td> U+0223E </td><td> <span class="glyph">∾</span> </td></tr><tr id="entity-Mu"><td> <code>Mu;</code> </td><td> U+0039C </td><td> <span class="glyph">Μ</span> </td></tr><tr id="entity-mu"><td> <code>mu;</code> </td><td> U+003BC </td><td> <span class="glyph">μ</span> </td></tr><tr id="entity-multimap"><td> <code>multimap;</code> </td><td> U+022B8 </td><td> <span class="glyph">⊸</span> </td></tr><tr id="entity-mumap"><td> <code>mumap;</code> </td><td> U+022B8 </td><td> <span class="glyph">⊸</span> </td></tr><tr id="entity-nabla"><td> <code>nabla;</code> </td><td> U+02207 </td><td> <span class="glyph">∇</span> </td></tr><tr id="entity-Nacute"><td> <code>Nacute;</code> </td><td> U+00143 </td><td> <span class="glyph">Ń</span> </td></tr><tr id="entity-nacute"><td> <code>nacute;</code> </td><td> U+00144 </td><td> <span class="glyph">ń</span> </td></tr><tr id="entity-nang"><td> <code>nang;</code> </td><td> U+02220 U+020D2 </td><td> <span class="glyph compound">∠⃒</span> </td></tr><tr id="entity-nap"><td> <code>nap;</code> </td><td> U+02249 </td><td> <span class="glyph">≉</span> </td></tr><tr id="entity-napE"><td> <code>napE;</code> </td><td> U+02A70 U+00338 </td><td> <span class="glyph compound">⩰̸</span> </td></tr><tr id="entity-napid"><td> <code>napid;</code> </td><td> U+0224B U+00338 </td><td> <span class="glyph compound">≋̸</span> </td></tr><tr id="entity-napos"><td> <code>napos;</code> </td><td> U+00149 </td><td> <span class="glyph">ŉ</span> </td></tr><tr id="entity-napprox"><td> <code>napprox;</code> </td><td> U+02249 </td><td> <span class="glyph">≉</span> </td></tr><tr id="entity-natur"><td> <code>natur;</code> </td><td> U+0266E </td><td> <span class="glyph">♮</span> </td></tr><tr id="entity-natural"><td> <code>natural;</code> </td><td> U+0266E </td><td> <span class="glyph">♮</span> </td></tr><tr id="entity-naturals"><td> <code>naturals;</code> </td><td> U+02115 </td><td> <span class="glyph">ℕ</span> </td></tr><tr id="entity-nbsp"><td> <code>nbsp;</code> </td><td> U+000A0 </td><td> <span class="glyph">&nbsp;</span> </td></tr><tr id="entity-nbsp-legacy" class="impl"><td> <code>nbsp</code> </td><td> U+000A0 </td><td> <span>&nbsp;</span> </td></tr><tr id="entity-nbump"><td> <code>nbump;</code> </td><td> U+0224E U+00338 </td><td> <span class="glyph compound">≎̸</span> </td></tr><tr id="entity-nbumpe"><td> <code>nbumpe;</code> </td><td> U+0224F U+00338 </td><td> <span class="glyph compound">≏̸</span> </td></tr><tr id="entity-ncap"><td> <code>ncap;</code> </td><td> U+02A43 </td><td> <span class="glyph">⩃</span> </td></tr><tr id="entity-Ncaron"><td> <code>Ncaron;</code> </td><td> U+00147 </td><td> <span class="glyph">Ň</span> </td></tr><tr id="entity-ncaron"><td> <code>ncaron;</code> </td><td> U+00148 </td><td> <span class="glyph">ň</span> </td></tr><tr id="entity-Ncedil"><td> <code>Ncedil;</code> </td><td> U+00145 </td><td> <span class="glyph">Ņ</span> </td></tr><tr id="entity-ncedil"><td> <code>ncedil;</code> </td><td> U+00146 </td><td> <span class="glyph">ņ</span> </td></tr><tr id="entity-ncong"><td> <code>ncong;</code> </td><td> U+02247 </td><td> <span class="glyph">≇</span> </td></tr><tr id="entity-ncongdot"><td> <code>ncongdot;</code> </td><td> U+02A6D U+00338 </td><td> <span class="glyph compound">⩭̸</span> </td></tr><tr id="entity-ncup"><td> <code>ncup;</code> </td><td> U+02A42 </td><td> <span class="glyph">⩂</span> </td></tr><tr id="entity-Ncy"><td> <code>Ncy;</code> </td><td> U+0041D </td><td> <span class="glyph">Н</span> </td></tr><tr id="entity-ncy"><td> <code>ncy;</code> </td><td> U+0043D </td><td> <span class="glyph">н</span> </td></tr><tr id="entity-ndash"><td> <code>ndash;</code> </td><td> U+02013 </td><td> <span class="glyph">–</span> </td></tr><tr id="entity-ne"><td> <code>ne;</code> </td><td> U+02260 </td><td> <span class="glyph">≠</span> </td></tr><tr id="entity-nearhk"><td> <code>nearhk;</code> </td><td> U+02924 </td><td> <span class="glyph">⤤</span> </td></tr><tr id="entity-neArr"><td> <code>neArr;</code> </td><td> U+021D7 </td><td> <span class="glyph">⇗</span> </td></tr><tr id="entity-nearr"><td> <code>nearr;</code> </td><td> U+02197 </td><td> <span class="glyph">↗</span> </td></tr><tr id="entity-nearrow"><td> <code>nearrow;</code> </td><td> U+02197 </td><td> <span class="glyph">↗</span> </td></tr><tr id="entity-nedot"><td> <code>nedot;</code> </td><td> U+02250 U+00338 </td><td> <span class="glyph compound">≐̸</span> </td></tr><tr id="entity-NegativeMediumSpace"><td> <code>NegativeMediumSpace;</code> </td><td> U+0200B </td><td> <span class="glyph">​</span> </td></tr><tr id="entity-NegativeThickSpace"><td> <code>NegativeThickSpace;</code> </td><td> U+0200B </td><td> <span class="glyph">​</span> </td></tr><tr id="entity-NegativeThinSpace"><td> <code>NegativeThinSpace;</code> </td><td> U+0200B </td><td> <span class="glyph">​</span> </td></tr><tr id="entity-NegativeVeryThinSpace"><td> <code>NegativeVeryThinSpace;</code> </td><td> U+0200B </td><td> <span class="glyph">​</span> </td></tr><tr id="entity-nequiv"><td> <code>nequiv;</code> </td><td> U+02262 </td><td> <span class="glyph">≢</span> </td></tr><tr id="entity-nesear"><td> <code>nesear;</code> </td><td> U+02928 </td><td> <span class="glyph">⤨</span> </td></tr><tr id="entity-nesim"><td> <code>nesim;</code> </td><td> U+02242 U+00338 </td><td> <span class="glyph compound">≂̸</span> </td></tr><tr id="entity-NestedGreaterGreater"><td> <code>NestedGreaterGreater;</code> </td><td> U+0226B </td><td> <span class="glyph">≫</span> </td></tr><tr id="entity-NestedLessLess"><td> <code>NestedLessLess;</code> </td><td> U+0226A </td><td> <span class="glyph">≪</span> </td></tr><tr id="entity-NewLine"><td> <code>NewLine;</code> </td><td> U+0000A </td><td> <span class="glyph control">␊</span> </td></tr><tr id="entity-nexist"><td> <code>nexist;</code> </td><td> U+02204 </td><td> <span class="glyph">∄</span> </td></tr><tr id="entity-nexists"><td> <code>nexists;</code> </td><td> U+02204 </td><td> <span class="glyph">∄</span> </td></tr><tr id="entity-Nfr"><td> <code>Nfr;</code> </td><td> U+1D511 </td><td> <span class="glyph">𝔑</span> </td></tr><tr id="entity-nfr"><td> <code>nfr;</code> </td><td> U+1D52B </td><td> <span class="glyph">𝔫</span> </td></tr><tr id="entity-ngE"><td> <code>ngE;</code> </td><td> U+02267 U+00338 </td><td> <span class="glyph compound">≧̸</span> </td></tr><tr id="entity-nge"><td> <code>nge;</code> </td><td> U+02271 </td><td> <span class="glyph">≱</span> </td></tr><tr id="entity-ngeq"><td> <code>ngeq;</code> </td><td> U+02271 </td><td> <span class="glyph">≱</span> </td></tr><tr id="entity-ngeqq"><td> <code>ngeqq;</code> </td><td> U+02267 U+00338 </td><td> <span class="glyph compound">≧̸</span> </td></tr><tr id="entity-ngeqslant"><td> <code>ngeqslant;</code> </td><td> U+02A7E U+00338 </td><td> <span class="glyph compound">⩾̸</span> </td></tr><tr id="entity-nges"><td> <code>nges;</code> </td><td> U+02A7E U+00338 </td><td> <span class="glyph compound">⩾̸</span> </td></tr><tr id="entity-nGg"><td> <code>nGg;</code> </td><td> U+022D9 U+00338 </td><td> <span class="glyph compound">⋙̸</span> </td></tr><tr id="entity-ngsim"><td> <code>ngsim;</code> </td><td> U+02275 </td><td> <span class="glyph">≵</span> </td></tr><tr id="entity-nGt"><td> <code>nGt;</code> </td><td> U+0226B U+020D2 </td><td> <span class="glyph compound">≫⃒</span> </td></tr><tr id="entity-ngt"><td> <code>ngt;</code> </td><td> U+0226F </td><td> <span class="glyph">≯</span> </td></tr><tr id="entity-ngtr"><td> <code>ngtr;</code> </td><td> U+0226F </td><td> <span class="glyph">≯</span> </td></tr><tr id="entity-nGtv"><td> <code>nGtv;</code> </td><td> U+0226B U+00338 </td><td> <span class="glyph compound">≫̸</span> </td></tr><tr id="entity-nhArr"><td> <code>nhArr;</code> </td><td> U+021CE </td><td> <span class="glyph">⇎</span> </td></tr><tr id="entity-nharr"><td> <code>nharr;</code> </td><td> U+021AE </td><td> <span class="glyph">↮</span> </td></tr><tr id="entity-nhpar"><td> <code>nhpar;</code> </td><td> U+02AF2 </td><td> <span class="glyph">⫲</span> </td></tr><tr id="entity-ni"><td> <code>ni;</code> </td><td> U+0220B </td><td> <span class="glyph">∋</span> </td></tr><tr id="entity-nis"><td> <code>nis;</code> </td><td> U+022FC </td><td> <span class="glyph">⋼</span> </td></tr><tr id="entity-nisd"><td> <code>nisd;</code> </td><td> U+022FA </td><td> <span class="glyph">⋺</span> </td></tr><tr id="entity-niv"><td> <code>niv;</code> </td><td> U+0220B </td><td> <span class="glyph">∋</span> </td></tr><tr id="entity-NJcy"><td> <code>NJcy;</code> </td><td> U+0040A </td><td> <span class="glyph">Њ</span> </td></tr><tr id="entity-njcy"><td> <code>njcy;</code> </td><td> U+0045A </td><td> <span class="glyph">њ</span> </td></tr><tr id="entity-nlArr"><td> <code>nlArr;</code> </td><td> U+021CD </td><td> <span class="glyph">⇍</span> </td></tr><tr id="entity-nlarr"><td> <code>nlarr;</code> </td><td> U+0219A </td><td> <span class="glyph">↚</span> </td></tr><tr id="entity-nldr"><td> <code>nldr;</code> </td><td> U+02025 </td><td> <span class="glyph">‥</span> </td></tr><tr id="entity-nlE"><td> <code>nlE;</code> </td><td> U+02266 U+00338 </td><td> <span class="glyph compound">≦̸</span> </td></tr><tr id="entity-nle"><td> <code>nle;</code> </td><td> U+02270 </td><td> <span class="glyph">≰</span> </td></tr><tr id="entity-nLeftarrow"><td> <code>nLeftarrow;</code> </td><td> U+021CD </td><td> <span class="glyph">⇍</span> </td></tr><tr id="entity-nleftarrow"><td> <code>nleftarrow;</code> </td><td> U+0219A </td><td> <span class="glyph">↚</span> </td></tr><tr id="entity-nLeftrightarrow"><td> <code>nLeftrightarrow;</code> </td><td> U+021CE </td><td> <span class="glyph">⇎</span> </td></tr><tr id="entity-nleftrightarrow"><td> <code>nleftrightarrow;</code> </td><td> U+021AE </td><td> <span class="glyph">↮</span> </td></tr><tr id="entity-nleq"><td> <code>nleq;</code> </td><td> U+02270 </td><td> <span class="glyph">≰</span> </td></tr><tr id="entity-nleqq"><td> <code>nleqq;</code> </td><td> U+02266 U+00338 </td><td> <span class="glyph compound">≦̸</span> </td></tr><tr id="entity-nleqslant"><td> <code>nleqslant;</code> </td><td> U+02A7D U+00338 </td><td> <span class="glyph compound">⩽̸</span> </td></tr><tr id="entity-nles"><td> <code>nles;</code> </td><td> U+02A7D U+00338 </td><td> <span class="glyph compound">⩽̸</span> </td></tr><tr id="entity-nless"><td> <code>nless;</code> </td><td> U+0226E </td><td> <span class="glyph">≮</span> </td></tr><tr id="entity-nLl"><td> <code>nLl;</code> </td><td> U+022D8 U+00338 </td><td> <span class="glyph compound">⋘̸</span> </td></tr><tr id="entity-nlsim"><td> <code>nlsim;</code> </td><td> U+02274 </td><td> <span class="glyph">≴</span> </td></tr><tr id="entity-nLt"><td> <code>nLt;</code> </td><td> U+0226A U+020D2 </td><td> <span class="glyph compound">≪⃒</span> </td></tr><tr id="entity-nlt"><td> <code>nlt;</code> </td><td> U+0226E </td><td> <span class="glyph">≮</span> </td></tr><tr id="entity-nltri"><td> <code>nltri;</code> </td><td> U+022EA </td><td> <span class="glyph">⋪</span> </td></tr><tr id="entity-nltrie"><td> <code>nltrie;</code> </td><td> U+022EC </td><td> <span class="glyph">⋬</span> </td></tr><tr id="entity-nLtv"><td> <code>nLtv;</code> </td><td> U+0226A U+00338 </td><td> <span class="glyph compound">≪̸</span> </td></tr><tr id="entity-nmid"><td> <code>nmid;</code> </td><td> U+02224 </td><td> <span class="glyph">∤</span> </td></tr><tr id="entity-NoBreak"><td> <code>NoBreak;</code> </td><td> U+02060 </td><td> <span class="glyph">⁠</span> </td></tr><tr id="entity-NonBreakingSpace"><td> <code>NonBreakingSpace;</code> </td><td> U+000A0 </td><td> <span class="glyph">&nbsp;</span> </td></tr><tr id="entity-Nopf"><td> <code>Nopf;</code> </td><td> U+02115 </td><td> <span class="glyph">ℕ</span> </td></tr><tr id="entity-nopf"><td> <code>nopf;</code> </td><td> U+1D55F </td><td> <span class="glyph">𝕟</span> </td></tr><tr id="entity-Not"><td> <code>Not;</code> </td><td> U+02AEC </td><td> <span class="glyph">⫬</span> </td></tr><tr id="entity-not"><td> <code>not;</code> </td><td> U+000AC </td><td> <span class="glyph">¬</span> </td></tr><tr id="entity-not-legacy" class="impl"><td> <code>not</code> </td><td> U+000AC </td><td> <span>¬</span> </td></tr><tr id="entity-NotCongruent"><td> <code>NotCongruent;</code> </td><td> U+02262 </td><td> <span class="glyph">≢</span> </td></tr><tr id="entity-NotCupCap"><td> <code>NotCupCap;</code> </td><td> U+0226D </td><td> <span class="glyph">≭</span> </td></tr><tr id="entity-NotDoubleVerticalBar"><td> <code>NotDoubleVerticalBar;</code> </td><td> U+02226 </td><td> <span class="glyph">∦</span> </td></tr><tr id="entity-NotElement"><td> <code>NotElement;</code> </td><td> U+02209 </td><td> <span class="glyph">∉</span> </td></tr><tr id="entity-NotEqual"><td> <code>NotEqual;</code> </td><td> U+02260 </td><td> <span class="glyph">≠</span> </td></tr><tr id="entity-NotEqualTilde"><td> <code>NotEqualTilde;</code> </td><td> U+02242 U+00338 </td><td> <span class="glyph compound">≂̸</span> </td></tr><tr id="entity-NotExists"><td> <code>NotExists;</code> </td><td> U+02204 </td><td> <span class="glyph">∄</span> </td></tr><tr id="entity-NotGreater"><td> <code>NotGreater;</code> </td><td> U+0226F </td><td> <span class="glyph">≯</span> </td></tr><tr id="entity-NotGreaterEqual"><td> <code>NotGreaterEqual;</code> </td><td> U+02271 </td><td> <span class="glyph">≱</span> </td></tr><tr id="entity-NotGreaterFullEqual"><td> <code>NotGreaterFullEqual;</code> </td><td> U+02267 U+00338 </td><td> <span class="glyph compound">≧̸</span> </td></tr><tr id="entity-NotGreaterGreater"><td> <code>NotGreaterGreater;</code> </td><td> U+0226B U+00338 </td><td> <span class="glyph compound">≫̸</span> </td></tr><tr id="entity-NotGreaterLess"><td> <code>NotGreaterLess;</code> </td><td> U+02279 </td><td> <span class="glyph">≹</span> </td></tr><tr id="entity-NotGreaterSlantEqual"><td> <code>NotGreaterSlantEqual;</code> </td><td> U+02A7E U+00338 </td><td> <span class="glyph compound">⩾̸</span> </td></tr><tr id="entity-NotGreaterTilde"><td> <code>NotGreaterTilde;</code> </td><td> U+02275 </td><td> <span class="glyph">≵</span> </td></tr><tr id="entity-NotHumpDownHump"><td> <code>NotHumpDownHump;</code> </td><td> U+0224E U+00338 </td><td> <span class="glyph compound">≎̸</span> </td></tr><tr id="entity-NotHumpEqual"><td> <code>NotHumpEqual;</code> </td><td> U+0224F U+00338 </td><td> <span class="glyph compound">≏̸</span> </td></tr><tr id="entity-notin"><td> <code>notin;</code> </td><td> U+02209 </td><td> <span class="glyph">∉</span> </td></tr><tr id="entity-notindot"><td> <code>notindot;</code> </td><td> U+022F5 U+00338 </td><td> <span class="glyph compound">⋵̸</span> </td></tr><tr id="entity-notinE"><td> <code>notinE;</code> </td><td> U+022F9 U+00338 </td><td> <span class="glyph compound">⋹̸</span> </td></tr><tr id="entity-notinva"><td> <code>notinva;</code> </td><td> U+02209 </td><td> <span class="glyph">∉</span> </td></tr><tr id="entity-notinvb"><td> <code>notinvb;</code> </td><td> U+022F7 </td><td> <span class="glyph">⋷</span> </td></tr><tr id="entity-notinvc"><td> <code>notinvc;</code> </td><td> U+022F6 </td><td> <span class="glyph">⋶</span> </td></tr><tr id="entity-NotLeftTriangle"><td> <code>NotLeftTriangle;</code> </td><td> U+022EA </td><td> <span class="glyph">⋪</span> </td></tr><tr id="entity-NotLeftTriangleBar"><td> <code>NotLeftTriangleBar;</code> </td><td> U+029CF U+00338 </td><td> <span class="glyph compound">⧏̸</span> </td></tr><tr id="entity-NotLeftTriangleEqual"><td> <code>NotLeftTriangleEqual;</code> </td><td> U+022EC </td><td> <span class="glyph">⋬</span> </td></tr><tr id="entity-NotLess"><td> <code>NotLess;</code> </td><td> U+0226E </td><td> <span class="glyph">≮</span> </td></tr><tr id="entity-NotLessEqual"><td> <code>NotLessEqual;</code> </td><td> U+02270 </td><td> <span class="glyph">≰</span> </td></tr><tr id="entity-NotLessGreater"><td> <code>NotLessGreater;</code> </td><td> U+02278 </td><td> <span class="glyph">≸</span> </td></tr><tr id="entity-NotLessLess"><td> <code>NotLessLess;</code> </td><td> U+0226A U+00338 </td><td> <span class="glyph compound">≪̸</span> </td></tr><tr id="entity-NotLessSlantEqual"><td> <code>NotLessSlantEqual;</code> </td><td> U+02A7D U+00338 </td><td> <span class="glyph compound">⩽̸</span> </td></tr><tr id="entity-NotLessTilde"><td> <code>NotLessTilde;</code> </td><td> U+02274 </td><td> <span class="glyph">≴</span> </td></tr><tr id="entity-NotNestedGreaterGreater"><td> <code>NotNestedGreaterGreater;</code> </td><td> U+02AA2 U+00338 </td><td> <span class="glyph compound">⪢̸</span> </td></tr><tr id="entity-NotNestedLessLess"><td> <code>NotNestedLessLess;</code> </td><td> U+02AA1 U+00338 </td><td> <span class="glyph compound">⪡̸</span> </td></tr><tr id="entity-notni"><td> <code>notni;</code> </td><td> U+0220C </td><td> <span class="glyph">∌</span> </td></tr><tr id="entity-notniva"><td> <code>notniva;</code> </td><td> U+0220C </td><td> <span class="glyph">∌</span> </td></tr><tr id="entity-notnivb"><td> <code>notnivb;</code> </td><td> U+022FE </td><td> <span class="glyph">⋾</span> </td></tr><tr id="entity-notnivc"><td> <code>notnivc;</code> </td><td> U+022FD </td><td> <span class="glyph">⋽</span> </td></tr><tr id="entity-NotPrecedes"><td> <code>NotPrecedes;</code> </td><td> U+02280 </td><td> <span class="glyph">⊀</span> </td></tr><tr id="entity-NotPrecedesEqual"><td> <code>NotPrecedesEqual;</code> </td><td> U+02AAF U+00338 </td><td> <span class="glyph compound">⪯̸</span> </td></tr><tr id="entity-NotPrecedesSlantEqual"><td> <code>NotPrecedesSlantEqual;</code> </td><td> U+022E0 </td><td> <span class="glyph">⋠</span> </td></tr><tr id="entity-NotReverseElement"><td> <code>NotReverseElement;</code> </td><td> U+0220C </td><td> <span class="glyph">∌</span> </td></tr><tr id="entity-NotRightTriangle"><td> <code>NotRightTriangle;</code> </td><td> U+022EB </td><td> <span class="glyph">⋫</span> </td></tr><tr id="entity-NotRightTriangleBar"><td> <code>NotRightTriangleBar;</code> </td><td> U+029D0 U+00338 </td><td> <span class="glyph compound">⧐̸</span> </td></tr><tr id="entity-NotRightTriangleEqual"><td> <code>NotRightTriangleEqual;</code> </td><td> U+022ED </td><td> <span class="glyph">⋭</span> </td></tr><tr id="entity-NotSquareSubset"><td> <code>NotSquareSubset;</code> </td><td> U+0228F U+00338 </td><td> <span class="glyph compound">⊏̸</span> </td></tr><tr id="entity-NotSquareSubsetEqual"><td> <code>NotSquareSubsetEqual;</code> </td><td> U+022E2 </td><td> <span class="glyph">⋢</span> </td></tr><tr id="entity-NotSquareSuperset"><td> <code>NotSquareSuperset;</code> </td><td> U+02290 U+00338 </td><td> <span class="glyph compound">⊐̸</span> </td></tr><tr id="entity-NotSquareSupersetEqual"><td> <code>NotSquareSupersetEqual;</code> </td><td> U+022E3 </td><td> <span class="glyph">⋣</span> </td></tr><tr id="entity-NotSubset"><td> <code>NotSubset;</code> </td><td> U+02282 U+020D2 </td><td> <span class="glyph compound">⊂⃒</span> </td></tr><tr id="entity-NotSubsetEqual"><td> <code>NotSubsetEqual;</code> </td><td> U+02288 </td><td> <span class="glyph">⊈</span> </td></tr><tr id="entity-NotSucceeds"><td> <code>NotSucceeds;</code> </td><td> U+02281 </td><td> <span class="glyph">⊁</span> </td></tr><tr id="entity-NotSucceedsEqual"><td> <code>NotSucceedsEqual;</code> </td><td> U+02AB0 U+00338 </td><td> <span class="glyph compound">⪰̸</span> </td></tr><tr id="entity-NotSucceedsSlantEqual"><td> <code>NotSucceedsSlantEqual;</code> </td><td> U+022E1 </td><td> <span class="glyph">⋡</span> </td></tr><tr id="entity-NotSucceedsTilde"><td> <code>NotSucceedsTilde;</code> </td><td> U+0227F U+00338 </td><td> <span class="glyph compound">≿̸</span> </td></tr><tr id="entity-NotSuperset"><td> <code>NotSuperset;</code> </td><td> U+02283 U+020D2 </td><td> <span class="glyph compound">⊃⃒</span> </td></tr><tr id="entity-NotSupersetEqual"><td> <code>NotSupersetEqual;</code> </td><td> U+02289 </td><td> <span class="glyph">⊉</span> </td></tr><tr id="entity-NotTilde"><td> <code>NotTilde;</code> </td><td> U+02241 </td><td> <span class="glyph">≁</span> </td></tr><tr id="entity-NotTildeEqual"><td> <code>NotTildeEqual;</code> </td><td> U+02244 </td><td> <span class="glyph">≄</span> </td></tr><tr id="entity-NotTildeFullEqual"><td> <code>NotTildeFullEqual;</code> </td><td> U+02247 </td><td> <span class="glyph">≇</span> </td></tr><tr id="entity-NotTildeTilde"><td> <code>NotTildeTilde;</code> </td><td> U+02249 </td><td> <span class="glyph">≉</span> </td></tr><tr id="entity-NotVerticalBar"><td> <code>NotVerticalBar;</code> </td><td> U+02224 </td><td> <span class="glyph">∤</span> </td></tr><tr id="entity-npar"><td> <code>npar;</code> </td><td> U+02226 </td><td> <span class="glyph">∦</span> </td></tr><tr id="entity-nparallel"><td> <code>nparallel;</code> </td><td> U+02226 </td><td> <span class="glyph">∦</span> </td></tr><tr id="entity-nparsl"><td> <code>nparsl;</code> </td><td> U+02AFD U+020E5 </td><td> <span class="glyph compound">⫽⃥</span> </td></tr><tr id="entity-npart"><td> <code>npart;</code> </td><td> U+02202 U+00338 </td><td> <span class="glyph compound">∂̸</span> </td></tr><tr id="entity-npolint"><td> <code>npolint;</code> </td><td> U+02A14 </td><td> <span class="glyph">⨔</span> </td></tr><tr id="entity-npr"><td> <code>npr;</code> </td><td> U+02280 </td><td> <span class="glyph">⊀</span> </td></tr><tr id="entity-nprcue"><td> <code>nprcue;</code> </td><td> U+022E0 </td><td> <span class="glyph">⋠</span> </td></tr><tr id="entity-npre"><td> <code>npre;</code> </td><td> U+02AAF U+00338 </td><td> <span class="glyph compound">⪯̸</span> </td></tr><tr id="entity-nprec"><td> <code>nprec;</code> </td><td> U+02280 </td><td> <span class="glyph">⊀</span> </td></tr><tr id="entity-npreceq"><td> <code>npreceq;</code> </td><td> U+02AAF U+00338 </td><td> <span class="glyph compound">⪯̸</span> </td></tr><tr id="entity-nrArr"><td> <code>nrArr;</code> </td><td> U+021CF </td><td> <span class="glyph">⇏</span> </td></tr><tr id="entity-nrarr"><td> <code>nrarr;</code> </td><td> U+0219B </td><td> <span class="glyph">↛</span> </td></tr><tr id="entity-nrarrc"><td> <code>nrarrc;</code> </td><td> U+02933 U+00338 </td><td> <span class="glyph compound">⤳̸</span> </td></tr><tr id="entity-nrarrw"><td> <code>nrarrw;</code> </td><td> U+0219D U+00338 </td><td> <span class="glyph compound">↝̸</span> </td></tr><tr id="entity-nRightarrow"><td> <code>nRightarrow;</code> </td><td> U+021CF </td><td> <span class="glyph">⇏</span> </td></tr><tr id="entity-nrightarrow"><td> <code>nrightarrow;</code> </td><td> U+0219B </td><td> <span class="glyph">↛</span> </td></tr><tr id="entity-nrtri"><td> <code>nrtri;</code> </td><td> U+022EB </td><td> <span class="glyph">⋫</span> </td></tr><tr id="entity-nrtrie"><td> <code>nrtrie;</code> </td><td> U+022ED </td><td> <span class="glyph">⋭</span> </td></tr><tr id="entity-nsc"><td> <code>nsc;</code> </td><td> U+02281 </td><td> <span class="glyph">⊁</span> </td></tr><tr id="entity-nsccue"><td> <code>nsccue;</code> </td><td> U+022E1 </td><td> <span class="glyph">⋡</span> </td></tr><tr id="entity-nsce"><td> <code>nsce;</code> </td><td> U+02AB0 U+00338 </td><td> <span class="glyph compound">⪰̸</span> </td></tr><tr id="entity-Nscr"><td> <code>Nscr;</code> </td><td> U+1D4A9 </td><td> <span class="glyph">𝒩</span> </td></tr><tr id="entity-nscr"><td> <code>nscr;</code> </td><td> U+1D4C3 </td><td> <span class="glyph">𝓃</span> </td></tr><tr id="entity-nshortmid"><td> <code>nshortmid;</code> </td><td> U+02224 </td><td> <span class="glyph">∤</span> </td></tr><tr id="entity-nshortparallel"><td> <code>nshortparallel;</code> </td><td> U+02226 </td><td> <span class="glyph">∦</span> </td></tr><tr id="entity-nsim"><td> <code>nsim;</code> </td><td> U+02241 </td><td> <span class="glyph">≁</span> </td></tr><tr id="entity-nsime"><td> <code>nsime;</code> </td><td> U+02244 </td><td> <span class="glyph">≄</span> </td></tr><tr id="entity-nsimeq"><td> <code>nsimeq;</code> </td><td> U+02244 </td><td> <span class="glyph">≄</span> </td></tr><tr id="entity-nsmid"><td> <code>nsmid;</code> </td><td> U+02224 </td><td> <span class="glyph">∤</span> </td></tr><tr id="entity-nspar"><td> <code>nspar;</code> </td><td> U+02226 </td><td> <span class="glyph">∦</span> </td></tr><tr id="entity-nsqsube"><td> <code>nsqsube;</code> </td><td> U+022E2 </td><td> <span class="glyph">⋢</span> </td></tr><tr id="entity-nsqsupe"><td> <code>nsqsupe;</code> </td><td> U+022E3 </td><td> <span class="glyph">⋣</span> </td></tr><tr id="entity-nsub"><td> <code>nsub;</code> </td><td> U+02284 </td><td> <span class="glyph">⊄</span> </td></tr><tr id="entity-nsubE"><td> <code>nsubE;</code> </td><td> U+02AC5 U+00338 </td><td> <span class="glyph compound">⫅̸</span> </td></tr><tr id="entity-nsube"><td> <code>nsube;</code> </td><td> U+02288 </td><td> <span class="glyph">⊈</span> </td></tr><tr id="entity-nsubset"><td> <code>nsubset;</code> </td><td> U+02282 U+020D2 </td><td> <span class="glyph compound">⊂⃒</span> </td></tr><tr id="entity-nsubseteq"><td> <code>nsubseteq;</code> </td><td> U+02288 </td><td> <span class="glyph">⊈</span> </td></tr><tr id="entity-nsubseteqq"><td> <code>nsubseteqq;</code> </td><td> U+02AC5 U+00338 </td><td> <span class="glyph compound">⫅̸</span> </td></tr><tr id="entity-nsucc"><td> <code>nsucc;</code> </td><td> U+02281 </td><td> <span class="glyph">⊁</span> </td></tr><tr id="entity-nsucceq"><td> <code>nsucceq;</code> </td><td> U+02AB0 U+00338 </td><td> <span class="glyph compound">⪰̸</span> </td></tr><tr id="entity-nsup"><td> <code>nsup;</code> </td><td> U+02285 </td><td> <span class="glyph">⊅</span> </td></tr><tr id="entity-nsupE"><td> <code>nsupE;</code> </td><td> U+02AC6 U+00338 </td><td> <span class="glyph compound">⫆̸</span> </td></tr><tr id="entity-nsupe"><td> <code>nsupe;</code> </td><td> U+02289 </td><td> <span class="glyph">⊉</span> </td></tr><tr id="entity-nsupset"><td> <code>nsupset;</code> </td><td> U+02283 U+020D2 </td><td> <span class="glyph compound">⊃⃒</span> </td></tr><tr id="entity-nsupseteq"><td> <code>nsupseteq;</code> </td><td> U+02289 </td><td> <span class="glyph">⊉</span> </td></tr><tr id="entity-nsupseteqq"><td> <code>nsupseteqq;</code> </td><td> U+02AC6 U+00338 </td><td> <span class="glyph compound">⫆̸</span> </td></tr><tr id="entity-ntgl"><td> <code>ntgl;</code> </td><td> U+02279 </td><td> <span class="glyph">≹</span> </td></tr><tr id="entity-Ntilde"><td> <code>Ntilde;</code> </td><td> U+000D1 </td><td> <span class="glyph">Ñ</span> </td></tr><tr id="entity-Ntilde-legacy" class="impl"><td> <code>Ntilde</code> </td><td> U+000D1 </td><td> <span>Ñ</span> </td></tr><tr id="entity-ntilde"><td> <code>ntilde;</code> </td><td> U+000F1 </td><td> <span class="glyph">ñ</span> </td></tr><tr id="entity-ntilde-legacy" class="impl"><td> <code>ntilde</code> </td><td> U+000F1 </td><td> <span>ñ</span> </td></tr><tr id="entity-ntlg"><td> <code>ntlg;</code> </td><td> U+02278 </td><td> <span class="glyph">≸</span> </td></tr><tr id="entity-ntriangleleft"><td> <code>ntriangleleft;</code> </td><td> U+022EA </td><td> <span class="glyph">⋪</span> </td></tr><tr id="entity-ntrianglelefteq"><td> <code>ntrianglelefteq;</code> </td><td> U+022EC </td><td> <span class="glyph">⋬</span> </td></tr><tr id="entity-ntriangleright"><td> <code>ntriangleright;</code> </td><td> U+022EB </td><td> <span class="glyph">⋫</span> </td></tr><tr id="entity-ntrianglerighteq"><td> <code>ntrianglerighteq;</code> </td><td> U+022ED </td><td> <span class="glyph">⋭</span> </td></tr><tr id="entity-Nu"><td> <code>Nu;</code> </td><td> U+0039D </td><td> <span class="glyph">Ν</span> </td></tr><tr id="entity-nu"><td> <code>nu;</code> </td><td> U+003BD </td><td> <span class="glyph">ν</span> </td></tr><tr id="entity-num"><td> <code>num;</code> </td><td> U+00023 </td><td> <span class="glyph">#</span> </td></tr><tr id="entity-numero"><td> <code>numero;</code> </td><td> U+02116 </td><td> <span class="glyph">№</span> </td></tr><tr id="entity-numsp"><td> <code>numsp;</code> </td><td> U+02007 </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-nvap"><td> <code>nvap;</code> </td><td> U+0224D U+020D2 </td><td> <span class="glyph compound">≍⃒</span> </td></tr><tr id="entity-nVDash"><td> <code>nVDash;</code> </td><td> U+022AF </td><td> <span class="glyph">⊯</span> </td></tr><tr id="entity-nVdash"><td> <code>nVdash;</code> </td><td> U+022AE </td><td> <span class="glyph">⊮</span> </td></tr><tr id="entity-nvDash"><td> <code>nvDash;</code> </td><td> U+022AD </td><td> <span class="glyph">⊭</span> </td></tr><tr id="entity-nvdash"><td> <code>nvdash;</code> </td><td> U+022AC </td><td> <span class="glyph">⊬</span> </td></tr><tr id="entity-nvge"><td> <code>nvge;</code> </td><td> U+02265 U+020D2 </td><td> <span class="glyph compound">≥⃒</span> </td></tr><tr id="entity-nvgt"><td> <code>nvgt;</code> </td><td> U+0003E U+020D2 </td><td> <span class="glyph compound">&gt;⃒</span> </td></tr><tr id="entity-nvHarr"><td> <code>nvHarr;</code> </td><td> U+02904 </td><td> <span class="glyph">⤄</span> </td></tr><tr id="entity-nvinfin"><td> <code>nvinfin;</code> </td><td> U+029DE </td><td> <span class="glyph">⧞</span> </td></tr><tr id="entity-nvlArr"><td> <code>nvlArr;</code> </td><td> U+02902 </td><td> <span class="glyph">⤂</span> </td></tr><tr id="entity-nvle"><td> <code>nvle;</code> </td><td> U+02264 U+020D2 </td><td> <span class="glyph compound">≤⃒</span> </td></tr><tr id="entity-nvlt"><td> <code>nvlt;</code> </td><td> U+0003C U+020D2 </td><td> <span class="glyph compound">&lt;⃒</span> </td></tr><tr id="entity-nvltrie"><td> <code>nvltrie;</code> </td><td> U+022B4 U+020D2 </td><td> <span class="glyph compound">⊴⃒</span> </td></tr><tr id="entity-nvrArr"><td> <code>nvrArr;</code> </td><td> U+02903 </td><td> <span class="glyph">⤃</span> </td></tr><tr id="entity-nvrtrie"><td> <code>nvrtrie;</code> </td><td> U+022B5 U+020D2 </td><td> <span class="glyph compound">⊵⃒</span> </td></tr><tr id="entity-nvsim"><td> <code>nvsim;</code> </td><td> U+0223C U+020D2 </td><td> <span class="glyph compound">∼⃒</span> </td></tr><tr id="entity-nwarhk"><td> <code>nwarhk;</code> </td><td> U+02923 </td><td> <span class="glyph">⤣</span> </td></tr><tr id="entity-nwArr"><td> <code>nwArr;</code> </td><td> U+021D6 </td><td> <span class="glyph">⇖</span> </td></tr><tr id="entity-nwarr"><td> <code>nwarr;</code> </td><td> U+02196 </td><td> <span class="glyph">↖</span> </td></tr><tr id="entity-nwarrow"><td> <code>nwarrow;</code> </td><td> U+02196 </td><td> <span class="glyph">↖</span> </td></tr><tr id="entity-nwnear"><td> <code>nwnear;</code> </td><td> U+02927 </td><td> <span class="glyph">⤧</span> </td></tr><tr id="entity-Oacute"><td> <code>Oacute;</code> </td><td> U+000D3 </td><td> <span class="glyph">Ó</span> </td></tr><tr id="entity-Oacute-legacy" class="impl"><td> <code>Oacute</code> </td><td> U+000D3 </td><td> <span>Ó</span> </td></tr><tr id="entity-oacute"><td> <code>oacute;</code> </td><td> U+000F3 </td><td> <span class="glyph">ó</span> </td></tr><tr id="entity-oacute-legacy" class="impl"><td> <code>oacute</code> </td><td> U+000F3 </td><td> <span>ó</span> </td></tr><tr id="entity-oast"><td> <code>oast;</code> </td><td> U+0229B </td><td> <span class="glyph">⊛</span> </td></tr><tr id="entity-ocir"><td> <code>ocir;</code> </td><td> U+0229A </td><td> <span class="glyph">⊚</span> </td></tr><tr id="entity-Ocirc"><td> <code>Ocirc;</code> </td><td> U+000D4 </td><td> <span class="glyph">Ô</span> </td></tr><tr id="entity-Ocirc-legacy" class="impl"><td> <code>Ocirc</code> </td><td> U+000D4 </td><td> <span>Ô</span> </td></tr><tr id="entity-ocirc"><td> <code>ocirc;</code> </td><td> U+000F4 </td><td> <span class="glyph">ô</span> </td></tr><tr id="entity-ocirc-legacy" class="impl"><td> <code>ocirc</code> </td><td> U+000F4 </td><td> <span>ô</span> </td></tr><tr id="entity-Ocy"><td> <code>Ocy;</code> </td><td> U+0041E </td><td> <span class="glyph">О</span> </td></tr><tr id="entity-ocy"><td> <code>ocy;</code> </td><td> U+0043E </td><td> <span class="glyph">о</span> </td></tr><tr id="entity-odash"><td> <code>odash;</code> </td><td> U+0229D </td><td> <span class="glyph">⊝</span> </td></tr><tr id="entity-Odblac"><td> <code>Odblac;</code> </td><td> U+00150 </td><td> <span class="glyph">Ő</span> </td></tr><tr id="entity-odblac"><td> <code>odblac;</code> </td><td> U+00151 </td><td> <span class="glyph">ő</span> </td></tr><tr id="entity-odiv"><td> <code>odiv;</code> </td><td> U+02A38 </td><td> <span class="glyph">⨸</span> </td></tr><tr id="entity-odot"><td> <code>odot;</code> </td><td> U+02299 </td><td> <span class="glyph">⊙</span> </td></tr><tr id="entity-odsold"><td> <code>odsold;</code> </td><td> U+029BC </td><td> <span class="glyph">⦼</span> </td></tr><tr id="entity-OElig"><td> <code>OElig;</code> </td><td> U+00152 </td><td> <span class="glyph">Œ</span> </td></tr><tr id="entity-oelig"><td> <code>oelig;</code> </td><td> U+00153 </td><td> <span class="glyph">œ</span> </td></tr><tr id="entity-ofcir"><td> <code>ofcir;</code> </td><td> U+029BF </td><td> <span class="glyph">⦿</span> </td></tr><tr id="entity-Ofr"><td> <code>Ofr;</code> </td><td> U+1D512 </td><td> <span class="glyph">𝔒</span> </td></tr><tr id="entity-ofr"><td> <code>ofr;</code> </td><td> U+1D52C </td><td> <span class="glyph">𝔬</span> </td></tr><tr id="entity-ogon"><td> <code>ogon;</code> </td><td> U+002DB </td><td> <span class="glyph">˛</span> </td></tr><tr id="entity-Ograve"><td> <code>Ograve;</code> </td><td> U+000D2 </td><td> <span class="glyph">Ò</span> </td></tr><tr id="entity-Ograve-legacy" class="impl"><td> <code>Ograve</code> </td><td> U+000D2 </td><td> <span>Ò</span> </td></tr><tr id="entity-ograve"><td> <code>ograve;</code> </td><td> U+000F2 </td><td> <span class="glyph">ò</span> </td></tr><tr id="entity-ograve-legacy" class="impl"><td> <code>ograve</code> </td><td> U+000F2 </td><td> <span>ò</span> </td></tr><tr id="entity-ogt"><td> <code>ogt;</code> </td><td> U+029C1 </td><td> <span class="glyph">⧁</span> </td></tr><tr id="entity-ohbar"><td> <code>ohbar;</code> </td><td> U+029B5 </td><td> <span class="glyph">⦵</span> </td></tr><tr id="entity-ohm"><td> <code>ohm;</code> </td><td> U+003A9 </td><td> <span class="glyph">Ω</span> </td></tr><tr id="entity-oint"><td> <code>oint;</code> </td><td> U+0222E </td><td> <span class="glyph">∮</span> </td></tr><tr id="entity-olarr"><td> <code>olarr;</code> </td><td> U+021BA </td><td> <span class="glyph">↺</span> </td></tr><tr id="entity-olcir"><td> <code>olcir;</code> </td><td> U+029BE </td><td> <span class="glyph">⦾</span> </td></tr><tr id="entity-olcross"><td> <code>olcross;</code> </td><td> U+029BB </td><td> <span class="glyph">⦻</span> </td></tr><tr id="entity-oline"><td> <code>oline;</code> </td><td> U+0203E </td><td> <span class="glyph">‾</span> </td></tr><tr id="entity-olt"><td> <code>olt;</code> </td><td> U+029C0 </td><td> <span class="glyph">⧀</span> </td></tr><tr id="entity-Omacr"><td> <code>Omacr;</code> </td><td> U+0014C </td><td> <span class="glyph">Ō</span> </td></tr><tr id="entity-omacr"><td> <code>omacr;</code> </td><td> U+0014D </td><td> <span class="glyph">ō</span> </td></tr><tr id="entity-Omega"><td> <code>Omega;</code> </td><td> U+003A9 </td><td> <span class="glyph">Ω</span> </td></tr><tr id="entity-omega"><td> <code>omega;</code> </td><td> U+003C9 </td><td> <span class="glyph">ω</span> </td></tr><tr id="entity-Omicron"><td> <code>Omicron;</code> </td><td> U+0039F </td><td> <span class="glyph">Ο</span> </td></tr><tr id="entity-omicron"><td> <code>omicron;</code> </td><td> U+003BF </td><td> <span class="glyph">ο</span> </td></tr><tr id="entity-omid"><td> <code>omid;</code> </td><td> U+029B6 </td><td> <span class="glyph">⦶</span> </td></tr><tr id="entity-ominus"><td> <code>ominus;</code> </td><td> U+02296 </td><td> <span class="glyph">⊖</span> </td></tr><tr id="entity-Oopf"><td> <code>Oopf;</code> </td><td> U+1D546 </td><td> <span class="glyph">𝕆</span> </td></tr><tr id="entity-oopf"><td> <code>oopf;</code> </td><td> U+1D560 </td><td> <span class="glyph">𝕠</span> </td></tr><tr id="entity-opar"><td> <code>opar;</code> </td><td> U+029B7 </td><td> <span class="glyph">⦷</span> </td></tr><tr id="entity-OpenCurlyDoubleQuote"><td> <code>OpenCurlyDoubleQuote;</code> </td><td> U+0201C </td><td> <span class="glyph">“</span> </td></tr><tr id="entity-OpenCurlyQuote"><td> <code>OpenCurlyQuote;</code> </td><td> U+02018 </td><td> <span class="glyph">‘</span> </td></tr><tr id="entity-operp"><td> <code>operp;</code> </td><td> U+029B9 </td><td> <span class="glyph">⦹</span> </td></tr><tr id="entity-oplus"><td> <code>oplus;</code> </td><td> U+02295 </td><td> <span class="glyph">⊕</span> </td></tr><tr id="entity-Or"><td> <code>Or;</code> </td><td> U+02A54 </td><td> <span class="glyph">⩔</span> </td></tr><tr id="entity-or"><td> <code>or;</code> </td><td> U+02228 </td><td> <span class="glyph">∨</span> </td></tr><tr id="entity-orarr"><td> <code>orarr;</code> </td><td> U+021BB </td><td> <span class="glyph">↻</span> </td></tr><tr id="entity-ord"><td> <code>ord;</code> </td><td> U+02A5D </td><td> <span class="glyph">⩝</span> </td></tr><tr id="entity-order"><td> <code>order;</code> </td><td> U+02134 </td><td> <span class="glyph">ℴ</span> </td></tr><tr id="entity-orderof"><td> <code>orderof;</code> </td><td> U+02134 </td><td> <span class="glyph">ℴ</span> </td></tr><tr id="entity-ordf"><td> <code>ordf;</code> </td><td> U+000AA </td><td> <span class="glyph">ª</span> </td></tr><tr id="entity-ordf-legacy" class="impl"><td> <code>ordf</code> </td><td> U+000AA </td><td> <span>ª</span> </td></tr><tr id="entity-ordm"><td> <code>ordm;</code> </td><td> U+000BA </td><td> <span class="glyph">º</span> </td></tr><tr id="entity-ordm-legacy" class="impl"><td> <code>ordm</code> </td><td> U+000BA </td><td> <span>º</span> </td></tr><tr id="entity-origof"><td> <code>origof;</code> </td><td> U+022B6 </td><td> <span class="glyph">⊶</span> </td></tr><tr id="entity-oror"><td> <code>oror;</code> </td><td> U+02A56 </td><td> <span class="glyph">⩖</span> </td></tr><tr id="entity-orslope"><td> <code>orslope;</code> </td><td> U+02A57 </td><td> <span class="glyph">⩗</span> </td></tr><tr id="entity-orv"><td> <code>orv;</code> </td><td> U+02A5B </td><td> <span class="glyph">⩛</span> </td></tr><tr id="entity-oS"><td> <code>oS;</code> </td><td> U+024C8 </td><td> <span class="glyph">Ⓢ</span> </td></tr><tr id="entity-Oscr"><td> <code>Oscr;</code> </td><td> U+1D4AA </td><td> <span class="glyph">𝒪</span> </td></tr><tr id="entity-oscr"><td> <code>oscr;</code> </td><td> U+02134 </td><td> <span class="glyph">ℴ</span> </td></tr><tr id="entity-Oslash"><td> <code>Oslash;</code> </td><td> U+000D8 </td><td> <span class="glyph">Ø</span> </td></tr><tr id="entity-Oslash-legacy" class="impl"><td> <code>Oslash</code> </td><td> U+000D8 </td><td> <span>Ø</span> </td></tr><tr id="entity-oslash"><td> <code>oslash;</code> </td><td> U+000F8 </td><td> <span class="glyph">ø</span> </td></tr><tr id="entity-oslash-legacy" class="impl"><td> <code>oslash</code> </td><td> U+000F8 </td><td> <span>ø</span> </td></tr><tr id="entity-osol"><td> <code>osol;</code> </td><td> U+02298 </td><td> <span class="glyph">⊘</span> </td></tr><tr id="entity-Otilde"><td> <code>Otilde;</code> </td><td> U+000D5 </td><td> <span class="glyph">Õ</span> </td></tr><tr id="entity-Otilde-legacy" class="impl"><td> <code>Otilde</code> </td><td> U+000D5 </td><td> <span>Õ</span> </td></tr><tr id="entity-otilde"><td> <code>otilde;</code> </td><td> U+000F5 </td><td> <span class="glyph">õ</span> </td></tr><tr id="entity-otilde-legacy" class="impl"><td> <code>otilde</code> </td><td> U+000F5 </td><td> <span>õ</span> </td></tr><tr id="entity-Otimes"><td> <code>Otimes;</code> </td><td> U+02A37 </td><td> <span class="glyph">⨷</span> </td></tr><tr id="entity-otimes"><td> <code>otimes;</code> </td><td> U+02297 </td><td> <span class="glyph">⊗</span> </td></tr><tr id="entity-otimesas"><td> <code>otimesas;</code> </td><td> U+02A36 </td><td> <span class="glyph">⨶</span> </td></tr><tr id="entity-Ouml"><td> <code>Ouml;</code> </td><td> U+000D6 </td><td> <span class="glyph">Ö</span> </td></tr><tr id="entity-Ouml-legacy" class="impl"><td> <code>Ouml</code> </td><td> U+000D6 </td><td> <span>Ö</span> </td></tr><tr id="entity-ouml"><td> <code>ouml;</code> </td><td> U+000F6 </td><td> <span class="glyph">ö</span> </td></tr><tr id="entity-ouml-legacy" class="impl"><td> <code>ouml</code> </td><td> U+000F6 </td><td> <span>ö</span> </td></tr><tr id="entity-ovbar"><td> <code>ovbar;</code> </td><td> U+0233D </td><td> <span class="glyph">⌽</span> </td></tr><tr id="entity-OverBar"><td> <code>OverBar;</code> </td><td> U+0203E </td><td> <span class="glyph">‾</span> </td></tr><tr id="entity-OverBrace"><td> <code>OverBrace;</code> </td><td> U+023DE </td><td> <span class="glyph">⏞</span> </td></tr><tr id="entity-OverBracket"><td> <code>OverBracket;</code> </td><td> U+023B4 </td><td> <span class="glyph">⎴</span> </td></tr><tr id="entity-OverParenthesis"><td> <code>OverParenthesis;</code> </td><td> U+023DC </td><td> <span class="glyph">⏜</span> </td></tr><tr id="entity-par"><td> <code>par;</code> </td><td> U+02225 </td><td> <span class="glyph">∥</span> </td></tr><tr id="entity-para"><td> <code>para;</code> </td><td> U+000B6 </td><td> <span class="glyph">¶</span> </td></tr><tr id="entity-para-legacy" class="impl"><td> <code>para</code> </td><td> U+000B6 </td><td> <span>¶</span> </td></tr><tr id="entity-parallel"><td> <code>parallel;</code> </td><td> U+02225 </td><td> <span class="glyph">∥</span> </td></tr><tr id="entity-parsim"><td> <code>parsim;</code> </td><td> U+02AF3 </td><td> <span class="glyph">⫳</span> </td></tr><tr id="entity-parsl"><td> <code>parsl;</code> </td><td> U+02AFD </td><td> <span class="glyph">⫽</span> </td></tr><tr id="entity-part"><td> <code>part;</code> </td><td> U+02202 </td><td> <span class="glyph">∂</span> </td></tr><tr id="entity-PartialD"><td> <code>PartialD;</code> </td><td> U+02202 </td><td> <span class="glyph">∂</span> </td></tr><tr id="entity-Pcy"><td> <code>Pcy;</code> </td><td> U+0041F </td><td> <span class="glyph">П</span> </td></tr><tr id="entity-pcy"><td> <code>pcy;</code> </td><td> U+0043F </td><td> <span class="glyph">п</span> </td></tr><tr id="entity-percnt"><td> <code>percnt;</code> </td><td> U+00025 </td><td> <span class="glyph">%</span> </td></tr><tr id="entity-period"><td> <code>period;</code> </td><td> U+0002E </td><td> <span class="glyph">.</span> </td></tr><tr id="entity-permil"><td> <code>permil;</code> </td><td> U+02030 </td><td> <span class="glyph">‰</span> </td></tr><tr id="entity-perp"><td> <code>perp;</code> </td><td> U+022A5 </td><td> <span class="glyph">⊥</span> </td></tr><tr id="entity-pertenk"><td> <code>pertenk;</code> </td><td> U+02031 </td><td> <span class="glyph">‱</span> </td></tr><tr id="entity-Pfr"><td> <code>Pfr;</code> </td><td> U+1D513 </td><td> <span class="glyph">𝔓</span> </td></tr><tr id="entity-pfr"><td> <code>pfr;</code> </td><td> U+1D52D </td><td> <span class="glyph">𝔭</span> </td></tr><tr id="entity-Phi"><td> <code>Phi;</code> </td><td> U+003A6 </td><td> <span class="glyph">Φ</span> </td></tr><tr id="entity-phi"><td> <code>phi;</code> </td><td> U+003C6 </td><td> <span class="glyph">φ</span> </td></tr><tr id="entity-phiv"><td> <code>phiv;</code> </td><td> U+003D5 </td><td> <span class="glyph">ϕ</span> </td></tr><tr id="entity-phmmat"><td> <code>phmmat;</code> </td><td> U+02133 </td><td> <span class="glyph">ℳ</span> </td></tr><tr id="entity-phone"><td> <code>phone;</code> </td><td> U+0260E </td><td> <span class="glyph">☎</span> </td></tr><tr id="entity-Pi"><td> <code>Pi;</code> </td><td> U+003A0 </td><td> <span class="glyph">Π</span> </td></tr><tr id="entity-pi"><td> <code>pi;</code> </td><td> U+003C0 </td><td> <span class="glyph">π</span> </td></tr><tr id="entity-pitchfork"><td> <code>pitchfork;</code> </td><td> U+022D4 </td><td> <span class="glyph">⋔</span> </td></tr><tr id="entity-piv"><td> <code>piv;</code> </td><td> U+003D6 </td><td> <span class="glyph">ϖ</span> </td></tr><tr id="entity-planck"><td> <code>planck;</code> </td><td> U+0210F </td><td> <span class="glyph">ℏ</span> </td></tr><tr id="entity-planckh"><td> <code>planckh;</code> </td><td> U+0210E </td><td> <span class="glyph">ℎ</span> </td></tr><tr id="entity-plankv"><td> <code>plankv;</code> </td><td> U+0210F </td><td> <span class="glyph">ℏ</span> </td></tr><tr id="entity-plus"><td> <code>plus;</code> </td><td> U+0002B </td><td> <span class="glyph">+</span> </td></tr><tr id="entity-plusacir"><td> <code>plusacir;</code> </td><td> U+02A23 </td><td> <span class="glyph">⨣</span> </td></tr><tr id="entity-plusb"><td> <code>plusb;</code> </td><td> U+0229E </td><td> <span class="glyph">⊞</span> </td></tr><tr id="entity-pluscir"><td> <code>pluscir;</code> </td><td> U+02A22 </td><td> <span class="glyph">⨢</span> </td></tr><tr id="entity-plusdo"><td> <code>plusdo;</code> </td><td> U+02214 </td><td> <span class="glyph">∔</span> </td></tr><tr id="entity-plusdu"><td> <code>plusdu;</code> </td><td> U+02A25 </td><td> <span class="glyph">⨥</span> </td></tr><tr id="entity-pluse"><td> <code>pluse;</code> </td><td> U+02A72 </td><td> <span class="glyph">⩲</span> </td></tr><tr id="entity-PlusMinus"><td> <code>PlusMinus;</code> </td><td> U+000B1 </td><td> <span class="glyph">±</span> </td></tr><tr id="entity-plusmn"><td> <code>plusmn;</code> </td><td> U+000B1 </td><td> <span class="glyph">±</span> </td></tr><tr id="entity-plusmn-legacy" class="impl"><td> <code>plusmn</code> </td><td> U+000B1 </td><td> <span>±</span> </td></tr><tr id="entity-plussim"><td> <code>plussim;</code> </td><td> U+02A26 </td><td> <span class="glyph">⨦</span> </td></tr><tr id="entity-plustwo"><td> <code>plustwo;</code> </td><td> U+02A27 </td><td> <span class="glyph">⨧</span> </td></tr><tr id="entity-pm"><td> <code>pm;</code> </td><td> U+000B1 </td><td> <span class="glyph">±</span> </td></tr><tr id="entity-Poincareplane"><td> <code>Poincareplane;</code> </td><td> U+0210C </td><td> <span class="glyph">ℌ</span> </td></tr><tr id="entity-pointint"><td> <code>pointint;</code> </td><td> U+02A15 </td><td> <span class="glyph">⨕</span> </td></tr><tr id="entity-Popf"><td> <code>Popf;</code> </td><td> U+02119 </td><td> <span class="glyph">ℙ</span> </td></tr><tr id="entity-popf"><td> <code>popf;</code> </td><td> U+1D561 </td><td> <span class="glyph">𝕡</span> </td></tr><tr id="entity-pound"><td> <code>pound;</code> </td><td> U+000A3 </td><td> <span class="glyph">£</span> </td></tr><tr id="entity-pound-legacy" class="impl"><td> <code>pound</code> </td><td> U+000A3 </td><td> <span>£</span> </td></tr><tr id="entity-Pr"><td> <code>Pr;</code> </td><td> U+02ABB </td><td> <span class="glyph">⪻</span> </td></tr><tr id="entity-pr"><td> <code>pr;</code> </td><td> U+0227A </td><td> <span class="glyph">≺</span> </td></tr><tr id="entity-prap"><td> <code>prap;</code> </td><td> U+02AB7 </td><td> <span class="glyph">⪷</span> </td></tr><tr id="entity-prcue"><td> <code>prcue;</code> </td><td> U+0227C </td><td> <span class="glyph">≼</span> </td></tr><tr id="entity-prE"><td> <code>prE;</code> </td><td> U+02AB3 </td><td> <span class="glyph">⪳</span> </td></tr><tr id="entity-pre"><td> <code>pre;</code> </td><td> U+02AAF </td><td> <span class="glyph">⪯</span> </td></tr><tr id="entity-prec"><td> <code>prec;</code> </td><td> U+0227A </td><td> <span class="glyph">≺</span> </td></tr><tr id="entity-precapprox"><td> <code>precapprox;</code> </td><td> U+02AB7 </td><td> <span class="glyph">⪷</span> </td></tr><tr id="entity-preccurlyeq"><td> <code>preccurlyeq;</code> </td><td> U+0227C </td><td> <span class="glyph">≼</span> </td></tr><tr id="entity-Precedes"><td> <code>Precedes;</code> </td><td> U+0227A </td><td> <span class="glyph">≺</span> </td></tr><tr id="entity-PrecedesEqual"><td> <code>PrecedesEqual;</code> </td><td> U+02AAF </td><td> <span class="glyph">⪯</span> </td></tr><tr id="entity-PrecedesSlantEqual"><td> <code>PrecedesSlantEqual;</code> </td><td> U+0227C </td><td> <span class="glyph">≼</span> </td></tr><tr id="entity-PrecedesTilde"><td> <code>PrecedesTilde;</code> </td><td> U+0227E </td><td> <span class="glyph">≾</span> </td></tr><tr id="entity-preceq"><td> <code>preceq;</code> </td><td> U+02AAF </td><td> <span class="glyph">⪯</span> </td></tr><tr id="entity-precnapprox"><td> <code>precnapprox;</code> </td><td> U+02AB9 </td><td> <span class="glyph">⪹</span> </td></tr><tr id="entity-precneqq"><td> <code>precneqq;</code> </td><td> U+02AB5 </td><td> <span class="glyph">⪵</span> </td></tr><tr id="entity-precnsim"><td> <code>precnsim;</code> </td><td> U+022E8 </td><td> <span class="glyph">⋨</span> </td></tr><tr id="entity-precsim"><td> <code>precsim;</code> </td><td> U+0227E </td><td> <span class="glyph">≾</span> </td></tr><tr id="entity-Prime"><td> <code>Prime;</code> </td><td> U+02033 </td><td> <span class="glyph">″</span> </td></tr><tr id="entity-prime"><td> <code>prime;</code> </td><td> U+02032 </td><td> <span class="glyph">′</span> </td></tr><tr id="entity-primes"><td> <code>primes;</code> </td><td> U+02119 </td><td> <span class="glyph">ℙ</span> </td></tr><tr id="entity-prnap"><td> <code>prnap;</code> </td><td> U+02AB9 </td><td> <span class="glyph">⪹</span> </td></tr><tr id="entity-prnE"><td> <code>prnE;</code> </td><td> U+02AB5 </td><td> <span class="glyph">⪵</span> </td></tr><tr id="entity-prnsim"><td> <code>prnsim;</code> </td><td> U+022E8 </td><td> <span class="glyph">⋨</span> </td></tr><tr id="entity-prod"><td> <code>prod;</code> </td><td> U+0220F </td><td> <span class="glyph">∏</span> </td></tr><tr id="entity-Product"><td> <code>Product;</code> </td><td> U+0220F </td><td> <span class="glyph">∏</span> </td></tr><tr id="entity-profalar"><td> <code>profalar;</code> </td><td> U+0232E </td><td> <span class="glyph">⌮</span> </td></tr><tr id="entity-profline"><td> <code>profline;</code> </td><td> U+02312 </td><td> <span class="glyph">⌒</span> </td></tr><tr id="entity-profsurf"><td> <code>profsurf;</code> </td><td> U+02313 </td><td> <span class="glyph">⌓</span> </td></tr><tr id="entity-prop"><td> <code>prop;</code> </td><td> U+0221D </td><td> <span class="glyph">∝</span> </td></tr><tr id="entity-Proportion"><td> <code>Proportion;</code> </td><td> U+02237 </td><td> <span class="glyph">∷</span> </td></tr><tr id="entity-Proportional"><td> <code>Proportional;</code> </td><td> U+0221D </td><td> <span class="glyph">∝</span> </td></tr><tr id="entity-propto"><td> <code>propto;</code> </td><td> U+0221D </td><td> <span class="glyph">∝</span> </td></tr><tr id="entity-prsim"><td> <code>prsim;</code> </td><td> U+0227E </td><td> <span class="glyph">≾</span> </td></tr><tr id="entity-prurel"><td> <code>prurel;</code> </td><td> U+022B0 </td><td> <span class="glyph">⊰</span> </td></tr><tr id="entity-Pscr"><td> <code>Pscr;</code> </td><td> U+1D4AB </td><td> <span class="glyph">𝒫</span> </td></tr><tr id="entity-pscr"><td> <code>pscr;</code> </td><td> U+1D4C5 </td><td> <span class="glyph">𝓅</span> </td></tr><tr id="entity-Psi"><td> <code>Psi;</code> </td><td> U+003A8 </td><td> <span class="glyph">Ψ</span> </td></tr><tr id="entity-psi"><td> <code>psi;</code> </td><td> U+003C8 </td><td> <span class="glyph">ψ</span> </td></tr><tr id="entity-puncsp"><td> <code>puncsp;</code> </td><td> U+02008 </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-Qfr"><td> <code>Qfr;</code> </td><td> U+1D514 </td><td> <span class="glyph">𝔔</span> </td></tr><tr id="entity-qfr"><td> <code>qfr;</code> </td><td> U+1D52E </td><td> <span class="glyph">𝔮</span> </td></tr><tr id="entity-qint"><td> <code>qint;</code> </td><td> U+02A0C </td><td> <span class="glyph">⨌</span> </td></tr><tr id="entity-Qopf"><td> <code>Qopf;</code> </td><td> U+0211A </td><td> <span class="glyph">ℚ</span> </td></tr><tr id="entity-qopf"><td> <code>qopf;</code> </td><td> U+1D562 </td><td> <span class="glyph">𝕢</span> </td></tr><tr id="entity-qprime"><td> <code>qprime;</code> </td><td> U+02057 </td><td> <span class="glyph">⁗</span> </td></tr><tr id="entity-Qscr"><td> <code>Qscr;</code> </td><td> U+1D4AC </td><td> <span class="glyph">𝒬</span> </td></tr><tr id="entity-qscr"><td> <code>qscr;</code> </td><td> U+1D4C6 </td><td> <span class="glyph">𝓆</span> </td></tr><tr id="entity-quaternions"><td> <code>quaternions;</code> </td><td> U+0210D </td><td> <span class="glyph">ℍ</span> </td></tr><tr id="entity-quatint"><td> <code>quatint;</code> </td><td> U+02A16 </td><td> <span class="glyph">⨖</span> </td></tr><tr id="entity-quest"><td> <code>quest;</code> </td><td> U+0003F </td><td> <span class="glyph">?</span> </td></tr><tr id="entity-questeq"><td> <code>questeq;</code> </td><td> U+0225F </td><td> <span class="glyph">≟</span> </td></tr><tr id="entity-QUOT"><td> <code>QUOT;</code> </td><td> U+00022 </td><td> <span class="glyph">"</span> </td></tr><tr id="entity-QUOT-legacy" class="impl"><td> <code>QUOT</code> </td><td> U+00022 </td><td> <span>"</span> </td></tr><tr id="entity-quot"><td> <code>quot;</code> </td><td> U+00022 </td><td> <span class="glyph">"</span> </td></tr><tr id="entity-quot-legacy" class="impl"><td> <code>quot</code> </td><td> U+00022 </td><td> <span>"</span> </td></tr><tr id="entity-rAarr"><td> <code>rAarr;</code> </td><td> U+021DB </td><td> <span class="glyph">⇛</span> </td></tr><tr id="entity-race"><td> <code>race;</code> </td><td> U+0223D U+00331 </td><td> <span class="glyph compound">∽̱</span> </td></tr><tr id="entity-Racute"><td> <code>Racute;</code> </td><td> U+00154 </td><td> <span class="glyph">Ŕ</span> </td></tr><tr id="entity-racute"><td> <code>racute;</code> </td><td> U+00155 </td><td> <span class="glyph">ŕ</span> </td></tr><tr id="entity-radic"><td> <code>radic;</code> </td><td> U+0221A </td><td> <span class="glyph">√</span> </td></tr><tr id="entity-raemptyv"><td> <code>raemptyv;</code> </td><td> U+029B3 </td><td> <span class="glyph">⦳</span> </td></tr><tr id="entity-Rang"><td> <code>Rang;</code> </td><td> U+027EB </td><td> <span class="glyph">⟫</span> </td></tr><tr id="entity-rang"><td> <code>rang;</code> </td><td> U+027E9 </td><td> <span class="glyph">⟩</span> </td></tr><tr id="entity-rangd"><td> <code>rangd;</code> </td><td> U+02992 </td><td> <span class="glyph">⦒</span> </td></tr><tr id="entity-range"><td> <code>range;</code> </td><td> U+029A5 </td><td> <span class="glyph">⦥</span> </td></tr><tr id="entity-rangle"><td> <code>rangle;</code> </td><td> U+027E9 </td><td> <span class="glyph">⟩</span> </td></tr><tr id="entity-raquo"><td> <code>raquo;</code> </td><td> U+000BB </td><td> <span class="glyph">»</span> </td></tr><tr id="entity-raquo-legacy" class="impl"><td> <code>raquo</code> </td><td> U+000BB </td><td> <span>»</span> </td></tr><tr id="entity-Rarr"><td> <code>Rarr;</code> </td><td> U+021A0 </td><td> <span class="glyph">↠</span> </td></tr><tr id="entity-rArr"><td> <code>rArr;</code> </td><td> U+021D2 </td><td> <span class="glyph">⇒</span> </td></tr><tr id="entity-rarr"><td> <code>rarr;</code> </td><td> U+02192 </td><td> <span class="glyph">→</span> </td></tr><tr id="entity-rarrap"><td> <code>rarrap;</code> </td><td> U+02975 </td><td> <span class="glyph">⥵</span> </td></tr><tr id="entity-rarrb"><td> <code>rarrb;</code> </td><td> U+021E5 </td><td> <span class="glyph">⇥</span> </td></tr><tr id="entity-rarrbfs"><td> <code>rarrbfs;</code> </td><td> U+02920 </td><td> <span class="glyph">⤠</span> </td></tr><tr id="entity-rarrc"><td> <code>rarrc;</code> </td><td> U+02933 </td><td> <span class="glyph">⤳</span> </td></tr><tr id="entity-rarrfs"><td> <code>rarrfs;</code> </td><td> U+0291E </td><td> <span class="glyph">⤞</span> </td></tr><tr id="entity-rarrhk"><td> <code>rarrhk;</code> </td><td> U+021AA </td><td> <span class="glyph">↪</span> </td></tr><tr id="entity-rarrlp"><td> <code>rarrlp;</code> </td><td> U+021AC </td><td> <span class="glyph">↬</span> </td></tr><tr id="entity-rarrpl"><td> <code>rarrpl;</code> </td><td> U+02945 </td><td> <span class="glyph">⥅</span> </td></tr><tr id="entity-rarrsim"><td> <code>rarrsim;</code> </td><td> U+02974 </td><td> <span class="glyph">⥴</span> </td></tr><tr id="entity-Rarrtl"><td> <code>Rarrtl;</code> </td><td> U+02916 </td><td> <span class="glyph">⤖</span> </td></tr><tr id="entity-rarrtl"><td> <code>rarrtl;</code> </td><td> U+021A3 </td><td> <span class="glyph">↣</span> </td></tr><tr id="entity-rarrw"><td> <code>rarrw;</code> </td><td> U+0219D </td><td> <span class="glyph">↝</span> </td></tr><tr id="entity-rAtail"><td> <code>rAtail;</code> </td><td> U+0291C </td><td> <span class="glyph">⤜</span> </td></tr><tr id="entity-ratail"><td> <code>ratail;</code> </td><td> U+0291A </td><td> <span class="glyph">⤚</span> </td></tr><tr id="entity-ratio"><td> <code>ratio;</code> </td><td> U+02236 </td><td> <span class="glyph">∶</span> </td></tr><tr id="entity-rationals"><td> <code>rationals;</code> </td><td> U+0211A </td><td> <span class="glyph">ℚ</span> </td></tr><tr id="entity-RBarr"><td> <code>RBarr;</code> </td><td> U+02910 </td><td> <span class="glyph">⤐</span> </td></tr><tr id="entity-rBarr"><td> <code>rBarr;</code> </td><td> U+0290F </td><td> <span class="glyph">⤏</span> </td></tr><tr id="entity-rbarr"><td> <code>rbarr;</code> </td><td> U+0290D </td><td> <span class="glyph">⤍</span> </td></tr><tr id="entity-rbbrk"><td> <code>rbbrk;</code> </td><td> U+02773 </td><td> <span class="glyph">❳</span> </td></tr><tr id="entity-rbrace"><td> <code>rbrace;</code> </td><td> U+0007D </td><td> <span class="glyph">}</span> </td></tr><tr id="entity-rbrack"><td> <code>rbrack;</code> </td><td> U+0005D </td><td> <span class="glyph">]</span> </td></tr><tr id="entity-rbrke"><td> <code>rbrke;</code> </td><td> U+0298C </td><td> <span class="glyph">⦌</span> </td></tr><tr id="entity-rbrksld"><td> <code>rbrksld;</code> </td><td> U+0298E </td><td> <span class="glyph">⦎</span> </td></tr><tr id="entity-rbrkslu"><td> <code>rbrkslu;</code> </td><td> U+02990 </td><td> <span class="glyph">⦐</span> </td></tr><tr id="entity-Rcaron"><td> <code>Rcaron;</code> </td><td> U+00158 </td><td> <span class="glyph">Ř</span> </td></tr><tr id="entity-rcaron"><td> <code>rcaron;</code> </td><td> U+00159 </td><td> <span class="glyph">ř</span> </td></tr><tr id="entity-Rcedil"><td> <code>Rcedil;</code> </td><td> U+00156 </td><td> <span class="glyph">Ŗ</span> </td></tr><tr id="entity-rcedil"><td> <code>rcedil;</code> </td><td> U+00157 </td><td> <span class="glyph">ŗ</span> </td></tr><tr id="entity-rceil"><td> <code>rceil;</code> </td><td> U+02309 </td><td> <span class="glyph">⌉</span> </td></tr><tr id="entity-rcub"><td> <code>rcub;</code> </td><td> U+0007D </td><td> <span class="glyph">}</span> </td></tr><tr id="entity-Rcy"><td> <code>Rcy;</code> </td><td> U+00420 </td><td> <span class="glyph">Р</span> </td></tr><tr id="entity-rcy"><td> <code>rcy;</code> </td><td> U+00440 </td><td> <span class="glyph">р</span> </td></tr><tr id="entity-rdca"><td> <code>rdca;</code> </td><td> U+02937 </td><td> <span class="glyph">⤷</span> </td></tr><tr id="entity-rdldhar"><td> <code>rdldhar;</code> </td><td> U+02969 </td><td> <span class="glyph">⥩</span> </td></tr><tr id="entity-rdquo"><td> <code>rdquo;</code> </td><td> U+0201D </td><td> <span class="glyph">”</span> </td></tr><tr id="entity-rdquor"><td> <code>rdquor;</code> </td><td> U+0201D </td><td> <span class="glyph">”</span> </td></tr><tr id="entity-rdsh"><td> <code>rdsh;</code> </td><td> U+021B3 </td><td> <span class="glyph">↳</span> </td></tr><tr id="entity-Re"><td> <code>Re;</code> </td><td> U+0211C </td><td> <span class="glyph">ℜ</span> </td></tr><tr id="entity-real"><td> <code>real;</code> </td><td> U+0211C </td><td> <span class="glyph">ℜ</span> </td></tr><tr id="entity-realine"><td> <code>realine;</code> </td><td> U+0211B </td><td> <span class="glyph">ℛ</span> </td></tr><tr id="entity-realpart"><td> <code>realpart;</code> </td><td> U+0211C </td><td> <span class="glyph">ℜ</span> </td></tr><tr id="entity-reals"><td> <code>reals;</code> </td><td> U+0211D </td><td> <span class="glyph">ℝ</span> </td></tr><tr id="entity-rect"><td> <code>rect;</code> </td><td> U+025AD </td><td> <span class="glyph">▭</span> </td></tr><tr id="entity-REG"><td> <code>REG;</code> </td><td> U+000AE </td><td> <span class="glyph">®</span> </td></tr><tr id="entity-REG-legacy" class="impl"><td> <code>REG</code> </td><td> U+000AE </td><td> <span>®</span> </td></tr><tr id="entity-reg"><td> <code>reg;</code> </td><td> U+000AE </td><td> <span class="glyph">®</span> </td></tr><tr id="entity-reg-legacy" class="impl"><td> <code>reg</code> </td><td> U+000AE </td><td> <span>®</span> </td></tr><tr id="entity-ReverseElement"><td> <code>ReverseElement;</code> </td><td> U+0220B </td><td> <span class="glyph">∋</span> </td></tr><tr id="entity-ReverseEquilibrium"><td> <code>ReverseEquilibrium;</code> </td><td> U+021CB </td><td> <span class="glyph">⇋</span> </td></tr><tr id="entity-ReverseUpEquilibrium"><td> <code>ReverseUpEquilibrium;</code> </td><td> U+0296F </td><td> <span class="glyph">⥯</span> </td></tr><tr id="entity-rfisht"><td> <code>rfisht;</code> </td><td> U+0297D </td><td> <span class="glyph">⥽</span> </td></tr><tr id="entity-rfloor"><td> <code>rfloor;</code> </td><td> U+0230B </td><td> <span class="glyph">⌋</span> </td></tr><tr id="entity-Rfr"><td> <code>Rfr;</code> </td><td> U+0211C </td><td> <span class="glyph">ℜ</span> </td></tr><tr id="entity-rfr"><td> <code>rfr;</code> </td><td> U+1D52F </td><td> <span class="glyph">𝔯</span> </td></tr><tr id="entity-rHar"><td> <code>rHar;</code> </td><td> U+02964 </td><td> <span class="glyph">⥤</span> </td></tr><tr id="entity-rhard"><td> <code>rhard;</code> </td><td> U+021C1 </td><td> <span class="glyph">⇁</span> </td></tr><tr id="entity-rharu"><td> <code>rharu;</code> </td><td> U+021C0 </td><td> <span class="glyph">⇀</span> </td></tr><tr id="entity-rharul"><td> <code>rharul;</code> </td><td> U+0296C </td><td> <span class="glyph">⥬</span> </td></tr><tr id="entity-Rho"><td> <code>Rho;</code> </td><td> U+003A1 </td><td> <span class="glyph">Ρ</span> </td></tr><tr id="entity-rho"><td> <code>rho;</code> </td><td> U+003C1 </td><td> <span class="glyph">ρ</span> </td></tr><tr id="entity-rhov"><td> <code>rhov;</code> </td><td> U+003F1 </td><td> <span class="glyph">ϱ</span> </td></tr><tr id="entity-RightAngleBracket"><td> <code>RightAngleBracket;</code> </td><td> U+027E9 </td><td> <span class="glyph">⟩</span> </td></tr><tr id="entity-RightArrow"><td> <code>RightArrow;</code> </td><td> U+02192 </td><td> <span class="glyph">→</span> </td></tr><tr id="entity-Rightarrow"><td> <code>Rightarrow;</code> </td><td> U+021D2 </td><td> <span class="glyph">⇒</span> </td></tr><tr id="entity-rightarrow"><td> <code>rightarrow;</code> </td><td> U+02192 </td><td> <span class="glyph">→</span> </td></tr><tr id="entity-RightArrowBar"><td> <code>RightArrowBar;</code> </td><td> U+021E5 </td><td> <span class="glyph">⇥</span> </td></tr><tr id="entity-RightArrowLeftArrow"><td> <code>RightArrowLeftArrow;</code> </td><td> U+021C4 </td><td> <span class="glyph">⇄</span> </td></tr><tr id="entity-rightarrowtail"><td> <code>rightarrowtail;</code> </td><td> U+021A3 </td><td> <span class="glyph">↣</span> </td></tr><tr id="entity-RightCeiling"><td> <code>RightCeiling;</code> </td><td> U+02309 </td><td> <span class="glyph">⌉</span> </td></tr><tr id="entity-RightDoubleBracket"><td> <code>RightDoubleBracket;</code> </td><td> U+027E7 </td><td> <span class="glyph">⟧</span> </td></tr><tr id="entity-RightDownTeeVector"><td> <code>RightDownTeeVector;</code> </td><td> U+0295D </td><td> <span class="glyph">⥝</span> </td></tr><tr id="entity-RightDownVector"><td> <code>RightDownVector;</code> </td><td> U+021C2 </td><td> <span class="glyph">⇂</span> </td></tr><tr id="entity-RightDownVectorBar"><td> <code>RightDownVectorBar;</code> </td><td> U+02955 </td><td> <span class="glyph">⥕</span> </td></tr><tr id="entity-RightFloor"><td> <code>RightFloor;</code> </td><td> U+0230B </td><td> <span class="glyph">⌋</span> </td></tr><tr id="entity-rightharpoondown"><td> <code>rightharpoondown;</code> </td><td> U+021C1 </td><td> <span class="glyph">⇁</span> </td></tr><tr id="entity-rightharpoonup"><td> <code>rightharpoonup;</code> </td><td> U+021C0 </td><td> <span class="glyph">⇀</span> </td></tr><tr id="entity-rightleftarrows"><td> <code>rightleftarrows;</code> </td><td> U+021C4 </td><td> <span class="glyph">⇄</span> </td></tr><tr id="entity-rightleftharpoons"><td> <code>rightleftharpoons;</code> </td><td> U+021CC </td><td> <span class="glyph">⇌</span> </td></tr><tr id="entity-rightrightarrows"><td> <code>rightrightarrows;</code> </td><td> U+021C9 </td><td> <span class="glyph">⇉</span> </td></tr><tr id="entity-rightsquigarrow"><td> <code>rightsquigarrow;</code> </td><td> U+0219D </td><td> <span class="glyph">↝</span> </td></tr><tr id="entity-RightTee"><td> <code>RightTee;</code> </td><td> U+022A2 </td><td> <span class="glyph">⊢</span> </td></tr><tr id="entity-RightTeeArrow"><td> <code>RightTeeArrow;</code> </td><td> U+021A6 </td><td> <span class="glyph">↦</span> </td></tr><tr id="entity-RightTeeVector"><td> <code>RightTeeVector;</code> </td><td> U+0295B </td><td> <span class="glyph">⥛</span> </td></tr><tr id="entity-rightthreetimes"><td> <code>rightthreetimes;</code> </td><td> U+022CC </td><td> <span class="glyph">⋌</span> </td></tr><tr id="entity-RightTriangle"><td> <code>RightTriangle;</code> </td><td> U+022B3 </td><td> <span class="glyph">⊳</span> </td></tr><tr id="entity-RightTriangleBar"><td> <code>RightTriangleBar;</code> </td><td> U+029D0 </td><td> <span class="glyph">⧐</span> </td></tr><tr id="entity-RightTriangleEqual"><td> <code>RightTriangleEqual;</code> </td><td> U+022B5 </td><td> <span class="glyph">⊵</span> </td></tr><tr id="entity-RightUpDownVector"><td> <code>RightUpDownVector;</code> </td><td> U+0294F </td><td> <span class="glyph">⥏</span> </td></tr><tr id="entity-RightUpTeeVector"><td> <code>RightUpTeeVector;</code> </td><td> U+0295C </td><td> <span class="glyph">⥜</span> </td></tr><tr id="entity-RightUpVector"><td> <code>RightUpVector;</code> </td><td> U+021BE </td><td> <span class="glyph">↾</span> </td></tr><tr id="entity-RightUpVectorBar"><td> <code>RightUpVectorBar;</code> </td><td> U+02954 </td><td> <span class="glyph">⥔</span> </td></tr><tr id="entity-RightVector"><td> <code>RightVector;</code> </td><td> U+021C0 </td><td> <span class="glyph">⇀</span> </td></tr><tr id="entity-RightVectorBar"><td> <code>RightVectorBar;</code> </td><td> U+02953 </td><td> <span class="glyph">⥓</span> </td></tr><tr id="entity-ring"><td> <code>ring;</code> </td><td> U+002DA </td><td> <span class="glyph">˚</span> </td></tr><tr id="entity-risingdotseq"><td> <code>risingdotseq;</code> </td><td> U+02253 </td><td> <span class="glyph">≓</span> </td></tr><tr id="entity-rlarr"><td> <code>rlarr;</code> </td><td> U+021C4 </td><td> <span class="glyph">⇄</span> </td></tr><tr id="entity-rlhar"><td> <code>rlhar;</code> </td><td> U+021CC </td><td> <span class="glyph">⇌</span> </td></tr><tr id="entity-rlm"><td> <code>rlm;</code> </td><td> U+0200F </td><td> <span class="glyph">‏</span> </td></tr><tr id="entity-rmoust"><td> <code>rmoust;</code> </td><td> U+023B1 </td><td> <span class="glyph">⎱</span> </td></tr><tr id="entity-rmoustache"><td> <code>rmoustache;</code> </td><td> U+023B1 </td><td> <span class="glyph">⎱</span> </td></tr><tr id="entity-rnmid"><td> <code>rnmid;</code> </td><td> U+02AEE </td><td> <span class="glyph">⫮</span> </td></tr><tr id="entity-roang"><td> <code>roang;</code> </td><td> U+027ED </td><td> <span class="glyph">⟭</span> </td></tr><tr id="entity-roarr"><td> <code>roarr;</code> </td><td> U+021FE </td><td> <span class="glyph">⇾</span> </td></tr><tr id="entity-robrk"><td> <code>robrk;</code> </td><td> U+027E7 </td><td> <span class="glyph">⟧</span> </td></tr><tr id="entity-ropar"><td> <code>ropar;</code> </td><td> U+02986 </td><td> <span class="glyph">⦆</span> </td></tr><tr id="entity-Ropf"><td> <code>Ropf;</code> </td><td> U+0211D </td><td> <span class="glyph">ℝ</span> </td></tr><tr id="entity-ropf"><td> <code>ropf;</code> </td><td> U+1D563 </td><td> <span class="glyph">𝕣</span> </td></tr><tr id="entity-roplus"><td> <code>roplus;</code> </td><td> U+02A2E </td><td> <span class="glyph">⨮</span> </td></tr><tr id="entity-rotimes"><td> <code>rotimes;</code> </td><td> U+02A35 </td><td> <span class="glyph">⨵</span> </td></tr><tr id="entity-RoundImplies"><td> <code>RoundImplies;</code> </td><td> U+02970 </td><td> <span class="glyph">⥰</span> </td></tr><tr id="entity-rpar"><td> <code>rpar;</code> </td><td> U+00029 </td><td> <span class="glyph">)</span> </td></tr><tr id="entity-rpargt"><td> <code>rpargt;</code> </td><td> U+02994 </td><td> <span class="glyph">⦔</span> </td></tr><tr id="entity-rppolint"><td> <code>rppolint;</code> </td><td> U+02A12 </td><td> <span class="glyph">⨒</span> </td></tr><tr id="entity-rrarr"><td> <code>rrarr;</code> </td><td> U+021C9 </td><td> <span class="glyph">⇉</span> </td></tr><tr id="entity-Rrightarrow"><td> <code>Rrightarrow;</code> </td><td> U+021DB </td><td> <span class="glyph">⇛</span> </td></tr><tr id="entity-rsaquo"><td> <code>rsaquo;</code> </td><td> U+0203A </td><td> <span class="glyph">›</span> </td></tr><tr id="entity-Rscr"><td> <code>Rscr;</code> </td><td> U+0211B </td><td> <span class="glyph">ℛ</span> </td></tr><tr id="entity-rscr"><td> <code>rscr;</code> </td><td> U+1D4C7 </td><td> <span class="glyph">𝓇</span> </td></tr><tr id="entity-Rsh"><td> <code>Rsh;</code> </td><td> U+021B1 </td><td> <span class="glyph">↱</span> </td></tr><tr id="entity-rsh"><td> <code>rsh;</code> </td><td> U+021B1 </td><td> <span class="glyph">↱</span> </td></tr><tr id="entity-rsqb"><td> <code>rsqb;</code> </td><td> U+0005D </td><td> <span class="glyph">]</span> </td></tr><tr id="entity-rsquo"><td> <code>rsquo;</code> </td><td> U+02019 </td><td> <span class="glyph">’</span> </td></tr><tr id="entity-rsquor"><td> <code>rsquor;</code> </td><td> U+02019 </td><td> <span class="glyph">’</span> </td></tr><tr id="entity-rthree"><td> <code>rthree;</code> </td><td> U+022CC </td><td> <span class="glyph">⋌</span> </td></tr><tr id="entity-rtimes"><td> <code>rtimes;</code> </td><td> U+022CA </td><td> <span class="glyph">⋊</span> </td></tr><tr id="entity-rtri"><td> <code>rtri;</code> </td><td> U+025B9 </td><td> <span class="glyph">▹</span> </td></tr><tr id="entity-rtrie"><td> <code>rtrie;</code> </td><td> U+022B5 </td><td> <span class="glyph">⊵</span> </td></tr><tr id="entity-rtrif"><td> <code>rtrif;</code> </td><td> U+025B8 </td><td> <span class="glyph">▸</span> </td></tr><tr id="entity-rtriltri"><td> <code>rtriltri;</code> </td><td> U+029CE </td><td> <span class="glyph">⧎</span> </td></tr><tr id="entity-RuleDelayed"><td> <code>RuleDelayed;</code> </td><td> U+029F4 </td><td> <span class="glyph">⧴</span> </td></tr><tr id="entity-ruluhar"><td> <code>ruluhar;</code> </td><td> U+02968 </td><td> <span class="glyph">⥨</span> </td></tr><tr id="entity-rx"><td> <code>rx;</code> </td><td> U+0211E </td><td> <span class="glyph">℞</span> </td></tr><tr id="entity-Sacute"><td> <code>Sacute;</code> </td><td> U+0015A </td><td> <span class="glyph">Ś</span> </td></tr><tr id="entity-sacute"><td> <code>sacute;</code> </td><td> U+0015B </td><td> <span class="glyph">ś</span> </td></tr><tr id="entity-sbquo"><td> <code>sbquo;</code> </td><td> U+0201A </td><td> <span class="glyph">‚</span> </td></tr><tr id="entity-Sc"><td> <code>Sc;</code> </td><td> U+02ABC </td><td> <span class="glyph">⪼</span> </td></tr><tr id="entity-sc"><td> <code>sc;</code> </td><td> U+0227B </td><td> <span class="glyph">≻</span> </td></tr><tr id="entity-scap"><td> <code>scap;</code> </td><td> U+02AB8 </td><td> <span class="glyph">⪸</span> </td></tr><tr id="entity-Scaron"><td> <code>Scaron;</code> </td><td> U+00160 </td><td> <span class="glyph">Š</span> </td></tr><tr id="entity-scaron"><td> <code>scaron;</code> </td><td> U+00161 </td><td> <span class="glyph">š</span> </td></tr><tr id="entity-sccue"><td> <code>sccue;</code> </td><td> U+0227D </td><td> <span class="glyph">≽</span> </td></tr><tr id="entity-scE"><td> <code>scE;</code> </td><td> U+02AB4 </td><td> <span class="glyph">⪴</span> </td></tr><tr id="entity-sce"><td> <code>sce;</code> </td><td> U+02AB0 </td><td> <span class="glyph">⪰</span> </td></tr><tr id="entity-Scedil"><td> <code>Scedil;</code> </td><td> U+0015E </td><td> <span class="glyph">Ş</span> </td></tr><tr id="entity-scedil"><td> <code>scedil;</code> </td><td> U+0015F </td><td> <span class="glyph">ş</span> </td></tr><tr id="entity-Scirc"><td> <code>Scirc;</code> </td><td> U+0015C </td><td> <span class="glyph">Ŝ</span> </td></tr><tr id="entity-scirc"><td> <code>scirc;</code> </td><td> U+0015D </td><td> <span class="glyph">ŝ</span> </td></tr><tr id="entity-scnap"><td> <code>scnap;</code> </td><td> U+02ABA </td><td> <span class="glyph">⪺</span> </td></tr><tr id="entity-scnE"><td> <code>scnE;</code> </td><td> U+02AB6 </td><td> <span class="glyph">⪶</span> </td></tr><tr id="entity-scnsim"><td> <code>scnsim;</code> </td><td> U+022E9 </td><td> <span class="glyph">⋩</span> </td></tr><tr id="entity-scpolint"><td> <code>scpolint;</code> </td><td> U+02A13 </td><td> <span class="glyph">⨓</span> </td></tr><tr id="entity-scsim"><td> <code>scsim;</code> </td><td> U+0227F </td><td> <span class="glyph">≿</span> </td></tr><tr id="entity-Scy"><td> <code>Scy;</code> </td><td> U+00421 </td><td> <span class="glyph">С</span> </td></tr><tr id="entity-scy"><td> <code>scy;</code> </td><td> U+00441 </td><td> <span class="glyph">с</span> </td></tr><tr id="entity-sdot"><td> <code>sdot;</code> </td><td> U+022C5 </td><td> <span class="glyph">⋅</span> </td></tr><tr id="entity-sdotb"><td> <code>sdotb;</code> </td><td> U+022A1 </td><td> <span class="glyph">⊡</span> </td></tr><tr id="entity-sdote"><td> <code>sdote;</code> </td><td> U+02A66 </td><td> <span class="glyph">⩦</span> </td></tr><tr id="entity-searhk"><td> <code>searhk;</code> </td><td> U+02925 </td><td> <span class="glyph">⤥</span> </td></tr><tr id="entity-seArr"><td> <code>seArr;</code> </td><td> U+021D8 </td><td> <span class="glyph">⇘</span> </td></tr><tr id="entity-searr"><td> <code>searr;</code> </td><td> U+02198 </td><td> <span class="glyph">↘</span> </td></tr><tr id="entity-searrow"><td> <code>searrow;</code> </td><td> U+02198 </td><td> <span class="glyph">↘</span> </td></tr><tr id="entity-sect"><td> <code>sect;</code> </td><td> U+000A7 </td><td> <span class="glyph">§</span> </td></tr><tr id="entity-sect-legacy" class="impl"><td> <code>sect</code> </td><td> U+000A7 </td><td> <span>§</span> </td></tr><tr id="entity-semi"><td> <code>semi;</code> </td><td> U+0003B </td><td> <span class="glyph">;</span> </td></tr><tr id="entity-seswar"><td> <code>seswar;</code> </td><td> U+02929 </td><td> <span class="glyph">⤩</span> </td></tr><tr id="entity-setminus"><td> <code>setminus;</code> </td><td> U+02216 </td><td> <span class="glyph">∖</span> </td></tr><tr id="entity-setmn"><td> <code>setmn;</code> </td><td> U+02216 </td><td> <span class="glyph">∖</span> </td></tr><tr id="entity-sext"><td> <code>sext;</code> </td><td> U+02736 </td><td> <span class="glyph">✶</span> </td></tr><tr id="entity-Sfr"><td> <code>Sfr;</code> </td><td> U+1D516 </td><td> <span class="glyph">𝔖</span> </td></tr><tr id="entity-sfr"><td> <code>sfr;</code> </td><td> U+1D530 </td><td> <span class="glyph">𝔰</span> </td></tr><tr id="entity-sfrown"><td> <code>sfrown;</code> </td><td> U+02322 </td><td> <span class="glyph">⌢</span> </td></tr><tr id="entity-sharp"><td> <code>sharp;</code> </td><td> U+0266F </td><td> <span class="glyph">♯</span> </td></tr><tr id="entity-SHCHcy"><td> <code>SHCHcy;</code> </td><td> U+00429 </td><td> <span class="glyph">Щ</span> </td></tr><tr id="entity-shchcy"><td> <code>shchcy;</code> </td><td> U+00449 </td><td> <span class="glyph">щ</span> </td></tr><tr id="entity-SHcy"><td> <code>SHcy;</code> </td><td> U+00428 </td><td> <span class="glyph">Ш</span> </td></tr><tr id="entity-shcy"><td> <code>shcy;</code> </td><td> U+00448 </td><td> <span class="glyph">ш</span> </td></tr><tr id="entity-ShortDownArrow"><td> <code>ShortDownArrow;</code> </td><td> U+02193 </td><td> <span class="glyph">↓</span> </td></tr><tr id="entity-ShortLeftArrow"><td> <code>ShortLeftArrow;</code> </td><td> U+02190 </td><td> <span class="glyph">←</span> </td></tr><tr id="entity-shortmid"><td> <code>shortmid;</code> </td><td> U+02223 </td><td> <span class="glyph">∣</span> </td></tr><tr id="entity-shortparallel"><td> <code>shortparallel;</code> </td><td> U+02225 </td><td> <span class="glyph">∥</span> </td></tr><tr id="entity-ShortRightArrow"><td> <code>ShortRightArrow;</code> </td><td> U+02192 </td><td> <span class="glyph">→</span> </td></tr><tr id="entity-ShortUpArrow"><td> <code>ShortUpArrow;</code> </td><td> U+02191 </td><td> <span class="glyph">↑</span> </td></tr><tr id="entity-shy"><td> <code>shy;</code> </td><td> U+000AD </td><td> <span class="glyph">­</span> </td></tr><tr id="entity-shy-legacy" class="impl"><td> <code>shy</code> </td><td> U+000AD </td><td> <span>­</span> </td></tr><tr id="entity-Sigma"><td> <code>Sigma;</code> </td><td> U+003A3 </td><td> <span class="glyph">Σ</span> </td></tr><tr id="entity-sigma"><td> <code>sigma;</code> </td><td> U+003C3 </td><td> <span class="glyph">σ</span> </td></tr><tr id="entity-sigmaf"><td> <code>sigmaf;</code> </td><td> U+003C2 </td><td> <span class="glyph">ς</span> </td></tr><tr id="entity-sigmav"><td> <code>sigmav;</code> </td><td> U+003C2 </td><td> <span class="glyph">ς</span> </td></tr><tr id="entity-sim"><td> <code>sim;</code> </td><td> U+0223C </td><td> <span class="glyph">∼</span> </td></tr><tr id="entity-simdot"><td> <code>simdot;</code> </td><td> U+02A6A </td><td> <span class="glyph">⩪</span> </td></tr><tr id="entity-sime"><td> <code>sime;</code> </td><td> U+02243 </td><td> <span class="glyph">≃</span> </td></tr><tr id="entity-simeq"><td> <code>simeq;</code> </td><td> U+02243 </td><td> <span class="glyph">≃</span> </td></tr><tr id="entity-simg"><td> <code>simg;</code> </td><td> U+02A9E </td><td> <span class="glyph">⪞</span> </td></tr><tr id="entity-simgE"><td> <code>simgE;</code> </td><td> U+02AA0 </td><td> <span class="glyph">⪠</span> </td></tr><tr id="entity-siml"><td> <code>siml;</code> </td><td> U+02A9D </td><td> <span class="glyph">⪝</span> </td></tr><tr id="entity-simlE"><td> <code>simlE;</code> </td><td> U+02A9F </td><td> <span class="glyph">⪟</span> </td></tr><tr id="entity-simne"><td> <code>simne;</code> </td><td> U+02246 </td><td> <span class="glyph">≆</span> </td></tr><tr id="entity-simplus"><td> <code>simplus;</code> </td><td> U+02A24 </td><td> <span class="glyph">⨤</span> </td></tr><tr id="entity-simrarr"><td> <code>simrarr;</code> </td><td> U+02972 </td><td> <span class="glyph">⥲</span> </td></tr><tr id="entity-slarr"><td> <code>slarr;</code> </td><td> U+02190 </td><td> <span class="glyph">←</span> </td></tr><tr id="entity-SmallCircle"><td> <code>SmallCircle;</code> </td><td> U+02218 </td><td> <span class="glyph">∘</span> </td></tr><tr id="entity-smallsetminus"><td> <code>smallsetminus;</code> </td><td> U+02216 </td><td> <span class="glyph">∖</span> </td></tr><tr id="entity-smashp"><td> <code>smashp;</code> </td><td> U+02A33 </td><td> <span class="glyph">⨳</span> </td></tr><tr id="entity-smeparsl"><td> <code>smeparsl;</code> </td><td> U+029E4 </td><td> <span class="glyph">⧤</span> </td></tr><tr id="entity-smid"><td> <code>smid;</code> </td><td> U+02223 </td><td> <span class="glyph">∣</span> </td></tr><tr id="entity-smile"><td> <code>smile;</code> </td><td> U+02323 </td><td> <span class="glyph">⌣</span> </td></tr><tr id="entity-smt"><td> <code>smt;</code> </td><td> U+02AAA </td><td> <span class="glyph">⪪</span> </td></tr><tr id="entity-smte"><td> <code>smte;</code> </td><td> U+02AAC </td><td> <span class="glyph">⪬</span> </td></tr><tr id="entity-smtes"><td> <code>smtes;</code> </td><td> U+02AAC U+0FE00 </td><td> <span class="glyph compound">⪬︀</span> </td></tr><tr id="entity-SOFTcy"><td> <code>SOFTcy;</code> </td><td> U+0042C </td><td> <span class="glyph">Ь</span> </td></tr><tr id="entity-softcy"><td> <code>softcy;</code> </td><td> U+0044C </td><td> <span class="glyph">ь</span> </td></tr><tr id="entity-sol"><td> <code>sol;</code> </td><td> U+0002F </td><td> <span class="glyph">/</span> </td></tr><tr id="entity-solb"><td> <code>solb;</code> </td><td> U+029C4 </td><td> <span class="glyph">⧄</span> </td></tr><tr id="entity-solbar"><td> <code>solbar;</code> </td><td> U+0233F </td><td> <span class="glyph">⌿</span> </td></tr><tr id="entity-Sopf"><td> <code>Sopf;</code> </td><td> U+1D54A </td><td> <span class="glyph">𝕊</span> </td></tr><tr id="entity-sopf"><td> <code>sopf;</code> </td><td> U+1D564 </td><td> <span class="glyph">𝕤</span> </td></tr><tr id="entity-spades"><td> <code>spades;</code> </td><td> U+02660 </td><td> <span class="glyph">♠</span> </td></tr><tr id="entity-spadesuit"><td> <code>spadesuit;</code> </td><td> U+02660 </td><td> <span class="glyph">♠</span> </td></tr><tr id="entity-spar"><td> <code>spar;</code> </td><td> U+02225 </td><td> <span class="glyph">∥</span> </td></tr><tr id="entity-sqcap"><td> <code>sqcap;</code> </td><td> U+02293 </td><td> <span class="glyph">⊓</span> </td></tr><tr id="entity-sqcaps"><td> <code>sqcaps;</code> </td><td> U+02293 U+0FE00 </td><td> <span class="glyph compound">⊓︀</span> </td></tr><tr id="entity-sqcup"><td> <code>sqcup;</code> </td><td> U+02294 </td><td> <span class="glyph">⊔</span> </td></tr><tr id="entity-sqcups"><td> <code>sqcups;</code> </td><td> U+02294 U+0FE00 </td><td> <span class="glyph compound">⊔︀</span> </td></tr><tr id="entity-Sqrt"><td> <code>Sqrt;</code> </td><td> U+0221A </td><td> <span class="glyph">√</span> </td></tr><tr id="entity-sqsub"><td> <code>sqsub;</code> </td><td> U+0228F </td><td> <span class="glyph">⊏</span> </td></tr><tr id="entity-sqsube"><td> <code>sqsube;</code> </td><td> U+02291 </td><td> <span class="glyph">⊑</span> </td></tr><tr id="entity-sqsubset"><td> <code>sqsubset;</code> </td><td> U+0228F </td><td> <span class="glyph">⊏</span> </td></tr><tr id="entity-sqsubseteq"><td> <code>sqsubseteq;</code> </td><td> U+02291 </td><td> <span class="glyph">⊑</span> </td></tr><tr id="entity-sqsup"><td> <code>sqsup;</code> </td><td> U+02290 </td><td> <span class="glyph">⊐</span> </td></tr><tr id="entity-sqsupe"><td> <code>sqsupe;</code> </td><td> U+02292 </td><td> <span class="glyph">⊒</span> </td></tr><tr id="entity-sqsupset"><td> <code>sqsupset;</code> </td><td> U+02290 </td><td> <span class="glyph">⊐</span> </td></tr><tr id="entity-sqsupseteq"><td> <code>sqsupseteq;</code> </td><td> U+02292 </td><td> <span class="glyph">⊒</span> </td></tr><tr id="entity-squ"><td> <code>squ;</code> </td><td> U+025A1 </td><td> <span class="glyph">□</span> </td></tr><tr id="entity-Square"><td> <code>Square;</code> </td><td> U+025A1 </td><td> <span class="glyph">□</span> </td></tr><tr id="entity-square"><td> <code>square;</code> </td><td> U+025A1 </td><td> <span class="glyph">□</span> </td></tr><tr id="entity-SquareIntersection"><td> <code>SquareIntersection;</code> </td><td> U+02293 </td><td> <span class="glyph">⊓</span> </td></tr><tr id="entity-SquareSubset"><td> <code>SquareSubset;</code> </td><td> U+0228F </td><td> <span class="glyph">⊏</span> </td></tr><tr id="entity-SquareSubsetEqual"><td> <code>SquareSubsetEqual;</code> </td><td> U+02291 </td><td> <span class="glyph">⊑</span> </td></tr><tr id="entity-SquareSuperset"><td> <code>SquareSuperset;</code> </td><td> U+02290 </td><td> <span class="glyph">⊐</span> </td></tr><tr id="entity-SquareSupersetEqual"><td> <code>SquareSupersetEqual;</code> </td><td> U+02292 </td><td> <span class="glyph">⊒</span> </td></tr><tr id="entity-SquareUnion"><td> <code>SquareUnion;</code> </td><td> U+02294 </td><td> <span class="glyph">⊔</span> </td></tr><tr id="entity-squarf"><td> <code>squarf;</code> </td><td> U+025AA </td><td> <span class="glyph">▪</span> </td></tr><tr id="entity-squf"><td> <code>squf;</code> </td><td> U+025AA </td><td> <span class="glyph">▪</span> </td></tr><tr id="entity-srarr"><td> <code>srarr;</code> </td><td> U+02192 </td><td> <span class="glyph">→</span> </td></tr><tr id="entity-Sscr"><td> <code>Sscr;</code> </td><td> U+1D4AE </td><td> <span class="glyph">𝒮</span> </td></tr><tr id="entity-sscr"><td> <code>sscr;</code> </td><td> U+1D4C8 </td><td> <span class="glyph">𝓈</span> </td></tr><tr id="entity-ssetmn"><td> <code>ssetmn;</code> </td><td> U+02216 </td><td> <span class="glyph">∖</span> </td></tr><tr id="entity-ssmile"><td> <code>ssmile;</code> </td><td> U+02323 </td><td> <span class="glyph">⌣</span> </td></tr><tr id="entity-sstarf"><td> <code>sstarf;</code> </td><td> U+022C6 </td><td> <span class="glyph">⋆</span> </td></tr><tr id="entity-Star"><td> <code>Star;</code> </td><td> U+022C6 </td><td> <span class="glyph">⋆</span> </td></tr><tr id="entity-star"><td> <code>star;</code> </td><td> U+02606 </td><td> <span class="glyph">☆</span> </td></tr><tr id="entity-starf"><td> <code>starf;</code> </td><td> U+02605 </td><td> <span class="glyph">★</span> </td></tr><tr id="entity-straightepsilon"><td> <code>straightepsilon;</code> </td><td> U+003F5 </td><td> <span class="glyph">ϵ</span> </td></tr><tr id="entity-straightphi"><td> <code>straightphi;</code> </td><td> U+003D5 </td><td> <span class="glyph">ϕ</span> </td></tr><tr id="entity-strns"><td> <code>strns;</code> </td><td> U+000AF </td><td> <span class="glyph">¯</span> </td></tr><tr id="entity-Sub"><td> <code>Sub;</code> </td><td> U+022D0 </td><td> <span class="glyph">⋐</span> </td></tr><tr id="entity-sub"><td> <code>sub;</code> </td><td> U+02282 </td><td> <span class="glyph">⊂</span> </td></tr><tr id="entity-subdot"><td> <code>subdot;</code> </td><td> U+02ABD </td><td> <span class="glyph">⪽</span> </td></tr><tr id="entity-subE"><td> <code>subE;</code> </td><td> U+02AC5 </td><td> <span class="glyph">⫅</span> </td></tr><tr id="entity-sube"><td> <code>sube;</code> </td><td> U+02286 </td><td> <span class="glyph">⊆</span> </td></tr><tr id="entity-subedot"><td> <code>subedot;</code> </td><td> U+02AC3 </td><td> <span class="glyph">⫃</span> </td></tr><tr id="entity-submult"><td> <code>submult;</code> </td><td> U+02AC1 </td><td> <span class="glyph">⫁</span> </td></tr><tr id="entity-subnE"><td> <code>subnE;</code> </td><td> U+02ACB </td><td> <span class="glyph">⫋</span> </td></tr><tr id="entity-subne"><td> <code>subne;</code> </td><td> U+0228A </td><td> <span class="glyph">⊊</span> </td></tr><tr id="entity-subplus"><td> <code>subplus;</code> </td><td> U+02ABF </td><td> <span class="glyph">⪿</span> </td></tr><tr id="entity-subrarr"><td> <code>subrarr;</code> </td><td> U+02979 </td><td> <span class="glyph">⥹</span> </td></tr><tr id="entity-Subset"><td> <code>Subset;</code> </td><td> U+022D0 </td><td> <span class="glyph">⋐</span> </td></tr><tr id="entity-subset"><td> <code>subset;</code> </td><td> U+02282 </td><td> <span class="glyph">⊂</span> </td></tr><tr id="entity-subseteq"><td> <code>subseteq;</code> </td><td> U+02286 </td><td> <span class="glyph">⊆</span> </td></tr><tr id="entity-subseteqq"><td> <code>subseteqq;</code> </td><td> U+02AC5 </td><td> <span class="glyph">⫅</span> </td></tr><tr id="entity-SubsetEqual"><td> <code>SubsetEqual;</code> </td><td> U+02286 </td><td> <span class="glyph">⊆</span> </td></tr><tr id="entity-subsetneq"><td> <code>subsetneq;</code> </td><td> U+0228A </td><td> <span class="glyph">⊊</span> </td></tr><tr id="entity-subsetneqq"><td> <code>subsetneqq;</code> </td><td> U+02ACB </td><td> <span class="glyph">⫋</span> </td></tr><tr id="entity-subsim"><td> <code>subsim;</code> </td><td> U+02AC7 </td><td> <span class="glyph">⫇</span> </td></tr><tr id="entity-subsub"><td> <code>subsub;</code> </td><td> U+02AD5 </td><td> <span class="glyph">⫕</span> </td></tr><tr id="entity-subsup"><td> <code>subsup;</code> </td><td> U+02AD3 </td><td> <span class="glyph">⫓</span> </td></tr><tr id="entity-succ"><td> <code>succ;</code> </td><td> U+0227B </td><td> <span class="glyph">≻</span> </td></tr><tr id="entity-succapprox"><td> <code>succapprox;</code> </td><td> U+02AB8 </td><td> <span class="glyph">⪸</span> </td></tr><tr id="entity-succcurlyeq"><td> <code>succcurlyeq;</code> </td><td> U+0227D </td><td> <span class="glyph">≽</span> </td></tr><tr id="entity-Succeeds"><td> <code>Succeeds;</code> </td><td> U+0227B </td><td> <span class="glyph">≻</span> </td></tr><tr id="entity-SucceedsEqual"><td> <code>SucceedsEqual;</code> </td><td> U+02AB0 </td><td> <span class="glyph">⪰</span> </td></tr><tr id="entity-SucceedsSlantEqual"><td> <code>SucceedsSlantEqual;</code> </td><td> U+0227D </td><td> <span class="glyph">≽</span> </td></tr><tr id="entity-SucceedsTilde"><td> <code>SucceedsTilde;</code> </td><td> U+0227F </td><td> <span class="glyph">≿</span> </td></tr><tr id="entity-succeq"><td> <code>succeq;</code> </td><td> U+02AB0 </td><td> <span class="glyph">⪰</span> </td></tr><tr id="entity-succnapprox"><td> <code>succnapprox;</code> </td><td> U+02ABA </td><td> <span class="glyph">⪺</span> </td></tr><tr id="entity-succneqq"><td> <code>succneqq;</code> </td><td> U+02AB6 </td><td> <span class="glyph">⪶</span> </td></tr><tr id="entity-succnsim"><td> <code>succnsim;</code> </td><td> U+022E9 </td><td> <span class="glyph">⋩</span> </td></tr><tr id="entity-succsim"><td> <code>succsim;</code> </td><td> U+0227F </td><td> <span class="glyph">≿</span> </td></tr><tr id="entity-SuchThat"><td> <code>SuchThat;</code> </td><td> U+0220B </td><td> <span class="glyph">∋</span> </td></tr><tr id="entity-Sum"><td> <code>Sum;</code> </td><td> U+02211 </td><td> <span class="glyph">∑</span> </td></tr><tr id="entity-sum"><td> <code>sum;</code> </td><td> U+02211 </td><td> <span class="glyph">∑</span> </td></tr><tr id="entity-sung"><td> <code>sung;</code> </td><td> U+0266A </td><td> <span class="glyph">♪</span> </td></tr><tr id="entity-Sup"><td> <code>Sup;</code> </td><td> U+022D1 </td><td> <span class="glyph">⋑</span> </td></tr><tr id="entity-sup"><td> <code>sup;</code> </td><td> U+02283 </td><td> <span class="glyph">⊃</span> </td></tr><tr id="entity-sup1"><td> <code>sup1;</code> </td><td> U+000B9 </td><td> <span class="glyph">¹</span> </td></tr><tr id="entity-sup1-legacy" class="impl"><td> <code>sup1</code> </td><td> U+000B9 </td><td> <span>¹</span> </td></tr><tr id="entity-sup2"><td> <code>sup2;</code> </td><td> U+000B2 </td><td> <span class="glyph">²</span> </td></tr><tr id="entity-sup2-legacy" class="impl"><td> <code>sup2</code> </td><td> U+000B2 </td><td> <span>²</span> </td></tr><tr id="entity-sup3"><td> <code>sup3;</code> </td><td> U+000B3 </td><td> <span class="glyph">³</span> </td></tr><tr id="entity-sup3-legacy" class="impl"><td> <code>sup3</code> </td><td> U+000B3 </td><td> <span>³</span> </td></tr><tr id="entity-supdot"><td> <code>supdot;</code> </td><td> U+02ABE </td><td> <span class="glyph">⪾</span> </td></tr><tr id="entity-supdsub"><td> <code>supdsub;</code> </td><td> U+02AD8 </td><td> <span class="glyph">⫘</span> </td></tr><tr id="entity-supE"><td> <code>supE;</code> </td><td> U+02AC6 </td><td> <span class="glyph">⫆</span> </td></tr><tr id="entity-supe"><td> <code>supe;</code> </td><td> U+02287 </td><td> <span class="glyph">⊇</span> </td></tr><tr id="entity-supedot"><td> <code>supedot;</code> </td><td> U+02AC4 </td><td> <span class="glyph">⫄</span> </td></tr><tr id="entity-Superset"><td> <code>Superset;</code> </td><td> U+02283 </td><td> <span class="glyph">⊃</span> </td></tr><tr id="entity-SupersetEqual"><td> <code>SupersetEqual;</code> </td><td> U+02287 </td><td> <span class="glyph">⊇</span> </td></tr><tr id="entity-suphsol"><td> <code>suphsol;</code> </td><td> U+027C9 </td><td> <span class="glyph">⟉</span> </td></tr><tr id="entity-suphsub"><td> <code>suphsub;</code> </td><td> U+02AD7 </td><td> <span class="glyph">⫗</span> </td></tr><tr id="entity-suplarr"><td> <code>suplarr;</code> </td><td> U+0297B </td><td> <span class="glyph">⥻</span> </td></tr><tr id="entity-supmult"><td> <code>supmult;</code> </td><td> U+02AC2 </td><td> <span class="glyph">⫂</span> </td></tr><tr id="entity-supnE"><td> <code>supnE;</code> </td><td> U+02ACC </td><td> <span class="glyph">⫌</span> </td></tr><tr id="entity-supne"><td> <code>supne;</code> </td><td> U+0228B </td><td> <span class="glyph">⊋</span> </td></tr><tr id="entity-supplus"><td> <code>supplus;</code> </td><td> U+02AC0 </td><td> <span class="glyph">⫀</span> </td></tr><tr id="entity-Supset"><td> <code>Supset;</code> </td><td> U+022D1 </td><td> <span class="glyph">⋑</span> </td></tr><tr id="entity-supset"><td> <code>supset;</code> </td><td> U+02283 </td><td> <span class="glyph">⊃</span> </td></tr><tr id="entity-supseteq"><td> <code>supseteq;</code> </td><td> U+02287 </td><td> <span class="glyph">⊇</span> </td></tr><tr id="entity-supseteqq"><td> <code>supseteqq;</code> </td><td> U+02AC6 </td><td> <span class="glyph">⫆</span> </td></tr><tr id="entity-supsetneq"><td> <code>supsetneq;</code> </td><td> U+0228B </td><td> <span class="glyph">⊋</span> </td></tr><tr id="entity-supsetneqq"><td> <code>supsetneqq;</code> </td><td> U+02ACC </td><td> <span class="glyph">⫌</span> </td></tr><tr id="entity-supsim"><td> <code>supsim;</code> </td><td> U+02AC8 </td><td> <span class="glyph">⫈</span> </td></tr><tr id="entity-supsub"><td> <code>supsub;</code> </td><td> U+02AD4 </td><td> <span class="glyph">⫔</span> </td></tr><tr id="entity-supsup"><td> <code>supsup;</code> </td><td> U+02AD6 </td><td> <span class="glyph">⫖</span> </td></tr><tr id="entity-swarhk"><td> <code>swarhk;</code> </td><td> U+02926 </td><td> <span class="glyph">⤦</span> </td></tr><tr id="entity-swArr"><td> <code>swArr;</code> </td><td> U+021D9 </td><td> <span class="glyph">⇙</span> </td></tr><tr id="entity-swarr"><td> <code>swarr;</code> </td><td> U+02199 </td><td> <span class="glyph">↙</span> </td></tr><tr id="entity-swarrow"><td> <code>swarrow;</code> </td><td> U+02199 </td><td> <span class="glyph">↙</span> </td></tr><tr id="entity-swnwar"><td> <code>swnwar;</code> </td><td> U+0292A </td><td> <span class="glyph">⤪</span> </td></tr><tr id="entity-szlig"><td> <code>szlig;</code> </td><td> U+000DF </td><td> <span class="glyph">ß</span> </td></tr><tr id="entity-szlig-legacy" class="impl"><td> <code>szlig</code> </td><td> U+000DF </td><td> <span>ß</span> </td></tr><tr id="entity-Tab"><td> <code>Tab;</code> </td><td> U+00009 </td><td> <span class="glyph control">␉</span> </td></tr><tr id="entity-target"><td> <code>target;</code> </td><td> U+02316 </td><td> <span class="glyph">⌖</span> </td></tr><tr id="entity-Tau"><td> <code>Tau;</code> </td><td> U+003A4 </td><td> <span class="glyph">Τ</span> </td></tr><tr id="entity-tau"><td> <code>tau;</code> </td><td> U+003C4 </td><td> <span class="glyph">τ</span> </td></tr><tr id="entity-tbrk"><td> <code>tbrk;</code> </td><td> U+023B4 </td><td> <span class="glyph">⎴</span> </td></tr><tr id="entity-Tcaron"><td> <code>Tcaron;</code> </td><td> U+00164 </td><td> <span class="glyph">Ť</span> </td></tr><tr id="entity-tcaron"><td> <code>tcaron;</code> </td><td> U+00165 </td><td> <span class="glyph">ť</span> </td></tr><tr id="entity-Tcedil"><td> <code>Tcedil;</code> </td><td> U+00162 </td><td> <span class="glyph">Ţ</span> </td></tr><tr id="entity-tcedil"><td> <code>tcedil;</code> </td><td> U+00163 </td><td> <span class="glyph">ţ</span> </td></tr><tr id="entity-Tcy"><td> <code>Tcy;</code> </td><td> U+00422 </td><td> <span class="glyph">Т</span> </td></tr><tr id="entity-tcy"><td> <code>tcy;</code> </td><td> U+00442 </td><td> <span class="glyph">т</span> </td></tr><tr id="entity-tdot"><td> <code>tdot;</code> </td><td> U+020DB </td><td> <span class="glyph composition">◌⃛</span> </td></tr><tr id="entity-telrec"><td> <code>telrec;</code> </td><td> U+02315 </td><td> <span class="glyph">⌕</span> </td></tr><tr id="entity-Tfr"><td> <code>Tfr;</code> </td><td> U+1D517 </td><td> <span class="glyph">𝔗</span> </td></tr><tr id="entity-tfr"><td> <code>tfr;</code> </td><td> U+1D531 </td><td> <span class="glyph">𝔱</span> </td></tr><tr id="entity-there4"><td> <code>there4;</code> </td><td> U+02234 </td><td> <span class="glyph">∴</span> </td></tr><tr id="entity-Therefore"><td> <code>Therefore;</code> </td><td> U+02234 </td><td> <span class="glyph">∴</span> </td></tr><tr id="entity-therefore"><td> <code>therefore;</code> </td><td> U+02234 </td><td> <span class="glyph">∴</span> </td></tr><tr id="entity-Theta"><td> <code>Theta;</code> </td><td> U+00398 </td><td> <span class="glyph">Θ</span> </td></tr><tr id="entity-theta"><td> <code>theta;</code> </td><td> U+003B8 </td><td> <span class="glyph">θ</span> </td></tr><tr id="entity-thetasym"><td> <code>thetasym;</code> </td><td> U+003D1 </td><td> <span class="glyph">ϑ</span> </td></tr><tr id="entity-thetav"><td> <code>thetav;</code> </td><td> U+003D1 </td><td> <span class="glyph">ϑ</span> </td></tr><tr id="entity-thickapprox"><td> <code>thickapprox;</code> </td><td> U+02248 </td><td> <span class="glyph">≈</span> </td></tr><tr id="entity-thicksim"><td> <code>thicksim;</code> </td><td> U+0223C </td><td> <span class="glyph">∼</span> </td></tr><tr id="entity-ThickSpace"><td> <code>ThickSpace;</code> </td><td> U+0205F U+0200A </td><td> <span class="glyph compound">  </span> </td></tr><tr id="entity-thinsp"><td> <code>thinsp;</code> </td><td> U+02009 </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-ThinSpace"><td> <code>ThinSpace;</code> </td><td> U+02009 </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-thkap"><td> <code>thkap;</code> </td><td> U+02248 </td><td> <span class="glyph">≈</span> </td></tr><tr id="entity-thksim"><td> <code>thksim;</code> </td><td> U+0223C </td><td> <span class="glyph">∼</span> </td></tr><tr id="entity-THORN"><td> <code>THORN;</code> </td><td> U+000DE </td><td> <span class="glyph">Þ</span> </td></tr><tr id="entity-THORN-legacy" class="impl"><td> <code>THORN</code> </td><td> U+000DE </td><td> <span>Þ</span> </td></tr><tr id="entity-thorn"><td> <code>thorn;</code> </td><td> U+000FE </td><td> <span class="glyph">þ</span> </td></tr><tr id="entity-thorn-legacy" class="impl"><td> <code>thorn</code> </td><td> U+000FE </td><td> <span>þ</span> </td></tr><tr id="entity-Tilde"><td> <code>Tilde;</code> </td><td> U+0223C </td><td> <span class="glyph">∼</span> </td></tr><tr id="entity-tilde"><td> <code>tilde;</code> </td><td> U+002DC </td><td> <span class="glyph">˜</span> </td></tr><tr id="entity-TildeEqual"><td> <code>TildeEqual;</code> </td><td> U+02243 </td><td> <span class="glyph">≃</span> </td></tr><tr id="entity-TildeFullEqual"><td> <code>TildeFullEqual;</code> </td><td> U+02245 </td><td> <span class="glyph">≅</span> </td></tr><tr id="entity-TildeTilde"><td> <code>TildeTilde;</code> </td><td> U+02248 </td><td> <span class="glyph">≈</span> </td></tr><tr id="entity-times"><td> <code>times;</code> </td><td> U+000D7 </td><td> <span class="glyph">×</span> </td></tr><tr id="entity-times-legacy" class="impl"><td> <code>times</code> </td><td> U+000D7 </td><td> <span>×</span> </td></tr><tr id="entity-timesb"><td> <code>timesb;</code> </td><td> U+022A0 </td><td> <span class="glyph">⊠</span> </td></tr><tr id="entity-timesbar"><td> <code>timesbar;</code> </td><td> U+02A31 </td><td> <span class="glyph">⨱</span> </td></tr><tr id="entity-timesd"><td> <code>timesd;</code> </td><td> U+02A30 </td><td> <span class="glyph">⨰</span> </td></tr><tr id="entity-tint"><td> <code>tint;</code> </td><td> U+0222D </td><td> <span class="glyph">∭</span> </td></tr><tr id="entity-toea"><td> <code>toea;</code> </td><td> U+02928 </td><td> <span class="glyph">⤨</span> </td></tr><tr id="entity-top"><td> <code>top;</code> </td><td> U+022A4 </td><td> <span class="glyph">⊤</span> </td></tr><tr id="entity-topbot"><td> <code>topbot;</code> </td><td> U+02336 </td><td> <span class="glyph">⌶</span> </td></tr><tr id="entity-topcir"><td> <code>topcir;</code> </td><td> U+02AF1 </td><td> <span class="glyph">⫱</span> </td></tr><tr id="entity-Topf"><td> <code>Topf;</code> </td><td> U+1D54B </td><td> <span class="glyph">𝕋</span> </td></tr><tr id="entity-topf"><td> <code>topf;</code> </td><td> U+1D565 </td><td> <span class="glyph">𝕥</span> </td></tr><tr id="entity-topfork"><td> <code>topfork;</code> </td><td> U+02ADA </td><td> <span class="glyph">⫚</span> </td></tr><tr id="entity-tosa"><td> <code>tosa;</code> </td><td> U+02929 </td><td> <span class="glyph">⤩</span> </td></tr><tr id="entity-tprime"><td> <code>tprime;</code> </td><td> U+02034 </td><td> <span class="glyph">‴</span> </td></tr><tr id="entity-TRADE"><td> <code>TRADE;</code> </td><td> U+02122 </td><td> <span class="glyph">™</span> </td></tr><tr id="entity-trade"><td> <code>trade;</code> </td><td> U+02122 </td><td> <span class="glyph">™</span> </td></tr><tr id="entity-triangle"><td> <code>triangle;</code> </td><td> U+025B5 </td><td> <span class="glyph">▵</span> </td></tr><tr id="entity-triangledown"><td> <code>triangledown;</code> </td><td> U+025BF </td><td> <span class="glyph">▿</span> </td></tr><tr id="entity-triangleleft"><td> <code>triangleleft;</code> </td><td> U+025C3 </td><td> <span class="glyph">◃</span> </td></tr><tr id="entity-trianglelefteq"><td> <code>trianglelefteq;</code> </td><td> U+022B4 </td><td> <span class="glyph">⊴</span> </td></tr><tr id="entity-triangleq"><td> <code>triangleq;</code> </td><td> U+0225C </td><td> <span class="glyph">≜</span> </td></tr><tr id="entity-triangleright"><td> <code>triangleright;</code> </td><td> U+025B9 </td><td> <span class="glyph">▹</span> </td></tr><tr id="entity-trianglerighteq"><td> <code>trianglerighteq;</code> </td><td> U+022B5 </td><td> <span class="glyph">⊵</span> </td></tr><tr id="entity-tridot"><td> <code>tridot;</code> </td><td> U+025EC </td><td> <span class="glyph">◬</span> </td></tr><tr id="entity-trie"><td> <code>trie;</code> </td><td> U+0225C </td><td> <span class="glyph">≜</span> </td></tr><tr id="entity-triminus"><td> <code>triminus;</code> </td><td> U+02A3A </td><td> <span class="glyph">⨺</span> </td></tr><tr id="entity-TripleDot"><td> <code>TripleDot;</code> </td><td> U+020DB </td><td> <span class="glyph composition">◌⃛</span> </td></tr><tr id="entity-triplus"><td> <code>triplus;</code> </td><td> U+02A39 </td><td> <span class="glyph">⨹</span> </td></tr><tr id="entity-trisb"><td> <code>trisb;</code> </td><td> U+029CD </td><td> <span class="glyph">⧍</span> </td></tr><tr id="entity-tritime"><td> <code>tritime;</code> </td><td> U+02A3B </td><td> <span class="glyph">⨻</span> </td></tr><tr id="entity-trpezium"><td> <code>trpezium;</code> </td><td> U+023E2 </td><td> <span class="glyph">⏢</span> </td></tr><tr id="entity-Tscr"><td> <code>Tscr;</code> </td><td> U+1D4AF </td><td> <span class="glyph">𝒯</span> </td></tr><tr id="entity-tscr"><td> <code>tscr;</code> </td><td> U+1D4C9 </td><td> <span class="glyph">𝓉</span> </td></tr><tr id="entity-TScy"><td> <code>TScy;</code> </td><td> U+00426 </td><td> <span class="glyph">Ц</span> </td></tr><tr id="entity-tscy"><td> <code>tscy;</code> </td><td> U+00446 </td><td> <span class="glyph">ц</span> </td></tr><tr id="entity-TSHcy"><td> <code>TSHcy;</code> </td><td> U+0040B </td><td> <span class="glyph">Ћ</span> </td></tr><tr id="entity-tshcy"><td> <code>tshcy;</code> </td><td> U+0045B </td><td> <span class="glyph">ћ</span> </td></tr><tr id="entity-Tstrok"><td> <code>Tstrok;</code> </td><td> U+00166 </td><td> <span class="glyph">Ŧ</span> </td></tr><tr id="entity-tstrok"><td> <code>tstrok;</code> </td><td> U+00167 </td><td> <span class="glyph">ŧ</span> </td></tr><tr id="entity-twixt"><td> <code>twixt;</code> </td><td> U+0226C </td><td> <span class="glyph">≬</span> </td></tr><tr id="entity-twoheadleftarrow"><td> <code>twoheadleftarrow;</code> </td><td> U+0219E </td><td> <span class="glyph">↞</span> </td></tr><tr id="entity-twoheadrightarrow"><td> <code>twoheadrightarrow;</code> </td><td> U+021A0 </td><td> <span class="glyph">↠</span> </td></tr><tr id="entity-Uacute"><td> <code>Uacute;</code> </td><td> U+000DA </td><td> <span class="glyph">Ú</span> </td></tr><tr id="entity-Uacute-legacy" class="impl"><td> <code>Uacute</code> </td><td> U+000DA </td><td> <span>Ú</span> </td></tr><tr id="entity-uacute"><td> <code>uacute;</code> </td><td> U+000FA </td><td> <span class="glyph">ú</span> </td></tr><tr id="entity-uacute-legacy" class="impl"><td> <code>uacute</code> </td><td> U+000FA </td><td> <span>ú</span> </td></tr><tr id="entity-Uarr"><td> <code>Uarr;</code> </td><td> U+0219F </td><td> <span class="glyph">↟</span> </td></tr><tr id="entity-uArr"><td> <code>uArr;</code> </td><td> U+021D1 </td><td> <span class="glyph">⇑</span> </td></tr><tr id="entity-uarr"><td> <code>uarr;</code> </td><td> U+02191 </td><td> <span class="glyph">↑</span> </td></tr><tr id="entity-Uarrocir"><td> <code>Uarrocir;</code> </td><td> U+02949 </td><td> <span class="glyph">⥉</span> </td></tr><tr id="entity-Ubrcy"><td> <code>Ubrcy;</code> </td><td> U+0040E </td><td> <span class="glyph">Ў</span> </td></tr><tr id="entity-ubrcy"><td> <code>ubrcy;</code> </td><td> U+0045E </td><td> <span class="glyph">ў</span> </td></tr><tr id="entity-Ubreve"><td> <code>Ubreve;</code> </td><td> U+0016C </td><td> <span class="glyph">Ŭ</span> </td></tr><tr id="entity-ubreve"><td> <code>ubreve;</code> </td><td> U+0016D </td><td> <span class="glyph">ŭ</span> </td></tr><tr id="entity-Ucirc"><td> <code>Ucirc;</code> </td><td> U+000DB </td><td> <span class="glyph">Û</span> </td></tr><tr id="entity-Ucirc-legacy" class="impl"><td> <code>Ucirc</code> </td><td> U+000DB </td><td> <span>Û</span> </td></tr><tr id="entity-ucirc"><td> <code>ucirc;</code> </td><td> U+000FB </td><td> <span class="glyph">û</span> </td></tr><tr id="entity-ucirc-legacy" class="impl"><td> <code>ucirc</code> </td><td> U+000FB </td><td> <span>û</span> </td></tr><tr id="entity-Ucy"><td> <code>Ucy;</code> </td><td> U+00423 </td><td> <span class="glyph">У</span> </td></tr><tr id="entity-ucy"><td> <code>ucy;</code> </td><td> U+00443 </td><td> <span class="glyph">у</span> </td></tr><tr id="entity-udarr"><td> <code>udarr;</code> </td><td> U+021C5 </td><td> <span class="glyph">⇅</span> </td></tr><tr id="entity-Udblac"><td> <code>Udblac;</code> </td><td> U+00170 </td><td> <span class="glyph">Ű</span> </td></tr><tr id="entity-udblac"><td> <code>udblac;</code> </td><td> U+00171 </td><td> <span class="glyph">ű</span> </td></tr><tr id="entity-udhar"><td> <code>udhar;</code> </td><td> U+0296E </td><td> <span class="glyph">⥮</span> </td></tr><tr id="entity-ufisht"><td> <code>ufisht;</code> </td><td> U+0297E </td><td> <span class="glyph">⥾</span> </td></tr><tr id="entity-Ufr"><td> <code>Ufr;</code> </td><td> U+1D518 </td><td> <span class="glyph">𝔘</span> </td></tr><tr id="entity-ufr"><td> <code>ufr;</code> </td><td> U+1D532 </td><td> <span class="glyph">𝔲</span> </td></tr><tr id="entity-Ugrave"><td> <code>Ugrave;</code> </td><td> U+000D9 </td><td> <span class="glyph">Ù</span> </td></tr><tr id="entity-Ugrave-legacy" class="impl"><td> <code>Ugrave</code> </td><td> U+000D9 </td><td> <span>Ù</span> </td></tr><tr id="entity-ugrave"><td> <code>ugrave;</code> </td><td> U+000F9 </td><td> <span class="glyph">ù</span> </td></tr><tr id="entity-ugrave-legacy" class="impl"><td> <code>ugrave</code> </td><td> U+000F9 </td><td> <span>ù</span> </td></tr><tr id="entity-uHar"><td> <code>uHar;</code> </td><td> U+02963 </td><td> <span class="glyph">⥣</span> </td></tr><tr id="entity-uharl"><td> <code>uharl;</code> </td><td> U+021BF </td><td> <span class="glyph">↿</span> </td></tr><tr id="entity-uharr"><td> <code>uharr;</code> </td><td> U+021BE </td><td> <span class="glyph">↾</span> </td></tr><tr id="entity-uhblk"><td> <code>uhblk;</code> </td><td> U+02580 </td><td> <span class="glyph">▀</span> </td></tr><tr id="entity-ulcorn"><td> <code>ulcorn;</code> </td><td> U+0231C </td><td> <span class="glyph">⌜</span> </td></tr><tr id="entity-ulcorner"><td> <code>ulcorner;</code> </td><td> U+0231C </td><td> <span class="glyph">⌜</span> </td></tr><tr id="entity-ulcrop"><td> <code>ulcrop;</code> </td><td> U+0230F </td><td> <span class="glyph">⌏</span> </td></tr><tr id="entity-ultri"><td> <code>ultri;</code> </td><td> U+025F8 </td><td> <span class="glyph">◸</span> </td></tr><tr id="entity-Umacr"><td> <code>Umacr;</code> </td><td> U+0016A </td><td> <span class="glyph">Ū</span> </td></tr><tr id="entity-umacr"><td> <code>umacr;</code> </td><td> U+0016B </td><td> <span class="glyph">ū</span> </td></tr><tr id="entity-uml"><td> <code>uml;</code> </td><td> U+000A8 </td><td> <span class="glyph">¨</span> </td></tr><tr id="entity-uml-legacy" class="impl"><td> <code>uml</code> </td><td> U+000A8 </td><td> <span>¨</span> </td></tr><tr id="entity-UnderBar"><td> <code>UnderBar;</code> </td><td> U+0005F </td><td> <span class="glyph">_</span> </td></tr><tr id="entity-UnderBrace"><td> <code>UnderBrace;</code> </td><td> U+023DF </td><td> <span class="glyph">⏟</span> </td></tr><tr id="entity-UnderBracket"><td> <code>UnderBracket;</code> </td><td> U+023B5 </td><td> <span class="glyph">⎵</span> </td></tr><tr id="entity-UnderParenthesis"><td> <code>UnderParenthesis;</code> </td><td> U+023DD </td><td> <span class="glyph">⏝</span> </td></tr><tr id="entity-Union"><td> <code>Union;</code> </td><td> U+022C3 </td><td> <span class="glyph">⋃</span> </td></tr><tr id="entity-UnionPlus"><td> <code>UnionPlus;</code> </td><td> U+0228E </td><td> <span class="glyph">⊎</span> </td></tr><tr id="entity-Uogon"><td> <code>Uogon;</code> </td><td> U+00172 </td><td> <span class="glyph">Ų</span> </td></tr><tr id="entity-uogon"><td> <code>uogon;</code> </td><td> U+00173 </td><td> <span class="glyph">ų</span> </td></tr><tr id="entity-Uopf"><td> <code>Uopf;</code> </td><td> U+1D54C </td><td> <span class="glyph">𝕌</span> </td></tr><tr id="entity-uopf"><td> <code>uopf;</code> </td><td> U+1D566 </td><td> <span class="glyph">𝕦</span> </td></tr><tr id="entity-UpArrow"><td> <code>UpArrow;</code> </td><td> U+02191 </td><td> <span class="glyph">↑</span> </td></tr><tr id="entity-Uparrow"><td> <code>Uparrow;</code> </td><td> U+021D1 </td><td> <span class="glyph">⇑</span> </td></tr><tr id="entity-uparrow"><td> <code>uparrow;</code> </td><td> U+02191 </td><td> <span class="glyph">↑</span> </td></tr><tr id="entity-UpArrowBar"><td> <code>UpArrowBar;</code> </td><td> U+02912 </td><td> <span class="glyph">⤒</span> </td></tr><tr id="entity-UpArrowDownArrow"><td> <code>UpArrowDownArrow;</code> </td><td> U+021C5 </td><td> <span class="glyph">⇅</span> </td></tr><tr id="entity-UpDownArrow"><td> <code>UpDownArrow;</code> </td><td> U+02195 </td><td> <span class="glyph">↕</span> </td></tr><tr id="entity-Updownarrow"><td> <code>Updownarrow;</code> </td><td> U+021D5 </td><td> <span class="glyph">⇕</span> </td></tr><tr id="entity-updownarrow"><td> <code>updownarrow;</code> </td><td> U+02195 </td><td> <span class="glyph">↕</span> </td></tr><tr id="entity-UpEquilibrium"><td> <code>UpEquilibrium;</code> </td><td> U+0296E </td><td> <span class="glyph">⥮</span> </td></tr><tr id="entity-upharpoonleft"><td> <code>upharpoonleft;</code> </td><td> U+021BF </td><td> <span class="glyph">↿</span> </td></tr><tr id="entity-upharpoonright"><td> <code>upharpoonright;</code> </td><td> U+021BE </td><td> <span class="glyph">↾</span> </td></tr><tr id="entity-uplus"><td> <code>uplus;</code> </td><td> U+0228E </td><td> <span class="glyph">⊎</span> </td></tr><tr id="entity-UpperLeftArrow"><td> <code>UpperLeftArrow;</code> </td><td> U+02196 </td><td> <span class="glyph">↖</span> </td></tr><tr id="entity-UpperRightArrow"><td> <code>UpperRightArrow;</code> </td><td> U+02197 </td><td> <span class="glyph">↗</span> </td></tr><tr id="entity-Upsi"><td> <code>Upsi;</code> </td><td> U+003D2 </td><td> <span class="glyph">ϒ</span> </td></tr><tr id="entity-upsi"><td> <code>upsi;</code> </td><td> U+003C5 </td><td> <span class="glyph">υ</span> </td></tr><tr id="entity-upsih"><td> <code>upsih;</code> </td><td> U+003D2 </td><td> <span class="glyph">ϒ</span> </td></tr><tr id="entity-Upsilon"><td> <code>Upsilon;</code> </td><td> U+003A5 </td><td> <span class="glyph">Υ</span> </td></tr><tr id="entity-upsilon"><td> <code>upsilon;</code> </td><td> U+003C5 </td><td> <span class="glyph">υ</span> </td></tr><tr id="entity-UpTee"><td> <code>UpTee;</code> </td><td> U+022A5 </td><td> <span class="glyph">⊥</span> </td></tr><tr id="entity-UpTeeArrow"><td> <code>UpTeeArrow;</code> </td><td> U+021A5 </td><td> <span class="glyph">↥</span> </td></tr><tr id="entity-upuparrows"><td> <code>upuparrows;</code> </td><td> U+021C8 </td><td> <span class="glyph">⇈</span> </td></tr><tr id="entity-urcorn"><td> <code>urcorn;</code> </td><td> U+0231D </td><td> <span class="glyph">⌝</span> </td></tr><tr id="entity-urcorner"><td> <code>urcorner;</code> </td><td> U+0231D </td><td> <span class="glyph">⌝</span> </td></tr><tr id="entity-urcrop"><td> <code>urcrop;</code> </td><td> U+0230E </td><td> <span class="glyph">⌎</span> </td></tr><tr id="entity-Uring"><td> <code>Uring;</code> </td><td> U+0016E </td><td> <span class="glyph">Ů</span> </td></tr><tr id="entity-uring"><td> <code>uring;</code> </td><td> U+0016F </td><td> <span class="glyph">ů</span> </td></tr><tr id="entity-urtri"><td> <code>urtri;</code> </td><td> U+025F9 </td><td> <span class="glyph">◹</span> </td></tr><tr id="entity-Uscr"><td> <code>Uscr;</code> </td><td> U+1D4B0 </td><td> <span class="glyph">𝒰</span> </td></tr><tr id="entity-uscr"><td> <code>uscr;</code> </td><td> U+1D4CA </td><td> <span class="glyph">𝓊</span> </td></tr><tr id="entity-utdot"><td> <code>utdot;</code> </td><td> U+022F0 </td><td> <span class="glyph">⋰</span> </td></tr><tr id="entity-Utilde"><td> <code>Utilde;</code> </td><td> U+00168 </td><td> <span class="glyph">Ũ</span> </td></tr><tr id="entity-utilde"><td> <code>utilde;</code> </td><td> U+00169 </td><td> <span class="glyph">ũ</span> </td></tr><tr id="entity-utri"><td> <code>utri;</code> </td><td> U+025B5 </td><td> <span class="glyph">▵</span> </td></tr><tr id="entity-utrif"><td> <code>utrif;</code> </td><td> U+025B4 </td><td> <span class="glyph">▴</span> </td></tr><tr id="entity-uuarr"><td> <code>uuarr;</code> </td><td> U+021C8 </td><td> <span class="glyph">⇈</span> </td></tr><tr id="entity-Uuml"><td> <code>Uuml;</code> </td><td> U+000DC </td><td> <span class="glyph">Ü</span> </td></tr><tr id="entity-Uuml-legacy" class="impl"><td> <code>Uuml</code> </td><td> U+000DC </td><td> <span>Ü</span> </td></tr><tr id="entity-uuml"><td> <code>uuml;</code> </td><td> U+000FC </td><td> <span class="glyph">ü</span> </td></tr><tr id="entity-uuml-legacy" class="impl"><td> <code>uuml</code> </td><td> U+000FC </td><td> <span>ü</span> </td></tr><tr id="entity-uwangle"><td> <code>uwangle;</code> </td><td> U+029A7 </td><td> <span class="glyph">⦧</span> </td></tr><tr id="entity-vangrt"><td> <code>vangrt;</code> </td><td> U+0299C </td><td> <span class="glyph">⦜</span> </td></tr><tr id="entity-varepsilon"><td> <code>varepsilon;</code> </td><td> U+003F5 </td><td> <span class="glyph">ϵ</span> </td></tr><tr id="entity-varkappa"><td> <code>varkappa;</code> </td><td> U+003F0 </td><td> <span class="glyph">ϰ</span> </td></tr><tr id="entity-varnothing"><td> <code>varnothing;</code> </td><td> U+02205 </td><td> <span class="glyph">∅</span> </td></tr><tr id="entity-varphi"><td> <code>varphi;</code> </td><td> U+003D5 </td><td> <span class="glyph">ϕ</span> </td></tr><tr id="entity-varpi"><td> <code>varpi;</code> </td><td> U+003D6 </td><td> <span class="glyph">ϖ</span> </td></tr><tr id="entity-varpropto"><td> <code>varpropto;</code> </td><td> U+0221D </td><td> <span class="glyph">∝</span> </td></tr><tr id="entity-vArr"><td> <code>vArr;</code> </td><td> U+021D5 </td><td> <span class="glyph">⇕</span> </td></tr><tr id="entity-varr"><td> <code>varr;</code> </td><td> U+02195 </td><td> <span class="glyph">↕</span> </td></tr><tr id="entity-varrho"><td> <code>varrho;</code> </td><td> U+003F1 </td><td> <span class="glyph">ϱ</span> </td></tr><tr id="entity-varsigma"><td> <code>varsigma;</code> </td><td> U+003C2 </td><td> <span class="glyph">ς</span> </td></tr><tr id="entity-varsubsetneq"><td> <code>varsubsetneq;</code> </td><td> U+0228A U+0FE00 </td><td> <span class="glyph compound">⊊︀</span> </td></tr><tr id="entity-varsubsetneqq"><td> <code>varsubsetneqq;</code> </td><td> U+02ACB U+0FE00 </td><td> <span class="glyph compound">⫋︀</span> </td></tr><tr id="entity-varsupsetneq"><td> <code>varsupsetneq;</code> </td><td> U+0228B U+0FE00 </td><td> <span class="glyph compound">⊋︀</span> </td></tr><tr id="entity-varsupsetneqq"><td> <code>varsupsetneqq;</code> </td><td> U+02ACC U+0FE00 </td><td> <span class="glyph compound">⫌︀</span> </td></tr><tr id="entity-vartheta"><td> <code>vartheta;</code> </td><td> U+003D1 </td><td> <span class="glyph">ϑ</span> </td></tr><tr id="entity-vartriangleleft"><td> <code>vartriangleleft;</code> </td><td> U+022B2 </td><td> <span class="glyph">⊲</span> </td></tr><tr id="entity-vartriangleright"><td> <code>vartriangleright;</code> </td><td> U+022B3 </td><td> <span class="glyph">⊳</span> </td></tr><tr id="entity-Vbar"><td> <code>Vbar;</code> </td><td> U+02AEB </td><td> <span class="glyph">⫫</span> </td></tr><tr id="entity-vBar"><td> <code>vBar;</code> </td><td> U+02AE8 </td><td> <span class="glyph">⫨</span> </td></tr><tr id="entity-vBarv"><td> <code>vBarv;</code> </td><td> U+02AE9 </td><td> <span class="glyph">⫩</span> </td></tr><tr id="entity-Vcy"><td> <code>Vcy;</code> </td><td> U+00412 </td><td> <span class="glyph">В</span> </td></tr><tr id="entity-vcy"><td> <code>vcy;</code> </td><td> U+00432 </td><td> <span class="glyph">в</span> </td></tr><tr id="entity-VDash"><td> <code>VDash;</code> </td><td> U+022AB </td><td> <span class="glyph">⊫</span> </td></tr><tr id="entity-Vdash"><td> <code>Vdash;</code> </td><td> U+022A9 </td><td> <span class="glyph">⊩</span> </td></tr><tr id="entity-vDash"><td> <code>vDash;</code> </td><td> U+022A8 </td><td> <span class="glyph">⊨</span> </td></tr><tr id="entity-vdash"><td> <code>vdash;</code> </td><td> U+022A2 </td><td> <span class="glyph">⊢</span> </td></tr><tr id="entity-Vdashl"><td> <code>Vdashl;</code> </td><td> U+02AE6 </td><td> <span class="glyph">⫦</span> </td></tr><tr id="entity-Vee"><td> <code>Vee;</code> </td><td> U+022C1 </td><td> <span class="glyph">⋁</span> </td></tr><tr id="entity-vee"><td> <code>vee;</code> </td><td> U+02228 </td><td> <span class="glyph">∨</span> </td></tr><tr id="entity-veebar"><td> <code>veebar;</code> </td><td> U+022BB </td><td> <span class="glyph">⊻</span> </td></tr><tr id="entity-veeeq"><td> <code>veeeq;</code> </td><td> U+0225A </td><td> <span class="glyph">≚</span> </td></tr><tr id="entity-vellip"><td> <code>vellip;</code> </td><td> U+022EE </td><td> <span class="glyph">⋮</span> </td></tr><tr id="entity-Verbar"><td> <code>Verbar;</code> </td><td> U+02016 </td><td> <span class="glyph">‖</span> </td></tr><tr id="entity-verbar"><td> <code>verbar;</code> </td><td> U+0007C </td><td> <span class="glyph">|</span> </td></tr><tr id="entity-Vert"><td> <code>Vert;</code> </td><td> U+02016 </td><td> <span class="glyph">‖</span> </td></tr><tr id="entity-vert"><td> <code>vert;</code> </td><td> U+0007C </td><td> <span class="glyph">|</span> </td></tr><tr id="entity-VerticalBar"><td> <code>VerticalBar;</code> </td><td> U+02223 </td><td> <span class="glyph">∣</span> </td></tr><tr id="entity-VerticalLine"><td> <code>VerticalLine;</code> </td><td> U+0007C </td><td> <span class="glyph">|</span> </td></tr><tr id="entity-VerticalSeparator"><td> <code>VerticalSeparator;</code> </td><td> U+02758 </td><td> <span class="glyph">❘</span> </td></tr><tr id="entity-VerticalTilde"><td> <code>VerticalTilde;</code> </td><td> U+02240 </td><td> <span class="glyph">≀</span> </td></tr><tr id="entity-VeryThinSpace"><td> <code>VeryThinSpace;</code> </td><td> U+0200A </td><td> <span class="glyph"> </span> </td></tr><tr id="entity-Vfr"><td> <code>Vfr;</code> </td><td> U+1D519 </td><td> <span class="glyph">𝔙</span> </td></tr><tr id="entity-vfr"><td> <code>vfr;</code> </td><td> U+1D533 </td><td> <span class="glyph">𝔳</span> </td></tr><tr id="entity-vltri"><td> <code>vltri;</code> </td><td> U+022B2 </td><td> <span class="glyph">⊲</span> </td></tr><tr id="entity-vnsub"><td> <code>vnsub;</code> </td><td> U+02282 U+020D2 </td><td> <span class="glyph compound">⊂⃒</span> </td></tr><tr id="entity-vnsup"><td> <code>vnsup;</code> </td><td> U+02283 U+020D2 </td><td> <span class="glyph compound">⊃⃒</span> </td></tr><tr id="entity-Vopf"><td> <code>Vopf;</code> </td><td> U+1D54D </td><td> <span class="glyph">𝕍</span> </td></tr><tr id="entity-vopf"><td> <code>vopf;</code> </td><td> U+1D567 </td><td> <span class="glyph">𝕧</span> </td></tr><tr id="entity-vprop"><td> <code>vprop;</code> </td><td> U+0221D </td><td> <span class="glyph">∝</span> </td></tr><tr id="entity-vrtri"><td> <code>vrtri;</code> </td><td> U+022B3 </td><td> <span class="glyph">⊳</span> </td></tr><tr id="entity-Vscr"><td> <code>Vscr;</code> </td><td> U+1D4B1 </td><td> <span class="glyph">𝒱</span> </td></tr><tr id="entity-vscr"><td> <code>vscr;</code> </td><td> U+1D4CB </td><td> <span class="glyph">𝓋</span> </td></tr><tr id="entity-vsubnE"><td> <code>vsubnE;</code> </td><td> U+02ACB U+0FE00 </td><td> <span class="glyph compound">⫋︀</span> </td></tr><tr id="entity-vsubne"><td> <code>vsubne;</code> </td><td> U+0228A U+0FE00 </td><td> <span class="glyph compound">⊊︀</span> </td></tr><tr id="entity-vsupnE"><td> <code>vsupnE;</code> </td><td> U+02ACC U+0FE00 </td><td> <span class="glyph compound">⫌︀</span> </td></tr><tr id="entity-vsupne"><td> <code>vsupne;</code> </td><td> U+0228B U+0FE00 </td><td> <span class="glyph compound">⊋︀</span> </td></tr><tr id="entity-Vvdash"><td> <code>Vvdash;</code> </td><td> U+022AA </td><td> <span class="glyph">⊪</span> </td></tr><tr id="entity-vzigzag"><td> <code>vzigzag;</code> </td><td> U+0299A </td><td> <span class="glyph">⦚</span> </td></tr><tr id="entity-Wcirc"><td> <code>Wcirc;</code> </td><td> U+00174 </td><td> <span class="glyph">Ŵ</span> </td></tr><tr id="entity-wcirc"><td> <code>wcirc;</code> </td><td> U+00175 </td><td> <span class="glyph">ŵ</span> </td></tr><tr id="entity-wedbar"><td> <code>wedbar;</code> </td><td> U+02A5F </td><td> <span class="glyph">⩟</span> </td></tr><tr id="entity-Wedge"><td> <code>Wedge;</code> </td><td> U+022C0 </td><td> <span class="glyph">⋀</span> </td></tr><tr id="entity-wedge"><td> <code>wedge;</code> </td><td> U+02227 </td><td> <span class="glyph">∧</span> </td></tr><tr id="entity-wedgeq"><td> <code>wedgeq;</code> </td><td> U+02259 </td><td> <span class="glyph">≙</span> </td></tr><tr id="entity-weierp"><td> <code>weierp;</code> </td><td> U+02118 </td><td> <span class="glyph">℘</span> </td></tr><tr id="entity-Wfr"><td> <code>Wfr;</code> </td><td> U+1D51A </td><td> <span class="glyph">𝔚</span> </td></tr><tr id="entity-wfr"><td> <code>wfr;</code> </td><td> U+1D534 </td><td> <span class="glyph">𝔴</span> </td></tr><tr id="entity-Wopf"><td> <code>Wopf;</code> </td><td> U+1D54E </td><td> <span class="glyph">𝕎</span> </td></tr><tr id="entity-wopf"><td> <code>wopf;</code> </td><td> U+1D568 </td><td> <span class="glyph">𝕨</span> </td></tr><tr id="entity-wp"><td> <code>wp;</code> </td><td> U+02118 </td><td> <span class="glyph">℘</span> </td></tr><tr id="entity-wr"><td> <code>wr;</code> </td><td> U+02240 </td><td> <span class="glyph">≀</span> </td></tr><tr id="entity-wreath"><td> <code>wreath;</code> </td><td> U+02240 </td><td> <span class="glyph">≀</span> </td></tr><tr id="entity-Wscr"><td> <code>Wscr;</code> </td><td> U+1D4B2 </td><td> <span class="glyph">𝒲</span> </td></tr><tr id="entity-wscr"><td> <code>wscr;</code> </td><td> U+1D4CC </td><td> <span class="glyph">𝓌</span> </td></tr><tr id="entity-xcap"><td> <code>xcap;</code> </td><td> U+022C2 </td><td> <span class="glyph">⋂</span> </td></tr><tr id="entity-xcirc"><td> <code>xcirc;</code> </td><td> U+025EF </td><td> <span class="glyph">◯</span> </td></tr><tr id="entity-xcup"><td> <code>xcup;</code> </td><td> U+022C3 </td><td> <span class="glyph">⋃</span> </td></tr><tr id="entity-xdtri"><td> <code>xdtri;</code> </td><td> U+025BD </td><td> <span class="glyph">▽</span> </td></tr><tr id="entity-Xfr"><td> <code>Xfr;</code> </td><td> U+1D51B </td><td> <span class="glyph">𝔛</span> </td></tr><tr id="entity-xfr"><td> <code>xfr;</code> </td><td> U+1D535 </td><td> <span class="glyph">𝔵</span> </td></tr><tr id="entity-xhArr"><td> <code>xhArr;</code> </td><td> U+027FA </td><td> <span class="glyph">⟺</span> </td></tr><tr id="entity-xharr"><td> <code>xharr;</code> </td><td> U+027F7 </td><td> <span class="glyph">⟷</span> </td></tr><tr id="entity-Xi"><td> <code>Xi;</code> </td><td> U+0039E </td><td> <span class="glyph">Ξ</span> </td></tr><tr id="entity-xi"><td> <code>xi;</code> </td><td> U+003BE </td><td> <span class="glyph">ξ</span> </td></tr><tr id="entity-xlArr"><td> <code>xlArr;</code> </td><td> U+027F8 </td><td> <span class="glyph">⟸</span> </td></tr><tr id="entity-xlarr"><td> <code>xlarr;</code> </td><td> U+027F5 </td><td> <span class="glyph">⟵</span> </td></tr><tr id="entity-xmap"><td> <code>xmap;</code> </td><td> U+027FC </td><td> <span class="glyph">⟼</span> </td></tr><tr id="entity-xnis"><td> <code>xnis;</code> </td><td> U+022FB </td><td> <span class="glyph">⋻</span> </td></tr><tr id="entity-xodot"><td> <code>xodot;</code> </td><td> U+02A00 </td><td> <span class="glyph">⨀</span> </td></tr><tr id="entity-Xopf"><td> <code>Xopf;</code> </td><td> U+1D54F </td><td> <span class="glyph">𝕏</span> </td></tr><tr id="entity-xopf"><td> <code>xopf;</code> </td><td> U+1D569 </td><td> <span class="glyph">𝕩</span> </td></tr><tr id="entity-xoplus"><td> <code>xoplus;</code> </td><td> U+02A01 </td><td> <span class="glyph">⨁</span> </td></tr><tr id="entity-xotime"><td> <code>xotime;</code> </td><td> U+02A02 </td><td> <span class="glyph">⨂</span> </td></tr><tr id="entity-xrArr"><td> <code>xrArr;</code> </td><td> U+027F9 </td><td> <span class="glyph">⟹</span> </td></tr><tr id="entity-xrarr"><td> <code>xrarr;</code> </td><td> U+027F6 </td><td> <span class="glyph">⟶</span> </td></tr><tr id="entity-Xscr"><td> <code>Xscr;</code> </td><td> U+1D4B3 </td><td> <span class="glyph">𝒳</span> </td></tr><tr id="entity-xscr"><td> <code>xscr;</code> </td><td> U+1D4CD </td><td> <span class="glyph">𝓍</span> </td></tr><tr id="entity-xsqcup"><td> <code>xsqcup;</code> </td><td> U+02A06 </td><td> <span class="glyph">⨆</span> </td></tr><tr id="entity-xuplus"><td> <code>xuplus;</code> </td><td> U+02A04 </td><td> <span class="glyph">⨄</span> </td></tr><tr id="entity-xutri"><td> <code>xutri;</code> </td><td> U+025B3 </td><td> <span class="glyph">△</span> </td></tr><tr id="entity-xvee"><td> <code>xvee;</code> </td><td> U+022C1 </td><td> <span class="glyph">⋁</span> </td></tr><tr id="entity-xwedge"><td> <code>xwedge;</code> </td><td> U+022C0 </td><td> <span class="glyph">⋀</span> </td></tr><tr id="entity-Yacute"><td> <code>Yacute;</code> </td><td> U+000DD </td><td> <span class="glyph">Ý</span> </td></tr><tr id="entity-Yacute-legacy" class="impl"><td> <code>Yacute</code> </td><td> U+000DD </td><td> <span>Ý</span> </td></tr><tr id="entity-yacute"><td> <code>yacute;</code> </td><td> U+000FD </td><td> <span class="glyph">ý</span> </td></tr><tr id="entity-yacute-legacy" class="impl"><td> <code>yacute</code> </td><td> U+000FD </td><td> <span>ý</span> </td></tr><tr id="entity-YAcy"><td> <code>YAcy;</code> </td><td> U+0042F </td><td> <span class="glyph">Я</span> </td></tr><tr id="entity-yacy"><td> <code>yacy;</code> </td><td> U+0044F </td><td> <span class="glyph">я</span> </td></tr><tr id="entity-Ycirc"><td> <code>Ycirc;</code> </td><td> U+00176 </td><td> <span class="glyph">Ŷ</span> </td></tr><tr id="entity-ycirc"><td> <code>ycirc;</code> </td><td> U+00177 </td><td> <span class="glyph">ŷ</span> </td></tr><tr id="entity-Ycy"><td> <code>Ycy;</code> </td><td> U+0042B </td><td> <span class="glyph">Ы</span> </td></tr><tr id="entity-ycy"><td> <code>ycy;</code> </td><td> U+0044B </td><td> <span class="glyph">ы</span> </td></tr><tr id="entity-yen"><td> <code>yen;</code> </td><td> U+000A5 </td><td> <span class="glyph">¥</span> </td></tr><tr id="entity-yen-legacy" class="impl"><td> <code>yen</code> </td><td> U+000A5 </td><td> <span>¥</span> </td></tr><tr id="entity-Yfr"><td> <code>Yfr;</code> </td><td> U+1D51C </td><td> <span class="glyph">𝔜</span> </td></tr><tr id="entity-yfr"><td> <code>yfr;</code> </td><td> U+1D536 </td><td> <span class="glyph">𝔶</span> </td></tr><tr id="entity-YIcy"><td> <code>YIcy;</code> </td><td> U+00407 </td><td> <span class="glyph">Ї</span> </td></tr><tr id="entity-yicy"><td> <code>yicy;</code> </td><td> U+00457 </td><td> <span class="glyph">ї</span> </td></tr><tr id="entity-Yopf"><td> <code>Yopf;</code> </td><td> U+1D550 </td><td> <span class="glyph">𝕐</span> </td></tr><tr id="entity-yopf"><td> <code>yopf;</code> </td><td> U+1D56A </td><td> <span class="glyph">𝕪</span> </td></tr><tr id="entity-Yscr"><td> <code>Yscr;</code> </td><td> U+1D4B4 </td><td> <span class="glyph">𝒴</span> </td></tr><tr id="entity-yscr"><td> <code>yscr;</code> </td><td> U+1D4CE </td><td> <span class="glyph">𝓎</span> </td></tr><tr id="entity-YUcy"><td> <code>YUcy;</code> </td><td> U+0042E </td><td> <span class="glyph">Ю</span> </td></tr><tr id="entity-yucy"><td> <code>yucy;</code> </td><td> U+0044E </td><td> <span class="glyph">ю</span> </td></tr><tr id="entity-Yuml"><td> <code>Yuml;</code> </td><td> U+00178 </td><td> <span class="glyph">Ÿ</span> </td></tr><tr id="entity-yuml"><td> <code>yuml;</code> </td><td> U+000FF </td><td> <span class="glyph">ÿ</span> </td></tr><tr id="entity-yuml-legacy" class="impl"><td> <code>yuml</code> </td><td> U+000FF </td><td> <span>ÿ</span> </td></tr><tr id="entity-Zacute"><td> <code>Zacute;</code> </td><td> U+00179 </td><td> <span class="glyph">Ź</span> </td></tr><tr id="entity-zacute"><td> <code>zacute;</code> </td><td> U+0017A </td><td> <span class="glyph">ź</span> </td></tr><tr id="entity-Zcaron"><td> <code>Zcaron;</code> </td><td> U+0017D </td><td> <span class="glyph">Ž</span> </td></tr><tr id="entity-zcaron"><td> <code>zcaron;</code> </td><td> U+0017E </td><td> <span class="glyph">ž</span> </td></tr><tr id="entity-Zcy"><td> <code>Zcy;</code> </td><td> U+00417 </td><td> <span class="glyph">З</span> </td></tr><tr id="entity-zcy"><td> <code>zcy;</code> </td><td> U+00437 </td><td> <span class="glyph">з</span> </td></tr><tr id="entity-Zdot"><td> <code>Zdot;</code> </td><td> U+0017B </td><td> <span class="glyph">Ż</span> </td></tr><tr id="entity-zdot"><td> <code>zdot;</code> </td><td> U+0017C </td><td> <span class="glyph">ż</span> </td></tr><tr id="entity-zeetrf"><td> <code>zeetrf;</code> </td><td> U+02128 </td><td> <span class="glyph">ℨ</span> </td></tr><tr id="entity-ZeroWidthSpace"><td> <code>ZeroWidthSpace;</code> </td><td> U+0200B </td><td> <span class="glyph">​</span> </td></tr><tr id="entity-Zeta"><td> <code>Zeta;</code> </td><td> U+00396 </td><td> <span class="glyph">Ζ</span> </td></tr><tr id="entity-zeta"><td> <code>zeta;</code> </td><td> U+003B6 </td><td> <span class="glyph">ζ</span> </td></tr><tr id="entity-Zfr"><td> <code>Zfr;</code> </td><td> U+02128 </td><td> <span class="glyph">ℨ</span> </td></tr><tr id="entity-zfr"><td> <code>zfr;</code> </td><td> U+1D537 </td><td> <span class="glyph">𝔷</span> </td></tr><tr id="entity-ZHcy"><td> <code>ZHcy;</code> </td><td> U+00416 </td><td> <span class="glyph">Ж</span> </td></tr><tr id="entity-zhcy"><td> <code>zhcy;</code> </td><td> U+00436 </td><td> <span class="glyph">ж</span> </td></tr><tr id="entity-zigrarr"><td> <code>zigrarr;</code> </td><td> U+021DD </td><td> <span class="glyph">⇝</span> </td></tr><tr id="entity-Zopf"><td> <code>Zopf;</code> </td><td> U+02124 </td><td> <span class="glyph">ℤ</span> </td></tr><tr id="entity-zopf"><td> <code>zopf;</code> </td><td> U+1D56B </td><td> <span class="glyph">𝕫</span> </td></tr><tr id="entity-Zscr"><td> <code>Zscr;</code> </td><td> U+1D4B5 </td><td> <span class="glyph">𝒵</span> </td></tr><tr id="entity-zscr"><td> <code>zscr;</code> </td><td> U+1D4CF </td><td> <span class="glyph">𝓏</span> </td></tr><tr id="entity-zwj"><td> <code>zwj;</code> </td><td> U+0200D </td><td> <span class="glyph">‍</span> </td></tr><tr id="entity-zwnj"><td> <code>zwnj;</code> </td><td> U+0200C </td><td> <span class="glyph">‌</span> </td></tr></tbody></table>
  
  </div>

  <p>This data is also available <a href="/entities.json">as a JSON file</a>.</p>

  <p><i>The glyphs displayed above are non-normative. Refer to Unicode for formal definitions of the
  characters listed above.</i></p>

  <p class="note">The character reference names originate from <cite>XML Entity Definitions for
  Characters</cite>, though only the above is considered normative. <a href="#refsXMLENTITY">[XMLENTITY]</a></p>

  <p class="note">This list is static and <a href="https://github.com/whatwg/html/blob/main/FAQ.md#html-should-add-more-named-character-references">will
  not be expanded or changed in the future</a>.</p>


  <h2 id="the-xhtml-syntax"><span class="secno">14</span> <dfn id="xhtml">The XML syntax</dfn><a href="#the-xhtml-syntax" class="self-link"></a></h2><div class="mdn-anno wrapped"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/XHTML" title="XHTML is a term that was historically used to describe HTML documents written to conform with XML syntax rules.">HTML/XHTML</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>2+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>2+</span></span><span class="chrome_android yes"><span>Chrome Android</span><span>18+</span></span><span class="webview_android yes"><span>WebView Android</span><span>2+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>1.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div>

  <p class="note">This section only describes the rules for XML resources. Rules for
  <code id="the-xhtml-syntax:text/html"><a href="#text/html">text/html</a></code> resources are discussed in the section above entitled "<a href="#syntax" id="the-xhtml-syntax:syntax">The HTML
  syntax</a>".</p>

  <p id="xml-syntax-not-recommended" class="warning">Using the XML syntax is not recommended, for
  reasons which include the fact that there is no specification which defines the rules for how an
  XML parser must map a string of bytes or characters into a <code id="the-xhtml-syntax:document"><a href="#document">Document</a></code> object, as well
  as the fact that the XML syntax is essentially unmaintained — in that, it’s not expected that any
  further features will ever be added to the XML syntax (even when such features have been added to
  the <a href="#syntax" id="the-xhtml-syntax:syntax-2">HTML syntax</a>).</p>

  

  <h3 id="writing-xhtml-documents"><span class="secno">14.1</span> Writing documents in the XML syntax<a href="#writing-xhtml-documents" class="self-link"></a></h3>

  

  <p class="note">The XML syntax for HTML was formerly referred to as "XHTML", but this
  specification does not use that term (among other reasons, because no such term is used for the
  HTML syntaxes of MathML and SVG).</p>

  <p>The syntax for XML is defined in <cite>XML</cite> and <cite>Namespaces in XML</cite>. <a href="#refsXML">[XML]</a>
  <a href="#refsXMLNS">[XMLNS]</a></p>

  <p>This specification does not define any syntax-level requirements beyond those defined for XML
  proper.</p>

  <p>XML documents may contain a <code>DOCTYPE</code> if desired, but this is not required
  to conform to this specification. This specification does not define a public or system
  identifier, nor provide a formal DTD.</p>

  <p class="note">According to <cite>XML</cite>, XML processors are not guaranteed to process
  the external DTD subset referenced in the DOCTYPE. This means, for example, that using <a href="https://www.w3.org/TR/xml/#dt-entref">entity references</a> for characters in XML documents
  is unsafe if they are defined in an external file (except for <code>&amp;lt;</code>,
  <code>&amp;gt;</code>, <code>&amp;amp;</code>,
  <code>&amp;quot;</code>, and <code>&amp;apos;</code>).</p>


  

  <h3 id="parsing-xhtml-documents"><span class="secno">14.2</span> Parsing XML documents<a href="#parsing-xhtml-documents" class="self-link"></a></h3>

  <p>This section describes the relationship between XML and the DOM, with a particular emphasis on
  how this interacts with HTML.</p>

  <p>An <dfn id="xml-parser" data-export="">XML parser</dfn>, for the purposes of this specification, is a construct that
  follows the rules given in <cite>XML</cite> to map a string of bytes or characters into a
  <code id="parsing-xhtml-documents:document"><a href="#document">Document</a></code> object.</p>

  <p class="note">At the time of writing, no such rules actually exist.</p>

  <p>An <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser">XML parser</a> is either associated with a <code id="parsing-xhtml-documents:document-2"><a href="#document">Document</a></code> object when it is
  created, or creates one implicitly.</p>

  <p>This <code id="parsing-xhtml-documents:document-3"><a href="#document">Document</a></code> must then be populated with DOM nodes that represent the tree
  structure of the input passed to the parser, as defined by <cite>XML</cite>, <cite>Namespaces
  in XML</cite>, and <cite>DOM</cite>. When creating DOM nodes representing elements,
  the <a href="#create-an-element-for-the-token" id="parsing-xhtml-documents:create-an-element-for-the-token">create an element for a token</a> algorithm
  or some equivalent that operates on appropriate XML data structures must be used, to ensure the
  proper <a href="https://dom.spec.whatwg.org/#concept-element-interface" id="parsing-xhtml-documents:element-interface" data-x-internal="element-interface">element interfaces</a> are created and that <a href="#custom-element" id="parsing-xhtml-documents:custom-element">custom elements</a> are set up correctly.</p>

  <p>For the operations that the <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-2">XML parser</a> performs on the <code id="parsing-xhtml-documents:document-4"><a href="#document">Document</a></code>'s
  tree, the user agent must act as if elements and attributes were individually appended and set
  respectively so as to trigger rules in this specification regarding what happens when an element
  is inserted into a document or has its attributes set, and <cite>DOM</cite>'s requirements
  regarding <a id="parsing-xhtml-documents:mutation-observers" href="https://dom.spec.whatwg.org/#mutation-observers" data-x-internal="mutation-observers">mutation observers</a> mean that mutation observers <em>are</em> fired.
  <a href="#refsXML">[XML]</a> <a href="#refsXMLNS">[XMLNS]</a> <a href="#refsDOM">[DOM]</a> <a href="#refsUIEVENTS">[UIEVENTS]</a></p>

  <p>Between the time an element's start tag is parsed and the time either the element's end tag is
  parsed or the parser detects a well-formedness error, the user agent must act as if the element
  was in a <a href="#stack-of-open-elements" id="parsing-xhtml-documents:stack-of-open-elements">stack of open elements</a>.</p>

  <p class="note">This is used by various elements to only start certain processes once they are
  popped off of the <a href="#stack-of-open-elements" id="parsing-xhtml-documents:stack-of-open-elements-2">stack of open elements</a>.</p>

  <p>This specification provides the following additional information that user agents should use
  when retrieving an external entity: the public identifiers given in the following list all
  correspond to <a href="data:application/xml-dtd;base64,PCFFTlRJVFkgVGFiICImI3g5OyI%2BPCFFTlRJVFkgTmV3TGluZSAiJiN4QTsiPjwhRU5USVRZIGV4Y2wgIiYjeDIxOyI%2BPCFFTlRJVFkgcXVvdCAiJiN4MjI7Ij48IUVOVElUWSBRVU9UICImI3gyMjsiPjwhRU5USVRZIG51bSAiJiN4MjM7Ij48IUVOVElUWSBkb2xsYXIgIiYjeDI0OyI%2BPCFFTlRJVFkgcGVyY250ICImI3gyNTsiPjwhRU5USVRZIGFtcCAiJiN4MjY7I3gyNjsiPjwhRU5USVRZIEFNUCAiJiN4MjY7I3gyNjsiPjwhRU5USVRZIGFwb3MgIiYjeDI3OyI%2BPCFFTlRJVFkgbHBhciAiJiN4Mjg7Ij48IUVOVElUWSBycGFyICImI3gyOTsiPjwhRU5USVRZIGFzdCAiJiN4MkE7Ij48IUVOVElUWSBtaWRhc3QgIiYjeDJBOyI%2BPCFFTlRJVFkgcGx1cyAiJiN4MkI7Ij48IUVOVElUWSBjb21tYSAiJiN4MkM7Ij48IUVOVElUWSBwZXJpb2QgIiYjeDJFOyI%2BPCFFTlRJVFkgc29sICImI3gyRjsiPjwhRU5USVRZIGNvbG9uICImI3gzQTsiPjwhRU5USVRZIHNlbWkgIiYjeDNCOyI%2BPCFFTlRJVFkgbHQgIiYjeDI2OyN4M0M7Ij48IUVOVElUWSBMVCAiJiN4MjY7I3gzQzsiPjwhRU5USVRZIG52bHQgIiYjeDI2OyN4M0M7JiN4MjBEMjsiPjwhRU5USVRZIGVxdWFscyAiJiN4M0Q7Ij48IUVOVElUWSBibmUgIiYjeDNEOyYjeDIwRTU7Ij48IUVOVElUWSBndCAiJiN4M0U7Ij48IUVOVElUWSBHVCAiJiN4M0U7Ij48IUVOVElUWSBudmd0ICImI3gzRTsmI3gyMEQyOyI%2BPCFFTlRJVFkgcXVlc3QgIiYjeDNGOyI%2BPCFFTlRJVFkgY29tbWF0ICImI3g0MDsiPjwhRU5USVRZIGxzcWIgIiYjeDVCOyI%2BPCFFTlRJVFkgbGJyYWNrICImI3g1QjsiPjwhRU5USVRZIGJzb2wgIiYjeDVDOyI%2BPCFFTlRJVFkgcnNxYiAiJiN4NUQ7Ij48IUVOVElUWSByYnJhY2sgIiYjeDVEOyI%2BPCFFTlRJVFkgSGF0ICImI3g1RTsiPjwhRU5USVRZIGxvd2JhciAiJiN4NUY7Ij48IUVOVElUWSBVbmRlckJhciAiJiN4NUY7Ij48IUVOVElUWSBncmF2ZSAiJiN4NjA7Ij48IUVOVElUWSBEaWFjcml0aWNhbEdyYXZlICImI3g2MDsiPjwhRU5USVRZIGZqbGlnICImI3g2NjsmI3g2QTsiPjwhRU5USVRZIGxjdWIgIiYjeDdCOyI%2BPCFFTlRJVFkgbGJyYWNlICImI3g3QjsiPjwhRU5USVRZIHZlcmJhciAiJiN4N0M7Ij48IUVOVElUWSB2ZXJ0ICImI3g3QzsiPjwhRU5USVRZIFZlcnRpY2FsTGluZSAiJiN4N0M7Ij48IUVOVElUWSByY3ViICImI3g3RDsiPjwhRU5USVRZIHJicmFjZSAiJiN4N0Q7Ij48IUVOVElUWSBuYnNwICImI3hBMDsiPjwhRU5USVRZIE5vbkJyZWFraW5nU3BhY2UgIiYjeEEwOyI%2BPCFFTlRJVFkgaWV4Y2wgIiYjeEExOyI%2BPCFFTlRJVFkgY2VudCAiJiN4QTI7Ij48IUVOVElUWSBwb3VuZCAiJiN4QTM7Ij48IUVOVElUWSBjdXJyZW4gIiYjeEE0OyI%2BPCFFTlRJVFkgeWVuICImI3hBNTsiPjwhRU5USVRZIGJydmJhciAiJiN4QTY7Ij48IUVOVElUWSBzZWN0ICImI3hBNzsiPjwhRU5USVRZIERvdCAiJiN4QTg7Ij48IUVOVElUWSBkaWUgIiYjeEE4OyI%2BPCFFTlRJVFkgRG91YmxlRG90ICImI3hBODsiPjwhRU5USVRZIHVtbCAiJiN4QTg7Ij48IUVOVElUWSBjb3B5ICImI3hBOTsiPjwhRU5USVRZIENPUFkgIiYjeEE5OyI%2BPCFFTlRJVFkgb3JkZiAiJiN4QUE7Ij48IUVOVElUWSBsYXF1byAiJiN4QUI7Ij48IUVOVElUWSBub3QgIiYjeEFDOyI%2BPCFFTlRJVFkgc2h5ICImI3hBRDsiPjwhRU5USVRZIHJlZyAiJiN4QUU7Ij48IUVOVElUWSBjaXJjbGVkUiAiJiN4QUU7Ij48IUVOVElUWSBSRUcgIiYjeEFFOyI%2BPCFFTlRJVFkgbWFjciAiJiN4QUY7Ij48IUVOVElUWSBzdHJucyAiJiN4QUY7Ij48IUVOVElUWSBkZWcgIiYjeEIwOyI%2BPCFFTlRJVFkgcGx1c21uICImI3hCMTsiPjwhRU5USVRZIHBtICImI3hCMTsiPjwhRU5USVRZIFBsdXNNaW51cyAiJiN4QjE7Ij48IUVOVElUWSBzdXAyICImI3hCMjsiPjwhRU5USVRZIHN1cDMgIiYjeEIzOyI%2BPCFFTlRJVFkgYWN1dGUgIiYjeEI0OyI%2BPCFFTlRJVFkgRGlhY3JpdGljYWxBY3V0ZSAiJiN4QjQ7Ij48IUVOVElUWSBtaWNybyAiJiN4QjU7Ij48IUVOVElUWSBwYXJhICImI3hCNjsiPjwhRU5USVRZIG1pZGRvdCAiJiN4Qjc7Ij48IUVOVElUWSBjZW50ZXJkb3QgIiYjeEI3OyI%2BPCFFTlRJVFkgQ2VudGVyRG90ICImI3hCNzsiPjwhRU5USVRZIGNlZGlsICImI3hCODsiPjwhRU5USVRZIENlZGlsbGEgIiYjeEI4OyI%2BPCFFTlRJVFkgc3VwMSAiJiN4Qjk7Ij48IUVOVElUWSBvcmRtICImI3hCQTsiPjwhRU5USVRZIHJhcXVvICImI3hCQjsiPjwhRU5USVRZIGZyYWMxNCAiJiN4QkM7Ij48IUVOVElUWSBmcmFjMTIgIiYjeEJEOyI%2BPCFFTlRJVFkgaGFsZiAiJiN4QkQ7Ij48IUVOVElUWSBmcmFjMzQgIiYjeEJFOyI%2BPCFFTlRJVFkgaXF1ZXN0ICImI3hCRjsiPjwhRU5USVRZIEFncmF2ZSAiJiN4QzA7Ij48IUVOVElUWSBBYWN1dGUgIiYjeEMxOyI%2BPCFFTlRJVFkgQWNpcmMgIiYjeEMyOyI%2BPCFFTlRJVFkgQXRpbGRlICImI3hDMzsiPjwhRU5USVRZIEF1bWwgIiYjeEM0OyI%2BPCFFTlRJVFkgQXJpbmcgIiYjeEM1OyI%2BPCFFTlRJVFkgYW5nc3QgIiYjeEM1OyI%2BPCFFTlRJVFkgQUVsaWcgIiYjeEM2OyI%2BPCFFTlRJVFkgQ2NlZGlsICImI3hDNzsiPjwhRU5USVRZIEVncmF2ZSAiJiN4Qzg7Ij48IUVOVElUWSBFYWN1dGUgIiYjeEM5OyI%2BPCFFTlRJVFkgRWNpcmMgIiYjeENBOyI%2BPCFFTlRJVFkgRXVtbCAiJiN4Q0I7Ij48IUVOVElUWSBJZ3JhdmUgIiYjeENDOyI%2BPCFFTlRJVFkgSWFjdXRlICImI3hDRDsiPjwhRU5USVRZIEljaXJjICImI3hDRTsiPjwhRU5USVRZIEl1bWwgIiYjeENGOyI%2BPCFFTlRJVFkgRVRIICImI3hEMDsiPjwhRU5USVRZIE50aWxkZSAiJiN4RDE7Ij48IUVOVElUWSBPZ3JhdmUgIiYjeEQyOyI%2BPCFFTlRJVFkgT2FjdXRlICImI3hEMzsiPjwhRU5USVRZIE9jaXJjICImI3hENDsiPjwhRU5USVRZIE90aWxkZSAiJiN4RDU7Ij48IUVOVElUWSBPdW1sICImI3hENjsiPjwhRU5USVRZIHRpbWVzICImI3hENzsiPjwhRU5USVRZIE9zbGFzaCAiJiN4RDg7Ij48IUVOVElUWSBVZ3JhdmUgIiYjeEQ5OyI%2BPCFFTlRJVFkgVWFjdXRlICImI3hEQTsiPjwhRU5USVRZIFVjaXJjICImI3hEQjsiPjwhRU5USVRZIFV1bWwgIiYjeERDOyI%2BPCFFTlRJVFkgWWFjdXRlICImI3hERDsiPjwhRU5USVRZIFRIT1JOICImI3hERTsiPjwhRU5USVRZIHN6bGlnICImI3hERjsiPjwhRU5USVRZIGFncmF2ZSAiJiN4RTA7Ij48IUVOVElUWSBhYWN1dGUgIiYjeEUxOyI%2BPCFFTlRJVFkgYWNpcmMgIiYjeEUyOyI%2BPCFFTlRJVFkgYXRpbGRlICImI3hFMzsiPjwhRU5USVRZIGF1bWwgIiYjeEU0OyI%2BPCFFTlRJVFkgYXJpbmcgIiYjeEU1OyI%2BPCFFTlRJVFkgYWVsaWcgIiYjeEU2OyI%2BPCFFTlRJVFkgY2NlZGlsICImI3hFNzsiPjwhRU5USVRZIGVncmF2ZSAiJiN4RTg7Ij48IUVOVElUWSBlYWN1dGUgIiYjeEU5OyI%2BPCFFTlRJVFkgZWNpcmMgIiYjeEVBOyI%2BPCFFTlRJVFkgZXVtbCAiJiN4RUI7Ij48IUVOVElUWSBpZ3JhdmUgIiYjeEVDOyI%2BPCFFTlRJVFkgaWFjdXRlICImI3hFRDsiPjwhRU5USVRZIGljaXJjICImI3hFRTsiPjwhRU5USVRZIGl1bWwgIiYjeEVGOyI%2BPCFFTlRJVFkgZXRoICImI3hGMDsiPjwhRU5USVRZIG50aWxkZSAiJiN4RjE7Ij48IUVOVElUWSBvZ3JhdmUgIiYjeEYyOyI%2BPCFFTlRJVFkgb2FjdXRlICImI3hGMzsiPjwhRU5USVRZIG9jaXJjICImI3hGNDsiPjwhRU5USVRZIG90aWxkZSAiJiN4RjU7Ij48IUVOVElUWSBvdW1sICImI3hGNjsiPjwhRU5USVRZIGRpdmlkZSAiJiN4Rjc7Ij48IUVOVElUWSBkaXYgIiYjeEY3OyI%2BPCFFTlRJVFkgb3NsYXNoICImI3hGODsiPjwhRU5USVRZIHVncmF2ZSAiJiN4Rjk7Ij48IUVOVElUWSB1YWN1dGUgIiYjeEZBOyI%2BPCFFTlRJVFkgdWNpcmMgIiYjeEZCOyI%2BPCFFTlRJVFkgdXVtbCAiJiN4RkM7Ij48IUVOVElUWSB5YWN1dGUgIiYjeEZEOyI%2BPCFFTlRJVFkgdGhvcm4gIiYjeEZFOyI%2BPCFFTlRJVFkgeXVtbCAiJiN4RkY7Ij48IUVOVElUWSBBbWFjciAiJiN4MTAwOyI%2BPCFFTlRJVFkgYW1hY3IgIiYjeDEwMTsiPjwhRU5USVRZIEFicmV2ZSAiJiN4MTAyOyI%2BPCFFTlRJVFkgYWJyZXZlICImI3gxMDM7Ij48IUVOVElUWSBBb2dvbiAiJiN4MTA0OyI%2BPCFFTlRJVFkgYW9nb24gIiYjeDEwNTsiPjwhRU5USVRZIENhY3V0ZSAiJiN4MTA2OyI%2BPCFFTlRJVFkgY2FjdXRlICImI3gxMDc7Ij48IUVOVElUWSBDY2lyYyAiJiN4MTA4OyI%2BPCFFTlRJVFkgY2NpcmMgIiYjeDEwOTsiPjwhRU5USVRZIENkb3QgIiYjeDEwQTsiPjwhRU5USVRZIGNkb3QgIiYjeDEwQjsiPjwhRU5USVRZIENjYXJvbiAiJiN4MTBDOyI%2BPCFFTlRJVFkgY2Nhcm9uICImI3gxMEQ7Ij48IUVOVElUWSBEY2Fyb24gIiYjeDEwRTsiPjwhRU5USVRZIGRjYXJvbiAiJiN4MTBGOyI%2BPCFFTlRJVFkgRHN0cm9rICImI3gxMTA7Ij48IUVOVElUWSBkc3Ryb2sgIiYjeDExMTsiPjwhRU5USVRZIEVtYWNyICImI3gxMTI7Ij48IUVOVElUWSBlbWFjciAiJiN4MTEzOyI%2BPCFFTlRJVFkgRWRvdCAiJiN4MTE2OyI%2BPCFFTlRJVFkgZWRvdCAiJiN4MTE3OyI%2BPCFFTlRJVFkgRW9nb24gIiYjeDExODsiPjwhRU5USVRZIGVvZ29uICImI3gxMTk7Ij48IUVOVElUWSBFY2Fyb24gIiYjeDExQTsiPjwhRU5USVRZIGVjYXJvbiAiJiN4MTFCOyI%2BPCFFTlRJVFkgR2NpcmMgIiYjeDExQzsiPjwhRU5USVRZIGdjaXJjICImI3gxMUQ7Ij48IUVOVElUWSBHYnJldmUgIiYjeDExRTsiPjwhRU5USVRZIGdicmV2ZSAiJiN4MTFGOyI%2BPCFFTlRJVFkgR2RvdCAiJiN4MTIwOyI%2BPCFFTlRJVFkgZ2RvdCAiJiN4MTIxOyI%2BPCFFTlRJVFkgR2NlZGlsICImI3gxMjI7Ij48IUVOVElUWSBIY2lyYyAiJiN4MTI0OyI%2BPCFFTlRJVFkgaGNpcmMgIiYjeDEyNTsiPjwhRU5USVRZIEhzdHJvayAiJiN4MTI2OyI%2BPCFFTlRJVFkgaHN0cm9rICImI3gxMjc7Ij48IUVOVElUWSBJdGlsZGUgIiYjeDEyODsiPjwhRU5USVRZIGl0aWxkZSAiJiN4MTI5OyI%2BPCFFTlRJVFkgSW1hY3IgIiYjeDEyQTsiPjwhRU5USVRZIGltYWNyICImI3gxMkI7Ij48IUVOVElUWSBJb2dvbiAiJiN4MTJFOyI%2BPCFFTlRJVFkgaW9nb24gIiYjeDEyRjsiPjwhRU5USVRZIElkb3QgIiYjeDEzMDsiPjwhRU5USVRZIGltYXRoICImI3gxMzE7Ij48IUVOVElUWSBpbm9kb3QgIiYjeDEzMTsiPjwhRU5USVRZIElKbGlnICImI3gxMzI7Ij48IUVOVElUWSBpamxpZyAiJiN4MTMzOyI%2BPCFFTlRJVFkgSmNpcmMgIiYjeDEzNDsiPjwhRU5USVRZIGpjaXJjICImI3gxMzU7Ij48IUVOVElUWSBLY2VkaWwgIiYjeDEzNjsiPjwhRU5USVRZIGtjZWRpbCAiJiN4MTM3OyI%2BPCFFTlRJVFkga2dyZWVuICImI3gxMzg7Ij48IUVOVElUWSBMYWN1dGUgIiYjeDEzOTsiPjwhRU5USVRZIGxhY3V0ZSAiJiN4MTNBOyI%2BPCFFTlRJVFkgTGNlZGlsICImI3gxM0I7Ij48IUVOVElUWSBsY2VkaWwgIiYjeDEzQzsiPjwhRU5USVRZIExjYXJvbiAiJiN4MTNEOyI%2BPCFFTlRJVFkgbGNhcm9uICImI3gxM0U7Ij48IUVOVElUWSBMbWlkb3QgIiYjeDEzRjsiPjwhRU5USVRZIGxtaWRvdCAiJiN4MTQwOyI%2BPCFFTlRJVFkgTHN0cm9rICImI3gxNDE7Ij48IUVOVElUWSBsc3Ryb2sgIiYjeDE0MjsiPjwhRU5USVRZIE5hY3V0ZSAiJiN4MTQzOyI%2BPCFFTlRJVFkgbmFjdXRlICImI3gxNDQ7Ij48IUVOVElUWSBOY2VkaWwgIiYjeDE0NTsiPjwhRU5USVRZIG5jZWRpbCAiJiN4MTQ2OyI%2BPCFFTlRJVFkgTmNhcm9uICImI3gxNDc7Ij48IUVOVElUWSBuY2Fyb24gIiYjeDE0ODsiPjwhRU5USVRZIG5hcG9zICImI3gxNDk7Ij48IUVOVElUWSBFTkcgIiYjeDE0QTsiPjwhRU5USVRZIGVuZyAiJiN4MTRCOyI%2BPCFFTlRJVFkgT21hY3IgIiYjeDE0QzsiPjwhRU5USVRZIG9tYWNyICImI3gxNEQ7Ij48IUVOVElUWSBPZGJsYWMgIiYjeDE1MDsiPjwhRU5USVRZIG9kYmxhYyAiJiN4MTUxOyI%2BPCFFTlRJVFkgT0VsaWcgIiYjeDE1MjsiPjwhRU5USVRZIG9lbGlnICImI3gxNTM7Ij48IUVOVElUWSBSYWN1dGUgIiYjeDE1NDsiPjwhRU5USVRZIHJhY3V0ZSAiJiN4MTU1OyI%2BPCFFTlRJVFkgUmNlZGlsICImI3gxNTY7Ij48IUVOVElUWSByY2VkaWwgIiYjeDE1NzsiPjwhRU5USVRZIFJjYXJvbiAiJiN4MTU4OyI%2BPCFFTlRJVFkgcmNhcm9uICImI3gxNTk7Ij48IUVOVElUWSBTYWN1dGUgIiYjeDE1QTsiPjwhRU5USVRZIHNhY3V0ZSAiJiN4MTVCOyI%2BPCFFTlRJVFkgU2NpcmMgIiYjeDE1QzsiPjwhRU5USVRZIHNjaXJjICImI3gxNUQ7Ij48IUVOVElUWSBTY2VkaWwgIiYjeDE1RTsiPjwhRU5USVRZIHNjZWRpbCAiJiN4MTVGOyI%2BPCFFTlRJVFkgU2Nhcm9uICImI3gxNjA7Ij48IUVOVElUWSBzY2Fyb24gIiYjeDE2MTsiPjwhRU5USVRZIFRjZWRpbCAiJiN4MTYyOyI%2BPCFFTlRJVFkgdGNlZGlsICImI3gxNjM7Ij48IUVOVElUWSBUY2Fyb24gIiYjeDE2NDsiPjwhRU5USVRZIHRjYXJvbiAiJiN4MTY1OyI%2BPCFFTlRJVFkgVHN0cm9rICImI3gxNjY7Ij48IUVOVElUWSB0c3Ryb2sgIiYjeDE2NzsiPjwhRU5USVRZIFV0aWxkZSAiJiN4MTY4OyI%2BPCFFTlRJVFkgdXRpbGRlICImI3gxNjk7Ij48IUVOVElUWSBVbWFjciAiJiN4MTZBOyI%2BPCFFTlRJVFkgdW1hY3IgIiYjeDE2QjsiPjwhRU5USVRZIFVicmV2ZSAiJiN4MTZDOyI%2BPCFFTlRJVFkgdWJyZXZlICImI3gxNkQ7Ij48IUVOVElUWSBVcmluZyAiJiN4MTZFOyI%2BPCFFTlRJVFkgdXJpbmcgIiYjeDE2RjsiPjwhRU5USVRZIFVkYmxhYyAiJiN4MTcwOyI%2BPCFFTlRJVFkgdWRibGFjICImI3gxNzE7Ij48IUVOVElUWSBVb2dvbiAiJiN4MTcyOyI%2BPCFFTlRJVFkgdW9nb24gIiYjeDE3MzsiPjwhRU5USVRZIFdjaXJjICImI3gxNzQ7Ij48IUVOVElUWSB3Y2lyYyAiJiN4MTc1OyI%2BPCFFTlRJVFkgWWNpcmMgIiYjeDE3NjsiPjwhRU5USVRZIHljaXJjICImI3gxNzc7Ij48IUVOVElUWSBZdW1sICImI3gxNzg7Ij48IUVOVElUWSBaYWN1dGUgIiYjeDE3OTsiPjwhRU5USVRZIHphY3V0ZSAiJiN4MTdBOyI%2BPCFFTlRJVFkgWmRvdCAiJiN4MTdCOyI%2BPCFFTlRJVFkgemRvdCAiJiN4MTdDOyI%2BPCFFTlRJVFkgWmNhcm9uICImI3gxN0Q7Ij48IUVOVElUWSB6Y2Fyb24gIiYjeDE3RTsiPjwhRU5USVRZIGZub2YgIiYjeDE5MjsiPjwhRU5USVRZIGltcGVkICImI3gxQjU7Ij48IUVOVElUWSBnYWN1dGUgIiYjeDFGNTsiPjwhRU5USVRZIGptYXRoICImI3gyMzc7Ij48IUVOVElUWSBjaXJjICImI3gyQzY7Ij48IUVOVElUWSBjYXJvbiAiJiN4MkM3OyI%2BPCFFTlRJVFkgSGFjZWsgIiYjeDJDNzsiPjwhRU5USVRZIGJyZXZlICImI3gyRDg7Ij48IUVOVElUWSBCcmV2ZSAiJiN4MkQ4OyI%2BPCFFTlRJVFkgZG90ICImI3gyRDk7Ij48IUVOVElUWSBEaWFjcml0aWNhbERvdCAiJiN4MkQ5OyI%2BPCFFTlRJVFkgcmluZyAiJiN4MkRBOyI%2BPCFFTlRJVFkgb2dvbiAiJiN4MkRCOyI%2BPCFFTlRJVFkgdGlsZGUgIiYjeDJEQzsiPjwhRU5USVRZIERpYWNyaXRpY2FsVGlsZGUgIiYjeDJEQzsiPjwhRU5USVRZIGRibGFjICImI3gyREQ7Ij48IUVOVElUWSBEaWFjcml0aWNhbERvdWJsZUFjdXRlICImI3gyREQ7Ij48IUVOVElUWSBEb3duQnJldmUgIiYjeDMxMTsiPjwhRU5USVRZIEFscGhhICImI3gzOTE7Ij48IUVOVElUWSBCZXRhICImI3gzOTI7Ij48IUVOVElUWSBHYW1tYSAiJiN4MzkzOyI%2BPCFFTlRJVFkgRGVsdGEgIiYjeDM5NDsiPjwhRU5USVRZIEVwc2lsb24gIiYjeDM5NTsiPjwhRU5USVRZIFpldGEgIiYjeDM5NjsiPjwhRU5USVRZIEV0YSAiJiN4Mzk3OyI%2BPCFFTlRJVFkgVGhldGEgIiYjeDM5ODsiPjwhRU5USVRZIElvdGEgIiYjeDM5OTsiPjwhRU5USVRZIEthcHBhICImI3gzOUE7Ij48IUVOVElUWSBMYW1iZGEgIiYjeDM5QjsiPjwhRU5USVRZIE11ICImI3gzOUM7Ij48IUVOVElUWSBOdSAiJiN4MzlEOyI%2BPCFFTlRJVFkgWGkgIiYjeDM5RTsiPjwhRU5USVRZIE9taWNyb24gIiYjeDM5RjsiPjwhRU5USVRZIFBpICImI3gzQTA7Ij48IUVOVElUWSBSaG8gIiYjeDNBMTsiPjwhRU5USVRZIFNpZ21hICImI3gzQTM7Ij48IUVOVElUWSBUYXUgIiYjeDNBNDsiPjwhRU5USVRZIFVwc2lsb24gIiYjeDNBNTsiPjwhRU5USVRZIFBoaSAiJiN4M0E2OyI%2BPCFFTlRJVFkgQ2hpICImI3gzQTc7Ij48IUVOVElUWSBQc2kgIiYjeDNBODsiPjwhRU5USVRZIE9tZWdhICImI3gzQTk7Ij48IUVOVElUWSBvaG0gIiYjeDNBOTsiPjwhRU5USVRZIGFscGhhICImI3gzQjE7Ij48IUVOVElUWSBiZXRhICImI3gzQjI7Ij48IUVOVElUWSBnYW1tYSAiJiN4M0IzOyI%2BPCFFTlRJVFkgZGVsdGEgIiYjeDNCNDsiPjwhRU5USVRZIGVwc2kgIiYjeDNCNTsiPjwhRU5USVRZIGVwc2lsb24gIiYjeDNCNTsiPjwhRU5USVRZIHpldGEgIiYjeDNCNjsiPjwhRU5USVRZIGV0YSAiJiN4M0I3OyI%2BPCFFTlRJVFkgdGhldGEgIiYjeDNCODsiPjwhRU5USVRZIGlvdGEgIiYjeDNCOTsiPjwhRU5USVRZIGthcHBhICImI3gzQkE7Ij48IUVOVElUWSBsYW1iZGEgIiYjeDNCQjsiPjwhRU5USVRZIG11ICImI3gzQkM7Ij48IUVOVElUWSBudSAiJiN4M0JEOyI%2BPCFFTlRJVFkgeGkgIiYjeDNCRTsiPjwhRU5USVRZIG9taWNyb24gIiYjeDNCRjsiPjwhRU5USVRZIHBpICImI3gzQzA7Ij48IUVOVElUWSByaG8gIiYjeDNDMTsiPjwhRU5USVRZIHNpZ21hdiAiJiN4M0MyOyI%2BPCFFTlRJVFkgdmFyc2lnbWEgIiYjeDNDMjsiPjwhRU5USVRZIHNpZ21hZiAiJiN4M0MyOyI%2BPCFFTlRJVFkgc2lnbWEgIiYjeDNDMzsiPjwhRU5USVRZIHRhdSAiJiN4M0M0OyI%2BPCFFTlRJVFkgdXBzaSAiJiN4M0M1OyI%2BPCFFTlRJVFkgdXBzaWxvbiAiJiN4M0M1OyI%2BPCFFTlRJVFkgcGhpICImI3gzQzY7Ij48IUVOVElUWSBjaGkgIiYjeDNDNzsiPjwhRU5USVRZIHBzaSAiJiN4M0M4OyI%2BPCFFTlRJVFkgb21lZ2EgIiYjeDNDOTsiPjwhRU5USVRZIHRoZXRhdiAiJiN4M0QxOyI%2BPCFFTlRJVFkgdmFydGhldGEgIiYjeDNEMTsiPjwhRU5USVRZIHRoZXRhc3ltICImI3gzRDE7Ij48IUVOVElUWSBVcHNpICImI3gzRDI7Ij48IUVOVElUWSB1cHNpaCAiJiN4M0QyOyI%2BPCFFTlRJVFkgc3RyYWlnaHRwaGkgIiYjeDNENTsiPjwhRU5USVRZIHBoaXYgIiYjeDNENTsiPjwhRU5USVRZIHZhcnBoaSAiJiN4M0Q1OyI%2BPCFFTlRJVFkgcGl2ICImI3gzRDY7Ij48IUVOVElUWSB2YXJwaSAiJiN4M0Q2OyI%2BPCFFTlRJVFkgR2FtbWFkICImI3gzREM7Ij48IUVOVElUWSBnYW1tYWQgIiYjeDNERDsiPjwhRU5USVRZIGRpZ2FtbWEgIiYjeDNERDsiPjwhRU5USVRZIGthcHBhdiAiJiN4M0YwOyI%2BPCFFTlRJVFkgdmFya2FwcGEgIiYjeDNGMDsiPjwhRU5USVRZIHJob3YgIiYjeDNGMTsiPjwhRU5USVRZIHZhcnJobyAiJiN4M0YxOyI%2BPCFFTlRJVFkgZXBzaXYgIiYjeDNGNTsiPjwhRU5USVRZIHN0cmFpZ2h0ZXBzaWxvbiAiJiN4M0Y1OyI%2BPCFFTlRJVFkgdmFyZXBzaWxvbiAiJiN4M0Y1OyI%2BPCFFTlRJVFkgYmVwc2kgIiYjeDNGNjsiPjwhRU5USVRZIGJhY2tlcHNpbG9uICImI3gzRjY7Ij48IUVOVElUWSBJT2N5ICImI3g0MDE7Ij48IUVOVElUWSBESmN5ICImI3g0MDI7Ij48IUVOVElUWSBHSmN5ICImI3g0MDM7Ij48IUVOVElUWSBKdWtjeSAiJiN4NDA0OyI%2BPCFFTlRJVFkgRFNjeSAiJiN4NDA1OyI%2BPCFFTlRJVFkgSXVrY3kgIiYjeDQwNjsiPjwhRU5USVRZIFlJY3kgIiYjeDQwNzsiPjwhRU5USVRZIEpzZXJjeSAiJiN4NDA4OyI%2BPCFFTlRJVFkgTEpjeSAiJiN4NDA5OyI%2BPCFFTlRJVFkgTkpjeSAiJiN4NDBBOyI%2BPCFFTlRJVFkgVFNIY3kgIiYjeDQwQjsiPjwhRU5USVRZIEtKY3kgIiYjeDQwQzsiPjwhRU5USVRZIFVicmN5ICImI3g0MEU7Ij48IUVOVElUWSBEWmN5ICImI3g0MEY7Ij48IUVOVElUWSBBY3kgIiYjeDQxMDsiPjwhRU5USVRZIEJjeSAiJiN4NDExOyI%2BPCFFTlRJVFkgVmN5ICImI3g0MTI7Ij48IUVOVElUWSBHY3kgIiYjeDQxMzsiPjwhRU5USVRZIERjeSAiJiN4NDE0OyI%2BPCFFTlRJVFkgSUVjeSAiJiN4NDE1OyI%2BPCFFTlRJVFkgWkhjeSAiJiN4NDE2OyI%2BPCFFTlRJVFkgWmN5ICImI3g0MTc7Ij48IUVOVElUWSBJY3kgIiYjeDQxODsiPjwhRU5USVRZIEpjeSAiJiN4NDE5OyI%2BPCFFTlRJVFkgS2N5ICImI3g0MUE7Ij48IUVOVElUWSBMY3kgIiYjeDQxQjsiPjwhRU5USVRZIE1jeSAiJiN4NDFDOyI%2BPCFFTlRJVFkgTmN5ICImI3g0MUQ7Ij48IUVOVElUWSBPY3kgIiYjeDQxRTsiPjwhRU5USVRZIFBjeSAiJiN4NDFGOyI%2BPCFFTlRJVFkgUmN5ICImI3g0MjA7Ij48IUVOVElUWSBTY3kgIiYjeDQyMTsiPjwhRU5USVRZIFRjeSAiJiN4NDIyOyI%2BPCFFTlRJVFkgVWN5ICImI3g0MjM7Ij48IUVOVElUWSBGY3kgIiYjeDQyNDsiPjwhRU5USVRZIEtIY3kgIiYjeDQyNTsiPjwhRU5USVRZIFRTY3kgIiYjeDQyNjsiPjwhRU5USVRZIENIY3kgIiYjeDQyNzsiPjwhRU5USVRZIFNIY3kgIiYjeDQyODsiPjwhRU5USVRZIFNIQ0hjeSAiJiN4NDI5OyI%2BPCFFTlRJVFkgSEFSRGN5ICImI3g0MkE7Ij48IUVOVElUWSBZY3kgIiYjeDQyQjsiPjwhRU5USVRZIFNPRlRjeSAiJiN4NDJDOyI%2BPCFFTlRJVFkgRWN5ICImI3g0MkQ7Ij48IUVOVElUWSBZVWN5ICImI3g0MkU7Ij48IUVOVElUWSBZQWN5ICImI3g0MkY7Ij48IUVOVElUWSBhY3kgIiYjeDQzMDsiPjwhRU5USVRZIGJjeSAiJiN4NDMxOyI%2BPCFFTlRJVFkgdmN5ICImI3g0MzI7Ij48IUVOVElUWSBnY3kgIiYjeDQzMzsiPjwhRU5USVRZIGRjeSAiJiN4NDM0OyI%2BPCFFTlRJVFkgaWVjeSAiJiN4NDM1OyI%2BPCFFTlRJVFkgemhjeSAiJiN4NDM2OyI%2BPCFFTlRJVFkgemN5ICImI3g0Mzc7Ij48IUVOVElUWSBpY3kgIiYjeDQzODsiPjwhRU5USVRZIGpjeSAiJiN4NDM5OyI%2BPCFFTlRJVFkga2N5ICImI3g0M0E7Ij48IUVOVElUWSBsY3kgIiYjeDQzQjsiPjwhRU5USVRZIG1jeSAiJiN4NDNDOyI%2BPCFFTlRJVFkgbmN5ICImI3g0M0Q7Ij48IUVOVElUWSBvY3kgIiYjeDQzRTsiPjwhRU5USVRZIHBjeSAiJiN4NDNGOyI%2BPCFFTlRJVFkgcmN5ICImI3g0NDA7Ij48IUVOVElUWSBzY3kgIiYjeDQ0MTsiPjwhRU5USVRZIHRjeSAiJiN4NDQyOyI%2BPCFFTlRJVFkgdWN5ICImI3g0NDM7Ij48IUVOVElUWSBmY3kgIiYjeDQ0NDsiPjwhRU5USVRZIGtoY3kgIiYjeDQ0NTsiPjwhRU5USVRZIHRzY3kgIiYjeDQ0NjsiPjwhRU5USVRZIGNoY3kgIiYjeDQ0NzsiPjwhRU5USVRZIHNoY3kgIiYjeDQ0ODsiPjwhRU5USVRZIHNoY2hjeSAiJiN4NDQ5OyI%2BPCFFTlRJVFkgaGFyZGN5ICImI3g0NEE7Ij48IUVOVElUWSB5Y3kgIiYjeDQ0QjsiPjwhRU5USVRZIHNvZnRjeSAiJiN4NDRDOyI%2BPCFFTlRJVFkgZWN5ICImI3g0NEQ7Ij48IUVOVElUWSB5dWN5ICImI3g0NEU7Ij48IUVOVElUWSB5YWN5ICImI3g0NEY7Ij48IUVOVElUWSBpb2N5ICImI3g0NTE7Ij48IUVOVElUWSBkamN5ICImI3g0NTI7Ij48IUVOVElUWSBnamN5ICImI3g0NTM7Ij48IUVOVElUWSBqdWtjeSAiJiN4NDU0OyI%2BPCFFTlRJVFkgZHNjeSAiJiN4NDU1OyI%2BPCFFTlRJVFkgaXVrY3kgIiYjeDQ1NjsiPjwhRU5USVRZIHlpY3kgIiYjeDQ1NzsiPjwhRU5USVRZIGpzZXJjeSAiJiN4NDU4OyI%2BPCFFTlRJVFkgbGpjeSAiJiN4NDU5OyI%2BPCFFTlRJVFkgbmpjeSAiJiN4NDVBOyI%2BPCFFTlRJVFkgdHNoY3kgIiYjeDQ1QjsiPjwhRU5USVRZIGtqY3kgIiYjeDQ1QzsiPjwhRU5USVRZIHVicmN5ICImI3g0NUU7Ij48IUVOVElUWSBkemN5ICImI3g0NUY7Ij48IUVOVElUWSBlbnNwICImI3gyMDAyOyI%2BPCFFTlRJVFkgZW1zcCAiJiN4MjAwMzsiPjwhRU5USVRZIGVtc3AxMyAiJiN4MjAwNDsiPjwhRU5USVRZIGVtc3AxNCAiJiN4MjAwNTsiPjwhRU5USVRZIG51bXNwICImI3gyMDA3OyI%2BPCFFTlRJVFkgcHVuY3NwICImI3gyMDA4OyI%2BPCFFTlRJVFkgdGhpbnNwICImI3gyMDA5OyI%2BPCFFTlRJVFkgVGhpblNwYWNlICImI3gyMDA5OyI%2BPCFFTlRJVFkgaGFpcnNwICImI3gyMDBBOyI%2BPCFFTlRJVFkgVmVyeVRoaW5TcGFjZSAiJiN4MjAwQTsiPjwhRU5USVRZIFplcm9XaWR0aFNwYWNlICImI3gyMDBCOyI%2BPCFFTlRJVFkgTmVnYXRpdmVWZXJ5VGhpblNwYWNlICImI3gyMDBCOyI%2BPCFFTlRJVFkgTmVnYXRpdmVUaGluU3BhY2UgIiYjeDIwMEI7Ij48IUVOVElUWSBOZWdhdGl2ZU1lZGl1bVNwYWNlICImI3gyMDBCOyI%2BPCFFTlRJVFkgTmVnYXRpdmVUaGlja1NwYWNlICImI3gyMDBCOyI%2BPCFFTlRJVFkgenduaiAiJiN4MjAwQzsiPjwhRU5USVRZIHp3aiAiJiN4MjAwRDsiPjwhRU5USVRZIGxybSAiJiN4MjAwRTsiPjwhRU5USVRZIHJsbSAiJiN4MjAwRjsiPjwhRU5USVRZIGh5cGhlbiAiJiN4MjAxMDsiPjwhRU5USVRZIGRhc2ggIiYjeDIwMTA7Ij48IUVOVElUWSBuZGFzaCAiJiN4MjAxMzsiPjwhRU5USVRZIG1kYXNoICImI3gyMDE0OyI%2BPCFFTlRJVFkgaG9yYmFyICImI3gyMDE1OyI%2BPCFFTlRJVFkgVmVyYmFyICImI3gyMDE2OyI%2BPCFFTlRJVFkgVmVydCAiJiN4MjAxNjsiPjwhRU5USVRZIGxzcXVvICImI3gyMDE4OyI%2BPCFFTlRJVFkgT3BlbkN1cmx5UXVvdGUgIiYjeDIwMTg7Ij48IUVOVElUWSByc3F1byAiJiN4MjAxOTsiPjwhRU5USVRZIHJzcXVvciAiJiN4MjAxOTsiPjwhRU5USVRZIENsb3NlQ3VybHlRdW90ZSAiJiN4MjAxOTsiPjwhRU5USVRZIGxzcXVvciAiJiN4MjAxQTsiPjwhRU5USVRZIHNicXVvICImI3gyMDFBOyI%2BPCFFTlRJVFkgbGRxdW8gIiYjeDIwMUM7Ij48IUVOVElUWSBPcGVuQ3VybHlEb3VibGVRdW90ZSAiJiN4MjAxQzsiPjwhRU5USVRZIHJkcXVvICImI3gyMDFEOyI%2BPCFFTlRJVFkgcmRxdW9yICImI3gyMDFEOyI%2BPCFFTlRJVFkgQ2xvc2VDdXJseURvdWJsZVF1b3RlICImI3gyMDFEOyI%2BPCFFTlRJVFkgbGRxdW9yICImI3gyMDFFOyI%2BPCFFTlRJVFkgYmRxdW8gIiYjeDIwMUU7Ij48IUVOVElUWSBkYWdnZXIgIiYjeDIwMjA7Ij48IUVOVElUWSBEYWdnZXIgIiYjeDIwMjE7Ij48IUVOVElUWSBkZGFnZ2VyICImI3gyMDIxOyI%2BPCFFTlRJVFkgYnVsbCAiJiN4MjAyMjsiPjwhRU5USVRZIGJ1bGxldCAiJiN4MjAyMjsiPjwhRU5USVRZIG5sZHIgIiYjeDIwMjU7Ij48IUVOVElUWSBoZWxsaXAgIiYjeDIwMjY7Ij48IUVOVElUWSBtbGRyICImI3gyMDI2OyI%2BPCFFTlRJVFkgcGVybWlsICImI3gyMDMwOyI%2BPCFFTlRJVFkgcGVydGVuayAiJiN4MjAzMTsiPjwhRU5USVRZIHByaW1lICImI3gyMDMyOyI%2BPCFFTlRJVFkgUHJpbWUgIiYjeDIwMzM7Ij48IUVOVElUWSB0cHJpbWUgIiYjeDIwMzQ7Ij48IUVOVElUWSBicHJpbWUgIiYjeDIwMzU7Ij48IUVOVElUWSBiYWNrcHJpbWUgIiYjeDIwMzU7Ij48IUVOVElUWSBsc2FxdW8gIiYjeDIwMzk7Ij48IUVOVElUWSByc2FxdW8gIiYjeDIwM0E7Ij48IUVOVElUWSBvbGluZSAiJiN4MjAzRTsiPjwhRU5USVRZIE92ZXJCYXIgIiYjeDIwM0U7Ij48IUVOVElUWSBjYXJldCAiJiN4MjA0MTsiPjwhRU5USVRZIGh5YnVsbCAiJiN4MjA0MzsiPjwhRU5USVRZIGZyYXNsICImI3gyMDQ0OyI%2BPCFFTlRJVFkgYnNlbWkgIiYjeDIwNEY7Ij48IUVOVElUWSBxcHJpbWUgIiYjeDIwNTc7Ij48IUVOVElUWSBNZWRpdW1TcGFjZSAiJiN4MjA1RjsiPjwhRU5USVRZIFRoaWNrU3BhY2UgIiYjeDIwNUY7JiN4MjAwQTsiPjwhRU5USVRZIE5vQnJlYWsgIiYjeDIwNjA7Ij48IUVOVElUWSBBcHBseUZ1bmN0aW9uICImI3gyMDYxOyI%2BPCFFTlRJVFkgYWYgIiYjeDIwNjE7Ij48IUVOVElUWSBJbnZpc2libGVUaW1lcyAiJiN4MjA2MjsiPjwhRU5USVRZIGl0ICImI3gyMDYyOyI%2BPCFFTlRJVFkgSW52aXNpYmxlQ29tbWEgIiYjeDIwNjM7Ij48IUVOVElUWSBpYyAiJiN4MjA2MzsiPjwhRU5USVRZIGV1cm8gIiYjeDIwQUM7Ij48IUVOVElUWSB0ZG90ICImI3gyMERCOyI%2BPCFFTlRJVFkgVHJpcGxlRG90ICImI3gyMERCOyI%2BPCFFTlRJVFkgRG90RG90ICImI3gyMERDOyI%2BPCFFTlRJVFkgQ29wZiAiJiN4MjEwMjsiPjwhRU5USVRZIGNvbXBsZXhlcyAiJiN4MjEwMjsiPjwhRU5USVRZIGluY2FyZSAiJiN4MjEwNTsiPjwhRU5USVRZIGdzY3IgIiYjeDIxMEE7Ij48IUVOVElUWSBoYW1pbHQgIiYjeDIxMEI7Ij48IUVOVElUWSBIaWxiZXJ0U3BhY2UgIiYjeDIxMEI7Ij48IUVOVElUWSBIc2NyICImI3gyMTBCOyI%2BPCFFTlRJVFkgSGZyICImI3gyMTBDOyI%2BPCFFTlRJVFkgUG9pbmNhcmVwbGFuZSAiJiN4MjEwQzsiPjwhRU5USVRZIHF1YXRlcm5pb25zICImI3gyMTBEOyI%2BPCFFTlRJVFkgSG9wZiAiJiN4MjEwRDsiPjwhRU5USVRZIHBsYW5ja2ggIiYjeDIxMEU7Ij48IUVOVElUWSBwbGFuY2sgIiYjeDIxMEY7Ij48IUVOVElUWSBoYmFyICImI3gyMTBGOyI%2BPCFFTlRJVFkgcGxhbmt2ICImI3gyMTBGOyI%2BPCFFTlRJVFkgaHNsYXNoICImI3gyMTBGOyI%2BPCFFTlRJVFkgSXNjciAiJiN4MjExMDsiPjwhRU5USVRZIGltYWdsaW5lICImI3gyMTEwOyI%2BPCFFTlRJVFkgaW1hZ2UgIiYjeDIxMTE7Ij48IUVOVElUWSBJbSAiJiN4MjExMTsiPjwhRU5USVRZIGltYWdwYXJ0ICImI3gyMTExOyI%2BPCFFTlRJVFkgSWZyICImI3gyMTExOyI%2BPCFFTlRJVFkgTHNjciAiJiN4MjExMjsiPjwhRU5USVRZIGxhZ3JhbiAiJiN4MjExMjsiPjwhRU5USVRZIExhcGxhY2V0cmYgIiYjeDIxMTI7Ij48IUVOVElUWSBlbGwgIiYjeDIxMTM7Ij48IUVOVElUWSBOb3BmICImI3gyMTE1OyI%2BPCFFTlRJVFkgbmF0dXJhbHMgIiYjeDIxMTU7Ij48IUVOVElUWSBudW1lcm8gIiYjeDIxMTY7Ij48IUVOVElUWSBjb3B5c3IgIiYjeDIxMTc7Ij48IUVOVElUWSB3ZWllcnAgIiYjeDIxMTg7Ij48IUVOVElUWSB3cCAiJiN4MjExODsiPjwhRU5USVRZIFBvcGYgIiYjeDIxMTk7Ij48IUVOVElUWSBwcmltZXMgIiYjeDIxMTk7Ij48IUVOVElUWSByYXRpb25hbHMgIiYjeDIxMUE7Ij48IUVOVElUWSBRb3BmICImI3gyMTFBOyI%2BPCFFTlRJVFkgUnNjciAiJiN4MjExQjsiPjwhRU5USVRZIHJlYWxpbmUgIiYjeDIxMUI7Ij48IUVOVElUWSByZWFsICImI3gyMTFDOyI%2BPCFFTlRJVFkgUmUgIiYjeDIxMUM7Ij48IUVOVElUWSByZWFscGFydCAiJiN4MjExQzsiPjwhRU5USVRZIFJmciAiJiN4MjExQzsiPjwhRU5USVRZIHJlYWxzICImI3gyMTFEOyI%2BPCFFTlRJVFkgUm9wZiAiJiN4MjExRDsiPjwhRU5USVRZIHJ4ICImI3gyMTFFOyI%2BPCFFTlRJVFkgdHJhZGUgIiYjeDIxMjI7Ij48IUVOVElUWSBUUkFERSAiJiN4MjEyMjsiPjwhRU5USVRZIGludGVnZXJzICImI3gyMTI0OyI%2BPCFFTlRJVFkgWm9wZiAiJiN4MjEyNDsiPjwhRU5USVRZIG1obyAiJiN4MjEyNzsiPjwhRU5USVRZIFpmciAiJiN4MjEyODsiPjwhRU5USVRZIHplZXRyZiAiJiN4MjEyODsiPjwhRU5USVRZIGlpb3RhICImI3gyMTI5OyI%2BPCFFTlRJVFkgYmVybm91ICImI3gyMTJDOyI%2BPCFFTlRJVFkgQmVybm91bGxpcyAiJiN4MjEyQzsiPjwhRU5USVRZIEJzY3IgIiYjeDIxMkM7Ij48IUVOVElUWSBDZnIgIiYjeDIxMkQ7Ij48IUVOVElUWSBDYXlsZXlzICImI3gyMTJEOyI%2BPCFFTlRJVFkgZXNjciAiJiN4MjEyRjsiPjwhRU5USVRZIEVzY3IgIiYjeDIxMzA7Ij48IUVOVElUWSBleHBlY3RhdGlvbiAiJiN4MjEzMDsiPjwhRU5USVRZIEZzY3IgIiYjeDIxMzE7Ij48IUVOVElUWSBGb3VyaWVydHJmICImI3gyMTMxOyI%2BPCFFTlRJVFkgcGhtbWF0ICImI3gyMTMzOyI%2BPCFFTlRJVFkgTWVsbGludHJmICImI3gyMTMzOyI%2BPCFFTlRJVFkgTXNjciAiJiN4MjEzMzsiPjwhRU5USVRZIG9yZGVyICImI3gyMTM0OyI%2BPCFFTlRJVFkgb3JkZXJvZiAiJiN4MjEzNDsiPjwhRU5USVRZIG9zY3IgIiYjeDIxMzQ7Ij48IUVOVElUWSBhbGVmc3ltICImI3gyMTM1OyI%2BPCFFTlRJVFkgYWxlcGggIiYjeDIxMzU7Ij48IUVOVElUWSBiZXRoICImI3gyMTM2OyI%2BPCFFTlRJVFkgZ2ltZWwgIiYjeDIxMzc7Ij48IUVOVElUWSBkYWxldGggIiYjeDIxMzg7Ij48IUVOVElUWSBDYXBpdGFsRGlmZmVyZW50aWFsRCAiJiN4MjE0NTsiPjwhRU5USVRZIEREICImI3gyMTQ1OyI%2BPCFFTlRJVFkgRGlmZmVyZW50aWFsRCAiJiN4MjE0NjsiPjwhRU5USVRZIGRkICImI3gyMTQ2OyI%2BPCFFTlRJVFkgRXhwb25lbnRpYWxFICImI3gyMTQ3OyI%2BPCFFTlRJVFkgZXhwb25lbnRpYWxlICImI3gyMTQ3OyI%2BPCFFTlRJVFkgZWUgIiYjeDIxNDc7Ij48IUVOVElUWSBJbWFnaW5hcnlJICImI3gyMTQ4OyI%2BPCFFTlRJVFkgaWkgIiYjeDIxNDg7Ij48IUVOVElUWSBmcmFjMTMgIiYjeDIxNTM7Ij48IUVOVElUWSBmcmFjMjMgIiYjeDIxNTQ7Ij48IUVOVElUWSBmcmFjMTUgIiYjeDIxNTU7Ij48IUVOVElUWSBmcmFjMjUgIiYjeDIxNTY7Ij48IUVOVElUWSBmcmFjMzUgIiYjeDIxNTc7Ij48IUVOVElUWSBmcmFjNDUgIiYjeDIxNTg7Ij48IUVOVElUWSBmcmFjMTYgIiYjeDIxNTk7Ij48IUVOVElUWSBmcmFjNTYgIiYjeDIxNUE7Ij48IUVOVElUWSBmcmFjMTggIiYjeDIxNUI7Ij48IUVOVElUWSBmcmFjMzggIiYjeDIxNUM7Ij48IUVOVElUWSBmcmFjNTggIiYjeDIxNUQ7Ij48IUVOVElUWSBmcmFjNzggIiYjeDIxNUU7Ij48IUVOVElUWSBsYXJyICImI3gyMTkwOyI%2BPCFFTlRJVFkgbGVmdGFycm93ICImI3gyMTkwOyI%2BPCFFTlRJVFkgTGVmdEFycm93ICImI3gyMTkwOyI%2BPCFFTlRJVFkgc2xhcnIgIiYjeDIxOTA7Ij48IUVOVElUWSBTaG9ydExlZnRBcnJvdyAiJiN4MjE5MDsiPjwhRU5USVRZIHVhcnIgIiYjeDIxOTE7Ij48IUVOVElUWSB1cGFycm93ICImI3gyMTkxOyI%2BPCFFTlRJVFkgVXBBcnJvdyAiJiN4MjE5MTsiPjwhRU5USVRZIFNob3J0VXBBcnJvdyAiJiN4MjE5MTsiPjwhRU5USVRZIHJhcnIgIiYjeDIxOTI7Ij48IUVOVElUWSByaWdodGFycm93ICImI3gyMTkyOyI%2BPCFFTlRJVFkgUmlnaHRBcnJvdyAiJiN4MjE5MjsiPjwhRU5USVRZIHNyYXJyICImI3gyMTkyOyI%2BPCFFTlRJVFkgU2hvcnRSaWdodEFycm93ICImI3gyMTkyOyI%2BPCFFTlRJVFkgZGFyciAiJiN4MjE5MzsiPjwhRU5USVRZIGRvd25hcnJvdyAiJiN4MjE5MzsiPjwhRU5USVRZIERvd25BcnJvdyAiJiN4MjE5MzsiPjwhRU5USVRZIFNob3J0RG93bkFycm93ICImI3gyMTkzOyI%2BPCFFTlRJVFkgaGFyciAiJiN4MjE5NDsiPjwhRU5USVRZIGxlZnRyaWdodGFycm93ICImI3gyMTk0OyI%2BPCFFTlRJVFkgTGVmdFJpZ2h0QXJyb3cgIiYjeDIxOTQ7Ij48IUVOVElUWSB2YXJyICImI3gyMTk1OyI%2BPCFFTlRJVFkgdXBkb3duYXJyb3cgIiYjeDIxOTU7Ij48IUVOVElUWSBVcERvd25BcnJvdyAiJiN4MjE5NTsiPjwhRU5USVRZIG53YXJyICImI3gyMTk2OyI%2BPCFFTlRJVFkgVXBwZXJMZWZ0QXJyb3cgIiYjeDIxOTY7Ij48IUVOVElUWSBud2Fycm93ICImI3gyMTk2OyI%2BPCFFTlRJVFkgbmVhcnIgIiYjeDIxOTc7Ij48IUVOVElUWSBVcHBlclJpZ2h0QXJyb3cgIiYjeDIxOTc7Ij48IUVOVElUWSBuZWFycm93ICImI3gyMTk3OyI%2BPCFFTlRJVFkgc2VhcnIgIiYjeDIxOTg7Ij48IUVOVElUWSBzZWFycm93ICImI3gyMTk4OyI%2BPCFFTlRJVFkgTG93ZXJSaWdodEFycm93ICImI3gyMTk4OyI%2BPCFFTlRJVFkgc3dhcnIgIiYjeDIxOTk7Ij48IUVOVElUWSBzd2Fycm93ICImI3gyMTk5OyI%2BPCFFTlRJVFkgTG93ZXJMZWZ0QXJyb3cgIiYjeDIxOTk7Ij48IUVOVElUWSBubGFyciAiJiN4MjE5QTsiPjwhRU5USVRZIG5sZWZ0YXJyb3cgIiYjeDIxOUE7Ij48IUVOVElUWSBucmFyciAiJiN4MjE5QjsiPjwhRU5USVRZIG5yaWdodGFycm93ICImI3gyMTlCOyI%2BPCFFTlRJVFkgcmFycncgIiYjeDIxOUQ7Ij48IUVOVElUWSByaWdodHNxdWlnYXJyb3cgIiYjeDIxOUQ7Ij48IUVOVElUWSBucmFycncgIiYjeDIxOUQ7JiN4MzM4OyI%2BPCFFTlRJVFkgTGFyciAiJiN4MjE5RTsiPjwhRU5USVRZIHR3b2hlYWRsZWZ0YXJyb3cgIiYjeDIxOUU7Ij48IUVOVElUWSBVYXJyICImI3gyMTlGOyI%2BPCFFTlRJVFkgUmFyciAiJiN4MjFBMDsiPjwhRU5USVRZIHR3b2hlYWRyaWdodGFycm93ICImI3gyMUEwOyI%2BPCFFTlRJVFkgRGFyciAiJiN4MjFBMTsiPjwhRU5USVRZIGxhcnJ0bCAiJiN4MjFBMjsiPjwhRU5USVRZIGxlZnRhcnJvd3RhaWwgIiYjeDIxQTI7Ij48IUVOVElUWSByYXJydGwgIiYjeDIxQTM7Ij48IUVOVElUWSByaWdodGFycm93dGFpbCAiJiN4MjFBMzsiPjwhRU5USVRZIExlZnRUZWVBcnJvdyAiJiN4MjFBNDsiPjwhRU5USVRZIG1hcHN0b2xlZnQgIiYjeDIxQTQ7Ij48IUVOVElUWSBVcFRlZUFycm93ICImI3gyMUE1OyI%2BPCFFTlRJVFkgbWFwc3RvdXAgIiYjeDIxQTU7Ij48IUVOVElUWSBtYXAgIiYjeDIxQTY7Ij48IUVOVElUWSBSaWdodFRlZUFycm93ICImI3gyMUE2OyI%2BPCFFTlRJVFkgbWFwc3RvICImI3gyMUE2OyI%2BPCFFTlRJVFkgRG93blRlZUFycm93ICImI3gyMUE3OyI%2BPCFFTlRJVFkgbWFwc3RvZG93biAiJiN4MjFBNzsiPjwhRU5USVRZIGxhcnJoayAiJiN4MjFBOTsiPjwhRU5USVRZIGhvb2tsZWZ0YXJyb3cgIiYjeDIxQTk7Ij48IUVOVElUWSByYXJyaGsgIiYjeDIxQUE7Ij48IUVOVElUWSBob29rcmlnaHRhcnJvdyAiJiN4MjFBQTsiPjwhRU5USVRZIGxhcnJscCAiJiN4MjFBQjsiPjwhRU5USVRZIGxvb3BhcnJvd2xlZnQgIiYjeDIxQUI7Ij48IUVOVElUWSByYXJybHAgIiYjeDIxQUM7Ij48IUVOVElUWSBsb29wYXJyb3dyaWdodCAiJiN4MjFBQzsiPjwhRU5USVRZIGhhcnJ3ICImI3gyMUFEOyI%2BPCFFTlRJVFkgbGVmdHJpZ2h0c3F1aWdhcnJvdyAiJiN4MjFBRDsiPjwhRU5USVRZIG5oYXJyICImI3gyMUFFOyI%2BPCFFTlRJVFkgbmxlZnRyaWdodGFycm93ICImI3gyMUFFOyI%2BPCFFTlRJVFkgbHNoICImI3gyMUIwOyI%2BPCFFTlRJVFkgTHNoICImI3gyMUIwOyI%2BPCFFTlRJVFkgcnNoICImI3gyMUIxOyI%2BPCFFTlRJVFkgUnNoICImI3gyMUIxOyI%2BPCFFTlRJVFkgbGRzaCAiJiN4MjFCMjsiPjwhRU5USVRZIHJkc2ggIiYjeDIxQjM7Ij48IUVOVElUWSBjcmFyciAiJiN4MjFCNTsiPjwhRU5USVRZIGN1bGFyciAiJiN4MjFCNjsiPjwhRU5USVRZIGN1cnZlYXJyb3dsZWZ0ICImI3gyMUI2OyI%2BPCFFTlRJVFkgY3VyYXJyICImI3gyMUI3OyI%2BPCFFTlRJVFkgY3VydmVhcnJvd3JpZ2h0ICImI3gyMUI3OyI%2BPCFFTlRJVFkgb2xhcnIgIiYjeDIxQkE7Ij48IUVOVElUWSBjaXJjbGVhcnJvd2xlZnQgIiYjeDIxQkE7Ij48IUVOVElUWSBvcmFyciAiJiN4MjFCQjsiPjwhRU5USVRZIGNpcmNsZWFycm93cmlnaHQgIiYjeDIxQkI7Ij48IUVOVElUWSBsaGFydSAiJiN4MjFCQzsiPjwhRU5USVRZIExlZnRWZWN0b3IgIiYjeDIxQkM7Ij48IUVOVElUWSBsZWZ0aGFycG9vbnVwICImI3gyMUJDOyI%2BPCFFTlRJVFkgbGhhcmQgIiYjeDIxQkQ7Ij48IUVOVElUWSBsZWZ0aGFycG9vbmRvd24gIiYjeDIxQkQ7Ij48IUVOVElUWSBEb3duTGVmdFZlY3RvciAiJiN4MjFCRDsiPjwhRU5USVRZIHVoYXJyICImI3gyMUJFOyI%2BPCFFTlRJVFkgdXBoYXJwb29ucmlnaHQgIiYjeDIxQkU7Ij48IUVOVElUWSBSaWdodFVwVmVjdG9yICImI3gyMUJFOyI%2BPCFFTlRJVFkgdWhhcmwgIiYjeDIxQkY7Ij48IUVOVElUWSB1cGhhcnBvb25sZWZ0ICImI3gyMUJGOyI%2BPCFFTlRJVFkgTGVmdFVwVmVjdG9yICImI3gyMUJGOyI%2BPCFFTlRJVFkgcmhhcnUgIiYjeDIxQzA7Ij48IUVOVElUWSBSaWdodFZlY3RvciAiJiN4MjFDMDsiPjwhRU5USVRZIHJpZ2h0aGFycG9vbnVwICImI3gyMUMwOyI%2BPCFFTlRJVFkgcmhhcmQgIiYjeDIxQzE7Ij48IUVOVElUWSByaWdodGhhcnBvb25kb3duICImI3gyMUMxOyI%2BPCFFTlRJVFkgRG93blJpZ2h0VmVjdG9yICImI3gyMUMxOyI%2BPCFFTlRJVFkgZGhhcnIgIiYjeDIxQzI7Ij48IUVOVElUWSBSaWdodERvd25WZWN0b3IgIiYjeDIxQzI7Ij48IUVOVElUWSBkb3duaGFycG9vbnJpZ2h0ICImI3gyMUMyOyI%2BPCFFTlRJVFkgZGhhcmwgIiYjeDIxQzM7Ij48IUVOVElUWSBMZWZ0RG93blZlY3RvciAiJiN4MjFDMzsiPjwhRU5USVRZIGRvd25oYXJwb29ubGVmdCAiJiN4MjFDMzsiPjwhRU5USVRZIHJsYXJyICImI3gyMUM0OyI%2BPCFFTlRJVFkgcmlnaHRsZWZ0YXJyb3dzICImI3gyMUM0OyI%2BPCFFTlRJVFkgUmlnaHRBcnJvd0xlZnRBcnJvdyAiJiN4MjFDNDsiPjwhRU5USVRZIHVkYXJyICImI3gyMUM1OyI%2BPCFFTlRJVFkgVXBBcnJvd0Rvd25BcnJvdyAiJiN4MjFDNTsiPjwhRU5USVRZIGxyYXJyICImI3gyMUM2OyI%2BPCFFTlRJVFkgbGVmdHJpZ2h0YXJyb3dzICImI3gyMUM2OyI%2BPCFFTlRJVFkgTGVmdEFycm93UmlnaHRBcnJvdyAiJiN4MjFDNjsiPjwhRU5USVRZIGxsYXJyICImI3gyMUM3OyI%2BPCFFTlRJVFkgbGVmdGxlZnRhcnJvd3MgIiYjeDIxQzc7Ij48IUVOVElUWSB1dWFyciAiJiN4MjFDODsiPjwhRU5USVRZIHVwdXBhcnJvd3MgIiYjeDIxQzg7Ij48IUVOVElUWSBycmFyciAiJiN4MjFDOTsiPjwhRU5USVRZIHJpZ2h0cmlnaHRhcnJvd3MgIiYjeDIxQzk7Ij48IUVOVElUWSBkZGFyciAiJiN4MjFDQTsiPjwhRU5USVRZIGRvd25kb3duYXJyb3dzICImI3gyMUNBOyI%2BPCFFTlRJVFkgbHJoYXIgIiYjeDIxQ0I7Ij48IUVOVElUWSBSZXZlcnNlRXF1aWxpYnJpdW0gIiYjeDIxQ0I7Ij48IUVOVElUWSBsZWZ0cmlnaHRoYXJwb29ucyAiJiN4MjFDQjsiPjwhRU5USVRZIHJsaGFyICImI3gyMUNDOyI%2BPCFFTlRJVFkgcmlnaHRsZWZ0aGFycG9vbnMgIiYjeDIxQ0M7Ij48IUVOVElUWSBFcXVpbGlicml1bSAiJiN4MjFDQzsiPjwhRU5USVRZIG5sQXJyICImI3gyMUNEOyI%2BPCFFTlRJVFkgbkxlZnRhcnJvdyAiJiN4MjFDRDsiPjwhRU5USVRZIG5oQXJyICImI3gyMUNFOyI%2BPCFFTlRJVFkgbkxlZnRyaWdodGFycm93ICImI3gyMUNFOyI%2BPCFFTlRJVFkgbnJBcnIgIiYjeDIxQ0Y7Ij48IUVOVElUWSBuUmlnaHRhcnJvdyAiJiN4MjFDRjsiPjwhRU5USVRZIGxBcnIgIiYjeDIxRDA7Ij48IUVOVElUWSBMZWZ0YXJyb3cgIiYjeDIxRDA7Ij48IUVOVElUWSBEb3VibGVMZWZ0QXJyb3cgIiYjeDIxRDA7Ij48IUVOVElUWSB1QXJyICImI3gyMUQxOyI%2BPCFFTlRJVFkgVXBhcnJvdyAiJiN4MjFEMTsiPjwhRU5USVRZIERvdWJsZVVwQXJyb3cgIiYjeDIxRDE7Ij48IUVOVElUWSByQXJyICImI3gyMUQyOyI%2BPCFFTlRJVFkgUmlnaHRhcnJvdyAiJiN4MjFEMjsiPjwhRU5USVRZIEltcGxpZXMgIiYjeDIxRDI7Ij48IUVOVElUWSBEb3VibGVSaWdodEFycm93ICImI3gyMUQyOyI%2BPCFFTlRJVFkgZEFyciAiJiN4MjFEMzsiPjwhRU5USVRZIERvd25hcnJvdyAiJiN4MjFEMzsiPjwhRU5USVRZIERvdWJsZURvd25BcnJvdyAiJiN4MjFEMzsiPjwhRU5USVRZIGhBcnIgIiYjeDIxRDQ7Ij48IUVOVElUWSBMZWZ0cmlnaHRhcnJvdyAiJiN4MjFENDsiPjwhRU5USVRZIERvdWJsZUxlZnRSaWdodEFycm93ICImI3gyMUQ0OyI%2BPCFFTlRJVFkgaWZmICImI3gyMUQ0OyI%2BPCFFTlRJVFkgdkFyciAiJiN4MjFENTsiPjwhRU5USVRZIFVwZG93bmFycm93ICImI3gyMUQ1OyI%2BPCFFTlRJVFkgRG91YmxlVXBEb3duQXJyb3cgIiYjeDIxRDU7Ij48IUVOVElUWSBud0FyciAiJiN4MjFENjsiPjwhRU5USVRZIG5lQXJyICImI3gyMUQ3OyI%2BPCFFTlRJVFkgc2VBcnIgIiYjeDIxRDg7Ij48IUVOVElUWSBzd0FyciAiJiN4MjFEOTsiPjwhRU5USVRZIGxBYXJyICImI3gyMURBOyI%2BPCFFTlRJVFkgTGxlZnRhcnJvdyAiJiN4MjFEQTsiPjwhRU5USVRZIHJBYXJyICImI3gyMURCOyI%2BPCFFTlRJVFkgUnJpZ2h0YXJyb3cgIiYjeDIxREI7Ij48IUVOVElUWSB6aWdyYXJyICImI3gyMUREOyI%2BPCFFTlRJVFkgbGFycmIgIiYjeDIxRTQ7Ij48IUVOVElUWSBMZWZ0QXJyb3dCYXIgIiYjeDIxRTQ7Ij48IUVOVElUWSByYXJyYiAiJiN4MjFFNTsiPjwhRU5USVRZIFJpZ2h0QXJyb3dCYXIgIiYjeDIxRTU7Ij48IUVOVElUWSBkdWFyciAiJiN4MjFGNTsiPjwhRU5USVRZIERvd25BcnJvd1VwQXJyb3cgIiYjeDIxRjU7Ij48IUVOVElUWSBsb2FyciAiJiN4MjFGRDsiPjwhRU5USVRZIHJvYXJyICImI3gyMUZFOyI%2BPCFFTlRJVFkgaG9hcnIgIiYjeDIxRkY7Ij48IUVOVElUWSBmb3JhbGwgIiYjeDIyMDA7Ij48IUVOVElUWSBGb3JBbGwgIiYjeDIyMDA7Ij48IUVOVElUWSBjb21wICImI3gyMjAxOyI%2BPCFFTlRJVFkgY29tcGxlbWVudCAiJiN4MjIwMTsiPjwhRU5USVRZIHBhcnQgIiYjeDIyMDI7Ij48IUVOVElUWSBQYXJ0aWFsRCAiJiN4MjIwMjsiPjwhRU5USVRZIG5wYXJ0ICImI3gyMjAyOyYjeDMzODsiPjwhRU5USVRZIGV4aXN0ICImI3gyMjAzOyI%2BPCFFTlRJVFkgRXhpc3RzICImI3gyMjAzOyI%2BPCFFTlRJVFkgbmV4aXN0ICImI3gyMjA0OyI%2BPCFFTlRJVFkgTm90RXhpc3RzICImI3gyMjA0OyI%2BPCFFTlRJVFkgbmV4aXN0cyAiJiN4MjIwNDsiPjwhRU5USVRZIGVtcHR5ICImI3gyMjA1OyI%2BPCFFTlRJVFkgZW1wdHlzZXQgIiYjeDIyMDU7Ij48IUVOVElUWSBlbXB0eXYgIiYjeDIyMDU7Ij48IUVOVElUWSB2YXJub3RoaW5nICImI3gyMjA1OyI%2BPCFFTlRJVFkgbmFibGEgIiYjeDIyMDc7Ij48IUVOVElUWSBEZWwgIiYjeDIyMDc7Ij48IUVOVElUWSBpc2luICImI3gyMjA4OyI%2BPCFFTlRJVFkgaXNpbnYgIiYjeDIyMDg7Ij48IUVOVElUWSBFbGVtZW50ICImI3gyMjA4OyI%2BPCFFTlRJVFkgaW4gIiYjeDIyMDg7Ij48IUVOVElUWSBub3RpbiAiJiN4MjIwOTsiPjwhRU5USVRZIE5vdEVsZW1lbnQgIiYjeDIyMDk7Ij48IUVOVElUWSBub3RpbnZhICImI3gyMjA5OyI%2BPCFFTlRJVFkgbml2ICImI3gyMjBCOyI%2BPCFFTlRJVFkgUmV2ZXJzZUVsZW1lbnQgIiYjeDIyMEI7Ij48IUVOVElUWSBuaSAiJiN4MjIwQjsiPjwhRU5USVRZIFN1Y2hUaGF0ICImI3gyMjBCOyI%2BPCFFTlRJVFkgbm90bmkgIiYjeDIyMEM7Ij48IUVOVElUWSBub3RuaXZhICImI3gyMjBDOyI%2BPCFFTlRJVFkgTm90UmV2ZXJzZUVsZW1lbnQgIiYjeDIyMEM7Ij48IUVOVElUWSBwcm9kICImI3gyMjBGOyI%2BPCFFTlRJVFkgUHJvZHVjdCAiJiN4MjIwRjsiPjwhRU5USVRZIGNvcHJvZCAiJiN4MjIxMDsiPjwhRU5USVRZIENvcHJvZHVjdCAiJiN4MjIxMDsiPjwhRU5USVRZIHN1bSAiJiN4MjIxMTsiPjwhRU5USVRZIFN1bSAiJiN4MjIxMTsiPjwhRU5USVRZIG1pbnVzICImI3gyMjEyOyI%2BPCFFTlRJVFkgbW5wbHVzICImI3gyMjEzOyI%2BPCFFTlRJVFkgbXAgIiYjeDIyMTM7Ij48IUVOVElUWSBNaW51c1BsdXMgIiYjeDIyMTM7Ij48IUVOVElUWSBwbHVzZG8gIiYjeDIyMTQ7Ij48IUVOVElUWSBkb3RwbHVzICImI3gyMjE0OyI%2BPCFFTlRJVFkgc2V0bW4gIiYjeDIyMTY7Ij48IUVOVElUWSBzZXRtaW51cyAiJiN4MjIxNjsiPjwhRU5USVRZIEJhY2tzbGFzaCAiJiN4MjIxNjsiPjwhRU5USVRZIHNzZXRtbiAiJiN4MjIxNjsiPjwhRU5USVRZIHNtYWxsc2V0bWludXMgIiYjeDIyMTY7Ij48IUVOVElUWSBsb3dhc3QgIiYjeDIyMTc7Ij48IUVOVElUWSBjb21wZm4gIiYjeDIyMTg7Ij48IUVOVElUWSBTbWFsbENpcmNsZSAiJiN4MjIxODsiPjwhRU5USVRZIHJhZGljICImI3gyMjFBOyI%2BPCFFTlRJVFkgU3FydCAiJiN4MjIxQTsiPjwhRU5USVRZIHByb3AgIiYjeDIyMUQ7Ij48IUVOVElUWSBwcm9wdG8gIiYjeDIyMUQ7Ij48IUVOVElUWSBQcm9wb3J0aW9uYWwgIiYjeDIyMUQ7Ij48IUVOVElUWSB2cHJvcCAiJiN4MjIxRDsiPjwhRU5USVRZIHZhcnByb3B0byAiJiN4MjIxRDsiPjwhRU5USVRZIGluZmluICImI3gyMjFFOyI%2BPCFFTlRJVFkgYW5ncnQgIiYjeDIyMUY7Ij48IUVOVElUWSBhbmcgIiYjeDIyMjA7Ij48IUVOVElUWSBhbmdsZSAiJiN4MjIyMDsiPjwhRU5USVRZIG5hbmcgIiYjeDIyMjA7JiN4MjBEMjsiPjwhRU5USVRZIGFuZ21zZCAiJiN4MjIyMTsiPjwhRU5USVRZIG1lYXN1cmVkYW5nbGUgIiYjeDIyMjE7Ij48IUVOVElUWSBhbmdzcGggIiYjeDIyMjI7Ij48IUVOVElUWSBtaWQgIiYjeDIyMjM7Ij48IUVOVElUWSBWZXJ0aWNhbEJhciAiJiN4MjIyMzsiPjwhRU5USVRZIHNtaWQgIiYjeDIyMjM7Ij48IUVOVElUWSBzaG9ydG1pZCAiJiN4MjIyMzsiPjwhRU5USVRZIG5taWQgIiYjeDIyMjQ7Ij48IUVOVElUWSBOb3RWZXJ0aWNhbEJhciAiJiN4MjIyNDsiPjwhRU5USVRZIG5zbWlkICImI3gyMjI0OyI%2BPCFFTlRJVFkgbnNob3J0bWlkICImI3gyMjI0OyI%2BPCFFTlRJVFkgcGFyICImI3gyMjI1OyI%2BPCFFTlRJVFkgcGFyYWxsZWwgIiYjeDIyMjU7Ij48IUVOVElUWSBEb3VibGVWZXJ0aWNhbEJhciAiJiN4MjIyNTsiPjwhRU5USVRZIHNwYXIgIiYjeDIyMjU7Ij48IUVOVElUWSBzaG9ydHBhcmFsbGVsICImI3gyMjI1OyI%2BPCFFTlRJVFkgbnBhciAiJiN4MjIyNjsiPjwhRU5USVRZIG5wYXJhbGxlbCAiJiN4MjIyNjsiPjwhRU5USVRZIE5vdERvdWJsZVZlcnRpY2FsQmFyICImI3gyMjI2OyI%2BPCFFTlRJVFkgbnNwYXIgIiYjeDIyMjY7Ij48IUVOVElUWSBuc2hvcnRwYXJhbGxlbCAiJiN4MjIyNjsiPjwhRU5USVRZIGFuZCAiJiN4MjIyNzsiPjwhRU5USVRZIHdlZGdlICImI3gyMjI3OyI%2BPCFFTlRJVFkgb3IgIiYjeDIyMjg7Ij48IUVOVElUWSB2ZWUgIiYjeDIyMjg7Ij48IUVOVElUWSBjYXAgIiYjeDIyMjk7Ij48IUVOVElUWSBjYXBzICImI3gyMjI5OyYjeEZFMDA7Ij48IUVOVElUWSBjdXAgIiYjeDIyMkE7Ij48IUVOVElUWSBjdXBzICImI3gyMjJBOyYjeEZFMDA7Ij48IUVOVElUWSBpbnQgIiYjeDIyMkI7Ij48IUVOVElUWSBJbnRlZ3JhbCAiJiN4MjIyQjsiPjwhRU5USVRZIEludCAiJiN4MjIyQzsiPjwhRU5USVRZIHRpbnQgIiYjeDIyMkQ7Ij48IUVOVElUWSBpaWludCAiJiN4MjIyRDsiPjwhRU5USVRZIGNvbmludCAiJiN4MjIyRTsiPjwhRU5USVRZIG9pbnQgIiYjeDIyMkU7Ij48IUVOVElUWSBDb250b3VySW50ZWdyYWwgIiYjeDIyMkU7Ij48IUVOVElUWSBDb25pbnQgIiYjeDIyMkY7Ij48IUVOVElUWSBEb3VibGVDb250b3VySW50ZWdyYWwgIiYjeDIyMkY7Ij48IUVOVElUWSBDY29uaW50ICImI3gyMjMwOyI%2BPCFFTlRJVFkgY3dpbnQgIiYjeDIyMzE7Ij48IUVOVElUWSBjd2NvbmludCAiJiN4MjIzMjsiPjwhRU5USVRZIENsb2Nrd2lzZUNvbnRvdXJJbnRlZ3JhbCAiJiN4MjIzMjsiPjwhRU5USVRZIGF3Y29uaW50ICImI3gyMjMzOyI%2BPCFFTlRJVFkgQ291bnRlckNsb2Nrd2lzZUNvbnRvdXJJbnRlZ3JhbCAiJiN4MjIzMzsiPjwhRU5USVRZIHRoZXJlNCAiJiN4MjIzNDsiPjwhRU5USVRZIHRoZXJlZm9yZSAiJiN4MjIzNDsiPjwhRU5USVRZIFRoZXJlZm9yZSAiJiN4MjIzNDsiPjwhRU5USVRZIGJlY2F1cyAiJiN4MjIzNTsiPjwhRU5USVRZIGJlY2F1c2UgIiYjeDIyMzU7Ij48IUVOVElUWSBCZWNhdXNlICImI3gyMjM1OyI%2BPCFFTlRJVFkgcmF0aW8gIiYjeDIyMzY7Ij48IUVOVElUWSBDb2xvbiAiJiN4MjIzNzsiPjwhRU5USVRZIFByb3BvcnRpb24gIiYjeDIyMzc7Ij48IUVOVElUWSBtaW51c2QgIiYjeDIyMzg7Ij48IUVOVElUWSBkb3RtaW51cyAiJiN4MjIzODsiPjwhRU5USVRZIG1ERG90ICImI3gyMjNBOyI%2BPCFFTlRJVFkgaG9tdGh0ICImI3gyMjNCOyI%2BPCFFTlRJVFkgc2ltICImI3gyMjNDOyI%2BPCFFTlRJVFkgVGlsZGUgIiYjeDIyM0M7Ij48IUVOVElUWSB0aGtzaW0gIiYjeDIyM0M7Ij48IUVOVElUWSB0aGlja3NpbSAiJiN4MjIzQzsiPjwhRU5USVRZIG52c2ltICImI3gyMjNDOyYjeDIwRDI7Ij48IUVOVElUWSBic2ltICImI3gyMjNEOyI%2BPCFFTlRJVFkgYmFja3NpbSAiJiN4MjIzRDsiPjwhRU5USVRZIHJhY2UgIiYjeDIyM0Q7JiN4MzMxOyI%2BPCFFTlRJVFkgYWMgIiYjeDIyM0U7Ij48IUVOVElUWSBtc3Rwb3MgIiYjeDIyM0U7Ij48IUVOVElUWSBhY0UgIiYjeDIyM0U7JiN4MzMzOyI%2BPCFFTlRJVFkgYWNkICImI3gyMjNGOyI%2BPCFFTlRJVFkgd3JlYXRoICImI3gyMjQwOyI%2BPCFFTlRJVFkgVmVydGljYWxUaWxkZSAiJiN4MjI0MDsiPjwhRU5USVRZIHdyICImI3gyMjQwOyI%2BPCFFTlRJVFkgbnNpbSAiJiN4MjI0MTsiPjwhRU5USVRZIE5vdFRpbGRlICImI3gyMjQxOyI%2BPCFFTlRJVFkgZXNpbSAiJiN4MjI0MjsiPjwhRU5USVRZIEVxdWFsVGlsZGUgIiYjeDIyNDI7Ij48IUVOVElUWSBlcXNpbSAiJiN4MjI0MjsiPjwhRU5USVRZIE5vdEVxdWFsVGlsZGUgIiYjeDIyNDI7JiN4MzM4OyI%2BPCFFTlRJVFkgbmVzaW0gIiYjeDIyNDI7JiN4MzM4OyI%2BPCFFTlRJVFkgc2ltZSAiJiN4MjI0MzsiPjwhRU5USVRZIFRpbGRlRXF1YWwgIiYjeDIyNDM7Ij48IUVOVElUWSBzaW1lcSAiJiN4MjI0MzsiPjwhRU5USVRZIG5zaW1lICImI3gyMjQ0OyI%2BPCFFTlRJVFkgbnNpbWVxICImI3gyMjQ0OyI%2BPCFFTlRJVFkgTm90VGlsZGVFcXVhbCAiJiN4MjI0NDsiPjwhRU5USVRZIGNvbmcgIiYjeDIyNDU7Ij48IUVOVElUWSBUaWxkZUZ1bGxFcXVhbCAiJiN4MjI0NTsiPjwhRU5USVRZIHNpbW5lICImI3gyMjQ2OyI%2BPCFFTlRJVFkgbmNvbmcgIiYjeDIyNDc7Ij48IUVOVElUWSBOb3RUaWxkZUZ1bGxFcXVhbCAiJiN4MjI0NzsiPjwhRU5USVRZIGFzeW1wICImI3gyMjQ4OyI%2BPCFFTlRJVFkgYXAgIiYjeDIyNDg7Ij48IUVOVElUWSBUaWxkZVRpbGRlICImI3gyMjQ4OyI%2BPCFFTlRJVFkgYXBwcm94ICImI3gyMjQ4OyI%2BPCFFTlRJVFkgdGhrYXAgIiYjeDIyNDg7Ij48IUVOVElUWSB0aGlja2FwcHJveCAiJiN4MjI0ODsiPjwhRU5USVRZIG5hcCAiJiN4MjI0OTsiPjwhRU5USVRZIE5vdFRpbGRlVGlsZGUgIiYjeDIyNDk7Ij48IUVOVElUWSBuYXBwcm94ICImI3gyMjQ5OyI%2BPCFFTlRJVFkgYXBlICImI3gyMjRBOyI%2BPCFFTlRJVFkgYXBwcm94ZXEgIiYjeDIyNEE7Ij48IUVOVElUWSBhcGlkICImI3gyMjRCOyI%2BPCFFTlRJVFkgbmFwaWQgIiYjeDIyNEI7JiN4MzM4OyI%2BPCFFTlRJVFkgYmNvbmcgIiYjeDIyNEM7Ij48IUVOVElUWSBiYWNrY29uZyAiJiN4MjI0QzsiPjwhRU5USVRZIGFzeW1wZXEgIiYjeDIyNEQ7Ij48IUVOVElUWSBDdXBDYXAgIiYjeDIyNEQ7Ij48IUVOVElUWSBudmFwICImI3gyMjREOyYjeDIwRDI7Ij48IUVOVElUWSBidW1wICImI3gyMjRFOyI%2BPCFFTlRJVFkgSHVtcERvd25IdW1wICImI3gyMjRFOyI%2BPCFFTlRJVFkgQnVtcGVxICImI3gyMjRFOyI%2BPCFFTlRJVFkgTm90SHVtcERvd25IdW1wICImI3gyMjRFOyYjeDMzODsiPjwhRU5USVRZIG5idW1wICImI3gyMjRFOyYjeDMzODsiPjwhRU5USVRZIGJ1bXBlICImI3gyMjRGOyI%2BPCFFTlRJVFkgSHVtcEVxdWFsICImI3gyMjRGOyI%2BPCFFTlRJVFkgYnVtcGVxICImI3gyMjRGOyI%2BPCFFTlRJVFkgbmJ1bXBlICImI3gyMjRGOyYjeDMzODsiPjwhRU5USVRZIE5vdEh1bXBFcXVhbCAiJiN4MjI0RjsmI3gzMzg7Ij48IUVOVElUWSBlc2RvdCAiJiN4MjI1MDsiPjwhRU5USVRZIERvdEVxdWFsICImI3gyMjUwOyI%2BPCFFTlRJVFkgZG90ZXEgIiYjeDIyNTA7Ij48IUVOVElUWSBuZWRvdCAiJiN4MjI1MDsmI3gzMzg7Ij48IUVOVElUWSBlRG90ICImI3gyMjUxOyI%2BPCFFTlRJVFkgZG90ZXFkb3QgIiYjeDIyNTE7Ij48IUVOVElUWSBlZkRvdCAiJiN4MjI1MjsiPjwhRU5USVRZIGZhbGxpbmdkb3RzZXEgIiYjeDIyNTI7Ij48IUVOVElUWSBlckRvdCAiJiN4MjI1MzsiPjwhRU5USVRZIHJpc2luZ2RvdHNlcSAiJiN4MjI1MzsiPjwhRU5USVRZIGNvbG9uZSAiJiN4MjI1NDsiPjwhRU5USVRZIGNvbG9uZXEgIiYjeDIyNTQ7Ij48IUVOVElUWSBBc3NpZ24gIiYjeDIyNTQ7Ij48IUVOVElUWSBlY29sb24gIiYjeDIyNTU7Ij48IUVOVElUWSBlcWNvbG9uICImI3gyMjU1OyI%2BPCFFTlRJVFkgZWNpciAiJiN4MjI1NjsiPjwhRU5USVRZIGVxY2lyYyAiJiN4MjI1NjsiPjwhRU5USVRZIGNpcmUgIiYjeDIyNTc7Ij48IUVOVElUWSBjaXJjZXEgIiYjeDIyNTc7Ij48IUVOVElUWSB3ZWRnZXEgIiYjeDIyNTk7Ij48IUVOVElUWSB2ZWVlcSAiJiN4MjI1QTsiPjwhRU5USVRZIHRyaWUgIiYjeDIyNUM7Ij48IUVOVElUWSB0cmlhbmdsZXEgIiYjeDIyNUM7Ij48IUVOVElUWSBlcXVlc3QgIiYjeDIyNUY7Ij48IUVOVElUWSBxdWVzdGVxICImI3gyMjVGOyI%2BPCFFTlRJVFkgbmUgIiYjeDIyNjA7Ij48IUVOVElUWSBOb3RFcXVhbCAiJiN4MjI2MDsiPjwhRU5USVRZIGVxdWl2ICImI3gyMjYxOyI%2BPCFFTlRJVFkgQ29uZ3J1ZW50ICImI3gyMjYxOyI%2BPCFFTlRJVFkgYm5lcXVpdiAiJiN4MjI2MTsmI3gyMEU1OyI%2BPCFFTlRJVFkgbmVxdWl2ICImI3gyMjYyOyI%2BPCFFTlRJVFkgTm90Q29uZ3J1ZW50ICImI3gyMjYyOyI%2BPCFFTlRJVFkgbGUgIiYjeDIyNjQ7Ij48IUVOVElUWSBsZXEgIiYjeDIyNjQ7Ij48IUVOVElUWSBudmxlICImI3gyMjY0OyYjeDIwRDI7Ij48IUVOVElUWSBnZSAiJiN4MjI2NTsiPjwhRU5USVRZIEdyZWF0ZXJFcXVhbCAiJiN4MjI2NTsiPjwhRU5USVRZIGdlcSAiJiN4MjI2NTsiPjwhRU5USVRZIG52Z2UgIiYjeDIyNjU7JiN4MjBEMjsiPjwhRU5USVRZIGxFICImI3gyMjY2OyI%2BPCFFTlRJVFkgTGVzc0Z1bGxFcXVhbCAiJiN4MjI2NjsiPjwhRU5USVRZIGxlcXEgIiYjeDIyNjY7Ij48IUVOVElUWSBubEUgIiYjeDIyNjY7JiN4MzM4OyI%2BPCFFTlRJVFkgbmxlcXEgIiYjeDIyNjY7JiN4MzM4OyI%2BPCFFTlRJVFkgZ0UgIiYjeDIyNjc7Ij48IUVOVElUWSBHcmVhdGVyRnVsbEVxdWFsICImI3gyMjY3OyI%2BPCFFTlRJVFkgZ2VxcSAiJiN4MjI2NzsiPjwhRU5USVRZIG5nRSAiJiN4MjI2NzsmI3gzMzg7Ij48IUVOVElUWSBuZ2VxcSAiJiN4MjI2NzsmI3gzMzg7Ij48IUVOVElUWSBOb3RHcmVhdGVyRnVsbEVxdWFsICImI3gyMjY3OyYjeDMzODsiPjwhRU5USVRZIGxuRSAiJiN4MjI2ODsiPjwhRU5USVRZIGxuZXFxICImI3gyMjY4OyI%2BPCFFTlRJVFkgbHZuRSAiJiN4MjI2ODsmI3hGRTAwOyI%2BPCFFTlRJVFkgbHZlcnRuZXFxICImI3gyMjY4OyYjeEZFMDA7Ij48IUVOVElUWSBnbkUgIiYjeDIyNjk7Ij48IUVOVElUWSBnbmVxcSAiJiN4MjI2OTsiPjwhRU5USVRZIGd2bkUgIiYjeDIyNjk7JiN4RkUwMDsiPjwhRU5USVRZIGd2ZXJ0bmVxcSAiJiN4MjI2OTsmI3hGRTAwOyI%2BPCFFTlRJVFkgTHQgIiYjeDIyNkE7Ij48IUVOVElUWSBOZXN0ZWRMZXNzTGVzcyAiJiN4MjI2QTsiPjwhRU5USVRZIGxsICImI3gyMjZBOyI%2BPCFFTlRJVFkgbkx0diAiJiN4MjI2QTsmI3gzMzg7Ij48IUVOVElUWSBOb3RMZXNzTGVzcyAiJiN4MjI2QTsmI3gzMzg7Ij48IUVOVElUWSBuTHQgIiYjeDIyNkE7JiN4MjBEMjsiPjwhRU5USVRZIEd0ICImI3gyMjZCOyI%2BPCFFTlRJVFkgTmVzdGVkR3JlYXRlckdyZWF0ZXIgIiYjeDIyNkI7Ij48IUVOVElUWSBnZyAiJiN4MjI2QjsiPjwhRU5USVRZIG5HdHYgIiYjeDIyNkI7JiN4MzM4OyI%2BPCFFTlRJVFkgTm90R3JlYXRlckdyZWF0ZXIgIiYjeDIyNkI7JiN4MzM4OyI%2BPCFFTlRJVFkgbkd0ICImI3gyMjZCOyYjeDIwRDI7Ij48IUVOVElUWSB0d2l4dCAiJiN4MjI2QzsiPjwhRU5USVRZIGJldHdlZW4gIiYjeDIyNkM7Ij48IUVOVElUWSBOb3RDdXBDYXAgIiYjeDIyNkQ7Ij48IUVOVElUWSBubHQgIiYjeDIyNkU7Ij48IUVOVElUWSBOb3RMZXNzICImI3gyMjZFOyI%2BPCFFTlRJVFkgbmxlc3MgIiYjeDIyNkU7Ij48IUVOVElUWSBuZ3QgIiYjeDIyNkY7Ij48IUVOVElUWSBOb3RHcmVhdGVyICImI3gyMjZGOyI%2BPCFFTlRJVFkgbmd0ciAiJiN4MjI2RjsiPjwhRU5USVRZIG5sZSAiJiN4MjI3MDsiPjwhRU5USVRZIE5vdExlc3NFcXVhbCAiJiN4MjI3MDsiPjwhRU5USVRZIG5sZXEgIiYjeDIyNzA7Ij48IUVOVElUWSBuZ2UgIiYjeDIyNzE7Ij48IUVOVElUWSBOb3RHcmVhdGVyRXF1YWwgIiYjeDIyNzE7Ij48IUVOVElUWSBuZ2VxICImI3gyMjcxOyI%2BPCFFTlRJVFkgbHNpbSAiJiN4MjI3MjsiPjwhRU5USVRZIExlc3NUaWxkZSAiJiN4MjI3MjsiPjwhRU5USVRZIGxlc3NzaW0gIiYjeDIyNzI7Ij48IUVOVElUWSBnc2ltICImI3gyMjczOyI%2BPCFFTlRJVFkgZ3Ryc2ltICImI3gyMjczOyI%2BPCFFTlRJVFkgR3JlYXRlclRpbGRlICImI3gyMjczOyI%2BPCFFTlRJVFkgbmxzaW0gIiYjeDIyNzQ7Ij48IUVOVElUWSBOb3RMZXNzVGlsZGUgIiYjeDIyNzQ7Ij48IUVOVElUWSBuZ3NpbSAiJiN4MjI3NTsiPjwhRU5USVRZIE5vdEdyZWF0ZXJUaWxkZSAiJiN4MjI3NTsiPjwhRU5USVRZIGxnICImI3gyMjc2OyI%2BPCFFTlRJVFkgbGVzc2d0ciAiJiN4MjI3NjsiPjwhRU5USVRZIExlc3NHcmVhdGVyICImI3gyMjc2OyI%2BPCFFTlRJVFkgZ2wgIiYjeDIyNzc7Ij48IUVOVElUWSBndHJsZXNzICImI3gyMjc3OyI%2BPCFFTlRJVFkgR3JlYXRlckxlc3MgIiYjeDIyNzc7Ij48IUVOVElUWSBudGxnICImI3gyMjc4OyI%2BPCFFTlRJVFkgTm90TGVzc0dyZWF0ZXIgIiYjeDIyNzg7Ij48IUVOVElUWSBudGdsICImI3gyMjc5OyI%2BPCFFTlRJVFkgTm90R3JlYXRlckxlc3MgIiYjeDIyNzk7Ij48IUVOVElUWSBwciAiJiN4MjI3QTsiPjwhRU5USVRZIFByZWNlZGVzICImI3gyMjdBOyI%2BPCFFTlRJVFkgcHJlYyAiJiN4MjI3QTsiPjwhRU5USVRZIHNjICImI3gyMjdCOyI%2BPCFFTlRJVFkgU3VjY2VlZHMgIiYjeDIyN0I7Ij48IUVOVElUWSBzdWNjICImI3gyMjdCOyI%2BPCFFTlRJVFkgcHJjdWUgIiYjeDIyN0M7Ij48IUVOVElUWSBQcmVjZWRlc1NsYW50RXF1YWwgIiYjeDIyN0M7Ij48IUVOVElUWSBwcmVjY3VybHllcSAiJiN4MjI3QzsiPjwhRU5USVRZIHNjY3VlICImI3gyMjdEOyI%2BPCFFTlRJVFkgU3VjY2VlZHNTbGFudEVxdWFsICImI3gyMjdEOyI%2BPCFFTlRJVFkgc3VjY2N1cmx5ZXEgIiYjeDIyN0Q7Ij48IUVOVElUWSBwcnNpbSAiJiN4MjI3RTsiPjwhRU5USVRZIHByZWNzaW0gIiYjeDIyN0U7Ij48IUVOVElUWSBQcmVjZWRlc1RpbGRlICImI3gyMjdFOyI%2BPCFFTlRJVFkgc2NzaW0gIiYjeDIyN0Y7Ij48IUVOVElUWSBzdWNjc2ltICImI3gyMjdGOyI%2BPCFFTlRJVFkgU3VjY2VlZHNUaWxkZSAiJiN4MjI3RjsiPjwhRU5USVRZIE5vdFN1Y2NlZWRzVGlsZGUgIiYjeDIyN0Y7JiN4MzM4OyI%2BPCFFTlRJVFkgbnByICImI3gyMjgwOyI%2BPCFFTlRJVFkgbnByZWMgIiYjeDIyODA7Ij48IUVOVElUWSBOb3RQcmVjZWRlcyAiJiN4MjI4MDsiPjwhRU5USVRZIG5zYyAiJiN4MjI4MTsiPjwhRU5USVRZIG5zdWNjICImI3gyMjgxOyI%2BPCFFTlRJVFkgTm90U3VjY2VlZHMgIiYjeDIyODE7Ij48IUVOVElUWSBzdWIgIiYjeDIyODI7Ij48IUVOVElUWSBzdWJzZXQgIiYjeDIyODI7Ij48IUVOVElUWSB2bnN1YiAiJiN4MjI4MjsmI3gyMEQyOyI%2BPCFFTlRJVFkgbnN1YnNldCAiJiN4MjI4MjsmI3gyMEQyOyI%2BPCFFTlRJVFkgTm90U3Vic2V0ICImI3gyMjgyOyYjeDIwRDI7Ij48IUVOVElUWSBzdXAgIiYjeDIyODM7Ij48IUVOVElUWSBzdXBzZXQgIiYjeDIyODM7Ij48IUVOVElUWSBTdXBlcnNldCAiJiN4MjI4MzsiPjwhRU5USVRZIHZuc3VwICImI3gyMjgzOyYjeDIwRDI7Ij48IUVOVElUWSBuc3Vwc2V0ICImI3gyMjgzOyYjeDIwRDI7Ij48IUVOVElUWSBOb3RTdXBlcnNldCAiJiN4MjI4MzsmI3gyMEQyOyI%2BPCFFTlRJVFkgbnN1YiAiJiN4MjI4NDsiPjwhRU5USVRZIG5zdXAgIiYjeDIyODU7Ij48IUVOVElUWSBzdWJlICImI3gyMjg2OyI%2BPCFFTlRJVFkgU3Vic2V0RXF1YWwgIiYjeDIyODY7Ij48IUVOVElUWSBzdWJzZXRlcSAiJiN4MjI4NjsiPjwhRU5USVRZIHN1cGUgIiYjeDIyODc7Ij48IUVOVElUWSBzdXBzZXRlcSAiJiN4MjI4NzsiPjwhRU5USVRZIFN1cGVyc2V0RXF1YWwgIiYjeDIyODc7Ij48IUVOVElUWSBuc3ViZSAiJiN4MjI4ODsiPjwhRU5USVRZIG5zdWJzZXRlcSAiJiN4MjI4ODsiPjwhRU5USVRZIE5vdFN1YnNldEVxdWFsICImI3gyMjg4OyI%2BPCFFTlRJVFkgbnN1cGUgIiYjeDIyODk7Ij48IUVOVElUWSBuc3Vwc2V0ZXEgIiYjeDIyODk7Ij48IUVOVElUWSBOb3RTdXBlcnNldEVxdWFsICImI3gyMjg5OyI%2BPCFFTlRJVFkgc3VibmUgIiYjeDIyOEE7Ij48IUVOVElUWSBzdWJzZXRuZXEgIiYjeDIyOEE7Ij48IUVOVElUWSB2c3VibmUgIiYjeDIyOEE7JiN4RkUwMDsiPjwhRU5USVRZIHZhcnN1YnNldG5lcSAiJiN4MjI4QTsmI3hGRTAwOyI%2BPCFFTlRJVFkgc3VwbmUgIiYjeDIyOEI7Ij48IUVOVElUWSBzdXBzZXRuZXEgIiYjeDIyOEI7Ij48IUVOVElUWSB2c3VwbmUgIiYjeDIyOEI7JiN4RkUwMDsiPjwhRU5USVRZIHZhcnN1cHNldG5lcSAiJiN4MjI4QjsmI3hGRTAwOyI%2BPCFFTlRJVFkgY3VwZG90ICImI3gyMjhEOyI%2BPCFFTlRJVFkgdXBsdXMgIiYjeDIyOEU7Ij48IUVOVElUWSBVbmlvblBsdXMgIiYjeDIyOEU7Ij48IUVOVElUWSBzcXN1YiAiJiN4MjI4RjsiPjwhRU5USVRZIFNxdWFyZVN1YnNldCAiJiN4MjI4RjsiPjwhRU5USVRZIHNxc3Vic2V0ICImI3gyMjhGOyI%2BPCFFTlRJVFkgTm90U3F1YXJlU3Vic2V0ICImI3gyMjhGOyYjeDMzODsiPjwhRU5USVRZIHNxc3VwICImI3gyMjkwOyI%2BPCFFTlRJVFkgU3F1YXJlU3VwZXJzZXQgIiYjeDIyOTA7Ij48IUVOVElUWSBzcXN1cHNldCAiJiN4MjI5MDsiPjwhRU5USVRZIE5vdFNxdWFyZVN1cGVyc2V0ICImI3gyMjkwOyYjeDMzODsiPjwhRU5USVRZIHNxc3ViZSAiJiN4MjI5MTsiPjwhRU5USVRZIFNxdWFyZVN1YnNldEVxdWFsICImI3gyMjkxOyI%2BPCFFTlRJVFkgc3FzdWJzZXRlcSAiJiN4MjI5MTsiPjwhRU5USVRZIHNxc3VwZSAiJiN4MjI5MjsiPjwhRU5USVRZIFNxdWFyZVN1cGVyc2V0RXF1YWwgIiYjeDIyOTI7Ij48IUVOVElUWSBzcXN1cHNldGVxICImI3gyMjkyOyI%2BPCFFTlRJVFkgc3FjYXAgIiYjeDIyOTM7Ij48IUVOVElUWSBTcXVhcmVJbnRlcnNlY3Rpb24gIiYjeDIyOTM7Ij48IUVOVElUWSBzcWNhcHMgIiYjeDIyOTM7JiN4RkUwMDsiPjwhRU5USVRZIHNxY3VwICImI3gyMjk0OyI%2BPCFFTlRJVFkgU3F1YXJlVW5pb24gIiYjeDIyOTQ7Ij48IUVOVElUWSBzcWN1cHMgIiYjeDIyOTQ7JiN4RkUwMDsiPjwhRU5USVRZIG9wbHVzICImI3gyMjk1OyI%2BPCFFTlRJVFkgQ2lyY2xlUGx1cyAiJiN4MjI5NTsiPjwhRU5USVRZIG9taW51cyAiJiN4MjI5NjsiPjwhRU5USVRZIENpcmNsZU1pbnVzICImI3gyMjk2OyI%2BPCFFTlRJVFkgb3RpbWVzICImI3gyMjk3OyI%2BPCFFTlRJVFkgQ2lyY2xlVGltZXMgIiYjeDIyOTc7Ij48IUVOVElUWSBvc29sICImI3gyMjk4OyI%2BPCFFTlRJVFkgb2RvdCAiJiN4MjI5OTsiPjwhRU5USVRZIENpcmNsZURvdCAiJiN4MjI5OTsiPjwhRU5USVRZIG9jaXIgIiYjeDIyOUE7Ij48IUVOVElUWSBjaXJjbGVkY2lyYyAiJiN4MjI5QTsiPjwhRU5USVRZIG9hc3QgIiYjeDIyOUI7Ij48IUVOVElUWSBjaXJjbGVkYXN0ICImI3gyMjlCOyI%2BPCFFTlRJVFkgb2Rhc2ggIiYjeDIyOUQ7Ij48IUVOVElUWSBjaXJjbGVkZGFzaCAiJiN4MjI5RDsiPjwhRU5USVRZIHBsdXNiICImI3gyMjlFOyI%2BPCFFTlRJVFkgYm94cGx1cyAiJiN4MjI5RTsiPjwhRU5USVRZIG1pbnVzYiAiJiN4MjI5RjsiPjwhRU5USVRZIGJveG1pbnVzICImI3gyMjlGOyI%2BPCFFTlRJVFkgdGltZXNiICImI3gyMkEwOyI%2BPCFFTlRJVFkgYm94dGltZXMgIiYjeDIyQTA7Ij48IUVOVElUWSBzZG90YiAiJiN4MjJBMTsiPjwhRU5USVRZIGRvdHNxdWFyZSAiJiN4MjJBMTsiPjwhRU5USVRZIHZkYXNoICImI3gyMkEyOyI%2BPCFFTlRJVFkgUmlnaHRUZWUgIiYjeDIyQTI7Ij48IUVOVElUWSBkYXNodiAiJiN4MjJBMzsiPjwhRU5USVRZIExlZnRUZWUgIiYjeDIyQTM7Ij48IUVOVElUWSB0b3AgIiYjeDIyQTQ7Ij48IUVOVElUWSBEb3duVGVlICImI3gyMkE0OyI%2BPCFFTlRJVFkgYm90dG9tICImI3gyMkE1OyI%2BPCFFTlRJVFkgYm90ICImI3gyMkE1OyI%2BPCFFTlRJVFkgcGVycCAiJiN4MjJBNTsiPjwhRU5USVRZIFVwVGVlICImI3gyMkE1OyI%2BPCFFTlRJVFkgbW9kZWxzICImI3gyMkE3OyI%2BPCFFTlRJVFkgdkRhc2ggIiYjeDIyQTg7Ij48IUVOVElUWSBEb3VibGVSaWdodFRlZSAiJiN4MjJBODsiPjwhRU5USVRZIFZkYXNoICImI3gyMkE5OyI%2BPCFFTlRJVFkgVnZkYXNoICImI3gyMkFBOyI%2BPCFFTlRJVFkgVkRhc2ggIiYjeDIyQUI7Ij48IUVOVElUWSBudmRhc2ggIiYjeDIyQUM7Ij48IUVOVElUWSBudkRhc2ggIiYjeDIyQUQ7Ij48IUVOVElUWSBuVmRhc2ggIiYjeDIyQUU7Ij48IUVOVElUWSBuVkRhc2ggIiYjeDIyQUY7Ij48IUVOVElUWSBwcnVyZWwgIiYjeDIyQjA7Ij48IUVOVElUWSB2bHRyaSAiJiN4MjJCMjsiPjwhRU5USVRZIHZhcnRyaWFuZ2xlbGVmdCAiJiN4MjJCMjsiPjwhRU5USVRZIExlZnRUcmlhbmdsZSAiJiN4MjJCMjsiPjwhRU5USVRZIHZydHJpICImI3gyMkIzOyI%2BPCFFTlRJVFkgdmFydHJpYW5nbGVyaWdodCAiJiN4MjJCMzsiPjwhRU5USVRZIFJpZ2h0VHJpYW5nbGUgIiYjeDIyQjM7Ij48IUVOVElUWSBsdHJpZSAiJiN4MjJCNDsiPjwhRU5USVRZIHRyaWFuZ2xlbGVmdGVxICImI3gyMkI0OyI%2BPCFFTlRJVFkgTGVmdFRyaWFuZ2xlRXF1YWwgIiYjeDIyQjQ7Ij48IUVOVElUWSBudmx0cmllICImI3gyMkI0OyYjeDIwRDI7Ij48IUVOVElUWSBydHJpZSAiJiN4MjJCNTsiPjwhRU5USVRZIHRyaWFuZ2xlcmlnaHRlcSAiJiN4MjJCNTsiPjwhRU5USVRZIFJpZ2h0VHJpYW5nbGVFcXVhbCAiJiN4MjJCNTsiPjwhRU5USVRZIG52cnRyaWUgIiYjeDIyQjU7JiN4MjBEMjsiPjwhRU5USVRZIG9yaWdvZiAiJiN4MjJCNjsiPjwhRU5USVRZIGltb2YgIiYjeDIyQjc7Ij48IUVOVElUWSBtdW1hcCAiJiN4MjJCODsiPjwhRU5USVRZIG11bHRpbWFwICImI3gyMkI4OyI%2BPCFFTlRJVFkgaGVyY29uICImI3gyMkI5OyI%2BPCFFTlRJVFkgaW50Y2FsICImI3gyMkJBOyI%2BPCFFTlRJVFkgaW50ZXJjYWwgIiYjeDIyQkE7Ij48IUVOVElUWSB2ZWViYXIgIiYjeDIyQkI7Ij48IUVOVElUWSBiYXJ2ZWUgIiYjeDIyQkQ7Ij48IUVOVElUWSBhbmdydHZiICImI3gyMkJFOyI%2BPCFFTlRJVFkgbHJ0cmkgIiYjeDIyQkY7Ij48IUVOVElUWSB4d2VkZ2UgIiYjeDIyQzA7Ij48IUVOVElUWSBXZWRnZSAiJiN4MjJDMDsiPjwhRU5USVRZIGJpZ3dlZGdlICImI3gyMkMwOyI%2BPCFFTlRJVFkgeHZlZSAiJiN4MjJDMTsiPjwhRU5USVRZIFZlZSAiJiN4MjJDMTsiPjwhRU5USVRZIGJpZ3ZlZSAiJiN4MjJDMTsiPjwhRU5USVRZIHhjYXAgIiYjeDIyQzI7Ij48IUVOVElUWSBJbnRlcnNlY3Rpb24gIiYjeDIyQzI7Ij48IUVOVElUWSBiaWdjYXAgIiYjeDIyQzI7Ij48IUVOVElUWSB4Y3VwICImI3gyMkMzOyI%2BPCFFTlRJVFkgVW5pb24gIiYjeDIyQzM7Ij48IUVOVElUWSBiaWdjdXAgIiYjeDIyQzM7Ij48IUVOVElUWSBkaWFtICImI3gyMkM0OyI%2BPCFFTlRJVFkgZGlhbW9uZCAiJiN4MjJDNDsiPjwhRU5USVRZIERpYW1vbmQgIiYjeDIyQzQ7Ij48IUVOVElUWSBzZG90ICImI3gyMkM1OyI%2BPCFFTlRJVFkgc3N0YXJmICImI3gyMkM2OyI%2BPCFFTlRJVFkgU3RhciAiJiN4MjJDNjsiPjwhRU5USVRZIGRpdm9ueCAiJiN4MjJDNzsiPjwhRU5USVRZIGRpdmlkZW9udGltZXMgIiYjeDIyQzc7Ij48IUVOVElUWSBib3d0aWUgIiYjeDIyQzg7Ij48IUVOVElUWSBsdGltZXMgIiYjeDIyQzk7Ij48IUVOVElUWSBydGltZXMgIiYjeDIyQ0E7Ij48IUVOVElUWSBsdGhyZWUgIiYjeDIyQ0I7Ij48IUVOVElUWSBsZWZ0dGhyZWV0aW1lcyAiJiN4MjJDQjsiPjwhRU5USVRZIHJ0aHJlZSAiJiN4MjJDQzsiPjwhRU5USVRZIHJpZ2h0dGhyZWV0aW1lcyAiJiN4MjJDQzsiPjwhRU5USVRZIGJzaW1lICImI3gyMkNEOyI%2BPCFFTlRJVFkgYmFja3NpbWVxICImI3gyMkNEOyI%2BPCFFTlRJVFkgY3V2ZWUgIiYjeDIyQ0U7Ij48IUVOVElUWSBjdXJseXZlZSAiJiN4MjJDRTsiPjwhRU5USVRZIGN1d2VkICImI3gyMkNGOyI%2BPCFFTlRJVFkgY3VybHl3ZWRnZSAiJiN4MjJDRjsiPjwhRU5USVRZIFN1YiAiJiN4MjJEMDsiPjwhRU5USVRZIFN1YnNldCAiJiN4MjJEMDsiPjwhRU5USVRZIFN1cCAiJiN4MjJEMTsiPjwhRU5USVRZIFN1cHNldCAiJiN4MjJEMTsiPjwhRU5USVRZIENhcCAiJiN4MjJEMjsiPjwhRU5USVRZIEN1cCAiJiN4MjJEMzsiPjwhRU5USVRZIGZvcmsgIiYjeDIyRDQ7Ij48IUVOVElUWSBwaXRjaGZvcmsgIiYjeDIyRDQ7Ij48IUVOVElUWSBlcGFyICImI3gyMkQ1OyI%2BPCFFTlRJVFkgbHRkb3QgIiYjeDIyRDY7Ij48IUVOVElUWSBsZXNzZG90ICImI3gyMkQ2OyI%2BPCFFTlRJVFkgZ3Rkb3QgIiYjeDIyRDc7Ij48IUVOVElUWSBndHJkb3QgIiYjeDIyRDc7Ij48IUVOVElUWSBMbCAiJiN4MjJEODsiPjwhRU5USVRZIG5MbCAiJiN4MjJEODsmI3gzMzg7Ij48IUVOVElUWSBHZyAiJiN4MjJEOTsiPjwhRU5USVRZIGdnZyAiJiN4MjJEOTsiPjwhRU5USVRZIG5HZyAiJiN4MjJEOTsmI3gzMzg7Ij48IUVOVElUWSBsZWcgIiYjeDIyREE7Ij48IUVOVElUWSBMZXNzRXF1YWxHcmVhdGVyICImI3gyMkRBOyI%2BPCFFTlRJVFkgbGVzc2VxZ3RyICImI3gyMkRBOyI%2BPCFFTlRJVFkgbGVzZyAiJiN4MjJEQTsmI3hGRTAwOyI%2BPCFFTlRJVFkgZ2VsICImI3gyMkRCOyI%2BPCFFTlRJVFkgZ3RyZXFsZXNzICImI3gyMkRCOyI%2BPCFFTlRJVFkgR3JlYXRlckVxdWFsTGVzcyAiJiN4MjJEQjsiPjwhRU5USVRZIGdlc2wgIiYjeDIyREI7JiN4RkUwMDsiPjwhRU5USVRZIGN1ZXByICImI3gyMkRFOyI%2BPCFFTlRJVFkgY3VybHllcXByZWMgIiYjeDIyREU7Ij48IUVOVElUWSBjdWVzYyAiJiN4MjJERjsiPjwhRU5USVRZIGN1cmx5ZXFzdWNjICImI3gyMkRGOyI%2BPCFFTlRJVFkgbnByY3VlICImI3gyMkUwOyI%2BPCFFTlRJVFkgTm90UHJlY2VkZXNTbGFudEVxdWFsICImI3gyMkUwOyI%2BPCFFTlRJVFkgbnNjY3VlICImI3gyMkUxOyI%2BPCFFTlRJVFkgTm90U3VjY2VlZHNTbGFudEVxdWFsICImI3gyMkUxOyI%2BPCFFTlRJVFkgbnNxc3ViZSAiJiN4MjJFMjsiPjwhRU5USVRZIE5vdFNxdWFyZVN1YnNldEVxdWFsICImI3gyMkUyOyI%2BPCFFTlRJVFkgbnNxc3VwZSAiJiN4MjJFMzsiPjwhRU5USVRZIE5vdFNxdWFyZVN1cGVyc2V0RXF1YWwgIiYjeDIyRTM7Ij48IUVOVElUWSBsbnNpbSAiJiN4MjJFNjsiPjwhRU5USVRZIGduc2ltICImI3gyMkU3OyI%2BPCFFTlRJVFkgcHJuc2ltICImI3gyMkU4OyI%2BPCFFTlRJVFkgcHJlY25zaW0gIiYjeDIyRTg7Ij48IUVOVElUWSBzY25zaW0gIiYjeDIyRTk7Ij48IUVOVElUWSBzdWNjbnNpbSAiJiN4MjJFOTsiPjwhRU5USVRZIG5sdHJpICImI3gyMkVBOyI%2BPCFFTlRJVFkgbnRyaWFuZ2xlbGVmdCAiJiN4MjJFQTsiPjwhRU5USVRZIE5vdExlZnRUcmlhbmdsZSAiJiN4MjJFQTsiPjwhRU5USVRZIG5ydHJpICImI3gyMkVCOyI%2BPCFFTlRJVFkgbnRyaWFuZ2xlcmlnaHQgIiYjeDIyRUI7Ij48IUVOVElUWSBOb3RSaWdodFRyaWFuZ2xlICImI3gyMkVCOyI%2BPCFFTlRJVFkgbmx0cmllICImI3gyMkVDOyI%2BPCFFTlRJVFkgbnRyaWFuZ2xlbGVmdGVxICImI3gyMkVDOyI%2BPCFFTlRJVFkgTm90TGVmdFRyaWFuZ2xlRXF1YWwgIiYjeDIyRUM7Ij48IUVOVElUWSBucnRyaWUgIiYjeDIyRUQ7Ij48IUVOVElUWSBudHJpYW5nbGVyaWdodGVxICImI3gyMkVEOyI%2BPCFFTlRJVFkgTm90UmlnaHRUcmlhbmdsZUVxdWFsICImI3gyMkVEOyI%2BPCFFTlRJVFkgdmVsbGlwICImI3gyMkVFOyI%2BPCFFTlRJVFkgY3Rkb3QgIiYjeDIyRUY7Ij48IUVOVElUWSB1dGRvdCAiJiN4MjJGMDsiPjwhRU5USVRZIGR0ZG90ICImI3gyMkYxOyI%2BPCFFTlRJVFkgZGlzaW4gIiYjeDIyRjI7Ij48IUVOVElUWSBpc2luc3YgIiYjeDIyRjM7Ij48IUVOVElUWSBpc2lucyAiJiN4MjJGNDsiPjwhRU5USVRZIGlzaW5kb3QgIiYjeDIyRjU7Ij48IUVOVElUWSBub3RpbmRvdCAiJiN4MjJGNTsmI3gzMzg7Ij48IUVOVElUWSBub3RpbnZjICImI3gyMkY2OyI%2BPCFFTlRJVFkgbm90aW52YiAiJiN4MjJGNzsiPjwhRU5USVRZIGlzaW5FICImI3gyMkY5OyI%2BPCFFTlRJVFkgbm90aW5FICImI3gyMkY5OyYjeDMzODsiPjwhRU5USVRZIG5pc2QgIiYjeDIyRkE7Ij48IUVOVElUWSB4bmlzICImI3gyMkZCOyI%2BPCFFTlRJVFkgbmlzICImI3gyMkZDOyI%2BPCFFTlRJVFkgbm90bml2YyAiJiN4MjJGRDsiPjwhRU5USVRZIG5vdG5pdmIgIiYjeDIyRkU7Ij48IUVOVElUWSBiYXJ3ZWQgIiYjeDIzMDU7Ij48IUVOVElUWSBiYXJ3ZWRnZSAiJiN4MjMwNTsiPjwhRU5USVRZIEJhcndlZCAiJiN4MjMwNjsiPjwhRU5USVRZIGRvdWJsZWJhcndlZGdlICImI3gyMzA2OyI%2BPCFFTlRJVFkgbGNlaWwgIiYjeDIzMDg7Ij48IUVOVElUWSBMZWZ0Q2VpbGluZyAiJiN4MjMwODsiPjwhRU5USVRZIHJjZWlsICImI3gyMzA5OyI%2BPCFFTlRJVFkgUmlnaHRDZWlsaW5nICImI3gyMzA5OyI%2BPCFFTlRJVFkgbGZsb29yICImI3gyMzBBOyI%2BPCFFTlRJVFkgTGVmdEZsb29yICImI3gyMzBBOyI%2BPCFFTlRJVFkgcmZsb29yICImI3gyMzBCOyI%2BPCFFTlRJVFkgUmlnaHRGbG9vciAiJiN4MjMwQjsiPjwhRU5USVRZIGRyY3JvcCAiJiN4MjMwQzsiPjwhRU5USVRZIGRsY3JvcCAiJiN4MjMwRDsiPjwhRU5USVRZIHVyY3JvcCAiJiN4MjMwRTsiPjwhRU5USVRZIHVsY3JvcCAiJiN4MjMwRjsiPjwhRU5USVRZIGJub3QgIiYjeDIzMTA7Ij48IUVOVElUWSBwcm9mbGluZSAiJiN4MjMxMjsiPjwhRU5USVRZIHByb2ZzdXJmICImI3gyMzEzOyI%2BPCFFTlRJVFkgdGVscmVjICImI3gyMzE1OyI%2BPCFFTlRJVFkgdGFyZ2V0ICImI3gyMzE2OyI%2BPCFFTlRJVFkgdWxjb3JuICImI3gyMzFDOyI%2BPCFFTlRJVFkgdWxjb3JuZXIgIiYjeDIzMUM7Ij48IUVOVElUWSB1cmNvcm4gIiYjeDIzMUQ7Ij48IUVOVElUWSB1cmNvcm5lciAiJiN4MjMxRDsiPjwhRU5USVRZIGRsY29ybiAiJiN4MjMxRTsiPjwhRU5USVRZIGxsY29ybmVyICImI3gyMzFFOyI%2BPCFFTlRJVFkgZHJjb3JuICImI3gyMzFGOyI%2BPCFFTlRJVFkgbHJjb3JuZXIgIiYjeDIzMUY7Ij48IUVOVElUWSBmcm93biAiJiN4MjMyMjsiPjwhRU5USVRZIHNmcm93biAiJiN4MjMyMjsiPjwhRU5USVRZIHNtaWxlICImI3gyMzIzOyI%2BPCFFTlRJVFkgc3NtaWxlICImI3gyMzIzOyI%2BPCFFTlRJVFkgY3lsY3R5ICImI3gyMzJEOyI%2BPCFFTlRJVFkgcHJvZmFsYXIgIiYjeDIzMkU7Ij48IUVOVElUWSB0b3Bib3QgIiYjeDIzMzY7Ij48IUVOVElUWSBvdmJhciAiJiN4MjMzRDsiPjwhRU5USVRZIHNvbGJhciAiJiN4MjMzRjsiPjwhRU5USVRZIGFuZ3phcnIgIiYjeDIzN0M7Ij48IUVOVElUWSBsbW91c3QgIiYjeDIzQjA7Ij48IUVOVElUWSBsbW91c3RhY2hlICImI3gyM0IwOyI%2BPCFFTlRJVFkgcm1vdXN0ICImI3gyM0IxOyI%2BPCFFTlRJVFkgcm1vdXN0YWNoZSAiJiN4MjNCMTsiPjwhRU5USVRZIHRicmsgIiYjeDIzQjQ7Ij48IUVOVElUWSBPdmVyQnJhY2tldCAiJiN4MjNCNDsiPjwhRU5USVRZIGJicmsgIiYjeDIzQjU7Ij48IUVOVElUWSBVbmRlckJyYWNrZXQgIiYjeDIzQjU7Ij48IUVOVElUWSBiYnJrdGJyayAiJiN4MjNCNjsiPjwhRU5USVRZIE92ZXJQYXJlbnRoZXNpcyAiJiN4MjNEQzsiPjwhRU5USVRZIFVuZGVyUGFyZW50aGVzaXMgIiYjeDIzREQ7Ij48IUVOVElUWSBPdmVyQnJhY2UgIiYjeDIzREU7Ij48IUVOVElUWSBVbmRlckJyYWNlICImI3gyM0RGOyI%2BPCFFTlRJVFkgdHJwZXppdW0gIiYjeDIzRTI7Ij48IUVOVElUWSBlbGludGVycyAiJiN4MjNFNzsiPjwhRU5USVRZIGJsYW5rICImI3gyNDIzOyI%2BPCFFTlRJVFkgb1MgIiYjeDI0Qzg7Ij48IUVOVElUWSBjaXJjbGVkUyAiJiN4MjRDODsiPjwhRU5USVRZIGJveGggIiYjeDI1MDA7Ij48IUVOVElUWSBIb3Jpem9udGFsTGluZSAiJiN4MjUwMDsiPjwhRU5USVRZIGJveHYgIiYjeDI1MDI7Ij48IUVOVElUWSBib3hkciAiJiN4MjUwQzsiPjwhRU5USVRZIGJveGRsICImI3gyNTEwOyI%2BPCFFTlRJVFkgYm94dXIgIiYjeDI1MTQ7Ij48IUVOVElUWSBib3h1bCAiJiN4MjUxODsiPjwhRU5USVRZIGJveHZyICImI3gyNTFDOyI%2BPCFFTlRJVFkgYm94dmwgIiYjeDI1MjQ7Ij48IUVOVElUWSBib3hoZCAiJiN4MjUyQzsiPjwhRU5USVRZIGJveGh1ICImI3gyNTM0OyI%2BPCFFTlRJVFkgYm94dmggIiYjeDI1M0M7Ij48IUVOVElUWSBib3hIICImI3gyNTUwOyI%2BPCFFTlRJVFkgYm94ViAiJiN4MjU1MTsiPjwhRU5USVRZIGJveGRSICImI3gyNTUyOyI%2BPCFFTlRJVFkgYm94RHIgIiYjeDI1NTM7Ij48IUVOVElUWSBib3hEUiAiJiN4MjU1NDsiPjwhRU5USVRZIGJveGRMICImI3gyNTU1OyI%2BPCFFTlRJVFkgYm94RGwgIiYjeDI1NTY7Ij48IUVOVElUWSBib3hETCAiJiN4MjU1NzsiPjwhRU5USVRZIGJveHVSICImI3gyNTU4OyI%2BPCFFTlRJVFkgYm94VXIgIiYjeDI1NTk7Ij48IUVOVElUWSBib3hVUiAiJiN4MjU1QTsiPjwhRU5USVRZIGJveHVMICImI3gyNTVCOyI%2BPCFFTlRJVFkgYm94VWwgIiYjeDI1NUM7Ij48IUVOVElUWSBib3hVTCAiJiN4MjU1RDsiPjwhRU5USVRZIGJveHZSICImI3gyNTVFOyI%2BPCFFTlRJVFkgYm94VnIgIiYjeDI1NUY7Ij48IUVOVElUWSBib3hWUiAiJiN4MjU2MDsiPjwhRU5USVRZIGJveHZMICImI3gyNTYxOyI%2BPCFFTlRJVFkgYm94VmwgIiYjeDI1NjI7Ij48IUVOVElUWSBib3hWTCAiJiN4MjU2MzsiPjwhRU5USVRZIGJveEhkICImI3gyNTY0OyI%2BPCFFTlRJVFkgYm94aEQgIiYjeDI1NjU7Ij48IUVOVElUWSBib3hIRCAiJiN4MjU2NjsiPjwhRU5USVRZIGJveEh1ICImI3gyNTY3OyI%2BPCFFTlRJVFkgYm94aFUgIiYjeDI1Njg7Ij48IUVOVElUWSBib3hIVSAiJiN4MjU2OTsiPjwhRU5USVRZIGJveHZIICImI3gyNTZBOyI%2BPCFFTlRJVFkgYm94VmggIiYjeDI1NkI7Ij48IUVOVElUWSBib3hWSCAiJiN4MjU2QzsiPjwhRU5USVRZIHVoYmxrICImI3gyNTgwOyI%2BPCFFTlRJVFkgbGhibGsgIiYjeDI1ODQ7Ij48IUVOVElUWSBibG9jayAiJiN4MjU4ODsiPjwhRU5USVRZIGJsazE0ICImI3gyNTkxOyI%2BPCFFTlRJVFkgYmxrMTIgIiYjeDI1OTI7Ij48IUVOVElUWSBibGszNCAiJiN4MjU5MzsiPjwhRU5USVRZIHNxdSAiJiN4MjVBMTsiPjwhRU5USVRZIHNxdWFyZSAiJiN4MjVBMTsiPjwhRU5USVRZIFNxdWFyZSAiJiN4MjVBMTsiPjwhRU5USVRZIHNxdWYgIiYjeDI1QUE7Ij48IUVOVElUWSBzcXVhcmYgIiYjeDI1QUE7Ij48IUVOVElUWSBibGFja3NxdWFyZSAiJiN4MjVBQTsiPjwhRU5USVRZIEZpbGxlZFZlcnlTbWFsbFNxdWFyZSAiJiN4MjVBQTsiPjwhRU5USVRZIEVtcHR5VmVyeVNtYWxsU3F1YXJlICImI3gyNUFCOyI%2BPCFFTlRJVFkgcmVjdCAiJiN4MjVBRDsiPjwhRU5USVRZIG1hcmtlciAiJiN4MjVBRTsiPjwhRU5USVRZIGZsdG5zICImI3gyNUIxOyI%2BPCFFTlRJVFkgeHV0cmkgIiYjeDI1QjM7Ij48IUVOVElUWSBiaWd0cmlhbmdsZXVwICImI3gyNUIzOyI%2BPCFFTlRJVFkgdXRyaWYgIiYjeDI1QjQ7Ij48IUVOVElUWSBibGFja3RyaWFuZ2xlICImI3gyNUI0OyI%2BPCFFTlRJVFkgdXRyaSAiJiN4MjVCNTsiPjwhRU5USVRZIHRyaWFuZ2xlICImI3gyNUI1OyI%2BPCFFTlRJVFkgcnRyaWYgIiYjeDI1Qjg7Ij48IUVOVElUWSBibGFja3RyaWFuZ2xlcmlnaHQgIiYjeDI1Qjg7Ij48IUVOVElUWSBydHJpICImI3gyNUI5OyI%2BPCFFTlRJVFkgdHJpYW5nbGVyaWdodCAiJiN4MjVCOTsiPjwhRU5USVRZIHhkdHJpICImI3gyNUJEOyI%2BPCFFTlRJVFkgYmlndHJpYW5nbGVkb3duICImI3gyNUJEOyI%2BPCFFTlRJVFkgZHRyaWYgIiYjeDI1QkU7Ij48IUVOVElUWSBibGFja3RyaWFuZ2xlZG93biAiJiN4MjVCRTsiPjwhRU5USVRZIGR0cmkgIiYjeDI1QkY7Ij48IUVOVElUWSB0cmlhbmdsZWRvd24gIiYjeDI1QkY7Ij48IUVOVElUWSBsdHJpZiAiJiN4MjVDMjsiPjwhRU5USVRZIGJsYWNrdHJpYW5nbGVsZWZ0ICImI3gyNUMyOyI%2BPCFFTlRJVFkgbHRyaSAiJiN4MjVDMzsiPjwhRU5USVRZIHRyaWFuZ2xlbGVmdCAiJiN4MjVDMzsiPjwhRU5USVRZIGxveiAiJiN4MjVDQTsiPjwhRU5USVRZIGxvemVuZ2UgIiYjeDI1Q0E7Ij48IUVOVElUWSBjaXIgIiYjeDI1Q0I7Ij48IUVOVElUWSB0cmlkb3QgIiYjeDI1RUM7Ij48IUVOVElUWSB4Y2lyYyAiJiN4MjVFRjsiPjwhRU5USVRZIGJpZ2NpcmMgIiYjeDI1RUY7Ij48IUVOVElUWSB1bHRyaSAiJiN4MjVGODsiPjwhRU5USVRZIHVydHJpICImI3gyNUY5OyI%2BPCFFTlRJVFkgbGx0cmkgIiYjeDI1RkE7Ij48IUVOVElUWSBFbXB0eVNtYWxsU3F1YXJlICImI3gyNUZCOyI%2BPCFFTlRJVFkgRmlsbGVkU21hbGxTcXVhcmUgIiYjeDI1RkM7Ij48IUVOVElUWSBzdGFyZiAiJiN4MjYwNTsiPjwhRU5USVRZIGJpZ3N0YXIgIiYjeDI2MDU7Ij48IUVOVElUWSBzdGFyICImI3gyNjA2OyI%2BPCFFTlRJVFkgcGhvbmUgIiYjeDI2MEU7Ij48IUVOVElUWSBmZW1hbGUgIiYjeDI2NDA7Ij48IUVOVElUWSBtYWxlICImI3gyNjQyOyI%2BPCFFTlRJVFkgc3BhZGVzICImI3gyNjYwOyI%2BPCFFTlRJVFkgc3BhZGVzdWl0ICImI3gyNjYwOyI%2BPCFFTlRJVFkgY2x1YnMgIiYjeDI2NjM7Ij48IUVOVElUWSBjbHVic3VpdCAiJiN4MjY2MzsiPjwhRU5USVRZIGhlYXJ0cyAiJiN4MjY2NTsiPjwhRU5USVRZIGhlYXJ0c3VpdCAiJiN4MjY2NTsiPjwhRU5USVRZIGRpYW1zICImI3gyNjY2OyI%2BPCFFTlRJVFkgZGlhbW9uZHN1aXQgIiYjeDI2NjY7Ij48IUVOVElUWSBzdW5nICImI3gyNjZBOyI%2BPCFFTlRJVFkgZmxhdCAiJiN4MjY2RDsiPjwhRU5USVRZIG5hdHVyICImI3gyNjZFOyI%2BPCFFTlRJVFkgbmF0dXJhbCAiJiN4MjY2RTsiPjwhRU5USVRZIHNoYXJwICImI3gyNjZGOyI%2BPCFFTlRJVFkgY2hlY2sgIiYjeDI3MTM7Ij48IUVOVElUWSBjaGVja21hcmsgIiYjeDI3MTM7Ij48IUVOVElUWSBjcm9zcyAiJiN4MjcxNzsiPjwhRU5USVRZIG1hbHQgIiYjeDI3MjA7Ij48IUVOVElUWSBtYWx0ZXNlICImI3gyNzIwOyI%2BPCFFTlRJVFkgc2V4dCAiJiN4MjczNjsiPjwhRU5USVRZIFZlcnRpY2FsU2VwYXJhdG9yICImI3gyNzU4OyI%2BPCFFTlRJVFkgbGJicmsgIiYjeDI3NzI7Ij48IUVOVElUWSByYmJyayAiJiN4Mjc3MzsiPjwhRU5USVRZIGJzb2xoc3ViICImI3gyN0M4OyI%2BPCFFTlRJVFkgc3VwaHNvbCAiJiN4MjdDOTsiPjwhRU5USVRZIGxvYnJrICImI3gyN0U2OyI%2BPCFFTlRJVFkgTGVmdERvdWJsZUJyYWNrZXQgIiYjeDI3RTY7Ij48IUVOVElUWSByb2JyayAiJiN4MjdFNzsiPjwhRU5USVRZIFJpZ2h0RG91YmxlQnJhY2tldCAiJiN4MjdFNzsiPjwhRU5USVRZIGxhbmcgIiYjeDI3RTg7Ij48IUVOVElUWSBMZWZ0QW5nbGVCcmFja2V0ICImI3gyN0U4OyI%2BPCFFTlRJVFkgbGFuZ2xlICImI3gyN0U4OyI%2BPCFFTlRJVFkgcmFuZyAiJiN4MjdFOTsiPjwhRU5USVRZIFJpZ2h0QW5nbGVCcmFja2V0ICImI3gyN0U5OyI%2BPCFFTlRJVFkgcmFuZ2xlICImI3gyN0U5OyI%2BPCFFTlRJVFkgTGFuZyAiJiN4MjdFQTsiPjwhRU5USVRZIFJhbmcgIiYjeDI3RUI7Ij48IUVOVElUWSBsb2FuZyAiJiN4MjdFQzsiPjwhRU5USVRZIHJvYW5nICImI3gyN0VEOyI%2BPCFFTlRJVFkgeGxhcnIgIiYjeDI3RjU7Ij48IUVOVElUWSBsb25nbGVmdGFycm93ICImI3gyN0Y1OyI%2BPCFFTlRJVFkgTG9uZ0xlZnRBcnJvdyAiJiN4MjdGNTsiPjwhRU5USVRZIHhyYXJyICImI3gyN0Y2OyI%2BPCFFTlRJVFkgbG9uZ3JpZ2h0YXJyb3cgIiYjeDI3RjY7Ij48IUVOVElUWSBMb25nUmlnaHRBcnJvdyAiJiN4MjdGNjsiPjwhRU5USVRZIHhoYXJyICImI3gyN0Y3OyI%2BPCFFTlRJVFkgbG9uZ2xlZnRyaWdodGFycm93ICImI3gyN0Y3OyI%2BPCFFTlRJVFkgTG9uZ0xlZnRSaWdodEFycm93ICImI3gyN0Y3OyI%2BPCFFTlRJVFkgeGxBcnIgIiYjeDI3Rjg7Ij48IUVOVElUWSBMb25nbGVmdGFycm93ICImI3gyN0Y4OyI%2BPCFFTlRJVFkgRG91YmxlTG9uZ0xlZnRBcnJvdyAiJiN4MjdGODsiPjwhRU5USVRZIHhyQXJyICImI3gyN0Y5OyI%2BPCFFTlRJVFkgTG9uZ3JpZ2h0YXJyb3cgIiYjeDI3Rjk7Ij48IUVOVElUWSBEb3VibGVMb25nUmlnaHRBcnJvdyAiJiN4MjdGOTsiPjwhRU5USVRZIHhoQXJyICImI3gyN0ZBOyI%2BPCFFTlRJVFkgTG9uZ2xlZnRyaWdodGFycm93ICImI3gyN0ZBOyI%2BPCFFTlRJVFkgRG91YmxlTG9uZ0xlZnRSaWdodEFycm93ICImI3gyN0ZBOyI%2BPCFFTlRJVFkgeG1hcCAiJiN4MjdGQzsiPjwhRU5USVRZIGxvbmdtYXBzdG8gIiYjeDI3RkM7Ij48IUVOVElUWSBkemlncmFyciAiJiN4MjdGRjsiPjwhRU5USVRZIG52bEFyciAiJiN4MjkwMjsiPjwhRU5USVRZIG52ckFyciAiJiN4MjkwMzsiPjwhRU5USVRZIG52SGFyciAiJiN4MjkwNDsiPjwhRU5USVRZIE1hcCAiJiN4MjkwNTsiPjwhRU5USVRZIGxiYXJyICImI3gyOTBDOyI%2BPCFFTlRJVFkgcmJhcnIgIiYjeDI5MEQ7Ij48IUVOVElUWSBia2Fyb3cgIiYjeDI5MEQ7Ij48IUVOVElUWSBsQmFyciAiJiN4MjkwRTsiPjwhRU5USVRZIHJCYXJyICImI3gyOTBGOyI%2BPCFFTlRJVFkgZGJrYXJvdyAiJiN4MjkwRjsiPjwhRU5USVRZIFJCYXJyICImI3gyOTEwOyI%2BPCFFTlRJVFkgZHJia2Fyb3cgIiYjeDI5MTA7Ij48IUVOVElUWSBERG90cmFoZCAiJiN4MjkxMTsiPjwhRU5USVRZIFVwQXJyb3dCYXIgIiYjeDI5MTI7Ij48IUVOVElUWSBEb3duQXJyb3dCYXIgIiYjeDI5MTM7Ij48IUVOVElUWSBSYXJydGwgIiYjeDI5MTY7Ij48IUVOVElUWSBsYXRhaWwgIiYjeDI5MTk7Ij48IUVOVElUWSByYXRhaWwgIiYjeDI5MUE7Ij48IUVOVElUWSBsQXRhaWwgIiYjeDI5MUI7Ij48IUVOVElUWSByQXRhaWwgIiYjeDI5MUM7Ij48IUVOVElUWSBsYXJyZnMgIiYjeDI5MUQ7Ij48IUVOVElUWSByYXJyZnMgIiYjeDI5MUU7Ij48IUVOVElUWSBsYXJyYmZzICImI3gyOTFGOyI%2BPCFFTlRJVFkgcmFycmJmcyAiJiN4MjkyMDsiPjwhRU5USVRZIG53YXJoayAiJiN4MjkyMzsiPjwhRU5USVRZIG5lYXJoayAiJiN4MjkyNDsiPjwhRU5USVRZIHNlYXJoayAiJiN4MjkyNTsiPjwhRU5USVRZIGhrc2Vhcm93ICImI3gyOTI1OyI%2BPCFFTlRJVFkgc3dhcmhrICImI3gyOTI2OyI%2BPCFFTlRJVFkgaGtzd2Fyb3cgIiYjeDI5MjY7Ij48IUVOVElUWSBud25lYXIgIiYjeDI5Mjc7Ij48IUVOVElUWSBuZXNlYXIgIiYjeDI5Mjg7Ij48IUVOVElUWSB0b2VhICImI3gyOTI4OyI%2BPCFFTlRJVFkgc2Vzd2FyICImI3gyOTI5OyI%2BPCFFTlRJVFkgdG9zYSAiJiN4MjkyOTsiPjwhRU5USVRZIHN3bndhciAiJiN4MjkyQTsiPjwhRU5USVRZIHJhcnJjICImI3gyOTMzOyI%2BPCFFTlRJVFkgbnJhcnJjICImI3gyOTMzOyYjeDMzODsiPjwhRU5USVRZIGN1ZGFycnIgIiYjeDI5MzU7Ij48IUVOVElUWSBsZGNhICImI3gyOTM2OyI%2BPCFFTlRJVFkgcmRjYSAiJiN4MjkzNzsiPjwhRU5USVRZIGN1ZGFycmwgIiYjeDI5Mzg7Ij48IUVOVElUWSBsYXJycGwgIiYjeDI5Mzk7Ij48IUVOVElUWSBjdXJhcnJtICImI3gyOTNDOyI%2BPCFFTlRJVFkgY3VsYXJycCAiJiN4MjkzRDsiPjwhRU5USVRZIHJhcnJwbCAiJiN4Mjk0NTsiPjwhRU5USVRZIGhhcnJjaXIgIiYjeDI5NDg7Ij48IUVOVElUWSBVYXJyb2NpciAiJiN4Mjk0OTsiPjwhRU5USVRZIGx1cmRzaGFyICImI3gyOTRBOyI%2BPCFFTlRJVFkgbGRydXNoYXIgIiYjeDI5NEI7Ij48IUVOVElUWSBMZWZ0UmlnaHRWZWN0b3IgIiYjeDI5NEU7Ij48IUVOVElUWSBSaWdodFVwRG93blZlY3RvciAiJiN4Mjk0RjsiPjwhRU5USVRZIERvd25MZWZ0UmlnaHRWZWN0b3IgIiYjeDI5NTA7Ij48IUVOVElUWSBMZWZ0VXBEb3duVmVjdG9yICImI3gyOTUxOyI%2BPCFFTlRJVFkgTGVmdFZlY3RvckJhciAiJiN4Mjk1MjsiPjwhRU5USVRZIFJpZ2h0VmVjdG9yQmFyICImI3gyOTUzOyI%2BPCFFTlRJVFkgUmlnaHRVcFZlY3RvckJhciAiJiN4Mjk1NDsiPjwhRU5USVRZIFJpZ2h0RG93blZlY3RvckJhciAiJiN4Mjk1NTsiPjwhRU5USVRZIERvd25MZWZ0VmVjdG9yQmFyICImI3gyOTU2OyI%2BPCFFTlRJVFkgRG93blJpZ2h0VmVjdG9yQmFyICImI3gyOTU3OyI%2BPCFFTlRJVFkgTGVmdFVwVmVjdG9yQmFyICImI3gyOTU4OyI%2BPCFFTlRJVFkgTGVmdERvd25WZWN0b3JCYXIgIiYjeDI5NTk7Ij48IUVOVElUWSBMZWZ0VGVlVmVjdG9yICImI3gyOTVBOyI%2BPCFFTlRJVFkgUmlnaHRUZWVWZWN0b3IgIiYjeDI5NUI7Ij48IUVOVElUWSBSaWdodFVwVGVlVmVjdG9yICImI3gyOTVDOyI%2BPCFFTlRJVFkgUmlnaHREb3duVGVlVmVjdG9yICImI3gyOTVEOyI%2BPCFFTlRJVFkgRG93bkxlZnRUZWVWZWN0b3IgIiYjeDI5NUU7Ij48IUVOVElUWSBEb3duUmlnaHRUZWVWZWN0b3IgIiYjeDI5NUY7Ij48IUVOVElUWSBMZWZ0VXBUZWVWZWN0b3IgIiYjeDI5NjA7Ij48IUVOVElUWSBMZWZ0RG93blRlZVZlY3RvciAiJiN4Mjk2MTsiPjwhRU5USVRZIGxIYXIgIiYjeDI5NjI7Ij48IUVOVElUWSB1SGFyICImI3gyOTYzOyI%2BPCFFTlRJVFkgckhhciAiJiN4Mjk2NDsiPjwhRU5USVRZIGRIYXIgIiYjeDI5NjU7Ij48IUVOVElUWSBsdXJ1aGFyICImI3gyOTY2OyI%2BPCFFTlRJVFkgbGRyZGhhciAiJiN4Mjk2NzsiPjwhRU5USVRZIHJ1bHVoYXIgIiYjeDI5Njg7Ij48IUVOVElUWSByZGxkaGFyICImI3gyOTY5OyI%2BPCFFTlRJVFkgbGhhcnVsICImI3gyOTZBOyI%2BPCFFTlRJVFkgbGxoYXJkICImI3gyOTZCOyI%2BPCFFTlRJVFkgcmhhcnVsICImI3gyOTZDOyI%2BPCFFTlRJVFkgbHJoYXJkICImI3gyOTZEOyI%2BPCFFTlRJVFkgdWRoYXIgIiYjeDI5NkU7Ij48IUVOVElUWSBVcEVxdWlsaWJyaXVtICImI3gyOTZFOyI%2BPCFFTlRJVFkgZHVoYXIgIiYjeDI5NkY7Ij48IUVOVElUWSBSZXZlcnNlVXBFcXVpbGlicml1bSAiJiN4Mjk2RjsiPjwhRU5USVRZIFJvdW5kSW1wbGllcyAiJiN4Mjk3MDsiPjwhRU5USVRZIGVyYXJyICImI3gyOTcxOyI%2BPCFFTlRJVFkgc2ltcmFyciAiJiN4Mjk3MjsiPjwhRU5USVRZIGxhcnJzaW0gIiYjeDI5NzM7Ij48IUVOVElUWSByYXJyc2ltICImI3gyOTc0OyI%2BPCFFTlRJVFkgcmFycmFwICImI3gyOTc1OyI%2BPCFFTlRJVFkgbHRsYXJyICImI3gyOTc2OyI%2BPCFFTlRJVFkgZ3RyYXJyICImI3gyOTc4OyI%2BPCFFTlRJVFkgc3VicmFyciAiJiN4Mjk3OTsiPjwhRU5USVRZIHN1cGxhcnIgIiYjeDI5N0I7Ij48IUVOVElUWSBsZmlzaHQgIiYjeDI5N0M7Ij48IUVOVElUWSByZmlzaHQgIiYjeDI5N0Q7Ij48IUVOVElUWSB1ZmlzaHQgIiYjeDI5N0U7Ij48IUVOVElUWSBkZmlzaHQgIiYjeDI5N0Y7Ij48IUVOVElUWSBsb3BhciAiJiN4Mjk4NTsiPjwhRU5USVRZIHJvcGFyICImI3gyOTg2OyI%2BPCFFTlRJVFkgbGJya2UgIiYjeDI5OEI7Ij48IUVOVElUWSByYnJrZSAiJiN4Mjk4QzsiPjwhRU5USVRZIGxicmtzbHUgIiYjeDI5OEQ7Ij48IUVOVElUWSByYnJrc2xkICImI3gyOThFOyI%2BPCFFTlRJVFkgbGJya3NsZCAiJiN4Mjk4RjsiPjwhRU5USVRZIHJicmtzbHUgIiYjeDI5OTA7Ij48IUVOVElUWSBsYW5nZCAiJiN4Mjk5MTsiPjwhRU5USVRZIHJhbmdkICImI3gyOTkyOyI%2BPCFFTlRJVFkgbHBhcmx0ICImI3gyOTkzOyI%2BPCFFTlRJVFkgcnBhcmd0ICImI3gyOTk0OyI%2BPCFFTlRJVFkgZ3RsUGFyICImI3gyOTk1OyI%2BPCFFTlRJVFkgbHRyUGFyICImI3gyOTk2OyI%2BPCFFTlRJVFkgdnppZ3phZyAiJiN4Mjk5QTsiPjwhRU5USVRZIHZhbmdydCAiJiN4Mjk5QzsiPjwhRU5USVRZIGFuZ3J0dmJkICImI3gyOTlEOyI%2BPCFFTlRJVFkgYW5nZSAiJiN4MjlBNDsiPjwhRU5USVRZIHJhbmdlICImI3gyOUE1OyI%2BPCFFTlRJVFkgZHdhbmdsZSAiJiN4MjlBNjsiPjwhRU5USVRZIHV3YW5nbGUgIiYjeDI5QTc7Ij48IUVOVElUWSBhbmdtc2RhYSAiJiN4MjlBODsiPjwhRU5USVRZIGFuZ21zZGFiICImI3gyOUE5OyI%2BPCFFTlRJVFkgYW5nbXNkYWMgIiYjeDI5QUE7Ij48IUVOVElUWSBhbmdtc2RhZCAiJiN4MjlBQjsiPjwhRU5USVRZIGFuZ21zZGFlICImI3gyOUFDOyI%2BPCFFTlRJVFkgYW5nbXNkYWYgIiYjeDI5QUQ7Ij48IUVOVElUWSBhbmdtc2RhZyAiJiN4MjlBRTsiPjwhRU5USVRZIGFuZ21zZGFoICImI3gyOUFGOyI%2BPCFFTlRJVFkgYmVtcHR5diAiJiN4MjlCMDsiPjwhRU5USVRZIGRlbXB0eXYgIiYjeDI5QjE7Ij48IUVOVElUWSBjZW1wdHl2ICImI3gyOUIyOyI%2BPCFFTlRJVFkgcmFlbXB0eXYgIiYjeDI5QjM7Ij48IUVOVElUWSBsYWVtcHR5diAiJiN4MjlCNDsiPjwhRU5USVRZIG9oYmFyICImI3gyOUI1OyI%2BPCFFTlRJVFkgb21pZCAiJiN4MjlCNjsiPjwhRU5USVRZIG9wYXIgIiYjeDI5Qjc7Ij48IUVOVElUWSBvcGVycCAiJiN4MjlCOTsiPjwhRU5USVRZIG9sY3Jvc3MgIiYjeDI5QkI7Ij48IUVOVElUWSBvZHNvbGQgIiYjeDI5QkM7Ij48IUVOVElUWSBvbGNpciAiJiN4MjlCRTsiPjwhRU5USVRZIG9mY2lyICImI3gyOUJGOyI%2BPCFFTlRJVFkgb2x0ICImI3gyOUMwOyI%2BPCFFTlRJVFkgb2d0ICImI3gyOUMxOyI%2BPCFFTlRJVFkgY2lyc2NpciAiJiN4MjlDMjsiPjwhRU5USVRZIGNpckUgIiYjeDI5QzM7Ij48IUVOVElUWSBzb2xiICImI3gyOUM0OyI%2BPCFFTlRJVFkgYnNvbGIgIiYjeDI5QzU7Ij48IUVOVElUWSBib3hib3ggIiYjeDI5Qzk7Ij48IUVOVElUWSB0cmlzYiAiJiN4MjlDRDsiPjwhRU5USVRZIHJ0cmlsdHJpICImI3gyOUNFOyI%2BPCFFTlRJVFkgTGVmdFRyaWFuZ2xlQmFyICImI3gyOUNGOyI%2BPCFFTlRJVFkgTm90TGVmdFRyaWFuZ2xlQmFyICImI3gyOUNGOyYjeDMzODsiPjwhRU5USVRZIFJpZ2h0VHJpYW5nbGVCYXIgIiYjeDI5RDA7Ij48IUVOVElUWSBOb3RSaWdodFRyaWFuZ2xlQmFyICImI3gyOUQwOyYjeDMzODsiPjwhRU5USVRZIGlpbmZpbiAiJiN4MjlEQzsiPjwhRU5USVRZIGluZmludGllICImI3gyOUREOyI%2BPCFFTlRJVFkgbnZpbmZpbiAiJiN4MjlERTsiPjwhRU5USVRZIGVwYXJzbCAiJiN4MjlFMzsiPjwhRU5USVRZIHNtZXBhcnNsICImI3gyOUU0OyI%2BPCFFTlRJVFkgZXF2cGFyc2wgIiYjeDI5RTU7Ij48IUVOVElUWSBsb3pmICImI3gyOUVCOyI%2BPCFFTlRJVFkgYmxhY2tsb3plbmdlICImI3gyOUVCOyI%2BPCFFTlRJVFkgUnVsZURlbGF5ZWQgIiYjeDI5RjQ7Ij48IUVOVElUWSBkc29sICImI3gyOUY2OyI%2BPCFFTlRJVFkgeG9kb3QgIiYjeDJBMDA7Ij48IUVOVElUWSBiaWdvZG90ICImI3gyQTAwOyI%2BPCFFTlRJVFkgeG9wbHVzICImI3gyQTAxOyI%2BPCFFTlRJVFkgYmlnb3BsdXMgIiYjeDJBMDE7Ij48IUVOVElUWSB4b3RpbWUgIiYjeDJBMDI7Ij48IUVOVElUWSBiaWdvdGltZXMgIiYjeDJBMDI7Ij48IUVOVElUWSB4dXBsdXMgIiYjeDJBMDQ7Ij48IUVOVElUWSBiaWd1cGx1cyAiJiN4MkEwNDsiPjwhRU5USVRZIHhzcWN1cCAiJiN4MkEwNjsiPjwhRU5USVRZIGJpZ3NxY3VwICImI3gyQTA2OyI%2BPCFFTlRJVFkgcWludCAiJiN4MkEwQzsiPjwhRU5USVRZIGlpaWludCAiJiN4MkEwQzsiPjwhRU5USVRZIGZwYXJ0aW50ICImI3gyQTBEOyI%2BPCFFTlRJVFkgY2lyZm5pbnQgIiYjeDJBMTA7Ij48IUVOVElUWSBhd2ludCAiJiN4MkExMTsiPjwhRU5USVRZIHJwcG9saW50ICImI3gyQTEyOyI%2BPCFFTlRJVFkgc2Nwb2xpbnQgIiYjeDJBMTM7Ij48IUVOVElUWSBucG9saW50ICImI3gyQTE0OyI%2BPCFFTlRJVFkgcG9pbnRpbnQgIiYjeDJBMTU7Ij48IUVOVElUWSBxdWF0aW50ICImI3gyQTE2OyI%2BPCFFTlRJVFkgaW50bGFyaGsgIiYjeDJBMTc7Ij48IUVOVElUWSBwbHVzY2lyICImI3gyQTIyOyI%2BPCFFTlRJVFkgcGx1c2FjaXIgIiYjeDJBMjM7Ij48IUVOVElUWSBzaW1wbHVzICImI3gyQTI0OyI%2BPCFFTlRJVFkgcGx1c2R1ICImI3gyQTI1OyI%2BPCFFTlRJVFkgcGx1c3NpbSAiJiN4MkEyNjsiPjwhRU5USVRZIHBsdXN0d28gIiYjeDJBMjc7Ij48IUVOVElUWSBtY29tbWEgIiYjeDJBMjk7Ij48IUVOVElUWSBtaW51c2R1ICImI3gyQTJBOyI%2BPCFFTlRJVFkgbG9wbHVzICImI3gyQTJEOyI%2BPCFFTlRJVFkgcm9wbHVzICImI3gyQTJFOyI%2BPCFFTlRJVFkgQ3Jvc3MgIiYjeDJBMkY7Ij48IUVOVElUWSB0aW1lc2QgIiYjeDJBMzA7Ij48IUVOVElUWSB0aW1lc2JhciAiJiN4MkEzMTsiPjwhRU5USVRZIHNtYXNocCAiJiN4MkEzMzsiPjwhRU5USVRZIGxvdGltZXMgIiYjeDJBMzQ7Ij48IUVOVElUWSByb3RpbWVzICImI3gyQTM1OyI%2BPCFFTlRJVFkgb3RpbWVzYXMgIiYjeDJBMzY7Ij48IUVOVElUWSBPdGltZXMgIiYjeDJBMzc7Ij48IUVOVElUWSBvZGl2ICImI3gyQTM4OyI%2BPCFFTlRJVFkgdHJpcGx1cyAiJiN4MkEzOTsiPjwhRU5USVRZIHRyaW1pbnVzICImI3gyQTNBOyI%2BPCFFTlRJVFkgdHJpdGltZSAiJiN4MkEzQjsiPjwhRU5USVRZIGlwcm9kICImI3gyQTNDOyI%2BPCFFTlRJVFkgaW50cHJvZCAiJiN4MkEzQzsiPjwhRU5USVRZIGFtYWxnICImI3gyQTNGOyI%2BPCFFTlRJVFkgY2FwZG90ICImI3gyQTQwOyI%2BPCFFTlRJVFkgbmN1cCAiJiN4MkE0MjsiPjwhRU5USVRZIG5jYXAgIiYjeDJBNDM7Ij48IUVOVElUWSBjYXBhbmQgIiYjeDJBNDQ7Ij48IUVOVElUWSBjdXBvciAiJiN4MkE0NTsiPjwhRU5USVRZIGN1cGNhcCAiJiN4MkE0NjsiPjwhRU5USVRZIGNhcGN1cCAiJiN4MkE0NzsiPjwhRU5USVRZIGN1cGJyY2FwICImI3gyQTQ4OyI%2BPCFFTlRJVFkgY2FwYnJjdXAgIiYjeDJBNDk7Ij48IUVOVElUWSBjdXBjdXAgIiYjeDJBNEE7Ij48IUVOVElUWSBjYXBjYXAgIiYjeDJBNEI7Ij48IUVOVElUWSBjY3VwcyAiJiN4MkE0QzsiPjwhRU5USVRZIGNjYXBzICImI3gyQTREOyI%2BPCFFTlRJVFkgY2N1cHNzbSAiJiN4MkE1MDsiPjwhRU5USVRZIEFuZCAiJiN4MkE1MzsiPjwhRU5USVRZIE9yICImI3gyQTU0OyI%2BPCFFTlRJVFkgYW5kYW5kICImI3gyQTU1OyI%2BPCFFTlRJVFkgb3JvciAiJiN4MkE1NjsiPjwhRU5USVRZIG9yc2xvcGUgIiYjeDJBNTc7Ij48IUVOVElUWSBhbmRzbG9wZSAiJiN4MkE1ODsiPjwhRU5USVRZIGFuZHYgIiYjeDJBNUE7Ij48IUVOVElUWSBvcnYgIiYjeDJBNUI7Ij48IUVOVElUWSBhbmRkICImI3gyQTVDOyI%2BPCFFTlRJVFkgb3JkICImI3gyQTVEOyI%2BPCFFTlRJVFkgd2VkYmFyICImI3gyQTVGOyI%2BPCFFTlRJVFkgc2RvdGUgIiYjeDJBNjY7Ij48IUVOVElUWSBzaW1kb3QgIiYjeDJBNkE7Ij48IUVOVElUWSBjb25nZG90ICImI3gyQTZEOyI%2BPCFFTlRJVFkgbmNvbmdkb3QgIiYjeDJBNkQ7JiN4MzM4OyI%2BPCFFTlRJVFkgZWFzdGVyICImI3gyQTZFOyI%2BPCFFTlRJVFkgYXBhY2lyICImI3gyQTZGOyI%2BPCFFTlRJVFkgYXBFICImI3gyQTcwOyI%2BPCFFTlRJVFkgbmFwRSAiJiN4MkE3MDsmI3gzMzg7Ij48IUVOVElUWSBlcGx1cyAiJiN4MkE3MTsiPjwhRU5USVRZIHBsdXNlICImI3gyQTcyOyI%2BPCFFTlRJVFkgRXNpbSAiJiN4MkE3MzsiPjwhRU5USVRZIENvbG9uZSAiJiN4MkE3NDsiPjwhRU5USVRZIEVxdWFsICImI3gyQTc1OyI%2BPCFFTlRJVFkgZUREb3QgIiYjeDJBNzc7Ij48IUVOVElUWSBkZG90c2VxICImI3gyQTc3OyI%2BPCFFTlRJVFkgZXF1aXZERCAiJiN4MkE3ODsiPjwhRU5USVRZIGx0Y2lyICImI3gyQTc5OyI%2BPCFFTlRJVFkgZ3RjaXIgIiYjeDJBN0E7Ij48IUVOVElUWSBsdHF1ZXN0ICImI3gyQTdCOyI%2BPCFFTlRJVFkgZ3RxdWVzdCAiJiN4MkE3QzsiPjwhRU5USVRZIGxlcyAiJiN4MkE3RDsiPjwhRU5USVRZIExlc3NTbGFudEVxdWFsICImI3gyQTdEOyI%2BPCFFTlRJVFkgbGVxc2xhbnQgIiYjeDJBN0Q7Ij48IUVOVElUWSBubGVzICImI3gyQTdEOyYjeDMzODsiPjwhRU5USVRZIE5vdExlc3NTbGFudEVxdWFsICImI3gyQTdEOyYjeDMzODsiPjwhRU5USVRZIG5sZXFzbGFudCAiJiN4MkE3RDsmI3gzMzg7Ij48IUVOVElUWSBnZXMgIiYjeDJBN0U7Ij48IUVOVElUWSBHcmVhdGVyU2xhbnRFcXVhbCAiJiN4MkE3RTsiPjwhRU5USVRZIGdlcXNsYW50ICImI3gyQTdFOyI%2BPCFFTlRJVFkgbmdlcyAiJiN4MkE3RTsmI3gzMzg7Ij48IUVOVElUWSBOb3RHcmVhdGVyU2xhbnRFcXVhbCAiJiN4MkE3RTsmI3gzMzg7Ij48IUVOVElUWSBuZ2Vxc2xhbnQgIiYjeDJBN0U7JiN4MzM4OyI%2BPCFFTlRJVFkgbGVzZG90ICImI3gyQTdGOyI%2BPCFFTlRJVFkgZ2VzZG90ICImI3gyQTgwOyI%2BPCFFTlRJVFkgbGVzZG90byAiJiN4MkE4MTsiPjwhRU5USVRZIGdlc2RvdG8gIiYjeDJBODI7Ij48IUVOVElUWSBsZXNkb3RvciAiJiN4MkE4MzsiPjwhRU5USVRZIGdlc2RvdG9sICImI3gyQTg0OyI%2BPCFFTlRJVFkgbGFwICImI3gyQTg1OyI%2BPCFFTlRJVFkgbGVzc2FwcHJveCAiJiN4MkE4NTsiPjwhRU5USVRZIGdhcCAiJiN4MkE4NjsiPjwhRU5USVRZIGd0cmFwcHJveCAiJiN4MkE4NjsiPjwhRU5USVRZIGxuZSAiJiN4MkE4NzsiPjwhRU5USVRZIGxuZXEgIiYjeDJBODc7Ij48IUVOVElUWSBnbmUgIiYjeDJBODg7Ij48IUVOVElUWSBnbmVxICImI3gyQTg4OyI%2BPCFFTlRJVFkgbG5hcCAiJiN4MkE4OTsiPjwhRU5USVRZIGxuYXBwcm94ICImI3gyQTg5OyI%2BPCFFTlRJVFkgZ25hcCAiJiN4MkE4QTsiPjwhRU5USVRZIGduYXBwcm94ICImI3gyQThBOyI%2BPCFFTlRJVFkgbEVnICImI3gyQThCOyI%2BPCFFTlRJVFkgbGVzc2VxcWd0ciAiJiN4MkE4QjsiPjwhRU5USVRZIGdFbCAiJiN4MkE4QzsiPjwhRU5USVRZIGd0cmVxcWxlc3MgIiYjeDJBOEM7Ij48IUVOVElUWSBsc2ltZSAiJiN4MkE4RDsiPjwhRU5USVRZIGdzaW1lICImI3gyQThFOyI%2BPCFFTlRJVFkgbHNpbWcgIiYjeDJBOEY7Ij48IUVOVElUWSBnc2ltbCAiJiN4MkE5MDsiPjwhRU5USVRZIGxnRSAiJiN4MkE5MTsiPjwhRU5USVRZIGdsRSAiJiN4MkE5MjsiPjwhRU5USVRZIGxlc2dlcyAiJiN4MkE5MzsiPjwhRU5USVRZIGdlc2xlcyAiJiN4MkE5NDsiPjwhRU5USVRZIGVscyAiJiN4MkE5NTsiPjwhRU5USVRZIGVxc2xhbnRsZXNzICImI3gyQTk1OyI%2BPCFFTlRJVFkgZWdzICImI3gyQTk2OyI%2BPCFFTlRJVFkgZXFzbGFudGd0ciAiJiN4MkE5NjsiPjwhRU5USVRZIGVsc2RvdCAiJiN4MkE5NzsiPjwhRU5USVRZIGVnc2RvdCAiJiN4MkE5ODsiPjwhRU5USVRZIGVsICImI3gyQTk5OyI%2BPCFFTlRJVFkgZWcgIiYjeDJBOUE7Ij48IUVOVElUWSBzaW1sICImI3gyQTlEOyI%2BPCFFTlRJVFkgc2ltZyAiJiN4MkE5RTsiPjwhRU5USVRZIHNpbWxFICImI3gyQTlGOyI%2BPCFFTlRJVFkgc2ltZ0UgIiYjeDJBQTA7Ij48IUVOVElUWSBMZXNzTGVzcyAiJiN4MkFBMTsiPjwhRU5USVRZIE5vdE5lc3RlZExlc3NMZXNzICImI3gyQUExOyYjeDMzODsiPjwhRU5USVRZIEdyZWF0ZXJHcmVhdGVyICImI3gyQUEyOyI%2BPCFFTlRJVFkgTm90TmVzdGVkR3JlYXRlckdyZWF0ZXIgIiYjeDJBQTI7JiN4MzM4OyI%2BPCFFTlRJVFkgZ2xqICImI3gyQUE0OyI%2BPCFFTlRJVFkgZ2xhICImI3gyQUE1OyI%2BPCFFTlRJVFkgbHRjYyAiJiN4MkFBNjsiPjwhRU5USVRZIGd0Y2MgIiYjeDJBQTc7Ij48IUVOVElUWSBsZXNjYyAiJiN4MkFBODsiPjwhRU5USVRZIGdlc2NjICImI3gyQUE5OyI%2BPCFFTlRJVFkgc210ICImI3gyQUFBOyI%2BPCFFTlRJVFkgbGF0ICImI3gyQUFCOyI%2BPCFFTlRJVFkgc210ZSAiJiN4MkFBQzsiPjwhRU5USVRZIHNtdGVzICImI3gyQUFDOyYjeEZFMDA7Ij48IUVOVElUWSBsYXRlICImI3gyQUFEOyI%2BPCFFTlRJVFkgbGF0ZXMgIiYjeDJBQUQ7JiN4RkUwMDsiPjwhRU5USVRZIGJ1bXBFICImI3gyQUFFOyI%2BPCFFTlRJVFkgcHJlICImI3gyQUFGOyI%2BPCFFTlRJVFkgcHJlY2VxICImI3gyQUFGOyI%2BPCFFTlRJVFkgUHJlY2VkZXNFcXVhbCAiJiN4MkFBRjsiPjwhRU5USVRZIG5wcmUgIiYjeDJBQUY7JiN4MzM4OyI%2BPCFFTlRJVFkgbnByZWNlcSAiJiN4MkFBRjsmI3gzMzg7Ij48IUVOVElUWSBOb3RQcmVjZWRlc0VxdWFsICImI3gyQUFGOyYjeDMzODsiPjwhRU5USVRZIHNjZSAiJiN4MkFCMDsiPjwhRU5USVRZIHN1Y2NlcSAiJiN4MkFCMDsiPjwhRU5USVRZIFN1Y2NlZWRzRXF1YWwgIiYjeDJBQjA7Ij48IUVOVElUWSBuc2NlICImI3gyQUIwOyYjeDMzODsiPjwhRU5USVRZIG5zdWNjZXEgIiYjeDJBQjA7JiN4MzM4OyI%2BPCFFTlRJVFkgTm90U3VjY2VlZHNFcXVhbCAiJiN4MkFCMDsmI3gzMzg7Ij48IUVOVElUWSBwckUgIiYjeDJBQjM7Ij48IUVOVElUWSBzY0UgIiYjeDJBQjQ7Ij48IUVOVElUWSBwcm5FICImI3gyQUI1OyI%2BPCFFTlRJVFkgcHJlY25lcXEgIiYjeDJBQjU7Ij48IUVOVElUWSBzY25FICImI3gyQUI2OyI%2BPCFFTlRJVFkgc3VjY25lcXEgIiYjeDJBQjY7Ij48IUVOVElUWSBwcmFwICImI3gyQUI3OyI%2BPCFFTlRJVFkgcHJlY2FwcHJveCAiJiN4MkFCNzsiPjwhRU5USVRZIHNjYXAgIiYjeDJBQjg7Ij48IUVOVElUWSBzdWNjYXBwcm94ICImI3gyQUI4OyI%2BPCFFTlRJVFkgcHJuYXAgIiYjeDJBQjk7Ij48IUVOVElUWSBwcmVjbmFwcHJveCAiJiN4MkFCOTsiPjwhRU5USVRZIHNjbmFwICImI3gyQUJBOyI%2BPCFFTlRJVFkgc3VjY25hcHByb3ggIiYjeDJBQkE7Ij48IUVOVElUWSBQciAiJiN4MkFCQjsiPjwhRU5USVRZIFNjICImI3gyQUJDOyI%2BPCFFTlRJVFkgc3ViZG90ICImI3gyQUJEOyI%2BPCFFTlRJVFkgc3VwZG90ICImI3gyQUJFOyI%2BPCFFTlRJVFkgc3VicGx1cyAiJiN4MkFCRjsiPjwhRU5USVRZIHN1cHBsdXMgIiYjeDJBQzA7Ij48IUVOVElUWSBzdWJtdWx0ICImI3gyQUMxOyI%2BPCFFTlRJVFkgc3VwbXVsdCAiJiN4MkFDMjsiPjwhRU5USVRZIHN1YmVkb3QgIiYjeDJBQzM7Ij48IUVOVElUWSBzdXBlZG90ICImI3gyQUM0OyI%2BPCFFTlRJVFkgc3ViRSAiJiN4MkFDNTsiPjwhRU5USVRZIHN1YnNldGVxcSAiJiN4MkFDNTsiPjwhRU5USVRZIG5zdWJFICImI3gyQUM1OyYjeDMzODsiPjwhRU5USVRZIG5zdWJzZXRlcXEgIiYjeDJBQzU7JiN4MzM4OyI%2BPCFFTlRJVFkgc3VwRSAiJiN4MkFDNjsiPjwhRU5USVRZIHN1cHNldGVxcSAiJiN4MkFDNjsiPjwhRU5USVRZIG5zdXBFICImI3gyQUM2OyYjeDMzODsiPjwhRU5USVRZIG5zdXBzZXRlcXEgIiYjeDJBQzY7JiN4MzM4OyI%2BPCFFTlRJVFkgc3Vic2ltICImI3gyQUM3OyI%2BPCFFTlRJVFkgc3Vwc2ltICImI3gyQUM4OyI%2BPCFFTlRJVFkgc3VibkUgIiYjeDJBQ0I7Ij48IUVOVElUWSBzdWJzZXRuZXFxICImI3gyQUNCOyI%2BPCFFTlRJVFkgdnN1Ym5FICImI3gyQUNCOyYjeEZFMDA7Ij48IUVOVElUWSB2YXJzdWJzZXRuZXFxICImI3gyQUNCOyYjeEZFMDA7Ij48IUVOVElUWSBzdXBuRSAiJiN4MkFDQzsiPjwhRU5USVRZIHN1cHNldG5lcXEgIiYjeDJBQ0M7Ij48IUVOVElUWSB2c3VwbkUgIiYjeDJBQ0M7JiN4RkUwMDsiPjwhRU5USVRZIHZhcnN1cHNldG5lcXEgIiYjeDJBQ0M7JiN4RkUwMDsiPjwhRU5USVRZIGNzdWIgIiYjeDJBQ0Y7Ij48IUVOVElUWSBjc3VwICImI3gyQUQwOyI%2BPCFFTlRJVFkgY3N1YmUgIiYjeDJBRDE7Ij48IUVOVElUWSBjc3VwZSAiJiN4MkFEMjsiPjwhRU5USVRZIHN1YnN1cCAiJiN4MkFEMzsiPjwhRU5USVRZIHN1cHN1YiAiJiN4MkFENDsiPjwhRU5USVRZIHN1YnN1YiAiJiN4MkFENTsiPjwhRU5USVRZIHN1cHN1cCAiJiN4MkFENjsiPjwhRU5USVRZIHN1cGhzdWIgIiYjeDJBRDc7Ij48IUVOVElUWSBzdXBkc3ViICImI3gyQUQ4OyI%2BPCFFTlRJVFkgZm9ya3YgIiYjeDJBRDk7Ij48IUVOVElUWSB0b3Bmb3JrICImI3gyQURBOyI%2BPCFFTlRJVFkgbWxjcCAiJiN4MkFEQjsiPjwhRU5USVRZIERhc2h2ICImI3gyQUU0OyI%2BPCFFTlRJVFkgRG91YmxlTGVmdFRlZSAiJiN4MkFFNDsiPjwhRU5USVRZIFZkYXNobCAiJiN4MkFFNjsiPjwhRU5USVRZIEJhcnYgIiYjeDJBRTc7Ij48IUVOVElUWSB2QmFyICImI3gyQUU4OyI%2BPCFFTlRJVFkgdkJhcnYgIiYjeDJBRTk7Ij48IUVOVElUWSBWYmFyICImI3gyQUVCOyI%2BPCFFTlRJVFkgTm90ICImI3gyQUVDOyI%2BPCFFTlRJVFkgYk5vdCAiJiN4MkFFRDsiPjwhRU5USVRZIHJubWlkICImI3gyQUVFOyI%2BPCFFTlRJVFkgY2lybWlkICImI3gyQUVGOyI%2BPCFFTlRJVFkgbWlkY2lyICImI3gyQUYwOyI%2BPCFFTlRJVFkgdG9wY2lyICImI3gyQUYxOyI%2BPCFFTlRJVFkgbmhwYXIgIiYjeDJBRjI7Ij48IUVOVElUWSBwYXJzaW0gIiYjeDJBRjM7Ij48IUVOVElUWSBwYXJzbCAiJiN4MkFGRDsiPjwhRU5USVRZIG5wYXJzbCAiJiN4MkFGRDsmI3gyMEU1OyI%2BPCFFTlRJVFkgZmZsaWcgIiYjeEZCMDA7Ij48IUVOVElUWSBmaWxpZyAiJiN4RkIwMTsiPjwhRU5USVRZIGZsbGlnICImI3hGQjAyOyI%2BPCFFTlRJVFkgZmZpbGlnICImI3hGQjAzOyI%2BPCFFTlRJVFkgZmZsbGlnICImI3hGQjA0OyI%2BPCFFTlRJVFkgQXNjciAiJiN4MUQ0OUM7Ij48IUVOVElUWSBDc2NyICImI3gxRDQ5RTsiPjwhRU5USVRZIERzY3IgIiYjeDFENDlGOyI%2BPCFFTlRJVFkgR3NjciAiJiN4MUQ0QTI7Ij48IUVOVElUWSBKc2NyICImI3gxRDRBNTsiPjwhRU5USVRZIEtzY3IgIiYjeDFENEE2OyI%2BPCFFTlRJVFkgTnNjciAiJiN4MUQ0QTk7Ij48IUVOVElUWSBPc2NyICImI3gxRDRBQTsiPjwhRU5USVRZIFBzY3IgIiYjeDFENEFCOyI%2BPCFFTlRJVFkgUXNjciAiJiN4MUQ0QUM7Ij48IUVOVElUWSBTc2NyICImI3gxRDRBRTsiPjwhRU5USVRZIFRzY3IgIiYjeDFENEFGOyI%2BPCFFTlRJVFkgVXNjciAiJiN4MUQ0QjA7Ij48IUVOVElUWSBWc2NyICImI3gxRDRCMTsiPjwhRU5USVRZIFdzY3IgIiYjeDFENEIyOyI%2BPCFFTlRJVFkgWHNjciAiJiN4MUQ0QjM7Ij48IUVOVElUWSBZc2NyICImI3gxRDRCNDsiPjwhRU5USVRZIFpzY3IgIiYjeDFENEI1OyI%2BPCFFTlRJVFkgYXNjciAiJiN4MUQ0QjY7Ij48IUVOVElUWSBic2NyICImI3gxRDRCNzsiPjwhRU5USVRZIGNzY3IgIiYjeDFENEI4OyI%2BPCFFTlRJVFkgZHNjciAiJiN4MUQ0Qjk7Ij48IUVOVElUWSBmc2NyICImI3gxRDRCQjsiPjwhRU5USVRZIGhzY3IgIiYjeDFENEJEOyI%2BPCFFTlRJVFkgaXNjciAiJiN4MUQ0QkU7Ij48IUVOVElUWSBqc2NyICImI3gxRDRCRjsiPjwhRU5USVRZIGtzY3IgIiYjeDFENEMwOyI%2BPCFFTlRJVFkgbHNjciAiJiN4MUQ0QzE7Ij48IUVOVElUWSBtc2NyICImI3gxRDRDMjsiPjwhRU5USVRZIG5zY3IgIiYjeDFENEMzOyI%2BPCFFTlRJVFkgcHNjciAiJiN4MUQ0QzU7Ij48IUVOVElUWSBxc2NyICImI3gxRDRDNjsiPjwhRU5USVRZIHJzY3IgIiYjeDFENEM3OyI%2BPCFFTlRJVFkgc3NjciAiJiN4MUQ0Qzg7Ij48IUVOVElUWSB0c2NyICImI3gxRDRDOTsiPjwhRU5USVRZIHVzY3IgIiYjeDFENENBOyI%2BPCFFTlRJVFkgdnNjciAiJiN4MUQ0Q0I7Ij48IUVOVElUWSB3c2NyICImI3gxRDRDQzsiPjwhRU5USVRZIHhzY3IgIiYjeDFENENEOyI%2BPCFFTlRJVFkgeXNjciAiJiN4MUQ0Q0U7Ij48IUVOVElUWSB6c2NyICImI3gxRDRDRjsiPjwhRU5USVRZIEFmciAiJiN4MUQ1MDQ7Ij48IUVOVElUWSBCZnIgIiYjeDFENTA1OyI%2BPCFFTlRJVFkgRGZyICImI3gxRDUwNzsiPjwhRU5USVRZIEVmciAiJiN4MUQ1MDg7Ij48IUVOVElUWSBGZnIgIiYjeDFENTA5OyI%2BPCFFTlRJVFkgR2ZyICImI3gxRDUwQTsiPjwhRU5USVRZIEpmciAiJiN4MUQ1MEQ7Ij48IUVOVElUWSBLZnIgIiYjeDFENTBFOyI%2BPCFFTlRJVFkgTGZyICImI3gxRDUwRjsiPjwhRU5USVRZIE1mciAiJiN4MUQ1MTA7Ij48IUVOVElUWSBOZnIgIiYjeDFENTExOyI%2BPCFFTlRJVFkgT2ZyICImI3gxRDUxMjsiPjwhRU5USVRZIFBmciAiJiN4MUQ1MTM7Ij48IUVOVElUWSBRZnIgIiYjeDFENTE0OyI%2BPCFFTlRJVFkgU2ZyICImI3gxRDUxNjsiPjwhRU5USVRZIFRmciAiJiN4MUQ1MTc7Ij48IUVOVElUWSBVZnIgIiYjeDFENTE4OyI%2BPCFFTlRJVFkgVmZyICImI3gxRDUxOTsiPjwhRU5USVRZIFdmciAiJiN4MUQ1MUE7Ij48IUVOVElUWSBYZnIgIiYjeDFENTFCOyI%2BPCFFTlRJVFkgWWZyICImI3gxRDUxQzsiPjwhRU5USVRZIGFmciAiJiN4MUQ1MUU7Ij48IUVOVElUWSBiZnIgIiYjeDFENTFGOyI%2BPCFFTlRJVFkgY2ZyICImI3gxRDUyMDsiPjwhRU5USVRZIGRmciAiJiN4MUQ1MjE7Ij48IUVOVElUWSBlZnIgIiYjeDFENTIyOyI%2BPCFFTlRJVFkgZmZyICImI3gxRDUyMzsiPjwhRU5USVRZIGdmciAiJiN4MUQ1MjQ7Ij48IUVOVElUWSBoZnIgIiYjeDFENTI1OyI%2BPCFFTlRJVFkgaWZyICImI3gxRDUyNjsiPjwhRU5USVRZIGpmciAiJiN4MUQ1Mjc7Ij48IUVOVElUWSBrZnIgIiYjeDFENTI4OyI%2BPCFFTlRJVFkgbGZyICImI3gxRDUyOTsiPjwhRU5USVRZIG1mciAiJiN4MUQ1MkE7Ij48IUVOVElUWSBuZnIgIiYjeDFENTJCOyI%2BPCFFTlRJVFkgb2ZyICImI3gxRDUyQzsiPjwhRU5USVRZIHBmciAiJiN4MUQ1MkQ7Ij48IUVOVElUWSBxZnIgIiYjeDFENTJFOyI%2BPCFFTlRJVFkgcmZyICImI3gxRDUyRjsiPjwhRU5USVRZIHNmciAiJiN4MUQ1MzA7Ij48IUVOVElUWSB0ZnIgIiYjeDFENTMxOyI%2BPCFFTlRJVFkgdWZyICImI3gxRDUzMjsiPjwhRU5USVRZIHZmciAiJiN4MUQ1MzM7Ij48IUVOVElUWSB3ZnIgIiYjeDFENTM0OyI%2BPCFFTlRJVFkgeGZyICImI3gxRDUzNTsiPjwhRU5USVRZIHlmciAiJiN4MUQ1MzY7Ij48IUVOVElUWSB6ZnIgIiYjeDFENTM3OyI%2BPCFFTlRJVFkgQW9wZiAiJiN4MUQ1Mzg7Ij48IUVOVElUWSBCb3BmICImI3gxRDUzOTsiPjwhRU5USVRZIERvcGYgIiYjeDFENTNCOyI%2BPCFFTlRJVFkgRW9wZiAiJiN4MUQ1M0M7Ij48IUVOVElUWSBGb3BmICImI3gxRDUzRDsiPjwhRU5USVRZIEdvcGYgIiYjeDFENTNFOyI%2BPCFFTlRJVFkgSW9wZiAiJiN4MUQ1NDA7Ij48IUVOVElUWSBKb3BmICImI3gxRDU0MTsiPjwhRU5USVRZIEtvcGYgIiYjeDFENTQyOyI%2BPCFFTlRJVFkgTG9wZiAiJiN4MUQ1NDM7Ij48IUVOVElUWSBNb3BmICImI3gxRDU0NDsiPjwhRU5USVRZIE9vcGYgIiYjeDFENTQ2OyI%2BPCFFTlRJVFkgU29wZiAiJiN4MUQ1NEE7Ij48IUVOVElUWSBUb3BmICImI3gxRDU0QjsiPjwhRU5USVRZIFVvcGYgIiYjeDFENTRDOyI%2BPCFFTlRJVFkgVm9wZiAiJiN4MUQ1NEQ7Ij48IUVOVElUWSBXb3BmICImI3gxRDU0RTsiPjwhRU5USVRZIFhvcGYgIiYjeDFENTRGOyI%2BPCFFTlRJVFkgWW9wZiAiJiN4MUQ1NTA7Ij48IUVOVElUWSBhb3BmICImI3gxRDU1MjsiPjwhRU5USVRZIGJvcGYgIiYjeDFENTUzOyI%2BPCFFTlRJVFkgY29wZiAiJiN4MUQ1NTQ7Ij48IUVOVElUWSBkb3BmICImI3gxRDU1NTsiPjwhRU5USVRZIGVvcGYgIiYjeDFENTU2OyI%2BPCFFTlRJVFkgZm9wZiAiJiN4MUQ1NTc7Ij48IUVOVElUWSBnb3BmICImI3gxRDU1ODsiPjwhRU5USVRZIGhvcGYgIiYjeDFENTU5OyI%2BPCFFTlRJVFkgaW9wZiAiJiN4MUQ1NUE7Ij48IUVOVElUWSBqb3BmICImI3gxRDU1QjsiPjwhRU5USVRZIGtvcGYgIiYjeDFENTVDOyI%2BPCFFTlRJVFkgbG9wZiAiJiN4MUQ1NUQ7Ij48IUVOVElUWSBtb3BmICImI3gxRDU1RTsiPjwhRU5USVRZIG5vcGYgIiYjeDFENTVGOyI%2BPCFFTlRJVFkgb29wZiAiJiN4MUQ1NjA7Ij48IUVOVElUWSBwb3BmICImI3gxRDU2MTsiPjwhRU5USVRZIHFvcGYgIiYjeDFENTYyOyI%2BPCFFTlRJVFkgcm9wZiAiJiN4MUQ1NjM7Ij48IUVOVElUWSBzb3BmICImI3gxRDU2NDsiPjwhRU5USVRZIHRvcGYgIiYjeDFENTY1OyI%2BPCFFTlRJVFkgdW9wZiAiJiN4MUQ1NjY7Ij48IUVOVElUWSB2b3BmICImI3gxRDU2NzsiPjwhRU5USVRZIHdvcGYgIiYjeDFENTY4OyI%2BPCFFTlRJVFkgeG9wZiAiJiN4MUQ1Njk7Ij48IUVOVElUWSB5b3BmICImI3gxRDU2QTsiPjwhRU5USVRZIHpvcGYgIiYjeDFENTZCOyI%2B">the URL given by this link</a>. (This
  URL is a DTD containing the <a href="https://www.w3.org/TR/xml/#sec-entity-decl">entity
  declarations</a> for the names listed in the <a href="#named-character-references" id="parsing-xhtml-documents:named-character-references">named character references</a> section.) <a href="#refsXML">[XML]</a></p>

  <ul class="brief"><li><code>-//W3C//DTD XHTML 1.0 Transitional//EN</code></li><li><code>-//W3C//DTD XHTML 1.1//EN</code></li><li><code>-//W3C//DTD XHTML 1.0 Strict//EN</code></li><li><code>-//W3C//DTD XHTML 1.0 Frameset//EN</code></li><li><code>-//W3C//DTD XHTML Basic 1.0//EN</code></li><li><code>-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN</code></li><li><code>-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN</code></li><li><code>-//W3C//DTD MathML 2.0//EN</code></li><li><code>-//WAPFORUM//DTD XHTML Mobile 1.0//EN</code></li><li><code>-//WAPFORUM//DTD XHTML Mobile 1.1//EN</code></li><li><code>-//WAPFORUM//DTD XHTML Mobile 1.2//EN</code></li></ul>

  <p>Furthermore, user agents should attempt to retrieve the above external entity's content when
  one of the above public identifiers is used, and should not attempt to retrieve any other external
  entity's content.</p>

  <p class="note">This is not strictly a <a href="https://infra.spec.whatwg.org/#willful-violation" id="parsing-xhtml-documents:willful-violation" data-x-internal="willful-violation">violation</a> of
  <cite>XML</cite>, but it does contradict the spirit of <cite>XML</cite>'s requirements. This is
  motivated by a desire for user agents to all handle entities in an interoperable fashion without
  requiring any network access for handling external subsets. <a href="#refsXML">[XML]</a></p>

  <p>XML parsers can be invoked with <dfn id="xml-scripting-support-enabled" data-export="">XML scripting support enabled</dfn> or <dfn id="xml-scripting-support-disabled" data-export="">XML scripting support disabled</dfn>. Except where otherwise specified, XML parsers are
  invoked with <a href="#xml-scripting-support-enabled" id="parsing-xhtml-documents:xml-scripting-support-enabled">XML scripting support enabled</a>.</p>

  <div data-algorithm="">
  <p id="scriptTagXML">When an <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-3">XML parser</a> with <a href="#xml-scripting-support-enabled" id="parsing-xhtml-documents:xml-scripting-support-enabled-2">XML scripting support
  enabled</a> creates a <code id="parsing-xhtml-documents:the-script-element"><a href="#the-script-element">script</a></code> element, it must have its <a href="#parser-document" id="parsing-xhtml-documents:parser-document">parser
  document</a> set and its <a href="#script-force-async" id="parsing-xhtml-documents:script-force-async">force async</a> set to false. If
  the parser was created as part of the <a href="#xml-fragment-parsing-algorithm" id="parsing-xhtml-documents:xml-fragment-parsing-algorithm">XML fragment parsing algorithm</a>, then the
  element's <a href="#already-started" id="parsing-xhtml-documents:already-started">already started</a> must be set to true. When the element's end tag is
  subsequently parsed, the user agent must <a href="#perform-a-microtask-checkpoint" id="parsing-xhtml-documents:perform-a-microtask-checkpoint">perform a microtask checkpoint</a>, and then
  <a href="#prepare-the-script-element" id="parsing-xhtml-documents:prepare-the-script-element">prepare</a> the <code id="parsing-xhtml-documents:the-script-element-2"><a href="#the-script-element">script</a></code> element. If this
  causes there to be a <a href="#pending-parsing-blocking-script" id="parsing-xhtml-documents:pending-parsing-blocking-script">pending parsing-blocking script</a>, then the user agent must run
  the following steps:</p>


  <ol><li><p>Block this instance of the <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-4">XML parser</a>, such that the <a href="#event-loop" id="parsing-xhtml-documents:event-loop">event loop</a>
   will not run <a href="#concept-task" id="parsing-xhtml-documents:concept-task">tasks</a> that invoke it.</p></li><li><p><a href="#spin-the-event-loop" id="parsing-xhtml-documents:spin-the-event-loop">Spin the event loop</a> until the parser's <code id="parsing-xhtml-documents:document-5"><a href="#document">Document</a></code> <a href="#has-no-style-sheet-that-is-blocking-scripts" id="parsing-xhtml-documents:has-no-style-sheet-that-is-blocking-scripts">has no
   style sheet that is blocking scripts</a> and the <a href="#pending-parsing-blocking-script" id="parsing-xhtml-documents:pending-parsing-blocking-script-2">pending parsing-blocking
   script</a>'s <a href="#ready-to-be-parser-executed" id="parsing-xhtml-documents:ready-to-be-parser-executed">ready to be parser-executed</a> is true.</p></li><li><p>Unblock this instance of the <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-5">XML parser</a>, such that <a href="#concept-task" id="parsing-xhtml-documents:concept-task-2">tasks</a> that invoke it can again be run.</p></li><li><p><a href="#execute-the-script-element" id="parsing-xhtml-documents:execute-the-script-element">Execute the script element</a> given by the <a href="#pending-parsing-blocking-script" id="parsing-xhtml-documents:pending-parsing-blocking-script-3">pending parsing-blocking
   script</a>.</p></li><li><p>Set the <a href="#pending-parsing-blocking-script" id="parsing-xhtml-documents:pending-parsing-blocking-script-4">pending parsing-blocking script</a> to null.</p></li></ol>
  </div>

  <p class="note">Since the <code id="parsing-xhtml-documents:dom-document-write"><a href="#dom-document-write">document.write()</a></code> API is not
  available for <a id="parsing-xhtml-documents:xml-documents" href="https://dom.spec.whatwg.org/#xml-document" data-x-internal="xml-documents">XML documents</a>, much of the complexity in the <a href="#html-parser" id="parsing-xhtml-documents:html-parser">HTML parser</a>
  is not needed in the <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-6">XML parser</a>.</p>

  <p class="note">When the <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-7">XML parser</a> has <a href="#xml-scripting-support-disabled" id="parsing-xhtml-documents:xml-scripting-support-disabled">XML scripting support disabled</a>,
  none of this happens.</p>

  <p id="templateTagXML">When an <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-8">XML parser</a> would append a node to a
  <code id="parsing-xhtml-documents:the-template-element"><a href="#the-template-element">template</a></code> element, it must instead append it to the <code id="parsing-xhtml-documents:the-template-element-2"><a href="#the-template-element">template</a></code> element's
  <a href="#template-contents" id="parsing-xhtml-documents:template-contents">template contents</a> (a <code id="parsing-xhtml-documents:documentfragment"><a data-x-internal="documentfragment" href="https://dom.spec.whatwg.org/#interface-documentfragment">DocumentFragment</a></code> node).</p>

  <p class="note">This is a <a id="parsing-xhtml-documents:willful-violation-2" href="https://infra.spec.whatwg.org/#willful-violation" data-x-internal="willful-violation">willful violation</a> of <cite>XML</cite>; unfortunately,
  XML is not formally extensible in the manner that is needed for <code id="parsing-xhtml-documents:the-template-element-3"><a href="#the-template-element">template</a></code> processing.
  <a href="#refsXML">[XML]</a></p>

  <div data-algorithm="">
  <p>When an <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-9">XML parser</a> creates a <code id="parsing-xhtml-documents:node"><a data-x-internal="node" href="https://dom.spec.whatwg.org/#interface-node">Node</a></code> object, its <a id="parsing-xhtml-documents:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>
  must be set to the <a id="parsing-xhtml-documents:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> of
  the node into which the newly created node is to be inserted.</p>
  </div>

  <p>Certain algorithms in this specification <dfn id="feed-the-parser">spoon-feed the
  parser</dfn> characters one at a time. In such cases, the <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-10">XML parser</a> must act
  as it would have if faced with a single string consisting of the concatenation of all those
  characters.</p>

  <div data-algorithm="">
  <p>When an <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-11">XML parser</a> reaches the end of its input, it must <a href="#stop-parsing" id="parsing-xhtml-documents:stop-parsing">stop
  parsing</a>, following the same rules as the <a href="#html-parser" id="parsing-xhtml-documents:html-parser-2">HTML parser</a>. An <a href="#xml-parser" id="parsing-xhtml-documents:xml-parser-12">XML
  parser</a> can also be <a href="#abort-a-parser" id="parsing-xhtml-documents:abort-a-parser">aborted</a>, which must again be done in
  the same way as for an <a href="#html-parser" id="parsing-xhtml-documents:html-parser-3">HTML parser</a>.</p>
  </div>

  <p>For the purposes of conformance checkers, if a resource is determined to be in <a href="#the-xhtml-syntax" id="parsing-xhtml-documents:the-xhtml-syntax">the XML
  syntax</a>, then it is an <a href="https://dom.spec.whatwg.org/#xml-document" id="parsing-xhtml-documents:xml-documents-2" data-x-internal="xml-documents">XML document</a>.</p>





  <h3 id="serialising-xhtml-fragments"><span class="secno">14.3</span> Serializing XML fragments<a href="#serialising-xhtml-fragments" class="self-link"></a></h3>

  <p>The <dfn id="xml-fragment-serialisation-algorithm">XML fragment serialization
  algorithm</dfn> for a <code id="serialising-xhtml-fragments:document"><a href="#document">Document</a></code> or <code id="serialising-xhtml-fragments:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> node either returns a fragment
  of XML that represents that node or throws an exception.</p>

  <p>For <code id="serialising-xhtml-fragments:document-2"><a href="#document">Document</a></code>s, the algorithm must return a string in the form of a <a href="https://www.w3.org/TR/xml/#sec-well-formed">document entity</a>, if none of the error cases
  below apply.</p>

  <p>For <code id="serialising-xhtml-fragments:element-2"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>s, the algorithm must return a string in the form of an <a href="https://www.w3.org/TR/xml/#wf-entities">internal general parsed entity</a>, if none of the
  error cases below apply.</p>

  <p>In both cases, the string returned must be XML namespace-well-formed and must be an isomorphic
  serialization of all of that node's <a href="#relevant-child-nodes" id="serialising-xhtml-fragments:relevant-child-nodes">relevant child nodes</a>, in <a id="serialising-xhtml-fragments:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.
  User agents may adjust prefixes and namespace declarations in the serialization (and indeed might
  be forced to do so in some cases to obtain namespace-well-formed XML). User agents may use a
  combination of regular text and character references to represent <code id="serialising-xhtml-fragments:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes in the
  DOM.</p>

  <div data-algorithm="">
  <p>A node's <dfn id="relevant-child-nodes">relevant child nodes</dfn> are those that apply given the following rules:</p>

  <dl><dt>For <code id="serialising-xhtml-fragments:the-template-element"><a href="#the-template-element">template</a></code> elements</dt><dd>The <a href="#relevant-child-nodes" id="serialising-xhtml-fragments:relevant-child-nodes-2">relevant child nodes</a> are the child nodes of the <code id="serialising-xhtml-fragments:the-template-element-2"><a href="#the-template-element">template</a></code>
   element's <a href="#template-contents" id="serialising-xhtml-fragments:template-contents">template contents</a>, if any.</dd><dt>For all other nodes</dt><dd>The <a href="#relevant-child-nodes" id="serialising-xhtml-fragments:relevant-child-nodes-3">relevant child nodes</a> are the child nodes of node itself, if any.</dd></dl>
  </div>

  <p>For <code id="serialising-xhtml-fragments:element-3"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>s, if any of the elements in the serialization are in no namespace, the
  default namespace in scope for those elements must be explicitly declared as the empty string. (This doesn't apply in the <code id="serialising-xhtml-fragments:document-3"><a href="#document">Document</a></code> case.) <a href="#refsXML">[XML]</a>
  <a href="#refsXMLNS">[XMLNS]</a></p>

  <p>For the purposes of this section, an internal general parsed entity is considered XML
  namespace-well-formed if a document consisting of an element with no namespace declarations whose
  contents are the internal general parsed entity would itself be XML namespace-well-formed.</p>

  <p>If any of the following error cases are found in the DOM subtree being serialized, then the
  algorithm must throw an <a id="serialising-xhtml-fragments:invalidstateerror" href="https://webidl.spec.whatwg.org/#invalidstateerror" data-x-internal="invalidstateerror">"<code>InvalidStateError</code>"</a> <code id="serialising-xhtml-fragments:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>
  instead of returning a string:</p>

  <ul><li>A <code id="serialising-xhtml-fragments:document-4"><a href="#document">Document</a></code> node with no child element nodes.</li><li>A <code id="serialising-xhtml-fragments:documenttype"><a data-x-internal="documenttype" href="https://dom.spec.whatwg.org/#interface-documenttype">DocumentType</a></code> node that has an external subset public identifier that contains
   characters that are not matched by the XML <code>PubidChar</code> production. <a href="#refsXML">[XML]</a></li><li>A <code id="serialising-xhtml-fragments:documenttype-2"><a data-x-internal="documenttype" href="https://dom.spec.whatwg.org/#interface-documenttype">DocumentType</a></code> node that has an external subset system identifier that contains
   both a U+0022 QUOTATION MARK (") and a U+0027 APOSTROPHE (') or that contains characters that are
   not matched by the XML <code>Char</code> production. <a href="#refsXML">[XML]</a></li><li>A node with a  local name containing a U+003A COLON (:).</li><li>A node with a  local name that does not match the XML <code id="serialising-xhtml-fragments:xml-name"><a data-x-internal="xml-name" href="https://www.w3.org/TR/xml/#NT-Name">Name</a></code> production. <a href="#refsXML">[XML]</a></li><li>An <code id="serialising-xhtml-fragments:attr"><a data-x-internal="attr" href="https://dom.spec.whatwg.org/#interface-attr">Attr</a></code> node with no namespace whose local name is the lowercase string "<code>xmlns</code>". <a href="#refsXMLNS">[XMLNS]</a></li><li>An <code id="serialising-xhtml-fragments:element-4"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> node with two or more attributes with the same local name and
   namespace.</li><li>An <code id="serialising-xhtml-fragments:attr-2"><a data-x-internal="attr" href="https://dom.spec.whatwg.org/#interface-attr">Attr</a></code> node, <code id="serialising-xhtml-fragments:text-2"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> node, <code id="serialising-xhtml-fragments:comment-2"><a data-x-internal="comment-2" href="https://dom.spec.whatwg.org/#interface-comment">Comment</a></code> node, or
   <code id="serialising-xhtml-fragments:processinginstruction"><a data-x-internal="processinginstruction" href="https://dom.spec.whatwg.org/#interface-processinginstruction">ProcessingInstruction</a></code> node whose data contains characters that are not matched by
   the XML <code>Char</code> production. <a href="#refsXML">[XML]</a></li><li>A <code id="serialising-xhtml-fragments:comment-2-2"><a data-x-internal="comment-2" href="https://dom.spec.whatwg.org/#interface-comment">Comment</a></code> node whose data contains two adjacent U+002D HYPHEN-MINUS characters
   (-) or ends with such a character.</li><li>A <code id="serialising-xhtml-fragments:processinginstruction-2"><a data-x-internal="processinginstruction" href="https://dom.spec.whatwg.org/#interface-processinginstruction">ProcessingInstruction</a></code> node whose target name is an <a id="serialising-xhtml-fragments:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
   case-insensitive</a> match for the string "<code>xml</code>".</li><li>A <code id="serialising-xhtml-fragments:processinginstruction-3"><a data-x-internal="processinginstruction" href="https://dom.spec.whatwg.org/#interface-processinginstruction">ProcessingInstruction</a></code> node whose target name contains a U+003A COLON (:).</li><li>A <code id="serialising-xhtml-fragments:processinginstruction-4"><a data-x-internal="processinginstruction" href="https://dom.spec.whatwg.org/#interface-processinginstruction">ProcessingInstruction</a></code> node whose data contains the string "<code>?&gt;</code>".</li></ul>

  <p class="note">These are the only ways to make a DOM unserialisable. The DOM enforces all the
  other XML constraints; for example, trying to append two elements to a <code id="serialising-xhtml-fragments:document-5"><a href="#document">Document</a></code> node
  will throw a <a id="serialising-xhtml-fragments:hierarchyrequesterror" href="https://webidl.spec.whatwg.org/#hierarchyrequesterror" data-x-internal="hierarchyrequesterror">"<code>HierarchyRequestError</code>"</a> <code id="serialising-xhtml-fragments:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p>



  <h3 id="parsing-xhtml-fragments"><span class="secno">14.4</span> Parsing XML fragments<a href="#parsing-xhtml-fragments" class="self-link"></a></h3>

  <div data-algorithm="">
  <p>The <dfn id="xml-fragment-parsing-algorithm">XML fragment parsing algorithm</dfn> given an <code id="parsing-xhtml-fragments:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code> node <var id="parsing-xhtml-fragments:concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> and a string <var>input</var>, runs the
  following steps. They return a list of nodes.</p>

  <ol><li><p>Create a new <a href="#xml-parser" id="parsing-xhtml-fragments:xml-parser">XML parser</a>.</p></li><li>
    <p><a href="#feed-the-parser" id="parsing-xhtml-fragments:feed-the-parser">Feed the parser</a> just created the string corresponding to the start tag of <var id="parsing-xhtml-fragments:concept-frag-parse-context-2"><a href="#concept-frag-parse-context">context</a></var>, declaring all the namespace prefixes that are
    in scope on that element in the DOM, as well as declaring the default namespace (if any) that is
    in scope on that element in the DOM.</p>

    <p>A namespace prefix is in scope if the DOM <code>lookupNamespaceURI()</code> method
    on the element would return a non-null value for that prefix.</p>

    <p>The default namespace is the namespace for which the DOM <code>isDefaultNamespace()</code> method on the element would return true.</p>

    <p class="note">No <code>DOCTYPE</code> is passed to the parser, and therefore no
    external subset is referenced, and therefore no entities will be recognized.</p>
   </li><li><p><a href="#feed-the-parser" id="parsing-xhtml-fragments:feed-the-parser-2">Feed the parser</a> just created the string <var>input</var>.</p></li><li><p><a href="#feed-the-parser" id="parsing-xhtml-fragments:feed-the-parser-3">Feed the parser</a> just created the string corresponding to the end tag of <var id="parsing-xhtml-fragments:concept-frag-parse-context-3"><a href="#concept-frag-parse-context">context</a></var>.</p></li><li><p>If there is an XML well-formedness or XML namespace well-formedness error, then throw a
   <a id="parsing-xhtml-fragments:syntaxerror" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a> <code id="parsing-xhtml-fragments:domexception"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>If the <a id="parsing-xhtml-fragments:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> of the resulting <code id="parsing-xhtml-fragments:document"><a href="#document">Document</a></code> has any
   sibling nodes, then throw a <a id="parsing-xhtml-fragments:syntaxerror-2" href="https://webidl.spec.whatwg.org/#syntaxerror" data-x-internal="syntaxerror">"<code>SyntaxError</code>"</a>
   <code id="parsing-xhtml-fragments:domexception-2"><a data-x-internal="domexception" href="https://webidl.spec.whatwg.org/#dfn-DOMException">DOMException</a></code>.</p></li><li><p>Return the resulting <code id="parsing-xhtml-fragments:document-2"><a href="#document">Document</a></code> node's <a id="parsing-xhtml-fragments:document-element-2" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a>'s <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="parsing-xhtml-fragments:concept-tree-child" data-x-internal="concept-tree-child">children</a>, in <a id="parsing-xhtml-fragments:tree-order" href="https://dom.spec.whatwg.org/#concept-tree-order" data-x-internal="tree-order">tree order</a>.</p></li></ol>
  </div>

  



  

  <h2 id="rendering"><span class="secno">15</span> Rendering<a href="#rendering" class="self-link"></a></h2>

  <p><i>User agents are not required to present HTML documents in any particular way. However, this
  section provides a set of suggestions for rendering HTML documents that, if followed, are likely
  to lead to a user experience that closely resembles the experience intended by the documents'
  authors. So as to avoid confusion regarding the normativity of this section, "must" has not been
  used. Instead, the term "expected" is used to indicate behavior that will lead to this experience.
  For the purposes of conformance for user agents designated as <a href="#renderingUA">supporting
  the suggested default rendering</a>, the term "<dfn id="expected">expected</dfn>" in this section has the same
  conformance implications as "must".</i></p>


  <h3 id="introduction-16"><span class="secno">15.1</span> Introduction<a href="#introduction-16" class="self-link"></a></h3>

  <p>The suggestions in this section are generally expressed in CSS terms. User agents are
  <a href="#expected" id="introduction-16:expected">expected</a> to either support CSS, or translate from the CSS rules given in this
  section to approximations for other presentation mechanisms.</p>

  <p>In the absence of style-layer rules to the contrary (e.g. author style sheets), user agents are
  <a href="#expected" id="introduction-16:expected-2">expected</a> to render an element so that it conveys to the user the meaning that the
  element <a href="#represents" id="introduction-16:represents">represents</a>, as described by this specification.</p>

  <p>The suggestions in this section generally assume a visual output medium with a resolution of
  96dpi or greater, but HTML is intended to apply to multiple media (it is a
  <i>media-independent</i> language). User agent implementers are encouraged to adapt the
  suggestions in this section to their target media.</p>

  <hr>

  <div data-algorithm="">
  <p>An element is <dfn id="being-rendered" data-export="">being rendered</dfn> if it has any associated CSS layout boxes, SVG
  layout boxes, or some equivalent in other styling languages.</p>
  </div>

  <p class="note">Just being off-screen does not mean the element is not <a href="#being-rendered" id="introduction-16:being-rendered">being
  rendered</a>. The presence of the <code id="introduction-16:attr-hidden"><a href="#attr-hidden">hidden</a></code> attribute normally
  means the element is not <a href="#being-rendered" id="introduction-16:being-rendered-2">being rendered</a>, though this might be overridden by the style
  sheets.</p>

  <p class="note">The <a href="#fully-active" id="introduction-16:fully-active">fully active</a> state does not affect whether an element is
  <a href="#being-rendered" id="introduction-16:being-rendered-3">being rendered</a> or not. Even if a document is not <a href="#fully-active" id="introduction-16:fully-active-2">fully active</a> and not
  shown at all to the user, elements within it can still qualify as "being rendered".</p>

  <div data-algorithm="">
  <p>An element is said to <dfn id="intersect-the-viewport">intersect the viewport</dfn> when it is <a href="#being-rendered" id="introduction-16:being-rendered-4">being rendered</a>
  and its associated CSS layout box intersects the <a id="introduction-16:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>.</p>
  </div>

  <p class="note">Similar to the <a href="#being-rendered" id="introduction-16:being-rendered-5">being rendered</a> state, elements in non-<a href="#fully-active" id="introduction-16:fully-active-3">fully
  active</a> documents can still <a href="#intersect-the-viewport" id="introduction-16:intersect-the-viewport">intersect the viewport</a>. The <a id="introduction-16:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>
  is not shared between documents and might not always be shown to the user, so an element in a
  non-<a href="#fully-active" id="introduction-16:fully-active-4">fully active</a> document can still intersect the <a id="introduction-16:viewport-3" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> associated
  with its document.</p>

  <p class="note">This specification does not define the precise timing for when the intersection is
  tested, but it is suggested that the timing match that of the Intersection Observer API. <a href="#refsINTERSECTIONOBSERVER">[INTERSECTIONOBSERVER]</a></p>

  <div data-algorithm="">
  <p>An element is <dfn id="delegating-its-rendering-to-its-children">delegating its rendering to its children</dfn> if it is not <a href="#being-rendered" id="introduction-16:being-rendered-6">being
  rendered</a> but its children (if any) could <a href="#being-rendered" id="introduction-16:being-rendered-7">be rendered</a>,
  as a result of CSS 'display: contents', or some equivalent in other styling languages.
  <a href="#refsCSSDISPLAY">[CSSDISPLAY]</a></p>
  </div>

  <hr>

  <p>User agents that do not honor author-level CSS style sheets are nonetheless
  <a href="#expected" id="introduction-16:expected-3">expected</a> to act as if they applied the CSS rules given in these sections in a manner
  consistent with this specification and the relevant CSS and Unicode specifications.
  <a href="#refsCSS">[CSS]</a> <a href="#refsUNICODE">[UNICODE]</a> <a href="#refsBIDI">[BIDI]</a></p>

  <p class="note">This is especially important for issues relating to the <a id="introduction-16:'display'" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a>,
  <a id="introduction-16:'unicode-bidi'" href="https://drafts.csswg.org/css-writing-modes/#unicode-bidi" data-x-internal="'unicode-bidi'">'unicode-bidi'</a>, and <a id="introduction-16:'direction'" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a> properties.</p>



  <h3 id="the-css-user-agent-style-sheet-and-presentational-hints"><span class="secno">15.2</span> The CSS user agent style sheet and presentational hints<a href="#the-css-user-agent-style-sheet-and-presentational-hints" class="self-link"></a></h3>

  <p>The CSS rules given in these subsections are, except where otherwise specified,
  <a href="#expected" id="the-css-user-agent-style-sheet-and-presentational-hints:expected">expected</a> to be used as part of the user-agent level style sheet defaults for all
  documents that contain <a href="#html-elements" id="the-css-user-agent-style-sheet-and-presentational-hints:html-elements">HTML elements</a>.</p>

  <p>Some rules are intended for the author-level zero-specificity presentational hints part of the
  CSS cascade; these are explicitly called out as <dfn id="presentational-hints" data-lt="presentational hint" data-export="">presentational hints</dfn>.</p>

  <hr>

  <div data-algorithm="">
  <p>When the text below says that an attribute <var>attribute</var> on an element
  <var>element</var> <dfn id="maps-to-the-pixel-length-property">maps to the pixel length property</dfn> (or properties)
  <var>properties</var>, it means that if <var>element</var> has an attribute <var>attribute</var>
  set, and parsing that attribute's value using the <a href="#rules-for-parsing-non-negative-integers" id="the-css-user-agent-style-sheet-and-presentational-hints:rules-for-parsing-non-negative-integers">rules for parsing non-negative
  integers</a> doesn't generate an error, then the user agent is <a href="#expected" id="the-css-user-agent-style-sheet-and-presentational-hints:expected-2">expected</a> to use
  the parsed value as a pixel length for a <a href="#presentational-hints" id="the-css-user-agent-style-sheet-and-presentational-hints:presentational-hints">presentational
  hint</a> for <var>properties</var>.</p>
  </div>

  <div data-algorithm="">
  <p>When the text below says that an attribute <var>attribute</var> on an element
  <var>element</var> <dfn id="maps-to-the-dimension-property">maps to the dimension property</dfn> (or properties)
  <var>properties</var>, it means that if <var>element</var> has an attribute <var>attribute</var>
  set, and parsing that attribute's value using the <a href="#rules-for-parsing-dimension-values" id="the-css-user-agent-style-sheet-and-presentational-hints:rules-for-parsing-dimension-values">rules for parsing dimension values</a>
  doesn't generate an error, then the user agent is <a href="#expected" id="the-css-user-agent-style-sheet-and-presentational-hints:expected-3">expected</a> to use the parsed
  dimension as the value for a <a href="#presentational-hints" id="the-css-user-agent-style-sheet-and-presentational-hints:presentational-hints-2">presentational hint</a> for
  <var>properties</var>, with the value given as a pixel length if the dimension was a length, and
  with the value given as a percentage if the dimension was a percentage.</p>
  </div>

  <div data-algorithm="">
  <p>When the text below says that an attribute <var>attribute</var> on an element
  <var>element</var> <dfn id="maps-to-the-dimension-property-(ignoring-zero)">maps to the dimension property (ignoring zero)</dfn> (or properties)
  <var>properties</var>, it means that if <var>element</var> has an attribute <var>attribute</var>
  set, and parsing that attribute's value using the <a href="#rules-for-parsing-non-zero-dimension-values" id="the-css-user-agent-style-sheet-and-presentational-hints:rules-for-parsing-non-zero-dimension-values">rules for parsing nonzero dimension
  values</a> doesn't generate an error, then the user agent is <a href="#expected" id="the-css-user-agent-style-sheet-and-presentational-hints:expected-4">expected</a> to use the
  parsed dimension as the value for a <a href="#presentational-hints" id="the-css-user-agent-style-sheet-and-presentational-hints:presentational-hints-3">presentational
  hint</a> for <var>properties</var>, with the value given as a pixel length if the dimension
  was a length, and with the value given as a percentage if the dimension was a percentage.</p>
  </div>

  <div data-algorithm="">
  <p>When the text below says that a pair of attributes <var>w</var> and <var>h</var> on an
  element <var>element</var> <dfn id="map-to-the-aspect-ratio-property">map to the aspect-ratio property</dfn>, it means that if
  <var>element</var> has both attributes <var>w</var> and <var>h</var>, and parsing those
  attributes' values using the <a href="#rules-for-parsing-non-negative-integers" id="the-css-user-agent-style-sheet-and-presentational-hints:rules-for-parsing-non-negative-integers-2">rules for parsing non-negative integers</a> doesn't
  generate an error for either, then the user agent is <a href="#expected" id="the-css-user-agent-style-sheet-and-presentational-hints:expected-5">expected</a> to use the parsed
  integers as a <a href="#presentational-hints" id="the-css-user-agent-style-sheet-and-presentational-hints:presentational-hints-4">presentational hint</a> for the
  <a id="the-css-user-agent-style-sheet-and-presentational-hints:'aspect-ratio'" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio" data-x-internal="'aspect-ratio'">'aspect-ratio'</a> property of the form <code>auto <var>w</var> /
  <var>h</var></code>.</p>
  </div>

  <div data-algorithm="">
  <p>When the text below says that a pair of attributes <var>w</var> and <var>h</var> on an
  element <var>element</var> <dfn id="map-to-the-aspect-ratio-property-(using-dimension-rules)">map to the aspect-ratio property (using dimension rules)</dfn>, it
  means that if <var>element</var> has both attributes <var>w</var> and <var>h</var>, and parsing
  those attributes' values using the <a href="#rules-for-parsing-dimension-values" id="the-css-user-agent-style-sheet-and-presentational-hints:rules-for-parsing-dimension-values-2">rules for parsing dimension values</a> doesn't
  generate an error or return a percentage for either, then the user agent is <a href="#expected" id="the-css-user-agent-style-sheet-and-presentational-hints:expected-6">expected</a>
  to use the parsed dimensions as a <a href="#presentational-hints" id="the-css-user-agent-style-sheet-and-presentational-hints:presentational-hints-5">presentational hint</a>
  for the <a id="the-css-user-agent-style-sheet-and-presentational-hints:'aspect-ratio'-2" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio" data-x-internal="'aspect-ratio'">'aspect-ratio'</a> property of the form <code>auto <var>w</var> /
  <var>h</var></code>.</p>
  </div>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="align-descendants">align descendants</dfn> of a node, the user agent is
  <a href="#expected" id="the-css-user-agent-style-sheet-and-presentational-hints:expected-7">expected</a> to align only those descendants that have both their
  <a id="the-css-user-agent-style-sheet-and-presentational-hints:'margin-inline-start'" href="https://drafts.csswg.org/css-logical/#propdef-margin-inline-start" data-x-internal="'margin-inline-start'">'margin-inline-start'</a> and <a id="the-css-user-agent-style-sheet-and-presentational-hints:'margin-inline-end'" href="https://drafts.csswg.org/css-logical/#propdef-margin-inline-end" data-x-internal="'margin-inline-end'">'margin-inline-end'</a> properties computing to a
  value other than 'auto', that are over-constrained and that have one of those two margins with a
  <a id="the-css-user-agent-style-sheet-and-presentational-hints:used-value" href="https://drafts.csswg.org/css-cascade/#used-value" data-x-internal="used-value">used value</a> forced to a greater value, and that do not themselves have an applicable
  <code>align</code> attribute. When multiple elements are to <a href="#align-descendants" id="the-css-user-agent-style-sheet-and-presentational-hints:align-descendants">align</a> a particular descendant, the most deeply nested such element is
  <a href="#expected" id="the-css-user-agent-style-sheet-and-presentational-hints:expected-8">expected</a> to override the others. Aligned elements are <a href="#expected" id="the-css-user-agent-style-sheet-and-presentational-hints:expected-9">expected</a> to be
  aligned by having the <a href="https://drafts.csswg.org/css-cascade/#used-value" id="the-css-user-agent-style-sheet-and-presentational-hints:used-value-2" data-x-internal="used-value">used values</a> of their margins on the
  <a id="the-css-user-agent-style-sheet-and-presentational-hints:line-left" href="https://drafts.csswg.org/css-writing-modes/#line-left" data-x-internal="line-left">line-left</a> and <a id="the-css-user-agent-style-sheet-and-presentational-hints:line-right" href="https://drafts.csswg.org/css-writing-modes/#line-right" data-x-internal="line-right">line-right</a> sides be set accordingly.
  <a href="#refsCSSLOGICAL">[CSSLOGICAL]</a> <a href="#refsCSSWM">[CSSWM]</a></p>
  </div>



  <h3 id="non-replaced-elements"><span class="secno">15.3</span> Non-replaced elements<a href="#non-replaced-elements" class="self-link"></a></h3>


  <h4 id="hidden-elements"><span class="secno">15.3.1</span> Hidden elements<a href="#hidden-elements" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">area, base, basefont, datalist, head, link, meta, noembed,</c->
<c- f="">noframes, param, rp, script, style, template, title </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c-> none<c- p="">;</c->
<c- p="">}</c->

<span id="hiddenCSS"><c- f="">[hidden]:not([hidden=until-found i]):not(embed)</c-></span><c- f=""> </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c-> none<c- p="">;</c->
<c- p="">}</c->

<c- f="">[hidden=until-found i]:not(embed) </c-><c- p="">{</c->
  <c- k="">content-visibility</c-><c- p="">:</c-> hidden<c- p="">;</c->
<c- p="">}</c->

<c- f="">embed[hidden] </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> inline<c- p="">;</c-> <c- k="">height</c-><c- p="">:</c-> <c- m="">0</c-><c- p="">;</c-> <c- k="">width</c-><c- p="">:</c-> <c- m="">0</c-><c- p="">;</c-> <c- p="">}</c-> 

<c- f="">input[type=hidden i] </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> none !important; }

@media (scripting) {
  noscript { display: none !important; }
}</code></pre>


  <h4 id="the-page"><span class="secno">15.3.2</span> The page<a href="#the-page" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">html, body </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> block<c- p="">;</c-> <c- p="">}</c-></code></pre>


  

  <div data-algorithm="">
  <p>For each property in the table below, given a <code id="the-page:the-body-element"><a href="#the-body-element">body</a></code> element, the first attribute
  that exists <a href="#maps-to-the-pixel-length-property" id="the-page:maps-to-the-pixel-length-property">maps to the pixel length property</a> on the <code id="the-page:the-body-element-2"><a href="#the-body-element">body</a></code> element. If
  none of the attributes for a property are found, or if the value of the attribute that was found
  cannot be parsed successfully, then a default value of 8px is <a href="#expected" id="the-page:expected">expected</a> to be used
  for that property instead.</p>

  <table><thead><tr><th>Property
     </th><th>Source
   </th></tr></thead><tbody><tr><td rowspan="3"><a id="the-page:'margin-top'" href="https://drafts.csswg.org/css-box/#propdef-margin-top" data-x-internal="'margin-top'">'margin-top'</a>
     </td><td>The <code id="the-page:the-body-element-3"><a href="#the-body-element">body</a></code> element's <code id="the-page:attr-body-marginheight"><a href="#attr-body-marginheight">marginheight</a></code> attribute
    </td></tr><tr><td>The <code id="the-page:the-body-element-4"><a href="#the-body-element">body</a></code> element's <code id="the-page:attr-body-topmargin"><a href="#attr-body-topmargin">topmargin</a></code> attribute
    </td></tr><tr><td>The <code id="the-page:the-body-element-5"><a href="#the-body-element">body</a></code> element's <a href="#container-frame-element" id="the-page:container-frame-element">container frame element</a>'s <code id="the-page:attr-iframe-marginheight"><a href="#attr-iframe-marginheight">marginheight</a></code> attribute
   </td></tr></tbody><tbody><tr><td rowspan="3"><a id="the-page:'margin-right'" href="https://drafts.csswg.org/css-box/#propdef-margin-right" data-x-internal="'margin-right'">'margin-right'</a>
     </td><td>The <code id="the-page:the-body-element-6"><a href="#the-body-element">body</a></code> element's <code id="the-page:attr-body-marginwidth"><a href="#attr-body-marginwidth">marginwidth</a></code> attribute
    </td></tr><tr><td>The <code id="the-page:the-body-element-7"><a href="#the-body-element">body</a></code> element's <code id="the-page:attr-body-rightmargin"><a href="#attr-body-rightmargin">rightmargin</a></code> attribute
    </td></tr><tr><td>The <code id="the-page:the-body-element-8"><a href="#the-body-element">body</a></code> element's <a href="#container-frame-element" id="the-page:container-frame-element-2">container frame element</a>'s <code id="the-page:attr-iframe-marginwidth"><a href="#attr-iframe-marginwidth">marginwidth</a></code> attribute
   </td></tr></tbody><tbody><tr><td rowspan="3"><a id="the-page:'margin-bottom'" href="https://drafts.csswg.org/css-box/#propdef-margin-bottom" data-x-internal="'margin-bottom'">'margin-bottom'</a>
     </td><td>The <code id="the-page:the-body-element-9"><a href="#the-body-element">body</a></code> element's <code id="the-page:attr-body-marginheight-2"><a href="#attr-body-marginheight">marginheight</a></code> attribute
    </td></tr><tr><td>The <code id="the-page:the-body-element-10"><a href="#the-body-element">body</a></code> element's <code id="the-page:attr-body-bottommargin"><a href="#attr-body-bottommargin">bottommargin</a></code> attribute
    </td></tr><tr><td>The <code id="the-page:the-body-element-11"><a href="#the-body-element">body</a></code> element's <a href="#container-frame-element" id="the-page:container-frame-element-3">container frame element</a>'s <code id="the-page:attr-iframe-marginheight-2"><a href="#attr-iframe-marginheight">marginheight</a></code> attribute
   </td></tr></tbody><tbody><tr><td rowspan="3"><a id="the-page:'margin-left'" href="https://drafts.csswg.org/css-box/#propdef-margin-left" data-x-internal="'margin-left'">'margin-left'</a>
     </td><td>The <code id="the-page:the-body-element-12"><a href="#the-body-element">body</a></code> element's <code id="the-page:attr-body-marginwidth-2"><a href="#attr-body-marginwidth">marginwidth</a></code> attribute
    </td></tr><tr><td>The <code id="the-page:the-body-element-13"><a href="#the-body-element">body</a></code> element's <code id="the-page:attr-body-leftmargin"><a href="#attr-body-leftmargin">leftmargin</a></code> attribute
    </td></tr><tr><td>The <code id="the-page:the-body-element-14"><a href="#the-body-element">body</a></code> element's <a href="#container-frame-element" id="the-page:container-frame-element-4">container frame element</a>'s <code id="the-page:attr-iframe-marginwidth-2"><a href="#attr-iframe-marginwidth">marginwidth</a></code> attribute
  </td></tr></tbody></table>
  </div>

  <div data-algorithm="">
  <p>If the <code id="the-page:the-body-element-15"><a href="#the-body-element">body</a></code> element's <a id="the-page:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>'s <a href="#node-navigable" id="the-page:node-navigable">node navigable</a> is
  a <a href="#child-navigable" id="the-page:child-navigable">child navigable</a>, and the <a href="#nav-container" id="the-page:nav-container">container</a> of that
  <a href="#navigable" id="the-page:navigable">navigable</a> is a <code id="the-page:frame"><a href="#frame">frame</a></code> or <code id="the-page:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element, then the
  <dfn id="container-frame-element">container frame element</dfn> of the <code id="the-page:the-body-element-16"><a href="#the-body-element">body</a></code> element is that <code id="the-page:frame-2"><a href="#frame">frame</a></code> or
  <code id="the-page:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> element. Otherwise, there is no <a href="#container-frame-element" id="the-page:container-frame-element-5">container frame element</a>.</p>
  </div>

  <p class="warning">The above requirements imply that a page can change the margins of another page
  (including one from another <a href="#concept-origin" id="the-page:concept-origin">origin</a>) using, for example, an <code id="the-page:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code>. This
  is potentially a security risk, as it might in some cases allow an attack to contrive a situation
  in which a page is rendered not as the author intended, possibly for the purposes of phishing or
  otherwise misleading the user.</p>

  <hr>

  <div data-algorithm="">
  <p>If a <code id="the-page:document"><a href="#document">Document</a></code>'s <a href="#node-navigable" id="the-page:node-navigable-2">node navigable</a> is a <a href="#child-navigable" id="the-page:child-navigable-2">child navigable</a>,
  then it is <a href="#expected" id="the-page:expected-2">expected</a> to be positioned and sized to fit inside the <a id="the-page:content-box" href="https://drafts.csswg.org/css-box/#content-box" data-x-internal="content-box">content
  box</a> of the <a href="#nav-container" id="the-page:nav-container-2">container</a> of that <a href="#navigable" id="the-page:navigable-2">navigable</a>.
  If the <a href="#nav-container" id="the-page:nav-container-3">container</a> is not <a href="#being-rendered" id="the-page:being-rendered">being rendered</a>, the
  <a href="#navigable" id="the-page:navigable-3">navigable</a> is <a href="#expected" id="the-page:expected-3">expected</a> to have a <a id="the-page:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> with zero width
  and zero height.</p>
  </div>

  <div data-algorithm="">
  <p>If a <code id="the-page:document-2"><a href="#document">Document</a></code>'s <a href="#node-navigable" id="the-page:node-navigable-3">node navigable</a> is a <a href="#child-navigable" id="the-page:child-navigable-3">child navigable</a>,
  the <a href="#nav-container" id="the-page:nav-container-4">container</a> of that <a href="#navigable" id="the-page:navigable-4">navigable</a> is a
  <code id="the-page:frame-3"><a href="#frame">frame</a></code> or <code id="the-page:the-iframe-element-4"><a href="#the-iframe-element">iframe</a></code> element, that element has a <code>scrolling</code> attribute, and that attribute's value is an <a id="the-page:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for the string "<code>off</code>", "<code>noscroll</code>", or "<code>no</code>", then the user agent is
  <a href="#expected" id="the-page:expected-4">expected</a> to prevent any scrollbars from being shown for the <a id="the-page:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> of
  the <code id="the-page:document-3"><a href="#document">Document</a></code>'s <a href="#node-navigable" id="the-page:node-navigable-4">node navigable</a>, regardless of the
  <a id="the-page:'overflow'" href="https://drafts.csswg.org/css-overflow/#propdef-overflow" data-x-internal="'overflow'">'overflow'</a> property that applies to that <a id="the-page:viewport-3" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>When a <code id="the-page:the-body-element-17"><a href="#the-body-element">body</a></code> element has a <code id="the-page:attr-background"><a href="#attr-background">background</a></code>
  attribute set to a non-empty value, the new value is <a href="#expected" id="the-page:expected-5">expected</a> to be <a href="#encoding-parsing-and-serializing-a-url" id="the-page:encoding-parsing-and-serializing-a-url">encoding-parsed-and-serialized</a> relative to
  the element's <a id="the-page:node-document-2" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>, and if that does not return failure, the user agent is
  <a href="#expected" id="the-page:expected-6">expected</a> to treat the attribute as a <a href="#presentational-hints" id="the-page:presentational-hints">presentational hint</a> setting the element's <a id="the-page:'background-image'" href="https://drafts.csswg.org/css-backgrounds/#propdef-background-image" data-x-internal="'background-image'">'background-image'</a> property
  to the return value.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="the-page:the-body-element-18"><a href="#the-body-element">body</a></code> element has a <code id="the-page:attr-body-bgcolor"><a href="#attr-body-bgcolor">bgcolor</a></code>
  attribute set, the new value is <a href="#expected" id="the-page:expected-7">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="the-page:rules-for-parsing-a-legacy-colour-value">rules for
  parsing a legacy color value</a>, and if that does not return failure, the user agent is
  <a href="#expected" id="the-page:expected-8">expected</a> to treat the attribute as a <a href="#presentational-hints" id="the-page:presentational-hints-2">presentational hint</a> setting the element's <a id="the-page:'background-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-background-color" data-x-internal="'background-color'">'background-color'</a> property
  to the resulting color.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="the-page:the-body-element-19"><a href="#the-body-element">body</a></code> element has a <code id="the-page:attr-body-text"><a href="#attr-body-text">text</a></code> attribute, its
  value is <a href="#expected" id="the-page:expected-9">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="the-page:rules-for-parsing-a-legacy-colour-value-2">rules for parsing a legacy color
  value</a>, and if that does not return failure, the user agent is <a href="#expected" id="the-page:expected-10">expected</a> to
  treat the attribute as a <a href="#presentational-hints" id="the-page:presentational-hints-3">presentational hint</a> setting
  the element's <a id="the-page:'color'" href="https://drafts.csswg.org/css-color/#the-color-property" data-x-internal="'color'">'color'</a> property to the resulting color.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="the-page:the-body-element-20"><a href="#the-body-element">body</a></code> element has a <code id="the-page:attr-body-link"><a href="#attr-body-link">link</a></code> attribute, its
  value is <a href="#expected" id="the-page:expected-11">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="the-page:rules-for-parsing-a-legacy-colour-value-3">rules for parsing a legacy color
  value</a>, and if that does not return failure, the user agent is <a href="#expected" id="the-page:expected-12">expected</a> to
  treat the attribute as a <a href="#presentational-hints" id="the-page:presentational-hints-4">presentational hint</a> setting
  the <a id="the-page:'color'-2" href="https://drafts.csswg.org/css-color/#the-color-property" data-x-internal="'color'">'color'</a> property of any element in the <code id="the-page:document-4"><a href="#document">Document</a></code> matching the <code id="the-page:selector-link"><a href="#selector-link">:link</a></code> <a id="the-page:pseudo-class" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> to the resulting color.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="the-page:the-body-element-21"><a href="#the-body-element">body</a></code> element has a <code id="the-page:attr-body-vlink"><a href="#attr-body-vlink">vlink</a></code> attribute,
  its value is <a href="#expected" id="the-page:expected-13">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="the-page:rules-for-parsing-a-legacy-colour-value-4">rules for parsing a legacy color
  value</a>, and if that does not return failure, the user agent is <a href="#expected" id="the-page:expected-14">expected</a> to
  treat the attribute as a <a href="#presentational-hints" id="the-page:presentational-hints-5">presentational hint</a> setting
  the <a id="the-page:'color'-3" href="https://drafts.csswg.org/css-color/#the-color-property" data-x-internal="'color'">'color'</a> property of any element in the <code id="the-page:document-5"><a href="#document">Document</a></code> matching the <code id="the-page:selector-visited"><a href="#selector-visited">:visited</a></code> <a id="the-page:pseudo-class-2" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> to the resulting color.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="the-page:the-body-element-22"><a href="#the-body-element">body</a></code> element has an <code id="the-page:attr-body-alink"><a href="#attr-body-alink">alink</a></code> attribute,
  its value is <a href="#expected" id="the-page:expected-15">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="the-page:rules-for-parsing-a-legacy-colour-value-5">rules for parsing a legacy color
  value</a>, and if that does not return failure, the user agent is <a href="#expected" id="the-page:expected-16">expected</a> to
  treat the attribute as a <a href="#presentational-hints" id="the-page:presentational-hints-6">presentational hint</a> setting
  the <a id="the-page:'color'-4" href="https://drafts.csswg.org/css-color/#the-color-property" data-x-internal="'color'">'color'</a> property of any element in the <code id="the-page:document-6"><a href="#document">Document</a></code> matching the
  <code id="the-page:selector-active"><a href="#selector-active">:active</a></code> <a id="the-page:pseudo-class-3" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> and either the <code id="the-page:selector-link-2"><a href="#selector-link">:link</a></code> <a id="the-page:pseudo-class-4" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> or the <code id="the-page:selector-visited-2"><a href="#selector-visited">:visited</a></code> <a id="the-page:pseudo-class-5" href="https://drafts.csswg.org/selectors/#pseudo-class" data-x-internal="pseudo-class">pseudo-class</a> to the resulting color.</p>
  </div>



  <h4 id="flow-content-3"><span class="secno">15.3.3</span> Flow content<a href="#flow-content-3" class="self-link"></a></h4>

  

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">address, blockquote, center, dialog, div, figure, figcaption, footer, form,</c->
<c- f="">header, hr, legend, listing, main, p, plaintext, pre, search, xmp </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c-> block<c- p="">;</c->
<c- p="">}</c->

<c- f="">blockquote, figure, listing, p, plaintext, pre, xmp </c-><c- p="">{</c->
  <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">em</c-><c- p="">;</c->
<c- p="">}</c->

<c- f="">blockquote, figure </c-><c- p="">{</c-> <c- k="">margin-inline</c-><c- p="">:</c-> <c- m="">40</c-><c- l="">px</c-><c- p="">;</c-> <c- p="">}</c->

<c- f="">address </c-><c- p="">{</c-> <c- k="">font-style</c-><c- p="">:</c-> italic<c- p="">;</c-> <c- p="">}</c->
<c- f="">listing, plaintext, pre, xmp </c-><c- p="">{</c->
  <c- k="">font-family</c-><c- p="">:</c-> monospace<c- p="">;</c-> <c- k="">white-space</c-><c- p="">:</c-> pre<c- p="">;</c->
<c- p="">}</c->

<c- f="">dialog:not([open]) </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> none<c- p="">;</c-> <c- p="">}</c->
<c- f="">dialog </c-><c- p="">{</c->
  <c- k="">position</c-><c- p="">:</c-> absolute<c- p="">;</c->
  <c- k="">justify-self</c-><c- p="">:</c-> dialog<c- p="">;</c->
  <c- k="">border</c-><c- p="">:</c-> solid<c- p="">;</c->
  <c- k="">padding</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">background-color</c-><c- p="">:</c-> Canvas<c- p="">;</c->
  <c- k="">color</c-><c- p="">:</c-> CanvasText<c- p="">;</c->
<c- p="">}</c->
<c- f="">dialog:modal </c-><c- p="">{</c->
  <c- k="">position</c-><c- p="">:</c-> fixed<c- p="">;</c->
  <c- k="">place-self</c-><c- p="">:</c-> dialog<c- p="">;</c->
  <c- k="">overflow</c-><c- p="">:</c-> auto<c- p="">;</c->
  <c- k="">max-width</c-><c- p="">:</c-> <c- nf="">calc</c-><c- p="">(</c-><c- m="">100</c-><c- l="">%</c-> - <c- m="">6</c-><c- l="">px</c-> - <c- m="">2</c-><c- l="">em</c-><c- p="">);</c->
  <c- k="">max-height</c-><c- p="">:</c-> <c- nf="">calc</c-><c- p="">(</c-><c- m="">100</c-><c- l="">%</c-> - <c- m="">6</c-><c- l="">px</c-> - <c- m="">2</c-><c- l="">em</c-><c- p="">);</c->
<c- p="">}</c->
<c- f="">dialog::backdrop </c-><c- p="">{</c->
  <c- k="">background</c-><c- p="">:</c-> <c- nf="">rgba</c-><c- p="">(</c-><c- m="">0</c-><c- p="">,</c-><c- m="">0</c-><c- p="">,</c-><c- m="">0</c-><c- p="">,</c-><c- m="">0.1</c-><c- p="">);</c->
<c- p="">}</c->

<c- f="">[popover]:not(:popover-open):not(dialog[open]) </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c->none<c- p="">;</c->
<c- p="">}</c->

<c- f="">dialog:popover-open </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c->block<c- p="">;</c->
<c- p="">}</c->

<c- f="">[popover] </c-><c- p="">{</c->
  <c- k="">position</c-><c- p="">:</c-> fixed<c- p="">;</c->
  <c- k="">place-self</c-><c- p="">:</c-> dialog<c- p="">;</c->
  <c- k="">border</c-><c- p="">:</c-> solid<c- p="">;</c->
  <c- k="">padding</c-><c- p="">:</c-> <c- m="">0.25</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">overflow</c-><c- p="">:</c-> auto<c- p="">;</c->
  <c- k="">color</c-><c- p="">:</c-> CanvasText<c- p="">;</c->
  <c- k="">background-color</c-><c- p="">:</c-> Canvas<c- p="">;</c->
<c- p="">}</c->

<c- f="">:popover-open::backdrop </c-><c- p="">{</c->
  <c- k="">position</c-><c- p="">:</c-> fixed<c- p="">;</c->
  <c- k="">inset</c-><c- p="">:</c-> <c- m="">0</c-><c- p="">;</c->
  <c- k="">pointer-events</c-><c- p="">:</c-> none !important;
  background-color: transparent;
}

slot {
  display: contents;
}</code></pre>

  <p>The following rules are also <a href="#expected" id="flow-content-3:expected">expected</a> to apply, as <a href="#presentational-hints" id="flow-content-3:presentational-hints">presentational
  hints</a>:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">pre[wrap] </c-><c- p="">{</c-> <c- k="">white-space</c-><c- p="">:</c-> pre-wrap<c- p="">;</c-> <c- p="">}</c-></code></pre>

  <p>In <a id="flow-content-3:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, the following rules are also <a href="#expected" id="flow-content-3:expected-2">expected</a> to apply:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">form </c-><c- p="">{</c-> <c- k="">margin-block-end</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">em</c-><c- p="">;</c-> <c- p="">}</c-></code></pre>

  <hr>

  <div data-algorithm="">
  <p>The <code id="flow-content-3:center"><a href="#center">center</a></code> element, and the <code id="flow-content-3:the-div-element"><a href="#the-div-element">div</a></code> element when it has an <code id="flow-content-3:attr-div-align"><a href="#attr-div-align">align</a></code> attribute whose value is an <a id="flow-content-3:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for either the string "<code>center</code>" or the string
  "<code>middle</code>", are <a href="#expected" id="flow-content-3:expected-3">expected</a> to center text within themselves, as
  if they had their <a id="flow-content-3:'text-align'" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property set to 'center' in a <a href="#presentational-hints" id="flow-content-3:presentational-hints-2">presentational hint</a>, and to <a href="#align-descendants" id="flow-content-3:align-descendants">align descendants</a>
  to the center.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="flow-content-3:the-div-element-2"><a href="#the-div-element">div</a></code> element, when it has an <code id="flow-content-3:attr-div-align-2"><a href="#attr-div-align">align</a></code>
  attribute whose value is an <a id="flow-content-3:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>left</code>", is <a href="#expected" id="flow-content-3:expected-4">expected</a> to left-align text within itself, as if it had
  its <a id="flow-content-3:'text-align'-2" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property set to 'left' in a <a href="#presentational-hints" id="flow-content-3:presentational-hints-3">presentational hint</a>, and to <a href="#align-descendants" id="flow-content-3:align-descendants-2">align descendants</a> to the left.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="flow-content-3:the-div-element-3"><a href="#the-div-element">div</a></code> element, when it has an <code id="flow-content-3:attr-div-align-3"><a href="#attr-div-align">align</a></code>
  attribute whose value is an <a id="flow-content-3:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>right</code>", is <a href="#expected" id="flow-content-3:expected-5">expected</a> to right-align text within itself, as if it had
  its <a id="flow-content-3:'text-align'-3" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property set to 'right' in a <a href="#presentational-hints" id="flow-content-3:presentational-hints-4">presentational hint</a>, and to <a href="#align-descendants" id="flow-content-3:align-descendants-3">align descendants</a> to the right.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="flow-content-3:the-div-element-4"><a href="#the-div-element">div</a></code> element, when it has an <code id="flow-content-3:attr-div-align-4"><a href="#attr-div-align">align</a></code>
  attribute whose value is an <a id="flow-content-3:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>justify</code>", is <a href="#expected" id="flow-content-3:expected-6">expected</a> to full-justify text within itself, as if it
  had its <a id="flow-content-3:'text-align'-4" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property set to 'justify' in a <a href="#presentational-hints" id="flow-content-3:presentational-hints-5">presentational hint</a>, and to <a href="#align-descendants" id="flow-content-3:align-descendants-4">align descendants</a> to the left.</p>
  </div>

  <h4 id="phrasing-content-3"><span class="secno">15.3.4</span> Phrasing content<a href="#phrasing-content-3" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">cite, dfn, em, i, var </c-><c- p="">{</c-> <c- k="">font-style</c-><c- p="">:</c-> italic<c- p="">;</c-> <c- p="">}</c->
<c- f="">b, strong </c-><c- p="">{</c-> <c- k="">font-weight</c-><c- p="">:</c-> bolder<c- p="">;</c-> <c- p="">}</c->
<c- f="">code, kbd, samp, tt </c-><c- p="">{</c-> <c- k="">font-family</c-><c- p="">:</c-> monospace<c- p="">;</c-> <c- p="">}</c->
<c- f="">big </c-><c- p="">{</c-> <c- k="">font-size</c-><c- p="">:</c-> larger<c- p="">;</c-> <c- p="">}</c->
<c- f="">small </c-><c- p="">{</c-> <c- k="">font-size</c-><c- p="">:</c-> smaller<c- p="">;</c-> <c- p="">}</c->

<c- f="">sub </c-><c- p="">{</c-> <c- k="">vertical-align</c-><c- p="">:</c-> sub<c- p="">;</c-> <c- p="">}</c->
<c- f="">sup </c-><c- p="">{</c-> <c- k="">vertical-align</c-><c- p="">:</c-> super<c- p="">;</c-> <c- p="">}</c->
<c- f="">sub, sup </c-><c- p="">{</c-> <c- k="">line-height</c-><c- p="">:</c-> normal<c- p="">;</c-> <c- k="">font-size</c-><c- p="">:</c-> smaller<c- p="">;</c-> <c- p="">}</c->

<c- f="">ruby </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> ruby<c- p="">;</c-> <c- p="">}</c->
<c- f="">rt </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> ruby-text<c- p="">;</c-> <c- p="">}</c->

<c- f="">:link </c-><c- p="">{</c-> <c- k="">color</c-><c- p="">:</c-> #0000EE<c- p="">;</c-> <c- p="">}</c->
<c- f="">:visited </c-><c- p="">{</c-> <c- k="">color</c-><c- p="">:</c-> #551A8B<c- p="">;</c-> <c- p="">}</c->
<c- f="">:link:active, :visited:active </c-><c- p="">{</c-> <c- k="">color</c-><c- p="">:</c-> #FF0000<c- p="">;</c-> <c- p="">}</c->
<c- f="">:link, :visited </c-><c- p="">{</c-> <c- k="">text-decoration</c-><c- p="">:</c-> underline<c- p="">;</c-> <c- k="">cursor</c-><c- p="">:</c-> pointer<c- p="">;</c-> <c- p="">}</c->

<c- f="">:focus-visible </c-><c- p="">{</c-> <c- k="">outline</c-><c- p="">:</c-> auto<c- p="">;</c-> <c- p="">}</c->

<c- f="">mark </c-><c- p="">{</c-> <c- k="">background</c-><c- p="">:</c-> yellow<c- p="">;</c-> <c- k="">color</c-><c- p="">:</c-> black<c- p="">;</c-> <c- p="">}</c-> <c- c="">/* this color is just a suggestion and can be changed based on implementation feedback */</c->

<c- f="">abbr[title], acronym[title] </c-><c- p="">{</c-> <c- k="">text-decoration</c-><c- p="">:</c-> dotted underline<c- p="">;</c-> <c- p="">}</c->
<c- f="">ins, u </c-><c- p="">{</c-> <c- k="">text-decoration</c-><c- p="">:</c-> underline<c- p="">;</c-> <c- p="">}</c->
<c- f="">del, s, strike </c-><c- p="">{</c-> <c- k="">text-decoration</c-><c- p="">:</c-> line-through<c- p="">;</c-> <c- p="">}</c->

<c- f="">q::before </c-><c- p="">{</c-> <c- k="">content</c-><c- p="">:</c-> open-quote<c- p="">;</c-> <c- p="">}</c->
<c- f="">q::after </c-><c- p="">{</c-> <c- k="">content</c-><c- p="">:</c-> close-quote<c- p="">;</c-> <c- p="">}</c->

<span id="br-wbr-content"><c- f="">br </c-><c- p="">{</c-> <c- k="">display-outside</c-><c- p="">:</c-> newline<c- p="">;</c-> <c- p="">}</c-> <c- c="">/* </c-><a href="#bidi-rendering"><c- c="">this also has bidi implications</c-></a><c- c=""> */</c->
<c- f="">nobr </c-><c- p="">{</c-> <c- k="">white-space</c-><c- p="">:</c-> nowrap<c- p="">;</c-> <c- p="">}</c->
<c- f="">wbr </c-><c- p="">{</c-> <c- k="">display-outside</c-><c- p="">:</c-> break-opportunity<c- p="">;</c-> <c- p="">}</c-> <c- c="">/* </c-><a href="#bidi-rendering"><c- c="">this also has bidi implications</c-></a><c- c=""> */</c->
<c- f="">nobr wbr </c-><c- p="">{</c-> <c- k="">white-space</c-><c- p="">:</c-> normal<c- p="">;</c-> <c- p="">}</c-></span></code></pre>

  <p>The following rules are also <a href="#expected" id="phrasing-content-3:expected">expected</a> to apply, as
  <a href="#presentational-hints" id="phrasing-content-3:presentational-hints">presentational hints</a>:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">br[clear=left i] </c-><c- p="">{</c-> <c- k="">clear</c-><c- p="">:</c-> left<c- p="">;</c-> <c- p="">}</c->
<c- f="">br[clear=right i] </c-><c- p="">{</c-> <c- k="">clear</c-><c- p="">:</c-> right<c- p="">;</c-> <c- p="">}</c->
<c- f="">br[clear=all i], br[clear=both i] </c-><c- p="">{</c-> <c- k="">clear</c-><c- p="">:</c-> both<c- p="">;</c-> <c- p="">}</c-></code></pre>

  <p>For the purposes of the CSS ruby model, runs of children of <code id="phrasing-content-3:the-ruby-element"><a href="#the-ruby-element">ruby</a></code> elements that are
  not <code id="phrasing-content-3:the-rt-element"><a href="#the-rt-element">rt</a></code> or <code id="phrasing-content-3:the-rp-element"><a href="#the-rp-element">rp</a></code> elements are <a href="#expected" id="phrasing-content-3:expected-2">expected</a> to be wrapped in
  anonymous boxes whose <a id="phrasing-content-3:'display'" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property has the value <a id="phrasing-content-3:'ruby-base'" href="https://drafts.csswg.org/css-ruby/#valdef-display-ruby-base" data-x-internal="'ruby-base'">'ruby-base'</a>.
  <a href="#refsCSSRUBY">[CSSRUBY]</a></p>

  <p>When a particular part of a ruby has more than one annotation, the annotations should be
  distributed on both sides of the base text so as to minimize the stacking of ruby annotations on
  one side.</p>

  <p class="note">When it becomes possible to do so, the preceding requirement will be updated to be
  expressed in terms of CSS ruby. (Currently, CSS ruby does not handle nested <code id="phrasing-content-3:the-ruby-element-2"><a href="#the-ruby-element">ruby</a></code>
  elements or multiple sequential <code id="phrasing-content-3:the-rt-element-2"><a href="#the-rt-element">rt</a></code> elements, which is how this semantic is
  expressed.)</p>

  <p>User agents that do not support correct ruby rendering are <a href="#expected" id="phrasing-content-3:expected-3">expected</a> to render
  parentheses around the text of <code id="phrasing-content-3:the-rt-element-3"><a href="#the-rt-element">rt</a></code> elements in the absence of <code id="phrasing-content-3:the-rp-element-2"><a href="#the-rp-element">rp</a></code>
  elements.</p>

  <hr>

  <p>User agents are <a href="#expected" id="phrasing-content-3:expected-4">expected</a> to support the <a id="phrasing-content-3:'clear'" href="https://drafts.csswg.org/css2/#flow-control" data-x-internal="'clear'">'clear'</a> property on inline
  elements (in order to render <code id="phrasing-content-3:the-br-element"><a href="#the-br-element">br</a></code> elements with <code id="phrasing-content-3:attr-br-clear"><a href="#attr-br-clear">clear</a></code> attributes) in the manner described in the non-normative note
  to this effect in <cite>CSS</cite>.</p> 

  <p>The initial value for the <a id="phrasing-content-3:'color'" href="https://drafts.csswg.org/css-color/#the-color-property" data-x-internal="'color'">'color'</a> property is <a href="#expected" id="phrasing-content-3:expected-5">expected</a> to be black.
  The initial value for the <a id="phrasing-content-3:'background-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-background-color" data-x-internal="'background-color'">'background-color'</a> property is <a href="#expected" id="phrasing-content-3:expected-6">expected</a> to be
  'transparent'. The canvas's background is <a href="#expected" id="phrasing-content-3:expected-7">expected</a> to be white.</p>

  <hr>

  <div data-algorithm="">
  <p>When a <code id="phrasing-content-3:font"><a href="#font">font</a></code> element has a <code>color</code>
  attribute, its value is <a href="#expected" id="phrasing-content-3:expected-8">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="phrasing-content-3:rules-for-parsing-a-legacy-colour-value">rules for parsing a
  legacy color value</a>, and if that does not return failure, the user agent is
  <a href="#expected" id="phrasing-content-3:expected-9">expected</a> to treat the attribute as a <a href="#presentational-hints" id="phrasing-content-3:presentational-hints-2">presentational hint</a> setting the element's <a id="phrasing-content-3:'color'-2" href="https://drafts.csswg.org/css-color/#the-color-property" data-x-internal="'color'">'color'</a> property to the
  resulting color.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="phrasing-content-3:font-2"><a href="#font">font</a></code> element has a <code>face</code>
  attribute, the user agent is <a href="#expected" id="phrasing-content-3:expected-10">expected</a> to treat the attribute as a <a href="#presentational-hints" id="phrasing-content-3:presentational-hints-3">presentational hint</a> setting the element's
  <a id="phrasing-content-3:'font-family'" href="https://drafts.csswg.org/css-fonts/#font-family-prop" data-x-internal="'font-family'">'font-family'</a> property to the attribute's value.</p>
  </div>

  

  <div data-algorithm="">
  <p>When a <code id="phrasing-content-3:font-3"><a href="#font">font</a></code> element has a <code>size</code>
  attribute, the user agent is <a href="#expected" id="phrasing-content-3:expected-11">expected</a> to use the following steps, known as the
  <dfn id="rules-for-parsing-a-legacy-font-size">rules for parsing a legacy font size</dfn>, to treat the attribute as a <a href="#presentational-hints" id="phrasing-content-3:presentational-hints-4">presentational hint</a> setting the element's
  <a id="phrasing-content-3:'font-size'" href="https://drafts.csswg.org/css-fonts/#font-size-prop" data-x-internal="'font-size'">'font-size'</a> property:</p>

  <ol><li><p>Let <var>input</var> be the attribute's value.</p></li><li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the
   start of the string.</p></li><li><p><a id="phrasing-content-3:skip-ascii-whitespace" href="https://infra.spec.whatwg.org/#skip-ascii-whitespace" data-x-internal="skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given
   <var>position</var>.</p></li><li><p>If <var>position</var> is past the end of <var>input</var>, there is no <a href="#presentational-hints" id="phrasing-content-3:presentational-hints-5">presentational hint</a>. Return.</p></li><li><p>If the character at <var>position</var> is a U+002B PLUS SIGN character (+), then let
   <var>mode</var> be <i>relative-plus</i>, and advance <var>position</var> to the next character.
   Otherwise, if the character at <var>position</var> is a U+002D HYPHEN-MINUS character (-), then
   let <var>mode</var> be <i>relative-minus</i>, and advance <var>position</var> to the next
   character. Otherwise, let <var>mode</var> be <i>absolute</i>.</p></li><li><p><a id="phrasing-content-3:collect-a-sequence-of-code-points" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" data-x-internal="collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are <a id="phrasing-content-3:ascii-digits" href="https://infra.spec.whatwg.org/#ascii-digit" data-x-internal="ascii-digits">ASCII digits</a> from
   <var>input</var> given <var>position</var>, and let <var>digits</var> be the resulting
   sequence.</p></li><li><p>If <var>digits</var> is the empty string, there is no <a href="#presentational-hints" id="phrasing-content-3:presentational-hints-6">presentational hint</a>. Return.</p></li><li><p>Interpret <var>digits</var> as a base-ten integer. Let <var>value</var> be the resulting
   number.</p></li><li>
    

    <p>If <var>mode</var> is <i>relative-plus</i>, then increment <var>value</var> by 3. If
    <var>mode</var> is <i>relative-minus</i>, then let <var>value</var> be the result of subtracting
    <var>value</var> from 3.</p>
   </li><li><p>If <var>value</var> is greater than 7, let it be 7.</p></li><li><p>If <var>value</var> is less than 1, let it be 1.</p></li><li>
    <p>Set the <a id="phrasing-content-3:'font-size'-2" href="https://drafts.csswg.org/css-fonts/#font-size-prop" data-x-internal="'font-size'">'font-size'</a> property to the keyword corresponding to the value of <var>value</var>
    according to the following table:</p>

    <table><thead><tr><th><var>value</var>
       </th><th><a id="phrasing-content-3:'font-size'-3" href="https://drafts.csswg.org/css-fonts/#font-size-prop" data-x-internal="'font-size'">'font-size'</a> keyword
     </th></tr></thead><tbody><tr><td>1
       </td><td>'x-small'
      </td></tr><tr><td>2
       </td><td>'small'
      </td></tr><tr><td>3
       </td><td>'medium'
      </td></tr><tr><td>4
       </td><td>'large'
      </td></tr><tr><td>5
       </td><td>'x-large'
      </td></tr><tr><td>6
       </td><td>'xx-large'
      </td></tr><tr><td>7
       </td><td>'xxx-large'
    </td></tr></tbody></table>
   </li></ol>
  </div>


  <h4 id="bidi-rendering"><span class="secno">15.3.5</span> Bidirectional text<a href="#bidi-rendering" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">[dir]:dir(ltr), bdi:dir(ltr), input[type=tel i]:dir(ltr) </c-><c- p="">{</c-> <c- k="">direction</c-><c- p="">:</c-> ltr<c- p="">;</c-> <c- p="">}</c->
<c- f="">[dir]:dir(rtl), bdi:dir(rtl) </c-><c- p="">{</c-> <c- k="">direction</c-><c- p="">:</c-> rtl<c- p="">;</c-> <c- p="">}</c->

<c- f="">address, blockquote, center, div, figure, figcaption, footer, form, header, hr,</c->
<c- f="">legend, listing, main, p, plaintext, pre, summary, xmp, article, aside,</c->
<c- f="">:heading, hgroup, nav, section, search, table, caption, colgroup, col, thead,</c->
<c- f="">tbody, tfoot, tr, td, th, dir, dd, dl, dt, menu, ol, ul, li, bdi, output,</c->
<c- f="">[dir=ltr i], [dir=rtl i], [dir=auto i] </c-><c- p="">{</c->
  <c- k="">unicode-bidi</c-><c- p="">:</c-> isolate<c- p="">;</c-> 
<c- p="">}</c->

<c- f="">bdo, bdo[dir] </c-><c- p="">{</c-> <c- k="">unicode-bidi</c-><c- p="">:</c-> isolate-override<c- p="">;</c-> <c- p="">}</c-> 

<c- f="">input[dir=auto i]:is([type=search i], [type=tel i], [type=url i],</c->
<c- f="">[type=email i]), textarea[dir=auto i], pre[dir=auto i] </c-><c- p="">{</c->
  <c- k="">unicode-bidi</c-><c- p="">:</c-> plaintext<c- p="">;</c->
<c- p="">}</c->
<c- c="">/* see prose for input elements whose type attribute is in the Text state */</c->

<c- c="">/* the </c-><a href="#br-wbr-content"><c- c="">rules setting the 'content' property</c-></a><c- c=""> on </c-><code id="bidi-rendering:the-br-element"><a href="#the-br-element"><c- c="">br</c-></a></code><c- c=""> and </c-><code id="bidi-rendering:the-wbr-element"><a href="#the-wbr-element"><c- c="">wbr</c-></a></code><c- c=""> elements also has bidi implications */</c-></code></pre>

  <p>When an <code id="bidi-rendering:the-input-element"><a href="#the-input-element">input</a></code> element's <code id="bidi-rendering:attr-dir"><a href="#attr-dir">dir</a></code> attribute is in the
  <a href="#attr-dir-auto" id="bidi-rendering:attr-dir-auto">auto</a> state and its <code id="bidi-rendering:attr-input-type"><a href="#attr-input-type">type</a></code>
  attribute is in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="bidi-rendering:text-(type=text)-state-and-search-state-(type=search)">Text</a> state, then the user agent is
  <a href="#expected" id="bidi-rendering:expected">expected</a> to act as if it had a user-agent-level style sheet rule setting the
  <a id="bidi-rendering:'unicode-bidi'" href="https://drafts.csswg.org/css-writing-modes/#unicode-bidi" data-x-internal="'unicode-bidi'">'unicode-bidi'</a> property to 'plaintext'.</p>

  <p>Input fields (i.e. <code id="bidi-rendering:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements, and <code id="bidi-rendering:the-input-element-2"><a href="#the-input-element">input</a></code> elements when their
  <code id="bidi-rendering:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="bidi-rendering:text-(type=text)-state-and-search-state-(type=search)-2">Text</a>, <a href="#text-(type=text)-state-and-search-state-(type=search)" id="bidi-rendering:text-(type=text)-state-and-search-state-(type=search)-3">Search</a>,
  <a href="#telephone-state-(type=tel)" id="bidi-rendering:telephone-state-(type=tel)">Telephone</a>, <a href="#url-state-(type=url)" id="bidi-rendering:url-state-(type=url)">URL</a>,
  or <a href="#email-state-(type=email)" id="bidi-rendering:email-state-(type=email)">Email</a> state) are <a href="#expected" id="bidi-rendering:expected-2">expected</a> to present
  an editing user interface with a directionality that matches the element's
  <a id="bidi-rendering:'direction'" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a> property.</p>

  <p>When the document's character encoding is <a id="bidi-rendering:iso-8859-8" href="https://encoding.spec.whatwg.org/#iso-8859-8" data-x-internal="iso-8859-8">ISO-8859-8</a>, the following rules are
  additionally <a href="#expected" id="bidi-rendering:expected-3">expected</a> to apply, following those above: <a href="#refsENCODING">[ENCODING]</a></p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">address, blockquote, center, div, figure, figcaption, footer, form, header, hr,</c->
<c- f="">legend, listing, main, p, plaintext, pre, summary, xmp, article, aside,</c->
<c- f="">:heading, hgroup, nav, section, search, table, caption, colgroup, col, thead,</c->
<c- f="">tbody, tfoot, tr, td, th, dir, dd, dl, dt, menu, ol, ul, li, [dir=ltr i],</c->
<c- f="">[dir=rtl i], [dir=auto i], *|* </c-><c- p="">{</c->
  <c- k="">unicode-bidi</c-><c- p="">:</c-> bidi-override<c- p="">;</c->
<c- p="">}</c->
<c- f="">input:not([type=submit i]):not([type=reset i]):not([type=button i]),</c->
<c- f="">textarea </c-><c- p="">{</c->
  <c- k="">unicode-bidi</c-><c- p="">:</c-> normal<c- p="">;</c->
<c- p="">}</c-></code></pre>


  <h4 id="sections-and-headings"><span class="secno">15.3.6</span> Sections and headings<a href="#sections-and-headings" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">article, aside, :heading, hgroup, nav, section </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c-> block<c- p="">;</c->
<c- p="">}</c->

<c- f="">:heading </c-><c- p="">{</c-> <c- k="">font-weight</c-><c- p="">:</c-> bold<c- p="">;</c-> <c- p="">}</c->

<c- f="">:heading(1) </c-><c- p="">{</c-> <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">0.67</c-><c- l="">em</c-><c- p="">;</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- m="">2.00</c-><c- l="">em</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">:heading(2) </c-><c- p="">{</c-> <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">0.83</c-><c- l="">em</c-><c- p="">;</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- m="">1.50</c-><c- l="">em</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">:heading(3) </c-><c- p="">{</c-> <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">1.00</c-><c- l="">em</c-><c- p="">;</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- m="">1.17</c-><c- l="">em</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">:heading(4) </c-><c- p="">{</c-> <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">1.33</c-><c- l="">em</c-><c- p="">;</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- m="">1.00</c-><c- l="">em</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">:heading(5) </c-><c- p="">{</c-> <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">1.67</c-><c- l="">em</c-><c- p="">;</c-> <c- k="">font-size</c-><c- p="">:</c-> <c- m="">0.83</c-><c- l="">em</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">:heading(6, 7, 8, 9) </c-><c- p="">{</c->
  <c- k="">font-size</c-><c- p="">:</c-> <c- m="">0.67</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">2.33</c-><c- l="">em</c-><c- p="">;</c->
<c- p="">}</c->
</code></pre>



  <h4 id="lists"><span class="secno">15.3.7</span> Lists<a href="#lists" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">dir, dd, dl, dt, menu, ol, ul </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> block<c- p="">;</c-> <c- p="">}</c->
<c- f="">li </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> list-item<c- p="">;</c-> <c- k="">text-align</c-><c- p="">:</c-> match-parent<c- p="">;</c-> <c- p="">}</c->

<c- f="">dir, dl, menu, ol, ul </c-><c- p="">{</c-> <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">em</c-><c- p="">;</c-> <c- p="">}</c->

<c- f="">:is(dir, dl, menu, ol, ul) :is(dir, dl, menu, ol, ul) </c-><c- p="">{</c->
  <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">0</c-><c- p="">;</c->
<c- p="">}</c->

<c- f="">dd </c-><c- p="">{</c-> <c- k="">margin-inline-start</c-><c- p="">:</c-> <c- m="">40</c-><c- l="">px</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">dir, menu, ol, ul </c-><c- p="">{</c-> <c- k="">padding-inline-start</c-><c- p="">:</c-> <c- m="">40</c-><c- l="">px</c-><c- p="">;</c-> <c- p="">}</c->

<c- f="">ol, ul, menu </c-><c- p="">{</c-> <c- k="">counter-reset</c-><c- p="">:</c-> list-item<c- p="">;</c-> <c- p="">}</c->
<c- f="">ol </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> decimal<c- p="">;</c-> <c- p="">}</c->

<c- f="">dir, menu, ul </c-><c- p="">{</c->
  <c- k="">list-style-type</c-><c- p="">:</c-> disc<c- p="">;</c->
<c- p="">}</c->
<c- f="">:is(dir, menu, ol, ul) :is(dir, menu, ul) </c-><c- p="">{</c->
  <c- k="">list-style-type</c-><c- p="">:</c-> circle<c- p="">;</c->
<c- p="">}</c->
<c- f="">:is(dir, menu, ol, ul) :is(dir, menu, ol, ul) :is(dir, menu, ul) </c-><c- p="">{</c->
  <c- k="">list-style-type</c-><c- p="">:</c-> square<c- p="">;</c->
<c- p="">}</c-></code></pre>

  <p id="decohints">The following rules are also <a href="#expected" id="lists:expected">expected</a> to apply, as
  <a href="#presentational-hints" id="lists:presentational-hints">presentational hints</a>:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">ol[type="1"], li[type="1"] </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> decimal<c- p="">;</c-> <c- p="">}</c->
<c- f="">ol[type=a </c-><c- f="">s], li[type=a </c-><c- f="">s] </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> lower-alpha<c- p="">;</c-> <c- p="">}</c->
<c- f="">ol[type=A </c-><c- f="">s], li[type=A </c-><c- f="">s] </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> upper-alpha<c- p="">;</c-> <c- p="">}</c->
<c- f="">ol[type=i s], li[type=i s] </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> lower-roman<c- p="">;</c-> <c- p="">}</c->
<c- f="">ol[type=I s], li[type=I s] </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> upper-roman<c- p="">;</c-> <c- p="">}</c->
<c- f="">ul[type=none i], li[type=none i] </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> none<c- p="">;</c-> <c- p="">}</c->
<c- f="">ul[type=disc i], li[type=disc i] </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> disc<c- p="">;</c-> <c- p="">}</c->
<c- f="">ul[type=circle i], li[type=circle i] </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> circle<c- p="">;</c-> <c- p="">}</c->
<c- f="">ul[type=square i], li[type=square i] </c-><c- p="">{</c-> <c- k="">list-style-type</c-><c- p="">:</c-> square<c- p="">;</c-> <c- p="">}</c-></code></pre>

  <p>In <a id="lists:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, the following rules are also <a href="#expected" id="lists:expected-2">expected</a> to apply:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">li </c-><c- p="">{</c-> <c- k="">list-style-position</c-><c- p="">:</c-> inside<c- p="">;</c-> <c- p="">}</c->
<c- f="">li :is(dir, menu, ol, ul) </c-><c- p="">{</c-> <c- k="">list-style-position</c-><c- p="">:</c-> outside<c- p="">;</c-> <c- p="">}</c->
<c- f="">:is(dir, menu, ol, ul) :is(dir, menu, ol, ul, li) </c-><c- p="">{</c-> <c- k="">list-style-position</c-><c- p="">:</c-> unset<c- p="">;</c-> <c- p="">}</c-></code></pre>

  <p>When rendering <code id="lists:the-li-element"><a href="#the-li-element">li</a></code> elements, non-CSS user agents are <a href="#expected" id="lists:expected-3">expected</a> to use
  the <a href="#ordinal-value" id="lists:ordinal-value">ordinal value</a> of the <code id="lists:the-li-element-2"><a href="#the-li-element">li</a></code> element to render the counter in the list
  item marker.</p>

  <p id="css-list-rendering">For CSS user agents, some aspects of rendering <a href="https://drafts.csswg.org/css-lists/#list-item" id="lists:css-list-item" data-x-internal="css-list-item">list items</a> are defined by the <cite>CSS Lists</cite> specification.
  Additionally, the following attribute mappings are <a href="#expected" id="lists:expected-4">expected</a> to apply:
  <a href="#refsCSSLISTS">[CSSLISTS]</a></p>

  <div data-algorithm="">
  <p>When an <code id="lists:the-li-element-3"><a href="#the-li-element">li</a></code> element has a <code id="lists:attr-li-value"><a href="#attr-li-value">value</a></code> attribute, and parsing that attribute's value using the
  <a href="#rules-for-parsing-integers" id="lists:rules-for-parsing-integers">rules for parsing integers</a> doesn't generate an error, the user agent is
  <a href="#expected" id="lists:expected-5">expected</a> to use the parsed value <var>value</var> as a <a href="#presentational-hints" id="lists:presentational-hints-2">presentational hint</a> for the <a id="lists:'counter-set'" href="https://drafts.csswg.org/css-lists/#propdef-counter-set" data-x-internal="'counter-set'">'counter-set'</a> property of the form <code>list-item <var>value</var></code>.</p>
  </div>

  <div data-algorithm="">
  <p>When an <code id="lists:the-ol-element"><a href="#the-ol-element">ol</a></code> element has a <code id="lists:attr-ol-start"><a href="#attr-ol-start">start</a></code>
  attribute or a <code id="lists:attr-ol-reversed"><a href="#attr-ol-reversed">reversed</a></code> attribute, or both, the user agent
  is <a href="#expected" id="lists:expected-6">expected</a> to use the following steps to treat the attributes as a <a href="#presentational-hints" id="lists:presentational-hints-3">presentational hint</a> for the <a id="lists:'counter-reset'" href="https://drafts.csswg.org/css-lists/#propdef-counter-reset" data-x-internal="'counter-reset'">'counter-reset'</a>
  property:</p>

  <ol><li><p>Let <var>value</var> be null.</p></li><li><p>If the element has a <code id="lists:attr-ol-start-2"><a href="#attr-ol-start">start</a></code> attribute, then set
   <var>value</var> to the result of parsing the attribute's value using the <a href="#rules-for-parsing-integers" id="lists:rules-for-parsing-integers-2">rules for
   parsing integers</a>.</p></li><li>
    <p>If the element has a <code id="lists:attr-ol-reversed-2"><a href="#attr-ol-reversed">reversed</a></code> attribute, then:</p>

    <ol><li><p>If <var>value</var> is an integer, then increment <var>value</var> by 1 and return
     <code>reversed(list-item) <var>value</var></code>.</p></li><li>
      <p>Otherwise, return <code>reversed(list-item)</code>.</p>

      <p class="note">Either the <code id="lists:attr-ol-start-3"><a href="#attr-ol-start">start</a></code> attribute was absent, or
      parsing its value resulted in an error.</p>
     </li></ol>
   </li><li>
    <p>Otherwise:</p>

    <ol><li><p>If <var>value</var> is an integer, then decrement <var>value</var> by 1 and return
     <code>list-item <var>value</var></code>.</p></li><li><p>Otherwise, there is no <a href="#presentational-hints" id="lists:presentational-hints-4">presentational
     hint</a>.</p></li></ol>
   </li></ol>
  </div>


  <h4 id="tables-2"><span class="secno">15.3.8</span> Tables<a href="#tables-2" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">table </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> table<c- p="">;</c-> <c- p="">}</c->
<c- f="">caption </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> table-caption<c- p="">;</c-> <c- p="">}</c->
<c- f="">colgroup, colgroup[hidden] </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> table-column-group<c- p="">;</c-> <c- p="">}</c->
<c- f="">col, col[hidden] </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> table-column<c- p="">;</c-> <c- p="">}</c->
<c- f="">thead, thead[hidden] </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> table-header-group<c- p="">;</c-> <c- p="">}</c->
<c- f="">tbody, tbody[hidden] </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> table-row-group<c- p="">;</c-> <c- p="">}</c->
<c- f="">tfoot, tfoot[hidden] </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> table-footer-group<c- p="">;</c-> <c- p="">}</c->
<c- f="">tr, tr[hidden] </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> table-row<c- p="">;</c-> <c- p="">}</c->
<c- f="">td, th </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> table-cell<c- p="">;</c-> <c- p="">}</c->

<c- f="">colgroup[hidden], col[hidden], thead[hidden], tbody[hidden],</c->
<c- f="">tfoot[hidden], tr[hidden] </c-><c- p="">{</c->
  <c- k="">visibility</c-><c- p="">:</c-> collapse<c- p="">;</c->
<c- p="">}</c->

<c- f="">table </c-><c- p="">{</c->
  <c- k="">box-sizing</c-><c- p="">:</c-> border-box<c- p="">;</c->
  <c- k="">border-spacing</c-><c- p="">:</c-> <c- m="">2</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">border-collapse</c-><c- p="">:</c-> separate<c- p="">;</c->
  <c- k="">text-indent</c-><c- p="">:</c-> initial<c- p="">;</c->
<c- p="">}</c->
<c- f="">td, th </c-><c- p="">{</c-> <c- k="">padding</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">th </c-><c- p="">{</c-> <c- k="">font-weight</c-><c- p="">:</c-> bold<c- p="">;</c-> <c- p="">}</c->

<c- f="">caption </c-><c- p="">{</c-> <c- k="">text-align</c-><c- p="">:</c-> center<c- p="">;</c-> <c- p="">}</c->
<c- f="">thead, tbody, tfoot, table &gt; tr </c-><c- p="">{</c-> <c- k="">vertical-align</c-><c- p="">:</c-> middle<c- p="">;</c-> <c- p="">}</c->
<c- f="">tr, td, th </c-><c- p="">{</c-> <c- k="">vertical-align</c-><c- p="">:</c-> inherit<c- p="">;</c-> <c- p="">}</c->

<c- f="">thead, tbody, tfoot, tr </c-><c- p="">{</c-> <c- k="">border-color</c-><c- p="">:</c-> inherit<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[rules=none i], table[rules=groups i], table[rules=rows i],</c->
<c- f="">table[rules=cols i], table[rules=all i], table[frame=void i],</c->
<c- f="">table[frame=above i], table[frame=below i], table[frame=hsides i],</c->
<c- f="">table[frame=lhs i], table[frame=rhs i], table[frame=vsides i],</c->
<c- f="">table[frame=box i], table[frame=border i],</c->
<c- f="">table[rules=none i] &gt; tr &gt; td, table[rules=none i] &gt; tr &gt; th,</c->
<c- f="">table[rules=groups i] &gt; tr &gt; td, table[rules=groups i] &gt; tr &gt; th,</c->
<c- f="">table[rules=rows i] &gt; tr &gt; td, table[rules=rows i] &gt; tr &gt; th,</c->
<c- f="">table[rules=cols i] &gt; tr &gt; td, table[rules=cols i] &gt; tr &gt; th,</c->
<c- f="">table[rules=all i] &gt; tr &gt; td, table[rules=all i] &gt; tr &gt; th,</c->
<c- f="">table[rules=none i] &gt; thead &gt; tr &gt; td, table[rules=none i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=groups i] &gt; thead &gt; tr &gt; td, table[rules=groups i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=rows i] &gt; thead &gt; tr &gt; td, table[rules=rows i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=cols i] &gt; thead &gt; tr &gt; td, table[rules=cols i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=all i] &gt; thead &gt; tr &gt; td, table[rules=all i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=none i] &gt; tbody &gt; tr &gt; td, table[rules=none i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=groups i] &gt; tbody &gt; tr &gt; td, table[rules=groups i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=rows i] &gt; tbody &gt; tr &gt; td, table[rules=rows i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=cols i] &gt; tbody &gt; tr &gt; td, table[rules=cols i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=all i] &gt; tbody &gt; tr &gt; td, table[rules=all i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=none i] &gt; tfoot &gt; tr &gt; td, table[rules=none i] &gt; tfoot &gt; tr &gt; th,</c->
<c- f="">table[rules=groups i] &gt; tfoot &gt; tr &gt; td, table[rules=groups i] &gt; tfoot &gt; tr &gt; th,</c->
<c- f="">table[rules=rows i] &gt; tfoot &gt; tr &gt; td, table[rules=rows i] &gt; tfoot &gt; tr &gt; th,</c->
<c- f="">table[rules=cols i] &gt; tfoot &gt; tr &gt; td, table[rules=cols i] &gt; tfoot &gt; tr &gt; th,</c->
<c- f="">table[rules=all i] &gt; tfoot &gt; tr &gt; td, table[rules=all i] &gt; tfoot &gt; tr &gt; th </c-><c- p="">{</c->
  <c- k="">border-color</c-><c- p="">:</c-> black<c- p="">;</c->
<c- p="">}</c-></code></pre>

  <p>The following rules are also <a href="#expected" id="tables-2:expected">expected</a> to apply, as <a href="#presentational-hints" id="tables-2:presentational-hints">presentational
  hints</a>:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">table[align=left i] </c-><c- p="">{</c-> <c- k="">float</c-><c- p="">:</c-> left<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[align=right i] </c-><c- p="">{</c-> <c- k="">float</c-><c- p="">:</c-> right<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[align=center i] </c-><c- p="">{</c-> <c- k="">margin-inline</c-><c- p="">:</c-> auto<c- p="">;</c-> <c- p="">}</c->
<c- f="">thead[align=absmiddle i], tbody[align=absmiddle i], tfoot[align=absmiddle i],</c->
<c- f="">tr[align=absmiddle i], td[align=absmiddle i], th[align=absmiddle i] </c-><c- p="">{</c->
  <c- k="">text-align</c-><c- p="">:</c-> center<c- p="">;</c->
<c- p="">}</c->

<c- f="">caption[align=bottom i] </c-><c- p="">{</c-> <c- k="">caption-side</c-><c- p="">:</c-> bottom<c- p="">;</c-> <c- p="">}</c->
<c- f="">p[align=left i], h1[align=left i], h2[align=left i], h3[align=left i],</c->
<c- f="">h4[align=left i], h5[align=left i], h6[align=left i] </c-><c- p="">{</c->
  <c- k="">text-align</c-><c- p="">:</c-> left<c- p="">;</c->
<c- p="">}</c->
<c- f="">p[align=right i], h1[align=right i], h2[align=right i], h3[align=right i],</c->
<c- f="">h4[align=right i], h5[align=right i], h6[align=right i] </c-><c- p="">{</c->
  <c- k="">text-align</c-><c- p="">:</c-> right<c- p="">;</c->
<c- p="">}</c->
<c- f="">p[align=center i], h1[align=center i], h2[align=center i], h3[align=center i],</c->
<c- f="">h4[align=center i], h5[align=center i], h6[align=center i] </c-><c- p="">{</c->
  <c- k="">text-align</c-><c- p="">:</c-> center<c- p="">;</c->
<c- p="">}</c->
<c- f="">p[align=justify i], h1[align=justify i], h2[align=justify i], h3[align=justify i],</c->
<c- f="">h4[align=justify i], h5[align=justify i], h6[align=justify i] </c-><c- p="">{</c->
  <c- k="">text-align</c-><c- p="">:</c-> justify<c- p="">;</c->
<c- p="">}</c->
<c- f="">thead[valign=top i], tbody[valign=top i], tfoot[valign=top i],</c->
<c- f="">tr[valign=top i], td[valign=top i], th[valign=top i] </c-><c- p="">{</c->
  <c- k="">vertical-align</c-><c- p="">:</c-> top<c- p="">;</c->
<c- p="">}</c->
<c- f="">thead[valign=middle i], tbody[valign=middle i], tfoot[valign=middle i],</c->
<c- f="">tr[valign=middle i], td[valign=middle i], th[valign=middle i] </c-><c- p="">{</c->
  <c- k="">vertical-align</c-><c- p="">:</c-> middle<c- p="">;</c->
<c- p="">}</c->
<c- f="">thead[valign=bottom i], tbody[valign=bottom i], tfoot[valign=bottom i],</c->
<c- f="">tr[valign=bottom i], td[valign=bottom i], th[valign=bottom i] </c-><c- p="">{</c->
  <c- k="">vertical-align</c-><c- p="">:</c-> bottom<c- p="">;</c->
<c- p="">}</c->
<c- f="">thead[valign=baseline i], tbody[valign=baseline i], tfoot[valign=baseline i],</c->
<c- f="">tr[valign=baseline i], td[valign=baseline i], th[valign=baseline i] </c-><c- p="">{</c->
  <c- k="">vertical-align</c-><c- p="">:</c-> baseline<c- p="">;</c->
<c- p="">}</c->

<c- f="">td[nowrap], th[nowrap] </c-><c- p="">{</c-> <c- k="">white-space</c-><c- p="">:</c-> nowrap<c- p="">;</c-> <c- p="">}</c->

<c- f="">table[rules=none i], table[rules=groups i], table[rules=rows i],</c->
<c- f="">table[rules=cols i], table[rules=all i] </c-><c- p="">{</c->
  <c- k="">border-style</c-><c- p="">:</c-> hidden<c- p="">;</c->
  <c- k="">border-collapse</c-><c- p="">:</c-> collapse<c- p="">;</c->
<c- p="">}</c->
<c- f="">table[border] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> outset<c- p="">;</c-> <c- p="">}</c-> <c- c="">/* </c-><a href="#magic-border-selector" id="tables-2:magic-border-selector"><c- c="">only if border is not equivalent to zero</c-></a><c- c=""> */</c->
<c- f="">table[frame=void i] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> hidden<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[frame=above i] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> outset hidden hidden hidden<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[frame=below i] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> hidden hidden outset hidden<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[frame=hsides i] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> outset hidden outset hidden<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[frame=lhs i] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> hidden hidden hidden outset<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[frame=rhs i] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> hidden outset hidden hidden<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[frame=vsides i] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> hidden outset<c- p="">;</c-> <c- p="">}</c->
<c- f="">table[frame=box i], table[frame=border i] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> outset<c- p="">;</c-> <c- p="">}</c->

<c- f="">table[border] &gt; tr &gt; td, table[border] &gt; tr &gt; th,</c->
<c- f="">table[border] &gt; thead &gt; tr &gt; td, table[border] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[border] &gt; tbody &gt; tr &gt; td, table[border] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[border] &gt; tfoot &gt; tr &gt; td, table[border] &gt; tfoot &gt; tr &gt; th </c-><c- p="">{</c->
  <c- c="">/* </c-><a href="#magic-border-selector" id="tables-2:magic-border-selector-2"><c- c="">only if border is not equivalent to zero</c-></a><c- c=""> */</c->
  <c- k="">border-width</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">border-style</c-><c- p="">:</c-> inset<c- p="">;</c->
<c- p="">}</c->
<c- f="">table[rules=none i] &gt; tr &gt; td, table[rules=none i] &gt; tr &gt; th,</c->
<c- f="">table[rules=none i] &gt; thead &gt; tr &gt; td, table[rules=none i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=none i] &gt; tbody &gt; tr &gt; td, table[rules=none i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=none i] &gt; tfoot &gt; tr &gt; td, table[rules=none i] &gt; tfoot &gt; tr &gt; th,</c->
<c- f="">table[rules=groups i] &gt; tr &gt; td, table[rules=groups i] &gt; tr &gt; th,</c->
<c- f="">table[rules=groups i] &gt; thead &gt; tr &gt; td, table[rules=groups i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=groups i] &gt; tbody &gt; tr &gt; td, table[rules=groups i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=groups i] &gt; tfoot &gt; tr &gt; td, table[rules=groups i] &gt; tfoot &gt; tr &gt; th,</c->
<c- f="">table[rules=rows i] &gt; tr &gt; td, table[rules=rows i] &gt; tr &gt; th,</c->
<c- f="">table[rules=rows i] &gt; thead &gt; tr &gt; td, table[rules=rows i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=rows i] &gt; tbody &gt; tr &gt; td, table[rules=rows i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=rows i] &gt; tfoot &gt; tr &gt; td, table[rules=rows i] &gt; tfoot &gt; tr &gt; th </c-><c- p="">{</c->
  <c- k="">border-width</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">border-style</c-><c- p="">:</c-> none<c- p="">;</c->
<c- p="">}</c->
<c- f="">table[rules=cols i] &gt; tr &gt; td, table[rules=cols i] &gt; tr &gt; th,</c->
<c- f="">table[rules=cols i] &gt; thead &gt; tr &gt; td, table[rules=cols i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=cols i] &gt; tbody &gt; tr &gt; td, table[rules=cols i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=cols i] &gt; tfoot &gt; tr &gt; td, table[rules=cols i] &gt; tfoot &gt; tr &gt; th </c-><c- p="">{</c->
  <c- k="">border-width</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">border-block-style</c-><c- p="">:</c-> none<c- p="">;</c->
  <c- k="">border-inline-style</c-><c- p="">:</c-> solid<c- p="">;</c->
<c- p="">}</c->
<c- f="">table[rules=all i] &gt; tr &gt; td, table[rules=all i] &gt; tr &gt; th,</c->
<c- f="">table[rules=all i] &gt; thead &gt; tr &gt; td, table[rules=all i] &gt; thead &gt; tr &gt; th,</c->
<c- f="">table[rules=all i] &gt; tbody &gt; tr &gt; td, table[rules=all i] &gt; tbody &gt; tr &gt; th,</c->
<c- f="">table[rules=all i] &gt; tfoot &gt; tr &gt; td, table[rules=all i] &gt; tfoot &gt; tr &gt; th </c-><c- p="">{</c->
  <c- k="">border-width</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">border-style</c-><c- p="">:</c-> solid<c- p="">;</c->
<c- p="">}</c->

<c- f="">table[rules=groups i] &gt; colgroup </c-><c- p="">{</c->
  <c- k="">border-inline-width</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">border-inline-style</c-><c- p="">:</c-> solid<c- p="">;</c->
<c- p="">}</c->
<c- f="">table[rules=groups i] &gt; thead,</c->
<c- f="">table[rules=groups i] &gt; tbody,</c->
<c- f="">table[rules=groups i] &gt; tfoot </c-><c- p="">{</c->
  <c- k="">border-block-width</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">border-block-style</c-><c- p="">:</c-> solid<c- p="">;</c->
<c- p="">}</c->

<c- f="">table[rules=rows i] &gt; tr, table[rules=rows i] &gt; thead &gt; tr,</c->
<c- f="">table[rules=rows i] &gt; tbody &gt; tr, table[rules=rows i] &gt; tfoot &gt; tr </c-><c- p="">{</c->
  <c- k="">border-block-width</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">border-block-style</c-><c- p="">:</c-> solid<c- p="">;</c->
<c- p="">}</c-></code></pre>




  <p>In <a id="tables-2:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, the following rules are also <a href="#expected" id="tables-2:expected-2">expected</a> to apply:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">table </c-><c- p="">{</c->
  <c- k="">font-weight</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">font-style</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">font-variant</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">font-size</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">line-height</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">white-space</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">text-align</c-><c- p="">:</c-> initial<c- p="">;</c->
<c- p="">}</c-></code></pre>

  <hr>

  <p>For the purposes of the CSS table model, the <code id="tables-2:the-col-element"><a href="#the-col-element">col</a></code> element is <a href="#expected" id="tables-2:expected-3">expected</a>
  to be treated as if it was present as many times as its <code id="tables-2:attr-col-span"><a href="#attr-col-span">span</a></code>
  attribute <a href="#rules-for-parsing-non-negative-integers" id="tables-2:rules-for-parsing-non-negative-integers">specifies</a>.</p>

  <p>For the purposes of the CSS table model, the <code id="tables-2:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code> element, if it contains no
  <code id="tables-2:the-col-element-2"><a href="#the-col-element">col</a></code> element, is <a href="#expected" id="tables-2:expected-4">expected</a> to be treated as if it had as many such
  children as its <code id="tables-2:attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code> attribute <a href="#rules-for-parsing-non-negative-integers" id="tables-2:rules-for-parsing-non-negative-integers-2">specifies</a>.</p>

  <p>For the purposes of the CSS table model, the <code id="tables-2:attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code> and
  <code id="tables-2:attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code> attributes on <code id="tables-2:the-td-element"><a href="#the-td-element">td</a></code> and <code id="tables-2:the-th-element"><a href="#the-th-element">th</a></code>
  elements are <a href="#expected" id="tables-2:expected-5">expected</a> to <a href="#rules-for-parsing-non-negative-integers" id="tables-2:rules-for-parsing-non-negative-integers-3">provide</a> the <i>special knowledge</i> regarding cells spanning rows and columns.</p>

  <p>In <a id="tables-2:html-documents" href="https://dom.spec.whatwg.org/#html-document" data-x-internal="html-documents">HTML documents</a>, the following rules are also <a href="#expected" id="tables-2:expected-6">expected</a> to apply:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">:is(table, thead, tbody, tfoot, tr) &gt; form </c-><c- p="">{</c-> <c- k="">display</c-><c- p="">:</c-> none !important; }</code></pre>

  <hr>

  <p>The <code id="tables-2:the-table-element"><a href="#the-table-element">table</a></code> element's <code id="tables-2:attr-table-cellspacing"><a href="#attr-table-cellspacing">cellspacing</a></code>
  attribute <a href="#maps-to-the-pixel-length-property" id="tables-2:maps-to-the-pixel-length-property">maps to the pixel length property</a> <a id="tables-2:'border-spacing'" href="https://drafts.csswg.org/css-tables/#propdef-border-spacing" data-x-internal="'border-spacing'">'border-spacing'</a> on the
  element.</p>

  <p>The <code id="tables-2:the-table-element-2"><a href="#the-table-element">table</a></code> element's <code id="tables-2:attr-table-cellpadding"><a href="#attr-table-cellpadding">cellpadding</a></code>
  attribute <a href="#maps-to-the-pixel-length-property" id="tables-2:maps-to-the-pixel-length-property-2">maps to the pixel length
  properties</a> <a id="tables-2:'padding-top'" href="https://drafts.csswg.org/css-box/#propdef-padding-top" data-x-internal="'padding-top'">'padding-top'</a>, <a id="tables-2:'padding-right'" href="https://drafts.csswg.org/css-box/#propdef-padding-right" data-x-internal="'padding-right'">'padding-right'</a>,
  <a id="tables-2:'padding-bottom'" href="https://drafts.csswg.org/css-box/#propdef-padding-bottom" data-x-internal="'padding-bottom'">'padding-bottom'</a>, and <a id="tables-2:'padding-left'" href="https://drafts.csswg.org/css-box/#propdef-padding-left" data-x-internal="'padding-left'">'padding-left'</a> of any <code id="tables-2:the-td-element-2"><a href="#the-td-element">td</a></code> and
  <code id="tables-2:the-th-element-2"><a href="#the-th-element">th</a></code> elements that have corresponding <a href="#concept-cell" id="tables-2:concept-cell">cells</a> in the
  <a href="#concept-table" id="tables-2:concept-table">table</a> corresponding to the <code id="tables-2:the-table-element-3"><a href="#the-table-element">table</a></code> element.</p>

  <p>The <code id="tables-2:the-table-element-4"><a href="#the-table-element">table</a></code> element's <code id="tables-2:attr-table-height"><a href="#attr-table-height">height</a></code> attribute
  <a href="#maps-to-the-dimension-property" id="tables-2:maps-to-the-dimension-property">maps to the dimension property</a> <a id="tables-2:'height'" href="https://drafts.csswg.org/css2/#the-height-property" data-x-internal="'height'">'height'</a> on the <code id="tables-2:the-table-element-5"><a href="#the-table-element">table</a></code>
  element.</p>

  <p>The <code id="tables-2:the-table-element-6"><a href="#the-table-element">table</a></code> element's <code id="tables-2:attr-table-width"><a href="#attr-table-width">width</a></code> attribute
  <a href="#maps-to-the-dimension-property-(ignoring-zero)" id="tables-2:maps-to-the-dimension-property-(ignoring-zero)">maps to the dimension property (ignoring zero)</a> <a id="tables-2:'width'" href="https://drafts.csswg.org/css2/#the-width-property" data-x-internal="'width'">'width'</a> on the
  <code id="tables-2:the-table-element-7"><a href="#the-table-element">table</a></code> element.</p>

  <p>The <code id="tables-2:the-col-element-3"><a href="#the-col-element">col</a></code> element's <code id="tables-2:attr-col-width"><a href="#attr-col-width">width</a></code> attribute <a href="#maps-to-the-dimension-property" id="tables-2:maps-to-the-dimension-property-2">maps
  to the dimension property</a> <a id="tables-2:'width'-2" href="https://drafts.csswg.org/css2/#the-width-property" data-x-internal="'width'">'width'</a> on the <code id="tables-2:the-col-element-4"><a href="#the-col-element">col</a></code>
  element.</p>

  <p>The <code id="tables-2:the-thead-element"><a href="#the-thead-element">thead</a></code>, <code id="tables-2:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>, and <code id="tables-2:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> elements' <code id="tables-2:attr-tbody-height"><a href="#attr-tbody-height">height</a></code> attribute <a href="#maps-to-the-dimension-property" id="tables-2:maps-to-the-dimension-property-3">maps to the dimension property</a>
  <a id="tables-2:'height'-2" href="https://drafts.csswg.org/css2/#the-height-property" data-x-internal="'height'">'height'</a> on the element.</p>

  <p>The <code id="tables-2:the-tr-element"><a href="#the-tr-element">tr</a></code> element's <code id="tables-2:attr-tr-height"><a href="#attr-tr-height">height</a></code> attribute <a href="#maps-to-the-dimension-property" id="tables-2:maps-to-the-dimension-property-4">maps
  to the dimension property</a> <a id="tables-2:'height'-3" href="https://drafts.csswg.org/css2/#the-height-property" data-x-internal="'height'">'height'</a> on the <code id="tables-2:the-tr-element-2"><a href="#the-tr-element">tr</a></code> element.</p>

  <p>The <code id="tables-2:the-td-element-3"><a href="#the-td-element">td</a></code> and <code id="tables-2:the-th-element-3"><a href="#the-th-element">th</a></code> elements' <code id="tables-2:attr-tdth-height"><a href="#attr-tdth-height">height</a></code>
  attributes <a href="#maps-to-the-dimension-property-(ignoring-zero)" id="tables-2:maps-to-the-dimension-property-(ignoring-zero)-2">map to the dimension
  property (ignoring zero)</a> <a id="tables-2:'height'-4" href="https://drafts.csswg.org/css2/#the-height-property" data-x-internal="'height'">'height'</a> on the element.</p>

  <p>The <code id="tables-2:the-td-element-4"><a href="#the-td-element">td</a></code> and <code id="tables-2:the-th-element-4"><a href="#the-th-element">th</a></code> elements' <code id="tables-2:attr-tdth-width"><a href="#attr-tdth-width">width</a></code>
  attributes <a href="#maps-to-the-dimension-property-(ignoring-zero)" id="tables-2:maps-to-the-dimension-property-(ignoring-zero)-3">map to the dimension
  property (ignoring zero)</a> <a id="tables-2:'width'-3" href="https://drafts.csswg.org/css2/#the-width-property" data-x-internal="'width'">'width'</a> on the element.</p>

  <hr>

  <div data-algorithm="">
  <p>The <code id="tables-2:the-thead-element-2"><a href="#the-thead-element">thead</a></code>, <code id="tables-2:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code>, <code id="tables-2:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code>, <code id="tables-2:the-tr-element-3"><a href="#the-tr-element">tr</a></code>,
  <code id="tables-2:the-td-element-5"><a href="#the-td-element">td</a></code>, and <code id="tables-2:the-th-element-5"><a href="#the-th-element">th</a></code> elements, when they have an <code>align</code>
  attribute whose value is an <a id="tables-2:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for either the string "<code>center</code>" or the string "<code>middle</code>", are <a href="#expected" id="tables-2:expected-7">expected</a>
  to center text within themselves, as if they had their <a id="tables-2:'text-align'" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property set to
  'center' in a <a href="#presentational-hints" id="tables-2:presentational-hints-2">presentational hint</a>, and to <a href="#align-descendants" id="tables-2:align-descendants">align
  descendants</a> to the center.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="tables-2:the-thead-element-3"><a href="#the-thead-element">thead</a></code>, <code id="tables-2:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code>, <code id="tables-2:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code>, <code id="tables-2:the-tr-element-4"><a href="#the-tr-element">tr</a></code>,
  <code id="tables-2:the-td-element-6"><a href="#the-td-element">td</a></code>, and <code id="tables-2:the-th-element-6"><a href="#the-th-element">th</a></code> elements, when they have an <code>align</code>
  attribute whose value is an <a id="tables-2:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>left</code>", are <a href="#expected" id="tables-2:expected-8">expected</a> to left-align text within themselves, as if
  they had their <a id="tables-2:'text-align'-2" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property set to 'left' in a <a href="#presentational-hints" id="tables-2:presentational-hints-3">presentational hint</a>, and to <a href="#align-descendants" id="tables-2:align-descendants-2">align descendants</a> to the left.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="tables-2:the-thead-element-4"><a href="#the-thead-element">thead</a></code>, <code id="tables-2:the-tbody-element-4"><a href="#the-tbody-element">tbody</a></code>, <code id="tables-2:the-tfoot-element-4"><a href="#the-tfoot-element">tfoot</a></code>, <code id="tables-2:the-tr-element-5"><a href="#the-tr-element">tr</a></code>,
  <code id="tables-2:the-td-element-7"><a href="#the-td-element">td</a></code>, and <code id="tables-2:the-th-element-7"><a href="#the-th-element">th</a></code> elements, when they have an <code>align</code>
  attribute whose value is an <a id="tables-2:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>right</code>", are <a href="#expected" id="tables-2:expected-9">expected</a> to right-align text within themselves, as if
  they had their <a id="tables-2:'text-align'-3" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property set to 'right' in a <a href="#presentational-hints" id="tables-2:presentational-hints-4">presentational hint</a>, and to <a href="#align-descendants" id="tables-2:align-descendants-3">align descendants</a>
  to the right.</p>
  </div>

  <div data-algorithm="">
  <p>The <code id="tables-2:the-thead-element-5"><a href="#the-thead-element">thead</a></code>, <code id="tables-2:the-tbody-element-5"><a href="#the-tbody-element">tbody</a></code>, <code id="tables-2:the-tfoot-element-5"><a href="#the-tfoot-element">tfoot</a></code>, <code id="tables-2:the-tr-element-6"><a href="#the-tr-element">tr</a></code>,
  <code id="tables-2:the-td-element-8"><a href="#the-td-element">td</a></code>, and <code id="tables-2:the-th-element-8"><a href="#the-th-element">th</a></code> elements, when they have an <code>align</code>
  attribute whose value is an <a id="tables-2:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>justify</code>", are <a href="#expected" id="tables-2:expected-10">expected</a> to full-justify text within themselves, as
  if they had their <a id="tables-2:'text-align'-4" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property set to 'justify' in a <a href="#presentational-hints" id="tables-2:presentational-hints-5">presentational hint</a>, and to <a href="#align-descendants" id="tables-2:align-descendants-4">align descendants</a>
  to the left.</p>
  </div>

  <p>User agents are <a href="#expected" id="tables-2:expected-11">expected</a> to have a rule in their user agent style sheet that
  matches <code id="tables-2:the-th-element-9"><a href="#the-th-element">th</a></code> elements that have a parent node whose <a id="tables-2:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> for
  the <a id="tables-2:'text-align'-5" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property is its initial value, whose declaration block consists of
  just a single declaration that sets the <a id="tables-2:'text-align'-6" href="https://drafts.csswg.org/css-text/#text-align-property" data-x-internal="'text-align'">'text-align'</a> property to the value
  'center'.</p>
  

  <hr>

  <div data-algorithm="">
  <p>When a <code id="tables-2:the-table-element-8"><a href="#the-table-element">table</a></code>, <code id="tables-2:the-thead-element-6"><a href="#the-thead-element">thead</a></code>, <code id="tables-2:the-tbody-element-6"><a href="#the-tbody-element">tbody</a></code>, <code id="tables-2:the-tfoot-element-6"><a href="#the-tfoot-element">tfoot</a></code>,
  <code id="tables-2:the-tr-element-7"><a href="#the-tr-element">tr</a></code>, <code id="tables-2:the-td-element-9"><a href="#the-td-element">td</a></code>, or <code id="tables-2:the-th-element-10"><a href="#the-th-element">th</a></code> element has a <code id="tables-2:attr-background"><a href="#attr-background">background</a></code> attribute set to a non-empty value, the new value is
  <a href="#expected" id="tables-2:expected-12">expected</a> to be <a href="#encoding-parsing-and-serializing-a-url" id="tables-2:encoding-parsing-and-serializing-a-url">encoding-parsed-and-serialized</a> relative to the element's <a id="tables-2:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a>,
  and if that does not return failure, the user agent is <a href="#expected" id="tables-2:expected-13">expected</a> to treat the
  attribute as a <a href="#presentational-hints" id="tables-2:presentational-hints-6">presentational hint</a> setting the
  element's <a id="tables-2:'background-image'" href="https://drafts.csswg.org/css-backgrounds/#propdef-background-image" data-x-internal="'background-image'">'background-image'</a> property to the return value.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="tables-2:the-table-element-9"><a href="#the-table-element">table</a></code>, <code id="tables-2:the-thead-element-7"><a href="#the-thead-element">thead</a></code>, <code id="tables-2:the-tbody-element-7"><a href="#the-tbody-element">tbody</a></code>, <code id="tables-2:the-tfoot-element-7"><a href="#the-tfoot-element">tfoot</a></code>,
  <code id="tables-2:the-tr-element-8"><a href="#the-tr-element">tr</a></code>, <code id="tables-2:the-td-element-10"><a href="#the-td-element">td</a></code>, or <code id="tables-2:the-th-element-11"><a href="#the-th-element">th</a></code> element has a <code>bgcolor</code>
  attribute set, the new value is <a href="#expected" id="tables-2:expected-14">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="tables-2:rules-for-parsing-a-legacy-colour-value">rules for
  parsing a legacy color value</a>, and if that does not return failure, the user agent is
  <a href="#expected" id="tables-2:expected-15">expected</a> to treat the attribute as a <a href="#presentational-hints" id="tables-2:presentational-hints-7">presentational hint</a> setting the element's <a id="tables-2:'background-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-background-color" data-x-internal="'background-color'">'background-color'</a> property
  to the resulting color.</p>
  </div>

  <div data-algorithm="">
  <p>When a <code id="tables-2:the-table-element-10"><a href="#the-table-element">table</a></code> element has a <code id="tables-2:attr-table-bordercolor"><a href="#attr-table-bordercolor">bordercolor</a></code>
  attribute, its value is <a href="#expected" id="tables-2:expected-16">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="tables-2:rules-for-parsing-a-legacy-colour-value-2">rules for parsing a
  legacy color value</a>, and if that does not return failure, the user agent is
  <a href="#expected" id="tables-2:expected-17">expected</a> to treat the attribute as a <a href="#presentational-hints" id="tables-2:presentational-hints-8">presentational hint</a> setting the element's <a id="tables-2:'border-top-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-color" data-x-internal="'border-top-color'">'border-top-color'</a>,
  <a id="tables-2:'border-right-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-right-color" data-x-internal="'border-right-color'">'border-right-color'</a>, <a id="tables-2:'border-bottom-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-color" data-x-internal="'border-bottom-color'">'border-bottom-color'</a>, and
  <a id="tables-2:'border-left-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-left-color" data-x-internal="'border-left-color'">'border-left-color'</a> properties to the resulting color.</p>
  </div>

  <hr>

  <p>The <code id="tables-2:the-table-element-11"><a href="#the-table-element">table</a></code> element's <code id="tables-2:attr-table-border"><a href="#attr-table-border">border</a></code> attribute <a href="#maps-to-the-pixel-length-property" id="tables-2:maps-to-the-pixel-length-property-3">maps to the pixel length properties</a>
  <a id="tables-2:'border-top-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-width" data-x-internal="'border-top-width'">'border-top-width'</a>, <a id="tables-2:'border-right-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-right-width" data-x-internal="'border-right-width'">'border-right-width'</a>,
  <a id="tables-2:'border-bottom-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-width" data-x-internal="'border-bottom-width'">'border-bottom-width'</a>, <a id="tables-2:'border-left-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-left-width" data-x-internal="'border-left-width'">'border-left-width'</a> on the element. If the
  attribute is present but parsing the attribute's value using the <a href="#rules-for-parsing-non-negative-integers" id="tables-2:rules-for-parsing-non-negative-integers-4">rules for parsing
  non-negative integers</a> generates an error, a default value of 1px is <a href="#expected" id="tables-2:expected-18">expected</a>
  to be used for that property instead.</p>

  <div data-algorithm="">
  <p>Rules marked "<dfn id="magic-border-selector">only if border is not equivalent to zero</dfn>"
  in the CSS block above is <a href="#expected" id="tables-2:expected-19">expected</a> to only be applied if the <code id="tables-2:attr-table-border-2"><a href="#attr-table-border">border</a></code> attribute mentioned in the selectors for the rule is not
  only present but, when parsed using the <a href="#rules-for-parsing-non-negative-integers" id="tables-2:rules-for-parsing-non-negative-integers-5">rules for parsing non-negative integers</a>, is
  also found to have a value other than zero or to generate an error.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>In <a id="tables-2:quirks-mode-2" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, a <code id="tables-2:the-td-element-11"><a href="#the-td-element">td</a></code> element or a <code id="tables-2:the-th-element-12"><a href="#the-th-element">th</a></code> element that has a
  <code id="tables-2:attr-tdth-nowrap"><a href="#attr-tdth-nowrap">nowrap</a></code> attribute but also has a <code id="tables-2:attr-tdth-width-2"><a href="#attr-tdth-width">width</a></code> attribute whose value, when parsed using the <a href="#rules-for-parsing-non-zero-dimension-values" id="tables-2:rules-for-parsing-non-zero-dimension-values">rules for
  parsing nonzero dimension values</a>, is found to be a length (not an error or a number
  classified as a percentage), is <a href="#expected" id="tables-2:expected-20">expected</a> to have a <a href="#presentational-hints" id="tables-2:presentational-hints-9">presentational hint</a> setting the element's <a id="tables-2:'white-space'" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> property to
  'normal', overriding the rule in the CSS block above that sets it to 'nowrap'.</p>  
  </div>

  <h4 id="margin-collapsing-quirks"><span class="secno">15.3.9</span> Margin collapsing quirks<a href="#margin-collapsing-quirks" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>A node is <dfn id="concept-rendering-substantial">substantial</dfn> if it is a text node
  that is not <a href="#inter-element-whitespace" id="margin-collapsing-quirks:inter-element-whitespace">inter-element whitespace</a>, or if it is an element node.</p>
  </div>

  <div data-algorithm="">
  <p>A node is <dfn id="concept-rendering-blank">blank</dfn> if it is an element that contains no
  <a href="#concept-rendering-substantial" id="margin-collapsing-quirks:concept-rendering-substantial">substantial</a> nodes.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="concept-rendering-elements-with-margins">elements with default margins</dfn>
  are the following elements: <code id="margin-collapsing-quirks:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code>, <code id="margin-collapsing-quirks:dir"><a href="#dir">dir</a></code>, <code id="margin-collapsing-quirks:the-dl-element"><a href="#the-dl-element">dl</a></code>,
  <code id="margin-collapsing-quirks:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, <code id="margin-collapsing-quirks:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>, <code id="margin-collapsing-quirks:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, <code id="margin-collapsing-quirks:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>, <code id="margin-collapsing-quirks:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>,
  <code id="margin-collapsing-quirks:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>, <code id="margin-collapsing-quirks:listing"><a href="#listing">listing</a></code>, <code id="margin-collapsing-quirks:the-menu-element"><a href="#the-menu-element">menu</a></code>, <code id="margin-collapsing-quirks:the-ol-element"><a href="#the-ol-element">ol</a></code>,
  <code id="margin-collapsing-quirks:the-p-element"><a href="#the-p-element">p</a></code>, <code id="margin-collapsing-quirks:plaintext"><a href="#plaintext">plaintext</a></code>, <code id="margin-collapsing-quirks:the-pre-element"><a href="#the-pre-element">pre</a></code>, <code id="margin-collapsing-quirks:the-ul-element"><a href="#the-ul-element">ul</a></code>, <code id="margin-collapsing-quirks:xmp"><a href="#xmp">xmp</a></code>.</p>
  </div>

  <div data-algorithm="">
  <p>In <a id="margin-collapsing-quirks:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, any <a href="#concept-rendering-elements-with-margins" id="margin-collapsing-quirks:concept-rendering-elements-with-margins">element
  with default margins</a> that is the <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="margin-collapsing-quirks:concept-tree-child" data-x-internal="concept-tree-child">child</a> of a
  <code id="margin-collapsing-quirks:the-body-element"><a href="#the-body-element">body</a></code>, <code id="margin-collapsing-quirks:the-td-element"><a href="#the-td-element">td</a></code>, or <code id="margin-collapsing-quirks:the-th-element"><a href="#the-th-element">th</a></code> element and has no <a href="#concept-rendering-substantial" id="margin-collapsing-quirks:concept-rendering-substantial-2">substantial</a> previous siblings is
  <a href="#expected" id="margin-collapsing-quirks:expected">expected</a> to have a user-agent level style sheet rule that sets its
  <a id="margin-collapsing-quirks:'margin-block-start'" href="https://drafts.csswg.org/css-logical/#propdef-margin-block-start" data-x-internal="'margin-block-start'">'margin-block-start'</a> property to zero.</p>
  </div>

  <div data-algorithm="">
  <p>In <a id="margin-collapsing-quirks:quirks-mode-2" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, any <a href="#concept-rendering-elements-with-margins" id="margin-collapsing-quirks:concept-rendering-elements-with-margins-2">element
  with default margins</a> that is the <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="margin-collapsing-quirks:concept-tree-child-2" data-x-internal="concept-tree-child">child</a> of a
  <code id="margin-collapsing-quirks:the-body-element-2"><a href="#the-body-element">body</a></code>, <code id="margin-collapsing-quirks:the-td-element-2"><a href="#the-td-element">td</a></code>, or <code id="margin-collapsing-quirks:the-th-element-2"><a href="#the-th-element">th</a></code> element, has no <a href="#concept-rendering-substantial" id="margin-collapsing-quirks:concept-rendering-substantial-3">substantial</a> previous siblings, and is <a href="#concept-rendering-blank" id="margin-collapsing-quirks:concept-rendering-blank">blank</a>, is <a href="#expected" id="margin-collapsing-quirks:expected-2">expected</a> to have a user-agent
  level style sheet rule that sets its <a id="margin-collapsing-quirks:'margin-block-end'" href="https://drafts.csswg.org/css-logical/#propdef-margin-block-end" data-x-internal="'margin-block-end'">'margin-block-end'</a> property to zero also.</p>
  </div>

  <div data-algorithm="">
  <p>In <a id="margin-collapsing-quirks:quirks-mode-3" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, any <a href="#concept-rendering-elements-with-margins" id="margin-collapsing-quirks:concept-rendering-elements-with-margins-3">element
  with default margins</a> that is the <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="margin-collapsing-quirks:concept-tree-child-3" data-x-internal="concept-tree-child">child</a> of a
  <code id="margin-collapsing-quirks:the-td-element-3"><a href="#the-td-element">td</a></code> or <code id="margin-collapsing-quirks:the-th-element-3"><a href="#the-th-element">th</a></code> element, has no <a href="#concept-rendering-substantial" id="margin-collapsing-quirks:concept-rendering-substantial-4">substantial</a> following siblings, and is <a href="#concept-rendering-blank" id="margin-collapsing-quirks:concept-rendering-blank-2">blank</a>, is <a href="#expected" id="margin-collapsing-quirks:expected-3">expected</a> to have a user-agent
  level style sheet rule that sets its <a id="margin-collapsing-quirks:'margin-block-start'-2" href="https://drafts.csswg.org/css-logical/#propdef-margin-block-start" data-x-internal="'margin-block-start'">'margin-block-start'</a> property to zero.</p>
  </div>

  <div data-algorithm="">
  <p>In <a id="margin-collapsing-quirks:quirks-mode-4" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, any <code id="margin-collapsing-quirks:the-p-element-2"><a href="#the-p-element">p</a></code> element that is the <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="margin-collapsing-quirks:concept-tree-child-4" data-x-internal="concept-tree-child">child</a> of a <code id="margin-collapsing-quirks:the-td-element-4"><a href="#the-td-element">td</a></code> or <code id="margin-collapsing-quirks:the-th-element-4"><a href="#the-th-element">th</a></code> element and has
  no <a href="#concept-rendering-substantial" id="margin-collapsing-quirks:concept-rendering-substantial-5">substantial</a> following siblings, is
  <a href="#expected" id="margin-collapsing-quirks:expected-4">expected</a> to have a user-agent level style sheet rule that sets its
  <a id="margin-collapsing-quirks:'margin-block-end'-2" href="https://drafts.csswg.org/css-logical/#propdef-margin-block-end" data-x-internal="'margin-block-end'">'margin-block-end'</a> property to zero.</p>
  </div>


  <h4 id="form-controls"><span class="secno">15.3.10</span> Form controls<a href="#form-controls" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">input, select, button, textarea </c-><c- p="">{</c->
  <c- k="">letter-spacing</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">word-spacing</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">line-height</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">text-transform</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">text-indent</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">text-shadow</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">appearance</c-><c- p="">:</c-> auto<c- p="">;</c->
<c- p="">}</c->

<c- f="">input:not([type=image i], [type=range i], [type=checkbox i], [type=radio i]) </c-><c- p="">{</c->
  <c- k="">overflow</c-><c- p="">:</c-> clip !important;
  overflow-clip-margin: 0 !important;
}

input, select, textarea {
  text-align: initial;
}

:autofill {
  field-sizing: fixed !important;
}

input:is([type=reset i], [type=button i], [type=submit i]), button {
  text-align: center;
}

input, button {
  display: inline-block;
}

input[type=hidden i], input[type=file i], input[type=image i] {
  appearance: none;
}

input:is([type=radio i], [type=checkbox i], [type=reset i], [type=button i],
[type=submit i], [type=color i], [type=search i]), select, button {
  box-sizing: border-box;
}

textarea { white-space: pre-wrap; }</code></pre>

  <p>In <a id="form-controls:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, the following rules are also <a href="#expected" id="form-controls:expected">expected</a> to apply:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">input:not([type=image i]), textarea </c-><c- p="">{</c-> <c- k="">box-sizing</c-><c- p="">:</c-> border-box<c- p="">;</c-> <c- p="">}</c-></code></pre>

  <p>Each kind of form control is also described in the <a href="#widgets">Widgets</a> section,
  which describes the look and feel of the control.</p>

  <p>For <code id="form-controls:the-input-element"><a href="#the-input-element">input</a></code> elements where the <code id="form-controls:attr-input-type"><a href="#attr-input-type">type</a></code> attribute
  is not in the <a href="#hidden-state-(type=hidden)" id="form-controls:hidden-state-(type=hidden)">Hidden</a> state or the <a href="#image-button-state-(type=image)" id="form-controls:image-button-state-(type=image)">Image Button</a> state, and that are <a href="#being-rendered" id="form-controls:being-rendered">being
  rendered</a>, are <a href="#expected" id="form-controls:expected-2">expected</a> to act as follows:</p>

  <ul><li><p>The <a id="form-controls:inner-display-type" href="https://drafts.csswg.org/css-display/#inner-display-type" data-x-internal="inner-display-type">inner display type</a> is always 'flow-root'.</p></li></ul>


  <h4 id="the-hr-element-2"><span class="secno">15.3.11</span> The <code id="the-hr-element-2:the-hr-element"><a href="#the-hr-element">hr</a></code> element<a href="#the-hr-element-2" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">hr </c-><c- p="">{</c->
  <c- k="">color</c-><c- p="">:</c-> gray<c- p="">;</c->
  <c- k="">border-style</c-><c- p="">:</c-> inset<c- p="">;</c->
  <c- k="">border-width</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">margin-block</c-><c- p="">:</c-> <c- m="">0.5</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">margin-inline</c-><c- p="">:</c-> auto<c- p="">;</c->
  <c- k="">overflow</c-><c- p="">:</c-> hidden<c- p="">;</c->
<c- p="">}</c-></code></pre>

  <p>The following rules are also <a href="#expected" id="the-hr-element-2:expected">expected</a> to apply, as <a href="#presentational-hints" id="the-hr-element-2:presentational-hints">presentational
  hints</a>:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">hr[align=left i] </c-><c- p="">{</c-> <c- k="">margin-left</c-><c- p="">:</c-> <c- m="">0</c-><c- p="">;</c-> <c- k="">margin-right</c-><c- p="">:</c-> auto<c- p="">;</c-> <c- p="">}</c->
<c- f="">hr[align=right i] </c-><c- p="">{</c-> <c- k="">margin-left</c-><c- p="">:</c-> auto<c- p="">;</c-> <c- k="">margin-right</c-><c- p="">:</c-> <c- m="">0</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">hr[align=center i] </c-><c- p="">{</c-> <c- k="">margin-left</c-><c- p="">:</c-> auto<c- p="">;</c-> <c- k="">margin-right</c-><c- p="">:</c-> auto<c- p="">;</c-> <c- p="">}</c->
<c- f="">hr[color], hr[noshade] </c-><c- p="">{</c-> <c- k="">border-style</c-><c- p="">:</c-> solid<c- p="">;</c-> <c- p="">}</c-></code></pre>

  <div data-algorithm="">
  <p>If an <code id="the-hr-element-2:the-hr-element-2"><a href="#the-hr-element">hr</a></code> element has either a <code id="the-hr-element-2:attr-hr-color"><a href="#attr-hr-color">color</a></code> attribute
  or a <code id="the-hr-element-2:attr-hr-noshade"><a href="#attr-hr-noshade">noshade</a></code> attribute, and furthermore also has a <code id="the-hr-element-2:attr-hr-size"><a href="#attr-hr-size">size</a></code> attribute, and parsing that attribute's value using the
  <a href="#rules-for-parsing-non-negative-integers" id="the-hr-element-2:rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a> doesn't generate an error, then the user
  agent is <a href="#expected" id="the-hr-element-2:expected-2">expected</a> to use the parsed value divided by two as a pixel length for
  <a href="#presentational-hints" id="the-hr-element-2:presentational-hints-2">presentational hints</a> for the properties <a id="the-hr-element-2:'border-top-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-width" data-x-internal="'border-top-width'">'border-top-width'</a>,
  <a id="the-hr-element-2:'border-right-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-right-width" data-x-internal="'border-right-width'">'border-right-width'</a>, <a id="the-hr-element-2:'border-bottom-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-width" data-x-internal="'border-bottom-width'">'border-bottom-width'</a>, and
  <a id="the-hr-element-2:'border-left-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-left-width" data-x-internal="'border-left-width'">'border-left-width'</a> on the element.</p>

  <p>Otherwise, if an <code id="the-hr-element-2:the-hr-element-3"><a href="#the-hr-element">hr</a></code> element has neither a <code id="the-hr-element-2:attr-hr-color-2"><a href="#attr-hr-color">color</a></code>
  attribute nor a <code id="the-hr-element-2:attr-hr-noshade-2"><a href="#attr-hr-noshade">noshade</a></code> attribute, but does have a <code id="the-hr-element-2:attr-hr-size-2"><a href="#attr-hr-size">size</a></code> attribute, and parsing that attribute's value using the
  <a href="#rules-for-parsing-non-negative-integers" id="the-hr-element-2:rules-for-parsing-non-negative-integers-2">rules for parsing non-negative integers</a> doesn't generate an error, then: if the
  parsed value is one, then the user agent is <a href="#expected" id="the-hr-element-2:expected-3">expected</a> to use the attribute as a <a href="#presentational-hints" id="the-hr-element-2:presentational-hints-3">presentational hint</a> setting the element's
  <a id="the-hr-element-2:'border-bottom-width'-2" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-width" data-x-internal="'border-bottom-width'">'border-bottom-width'</a> to 0; otherwise, if the parsed value is greater than one, then
  the user agent is <a href="#expected" id="the-hr-element-2:expected-4">expected</a> to use the parsed value minus two as a pixel length for
  <a href="#presentational-hints" id="the-hr-element-2:presentational-hints-4">presentational hints</a> for the <a id="the-hr-element-2:'height'" href="https://drafts.csswg.org/css2/#the-height-property" data-x-internal="'height'">'height'</a> property on the element.</p>
  </div>

  <p>The <code id="the-hr-element-2:attr-hr-width"><a href="#attr-hr-width">width</a></code> attribute on an <code id="the-hr-element-2:the-hr-element-4"><a href="#the-hr-element">hr</a></code> element <a href="#maps-to-the-dimension-property" id="the-hr-element-2:maps-to-the-dimension-property">maps
  to the dimension property</a> <a id="the-hr-element-2:'width'" href="https://drafts.csswg.org/css2/#the-width-property" data-x-internal="'width'">'width'</a> on the element.</p>

  <p>When an <code id="the-hr-element-2:the-hr-element-5"><a href="#the-hr-element">hr</a></code> element has a <code id="the-hr-element-2:attr-hr-color-3"><a href="#attr-hr-color">color</a></code> attribute, its
  value is <a href="#expected" id="the-hr-element-2:expected-5">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="the-hr-element-2:rules-for-parsing-a-legacy-colour-value">rules for parsing a legacy color
  value</a>, and if that does not return failure, the user agent is <a href="#expected" id="the-hr-element-2:expected-6">expected</a> to
  treat the attribute as a <a href="#presentational-hints" id="the-hr-element-2:presentational-hints-5">presentational hint</a> setting
  the element's <a id="the-hr-element-2:'color'" href="https://drafts.csswg.org/css-color/#the-color-property" data-x-internal="'color'">'color'</a> property to the resulting color.</p>



  <h4 id="the-fieldset-and-legend-elements"><span class="secno">15.3.12</span> The <code id="the-fieldset-and-legend-elements:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code> and <code id="the-fieldset-and-legend-elements:the-legend-element"><a href="#the-legend-element">legend</a></code> elements<a href="#the-fieldset-and-legend-elements" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">fieldset </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c-> block<c- p="">;</c->
  <c- k="">margin-inline</c-><c- p="">:</c-> <c- m="">2</c-><c- l="">px</c-><c- p="">;</c->
  <c- k="">border</c-><c- p="">:</c-> groove <c- m="">2</c-><c- l="">px</c-> ThreeDFace<c- p="">;</c->
  <c- k="">padding-block</c-><c- p="">:</c-> <c- m="">0.35</c-><c- l="">em</c-> <c- m="">0.625</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">padding-inline</c-><c- p="">:</c-> <c- m="">0.75</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">min-inline-size</c-><c- p="">:</c-> min-content<c- p="">;</c->
<c- p="">}</c->

<c- f="">legend </c-><c- p="">{</c->
  <c- k="">padding-inline</c-><c- p="">:</c-> <c- m="">2</c-><c- l="">px</c-><c- p="">;</c->
<c- p="">}</c->

<c- f="">legend[align=left i] </c-><c- p="">{</c->
  <c- k="">justify-self</c-><c- p="">:</c-> left<c- p="">;</c->
<c- p="">}</c->

<c- f="">legend[align=center i] </c-><c- p="">{</c->
  <c- k="">justify-self</c-><c- p="">:</c-> center<c- p="">;</c->
<c- p="">}</c->

<c- f="">legend[align=right i] </c-><c- p="">{</c->
  <c- k="">justify-self</c-><c- p="">:</c-> right<c- p="">;</c->
<c- p="">}</c-></code></pre>

  <div data-algorithm="">
  <p>The <code id="the-fieldset-and-legend-elements:the-fieldset-element-2"><a href="#the-fieldset-element">fieldset</a></code> element, when it generates a <a id="the-fieldset-and-legend-elements:css-box" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS box</a>, is
  <a href="#expected" id="the-fieldset-and-legend-elements:expected">expected</a> to act as follows:</p>

  <ul><li><p>The element is <a href="#expected" id="the-fieldset-and-legend-elements:expected-2">expected</a> to establish a new <a id="the-fieldset-and-legend-elements:block-formatting-context" href="https://drafts.csswg.org/css-display/#block-formatting-context" data-x-internal="block-formatting-context">block formatting
   context</a>.</p></li><li>
    <p>The <a id="the-fieldset-and-legend-elements:'display'" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property is <a href="#expected" id="the-fieldset-and-legend-elements:expected-3">expected</a> to act as follows:</p>

    <ul><li><p>If the computed value of <a id="the-fieldset-and-legend-elements:'display'-2" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> is a value such that the <a id="the-fieldset-and-legend-elements:outer-display-type" href="https://drafts.csswg.org/css-display/#outer-display-type" data-x-internal="outer-display-type">outer
     display type</a> is 'inline', then behave as 'inline-block'.</p></li><li><p>Otherwise, behave as 'flow-root'.</p></li></ul>

    <p class="note">This does not change the computed value.</p>
   </li><li>
    <p>If the element's box has a child box that matches the conditions in the list below, then the
    first such child box is the 'fieldset' element's <dfn id="rendered-legend">rendered legend</dfn>:</p>

    <ul class="brief"><li>The child is a <code id="the-fieldset-and-legend-elements:the-legend-element-2"><a href="#the-legend-element">legend</a></code> element.</li><li>The child's used value of <a id="the-fieldset-and-legend-elements:'float'" href="https://drafts.csswg.org/css2/#float-position" data-x-internal="'float'">'float'</a> is 'none'.</li><li>The child's used value of <a id="the-fieldset-and-legend-elements:'position'" href="https://drafts.csswg.org/css-position/#position-property" data-x-internal="'position'">'position'</a> is not 'absolute' or 'fixed'.</li></ul>
   </li><li>
    <p>If the element has a <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend">rendered legend</a>, then the border is <a href="#expected" id="the-fieldset-and-legend-elements:expected-4">expected</a>
    to not be painted behind the rectangle defined as follows, using the writing mode of the
    fieldset:</p>

    <ol><li><p>The block-start edge of the rectangle is the smaller of the block-start edge of the
     <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-2">rendered legend</a>'s margin rectangle at its static position (ignoring transforms),
     and the block-start outer edge of the <code id="the-fieldset-and-legend-elements:the-fieldset-element-3"><a href="#the-fieldset-element">fieldset</a></code>'s border.</p></li><li><p>The block-end edge of the rectangle is the larger of the block-end edge of the
     <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-3">rendered legend</a>'s margin rectangle at its static position (ignoring transforms),
     and the block-end outer edge of the <code id="the-fieldset-and-legend-elements:the-fieldset-element-4"><a href="#the-fieldset-element">fieldset</a></code>'s border.</p></li><li><p>The inline-start edge of the rectangle is the smaller of the inline-start edge of the
     <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-4">rendered legend</a>'s border rectangle at its static position (ignoring transforms),
     and the inline-start outer edge of the <code id="the-fieldset-and-legend-elements:the-fieldset-element-5"><a href="#the-fieldset-element">fieldset</a></code>'s border.</p></li><li><p>The inline-end edge of the rectangle is the larger of the inline-end edge of the
     <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-5">rendered legend</a>'s border rectangle at its static position (ignoring transforms),
     and the inline-end outer edge of the <code id="the-fieldset-and-legend-elements:the-fieldset-element-6"><a href="#the-fieldset-element">fieldset</a></code>'s border.</p></li></ol>
   </li><li><p>The space allocated for the element's border on the block-start side is
   <a href="#expected" id="the-fieldset-and-legend-elements:expected-5">expected</a> to be the element's <a id="the-fieldset-and-legend-elements:'border-block-start-width'" href="https://drafts.csswg.org/css-logical/#propdef-border-block-start-width" data-x-internal="'border-block-start-width'">'border-block-start-width'</a> or the
   <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-6">rendered legend</a>'s margin box size in the <code id="the-fieldset-and-legend-elements:the-fieldset-element-7"><a href="#the-fieldset-element">fieldset</a></code>'s block-flow
   direction, whichever is greater.</p></li><li><p>For the purpose of calculating the used <a id="the-fieldset-and-legend-elements:'block-size'" href="https://drafts.csswg.org/css-logical/#propdef-block-size" data-x-internal="'block-size'">'block-size'</a>, if the computed
   <a id="the-fieldset-and-legend-elements:'block-size'-2" href="https://drafts.csswg.org/css-logical/#propdef-block-size" data-x-internal="'block-size'">'block-size'</a> is not 'auto', the space allocated for the <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-7">rendered
   legend</a>'s margin box that spills out past the border, if any, is <a href="#expected" id="the-fieldset-and-legend-elements:expected-6">expected</a> to
   be subtracted from the <a id="the-fieldset-and-legend-elements:'block-size'-3" href="https://drafts.csswg.org/css-logical/#propdef-block-size" data-x-internal="'block-size'">'block-size'</a>. If the content box's block-size would be
   negative, then let the content box's block-size be 0 instead.</p></li><li><p>If the element has a <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-8">rendered legend</a>, then that element is
   <a href="#expected" id="the-fieldset-and-legend-elements:expected-7">expected</a> to be the first child box.</p></li><li><p>The <a href="#anonymous-fieldset-content-box" id="the-fieldset-and-legend-elements:anonymous-fieldset-content-box">anonymous fieldset content box</a> is <a href="#expected" id="the-fieldset-and-legend-elements:expected-8">expected</a> to appear after
   the <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-9">rendered legend</a> and is <a href="#expected" id="the-fieldset-and-legend-elements:expected-9">expected</a> to contain the content (including
   the '::before' and '::after' pseudo-elements) of the <code id="the-fieldset-and-legend-elements:the-fieldset-element-8"><a href="#the-fieldset-element">fieldset</a></code> element except for
   the <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-10">rendered legend</a>, if there is one.</p></li><li><p>The used value of the <a id="the-fieldset-and-legend-elements:'padding-top'" href="https://drafts.csswg.org/css-box/#propdef-padding-top" data-x-internal="'padding-top'">'padding-top'</a>, <a id="the-fieldset-and-legend-elements:'padding-right'" href="https://drafts.csswg.org/css-box/#propdef-padding-right" data-x-internal="'padding-right'">'padding-right'</a>,
   <a id="the-fieldset-and-legend-elements:'padding-bottom'" href="https://drafts.csswg.org/css-box/#propdef-padding-bottom" data-x-internal="'padding-bottom'">'padding-bottom'</a>, and <a id="the-fieldset-and-legend-elements:'padding-left'" href="https://drafts.csswg.org/css-box/#propdef-padding-left" data-x-internal="'padding-left'">'padding-left'</a> properties are
   <a href="#expected" id="the-fieldset-and-legend-elements:expected-10">expected</a> to be zero.</p></li><li><p>For the purpose of calculating the min-content inline size, use the greater of the
   min-content inline size of the <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-11">rendered legend</a> and the min-content inline size of
   the <a href="#anonymous-fieldset-content-box" id="the-fieldset-and-legend-elements:anonymous-fieldset-content-box-2">anonymous fieldset content box</a>.</p></li><li><p>For the purpose of calculating the max-content inline size, use the greater of the
   max-content inline size of the <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-12">rendered legend</a> and the max-content inline size of
   the <a href="#anonymous-fieldset-content-box" id="the-fieldset-and-legend-elements:anonymous-fieldset-content-box-3">anonymous fieldset content box</a>.</p></li></ul>
  </div>

  <div data-algorithm="">
  <p>A <code id="the-fieldset-and-legend-elements:the-fieldset-element-9"><a href="#the-fieldset-element">fieldset</a></code> element's <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-13">rendered legend</a>, if any, is
  <a href="#expected" id="the-fieldset-and-legend-elements:expected-11">expected</a> to act as follows:</p>

  <ul><li><p>The element is <a href="#expected" id="the-fieldset-and-legend-elements:expected-12">expected</a> to establish a new <a id="the-fieldset-and-legend-elements:formatting-context" href="https://drafts.csswg.org/css-display/#formatting-context" data-x-internal="formatting-context">formatting context</a>
   for its contents. The type of this <a id="the-fieldset-and-legend-elements:formatting-context-2" href="https://drafts.csswg.org/css-display/#formatting-context" data-x-internal="formatting-context">formatting context</a> is determined by its
   <a id="the-fieldset-and-legend-elements:'display'-3" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> value, as usual.</p></li><li>
    <p>The <a id="the-fieldset-and-legend-elements:'display'-4" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property is <a href="#expected" id="the-fieldset-and-legend-elements:expected-13">expected</a> to behave as if its computed
    value was blockified.</p>

    <p class="note">This does not change the computed value.</p>
   </li><li><p>If the <a id="the-fieldset-and-legend-elements:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of <a id="the-fieldset-and-legend-elements:'inline-size'" href="https://drafts.csswg.org/css-logical/#propdef-inline-size" data-x-internal="'inline-size'">'inline-size'</a> is 'auto', then the
   <a id="the-fieldset-and-legend-elements:used-value" href="https://drafts.csswg.org/css-cascade/#used-value" data-x-internal="used-value">used value</a> is the <a id="the-fieldset-and-legend-elements:fit-content-inline-size" href="https://drafts.csswg.org/css-sizing/#fit-content-inline-size" data-x-internal="fit-content-inline-size">fit-content inline size</a>.</p></li><li><p>The element is <a href="#expected" id="the-fieldset-and-legend-elements:expected-14">expected</a> to be positioned in the inline direction as is
   normal for blocks (e.g., taking into account margins and the <a id="the-fieldset-and-legend-elements:'justify-self'" href="https://drafts.csswg.org/css-align/#propdef-justify-self" data-x-internal="'justify-self'">'justify-self'</a>
   property).</p></li><li>
    <p>The element's box is <a href="#expected" id="the-fieldset-and-legend-elements:expected-15">expected</a> to be constrained in the inline direction by the
    inline content size of the <code id="the-fieldset-and-legend-elements:the-fieldset-element-10"><a href="#the-fieldset-element">fieldset</a></code> as if it had used its computed inline
    padding.</p>

    <div class="example">
     <p>For example, if the <code id="the-fieldset-and-legend-elements:the-fieldset-element-11"><a href="#the-fieldset-element">fieldset</a></code> has a specified padding of 50px, then the
     <a href="#rendered-legend" id="the-fieldset-and-legend-elements:rendered-legend-14">rendered legend</a> will be positioned 50px in from the <code id="the-fieldset-and-legend-elements:the-fieldset-element-12"><a href="#the-fieldset-element">fieldset</a></code>'s
     border. The padding will further apply to the <a href="#anonymous-fieldset-content-box" id="the-fieldset-and-legend-elements:anonymous-fieldset-content-box-4">anonymous fieldset content box</a>
     instead of the <code id="the-fieldset-and-legend-elements:the-fieldset-element-13"><a href="#the-fieldset-element">fieldset</a></code> element itself.</p>
    </div>
   </li><li><p>The element is <a href="#expected" id="the-fieldset-and-legend-elements:expected-16">expected</a> to be positioned in the block-flow direction such
   that its border box is centered over the border on the block-start side of the
   <code id="the-fieldset-and-legend-elements:the-fieldset-element-14"><a href="#the-fieldset-element">fieldset</a></code> element.</p></li></ul>
  </div>


  <div data-algorithm="">
  <p>A <code id="the-fieldset-and-legend-elements:the-fieldset-element-15"><a href="#the-fieldset-element">fieldset</a></code> element's <dfn id="anonymous-fieldset-content-box">anonymous fieldset content box</dfn> is
  <a href="#expected" id="the-fieldset-and-legend-elements:expected-17">expected</a> to act as follows:</p>

  <ul><li>
    <p>The <a id="the-fieldset-and-legend-elements:'display'-5" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property is <a href="#expected" id="the-fieldset-and-legend-elements:expected-18">expected</a> to act as follows:</p>

    <ul><li><p>If the computed value of <a id="the-fieldset-and-legend-elements:'display'-6" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> on the <code id="the-fieldset-and-legend-elements:the-fieldset-element-16"><a href="#the-fieldset-element">fieldset</a></code> element
     is 'grid' or 'inline-grid', then set the used value to 'grid'.</p></li><li><p>If the computed value of <a id="the-fieldset-and-legend-elements:'display'-7" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> on the <code id="the-fieldset-and-legend-elements:the-fieldset-element-17"><a href="#the-fieldset-element">fieldset</a></code> element
     is 'flex' or 'inline-flex', then set the used value to 'flex'.</p></li><li><p>Otherwise, set the used value to 'flow-root'.</p></li></ul>
   </li><li>
    <p>The following properties are <a href="#expected" id="the-fieldset-and-legend-elements:expected-19">expected</a> to inherit from the <code id="the-fieldset-and-legend-elements:the-fieldset-element-18"><a href="#the-fieldset-element">fieldset</a></code>
    element:</p>

    <ul class="brief"><li><a id="the-fieldset-and-legend-elements:'align-content'" href="https://drafts.csswg.org/css-align/#propdef-align-content" data-x-internal="'align-content'">'align-content'</a></li><li><a id="the-fieldset-and-legend-elements:'align-items'" href="https://drafts.csswg.org/css-align/#propdef-align-items" data-x-internal="'align-items'">'align-items'</a></li><li><a id="the-fieldset-and-legend-elements:'border-radius'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-radius" data-x-internal="'border-radius'">'border-radius'</a></li><li><a id="the-fieldset-and-legend-elements:'column-count'" href="https://drafts.csswg.org/css-multicol/#propdef-column-count" data-x-internal="'column-count'">'column-count'</a></li><li><a id="the-fieldset-and-legend-elements:'column-fill'" href="https://drafts.csswg.org/css-multicol/#propdef-column-fill" data-x-internal="'column-fill'">'column-fill'</a></li><li><a id="the-fieldset-and-legend-elements:'column-gap'" href="https://drafts.csswg.org/css-multicol/#propdef-column-gap" data-x-internal="'column-gap'">'column-gap'</a></li><li><a id="the-fieldset-and-legend-elements:'column-rule'" href="https://drafts.csswg.org/css-multicol/#propdef-column-rule" data-x-internal="'column-rule'">'column-rule'</a></li><li><a id="the-fieldset-and-legend-elements:'column-width'" href="https://drafts.csswg.org/css-multicol/#propdef-column-width" data-x-internal="'column-width'">'column-width'</a></li><li><a id="the-fieldset-and-legend-elements:'flex-direction'" href="https://drafts.csswg.org/css-flexbox/#propdef-flex-direction" data-x-internal="'flex-direction'">'flex-direction'</a></li><li><a id="the-fieldset-and-legend-elements:'flex-wrap'" href="https://drafts.csswg.org/css-flexbox/#propdef-flex-wrap" data-x-internal="'flex-wrap'">'flex-wrap'</a></li><li><a id="the-fieldset-and-legend-elements:'grid-auto-columns'" href="https://drafts.csswg.org/css-grid/#propdef-grid-auto-columns" data-x-internal="'grid-auto-columns'">'grid-auto-columns'</a></li><li><a id="the-fieldset-and-legend-elements:'grid-auto-flow'" href="https://drafts.csswg.org/css-grid/#propdef-grid-auto-flow" data-x-internal="'grid-auto-flow'">'grid-auto-flow'</a></li><li><a id="the-fieldset-and-legend-elements:'grid-auto-rows'" href="https://drafts.csswg.org/css-grid/#propdef-grid-auto-rows" data-x-internal="'grid-auto-rows'">'grid-auto-rows'</a></li><li><a id="the-fieldset-and-legend-elements:'grid-column-gap'" href="https://drafts.csswg.org/css-grid/#propdef-grid-column-gap" data-x-internal="'grid-column-gap'">'grid-column-gap'</a></li><li><a id="the-fieldset-and-legend-elements:'grid-row-gap'" href="https://drafts.csswg.org/css-grid/#propdef-grid-row-gap" data-x-internal="'grid-row-gap'">'grid-row-gap'</a></li><li><a id="the-fieldset-and-legend-elements:'grid-template-areas'" href="https://drafts.csswg.org/css-grid/#propdef-grid-template-areas" data-x-internal="'grid-template-areas'">'grid-template-areas'</a></li><li><a id="the-fieldset-and-legend-elements:'grid-template-columns'" href="https://drafts.csswg.org/css-grid/#propdef-grid-template-columns" data-x-internal="'grid-template-columns'">'grid-template-columns'</a></li><li><a id="the-fieldset-and-legend-elements:'grid-template-rows'" href="https://drafts.csswg.org/css-grid/#propdef-grid-template-rows" data-x-internal="'grid-template-rows'">'grid-template-rows'</a></li><li><a id="the-fieldset-and-legend-elements:'justify-content'" href="https://drafts.csswg.org/css-align/#propdef-propdef-justify-content" data-x-internal="'justify-content'">'justify-content'</a></li><li><a id="the-fieldset-and-legend-elements:'justify-items'" href="https://drafts.csswg.org/css-align/#propdef-propdef-justify-items" data-x-internal="'justify-items'">'justify-items'</a></li><li><a id="the-fieldset-and-legend-elements:'overflow'" href="https://drafts.csswg.org/css-overflow/#propdef-overflow" data-x-internal="'overflow'">'overflow'</a></li><li><a id="the-fieldset-and-legend-elements:'padding-bottom'-2" href="https://drafts.csswg.org/css-box/#propdef-padding-bottom" data-x-internal="'padding-bottom'">'padding-bottom'</a></li><li><a id="the-fieldset-and-legend-elements:'padding-left'-2" href="https://drafts.csswg.org/css-box/#propdef-padding-left" data-x-internal="'padding-left'">'padding-left'</a></li><li><a id="the-fieldset-and-legend-elements:'padding-right'-2" href="https://drafts.csswg.org/css-box/#propdef-padding-right" data-x-internal="'padding-right'">'padding-right'</a></li><li><a id="the-fieldset-and-legend-elements:'padding-top'-2" href="https://drafts.csswg.org/css-box/#propdef-padding-top" data-x-internal="'padding-top'">'padding-top'</a></li><li><a id="the-fieldset-and-legend-elements:'text-overflow'" href="https://drafts.csswg.org/css-overflow/#propdef-text-overflow" data-x-internal="'text-overflow'">'text-overflow'</a></li><li><a id="the-fieldset-and-legend-elements:'unicode-bidi'" href="https://drafts.csswg.org/css-writing-modes/#unicode-bidi" data-x-internal="'unicode-bidi'">'unicode-bidi'</a></li></ul>
   </li><li><p>The <a id="the-fieldset-and-legend-elements:'block-size'-4" href="https://drafts.csswg.org/css-logical/#propdef-block-size" data-x-internal="'block-size'">'block-size'</a> property is <a href="#expected" id="the-fieldset-and-legend-elements:expected-20">expected</a> to be set to
   '100%'.</p></li><li><p>For the purpose of calculating percentage padding, act as if the padding was calculated
   for the <code id="the-fieldset-and-legend-elements:the-fieldset-element-19"><a href="#the-fieldset-element">fieldset</a></code> element.</p></li></ul>
  </div>

  <div id="fieldset-layout-model" class="note"><a href="#fieldset-layout-model" class="self-link"></a>
   <figure>
    <svg width="480" role="img" viewBox="0 0 400 270" height="324" aria-label="Fieldset layout
    model">

     <defs>
      <marker markerHeight="4" id="arrow-red" orient="auto" markerWidth="5" refX="0.1" refY="2">
       <path fill="red" d="M0,0 V4 L5,2 Z"></path>
      </marker>
      <marker markerHeight="4" id="arrow-blue" orient="auto" markerWidth="5" refX="0.1" refY="2">
       <path fill="blue" d="M0,0 V4 L5,2 Z"></path>
      </marker>
     </defs>

     
     <rect width="304" stroke-dasharray="6" stroke-width="1" fill="none" x="48" stroke="black" y="48" height="176"></rect>

     <line y2="20" stroke-width="2" marker-end="url(#arrow-blue)" stroke="blue" x1="200" x2="200" y1="48"></line>
     <line y2="136" stroke-width="2" marker-end="url(#arrow-blue)" stroke="blue" x1="48" x2="20" y1="136"></line>
     <line y2="136" stroke-width="2" marker-end="url(#arrow-blue)" stroke="blue" x1="352" x2="380" y1="136"></line>
     <line y2="250" stroke-width="2" marker-end="url(#arrow-blue)" stroke="blue" x1="200" x2="200" y1="224"></line>
     <text font-size="12" font-style="normal" font-family="sans-serif" fill="blue" x="210" y="35">fieldset's margin</text>

     
     <rect width="300" stroke-width="2" fill="white" stroke="blue" x="50" y="105" height="116.5"></rect>

     
     <rect width="85" stroke-width="2" fill="white" stroke="red" x="100" y="75" height="60"></rect>
     <text font-style="normal" font-family="serif" fill="red" x="120" y="105" dominant-baseline="central">legend</text>

     
     <rect width="65" stroke-width="18" fill="none" stroke="#eee" x="110" y="85" height="40"></rect>
     <text font-size="12" font-style="normal" font-family="sans-serif" fill="gray" x="133" y="88">padding</text>

     <line y2="90" stroke-width="2" marker-end="url(#arrow-red)" stroke="red" x1="185" x2="325" y1="90"></line>
     <text font-size="12" font-style="normal" font-family="sans-serif" fill="red" x="210" y="85">legend's margin</text>

     <line y2="90" stroke-width="2" marker-end="url(#arrow-red)" stroke="red" x1="100" x2="75" y1="90"></line>
     <line y2="60" stroke-width="2" marker-end="url(#arrow-red)" stroke="red" x1="143" x2="143" y1="75"></line>
     <line y2="150" stroke-width="2" marker-end="url(#arrow-red)" stroke="red" x1="143" x2="143" y1="135"></line>

     
     <rect width="280" stroke-width="18" fill="none" stroke="#eee" x="60" y="171" height="40"></rect>
     <text font-size="12" font-style="normal" font-family="sans-serif" fill="gray" x="297" y="174">padding</text>

     
     <rect width="296" stroke-dasharray="6" stroke-width="1" fill="none" x="52" stroke="black" y="161" height="58"></rect>
     <text font-style="normal" font-family="sans-serif" font-size="12" x="170" y="156">anonymous
     fieldset content box</text>
     <text font-style="normal" font-family="serif" fill="blue" x="70" y="191" dominant-baseline="central">content</text>

    </svg>

    <figcaption>The legend is rendered over the top border, and the top border area reserves
    vertical space for the legend. The fieldset's top margin starts at the top margin edge of the
    legend. The legend's horizontal margins, or the <a id="the-fieldset-and-legend-elements:'justify-self'-2" href="https://drafts.csswg.org/css-align/#propdef-justify-self" data-x-internal="'justify-self'">'justify-self'</a> property, gives
    its horizontal position. The <a href="#anonymous-fieldset-content-box" id="the-fieldset-and-legend-elements:anonymous-fieldset-content-box-5">anonymous fieldset content box</a> appears below the
    legend.</figcaption>
   </figure>
  </div>


  <h3 id="replaced-elements"><span class="secno">15.4</span> Replaced elements<a href="#replaced-elements" class="self-link"></a></h3>

  <p class="note">The following elements can be <a href="https://drafts.csswg.org/css-display/#replaced-element" id="replaced-elements:replaced-element" data-x-internal="replaced-element">replaced
  elements</a>: <code id="replaced-elements:the-audio-element"><a href="#the-audio-element">audio</a></code>, <code id="replaced-elements:the-canvas-element"><a href="#the-canvas-element">canvas</a></code>, <code id="replaced-elements:the-embed-element"><a href="#the-embed-element">embed</a></code>, <code id="replaced-elements:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>,
  <code id="replaced-elements:the-img-element"><a href="#the-img-element">img</a></code>, <code id="replaced-elements:the-input-element"><a href="#the-input-element">input</a></code>, <code id="replaced-elements:the-object-element"><a href="#the-object-element">object</a></code>, and <code id="replaced-elements:the-video-element"><a href="#the-video-element">video</a></code>.</p>


  <h4 id="embedded-content-rendering-rules"><span class="secno">15.4.1</span> Embedded content<a href="#embedded-content-rendering-rules" class="self-link"></a></h4>

  <p>The <code id="embedded-content-rendering-rules:the-embed-element"><a href="#the-embed-element">embed</a></code>, <code id="embedded-content-rendering-rules:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, and <code id="embedded-content-rendering-rules:the-video-element"><a href="#the-video-element">video</a></code> elements are
  <a href="#expected" id="embedded-content-rendering-rules:expected">expected</a> to be treated as <a href="https://drafts.csswg.org/css-display/#replaced-element" id="embedded-content-rendering-rules:replaced-element" data-x-internal="replaced-element">replaced
  elements</a>.</p>

  <p>A <code id="embedded-content-rendering-rules:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> element that <a href="#represents" id="embedded-content-rendering-rules:represents">represents</a> <a href="#embedded-content-category" id="embedded-content-rendering-rules:embedded-content-category">embedded content</a> is
  <a href="#expected" id="embedded-content-rendering-rules:expected-2">expected</a> to be treated as a <a id="embedded-content-rendering-rules:replaced-element-2" href="https://drafts.csswg.org/css-display/#replaced-element" data-x-internal="replaced-element">replaced element</a>; the contents of such
  elements are the element's bitmap, if any, or else a <a id="embedded-content-rendering-rules:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a> bitmap with
  the same <a id="embedded-content-rendering-rules:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> as the element. Other <code id="embedded-content-rendering-rules:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> elements are
  <a href="#expected" id="embedded-content-rendering-rules:expected-3">expected</a> to be treated as ordinary elements in the rendering model.</p>

  <p>An <code id="embedded-content-rendering-rules:the-object-element"><a href="#the-object-element">object</a></code> element that <a href="#represents" id="embedded-content-rendering-rules:represents-2">represents</a> an image, plugin, or its
  <a href="#content-navigable" id="embedded-content-rendering-rules:content-navigable">content navigable</a> is <a href="#expected" id="embedded-content-rendering-rules:expected-4">expected</a> to be treated as a <a id="embedded-content-rendering-rules:replaced-element-3" href="https://drafts.csswg.org/css-display/#replaced-element" data-x-internal="replaced-element">replaced
  element</a>. Other <code id="embedded-content-rendering-rules:the-object-element-2"><a href="#the-object-element">object</a></code> elements are <a href="#expected" id="embedded-content-rendering-rules:expected-5">expected</a> to be treated as
  ordinary elements in the rendering model.</p>

  <p>The <code id="embedded-content-rendering-rules:the-audio-element"><a href="#the-audio-element">audio</a></code> element, when it is <a href="#expose-a-user-interface-to-the-user" id="embedded-content-rendering-rules:expose-a-user-interface-to-the-user">exposing a user interface</a>, is <a href="#expected" id="embedded-content-rendering-rules:expected-6">expected</a> to be treated as a
  <a id="embedded-content-rendering-rules:replaced-element-4" href="https://drafts.csswg.org/css-display/#replaced-element" data-x-internal="replaced-element">replaced element</a> about one line high, as wide as is necessary to expose the user
  agent's user interface features. When an <code id="embedded-content-rendering-rules:the-audio-element-2"><a href="#the-audio-element">audio</a></code> element is not <a href="#expose-a-user-interface-to-the-user" id="embedded-content-rendering-rules:expose-a-user-interface-to-the-user-2">exposing a user interface</a>, the user agent is
  <a href="#expected" id="embedded-content-rendering-rules:expected-7">expected</a> to force its <a id="embedded-content-rendering-rules:'display'" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property to compute to 'none',
  irrespective of CSS rules.</p>

  <p>Whether a <code id="embedded-content-rendering-rules:the-video-element-2"><a href="#the-video-element">video</a></code> element is <a href="#expose-a-user-interface-to-the-user" id="embedded-content-rendering-rules:expose-a-user-interface-to-the-user-3">exposing a user interface</a> is not <a href="#expected" id="embedded-content-rendering-rules:expected-8">expected</a> to affect the size of the
  rendering; controls are <a href="#expected" id="embedded-content-rendering-rules:expected-9">expected</a> to be overlaid above the page content without
  causing any layout changes, and are <a href="#expected" id="embedded-content-rendering-rules:expected-10">expected</a> to disappear when the user does not
  need them.</p>

  <p>When a <code id="embedded-content-rendering-rules:the-video-element-3"><a href="#the-video-element">video</a></code> element represents a poster frame or frame of video, the poster frame
  or frame of video is <a href="#expected" id="embedded-content-rendering-rules:expected-11">expected</a> to be rendered at the largest size that maintains the
  aspect ratio of that poster frame or frame of video without being taller or wider than the
  <code id="embedded-content-rendering-rules:the-video-element-4"><a href="#the-video-element">video</a></code> element itself, and is <a href="#expected" id="embedded-content-rendering-rules:expected-12">expected</a> to be centered in the
  <code id="embedded-content-rendering-rules:the-video-element-5"><a href="#the-video-element">video</a></code> element.</p>

  <p>Any subtitles or captions are <a href="#expected" id="embedded-content-rendering-rules:expected-13">expected</a> to be overlaid directly on top of their
  <code id="embedded-content-rendering-rules:the-video-element-6"><a href="#the-video-element">video</a></code> element, as defined by the relevant rendering rules; for WebVTT, those are the
  <a id="embedded-content-rendering-rules:rules-for-updating-the-display-of-webvtt-text-tracks" href="https://w3c.github.io/webvtt/#rules-for-updating-the-display-of-webvtt-text-tracks" data-x-internal="rules-for-updating-the-display-of-webvtt-text-tracks">rules for updating the display of WebVTT text tracks</a>. <a href="#refsWEBVTT">[WEBVTT]</a></p>

  <p>When the user agent starts <a href="#expose-a-user-interface-to-the-user" id="embedded-content-rendering-rules:expose-a-user-interface-to-the-user-4">exposing a user
  interface</a> for a <code id="embedded-content-rendering-rules:the-video-element-7"><a href="#the-video-element">video</a></code> element, the user agent should run the <a href="#rules-for-updating-the-text-track-rendering" id="embedded-content-rendering-rules:rules-for-updating-the-text-track-rendering">rules for
  updating the text track rendering</a> of each of the <a href="#text-track" id="embedded-content-rendering-rules:text-track">text
  tracks</a> in the <code id="embedded-content-rendering-rules:the-video-element-8"><a href="#the-video-element">video</a></code> element's <a href="#list-of-text-tracks" id="embedded-content-rendering-rules:list-of-text-tracks">list of text tracks</a> that are <a href="#text-track-showing" id="embedded-content-rendering-rules:text-track-showing">showing</a> and whose <a href="#text-track-kind" id="embedded-content-rendering-rules:text-track-kind">text track kind</a> is one of <code id="embedded-content-rendering-rules:dom-texttrack-kind-subtitles"><a href="#dom-texttrack-kind-subtitles">subtitles</a></code> or <code id="embedded-content-rendering-rules:dom-texttrack-kind-captions"><a href="#dom-texttrack-kind-captions">captions</a></code> (e.g., for <a href="#text-track" id="embedded-content-rendering-rules:text-track-2">text
  tracks</a> based on WebVTT, the <a id="embedded-content-rendering-rules:rules-for-updating-the-display-of-webvtt-text-tracks-2" href="https://w3c.github.io/webvtt/#rules-for-updating-the-display-of-webvtt-text-tracks" data-x-internal="rules-for-updating-the-display-of-webvtt-text-tracks">rules for updating the display of WebVTT text
  tracks</a>). <a href="#refsWEBVTT">[WEBVTT]</a></p>

  <p class="note">Resizing <code id="embedded-content-rendering-rules:the-video-element-9"><a href="#the-video-element">video</a></code> and <code id="embedded-content-rendering-rules:the-canvas-element-3"><a href="#the-canvas-element">canvas</a></code> elements does not interrupt
  video playback or clear the canvas.</p>

  <hr>

  <p>The following CSS rules are <a href="#expected" id="embedded-content-rendering-rules:expected-14">expected</a> to apply:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">iframe </c-><c- p="">{</c-> <c- k="">border</c-><c- p="">:</c-> <c- m="">2</c-><c- l="">px</c-> inset<c- p="">;</c-> <c- p="">}</c->
<span id="video-object-fit"><c- f="">video </c-><c- p="">{</c-> <c- k="">object-fit</c-><c- p="">:</c-> contain<c- p="">;</c-> <c- p="">}</c-></span></code></pre>


  <h4 id="images-3"><span class="secno">15.4.2</span> Images<a href="#images-3" class="self-link"></a></h4>

  <p>User agents are <a href="#expected" id="images-3:expected">expected</a> to render <code id="images-3:the-img-element"><a href="#the-img-element">img</a></code> elements and
  <code id="images-3:the-input-element"><a href="#the-input-element">input</a></code> elements whose <code id="images-3:attr-input-type"><a href="#attr-input-type">type</a></code> attributes are in
  the <a href="#image-button-state-(type=image)" id="images-3:image-button-state-(type=image)">Image Button</a> state, according to the first
  applicable rules from the following list:</p>

  <dl class="switch"><dt>If the element <a href="#represents" id="images-3:represents">represents</a> an image</dt><dd>The user agent is <a href="#expected" id="images-3:expected-2">expected</a> to treat the element as a <a id="images-3:replaced-element" href="https://drafts.csswg.org/css-display/#replaced-element" data-x-internal="replaced-element">replaced
   element</a> and render the image according to the rules for doing so defined in CSS.</dd><dt>

    If the element does not <a href="#represents" id="images-3:represents-2">represent</a> an image and either:

    <ul><li>the user agent has reason to believe that the image will become <i id="images-3:img-available"><a href="#img-available">available</a></i> and be rendered in due
     course, or

     </li><li>the element has no <code>alt</code> attribute, or

     </li><li>the <code id="images-3:document"><a href="#document">Document</a></code> is in <a id="images-3:quirks-mode" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>, and the element already has
     <a id="images-3:natural-dimensions" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> (e.g., from the <a href="#dimension-attributes" id="images-3:dimension-attributes">dimension attributes</a> or CSS
     rules)
    </li></ul>

   </dt><dd>The user agent is <a href="#expected" id="images-3:expected-3">expected</a> to treat the element as a <a id="images-3:replaced-element-2" href="https://drafts.csswg.org/css-display/#replaced-element" data-x-internal="replaced-element">replaced
   element</a> whose content is the text that the element represents, if any, optionally
   alongside an icon indicating that the image is being obtained (if applicable). For
   <code id="images-3:the-input-element-2"><a href="#the-input-element">input</a></code> elements, the element is <a href="#expected" id="images-3:expected-4">expected</a> to appear button-like to
   indicate that the element is a <a href="#concept-button" id="images-3:concept-button">button</a>.</dd><dt>If the element is an <code id="images-3:the-img-element-2"><a href="#the-img-element">img</a></code> element that <a href="#represents" id="images-3:represents-3">represents</a> some text and the
   user agent does not expect this to change</dt><dd>The user agent is <a href="#expected" id="images-3:expected-5">expected</a> to treat the element as a non-replaced phrasing
   element whose content is the text, optionally with an icon indicating that an image is missing,
   so that the user can request the image be displayed or investigate why it is not rendering. In
   non-graphical contexts, such an icon should be omitted.</dd><dt>If the element is an <code id="images-3:the-img-element-3"><a href="#the-img-element">img</a></code> element that <a href="#represents" id="images-3:represents-4">represents</a> nothing and the
   user agent does not expect this to change</dt><dd>The user agent is <a href="#expected" id="images-3:expected-6">expected</a> to treat the element as a <a id="images-3:replaced-element-3" href="https://drafts.csswg.org/css-display/#replaced-element" data-x-internal="replaced-element">replaced
   element</a> whose <a id="images-3:natural-dimensions-2" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> are 0. (In the absence of further styles,
   this will cause the element to essentially not be rendered.)</dd><dt>If the element is an <code id="images-3:the-input-element-3"><a href="#the-input-element">input</a></code> element that does not <a href="#represents" id="images-3:represents-5">represent</a> an image and the user agent does not expect this to change</dt><dd>The user agent is <a href="#expected" id="images-3:expected-7">expected</a> to treat the element as a <a id="images-3:replaced-element-4" href="https://drafts.csswg.org/css-display/#replaced-element" data-x-internal="replaced-element">replaced
   element</a> consisting of a button whose content is the element's alternative text. The
   <a id="images-3:natural-dimensions-3" href="https://drafts.csswg.org/css-images/#natural-dimensions" data-x-internal="natural-dimensions">natural dimensions</a> of the button are <a href="#expected" id="images-3:expected-8">expected</a> to be about one line in
   height and whatever width is necessary to render the text on one line.</dd></dl>

  <p>The icons mentioned above are <a href="#expected" id="images-3:expected-9">expected</a> to be relatively small so as not to
  disrupt most text but be easily clickable. In a visual environment, for instance, icons could be
  16 pixels by 16 pixels square, or 1em by 1em if the images are scalable. In an audio environment,
  the icon could be a short bleep. The icons are intended to indicate to the user that they can be
  used to get to whatever options the UA provides for images, and, where appropriate, are
  <a href="#expected" id="images-3:expected-10">expected</a> to provide access to the context menu that would have come up if the user
  interacted with the actual image.</p>

  <hr>

  <p>All animated images with the same <a id="images-3:absolute-url" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a> and the same image data are
  <a href="#expected" id="images-3:expected-11">expected</a> to be rendered synchronized to the same timeline as a group, with the
  timeline starting at the time of the least recent addition to the group.</p>

  <p class="note">In other words, when a second image with the same <a id="images-3:absolute-url-2" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a> and
  animated image data is inserted into a document, it jumps to the point in the animation cycle that
  is currently being displayed by the first image.</p>

  <div data-algorithm="">
  <p>When a user agent is to <dfn id="restart-the-animation">restart the animation</dfn> for an <code id="images-3:the-img-element-4"><a href="#the-img-element">img</a></code> element
  showing an animated image, all animated images with the same <a id="images-3:absolute-url-3" href="https://url.spec.whatwg.org/#syntax-url-absolute" data-x-internal="absolute-url">absolute URL</a> and the
  same image data in that <code id="images-3:the-img-element-5"><a href="#the-img-element">img</a></code> element's <a id="images-3:node-document" href="https://dom.spec.whatwg.org/#concept-node-document" data-x-internal="node-document">node document</a> are
  <a href="#expected" id="images-3:expected-12">expected</a> to restart their animation from the beginning.</p>
  </div>

  <hr>

  <p>The following CSS rules are <a href="#expected" id="images-3:expected-13">expected</a> to apply:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<span id="img-contain-size"><c- f="">img:is([sizes="auto" i], [sizes^="auto," i]) </c-><c- p="">{</c->
  <c- k="">contain</c-><c- p="">:</c-> size !important;
  contain-intrinsic-size: 300px 150px;
}</span></code></pre>

  <p>The following CSS rules are <a href="#expected" id="images-3:expected-14">expected</a> to apply when the <code id="images-3:document-2"><a href="#document">Document</a></code> is
  in <a id="images-3:quirks-mode-2" href="https://dom.spec.whatwg.org/#concept-document-quirks" data-x-internal="quirks-mode">quirks mode</a>:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">img[align=left i] </c-><c- p="">{</c-> <c- k="">margin-right</c-><c- p="">:</c-> <c- m="">3</c-><c- l="">px</c-><c- p="">;</c-> <c- p="">}</c->
<c- f="">img[align=right i] </c-><c- p="">{</c-> <c- k="">margin-left</c-><c- p="">:</c-> <c- m="">3</c-><c- l="">px</c-><c- p="">;</c-> <c- p="">}</c-></code></pre>

  


  

  <h4 id="attributes-for-embedded-content-and-images"><span class="secno">15.4.3</span> Attributes for embedded content and images<a href="#attributes-for-embedded-content-and-images" class="self-link"></a></h4>

  <p>The following CSS rules are <a href="#expected" id="attributes-for-embedded-content-and-images:expected">expected</a> to apply as <a href="#presentational-hints" id="attributes-for-embedded-content-and-images:presentational-hints">presentational
  hints</a>:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">embed[align=left i], iframe[align=left i], img[align=left i],</c->
<c- f="">input[type=image i][align=left i], object[align=left i] </c-><c- p="">{</c->
  <c- k="">float</c-><c- p="">:</c-> left<c- p="">;</c->
<c- p="">}</c->

<c- f="">embed[align=right i], iframe[align=right i], img[align=right i],</c->
<c- f="">input[type=image i][align=right i], object[align=right i] </c-><c- p="">{</c->
  <c- k="">float</c-><c- p="">:</c-> right<c- p="">;</c->
<c- p="">}</c->

<c- f="">embed[align=top i], iframe[align=top i], img[align=top i],</c->
<c- f="">input[type=image i][align=top i], object[align=top i] </c-><c- p="">{</c->
  <c- k="">vertical-align</c-><c- p="">:</c-> top<c- p="">;</c->
<c- p="">}</c->

<c- f="">embed[align=baseline i], iframe[align=baseline i], img[align=baseline i],</c->
<c- f="">input[type=image i][align=baseline i], object[align=baseline i] </c-><c- p="">{</c->
  <c- k="">vertical-align</c-><c- p="">:</c-> baseline<c- p="">;</c->
<c- p="">}</c->

<c- f="">embed[align=texttop i], iframe[align=texttop i], img[align=texttop i],</c->
<c- f="">input[type=image i][align=texttop i], object[align=texttop i] </c-><c- p="">{</c->
  <c- k="">vertical-align</c-><c- p="">:</c-> text-top<c- p="">;</c->
<c- p="">}</c->

<c- f="">embed[align=absmiddle i], iframe[align=absmiddle i], img[align=absmiddle i],</c->
<c- f="">input[type=image i][align=absmiddle i], object[align=absmiddle i],</c->
<c- f="">embed[align=abscenter i], iframe[align=abscenter i], img[align=abscenter i],</c->
<c- f="">input[type=image i][align=abscenter i], object[align=abscenter i] </c-><c- p="">{</c->
  <c- k="">vertical-align</c-><c- p="">:</c-> middle<c- p="">;</c->
<c- p="">}</c->

<c- f="">embed[align=bottom i], iframe[align=bottom i], img[align=bottom i],</c->
<c- f="">input[type=image i][align=bottom i], object[align=bottom i] </c-><c- p="">{</c->
  <c- k="">vertical-align</c-><c- p="">:</c-> bottom<c- p="">;</c->
<c- p="">}</c-></code></pre>

  <p>When an <code id="attributes-for-embedded-content-and-images:the-embed-element"><a href="#the-embed-element">embed</a></code>, <code id="attributes-for-embedded-content-and-images:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>, <code id="attributes-for-embedded-content-and-images:the-img-element"><a href="#the-img-element">img</a></code>, or <code id="attributes-for-embedded-content-and-images:the-object-element"><a href="#the-object-element">object</a></code>
  element, or an <code id="attributes-for-embedded-content-and-images:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="attributes-for-embedded-content-and-images:attr-input-type"><a href="#attr-input-type">type</a></code>
  attribute is in the <a href="#image-button-state-(type=image)" id="attributes-for-embedded-content-and-images:image-button-state-(type=image)">Image Button</a> state, has an <code>align</code> attribute whose value is an <a id="attributes-for-embedded-content-and-images:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
  the string "<code>center</code>" or the string "<code>middle</code>", the user
  agent is <a href="#expected" id="attributes-for-embedded-content-and-images:expected-2">expected</a> to act as if the element's <a id="attributes-for-embedded-content-and-images:'vertical-align'" href="https://drafts.csswg.org/css2/#propdef-vertical-align" data-x-internal="'vertical-align'">'vertical-align'</a> property
  was set to a value that aligns the vertical middle of the element with the parent element's
  baseline.</p>

  <p>The <code>hspace</code> attribute of <code id="attributes-for-embedded-content-and-images:the-embed-element-2"><a href="#the-embed-element">embed</a></code>,
  <code id="attributes-for-embedded-content-and-images:the-img-element-2"><a href="#the-img-element">img</a></code>, or <code id="attributes-for-embedded-content-and-images:the-object-element-2"><a href="#the-object-element">object</a></code> elements, and <code id="attributes-for-embedded-content-and-images:the-input-element-2"><a href="#the-input-element">input</a></code> elements with a <code id="attributes-for-embedded-content-and-images:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute in the <a href="#image-button-state-(type=image)" id="attributes-for-embedded-content-and-images:image-button-state-(type=image)-2">Image
  Button</a> state, <a href="#maps-to-the-dimension-property" id="attributes-for-embedded-content-and-images:maps-to-the-dimension-property">maps to the dimension
  properties</a> <a id="attributes-for-embedded-content-and-images:'margin-left'" href="https://drafts.csswg.org/css-box/#propdef-margin-left" data-x-internal="'margin-left'">'margin-left'</a> and <a id="attributes-for-embedded-content-and-images:'margin-right'" href="https://drafts.csswg.org/css-box/#propdef-margin-right" data-x-internal="'margin-right'">'margin-right'</a> on the element.</p>

  <p>The <code>vspace</code> attribute of <code id="attributes-for-embedded-content-and-images:the-embed-element-3"><a href="#the-embed-element">embed</a></code>,
  <code id="attributes-for-embedded-content-and-images:the-img-element-3"><a href="#the-img-element">img</a></code>, or <code id="attributes-for-embedded-content-and-images:the-object-element-3"><a href="#the-object-element">object</a></code> elements, and <code id="attributes-for-embedded-content-and-images:the-input-element-3"><a href="#the-input-element">input</a></code> elements with a <code id="attributes-for-embedded-content-and-images:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute in the <a href="#image-button-state-(type=image)" id="attributes-for-embedded-content-and-images:image-button-state-(type=image)-3">Image
  Button</a> state, <a href="#maps-to-the-dimension-property" id="attributes-for-embedded-content-and-images:maps-to-the-dimension-property-2">maps to the dimension
  properties</a> <a id="attributes-for-embedded-content-and-images:'margin-top'" href="https://drafts.csswg.org/css-box/#propdef-margin-top" data-x-internal="'margin-top'">'margin-top'</a> and <a id="attributes-for-embedded-content-and-images:'margin-bottom'" href="https://drafts.csswg.org/css-box/#propdef-margin-bottom" data-x-internal="'margin-bottom'">'margin-bottom'</a> on the element.</p>

  <p>When an <code id="attributes-for-embedded-content-and-images:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> element has a <code id="attributes-for-embedded-content-and-images:attr-iframe-frameborder"><a href="#attr-iframe-frameborder">frameborder</a></code> attribute whose value, when parsed using the
  <a href="#rules-for-parsing-integers" id="attributes-for-embedded-content-and-images:rules-for-parsing-integers">rules for parsing integers</a>, is zero or an error, the user agent is
  <a href="#expected" id="attributes-for-embedded-content-and-images:expected-3">expected</a> to have <a href="#presentational-hints" id="attributes-for-embedded-content-and-images:presentational-hints-2">presentational hints</a> setting the element's
  <a id="attributes-for-embedded-content-and-images:'border-top-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-width" data-x-internal="'border-top-width'">'border-top-width'</a>, <a id="attributes-for-embedded-content-and-images:'border-right-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-right-width" data-x-internal="'border-right-width'">'border-right-width'</a>,
  <a id="attributes-for-embedded-content-and-images:'border-bottom-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-width" data-x-internal="'border-bottom-width'">'border-bottom-width'</a>, and <a id="attributes-for-embedded-content-and-images:'border-left-width'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-left-width" data-x-internal="'border-left-width'">'border-left-width'</a> properties to zero.</p>

  <p>When an <code id="attributes-for-embedded-content-and-images:the-img-element-4"><a href="#the-img-element">img</a></code> element, <code id="attributes-for-embedded-content-and-images:the-object-element-4"><a href="#the-object-element">object</a></code> element, or <code id="attributes-for-embedded-content-and-images:the-input-element-4"><a href="#the-input-element">input</a></code> element
  with a <code id="attributes-for-embedded-content-and-images:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute in the <a href="#image-button-state-(type=image)" id="attributes-for-embedded-content-and-images:image-button-state-(type=image)-4">Image Button</a> state has a <code>border</code> attribute whose value, when parsed using the <a href="#rules-for-parsing-non-negative-integers" id="attributes-for-embedded-content-and-images:rules-for-parsing-non-negative-integers">rules for
  parsing non-negative integers</a>, is found to be a number greater than zero, the user agent is
  <a href="#expected" id="attributes-for-embedded-content-and-images:expected-4">expected</a> to use the parsed value for eight <a href="#presentational-hints" id="attributes-for-embedded-content-and-images:presentational-hints-3">presentational hints</a>: four
  setting the parsed value as a pixel length for the element's <a id="attributes-for-embedded-content-and-images:'border-top-width'-2" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-width" data-x-internal="'border-top-width'">'border-top-width'</a>,
  <a id="attributes-for-embedded-content-and-images:'border-right-width'-2" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-right-width" data-x-internal="'border-right-width'">'border-right-width'</a>, <a id="attributes-for-embedded-content-and-images:'border-bottom-width'-2" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-width" data-x-internal="'border-bottom-width'">'border-bottom-width'</a>, and
  <a id="attributes-for-embedded-content-and-images:'border-left-width'-2" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-left-width" data-x-internal="'border-left-width'">'border-left-width'</a> properties, and four setting the element's
  <a id="attributes-for-embedded-content-and-images:'border-top-style'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-top-style" data-x-internal="'border-top-style'">'border-top-style'</a>, <a id="attributes-for-embedded-content-and-images:'border-right-style'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-right-style" data-x-internal="'border-right-style'">'border-right-style'</a>,
  <a id="attributes-for-embedded-content-and-images:'border-bottom-style'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-bottom-style" data-x-internal="'border-bottom-style'">'border-bottom-style'</a>, and <a id="attributes-for-embedded-content-and-images:'border-left-style'" href="https://drafts.csswg.org/css-backgrounds/#propdef-border-left-style" data-x-internal="'border-left-style'">'border-left-style'</a> properties to the value
  'solid'.</p>

  <p id="dimRendering">The <code id="attributes-for-embedded-content-and-images:attr-dim-width"><a href="#attr-dim-width">width</a></code> and <code id="attributes-for-embedded-content-and-images:attr-dim-height"><a href="#attr-dim-height">height</a></code> attributes on an <code id="attributes-for-embedded-content-and-images:the-img-element-5"><a href="#the-img-element">img</a></code> element's <a href="#concept-img-dimension-attribute-source" id="attributes-for-embedded-content-and-images:concept-img-dimension-attribute-source">dimension attribute source</a> <a href="#maps-to-the-dimension-property" id="attributes-for-embedded-content-and-images:maps-to-the-dimension-property-3">map to the dimension properties</a>
  <a id="attributes-for-embedded-content-and-images:'width'" href="https://drafts.csswg.org/css2/#the-width-property" data-x-internal="'width'">'width'</a> and <a id="attributes-for-embedded-content-and-images:'height'" href="https://drafts.csswg.org/css2/#the-height-property" data-x-internal="'height'">'height'</a> on the <code id="attributes-for-embedded-content-and-images:the-img-element-6"><a href="#the-img-element">img</a></code> element respectively. They
  similarly <a href="#map-to-the-aspect-ratio-property-(using-dimension-rules)" id="attributes-for-embedded-content-and-images:map-to-the-aspect-ratio-property-(using-dimension-rules)">map to the aspect-ratio property (using dimension rules)</a> of the
  <code id="attributes-for-embedded-content-and-images:the-img-element-7"><a href="#the-img-element">img</a></code> element.</p>

  <p>The <code id="attributes-for-embedded-content-and-images:attr-dim-width-2"><a href="#attr-dim-width">width</a></code> and <code id="attributes-for-embedded-content-and-images:attr-dim-height-2"><a href="#attr-dim-height">height</a></code>
  attributes on <code id="attributes-for-embedded-content-and-images:the-embed-element-4"><a href="#the-embed-element">embed</a></code>, <code id="attributes-for-embedded-content-and-images:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code>, <code id="attributes-for-embedded-content-and-images:the-object-element-5"><a href="#the-object-element">object</a></code>, and <code id="attributes-for-embedded-content-and-images:the-video-element"><a href="#the-video-element">video</a></code>
  elements, and <code id="attributes-for-embedded-content-and-images:the-input-element-5"><a href="#the-input-element">input</a></code> elements with a <code id="attributes-for-embedded-content-and-images:attr-input-type-5"><a href="#attr-input-type">type</a></code>
  attribute in the <a href="#image-button-state-(type=image)" id="attributes-for-embedded-content-and-images:image-button-state-(type=image)-5">Image Button</a> state and that either
  represents an image or that the user expects will eventually represent an image, <a href="#maps-to-the-dimension-property" id="attributes-for-embedded-content-and-images:maps-to-the-dimension-property-4">map to the dimension properties</a>
  <a id="attributes-for-embedded-content-and-images:'width'-2" href="https://drafts.csswg.org/css2/#the-width-property" data-x-internal="'width'">'width'</a> and <a id="attributes-for-embedded-content-and-images:'height'-2" href="https://drafts.csswg.org/css2/#the-height-property" data-x-internal="'height'">'height'</a> on the element respectively.</p>

  <p>The <code id="attributes-for-embedded-content-and-images:attr-dim-width-3"><a href="#attr-dim-width">width</a></code> and <code id="attributes-for-embedded-content-and-images:attr-dim-height-3"><a href="#attr-dim-height">height</a></code>
  attributes <a href="#map-to-the-aspect-ratio-property-(using-dimension-rules)" id="attributes-for-embedded-content-and-images:map-to-the-aspect-ratio-property-(using-dimension-rules)-2">map to the aspect-ratio property (using dimension rules)</a> on
  <code id="attributes-for-embedded-content-and-images:the-img-element-8"><a href="#the-img-element">img</a></code> and <code id="attributes-for-embedded-content-and-images:the-video-element-2"><a href="#the-video-element">video</a></code> elements, and <code id="attributes-for-embedded-content-and-images:the-input-element-6"><a href="#the-input-element">input</a></code> elements with a <code id="attributes-for-embedded-content-and-images:attr-input-type-6"><a href="#attr-input-type">type</a></code> attribute in the <a href="#image-button-state-(type=image)" id="attributes-for-embedded-content-and-images:image-button-state-(type=image)-6">Image
  Button</a> state.</p>

  <p>The <code id="attributes-for-embedded-content-and-images:attr-canvas-width"><a href="#attr-canvas-width">width</a></code> and <code id="attributes-for-embedded-content-and-images:attr-canvas-height"><a href="#attr-canvas-height">height</a></code> attributes <a href="#map-to-the-aspect-ratio-property" id="attributes-for-embedded-content-and-images:map-to-the-aspect-ratio-property">map to the aspect-ratio property</a>
  on <code id="attributes-for-embedded-content-and-images:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> elements.</p>
  


  

  <h4 id="image-maps-2"><span class="secno">15.4.4</span> Image maps<a href="#image-maps-2" class="self-link"></a></h4>

  <p>Shapes on an <a href="#image-map" id="image-maps-2:image-map">image map</a> are <a href="#expected" id="image-maps-2:expected">expected</a> to act, for the purpose of the
  CSS cascade, as elements independent of the original <code id="image-maps-2:the-area-element"><a href="#the-area-element">area</a></code> element that happen to
  match the same style rules but inherit from the <code id="image-maps-2:the-img-element"><a href="#the-img-element">img</a></code> or <code id="image-maps-2:the-object-element"><a href="#the-object-element">object</a></code>
  element.</p>

  <p>For the purposes of the rendering, only the <a id="image-maps-2:'cursor'" href="https://drafts.csswg.org/css-ui/#cursor" data-x-internal="'cursor'">'cursor'</a> property is
  <a href="#expected" id="image-maps-2:expected-2">expected</a> to have any effect on the shape.</p>

  <p class="example">Thus, for example, if an <code id="image-maps-2:the-area-element-2"><a href="#the-area-element">area</a></code> element has a <code id="image-maps-2:attr-style"><a href="#attr-style">style</a></code> attribute that sets the <a id="image-maps-2:'cursor'-2" href="https://drafts.csswg.org/css-ui/#cursor" data-x-internal="'cursor'">'cursor'</a> property to 'help',
  then when the user designates that shape, the cursor would change to a Help cursor.</p>

  <p class="example">Similarly, if an <code id="image-maps-2:the-area-element-3"><a href="#the-area-element">area</a></code> element had a CSS rule that set its
  <a id="image-maps-2:'cursor'-3" href="https://drafts.csswg.org/css-ui/#cursor" data-x-internal="'cursor'">'cursor'</a> property to 'inherit' (or if no rule setting the <a id="image-maps-2:'cursor'-4" href="https://drafts.csswg.org/css-ui/#cursor" data-x-internal="'cursor'">'cursor'</a>
  property matched the element at all), the shape's cursor would be inherited from the
  <code id="image-maps-2:the-img-element-2"><a href="#the-img-element">img</a></code> or <code id="image-maps-2:the-object-element-2"><a href="#the-object-element">object</a></code> element of the <a href="#image-map" id="image-maps-2:image-map-2">image map</a>, not from the parent
  of the <code id="image-maps-2:the-area-element-4"><a href="#the-area-element">area</a></code> element.</p>

  


  

  <h3 id="widgets"><span class="secno">15.5</span> <span id="bindings"></span>Widgets<a href="#widgets" class="self-link"></a></h3>

  <h4 id="native-appearance-2"><span class="secno">15.5.1</span> Native appearance<a href="#native-appearance-2" class="self-link"></a></h4>

  <p>The <cite>CSS Basic User Interface</cite> specification calls elements that can have a
  <a id="native-appearance-2:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> <a href="https://drafts.csswg.org/css-ui/#widget" id="native-appearance-2:widget" data-x-internal="widget">widgets</a>, and defines whether to use that <a id="native-appearance-2:native-appearance-2" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native
  appearance</a> depending on the <a id="native-appearance-2:'appearance'" href="https://drafts.csswg.org/css-ui/#appearance-switching" data-x-internal="'appearance'">'appearance'</a> property. That logic, in
  turn, depends on whether each the element is classified as a <a id="native-appearance-2:devolvable-widget" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable
  widget</a> or <a id="native-appearance-2:non-devolvable-widget" href="https://drafts.csswg.org/css-ui/#non-devolvable" data-x-internal="non-devolvable-widget">non-devolvable widget</a>. This section defines which elements match
  these concepts for HTML, what their <a id="native-appearance-2:native-appearance-3" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> is, and any particularity of
  their <a href="https://drafts.csswg.org/css-ui/#devolved" id="native-appearance-2:devolved-widget" data-x-internal="devolved-widget">devolved</a> state or <a id="native-appearance-2:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive appearance</a>.
  <a href="#refsCSSUI">[CSSUI]</a></p>

  <p>The following elements can have a <a id="native-appearance-2:native-appearance-4" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> for the purpose of the CSS
  <a id="native-appearance-2:'appearance'-2" href="https://drafts.csswg.org/css-ui/#appearance-switching" data-x-internal="'appearance'">'appearance'</a> property.</p>

  <ul class="brief"><li><code id="native-appearance-2:the-button-element"><a href="#the-button-element">button</a></code></li><li><code id="native-appearance-2:the-input-element"><a href="#the-input-element">input</a></code></li><li><code id="native-appearance-2:the-meter-element"><a href="#the-meter-element">meter</a></code></li><li><code id="native-appearance-2:the-progress-element"><a href="#the-progress-element">progress</a></code></li><li><code id="native-appearance-2:the-select-element"><a href="#the-select-element">select</a></code></li><li><code id="native-appearance-2:the-textarea-element"><a href="#the-textarea-element">textarea</a></code></li></ul>

  


  

  <h4 id="writing-mode"><span class="secno">15.5.2</span> Writing mode<a href="#writing-mode" class="self-link"></a></h4>

  <p>Several widgets have their rendering controlled by the <a id="writing-mode:'writing-mode'" href="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode" data-x-internal="'writing-mode'">'writing-mode'</a> CSS
  property. For the purposes of those widgets, we have the following definitions.</p>

  <div data-algorithm="">
  <p>A <dfn id="horizontal-writing-mode">horizontal writing mode</dfn> is when resolving the <a id="writing-mode:'writing-mode'-2" href="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode" data-x-internal="'writing-mode'">'writing-mode'</a>
  property of the control results in a computed value of 'horizontal-tb'.</p>
  </div>

  <div data-algorithm="">
  <p>A <dfn id="vertical-writing-mode">vertical writing mode</dfn> is when resolving the <a id="writing-mode:'writing-mode'-3" href="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode" data-x-internal="'writing-mode'">'writing-mode'</a> property
  of the control results in a computed value of either 'vertical-rl', 'vertical-lr', 'sideways-rl'
  or 'sideways-lr'.</p>
  </div>

  


  

  <h4 id="button-layout"><span class="secno">15.5.3</span> Button layout<a href="#button-layout" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>When an element uses <a href="#button-layout-2" id="button-layout:button-layout-2">button layout</a>, it is a <a id="button-layout:devolvable-widget" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>, and
  its <a id="button-layout:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> is that of a button.</p>
  </div>

  <div data-algorithm="">
  <p><dfn id="button-layout-2">Button layout</dfn> is as follows:</p>

  <ul><li>
    <p>If the element is a <code id="button-layout:the-button-element"><a href="#the-button-element">button</a></code> element, then the <a id="button-layout:'display'" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> property is
    <a href="#expected" id="button-layout:expected">expected</a> to act as follows:</p>

    <ul><li><p>If the computed value of <a id="button-layout:'display'-2" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> is 'inline-grid', 'grid',
     'inline-flex', 'flex', 'none', or 'contents', then behave as the computed value.</p></li><li><p>Otherwise, if the computed value of <a id="button-layout:'display'-3" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> is a value such that the
     <a id="button-layout:outer-display-type" href="https://drafts.csswg.org/css-display/#outer-display-type" data-x-internal="outer-display-type">outer display type</a> is 'inline', then behave as 'inline-block'.</p></li><li><p>Otherwise, behave as 'flow-root'.</p></li></ul>
   </li><li><p>The element is <a href="#expected" id="button-layout:expected-2">expected</a> to establish a new <a id="button-layout:formatting-context" href="https://drafts.csswg.org/css-display/#formatting-context" data-x-internal="formatting-context">formatting context</a>
   for its contents. The type of this formatting context is determined by its
   <a id="button-layout:'display'-4" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> value, as usual.</p></li><li><p>If the element is <a id="button-layout:absolutely-positioned" href="https://drafts.csswg.org/css-position/#absolute-position" data-x-internal="absolutely-positioned">absolutely-positioned</a>, then for the purpose of the
   <a href="https://drafts.csswg.org/css2/#visuren">CSS visual formatting model</a>, act as if
   the element is a <a id="button-layout:replaced-element" href="https://drafts.csswg.org/css-display/#replaced-element" data-x-internal="replaced-element">replaced element</a>. <a href="#refsCSS">[CSS]</a></p></li><li><p>If the <a id="button-layout:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of <a id="button-layout:'inline-size'" href="https://drafts.csswg.org/css-logical/#propdef-inline-size" data-x-internal="'inline-size'">'inline-size'</a> is 'auto', then the
   <a id="button-layout:used-value" href="https://drafts.csswg.org/css-cascade/#used-value" data-x-internal="used-value">used value</a> is the <a id="button-layout:fit-content-inline-size" href="https://drafts.csswg.org/css-sizing/#fit-content-inline-size" data-x-internal="fit-content-inline-size">fit-content inline size</a>.</p></li><li><p>For the purpose of the 'normal' keyword of the <a id="button-layout:'align-self'" href="https://drafts.csswg.org/css-align/#propdef-align-self" data-x-internal="'align-self'">'align-self'</a> property, act
   as if the element is a replaced element.</p></li><li>
    <p>If the element is an <code id="button-layout:the-input-element"><a href="#the-input-element">input</a></code> element, or if it is a <code id="button-layout:the-button-element-2"><a href="#the-button-element">button</a></code> element
    and its computed value for <a id="button-layout:'display'-5" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> is not 'inline-grid', 'grid', 'inline-flex',
    or 'flex', then the element's box has a child <dfn id="anonymous-button-content-box">anonymous button content box</dfn> with the
    following behaviors:</p>

    <ul><li><p>The box is a <a id="button-layout:block-level" href="https://drafts.csswg.org/css-display/#block-level" data-x-internal="block-level">block-level</a> <a id="button-layout:block-container" href="https://drafts.csswg.org/css-display/#block-container" data-x-internal="block-container">block container</a> that establishes a
     new <a id="button-layout:block-formatting-context" href="https://drafts.csswg.org/css-display/#block-formatting-context" data-x-internal="block-formatting-context">block formatting context</a> (i.e., <a id="button-layout:'display'-6" href="https://drafts.csswg.org/css2/#display-prop" data-x-internal="'display'">'display'</a> is
     'flow-root').</p></li><li><p>If the box does not overflow in the horizontal axis, then it is centered
     horizontally.</p></li><li><p>If the box does not overflow in the vertical axis, then it is centered
     vertically.</p></li></ul>

    <p>Otherwise, there is no <a href="#anonymous-button-content-box" id="button-layout:anonymous-button-content-box">anonymous button content box</a>.</p>
   </li></ul>
  </div>

  <p class="XXX">Need to define the <a id="button-layout:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive appearance</a>.</p>

  <h4 id="the-button-element-2"><span class="secno">15.5.4</span> The <code id="the-button-element-2:the-button-element"><a href="#the-button-element">button</a></code> element<a href="#the-button-element-2" class="self-link"></a></h4>

  <p>The <code id="the-button-element-2:the-button-element-2"><a href="#the-button-element">button</a></code> element, when it generates a <a id="the-button-element-2:css-box" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS box</a>, is
  <a href="#expected" id="the-button-element-2:expected">expected</a> to depict a button and to use <a href="#button-layout-2" id="the-button-element-2:button-layout-2">button layout</a> whose
  <a href="#anonymous-button-content-box" id="the-button-element-2:anonymous-button-content-box">anonymous button content box</a>'s contents (if there is an <a href="#anonymous-button-content-box" id="the-button-element-2:anonymous-button-content-box-2">anonymous button
  content box</a>) are the child boxes the element's box would otherwise have.</p>

  

  

  <h4 id="the-details-and-summary-elements"><span class="secno">15.5.5</span> The <code id="the-details-and-summary-elements:the-details-element"><a href="#the-details-element">details</a></code> and <code id="the-details-and-summary-elements:the-summary-element"><a href="#the-summary-element">summary</a></code> elements<a href="#the-details-and-summary-elements" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">details, summary </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c-> block<c- p="">;</c->
<c- p="">}</c->
<c- f="">details &gt; summary:first-of-type </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c-> list-item<c- p="">;</c->
  <c- k="">counter-increment</c-><c- p="">:</c-> list-item <c- m="">0</c-><c- p="">;</c->
  <c- k="">list-style</c-><c- p="">:</c-> disclosure-closed inside<c- p="">;</c->
<c- p="">}</c->
<c- f="">details[open] &gt; summary:first-of-type </c-><c- p="">{</c->
  <c- k="">list-style-type</c-><c- p="">:</c-> disclosure-open<c- p="">;</c->
<c- p="">}</c-></code></pre>

  <p>The <code id="the-details-and-summary-elements:the-details-element-2"><a href="#the-details-element">details</a></code> element is <a href="#expected" id="the-details-and-summary-elements:expected">expected</a> to have an internal <a id="the-details-and-summary-elements:shadow-tree" href="https://dom.spec.whatwg.org/#concept-shadow-tree" data-x-internal="shadow-tree">shadow
  tree</a> with three child elements:</p>

  <ol><li>
    <p>The first child element is a <code id="the-details-and-summary-elements:the-slot-element"><a href="#the-slot-element">slot</a></code> that is <a href="#expected" id="the-details-and-summary-elements:expected-2">expected</a> to take the
    <code id="the-details-and-summary-elements:the-details-element-3"><a href="#the-details-element">details</a></code> element's first <code id="the-details-and-summary-elements:the-summary-element-2"><a href="#the-summary-element">summary</a></code> element child, if any.  This element
    has a single child <code id="the-details-and-summary-elements:the-summary-element-3"><a href="#the-summary-element">summary</a></code> element called the <dfn id="default-summary">default summary</dfn> which has
    text content that is <a id="the-details-and-summary-elements:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> (and probably locale-specific).</p>

    <p>The <code id="the-details-and-summary-elements:the-summary-element-4"><a href="#the-summary-element">summary</a></code> element that this slot <a href="#represents" id="the-details-and-summary-elements:represents">represents</a> is
    <a href="#expected" id="the-details-and-summary-elements:expected-3">expected</a> to allow the user to request the details be shown or hidden.</p>
   </li><li>
    <p>The second child element is a <code id="the-details-and-summary-elements:the-slot-element-2"><a href="#the-slot-element">slot</a></code> that is <a href="#expected" id="the-details-and-summary-elements:expected-4">expected</a> to take the
    <code id="the-details-and-summary-elements:the-details-element-4"><a href="#the-details-element">details</a></code> element's remaining descendants, if any.  This element has no contents.</p>

    <p>This element is <a href="#expected" id="the-details-and-summary-elements:expected-5">expected</a> to match the <a id="the-details-and-summary-elements:'::details-content'" href="https://drafts.csswg.org/css-pseudo/#details-content-pseudo" data-x-internal="'::details-content'">'::details-content'</a>
    pseudo-element.</p>

    <div data-algorithm="">
    <p>This element is <a href="#expected" id="the-details-and-summary-elements:expected-6">expected</a> to have its <code id="the-details-and-summary-elements:attr-style"><a href="#attr-style">style</a></code>
    attribute set to "<code>display: block; content-visibility: hidden;</code>" when the
    <code id="the-details-and-summary-elements:the-details-element-5"><a href="#the-details-element">details</a></code> element does not have an <code id="the-details-and-summary-elements:attr-details-open"><a href="#attr-details-open">open</a></code>
    attribute. When it does have the <code id="the-details-and-summary-elements:attr-details-open-2"><a href="#attr-details-open">open</a></code> attribute, the
    <code id="the-details-and-summary-elements:attr-style-2"><a href="#attr-style">style</a></code> attribute is <a href="#expected" id="the-details-and-summary-elements:expected-7">expected</a> to be set to
    "<code>display: block;</code>".</p>
    </div>

    <p class="note">Because the slots are hidden inside a shadow tree, this <code id="the-details-and-summary-elements:attr-style-3"><a href="#attr-style">style</a></code> attribute is not directly visible to author code. Its impacts,
    however, are visible. Notably, the choice of <code>content-visibility: hidden</code>
    instead of, e.g., <code>display: none</code>, impacts the results of various APIs that
    query layout information.</p>
   </li><li>
    <p>The third child element is either a <code id="the-details-and-summary-elements:the-link-element"><a href="#the-link-element">link</a></code> or <code id="the-details-and-summary-elements:the-style-element"><a href="#the-style-element">style</a></code>
    element with the following styles for the <a href="#default-summary" id="the-details-and-summary-elements:default-summary">default summary</a>:</p>
    <pre><code class="css"><c- f="">:host summary </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c-> list-item<c- p="">;</c->
  <c- k="">counter-increment</c-><c- p="">:</c-> list-item <c- m="">0</c-><c- p="">;</c->
  <c- k="">list-style</c-><c- p="">:</c-> disclosure-closed inside<c- p="">;</c->
<c- p="">}</c->
<c- f="">:host([open]) summary </c-><c- p="">{</c->
  <c- k="">list-style-type</c-><c- p="">:</c-> disclosure-open<c- p="">;</c->
<c- p="">}</c-></code></pre>
    <p class="note">The position of this child element relative to the other two is not observable.
    This means that implementations might have it in a different order relative to its siblings.
    Implementations might even associate the style with the shadow tree using a mechanism that is
    not an element.</p>
   </li></ol>

  <p class="note">The structure of this shadow tree is observable through the ways that the children
  of the <code id="the-details-and-summary-elements:the-details-element-6"><a href="#the-details-element">details</a></code> element and the <a id="the-details-and-summary-elements:'::details-content'-2" href="https://drafts.csswg.org/css-pseudo/#details-content-pseudo" data-x-internal="'::details-content'">'::details-content'</a> pseudo-element
  respond to CSS styles.</p>

  

  

  

  <h4 id="the-input-element-as-a-text-entry-widget"><span class="secno">15.5.6</span> The <code id="the-input-element-as-a-text-entry-widget:the-input-element"><a href="#the-input-element">input</a></code> element as a text entry widget<a href="#the-input-element-as-a-text-entry-widget" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-a-text-entry-widget:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-text-entry-widget:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-input-element-as-a-text-entry-widget:text-(type=text)-state-and-search-state-(type=search)">Text</a>, <a href="#telephone-state-(type=tel)" id="the-input-element-as-a-text-entry-widget:telephone-state-(type=tel)">Telephone</a>, <a href="#url-state-(type=url)" id="the-input-element-as-a-text-entry-widget:url-state-(type=url)">URL</a>, or
  <a href="#email-state-(type=email)" id="the-input-element-as-a-text-entry-widget:email-state-(type=email)">Email</a> state, is a <a id="the-input-element-as-a-text-entry-widget:devolvable-widget" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>. Its
  <a id="the-input-element-as-a-text-entry-widget:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> is <a href="#expected" id="the-input-element-as-a-text-entry-widget:expected">expected</a> to render as an
  <a id="the-input-element-as-a-text-entry-widget:'inline-block'" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a one-line text control.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-a-text-entry-widget:the-input-element-3"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-text-entry-widget:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#text-(type=text)-state-and-search-state-(type=search)" id="the-input-element-as-a-text-entry-widget:text-(type=text)-state-and-search-state-(type=search)-2">Search</a> state is a <a id="the-input-element-as-a-text-entry-widget:devolvable-widget-2" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>.
  Its <a id="the-input-element-as-a-text-entry-widget:native-appearance-2" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> is <a href="#expected" id="the-input-element-as-a-text-entry-widget:expected-2">expected</a> to render as an
  <a id="the-input-element-as-a-text-entry-widget:'inline-block'-2" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a one-line text control. If the <a id="the-input-element-as-a-text-entry-widget:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed
  value</a> of the element's <a id="the-input-element-as-a-text-entry-widget:'appearance'" href="https://drafts.csswg.org/css-ui/#appearance-switching" data-x-internal="'appearance'">'appearance'</a> property is not <code id="the-input-element-as-a-text-entry-widget:'textfield'"><a data-x-internal="'textfield'" href="https://drafts.csswg.org/css-ui/#valdef-appearance-textfield">'textfield'</a></code>,
  it may have a distinct style indicating that it is a search field.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-a-text-entry-widget:the-input-element-4"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-text-entry-widget:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#password-state-(type=password)" id="the-input-element-as-a-text-entry-widget:password-state-(type=password)">Password</a> state is a <a id="the-input-element-as-a-text-entry-widget:devolvable-widget-3" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable
  widget</a>. Its <a id="the-input-element-as-a-text-entry-widget:native-appearance-3" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> is <a href="#expected" id="the-input-element-as-a-text-entry-widget:expected-3">expected</a> to render as an
  <a id="the-input-element-as-a-text-entry-widget:'inline-block'-3" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a one-line text control that obscures data entry.</p>
  </div>

  <p>For <code id="the-input-element-as-a-text-entry-widget:the-input-element-5"><a href="#the-input-element">input</a></code> elements whose <code id="the-input-element-as-a-text-entry-widget:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute is
  in one of the above states, the <a id="the-input-element-as-a-text-entry-widget:used-value" href="https://drafts.csswg.org/css-cascade/#used-value" data-x-internal="used-value">used value</a> of the <a id="the-input-element-as-a-text-entry-widget:'line-height'" href="https://drafts.csswg.org/css2/#propdef-line-height" data-x-internal="'line-height'">'line-height'</a> property
  must be a length value that is no smaller than what the <a id="the-input-element-as-a-text-entry-widget:used-value-2" href="https://drafts.csswg.org/css-cascade/#used-value" data-x-internal="used-value">used value</a> would be for
  'line-height: normal'.</p>

  <p class="note">The <a id="the-input-element-as-a-text-entry-widget:used-value-3" href="https://drafts.csswg.org/css-cascade/#used-value" data-x-internal="used-value">used value</a> will not be the actual keyword 'normal'. Also, this
  rule does not affect the <a id="the-input-element-as-a-text-entry-widget:computed-value-2" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a>.</p>

  <div data-algorithm="">
  <p>If these text controls provide a text selection, then, when the user changes the current
  selection, the user agent is <a href="#expected" id="the-input-element-as-a-text-entry-widget:expected-4">expected</a> to <a href="#queue-an-element-task" id="the-input-element-as-a-text-entry-widget:queue-an-element-task">queue an element task</a> on the
  <a href="#user-interaction-task-source" id="the-input-element-as-a-text-entry-widget:user-interaction-task-source">user interaction task source</a> given the <code id="the-input-element-as-a-text-entry-widget:the-input-element-6"><a href="#the-input-element">input</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-input-element-as-a-text-entry-widget:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-input-element-as-a-text-entry-widget:event-select"><a href="#event-select">select</a></code>
  at the element, with the <code id="the-input-element-as-a-text-entry-widget:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to
  true.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-a-text-entry-widget:the-input-element-7"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-text-entry-widget:attr-input-type-5"><a href="#attr-input-type">type</a></code> attribute is
  in one of the above states is an <a id="the-input-element-as-a-text-entry-widget:element-with-default-preferred-size" href="https://drafts.csswg.org/css-ui/#element-with-default-preferred-size" data-x-internal="element-with-default-preferred-size">element with default preferred size</a>, and user
  agents are <a href="#expected" id="the-input-element-as-a-text-entry-widget:expected-5">expected</a> to apply the <a id="the-input-element-as-a-text-entry-widget:'field-sizing'" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a> CSS property to the
  element. User agents are <a href="#expected" id="the-input-element-as-a-text-entry-widget:expected-6">expected</a> to determine the <a id="the-input-element-as-a-text-entry-widget:inline-size" href="https://drafts.csswg.org/css-writing-modes/#inline-size" data-x-internal="inline-size">inline size</a> of its
  <a id="the-input-element-as-a-text-entry-widget:intrinsic-size" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> by the following steps:</p>

  <ol><li>
    <p>If the <a id="the-input-element-as-a-text-entry-widget:'field-sizing'-2" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a> property on the element has a <a id="the-input-element-as-a-text-entry-widget:computed-value-3" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a>
    of <a href="https://drafts.csswg.org/css-ui/#valdef-field-sizing-content" id="the-input-element-as-a-text-entry-widget:field-sizing-content" data-x-internal="field-sizing-content">'content'</a>, the <a id="the-input-element-as-a-text-entry-widget:inline-size-2" href="https://drafts.csswg.org/css-writing-modes/#inline-size" data-x-internal="inline-size">inline size</a> is
    determined by the text which the element shows. The text is either a
    <a href="#concept-fe-value" id="the-input-element-as-a-text-entry-widget:concept-fe-value">value</a> or a short hint specified by the
    <code id="the-input-element-as-a-text-entry-widget:attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code> attribute. User agents may take the
    text caret size into account in the <a id="the-input-element-as-a-text-entry-widget:inline-size-3" href="https://drafts.csswg.org/css-writing-modes/#inline-size" data-x-internal="inline-size">inline size</a>.</p>
   </li><li>
    <p>If the element has a <code id="the-input-element-as-a-text-entry-widget:attr-input-size"><a href="#attr-input-size">size</a></code> attribute, and parsing that
    attribute's value using the <a href="#rules-for-parsing-non-negative-integers" id="the-input-element-as-a-text-entry-widget:rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a> doesn't
    generate an error, return the value obtained from applying the <a href="#converting-a-character-width-to-pixels" id="the-input-element-as-a-text-entry-widget:converting-a-character-width-to-pixels">converting a character
    width to pixels</a> algorithm to the value of the attribute.</p>
   </li><li>
    <p>Otherwise, return the value obtained from applying the <a href="#converting-a-character-width-to-pixels" id="the-input-element-as-a-text-entry-widget:converting-a-character-width-to-pixels-2">converting a character width to
    pixels</a> algorithm to the number 20.</p>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="converting-a-character-width-to-pixels">converting a character width to pixels</dfn> algorithm returns <span>(<var>size</var>-1)×<var>avg</var>&nbsp;+&nbsp;<var>max</var></span>,
  where <var>size</var> is the character width to convert, <var>avg</var> is the
  average character width of the primary font for the element for which the algorithm is being run,
  in pixels, and <var>max</var> is the maximum character width of that same font, also in
  pixels. (The element's <a id="the-input-element-as-a-text-entry-widget:'letter-spacing'" href="https://drafts.csswg.org/css-text/#letter-spacing-property" data-x-internal="'letter-spacing'">'letter-spacing'</a> property does not affect the result.)</p>
  </div>

  <p>These text controls are <a href="#expected" id="the-input-element-as-a-text-entry-widget:expected-7">expected</a> to be <a href="https://drafts.csswg.org/css-overflow/#scroll-container" id="the-input-element-as-a-text-entry-widget:scroll-container" data-x-internal="scroll-container">scroll
  containers</a> and support scrolling in the <a id="the-input-element-as-a-text-entry-widget:inline-axis" href="https://drafts.csswg.org/css-writing-modes/#inline-axis" data-x-internal="inline-axis">inline axis</a>, but not the <a id="the-input-element-as-a-text-entry-widget:block-axis" href="https://drafts.csswg.org/css-writing-modes/#block-axis" data-x-internal="block-axis">block
  axis</a>.</p>

  <p class="XXX">Need to detail the <a id="the-input-element-as-a-text-entry-widget:native-appearance-4" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> and <a id="the-input-element-as-a-text-entry-widget:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive
  appearance</a>.</p>

  


  

  <h4 id="the-input-element-as-domain-specific-widgets"><span class="secno">15.5.7</span> The <code id="the-input-element-as-domain-specific-widgets:the-input-element"><a href="#the-input-element">input</a></code> element as domain-specific widgets<a href="#the-input-element-as-domain-specific-widgets" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-domain-specific-widgets:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-domain-specific-widgets:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#date-state-(type=date)" id="the-input-element-as-domain-specific-widgets:date-state-(type=date)">Date</a> state is a <a id="the-input-element-as-domain-specific-widgets:devolvable-widget" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>
  <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected">expected</a> to render as an <a id="the-input-element-as-domain-specific-widgets:'inline-block'" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a date control.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-domain-specific-widgets:the-input-element-3"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-domain-specific-widgets:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#month-state-(type=month)" id="the-input-element-as-domain-specific-widgets:month-state-(type=month)">Month</a> state is a <a id="the-input-element-as-domain-specific-widgets:devolvable-widget-2" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>
  <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected-2">expected</a> to render as an <a id="the-input-element-as-domain-specific-widgets:'inline-block'-2" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a month control.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-domain-specific-widgets:the-input-element-4"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-domain-specific-widgets:attr-input-type-3"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#week-state-(type=week)" id="the-input-element-as-domain-specific-widgets:week-state-(type=week)">Week</a> state is a <a id="the-input-element-as-domain-specific-widgets:devolvable-widget-3" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>
  <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected-3">expected</a> to render as an <a id="the-input-element-as-domain-specific-widgets:'inline-block'-3" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a week control.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-domain-specific-widgets:the-input-element-5"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-domain-specific-widgets:attr-input-type-4"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#time-state-(type=time)" id="the-input-element-as-domain-specific-widgets:time-state-(type=time)">Time</a> state is a <a id="the-input-element-as-domain-specific-widgets:devolvable-widget-4" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>
  <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected-4">expected</a> to render as an <a id="the-input-element-as-domain-specific-widgets:'inline-block'-4" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a time control.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-domain-specific-widgets:the-input-element-6"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-domain-specific-widgets:attr-input-type-5"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#local-date-and-time-state-(type=datetime-local)" id="the-input-element-as-domain-specific-widgets:local-date-and-time-state-(type=datetime-local)">Local Date and Time</a> state is a
  <a id="the-input-element-as-domain-specific-widgets:devolvable-widget-5" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a> <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected-5">expected</a> to render as an <a id="the-input-element-as-domain-specific-widgets:'inline-block'-5" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a>
  box depicting a local date and time control.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-domain-specific-widgets:the-input-element-7"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-domain-specific-widgets:attr-input-type-6"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#number-state-(type=number)" id="the-input-element-as-domain-specific-widgets:number-state-(type=number)">Number</a> state is a <a id="the-input-element-as-domain-specific-widgets:devolvable-widget-6" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>
  <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected-6">expected</a> to render as an <a id="the-input-element-as-domain-specific-widgets:'inline-block'-6" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a number
  control.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-domain-specific-widgets:the-input-element-8"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-domain-specific-widgets:attr-input-type-7"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#number-state-(type=number)" id="the-input-element-as-domain-specific-widgets:number-state-(type=number)-2">Number</a> state is an
  <a id="the-input-element-as-domain-specific-widgets:element-with-default-preferred-size" href="https://drafts.csswg.org/css-ui/#element-with-default-preferred-size" data-x-internal="element-with-default-preferred-size">element with default preferred size</a>, and user agents are <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected-7">expected</a> to
  apply the <a id="the-input-element-as-domain-specific-widgets:'field-sizing'" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a> CSS property to the element. The <a id="the-input-element-as-domain-specific-widgets:block-size" href="https://drafts.csswg.org/css-writing-modes/#block-size" data-x-internal="block-size">block size</a> of
  the <a id="the-input-element-as-domain-specific-widgets:intrinsic-size" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> is about one line high. If the <a id="the-input-element-as-domain-specific-widgets:'field-sizing'-2" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a>
  property on the element has a <a id="the-input-element-as-domain-specific-widgets:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of
  <a href="https://drafts.csswg.org/css-ui/#valdef-field-sizing-content" id="the-input-element-as-domain-specific-widgets:field-sizing-content" data-x-internal="field-sizing-content">'content'</a>, the <a id="the-input-element-as-domain-specific-widgets:inline-size" href="https://drafts.csswg.org/css-writing-modes/#inline-size" data-x-internal="inline-size">inline size</a> of the
  <a id="the-input-element-as-domain-specific-widgets:intrinsic-size-2" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> is <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected-8">expected</a> to be about as wide as necessary to show the
  current <a href="#concept-fe-value" id="the-input-element-as-domain-specific-widgets:concept-fe-value">value</a>. Otherwise, the <a id="the-input-element-as-domain-specific-widgets:inline-size-2" href="https://drafts.csswg.org/css-writing-modes/#inline-size" data-x-internal="inline-size">inline size</a> of
  the <a id="the-input-element-as-domain-specific-widgets:intrinsic-size-3" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> is <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected-9">expected</a> to be about as wide as necessary to show
  the widest possible value.</p>
  </div>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-domain-specific-widgets:the-input-element-9"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-domain-specific-widgets:attr-input-type-8"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#date-state-(type=date)" id="the-input-element-as-domain-specific-widgets:date-state-(type=date)-2">Date</a>,
  <a href="#month-state-(type=month)" id="the-input-element-as-domain-specific-widgets:month-state-(type=month)-2">Month</a>,
  <a href="#week-state-(type=week)" id="the-input-element-as-domain-specific-widgets:week-state-(type=week)-2">Week</a>, <a href="#time-state-(type=time)" id="the-input-element-as-domain-specific-widgets:time-state-(type=time)-2">Time</a>,
  or <a href="#local-date-and-time-state-(type=datetime-local)" id="the-input-element-as-domain-specific-widgets:local-date-and-time-state-(type=datetime-local)-2">Local Date and Time</a> state, is
  <a href="#expected" id="the-input-element-as-domain-specific-widgets:expected-10">expected</a> to be about one line high, and about as wide as necessary to show the
  widest possible value.</p>
  </div>

  <p class="XXX">Need to detail the <a id="the-input-element-as-domain-specific-widgets:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> and <a id="the-input-element-as-domain-specific-widgets:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive
  appearance</a>.</p>

  


  

  <h4 id="the-input-element-as-a-range-control"><span class="secno">15.5.8</span> The <code id="the-input-element-as-a-range-control:the-input-element"><a href="#the-input-element">input</a></code> element as a range control<a href="#the-input-element-as-a-range-control" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-a-range-control:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-range-control:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#range-state-(type=range)" id="the-input-element-as-a-range-control:range-state-(type=range)">Range</a> state is a <a id="the-input-element-as-a-range-control:non-devolvable-widget" href="https://drafts.csswg.org/css-ui/#non-devolvable" data-x-internal="non-devolvable-widget">non-devolvable
  widget</a>. Its <a id="the-input-element-as-a-range-control:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> is <a href="#expected" id="the-input-element-as-a-range-control:expected">expected</a> to render as an
  <a id="the-input-element-as-a-range-control:'inline-block'" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a slider control.</p>
  </div>

  <p>When this control has a <a href="#horizontal-writing-mode" id="the-input-element-as-a-range-control:horizontal-writing-mode">horizontal writing mode</a>, the control is
  <a href="#expected" id="the-input-element-as-a-range-control:expected-2">expected</a> to be a horizontal slider. Its lowest value is on the right if the
  <a id="the-input-element-as-a-range-control:'direction'" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a> property has a <a id="the-input-element-as-a-range-control:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of 'rtl', and on the left
  otherwise. When this control has a <a href="#vertical-writing-mode" id="the-input-element-as-a-range-control:vertical-writing-mode">vertical writing mode</a>, it is
  <a href="#expected" id="the-input-element-as-a-range-control:expected-3">expected</a> to be a vertical slider. Its lowest value is on the bottom if the
  <a id="the-input-element-as-a-range-control:'direction'-2" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a> property has a <a id="the-input-element-as-a-range-control:computed-value-2" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of 'rtl', and on the top
  otherwise.</p>

  <p>Predefined suggested values (provided by the <code id="the-input-element-as-a-range-control:attr-input-list"><a href="#attr-input-list">list</a></code>
  attribute) are <a href="#expected" id="the-input-element-as-a-range-control:expected-4">expected</a> to be shown as tick marks on the slider, which the slider
  can snap to.</p>

  <p class="XXX">Need to detail the <a id="the-input-element-as-a-range-control:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive appearance</a>.</p>
  


  

  <h4 id="the-input-element-as-a-colour-well"><span class="secno">15.5.9</span> The <code id="the-input-element-as-a-colour-well:the-input-element"><a href="#the-input-element">input</a></code> element as a color
  well<a href="#the-input-element-as-a-colour-well" class="self-link"></a></h4>

  <p>An <code id="the-input-element-as-a-colour-well:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-colour-well:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#color-state-(type=color)" id="the-input-element-as-a-colour-well:color-state-(type=color)">Color</a> state is <a href="#expected" id="the-input-element-as-a-colour-well:expected">expected</a> to depict a
  color well, which, when activated, provides the user with a color picker (e.g. a color wheel or
  color palette) from which the color can be changed. The element, when it generates a <a id="the-input-element-as-a-colour-well:css-box" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS
  box</a>, is <a href="#expected" id="the-input-element-as-a-colour-well:expected-2">expected</a> to use <a href="#button-layout-2" id="the-input-element-as-a-colour-well:button-layout-2">button layout</a>, that has no child boxes
  of the <a href="#anonymous-button-content-box" id="the-input-element-as-a-colour-well:anonymous-button-content-box">anonymous button content box</a>. The <a href="#anonymous-button-content-box" id="the-input-element-as-a-colour-well:anonymous-button-content-box-2">anonymous button content box</a>
  is <a href="#expected" id="the-input-element-as-a-colour-well:expected-3">expected</a> to have a <a href="#presentational-hints" id="the-input-element-as-a-colour-well:presentational-hints">presentational hint</a>
  setting the <a id="the-input-element-as-a-colour-well:'background-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-background-color" data-x-internal="'background-color'">'background-color'</a> property to the element's <a href="#concept-fe-value" id="the-input-element-as-a-colour-well:concept-fe-value">value</a>.</p>

  <p>Predefined suggested values (provided by the <code id="the-input-element-as-a-colour-well:attr-input-list"><a href="#attr-input-list">list</a></code>
  attribute) are <a href="#expected" id="the-input-element-as-a-colour-well:expected-4">expected</a> to be shown in the color picker interface, not on the color
  well itself.</p>

  <p class="XXX">Need to detail the <a id="the-input-element-as-a-colour-well:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> and <a id="the-input-element-as-a-colour-well:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive
  appearance</a>.</p>

  


  

  <h4 id="the-input-element-as-a-checkbox-and-radio-button-widgets"><span class="secno">15.5.10</span> The <code id="the-input-element-as-a-checkbox-and-radio-button-widgets:the-input-element"><a href="#the-input-element">input</a></code> element as a checkbox and radio button widgets<a href="#the-input-element-as-a-checkbox-and-radio-button-widgets" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-a-checkbox-and-radio-button-widgets:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-checkbox-and-radio-button-widgets:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#checkbox-state-(type=checkbox)" id="the-input-element-as-a-checkbox-and-radio-button-widgets:checkbox-state-(type=checkbox)">Checkbox</a> state is a <a id="the-input-element-as-a-checkbox-and-radio-button-widgets:non-devolvable-widget" href="https://drafts.csswg.org/css-ui/#non-devolvable" data-x-internal="non-devolvable-widget">non-devolvable
  widget</a> <a href="#expected" id="the-input-element-as-a-checkbox-and-radio-button-widgets:expected">expected</a> to render as an <a id="the-input-element-as-a-checkbox-and-radio-button-widgets:'inline-block'" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box containing a
  single checkbox control, with no label.</p>
  </div>

  <p class="XXX">Need to detail the <a id="the-input-element-as-a-checkbox-and-radio-button-widgets:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> and <a id="the-input-element-as-a-checkbox-and-radio-button-widgets:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive
  appearance</a>.</p>

  <div data-algorithm="">
  <p>An <code id="the-input-element-as-a-checkbox-and-radio-button-widgets:the-input-element-3"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-checkbox-and-radio-button-widgets:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#radio-button-state-(type=radio)" id="the-input-element-as-a-checkbox-and-radio-button-widgets:radio-button-state-(type=radio)">Radio Button</a> state is a <a id="the-input-element-as-a-checkbox-and-radio-button-widgets:non-devolvable-widget-2" href="https://drafts.csswg.org/css-ui/#non-devolvable" data-x-internal="non-devolvable-widget">non-devolvable
  widget</a> <a href="#expected" id="the-input-element-as-a-checkbox-and-radio-button-widgets:expected-2">expected</a> to render as an <a id="the-input-element-as-a-checkbox-and-radio-button-widgets:'inline-block'-2" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box containing a
  single radio button control, with no label.</p>
  </div>

  <p class="XXX">Need to detail the <a id="the-input-element-as-a-checkbox-and-radio-button-widgets:native-appearance-2" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> and <a id="the-input-element-as-a-checkbox-and-radio-button-widgets:primitive-appearance-2" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive
  appearance</a>.</p>

  


  

  <h4 id="the-input-element-as-a-file-upload-control"><span class="secno">15.5.11</span> The <code id="the-input-element-as-a-file-upload-control:the-input-element"><a href="#the-input-element">input</a></code> element as a file upload control<a href="#the-input-element-as-a-file-upload-control" class="self-link"></a></h4>

  <p>An <code id="the-input-element-as-a-file-upload-control:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-file-upload-control:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#file-upload-state-(type=file)" id="the-input-element-as-a-file-upload-control:file-upload-state-(type=file)">File Upload</a> state, when it generates a <a id="the-input-element-as-a-file-upload-control:css-box" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS
  box</a>, is <a href="#expected" id="the-input-element-as-a-file-upload-control:expected">expected</a> to render as an <a id="the-input-element-as-a-file-upload-control:'inline-block'" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box containing a
  span of text giving the filename(s) of the <a href="#concept-input-type-file-selected" id="the-input-element-as-a-file-upload-control:concept-input-type-file-selected">selected files</a>, if any, followed by a button
  that, when activated, provides the user with a file picker from which the selection can be
  changed. The button is <a href="#expected" id="the-input-element-as-a-file-upload-control:expected-2">expected</a> to use <a href="#button-layout-2" id="the-input-element-as-a-file-upload-control:button-layout-2">button layout</a> and match the
  <a id="the-input-element-as-a-file-upload-control:'::file-selector-button'" href="https://drafts.csswg.org/css-pseudo/#file-selector-button-pseudo" data-x-internal="'::file-selector-button'">'::file-selector-button'</a> pseudo-element. The contents of its <a href="#anonymous-button-content-box" id="the-input-element-as-a-file-upload-control:anonymous-button-content-box">anonymous button
  content box</a> are <a href="#expected" id="the-input-element-as-a-file-upload-control:expected-3">expected</a> to be <a id="the-input-element-as-a-file-upload-control:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> (and
  possibly locale-specific) text, for example "Choose file".</p>

  <p>User agents may handle an <code id="the-input-element-as-a-file-upload-control:the-input-element-3"><a href="#the-input-element">input</a></code> element whose
  <code id="the-input-element-as-a-file-upload-control:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the
  <a href="#file-upload-state-(type=file)" id="the-input-element-as-a-file-upload-control:file-upload-state-(type=file)-2">File Upload</a> state as an
  <a id="the-input-element-as-a-file-upload-control:element-with-default-preferred-size" href="https://drafts.csswg.org/css-ui/#element-with-default-preferred-size" data-x-internal="element-with-default-preferred-size">element with default preferred size</a>, and user agents may apply the
  <a id="the-input-element-as-a-file-upload-control:'field-sizing'" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a> CSS property to the element. If the <a id="the-input-element-as-a-file-upload-control:'field-sizing'-2" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a>
  property on the element has a <a id="the-input-element-as-a-file-upload-control:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of
  <a href="https://drafts.csswg.org/css-ui/#valdef-field-sizing-content" id="the-input-element-as-a-file-upload-control:field-sizing-content" data-x-internal="field-sizing-content">'content'</a>, the <a id="the-input-element-as-a-file-upload-control:intrinsic-size" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> of the
  element is <a href="#expected" id="the-input-element-as-a-file-upload-control:expected-4">expected</a> to depend on its content such as the
  <a id="the-input-element-as-a-file-upload-control:'::file-selector-button'-2" href="https://drafts.csswg.org/css-pseudo/#file-selector-button-pseudo" data-x-internal="'::file-selector-button'">'::file-selector-button'</a> pseudo-element and chosen file names.</p>

  


  

  <h4 id="the-input-element-as-a-button"><span class="secno">15.5.12</span> The <code id="the-input-element-as-a-button:the-input-element"><a href="#the-input-element">input</a></code> element as a button<a href="#the-input-element-as-a-button" class="self-link"></a></h4>

  <p>An <code id="the-input-element-as-a-button:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="the-input-element-as-a-button:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in
  the <a href="#submit-button-state-(type=submit)" id="the-input-element-as-a-button:submit-button-state-(type=submit)">Submit Button</a>, <a href="#reset-button-state-(type=reset)" id="the-input-element-as-a-button:reset-button-state-(type=reset)">Reset Button</a>, or <a href="#button-state-(type=button)" id="the-input-element-as-a-button:button-state-(type=button)">Button</a> state, when it generates a <a id="the-input-element-as-a-button:css-box" href="https://drafts.csswg.org/css-display/#css-box" data-x-internal="css-box">CSS box</a>, is
  <a href="#expected" id="the-input-element-as-a-button:expected">expected</a> to depict a button and use <a href="#button-layout-2" id="the-input-element-as-a-button:button-layout-2">button layout</a> and the contents of
  the <a href="#anonymous-button-content-box" id="the-input-element-as-a-button:anonymous-button-content-box">anonymous button content box</a> are <a href="#expected" id="the-input-element-as-a-button:expected-2">expected</a> to be the text of the
  element's <code id="the-input-element-as-a-button:attr-input-value"><a href="#attr-input-value">value</a></code> attribute, if any, or text derived from
  the element's <code id="the-input-element-as-a-button:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute in an
  <a id="the-input-element-as-a-button:implementation-defined" href="https://infra.spec.whatwg.org/#implementation-defined" data-x-internal="implementation-defined">implementation-defined</a> (and probably locale-specific) fashion, if not.</p>

  


  

  <h4 id="the-marquee-element-2"><span class="secno">15.5.13</span> The <code id="the-marquee-element-2:the-marquee-element"><a href="#the-marquee-element">marquee</a></code> element<a href="#the-marquee-element-2" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">marquee </c-><c- p="">{</c->
  <c- k="">display</c-><c- p="">:</c-> inline-block<c- p="">;</c->
  <c- k="">text-align</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">overflow</c-><c- p="">:</c-> hidden !important;
}</code></pre>

  <div data-algorithm="">
  <p>The <code id="the-marquee-element-2:the-marquee-element-2"><a href="#the-marquee-element">marquee</a></code> element, while <a href="#concept-marquee-on" id="the-marquee-element-2:concept-marquee-on">turned on</a>, is
  <a href="#expected" id="the-marquee-element-2:expected">expected</a> to render in an animated fashion according to its attributes as
  follows:</p>

  <dl><dt>If the element's <code id="the-marquee-element-2:attr-marquee-behavior"><a href="#attr-marquee-behavior">behavior</a></code> attribute is in the
   <a href="#attr-marquee-behavior-scroll" id="the-marquee-element-2:attr-marquee-behavior-scroll">scroll</a> state</dt><dd>
    <p>Slide the contents of the element in the direction described by the <code id="the-marquee-element-2:attr-marquee-direction"><a href="#attr-marquee-direction">direction</a></code> attribute as defined below, such that it begins
    off the start side of the <code id="the-marquee-element-2:the-marquee-element-3"><a href="#the-marquee-element">marquee</a></code>, and ends flush with the inner end side.</p>

    <p class="example">For example, if the <code id="the-marquee-element-2:attr-marquee-direction-2"><a href="#attr-marquee-direction">direction</a></code>
    attribute is <a href="#attr-marquee-direction-left" id="the-marquee-element-2:attr-marquee-direction-left">left</a> (the default), then the
    contents would start such that their left edge are off the side of the right edge of the
    <code id="the-marquee-element-2:the-marquee-element-4"><a href="#the-marquee-element">marquee</a></code>'s <a id="the-marquee-element-2:content-area" href="https://drafts.csswg.org/css-box/#content-area" data-x-internal="content-area">content area</a>, and the contents would then slide up to the
    point where the left edge of the contents are flush with the left inner edge of the
    <code id="the-marquee-element-2:the-marquee-element-5"><a href="#the-marquee-element">marquee</a></code>'s <a id="the-marquee-element-2:content-area-2" href="https://drafts.csswg.org/css-box/#content-area" data-x-internal="content-area">content area</a>.</p>

    <p>Once the animation has ended, the user agent is <a href="#expected" id="the-marquee-element-2:expected-2">expected</a> to <a href="#increment-the-marquee-current-loop-index" id="the-marquee-element-2:increment-the-marquee-current-loop-index">increment the
    marquee current loop index</a>. If the element is still <a href="#concept-marquee-on" id="the-marquee-element-2:concept-marquee-on-2">turned on</a> after this, then the user agent is
    <a href="#expected" id="the-marquee-element-2:expected-3">expected</a> to restart the animation.</p>
   </dd><dt>If the element's <code id="the-marquee-element-2:attr-marquee-behavior-2"><a href="#attr-marquee-behavior">behavior</a></code> attribute is in the
   <a href="#attr-marquee-behavior-slide" id="the-marquee-element-2:attr-marquee-behavior-slide">slide</a> state</dt><dd>
    <p>Slide the contents of the element in the direction described by the <code id="the-marquee-element-2:attr-marquee-direction-3"><a href="#attr-marquee-direction">direction</a></code> attribute as defined below, such that it begins
    off the start side of the <code id="the-marquee-element-2:the-marquee-element-6"><a href="#the-marquee-element">marquee</a></code>, and ends off the end side of the
    <code id="the-marquee-element-2:the-marquee-element-7"><a href="#the-marquee-element">marquee</a></code>.</p>

    <p class="example">For example, if the <code id="the-marquee-element-2:attr-marquee-direction-4"><a href="#attr-marquee-direction">direction</a></code>
    attribute is <a href="#attr-marquee-direction-left" id="the-marquee-element-2:attr-marquee-direction-left-2">left</a> (the default), then the
    contents would start such that their left edge are off the side of the right edge of the
    <code id="the-marquee-element-2:the-marquee-element-8"><a href="#the-marquee-element">marquee</a></code>'s <a id="the-marquee-element-2:content-area-3" href="https://drafts.csswg.org/css-box/#content-area" data-x-internal="content-area">content area</a>, and the contents would then slide up to the
    point where the <em>right</em> edge of the contents are flush with the left inner edge of the
    <code id="the-marquee-element-2:the-marquee-element-9"><a href="#the-marquee-element">marquee</a></code>'s <a id="the-marquee-element-2:content-area-4" href="https://drafts.csswg.org/css-box/#content-area" data-x-internal="content-area">content area</a>.</p>

    <p>Once the animation has ended, the user agent is <a href="#expected" id="the-marquee-element-2:expected-4">expected</a> to <a href="#increment-the-marquee-current-loop-index" id="the-marquee-element-2:increment-the-marquee-current-loop-index-2">increment the
    marquee current loop index</a>. If the element is still <a href="#concept-marquee-on" id="the-marquee-element-2:concept-marquee-on-3">turned on</a> after this, then the user agent is
    <a href="#expected" id="the-marquee-element-2:expected-5">expected</a> to restart the animation.</p>
   </dd><dt>If the element's <code id="the-marquee-element-2:attr-marquee-behavior-3"><a href="#attr-marquee-behavior">behavior</a></code> attribute is in the
   <a href="#attr-marquee-behavior-alternate" id="the-marquee-element-2:attr-marquee-behavior-alternate">alternate</a> state</dt><dd>
    <p>When the <a href="#marquee-current-loop-index" id="the-marquee-element-2:marquee-current-loop-index">marquee current loop index</a> is even (or zero), slide the contents of the
    element in the direction described by the <code id="the-marquee-element-2:attr-marquee-direction-5"><a href="#attr-marquee-direction">direction</a></code>
    attribute as defined below, such that it begins flush with the start side of the
    <code id="the-marquee-element-2:the-marquee-element-10"><a href="#the-marquee-element">marquee</a></code>, and ends flush with the end side of the <code id="the-marquee-element-2:the-marquee-element-11"><a href="#the-marquee-element">marquee</a></code>.</p>

    <p>When the <a href="#marquee-current-loop-index" id="the-marquee-element-2:marquee-current-loop-index-2">marquee current loop index</a> is odd, slide the contents of the element in
    the opposite direction than that described by the <code id="the-marquee-element-2:attr-marquee-direction-6"><a href="#attr-marquee-direction">direction</a></code> attribute as defined below, such that it begins
    flush with the end side of the <code id="the-marquee-element-2:the-marquee-element-12"><a href="#the-marquee-element">marquee</a></code>, and ends flush with the start side of the
    <code id="the-marquee-element-2:the-marquee-element-13"><a href="#the-marquee-element">marquee</a></code>.</p>

    <p class="example">For example, if the <code id="the-marquee-element-2:attr-marquee-direction-7"><a href="#attr-marquee-direction">direction</a></code>
    attribute is <a href="#attr-marquee-direction-left" id="the-marquee-element-2:attr-marquee-direction-left-3">left</a> (the default), then the
    contents would with their right edge flush with the right inner edge of the
    <code id="the-marquee-element-2:the-marquee-element-14"><a href="#the-marquee-element">marquee</a></code>'s <a id="the-marquee-element-2:content-area-5" href="https://drafts.csswg.org/css-box/#content-area" data-x-internal="content-area">content area</a>, and the contents would then slide up to the
    point where the <em>left</em> edge of the contents are flush with the left inner edge of the
    <code id="the-marquee-element-2:the-marquee-element-15"><a href="#the-marquee-element">marquee</a></code>'s <a id="the-marquee-element-2:content-area-6" href="https://drafts.csswg.org/css-box/#content-area" data-x-internal="content-area">content area</a>.</p>

    <p>Once the animation has ended, the user agent is <a href="#expected" id="the-marquee-element-2:expected-6">expected</a> to <a href="#increment-the-marquee-current-loop-index" id="the-marquee-element-2:increment-the-marquee-current-loop-index-3">increment the
    marquee current loop index</a>. If the element is still <a href="#concept-marquee-on" id="the-marquee-element-2:concept-marquee-on-4">turned on</a> after this, then the user agent is
    <a href="#expected" id="the-marquee-element-2:expected-7">expected</a> to continue the animation.</p>
   </dd></dl>
  </div>

  <p>The <code id="the-marquee-element-2:attr-marquee-direction-8"><a href="#attr-marquee-direction">direction</a></code> attribute has the meanings described
  in the following table:</p>

  <table><thead><tr><th><code id="the-marquee-element-2:attr-marquee-direction-9"><a href="#attr-marquee-direction">direction</a></code> attribute state
     </th><th>Direction of animation
     </th><th>Start edge
     </th><th>End edge
     </th><th>Opposite direction
   </th></tr></thead><tbody><tr><td><a href="#attr-marquee-direction-left" id="the-marquee-element-2:attr-marquee-direction-left-4">left</a>
     </td><td>← Right to left
     </td><td>Right
     </td><td>Left
     </td><td>→ Left to Right
    </td></tr><tr><td><a href="#attr-marquee-direction-right" id="the-marquee-element-2:attr-marquee-direction-right">right</a>
     </td><td>→ Left to Right
     </td><td>Left
     </td><td>Right
     </td><td>← Right to left
    </td></tr><tr><td><a href="#attr-marquee-direction-up" id="the-marquee-element-2:attr-marquee-direction-up">up</a>
     </td><td>↑ Up (Bottom to Top)
     </td><td>Bottom
     </td><td>Top
     </td><td>↓ Down (Top to Bottom)
    </td></tr><tr><td><a href="#attr-marquee-direction-down" id="the-marquee-element-2:attr-marquee-direction-down">down</a>
     </td><td>↓ Down (Top to Bottom)
     </td><td>Top
     </td><td>Bottom
     </td><td>↑ Up (Bottom to Top)
  </td></tr></tbody></table>

  <p>In any case, the animation should proceed such that there is a delay given by the <a href="#marquee-scroll-interval" id="the-marquee-element-2:marquee-scroll-interval">marquee
  scroll interval</a> between each frame, and such that the content moves at most the distance
  given by the <a href="#marquee-scroll-distance" id="the-marquee-element-2:marquee-scroll-distance">marquee scroll distance</a> with each frame.</p>

  <div data-algorithm="">
  <p>When a <code id="the-marquee-element-2:the-marquee-element-16"><a href="#the-marquee-element">marquee</a></code> element has a <code>bgcolor</code>
  attribute set, the value is <a href="#expected" id="the-marquee-element-2:expected-8">expected</a> to be parsed using the <a href="#rules-for-parsing-a-legacy-colour-value" id="the-marquee-element-2:rules-for-parsing-a-legacy-colour-value">rules for parsing
  a legacy color value</a>, and if that does not return failure, the user agent is
  <a href="#expected" id="the-marquee-element-2:expected-9">expected</a> to treat the attribute as a <a href="#presentational-hints" id="the-marquee-element-2:presentational-hints">presentational hint</a> setting the element's <a id="the-marquee-element-2:'background-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-background-color" data-x-internal="'background-color'">'background-color'</a> property
  to the resulting color.</p>
  </div>

  <p>The <code>width</code> and <code>height</code> attributes on a <code id="the-marquee-element-2:the-marquee-element-17"><a href="#the-marquee-element">marquee</a></code> element
  <a href="#maps-to-the-dimension-property" id="the-marquee-element-2:maps-to-the-dimension-property">map to the dimension properties</a>
  <a id="the-marquee-element-2:'width'" href="https://drafts.csswg.org/css2/#the-width-property" data-x-internal="'width'">'width'</a> and <a id="the-marquee-element-2:'height'" href="https://drafts.csswg.org/css2/#the-height-property" data-x-internal="'height'">'height'</a> on the element respectively.</p>

  <div data-algorithm="">
  <p>The <a id="the-marquee-element-2:natural-height" href="https://drafts.csswg.org/css-images/#natural-height" data-x-internal="natural-height">natural height</a> of a <code id="the-marquee-element-2:the-marquee-element-18"><a href="#the-marquee-element">marquee</a></code> element with its <code id="the-marquee-element-2:attr-marquee-direction-10"><a href="#attr-marquee-direction">direction</a></code> attribute in the <a href="#attr-marquee-direction-up" id="the-marquee-element-2:attr-marquee-direction-up-2">up</a> or <a href="#attr-marquee-direction-down" id="the-marquee-element-2:attr-marquee-direction-down-2">down</a> states is 200 <a href="https://drafts.csswg.org/css-values/#px" id="the-marquee-element-2:'px'" data-x-internal="'px'">CSS
  pixels</a>.</p>
  </div>

  <p>The <code>vspace</code> attribute of a
  <code id="the-marquee-element-2:the-marquee-element-19"><a href="#the-marquee-element">marquee</a></code> element <a href="#maps-to-the-dimension-property" id="the-marquee-element-2:maps-to-the-dimension-property-2">maps to the dimension
  properties</a> <a id="the-marquee-element-2:'margin-top'" href="https://drafts.csswg.org/css-box/#propdef-margin-top" data-x-internal="'margin-top'">'margin-top'</a> and <a id="the-marquee-element-2:'margin-bottom'" href="https://drafts.csswg.org/css-box/#propdef-margin-bottom" data-x-internal="'margin-bottom'">'margin-bottom'</a> on the element. The
  <code>hspace</code> attribute of a <code id="the-marquee-element-2:the-marquee-element-20"><a href="#the-marquee-element">marquee</a></code>
  element <a href="#maps-to-the-dimension-property" id="the-marquee-element-2:maps-to-the-dimension-property-3">maps to the dimension properties</a>
  <a id="the-marquee-element-2:'margin-left'" href="https://drafts.csswg.org/css-box/#propdef-margin-left" data-x-internal="'margin-left'">'margin-left'</a> and <a id="the-marquee-element-2:'margin-right'" href="https://drafts.csswg.org/css-box/#propdef-margin-right" data-x-internal="'margin-right'">'margin-right'</a> on the element.</p>

  


  

  <h4 id="the-meter-element-2"><span class="secno">15.5.14</span> The <code id="the-meter-element-2:the-meter-element"><a href="#the-meter-element">meter</a></code> element<a href="#the-meter-element-2" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">meter </c-><c- p="">{</c-> <c- k="">appearance</c-><c- p="">:</c-> auto<c- p="">;</c-> <c- p="">}</c-></code></pre>

  <div data-algorithm="">
  <p>The <code id="the-meter-element-2:the-meter-element-2"><a href="#the-meter-element">meter</a></code> element is a <a id="the-meter-element-2:devolvable-widget" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>. Its <a id="the-meter-element-2:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native
  appearance</a> is <a href="#expected" id="the-meter-element-2:expected">expected</a> to render as an <a id="the-meter-element-2:'inline-block'" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box with a
  <a id="the-meter-element-2:'block-size'" href="https://drafts.csswg.org/css-logical/#propdef-block-size" data-x-internal="'block-size'">'block-size'</a> of '1em' and a <a id="the-meter-element-2:'inline-size'" href="https://drafts.csswg.org/css-logical/#propdef-inline-size" data-x-internal="'inline-size'">'inline-size'</a> of '5em', a
  <a id="the-meter-element-2:'vertical-align'" href="https://drafts.csswg.org/css2/#propdef-vertical-align" data-x-internal="'vertical-align'">'vertical-align'</a> of '-0.2em', and with its contents depicting a gauge.</p>
  </div>

  <p>When this element has a <a href="#horizontal-writing-mode" id="the-meter-element-2:horizontal-writing-mode">horizontal writing mode</a>, the depiction is
  <a href="#expected" id="the-meter-element-2:expected-2">expected</a> to be of a horizontal gauge. Its minimum value is on the right if the
  <a id="the-meter-element-2:'direction'" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a> property has a <a id="the-meter-element-2:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of 'rtl', and on the left
  otherwise. When this element has a <a href="#vertical-writing-mode" id="the-meter-element-2:vertical-writing-mode">vertical writing mode</a>, it is
  <a href="#expected" id="the-meter-element-2:expected-3">expected</a> to depict a vertical gauge. Its minimum value is on the bottom if the
  <a id="the-meter-element-2:'direction'-2" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a> property has a <a id="the-meter-element-2:computed-value-2" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of 'rtl', and on the top
  otherwise.</p>

  <p>User agents are <a href="#expected" id="the-meter-element-2:expected-4">expected</a> to use a presentation consistent with platform
  conventions for gauges, if any.</p>

  <p class="note">Requirements for what must be depicted in the gauge are
  included in the definition of the <code id="the-meter-element-2:the-meter-element-3"><a href="#the-meter-element">meter</a></code> element.</p>

  <p class="XXX">Need to detail the <a id="the-meter-element-2:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive appearance</a>.</p>

  


  

  <h4 id="the-progress-element-2"><span class="secno">15.5.15</span> The <code id="the-progress-element-2:the-progress-element"><a href="#the-progress-element">progress</a></code> element<a href="#the-progress-element-2" class="self-link"></a></h4>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">progress </c-><c- p="">{</c-> <c- k="">appearance</c-><c- p="">:</c-> auto<c- p="">;</c-> <c- p="">}</c-></code></pre>

  <div data-algorithm="">
  <p>The <code id="the-progress-element-2:the-progress-element-2"><a href="#the-progress-element">progress</a></code> element is a <a id="the-progress-element-2:devolvable-widget" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>. Its
  <a id="the-progress-element-2:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> is <a href="#expected" id="the-progress-element-2:expected">expected</a> to render as an
  <a id="the-progress-element-2:'inline-block'" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box with a <a id="the-progress-element-2:'block-size'" href="https://drafts.csswg.org/css-logical/#propdef-block-size" data-x-internal="'block-size'">'block-size'</a> of '1em' and a
  <a id="the-progress-element-2:'inline-size'" href="https://drafts.csswg.org/css-logical/#propdef-inline-size" data-x-internal="'inline-size'">'inline-size'</a> of '10em', and a <a id="the-progress-element-2:'vertical-align'" href="https://drafts.csswg.org/css2/#propdef-vertical-align" data-x-internal="'vertical-align'">'vertical-align'</a> of '-0.2em'.</p>
  </div>

  

  <p> <img class="extra" width="276" src="/images/sample-progress.png" height="115" alt=""> When this
  element has a <a href="#horizontal-writing-mode" id="the-progress-element-2:horizontal-writing-mode">horizontal writing mode</a>, the element is <a href="#expected" id="the-progress-element-2:expected-2">expected</a> to be
  depicted as a horizontal progress bar. The start is on the right and the end is on the left if
  the <a id="the-progress-element-2:'direction'" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a> property on this element has a <a id="the-progress-element-2:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of 'rtl',
  and with the start on the left and the end on the right otherwise. When this element has a
  <a href="#vertical-writing-mode" id="the-progress-element-2:vertical-writing-mode">vertical writing mode</a>, it is <a href="#expected" id="the-progress-element-2:expected-3">expected</a> to be depicted as a vertical
  progress bar. The start is on the bottom and the end is on the top if the
  <a id="the-progress-element-2:'direction'-2" href="https://drafts.csswg.org/css-writing-modes/#direction" data-x-internal="'direction'">'direction'</a> property on this element has a <a id="the-progress-element-2:computed-value-2" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of 'rtl', and
  with the start on the top and the end on the bottom otherwise.</p>

  <p>User agents are <a href="#expected" id="the-progress-element-2:expected-4">expected</a> to use a presentation consistent with platform
  conventions for progress bars. In particular, user agents are <a href="#expected" id="the-progress-element-2:expected-5">expected</a> to use
  different presentations for determinate and indeterminate progress bars. User agents are also
  <a href="#expected" id="the-progress-element-2:expected-6">expected</a> to vary the presentation based on the dimensions of the element.</p>

  <p class="note">Requirements for how to determine if the progress bar is determinate or
  indeterminate, and what progress a determinate progress bar is to show, are included in the
  definition of the <code id="the-progress-element-2:the-progress-element-3"><a href="#the-progress-element">progress</a></code> element.</p>

  <p class="XXX">Need to detail the <a id="the-progress-element-2:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive appearance</a>.</p>

  


  

  <h4 id="the-select-element-2"><span class="secno">15.5.16</span> The <code id="the-select-element-2:the-select-element"><a href="#the-select-element">select</a></code> element<a href="#the-select-element-2" class="self-link"></a></h4>

  <p>The <code id="the-select-element-2:the-select-element-2"><a href="#the-select-element">select</a></code> element is an <a id="the-select-element-2:element-with-default-preferred-size" href="https://drafts.csswg.org/css-ui/#element-with-default-preferred-size" data-x-internal="element-with-default-preferred-size">element with default preferred size</a>, and
  user agents are <a href="#expected" id="the-select-element-2:expected">expected</a> to apply the <a id="the-select-element-2:'field-sizing'" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a> CSS property to
  <code id="the-select-element-2:the-select-element-3"><a href="#the-select-element">select</a></code> elements.

  </p><p>A <code id="the-select-element-2:the-select-element-4"><a href="#the-select-element">select</a></code> element is either a <dfn data-dfn-for="select" id="list-box" data-export="">list box</dfn> or a <dfn data-dfn-for="select" id="drop-down-box" data-export="">drop-down box</dfn>, depending on its attributes.</p>

  <p>A <code id="the-select-element-2:the-select-element-5"><a href="#the-select-element">select</a></code> element whose <code id="the-select-element-2:attr-select-multiple"><a href="#attr-select-multiple">multiple</a></code>
  attribute is present is <a href="#expected" id="the-select-element-2:expected-2">expected</a> to render as a multi-select <a href="#list-box" id="the-select-element-2:list-box">list
  box</a>.</p>

  <p>A <code id="the-select-element-2:the-select-element-6"><a href="#the-select-element">select</a></code> element whose <code id="the-select-element-2:attr-select-multiple-2"><a href="#attr-select-multiple">multiple</a></code>
  attribute is absent, and whose <a href="#concept-select-size" id="the-select-element-2:concept-select-size">display size</a> is greater
  than 1, is <a href="#expected" id="the-select-element-2:expected-3">expected</a> to render as a single-select <a href="#list-box" id="the-select-element-2:list-box-2">list box</a>.</p>

  <div data-algorithm="">
  <p>When the element renders as a <a href="#list-box" id="the-select-element-2:list-box-3">list box</a>, it is a <a id="the-select-element-2:devolvable-widget" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a>
  <a href="#expected" id="the-select-element-2:expected-4">expected</a> to render as an <a id="the-select-element-2:'inline-block'" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box. The <a id="the-select-element-2:inline-size" href="https://drafts.csswg.org/css-writing-modes/#inline-size" data-x-internal="inline-size">inline
  size</a> of its <a id="the-select-element-2:intrinsic-size" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> is the <a href="#width-of-the-select's-labels" id="the-select-element-2:width-of-the-select's-labels">width of the <code>select</code>'s
  labels</a> plus the width of a scrollbar. The <a id="the-select-element-2:block-size" href="https://drafts.csswg.org/css-writing-modes/#block-size" data-x-internal="block-size">block size</a> of its <a id="the-select-element-2:intrinsic-size-2" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic
  size</a> is determined by the following steps:</p>

  <ol><li>
    <p>If the <a id="the-select-element-2:'field-sizing'-2" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a> property on the element has a <a id="the-select-element-2:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a>
    of <a href="https://drafts.csswg.org/css-ui/#valdef-field-sizing-content" id="the-select-element-2:field-sizing-content" data-x-internal="field-sizing-content">'content'</a>, return the height necessary to contain
    all rows for items.</p>
   </li><li>
    <p>If the <code id="the-select-element-2:attr-select-size"><a href="#attr-select-size">size</a></code> attribute is absent or it has no valid
    value, return the height necessary to contain four rows.</p>
   </li><li>
    <p>Otherwise, return the height necessary to contain as many rows for items as given by the
    element's <a href="#concept-select-size" id="the-select-element-2:concept-select-size-2">display size</a>.</p>
   </li></ol>
  </div>

  <p>A <code id="the-select-element-2:the-select-element-7"><a href="#the-select-element">select</a></code> element whose <code id="the-select-element-2:attr-select-multiple-3"><a href="#attr-select-multiple">multiple</a></code>
  attribute is absent, and whose <a href="#concept-select-size" id="the-select-element-2:concept-select-size-3">display size</a> is 1, is
  <a href="#expected" id="the-select-element-2:expected-5">expected</a> to render as an <a id="the-select-element-2:'inline-block'-2" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> one-line <a href="#drop-down-box" id="the-select-element-2:drop-down-box">drop-down
  box</a>. The <a id="the-select-element-2:inline-size-2" href="https://drafts.csswg.org/css-writing-modes/#inline-size" data-x-internal="inline-size">inline size</a> of its <a id="the-select-element-2:intrinsic-size-3" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> is the
  <a href="#width-of-the-select's-labels" id="the-select-element-2:width-of-the-select's-labels-2">width of the <code>select</code>'s labels</a>. If the <a id="the-select-element-2:'field-sizing'-3" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a>
  property on the element has a <a id="the-select-element-2:computed-value-2" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of
  <a href="https://drafts.csswg.org/css-ui/#valdef-field-sizing-content" id="the-select-element-2:field-sizing-content-2" data-x-internal="field-sizing-content">'content'</a>, the <a id="the-select-element-2:inline-size-3" href="https://drafts.csswg.org/css-writing-modes/#inline-size" data-x-internal="inline-size">inline size</a> of the
  <a id="the-select-element-2:intrinsic-size-4" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> depends on the shown text. The shown text is typically the label of
  an <code id="the-select-element-2:the-option-element"><a href="#the-option-element">option</a></code> of which <a href="#concept-option-selectedness" id="the-select-element-2:concept-option-selectedness">selectedness</a> is
  set to true.</p>

  <div data-algorithm="">
  <p>When the element renders as a <a href="#drop-down-box" id="the-select-element-2:drop-down-box-2">drop-down box</a>, it is a <a id="the-select-element-2:devolvable-widget-2" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable
  widget</a>. Its appearance in the devolved state, as well as its appearance when the
  <a id="the-select-element-2:computed-value-3" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a> of the element's <a id="the-select-element-2:'appearance'" href="https://drafts.csswg.org/css-ui/#appearance-switching" data-x-internal="'appearance'">'appearance'</a> property is
  <code id="the-select-element-2:'menulist-button'"><a data-x-internal="'menulist-button'" href="https://drafts.csswg.org/css-ui/#valdef-appearance-menulist-button">'menulist-button'</a></code>, is that of a drop-down box, including a "drop-down button",
  but not necessarily rendered using a native control of the host operating system. In such a state,
  CSS properties such as <a id="the-select-element-2:'color'" href="https://drafts.csswg.org/css-color/#the-color-property" data-x-internal="'color'">'color'</a>, <a id="the-select-element-2:'background-color'" href="https://drafts.csswg.org/css-backgrounds/#propdef-background-color" data-x-internal="'background-color'">'background-color'</a>, and 'border' should
  not be disregarded (as is generally permissible when rendering an element according to its
  <a id="the-select-element-2:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a>).</p>
  </div>

  <p>In either case (<a href="#list-box" id="the-select-element-2:list-box-4">list box</a> or <a href="#drop-down-box" id="the-select-element-2:drop-down-box-3">drop-down box</a>), the element's items are
  <a href="#expected" id="the-select-element-2:expected-6">expected</a> to be the element's <a href="#concept-select-option-list" id="the-select-element-2:concept-select-option-list">list of
  options</a>, with the element's <code id="the-select-element-2:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code> element <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="the-select-element-2:concept-tree-child" data-x-internal="concept-tree-child">children</a> providing headers for groups of options where
  applicable.</p>

  <p><code id="the-select-element-2:the-select-element-8"><a href="#the-select-element">select</a></code> elements which render as a <a href="#drop-down-box" id="the-select-element-2:drop-down-box-4">drop-down box</a> support a <a id="the-select-element-2:base-appearance" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base
  appearance</a> in addition to <a id="the-select-element-2:native-appearance-2" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> and <a id="the-select-element-2:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive
  appearance</a>.</p>

  <p>The <code id="the-select-element-2:the-select-element-9"><a href="#the-select-element">select</a></code> element's <a href="#select-popover" id="the-select-element-2:select-popover">select popover</a> supports a <a id="the-select-element-2:base-appearance-2" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base
  appearance</a> and a <a id="the-select-element-2:native-appearance-3" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a>. The <a href="#select-popover" id="the-select-element-2:select-popover-2">select popover</a> can only
  be rendered with <a id="the-select-element-2:base-appearance-3" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base appearance</a> if its associated <code id="the-select-element-2:the-select-element-10"><a href="#the-select-element">select</a></code> is being
  rendered with <a id="the-select-element-2:base-appearance-4" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base appearance</a>.</p>

  <div data-algorithm="">
  <p>When a <code id="the-select-element-2:the-select-element-11"><a href="#the-select-element">select</a></code> is being rendered as a <a href="#drop-down-box" id="the-select-element-2:drop-down-box-5">drop-down box</a> with <a id="the-select-element-2:base-appearance-5" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base
  appearance</a>, it is <a href="#expected" id="the-select-element-2:expected-7">expected</a> to render with a <a id="the-select-element-2:shadow-tree" href="https://dom.spec.whatwg.org/#concept-shadow-tree" data-x-internal="shadow-tree">shadow tree</a> that
  contains the following elements:</p>

  <ol><li><p>A <dfn id="select-button-slot">select button slot</dfn>, which is a <code id="the-select-element-2:the-slot-element"><a href="#the-slot-element">slot</a></code> element. It is appended to
   the <code id="the-select-element-2:the-select-element-12"><a href="#the-select-element">select</a></code>'s <a id="the-select-element-2:shadow-root" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a> as the first child. It is
   <a href="#expected" id="the-select-element-2:expected-8">expected</a> to take the first child element of the <code id="the-select-element-2:the-select-element-13"><a href="#the-select-element">select</a></code> if the first
   child element is a <code id="the-select-element-2:the-button-element"><a href="#the-button-element">button</a></code>, otherwise the <a href="#select-fallback-button-text" id="the-select-element-2:select-fallback-button-text">select fallback button
   text</a>.</p></li><li><p>A <dfn id="select-fallback-button-text">select fallback button text</dfn>, which is a <code id="the-select-element-2:the-div-element"><a href="#the-div-element">div</a></code> element. It is
   appended to the <a href="#select-button-slot" id="the-select-element-2:select-button-slot">select button slot</a>.</p></li><li><p>A <dfn id="select-popover">select popover</dfn>, which is a <code id="the-select-element-2:the-div-element-2"><a href="#the-div-element">div</a></code> element. It is appended to the
   <code id="the-select-element-2:the-select-element-14"><a href="#the-select-element">select</a></code>'s <a id="the-select-element-2:shadow-root-2" href="https://dom.spec.whatwg.org/#concept-shadow-root" data-x-internal="shadow-root">shadow root</a> as the second child, after the <a href="#select-button-slot" id="the-select-element-2:select-button-slot-2">select button
   slot</a>. The <code id="the-select-element-2:the-select-element-15"><a href="#the-select-element">select</a></code> element's <a id="the-select-element-2:'::picker'" href="https://drafts.csswg.org/css-forms/#the-picker-pseudo-element" data-x-internal="'::picker'">'::picker'</a> pseudo-element is the
   <a href="#select-popover" id="the-select-element-2:select-popover-3">select popover</a>.</p></li><li><p>A <dfn id="select-popover-slot">select popover slot</dfn>, which is a <code id="the-select-element-2:the-slot-element-2"><a href="#the-slot-element">slot</a></code> element. It is appended to
   the <a href="#select-popover" id="the-select-element-2:select-popover-4">select popover</a>. It is <a href="#expected" id="the-select-element-2:expected-9">expected</a> to take all child nodes of the
   <code id="the-select-element-2:the-select-element-16"><a href="#the-select-element">select</a></code> except for the first child <code id="the-select-element-2:the-button-element-2"><a href="#the-button-element">button</a></code>, which is taken by the
   <code id="the-select-element-2:select-button-slot-3"><a href="#select-button-slot">select button slot</a></code>.</p></li></ol>
  </div>

  <p class="note">Since <a id="the-select-element-2:base-appearance-6" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base appearance</a> is determined by computing style, it isn't
  possible to swap this DOM structure when switching appearance. Implementations can always include
  the DOM structure for <a id="the-select-element-2:base-appearance-7" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base appearance</a> when the <code id="the-select-element-2:the-select-element-17"><a href="#the-select-element">select</a></code> is rendered as a
  <a href="#drop-down-box" id="the-select-element-2:drop-down-box-6">drop-down box</a> and then choose to include or exclude it from the layout tree in order
  to control whether it gets rendered or not.</p>

  <p class="note">The <a href="#select-popover" id="the-select-element-2:select-popover-5">select popover</a> is only rendered when it is opted in to <a id="the-select-element-2:base-appearance-8" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base
  appearance</a> separately from the <code id="the-select-element-2:the-select-element-18"><a href="#the-select-element">select</a></code> element. Otherwise, a native picker is
  used.</p>

  <p>The <a href="#select-popover" id="the-select-element-2:select-popover-6">select popover</a>'s <a id="the-select-element-2:implicit-anchor-element" href="https://drafts.csswg.org/css-anchor-position/#implicit-anchor-element" data-x-internal="implicit-anchor-element">implicit anchor element</a> is its associated
  <code id="the-select-element-2:the-select-element-19"><a href="#the-select-element">select</a></code> element.</p>

  <p>When a <code id="the-select-element-2:the-select-element-20"><a href="#the-select-element">select</a></code> element is being rendered with <a id="the-select-element-2:native-appearance-4" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> or
  <a id="the-select-element-2:primitive-appearance-2" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive appearance</a>, the <a id="the-select-element-2:'::picker'-2" href="https://drafts.csswg.org/css-forms/#the-picker-pseudo-element" data-x-internal="'::picker'">'::picker'</a> pseudo-element and the
  <a id="the-select-element-2:'::picker-icon'" href="https://drafts.csswg.org/css-forms/#picker-opener-icon-the-picker-icon-pseudo-element" data-x-internal="'::picker-icon'">'::picker-icon'</a> pseudo-element do not apply.</p>

  <p>The <a id="the-select-element-2:'::picker'-3" href="https://drafts.csswg.org/css-forms/#the-picker-pseudo-element" data-x-internal="'::picker'">'::picker'</a> pseudo-element is not rendered when it has <a id="the-select-element-2:native-appearance-5" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native
  appearance</a> or <a id="the-select-element-2:primitive-appearance-3" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive appearance</a>.</p>

  <p>The <a id="the-select-element-2:'::checkmark'" href="https://drafts.csswg.org/css-forms/#selectordef-checkmark" data-x-internal="'::checkmark'">'::checkmark'</a> pseudo-element only applies to <code id="the-select-element-2:the-option-element-2"><a href="#the-option-element">option</a></code> elements
  which are inside a <code id="the-select-element-2:the-select-element-21"><a href="#the-select-element">select</a></code> element with <a id="the-select-element-2:base-appearance-9" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base appearance</a> whose
  <a id="the-select-element-2:'::picker'-4" href="https://drafts.csswg.org/css-forms/#the-picker-pseudo-element" data-x-internal="'::picker'">'::picker'</a> pseudo-element has <a id="the-select-element-2:base-appearance-10" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base appearance</a>.</p>

  <p>An <code id="the-select-element-2:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code> element is <a href="#expected" id="the-select-element-2:expected-10">expected</a> to be rendered by displaying the
  element's <code id="the-select-element-2:attr-optgroup-label"><a href="#attr-optgroup-label">label</a></code> attribute.</p>

  <p>An <code id="the-select-element-2:the-option-element-3"><a href="#the-option-element">option</a></code> element is <a href="#expected" id="the-select-element-2:expected-11">expected</a> to be rendered by displaying the
  result of <a href="#collect-option-text" id="the-select-element-2:collect-option-text">collect option text</a> given the <code id="the-select-element-2:the-option-element-4"><a href="#the-option-element">option</a></code> and true, indented under
  its <code id="the-select-element-2:the-optgroup-element-3"><a href="#the-optgroup-element">optgroup</a></code> element if it has one. If the <code id="the-select-element-2:the-option-element-5"><a href="#the-option-element">option</a></code> is in a
  <code id="the-select-element-2:the-select-element-22"><a href="#the-select-element">select</a></code> which is being rendered as a <a href="#drop-down-box" id="the-select-element-2:drop-down-box-7">drop-down box</a> with <a id="the-select-element-2:base-appearance-11" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base
  appearance</a>, and the <code id="the-select-element-2:the-select-element-23"><a href="#the-select-element">select</a></code>'s <a href="#select-popover" id="the-select-element-2:select-popover-7">select popover</a> is being rendered
  with <a id="the-select-element-2:base-appearance-12" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base appearance</a>, and the <code id="the-select-element-2:the-option-element-6"><a href="#the-option-element">option</a></code>'s <code id="the-select-element-2:attr-option-label"><a href="#attr-option-label">label</a></code> attribute is not set, then the <code id="the-select-element-2:the-option-element-7"><a href="#the-option-element">option</a></code> is
  <a href="#expected" id="the-select-element-2:expected-12">expected</a> to render all of its children rather than by displaying its <a href="#concept-option-label" id="the-select-element-2:concept-option-label">label</a>.</p>

  <p>Each sequence of one or more child <code id="the-select-element-2:the-hr-element"><a href="#the-hr-element">hr</a></code> element siblings may be rendered as a single
  separator.</p>

  <div data-algorithm="">
  <p>The <dfn id="width-of-the-select's-labels">width of the <code>select</code>'s labels</dfn> is the wider of the width necessary to
  render the widest <code id="the-select-element-2:the-optgroup-element-4"><a href="#the-optgroup-element">optgroup</a></code>, and the width necessary to render the widest
  <code id="the-select-element-2:the-option-element-8"><a href="#the-option-element">option</a></code> element in the element's <a href="#concept-select-option-list" id="the-select-element-2:concept-select-option-list-2">list of
  options</a> (including its indent, if any).</p>
  </div>

  <p>If a <code id="the-select-element-2:the-select-element-24"><a href="#the-select-element">select</a></code> element contains a <a href="#placeholder-label-option" id="the-select-element-2:placeholder-label-option">placeholder label option</a>, the user
  agent is <a href="#expected" id="the-select-element-2:expected-13">expected</a> to render that <code id="the-select-element-2:the-option-element-9"><a href="#the-option-element">option</a></code> in a manner that conveys that
  it is a label, rather than a valid option of the control. This can include preventing the
  <a href="#placeholder-label-option" id="the-select-element-2:placeholder-label-option-2">placeholder label option</a> from being explicitly selected by the user. When the
  <a href="#placeholder-label-option" id="the-select-element-2:placeholder-label-option-3">placeholder label option</a>'s <a href="#concept-option-selectedness" id="the-select-element-2:concept-option-selectedness-2">selectedness</a> is true, the control is
  <a href="#expected" id="the-select-element-2:expected-14">expected</a> to be displayed in a fashion that indicates that no valid option is
  currently selected.</p>

  <p>User agents are <a href="#expected" id="the-select-element-2:expected-15">expected</a> to render the labels in a <code id="the-select-element-2:the-select-element-25"><a href="#the-select-element">select</a></code> in such a
  manner that any alignment remains consistent whether the label is being displayed as part of the
  page or in a menu control.</p>

  <p class="XXX">Need to detail the <a id="the-select-element-2:native-appearance-6" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> and <a id="the-select-element-2:primitive-appearance-4" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive
  appearance</a>.</p>

  

  <p>The following styles are <a href="#expected" id="the-select-element-2:expected-16">expected</a> to apply to <code id="the-select-element-2:the-select-element-26"><a href="#the-select-element">select</a></code> elements when
  they are being rendered as a <a href="#drop-down-box" id="the-select-element-2:drop-down-box-8">drop-down box</a> with <a id="the-select-element-2:base-appearance-13" href="https://drafts.csswg.org/css-ui/#base-appearance" data-x-internal="base-appearance">base appearance</a>:</p>

  <pre><code class="css"><c- n="">@namespace</c-> <c- s="">"http://www.w3.org/1999/xhtml"</c-><c- p="">;</c->

<c- f="">select </c-><c- p="">{</c->
  <c- k="">text-transform</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">text-align</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">text-indent</c-><c- p="">:</c-> initial<c- p="">;</c->
  <c- k="">background-color</c-><c- p="">:</c-> transparent<c- p="">;</c->
  <c- k="">border</c-><c- p="">:</c-> <c- m="">1</c-><c- l="">px</c-> solid currentColor<c- p="">;</c->
  <c- k="">padding-block</c-><c- p="">:</c-> <c- m="">0.25</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">padding-inline</c-><c- p="">:</c-> <c- m="">0.5</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">min-block-size</c-><c- p="">:</c-> <c- nf="">calc-size</c-><c- p="">(</c->auto<c- p="">,</c-> <c- nf="">max</c-><c- p="">(</c->size<c- p="">,</c-> <c- m="">24</c-><c- l="">px</c-><c- p="">,</c-> <c- m="">1</c-><c- l="">lh</c-><c- p="">));</c->
  <c- k="">min-inline-size</c-><c- p="">:</c-> <c- nf="">calc-size</c-><c- p="">(</c->auto<c- p="">,</c-> <c- nf="">max</c-><c- p="">(</c->size<c- p="">,</c-> <c- m="">24</c-><c- l="">px</c-><c- p="">));</c->
  <c- k="">display</c-><c- p="">:</c-> inline-flex<c- p="">;</c->
  <c- k="">gap</c-><c- p="">:</c-> <c- m="">0.5</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">border-radius</c-><c- p="">:</c-> <c- m="">0.5</c-><c- l="">em</c-><c- p="">;</c->
  <c- k="">user-select</c-><c- p="">:</c-> none<c- p="">;</c->
  <c- k="">box-sizing</c-><c- p="">:</c-> border-box<c- p="">;</c->
  <c- k="">field-sizing</c-><c- p="">:</c-> content !important;
}

select &gt; button:first-child {
  all: unset;
  display: contents;
}

select:enabled:hover,
select option:enabled:hover {
  background-color: color-mix(in lab, currentColor 10%, transparent);
}
select:enabled:active,
select option:enabled:active {
  background-color: color-mix(in lab, currentColor 20%, transparent);
}
select:disabled,
select option:disabled {
  color: color-mix(in lab, currentColor 50%, transparent);
}

::picker(select) {
  box-sizing: border-box;
  border: 1px solid;
  padding: 0;
  color: CanvasText;
  background-color: Canvas;
  margin: 0;
  inset: auto;
  min-inline-size: anchor-size(self-inline);
  max-block-size: stretch;
  overflow: auto;
  position-area: block-end span-inline-end;
  position-try-order: most-block-size;
  position-try-fallbacks:
    block-start span-inline-end,
    block-end span-inline-start,
    block-start span-inline-start;
}

select option {
  min-inline-size: 24px;
  min-block-size: max(24px, 1lh);
  padding-inline: 0.5em;
  padding-block-end: 0;
  display: flex;
  align-items: center;
  gap: 0.5em;
  white-space: nowrap;
}

select option::checkmark {
  content: '\2713' / '';
}
select option:not(:checked)::checkmark {
  visibility: hidden;
}

select::picker-icon {
  content: counter(fake-counter-name, disclosure-open);
  display: block;
  margin-inline-start: auto;
}

select optgroup {
  font-weight: bolder;
}

select optgroup option {
  font-weight: normal;
}

select optgroup legend {
  padding-inline: 0.5em;
  min-block-size: 1lh;
}</code></pre>

  

  <h4 id="the-textarea-element-2"><span class="secno">15.5.17</span> The <code id="the-textarea-element-2:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> element<a href="#the-textarea-element-2" class="self-link"></a></h4>

  <div data-algorithm="">
  <p>The <code id="the-textarea-element-2:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> element is a <a id="the-textarea-element-2:devolvable-widget" href="https://drafts.csswg.org/css-ui/#devolvable" data-x-internal="devolvable-widget">devolvable widget</a> <a href="#expected" id="the-textarea-element-2:expected">expected</a> to
  render as an <a id="the-textarea-element-2:'inline-block'" href="https://drafts.csswg.org/css2/#value-def-inline-block" data-x-internal="'inline-block'">'inline-block'</a> box depicting a multiline text control. If this
  multiline text control provides a selection, then, when the user changes the current selection,
  the user agent is <a href="#expected" id="the-textarea-element-2:expected-2">expected</a> to <a href="#queue-an-element-task" id="the-textarea-element-2:queue-an-element-task">queue an element task</a> on the <a href="#user-interaction-task-source" id="the-textarea-element-2:user-interaction-task-source">user
  interaction task source</a> given the <code id="the-textarea-element-2:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code> element to <a href="https://dom.spec.whatwg.org/#concept-event-fire" id="the-textarea-element-2:concept-event-fire" data-x-internal="concept-event-fire">fire an event</a> named <code id="the-textarea-element-2:event-select"><a href="#event-select">select</a></code>
  at the element, with the <code id="the-textarea-element-2:dom-event-bubbles"><a data-x-internal="dom-event-bubbles" href="https://dom.spec.whatwg.org/#dom-event-bubbles">bubbles</a></code> attribute initialized to
  true.</p>
  </div>

  <p>The <code id="the-textarea-element-2:the-textarea-element-4"><a href="#the-textarea-element">textarea</a></code> element is an <a id="the-textarea-element-2:element-with-default-preferred-size" href="https://drafts.csswg.org/css-ui/#element-with-default-preferred-size" data-x-internal="element-with-default-preferred-size">element with default preferred size</a>, and
  user agents are <a href="#expected" id="the-textarea-element-2:expected-3">expected</a> to apply the <a id="the-textarea-element-2:'field-sizing'" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a> CSS property to
  <code id="the-textarea-element-2:the-textarea-element-5"><a href="#the-textarea-element">textarea</a></code> elements.

  </p><p>If the <a id="the-textarea-element-2:'field-sizing'-2" href="https://drafts.csswg.org/css-ui/#field-sizing" data-x-internal="'field-sizing'">'field-sizing'</a> property on the element has a <a id="the-textarea-element-2:computed-value" href="https://drafts.csswg.org/css-cascade/#computed-value" data-x-internal="computed-value">computed value</a>
  of <a href="https://drafts.csswg.org/css-ui/#valdef-field-sizing-content" id="the-textarea-element-2:field-sizing-content" data-x-internal="field-sizing-content">'content'</a>, the <a id="the-textarea-element-2:intrinsic-size" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> is
  determined from the text which the element shows. The text is either a
  <a href="#concept-textarea-raw-value" id="the-textarea-element-2:concept-textarea-raw-value">raw value</a> or a short hint specified by the
  <code id="the-textarea-element-2:attr-textarea-placeholder"><a href="#attr-textarea-placeholder">placeholder</a></code> attribute. User agents may take the
  text caret size into account in the <a id="the-textarea-element-2:intrinsic-size-2" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a>. Otherwise, its
  <a id="the-textarea-element-2:intrinsic-size-3" href="https://drafts.csswg.org/css-sizing/#intrinsic-size" data-x-internal="intrinsic-size">intrinsic size</a> is computed from <a href="#textarea-effective-width" id="the-textarea-element-2:textarea-effective-width">textarea effective width</a> and
  <a href="#textarea-effective-height" id="the-textarea-element-2:textarea-effective-height">textarea effective height</a> (as defined below).</p>

  <div data-algorithm="">
  <p>The <dfn id="textarea-effective-width">textarea effective width</dfn> of a <code id="the-textarea-element-2:the-textarea-element-6"><a href="#the-textarea-element">textarea</a></code> element is <span><var>size</var>×<var>avg</var>&nbsp;+&nbsp;<var>sbw</var></span>, where
  <var>size</var> is the element's <a href="#attr-textarea-cols-value" id="the-textarea-element-2:attr-textarea-cols-value">character width</a>,
  <var>avg</var> is the average character width of the primary font of the element, in <a href="https://drafts.csswg.org/css-values/#px" id="the-textarea-element-2:'px'" data-x-internal="'px'">CSS pixels</a>, and <var>sbw</var> is the width of a scrollbar, in <a href="https://drafts.csswg.org/css-values/#px" id="the-textarea-element-2:'px'-2" data-x-internal="'px'">CSS pixels</a>. (The element's <a id="the-textarea-element-2:'letter-spacing'" href="https://drafts.csswg.org/css-text/#letter-spacing-property" data-x-internal="'letter-spacing'">'letter-spacing'</a> property does not
  affect the result.)</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn id="textarea-effective-height">textarea effective height</dfn> of a <code id="the-textarea-element-2:the-textarea-element-7"><a href="#the-textarea-element">textarea</a></code> element is the height in
  <a href="https://drafts.csswg.org/css-values/#px" id="the-textarea-element-2:'px'-3" data-x-internal="'px'">CSS pixels</a> of the number of lines given by the element's <a href="#attr-textarea-rows-value" id="the-textarea-element-2:attr-textarea-rows-value">character height</a>, plus the height of a scrollbar in <a href="https://drafts.csswg.org/css-values/#px" id="the-textarea-element-2:'px'-4" data-x-internal="'px'">CSS pixels</a>.</p>
  </div>

  <p>User agents are <a href="#expected" id="the-textarea-element-2:expected-4">expected</a> to apply the <a id="the-textarea-element-2:'white-space'" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> CSS property to
  <code id="the-textarea-element-2:the-textarea-element-8"><a href="#the-textarea-element">textarea</a></code> elements. For historical reasons, if the element has a <code id="the-textarea-element-2:attr-textarea-wrap"><a href="#attr-textarea-wrap">wrap</a></code> attribute whose value is an <a id="the-textarea-element-2:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for the string "<code>off</code>", then the user agent is <a href="#expected" id="the-textarea-element-2:expected-5">expected</a> to treat the attribute as a
  <a href="#presentational-hints" id="the-textarea-element-2:presentational-hints">presentational hint</a> setting the element's
  <a id="the-textarea-element-2:'white-space'-2" href="https://drafts.csswg.org/css-text/#white-space-property" data-x-internal="'white-space'">'white-space'</a> property to 'pre'.</p>

  <p class="XXX">Need to detail the <a id="the-textarea-element-2:native-appearance" href="https://drafts.csswg.org/css-ui/#native-appearance" data-x-internal="native-appearance">native appearance</a> and <a id="the-textarea-element-2:primitive-appearance" href="https://drafts.csswg.org/css-ui/#primitive-appearance" data-x-internal="primitive-appearance">primitive
  appearance</a>.</p>

  



  

  <h3 id="frames-and-framesets"><span class="secno">15.6</span> Frames and framesets<a href="#frames-and-framesets" class="self-link"></a></h3>

  <div data-algorithm="">
  <p>User agents are <a href="#expected" id="frames-and-framesets:expected">expected</a> to render <code id="frames-and-framesets:frameset"><a href="#frameset">frameset</a></code> elements as a box with
  the height and width of the <a id="frames-and-framesets:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>, with a surface rendered according to the
  following layout algorithm:</p>

  <ol><li>
    <p>The <var>cols</var> and <var>rows</var> variables are lists of zero or more pairs consisting
    of a number and a unit, the unit being one of <i>percentage</i>, <i>relative</i>, and
    <i>absolute</i>.</p>

    <p>Use the <a href="#rules-for-parsing-a-list-of-dimensions" id="frames-and-framesets:rules-for-parsing-a-list-of-dimensions">rules for parsing a list of dimensions</a> to parse the value of the
    element's <code>cols</code> attribute, if there is one.
    Let <var>cols</var> be the result, or an empty list if there is no such attribute.</p>

    <p>Use the <a href="#rules-for-parsing-a-list-of-dimensions" id="frames-and-framesets:rules-for-parsing-a-list-of-dimensions-2">rules for parsing a list of dimensions</a> to parse the value of the
    element's <code>rows</code> attribute, if there is one.
    Let <var>rows</var> be the result, or an empty list if there is no such attribute.</p>
   </li><li>
    <p>For any of the entries in <var>cols</var> or <var>rows</var> that have the number zero and
    the unit <i>relative</i>, change the entry's number to one.</p>
   </li><li>
    <p>If <var>cols</var> has no entries, then add a single entry consisting of the value 1 and the
    unit <i>relative</i> to <var>cols</var>.</p>

    <p>If <var>rows</var> has no entries, then add a single entry consisting of the value 1 and the
    unit <i>relative</i> to <var>rows</var>.</p>
   </li><li>
    <p>Invoke the algorithm defined below to <a href="#convert-a-list-of-dimensions-to-a-list-of-pixel-values" id="frames-and-framesets:convert-a-list-of-dimensions-to-a-list-of-pixel-values">convert a list of dimensions to a list of pixel
    values</a> using <var>cols</var> as the input list, and the width of the surface that the
    <code id="frames-and-framesets:frameset-2"><a href="#frameset">frameset</a></code> is being rendered into, in <a href="https://drafts.csswg.org/css-values/#px" id="frames-and-framesets:'px'" data-x-internal="'px'">CSS pixels</a>, as the
    input dimension. Let <var>sized cols</var> be the resulting list.</p>

    <p>Invoke the algorithm defined below to <a href="#convert-a-list-of-dimensions-to-a-list-of-pixel-values" id="frames-and-framesets:convert-a-list-of-dimensions-to-a-list-of-pixel-values-2">convert a list of dimensions to a list of pixel
    values</a> using <var>rows</var> as the input list, and the height of the surface that the
    <code id="frames-and-framesets:frameset-3"><a href="#frameset">frameset</a></code> is being rendered into, in <a href="https://drafts.csswg.org/css-values/#px" id="frames-and-framesets:'px'-2" data-x-internal="'px'">CSS pixels</a>, as the
    input dimension. Let <var>sized rows</var> be the resulting list.</p>
   </li><li>
    <p>Split the surface into a grid of <var>w</var>×<var>h</var>
    rectangles, where <var>w</var> is the number of entries in <var>sized cols</var> and
    <var>h</var> is the number of entries in <var>sized rows</var>.</p>

    <p>Size the columns so that each column in the grid is as many <a href="https://drafts.csswg.org/css-values/#px" id="frames-and-framesets:'px'-3" data-x-internal="'px'">CSS
    pixels</a> wide as the corresponding entry in the <var>sized cols</var> list.</p>

    <p>Size the rows so that each row in the grid is as many <a href="https://drafts.csswg.org/css-values/#px" id="frames-and-framesets:'px'-4" data-x-internal="'px'">CSS pixels</a>
    high as the corresponding entry in the <var>sized rows</var> list.</p>
   </li><li>
    <p>Let <var>children</var> be the list of <code id="frames-and-framesets:frame"><a href="#frame">frame</a></code> and <code id="frames-and-framesets:frameset-4"><a href="#frameset">frameset</a></code> elements
    that are <a href="https://dom.spec.whatwg.org/#concept-tree-child" id="frames-and-framesets:concept-tree-child" data-x-internal="concept-tree-child">children</a> of the <code id="frames-and-framesets:frameset-5"><a href="#frameset">frameset</a></code> element
    for which the algorithm was invoked.</p>
   </li><li>
    <p>For each row of the grid of rectangles created in the previous step, from top to bottom, run
    these substeps:</p>

    <ol><li>
      <p>For each rectangle in the row, from left to right, run these substeps:</p>

      <ol><li>
        <p>If there are any elements left in <var>children</var>, take the first element in the
        list, and assign it to the rectangle.</p>

        <p>If this is a <code id="frames-and-framesets:frameset-6"><a href="#frameset">frameset</a></code> element, then recurse the entire <code id="frames-and-framesets:frameset-7"><a href="#frameset">frameset</a></code>
        layout algorithm for that <code id="frames-and-framesets:frameset-8"><a href="#frameset">frameset</a></code> element, with the rectangle as the
        surface.</p>

        <p>Otherwise, it is a <code id="frames-and-framesets:frame-2"><a href="#frame">frame</a></code> element; render its <a href="#content-navigable" id="frames-and-framesets:content-navigable">content
        navigable</a>, positioned and sized to fit the rectangle.</p>
       </li><li>
        <p>If there are any elements left in <var>children</var>, remove the first element from
        <var>children</var>.</p>
       </li></ol>
     </li></ol>
   </li><li>
    <p>If the <code id="frames-and-framesets:frameset-9"><a href="#frameset">frameset</a></code> element <a href="#has-a-border" id="frames-and-framesets:has-a-border">has a border</a>, draw an outer set of borders
    around the rectangles, using the element's <a href="#frame-border-colour" id="frames-and-framesets:frame-border-colour">frame border color</a>.</p>

    <p>For each rectangle, if there is an element assigned to that rectangle, and that element
    <a href="#has-a-border" id="frames-and-framesets:has-a-border-2">has a border</a>, draw an inner set of borders around that rectangle, using the
    element's <a href="#frame-border-colour" id="frames-and-framesets:frame-border-colour-2">frame border color</a>.</p>

    <p>For each (visible) border that does not abut a rectangle that is assigned a
    <code id="frames-and-framesets:frame-3"><a href="#frame">frame</a></code> element with a <code>noresize</code>
    attribute (including rectangles in further nested <code id="frames-and-framesets:frameset-10"><a href="#frameset">frameset</a></code> elements), the user
    agent is <a href="#expected" id="frames-and-framesets:expected-2">expected</a> to allow the user to move the border, resizing the rectangles
    within, keeping the proportions of any nested <code id="frames-and-framesets:frameset-11"><a href="#frameset">frameset</a></code> grids.</p>

    <p>A <code id="frames-and-framesets:frameset-12"><a href="#frameset">frameset</a></code> or <code id="frames-and-framesets:frame-4"><a href="#frame">frame</a></code> element <dfn id="has-a-border">has a border</dfn> if the
    following algorithm returns true:</p>

    <ol><li><p>If the element has a <code>frameborder</code> attribute whose value is not the
     empty string and whose first character is either a U+0031 DIGIT ONE (1) character, a U+0079
     LATIN SMALL LETTER Y character (y), or a U+0059 LATIN CAPITAL LETTER Y character (Y), then
     return true.</p></li><li><p>Otherwise, if the element has a <code>frameborder</code> attribute, return
     false.</p></li><li><p>Otherwise, if the element has a parent element that is a <code id="frames-and-framesets:frameset-13"><a href="#frameset">frameset</a></code> element,
     then return true if <em>that</em> element <a href="#has-a-border" id="frames-and-framesets:has-a-border-3">has a border</a>, and false if it does
     not.</p></li><li><p>Otherwise, return true.</p></li></ol>

    <p>The <dfn id="frame-border-colour">frame border color</dfn> of a
    <code id="frames-and-framesets:frameset-14"><a href="#frameset">frameset</a></code> or <code id="frames-and-framesets:frame-5"><a href="#frame">frame</a></code> element is the color obtained from the following
    algorithm:</p>

    <ol><li><p>If the element has a <code>bordercolor</code> attribute, and applying the
     <a href="#rules-for-parsing-a-legacy-colour-value" id="frames-and-framesets:rules-for-parsing-a-legacy-colour-value">rules for parsing a legacy color value</a> to that attribute's value does not return
     failure, then return the color so obtained.</p></li><li><p>Otherwise, if the element has a parent element that is a <code id="frames-and-framesets:frameset-15"><a href="#frameset">frameset</a></code> element,
     then return the <a href="#frame-border-colour" id="frames-and-framesets:frame-border-colour-3">frame border color</a> of that element.</p>

     </li><li><p>Otherwise, return gray.</p></li></ol>
   </li></ol>
  </div>

  <div data-algorithm="">
  <p>The algorithm to <dfn id="convert-a-list-of-dimensions-to-a-list-of-pixel-values">convert a list of dimensions to a list of pixel values</dfn> consists of
  the following steps:</p>

  <ol><li>
    <p>Let <var>input list</var> be the list of numbers and units passed to the algorithm.</p>

    <p>Let <var>output list</var> be a list of numbers the same length as <var>input list</var>, all
    zero.</p>

    <p>Entries in <var>output list</var> correspond to the entries in <var>input list</var> that
    have the same position.</p>
   </li><li><p>Let <var>input dimension</var> be the size passed to the algorithm.</p>

   </li><li>
    <p>Let <var>total percentage</var> be the sum of all the numbers in <var>input list</var> whose
    unit is <i>percentage</i>.</p>

    <p>Let <var>total relative</var> be the sum of all the numbers in <var>input list</var> whose
    unit is <i>relative</i>.</p>

    <p>Let <var>total absolute</var> be the sum of all the numbers in <var>input list</var> whose
    unit is <i>absolute</i>.</p>

    <p>Let <var>remaining space</var> be the value of <var>input dimension</var>.</p>
   </li><li>
    <p>If <var>total absolute</var> is greater than <var>remaining space</var>, then for each entry
    in <var>input list</var> whose unit is <i>absolute</i>, set the corresponding value in
    <var>output list</var> to the number of the entry in <var>input list</var> multiplied by
    <var>remaining space</var> and divided by <var>total absolute</var>. Then, set <var>remaining
    space</var> to zero.</p>

    <p>Otherwise, for each entry in <var>input list</var> whose unit is <i>absolute</i>, set the
    corresponding value in <var>output list</var> to the number of the entry in <var>input
    list</var>. Then, decrement <var>remaining space</var> by <var>total absolute</var>.</p>
   </li><li>
    <p>If <var>total percentage</var> multiplied by the <var>input dimension</var> and divided by
    100 is greater than <var>remaining space</var>, then for each entry in <var>input list</var>
    whose unit is <i>percentage</i>, set the corresponding value in <var>output list</var> to the
    number of the entry in <var>input list</var> multiplied by <var>remaining space</var> and
    divided by <var>total percentage</var>. Then, set <var>remaining space</var> to zero.</p>

    <p>Otherwise, for each entry in <var>input list</var> whose unit is <i>percentage</i>, set the
    corresponding value in <var>output list</var> to the number of the entry in <var>input
    list</var> multiplied by the <var>input dimension</var> and divided by 100. Then, decrement
    <var>remaining space</var> by <var>total percentage</var> multiplied by the <var>input
    dimension</var> and divided by 100.</p>
   </li><li>
    <p>For each entry in <var>input list</var> whose unit is <i>relative</i>, set the corresponding
    value in <var>output list</var> to the number of the entry in <var>input list</var> multiplied
    by <var>remaining space</var> and divided by <var>total relative</var>.</p>
   </li><li><p>Return <var>output list</var>.</p></li></ol>
  </div>

  <p>User agents working with integer values for frame widths (as opposed to user agents that can
  lay frames out with subpixel accuracy) are <a href="#expected" id="frames-and-framesets:expected-3">expected</a> to distribute the remainder
  first to the last entry whose unit is <i>relative</i>, then equally (not proportionally) to each
  entry whose unit is <i>percentage</i>, then equally (not proportionally) to each entry whose unit
  is <i>absolute</i>, and finally, failing all else, to the last entry.</p>

  <hr>



  <p>The contents of a <code id="frames-and-framesets:frame-6"><a href="#frame">frame</a></code> element that does not have a <code id="frames-and-framesets:frameset-16"><a href="#frameset">frameset</a></code> parent
  are <a href="#expected" id="frames-and-framesets:expected-4">expected</a> to be rendered as <a id="frames-and-framesets:transparent-black" href="https://drafts.csswg.org/css-color/#transparent-black" data-x-internal="transparent-black">transparent black</a>; the user agent is
  <a href="#expected" id="frames-and-framesets:expected-5">expected</a> to not render its <a href="#content-navigable" id="frames-and-framesets:content-navigable-2">content navigable</a> in this case, and its
  <a href="#content-navigable" id="frames-and-framesets:content-navigable-3">content navigable</a> is <a href="#expected" id="frames-and-framesets:expected-6">expected</a> to have a <a id="frames-and-framesets:viewport-2" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a> with zero
  width and zero height.</p>

  


  

  <h3 id="interactive-media"><span class="secno">15.7</span> Interactive media<a href="#interactive-media" class="self-link"></a></h3>

  <h4 id="links,-forms,-and-navigation"><span class="secno">15.7.1</span> Links, forms, and navigation<a href="#links,-forms,-and-navigation" class="self-link"></a></h4>

  <p>User agents are <a href="#expected" id="links,-forms,-and-navigation:expected">expected</a> to allow the user to control aspects of
  <a href="#hyperlink" id="links,-forms,-and-navigation:hyperlink">hyperlink</a> activation and <a href="#form-submission-2" id="links,-forms,-and-navigation:form-submission-2">form submission</a>, such as which
  <a href="#navigable" id="links,-forms,-and-navigation:navigable">navigable</a> is to be used for the subsequent <a href="#navigate" id="links,-forms,-and-navigation:navigate">navigation</a>.</p>

  <p>User agents are <a href="#expected" id="links,-forms,-and-navigation:expected-2">expected</a> to allow users to discover the destination of <a href="#hyperlink" id="links,-forms,-and-navigation:hyperlink-2">hyperlinks</a> and of <a href="#the-form-element" id="links,-forms,-and-navigation:the-form-element">forms</a> before triggering their
  <a href="#navigate" id="links,-forms,-and-navigation:navigate-2">navigation</a>.</p>

  <p>User agents are <a href="#expected" id="links,-forms,-and-navigation:expected-3">expected</a> to inform the user of whether a <a href="#hyperlink" id="links,-forms,-and-navigation:hyperlink-3">hyperlink</a>
  includes <a href="#hyperlink-auditing" id="links,-forms,-and-navigation:hyperlink-auditing">hyperlink auditing</a>, and to let them know at a minimum which domains will be
  contacted as part of such auditing.</p>

  <p>User agents may allow users to <a href="#navigate" id="links,-forms,-and-navigation:navigate-3">navigate</a> <a href="#navigable" id="links,-forms,-and-navigation:navigable-2">navigables</a> to the URLs <a href="#encoding-parsing-a-url" id="links,-forms,-and-navigation:encoding-parsing-a-url">indicated</a> by the <code>cite</code> attributes on <code id="links,-forms,-and-navigation:the-q-element"><a href="#the-q-element">q</a></code>,
  <code id="links,-forms,-and-navigation:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code>, <code id="links,-forms,-and-navigation:the-ins-element"><a href="#the-ins-element">ins</a></code>, and <code id="links,-forms,-and-navigation:the-del-element"><a href="#the-del-element">del</a></code> elements.</p>

  <p>User agents may surface <a href="#hyperlink" id="links,-forms,-and-navigation:hyperlink-4">hyperlinks</a> created by <code id="links,-forms,-and-navigation:the-link-element"><a href="#the-link-element">link</a></code>
  elements in their user interface, as discussed <a href="#providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element">previously</a>.</p>




  <h4 id="the-title-attribute-2"><span class="secno">15.7.2</span> The <code id="the-title-attribute-2:attr-title"><a href="#attr-title">title</a></code> attribute<a href="#the-title-attribute-2" class="self-link"></a></h4>

  <p>User agents are <a href="#expected" id="the-title-attribute-2:expected">expected</a> to expose the <a href="#advisory-information" id="the-title-attribute-2:advisory-information">advisory information</a> of
  elements upon user request, and to make the user aware of the presence of such information.</p>

  <p>On interactive graphical systems where the user can use a pointing device, this could take the
  form of a tooltip. When the user is unable to use a pointing device, then the user agent is
  <a href="#expected" id="the-title-attribute-2:expected-2">expected</a> to make the content available in some other fashion, e.g. by making the
  element a <a href="#focusable-area" id="the-title-attribute-2:focusable-area">focusable area</a> and always displaying the <a href="#advisory-information" id="the-title-attribute-2:advisory-information-2">advisory information</a>
  of the currently <a href="#focused" id="the-title-attribute-2:focused">focused</a> element, or by showing the <a href="#advisory-information" id="the-title-attribute-2:advisory-information-3">advisory
  information</a> of the elements under the user's finger on a touch device as the user pans
  around the screen.</p>

  <p>U+000A LINE FEED (LF) characters are <a href="#expected" id="the-title-attribute-2:expected-3">expected</a> to cause line breaks in the
  tooltip; U+0009 CHARACTER TABULATION (tab) characters are <a href="#expected" id="the-title-attribute-2:expected-4">expected</a> to render as a
  nonzero horizontal shift that lines up the next glyph with the next tab stop, with tab stops
  occurring at points that are multiples of 8 times the width of a U+0020 SPACE character.</p>

  <div class="example">

   <p>For example, a visual user agent could make elements with a <code id="the-title-attribute-2:attr-title-2"><a href="#attr-title">title</a></code> attribute <a href="#focusable" id="the-title-attribute-2:focusable">focusable</a>, and could make
   any <a href="#focused" id="the-title-attribute-2:focused-2">focused</a> element with a <code id="the-title-attribute-2:attr-title-3"><a href="#attr-title">title</a></code> attribute
   show its tooltip under the element while the element has focus. This would allow a user to tab
   around the document to find all the advisory text.</p>

  </div>

  <div class="example">

   <p>As another example, a screen reader could provide an audio cue when reading an element with a
   tooltip, with an associated key to read the last tooltip for which a cue was played.</p>

  </div>


  <h4 id="editing-hosts"><span class="secno">15.7.3</span> Editing hosts<a href="#editing-hosts" class="self-link"></a></h4>

  <p>The current text editing caret (i.e. the <a id="editing-hosts:active-range" href="https://w3c.github.io/editing/docs/execCommand/#active-range" data-x-internal="active-range">active range</a>, if it is empty and in an
  <a href="#editing-host" id="editing-hosts:editing-host">editing host</a>), if any, is <a href="#expected" id="editing-hosts:expected">expected</a> to act like an inline
  <a id="editing-hosts:replaced-element" href="https://drafts.csswg.org/css-display/#replaced-element" data-x-internal="replaced-element">replaced element</a> with the vertical dimensions of the caret and with zero width for
  the purposes of the CSS rendering model.</p>

  <p class="note">This means that even an empty block can have the caret inside it, and that when
  the caret is in such an element, it prevents <a href="https://drafts.csswg.org/css2/#collapsing-margins" id="editing-hosts:collapsing-margins" data-x-internal="collapsing-margins">margins from
  collapsing</a> through the element.</p>



  <h4 id="text-rendered-in-native-user-interfaces"><span class="secno">15.7.4</span> Text rendered in native user interfaces<a href="#text-rendered-in-native-user-interfaces" class="self-link"></a></h4>

  <p>User agents are <a href="#expected" id="text-rendered-in-native-user-interfaces:expected">expected</a> to honor the Unicode semantics of text that is exposed
  in user interfaces, for example supporting the bidirectional algorithm in text shown in dialogs,
  title bars, popup menus, and tooltips. Text from the contents of elements is
  <a href="#expected" id="text-rendered-in-native-user-interfaces:expected-2">expected</a> to be rendered in a manner that honors <a href="#the-directionality" id="text-rendered-in-native-user-interfaces:the-directionality">the directionality</a> of
  the element from which the text was obtained. Text from attributes is <a href="#expected" id="text-rendered-in-native-user-interfaces:expected-3">expected</a> to be
  rendered in a manner that honours the <a href="#directionality-of-the-attribute" id="text-rendered-in-native-user-interfaces:directionality-of-the-attribute">directionality of the attribute</a>.</p>

  <div class="example">

   <p>Consider the following markup, which has Hebrew text asking for a programming language, the
   languages being text for which a left-to-right direction is important given the punctuation in
   some of their names:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">p</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">"rtl"</c-> <c- e="">lang</c-><c- o="">=</c-><c- s="">"he"</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">label</c-><c- p="">&gt;</c->
  <span dir="rtl" lang="he">בחר שפת תכנות:</span>
  <c- p="">&lt;</c-><c- f="">select</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">"ltr"</c-><c- p="">&gt;</c->C++<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">"ltr"</c-><c- p="">&gt;</c->C#<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">"ltr"</c-><c- p="">&gt;</c->FreePascal<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
   <c- p="">&lt;</c-><c- f="">option</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">"ltr"</c-><c- p="">&gt;</c->F#<c- p="">&lt;/</c-><c- f="">option</c-><c- p="">&gt;</c->
  <c- p="">&lt;/</c-><c- f="">select</c-><c- p="">&gt;</c->
 <c- p="">&lt;/</c-><c- f="">label</c-><c- p="">&gt;</c->
<c- p="">&lt;/</c-><c- f="">p</c-><c- p="">&gt;</c-></code></pre>

   <p>If the <code id="text-rendered-in-native-user-interfaces:the-select-element"><a href="#the-select-element">select</a></code> element was rendered as a drop down box, a correct rendering would
   ensure that the punctuation was the same both in the drop down, and in the box showing the
   current selection.</p>

   <p><img src="/images/bidiselect.png" width="206" alt="" height="105"></p> 

  </div>

  <div class="example">

   <p>The directionality of attributes depends on the attribute and on the element's <code id="text-rendered-in-native-user-interfaces:attr-dir"><a href="#attr-dir">dir</a></code> attribute, as the following example demonstrates. Consider this
   markup:</p>

   <pre><code class="html"><bdo dir="ltr"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">abbr</c-><c- o="">=</c-><c- s="">"(א"</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">ltr</c-><c- p="">&gt;</c->A
  <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">abbr</c-><c- o="">=</c-><c- s="">"(א"</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">rtl</c-><c- p="">&gt;</c->A
  <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">abbr</c-><c- o="">=</c-><c- s="">"(א"</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">auto</c-><c- p="">&gt;</c->A
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></bdo></code></pre>

   <p>If the <code id="text-rendered-in-native-user-interfaces:attr-th-abbr"><a href="#attr-th-abbr">abbr</a></code> attributes are rendered, e.g. in a tooltip or
   other user interface, the first will have a left parenthesis (because the direction is 'ltr'),
   the second will have a right parenthesis (because the direction is 'rtl'), and the third will
   have a right parenthesis (because the direction is determined <em>from the attribute value</em>
   to be 'rtl').</p>

   <p>However, if instead the attribute was not a <a href="#directionality-capable-attribute" id="text-rendered-in-native-user-interfaces:directionality-capable-attribute">directionality-capable attribute</a>, the
   results would be different:</p>

   <pre><code class="html"><bdo dir="ltr"><c- p="">&lt;</c-><c- f="">table</c-><c- p="">&gt;</c->
 <c- p="">&lt;</c-><c- f="">tr</c-><c- p="">&gt;</c->
  <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">data-abbr</c-><c- o="">=</c-><c- s="">"(א"</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">ltr</c-><c- p="">&gt;</c->A
  <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">data-abbr</c-><c- o="">=</c-><c- s="">"(א"</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">rtl</c-><c- p="">&gt;</c->A
  <c- p="">&lt;</c-><c- f="">th</c-> <c- e="">data-abbr</c-><c- o="">=</c-><c- s="">"(א"</c-> <c- e="">dir</c-><c- o="">=</c-><c- s="">auto</c-><c- p="">&gt;</c->A
<c- p="">&lt;/</c-><c- f="">table</c-><c- p="">&gt;</c-></bdo></code></pre>

   <p>In this case, if the user agent were to expose the <code>data-abbr</code> attribute
   in the user interface (e.g. in a debugging environment), the last case would be rendered with a
   <em>left</em> parenthesis, because the direction would be determined from the element's
   contents.</p>

  </div>

  <p>A string provided by a script (e.g. the argument to <code id="text-rendered-in-native-user-interfaces:dom-alert"><a href="#dom-alert">window.alert()</a></code>) is <a href="#expected" id="text-rendered-in-native-user-interfaces:expected-4">expected</a> to be treated as an
  independent set of one or more bidirectional algorithm paragraphs when displayed, as defined by
  the bidirectional algorithm, including, for instance, supporting the paragraph-breaking behavior
  of U+000A LINE FEED (LF) characters. For the purposes of determining the paragraph level of such
  text in the bidirectional algorithm, this specification does <em>not</em> provide a higher-level
  override of rules P2 and P3. <a href="#refsBIDI">[BIDI]</a></p>

  <p>When necessary, authors can enforce a particular direction for a given paragraph by starting it
  with the Unicode U+200E LEFT-TO-RIGHT MARK or U+200F RIGHT-TO-LEFT MARK characters.</p>

  <div class="example">

   <p>Thus, the following script:</p>

   <pre><code class="js">alert<c- p="">(</c-><c- t="">'\u05DC\u05DE\u05D3 HTML \u05D4\u05D9\u05D5\u05DD!'</c-><c- p="">)</c-></code></pre>

   <p>...would always result in a message reading
        "<bdo dir="rtl" lang="">למד&nbsp;LMTH&nbsp;היום!</bdo>"
   (not "<bdo dir="ltr" lang="">דמל&nbsp;HTML&nbsp;םויה!</bdo>"),
   regardless of the language of the user agent interface or the
   direction of the page or any of its elements.</p>

  </div>

  <div class="example">

   <p>For a more complex example, consider the following script:</p>

   <pre class="bad"><code class="js"><c- d="">/* Warning: this script does not handle right-to-left scripts correctly */</c->
<c- a="">var</c-> s<c- p="">;</c->
<c- k="">if</c-> <c- p="">(</c->s <c- o="">=</c-> prompt<c- p="">(</c-><c- t="">'What is your name?'</c-><c- p="">))</c-> <c- p="">{</c->
  alert<c- p="">(</c->s <c- o="">+</c-> <c- t="">'! Ok, Fred, '</c-> <c- o="">+</c-> s <c- o="">+</c-> <c- t="">', and Wilma will get the car.'</c-><c- p="">);</c->
<c- p="">}</c-></code></pre>

   <p>When the user enters "<kbd>Kitty</kbd>", the user agent would alert "<samp>Kitty! Ok, Fred,
   Kitty, and Wilma will get the car.</samp>". However, if the user enters "<kbd dir="rtl" lang="ar">لا&nbsp;أفهم</kbd>", then the bidirectional
   algorithm will determine that the direction of the paragraph is right-to-left, and so the output
   will be the following unintended mess: "<samp lang=""><bdo dir="rtl">لا&nbsp;أفهم!&nbsp;derF&nbsp;,kO,&nbsp;لا&nbsp;أفهم,&nbsp;rac&nbsp;eht&nbsp;teg&nbsp;lliw&nbsp;amliW&nbsp;dna.</bdo></samp>"</p>

   <p>To force an alert that starts with user-provided text (or other text of unknown
   directionality) to render left-to-right, the string can be prefixed with a U+200E LEFT-TO-RIGHT
   MARK character:</p>

   <pre><code class="js"><c- a="">var</c-> s<c- p="">;</c->
<c- k="">if</c-> <c- p="">(</c->s <c- o="">=</c-> prompt<c- p="">(</c-><c- t="">'What is your name?'</c-><c- p="">))</c-> <c- p="">{</c->
  alert<c- p="">(</c-><c- t="">'</c-><strong><c- t="">\u200E</c-></strong><c- t="">'</c-> <c- o="">+</c-> s <c- o="">+</c-> <c- t="">'! Ok, Fred, '</c-> <c- o="">+</c-> s <c- o="">+</c-> <c- t="">', and Wilma will get the car.'</c-><c- p="">);</c->
<c- p="">}</c-></code></pre>

  </div>



  <h3 id="print-media"><span class="secno">15.8</span> Print media<a href="#print-media" class="self-link"></a></h3>

  <p>User agents are <a href="#expected" id="print-media:expected">expected</a> to allow the user to request the opportunity to
  <dfn id="obtain-a-physical-form">obtain a physical form</dfn> (or a representation of a physical form) of a
  <code id="print-media:document"><a href="#document">Document</a></code>. For example, selecting the option to print a page or convert it to PDF
  format. <a href="#refsPDF">[PDF]</a></p>

  <p>When the user actually <a href="#obtain-a-physical-form" id="print-media:obtain-a-physical-form">obtains a physical form</a> (or
  a representation of a physical form) of a <code id="print-media:document-2"><a href="#document">Document</a></code>, the user agent is
  <a href="#expected" id="print-media:expected-2">expected</a> to create a new rendering of the <code id="print-media:document-3"><a href="#document">Document</a></code> for the print media.</p>



  <h3 id="unstyled-xml-documents"><span class="secno">15.9</span> Unstyled XML documents<a href="#unstyled-xml-documents" class="self-link"></a></h3>

  

  <p>HTML user agents may, in certain circumstances, find themselves rendering non-HTML documents
  that use vocabularies for which they lack any built-in knowledge. This section provides for a way
  for user agents to handle such documents in a somewhat useful manner.</p>

  <p>While a <code id="unstyled-xml-documents:document"><a href="#document">Document</a></code> is an <a href="#unstyled-document" id="unstyled-xml-documents:unstyled-document">unstyled document</a>, the user agent is
  <a href="#expected" id="unstyled-xml-documents:expected">expected</a> to render <a href="#an-unstyled-document-view" id="unstyled-xml-documents:an-unstyled-document-view">an unstyled document view</a>.</p>

  <div data-algorithm="">
  <p>A <code id="unstyled-xml-documents:document-2"><a href="#document">Document</a></code> is an <dfn id="unstyled-document">unstyled document</dfn> while it matches the following
  conditions:</p>

  <ul><li>The <code id="unstyled-xml-documents:document-3"><a href="#document">Document</a></code> has no author style sheets (whether referenced by HTTP headers, processing instructions, elements like <code id="unstyled-xml-documents:the-link-element"><a href="#the-link-element">link</a></code>, inline elements like <code id="unstyled-xml-documents:the-style-element"><a href="#the-style-element">style</a></code>, or any other mechanism).
   </li><li>None of the elements in the <code id="unstyled-xml-documents:document-4"><a href="#document">Document</a></code> have any <a href="#presentational-hints" id="unstyled-xml-documents:presentational-hints">presentational hints</a>.
   </li><li>None of the elements in the <code id="unstyled-xml-documents:document-5"><a href="#document">Document</a></code> have any <a href="https://drafts.csswg.org/css-style-attr/#style-attribute" id="unstyled-xml-documents:css-styling-attribute" data-x-internal="css-styling-attribute">style attributes</a>.
   </li><li>None of the elements in the <code id="unstyled-xml-documents:document-6"><a href="#document">Document</a></code> are in any of the following namespaces: <a id="unstyled-xml-documents:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML namespace</a>, <a id="unstyled-xml-documents:svg-namespace" href="https://infra.spec.whatwg.org/#svg-namespace" data-x-internal="svg-namespace">SVG namespace</a>, <a id="unstyled-xml-documents:mathml-namespace" href="https://infra.spec.whatwg.org/#mathml-namespace" data-x-internal="mathml-namespace">MathML namespace</a>
   </li><li>The <code id="unstyled-xml-documents:document-7"><a href="#document">Document</a></code> has no <a href="#focusable-area" id="unstyled-xml-documents:focusable-area">focusable area</a> (e.g. from XLink) other than the <a id="unstyled-xml-documents:viewport" href="https://drafts.csswg.org/css2/#viewport" data-x-internal="viewport">viewport</a>.
   </li><li>The <code id="unstyled-xml-documents:document-8"><a href="#document">Document</a></code> has no <a href="#hyperlink" id="unstyled-xml-documents:hyperlink">hyperlinks</a> (e.g. from XLink).
   </li><li>There exists no <a href="#concept-script" id="unstyled-xml-documents:concept-script">script</a> whose <a href="#settings-object" id="unstyled-xml-documents:settings-object">settings object</a>'s <a href="#concept-settings-object-global" id="unstyled-xml-documents:concept-settings-object-global">global object</a> is a <code id="unstyled-xml-documents:window"><a href="#window">Window</a></code> object with
   this <code id="unstyled-xml-documents:document-9"><a href="#document">Document</a></code> as its <a href="#concept-document-window" id="unstyled-xml-documents:concept-document-window">associated
   <code>Document</code></a>.
   </li><li>None of the elements in the <code id="unstyled-xml-documents:document-10"><a href="#document">Document</a></code> have any registered event listeners.
  </li></ul>
  </div>

  <p><dfn id="an-unstyled-document-view">An unstyled document view</dfn> is one where the DOM is not rendered according to CSS
  (which would, since there are no applicable styles in this context, just result in a wall of
  text), but is instead rendered in a manner that is useful for a developer. This could consist of
  just showing the <code id="unstyled-xml-documents:document-11"><a href="#document">Document</a></code> object's source, maybe with syntax highlighting, or it
  could consist of displaying just the DOM tree, or simply a message saying that the page is not a
  styled document.</p>

  <p class="note">If a <code id="unstyled-xml-documents:document-12"><a href="#document">Document</a></code> stops being an <a href="#unstyled-document" id="unstyled-xml-documents:unstyled-document-2">unstyled document</a>, then the
  conditions above stop applying, and thus a user agent following these requirements will switch to
  using the regular CSS rendering.</p>

  




  <h2 id="obsolete"><span class="secno">16</span> Obsolete features<a href="#obsolete" class="self-link"></a></h2>

  <h3 id="obsolete-but-conforming-features"><span class="secno">16.1</span> Obsolete but conforming features<a href="#obsolete-but-conforming-features" class="self-link"></a></h3>

  <p>Features listed in this section will trigger warnings in conformance checkers.</p>

  <p>Authors should not specify a <code id="obsolete-but-conforming-features:attr-img-border"><a href="#attr-img-border">border</a></code> attribute on an
  <code id="obsolete-but-conforming-features:the-img-element"><a href="#the-img-element">img</a></code> element. If the attribute is present, its value must be the string "<code>0</code>". CSS should be used instead.</p>

  <p>Authors should not specify a <code id="obsolete-but-conforming-features:attr-script-charset"><a href="#attr-script-charset">charset</a></code> attribute on a
  <code id="obsolete-but-conforming-features:the-script-element"><a href="#the-script-element">script</a></code> element. If the attribute is present, its value must be an <a id="obsolete-but-conforming-features:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for "<code>utf-8</code>". (This has no effect in a
  document that conforms to the requirements elsewhere in this standard of being encoded as
  <a id="obsolete-but-conforming-features:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>.)</p>

  <p>Authors should not specify a <code id="obsolete-but-conforming-features:attr-script-language"><a href="#attr-script-language">language</a></code> attribute on a
  <code id="obsolete-but-conforming-features:the-script-element-2"><a href="#the-script-element">script</a></code> element. If the attribute is present, its value must be an <a id="obsolete-but-conforming-features:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for the string "<code>JavaScript</code>" and either the
  <code id="obsolete-but-conforming-features:attr-script-type"><a href="#attr-script-type">type</a></code> attribute must be omitted or its value must be an
  <a id="obsolete-but-conforming-features:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code>text/javascript</code>".
  The attribute should be entirely omitted instead (with the value "<code>JavaScript</code>", it has no effect), or replaced with use of the <code id="obsolete-but-conforming-features:attr-script-type-2"><a href="#attr-script-type">type</a></code> attribute.</p>

  <p>Authors should not specify a value for the <code id="obsolete-but-conforming-features:attr-script-type-3"><a href="#attr-script-type">type</a></code>
  attribute on <code id="obsolete-but-conforming-features:the-script-element-3"><a href="#the-script-element">script</a></code> elements that is the empty string or a <a id="obsolete-but-conforming-features:javascript-mime-type-essence-match" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match" data-x-internal="javascript-mime-type-essence-match">JavaScript MIME type
  essence match</a>. Instead, they should omit the attribute, which has the same effect.</p>

  <p>Authors should not specify a <code id="obsolete-but-conforming-features:attr-style-type"><a href="#attr-style-type">type</a></code> attribute on a
  <code id="obsolete-but-conforming-features:the-style-element"><a href="#the-style-element">style</a></code> element. If the attribute is present, its value must be an <a id="obsolete-but-conforming-features:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
  case-insensitive</a> match for "<code id="obsolete-but-conforming-features:text/css"><a href="#text/css">text/css</a></code>".</p>

  <p>Authors should not specify the <code id="obsolete-but-conforming-features:attr-a-name"><a href="#attr-a-name">name</a></code> attribute on
  <code id="obsolete-but-conforming-features:the-a-element"><a href="#the-a-element">a</a></code> elements. If the attribute is present, its value must not be the empty string and
  must neither be equal to the value of any of the <a href="https://dom.spec.whatwg.org/#concept-id" id="obsolete-but-conforming-features:concept-id" data-x-internal="concept-id">IDs</a> in the
  element's <a id="obsolete-but-conforming-features:tree" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a> other than the element's own <a href="https://dom.spec.whatwg.org/#concept-id" id="obsolete-but-conforming-features:concept-id-2" data-x-internal="concept-id">ID</a>, if
  any, nor be equal to the value of any of the other <code id="obsolete-but-conforming-features:attr-a-name-2"><a href="#attr-a-name">name</a></code>
  attributes on <code id="obsolete-but-conforming-features:the-a-element-2"><a href="#the-a-element">a</a></code> elements in the element's <a id="obsolete-but-conforming-features:tree-2" href="https://dom.spec.whatwg.org/#concept-tree" data-x-internal="tree">tree</a>. If this attribute is
  present and the element has an <a href="https://dom.spec.whatwg.org/#concept-id" id="obsolete-but-conforming-features:concept-id-3" data-x-internal="concept-id">ID</a>, then the attribute's value
  must be equal to the element's <a href="https://dom.spec.whatwg.org/#concept-id" id="obsolete-but-conforming-features:concept-id-4" data-x-internal="concept-id">ID</a>. In earlier versions of the
  language, this attribute was intended as a way to specify possible targets for <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="obsolete-but-conforming-features:concept-url-fragment" data-x-internal="concept-url-fragment">fragments</a> in <a href="https://url.spec.whatwg.org/#concept-url" id="obsolete-but-conforming-features:url" data-x-internal="url">URLs</a>. The <code id="obsolete-but-conforming-features:the-id-attribute"><a href="#the-id-attribute">id</a></code> attribute should be used instead.</p>

  
  <p>Authors should not, but may despite requirements to the contrary elsewhere in this
  specification, specify the <code id="obsolete-but-conforming-features:attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code> and <code id="obsolete-but-conforming-features:attr-input-size"><a href="#attr-input-size">size</a></code> attributes on <code id="obsolete-but-conforming-features:the-input-element"><a href="#the-input-element">input</a></code> elements whose <code id="obsolete-but-conforming-features:attr-input-type"><a href="#attr-input-type">type</a></code> attributes are in the <a href="#number-state-(type=number)" id="obsolete-but-conforming-features:number-state-(type=number)">Number</a> state. One valid reason for using these attributes
  regardless is to help legacy user agents that do not support <code id="obsolete-but-conforming-features:the-input-element-2"><a href="#the-input-element">input</a></code> elements with
  <code>type="number"</code> to still render the text control with a useful width.</p>


  

  <h4 id="warnings-for-obsolete-but-conforming-features"><span class="secno">16.1.1</span> Warnings for obsolete but conforming features<a href="#warnings-for-obsolete-but-conforming-features" class="self-link"></a></h4>

  <p>To ease the transition from HTML4 Transitional documents to the language defined in
  <em>this</em> specification, and to discourage certain features that are only allowed in very few
  circumstances, conformance checkers must warn the user when the following features are used in a
  document. These are generally old obsolete features that have no effect, and are allowed only to
  distinguish between likely mistakes (regular conformance errors) and mere vestigial markup or
  unusual and discouraged practices (these warnings).</p>

  <p>The following features must be categorized as described
  above:</p>

  <ul><li><p>The presence of a <code id="warnings-for-obsolete-but-conforming-features:attr-img-border"><a href="#attr-img-border">border</a></code> attribute on an
   <code id="warnings-for-obsolete-but-conforming-features:the-img-element"><a href="#the-img-element">img</a></code> element if its value is the string "<code>0</code>".</p></li><li><p>The presence of a <code id="warnings-for-obsolete-but-conforming-features:attr-script-charset"><a href="#attr-script-charset">charset</a></code> attribute on a
   <code id="warnings-for-obsolete-but-conforming-features:the-script-element"><a href="#the-script-element">script</a></code> element if its value is an <a id="warnings-for-obsolete-but-conforming-features:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
   "<code>utf-8</code>".</p></li><li><p>The presence of a <code id="warnings-for-obsolete-but-conforming-features:attr-script-language"><a href="#attr-script-language">language</a></code> attribute on a
   <code id="warnings-for-obsolete-but-conforming-features:the-script-element-2"><a href="#the-script-element">script</a></code> element if its value is an <a id="warnings-for-obsolete-but-conforming-features:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the
   string "<code>JavaScript</code>" and if there is no <code id="warnings-for-obsolete-but-conforming-features:attr-script-type"><a href="#attr-script-type">type</a></code> attribute or there is and its value is an <a id="warnings-for-obsolete-but-conforming-features:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII
   case-insensitive</a> match for the string "<code>text/javascript</code>".</p></li><li><p>The presence of a <code id="warnings-for-obsolete-but-conforming-features:attr-style-type"><a href="#attr-style-type">type</a></code> attribute on a
   <code id="warnings-for-obsolete-but-conforming-features:the-script-element-3"><a href="#the-script-element">script</a></code> element if its value is a <a id="warnings-for-obsolete-but-conforming-features:javascript-mime-type-essence-match" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match" data-x-internal="javascript-mime-type-essence-match">JavaScript MIME type essence
   match</a>.</p></li><li><p>The presence of a <code id="warnings-for-obsolete-but-conforming-features:attr-style-type-2"><a href="#attr-style-type">type</a></code> attribute on a
   <code id="warnings-for-obsolete-but-conforming-features:the-style-element"><a href="#the-style-element">style</a></code> element if its value is an <a id="warnings-for-obsolete-but-conforming-features:ascii-case-insensitive-4" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for
   "<code id="warnings-for-obsolete-but-conforming-features:text/css"><a href="#text/css">text/css</a></code>".</p></li><li><p>The presence of a <code id="warnings-for-obsolete-but-conforming-features:attr-a-name"><a href="#attr-a-name">name</a></code> attribute on an <code id="warnings-for-obsolete-but-conforming-features:the-a-element"><a href="#the-a-element">a</a></code>
   element, if its value is not the empty string.</p></li><li><p>The presence of a <code id="warnings-for-obsolete-but-conforming-features:attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code> attribute on an
   <code id="warnings-for-obsolete-but-conforming-features:the-input-element"><a href="#the-input-element">input</a></code> element whose <code id="warnings-for-obsolete-but-conforming-features:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the
   <a href="#number-state-(type=number)" id="warnings-for-obsolete-but-conforming-features:number-state-(type=number)">Number</a> state.</p></li><li><p>The presence of a <code id="warnings-for-obsolete-but-conforming-features:attr-input-size"><a href="#attr-input-size">size</a></code> attribute on an
   <code id="warnings-for-obsolete-but-conforming-features:the-input-element-2"><a href="#the-input-element">input</a></code> element whose <code id="warnings-for-obsolete-but-conforming-features:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is in the
   <a href="#number-state-(type=number)" id="warnings-for-obsolete-but-conforming-features:number-state-(type=number)-2">Number</a> state.</p></li></ul>

  <p>Conformance checkers must distinguish between pages that have no conformance errors and have
  none of these obsolete features, and pages that have no conformance errors but do have some of
  these obsolete features.</p>

  <p class="example">For example, a validator could report some pages as "Valid HTML" and others as
  "Valid HTML with warnings".</p>

  


  <h3 id="non-conforming-features"><span class="secno">16.2</span> Non-conforming features<a href="#non-conforming-features" class="self-link"></a></h3>

  <p>Elements in the following list are entirely obsolete, and must not be used by authors:</p>

  <dl><dt><dfn id="applet" data-dfn-type="element"><code>applet</code></dfn></dt><dd><p>Use <code id="non-conforming-features:the-embed-element"><a href="#the-embed-element">embed</a></code> or <code id="non-conforming-features:the-object-element"><a href="#the-object-element">object</a></code> instead.</p></dd><dt><dfn id="acronym" data-dfn-type="element"><code>acronym</code></dfn></dt><dd><p>Use <code id="non-conforming-features:the-abbr-element"><a href="#the-abbr-element">abbr</a></code> instead.</p></dd><dt><dfn id="bgsound" data-dfn-type="element"><code>bgsound</code></dfn></dt><dd><p>Use <code id="non-conforming-features:the-audio-element"><a href="#the-audio-element">audio</a></code> instead.</p></dd><dt><dfn id="dir" data-dfn-type="element"><code>dir</code></dfn></dt><dd><p>Use <code id="non-conforming-features:the-ul-element"><a href="#the-ul-element">ul</a></code> instead.</p></dd><dt><code id="non-conforming-features:frame"><a href="#frame">frame</a></code></dt><dt><code id="non-conforming-features:frameset"><a href="#frameset">frameset</a></code></dt><dt><dfn id="noframes" data-dfn-type="element"><code>noframes</code></dfn></dt><dd><p>Either use <code id="non-conforming-features:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> and CSS instead, or use server-side includes to generate complete pages with the various invariant parts merged in.</p></dd><dt><dfn id="isindex" data-dfn-type="element"><code>isindex</code></dfn></dt><dd><p>Use an explicit <code id="non-conforming-features:the-form-element"><a href="#the-form-element">form</a></code> and <a href="#text-(type=text)-state-and-search-state-(type=search)" id="non-conforming-features:text-(type=text)-state-and-search-state-(type=search)">text control</a> combination instead.</p></dd><dt><dfn id="keygen" data-dfn-type="element"><code>keygen</code></dfn></dt><dd>
    <p>For enterprise device management use cases, use native on-device management capabilities.</p>

    <p>For certificate enrollment use cases, use the Web Cryptography API to generate a keypair for
    the certificate, and then export the certificate and key to allow the user to install them
    manually. <a href="#refsWEBCRYPTO">[WEBCRYPTO]</a></p>
   </dd><dt><dfn id="listing" data-dfn-type="element"><code>listing</code></dfn></dt><dd><p>Use <code id="non-conforming-features:the-pre-element"><a href="#the-pre-element">pre</a></code> and <code id="non-conforming-features:the-code-element"><a href="#the-code-element">code</a></code> instead.</p></dd><dt><dfn id="menuitem" data-dfn-type="element"><code>menuitem</code></dfn></dt><dd><p>To implement a custom context menu, use script to handle the <code id="non-conforming-features:event-contextmenu"><a data-x-internal="event-contextmenu" href="https://w3c.github.io/uievents/#event-type-contextmenu">contextmenu</a></code> event.</p></dd><dt><dfn id="nextid" data-dfn-type="element"><code>nextid</code></dfn></dt><dd><p>Use GUIDs instead.</p></dd><dt><dfn id="noembed" data-dfn-type="element"><code>noembed</code></dfn></dt><dd><p>Use <code id="non-conforming-features:the-object-element-2"><a href="#the-object-element">object</a></code> instead of <code id="non-conforming-features:the-embed-element-2"><a href="#the-embed-element">embed</a></code> when fallback is necessary.</p></dd><dt id="the-param-element"><dfn id="param" data-dfn-type="element"><code>param</code></dfn></dt><dd><p>Use the <code id="non-conforming-features:attr-object-data"><a href="#attr-object-data">data</a></code> attribute of the <code id="non-conforming-features:the-object-element-3"><a href="#the-object-element">object</a></code> element to set the
   URL of the external resource.</p></dd><dt><dfn id="plaintext" data-dfn-type="element"><code>plaintext</code></dfn></dt><dd><p>Use the "<code id="non-conforming-features:text/plain"><a data-x-internal="text/plain" href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3">text/plain</a></code>" <a id="non-conforming-features:mime-type" href="https://mimesniff.spec.whatwg.org/#mime-type" data-x-internal="mime-type">MIME type</a> instead.</p></dd><dt><dfn id="rb" data-dfn-type="element"><code>rb</code></dfn></dt><dt><dfn id="rtc" data-dfn-type="element"><code>rtc</code></dfn></dt><dd><p>Providing the ruby base directly inside the <code id="non-conforming-features:the-ruby-element"><a href="#the-ruby-element">ruby</a></code> element or using nested
   <code id="non-conforming-features:the-ruby-element-2"><a href="#the-ruby-element">ruby</a></code> elements is sufficient.</p></dd><dt><dfn id="strike" data-dfn-type="element"><code>strike</code></dfn></dt><dd><p>Use <code id="non-conforming-features:the-del-element"><a href="#the-del-element">del</a></code> instead if the element is marking an edit, otherwise use <code id="non-conforming-features:the-s-element"><a href="#the-s-element">s</a></code> instead.</p></dd><dt><dfn id="xmp" data-dfn-type="element"><code>xmp</code></dfn></dt><dd><p>Use <code id="non-conforming-features:the-pre-element-2"><a href="#the-pre-element">pre</a></code> and <code id="non-conforming-features:the-code-element-2"><a href="#the-code-element">code</a></code> instead, and escape "<code>&lt;</code>" and "<code>&amp;</code>" characters as "<code>&amp;lt;</code>" and "<code>&amp;amp;</code>" respectively.</p></dd><dt><dfn id="basefont" data-dfn-type="element"><code>basefont</code></dfn></dt><dt><dfn id="big" data-dfn-type="element"><code>big</code></dfn></dt><dt><dfn id="blink" data-dfn-type="element"><code>blink</code></dfn></dt><dt><dfn id="center" data-dfn-type="element"><code>center</code></dfn></dt><dt><dfn id="font" data-dfn-type="element"><code>font</code></dfn></dt><dt><code id="non-conforming-features:the-marquee-element"><a href="#the-marquee-element">marquee</a></code></dt><dt><dfn id="multicol" data-dfn-type="element"><code>multicol</code></dfn></dt><dt><dfn id="nobr" data-dfn-type="element"><code>nobr</code></dfn></dt><dt><dfn id="spacer" data-dfn-type="element"><code>spacer</code></dfn></dt><dt><dfn id="tt" data-dfn-type="element"><code>tt</code></dfn></dt><dd>
    <p>Use appropriate elements or CSS instead.</p>

    <p>Where the <code id="non-conforming-features:tt"><a href="#tt">tt</a></code> element would have been used for marking up keyboard input,
    consider the <code id="non-conforming-features:the-kbd-element"><a href="#the-kbd-element">kbd</a></code> element; for variables, consider the <code id="non-conforming-features:the-var-element"><a href="#the-var-element">var</a></code> element; for
    computer code, consider the <code id="non-conforming-features:the-code-element-3"><a href="#the-code-element">code</a></code> element; and for computer output, consider the
    <code id="non-conforming-features:the-samp-element"><a href="#the-samp-element">samp</a></code> element.</p>

    <p>Similarly, if the <code id="non-conforming-features:big"><a href="#big">big</a></code> element is being used to denote a heading, consider using
    the <code id="non-conforming-features:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code> element; if it is being used for marking up important passages, consider the
    <code id="non-conforming-features:the-strong-element"><a href="#the-strong-element">strong</a></code> element; and if it is being used for highlighting text for reference
    purposes, consider the <code id="non-conforming-features:the-mark-element"><a href="#the-mark-element">mark</a></code> element.</p>

    <p>See also the <a href="#usage-summary">text-level semantics usage summary</a> for more
    suggestions with examples.</p>
   </dd></dl>

  <hr>

  <p>The following attributes are obsolete (though the elements are still part of the language), and
  must not be used by authors:</p>

  <dl><dt><dfn data-dfn-for="a" id="attr-a-charset" data-dfn-type="element-attr"><code>charset</code></dfn> on <code id="non-conforming-features:the-a-element"><a href="#the-a-element">a</a></code> elements</dt><dt><dfn data-dfn-for="link" id="attr-link-charset" data-dfn-type="element-attr"><code>charset</code></dfn> on <code id="non-conforming-features:the-link-element"><a href="#the-link-element">link</a></code> elements</dt><dd><p>Use an HTTP `<code id="non-conforming-features:content-type"><a href="#content-type">Content-Type</a></code>` header on the linked resource instead.</p></dd><dt><dfn data-dfn-for="script" id="attr-script-charset" data-dfn-type="element-attr"><code>charset</code></dfn> on <code id="non-conforming-features:the-script-element"><a href="#the-script-element">script</a></code>
   elements (except as noted in the previous section)</dt><dd><p>Omit the attribute. Both documents and scripts are required to use <a id="non-conforming-features:utf-8" href="https://encoding.spec.whatwg.org/#utf-8" data-x-internal="utf-8">UTF-8</a>, so
   it is redundant to specify it on the <code id="non-conforming-features:the-script-element-2"><a href="#the-script-element">script</a></code> element since it inherits from the
   document.</p></dd><dt><dfn data-dfn-for="a" id="attr-a-coords" data-dfn-type="element-attr"><code>coords</code></dfn> on <code id="non-conforming-features:the-a-element-2"><a href="#the-a-element">a</a></code> elements</dt><dt><dfn data-dfn-for="a" id="attr-a-shape" data-dfn-type="element-attr"><code>shape</code></dfn> on <code id="non-conforming-features:the-a-element-3"><a href="#the-a-element">a</a></code> elements</dt><dd><p>Use <code id="non-conforming-features:the-area-element"><a href="#the-area-element">area</a></code> instead of <code id="non-conforming-features:the-a-element-4"><a href="#the-a-element">a</a></code> for image maps.</p></dd><dt><dfn data-dfn-for="a" id="attr-a-methods" data-dfn-type="element-attr"><code>methods</code></dfn> on <code id="non-conforming-features:the-a-element-5"><a href="#the-a-element">a</a></code> elements</dt><dt><dfn data-dfn-for="link" id="attr-link-methods" data-dfn-type="element-attr"><code>methods</code></dfn> on <code id="non-conforming-features:the-link-element-2"><a href="#the-link-element">link</a></code> elements</dt><dd><p>Use the HTTP OPTIONS feature instead.</p></dd><dt><dfn data-dfn-for="a" id="attr-a-name" data-dfn-type="element-attr"><code>name</code></dfn> on <code id="non-conforming-features:the-a-element-6"><a href="#the-a-element">a</a></code> elements (except as noted in the previous section)</dt><dt><dfn data-dfn-for="embed" id="attr-embed-name" data-dfn-type="element-attr"><code>name</code></dfn> on <code id="non-conforming-features:the-embed-element-3"><a href="#the-embed-element">embed</a></code> elements</dt><dt><dfn data-dfn-for="img" id="attr-img-name" data-dfn-type="element-attr"><code>name</code></dfn> on <code id="non-conforming-features:the-img-element"><a href="#the-img-element">img</a></code> elements</dt><dt><dfn data-dfn-for="option" id="attr-option-name" data-dfn-type="element-attr"><code>name</code></dfn> on <code id="non-conforming-features:the-option-element"><a href="#the-option-element">option</a></code> elements</dt><dd><p>Use the <code id="non-conforming-features:the-id-attribute"><a href="#the-id-attribute">id</a></code> attribute instead.</p></dd><dt><dfn data-dfn-for="a" id="attr-a-rev" data-dfn-type="element-attr"><code>rev</code></dfn> on <code id="non-conforming-features:the-a-element-7"><a href="#the-a-element">a</a></code> elements</dt><dt><dfn data-dfn-for="link" id="attr-link-rev" data-dfn-type="element-attr"><code>rev</code></dfn> on <code id="non-conforming-features:the-link-element-3"><a href="#the-link-element">link</a></code> elements</dt><dd><p>Use the <code id="non-conforming-features:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code>
   attribute instead, with an opposite term. (For example, instead of
   <code>rev="made"</code>, use <code>rel="author"</code>.)</p></dd><dt><dfn data-dfn-for="a" id="attr-a-urn" data-dfn-type="element-attr"><code>urn</code></dfn> on <code id="non-conforming-features:the-a-element-8"><a href="#the-a-element">a</a></code> elements</dt><dt><dfn data-dfn-for="link" id="attr-link-urn" data-dfn-type="element-attr"><code>urn</code></dfn> on <code id="non-conforming-features:the-link-element-4"><a href="#the-link-element">link</a></code> elements</dt><dd><p>Specify the preferred persistent identifier using the <code id="non-conforming-features:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute instead.</p></dd><dt><dfn data-dfn-for="form" id="attr-form-accept" data-dfn-type="element-attr"><code>accept</code></dfn> on <code id="non-conforming-features:the-form-element-2"><a href="#the-form-element">form</a></code> elements</dt><dd><p>Use the <code id="non-conforming-features:attr-input-accept"><a href="#attr-input-accept">accept</a></code> attribute directly on the <code id="non-conforming-features:the-input-element"><a href="#the-input-element">input</a></code> elements instead.</p></dd><dt><dfn data-dfn-for="area" id="attr-area-hreflang" data-dfn-type="element-attr"><code>hreflang</code></dfn> on <code id="non-conforming-features:the-area-element-2"><a href="#the-area-element">area</a></code>
   elements</dt><dt><dfn data-dfn-for="area" id="attr-area-type" data-dfn-type="element-attr"><code>type</code></dfn> on <code id="non-conforming-features:the-area-element-3"><a href="#the-area-element">area</a></code> elements</dt><dd><p>These attributes do not do anything useful, and for historical reasons there are no
   corresponding IDL attributes on <code id="non-conforming-features:the-area-element-4"><a href="#the-area-element">area</a></code> elements. Omit them altogether.</p></dd><dt><dfn data-dfn-for="area" id="attr-area-nohref" data-dfn-type="element-attr"><code>nohref</code></dfn> on <code id="non-conforming-features:the-area-element-5"><a href="#the-area-element">area</a></code> elements</dt><dd><p>Omitting the <code id="non-conforming-features:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code>
   attribute is sufficient; the <code id="non-conforming-features:attr-area-nohref"><a href="#attr-area-nohref">nohref</a></code> attribute is
   unnecessary. Omit it altogether.</p></dd><dt><dfn data-dfn-for="head" id="attr-head-profile" data-dfn-type="element-attr"><code>profile</code></dfn> on <code id="non-conforming-features:the-head-element"><a href="#the-head-element">head</a></code> elements</dt><dd><p>Unnecessary. Omit it altogether.</p></dd><dt><dfn data-dfn-for="html" id="attr-html-manifest" data-dfn-type="element-attr"><code>manifest</code></dfn> on <code id="non-conforming-features:the-html-element"><a href="#the-html-element">html</a></code> elements</dt><dd><p>Use service workers instead. <a href="#refsSW">[SW]</a></p></dd><dt><dfn data-dfn-for="html" id="attr-html-version" data-dfn-type="element-attr"><code>version</code></dfn> on <code id="non-conforming-features:the-html-element-2"><a href="#the-html-element">html</a></code> elements</dt><dd><p>Unnecessary. Omit it altogether.</p></dd><dt><dfn data-dfn-for="input" id="attr-input-ismap" data-dfn-type="element-attr"><code>ismap</code></dfn> on <code id="non-conforming-features:the-input-element-2"><a href="#the-input-element">input</a></code> elements</dt><dd><p>Unnecessary. Omit it altogether. All <code id="non-conforming-features:the-input-element-3"><a href="#the-input-element">input</a></code> elements with a <code id="non-conforming-features:attr-input-type"><a href="#attr-input-type">type</a></code> attribute in the <a href="#image-button-state-(type=image)" id="non-conforming-features:image-button-state-(type=image)">Image
   Button</a> state are processed as server-side image maps.</p></dd><dt><dfn data-dfn-for="input" id="attr-input-usemap" data-dfn-type="element-attr"><code>usemap</code></dfn> on <code id="non-conforming-features:the-input-element-4"><a href="#the-input-element">input</a></code> elements</dt><dt><dfn data-dfn-for="object" id="attr-object-usemap" data-dfn-type="element-attr"><code>usemap</code></dfn> on <code id="non-conforming-features:the-object-element-4"><a href="#the-object-element">object</a></code> elements</dt><dd><p>Use the <code id="non-conforming-features:the-img-element-2"><a href="#the-img-element">img</a></code> element for image maps.</p></dd><dt><dfn data-dfn-for="iframe" id="attr-iframe-longdesc" data-dfn-type="element-attr"><code>longdesc</code></dfn> on <code id="non-conforming-features:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="img" id="attr-img-longdesc" data-dfn-type="element-attr"><code>longdesc</code></dfn> on <code id="non-conforming-features:the-img-element-3"><a href="#the-img-element">img</a></code> elements</dt><dd><p>Use a regular <code id="non-conforming-features:the-a-element-9"><a href="#the-a-element">a</a></code> element to link to the
   description, or (in the case of images) use an <a href="#image-map" id="non-conforming-features:image-map">image
   map</a> to provide a link from the image to the image's
   description.</p></dd><dt><dfn data-dfn-for="img" id="attr-img-lowsrc" data-dfn-type="element-attr"><code>lowsrc</code></dfn> on <code id="non-conforming-features:the-img-element-4"><a href="#the-img-element">img</a></code> elements</dt><dd><p>Use a progressive JPEG image (given in the <code id="non-conforming-features:attr-img-src"><a href="#attr-img-src">src</a></code> attribute),
   instead of using two separate images.</p></dd><dt><dfn data-dfn-for="link" id="attr-link-target" data-dfn-type="element-attr"><code>target</code></dfn> on <code id="non-conforming-features:the-link-element-5"><a href="#the-link-element">link</a></code> elements</dt><dd><p>Unnecessary. Omit it altogether.</p></dd><dt><dfn data-dfn-for="menu" id="attr-menu-type" data-dfn-type="element-attr"><code>type</code></dfn> on <code id="non-conforming-features:the-menu-element"><a href="#the-menu-element">menu</a></code> elements</dt><dd><p>To implement a custom context menu, use script to handle the <code id="non-conforming-features:event-contextmenu-2"><a data-x-internal="event-contextmenu" href="https://w3c.github.io/uievents/#event-type-contextmenu">contextmenu</a></code> event. For toolbar menus, omit the
   attribute.</p></dd><dt><dfn data-dfn-for="menu" id="attr-menu-label" data-dfn-type="element-attr"><code>label</code></dfn> on <code id="non-conforming-features:the-menu-element-2"><a href="#the-menu-element">menu</a></code> elements</dt><dt><dfn id="attr-contextmenu" data-dfn-type="element-attr"><code>contextmenu</code></dfn> on all elements</dt><dt><dfn id="handler-onshow" data-dfn-type="element-attr"><code>onshow</code></dfn> on all elements</dt><dd><p>To implement a custom context menu, use script to handle the <code id="non-conforming-features:event-contextmenu-3"><a data-x-internal="event-contextmenu" href="https://w3c.github.io/uievents/#event-type-contextmenu">contextmenu</a></code> event.</p></dd><dt><dfn data-dfn-for="meta" id="attr-meta-scheme" data-dfn-type="element-attr"><code>scheme</code></dfn> on <code id="non-conforming-features:the-meta-element"><a href="#the-meta-element">meta</a></code> elements</dt><dd><p>Use only one scheme per field, or make the scheme declaration part of the value.</p></dd><dt><dfn data-dfn-for="object" id="attr-object-archive" data-dfn-type="element-attr"><code>archive</code></dfn> on <code id="non-conforming-features:the-object-element-5"><a href="#the-object-element">object</a></code> elements</dt><dt><dfn data-dfn-for="object" id="attr-object-classid" data-dfn-type="element-attr"><code>classid</code></dfn> on <code id="non-conforming-features:the-object-element-6"><a href="#the-object-element">object</a></code> elements</dt><dt><dfn data-dfn-for="object" id="attr-object-code" data-dfn-type="element-attr"><code>code</code></dfn> on <code id="non-conforming-features:the-object-element-7"><a href="#the-object-element">object</a></code> elements</dt><dt><dfn data-dfn-for="object" id="attr-object-codebase" data-dfn-type="element-attr"><code>codebase</code></dfn> on <code id="non-conforming-features:the-object-element-8"><a href="#the-object-element">object</a></code> elements</dt><dt><dfn data-dfn-for="object" id="attr-object-codetype" data-dfn-type="element-attr"><code>codetype</code></dfn> on <code id="non-conforming-features:the-object-element-9"><a href="#the-object-element">object</a></code> elements</dt><dd><p>Use the <code id="non-conforming-features:attr-object-data-2"><a href="#attr-object-data">data</a></code> and <code id="non-conforming-features:attr-object-type"><a href="#attr-object-type">type</a></code> attributes to invoke <a href="#plugin" id="non-conforming-features:plugin">plugins</a>.</p></dd><dt><dfn data-dfn-for="object" id="attr-object-declare" data-dfn-type="element-attr"><code>declare</code></dfn> on <code id="non-conforming-features:the-object-element-10"><a href="#the-object-element">object</a></code> elements</dt><dd><p>Repeat the <code id="non-conforming-features:the-object-element-11"><a href="#the-object-element">object</a></code> element completely each time the resource is to be reused.</p></dd><dt><dfn data-dfn-for="object" id="attr-object-standby" data-dfn-type="element-attr"><code>standby</code></dfn> on <code id="non-conforming-features:the-object-element-12"><a href="#the-object-element">object</a></code> elements</dt><dd><p>Optimize the linked resource so that it loads quickly or, at least, incrementally.</p></dd><dt><dfn data-dfn-for="object" id="attr-object-typemustmatch" data-dfn-type="element-attr"><code>typemustmatch</code></dfn> on <code id="non-conforming-features:the-object-element-13"><a href="#the-object-element">object</a></code> elements</dt><dd><p>Avoid using <code id="non-conforming-features:the-object-element-14"><a href="#the-object-element">object</a></code> elements with untrusted resources.</p></dd><dt><dfn data-dfn-for="script" id="attr-script-language" data-dfn-type="element-attr"><code>language</code></dfn> on <code id="non-conforming-features:the-script-element-3"><a href="#the-script-element">script</a></code> elements (except as noted in the previous section)</dt><dd><p>Omit the attribute for JavaScript; for <a href="#data-block" id="non-conforming-features:data-block">data blocks</a>, use
   the <code id="non-conforming-features:attr-script-type"><a href="#attr-script-type">type</a></code> attribute instead.</p></dd><dt><dfn data-dfn-for="script" id="attr-script-event" data-dfn-type="element-attr"><code>event</code></dfn> on <code id="non-conforming-features:the-script-element-4"><a href="#the-script-element">script</a></code> elements</dt><dt><dfn data-dfn-for="script" id="attr-script-for" data-dfn-type="element-attr"><code>for</code></dfn> on <code id="non-conforming-features:the-script-element-5"><a href="#the-script-element">script</a></code> elements</dt><dd><p>Use DOM events mechanisms to register event listeners. <a href="#refsDOM">[DOM]</a></p></dd><dt><dfn data-dfn-for="style" id="attr-style-type" data-dfn-type="element-attr"><code>type</code></dfn> on <code id="non-conforming-features:the-style-element"><a href="#the-style-element">style</a></code> elements (except as noted in the previous section)</dt><dd><p>Omit the attribute for CSS; for <a href="#data-block" id="non-conforming-features:data-block-2">data blocks</a>, use
   <code id="non-conforming-features:the-script-element-6"><a href="#the-script-element">script</a></code> as the container instead of <code id="non-conforming-features:the-style-element-2"><a href="#the-style-element">style</a></code>.</p></dd><dt><dfn data-dfn-for="table" id="attr-table-datapagesize" data-dfn-type="element-attr"><code>datapagesize</code></dfn> on <code id="non-conforming-features:the-table-element"><a href="#the-table-element">table</a></code> elements</dt><dd><p>Unnecessary. Omit it altogether.</p></dd><dt><dfn data-dfn-for="table" id="attr-table-summary" data-dfn-type="element-attr"><code>summary</code></dfn> on <code id="non-conforming-features:the-table-element-2"><a href="#the-table-element">table</a></code> elements</dt><dd><p>Use one of the <a href="#table-descriptions-techniques">techniques for describing
   tables</a> given in the <code id="non-conforming-features:the-table-element-3"><a href="#the-table-element">table</a></code> section instead.</p></dd><dt><dfn data-dfn-for="td" id="attr-td-abbr" data-dfn-type="element-attr"><code>abbr</code></dfn> on <code id="non-conforming-features:the-td-element"><a href="#the-td-element">td</a></code> elements</dt><dd><p>Use text that begins in an unambiguous and terse manner, and include any more elaborate text after that. The <code id="non-conforming-features:attr-title"><a href="#attr-title">title</a></code> attribute can also be useful in including more detailed text, so that the cell's contents can be made terse. If it's a heading, use <code id="non-conforming-features:the-th-element"><a href="#the-th-element">th</a></code> (which has an <code id="non-conforming-features:attr-th-abbr"><a href="#attr-th-abbr">abbr</a></code> attribute).</p>

   </dd><dt><dfn data-dfn-for="td,th" id="attr-tdth-axis" data-dfn-type="element-attr"><code>axis</code></dfn> on <code id="non-conforming-features:the-td-element-2"><a href="#the-td-element">td</a></code> and <code id="non-conforming-features:the-th-element-2"><a href="#the-th-element">th</a></code> elements</dt><dd><p>Use the <code id="non-conforming-features:attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute on the relevant <code id="non-conforming-features:the-th-element-3"><a href="#the-th-element">th</a></code>.</p>

   </dd><dt><dfn data-dfn-for="td" id="attr-td-scope" data-dfn-type="element-attr"><code>scope</code></dfn> on <code id="non-conforming-features:the-td-element-3"><a href="#the-td-element">td</a></code> elements</dt><dd><p>Use <code id="non-conforming-features:the-th-element-4"><a href="#the-th-element">th</a></code> elements for heading cells.</p>

   </dd><dt><dfn id="attr-datasrc" data-dfn-type="element-attr"><code>datasrc</code></dfn> on <code id="non-conforming-features:the-a-element-10"><a href="#the-a-element">a</a></code>, <code id="non-conforming-features:the-button-element"><a href="#the-button-element">button</a></code>, <code id="non-conforming-features:the-div-element"><a href="#the-div-element">div</a></code>, <code id="non-conforming-features:frame-2"><a href="#frame">frame</a></code>, <code id="non-conforming-features:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code>, <code id="non-conforming-features:the-img-element-5"><a href="#the-img-element">img</a></code>, <code id="non-conforming-features:the-input-element-5"><a href="#the-input-element">input</a></code>, <code id="non-conforming-features:the-label-element"><a href="#the-label-element">label</a></code>, <code id="non-conforming-features:the-legend-element"><a href="#the-legend-element">legend</a></code>, <code id="non-conforming-features:the-marquee-element-2"><a href="#the-marquee-element">marquee</a></code>, <code id="non-conforming-features:the-object-element-15"><a href="#the-object-element">object</a></code>, <code id="non-conforming-features:the-option-element-2"><a href="#the-option-element">option</a></code>, <code id="non-conforming-features:the-select-element"><a href="#the-select-element">select</a></code>, <code id="non-conforming-features:the-span-element"><a href="#the-span-element">span</a></code>, <code id="non-conforming-features:the-table-element-4"><a href="#the-table-element">table</a></code>, and <code id="non-conforming-features:the-textarea-element"><a href="#the-textarea-element">textarea</a></code> elements</dt><dt><dfn id="attr-datafld" data-dfn-type="element-attr"><code>datafld</code></dfn> on <code id="non-conforming-features:the-a-element-11"><a href="#the-a-element">a</a></code>, <code id="non-conforming-features:the-button-element-2"><a href="#the-button-element">button</a></code>, <code id="non-conforming-features:the-div-element-2"><a href="#the-div-element">div</a></code>, <code id="non-conforming-features:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code>, <code id="non-conforming-features:frame-3"><a href="#frame">frame</a></code>, <code id="non-conforming-features:the-iframe-element-4"><a href="#the-iframe-element">iframe</a></code>, <code id="non-conforming-features:the-img-element-6"><a href="#the-img-element">img</a></code>, <code id="non-conforming-features:the-input-element-6"><a href="#the-input-element">input</a></code>, <code id="non-conforming-features:the-label-element-2"><a href="#the-label-element">label</a></code>, <code id="non-conforming-features:the-legend-element-2"><a href="#the-legend-element">legend</a></code>, <code id="non-conforming-features:the-marquee-element-3"><a href="#the-marquee-element">marquee</a></code>, <code id="non-conforming-features:the-object-element-16"><a href="#the-object-element">object</a></code>, <code id="non-conforming-features:the-select-element-2"><a href="#the-select-element">select</a></code>, <code id="non-conforming-features:the-span-element-2"><a href="#the-span-element">span</a></code>, and <code id="non-conforming-features:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code> elements</dt><dt><dfn id="attr-dataformatas" data-dfn-type="element-attr"><code>dataformatas</code></dfn> on <code id="non-conforming-features:the-button-element-3"><a href="#the-button-element">button</a></code>, <code id="non-conforming-features:the-div-element-3"><a href="#the-div-element">div</a></code>, <code id="non-conforming-features:the-input-element-7"><a href="#the-input-element">input</a></code>, <code id="non-conforming-features:the-label-element-3"><a href="#the-label-element">label</a></code>, <code id="non-conforming-features:the-legend-element-3"><a href="#the-legend-element">legend</a></code>, <code id="non-conforming-features:the-marquee-element-4"><a href="#the-marquee-element">marquee</a></code>, <code id="non-conforming-features:the-object-element-17"><a href="#the-object-element">object</a></code>, <code id="non-conforming-features:the-option-element-3"><a href="#the-option-element">option</a></code>, <code id="non-conforming-features:the-select-element-3"><a href="#the-select-element">select</a></code>, <code id="non-conforming-features:the-span-element-3"><a href="#the-span-element">span</a></code>, and <code id="non-conforming-features:the-table-element-5"><a href="#the-table-element">table</a></code> elements</dt><dd><p>Use script and a mechanism such as <code id="non-conforming-features:xmlhttprequest"><a data-x-internal="xmlhttprequest" href="https://xhr.spec.whatwg.org/#xmlhttprequest">XMLHttpRequest</a></code> to populate the page dynamically. <a href="#refsXHR">[XHR]</a></p></dd><dt><dfn id="attr-dropzone" data-dfn-type="element-attr"><code>dropzone</code></dfn> on all elements</dt><dd><p>Use script to handle the <code id="non-conforming-features:event-dnd-dragenter"><a href="#event-dnd-dragenter">dragenter</a></code> and <code id="non-conforming-features:event-dnd-dragover"><a href="#event-dnd-dragover">dragover</a></code> events instead.</p></dd><dt><dfn data-dfn-for="body" id="attr-body-alink" data-dfn-type="element-attr"><code>alink</code></dfn> on <code id="non-conforming-features:the-body-element"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-bgcolor" data-dfn-type="element-attr"><code>bgcolor</code></dfn> on <code id="non-conforming-features:the-body-element-2"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-bottommargin" data-dfn-type="element-attr"><code>bottommargin</code></dfn> on <code id="non-conforming-features:the-body-element-3"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-leftmargin" data-dfn-type="element-attr"><code>leftmargin</code></dfn> on <code id="non-conforming-features:the-body-element-4"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-link" data-dfn-type="element-attr"><code>link</code></dfn> on <code id="non-conforming-features:the-body-element-5"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-marginheight" data-dfn-type="element-attr"><code>marginheight</code></dfn> on <code id="non-conforming-features:the-body-element-6"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-marginwidth" data-dfn-type="element-attr"><code>marginwidth</code></dfn> on <code id="non-conforming-features:the-body-element-7"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-rightmargin" data-dfn-type="element-attr"><code>rightmargin</code></dfn> on <code id="non-conforming-features:the-body-element-8"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-text" data-dfn-type="element-attr"><code>text</code></dfn> on <code id="non-conforming-features:the-body-element-9"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-topmargin" data-dfn-type="element-attr"><code>topmargin</code></dfn> on <code id="non-conforming-features:the-body-element-10"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="body" id="attr-body-vlink" data-dfn-type="element-attr"><code>vlink</code></dfn> on <code id="non-conforming-features:the-body-element-11"><a href="#the-body-element">body</a></code> elements</dt><dt><dfn data-dfn-for="br" id="attr-br-clear" data-dfn-type="element-attr"><code>clear</code></dfn> on <code id="non-conforming-features:the-br-element"><a href="#the-br-element">br</a></code> elements</dt><dt><dfn data-dfn-for="caption" id="attr-caption-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-caption-element"><a href="#the-caption-element">caption</a></code> elements</dt><dt><dfn data-dfn-for="col" id="attr-col-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-col-element"><a href="#the-col-element">col</a></code> elements</dt><dt><dfn data-dfn-for="col" id="attr-col-char" data-dfn-type="element-attr"><code>char</code></dfn> on <code id="non-conforming-features:the-col-element-2"><a href="#the-col-element">col</a></code> elements</dt><dt><dfn data-dfn-for="col" id="attr-col-charoff" data-dfn-type="element-attr"><code>charoff</code></dfn> on <code id="non-conforming-features:the-col-element-3"><a href="#the-col-element">col</a></code> elements</dt><dt><dfn data-dfn-for="col" id="attr-col-valign" data-dfn-type="element-attr"><code>valign</code></dfn> on <code id="non-conforming-features:the-col-element-4"><a href="#the-col-element">col</a></code> elements</dt><dt><dfn data-dfn-for="col" id="attr-col-width" data-dfn-type="element-attr"><code>width</code></dfn> on <code id="non-conforming-features:the-col-element-5"><a href="#the-col-element">col</a></code> elements</dt><dt><dfn data-dfn-for="div" id="attr-div-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-div-element-4"><a href="#the-div-element">div</a></code> elements</dt><dt><dfn data-dfn-for="dl" id="attr-dl-compact" data-dfn-type="element-attr"><code>compact</code></dfn> on <code id="non-conforming-features:the-dl-element"><a href="#the-dl-element">dl</a></code> elements</dt><dt><dfn data-dfn-for="embed" id="attr-embed-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-embed-element-4"><a href="#the-embed-element">embed</a></code> elements</dt><dt><dfn data-dfn-for="embed" id="attr-embed-hspace" data-dfn-type="element-attr"><code>hspace</code></dfn> on <code id="non-conforming-features:the-embed-element-5"><a href="#the-embed-element">embed</a></code> elements</dt><dt><dfn data-dfn-for="embed" id="attr-embed-vspace" data-dfn-type="element-attr"><code>vspace</code></dfn> on <code id="non-conforming-features:the-embed-element-6"><a href="#the-embed-element">embed</a></code> elements</dt><dt><dfn data-dfn-for="hr" id="attr-hr-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-hr-element"><a href="#the-hr-element">hr</a></code> elements</dt><dt><dfn data-dfn-for="hr" id="attr-hr-color" data-dfn-type="element-attr"><code>color</code></dfn> on <code id="non-conforming-features:the-hr-element-2"><a href="#the-hr-element">hr</a></code> elements</dt><dt><dfn data-dfn-for="hr" id="attr-hr-noshade" data-dfn-type="element-attr"><code>noshade</code></dfn> on <code id="non-conforming-features:the-hr-element-3"><a href="#the-hr-element">hr</a></code> elements</dt><dt><dfn data-dfn-for="hr" id="attr-hr-size" data-dfn-type="element-attr"><code>size</code></dfn> on <code id="non-conforming-features:the-hr-element-4"><a href="#the-hr-element">hr</a></code> elements</dt><dt><dfn data-dfn-for="hr" id="attr-hr-width" data-dfn-type="element-attr"><code>width</code></dfn> on <code id="non-conforming-features:the-hr-element-5"><a href="#the-hr-element">hr</a></code> elements</dt><dt><dfn data-dfn-for="h1,h2,h3,h4,h5,h6" id="attr-hx-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>—<code id="non-conforming-features:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code> elements</dt><dt><dfn data-dfn-for="iframe" id="attr-iframe-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-iframe-element-5"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="iframe" id="attr-iframe-allowtransparency" data-dfn-type="element-attr"><code>allowtransparency</code></dfn> on <code id="non-conforming-features:the-iframe-element-6"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="iframe" id="attr-iframe-frameborder" data-dfn-type="element-attr"><code>frameborder</code></dfn> on <code id="non-conforming-features:the-iframe-element-7"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="iframe" id="attr-iframe-framespacing" data-dfn-type="element-attr"><code>framespacing</code></dfn> on <code id="non-conforming-features:the-iframe-element-8"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="iframe" id="attr-iframe-hspace" data-dfn-type="element-attr"><code>hspace</code></dfn> on <code id="non-conforming-features:the-iframe-element-9"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="iframe" id="attr-iframe-marginheight" data-dfn-type="element-attr"><code>marginheight</code></dfn> on <code id="non-conforming-features:the-iframe-element-10"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="iframe" id="attr-iframe-marginwidth" data-dfn-type="element-attr"><code>marginwidth</code></dfn> on <code id="non-conforming-features:the-iframe-element-11"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="iframe" id="attr-iframe-scrolling" data-dfn-type="element-attr"><code>scrolling</code></dfn> on <code id="non-conforming-features:the-iframe-element-12"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="iframe" id="attr-iframe-vspace" data-dfn-type="element-attr"><code>vspace</code></dfn> on <code id="non-conforming-features:the-iframe-element-13"><a href="#the-iframe-element">iframe</a></code> elements</dt><dt><dfn data-dfn-for="input" id="attr-input-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-input-element-8"><a href="#the-input-element">input</a></code> elements</dt><dt><dfn data-dfn-for="input" id="attr-input-border" data-dfn-type="element-attr"><code>border</code></dfn> on <code id="non-conforming-features:the-input-element-9"><a href="#the-input-element">input</a></code> elements</dt><dt><dfn data-dfn-for="input" id="attr-input-hspace" data-dfn-type="element-attr"><code>hspace</code></dfn> on <code id="non-conforming-features:the-input-element-10"><a href="#the-input-element">input</a></code> elements</dt><dt><dfn data-dfn-for="input" id="attr-input-vspace" data-dfn-type="element-attr"><code>vspace</code></dfn> on <code id="non-conforming-features:the-input-element-11"><a href="#the-input-element">input</a></code> elements</dt><dt><dfn data-dfn-for="img" id="attr-img-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-img-element-7"><a href="#the-img-element">img</a></code> elements</dt><dt><dfn data-dfn-for="img" id="attr-img-border" data-dfn-type="element-attr"><code>border</code></dfn> on <code id="non-conforming-features:the-img-element-8"><a href="#the-img-element">img</a></code> elements (except as noted in the previous section)</dt><dt><dfn data-dfn-for="img" id="attr-img-hspace" data-dfn-type="element-attr"><code>hspace</code></dfn> on <code id="non-conforming-features:the-img-element-9"><a href="#the-img-element">img</a></code> elements</dt><dt><dfn data-dfn-for="img" id="attr-img-vspace" data-dfn-type="element-attr"><code>vspace</code></dfn> on <code id="non-conforming-features:the-img-element-10"><a href="#the-img-element">img</a></code> elements</dt><dt><dfn data-dfn-for="legend" id="attr-legend-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-legend-element-4"><a href="#the-legend-element">legend</a></code> elements</dt><dt><dfn data-dfn-for="li" id="attr-li-type" data-dfn-type="element-attr"><code>type</code></dfn> on <code id="non-conforming-features:the-li-element"><a href="#the-li-element">li</a></code> elements</dt><dt><dfn data-dfn-for="menu" id="attr-menu-compact" data-dfn-type="element-attr"><code>compact</code></dfn> on <code id="non-conforming-features:the-menu-element-3"><a href="#the-menu-element">menu</a></code> elements</dt><dt><dfn data-dfn-for="object" id="attr-object-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-object-element-18"><a href="#the-object-element">object</a></code> elements</dt><dt><dfn data-dfn-for="object" id="attr-object-border" data-dfn-type="element-attr"><code>border</code></dfn> on <code id="non-conforming-features:the-object-element-19"><a href="#the-object-element">object</a></code> elements</dt><dt><dfn data-dfn-for="object" id="attr-object-hspace" data-dfn-type="element-attr"><code>hspace</code></dfn> on <code id="non-conforming-features:the-object-element-20"><a href="#the-object-element">object</a></code> elements</dt><dt><dfn data-dfn-for="object" id="attr-object-vspace" data-dfn-type="element-attr"><code>vspace</code></dfn> on <code id="non-conforming-features:the-object-element-21"><a href="#the-object-element">object</a></code> elements</dt><dt><dfn data-dfn-for="ol" id="attr-ol-compact" data-dfn-type="element-attr"><code>compact</code></dfn> on <code id="non-conforming-features:the-ol-element"><a href="#the-ol-element">ol</a></code> elements</dt><dt><dfn data-dfn-for="p" id="attr-p-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-p-element"><a href="#the-p-element">p</a></code> elements</dt><dt><dfn data-dfn-for="pre" id="attr-pre-width" data-dfn-type="element-attr"><code>width</code></dfn> on <code id="non-conforming-features:the-pre-element-3"><a href="#the-pre-element">pre</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-table-element-6"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-bgcolor" data-dfn-type="element-attr"><code>bgcolor</code></dfn> on <code id="non-conforming-features:the-table-element-7"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-border" data-dfn-type="element-attr"><code>border</code></dfn> on <code id="non-conforming-features:the-table-element-8"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-bordercolor" data-dfn-type="element-attr"><code>bordercolor</code></dfn> on <code id="non-conforming-features:the-table-element-9"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-cellpadding" data-dfn-type="element-attr"><code>cellpadding</code></dfn> on <code id="non-conforming-features:the-table-element-10"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-cellspacing" data-dfn-type="element-attr"><code>cellspacing</code></dfn> on <code id="non-conforming-features:the-table-element-11"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-frame" data-dfn-type="element-attr"><code>frame</code></dfn> on <code id="non-conforming-features:the-table-element-12"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-height" data-dfn-type="element-attr"><code>height</code></dfn> on <code id="non-conforming-features:the-table-element-13"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-rules" data-dfn-type="element-attr"><code>rules</code></dfn> on <code id="non-conforming-features:the-table-element-14"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="table" id="attr-table-width" data-dfn-type="element-attr"><code>width</code></dfn> on <code id="non-conforming-features:the-table-element-15"><a href="#the-table-element">table</a></code> elements</dt><dt><dfn data-dfn-for="tbody" id="attr-tbody-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>, <code id="non-conforming-features:the-thead-element"><a href="#the-thead-element">thead</a></code>, and <code id="non-conforming-features:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code> elements</dt><dt><dfn data-dfn-for="tbody" id="attr-tbody-char" data-dfn-type="element-attr"><code>char</code></dfn> on <code id="non-conforming-features:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code>, <code id="non-conforming-features:the-thead-element-2"><a href="#the-thead-element">thead</a></code>, and <code id="non-conforming-features:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code> elements</dt><dt><dfn data-dfn-for="tbody" id="attr-tbody-charoff" data-dfn-type="element-attr"><code>charoff</code></dfn> on <code id="non-conforming-features:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code>, <code id="non-conforming-features:the-thead-element-3"><a href="#the-thead-element">thead</a></code>, and <code id="non-conforming-features:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code> elements</dt><dt><dfn data-dfn-for="tbody" id="attr-tbody-height" data-dfn-type="element-attr"><code>height</code></dfn> on <code id="non-conforming-features:the-thead-element-4"><a href="#the-thead-element">thead</a></code>, <code id="non-conforming-features:the-tbody-element-4"><a href="#the-tbody-element">tbody</a></code>, and <code id="non-conforming-features:the-tfoot-element-4"><a href="#the-tfoot-element">tfoot</a></code> elements</dt><dt><dfn data-dfn-for="tbody" id="attr-tbody-valign" data-dfn-type="element-attr"><code>valign</code></dfn> on <code id="non-conforming-features:the-tbody-element-5"><a href="#the-tbody-element">tbody</a></code>, <code id="non-conforming-features:the-thead-element-5"><a href="#the-thead-element">thead</a></code>, and <code id="non-conforming-features:the-tfoot-element-5"><a href="#the-tfoot-element">tfoot</a></code> elements</dt><dt><dfn data-dfn-for="td,th" id="attr-tdth-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-td-element-4"><a href="#the-td-element">td</a></code> and <code id="non-conforming-features:the-th-element-5"><a href="#the-th-element">th</a></code> elements</dt><dt><dfn data-dfn-for="td,th" id="attr-tdth-bgcolor" data-dfn-type="element-attr"><code>bgcolor</code></dfn> on <code id="non-conforming-features:the-td-element-5"><a href="#the-td-element">td</a></code> and <code id="non-conforming-features:the-th-element-6"><a href="#the-th-element">th</a></code> elements</dt><dt><dfn data-dfn-for="td,th" id="attr-tdth-char" data-dfn-type="element-attr"><code>char</code></dfn> on <code id="non-conforming-features:the-td-element-6"><a href="#the-td-element">td</a></code> and <code id="non-conforming-features:the-th-element-7"><a href="#the-th-element">th</a></code> elements</dt><dt><dfn data-dfn-for="td,th" id="attr-tdth-charoff" data-dfn-type="element-attr"><code>charoff</code></dfn> on <code id="non-conforming-features:the-td-element-7"><a href="#the-td-element">td</a></code> and <code id="non-conforming-features:the-th-element-8"><a href="#the-th-element">th</a></code> elements</dt><dt><dfn data-dfn-for="td,th" id="attr-tdth-height" data-dfn-type="element-attr"><code>height</code></dfn> on <code id="non-conforming-features:the-td-element-8"><a href="#the-td-element">td</a></code> and <code id="non-conforming-features:the-th-element-9"><a href="#the-th-element">th</a></code> elements</dt><dt><dfn data-dfn-for="td,th" id="attr-tdth-nowrap" data-dfn-type="element-attr"><code>nowrap</code></dfn> on <code id="non-conforming-features:the-td-element-9"><a href="#the-td-element">td</a></code> and <code id="non-conforming-features:the-th-element-10"><a href="#the-th-element">th</a></code> elements</dt><dt><dfn data-dfn-for="td,th" id="attr-tdth-valign" data-dfn-type="element-attr"><code>valign</code></dfn> on <code id="non-conforming-features:the-td-element-10"><a href="#the-td-element">td</a></code> and <code id="non-conforming-features:the-th-element-11"><a href="#the-th-element">th</a></code> elements</dt><dt><dfn data-dfn-for="td,th" id="attr-tdth-width" data-dfn-type="element-attr"><code>width</code></dfn> on <code id="non-conforming-features:the-td-element-11"><a href="#the-td-element">td</a></code> and <code id="non-conforming-features:the-th-element-12"><a href="#the-th-element">th</a></code> elements</dt><dt><dfn data-dfn-for="tr" id="attr-tr-align" data-dfn-type="element-attr"><code>align</code></dfn> on <code id="non-conforming-features:the-tr-element"><a href="#the-tr-element">tr</a></code> elements</dt><dt><dfn data-dfn-for="tr" id="attr-tr-bgcolor" data-dfn-type="element-attr"><code>bgcolor</code></dfn> on <code id="non-conforming-features:the-tr-element-2"><a href="#the-tr-element">tr</a></code> elements</dt><dt><dfn data-dfn-for="tr" id="attr-tr-char" data-dfn-type="element-attr"><code>char</code></dfn> on <code id="non-conforming-features:the-tr-element-3"><a href="#the-tr-element">tr</a></code> elements</dt><dt><dfn data-dfn-for="tr" id="attr-tr-charoff" data-dfn-type="element-attr"><code>charoff</code></dfn> on <code id="non-conforming-features:the-tr-element-4"><a href="#the-tr-element">tr</a></code> elements</dt><dt><dfn data-dfn-for="tr" id="attr-tr-height" data-dfn-type="element-attr"><code>height</code></dfn> on <code id="non-conforming-features:the-tr-element-5"><a href="#the-tr-element">tr</a></code> elements</dt><dt><dfn data-dfn-for="tr" id="attr-tr-valign" data-dfn-type="element-attr"><code>valign</code></dfn> on <code id="non-conforming-features:the-tr-element-6"><a href="#the-tr-element">tr</a></code> elements</dt><dt><dfn data-dfn-for="ul" id="attr-ul-compact" data-dfn-type="element-attr"><code>compact</code></dfn> on <code id="non-conforming-features:the-ul-element-2"><a href="#the-ul-element">ul</a></code> elements</dt><dt><dfn data-dfn-for="ul" id="attr-ul-type" data-dfn-type="element-attr"><code>type</code></dfn> on <code id="non-conforming-features:the-ul-element-3"><a href="#the-ul-element">ul</a></code> elements</dt><dt><dfn id="attr-background" data-dfn-type="element-attr"><code>background</code></dfn> on <code id="non-conforming-features:the-body-element-12"><a href="#the-body-element">body</a></code>, <code id="non-conforming-features:the-table-element-16"><a href="#the-table-element">table</a></code>, <code id="non-conforming-features:the-thead-element-6"><a href="#the-thead-element">thead</a></code>, <code id="non-conforming-features:the-tbody-element-6"><a href="#the-tbody-element">tbody</a></code>, <code id="non-conforming-features:the-tfoot-element-6"><a href="#the-tfoot-element">tfoot</a></code>, <code id="non-conforming-features:the-tr-element-7"><a href="#the-tr-element">tr</a></code>, <code id="non-conforming-features:the-td-element-12"><a href="#the-td-element">td</a></code>, and <code id="non-conforming-features:the-th-element-13"><a href="#the-th-element">th</a></code> elements</dt><dd><p>Use CSS instead.</p></dd></dl>


  

  <h3 id="requirements-for-implementations"><span class="secno">16.3</span> Requirements for implementations<a href="#requirements-for-implementations" class="self-link"></a></h3>

  <h4 id="the-marquee-element"><span class="secno">16.3.1</span> The <dfn data-dfn-type="element"><code>marquee</code></dfn> element<a href="#the-marquee-element" class="self-link"></a></h4>

  <p>The <code id="the-marquee-element:the-marquee-element"><a href="#the-marquee-element">marquee</a></code> element is a presentational element that animates content. CSS
  transitions and animations are a more appropriate mechanism. <a href="#refsCSSANIMATIONS">[CSSANIMATIONS]</a> <a href="#refsCSSTRANSITIONS">[CSSTRANSITIONS]</a></p>

  <p>The <code id="the-marquee-element:the-marquee-element-2"><a href="#the-marquee-element">marquee</a></code> element must implement the <code id="the-marquee-element:htmlmarqueeelement"><a href="#htmlmarqueeelement">HTMLMarqueeElement</a></code>
  interface.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlmarqueeelement" data-dfn-type="interface"><c- g="">HTMLMarqueeElement</c-></dfn> : <a href="#htmlelement" id="the-marquee-element:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="the-marquee-element:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="the-marquee-element:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-behavior" data-dfn-type="attribute"><c- g="">behavior</c-></dfn>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-bgcolor" data-dfn-type="attribute"><c- g="">bgColor</c-></dfn>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-direction" data-dfn-type="attribute"><c- g="">direction</c-></dfn>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-height" data-dfn-type="attribute"><c- g="">height</c-></dfn>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-hspace" data-dfn-type="attribute"><c- g="">hspace</c-></dfn>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-6"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> <c- b="">long</c-> <a href="#dom-marquee-loop" id="the-marquee-element:dom-marquee-loop"><c- g="">loop</c-></a>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect-6"><c- g="">Reflect</c-></a>, <a href="#xattr-reflectdefault" id="the-marquee-element:xattr-reflectdefault">ReflectDefault=6</a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-scrollamount" data-dfn-type="attribute"><c- g="">scrollAmount</c-></dfn>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect-7"><c- g="">Reflect</c-></a>, <a href="#xattr-reflectdefault" id="the-marquee-element:xattr-reflectdefault-2">ReflectDefault=85</a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-scrolldelay" data-dfn-type="attribute"><c- g="">scrollDelay</c-></dfn>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-9"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect-8"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-truespeed" data-dfn-type="attribute"><c- g="">trueSpeed</c-></dfn>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-10"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect-9"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-vspace" data-dfn-type="attribute"><c- g="">vspace</c-></dfn>;
  [<a href="#cereactions" id="the-marquee-element:cereactions-11"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="the-marquee-element:xattr-reflect-10"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;

  <c- b="">undefined</c-> <a href="#dom-marquee-start" id="the-marquee-element:dom-marquee-start"><c- g="">start</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-marquee-stop" id="the-marquee-element:dom-marquee-stop"><c- g="">stop</c-></a>();
};</code></pre>

  <p>A <code id="the-marquee-element:the-marquee-element-3"><a href="#the-marquee-element">marquee</a></code> element can be <dfn id="concept-marquee-on">turned on</dfn> or <dfn id="concept-marquee-off">turned off</dfn>. When it is created, it is <a href="#concept-marquee-on" id="the-marquee-element:concept-marquee-on">turned on</a>.</p>

  <div data-algorithm="">
  <p>When the <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-start" data-dfn-type="method"><code>start()</code></dfn> method is called, the <code id="the-marquee-element:the-marquee-element-4"><a href="#the-marquee-element">marquee</a></code> element
  must be <a href="#concept-marquee-on" id="the-marquee-element:concept-marquee-on-2">turned on</a>.</p>
  </div>

  <div data-algorithm="">
  <p>When the <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-stop" data-dfn-type="method"><code>stop()</code></dfn> method is called, the <code id="the-marquee-element:the-marquee-element-5"><a href="#the-marquee-element">marquee</a></code> element
  must be <a href="#concept-marquee-off" id="the-marquee-element:concept-marquee-off">turned off</a>.</p>
  </div>

  <hr>

  <p>The <dfn data-dfn-for="marquee" id="attr-marquee-behavior" data-dfn-type="element-attr"><code>behavior</code></dfn>
  content attribute on <code id="the-marquee-element:the-marquee-element-6"><a href="#the-marquee-element">marquee</a></code> elements is an <a href="#enumerated-attribute" id="the-marquee-element:enumerated-attribute">enumerated attribute</a> with
  the following keywords and states (all non-conforming):</p>

  <table><thead><tr><th>Keyword
     </th><th>State
   </th></tr></thead><tbody><tr><td><code>scroll</code>
     </td><td><dfn id="attr-marquee-behavior-scroll">scroll</dfn>
    </td></tr><tr><td><code>slide</code>
     </td><td><dfn id="attr-marquee-behavior-slide">slide</dfn>
    </td></tr><tr><td><code>alternate</code>
     </td><td><dfn id="attr-marquee-behavior-alternate">alternate</dfn>
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-marquee-element:missing-value-default"><a href="#missing-value-default">missing value default</a></i> and <i id="the-marquee-element:invalid-value-default"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#attr-marquee-behavior-scroll" id="the-marquee-element:attr-marquee-behavior-scroll">scroll</a> state.</p>
  </div>

  <hr>

  <p>The <dfn data-dfn-for="marquee" id="attr-marquee-direction" data-dfn-type="element-attr"><code>direction</code></dfn> content attribute on <code id="the-marquee-element:the-marquee-element-7"><a href="#the-marquee-element">marquee</a></code>
  elements is an <a href="#enumerated-attribute" id="the-marquee-element:enumerated-attribute-2">enumerated attribute</a> with the following keywords and states (all
  non-conforming):</p>

  <table><thead><tr><th>Keyword
     </th><th>State
   </th></tr></thead><tbody><tr><td><code>left</code>
     </td><td><dfn id="attr-marquee-direction-left">left</dfn>
    </td></tr><tr><td><code>right</code>
     </td><td><dfn id="attr-marquee-direction-right">right</dfn>
    </td></tr><tr><td><code>up</code>
     </td><td><dfn id="attr-marquee-direction-up">up</dfn>
    </td></tr><tr><td><code>down</code>
     </td><td><dfn id="attr-marquee-direction-down">down</dfn>
  </td></tr></tbody></table>

  <div data-algorithm="">
  <p>The attribute's <i id="the-marquee-element:missing-value-default-2"><a href="#missing-value-default">missing value default</a></i> and <i id="the-marquee-element:invalid-value-default-2"><a href="#invalid-value-default">invalid value default</a></i> are both the <a href="#attr-marquee-direction-left" id="the-marquee-element:attr-marquee-direction-left">left</a> state.</p>
  </div>

  <hr>

  <p>The <dfn data-dfn-for="marquee" id="attr-marquee-truespeed" data-dfn-type="element-attr"><code>truespeed</code></dfn> content attribute on <code id="the-marquee-element:the-marquee-element-8"><a href="#the-marquee-element">marquee</a></code>
  elements is a <a href="#boolean-attribute" id="the-marquee-element:boolean-attribute">boolean attribute</a>.</p>

  <hr>

  <div data-algorithm="">
  <p>A <code id="the-marquee-element:the-marquee-element-9"><a href="#the-marquee-element">marquee</a></code> element has a <dfn id="marquee-scroll-interval">marquee scroll interval</dfn>, which is obtained as
  follows:</p>

  <ol><li><p>If the element has a <code>scrolldelay</code> attribute,
   and parsing its value using the <a href="#rules-for-parsing-non-negative-integers" id="the-marquee-element:rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a> does not
   return an error, then let <var>delay</var> be the parsed value. Otherwise, let <var>delay</var>
   be 85.</p></li><li><p>If the element does not have a <code id="the-marquee-element:attr-marquee-truespeed"><a href="#attr-marquee-truespeed">truespeed</a></code>
   attribute, and the <var>delay</var> value is less than 60, then let <var>delay</var> be 60
   instead.</p></li><li><p>The <a href="#marquee-scroll-interval" id="the-marquee-element:marquee-scroll-interval">marquee scroll interval</a> is <var>delay</var>, interpreted in
   milliseconds.</p></li></ol>
  </div>

  <hr>

  <div data-algorithm="">
  <p>A <code id="the-marquee-element:the-marquee-element-10"><a href="#the-marquee-element">marquee</a></code> element has a <dfn id="marquee-scroll-distance">marquee scroll distance</dfn>, which, if the element
  has a <code>scrollamount</code> attribute, and
  parsing its value using the <a href="#rules-for-parsing-non-negative-integers" id="the-marquee-element:rules-for-parsing-non-negative-integers-2">rules for parsing non-negative integers</a> does not return
  an error, is the parsed value interpreted in <a href="https://drafts.csswg.org/css-values/#px" id="the-marquee-element:'px'" data-x-internal="'px'">CSS pixels</a>, and otherwise
  is 6 <a href="https://drafts.csswg.org/css-values/#px" id="the-marquee-element:'px'-2" data-x-internal="'px'">CSS pixels</a>.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>A <code id="the-marquee-element:the-marquee-element-11"><a href="#the-marquee-element">marquee</a></code> element has a <dfn id="marquee-loop-count">marquee loop count</dfn>, which, if the element has a
  <dfn data-dfn-for="marquee" id="attr-marquee-loop" data-dfn-type="element-attr"><code>loop</code></dfn> attribute, and
  parsing its value using the <a href="#rules-for-parsing-integers" id="the-marquee-element:rules-for-parsing-integers">rules for parsing integers</a> does not return an error or a
  number less than 1, is the parsed value, and otherwise is −1.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLMarqueeElement" id="dom-marquee-loop" data-dfn-type="attribute"><code>loop</code></dfn>
  IDL attribute, on getting, must return the element's <a href="#marquee-loop-count" id="the-marquee-element:marquee-loop-count">marquee loop count</a>; and on
  setting, if the new value is different than the element's <a href="#marquee-loop-count" id="the-marquee-element:marquee-loop-count-2">marquee loop count</a> and
  either greater than zero or equal to −1, must set the element's <code id="the-marquee-element:attr-marquee-loop"><a href="#attr-marquee-loop">loop</a></code> content attribute (adding it if necessary) to the
  <a href="#valid-integer" id="the-marquee-element:valid-integer">valid integer</a> that represents the new value. (Other values are ignored.)</p>
  </div>

  <p>A <code id="the-marquee-element:the-marquee-element-12"><a href="#the-marquee-element">marquee</a></code> element also has a <dfn id="marquee-current-loop-index">marquee current loop index</dfn>, which is zero
  when the element is created.</p>

  <div data-algorithm="">
  <p>The rendering layer will occasionally <dfn id="increment-the-marquee-current-loop-index">increment the marquee current loop index</dfn>,
  which must cause the following steps to be run:</p>

  <ol><li><p>If the <a href="#marquee-loop-count" id="the-marquee-element:marquee-loop-count-3">marquee loop count</a> is −1, then return.</p>

   </li><li><p>Increment the <a href="#marquee-current-loop-index" id="the-marquee-element:marquee-current-loop-index">marquee current loop index</a> by one.</p></li><li><p>If the <a href="#marquee-current-loop-index" id="the-marquee-element:marquee-current-loop-index-2">marquee current loop index</a> is now greater than or equal to the
   element's <a href="#marquee-loop-count" id="the-marquee-element:marquee-loop-count-4">marquee loop count</a>, <a href="#concept-marquee-off" id="the-marquee-element:concept-marquee-off-2">turn off</a> the
   <code id="the-marquee-element:the-marquee-element-13"><a href="#the-marquee-element">marquee</a></code> element.</p></li></ol>
  </div>

  <hr>


  <h4 id="frames"><span class="secno">16.3.2</span> Frames<a href="#frames" class="self-link"></a></h4>

  <p>The <dfn id="frameset" data-dfn-type="element"><code>frameset</code></dfn> element acts as <a href="#the-body-element-2" id="frames:the-body-element-2">the body element</a> in
  documents that use frames.</p>

  <p>The <code id="frames:frameset"><a href="#frameset">frameset</a></code> element must implement the <code id="frames:htmlframesetelement"><a href="#htmlframesetelement">HTMLFrameSetElement</a></code>
  interface.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlframesetelement" data-dfn-type="interface"><c- g="">HTMLFrameSetElement</c-></dfn> : <a href="#htmlelement" id="frames:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="frames:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="frames:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="frames:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFrameSetElement" id="dom-frameset-cols" data-dfn-type="attribute"><c- g="">cols</c-></dfn>;
  [<a href="#cereactions" id="frames:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="frames:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFrameSetElement" id="dom-frameset-rows" data-dfn-type="attribute"><c- g="">rows</c-></dfn>;
};
<a href="#htmlframesetelement" id="frames:htmlframesetelement-2"><c- n="">HTMLFrameSetElement</c-></a> <c- b="">includes</c-> <a href="#windoweventhandlers" id="frames:windoweventhandlers"><c- n="">WindowEventHandlers</c-></a>;</code></pre>

  <p>The <code id="frames:frameset-2"><a href="#frameset">frameset</a></code> element exposes as <a href="#event-handler-content-attributes" id="frames:event-handler-content-attributes">event handler content attributes</a> a
  number of the <a href="#event-handlers" id="frames:event-handlers">event handlers</a> of the <code id="frames:window"><a href="#window">Window</a></code> object. It also mirrors their
  <a href="#event-handler-idl-attributes" id="frames:event-handler-idl-attributes">event handler IDL attributes</a>.</p>

  <p>The <a href="#event-handlers" id="frames:event-handlers-2">event handlers</a> of the <code id="frames:window-2"><a href="#window">Window</a></code> object named by the
  <a href="#window-reflecting-body-element-event-handler-set" id="frames:window-reflecting-body-element-event-handler-set"><code>Window</code>-reflecting body element event handler set</a>, exposed on the
  <code id="frames:frameset-3"><a href="#frameset">frameset</a></code> element, replace the generic <a href="#event-handlers" id="frames:event-handlers-3">event handlers</a> with the same names
  normally supported by <a href="#html-elements" id="frames:html-elements">HTML elements</a>.</p>

  <hr>

  <p>The <dfn id="frame" data-dfn-type="element"><code>frame</code></dfn> element has a <a href="#content-navigable" id="frames:content-navigable">content navigable</a> similar
  to the <code id="frames:the-iframe-element"><a href="#the-iframe-element">iframe</a></code> element, but rendered within a <code id="frames:frameset-4"><a href="#frameset">frameset</a></code> element.</p>

  

  <div data-algorithm="">
  <p>The <code id="frames:frame"><a href="#frame">frame</a></code> <a href="#html-element-insertion-steps" id="frames:html-element-insertion-steps">HTML element insertion steps</a>, given
  <var>insertedNode</var>, are:</p>

  <ol><li><p>If <var>insertedNode</var> is not <a id="frames:in-a-document-tree" href="https://dom.spec.whatwg.org/#in-a-document-tree" data-x-internal="in-a-document-tree">in a document tree</a>, then return.</p></li><li><p>If <var>insertedNode</var>'s <a id="frames:root" href="https://dom.spec.whatwg.org/#concept-tree-root" data-x-internal="root">root</a>'s <a href="#concept-document-bc" id="frames:concept-document-bc">browsing context</a> is null, then return.</p></li><li><p><a href="#create-a-new-child-navigable" id="frames:create-a-new-child-navigable">Create a new child navigable</a> for <var>insertedNode</var>.</p></li><li><p><a href="#process-the-frame-attributes" id="frames:process-the-frame-attributes">Process the <code>frame</code> attributes</a> for <var>insertedNode</var>, with
   <i id="frames:process-frame-initial-insertion"><a href="#process-frame-initial-insertion">initialInsertion</a></i> set to true.</p></li></ol>
  </div>

  <div data-algorithm="">
  <p>The <code id="frames:frame-2"><a href="#frame">frame</a></code> <a href="#html-element-removing-steps" id="frames:html-element-removing-steps">HTML element removing steps</a>, given <var>removedNode</var>,
  are to <a href="#destroy-a-child-navigable" id="frames:destroy-a-child-navigable">destroy a child navigable</a> given <var>removedNode</var>.</p>
  </div>

  <p>Whenever a <code id="frames:frame-3"><a href="#frame">frame</a></code> element with a non-null <a href="#content-navigable" id="frames:content-navigable-2">content navigable</a> has its
  <code>src</code> attribute set, changed, or removed, the user
  agent must <a href="#process-the-frame-attributes" id="frames:process-the-frame-attributes-2">process the <code>frame</code> attributes</a>.</p> 

  <div data-algorithm="">
  <p>To <dfn id="process-the-frame-attributes">process the <code>frame</code> attributes</dfn> for an element <var>element</var>, with
  an optional boolean <dfn id="process-frame-initial-insertion"><var>initialInsertion</var></dfn>:</p>

  <ol><li><p>Let <var>url</var> be the result of running the <a href="#shared-attribute-processing-steps-for-iframe-and-frame-elements" id="frames:shared-attribute-processing-steps-for-iframe-and-frame-elements">shared attribute processing steps
   for <code>iframe</code> and <code>frame</code> elements</a> given <var>element</var> and
   <var>initialInsertion</var>.</p></li><li><p>If <var>url</var> is null, then return.</p></li><li>
    <p>If <var>url</var> <a href="#matches-about:blank" id="frames:matches-about:blank">matches <code>about:blank</code></a> and
    <var>initialInsertion</var> is true, then:</p>

    <ol><li><p><a href="https://dom.spec.whatwg.org/#concept-event-fire" id="frames:concept-event-fire" data-x-internal="concept-event-fire">Fire an event</a> named <code id="frames:event-load"><a href="#event-load">load</a></code> at <var>element</var>.</p></li><li><p>Return.</p></li></ol>
   </li><li><p><a href="#navigate-an-iframe-or-frame" id="frames:navigate-an-iframe-or-frame">Navigate an <code>iframe</code> or <code>frame</code></a> given
   <var>element</var>, <var>url</var>, the empty string, and <var>initialInsertion</var>.</p></li></ol>
  </div>

  <p>The <code id="frames:frame-4"><a href="#frame">frame</a></code> element <a href="#potentially-delays-the-load-event" id="frames:potentially-delays-the-load-event">potentially delays the load event</a>.</p>

  

  <p>The <code id="frames:frame-5"><a href="#frame">frame</a></code> element must implement the <code id="frames:htmlframeelement"><a href="#htmlframeelement">HTMLFrameElement</a></code> interface.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlframeelement" data-dfn-type="interface"><c- g="">HTMLFrameElement</c-></dfn> : <a href="#htmlelement" id="frames:htmlelement-2"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="frames:htmlconstructor-2"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="frames:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="frames:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="frames:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="frames:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-scrolling" data-dfn-type="attribute"><c- g="">scrolling</c-></dfn>;
  [<a href="#cereactions" id="frames:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="frames:xattr-reflecturl"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-src" data-dfn-type="attribute"><c- g="">src</c-></dfn>;
  [<a href="#cereactions" id="frames:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="frames:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-frameborder" data-dfn-type="attribute"><c- g="">frameBorder</c-></dfn>;
  [<a href="#cereactions" id="frames:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="frames:xattr-reflecturl-2"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-longdesc" data-dfn-type="attribute"><c- g="">longDesc</c-></dfn>;
  [<a href="#cereactions" id="frames:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="frames:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-noresize" data-dfn-type="attribute"><c- g="">noResize</c-></dfn>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#document" id="frames:document"><c- n="">Document</c-></a>? <a href="#dom-frame-contentdocument" id="frames:dom-frame-contentdocument"><c- g="">contentDocument</c-></a>;
  <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#windowproxy" id="frames:windowproxy"><c- n="">WindowProxy</c-></a>? <a href="#dom-frame-contentwindow" id="frames:dom-frame-contentwindow"><c- g="">contentWindow</c-></a>;

  [<a href="#cereactions" id="frames:cereactions-9"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="frames:xattr-reflect-7"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="frames:legacynulltoemptystring" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-marginheight" data-dfn-type="attribute"><c- g="">marginHeight</c-></dfn>;
  [<a href="#cereactions" id="frames:cereactions-10"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="frames:xattr-reflect-8"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="frames:legacynulltoemptystring-2" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-marginwidth" data-dfn-type="attribute"><c- g="">marginWidth</c-></dfn>;
};</code></pre>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-contentdocument" data-dfn-type="attribute"><code>contentDocument</code></dfn> getter steps are to return
  <a id="frames:this" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#concept-bcc-content-document" id="frames:concept-bcc-content-document">content document</a>.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="HTMLFrameElement" id="dom-frame-contentwindow" data-dfn-type="attribute"><code>contentWindow</code></dfn> getter steps are to return
  <a id="frames:this-2" href="https://webidl.spec.whatwg.org/#this" data-x-internal="this">this</a>'s <a href="#content-window" id="frames:content-window">content window</a>.</p>
  </div>


  <h4 id="other-elements,-attributes-and-apis"><span class="secno">16.3.3</span> Other elements, attributes and APIs<a href="#other-elements,-attributes-and-apis" class="self-link"></a></h4> 

  <p>User agents must treat <code id="other-elements,-attributes-and-apis:acronym"><a href="#acronym">acronym</a></code> elements in a manner
  equivalent to <code id="other-elements,-attributes-and-apis:the-abbr-element"><a href="#the-abbr-element">abbr</a></code> elements in terms of semantics and
  for purposes of rendering.</p>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlanchorelement" id="HTMLAnchorElement-partial"><c- g="">HTMLAnchorElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-coords" data-dfn-type="attribute"><c- g="">coords</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-2"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-2"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-charset" data-dfn-type="attribute"><c- g="">charset</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-3"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-3"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-4"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-4"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-rev" data-dfn-type="attribute"><c- g="">rev</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-5"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-5"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLAnchorElement" id="dom-a-shape" data-dfn-type="attribute"><c- g="">shape</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlareaelement" id="HTMLAreaElement-partial"><c- g="">HTMLAreaElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-6"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-6"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLAreaElement" id="dom-area-nohref" data-dfn-type="attribute"><c- g="">noHref</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlbodyelement" id="HTMLBodyElement-partial"><c- g="">HTMLBodyElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-7"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-7"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLBodyElement" id="dom-body-text" data-dfn-type="attribute"><c- g="">text</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-8"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-8"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-2" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLBodyElement" id="dom-body-link" data-dfn-type="attribute"><c- g="">link</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-9"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-9"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-3" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLBodyElement" id="dom-body-vlink" data-dfn-type="attribute"><c- g="">vLink</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-10"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-10"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-4" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLBodyElement" id="dom-body-alink" data-dfn-type="attribute"><c- g="">aLink</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-11"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-11"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-5" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLBodyElement" id="dom-body-bgcolor" data-dfn-type="attribute"><c- g="">bgColor</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-12"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-12"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLBodyElement" id="dom-body-background" data-dfn-type="attribute"><c- g="">background</c-></dfn>;
};</code></pre>

  <p class="note">The <code id="other-elements,-attributes-and-apis:dom-body-background"><a href="#dom-body-background">background</a></code> IDL attribute does not
  use <a href="#xattr-reflecturl" id="other-elements,-attributes-and-apis:xattr-reflecturl">ReflectURL</a> or <code id="other-elements,-attributes-and-apis:idl-usvstring"><a data-x-internal="idl-usvstring" href="https://webidl.spec.whatwg.org/#idl-USVString">USVString</a></code> for historical reasons.</p>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlbrelement" id="HTMLBRElement-partial"><c- g="">HTMLBRElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-13"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-13"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLBRElement" id="dom-br-clear" data-dfn-type="attribute"><c- g="">clear</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmltablecaptionelement" id="HTMLTableCaptionElement-partial"><c- g="">HTMLTableCaptionElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-14"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-14"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCaptionElement" id="dom-caption-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmltablecolelement" id="HTMLTableColElement-partial"><c- g="">HTMLTableColElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-15"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-15"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableColElement" id="dom-col-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-16"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-16">Reflect</a>="<a href="#attr-col-char" id="other-elements,-attributes-and-apis:attr-col-char">char</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableColElement" id="dom-col-ch" data-dfn-type="attribute"><c- g="">ch</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-17"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-17">Reflect</a>="<a href="#attr-col-charoff" id="other-elements,-attributes-and-apis:attr-col-charoff">charoff</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableColElement" id="dom-col-choff" data-dfn-type="attribute"><c- g="">chOff</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-18"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-18"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableColElement" id="dom-col-valign" data-dfn-type="attribute"><c- g="">vAlign</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-19"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-19"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableColElement" id="dom-col-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;
};</code></pre>

  <hr>

  <p>User agents must treat <code id="other-elements,-attributes-and-apis:dir"><a href="#dir">dir</a></code> elements in a manner equivalent to <code id="other-elements,-attributes-and-apis:the-ul-element"><a href="#the-ul-element">ul</a></code>
  elements in terms of semantics and for purposes of rendering.</p>

  <p>The <code id="other-elements,-attributes-and-apis:dir-2"><a href="#dir">dir</a></code> element must implement the <code id="other-elements,-attributes-and-apis:htmldirectoryelement"><a href="#htmldirectoryelement">HTMLDirectoryElement</a></code>
  interface.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmldirectoryelement" data-dfn-type="interface"><c- g="">HTMLDirectoryElement</c-></dfn> : <a href="#htmlelement" id="other-elements,-attributes-and-apis:htmlelement"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="other-elements,-attributes-and-apis:htmlconstructor"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-20"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-20"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLDirectoryElement" id="dom-dir-compact" data-dfn-type="attribute"><c- g="">compact</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmldivelement" id="HTMLDivElement-partial"><c- g="">HTMLDivElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-21"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-21"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLDivElement" id="dom-div-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmldlistelement" id="HTMLDListElement-partial"><c- g="">HTMLDListElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-22"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-22"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLDListElement" id="dom-dl-compact" data-dfn-type="attribute"><c- g="">compact</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlembedelement" id="HTMLEmbedElement-partial"><c- g="">HTMLEmbedElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-23"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-23"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLEmbedElement" id="dom-embed-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-24"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-24"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLEmbedElement" id="dom-embed-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
};</code></pre>

  <hr>

  <p>The <code id="other-elements,-attributes-and-apis:font"><a href="#font">font</a></code> element must implement the <code id="other-elements,-attributes-and-apis:htmlfontelement"><a href="#htmlfontelement">HTMLFontElement</a></code> interface.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlfontelement" data-dfn-type="interface"><c- g="">HTMLFontElement</c-></dfn> : <a href="#htmlelement" id="other-elements,-attributes-and-apis:htmlelement-2"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="other-elements,-attributes-and-apis:htmlconstructor-2"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-25"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-25"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-6" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFontElement" id="dom-font-color" data-dfn-type="attribute"><c- g="">color</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-26"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-26"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFontElement" id="dom-font-face" data-dfn-type="attribute"><c- g="">face</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-27"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-27"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLFontElement" id="dom-font-size" data-dfn-type="attribute"><c- g="">size</c-></dfn>; 
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlheadingelement" id="HTMLHeadingElement-partial"><c- g="">HTMLHeadingElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-28"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-28"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLHeadingElement" id="dom-hx-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
};</code></pre>

  <hr>

  <p class="note">The <dfn data-dfn-for="HTMLHeadElement" id="dom-head-profile" data-dfn-type="attribute"><code>profile</code></dfn> IDL attribute on <code id="other-elements,-attributes-and-apis:the-head-element"><a href="#the-head-element">head</a></code> elements (with
  the <code id="other-elements,-attributes-and-apis:htmlheadelement"><a href="#htmlheadelement">HTMLHeadElement</a></code> interface) is intentionally omitted. Unless so required by <a href="#other-applicable-specifications" id="other-elements,-attributes-and-apis:other-applicable-specifications">another applicable specification</a>, implementations
  would therefore not support this attribute. (It is mentioned here as it was defined in a previous
  version of <cite>DOM</cite>.)</p>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlhrelement" id="HTMLHRElement-partial"><c- g="">HTMLHRElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-29"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-29"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLHRElement" id="dom-hr-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-30"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-30"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLHRElement" id="dom-hr-color" data-dfn-type="attribute"><c- g="">color</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-31"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-31"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLHRElement" id="dom-hr-noshade" data-dfn-type="attribute"><c- g="">noShade</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-32"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-32"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLHRElement" id="dom-hr-size" data-dfn-type="attribute"><c- g="">size</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-33"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-33"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLHRElement" id="dom-hr-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlhtmlelement" id="HTMLHtmlElement-partial"><c- g="">HTMLHtmlElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-34"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-34"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLHtmlElement" id="dom-html-version" data-dfn-type="attribute"><c- g="">version</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmliframeelement" id="HTMLIFrameElement-partial"><c- g="">HTMLIFrameElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-35"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-35"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-36"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-36"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-scrolling" data-dfn-type="attribute"><c- g="">scrolling</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-37"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-37"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-frameborder" data-dfn-type="attribute"><c- g="">frameBorder</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-38"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="other-elements,-attributes-and-apis:xattr-reflecturl-2"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-longdesc" data-dfn-type="attribute"><c- g="">longDesc</c-></dfn>;

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-39"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-38"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-7" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-marginheight" data-dfn-type="attribute"><c- g="">marginHeight</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-40"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-39"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-8" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLIFrameElement" id="dom-iframe-marginwidth" data-dfn-type="attribute"><c- g="">marginWidth</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlimageelement" id="HTMLImageElement-partial"><c- g="">HTMLImageElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-41"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-40"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-42"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="other-elements,-attributes-and-apis:xattr-reflecturl-3"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-lowsrc" data-dfn-type="attribute"><c- g="">lowsrc</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-43"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-41"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-44"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-42"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-hspace" data-dfn-type="attribute"><c- g="">hspace</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-45"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-43"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-vspace" data-dfn-type="attribute"><c- g="">vspace</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-46"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="other-elements,-attributes-and-apis:xattr-reflecturl-4"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">USVString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-longdesc" data-dfn-type="attribute"><c- g="">longDesc</c-></dfn>;

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-47"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-44"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-9" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLImageElement" id="dom-img-border" data-dfn-type="attribute"><c- g="">border</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlinputelement" id="HTMLInputElement-partial"><c- g="">HTMLInputElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-48"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-45"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-49"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-46"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLInputElement" id="dom-input-usemap" data-dfn-type="attribute"><c- g="">useMap</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmllegendelement" id="HTMLLegendElement-partial"><c- g="">HTMLLegendElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-50"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-47"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLegendElement" id="dom-legend-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmllielement" id="HTMLLIElement-partial"><c- g="">HTMLLIElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-51"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-48"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLIElement" id="dom-li-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmllinkelement" id="HTMLLinkElement-partial"><c- g="">HTMLLinkElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-52"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-49"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-charset" data-dfn-type="attribute"><c- g="">charset</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-53"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-50"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-rev" data-dfn-type="attribute"><c- g="">rev</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-54"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-51"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLLinkElement" id="dom-link-target" data-dfn-type="attribute"><c- g="">target</c-></dfn>;
};</code></pre>

  <hr>

  <p>User agents must treat <code id="other-elements,-attributes-and-apis:listing"><a href="#listing">listing</a></code> elements in a manner equivalent to <code id="other-elements,-attributes-and-apis:the-pre-element"><a href="#the-pre-element">pre</a></code>
  elements in terms of semantics and for purposes of rendering.</p>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlmenuelement" id="HTMLMenuElement-partial"><c- g="">HTMLMenuElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-55"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-52"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLMenuElement" id="dom-menu-compact" data-dfn-type="attribute"><c- g="">compact</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlmetaelement" id="HTMLMetaElement-partial"><c- g="">HTMLMetaElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-56"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-53"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLMetaElement" id="dom-meta-scheme" data-dfn-type="attribute"><c- g="">scheme</c-></dfn>;
};</code></pre>

  <p>User agents may treat the <code id="other-elements,-attributes-and-apis:attr-meta-scheme"><a href="#attr-meta-scheme">scheme</a></code> content attribute on the
  <code id="other-elements,-attributes-and-apis:the-meta-element"><a href="#the-meta-element">meta</a></code> element as an extension of the element's <code id="other-elements,-attributes-and-apis:attr-meta-name"><a href="#attr-meta-name">name</a></code> content attribute when processing a <code id="other-elements,-attributes-and-apis:the-meta-element-2"><a href="#the-meta-element">meta</a></code> element
  with a <code id="other-elements,-attributes-and-apis:attr-meta-name-2"><a href="#attr-meta-name">name</a></code> attribute whose value is one that the user agent
  recognizes as supporting the <code id="other-elements,-attributes-and-apis:attr-meta-scheme-2"><a href="#attr-meta-scheme">scheme</a></code> attribute.</p>

  <p>User agents are encouraged to ignore the <code id="other-elements,-attributes-and-apis:attr-meta-scheme-3"><a href="#attr-meta-scheme">scheme</a></code> attribute
  and instead process the value given to the metadata name as if it had been specified for each
  expected value of the <code id="other-elements,-attributes-and-apis:attr-meta-scheme-4"><a href="#attr-meta-scheme">scheme</a></code> attribute.</p>

  <div class="example">

   <p>For example, if the user agent acts on <code id="other-elements,-attributes-and-apis:the-meta-element-3"><a href="#the-meta-element">meta</a></code> elements with <code id="other-elements,-attributes-and-apis:attr-meta-name-3"><a href="#attr-meta-name">name</a></code> attributes having the value "eGMS.subject.keyword", and knows
   that the <code id="other-elements,-attributes-and-apis:attr-meta-scheme-5"><a href="#attr-meta-scheme">scheme</a></code> attribute is used with this metadata name,
   then it could take the <code id="other-elements,-attributes-and-apis:attr-meta-scheme-6"><a href="#attr-meta-scheme">scheme</a></code> attribute into account,
   acting as if it was an extension of the <code id="other-elements,-attributes-and-apis:attr-meta-name-4"><a href="#attr-meta-name">name</a></code> attribute. Thus
   the following two <code id="other-elements,-attributes-and-apis:the-meta-element-4"><a href="#the-meta-element">meta</a></code> elements could be treated as two elements giving values for
   two different metadata names, one consisting of a combination of "eGMS.subject.keyword" and
   "LGCL", and the other consisting of a combination of "eGMS.subject.keyword" and "ORLY":</p>

   <pre class="bad"><code class="html"><c- c="">&lt;!-- this markup is invalid --&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"eGMS.subject.keyword"</c-> <c- e="">scheme</c-><c- o="">=</c-><c- s="">"LGCL"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"Abandoned vehicles"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"eGMS.subject.keyword"</c-> <c- e="">scheme</c-><c- o="">=</c-><c- s="">"ORLY"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"Mah car: kthxbye"</c-><c- p="">&gt;</c-></code></pre>

   <p>The suggested processing of this markup, however, would be equivalent to the following:</p>

   <pre><code class="html"><c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"eGMS.subject.keyword"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"Abandoned vehicles"</c-><c- p="">&gt;</c->
<c- p="">&lt;</c-><c- f="">meta</c-> <c- e="">name</c-><c- o="">=</c-><c- s="">"eGMS.subject.keyword"</c-> <c- e="">content</c-><c- o="">=</c-><c- s="">"Mah car: kthxbye"</c-><c- p="">&gt;</c-></code></pre>

  </div>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/useMap" title="The useMap property of the HTMLObjectElement interface returns a string that reflects the usemap HTML attribute, specifying a <map> element to use.">HTMLObjectElement/useMap</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>6+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlobjectelement" id="HTMLObjectElement-partial"><c- g="">HTMLObjectElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-57"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-54"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-58"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-55"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-archive" data-dfn-type="attribute"><c- g="">archive</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-59"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-56"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-code" data-dfn-type="attribute"><c- g="">code</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-60"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-57"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-declare" data-dfn-type="attribute"><c- g="">declare</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-61"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-58"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-hspace" data-dfn-type="attribute"><c- g="">hspace</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-62"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-59"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-standby" data-dfn-type="attribute"><c- g="">standby</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-63"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-60"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">unsigned</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-vspace" data-dfn-type="attribute"><c- g="">vspace</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-64"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflecturl" id="other-elements,-attributes-and-apis:xattr-reflecturl-5"><c- g="">ReflectURL</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-codebase" data-dfn-type="attribute"><c- g="">codeBase</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-65"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-61"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-codetype" data-dfn-type="attribute"><c- g="">codeType</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-66"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-62"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-usemap" data-dfn-type="attribute"><c- g="">useMap</c-></dfn>;

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-67"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-63"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-10" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLObjectElement" id="dom-object-border" data-dfn-type="attribute"><c- g="">border</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlolistelement" id="HTMLOListElement-partial"><c- g="">HTMLOListElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-68"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-64"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLOListElement" id="dom-ol-compact" data-dfn-type="attribute"><c- g="">compact</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlparagraphelement" id="HTMLParagraphElement-partial"><c- g="">HTMLParagraphElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-69"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-65"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLParagraphElement" id="dom-p-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
};</code></pre>

  <hr>

  <p>The <code id="other-elements,-attributes-and-apis:param"><a href="#param">param</a></code> element must implement the <code id="other-elements,-attributes-and-apis:htmlparamelement"><a href="#htmlparamelement">HTMLParamElement</a></code> interface.</p>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="htmlparamelement" data-dfn-type="interface"><c- g="">HTMLParamElement</c-></dfn> : <a href="#htmlelement" id="other-elements,-attributes-and-apis:htmlelement-3"><c- n="">HTMLElement</c-></a> {
  [<a href="#htmlconstructor" id="other-elements,-attributes-and-apis:htmlconstructor-3"><c- g="">HTMLConstructor</c-></a>] <c- g="">constructor</c->();

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-70"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-66"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLParamElement" id="dom-param-name" data-dfn-type="attribute"><c- g="">name</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-71"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-67"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLParamElement" id="dom-param-value" data-dfn-type="attribute"><c- g="">value</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-72"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-68"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLParamElement" id="dom-param-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-73"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-69"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLParamElement" id="dom-param-valuetype" data-dfn-type="attribute"><c- g="">valueType</c-></dfn>;
};</code></pre>

  <hr>

  <p>User agents must treat <code id="other-elements,-attributes-and-apis:plaintext"><a href="#plaintext">plaintext</a></code> elements in a manner equivalent to
  <code id="other-elements,-attributes-and-apis:the-pre-element-2"><a href="#the-pre-element">pre</a></code> elements in terms of semantics and for purposes of rendering. (The parser has
  special behavior for this element, though.)</p>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlpreelement" id="HTMLPreElement-partial"><c- g="">HTMLPreElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-74"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-70"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">long</c-> <dfn data-dfn-for="HTMLPreElement" id="dom-pre-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlstyleelement" id="HTMLStyleElement-partial"><c- g="">HTMLStyleElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-75"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-71"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLStyleElement" id="dom-style-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlscriptelement" id="HTMLScriptElement-partial"><c- g="">HTMLScriptElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-76"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-72"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLScriptElement" id="dom-script-charset" data-dfn-type="attribute"><c- g="">charset</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-77"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-73"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLScriptElement" id="dom-script-event" data-dfn-type="attribute"><c- g="">event</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-78"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-74">Reflect</a>="<a href="#attr-script-for" id="other-elements,-attributes-and-apis:attr-script-for">for</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLScriptElement" id="dom-script-htmlfor" data-dfn-type="attribute"><c- g="">htmlFor</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmltableelement" id="HTMLTableElement-partial"><c- g="">HTMLTableElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-79"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-75"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableElement" id="dom-table-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-80"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-76"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableElement" id="dom-table-border" data-dfn-type="attribute"><c- g="">border</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-81"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-77"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableElement" id="dom-table-frame" data-dfn-type="attribute"><c- g="">frame</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-82"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-78"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableElement" id="dom-table-rules" data-dfn-type="attribute"><c- g="">rules</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-83"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-79"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableElement" id="dom-table-summary" data-dfn-type="attribute"><c- g="">summary</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-84"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-80"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableElement" id="dom-table-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-85"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-81"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-11" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableElement" id="dom-table-bgcolor" data-dfn-type="attribute"><c- g="">bgColor</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-86"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-82"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-12" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableElement" id="dom-table-cellpadding" data-dfn-type="attribute"><c- g="">cellPadding</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-87"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-83"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-13" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableElement" id="dom-table-cellspacing" data-dfn-type="attribute"><c- g="">cellSpacing</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmltablesectionelement" id="HTMLTableSectionElement-partial"><c- g="">HTMLTableSectionElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-88"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-84"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableSectionElement" id="dom-tbody-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-89"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-85">Reflect</a>="<a href="#attr-tbody-char" id="other-elements,-attributes-and-apis:attr-tbody-char">char</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableSectionElement" id="dom-tbody-ch" data-dfn-type="attribute"><c- g="">ch</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-90"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-86">Reflect</a>="<a href="#attr-tbody-charoff" id="other-elements,-attributes-and-apis:attr-tbody-charoff">charoff</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableSectionElement" id="dom-tbody-choff" data-dfn-type="attribute"><c- g="">chOff</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-91"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-87"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableSectionElement" id="dom-tbody-valign" data-dfn-type="attribute"><c- g="">vAlign</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmltablecellelement" id="HTMLTableCellElement-partial"><c- g="">HTMLTableCellElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-92"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-88"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-93"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-89"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-axis" data-dfn-type="attribute"><c- g="">axis</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-94"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-90"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-height" data-dfn-type="attribute"><c- g="">height</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-95"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-91"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-width" data-dfn-type="attribute"><c- g="">width</c-></dfn>;

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-96"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-92">Reflect</a>="<a href="#attr-tdth-char" id="other-elements,-attributes-and-apis:attr-tdth-char">char</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-ch" data-dfn-type="attribute"><c- g="">ch</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-97"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-93">Reflect</a>="<a href="#attr-tdth-charoff" id="other-elements,-attributes-and-apis:attr-tdth-charoff">charoff</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-choff" data-dfn-type="attribute"><c- g="">chOff</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-98"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-94"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-nowrap" data-dfn-type="attribute"><c- g="">noWrap</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-99"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-95"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-valign" data-dfn-type="attribute"><c- g="">vAlign</c-></dfn>;

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-100"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-96"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-14" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableCellElement" id="dom-tdth-bgcolor" data-dfn-type="attribute"><c- g="">bgColor</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmltablerowelement" id="HTMLTableRowElement-partial"><c- g="">HTMLTableRowElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-101"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-97"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-align" data-dfn-type="attribute"><c- g="">align</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-102"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-98">Reflect</a>="<a href="#attr-tr-char" id="other-elements,-attributes-and-apis:attr-tr-char">char</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-ch" data-dfn-type="attribute"><c- g="">ch</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-103"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-99">Reflect</a>="<a href="#attr-tr-charoff" id="other-elements,-attributes-and-apis:attr-tr-charoff">charoff</a>"] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-choff" data-dfn-type="attribute"><c- g="">chOff</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-104"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-100"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-valign" data-dfn-type="attribute"><c- g="">vAlign</c-></dfn>;

  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-105"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-101"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-15" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLTableRowElement" id="dom-tr-bgcolor" data-dfn-type="attribute"><c- g="">bgColor</c-></dfn>;
};</code></pre>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#htmlulistelement" id="HTMLUListElement-partial"><c- g="">HTMLUListElement</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-106"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-102"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">boolean</c-> <dfn data-dfn-for="HTMLUListElement" id="dom-ul-compact" data-dfn-type="attribute"><c- g="">compact</c-></dfn>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-107"><c- g="">CEReactions</c-></a>, <a href="#xattr-reflect" id="other-elements,-attributes-and-apis:xattr-reflect-103"><c- g="">Reflect</c-></a>] <c- b="">attribute</c-> <c- b="">DOMString</c-> <dfn data-dfn-for="HTMLUListElement" id="dom-ul-type" data-dfn-type="attribute"><c- g="">type</c-></dfn>;
};</code></pre>

  <hr>

  <p>User agents must treat <code id="other-elements,-attributes-and-apis:xmp"><a href="#xmp">xmp</a></code> elements in a manner equivalent to <code id="other-elements,-attributes-and-apis:the-pre-element-3"><a href="#the-pre-element">pre</a></code>
  elements in terms of semantics and for purposes of rendering. (The parser has special behavior for
  this element though.)</p>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#document" id="Document-partial"><c- g="">Document</c-></a> {
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-108"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-16" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <a href="#dom-document-fgcolor" id="other-elements,-attributes-and-apis:dom-document-fgcolor"><c- g="">fgColor</c-></a>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-109"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-17" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <a href="#dom-document-linkcolor" id="other-elements,-attributes-and-apis:dom-document-linkcolor"><c- g="">linkColor</c-></a>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-110"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-18" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <a href="#dom-document-vlinkcolor" id="other-elements,-attributes-and-apis:dom-document-vlinkcolor"><c- g="">vlinkColor</c-></a>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-111"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-19" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <a href="#dom-document-alinkcolor" id="other-elements,-attributes-and-apis:dom-document-alinkcolor"><c- g="">alinkColor</c-></a>;
  [<a href="#cereactions" id="other-elements,-attributes-and-apis:cereactions-112"><c- g="">CEReactions</c-></a>] <c- b="">attribute</c-> [<a id="other-elements,-attributes-and-apis:legacynulltoemptystring-20" href="https://webidl.spec.whatwg.org/#LegacyNullToEmptyString" data-x-internal="legacynulltoemptystring"><c- g="">LegacyNullToEmptyString</c-></a>] <c- b="">DOMString</c-> <a href="#dom-document-bgcolor" id="other-elements,-attributes-and-apis:dom-document-bgcolor"><c- g="">bgColor</c-></a>;

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="other-elements,-attributes-and-apis:htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-document-anchors" id="other-elements,-attributes-and-apis:dom-document-anchors"><c- g="">anchors</c-></a>;
  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a id="other-elements,-attributes-and-apis:htmlcollection-2" href="https://dom.spec.whatwg.org/#interface-htmlcollection" data-x-internal="htmlcollection"><c- n="">HTMLCollection</c-></a> <a href="#dom-document-applets" id="other-elements,-attributes-and-apis:dom-document-applets"><c- g="">applets</c-></a>;

  <c- b="">undefined</c-> <a href="#dom-document-clear" id="other-elements,-attributes-and-apis:dom-document-clear"><c- g="">clear</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-document-captureevents" id="other-elements,-attributes-and-apis:dom-document-captureevents"><c- g="">captureEvents</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-document-releaseevents" id="other-elements,-attributes-and-apis:dom-document-releaseevents"><c- g="">releaseEvents</c-></a>();

  [<c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#htmlallcollection" id="other-elements,-attributes-and-apis:htmlallcollection"><c- n="">HTMLAllCollection</c-></a> <a href="#dom-document-all" id="other-elements,-attributes-and-apis:dom-document-all"><c- g="">all</c-></a>;
};</code></pre>

  <div data-algorithm="">
  <p>The attributes of the <code id="other-elements,-attributes-and-apis:document"><a href="#document">Document</a></code> object listed in the first column of the following
  table must <a href="#reflect" id="other-elements,-attributes-and-apis:reflect">reflect</a> the content attribute on <a href="#the-body-element-2" id="other-elements,-attributes-and-apis:the-body-element-2">the body element</a> with the
  name given in the corresponding cell in the second column on the same row, if <a href="#the-body-element-2" id="other-elements,-attributes-and-apis:the-body-element-2-2">the body
  element</a> is a <code id="other-elements,-attributes-and-apis:the-body-element"><a href="#the-body-element">body</a></code> element (as opposed to a <code id="other-elements,-attributes-and-apis:frameset"><a href="#frameset">frameset</a></code> element).
  When there is no <a href="#the-body-element-2" id="other-elements,-attributes-and-apis:the-body-element-2-3">body element</a> or if it is a
  <code id="other-elements,-attributes-and-apis:frameset-2"><a href="#frameset">frameset</a></code> element, the attributes must instead return the empty string on getting and
  do nothing on setting.</p>

  <table><thead><tr><th> IDL attribute
     </th><th> Content attribute
   </th></tr></thead><tbody><tr><td><dfn data-dfn-for="Document" id="dom-document-fgcolor" data-dfn-type="attribute"><code>fgColor</code></dfn>
     </td><td><code id="other-elements,-attributes-and-apis:attr-body-text"><a href="#attr-body-text">text</a></code>
    </td></tr><tr><td><dfn data-dfn-for="Document" id="dom-document-linkcolor" data-dfn-type="attribute"><code>linkColor</code></dfn>
     </td><td><code id="other-elements,-attributes-and-apis:attr-body-link"><a href="#attr-body-link">link</a></code>
    </td></tr><tr><td><dfn data-dfn-for="Document" id="dom-document-vlinkcolor" data-dfn-type="attribute"><code>vlinkColor</code></dfn>
     </td><td><code id="other-elements,-attributes-and-apis:attr-body-vlink"><a href="#attr-body-vlink">vlink</a></code>
    </td></tr><tr><td><dfn data-dfn-for="Document" id="dom-document-alinkcolor" data-dfn-type="attribute"><code>alinkColor</code></dfn>
     </td><td><code id="other-elements,-attributes-and-apis:attr-body-alink"><a href="#attr-body-alink">alink</a></code>
    </td></tr><tr><td><dfn data-dfn-for="Document" id="dom-document-bgcolor" data-dfn-type="attribute"><code>bgColor</code></dfn>
     </td><td><code id="other-elements,-attributes-and-apis:attr-body-bgcolor"><a href="#attr-body-bgcolor">bgcolor</a></code>
  </td></tr></tbody></table>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-anchors" data-dfn-type="attribute"><code>anchors</code></dfn>
  attribute must return an <code id="other-elements,-attributes-and-apis:htmlcollection-3"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="other-elements,-attributes-and-apis:document-2"><a href="#document">Document</a></code> node,
  whose filter matches only <code id="other-elements,-attributes-and-apis:the-a-element"><a href="#the-a-element">a</a></code> elements with <code id="other-elements,-attributes-and-apis:attr-a-name"><a href="#attr-a-name">name</a></code>
  attributes.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-applets" data-dfn-type="attribute"><code>applets</code></dfn>
  attribute must return an <code id="other-elements,-attributes-and-apis:htmlcollection-4"><a data-x-internal="htmlcollection" href="https://dom.spec.whatwg.org/#interface-htmlcollection">HTMLCollection</a></code> rooted at the <code id="other-elements,-attributes-and-apis:document-3"><a href="#document">Document</a></code> node,
  whose filter matches nothing. (It exists for historical reasons.)</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-clear" data-dfn-type="method"><code>clear()</code></dfn>,
  <dfn data-dfn-for="Document" id="dom-document-captureevents" data-dfn-type="method"><code>captureEvents()</code></dfn>,
  and <dfn data-dfn-for="Document" id="dom-document-releaseevents" data-dfn-type="method"><code>releaseEvents()</code></dfn> methods must do nothing.</p>
  </div>

  <hr>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Document" id="dom-document-all" data-dfn-type="attribute"><code>all</code></dfn> attribute
  must return an <code id="other-elements,-attributes-and-apis:htmlallcollection-2"><a href="#htmlallcollection">HTMLAllCollection</a></code> rooted at the <code id="other-elements,-attributes-and-apis:document-4"><a href="#document">Document</a></code> node, whose
  filter matches all elements.</p>
  </div>

  <hr>

  <pre><code class="idl"><c- b="">partial</c-> <c- b="">interface</c-> <a href="#window" id="Window-partial"><c- g="">Window</c-></a> {
  <c- b="">undefined</c-> <a href="#dom-window-captureevents" id="other-elements,-attributes-and-apis:dom-window-captureevents"><c- g="">captureEvents</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-window-releaseevents" id="other-elements,-attributes-and-apis:dom-window-releaseevents"><c- g="">releaseEvents</c-></a>();

  [<c- g="">Replaceable</c->, <c- g="">SameObject</c->] <c- b="">readonly</c-> <c- b="">attribute</c-> <a href="#external" id="other-elements,-attributes-and-apis:external"><c- n="">External</c-></a> <a href="#dom-external" id="other-elements,-attributes-and-apis:dom-external"><c- g="">external</c-></a>;
};</code></pre>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-window-captureevents" data-dfn-type="method"><code>captureEvents()</code></dfn> and <dfn data-dfn-for="Window" id="dom-window-releaseevents" data-dfn-type="method"><code>releaseEvents()</code></dfn> methods must do nothing.</p>
  </div>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="Window" id="dom-external" data-dfn-type="attribute"><code>external</code></dfn> attribute of
  the <code id="other-elements,-attributes-and-apis:window"><a href="#window">Window</a></code> interface must return an instance of the <code id="other-elements,-attributes-and-apis:external-2"><a href="#external">External</a></code>
  interface:</p>
  </div>

  <pre><code class="idl">[<c- g="">Exposed</c->=<c- n="">Window</c->]
<c- b="">interface</c-> <dfn id="external" data-dfn-type="interface"><c- g="">External</c-></dfn> {
  <c- b="">undefined</c-> <a href="#dom-external-addsearchprovider" id="other-elements,-attributes-and-apis:dom-external-addsearchprovider"><c- g="">AddSearchProvider</c-></a>();
  <c- b="">undefined</c-> <a href="#dom-external-issearchproviderinstalled" id="other-elements,-attributes-and-apis:dom-external-issearchproviderinstalled"><c- g="">IsSearchProviderInstalled</c-></a>();
};</code></pre>

  <div data-algorithm="">
  <p>The <dfn data-dfn-for="External" id="dom-external-addsearchprovider" data-dfn-type="method"><code>AddSearchProvider()</code></dfn> and <dfn data-dfn-for="External" id="dom-external-issearchproviderinstalled" data-dfn-type="method"><code>IsSearchProviderInstalled()</code></dfn> methods
  must do nothing.</p>
  </div>

  



  

  <h2 id="iana"><span class="secno">17</span> IANA considerations<a href="#iana" class="self-link"></a></h2>

  


  <h3 id="text/html"><span class="secno">17.1</span> <dfn><code>text/html</code></dfn><a href="#text/html" class="self-link"></a></h3>

  <p>This registration is for community review and will be submitted to the IESG for review,
  approval, and registration with IANA.</p>

  

  

  <dl><dt>Type name:</dt><dd>text</dd><dt>Subtype name:</dt><dd>html</dd><dt>Required parameters:</dt><dd>No required parameters</dd><dt>Optional parameters:</dt><dd>
    <dl><dt><code>charset</code></dt><dd>
      <p>The <code>charset</code> parameter may be provided to specify the
      <a id="text/html:document's-character-encoding" href="https://dom.spec.whatwg.org/#concept-document-encoding" data-x-internal="document's-character-encoding">document's character encoding</a>, overriding any <a href="#character-encoding-declaration" id="text/html:character-encoding-declaration">character encoding declarations</a> in the document other than a Byte Order
      Mark (BOM). The parameter's value must be an <a id="text/html:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for the
      string "<code>utf-8</code>". <a href="#refsENCODING">[ENCODING]</a></p>
     </dd></dl>
   </dd><dt>Encoding considerations:</dt><dd>
    8bit (see the section on <a href="#character-encoding-declaration" id="text/html:character-encoding-declaration-2">character encoding
    declarations</a>)
   </dd><dt>Security considerations:</dt><dd>
    <p>Entire novels have been written about the security considerations that apply to HTML
    documents. Many are listed in this document, to which the reader is referred for more details.
    Some general concerns bear mentioning here, however:</p>

    <p>HTML is scripted language, and has a large number of APIs (some of which are described in
    this document). Script can expose the user to potential risks of information leakage, credential
    leakage, cross-site scripting attacks, cross-site request forgeries, and a host of other
    problems. While the designs in this specification are intended to be safe if implemented
    correctly, a full implementation is a massive undertaking and, as with any software, user agents
    are likely to have security bugs.</p>

    <p>Even without scripting, there are specific features in HTML which, for historical reasons,
    are required for broad compatibility with legacy content but that expose the user to unfortunate
    security problems. In particular, the <code id="text/html:the-img-element"><a href="#the-img-element">img</a></code> element can be used in conjunction with
    some other features as a way to effect a port scan from the user's location on the Internet.
    This can expose local network topologies that the attacker would otherwise not be able to
    determine.</p>

    <p>HTML relies on a compartmentalization scheme sometimes known as the <i>same-origin
    policy</i>. An <a href="#concept-origin" id="text/html:concept-origin">origin</a> in most cases consists of all the pages served from the same
    host, on the same port, using the same protocol.</p>

    <p>It is critical, therefore, to ensure that any untrusted content that forms part of a site be
    hosted on a different <a href="#concept-origin" id="text/html:concept-origin-2">origin</a> than any sensitive content on that site. Untrusted
    content can easily spoof any other page on the same origin, read data from that origin, cause
    scripts in that origin to execute, submit forms to and from that origin even if they are
    protected from cross-site request forgery attacks by unique tokens, and make use of any
    third-party resources exposed to or rights granted to that origin.</p>
   </dd><dt>Interoperability considerations:</dt><dd>
    Rules for processing both conforming and non-conforming content
    are defined in this specification.
   </dd><dt>Published specification:</dt><dd id="authors-using-html">
    This document is the relevant specification. Labeling a resource
    with the <code id="text/html:text/html"><a href="#text/html">text/html</a></code> type asserts that the resource is
    an <a href="https://dom.spec.whatwg.org/#html-document" id="text/html:html-documents" data-x-internal="html-documents">HTML document</a> using
    <a href="#syntax" id="text/html:syntax">the HTML syntax</a>.
   </dd><dt>Applications that use this media type:</dt><dd>
    Web browsers, tools for processing web content, HTML authoring
    tools, search engines, validators.
   </dd><dt>Additional information:</dt><dd>
    <dl><dt>Magic number(s):</dt><dd>No sequence of bytes can uniquely identify an HTML
     document. More information on detecting HTML documents is
     available in <cite>MIME Sniffing</cite>. <a href="#refsMIMESNIFF">[MIMESNIFF]</a></dd><dt>File extension(s):</dt><dd>"<code>html</code>" and "<code>htm</code>"
     are commonly, but certainly not exclusively, used as the
     extension for HTML documents.</dd><dt>Macintosh file type code(s):</dt><dd><code>TEXT</code></dd></dl>
   </dd><dt>Person &amp; email address to contact for further information:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Intended usage:</dt><dd>Common</dd><dt>Restrictions on usage:</dt><dd>No restrictions apply.</dd><dt>Author:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Change controller:</dt><dd>W3C</dd></dl>

  <p><a href="https://url.spec.whatwg.org/#concept-url-fragment" id="text/html:concept-url-fragment" data-x-internal="concept-url-fragment">Fragments</a> used with <code id="text/html:text/html-2"><a href="#text/html">text/html</a></code> resources
  either refer to the <a href="#the-indicated-part-of-the-document" id="text/html:the-indicated-part-of-the-document">indicated part</a> of the corresponding <code id="text/html:document"><a href="#document">Document</a></code>, or
  provide state information for in-page scripts.</p>



  <h3 id="multipart/x-mixed-replace"><span class="secno">17.2</span> <dfn><code>multipart/x-mixed-replace</code></dfn><a href="#multipart/x-mixed-replace" class="self-link"></a></h3>

  <p>This registration is for community review and will be submitted to the IESG for review,
  approval, and registration with IANA.</p>

  

  <dl><dt>Type name:</dt><dd>multipart</dd><dt>Subtype name:</dt><dd>x-mixed-replace</dd><dt>Required parameters:</dt><dd>
    <ul class="brief"><li><code>boundary</code> (defined in RFC2046) <a href="#refsRFC2046">[RFC2046]</a>
    </li></ul>
   </dd><dt>Optional parameters:</dt><dd>No optional parameters.</dd><dt>Encoding considerations:</dt><dd>binary</dd><dt>Security considerations:</dt><dd>
    Subresources of a <code id="multipart/x-mixed-replace:multipart/x-mixed-replace"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code>
    resource can be of any type, including types with non-trivial
    security implications such as <code id="multipart/x-mixed-replace:text/html"><a href="#text/html">text/html</a></code>.
   </dd><dt>Interoperability considerations:</dt><dd>
    None.
   </dd><dt>Published specification:</dt><dd>
    This specification describes processing rules for web browsers.
    Conformance requirements for generating resources with this type are the same as for <code id="multipart/x-mixed-replace:multipart/mixed"><a href="#multipart/mixed">multipart/mixed</a></code>. <a href="#refsRFC2046">[RFC2046]</a>
   </dd><dt>Applications that use this media type:</dt><dd>
    This type is intended to be used in resources generated by web servers, for consumption by web browsers.
   </dd><dt>Additional information:</dt><dd>
    <dl><dt>Magic number(s):</dt><dd>No sequence of bytes can uniquely identify a <code id="multipart/x-mixed-replace:multipart/x-mixed-replace-2"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code> resource.</dd><dt>File extension(s):</dt><dd>No specific file extensions are recommended for this type.</dd><dt>Macintosh file type code(s):</dt><dd>No specific Macintosh file type codes are recommended for this type.</dd></dl>
   </dd><dt>Person &amp; email address to contact for further information:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Intended usage:</dt><dd>Common</dd><dt>Restrictions on usage:</dt><dd>No restrictions apply.</dd><dt>Author:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Change controller:</dt><dd>W3C</dd></dl>

  <p><a href="https://url.spec.whatwg.org/#concept-url-fragment" id="multipart/x-mixed-replace:concept-url-fragment" data-x-internal="concept-url-fragment">Fragments</a> used with
  <code id="multipart/x-mixed-replace:multipart/x-mixed-replace-3"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code> resources apply to each body part as defined by the type
  used by that body part.</p>


  <h3 id="application/xhtml+xml"><span class="secno">17.3</span> <dfn><code>application/xhtml+xml</code></dfn><a href="#application/xhtml+xml" class="self-link"></a></h3>

  <p>This registration is for community review and will be submitted to the IESG for review,
  approval, and registration with IANA.</p>

  

  

  <dl><dt>Type name:</dt><dd>application</dd><dt>Subtype name:</dt><dd>xhtml+xml</dd><dt>Required parameters:</dt><dd>Same as for <code id="application/xhtml+xml:application/xml"><a href="#application/xml">application/xml</a></code> <a href="#refsRFC7303">[RFC7303]</a></dd><dt>Optional parameters:</dt><dd>Same as for <code id="application/xhtml+xml:application/xml-2"><a href="#application/xml">application/xml</a></code> <a href="#refsRFC7303">[RFC7303]</a></dd><dt>Encoding considerations:</dt><dd>Same as for <code id="application/xhtml+xml:application/xml-3"><a href="#application/xml">application/xml</a></code> <a href="#refsRFC7303">[RFC7303]</a></dd><dt>Security considerations:</dt><dd>Same as for <code id="application/xhtml+xml:application/xml-4"><a href="#application/xml">application/xml</a></code> <a href="#refsRFC7303">[RFC7303]</a></dd><dt>Interoperability considerations:</dt><dd>Same as for <code id="application/xhtml+xml:application/xml-5"><a href="#application/xml">application/xml</a></code> <a href="#refsRFC7303">[RFC7303]</a></dd><dt id="authors-using-xhtml">Published specification:</dt><dd>Labeling a resource with the <code id="application/xhtml+xml:application/xhtml+xml"><a href="#application/xhtml+xml">application/xhtml+xml</a></code> type asserts that the
   resource is an XML document that likely has a <a id="application/xhtml+xml:document-element" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> from the <a id="application/xhtml+xml:html-namespace-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
   namespace</a>. Thus, the relevant specifications are <cite>XML</cite>, <cite>Namespaces in
   XML</cite>, and this specification. <a href="#refsXML">[XML]</a> <a href="#refsXMLNS">[XMLNS]</a></dd><dt>Applications that use this media type:</dt><dd>Same as for <code id="application/xhtml+xml:application/xml-6"><a href="#application/xml">application/xml</a></code> <a href="#refsRFC7303">[RFC7303]</a></dd><dt>Additional information:</dt><dd>
    <dl><dt>Magic number(s):</dt><dd>Same as for <code id="application/xhtml+xml:application/xml-7"><a href="#application/xml">application/xml</a></code> <a href="#refsRFC7303">[RFC7303]</a></dd><dt>File extension(s):</dt><dd>"<code>xhtml</code>" and "<code>xht</code>" are sometimes used as
     extensions for XML resources that have a <a id="application/xhtml+xml:document-element-2" href="https://dom.spec.whatwg.org/#document-element" data-x-internal="document-element">document element</a> from the <a id="application/xhtml+xml:html-namespace-2-2" href="https://infra.spec.whatwg.org/#html-namespace" data-x-internal="html-namespace-2">HTML
     namespace</a>.</dd><dt>Macintosh file type code(s):</dt><dd><code>TEXT</code></dd></dl>
   </dd><dt>Person &amp; email address to contact for further information:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Intended usage:</dt><dd>Common</dd><dt>Restrictions on usage:</dt><dd>No restrictions apply.</dd><dt>Author:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Change controller:</dt><dd>W3C</dd></dl>

  <p><a href="https://url.spec.whatwg.org/#concept-url-fragment" id="application/xhtml+xml:concept-url-fragment" data-x-internal="concept-url-fragment">Fragments</a> used with
  <code id="application/xhtml+xml:application/xhtml+xml-2"><a href="#application/xhtml+xml">application/xhtml+xml</a></code> resources have the same semantics as with any
  <a id="application/xhtml+xml:xml-mime-type" href="https://mimesniff.spec.whatwg.org/#xml-mime-type" data-x-internal="xml-mime-type">XML MIME type</a>. <a href="#refsRFC7303">[RFC7303]</a></p>


  <h3 id="text/ping"><span class="secno">17.4</span> <dfn><code>text/ping</code></dfn><a href="#text/ping" class="self-link"></a></h3>

  <p>This registration is for community review and will be submitted to the IESG for review,
  approval, and registration with IANA.</p>

  

  <dl><dt>Type name:</dt><dd>text</dd><dt>Subtype name:</dt><dd>ping</dd><dt>Required parameters:</dt><dd>No parameters</dd><dt>Optional parameters:</dt><dd>
    <dl><dt><code>charset</code></dt><dd>
      <p>The <code>charset</code> parameter may be provided. The parameter's value must be
      "<code>utf-8</code>". This parameter serves no purpose; it is only allowed for
      compatibility with legacy servers.</p>
     </dd></dl>
   </dd><dt>Encoding considerations:</dt><dd>Not applicable.</dd><dt>Security considerations:</dt><dd>
    <p>If used exclusively in the fashion described in the context of
    <a href="#hyperlink-auditing" id="text/ping:hyperlink-auditing">hyperlink auditing</a>, this type introduces no new
    security concerns.</p>
   </dd><dt>Interoperability considerations:</dt><dd>
    Rules applicable to this type are defined in this specification.
   </dd><dt>Published specification:</dt><dd>
    This document is the relevant specification.
   </dd><dt>Applications that use this media type:</dt><dd>
    Web browsers.
   </dd><dt>Additional information:</dt><dd>
    <dl><dt>Magic number(s):</dt><dd><code id="text/ping:text/ping"><a href="#text/ping">text/ping</a></code> resources always consist of the four
     bytes 0x50 0x49 0x4E 0x47 (`<code>PING</code>`).</dd><dt>File extension(s):</dt><dd>No specific file extension is recommended for this type.</dd><dt>Macintosh file type code(s):</dt><dd>No specific Macintosh file type codes are recommended for this type.</dd></dl>
   </dd><dt>Person &amp; email address to contact for further information:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Intended usage:</dt><dd>Common</dd><dt>Restrictions on usage:</dt><dd>Only intended for use with HTTP POST requests generated as part
   of a web browser's processing of the <code id="text/ping:ping"><a href="#ping">ping</a></code> attribute.</dd><dt>Author:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Change controller:</dt><dd>W3C</dd></dl>

  <p><a href="https://url.spec.whatwg.org/#concept-url-fragment" id="text/ping:concept-url-fragment" data-x-internal="concept-url-fragment">Fragments</a> have no meaning with
  <code id="text/ping:text/ping-2"><a href="#text/ping">text/ping</a></code> resources.</p>


  <h3 id="application/microdata+json"><span class="secno">17.5</span> <dfn><code>application/microdata+json</code></dfn><a href="#application/microdata+json" class="self-link"></a></h3>

  <p>This registration is for community review and will be submitted to the IESG for review,
  approval, and registration with IANA.</p>

  

  <dl><dt>Type name:</dt><dd>application</dd><dt>Subtype name:</dt><dd>microdata+json</dd><dt>Required parameters:</dt><dd>Same as for <code id="application/microdata+json:application/json"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Optional parameters:</dt><dd>Same as for <code id="application/microdata+json:application/json-2"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Encoding considerations:</dt><dd>8bit (always UTF-8)</dd><dt>Security considerations:</dt><dd>Same as for <code id="application/microdata+json:application/json-3"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Interoperability considerations:</dt><dd>Same as for <code id="application/microdata+json:application/json-4"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Published specification:</dt><dd>
    Labeling a resource with the <code id="application/microdata+json:application/microdata+json"><a href="#application/microdata+json">application/microdata+json</a></code> type asserts that the
    resource is a JSON text that consists of an object with a single entry called "<code>items</code>" consisting of an array of entries, each of which consists of an object
    with an entry called "<code>id</code>" whose value is a string, an entry called "<code>type</code>" whose value is another string, and an entry called "<code>properties</code>" whose value is an object whose entries each have a value consisting
    of an array of either objects or strings, the objects being of the same form as the objects in
    the aforementioned "<code>items</code>" entry. Thus, the relevant specifications are
    <cite>JSON</cite> and this specification. <a href="#refsJSON">[JSON]</a>
   </dd><dt>Applications that use this media type:</dt><dd>
    <p>Applications that transfer data intended for use with HTML's microdata feature, especially in
    the context of drag-and-drop, are the primary application class for this type.</p>
   </dd><dt>Additional information:</dt><dd>
    <dl><dt>Magic number(s):</dt><dd>Same as for <code id="application/microdata+json:application/json-5"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>File extension(s):</dt><dd>Same as for <code id="application/microdata+json:application/json-6"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Macintosh file type code(s):</dt><dd>Same as for <code id="application/microdata+json:application/json-7"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd></dl>
   </dd><dt>Person &amp; email address to contact for further information:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Intended usage:</dt><dd>Common</dd><dt>Restrictions on usage:</dt><dd>No restrictions apply.</dd><dt>Author:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Change controller:</dt><dd>W3C</dd></dl>

  <p><a href="https://url.spec.whatwg.org/#concept-url-fragment" id="application/microdata+json:concept-url-fragment" data-x-internal="concept-url-fragment">Fragments</a> used with
  <code id="application/microdata+json:application/microdata+json-2"><a href="#application/microdata+json">application/microdata+json</a></code> resources have the same semantics as when used with
  <code id="application/microdata+json:application/json-8"><a href="#application/json">application/json</a></code> (namely, at the time of writing, no semantics at all).
  <a href="#refsJSON">[JSON]</a></p>

  <h3 id="application/speculationrules+json"><span class="secno">17.6</span> <dfn><code>application/speculationrules+json</code></dfn><a href="#application/speculationrules+json" class="self-link"></a></h3>

  <p>This registration is for community review and will be submitted to the IESG for review,
  approval, and registration with IANA.</p>

  

  <dl><dt>Type name:</dt><dd>application</dd><dt>Subtype name:</dt><dd>microdata+json</dd><dt>Required parameters:</dt><dd>Same as for <code id="application/speculationrules+json:application/json"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Optional parameters:</dt><dd>Same as for <code id="application/speculationrules+json:application/json-2"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Encoding considerations:</dt><dd>8bit (always UTF-8)</dd><dt>Security considerations:</dt><dd>Same as for <code id="application/speculationrules+json:application/json-3"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Interoperability considerations:</dt><dd>Same as for <code id="application/speculationrules+json:application/json-4"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Published specification:</dt><dd>
    Labeling a resource with the <code id="application/speculationrules+json:application/microdata+json"><a href="#application/microdata+json">application/microdata+json</a></code> type asserts that the
    resource is a JSON text that follows the <a href="#speculation-rule-set-authoring-requirements" id="application/speculationrules+json:speculation-rule-set-authoring-requirements">speculation rule set authoring requirements</a>. Thus, the relevant specifications are
    <cite>JSON</cite> and this specification. <a href="#refsJSON">[JSON]</a>
   </dd><dt>Applications that use this media type:</dt><dd>
    <p>Web browsers.</p>
   </dd><dt>Additional information:</dt><dd>
    <dl><dt>Magic number(s):</dt><dd>Same as for <code id="application/speculationrules+json:application/json-5"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>File extension(s):</dt><dd>Same as for <code id="application/speculationrules+json:application/json-6"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd><dt>Macintosh file type code(s):</dt><dd>Same as for <code id="application/speculationrules+json:application/json-7"><a href="#application/json">application/json</a></code> <a href="#refsJSON">[JSON]</a></dd></dl>
   </dd><dt>Person &amp; email address to contact for further information:</dt><dd>Domenic Denicola &lt;d@domenic.me&gt;</dd><dt>Intended usage:</dt><dd>Common</dd><dt>Restrictions on usage:</dt><dd>No restrictions apply.</dd><dt>Author:</dt><dd>Domenic Denicola &lt;d@domenic.me&gt;</dd><dt>Change controller:</dt><dd>WHATWG</dd></dl>

  <p><a href="https://url.spec.whatwg.org/#concept-url-fragment" id="application/speculationrules+json:concept-url-fragment" data-x-internal="concept-url-fragment">Fragments</a> used with
  <code id="application/speculationrules+json:application/speculationrules+json"><a href="#application/speculationrules+json">application/speculationrules+json</a></code> resources have the same semantics as when used with
  <code id="application/speculationrules+json:application/json-8"><a href="#application/json">application/json</a></code> (namely, at the time of writing, no semantics at all).
  <a href="#refsJSON">[JSON]</a></p>


  <h3 id="text/event-stream"><span class="secno">17.7</span> <dfn><code>text/event-stream</code></dfn><a href="#text/event-stream" class="self-link"></a></h3>

  <p>This registration is for community review and will be submitted to the IESG for review,
  approval, and registration with IANA.</p>

  

  <dl><dt>Type name:</dt><dd>text</dd><dt>Subtype name:</dt><dd>event-stream</dd><dt>Required parameters:</dt><dd>No parameters</dd><dt>Optional parameters:</dt><dd>
    <dl><dt><code>charset</code></dt><dd>
      <p>The <code>charset</code> parameter may be provided. The parameter's value must be
      "<code>utf-8</code>". This parameter serves no purpose; it is only allowed for
      compatibility with legacy servers.</p>
     </dd></dl>
   </dd><dt>Encoding considerations:</dt><dd>8bit (always UTF-8)</dd><dt>Security considerations:</dt><dd>
    <p>An event stream from an origin distinct from the origin of the content consuming the event
    stream can result in information leakage. To avoid this, user agents are required to apply CORS
    semantics. <a href="#refsFETCH">[FETCH]</a></p>

    <p>Event streams can overwhelm a user agent; a user agent is expected to apply suitable
    restrictions to avoid depleting local resources because of an overabundance of information from
    an event stream.</p>

    <p>Servers can be overwhelmed if a situation develops in which the server is causing clients to
    reconnect rapidly. Servers should use a 5xx status code to indicate capacity problems, as this
    will prevent conforming clients from reconnecting automatically.</p>
   </dd><dt>Interoperability considerations:</dt><dd>
    Rules for processing both conforming and non-conforming content are defined in this
    specification.
   </dd><dt>Published specification:</dt><dd>
    This document is the relevant specification.
   </dd><dt>Applications that use this media type:</dt><dd>
    Web browsers and tools using web services.
   </dd><dt>Additional information:</dt><dd>
    <dl><dt>Magic number(s):</dt><dd>No sequence of bytes can uniquely identify an event stream.</dd><dt>File extension(s):</dt><dd>No specific file extensions are recommended for this type.</dd><dt>Macintosh file type code(s):</dt><dd>No specific Macintosh file type codes are recommended for this type.</dd></dl>
   </dd><dt>Person &amp; email address to contact for further information:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Intended usage:</dt><dd>Common</dd><dt>Restrictions on usage:</dt><dd>This format is only expected to be used by dynamic open-ended streams served using HTTP or a
   similar protocol. Finite resources are not expected to be labeled with this type.</dd><dt>Author:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Change controller:</dt><dd>W3C</dd></dl>

  <p><a href="https://url.spec.whatwg.org/#concept-url-fragment" id="text/event-stream:concept-url-fragment" data-x-internal="concept-url-fragment">Fragments</a> have no meaning with
  <code id="text/event-stream:text/event-stream"><a href="#text/event-stream">text/event-stream</a></code> resources.</p>


  <h3 id="web+-scheme-prefix"><span class="secno">17.8</span> <dfn><code>web+</code> scheme prefix</dfn><a href="#web+-scheme-prefix" class="self-link"></a></h3>

  <p>This section describes a convention for use with the IANA URI scheme registry. It does not
  itself register a specific scheme. <a href="#refsRFC7595">[RFC7595]</a></p>

  <dl><dt>Scheme name:</dt><dd>
    Schemes starting with the four characters "<code>web+</code>" followed by one or more letters in the range
    <code>a</code>-<code>z</code>.
   </dd><dt>Status:</dt><dd>Permanent</dd><dt>Scheme syntax:</dt><dd>Scheme-specific.</dd><dt>Scheme semantics:</dt><dd>Scheme-specific.</dd><dt>Encoding considerations:</dt><dd>All "<code>web+</code>" schemes should use UTF-8 encodings where relevant.</dd><dt>Applications/protocols that use this scheme name:</dt><dd>Scheme-specific.</dd><dt>Interoperability considerations:</dt><dd>The scheme is expected to be used in the context of web applications.</dd><dt>Security considerations:</dt><dd>
    Any web page is able to register a handler for all "<code>web+</code>" schemes. As
    such, these schemes must not be used for features intended to be core platform features (e.g.,
    HTTP). Similarly, such schemes must not store confidential information in their URLs, such as
    usernames, passwords, personal information, or confidential project names.
   </dd><dt>Contact:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>Change controller:</dt><dd>Ian Hickson &lt;ian@hixie.ch&gt;</dd><dt>References:</dt><dd>
    <cite>Custom scheme handlers</cite>, HTML Living Standard:
    <a href="#custom-handlers">https://html.spec.whatwg.org/#custom-handlers</a>
   </dd></dl>

  



  <h2 id="index" class="no-num">Index<a href="#index" class="self-link"></a></h2>

  

  <p>The following sections only cover conforming elements and features.</p>

  

  <h3 id="elements-3" class="no-num">Elements<a href="#elements-3" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <table><caption>List of elements</caption><thead><tr><th> Element
     </th><th> Description
     </th><th> Categories
     </th><th> Parents†
     </th><th> Children
     </th><th> Attributes
     </th><th> Interface
   </th></tr></thead><tbody><tr><th><code id="elements-3:the-a-element"><a href="#the-a-element">a</a></code></th><td>Hyperlink</td><td><a href="#flow-content-2" id="elements-3:flow-content-2">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2">phrasing</a>*;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2">interactive</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-2">phrasing</a></td><td><a href="#transparent" id="elements-3:transparent">transparent</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes">globals</a>;
         <code id="elements-3:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code>;
         <code id="elements-3:attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code>;
         <code id="elements-3:attr-hyperlink-download"><a href="#attr-hyperlink-download">download</a></code>;
         <code id="elements-3:ping"><a href="#ping">ping</a></code>;
         <code id="elements-3:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code>;
         <code id="elements-3:attr-hyperlink-hreflang"><a href="#attr-hyperlink-hreflang">hreflang</a></code>;
         <code id="elements-3:attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code>;
         <code id="elements-3:attr-hyperlink-referrerpolicy"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code></td><td><code id="elements-3:htmlanchorelement"><a href="#htmlanchorelement">HTMLAnchorElement</a></code></td></tr><tr><th><code id="elements-3:the-abbr-element"><a href="#the-abbr-element">abbr</a></code></th><td>Abbreviation</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-2">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-3">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-2">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-4">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-5">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-2">globals</a></td><td><code id="elements-3:htmlelement"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-address-element"><a href="#the-address-element">address</a></code></th><td>Contact information for a page or <code id="elements-3:the-article-element"><a href="#the-article-element">article</a></code> element</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-3">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-3">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-4">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-5">flow</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-3">globals</a></td><td><code id="elements-3:htmlelement-2"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-area-element"><a href="#the-area-element">area</a></code></th><td>Hyperlink or dead area on an image map</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-6">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-6">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-7">phrasing</a>*</td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-4">globals</a>;
         <code id="elements-3:attr-area-alt"><a href="#attr-area-alt">alt</a></code>;
         <code id="elements-3:attr-area-coords"><a href="#attr-area-coords">coords</a></code>;
         <code id="elements-3:attr-area-shape"><a href="#attr-area-shape">shape</a></code>;
         <code id="elements-3:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">href</a></code>;
         <code id="elements-3:attr-hyperlink-target-2"><a href="#attr-hyperlink-target">target</a></code>;
         <code id="elements-3:attr-hyperlink-download-2"><a href="#attr-hyperlink-download">download</a></code>;
         <code id="elements-3:ping-2"><a href="#ping">ping</a></code>;
         <code id="elements-3:attr-hyperlink-rel-2"><a href="#attr-hyperlink-rel">rel</a></code>;
         <code id="elements-3:attr-hyperlink-referrerpolicy-2"><a href="#attr-hyperlink-referrerpolicy">referrerpolicy</a></code></td><td><code id="elements-3:htmlareaelement"><a href="#htmlareaelement">HTMLAreaElement</a></code></td></tr><tr><th><code id="elements-3:the-article-element-2"><a href="#the-article-element">article</a></code></th><td>Self-contained syndicatable or reusable composition</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-7">flow</a>;
         <a href="#sectioning-content-2" id="elements-3:sectioning-content-2">sectioning</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-4">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-8">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-9">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-5">globals</a></td><td><code id="elements-3:htmlelement-3"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-aside-element"><a href="#the-aside-element">aside</a></code></th><td>Sidebar for tangentially related content</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-10">flow</a>;
         <a href="#sectioning-content-2" id="elements-3:sectioning-content-2-2">sectioning</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-5">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-11">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-12">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-6">globals</a></td><td><code id="elements-3:htmlelement-4"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-audio-element"><a href="#the-audio-element">audio</a></code></th><td>Audio player</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-13">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-8">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category">embedded</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-2">interactive</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-6">palpable</a>*</td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-9">phrasing</a></td><td><code id="elements-3:the-source-element"><a href="#the-source-element">source</a></code>*;
         <code id="elements-3:the-track-element"><a href="#the-track-element">track</a></code>*;
         <a href="#transparent" id="elements-3:transparent-2">transparent</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-7">globals</a>;
         <code id="elements-3:attr-media-src"><a href="#attr-media-src">src</a></code>;
         <code id="elements-3:attr-media-crossorigin"><a href="#attr-media-crossorigin">crossorigin</a></code>;
         <code id="elements-3:attr-media-preload"><a href="#attr-media-preload">preload</a></code>;
         <code id="elements-3:attr-media-autoplay"><a href="#attr-media-autoplay">autoplay</a></code>;
         <code id="elements-3:attr-media-loop"><a href="#attr-media-loop">loop</a></code>;
         <code id="elements-3:attr-media-muted"><a href="#attr-media-muted">muted</a></code>;
         <code id="elements-3:attr-media-controls"><a href="#attr-media-controls">controls</a></code></td><td><code id="elements-3:htmlaudioelement"><a href="#htmlaudioelement">HTMLAudioElement</a></code></td></tr><tr><th><code id="elements-3:the-b-element"><a href="#the-b-element">b</a></code></th><td>Keywords</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-14">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-10">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-7">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-11">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-12">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-8">globals</a></td><td><code id="elements-3:htmlelement-5"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-base-element"><a href="#the-base-element">base</a></code></th><td>Base URL and default target <a href="#navigable" id="elements-3:navigable">navigable</a> for <a href="#attr-hyperlink-target" id="elements-3:attr-hyperlink-target-3">hyperlinks</a> and <a href="#attr-fs-target" id="elements-3:attr-fs-target">forms</a></td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2">metadata</a></td><td><code id="elements-3:the-head-element"><a href="#the-head-element">head</a></code></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-9">globals</a>;
         <code id="elements-3:attr-base-href"><a href="#attr-base-href">href</a></code>;
         <code id="elements-3:attr-base-target"><a href="#attr-base-target">target</a></code></td><td><code id="elements-3:htmlbaseelement"><a href="#htmlbaseelement">HTMLBaseElement</a></code></td></tr><tr><th><code id="elements-3:the-bdi-element"><a href="#the-bdi-element">bdi</a></code></th><td>Text directionality isolation</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-15">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-13">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-8">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-14">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-15">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-10">globals</a></td><td><code id="elements-3:htmlelement-6"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-bdo-element"><a href="#the-bdo-element">bdo</a></code></th><td>Text directionality formatting</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-16">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-16">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-9">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-17">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-18">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-11">globals</a></td><td><code id="elements-3:htmlelement-7"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code></th><td>A section quoted from another source</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-17">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-10">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-18">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-19">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-12">globals</a>;
         <code id="elements-3:attr-blockquote-cite"><a href="#attr-blockquote-cite">cite</a></code></td><td><code id="elements-3:htmlquoteelement"><a href="#htmlquoteelement">HTMLQuoteElement</a></code></td></tr><tr><th><code id="elements-3:the-body-element"><a href="#the-body-element">body</a></code></th><td>Document body</td><td>none</td><td><code id="elements-3:the-html-element"><a href="#the-html-element">html</a></code></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-20">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-13">globals</a>;
         <code id="elements-3:handler-window-onafterprint"><a href="#handler-window-onafterprint">onafterprint</a></code>;
         <code id="elements-3:handler-window-onbeforeprint"><a href="#handler-window-onbeforeprint">onbeforeprint</a></code>;
         <code id="elements-3:handler-window-onbeforeunload"><a href="#handler-window-onbeforeunload">onbeforeunload</a></code>;
         <code id="elements-3:handler-window-onhashchange"><a href="#handler-window-onhashchange">onhashchange</a></code>;
         <code id="elements-3:handler-window-onlanguagechange"><a href="#handler-window-onlanguagechange">onlanguagechange</a></code>;
         <code id="elements-3:handler-window-onmessage"><a href="#handler-window-onmessage">onmessage</a></code>;
         <code id="elements-3:handler-window-onmessageerror"><a href="#handler-window-onmessageerror">onmessageerror</a></code>;
         <code id="elements-3:handler-window-onoffline"><a href="#handler-window-onoffline">onoffline</a></code>;
         <code id="elements-3:handler-window-ononline"><a href="#handler-window-ononline">ononline</a></code>;
         <code id="elements-3:handler-window-onpageswap"><a href="#handler-window-onpageswap">onpageswap</a></code>;
         <code id="elements-3:handler-window-onpagehide"><a href="#handler-window-onpagehide">onpagehide</a></code>;
         <code id="elements-3:handler-window-onpagereveal"><a href="#handler-window-onpagereveal">onpagereveal</a></code>;
         <code id="elements-3:handler-window-onpageshow"><a href="#handler-window-onpageshow">onpageshow</a></code>;
         <code id="elements-3:handler-window-onpopstate"><a href="#handler-window-onpopstate">onpopstate</a></code>;
         <code id="elements-3:handler-window-onrejectionhandled"><a href="#handler-window-onrejectionhandled">onrejectionhandled</a></code>;
         <code id="elements-3:handler-window-onstorage"><a href="#handler-window-onstorage">onstorage</a></code>;
         <code id="elements-3:handler-window-onunhandledrejection"><a href="#handler-window-onunhandledrejection">onunhandledrejection</a></code>;
         <code id="elements-3:handler-window-onunload"><a href="#handler-window-onunload">onunload</a></code></td><td><code id="elements-3:htmlbodyelement"><a href="#htmlbodyelement">HTMLBodyElement</a></code></td></tr><tr><th><code id="elements-3:the-br-element"><a href="#the-br-element">br</a></code></th><td>Line break, e.g. in poem or postal address</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-21">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-19">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-20">phrasing</a></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-14">globals</a></td><td><code id="elements-3:htmlbrelement"><a href="#htmlbrelement">HTMLBRElement</a></code></td></tr><tr><th><code id="elements-3:the-button-element"><a href="#the-button-element">button</a></code></th><td>Button control</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-22">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-21">phrasing</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-3">interactive</a>;
         <a href="#category-listed" id="elements-3:category-listed">listed</a>;
         <a href="#category-label" id="elements-3:category-label">labelable</a>;
         <a href="#category-submit" id="elements-3:category-submit">submittable</a>;
         <a href="#form-associated-element" id="elements-3:form-associated-element">form-associated</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-11">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-22">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-23">phrasing</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-15">globals</a>;
         <code id="elements-3:attr-button-command"><a href="#attr-button-command">command</a></code>;
         <code id="elements-3:attr-button-commandfor"><a href="#attr-button-commandfor">commandfor</a></code>;
         <code id="elements-3:attr-fe-disabled"><a href="#attr-fe-disabled">disabled</a></code>;
         <code id="elements-3:attr-fae-form"><a href="#attr-fae-form">form</a></code>;
         <code id="elements-3:attr-fs-formaction"><a href="#attr-fs-formaction">formaction</a></code>;
         <code id="elements-3:attr-fs-formenctype"><a href="#attr-fs-formenctype">formenctype</a></code>;
         <code id="elements-3:attr-fs-formmethod"><a href="#attr-fs-formmethod">formmethod</a></code>;
         <code id="elements-3:attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>;
         <code id="elements-3:attr-fs-formtarget"><a href="#attr-fs-formtarget">formtarget</a></code>;
         <code id="elements-3:attr-fe-name"><a href="#attr-fe-name">name</a></code>;
         <code id="elements-3:attr-popovertarget"><a href="#attr-popovertarget">popovertarget</a></code>;
         <code id="elements-3:attr-popovertargetaction"><a href="#attr-popovertargetaction">popovertargetaction</a></code>;
         <code id="elements-3:attr-button-type"><a href="#attr-button-type">type</a></code>;
         <code id="elements-3:attr-button-value"><a href="#attr-button-value">value</a></code></td><td><code id="elements-3:htmlbuttonelement"><a href="#htmlbuttonelement">HTMLButtonElement</a></code></td></tr><tr><th><code id="elements-3:the-canvas-element"><a href="#the-canvas-element">canvas</a></code></th><td>Scriptable bitmap canvas</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-23">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-24">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category-2">embedded</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-12">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-25">phrasing</a></td><td><a href="#transparent" id="elements-3:transparent-3">transparent</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-16">globals</a>;
         <code id="elements-3:attr-canvas-width"><a href="#attr-canvas-width">width</a></code>;
         <code id="elements-3:attr-canvas-height"><a href="#attr-canvas-height">height</a></code></td><td><code id="elements-3:htmlcanvaselement"><a href="#htmlcanvaselement">HTMLCanvasElement</a></code></td></tr><tr><th><code id="elements-3:the-caption-element"><a href="#the-caption-element">caption</a></code></th><td>Table caption</td><td>none</td><td><code id="elements-3:the-table-element"><a href="#the-table-element">table</a></code></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-24">flow</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-17">globals</a></td><td><code id="elements-3:htmltablecaptionelement"><a href="#htmltablecaptionelement">HTMLTableCaptionElement</a></code></td></tr><tr><th><code id="elements-3:the-cite-element"><a href="#the-cite-element">cite</a></code></th><td>Title of a work</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-25">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-26">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-13">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-27">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-28">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-18">globals</a></td><td><code id="elements-3:htmlelement-8"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-code-element"><a href="#the-code-element">code</a></code></th><td>Computer code</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-26">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-29">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-14">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-30">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-31">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-19">globals</a></td><td><code id="elements-3:htmlelement-9"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-col-element"><a href="#the-col-element">col</a></code></th><td>Table column</td><td>none</td><td><code id="elements-3:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-20">globals</a>;
         <code id="elements-3:attr-col-span"><a href="#attr-col-span">span</a></code></td><td><code id="elements-3:htmltablecolelement"><a href="#htmltablecolelement">HTMLTableColElement</a></code></td></tr><tr><th><code id="elements-3:the-colgroup-element-2"><a href="#the-colgroup-element">colgroup</a></code></th><td>Group of columns in a table</td><td>none</td><td><code id="elements-3:the-table-element-2"><a href="#the-table-element">table</a></code></td><td><code id="elements-3:the-col-element-2"><a href="#the-col-element">col</a></code>*;
         <code id="elements-3:the-template-element"><a href="#the-template-element">template</a></code>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-21">globals</a>;
         <code id="elements-3:attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code></td><td><code id="elements-3:htmltablecolelement-2"><a href="#htmltablecolelement">HTMLTableColElement</a></code></td></tr><tr><th><code id="elements-3:the-data-element"><a href="#the-data-element">data</a></code></th><td>Machine-readable equivalent</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-27">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-32">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-15">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-33">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-34">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-22">globals</a>;
         <code id="elements-3:attr-data-value"><a href="#attr-data-value">value</a></code></td><td><code id="elements-3:htmldataelement"><a href="#htmldataelement">HTMLDataElement</a></code></td></tr><tr><th><code id="elements-3:the-datalist-element"><a href="#the-datalist-element">datalist</a></code></th><td>Container for options for <a href="#attr-input-list" id="elements-3:attr-input-list">combo box control</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-28">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-35">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-36">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-37">phrasing</a>*;
         <code id="elements-3:the-option-element"><a href="#the-option-element">option</a></code>*;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2">script-supporting elements</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-23">globals</a></td><td><code id="elements-3:htmldatalistelement"><a href="#htmldatalistelement">HTMLDataListElement</a></code></td></tr><tr><th><code id="elements-3:the-dd-element"><a href="#the-dd-element">dd</a></code></th><td>Content for corresponding <code id="elements-3:the-dt-element"><a href="#the-dt-element">dt</a></code> element(s)</td><td>none</td><td><code id="elements-3:the-dl-element"><a href="#the-dl-element">dl</a></code>;
         <code id="elements-3:the-div-element"><a href="#the-div-element">div</a></code>*</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-29">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-24">globals</a></td><td><code id="elements-3:htmlelement-10"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-del-element"><a href="#the-del-element">del</a></code></th><td>A removal from the document</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-30">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-38">phrasing</a>*;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-16">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-39">phrasing</a></td><td><a href="#transparent" id="elements-3:transparent-4">transparent</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-25">globals</a>;
         <code id="elements-3:attr-mod-cite"><a href="#attr-mod-cite">cite</a></code>;
         <code id="elements-3:attr-mod-datetime"><a href="#attr-mod-datetime">datetime</a></code></td><td><code id="elements-3:htmlmodelement"><a href="#htmlmodelement">HTMLModElement</a></code></td></tr><tr><th><code id="elements-3:the-details-element"><a href="#the-details-element">details</a></code></th><td>Disclosure control for hiding details</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-31">flow</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-4">interactive</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-17">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-32">flow</a></td><td><code id="elements-3:the-summary-element"><a href="#the-summary-element">summary</a></code>*;
         <a href="#flow-content-2" id="elements-3:flow-content-2-33">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-26">globals</a>;
         <code id="elements-3:attr-details-name"><a href="#attr-details-name">name</a></code>;
         <code id="elements-3:attr-details-open"><a href="#attr-details-open">open</a></code></td><td><code id="elements-3:htmldetailselement"><a href="#htmldetailselement">HTMLDetailsElement</a></code></td></tr><tr><th><code id="elements-3:the-dfn-element"><a href="#the-dfn-element">dfn</a></code></th><td>Defining instance</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-34">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-40">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-18">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-41">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-42">phrasing</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-27">globals</a></td><td><code id="elements-3:htmlelement-11"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-dialog-element"><a href="#the-dialog-element">dialog</a></code></th><td>Dialog box or window</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-35">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-36">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-37">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-28">globals</a>;
         <code id="elements-3:attr-dialog-open"><a href="#attr-dialog-open">open</a></code></td><td><code id="elements-3:htmldialogelement"><a href="#htmldialogelement">HTMLDialogElement</a></code></td></tr><tr><th><code id="elements-3:the-div-element-2"><a href="#the-div-element">div</a></code></th><td>Generic flow container, or container for name-value groups in <code id="elements-3:the-dl-element-2"><a href="#the-dl-element">dl</a></code> elements</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-38">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-19">palpable</a>;
         <a href="#select-element-inner-content-elements-2" id="elements-3:select-element-inner-content-elements-2"><code>select</code> element inner content elements</a>;
         <a href="#optgroup-element-inner-content-elements-2" id="elements-3:optgroup-element-inner-content-elements-2"><code>optgroup</code> element inner content elements</a>;
         <a href="#option-element-inner-content-elements-2" id="elements-3:option-element-inner-content-elements-2"><code>option</code> element inner content elements</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-39">flow</a>;
         <code id="elements-3:the-dl-element-3"><a href="#the-dl-element">dl</a></code>;
         <a href="#select-element-inner-content-elements-2" id="elements-3:select-element-inner-content-elements-2-2"><code>select</code> element inner content elements</a>;
         <a href="#optgroup-element-inner-content-elements-2" id="elements-3:optgroup-element-inner-content-elements-2-2"><code>optgroup</code> element inner content elements</a>;
         <a href="#option-element-inner-content-elements-2" id="elements-3:option-element-inner-content-elements-2-2"><code>option</code> element inner content elements</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-40">flow</a>
         <a href="#select-element-inner-content-elements-2" id="elements-3:select-element-inner-content-elements-2-3"><code>select</code> element inner content elements</a>*;
         <a href="#optgroup-element-inner-content-elements-2" id="elements-3:optgroup-element-inner-content-elements-2-3"><code>optgroup</code> element inner content elements</a>*;
         <a href="#option-element-inner-content-elements-2" id="elements-3:option-element-inner-content-elements-2-3"><code>option</code> element inner content elements</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-29">globals</a></td><td><code id="elements-3:htmldivelement"><a href="#htmldivelement">HTMLDivElement</a></code></td></tr><tr><th><code id="elements-3:the-dl-element-4"><a href="#the-dl-element">dl</a></code></th><td>Association list consisting of zero or more name-value groups</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-41">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-20">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-42">flow</a></td><td><code id="elements-3:the-dt-element-2"><a href="#the-dt-element">dt</a></code>*;
         <code id="elements-3:the-dd-element-2"><a href="#the-dd-element">dd</a></code>*;
         <code id="elements-3:the-div-element-3"><a href="#the-div-element">div</a></code>*;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-2">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-30">globals</a></td><td><code id="elements-3:htmldlistelement"><a href="#htmldlistelement">HTMLDListElement</a></code></td></tr><tr><th><code id="elements-3:the-dt-element-3"><a href="#the-dt-element">dt</a></code></th><td>Legend for corresponding <code id="elements-3:the-dd-element-3"><a href="#the-dd-element">dd</a></code> element(s)</td><td>none</td><td><code id="elements-3:the-dl-element-5"><a href="#the-dl-element">dl</a></code>;
         <code id="elements-3:the-div-element-4"><a href="#the-div-element">div</a></code>*</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-43">flow</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-31">globals</a></td><td><code id="elements-3:htmlelement-12"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-em-element"><a href="#the-em-element">em</a></code></th><td>Stress emphasis</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-44">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-43">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-21">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-44">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-45">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-32">globals</a></td><td><code id="elements-3:htmlelement-13"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-embed-element"><a href="#the-embed-element">embed</a></code></th><td><a href="#plugin" id="elements-3:plugin">Plugin</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-45">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-46">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category-3">embedded</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-5">interactive</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-22">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-47">phrasing</a></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-33">globals</a>;
         <code id="elements-3:attr-embed-src"><a href="#attr-embed-src">src</a></code>;
         <code id="elements-3:attr-embed-type"><a href="#attr-embed-type">type</a></code>;
         <code id="elements-3:attr-dim-width"><a href="#attr-dim-width">width</a></code>;
         <code id="elements-3:attr-dim-height"><a href="#attr-dim-height">height</a></code>;
         any*</td><td><code id="elements-3:htmlembedelement"><a href="#htmlembedelement">HTMLEmbedElement</a></code></td></tr><tr><th><code id="elements-3:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code></th><td>Group of form controls</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-46">flow</a>;
         <a href="#category-listed" id="elements-3:category-listed-2">listed</a>;
         <a href="#form-associated-element" id="elements-3:form-associated-element-2">form-associated</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-23">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-47">flow</a></td><td><code id="elements-3:the-legend-element"><a href="#the-legend-element">legend</a></code>*;
         <a href="#flow-content-2" id="elements-3:flow-content-2-48">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-34">globals</a>;
         <code id="elements-3:attr-fieldset-disabled"><a href="#attr-fieldset-disabled">disabled</a></code>;
         <code id="elements-3:attr-fae-form-2"><a href="#attr-fae-form">form</a></code>;
         <code id="elements-3:attr-fe-name-2"><a href="#attr-fe-name">name</a></code></td><td><code id="elements-3:htmlfieldsetelement"><a href="#htmlfieldsetelement">HTMLFieldSetElement</a></code></td></tr><tr><th><code id="elements-3:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code></th><td>Caption for <code id="elements-3:the-figure-element"><a href="#the-figure-element">figure</a></code></td><td>none</td><td><code id="elements-3:the-figure-element-2"><a href="#the-figure-element">figure</a></code></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-49">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-35">globals</a></td><td><code id="elements-3:htmlelement-14"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-figure-element-3"><a href="#the-figure-element">figure</a></code></th><td>Figure with optional caption</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-50">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-24">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-51">flow</a></td><td><code id="elements-3:the-figcaption-element-2"><a href="#the-figcaption-element">figcaption</a></code>*;
         <a href="#flow-content-2" id="elements-3:flow-content-2-52">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-36">globals</a></td><td><code id="elements-3:htmlelement-15"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-footer-element"><a href="#the-footer-element">footer</a></code></th><td>Footer for a page or section</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-53">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-25">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-54">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-55">flow</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-37">globals</a></td><td><code id="elements-3:htmlelement-16"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-form-element"><a href="#the-form-element">form</a></code></th><td>User-submittable form</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-56">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-26">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-57">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-58">flow</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-38">globals</a>;
         <code id="elements-3:attr-form-accept-charset"><a href="#attr-form-accept-charset">accept-charset</a></code>;
         <code id="elements-3:attr-fs-action"><a href="#attr-fs-action">action</a></code>;
         <code id="elements-3:attr-form-autocomplete"><a href="#attr-form-autocomplete">autocomplete</a></code>;
         <code id="elements-3:attr-fs-enctype"><a href="#attr-fs-enctype">enctype</a></code>;
         <code id="elements-3:attr-fs-method"><a href="#attr-fs-method">method</a></code>;
         <code id="elements-3:attr-form-name"><a href="#attr-form-name">name</a></code>;
         <code id="elements-3:attr-fs-novalidate"><a href="#attr-fs-novalidate">novalidate</a></code>;
         <code id="elements-3:attr-form-rel"><a href="#attr-form-rel">rel</a></code>;
         <code id="elements-3:attr-fs-target-2"><a href="#attr-fs-target">target</a></code></td><td><code id="elements-3:htmlformelement"><a href="#htmlformelement">HTMLFormElement</a></code></td></tr><tr><th><code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>, <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>, <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>, <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code></th><td>Heading</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-59">flow</a>;
         <a href="#heading-content-2" id="elements-3:heading-content-2">heading</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-27">palpable</a></td><td><code id="elements-3:the-legend-element-2"><a href="#the-legend-element">legend</a></code>;
         <code id="elements-3:the-summary-element-2"><a href="#the-summary-element">summary</a></code>;
         <a href="#flow-content-2" id="elements-3:flow-content-2-60">flow</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-48">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-39">globals</a></td><td><code id="elements-3:htmlheadingelement"><a href="#htmlheadingelement">HTMLHeadingElement</a></code></td></tr><tr><th><code id="elements-3:the-head-element-2"><a href="#the-head-element">head</a></code></th><td>Container for document metadata</td><td>none</td><td><code id="elements-3:the-html-element-2"><a href="#the-html-element">html</a></code></td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2-2">metadata content</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-40">globals</a></td><td><code id="elements-3:htmlheadelement"><a href="#htmlheadelement">HTMLHeadElement</a></code></td></tr><tr><th><code id="elements-3:the-header-element"><a href="#the-header-element">header</a></code></th><td>Introductory or navigational aids for a page or section</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-61">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-28">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-62">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-63">flow</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-41">globals</a></td><td><code id="elements-3:htmlelement-17"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code></th><td>Heading container</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-64">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-29">palpable</a></td><td>
      <code id="elements-3:the-legend-element-3"><a href="#the-legend-element">legend</a></code>;
      <code id="elements-3:the-summary-element-3"><a href="#the-summary-element">summary</a></code>;
      <a href="#flow-content-2" id="elements-3:flow-content-2-65">flow</a></td><td><code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-7"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>;
         <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-8"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>;
         <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-9"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>;
         <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-10"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>;
         <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-11"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>;
         <code id="elements-3:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-12"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>;
         <code id="elements-3:the-p-element"><a href="#the-p-element">p</a></code>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-3">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-42">globals</a></td><td><code id="elements-3:htmlelement-18"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-hr-element"><a href="#the-hr-element">hr</a></code></th><td>Thematic break</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-66">flow</a>;
         <a href="#select-element-inner-content-elements-2" id="elements-3:select-element-inner-content-elements-2-4"><code>select</code> element inner content elements</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-67">flow</a>;
         <a href="#select-element-inner-content-elements-2" id="elements-3:select-element-inner-content-elements-2-5"><code>select</code> element inner content elements</a></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-43">globals</a></td><td><code id="elements-3:htmlhrelement"><a href="#htmlhrelement">HTMLHRElement</a></code></td></tr><tr><th><code id="elements-3:the-html-element-3"><a href="#the-html-element">html</a></code></th><td>Root element</td><td>none</td><td>none*</td><td><code id="elements-3:the-head-element-3"><a href="#the-head-element">head</a></code>*;
         <code id="elements-3:the-body-element-2"><a href="#the-body-element">body</a></code>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-44">globals</a></td><td><code id="elements-3:htmlhtmlelement"><a href="#htmlhtmlelement">HTMLHtmlElement</a></code></td></tr><tr><th><code id="elements-3:the-i-element"><a href="#the-i-element">i</a></code></th><td>Alternate voice</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-68">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-49">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-30">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-50">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-51">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-45">globals</a></td><td><code id="elements-3:htmlelement-19"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-iframe-element"><a href="#the-iframe-element">iframe</a></code></th><td><a href="#child-navigable" id="elements-3:child-navigable">Child navigable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-69">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-52">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category-4">embedded</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-6">interactive</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-31">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-53">phrasing</a></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-46">globals</a>;
         <code id="elements-3:attr-iframe-src"><a href="#attr-iframe-src">src</a></code>;
         <code id="elements-3:attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code>;
         <code id="elements-3:attr-iframe-name"><a href="#attr-iframe-name">name</a></code>;
         <code id="elements-3:attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code>;
         <code id="elements-3:attr-iframe-allow"><a href="#attr-iframe-allow">allow</a></code>;
         <code id="elements-3:attr-iframe-allowfullscreen"><a href="#attr-iframe-allowfullscreen">allowfullscreen</a></code>;
         <code id="elements-3:attr-dim-width-2"><a href="#attr-dim-width">width</a></code>;
         <code id="elements-3:attr-dim-height-2"><a href="#attr-dim-height">height</a></code>;
         <code id="elements-3:attr-iframe-referrerpolicy"><a href="#attr-iframe-referrerpolicy">referrerpolicy</a></code>;
         <code id="elements-3:attr-iframe-loading"><a href="#attr-iframe-loading">loading</a></code></td><td><code id="elements-3:htmliframeelement"><a href="#htmliframeelement">HTMLIFrameElement</a></code></td></tr><tr><th><code id="elements-3:the-img-element"><a href="#the-img-element">img</a></code></th><td>Image</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-70">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-54">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category-5">embedded</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-7">interactive</a>*;
         <a href="#form-associated-element" id="elements-3:form-associated-element-3">form-associated</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-32">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-55">phrasing</a>;
         <code id="elements-3:the-picture-element"><a href="#the-picture-element">picture</a></code></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-47">globals</a>;
         <code id="elements-3:attr-img-alt"><a href="#attr-img-alt">alt</a></code>;
         <code id="elements-3:attr-img-src"><a href="#attr-img-src">src</a></code>;
         <code id="elements-3:attr-img-srcset"><a href="#attr-img-srcset">srcset</a></code>;
         <code id="elements-3:attr-img-sizes"><a href="#attr-img-sizes">sizes</a></code>;
         <code id="elements-3:attr-img-crossorigin"><a href="#attr-img-crossorigin">crossorigin</a></code>;
         <code id="elements-3:attr-hyperlink-usemap"><a href="#attr-hyperlink-usemap">usemap</a></code>;
         <code id="elements-3:attr-img-ismap"><a href="#attr-img-ismap">ismap</a></code>;
         <code id="elements-3:attr-dim-width-3"><a href="#attr-dim-width">width</a></code>;
         <code id="elements-3:attr-dim-height-3"><a href="#attr-dim-height">height</a></code>;
         <code id="elements-3:attr-img-referrerpolicy"><a href="#attr-img-referrerpolicy">referrerpolicy</a></code>;
         <code id="elements-3:attr-img-decoding"><a href="#attr-img-decoding">decoding</a></code>;
         <code id="elements-3:attr-img-loading"><a href="#attr-img-loading">loading</a></code>;
         <code id="elements-3:attr-img-fetchpriority"><a href="#attr-img-fetchpriority">fetchpriority</a></code></td><td><code id="elements-3:htmlimageelement"><a href="#htmlimageelement">HTMLImageElement</a></code></td></tr><tr><th><code id="elements-3:the-input-element"><a href="#the-input-element">input</a></code></th><td>Form control</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-71">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-56">phrasing</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-8">interactive</a>*;
         <a href="#category-listed" id="elements-3:category-listed-3">listed</a>;
         <a href="#category-label" id="elements-3:category-label-2">labelable</a>;
         <a href="#category-submit" id="elements-3:category-submit-2">submittable</a>;
         <a href="#category-reset" id="elements-3:category-reset">resettable</a>;
         <a href="#form-associated-element" id="elements-3:form-associated-element-4">form-associated</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-33">palpable</a>*</td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-57">phrasing</a></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-48">globals</a>;
         <code id="elements-3:attr-input-accept"><a href="#attr-input-accept">accept</a></code>;
         <code id="elements-3:attr-input-alpha"><a href="#attr-input-alpha">alpha</a></code>;
         <code id="elements-3:attr-input-alt"><a href="#attr-input-alt">alt</a></code>;
         <code id="elements-3:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">autocomplete</a></code>;
         <code id="elements-3:attr-input-checked"><a href="#attr-input-checked">checked</a></code>;
         <code id="elements-3:attr-input-colorspace"><a href="#attr-input-colorspace">colorspace</a></code>;
         <code id="elements-3:attr-fe-dirname"><a href="#attr-fe-dirname">dirname</a></code>;
         <code id="elements-3:attr-fe-disabled-2"><a href="#attr-fe-disabled">disabled</a></code>;
         <code id="elements-3:attr-fae-form-3"><a href="#attr-fae-form">form</a></code>;
         <code id="elements-3:attr-fs-formaction-2"><a href="#attr-fs-formaction">formaction</a></code>;
         <code id="elements-3:attr-fs-formenctype-2"><a href="#attr-fs-formenctype">formenctype</a></code>;
         <code id="elements-3:attr-fs-formmethod-2"><a href="#attr-fs-formmethod">formmethod</a></code>;
         <code id="elements-3:attr-fs-formnovalidate-2"><a href="#attr-fs-formnovalidate">formnovalidate</a></code>;
         <code id="elements-3:attr-fs-formtarget-2"><a href="#attr-fs-formtarget">formtarget</a></code>;
         <code id="elements-3:attr-dim-height-4"><a href="#attr-dim-height">height</a></code>;
         <code id="elements-3:attr-input-list-2"><a href="#attr-input-list">list</a></code>;
         <code id="elements-3:attr-input-max"><a href="#attr-input-max">max</a></code>;
         <code id="elements-3:attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code>;
         <code id="elements-3:attr-input-min"><a href="#attr-input-min">min</a></code>;
         <code id="elements-3:attr-input-minlength"><a href="#attr-input-minlength">minlength</a></code>;
         <code id="elements-3:attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code>;
         <code id="elements-3:attr-fe-name-3"><a href="#attr-fe-name">name</a></code>;
         <code id="elements-3:attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>;
         <code id="elements-3:attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>;
         <code id="elements-3:attr-popovertarget-2"><a href="#attr-popovertarget">popovertarget</a></code>;
         <code id="elements-3:attr-popovertargetaction-2"><a href="#attr-popovertargetaction">popovertargetaction</a></code>;
         <code id="elements-3:attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code>;
         <code id="elements-3:attr-input-required"><a href="#attr-input-required">required</a></code>;
         <code id="elements-3:attr-input-size"><a href="#attr-input-size">size</a></code>;
         <code id="elements-3:attr-input-src"><a href="#attr-input-src">src</a></code>;
         <code id="elements-3:attr-input-step"><a href="#attr-input-step">step</a></code>;
         <code id="elements-3:attr-input-type"><a href="#attr-input-type">type</a></code>;
         <code id="elements-3:attr-input-value"><a href="#attr-input-value">value</a></code>;
         <code id="elements-3:attr-dim-width-4"><a href="#attr-dim-width">width</a></code></td><td><code id="elements-3:htmlinputelement"><a href="#htmlinputelement">HTMLInputElement</a></code></td></tr><tr><th><code id="elements-3:the-ins-element"><a href="#the-ins-element">ins</a></code></th><td>An addition to the document</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-72">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-58">phrasing</a>*;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-34">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-59">phrasing</a></td><td><a href="#transparent" id="elements-3:transparent-5">transparent</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-49">globals</a>;
         <code id="elements-3:attr-mod-cite-2"><a href="#attr-mod-cite">cite</a></code>;
         <code id="elements-3:attr-mod-datetime-2"><a href="#attr-mod-datetime">datetime</a></code></td><td><code id="elements-3:htmlmodelement-2"><a href="#htmlmodelement">HTMLModElement</a></code></td></tr><tr><th><code id="elements-3:the-kbd-element"><a href="#the-kbd-element">kbd</a></code></th><td>User input</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-73">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-60">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-35">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-61">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-62">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-50">globals</a></td><td><code id="elements-3:htmlelement-20"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-label-element"><a href="#the-label-element">label</a></code></th><td>Caption for a form control</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-74">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-63">phrasing</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-9">interactive</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-36">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-64">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-65">phrasing</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-51">globals</a>;
         <code id="elements-3:attr-label-for"><a href="#attr-label-for">for</a></code></td><td><code id="elements-3:htmllabelelement"><a href="#htmllabelelement">HTMLLabelElement</a></code></td></tr><tr><th><code id="elements-3:the-legend-element-4"><a href="#the-legend-element">legend</a></code></th><td>Caption for <code id="elements-3:the-fieldset-element-2"><a href="#the-fieldset-element">fieldset</a></code></td><td>none</td><td><code id="elements-3:the-fieldset-element-3"><a href="#the-fieldset-element">fieldset</a></code>;
         <code id="elements-3:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-66">phrasing</a>*;
         <a href="#heading-content-2" id="elements-3:heading-content-2-2">heading content</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-52">globals</a></td><td><code id="elements-3:htmllegendelement"><a href="#htmllegendelement">HTMLLegendElement</a></code></td></tr><tr><th><code id="elements-3:the-li-element"><a href="#the-li-element">li</a></code></th><td>List item</td><td>none</td><td><code id="elements-3:the-ol-element"><a href="#the-ol-element">ol</a></code>;
         <code id="elements-3:the-ul-element"><a href="#the-ul-element">ul</a></code>;
         <code id="elements-3:the-menu-element"><a href="#the-menu-element">menu</a></code>*</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-75">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-53">globals</a>;
         <code id="elements-3:attr-li-value"><a href="#attr-li-value">value</a></code>*</td><td><code id="elements-3:htmllielement"><a href="#htmllielement">HTMLLIElement</a></code></td></tr><tr><th><code id="elements-3:the-link-element"><a href="#the-link-element">link</a></code></th><td>Link metadata</td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2-3">metadata</a>;
         <a href="#flow-content-2" id="elements-3:flow-content-2-76">flow</a>*;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-67">phrasing</a>*</td><td><code id="elements-3:the-head-element-4"><a href="#the-head-element">head</a></code>;
         <code id="elements-3:the-noscript-element"><a href="#the-noscript-element">noscript</a></code>*;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-68">phrasing</a>*</td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-54">globals</a>;
         <code id="elements-3:attr-link-href"><a href="#attr-link-href">href</a></code>;
         <code id="elements-3:attr-link-crossorigin"><a href="#attr-link-crossorigin">crossorigin</a></code>;
         <code id="elements-3:attr-link-rel"><a href="#attr-link-rel">rel</a></code>;
         <code id="elements-3:attr-link-as"><a href="#attr-link-as">as</a></code>;
         <code id="elements-3:attr-link-media"><a href="#attr-link-media">media</a></code>;
         <code id="elements-3:attr-link-hreflang"><a href="#attr-link-hreflang">hreflang</a></code>;
         <code id="elements-3:attr-link-type"><a href="#attr-link-type">type</a></code>;
         <code id="elements-3:attr-link-sizes"><a href="#attr-link-sizes">sizes</a></code>;
         <code id="elements-3:attr-link-imagesrcset"><a href="#attr-link-imagesrcset">imagesrcset</a></code>;
         <code id="elements-3:attr-link-imagesizes"><a href="#attr-link-imagesizes">imagesizes</a></code>;
         <code id="elements-3:attr-link-referrerpolicy"><a href="#attr-link-referrerpolicy">referrerpolicy</a></code>;
         <code id="elements-3:attr-link-integrity"><a href="#attr-link-integrity">integrity</a></code>;
         <code id="elements-3:attr-link-blocking"><a href="#attr-link-blocking">blocking</a></code>;
         <code id="elements-3:attr-link-color"><a href="#attr-link-color">color</a></code>;
         <code id="elements-3:attr-link-disabled"><a href="#attr-link-disabled">disabled</a></code>;
         <code id="elements-3:attr-link-fetchpriority"><a href="#attr-link-fetchpriority">fetchpriority</a></code></td><td><code id="elements-3:htmllinkelement"><a href="#htmllinkelement">HTMLLinkElement</a></code></td></tr><tr><th><code id="elements-3:the-main-element"><a href="#the-main-element">main</a></code></th><td>Container for the dominant contents of the document</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-77">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-37">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-78">flow</a>*</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-79">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-55">globals</a></td><td><code id="elements-3:htmlelement-21"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-map-element"><a href="#the-map-element">map</a></code></th><td><a href="#image-map" id="elements-3:image-map">Image map</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-80">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-69">phrasing</a>*;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-38">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-70">phrasing</a></td><td><a href="#transparent" id="elements-3:transparent-6">transparent</a>;
         <code id="elements-3:the-area-element-2"><a href="#the-area-element">area</a></code>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-56">globals</a>;
         <code id="elements-3:attr-map-name"><a href="#attr-map-name">name</a></code></td><td><code id="elements-3:htmlmapelement"><a href="#htmlmapelement">HTMLMapElement</a></code></td></tr><tr><th><code id="elements-3:the-mark-element"><a href="#the-mark-element">mark</a></code></th><td>Highlight</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-81">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-71">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-39">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-72">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-73">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-57">globals</a></td><td><code id="elements-3:htmlelement-22"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><a id="elements-3:mathml-math" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a></th><td>MathML root</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-82">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-74">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category-6">embedded</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-40">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-75">phrasing</a></td><td>per <a href="#refsMATHML">[MATHML]</a></td><td>per <a href="#refsMATHML">[MATHML]</a></td><td><code id="elements-3:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code></td></tr><tr><th><code id="elements-3:the-menu-element-2"><a href="#the-menu-element">menu</a></code></th><td>Menu of commands</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-83">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-41">palpable</a>*</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-84">flow</a></td><td><code id="elements-3:the-li-element-2"><a href="#the-li-element">li</a></code>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-4">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-58">globals</a></td><td><code id="elements-3:htmlmenuelement"><a href="#htmlmenuelement">HTMLMenuElement</a></code></td></tr><tr><th><code id="elements-3:the-meta-element"><a href="#the-meta-element">meta</a></code></th><td>Text metadata</td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2-4">metadata</a>;
         <a href="#flow-content-2" id="elements-3:flow-content-2-85">flow</a>*;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-76">phrasing</a>*</td><td><code id="elements-3:the-head-element-5"><a href="#the-head-element">head</a></code>;
         <code id="elements-3:the-noscript-element-2"><a href="#the-noscript-element">noscript</a></code>*;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-77">phrasing</a>*</td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-59">globals</a>;
         <code id="elements-3:attr-meta-name"><a href="#attr-meta-name">name</a></code>;
         <code id="elements-3:attr-meta-http-equiv"><a href="#attr-meta-http-equiv">http-equiv</a></code>;
         <code id="elements-3:attr-meta-content"><a href="#attr-meta-content">content</a></code>;
         <code id="elements-3:attr-meta-charset"><a href="#attr-meta-charset">charset</a></code>;
         <code id="elements-3:attr-meta-media"><a href="#attr-meta-media">media</a></code></td><td><code id="elements-3:htmlmetaelement"><a href="#htmlmetaelement">HTMLMetaElement</a></code></td></tr><tr><th><code id="elements-3:the-meter-element"><a href="#the-meter-element">meter</a></code></th><td>Gauge</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-86">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-78">phrasing</a>;
         <a href="#category-label" id="elements-3:category-label-3">labelable</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-42">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-79">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-80">phrasing</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-60">globals</a>;
         <code id="elements-3:attr-meter-value"><a href="#attr-meter-value">value</a></code>;
         <code id="elements-3:attr-meter-min"><a href="#attr-meter-min">min</a></code>;
         <code id="elements-3:attr-meter-max"><a href="#attr-meter-max">max</a></code>;
         <code id="elements-3:attr-meter-low"><a href="#attr-meter-low">low</a></code>;
         <code id="elements-3:attr-meter-high"><a href="#attr-meter-high">high</a></code>;
         <code id="elements-3:attr-meter-optimum"><a href="#attr-meter-optimum">optimum</a></code></td><td><code id="elements-3:htmlmeterelement"><a href="#htmlmeterelement">HTMLMeterElement</a></code></td></tr><tr><th><code id="elements-3:the-nav-element"><a href="#the-nav-element">nav</a></code></th><td>Section with navigational links</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-87">flow</a>;
         <a href="#sectioning-content-2" id="elements-3:sectioning-content-2-3">sectioning</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-43">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-88">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-89">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-61">globals</a></td><td><code id="elements-3:htmlelement-23"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-noscript-element-3"><a href="#the-noscript-element">noscript</a></code></th><td>Fallback content for script</td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2-5">metadata</a>;
         <a href="#flow-content-2" id="elements-3:flow-content-2-90">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-81">phrasing</a>;
         <a href="#select-element-inner-content-elements-2" id="elements-3:select-element-inner-content-elements-2-6"><code>select</code> element inner content elements</a>;
         <a href="#optgroup-element-inner-content-elements-2" id="elements-3:optgroup-element-inner-content-elements-2-4"><code>optgroup</code> element inner content elements</a></td><td><code id="elements-3:the-head-element-6"><a href="#the-head-element">head</a></code>*;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-82">phrasing</a>*</td><td>varies*</td><td><a href="#global-attributes" id="elements-3:global-attributes-62">globals</a></td><td><code id="elements-3:htmlelement-24"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-object-element"><a href="#the-object-element">object</a></code></th><td>Image, <a href="#child-navigable" id="elements-3:child-navigable-2">child navigable</a>, or <a href="#plugin" id="elements-3:plugin-2">plugin</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-91">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-83">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category-7">embedded</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-10">interactive</a>*;
         <a href="#category-listed" id="elements-3:category-listed-4">listed</a>;
         <a href="#form-associated-element" id="elements-3:form-associated-element-5">form-associated</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-44">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-84">phrasing</a></td><td><a href="#transparent" id="elements-3:transparent-7">transparent</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-63">globals</a>;
         <code id="elements-3:attr-object-data"><a href="#attr-object-data">data</a></code>;
         <code id="elements-3:attr-object-type"><a href="#attr-object-type">type</a></code>;
         <code id="elements-3:attr-object-name"><a href="#attr-object-name">name</a></code>;
         <code id="elements-3:attr-fae-form-4"><a href="#attr-fae-form">form</a></code>;
         <code id="elements-3:attr-dim-width-5"><a href="#attr-dim-width">width</a></code>;
         <code id="elements-3:attr-dim-height-5"><a href="#attr-dim-height">height</a></code></td><td><code id="elements-3:htmlobjectelement"><a href="#htmlobjectelement">HTMLObjectElement</a></code></td></tr><tr><th><code id="elements-3:the-ol-element-2"><a href="#the-ol-element">ol</a></code></th><td>Ordered list</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-92">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-45">palpable</a>*</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-93">flow</a></td><td><code id="elements-3:the-li-element-3"><a href="#the-li-element">li</a></code>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-5">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-64">globals</a>;
         <code id="elements-3:attr-ol-reversed"><a href="#attr-ol-reversed">reversed</a></code>;
         <code id="elements-3:attr-ol-start"><a href="#attr-ol-start">start</a></code>;
         <code id="elements-3:attr-ol-type"><a href="#attr-ol-type">type</a></code></td><td><code id="elements-3:htmlolistelement"><a href="#htmlolistelement">HTMLOListElement</a></code></td></tr><tr><th><code id="elements-3:the-optgroup-element-2"><a href="#the-optgroup-element">optgroup</a></code></th><td>Group of options in a list box</td><td><a href="#select-element-inner-content-elements-2" id="elements-3:select-element-inner-content-elements-2-7"><code>select</code> element inner content elements</a></td><td><code id="elements-3:the-select-element"><a href="#the-select-element">select</a></code>;
         <code id="elements-3:the-div-element-5"><a href="#the-div-element">div</a></code>*</td><td><code id="elements-3:optgroup-element-inner-content-elements-2-5"><a href="#optgroup-element-inner-content-elements-2"><code>optgroup</code> element inner content elements</a></code>;
         <code id="elements-3:the-legend-element-5"><a href="#the-legend-element">legend</a></code>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-65">globals</a>;
         <code id="elements-3:attr-optgroup-disabled"><a href="#attr-optgroup-disabled">disabled</a></code>;
         <code id="elements-3:attr-optgroup-label"><a href="#attr-optgroup-label">label</a></code></td><td><code id="elements-3:htmloptgroupelement"><a href="#htmloptgroupelement">HTMLOptGroupElement</a></code></td></tr><tr><th><code id="elements-3:the-option-element-2"><a href="#the-option-element">option</a></code></th><td>Option in a list box or combo box control</td><td><a href="#select-element-inner-content-elements-2" id="elements-3:select-element-inner-content-elements-2-8"><code>select</code> element inner content elements</a>;
         <a href="#optgroup-element-inner-content-elements-2" id="elements-3:optgroup-element-inner-content-elements-2-6"><code>optgroup</code> element inner content elements</a></td><td><code id="elements-3:the-select-element-2"><a href="#the-select-element">select</a></code>;
         <code id="elements-3:the-datalist-element-2"><a href="#the-datalist-element">datalist</a></code>;
         <code id="elements-3:the-optgroup-element-3"><a href="#the-optgroup-element">optgroup</a></code>;
         <code id="elements-3:the-div-element-6"><a href="#the-div-element">div</a></code>*</td><td><a href="#text-content" id="elements-3:text-content">text</a>*;
         <a href="#option-element-inner-content-elements-2" id="elements-3:option-element-inner-content-elements-2-4"><code>option</code> element inner content elements</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-66">globals</a>;
         <code id="elements-3:attr-option-disabled"><a href="#attr-option-disabled">disabled</a></code>;
         <code id="elements-3:attr-option-label"><a href="#attr-option-label">label</a></code>;
         <code id="elements-3:attr-option-selected"><a href="#attr-option-selected">selected</a></code>;
         <code id="elements-3:attr-option-value"><a href="#attr-option-value">value</a></code></td><td><code id="elements-3:htmloptionelement"><a href="#htmloptionelement">HTMLOptionElement</a></code></td></tr><tr><th><code id="elements-3:the-output-element"><a href="#the-output-element">output</a></code></th><td>Calculated output value</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-94">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-85">phrasing</a>;
         <a href="#category-listed" id="elements-3:category-listed-5">listed</a>;
         <a href="#category-label" id="elements-3:category-label-4">labelable</a>;
         <a href="#category-reset" id="elements-3:category-reset-2">resettable</a>;
         <a href="#form-associated-element" id="elements-3:form-associated-element-6">form-associated</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-46">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-86">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-87">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-67">globals</a>;
         <code id="elements-3:attr-output-for"><a href="#attr-output-for">for</a></code>;
         <code id="elements-3:attr-fae-form-5"><a href="#attr-fae-form">form</a></code>;
         <code id="elements-3:attr-fe-name-4"><a href="#attr-fe-name">name</a></code></td><td><code id="elements-3:htmloutputelement"><a href="#htmloutputelement">HTMLOutputElement</a></code></td></tr><tr><th><code id="elements-3:the-p-element-2"><a href="#the-p-element">p</a></code></th><td>Paragraph</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-95">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-47">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-96">flow</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-88">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-68">globals</a></td><td><code id="elements-3:htmlparagraphelement"><a href="#htmlparagraphelement">HTMLParagraphElement</a></code></td></tr><tr><th><code id="elements-3:the-picture-element-2"><a href="#the-picture-element">picture</a></code></th><td>Image</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-97">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-89">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category-8">embedded</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-48">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-90">phrasing</a></td><td><code id="elements-3:the-source-element-2"><a href="#the-source-element">source</a></code>*;
         one <code id="elements-3:the-img-element-2"><a href="#the-img-element">img</a></code>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-6">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-69">globals</a></td><td><code id="elements-3:htmlpictureelement"><a href="#htmlpictureelement">HTMLPictureElement</a></code></td></tr><tr><th><code id="elements-3:the-pre-element"><a href="#the-pre-element">pre</a></code></th><td>Block of preformatted text</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-98">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-49">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-99">flow</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-91">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-70">globals</a></td><td><code id="elements-3:htmlpreelement"><a href="#htmlpreelement">HTMLPreElement</a></code></td></tr><tr><th><code id="elements-3:the-progress-element"><a href="#the-progress-element">progress</a></code></th><td>Progress bar</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-100">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-92">phrasing</a>;
         <a href="#category-label" id="elements-3:category-label-5">labelable</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-50">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-93">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-94">phrasing</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-71">globals</a>;
         <code id="elements-3:attr-progress-value"><a href="#attr-progress-value">value</a></code>;
         <code id="elements-3:attr-progress-max"><a href="#attr-progress-max">max</a></code></td><td><code id="elements-3:htmlprogresselement"><a href="#htmlprogresselement">HTMLProgressElement</a></code></td></tr><tr><th><code id="elements-3:the-q-element"><a href="#the-q-element">q</a></code></th><td>Quotation</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-101">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-95">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-51">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-96">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-97">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-72">globals</a>;
         <code id="elements-3:attr-q-cite"><a href="#attr-q-cite">cite</a></code></td><td><code id="elements-3:htmlquoteelement-2"><a href="#htmlquoteelement">HTMLQuoteElement</a></code></td></tr><tr><th><code id="elements-3:the-rp-element"><a href="#the-rp-element">rp</a></code></th><td>Parenthesis for ruby annotation text</td><td>none</td><td><code id="elements-3:the-ruby-element"><a href="#the-ruby-element">ruby</a></code></td><td><a href="#text-content" id="elements-3:text-content-2">text</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-73">globals</a></td><td><code id="elements-3:htmlelement-25"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-rt-element"><a href="#the-rt-element">rt</a></code></th><td>Ruby annotation text</td><td>none</td><td><code id="elements-3:the-ruby-element-2"><a href="#the-ruby-element">ruby</a></code></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-98">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-74">globals</a></td><td><code id="elements-3:htmlelement-26"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-ruby-element-3"><a href="#the-ruby-element">ruby</a></code></th><td>Ruby annotation(s)</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-102">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-99">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-52">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-100">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-101">phrasing</a>;
         <code id="elements-3:the-rt-element-2"><a href="#the-rt-element">rt</a></code>;
         <code id="elements-3:the-rp-element-2"><a href="#the-rp-element">rp</a></code>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-75">globals</a></td><td><code id="elements-3:htmlelement-27"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-s-element"><a href="#the-s-element">s</a></code></th><td>Inaccurate text</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-103">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-102">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-53">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-103">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-104">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-76">globals</a></td><td><code id="elements-3:htmlelement-28"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-samp-element"><a href="#the-samp-element">samp</a></code></th><td>Computer output</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-104">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-105">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-54">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-106">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-107">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-77">globals</a></td><td><code id="elements-3:htmlelement-29"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-script-element"><a href="#the-script-element">script</a></code></th><td>Embedded script</td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2-6">metadata</a>;
         <a href="#flow-content-2" id="elements-3:flow-content-2-105">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-108">phrasing</a>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-7">script-supporting</a></td><td><code id="elements-3:the-head-element-7"><a href="#the-head-element">head</a></code>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-109">phrasing</a>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-8">script-supporting</a></td><td>script, data, or script documentation*</td><td><a href="#global-attributes" id="elements-3:global-attributes-78">globals</a>;
         <code id="elements-3:attr-script-src"><a href="#attr-script-src">src</a></code>;
         <code id="elements-3:attr-script-type"><a href="#attr-script-type">type</a></code>;
         <code id="elements-3:attr-script-nomodule"><a href="#attr-script-nomodule">nomodule</a></code>;
         <code id="elements-3:attr-script-async"><a href="#attr-script-async">async</a></code>;
         <code id="elements-3:attr-script-defer"><a href="#attr-script-defer">defer</a></code>;
         <code id="elements-3:attr-script-crossorigin"><a href="#attr-script-crossorigin">crossorigin</a></code>;
         <code id="elements-3:attr-script-integrity"><a href="#attr-script-integrity">integrity</a></code>;
         <code id="elements-3:attr-script-referrerpolicy"><a href="#attr-script-referrerpolicy">referrerpolicy</a></code>;
         <code id="elements-3:attr-script-blocking"><a href="#attr-script-blocking">blocking</a></code>;
         <code id="elements-3:attr-script-fetchpriority"><a href="#attr-script-fetchpriority">fetchpriority</a></code></td><td><code id="elements-3:htmlscriptelement"><a href="#htmlscriptelement">HTMLScriptElement</a></code></td></tr><tr><th><code id="elements-3:the-search-element"><a href="#the-search-element">search</a></code></th><td>Container for search controls</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-106">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-55">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-107">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-108">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-79">globals</a></td><td><code id="elements-3:htmlelement-30"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-section-element"><a href="#the-section-element">section</a></code></th><td>Generic document or application section</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-109">flow</a>;
         <a href="#sectioning-content-2" id="elements-3:sectioning-content-2-4">sectioning</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-56">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-110">flow</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-111">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-80">globals</a></td><td><code id="elements-3:htmlelement-31"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-select-element-3"><a href="#the-select-element">select</a></code></th><td>List box control</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-112">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-110">phrasing</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-11">interactive</a>;
         <a href="#category-listed" id="elements-3:category-listed-6">listed</a>;
         <a href="#category-label" id="elements-3:category-label-6">labelable</a>;
         <a href="#category-submit" id="elements-3:category-submit-3">submittable</a>;
         <a href="#category-reset" id="elements-3:category-reset-3">resettable</a>;
         <a href="#form-associated-element" id="elements-3:form-associated-element-7">form-associated</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-57">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-111">phrasing</a></td><td><a href="#select-element-inner-content-elements-2" id="elements-3:select-element-inner-content-elements-2-9"><code>select</code> element inner content elements</a>;
         <code id="elements-3:the-button-element-2"><a href="#the-button-element">button</a></code>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-81">globals</a>;
         <code id="elements-3:attr-fe-autocomplete-2"><a href="#attr-fe-autocomplete">autocomplete</a></code>;
         <code id="elements-3:attr-fe-disabled-3"><a href="#attr-fe-disabled">disabled</a></code>;
         <code id="elements-3:attr-fae-form-6"><a href="#attr-fae-form">form</a></code>;
         <code id="elements-3:attr-select-multiple"><a href="#attr-select-multiple">multiple</a></code>;
         <code id="elements-3:attr-fe-name-5"><a href="#attr-fe-name">name</a></code>;
         <code id="elements-3:attr-select-required"><a href="#attr-select-required">required</a></code>;
         <code id="elements-3:attr-select-size"><a href="#attr-select-size">size</a></code></td><td><code id="elements-3:htmlselectelement"><a href="#htmlselectelement">HTMLSelectElement</a></code></td></tr><tr><th><code id="elements-3:the-selectedcontent-element"><a href="#the-selectedcontent-element">selectedcontent</a></code></th><td>Mirrors content from an <code id="elements-3:the-option-element-3"><a href="#the-option-element">option</a></code></td><td>none</td><td><code id="elements-3:the-button-element-3"><a href="#the-button-element">button</a></code></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-82">globals</a></td><td><code id="elements-3:htmlselectedcontentelement"><a href="#htmlselectedcontentelement">HTMLSelectedContentElement</a></code></td></tr><tr><th><code id="elements-3:the-slot-element"><a href="#the-slot-element">slot</a></code></th><td>Shadow tree slot</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-113">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-112">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-113">phrasing</a></td><td><a href="#transparent" id="elements-3:transparent-8">transparent</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-83">globals</a>;
         <code id="elements-3:attr-slot-name"><a href="#attr-slot-name">name</a></code></td><td><code id="elements-3:htmlslotelement"><a href="#htmlslotelement">HTMLSlotElement</a></code></td></tr><tr><th><code id="elements-3:the-small-element"><a href="#the-small-element">small</a></code></th><td>Side comment</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-114">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-114">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-58">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-115">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-116">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-84">globals</a></td><td><code id="elements-3:htmlelement-32"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-source-element-3"><a href="#the-source-element">source</a></code></th><td>Image source for <code id="elements-3:the-img-element-3"><a href="#the-img-element">img</a></code> or media source for <code id="elements-3:the-video-element"><a href="#the-video-element">video</a></code> or <code id="elements-3:the-audio-element-2"><a href="#the-audio-element">audio</a></code></td><td>none</td><td><code id="elements-3:the-picture-element-3"><a href="#the-picture-element">picture</a></code>;
         <code id="elements-3:the-video-element-2"><a href="#the-video-element">video</a></code>;
         <code id="elements-3:the-audio-element-3"><a href="#the-audio-element">audio</a></code></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-85">globals</a>;
         <code id="elements-3:attr-source-type"><a href="#attr-source-type">type</a></code>;
         <code id="elements-3:attr-source-media"><a href="#attr-source-media">media</a></code>;
         <code id="elements-3:attr-source-src"><a href="#attr-source-src">src</a></code>;
         <code id="elements-3:attr-source-srcset"><a href="#attr-source-srcset">srcset</a></code>;
         <code id="elements-3:attr-source-sizes"><a href="#attr-source-sizes">sizes</a></code>;
         <code id="elements-3:attr-dim-width-6"><a href="#attr-dim-width">width</a></code>;
         <code id="elements-3:attr-dim-height-6"><a href="#attr-dim-height">height</a></code></td><td><code id="elements-3:htmlsourceelement"><a href="#htmlsourceelement">HTMLSourceElement</a></code></td></tr><tr><th><code id="elements-3:the-span-element"><a href="#the-span-element">span</a></code></th><td>Generic phrasing container</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-115">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-117">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-59">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-118">phrasing</a>;
         <a href="#option-element-inner-content-elements-2" id="elements-3:option-element-inner-content-elements-2-5"><code>option</code> element inner content elements</a>*</td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-119">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-86">globals</a></td><td><code id="elements-3:htmlspanelement"><a href="#htmlspanelement">HTMLSpanElement</a></code></td></tr><tr><th><code id="elements-3:the-strong-element"><a href="#the-strong-element">strong</a></code></th><td>Importance</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-116">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-120">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-60">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-121">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-122">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-87">globals</a></td><td><code id="elements-3:htmlelement-33"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-style-element"><a href="#the-style-element">style</a></code></th><td>Embedded styling information</td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2-7">metadata</a></td><td><code id="elements-3:the-head-element-8"><a href="#the-head-element">head</a></code>;
         <code id="elements-3:the-noscript-element-4"><a href="#the-noscript-element">noscript</a></code>*</td><td>text*</td><td><a href="#global-attributes" id="elements-3:global-attributes-88">globals</a>;
         <code id="elements-3:attr-style-media"><a href="#attr-style-media">media</a></code>;
         <code id="elements-3:attr-style-blocking"><a href="#attr-style-blocking">blocking</a></code></td><td><code id="elements-3:htmlstyleelement"><a href="#htmlstyleelement">HTMLStyleElement</a></code></td></tr><tr><th><code id="elements-3:the-sub-and-sup-elements"><a href="#the-sub-and-sup-elements">sub</a></code></th><td>Subscript</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-117">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-123">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-61">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-124">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-125">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-89">globals</a></td><td><code id="elements-3:htmlelement-34"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-summary-element-4"><a href="#the-summary-element">summary</a></code></th><td>Caption for <code id="elements-3:the-details-element-2"><a href="#the-details-element">details</a></code></td><td>none</td><td><code id="elements-3:the-details-element-3"><a href="#the-details-element">details</a></code></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-126">phrasing</a>;
         <a href="#heading-content-2" id="elements-3:heading-content-2-3">heading content</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-90">globals</a></td><td><code id="elements-3:htmlelement-35"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-sub-and-sup-elements-2"><a href="#the-sub-and-sup-elements">sup</a></code></th><td>Superscript</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-118">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-127">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-62">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-128">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-129">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-91">globals</a></td><td><code id="elements-3:htmlelement-36"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><a id="elements-3:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a></th><td>SVG root</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-119">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-130">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category-9">embedded</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-63">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-131">phrasing</a></td><td>per <a href="#refsSVG">[SVG]</a></td><td>per <a href="#refsSVG">[SVG]</a></td><td><code id="elements-3:svgsvgelement"><a data-x-internal="svgsvgelement" href="https://svgwg.org/svg2-draft/struct.html#InterfaceSVGSVGElement">SVGSVGElement</a></code></td></tr><tr><th><code id="elements-3:the-table-element-3"><a href="#the-table-element">table</a></code></th><td>Table</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-120">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-64">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-121">flow</a></td><td><code id="elements-3:the-caption-element-2"><a href="#the-caption-element">caption</a></code>*;
         <code id="elements-3:the-colgroup-element-3"><a href="#the-colgroup-element">colgroup</a></code>*;
         <code id="elements-3:the-thead-element"><a href="#the-thead-element">thead</a></code>*;
         <code id="elements-3:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>*;
         <code id="elements-3:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code>*;
         <code id="elements-3:the-tr-element"><a href="#the-tr-element">tr</a></code>*;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-9">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-92">globals</a></td><td><code id="elements-3:htmltableelement"><a href="#htmltableelement">HTMLTableElement</a></code></td></tr><tr><th><code id="elements-3:the-tbody-element-2"><a href="#the-tbody-element">tbody</a></code></th><td>Group of rows in a table</td><td>none</td><td><code id="elements-3:the-table-element-4"><a href="#the-table-element">table</a></code></td><td><code id="elements-3:the-tr-element-2"><a href="#the-tr-element">tr</a></code>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-10">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-93">globals</a></td><td><code id="elements-3:htmltablesectionelement"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code></td></tr><tr><th><code id="elements-3:the-td-element"><a href="#the-td-element">td</a></code></th><td>Table cell</td><td>none</td><td><code id="elements-3:the-tr-element-3"><a href="#the-tr-element">tr</a></code></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-122">flow</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-94">globals</a>;
         <code id="elements-3:attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code>;
         <code id="elements-3:attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code>;
         <code id="elements-3:attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code></td><td><code id="elements-3:htmltablecellelement"><a href="#htmltablecellelement">HTMLTableCellElement</a></code></td></tr><tr><th><code id="elements-3:the-template-element-2"><a href="#the-template-element">template</a></code></th><td>Template</td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2-8">metadata</a>;
         <a href="#flow-content-2" id="elements-3:flow-content-2-123">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-132">phrasing</a>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-11">script-supporting</a></td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2-9">metadata</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-133">phrasing</a>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-12">script-supporting</a>;
         <code id="elements-3:the-colgroup-element-4"><a href="#the-colgroup-element">colgroup</a></code>*</td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-95">globals</a>;
         <code id="elements-3:attr-template-shadowrootmode"><a href="#attr-template-shadowrootmode">shadowrootmode</a></code>;
         <code id="elements-3:attr-template-shadowrootdelegatesfocus"><a href="#attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus</a></code>;
         <code id="elements-3:attr-template-shadowrootclonable"><a href="#attr-template-shadowrootclonable">shadowrootclonable</a></code>;
         <code id="elements-3:attr-template-shadowrootserializable"><a href="#attr-template-shadowrootserializable">shadowrootserializable</a></code>;
         <code id="elements-3:attr-template-shadowrootcustomelementregistry"><a href="#attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</a></code></td><td><code id="elements-3:htmltemplateelement"><a href="#htmltemplateelement">HTMLTemplateElement</a></code></td></tr><tr><th><code id="elements-3:the-textarea-element"><a href="#the-textarea-element">textarea</a></code></th><td>Multiline text controls</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-124">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-134">phrasing</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-12">interactive</a>;
         <a href="#category-listed" id="elements-3:category-listed-7">listed</a>;
         <a href="#category-label" id="elements-3:category-label-7">labelable</a>;
         <a href="#category-submit" id="elements-3:category-submit-4">submittable</a>;
         <a href="#category-reset" id="elements-3:category-reset-4">resettable</a>;
         <a href="#form-associated-element" id="elements-3:form-associated-element-8">form-associated</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-65">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-135">phrasing</a></td><td><a href="#text-content" id="elements-3:text-content-3">text</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-96">globals</a>;
         <code id="elements-3:attr-fe-autocomplete-3"><a href="#attr-fe-autocomplete">autocomplete</a></code>;
         <code id="elements-3:attr-textarea-cols"><a href="#attr-textarea-cols">cols</a></code>;
         <code id="elements-3:attr-fe-dirname-2"><a href="#attr-fe-dirname">dirname</a></code>;
         <code id="elements-3:attr-fe-disabled-4"><a href="#attr-fe-disabled">disabled</a></code>;
         <code id="elements-3:attr-fae-form-7"><a href="#attr-fae-form">form</a></code>;
         <code id="elements-3:attr-textarea-maxlength"><a href="#attr-textarea-maxlength">maxlength</a></code>;
         <code id="elements-3:attr-textarea-minlength"><a href="#attr-textarea-minlength">minlength</a></code>;
         <code id="elements-3:attr-fe-name-6"><a href="#attr-fe-name">name</a></code>;
         <code id="elements-3:attr-textarea-placeholder"><a href="#attr-textarea-placeholder">placeholder</a></code>;
         <code id="elements-3:attr-textarea-readonly"><a href="#attr-textarea-readonly">readonly</a></code>;
         <code id="elements-3:attr-textarea-required"><a href="#attr-textarea-required">required</a></code>;
         <code id="elements-3:attr-textarea-rows"><a href="#attr-textarea-rows">rows</a></code>;
         <code id="elements-3:attr-textarea-wrap"><a href="#attr-textarea-wrap">wrap</a></code></td><td><code id="elements-3:htmltextareaelement"><a href="#htmltextareaelement">HTMLTextAreaElement</a></code></td></tr><tr><th><code id="elements-3:the-tfoot-element-2"><a href="#the-tfoot-element">tfoot</a></code></th><td>Group of footer rows in a table</td><td>none</td><td><code id="elements-3:the-table-element-5"><a href="#the-table-element">table</a></code></td><td><code id="elements-3:the-tr-element-4"><a href="#the-tr-element">tr</a></code>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-13">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-97">globals</a></td><td><code id="elements-3:htmltablesectionelement-2"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code></td></tr><tr><th><code id="elements-3:the-th-element"><a href="#the-th-element">th</a></code></th><td>Table header cell</td><td><a href="#interactive-content-2" id="elements-3:interactive-content-2-13">interactive</a>*</td><td><code id="elements-3:the-tr-element-5"><a href="#the-tr-element">tr</a></code></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-125">flow</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-98">globals</a>;
         <code id="elements-3:attr-tdth-colspan-2"><a href="#attr-tdth-colspan">colspan</a></code>;
         <code id="elements-3:attr-tdth-rowspan-2"><a href="#attr-tdth-rowspan">rowspan</a></code>;
         <code id="elements-3:attr-tdth-headers-2"><a href="#attr-tdth-headers">headers</a></code>;
         <code id="elements-3:attr-th-scope"><a href="#attr-th-scope">scope</a></code>;
         <code id="elements-3:attr-th-abbr"><a href="#attr-th-abbr">abbr</a></code></td><td><code id="elements-3:htmltablecellelement-2"><a href="#htmltablecellelement">HTMLTableCellElement</a></code></td></tr><tr><th><code id="elements-3:the-thead-element-2"><a href="#the-thead-element">thead</a></code></th><td>Group of heading rows in a table</td><td>none</td><td><code id="elements-3:the-table-element-6"><a href="#the-table-element">table</a></code></td><td><code id="elements-3:the-tr-element-6"><a href="#the-tr-element">tr</a></code>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-14">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-99">globals</a></td><td><code id="elements-3:htmltablesectionelement-3"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code></td></tr><tr><th><code id="elements-3:the-time-element"><a href="#the-time-element">time</a></code></th><td>Machine-readable equivalent of date- or time-related data</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-126">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-136">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-66">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-137">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-138">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-100">globals</a>;
         <code id="elements-3:attr-time-datetime"><a href="#attr-time-datetime">datetime</a></code></td><td><code id="elements-3:htmltimeelement"><a href="#htmltimeelement">HTMLTimeElement</a></code></td></tr><tr><th><code id="elements-3:the-title-element"><a href="#the-title-element">title</a></code></th><td>Document title</td><td><a href="#metadata-content-2" id="elements-3:metadata-content-2-10">metadata</a></td><td><code id="elements-3:the-head-element-9"><a href="#the-head-element">head</a></code></td><td><a href="#text-content" id="elements-3:text-content-4">text</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-101">globals</a></td><td><code id="elements-3:htmltitleelement"><a href="#htmltitleelement">HTMLTitleElement</a></code></td></tr><tr><th><code id="elements-3:the-tr-element-7"><a href="#the-tr-element">tr</a></code></th><td>Table row</td><td>none</td><td><code id="elements-3:the-table-element-7"><a href="#the-table-element">table</a></code>;
         <code id="elements-3:the-thead-element-3"><a href="#the-thead-element">thead</a></code>;
         <code id="elements-3:the-tbody-element-3"><a href="#the-tbody-element">tbody</a></code>;
         <code id="elements-3:the-tfoot-element-3"><a href="#the-tfoot-element">tfoot</a></code></td><td><code id="elements-3:the-th-element-2"><a href="#the-th-element">th</a></code>*;
         <code id="elements-3:the-td-element-2"><a href="#the-td-element">td</a></code>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-15">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-102">globals</a></td><td><code id="elements-3:htmltablerowelement"><a href="#htmltablerowelement">HTMLTableRowElement</a></code></td></tr><tr><th><code id="elements-3:the-track-element-2"><a href="#the-track-element">track</a></code></th><td>Timed text track</td><td>none</td><td><code id="elements-3:the-audio-element-4"><a href="#the-audio-element">audio</a></code>;
         <code id="elements-3:the-video-element-3"><a href="#the-video-element">video</a></code></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-103">globals</a>;
         <code id="elements-3:attr-track-default"><a href="#attr-track-default">default</a></code>;
         <code id="elements-3:attr-track-kind"><a href="#attr-track-kind">kind</a></code>;
         <code id="elements-3:attr-track-label"><a href="#attr-track-label">label</a></code>;
         <code id="elements-3:attr-track-src"><a href="#attr-track-src">src</a></code>;
         <code id="elements-3:attr-track-srclang"><a href="#attr-track-srclang">srclang</a></code></td><td><code id="elements-3:htmltrackelement"><a href="#htmltrackelement">HTMLTrackElement</a></code></td></tr><tr><th><code id="elements-3:the-u-element"><a href="#the-u-element">u</a></code></th><td>Unarticulated annotation</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-127">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-139">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-67">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-140">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-141">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-104">globals</a></td><td><code id="elements-3:htmlelement-37"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-ul-element-2"><a href="#the-ul-element">ul</a></code></th><td>List</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-128">flow</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-68">palpable</a>*</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-129">flow</a></td><td><code id="elements-3:the-li-element-4"><a href="#the-li-element">li</a></code>;
         <a href="#script-supporting-elements-2" id="elements-3:script-supporting-elements-2-16">script-supporting elements</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-105">globals</a></td><td><code id="elements-3:htmlulistelement"><a href="#htmlulistelement">HTMLUListElement</a></code></td></tr><tr><th><code id="elements-3:the-var-element"><a href="#the-var-element">var</a></code></th><td>Variable</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-130">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-142">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-69">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-143">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-144">phrasing</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-106">globals</a></td><td><code id="elements-3:htmlelement-38"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><code id="elements-3:the-video-element-4"><a href="#the-video-element">video</a></code></th><td>Video player</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-131">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-145">phrasing</a>;
         <a href="#embedded-content-category" id="elements-3:embedded-content-category-10">embedded</a>;
         <a href="#interactive-content-2" id="elements-3:interactive-content-2-14">interactive</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-70">palpable</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-146">phrasing</a></td><td><code id="elements-3:the-source-element-4"><a href="#the-source-element">source</a></code>*;
         <code id="elements-3:the-track-element-3"><a href="#the-track-element">track</a></code>*;
         <a href="#transparent" id="elements-3:transparent-9">transparent</a>*</td><td><a href="#global-attributes" id="elements-3:global-attributes-107">globals</a>;
         <code id="elements-3:attr-media-src-2"><a href="#attr-media-src">src</a></code>;
         <code id="elements-3:attr-media-crossorigin-2"><a href="#attr-media-crossorigin">crossorigin</a></code>;
         <code id="elements-3:attr-video-poster"><a href="#attr-video-poster">poster</a></code>;
         <code id="elements-3:attr-media-preload-2"><a href="#attr-media-preload">preload</a></code>;
         <code id="elements-3:attr-media-autoplay-2"><a href="#attr-media-autoplay">autoplay</a></code>;
         <code id="elements-3:attr-video-playsinline"><a href="#attr-video-playsinline">playsinline</a></code>;
         <code id="elements-3:attr-media-loop-2"><a href="#attr-media-loop">loop</a></code>;
         <code id="elements-3:attr-media-muted-2"><a href="#attr-media-muted">muted</a></code>;
         <code id="elements-3:attr-media-controls-2"><a href="#attr-media-controls">controls</a></code>;
         <code id="elements-3:attr-dim-width-7"><a href="#attr-dim-width">width</a></code>;
         <code id="elements-3:attr-dim-height-7"><a href="#attr-dim-height">height</a></code></td><td><code id="elements-3:htmlvideoelement"><a href="#htmlvideoelement">HTMLVideoElement</a></code></td></tr><tr><th><code id="elements-3:the-wbr-element"><a href="#the-wbr-element">wbr</a></code></th><td>Line breaking opportunity</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-132">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-147">phrasing</a></td><td><a href="#phrasing-content-2" id="elements-3:phrasing-content-2-148">phrasing</a></td><td>empty</td><td><a href="#global-attributes" id="elements-3:global-attributes-108">globals</a></td><td><code id="elements-3:htmlelement-39"><a href="#htmlelement">HTMLElement</a></code></td></tr><tr><th><a href="#autonomous-custom-element" id="elements-3:autonomous-custom-element">autonomous custom elements</a></th><td>Author-defined elements</td><td><a href="#flow-content-2" id="elements-3:flow-content-2-133">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-149">phrasing</a>;
         <a href="#palpable-content-2" id="elements-3:palpable-content-2-71">palpable</a></td><td><a href="#flow-content-2" id="elements-3:flow-content-2-134">flow</a>;
         <a href="#phrasing-content-2" id="elements-3:phrasing-content-2-150">phrasing</a></td><td><a href="#transparent" id="elements-3:transparent-10">transparent</a></td><td><a href="#global-attributes" id="elements-3:global-attributes-109">globals</a>; any, as decided by the element's author</td><td>Supplied by the element's author (inherits from <code id="elements-3:htmlelement-40"><a href="#htmlelement">HTMLElement</a></code>)</td></tr></tbody></table>

  <p class="tablenote"><small>An asterisk (*) in a cell indicates that the actual rules are more
  complicated than indicated in the table above.</small></p>

  <p class="tablenote"><small>† Categories in the "Parents" column refer to parents that list
  the given categories in their content model, not to elements that themselves are in those
  categories. For example, the <code id="elements-3:the-a-element-2"><a href="#the-a-element">a</a></code> element's "Parents" column says "phrasing", so any
  element whose content model contains the "phrasing" category could be a parent of an
  <code id="elements-3:the-a-element-3"><a href="#the-a-element">a</a></code> element. Since the "flow" category includes all the "phrasing" elements, that means
  the <code id="elements-3:the-th-element-3"><a href="#the-th-element">th</a></code> element could be a parent to an <code id="elements-3:the-a-element-4"><a href="#the-a-element">a</a></code> element.</small></p>


  <h3 id="element-content-categories" class="no-num">Element content categories<a href="#element-content-categories" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  

  <table><caption>List of element content categories</caption><thead><tr><th> Category
     </th><th> Elements
     </th><th> Elements with exceptions
   </th></tr></thead><tbody><tr><td> <a href="#metadata-content-2" id="element-content-categories:metadata-content-2">Metadata content</a>
     </td><td>
      <code id="element-content-categories:the-base-element"><a href="#the-base-element">base</a></code>;
      <code id="element-content-categories:the-link-element"><a href="#the-link-element">link</a></code>;
      <code id="element-content-categories:the-meta-element"><a href="#the-meta-element">meta</a></code>;
      <code id="element-content-categories:the-noscript-element"><a href="#the-noscript-element">noscript</a></code>;
      <code id="element-content-categories:the-script-element"><a href="#the-script-element">script</a></code>;
      <code id="element-content-categories:the-style-element"><a href="#the-style-element">style</a></code>;
      <code id="element-content-categories:the-template-element"><a href="#the-template-element">template</a></code>;
      <code id="element-content-categories:the-title-element"><a href="#the-title-element">title</a></code>
     </td><td>
      —

    </td></tr><tr><td> <a href="#flow-content-2" id="element-content-categories:flow-content-2">Flow content</a>
     </td><td>
      <code id="element-content-categories:the-a-element"><a href="#the-a-element">a</a></code>;
      <code id="element-content-categories:the-abbr-element"><a href="#the-abbr-element">abbr</a></code>;
      <code id="element-content-categories:the-address-element"><a href="#the-address-element">address</a></code>;
      <code id="element-content-categories:the-article-element"><a href="#the-article-element">article</a></code>;
      <code id="element-content-categories:the-aside-element"><a href="#the-aside-element">aside</a></code>;
      <code id="element-content-categories:the-audio-element"><a href="#the-audio-element">audio</a></code>;
      <code id="element-content-categories:the-b-element"><a href="#the-b-element">b</a></code>;
      <code id="element-content-categories:the-bdi-element"><a href="#the-bdi-element">bdi</a></code>;
      <code id="element-content-categories:the-bdo-element"><a href="#the-bdo-element">bdo</a></code>;
      <code id="element-content-categories:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code>;
      <code id="element-content-categories:the-br-element"><a href="#the-br-element">br</a></code>;
      <code id="element-content-categories:the-button-element"><a href="#the-button-element">button</a></code>;
      <code id="element-content-categories:the-canvas-element"><a href="#the-canvas-element">canvas</a></code>;
      <code id="element-content-categories:the-cite-element"><a href="#the-cite-element">cite</a></code>;
      <code id="element-content-categories:the-code-element"><a href="#the-code-element">code</a></code>;
      <code id="element-content-categories:the-data-element"><a href="#the-data-element">data</a></code>;
      <code id="element-content-categories:the-datalist-element"><a href="#the-datalist-element">datalist</a></code>;
      <code id="element-content-categories:the-del-element"><a href="#the-del-element">del</a></code>;
      <code id="element-content-categories:the-details-element"><a href="#the-details-element">details</a></code>;
      <code id="element-content-categories:the-dfn-element"><a href="#the-dfn-element">dfn</a></code>;
      <code id="element-content-categories:the-dialog-element"><a href="#the-dialog-element">dialog</a></code>;
      <code id="element-content-categories:the-div-element"><a href="#the-div-element">div</a></code>;
      <code id="element-content-categories:the-dl-element"><a href="#the-dl-element">dl</a></code>;
      <code id="element-content-categories:the-em-element"><a href="#the-em-element">em</a></code>;
      <code id="element-content-categories:the-embed-element"><a href="#the-embed-element">embed</a></code>;
      <code id="element-content-categories:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code>;
      <code id="element-content-categories:the-figure-element"><a href="#the-figure-element">figure</a></code>;
      <code id="element-content-categories:the-footer-element"><a href="#the-footer-element">footer</a></code>;
      <code id="element-content-categories:the-form-element"><a href="#the-form-element">form</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>;
      <code id="element-content-categories:the-header-element"><a href="#the-header-element">header</a></code>;
      <code id="element-content-categories:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code>;
      <code id="element-content-categories:the-hr-element"><a href="#the-hr-element">hr</a></code>;
      <code id="element-content-categories:the-i-element"><a href="#the-i-element">i</a></code>;
      <code id="element-content-categories:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>;
      <code id="element-content-categories:the-img-element"><a href="#the-img-element">img</a></code>;
      <code id="element-content-categories:the-input-element"><a href="#the-input-element">input</a></code>;
      <code id="element-content-categories:the-ins-element"><a href="#the-ins-element">ins</a></code>;
      <code id="element-content-categories:the-kbd-element"><a href="#the-kbd-element">kbd</a></code>;
      <code id="element-content-categories:the-label-element"><a href="#the-label-element">label</a></code>;
      <code id="element-content-categories:the-map-element"><a href="#the-map-element">map</a></code>;
      <code id="element-content-categories:the-mark-element"><a href="#the-mark-element">mark</a></code>;
      <a id="element-content-categories:mathml-math" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a>;
      <code id="element-content-categories:the-menu-element"><a href="#the-menu-element">menu</a></code>;
      <code id="element-content-categories:the-meter-element"><a href="#the-meter-element">meter</a></code>;
      <code id="element-content-categories:the-nav-element"><a href="#the-nav-element">nav</a></code>;
      <code id="element-content-categories:the-noscript-element-2"><a href="#the-noscript-element">noscript</a></code>;
      <code id="element-content-categories:the-object-element"><a href="#the-object-element">object</a></code>;
      <code id="element-content-categories:the-ol-element"><a href="#the-ol-element">ol</a></code>;
      <code id="element-content-categories:the-output-element"><a href="#the-output-element">output</a></code>;
      <code id="element-content-categories:the-p-element"><a href="#the-p-element">p</a></code>;
      <code id="element-content-categories:the-picture-element"><a href="#the-picture-element">picture</a></code>;
      <code id="element-content-categories:the-pre-element"><a href="#the-pre-element">pre</a></code>;
      <code id="element-content-categories:the-progress-element"><a href="#the-progress-element">progress</a></code>;
      <code id="element-content-categories:the-q-element"><a href="#the-q-element">q</a></code>;
      <code id="element-content-categories:the-ruby-element"><a href="#the-ruby-element">ruby</a></code>;
      <code id="element-content-categories:the-s-element"><a href="#the-s-element">s</a></code>;
      <code id="element-content-categories:the-samp-element"><a href="#the-samp-element">samp</a></code>;
      <code id="element-content-categories:the-script-element-2"><a href="#the-script-element">script</a></code>;
      <code id="element-content-categories:the-search-element"><a href="#the-search-element">search</a></code>;
      <code id="element-content-categories:the-section-element"><a href="#the-section-element">section</a></code>;
      <code id="element-content-categories:the-select-element"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-slot-element"><a href="#the-slot-element">slot</a></code>;
      <code id="element-content-categories:the-small-element"><a href="#the-small-element">small</a></code>;
      <code id="element-content-categories:the-span-element"><a href="#the-span-element">span</a></code>;
      <code id="element-content-categories:the-strong-element"><a href="#the-strong-element">strong</a></code>;
      <code id="element-content-categories:the-sub-and-sup-elements"><a href="#the-sub-and-sup-elements">sub</a></code>;
      <code id="element-content-categories:the-sub-and-sup-elements-2"><a href="#the-sub-and-sup-elements">sup</a></code>;
      <a id="element-content-categories:svg-svg" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a>;
      <code id="element-content-categories:the-table-element"><a href="#the-table-element">table</a></code>;
      <code id="element-content-categories:the-template-element-2"><a href="#the-template-element">template</a></code>;
      <code id="element-content-categories:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>;
      <code id="element-content-categories:the-time-element"><a href="#the-time-element">time</a></code>;
      <code id="element-content-categories:the-u-element"><a href="#the-u-element">u</a></code>;
      <code id="element-content-categories:the-ul-element"><a href="#the-ul-element">ul</a></code>;
      <code id="element-content-categories:the-var-element"><a href="#the-var-element">var</a></code>;
      <code id="element-content-categories:the-video-element"><a href="#the-video-element">video</a></code>;
      <code id="element-content-categories:the-wbr-element"><a href="#the-wbr-element">wbr</a></code>;
      <a href="#autonomous-custom-element" id="element-content-categories:autonomous-custom-element">autonomous custom elements</a>;
      <a href="#text-content" id="element-content-categories:text-content">Text</a>
     </td><td>
      <code id="element-content-categories:the-area-element"><a href="#the-area-element">area</a></code> (if it is a descendant of a <code id="element-content-categories:the-map-element-2"><a href="#the-map-element">map</a></code> element);
      <code id="element-content-categories:the-link-element-2"><a href="#the-link-element">link</a></code> (if it is <a href="#allowed-in-the-body" id="element-content-categories:allowed-in-the-body">allowed in the body</a>);
      <code id="element-content-categories:the-main-element"><a href="#the-main-element">main</a></code> (if it is a <a href="#hierarchically-correct-main-element" id="element-content-categories:hierarchically-correct-main-element">hierarchically correct <code>main</code> element</a>);
      <code id="element-content-categories:the-meta-element-2"><a href="#the-meta-element">meta</a></code> (if the <code id="element-content-categories:names:-the-itemprop-attribute"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is present)

    </td></tr><tr><td> <a href="#sectioning-content-2" id="element-content-categories:sectioning-content-2">Sectioning content</a>
     </td><td>
      <code id="element-content-categories:the-article-element-2"><a href="#the-article-element">article</a></code>;
      <code id="element-content-categories:the-aside-element-2"><a href="#the-aside-element">aside</a></code>;
      <code id="element-content-categories:the-nav-element-2"><a href="#the-nav-element">nav</a></code>;
      <code id="element-content-categories:the-section-element-2"><a href="#the-section-element">section</a></code>
     </td><td>
      —

    </td></tr><tr><td> <a href="#heading-content-2" id="element-content-categories:heading-content-2">Heading content</a>
     </td><td>
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-7"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-8"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-9"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-10"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-11"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-12"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>;
      <code id="element-content-categories:the-hgroup-element-2"><a href="#the-hgroup-element">hgroup</a></code>
     </td><td>
      —

    </td></tr><tr><td> <a href="#phrasing-content-2" id="element-content-categories:phrasing-content-2">Phrasing content</a>
     </td><td>
      <code id="element-content-categories:the-a-element-2"><a href="#the-a-element">a</a></code>;
      <code id="element-content-categories:the-abbr-element-2"><a href="#the-abbr-element">abbr</a></code>;
      <code id="element-content-categories:the-audio-element-2"><a href="#the-audio-element">audio</a></code>;
      <code id="element-content-categories:the-b-element-2"><a href="#the-b-element">b</a></code>;
      <code id="element-content-categories:the-bdi-element-2"><a href="#the-bdi-element">bdi</a></code>;
      <code id="element-content-categories:the-bdo-element-2"><a href="#the-bdo-element">bdo</a></code>;
      <code id="element-content-categories:the-br-element-2"><a href="#the-br-element">br</a></code>;
      <code id="element-content-categories:the-button-element-2"><a href="#the-button-element">button</a></code>;
      <code id="element-content-categories:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code>;
      <code id="element-content-categories:the-cite-element-2"><a href="#the-cite-element">cite</a></code>;
      <code id="element-content-categories:the-code-element-2"><a href="#the-code-element">code</a></code>;
      <code id="element-content-categories:the-data-element-2"><a href="#the-data-element">data</a></code>;
      <code id="element-content-categories:the-datalist-element-2"><a href="#the-datalist-element">datalist</a></code>;
      <code id="element-content-categories:the-del-element-2"><a href="#the-del-element">del</a></code>;
      <code id="element-content-categories:the-dfn-element-2"><a href="#the-dfn-element">dfn</a></code>;
      <code id="element-content-categories:the-em-element-2"><a href="#the-em-element">em</a></code>;
      <code id="element-content-categories:the-embed-element-2"><a href="#the-embed-element">embed</a></code>;
      <code id="element-content-categories:the-i-element-2"><a href="#the-i-element">i</a></code>;
      <code id="element-content-categories:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>;
      <code id="element-content-categories:the-img-element-2"><a href="#the-img-element">img</a></code>;
      <code id="element-content-categories:the-input-element-2"><a href="#the-input-element">input</a></code>;
      <code id="element-content-categories:the-ins-element-2"><a href="#the-ins-element">ins</a></code>;
      <code id="element-content-categories:the-kbd-element-2"><a href="#the-kbd-element">kbd</a></code>;
      <code id="element-content-categories:the-label-element-2"><a href="#the-label-element">label</a></code>;
      <code id="element-content-categories:the-map-element-3"><a href="#the-map-element">map</a></code>;
      <code id="element-content-categories:the-mark-element-2"><a href="#the-mark-element">mark</a></code>;
      <a id="element-content-categories:mathml-math-2" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a>;
      <code id="element-content-categories:the-meter-element-2"><a href="#the-meter-element">meter</a></code>;
      <code id="element-content-categories:the-noscript-element-3"><a href="#the-noscript-element">noscript</a></code>;
      <code id="element-content-categories:the-object-element-2"><a href="#the-object-element">object</a></code>;
      <code id="element-content-categories:the-output-element-2"><a href="#the-output-element">output</a></code>;
      <code id="element-content-categories:the-picture-element-2"><a href="#the-picture-element">picture</a></code>;
      <code id="element-content-categories:the-progress-element-2"><a href="#the-progress-element">progress</a></code>;
      <code id="element-content-categories:the-q-element-2"><a href="#the-q-element">q</a></code>;
      <code id="element-content-categories:the-ruby-element-2"><a href="#the-ruby-element">ruby</a></code>;
      <code id="element-content-categories:the-s-element-2"><a href="#the-s-element">s</a></code>;
      <code id="element-content-categories:the-samp-element-2"><a href="#the-samp-element">samp</a></code>;
      <code id="element-content-categories:the-script-element-3"><a href="#the-script-element">script</a></code>;
      <code id="element-content-categories:the-select-element-2"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-selectedcontent-element"><a href="#the-selectedcontent-element">selectedcontent</a></code>;
      <code id="element-content-categories:the-slot-element-2"><a href="#the-slot-element">slot</a></code>;
      <code id="element-content-categories:the-small-element-2"><a href="#the-small-element">small</a></code>;
      <code id="element-content-categories:the-span-element-2"><a href="#the-span-element">span</a></code>;
      <code id="element-content-categories:the-strong-element-2"><a href="#the-strong-element">strong</a></code>;
      <code id="element-content-categories:the-sub-and-sup-elements-3"><a href="#the-sub-and-sup-elements">sub</a></code>;
      <code id="element-content-categories:the-sub-and-sup-elements-4"><a href="#the-sub-and-sup-elements">sup</a></code>;
      <a id="element-content-categories:svg-svg-2" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a>;
      <code id="element-content-categories:the-template-element-3"><a href="#the-template-element">template</a></code>;
      <code id="element-content-categories:the-textarea-element-2"><a href="#the-textarea-element">textarea</a></code>;
      <code id="element-content-categories:the-time-element-2"><a href="#the-time-element">time</a></code>;
      <code id="element-content-categories:the-u-element-2"><a href="#the-u-element">u</a></code>;
      <code id="element-content-categories:the-var-element-2"><a href="#the-var-element">var</a></code>;
      <code id="element-content-categories:the-video-element-2"><a href="#the-video-element">video</a></code>;
      <code id="element-content-categories:the-wbr-element-2"><a href="#the-wbr-element">wbr</a></code>;
      <a href="#autonomous-custom-element" id="element-content-categories:autonomous-custom-element-2">autonomous custom elements</a>;
      <a href="#text-content" id="element-content-categories:text-content-2">Text</a>
     </td><td>
      <code id="element-content-categories:the-area-element-2"><a href="#the-area-element">area</a></code> (if it is a descendant of a  <code id="element-content-categories:the-map-element-4"><a href="#the-map-element">map</a></code> element);
      <code id="element-content-categories:the-link-element-3"><a href="#the-link-element">link</a></code> (if it is <a href="#allowed-in-the-body" id="element-content-categories:allowed-in-the-body-2">allowed in the body</a>);
      <code id="element-content-categories:the-meta-element-3"><a href="#the-meta-element">meta</a></code> (if the <code id="element-content-categories:names:-the-itemprop-attribute-2"><a href="#names:-the-itemprop-attribute">itemprop</a></code> attribute is present)

    </td></tr><tr><td> <a href="#embedded-content-category" id="element-content-categories:embedded-content-category">Embedded content</a>
     </td><td>
      <code id="element-content-categories:the-audio-element-3"><a href="#the-audio-element">audio</a></code>;
      <code id="element-content-categories:the-canvas-element-3"><a href="#the-canvas-element">canvas</a></code>;
      <code id="element-content-categories:the-embed-element-3"><a href="#the-embed-element">embed</a></code>;
      <code id="element-content-categories:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code>;
      <code id="element-content-categories:the-img-element-3"><a href="#the-img-element">img</a></code>;
      <a id="element-content-categories:mathml-math-3" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a>;
      <code id="element-content-categories:the-object-element-3"><a href="#the-object-element">object</a></code>;
      <code id="element-content-categories:the-picture-element-3"><a href="#the-picture-element">picture</a></code>;
      <a id="element-content-categories:svg-svg-3" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a>;
      <code id="element-content-categories:the-video-element-3"><a href="#the-video-element">video</a></code>
     </td><td>
      —

    </td></tr><tr><td> <a href="#interactive-content-2" id="element-content-categories:interactive-content-2">Interactive content</a>
     </td><td>
      <code id="element-content-categories:the-button-element-3"><a href="#the-button-element">button</a></code>;
      <code id="element-content-categories:the-details-element-2"><a href="#the-details-element">details</a></code>;
      <code id="element-content-categories:the-embed-element-4"><a href="#the-embed-element">embed</a></code>;
      <code id="element-content-categories:the-iframe-element-4"><a href="#the-iframe-element">iframe</a></code>;
      <code id="element-content-categories:the-label-element-3"><a href="#the-label-element">label</a></code>;
      <code id="element-content-categories:the-select-element-3"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-textarea-element-3"><a href="#the-textarea-element">textarea</a></code>
     </td><td>
      <code id="element-content-categories:the-a-element-3"><a href="#the-a-element">a</a></code> (if the <code id="element-content-categories:attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute is present);
      <code id="element-content-categories:the-audio-element-4"><a href="#the-audio-element">audio</a></code> (if the <code id="element-content-categories:attr-media-controls"><a href="#attr-media-controls">controls</a></code> attribute is present);
      <code id="element-content-categories:the-img-element-4"><a href="#the-img-element">img</a></code> (if the <code id="element-content-categories:attr-hyperlink-usemap"><a href="#attr-hyperlink-usemap">usemap</a></code> attribute is present);
      <code id="element-content-categories:the-input-element-3"><a href="#the-input-element">input</a></code> (if the <code id="element-content-categories:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is <em>not</em> in the <a href="#hidden-state-(type=hidden)" id="element-content-categories:hidden-state-(type=hidden)">Hidden</a> state);
      <code id="element-content-categories:the-video-element-4"><a href="#the-video-element">video</a></code> (if the <code id="element-content-categories:attr-media-controls-2"><a href="#attr-media-controls">controls</a></code> attribute is present)

    </td></tr><tr><td> <a href="#form-associated-element" id="element-content-categories:form-associated-element">Form-associated elements</a>
     </td><td>
      <code id="element-content-categories:the-button-element-4"><a href="#the-button-element">button</a></code>;
      <code id="element-content-categories:the-fieldset-element-2"><a href="#the-fieldset-element">fieldset</a></code>;
      <code id="element-content-categories:the-input-element-4"><a href="#the-input-element">input</a></code>;
      <code id="element-content-categories:the-label-element-4"><a href="#the-label-element">label</a></code>;
      <code id="element-content-categories:the-object-element-4"><a href="#the-object-element">object</a></code>;
      <code id="element-content-categories:the-output-element-3"><a href="#the-output-element">output</a></code>;
      <code id="element-content-categories:the-select-element-4"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-textarea-element-4"><a href="#the-textarea-element">textarea</a></code>;
      <code id="element-content-categories:the-img-element-5"><a href="#the-img-element">img</a></code>;
      <a href="#form-associated-custom-element" id="element-content-categories:form-associated-custom-element">form-associated custom elements</a>
     </td><td>
      —

    </td></tr><tr><td> <a href="#category-listed" id="element-content-categories:category-listed">Listed elements</a>
     </td><td>
      <code id="element-content-categories:the-button-element-5"><a href="#the-button-element">button</a></code>;
      <code id="element-content-categories:the-fieldset-element-3"><a href="#the-fieldset-element">fieldset</a></code>;
      <code id="element-content-categories:the-input-element-5"><a href="#the-input-element">input</a></code>;
      <code id="element-content-categories:the-object-element-5"><a href="#the-object-element">object</a></code>;
      <code id="element-content-categories:the-output-element-4"><a href="#the-output-element">output</a></code>;
      <code id="element-content-categories:the-select-element-5"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-textarea-element-5"><a href="#the-textarea-element">textarea</a></code>;
      <a href="#form-associated-custom-element" id="element-content-categories:form-associated-custom-element-2">form-associated custom elements</a>
     </td><td>
      —

    </td></tr><tr><td> <a href="#category-submit" id="element-content-categories:category-submit">Submittable elements</a>
     </td><td>
      <code id="element-content-categories:the-button-element-6"><a href="#the-button-element">button</a></code>;
      <code id="element-content-categories:the-input-element-6"><a href="#the-input-element">input</a></code>;
      <code id="element-content-categories:the-select-element-6"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-textarea-element-6"><a href="#the-textarea-element">textarea</a></code>;
      <a href="#form-associated-custom-element" id="element-content-categories:form-associated-custom-element-3">form-associated custom elements</a>
     </td><td>
      —

    </td></tr><tr><td> <a href="#category-reset" id="element-content-categories:category-reset">Resettable elements</a>
     </td><td>
      <code id="element-content-categories:the-input-element-7"><a href="#the-input-element">input</a></code>;
      <code id="element-content-categories:the-output-element-5"><a href="#the-output-element">output</a></code>;
      <code id="element-content-categories:the-select-element-7"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-textarea-element-7"><a href="#the-textarea-element">textarea</a></code>;
      <a href="#form-associated-custom-element" id="element-content-categories:form-associated-custom-element-4">form-associated custom elements</a>
     </td><td>
      —

    </td></tr><tr><td> <a href="#category-autocapitalize" id="element-content-categories:category-autocapitalize">Autocapitalize-and-autocorrect
     inheriting elements</a>
     </td><td>
      <code id="element-content-categories:the-button-element-7"><a href="#the-button-element">button</a></code>;
      <code id="element-content-categories:the-fieldset-element-4"><a href="#the-fieldset-element">fieldset</a></code>;
      <code id="element-content-categories:the-input-element-8"><a href="#the-input-element">input</a></code>;
      <code id="element-content-categories:the-output-element-6"><a href="#the-output-element">output</a></code>;
      <code id="element-content-categories:the-select-element-8"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-textarea-element-8"><a href="#the-textarea-element">textarea</a></code>
     </td><td>
      —

    </td></tr><tr><td> <a href="#category-label" id="element-content-categories:category-label">Labelable elements</a>
     </td><td>
      <code id="element-content-categories:the-button-element-8"><a href="#the-button-element">button</a></code>;
      <code id="element-content-categories:the-input-element-9"><a href="#the-input-element">input</a></code>;
      <code id="element-content-categories:the-meter-element-3"><a href="#the-meter-element">meter</a></code>;
      <code id="element-content-categories:the-output-element-7"><a href="#the-output-element">output</a></code>;
      <code id="element-content-categories:the-progress-element-3"><a href="#the-progress-element">progress</a></code>;
      <code id="element-content-categories:the-select-element-9"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-textarea-element-9"><a href="#the-textarea-element">textarea</a></code>;
      <a href="#form-associated-custom-element" id="element-content-categories:form-associated-custom-element-5">form-associated custom elements</a>
     </td><td>
      —

    </td></tr><tr><td> <a href="#palpable-content-2" id="element-content-categories:palpable-content-2">Palpable content</a>
     </td><td>
      <code id="element-content-categories:the-a-element-4"><a href="#the-a-element">a</a></code>;
      <code id="element-content-categories:the-abbr-element-3"><a href="#the-abbr-element">abbr</a></code>;
      <code id="element-content-categories:the-address-element-2"><a href="#the-address-element">address</a></code>;
      <code id="element-content-categories:the-article-element-3"><a href="#the-article-element">article</a></code>;
      <code id="element-content-categories:the-aside-element-3"><a href="#the-aside-element">aside</a></code>;
      <code id="element-content-categories:the-b-element-3"><a href="#the-b-element">b</a></code>;
      <code id="element-content-categories:the-bdi-element-3"><a href="#the-bdi-element">bdi</a></code>;
      <code id="element-content-categories:the-bdo-element-3"><a href="#the-bdo-element">bdo</a></code>;
      <code id="element-content-categories:the-blockquote-element-2"><a href="#the-blockquote-element">blockquote</a></code>;
      <code id="element-content-categories:the-button-element-9"><a href="#the-button-element">button</a></code>;
      <code id="element-content-categories:the-canvas-element-4"><a href="#the-canvas-element">canvas</a></code>;
      <code id="element-content-categories:the-cite-element-3"><a href="#the-cite-element">cite</a></code>;
      <code id="element-content-categories:the-code-element-3"><a href="#the-code-element">code</a></code>;
      <code id="element-content-categories:the-data-element-3"><a href="#the-data-element">data</a></code>;
      <code id="element-content-categories:the-del-element-3"><a href="#the-del-element">del</a></code>;
      <code id="element-content-categories:the-details-element-3"><a href="#the-details-element">details</a></code>;
      <code id="element-content-categories:the-dfn-element-3"><a href="#the-dfn-element">dfn</a></code>;
      <code id="element-content-categories:the-div-element-2"><a href="#the-div-element">div</a></code>;
      <code id="element-content-categories:the-em-element-3"><a href="#the-em-element">em</a></code>;
      <code id="element-content-categories:the-embed-element-5"><a href="#the-embed-element">embed</a></code>;
      <code id="element-content-categories:the-fieldset-element-5"><a href="#the-fieldset-element">fieldset</a></code>;
      <code id="element-content-categories:the-figure-element-2"><a href="#the-figure-element">figure</a></code>;
      <code id="element-content-categories:the-footer-element-2"><a href="#the-footer-element">footer</a></code>;
      <code id="element-content-categories:the-form-element-2"><a href="#the-form-element">form</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-13"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-14"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-15"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-16"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-17"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>;
      <code id="element-content-categories:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-18"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>;
      <code id="element-content-categories:the-header-element-2"><a href="#the-header-element">header</a></code>;
      <code id="element-content-categories:the-hgroup-element-3"><a href="#the-hgroup-element">hgroup</a></code>;
      <code id="element-content-categories:the-i-element-3"><a href="#the-i-element">i</a></code>;
      <code id="element-content-categories:the-iframe-element-5"><a href="#the-iframe-element">iframe</a></code>;
      <code id="element-content-categories:the-img-element-6"><a href="#the-img-element">img</a></code>;
      <code id="element-content-categories:the-ins-element-3"><a href="#the-ins-element">ins</a></code>;
      <code id="element-content-categories:the-kbd-element-3"><a href="#the-kbd-element">kbd</a></code>;
      <code id="element-content-categories:the-label-element-5"><a href="#the-label-element">label</a></code>;
      <code id="element-content-categories:the-main-element-2"><a href="#the-main-element">main</a></code>;
      <code id="element-content-categories:the-map-element-5"><a href="#the-map-element">map</a></code>;
      <code id="element-content-categories:the-mark-element-3"><a href="#the-mark-element">mark</a></code>;
      <a id="element-content-categories:mathml-math-4" href="https://w3c.github.io/mathml-core/#the-top-level-math-element" data-x-internal="mathml-math">MathML <code>math</code></a>;
      <code id="element-content-categories:the-meter-element-4"><a href="#the-meter-element">meter</a></code>;
      <code id="element-content-categories:the-nav-element-3"><a href="#the-nav-element">nav</a></code>;
      <code id="element-content-categories:the-object-element-6"><a href="#the-object-element">object</a></code>;
      <code id="element-content-categories:the-output-element-8"><a href="#the-output-element">output</a></code>;
      <code id="element-content-categories:the-p-element-2"><a href="#the-p-element">p</a></code>;
      <code id="element-content-categories:the-picture-element-4"><a href="#the-picture-element">picture</a></code>;
      <code id="element-content-categories:the-pre-element-2"><a href="#the-pre-element">pre</a></code>;
      <code id="element-content-categories:the-progress-element-4"><a href="#the-progress-element">progress</a></code>;
      <code id="element-content-categories:the-q-element-3"><a href="#the-q-element">q</a></code>;
      <code id="element-content-categories:the-ruby-element-3"><a href="#the-ruby-element">ruby</a></code>;
      <code id="element-content-categories:the-s-element-3"><a href="#the-s-element">s</a></code>;
      <code id="element-content-categories:the-samp-element-3"><a href="#the-samp-element">samp</a></code>;
      <code id="element-content-categories:the-search-element-2"><a href="#the-search-element">search</a></code>;
      <code id="element-content-categories:the-section-element-3"><a href="#the-section-element">section</a></code>;
      <code id="element-content-categories:the-select-element-10"><a href="#the-select-element">select</a></code>;
      <code id="element-content-categories:the-small-element-3"><a href="#the-small-element">small</a></code>;
      <code id="element-content-categories:the-span-element-3"><a href="#the-span-element">span</a></code>;
      <code id="element-content-categories:the-strong-element-3"><a href="#the-strong-element">strong</a></code>;
      <code id="element-content-categories:the-sub-and-sup-elements-5"><a href="#the-sub-and-sup-elements">sub</a></code>;
      <code id="element-content-categories:the-sub-and-sup-elements-6"><a href="#the-sub-and-sup-elements">sup</a></code>;
      <a id="element-content-categories:svg-svg-4" href="https://svgwg.org/svg2-draft/struct.html#SVGElement" data-x-internal="svg-svg">SVG <code>svg</code></a>;
      <code id="element-content-categories:the-table-element-2"><a href="#the-table-element">table</a></code>;
      <code id="element-content-categories:the-textarea-element-10"><a href="#the-textarea-element">textarea</a></code>;
      <code id="element-content-categories:the-time-element-3"><a href="#the-time-element">time</a></code>;
      <code id="element-content-categories:the-u-element-3"><a href="#the-u-element">u</a></code>;
      <code id="element-content-categories:the-var-element-3"><a href="#the-var-element">var</a></code>;
      <code id="element-content-categories:the-video-element-5"><a href="#the-video-element">video</a></code>;
      <a href="#autonomous-custom-element" id="element-content-categories:autonomous-custom-element-3">autonomous custom elements</a>
     </td><td>
      <code id="element-content-categories:the-audio-element-5"><a href="#the-audio-element">audio</a></code> (if the <code id="element-content-categories:attr-media-controls-3"><a href="#attr-media-controls">controls</a></code> attribute is present);
      <code id="element-content-categories:the-dl-element-2"><a href="#the-dl-element">dl</a></code> (if the element's children include at least one name-value group);
      <code id="element-content-categories:the-input-element-10"><a href="#the-input-element">input</a></code> (if the <code id="element-content-categories:attr-input-type-2"><a href="#attr-input-type">type</a></code> attribute is <em>not</em> in the <a href="#hidden-state-(type=hidden)" id="element-content-categories:hidden-state-(type=hidden)-2">Hidden</a> state);
      <code id="element-content-categories:the-menu-element-2"><a href="#the-menu-element">menu</a></code> (if the element's children include at least one <code id="element-content-categories:the-li-element"><a href="#the-li-element">li</a></code> element);
      <code id="element-content-categories:the-ol-element-2"><a href="#the-ol-element">ol</a></code> (if the element's children include at least one <code id="element-content-categories:the-li-element-2"><a href="#the-li-element">li</a></code> element);
      <code id="element-content-categories:the-ul-element-2"><a href="#the-ul-element">ul</a></code> (if the element's children include at least one <code id="element-content-categories:the-li-element-3"><a href="#the-li-element">li</a></code> element);
      <a href="#text-content" id="element-content-categories:text-content-3">Text</a> that is not <a href="#inter-element-whitespace" id="element-content-categories:inter-element-whitespace">inter-element whitespace</a>

    </td></tr><tr><td> <a href="#script-supporting-elements-2" id="element-content-categories:script-supporting-elements-2">Script-supporting elements</a>
     </td><td>
      <code id="element-content-categories:the-script-element-4"><a href="#the-script-element">script</a></code>;
      <code id="element-content-categories:the-template-element-4"><a href="#the-template-element">template</a></code>
     </td><td>
      —

    </td></tr><tr><td> <a href="#select-element-inner-content-elements-2" id="element-content-categories:select-element-inner-content-elements-2"><code>select</code> element inner content elements</a>
     </td><td>
      <code id="element-content-categories:the-option-element"><a href="#the-option-element">option</a></code>;
      <code id="element-content-categories:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code>;
      <code id="element-content-categories:the-hr-element-2"><a href="#the-hr-element">hr</a></code>;
      <a href="#script-supporting-elements-2" id="element-content-categories:script-supporting-elements-2-2">script-supporting elements</a>;
      <code id="element-content-categories:the-noscript-element-4"><a href="#the-noscript-element">noscript</a></code>;
      <code id="element-content-categories:the-div-element-3"><a href="#the-div-element">div</a></code>
     </td><td>
      —

    </td></tr><tr><td> <a href="#optgroup-element-inner-content-elements-2" id="element-content-categories:optgroup-element-inner-content-elements-2"><code>optgroup</code> element inner content elements</a>
     </td><td>
      <code id="element-content-categories:the-option-element-2"><a href="#the-option-element">option</a></code>;
      <a href="#script-supporting-elements-2" id="element-content-categories:script-supporting-elements-2-3">script-supporting elements</a>;
      <code id="element-content-categories:the-noscript-element-5"><a href="#the-noscript-element">noscript</a></code>;
      <code id="element-content-categories:the-div-element-4"><a href="#the-div-element">div</a></code>
     </td><td>
      —

    </td></tr><tr><td> <a href="#option-element-inner-content-elements-2" id="element-content-categories:option-element-inner-content-elements-2"><code>option</code> element inner content elements</a>
     </td><td>
      <code id="element-content-categories:the-div-element-5"><a href="#the-div-element">div</a></code>
     </td><td>
      <a href="#phrasing-content-2" id="element-content-categories:phrasing-content-2-2">phrasing content</a> except for <code id="element-content-categories:the-datalist-element-3"><a href="#the-datalist-element">datalist</a></code>, <code id="element-content-categories:the-object-element-7"><a href="#the-object-element">object</a></code>,
      <a href="#interactive-content-2" id="element-content-categories:interactive-content-2-2">interactive content</a>, or elements with <code id="element-content-categories:attr-tabindex"><a href="#attr-tabindex">tabindex</a></code>

  </td></tr></tbody></table>


  <h3 id="attributes-3" class="no-num">Attributes<a href="#attributes-3" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <table id="attributes-1"><caption>List of attributes (excluding event handler content attributes)</caption><thead><tr><th> Attribute
     </th><th> Element(s)
     </th><th> Description
     </th><th> Value
   </th></tr></thead><tbody><tr><th> <code>abbr</code>
     </th><td> <code id="attributes-3:attr-th-abbr"><a href="#attr-th-abbr">th</a></code>
     </td><td> Alternative label to use for the header cell when referencing the cell in other contexts
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>accept</code>
     </th><td> <code id="attributes-3:attr-input-accept"><a href="#attr-input-accept">input</a></code>
     </td><td> Hint for expected file type in <a href="#file-upload-state-(type=file)" id="attributes-3:file-upload-state-(type=file)">file upload controls</a>
     </td><td> <a href="#set-of-comma-separated-tokens" id="attributes-3:set-of-comma-separated-tokens">Set of comma-separated tokens</a>* consisting of <a href="https://mimesniff.spec.whatwg.org/#valid-mime-type-with-no-parameters" id="attributes-3:valid-mime-type-string-with-no-parameters" data-x-internal="valid-mime-type-string-with-no-parameters">valid MIME type strings with no parameters</a> or <code>audio/*</code>, <code>video/*</code>, or <code>image/*</code>
    </td></tr><tr><th> <code>accept-charset</code>
     </th><td> <code id="attributes-3:attr-form-accept-charset"><a href="#attr-form-accept-charset">form</a></code>
     </td><td> Character encodings to use for <a href="#form-submission-2" id="attributes-3:form-submission-2">form submission</a>
     </td><td> <a id="attributes-3:ascii-case-insensitive" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a> match for "<code>UTF-8</code>"
    </td></tr><tr><th> <code>accesskey</code>
     </th><td> <a href="#the-accesskey-attribute" id="attributes-3:the-accesskey-attribute">HTML elements</a>
     </td><td> Keyboard shortcut to activate or focus element
     </td><td> <a href="#ordered-set-of-unique-space-separated-tokens" id="attributes-3:ordered-set-of-unique-space-separated-tokens">Ordered set of unique space-separated tokens</a>, none of which are <a id="attributes-3:identical-to" href="https://infra.spec.whatwg.org/#string-is" data-x-internal="identical-to">identical to</a> another, each consisting of one code point in length
    </td></tr><tr><th> <code>action</code>
     </th><td> <code id="attributes-3:attr-fs-action"><a href="#attr-fs-action">form</a></code>
     </td><td> <a id="attributes-3:url" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> to use for <a href="#form-submission-2" id="attributes-3:form-submission-2-2">form submission</a>
     </td><td> <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="attributes-3:valid-non-empty-url-potentially-surrounded-by-spaces">Valid non-empty URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>allow</code>
     </th><td> <code id="attributes-3:attr-iframe-allow"><a href="#attr-iframe-allow">iframe</a></code>
     </td><td> <a href="https://w3c.github.io/webappsec-feature-policy/#permissions-policy" id="attributes-3:concept-permissions-policy" data-x-internal="concept-permissions-policy">Permissions policy</a> to be applied to the <code id="attributes-3:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>'s contents
     </td><td> <a href="https://w3c.github.io/webappsec-feature-policy/#serialized-permissions-policy" id="attributes-3:concept-serialized-permissions-policy" data-x-internal="concept-serialized-permissions-policy">Serialized permissions policy</a>
    </td></tr><tr><th> <code>allowfullscreen</code>
     </th><td> <code id="attributes-3:attr-iframe-allowfullscreen"><a href="#attr-iframe-allowfullscreen">iframe</a></code>
     </td><td> Whether to allow the <code id="attributes-3:the-iframe-element-2"><a href="#the-iframe-element">iframe</a></code>'s contents to use <code id="attributes-3:dom-element-requestfullscreen"><a data-x-internal="dom-element-requestfullscreen" href="https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen">requestFullscreen()</a></code>
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute">Boolean attribute</a>
    </td></tr><tr><th> <code>alpha</code>
     </th><td> <code id="attributes-3:attr-input-alpha"><a href="#attr-input-alpha">input</a></code>
     </td><td> Allow the color's alpha component to be set
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-2">Boolean attribute</a>
    </td></tr><tr><th> <code>alt</code>
     </th><td> <code id="attributes-3:attr-area-alt"><a href="#attr-area-alt">area</a></code>;
          <code id="attributes-3:attr-img-alt"><a href="#attr-img-alt">img</a></code>;
          <code id="attributes-3:attr-input-alt"><a href="#attr-input-alt">input</a></code>
     </td><td> Replacement text for use when images are not available
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>as</code>
     </th><td> <code id="attributes-3:attr-link-as"><a href="#attr-link-as">link</a></code>
     </td><td> <a href="https://fetch.spec.whatwg.org/#concept-potential-destination" id="attributes-3:concept-potential-destination" data-x-internal="concept-potential-destination">Potential destination</a> for a preload request (for <code id="attributes-3:attr-link-rel"><a href="#attr-link-rel">rel</a></code>="<code id="attributes-3:link-type-preload"><a href="#link-type-preload">preload</a></code>" and <code id="attributes-3:attr-link-rel-2"><a href="#attr-link-rel">rel</a></code>="<code id="attributes-3:link-type-modulepreload"><a href="#link-type-modulepreload">modulepreload</a></code>")
     </td><td> <a href="https://fetch.spec.whatwg.org/#concept-potential-destination" id="attributes-3:concept-potential-destination-2" data-x-internal="concept-potential-destination">Potential destination</a>, for <code id="attributes-3:attr-link-rel-3"><a href="#attr-link-rel">rel</a></code>="<code id="attributes-3:link-type-preload-2"><a href="#link-type-preload">preload</a></code>"; <a href="https://fetch.spec.whatwg.org/#request-destination-script-like" id="attributes-3:concept-script-like-destination" data-x-internal="concept-script-like-destination">script-like destination</a>, for <code id="attributes-3:attr-link-rel-4"><a href="#attr-link-rel">rel</a></code>="<code id="attributes-3:link-type-modulepreload-2"><a href="#link-type-modulepreload">modulepreload</a></code>"
    </td></tr><tr><th> <code>async</code>
     </th><td> <code id="attributes-3:attr-script-async"><a href="#attr-script-async">script</a></code>
     </td><td> Execute script when available, without blocking while fetching
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-3">Boolean attribute</a>
    </td></tr><tr><th> <code>autocapitalize</code>
     </th><td> <a href="#attr-autocapitalize" id="attributes-3:attr-autocapitalize">HTML elements</a>
     </td><td> Recommended autocapitalization behavior (for supported input methods)
     </td><td> "<code id="attributes-3:attr-autocapitalize-on"><a href="#attr-autocapitalize-on">on</a></code>";
          "<code id="attributes-3:attr-autocapitalize-off"><a href="#attr-autocapitalize-off">off</a></code>";
          "<code id="attributes-3:attr-autocapitalize-none"><a href="#attr-autocapitalize-none">none</a></code>";
          "<code id="attributes-3:attr-autocapitalize-sentences"><a href="#attr-autocapitalize-sentences">sentences</a></code>";
          "<code id="attributes-3:attr-autocapitalize-words"><a href="#attr-autocapitalize-words">words</a></code>";
          "<code id="attributes-3:attr-autocapitalize-characters"><a href="#attr-autocapitalize-characters">characters</a></code>"
    </td></tr><tr><th> <code>autocomplete</code>
     </th><td> <code id="attributes-3:attr-form-autocomplete"><a href="#attr-form-autocomplete">form</a></code>
     </td><td> Default setting for autofill feature for controls in the form
     </td><td> "<code>on</code>"; "<code>off</code>"
    </td></tr><tr><th> <code>autocomplete</code>
     </th><td> <code id="attributes-3:attr-fe-autocomplete"><a href="#attr-fe-autocomplete">input</a></code>;
          <code id="attributes-3:attr-fe-autocomplete-2"><a href="#attr-fe-autocomplete">select</a></code>;
          <code id="attributes-3:attr-fe-autocomplete-3"><a href="#attr-fe-autocomplete">textarea</a></code>
     </td><td> Hint for form autofill feature
     </td><td> <a href="#autofill-field" id="attributes-3:autofill-field">Autofill field</a> name and related tokens*
    </td></tr><tr><th> <code>autocorrect</code>
     </th><td> <a href="#attr-autocorrect" id="attributes-3:attr-autocorrect">HTML elements</a>
     </td><td> Recommended autocorrection behavior (for supported input methods)
     </td><td> "<code id="attributes-3:attr-autocorrect-on"><a href="#attr-autocorrect-on">on</a></code>";
          "<code id="attributes-3:attr-autocorrect-off"><a href="#attr-autocorrect-off">off</a></code>"
    </td></tr><tr><th> <code>autofocus</code>
     </th><td> <a href="#attr-fe-autofocus" id="attributes-3:attr-fe-autofocus">HTML elements</a>
     </td><td> Automatically focus the element when the page is loaded
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-4">Boolean attribute</a>
    </td></tr><tr><th> <code>autoplay</code>
     </th><td> <code id="attributes-3:attr-media-autoplay"><a href="#attr-media-autoplay">audio</a></code>;
          <code id="attributes-3:attr-media-autoplay-2"><a href="#attr-media-autoplay">video</a></code>
     </td><td> Hint that the <a href="#media-resource" id="attributes-3:media-resource">media resource</a> can be started automatically when the page is loaded
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-5">Boolean attribute</a>
    </td></tr><tr><th> <code>blocking</code>
     </th><td> <code id="attributes-3:attr-link-blocking"><a href="#attr-link-blocking">link</a></code>;
          <code id="attributes-3:attr-script-blocking"><a href="#attr-script-blocking">script</a></code>;
          <code id="attributes-3:attr-style-blocking"><a href="#attr-style-blocking">style</a></code>
     </td><td> Whether the element is <a href="#potentially-render-blocking" id="attributes-3:potentially-render-blocking">potentially render-blocking</a>
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens">Unordered set of unique space-separated tokens</a>*
    </td></tr><tr><th> <code>charset</code>
     </th><td> <code id="attributes-3:attr-meta-charset"><a href="#attr-meta-charset">meta</a></code>
     </td><td> <a href="#character-encoding-declaration" id="attributes-3:character-encoding-declaration">Character encoding declaration</a>
     </td><td> "<code>utf-8</code>"
    </td></tr><tr><th> <code>checked</code>
     </th><td> <code id="attributes-3:attr-input-checked"><a href="#attr-input-checked">input</a></code>
     </td><td> Whether the control is checked
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-6">Boolean attribute</a>
    </td></tr><tr><th> <code>cite</code>
     </th><td> <code id="attributes-3:attr-blockquote-cite"><a href="#attr-blockquote-cite">blockquote</a></code>;
          <code id="attributes-3:attr-mod-cite"><a href="#attr-mod-cite">del</a></code>;
          <code id="attributes-3:attr-mod-cite-2"><a href="#attr-mod-cite">ins</a></code>;
          <code id="attributes-3:attr-q-cite"><a href="#attr-q-cite">q</a></code>
     </td><td> Link to the source of the quotation or more information about the edit
     </td><td> <a href="#valid-url-potentially-surrounded-by-spaces" id="attributes-3:valid-url-potentially-surrounded-by-spaces">Valid URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>class</code>
     </th><td> <a href="#classes" id="attributes-3:classes">HTML elements</a>
     </td><td> Classes to which the element belongs
     </td><td> <a href="#set-of-space-separated-tokens" id="attributes-3:set-of-space-separated-tokens">Set of space-separated tokens</a>
    </td></tr><tr><th> <code>closedby</code>
     </th><td> <code id="attributes-3:attr-dialog-closedby"><a href="#attr-dialog-closedby">dialog</a></code>
     </td><td> Which user actions will close the dialog
     </td><td> "<code id="attributes-3:attr-dialog-closedby-any"><a href="#attr-dialog-closedby-any">any</a></code>";
          "<code id="attributes-3:attr-dialog-closedby-closerequest"><a href="#attr-dialog-closedby-closerequest">closerequest</a></code>";
          "<code id="attributes-3:attr-dialog-closedby-none"><a href="#attr-dialog-closedby-none">none</a></code>";
    </td></tr><tr><th> <code>color</code>
     </th><td> <code id="attributes-3:attr-link-color"><a href="#attr-link-color">link</a></code>
     </td><td> Color to use when customizing a site's icon (for <code id="attributes-3:attr-link-rel-5"><a href="#attr-link-rel">rel</a></code>="<code>mask-icon</code>")
     </td><td> CSS <a id="attributes-3:color" href="https://drafts.csswg.org/css-color/#typedef-color" data-x-internal="color">&lt;color&gt;</a>
    </td></tr><tr><th> <code>colorspace</code>
     </th><td> <code id="attributes-3:attr-input-colorspace"><a href="#attr-input-colorspace">input</a></code>
     </td><td> The color space of the serialized color
     </td><td> "<code id="attributes-3:attr-input-colorspace-limited-srgb"><a href="#attr-input-colorspace-limited-srgb">limited-srgb</a></code>";
          "<code id="attributes-3:attr-input-colorspace-display-p3"><a href="#attr-input-colorspace-display-p3">display-p3</a></code>"
    </td></tr><tr><th> <code>cols</code>
     </th><td> <code id="attributes-3:attr-textarea-cols"><a href="#attr-textarea-cols">textarea</a></code>
     </td><td> Maximum number of characters per line
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer">Valid non-negative integer</a> greater than zero
    </td></tr><tr><th> <code>colspan</code>
     </th><td> <code id="attributes-3:attr-tdth-colspan"><a href="#attr-tdth-colspan">td</a></code>;
          <code id="attributes-3:attr-tdth-colspan-2"><a href="#attr-tdth-colspan">th</a></code>
     </td><td> Number of columns that the cell is to span
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-2">Valid non-negative integer</a> greater than zero
    </td></tr><tr><th> <code>command</code>
     </th><td> <code id="attributes-3:attr-button-command"><a href="#attr-button-command">button</a></code>
     </td><td> Indicates to the targeted element which action to take.
     </td><td> "<code id="attributes-3:attr-button-command-toggle-popover"><a href="#attr-button-command-toggle-popover">toggle-popover</a></code>";
          "<code id="attributes-3:attr-button-command-show-popover"><a href="#attr-button-command-show-popover">show-popover</a></code>";
          "<code id="attributes-3:attr-button-command-hide-popover"><a href="#attr-button-command-hide-popover">hide-popover</a></code>";
          "<code id="attributes-3:attr-button-command-close"><a href="#attr-button-command-close">close</a></code>";
          "<code id="attributes-3:attr-button-command-request-close"><a href="#attr-button-command-request-close">request-close</a></code>";
          "<code id="attributes-3:attr-button-command-show-modal"><a href="#attr-button-command-show-modal">show-modal</a></code>";
          a <a href="#attr-button-command-custom" id="attributes-3:attr-button-command-custom">custom command keyword</a>
    </td></tr><tr><th> <code>commandfor</code>
     </th><td> <code id="attributes-3:attr-button-commandfor"><a href="#attr-button-commandfor">button</a></code>
     </td><td> Targets another element to be invoked.
     </td><td> <a href="https://dom.spec.whatwg.org/#concept-id" id="attributes-3:concept-id" data-x-internal="concept-id">ID</a>*
    </td></tr><tr><th> <code>content</code>
     </th><td> <code id="attributes-3:attr-meta-content"><a href="#attr-meta-content">meta</a></code>
     </td><td> Value of the element
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>contenteditable</code>
     </th><td> <a href="#attr-contenteditable" id="attributes-3:attr-contenteditable">HTML elements</a>
     </td><td> Whether the element is editable
     </td><td> "<code>true</code>"; "<code>plaintext-only</code>";
          "<code>false</code>"
    </td></tr><tr><th> <code>controls</code>
     </th><td> <code id="attributes-3:attr-media-controls"><a href="#attr-media-controls">audio</a></code>;
          <code id="attributes-3:attr-media-controls-2"><a href="#attr-media-controls">video</a></code>
     </td><td> Show user agent controls
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-7">Boolean attribute</a>
    </td></tr><tr><th> <code>coords</code>
     </th><td> <code id="attributes-3:attr-area-coords"><a href="#attr-area-coords">area</a></code>
     </td><td> Coordinates for the shape to be created in an <a href="#image-map" id="attributes-3:image-map">image map</a>
     </td><td> <a href="#valid-list-of-floating-point-numbers" id="attributes-3:valid-list-of-floating-point-numbers">Valid list of floating-point numbers</a>*
    </td></tr><tr><th> <code>crossorigin</code>
     </th><td> <code id="attributes-3:attr-media-crossorigin"><a href="#attr-media-crossorigin">audio</a></code>;
          <code id="attributes-3:attr-img-crossorigin"><a href="#attr-img-crossorigin">img</a></code>;
          <code id="attributes-3:attr-link-crossorigin"><a href="#attr-link-crossorigin">link</a></code>;
          <code id="attributes-3:attr-script-crossorigin"><a href="#attr-script-crossorigin">script</a></code>;
          <code id="attributes-3:attr-media-crossorigin-2"><a href="#attr-media-crossorigin">video</a></code>
     </td><td> How the element handles crossorigin requests
     </td><td> "<code id="attributes-3:attr-crossorigin-anonymous-keyword"><a href="#attr-crossorigin-anonymous-keyword">anonymous</a></code>"; "<code id="attributes-3:attr-crossorigin-use-credentials-keyword"><a href="#attr-crossorigin-use-credentials-keyword">use-credentials</a></code>"
    </td></tr><tr><th> <code>data</code>
     </th><td> <code id="attributes-3:attr-object-data"><a href="#attr-object-data">object</a></code>
     </td><td> Address of the resource
     </td><td> <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="attributes-3:valid-non-empty-url-potentially-surrounded-by-spaces-2">Valid non-empty URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>datetime</code>
     </th><td> <code id="attributes-3:attr-mod-datetime"><a href="#attr-mod-datetime">del</a></code>;
          <code id="attributes-3:attr-mod-datetime-2"><a href="#attr-mod-datetime">ins</a></code>
     </td><td> Date and (optionally) time of the change
     </td><td> <a href="#valid-date-string-with-optional-time" id="attributes-3:valid-date-string-with-optional-time">Valid date string with optional time</a>
    </td></tr><tr><th> <code>datetime</code>
     </th><td> <code id="attributes-3:attr-time-datetime"><a href="#attr-time-datetime">time</a></code>
     </td><td> Machine-readable value
     </td><td> <a href="#valid-month-string" id="attributes-3:valid-month-string">Valid month string</a>,
          <a href="#valid-date-string" id="attributes-3:valid-date-string">valid date string</a>,
          <a href="#valid-yearless-date-string" id="attributes-3:valid-yearless-date-string">valid yearless date string</a>,
          <a href="#valid-time-string" id="attributes-3:valid-time-string">valid time string</a>,
          <a href="#valid-local-date-and-time-string" id="attributes-3:valid-local-date-and-time-string">valid local date and time string</a>,
          <a href="#valid-time-zone-offset-string" id="attributes-3:valid-time-zone-offset-string">valid time-zone offset string</a>,
          <a href="#valid-global-date-and-time-string" id="attributes-3:valid-global-date-and-time-string">valid global date and time string</a>,
          <a href="#valid-week-string" id="attributes-3:valid-week-string">valid week string</a>,
          <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-3">valid non-negative integer</a>, or
          <a href="#valid-duration-string" id="attributes-3:valid-duration-string">valid duration string</a>
    </td></tr><tr><th> <code>decoding</code>
     </th><td> <code id="attributes-3:attr-img-decoding"><a href="#attr-img-decoding">img</a></code>
     </td><td> Decoding hint to use when processing this image for presentation
     </td><td> "<code id="attributes-3:attr-img-decoding-sync"><a href="#attr-img-decoding-sync">sync</a></code>";
          "<code id="attributes-3:attr-img-decoding-async"><a href="#attr-img-decoding-async">async</a></code>";
          "<code id="attributes-3:attr-img-decoding-auto"><a href="#attr-img-decoding-auto">auto</a></code>"
    </td></tr><tr><th> <code>default</code>
     </th><td> <code id="attributes-3:attr-track-default"><a href="#attr-track-default">track</a></code>
     </td><td> Enable the track if no other <a href="#text-track" id="attributes-3:text-track">text track</a> is more suitable
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-8">Boolean attribute</a>
    </td></tr><tr><th> <code>defer</code>
     </th><td> <code id="attributes-3:attr-script-defer"><a href="#attr-script-defer">script</a></code>
     </td><td> Defer script execution
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-9">Boolean attribute</a>
    </td></tr><tr><th> <code>dir</code>
     </th><td> <a href="#attr-dir" id="attributes-3:attr-dir">HTML elements</a>
     </td><td> <a href="#the-directionality" id="attributes-3:the-directionality">The text directionality</a> of the element
     </td><td> "<code id="attributes-3:attr-dir-ltr"><a href="#attr-dir-ltr">ltr</a></code>"; "<code id="attributes-3:attr-dir-rtl"><a href="#attr-dir-rtl">rtl</a></code>"; "<code id="attributes-3:attr-dir-auto"><a href="#attr-dir-auto">auto</a></code>"
    </td></tr><tr><th> <code>dir</code>
     </th><td> <code id="attributes-3:the-bdo-element"><a href="#the-bdo-element">bdo</a></code>
     </td><td> <a href="#the-directionality" id="attributes-3:the-directionality-2">The text directionality</a> of the element
     </td><td> "<code id="attributes-3:attr-dir-ltr-2"><a href="#attr-dir-ltr">ltr</a></code>"; "<code id="attributes-3:attr-dir-rtl-2"><a href="#attr-dir-rtl">rtl</a></code>"
    </td></tr><tr><th> <code>dirname</code>
     </th><td> <code id="attributes-3:attr-fe-dirname"><a href="#attr-fe-dirname">input</a></code>;
          <code id="attributes-3:attr-fe-dirname-2"><a href="#attr-fe-dirname">textarea</a></code>
     </td><td> Name of form control to use for sending the element's <a href="#the-directionality" id="attributes-3:the-directionality-3">directionality</a> in <a href="#form-submission-2" id="attributes-3:form-submission-2-3">form submission</a>
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>disabled</code>
     </th><td> <code id="attributes-3:attr-fe-disabled"><a href="#attr-fe-disabled">button</a></code>;
          <code id="attributes-3:attr-fe-disabled-2"><a href="#attr-fe-disabled">input</a></code>;
          <code id="attributes-3:attr-optgroup-disabled"><a href="#attr-optgroup-disabled">optgroup</a></code>;
          <code id="attributes-3:attr-option-disabled"><a href="#attr-option-disabled">option</a></code>;
          <code id="attributes-3:attr-fe-disabled-3"><a href="#attr-fe-disabled">select</a></code>;
          <code id="attributes-3:attr-fe-disabled-4"><a href="#attr-fe-disabled">textarea</a></code>;
          <a href="#attr-fe-disabled" id="attributes-3:attr-fe-disabled-5">form-associated custom elements</a>
     </td><td> Whether the form control is disabled
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-10">Boolean attribute</a>
    </td></tr><tr><th> <code>disabled</code>
     </th><td> <code id="attributes-3:attr-fieldset-disabled"><a href="#attr-fieldset-disabled">fieldset</a></code>
     </td><td> Whether the descendant form controls, except any inside <code id="attributes-3:the-legend-element"><a href="#the-legend-element">legend</a></code>, are disabled
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-11">Boolean attribute</a>
    </td></tr><tr><th> <code>disabled</code>
     </th><td> <code id="attributes-3:attr-link-disabled"><a href="#attr-link-disabled">link</a></code>
     </td><td> Whether the link is disabled
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-12">Boolean attribute</a>
    </td></tr><tr><th> <code>download</code>
     </th><td> <code id="attributes-3:attr-hyperlink-download"><a href="#attr-hyperlink-download">a</a></code>;
          <code id="attributes-3:attr-hyperlink-download-2"><a href="#attr-hyperlink-download">area</a></code>
     </td><td> Whether to download the resource instead of navigating to it, and its filename if so
     </td><td> Text
    </td></tr><tr><th> <code>draggable</code>
     </th><td> <a href="#attr-draggable" id="attributes-3:attr-draggable">HTML elements</a>
     </td><td> Whether the element is draggable
     </td><td> "<code>true</code>"; "<code>false</code>"
    </td></tr><tr><th> <code>enctype</code>
     </th><td> <code id="attributes-3:attr-fs-enctype"><a href="#attr-fs-enctype">form</a></code>
     </td><td> <a href="#entry-list" id="attributes-3:entry-list">Entry list</a> encoding type to use for <a href="#form-submission-2" id="attributes-3:form-submission-2-4">form submission</a>
     </td><td> "<code id="attributes-3:attr-fs-enctype-urlencoded"><a href="#attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</a></code>"; "<code id="attributes-3:attr-fs-enctype-formdata"><a href="#attr-fs-enctype-formdata">multipart/form-data</a></code>"; "<code id="attributes-3:attr-fs-enctype-text"><a href="#attr-fs-enctype-text">text/plain</a></code>"
    </td></tr><tr><th> <code>enterkeyhint</code>
     </th><td> <a href="#attr-enterkeyhint" id="attributes-3:attr-enterkeyhint">HTML elements</a>
     </td><td> Hint for selecting an enter key action
     </td><td> "<code id="attributes-3:attr-enterkeyhint-keyword-enter"><a href="#attr-enterkeyhint-keyword-enter">enter</a></code>";
          "<code id="attributes-3:attr-enterkeyhint-keyword-done"><a href="#attr-enterkeyhint-keyword-done">done</a></code>";
          "<code id="attributes-3:attr-enterkeyhint-keyword-go"><a href="#attr-enterkeyhint-keyword-go">go</a></code>";
          "<code id="attributes-3:attr-enterkeyhint-keyword-next"><a href="#attr-enterkeyhint-keyword-next">next</a></code>";
          "<code id="attributes-3:attr-enterkeyhint-keyword-previous"><a href="#attr-enterkeyhint-keyword-previous">previous</a></code>";
          "<code id="attributes-3:attr-enterkeyhint-keyword-search"><a href="#attr-enterkeyhint-keyword-search">search</a></code>";
          "<code id="attributes-3:attr-enterkeyhint-keyword-send"><a href="#attr-enterkeyhint-keyword-send">send</a></code>"
    </td></tr><tr><th> <code>fetchpriority</code>
     </th><td> <code id="attributes-3:attr-img-fetchpriority"><a href="#attr-img-fetchpriority">img</a></code>;
          <code id="attributes-3:attr-link-fetchpriority"><a href="#attr-link-fetchpriority">link</a></code>;
          <code id="attributes-3:attr-script-fetchpriority"><a href="#attr-script-fetchpriority">script</a></code>
     </td><td> Sets the <a href="https://fetch.spec.whatwg.org/#request-priority" id="attributes-3:concept-request-priority" data-x-internal="concept-request-priority">priority</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="attributes-3:concept-fetch" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </td><td> "<code id="attributes-3:attr-fetchpriority-auto"><a href="#attr-fetchpriority-auto">auto</a></code>";
          "<code id="attributes-3:attr-fetchpriority-high"><a href="#attr-fetchpriority-high">high</a></code>";
          "<code id="attributes-3:attr-fetchpriority-low"><a href="#attr-fetchpriority-low">low</a></code>"
    </td></tr><tr><th> <code>for</code>
     </th><td> <code id="attributes-3:attr-label-for"><a href="#attr-label-for">label</a></code>
     </td><td> Associate the label with form control
     </td><td> <a href="https://dom.spec.whatwg.org/#concept-id" id="attributes-3:concept-id-2" data-x-internal="concept-id">ID</a>*
    </td></tr><tr><th> <code>for</code>
     </th><td> <code id="attributes-3:attr-output-for"><a href="#attr-output-for">output</a></code>
     </td><td> Specifies controls from which the output was calculated
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens-2">Unordered set of unique space-separated tokens</a> consisting of IDs*
    </td></tr><tr><th> <code>form</code>
     </th><td> <code id="attributes-3:attr-fae-form"><a href="#attr-fae-form">button</a></code>;
          <code id="attributes-3:attr-fae-form-2"><a href="#attr-fae-form">fieldset</a></code>;
          <code id="attributes-3:attr-fae-form-3"><a href="#attr-fae-form">input</a></code>;
          <code id="attributes-3:attr-fae-form-4"><a href="#attr-fae-form">object</a></code>;
          <code id="attributes-3:attr-fae-form-5"><a href="#attr-fae-form">output</a></code>;
          <code id="attributes-3:attr-fae-form-6"><a href="#attr-fae-form">select</a></code>;
          <code id="attributes-3:attr-fae-form-7"><a href="#attr-fae-form">textarea</a></code>;
          <a href="#attr-fae-form" id="attributes-3:attr-fae-form-8">form-associated custom elements</a>
     </td><td> Associates the element with a <code id="attributes-3:the-form-element"><a href="#the-form-element">form</a></code> element
     </td><td> <a href="https://dom.spec.whatwg.org/#concept-id" id="attributes-3:concept-id-3" data-x-internal="concept-id">ID</a>*
    </td></tr><tr><th> <code>formaction</code>
     </th><td> <code id="attributes-3:attr-fs-formaction"><a href="#attr-fs-formaction">button</a></code>;
          <code id="attributes-3:attr-fs-formaction-2"><a href="#attr-fs-formaction">input</a></code>
     </td><td> <a id="attributes-3:url-2" href="https://url.spec.whatwg.org/#concept-url" data-x-internal="url">URL</a> to use for <a href="#form-submission-2" id="attributes-3:form-submission-2-5">form submission</a>
     </td><td> <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="attributes-3:valid-non-empty-url-potentially-surrounded-by-spaces-3">Valid non-empty URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>formenctype</code>
     </th><td> <code id="attributes-3:attr-fs-formenctype"><a href="#attr-fs-formenctype">button</a></code>;
          <code id="attributes-3:attr-fs-formenctype-2"><a href="#attr-fs-formenctype">input</a></code>
     </td><td> <a href="#entry-list" id="attributes-3:entry-list-2">Entry list</a> encoding type to use for <a href="#form-submission-2" id="attributes-3:form-submission-2-6">form submission</a>
     </td><td> "<code id="attributes-3:attr-fs-enctype-urlencoded-2"><a href="#attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</a></code>"; "<code id="attributes-3:attr-fs-enctype-formdata-2"><a href="#attr-fs-enctype-formdata">multipart/form-data</a></code>"; "<code id="attributes-3:attr-fs-enctype-text-2"><a href="#attr-fs-enctype-text">text/plain</a></code>"
    </td></tr><tr><th> <code>formmethod</code>
     </th><td> <code id="attributes-3:attr-fs-formmethod"><a href="#attr-fs-formmethod">button</a></code>;
          <code id="attributes-3:attr-fs-formmethod-2"><a href="#attr-fs-formmethod">input</a></code>
     </td><td> Variant to use for <a href="#form-submission-2" id="attributes-3:form-submission-2-7">form submission</a>
     </td><td> "<code>GET</code>";
          "<code>POST</code>";
          "<code>dialog</code>"
    </td></tr><tr><th> <code>formnovalidate</code>
     </th><td> <code id="attributes-3:attr-fs-formnovalidate"><a href="#attr-fs-formnovalidate">button</a></code>;
          <code id="attributes-3:attr-fs-formnovalidate-2"><a href="#attr-fs-formnovalidate">input</a></code>
     </td><td> Bypass form control validation for <a href="#form-submission-2" id="attributes-3:form-submission-2-8">form submission</a>
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-13">Boolean attribute</a>
    </td></tr><tr><th> <code>formtarget</code>
     </th><td> <code id="attributes-3:attr-fs-formtarget"><a href="#attr-fs-formtarget">button</a></code>;
          <code id="attributes-3:attr-fs-formtarget-2"><a href="#attr-fs-formtarget">input</a></code>
     </td><td> <a href="#navigable" id="attributes-3:navigable">Navigable</a> for <a href="#form-submission-2" id="attributes-3:form-submission-2-9">form submission</a>
     </td><td> <a href="#valid-navigable-target-name-or-keyword" id="attributes-3:valid-navigable-target-name-or-keyword">Valid navigable target name or keyword</a>
    </td></tr><tr><th> <code>headers</code>
     </th><td> <code id="attributes-3:attr-tdth-headers"><a href="#attr-tdth-headers">td</a></code>;
          <code id="attributes-3:attr-tdth-headers-2"><a href="#attr-tdth-headers">th</a></code>
     </td><td> The header cells for this cell
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens-3">Unordered set of unique space-separated tokens</a> consisting of IDs*
    </td></tr><tr><th> <code>height</code>
     </th><td> <code id="attributes-3:attr-canvas-height"><a href="#attr-canvas-height">canvas</a></code>;
          <code id="attributes-3:attr-dim-height"><a href="#attr-dim-height">embed</a></code>;
          <code id="attributes-3:attr-dim-height-2"><a href="#attr-dim-height">iframe</a></code>;
          <code id="attributes-3:attr-dim-height-3"><a href="#attr-dim-height">img</a></code>;
          <code id="attributes-3:attr-dim-height-4"><a href="#attr-dim-height">input</a></code>;
          <code id="attributes-3:attr-dim-height-5"><a href="#attr-dim-height">object</a></code>;
          <code id="attributes-3:attr-dim-height-6"><a href="#attr-dim-height">source</a></code> (in <code id="attributes-3:the-picture-element"><a href="#the-picture-element">picture</a></code>);
          <code id="attributes-3:attr-dim-height-7"><a href="#attr-dim-height">video</a></code>
     </td><td> Vertical dimension
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-4">Valid non-negative integer</a>
    </td></tr><tr><th> <code>hidden</code>
     </th><td> <a href="#attr-hidden" id="attributes-3:attr-hidden">HTML elements</a>
     </td><td> Whether the element is relevant
     </td><td> "<code id="attributes-3:attr-hidden-until-found"><a href="#attr-hidden-until-found">until-found</a></code>";
          "<code id="attributes-3:attr-hidden-2"><a href="#attr-hidden">hidden</a></code>";
          the empty string
    </td></tr><tr><th> <code>high</code>
     </th><td> <code id="attributes-3:attr-meter-high"><a href="#attr-meter-high">meter</a></code>
     </td><td> Low limit of high range
     </td><td> <a href="#valid-floating-point-number" id="attributes-3:valid-floating-point-number">Valid floating-point number</a>*
    </td></tr><tr><th> <code>href</code>
     </th><td> <code id="attributes-3:attr-hyperlink-href"><a href="#attr-hyperlink-href">a</a></code>;
          <code id="attributes-3:attr-hyperlink-href-2"><a href="#attr-hyperlink-href">area</a></code>
     </td><td> Address of the <a href="#hyperlink" id="attributes-3:hyperlink">hyperlink</a>
     </td><td> <a href="#valid-url-potentially-surrounded-by-spaces" id="attributes-3:valid-url-potentially-surrounded-by-spaces-2">Valid URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>href</code>
     </th><td> <code id="attributes-3:attr-link-href"><a href="#attr-link-href">link</a></code>
     </td><td> Address of the <a href="#hyperlink" id="attributes-3:hyperlink-2">hyperlink</a>
     </td><td> <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="attributes-3:valid-non-empty-url-potentially-surrounded-by-spaces-4">Valid non-empty URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>href</code>
     </th><td> <code id="attributes-3:attr-base-href"><a href="#attr-base-href">base</a></code>
     </td><td> <a href="#document-base-url" id="attributes-3:document-base-url">Document base URL</a>
     </td><td> <a href="#valid-url-potentially-surrounded-by-spaces" id="attributes-3:valid-url-potentially-surrounded-by-spaces-3">Valid URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>hreflang</code>
     </th><td> <code id="attributes-3:attr-hyperlink-hreflang"><a href="#attr-hyperlink-hreflang">a</a></code>;
          <code id="attributes-3:attr-link-hreflang"><a href="#attr-link-hreflang">link</a></code>
     </td><td> Language of the linked resource
     </td><td> Valid BCP 47 language tag
    </td></tr><tr><th> <code>http-equiv</code>
     </th><td> <code id="attributes-3:attr-meta-http-equiv"><a href="#attr-meta-http-equiv">meta</a></code>
     </td><td> Pragma directive
     </td><td> "<code id="attributes-3:attr-meta-http-equiv-keyword-content-type"><a href="#attr-meta-http-equiv-keyword-content-type">content-type</a></code>";
          "<code id="attributes-3:attr-meta-http-equiv-keyword-default-style"><a href="#attr-meta-http-equiv-keyword-default-style">default-style</a></code>";
          "<code id="attributes-3:attr-meta-http-equiv-keyword-refresh"><a href="#attr-meta-http-equiv-keyword-refresh">refresh</a></code>";
          "<code id="attributes-3:attr-meta-http-equiv-keyword-x-ua-compatible"><a href="#attr-meta-http-equiv-keyword-x-ua-compatible">x-ua-compatible</a></code>";
          "<code id="attributes-3:attr-meta-http-equiv-keyword-content-security-policy"><a href="#attr-meta-http-equiv-keyword-content-security-policy">content-security-policy</a></code>"
    </td></tr><tr><th> <code>id</code>
     </th><td> <a href="#the-id-attribute" id="attributes-3:the-id-attribute">HTML elements</a>
     </td><td> The element's <a href="https://dom.spec.whatwg.org/#concept-id" id="attributes-3:concept-id-4" data-x-internal="concept-id">ID</a>
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>imagesizes</code>
     </th><td> <code id="attributes-3:attr-link-imagesizes"><a href="#attr-link-imagesizes">link</a></code>
     </td><td> Image sizes for different page layouts (for <code id="attributes-3:attr-link-rel-6"><a href="#attr-link-rel">rel</a></code>="<code id="attributes-3:link-type-preload-3"><a href="#link-type-preload">preload</a></code>")
     </td><td> <a href="#valid-source-size-list" id="attributes-3:valid-source-size-list">Valid source size list</a>
    </td></tr><tr><th> <code>imagesrcset</code>
     </th><td> <code id="attributes-3:attr-link-imagesrcset"><a href="#attr-link-imagesrcset">link</a></code>
     </td><td> Images to use in different situations, e.g., high-resolution displays, small monitors, etc. (for <code id="attributes-3:attr-link-rel-7"><a href="#attr-link-rel">rel</a></code>="<code id="attributes-3:link-type-preload-4"><a href="#link-type-preload">preload</a></code>")
     </td><td> Comma-separated list of <a href="#image-candidate-string" id="attributes-3:image-candidate-string">image candidate strings</a>
    </td></tr><tr><th> <code>inert</code>
     </th><td> <a href="#the-inert-attribute" id="attributes-3:the-inert-attribute">HTML elements</a>
     </td><td> Whether the element is <a href="#inert" id="attributes-3:inert">inert</a>.
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-14">Boolean attribute</a>
    </td></tr><tr><th> <code>inputmode</code>
     </th><td> <a href="#attr-inputmode" id="attributes-3:attr-inputmode">HTML elements</a>
     </td><td> Hint for selecting an input modality
     </td><td> "<code id="attributes-3:attr-inputmode-keyword-none"><a href="#attr-inputmode-keyword-none">none</a></code>";
          "<code id="attributes-3:attr-inputmode-keyword-text"><a href="#attr-inputmode-keyword-text">text</a></code>";
          "<code id="attributes-3:attr-inputmode-keyword-tel"><a href="#attr-inputmode-keyword-tel">tel</a></code>";
          "<code id="attributes-3:attr-inputmode-keyword-email"><a href="#attr-inputmode-keyword-email">email</a></code>";
          "<code id="attributes-3:attr-inputmode-keyword-url"><a href="#attr-inputmode-keyword-url">url</a></code>";
          "<code id="attributes-3:attr-inputmode-keyword-numeric"><a href="#attr-inputmode-keyword-numeric">numeric</a></code>";
          "<code id="attributes-3:attr-inputmode-keyword-decimal"><a href="#attr-inputmode-keyword-decimal">decimal</a></code>";
          "<code id="attributes-3:attr-inputmode-keyword-search"><a href="#attr-inputmode-keyword-search">search</a></code>"
    </td></tr><tr><th> <code>integrity</code>
     </th><td> <code id="attributes-3:attr-link-integrity"><a href="#attr-link-integrity">link</a></code>;
          <code id="attributes-3:attr-script-integrity"><a href="#attr-script-integrity">script</a></code>
     </td><td> Integrity metadata used in <cite>Subresource Integrity</cite> checks <a href="#refsSRI">[SRI]</a>
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>is</code>
     </th><td> <a href="#attr-is" id="attributes-3:attr-is">HTML elements</a>
     </td><td> Creates a <a href="#customized-built-in-element" id="attributes-3:customized-built-in-element">customized built-in element</a>
     </td><td> <a href="#valid-custom-element-name" id="attributes-3:valid-custom-element-name">Valid custom element name</a> of a defined <a href="#customized-built-in-element" id="attributes-3:customized-built-in-element-2">customized built-in element</a>
    </td></tr><tr><th> <code>ismap</code>
     </th><td> <code id="attributes-3:attr-img-ismap"><a href="#attr-img-ismap">img</a></code>
     </td><td> Whether the image is a server-side image map
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-15">Boolean attribute</a>
    </td></tr><tr><th> <code>itemid</code>
     </th><td> <a href="#attr-itemid" id="attributes-3:attr-itemid">HTML elements</a>
     </td><td> <a href="#global-identifier" id="attributes-3:global-identifier">Global identifier</a> for a microdata item
     </td><td> <a href="#valid-url-potentially-surrounded-by-spaces" id="attributes-3:valid-url-potentially-surrounded-by-spaces-4">Valid URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>itemprop</code>
     </th><td> <a href="#names:-the-itemprop-attribute" id="attributes-3:names:-the-itemprop-attribute">HTML elements</a>
     </td><td> <a href="#property-names" id="attributes-3:property-names">Property names</a> of a microdata item
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens-4">Unordered set of unique space-separated tokens</a> consisting of <a href="https://url.spec.whatwg.org/#syntax-url-absolute" id="attributes-3:absolute-url" data-x-internal="absolute-url">valid absolute URLs</a>, <a href="#defined-property-name" id="attributes-3:defined-property-name">defined property names</a>, or text*
    </td></tr><tr><th> <code>itemref</code>
     </th><td> <a href="#attr-itemref" id="attributes-3:attr-itemref">HTML elements</a>
     </td><td> <a href="#referenced" id="attributes-3:referenced">Referenced</a> elements
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens-5">Unordered set of unique space-separated tokens</a> consisting of IDs*
    </td></tr><tr><th> <code>itemscope</code>
     </th><td> <a href="#attr-itemscope" id="attributes-3:attr-itemscope">HTML elements</a>
     </td><td> Introduces a microdata item
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-16">Boolean attribute</a>
    </td></tr><tr><th> <code>itemtype</code>
     </th><td> <a href="#attr-itemtype" id="attributes-3:attr-itemtype">HTML elements</a>
     </td><td> <a href="#item-types" id="attributes-3:item-types">Item types</a> of a microdata item
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens-6">Unordered set of unique space-separated tokens</a> consisting of <a href="https://url.spec.whatwg.org/#syntax-url-absolute" id="attributes-3:absolute-url-2" data-x-internal="absolute-url">valid absolute URLs</a>*
    </td></tr><tr><th> <code>kind</code>
     </th><td> <code id="attributes-3:attr-track-kind"><a href="#attr-track-kind">track</a></code>
     </td><td> The type of text track
     </td><td> "<code id="attributes-3:attr-track-kind-keyword-subtitles"><a href="#attr-track-kind-keyword-subtitles">subtitles</a></code>";
          "<code id="attributes-3:attr-track-kind-keyword-captions"><a href="#attr-track-kind-keyword-captions">captions</a></code>";
          "<code id="attributes-3:attr-track-kind-keyword-descriptions"><a href="#attr-track-kind-keyword-descriptions">descriptions</a></code>";
          "<code id="attributes-3:attr-track-kind-keyword-chapters"><a href="#attr-track-kind-keyword-chapters">chapters</a></code>";
          "<code id="attributes-3:attr-track-kind-keyword-metadata"><a href="#attr-track-kind-keyword-metadata">metadata</a></code>"
    </td></tr><tr><th> <code>label</code>
     </th><td> <code id="attributes-3:attr-optgroup-label"><a href="#attr-optgroup-label">optgroup</a></code>;
          <code id="attributes-3:attr-option-label"><a href="#attr-option-label">option</a></code>;
          <code id="attributes-3:attr-track-label"><a href="#attr-track-label">track</a></code>
     </td><td> User-visible label
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>lang</code>
     </th><td> <a href="#attr-lang" id="attributes-3:attr-lang">HTML elements</a>
     </td><td> <a href="#language" id="attributes-3:language">Language</a> of the element
     </td><td> Valid BCP 47 language tag or the empty string
    </td></tr><tr><th> <code>list</code>
     </th><td> <code id="attributes-3:attr-input-list"><a href="#attr-input-list">input</a></code>
     </td><td> List of autocomplete options
     </td><td> <a href="https://dom.spec.whatwg.org/#concept-id" id="attributes-3:concept-id-5" data-x-internal="concept-id">ID</a>*
    </td></tr><tr><th> <code>loading</code>
     </th><td> <code id="attributes-3:attr-iframe-loading"><a href="#attr-iframe-loading">iframe</a></code>;
          <code id="attributes-3:attr-img-loading"><a href="#attr-img-loading">img</a></code>
     </td><td> Used when determining loading deferral
     </td><td> "<code id="attributes-3:attr-loading-lazy"><a href="#attr-loading-lazy">lazy</a></code>";
          "<code id="attributes-3:attr-loading-eager"><a href="#attr-loading-eager">eager</a></code>"
    </td></tr><tr><th> <code>loop</code>
     </th><td> <code id="attributes-3:attr-media-loop"><a href="#attr-media-loop">audio</a></code>;
          <code id="attributes-3:attr-media-loop-2"><a href="#attr-media-loop">video</a></code>
     </td><td> Whether to loop the <a href="#media-resource" id="attributes-3:media-resource-2">media resource</a>
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-17">Boolean attribute</a>
    </td></tr><tr><th> <code>low</code>
     </th><td> <code id="attributes-3:attr-meter-low"><a href="#attr-meter-low">meter</a></code>
     </td><td> High limit of low range
     </td><td> <a href="#valid-floating-point-number" id="attributes-3:valid-floating-point-number-2">Valid floating-point number</a>*
    </td></tr><tr><th> <code>max</code>
     </th><td> <code id="attributes-3:attr-input-max"><a href="#attr-input-max">input</a></code>
     </td><td> Maximum value
     </td><td> Varies*
    </td></tr><tr><th> <code>max</code>
     </th><td> <code id="attributes-3:attr-meter-max"><a href="#attr-meter-max">meter</a></code>;
          <code id="attributes-3:attr-progress-max"><a href="#attr-progress-max">progress</a></code>
     </td><td> Upper bound of range
     </td><td> <a href="#valid-floating-point-number" id="attributes-3:valid-floating-point-number-3">Valid floating-point number</a>*
    </td></tr><tr><th> <code>maxlength</code>
     </th><td> <code id="attributes-3:attr-input-maxlength"><a href="#attr-input-maxlength">input</a></code>;
          <code id="attributes-3:attr-textarea-maxlength"><a href="#attr-textarea-maxlength">textarea</a></code>
     </td><td> Maximum <a id="attributes-3:length" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of value
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-5">Valid non-negative integer</a>
    </td></tr><tr><th> <code>media</code>
     </th><td> <code id="attributes-3:attr-link-media"><a href="#attr-link-media">link</a></code>;
          <code id="attributes-3:attr-meta-media"><a href="#attr-meta-media">meta</a></code>;
          <code id="attributes-3:attr-source-media"><a href="#attr-source-media">source</a></code>;
          <code id="attributes-3:attr-style-media"><a href="#attr-style-media">style</a></code>
     </td><td> Applicable media
     </td><td> <a href="#valid-media-query-list" id="attributes-3:valid-media-query-list">Valid media query list</a>
    </td></tr><tr><th> <code>method</code>
     </th><td> <code id="attributes-3:attr-fs-method"><a href="#attr-fs-method">form</a></code>
     </td><td> Variant to use for <a href="#form-submission-2" id="attributes-3:form-submission-2-10">form submission</a>
     </td><td> "<code id="attributes-3:attr-fs-method-get-keyword"><a href="#attr-fs-method-get-keyword">GET</a></code>";
          "<code id="attributes-3:attr-fs-method-post-keyword"><a href="#attr-fs-method-post-keyword">POST</a></code>";
          "<code id="attributes-3:attr-fs-method-dialog-keyword"><a href="#attr-fs-method-dialog-keyword">dialog</a></code>"
    </td></tr><tr><th> <code>min</code>
     </th><td> <code id="attributes-3:attr-input-min"><a href="#attr-input-min">input</a></code>
     </td><td> Minimum value
     </td><td> Varies*
    </td></tr><tr><th> <code>min</code>
     </th><td> <code id="attributes-3:attr-meter-min"><a href="#attr-meter-min">meter</a></code>
     </td><td> Lower bound of range
     </td><td> <a href="#valid-floating-point-number" id="attributes-3:valid-floating-point-number-4">Valid floating-point number</a>*
    </td></tr><tr><th> <code>minlength</code>
     </th><td> <code id="attributes-3:attr-input-minlength"><a href="#attr-input-minlength">input</a></code>;
          <code id="attributes-3:attr-textarea-minlength"><a href="#attr-textarea-minlength">textarea</a></code>
     </td><td> Minimum <a id="attributes-3:length-2" href="https://infra.spec.whatwg.org/#string-length" data-x-internal="length">length</a> of value
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-6">Valid non-negative integer</a>
    </td></tr><tr><th> <code>multiple</code>
     </th><td> <code id="attributes-3:attr-input-multiple"><a href="#attr-input-multiple">input</a></code>;
          <code id="attributes-3:attr-select-multiple"><a href="#attr-select-multiple">select</a></code>
     </td><td> Whether to allow multiple values
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-18">Boolean attribute</a>
    </td></tr><tr><th> <code>muted</code>
     </th><td> <code id="attributes-3:attr-media-muted"><a href="#attr-media-muted">audio</a></code>;
          <code id="attributes-3:attr-media-muted-2"><a href="#attr-media-muted">video</a></code>
     </td><td> Whether to mute the <a href="#media-resource" id="attributes-3:media-resource-3">media resource</a> by default
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-19">Boolean attribute</a>
    </td></tr><tr><th> <code>name</code>
     </th><td> <code id="attributes-3:attr-fe-name"><a href="#attr-fe-name">button</a></code>;
          <code id="attributes-3:attr-fe-name-2"><a href="#attr-fe-name">fieldset</a></code>;
          <code id="attributes-3:attr-fe-name-3"><a href="#attr-fe-name">input</a></code>;
          <code id="attributes-3:attr-fe-name-4"><a href="#attr-fe-name">output</a></code>;
          <code id="attributes-3:attr-fe-name-5"><a href="#attr-fe-name">select</a></code>;
          <code id="attributes-3:attr-fe-name-6"><a href="#attr-fe-name">textarea</a></code>;
          <a href="#attr-fe-name" id="attributes-3:attr-fe-name-7">form-associated custom elements</a>
     </td><td> Name of the element to use for <a href="#form-submission-2" id="attributes-3:form-submission-2-11">form submission</a> and in the <code id="attributes-3:dom-form-elements"><a href="#dom-form-elements">form.elements</a></code> API 
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>name</code>
     </th><td> <code id="attributes-3:attr-details-name"><a href="#attr-details-name">details</a></code>
     </td><td> Name of group of mutually-exclusive <code id="attributes-3:the-details-element"><a href="#the-details-element">details</a></code> elements
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>name</code>
     </th><td> <code id="attributes-3:attr-form-name"><a href="#attr-form-name">form</a></code>
     </td><td> Name of form to use in the <code id="attributes-3:dom-document-forms"><a href="#dom-document-forms">document.forms</a></code> API
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>name</code>
     </th><td> <code id="attributes-3:attr-iframe-name"><a href="#attr-iframe-name">iframe</a></code>;
          <code id="attributes-3:attr-object-name"><a href="#attr-object-name">object</a></code>
     </td><td> Name of <a href="#content-navigable" id="attributes-3:content-navigable">content navigable</a>
     </td><td> <a href="#valid-navigable-target-name-or-keyword" id="attributes-3:valid-navigable-target-name-or-keyword-2">Valid navigable target name or keyword</a>
    </td></tr><tr><th> <code>name</code>
     </th><td> <code id="attributes-3:attr-map-name"><a href="#attr-map-name">map</a></code>
     </td><td> Name of <a href="#image-map" id="attributes-3:image-map-2">image map</a> to <a href="#referenced" id="attributes-3:referenced-2">reference</a> from the <code id="attributes-3:attr-hyperlink-usemap"><a href="#attr-hyperlink-usemap">usemap</a></code> attribute
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>name</code>
     </th><td> <code id="attributes-3:attr-meta-name"><a href="#attr-meta-name">meta</a></code>
     </td><td> Metadata name
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>name</code>
     </th><td> <code id="attributes-3:attr-slot-name"><a href="#attr-slot-name">slot</a></code>
     </td><td> Name of shadow tree slot
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>nomodule</code>
     </th><td> <code id="attributes-3:attr-script-nomodule"><a href="#attr-script-nomodule">script</a></code>
     </td><td> Prevents execution in user agents that support <a href="#module-script" id="attributes-3:module-script">module scripts</a>
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-20">Boolean attribute</a>
    </td></tr><tr><th> <code>nonce</code>
     </th><td> <a href="#attr-nonce" id="attributes-3:attr-nonce">HTML elements</a>
     </td><td> Cryptographic nonce used in <cite>Content Security Policy</cite> checks <a href="#refsCSP">[CSP]</a>
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>novalidate</code>
     </th><td> <code id="attributes-3:attr-fs-novalidate"><a href="#attr-fs-novalidate">form</a></code>
     </td><td> Bypass form control validation for <a href="#form-submission-2" id="attributes-3:form-submission-2-12">form submission</a>
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-21">Boolean attribute</a>
    </td></tr><tr><th> <code>open</code>
     </th><td> <code id="attributes-3:attr-details-open"><a href="#attr-details-open">details</a></code>
     </td><td> Whether the details are visible
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-22">Boolean attribute</a>
    </td></tr><tr><th> <code>open</code>
     </th><td> <code id="attributes-3:attr-dialog-open"><a href="#attr-dialog-open">dialog</a></code>
     </td><td> Whether the dialog box is showing
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-23">Boolean attribute</a>
    </td></tr><tr><th> <code>optimum</code>
     </th><td> <code id="attributes-3:attr-meter-optimum"><a href="#attr-meter-optimum">meter</a></code>
     </td><td> Optimum value in gauge
     </td><td> <a href="#valid-floating-point-number" id="attributes-3:valid-floating-point-number-5">Valid floating-point number</a>*
    </td></tr><tr><th> <code>pattern</code>
     </th><td> <code id="attributes-3:attr-input-pattern"><a href="#attr-input-pattern">input</a></code>
     </td><td> Pattern to be matched by the form control's value
     </td><td> Regular expression matching the JavaScript <i id="attributes-3:js-prod-pattern"><a data-x-internal="js-prod-pattern" href="https://tc39.es/ecma262/#prod-Pattern">Pattern</a></i> production
    </td></tr><tr><th> <code>ping</code>
     </th><td> <code id="attributes-3:ping"><a href="#ping">a</a></code>;
          <code id="attributes-3:ping-2"><a href="#ping">area</a></code>
     </td><td> <a href="https://url.spec.whatwg.org/#concept-url" id="attributes-3:url-3" data-x-internal="url">URLs</a> to ping
     </td><td> <a href="#set-of-space-separated-tokens" id="attributes-3:set-of-space-separated-tokens-2">Set of space-separated tokens</a> consisting of <a href="#valid-non-empty-url" id="attributes-3:valid-non-empty-url">valid non-empty URLs</a>
    </td></tr><tr><th> <code>placeholder</code>
     </th><td> <code id="attributes-3:attr-input-placeholder"><a href="#attr-input-placeholder">input</a></code>;
          <code id="attributes-3:attr-textarea-placeholder"><a href="#attr-textarea-placeholder">textarea</a></code>
     </td><td> User-visible label to be placed within the form control
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>playsinline</code>
     </th><td> <code id="attributes-3:attr-video-playsinline"><a href="#attr-video-playsinline">video</a></code>
     </td><td> Encourage the user agent to display video content within the element's playback area
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-24">Boolean attribute</a>
    </td></tr><tr><th> <code>popover</code>
     </th><td> <a href="#attr-popover" id="attributes-3:attr-popover">HTML elements</a>
     </td><td> Makes the element a <a href="#attr-popover" id="attributes-3:attr-popover-2">popover</a> element
     </td><td> "<code id="attributes-3:attr-popover-auto"><a href="#attr-popover-auto">auto</a></code>";
          "<code id="attributes-3:attr-popover-manual"><a href="#attr-popover-manual">manual</a></code>";
          "<code id="attributes-3:attr-popover-hint"><a href="#attr-popover-hint">hint</a></code>"
    </td></tr><tr><th> <code>popovertarget</code>
     </th><td> <code id="attributes-3:attr-popovertarget"><a href="#attr-popovertarget">button</a></code>;
          <code id="attributes-3:attr-popovertarget-2"><a href="#attr-popovertarget">input</a></code>
     </td><td> Targets a popover element to toggle, show, or hide
     </td><td> <a href="https://dom.spec.whatwg.org/#concept-id" id="attributes-3:concept-id-6" data-x-internal="concept-id">ID</a>*
    </td></tr><tr><th> <code>popovertargetaction</code>
     </th><td> <code id="attributes-3:attr-popovertargetaction"><a href="#attr-popovertargetaction">button</a></code>;
          <code id="attributes-3:attr-popovertargetaction-2"><a href="#attr-popovertargetaction">input</a></code>
     </td><td> Indicates whether a targeted popover element is to be toggled, shown, or hidden
     </td><td> "<code id="attributes-3:attr-popovertargetaction-toggle"><a href="#attr-popovertargetaction-toggle">toggle</a></code>";
          "<code id="attributes-3:attr-popovertargetaction-show"><a href="#attr-popovertargetaction-show">show</a></code>";
          "<code id="attributes-3:attr-popovertargetaction-hide"><a href="#attr-popovertargetaction-hide">hide</a></code>"
    </td></tr><tr><th> <code>poster</code>
     </th><td> <code id="attributes-3:attr-video-poster"><a href="#attr-video-poster">video</a></code>
     </td><td> Poster frame to show prior to video playback
     </td><td> <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="attributes-3:valid-non-empty-url-potentially-surrounded-by-spaces-5">Valid non-empty URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>preload</code>
     </th><td> <code id="attributes-3:attr-media-preload"><a href="#attr-media-preload">audio</a></code>;
          <code id="attributes-3:attr-media-preload-2"><a href="#attr-media-preload">video</a></code>
     </td><td> Hints how much buffering the <a href="#media-resource" id="attributes-3:media-resource-4">media resource</a> will likely need
     </td><td> "<code id="attributes-3:attr-media-preload-none"><a href="#attr-media-preload-none">none</a></code>";
          "<code id="attributes-3:attr-media-preload-metadata"><a href="#attr-media-preload-metadata">metadata</a></code>";
          "<code id="attributes-3:attr-media-preload-auto"><a href="#attr-media-preload-auto">auto</a></code>"
    </td></tr><tr><th> <code>readonly</code>
     </th><td> <code id="attributes-3:attr-input-readonly"><a href="#attr-input-readonly">input</a></code>;
          <code id="attributes-3:attr-textarea-readonly"><a href="#attr-textarea-readonly">textarea</a></code>
     </td><td> Whether to allow the value to be edited by the user
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-25">Boolean attribute</a>
    </td></tr><tr><th> <code>readonly</code>
     </th><td> <a href="#attr-face-readonly" id="attributes-3:attr-face-readonly">form-associated custom elements</a>
     </td><td> Affects <code id="attributes-3:dom-elementinternals-willvalidate"><a href="#dom-elementinternals-willvalidate">willValidate</a></code>, plus any behavior added by the custom element author
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-26">Boolean attribute</a>
    </td></tr><tr><th> <code>referrerpolicy</code>
     </th><td> <code id="attributes-3:attr-hyperlink-referrerpolicy"><a href="#attr-hyperlink-referrerpolicy">a</a></code>;
          <code id="attributes-3:attr-hyperlink-referrerpolicy-2"><a href="#attr-hyperlink-referrerpolicy">area</a></code>;
          <code id="attributes-3:attr-iframe-referrerpolicy"><a href="#attr-iframe-referrerpolicy">iframe</a></code>;
          <code id="attributes-3:attr-img-referrerpolicy"><a href="#attr-img-referrerpolicy">img</a></code>;
          <code id="attributes-3:attr-link-referrerpolicy"><a href="#attr-link-referrerpolicy">link</a></code>;
          <code id="attributes-3:attr-script-referrerpolicy"><a href="#attr-script-referrerpolicy">script</a></code>
     </td><td> <a id="attributes-3:referrer-policy" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">Referrer policy</a> for <a href="https://fetch.spec.whatwg.org/#concept-fetch" id="attributes-3:concept-fetch-2" data-x-internal="concept-fetch">fetches</a> initiated by the element
     </td><td> <a id="attributes-3:referrer-policy-2" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" data-x-internal="referrer-policy">Referrer policy</a>
    </td></tr><tr><th> <code>rel</code>
     </th><td> <code id="attributes-3:attr-hyperlink-rel"><a href="#attr-hyperlink-rel">a</a></code>;
          <code id="attributes-3:attr-hyperlink-rel-2"><a href="#attr-hyperlink-rel">area</a></code>
     </td><td> Relationship between the location in the document containing the <a href="#hyperlink" id="attributes-3:hyperlink-3">hyperlink</a> and the destination resource
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens-7">Unordered set of unique space-separated tokens</a>*
    </td></tr><tr><th> <code>rel</code>
     </th><td> <code id="attributes-3:attr-link-rel-8"><a href="#attr-link-rel">link</a></code>
     </td><td> Relationship between the document containing the <a href="#hyperlink" id="attributes-3:hyperlink-4">hyperlink</a> and the destination resource
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens-8">Unordered set of unique space-separated tokens</a>*
    </td></tr><tr><th> <code>required</code>
     </th><td> <code id="attributes-3:attr-input-required"><a href="#attr-input-required">input</a></code>;
          <code id="attributes-3:attr-select-required"><a href="#attr-select-required">select</a></code>;
          <code id="attributes-3:attr-textarea-required"><a href="#attr-textarea-required">textarea</a></code>
     </td><td> Whether the control is required for <a href="#form-submission-2" id="attributes-3:form-submission-2-13">form submission</a>
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-27">Boolean attribute</a>
    </td></tr><tr><th> <code>reversed</code>
     </th><td> <code id="attributes-3:attr-ol-reversed"><a href="#attr-ol-reversed">ol</a></code>
     </td><td> Number the list backwards
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-28">Boolean attribute</a>
    </td></tr><tr><th> <code>rows</code>
     </th><td> <code id="attributes-3:attr-textarea-rows"><a href="#attr-textarea-rows">textarea</a></code>
     </td><td> Number of lines to show
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-7">Valid non-negative integer</a> greater than zero
    </td></tr><tr><th> <code>rowspan</code>
     </th><td> <code id="attributes-3:attr-tdth-rowspan"><a href="#attr-tdth-rowspan">td</a></code>;
          <code id="attributes-3:attr-tdth-rowspan-2"><a href="#attr-tdth-rowspan">th</a></code>
     </td><td> Number of rows that the cell is to span
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-8">Valid non-negative integer</a>
    </td></tr><tr><th> <code>sandbox</code>
     </th><td> <code id="attributes-3:attr-iframe-sandbox"><a href="#attr-iframe-sandbox">iframe</a></code>
     </td><td> Security rules for nested content
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens-9">Unordered set of unique space-separated tokens</a>, <a id="attributes-3:ascii-case-insensitive-2" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>, consisting of
      <ul class="brief"><li>"<code id="attributes-3:attr-iframe-sandbox-allow-downloads"><a href="#attr-iframe-sandbox-allow-downloads">allow-downloads</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-forms"><a href="#attr-iframe-sandbox-allow-forms">allow-forms</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-modals"><a href="#attr-iframe-sandbox-allow-modals">allow-modals</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-orientation-lock"><a href="#attr-iframe-sandbox-allow-orientation-lock">allow-orientation-lock</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-pointer-lock"><a href="#attr-iframe-sandbox-allow-pointer-lock">allow-pointer-lock</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-popups"><a href="#attr-iframe-sandbox-allow-popups">allow-popups</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-popups-to-escape-sandbox"><a href="#attr-iframe-sandbox-allow-popups-to-escape-sandbox">allow-popups-to-escape-sandbox</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-presentation"><a href="#attr-iframe-sandbox-allow-presentation">allow-presentation</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-scripts"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-top-navigation"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-top-navigation-by-user-activation"><a href="#attr-iframe-sandbox-allow-top-navigation-by-user-activation">allow-top-navigation-by-user-activation</a></code>"</li><li>"<code id="attributes-3:attr-iframe-sandbox-allow-top-navigation-to-custom-protocols"><a href="#attr-iframe-sandbox-allow-top-navigation-to-custom-protocols">allow-top-navigation-to-custom-protocols</a></code>"</li></ul>
    </td></tr><tr><th> <code>scope</code>
     </th><td> <code id="attributes-3:attr-th-scope"><a href="#attr-th-scope">th</a></code>
     </td><td> Specifies which cells the header cell applies to
     </td><td> "<code id="attributes-3:attr-th-scope-row"><a href="#attr-th-scope-row">row</a></code>";
          "<code id="attributes-3:attr-th-scope-col"><a href="#attr-th-scope-col">col</a></code>";
          "<code id="attributes-3:attr-th-scope-rowgroup"><a href="#attr-th-scope-rowgroup">rowgroup</a></code>";
          "<code id="attributes-3:attr-th-scope-colgroup"><a href="#attr-th-scope-colgroup">colgroup</a></code>"
    </td></tr><tr><th> <code>selected</code>
     </th><td> <code id="attributes-3:attr-option-selected"><a href="#attr-option-selected">option</a></code>
     </td><td> Whether the option is selected by default
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-29">Boolean attribute</a>
    </td></tr><tr><th> <code>shadowrootclonable</code>
     </th><td> <code id="attributes-3:attr-template-shadowrootclonable"><a href="#attr-template-shadowrootclonable">template</a></code>
     </td><td> Sets <a id="attributes-3:clonable" href="https://dom.spec.whatwg.org/#shadowroot-clonable" data-x-internal="clonable">clonable</a> on a declarative shadow root
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-30">Boolean attribute</a>
    </td></tr><tr><th> <code>shadowrootcustomelementregistry</code>
     </th><td> <code id="attributes-3:attr-template-shadowrootcustomelementregistry"><a href="#attr-template-shadowrootcustomelementregistry">template</a></code>
     </td><td> Enables declarative shadow roots to indicate they will use a custom element registry
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-31">Boolean attribute</a>
    </td></tr><tr><th> <code>shadowrootdelegatesfocus</code>
     </th><td> <code id="attributes-3:attr-template-shadowrootdelegatesfocus"><a href="#attr-template-shadowrootdelegatesfocus">template</a></code>
     </td><td> Sets <a id="attributes-3:delegates-focus" href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus" data-x-internal="delegates-focus">delegates focus</a> on a declarative shadow root
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-32">Boolean attribute</a>
    </td></tr><tr><th> <code>shadowrootmode</code>
     </th><td> <code id="attributes-3:attr-template-shadowrootmode"><a href="#attr-template-shadowrootmode">template</a></code>
     </td><td> Enables streaming declarative shadow roots
     </td><td> "<code>open</code>";
          "<code>closed</code>"
    </td></tr><tr><th> <code>shadowrootserializable</code>
     </th><td> <code id="attributes-3:attr-template-shadowrootserializable"><a href="#attr-template-shadowrootserializable">template</a></code>
     </td><td> Sets <a href="https://dom.spec.whatwg.org/#shadowroot-serializable" id="attributes-3:shadow-serializable" data-x-internal="shadow-serializable">serializable</a> on a declarative shadow root
     </td><td> <a href="#boolean-attribute" id="attributes-3:boolean-attribute-33">Boolean attribute</a>
    </td></tr><tr><th> <code>shape</code>
     </th><td> <code id="attributes-3:attr-area-shape"><a href="#attr-area-shape">area</a></code>
     </td><td> The kind of shape to be created in an <a href="#image-map" id="attributes-3:image-map-3">image map</a>
     </td><td> "<code id="attributes-3:attr-area-shape-keyword-circle"><a href="#attr-area-shape-keyword-circle">circle</a></code>";
          "<code id="attributes-3:attr-area-shape-keyword-default"><a href="#attr-area-shape-keyword-default">default</a></code>";
          "<code id="attributes-3:attr-area-shape-keyword-poly"><a href="#attr-area-shape-keyword-poly">poly</a></code>";
          "<code id="attributes-3:attr-area-shape-keyword-rect"><a href="#attr-area-shape-keyword-rect">rect</a></code>"
    </td></tr><tr><th> <code>size</code>
     </th><td> <code id="attributes-3:attr-input-size"><a href="#attr-input-size">input</a></code>;
          <code id="attributes-3:attr-select-size"><a href="#attr-select-size">select</a></code>
     </td><td> Size of the control
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-9">Valid non-negative integer</a> greater than zero
    </td></tr><tr><th> <code>sizes</code>
     </th><td> <code id="attributes-3:attr-link-sizes"><a href="#attr-link-sizes">link</a></code>
     </td><td> Sizes of the icons (for <code id="attributes-3:attr-link-rel-9"><a href="#attr-link-rel">rel</a></code>="<code id="attributes-3:rel-icon"><a href="#rel-icon">icon</a></code>")
     </td><td> <a href="#unordered-set-of-unique-space-separated-tokens" id="attributes-3:unordered-set-of-unique-space-separated-tokens-10">Unordered set of unique space-separated tokens</a>, <a id="attributes-3:ascii-case-insensitive-3" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" data-x-internal="ascii-case-insensitive">ASCII case-insensitive</a>, consisting of sizes*
    </td></tr><tr><th> <code>sizes</code>
     </th><td> <code id="attributes-3:attr-img-sizes"><a href="#attr-img-sizes">img</a></code>;
          <code id="attributes-3:attr-source-sizes"><a href="#attr-source-sizes">source</a></code>
     </td><td> Image sizes for different page layouts
     </td><td> <a href="#valid-source-size-list" id="attributes-3:valid-source-size-list-2">Valid source size list</a>
    </td></tr><tr><th> <code>slot</code>
     </th><td> <a href="#the-id-attribute" id="attributes-3:the-id-attribute-2">HTML elements</a>
     </td><td> The element's desired slot
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>span</code>
     </th><td> <code id="attributes-3:attr-col-span"><a href="#attr-col-span">col</a></code>;
          <code id="attributes-3:attr-colgroup-span"><a href="#attr-colgroup-span">colgroup</a></code>
     </td><td> Number of columns spanned by the element
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-10">Valid non-negative integer</a> greater than zero
    </td></tr><tr><th> <code>spellcheck</code>
     </th><td> <a href="#attr-spellcheck" id="attributes-3:attr-spellcheck">HTML elements</a>
     </td><td> Whether the element is to have its spelling and grammar checked
     </td><td> "<code id="attributes-3:attr-spellcheck-true"><a href="#attr-spellcheck-true">true</a></code>";
          "<code id="attributes-3:attr-spellcheck-false"><a href="#attr-spellcheck-false">false</a></code>";
          the empty string
    </td></tr><tr><th> <code>src</code>
     </th><td> <code id="attributes-3:attr-media-src"><a href="#attr-media-src">audio</a></code>;
          <code id="attributes-3:attr-embed-src"><a href="#attr-embed-src">embed</a></code>;
          <code id="attributes-3:attr-iframe-src"><a href="#attr-iframe-src">iframe</a></code>;
          <code id="attributes-3:attr-img-src"><a href="#attr-img-src">img</a></code>;
          <code id="attributes-3:attr-input-src"><a href="#attr-input-src">input</a></code>;
          <code id="attributes-3:attr-script-src"><a href="#attr-script-src">script</a></code>;
          <code id="attributes-3:attr-source-src"><a href="#attr-source-src">source</a></code> (in <code id="attributes-3:the-video-element"><a href="#the-video-element">video</a></code> or <code id="attributes-3:the-audio-element"><a href="#the-audio-element">audio</a></code>);
          <code id="attributes-3:attr-track-src"><a href="#attr-track-src">track</a></code>;
          <code id="attributes-3:attr-media-src-2"><a href="#attr-media-src">video</a></code>
     </td><td> Address of the resource
     </td><td> <a href="#valid-non-empty-url-potentially-surrounded-by-spaces" id="attributes-3:valid-non-empty-url-potentially-surrounded-by-spaces-6">Valid non-empty URL potentially surrounded by spaces</a>
    </td></tr><tr><th> <code>srcdoc</code>
     </th><td> <code id="attributes-3:attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">iframe</a></code>
     </td><td> A document to render in the <code id="attributes-3:the-iframe-element-3"><a href="#the-iframe-element">iframe</a></code>
     </td><td> The source of <a href="#an-iframe-srcdoc-document" id="attributes-3:an-iframe-srcdoc-document">an <code>iframe</code> <code>srcdoc</code> document</a>*
    </td></tr><tr><th> <code>srclang</code>
     </th><td> <code id="attributes-3:attr-track-srclang"><a href="#attr-track-srclang">track</a></code>
     </td><td> Language of the text track
     </td><td> Valid BCP 47 language tag
    </td></tr><tr><th> <code>srcset</code>
     </th><td> <code id="attributes-3:attr-img-srcset"><a href="#attr-img-srcset">img</a></code>;
          <code id="attributes-3:attr-source-srcset"><a href="#attr-source-srcset">source</a></code>
     </td><td> Images to use in different situations, e.g., high-resolution displays, small monitors, etc.
     </td><td> Comma-separated list of <a href="#image-candidate-string" id="attributes-3:image-candidate-string-2">image candidate strings</a>
    </td></tr><tr><th> <code>start</code>
     </th><td> <code id="attributes-3:attr-ol-start"><a href="#attr-ol-start">ol</a></code>
     </td><td> <a href="#concept-ol-start" id="attributes-3:concept-ol-start">Starting value</a> of the list
     </td><td> <a href="#valid-integer" id="attributes-3:valid-integer">Valid integer</a>
    </td></tr><tr><th> <code>step</code>
     </th><td> <code id="attributes-3:attr-input-step"><a href="#attr-input-step">input</a></code>
     </td><td> Granularity to be matched by the form control's value
     </td><td> <a href="#valid-floating-point-number" id="attributes-3:valid-floating-point-number-6">Valid floating-point number</a> greater than zero, or "<code>any</code>"
    </td></tr><tr><th> <code>style</code>
     </th><td> <a href="#attr-style" id="attributes-3:attr-style">HTML elements</a>
     </td><td> Presentational and formatting instructions
     </td><td> CSS declarations*
    </td></tr><tr><th> <code>tabindex</code>
     </th><td> <a href="#attr-tabindex" id="attributes-3:attr-tabindex">HTML elements</a>
     </td><td> Whether the element is <a href="#focusable" id="attributes-3:focusable">focusable</a> and <a href="#sequentially-focusable" id="attributes-3:sequentially-focusable">sequentially focusable</a>, and
     the relative order of the element for the purposes of <a href="#sequential-focus-navigation" id="attributes-3:sequential-focus-navigation">sequential focus navigation</a>
     </td><td> <a href="#valid-integer" id="attributes-3:valid-integer-2">Valid integer</a>
    </td></tr><tr><th> <code>target</code>
     </th><td> <code id="attributes-3:attr-hyperlink-target"><a href="#attr-hyperlink-target">a</a></code>;
          <code id="attributes-3:attr-hyperlink-target-2"><a href="#attr-hyperlink-target">area</a></code>
     </td><td> <a href="#navigable" id="attributes-3:navigable-2">Navigable</a> for <a href="#hyperlink" id="attributes-3:hyperlink-5">hyperlink</a> <a href="#navigate" id="attributes-3:navigate">navigation</a>
     </td><td> <a href="#valid-navigable-target-name-or-keyword" id="attributes-3:valid-navigable-target-name-or-keyword-3">Valid navigable target name or keyword</a>
    </td></tr><tr><th> <code>target</code>
     </th><td> <code id="attributes-3:attr-base-target"><a href="#attr-base-target">base</a></code>
     </td><td> Default <a href="#navigable" id="attributes-3:navigable-3">navigable</a> for <a href="#hyperlink" id="attributes-3:hyperlink-6">hyperlink</a> <a href="#navigate" id="attributes-3:navigate-2">navigation</a> and <a href="#form-submission-2" id="attributes-3:form-submission-2-14">form submission</a>
     </td><td> <a href="#valid-navigable-target-name-or-keyword" id="attributes-3:valid-navigable-target-name-or-keyword-4">Valid navigable target name or keyword</a>
    </td></tr><tr><th> <code>target</code>
     </th><td> <code id="attributes-3:attr-fs-target"><a href="#attr-fs-target">form</a></code>
     </td><td> <a href="#navigable" id="attributes-3:navigable-4">Navigable</a> for <a href="#form-submission-2" id="attributes-3:form-submission-2-15">form submission</a>
     </td><td> <a href="#valid-navigable-target-name-or-keyword" id="attributes-3:valid-navigable-target-name-or-keyword-5">Valid navigable target name or keyword</a>
    </td></tr><tr><th> <code>title</code>
     </th><td> <a href="#attr-title" id="attributes-3:attr-title">HTML elements</a>
     </td><td> Advisory information for the element
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>title</code>
     </th><td> <code id="attributes-3:attr-abbr-title"><a href="#attr-abbr-title">abbr</a></code>;
          <code id="attributes-3:attr-dfn-title"><a href="#attr-dfn-title">dfn</a></code>
     </td><td> Full term or expansion of abbreviation
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>title</code>
     </th><td> <code id="attributes-3:attr-input-title"><a href="#attr-input-title">input</a></code>
     </td><td> Description of pattern (when used with <code id="attributes-3:attr-input-pattern-2"><a href="#attr-input-pattern">pattern</a></code> attribute)
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>title</code>
     </th><td> <code id="attributes-3:attr-link-title"><a href="#attr-link-title">link</a></code>
     </td><td> Title of the link
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>title</code>
     </th><td> <code id="attributes-3:attr-link-title-2"><a href="#attr-link-title">link</a></code>;
          <code id="attributes-3:attr-style-title"><a href="#attr-style-title">style</a></code>
     </td><td> <a id="attributes-3:css-style-sheet-set-name" href="https://drafts.csswg.org/cssom/#css-style-sheet-set-name" data-x-internal="css-style-sheet-set-name">CSS style sheet set name</a>
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>translate</code>
     </th><td> <a href="#attr-translate" id="attributes-3:attr-translate">HTML elements</a>
     </td><td> Whether the element is to be translated when the page is localized
     </td><td> "<code>yes</code>"; "<code>no</code>"
    </td></tr><tr><th> <code>type</code>
     </th><td> <code id="attributes-3:attr-hyperlink-type"><a href="#attr-hyperlink-type">a</a></code>;
          <code id="attributes-3:attr-link-type"><a href="#attr-link-type">link</a></code>
     </td><td> Hint for the type of the referenced resource
     </td><td> <a id="attributes-3:valid-mime-type-string" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">Valid MIME type string</a>
    </td></tr><tr><th> <code>type</code>
     </th><td> <code id="attributes-3:attr-button-type"><a href="#attr-button-type">button</a></code>
     </td><td> Type of button
     </td><td> "<code id="attributes-3:attr-button-type-submit"><a href="#attr-button-type-submit">submit</a></code>";
          "<code id="attributes-3:attr-button-type-reset"><a href="#attr-button-type-reset">reset</a></code>";
          "<code id="attributes-3:attr-button-type-button"><a href="#attr-button-type-button">button</a></code>"
    </td></tr><tr><th> <code>type</code>
     </th><td> <code id="attributes-3:attr-embed-type"><a href="#attr-embed-type">embed</a></code>;
          <code id="attributes-3:attr-object-type"><a href="#attr-object-type">object</a></code>;
          <code id="attributes-3:attr-source-type"><a href="#attr-source-type">source</a></code>
     </td><td> Type of embedded resource
     </td><td> <a id="attributes-3:valid-mime-type-string-2" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">Valid MIME type string</a>
    </td></tr><tr><th> <code>type</code>
     </th><td> <code id="attributes-3:attr-input-type"><a href="#attr-input-type">input</a></code>
     </td><td> Type of form control
     </td><td> <a href="#attr-input-type" id="attributes-3:attr-input-type-2"><code>input</code> type keyword</a>
    </td></tr><tr><th> <code>type</code>
     </th><td> <code id="attributes-3:attr-ol-type"><a href="#attr-ol-type">ol</a></code>
     </td><td> Kind of list marker
     </td><td> "<code id="attributes-3:attr-ol-type-keyword-decimal"><a href="#attr-ol-type-keyword-decimal">1</a></code>";
          "<code id="attributes-3:attr-ol-type-keyword-lower-alpha"><a href="#attr-ol-type-keyword-lower-alpha">a</a></code>";
          "<code id="attributes-3:attr-ol-type-keyword-upper-alpha"><a href="#attr-ol-type-keyword-upper-alpha">A</a></code>";
          "<code id="attributes-3:attr-ol-type-keyword-lower-roman"><a href="#attr-ol-type-keyword-lower-roman">i</a></code>";
          "<code id="attributes-3:attr-ol-type-keyword-upper-roman"><a href="#attr-ol-type-keyword-upper-roman">I</a></code>"
    </td></tr><tr><th> <code>type</code>
     </th><td> <code id="attributes-3:attr-script-type"><a href="#attr-script-type">script</a></code>
     </td><td> Type of script
     </td><td> "<code>module</code>"; "<code>importmap</code>"; "<code>speculationrules</code>"; a <a id="attributes-3:valid-mime-type-string-3" href="https://mimesniff.spec.whatwg.org/#valid-mime-type" data-x-internal="valid-mime-type-string">valid MIME type string</a> that is not a <a id="attributes-3:javascript-mime-type-essence-match" href="https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match" data-x-internal="javascript-mime-type-essence-match">JavaScript MIME type essence match</a>
    </td></tr><tr><th> <code>usemap</code>
     </th><td> <code id="attributes-3:attr-hyperlink-usemap-2"><a href="#attr-hyperlink-usemap">img</a></code>
     </td><td> Name of <a href="#image-map" id="attributes-3:image-map-4">image map</a> to use
     </td><td> <a href="#valid-hash-name-reference" id="attributes-3:valid-hash-name-reference">Valid hash-name reference</a>*
    </td></tr><tr><th> <code>value</code>
     </th><td> <code id="attributes-3:attr-button-value"><a href="#attr-button-value">button</a></code>;
          <code id="attributes-3:attr-option-value"><a href="#attr-option-value">option</a></code>
     </td><td> Value to be used for <a href="#form-submission-2" id="attributes-3:form-submission-2-16">form submission</a>
     </td><td> <a href="#attribute-text">Text</a>
    </td></tr><tr><th> <code>value</code>
     </th><td> <code id="attributes-3:attr-data-value"><a href="#attr-data-value">data</a></code>
     </td><td> Machine-readable value
     </td><td> <a href="#attribute-text">Text</a>*
    </td></tr><tr><th> <code>value</code>
     </th><td> <code id="attributes-3:attr-input-value"><a href="#attr-input-value">input</a></code>
     </td><td> Value of the form control
     </td><td> Varies*
    </td></tr><tr><th> <code>value</code>
     </th><td> <code id="attributes-3:attr-li-value"><a href="#attr-li-value">li</a></code>
     </td><td> <a href="#ordinal-value" id="attributes-3:ordinal-value">Ordinal value</a> of the list item
     </td><td> <a href="#valid-integer" id="attributes-3:valid-integer-3">Valid integer</a>
    </td></tr><tr><th> <code>value</code>
     </th><td> <code id="attributes-3:attr-meter-value"><a href="#attr-meter-value">meter</a></code>;
          <code id="attributes-3:attr-progress-value"><a href="#attr-progress-value">progress</a></code>
     </td><td> Current value of the element
     </td><td> <a href="#valid-floating-point-number" id="attributes-3:valid-floating-point-number-7">Valid floating-point number</a>
    </td></tr><tr><th> <code>width</code>
     </th><td> <code id="attributes-3:attr-canvas-width"><a href="#attr-canvas-width">canvas</a></code>;
          <code id="attributes-3:attr-dim-width"><a href="#attr-dim-width">embed</a></code>;
          <code id="attributes-3:attr-dim-width-2"><a href="#attr-dim-width">iframe</a></code>;
          <code id="attributes-3:attr-dim-width-3"><a href="#attr-dim-width">img</a></code>;
          <code id="attributes-3:attr-dim-width-4"><a href="#attr-dim-width">input</a></code>;
          <code id="attributes-3:attr-dim-width-5"><a href="#attr-dim-width">object</a></code>;
          <code id="attributes-3:attr-dim-width-6"><a href="#attr-dim-width">source</a></code> (in <code id="attributes-3:the-picture-element-2"><a href="#the-picture-element">picture</a></code>);
          <code id="attributes-3:attr-dim-width-7"><a href="#attr-dim-width">video</a></code>
     </td><td> Horizontal dimension
     </td><td> <a href="#valid-non-negative-integer" id="attributes-3:valid-non-negative-integer-11">Valid non-negative integer</a>
    </td></tr><tr><th> <code>wrap</code>
     </th><td> <code id="attributes-3:attr-textarea-wrap"><a href="#attr-textarea-wrap">textarea</a></code>
     </td><td> How the value of the form control is to be wrapped for <a href="#form-submission-2" id="attributes-3:form-submission-2-17">form submission</a>
     </td><td> "<code id="attributes-3:attr-textarea-wrap-soft"><a href="#attr-textarea-wrap-soft">soft</a></code>";
          "<code id="attributes-3:attr-textarea-wrap-hard"><a href="#attr-textarea-wrap-hard">hard</a></code>"
    </td></tr><tr><th> <code>writingsuggestions</code>
     </th><td> <a href="#attr-writingsuggestions" id="attributes-3:attr-writingsuggestions">HTML elements</a>
     </td><td> Whether the element can offer writing suggestions or not.
     </td><td> "<code id="attributes-3:attr-writingsuggestions-true"><a href="#attr-writingsuggestions-true">true</a></code>";
          "<code id="attributes-3:attr-writingsuggestions-false"><a href="#attr-writingsuggestions-false">false</a></code>";
          the empty string
  </td></tr></tbody></table>

  <p class="tablenote"><small>An asterisk (*) in a cell indicates that the actual rules are more
  complicated than indicated in the table above.</small></p>

  <hr>

  <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event" title="The drag event is fired every few hundred milliseconds as an element or text selection is being dragged by the user.">HTMLElement/drag_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragend_event" title="The dragend event is fired when a drag operation is being ended (by releasing a mouse button or hitting the escape key).">HTMLElement/dragend_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragenter_event" title="The dragenter event is fired when a dragged element or text selection enters a valid drop target.">HTMLElement/dragenter_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragleave_event" title="The dragleave event is fired when a dragged element or text selection leaves a valid drop target.">HTMLElement/dragleave_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragover_event" title="The dragover event is fired when an element or text selection is being dragged over a valid drop target (every few hundred milliseconds).">HTMLElement/dragover_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragstart_event" title="The dragstart event is fired when the user starts dragging an element or text selection.">HTMLElement/dragstart_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drop_event" title="The drop event is fired when an element or text selection is dropped on a valid drop target. To ensure that the drop event always fires as expected, you should always include a preventDefault() call in the part of your code which handles the dragover event.">HTMLElement/drop_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div><table id="ix-event-handlers"><caption>List of event handler content attributes</caption><thead><tr><th> Attribute
     </th><th> Element(s)
     </th><th> Description
     </th><th> Value
   </th></tr></thead><tbody><tr><th id="ix-handler-window-onafterprint"> <code>onafterprint</code>
     </th><td> <code id="attributes-3:handler-window-onafterprint"><a href="#handler-window-onafterprint">body</a></code>
     </td><td> <code id="attributes-3:event-afterprint"><a href="#event-afterprint">afterprint</a></code> event handler for <code id="attributes-3:window"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onauxclick"> <code>onauxclick</code>
     </th><td> <a href="#handler-onauxclick" id="attributes-3:handler-onauxclick">HTML elements</a>
     </td><td> <code id="attributes-3:event-auxclick"><a data-x-internal="event-auxclick" href="https://w3c.github.io/uievents/#event-type-auxclick">auxclick</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-2">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onbeforeinput"> <code>onbeforeinput</code>
     </th><td> <a href="#handler-onbeforeinput" id="attributes-3:handler-onbeforeinput">HTML elements</a>
     </td><td> <code id="attributes-3:event-beforeinput"><a data-x-internal="event-beforeinput" href="https://w3c.github.io/uievents/#event-type-beforeinput">beforeinput</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-3">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onbeforematch"> <code>onbeforematch</code>
     </th><td> <a href="#handler-onbeforematch" id="attributes-3:handler-onbeforematch">HTML elements</a>
     </td><td> <code id="attributes-3:event-beforematch"><a href="#event-beforematch">beforematch</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-4">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onbeforeprint"> <code>onbeforeprint</code>
     </th><td> <code id="attributes-3:handler-window-onbeforeprint"><a href="#handler-window-onbeforeprint">body</a></code>
     </td><td> <code id="attributes-3:event-beforeprint"><a href="#event-beforeprint">beforeprint</a></code> event handler for <code id="attributes-3:window-2"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-5">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onbeforeunload"> <code>onbeforeunload</code>
     </th><td> <code id="attributes-3:handler-window-onbeforeunload"><a href="#handler-window-onbeforeunload">body</a></code>
     </td><td> <code id="attributes-3:event-beforeunload"><a href="#event-beforeunload">beforeunload</a></code> event handler for <code id="attributes-3:window-3"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-6">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onbeforetoggle"> <code>onbeforetoggle</code>
     </th><td> <a href="#handler-onbeforetoggle" id="attributes-3:handler-onbeforetoggle">HTML elements</a>
     </td><td> <code id="attributes-3:event-beforetoggle"><a href="#event-beforetoggle">beforetoggle</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-7">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onblur"> <code>onblur</code>
     </th><td> <a href="#handler-onblur" id="attributes-3:handler-onblur">HTML elements</a>
     </td><td> <code id="attributes-3:event-blur"><a href="#event-blur">blur</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-8">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncancel"> <code>oncancel</code>
     </th><td> <a href="#handler-oncancel" id="attributes-3:handler-oncancel">HTML elements</a>
     </td><td> <code id="attributes-3:event-cancel"><a href="#event-cancel">cancel</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-9">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncanplay"> <code>oncanplay</code>
     </th><td> <a href="#handler-oncanplay" id="attributes-3:handler-oncanplay">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-canplay"><a href="#event-media-canplay">canplay</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-10">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncanplaythrough"> <code>oncanplaythrough</code>
     </th><td> <a href="#handler-oncanplaythrough" id="attributes-3:handler-oncanplaythrough">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-canplaythrough"><a href="#event-media-canplaythrough">canplaythrough</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-11">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onchange"> <code>onchange</code>
     </th><td> <a href="#handler-onchange" id="attributes-3:handler-onchange">HTML elements</a>
     </td><td> <code id="attributes-3:event-change"><a href="#event-change">change</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-12">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onclick"> <code>onclick</code>
     </th><td> <a href="#handler-onclick" id="attributes-3:handler-onclick">HTML elements</a>
     </td><td> <code id="attributes-3:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-13">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onclose"> <code>onclose</code>
     </th><td> <a href="#handler-onclose" id="attributes-3:handler-onclose">HTML elements</a>
     </td><td> <code id="attributes-3:event-close"><a href="#event-close">close</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-14">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncommand"> <code>oncommand</code>
     </th><td> <a href="#handler-oncommand" id="attributes-3:handler-oncommand">HTML elements</a>
     </td><td> <code id="attributes-3:event-command"><a href="#event-command">command</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-15">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncontextlost"> <code>oncontextlost</code>
     </th><td> <a href="#handler-oncontextlost" id="attributes-3:handler-oncontextlost">HTML elements</a>
     </td><td> <code id="attributes-3:event-contextlost"><a href="#event-contextlost">contextlost</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-16">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncontextmenu"> <code>oncontextmenu</code>
     </th><td> <a href="#handler-oncontextmenu" id="attributes-3:handler-oncontextmenu">HTML elements</a>
     </td><td> <code id="attributes-3:event-contextmenu"><a data-x-internal="event-contextmenu" href="https://w3c.github.io/uievents/#event-type-contextmenu">contextmenu</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-17">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncontextrestored"> <code>oncontextrestored</code>
     </th><td> <a href="#handler-oncontextrestored" id="attributes-3:handler-oncontextrestored">HTML elements</a>
     </td><td> <code id="attributes-3:event-contextrestored"><a href="#event-contextrestored">contextrestored</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-18">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncopy"> <code>oncopy</code>
     </th><td> <a href="#handler-oncopy" id="attributes-3:handler-oncopy">HTML elements</a>
     </td><td> <code id="attributes-3:event-copy"><a data-x-internal="event-copy" href="https://w3c.github.io/clipboard-apis/#clipboard-event-copy">copy</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-19">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncuechange"> <code>oncuechange</code>
     </th><td> <a href="#handler-oncuechange" id="attributes-3:handler-oncuechange">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-cuechange"><a href="#event-media-cuechange">cuechange</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-20">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oncut"> <code>oncut</code>
     </th><td> <a href="#handler-oncut" id="attributes-3:handler-oncut">HTML elements</a>
     </td><td> <code id="attributes-3:event-cut"><a data-x-internal="event-cut" href="https://w3c.github.io/clipboard-apis/#clipboard-event-cut">cut</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-21">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ondblclick"> <code>ondblclick</code>
     </th><td> <a href="#handler-ondblclick" id="attributes-3:handler-ondblclick">HTML elements</a>
     </td><td> <code id="attributes-3:event-dblclick"><a data-x-internal="event-dblclick" href="https://w3c.github.io/uievents/#event-type-dblclick">dblclick</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-22">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ondrag"> <code>ondrag</code>
     </th><td> <a href="#handler-ondrag" id="attributes-3:handler-ondrag">HTML elements</a>
     </td><td> <code id="attributes-3:event-dnd-drag"><a href="#event-dnd-drag">drag</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-23">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ondragend"> <code>ondragend</code>
     </th><td> <a href="#handler-ondragend" id="attributes-3:handler-ondragend">HTML elements</a>
     </td><td> <code id="attributes-3:event-dnd-dragend"><a href="#event-dnd-dragend">dragend</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-24">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ondragenter"> <code>ondragenter</code>
     </th><td> <a href="#handler-ondragenter" id="attributes-3:handler-ondragenter">HTML elements</a>
     </td><td> <code id="attributes-3:event-dnd-dragenter"><a href="#event-dnd-dragenter">dragenter</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-25">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ondragleave"> <code>ondragleave</code>
     </th><td> <a href="#handler-ondragleave" id="attributes-3:handler-ondragleave">HTML elements</a>
     </td><td> <code id="attributes-3:event-dnd-dragleave"><a href="#event-dnd-dragleave">dragleave</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-26">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ondragover"> <code>ondragover</code>
     </th><td> <a href="#handler-ondragover" id="attributes-3:handler-ondragover">HTML elements</a>
     </td><td> <code id="attributes-3:event-dnd-dragover"><a href="#event-dnd-dragover">dragover</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-27">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ondragstart"> <code>ondragstart</code>
     </th><td> <a href="#handler-ondragstart" id="attributes-3:handler-ondragstart">HTML elements</a>
     </td><td> <code id="attributes-3:event-dnd-dragstart"><a href="#event-dnd-dragstart">dragstart</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-28">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ondrop"> <code>ondrop</code>
     </th><td> <a href="#handler-ondrop" id="attributes-3:handler-ondrop">HTML elements</a>
     </td><td> <code id="attributes-3:event-dnd-drop"><a href="#event-dnd-drop">drop</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-29">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ondurationchange"> <code>ondurationchange</code>
     </th><td> <a href="#handler-ondurationchange" id="attributes-3:handler-ondurationchange">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-durationchange"><a href="#event-media-durationchange">durationchange</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-30">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onemptied"> <code>onemptied</code>
     </th><td> <a href="#handler-onemptied" id="attributes-3:handler-onemptied">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-emptied"><a href="#event-media-emptied">emptied</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-31">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onended"> <code>onended</code>
     </th><td> <a href="#handler-onended" id="attributes-3:handler-onended">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-ended"><a href="#event-media-ended">ended</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-32">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onerror"> <code>onerror</code>
     </th><td> <a href="#handler-onerror" id="attributes-3:handler-onerror">HTML elements</a>
     </td><td> <code id="attributes-3:event-error"><a href="#event-error">error</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-33">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onfocus"> <code>onfocus</code>
     </th><td> <a href="#handler-onfocus" id="attributes-3:handler-onfocus">HTML elements</a>
     </td><td> <code id="attributes-3:event-focus"><a href="#event-focus">focus</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-34">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onformdata"> <code>onformdata</code>
     </th><td> <a href="#handler-onformdata" id="attributes-3:handler-onformdata">HTML elements</a>
     </td><td> <code id="attributes-3:event-formdata"><a href="#event-formdata">formdata</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-35">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onhashchange"> <code>onhashchange</code>
     </th><td> <code id="attributes-3:handler-window-onhashchange"><a href="#handler-window-onhashchange">body</a></code>
     </td><td> <code id="attributes-3:event-hashchange"><a href="#event-hashchange">hashchange</a></code> event handler for <code id="attributes-3:window-4"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-36">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oninput"> <code>oninput</code>
     </th><td> <a href="#handler-oninput" id="attributes-3:handler-oninput">HTML elements</a>
     </td><td> <code id="attributes-3:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-37">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-oninvalid"> <code>oninvalid</code>
     </th><td> <a href="#handler-oninvalid" id="attributes-3:handler-oninvalid">HTML elements</a>
     </td><td> <code id="attributes-3:event-invalid"><a href="#event-invalid">invalid</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-38">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onkeydown"> <code>onkeydown</code>
     </th><td> <a href="#handler-onkeydown" id="attributes-3:handler-onkeydown">HTML elements</a>
     </td><td> <code id="attributes-3:event-keydown"><a data-x-internal="event-keydown" href="https://w3c.github.io/uievents/#event-type-keydown">keydown</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-39">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onkeypress"> <code>onkeypress</code>
     </th><td> <a href="#handler-onkeypress" id="attributes-3:handler-onkeypress">HTML elements</a>
     </td><td> <code id="attributes-3:event-keypress"><a data-x-internal="event-keypress" href="https://w3c.github.io/uievents/#event-type-keypress">keypress</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-40">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onkeyup"> <code>onkeyup</code>
     </th><td> <a href="#handler-onkeyup" id="attributes-3:handler-onkeyup">HTML elements</a>
     </td><td> <code id="attributes-3:event-keyup"><a data-x-internal="event-keyup" href="https://w3c.github.io/uievents/#event-type-keyup">keyup</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-41">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onlanguagechange"> <code>onlanguagechange</code>
     </th><td> <code id="attributes-3:handler-window-onlanguagechange"><a href="#handler-window-onlanguagechange">body</a></code>
     </td><td> <code id="attributes-3:event-languagechange"><a href="#event-languagechange">languagechange</a></code> event handler for <code id="attributes-3:window-5"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-42">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onload"> <code>onload</code>
     </th><td> <a href="#handler-onload" id="attributes-3:handler-onload">HTML elements</a>
     </td><td> <code id="attributes-3:event-load"><a href="#event-load">load</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-43">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onloadeddata"> <code>onloadeddata</code>
     </th><td> <a href="#handler-onloadeddata" id="attributes-3:handler-onloadeddata">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-loadeddata"><a href="#event-media-loadeddata">loadeddata</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-44">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onloadedmetadata"> <code>onloadedmetadata</code>
     </th><td> <a href="#handler-onloadedmetadata" id="attributes-3:handler-onloadedmetadata">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-loadedmetadata"><a href="#event-media-loadedmetadata">loadedmetadata</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-45">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onloadstart"> <code>onloadstart</code>
     </th><td> <a href="#handler-onloadstart" id="attributes-3:handler-onloadstart">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-loadstart"><a href="#event-media-loadstart">loadstart</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-46">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onmessage"> <code>onmessage</code>
     </th><td> <code id="attributes-3:handler-window-onmessage"><a href="#handler-window-onmessage">body</a></code>
     </td><td> <code id="attributes-3:event-message"><a href="#event-message">message</a></code> event handler for <code id="attributes-3:window-6"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-47">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onmessageerror"> <code>onmessageerror</code>
     </th><td> <code id="attributes-3:handler-window-onmessageerror"><a href="#handler-window-onmessageerror">body</a></code>
     </td><td> <code id="attributes-3:event-messageerror"><a href="#event-messageerror">messageerror</a></code> event handler for <code id="attributes-3:window-7"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-48">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onmousedown"> <code>onmousedown</code>
     </th><td> <a href="#handler-onmousedown" id="attributes-3:handler-onmousedown">HTML elements</a>
     </td><td> <code id="attributes-3:event-mousedown"><a data-x-internal="event-mousedown" href="https://w3c.github.io/uievents/#event-type-mousedown">mousedown</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-49">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onmouseenter"> <code>onmouseenter</code>
     </th><td> <a href="#handler-onmouseenter" id="attributes-3:handler-onmouseenter">HTML elements</a>
     </td><td> <code id="attributes-3:event-mouseenter"><a data-x-internal="event-mouseenter" href="https://w3c.github.io/uievents/#event-type-mouseenter">mouseenter</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-50">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onmouseleave"> <code>onmouseleave</code>
     </th><td> <a href="#handler-onmouseleave" id="attributes-3:handler-onmouseleave">HTML elements</a>
     </td><td> <code id="attributes-3:event-mouseleave"><a data-x-internal="event-mouseleave" href="https://w3c.github.io/uievents/#event-type-mouseleave">mouseleave</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-51">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onmousemove"> <code>onmousemove</code>
     </th><td> <a href="#handler-onmousemove" id="attributes-3:handler-onmousemove">HTML elements</a>
     </td><td> <code id="attributes-3:event-mousemove"><a data-x-internal="event-mousemove" href="https://w3c.github.io/uievents/#event-type-mousemove">mousemove</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-52">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onmouseout"> <code>onmouseout</code>
     </th><td> <a href="#handler-onmouseout" id="attributes-3:handler-onmouseout">HTML elements</a>
     </td><td> <code id="attributes-3:event-mouseout"><a data-x-internal="event-mouseout" href="https://w3c.github.io/uievents/#event-type-mouseout">mouseout</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-53">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onmouseover"> <code>onmouseover</code>
     </th><td> <a href="#handler-onmouseover" id="attributes-3:handler-onmouseover">HTML elements</a>
     </td><td> <code id="attributes-3:event-mouseover"><a data-x-internal="event-mouseover" href="https://w3c.github.io/uievents/#event-type-mouseover">mouseover</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-54">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onmouseup"> <code>onmouseup</code>
     </th><td> <a href="#handler-onmouseup" id="attributes-3:handler-onmouseup">HTML elements</a>
     </td><td> <code id="attributes-3:event-mouseup"><a data-x-internal="event-mouseup" href="https://w3c.github.io/uievents/#event-type-mouseup">mouseup</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-55">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onoffline"> <code>onoffline</code>
     </th><td> <code id="attributes-3:handler-window-onoffline"><a href="#handler-window-onoffline">body</a></code>
     </td><td> <code id="attributes-3:event-offline"><a href="#event-offline">offline</a></code> event handler for <code id="attributes-3:window-8"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-56">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-ononline"> <code>ononline</code>
     </th><td> <code id="attributes-3:handler-window-ononline"><a href="#handler-window-ononline">body</a></code>
     </td><td> <code id="attributes-3:event-online"><a href="#event-online">online</a></code> event handler for <code id="attributes-3:window-9"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-57">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onpagehide"> <code>onpagehide</code>
     </th><td> <code id="attributes-3:handler-window-onpagehide"><a href="#handler-window-onpagehide">body</a></code>
     </td><td> <code id="attributes-3:event-pagehide"><a href="#event-pagehide">pagehide</a></code> event handler for <code id="attributes-3:window-10"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-58">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onpagereveal"> <code>onpagereveal</code>
     </th><td> <code id="attributes-3:handler-window-onpagereveal"><a href="#handler-window-onpagereveal">body</a></code>
     </td><td> <code id="attributes-3:event-pagereveal"><a href="#event-pagereveal">pagereveal</a></code> event handler for <code id="attributes-3:window-11"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-59">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onpageshow"> <code>onpageshow</code>
     </th><td> <code id="attributes-3:handler-window-onpageshow"><a href="#handler-window-onpageshow">body</a></code>
     </td><td> <code id="attributes-3:event-pageshow"><a href="#event-pageshow">pageshow</a></code> event handler for <code id="attributes-3:window-12"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-60">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onpageswap"> <code>onpageswap</code>
     </th><td> <code id="attributes-3:handler-window-onpageswap"><a href="#handler-window-onpageswap">body</a></code>
     </td><td> <code id="attributes-3:event-pageswap"><a href="#event-pageswap">pageswap</a></code> event handler for <code id="attributes-3:window-13"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-61">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onpaste"> <code>onpaste</code>
     </th><td> <a href="#handler-onpaste" id="attributes-3:handler-onpaste">HTML elements</a>
     </td><td> <code id="attributes-3:event-paste"><a data-x-internal="event-paste" href="https://w3c.github.io/clipboard-apis/#clipboard-event-paste">paste</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-62">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onpause"> <code>onpause</code>
     </th><td> <a href="#handler-onpause" id="attributes-3:handler-onpause">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-pause"><a href="#event-media-pause">pause</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-63">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onplay"> <code>onplay</code>
     </th><td> <a href="#handler-onplay" id="attributes-3:handler-onplay">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-play"><a href="#event-media-play">play</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-64">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onplaying"> <code>onplaying</code>
     </th><td> <a href="#handler-onplaying" id="attributes-3:handler-onplaying">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-playing"><a href="#event-media-playing">playing</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-65">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onpopstate"> <code>onpopstate</code>
     </th><td> <code id="attributes-3:handler-window-onpopstate"><a href="#handler-window-onpopstate">body</a></code>
     </td><td> <code id="attributes-3:event-popstate"><a href="#event-popstate">popstate</a></code> event handler for <code id="attributes-3:window-14"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-66">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onprogress"> <code>onprogress</code>
     </th><td> <a href="#handler-onprogress" id="attributes-3:handler-onprogress">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-progress"><a href="#event-media-progress">progress</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-67">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onratechange"> <code>onratechange</code>
     </th><td> <a href="#handler-onratechange" id="attributes-3:handler-onratechange">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-ratechange"><a href="#event-media-ratechange">ratechange</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-68">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onreset"> <code>onreset</code>
     </th><td> <a href="#handler-onreset" id="attributes-3:handler-onreset">HTML elements</a>
     </td><td> <code id="attributes-3:event-reset"><a href="#event-reset">reset</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-69">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onresize"> <code>onresize</code>
     </th><td> <a href="#handler-onresize" id="attributes-3:handler-onresize">HTML elements</a>
     </td><td> <code id="attributes-3:event-resize"><a data-x-internal="event-resize" href="https://drafts.csswg.org/cssom-view/#eventdef-window-resize">resize</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-70">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onrejectionhandled"> <code>onrejectionhandled</code>
     </th><td> <code id="attributes-3:handler-window-onrejectionhandled"><a href="#handler-window-onrejectionhandled">body</a></code>
     </td><td> <code id="attributes-3:event-rejectionhandled"><a href="#event-rejectionhandled">rejectionhandled</a></code> event handler for <code id="attributes-3:window-15"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-71">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onscroll"> <code>onscroll</code>
     </th><td> <a href="#handler-onscroll" id="attributes-3:handler-onscroll">HTML elements</a>
     </td><td> <code id="attributes-3:event-scroll"><a data-x-internal="event-scroll" href="https://drafts.csswg.org/cssom-view/#eventdef-document-scroll">scroll</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-72">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onscrollend"> <code>onscrollend</code>
     </th><td> <a href="#handler-onscrollend" id="attributes-3:handler-onscrollend">HTML elements</a>
     </td><td> <code id="attributes-3:event-scrollend"><a data-x-internal="event-scrollend" href="https://drafts.csswg.org/cssom-view/#eventdef-document-scrollend">scrollend</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-73">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onsecuritypolicyviolation"> <code>onsecuritypolicyviolation</code>
     </th><td> <a href="#handler-onsecuritypolicyviolation" id="attributes-3:handler-onsecuritypolicyviolation">HTML elements</a>
     </td><td> <code id="attributes-3:event-securitypolicyviolation"><a data-x-internal="event-securitypolicyviolation" href="https://w3c.github.io/webappsec-csp/#eventdef-globaleventhandlers-securitypolicyviolation">securitypolicyviolation</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-74">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onseeked"> <code>onseeked</code>
     </th><td> <a href="#handler-onseeked" id="attributes-3:handler-onseeked">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-seeked"><a href="#event-media-seeked">seeked</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-75">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onseeking"> <code>onseeking</code>
     </th><td> <a href="#handler-onseeking" id="attributes-3:handler-onseeking">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-seeking"><a href="#event-media-seeking">seeking</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-76">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onselect"> <code>onselect</code>
     </th><td> <a href="#handler-onselect" id="attributes-3:handler-onselect">HTML elements</a>
     </td><td> <code id="attributes-3:event-select"><a href="#event-select">select</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-77">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onslotchange"> <code>onslotchange</code>
     </th><td> <a href="#handler-onslotchange" id="attributes-3:handler-onslotchange">HTML elements</a>
     </td><td> <code id="attributes-3:event-slotchange"><a data-x-internal="event-slotchange" href="https://dom.spec.whatwg.org/#eventdef-htmlslotelement-slotchange">slotchange</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-78">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onstalled"> <code>onstalled</code>
     </th><td> <a href="#handler-onstalled" id="attributes-3:handler-onstalled">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-stalled"><a href="#event-media-stalled">stalled</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-79">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onstorage"> <code>onstorage</code>
     </th><td> <code id="attributes-3:handler-window-onstorage"><a href="#handler-window-onstorage">body</a></code>
     </td><td> <code id="attributes-3:event-storage"><a href="#event-storage">storage</a></code> event handler for <code id="attributes-3:window-16"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-80">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onsubmit"> <code>onsubmit</code>
     </th><td> <a href="#handler-onsubmit" id="attributes-3:handler-onsubmit">HTML elements</a>
     </td><td> <code id="attributes-3:event-submit"><a href="#event-submit">submit</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-81">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onsuspend"> <code>onsuspend</code>
     </th><td> <a href="#handler-onsuspend" id="attributes-3:handler-onsuspend">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-suspend"><a href="#event-media-suspend">suspend</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-82">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ontimeupdate"> <code>ontimeupdate</code>
     </th><td> <a href="#handler-ontimeupdate" id="attributes-3:handler-ontimeupdate">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-timeupdate"><a href="#event-media-timeupdate">timeupdate</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-83">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-ontoggle"> <code>ontoggle</code>
     </th><td> <a href="#handler-ontoggle" id="attributes-3:handler-ontoggle">HTML elements</a>
     </td><td> <code id="attributes-3:event-toggle"><a href="#event-toggle">toggle</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-84">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onunhandledrejection"> <code>onunhandledrejection</code>
     </th><td> <code id="attributes-3:handler-window-onunhandledrejection"><a href="#handler-window-onunhandledrejection">body</a></code>
     </td><td> <code id="attributes-3:event-unhandledrejection"><a href="#event-unhandledrejection">unhandledrejection</a></code> event handler for <code id="attributes-3:window-17"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-85">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-window-onunload"> <code>onunload</code>
     </th><td> <code id="attributes-3:handler-window-onunload"><a href="#handler-window-onunload">body</a></code>
     </td><td> <code id="attributes-3:event-unload"><a href="#event-unload">unload</a></code> event handler for <code id="attributes-3:window-18"><a href="#window">Window</a></code> object
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-86">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onvolumechange"> <code>onvolumechange</code>
     </th><td> <a href="#handler-onvolumechange" id="attributes-3:handler-onvolumechange">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-volumechange"><a href="#event-media-volumechange">volumechange</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-87">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onwaiting"> <code>onwaiting</code>
     </th><td> <a href="#handler-onwaiting" id="attributes-3:handler-onwaiting">HTML elements</a>
     </td><td> <code id="attributes-3:event-media-waiting"><a href="#event-media-waiting">waiting</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-88">Event handler content attribute</a>

    </td></tr><tr><th id="ix-handler-onwheel"> <code>onwheel</code>
     </th><td> <a href="#handler-onwheel" id="attributes-3:handler-onwheel">HTML elements</a>
     </td><td> <code id="attributes-3:event-wheel"><a data-x-internal="event-wheel" href="https://w3c.github.io/uievents/#event-type-wheel">wheel</a></code> event handler
     </td><td> <a href="#event-handler-content-attributes" id="attributes-3:event-handler-content-attributes-89">Event handler content attribute</a>

  </td></tr></tbody></table>


  <h3 id="element-interfaces" class="no-num">Element interfaces<a href="#element-interfaces" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <table><caption>List of interfaces for elements</caption><thead><tr><th> Element(s)
     </th><th> Interface(s)
   </th></tr></thead><tbody><tr><td> <code id="element-interfaces:the-a-element"><a href="#the-a-element">a</a></code>
     </td><td> <code id="element-interfaces:htmlanchorelement"><a href="#htmlanchorelement">HTMLAnchorElement</a></code> : <code id="element-interfaces:htmlelement"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-abbr-element"><a href="#the-abbr-element">abbr</a></code>
     </td><td> <code id="element-interfaces:htmlelement-2"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-address-element"><a href="#the-address-element">address</a></code>
     </td><td> <code id="element-interfaces:htmlelement-3"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-area-element"><a href="#the-area-element">area</a></code>
     </td><td> <code id="element-interfaces:htmlareaelement"><a href="#htmlareaelement">HTMLAreaElement</a></code> : <code id="element-interfaces:htmlelement-4"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-article-element"><a href="#the-article-element">article</a></code>
     </td><td> <code id="element-interfaces:htmlelement-5"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-aside-element"><a href="#the-aside-element">aside</a></code>
     </td><td> <code id="element-interfaces:htmlelement-6"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-audio-element"><a href="#the-audio-element">audio</a></code>
     </td><td> <code id="element-interfaces:htmlaudioelement"><a href="#htmlaudioelement">HTMLAudioElement</a></code> : <code id="element-interfaces:htmlmediaelement"><a href="#htmlmediaelement">HTMLMediaElement</a></code> : <code id="element-interfaces:htmlelement-7"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-b-element"><a href="#the-b-element">b</a></code>
     </td><td> <code id="element-interfaces:htmlelement-8"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-base-element"><a href="#the-base-element">base</a></code>
     </td><td> <code id="element-interfaces:htmlbaseelement"><a href="#htmlbaseelement">HTMLBaseElement</a></code> : <code id="element-interfaces:htmlelement-9"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-bdi-element"><a href="#the-bdi-element">bdi</a></code>
     </td><td> <code id="element-interfaces:htmlelement-10"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-bdo-element"><a href="#the-bdo-element">bdo</a></code>
     </td><td> <code id="element-interfaces:htmlelement-11"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-blockquote-element"><a href="#the-blockquote-element">blockquote</a></code>
     </td><td> <code id="element-interfaces:htmlquoteelement"><a href="#htmlquoteelement">HTMLQuoteElement</a></code> : <code id="element-interfaces:htmlelement-12"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-body-element"><a href="#the-body-element">body</a></code>
     </td><td> <code id="element-interfaces:htmlbodyelement"><a href="#htmlbodyelement">HTMLBodyElement</a></code> : <code id="element-interfaces:htmlelement-13"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-br-element"><a href="#the-br-element">br</a></code>
     </td><td> <code id="element-interfaces:htmlbrelement"><a href="#htmlbrelement">HTMLBRElement</a></code> : <code id="element-interfaces:htmlelement-14"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-button-element"><a href="#the-button-element">button</a></code>
     </td><td> <code id="element-interfaces:htmlbuttonelement"><a href="#htmlbuttonelement">HTMLButtonElement</a></code> : <code id="element-interfaces:htmlelement-15"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-canvas-element"><a href="#the-canvas-element">canvas</a></code>
     </td><td> <code id="element-interfaces:htmlcanvaselement"><a href="#htmlcanvaselement">HTMLCanvasElement</a></code> : <code id="element-interfaces:htmlelement-16"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-caption-element"><a href="#the-caption-element">caption</a></code>
     </td><td> <code id="element-interfaces:htmltablecaptionelement"><a href="#htmltablecaptionelement">HTMLTableCaptionElement</a></code> : <code id="element-interfaces:htmlelement-17"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-cite-element"><a href="#the-cite-element">cite</a></code>
     </td><td> <code id="element-interfaces:htmlelement-18"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-code-element"><a href="#the-code-element">code</a></code>
     </td><td> <code id="element-interfaces:htmlelement-19"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-col-element"><a href="#the-col-element">col</a></code>
     </td><td> <code id="element-interfaces:htmltablecolelement"><a href="#htmltablecolelement">HTMLTableColElement</a></code> : <code id="element-interfaces:htmlelement-20"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-colgroup-element"><a href="#the-colgroup-element">colgroup</a></code>
     </td><td> <code id="element-interfaces:htmltablecolelement-2"><a href="#htmltablecolelement">HTMLTableColElement</a></code> : <code id="element-interfaces:htmlelement-21"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-data-element"><a href="#the-data-element">data</a></code>
     </td><td> <code id="element-interfaces:htmldataelement"><a href="#htmldataelement">HTMLDataElement</a></code> : <code id="element-interfaces:htmlelement-22"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-datalist-element"><a href="#the-datalist-element">datalist</a></code>
     </td><td> <code id="element-interfaces:htmldatalistelement"><a href="#htmldatalistelement">HTMLDataListElement</a></code> : <code id="element-interfaces:htmlelement-23"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-dd-element"><a href="#the-dd-element">dd</a></code>
     </td><td> <code id="element-interfaces:htmlelement-24"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-del-element"><a href="#the-del-element">del</a></code>
     </td><td> <code id="element-interfaces:htmlmodelement"><a href="#htmlmodelement">HTMLModElement</a></code> : <code id="element-interfaces:htmlelement-25"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-details-element"><a href="#the-details-element">details</a></code>
     </td><td> <code id="element-interfaces:htmldetailselement"><a href="#htmldetailselement">HTMLDetailsElement</a></code> : <code id="element-interfaces:htmlelement-26"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-dfn-element"><a href="#the-dfn-element">dfn</a></code>
     </td><td> <code id="element-interfaces:htmlelement-27"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-dialog-element"><a href="#the-dialog-element">dialog</a></code>
     </td><td> <code id="element-interfaces:htmldialogelement"><a href="#htmldialogelement">HTMLDialogElement</a></code> : <code id="element-interfaces:htmlelement-28"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-div-element"><a href="#the-div-element">div</a></code>
     </td><td> <code id="element-interfaces:htmldivelement"><a href="#htmldivelement">HTMLDivElement</a></code> : <code id="element-interfaces:htmlelement-29"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-dl-element"><a href="#the-dl-element">dl</a></code>
     </td><td> <code id="element-interfaces:htmldlistelement"><a href="#htmldlistelement">HTMLDListElement</a></code> : <code id="element-interfaces:htmlelement-30"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-dt-element"><a href="#the-dt-element">dt</a></code>
     </td><td> <code id="element-interfaces:htmlelement-31"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-em-element"><a href="#the-em-element">em</a></code>
     </td><td> <code id="element-interfaces:htmlelement-32"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-embed-element"><a href="#the-embed-element">embed</a></code>
     </td><td> <code id="element-interfaces:htmlembedelement"><a href="#htmlembedelement">HTMLEmbedElement</a></code> : <code id="element-interfaces:htmlelement-33"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-fieldset-element"><a href="#the-fieldset-element">fieldset</a></code>
     </td><td> <code id="element-interfaces:htmlfieldsetelement"><a href="#htmlfieldsetelement">HTMLFieldSetElement</a></code> : <code id="element-interfaces:htmlelement-34"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-figcaption-element"><a href="#the-figcaption-element">figcaption</a></code>
     </td><td> <code id="element-interfaces:htmlelement-35"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-figure-element"><a href="#the-figure-element">figure</a></code>
     </td><td> <code id="element-interfaces:htmlelement-36"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-footer-element"><a href="#the-footer-element">footer</a></code>
     </td><td> <code id="element-interfaces:htmlelement-37"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-form-element"><a href="#the-form-element">form</a></code>
     </td><td> <code id="element-interfaces:htmlformelement"><a href="#htmlformelement">HTMLFormElement</a></code> : <code id="element-interfaces:htmlelement-38"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>
     </td><td> <code id="element-interfaces:htmlheadingelement"><a href="#htmlheadingelement">HTMLHeadingElement</a></code> : <code id="element-interfaces:htmlelement-39"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>
     </td><td> <code id="element-interfaces:htmlheadingelement-2"><a href="#htmlheadingelement">HTMLHeadingElement</a></code> : <code id="element-interfaces:htmlelement-40"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>
     </td><td> <code id="element-interfaces:htmlheadingelement-3"><a href="#htmlheadingelement">HTMLHeadingElement</a></code> : <code id="element-interfaces:htmlelement-41"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>
     </td><td> <code id="element-interfaces:htmlheadingelement-4"><a href="#htmlheadingelement">HTMLHeadingElement</a></code> : <code id="element-interfaces:htmlelement-42"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>
     </td><td> <code id="element-interfaces:htmlheadingelement-5"><a href="#htmlheadingelement">HTMLHeadingElement</a></code> : <code id="element-interfaces:htmlelement-43"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6"><a href="#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>
     </td><td> <code id="element-interfaces:htmlheadingelement-6"><a href="#htmlheadingelement">HTMLHeadingElement</a></code> : <code id="element-interfaces:htmlelement-44"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-head-element"><a href="#the-head-element">head</a></code>
     </td><td> <code id="element-interfaces:htmlheadelement"><a href="#htmlheadelement">HTMLHeadElement</a></code> : <code id="element-interfaces:htmlelement-45"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-header-element"><a href="#the-header-element">header</a></code>
     </td><td> <code id="element-interfaces:htmlelement-46"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-hgroup-element"><a href="#the-hgroup-element">hgroup</a></code>
     </td><td> <code id="element-interfaces:htmlelement-47"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-hr-element"><a href="#the-hr-element">hr</a></code>
     </td><td> <code id="element-interfaces:htmlhrelement"><a href="#htmlhrelement">HTMLHRElement</a></code> : <code id="element-interfaces:htmlelement-48"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-html-element"><a href="#the-html-element">html</a></code>
     </td><td> <code id="element-interfaces:htmlhtmlelement"><a href="#htmlhtmlelement">HTMLHtmlElement</a></code> : <code id="element-interfaces:htmlelement-49"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-i-element"><a href="#the-i-element">i</a></code>
     </td><td> <code id="element-interfaces:htmlelement-50"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-iframe-element"><a href="#the-iframe-element">iframe</a></code>
     </td><td> <code id="element-interfaces:htmliframeelement"><a href="#htmliframeelement">HTMLIFrameElement</a></code> : <code id="element-interfaces:htmlelement-51"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-img-element"><a href="#the-img-element">img</a></code>
     </td><td> <code id="element-interfaces:htmlimageelement"><a href="#htmlimageelement">HTMLImageElement</a></code> : <code id="element-interfaces:htmlelement-52"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-input-element"><a href="#the-input-element">input</a></code>
     </td><td> <code id="element-interfaces:htmlinputelement"><a href="#htmlinputelement">HTMLInputElement</a></code> : <code id="element-interfaces:htmlelement-53"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-ins-element"><a href="#the-ins-element">ins</a></code>
     </td><td> <code id="element-interfaces:htmlmodelement-2"><a href="#htmlmodelement">HTMLModElement</a></code> : <code id="element-interfaces:htmlelement-54"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-kbd-element"><a href="#the-kbd-element">kbd</a></code>
     </td><td> <code id="element-interfaces:htmlelement-55"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-label-element"><a href="#the-label-element">label</a></code>
     </td><td> <code id="element-interfaces:htmllabelelement"><a href="#htmllabelelement">HTMLLabelElement</a></code> : <code id="element-interfaces:htmlelement-56"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-legend-element"><a href="#the-legend-element">legend</a></code>
     </td><td> <code id="element-interfaces:htmllegendelement"><a href="#htmllegendelement">HTMLLegendElement</a></code> : <code id="element-interfaces:htmlelement-57"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-li-element"><a href="#the-li-element">li</a></code>
     </td><td> <code id="element-interfaces:htmllielement"><a href="#htmllielement">HTMLLIElement</a></code> : <code id="element-interfaces:htmlelement-58"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-link-element"><a href="#the-link-element">link</a></code>
     </td><td> <code id="element-interfaces:htmllinkelement"><a href="#htmllinkelement">HTMLLinkElement</a></code> : <code id="element-interfaces:htmlelement-59"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-main-element"><a href="#the-main-element">main</a></code>
     </td><td> <code id="element-interfaces:htmlelement-60"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-map-element"><a href="#the-map-element">map</a></code>
     </td><td> <code id="element-interfaces:htmlmapelement"><a href="#htmlmapelement">HTMLMapElement</a></code> : <code id="element-interfaces:htmlelement-61"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-mark-element"><a href="#the-mark-element">mark</a></code>
     </td><td> <code id="element-interfaces:htmlelement-62"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-menu-element"><a href="#the-menu-element">menu</a></code>
     </td><td> <code id="element-interfaces:htmlmenuelement"><a href="#htmlmenuelement">HTMLMenuElement</a></code> : <code id="element-interfaces:htmlelement-63"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-meta-element"><a href="#the-meta-element">meta</a></code>
     </td><td> <code id="element-interfaces:htmlmetaelement"><a href="#htmlmetaelement">HTMLMetaElement</a></code> : <code id="element-interfaces:htmlelement-64"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-meter-element"><a href="#the-meter-element">meter</a></code>
     </td><td> <code id="element-interfaces:htmlmeterelement"><a href="#htmlmeterelement">HTMLMeterElement</a></code> : <code id="element-interfaces:htmlelement-65"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-nav-element"><a href="#the-nav-element">nav</a></code>
     </td><td> <code id="element-interfaces:htmlelement-66"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-noscript-element"><a href="#the-noscript-element">noscript</a></code>
     </td><td> <code id="element-interfaces:htmlelement-67"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-object-element"><a href="#the-object-element">object</a></code>
     </td><td> <code id="element-interfaces:htmlobjectelement"><a href="#htmlobjectelement">HTMLObjectElement</a></code> : <code id="element-interfaces:htmlelement-68"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-ol-element"><a href="#the-ol-element">ol</a></code>
     </td><td> <code id="element-interfaces:htmlolistelement"><a href="#htmlolistelement">HTMLOListElement</a></code> : <code id="element-interfaces:htmlelement-69"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-optgroup-element"><a href="#the-optgroup-element">optgroup</a></code>
     </td><td> <code id="element-interfaces:htmloptgroupelement"><a href="#htmloptgroupelement">HTMLOptGroupElement</a></code> : <code id="element-interfaces:htmlelement-70"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-option-element"><a href="#the-option-element">option</a></code>
     </td><td> <code id="element-interfaces:htmloptionelement"><a href="#htmloptionelement">HTMLOptionElement</a></code> : <code id="element-interfaces:htmlelement-71"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-output-element"><a href="#the-output-element">output</a></code>
     </td><td> <code id="element-interfaces:htmloutputelement"><a href="#htmloutputelement">HTMLOutputElement</a></code> : <code id="element-interfaces:htmlelement-72"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-p-element"><a href="#the-p-element">p</a></code>
     </td><td> <code id="element-interfaces:htmlparagraphelement"><a href="#htmlparagraphelement">HTMLParagraphElement</a></code> : <code id="element-interfaces:htmlelement-73"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-picture-element"><a href="#the-picture-element">picture</a></code>
     </td><td> <code id="element-interfaces:htmlpictureelement"><a href="#htmlpictureelement">HTMLPictureElement</a></code> : <code id="element-interfaces:htmlelement-74"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-pre-element"><a href="#the-pre-element">pre</a></code>
     </td><td> <code id="element-interfaces:htmlpreelement"><a href="#htmlpreelement">HTMLPreElement</a></code> : <code id="element-interfaces:htmlelement-75"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-progress-element"><a href="#the-progress-element">progress</a></code>
     </td><td> <code id="element-interfaces:htmlprogresselement"><a href="#htmlprogresselement">HTMLProgressElement</a></code> : <code id="element-interfaces:htmlelement-76"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-q-element"><a href="#the-q-element">q</a></code>
     </td><td> <code id="element-interfaces:htmlquoteelement-2"><a href="#htmlquoteelement">HTMLQuoteElement</a></code> : <code id="element-interfaces:htmlelement-77"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-rp-element"><a href="#the-rp-element">rp</a></code>
     </td><td> <code id="element-interfaces:htmlelement-78"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-rt-element"><a href="#the-rt-element">rt</a></code>
     </td><td> <code id="element-interfaces:htmlelement-79"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-ruby-element"><a href="#the-ruby-element">ruby</a></code>
     </td><td> <code id="element-interfaces:htmlelement-80"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-s-element"><a href="#the-s-element">s</a></code>
     </td><td> <code id="element-interfaces:htmlelement-81"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-samp-element"><a href="#the-samp-element">samp</a></code>
     </td><td> <code id="element-interfaces:htmlelement-82"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-search-element"><a href="#the-search-element">search</a></code>
     </td><td> <code id="element-interfaces:htmlelement-83"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-script-element"><a href="#the-script-element">script</a></code>
     </td><td> <code id="element-interfaces:htmlscriptelement"><a href="#htmlscriptelement">HTMLScriptElement</a></code> : <code id="element-interfaces:htmlelement-84"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-section-element"><a href="#the-section-element">section</a></code>
     </td><td> <code id="element-interfaces:htmlelement-85"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-select-element"><a href="#the-select-element">select</a></code>
     </td><td> <code id="element-interfaces:htmlselectelement"><a href="#htmlselectelement">HTMLSelectElement</a></code> : <code id="element-interfaces:htmlelement-86"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-selectedcontent-element"><a href="#the-selectedcontent-element">selectedcontent</a></code>
     </td><td> <code id="element-interfaces:htmlselectedcontentelement"><a href="#htmlselectedcontentelement">HTMLSelectedContentElement</a></code> : <code id="element-interfaces:htmlelement-87"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-slot-element"><a href="#the-slot-element">slot</a></code>
     </td><td> <code id="element-interfaces:htmlslotelement"><a href="#htmlslotelement">HTMLSlotElement</a></code> : <code id="element-interfaces:htmlelement-88"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-small-element"><a href="#the-small-element">small</a></code>
     </td><td> <code id="element-interfaces:htmlelement-89"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-source-element"><a href="#the-source-element">source</a></code>
     </td><td> <code id="element-interfaces:htmlsourceelement"><a href="#htmlsourceelement">HTMLSourceElement</a></code> : <code id="element-interfaces:htmlelement-90"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-span-element"><a href="#the-span-element">span</a></code>
     </td><td> <code id="element-interfaces:htmlspanelement"><a href="#htmlspanelement">HTMLSpanElement</a></code> : <code id="element-interfaces:htmlelement-91"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-strong-element"><a href="#the-strong-element">strong</a></code>
     </td><td> <code id="element-interfaces:htmlelement-92"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-style-element"><a href="#the-style-element">style</a></code>
     </td><td> <code id="element-interfaces:htmlstyleelement"><a href="#htmlstyleelement">HTMLStyleElement</a></code> : <code id="element-interfaces:htmlelement-93"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-sub-and-sup-elements"><a href="#the-sub-and-sup-elements">sub</a></code>
     </td><td> <code id="element-interfaces:htmlelement-94"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-summary-element"><a href="#the-summary-element">summary</a></code>
     </td><td> <code id="element-interfaces:htmlelement-95"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-sub-and-sup-elements-2"><a href="#the-sub-and-sup-elements">sup</a></code>
     </td><td> <code id="element-interfaces:htmlelement-96"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-table-element"><a href="#the-table-element">table</a></code>
     </td><td> <code id="element-interfaces:htmltableelement"><a href="#htmltableelement">HTMLTableElement</a></code> : <code id="element-interfaces:htmlelement-97"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-tbody-element"><a href="#the-tbody-element">tbody</a></code>
     </td><td> <code id="element-interfaces:htmltablesectionelement"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code> : <code id="element-interfaces:htmlelement-98"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-td-element"><a href="#the-td-element">td</a></code>
     </td><td> <code id="element-interfaces:htmltablecellelement"><a href="#htmltablecellelement">HTMLTableCellElement</a></code> : <code id="element-interfaces:htmlelement-99"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-template-element"><a href="#the-template-element">template</a></code>
     </td><td> <code id="element-interfaces:htmltemplateelement"><a href="#htmltemplateelement">HTMLTemplateElement</a></code> : <code id="element-interfaces:htmlelement-100"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-textarea-element"><a href="#the-textarea-element">textarea</a></code>
     </td><td> <code id="element-interfaces:htmltextareaelement"><a href="#htmltextareaelement">HTMLTextAreaElement</a></code> : <code id="element-interfaces:htmlelement-101"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-tfoot-element"><a href="#the-tfoot-element">tfoot</a></code>
     </td><td> <code id="element-interfaces:htmltablesectionelement-2"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code> : <code id="element-interfaces:htmlelement-102"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-th-element"><a href="#the-th-element">th</a></code>
     </td><td> <code id="element-interfaces:htmltablecellelement-2"><a href="#htmltablecellelement">HTMLTableCellElement</a></code> : <code id="element-interfaces:htmlelement-103"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-thead-element"><a href="#the-thead-element">thead</a></code>
     </td><td> <code id="element-interfaces:htmltablesectionelement-3"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code> : <code id="element-interfaces:htmlelement-104"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-time-element"><a href="#the-time-element">time</a></code>
     </td><td> <code id="element-interfaces:htmltimeelement"><a href="#htmltimeelement">HTMLTimeElement</a></code> : <code id="element-interfaces:htmlelement-105"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-title-element"><a href="#the-title-element">title</a></code>
     </td><td> <code id="element-interfaces:htmltitleelement"><a href="#htmltitleelement">HTMLTitleElement</a></code> : <code id="element-interfaces:htmlelement-106"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-tr-element"><a href="#the-tr-element">tr</a></code>
     </td><td> <code id="element-interfaces:htmltablerowelement"><a href="#htmltablerowelement">HTMLTableRowElement</a></code> : <code id="element-interfaces:htmlelement-107"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-track-element"><a href="#the-track-element">track</a></code>
     </td><td> <code id="element-interfaces:htmltrackelement"><a href="#htmltrackelement">HTMLTrackElement</a></code> : <code id="element-interfaces:htmlelement-108"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-u-element"><a href="#the-u-element">u</a></code>
     </td><td> <code id="element-interfaces:htmlelement-109"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-ul-element"><a href="#the-ul-element">ul</a></code>
     </td><td> <code id="element-interfaces:htmlulistelement"><a href="#htmlulistelement">HTMLUListElement</a></code> : <code id="element-interfaces:htmlelement-110"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-var-element"><a href="#the-var-element">var</a></code>
     </td><td> <code id="element-interfaces:htmlelement-111"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-video-element"><a href="#the-video-element">video</a></code>
     </td><td> <code id="element-interfaces:htmlvideoelement"><a href="#htmlvideoelement">HTMLVideoElement</a></code> : <code id="element-interfaces:htmlmediaelement-2"><a href="#htmlmediaelement">HTMLMediaElement</a></code> : <code id="element-interfaces:htmlelement-112"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <code id="element-interfaces:the-wbr-element"><a href="#the-wbr-element">wbr</a></code>
     </td><td> <code id="element-interfaces:htmlelement-113"><a href="#htmlelement">HTMLElement</a></code>

    </td></tr><tr><td> <a href="#custom-element" id="element-interfaces:custom-element">custom elements</a>
     </td><td> supplied by the element's author (inherits from <code id="element-interfaces:htmlelement-114"><a href="#htmlelement">HTMLElement</a></code>)

  </td></tr></tbody></table>


  <h3 id="all-interfaces" class="no-num">All interfaces<a href="#all-interfaces" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

<ul class="brief"><li><code id="all-interfaces:audiotrack"><a href="#audiotrack">AudioTrack</a></code></li><li><code id="all-interfaces:audiotracklist"><a href="#audiotracklist">AudioTrackList</a></code></li><li><code id="all-interfaces:barprop"><a href="#barprop">BarProp</a></code></li><li><code id="all-interfaces:beforeunloadevent"><a href="#beforeunloadevent">BeforeUnloadEvent</a></code></li><li><code id="all-interfaces:broadcastchannel"><a href="#broadcastchannel">BroadcastChannel</a></code></li><li><code id="all-interfaces:canvasgradient"><a href="#canvasgradient">CanvasGradient</a></code></li><li><code id="all-interfaces:canvaspattern"><a href="#canvaspattern">CanvasPattern</a></code></li><li><code id="all-interfaces:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code></li><li><code id="all-interfaces:closewatcher"><a href="#closewatcher">CloseWatcher</a></code></li><li><code id="all-interfaces:commandevent"><a href="#commandevent">CommandEvent</a></code></li><li><code id="all-interfaces:customelementregistry"><a href="#customelementregistry">CustomElementRegistry</a></code></li><li><code id="all-interfaces:customstateset"><a href="#customstateset">CustomStateSet</a></code></li><li><code id="all-interfaces:domparser"><a href="#domparser">DOMParser</a></code></li><li><code id="all-interfaces:domstringlist"><a href="#domstringlist">DOMStringList</a></code></li><li><code id="all-interfaces:domstringmap"><a href="#domstringmap">DOMStringMap</a></code></li><li><code id="all-interfaces:datatransfer"><a href="#datatransfer">DataTransfer</a></code></li><li><code id="all-interfaces:datatransferitem"><a href="#datatransferitem">DataTransferItem</a></code></li><li><code id="all-interfaces:datatransferitemlist"><a href="#datatransferitemlist">DataTransferItemList</a></code></li><li><code id="all-interfaces:dedicatedworkerglobalscope"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code></li><li><code id="all-interfaces:document"><a href="#document">Document</a></code>, <a href="#document">partial 1</a> <a href="#Document-partial">2</a></li><li><code id="all-interfaces:dragevent"><a href="#dragevent">DragEvent</a></code></li><li><code id="all-interfaces:element"><a data-x-internal="element" href="https://dom.spec.whatwg.org/#interface-element">Element</a></code>, <a href="#Element-partial">partial</a></li><li><code id="all-interfaces:elementinternals"><a href="#elementinternals">ElementInternals</a></code></li><li><code id="all-interfaces:errorevent"><a href="#errorevent">ErrorEvent</a></code></li><li><code id="all-interfaces:eventsource"><a href="#eventsource">EventSource</a></code></li><li><code id="all-interfaces:external"><a href="#external">External</a></code></li><li><code id="all-interfaces:formdataevent"><a href="#formdataevent">FormDataEvent</a></code></li><li><code id="all-interfaces:htmlallcollection"><a href="#htmlallcollection">HTMLAllCollection</a></code></li><li><code id="all-interfaces:htmlanchorelement"><a href="#htmlanchorelement">HTMLAnchorElement</a></code>, <a href="#HTMLAnchorElement-partial">partial</a></li><li><code id="all-interfaces:htmlareaelement"><a href="#htmlareaelement">HTMLAreaElement</a></code>, <a href="#HTMLAreaElement-partial">partial</a></li><li><code id="all-interfaces:htmlaudioelement"><a href="#htmlaudioelement">HTMLAudioElement</a></code></li><li><code id="all-interfaces:htmlbrelement"><a href="#htmlbrelement">HTMLBRElement</a></code>, <a href="#HTMLBRElement-partial">partial</a></li><li><code id="all-interfaces:htmlbaseelement"><a href="#htmlbaseelement">HTMLBaseElement</a></code></li><li><code id="all-interfaces:htmlbodyelement"><a href="#htmlbodyelement">HTMLBodyElement</a></code>, <a href="#HTMLBodyElement-partial">partial</a></li><li><code id="all-interfaces:htmlbuttonelement"><a href="#htmlbuttonelement">HTMLButtonElement</a></code></li><li><code id="all-interfaces:htmlcanvaselement"><a href="#htmlcanvaselement">HTMLCanvasElement</a></code></li><li><code id="all-interfaces:htmldlistelement"><a href="#htmldlistelement">HTMLDListElement</a></code>, <a href="#HTMLDListElement-partial">partial</a></li><li><code id="all-interfaces:htmldataelement"><a href="#htmldataelement">HTMLDataElement</a></code></li><li><code id="all-interfaces:htmldatalistelement"><a href="#htmldatalistelement">HTMLDataListElement</a></code></li><li><code id="all-interfaces:htmldetailselement"><a href="#htmldetailselement">HTMLDetailsElement</a></code></li><li><code id="all-interfaces:htmldialogelement"><a href="#htmldialogelement">HTMLDialogElement</a></code></li><li><code id="all-interfaces:htmldirectoryelement"><a href="#htmldirectoryelement">HTMLDirectoryElement</a></code></li><li><code id="all-interfaces:htmldivelement"><a href="#htmldivelement">HTMLDivElement</a></code>, <a href="#HTMLDivElement-partial">partial</a></li><li><code id="all-interfaces:htmlelement"><a href="#htmlelement">HTMLElement</a></code></li><li><code id="all-interfaces:htmlembedelement"><a href="#htmlembedelement">HTMLEmbedElement</a></code>, <a href="#HTMLEmbedElement-partial">partial</a></li><li><code id="all-interfaces:htmlfieldsetelement"><a href="#htmlfieldsetelement">HTMLFieldSetElement</a></code></li><li><code id="all-interfaces:htmlfontelement"><a href="#htmlfontelement">HTMLFontElement</a></code></li><li><code id="all-interfaces:htmlformcontrolscollection"><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code></li><li><code id="all-interfaces:htmlformelement"><a href="#htmlformelement">HTMLFormElement</a></code></li><li><code id="all-interfaces:htmlframeelement"><a href="#htmlframeelement">HTMLFrameElement</a></code></li><li><code id="all-interfaces:htmlframesetelement"><a href="#htmlframesetelement">HTMLFrameSetElement</a></code></li><li><code id="all-interfaces:htmlhrelement"><a href="#htmlhrelement">HTMLHRElement</a></code>, <a href="#HTMLHRElement-partial">partial</a></li><li><code id="all-interfaces:htmlheadelement"><a href="#htmlheadelement">HTMLHeadElement</a></code></li><li><code id="all-interfaces:htmlheadingelement"><a href="#htmlheadingelement">HTMLHeadingElement</a></code>, <a href="#HTMLHeadingElement-partial">partial</a></li><li><code id="all-interfaces:htmlhtmlelement"><a href="#htmlhtmlelement">HTMLHtmlElement</a></code>, <a href="#HTMLHtmlElement-partial">partial</a></li><li><code id="all-interfaces:htmliframeelement"><a href="#htmliframeelement">HTMLIFrameElement</a></code>, <a href="#HTMLIFrameElement-partial">partial</a></li><li><code id="all-interfaces:htmlimageelement"><a href="#htmlimageelement">HTMLImageElement</a></code>, <a href="#HTMLImageElement-partial">partial</a></li><li><code id="all-interfaces:htmlinputelement"><a href="#htmlinputelement">HTMLInputElement</a></code>, <a href="#HTMLInputElement-partial">partial</a></li><li><code id="all-interfaces:htmllielement"><a href="#htmllielement">HTMLLIElement</a></code>, <a href="#HTMLLIElement-partial">partial</a></li><li><code id="all-interfaces:htmllabelelement"><a href="#htmllabelelement">HTMLLabelElement</a></code></li><li><code id="all-interfaces:htmllegendelement"><a href="#htmllegendelement">HTMLLegendElement</a></code>, <a href="#HTMLLegendElement-partial">partial</a></li><li><code id="all-interfaces:htmllinkelement"><a href="#htmllinkelement">HTMLLinkElement</a></code>, <a href="#HTMLLinkElement-partial">partial</a></li><li><code id="all-interfaces:htmlmapelement"><a href="#htmlmapelement">HTMLMapElement</a></code></li><li><code id="all-interfaces:htmlmarqueeelement"><a href="#htmlmarqueeelement">HTMLMarqueeElement</a></code></li><li><code id="all-interfaces:htmlmediaelement"><a href="#htmlmediaelement">HTMLMediaElement</a></code></li><li><code id="all-interfaces:htmlmenuelement"><a href="#htmlmenuelement">HTMLMenuElement</a></code>, <a href="#HTMLMenuElement-partial">partial</a></li><li><code id="all-interfaces:htmlmetaelement"><a href="#htmlmetaelement">HTMLMetaElement</a></code>, <a href="#HTMLMetaElement-partial">partial</a></li><li><code id="all-interfaces:htmlmeterelement"><a href="#htmlmeterelement">HTMLMeterElement</a></code></li><li><code id="all-interfaces:htmlmodelement"><a href="#htmlmodelement">HTMLModElement</a></code></li><li><code id="all-interfaces:htmlolistelement"><a href="#htmlolistelement">HTMLOListElement</a></code>, <a href="#HTMLOListElement-partial">partial</a></li><li><code id="all-interfaces:htmlobjectelement"><a href="#htmlobjectelement">HTMLObjectElement</a></code>, <a href="#HTMLObjectElement-partial">partial</a></li><li><code id="all-interfaces:htmloptgroupelement"><a href="#htmloptgroupelement">HTMLOptGroupElement</a></code></li><li><code id="all-interfaces:htmloptionelement"><a href="#htmloptionelement">HTMLOptionElement</a></code></li><li><code id="all-interfaces:htmloptionscollection"><a href="#htmloptionscollection">HTMLOptionsCollection</a></code></li><li><code id="all-interfaces:htmloutputelement"><a href="#htmloutputelement">HTMLOutputElement</a></code></li><li><code id="all-interfaces:htmlparagraphelement"><a href="#htmlparagraphelement">HTMLParagraphElement</a></code>, <a href="#HTMLParagraphElement-partial">partial</a></li><li><code id="all-interfaces:htmlparamelement"><a href="#htmlparamelement">HTMLParamElement</a></code></li><li><code id="all-interfaces:htmlpictureelement"><a href="#htmlpictureelement">HTMLPictureElement</a></code></li><li><code id="all-interfaces:htmlpreelement"><a href="#htmlpreelement">HTMLPreElement</a></code>, <a href="#HTMLPreElement-partial">partial</a></li><li><code id="all-interfaces:htmlprogresselement"><a href="#htmlprogresselement">HTMLProgressElement</a></code></li><li><code id="all-interfaces:htmlquoteelement"><a href="#htmlquoteelement">HTMLQuoteElement</a></code></li><li><code id="all-interfaces:htmlscriptelement"><a href="#htmlscriptelement">HTMLScriptElement</a></code>, <a href="#HTMLScriptElement-partial">partial</a></li><li><code id="all-interfaces:htmlselectelement"><a href="#htmlselectelement">HTMLSelectElement</a></code></li><li><code id="all-interfaces:htmlselectedcontentelement"><a href="#htmlselectedcontentelement">HTMLSelectedContentElement</a></code></li><li><code id="all-interfaces:htmlslotelement"><a href="#htmlslotelement">HTMLSlotElement</a></code></li><li><code id="all-interfaces:htmlsourceelement"><a href="#htmlsourceelement">HTMLSourceElement</a></code></li><li><code id="all-interfaces:htmlspanelement"><a href="#htmlspanelement">HTMLSpanElement</a></code></li><li><code id="all-interfaces:htmlstyleelement"><a href="#htmlstyleelement">HTMLStyleElement</a></code>, <a href="#HTMLStyleElement-partial">partial</a></li><li><code id="all-interfaces:htmltablecaptionelement"><a href="#htmltablecaptionelement">HTMLTableCaptionElement</a></code>, <a href="#HTMLTableCaptionElement-partial">partial</a></li><li><code id="all-interfaces:htmltablecellelement"><a href="#htmltablecellelement">HTMLTableCellElement</a></code>, <a href="#HTMLTableCellElement-partial">partial</a></li><li><code id="all-interfaces:htmltablecolelement"><a href="#htmltablecolelement">HTMLTableColElement</a></code>, <a href="#HTMLTableColElement-partial">partial</a></li><li><code id="all-interfaces:htmltableelement"><a href="#htmltableelement">HTMLTableElement</a></code>, <a href="#HTMLTableElement-partial">partial</a></li><li><code id="all-interfaces:htmltablerowelement"><a href="#htmltablerowelement">HTMLTableRowElement</a></code>, <a href="#HTMLTableRowElement-partial">partial</a></li><li><code id="all-interfaces:htmltablesectionelement"><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code>, <a href="#HTMLTableSectionElement-partial">partial</a></li><li><code id="all-interfaces:htmltemplateelement"><a href="#htmltemplateelement">HTMLTemplateElement</a></code></li><li><code id="all-interfaces:htmltextareaelement"><a href="#htmltextareaelement">HTMLTextAreaElement</a></code></li><li><code id="all-interfaces:htmltimeelement"><a href="#htmltimeelement">HTMLTimeElement</a></code></li><li><code id="all-interfaces:htmltitleelement"><a href="#htmltitleelement">HTMLTitleElement</a></code></li><li><code id="all-interfaces:htmltrackelement"><a href="#htmltrackelement">HTMLTrackElement</a></code></li><li><code id="all-interfaces:htmlulistelement"><a href="#htmlulistelement">HTMLUListElement</a></code>, <a href="#HTMLUListElement-partial">partial</a></li><li><code id="all-interfaces:htmlunknownelement"><a href="#htmlunknownelement">HTMLUnknownElement</a></code></li><li><code id="all-interfaces:htmlvideoelement"><a href="#htmlvideoelement">HTMLVideoElement</a></code></li><li><code id="all-interfaces:hashchangeevent"><a href="#hashchangeevent">HashChangeEvent</a></code></li><li><code id="all-interfaces:history-3"><a href="#history-3">History</a></code></li><li><code id="all-interfaces:imagebitmap"><a href="#imagebitmap">ImageBitmap</a></code></li><li><code id="all-interfaces:imagebitmaprenderingcontext"><a href="#imagebitmaprenderingcontext">ImageBitmapRenderingContext</a></code></li><li><code id="all-interfaces:imagedata"><a href="#imagedata">ImageData</a></code></li><li><code id="all-interfaces:location"><a href="#location">Location</a></code></li><li><code id="all-interfaces:mediaerror"><a href="#mediaerror">MediaError</a></code></li><li><code id="all-interfaces:messagechannel"><a href="#messagechannel">MessageChannel</a></code></li><li><code id="all-interfaces:messageevent"><a href="#messageevent">MessageEvent</a></code></li><li><code id="all-interfaces:messageport"><a href="#messageport">MessagePort</a></code></li><li><code id="all-interfaces:mimetype"><a href="#mimetype">MimeType</a></code></li><li><code id="all-interfaces:mimetypearray"><a href="#mimetypearray">MimeTypeArray</a></code></li><li><code id="all-interfaces:navigateevent"><a href="#navigateevent">NavigateEvent</a></code></li><li><code id="all-interfaces:navigation"><a href="#navigation">Navigation</a></code></li><li><code id="all-interfaces:navigationactivation"><a href="#navigationactivation">NavigationActivation</a></code></li><li><code id="all-interfaces:navigationcurrententrychangeevent"><a href="#navigationcurrententrychangeevent">NavigationCurrentEntryChangeEvent</a></code></li><li><code id="all-interfaces:navigationdestination"><a href="#navigationdestination">NavigationDestination</a></code></li><li><code id="all-interfaces:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code></li><li><code id="all-interfaces:navigationprecommitcontroller"><a href="#navigationprecommitcontroller">NavigationPrecommitController</a></code></li><li><code id="all-interfaces:navigationtransition"><a href="#navigationtransition">NavigationTransition</a></code></li><li><code id="all-interfaces:navigator"><a href="#navigator">Navigator</a></code>, <a href="#NavigatorUserActivation-partial">partial</a></li><li><code id="all-interfaces:notrestoredreasondetails"><a href="#notrestoredreasondetails">NotRestoredReasonDetails</a></code></li><li><code id="all-interfaces:notrestoredreasons"><a href="#notrestoredreasons">NotRestoredReasons</a></code></li><li><code id="all-interfaces:offscreencanvas"><a href="#offscreencanvas">OffscreenCanvas</a></code></li><li><code id="all-interfaces:offscreencanvasrenderingcontext2d"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code></li><li><code id="all-interfaces:pagerevealevent"><a href="#pagerevealevent">PageRevealEvent</a></code></li><li><code id="all-interfaces:pageswapevent"><a href="#pageswapevent">PageSwapEvent</a></code></li><li><code id="all-interfaces:pagetransitionevent"><a href="#pagetransitionevent">PageTransitionEvent</a></code></li><li><code id="all-interfaces:path2d"><a href="#path2d">Path2D</a></code></li><li><code id="all-interfaces:plugin"><a href="#plugin">Plugin</a></code></li><li><code id="all-interfaces:pluginarray"><a href="#pluginarray">PluginArray</a></code></li><li><code id="all-interfaces:popstateevent"><a href="#popstateevent">PopStateEvent</a></code></li><li><code id="all-interfaces:promiserejectionevent"><a href="#promiserejectionevent">PromiseRejectionEvent</a></code></li><li><code id="all-interfaces:radionodelist"><a href="#radionodelist">RadioNodeList</a></code></li><li><code id="all-interfaces:range"><a data-x-internal="range" href="https://dom.spec.whatwg.org/#interface-range">Range</a></code>, <a href="#Range-partial">partial</a></li><li><code id="all-interfaces:shadowroot"><a data-x-internal="shadowroot" href="https://dom.spec.whatwg.org/#interface-shadowroot">ShadowRoot</a></code>, <a href="#ShadowRoot-partial">partial</a></li><li><code id="all-interfaces:sharedworker"><a href="#sharedworker">SharedWorker</a></code></li><li><code id="all-interfaces:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code></li><li><code id="all-interfaces:storage-2"><a href="#storage-2">Storage</a></code></li><li><code id="all-interfaces:storageevent"><a href="#storageevent">StorageEvent</a></code></li><li><code id="all-interfaces:submitevent"><a href="#submitevent">SubmitEvent</a></code></li><li><code id="all-interfaces:textmetrics"><a href="#textmetrics">TextMetrics</a></code></li><li><code id="all-interfaces:texttrack"><a href="#texttrack">TextTrack</a></code></li><li><code id="all-interfaces:texttrackcue"><a href="#texttrackcue">TextTrackCue</a></code></li><li><code id="all-interfaces:texttrackcuelist"><a href="#texttrackcuelist">TextTrackCueList</a></code></li><li><code id="all-interfaces:texttracklist"><a href="#texttracklist">TextTrackList</a></code></li><li><code id="all-interfaces:timeranges"><a href="#timeranges">TimeRanges</a></code></li><li><code id="all-interfaces:toggleevent"><a href="#toggleevent">ToggleEvent</a></code></li><li><code id="all-interfaces:trackevent"><a href="#trackevent">TrackEvent</a></code></li><li><code id="all-interfaces:useractivation"><a href="#useractivation">UserActivation</a></code></li><li><code id="all-interfaces:validitystate"><a href="#validitystate">ValidityState</a></code></li><li><code id="all-interfaces:videotrack"><a href="#videotrack">VideoTrack</a></code></li><li><code id="all-interfaces:videotracklist"><a href="#videotracklist">VideoTrackList</a></code></li><li><code id="all-interfaces:visibilitystateentry"><a href="#visibilitystateentry">VisibilityStateEntry</a></code></li><li><code id="all-interfaces:window"><a href="#window">Window</a></code>, <a href="#Window-partial">partial</a></li><li><code id="all-interfaces:worker"><a href="#worker">Worker</a></code></li><li><code id="all-interfaces:workerglobalscope"><a href="#workerglobalscope">WorkerGlobalScope</a></code></li><li><code id="all-interfaces:workerlocation"><a href="#workerlocation">WorkerLocation</a></code></li><li><code id="all-interfaces:workernavigator"><a href="#workernavigator">WorkerNavigator</a></code></li><li><code id="all-interfaces:worklet"><a href="#worklet">Worklet</a></code></li><li><code id="all-interfaces:workletglobalscope"><a href="#workletglobalscope">WorkletGlobalScope</a></code></li><li><code id="all-interfaces:xmlserializer"><a href="#xmlserializer">XMLSerializer</a></code></li></ul>


  <h3 id="events-2" class="no-num">Events<a href="#events-2" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>The following table lists events fired by this document, excluding those
  already defined in <a href="#mediaevents">media element events</a> and
  <a href="#dndevents">drag-and-drop events</a>.</p>

  <table><caption>List of events</caption><thead><tr><th> Event
     </th><th> Interface
     </th><th> Interesting targets
     </th><th> Description
   </th></tr></thead><tbody><tr><td> <dfn data-dfn-for="Document" id="event-domcontentloaded" data-dfn-type="event"><code>DOMContentLoaded</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event" title="The DOMContentLoaded event fires when the HTML document has been completely parsed, and all deferred scripts (<script defer src=&quot;…&quot;> and <script type=&quot;module&quot;>) have downloaded and executed. It doesn't wait for other things like images, subframes, and async scripts to finish loading.">Window/DOMContentLoaded_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3.1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></td><td> <code id="events-2:event"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:document"><a href="#document">Document</a></code>
     </td><td> Fired at the <code id="events-2:document-2"><a href="#document">Document</a></code> once the parser has finished

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-afterprint" data-dfn-type="event"><code>afterprint</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/afterprint_event" title="The afterprint event is fired after the associated document has started printing or the print preview has been closed.">Window/afterprint_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>13+</span></span><span class="chrome yes"><span>Chrome</span><span>63+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-2"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:window"><a href="#window">Window</a></code>
     </td><td> Fired at the <code id="events-2:window-2"><a href="#window">Window</a></code> after printing

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-beforeprint" data-dfn-type="event"><code>beforeprint</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeprint_event" title="The beforeprint event is fired when the associated document is about to be printed or previewed for printing.">Window/beforeprint_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>13+</span></span><span class="chrome yes"><span>Chrome</span><span>63+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-3"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:window-3"><a href="#window">Window</a></code>
     </td><td> Fired at the <code id="events-2:window-4"><a href="#window">Window</a></code> before printing

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-beforematch" data-dfn-type="event"><code>beforematch</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/beforematch_event" title="An element receives a beforematch event when it is in the hidden until found state and the browser is about to reveal its content because the user has found the content through the &quot;find in page&quot; feature or through fragment navigation.">Element/beforematch_event</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>102+</span></span><hr><span class="opera no"><span>Opera</span><span>No</span></span><span class="edge_blink yes"><span>Edge</span><span>102+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-4"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> Elements
     </td><td> Fired on elements with the <code id="events-2:attr-hidden-until-found-state"><a href="#attr-hidden-until-found-state">hidden=until-found</a></code> attribute before they are
     revealed.

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-beforetoggle" data-dfn-type="event"><code>beforetoggle</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforetoggle_event" title="The beforetoggle event of the HTMLElement interface fires on a popover element (i.e. one that has a valid popover attribute) just before it is shown or hidden.">HTMLElement/beforetoggle_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>preview+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:toggleevent"><a href="#toggleevent">ToggleEvent</a></code>
     </td><td> Elements
     </td><td> Fired on elements with the <code id="events-2:attr-popover"><a href="#attr-popover">popover</a></code> attribute when they
     are transitioning between showing and hidden

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-beforeunload" data-dfn-type="event"><code>beforeunload</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event" title="The beforeunload event is fired when the window, the document and its resources are about to be unloaded. The document is still visible and the event is still cancelable at this point.">Window/beforeunload_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td> <code id="events-2:beforeunloadevent"><a href="#beforeunloadevent">BeforeUnloadEvent</a></code>
     </td><td> <code id="events-2:window-5"><a href="#window">Window</a></code>
     </td><td> Fired at the <code id="events-2:window-6"><a href="#window">Window</a></code> when the page is about to be unloaded, in case the page would like to show a warning prompt

    </td></tr><tr><td> <dfn data-dfn-for="Window,HTMLElement" id="event-blur" data-dfn-type="event"><code>blur</code></dfn>
     </td><td> <code id="events-2:event-5"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:window-7"><a href="#window">Window</a></code>, elements
     </td><td> Fired at nodes when they stop being <a href="#focused" id="events-2:focused">focused</a>

    </td></tr><tr><td> <dfn data-dfn-for="CloseWatcher,HTMLElement" id="event-cancel" data-dfn-type="event"><code>cancel</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/cancel_event" title="The cancel event fires on a <dialog> when the user instructs the browser that they wish to dismiss the current open dialog. The browser fires this event when the user presses the Esc key.">HTMLDialogElement/cancel_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android no"><span>Chrome Android</span><span>No</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-6"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:closewatcher"><a href="#closewatcher">CloseWatcher</a></code>, <code id="events-2:the-dialog-element"><a href="#the-dialog-element">dialog</a></code> elements, <code id="events-2:the-input-element"><a href="#the-input-element">input</a></code> elements
     </td><td> Fired at <code id="events-2:closewatcher-2"><a href="#closewatcher">CloseWatcher</a></code> objects or <code id="events-2:the-dialog-element-2"><a href="#the-dialog-element">dialog</a></code> elements when they receive a <a href="#close-request" id="events-2:close-request">close request</a>, or at <code id="events-2:the-input-element-2"><a href="#the-input-element">input</a></code> elements whose <code id="events-2:attr-input-type"><a href="#attr-input-type">type</a></code> attribute is in the <a href="#file-upload-state-(type=file)" id="events-2:file-upload-state-(type=file)">File</a> state when the user does not change their selection

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-change" data-dfn-type="event"><code id="event-input-change">change</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event" title="The change event is fired for <input>, <select>, and <textarea> elements when the user modifies the element's value. Unlike the input event, the change event is not necessarily fired for each alteration to an element's value.">HTMLElement/change_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>9+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></td><td> <code id="events-2:event-7"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> Form controls
     </td><td> Fired at controls when the user commits a value change (see also the <code id="events-2:event-input"><a data-x-internal="event-input" href="https://w3c.github.io/uievents/#event-type-input">input</a></code> event)

    </td></tr><tr><td> <code id="events-2:event-click"><a data-x-internal="event-click" href="https://w3c.github.io/uievents/#event-type-click">click</a></code>
     </td><td> <code id="events-2:pointerevent"><a data-x-internal="pointerevent" href="https://w3c.github.io/pointerevents/#pointerevent-interface">PointerEvent</a></code>
     </td><td> Elements
     </td><td> Normally a mouse event; also synthetically fired at an element before its <a id="events-2:activation-behaviour" href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior" data-x-internal="activation-behaviour">activation behavior</a> is run, when an element is activated from a non-pointer input device (e.g. a keyboard)

    </td></tr><tr><td> <dfn data-dfn-for="CloseWatcher,HTMLElement,MessagePort" id="event-close" data-dfn-type="event"><code>close</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/close_event" title="The close event is fired on an HTMLDialogElement object when the <dialog> it represents has been closed.">HTMLDialogElement/close_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>98+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-8"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:closewatcher-3"><a href="#closewatcher">CloseWatcher</a></code>, <code id="events-2:the-dialog-element-3"><a href="#the-dialog-element">dialog</a></code> elements, <code id="events-2:messageport"><a href="#messageport">MessagePort</a></code>
     </td><td> Fired at <code id="events-2:closewatcher-4"><a href="#closewatcher">CloseWatcher</a></code> objects or <code id="events-2:the-dialog-element-4"><a href="#the-dialog-element">dialog</a></code> elements when they are closed via a <a href="#close-request" id="events-2:close-request-2">close request</a> or via web developer code, or at <code id="events-2:messageport-2"><a href="#messageport">MessagePort</a></code> objects when <a href="#disentangle" id="events-2:disentangle">disentangled</a>

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-command" data-dfn-type="event"><code>command</code></dfn>
     </td><td> <code id="events-2:commandevent"><a href="#commandevent">CommandEvent</a></code>
     </td><td> Elements
     </td><td> Fired at elements when they handle a user invocation, via a <code id="events-2:attr-button-commandfor"><a href="#attr-button-commandfor">commandfor</a></code> attribute.

    </td></tr><tr><td> <dfn data-dfn-for="SharedWorkerGlobalScope" id="event-workerglobalscope-connect" data-dfn-type="event"><code>connect</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/SharedWorkerGlobalScope/connect_event" title="The connect event is fired in shared workers at their SharedWorkerGlobalScope when a new client connects.">SharedWorkerGlobalScope/connect_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>29+</span></span><span class="safari yes"><span>Safari</span><span>16+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>16+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="events-2:messageevent"><a href="#messageevent">MessageEvent</a></code>
     </td><td> <code id="events-2:sharedworkerglobalscope"><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code>
     </td><td> Fired at a shared worker's global scope when a new client connects

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement,OffscreenCanvas" id="event-contextlost" data-dfn-type="event"><code>contextlost</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event" title="The webglcontextlost event of the WebGL API is fired if the user agent detects that the drawing buffer associated with a WebGLRenderingContext object has been lost.">HTMLCanvasElement/webglcontextlost_event</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>98+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>98+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-9"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> elements, <code id="events-2:offscreencanvas"><a href="#offscreencanvas">OffscreenCanvas</a></code> objects
     </td><td> Fired when the corresponding <code id="events-2:canvasrenderingcontext2d"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> or <code id="events-2:offscreencanvasrenderingcontext2d"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code> is lost

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement,OffscreenCanvas" id="event-contextrestored" data-dfn-type="event"><code>contextrestored</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in one engine only." class="less-than-two-engines-flag">⚠</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/contextrestored_event" title="The contextrestored event of the Canvas API is fired if the user agent restores the backing storage for a CanvasRenderingContext2D.">HTMLCanvasElement/contextrestored_event</a></p><p class="less-than-two-engines-text">Support in one engine only.</p><div class="support"><span class="firefox no"><span>Firefox</span><span>No</span></span><span class="safari no"><span>Safari</span><span>No</span></span><span class="chrome yes"><span>Chrome</span><span>98+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>98+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-10"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:the-canvas-element-2"><a href="#the-canvas-element">canvas</a></code> elements, <code id="events-2:offscreencanvas-2"><a href="#offscreencanvas">OffscreenCanvas</a></code> objects
     </td><td> Fired when the corresponding <code id="events-2:canvasrenderingcontext2d-2"><a href="#canvasrenderingcontext2d">CanvasRenderingContext2D</a></code> or <code id="events-2:offscreencanvasrenderingcontext2d-2"><a href="#offscreencanvasrenderingcontext2d">OffscreenCanvasRenderingContext2D</a></code> is restored after being lost

    </td></tr><tr><td> <dfn data-dfn-for="Navigation" id="event-currententrychange" data-dfn-type="event"><code>currententrychange</code></dfn>
     </td><td> <code id="events-2:navigationcurrententrychangeevent"><a href="#navigationcurrententrychangeevent">NavigationCurrentEntryChangeEvent</a></code>
     </td><td> <code id="events-2:navigation"><a href="#navigation">Navigation</a></code>
     </td><td> Fired when <code id="events-2:dom-navigation-currententry"><a href="#dom-navigation-currententry">navigation.currentEntry</a></code> changes

    </td></tr><tr><td> <dfn data-dfn-for="NavigationHistoryEntry" id="event-dispose" data-dfn-type="event"><code>dispose</code></dfn>
     </td><td> <code id="events-2:event-11"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:navigationhistoryentry"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code>
     </td><td> Fired when the <a href="#session-history-entry" id="events-2:session-history-entry">session history entry</a> corresponding to the <code id="events-2:navigationhistoryentry-2"><a href="#navigationhistoryentry">NavigationHistoryEntry</a></code> has been permanently evicted from session history and can no longer be traversed to

    </td></tr><tr><td> <dfn data-dfn-for="Window,WorkerGlobalScope,HTMLElement,EventSource,Worker,SharedWorker,AbstractWorker" id="event-error" data-dfn-type="event"><code>error</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/error_event" title="The error event of the EventSource API is fired when a connection with an event source fails to be opened.">EventSource/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event" title="The error event is fired on a Window object when a resource failed to load or couldn't be used — for example if a script has an execution error.">Window/error_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-12"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code> or <code id="events-2:errorevent"><a href="#errorevent">ErrorEvent</a></code>
     </td><td> Global scope objects, <code id="events-2:worker"><a href="#worker">Worker</a></code> objects, elements, networking-related objects
     </td><td> Fired when unexpected errors occur (e.g. networking errors, script errors, decoding errors)

    </td></tr><tr><td> <dfn data-dfn-for="Window,HTMLElement" id="event-focus" data-dfn-type="event"><code>focus</code></dfn>
     </td><td> <code id="events-2:event-13"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:window-8"><a href="#window">Window</a></code>, elements
     </td><td> Fired at nodes <a href="#gains-focus" id="events-2:gains-focus">gaining focus</a>

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-formdata" data-dfn-type="event"><code>formdata</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/formdata_event" title="The formdata event fires after the entry list representing the form's data is constructed. This happens when the form is submitted, but can also be triggered by the invocation of a FormData() constructor.">HTMLFormElement/formdata_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>72+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>77+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:formdataevent"><a href="#formdataevent">FormDataEvent</a></code>
     </td><td> <code id="events-2:the-form-element"><a href="#the-form-element">form</a></code> elements
     </td><td> Fired at a <code id="events-2:the-form-element-2"><a href="#the-form-element">form</a></code> element when it is <a href="#constructing-the-form-data-set" id="events-2:constructing-the-form-data-set">constructing the entry list</a>

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-hashchange" data-dfn-type="event"><code>hashchange</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/hashchange_event" title="The hashchange event is fired when the fragment identifier of the URL has changed (the part of the URL beginning with and following the # symbol).">Window/hashchange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>8+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div></td><td> <code id="events-2:hashchangeevent"><a href="#hashchangeevent">HashChangeEvent</a></code>
     </td><td> <code id="events-2:window-9"><a href="#window">Window</a></code>
     </td><td> Fired at the <code id="events-2:window-10"><a href="#window">Window</a></code> when the <a href="https://url.spec.whatwg.org/#concept-url-fragment" id="events-2:concept-url-fragment" data-x-internal="concept-url-fragment">fragment</a> part of the document's <a href="https://dom.spec.whatwg.org/#concept-document-url" id="events-2:the-document's-address" data-x-internal="the-document's-address">URL</a> changes

    </td></tr><tr><td> <a id="events-2:event-input-2" href="https://w3c.github.io/uievents/#event-type-input" data-x-internal="event-input"><code>input</code></a>
     </td><td> <code id="events-2:event-14"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> Elements
     </td><td> Fired when the user changes the <code id="events-2:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code> element's content, or the form control's value. See also the <code id="events-2:event-change"><a href="#event-change">change</a></code> event for form controls.

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-invalid" data-dfn-type="event"><code>invalid</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/invalid_event" title="The invalid event fires when a submittable element has been checked for validity and doesn't satisfy its constraints.">HTMLInputElement/invalid_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>10+</span></span><hr><span class="opera yes"><span>Opera</span><span>10+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>64+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>4+</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>4.0+</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td> <code id="events-2:event-15"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> Form controls
     </td><td> Fired at controls during form validation if they do not satisfy their constraints

    </td></tr><tr><td> <dfn data-dfn-for="Window,WorkerGlobalScope" id="event-languagechange" data-dfn-type="event"><code>languagechange</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/languagechange_event" title="The languagechange event is fired at the global scope object when the user's preferred language changes.">Window/languagechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>32+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>37+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>4+</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android yes"><span>Samsung Internet</span><span>4.0+</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/languagechange_event" title="The languagechange event is fired at the global scope object when the user's preferred language changes.">WorkerGlobalScope/languagechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>74+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-16"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> Global scope objects
     </td><td> Fired at the global scope object when the user's preferred languages change

    </td></tr><tr><td> <dfn data-dfn-for="Window,HTMLElement" id="event-load" data-dfn-type="event"><code>load</code></dfn>
     </td><td> <code id="events-2:event-17"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:window-11"><a href="#window">Window</a></code>, elements
     </td><td> Fired at the <code id="events-2:window-12"><a href="#window">Window</a></code> when the document has finished loading; fired at an element containing a resource (e.g. <code id="events-2:the-img-element"><a href="#the-img-element">img</a></code>, <code id="events-2:the-embed-element"><a href="#the-embed-element">embed</a></code>) when its resource has finished loading

    </td></tr><tr><td> <dfn data-dfn-for="Window,EventSource,MessagePort,BroadcastChannel,DedicatedWorkerGlobalScope,Worker,ServiceWorkerContainer" id="event-message" data-dfn-type="event"><code>message</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/message_event" title="The message event is fired on a BroadcastChannel object when a message arrives on that channel.">BroadcastChannel/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>38+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>54+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/message_event" title="The message event is fired on a DedicatedWorkerGlobalScope object when the worker receives a message from its parent (i.e. when the parent sends a message using Worker.postMessage()).">DedicatedWorkerGlobalScope/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.5+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/message_event" title="The message event of the EventSource API is fired when data is received through an event source.">EventSource/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/message_event" title="The message event is fired on a MessagePort object when a message arrives on that channel.">MessagePort/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>41+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.5+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/message_event" title="The message event is fired on a Window object when the window receives a message, for example from a call to Window.postMessage() from another browsing context.">Window/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>8+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker/message_event" title="The message event is fired on a Worker object when the worker's parent receives a message from its worker (i.e. when the worker sends a message using DedicatedWorkerGlobalScope.postMessage()).">Worker/message_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>3.5+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.5+</span></span></div></div></div></td><td> <code id="events-2:messageevent-2"><a href="#messageevent">MessageEvent</a></code>
     </td><td> <code id="events-2:window-13"><a href="#window">Window</a></code>, <code id="events-2:eventsource"><a href="#eventsource">EventSource</a></code>, <code id="events-2:messageport-3"><a href="#messageport">MessagePort</a></code>, <code id="events-2:broadcastchannel"><a href="#broadcastchannel">BroadcastChannel</a></code>, <code id="events-2:dedicatedworkerglobalscope"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code>, <code id="events-2:worker-2"><a href="#worker">Worker</a></code>, <code id="events-2:serviceworkercontainer"><a data-x-internal="serviceworkercontainer" href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer">ServiceWorkerContainer</a></code>
     </td><td> Fired at an object when it receives a message

    </td></tr><tr><td> <dfn data-dfn-for="Window,MessagePort,BroadcastChannel,DedicatedWorkerGlobalScope,Worker,ServiceWorkerContainer" id="event-messageerror" data-dfn-type="event"><code>messageerror</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/messageerror_event" title="The messageerror event is fired on a BroadcastChannel object when a message that can't be deserialized arrives on the channel.">BroadcastChannel/messageerror_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>15.4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/messageerror_event" title="The messageerror event is fired on a DedicatedWorkerGlobalScope object when it receives a message that can't be deserialized.">DedicatedWorkerGlobalScope/messageerror_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/messageerror_event" title="The messageerror event is fired on a MessagePort object when it receives a message that can't be deserialized.">MessagePort/messageerror_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/messageerror_event" title="The messageerror event is fired on a Window object when it receives a message that can't be deserialized.">Window/messageerror_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker/messageerror_event" title="The messageerror event is fired on a Worker object when it receives a message that can't be deserialized.">Worker/messageerror_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>57+</span></span><span class="safari yes"><span>Safari</span><span>16.4+</span></span><span class="chrome yes"><span>Chrome</span><span>60+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>47+</span></span></div></div></div></td><td> <code id="events-2:messageevent-3"><a href="#messageevent">MessageEvent</a></code>
     </td><td> <code id="events-2:window-14"><a href="#window">Window</a></code>, <code id="events-2:messageport-4"><a href="#messageport">MessagePort</a></code>, <code id="events-2:broadcastchannel-2"><a href="#broadcastchannel">BroadcastChannel</a></code>, <code id="events-2:dedicatedworkerglobalscope-2"><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code>, <code id="events-2:worker-3"><a href="#worker">Worker</a></code>, <code id="events-2:serviceworkercontainer-2"><a data-x-internal="serviceworkercontainer" href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer">ServiceWorkerContainer</a></code>
     </td><td> Fired at an object when it receives a message that cannot be deserialized

    </td></tr><tr><td> <dfn data-dfn-for="Navigation" id="event-navigate" data-dfn-type="event"><code>navigate</code></dfn>
     </td><td> <code id="events-2:navigateevent"><a href="#navigateevent">NavigateEvent</a></code>
     </td><td> <code id="events-2:navigation-2"><a href="#navigation">Navigation</a></code>
     </td><td> Fired before the <a href="#navigable" id="events-2:navigable">navigable</a> <a href="#navigate" id="events-2:navigate">navigates</a>, <a href="#reload" id="events-2:reload">reloads</a>, <a href="#traverse-the-history-by-a-delta" id="events-2:traverse-the-history-by-a-delta">traverses</a>, or <a href="#shared-history-push/replace-state-steps" id="events-2:shared-history-push/replace-state-steps">otherwise</a> changes its URL

    </td></tr><tr><td> <dfn data-dfn-for="Navigation" id="event-navigateerror" data-dfn-type="event"><code>navigateerror</code></dfn>
     </td><td> <code id="events-2:errorevent-2"><a href="#errorevent">ErrorEvent</a></code>
     </td><td> <code id="events-2:navigation-3"><a href="#navigation">Navigation</a></code>
     </td><td> Fired when a navigation does not complete successfully

    </td></tr><tr><td> <dfn data-dfn-for="Navigation" id="event-navigatesuccess" data-dfn-type="event"><code>navigatesuccess</code></dfn>
     </td><td> <code id="events-2:event-18"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:navigation-4"><a href="#navigation">Navigation</a></code>
     </td><td> Fired when a navigation completes successfully

    </td></tr><tr><td> <dfn data-dfn-for="Window,WorkerGlobalScope" id="event-offline" data-dfn-type="event"><code>offline</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/offline_event" title="The offline event of the Window interface is fired when the browser has lost access to the network and the value of Navigator.onLine switches to false.">Window/offline_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-19"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> Global scope objects
     </td><td> Fired at the global scope object when the network connections fails

    </td></tr><tr><td> <dfn data-dfn-for="Window,WorkerGlobalScope" id="event-online" data-dfn-type="event"><code>online</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/online_event" title="The online event of the Window interface is fired when the browser has gained access to the network and the value of Navigator.onLine switches to true.">Window/online_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>9+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:event-20"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> Global scope objects
     </td><td> Fired at the global scope object when the network connections returns

    </td></tr><tr><td> <dfn data-dfn-for="EventSource" id="event-open" data-dfn-type="event"><code>open</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource/open_event" title="The open event of the EventSource API is fired when a connection with an event source is opened.">EventSource/open_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>6+</span></span><hr><span class="opera yes"><span>Opera</span><span>12+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android yes"><span>Firefox Android</span><span>45+</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>5+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12+</span></span></div></div></div></td><td> <code id="events-2:event-21"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:eventsource-2"><a href="#eventsource">EventSource</a></code>
     </td><td> Fired at <code id="events-2:eventsource-3"><a href="#eventsource">EventSource</a></code> objects when a connection is established

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-pageswap" data-dfn-type="event"><code>pageswap</code></dfn>
     </td><td> <code id="events-2:pageswapevent"><a href="#pageswapevent">PageSwapEvent</a></code>
     </td><td> <code id="events-2:window-15"><a href="#window">Window</a></code>
     </td><td>Fired at the <code id="events-2:window-16"><a href="#window">Window</a></code> right before a document is <a href="#unload-a-document" id="events-2:unload-a-document">unloaded</a> as a result of a navigation.

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-pagehide" data-dfn-type="event"><code>pagehide</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_event" title="The pagehide event is sent to a Window when the browser hides the current page in the process of presenting a different page from the session's history.">Window/pagehide_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:pagetransitionevent"><a href="#pagetransitionevent">PageTransitionEvent</a></code>
     </td><td> <code id="events-2:window-17"><a href="#window">Window</a></code>
     </td><td> Fired at the <code id="events-2:window-18"><a href="#window">Window</a></code> when the page's <a href="#session-history-entry" id="events-2:session-history-entry-2">session history entry</a> stops
     being the <a href="#nav-active-history-entry" id="events-2:nav-active-history-entry">active entry</a>

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-pagereveal" data-dfn-type="event"><code>pagereveal</code></dfn>
     </td><td> <code id="events-2:pagerevealevent"><a href="#pagerevealevent">PageRevealEvent</a></code>
     </td><td> <code id="events-2:window-19"><a href="#window">Window</a></code>
     </td><td> Fired at the <code id="events-2:window-20"><a href="#window">Window</a></code> when the page begins to render for the first time after
     it has been initialized or <a href="#reactivate-a-document" id="events-2:reactivate-a-document">reactivated</a>

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-pageshow" data-dfn-type="event"><code>pageshow</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event" title="The pageshow event is sent to a Window when the browser displays the window's document due to navigation.">Window/pageshow_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>3+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>11</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:pagetransitionevent-2"><a href="#pagetransitionevent">PageTransitionEvent</a></code>
     </td><td> <code id="events-2:window-21"><a href="#window">Window</a></code>
     </td><td> Fired at the <code id="events-2:window-22"><a href="#window">Window</a></code> when the page's <a href="#session-history-entry" id="events-2:session-history-entry-3">session history entry</a>
     becomes the <a href="#nav-active-history-entry" id="events-2:nav-active-history-entry-2">active entry</a>

    </td></tr><tr><td> <a id="events-2:event-pointercancel" href="https://w3c.github.io/pointerevents/#the-pointercancel-event" data-x-internal="event-pointercancel"><code>pointercancel</code></a>
     </td><td> <code id="events-2:pointerevent-2"><a data-x-internal="pointerevent" href="https://w3c.github.io/pointerevents/#pointerevent-interface">PointerEvent</a></code>
     </td><td> Elements and <code id="events-2:text"><a data-x-internal="text" href="https://dom.spec.whatwg.org/#interface-text">Text</a></code> nodes
     </td><td> Fired at the <a href="#source-node" id="events-2:source-node">source node</a> when the user attempts to initiate a drag-and-drop operation

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-popstate" data-dfn-type="event"><code>popstate</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event" title="The popstate event of the Window interface is fired when the active history entry changes while the user navigates the session history. It changes the current history entry to that of the last page the user visited or, if history.pushState() has been used to add a history entry to the history stack, that history entry is used instead.">Window/popstate_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5+</span></span><span class="chrome yes"><span>Chrome</span><span>5+</span></span><hr><span class="opera yes"><span>Opera</span><span>11.5+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11.5+</span></span></div></div></div></td><td> <code id="events-2:popstateevent"><a href="#popstateevent">PopStateEvent</a></code>
     </td><td> <code id="events-2:window-23"><a href="#window">Window</a></code>
     </td><td> Fired at the <code id="events-2:window-24"><a href="#window">Window</a></code> when in some cases of <a href="#traverse-the-history-by-a-delta" id="events-2:traverse-the-history-by-a-delta-2">session history traversal</a>

    </td></tr><tr><td> <dfn data-dfn-for="Document" id="event-readystatechange" data-dfn-type="event"><code>readystatechange</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/readystatechange_event" title="The readystatechange event is fired when the readyState attribute of a document has changed.">Document/readystatechange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>4+</span></span><span class="safari yes"><span>Safari</span><span>5.1+</span></span><span class="chrome yes"><span>Chrome</span><span>9+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="events-2:event-22"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:document-3"><a href="#document">Document</a></code>
     </td><td> Fired at the <code id="events-2:document-4"><a href="#document">Document</a></code> when it finishes parsing and again when all its subresources have finished loading

    </td></tr><tr><td> <dfn data-dfn-for="Window,WorkerGlobalScope" id="event-rejectionhandled" data-dfn-type="event"><code>rejectionhandled</code></dfn>
     </td><td> <code id="events-2:promiserejectionevent"><a href="#promiserejectionevent">PromiseRejectionEvent</a></code>
     </td><td> Global scope objects
     </td><td> Fired at global scope objects when a previously-unhandled promise rejection becomes handled

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-reset" data-dfn-type="event"><code>reset</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset_event" title="The reset event fires when a <form> is reset.">HTMLFormElement/reset_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="events-2:event-23"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:the-form-element-3"><a href="#the-form-element">form</a></code> elements
     </td><td> Fired at a <code id="events-2:the-form-element-4"><a href="#the-form-element">form</a></code> element when it is <a href="#concept-form-reset" id="events-2:concept-form-reset">reset</a>

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-select" data-dfn-type="event"><code>select</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select_event" title="The select event fires when some text has been selected.">HTMLInputElement/select_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/select_event" title="The select event fires when some text has been selected.">HTMLTextAreaElement/select_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>6+</span></span><span class="safari yes"><span>Safari</span><span>1+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div></td><td> <code id="events-2:event-24"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> Form controls
     </td><td> Fired at form controls when their text selection is adjusted (whether by an API or by the user)

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-storage" data-dfn-type="event"><code>storage</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event" title="The storage event of the Window interface fires when a storage area (localStorage) has been modified in the context of another document.">Window/storage_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>45+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>15+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>4+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:storageevent"><a href="#storageevent">StorageEvent</a></code>
     </td><td> <code id="events-2:window-25"><a href="#window">Window</a></code>
     </td><td> Fired at <code id="events-2:window-26"><a href="#window">Window</a></code> event when the corresponding <code id="events-2:dom-localstorage"><a href="#dom-localstorage">localStorage</a></code> or <code id="events-2:dom-sessionstorage"><a href="#dom-sessionstorage">sessionStorage</a></code> storage areas change

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-submit" data-dfn-type="event"><code>submit</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event" title="The submit event fires when a <form> is submitted.">HTMLFormElement/submit_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>8+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></td><td> <code id="events-2:submitevent"><a href="#submitevent">SubmitEvent</a></code>
     </td><td> <code id="events-2:the-form-element-5"><a href="#the-form-element">form</a></code> elements
     </td><td> Fired at a <code id="events-2:the-form-element-6"><a href="#the-form-element">form</a></code> element when it is <a href="#concept-form-submit" id="events-2:concept-form-submit">submitted</a>

    </td></tr><tr><td> <dfn data-dfn-for="HTMLElement" id="event-toggle" data-dfn-type="event"><code>toggle</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDetailsElement/toggle_event" title="The toggle event fires when the open/closed state of a <details> element is toggled.">HTMLDetailsElement/toggle_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>49+</span></span><span class="safari yes"><span>Safari</span><span>10.1+</span></span><span class="chrome yes"><span>Chrome</span><span>36+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/toggle_event" title="The toggle event of the HTMLElement interface fires on a popover element (i.e. one that has a valid popover attribute) just after it is shown or hidden.">HTMLElement/toggle_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span title="Requires setting a user preference or runtime flag.">🔰 114+</span></span><span class="safari yes"><span>Safari</span><span>preview+</span></span><span class="chrome yes"><span>Chrome</span><span>114+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>114+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:toggleevent-2"><a href="#toggleevent">ToggleEvent</a></code>
     </td><td> <code id="events-2:the-details-element"><a href="#the-details-element">details</a></code> and <a href="#attr-popover" id="events-2:attr-popover-2">popover</a> elements
     </td><td> Fired at <code id="events-2:the-details-element-2"><a href="#the-details-element">details</a></code> elements when they open or close; fired on elements with the
     <code id="events-2:attr-popover-3"><a href="#attr-popover">popover</a></code> attribute when they are transitioning between
     showing and hidden

    </td></tr><tr><td> <dfn data-dfn-for="Window,WorkerGlobalScope" id="event-unhandledrejection" data-dfn-type="event"><code>unhandledrejection</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event" title="The unhandledrejection event is sent to the global scope of a script when a JavaScript Promise that has no rejection handler is rejected; typically, this is the window, but may also be a Worker.">Window/unhandledrejection_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>69+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span><hr><span class="opera unknown"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge unknown"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>11.3+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android unknown"><span>Opera Android</span><span>?</span></span></div></div></div></td><td> <code id="events-2:promiserejectionevent-2"><a href="#promiserejectionevent">PromiseRejectionEvent</a></code>
     </td><td> Global scope objects
     </td><td> Fired at global scope objects when a promise rejection goes unhandled

    </td></tr><tr><td> <dfn data-dfn-for="Window" id="event-unload" data-dfn-type="event"><code>unload</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event" title="The unload event is fired when the document or a child resource is being unloaded.">Window/unload_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>1+</span></span><span class="safari yes"><span>Safari</span><span>3+</span></span><span class="chrome yes"><span>Chrome</span><span>1+</span></span><hr><span class="opera yes"><span>Opera</span><span>4+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>4+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios yes"><span>Safari iOS</span><span>1+</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android unknown"><span>WebView Android</span><span>?</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>10.1+</span></span></div></div></div></td><td> <code id="events-2:event-25"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:window-27"><a href="#window">Window</a></code>
     </td><td> Fired at the <code id="events-2:window-28"><a href="#window">Window</a></code> object when the page is going away

    </td></tr><tr><td> <dfn data-dfn-for="Document" id="event-visibilitychange" data-dfn-type="event"><code>visibilitychange</code></dfn>
     <div class="mdn-anno wrapped before"><button onclick="toggleStatus(this)" class="mdn-anno-btn"><b title="Support in all current engines." class="all-engines-flag">✔</b><span>MDN</span></button><div class="feature"><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event" title="The visibilitychange event is fired at the document when the contents of its tab have become visible or have been hidden.">Document/visibilitychange_event</a></p><p class="all-engines-text">Support in all current engines.</p><div class="support"><span class="firefox yes"><span>Firefox</span><span>56+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>62+</span></span><hr><span class="opera yes"><span>Opera</span><span>49+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>18</span></span><span class="ie yes"><span>Internet Explorer</span><span title="Partial implementation.">🔰 10+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>62+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>46+</span></span></div></div></div></td><td> <code id="events-2:event-26"><a data-x-internal="event" href="https://dom.spec.whatwg.org/#interface-event">Event</a></code>
     </td><td> <code id="events-2:document-5"><a href="#document">Document</a></code>
     </td><td> Fired at the <code id="events-2:document-6"><a href="#document">Document</a></code> object when the page becomes visible or hidden to the
     user

  </td></tr></tbody></table>


  <h3 id="http-headers" class="no-num">HTTP headers<a href="#http-headers" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>The following HTTP request headers are defined by this specification:</p>

  <ul><li>`<code id="http-headers:last-event-id"><a href="#last-event-id">Last-Event-ID</a></code>`</li><li>`<code id="http-headers:ping-from"><a href="#ping-from">Ping-From</a></code>`</li><li>`<code id="http-headers:ping-to"><a href="#ping-to">Ping-To</a></code>`</li></ul>

  <p>The following HTTP response headers are defined by this specification:</p>

  <ul><li>`<code id="http-headers:cross-origin-embedder-policy"><a href="#cross-origin-embedder-policy">Cross-Origin-Embedder-Policy</a></code>`</li><li>`<code id="http-headers:cross-origin-embedder-policy-report-only"><a href="#cross-origin-embedder-policy-report-only">Cross-Origin-Embedder-Policy-Report-Only</a></code>`</li><li>`<code id="http-headers:cross-origin-opener-policy-2"><a href="#cross-origin-opener-policy-2">Cross-Origin-Opener-Policy</a></code>`</li><li>`<code id="http-headers:cross-origin-opener-policy-report-only"><a href="#cross-origin-opener-policy-report-only">Cross-Origin-Opener-Policy-Report-Only</a></code>`</li><li>`<code id="http-headers:origin-agent-cluster"><a href="#origin-agent-cluster">Origin-Agent-Cluster</a></code>`</li><li>`<code id="http-headers:refresh"><a href="#refresh">Refresh</a></code>`</li><li>`<code id="http-headers:x-frame-options"><a href="#x-frame-options">X-Frame-Options</a></code>`</li></ul>


  <h3 id="mime-types-2" class="no-num">MIME types<a href="#mime-types-2" class="self-link"></a></h3>

  <p><i>This section is non-normative.</i></p>

  <p>The following MIME types are mentioned in this specification:</p>

  <dl><dt><dfn id="application/atom+xml"><code>application/atom+xml</code></dfn></dt><dd>Atom <a href="#refsATOM">[ATOM]</a></dd><dt><dfn id="application/json"><code>application/json</code></dfn></dt><dd>JSON <a href="#refsJSON">[JSON]</a></dd><dt><dfn id="application/octet-stream"><a href="https://www.rfc-editor.org/rfc/rfc2046#section-4.5.1"><code>application/octet-stream</code></a></dfn></dt><dd>Generic binary data <a href="#refsRFC2046">[RFC2046]</a></dd><dt><code id="mime-types-2:application/microdata+json"><a href="#application/microdata+json">application/microdata+json</a></code></dt><dd>Microdata as JSON

   </dd><dt><dfn id="application/rss+xml"><code>application/rss+xml</code></dfn></dt><dd>RSS 

   </dd><dt><dfn id="application/wasm"><code>application/wasm</code></dfn></dt><dd>WebAssembly <a href="#refsWASM">[WASM]</a></dd><dt><code id="mime-types-2:application/x-www-form-urlencoded"><a data-x-internal="application/x-www-form-urlencoded" href="https://url.spec.whatwg.org/#concept-urlencoded">application/x-www-form-urlencoded</a></code></dt><dd>Form submission</dd><dt><code id="mime-types-2:application/xhtml+xml"><a href="#application/xhtml+xml">application/xhtml+xml</a></code></dt><dd>HTML</dd><dt><dfn id="application/xml"><code>application/xml</code></dfn></dt><dd>XML <a href="#refsXML">[XML]</a> <a href="#refsRFC7303">[RFC7303]</a></dd><dt><dfn id="image/gif"><code>image/gif</code></dfn></dt><dd>GIF images <a href="#refsGIF">[GIF]</a></dd><dt><dfn id="image/jpeg"><code>image/jpeg</code></dfn></dt><dd>JPEG images <a href="#refsJPEG">[JPEG]</a></dd><dt><dfn id="image/png"><code>image/png</code></dfn></dt><dd>PNG images <a href="#refsPNG">[PNG]</a></dd><dt><dfn id="image/svg+xml"><code>image/svg+xml</code></dfn></dt><dd>SVG images <a href="#refsSVG">[SVG]</a></dd><dt><dfn id="multipart/form-data"><code>multipart/form-data</code></dfn></dt><dd>Form submission <a href="#refsRFC7578">[RFC7578]</a></dd><dt><dfn id="multipart/mixed"><code>multipart/mixed</code></dfn></dt><dd>Generic mixed content <a href="#refsRFC2046">[RFC2046]</a></dd><dt><code id="mime-types-2:multipart/x-mixed-replace"><a href="#multipart/x-mixed-replace">multipart/x-mixed-replace</a></code></dt><dd>Streaming server push</dd><dt><dfn id="text/css"><code>text/css</code></dfn></dt><dd>CSS <a href="#refsCSS">[CSS]</a></dd><dt><code id="mime-types-2:text/event-stream"><a href="#text/event-stream">text/event-stream</a></code></dt><dd>Server-sent event streams</dd><dt><dfn id="text/javascript"><code>text/javascript</code></dfn></dt><dd>JavaScript <a href="#refsJAVASCRIPT">[JAVASCRIPT]</a> <a href="#refsRFC9239">[RFC9239]</a>

   

   </dd><dt><dfn id="text/json"><code>text/json</code></dfn></dt><dd>JSON (legacy type)</dd><dt><dfn id="text/plain"><a href="https://www.rfc-editor.org/rfc/rfc2046#section-4.1.3"><code>text/plain</code></a></dfn></dt><dd>Generic plain text <a href="#refsRFC2046">[RFC2046]</a> <a href="#refsRFC3676">[RFC3676]</a></dd><dt><code id="mime-types-2:text/html"><a href="#text/html">text/html</a></code></dt><dd>HTML</dd><dt><code id="mime-types-2:text/ping"><a href="#text/ping">text/ping</a></code></dt><dd>Hyperlink auditing</dd><dt><dfn id="text/uri-list"><code>text/uri-list</code></dfn></dt><dd>List of URLs <a href="#refsRFC2483">[RFC2483]</a>

   </dd><dt><dfn id="text/vcard"><code>text/vcard</code></dfn></dt><dd>vCard <a href="#refsRFC6350">[RFC6350]</a>

   </dd><dt><dfn id="text/vtt"><code>text/vtt</code></dfn></dt><dd>WebVTT <a href="#refsWEBVTT">[WEBVTT]</a></dd><dt><dfn id="text/xml"><code>text/xml</code></dfn></dt><dd>XML <a href="#refsXML">[XML]</a> <a href="#refsRFC7303">[RFC7303]</a></dd><dt><dfn id="video/mp4"><a href="https://www.rfc-editor.org/rfc/rfc4337#section-3"><code>video/mp4</code></a></dfn></dt><dd>MPEG-4 video <a href="#refsRFC4337">[RFC4337]</a></dd><dt><dfn id="video/mpeg"><code>video/mpeg</code></dfn></dt><dd>MPEG video <a href="#refsRFC2046">[RFC2046]</a></dd></dl>



  <h2 id="references" class="no-num">References<a href="#references" class="self-link"></a></h2>

  <p>All references are normative unless marked "Non-normative".</p>

  

  <dl id="ref-list"><dt id="refsABNF">[ABNF]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc5234">Augmented BNF for Syntax Specifications: ABNF</a></cite>, D. Crocker, P. Overell. IETF.</dd><dt id="refsABOUT">[ABOUT]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc6694">The 'about' URI scheme</a></cite>, S. Moonesamy. IETF.</dd><dt id="refsAPNG">[APNG]</dt><dd>(Non-normative) <cite><a href="https://wiki.mozilla.org/APNG_Specification">APNG Specification</a></cite>. S. Parmenter, V. Vukicevic, A. Smith. Mozilla.</dd><dt id="refsARIA">[ARIA]</dt><dd><cite><a href="https://w3c.github.io/aria/">Accessible Rich Internet Applications (WAI-ARIA)</a></cite>, J. Diggs, J. Nurthen, M. Cooper. W3C.</dd><dt id="refsARIAHTML">[ARIAHTML]</dt><dd><cite><a href="https://w3c.github.io/html-aria/">ARIA in HTML</a></cite>, S. Faulkner, S. O'Hara. W3C.</dd><dt id="refsATAG">[ATAG]</dt><dd>(Non-normative) <cite><a href="https://www.w3.org/TR/ATAG20/">Authoring Tool Accessibility Guidelines (ATAG) 2.0</a></cite>, J. Richards, J. Spellman, J. Treviranus. W3C.</dd><dt id="refsATOM">[ATOM]</dt><dd>(Non-normative) <cite><a href="https://www.rfc-editor.org/rfc/rfc4287">The Atom Syndication Format</a></cite>, M. Nottingham, R. Sayre. IETF.</dd><dt id="refsBATTERY">[BATTERY]</dt><dd>(Non-normative) <cite><a href="https://w3c.github.io/battery/">Battery Status API</a></cite>, A. Kostiainen, M. Lamouri. W3C.</dd><dt id="refsBCP47">[BCP47]</dt><dd><cite><a href="https://www.rfc-editor.org/info/bcp47">Tags for Identifying Languages; Matching of Language Tags</a></cite>, A. Phillips, M. Davis. IETF.</dd><dt id="refsBEZIER">[BEZIER]</dt><dd><cite>Courbes à poles</cite>, P. de Casteljau. INPI, 1959.</dd><dt id="refsBIDI">[BIDI]</dt><dd><cite><a href="https://www.unicode.org/reports/tr9/">UAX #9: Unicode Bidirectional Algorithm</a></cite>, M. Davis. Unicode Consortium.</dd><dt id="refsBOCU1">[BOCU1]</dt><dd>(Non-normative) <cite><a href="https://www.unicode.org/notes/tn6/">UTN #6: BOCU-1: MIME-Compatible Unicode Compression</a></cite>, M. Scherer, M. Davis. Unicode Consortium.</dd><dt id="refsCESU8">[CESU8]</dt><dd>(Non-normative) <cite><a href="https://www.unicode.org/reports/tr26/">UTR #26: Compatibility Encoding Scheme For UTF-16: 8-BIT (CESU-8)</a></cite>, T. Phipps. Unicode Consortium.</dd><dt id="refsCHARMOD">[CHARMOD]</dt><dd>(Non-normative) <cite><a href="https://www.w3.org/TR/charmod/">Character Model for the World Wide Web 1.0: Fundamentals</a></cite>, M. Dürst, F. Yergeau, R. Ishida, M. Wolf, T. Texin. W3C.</dd><dt id="refsCHARMODNORM">[CHARMODNORM]</dt><dd>(Non-normative) <cite><a href="https://w3c.github.io/charmod-norm/">Character Model for the World Wide Web: String Matching</a></cite>, A. Phillips. W3C.</dd><dt id="refsCLIPBOARD-APIS">[CLIPBOARD-APIS]</dt><dd><cite><a href="https://w3c.github.io/clipboard-apis/">Clipboard API and events</a></cite>, G. Kacmarcik, A. Snigdha. W3C.</dd><dt id="refsCOMPOSITE">[COMPOSITE]</dt><dd><cite><a href="https://drafts.fxtf.org/compositing/">Compositing and Blending</a></cite>, R. Cabanier, N. Andronikos. W3C.</dd><dt id="refsCOMPUTABLE">[COMPUTABLE]</dt><dd>(Non-normative) <cite><a href="http://www.turingarchive.org/browse.php/B/12">On computable numbers, with an application to the Entscheidungsproblem</a></cite>, A. Turing. In <cite>Proceedings of the London Mathematical Society</cite>, series 2, volume 42, pages 230-265. London Mathematical Society, 1937.</dd><dt id="refsCOMPUTEPRESSURE">[COMPUTEPRESSURE]</dt><dd>(Non-normative) <cite><a href="https://w3c.github.io/compute-pressure/">Compute Pressure</a></cite>, K. Christiansen, A. Mandy. W3C.</dd><dt id="refsCONSOLE">[CONSOLE]</dt><dd><cite><a href="https://console.spec.whatwg.org/">Console</a></cite>, T. Stock, R. Kowalski, D. Farolino. WHATWG.</dd><dt id="refsCOOKIES">[COOKIES]</dt><dd><cite><a href="https://httpwg.org/specs/rfc6265.html">HTTP State Management Mechanism</a></cite>, A. Barth. IETF.</dd><dt id="refsCOOKIESTORE">[COOKIESTORE]</dt><dd>(Non-normative) <cite><a href="https://cookiestore.spec.whatwg.org/">Cookie Store API</a></cite>, J. Wilcock, M. Nottingham. WHATWG.</dd><dt id="refsCREDMAN">[CREDMAN]</dt><dd><cite><a href="https://w3c.github.io/webappsec-credential-management/">Credential Management</a></cite>, N. Satragno, J. Hodges, M. West. W3C.</dd><dt id="refsCSP">[CSP]</dt><dd><cite><a href="https://w3c.github.io/webappsec-csp/">Content Security Policy</a></cite>, M. West, D. Veditz. W3C.</dd><dt id="refsCSS">[CSS]</dt><dd><cite><a href="https://drafts.csswg.org/css2/">Cascading Style Sheets Level 2 Revision 2</a></cite>, B. Bos, T. Çelik, I. Hickson, H. Lie. W3C.</dd><dt id="refsCSSALIGN">[CSSALIGN]</dt><dd><cite><a href="https://drafts.csswg.org/css-align/">CSS Box Alignment</a></cite>, E. Etemad, T. Atkins. W3C.</dd><dt id="refsCSSANCHOR">[CSSANCHOR]</dt><dd><cite><a href="https://drafts.csswg.org/css-anchor-position/">CSS Anchor Positioning</a></cite>, T. Atkins, E. Etemad, I. Kilpatrick. W3C.</dd><dt id="refsCSSANIMATIONS">[CSSANIMATIONS]</dt><dd><cite><a href="https://drafts.csswg.org/css-animations/">CSS Animations</a></cite>, D. Jackson, D. Hyatt, C. Marrin, S. Galineau, L. Baron. W3C.</dd><dt id="refsCSSATTR">[CSSATTR]</dt><dd><cite><a href="https://drafts.csswg.org/css-style-attr/">CSS Style Attributes</a></cite>, T. Çelik, E. Etemad. W3C.</dd><dt id="refsCSSBG">[CSSBG]</dt><dd><cite><a href="https://drafts.csswg.org/css-backgrounds/">CSS Backgrounds and Borders</a></cite>, B. Bos, E. Etemad, B. Kemper. W3C.</dd><dt id="refsCSSBOX">[CSSBOX]</dt><dd><cite><a href="https://drafts.csswg.org/css-box-3/">CSS Box Model</a></cite>, E. Etemad. W3C.</dd><dt id="refsCSSCASCADE">[CSSCASCADE]</dt><dd><cite><a href="https://drafts.csswg.org/css-cascade/">CSS Cascading and Inheritance</a></cite>, E. Etemad, T. Atkins. W3C.</dd><dt id="refsCSSCONTAIN">[CSSCONTAIN]</dt><dd><cite><a href="https://drafts.csswg.org/css-contain/">CSS Containment</a></cite>, T. Atkins, F. Rivoal, V. Levin. W3C.</dd><dt id="refsCSSCOLOR">[CSSCOLOR]</dt><dd><cite><a href="https://drafts.csswg.org/css-color/">CSS Color Module</a></cite>, T. Çelik, C. Lilley, L. Baron. W3C.</dd><dt id="refsCSSCOLORADJUST">[CSSCOLORADJUST]</dt><dd><cite><a href="https://drafts.csswg.org/css-color-adjust/">CSS Color Adjustment Module</a></cite>, E. Etemad, R. Atanassov, R. Lillesveen, T. Atkins. W3C.</dd><dt id="refsCSSDEVICEADAPT">[CSSDEVICEADAPT]</dt><dd><cite><a href="https://drafts.csswg.org/css-device-adapt/">CSS Device Adaption</a></cite>, F. Rivoal, M. Rakow. W3C.</dd><dt id="refsCSSDISPLAY">[CSSDISPLAY]</dt><dd><cite><a href="https://drafts.csswg.org/css-display/">CSS Display</a></cite>, T. Atkins, E. Etemad. W3C.</dd><dt id="refsCSSFONTLOAD">[CSSFONTLOAD]</dt><dd><cite><a href="https://drafts.csswg.org/css-font-loading/">CSS Font Loading</a></cite>, T. Atkins, J. Daggett. W3C.</dd><dt id="refsCSSFONTS">[CSSFONTS]</dt><dd><cite><a href="https://drafts.csswg.org/css-fonts/">CSS Fonts</a></cite>, J. Daggett. W3C.</dd><dt id="refsCSSFORMS">[CSSFORMS]</dt><dd><cite><a href="https://w3c.github.io/csswg-drafts/css-forms/">CSS Forms</a></cite>, T. Nguyen. W3C.</dd><dt id="refsCSSFLEXBOX">[CSSFLEXBOX]</dt><dd><cite><a href="https://drafts.csswg.org/css-flexbox/">CSS Flexible Box Layout</a></cite>, T. Atkins, E. Etemad, R. Atanassov. W3C.</dd><dt id="refsCSSGC">[CSSGC]</dt><dd><cite><a href="https://drafts.csswg.org/css-content/">CSS Generated Content</a></cite>, H. Lie, E. Etemad, I. Hickson. W3C.</dd><dt id="refsCSSGRID">[CSSGRID]</dt><dd><cite><a href="https://drafts.csswg.org/css-grid/">CSS Grid Layout</a></cite>, T. Atkins, E. Etemad, R. Atanassov. W3C.</dd><dt id="refsCSSIMAGES">[CSSIMAGES]</dt><dd><cite><a href="https://drafts.csswg.org/css-images/">CSS Images Module</a></cite>, E. Etemad, T. Atkins, L. Verou. W3C.</dd><dt id="refsCSSIMAGES4">[CSSIMAGES4]</dt><dd><cite><a href="https://drafts.csswg.org/css-images-4/">CSS Images Module Level 4</a></cite>, E. Etemad, T. Atkins, L. Verou. W3C.</dd><dt id="refsCSSINLINE">[CSSINLINE]</dt><dd><cite><a href="https://drafts.csswg.org/css-inline/">CSS Inline Layout</a></cite>, D. Cramer, E. Etemad. W3C.</dd><dt id="refsCSSLISTS">[CSSLISTS]</dt><dd><cite><a href="https://drafts.csswg.org/css-lists/">CSS Lists and Counters</a></cite>, T. Atkins. W3C.</dd><dt id="refsCSSLOGICAL">[CSSLOGICAL]</dt><dd><cite><a href="https://drafts.csswg.org/css-logical/">CSS Logical Properties</a></cite>, R. Atanassov, E. Etemad. W3C.</dd><dt id="refsCSSMULTICOL">[CSSMULTICOL]</dt><dd><cite><a href="https://drafts.csswg.org/css-multicol/">CSS Multi-column Layout</a></cite>, H. Lie, F. Rivoal, R. Andrew. W3C.</dd><dt id="refsCSSOM">[CSSOM]</dt><dd><cite><a href="https://drafts.csswg.org/cssom/">Cascading Style Sheets Object Model (CSSOM)</a></cite>, S. Pieters, G. Adams. W3C.</dd><dt id="refsCSSOMVIEW">[CSSOMVIEW]</dt><dd><cite><a href="https://drafts.csswg.org/cssom-view/">CSSOM View Module</a></cite>, S. Pieters, G. Adams. W3C.</dd><dt id="refsCSSOVERFLOW">[CSSOVERFLOW]</dt><dd><cite><a href="https://drafts.csswg.org/css-overflow-3/">CSS Overflow Module</a></cite>, L. Baron, F. Rivoal. W3C.</dd><dt id="refsCSSPAINT">[CSSPAINT]</dt><dd>(Non-normative) <cite><a href="https://drafts.css-houdini.org/css-paint-api/">CSS Painting API</a></cite>, I. Kilpatrick, D. Jackson. W3C.</dd><dt id="refsCSSPOSITION">[CSSPOSITION]</dt><dd><cite><a href="https://drafts.csswg.org/css-position/">CSS Positioned Layout</a></cite>, R. Atanassov, A. Eicholz. W3C.</dd><dt id="refsCSSPSEUDO">[CSSPSEUDO]</dt><dd><cite><a href="https://drafts.csswg.org/css-pseudo/">CSS Pseudo-Elements</a></cite>, D. Glazman, E. Etemad, A. Stearns. W3C.</dd><dt id="refsCSSRUBY">[CSSRUBY]</dt><dd><cite><a href="https://drafts.csswg.org/css-ruby/">CSS3 Ruby Module</a></cite>, R. Ishida. W3C.</dd><dt id="refsCSSSCOPING">[CSSSCOPING]</dt><dd><cite><a href="https://drafts.csswg.org/css-scoping/">CSS Scoping Module</a></cite>, T. Atkins. W3C.</dd><dt id="refsCSSSIZING">[CSSSIZING]</dt><dd><cite><a href="https://drafts.csswg.org/css-sizing/">CSS Box Sizing Module</a></cite>, T. Atkins, E. Etemad. W3C.</dd><dt id="refsCSSSCROLLANCHORING">[CSSSCROLLANCHORING]</dt><dd>(Non-normative) <cite><a href="https://drafts.csswg.org/css-scroll-anchoring/">CSS Scroll Anchoring</a></cite>, T. Atkins-Bittner. W3C.</dd><dt id="refsCSSSYNTAX">[CSSSYNTAX]</dt><dd><cite><a href="https://drafts.csswg.org/css-syntax/">CSS Syntax</a></cite>, T. Atkins, S. Sapin. W3C.</dd><dt id="refsCSSTRANSITIONS">[CSSTRANSITIONS]</dt><dd>(Non-normative) <cite><a href="https://drafts.csswg.org/css-transitions/">CSS Transitions</a></cite>, L. Baron, D. Jackson, B. Birtles. W3C.</dd><dt id="refsCSSTABLE">[CSSTABLE]</dt><dd><cite><a href="https://drafts.csswg.org/css-tables/">CSS Table</a></cite>, F. Remy, G. Whitworth. W3C.</dd><dt id="refsCSSTEXT">[CSSTEXT]</dt><dd><cite><a href="https://drafts.csswg.org/css-text/">CSS Text</a></cite>, E. Etemad, K. Ishii. W3C.</dd><dt id="refsCSSVALUES">[CSSVALUES]</dt><dd><cite><a href="https://drafts.csswg.org/css-values/">CSS3 Values and Units</a></cite>, H. Lie, T. Atkins, E. Etemad. W3C.</dd><dt id="refsCSSVIEWTRANSITIONS">[CSSVIEWTRANSITIONS]</dt><dd><cite><a href="https://drafts.csswg.org/css-view-transitions/">CSS View Transitions</a></cite>, T. Atkins Jr.; J. Archibald; K Sagar. W3C.</dd><dt id="refsCSSUI">[CSSUI]</dt><dd><cite><a href="https://drafts.csswg.org/css-ui/">CSS3 Basic User Interface Module</a></cite>, F. Rivoal. W3C.</dd><dt id="refsCSSWM">[CSSWM]</dt><dd><cite><a href="https://drafts.csswg.org/css-writing-modes/">CSS Writing Modes</a></cite>, E. Etemad, K. Ishii. W3C.</dd><dt id="refsDASH">[DASH]</dt><dd><cite><a href="https://www.iso.org/standard/65274.html">Dynamic adaptive streaming over HTTP (DASH)</a></cite>. ISO.</dd><dt id="refsDEVICEPOSTURE">[DEVICEPOSTURE]</dt><dd>(Non-normative) <cite><a href="https://w3c.github.io/device-posture/">Device Posture API</a></cite>, D. Gonzalez-Zuniga, K. Christiansen. W3C.</dd><dt id="refsDOM">[DOM]</dt><dd><cite><a href="https://dom.spec.whatwg.org/">DOM</a></cite>, A. van Kesteren, A. Gregor, Ms2ger. WHATWG.</dd><dt id="refsDOMPARSING">[DOMPARSING]</dt><dd><cite><a href="https://w3c.github.io/DOM-Parsing/">DOM Parsing and Serialization</a></cite>, T. Leithead. W3C.</dd><dt id="refsDOT">[DOT]</dt><dd>(Non-normative) <cite><a href="https://graphviz.org/doc/info/lang.html">The DOT Language</a></cite>. Graphviz.</dd><dt id="refsE163">[E163]</dt><dd><cite>Recommendation E.163 — Numbering Plan for The International Telephone Service</cite>, CCITT Blue Book, Fascicle II.2, pp. 128-134, November 1988.</dd><dt id="refsENCODING">[ENCODING]</dt><dd><cite><a href="https://encoding.spec.whatwg.org/">Encoding</a></cite>, A. van Kesteren, J. Bell. WHATWG.</dd><dt id="refsEXECCOMMAND">[EXECCOMMAND]</dt><dd><cite><a href="https://w3c.github.io/editing/docs/execCommand/">execCommand</a></cite>, J. Wilm, A. Gregor. W3C Editing APIs CG.</dd><dt id="refsEXIF">[EXIF]</dt><dd>(Non-normative) <cite><a href="https://www.jeita.or.jp/cgi-bin/standard_e/list.cgi?cateid=1&amp;subcateid=4">Exchangeable image file format</a></cite>. JEITA.</dd><dt id="refsFETCH">[FETCH]</dt><dd><cite><a href="https://fetch.spec.whatwg.org/">Fetch</a></cite>, A. van Kesteren. WHATWG.</dd><dt id="refsFETCHMETADATA">[FETCH-METADATA]</dt><dd><cite><a href="https://w3c.github.io/webappsec-fetch-metadata/">Fetch Metadata Request Headers</a></cite>, M.West. W3C.</dd><dt id="refsFILEAPI">[FILEAPI]</dt><dd><cite><a href="https://w3c.github.io/FileAPI/">File API</a></cite>, A. Ranganathan. W3C.</dd><dt id="refsFILTERS">[FILTERS]</dt><dd><cite><a href="https://drafts.fxtf.org/filter-effects/">Filter Effects</a></cite>, D. Schulze, D. Jackson, C. Harrelson. W3C.</dd><dt id="refsFULLSCREEN">[FULLSCREEN]</dt><dd><cite><a href="https://fullscreen.spec.whatwg.org/">Fullscreen</a></cite>, A. van Kesteren, T. Çelik. WHATWG.</dd><dt id="refsGEOMETRY">[GEOMETRY]</dt><dd><cite><a href="https://drafts.fxtf.org/geometry/">Geometry Interfaces</a></cite>. S. Pieters, D. Schulze, R. Cabanier. W3C.</dd><dt id="refsGIF">[GIF]</dt><dd>(Non-normative) <cite><a href="https://www.w3.org/Graphics/GIF/spec-gif89a.txt">Graphics Interchange Format</a></cite>. CompuServe.</dd><dt id="refsGRAPHICS">[GRAPHICS]</dt><dd>(Non-normative) <cite>Computer Graphics: Principles and Practice in C</cite>, Second Edition, J. Foley, A. van Dam, S. Feiner, J. Hughes. Addison-Wesley. ISBN 0-201-84840-6.</dd><dt id="refsGREGORIAN">[GREGORIAN]</dt><dd>(Non-normative) <cite>Inter Gravissimas</cite>, A. Lilius, C. Clavius. Gregory XIII Papal Bull, February 1582.</dd><dt id="refsHRT">[HRT]</dt><dd><cite><a href="https://w3c.github.io/hr-time/">High Resolution Time</a></cite>, I. Grigorik, J. Simonsen, J. Mann. W3C.</dd><dt id="refsHTMLAAM">[HTMLAAM]</dt><dd><cite><a href="https://w3c.github.io/html-aam/">HTML Accessibility API Mappings 1.0</a></cite>, S. Faulkner, A. Surkov, S. O'Hara. W3C.</dd><dt id="refsHTTP">[HTTP]</dt><dd><cite><a href="https://httpwg.org/specs/rfc7230.html">Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</a></cite>, R. Fielding, J. Reschke. IETF.</dd><dd><cite><a href="https://httpwg.org/specs/rfc7231.html">Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</a></cite>, R. Fielding, J. Reschke. IETF.</dd><dd><cite><a href="https://httpwg.org/specs/rfc7232.html">Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests</a></cite>, R. Fielding, J. Reschke. IETF.</dd><dd><cite><a href="https://httpwg.org/specs/rfc7233.html">Hypertext Transfer Protocol (HTTP/1.1): Range Requests</a></cite>, R. Fielding, Y. Lafon, J. Reschke. IETF.</dd><dd><cite><a href="https://httpwg.org/specs/rfc7234.html">Hypertext Transfer Protocol (HTTP/1.1): Caching</a></cite>, R. Fielding, M. Nottingham, J. Reschke. IETF.</dd><dd><cite><a href="https://httpwg.org/specs/rfc7235.html">Hypertext Transfer Protocol (HTTP/1.1): Authentication</a></cite>, R. Fielding, J. Reschke. IETF.</dd><dt id="refsINDEXEDDB">[INDEXEDDB]</dt><dd><cite><a href="https://w3c.github.io/IndexedDB/">Indexed Database API</a></cite>, A. Alabbas, J. Bell. W3C.</dd><dt id="refsINBAND">[INBAND]</dt><dd><cite><a href="https://dev.w3.org/html5/html-sourcing-inband-tracks/">Sourcing In-band Media Resource Tracks from Media Containers into HTML</a></cite>, S. Pfeiffer, B. Lund. W3C.</dd><dt id="refsINFRA">[INFRA]</dt><dd><cite><a href="https://infra.spec.whatwg.org/">Infra</a></cite>, A. van Kesteren, D. Denicola. WHATWG.</dd><dt id="refsINTERSECTIONOBSERVER">[INTERSECTIONOBSERVER]</dt><dd><cite><a href="https://w3c.github.io/IntersectionObserver/">Intersection Observer</a></cite>, S. Zager. W3C.</dd><dt id="refsRESIZEOBSERVER">[RESIZEOBSERVER]</dt><dd><cite><a href="https://drafts.csswg.org/resize-observer-1/">Resize Observer</a></cite>, O. Brufau, E. Álvarez. W3C.</dd><dt id="refsISO3166">[ISO3166]</dt><dd><cite><a href="https://www.iso.org/iso-3166-country-codes.html">ISO 3166: Codes for the representation of names of countries and their subdivisions</a></cite>. ISO.</dd><dt id="refsISO4217">[ISO4217]</dt><dd><cite><a href="https://www.iso.org/iso-4217-currency-codes.html">ISO 4217: Codes for the representation of currencies and funds</a></cite>. ISO.</dd><dt id="refsISO8601">[ISO8601]</dt><dd>(Non-normative) <cite><a href="http://isotc.iso.org/livelink/livelink/4021199/ISO_8601_2004_E.zip?func=doc.Fetch&amp;nodeid=4021199">ISO8601: Data elements and interchange formats — Information interchange — Representation of dates and times</a></cite>. ISO.</dd><dt id="refsJAVASCRIPT">[JAVASCRIPT]</dt><dd><cite><a href="https://tc39.es/ecma262/">ECMAScript Language Specification</a></cite>. Ecma International.</dd><dt id="refsJLREQ">[JLREQ]</dt><dd><cite><a href="https://www.w3.org/TR/jlreq/">Requirements for Japanese Text Layout</a></cite>. W3C.</dd><dt id="refsJPEG">[JPEG]</dt><dd><cite><a href="https://www.w3.org/Graphics/JPEG/jfif3.pdf">JPEG File Interchange Format</a></cite>, E. Hamilton.</dd><dt id="refsJSERRORSTACKS">[JSERRORSTACKS]</dt><dd>(Non-normative) <cite><a href="https://tc39.es/proposal-error-stacks/">Error Stacks</a></cite>. Ecma International.</dd><dt id="refsJSDYNAMICCODEBRANDCHECKS">[JSDYNAMICCODEBRANDCHECKS]</dt><dd><cite><a href="https://tc39.es/proposal-dynamic-code-brand-checks/">Dynamic code brand checks</a></cite>. Ecma International.</dd><dt id="refsJSINTL">[JSINTL]</dt><dd><cite><a href="https://tc39.es/ecma402/">ECMAScript Internationalization API Specification</a></cite>. Ecma International.</dd><dt id="refsJSON">[JSON]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc8259">The JavaScript Object Notation (JSON) Data Interchange Format</a></cite>, T. Bray. IETF.</dd><dt id="refsJSTEMPORAL">[JSTEMPORAL]</dt><dd><cite><a href="https://tc39.es/proposal-temporal/">Temporal</a></cite>. Ecma International.</dd><dt id="refsLONGTASKS">[LONGTASKS]</dt><dd><cite><a href="https://w3c.github.io/longtasks/">Long Tasks</a></cite>, D. Denicola, I. Grigorik, S. Panicker. W3C.</dd><dt id="refsLONGANIMATIONFRAMES">[LONGANIMATIONFRAMES]</dt><dd><cite><a href="https://w3c.github.io/long-animation-frames/">Long Animation Frames</a></cite>, N. Rosenthal. W3C.</dd><dt id="refsMAILTO">[MAILTO]</dt><dd>(Non-normative) <cite><a href="https://www.rfc-editor.org/rfc/rfc6068">The 'mailto' URI scheme</a></cite>, M. Duerst, L. Masinter, J. Zawinski. IETF.</dd><dt id="refsMANIFEST">[MANIFEST]</dt><dd><cite><a href="https://www.w3.org/TR/appmanifest/">Web App Manifest</a></cite>, M. Caceres, K. Rohde Christiansen, M. Lamouri, A. Kostiainen, M. Giuca, A. Gustafson. W3C.</dd><dt id="refsMATHML">[MATHMLCORE]</dt><dd><cite><a href="https://w3c.github.io/mathml-core/">Mathematical Markup Language (MathML)</a></cite>, D. Carlisle, Frédéric Wang. W3C.</dd><dt id="refsMEDIAFRAG">[MEDIAFRAG]</dt><dd><cite><a href="https://www.w3.org/TR/media-frags/">Media Fragments URI</a></cite>, R. Troncy, E. Mannens, S. Pfeiffer, D. Van Deursen. W3C.</dd><dt id="refsMEDIASOURCE">[MEDIASOURCE]</dt><dd><cite><a href="https://w3c.github.io/media-source/">Media Source Extensions</a></cite>, A. Colwell, A. Bateman, M. Watson. W3C.</dd><dt id="refsMEDIASTREAM">[MEDIASTREAM]</dt><dd><cite><a href="https://w3c.github.io/mediacapture-main/getusermedia.html">Media Capture and Streams</a></cite>, D. Burnett, A. Bergkvist, C. Jennings, A. Narayanan. W3C.</dd><dt id="refsREPORTING">[REPORTING]</dt><dd><cite><a href="https://w3c.github.io/reporting/">Reporting</a></cite>, D. Creager, I. Clelland, M. West. W3C.</dd><dt id="refsMFREL">[MFREL]</dt><dd><cite><a href="https://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions">Microformats Wiki: existing rel values</a></cite>. Microformats.</dd><dt id="refsMIMESNIFF">[MIMESNIFF]</dt><dd><cite><a href="https://mimesniff.spec.whatwg.org/">MIME Sniffing</a></cite>, G. Hemsley. WHATWG.</dd><dt id="refsMIX">[MIX]</dt><dd><cite><a href="https://w3c.github.io/webappsec-mixed-content/">Mixed Content</a></cite>, M. West. W3C.</dd><dt id="refsMNG">[MNG]</dt><dd><cite><a href="http://www.libpng.org/pub/mng/spec/">MNG (Multiple-image Network Graphics) Format</a></cite>. G. Randers-Pehrson.</dd><dt id="refsMPEG2">[MPEG2]</dt><dd><cite>ISO/IEC 13818-1: Information technology — Generic coding of moving pictures and associated audio information: Systems</cite>. ISO/IEC.</dd><dt id="refsMPEG4">[MPEG4]</dt><dd><cite>ISO/IEC 14496-12: ISO base media file format</cite>. ISO/IEC.</dd><dt id="refsMQ">[MQ]</dt><dd><cite><a href="https://drafts.csswg.org/mediaqueries/">Media Queries</a></cite>, H. Lie, T. Çelik, D. Glazman, A. van Kesteren. W3C.</dd><dt id="refsMULTIPLEBUFFERING">[MULTIPLEBUFFERING]</dt><dd>(Non-normative) <cite><a href="https://en.wikipedia.org/wiki/Multiple_buffering">Multiple buffering</a></cite>. Wikipedia.</dd><dt id="refsNAVIGATIONTIMING">[NAVIGATIONTIMING]</dt><dd><cite><a href="https://w3c.github.io/navigation-timing/">Navigation Timing</a></cite>, Y. Weiss. W3C.</dd><dt id="refsNOVARYSEARCH">[NOVARYSEARCH]</dt><dd><cite><a href="https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html">The No-Vary-Search HTTP Response Header Field</a></cite>, D. Denicola, J. Roman. IETF.</dd><dt id="refsNPAPI">[NPAPI]</dt><dd>(Non-normative) <cite><a href="https://developer.mozilla.org/en-US/docs/Plugins/Guide">Gecko Plugin API Reference</a></cite>. Mozilla.</dd><dt id="refsOGGSKELETONHEADERS">[OGGSKELETONHEADERS]</dt><dd><cite><a href="https://wiki.xiph.org/SkeletonHeaders">SkeletonHeaders</a></cite>. Xiph.Org.</dd><dt id="refsOPENSEARCH">[OPENSEARCH]</dt><dd><cite><a href="https://github.com/dewitt/opensearch/blob/master/opensearch-1-1-draft-6.md#autodiscovery-in-htmlxhtml">Autodiscovery in HTML/XHTML</a></cite>. In <cite>OpenSearch 1.1 Draft 6</cite>. GitHub.</dd><dt id="refsORIGIN">[ORIGIN]</dt><dd>(Non-normative) <cite><a href="https://www.rfc-editor.org/rfc/rfc6454">The Web Origin Concept</a></cite>, A. Barth. IETF.</dd><dt id="refsPAINTTIMING">[PAINTTIMING]</dt><dd><cite><a href="https://w3c.github.io/paint-timing/">Paint Timing</a></cite>, S. Panicker. W3C.</dd><dt id="refsPAYMENTREQUEST">[PAYMENTREQUEST]</dt><dd><cite><a href="https://w3c.github.io/payment-request/">Payment Request API</a></cite>, M. Cáceres, D. Wang, R. Solomakhin, I. Jacobs. W3C.</dd><dt id="refsPDF">[PDF]</dt><dd>(Non-normative) <cite><a href="https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf">Document management — Portable document format — Part 1: PDF</a></cite>. ISO.</dd><dt id="refsPERFORMANCETIMELINE">[PERFORMANCETIMELINE]</dt><dd><cite><a href="https://w3c.github.io/performance-timeline/">Performance Timeline</a></cite>, N. Peña Moreno, W3C.</dd><dt id="refsPERMISSIONSPOLICY">[PERMISSIONSPOLICY]</dt><dd><cite><a href="https://w3c.github.io/webappsec-feature-policy/">Permissions Policy</a></cite>, I. Clelland, W3C.</dd><dt id="refsPICTUREINPICTURE">[PICTUREINPICTURE]</dt><dd>(Non-normative) <cite><a href="https://w3c.github.io/picture-in-picture/">Picture-in-Picture</a></cite>, F. Beaufort, M. Lamouri, W3C</dd><dt id="refsPINGBACK">[PINGBACK]</dt><dd><cite><a href="https://www.hixie.ch/specs/pingback/pingback">Pingback 1.0</a></cite>, S. Langridge, I. Hickson.</dd><dt id="refsPNG">[PNG]</dt><dd><cite><a href="https://www.w3.org/TR/PNG/">Portable Network Graphics (PNG) Specification</a></cite>, D. Duce. W3C.</dd><dt id="refsPOINTEREVENTS">[POINTEREVENTS]</dt><dd><cite><a href="https://w3c.github.io/pointerevents/">Pointer Events</a></cite>, J. Rossi, M. Brubeck, R. Byers, P. H. Lauke. W3C.</dd><dt id="refsPOINTERLOCK">[POINTERLOCK]</dt><dd><cite><a href="https://w3c.github.io/pointerlock/">Pointer Lock</a></cite>, V. Scheib. W3C.</dd><dt id="refsPPUTF8">[PPUTF8]</dt><dd>(Non-normative) <cite><a href="https://www.sw.it.aoyama.ac.jp/2012/pub/IUC11-UTF-8.pdf">The Properties and Promises  of UTF-8</a></cite>, M. Dürst. University of Zürich. In <cite>Proceedings of the 11th International Unicode Conference</cite>.</dd><dt id="refsPREFETCH">[PREFETCH]</dt><dd><cite><a href="https://wicg.github.io/nav-speculation/prefetch.html">Prefetch</a></cite>, J. Roman. WICG.</dd><dt id="refsPRERENDERING-REVAMPED">[PRERENDERING-REVAMPED]</dt><dd>(Non-normative) <cite><a href="https://wicg.github.io/nav-speculation/prerendering.html">Prerendering Revamped</a></cite>, D. Denicola, D. Farolino. W3C.</dd><dt id="refsPRESENTATION">[PRESENTATION]</dt><dd><cite><a href="https://w3c.github.io/presentation-api/">Presentation API</a></cite>, M. Foltz, D. Röttsches. W3C.</dd><dt id="refsREFERRERPOLICY">[REFERRERPOLICY]</dt><dd><cite><a href="https://w3c.github.io/webappsec-referrer-policy/">Referrer Policy</a></cite>, J. Eisinger, E. Stark. W3C.</dd><dt id="refsREQUESTIDLECALLBACK">[REQUESTIDLECALLBACK]</dt><dd><cite><a href="https://w3c.github.io/requestidlecallback/">Cooperative Scheduling of Background Tasks</a></cite>, R. McIlroy, I. Grigorik. W3C.</dd><dt id="refsRESOURCETIMING">[RESOURCETIMING]</dt><dd><cite><a href="https://w3c.github.io/resource-timing/">Resource Timing</a></cite>, Yoav Weiss; Noam Rosenthal. W3C.</dd><dt id="refsRFC1034">[RFC1034]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc1034">Domain Names - Concepts and Facilities</a></cite>, P. Mockapetris. IETF, November 1987.</dd><dt id="refsRFC1123">[RFC1123]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc1123">Requirements for Internet Hosts -- Application and Support</a></cite>, R. Braden. IETF, October 1989.</dd><dt id="refsRFC2046">[RFC2046]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc2046">Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types</a></cite>, N. Freed, N.  Borenstein. IETF.</dd><dt id="refsRFC2397">[RFC2397]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc2397">The "data" URL scheme</a></cite>, L. Masinter. IETF.</dd><dt id="refsRFC5545">[RFC5545]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc5545">Internet Calendaring and Scheduling Core Object Specification (iCalendar)</a></cite>, B. Desruisseaux. IETF.</dd><dt id="refsRFC2483">[RFC2483]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc2483">URI Resolution Services Necessary for URN Resolution</a></cite>, M. Mealling, R. Daniel. IETF.</dd><dt id="refsRFC3676">[RFC3676]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc3676">The Text/Plain Format and DelSp Parameters</a></cite>, R. Gellens. IETF.</dd><dt id="refsRFC9239">[RFC9239]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc9239">Updates to ECMAScript Media Types</a></cite>, M. Miller, M. Borins, M. Bynens, B. Farias. IETF.</dd><dt id="refsRFC4337">[RFC4337]</dt><dd>(Non-normative) <cite><a href="https://www.rfc-editor.org/rfc/rfc4337">MIME Type Registration for MPEG-4</a></cite>, Y. Lim, D. Singer. IETF.</dd><dt id="refsRFC7595">[RFC7595]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc7595">Guidelines and Registration Procedures for URI Schemes</a></cite>, D. Thaler, T. Hansen, T. Hardie. IETF.</dd><dt id="refsRFC5322">[RFC5322]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc5322">Internet Message Format</a></cite>, P. Resnick. IETF.</dd><dt id="refsRFC6381">[RFC6381]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc6381">The 'Codecs' and 'Profiles' Parameters for "Bucket" Media Types</a></cite>, R. Gellens, D. Singer, P. Frojdh. IETF.</dd><dt id="refsRFC6266">[RFC6266]</dt><dd><cite><a href="https://httpwg.org/specs/rfc6266.html">Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)</a></cite>, J. Reschke. IETF.</dd><dt id="refsRFC6350">[RFC6350]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc6350">vCard Format Specification</a></cite>, S. Perreault. IETF.</dd><dt id="refsRFC6596">[RFC6596]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc6596">The Canonical Link Relation</a></cite>, M. Ohye, J. Kupke. IETF.</dd><dt id="refsRFC6903">[RFC6903]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc6903">Additional Link Relation Types</a></cite>, J. Snell. IETF.</dd><dt id="refsRFC7034">[RFC7034]</dt><dd>(Non-normative) <cite><a href="https://www.rfc-editor.org/rfc/rfc7034">HTTP Header Field X-Frame-Options</a></cite>, D. Ross, T. Gondrom. IETF.</dd><dt id="refsRFC7303">[RFC7303]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc7303">XML Media Types</a></cite>, H. Thompson, C. Lilley. IETF.</dd><dt id="refsRFC7578">[RFC7578]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc7578">Returning Values from Forms: multipart/form-data</a></cite>, L. Masinter. IETF.</dd><dt id="refsRFC8297">[RFC8297]</dt><dd><cite><a href="https://httpwg.org/specs/rfc8297.html">An HTTP Status Code for Indicating Hints</a></cite>, K. Oku. IETF.</dd><dt id="refsSCREENORIENTATION">[SCREENORIENTATION]</dt><dd><cite><a href="https://w3c.github.io/screen-orientation/">Screen Orientation</a></cite>, M. Cáceres. W3C.</dd><dt id="refsSCSU">[SCSU]</dt><dd>(Non-normative) <cite><a href="https://www.unicode.org/reports/tr6/">UTR #6: A Standard Compression Scheme For Unicode</a></cite>, M. Wolf, K. Whistler, C. Wicksteed, M. Davis, A. Freytag, M. Scherer. Unicode Consortium.</dd><dt id="refsSECURE-CONTEXTS">[SECURE-CONTEXTS]</dt><dd><cite><a href="https://w3c.github.io/webappsec-secure-contexts/">Secure Contexts</a></cite>, M. West. W3C.</dd><dt id="refsSELECTION">[SELECTION]</dt><dd><cite><a href="https://w3c.github.io/selection-api/">Selection API</a></cite>, R. Niwa. W3C.</dd><dt id="refsSELECTORS">[SELECTORS]</dt><dd><cite><a href="https://drafts.csswg.org/selectors/">Selectors</a></cite>, E. Etemad, T. Çelik, D. Glazman, I. Hickson, P. Linss, J. Williams. W3C.</dd><dt id="refsSMS">[SMS]</dt><dd>(Non-normative) <cite><a href="https://www.rfc-editor.org/rfc/rfc5724">URI Scheme for Global System for Mobile Communications (GSM) Short Message Service (SMS)</a></cite>, E. Wilde, A. Vaha-Sipila. IETF.</dd><dt id="refsSTRUCTURED-FIELDS">[STRUCTURED-FIELDS]</dt><dd><cite><a href="https://httpwg.org/specs/rfc8941.html">Structured Field Values for HTTP</a></cite>, M. Nottingham, P-H. Kamp. IETF.</dd><dt id="refsSRI">[SRI]</dt><dd><cite><a href="https://w3c.github.io/webappsec-subresource-integrity/">Subresource Integrity</a></cite>, D. Akhawe, F. Braun, F. Marier, J. Weinberger. W3C.</dd><dt id="refsSTORAGE">[STORAGE]</dt><dd><cite><a href="https://storage.spec.whatwg.org/">Storage</a></cite>, A. van Kesteren. WHATWG.</dd><dt id="refsSVG">[SVG]</dt><dd><cite><a href="https://svgwg.org/svg2-draft/">Scalable Vector Graphics (SVG) 2</a></cite>, N Andronikos, R. Atanassov, T. Bah, B. Birtles, B. Brinza, C. Concolato, E. Dahlström, C. Lilley, C. McCormack, D. Schepers, R. Schwerdtfeger, D. Storey, S. Takagi, J. Watt. W3C.</dd><dt id="refsSW">[SW]</dt><dd><cite><a href="https://w3c.github.io/ServiceWorker/">Service Workers</a></cite>, A. Russell, J. Song, J. Archibald. W3C.</dd><dt id="refsTOR">[TOR]</dt><dd>(Non-normative) <cite><a href="https://www.torproject.org/">Tor</a></cite>.</dd><dt id="refsTOUCH">[TOUCH]</dt><dd><cite><a href="https://w3c.github.io/touch-events/">Touch Events</a></cite>, D. Schepers, S. Moon, M. Brubeck, A. Barstow, R. Byers. W3C.</dd><dt id="refsTRUSTED-TYPES">[TRUSTED-TYPES]</dt><dd><cite><a href="https://w3c.github.io/trusted-types/dist/spec/">Trusted Types</a></cite>, K. Kotowicz, M. West. W3C.</dd><dt id="refsTZDATABASE">[TZDATABASE]</dt><dd>(Non-normative) <cite><a href="https://www.iana.org/time-zones">Time Zone Database</a></cite>. IANA.</dd><dt id="refsUAAG">[UAAG]</dt><dd>(Non-normative) <cite><a href="https://www.w3.org/TR/UAAG20/">User Agent Accessibility Guidelines (UAAG) 2.0</a></cite>, J. Allan, K. Ford, J. Richards, J. Spellman. W3C.</dd><dt id="refsUIEVENTS">[UIEVENTS]</dt><dd><cite><a href="https://w3c.github.io/uievents/">UI Events Specification</a></cite>, G. Kacmarcik, T. Leithead. W3C.</dd><dt id="refsUNICODE">[UNICODE]</dt><dd><cite><a href="https://www.unicode.org/versions/">The Unicode Standard</a></cite>. Unicode Consortium.</dd><dt id="refsUNIVCHARDET">[UNIVCHARDET]</dt><dd>(Non-normative) <cite><a href="https://www-archive.mozilla.org/projects/intl/UniversalCharsetDetection.html">A composite approach to language/encoding detection</a></cite>, S. Li, K. Momoi. Netscape. In <cite>Proceedings of the 19th International Unicode Conference</cite>.</dd><dt id="refsURL">[URL]</dt><dd><cite><a href="https://url.spec.whatwg.org/">URL</a></cite>, A. van Kesteren. WHATWG.</dd><dt id="refsURLPATTERN">[URLPATTERN]</dt><dd><cite><a href="https://urlpattern.spec.whatwg.org/">URL Pattern</a></cite>, B. Kelly, J. Roman, 宍戸俊哉. WHATWG.</dd><dt id="refsURN">[URN]</dt><dd><cite><a href="https://www.rfc-editor.org/rfc/rfc2141">URN Syntax</a></cite>, R. Moats. IETF.</dd><dt id="refsUTF7">[UTF7]</dt><dd>(Non-normative) <cite><a href="https://www.rfc-editor.org/rfc/rfc2152">UTF-7: A Mail-Safe Transformation Format of Unicode</a></cite>, D. Goldsmith, M. Davis. IETF.</dd><dt id="refsUTF8DET">[UTF8DET]</dt><dd>(Non-normative) <cite><a href="https://www.w3.org/International/questions/qa-forms-utf-8">Multilingual form encoding</a></cite>, M. Dürst. W3C.</dd><dt id="refsUTR36">[UTR36]</dt><dd>(Non-normative) <cite><a href="https://www.unicode.org/reports/tr36/">UTR #36: Unicode Security Considerations</a></cite>, M. Davis, M. Suignard. Unicode Consortium.</dd><dt id="refsWASM">[WASM]</dt><dd><cite><a href="https://webassembly.github.io/spec/core/bikeshed/index.html">WebAssembly Core Specification</a></cite>, A. Rossberg. W3C.</dd><dt id="refsWASMESM">[WASMESM]</dt><dd><cite><a href="https://webassembly.github.io/esm-integration/js-api/index.html">WebAssembly JavaScript Interface: ESM Integration</a></cite>, L. Clark, D. Ehrenberg., A. Takikawa., G. Bedford. W3C.</dd><dt id="refsWASMJS">[WASMJS]</dt><dd>(Non-normative) <cite><a href="https://webassembly.github.io/spec/js-api/">WebAssembly JavaScript Interface</a></cite>, D. Ehrenberg. W3C.</dd><dt id="refsWCAG">[WCAG]</dt><dd>(Non-normative) <cite><a href="https://w3c.github.io/wcag/guidelines/">Web Content Accessibility Guidelines (WCAG)</a></cite>, A. Kirkpatrick, J. O Connor, A. Campbell, M. Cooper. W3C.</dd><dt id="refsWEBANIMATIONS">[WEBANIMATIONS]</dt><dd><cite><a href="https://drafts.csswg.org/web-animations-1/">Web Animations</a></cite>, B. Birtles, S. Stephens, D. Stockwell. W3C.</dd><dt id="refsWEBAUDIO">[WEBAUDIO]</dt><dd>(Non-normative) <cite><a href="https://webaudio.github.io/web-audio-api/">Web Audio API</a></cite>, P. Adenot, H. Choi. W3C.</dd><dt id="refsWEBAUTHN">[WEBAUTHN]</dt><dd><cite><a href="https://w3c.github.io/webauthn">Web Authentication: An API for accessing Public Key Credentials</a></cite>, M. Jones, A. Kumar, E. Lundberg, D. Balfanz, V. Bharadwaj, A. Birgisson, A. Czeskis, J. Hodges, J.C. Jones, H. Le Van Gong, A. Liao, R. Lindemann, J. Bradley, C. Brand, T. Cappalli, A. Langley, G. Mandyam, M. Miller, N. Satragno, N. Steele, J. Tan, S. Weeden, M. West, J. Yasskin. W3C.</dd><dt id="refsWEBCODECS">[WEBCODECS]</dt><dd><cite><a href="https://w3c.github.io/webcodecs/">WebCodecs API</a></cite>, C. Cunningham, P. Adenot, B. Aboba. W3C.</dd><dt id="refsWEBCRYPTO">[WEBCRYPTO]</dt><dd><cite><a href="https://w3c.github.io/webcrypto/Overview.html">Web Cryptography API</a></cite>, D. Huigens. W3C.</dd><dt id="refsWEBDRIVER">[WEBDRIVER]</dt><dd><cite><a href="https://w3c.github.io/webdriver/">WebDriver</a></cite>, S. Stewart, D. Burns. W3C.</dd><dt id="refsWEBDRIVERBIDI">[WEBDRIVERBIDI]</dt><dd><cite><a href="https://w3c.github.io/webdriver-bidi/">WebDriver BiDi</a></cite>. W3C</dd><dt id="refsWEBGL">[WEBGL]</dt><dd><cite><a href="https://www.khronos.org/registry/webgl/specs/latest/">WebGL Specifications</a></cite>, D. Jackson, J. Gilbert. Khronos Group.</dd><dt id="refsWEBGPU">[WEBGPU]</dt><dd><cite><a href="https://gpuweb.github.io/gpuweb/">WebGPU</a></cite>, D. Malyshau, K. Ninomiya. W3C.</dd><dt id="refsWEBIDL">[WEBIDL]</dt><dd><cite><a href="https://webidl.spec.whatwg.org/">Web IDL</a></cite>, E. Chen, T. Gu. WHATWG.</dd><dt id="refsWEBLINK">[WEBLINK]</dt><dd><cite><a href="https://httpwg.org/specs/rfc8288.html">Web Linking</a></cite>, M. Nottingham. IETF.</dd><dt id="refsWEBLOCKS">[WEBLOCKS]</dt><dd>(Non-normative) <cite><a href="https://w3c.github.io/web-locks/">Web Locks API</a></cite>, J. Bell, K. Rosylight. W3C.</dd><dt id="refsWEBMCG">[WEBMCG]</dt><dd><cite><a href="https://www.webmproject.org/docs/container/">WebM Container Guidelines</a></cite>. The WebM Project.</dd><dt id="refsWEBNFC">[WEBNFC]</dt><dd>(Non-normative) <cite><a href="https://w3c.github.io/web-nfc/">Web NFC</a></cite>, F. Beaufort, K. Christiansen, Z. Kis. W3C.</dd><dt id="refsWEBRTC">[WEBRTC]</dt><dd>(Non-normative) <cite><a href="https://w3c.github.io/webrtc-pc/">Web RTC</a></cite>, C. Jennings, F. Castelli, H. Boström, J. Bruaroey. W3C.</dd><dt id="refsWEBSOCKETS">[WEBSOCKETS]</dt><dd><cite><a href="https://websockets.spec.whatwg.org/">WebSockets</a></cite>, A. Rice. WHATWG.</dd><dt id="refsWEBTRANSPORT">[WEBTRANSPORT]</dt><dd><cite><a href="https://w3c.github.io/webtransport/">WebTransport</a></cite>, B. Aboba, N. Jaju, V. Vasiliev. W3C.</dd><dt id="refsWEBVTT">[WEBVTT]</dt><dd><cite><a href="https://w3c.github.io/webvtt/">WebVTT</a></cite>, S. Pieters. W3C.</dd><dt id="refsWHATWGWIKI">[WHATWGWIKI]</dt><dd><cite><a href="https://wiki.whatwg.org/">The WHATWG Wiki</a></cite>. WHATWG.</dd><dt id="refsX121">[X121]</dt><dd><cite>Recommendation X.121 — International Numbering Plan for Public Data Networks</cite>, CCITT Blue Book, Fascicle VIII.3, pp. 317-332.</dd><dt id="refsXFN">[XFN]</dt><dd><cite><a href="https://gmpg.org/xfn/11">XFN 1.1 profile</a></cite>, T. Çelik, M. Mullenweg, E. Meyer. GMPG.</dd><dt id="refsXHR">[XHR]</dt><dd><cite><a href="https://xhr.spec.whatwg.org/"><code>XMLHttpRequest</code></a></cite>, A. van Kesteren. WHATWG.</dd><dt id="refsXKCD1288">[XKCD1288]</dt><dd>(Non-normative) <cite><a href="https://xkcd.com/1288/">Substitutions</a></cite>, Randall Munroe. xkcd.</dd><dt id="refsXML">[XML]</dt><dd><cite><a href="https://www.w3.org/TR/xml/">Extensible Markup Language</a></cite>, T. Bray, J. Paoli, C. Sperberg-McQueen, E. Maler, F. Yergeau. W3C.</dd><dt id="refsXMLENTITY">[XMLENTITY]</dt><dd>(Non-normative) <cite><a href="https://www.w3.org/2003/entities/2007doc/">XML Entity Definitions for Characters</a></cite>, D. Carlisle, P. Ion. W3C.</dd><dt id="refsXMLNS">[XMLNS]</dt><dd><cite><a href="https://www.w3.org/TR/xml-names/">Namespaces in XML</a></cite>, T. Bray, D. Hollander, A. Layman, R. Tobin. W3C.</dd><dt id="refsXMLSSPI">[XMLSSPI]</dt><dd><cite><a href="https://www.w3.org/TR/xml-stylesheet/">Associating Style Sheets with XML documents</a></cite>, J. Clark, S. Pieters, H. Thompson. W3C.</dd><dt id="refsXPATH10">[XPATH10]</dt><dd><cite><a href="https://www.w3.org/TR/1999/REC-xpath-19991116/">XML Path Language (XPath) Version 1.0</a></cite>, J. Clark, S. DeRose. W3C.</dd><dt id="refsXSLT10">[XSLT10]</dt><dd>(Non-normative) <cite><a href="https://www.w3.org/TR/1999/REC-xslt-19991116">XSL Transformations (XSLT) Version 1.0</a></cite>, J. Clark. W3C.</dd><dt id="refsXSLTP">[XSLTP]</dt><dd>(Non-normative) <cite><a href="https://wiki.whatwg.org/wiki/DOM_XSLTProcessor">DOM XSLTProcessor</a></cite>, WHATWG Wiki. WHATWG.</dd></dl>


  <h2 id="acknowledgments" class="no-num">Acknowledgments<a href="#acknowledgments" class="self-link"></a></h2>
  

  <p>Thanks to Tim Berners-Lee for inventing HTML, without which none of this would exist.</p>

  <p>Thanks to

  Aankhen,
  Aaqa Ishtyaq,
  Aaron Boodman,
  Aaron Leventhal,
  Aaron Krajeski,
  Abhishek Ghaskata,
  Abhishek Gupta, 
  Adam Barth,
  Adam de Boor,
  Adam Hepton,
  Adam Klein,
  Adam Rice,
  Adam Roben,
  Addison Phillips,
  Adele Peterson,
  Adrian Bateman,
  Adrian Roselli,
  Adrian Sutton,
  Agustín Fernández,
  Aharon (Vladimir) Lanin,
  Ajai Tirumali,
  Ajay Poshak, 
  Akash Balenalli,
  Akatsuki Kitamura,
  Alan Jeffrey, 
  Alan Plum,
  Alastair Campbell,
  Alejandro G. Castro,
  Alex Bishop,
  Alex Nicolaou,
  Alex Nozdriukhin,
  Alex Rousskov,
  Alex Soncodi,
  Alexander Farkas,
  Alexander J. Vincent,
  Alexander Kalenik,
  Alexandre Dieulot,
  Alexandre Morgaut,
  Alexey Feldgendler,
  Алексей Проскуряков (Alexey Proskuryakov),
  Alexey Shvayka,
  Alexis Deveria,
  Alfred Agrell, 
  Ali Juma,
  Alice Boxhall,
  Alice Wonder,
  Allan Clements,
  Allen Wirfs-Brock,
  Alex Komoroske,
  Alex Russell,
  Alphan Chen,
  Aman Ansari, 
  Ami Fischman,
  Amos Jeffries,
  Amos Lim,
  Anders Carlsson,
  André Bargull,
  André E. Veltstra,
  Andrea Rendine,
  Andreas,
  Andreas Deuschlinger, 
  Andreas Farre,
  Andreas Kling,
  Andrei Popescu,
  Andres Gomez,
  Andres Rios,
  Andreu Botella,
  Andrew Barfield,
  Andrew Clover,
  Andrew Gove,
  Andrew Grieve,
  Andrew Kaster,
  Andrew Macpherson, 
  Andrew Oakley,
  Andrew Paseltiner,
  Andrew Simons,
  Andrew Smith,
  Andrew W. Hagen,
  Andrew Williams,
  Andrey V. Lukyanov,
  Andry Rendy,
  Andy Davies,
  Andy Earnshaw,
  Andy Heydon,
  Andy Paicu,
  Andy Palay,
  Anjana Vakil,
  Ankur Kaushal,
  Anna Belle Leiserson,
  Anna Sidwell,
  Anthony Boyd,
  Anthony Bryan,
  Anthony Hickson,
  Anthony Ramine,
  Anthony Ricaud,
  Anton Vayvod,
  Antonio Sartori,
  Antti Koivisto,
  Arfat Salman,
  Arkadiusz Michalski,
  Arne Thomassen,
  Aron Spohr,
  Arphen Lin,
  Arthur Hemery,
  Arthur Sonzogni, 
  Arthur Stolyar,
  Arun Patole,
  Aryeh Gregor,
  Asanka Herath,
  Asbjørn Ulsberg,
  Ashley Gullen,
  Ashley Sheridan,
  Asumu Takikawa,
  Atsushi Takayama,
  Attila Haraszti,
  Aurelien Levy,
  Ave Wrigley,
  Avi Drissman,
  Axel Dahmen,
  방성범 (Bang Seongbeom), 
  Barry Pollard, 
  Ben Boyle,
  Ben Godfrey,
  Ben Golightly, 
  Ben Kelly,
  Ben Lerner,
  Ben Leslie,
  Ben Meadowcroft,
  Ben Millard,
  Benjamin Carl Wiley Sittler,
  Benjamin Hawkes-Lewis,
  Benjamin VanderSloot,
  Benji Bilheimer, 
  Benoit Ren,
  Bert Bos,
  Bijan Parsia,
  Bil Corry,
  Bill Mason,
  Bill McCoy,
  Billy Wong,
  Billy Woods,
  Bjartur Thorlacius,
  Björn Höhrmann,
  Blake Frantz,
  Bob Lund,
  Bob Owen,
  Bobby Holley,
  Boris Zbarsky,
  Brad Fults,
  Brad Neuberg,
  Brad Spencer,
  Bradley Meck,
  Brady Eidson,
  Brandon Jones,
  Brendan Eich,
  Brenton Simpson,
  Brett Wilson,
  Brett Zamir,
  Brian Birtles,
  Brian Blakely,
  Brian Campbell,
  Brian Korver,
  Brian Kuhn,
  Brian M. Dube,
  Brian Ryner,
  Brian Smith,
  Brian Wilson,
  Bryan Sullivan,
  Bruce Bailey,
  Bruce D'Arcus,
  Bruce Lawson,
  Bruce Miller,
  Bugs Nash,
  C. Scott Ananian,
  C. Williams,
  Cameron McCormack,
  Cameron Zemek,
  Cao Yipeng,
  Carlos Amengual,
  Carlos Gabriel Cardona,
  Carlos Ibarra López, 
  Carlos Perelló Marín,
  Carolyn MacLeod,
  Casey Leask,
  Cătălin Badea,
  Cătălin Mariș,
  Cem Turesoy, 
  ceving, 
  Chao Cai,
  윤석찬 (Channy Yun),
  Charl van Niekerk,
  Charlene Wright,
  Charles Iliya Krempeaux,
  Charles McCathie Nevile,
  Charlie Reis,
  白丞祐 (Cheng-You Bai), 
  Chris Apers,
  Chris Cressman,
  Chris Dumez,
  Chris Evans,
  Chris Harrelson,
  Chris Markiewicz,
  Chris Morris,
  Chris Nardi,
  Chris Needham,
  Chris Pearce,
  Chris Peterson,
  Chris Rebert,
  Chris Weber,
  Chris Wilson,
  Christian Biesinger,
  Christian Johansen,
  Christian Schmidt,
  Christoph Päper,
  Christophe Dumez,
  Christopher Aillon,
  Christopher Cameron,
  Christopher Ferris,
  Chriswa,
  Clark Buehler,
  Cole Robison,
  Colin Fine,
  Collin Jackson,
  Conrad Crawford, 
  Corey Farwell,
  Corprew Reed,
  Craig Cockburn,
  Csaba Gabor,
  Csaba Marton,
  Cynthia Shelly,
  Cyrille Tuzi,
  Daksh Shah,
  Dan Callahan,
  Dan Yoder,
  Dane Foster, 
  Daniel Barclay,
  Daniel Bratell,
  Daniel Brooks,
  Daniel Brumbaugh Keeney,
  Daniel Buchner,
  Daniel Cheng,
  Daniel Clark, 
  Daniel Davis,
  Daniel Ehrenberg,
  Daniel Ethridge, 
  Daniel Glazman,
  Daniel Holbert,
  Daniel Peng,
  Daniel Schattenkirchner,
  Daniel Spång,
  Daniel Steinberg,
  Daniel Tan,
  Daniel Trebbien,
  Daniel Vogelheim,
  Danny Sullivan,
  Daphne Preston-Kendal,
  Darien Maillet Valentine,
  Darin Adler,
  Darin Fisher,
  Darxus,
  Dave Camp,
  Dave Cramer,
  Dave Hodder,
  Dave Lampton,
  Dave Singer,
  Dave Tapuska,
  Dave Townsend,
  David Baron,
  David Bloom,
  David Bokan,
  David Bruant,
  David Carlisle,
  David E. Cleary,
  David Egan Evans,
  David Fink,
  David Flanagan,
  David Gerard,
  David Grogan,
  David Hale,
  David Håsäther,
  David Hyatt,
  David I. Lehn,
  David John Burrowes,
  David Matja,
  David Remahl,
  David Resseguie,
  David Smith,
  David Storey,
  David Vest,
  David Woolley,
  David Zbarsky,
  Dave Methvin,
  DeWitt Clinton,
  Dean Edridge,
  Dean Edwards,
  Dean Jackson,
  Debanjana Sarkar, 
  Debi Orton,
  Delan Azabani, 
  Derek Featherstone,
  Derek Guenther,
  Devarshi Pant,
  Devdatta,
  Devin Mullins,
  Devin Rousso,
  Di Zhang,
  Diego Ferreiro Val,
  Diego González Zúñiga, 
  Diego Ponce de León,
  Dimitri Glazkov,
  Dimitry Golubovsky,
  Dirk Pranke,
  Dirk Schulze,
  Dirkjan Ochtman,
  Divya Manian,
  Dmitry Lazutkin,
  Dmitry Titov,
  dolphinling,
  Dominic Cooney,
  Dominique Hazaël-Massieux,
  Don Brutzman,
  Donovan Glover,
  Doron Rosenberg,
  Doug Kramer,
  Doug Simpkinson,
  Drew Wilson,
  Edgar Chen,
  Edmund Lai,
  Eduard Pascual,
  Eduardo Vela,
  Edward Welbourne,
  Edward Z. Yang,
  Ehsan Akhgari,
  Ehsan Karamad,
  Eira Monstad,
  Eitan Adler,
  Eli Friedman,
  Eli Grey,
  Eliot Graff,
  Elisabeth Robson,
  Elizabeth Castro,
  Elliott Sprehn,
  Elliotte Harold,
  Emilio Cobos Álvarez,
  Emily Stark,
  Eric Carlson,
  Eric Casler,
  Eric Lawrence,
  Eric Portis,
  Eric Rescorla,
  Eric Semling,
  Eric Shepherd, 
  Eric Willigers,
  Erik Arvidsson,
  Erik Charlebois,
  Erik Rose,
  栗本 英理子 (Eriko Kurimoto),
  espretto, 
  Evan Jacobs,
  Evan Martin,
  Evan Prodromou,
  Evan Stade,
  Evert,
  Evgeny Kapun,
  ExE-Boss, 
  Ezequiel Garzón,
  fantasai,
  Félix Sanz,
  Felix Sasaki,
  Fernando Altomare Serboncini,
  Forbes Lindesay,
  Francesco Schwarz,
  Francis Brosnan Blazquez,
  Franck 'Shift' Quélain,
  François Marier,
  Frank Barchard,
  Frank Liberato,
  Franklin Shirley,
  Frederik Braun,
  Fredrik Söderquist,
  鵜飼文敏 (Fumitoshi Ukai),
  Futomi Hatano,
  Gavin Carothers,
  Gavin Kistner,
  Gareth Rees,
  Garrett Smith,
  Gary Blackwood,
  Gary Kacmarcik,
  Gary Katsevman,
  Geoff Richards,
  Geoffrey Garen,
  Georg Neis,
  George Lund,
  Gianmarco Armellin,
  Giovanni Campagna,
  Giuseppe Pascale,
  Glenn Adams,
  Glenn Maynard,
  Graham Klyne,
  Greg Botten,
  Greg Houston,
  Greg Wilkins,
  Gregg Tavares,
  Gregory J. Rosmaita,
  Gregory Terzian,
  Grey,
  guest271314,
  Guilherme Johansson Tramontina,
  Guy Bedford,
  Gytis Jakutonis,
  Håkon Wium Lie,
  Habib Virji,
  Hajime Morrita,
  Hallvord Reiar Michaelsen Steen,
  Hanna Laakso,
  Hans S. Tømmerhalt,
  Hans Stimer,
  Harald Alvestrand,
  Hayato Ito,
  何志翔 (HE Zhixiang),
  Henri Sivonen,
  Henrik Lied,
  Henrik Lievonen,
  Henry Lewis,
  Henry Mason,
  Henry Story,
  Hermann Donfack Zeufack,
  中川博貴 (Hiroki Nakagawa), 
  Hiroshige Hayashizaki,
  Hiroyuki USHITO,
  Hitoshi Yoshida,
  Hongchan Choi, 
  王华 (Hua Wang), 
  Hugh Bellamy,
  Hugh Guiney,
  Hugh Winkler,
  Ian Bicking,
  Ian Clelland,
  Ian Davis,
  Ian Fette,
  Ian Henderson,
  Ian Kilpatrick,
  Ibrahim Ahmed,
  Ido Green,
  Ignacio Javier,
  Igor Oliveira,
  安次嶺 一功 (Ikko Ashimine), 
  Ilya Grigorik,
  Ingvar Stepanyan,
  isonmad,
  Iurii Kucherov,
  Ivan Enderlin,
  Ivan Nikulin, 
  Ivan Panchenko,
  Ivo Emanuel Gonçalves,
  J. King,
  J.C. Jones,
  Jackson Ray Hamilton,
  Jacob Davies,
  Jacques Distler,
  Jake Archibald,
  Jake Verbaten,
  Jakub Vrána,
  Jakub Łopuszański,
  Jakub Wilk,
  James Browning,
  James Craig,
  James Graham,
  James Greene,
  James Justin Harrell,
  James Kozianski,
  James M Snell,
  James Perrett,
  James Robinson,
  Jamie Liu,
  Jamie Lokier,
  Jamie Mansfield,
  Jan Kühle, 
  Jan Miksovsky,
  Janice Shiu,
  Janusz Majnert,
  Jan-Ivar Bruaroey,
  Jan-Klaas Kollhof,
  Jared Jacobs,
  Jason Duell,
  Jason Kersey,
  Jason Lustig,
  Jason Orendorff,
  Jason White,
  Jasper Bryant-Greene,
  Jasper St. Pierre,
  Jatinder Mann,
  Jay Henry Kao,
  Jean-Yves Avenard,
  Jed Hartman,
  Jeff Balogh,
  Jeff Cutsinger,
  Jeff Gilbert,
  Jeff "=JeffH" Hodges,
  Jeff Schiller,
  Jeff Walden,
  Jeffrey Yasskin,
  Jeffrey Zeldman,
  胡慧鋒 (Jennifer Braithwaite),
  Jellybean Stonerfish,
  Jennifer Apacible,
  Jens Bannmann,
  Jens Fendler,
  Jens Oliver Meiert,
  Jens Widell,
  Jer Noble,
  Jeremey Hustman,
  Jeremy Keith,
  Jeremy Orlow,
  Jeremy Roman,
  Jeroen van der Meer,
  Jerry Smith,
  Jesse Renée Beach,
  Jessica Jong,
  jfkthame, 
  Jian Li,
  Jihye Hong,
  Jim Jewett,
  Jim Ley,
  Jim Meehan,
  Jim Michaels,
  Jin Dongxun (金东勋, 金東勳, 김동훈),
  Jinho Bang,
  Jinjiang (勾三股四), 
  Jirka Kosek,
  Jjgod Jiang,
  Joaquim Medeiros,
  João Eiras,
  Jochen Eisinger,
  Joe Clark,
  Joe Gregorio,
  Joel Spolsky,
  Joel Verhagen,
  Joey Arhar,
  Johan Herland,
  Johanna Herman,
  John Boyer,
  John Bussjaeger,
  John Carpenter,
  John Daggett,
  John Fallows,
  John Foliot,
  John Harding,
  John Keiser,
  John Law,
  John Musgrave,
  John Snyders,
  John Stockton,
  John-Mark Bell,
  Johnny Stenback,
  Jon Coppeard,
  Jon Ferraiolo,
  Jon Gibbins,
  Jon Jensen,
  Jon Perlow,
  Jonas Sicking,
  Jonathan Cook,
  Jonathan Kew,
  Jonathan Neal,
  Jonathan Oddy,
  Jonathan Rees,
  Jonathan Watt,
  Jonathan Worent,
  Jonny Axelsson,
  Joram Schrijver,
  Jordan Tucker,
  Jorgen Horstink,
  Joris van der Wel,
  Jorunn Danielsen Newth,
  Joseph Kesselman,
  Joseph Mansfield,
  Joseph Pecoraro,
  Josh Aas,
  Josh Hart,
  Josh Juran,
  Josh Levenberg,
  Josh Matthews,
  Joshua Bell,
  Joshua Chen, 
  Joshua Randall,
  Juan Olvera, 
  Juanmi Huertas,
  Jukka K. Korpela,
  Jules Clément-Ripoche,
  Julian Reschke,
  Julio Lopez,
  小勝　純 (Jun Kokatsu),
  Jun Yang (harttle),
  Jungkee Song,
  Jürgen Jeka,
  Justin Lebar,
  Justin Novosad,
  Justin Rogers,
  Justin Schuh,
  Justin Sinclair,
  Juuso Lapinlampi,
  Ka-Sing Chou,
  Kagami Sascha Rosylight,
  Kai Hendry,
  Kamishetty Sreeja,
  呂康豪 (KangHao Lu),
  Karl Dubost,
  Karl Tomlinson,
  Kartik Arora,
  Kartikaya Gupta,
  Kathy Walton,
  河童エクマ（Kawarabe Ecma）
  Keith Cirkel, 
  Keith Rollin,
  Keith Yeung,
  Kelly Ford,
  Kelly Norton,
  Ken Russell,
  Kenji Baheux,
  Kevin Benson,
  Kevin Cole,
  Kevin Gadd,
  Kevin McNee,
  Kevin Venkiteswaran,
  Khushal Sagar,
  Kinuko Yasuda,
  Koji Ishii,
  Kornél Pál,
  Kornel Lesinski,
  上野 康平 (UENO, Kouhei),
  Kris Northfield,
  Kristian Spangsege,
  Kristof Zelechovski,
  Krzysztof Maczyński,
  黒澤剛志 (Kurosawa Takeshi),
  Kyle Barnhart,
  Kyle Hofmann,
  Kyle Huey,
  Léonard Bouchet,
  Léonie Watson,
  Lachlan Hunt,
  Larry Masinter,
  Larry Page,
  Lars Gunther,
  Lars Solberg,
  Laura Carlson,
  Laura Granka,
  Laura L. Carlson,
  Laura Wisewell,
  Laurens Holst,
  Lawrence Forooghian,
  Lee Kowalkowski,
  Leif Halvard Silli,
  Leif Kornstaedt,
  Lenny Domnitser,
  Leonard Rosenthol,
  Leons Petrazickis,
  Liviu Tinta,
  Lobotom Dysmon,
  Logan,
  Logan Moore,
  Loune,
  Lucas Gadani,
  Łukasz Pilorz,
  Luke Kenneth Casson Leighton,
  Luke Warlow,
  Luke Wilde,
  Maciej Stachowiak,
  Magne Andersson,
  Magnus Kristiansen,
  Maik Merten,
  Majid Valipour,
  Maksim Sadym,
  Malcolm Rowe,
  Manish Goregaokar,
  Manish Tripathi,
  Manuel Martinez-Almeida,
  Manuel Rego Casasnovas,
  Marc Hoyois,
  Marc-André Choquette, 
  Marc-André Lafortune,
  Marco Zehe,
  Marcus Bointon,
  Marcus Otterström,
  Marijn Kruisselbrink,
  Mark Amery,
  Mark Birbeck,
  Mark Davis,
  Mark Green,
  Mark Miller,
  Mark Nottingham,
  Mark Pilgrim,
  Mark Rogers, 
  Mark Rowe,
  Mark Schenk,
  Mark Vickers,
  Mark Wilton-Jones,
  Markus Cadonau,
  Markus Stange,
  Martijn van der Ven,
  Martijn Wargers,
  Martin Atkins,
  Martin Chaov,
  Martin Dürst,
  Martin Honnen,
  Martin Janecke,
  Martin Kutschker,
  Martin Nilsson,
  Martin Thomson,
  Masataka Yakura,
  Masatoshi Kimura,
  Mason Freed, 
  Mason Mize,
  Mathias Bynens,
  Mathieu Henri,
  Matias Larsson,
  Matt Brubeck,
  Matt Di Pasquale,
  Matt Falkenhagen,
  Matt Giuca, 
  Matt Harding,
  Matt Schmidt,
  Matt Wright,
  Matthew Gaudet, 
  Matthew Gregan,
  Matthew Mastracci,
  Matthew Noorenberghe,
  Matthew Raymond,
  Matthew Thomas,
  Matthew Tylee Atkinson, 
  Mattias Waldau,
  Max Romantschuk,
  Maxim Tsoy, 
  Mayeul Cantan,
  Menachem Salomon,
  Menno van Slooten,
  Micah Dubinko,
  Micah Nerren,
  Michael 'Ratt' Iannarelli,
  Michael A. Nachbaur,
  Michael A. Puls II,
  Michael Carter,
  Michael Daskalov,
  Michael Day,
  Michael Dyck,
  Michael Enright,
  Michael Ficarra,
  Michael Gratton,
  Michael Kohler,
  Michael McKelvey,
  Michael Nordman,
  Michael Powers,
  Michael Rakowski,
  Michael(tm) Smith,
  Michael Walmsley,
  Michal Zalewski,
  Michel Buffa,
  Michel Fortin,
  Michelangelo De Simone,
  Michiel van der Blonk,
  Miguel Casas-Sanchez,
  Mihai Şucan,
  Mihai Parparita,
  Mike Brown,
  Mike Dierken,
  Mike Dixon,
  Mike Hearn,
  Mike Pennisi,
  Mike Schinkel,
  Mike Shaver,
  Mikko Rantalainen,
  Mingye Wang,
  Mirko Brodesser,
  Mohamed Zergaoui,
  Mohammad Al Houssami,
  Mohammad Reza Zakerinasab,
  Momdo Nakamura,
  Morten Stenshorne,
  Mounir Lamouri,
  Ms2ger,
  mtrootyy,
  邱慕安 (Mu-An Chiou),
  Mukilan Thiyagarajan,
  Mustaq Ahmed,
  Myles Borins,
  Nadia Heninger,
  Nate Chapin,
  NARUSE Yui,
  Navid Zolghadr,
  Neil Deakin,
  Neil Rashbrook,
  Neil Soiffer,
  Nereida Rondon,
  networkException,
  Nicholas Shanks,
  Nicholas Stimpson,
  Nicholas Zakas,
  Nickolay Ponomarev,
  Nicolas Gallagher,
  Nicolas Pena Moreno,
  Nicolò Ribaudo,
  Nidhi Jaju,
  Nikki Bee,
  Niklas Gögge,
  Nina Satragno,
  Noah Mendelsohn,
  Noah Slater,
  Noam Rosenthal,
  Noel Gordon,
  Nolan Waite,
  NoozNooz42,
  Norbert Lindenberg,
  Oisín Nolan, 
  Ojan Vafai,
  Olaf Hoffmann,
  Olav Junker Kjær,
  Oldřich Vetešník,
  Oli Studholme,
  Oliver Hunt,
  Oliver Rigby,
  Olivia (Xiaoni) Lai, 
  Olivier Gendrin,
  Olli Pettay,
  Ondřej Žára, 
  Ori Avtalion,
  Oriol Brufau,
  oSand, 
  Pablo Flouret,
  Patrick Dark,
  Patrick Garies,
  Patrick H. Lauke,
  Patrik Persson,
  Paul Adenot,
  Paul Lewis,
  Paul Norman,
  Per-Erik Brodin,
  一丝 (percyley), 
  Perry Smith,
  Peter Beverloo,
  Peter Karlsson,
  Peter Kasting,
  Peter Moulder,
  Peter Occil,
  Peter Stark,
  Peter Van der Beken,
  Peter van der Zee,
  Peter-Paul Koch,
  Phil Pickering,
  Philip Ahlberg,
  Philip Brembeck, 
  Philip Taylor,
  Philip TAYLOR,
  Philippe De Ryck,
  Pierre-Arnaud Allumé,
  Pierre-Marie Dartus,
  Pierre-Yves Gérardy,
  Piers Wombwell, 
  Pooja Sanklecha,
  Prashant Hiremath,
  Prashanth Chandra,
  Prateek Rungta,
  Pravir Gupta,
  Prayag Verma,
  李普君 (Pujun Li),
  Rachid Finge,
  Rafael Weinstein,
  Rafał Miłecki,
  Rahim Abdi,
  Rahul Purohit,
  Raj Doshi,
  Rajas Moonka,
  Rakina Zata Amni,
  Ralf Stoltze,
  Ralph Giles,
  Raphael Champeimont,
  Rebecca Star,
  Remci Mizkur,
  Remco,
  Remy Sharp,
  Rene Saarsoo,
  Rene Stach,
  Ric Hardacre,
  Rich Clark,
  Rich Doughty,
  Richa Rupela,
  Richard Gibson,
  Richard Ishida,
  Richard Torres,
  Ricky Mondello,
  Rigo Wenning,
  Rikkert Koppes,
  Rimantas Liubertas,
  Riona Macnamara,
  Rob Buis,
  Rob Ennals,
  Rob Jellinghaus,
  Rob S,
  Rob Smith,
  Robert Blaut,
  Robert Collins,
  Robert Hogan,
  Robert Kieffer,
  Robert Linder,
  Robert Millan,
  Robert O'Callahan,
  Robert Sayre,
  Robin Berjon,
  Robin Schaufler,
  Rodger Combs,
  Roland Steiner,
  Roma Matusevich,
  Romain Deltour,
  Roman Ivanov,
  Roy Fielding,
  Rune Lillesveen,
  Russell Bicknell,
  Ruud Steltenpool,
  Ryan King,
  Ryan Landay,
  Ryan Sleevi,
  Ryo Kajiwara, 
  Ryo Kato,
  Ryosuke Niwa,
  S. Mike Dierken,
  Salvatore Loreto,
  Sam Atkins, 
  Sam Dutton,
  Sam Kuper,
  Sam Ruby,
  Sam Sneddon, 
  Sam Weinig,
  Samikshya Chand,
  Samuel Bronson,
  Samy Kamkar,
  Sander van Lambalgen,
  Sanjoy Pal,
  Sanket Joshi,
  Sarah Gebauer,
  Sarven Capadisli,
  Satrujit Behera,
  Sayan Sivakumaran,
  Schalk Neethling,
  Scott Beardsley,
  Scott González,
  Scott Hess,
  Scott Miles,
  Scott O'Hara,
  Sean B. Palmer, 
  Sean Feng,
  Sean Fraser,
  Sean Hayes,
  Sean Hogan,
  Sean Knapp,
  Sebastian Markbåge,
  Sebastian Schnitzenbaumer,
  Sendil Kumar N,
  Seth Call,
  Seth Dillingham,
  Shannon Moeller,
  Shanti Rao,
  Shaun Inman,
  Shiino Yuki, 
  贺师俊 (HE Shi-Jun), 
  Shiki Okasaka,
  Shivani Sharma,
  shreyateeza, 
  Shubheksha Jalan,
  Sidak Singh Aulakh,
  Sierk Bornemann,
  Sigbjørn Finne,
  Sigbjørn Vik,
  Silver Ghost, 
  Silvia Pfeiffer,
  Šime Vidas,
  Simon Fraser,
  Simon Montagu,
  Simon Sapin,
  Yu Han, 
  Simon Spiegel,
  Simon Wülker, 
  Siye Liu,
  skeww, 
  Smylers,
  Srirama Chandra Sekhar Mogali,
  Stanton McCandlish,
  stasoid, 
  Stefan Håkansson,
  Stefan Haustein,
  Stefan Santesson,
  Stefan Schumacher,
  Ştefan Vargyas,
  Stefan Weiss,
  Steffen Meschkat,
  Stephen Chenney,
  Stephen Ma,
  Stephen Stewart,
  Stephen White,
  Steve Comstock,
  Steve Faulkner,
  Steve Fink,
  Steve Orvell,
  Steve Runyon,
  Steven Bennett,
  Steven Bingler,
  Steven Garrity,
  Steven Tate,
  Stewart Brodie,
  Stuart Ballard,
  Stuart Langridge,
  Stuart Parmenter,
  Subramanian Peruvemba,
  Sudhanshu Jaiswal,
  sudokus999, 
  Sunava Dutta,
  Surma,
  Susan Borgrink,
  Susan  Lesch,
  Sylvain Pasche,
  T.J. Crowder, 
  Tab Atkins-Bittner,
  Taiju Tsuiki,
  Takashi Toyoshima,
  Takayoshi Kochi,
  Takeshi Yoshino,
  <span lang="tr">Tantek Çelik</span>,
  田村健人 (Kent TAMURA),
  Tawanda Moyo, 
  Taylor Hunt,
  Ted Mielczarek,
  Terence Eden, 
  Terrence Wood,
  Tetsuharu OHZEKI,
  Theresa O'Connor,
  Thijs van der Vossen,
  Thomas Broyer,
  Thomas Koetter,
  Thomas O'Connor,
  Tim Altman,
  Tim Dresser,
  Tim Flynn, 
  Tim Johansson,
  Tim Nguyen, 
  Tim Perry,
  Tim van der Lippe,
  TJ VanToll,
  Tobias Schneider,
  Tobie Langel,
  Toby Inkster,
  Todd Moody,
  Tom Baker,
  Tom Pike,
  Tom Schuster,
  Tom ten Thij,
  Tomasz Jakut, 
  Tomek Wytrębowicz,
  Tommy Thorsen,
  Tony Ross,
  Tooru Fujisawa,
  Toru Kobayashi,
  Traian Captan,
  Travis Leithead,
  Trevor Rowbotham,
  Trevor Saunders,
  Trey Eckels,
  triple-underscore, 
  Tristan Fraipont, 
  Tristan Parisot,  
  保呂 毅 (Tsuyoshi Horo),
  Tyler Close,
  Valentin Gosu,
  Vardhan Gupta,
  Vas Sudanagunta,
  Veli Şenol,
  Victor Carbune,
  Victor Costan,
  Vipul Snehadeep Chawathe,
  Vitya Muhachev,
  Vlad Levin,
  Vladimir Katardjiev,
  Vladimir Vukićević,
  Vyacheslav Aristov,
  voracity,
  Walter Steiner,
  Wakaba,
  Wayne Carr,
  Wayne Pollock,
  Wellington Fernando de Macedo,
  Wenson Hsieh,
  Weston Ruter,
  Wilhelm Joys Andersen,
  Will Levine,
  Will Ray,
  William Chen,
  William Swanson,
  Willy Martin Aguirre Rodriguez,
  Wladimir Palant,
  Wojciech Mach,
  Wolfram Kriesing,
  Xan Gregg,
  xenotheme,
  XhmikosR,
  Xida Chen,
  Xidorn Quan,
  Xue Fuqiao,
  Yang Chen,
  Yao Xiao,
  Yash Handa,
  Yay295,
  Ye-Kui Wang,
  Yehuda Katz,
  Yi Xu,
  Yi-An Huang,
  Yngve Nysaeter Pettersen,
  Yoav Weiss,
  Yonathan Randolph,
  Yu Huojiang,
  Yuki Okushi, 
  Yury Delendik,
  平野裕 (Yutaka Hirano),
  Yuzo Fujishima,
  西條柚 (Yuzu Saijo),
  Zhenbin Xu,
  张智强 (Zhiqiang Zhang),
  Zoltan Herczeg,
  Zyachel,
  and
  Øistein E. Andersen,

  for their useful comments, both large and small, that have led to changes to this specification
  over the years.</p>

  <p>Thanks also to everyone who has ever posted about HTML to their blogs, public mailing lists, or
  forums, including all the contributors to the <a href="https://www.w3.org/html/wg/lists/">various
  W3C HTML WG lists</a> and the <a href="https://whatwg.org/mailing-list">various WHATWG
  lists</a>.

  </p><p>Special thanks to Richard Williamson for creating the first implementation of
  <code id="acknowledgments:the-canvas-element"><a href="#the-canvas-element">canvas</a></code> in Safari, from which the canvas feature was designed.</p>

  <p>Special thanks also to the Microsoft employees who first implemented the event-based
  drag-and-drop mechanism, <code id="acknowledgments:attr-contenteditable"><a href="#attr-contenteditable">contenteditable</a></code>, and other
  features first widely deployed by the Windows Internet Explorer browser.</p>

  <p>Special thanks and $10,000 to David Hyatt who came up with a broken implementation
  of the <a href="#adoptionAgency">adoption agency algorithm</a> that the editor had to reverse
  engineer and fix before using it in the parsing section.</p>

  <p>Thanks to the participants of the microdata usability study for allowing us to use their
  mistakes as a guide for designing the microdata feature.</p>

  <p>Thanks to the many sources that provided inspiration for the examples used in the
  specification.</p>

  <p>Thanks also to the Microsoft blogging community for some ideas, to the attendees of the W3C
  Workshop on Web Applications and Compound Documents for inspiration, to the #mrt crew, the #mrt.no
  crew, and the #whatwg crew, and to Pillar and Hedral for their ideas and support.</p>

  <p>Thanks to Igor Zhbanov for generating PDF versions of the specification.</p>

  <p>Special thanks to the <a href="https://www.w3.org/community/respimg/">RICG</a> for developing
  the <code id="acknowledgments:the-picture-element"><a href="#the-picture-element">picture</a></code> element and related features; in particular thanks to Adrian Bateman,
  Bruce Lawson, David Newton, Ilya Grigorik, John Schoenick, Leon de Rijke, Mat Marquis, Marcos
  Cáceres, Tab Atkins, Theresa O'Connor, and Yoav Weiss for their contributions.</p>

  <p>Special thanks to the <a href="https://www.w3.org/WebPlatform/WG/">WPWG</a> for incubating the
  <a href="#custom-elements">custom elements</a> feature. In particular, thanks to David Hyatt and
  Ian Hickson for their influence through the XBL specifications, Dimitri Glazkov for the first
  draft of the custom elements specification, and to
  Alex Komoroske,
  Alex Russell,
  Andres Rios,
  Boris Zbarsky,
  Brian Kardell,
  Daniel Buchner,
  Dominic Cooney,
  Erik Arvidsson,
  Elliott Sprehn,
  Hajime Morrita,
  Hayato Ito,
  Jan Miksovsky,
  Jonas Sicking,
  Olli Pettay,
  Rafael Weinstein,
  Roland Steiner,
  Ryosuke Niwa,
  Scott Miles,
  Steve Faulkner,
  Steve Orvell,
  Tab Atkins,
  Theresa O'Connor,
  Tim Perry, and
  William Chen
  for their contributions.</p>

  <p>Special thanks to the <a href="https://www.w3.org/Style/CSS/members">CSSWG</a> for developing
  the <a href="#worklets">worklets</a>. In particular, thanks to Ian Kilpatrick for his work as
  editor of the original worklets specification.</p>

  <p>Special thanks to the <a href="https://wicg.io/">WICG</a> for incubating the <a href="#speculative-loading">speculative loading</a> feature. In particular, thanks to Jeremy Roman
  for his work as editor of the original speculation rules and prefetch specifications.</p>

  <p>For about ten years starting in 2003, this standard was almost entirely written by Ian Hickson
  (<a href="https://www.google.com/">Google</a>, <a href="mailto:ian@hixie.ch">ian@hixie.ch</a>).</p>

  <p>Starting in 2015, the editor group expanded. It is currently maintained by
  <a href="https://annevankesteren.nl/">Anne van Kesteren</a> (<a href="https://www.apple.com/">Apple</a>, <a href="mailto:annevk@annevk.nl">annevk@annevk.nl</a>),
  <a href="https://domenic.me/">Domenic Denicola</a> (<a href="https://www.google.com/">Google</a>, <a href="mailto:d@domenic.me">d@domenic.me</a>)
  <a href="https://domfarolino.com">Dominic Farolino</a> (<a href="https://www.google.com/">Google</a>, <a href="mailto:domfarolino@gmail.com">domfarolino@gmail.com</a>),
  <a href="https://foolip.org/">Philip Jägenstedt</a> (<a href="https://www.google.com/">Google</a>, <a href="mailto:philip@foolip.org">philip@foolip.org</a>), and
  Simon Pieters (<a href="https://www.mozilla.org/">Mozilla</a>, <a href="mailto:zcorpan@gmail.com">zcorpan@gmail.com</a>).</p>

  


  <h2 id="ipr" class="no-num">Intellectual property rights<a href="#ipr" class="self-link"></a></h2>

  <div itemtype="http://n.whatwg.org/work" itemscope="">
   <p>The image in the introduction is based on <a itemprop="work" href="https://www.flickr.com/photos/wonderlane/2986252088/">a photo</a>
   by <a itemprop="https://creativecommons.org/ns#attributionURL" href="https://www.flickr.com/photos/wonderlane/">Wonderlane</a>.
   (<a itemprop="license" href="https://creativecommons.org/licenses/by/2.0/">CC BY 2.0</a>)
  </p></div>

  <div itemtype="http://n.whatwg.org/work" itemscope="">
   <p>The image of the wolf in the embedded content introduction is based on <a itemprop="work" href="https://commons.wikimedia.org/wiki/File:WolfRunningInSnow.jpg">a photo</a>
   by <a itemprop="http://creativecommons.org/ns#attributionURL" href="https://commons.wikimedia.org/wiki/File:WolfRunningInSnow.jpg">Barry O'Neill</a>.
   (<a itemprop="license" href="https://en.wikipedia.org/wiki/Public_domain">Public domain</a>)
  </p></div>

  <div itemtype="http://n.whatwg.org/work" itemscope="">
   <p>The image of the kettlebell swing in the embedded content introduction is based on <a itemprop="work" href="https://pixabay.com/en/functional-mobility-articular-606568/">a photo</a>
   by <a itemprop="http://creativecommons.org/ns#attributionURL" href="https://pixabay.com/en/users/506563-506563/">kokkarina</a>.
   (<a itemprop="license" href="https://creativecommons.org/publicdomain/zero/1.0/">CC0 1.0</a>)
  </p></div>

  <div itemtype="http://n.whatwg.org/work" itemscope="">
   <p>The Blue Robot Player sprite used in the canvas demo is based on
   <a itemprop="work" href="https://johncolburn.deviantart.com/art/Blue-Robot-Player-Sprite-323813997">a work</a> by
   <a itemprop="https://creativecommons.org/ns#attributionURL" href="https://johncolburn.deviantart.com/">JohnColburn</a>.
   (<a itemprop="license" href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>)</p>
  </div>

  <div itemtype="http://n.whatwg.org/work" itemscope="">
   <p>The photograph of robot 148 climbing the tower at the FIRST Robotics Competition 2013 Silicon Valley Regional is based on
   <a itemprop="work" href="https://www.flickr.com/photos/lenore-m/8631391979/">a work</a> by
   <a itemprop="https://creativecommons.org/ns#attributionURL" href="https://www.flickr.com/photos/lenore-m/">Lenore Edman</a>.
   (<a itemprop="license" href="https://creativecommons.org/licenses/by/2.0/">CC BY 2.0</a>)</p>
  </div>

  <div itemtype="http://n.whatwg.org/work" itemscope="">
   <p>The diagram showing how <code id="ipr:attr-script-async"><a href="#attr-script-async">async</a></code> and <code id="ipr:attr-script-defer"><a href="#attr-script-defer">defer</a></code> impact <code id="ipr:the-script-element"><a href="#the-script-element">script</a></code> loading is based on a
   similar diagram from <a itemprop="work" href="https://peter.sh/experiments/asynchronous-and-deferred-javascript-execution-explained/">a
   blog post</a> by <a itemprop="https://creativecommons.org/ns#attributionURL" href="https://peter.sh/about/">Peter Beverloo</a>.
   (<a itemprop="license" href="https://creativecommons.org/publicdomain/zero/1.0/">CC0 1.0</a>)</p>
  </div>

  <div itemtype="http://n.whatwg.org/work" itemscope="">
   <p>The image decoding demo used to demonstrate module-based workers draws on some example code
   from <a itemprop="work" href="https://www.html5rocks.com/en/tutorials/canvas/imagefilters/">a
   tutorial</a> by <a itemprop="https://creativecommons.org/ns#attributionURL" href="https://www.fhtr.net/">Ilmari Heikkinen</a>.
   (<a itemprop="license" href="https://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>)</p>
  </div>

  <div itemtype="http://n.whatwg.org/work" itemscope="">
   <p>The <code>&lt;flag-icon&gt;</code> example was inspired by <a itemprop="work" href="https://github.com/stevenrskelton/flag-icon">a custom element</a> by <a itemprop="https://creativecommons.org/ns#attributionURL" href="http://stevenskelton.ca/">Steven
   Skelton</a>. (<a itemprop="license" href="https://opensource.org/licenses/MIT">MIT</a>)</p>
  </div>

  <p itemtype="http://n.whatwg.org/work" itemscope="">Part of the revision history of the
  <code id="ipr:the-picture-element"><a href="#the-picture-element">picture</a></code> element and related features can be found in the <a href="https://github.com/ResponsiveImagesCG/picture-element"><code>ResponsiveImagesCG/picture-element</code>
  repository</a>, which is available under the <a itemprop="license" href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Software and
  Document License</a>.</p>

  <p itemtype="http://n.whatwg.org/work" itemscope="">Part of the revision history of the <code id="ipr:meta-theme-color"><a href="#meta-theme-color">theme-color</a></code> metadata name can be found in the <a href="https://github.com/whatwg/meta-theme-color"><code>whatwg/meta-theme-color</code>
  repository</a>, which is available under <a itemprop="license" href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>.</p>

  <p itemtype="http://n.whatwg.org/work" itemscope="">Part of the revision history of the <a href="#custom-elements">custom elements</a> feature can be found in the <a href="https://github.com/w3c/webcomponents"><code>w3c/webcomponents</code> repository</a>, which
  is available under the <a itemprop="license" href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Software and
  Document License</a>.</p>

  <p itemtype="http://n.whatwg.org/work" itemscope="">Part of the revision history of the <code id="ipr:dom-innertext"><a href="#dom-innertext">innerText</a></code> getter and setter can be found in the <a href="https://github.com/rocallahan/innerText-spec"><code>rocallahan/innerText-spec</code>
  repository</a>, which is available under <a itemprop="license" href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>.</p>

  <p itemtype="http://n.whatwg.org/work" itemscope="">Part of the revision history of the <a href="#worklets">worklets</a> feature can be found in the <a href="https://github.com/w3c/css-houdini-drafts"><code>w3c/css-houdini-drafts</code>
  repository</a>, which is available under the <a itemprop="license" href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Software and
  Document License</a>.</p>

  <p itemtype="http://n.whatwg.org/work" itemscope="">Part of the revision history of the <a href="#import-maps">import maps</a> feature can be found in the <a href="https://github.com/WICG/import-maps"><code>WICG/import-maps</code>
  repository</a>, which is available under the <a itemprop="license" href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Software and
  Document License</a>.</p>

  <p itemtype="http://n.whatwg.org/work" itemscope="">Part of the revision history of the <a href="#navigation-api">navigation API</a> feature can be found in the <a href="https://github.com/WICG/navigation-api"><code>WICG/navigation-api</code>
  repository</a>, which is available under the <a itemprop="license" href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Software and
  Document License</a>.</p>

  <p itemtype="http://n.whatwg.org/work" itemscope="">Part of the revision history of the <a href="#close-requests-and-close-watchers">Close requests and close watchers</a> section can be
  found in the <a href="https://github.com/WICG/close-watcher"><code>WICG/close-watcher</code>
  repository</a>, which is available under the <a itemprop="license" href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Software and
  Document License</a>.</p>

  <p itemtype="http://n.whatwg.org/work" itemscope="">Part of the revision history of the <a href="#speculative-loading">Speculative loading</a> section can be
  found in the <a href="https://github.com/WICG/nav-speculation"><code>WICG/nav-speculation</code>
  repository</a>, which is available under the <a itemprop="license" href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Software and
  Document License</a>.</p>

  <p>Copyright © WHATWG (Apple, Google, Mozilla, Microsoft). This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0
  International License</a>. To the extent portions of it are incorporated into source code, such
  portions in the source code are licensed under the <a rel="license" href="https://opensource.org/licenses/BSD-3-Clause">BSD 3-Clause License</a> instead.</p>

  <p>This is the Living Standard. Those interested in the patent-review version
  should view the <a href="/review-drafts/2025-07/">Living Standard Review Draft</a>.</p>
 


</body></html>